@canlooks/can-ui 0.0.74 → 0.0.76
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/components/calendar/calendar.style.js +124 -124
- package/dist/cjs/components/clickAway/clickAway.d.ts +1 -1
- package/dist/cjs/components/curd/curdResizable.js +1 -1
- package/dist/cjs/components/dateTimePicker/dateTimePicker.d.ts +4 -4
- package/dist/cjs/components/dateTimePicker/dateTimePicker.js +14 -190
- package/dist/cjs/components/dateTimePicker/dateTimePicker.style.d.ts +2 -12
- package/dist/cjs/components/dateTimePicker/dateTimePicker.style.js +20 -17
- package/dist/cjs/components/descriptions/descriptions.js +1 -5
- package/dist/cjs/components/dialog/dialog.js +1 -1
- package/dist/cjs/components/dialog/dialog.style.js +2 -0
- package/dist/cjs/components/inputBase/inputBase.js +10 -1
- package/dist/cjs/components/popper/popper.js +21 -20
- package/dist/cjs/components/status/status.d.ts +6 -6
- package/dist/cjs/components/table/table.d.ts +1 -1
- package/dist/cjs/components/table/table.js +3 -1
- package/dist/cjs/components/table/table.style.js +21 -6
- package/dist/cjs/components/table/tableSticky.js +19 -16
- package/dist/cjs/components/table/tableSticky.style.js +0 -8
- package/dist/cjs/components/theme/themeVariables.js +2 -2
- package/dist/cjs/utils/utils.d.ts +5 -3
- package/dist/cjs/utils/utils.js +22 -7
- package/dist/esm/components/calendar/calendar.style.js +124 -124
- package/dist/esm/components/clickAway/clickAway.d.ts +1 -1
- package/dist/esm/components/curd/curdResizable.js +1 -1
- package/dist/esm/components/dateTimePicker/dateTimePicker.d.ts +4 -4
- package/dist/esm/components/dateTimePicker/dateTimePicker.js +15 -191
- package/dist/esm/components/dateTimePicker/dateTimePicker.style.d.ts +2 -12
- package/dist/esm/components/dateTimePicker/dateTimePicker.style.js +20 -17
- package/dist/esm/components/descriptions/descriptions.js +1 -5
- package/dist/esm/components/dialog/dialog.js +1 -1
- package/dist/esm/components/dialog/dialog.style.js +2 -0
- package/dist/esm/components/inputBase/inputBase.js +11 -2
- package/dist/esm/components/popper/popper.js +22 -21
- package/dist/esm/components/status/status.d.ts +6 -6
- package/dist/esm/components/table/table.d.ts +1 -1
- package/dist/esm/components/table/table.js +4 -2
- package/dist/esm/components/table/table.style.js +21 -6
- package/dist/esm/components/table/tableSticky.js +20 -17
- package/dist/esm/components/table/tableSticky.style.js +0 -8
- package/dist/esm/components/theme/themeVariables.js +2 -2
- package/dist/esm/utils/utils.d.ts +5 -3
- package/dist/esm/utils/utils.js +21 -6
- package/documentation/dist/assets/index-DvrKS6Tv.js +7747 -0
- package/documentation/dist/atom-one-dark.min.css +1 -0
- package/documentation/dist/components/accordion.md +38 -0
- package/documentation/dist/components/actionSheet.md +49 -0
- package/documentation/dist/components/alert.md +38 -0
- package/documentation/dist/components/anchorList.md +36 -0
- package/documentation/dist/components/autocomplete.md +68 -0
- package/documentation/dist/components/avatar.md +79 -0
- package/documentation/dist/components/badge.md +33 -0
- package/documentation/dist/components/bottomNavigation.md +39 -0
- package/documentation/dist/components/breadcrumb.md +28 -0
- package/documentation/dist/components/bubbleConfirm.md +34 -0
- package/documentation/dist/components/button.md +62 -0
- package/documentation/dist/components/card.md +30 -0
- package/documentation/dist/components/cascade.md +48 -0
- package/documentation/dist/components/checkbox.md +36 -0
- package/documentation/dist/components/colorPicker.md +27 -0
- package/documentation/dist/components/contextMenu.md +27 -0
- package/documentation/dist/components/counter.md +29 -0
- package/documentation/dist/components/dataGrid.md +112 -0
- package/documentation/dist/components/dateTimePicker.md +35 -0
- package/documentation/dist/components/dateTimeRangePicker.md +36 -0
- package/documentation/dist/components/descriptions.md +35 -0
- package/documentation/dist/components/dialog.md +56 -0
- package/documentation/dist/components/divider.md +26 -0
- package/documentation/dist/components/drawer.md +40 -0
- package/documentation/dist/components/flex.md +20 -0
- package/documentation/dist/components/form.md +131 -0
- package/documentation/dist/components/formDialog.md +36 -0
- package/documentation/dist/components/grid.md +34 -0
- package/documentation/dist/components/highlight.md +26 -0
- package/documentation/dist/components/image.md +90 -0
- package/documentation/dist/components/input.md +39 -0
- package/documentation/dist/components/loading.md +46 -0
- package/documentation/dist/components/menu.md +85 -0
- package/documentation/dist/components/pagination.md +38 -0
- package/documentation/dist/components/pickerDialog.md +56 -0
- package/documentation/dist/components/placeholder.md +30 -0
- package/documentation/dist/components/progress.md +43 -0
- package/documentation/dist/components/radio.md +37 -0
- package/documentation/dist/components/rating.md +35 -0
- package/documentation/dist/components/resizable.md +41 -0
- package/documentation/dist/components/scrollbar.md +31 -0
- package/documentation/dist/components/segmented.md +57 -0
- package/documentation/dist/components/select.md +30 -0
- package/documentation/dist/components/skeleton.md +26 -0
- package/documentation/dist/components/slidableActions.md +53 -0
- package/documentation/dist/guide/appComponent.md +30 -0
- package/documentation/dist/guide/globalMethods.md +238 -0
- package/documentation/dist/guide/icon.md +57 -0
- package/documentation/dist/guide/introduction.md +2 -0
- package/documentation/dist/guide/overrideProps.md +0 -0
- package/documentation/dist/guide/startup.md +23 -0
- package/documentation/dist/guide/theme.md +249 -0
- package/documentation/dist/index.html +13 -0
- package/documentation/dist/logo.png +0 -0
- package/extensions/curd.cjs +5 -5
- package/extensions/documentViewer.cjs +5 -5
- package/extensions/textFormatter.cjs +5 -5
- package/package.json +1 -1
|
@@ -16,128 +16,128 @@ exports.classes = (0, utils_1.defineInnerClasses)('calendar', [
|
|
|
16
16
|
'yearItem',
|
|
17
17
|
'foot'
|
|
18
18
|
]);
|
|
19
|
-
exports.style = (0, utils_1.defineCss)(({ divider, text, spacing }) => (0, react_1.css) `
|
|
20
|
-
.${exports.classes.head} {
|
|
21
|
-
height: 40px;
|
|
22
|
-
display: flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
justify-content: space-between;
|
|
25
|
-
border-bottom: 1px solid ${divider};
|
|
26
|
-
padding: 0 ${menuItem_style_1.menuListPadding}px;
|
|
27
|
-
position: relative;
|
|
28
|
-
|
|
29
|
-
.${exports.classes.headSide} {
|
|
30
|
-
z-index: 1;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.${exports.classes.headControl} {
|
|
34
|
-
color: ${text.placeholder};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.${exports.classes.headCenter} {
|
|
38
|
-
display: flex;
|
|
39
|
-
align-items: center;
|
|
40
|
-
justify-content: center;
|
|
41
|
-
position: absolute;
|
|
42
|
-
inset: 0;
|
|
43
|
-
|
|
44
|
-
.${exports.classes.headButton} {
|
|
45
|
-
font-weight: bold;
|
|
46
|
-
color: ${text.primary};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.${exports.classes.body} {
|
|
52
|
-
padding: ${spacing[3]}px ${spacing[4]}px;
|
|
53
|
-
display: grid;
|
|
54
|
-
place-items: center;
|
|
55
|
-
|
|
56
|
-
&[data-view-type=date] {
|
|
57
|
-
font-size: ${13 / 14}em;
|
|
58
|
-
grid-template-columns: repeat(7, 36px);
|
|
59
|
-
grid-template-rows: repeat(7, 36px);
|
|
60
|
-
|
|
61
|
-
.${exports.classes.dateItem} {
|
|
62
|
-
width: 24px;
|
|
63
|
-
height: 24px;
|
|
64
|
-
|
|
65
|
-
&:not([data-variant=filled]) {
|
|
66
|
-
color: ${text.primary};
|
|
67
|
-
border-color: ${text.disabled};
|
|
68
|
-
|
|
69
|
-
&[data-other-month=true] {
|
|
70
|
-
color: ${text.placeholder};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
&:disabled {
|
|
75
|
-
width: 100%;
|
|
76
|
-
border-radius: 0;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
&[data-view-type=month], &[data-view-type=year] {
|
|
82
|
-
grid-template-columns: repeat(3, 84px);
|
|
83
|
-
grid-template-rows: repeat(4, 63px);
|
|
84
|
-
|
|
85
|
-
.${exports.classes.monthItem},
|
|
86
|
-
.${exports.classes.yearItem} {
|
|
87
|
-
width: 72px;
|
|
88
|
-
padding-inline: 0;
|
|
89
|
-
|
|
90
|
-
&:not([data-variant=filled]) {
|
|
91
|
-
color: ${text.primary};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
&[data-size=small] {
|
|
98
|
-
.${exports.classes.body} {
|
|
99
|
-
&[data-view-type=date] {
|
|
100
|
-
grid-template-columns: repeat(7, 30px);
|
|
101
|
-
grid-template-rows: repeat(7, 30px);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
&[data-view-type=month], &[data-view-type=year] {
|
|
105
|
-
grid-template-columns: repeat(3, 70px);
|
|
106
|
-
grid-template-rows: repeat(4, 52.5px);
|
|
107
|
-
|
|
108
|
-
.${exports.classes.monthItem},
|
|
109
|
-
.${exports.classes.yearItem} {
|
|
110
|
-
width: 60px;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
&[data-size=large] {
|
|
117
|
-
.${exports.classes.body} {
|
|
118
|
-
&[data-view-type=date] {
|
|
119
|
-
font-size: 1em;
|
|
120
|
-
grid-template-columns: repeat(7, 42px);
|
|
121
|
-
grid-template-rows: repeat(7, 42px);
|
|
122
|
-
|
|
123
|
-
.${exports.classes.dateItem} {
|
|
124
|
-
width: 32px;
|
|
125
|
-
height: 32px;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
&[data-view-type=month], &[data-view-type=year] {
|
|
130
|
-
grid-template-columns: repeat(3, 98px);
|
|
131
|
-
grid-template-rows: repeat(4, 73.5px);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.${exports.classes.foot} {
|
|
137
|
-
height: 41px;
|
|
138
|
-
display: flex;
|
|
139
|
-
align-items: center;
|
|
140
|
-
justify-content: center;
|
|
141
|
-
border-top: 1px solid ${divider};
|
|
142
|
-
}
|
|
19
|
+
exports.style = (0, utils_1.defineCss)(({ divider, text, spacing }) => (0, react_1.css) `
|
|
20
|
+
.${exports.classes.head} {
|
|
21
|
+
height: 40px;
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: space-between;
|
|
25
|
+
border-bottom: 1px solid ${divider};
|
|
26
|
+
padding: 0 ${menuItem_style_1.menuListPadding}px;
|
|
27
|
+
position: relative;
|
|
28
|
+
|
|
29
|
+
.${exports.classes.headSide} {
|
|
30
|
+
z-index: 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.${exports.classes.headControl} {
|
|
34
|
+
color: ${text.placeholder};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.${exports.classes.headCenter} {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
position: absolute;
|
|
42
|
+
inset: 0;
|
|
43
|
+
|
|
44
|
+
.${exports.classes.headButton} {
|
|
45
|
+
font-weight: bold;
|
|
46
|
+
color: ${text.primary};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.${exports.classes.body} {
|
|
52
|
+
padding: ${spacing[3]}px ${spacing[4]}px;
|
|
53
|
+
display: grid;
|
|
54
|
+
place-items: center;
|
|
55
|
+
|
|
56
|
+
&[data-view-type=date] {
|
|
57
|
+
font-size: ${13 / 14}em;
|
|
58
|
+
grid-template-columns: repeat(7, 36px);
|
|
59
|
+
grid-template-rows: repeat(7, 36px);
|
|
60
|
+
|
|
61
|
+
.${exports.classes.dateItem} {
|
|
62
|
+
width: 24px;
|
|
63
|
+
height: 24px;
|
|
64
|
+
|
|
65
|
+
&:not([data-variant=filled]) {
|
|
66
|
+
color: ${text.primary};
|
|
67
|
+
border-color: ${text.disabled};
|
|
68
|
+
|
|
69
|
+
&[data-other-month=true] {
|
|
70
|
+
color: ${text.placeholder};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&:disabled {
|
|
75
|
+
width: 100%;
|
|
76
|
+
border-radius: 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&[data-view-type=month], &[data-view-type=year] {
|
|
82
|
+
grid-template-columns: repeat(3, 84px);
|
|
83
|
+
grid-template-rows: repeat(4, 63px);
|
|
84
|
+
|
|
85
|
+
.${exports.classes.monthItem},
|
|
86
|
+
.${exports.classes.yearItem} {
|
|
87
|
+
width: 72px;
|
|
88
|
+
padding-inline: 0;
|
|
89
|
+
|
|
90
|
+
&:not([data-variant=filled]) {
|
|
91
|
+
color: ${text.primary};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&[data-size=small] {
|
|
98
|
+
.${exports.classes.body} {
|
|
99
|
+
&[data-view-type=date] {
|
|
100
|
+
grid-template-columns: repeat(7, 30px);
|
|
101
|
+
grid-template-rows: repeat(7, 30px);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&[data-view-type=month], &[data-view-type=year] {
|
|
105
|
+
grid-template-columns: repeat(3, 70px);
|
|
106
|
+
grid-template-rows: repeat(4, 52.5px);
|
|
107
|
+
|
|
108
|
+
.${exports.classes.monthItem},
|
|
109
|
+
.${exports.classes.yearItem} {
|
|
110
|
+
width: 60px;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&[data-size=large] {
|
|
117
|
+
.${exports.classes.body} {
|
|
118
|
+
&[data-view-type=date] {
|
|
119
|
+
font-size: 1em;
|
|
120
|
+
grid-template-columns: repeat(7, 42px);
|
|
121
|
+
grid-template-rows: repeat(7, 42px);
|
|
122
|
+
|
|
123
|
+
.${exports.classes.dateItem} {
|
|
124
|
+
width: 32px;
|
|
125
|
+
height: 32px;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
&[data-view-type=month], &[data-view-type=year] {
|
|
130
|
+
grid-template-columns: repeat(3, 98px);
|
|
131
|
+
grid-template-rows: repeat(4, 73.5px);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.${exports.classes.foot} {
|
|
137
|
+
height: 41px;
|
|
138
|
+
display: flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
justify-content: center;
|
|
141
|
+
border-top: 1px solid ${divider};
|
|
142
|
+
}
|
|
143
143
|
`);
|
|
@@ -60,7 +60,7 @@ export declare function ClickAway({ ref, container, eventType, onClickAway, disa
|
|
|
60
60
|
results: number;
|
|
61
61
|
security: string;
|
|
62
62
|
unselectable: "off" | "on";
|
|
63
|
-
popover: "" | "auto" | "manual"
|
|
63
|
+
popover: "" | "auto" | "manual";
|
|
64
64
|
popoverTargetAction: "toggle" | "hide" | "show";
|
|
65
65
|
popoverTarget: string;
|
|
66
66
|
inert: boolean;
|
|
@@ -10,5 +10,5 @@ const button_1 = require("../button");
|
|
|
10
10
|
const icon_1 = require("../icon");
|
|
11
11
|
const faArrowsUpDown_1 = require("@fortawesome/free-solid-svg-icons/faArrowsUpDown");
|
|
12
12
|
exports.CurdResizable = (0, react_1.memo)(({ innerSize, setInnerSize }) => {
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { title: "\u8868\u683C\u5C3A\u5BF8", children: (0, jsx_runtime_1.jsx)(bubble_1.Bubble, { placement: "bottom", content: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { value: "small", label: "\u5C0F", selected: innerSize === 'small', onClick: () => setInnerSize('small') }), (0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { value: "medium", label: "\u4E2D", selected: innerSize === 'medium', onClick: () => setInnerSize('medium') }), (0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { value: "large", label: "\u5927", selected: innerSize === 'large', onClick: () => setInnerSize('large') })] }), children: (0, jsx_runtime_1.jsx)(button_1.Button, { shape: "circular", variant: "text", color: "text.secondary", children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faArrowsUpDown_1.faArrowsUpDown }) }) }) }));
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { title: "\u8868\u683C\u5C3A\u5BF8", clickToClose: true, children: (0, jsx_runtime_1.jsx)(bubble_1.Bubble, { placement: "bottom", trigger: "click", content: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { value: "small", label: "\u5C0F", selected: innerSize === 'small', onClick: () => setInnerSize('small') }), (0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { value: "medium", label: "\u4E2D", selected: innerSize === 'medium', onClick: () => setInnerSize('medium') }), (0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { value: "large", label: "\u5927", selected: innerSize === 'large', onClick: () => setInnerSize('large') })] }), children: (0, jsx_runtime_1.jsx)(button_1.Button, { shape: "circular", variant: "text", color: "text.secondary", children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faArrowsUpDown_1.faArrowsUpDown }) }) }) }));
|
|
14
14
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PopperProps } from '../popper';
|
|
3
|
-
import { InputBaseProps } from '../inputBase';
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
4
2
|
import { Dayjs } from 'dayjs';
|
|
3
|
+
import { InputBaseProps } from '../inputBase';
|
|
4
|
+
import { PopperProps } from '../popper';
|
|
5
5
|
export type DatePickerSharedProps = {
|
|
6
6
|
min?: Dayjs;
|
|
7
7
|
max?: Dayjs;
|
|
@@ -23,4 +23,4 @@ export interface DateTimePickerProps extends DatePickerSharedProps, Omit<InputBa
|
|
|
23
23
|
disabledDates?: (date: Dayjs) => any;
|
|
24
24
|
}
|
|
25
25
|
export declare function useDateTimePickerContext(): DatePickerSharedProps;
|
|
26
|
-
export declare const DateTimePicker:
|
|
26
|
+
export declare const DateTimePicker: import("react").MemoExoticComponent<({ inputProps, popperProps, min, max, disabledDates, disabledHours, disabledMinutes, disabledSeconds, format, defaultValue, value, onChange, defaultOpen, open, onOpenChange, autoClose, ...props }: DateTimePickerProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
|
|
@@ -5,206 +5,32 @@ exports.useDateTimePickerContext = useDateTimePickerContext;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
7
7
|
const react_1 = require("react");
|
|
8
|
-
const popper_1 = require("../popper");
|
|
9
|
-
const inputBase_1 = require("../inputBase");
|
|
10
|
-
const utils_1 = require("../../utils");
|
|
11
8
|
const dateTimePicker_style_1 = require("./dateTimePicker.style");
|
|
12
9
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
13
|
-
const
|
|
10
|
+
const inputBase_1 = require("../inputBase");
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
const popper_1 = require("../popper");
|
|
14
13
|
const calendar_1 = require("../calendar");
|
|
15
|
-
const timer_1 = require("./timer");
|
|
16
14
|
const icon_1 = require("../icon");
|
|
17
15
|
const faCalendar_1 = require("@fortawesome/free-regular-svg-icons/faCalendar");
|
|
18
16
|
const faClock_1 = require("@fortawesome/free-regular-svg-icons/faClock");
|
|
19
|
-
|
|
20
|
-
const availableFormatTokens = ['Y', 'M', 'D', 'H', 'm', 's'];
|
|
17
|
+
const timer_1 = require("./timer");
|
|
21
18
|
const DateTimePickerContext = (0, react_1.createContext)({});
|
|
22
19
|
function useDateTimePickerContext() {
|
|
23
20
|
return (0, react_1.useContext)(DateTimePickerContext);
|
|
24
21
|
}
|
|
25
22
|
exports.DateTimePicker = (0, react_1.memo)(({ inputProps, popperProps, min, max, disabledDates, disabledHours, disabledMinutes, disabledSeconds, format = 'YYYY-MM-DD', defaultValue = null, value, onChange, defaultOpen = false, open, onOpenChange, autoClose = !/[Hms]/.test(format), ...props }) => {
|
|
26
|
-
const innerInputRef = (0, react_1.useRef)(null);
|
|
27
23
|
const focused = (0, react_1.useRef)(false);
|
|
28
24
|
const [innerOpen, _setInnerOpen] = (0, utils_1.useControlled)(defaultOpen, open, onOpenChange);
|
|
29
25
|
const setInnerOpen = (open) => {
|
|
30
26
|
// 如果仍聚焦在输入框,则不用关闭弹框
|
|
31
27
|
(open || !focused.current) && _setInnerOpen(open);
|
|
32
28
|
};
|
|
33
|
-
(0, react_1.useEffect)(() => {
|
|
34
|
-
if (!innerOpen.current && !dateValue.current) {
|
|
35
|
-
// 弹框关闭时没有选中日期,清空输入框
|
|
36
|
-
innerInputRef.current.value = format;
|
|
37
|
-
}
|
|
38
|
-
}, [innerOpen.current]);
|
|
39
29
|
const [dateValue, _setDateValue] = (0, utils_1.useControlled)(defaultValue, value, onChange);
|
|
40
30
|
const setDateValue = (date) => {
|
|
41
31
|
_setDateValue(date);
|
|
42
32
|
autoClose && _setInnerOpen(false);
|
|
43
33
|
};
|
|
44
|
-
(0, react_1.useEffect)(() => {
|
|
45
|
-
innerInputRef.current.value = dateValue.current?.format(format) ?? format;
|
|
46
|
-
}, [dateValue.current]);
|
|
47
|
-
const clearHandler = () => {
|
|
48
|
-
setDateValue(null);
|
|
49
|
-
selectFn();
|
|
50
|
-
};
|
|
51
|
-
const ranges = (0, react_1.useMemo)(() => {
|
|
52
|
-
const range = [];
|
|
53
|
-
format.length && availableFormatTokens.forEach(token => {
|
|
54
|
-
const matched = format.match(new RegExp(`${token}+`));
|
|
55
|
-
if (matched && typeof matched.index === 'number') {
|
|
56
|
-
range.push({
|
|
57
|
-
token,
|
|
58
|
-
start: matched.index,
|
|
59
|
-
end: matched.index + matched[0].length
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
return range;
|
|
64
|
-
}, [format]);
|
|
65
|
-
const currentRange = (0, react_1.useRef)(null);
|
|
66
|
-
const selectFn = () => {
|
|
67
|
-
const input = innerInputRef.current;
|
|
68
|
-
const { selectionStart } = input;
|
|
69
|
-
const range = ranges.find(({ end }) => (selectionStart || 0) <= end) || ranges[ranges.length - 1];
|
|
70
|
-
if (range) {
|
|
71
|
-
currentRange.current = range;
|
|
72
|
-
input.value ||= format;
|
|
73
|
-
input.setSelectionRange(range.start, range.end);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const selectHandler = (e) => {
|
|
77
|
-
if (e.nativeEvent.type === 'selectionchange' || !ranges.length) {
|
|
78
|
-
// setSelectionRange()方法也会触发该回调,通过nativeEvent.type排除
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
selectFn();
|
|
82
|
-
};
|
|
83
|
-
const focusHandler = () => {
|
|
84
|
-
focused.current = true;
|
|
85
|
-
selectFn();
|
|
86
|
-
};
|
|
87
|
-
const blurHandler = () => {
|
|
88
|
-
resetContinue();
|
|
89
|
-
focused.current = false;
|
|
90
|
-
_setInnerOpen(false);
|
|
91
|
-
};
|
|
92
|
-
const valueContinueHelper = (0, react_1.useRef)({ token: '', value: '' });
|
|
93
|
-
const resetContinue = () => {
|
|
94
|
-
valueContinueHelper.current = { token: '', value: '' };
|
|
95
|
-
};
|
|
96
|
-
const keydownHandler = (e) => {
|
|
97
|
-
if (!currentRange.current) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const { key } = e;
|
|
101
|
-
const input = e.target;
|
|
102
|
-
const { token, start, end } = currentRange.current;
|
|
103
|
-
if (/^\d$/.test(e.key)) {
|
|
104
|
-
// 数字键
|
|
105
|
-
e.preventDefault();
|
|
106
|
-
let continuedValue;
|
|
107
|
-
if (valueContinueHelper.current.token === token) {
|
|
108
|
-
continuedValue = valueContinueHelper.current.value += key;
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
valueContinueHelper.current = { token, value: key };
|
|
112
|
-
continuedValue = key;
|
|
113
|
-
}
|
|
114
|
-
input.value = `${input.value.slice(0, start)}${continuedValue.padStart(end - start, '0')}${input.value.slice(end)}`;
|
|
115
|
-
input.setSelectionRange(start, end);
|
|
116
|
-
const d = (0, dayjs_1.default)(input.value, format);
|
|
117
|
-
d.isValid() && _setDateValue(d);
|
|
118
|
-
// 当长度达到,或者数值超过,将会跳转下一个range
|
|
119
|
-
if (token === 'Y') {
|
|
120
|
-
if (continuedValue.length === 4) {
|
|
121
|
-
return selectNext(input);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else if (continuedValue.length === 2) {
|
|
125
|
-
return selectNext(input);
|
|
126
|
-
}
|
|
127
|
-
switch (token) {
|
|
128
|
-
case 'M':
|
|
129
|
-
if (+key > 1) {
|
|
130
|
-
return selectNext(input);
|
|
131
|
-
}
|
|
132
|
-
break;
|
|
133
|
-
case 'D':
|
|
134
|
-
if (+key > 3) {
|
|
135
|
-
return selectNext(input);
|
|
136
|
-
}
|
|
137
|
-
break;
|
|
138
|
-
default:
|
|
139
|
-
// 'H' | 'm' | 's'
|
|
140
|
-
if (+key > 5) {
|
|
141
|
-
return selectNext(input);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
switch (key) {
|
|
146
|
-
case 'Backspace':
|
|
147
|
-
case 'Delete':
|
|
148
|
-
case 'ArrowLeft':
|
|
149
|
-
case 'ArrowRight':
|
|
150
|
-
case 'ArrowUp':
|
|
151
|
-
case 'ArrowDown':
|
|
152
|
-
case 'Escape':
|
|
153
|
-
e.preventDefault();
|
|
154
|
-
resetContinue();
|
|
155
|
-
}
|
|
156
|
-
switch (key) {
|
|
157
|
-
case 'Backspace':
|
|
158
|
-
case 'Delete':
|
|
159
|
-
input.value = `${input.value.slice(0, start)}${format.slice(start, end)}${input.value.slice(end)}`;
|
|
160
|
-
input.setSelectionRange(start, end);
|
|
161
|
-
_setDateValue(null);
|
|
162
|
-
break;
|
|
163
|
-
case 'ArrowLeft':
|
|
164
|
-
const prevRange = ranges[ranges.indexOf(currentRange.current) - 1] || ranges[0];
|
|
165
|
-
currentRange.current = prevRange;
|
|
166
|
-
input.setSelectionRange(prevRange.start, prevRange.end);
|
|
167
|
-
break;
|
|
168
|
-
case 'ArrowRight':
|
|
169
|
-
selectNext(input);
|
|
170
|
-
break;
|
|
171
|
-
case 'ArrowUp':
|
|
172
|
-
case 'ArrowDown':
|
|
173
|
-
let valueFragment = +input.value.slice(start, end);
|
|
174
|
-
if (isNaN(valueFragment)) {
|
|
175
|
-
valueFragment = 0;
|
|
176
|
-
}
|
|
177
|
-
key === 'ArrowUp' ? valueFragment++ : valueFragment--;
|
|
178
|
-
switch (token) {
|
|
179
|
-
case 'Y':
|
|
180
|
-
break;
|
|
181
|
-
case 'M':
|
|
182
|
-
valueFragment >= 13 ? valueFragment = 1
|
|
183
|
-
: valueFragment <= 0 && (valueFragment = 12);
|
|
184
|
-
break;
|
|
185
|
-
case 'D':
|
|
186
|
-
valueFragment >= 32 ? valueFragment = 1
|
|
187
|
-
: valueFragment <= 0 && (valueFragment = 31);
|
|
188
|
-
break;
|
|
189
|
-
default:
|
|
190
|
-
valueFragment >= 60 ? valueFragment = 1
|
|
191
|
-
: valueFragment <= 0 && (valueFragment = 59);
|
|
192
|
-
}
|
|
193
|
-
input.value = `${input.value.slice(0, start)}${valueFragment.toString().padStart(end - start, '0')}${input.value.slice(end)}`;
|
|
194
|
-
input.setSelectionRange(start, end);
|
|
195
|
-
const d = (0, dayjs_1.default)(input.value, format);
|
|
196
|
-
d.isValid() && _setDateValue(d);
|
|
197
|
-
break;
|
|
198
|
-
case 'Escape':
|
|
199
|
-
_setInnerOpen(false);
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
const selectNext = (input) => {
|
|
203
|
-
resetContinue();
|
|
204
|
-
const nextRange = ranges[ranges.indexOf(currentRange.current) + 1] || ranges[ranges.length - 1];
|
|
205
|
-
currentRange.current = nextRange;
|
|
206
|
-
input.setSelectionRange(nextRange.start, nextRange.end);
|
|
207
|
-
};
|
|
208
34
|
const contextValue = (0, react_1.useMemo)(() => ({
|
|
209
35
|
min, max, disabledHours, disabledMinutes, disabledSeconds
|
|
210
36
|
}), [
|
|
@@ -212,7 +38,8 @@ exports.DateTimePicker = (0, react_1.memo)(({ inputProps, popperProps, min, max,
|
|
|
212
38
|
]);
|
|
213
39
|
const showCalendar = /[YMD]/.test(format);
|
|
214
40
|
const showTimer = /[Hms]/.test(format);
|
|
215
|
-
|
|
41
|
+
// 若外部没有值,内部需要“现在”作为默认值
|
|
42
|
+
const innerValue = dateValue.current || (0, dayjs_1.default)();
|
|
216
43
|
return ((0, jsx_runtime_1.jsx)(popper_1.Popper, { ...(0, utils_1.mergeComponentProps)({
|
|
217
44
|
css: dateTimePicker_style_1.datePickerPopperStyle,
|
|
218
45
|
open: innerOpen.current,
|
|
@@ -222,8 +49,8 @@ exports.DateTimePicker = (0, react_1.memo)(({ inputProps, popperProps, min, max,
|
|
|
222
49
|
content: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showCalendar &&
|
|
223
50
|
(0, jsx_runtime_1.jsx)(calendar_1.Calendar, { viewLevel: format.includes('D') ? 'date'
|
|
224
51
|
: format.includes('M') ? 'month'
|
|
225
|
-
: 'year', _defaultNull: !dateValue.current, value:
|
|
226
|
-
(0, jsx_runtime_1.jsx)(DateTimePickerContext, { value: contextValue, children: (0, jsx_runtime_1.jsx)(timer_1.Timer, { showHours: format.includes('H'), showMinutes: format.includes('m'), showSeconds: format.includes('s'), value:
|
|
52
|
+
: 'year', _defaultNull: !dateValue.current, value: innerValue, onChange: setDateValue, min: min, max: max, disabledDates: disabledDates }), showTimer &&
|
|
53
|
+
(0, jsx_runtime_1.jsx)(DateTimePickerContext, { value: contextValue, children: (0, jsx_runtime_1.jsx)(timer_1.Timer, { showHours: format.includes('H'), showMinutes: format.includes('m'), showSeconds: format.includes('s'), value: innerValue, onChange: setDateValue }) })] }))
|
|
227
54
|
}, popperProps, {
|
|
228
55
|
onOpenChange: setInnerOpen,
|
|
229
56
|
onPointerDown: e => e.preventDefault()
|
|
@@ -231,15 +58,12 @@ exports.DateTimePicker = (0, react_1.memo)(({ inputProps, popperProps, min, max,
|
|
|
231
58
|
css: dateTimePicker_style_1.style,
|
|
232
59
|
className: dateTimePicker_style_1.classes.root,
|
|
233
60
|
value: dateValue.current,
|
|
234
|
-
onClear
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
ref: innerInputRef,
|
|
241
|
-
className: dateTimePicker_style_1.classes.input
|
|
242
|
-
}) }), (0, jsx_runtime_1.jsx)("div", { className: dateTimePicker_style_1.classes.dateTimeIcon, children: showTimer && !showCalendar
|
|
61
|
+
onClear() {
|
|
62
|
+
setDateValue(null);
|
|
63
|
+
}
|
|
64
|
+
}), "data-focused": innerOpen.current, children: inputBaseProps => (0, jsx_runtime_1.jsxs)("div", { className: dateTimePicker_style_1.classes.container, children: [!dateValue.current
|
|
65
|
+
? (0, jsx_runtime_1.jsx)("div", { className: dateTimePicker_style_1.classes.placeholder, children: props.placeholder ?? '请选择' })
|
|
66
|
+
: (0, jsx_runtime_1.jsx)("div", { className: dateTimePicker_style_1.classes.backfill, children: dateValue.current.format(format) }), (0, jsx_runtime_1.jsx)("input", { size: 1, ...(0, utils_1.mergeComponentProps)(inputBaseProps, inputProps), "data-hidden": "true" }), (0, jsx_runtime_1.jsx)("div", { className: dateTimePicker_style_1.classes.dateTimeIcon, children: showTimer && !showCalendar
|
|
243
67
|
? (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faClock_1.faClock })
|
|
244
68
|
: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faCalendar_1.faCalendar }) })] }) }) }));
|
|
245
69
|
});
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
export declare const classes: {
|
|
2
|
-
|
|
3
|
-
calendar: string;
|
|
2
|
+
placeholder: string;
|
|
4
3
|
container: string;
|
|
5
|
-
|
|
6
|
-
inputGroup: string;
|
|
7
|
-
inputUnit: string;
|
|
4
|
+
backfill: string;
|
|
8
5
|
dateTimeIcon: string;
|
|
9
|
-
calendarHead: string;
|
|
10
|
-
calendarHeadSide: string;
|
|
11
|
-
calendarHeadControl: string;
|
|
12
|
-
calendarHeadCenter: string;
|
|
13
|
-
calendarHeadButton: string;
|
|
14
|
-
calendarBody: string;
|
|
15
|
-
calendarDays: string;
|
|
16
6
|
} & {
|
|
17
7
|
root: string;
|
|
18
8
|
};
|
|
@@ -3,35 +3,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.datePickerPopperStyle = exports.style = exports.classes = void 0;
|
|
4
4
|
const react_1 = require("@emotion/react");
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
|
-
const input_style_1 = require("../input/input.style");
|
|
7
6
|
const calendar_style_1 = require("../calendar/calendar.style");
|
|
8
7
|
const timer_style_1 = require("./timer.style");
|
|
9
8
|
const popper_style_1 = require("../popper/popper.style");
|
|
10
9
|
exports.classes = (0, utils_1.defineInnerClasses)('date-time-picker', [
|
|
11
|
-
'input',
|
|
12
10
|
'container',
|
|
13
|
-
'inputGroup',
|
|
14
|
-
'inputUnit',
|
|
15
11
|
'dateTimeIcon',
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'calendarHeadSide',
|
|
19
|
-
'calendarHeadControl',
|
|
20
|
-
'calendarHeadCenter',
|
|
21
|
-
'calendarHeadButton',
|
|
22
|
-
'calendarBody',
|
|
23
|
-
'calendarDays',
|
|
24
|
-
'dateItem'
|
|
12
|
+
'placeholder',
|
|
13
|
+
'backfill'
|
|
25
14
|
]);
|
|
26
|
-
exports.style = (0, utils_1.defineCss)(({ text }) => (0, react_1.css) `
|
|
15
|
+
exports.style = (0, utils_1.defineCss)(({ text, spacing }) => (0, react_1.css) `
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
|
|
27
18
|
.${exports.classes.container} {
|
|
28
19
|
display: flex;
|
|
29
20
|
align-items: center;
|
|
30
21
|
|
|
31
|
-
.${exports.classes.
|
|
32
|
-
|
|
22
|
+
.${exports.classes.placeholder} {
|
|
23
|
+
flex: 1;
|
|
24
|
+
color: ${text.placeholder};
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
text-overflow: ellipsis;
|
|
27
|
+
overflow: hidden;
|
|
33
28
|
}
|
|
34
|
-
|
|
29
|
+
|
|
30
|
+
.${exports.classes.backfill} {
|
|
31
|
+
flex: 1;
|
|
32
|
+
min-width: 0;
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-wrap: wrap;
|
|
35
|
+
gap: ${spacing[1]}px;
|
|
36
|
+
}
|
|
37
|
+
|
|
35
38
|
.${exports.classes.dateTimeIcon} {
|
|
36
39
|
color: ${text.secondary};
|
|
37
40
|
}
|
|
@@ -23,11 +23,7 @@ exports.Descriptions = (0, react_2.memo)(({ size, labelWidth, colon = ':', label
|
|
|
23
23
|
size, labelWidth, colon, labelPlacement, disableMargin, disablePadding, variant
|
|
24
24
|
]);
|
|
25
25
|
const renderGridItems = () => {
|
|
26
|
-
return items?.map((itemProps, i) => (0, react_1.createElement)(ItemComponent
|
|
27
|
-
// 最后一项沾满剩余行空间
|
|
28
|
-
, {
|
|
29
|
-
// 最后一项沾满剩余行空间
|
|
30
|
-
flex: i === items.length - 1 ? 1 : void 0, ...itemProps, key: itemProps.key ?? i })) || props.children;
|
|
26
|
+
return items?.map((itemProps, i) => (0, react_1.createElement)(ItemComponent, { ...itemProps, key: itemProps.key ?? i })) || props.children;
|
|
31
27
|
};
|
|
32
28
|
const columnCountNum = (0, utils_1.useResponsiveValue)(columnCount, variant === 'grid');
|
|
33
29
|
const renderTableItems = () => {
|
|
@@ -62,12 +62,12 @@ function Dialog({ icon, title, footer, prefix, suffix, width = 420, minWidth, ma
|
|
|
62
62
|
(0, react_1.useEffect)(() => {
|
|
63
63
|
if (innerOpen.current) {
|
|
64
64
|
const resizeObserver = new ResizeObserver(onScroll);
|
|
65
|
+
resizeObserver.observe(bodyRef.current);
|
|
65
66
|
resizeObserver.observe(bodyWrapRef.current);
|
|
66
67
|
return () => {
|
|
67
68
|
resizeObserver.disconnect();
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
|
-
return;
|
|
71
71
|
}, [innerOpen.current]);
|
|
72
72
|
/**
|
|
73
73
|
* ---------------------------------------------------------------------
|
|
@@ -38,6 +38,7 @@ exports.style = (0, utils_1.defineCss)(({ background, borderRadius, boxShadow, s
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
.${exports.classes.content} {
|
|
41
|
+
min-width: 0;
|
|
41
42
|
flex: 1;
|
|
42
43
|
display: flex;
|
|
43
44
|
flex-direction: column;
|
|
@@ -93,6 +94,7 @@ exports.style = (0, utils_1.defineCss)(({ background, borderRadius, boxShadow, s
|
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
.${exports.classes.bodyWrap} {
|
|
97
|
+
min-width: 0;
|
|
96
98
|
flex: 1;
|
|
97
99
|
}
|
|
98
100
|
|