@rockshin/tao-ui 0.0.31 → 0.0.33
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/README.md +14 -3
- package/dist/components/alert/alert.js +1 -1
- package/dist/components/breadcrumb/breadcrumb.js +1 -1
- package/dist/components/button/button.d.ts +2 -2
- package/dist/components/button/button.js +48 -50
- package/dist/components/checkbox/checkbox.css +5 -1
- package/dist/components/checkbox/checkbox.d.ts +2 -2
- package/dist/components/checkbox/checkbox.js +135 -120
- package/dist/components/collapsible/collapsible.js +1 -1
- package/dist/components/context-menu/context-menu.js +1 -1
- package/dist/components/date-picker/calendar/calendar-header.js +1 -1
- package/dist/components/date-picker/calendar/month-grid.d.ts +3 -1
- package/dist/components/date-picker/calendar/month-grid.js +19 -17
- package/dist/components/date-picker/calendar/time-panel.js +1 -1
- package/dist/components/date-picker/calendar/year-grid.d.ts +3 -1
- package/dist/components/date-picker/calendar/year-grid.js +28 -24
- package/dist/components/date-picker/date-picker.d.ts +1 -1
- package/dist/components/date-picker/date-picker.js +37 -24
- package/dist/components/date-picker/presets.js +1 -1
- package/dist/components/date-picker/range-picker.d.ts +1 -1
- package/dist/components/date-picker/range-picker.js +104 -56
- package/dist/components/drawer/drawer.d.ts +1 -1
- package/dist/components/drawer/drawer.js +98 -91
- package/dist/components/dropdown/dropdown.js +84 -84
- package/dist/components/form/form-item.js +8 -4
- package/dist/components/form/form.js +1 -1
- package/dist/components/form-actions/form-actions.js +1 -1
- package/dist/components/form-field/form-field-view.js +58 -51
- package/dist/components/form-field/form-field.js +1 -1
- package/dist/components/form-section/form-section.js +1 -1
- package/dist/components/input/input.js +42 -39
- package/dist/components/input-number/input-number.d.ts +2 -2
- package/dist/components/input-number/input-number.js +57 -59
- package/dist/components/menu/menu-render.js +1 -1
- package/dist/components/modal/confirm-dialog.d.ts +2 -1
- package/dist/components/modal/confirm-dialog.js +25 -5
- package/dist/components/modal/confirm.js +15 -3
- package/dist/components/modal/modal.d.ts +1 -1
- package/dist/components/modal/modal.js +131 -132
- package/dist/components/modal/use-modal.js +48 -35
- package/dist/components/pagination/pagination.js +3 -1
- package/dist/components/popconfirm/popconfirm.js +1 -1
- package/dist/components/popover/popover.js +253 -228
- package/dist/components/radio/radio.css +2 -2
- package/dist/components/radio/radio.d.ts +1 -1
- package/dist/components/radio/radio.js +7 -7
- package/dist/components/scroll-area/scroll-area.css +2 -2
- package/dist/components/scroll-area/scroll-area.js +187 -165
- package/dist/components/select/mobile-select.d.ts +2 -1
- package/dist/components/select/mobile-select.js +12 -6
- package/dist/components/select/select-icons.js +1 -1
- package/dist/components/select/select-searchable-list.d.ts +1 -1
- package/dist/components/select/select-searchable-list.js +35 -21
- package/dist/components/select/select-tags.js +1 -1
- package/dist/components/select/select-types.d.ts +2 -2
- package/dist/components/select/select.css +4 -0
- package/dist/components/select/select.d.ts +2 -2
- package/dist/components/select/select.js +127 -73
- package/dist/components/sonner/sonner.js +6 -5
- package/dist/components/spinner/spinner.js +1 -1
- package/dist/components/splitter/splitter.js +187 -194
- package/dist/components/status-icon/status-icon.js +1 -1
- package/dist/components/switch/switch.d.ts +1 -1
- package/dist/components/switch/switch.js +6 -6
- package/dist/components/table/table-filter.js +1 -1
- package/dist/components/table/table-icons.js +1 -1
- package/dist/components/table/table.js +483 -599
- package/dist/components/tabs/tabs.js +179 -161
- package/dist/components/tag/tag.js +1 -1
- package/dist/components/textarea/textarea.d.ts +1 -1
- package/dist/components/textarea/textarea.js +142 -108
- package/dist/components/tooltip/tooltip.js +88 -72
- package/dist/entries/alert.d.ts +3 -0
- package/dist/entries/alert.js +4 -0
- package/dist/entries/breadcrumb.d.ts +3 -0
- package/dist/entries/breadcrumb.js +4 -0
- package/dist/entries/button.d.ts +3 -0
- package/dist/entries/button.js +4 -0
- package/dist/entries/checkbox.d.ts +3 -0
- package/dist/entries/checkbox.js +4 -0
- package/dist/entries/collapsible.d.ts +3 -0
- package/dist/entries/collapsible.js +4 -0
- package/dist/entries/context-menu.d.ts +3 -0
- package/dist/entries/context-menu.js +4 -0
- package/dist/entries/date-picker.d.ts +3 -0
- package/dist/entries/date-picker.js +4 -0
- package/dist/entries/drawer.d.ts +3 -0
- package/dist/entries/drawer.js +4 -0
- package/dist/entries/dropdown.d.ts +3 -0
- package/dist/entries/dropdown.js +4 -0
- package/dist/entries/form-actions.d.ts +3 -0
- package/dist/entries/form-actions.js +4 -0
- package/dist/entries/form-field.d.ts +3 -0
- package/dist/entries/form-field.js +4 -0
- package/dist/entries/form-layout.d.ts +3 -0
- package/dist/entries/form-layout.js +4 -0
- package/dist/entries/form-section.d.ts +3 -0
- package/dist/entries/form-section.js +4 -0
- package/dist/entries/form.d.ts +4 -0
- package/dist/entries/form.js +4 -0
- package/dist/entries/input-number.d.ts +3 -0
- package/dist/entries/input-number.js +4 -0
- package/dist/entries/input.d.ts +3 -0
- package/dist/entries/input.js +4 -0
- package/dist/entries/modal.d.ts +3 -0
- package/dist/entries/modal.js +4 -0
- package/dist/entries/number-input.d.ts +3 -0
- package/dist/entries/number-input.js +4 -0
- package/dist/entries/pagination.d.ts +3 -0
- package/dist/entries/pagination.js +4 -0
- package/dist/entries/popconfirm.d.ts +3 -0
- package/dist/entries/popconfirm.js +4 -0
- package/dist/entries/popover.d.ts +3 -0
- package/dist/entries/popover.js +4 -0
- package/dist/entries/provider.d.ts +3 -0
- package/dist/entries/provider.js +4 -0
- package/dist/entries/radio.d.ts +3 -0
- package/dist/entries/radio.js +4 -0
- package/dist/entries/range-picker.d.ts +3 -0
- package/dist/entries/range-picker.js +4 -0
- package/dist/entries/scroll-area.d.ts +3 -0
- package/dist/entries/scroll-area.js +4 -0
- package/dist/entries/select.d.ts +3 -0
- package/dist/entries/select.js +4 -0
- package/dist/entries/sonner.d.ts +3 -0
- package/dist/entries/sonner.js +4 -0
- package/dist/entries/spinner.d.ts +3 -0
- package/dist/entries/spinner.js +4 -0
- package/dist/entries/splitter.d.ts +3 -0
- package/dist/entries/splitter.js +4 -0
- package/dist/entries/stack.d.ts +3 -0
- package/dist/entries/stack.js +4 -0
- package/dist/entries/switch.d.ts +3 -0
- package/dist/entries/switch.js +4 -0
- package/dist/entries/table.d.ts +3 -0
- package/dist/entries/table.js +4 -0
- package/dist/entries/tabs.d.ts +3 -0
- package/dist/entries/tabs.js +4 -0
- package/dist/entries/tag.d.ts +3 -0
- package/dist/entries/tag.js +4 -0
- package/dist/entries/textarea.d.ts +3 -0
- package/dist/entries/textarea.js +4 -0
- package/dist/entries/tooltip.d.ts +3 -0
- package/dist/entries/tooltip.js +4 -0
- package/dist/layouts/form-layout/form-layout.js +1 -1
- package/dist/layouts/stack/stack.js +1 -1
- package/dist/number-input/number-input.js +1 -1
- package/dist/number-input/use-number-input.d.ts +2 -2
- package/dist/number-input/use-number-input.js +224 -131
- package/dist/number-input/validate.js +7 -2
- package/dist/provider/tao-provider.js +1 -1
- package/dist/utils/dialog-content.d.ts +10 -0
- package/dist/utils/dialog-content.js +222 -0
- package/dist/utils/overlay.d.ts +2 -2
- package/dist/utils/overlay.js +8 -3
- package/dist/utils/refs.js +17 -2
- package/llms.txt +5 -3
- package/package.json +21 -8
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { c } from "react
|
|
1
|
+
import { c } from "react-compiler-runtime";
|
|
2
2
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
-
import { isThousandSepBeforeCursor, reposition } from "./cursor.js";
|
|
3
|
+
import { countAnchored, findCursorAt, isThousandSepBeforeCursor, reposition } from "./cursor.js";
|
|
4
4
|
import { format, padOnBlur, parse, truncateDecimals } from "./format.js";
|
|
5
5
|
import { fromPercent, toPercent } from "./percentage.js";
|
|
6
6
|
import { clampToRange, isValidCanonical, stripDisallowedSign } from "./validate.js";
|
|
7
7
|
function useNumberInput(opts) {
|
|
8
|
-
const $ = c(
|
|
8
|
+
const $ = c(84);
|
|
9
9
|
const { value, defaultValue, onChange, onBlur, decimalSeparator: t0, thousandsSeparator: t1, decimalPlaces: t2, padDecimalsOnBlur: t3, isPercentage: t4, allowNegative: t5, min, max } = opts;
|
|
10
10
|
const decimalSeparator = void 0 === t0 ? "." : t0;
|
|
11
11
|
const thousandsSeparator = void 0 === t1 ? "," : t1;
|
|
@@ -35,177 +35,270 @@ function useNumberInput(opts) {
|
|
|
35
35
|
$[5] = t7;
|
|
36
36
|
} else t7 = $[5];
|
|
37
37
|
const canonicalToDisplay = t7;
|
|
38
|
+
const isValueControlled = "value" in opts;
|
|
38
39
|
let t8;
|
|
39
|
-
if ($[6] !== canonicalToDisplay || $[7] !== defaultValue || $[8] !== value) {
|
|
40
|
-
t8 = ()=>
|
|
40
|
+
if ($[6] !== canonicalToDisplay || $[7] !== defaultValue || $[8] !== fmtOpts || $[9] !== isPercentage || $[10] !== isValueControlled || $[11] !== value) {
|
|
41
|
+
t8 = ()=>({
|
|
42
|
+
display: canonicalToDisplay(isValueControlled ? value ?? "" : defaultValue ?? ""),
|
|
43
|
+
format: fmtOpts,
|
|
44
|
+
isPercentage
|
|
45
|
+
});
|
|
41
46
|
$[6] = canonicalToDisplay;
|
|
42
47
|
$[7] = defaultValue;
|
|
43
|
-
$[8] =
|
|
44
|
-
$[9] =
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
$[8] = fmtOpts;
|
|
49
|
+
$[9] = isPercentage;
|
|
50
|
+
$[10] = isValueControlled;
|
|
51
|
+
$[11] = value;
|
|
52
|
+
$[12] = t8;
|
|
53
|
+
} else t8 = $[12];
|
|
54
|
+
const [buffer, setBuffer] = useState(t8);
|
|
55
|
+
const displayBuffer = buffer.display;
|
|
56
|
+
let t9;
|
|
57
|
+
if ($[13] !== fmtOpts || $[14] !== isPercentage) {
|
|
58
|
+
t9 = (display)=>setBuffer({
|
|
59
|
+
display,
|
|
60
|
+
format: fmtOpts,
|
|
61
|
+
isPercentage
|
|
62
|
+
});
|
|
63
|
+
$[13] = fmtOpts;
|
|
64
|
+
$[14] = isPercentage;
|
|
65
|
+
$[15] = t9;
|
|
66
|
+
} else t9 = $[15];
|
|
67
|
+
const setDisplayBuffer = t9;
|
|
47
68
|
const isFocusedRef = useRef(false);
|
|
48
69
|
const inputRef = useRef(null);
|
|
49
70
|
const pendingCursorRef = useRef(null);
|
|
50
|
-
let
|
|
51
|
-
if ($[
|
|
52
|
-
|
|
53
|
-
if (
|
|
71
|
+
let t10;
|
|
72
|
+
if ($[16] !== buffer.display || $[17] !== buffer.format || $[18] !== buffer.isPercentage || $[19] !== fmtOpts || $[20] !== isPercentage || $[21] !== isValueControlled || $[22] !== thousandsSeparator || $[23] !== value) {
|
|
73
|
+
t10 = ()=>{
|
|
74
|
+
if (buffer.format === fmtOpts && buffer.isPercentage === isPercentage) return;
|
|
75
|
+
const previousCanonical = parse(buffer.display, buffer.format);
|
|
76
|
+
const useExternalValue = isValueControlled && !isFocusedRef.current;
|
|
77
|
+
const actual_0 = useExternalValue ? value ?? "" : buffer.isPercentage ? fromPercent(previousCanonical) : previousCanonical;
|
|
78
|
+
let canonical_0 = isPercentage ? toPercent(actual_0) : actual_0;
|
|
79
|
+
if (!useExternalValue && previousCanonical.endsWith(".") && !canonical_0.includes(".")) canonical_0 += ".";
|
|
80
|
+
const display_0 = format(canonical_0, fmtOpts);
|
|
81
|
+
const input = inputRef.current;
|
|
82
|
+
if (isFocusedRef.current && input && display_0 !== buffer.display) {
|
|
83
|
+
const beforeCount = countAnchored(buffer.display, buffer.display.length, buffer.format.thousandsSeparator);
|
|
84
|
+
const afterCount = countAnchored(display_0, display_0.length, thousandsSeparator);
|
|
85
|
+
const mapCursor = (position)=>findCursorAt(display_0, afterCount - beforeCount + countAnchored(buffer.display, position, buffer.format.thousandsSeparator), thousandsSeparator);
|
|
86
|
+
pendingCursorRef.current = {
|
|
87
|
+
display: display_0,
|
|
88
|
+
start: mapCursor(input.selectionStart ?? buffer.display.length),
|
|
89
|
+
end: mapCursor(input.selectionEnd ?? buffer.display.length)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
setBuffer({
|
|
93
|
+
display: display_0,
|
|
94
|
+
format: fmtOpts,
|
|
95
|
+
isPercentage
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
$[16] = buffer.display;
|
|
99
|
+
$[17] = buffer.format;
|
|
100
|
+
$[18] = buffer.isPercentage;
|
|
101
|
+
$[19] = fmtOpts;
|
|
102
|
+
$[20] = isPercentage;
|
|
103
|
+
$[21] = isValueControlled;
|
|
104
|
+
$[22] = thousandsSeparator;
|
|
105
|
+
$[23] = value;
|
|
106
|
+
$[24] = t10;
|
|
107
|
+
} else t10 = $[24];
|
|
108
|
+
let t11;
|
|
109
|
+
if ($[25] !== buffer || $[26] !== fmtOpts || $[27] !== isPercentage || $[28] !== isValueControlled || $[29] !== thousandsSeparator || $[30] !== value) {
|
|
110
|
+
t11 = [
|
|
111
|
+
buffer,
|
|
112
|
+
fmtOpts,
|
|
113
|
+
isPercentage,
|
|
114
|
+
isValueControlled,
|
|
115
|
+
value,
|
|
116
|
+
thousandsSeparator
|
|
117
|
+
];
|
|
118
|
+
$[25] = buffer;
|
|
119
|
+
$[26] = fmtOpts;
|
|
120
|
+
$[27] = isPercentage;
|
|
121
|
+
$[28] = isValueControlled;
|
|
122
|
+
$[29] = thousandsSeparator;
|
|
123
|
+
$[30] = value;
|
|
124
|
+
$[31] = t11;
|
|
125
|
+
} else t11 = $[31];
|
|
126
|
+
useLayoutEffect(t10, t11);
|
|
127
|
+
let t12;
|
|
128
|
+
if ($[32] !== canonicalToDisplay || $[33] !== displayBuffer || $[34] !== isValueControlled || $[35] !== setDisplayBuffer || $[36] !== value) {
|
|
129
|
+
t12 = ()=>{
|
|
130
|
+
if (!isValueControlled) return;
|
|
54
131
|
if (isFocusedRef.current) return;
|
|
55
|
-
const
|
|
56
|
-
|
|
132
|
+
const display_1 = canonicalToDisplay(value ?? "");
|
|
133
|
+
if (displayBuffer !== display_1) setDisplayBuffer(display_1);
|
|
57
134
|
};
|
|
58
|
-
$[
|
|
59
|
-
$[
|
|
60
|
-
$[
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
135
|
+
$[32] = canonicalToDisplay;
|
|
136
|
+
$[33] = displayBuffer;
|
|
137
|
+
$[34] = isValueControlled;
|
|
138
|
+
$[35] = setDisplayBuffer;
|
|
139
|
+
$[36] = value;
|
|
140
|
+
$[37] = t12;
|
|
141
|
+
} else t12 = $[37];
|
|
142
|
+
let t13;
|
|
143
|
+
if ($[38] !== isValueControlled || $[39] !== value) {
|
|
144
|
+
t13 = [
|
|
145
|
+
value,
|
|
146
|
+
isValueControlled
|
|
66
147
|
];
|
|
67
|
-
$[
|
|
68
|
-
$[
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
148
|
+
$[38] = isValueControlled;
|
|
149
|
+
$[39] = value;
|
|
150
|
+
$[40] = t13;
|
|
151
|
+
} else t13 = $[40];
|
|
152
|
+
useEffect(t12, t13);
|
|
153
|
+
let t14;
|
|
154
|
+
let t15;
|
|
155
|
+
if ($[41] !== displayBuffer) {
|
|
156
|
+
t14 = ()=>{
|
|
157
|
+
const pending = pendingCursorRef.current;
|
|
158
|
+
if (pending?.display !== displayBuffer) return;
|
|
159
|
+
inputRef.current?.setSelectionRange(pending.start, pending.end);
|
|
77
160
|
pendingCursorRef.current = null;
|
|
78
161
|
};
|
|
79
|
-
|
|
80
|
-
} else t11 = $[15];
|
|
81
|
-
let t12;
|
|
82
|
-
if ($[16] !== displayBuffer) {
|
|
83
|
-
t12 = [
|
|
162
|
+
t15 = [
|
|
84
163
|
displayBuffer
|
|
85
164
|
];
|
|
86
|
-
$[
|
|
87
|
-
$[
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
165
|
+
$[41] = displayBuffer;
|
|
166
|
+
$[42] = t14;
|
|
167
|
+
$[43] = t15;
|
|
168
|
+
} else {
|
|
169
|
+
t14 = $[42];
|
|
170
|
+
t15 = $[43];
|
|
171
|
+
}
|
|
172
|
+
useLayoutEffect(t14, t15);
|
|
173
|
+
let t16;
|
|
174
|
+
if ($[44] !== allowNegative || $[45] !== decimalPlaces || $[46] !== fmtOpts || $[47] !== isPercentage || $[48] !== onChange || $[49] !== setDisplayBuffer || $[50] !== thousandsSeparator) {
|
|
175
|
+
t16 = (e)=>{
|
|
93
176
|
const raw = e.target.value;
|
|
94
177
|
const cursor = e.target.selectionStart ?? raw.length;
|
|
95
|
-
let
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (!isValidCanonical(
|
|
99
|
-
const newDisplay = format(
|
|
100
|
-
|
|
178
|
+
let canonical_1 = parse(raw, fmtOpts);
|
|
179
|
+
canonical_1 = stripDisallowedSign(canonical_1, allowNegative);
|
|
180
|
+
canonical_1 = truncateDecimals(canonical_1, decimalPlaces);
|
|
181
|
+
if (!isValidCanonical(canonical_1)) return;
|
|
182
|
+
const newDisplay = format(canonical_1, fmtOpts);
|
|
183
|
+
const cursorPosition = reposition({
|
|
101
184
|
before: raw,
|
|
102
185
|
beforeCursor: cursor,
|
|
103
186
|
after: newDisplay,
|
|
104
187
|
thousandsSeparator
|
|
105
188
|
});
|
|
189
|
+
pendingCursorRef.current = {
|
|
190
|
+
display: newDisplay,
|
|
191
|
+
start: cursorPosition,
|
|
192
|
+
end: cursorPosition
|
|
193
|
+
};
|
|
106
194
|
setDisplayBuffer(newDisplay);
|
|
107
|
-
const
|
|
108
|
-
onChange?.(
|
|
195
|
+
const actual_1 = isPercentage ? fromPercent(canonical_1) : canonical_1;
|
|
196
|
+
onChange?.(actual_1);
|
|
109
197
|
};
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
198
|
+
$[44] = allowNegative;
|
|
199
|
+
$[45] = decimalPlaces;
|
|
200
|
+
$[46] = fmtOpts;
|
|
201
|
+
$[47] = isPercentage;
|
|
202
|
+
$[48] = onChange;
|
|
203
|
+
$[49] = setDisplayBuffer;
|
|
204
|
+
$[50] = thousandsSeparator;
|
|
205
|
+
$[51] = t16;
|
|
206
|
+
} else t16 = $[51];
|
|
207
|
+
const handleChange = t16;
|
|
208
|
+
let t17;
|
|
209
|
+
if ($[52] !== canonicalToDisplay || $[53] !== decimalPlaces || $[54] !== displayBuffer || $[55] !== fmtOpts || $[56] !== isPercentage || $[57] !== isValueControlled || $[58] !== max || $[59] !== min || $[60] !== onBlur || $[61] !== onChange || $[62] !== padMode || $[63] !== setDisplayBuffer || $[64] !== value) {
|
|
210
|
+
t17 = ()=>{
|
|
122
211
|
isFocusedRef.current = false;
|
|
123
|
-
const raw_0 = inputRef.current?.value ?? displayBuffer;
|
|
124
|
-
let
|
|
125
|
-
|
|
126
|
-
let
|
|
127
|
-
|
|
128
|
-
const canonicalAfter = isPercentage ? toPercent(
|
|
212
|
+
const raw_0 = isValueControlled ? canonicalToDisplay(value ?? "") : inputRef.current?.value ?? displayBuffer;
|
|
213
|
+
let canonical_2 = parse(raw_0, fmtOpts);
|
|
214
|
+
canonical_2 = padOnBlur(canonical_2, decimalPlaces, padMode);
|
|
215
|
+
let actual_2 = isPercentage ? fromPercent(canonical_2) : canonical_2;
|
|
216
|
+
actual_2 = clampToRange(actual_2, min, max);
|
|
217
|
+
const canonicalAfter = isPercentage ? toPercent(actual_2) : actual_2;
|
|
129
218
|
const newDisplay_0 = format(canonicalAfter, fmtOpts);
|
|
130
219
|
setDisplayBuffer(newDisplay_0);
|
|
131
|
-
onChange?.(
|
|
132
|
-
onBlur?.(
|
|
220
|
+
onChange?.(actual_2);
|
|
221
|
+
onBlur?.(actual_2);
|
|
133
222
|
};
|
|
134
|
-
$[
|
|
135
|
-
$[
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
142
|
-
$[
|
|
143
|
-
$[
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
223
|
+
$[52] = canonicalToDisplay;
|
|
224
|
+
$[53] = decimalPlaces;
|
|
225
|
+
$[54] = displayBuffer;
|
|
226
|
+
$[55] = fmtOpts;
|
|
227
|
+
$[56] = isPercentage;
|
|
228
|
+
$[57] = isValueControlled;
|
|
229
|
+
$[58] = max;
|
|
230
|
+
$[59] = min;
|
|
231
|
+
$[60] = onBlur;
|
|
232
|
+
$[61] = onChange;
|
|
233
|
+
$[62] = padMode;
|
|
234
|
+
$[63] = setDisplayBuffer;
|
|
235
|
+
$[64] = value;
|
|
236
|
+
$[65] = t17;
|
|
237
|
+
} else t17 = $[65];
|
|
238
|
+
const handleBlur = t17;
|
|
239
|
+
let t18;
|
|
240
|
+
if ($[66] === Symbol.for("react.memo_cache_sentinel")) {
|
|
241
|
+
t18 = ()=>{
|
|
149
242
|
isFocusedRef.current = true;
|
|
150
243
|
};
|
|
151
|
-
$[
|
|
152
|
-
} else
|
|
153
|
-
const handleFocus =
|
|
154
|
-
let
|
|
155
|
-
if ($[
|
|
156
|
-
|
|
244
|
+
$[66] = t18;
|
|
245
|
+
} else t18 = $[66];
|
|
246
|
+
const handleFocus = t18;
|
|
247
|
+
let t19;
|
|
248
|
+
if ($[67] !== displayBuffer || $[68] !== thousandsSeparator) {
|
|
249
|
+
t19 = (e_0)=>{
|
|
157
250
|
if ("Backspace" !== e_0.key) return;
|
|
158
251
|
const el = inputRef.current;
|
|
159
252
|
if (!el) return;
|
|
160
253
|
const cursor_0 = el.selectionStart ?? 0;
|
|
161
254
|
if (cursor_0 > 0 && isThousandSepBeforeCursor(displayBuffer, cursor_0, thousandsSeparator)) el.setSelectionRange(cursor_0 - 1, cursor_0 - 1);
|
|
162
255
|
};
|
|
163
|
-
$[
|
|
164
|
-
$[
|
|
165
|
-
$[
|
|
166
|
-
} else
|
|
167
|
-
const handleKeyDown =
|
|
168
|
-
let
|
|
169
|
-
if ($[
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
174
|
-
$[
|
|
175
|
-
$[
|
|
176
|
-
} else
|
|
177
|
-
const derivedActual =
|
|
178
|
-
const
|
|
179
|
-
let
|
|
180
|
-
if ($[
|
|
181
|
-
|
|
256
|
+
$[67] = displayBuffer;
|
|
257
|
+
$[68] = thousandsSeparator;
|
|
258
|
+
$[69] = t19;
|
|
259
|
+
} else t19 = $[69];
|
|
260
|
+
const handleKeyDown = t19;
|
|
261
|
+
let t20;
|
|
262
|
+
if ($[70] !== buffer.display || $[71] !== buffer.format || $[72] !== buffer.isPercentage) {
|
|
263
|
+
const canonical_3 = parse(buffer.display, buffer.format);
|
|
264
|
+
t20 = buffer.isPercentage ? fromPercent(canonical_3) : canonical_3;
|
|
265
|
+
$[70] = buffer.display;
|
|
266
|
+
$[71] = buffer.format;
|
|
267
|
+
$[72] = buffer.isPercentage;
|
|
268
|
+
$[73] = t20;
|
|
269
|
+
} else t20 = $[73];
|
|
270
|
+
const derivedActual = t20;
|
|
271
|
+
const t21 = decimalPlaces > 0 ? "decimal" : "numeric";
|
|
272
|
+
let t22;
|
|
273
|
+
if ($[74] !== displayBuffer || $[75] !== handleBlur || $[76] !== handleChange || $[77] !== handleKeyDown || $[78] !== t21) {
|
|
274
|
+
t22 = {
|
|
182
275
|
value: displayBuffer,
|
|
183
276
|
onChange: handleChange,
|
|
184
277
|
onBlur: handleBlur,
|
|
185
278
|
onFocus: handleFocus,
|
|
186
279
|
onKeyDown: handleKeyDown,
|
|
187
280
|
ref: inputRef,
|
|
188
|
-
inputMode:
|
|
281
|
+
inputMode: t21
|
|
189
282
|
};
|
|
190
|
-
$[
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
194
|
-
$[
|
|
195
|
-
$[
|
|
196
|
-
} else
|
|
197
|
-
let
|
|
198
|
-
if ($[
|
|
199
|
-
|
|
200
|
-
inputProps:
|
|
283
|
+
$[74] = displayBuffer;
|
|
284
|
+
$[75] = handleBlur;
|
|
285
|
+
$[76] = handleChange;
|
|
286
|
+
$[77] = handleKeyDown;
|
|
287
|
+
$[78] = t21;
|
|
288
|
+
$[79] = t22;
|
|
289
|
+
} else t22 = $[79];
|
|
290
|
+
let t23;
|
|
291
|
+
if ($[80] !== derivedActual || $[81] !== displayBuffer || $[82] !== t22) {
|
|
292
|
+
t23 = {
|
|
293
|
+
inputProps: t22,
|
|
201
294
|
value: derivedActual,
|
|
202
295
|
displayValue: displayBuffer
|
|
203
296
|
};
|
|
204
|
-
$[
|
|
205
|
-
$[
|
|
206
|
-
$[
|
|
207
|
-
$[
|
|
208
|
-
} else
|
|
209
|
-
return
|
|
297
|
+
$[80] = derivedActual;
|
|
298
|
+
$[81] = displayBuffer;
|
|
299
|
+
$[82] = t22;
|
|
300
|
+
$[83] = t23;
|
|
301
|
+
} else t23 = $[83];
|
|
302
|
+
return t23;
|
|
210
303
|
}
|
|
211
304
|
export { useNumberInput };
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { shiftDecimal } from "./percentage.js";
|
|
1
2
|
const CANONICAL_REGEX = /^-?\d*\.?\d*$/;
|
|
3
|
+
function toCanonical(value) {
|
|
4
|
+
const [coefficient, exponent] = String(value).split('e');
|
|
5
|
+
return void 0 === exponent ? coefficient : shiftDecimal(coefficient, Number(exponent));
|
|
6
|
+
}
|
|
2
7
|
function isValidCanonical(canonical) {
|
|
3
8
|
return CANONICAL_REGEX.test(canonical);
|
|
4
9
|
}
|
|
@@ -10,8 +15,8 @@ function clampToRange(canonical, min, max) {
|
|
|
10
15
|
if ('' === canonical || '-' === canonical) return canonical;
|
|
11
16
|
const n = Number(canonical);
|
|
12
17
|
if (!Number.isFinite(n)) return canonical;
|
|
13
|
-
if (void 0 !== min && n < min) return
|
|
14
|
-
if (void 0 !== max && n > max) return
|
|
18
|
+
if (void 0 !== min && n < min) return toCanonical(min);
|
|
19
|
+
if (void 0 !== max && n > max) return toCanonical(max);
|
|
15
20
|
return canonical;
|
|
16
21
|
}
|
|
17
22
|
export { clampToRange, isValidCanonical, stripDisallowedSign };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { c } from "react
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { Slot } from "@radix-ui/react-slot";
|
|
4
4
|
import { createContext, useContext, useRef } from "react";
|
|
5
5
|
import { taoTokenVars } from "../theme/tokens.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as Dialog from '@radix-ui/react-dialog';
|
|
2
|
+
import { type ComponentPropsWithoutRef, type Ref } from 'react';
|
|
3
|
+
type ContentProps = ComponentPropsWithoutRef<typeof Dialog.Content>;
|
|
4
|
+
interface DialogContentProps extends ContentProps {
|
|
5
|
+
open: boolean;
|
|
6
|
+
keepAlive: boolean;
|
|
7
|
+
contentRef?: Ref<HTMLDivElement>;
|
|
8
|
+
}
|
|
9
|
+
export declare function DialogContent({ open, keepAlive, contentRef, ...props }: DialogContentProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { forwardRef, memo, useImperativeHandle, useLayoutEffect, useState } from "react";
|
|
4
|
+
import * as __rspack_external__radix_ui_react_dialog_dabd8325 from "@radix-ui/react-dialog";
|
|
5
|
+
function DialogContent(t0) {
|
|
6
|
+
const $ = c(10);
|
|
7
|
+
let contentRef;
|
|
8
|
+
let keepAlive;
|
|
9
|
+
let open;
|
|
10
|
+
let props;
|
|
11
|
+
if ($[0] !== t0) {
|
|
12
|
+
({ open, keepAlive, contentRef, ...props } = t0);
|
|
13
|
+
$[0] = t0;
|
|
14
|
+
$[1] = contentRef;
|
|
15
|
+
$[2] = keepAlive;
|
|
16
|
+
$[3] = open;
|
|
17
|
+
$[4] = props;
|
|
18
|
+
} else {
|
|
19
|
+
contentRef = $[1];
|
|
20
|
+
keepAlive = $[2];
|
|
21
|
+
open = $[3];
|
|
22
|
+
props = $[4];
|
|
23
|
+
}
|
|
24
|
+
let t1;
|
|
25
|
+
if ($[5] !== contentRef || $[6] !== keepAlive || $[7] !== open || $[8] !== props) {
|
|
26
|
+
t1 = keepAlive ? /*#__PURE__*/ jsx(KeptDialogContent, {
|
|
27
|
+
open: open,
|
|
28
|
+
contentRef: contentRef,
|
|
29
|
+
contentProps: props
|
|
30
|
+
}) : /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_dialog_dabd8325.Content, {
|
|
31
|
+
...props,
|
|
32
|
+
ref: contentRef
|
|
33
|
+
});
|
|
34
|
+
$[5] = contentRef;
|
|
35
|
+
$[6] = keepAlive;
|
|
36
|
+
$[7] = open;
|
|
37
|
+
$[8] = props;
|
|
38
|
+
$[9] = t1;
|
|
39
|
+
} else t1 = $[9];
|
|
40
|
+
return t1;
|
|
41
|
+
}
|
|
42
|
+
function KeptDialogContent(t0) {
|
|
43
|
+
const $ = c(29);
|
|
44
|
+
const { open, contentRef, contentProps } = t0;
|
|
45
|
+
const [node, setNode] = useState(null);
|
|
46
|
+
let t1;
|
|
47
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
48
|
+
t1 = {};
|
|
49
|
+
$[0] = t1;
|
|
50
|
+
} else t1 = $[0];
|
|
51
|
+
const [layerProps, setLayerProps] = useState(t1);
|
|
52
|
+
let t2;
|
|
53
|
+
let t3;
|
|
54
|
+
if ($[1] !== node) {
|
|
55
|
+
t2 = ()=>node;
|
|
56
|
+
t3 = [
|
|
57
|
+
node
|
|
58
|
+
];
|
|
59
|
+
$[1] = node;
|
|
60
|
+
$[2] = t2;
|
|
61
|
+
$[3] = t3;
|
|
62
|
+
} else {
|
|
63
|
+
t2 = $[2];
|
|
64
|
+
t3 = $[3];
|
|
65
|
+
}
|
|
66
|
+
useImperativeHandle(contentRef, t2, t3);
|
|
67
|
+
let children;
|
|
68
|
+
let hostProps;
|
|
69
|
+
if ($[4] !== contentProps) {
|
|
70
|
+
const { children: t4, forceMount: _forceMount, asChild: _asChild, onOpenAutoFocus: _onOpenAutoFocus, onCloseAutoFocus: _onCloseAutoFocus, onEscapeKeyDown: _onEscapeKeyDown, onPointerDownOutside: _onPointerDownOutside, onFocusOutside: _onFocusOutside, onInteractOutside: _onInteractOutside, ...t5 } = contentProps;
|
|
71
|
+
children = t4;
|
|
72
|
+
hostProps = t5;
|
|
73
|
+
$[4] = contentProps;
|
|
74
|
+
$[5] = children;
|
|
75
|
+
$[6] = hostProps;
|
|
76
|
+
} else {
|
|
77
|
+
children = $[5];
|
|
78
|
+
hostProps = $[6];
|
|
79
|
+
}
|
|
80
|
+
let t4;
|
|
81
|
+
if ($[7] !== contentProps || $[8] !== node || $[9] !== open) {
|
|
82
|
+
t4 = open && node && /*#__PURE__*/ jsx(dialog_content_ModalLayer, {
|
|
83
|
+
node: node,
|
|
84
|
+
contentProps: contentProps,
|
|
85
|
+
onPropsChange: setLayerProps
|
|
86
|
+
});
|
|
87
|
+
$[7] = contentProps;
|
|
88
|
+
$[8] = node;
|
|
89
|
+
$[9] = open;
|
|
90
|
+
$[10] = t4;
|
|
91
|
+
} else t4 = $[10];
|
|
92
|
+
const t5 = layerProps["aria-labelledby"];
|
|
93
|
+
const t6 = layerProps["aria-describedby"];
|
|
94
|
+
const t7 = open ? layerProps : void 0;
|
|
95
|
+
const t8 = open ? "open" : "closed";
|
|
96
|
+
let t9;
|
|
97
|
+
if ($[11] !== layerProps.style || $[12] !== open) {
|
|
98
|
+
t9 = open ? layerProps.style : {
|
|
99
|
+
display: "none"
|
|
100
|
+
};
|
|
101
|
+
$[11] = layerProps.style;
|
|
102
|
+
$[12] = open;
|
|
103
|
+
$[13] = t9;
|
|
104
|
+
} else t9 = $[13];
|
|
105
|
+
let t10;
|
|
106
|
+
if ($[14] !== hostProps.style || $[15] !== t9) {
|
|
107
|
+
t10 = {
|
|
108
|
+
...hostProps.style,
|
|
109
|
+
...t9
|
|
110
|
+
};
|
|
111
|
+
$[14] = hostProps.style;
|
|
112
|
+
$[15] = t9;
|
|
113
|
+
$[16] = t10;
|
|
114
|
+
} else t10 = $[16];
|
|
115
|
+
let t11;
|
|
116
|
+
if ($[17] !== children || $[18] !== hostProps || $[19] !== layerProps.id || $[20] !== t10 || $[21] !== t5 || $[22] !== t6 || $[23] !== t7 || $[24] !== t8) {
|
|
117
|
+
t11 = /*#__PURE__*/ jsx("div", {
|
|
118
|
+
role: "dialog",
|
|
119
|
+
id: layerProps.id,
|
|
120
|
+
"aria-labelledby": t5,
|
|
121
|
+
"aria-describedby": t6,
|
|
122
|
+
...hostProps,
|
|
123
|
+
...t7,
|
|
124
|
+
ref: setNode,
|
|
125
|
+
"data-state": t8,
|
|
126
|
+
style: t10,
|
|
127
|
+
children: children
|
|
128
|
+
});
|
|
129
|
+
$[17] = children;
|
|
130
|
+
$[18] = hostProps;
|
|
131
|
+
$[19] = layerProps.id;
|
|
132
|
+
$[20] = t10;
|
|
133
|
+
$[21] = t5;
|
|
134
|
+
$[22] = t6;
|
|
135
|
+
$[23] = t7;
|
|
136
|
+
$[24] = t8;
|
|
137
|
+
$[25] = t11;
|
|
138
|
+
} else t11 = $[25];
|
|
139
|
+
let t12;
|
|
140
|
+
if ($[26] !== t11 || $[27] !== t4) {
|
|
141
|
+
t12 = /*#__PURE__*/ jsxs(Fragment, {
|
|
142
|
+
children: [
|
|
143
|
+
t4,
|
|
144
|
+
t11
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
$[26] = t11;
|
|
148
|
+
$[27] = t4;
|
|
149
|
+
$[28] = t12;
|
|
150
|
+
} else t12 = $[28];
|
|
151
|
+
return t12;
|
|
152
|
+
}
|
|
153
|
+
const dialog_content_ModalLayer = /*#__PURE__*/ memo(function(t0) {
|
|
154
|
+
const $ = c(6);
|
|
155
|
+
const { node, contentProps, onPropsChange } = t0;
|
|
156
|
+
let t1;
|
|
157
|
+
if ($[0] !== node || $[1] !== onPropsChange) {
|
|
158
|
+
t1 = /*#__PURE__*/ jsx(dialog_content_HostBridge, {
|
|
159
|
+
node: node,
|
|
160
|
+
onPropsChange: onPropsChange
|
|
161
|
+
});
|
|
162
|
+
$[0] = node;
|
|
163
|
+
$[1] = onPropsChange;
|
|
164
|
+
$[2] = t1;
|
|
165
|
+
} else t1 = $[2];
|
|
166
|
+
let t2;
|
|
167
|
+
if ($[3] !== contentProps || $[4] !== t1) {
|
|
168
|
+
t2 = /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_dialog_dabd8325.Content, {
|
|
169
|
+
...contentProps,
|
|
170
|
+
asChild: true,
|
|
171
|
+
children: t1
|
|
172
|
+
});
|
|
173
|
+
$[3] = contentProps;
|
|
174
|
+
$[4] = t1;
|
|
175
|
+
$[5] = t2;
|
|
176
|
+
} else t2 = $[5];
|
|
177
|
+
return t2;
|
|
178
|
+
});
|
|
179
|
+
const dialog_content_HostBridge = /*#__PURE__*/ forwardRef(function(t0, ref) {
|
|
180
|
+
const $ = c(10);
|
|
181
|
+
let node;
|
|
182
|
+
let onPropsChange;
|
|
183
|
+
let props;
|
|
184
|
+
if ($[0] !== t0) {
|
|
185
|
+
({ node, onPropsChange, ...props } = t0);
|
|
186
|
+
$[0] = t0;
|
|
187
|
+
$[1] = node;
|
|
188
|
+
$[2] = onPropsChange;
|
|
189
|
+
$[3] = props;
|
|
190
|
+
} else {
|
|
191
|
+
node = $[1];
|
|
192
|
+
onPropsChange = $[2];
|
|
193
|
+
props = $[3];
|
|
194
|
+
}
|
|
195
|
+
let t1;
|
|
196
|
+
let t2;
|
|
197
|
+
if ($[4] !== node) {
|
|
198
|
+
t1 = ()=>node;
|
|
199
|
+
t2 = [
|
|
200
|
+
node
|
|
201
|
+
];
|
|
202
|
+
$[4] = node;
|
|
203
|
+
$[5] = t1;
|
|
204
|
+
$[6] = t2;
|
|
205
|
+
} else {
|
|
206
|
+
t1 = $[5];
|
|
207
|
+
t2 = $[6];
|
|
208
|
+
}
|
|
209
|
+
useImperativeHandle(ref, t1, t2);
|
|
210
|
+
let t3;
|
|
211
|
+
if ($[7] !== onPropsChange || $[8] !== props) {
|
|
212
|
+
t3 = ()=>{
|
|
213
|
+
onPropsChange(props);
|
|
214
|
+
};
|
|
215
|
+
$[7] = onPropsChange;
|
|
216
|
+
$[8] = props;
|
|
217
|
+
$[9] = t3;
|
|
218
|
+
} else t3 = $[9];
|
|
219
|
+
useLayoutEffect(t3);
|
|
220
|
+
return null;
|
|
221
|
+
});
|
|
222
|
+
export { DialogContent };
|