-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from kne-union/release
Release
- Loading branch information
Showing
13 changed files
with
525 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,81 @@ | ||
import React, {useState} from 'react'; | ||
import {Popup, SafeArea} from '@kne/antd-taro'; | ||
import React, { useState } from 'react'; | ||
import { Popup, SafeArea } from '@kne/antd-taro'; | ||
import style from './style.module.scss'; | ||
import useControlValue from "@kne/use-control-value"; | ||
import useControlValue from '@kne/use-control-value'; | ||
import CalendarView from './CalendarView'; | ||
import classnames from 'classnames'; | ||
import {View} from '@tarojs/components'; | ||
import { View } from '@tarojs/components'; | ||
import computedIsDisabled from './computedIsDisabled'; | ||
|
||
const CalendarPopup = ({className, onClose, onCancel, isRootPortal, value, onChange, placeholder, ...props}) => { | ||
const [active, setActive] = useControlValue(props, { | ||
defaultValue: 'defaultOpen', value: 'open', onChange: 'onOpenChange' | ||
}); | ||
const [current, setCurrent] = useState(value); | ||
return <Popup className={classnames(style['popup'], 'adm-picker-popup')} isRootPortal={isRootPortal} hasSafeArea={false} | ||
position="bottom" open={active} | ||
onOpenChange={(open) => { | ||
if (open) { | ||
return; | ||
} | ||
setActive(false); | ||
onClose?.(); | ||
setCurrent(value); | ||
}}> | ||
|
||
{active && <><View className={`adm-picker-header`}> | ||
const CalendarPopup = ({ className, onClose, onCancel, isRootPortal, value, onChange, placeholder, ...props }) => { | ||
const [active, setActive] = useControlValue(props, { | ||
defaultValue: 'defaultOpen', | ||
value: 'open', | ||
onChange: 'onOpenChange' | ||
}); | ||
const [current, setCurrent] = useState(value); | ||
return ( | ||
<Popup | ||
className={classnames(style['popup'], 'adm-picker-popup')} | ||
isRootPortal={isRootPortal} | ||
hasSafeArea={false} | ||
position="bottom" | ||
open={active} | ||
onOpenChange={open => { | ||
if (open) { | ||
return; | ||
} | ||
setActive(false); | ||
onClose?.(); | ||
setCurrent(value); | ||
}} | ||
> | ||
{active && ( | ||
<> | ||
<View className={`adm-picker-header`}> | ||
<View | ||
className={`adm-picker-header-button`} | ||
onClick={() => { | ||
onCancel?.(); | ||
setActive(false); | ||
onClose?.(); | ||
}} | ||
className={`adm-picker-header-button`} | ||
onClick={() => { | ||
onCancel?.(); | ||
setActive(false); | ||
onClose?.(); | ||
}} | ||
> | ||
取消 | ||
取消 | ||
</View> | ||
<View className={`adm-picker-header-title`}>{placeholder}</View> | ||
<View | ||
className={classnames(`adm-picker-header-button`)} | ||
onClick={() => { | ||
setActive(false); | ||
onClose?.(); | ||
onChange?.(current); | ||
}} | ||
className={classnames(`adm-picker-header-button`)} | ||
onClick={() => { | ||
setActive(false); | ||
onClose?.(); | ||
if ( | ||
computedIsDisabled(current, { | ||
minDate: props.minDate, | ||
maxDate: props.maxDate, | ||
disabledDate: props.disabledDate | ||
}) | ||
) { | ||
return; | ||
} | ||
onChange?.(current); | ||
}} | ||
> | ||
确定 | ||
确定 | ||
</View> | ||
</View><CalendarView {...props} value={current} onChange={setCurrent}/></>} | ||
<SafeArea position="bottom"/> | ||
</View> | ||
<CalendarView {...props} value={current} onChange={setCurrent} /> | ||
</> | ||
)} | ||
<SafeArea position="bottom" /> | ||
</Popup> | ||
); | ||
}; | ||
|
||
CalendarPopup.defaultProps = { | ||
value: new Date(), placeholder: '请选择日期', isRootPortal: false | ||
value: new Date(), | ||
placeholder: '请选择日期', | ||
isRootPortal: false | ||
}; | ||
|
||
export default CalendarPopup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,65 @@ | ||
import React, {useState} from 'react'; | ||
import {Popup, SafeArea} from '@kne/antd-taro'; | ||
import React, { useState } from 'react'; | ||
import { Popup, SafeArea } from '@kne/antd-taro'; | ||
import style from './style.module.scss'; | ||
import useControlValue from "@kne/use-control-value"; | ||
import useControlValue from '@kne/use-control-value'; | ||
import CalendarRangeView from './CalendarRangeView'; | ||
import classnames from 'classnames'; | ||
import {View} from '@tarojs/components'; | ||
import { View } from '@tarojs/components'; | ||
import computedIsDisabled from './computedIsDisabled'; | ||
|
||
const CalendarRangePopup = ({className, onClose, onCancel, isRootPortal, value, onChange, placeholder, ...props}) => { | ||
const [active, setActive] = useControlValue(props, { | ||
defaultValue: 'defaultOpen', value: 'open', onChange: 'onOpenChange' | ||
}); | ||
const [current, setCurrent] = useState(value); | ||
return <Popup className={classnames(style['popup'], 'adm-picker-popup')} isRootPortal={false} hasSafeArea={false} | ||
position="bottom" open={active} | ||
onOpenChange={(open) => { | ||
if (open) { | ||
return; | ||
} | ||
setActive(false); | ||
onClose?.(); | ||
setCurrent(value); | ||
}}> | ||
|
||
{active && <CalendarRangeView {...props} value={current} onChange={setCurrent}/>} | ||
<View className={classnames(`adm-picker-header-button`, style['confirm-btn'])} onClick={() => { | ||
setActive(false); | ||
onClose?.(); | ||
onChange?.(current); | ||
}}>确定</View> | ||
<SafeArea position="bottom"/> | ||
const CalendarRangePopup = ({ className, onClose, onCancel, isRootPortal, value, onChange, placeholder, ...props }) => { | ||
const [active, setActive] = useControlValue(props, { | ||
defaultValue: 'defaultOpen', | ||
value: 'open', | ||
onChange: 'onOpenChange' | ||
}); | ||
const [current, setCurrent] = useState(value); | ||
return ( | ||
<Popup | ||
className={classnames(style['popup'], 'adm-picker-popup')} | ||
isRootPortal={false} | ||
hasSafeArea={false} | ||
position="bottom" | ||
open={active} | ||
onOpenChange={open => { | ||
if (open) { | ||
return; | ||
} | ||
setActive(false); | ||
onClose?.(); | ||
setCurrent(value); | ||
}} | ||
> | ||
{active && <CalendarRangeView {...props} value={current} onChange={setCurrent} />} | ||
<View | ||
className={classnames(`adm-picker-header-button`, style['confirm-btn'])} | ||
onClick={() => { | ||
setActive(false); | ||
onClose?.(); | ||
if ( | ||
current.some(target => | ||
computedIsDisabled(target, { | ||
minDate: props.minDate, | ||
maxDate: props.maxDate, | ||
disabledDate: props.disabledDate | ||
}) | ||
) | ||
) { | ||
return; | ||
} | ||
onChange?.(current); | ||
}} | ||
> | ||
确定 | ||
</View> | ||
<SafeArea position="bottom" /> | ||
</Popup> | ||
); | ||
}; | ||
|
||
CalendarRangePopup.defaultProps = { | ||
value: [], placeholder: '请选择日期' | ||
value: [], | ||
placeholder: '请选择日期' | ||
}; | ||
|
||
export default CalendarRangePopup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,66 @@ | ||
import React, {useState} from 'react'; | ||
import {Popup, SafeArea} from '@kne/antd-taro'; | ||
import React, { useState } from 'react'; | ||
import { Popup, SafeArea } from '@kne/antd-taro'; | ||
import style from './style.module.scss'; | ||
import useControlValue from "@kne/use-control-value"; | ||
import useControlValue from '@kne/use-control-value'; | ||
import TimeRangeView from './TimeRangeView'; | ||
import classnames from 'classnames'; | ||
import {View} from '@tarojs/components'; | ||
import { View } from '@tarojs/components'; | ||
import dayjs from 'dayjs'; | ||
import computedIsDisabled from './computedIsDisabled'; | ||
|
||
const TimeRangePopup = ({className, onClose, isRootPortal, value, onChange, ...props}) => { | ||
const [active, setActive] = useControlValue(props, { | ||
defaultValue: 'defaultOpen', value: 'open', onChange: 'onOpenChange' | ||
}); | ||
const [current, setCurrent] = useState(value); | ||
return <Popup className={classnames(style['popup'], 'adm-picker-popup')} isRootPortal={isRootPortal} | ||
hasSafeArea={false} | ||
position="bottom" open={active} | ||
onOpenChange={(open) => { | ||
if (open) { | ||
return; | ||
} | ||
setActive(false); | ||
onClose?.(); | ||
setCurrent(value); | ||
}}> | ||
{active && <TimeRangeView {...props} value={current} onChange={setCurrent}/>} | ||
<View className={classnames(`adm-picker-header-button`, style['confirm-btn'])} onClick={() => { | ||
setActive(false); | ||
onClose?.(); | ||
onChange?.(current); | ||
}}>确定</View> | ||
<SafeArea position="bottom"/> | ||
const TimeRangePopup = ({ className, onClose, isRootPortal, value, onChange, ...props }) => { | ||
const [active, setActive] = useControlValue(props, { | ||
defaultValue: 'defaultOpen', | ||
value: 'open', | ||
onChange: 'onOpenChange' | ||
}); | ||
const [current, setCurrent] = useState(value); | ||
return ( | ||
<Popup | ||
className={classnames(style['popup'], 'adm-picker-popup')} | ||
isRootPortal={isRootPortal} | ||
hasSafeArea={false} | ||
position="bottom" | ||
open={active} | ||
onOpenChange={open => { | ||
if (open) { | ||
return; | ||
} | ||
setActive(false); | ||
onClose?.(); | ||
setCurrent(value); | ||
}} | ||
> | ||
{active && <TimeRangeView {...props} value={current} onChange={setCurrent} />} | ||
<View | ||
className={classnames(`adm-picker-header-button`, style['confirm-btn'])} | ||
onClick={() => { | ||
setActive(false); | ||
onClose?.(); | ||
if ( | ||
current.some(target => | ||
computedIsDisabled(target, { | ||
minDate: props.minDate, | ||
maxDate: props.maxDate, | ||
disabledDate: props.disabledDate | ||
}) | ||
) | ||
) { | ||
return; | ||
} | ||
onChange?.(current); | ||
}} | ||
> | ||
确定 | ||
</View> | ||
<SafeArea position="bottom" /> | ||
</Popup> | ||
); | ||
}; | ||
|
||
TimeRangePopup.defaultProps = { | ||
value: [dayjs(new Date()).startOf('hour'), dayjs(new Date()).startOf('hour').add(1, 'hour')], isRootPortal: false | ||
value: [dayjs(new Date()).startOf('hour'), dayjs(new Date()).startOf('hour').add(1, 'hour')], | ||
isRootPortal: false | ||
}; | ||
|
||
export default TimeRangePopup; |
Oops, something went wrong.