@expcat/tigercat-vue 2.0.4 → 2.1.0

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.
Files changed (114) hide show
  1. package/README.md +20 -10
  2. package/dist/chunk-26QCTL2E.mjs +180 -0
  3. package/dist/{chunk-GS4SV2HK.mjs → chunk-32X54QKW.mjs} +1 -1
  4. package/dist/chunk-3ONCXHE5.mjs +184 -0
  5. package/dist/{chunk-KOG3HKOF.mjs → chunk-6AMWX5K4.mjs} +1 -4
  6. package/dist/chunk-6GR3XC5V.mjs +281 -0
  7. package/dist/chunk-6GR5U4UB.mjs +225 -0
  8. package/dist/chunk-7DWWNFRP.mjs +302 -0
  9. package/dist/chunk-AECXFT7D.mjs +121 -0
  10. package/dist/chunk-AOLRZG4E.mjs +347 -0
  11. package/dist/chunk-AY7CGLMO.mjs +368 -0
  12. package/dist/chunk-BBNCP55O.mjs +156 -0
  13. package/dist/chunk-F3ZVVVYD.mjs +257 -0
  14. package/dist/{chunk-OTGGPXDT.mjs → chunk-IEAEB4TX.mjs} +255 -44
  15. package/dist/chunk-P6FMU4AT.mjs +54 -0
  16. package/dist/chunk-PFIV5MXD.mjs +48 -0
  17. package/dist/chunk-TBOXTAIA.mjs +94 -0
  18. package/dist/{chunk-H6FZBFRT.mjs → chunk-TPESRDUG.mjs} +6 -1
  19. package/dist/{chunk-2XCXK3NQ.mjs → chunk-U4B5QT72.mjs} +1 -1
  20. package/dist/chunk-UUWPSRNV.mjs +337 -0
  21. package/dist/chunk-UXJRH72H.mjs +834 -0
  22. package/dist/chunk-VFS5XAZ3.mjs +602 -0
  23. package/dist/{chunk-WC5MKASU.mjs → chunk-VN2TWPRC.mjs} +169 -55
  24. package/dist/components/ActivityFeed.d.mts +1 -1
  25. package/dist/components/ActivityFeed.mjs +1 -1
  26. package/dist/components/Alert.d.mts +2 -2
  27. package/dist/components/AreaChart.mjs +2 -2
  28. package/dist/components/AspectRatio.d.mts +44 -0
  29. package/dist/components/AspectRatio.mjs +8 -0
  30. package/dist/components/BarChart.mjs +2 -2
  31. package/dist/components/Carousel.d.mts +1 -1
  32. package/dist/components/Cascader.d.mts +34 -0
  33. package/dist/components/Cascader.mjs +1 -1
  34. package/dist/components/ChartLegend.d.mts +1 -1
  35. package/dist/components/ChatWindow.mjs +1 -1
  36. package/dist/components/CodeEditor.mjs +1 -1
  37. package/dist/components/ColorSwatch.d.mts +1 -1
  38. package/dist/components/ContextMenu.d.mts +234 -0
  39. package/dist/components/ContextMenu.mjs +17 -0
  40. package/dist/components/DataTableWithToolbar.d.mts +1 -1
  41. package/dist/components/DataTableWithToolbar.mjs +2 -2
  42. package/dist/components/DonutChart.mjs +3 -3
  43. package/dist/components/Dropdown.d.mts +1 -1
  44. package/dist/components/FloatButton.d.mts +2 -2
  45. package/dist/components/FunnelChart.d.mts +1 -1
  46. package/dist/components/FunnelChart.mjs +2 -2
  47. package/dist/components/Highlight.d.mts +146 -0
  48. package/dist/components/Highlight.mjs +8 -0
  49. package/dist/components/ImageCompare.d.mts +284 -0
  50. package/dist/components/ImageCompare.mjs +8 -0
  51. package/dist/components/Input.d.mts +1 -1
  52. package/dist/components/InputOTP.d.mts +261 -0
  53. package/dist/components/InputOTP.mjs +11 -0
  54. package/dist/components/Kbd.d.mts +118 -0
  55. package/dist/components/Kbd.mjs +8 -0
  56. package/dist/components/LineChart.mjs +2 -2
  57. package/dist/components/List.d.mts +1 -1
  58. package/dist/components/List.mjs +1 -1
  59. package/dist/components/LoadingBar.d.mts +8 -0
  60. package/dist/components/LoadingBar.mjs +114 -0
  61. package/dist/components/LoadingBarContainer.d.mts +78 -0
  62. package/dist/components/LoadingBarContainer.mjs +8 -0
  63. package/dist/components/LoadingBarRoot.d.mts +6 -0
  64. package/dist/components/LoadingBarRoot.mjs +6 -0
  65. package/dist/components/Marquee.d.mts +158 -0
  66. package/dist/components/Marquee.mjs +8 -0
  67. package/dist/components/MaskInput.d.mts +201 -0
  68. package/dist/components/MaskInput.mjs +11 -0
  69. package/dist/components/Masonry.d.mts +66 -0
  70. package/dist/components/Masonry.mjs +8 -0
  71. package/dist/components/Menu.d.mts +2 -2
  72. package/dist/components/Modal.d.mts +1 -1
  73. package/dist/components/NavigationMenu.d.mts +411 -0
  74. package/dist/components/NavigationMenu.mjs +25 -0
  75. package/dist/components/NotificationCenter.d.mts +1 -1
  76. package/dist/components/NotificationCenter.mjs +2 -2
  77. package/dist/components/PageHeader.d.mts +140 -0
  78. package/dist/components/PageHeader.mjs +11 -0
  79. package/dist/components/PieChart.mjs +2 -2
  80. package/dist/components/Popconfirm.d.mts +3 -3
  81. package/dist/components/Popover.d.mts +2 -2
  82. package/dist/components/RadarChart.mjs +2 -2
  83. package/dist/components/ScatterChart.mjs +2 -2
  84. package/dist/components/ScrollArea.d.mts +136 -0
  85. package/dist/components/ScrollArea.mjs +8 -0
  86. package/dist/components/SplitButton.d.mts +286 -0
  87. package/dist/components/SplitButton.mjs +12 -0
  88. package/dist/components/Spotlight.d.mts +1 -1
  89. package/dist/components/SunburstChart.mjs +2 -2
  90. package/dist/components/TagsInput.d.mts +214 -0
  91. package/dist/components/TagsInput.mjs +12 -0
  92. package/dist/components/Timeline.d.mts +1 -1
  93. package/dist/components/Tooltip.d.mts +2 -2
  94. package/dist/components/Tour.d.mts +3 -3
  95. package/dist/components/Tree.d.mts +1 -1
  96. package/dist/components/TreeMapChart.d.mts +1 -1
  97. package/dist/components/TreeMapChart.mjs +2 -2
  98. package/dist/components/TreeSelect.d.mts +51 -0
  99. package/dist/components/TreeSelect.mjs +2 -1
  100. package/dist/components/Upload.d.mts +1 -1
  101. package/dist/components/VirtualTable.d.mts +1 -1
  102. package/dist/components/Watermark.d.mts +1 -1
  103. package/dist/index.d.mts +17 -1
  104. package/dist/index.mjs +356 -0
  105. package/package.json +117 -2
  106. package/dist/{chunk-MAKOSWR6.mjs → chunk-37W7XTA6.mjs} +3 -3
  107. package/dist/{chunk-WUQMFKQ6.mjs → chunk-66OS5A4D.mjs} +3 -3
  108. package/dist/{chunk-NNC75I7F.mjs → chunk-CHEXI7MO.mjs} +3 -3
  109. package/dist/{chunk-KFJIZED5.mjs → chunk-EHGFW5GX.mjs} +3 -3
  110. package/dist/{chunk-ZGA66PSG.mjs → chunk-EZYOCPMM.mjs} +3 -3
  111. package/dist/{chunk-XGXZF27U.mjs → chunk-JHMT5Q6P.mjs} +3 -3
  112. package/dist/{chunk-NGAA73CV.mjs → chunk-VLW3UBIR.mjs} +3 -3
  113. package/dist/{chunk-OTHJIFDV.mjs → chunk-W5XFWVNV.mjs} +3 -3
  114. package/dist/{chunk-3KITFMBJ.mjs → chunk-ZOYHZF4N.mjs} +3 -3
