@canlooks/can-ui 0.0.75 → 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/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/inputBase/inputBase.js +10 -1
- package/dist/cjs/components/popper/popper.js +21 -20
- 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/utils/utils.d.ts +5 -3
- package/dist/cjs/utils/utils.js +22 -7
- 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/inputBase/inputBase.js +11 -2
- package/dist/esm/components/popper/popper.js +22 -21
- 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/utils/utils.d.ts +5 -3
- package/dist/esm/utils/utils.js +21 -6
- package/package.json +1 -1
|
@@ -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
|
* ---------------------------------------------------------------------
|
|
@@ -56,6 +56,15 @@ min, max, step, precision, placeholder, disabled, readOnly, autoFocus, defaultVa
|
|
|
56
56
|
changeHandler(e);
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
+
const shouldRenderClearButton = () => {
|
|
60
|
+
if (!clearable || disabled || readOnly || (0, utils_1.isUnset)(innerValue.current)) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (Array.isArray(innerValue.current) || typeof innerValue.current === 'string') {
|
|
64
|
+
return !!innerValue.current.length;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
};
|
|
59
68
|
return ((0, jsx_runtime_1.jsxs)("div", { ...(0, utils_1.mergeComponentProps)(props, {
|
|
60
69
|
ref: innerRef,
|
|
61
70
|
className: inputBase_style_1.classes.root,
|
|
@@ -86,7 +95,7 @@ min, max, step, precision, placeholder, disabled, readOnly, autoFocus, defaultVa
|
|
|
86
95
|
onBlur: blurHandler,
|
|
87
96
|
onKeyDown: (e) => e.key === 'Enter' && blurHandler(e)
|
|
88
97
|
}) }), loading &&
|
|
89
|
-
(0, jsx_runtime_1.jsx)(loadingIndicator_1.LoadingIndicator, {}),
|
|
98
|
+
(0, jsx_runtime_1.jsx)(loadingIndicator_1.LoadingIndicator, {}), shouldRenderClearButton() &&
|
|
90
99
|
(0, jsx_runtime_1.jsx)(button_1.Button, { className: inputBase_style_1.classes.clear, variant: "plain", color: "text.disabled", onClick: clear, tabIndex: -1, children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faCircleXmark_1.faCircleXmark }) }), !!suffix &&
|
|
91
100
|
(0, jsx_runtime_1.jsx)("div", { className: inputBase_style_1.classes.suffix, children: suffix })] }));
|
|
92
101
|
});
|
|
@@ -15,8 +15,8 @@ const getAttemptOrder = (placement) => {
|
|
|
15
15
|
if (index > -1) {
|
|
16
16
|
return [
|
|
17
17
|
placement,
|
|
18
|
-
...order.slice(0, index),
|
|
19
18
|
...order.slice(index + 1),
|
|
19
|
+
...order.slice(0, index),
|
|
20
20
|
placement
|
|
21
21
|
];
|
|
22
22
|
}
|
|
@@ -65,8 +65,8 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
65
65
|
}
|
|
66
66
|
tellParentOpenChange(innerOpen.current);
|
|
67
67
|
}, [innerOpen.current]);
|
|
68
|
-
const onChildrenOpenChange = (
|
|
69
|
-
hold(
|
|
68
|
+
const onChildrenOpenChange = (childrenOpen) => {
|
|
69
|
+
hold(childrenOpen) === 0 && setInnerOpen(false);
|
|
70
70
|
};
|
|
71
71
|
const setOpenForce = (open) => {
|
|
72
72
|
if (!open) {
|
|
@@ -126,7 +126,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
126
126
|
// 右键菜单
|
|
127
127
|
const mouseX = contextMenuEvent.current.clientX - containerRect.left;
|
|
128
128
|
const mouseY = contextMenuEvent.current.clientY - containerRect.top;
|
|
129
|
-
attempt =
|
|
129
|
+
attempt = placement => {
|
|
130
130
|
[, pA, pB] = placement.match(/^(top|bottom|left|right)(Top|Bottom|Left|Right)?/);
|
|
131
131
|
if (pB) {
|
|
132
132
|
switch (placement) {
|
|
@@ -190,7 +190,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
190
190
|
}
|
|
191
191
|
popperEl.style.left = left + 'px';
|
|
192
192
|
popperEl.style.top = top + 'px';
|
|
193
|
-
return (0, utils_1.
|
|
193
|
+
return (0, utils_1.isElementOverflowed)(popperEl, containerEl.current === document.body ? void 0 : containerEl.current);
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
else {
|
|
@@ -198,7 +198,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
198
198
|
const anchorRect = getAnchorElement().getBoundingClientRect();
|
|
199
199
|
const topEdge = anchorRect.top - containerRect.top;
|
|
200
200
|
const leftEdge = anchorRect.left - containerRect.left;
|
|
201
|
-
attempt =
|
|
201
|
+
attempt = placement => {
|
|
202
202
|
[, pA, pB] = placement.match(/^(top|bottom|left|right)(Top|Bottom|Left|Right)?/);
|
|
203
203
|
if (sizeAdaptable) {
|
|
204
204
|
if (pA === 'top' || pA === 'bottom') {
|
|
@@ -261,7 +261,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
261
261
|
}
|
|
262
262
|
popperEl.style.left = left + 'px';
|
|
263
263
|
popperEl.style.top = top + 'px';
|
|
264
|
-
return (0, utils_1.
|
|
264
|
+
return (0, utils_1.isElementOverflowed)(popperEl, containerEl.current === document.body ? void 0 : containerEl.current);
|
|
265
265
|
};
|
|
266
266
|
}
|
|
267
267
|
if (options?.forcePlacement) {
|
|
@@ -270,7 +270,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
270
270
|
else {
|
|
271
271
|
const attemptOrder = getAttemptOrder(placement);
|
|
272
272
|
for (let i = 0; i < attemptOrder.length; i++) {
|
|
273
|
-
if (attempt(attemptOrder[i])) {
|
|
273
|
+
if (attempt(attemptOrder[i]) === false) {
|
|
274
274
|
break;
|
|
275
275
|
}
|
|
276
276
|
}
|
|
@@ -295,8 +295,8 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
295
295
|
popperEl.style.transform = variant === 'collapse'
|
|
296
296
|
? pA === 'top' || pA === 'bottom' ? 'scaleY(0)' : 'scaleX(0)'
|
|
297
297
|
: 'scale(0)';
|
|
298
|
+
animating.current = true;
|
|
298
299
|
requestAnimationFrame(() => {
|
|
299
|
-
animating.current = true;
|
|
300
300
|
settle();
|
|
301
301
|
setOpenNextFrame(true);
|
|
302
302
|
});
|
|
@@ -360,26 +360,26 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
360
360
|
const hoverable = triggersSet.has('hover');
|
|
361
361
|
const enterTimeout = (0, react_1.useRef)(void 0);
|
|
362
362
|
const leaveTimeout = (0, react_1.useRef)(void 0);
|
|
363
|
-
const
|
|
363
|
+
const hoverStack = (0, react_1.useRef)(0);
|
|
364
364
|
const pointerEnter = () => {
|
|
365
|
-
if (
|
|
365
|
+
if (hoverStack.current++) {
|
|
366
366
|
return;
|
|
367
367
|
}
|
|
368
|
-
isEntered.current = true;
|
|
369
|
-
hold(true);
|
|
370
368
|
clearTimeout(leaveTimeout.current);
|
|
371
369
|
mouseEnterDelay
|
|
372
370
|
? enterTimeout.current = setTimeout(() => setInnerOpen(true), mouseEnterDelay)
|
|
373
371
|
: setInnerOpen(true);
|
|
374
372
|
};
|
|
375
373
|
const pointerLeave = () => {
|
|
376
|
-
|
|
377
|
-
|
|
374
|
+
if (--hoverStack.current) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
378
377
|
clearTimeout(enterTimeout.current);
|
|
379
378
|
mouseLeaveDelay
|
|
380
379
|
? leaveTimeout.current = setTimeout(() => setInnerOpen(false), mouseLeaveDelay)
|
|
381
380
|
: setInnerOpen(false);
|
|
382
381
|
};
|
|
382
|
+
// 绑定锚点元素
|
|
383
383
|
(0, react_1.useEffect)(() => {
|
|
384
384
|
if (!hoverable) {
|
|
385
385
|
return;
|
|
@@ -392,6 +392,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
392
392
|
anchorEl.removeEventListener('pointerleave', pointerLeave);
|
|
393
393
|
};
|
|
394
394
|
}, [hoverable]);
|
|
395
|
+
// 绑定弹框元素,鼠标移入弹框也要保持弹框打开
|
|
395
396
|
(0, react_1.useEffect)(() => {
|
|
396
397
|
if (!hoverable || !innerPopperRef.current) {
|
|
397
398
|
return;
|
|
@@ -431,7 +432,9 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
431
432
|
return;
|
|
432
433
|
}
|
|
433
434
|
const keyDown = (e) => {
|
|
434
|
-
e.key === 'Enter'
|
|
435
|
+
if (e.key === 'Enter') {
|
|
436
|
+
openAndHold(true);
|
|
437
|
+
}
|
|
435
438
|
};
|
|
436
439
|
const anchorEl = anchorRef.current;
|
|
437
440
|
anchorEl.addEventListener('keydown', keyDown);
|
|
@@ -447,9 +450,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
447
450
|
if (!clickable) {
|
|
448
451
|
return;
|
|
449
452
|
}
|
|
450
|
-
const click = () =>
|
|
451
|
-
openAndHold(true);
|
|
452
|
-
};
|
|
453
|
+
const click = () => openAndHold(true);
|
|
453
454
|
const anchorEl = anchorRef.current;
|
|
454
455
|
anchorEl.addEventListener('click', click);
|
|
455
456
|
return () => {
|
|
@@ -457,7 +458,7 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
|
|
|
457
458
|
};
|
|
458
459
|
}, []);
|
|
459
460
|
const onClickAway = () => {
|
|
460
|
-
innerOpen.current &&
|
|
461
|
+
innerOpen.current && setOpenForce(false);
|
|
461
462
|
};
|
|
462
463
|
/**
|
|
463
464
|
* clickToClose
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Table = Table;
|
|
4
4
|
exports.TableRow = TableRow;
|
|
5
5
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
6
7
|
const table_style_1 = require("./table.style");
|
|
7
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
const theme_1 = require("../theme");
|
|
@@ -10,7 +11,8 @@ const tableSticky_1 = require("./tableSticky");
|
|
|
10
11
|
function Table({ size, bordered = 'none', striped = false, ...props }) {
|
|
11
12
|
const theme = (0, theme_1.useTheme)();
|
|
12
13
|
size ??= theme.size;
|
|
13
|
-
|
|
14
|
+
const tableRef = (0, react_1.useRef)(null);
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)("table", { ...props, css: table_style_1.style, ref: (0, utils_1.cloneRef)(props.ref, tableRef), className: (0, utils_1.clsx)(table_style_1.classes.root, props.className), "data-size": size, "data-bordered": bordered, "data-striped": striped }));
|
|
14
16
|
}
|
|
15
17
|
function TableRow({ selected, ...props }) {
|
|
16
18
|
return (0, jsx_runtime_1.jsx)("tr", { ...props, "data-selected": selected });
|
|
@@ -9,9 +9,9 @@ exports.classes = (0, utils_1.defineInnerClasses)('table', [
|
|
|
9
9
|
'container',
|
|
10
10
|
'cell'
|
|
11
11
|
]);
|
|
12
|
-
exports.style = (0, utils_1.defineCss)(({ mode, spacing, gray, divider, easing, colors }) => {
|
|
13
|
-
const headerBg = gray(mode === 'light' ? .
|
|
14
|
-
const stripedBg = gray(mode === 'light' ? .
|
|
12
|
+
exports.style = (0, utils_1.defineCss)(({ mode, spacing, gray, divider, background, easing, colors }) => {
|
|
13
|
+
const headerBg = gray(mode === 'light' ? .03 : .22);
|
|
14
|
+
const stripedBg = gray(mode === 'light' ? .02 : .21);
|
|
15
15
|
const selectedBg = (0, color_1.default)(colors.primary.main).alpha(mode === 'light' ? .05 : .1).string();
|
|
16
16
|
return (0, react_1.css) `
|
|
17
17
|
width: 100%;
|
|
@@ -38,6 +38,14 @@ exports.style = (0, utils_1.defineCss)(({ mode, spacing, gray, divider, easing,
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
tbody tr {
|
|
42
|
+
&:not(:hover):not([data-selected=true]) {
|
|
43
|
+
th, td {
|
|
44
|
+
background-color: ${background.content};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
41
49
|
th, td {
|
|
42
50
|
position: relative;
|
|
43
51
|
text-align: left;
|
|
@@ -59,11 +67,18 @@ exports.style = (0, utils_1.defineCss)(({ mode, spacing, gray, divider, easing,
|
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
&[data-bordered=all], &[data-bordered=true] {
|
|
62
|
-
border-top: 1px solid ${divider};
|
|
63
|
-
border-left: 1px solid ${divider};
|
|
64
|
-
|
|
65
70
|
th, td {
|
|
66
71
|
border-right: 1px solid ${divider};
|
|
72
|
+
|
|
73
|
+
&:first-of-type {
|
|
74
|
+
border-left: 1px solid ${divider};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
thead tr:first-of-type {
|
|
79
|
+
th, td {
|
|
80
|
+
border-top: 1px solid ${divider};
|
|
81
|
+
}
|
|
67
82
|
}
|
|
68
83
|
}
|
|
69
84
|
|