@snowui-design-system/components 0.3.0-alpha.6 → 0.3.0-alpha.7

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 (74) hide show
  1. package/AGENTS.md +8 -0
  2. package/README.md +19 -3
  3. package/THIRD_PARTY_NOTICES.md +27 -0
  4. package/component-catalog.json +26 -0
  5. package/dist/client/blocks/Sidebar.js +108 -95
  6. package/dist/client/blocks/SidebarItem.js +26 -12
  7. package/dist/client/blocks/SidebarSection.js +3 -1
  8. package/dist/client/components/BarChart.js +9 -2
  9. package/dist/client/components/Breadcrumb.js +10 -6
  10. package/dist/client/components/ChartGroup.js +23 -10
  11. package/dist/client/components/CircularChart.js +8 -1
  12. package/dist/client/components/GaugeChart.js +8 -1
  13. package/dist/client/components/Image.d.ts +2 -0
  14. package/dist/client/components/Image.js +14 -2
  15. package/dist/client/components/Input.js +2 -2
  16. package/dist/client/components/LineChart.js +9 -2
  17. package/dist/client/components/Listbox.js +43 -15
  18. package/dist/client/components/MenuItem.js +7 -1
  19. package/dist/client/components/OTPInput.d.ts +32 -0
  20. package/dist/client/components/OTPInput.js +556 -0
  21. package/dist/client/components/Pagination.js +9 -8
  22. package/dist/client/components/ScrollArea.js +11 -5
  23. package/dist/client/components/SearchBox.js +12 -3
  24. package/dist/client/components/Select.js +3 -1
  25. package/dist/client/components/SidePanel.js +4 -3
  26. package/dist/client/components/Slider.js +7 -3
  27. package/dist/client/components/Spinner.js +9 -2
  28. package/dist/client/components/Tag.js +8 -1
  29. package/dist/client/i18n/messages.d.ts +1 -1
  30. package/dist/client/i18n/messages.js +54 -0
  31. package/dist/client/index.d.ts +3 -0
  32. package/dist/client/index.js +2 -0
  33. package/dist/client/keys.d.ts +1 -0
  34. package/dist/client/keys.js +1 -0
  35. package/dist/client/lib/media-loading.d.ts +7 -0
  36. package/dist/client/lib/media-loading.js +12 -0
  37. package/dist/client/styles/components.css +6 -0
  38. package/dist/client/styles/layout.css +12 -2
  39. package/dist/server/blocks/Sidebar.js +5 -5
  40. package/dist/server/blocks/SidebarItem.js +4 -2
  41. package/dist/server/blocks/SidebarSection.js +3 -1
  42. package/dist/server/components/BarChart.js +5 -2
  43. package/dist/server/components/Breadcrumb.js +5 -2
  44. package/dist/server/components/ChartGroup.js +6 -3
  45. package/dist/server/components/CircularChart.js +4 -1
  46. package/dist/server/components/GaugeChart.js +4 -1
  47. package/dist/server/components/Image.d.ts +2 -0
  48. package/dist/server/components/Image.js +11 -4
  49. package/dist/server/components/Input.js +2 -2
  50. package/dist/server/components/LineChart.js +5 -2
  51. package/dist/server/components/Listbox.js +32 -14
  52. package/dist/server/components/MenuItem.js +4 -1
  53. package/dist/server/components/OTPInput.d.ts +32 -0
  54. package/dist/server/components/OTPInput.js +401 -0
  55. package/dist/server/components/Pagination.js +2 -2
  56. package/dist/server/components/ScrollArea.js +5 -2
  57. package/dist/server/components/SearchBox.js +9 -3
  58. package/dist/server/components/Select.js +3 -1
  59. package/dist/server/components/SidePanel.js +4 -3
  60. package/dist/server/components/Slider.js +7 -3
  61. package/dist/server/components/Spinner.js +4 -2
  62. package/dist/server/components/Tag.js +4 -1
  63. package/dist/server/i18n/messages.d.ts +1 -1
  64. package/dist/server/i18n/messages.js +54 -0
  65. package/dist/server/index.d.ts +3 -0
  66. package/dist/server/index.js +2 -0
  67. package/dist/server/keys.d.ts +1 -0
  68. package/dist/server/keys.js +1 -0
  69. package/dist/server/lib/media-loading.d.ts +7 -0
  70. package/dist/server/lib/media-loading.js +12 -0
  71. package/dist/server/styles/components.css +6 -0
  72. package/dist/server/styles/layout.css +12 -2
  73. package/llms.txt +1 -0
  74. package/package.json +1 -1