@@ -0,0 +1,337 @@
1
+ import {
2
+ FORM_ITEM_CONTROL_INJECTION_KEY
3
+ } from "./chunk-P2LZ2MR5.mjs";
4
+ import {
5
+ useTigerConfig
6
+ } from "./chunk-UOJOJBEU.mjs";
7
+
8
+ // src/components/InputOTP.ts
9
+ import { computed, defineComponent, h, inject, onMounted, ref, watch } from "vue";
10
+ import {
11
+ applyOtpBackspace,
12
+ applyOtpCharInput,
13
+ applyOtpDelete,
14
+ classNames,
15
+ coerceClassValue,
16
+ devWarn,
17
+ distributeOtpPaste,
18
+ formatOtpSlotLabel,
19
+ getInputOTPLabels,
20
+ getOtpContainerClasses,
21
+ getOtpErrorClasses,
22
+ getOtpSeparatorClasses,
23
+ getOtpSeparatorIndices,
24
+ getOtpSlotClasses,
25
+ injectShakeStyle,
26
+ isOtpComplete,
27
+ mergeStyleValues,
28
+ normalizeOtpValue,
29
+ SHAKE_CLASS
30
+ } from "@expcat/tigercat-core";
31
+ var inputOtpIdCounter = 0;
32
+ var InputOTP = defineComponent({
33
+ name: "TigerInputOTP",
34
+ inheritAttrs: false,
35
+ props: {
36
+ /**
37
+ * Value (for v-model) — the joined characters
38
+ */
39
+ modelValue: { type: String, default: void 0 },
40
+ /**
41
+ * Default value (for uncontrolled mode)
42
+ */
43
+ defaultValue: { type: String, default: "" },
44
+ /**
45
+ * Input size
46
+ * @default 'md'
47
+ */
48
+ size: { type: String, default: "md" },
49
+ /**
50
+ * Validation status
51
+ * @default 'default'
52
+ */
53
+ status: { type: String, default: "default" },
54
+ /**
55
+ * Error message to display
56
+ */
57
+ errorMessage: String,
58
+ /**
59
+ * Number of character slots
60
+ * @default 6
61
+ */
62
+ length: { type: Number, default: 6 },
63
+ /**
64
+ * Allowed character set
65
+ * @default 'numeric'
66
+ */
67
+ type: { type: String, default: "numeric" },
68
+ /**
69
+ * Per-character validation regex; overrides `type` filtering
70
+ */
71
+ pattern: { type: RegExp, default: void 0 },
72
+ /**
73
+ * Hide entered characters (renders maskChar instead)
74
+ */
75
+ masked: Boolean,
76
+ /**
77
+ * Character shown per filled slot when masked
78
+ * @default '•'
79
+ */
80
+ maskChar: { type: String, default: "\u2022" },
81
+ /**
82
+ * Visual slot grouping, e.g. [3, 3]
83
+ */
84
+ groups: { type: Array, default: void 0 },
85
+ /**
86
+ * Separator rendered between groups
87
+ * @default '-'
88
+ */
89
+ separator: { type: String, default: "-" },
90
+ /** Whether the input is disabled */
91
+ disabled: Boolean,
92
+ /** Whether the input is readonly */
93
+ readonly: Boolean,
94
+ /** Whether to autofocus the first empty slot on mount */
95
+ autoFocus: Boolean,
96
+ /** Name for the hidden input carrying the joined value */
97
+ name: String,
98
+ /** Id attribute applied to the group element */
99
+ id: String,
100
+ /** Accessible label for the slot group */
101
+ ariaLabel: String,
102
+ /**
103
+ * Internal shake trigger counter (used by FormItem)
104
+ * @internal
105
+ */
106
+ _shakeTrigger: { type: Number, default: void 0 },
107
+ /** Additional CSS classes */
108
+ className: String,
109
+ /** Inline styles */
110
+ style: { type: Object, default: void 0 }
111
+ },
112
+ emits: {
113
+ "update:modelValue": null,
114
+ complete: null,
115
+ focus: null,
116
+ blur: null
117
+ },
118
+ setup(props, { emit, attrs }) {
119
+ injectShakeStyle();
120
+ const config = useTigerConfig();
121
+ const formItemControl = inject(
122
+ FORM_ITEM_CONTROL_INJECTION_KEY,
123
+ null
124
+ );
125
+ const effectiveStatus = computed(
126
+ () => props.status !== "default" ? props.status : formItemControl?.status.value ?? props.status
127
+ );
128
+ const effectiveErrorMessage = computed(
129
+ () => props.errorMessage ?? formItemControl?.errorMessage.value
130
+ );
131
+ const effectiveShakeTrigger = computed(
132
+ () => props._shakeTrigger ?? formItemControl?.shakeTrigger.value
133
+ );
134
+ const labels = computed(() => getInputOTPLabels(config.value.locale));
135
+ const instanceId = ++inputOtpIdCounter;
136
+ const errorMsgId = `tiger-input-otp-error-${instanceId}`;
137
+ const containerRef = ref(null);
138
+ const slotRefs = ref([]);
139
+ const charOptions = computed(() => ({ type: props.type, pattern: props.pattern }));
140
+ const isControlled = computed(() => props.modelValue !== void 0);
141
+ const innerValue = ref(props.defaultValue ?? "");
142
+ const currentValue = computed(
143
+ () => normalizeOtpValue(
144
+ isControlled.value ? props.modelValue ?? "" : innerValue.value,
145
+ props.length,
146
+ charOptions.value
147
+ )
148
+ );
149
+ const separatorIndices = computed(() => {
150
+ const indices = getOtpSeparatorIndices(props.length, props.groups);
151
+ if (props.groups && props.groups.length > 0 && indices.length === 0) {
152
+ devWarn("InputOTP.groups", "[Tigercat] InputOTP: `groups` must sum to `length`; ignoring.");
153
+ }
154
+ return indices;
155
+ });
156
+ watch([effectiveStatus, effectiveShakeTrigger], ([newStatus]) => {
157
+ if (newStatus === "error" && containerRef.value) {
158
+ const el = containerRef.value;
159
+ el.classList.remove(SHAKE_CLASS);
160
+ void el.offsetWidth;
161
+ el.classList.add(SHAKE_CLASS);
162
+ }
163
+ });
164
+ const focusSlot = (index) => {
165
+ slotRefs.value[Math.max(0, Math.min(index, props.length - 1))]?.focus();
166
+ };
167
+ onMounted(() => {
168
+ if (props.autoFocus) {
169
+ focusSlot(Math.min(currentValue.value.length, props.length - 1));
170
+ }
171
+ });
172
+ const displayChar = (val, index) => {
173
+ const char = val[index] ?? "";
174
+ return char && props.masked ? props.maskChar : char;
175
+ };
176
+ const emitValue = (next) => {
177
+ if (next === currentValue.value) return;
178
+ if (!isControlled.value) innerValue.value = next;
179
+ emit("update:modelValue", next);
180
+ if (isOtpComplete(next, props.length)) emit("complete", next);
181
+ };
182
+ const isInteractive = computed(() => !props.disabled && !props.readonly);
183
+ const handleSlotInput = (index, event) => {
184
+ if (!isInteractive.value) return;
185
+ const target = event.target;
186
+ const result = applyOtpCharInput(
187
+ currentValue.value,
188
+ index,
189
+ target.value,
190
+ props.length,
191
+ charOptions.value
192
+ );
193
+ target.value = displayChar(result.value, index);
194
+ emitValue(result.value);
195
+ focusSlot(result.nextIndex);
196
+ };
197
+ const handleSlotKeydown = (index, event) => {
198
+ if (!isInteractive.value) return;
199
+ switch (event.key) {
200
+ case "Backspace": {
201
+ event.preventDefault();
202
+ const result = applyOtpBackspace(currentValue.value, index);
203
+ emitValue(result.value);
204
+ focusSlot(result.nextIndex);
205
+ break;
206
+ }
207
+ case "Delete": {
208
+ event.preventDefault();
209
+ const result = applyOtpDelete(currentValue.value, index);
210
+ emitValue(result.value);
211
+ break;
212
+ }
213
+ case "ArrowLeft":
214
+ event.preventDefault();
215
+ focusSlot(index - 1);
216
+ break;
217
+ case "ArrowRight":
218
+ event.preventDefault();
219
+ focusSlot(index + 1);
220
+ break;
221
+ case "Home":
222
+ event.preventDefault();
223
+ focusSlot(0);
224
+ break;
225
+ case "End":
226
+ event.preventDefault();
227
+ focusSlot(Math.min(currentValue.value.length, props.length - 1));
228
+ break;
229
+ }
230
+ };
231
+ const handlePaste = (event) => {
232
+ if (!isInteractive.value) return;
233
+ event.preventDefault();
234
+ const text = event.clipboardData?.getData("text") ?? "";
235
+ const result = distributeOtpPaste(text, props.length, charOptions.value);
236
+ if (!result) return;
237
+ emitValue(result.value);
238
+ focusSlot(result.nextIndex);
239
+ };
240
+ const handleSlotFocus = (event) => {
241
+ ;
242
+ event.target.select();
243
+ };
244
+ const containsNode = (node) => node instanceof Node && !!containerRef.value?.contains(node);
245
+ const handleGroupFocusin = (event) => {
246
+ if (!containsNode(event.relatedTarget)) emit("focus", event);
247
+ };
248
+ const handleGroupFocusout = (event) => {
249
+ if (!containsNode(event.relatedTarget)) emit("blur", event);
250
+ };
251
+ return () => {
252
+ const { class: attrClass, style: attrStyle, ...restAttrs } = attrs;
253
+ const activeError = effectiveStatus.value === "error" && !!effectiveErrorMessage.value;
254
+ const slotClasses = getOtpSlotClasses(props.size, effectiveStatus.value, {
255
+ disabled: props.disabled,
256
+ readonly: props.readonly
257
+ });
258
+ const children = [];
259
+ for (let i = 0; i < props.length; i++) {
260
+ children.push(
261
+ h("input", {
262
+ key: `slot-${i}`,
263
+ ref: (el) => {
264
+ slotRefs.value[i] = el;
265
+ },
266
+ class: slotClasses,
267
+ type: "text",
268
+ inputmode: props.type === "numeric" ? "numeric" : void 0,
269
+ autocomplete: i === 0 ? "one-time-code" : "off",
270
+ value: displayChar(currentValue.value, i),
271
+ disabled: props.disabled,
272
+ readonly: props.readonly,
273
+ "aria-label": formatOtpSlotLabel(labels.value.slotLabel, i + 1, props.length),
274
+ ...effectiveStatus.value === "error" ? { "aria-invalid": true } : {},
275
+ onInput: (event) => handleSlotInput(i, event),
276
+ onKeydown: (event) => handleSlotKeydown(i, event),
277
+ onFocus: handleSlotFocus
278
+ })
279
+ );
280
+ if (separatorIndices.value.includes(i) && props.separator) {
281
+ children.push(
282
+ h(
283
+ "span",
284
+ {
285
+ key: `separator-${i}`,
286
+ "aria-hidden": "true",
287
+ class: getOtpSeparatorClasses(props.size)
288
+ },
289
+ props.separator
290
+ )
291
+ );
292
+ }
293
+ }
294
+ if (props.name) {
295
+ children.push(
296
+ h("input", { key: "hidden", type: "hidden", name: props.name, value: currentValue.value })
297
+ );
298
+ }
299
+ const groupNode = h(
300
+ "div",
301
+ {
302
+ ...restAttrs,
303
+ ref: containerRef,
304
+ id: props.id,
305
+ role: "group",
306
+ "aria-label": props.ariaLabel ?? labels.value.groupLabel,
307
+ ...activeError ? { "aria-describedby": errorMsgId } : {},
308
+ class: getOtpContainerClasses(props.size),
309
+ onPaste: handlePaste,
310
+ onFocusin: handleGroupFocusin,
311
+ onFocusout: handleGroupFocusout
312
+ },
313
+ children
314
+ );
315
+ const nodes = [groupNode];
316
+ if (activeError) {
317
+ nodes.push(
318
+ h("div", { id: errorMsgId, class: getOtpErrorClasses() }, effectiveErrorMessage.value)
319
+ );
320
+ }
321
+ return h(
322
+ "div",
323
+ {
324
+ class: classNames("inline-block", props.className, coerceClassValue(attrClass)),
325
+ style: mergeStyleValues(props.style, attrStyle)
326
+ },
327
+ nodes
328
+ );
329
+ };
330
+ }
331
+ });
332
+ var InputOTP_default = InputOTP;
333
+
334
+ export {
335
+ InputOTP,
336
+ InputOTP_default
337
+ };