@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
@@ -1,6 +1,5 @@
1
1
  <script lang="ts" generics="TResult = void, TCancelResult = void, TData = void">import { default as DialogFrame } from './cmp.dialog-frame.svelte';
2
2
  import { Dialogs } from './dialog-store.svelte';
3
- import { untrack } from 'svelte';
4
3
  let { dialog } = $props();
5
4
  const DialogView = $derived(dialog.view);
6
5
  const settings = $derived(dialog.controller.settings);
@@ -9,14 +8,9 @@ $effect(() => {
9
8
  const handleNavigateBack = () => {
10
9
  Dialogs.closeAll();
11
10
  };
12
- const shouldTrack = untrack(() => Dialogs.count() === 1);
13
- if (shouldTrack) {
14
- window.addEventListener('popstate', handleNavigateBack);
15
- }
11
+ window.addEventListener('popstate', handleNavigateBack);
16
12
  return () => {
17
- if (shouldTrack) {
18
- window.removeEventListener('popstate', handleNavigateBack);
19
- }
13
+ window.removeEventListener('popstate', handleNavigateBack);
20
14
  };
21
15
  });
22
16
  </script>
@@ -89,6 +89,7 @@ class DialogStore {
89
89
  return;
90
90
  }
91
91
  this._mounted = [...this._mountedSet];
92
+ this.closeAllIn(containerId);
92
93
  };
93
94
  }