@@ -0,0 +1,556 @@
1
+ import 'svelte/internal/disclose-version';
2
+ import * as $ from 'svelte/internal/client';
3
+ import { onDestroy } from "svelte";
4
+ import Text from "./Text.js";
5
+ import { useLocale } from "../i18n/locale.js";
6
+ import { NUMBER_POP_APPEAR_MOTION } from "../motion/presets/effects.js";
7
+ import { TAB_INDICATOR_MOTION_STYLE } from "../motion/presets/tab.js";
8
+ import Frame from "./Frame.js";
9
+ import { splitFrameHostProps } from "../logic/frame-prop-filter.js";
10
+
11
+ var rest_excludes = new Set([
12
+ '$$slots',
13
+ '$$events',
14
+ '$$legacy',
15
+ 'value',
16
+ 'defaultValue',
17
+ 'length',
18
+ 'name',
19
+ 'form',
20
+ 'disabled',
21
+ 'readonly',
22
+ 'required',
23
+ 'autocomplete',
24
+ 'autofocus',
25
+ 'tabindex',
26
+ 'id',
27
+ 'title',
28
+ 'invalid',
29
+ 'error',
30
+ 'enableResponsive',
31
+ 'enableContext',
32
+ 'oncomplete',
33
+ 'oninput',
34
+ 'onchange',
35
+ 'onfocus',
36
+ 'onblur',
37
+ 'onkeydown',
38
+ 'onpaste',
39
+ 'class',
40
+ 'style'
41
+ ]);
42
+
43
+ var root = $.from_html(`<span class="snowui-otp-slot snowui-field-bordered snowui-rounded-rectangle" aria-hidden="true"><!></span>`);
44
+ var root_1 = $.from_html(`<span class="snowui-otp-slots"><input/> <!> <span aria-hidden="true" class="snowui-otp-indicator snowui-field-bordered snowui-rounded-rectangle"></span></span> <!>`, 1);
45
+
46
+ const $$css = {
47
+ hash: 'svelte-qr73h1',
48
+ code: ':where(.snowui-otp-input) {--snowui-otp-input-gap: var(--gap-2);--snowui-otp-input-size: var(--size-10);--snowui-otp-input-radius: var(--radius-4);--snowui-otp-input-font-size: var(--text-16);--snowui-otp-input-line-height: var(--leading-14);position:relative;display:inline-flex;flex-direction:column;align-items:flex-start;gap:var(--gap-2);width:fit-content;max-width:100%;color:var(--black-100, #000000);cursor:text;}:where(.snowui-otp-slots) {position:relative;display:flex;gap:var(--snowui-otp-input-gap-override, var(--snowui-otp-input-gap, var(--gap-2)));}:where(.snowui-otp-slot, .snowui-otp-indicator) {display:grid;place-items:center;width:var(--snowui-otp-input-size-override, var(--snowui-otp-input-size, var(--size-10)));height:var(--snowui-otp-input-size-override, var(--snowui-otp-input-size, var(--size-10)));box-sizing:border-box;border:0;border-radius:var(--snowui-otp-input-radius-override, var(--snowui-otp-input-radius, var(--radius-4)));font-size:var(--snowui-otp-input-font-size-override, var(--snowui-otp-input-font-size, var(--text-16)));line-height:var(--snowui-otp-input-line-height-override, var(--snowui-otp-input-line-height, var(--leading-14)));font-variant-numeric:tabular-nums;}:where(.snowui-otp-slot) {background:var(--surface-1, #ffffffcc);}.snowui-otp-input :where(.snowui-otp-indicator) {position:absolute;left:0;top:0;pointer-events:none;opacity:0;transform:translateX(calc(var(--snowui-otp-input-active-index) * (var(--snowui-otp-input-size-override, var(--snowui-otp-input-size)) + var(--snowui-otp-input-gap-override, var(--snowui-otp-input-gap)))));transition:transform var(--snowui-frame-control-motion-duration) var(--snowui-frame-control-motion-easing), box-shadow var(--snowui-frame-control-motion-duration) var(--snowui-frame-control-motion-easing);}.snowui-otp-input :where(.snowui-otp-indicator[data-field-focus="true"]) {opacity:1;}:where(.snowui-otp-input[data-disabled="true"]) {cursor:not-allowed;opacity:0.4;}:where(.snowui-otp-input[data-readonly="true"]) {cursor:default;}:where(.snowui-otp-input[data-readonly="true"] .snowui-otp-slot) {background:var(--surface-2, #00000008);box-shadow:none;}.snowui-otp-input[data-readonly="true"] :where(.snowui-otp-indicator) {opacity:0;}:where(.snowui-otp-native) {position:absolute;inset:0;z-index:1;width:100%;height:100%;margin:0;padding:0;border:0;opacity:0;cursor:inherit;}\n @media (prefers-reduced-motion: reduce) {.snowui-otp-input :where(.snowui-otp-indicator) {transition:none;}\n }'
49
+ };
50
+
51
+ export default function OTPInput($$anchor, $$props) {
52
+ const instanceId = $.props_id();
53
+
54
+ $.push($$props, true);
55
+ $.append_styles($$anchor, $$css);
56
+
57
+ let value = $.prop($$props, 'value', 15),
58
+ length = $.prop($$props, 'length', 3, 6),
59
+ disabled = $.prop($$props, 'disabled', 3, false),
60
+ readonly = $.prop($$props, 'readonly', 3, false),
61
+ required = $.prop($$props, 'required', 3, false),
62
+ autocomplete = $.prop($$props, 'autocomplete', 3, "one-time-code"),
63
+ invalid = $.prop($$props, 'invalid', 3, false),
64
+ enableResponsive = $.prop($$props, 'enableResponsive', 3, true),
65
+ enableContext = $.prop($$props, 'enableContext', 3, true),
66
+ userClass = $.prop($$props, 'class', 3, ""),
67
+ userStyle = $.prop($$props, 'style', 3, ""),
68
+ rest = $.rest_props($$props, rest_excludes);
69
+
70
+ let inputElement = $.state(void 0);
71
+ const locale = useLocale();
72
+ const errorId = `${instanceId}-error`;
73
+ let focused = $.state(false);
74
+ let hoveredIndex = $.state(void 0);
75
+ let pasteInvalid = $.state(false);
76
+ let errorTimer;
77
+ const resolvedInvalid = $.derived(() => invalid() || $.get(pasteInvalid));
78
+ const errorContent = $.derived(() => $$props.error ?? locale.t("otpInput.invalidCode", { length: length() }));
79
+
80
+ onDestroy(() => {
81
+ if (errorTimer) clearTimeout(errorTimer);
82
+ });
83
+
84
+ let selectionIndex = $.state(0);
85
+ let initialValue = "";
86
+ let initialized = false;
87
+ let lastUserCompletion = "";
88
+ let resetTimer;
89
+ const splitProps = $.derived(() => splitFrameHostProps(rest));
90
+ const frameRestProps = $.derived(() => $.get(splitProps).frameProps);
91
+ const inputRestProps = $.derived(() => $.get(splitProps).hostProps);
92
+ const normalize = (raw) => String(raw ?? "").replace(/\D/g, "").slice(0, length());
93
+ const currentValue = $.derived(() => normalize(value() === undefined ? $$props.defaultValue : value()));
94
+ const digits = $.derived(() => Array.from({ length: length() }, (_, index) => $.get(currentValue)[index] ?? ""));
95
+ const activeIndex = $.derived(() => Math.min($.get(selectionIndex), $.get(currentValue).length, length() - 1));
96
+ const groupLabel = $.derived(() => $.get(inputRestProps)["aria-label"]);
97
+ const groupLabelledby = $.derived(() => $.get(inputRestProps)["aria-labelledby"]);
98
+
99
+ const nativeInputProps = $.derived(() => {
100
+ const {
101
+ "aria-label": _label,
102
+ "aria-labelledby": _labelledby,
103
+ ...props
104
+ } = $.get(inputRestProps);
105
+
106
+ return props;
107
+ });
108
+
109
+ $.user_effect(() => {
110
+ const normalized = $.get(currentValue);
111
+
112
+ if (!initialized) {
113
+ initialValue = normalize($$props.defaultValue ?? normalized);
114
+ initialized = true;
115
+ }
116
+
117
+ if (value() !== normalized) value(normalized);
118
+ if (normalized.length < length()) lastUserCompletion = "";
119
+ });
120
+
121
+ function formReset(node, formId) {
122
+ let active = true;
123
+
124
+ const reset = (event) => {
125
+ if (event.target !== node.form) return;
126
+
127
+ const valueBeforeReset = normalize(node.value);
128
+
129
+ if (resetTimer) clearTimeout(resetTimer);
130
+
131
+ resetTimer = setTimeout(
132
+ () => {
133
+ if (!active) return;
134
+
135
+ value(normalize(event.defaultPrevented ? valueBeforeReset : initialValue));
136
+
137
+ if ($.get(inputElement)) $.get(inputElement).value = value();
138
+
139
+ $.set(selectionIndex, value().length, true);
140
+
141
+ if (!event.defaultPrevented) {
142
+ lastUserCompletion = "";
143
+ clearPasteError();
144
+ }
145
+ },
146
+ 0
147
+ );
148
+ };
149
+
150
+ document.addEventListener("reset", reset, true);
151
+
152
+ return {
153
+ update(nextFormId) {
154
+ formId = nextFormId;
155
+ void formId;
156
+ },
157
+
158
+ destroy() {
159
+ active = false;
160
+ document.removeEventListener("reset", reset, true);
161
+
162
+ if (resetTimer) clearTimeout(resetTimer);
163
+ }
164
+ };
165
+ }
166
+
167
+ function commitFromUser(raw) {
168
+ const next = normalize(raw);
169
+ const previous = $.get(currentValue);
170
+
171
+ value(next);
172
+ $.set(selectionIndex, $.get(inputElement)?.selectionStart ?? next.length, true);
173
+
174
+ if (next.length === length() && next !== previous && next !== lastUserCompletion) {
175
+ lastUserCompletion = next;
176
+ $$props.oncomplete?.(next);
177
+ }
178
+ }
179
+
180
+ function clearPasteError() {
181
+ if (errorTimer) clearTimeout(errorTimer);
182
+
183
+ errorTimer = undefined;
184
+ $.set(pasteInvalid, false);
185
+ }
186
+
187
+ function rejectPaste(clear) {
188
+ if (clear) {
189
+ value("");
190
+
191
+ if ($.get(inputElement)) $.get(inputElement).value = "";
192
+
193
+ moveCaret(0);
194
+ }
195
+
196
+ if (errorTimer) clearTimeout(errorTimer);
197
+
198
+ $.set(pasteInvalid, true);
199
+ errorTimer = setTimeout(clearPasteError, 2000);
200
+ }
201
+
202
+ function moveCaret(index, select = false) {
203
+ const at = Math.max(0, Math.min(index, $.get(currentValue).length, length() - 1));
204
+
205
+ $.set(selectionIndex, at, true);
206
+ $.get(inputElement)?.setSelectionRange(at, select && at < $.get(currentValue).length ? at + 1 : at);
207
+ }
208
+
209
+ function handleInput(event) {
210
+ const target = event.currentTarget;
211
+
212
+ if (disabled() || readonly()) {
213
+ target.value = $.get(currentValue);
214
+
215
+ return;
216
+ }
217
+
218
+ const caret = normalize(target.value.slice(0, target.selectionStart ?? target.value.length)).length;
219
+
220
+ commitFromUser(target.value);
221
+ target.value = normalize(target.value);
222
+
223
+ // Use the accepted digit count, not the raw text length, so filtering cannot skip a slot.
224
+ target.setSelectionRange(caret, caret);
225
+
226
+ $.set(selectionIndex, Math.min(caret, target.value.length, length() - 1), true);
227
+ $$props.oninput?.(event);
228
+ }
229
+
230
+ function handlePaste(event) {
231
+ $$props.onpaste?.(event);
232
+
233
+ if (event.defaultPrevented || disabled() || readonly()) return;
234
+
235
+ event.preventDefault();
236
+
237
+ const pasted = event.clipboardData?.getData("text") ?? "";
238
+ const at = Math.min($.get(selectionIndex), $.get(currentValue).length, length() - 1);
239
+
240
+ if (!(/^[0-9]+$/).test(pasted)) {
241
+ rejectPaste(false);
242
+
243
+ return;
244
+ }
245
+
246
+ let next;
247
+ let caret;
248
+
249
+ if (pasted.length === length()) {
250
+ next = pasted;
251
+ caret = length();
252
+ } else if (at > 0 && pasted.length <= length() - at) {
253
+ // Interior paste may complete or partially fill the remaining contiguous suffix.
254
+ next = $.get(currentValue).slice(0, at) + pasted + $.get(currentValue).slice(at + pasted.length);
255
+
256
+ caret = at + pasted.length;
257
+ } else {
258
+ rejectPaste(at === 0);
259
+
260
+ return;
261
+ }
262
+
263
+ commitFromUser(next);
264
+
265
+ if ($.get(inputElement)) {
266
+ $.get(inputElement).value = next;
267
+ $.get(inputElement).setSelectionRange(caret, caret);
268
+ }
269
+
270
+ $.set(selectionIndex, Math.min(caret, length() - 1), true);
271
+ $$props.oninput?.(event);
272
+ }
273
+
274
+ function pointerIndex(event) {
275
+ const row = event.currentTarget.parentElement;
276
+ const slots = Array.from(row?.querySelectorAll(".snowui-otp-slot") ?? []);
277
+
278
+ return slots.findIndex((slot) => {
279
+ const rect = slot.getBoundingClientRect();
280
+
281
+ return event.clientX >= rect.left && event.clientX <= rect.right;
282
+ });
283
+ }
284
+
285
+ function handlePointerDown(event) {
286
+ if (disabled()) return;
287
+
288
+ event.preventDefault();
289
+
290
+ const index = pointerIndex(event);
291
+
292
+ $.get(inputElement)?.focus();
293
+ moveCaret(index < 0 ? $.get(currentValue).length : index, true);
294
+ }
295
+
296
+ function syncSelection() {
297
+ if (!$.get(inputElement)) return;
298
+
299
+ const index = Math.min($.get(inputElement).selectionStart ?? $.get(currentValue).length, $.get(currentValue).length, length() - 1);
300
+
301
+ $.set(selectionIndex, index, true);
302
+
303
+ // A contiguous prefix is the only editable code; never activate a later empty slot.
304
+ if (($.get(inputElement).selectionStart ?? 0) > $.get(currentValue).length) moveCaret(index);
305
+ }
306
+
307
+ {
308
+ let $0 = $.derived(() => `snowui-otp-input${$.get(resolvedInvalid) ? " snowui-feedback-error-shake" : ""} ${userClass()}`.trim());
309
+ let $1 = $.derived(() => userStyle() || undefined);
310
+ let $2 = $.derived(() => disabled() ? "true" : undefined);
311
+ let $3 = $.derived(() => readonly() ? "true" : undefined);
312
+ let $4 = $.derived(() => $.get(resolvedInvalid) ? "true" : undefined);
313
+ let $5 = $.derived(() => $.get(focused) ? "true" : undefined);
314
+
315
+ Frame($$anchor, $.spread_props(() => $.get(frameRestProps), {
316
+ tag: 'div',
317
+ get class() {
318
+ return $.get($0);
319
+ },
320
+
321
+ get style() {
322
+ return $.get($1);
323
+ },
324
+
325
+ get 'data-disabled'() {
326
+ return $.get($2);
327
+ },
328
+
329
+ get 'data-readonly'() {
330
+ return $.get($3);
331
+ },
332
+
333
+ get 'data-invalid'() {
334
+ return $.get($4);
335
+ },
336
+
337
+ get 'data-focus'() {
338
+ return $.get($5);
339
+ },
340
+ role: 'group',
341
+ get 'aria-label'() {
342
+ return $.get(groupLabel);
343
+ },
344
+
345
+ get 'aria-labelledby'() {
346
+ return $.get(groupLabelledby);
347
+ },
348
+ enableAutoLayout: false,
349
+ get enableResponsive() {
350
+ return enableResponsive();
351
+ },
352
+
353
+ get enableContext() {
354
+ return enableContext();
355
+ },
356
+ enableScaleObserver: false,
357
+ children: ($$anchor, $$slotProps) => {
358
+ var fragment_1 = root_1();
359
+ var span = $.first_child(fragment_1);
360
+ var input = $.child(span);
361
+
362
+ var event_handler = (event) => {
363
+ $.set(focused, true);
364
+ syncSelection();
365
+ $$props.onfocus?.(event);
366
+ };
367
+
368
+ var event_handler_1 = (event) => {
369
+ $.set(focused, false);
370
+ $$props.onblur?.(event);
371
+ };
372
+
373
+ var event_handler_2 = (event) => {
374
+ $$props.onkeydown?.(event);
375
+ queueMicrotask(syncSelection);
376
+ };
377
+
378
+ var event_handler_3 = (event) => {
379
+ const index = pointerIndex(event);
380
+
381
+ $.set(hoveredIndex, index < 0 ? undefined : index, true);
382
+ };
383
+
384
+ var event_handler_4 = () => $.set(hoveredIndex, undefined);
385
+
386
+ $.attribute_effect(
387
+ input,
388
+ ($0) => ({
389
+ ...$.get(nativeInputProps),
390
+ class: 'snowui-otp-native',
391
+ type: 'text',
392
+ value: $.get(currentValue),
393
+ name: $$props.name,
394
+ form: $$props.form,
395
+ disabled: disabled(),
396
+ readonly: readonly(),
397
+ required: required(),
398
+ autocomplete: autocomplete(),
399
+ autofocus: $$props.autofocus,
400
+ tabindex: $$props.tabindex,
401
+ id: $$props.id,
402
+ title: $$props.title,
403
+ 'aria-label': $.get(groupLabel),
404
+ 'aria-labelledby': $.get(groupLabelledby),
405
+ 'aria-describedby': $0,
406
+ inputmode: 'numeric',
407
+ pattern: `[0-9]{${length()}}`,
408
+ minlength: length(),
409
+ 'aria-invalid': $.get(resolvedInvalid) || undefined,
410
+ oninput: handleInput,
411
+ onchange: $$props.onchange,
412
+ onfocus: event_handler,
413
+ onblur: event_handler_1,
414
+ onkeydown: event_handler_2,
415
+ onselect: syncSelection,
416
+ onpointerdown: handlePointerDown,
417
+ onpointermove: event_handler_3,
418
+ onpointerleave: event_handler_4,
419
+ onpaste: handlePaste
420
+ }),
421
+ [
422
+ () => [
423
+ $.get(inputRestProps)["aria-describedby"],
424
+ $.get(resolvedInvalid) ? errorId : undefined
425
+ ].filter(Boolean).join(" ") || undefined
426
+ ],
427
+ void 0,
428
+ void 0,
429
+ void 0,
430
+ true
431
+ );
432
+
433
+ $.action(input, ($$node, $$action_arg) => formReset?.($$node, $$action_arg), () => $$props.form);
434
+ $.bind_this(input, ($$value) => $.set(inputElement, $$value), () => $.get(inputElement));
435
+
436
+ var node_1 = $.sibling(input, 2);
437
+
438
+ $.each(node_1, 17, () => $.get(digits), $.index, ($$anchor, digit, index) => {
439
+ var span_1 = root();
440
+ var node_2 = $.child(span_1);
441
+
442
+ {
443
+ var consequent = ($$anchor) => {
444
+ var fragment_2 = $.comment();
445
+ var node_3 = $.first_child(fragment_2);
446
+
447
+ $.key(node_3, () => $.get(digit), ($$anchor) => {
448
+ Frame($$anchor, {
449
+ tag: 'span',
450
+ class: 'snowui-otp-digit',
451
+ enableAutoLayout: false,
452
+ enableContext: false,
453
+ enableResponsive: false,
454
+ enableScaleObserver: false,
455
+ get whileAppear() {
456
+ return NUMBER_POP_APPEAR_MOTION;
457
+ },
458
+
459
+ children: ($$anchor, $$slotProps) => {
460
+ $.next();
461
+
462
+ var text = $.text();
463
+
464
+ $.template_effect(() => $.set_text(text, $.get(digit)));
465
+ $.append($$anchor, text);
466
+ },
467
+ $$slots: { default: true }
468
+ });
469
+ });
470
+
471
+ $.append($$anchor, fragment_2);
472
+ };
473
+
474
+ $.if(node_2, ($$render) => {
475
+ if ($.get(digit)) $$render(consequent);
476
+ });
477
+ }
478
+
479
+ $.reset(span_1);
480
+
481
+ $.template_effect(() => {
482
+ $.set_attribute(span_1, 'data-active', $.get(focused) && index === $.get(activeIndex) || undefined);
483
+ $.set_attribute(span_1, 'data-field-hover', $.get(hoveredIndex) === index && !disabled() ? "true" : undefined);
484
+ $.set_attribute(span_1, 'data-invalid', $.get(resolvedInvalid) ? "true" : undefined);
485
+ $.set_attribute(span_1, 'data-filled', !!$.get(digit) || undefined);
486
+ });
487
+
488
+ $.append($$anchor, span_1);
489
+ });
490
+
491
+ var span_2 = $.sibling(node_1, 2);
492
+
493
+ $.reset(span);
494
+
495
+ var node_4 = $.sibling(span, 2);
496
+
497
+ {
498
+ var consequent_2 = ($$anchor) => {
499
+ Text($$anchor, {
500
+ get id() {
501
+ return errorId;
502
+ },
503
+ as: 'error',
504
+ role: 'status',
505
+ 'aria-live': 'polite',
506
+ class: 'snowui-field-error-message',
507
+ children: ($$anchor, $$slotProps) => {
508
+ var fragment_6 = $.comment();
509
+ var node_5 = $.first_child(fragment_6);
510
+
511
+ {
512
+ var consequent_1 = ($$anchor) => {
513
+ var fragment_7 = $.comment();
514
+ var node_6 = $.first_child(fragment_7);
515
+
516
+ $.snippet(node_6, () => $.get(errorContent));
517
+ $.append($$anchor, fragment_7);
518
+ };
519
+
520
+ var alternate = ($$anchor) => {
521
+ var text_1 = $.text();
522
+
523
+ $.template_effect(() => $.set_text(text_1, $.get(errorContent)));
524
+ $.append($$anchor, text_1);
525
+ };
526
+
527
+ $.if(node_5, ($$render) => {
528
+ if (typeof $.get(errorContent) === "function") $$render(consequent_1); else $$render(alternate, -1);
529
+ });
530
+ }
531
+
532
+ $.append($$anchor, fragment_6);
533
+ },
534
+ $$slots: { default: true }
535
+ });
536
+ };
537
+
538
+ $.if(node_4, ($$render) => {
539
+ if ($.get(resolvedInvalid)) $$render(consequent_2);
540
+ });
541
+ }
542
+
543
+ $.template_effect(() => {
544
+ $.set_attribute(span_2, 'data-field-focus', $.get(focused) && !disabled() ? "true" : undefined);
545
+ $.set_attribute(span_2, 'data-invalid', $.get(resolvedInvalid) ? "true" : undefined);
546
+ $.set_style(span_2, `${TAB_INDICATOR_MOTION_STYLE}; --snowui-otp-input-active-index: ${$.get(activeIndex)}`);
547
+ });
548
+
549
+ $.append($$anchor, fragment_1);
550
+ },
551
+ $$slots: { default: true }
552
+ }));
553
+ }
554
+
555
+ $.pop();
556
+ }
@@ -58,7 +58,7 @@ export default function Pagination($$anchor, $$props) {
58
58
  total = $.prop($$props, 'total', 3, 1),
59
59
  disabled = $.prop($$props, 'disabled', 3, false),
60
60
  disabledPages = $.prop($$props, 'disabledPages', 19, () => []),
61
- ariaLabel = $.prop($$props, 'ariaLabel', 3, "Pagination"),
61
+ ariaLabel = $.prop($$props, 'ariaLabel', 3, undefined),
62
62
  variant = $.prop($$props, 'variant', 3, "outline"),
63
63
  responsive = $.prop($$props, 'responsive', 3, "auto"),
64
64
  widthMode = $.prop($$props, 'widthMode', 3, "fill"),
@@ -1035,16 +1035,17 @@ export default function Pagination($$anchor, $$props) {
1035
1035
  });
