@rockshin/tao-ui 0.0.58 → 0.0.60
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/components/affix/affix.js +38 -4
- package/dist/components/app/app-modals.js +11 -6
- package/dist/components/app/app-notices.js +105 -47
- package/dist/components/auto-complete/auto-complete.js +9 -2
- package/dist/components/calendar/calendar.js +22 -18
- package/dist/components/carousel/carousel.js +27 -14
- package/dist/components/cascader/cascader.js +18 -12
- package/dist/components/checkbox/checkbox.d.ts +3 -1
- package/dist/components/checkbox/checkbox.js +65 -58
- package/dist/components/color-picker/color-picker.css +1 -1
- package/dist/components/color-picker/color-picker.js +386 -362
- package/dist/components/context-menu/context-menu.d.ts +3 -1
- package/dist/components/context-menu/context-menu.js +48 -43
- package/dist/components/date-picker/calendar/calendar-grid.d.ts +5 -3
- package/dist/components/date-picker/calendar/calendar-grid.js +9 -4
- package/dist/components/date-picker/calendar/month-grid.d.ts +2 -1
- package/dist/components/date-picker/calendar/month-grid.js +61 -45
- package/dist/components/date-picker/calendar/time-panel.d.ts +8 -1
- package/dist/components/date-picker/calendar/time-panel.js +93 -88
- package/dist/components/date-picker/calendar/year-grid.d.ts +2 -1
- package/dist/components/date-picker/calendar/year-grid.js +60 -44
- package/dist/components/date-picker/date-picker.css +9 -0
- package/dist/components/date-picker/date-picker.js +25 -14
- package/dist/components/date-picker/range-picker.d.ts +2 -0
- package/dist/components/date-picker/range-picker.js +132 -73
- package/dist/components/date-picker/types.js +1 -1
- package/dist/components/drawer/drawer.d.ts +1 -1
- package/dist/components/drawer/drawer.js +4 -3
- package/dist/components/dropdown/dropdown.d.ts +1 -0
- package/dist/components/dropdown/dropdown.js +29 -21
- package/dist/components/float-button/float-button.js +6 -5
- package/dist/components/form/form-item.d.ts +1 -1
- package/dist/components/form/form-item.js +160 -120
- package/dist/components/form/use-form.js +2 -1
- package/dist/components/form-field/form-field-view.d.ts +2 -1
- package/dist/components/form-field/form-field-view.js +173 -108
- package/dist/components/input/input-shared.js +3 -2
- package/dist/components/input/otp.js +114 -110
- package/dist/components/input/password.js +55 -61
- package/dist/components/input/search.js +8 -4
- package/dist/components/input-number/input-number.d.ts +2 -1
- package/dist/components/input-number/input-number.js +67 -52
- package/dist/components/mentions/mentions.js +4 -2
- package/dist/components/menu/menu-render.d.ts +6 -0
- package/dist/components/menu/menu-render.js +39 -26
- package/dist/components/modal/confirm-dialog.js +22 -10
- package/dist/components/modal/modal.js +320 -315
- package/dist/components/modal/use-modal.js +1 -1
- package/dist/components/pagination/pagination.d.ts +4 -2
- package/dist/components/pagination/pagination.js +128 -117
- package/dist/components/popover/popover.js +214 -351
- package/dist/components/qr-code/qr-code.js +157 -150
- package/dist/components/radio/radio.d.ts +3 -1
- package/dist/components/radio/radio.js +73 -64
- package/dist/components/select/mobile-select.js +7 -4
- package/dist/components/select/select-model.js +3 -3
- package/dist/components/select/select.js +78 -39
- package/dist/components/select/use-select-selection.js +100 -92
- package/dist/components/slider/slider.d.ts +2 -2
- package/dist/components/slider/slider.js +13 -2
- package/dist/components/sonner/sonner.js +2 -2
- package/dist/components/splitter/splitter.css +1 -0
- package/dist/components/splitter/splitter.js +152 -126
- package/dist/components/statistic/statistic.js +38 -31
- package/dist/components/switch/switch.js +45 -39
- package/dist/components/table/table-filter.d.ts +3 -1
- package/dist/components/table/table-filter.js +100 -74
- package/dist/components/table/table.js +2 -0
- package/dist/components/table/use-table-data.js +2 -2
- package/dist/components/tabs/tabs.d.ts +3 -2
- package/dist/components/tabs/tabs.js +122 -112
- package/dist/components/time-picker/time-picker.js +35 -3
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/components/tooltip/tooltip.js +220 -124
- package/dist/components/tree/tree.js +31 -3
- package/dist/components/tree-select/tree-select.js +2 -1
- package/dist/components/upload/upload.js +67 -40
- package/dist/locales/ar-EG.js +2 -0
- package/dist/locales/de-DE.js +2 -0
- package/dist/locales/en-US.js +2 -0
- package/dist/locales/es-ES.js +2 -0
- package/dist/locales/fr-FR.js +2 -0
- package/dist/locales/hi-IN.js +2 -0
- package/dist/locales/id-ID.js +2 -0
- package/dist/locales/it-IT.js +2 -0
- package/dist/locales/ja-JP.js +2 -0
- package/dist/locales/ko-KR.js +2 -0
- package/dist/locales/pt-BR.js +2 -0
- package/dist/locales/ru-RU.js +2 -0
- package/dist/locales/th-TH.js +2 -0
- package/dist/locales/tr-TR.js +2 -0
- package/dist/locales/types.d.ts +2 -0
- package/dist/locales/vi-VN.js +2 -0
- package/dist/locales/zh-CN.js +2 -0
- package/dist/locales/zh-TW.js +2 -0
- package/dist/number-input/format.js +1 -1
- package/dist/number-input/use-number-input.d.ts +1 -0
- package/dist/number-input/use-number-input.js +170 -321
- package/dist/number-input/validate.d.ts +1 -0
- package/dist/number-input/validate.js +1 -1
- package/dist/provider/tao-provider.d.ts +2 -2
- package/dist/provider/tao-provider.js +66 -52
- package/dist/theme/control.css +5 -1
- package/dist/theme/theme.css +2 -2
- package/dist/utils/composed-parent.d.ts +1 -0
- package/dist/utils/composed-parent.js +7 -0
- package/dist/utils/portal.d.ts +5 -0
- package/dist/utils/portal.js +7 -1
- package/dist/utils/refs.d.ts +3 -1
- package/dist/utils/refs.js +25 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import { type TaoSize } from '../../provider/tao-provider.js';
|
|
2
3
|
import { type SemanticClassNames, type SemanticStyles } from '../../utils/semantic.js';
|
|
3
4
|
import { type MenuProps, type MenuSemanticPart } from '../menu/menu-render.js';
|
|
4
5
|
import './context-menu.css';
|
|
@@ -10,6 +11,7 @@ export interface ContextMenuProps {
|
|
|
10
11
|
children: ReactNode;
|
|
11
12
|
open?: boolean;
|
|
12
13
|
onOpenChange?: (open: boolean) => void;
|
|
14
|
+
size?: TaoSize;
|
|
13
15
|
disabled?: boolean;
|
|
14
16
|
/** Merged onto the floating content. */
|
|
15
17
|
className?: string;
|
|
@@ -17,4 +19,4 @@ export interface ContextMenuProps {
|
|
|
17
19
|
classNames?: SemanticClassNames<ContextMenuSemanticPart>;
|
|
18
20
|
styles?: SemanticStyles<ContextMenuSemanticPart>;
|
|
19
21
|
}
|
|
20
|
-
export declare function ContextMenu({ direction: directionProp, menu, children, open, onOpenChange, disabled, className, style, classNames, styles, }: ContextMenuProps): import("react").JSX.Element;
|
|
22
|
+
export declare function ContextMenu({ direction: directionProp, menu, children, open, onOpenChange, size: sizeProp, disabled, className, style, classNames, styles, }: ContextMenuProps): import("react").JSX.Element;
|
|
@@ -22,10 +22,11 @@ const CM = {
|
|
|
22
22
|
ItemIndicator: __rspack_external__radix_ui_react_context_menu_d8b375cc.ItemIndicator
|
|
23
23
|
};
|
|
24
24
|
function ContextMenu(t0) {
|
|
25
|
-
const $ = c(
|
|
26
|
-
const { direction: directionProp, menu, children, open, onOpenChange, disabled, className, style, classNames, styles } = t0;
|
|
25
|
+
const $ = c(39);
|
|
26
|
+
const { direction: directionProp, menu, children, open, onOpenChange, size: sizeProp, disabled, className, style, classNames, styles } = t0;
|
|
27
27
|
const [direction, directionRef] = useTaoDirection(directionProp, "self");
|
|
28
|
-
const { size, disabled: ctxDisabled } = useTaoConfig();
|
|
28
|
+
const { size: ctxSize, disabled: ctxDisabled } = useTaoConfig();
|
|
29
|
+
const size = sizeProp ?? ctxSize;
|
|
29
30
|
const resolvedDisabled = disabled ?? ctxDisabled;
|
|
30
31
|
const t1 = !resolvedDisabled;
|
|
31
32
|
let t2;
|
|
@@ -65,51 +66,55 @@ function ContextMenu(t0) {
|
|
|
65
66
|
}
|
|
66
67
|
useEffect(t3, t4);
|
|
67
68
|
let t5;
|
|
68
|
-
if ($[10] !== classNames || $[11] !== styles) {
|
|
69
|
+
if ($[10] !== classNames || $[11] !== direction || $[12] !== size || $[13] !== styles) {
|
|
69
70
|
t5 = {
|
|
71
|
+
size,
|
|
72
|
+
direction,
|
|
70
73
|
classNames,
|
|
71
74
|
styles
|
|
72
75
|
};
|
|
73
76
|
$[10] = classNames;
|
|
74
|
-
$[11] =
|
|
75
|
-
$[12] =
|
|
76
|
-
|
|
77
|
+
$[11] = direction;
|
|
78
|
+
$[12] = size;
|
|
79
|
+
$[13] = styles;
|
|
80
|
+
$[14] = t5;
|
|
81
|
+
} else t5 = $[14];
|
|
77
82
|
const { content } = useMenuController(menu, CM, t5);
|
|
78
83
|
const t6 = realOpen && !resolvedDisabled;
|
|
79
84
|
let t7;
|
|
80
|
-
if ($[
|
|
85
|
+
if ($[15] !== children || $[16] !== directionRef || $[17] !== resolvedDisabled) {
|
|
81
86
|
t7 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_context_menu_d8b375cc.Trigger, {
|
|
82
87
|
ref: directionRef,
|
|
83
88
|
disabled: resolvedDisabled,
|
|
84
89
|
"data-tao-context-menu-trigger": "",
|
|
85
90
|
children: children
|
|
86
91
|
});
|
|
87
|
-
$[
|
|
88
|
-
$[
|
|
89
|
-
$[
|
|
90
|
-
$[
|
|
91
|
-
} else t7 = $[
|
|
92
|
+
$[15] = children;
|
|
93
|
+
$[16] = directionRef;
|
|
94
|
+
$[17] = resolvedDisabled;
|
|
95
|
+
$[18] = t7;
|
|
96
|
+
} else t7 = $[18];
|
|
92
97
|
const t8 = classNames?.content;
|
|
93
98
|
let t9;
|
|
94
|
-
if ($[
|
|
99
|
+
if ($[19] !== className || $[20] !== t8) {
|
|
95
100
|
t9 = cx(t8, className);
|
|
96
|
-
$[
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
99
|
-
} else t9 = $[
|
|
101
|
+
$[19] = className;
|
|
102
|
+
$[20] = t8;
|
|
103
|
+
$[21] = t9;
|
|
104
|
+
} else t9 = $[21];
|
|
100
105
|
const t10 = styles?.content;
|
|
101
106
|
let t11;
|
|
102
|
-
if ($[
|
|
107
|
+
if ($[22] !== style || $[23] !== t10) {
|
|
103
108
|
t11 = {
|
|
104
109
|
...t10,
|
|
105
110
|
...style
|
|
106
111
|
};
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
} else t11 = $[
|
|
112
|
+
$[22] = style;
|
|
113
|
+
$[23] = t10;
|
|
114
|
+
$[24] = t11;
|
|
115
|
+
} else t11 = $[24];
|
|
111
116
|
let t12;
|
|
112
|
-
if ($[
|
|
117
|
+
if ($[25] !== content || $[26] !== size || $[27] !== t11 || $[28] !== t9) {
|
|
113
118
|
t12 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_context_menu_d8b375cc.Content, {
|
|
114
119
|
"data-tao-menu-content": "",
|
|
115
120
|
"data-tao-context-menu": "",
|
|
@@ -118,14 +123,14 @@ function ContextMenu(t0) {
|
|
|
118
123
|
style: t11,
|
|
119
124
|
children: content
|
|
120
125
|
});
|
|
121
|
-
$[
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
} else t12 = $[
|
|
126
|
+
$[25] = content;
|
|
127
|
+
$[26] = size;
|
|
128
|
+
$[27] = t11;
|
|
129
|
+
$[28] = t9;
|
|
130
|
+
$[29] = t12;
|
|
131
|
+
} else t12 = $[29];
|
|
127
132
|
let t13;
|
|
128
|
-
if ($[
|
|
133
|
+
if ($[30] !== direction || $[31] !== t12) {
|
|
129
134
|
t13 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_context_menu_d8b375cc.Portal, {
|
|
130
135
|
children: /*#__PURE__*/ jsx(TaoPortalScope, {
|
|
131
136
|
asChild: true,
|
|
@@ -133,12 +138,12 @@ function ContextMenu(t0) {
|
|
|
133
138
|
children: t12
|
|
134
139
|
})
|
|
135
140
|
});
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
} else t13 = $[
|
|
141
|
+
$[30] = direction;
|
|
142
|
+
$[31] = t12;
|
|
143
|
+
$[32] = t13;
|
|
144
|
+
} else t13 = $[32];
|
|
140
145
|
let t14;
|
|
141
|
-
if ($[
|
|
146
|
+
if ($[33] !== direction || $[34] !== setOpen || $[35] !== t13 || $[36] !== t6 || $[37] !== t7) {
|
|
142
147
|
t14 = /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_context_menu_d8b375cc.Root, {
|
|
143
148
|
dir: direction,
|
|
144
149
|
open: t6,
|
|
@@ -148,13 +153,13 @@ function ContextMenu(t0) {
|
|
|
148
153
|
t13
|
|
149
154
|
]
|
|
150
155
|
});
|
|
151
|
-
$[
|
|
152
|
-
$[
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
} else t14 = $[
|
|
156
|
+
$[33] = direction;
|
|
157
|
+
$[34] = setOpen;
|
|
158
|
+
$[35] = t13;
|
|
159
|
+
$[36] = t6;
|
|
160
|
+
$[37] = t7;
|
|
161
|
+
$[38] = t14;
|
|
162
|
+
} else t14 = $[38];
|
|
158
163
|
return t14;
|
|
159
164
|
}
|
|
160
165
|
export { ContextMenu };
|
|
@@ -3,10 +3,12 @@ import { type CSSProperties } from 'react';
|
|
|
3
3
|
interface CalendarGridProps {
|
|
4
4
|
viewDate: Dayjs;
|
|
5
5
|
value?: Dayjs | null;
|
|
6
|
-
/** Range mode: start of
|
|
6
|
+
/** Range mode: start of the displayed range */
|
|
7
7
|
rangeStart?: Dayjs | null;
|
|
8
|
-
/** Range mode: end of
|
|
8
|
+
/** Range mode: end of the displayed range */
|
|
9
9
|
rangeEnd?: Dayjs | null;
|
|
10
|
+
/** Committed selection when the displayed range is still being edited. */
|
|
11
|
+
committedRange?: [Dayjs | null, Dayjs | null] | null;
|
|
10
12
|
/** Range mode: date currently being hovered */
|
|
11
13
|
hoverDate?: Dayjs | null;
|
|
12
14
|
onSelect: (date: Dayjs) => void;
|
|
@@ -20,5 +22,5 @@ interface CalendarGridProps {
|
|
|
20
22
|
cellClassName?: string;
|
|
21
23
|
cellStyle?: CSSProperties;
|
|
22
24
|
}
|
|
23
|
-
export declare function CalendarGrid({ viewDate, value, rangeStart, rangeEnd, hoverDate, onSelect, onViewDateChange, onHover, disabledDate, minDate, maxDate, className, style, cellClassName, cellStyle, }: CalendarGridProps): import("react").JSX.Element;
|
|
25
|
+
export declare function CalendarGrid({ viewDate, value, rangeStart, rangeEnd, committedRange, hoverDate, onSelect, onViewDateChange, onHover, disabledDate, minDate, maxDate, className, style, cellClassName, cellStyle, }: CalendarGridProps): import("react").JSX.Element;
|
|
24
26
|
export {};
|
|
@@ -3,7 +3,7 @@ import dayjs from "dayjs";
|
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { useTaoConfig } from "../../../provider/tao-provider.js";
|
|
5
5
|
import { getCalendarWeeks } from "./use-calendar.js";
|
|
6
|
-
function CalendarGrid({ viewDate, value, rangeStart, rangeEnd, hoverDate, onSelect, onViewDateChange, onHover, disabledDate, minDate, maxDate, className, style, cellClassName, cellStyle }) {
|
|
6
|
+
function CalendarGrid({ viewDate, value, rangeStart, rangeEnd, committedRange, hoverDate, onSelect, onViewDateChange, onHover, disabledDate, minDate, maxDate, className, style, cellClassName, cellStyle }) {
|
|
7
7
|
const { locale } = useTaoConfig();
|
|
8
8
|
const weekStartsOn = locale.weekStartsOn ?? 1;
|
|
9
9
|
const weekdayOffset = (weekStartsOn + 6) % 7;
|
|
@@ -15,6 +15,11 @@ function CalendarGrid({ viewDate, value, rangeStart, rangeEnd, hoverDate, onSele
|
|
|
15
15
|
const today = dayjs();
|
|
16
16
|
const currentMonth = viewDate.month();
|
|
17
17
|
const isRangeMode = void 0 !== rangeStart;
|
|
18
|
+
const [selectedStart, selectedEnd] = void 0 === committedRange ? [
|
|
19
|
+
rangeStart,
|
|
20
|
+
rangeEnd
|
|
21
|
+
] : committedRange ?? [];
|
|
22
|
+
const selectedEndpoint = selectedStart ?? selectedEnd;
|
|
18
23
|
const isDisabled = (date)=>{
|
|
19
24
|
if (disabledDate?.(date)) return true;
|
|
20
25
|
if (minDate && date.isBefore(minDate, 'day')) return true;
|
|
@@ -89,8 +94,8 @@ function CalendarGrid({ viewDate, value, rangeStart, rangeEnd, hoverDate, onSele
|
|
|
89
94
|
};
|
|
90
95
|
const getEffectiveRange = ()=>{
|
|
91
96
|
if (!isRangeMode) return null;
|
|
92
|
-
const s = rangeStart;
|
|
93
|
-
const e = rangeEnd ?? hoverDate;
|
|
97
|
+
const s = rangeStart ?? rangeEnd;
|
|
98
|
+
const e = rangeEnd ?? hoverDate ?? s;
|
|
94
99
|
if (!s || !e) return null;
|
|
95
100
|
return s.isBefore(e, 'day') ? [
|
|
96
101
|
s,
|
|
@@ -142,7 +147,7 @@ function CalendarGrid({ viewDate, value, rangeStart, rangeEnd, hoverDate, onSele
|
|
|
142
147
|
return /*#__PURE__*/ jsx("td", {
|
|
143
148
|
role: "gridcell",
|
|
144
149
|
"data-tao-calendar-cell": "",
|
|
145
|
-
"aria-selected": isRangeMode ?
|
|
150
|
+
"aria-selected": isRangeMode ? !isOtherMonth && (selectedStart && selectedEnd ? !date_9.isBefore(selectedStart, 'day') && !date_9.isAfter(selectedEnd, 'day') : !!committedRange && !!selectedEndpoint?.isSame(date_9, 'day')) : !!isSelected,
|
|
146
151
|
children: /*#__PURE__*/ jsx("button", {
|
|
147
152
|
ref: (element)=>{
|
|
148
153
|
const key = date_9.format('YYYY-MM-DD');
|
|
@@ -5,6 +5,7 @@ interface MonthGridProps {
|
|
|
5
5
|
value?: Dayjs | null;
|
|
6
6
|
rangeStart?: Dayjs | null;
|
|
7
7
|
rangeEnd?: Dayjs | null;
|
|
8
|
+
committedRange?: [Dayjs | null, Dayjs | null] | null;
|
|
8
9
|
onSelect: (date: Dayjs) => void;
|
|
9
10
|
disabledDate?: (date: Dayjs) => boolean;
|
|
10
11
|
minDate?: Dayjs;
|
|
@@ -14,5 +15,5 @@ interface MonthGridProps {
|
|
|
14
15
|
cellClassName?: string;
|
|
15
16
|
cellStyle?: CSSProperties;
|
|
16
17
|
}
|
|
17
|
-
export declare function MonthGrid({ viewDate, value, rangeStart, rangeEnd, onSelect, disabledDate, minDate, maxDate, className, style, cellClassName, cellStyle, }: MonthGridProps): import("react").JSX.Element;
|
|
18
|
+
export declare function MonthGrid({ viewDate, value, rangeStart, rangeEnd, committedRange, onSelect, disabledDate, minDate, maxDate, className, style, cellClassName, cellStyle, }: MonthGridProps): import("react").JSX.Element;
|
|
18
19
|
export {};
|
|
@@ -3,21 +3,35 @@ import { c } from "react-compiler-runtime";
|
|
|
3
3
|
import { getMonths } from "./use-calendar.js";
|
|
4
4
|
import { useTaoConfig } from "../../../provider/tao-provider.js";
|
|
5
5
|
function MonthGrid(t0) {
|
|
6
|
-
const $ = c(
|
|
7
|
-
const { viewDate, value, rangeStart, rangeEnd, onSelect, disabledDate, minDate, maxDate, className, style, cellClassName, cellStyle } = t0;
|
|
6
|
+
const $ = c(40);
|
|
7
|
+
const { viewDate, value, rangeStart, rangeEnd, committedRange, onSelect, disabledDate, minDate, maxDate, className, style, cellClassName, cellStyle } = t0;
|
|
8
8
|
const { locale } = useTaoConfig();
|
|
9
9
|
let t1;
|
|
10
10
|
let t2;
|
|
11
11
|
let t3;
|
|
12
12
|
let t4;
|
|
13
|
-
if ($[0] !== cellClassName || $[1] !== cellStyle || $[2] !== className || $[3] !==
|
|
13
|
+
if ($[0] !== cellClassName || $[1] !== cellStyle || $[2] !== className || $[3] !== committedRange || $[4] !== disabledDate || $[5] !== locale || $[6] !== maxDate || $[7] !== minDate || $[8] !== onSelect || $[9] !== rangeEnd || $[10] !== rangeStart || $[11] !== style || $[12] !== value || $[13] !== viewDate) {
|
|
14
14
|
const months = getMonths(viewDate.year());
|
|
15
|
+
let t5;
|
|
16
|
+
if ($[18] !== committedRange || $[19] !== rangeEnd || $[20] !== rangeStart || $[21] !== value) {
|
|
17
|
+
t5 = void 0 === committedRange ? [
|
|
18
|
+
value,
|
|
19
|
+
rangeStart,
|
|
20
|
+
rangeEnd
|
|
21
|
+
] : committedRange ?? [];
|
|
22
|
+
$[18] = committedRange;
|
|
23
|
+
$[19] = rangeEnd;
|
|
24
|
+
$[20] = rangeStart;
|
|
25
|
+
$[21] = value;
|
|
26
|
+
$[22] = t5;
|
|
27
|
+
} else t5 = $[22];
|
|
28
|
+
const accessibleSelection = t5;
|
|
15
29
|
t1 = "";
|
|
16
30
|
t2 = className;
|
|
17
31
|
t3 = style;
|
|
18
|
-
let
|
|
19
|
-
if ($[
|
|
20
|
-
|
|
32
|
+
let t6;
|
|
33
|
+
if ($[23] !== accessibleSelection || $[24] !== cellClassName || $[25] !== cellStyle || $[26] !== disabledDate || $[27] !== locale || $[28] !== maxDate || $[29] !== minDate || $[30] !== onSelect || $[31] !== rangeEnd || $[32] !== rangeStart || $[33] !== value) {
|
|
34
|
+
t6 = (m, i)=>{
|
|
21
35
|
const isSelected = [
|
|
22
36
|
value,
|
|
23
37
|
rangeStart,
|
|
@@ -33,63 +47,65 @@ function MonthGrid(t0) {
|
|
|
33
47
|
style: cellStyle,
|
|
34
48
|
"data-tao-in-range": inRange || void 0,
|
|
35
49
|
"data-tao-selected": isSelected || void 0,
|
|
36
|
-
"aria-pressed":
|
|
50
|
+
"aria-pressed": accessibleSelection.some((date_0)=>date_0?.isSame(m, "month")),
|
|
37
51
|
"data-tao-disabled": disabled || void 0,
|
|
38
52
|
disabled: disabled,
|
|
39
53
|
onClick: ()=>onSelect(m),
|
|
40
54
|
children: locale.months[i]
|
|
41
55
|
}, m.format("YYYY-MM"));
|
|
42
56
|
};
|
|
43
|
-
$[
|
|
44
|
-
$[
|
|
45
|
-
$[
|
|
46
|
-
$[
|
|
47
|
-
$[
|
|
48
|
-
$[
|
|
49
|
-
$[
|
|
50
|
-
$[
|
|
51
|
-
$[
|
|
52
|
-
$[
|
|
53
|
-
$[
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
$[23] = accessibleSelection;
|
|
58
|
+
$[24] = cellClassName;
|
|
59
|
+
$[25] = cellStyle;
|
|
60
|
+
$[26] = disabledDate;
|
|
61
|
+
$[27] = locale;
|
|
62
|
+
$[28] = maxDate;
|
|
63
|
+
$[29] = minDate;
|
|
64
|
+
$[30] = onSelect;
|
|
65
|
+
$[31] = rangeEnd;
|
|
66
|
+
$[32] = rangeStart;
|
|
67
|
+
$[33] = value;
|
|
68
|
+
$[34] = t6;
|
|
69
|
+
} else t6 = $[34];
|
|
70
|
+
t4 = months.map(t6);
|
|
56
71
|
$[0] = cellClassName;
|
|
57
72
|
$[1] = cellStyle;
|
|
58
73
|
$[2] = className;
|
|
59
|
-
$[3] =
|
|
60
|
-
$[4] =
|
|
61
|
-
$[5] =
|
|
62
|
-
$[6] =
|
|
63
|
-
$[7] =
|
|
64
|
-
$[8] =
|
|
65
|
-
$[9] =
|
|
66
|
-
$[10] =
|
|
67
|
-
$[11] =
|
|
68
|
-
$[12] =
|
|
69
|
-
$[13] =
|
|
70
|
-
$[14] =
|
|
71
|
-
$[15] =
|
|
72
|
-
$[16] =
|
|
74
|
+
$[3] = committedRange;
|
|
75
|
+
$[4] = disabledDate;
|
|
76
|
+
$[5] = locale;
|
|
77
|
+
$[6] = maxDate;
|
|
78
|
+
$[7] = minDate;
|
|
79
|
+
$[8] = onSelect;
|
|
80
|
+
$[9] = rangeEnd;
|
|
81
|
+
$[10] = rangeStart;
|
|
82
|
+
$[11] = style;
|
|
83
|
+
$[12] = value;
|
|
84
|
+
$[13] = viewDate;
|
|
85
|
+
$[14] = t1;
|
|
86
|
+
$[15] = t2;
|
|
87
|
+
$[16] = t3;
|
|
88
|
+
$[17] = t4;
|
|
73
89
|
} else {
|
|
74
|
-
t1 = $[
|
|
75
|
-
t2 = $[
|
|
76
|
-
t3 = $[
|
|
77
|
-
t4 = $[
|
|
90
|
+
t1 = $[14];
|
|
91
|
+
t2 = $[15];
|
|
92
|
+
t3 = $[16];
|
|
93
|
+
t4 = $[17];
|
|
78
94
|
}
|
|
79
95
|
let t5;
|
|
80
|
-
if ($[
|
|
96
|
+
if ($[35] !== t1 || $[36] !== t2 || $[37] !== t3 || $[38] !== t4) {
|
|
81
97
|
t5 = /*#__PURE__*/ jsx("div", {
|
|
82
98
|
"data-tao-month-grid": t1,
|
|
83
99
|
className: t2,
|
|
84
100
|
style: t3,
|
|
85
101
|
children: t4
|
|
86
102
|
});
|
|
87
|
-
$[
|
|
88
|
-
$[
|
|
89
|
-
$[
|
|
90
|
-
$[
|
|
91
|
-
$[
|
|
92
|
-
} else t5 = $[
|
|
103
|
+
$[35] = t1;
|
|
104
|
+
$[36] = t2;
|
|
105
|
+
$[37] = t3;
|
|
106
|
+
$[38] = t4;
|
|
107
|
+
$[39] = t5;
|
|
108
|
+
} else t5 = $[39];
|
|
93
109
|
return t5;
|
|
94
110
|
}
|
|
95
111
|
export { MonthGrid };
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { TimeConfig } from '../types.js';
|
|
2
|
+
/** Time units displayed by a format; formats without time tokens show all. */
|
|
3
|
+
export declare function getTimeUnits(format?: string): {
|
|
4
|
+
hour: boolean;
|
|
5
|
+
minute: boolean;
|
|
6
|
+
second: boolean;
|
|
7
|
+
};
|
|
2
8
|
interface TimePanelProps {
|
|
3
9
|
hour: number;
|
|
4
10
|
minute: number;
|
|
@@ -6,8 +12,9 @@ interface TimePanelProps {
|
|
|
6
12
|
disabled?: boolean;
|
|
7
13
|
onChange: (h: number, m: number, s: number) => void;
|
|
8
14
|
config?: TimeConfig;
|
|
15
|
+
format?: string;
|
|
9
16
|
/** Increment to force scroll-to-selected even when the value hasn't changed */
|
|
10
17
|
scrollKey?: number;
|
|
11
18
|
}
|
|
12
|
-
export declare function TimePanel({ hour, minute, second, disabled, onChange, config, scrollKey, }: TimePanelProps): import("react").JSX.Element;
|
|
19
|
+
export declare function TimePanel({ hour, minute, second, disabled, onChange, config, format, scrollKey, }: TimePanelProps): import("react").JSX.Element;
|
|
13
20
|
export {};
|
|
@@ -2,134 +2,139 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
4
|
import { useTaoConfig } from "../../../provider/tao-provider.js";
|
|
5
|
+
function getTimeUnits(format = '') {
|
|
6
|
+
const tokens = format.replace(/\[[^\]]*]/g, '');
|
|
7
|
+
const any = /[Hhms]/.test(tokens);
|
|
8
|
+
return {
|
|
9
|
+
hour: !any || /[Hh]/.test(tokens),
|
|
10
|
+
minute: !any || tokens.includes('m'),
|
|
11
|
+
second: !any || tokens.includes('s')
|
|
12
|
+
};
|
|
13
|
+
}
|
|
5
14
|
function TimePanel(t0) {
|
|
6
|
-
const $ = c(
|
|
7
|
-
const { hour, minute, second, disabled, onChange, config, scrollKey } = t0;
|
|
15
|
+
const $ = c(42);
|
|
16
|
+
const { hour, minute, second, disabled, onChange, config, format, scrollKey } = t0;
|
|
8
17
|
const { locale } = useTaoConfig();
|
|
9
|
-
const hourStep = config?.hourStep ?? 1;
|
|
10
|
-
const minuteStep = config?.minuteStep ?? 1;
|
|
11
|
-
const secondStep = config?.secondStep ?? 1;
|
|
12
18
|
let t1;
|
|
13
|
-
if ($[0] !==
|
|
14
|
-
t1 =
|
|
15
|
-
|
|
16
|
-
}, (_, i)=>i * hourStep);
|
|
17
|
-
$[0] = hourStep;
|
|
19
|
+
if ($[0] !== format) {
|
|
20
|
+
t1 = getTimeUnits(format);
|
|
21
|
+
$[0] = format;
|
|
18
22
|
$[1] = t1;
|
|
19
23
|
} else t1 = $[1];
|
|
20
|
-
const
|
|
24
|
+
const units = t1;
|
|
25
|
+
const normalizeStep = _temp;
|
|
26
|
+
const hourStep = normalizeStep(config?.hourStep);
|
|
27
|
+
const minuteStep = normalizeStep(config?.minuteStep);
|
|
28
|
+
const secondStep = normalizeStep(config?.secondStep);
|
|
21
29
|
let t2;
|
|
22
|
-
if ($[2] !==
|
|
30
|
+
if ($[2] !== hourStep) {
|
|
23
31
|
t2 = Array.from({
|
|
24
|
-
length: Math.ceil(
|
|
25
|
-
}, (
|
|
26
|
-
$[2] =
|
|
32
|
+
length: Math.ceil(24 / hourStep)
|
|
33
|
+
}, (_, i)=>i * hourStep);
|
|
34
|
+
$[2] = hourStep;
|
|
27
35
|
$[3] = t2;
|
|
28
36
|
} else t2 = $[3];
|
|
29
|
-
const
|
|
37
|
+
const hours = t2;
|
|
30
38
|
let t3;
|
|
31
|
-
if ($[4] !==
|
|
39
|
+
if ($[4] !== minuteStep) {
|
|
32
40
|
t3 = Array.from({
|
|
33
|
-
length: Math.ceil(60 /
|
|
34
|
-
}, (
|
|
35
|
-
$[4] =
|
|
41
|
+
length: Math.ceil(60 / minuteStep)
|
|
42
|
+
}, (__0, i_0)=>i_0 * minuteStep);
|
|
43
|
+
$[4] = minuteStep;
|
|
36
44
|
$[5] = t3;
|
|
37
45
|
} else t3 = $[5];
|
|
38
|
-
const
|
|
46
|
+
const minutes = t3;
|
|
39
47
|
let t4;
|
|
40
|
-
if ($[6] !==
|
|
41
|
-
t4 = (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
$[
|
|
45
|
-
$[
|
|
46
|
-
} else t4 = $[
|
|
48
|
+
if ($[6] !== secondStep) {
|
|
49
|
+
t4 = Array.from({
|
|
50
|
+
length: Math.ceil(60 / secondStep)
|
|
51
|
+
}, (__1, i_1)=>i_1 * secondStep);
|
|
52
|
+
$[6] = secondStep;
|
|
53
|
+
$[7] = t4;
|
|
54
|
+
} else t4 = $[7];
|
|
55
|
+
const seconds = t4;
|
|
47
56
|
let t5;
|
|
48
|
-
if ($[
|
|
49
|
-
t5 = /*#__PURE__*/ jsx(TimeColumn, {
|
|
57
|
+
if ($[8] !== disabled || $[9] !== hour || $[10] !== hours || $[11] !== locale || $[12] !== minute || $[13] !== onChange || $[14] !== scrollKey || $[15] !== second || $[16] !== units.hour) {
|
|
58
|
+
t5 = units.hour && /*#__PURE__*/ jsx(TimeColumn, {
|
|
50
59
|
values: hours,
|
|
51
60
|
selected: hour,
|
|
52
|
-
onSelect:
|
|
61
|
+
onSelect: (v)=>onChange(v, minute, second),
|
|
53
62
|
label: locale.hour,
|
|
54
63
|
disabled: disabled,
|
|
55
64
|
scrollKey: scrollKey
|
|
56
65
|
});
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
$[
|
|
60
|
-
$[
|
|
66
|
+
$[8] = disabled;
|
|
67
|
+
$[9] = hour;
|
|
68
|
+
$[10] = hours;
|
|
69
|
+
$[11] = locale;
|
|
70
|
+
$[12] = minute;
|
|
71
|
+
$[13] = onChange;
|
|
61
72
|
$[14] = scrollKey;
|
|
62
|
-
$[15] =
|
|
63
|
-
$[16] =
|
|
64
|
-
|
|
73
|
+
$[15] = second;
|
|
74
|
+
$[16] = units.hour;
|
|
75
|
+
$[17] = t5;
|
|
76
|
+
} else t5 = $[17];
|
|
65
77
|
let t6;
|
|
66
|
-
if ($[
|
|
67
|
-
t6 = (
|
|
68
|
-
$[17] = hour;
|
|
69
|
-
$[18] = onChange;
|
|
70
|
-
$[19] = second;
|
|
71
|
-
$[20] = t6;
|
|
72
|
-
} else t6 = $[20];
|
|
73
|
-
let t7;
|
|
74
|
-
if ($[21] !== disabled || $[22] !== locale.minute || $[23] !== minute || $[24] !== minutes || $[25] !== scrollKey || $[26] !== t6) {
|
|
75
|
-
t7 = /*#__PURE__*/ jsx(TimeColumn, {
|
|
78
|
+
if ($[18] !== disabled || $[19] !== hour || $[20] !== locale || $[21] !== minute || $[22] !== minutes || $[23] !== onChange || $[24] !== scrollKey || $[25] !== second || $[26] !== units.minute) {
|
|
79
|
+
t6 = units.minute && /*#__PURE__*/ jsx(TimeColumn, {
|
|
76
80
|
values: minutes,
|
|
77
81
|
selected: minute,
|
|
78
|
-
onSelect:
|
|
82
|
+
onSelect: (v_0)=>onChange(hour, v_0, second),
|
|
79
83
|
label: locale.minute,
|
|
80
84
|
disabled: disabled,
|
|
81
85
|
scrollKey: scrollKey
|
|
82
86
|
});
|
|
83
|
-
$[
|
|
84
|
-
$[
|
|
85
|
-
$[
|
|
86
|
-
$[
|
|
87
|
-
$[
|
|
88
|
-
$[
|
|
89
|
-
$[
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
$[31] = t8;
|
|
98
|
-
} else t8 = $[31];
|
|
99
|
-
let t9;
|
|
100
|
-
if ($[32] !== disabled || $[33] !== locale.second || $[34] !== scrollKey || $[35] !== second || $[36] !== seconds || $[37] !== t8) {
|
|
101
|
-
t9 = /*#__PURE__*/ jsx(TimeColumn, {
|
|
87
|
+
$[18] = disabled;
|
|
88
|
+
$[19] = hour;
|
|
89
|
+
$[20] = locale;
|
|
90
|
+
$[21] = minute;
|
|
91
|
+
$[22] = minutes;
|
|
92
|
+
$[23] = onChange;
|
|
93
|
+
$[24] = scrollKey;
|
|
94
|
+
$[25] = second;
|
|
95
|
+
$[26] = units.minute;
|
|
96
|
+
$[27] = t6;
|
|
97
|
+
} else t6 = $[27];
|
|
98
|
+
let t7;
|
|
99
|
+
if ($[28] !== disabled || $[29] !== hour || $[30] !== locale || $[31] !== minute || $[32] !== onChange || $[33] !== scrollKey || $[34] !== second || $[35] !== seconds || $[36] !== units.second) {
|
|
100
|
+
t7 = units.second && /*#__PURE__*/ jsx(TimeColumn, {
|
|
102
101
|
values: seconds,
|
|
103
102
|
selected: second,
|
|
104
|
-
onSelect:
|
|
103
|
+
onSelect: (v_1)=>onChange(hour, minute, v_1),
|
|
105
104
|
label: locale.second,
|
|
106
105
|
disabled: disabled,
|
|
107
106
|
scrollKey: scrollKey
|
|
108
107
|
});
|
|
109
|
-
$[
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
108
|
+
$[28] = disabled;
|
|
109
|
+
$[29] = hour;
|
|
110
|
+
$[30] = locale;
|
|
111
|
+
$[31] = minute;
|
|
112
|
+
$[32] = onChange;
|
|
113
|
+
$[33] = scrollKey;
|
|
114
|
+
$[34] = second;
|
|
115
|
+
$[35] = seconds;
|
|
116
|
+
$[36] = units.second;
|
|
117
|
+
$[37] = t7;
|
|
118
|
+
} else t7 = $[37];
|
|
119
|
+
let t8;
|
|
120
|
+
if ($[38] !== t5 || $[39] !== t6 || $[40] !== t7) {
|
|
121
|
+
t8 = /*#__PURE__*/ jsxs("div", {
|
|
120
122
|
"data-tao-time-panel": "",
|
|
121
123
|
children: [
|
|
122
124
|
t5,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
t6,
|
|
126
|
+
t7
|
|
125
127
|
]
|
|
126
128
|
});
|
|
127
|
-
$[
|
|
129
|
+
$[38] = t5;
|
|
130
|
+
$[39] = t6;
|
|
128
131
|
$[40] = t7;
|
|
129
|
-
$[41] =
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
$[41] = t8;
|
|
133
|
+
} else t8 = $[41];
|
|
134
|
+
return t8;
|
|
135
|
+
}
|
|
136
|
+
function _temp(step) {
|
|
137
|
+
return step && Number.isFinite(step) && step > 0 ? Math.max(1, Math.trunc(step)) : 1;
|
|
133
138
|
}
|
|
134
139
|
function centerSelected(list, behavior) {
|
|
135
140
|
const selected = list.querySelector('[data-tao-selected]');
|
|
@@ -232,4 +237,4 @@ function TimeColumn(t0) {
|
|
|
232
237
|
} else t7 = $[20];
|
|
233
238
|
return t7;
|
|
234
239
|
}
|
|
235
|
-
export { TimePanel };
|
|
240
|
+
export { TimePanel, getTimeUnits };
|