Skip to content

Release #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ const BaseExample = () => {
<Calendar.Item name="time2" label="时间"/>, <TimeStep.Item name="timeStep" label="时间2"/>,
<CalendarRange.Item name="time3" label="时间段"/>,
<CalendarTimeRange.Item name="time2" label="面试时间2" rule="REQ" durationHidden/>,
<UserListSelect.Item name="user" label="用户" rule="REQ"/>,
<UserListSelect.Item name="user" label="用户" rule="REQ" disabledValues={[1, 2, 3]}/>,
<Upload.Item name="attachment" label="附件" rule="REQ"/>,
<AutoComplete.Item name="school" label="学校" rule="REQ" api={{
loader: ({data}) => {
Expand All @@ -976,8 +976,8 @@ const BaseExample = () => {
<Space direction={"vertical"}>
<View>列表</View>
<Form onSubmit={(data) => {
console.log(data);
}}
console.log(data);
}}
>
<CommonListTitle
subtitle="(填写工作经历)"
Expand Down
6 changes: 3 additions & 3 deletions doc/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const BaseExample = () => {
<Calendar.Item name="time2" label="时间"/>, <TimeStep.Item name="timeStep" label="时间2"/>,
<CalendarRange.Item name="time3" label="时间段"/>,
<CalendarTimeRange.Item name="time2" label="面试时间2" rule="REQ" durationHidden/>,
<UserListSelect.Item name="user" label="用户" rule="REQ"/>,
<UserListSelect.Item name="user" label="用户" rule="REQ" disabledValues={[1, 2, 3]}/>,
<Upload.Item name="attachment" label="附件" rule="REQ"/>,
<AutoComplete.Item name="school" label="学校" rule="REQ" api={{
loader: ({data}) => {
Expand All @@ -147,8 +147,8 @@ const BaseExample = () => {
<Space direction={"vertical"}>
<View>列表</View>
<Form onSubmit={(data) => {
console.log(data);
}}
console.log(data);
}}
>
<CommonListTitle
subtitle="(填写工作经历)"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kne/mini-core",
"version": "2.1.1",
"version": "2.1.2",
"dependencies": {
"@kne/antd-taro": "^1.0.35",
"@kne/compose": "^0.1.0",
Expand Down
101 changes: 63 additions & 38 deletions src/Calendar/CalendarPopup.js
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;
82 changes: 54 additions & 28 deletions src/Calendar/CalendarRangePopup.js
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;
82 changes: 54 additions & 28 deletions src/Calendar/TimeRangePopup.js
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;
Loading
Loading