@streamscloud/kit 1.0.2 → 1.0.4

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 (77) hide show
  1. package/README.md +1 -1
  2. package/dist/core/actions/index.d.ts +1 -0
  3. package/dist/core/actions/index.js +1 -0
  4. package/dist/core/actions/stop-click-propagation.d.ts +3 -0
  5. package/dist/core/actions/stop-click-propagation.js +17 -0
  6. package/dist/core/continuation-token.js +1 -8
  7. package/dist/core/event-dispatcher.d.ts +1 -3
  8. package/dist/core/event-dispatcher.js +20 -12
  9. package/dist/core/files/file-service.js +3 -1
  10. package/dist/core/files/file-validator.js +1 -1
  11. package/dist/core/files/files-provider.js +2 -1
  12. package/dist/core/locale/app-locale.svelte.d.ts +2 -1
  13. package/dist/core/locale/app-locale.svelte.js +2 -1
  14. package/dist/core/repository/repository.svelte.js +4 -1
  15. package/dist/core/theme/app-theme.svelte.d.ts +2 -0
  16. package/dist/core/theme/app-theme.svelte.js +2 -0
  17. package/dist/core/utils/after-mount.svelte.d.ts +13 -0
  18. package/dist/core/utils/after-mount.svelte.js +21 -0
  19. package/dist/core/utils/array-helper.js +4 -3
  20. package/dist/core/utils/compact-number.js +1 -0
  21. package/dist/core/utils/date-helper.js +10 -35
  22. package/dist/core/utils/href-validator.js +4 -2
  23. package/dist/core/utils/html-helper.d.ts +2 -0
  24. package/dist/core/utils/html-helper.js +6 -1
  25. package/dist/core/utils/index.d.ts +1 -0
  26. package/dist/core/utils/index.js +1 -0
  27. package/dist/core/utils/string-helper.js +2 -2
  28. package/dist/core/utils/utils.d.ts +4 -2
  29. package/dist/core/utils/utils.js +4 -6
  30. package/dist/core/validation/form-validation-handler/yup-form-validator.d.ts +1 -1
  31. package/dist/core/validation/form-validation-handler/yup-form-validator.js +10 -5
  32. package/dist/core/validation/validation-schemas/email-validation.js +10 -10
  33. package/dist/ui/checkbox/cmp.checkbox.svelte +5 -4
  34. package/dist/ui/date-picker/cmp.date-picker.svelte +13 -2
  35. package/dist/ui/date-picker/cmp.date-picker.svelte.d.ts +1 -1
  36. package/dist/ui/dialog/cmp.dialog-container.svelte +2 -8
  37. package/dist/ui/dialog/dialog-store.svelte.js +1 -0
  38. package/dist/ui/drag-and-drop/cmp.drop-zone.svelte +31 -32
  39. package/dist/ui/drag-and-drop/cmp.drop-zone.svelte.d.ts +16 -21
  40. package/dist/ui/drag-and-drop/cmp.file-drop-zone.svelte +149 -0
  41. package/dist/ui/drag-and-drop/cmp.file-drop-zone.svelte.d.ts +36 -0
  42. package/dist/ui/drag-and-drop/index.d.ts +1 -0
  43. package/dist/ui/drag-and-drop/index.js +1 -0
  44. package/dist/ui/drawer/cmp.drawer.svelte +3 -1
  45. package/dist/ui/drawer/cmp.drawer.svelte.d.ts +3 -1
  46. package/dist/ui/duration/cmp.duration.svelte +7 -3
  47. package/dist/ui/duration/cmp.duration.svelte.d.ts +3 -3
  48. package/dist/ui/empty-state/cmp.empty-state.svelte +5 -5
  49. package/dist/ui/file-uploader/cmp.file-uploader.svelte +4 -4
  50. package/dist/ui/file-uploader/cmp.file-uploader.svelte.d.ts +2 -2
  51. package/dist/ui/grid-card/cmp.grid-card-media.svelte +1 -1
  52. package/dist/ui/grid-card/cmp.grid-card-media.svelte.d.ts +4 -1
  53. package/dist/ui/icon/cmp.icon.svelte +6 -10
  54. package/dist/ui/image/cmp.image.svelte +4 -3
  55. package/dist/ui/infinite-scroll/cmp.infinite-scroll.svelte +2 -2
  56. package/dist/ui/numeral-input/cmp.numeral-input.svelte +3 -0
  57. package/dist/ui/numeral-input/cmp.numeral-input.svelte.d.ts +1 -0
  58. package/dist/ui/pagination/pagination-state.svelte.d.ts +1 -0
  59. package/dist/ui/pagination/pagination-state.svelte.js +1 -0
  60. package/dist/ui/pin-input/cmp.pin-input.svelte +44 -26
  61. package/dist/ui/pin-input/cmp.pin-input.svelte.d.ts +3 -2
  62. package/dist/ui/player/carousel/cmp.carousel.svelte +8 -9
  63. package/dist/ui/player/carousel/cmp.carousel.svelte.d.ts +1 -1
  64. package/dist/ui/radio/cmp.radio.svelte +9 -4
  65. package/dist/ui/rich-text-input/validated-link-button.js +1 -1
  66. package/dist/ui/select/cmp.singleselect-async.svelte +2 -1
  67. package/dist/ui/select/multiselect-base.svelte +2 -1
  68. package/dist/ui/select/select-core.svelte.d.ts +2 -0
  69. package/dist/ui/select/select-core.svelte.js +18 -17
  70. package/dist/ui/slider/cmp.slider.svelte +28 -37
  71. package/dist/ui/slider/cmp.slider.svelte.d.ts +1 -0
  72. package/dist/ui/table/table-cells/table-text-cell.svelte +5 -3
  73. package/dist/ui/time-ago/cmp.time-ago.svelte +10 -1
  74. package/dist/ui/time-ago/cmp.time-ago.svelte.d.ts +1 -1
  75. package/dist/ui/toggle/cmp.toggle.svelte +4 -2
  76. package/dist/ui/video/cmp.video.svelte +6 -5
  77. package/package.json +1 -1
