@tidbcloud/uikit 2.4.8 → 2.4.10
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/CHANGELOG.md +12 -0
- package/dist/biz/DateTimePicker/TimeScollerPicker.cjs +93 -31
- package/dist/biz/DateTimePicker/TimeScollerPicker.d.cts +1 -2
- package/dist/biz/DateTimePicker/TimeScollerPicker.d.mts +1 -2
- package/dist/biz/DateTimePicker/TimeScollerPicker.mjs +93 -31
- package/dist/biz/DateTimePicker/index.cjs +21 -16
- package/dist/biz/DateTimePicker/index.d.cts +3 -3
- package/dist/biz/DateTimePicker/index.d.mts +3 -3
- package/dist/biz/DateTimePicker/index.mjs +21 -16
- package/dist/biz/ProMultiSelect/index.cjs +3 -0
- package/dist/biz/ProMultiSelect/index.d.cts +1 -1
- package/dist/biz/ProMultiSelect/index.d.mts +1 -1
- package/dist/biz/ProMultiSelect/index.mjs +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @tidbcloud/uikit
|
|
2
2
|
|
|
3
|
+
## 2.4.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat(ProMultiSelect): support `sx` and `size` props ([#561](https://github.com/tidbcloud/tidbcloud-uikit/pull/561))
|
|
8
|
+
|
|
9
|
+
## 2.4.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- refactor(DateTimePicker): remove utcOffset prop and simplify timezone handling ([#559](https://github.com/tidbcloud/tidbcloud-uikit/pull/559))
|
|
14
|
+
|
|
3
15
|
## 2.4.8
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -16,7 +16,7 @@ const useUncontrolled = require("../../node_modules/.pnpm/@mantine_hooks@7.15.2_
|
|
|
16
16
|
const ScrollArea = require("../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@mantine_hooks@7.15.2_react@18.3.1_szqfuioo5damkjdixckhzmwycq/node_modules/@mantine/core/esm/components/ScrollArea/ScrollArea.cjs");
|
|
17
17
|
const Box = require("../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@mantine_hooks@7.15.2_react@18.3.1_szqfuioo5damkjdixckhzmwycq/node_modules/@mantine/core/esm/core/Box/Box.cjs");
|
|
18
18
|
const createStyles = require("../../node_modules/.pnpm/@mantine_emotion@7.15.2_@emotion_cache@11.14.0_@emotion_react@11.14.0_@types_react@18.3.18_re_vflj3eioazr6wkrxpatinf66nq/node_modules/@mantine/emotion/esm/create-styles.cjs");
|
|
19
|
-
const useStyles = createStyles.createStyles(() => ({
|
|
19
|
+
const useStyles = createStyles.createStyles((theme) => ({
|
|
20
20
|
bold: {
|
|
21
21
|
fontWeight: 600
|
|
22
22
|
},
|
|
@@ -26,6 +26,14 @@ const useStyles = createStyles.createStyles(() => ({
|
|
|
26
26
|
scrollSnapAlign: "start",
|
|
27
27
|
userSelect: "none"
|
|
28
28
|
},
|
|
29
|
+
cellDisabled: {
|
|
30
|
+
textAlign: "center",
|
|
31
|
+
scrollSnapAlign: "start",
|
|
32
|
+
userSelect: "none",
|
|
33
|
+
cursor: "not-allowed",
|
|
34
|
+
color: theme.colors.carbon[6],
|
|
35
|
+
opacity: 0.5
|
|
36
|
+
},
|
|
29
37
|
cellPlaceholder: {
|
|
30
38
|
visibility: "hidden"
|
|
31
39
|
}
|
|
@@ -34,8 +42,7 @@ const getTimeRange = ({
|
|
|
34
42
|
curr,
|
|
35
43
|
type,
|
|
36
44
|
start,
|
|
37
|
-
end
|
|
38
|
-
utcOffset = dayjs.dayjs().utcOffset()
|
|
45
|
+
end
|
|
39
46
|
}) => {
|
|
40
47
|
const map = {
|
|
41
48
|
year: {
|
|
@@ -64,8 +71,8 @@ const getTimeRange = ({
|
|
|
64
71
|
}
|
|
65
72
|
};
|
|
66
73
|
let { min, max } = map[type];
|
|
67
|
-
const s1 = start ? dayjs.dayjs(start)
|
|
68
|
-
const s2 = end ? dayjs.dayjs(end)
|
|
74
|
+
const s1 = start ? dayjs.dayjs(start) : null;
|
|
75
|
+
const s2 = end ? dayjs.dayjs(end) : null;
|
|
69
76
|
switch (type) {
|
|
70
77
|
case "year": {
|
|
71
78
|
if (s1) {
|
|
@@ -140,9 +147,21 @@ function TimePickerScrollerColumn({
|
|
|
140
147
|
}) {
|
|
141
148
|
const { classes, cx: clsx } = useStyles();
|
|
142
149
|
const ref = React.useRef(null);
|
|
143
|
-
const
|
|
150
|
+
const fullRange = React.useMemo(() => {
|
|
151
|
+
switch (name) {
|
|
152
|
+
case "hour":
|
|
153
|
+
return lodashEs.range(0, 24);
|
|
154
|
+
case "minute":
|
|
155
|
+
case "second":
|
|
156
|
+
return lodashEs.range(0, 60);
|
|
157
|
+
default:
|
|
158
|
+
return lodashEs.range(min, max + 1);
|
|
159
|
+
}
|
|
160
|
+
}, [name, min, max]);
|
|
161
|
+
const numbers = fullRange;
|
|
144
162
|
const timeoutRef = React.useRef();
|
|
145
163
|
const isArtificialScroll = React.useRef(false);
|
|
164
|
+
const isDisabled = React.useMemo(() => (val2) => val2 < min || val2 > max, [min, max]);
|
|
146
165
|
const [val, setVal] = useUncontrolled.useUncontrolled({
|
|
147
166
|
value: curr,
|
|
148
167
|
onChange
|
|
@@ -160,6 +179,27 @@ function TimePickerScrollerColumn({
|
|
|
160
179
|
});
|
|
161
180
|
}
|
|
162
181
|
});
|
|
182
|
+
const findNearestValidValue = ahooks.useMemoizedFn((targetIndex) => {
|
|
183
|
+
let upIndex = targetIndex;
|
|
184
|
+
let downIndex = targetIndex;
|
|
185
|
+
while (upIndex >= 0 || downIndex < numbers.length) {
|
|
186
|
+
if (upIndex >= 0 && upIndex < numbers.length) {
|
|
187
|
+
const upVal = numbers[upIndex];
|
|
188
|
+
if (!isDisabled(upVal)) {
|
|
189
|
+
return { value: upVal, index: upIndex };
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (downIndex >= 0 && downIndex < numbers.length) {
|
|
193
|
+
const downVal = numbers[downIndex];
|
|
194
|
+
if (!isDisabled(downVal)) {
|
|
195
|
+
return { value: downVal, index: downIndex };
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
upIndex++;
|
|
199
|
+
downIndex--;
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
});
|
|
163
203
|
const onScroll = ahooks.useMemoizedFn((position) => {
|
|
164
204
|
if (isArtificialScroll.current) return;
|
|
165
205
|
if (currentValueChangedBy) return;
|
|
@@ -167,24 +207,44 @@ function TimePickerScrollerColumn({
|
|
|
167
207
|
const i = position.y / constant.CellHeight;
|
|
168
208
|
if (i === Math.floor(i)) {
|
|
169
209
|
const val2 = i >= numbers.length ? numbers.at(-1) : numbers[i];
|
|
170
|
-
if (typeof val2 !== "undefined") {
|
|
210
|
+
if (typeof val2 !== "undefined" && !isDisabled(val2)) {
|
|
171
211
|
setVal(val2);
|
|
212
|
+
} else if (typeof val2 !== "undefined" && isDisabled(val2)) {
|
|
213
|
+
const nearest = findNearestValidValue(i);
|
|
214
|
+
if (nearest) {
|
|
215
|
+
setVal(nearest.value);
|
|
216
|
+
setTimeout(() => {
|
|
217
|
+
var _a;
|
|
218
|
+
(_a = ref.current) == null ? void 0 : _a.scrollTo({ top: nearest.index * constant.CellHeight, behavior: "smooth" });
|
|
219
|
+
}, 100);
|
|
220
|
+
}
|
|
172
221
|
}
|
|
173
222
|
} else {
|
|
174
223
|
timeoutRef.current = window.setTimeout(() => {
|
|
175
224
|
const k = Math.round(i);
|
|
176
225
|
const val2 = k >= numbers.length ? numbers.at(-1) : numbers[k];
|
|
177
|
-
if (typeof val2 !== "undefined") {
|
|
226
|
+
if (typeof val2 !== "undefined" && !isDisabled(val2)) {
|
|
178
227
|
setVal(val2);
|
|
228
|
+
} else if (typeof val2 !== "undefined" && isDisabled(val2)) {
|
|
229
|
+
const nearest = findNearestValidValue(k);
|
|
230
|
+
if (nearest) {
|
|
231
|
+
setVal(nearest.value);
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
var _a;
|
|
234
|
+
(_a = ref.current) == null ? void 0 : _a.scrollTo({ top: nearest.index * constant.CellHeight, behavior: "smooth" });
|
|
235
|
+
}, 100);
|
|
236
|
+
}
|
|
179
237
|
}
|
|
180
238
|
}, 300);
|
|
181
239
|
}
|
|
182
240
|
});
|
|
183
|
-
const handleClickCell = ahooks.useMemoizedFn((e, i) => {
|
|
241
|
+
const handleClickCell = ahooks.useMemoizedFn((e, i, val2) => {
|
|
184
242
|
var _a;
|
|
185
243
|
e.stopPropagation();
|
|
186
244
|
e.preventDefault();
|
|
187
|
-
(
|
|
245
|
+
if (!isDisabled(val2)) {
|
|
246
|
+
(_a = ref.current) == null ? void 0 : _a.scrollTo({ top: i * constant.CellHeight, behavior: "smooth" });
|
|
247
|
+
}
|
|
188
248
|
});
|
|
189
249
|
React.useEffect(() => {
|
|
190
250
|
adjustScrollTop(val);
|
|
@@ -202,16 +262,19 @@ function TimePickerScrollerColumn({
|
|
|
202
262
|
},
|
|
203
263
|
onScrollPositionChange: onScroll,
|
|
204
264
|
children: [
|
|
205
|
-
numbers.map((i, index) =>
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
265
|
+
numbers.map((i, index) => {
|
|
266
|
+
const disabled = isDisabled(i);
|
|
267
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
268
|
+
"div",
|
|
269
|
+
{
|
|
270
|
+
className: clsx(disabled ? classes.cellDisabled : classes.cell, i === curr && !disabled && classes.bold),
|
|
271
|
+
onClick: (e) => handleClickCell(e, index, i),
|
|
272
|
+
style: constant.CellStyle,
|
|
273
|
+
children: render ? render(i) : i
|
|
274
|
+
},
|
|
275
|
+
i
|
|
276
|
+
);
|
|
277
|
+
}),
|
|
215
278
|
lodashEs.range(6).map((i) => /* @__PURE__ */ jsxRuntime.jsx(Box.Box, { className: clsx(classes.cell, classes.cellPlaceholder), style: constant.CellStyle }, i))
|
|
216
279
|
]
|
|
217
280
|
}
|
|
@@ -222,26 +285,25 @@ function TimeScollerPicker({
|
|
|
222
285
|
currentValueChangedBy,
|
|
223
286
|
start,
|
|
224
287
|
end,
|
|
225
|
-
utcOffset,
|
|
226
288
|
onChange
|
|
227
289
|
}) {
|
|
228
290
|
const options = React.useMemo(
|
|
229
291
|
() => ({
|
|
230
|
-
hour: getTimeRange({ curr: currentValue, start, end,
|
|
231
|
-
minute: getTimeRange({ curr: currentValue, start, end,
|
|
232
|
-
second: getTimeRange({ curr: currentValue, start, end,
|
|
292
|
+
hour: getTimeRange({ curr: currentValue, start, end, type: "hour" }),
|
|
293
|
+
minute: getTimeRange({ curr: currentValue, start, end, type: "minute" }),
|
|
294
|
+
second: getTimeRange({ curr: currentValue, start, end, type: "second" })
|
|
233
295
|
}),
|
|
234
|
-
[currentValue, start, end
|
|
296
|
+
[currentValue, start, end]
|
|
235
297
|
);
|
|
236
298
|
const hourValue = React.useMemo(() => {
|
|
237
|
-
return
|
|
238
|
-
}, [currentValue
|
|
299
|
+
return currentValue.hour();
|
|
300
|
+
}, [currentValue]);
|
|
239
301
|
const minuteValue = React.useMemo(() => {
|
|
240
|
-
return
|
|
241
|
-
}, [currentValue
|
|
302
|
+
return currentValue.minute();
|
|
303
|
+
}, [currentValue]);
|
|
242
304
|
const secondValue = React.useMemo(() => {
|
|
243
|
-
return
|
|
244
|
-
}, [currentValue
|
|
305
|
+
return currentValue.second();
|
|
306
|
+
}, [currentValue]);
|
|
245
307
|
const onHourChange = ahooks.useMemoizedFn((v) => {
|
|
246
308
|
onChange == null ? void 0 : onChange([v, minuteValue, secondValue]);
|
|
247
309
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
2
|
export type CurrentValueChangedBy = 'calendar' | 'timeInput' | 'timeScroller';
|
|
3
|
-
export declare function TimeScollerPicker({ currentValue, currentValueChangedBy, start, end,
|
|
3
|
+
export declare function TimeScollerPicker({ currentValue, currentValueChangedBy, start, end, onChange }: {
|
|
4
4
|
currentValue: Dayjs;
|
|
5
5
|
currentValueChangedBy: CurrentValueChangedBy | null;
|
|
6
6
|
start?: Date;
|
|
7
7
|
end?: Date;
|
|
8
|
-
utcOffset?: number;
|
|
9
8
|
onChange?: (v: [number, number, number]) => void;
|
|
10
9
|
}): import("react/jsx-runtime.js").JSX.Element;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
2
|
export type CurrentValueChangedBy = 'calendar' | 'timeInput' | 'timeScroller';
|
|
3
|
-
export declare function TimeScollerPicker({ currentValue, currentValueChangedBy, start, end,
|
|
3
|
+
export declare function TimeScollerPicker({ currentValue, currentValueChangedBy, start, end, onChange }: {
|
|
4
4
|
currentValue: Dayjs;
|
|
5
5
|
currentValueChangedBy: CurrentValueChangedBy | null;
|
|
6
6
|
start?: Date;
|
|
7
7
|
end?: Date;
|
|
8
|
-
utcOffset?: number;
|
|
9
8
|
onChange?: (v: [number, number, number]) => void;
|
|
10
9
|
}): import("react/jsx-runtime.js").JSX.Element;
|
|
@@ -14,7 +14,7 @@ import { useUncontrolled } from "../../node_modules/.pnpm/@mantine_hooks@7.15.2_
|
|
|
14
14
|
import { ScrollArea } from "../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@mantine_hooks@7.15.2_react@18.3.1_szqfuioo5damkjdixckhzmwycq/node_modules/@mantine/core/esm/components/ScrollArea/ScrollArea.mjs";
|
|
15
15
|
import { Box } from "../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@mantine_hooks@7.15.2_react@18.3.1_szqfuioo5damkjdixckhzmwycq/node_modules/@mantine/core/esm/core/Box/Box.mjs";
|
|
16
16
|
import { createStyles } from "../../node_modules/.pnpm/@mantine_emotion@7.15.2_@emotion_cache@11.14.0_@emotion_react@11.14.0_@types_react@18.3.18_re_vflj3eioazr6wkrxpatinf66nq/node_modules/@mantine/emotion/esm/create-styles.mjs";
|
|
17
|
-
const useStyles = createStyles(() => ({
|
|
17
|
+
const useStyles = createStyles((theme) => ({
|
|
18
18
|
bold: {
|
|
19
19
|
fontWeight: 600
|
|
20
20
|
},
|
|
@@ -24,6 +24,14 @@ const useStyles = createStyles(() => ({
|
|
|
24
24
|
scrollSnapAlign: "start",
|
|
25
25
|
userSelect: "none"
|
|
26
26
|
},
|
|
27
|
+
cellDisabled: {
|
|
28
|
+
textAlign: "center",
|
|
29
|
+
scrollSnapAlign: "start",
|
|
30
|
+
userSelect: "none",
|
|
31
|
+
cursor: "not-allowed",
|
|
32
|
+
color: theme.colors.carbon[6],
|
|
33
|
+
opacity: 0.5
|
|
34
|
+
},
|
|
27
35
|
cellPlaceholder: {
|
|
28
36
|
visibility: "hidden"
|
|
29
37
|
}
|
|
@@ -32,8 +40,7 @@ const getTimeRange = ({
|
|
|
32
40
|
curr,
|
|
33
41
|
type,
|
|
34
42
|
start,
|
|
35
|
-
end
|
|
36
|
-
utcOffset = dayjs().utcOffset()
|
|
43
|
+
end
|
|
37
44
|
}) => {
|
|
38
45
|
const map = {
|
|
39
46
|
year: {
|
|
@@ -62,8 +69,8 @@ const getTimeRange = ({
|
|
|
62
69
|
}
|
|
63
70
|
};
|
|
64
71
|
let { min, max } = map[type];
|
|
65
|
-
const s1 = start ? dayjs(start)
|
|
66
|
-
const s2 = end ? dayjs(end)
|
|
72
|
+
const s1 = start ? dayjs(start) : null;
|
|
73
|
+
const s2 = end ? dayjs(end) : null;
|
|
67
74
|
switch (type) {
|
|
68
75
|
case "year": {
|
|
69
76
|
if (s1) {
|
|
@@ -138,9 +145,21 @@ function TimePickerScrollerColumn({
|
|
|
138
145
|
}) {
|
|
139
146
|
const { classes, cx: clsx } = useStyles();
|
|
140
147
|
const ref = useRef(null);
|
|
141
|
-
const
|
|
148
|
+
const fullRange = useMemo(() => {
|
|
149
|
+
switch (name) {
|
|
150
|
+
case "hour":
|
|
151
|
+
return range(0, 24);
|
|
152
|
+
case "minute":
|
|
153
|
+
case "second":
|
|
154
|
+
return range(0, 60);
|
|
155
|
+
default:
|
|
156
|
+
return range(min, max + 1);
|
|
157
|
+
}
|
|
158
|
+
}, [name, min, max]);
|
|
159
|
+
const numbers = fullRange;
|
|
142
160
|
const timeoutRef = useRef();
|
|
143
161
|
const isArtificialScroll = useRef(false);
|
|
162
|
+
const isDisabled = useMemo(() => (val2) => val2 < min || val2 > max, [min, max]);
|
|
144
163
|
const [val, setVal] = useUncontrolled({
|
|
145
164
|
value: curr,
|
|
146
165
|
onChange
|
|
@@ -158,6 +177,27 @@ function TimePickerScrollerColumn({
|
|
|
158
177
|
});
|
|
159
178
|
}
|
|
160
179
|
});
|
|
180
|
+
const findNearestValidValue = useMemoizedFn((targetIndex) => {
|
|
181
|
+
let upIndex = targetIndex;
|
|
182
|
+
let downIndex = targetIndex;
|
|
183
|
+
while (upIndex >= 0 || downIndex < numbers.length) {
|
|
184
|
+
if (upIndex >= 0 && upIndex < numbers.length) {
|
|
185
|
+
const upVal = numbers[upIndex];
|
|
186
|
+
if (!isDisabled(upVal)) {
|
|
187
|
+
return { value: upVal, index: upIndex };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (downIndex >= 0 && downIndex < numbers.length) {
|
|
191
|
+
const downVal = numbers[downIndex];
|
|
192
|
+
if (!isDisabled(downVal)) {
|
|
193
|
+
return { value: downVal, index: downIndex };
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
upIndex++;
|
|
197
|
+
downIndex--;
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
});
|
|
161
201
|
const onScroll = useMemoizedFn((position) => {
|
|
162
202
|
if (isArtificialScroll.current) return;
|
|
163
203
|
if (currentValueChangedBy) return;
|
|
@@ -165,24 +205,44 @@ function TimePickerScrollerColumn({
|
|
|
165
205
|
const i = position.y / CellHeight;
|
|
166
206
|
if (i === Math.floor(i)) {
|
|
167
207
|
const val2 = i >= numbers.length ? numbers.at(-1) : numbers[i];
|
|
168
|
-
if (typeof val2 !== "undefined") {
|
|
208
|
+
if (typeof val2 !== "undefined" && !isDisabled(val2)) {
|
|
169
209
|
setVal(val2);
|
|
210
|
+
} else if (typeof val2 !== "undefined" && isDisabled(val2)) {
|
|
211
|
+
const nearest = findNearestValidValue(i);
|
|
212
|
+
if (nearest) {
|
|
213
|
+
setVal(nearest.value);
|
|
214
|
+
setTimeout(() => {
|
|
215
|
+
var _a;
|
|
216
|
+
(_a = ref.current) == null ? void 0 : _a.scrollTo({ top: nearest.index * CellHeight, behavior: "smooth" });
|
|
217
|
+
}, 100);
|
|
218
|
+
}
|
|
170
219
|
}
|
|
171
220
|
} else {
|
|
172
221
|
timeoutRef.current = window.setTimeout(() => {
|
|
173
222
|
const k = Math.round(i);
|
|
174
223
|
const val2 = k >= numbers.length ? numbers.at(-1) : numbers[k];
|
|
175
|
-
if (typeof val2 !== "undefined") {
|
|
224
|
+
if (typeof val2 !== "undefined" && !isDisabled(val2)) {
|
|
176
225
|
setVal(val2);
|
|
226
|
+
} else if (typeof val2 !== "undefined" && isDisabled(val2)) {
|
|
227
|
+
const nearest = findNearestValidValue(k);
|
|
228
|
+
if (nearest) {
|
|
229
|
+
setVal(nearest.value);
|
|
230
|
+
setTimeout(() => {
|
|
231
|
+
var _a;
|
|
232
|
+
(_a = ref.current) == null ? void 0 : _a.scrollTo({ top: nearest.index * CellHeight, behavior: "smooth" });
|
|
233
|
+
}, 100);
|
|
234
|
+
}
|
|
177
235
|
}
|
|
178
236
|
}, 300);
|
|
179
237
|
}
|
|
180
238
|
});
|
|
181
|
-
const handleClickCell = useMemoizedFn((e, i) => {
|
|
239
|
+
const handleClickCell = useMemoizedFn((e, i, val2) => {
|
|
182
240
|
var _a;
|
|
183
241
|
e.stopPropagation();
|
|
184
242
|
e.preventDefault();
|
|
185
|
-
(
|
|
243
|
+
if (!isDisabled(val2)) {
|
|
244
|
+
(_a = ref.current) == null ? void 0 : _a.scrollTo({ top: i * CellHeight, behavior: "smooth" });
|
|
245
|
+
}
|
|
186
246
|
});
|
|
187
247
|
useEffect(() => {
|
|
188
248
|
adjustScrollTop(val);
|
|
@@ -200,16 +260,19 @@ function TimePickerScrollerColumn({
|
|
|
200
260
|
},
|
|
201
261
|
onScrollPositionChange: onScroll,
|
|
202
262
|
children: [
|
|
203
|
-
numbers.map((i, index) =>
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
263
|
+
numbers.map((i, index) => {
|
|
264
|
+
const disabled = isDisabled(i);
|
|
265
|
+
return /* @__PURE__ */ jsx(
|
|
266
|
+
"div",
|
|
267
|
+
{
|
|
268
|
+
className: clsx(disabled ? classes.cellDisabled : classes.cell, i === curr && !disabled && classes.bold),
|
|
269
|
+
onClick: (e) => handleClickCell(e, index, i),
|
|
270
|
+
style: CellStyle,
|
|
271
|
+
children: render ? render(i) : i
|
|
272
|
+
},
|
|
273
|
+
i
|
|
274
|
+
);
|
|
275
|
+
}),
|
|
213
276
|
range(6).map((i) => /* @__PURE__ */ jsx(Box, { className: clsx(classes.cell, classes.cellPlaceholder), style: CellStyle }, i))
|
|
214
277
|
]
|
|
215
278
|
}
|
|
@@ -220,26 +283,25 @@ function TimeScollerPicker({
|
|
|
220
283
|
currentValueChangedBy,
|
|
221
284
|
start,
|
|
222
285
|
end,
|
|
223
|
-
utcOffset,
|
|
224
286
|
onChange
|
|
225
287
|
}) {
|
|
226
288
|
const options = useMemo(
|
|
227
289
|
() => ({
|
|
228
|
-
hour: getTimeRange({ curr: currentValue, start, end,
|
|
229
|
-
minute: getTimeRange({ curr: currentValue, start, end,
|
|
230
|
-
second: getTimeRange({ curr: currentValue, start, end,
|
|
290
|
+
hour: getTimeRange({ curr: currentValue, start, end, type: "hour" }),
|
|
291
|
+
minute: getTimeRange({ curr: currentValue, start, end, type: "minute" }),
|
|
292
|
+
second: getTimeRange({ curr: currentValue, start, end, type: "second" })
|
|
231
293
|
}),
|
|
232
|
-
[currentValue, start, end
|
|
294
|
+
[currentValue, start, end]
|
|
233
295
|
);
|
|
234
296
|
const hourValue = useMemo(() => {
|
|
235
|
-
return
|
|
236
|
-
}, [currentValue
|
|
297
|
+
return currentValue.hour();
|
|
298
|
+
}, [currentValue]);
|
|
237
299
|
const minuteValue = useMemo(() => {
|
|
238
|
-
return
|
|
239
|
-
}, [currentValue
|
|
300
|
+
return currentValue.minute();
|
|
301
|
+
}, [currentValue]);
|
|
240
302
|
const secondValue = useMemo(() => {
|
|
241
|
-
return
|
|
242
|
-
}, [currentValue
|
|
303
|
+
return currentValue.second();
|
|
304
|
+
}, [currentValue]);
|
|
243
305
|
const onHourChange = useMemoizedFn((v) => {
|
|
244
306
|
onChange == null ? void 0 : onChange([v, minuteValue, secondValue]);
|
|
245
307
|
});
|
|
@@ -35,7 +35,6 @@ const DateTimePicker = ({
|
|
|
35
35
|
endDate = dayjs.dayjs().add(10, "year").toDate(),
|
|
36
36
|
onChange,
|
|
37
37
|
disable = false,
|
|
38
|
-
utcOffset = dayjs.dayjs().utcOffset(),
|
|
39
38
|
withinPortal = true,
|
|
40
39
|
sx,
|
|
41
40
|
loading = false,
|
|
@@ -69,28 +68,29 @@ const DateTimePicker = ({
|
|
|
69
68
|
setCurrentValueChangedBy(null);
|
|
70
69
|
}, 20);
|
|
71
70
|
});
|
|
72
|
-
const inputStr = formatter ? formatter(currentValue.
|
|
71
|
+
const inputStr = formatter ? formatter(currentValue.toDate()) : currentValue.format(format);
|
|
73
72
|
const utcStr = React.useMemo(() => {
|
|
73
|
+
const utcOffset = currentValue.utcOffset();
|
|
74
74
|
const h = Math.floor(utcOffset / 60);
|
|
75
75
|
const m = utcOffset % 60;
|
|
76
76
|
return `UTC${h >= 0 ? "+" : "-"}${Math.abs(h)}:${m < 10 ? "0" : ""}${m}`;
|
|
77
|
-
}, [
|
|
77
|
+
}, []);
|
|
78
78
|
const calendarChange = ahooks.useMemoizedFn((v) => {
|
|
79
79
|
let next = currentValue;
|
|
80
|
-
next = next.
|
|
80
|
+
next = next.year(v.getFullYear()).month(v.getMonth()).date(v.getDate());
|
|
81
81
|
updateCurrentValue(next, "calendar");
|
|
82
82
|
});
|
|
83
83
|
const timeInputChange = ahooks.useMemoizedFn((e) => {
|
|
84
84
|
const originVal = e.currentTarget.value;
|
|
85
85
|
const v = dayjs.dayjs(originVal, "HH:mm:ss").toDate();
|
|
86
86
|
let next = currentValue;
|
|
87
|
-
next = next.
|
|
87
|
+
next = next.hour(v.getHours()).minute(v.getMinutes()).second(v.getSeconds());
|
|
88
88
|
updateCurrentValue(next, "timeInput");
|
|
89
89
|
});
|
|
90
90
|
const timeScrollPickerChange = ahooks.useMemoizedFn((v) => {
|
|
91
91
|
const [h, m, s] = v;
|
|
92
92
|
let next = currentValue;
|
|
93
|
-
next = next.
|
|
93
|
+
next = next.hour(h).minute(m).second(s);
|
|
94
94
|
updateCurrentValue(next, "timeScroller");
|
|
95
95
|
});
|
|
96
96
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -206,8 +206,7 @@ const DateTimePicker = ({
|
|
|
206
206
|
currentValueChangedBy,
|
|
207
207
|
onChange: timeScrollPickerChange,
|
|
208
208
|
start: startDate,
|
|
209
|
-
end: endDate
|
|
210
|
-
utcOffset
|
|
209
|
+
end: endDate
|
|
211
210
|
}
|
|
212
211
|
)
|
|
213
212
|
]
|
|
@@ -217,11 +216,9 @@ const DateTimePicker = ({
|
|
|
217
216
|
] }),
|
|
218
217
|
/* @__PURE__ */ jsxRuntime.jsx(Divider.Divider, { mx: -16 }),
|
|
219
218
|
/* @__PURE__ */ jsxRuntime.jsx(Group.Group, { children: /* @__PURE__ */ jsxRuntime.jsxs(index$1.Typography, { size: "sm", children: [
|
|
220
|
-
"
|
|
221
|
-
" ",
|
|
222
|
-
/* @__PURE__ */ jsxRuntime.jsx(index$1.Typography, { fw: 600, component: "span", children: utcStr }),
|
|
219
|
+
"Time selection in local time zone:",
|
|
223
220
|
" ",
|
|
224
|
-
|
|
221
|
+
/* @__PURE__ */ jsxRuntime.jsx(index$1.Typography, { fw: 600, component: "span", children: utcStr })
|
|
225
222
|
] }) })
|
|
226
223
|
] }) })
|
|
227
224
|
]
|
|
@@ -261,10 +258,18 @@ const TimePicker = ({
|
|
|
261
258
|
if ((currentValue == null ? void 0 : currentValue.unix()) === next.unix()) {
|
|
262
259
|
return;
|
|
263
260
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
next
|
|
261
|
+
const baseDate = next.format("YYYY-MM-DD");
|
|
262
|
+
if (startDate && startDate.isValid()) {
|
|
263
|
+
const startOnSameDate = dayjs.dayjs(`${baseDate} ${startDate.format("HH:mm:ss")}`);
|
|
264
|
+
if (next.isBefore(startOnSameDate)) {
|
|
265
|
+
next = next.hour(startDate.hour()).minute(startDate.minute()).second(startDate.second());
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (endDate && endDate.isValid()) {
|
|
269
|
+
const endOnSameDate = dayjs.dayjs(`${baseDate} ${endDate.format("HH:mm:ss")}`);
|
|
270
|
+
if (next.isAfter(endOnSameDate)) {
|
|
271
|
+
next = next.hour(endDate.hour()).minute(endDate.minute()).second(endDate.second());
|
|
272
|
+
}
|
|
268
273
|
}
|
|
269
274
|
setCurrentValue(next);
|
|
270
275
|
setCurrentValueChangedBy(from);
|
|
@@ -16,8 +16,8 @@ export interface DateTimePickerProps extends Omit<TextInputProps, 'value' | 'onC
|
|
|
16
16
|
*/
|
|
17
17
|
formatter?: (val: Date) => string;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* This props is deprecated, use `formatter` instead to display the time in any timezone.
|
|
20
|
+
* @deprecated
|
|
21
21
|
*/
|
|
22
22
|
utcOffset?: number;
|
|
23
23
|
defaultValue?: Date;
|
|
@@ -30,7 +30,7 @@ export interface DateTimePickerProps extends Omit<TextInputProps, 'value' | 'onC
|
|
|
30
30
|
loading?: boolean;
|
|
31
31
|
size?: MantineSize;
|
|
32
32
|
}
|
|
33
|
-
export declare const DateTimePicker: ({ placeholder, format, formatter, defaultValue, value, startDate, endDate, onChange, disable,
|
|
33
|
+
export declare const DateTimePicker: ({ placeholder, format, formatter, defaultValue, value, startDate, endDate, onChange, disable, withinPortal, sx, loading, size }: DateTimePickerProps) => import("react/jsx-runtime.js").JSX.Element;
|
|
34
34
|
export interface TimePickerProps extends Omit<TimeInputProps, 'value' | 'onChange' | 'defaultValue'>, Pick<PopoverProps, 'withinPortal' | 'withArrow' | 'position' | 'shadow'> {
|
|
35
35
|
defaultValue?: string;
|
|
36
36
|
/**
|
|
@@ -16,8 +16,8 @@ export interface DateTimePickerProps extends Omit<TextInputProps, 'value' | 'onC
|
|
|
16
16
|
*/
|
|
17
17
|
formatter?: (val: Date) => string;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* This props is deprecated, use `formatter` instead to display the time in any timezone.
|
|
20
|
+
* @deprecated
|
|
21
21
|
*/
|
|
22
22
|
utcOffset?: number;
|
|
23
23
|
defaultValue?: Date;
|
|
@@ -30,7 +30,7 @@ export interface DateTimePickerProps extends Omit<TextInputProps, 'value' | 'onC
|
|
|
30
30
|
loading?: boolean;
|
|
31
31
|
size?: MantineSize;
|
|
32
32
|
}
|
|
33
|
-
export declare const DateTimePicker: ({ placeholder, format, formatter, defaultValue, value, startDate, endDate, onChange, disable,
|
|
33
|
+
export declare const DateTimePicker: ({ placeholder, format, formatter, defaultValue, value, startDate, endDate, onChange, disable, withinPortal, sx, loading, size }: DateTimePickerProps) => import("react/jsx-runtime.js").JSX.Element;
|
|
34
34
|
export interface TimePickerProps extends Omit<TimeInputProps, 'value' | 'onChange' | 'defaultValue'>, Pick<PopoverProps, 'withinPortal' | 'withArrow' | 'position' | 'shadow'> {
|
|
35
35
|
defaultValue?: string;
|
|
36
36
|
/**
|
|
@@ -33,7 +33,6 @@ const DateTimePicker = ({
|
|
|
33
33
|
endDate = dayjs().add(10, "year").toDate(),
|
|
34
34
|
onChange,
|
|
35
35
|
disable = false,
|
|
36
|
-
utcOffset = dayjs().utcOffset(),
|
|
37
36
|
withinPortal = true,
|
|
38
37
|
sx,
|
|
39
38
|
loading = false,
|
|
@@ -67,28 +66,29 @@ const DateTimePicker = ({
|
|
|
67
66
|
setCurrentValueChangedBy(null);
|
|
68
67
|
}, 20);
|
|
69
68
|
});
|
|
70
|
-
const inputStr = formatter ? formatter(currentValue.
|
|
69
|
+
const inputStr = formatter ? formatter(currentValue.toDate()) : currentValue.format(format);
|
|
71
70
|
const utcStr = useMemo(() => {
|
|
71
|
+
const utcOffset = currentValue.utcOffset();
|
|
72
72
|
const h = Math.floor(utcOffset / 60);
|
|
73
73
|
const m = utcOffset % 60;
|
|
74
74
|
return `UTC${h >= 0 ? "+" : "-"}${Math.abs(h)}:${m < 10 ? "0" : ""}${m}`;
|
|
75
|
-
}, [
|
|
75
|
+
}, []);
|
|
76
76
|
const calendarChange = useMemoizedFn((v) => {
|
|
77
77
|
let next = currentValue;
|
|
78
|
-
next = next.
|
|
78
|
+
next = next.year(v.getFullYear()).month(v.getMonth()).date(v.getDate());
|
|
79
79
|
updateCurrentValue(next, "calendar");
|
|
80
80
|
});
|
|
81
81
|
const timeInputChange = useMemoizedFn((e) => {
|
|
82
82
|
const originVal = e.currentTarget.value;
|
|
83
83
|
const v = dayjs(originVal, "HH:mm:ss").toDate();
|
|
84
84
|
let next = currentValue;
|
|
85
|
-
next = next.
|
|
85
|
+
next = next.hour(v.getHours()).minute(v.getMinutes()).second(v.getSeconds());
|
|
86
86
|
updateCurrentValue(next, "timeInput");
|
|
87
87
|
});
|
|
88
88
|
const timeScrollPickerChange = useMemoizedFn((v) => {
|
|
89
89
|
const [h, m, s] = v;
|
|
90
90
|
let next = currentValue;
|
|
91
|
-
next = next.
|
|
91
|
+
next = next.hour(h).minute(m).second(s);
|
|
92
92
|
updateCurrentValue(next, "timeScroller");
|
|
93
93
|
});
|
|
94
94
|
return /* @__PURE__ */ jsxs(
|
|
@@ -204,8 +204,7 @@ const DateTimePicker = ({
|
|
|
204
204
|
currentValueChangedBy,
|
|
205
205
|
onChange: timeScrollPickerChange,
|
|
206
206
|
start: startDate,
|
|
207
|
-
end: endDate
|
|
208
|
-
utcOffset
|
|
207
|
+
end: endDate
|
|
209
208
|
}
|
|
210
209
|
)
|
|
211
210
|
]
|
|
@@ -215,11 +214,9 @@ const DateTimePicker = ({
|
|
|
215
214
|
] }),
|
|
216
215
|
/* @__PURE__ */ jsx(Divider, { mx: -16 }),
|
|
217
216
|
/* @__PURE__ */ jsx(Group, { children: /* @__PURE__ */ jsxs(Typography, { size: "sm", children: [
|
|
218
|
-
"
|
|
219
|
-
" ",
|
|
220
|
-
/* @__PURE__ */ jsx(Typography, { fw: 600, component: "span", children: utcStr }),
|
|
217
|
+
"Time selection in local time zone:",
|
|
221
218
|
" ",
|
|
222
|
-
|
|
219
|
+
/* @__PURE__ */ jsx(Typography, { fw: 600, component: "span", children: utcStr })
|
|
223
220
|
] }) })
|
|
224
221
|
] }) })
|
|
225
222
|
]
|
|
@@ -259,10 +256,18 @@ const TimePicker = ({
|
|
|
259
256
|
if ((currentValue == null ? void 0 : currentValue.unix()) === next.unix()) {
|
|
260
257
|
return;
|
|
261
258
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
259
|
+
const baseDate = next.format("YYYY-MM-DD");
|
|
260
|
+
if (startDate && startDate.isValid()) {
|
|
261
|
+
const startOnSameDate = dayjs(`${baseDate} ${startDate.format("HH:mm:ss")}`);
|
|
262
|
+
if (next.isBefore(startOnSameDate)) {
|
|
263
|
+
next = next.hour(startDate.hour()).minute(startDate.minute()).second(startDate.second());
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (endDate && endDate.isValid()) {
|
|
267
|
+
const endOnSameDate = dayjs(`${baseDate} ${endDate.format("HH:mm:ss")}`);
|
|
268
|
+
if (next.isAfter(endOnSameDate)) {
|
|
269
|
+
next = next.hour(endDate.hour()).minute(endDate.minute()).second(endDate.second());
|
|
270
|
+
}
|
|
266
271
|
}
|
|
267
272
|
setCurrentValue(next);
|
|
268
273
|
setCurrentValueChangedBy(from);
|
|
@@ -201,6 +201,7 @@ const ProMultiSelect = (_props) => {
|
|
|
201
201
|
error,
|
|
202
202
|
allowSelectAll,
|
|
203
203
|
selectAllText,
|
|
204
|
+
sx,
|
|
204
205
|
onOptionSubmit,
|
|
205
206
|
renderOption,
|
|
206
207
|
filter,
|
|
@@ -375,6 +376,8 @@ const ProMultiSelect = (_props) => {
|
|
|
375
376
|
{
|
|
376
377
|
error,
|
|
377
378
|
w: width,
|
|
379
|
+
sx,
|
|
380
|
+
size,
|
|
378
381
|
component: "button",
|
|
379
382
|
type: "button",
|
|
380
383
|
pointer: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { MultiSelectProps } from '../../primitive/index.cjs';
|
|
3
|
-
export interface ProMultiSelectProps extends Pick<MultiSelectProps, 'data' | 'value' | 'defaultValue' | 'limit' | 'searchable' | 'searchValue' | 'defaultSearchValue' | 'maxValues' | 'readOnly' | 'disabled' | 'size' | 'width' | 'selectFirstOptionOnChange' | 'placeholder' | 'clearable' | 'label' | 'nothingFoundMessage' | 'dropdownOpened' | 'defaultDropdownOpened' | 'maxDropdownHeight' | 'error' | 'onOptionSubmit' | 'renderOption' | 'filter' | 'onChange' | 'onSearchChange' | 'onRemove' | 'onClear'> {
|
|
3
|
+
export interface ProMultiSelectProps extends Pick<MultiSelectProps, 'data' | 'value' | 'defaultValue' | 'limit' | 'searchable' | 'searchValue' | 'defaultSearchValue' | 'maxValues' | 'readOnly' | 'disabled' | 'size' | 'width' | 'selectFirstOptionOnChange' | 'placeholder' | 'clearable' | 'label' | 'nothingFoundMessage' | 'dropdownOpened' | 'defaultDropdownOpened' | 'maxDropdownHeight' | 'error' | 'onOptionSubmit' | 'renderOption' | 'filter' | 'onChange' | 'onSearchChange' | 'onRemove' | 'onClear' | 'sx'> {
|
|
4
4
|
loading?: boolean;
|
|
5
5
|
allowSelectAll?: boolean;
|
|
6
6
|
selectAllText?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { MultiSelectProps } from '../../primitive/index.mjs';
|
|
3
|
-
export interface ProMultiSelectProps extends Pick<MultiSelectProps, 'data' | 'value' | 'defaultValue' | 'limit' | 'searchable' | 'searchValue' | 'defaultSearchValue' | 'maxValues' | 'readOnly' | 'disabled' | 'size' | 'width' | 'selectFirstOptionOnChange' | 'placeholder' | 'clearable' | 'label' | 'nothingFoundMessage' | 'dropdownOpened' | 'defaultDropdownOpened' | 'maxDropdownHeight' | 'error' | 'onOptionSubmit' | 'renderOption' | 'filter' | 'onChange' | 'onSearchChange' | 'onRemove' | 'onClear'> {
|
|
3
|
+
export interface ProMultiSelectProps extends Pick<MultiSelectProps, 'data' | 'value' | 'defaultValue' | 'limit' | 'searchable' | 'searchValue' | 'defaultSearchValue' | 'maxValues' | 'readOnly' | 'disabled' | 'size' | 'width' | 'selectFirstOptionOnChange' | 'placeholder' | 'clearable' | 'label' | 'nothingFoundMessage' | 'dropdownOpened' | 'defaultDropdownOpened' | 'maxDropdownHeight' | 'error' | 'onOptionSubmit' | 'renderOption' | 'filter' | 'onChange' | 'onSearchChange' | 'onRemove' | 'onClear' | 'sx'> {
|
|
4
4
|
loading?: boolean;
|
|
5
5
|
allowSelectAll?: boolean;
|
|
6
6
|
selectAllText?: string;
|
|
@@ -199,6 +199,7 @@ const ProMultiSelect = (_props) => {
|
|
|
199
199
|
error,
|
|
200
200
|
allowSelectAll,
|
|
201
201
|
selectAllText,
|
|
202
|
+
sx,
|
|
202
203
|
onOptionSubmit,
|
|
203
204
|
renderOption,
|
|
204
205
|
filter,
|
|
@@ -373,6 +374,8 @@ const ProMultiSelect = (_props) => {
|
|
|
373
374
|
{
|
|
374
375
|
error,
|
|
375
376
|
w: width,
|
|
377
|
+
sx,
|
|
378
|
+
size,
|
|
376
379
|
component: "button",
|
|
377
380
|
type: "button",
|
|
378
381
|
pointer: true,
|