1036
1036
 
1037
1037
  {
1038
- let $0 = $.derived(() => disabled() ? "true" : undefined);
1038
+ let $0 = $.derived(() => ariaLabel() ?? localeContext.t("pagination.navigation"));
1039
+ let $1 = $.derived(() => disabled() ? "true" : undefined);
1039
1040
 
1040
- let $1 = $.derived(() => [
1041
+ let $2 = $.derived(() => [
1041
1042
  "snowui-pagination",
1042
1043
  `snowui-pagination-width-${widthMode()}`,
1043
1044
  $.get(showPageSize) ? "snowui-pagination-has-page-size" : "",
1044
1045
  userClass()
1045
1046
  ].filter(Boolean).join(" "));
1046
1047
 
1047
- let $2 = $.derived(() => userStyle() || undefined);
1048
+ let $3 = $.derived(() => userStyle() || undefined);
1048
1049
 
1049
1050
  Frame($$anchor, $.spread_props(
1050
1051
  {
@@ -1062,11 +1063,11 @@ export default function Pagination($$anchor, $$props) {
1062
1063
  },
1063
1064
  enableAutoLayout: false,
1064
1065
  get 'aria-label'() {
1065
- return ariaLabel();
1066
+ return $.get($0);
1066
1067
  },
1067
1068
 
1068
1069
  get 'data-disabled'() {
1069
- return $.get($0);
1070
+ return $.get($1);
1070
1071
  },
1071
1072
 
1072
1073
  get 'data-responsive'() {
@@ -1078,11 +1079,11 @@ export default function Pagination($$anchor, $$props) {
1078
1079
  },
1079
1080
 
1080
1081
  get class() {
1081
- return $.get($1);
1082
+ return $.get($2);
1082
1083
  },
1083
1084
 
1084
1085
  get style() {
1085
- return $.get($2);
1086
+ return $.get($3);
1086
1087
  },
1087
1088
 
1088
1089
  get renderHints() {
@@ -1,5 +1,6 @@
1
1
  import 'svelte/internal/disclose-version';
2
2
  import * as $ from 'svelte/internal/client';
3
+ import { useLocale } from "../i18n/locale.js";
3
4
  import Frame from "./Frame.js";
4
5
  import { useOverlayScrollbar } from "../lib/overlay-scrollbar.js";
5
6
 
@@ -34,11 +35,13 @@ export default function ScrollArea($$anchor, $$props) {
34
35
  $.push($$props, true);
35
36
  $.append_styles($$anchor, $$css);
36
37
 
38
+ const localeContext = useLocale();
39
+
37
40
  /** 横向滚动条常显,或仅在鼠标移入区域时显示 */
38
41
  let axis = $.prop($$props, 'axis', 3, "vertical"),
39
42
  horizontalTrackPosition = $.prop($$props, 'horizontalTrackPosition', 3, "container"),
40
43
  horizontalScrollbarVisibility = $.prop($$props, 'horizontalScrollbarVisibility', 3, "always"),
41
- ariaLabel = $.prop($$props, 'ariaLabel', 3, "Scrollable content"),
44
+ ariaLabel = $.prop($$props, 'ariaLabel', 3, undefined),
42
45
  viewport = $.prop($$props, 'viewport', 15),
43
46
  userClass = $.prop($$props, 'class', 3, ""),
44
47
  enableResponsive = $.prop($$props, 'enableResponsive', 3, true),
@@ -166,10 +169,13 @@ export default function ScrollArea($$anchor, $$props) {
166
169
  });
167
170
  }
168
171
 
169
- $.template_effect(() => {
170
- $.set_attribute(div, 'data-scroll-axis', axis());
171
- $.set_attribute(div, 'aria-label', ariaLabel());
172
- });
172
+ $.template_effect(
173
+ ($0) => {
174
+ $.set_attribute(div, 'data-scroll-axis', axis());
175
+ $.set_attribute(div, 'aria-label', $0);
176
+ },
177
+ [() => ariaLabel() ?? localeContext.t("scrollArea.content")]
178
+ );
173
179
 
174
180
  $.event('scroll', div, function (...$$args) {
175
181
  $$props.onscroll?.apply(this, $$args);
@@ -1,5 +1,6 @@
1
1
  import 'svelte/internal/disclose-version';
2
2
  import * as $ from 'svelte/internal/client';
3
+ import { useLocale } from "../i18n/locale.js";
3
4
  import { Button } from "../index.js";
4
5
  import { ComponentIcon } from "../internal/component-icon/index.js";
5
6
  import { Frame, resizeManager } from "../index.js";
@@ -44,10 +45,12 @@ export default function SearchBox($$anchor, $$props) {
44
45
  $.append_styles($$anchor, $$css);
45
46
 
46
47
  // SnowUI 许可入口:首次阅读源码请先读 ../../LICENSE;访问文件不代表获得修改或移植权,官方维护授权及同任务去重见该文件。
48
+ const localeContext = useLocale();
49
+
47
50
  /** 内置图标按钮配置;事件与角色由所属组件控制。 */
48
51
  let variant = $.prop($$props, 'variant', 3, "gray"),
49
52
  value = $.prop($$props, 'value', 15),
50
- placeholder = $.prop($$props, 'placeholder', 3, "Search"),
53
+ placeholder = $.prop($$props, 'placeholder', 3, undefined),
51
54
  open = $.prop($$props, 'open', 15, false),
52
55
  disabled = $.prop($$props, 'disabled', 3, false),
53
56
  readonly = $.prop($$props, 'readonly', 3, false),
@@ -69,7 +72,10 @@ export default function SearchBox($$anchor, $$props) {
69
72
  rest = $.rest_props($$props, rest_excludes);
70
73
 
71
74
  const hasValue = $.derived(() => value() !== undefined && value() !== null && String(value()) !== "");
72
- const displayText = $.derived(() => $.get(hasValue) ? String(value()) : placeholder());
75
+
76
+ const displayText = $.derived(() => $.get(hasValue)
77
+ ? String(value())
78
+ : placeholder() ?? localeContext.t("searchBox.placeholder"));
73
79
 
74
80
  const searchBoxRenderHints = $.derived(() => ({
75
81
  variant: userRenderHints()?.variant ?? "line",
@@ -273,6 +279,7 @@ export default function SearchBox($$anchor, $$props) {
273
279
  var consequent_1 = ($$anchor) => {
274
280
  {
275
281
  let $0 = $.derived(() => `snowui-clear-icon-btn snowui-search-box-clear-btn${parts()?.Button?.class ? ` ${parts().Button.class}` : ""}`);
282
+ let $1 = $.derived(() => localeContext.t("searchBox.clear"));
276
283
 
277
284
  Button($$anchor, $.spread_props({ bare: true, emphasis: 'muted', size: 'sm' }, () => parts()?.Button, {
278
285
  type: 'button',
@@ -280,7 +287,9 @@ export default function SearchBox($$anchor, $$props) {
280
287
  return $.get($0);
281
288
  },
282
289
  as: 'trailing',
283
- 'aria-label': '清除搜索内容',
290
+ get 'aria-label'() {
291
+ return $.get($1);
292
+ },
284
293
  onclick: handleClear,
285
294
  onmousedown: (event) => event.preventDefault(),
286
295
  tabindex: -1,