@@ -15,9 +15,9 @@ $effect(() => {
15
15
  const trigger = paginationTrigger;
16
16
  const items = itemsContainer;
17
17
  const intersectionObserver = new IntersectionObserver((e) => {
18
- const [entries] = e;
18
+ const entry = e[e.length - 1];
19
19
  // an armed sentinel over a failing backend retries in a loop — the manual control is the only way on from here
20
- if (entries.isIntersecting && !source.failed) {
20
+ if (entry.isIntersecting && !source.failed) {
21
21
  void onLoadMore();
22
22
  }
23
23
  }, {
@@ -224,6 +224,7 @@ to a different value, that value shows next to the field as `→ 12` (off with `
224
224
  | `--sc-kit--numeral-input--underline-color` | Inset bottom-underline indicator (transparent default, danger on error) | `transparent` |
225
225
  | `--sc-kit--numeral-input--font-size` | Text font size | per size |
226
226
  | `--sc-kit--numeral-input--color` | Text color | `var(--sc-kit--color--text--primary)` |
227
+ | `--sc-kit--numeral-input--text-align` | Text alignment inside the field | `start` |
227
228
  | `--sc-kit--numeral-input--placeholder--color` | Placeholder text color | `var(--sc-kit--color--text--placeholder)` |
228
229
  | `--sc-kit--numeral-input--icon--color` | Leading / trailing icon color (does NOT affect inner affordances) | `var(--sc-kit--color--text--muted)` |
229
230
  | `--sc-kit--numeral-input--icon--size` | Leading / trailing icon size (does NOT affect inner affordances) | per size |
@@ -273,6 +274,7 @@ to a different value, that value shows next to the field as `→ 12` (off with `
273
274
  );
274
275
  --_ni--line-height: var(--_ni--size-line-height, var(--sc-kit--line-height--control--md));
275
276
  --_ni--color: var(--sc-kit--numeral-input--color, var(--sc-kit--color--text--primary));
277
+ --_ni--text-align: var(--sc-kit--numeral-input--text-align, start);
276
278
  --_ni--placeholder-color: var(
277
279
  --sc-kit--numeral-input--placeholder--color,
278
280
  var(--sc-kit--color--text--placeholder)
@@ -376,6 +378,7 @@ to a different value, that value shows next to the field as `→ 12` (off with `
376
378
  font-size: inherit;
377
379
  font-variant-numeric: tabular-nums;
378
380
  line-height: inherit;
381
+ text-align: var(--_ni--text-align);
379
382
  }
380
383
  .numeral-input__el::placeholder {
381
384
  color: var(--_ni--placeholder-color);
@@ -94,6 +94,7 @@ type Props = ClearableProps | RequiredProps;
94
94
  * | `--sc-kit--numeral-input--underline-color` | Inset bottom-underline indicator (transparent default, danger on error) | `transparent` |
95
95
  * | `--sc-kit--numeral-input--font-size` | Text font size | per size |
96
96
  * | `--sc-kit--numeral-input--color` | Text color | `var(--sc-kit--color--text--primary)` |
97
+ * | `--sc-kit--numeral-input--text-align` | Text alignment inside the field | `start` |
97
98
  * | `--sc-kit--numeral-input--placeholder--color` | Placeholder text color | `var(--sc-kit--color--text--placeholder)` |
98
99
  * | `--sc-kit--numeral-input--icon--color` | Leading / trailing icon color (does NOT affect inner affordances) | `var(--sc-kit--color--text--muted)` |
99
100
  * | `--sc-kit--numeral-input--icon--size` | Leading / trailing icon size (does NOT affect inner affordances) | per size |
@@ -9,5 +9,6 @@ export declare class PaginationState {
9
9
  resetPageNumber: () => void;
10
10
  setPageNumber: (pageNumber: number) => void;
11
11
  setPageSize: (pageSize: number) => void;
12
+ /** A `0` past page 1 is ignored — some endpoints return the count with the first page only. Call `reset()` when the filter changes. */
12
13
  setTotal: (total: number) => void;
13
14
  }
@@ -27,6 +27,7 @@ export class PaginationState {
27
27
  this.setPageNumber(1);
28
28
  this._pageSize = pageSize;
29
29
  };
30
+ /** A `0` past page 1 is ignored — some endpoints return the count with the first page only. Call `reset()` when the filter changes. */
30
31
  setTotal = (total) => {
31
32
  if (this._pageNumber === 1 || total > 0) {
32
33
  this._total = total;
@@ -12,37 +12,58 @@ const emit = (next) => {
12
12
  on?.complete?.(next);
13
13
  }
14
14
  };
15
- const writeAt = (idx, ch) => {
16
- const arr = value.padEnd(length, ' ').split('');
17
- arr[idx] = ch || ' ';
18
- return arr.join('').replace(/ +$/, '');
15
+ const selectContent = (cell) => {
16
+ setTimeout(() => cell.setSelectionRange(0, cell.value.length));
17
+ };
18
+ const focusCell = (idx) => {
19
+ const cell = cells[Math.max(0, Math.min(idx, length - 1))];
20
+ if (!cell) {
21
+ return;
22
+ }
23
+ cell.focus();
24
+ selectContent(cell);
25
+ };
26
+ const removeLast = (focusIdx) => {
27
+ emit(value.slice(0, -1));
28
+ focusCell(focusIdx);
19
29
  };
20
30
  const handleInput = (e, idx) => {
21
31
  const target = e.target;
22
32
  const ch = target.value.replace(/[^0-9]/g, '').slice(-1);
23
- target.value = ch;
24
- const next = writeAt(idx, ch);
25
- emit(next);
26
- if (ch && idx < length - 1) {
27
- cells[idx + 1]?.focus();
33
+ if (!ch) {
34
+ const isDeletion = e instanceof InputEvent && e.inputType.startsWith('delete');
35
+ if (isDeletion && idx === value.length - 1) {
36
+ removeLast(idx);
37
+ }
38
+ else {
39
+ target.value = cellValue(idx);
40
+ selectContent(target);
41
+ }
42
+ return;
28
43
  }
44
+ const at = Math.min(idx, value.length);
45
+ target.value = at === idx ? ch : '';
46
+ emit(value.slice(0, at) + ch + value.slice(at + 1));
47
+ focusCell(at + 1);
29
48
  };
30
49
  const handleKeydown = (e, idx) => {
31
- if (e.key === 'Backspace') {
32
- const target = e.target;
33
- if (!target.value && idx > 0) {
34
- cells[idx - 1]?.focus();
50
+ if (e.key === 'Backspace' || e.key === 'Delete') {
51
+ e.preventDefault();
52
+ if (idx === value.length - 1) {
53
+ removeLast(idx);
54
+ }
55
+ else if (e.key === 'Backspace' && idx === value.length && idx > 0) {
56
+ removeLast(idx - 1);
35
57
  }
36
58
  return;
37
59
  }
38
- if (e.key === 'ArrowLeft' && idx > 0) {
60
+ if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
39
61
  e.preventDefault();
40
- cells[idx - 1]?.focus();
62
+ focusCell(e.key === 'ArrowLeft' ? idx - 1 : idx + 1);
41
63
  return;
42
64
  }
43
- if (e.key === 'ArrowRight' && idx < length - 1) {
65
+ if (['ArrowUp', 'ArrowDown', 'Home', 'End'].includes(e.key)) {
44
66
  e.preventDefault();
45
- cells[idx + 1]?.focus();
46
67
  }
47
68
  };
48
69
  const handlePaste = (e) => {
@@ -52,12 +73,7 @@ const handlePaste = (e) => {
52
73
  return;
53
74
  }
54
75
  emit(pasted);
55
- const focusIdx = Math.min(pasted.length, length - 1);
56
- cells[focusIdx]?.focus();
57
- };
58
- const handleFocus = (e) => {
59
- const target = e.target;
60
- setTimeout(() => target.setSelectionRange(0, target.value.length));
76
+ focusCell(pasted.length);
61
77
  };
62
78
  </script>
63
79
 
@@ -85,14 +101,16 @@ const handleFocus = (e) => {
85
101
  oninput={(e) => handleInput(e, i)}
86
102
  onkeydown={(e) => handleKeydown(e, i)}
87
103
  onpaste={handlePaste}
88
- onfocus={handleFocus} />
104
+ onfocus={(e) => selectContent(e.currentTarget)}
105
+ onclick={(e) => selectContent(e.currentTarget)} />
89
106
  {/each}
90
107
  </div>
91
108
 
92
109
  <!--
93
110
  @component
94
- Multi-cell one-time-code input. Auto-advances cursor on entry, backspaces back, supports
95
- paste of the full code, and arrow-key navigation between cells. Numeric-only (forces
111
+ Multi-cell one-time-code input. Auto-advances cursor on entry; a filled cell is always selected, so
112
+ typing replaces its digit; Backspace / Delete erase from the end only. Supports paste of the full
113
+ code and arrow-key navigation between cells. Numeric-only (forces
96
114
  `inputmode="numeric"` + filters non-digits). Set `mask` for sensitive codes (renders cells
97
115
  as `<input type="password">`). Fires `on.complete` when all cells are filled.
98
116
 
@@ -18,8 +18,9 @@ type Props = {
18
18
  };
19
19
  };
20
20
  /**
21
- * Multi-cell one-time-code input. Auto-advances cursor on entry, backspaces back, supports
22
- * paste of the full code, and arrow-key navigation between cells. Numeric-only (forces
21
+ * Multi-cell one-time-code input. Auto-advances cursor on entry; a filled cell is always selected, so
22
+ * typing replaces its digit; Backspace / Delete erase from the end only. Supports paste of the full
23
+ * code and arrow-key navigation between cells. Numeric-only (forces
23
24
  * `inputmode="numeric"` + filters non-digits). Set `mask` for sensitive codes (renders cells
24
25
  * as `<input type="password">`). Fires `on.complete` when all cells are filled.
25
26
  *
@@ -143,9 +143,6 @@ onMount(() => {
143
143
  });
144
144
  });
145
145
  resizeObserver.observe(slidesRef);
146
- if (isBrowser()) {
147
- window.addEventListener(`keydown`, onKeyPress);
148
- }
149
146
  if (wheelNavigation) {
150
147
  wheelAdapter = createWheelAdapter(slidesRef, {
151
148
  axis: 'x',
@@ -157,11 +154,8 @@ onDestroy(() => {
157
154
  if (resizeObserver) {
158
155
  resizeObserver.disconnect();
159
156
  }
160
- if (isBrowser()) {
161
- window.removeEventListener('keydown', onKeyPress);
162
- if (interval) {
163
- window.clearInterval(interval);
164
- }
157
+ if (isBrowser() && interval) {
158
+ window.clearInterval(interval);
165
159
  }
166
160
  wheelAdapter?.destroy();
167
161
  });
@@ -223,8 +217,12 @@ const slidesTranslateX = $derived(swipeTransition ||
223
217
  : 0));
224
218
  </script>
225
219
 
220
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
226
221
  <div
227
222
  class="carousel"
223
+ role="group"
224
+ tabindex="0"
225
+ onkeydown={onKeyPress}
228
226
  class:carousel--arrows-and-dots={mode === 'arrows-and-dots'}
229
227
  class:carousel--arrows-only={mode === 'arrows-only'}
230
228
  class:carousel--dots-only={mode === 'dots-only'}
@@ -311,7 +309,7 @@ const slidesTranslateX = $derived(swipeTransition ||
311
309
 
312
310
  <!--
313
311
  @component
314
- A horizontal slide carousel with infinite looping, touch swipe support, keyboard navigation, and multiple display modes (arrows, dots, counts).
312
+ A horizontal slide carousel with infinite looping, touch swipe support, arrow-key navigation while it has focus, and multiple display modes (arrows, dots, counts).
315
313
 
316
314
  ### CSS Custom Properties
317
315
  | Property | Description | Default |
@@ -374,6 +372,7 @@ A horizontal slide carousel with infinite looping, touch swipe support, keyboard
374
372
  width: 100%;
375
373
  height: 100%;
376
374
  overflow: hidden;
375
+ outline: none;
377
376
  }
378
377
  .carousel:hover {
379
378
  --_carousel--nav-opacity: 1;
@@ -43,7 +43,7 @@ interface $$IsomorphicComponent {
43
43
  z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
44
44
  }
45
45
  /**
46
- * A horizontal slide carousel with infinite looping, touch swipe support, keyboard navigation, and multiple display modes (arrows, dots, counts).
46
+ * A horizontal slide carousel with infinite looping, touch swipe support, arrow-key navigation while it has focus, and multiple display modes (arrows, dots, counts).
47
47
  *
48
48
  * ### CSS Custom Properties
49
49
  * | Property | Description | Default |
@@ -1,9 +1,9 @@
1
- <script lang="ts">import { getFormFieldLabel } from '../_internal/form-field-label-context';
1
+ <script lang="ts">import { stopClickPropagation } from '../../core/actions';
2
+ import { getFormFieldLabel } from '../_internal/form-field-label-context';
2
3
  const { selected, label, disabled = false, title, name, on } = $props();
3
4
  const ariaLabel = $derived(typeof label === 'string' ? label : name);
4
5
  const formFieldLabel = getFormFieldLabel();
5
- const handleClick = (event) => {
6
- event.stopPropagation();
6
+ const handleClick = () => {
7
7
  if (disabled || selected) {
8
8
  return;
9
9
  }
@@ -11,7 +11,12 @@ const handleClick = (event) => {
11
11
  };
12
12
  </script>
13
13
 
14
- <label class="radio" class:radio--on={selected} class:radio--disabled={disabled} title={title}>
14
+ <label
15
+ class="radio"
16
+ class:radio--on={selected}
17
+ class:radio--disabled={disabled}
18
+ title={title}
19
+ use:stopClickPropagation>
15
20
  <button
16
21
  type="button"
17
22
  class="radio__dot"
@@ -69,7 +69,7 @@ export const registerValidatedLink = (editor, loc) => {
69
69
  linkNode.textContent = data.text ?? data.url;
70
70
  }
71
71
  else {
72
- editor.insertContent(`<a href="${data.url}" target="${LINK_TARGET}">${data.text ?? data.url}</a>`);
72
+ editor.insertContent(editor.dom.createHTML('a', { href: data.url, target: LINK_TARGET }, editor.dom.encode(data.text ?? data.url)));
73
73
  }
74
74
  api.close();
75
75
  }
@@ -121,7 +121,8 @@ const showClear = $derived(mode.clearable && hasValue && isInteractive && !core.
121
121
  value={displayValue}
122
122
  onfocus={core.handleFocus}
123
123
  oninput={core.handleInput}
124
- onkeydown={core.handleKeydown} />
124
+ onkeydown={core.handleKeydown}
125
+ onpaste={core.handlePaste} />
125
126
 
126
127
  {#if showClear}
127
128
  <InputClearButton
@@ -261,7 +261,8 @@ const handleDndFinalize = (e) => {
261
261
  value={core.isFiltering ? core.query : ''}
262
262
  onfocus={core.handleFocus}
263
263
  oninput={core.handleInput}
264
- onkeydown={core.handleKeydown} />
264
+ onkeydown={core.handleKeydown}
265
+ onpaste={core.handlePaste} />
265
266
 
266
267
  {#if core.loading}
267
268
  <span
@@ -82,6 +82,8 @@ export type SelectCore<T> = {
82
82
  handleMousedown: (e: MouseEvent) => void;
83
83
  handleInput: (e: Event) => void;
84
84
  handleKeydown: (e: KeyboardEvent) => void;
85
+ /** Starts filtering with the pasted text — the input stays `readonly` until filtering starts, so a native paste would be dropped. */
86
+ handlePaste: (e: ClipboardEvent) => void;
85
87
  openPopover: () => void;
86
88
  closePopover: () => void;
87
89
  pickRow: (row: SelectRow<T>) => void;
@@ -182,17 +182,6 @@ export function createSelectCore(config) {
182
182
  highlight = findSelectedRowIndex();
183
183
  }
184
184
  };
185
- const highlightFirstSelectedAndLoad = () => {
186
- const selected = config.getSelectedOptions()[0];
187
- if (selected) {
188
- const idx = rows.findIndex((r) => r.kind === 'option' && r.option === selected);
189
- highlight = idx >= 0 ? idx : (navigableIndices[0] ?? 0);
190
- }
191
- else {
192
- highlight = navigableIndices[0] ?? 0;
193
- }
194
- void runLoad('');
195
- };
196
185
  const openPopover = () => {
197
186
  if (!config.getInteractive() || isOpen) {
198
187
  return;
@@ -200,12 +189,7 @@ export function createSelectCore(config) {
200
189
  isOpen = true;
201
190
  query = '';
202
191
  isFiltering = false;
203
- if (config.picker === 'single') {
204
- void loadAndHighlightSelected();
205
- }
206
- else {
207
- highlightFirstSelectedAndLoad();
208
- }
192
+ void loadAndHighlightSelected();
209
193
  // Clicks land on the trigger root (div role=presentation) — focus the inner input so the
210
194
  // user can start typing immediately without a second click.
211
195
  config.getInputEl()?.focus();
@@ -224,6 +208,7 @@ export function createSelectCore(config) {
224
208
  isOpen = false;
225
209
  query = '';
226
210
  isFiltering = false;
211
+ debouncedLoad.cancel();
227
212
  cancelInFlightLoad();
228
213
  };
229
214
  const resetFilterKeepFocus = () => {
@@ -235,6 +220,7 @@ export function createSelectCore(config) {
235
220
  highlight = navigableIndices[0] ?? 0;
236
221
  }
237
222
  config.getInputEl()?.focus();
223
+ debouncedLoad.cancel();
238
224
  void runLoad('');
239
225
  };
240
226
  const finishPick = () => {
@@ -339,6 +325,20 @@ export function createSelectCore(config) {
339
325
  moveHighlightByUser(navigableIndices[0] ?? 0);
340
326
  debouncedLoad(query);
341
327
  };
328
+ const handlePaste = (e) => {
329
+ if (!config.getInteractive() || config.getSearchable?.() === false || isFiltering) {
330
+ return;
331
+ }
332
+ const text = e.clipboardData?.getData('text').trim();
333
+ if (!text) {
334
+ return;
335
+ }
336
+ e.preventDefault();
337
+ if (!isOpen) {
338
+ openPopover();
339
+ }
340
+ startFilteringWith(text);
341
+ };
342
342
  const handleKeydown = (e) => {
343
343
  if (!config.getInteractive()) {
344
344
  return;
@@ -425,6 +425,7 @@ export function createSelectCore(config) {
425
425
  handleMousedown,
426
426
  handleInput,
427
427
  handleKeydown,
428
+ handlePaste,
428
429
  openPopover,
429
430
  closePopover,
430
431
  pickRow,
@@ -1,8 +1,13 @@
1
- <script lang="ts">import { claimFormFieldLabel } from '../_internal/form-field-label-context';
2
- let { value, min = 0, max = 100, step = 1, disabled = false, showValue = false, withInput = false, ticks = [], valueSuffix = '', id, on } = $props();
1
+ <script lang="ts">import { claimFormFieldLabel, getFormFieldLabel, resolveAriaLabelledby } from '../_internal/form-field-label-context';
2
+ import { NumeralInput } from '../numeral-input';
3
+ import { untrack } from 'svelte';
4
+ let { value, min = 0, max = 100, step = 1, disabled = false, showValue = false, withInput = false, ticks = [], valueSuffix = '', id, 'aria-label': ariaLabel, on } = $props();
3
5
  const fallbackId = $props.id();
4
6
  const controlId = $derived(id ?? fallbackId);
5
- claimFormFieldLabel(() => controlId);
7
+ const formFieldLabel = getFormFieldLabel();
8
+ if (!untrack(() => withInput)) {
9
+ claimFormFieldLabel(() => controlId);
10
+ }
6
11
  let focused = $state(false);
7
12
  const fillPct = $derived(max === min ? 0 : ((value - min) / (max - min)) * 100);
8
13
  const handleInput = (e) => {
@@ -11,15 +16,7 @@ const handleInput = (e) => {
11
16
  const handleChange = (e) => {
12
17
  on?.change?.(Number(e.currentTarget.value));
13
18
  };
14
- const handleNumeric = (e) => {
15
- const raw = Number(e.currentTarget.value);
16
- if (Number.isNaN(raw)) {
17
- return;
18
- }
19
- const clamped = Math.min(max, Math.max(min, raw));
20
- on?.input?.(clamped);
21
- on?.change?.(clamped);
22
- };
19
+ const stepDecimals = $derived((String(step).split('.')[1] ?? '').length);
23
20
  </script>
24
21
 
25
22
  <div class="slider" class:slider--disabled={disabled}>
@@ -29,6 +26,8 @@ const handleNumeric = (e) => {
29
26
  type="range"
30
27
  class="slider__input"
31
28
  id={controlId}
29
+ aria-label={ariaLabel}
30
+ aria-labelledby={resolveAriaLabelledby(formFieldLabel, ariaLabel, undefined)}
32
31
  min={min}
33
32
  max={max}
34
33
  step={step}
@@ -45,21 +44,25 @@ const handleNumeric = (e) => {
45
44
  <span class="slider__value">{value}{valueSuffix}</span>
46
45
  {/if}
47
46
  {#if withInput}
48
- <input
49
- type="number"
50
- class="slider__numeric"
51
- min={min}
52
- max={max}
53
- step={step}
54
- disabled={disabled}
55
- value={value}
56
- oninput={handleNumeric} />
47
+ <div class="slider__numeric">
48
+ <NumeralInput
49
+ clearable={false}
50
+ value={value}
51
+ min={min}
52
+ max={max}
53
+ decimals={stepDecimals}
54
+ size="sm"
55
+ disabled={disabled}
56
+ hideResolvedValue
57
+ aria-label={ariaLabel}
58
+ on={{ input: (next) => on?.input?.(next), change: (next) => on?.change?.(next) }} />
59
+ </div>
57
60
  {/if}
58
61
  </div>
59
62
 
60
63
  {#if ticks.length}
61
64
  <div class="slider__ticks">
62
- {#each ticks as tick (tick)}
65
+ {#each ticks as tick, i (i)}
63
66
  <span class="slider__tick">{tick}</span>
64
67
  {/each}
65
68
  </div>
@@ -148,21 +151,9 @@ Optionally renders the current value, a numeric input alongside the track, and t
148
151
  text-align: right;
149
152
  }
150
153
  .slider__numeric {
151
- width: 4rem;
152
- height: var(--sc-kit--field--height--sm);
153
- padding: 0 var(--sc-kit--space--2);
154
- text-align: center;
155
- font-size: var(--sc-kit--font-size--sm);
156
- line-height: var(--sc-kit--line-height--control--sm);
157
- font-variant-numeric: tabular-nums;
158
- background: var(--sc-kit--field--background);
159
- border: 1px solid var(--sc-kit--field--border-color);
160
- border-radius: var(--sc-kit--field--border-radius--sm);
161
- color: var(--sc-kit--color--text--primary);
162
- outline: none;
163
- }
164
- .slider__numeric:focus {
165
- border-color: var(--sc-kit--field--border-color--focus);
154
+ --sc-kit--numeral-input--width: 3rem;
155
+ --sc-kit--numeral-input--text-align: center;
156
+ flex: none;
166
157
  }
167
158
  .slider__ticks {
168
159
  display: flex;
@@ -16,6 +16,7 @@ type Props = {
16
16
  /** Suffix appended to the displayed value (e.g. ' %'). @default '' */
17
17
  valueSuffix?: string;
18
18
  id?: string;
19
+ 'aria-label'?: string;
19
20
  on?: {
20
21
  change?: (value: number) => void;
21
22
  input?: (value: number) => void;
@@ -1,4 +1,4 @@
1
- <script lang="ts" generics="T extends {id: string}">import { HtmlHelper, DateHelper } from '../../../core/utils';
1
+ <script lang="ts" generics="T extends {id: string}">import { AfterMount, HtmlHelper, DateHelper } from '../../../core/utils';
2
2
  import { LineClamp } from '../../line-clamp';
3
3
  let { item, column, centered } = $props();
4
4
  const getValueForColumn = (column, item) => (column.valueFactory ? column.valueFactory(item) : item[column.id])?.toString();
@@ -8,6 +8,8 @@ const getDateValueForColumn = (column, item) => {
8
8
  };
9
9
  const dateValue = $derived(getDateValueForColumn(column, item) ?? null);
10
10
  const fmt = (d, options) => new Intl.DateTimeFormat(undefined, options).format(d);
11
+ const strippedHtml = new AfterMount(() => HtmlHelper.stripHtml(value), '');
12
+ const sanitizedHtml = new AfterMount(() => HtmlHelper.sanitizeHtml(value), '');
11
13
  </script>
12
14
 
13
15
  <span class="table-text-cell" class:table-text-cell--centered={centered}>
@@ -19,10 +21,10 @@ const fmt = (d, options) => new Intl.DateTimeFormat(undefined, options).format(d
19
21
  : `${fmt(dateValue, { dateStyle: 'medium' })} ${fmt(dateValue, { timeStyle: 'medium' })}`}
20
22
  {:else if column.format === 'html'}
21
23
  {#if column.maxLines === 'single-line-no-trim'}
22
- <span class="table-text-cell__single-line-no-trim">{HtmlHelper.stripHtml(value)}</span>
24
+ <span class="table-text-cell__single-line-no-trim">{strippedHtml.current}</span>
23
25
  {:else}
24
26
  <LineClamp maxLines={column.maxLines || 1}>
25
- {@html HtmlHelper.sanitizeHtml(value)}
27
+ {@html sanitizedHtml.current}
26
28
  </LineClamp>
27
29
  {/if}
28
30
  {:else if column.maxLines === 'single-line-no-trim'}
@@ -6,7 +6,11 @@ let timeSpan = $state.raw(null);
6
6
  let timeoutId;
7
7
  const setRelativeTime = (d) => {
8
8
  disableTimeout();
9
- const dateVal = d ? DateHelper.toDate(d) : new Date();
9
+ if (!d) {
10
+ timeSpan = null;
11
+ return;
12
+ }
13
+ const dateVal = DateHelper.toDate(d);
10
14
  const formatTime = () => dateVal.toLocaleString(localization.locale, DateFormatOptions.timeFormat);
11
15
  const setupAbsDate = () => {
12
16
  if (absoluteFormat === 'compact') {
@@ -48,6 +52,11 @@ const setRelativeTime = (d) => {
48
52
  refreshIntervalSec = 3600;
49
53
  }
50
54
  else if (diffSeconds < secsIn2Days) {
55
+ const yesterday = new Date();
56
+ yesterday.setDate(yesterday.getDate() - 1);
57
+ if (dateVal.toDateString() !== yesterday.toDateString()) {
58
+ return setupAbsDate();
59
+ }
51
60
  timeSpan = showTime ? localization.yesterdayAt(formatTime()) : localization.yesterday;
52
61
  refreshIntervalSec = 3600;
53
62
  }
@@ -1,6 +1,6 @@
1
1
  import type { AppLocaleValue } from '../../core/locale';
2
2
  type Props = {
3
- /** Date to display relative to now */
3
+ /** Date to display relative to now; `null` renders nothing. */
4
4
  date: Date | string | null;
5
5
  /** Minutes after which absolute date format is used @default 2880 */
6
6
  thresholdMinutes?: number;
@@ -1,4 +1,5 @@
1
- <script lang="ts">import { getFormFieldLabel } from '../_internal/form-field-label-context';
1
+ <script lang="ts">import { stopClickPropagation } from '../../core/actions';
2
+ import { getFormFieldLabel } from '../_internal/form-field-label-context';
2
3
  const { checked, size = 'md', disabled = false, presentational = false, layout = 'spread', label, sublabel, title, name, on } = $props();
3
4
  const hasLabel = $derived(label !== undefined || sublabel !== undefined);
4
5
  const ariaLabel = $derived(typeof label === 'string' ? label : name);
@@ -43,7 +44,8 @@ const handleClick = (event) => {
43
44
  <label
44
45
  class="toggle-row toggle-row--{layout}"
45
46
  class:toggle-row--disabled={disabled}
46
- title={title}>
47
+ title={title}
48
+ use:stopClickPropagation={!presentational}>
47
49
  <span class="toggle-row__text">
48
50
  {#if typeof label === 'string'}
49
51
  <span class="toggle-row__label">{label}</span>
@@ -235,12 +235,13 @@ const notifyProgress = () => {
235
235
  on?.progress?.(percentageCompleted);
236
236
  };
237
237
  const handleSeek = (percent) => {
238
- if (video) {
239
- video.currentTime = video.duration * percent;
240
- percentageCompleted = percent;
241
- notifyProgress();
242
- on?.timeUpdate?.({ id, seconds: video.currentTime });
238
+ if (!video || !Number.isFinite(video.duration)) {
239
+ return;
243
240
  }
241
+ video.currentTime = video.duration * percent;
242
+ percentageCompleted = percent;
243
+ notifyProgress();
244
+ on?.timeUpdate?.({ id, seconds: video.currentTime });
244
245
  };
245
246
  </script>
246
247
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/kit",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",