@expcat/tigercat-react 2.0.19 → 2.1.1
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 +25 -16
- package/dist/chunk-246DAUEF.mjs +181 -0
- package/dist/{chunk-PU3JY6RE.mjs → chunk-2JMI7TCM.mjs} +1 -1
- package/dist/chunk-2YBLMVDT.mjs +428 -0
- package/dist/chunk-2YOP55OF.mjs +639 -0
- package/dist/{chunk-25D5TXZH.mjs → chunk-32MCQMBJ.mjs} +8 -6
- package/dist/chunk-3HHEVMHE.mjs +180 -0
- package/dist/{chunk-HSBN5MLS.mjs → chunk-3LACOSJQ.mjs} +1 -1
- package/dist/{chunk-F6WV53BS.mjs → chunk-3LDDXHW2.mjs} +28 -11
- package/dist/{chunk-IXQAECFP.mjs → chunk-3QNIFKVF.mjs} +12 -14
- package/dist/{chunk-UD4DTVJZ.mjs → chunk-4C2X5PZO.mjs} +57 -25
- package/dist/chunk-5JETWHLJ.mjs +28 -0
- package/dist/{chunk-VA6PZWOH.mjs → chunk-5SEMRHBD.mjs} +14 -6
- package/dist/{chunk-EKILTLUO.mjs → chunk-72CJNKDY.mjs} +1 -1
- package/dist/{chunk-XE4YFBOZ.mjs → chunk-AUD3VOLO.mjs} +1 -1
- package/dist/{chunk-UT5BV2VO.mjs → chunk-AYFKHWJS.mjs} +16 -10
- package/dist/{chunk-RPSHILHD.mjs → chunk-BXAH2GH3.mjs} +8 -2
- package/dist/{chunk-EW5EO7VE.mjs → chunk-BYD7EAWK.mjs} +1 -1
- package/dist/{chunk-BOGOQ44C.mjs → chunk-CQOLQAB5.mjs} +105 -90
- package/dist/{chunk-L55UK45A.mjs → chunk-CRIEUKMD.mjs} +5 -2
- package/dist/{chunk-DKNVSQSV.mjs → chunk-CUAXRBKO.mjs} +12 -0
- package/dist/{chunk-E7OTDBI6.mjs → chunk-DECUASRW.mjs} +17 -19
- package/dist/{chunk-XMTEMBQV.mjs → chunk-EAAWB3CK.mjs} +16 -13
- package/dist/{chunk-D33BIMGK.mjs → chunk-EG7EMDKK.mjs} +12 -2
- package/dist/chunk-EW43YBPV.mjs +457 -0
- package/dist/{chunk-HOYBHB7B.mjs → chunk-FNK2VWPP.mjs} +1 -1
- package/dist/{chunk-RJPNBYK5.mjs → chunk-FQS24AUH.mjs} +12 -3
- package/dist/{chunk-LADKKOJT.mjs → chunk-GBEDWXLL.mjs} +16 -10
- package/dist/chunk-GR3Y3XWP.mjs +47 -0
- package/dist/{chunk-2ENQZECC.mjs → chunk-HAXRHSCN.mjs} +4 -3
- package/dist/{chunk-K4GIKSZE.mjs → chunk-I2BENK5X.mjs} +2 -1
- package/dist/chunk-IGBQGR6G.mjs +234 -0
- package/dist/chunk-J76R2S62.mjs +161 -0
- package/dist/{chunk-DNOPEJ5I.mjs → chunk-JZZPLKTW.mjs} +7 -4
- package/dist/{chunk-7KCQMXJA.mjs → chunk-KDURW5AS.mjs} +4 -3
- package/dist/{chunk-TFMEHUVZ.mjs → chunk-KKN7KLTB.mjs} +0 -1
- package/dist/{chunk-6MGQAJ62.mjs → chunk-KL6YJIZ3.mjs} +24 -7
- package/dist/chunk-KRDHM5KB.mjs +259 -0
- package/dist/{chunk-HHIW7V7B.mjs → chunk-M6ZPTGBV.mjs} +2 -10
- package/dist/chunk-MFPVVGNA.mjs +248 -0
- package/dist/{chunk-PXRZ6CKY.mjs → chunk-MJVSZ2UJ.mjs} +46 -16
- package/dist/{chunk-LZKBDQE4.mjs → chunk-MYI3FPG4.mjs} +23 -4
- package/dist/{chunk-OIGEBCAS.mjs → chunk-NADODEZX.mjs} +69 -1
- package/dist/{chunk-KMP5CVNK.mjs → chunk-NJWTZ5MO.mjs} +57 -45
- package/dist/chunk-NLGLBTSM.mjs +138 -0
- package/dist/chunk-NT7GW2FD.mjs +40 -0
- package/dist/{chunk-773LH7BK.mjs → chunk-O6VYD4E4.mjs} +24 -2
- package/dist/{chunk-G7D4QV7A.mjs → chunk-O7TV5OKS.mjs} +33 -6
- package/dist/{chunk-DPWRXXXW.mjs → chunk-OJ6SHHOZ.mjs} +3 -3
- package/dist/chunk-OKYMTHFQ.mjs +279 -0
- package/dist/{chunk-UYJJLHVA.mjs → chunk-PMQJ6AYT.mjs} +23 -21
- package/dist/chunk-PY2VUNEJ.mjs +494 -0
- package/dist/{chunk-BEJZPJIK.mjs → chunk-QOAOOD53.mjs} +10 -4
- package/dist/{chunk-2WGEHH5A.mjs → chunk-QU3QXUTC.mjs} +49 -23
- package/dist/{chunk-V6P7ZK6O.mjs → chunk-QXSUG7SN.mjs} +3 -3
- package/dist/{chunk-FYINJRYN.mjs → chunk-R7YZ6FKP.mjs} +27 -16
- package/dist/{chunk-YI6YWH66.mjs → chunk-RE5ZLA5D.mjs} +6 -6
- package/dist/{chunk-UCBW5RJN.mjs → chunk-RGVU4EMA.mjs} +11 -6
- package/dist/{chunk-IBSOUQGB.mjs → chunk-RRGPDFDI.mjs} +7 -4
- package/dist/{chunk-ZH5ZBLAN.mjs → chunk-RUQ3F3MV.mjs} +34 -7
- package/dist/chunk-SEOG5AGS.mjs +72 -0
- package/dist/{chunk-PGD5RPKF.mjs → chunk-SVIJ2UZA.mjs} +2 -1
- package/dist/chunk-SXWEFZOF.mjs +766 -0
- package/dist/{chunk-NCHUEGUW.mjs → chunk-TEVEXDY2.mjs} +27 -16
- package/dist/{chunk-DJOFM2VO.mjs → chunk-TO6MZFNQ.mjs} +52 -40
- package/dist/chunk-TQ6RIFWR.mjs +135 -0
- package/dist/chunk-U4M3DC2P.mjs +48 -0
- package/dist/{chunk-ZCGIZOMT.mjs → chunk-V7HJ5HLC.mjs} +6 -10
- package/dist/{chunk-SIDDYP3O.mjs → chunk-VJWSKJLJ.mjs} +1 -1
- package/dist/{chunk-ZG56T75O.mjs → chunk-WTHWLCRL.mjs} +51 -11
- package/dist/{chunk-KP6DEYWB.mjs → chunk-X4L3W7RQ.mjs} +1 -1
- package/dist/{chunk-ZMRTETN2.mjs → chunk-X6C6MNG5.mjs} +4 -3
- package/dist/chunk-XT43B7ZI.mjs +58 -0
- package/dist/{chunk-OGG2TQDG.mjs → chunk-XVHTJQ4T.mjs} +12 -1
- package/dist/{chunk-QJE3MZBO.mjs → chunk-Y6UH3EKE.mjs} +1 -1
- package/dist/chunk-YJ5T4XZN.mjs +81 -0
- package/dist/{chunk-VVNFXJMN.mjs → chunk-YNDPQVEK.mjs} +8 -1
- package/dist/{chunk-QGZ32NFQ.mjs → chunk-Z23KOLNU.mjs} +4 -3
- package/dist/{chunk-5CKMYMTS.mjs → chunk-ZATZRXMW.mjs} +27 -8
- package/dist/components/ActivityFeed.mjs +3 -3
- package/dist/components/Affix.mjs +1 -1
- package/dist/components/Anchor.mjs +1 -1
- package/dist/components/AreaChart.mjs +5 -4
- package/dist/components/AspectRatio.d.mts +10 -0
- package/dist/components/AspectRatio.mjs +8 -0
- package/dist/components/AutoComplete.mjs +1 -1
- package/dist/components/BarChart.mjs +5 -4
- package/dist/components/Calendar.mjs +1 -1
- package/dist/components/Cascader.mjs +1 -1
- package/dist/components/ChartCanvas.mjs +1 -1
- package/dist/components/ChatWindow.mjs +4 -4
- package/dist/components/Code.mjs +3 -1
- package/dist/components/CollapsePanel.mjs +1 -1
- package/dist/components/ColorPicker.mjs +1 -1
- package/dist/components/CommentThread.mjs +2 -2
- package/dist/components/ContextMenu.d.mts +36 -0
- package/dist/components/ContextMenu.mjs +17 -0
- package/dist/components/DataExport.mjs +2 -2
- package/dist/components/DataTableWithToolbar.mjs +7 -7
- package/dist/components/DonutChart.mjs +4 -4
- package/dist/components/Dropdown.mjs +1 -1
- package/dist/components/FileManager.mjs +2 -1
- package/dist/components/FloatButton.mjs +1 -1
- package/dist/components/FormItem.mjs +1 -1
- package/dist/components/FormWizard.mjs +1 -1
- package/dist/components/FunnelChart.mjs +3 -3
- package/dist/components/Gantt.d.mts +3 -1
- package/dist/components/Gantt.mjs +2 -2
- package/dist/components/GaugeChart.mjs +2 -2
- package/dist/components/HeatmapChart.mjs +3 -3
- package/dist/components/Highlight.d.mts +11 -0
- package/dist/components/Highlight.mjs +8 -0
- package/dist/components/Image.mjs +4 -4
- package/dist/components/ImageCompare.d.mts +15 -0
- package/dist/components/ImageCompare.mjs +8 -0
- package/dist/components/ImageGroup.mjs +2 -2
- package/dist/components/ImagePreview.mjs +1 -1
- package/dist/components/Input.mjs +1 -1
- package/dist/components/InputNumber.d.mts +1 -1
- package/dist/components/InputNumber.mjs +1 -1
- package/dist/components/InputOTP.d.mts +33 -0
- package/dist/components/InputOTP.mjs +12 -0
- package/dist/components/Kanban.mjs +2 -2
- package/dist/components/Kbd.d.mts +10 -0
- package/dist/components/Kbd.mjs +8 -0
- package/dist/components/LineChart.mjs +5 -4
- package/dist/components/List.mjs +2 -2
- package/dist/components/Loading.mjs +1 -1
- package/dist/components/LoadingBar.d.mts +8 -0
- package/dist/components/LoadingBar.mjs +138 -0
- package/dist/components/LoadingBarContainer.d.mts +8 -0
- package/dist/components/LoadingBarContainer.mjs +8 -0
- package/dist/components/LoadingBarRoot.d.mts +6 -0
- package/dist/components/LoadingBarRoot.mjs +6 -0
- package/dist/components/Marquee.d.mts +10 -0
- package/dist/components/Marquee.mjs +8 -0
- package/dist/components/MaskInput.d.mts +37 -0
- package/dist/components/MaskInput.mjs +10 -0
- package/dist/components/Masonry.d.mts +10 -0
- package/dist/components/Masonry.mjs +8 -0
- package/dist/components/NavigationMenu.d.mts +84 -0
- package/dist/components/NavigationMenu.mjs +23 -0
- package/dist/components/NotificationCenter.mjs +4 -4
- package/dist/components/OrgChart.mjs +2 -2
- package/dist/components/PageHeader.d.mts +34 -0
- package/dist/components/PageHeader.mjs +11 -0
- package/dist/components/Pagination.mjs +1 -1
- package/dist/components/PieChart.mjs +3 -3
- package/dist/components/Popconfirm.mjs +2 -2
- package/dist/components/Popover.mjs +2 -2
- package/dist/components/QRCode.d.mts +2 -2
- package/dist/components/QRCode.mjs +1 -1
- package/dist/components/RadarChart.mjs +4 -4
- package/dist/components/Rate.mjs +1 -1
- package/dist/components/ScatterChart.mjs +5 -4
- package/dist/components/ScrollArea.d.mts +10 -0
- package/dist/components/ScrollArea.mjs +8 -0
- package/dist/components/ScrollSpy.mjs +1 -1
- package/dist/components/Signature.mjs +1 -1
- package/dist/components/SplitButton.d.mts +38 -0
- package/dist/components/SplitButton.mjs +12 -0
- package/dist/components/Splitter.mjs +1 -1
- package/dist/components/Stepper.d.mts +2 -0
- package/dist/components/Stepper.mjs +2 -1
- package/dist/components/SunburstChart.mjs +3 -3
- package/dist/components/Switch.d.mts +5 -1
- package/dist/components/Switch.mjs +2 -1
- package/dist/components/Table.mjs +2 -2
- package/dist/components/TagsInput.d.mts +41 -0
- package/dist/components/TagsInput.mjs +13 -0
- package/dist/components/TaskBoard.mjs +1 -1
- package/dist/components/Textarea.mjs +1 -1
- package/dist/components/Tooltip.mjs +2 -2
- package/dist/components/Tour.mjs +1 -1
- package/dist/components/TreeMapChart.mjs +3 -3
- package/dist/components/TreeSelect.mjs +2 -1
- package/dist/components/Upload.mjs +1 -1
- package/dist/hooks/useChartInteraction.d.mts +5 -0
- package/dist/hooks/useChartInteraction.mjs +1 -1
- package/dist/index.d.mts +17 -1
- package/dist/index.mjs +406 -0
- package/package.json +117 -2
- package/dist/chunk-7AFRHC7P.mjs +0 -312
- package/dist/chunk-CB4SK5AU.mjs +0 -235
- package/dist/chunk-KPACLRQH.mjs +0 -55
- package/dist/chunk-YIB6ZXZF.mjs +0 -386
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useFormItemControlContext
|
|
3
|
+
} from "./chunk-F6T3OLTQ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
useControlledState
|
|
6
|
+
} from "./chunk-MEFARVQI.mjs";
|
|
7
|
+
import {
|
|
8
|
+
useTigerConfig
|
|
9
|
+
} from "./chunk-YSIXURBW.mjs";
|
|
10
|
+
|
|
11
|
+
// src/components/InputOTP.tsx
|
|
12
|
+
import { useEffect, useId, useMemo, useRef } from "react";
|
|
13
|
+
import {
|
|
14
|
+
applyOtpBackspace,
|
|
15
|
+
applyOtpCharInput,
|
|
16
|
+
applyOtpDelete,
|
|
17
|
+
classNames,
|
|
18
|
+
devWarn,
|
|
19
|
+
distributeOtpPaste,
|
|
20
|
+
formatOtpSlotLabel,
|
|
21
|
+
getInputOTPLabels,
|
|
22
|
+
getOtpContainerClasses,
|
|
23
|
+
getOtpErrorClasses,
|
|
24
|
+
getOtpSeparatorClasses,
|
|
25
|
+
getOtpSeparatorIndices,
|
|
26
|
+
getOtpSlotClasses,
|
|
27
|
+
injectShakeStyle,
|
|
28
|
+
isOtpComplete,
|
|
29
|
+
normalizeOtpValue,
|
|
30
|
+
SHAKE_CLASS
|
|
31
|
+
} from "@expcat/tigercat-core";
|
|
32
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
33
|
+
var InputOTP = ({
|
|
34
|
+
size = "md",
|
|
35
|
+
status: statusProp,
|
|
36
|
+
errorMessage: errorMessageProp,
|
|
37
|
+
_shakeTrigger: shakeTriggerProp,
|
|
38
|
+
length = 6,
|
|
39
|
+
value,
|
|
40
|
+
defaultValue,
|
|
41
|
+
type = "numeric",
|
|
42
|
+
pattern,
|
|
43
|
+
masked = false,
|
|
44
|
+
maskChar = "\u2022",
|
|
45
|
+
groups,
|
|
46
|
+
separator = "-",
|
|
47
|
+
disabled = false,
|
|
48
|
+
readonly = false,
|
|
49
|
+
autoFocus = false,
|
|
50
|
+
name,
|
|
51
|
+
id,
|
|
52
|
+
ariaLabel,
|
|
53
|
+
onChange,
|
|
54
|
+
onComplete,
|
|
55
|
+
onFocus,
|
|
56
|
+
onBlur,
|
|
57
|
+
className,
|
|
58
|
+
style,
|
|
59
|
+
...rest
|
|
60
|
+
}) => {
|
|
61
|
+
injectShakeStyle();
|
|
62
|
+
const config = useTigerConfig();
|
|
63
|
+
const formItemControl = useFormItemControlContext();
|
|
64
|
+
const status = statusProp ?? formItemControl?.status ?? "default";
|
|
65
|
+
const errorMessage = errorMessageProp ?? formItemControl?.errorMessage;
|
|
66
|
+
const shakeTrigger = shakeTriggerProp ?? formItemControl?.shakeTrigger;
|
|
67
|
+
const labels = getInputOTPLabels(config.locale);
|
|
68
|
+
const reactId = useId();
|
|
69
|
+
const errorMsgId = `tiger-input-otp-error-${reactId}`;
|
|
70
|
+
const containerRef = useRef(null);
|
|
71
|
+
const slotRefs = useRef([]);
|
|
72
|
+
const charOptions = useMemo(() => ({ type, pattern }), [type, pattern]);
|
|
73
|
+
const [rawValue, setRawValue] = useControlledState(value, defaultValue ?? "", onChange);
|
|
74
|
+
const currentValue = normalizeOtpValue(rawValue, length, charOptions);
|
|
75
|
+
const separatorIndices = useMemo(() => getOtpSeparatorIndices(length, groups), [length, groups]);
|
|
76
|
+
if (groups && groups.length > 0 && separatorIndices.length === 0) {
|
|
77
|
+
devWarn("InputOTP.groups", "[Tigercat] InputOTP: `groups` must sum to `length`; ignoring.");
|
|
78
|
+
}
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (status === "error" && containerRef.current) {
|
|
81
|
+
const el = containerRef.current;
|
|
82
|
+
el.classList.remove(SHAKE_CLASS);
|
|
83
|
+
void el.offsetWidth;
|
|
84
|
+
el.classList.add(SHAKE_CLASS);
|
|
85
|
+
}
|
|
86
|
+
}, [status, shakeTrigger]);
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (autoFocus) {
|
|
89
|
+
slotRefs.current[Math.min(currentValue.length, length - 1)]?.focus();
|
|
90
|
+
}
|
|
91
|
+
}, []);
|
|
92
|
+
const focusSlot = (index) => {
|
|
93
|
+
slotRefs.current[Math.max(0, Math.min(index, length - 1))]?.focus();
|
|
94
|
+
};
|
|
95
|
+
const displayChar = (val, index) => {
|
|
96
|
+
const char = val[index] ?? "";
|
|
97
|
+
return char && masked ? maskChar : char;
|
|
98
|
+
};
|
|
99
|
+
const emitValue = (next) => {
|
|
100
|
+
if (next === currentValue) return;
|
|
101
|
+
setRawValue(next);
|
|
102
|
+
if (isOtpComplete(next, length)) onComplete?.(next);
|
|
103
|
+
};
|
|
104
|
+
const isInteractive = !disabled && !readonly;
|
|
105
|
+
const handleSlotChange = (index, event) => {
|
|
106
|
+
if (!isInteractive) return;
|
|
107
|
+
const result = applyOtpCharInput(
|
|
108
|
+
currentValue,
|
|
109
|
+
index,
|
|
110
|
+
event.currentTarget.value,
|
|
111
|
+
length,
|
|
112
|
+
charOptions
|
|
113
|
+
);
|
|
114
|
+
event.currentTarget.value = displayChar(result.value, index);
|
|
115
|
+
emitValue(result.value);
|
|
116
|
+
focusSlot(result.nextIndex);
|
|
117
|
+
};
|
|
118
|
+
const handleSlotKeyDown = (index, event) => {
|
|
119
|
+
if (!isInteractive) return;
|
|
120
|
+
switch (event.key) {
|
|
121
|
+
case "Backspace": {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
const result = applyOtpBackspace(currentValue, index);
|
|
124
|
+
emitValue(result.value);
|
|
125
|
+
focusSlot(result.nextIndex);
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case "Delete": {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
const result = applyOtpDelete(currentValue, index);
|
|
131
|
+
emitValue(result.value);
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
case "ArrowLeft":
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
focusSlot(index - 1);
|
|
137
|
+
break;
|
|
138
|
+
case "ArrowRight":
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
focusSlot(index + 1);
|
|
141
|
+
break;
|
|
142
|
+
case "Home":
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
focusSlot(0);
|
|
145
|
+
break;
|
|
146
|
+
case "End":
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
focusSlot(Math.min(currentValue.length, length - 1));
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const handlePaste = (event) => {
|
|
153
|
+
if (!isInteractive) return;
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
const result = distributeOtpPaste(event.clipboardData.getData("text"), length, charOptions);
|
|
156
|
+
if (!result) return;
|
|
157
|
+
emitValue(result.value);
|
|
158
|
+
focusSlot(result.nextIndex);
|
|
159
|
+
};
|
|
160
|
+
const handleSlotFocus = (event) => {
|
|
161
|
+
event.currentTarget.select();
|
|
162
|
+
};
|
|
163
|
+
const handleGroupFocus = (event) => {
|
|
164
|
+
if (!containerRef.current?.contains(event.relatedTarget)) {
|
|
165
|
+
onFocus?.(event);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const handleGroupBlur = (event) => {
|
|
169
|
+
if (!containerRef.current?.contains(event.relatedTarget)) {
|
|
170
|
+
onBlur?.(event);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
const activeError = status === "error" && !!errorMessage;
|
|
174
|
+
const slotClasses = getOtpSlotClasses(size, status, { disabled, readonly });
|
|
175
|
+
const slots = [];
|
|
176
|
+
for (let i = 0; i < length; i++) {
|
|
177
|
+
slots.push(
|
|
178
|
+
/* @__PURE__ */ jsx(
|
|
179
|
+
"input",
|
|
180
|
+
{
|
|
181
|
+
ref: (el) => {
|
|
182
|
+
slotRefs.current[i] = el;
|
|
183
|
+
},
|
|
184
|
+
className: slotClasses,
|
|
185
|
+
type: "text",
|
|
186
|
+
inputMode: type === "numeric" ? "numeric" : void 0,
|
|
187
|
+
autoComplete: i === 0 ? "one-time-code" : "off",
|
|
188
|
+
value: displayChar(currentValue, i),
|
|
189
|
+
disabled,
|
|
190
|
+
readOnly: readonly,
|
|
191
|
+
"aria-label": formatOtpSlotLabel(labels.slotLabel, i + 1, length),
|
|
192
|
+
...status === "error" ? { "aria-invalid": true } : {},
|
|
193
|
+
onChange: (event) => handleSlotChange(i, event),
|
|
194
|
+
onKeyDown: (event) => handleSlotKeyDown(i, event),
|
|
195
|
+
onFocus: handleSlotFocus
|
|
196
|
+
},
|
|
197
|
+
`slot-${i}`
|
|
198
|
+
)
|
|
199
|
+
);
|
|
200
|
+
if (separatorIndices.includes(i) && separator) {
|
|
201
|
+
slots.push(
|
|
202
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: getOtpSeparatorClasses(size), children: separator }, `separator-${i}`)
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return /* @__PURE__ */ jsxs("div", { className: classNames("inline-block", className), style, children: [
|
|
207
|
+
/* @__PURE__ */ jsxs(
|
|
208
|
+
"div",
|
|
209
|
+
{
|
|
210
|
+
...rest,
|
|
211
|
+
ref: containerRef,
|
|
212
|
+
id,
|
|
213
|
+
role: "group",
|
|
214
|
+
"aria-label": ariaLabel ?? labels.groupLabel,
|
|
215
|
+
...activeError ? { "aria-describedby": errorMsgId } : {},
|
|
216
|
+
className: getOtpContainerClasses(size),
|
|
217
|
+
onPaste: handlePaste,
|
|
218
|
+
onFocus: handleGroupFocus,
|
|
219
|
+
onBlur: handleGroupBlur,
|
|
220
|
+
children: [
|
|
221
|
+
slots,
|
|
222
|
+
name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: currentValue })
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
activeError && /* @__PURE__ */ jsx("div", { id: errorMsgId, className: getOtpErrorClasses(), children: errorMessage })
|
|
227
|
+
] });
|
|
228
|
+
};
|
|
229
|
+
var InputOTP_default = InputOTP;
|
|
230
|
+
|
|
231
|
+
export {
|
|
232
|
+
InputOTP,
|
|
233
|
+
InputOTP_default
|
|
234
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// src/components/Masonry.tsx
|
|
2
|
+
import {
|
|
3
|
+
Children,
|
|
4
|
+
forwardRef,
|
|
5
|
+
useCallback,
|
|
6
|
+
useEffect,
|
|
7
|
+
useImperativeHandle,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
useSyncExternalStore
|
|
12
|
+
} from "react";
|
|
13
|
+
import {
|
|
14
|
+
classNames,
|
|
15
|
+
computeMasonryColumnHeights,
|
|
16
|
+
distributeMasonryItems,
|
|
17
|
+
getMasonryColumnClasses,
|
|
18
|
+
getMasonryColumnStyle,
|
|
19
|
+
getMasonryGapStyle,
|
|
20
|
+
getMasonryItemClasses,
|
|
21
|
+
getMasonryRootClasses,
|
|
22
|
+
moduloDistributeMasonryItems,
|
|
23
|
+
observeScrollAreaSize,
|
|
24
|
+
readMasonryItemHeight,
|
|
25
|
+
resolveMasonryColumnCount,
|
|
26
|
+
resolveMasonryGap,
|
|
27
|
+
MASONRY_DEFAULT_COLUMNS,
|
|
28
|
+
MASONRY_DEFAULT_GAP
|
|
29
|
+
} from "@expcat/tigercat-core";
|
|
30
|
+
import { jsx } from "react/jsx-runtime";
|
|
31
|
+
function childSignature(nodes) {
|
|
32
|
+
return nodes.map(
|
|
33
|
+
(node, index) => `${index}:${typeof node === "object" && node !== null && "key" in node ? String(node.key ?? "") : String(node)}`
|
|
34
|
+
).join("\0");
|
|
35
|
+
}
|
|
36
|
+
function sameHeights(previous, next) {
|
|
37
|
+
return previous.length === next.length && previous.every((height, index) => height === next[index]);
|
|
38
|
+
}
|
|
39
|
+
function subscribeToResize(onChange) {
|
|
40
|
+
window.addEventListener("resize", onChange);
|
|
41
|
+
return () => window.removeEventListener("resize", onChange);
|
|
42
|
+
}
|
|
43
|
+
var noopSubscribe = () => () => void 0;
|
|
44
|
+
var Masonry = forwardRef(
|
|
45
|
+
({
|
|
46
|
+
columns = MASONRY_DEFAULT_COLUMNS,
|
|
47
|
+
gap = MASONRY_DEFAULT_GAP,
|
|
48
|
+
className,
|
|
49
|
+
columnClassName,
|
|
50
|
+
itemClassName,
|
|
51
|
+
children,
|
|
52
|
+
onLayout,
|
|
53
|
+
style,
|
|
54
|
+
...rest
|
|
55
|
+
}, ref) => {
|
|
56
|
+
const itemRefs = useRef(/* @__PURE__ */ new Map());
|
|
57
|
+
const heightsRef = useRef([]);
|
|
58
|
+
const lastSignatureRef = useRef("");
|
|
59
|
+
const onLayoutRef = useRef(onLayout);
|
|
60
|
+
onLayoutRef.current = onLayout;
|
|
61
|
+
const [distribution, setDistribution] = useState([]);
|
|
62
|
+
const childNodes = useMemo(() => Children.toArray(children), [children]);
|
|
63
|
+
const signature = childSignature(childNodes);
|
|
64
|
+
const isResponsive = typeof columns === "object" || typeof gap === "object";
|
|
65
|
+
const subscribe = useMemo(
|
|
66
|
+
() => isResponsive ? subscribeToResize : noopSubscribe,
|
|
67
|
+
[isResponsive]
|
|
68
|
+
);
|
|
69
|
+
const windowWidth = useSyncExternalStore(
|
|
70
|
+
subscribe,
|
|
71
|
+
() => window.innerWidth,
|
|
72
|
+
() => 1024
|
|
73
|
+
);
|
|
74
|
+
const columnCount = resolveMasonryColumnCount(columns, windowWidth);
|
|
75
|
+
const gapPx = resolveMasonryGap(gap, windowWidth);
|
|
76
|
+
const relayout = useCallback(() => {
|
|
77
|
+
const elements = itemRefs.current;
|
|
78
|
+
const indices = Array.from(elements.keys());
|
|
79
|
+
const maxIndex = indices.length > 0 ? Math.max(...indices) : -1;
|
|
80
|
+
const nextHeights = [];
|
|
81
|
+
for (let index = 0; index <= maxIndex; index++) {
|
|
82
|
+
const element = elements.get(index);
|
|
83
|
+
nextHeights.push(element ? readMasonryItemHeight(element) : 0);
|
|
84
|
+
}
|
|
85
|
+
const countChanged = nextHeights.length !== heightsRef.current.length;
|
|
86
|
+
if (!countChanged && sameHeights(heightsRef.current, nextHeights)) return;
|
|
87
|
+
heightsRef.current = nextHeights;
|
|
88
|
+
const nextDistribution = distributeMasonryItems(nextHeights, columnCount);
|
|
89
|
+
setDistribution(nextDistribution);
|
|
90
|
+
onLayoutRef.current?.({
|
|
91
|
+
columnCount,
|
|
92
|
+
columnHeights: computeMasonryColumnHeights(nextHeights, nextDistribution, gapPx)
|
|
93
|
+
});
|
|
94
|
+
}, [columnCount, gapPx]);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (lastSignatureRef.current !== signature) {
|
|
97
|
+
lastSignatureRef.current = signature;
|
|
98
|
+
relayout();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (heightsRef.current.length === 0) return;
|
|
102
|
+
const nextDistribution = distributeMasonryItems(heightsRef.current, columnCount);
|
|
103
|
+
setDistribution(nextDistribution);
|
|
104
|
+
onLayoutRef.current?.({
|
|
105
|
+
columnCount,
|
|
106
|
+
columnHeights: computeMasonryColumnHeights(heightsRef.current, nextDistribution, gapPx)
|
|
107
|
+
});
|
|
108
|
+
}, [signature, columnCount, gapPx, relayout]);
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (childNodes.length === 0) return;
|
|
111
|
+
return observeScrollAreaSize(Array.from(itemRefs.current.values()), relayout);
|
|
112
|
+
}, [signature, distribution, relayout, childNodes.length]);
|
|
113
|
+
useImperativeHandle(
|
|
114
|
+
ref,
|
|
115
|
+
() => ({
|
|
116
|
+
relayout,
|
|
117
|
+
getColumnCount: () => columnCount
|
|
118
|
+
}),
|
|
119
|
+
[relayout, columnCount]
|
|
120
|
+
);
|
|
121
|
+
const activeDistribution = distribution.length > 0 && heightsRef.current.length === childNodes.length ? distribution : moduloDistributeMasonryItems(childNodes.length, columnCount);
|
|
122
|
+
return /* @__PURE__ */ jsx(
|
|
123
|
+
"div",
|
|
124
|
+
{
|
|
125
|
+
...rest,
|
|
126
|
+
className: classNames(getMasonryRootClasses(className)),
|
|
127
|
+
style: { ...getMasonryGapStyle(gapPx), ...style },
|
|
128
|
+
"data-masonry": "",
|
|
129
|
+
children: activeDistribution.map((indices, columnIndex) => /* @__PURE__ */ jsx(
|
|
130
|
+
"div",
|
|
131
|
+
{
|
|
132
|
+
className: getMasonryColumnClasses(columnClassName),
|
|
133
|
+
style: getMasonryColumnStyle(gapPx),
|
|
134
|
+
"data-masonry-column": columnIndex,
|
|
135
|
+
children: indices.map((index) => /* @__PURE__ */ jsx(
|
|
136
|
+
"div",
|
|
137
|
+
{
|
|
138
|
+
className: getMasonryItemClasses(itemClassName),
|
|
139
|
+
"data-masonry-item": index,
|
|
140
|
+
ref: (el) => {
|
|
141
|
+
if (el) itemRefs.current.set(index, el);
|
|
142
|
+
else itemRefs.current.delete(index);
|
|
143
|
+
},
|
|
144
|
+
children: childNodes[index]
|
|
145
|
+
},
|
|
146
|
+
`item-${index}`
|
|
147
|
+
))
|
|
148
|
+
},
|
|
149
|
+
`column-${columnIndex}`
|
|
150
|
+
))
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
Masonry.displayName = "Masonry";
|
|
156
|
+
var Masonry_default = Masonry;
|
|
157
|
+
|
|
158
|
+
export {
|
|
159
|
+
Masonry,
|
|
160
|
+
Masonry_default
|
|
161
|
+
};
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
function useChartInteraction(options) {
|
|
9
9
|
const {
|
|
10
10
|
hoverable,
|
|
11
|
+
showTooltip = true,
|
|
11
12
|
hoveredIndexProp,
|
|
12
13
|
selectable,
|
|
13
14
|
selectedIndexProp,
|
|
@@ -50,17 +51,18 @@ function useChartInteraction(options) {
|
|
|
50
51
|
);
|
|
51
52
|
const handleMouseEnter = useCallback(
|
|
52
53
|
(index, event) => {
|
|
53
|
-
if (!hoverable) return;
|
|
54
|
+
if (!hoverable && !showTooltip) return;
|
|
54
55
|
if (hoveredIndexProp === void 0) {
|
|
55
56
|
setLocalHoveredIndex(index);
|
|
56
57
|
}
|
|
57
58
|
setTooltipPosition({ x: event.clientX, y: event.clientY });
|
|
59
|
+
if (!hoverable) return;
|
|
58
60
|
onHoveredIndexChange?.(index);
|
|
59
61
|
if (callbacks?.onHover && getData) {
|
|
60
62
|
callbacks.onHover(index, getData(index) ?? null);
|
|
61
63
|
}
|
|
62
64
|
},
|
|
63
|
-
[hoverable, hoveredIndexProp, onHoveredIndexChange, callbacks, getData]
|
|
65
|
+
[hoverable, showTooltip, hoveredIndexProp, onHoveredIndexChange, callbacks, getData]
|
|
64
66
|
);
|
|
65
67
|
const handleMouseMove = useCallback(
|
|
66
68
|
(event) => {
|
|
@@ -70,13 +72,14 @@ function useChartInteraction(options) {
|
|
|
70
72
|
);
|
|
71
73
|
const handleMouseLeave = useCallback(() => {
|
|
72
74
|
tooltipScheduler.cancel();
|
|
73
|
-
if (!hoverable) return;
|
|
75
|
+
if (!hoverable && !showTooltip) return;
|
|
74
76
|
if (hoveredIndexProp === void 0) {
|
|
75
77
|
setLocalHoveredIndex(null);
|
|
76
78
|
}
|
|
79
|
+
if (!hoverable) return;
|
|
77
80
|
onHoveredIndexChange?.(null);
|
|
78
81
|
callbacks?.onHover?.(null, null);
|
|
79
|
-
}, [hoverable, tooltipScheduler, hoveredIndexProp, onHoveredIndexChange, callbacks]);
|
|
82
|
+
}, [hoverable, showTooltip, tooltipScheduler, hoveredIndexProp, onHoveredIndexChange, callbacks]);
|
|
80
83
|
const handleClick = useCallback(
|
|
81
84
|
(index) => {
|
|
82
85
|
if (!selectable) return;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useChartInteraction
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JZZPLKTW.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ChartTooltip
|
|
6
6
|
} from "./chunk-YORCCCQX.mjs";
|
|
7
7
|
import {
|
|
8
8
|
ChartCanvas
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-CUAXRBKO.mjs";
|
|
10
10
|
import {
|
|
11
11
|
ChartLegend
|
|
12
12
|
} from "./chunk-F2ITBDUS.mjs";
|
|
@@ -70,6 +70,7 @@ var FunnelChart = ({
|
|
|
70
70
|
wrapperClasses
|
|
71
71
|
} = useChartInteraction({
|
|
72
72
|
hoverable,
|
|
73
|
+
showTooltip,
|
|
73
74
|
hoveredIndexProp,
|
|
74
75
|
selectable,
|
|
75
76
|
selectedIndexProp,
|
|
@@ -191,7 +192,7 @@ var FunnelChart = ({
|
|
|
191
192
|
]
|
|
192
193
|
}
|
|
193
194
|
);
|
|
194
|
-
const tooltip = showTooltip
|
|
195
|
+
const tooltip = showTooltip ? /* @__PURE__ */ jsx(
|
|
195
196
|
ChartTooltip,
|
|
196
197
|
{
|
|
197
198
|
content: tooltipContent,
|
|
@@ -11,15 +11,24 @@ import {
|
|
|
11
11
|
colorPickerPanelClasses,
|
|
12
12
|
colorPickerInputClasses,
|
|
13
13
|
colorPickerPresetClasses,
|
|
14
|
-
hexToRgb,
|
|
15
14
|
rgbToHex,
|
|
16
15
|
rgbToHsv,
|
|
17
16
|
hsvToRgb,
|
|
18
17
|
formatColorString,
|
|
19
18
|
parseColorInput,
|
|
19
|
+
parseColorParts,
|
|
20
20
|
classNames
|
|
21
21
|
} from "@expcat/tigercat-core";
|
|
22
22
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
+
function rgbFromValue(value) {
|
|
24
|
+
const parts = parseColorParts(value);
|
|
25
|
+
return parts ? { r: parts.r, g: parts.g, b: parts.b } : { r: 0, g: 0, b: 0 };
|
|
26
|
+
}
|
|
27
|
+
function explicitAlphaFromValue(value) {
|
|
28
|
+
if (!/^(rgba|hsla)\(/i.test(value.trim())) return null;
|
|
29
|
+
const parts = parseColorParts(value);
|
|
30
|
+
return parts ? parts.a : null;
|
|
31
|
+
}
|
|
23
32
|
var ColorPicker = ({
|
|
24
33
|
value = "#2563eb",
|
|
25
34
|
disabled = false,
|
|
@@ -31,7 +40,7 @@ var ColorPicker = ({
|
|
|
31
40
|
onChange
|
|
32
41
|
}) => {
|
|
33
42
|
const [isOpen, setIsOpen] = useState(false);
|
|
34
|
-
const [alpha, setAlpha] = useState(1);
|
|
43
|
+
const [alpha, setAlpha] = useState(() => explicitAlphaFromValue(value) ?? 1);
|
|
35
44
|
const containerRef = useRef(null);
|
|
36
45
|
const triggerRef = useRef(null);
|
|
37
46
|
const panelRef = useRef(null);
|
|
@@ -47,8 +56,12 @@ var ColorPicker = ({
|
|
|
47
56
|
restoreFocusOnDismiss: true,
|
|
48
57
|
onDismiss: () => setIsOpen(false)
|
|
49
58
|
});
|
|
50
|
-
const rgb = useMemo(() =>
|
|
59
|
+
const rgb = useMemo(() => rgbFromValue(value), [value]);
|
|
51
60
|
const hsv = useMemo(() => rgbToHsv(rgb.r, rgb.g, rgb.b), [rgb]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
const next = explicitAlphaFromValue(value);
|
|
63
|
+
if (next !== null) setAlpha(next);
|
|
64
|
+
}, [value]);
|
|
52
65
|
const displayValue = useMemo(
|
|
53
66
|
() => formatColorString(rgb.r, rgb.g, rgb.b, format, showAlpha ? alpha : void 0),
|
|
54
67
|
[rgb, format, showAlpha, alpha]
|
|
@@ -80,13 +93,17 @@ var ColorPicker = ({
|
|
|
80
93
|
function handleInputChange(e) {
|
|
81
94
|
const val = e.target.value;
|
|
82
95
|
setInputValue(val);
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
onChange?.(
|
|
96
|
+
const parsed = parseColorInput(val);
|
|
97
|
+
if (parsed) {
|
|
98
|
+
onChange?.(parsed);
|
|
86
99
|
}
|
|
87
100
|
}
|
|
88
101
|
function handleAlphaChange(e) {
|
|
89
|
-
|
|
102
|
+
const nextAlpha = Number(e.target.value) / 100;
|
|
103
|
+
setAlpha(nextAlpha);
|
|
104
|
+
const emitFormat = format === "hex" ? "rgb" : format;
|
|
105
|
+
const next = formatColorString(rgb.r, rgb.g, rgb.b, emitFormat, nextAlpha);
|
|
106
|
+
onChange?.(next);
|
|
90
107
|
}
|
|
91
108
|
function handlePresetClick(color) {
|
|
92
109
|
onChange?.(color);
|