94
95
  const createDialogsSingleton = () => {
@@ -1,11 +1,16 @@
1
1
  <script lang="ts" generics="T">import { DragAndDrop } from './drag-and-drop.svelte';
2
- const { acceptedEvents, disabled, highlightOffset = 0, silent = false, showRejection = false, children, on } = $props();
3
- const dragEvent = $derived.by(() => DragAndDrop.event &&
4
- !disabled &&
5
- (acceptedEvents.includes(DragAndDrop.event.type) || !acceptedEvents.length)
6
- ? DragAndDrop.event
7
- : null);
8
- // A drag is in progress AND this zone refuses it (type not in acceptedEvents). Drives the
2
+ const { acceptedEvents, accepts, disabled, silent = false, showRejection = false, children, on } = $props();
3
+ const dragEvent = $derived.by(() => {
4
+ const event = DragAndDrop.event;
5
+ if (!event || disabled) {
6
+ return null;
7
+ }
8
+ if (acceptedEvents.length && !acceptedEvents.includes(event.type)) {
9
+ return null;
10
+ }
11
+ return !accepts || accepts(event) ? event : null;
12
+ });
13
+ // A drag is in progress AND this zone refuses it (type or `accepts`). Drives the
9
14
  // optional red-shield visual; `on.drop` / `on.enter` still don't fire for rejected drags.
10
15
  const dragRejected = $derived(!!DragAndDrop.event && !disabled && !dragEvent && showRejection);
11
16
  let dragOver = $state(false);
@@ -46,7 +51,6 @@ const onDragLeave = () => {
46
51
  class:drop-zone--drag-over={dragOver && dragEvent && !silent}
47
52
  class:drop-zone--drag-reject={dragOver && dragRejected && !silent}
48
53
  class:drop-zone--disabled={disabled}
49
- style:--_dz--offset="{highlightOffset}px"
50
54
  ondrop={onDrop}
51
55
  ondragover={onDragOver}
52
56
  ondragleave={onDragLeave}
@@ -58,39 +62,33 @@ const onDragLeave = () => {
58
62
 
59
63
  <!--
60
64
  @component
61
- Reactive drop target paired with `DragSource` via the `DragAndDrop` singleton store. When a
62
- source starts dragging a `DragEventModel<T>` whose `type` is listed in `acceptedEvents` (or
63
- when `acceptedEvents` is empty — accept any), the zone activates a dashed-border outline; on
64
- hover (`dragover`) the outline becomes solid and the body fills with the accent tint. The
65
- consumer handles the actual drop via `on.drop`.
66
-
67
- Set `silent` when the host paints its own active / hover visuals; the zone keeps the event
68
- plumbing but skips the built-in chrome. Use `highlightOffset` to outset the dashed border
69
- (e.g. when the host has a rounded background that should remain visible inside the border).
70
- Pass `showRejection` to paint a red shield when the zone is hovered with a drag whose type
71
- isn't in `acceptedEvents` — useful for visible zones where silent inertia could be confusing.
65
+ Drop target for in-app drags, paired with `DragSource` through the `DragAndDrop` singleton store.
66
+ A drag it takes (by `acceptedEvents` and `accepts`) draws a dashed outline that turns solid over an
67
+ info tint on hover, and its payload reaches `on.drop`.
72
68
 
73
69
  ### CSS Custom Properties
74
70
  | Property | Description | Default |
75
71
  |---|---|---|
76
- | `--sc-kit--drop-zone--border-color` | Dashed outline color (active, idle) | `var(--sc-kit--color--accent)` |
77
- | `--sc-kit--drop-zone--border-color--hover` | Solid outline color on dragover | `var(--sc-kit--color--accent)` |
78
- | `--sc-kit--drop-zone--background--hover` | Translucent fill on dragover (overlays content) | `var(--sc-kit--color--accent)` at 12% over transparent |
79
- | `--sc-kit--drop-zone--border-color--reject` | Solid outline color when hovered with a rejected type (requires `showRejection`) | `var(--sc-kit--color--danger)` |
80
- | `--sc-kit--drop-zone--background--reject` | Translucent fill when hovered with a rejected type | `var(--sc-kit--color--danger)` at 12% over transparent |
72
+ | `--sc-kit--drop-zone--border-color` | Dashed outline color (active, idle) | `var(--sc-kit--color--info)` |
73
+ | `--sc-kit--drop-zone--border-color--hover` | Solid outline color on dragover | `var(--sc-kit--color--info)` |
74
+ | `--sc-kit--drop-zone--background--hover` | Translucent fill on dragover (overlays content) | `var(--sc-kit--color--info)` at 12% over transparent |
75
+ | `--sc-kit--drop-zone--border-color--reject` | Solid outline color when hovered with a rejected drag (requires `showRejection`) | `var(--sc-kit--color--danger)` |
76
+ | `--sc-kit--drop-zone--background--reject` | Translucent fill when hovered with a rejected drag | `var(--sc-kit--color--danger)` at 12% over transparent |
77
+ | `--sc-kit--drop-zone--border-width` | Outline width in every state | `2px` |
81
78
  | `--sc-kit--drop-zone--border-radius` | Outline radius | `var(--sc-kit--radius--sm)` |
79
+ | `--sc-kit--drop-zone--inset` | Outline inset from the zone edges; negative values outset it | `0px` |
82
80
  -->
83
81
 
84
82
  <style>.drop-zone {
85
- --_dz--offset: 0px;
86
- --_dz--border-color: var(--sc-kit--drop-zone--border-color, var(--sc-kit--color--accent));
83
+ --_dz--inset: var(--sc-kit--drop-zone--inset, 0px);
84
+ --_dz--border-color: var(--sc-kit--drop-zone--border-color, var(--sc-kit--color--info));
87
85
  --_dz--border-color-hover: var(
88
86
  --sc-kit--drop-zone--border-color--hover,
89
- var(--sc-kit--color--accent)
87
+ var(--sc-kit--color--info)
90
88
  );
91
89
  --_dz--background-hover: var(
92
90
  --sc-kit--drop-zone--background--hover,
93
- color-mix(in srgb, var(--sc-kit--color--accent) 12%, transparent)
91
+ color-mix(in srgb, var(--sc-kit--color--info) 12%, transparent)
94
92
  );
95
93
  --_dz--border-color-reject: var(
96
94
  --sc-kit--drop-zone--border-color--reject,
@@ -100,6 +98,7 @@ isn't in `acceptedEvents` — useful for visible zones where silent inertia coul
100
98
  --sc-kit--drop-zone--background--reject,
101
99
  color-mix(in srgb, var(--sc-kit--color--danger) 12%, transparent)
102
100
  );
101
+ --_dz--border-width: var(--sc-kit--drop-zone--border-width, 2px);
103
102
  --_dz--border-radius: var(--sc-kit--drop-zone--border-radius, var(--sc-kit--radius--sm));
104
103
  width: 100%;
105
104
  height: 100%;
@@ -111,10 +110,10 @@ isn't in `acceptedEvents` — useful for visible zones where silent inertia coul
111
110
  .drop-zone--active::before {
112
111
  content: "";
113
112
  position: absolute;
114
- inset: calc(-1 * var(--_dz--offset));
113
+ inset: var(--_dz--inset);
115
114
  pointer-events: none;
116
115
  box-sizing: border-box;
117
- border: 1px dashed var(--_dz--border-color);
116
+ border: var(--_dz--border-width) dashed var(--_dz--border-color);
118
117
  border-radius: var(--_dz--border-radius);
119
118
  z-index: 2;
120
119
  }
@@ -126,10 +125,10 @@ isn't in `acceptedEvents` — useful for visible zones where silent inertia coul
126
125
  .drop-zone--drag-reject::before {
127
126
  content: "";
128
127
  position: absolute;
129
- inset: calc(-1 * var(--_dz--offset));
128
+ inset: var(--_dz--inset);
130
129
  pointer-events: none;
131
130
  box-sizing: border-box;
132
- border: 1px solid var(--_dz--border-color-reject);
131
+ border: var(--_dz--border-width) solid var(--_dz--border-color-reject);
133
132
  background: var(--_dz--background-reject);
134
133
  border-radius: var(--_dz--border-radius);
135
134
  z-index: 2;
@@ -7,15 +7,16 @@ declare function $$render<T>(): {
7
7
  * `type` field of whatever `DragSource` set on the shared store.
8
8
  */
9
9
  acceptedEvents: string[];
10
+ /** Payload check on top of `acceptedEvents`; `false` refuses the drag exactly like a type mismatch. */
11
+ accepts?: (event: DragEventModel<T>) => boolean;
10
12
  disabled?: boolean;
11
- /** Offset (px) for the dashed-border overlay. Positive values outset, negative inset. @default 0 */
12
- highlightOffset?: number;
13
13
  /** Suppress the built-in dashed-border + fill visual; the host paints its own. */
14
14
  silent?: boolean;
15
15
  /**
16
- * When `true`, the zone paints a red shield on hover if there's a drag in progress whose
17
- * type is NOT in `acceptedEvents`. Useful when the zone is visible and the user might
18
- * think it accepts the dragged item — explicit refusal beats silent inertia. @default false
16
+ * When `true`, the zone paints a red shield on hover if there's a drag in progress it
17
+ * refuses (type not in `acceptedEvents`, or `accepts` returned `false`). Useful when the
18
+ * zone is visible and the user might think it accepts the dragged item — explicit refusal
19
+ * beats silent inertia. @default false
19
20
  */
20
21
  showRejection?: boolean;
21
22
  children?: Snippet;
@@ -45,27 +46,21 @@ interface $$IsomorphicComponent {
45
46
  z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
46
47
  }
47
48
  /**
48
- * Reactive drop target paired with `DragSource` via the `DragAndDrop` singleton store. When a
49
- * source starts dragging a `DragEventModel<T>` whose `type` is listed in `acceptedEvents` (or
50
- * when `acceptedEvents` is empty — accept any), the zone activates a dashed-border outline; on
51
- * hover (`dragover`) the outline becomes solid and the body fills with the accent tint. The
52
- * consumer handles the actual drop via `on.drop`.
53
- *
54
- * Set `silent` when the host paints its own active / hover visuals; the zone keeps the event
55
- * plumbing but skips the built-in chrome. Use `highlightOffset` to outset the dashed border
56
- * (e.g. when the host has a rounded background that should remain visible inside the border).
57
- * Pass `showRejection` to paint a red shield when the zone is hovered with a drag whose type
58
- * isn't in `acceptedEvents` — useful for visible zones where silent inertia could be confusing.
49
+ * Drop target for in-app drags, paired with `DragSource` through the `DragAndDrop` singleton store.
50
+ * A drag it takes (by `acceptedEvents` and `accepts`) draws a dashed outline that turns solid over an
51
+ * info tint on hover, and its payload reaches `on.drop`.
59
52
  *
60
53
  * ### CSS Custom Properties
61
54
  * | Property | Description | Default |
62
55
  * |---|---|---|
63
- * | `--sc-kit--drop-zone--border-color` | Dashed outline color (active, idle) | `var(--sc-kit--color--accent)` |
64
- * | `--sc-kit--drop-zone--border-color--hover` | Solid outline color on dragover | `var(--sc-kit--color--accent)` |
65
- * | `--sc-kit--drop-zone--background--hover` | Translucent fill on dragover (overlays content) | `var(--sc-kit--color--accent)` at 12% over transparent |
66
- * | `--sc-kit--drop-zone--border-color--reject` | Solid outline color when hovered with a rejected type (requires `showRejection`) | `var(--sc-kit--color--danger)` |
67
- * | `--sc-kit--drop-zone--background--reject` | Translucent fill when hovered with a rejected type | `var(--sc-kit--color--danger)` at 12% over transparent |
56
+ * | `--sc-kit--drop-zone--border-color` | Dashed outline color (active, idle) | `var(--sc-kit--color--info)` |
57
+ * | `--sc-kit--drop-zone--border-color--hover` | Solid outline color on dragover | `var(--sc-kit--color--info)` |
58
+ * | `--sc-kit--drop-zone--background--hover` | Translucent fill on dragover (overlays content) | `var(--sc-kit--color--info)` at 12% over transparent |
59
+ * | `--sc-kit--drop-zone--border-color--reject` | Solid outline color when hovered with a rejected drag (requires `showRejection`) | `var(--sc-kit--color--danger)` |
60
+ * | `--sc-kit--drop-zone--background--reject` | Translucent fill when hovered with a rejected drag | `var(--sc-kit--color--danger)` at 12% over transparent |
61
+ * | `--sc-kit--drop-zone--border-width` | Outline width in every state | `2px` |
68
62
  * | `--sc-kit--drop-zone--border-radius` | Outline radius | `var(--sc-kit--radius--sm)` |
63
+ * | `--sc-kit--drop-zone--inset` | Outline inset from the zone edges; negative values outset it | `0px` |
69
64
  */
70
65
  declare const Cmp: $$IsomorphicComponent;
71
66
  type Cmp<T> = InstanceType<typeof Cmp<T>>;
@@ -0,0 +1,149 @@
1
+ <script lang="ts">import { matchesAcceptedFileTypes } from '../../core/files';
2
+ const { accept = '', refused = false, disabled = false, hint, children, on } = $props();
3
+ let rootRef = $state();
4
+ let verdict = $state(null);
5
+ const isFileDrag = (e) => !!e.dataTransfer?.types.includes('Files');
6
+ const isOverNestedZone = (e) => {
7
+ const element = e.target instanceof Text ? e.target.parentElement : e.target;
8
+ return !(element instanceof Element) || element.closest('[data-file-drop-zone]') !== rootRef;
9
+ };
10
+ // An extension token can't be checked before the drop: the browser hides file names until then.
11
+ const acceptsType = (type) => !type ||
12
+ accept.split(',').some((token) => token.trim().startsWith('.')) ||
13
+ matchesAcceptedFileTypes(new File([], '', { type }), accept);
14
+ const evaluate = (dataTransfer) => {
15
+ if (refused) {
16
+ return 'reject';
17
+ }
18
+ const types = [...dataTransfer.items]
19
+ .filter((item) => item.kind === 'file')
20
+ .map((item) => item.type);
21
+ if (!types.length) {
22
+ return null;
23
+ }
24
+ return types.some(acceptsType) ? 'accept' : 'reject';
25
+ };
26
+ const onDragOver = (e) => {
27
+ if (!isFileDrag(e) || !e.dataTransfer) {
28
+ return;
29
+ }
30
+ if (isOverNestedZone(e)) {
31
+ verdict = null;
32
+ return;
33
+ }
34
+ e.preventDefault();
35
+ e.stopPropagation();
36
+ verdict = disabled ? null : (evaluate(e.dataTransfer) ?? verdict ?? 'accept');
37
+ e.dataTransfer.dropEffect = verdict === 'accept' ? 'copy' : 'none';
38
+ };
39
+ const onDragLeave = (e) => {
40
+ if (!(e.relatedTarget instanceof Node) || !rootRef?.contains(e.relatedTarget)) {
41
+ verdict = null;
42
+ }
43
+ };
44
+ const onDrop = (e) => {
45
+ if (!isFileDrag(e)) {
46
+ return;
47
+ }
48
+ verdict = null;
49
+ if (isOverNestedZone(e)) {
50
+ return;
51
+ }
52
+ e.preventDefault();
53
+ e.stopPropagation();
54
+ if (disabled || refused) {
55
+ return;
56
+ }
57
+ const files = [...(e.dataTransfer?.files ?? [])];
58
+ const accepted = files.filter((file) => matchesAcceptedFileTypes(file, accept));
59
+ const rejected = files.filter((file) => !accepted.includes(file));
60
+ if (accepted.length) {
61
+ on.drop(accepted);
62
+ }
63
+ if (rejected.length) {
64
+ on.reject?.(rejected);
65
+ }
66
+ };
67
+ </script>
68
+
69
+ <div
70
+ class="file-drop-zone"
71
+ class:file-drop-zone--active={verdict !== null}
72
+ data-file-drop-zone
73
+ bind:this={rootRef}
74
+ ondragovercapture={onDragOver}
75
+ ondragleave={onDragLeave}
76
+ ondropcapture={onDrop}
77
+ role="none">
78
+ {@render children()}
79
+ {#if verdict}
80
+ <div
81
+ class="file-drop-zone__shield"
82
+ class:file-drop-zone__shield--rejected={verdict === 'reject'}>
83
+ {#if hint}
84
+ <div class="file-drop-zone__hint">{@render hint({ rejected: verdict === 'reject' })}</div>
85
+ {/if}
86
+ </div>
87
+ {/if}
88
+ </div>
89
+
90
+ <!--
91
+ @component
92
+ Drop target for files dragged in from the OS: hovering files paint an info shield when they match
93
+ `accept` and a danger one otherwise, and `on.drop` receives only the matching files (the rest go to `on.reject`). A file drop never
94
+ reaches the browser, in-app drags pass through untouched, and of nested zones the innermost takes the
95
+ files.
96
+
97
+ ### CSS Custom Properties
98
+ | Property | Description | Default |
99
+ |---|---|---|
100
+ | `--sc-kit--file-drop-zone--color` | Outline and shield color for accepted files | `var(--sc-kit--color--info)` |
101
+ | `--sc-kit--file-drop-zone--color--reject` | Outline and shield color for rejected files | `var(--sc-kit--color--danger)` |
102
+ | `--sc-kit--file-drop-zone--border-width` | Shield outline width | `2px` |
103
+ | `--sc-kit--file-drop-zone--border-radius` | Shield radius | `var(--sc-kit--radius--sm)` |
104
+ | `--sc-kit--file-drop-zone--inset` | Shield inset from the zone edges | `0px` |
105
+ -->
106
+
107
+ <style>.file-drop-zone {
108
+ --_fdz--color: var(--sc-kit--file-drop-zone--color, var(--sc-kit--color--info));
109
+ --_fdz--color-reject: var(
110
+ --sc-kit--file-drop-zone--color--reject,
111
+ var(--sc-kit--color--danger)
112
+ );
113
+ --_fdz--border-width: var(--sc-kit--file-drop-zone--border-width, 2px);
114
+ --_fdz--border-radius: var(--sc-kit--file-drop-zone--border-radius, var(--sc-kit--radius--sm));
115
+ --_fdz--inset: var(--sc-kit--file-drop-zone--inset, 0px);
116
+ position: relative;
117
+ width: 100%;
118
+ height: 100%;
119
+ }
120
+ .file-drop-zone--active {
121
+ isolation: isolate;
122
+ }
123
+ .file-drop-zone__shield {
124
+ --_fdz--shield-color: var(--_fdz--color);
125
+ position: absolute;
126
+ inset: var(--_fdz--inset);
127
+ z-index: 2;
128
+ display: flex;
129
+ flex-direction: column;
130
+ justify-content: center;
131
+ pointer-events: none;
132
+ border: var(--_fdz--border-width) solid var(--_fdz--shield-color);
133
+ border-radius: var(--_fdz--border-radius);
134
+ background: color-mix(in srgb, var(--_fdz--shield-color) 12%, transparent);
135
+ }
136
+ .file-drop-zone__shield--rejected {
137
+ --_fdz--shield-color: var(--_fdz--color-reject);
138
+ }
139
+ .file-drop-zone__hint {
140
+ position: sticky;
141
+ inset-block: var(--sc-kit--space--4);
142
+ inline-size: fit-content;
143
+ max-inline-size: calc(100% - 2 * var(--sc-kit--space--2));
144
+ margin-inline: auto;
145
+ padding: var(--sc-kit--space--2) var(--sc-kit--space--4);
146
+ background: var(--sc-kit--color--bg--element);
147
+ border-radius: var(--sc-kit--radius--md);
148
+ box-shadow: var(--sc-kit--shadow--md);
149
+ }</style>
@@ -0,0 +1,36 @@
1
+ import type { Snippet } from 'svelte';
2
+ type Props = {
3
+ /** Like `<input accept>`; `''` takes any file. @default '' */
4
+ accept?: string;
5
+ /** Files hovering the zone are shown as rejected and can't be dropped (e.g. while busy). */
6
+ refused?: boolean;
7
+ disabled?: boolean;
8
+ /** Content centered in the shield while files hover the zone. */
9
+ hint?: Snippet<[{
10
+ rejected: boolean;
11
+ }]>;
12
+ children: Snippet;
13
+ on: {
14
+ drop: (files: File[]) => void;
15
+ /** Dropped files that don't match `accept`; they never reach `drop`. */
16
+ reject?: (files: File[]) => void;
17
+ };
18
+ };
19
+ /**
20
+ * Drop target for files dragged in from the OS: hovering files paint an info shield when they match
21
+ * `accept` and a danger one otherwise, and `on.drop` receives only the matching files (the rest go to `on.reject`). A file drop never
22
+ * reaches the browser, in-app drags pass through untouched, and of nested zones the innermost takes the
23
+ * files.
24
+ *
25
+ * ### CSS Custom Properties
26
+ * | Property | Description | Default |
27
+ * |---|---|---|
28
+ * | `--sc-kit--file-drop-zone--color` | Outline and shield color for accepted files | `var(--sc-kit--color--info)` |
29
+ * | `--sc-kit--file-drop-zone--color--reject` | Outline and shield color for rejected files | `var(--sc-kit--color--danger)` |
30
+ * | `--sc-kit--file-drop-zone--border-width` | Shield outline width | `2px` |
31
+ * | `--sc-kit--file-drop-zone--border-radius` | Shield radius | `var(--sc-kit--radius--sm)` |
32
+ * | `--sc-kit--file-drop-zone--inset` | Shield inset from the zone edges | `0px` |
33
+ */
34
+ declare const Cmp: import("svelte").Component<Props, {}, "">;
35
+ type Cmp = ReturnType<typeof Cmp>;
36
+ export default Cmp;
@@ -2,3 +2,4 @@ export type { DragEventModel } from './types';
2
2
  export { DragAndDrop } from './drag-and-drop.svelte';
3
3
  export { default as DragSource } from './cmp.drag-source.svelte';
4
4
  export { default as DropZone } from './cmp.drop-zone.svelte';
5
+ export { default as FileDropZone } from './cmp.file-drop-zone.svelte';
@@ -1,3 +1,4 @@
1
1
  export { DragAndDrop } from './drag-and-drop.svelte';
2
2
  export { default as DragSource } from './cmp.drag-source.svelte';
3
3
  export { default as DropZone } from './cmp.drop-zone.svelte';
4
+ export { default as FileDropZone } from './cmp.file-drop-zone.svelte';
@@ -32,5 +32,7 @@ $effect(() => () => untrack(() => closeDrawer()));
32
32
  Drawer — declarative side sheet. A thin wrapper over the imperative `openDrawer` that bridges a
33
33
  controlled `open` prop to the kit Dialog engine: when `open` is `true` it opens the drawer (rendering
34
34
  the default slot as the body and the `footer` snippet as the footer), and closes it otherwise. Singleton —
35
- only one drawer shows at a time. Wire `on.close` to set `open` back to `false` when the user dismisses it.
35
+ only one drawer shows at a time, and any `Drawer` that mounts with `open={false}`, turns `false` or unmounts
36
+ closes whichever drawer is open, so keep one `Drawer` per screen. Wire `on.close` to set `open` back to
37
+ `false` when the user dismisses it.
36
38
  -->
@@ -22,7 +22,9 @@ type Props = {
22
22
  * Drawer — declarative side sheet. A thin wrapper over the imperative `openDrawer` that bridges a
23
23
  * controlled `open` prop to the kit Dialog engine: when `open` is `true` it opens the drawer (rendering
24
24
  * the default slot as the body and the `footer` snippet as the footer), and closes it otherwise. Singleton —
25
- * only one drawer shows at a time. Wire `on.close` to set `open` back to `false` when the user dismisses it.
25
+ * only one drawer shows at a time, and any `Drawer` that mounts with `open={false}`, turns `false` or unmounts
26
+ * closes whichever drawer is open, so keep one `Drawer` per screen. Wire `on.close` to set `open` back to
27
+ * `false` when the user dismisses it.
26
28
  */
27
29
  declare const Cmp: import("svelte").Component<Props, {}, "">;
28
30
  type Cmp = ReturnType<typeof Cmp>;
@@ -7,7 +7,11 @@ const format = (secs) => {
7
7
  const ss = (total % 60).toString().padStart(2, '0');
8
8
  return hours > 0 ? `${hours}:${minutes.toString().padStart(2, '0')}:${ss}` : `${minutes}:${ss}`;
9
9
  };
10
- const value = $derived(seconds !== null && seconds > 0 ? format(seconds) : showZero ? format(0) : null);
10
+ const value = $derived(seconds !== null && Number.isFinite(seconds) && seconds > 0
11
+ ? format(seconds)
12
+ : showZero
13
+ ? format(0)
14
+ : null);
11
15
  </script>
12
16
 
13
17
  {#if value !== null}
@@ -17,8 +21,8 @@ const value = $derived(seconds !== null && seconds > 0 ? format(seconds) : showZ
17
21
  <!--
18
22
  @component
19
23
  Renders a media/time duration given in seconds as a human-readable clock string — `m:ss` under an
20
- hour, `h:mm:ss` at or above (seconds are rounded, so a 60-second carry rolls up). `null` or ≤ 0
21
- renders nothing; pass `showZero` to force `0:00`. `variant='raw'` (default) is bare text that
24
+ hour, `h:mm:ss` at or above (seconds are rounded, so a 60-second carry rolls up). `null`, ≤ 0 or
25
+ non-finite renders nothing; pass `showZero` to force `0:00`. `variant='raw'` (default) is bare text that
22
26
  inherits the parent's typography; `variant='badge'` is a dark overlay pill for the bottom corner of
23
27
  a video thumbnail. Placement (e.g. absolute over media) is the consumer's job via the cascade.
24
28
 
@@ -1,5 +1,5 @@
1
1
  type Props = {
2
- /** Duration in seconds. Zero, negative, or `null` renders nothing unless `showZero`. */
2
+ /** Duration in seconds. Zero, negative, non-finite or `null` renders nothing unless `showZero`. */
3
3
  seconds: number | null;
4
4
  /** Visual style — `raw` is bare text; `badge` is a dark overlay pill for media thumbnails. @default 'raw' */
5
5
  variant?: 'raw' | 'badge';
@@ -8,8 +8,8 @@ type Props = {
8
8
  };
9
9
  /**
10
10
  * Renders a media/time duration given in seconds as a human-readable clock string — `m:ss` under an
11
- * hour, `h:mm:ss` at or above (seconds are rounded, so a 60-second carry rolls up). `null` or ≤ 0
12
- * renders nothing; pass `showZero` to force `0:00`. `variant='raw'` (default) is bare text that
11
+ * hour, `h:mm:ss` at or above (seconds are rounded, so a 60-second carry rolls up). `null`, ≤ 0 or
12
+ * non-finite renders nothing; pass `showZero` to force `0:00`. `variant='raw'` (default) is bare text that
13
13
  * inherits the parent's typography; `variant='badge'` is a dark overlay pill for the bottom corner of
14
14
  * a video thumbnail. Placement (e.g. absolute over media) is the consumer's job via the cascade.
15
15
  *
@@ -1,4 +1,4 @@
1
- <script lang="ts">import { HtmlHelper } from '../../core/utils';
1
+ <script lang="ts">import { AfterMount, HtmlHelper } from '../../core/utils';
2
2
  import DefaultGraphic from './zero-content.svg?raw';
3
3
  const GRAPHIC_PRESETS = {
4
4
  'zero-content': DefaultGraphic
@@ -6,8 +6,8 @@ const GRAPHIC_PRESETS = {
6
6
  let { graphic, title, description, action, layout = 'default' } = $props();
7
7
  const graphicPreset = $derived(typeof graphic === 'string' ? graphic : null);
8
8
  const graphicSnippet = $derived(typeof graphic === 'function' ? graphic : null);
9
- const sanitizedTitle = $derived(title ? HtmlHelper.sanitizeHtml(title) : '');
10
- const sanitizedDescription = $derived(description ? HtmlHelper.sanitizeHtml(description) : '');
9
+ const sanitizedTitle = new AfterMount(() => (title ? HtmlHelper.sanitizeHtml(title) : ''), '');
10
+ const sanitizedDescription = new AfterMount(() => (description ? HtmlHelper.sanitizeHtml(description) : ''), '');
11
11
  </script>
12
12
 
13
13
  <div class="empty-state empty-state--{layout}">
@@ -20,10 +20,10 @@ const sanitizedDescription = $derived(description ? HtmlHelper.sanitizeHtml(desc
20
20
  </div>
21
21
  {/if}
22
22
  {#if title}
23
- <h3 class="empty-state__title">{@html sanitizedTitle}</h3>
23
+ <h3 class="empty-state__title">{@html sanitizedTitle.current}</h3>
24
24
  {/if}
25
25
  {#if description}
26
- <p class="empty-state__description">{@html sanitizedDescription}</p>
26
+ <p class="empty-state__description">{@html sanitizedDescription.current}</p>
27
27
  {/if}
28
28
  {#if action}
29
29
  <div class="empty-state__action">{@render action()}</div>
@@ -132,10 +132,10 @@ via `DataTransfer.items` — extension-only accept tokens defer to drop).
132
132
  | Property | Description | Default |
133
133
  |---|---|---|
134
134
  | `--sc-kit--file-uploader--background` | Drop-zone background | `var(--sc-kit--color--bg--subtle)` |
135
- | `--sc-kit--file-uploader--background--drag` | Background during valid drag-over / hover | `var(--sc-kit--color--accent--softer)` |
135
+ | `--sc-kit--file-uploader--background--drag` | Background during valid drag-over / hover | `var(--sc-kit--color--info--soft)` |
136
136
  | `--sc-kit--file-uploader--background--drag-invalid` | Background when a dragged file's MIME does not match the Mime rule | `var(--sc-kit--color--danger--soft)` |
137
137
  | `--sc-kit--file-uploader--border-color` | Dashed border color (idle) | `var(--sc-kit--color--border--strong)` |
138
- | `--sc-kit--file-uploader--border-color--drag` | Dashed border color during valid drag-over / hover | `var(--sc-kit--color--accent)` |
138
+ | `--sc-kit--file-uploader--border-color--drag` | Dashed border color during valid drag-over / hover | `var(--sc-kit--color--info)` |
139
139
  | `--sc-kit--file-uploader--border-color--drag-invalid` | Dashed border color when dragged file's MIME does not match the Mime rule | `var(--sc-kit--color--danger)` |
140
140
  | `--sc-kit--file-uploader--border-radius` | Drop-zone radius | `var(--sc-kit--radius--lg)` |
141
141
  | `--sc-kit--file-uploader--padding` | Inner padding | `var(--sc-kit--space--6)` |
@@ -152,7 +152,7 @@ via `DataTransfer.items` — extension-only accept tokens defer to drop).
152
152
  --_fu--background: var(--sc-kit--file-uploader--background, var(--sc-kit--color--bg--subtle));
153
153
  --_fu--background-drag: var(
154
154
  --sc-kit--file-uploader--background--drag,
155
- var(--sc-kit--color--accent--softer)
155
+ var(--sc-kit--color--info--soft)
156
156
  );
157
157
  --_fu--background-drag-invalid: var(
158
158
  --sc-kit--file-uploader--background--drag-invalid,
@@ -164,7 +164,7 @@ via `DataTransfer.items` — extension-only accept tokens defer to drop).
164
164
  );
165
165
  --_fu--border-color-drag: var(
166
166
  --sc-kit--file-uploader--border-color--drag,
167
- var(--sc-kit--color--accent)
167
+ var(--sc-kit--color--info)
168
168
  );
169
169
  --_fu--border-color-drag-invalid: var(
170
170
  --sc-kit--file-uploader--border-color--drag-invalid,
@@ -43,10 +43,10 @@ type Props = {
43
43
  * | Property | Description | Default |
44
44
  * |---|---|---|
45
45
  * | `--sc-kit--file-uploader--background` | Drop-zone background | `var(--sc-kit--color--bg--subtle)` |
46
- * | `--sc-kit--file-uploader--background--drag` | Background during valid drag-over / hover | `var(--sc-kit--color--accent--softer)` |
46
+ * | `--sc-kit--file-uploader--background--drag` | Background during valid drag-over / hover | `var(--sc-kit--color--info--soft)` |
47
47
  * | `--sc-kit--file-uploader--background--drag-invalid` | Background when a dragged file's MIME does not match the Mime rule | `var(--sc-kit--color--danger--soft)` |
48
48
  * | `--sc-kit--file-uploader--border-color` | Dashed border color (idle) | `var(--sc-kit--color--border--strong)` |
49
- * | `--sc-kit--file-uploader--border-color--drag` | Dashed border color during valid drag-over / hover | `var(--sc-kit--color--accent)` |
49
+ * | `--sc-kit--file-uploader--border-color--drag` | Dashed border color during valid drag-over / hover | `var(--sc-kit--color--info)` |
50
50
  * | `--sc-kit--file-uploader--border-color--drag-invalid` | Dashed border color when dragged file's MIME does not match the Mime rule | `var(--sc-kit--color--danger)` |
51
51
  * | `--sc-kit--file-uploader--border-radius` | Drop-zone radius | `var(--sc-kit--radius--lg)` |
52
52
  * | `--sc-kit--file-uploader--padding` | Inner padding | `var(--sc-kit--space--6)` |
@@ -101,7 +101,7 @@ const onCarouselIndexChanged = (index) => {
101
101
  </div>
102
102
  {/if}
103
103
 
104
- {#if duration}
104
+ {#if duration && !isCurrentPlayable}
105
105
  <span class="grid-card-media__duration-anchor">
106
106
  <Duration seconds={duration} variant="badge" />
107
107
  </span>
@@ -13,7 +13,10 @@ type Props = {
13
13
  objectFit?: ObjectFit;
14
14
  /** @default true */
15
15
  showSeekBar?: boolean;
16
- /** Duration in seconds; rendered as a badge overlay at the bottom-right of the media. `≤ 0` / `undefined` renders nothing. */
16
+ /**
17
+ * Duration in seconds; rendered as a badge overlay at the bottom-right of the media. `≤ 0` / `undefined` renders nothing.
18
+ * Hidden while the current item is playable — its player shows a live countdown there.
19
+ */
17
20
  duration?: number;
18
21
  };
19
22
  /**
@@ -1,14 +1,10 @@
1
- <script lang="ts">import { HtmlHelper } from '../../core/utils/html-helper';
2
- import { onMount } from 'svelte';
1
+ <script lang="ts">import { AfterMount } from '../../core/utils/after-mount.svelte';
2
+ import { HtmlHelper } from '../../core/utils/html-helper';
3
3
  let { src, color = null, size } = $props();
4
- let mounted = $state(false);
5
- onMount(() => {
6
- mounted = true;
7
- });
8
- const sanitizedSvg = $derived(mounted ? HtmlHelper.sanitizeSvg(src) : null);
4
+ const sanitizedSvg = new AfterMount(() => HtmlHelper.sanitizeSvg(src), '');
9
5
  </script>
10
6
 
11
- {#if mounted && sanitizedSvg === null}
7
+ {#if sanitizedSvg.current === null}
12
8
  <i class="invalid-svg">Invalid SVG</i>
13
9
  {:else}
14
10
  <div
@@ -22,8 +18,8 @@ const sanitizedSvg = $derived(mounted ? HtmlHelper.sanitizeSvg(src) : null);
22
18
  class:icon--control-md={size === 'control-md'}
23
19
  class:icon--control-lg={size === 'control-lg'}
24
20
  class:icon--control-xl={size === 'control-xl'}>
25
- {#if sanitizedSvg}
26
- {@html sanitizedSvg}
21
+ {#if sanitizedSvg.current}
22
+ {@html sanitizedSvg.current}
27
23
  {/if}
28
24
  </div>
29
25
  {/if}
@@ -2,18 +2,19 @@
2
2
  import { calculateImageState } from './image-state';
3
3
  import IconImageOff from '@fluentui/svg-icons/icons/image_off_20_regular.svg?raw';
4
4
  let { src, alt = '', showStubOnError = false, on, stub } = $props();
5
- let hasError = $state(false);
5
+ let failedSrc = $state(null);
6
+ const hasError = $derived(!!src && failedSrc === src);
6
7
  const imageState = $derived(calculateImageState(src, hasError, showStubOnError));
7
8
  // A 0.01x density makes the intrinsic size 100× the natural one, so `contain` sizing always scales the picture
8
9
  // down to fit — small pictures upscale too — and the box hugs the picture, rounding its own corners.
9
10
  // `src` must stay unset: it would join srcset as the 1x candidate and win.
10
11
  const srcset = $derived(src ? `${src.replace(/\s/g, (char) => encodeURIComponent(char))} 0.01x` : undefined);
11
12
  const onLoad = () => {
12
- hasError = false;
13
+ failedSrc = null;
13
14
  on?.load?.(true);
14
15
  };
15
16
  const onLoadError = () => {
16
- hasError = true;
17
+ failedSrc = src;
17
18
  on?.load?.(false);
18
19
  };
19
20
  </script>