@rainbow-oh/yee-c 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Button/button.d.ts +1 -1
- package/dist/cjs/CSV/download.d.ts +1 -1
- package/dist/cjs/Carousel/carousel.d.ts +2 -2
- package/dist/cjs/Carousel/carousel.js +9 -2
- package/dist/cjs/Carousel/interface.d.ts +5 -0
- package/dist/cjs/Drawer/style/index.less +4 -0
- package/dist/cjs/FloatButton/float-button.d.ts +1 -1
- package/dist/cjs/Form/demo/basic.js +2 -2
- package/dist/cjs/Form/style/index.less +15 -0
- package/dist/cjs/Input/style/index.less +0 -17
- package/dist/cjs/InputNumber/style/index.less +0 -29
- package/dist/cjs/PickerPanel/interface.d.ts +44 -2
- package/dist/cjs/PickerPanel/panels/DatePanel/DateBody.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/DatePanel/DateHeader.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/DatePanel/DateHeader.js +1 -1
- package/dist/cjs/PickerPanel/panels/DatePanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/DateTimePanel/index.d.ts +7 -1
- package/dist/cjs/PickerPanel/panels/DateTimePanel/index.js +18 -4
- package/dist/cjs/PickerPanel/panels/DecadePanel/DecadeBody.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/DecadePanel/DecadeBody.js +1 -1
- package/dist/cjs/PickerPanel/panels/DecadePanel/DecadeHeader.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/DecadePanel/DecadeHeader.js +1 -1
- package/dist/cjs/PickerPanel/panels/DecadePanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/DecadePanel/index.js +1 -1
- package/dist/cjs/PickerPanel/panels/Header.d.ts +13 -1
- package/dist/cjs/PickerPanel/panels/MonthPanel/MonthBody.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/MonthPanel/MonthHeader.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/MonthPanel/MonthHeader.js +1 -1
- package/dist/cjs/PickerPanel/panels/MonthPanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/MonthPanel/index.js +1 -1
- package/dist/cjs/PickerPanel/panels/PanelBody.d.ts +21 -1
- package/dist/cjs/PickerPanel/panels/PanelBody.js +3 -3
- package/dist/cjs/PickerPanel/panels/QuarterPanel/QuarterBody.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/QuarterPanel/QuarterHeader.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/QuarterPanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/RangePanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/RangePanel/index.js +2 -2
- package/dist/cjs/PickerPanel/panels/RangePanel/interface.d.ts +5 -5
- package/dist/cjs/PickerPanel/panels/TimePanel/TimeBody.d.ts +17 -1
- package/dist/cjs/PickerPanel/panels/TimePanel/TimeCell.d.ts +7 -1
- package/dist/cjs/PickerPanel/panels/TimePanel/TimeCell.js +1 -1
- package/dist/cjs/PickerPanel/panels/TimePanel/TimeColumn.d.ts +14 -1
- package/dist/cjs/PickerPanel/panels/TimePanel/TimeColumn.js +1 -1
- package/dist/cjs/PickerPanel/panels/TimePanel/TimeHeader.d.ts +4 -1
- package/dist/cjs/PickerPanel/panels/TimePanel/index.d.ts +9 -1
- package/dist/cjs/PickerPanel/panels/WeekPanel/WeekBody.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/WeekPanel/WeekHeader.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/WeekPanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/YearPanel/YearBody.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/YearPanel/YearBody.js +2 -2
- package/dist/cjs/PickerPanel/panels/YearPanel/YearHeader.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/YearPanel/YearHeader.js +7 -1
- package/dist/cjs/PickerPanel/panels/YearPanel/index.d.ts +2 -1
- package/dist/cjs/PickerPanel/panels/YearPanel/index.js +1 -1
- package/dist/cjs/PickerPanel/utils/pickerUtils.d.ts +7 -7
- package/dist/cjs/PickerPanel/utils/pickerUtils.js +2 -2
- package/dist/cjs/Select/style/index.less +0 -13
- package/dist/cjs/Selector/style/index.less +2 -137
- package/dist/cjs/TextArea/style/index.less +0 -17
- package/dist/cjs/hooks/useEvent.js +4 -1
- package/dist/cjs/style/size.css +1 -0
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +2 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Button/button.d.ts +1 -1
- package/dist/esm/CSV/download.d.ts +1 -1
- package/dist/esm/Carousel/carousel.d.ts +2 -2
- package/dist/esm/Carousel/carousel.js +5 -1
- package/dist/esm/Carousel/interface.d.ts +5 -0
- package/dist/esm/Drawer/style/index.less +4 -0
- package/dist/esm/FloatButton/float-button.d.ts +1 -1
- package/dist/esm/Form/demo/basic.js +4 -2
- package/dist/esm/Form/style/index.less +15 -0
- package/dist/esm/Input/style/index.less +0 -17
- package/dist/esm/InputNumber/style/index.less +0 -29
- package/dist/esm/PickerPanel/interface.d.ts +44 -2
- package/dist/esm/PickerPanel/panels/DatePanel/DateBody.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/DatePanel/DateHeader.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/DatePanel/DateHeader.js +1 -1
- package/dist/esm/PickerPanel/panels/DatePanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/DateTimePanel/index.d.ts +7 -1
- package/dist/esm/PickerPanel/panels/DateTimePanel/index.js +11 -7
- package/dist/esm/PickerPanel/panels/DecadePanel/DecadeBody.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/DecadePanel/DecadeBody.js +2 -1
- package/dist/esm/PickerPanel/panels/DecadePanel/DecadeHeader.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/DecadePanel/DecadeHeader.js +2 -1
- package/dist/esm/PickerPanel/panels/DecadePanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/DecadePanel/index.js +1 -1
- package/dist/esm/PickerPanel/panels/Header.d.ts +13 -1
- package/dist/esm/PickerPanel/panels/MonthPanel/MonthBody.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/MonthPanel/MonthHeader.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/MonthPanel/MonthHeader.js +2 -1
- package/dist/esm/PickerPanel/panels/MonthPanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/MonthPanel/index.js +1 -1
- package/dist/esm/PickerPanel/panels/PanelBody.d.ts +21 -1
- package/dist/esm/PickerPanel/panels/PanelBody.js +2 -4
- package/dist/esm/PickerPanel/panels/QuarterPanel/QuarterBody.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/QuarterPanel/QuarterHeader.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/QuarterPanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/RangePanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/RangePanel/index.js +2 -2
- package/dist/esm/PickerPanel/panels/RangePanel/interface.d.ts +5 -5
- package/dist/esm/PickerPanel/panels/TimePanel/TimeBody.d.ts +17 -1
- package/dist/esm/PickerPanel/panels/TimePanel/TimeCell.d.ts +7 -1
- package/dist/esm/PickerPanel/panels/TimePanel/TimeCell.js +1 -1
- package/dist/esm/PickerPanel/panels/TimePanel/TimeColumn.d.ts +14 -1
- package/dist/esm/PickerPanel/panels/TimePanel/TimeColumn.js +1 -1
- package/dist/esm/PickerPanel/panels/TimePanel/TimeHeader.d.ts +4 -1
- package/dist/esm/PickerPanel/panels/TimePanel/index.d.ts +9 -1
- package/dist/esm/PickerPanel/panels/WeekPanel/WeekBody.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/WeekPanel/WeekHeader.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/WeekPanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/YearPanel/YearBody.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/YearPanel/YearBody.js +3 -2
- package/dist/esm/PickerPanel/panels/YearPanel/YearHeader.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/YearPanel/YearHeader.js +2 -1
- package/dist/esm/PickerPanel/panels/YearPanel/index.d.ts +2 -1
- package/dist/esm/PickerPanel/panels/YearPanel/index.js +1 -1
- package/dist/esm/PickerPanel/picker-panel.js +3 -0
- package/dist/esm/PickerPanel/utils/pickerUtils.d.ts +7 -7
- package/dist/esm/PickerPanel/utils/pickerUtils.js +4 -10
- package/dist/esm/Select/style/index.less +0 -13
- package/dist/esm/Selector/style/index.less +2 -137
- package/dist/esm/TextArea/style/index.less +0 -17
- package/dist/esm/style/size.css +1 -0
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +2 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +2 -2
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +1 -1
- package/src/Carousel/carousel.tsx +14 -3
- package/src/Carousel/interface.ts +6 -0
- package/src/Cascader/cascader.tsx +3 -1
- package/src/Cascader/column.tsx +1 -1
- package/src/Drawer/style/index.less +4 -0
- package/src/Dropdown/dropdown.tsx +1 -1
- package/src/FloatButton/float-button.tsx +5 -3
- package/src/Form/demo/basic.tsx +2 -2
- package/src/Form/style/index.less +15 -0
- package/src/Input/style/index.less +0 -17
- package/src/InputNumber/style/index.less +0 -29
- package/src/PickerPanel/interface.ts +43 -2
- package/src/PickerPanel/panels/DatePanel/DateBody.tsx +2 -1
- package/src/PickerPanel/panels/DatePanel/DateHeader.tsx +3 -2
- package/src/PickerPanel/panels/DatePanel/index.tsx +2 -1
- package/src/PickerPanel/panels/DateTimePanel/index.tsx +12 -5
- package/src/PickerPanel/panels/DecadePanel/DecadeBody.tsx +3 -2
- package/src/PickerPanel/panels/DecadePanel/DecadeHeader.tsx +3 -2
- package/src/PickerPanel/panels/DecadePanel/index.tsx +3 -2
- package/src/PickerPanel/panels/Header.tsx +14 -1
- package/src/PickerPanel/panels/MonthPanel/MonthBody.tsx +2 -1
- package/src/PickerPanel/panels/MonthPanel/MonthHeader.tsx +3 -2
- package/src/PickerPanel/panels/MonthPanel/index.tsx +3 -2
- package/src/PickerPanel/panels/PanelBody.tsx +27 -5
- package/src/PickerPanel/panels/QuarterPanel/QuarterBody.tsx +2 -1
- package/src/PickerPanel/panels/QuarterPanel/QuarterHeader.tsx +2 -1
- package/src/PickerPanel/panels/QuarterPanel/index.tsx +2 -1
- package/src/PickerPanel/panels/RangePanel/index.tsx +11 -9
- package/src/PickerPanel/panels/RangePanel/interface.ts +5 -5
- package/src/PickerPanel/panels/TimePanel/TimeBody.tsx +21 -5
- package/src/PickerPanel/panels/TimePanel/TimeCell.tsx +9 -2
- package/src/PickerPanel/panels/TimePanel/TimeColumn.tsx +15 -2
- package/src/PickerPanel/panels/TimePanel/TimeHeader.tsx +5 -1
- package/src/PickerPanel/panels/TimePanel/index.tsx +10 -1
- package/src/PickerPanel/panels/WeekPanel/WeekBody.tsx +2 -1
- package/src/PickerPanel/panels/WeekPanel/WeekHeader.tsx +2 -1
- package/src/PickerPanel/panels/WeekPanel/index.tsx +2 -1
- package/src/PickerPanel/panels/YearPanel/YearBody.tsx +4 -3
- package/src/PickerPanel/panels/YearPanel/YearHeader.tsx +9 -3
- package/src/PickerPanel/panels/YearPanel/index.tsx +3 -2
- package/src/PickerPanel/picker-panel.tsx +5 -3
- package/src/PickerPanel/utils/pickerUtils.ts +17 -8
- package/src/Select/style/index.less +0 -13
- package/src/Selector/style/index.less +2 -137
- package/src/Splitter/hooks/useMove.ts +2 -2
- package/src/TextArea/style/index.less +0 -17
- package/src/hooks/useEvent.ts +7 -4
- package/src/hooks/useMergedState.ts +6 -4
- package/src/style/size.css +1 -0
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -16,13 +16,21 @@ import { GlobalContext } from '../Config-Provider';
|
|
|
16
16
|
import useElementSize from '../hooks/useElementSize';
|
|
17
17
|
import mergeContextToProps from '../utils/mergeContextToProps';
|
|
18
18
|
import Item from './carousel-item';
|
|
19
|
-
import type {
|
|
19
|
+
import type {
|
|
20
|
+
CarouselContextProps,
|
|
21
|
+
CarouselItemProps,
|
|
22
|
+
CarouselProps,
|
|
23
|
+
} from './interface';
|
|
20
24
|
|
|
21
25
|
import './style/index.less';
|
|
22
26
|
|
|
23
27
|
const DEFAULT_ANIMATION_DURATION = 500;
|
|
24
28
|
|
|
25
|
-
export const CarouselCtx = React.createContext({
|
|
29
|
+
export const CarouselCtx = React.createContext<CarouselContextProps>({
|
|
30
|
+
prefixCls: 'yee-carousel',
|
|
31
|
+
effect: 'scrollx',
|
|
32
|
+
current: 1,
|
|
33
|
+
});
|
|
26
34
|
|
|
27
35
|
const Carousel = React.forwardRef(
|
|
28
36
|
(baseprops: CarouselProps, ref: React.Ref<HTMLDivElement>) => {
|
|
@@ -249,7 +257,10 @@ const Carousel = React.forwardRef(
|
|
|
249
257
|
|
|
250
258
|
const renderFadeChilds = () => {
|
|
251
259
|
return React.Children.map(children, (child, index) => {
|
|
252
|
-
return React.cloneElement(
|
|
260
|
+
return React.cloneElement(
|
|
261
|
+
child as React.ReactElement<CarouselItemProps>,
|
|
262
|
+
{ index },
|
|
263
|
+
);
|
|
253
264
|
});
|
|
254
265
|
};
|
|
255
266
|
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export type SemanticDOM = 'dot' | 'prev' | 'next';
|
|
2
2
|
|
|
3
|
+
export interface CarouselContextProps {
|
|
4
|
+
prefixCls: string;
|
|
5
|
+
effect: 'fade' | 'scrollx';
|
|
6
|
+
current: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
3
9
|
export interface CarouselItemProps {
|
|
4
10
|
index: number;
|
|
5
11
|
style?: React.CSSProperties;
|
|
@@ -65,7 +65,9 @@ const Cascader = (baseprops: CascaderProps) => {
|
|
|
65
65
|
|
|
66
66
|
// Status variables for internal use
|
|
67
67
|
const [columns, setColumns] = useState<Array<FlattenOption[]>>([]);
|
|
68
|
-
const [expandedPath, setExpandedPath] = useState<
|
|
68
|
+
const [expandedPath, setExpandedPath] = useState<
|
|
69
|
+
Array<{ key: string; label: string }>
|
|
70
|
+
>([]);
|
|
69
71
|
const [searchValue, setSearchValue] = useState(''); // Input field input
|
|
70
72
|
// NOTE: popupVisible uses ref instead of state to avoid triggering re-renders
|
|
71
73
|
// This is intentional - it's only used for side effects tracking, not for rendering
|
package/src/Cascader/column.tsx
CHANGED
|
@@ -56,7 +56,7 @@ const Dropdown: FC<DropdownProps> = (baseprops) => {
|
|
|
56
56
|
<Trigger
|
|
57
57
|
{...rest}
|
|
58
58
|
arrow={arrow}
|
|
59
|
-
popup={renderPopup() as
|
|
59
|
+
popup={renderPopup() as React.ReactElement}
|
|
60
60
|
placement={placement}
|
|
61
61
|
popupClassName={`${prefixCls}-popup`}
|
|
62
62
|
open={mergedOpen}
|
|
@@ -8,8 +8,8 @@ import { FloatButtonGroupCtx } from './float-button-group';
|
|
|
8
8
|
import type { FloatButtonProps } from './interface';
|
|
9
9
|
import './style/index.less';
|
|
10
10
|
|
|
11
|
-
const FloatButton = React.forwardRef(
|
|
12
|
-
(baseprops
|
|
11
|
+
const FloatButton = React.forwardRef<HTMLButtonElement, FloatButtonProps>(
|
|
12
|
+
(baseprops, ref) => {
|
|
13
13
|
const { floatbutton } = useContext(GlobalContext);
|
|
14
14
|
const props = mergeContextToProps(baseprops, floatbutton);
|
|
15
15
|
const {
|
|
@@ -26,7 +26,9 @@ const FloatButton = React.forwardRef(
|
|
|
26
26
|
...rest
|
|
27
27
|
} = props;
|
|
28
28
|
|
|
29
|
-
const componentRef =
|
|
29
|
+
const componentRef =
|
|
30
|
+
(ref as React.RefObject<HTMLButtonElement | null>) ||
|
|
31
|
+
React.createRef<HTMLButtonElement>();
|
|
30
32
|
|
|
31
33
|
const onMove = (pos: { x: number; y: number }) => {
|
|
32
34
|
// Check if element exists before operating
|
package/src/Form/demo/basic.tsx
CHANGED
|
@@ -64,7 +64,7 @@ export default () => {
|
|
|
64
64
|
</Form.Field>
|
|
65
65
|
</Grid.Item>
|
|
66
66
|
<Grid.Item>
|
|
67
|
-
<Form.Field name="gender" label="Gender" initialValue="male">
|
|
67
|
+
<Form.Field name="gender" label="Gender" initialValue="male" required>
|
|
68
68
|
<Select
|
|
69
69
|
options={[
|
|
70
70
|
{ label: 'male', value: 'male' },
|
|
@@ -76,7 +76,7 @@ export default () => {
|
|
|
76
76
|
</Grid.Item>
|
|
77
77
|
|
|
78
78
|
<Grid.Item>
|
|
79
|
-
<Form.Field name="birthday" label="Birthday">
|
|
79
|
+
<Form.Field name="birthday" label="Birthday" required>
|
|
80
80
|
<DatePicker />
|
|
81
81
|
</Form.Field>
|
|
82
82
|
</Grid.Item>
|
|
@@ -56,5 +56,20 @@
|
|
|
56
56
|
color: var(--yee-error-color);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
// 表单校验态:在此重定义控件读取的 border / box-shadow 变量,
|
|
61
|
+
// 后代里的 Input / Selector / InputNumber / TextArea 等通过 CSS 变量继承自动变色,
|
|
62
|
+
// 无需在每个组件里重复 .yee-form-item-error 块,也不存在 specificity / !important 问题。
|
|
63
|
+
&&-error {
|
|
64
|
+
--yee-input-border-color: var(--yee-error-color);
|
|
65
|
+
--yee-input-hover-border-color: var(--yee-error-color-hover);
|
|
66
|
+
--yee-input-focus-bs-color: var(--yee-error-color-border);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&&-warning {
|
|
70
|
+
--yee-input-border-color: var(--yee-warning-color);
|
|
71
|
+
--yee-input-hover-border-color: var(--yee-warning-color-hover);
|
|
72
|
+
--yee-input-focus-bs-color: var(--yee-warning-color-border);
|
|
73
|
+
}
|
|
59
74
|
}
|
|
60
75
|
}
|
|
@@ -110,20 +110,3 @@ input[type='number']::-webkit-outer-spin-button {
|
|
|
110
110
|
input::placeholder {
|
|
111
111
|
color: var(--yee-placeholder-color);
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
// form error status
|
|
115
|
-
.yee-form-item-error {
|
|
116
|
-
@{pls} {
|
|
117
|
-
border-color: var(--yee-error-color);
|
|
118
|
-
|
|
119
|
-
&:hover {
|
|
120
|
-
border-color: var(--yee-error-color-hover);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.yee-form-item-warning {
|
|
126
|
-
@{pls} {
|
|
127
|
-
border-color: var(--yee-warning-color);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
@@ -185,32 +185,3 @@
|
|
|
185
185
|
padding-right: 0;
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
|
|
189
|
-
// Form error status
|
|
190
|
-
.yee-form-item-error {
|
|
191
|
-
@{pls} {
|
|
192
|
-
border-color: var(--yee-error-color);
|
|
193
|
-
|
|
194
|
-
&:not(@{pls}-disabled):hover {
|
|
195
|
-
border-color: var(--yee-error-color);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
&-focused {
|
|
199
|
-
box-shadow: 0 0 0 2px var(--yee-input-content-error-focus-bs-color);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
.yee-form-item-warning {
|
|
205
|
-
@{pls} {
|
|
206
|
-
border-color: var(--yee-warning-color);
|
|
207
|
-
|
|
208
|
-
&:not(@{pls}-disabled):hover {
|
|
209
|
-
border-color: var(--yee-warning-color);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
&-focused {
|
|
213
|
-
box-shadow: 0 0 0 2px var(--yee-input-content-warning-focus-bs-color);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
|
+
import type { usePanelConfigs } from './configs/locale-adapter';
|
|
2
3
|
export type PickerType =
|
|
3
4
|
| 'date'
|
|
4
5
|
| 'week'
|
|
@@ -18,6 +19,9 @@ export type SemanticType =
|
|
|
18
19
|
|
|
19
20
|
export type UnitType = 'day' | 'hour' | 'minute' | 'second';
|
|
20
21
|
|
|
22
|
+
/** Hour/minute/second granularity used by the time sub-panels. */
|
|
23
|
+
export type TimeUnit = 'hour' | 'minute' | 'second';
|
|
24
|
+
|
|
21
25
|
interface HeaderProps {
|
|
22
26
|
showPrevIcon?: boolean;
|
|
23
27
|
showNextIcon?: boolean;
|
|
@@ -115,13 +119,50 @@ export interface PickerPanelProps extends HeaderProps {
|
|
|
115
119
|
/**
|
|
116
120
|
* Hover range dates [start date, end date]
|
|
117
121
|
*/
|
|
118
|
-
hoverRange?: Array<Dayjs | null>;
|
|
122
|
+
hoverRange?: Array<Dayjs | null | undefined>;
|
|
119
123
|
/**
|
|
120
124
|
* Selected range dates [start date, end date]
|
|
121
125
|
*/
|
|
122
|
-
selectedRange?: Array<Dayjs | null>;
|
|
126
|
+
selectedRange?: Array<Dayjs | null | undefined>;
|
|
123
127
|
/**
|
|
124
128
|
* Disabled date function
|
|
125
129
|
*/
|
|
126
130
|
disabledDate?: (current: Dayjs) => boolean;
|
|
127
131
|
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Locale/config bag produced by `usePanelConfigs`, shared by every panel.
|
|
135
|
+
*/
|
|
136
|
+
export type PanelConfigs = ReturnType<typeof usePanelConfigs>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The `panelProps` bag shared by all date-picking panels, headers and bodies.
|
|
140
|
+
*
|
|
141
|
+
* Standalone (does not extend `PickerPanelProps`) so each panel only declares
|
|
142
|
+
* the fields it actually reads while still receiving the full bag via
|
|
143
|
+
* `{...props}` spreads (JSX spreads do not trigger excess-property checks).
|
|
144
|
+
*/
|
|
145
|
+
export interface PanelSharedProps {
|
|
146
|
+
prefixCls?: string;
|
|
147
|
+
picker?: PickerType;
|
|
148
|
+
offset?: { year?: number; month?: number; day?: number };
|
|
149
|
+
viewDate: Dayjs;
|
|
150
|
+
selectedDate?: Dayjs;
|
|
151
|
+
panelConfigs: PanelConfigs;
|
|
152
|
+
handleMouseChange?: (date: Dayjs | '') => void;
|
|
153
|
+
onViewDateChange: (date: Dayjs) => void;
|
|
154
|
+
onPanelChange: (view: PickerType) => void;
|
|
155
|
+
onSelect?: (date: Dayjs) => void;
|
|
156
|
+
offsetYear?: number;
|
|
157
|
+
/** Never set in `panelProps`, so always `undefined` at runtime. */
|
|
158
|
+
nowDate?: Dayjs;
|
|
159
|
+
weekStart?: number;
|
|
160
|
+
showHeader?: boolean;
|
|
161
|
+
cellRender?: (date: Dayjs, panel: PickerType) => React.ReactNode;
|
|
162
|
+
prefixColumn?: (currentDate: Dayjs) => React.ReactNode;
|
|
163
|
+
getRowClassName?: (currentDate: Dayjs) => string;
|
|
164
|
+
hoverRange?: Array<Dayjs | null | undefined>;
|
|
165
|
+
selectedRange?: Array<Dayjs | null | undefined>;
|
|
166
|
+
maxDate?: Dayjs;
|
|
167
|
+
minDate?: Dayjs;
|
|
168
|
+
}
|
|
@@ -2,6 +2,7 @@ import clsx from 'clsx';
|
|
|
2
2
|
import { Dayjs } from 'dayjs';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import useEvent from '../../../hooks/useEvent';
|
|
5
|
+
import type { PanelSharedProps } from '../../interface';
|
|
5
6
|
import panelConfig from '../../configs';
|
|
6
7
|
import pickerUtils from '../../utils/pickerUtils';
|
|
7
8
|
import PanelBody from '../PanelBody';
|
|
@@ -10,7 +11,7 @@ const DATEPANEL_WEEK_DAY_COUNT = 7;
|
|
|
10
11
|
|
|
11
12
|
const weekTitle = panelConfig.shortWeekList;
|
|
12
13
|
|
|
13
|
-
function DateBody(props:
|
|
14
|
+
function DateBody(props: PanelSharedProps) {
|
|
14
15
|
const {
|
|
15
16
|
prefixCls,
|
|
16
17
|
viewDate,
|
|
@@ -2,10 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import Button from '../../../Button';
|
|
3
3
|
import useEvent from '../../../hooks/useEvent';
|
|
4
4
|
import { useLocale } from '../../../locale';
|
|
5
|
+
import type { PanelSharedProps } from '../../interface';
|
|
5
6
|
import pickerUtils from '../../utils/pickerUtils';
|
|
6
7
|
import Header from '../Header';
|
|
7
8
|
|
|
8
|
-
export default function DateHeader(props:
|
|
9
|
+
export default function DateHeader(props: PanelSharedProps) {
|
|
9
10
|
const { locale, lang } = useLocale();
|
|
10
11
|
const { datepicker } = locale;
|
|
11
12
|
|
|
@@ -15,7 +16,7 @@ export default function DateHeader(props: any) {
|
|
|
15
16
|
const month = pickerUtils.getMonth(viewDate);
|
|
16
17
|
|
|
17
18
|
if (offset?.year) {
|
|
18
|
-
year = year +
|
|
19
|
+
year = year + offset.year;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const onSuperPrevClick = useEvent(() => {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { PanelSharedProps } from '../../interface';
|
|
2
3
|
import DateBody from './DateBody';
|
|
3
4
|
import DateHeader from './DateHeader';
|
|
4
5
|
|
|
5
|
-
export default function DatePanel(props:
|
|
6
|
+
export default function DatePanel(props: PanelSharedProps) {
|
|
6
7
|
const { prefixCls, showHeader = true } = props;
|
|
7
8
|
|
|
8
9
|
return (
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import type { PickerType, PanelSharedProps } from '../../interface';
|
|
3
4
|
import DatePanel from '../DatePanel';
|
|
4
5
|
import TimePanel from '../TimePanel';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
interface DateTimePanelProps extends Omit<PanelSharedProps, 'onSelect'> {
|
|
8
|
+
onSelect?: (panel: PickerType, date: Dayjs) => void;
|
|
9
|
+
showTime?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function DateTimePanel(props: DateTimePanelProps) {
|
|
13
|
+
const { onSelect, showTime, ...rest } = props;
|
|
14
|
+
const prefixCls = rest.prefixCls ?? 'yee-picker';
|
|
8
15
|
|
|
9
16
|
const handleSelect = (type: string, date: Dayjs) => {
|
|
10
|
-
onSelect(type, date);
|
|
17
|
+
onSelect?.(type as PickerType, date);
|
|
11
18
|
};
|
|
12
19
|
|
|
13
20
|
return (
|
|
14
21
|
<div className={`${prefixCls}-datetime-panel`}>
|
|
15
22
|
<DatePanel
|
|
16
|
-
{...
|
|
23
|
+
{...rest}
|
|
17
24
|
onSelect={(date: Dayjs) => handleSelect('date', date)}
|
|
18
25
|
/>
|
|
19
26
|
{showTime ? (
|
|
20
27
|
<TimePanel
|
|
21
|
-
{...
|
|
28
|
+
{...rest}
|
|
22
29
|
onSelect={(date: Dayjs) => handleSelect('datetimetime', date)}
|
|
23
30
|
showHeader
|
|
24
31
|
/>
|
|
@@ -2,11 +2,12 @@ import clsx from 'clsx';
|
|
|
2
2
|
import { Dayjs } from 'dayjs';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import useEvent from '../../../hooks/useEvent';
|
|
5
|
+
import type { PanelSharedProps } from '../../interface';
|
|
5
6
|
import pickerUtils from '../../utils/pickerUtils';
|
|
6
7
|
import PanelBody from '../PanelBody';
|
|
7
8
|
|
|
8
|
-
function DecadeBody(props:
|
|
9
|
-
const { prefixCls, viewDate, offsetYear } = props;
|
|
9
|
+
function DecadeBody(props: PanelSharedProps) {
|
|
10
|
+
const { prefixCls, viewDate, offsetYear = 0 } = props;
|
|
10
11
|
|
|
11
12
|
const baseDate = pickerUtils.getBaseDate('decade', viewDate);
|
|
12
13
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import useEvent from '../../../hooks/useEvent';
|
|
3
|
+
import type { PanelSharedProps } from '../../interface';
|
|
3
4
|
import pickerUtils from '../../utils/pickerUtils';
|
|
4
5
|
import Header from '../Header';
|
|
5
6
|
|
|
6
|
-
export default function DecadeHeader(props:
|
|
7
|
-
const { viewDate, offsetYear, onViewDateChange } = props;
|
|
7
|
+
export default function DecadeHeader(props: PanelSharedProps) {
|
|
8
|
+
const { viewDate, offsetYear = 0, onViewDateChange } = props;
|
|
8
9
|
const onSuperPrevClick = useEvent(() => {
|
|
9
10
|
onViewDateChange(pickerUtils.addYear(viewDate, -100));
|
|
10
11
|
});
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { PanelSharedProps } from '../../interface';
|
|
2
3
|
|
|
3
4
|
import DecadeBody from './DecadeBody';
|
|
4
5
|
import DecadeHeader from './DecadeHeader';
|
|
5
6
|
|
|
6
|
-
export default function DecadePanel(props:
|
|
7
|
+
export default function DecadePanel(props: PanelSharedProps) {
|
|
7
8
|
const { prefixCls, offset } = props;
|
|
8
9
|
|
|
9
10
|
let offsetYear = 0;
|
|
10
11
|
if (offset?.year) {
|
|
11
|
-
offsetYear =
|
|
12
|
+
offsetYear = offset.year;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
return (
|
|
@@ -7,7 +7,20 @@ import {
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import Button from '../../Button';
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export interface PanelHeaderProps {
|
|
11
|
+
prefixCls?: string;
|
|
12
|
+
onPrevClick?: () => void;
|
|
13
|
+
onSuperPrevClick?: () => void;
|
|
14
|
+
onNextClick?: () => void;
|
|
15
|
+
onSuperNextClick?: () => void;
|
|
16
|
+
showPrevIcon?: boolean;
|
|
17
|
+
showNextIcon?: boolean;
|
|
18
|
+
showSuperPrevIcon?: boolean;
|
|
19
|
+
showSuperNextIcon?: boolean;
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default function Header(props: PanelHeaderProps) {
|
|
11
24
|
const {
|
|
12
25
|
prefixCls,
|
|
13
26
|
onPrevClick,
|
|
@@ -2,10 +2,11 @@ import clsx from 'clsx';
|
|
|
2
2
|
import { Dayjs } from 'dayjs';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import useEvent from '../../../hooks/useEvent';
|
|
5
|
+
import type { PanelSharedProps } from '../../interface';
|
|
5
6
|
import pickerUtils from '../../utils/pickerUtils';
|
|
6
7
|
import PanelBody from '../PanelBody';
|
|
7
8
|
|
|
8
|
-
function MonthBody(props:
|
|
9
|
+
function MonthBody(props: PanelSharedProps) {
|
|
9
10
|
const {
|
|
10
11
|
prefixCls,
|
|
11
12
|
viewDate,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import Button from '../../../Button';
|
|
3
3
|
import useEvent from '../../../hooks/useEvent';
|
|
4
|
+
import type { PanelSharedProps } from '../../interface';
|
|
4
5
|
import pickerUtils from '../../utils/pickerUtils';
|
|
5
6
|
import Header from '../Header';
|
|
6
7
|
|
|
7
|
-
export default function MonthHeader(props:
|
|
8
|
-
const { prefixCls, viewDate, offsetYear, onViewDateChange, onPanelChange } =
|
|
8
|
+
export default function MonthHeader(props: PanelSharedProps) {
|
|
9
|
+
const { prefixCls, viewDate, offsetYear = 0, onViewDateChange, onPanelChange } =
|
|
9
10
|
props;
|
|
10
11
|
|
|
11
12
|
const year = pickerUtils.getYear(viewDate) + offsetYear;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { PanelSharedProps } from '../../interface';
|
|
2
3
|
|
|
3
4
|
import MonthBody from './MonthBody';
|
|
4
5
|
import MonthHeader from './MonthHeader';
|
|
5
6
|
|
|
6
|
-
export default function DecadePanel(props:
|
|
7
|
+
export default function DecadePanel(props: PanelSharedProps) {
|
|
7
8
|
const { prefixCls, offset, showHeader = true } = props;
|
|
8
9
|
|
|
9
10
|
let offsetYear = 0;
|
|
10
11
|
if (offset?.year) {
|
|
11
|
-
offsetYear =
|
|
12
|
+
offsetYear = offset.year;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
return (
|
|
@@ -2,8 +2,28 @@ import clsx from 'clsx';
|
|
|
2
2
|
import { Dayjs } from 'dayjs';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import pickerUtils from '../utils/pickerUtils';
|
|
5
|
+
import type { PickerType } from '../interface';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
export interface PanelBodyProps {
|
|
8
|
+
prefixCls?: string;
|
|
9
|
+
picker?: PickerType;
|
|
10
|
+
rowCount: number;
|
|
11
|
+
colCount: number;
|
|
12
|
+
baseDate?: Dayjs | number;
|
|
13
|
+
onSelect?: (date: Dayjs) => void;
|
|
14
|
+
handleMouseChange?: (date: Dayjs | '') => void;
|
|
15
|
+
headerCells?: React.ReactNode;
|
|
16
|
+
getCellNode?: (currentDate: Dayjs) => React.ReactNode;
|
|
17
|
+
getCellDate: (baseDate: Dayjs, offset: number) => Dayjs;
|
|
18
|
+
getCellText: (currentDate: Dayjs) => number | string;
|
|
19
|
+
getCellTitle?: (currentDate: Dayjs) => string;
|
|
20
|
+
getCellClassName?: (currentDate: Dayjs) => string;
|
|
21
|
+
prefixColumn?: (currentDate: Dayjs) => React.ReactNode;
|
|
22
|
+
getRowClassName?: (currentDate: Dayjs) => string;
|
|
23
|
+
cellRender?: (date: Dayjs, panel: PickerType) => React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function PanelBody(props: PanelBodyProps) {
|
|
7
27
|
const {
|
|
8
28
|
prefixCls,
|
|
9
29
|
rowCount,
|
|
@@ -39,7 +59,7 @@ function PanelBody(props: any) {
|
|
|
39
59
|
|
|
40
60
|
for (let j = 0; j < colCount; j++) {
|
|
41
61
|
const offset = i * colCount + j;
|
|
42
|
-
const currentDate = getCellDate(baseDate, offset);
|
|
62
|
+
const currentDate = getCellDate(baseDate as Dayjs, offset);
|
|
43
63
|
|
|
44
64
|
if (j === 0) {
|
|
45
65
|
rowStartDate = currentDate;
|
|
@@ -60,11 +80,13 @@ function PanelBody(props: any) {
|
|
|
60
80
|
{
|
|
61
81
|
[`${cellPrefixCls}-start`]:
|
|
62
82
|
getCellText(currentDate) === 1 ||
|
|
63
|
-
(picker === 'year' &&
|
|
83
|
+
(picker === 'year' &&
|
|
84
|
+
Number(getCellText(currentDate)) % 10 === 0),
|
|
64
85
|
[`${cellPrefixCls}-end`]:
|
|
65
86
|
getCellText(currentDate) ===
|
|
66
87
|
pickerUtils.getDate(currentDate.endOf('month')) ||
|
|
67
|
-
(picker === 'year' &&
|
|
88
|
+
(picker === 'year' &&
|
|
89
|
+
Number(getCellText(currentDate)) % 10 === 9),
|
|
68
90
|
},
|
|
69
91
|
cls,
|
|
70
92
|
)}
|
|
@@ -90,7 +112,7 @@ function PanelBody(props: any) {
|
|
|
90
112
|
</div>
|
|
91
113
|
{cellRender ? (
|
|
92
114
|
<div className={`${prefixCls}-cell-content`}>
|
|
93
|
-
{cellRender(currentDate,
|
|
115
|
+
{cellRender(currentDate, picker as PickerType)}
|
|
94
116
|
</div>
|
|
95
117
|
) : null}
|
|
96
118
|
</div>
|
|
@@ -4,11 +4,12 @@ import React from 'react';
|
|
|
4
4
|
import PanelBody from '../PanelBody';
|
|
5
5
|
|
|
6
6
|
import useEvent from '../../../hooks/useEvent';
|
|
7
|
+
import type { PanelSharedProps } from '../../interface';
|
|
7
8
|
import pickerUtils from '../../utils/pickerUtils';
|
|
8
9
|
|
|
9
10
|
const quarter = ['Q1', 'Q2', 'Q3', 'Q4'];
|
|
10
11
|
|
|
11
|
-
function QuarterBody(props:
|
|
12
|
+
function QuarterBody(props: PanelSharedProps) {
|
|
12
13
|
const { prefixCls, viewDate, nowDate } = props;
|
|
13
14
|
|
|
14
15
|
const baseDate = pickerUtils.setMonth(viewDate, 0);
|
|
@@ -2,10 +2,11 @@ import * as React from 'react';
|
|
|
2
2
|
import Button from '../../../Button';
|
|
3
3
|
import useEvent from '../../../hooks/useEvent';
|
|
4
4
|
import Header from '../Header';
|
|
5
|
+
import type { PanelSharedProps } from '../../interface';
|
|
5
6
|
|
|
6
7
|
import pickerUtils from '../../utils/pickerUtils';
|
|
7
8
|
|
|
8
|
-
export default function QuarterHeader(props:
|
|
9
|
+
export default function QuarterHeader(props: PanelSharedProps) {
|
|
9
10
|
const { prefixCls, viewDate, onViewDateChange, onPanelChange } = props;
|
|
10
11
|
|
|
11
12
|
const year = pickerUtils.getYear(viewDate);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { PanelSharedProps } from '../../interface';
|
|
2
3
|
|
|
3
4
|
import QuarterBody from './QuarterBody';
|
|
4
5
|
import QuarterHeader from './QuarterHeader';
|
|
5
6
|
|
|
6
|
-
export default function DecadePanel(props:
|
|
7
|
+
export default function DecadePanel(props: PanelSharedProps) {
|
|
7
8
|
const { prefixCls } = props;
|
|
8
9
|
return (
|
|
9
10
|
<div className={`${prefixCls}-quarter-panel`}>
|