@juspay/svelte-ui-components 4.55.4 → 4.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/Accordion/Accordion.svelte +66 -34
  2. package/dist/Accordion/Accordion.svelte.d.ts +1 -1
  3. package/dist/Accordion/properties.d.ts +11 -0
  4. package/dist/Avatar/Avatar.svelte +20 -6
  5. package/dist/Button/Button.svelte +34 -19
  6. package/dist/Button/Button.svelte.d.ts +1 -1
  7. package/dist/Button/properties.d.ts +10 -0
  8. package/dist/Card/Card.svelte +31 -18
  9. package/dist/Card/properties.d.ts +7 -0
  10. package/dist/Dialog/Dialog.svelte +186 -0
  11. package/dist/Dialog/Dialog.svelte.d.ts +4 -0
  12. package/dist/Dialog/properties.d.ts +23 -0
  13. package/dist/Dialog/properties.js +1 -0
  14. package/dist/DockPanel/DockPanel.svelte.d.ts +1 -1
  15. package/dist/EmptyState/EmptyState.svelte +58 -33
  16. package/dist/EmptyState/properties.d.ts +4 -0
  17. package/dist/FileInput/FileInput.svelte +130 -31
  18. package/dist/FileInput/FileInput.svelte.d.ts +1 -1
  19. package/dist/FileInput/properties.d.ts +9 -0
  20. package/dist/Icon/Icon.svelte +99 -21
  21. package/dist/Icon/properties.d.ts +8 -0
  22. package/dist/IframeViewer/IframeViewer.svelte +29 -5
  23. package/dist/IframeViewer/IframeViewer.svelte.d.ts +1 -1
  24. package/dist/IframeViewer/properties.d.ts +9 -0
  25. package/dist/Img/Img.svelte +31 -11
  26. package/dist/Img/Img.svelte.d.ts +1 -1
  27. package/dist/Img/properties.d.ts +13 -0
  28. package/dist/Input/Input.svelte +260 -170
  29. package/dist/Input/Input.svelte.d.ts +1 -1
  30. package/dist/Input/properties.d.ts +10 -0
  31. package/dist/Link/Link.svelte +33 -0
  32. package/dist/Link/Link.svelte.d.ts +4 -0
  33. package/dist/Link/properties.d.ts +14 -0
  34. package/dist/Link/properties.js +1 -0
  35. package/dist/Loader/Loader.svelte +50 -5
  36. package/dist/Loader/properties.d.ts +4 -0
  37. package/dist/MediaPlayer/MediaPlayer.svelte +223 -161
  38. package/dist/MediaPlayer/MediaPlayer.svelte.d.ts +1 -1
  39. package/dist/MediaPlayer/properties.d.ts +13 -0
  40. package/dist/Modal/Modal.svelte +52 -3
  41. package/dist/Modal/properties.d.ts +11 -0
  42. package/dist/NativeFileInput/NativeFileInput.svelte +52 -0
  43. package/dist/NativeFileInput/NativeFileInput.svelte.d.ts +6 -0
  44. package/dist/NativeFileInput/properties.d.ts +6 -0
  45. package/dist/NativeFileInput/properties.js +1 -0
  46. package/dist/Pill/Pill.svelte +7 -3
  47. package/dist/Pill/properties.d.ts +4 -0
  48. package/dist/Progress/Progress.svelte +46 -7
  49. package/dist/Progress/properties.d.ts +4 -0
  50. package/dist/Resizable/Resizable.svelte.d.ts +1 -1
  51. package/dist/Select/Select.svelte +535 -354
  52. package/dist/Select/Select.svelte.d.ts +1 -1
  53. package/dist/Select/dropdownPosition.d.ts +2 -0
  54. package/dist/Select/dropdownPosition.js +3 -2
  55. package/dist/Select/properties.d.ts +11 -0
  56. package/dist/ThemeSwitcher/ThemeSwitcher.svelte +5 -0
  57. package/dist/_chart/ChartContainer.svelte.d.ts +1 -1
  58. package/dist/_field/form-reset.d.ts +2 -0
  59. package/dist/_field/form-reset.js +34 -0
  60. package/dist/_interaction/dismissal.d.ts +2 -0
  61. package/dist/_interaction/dismissal.js +7 -1
  62. package/dist/_interaction/focus.d.ts +1 -1
  63. package/dist/_interaction/focus.js +66 -3
  64. package/dist/index.d.ts +6 -0
  65. package/dist/index.js +3 -0
  66. package/dist/styles/theme-dark.css +4 -0
  67. package/dist-codemod/codemod/migration-assets/legacy-display.css +5 -2
  68. package/dist-codemod/codemod/migration-assets/legacy-palette.css +4 -1
  69. package/dist-codemod/codemod/migration-assets/wc-display.json +15 -0
  70. package/dist-wc/index.js +5301 -3252
  71. package/package.json +2 -2
@@ -3,6 +3,7 @@
3
3
 
4
4
  let {
5
5
  title,
6
+ unstyled = false,
6
7
  description,
7
8
  icon,
8
9
  children,
@@ -26,49 +27,73 @@
26
27
  </script>
27
28
 
28
29
  <div
29
- class="empty-state {classes ?? ''}"
30
+ class={`${unstyled ? '' : 'empty-state'} ${classes ?? ''}`}
30
31
  data-pw={typeof testId === 'string' ? testId : null}
31
32
  testID={typeof testId === 'string' ? testId : null}
32
33
  data-density={typeof density === 'string' ? density : null}
33
34
  >
34
- {#if typeof icon === 'function'}
35
- <div class="empty-state-icon">
36
- {@render icon()}
37
- </div>
38
- {/if}
39
- <svelte:element
40
- this={headingTag}
41
- class="empty-state-title"
42
- data-pw={typeof testId === 'string' ? `${testId}-title` : null}
43
- testID={typeof testId === 'string' ? `${testId}-title` : null}
44
- >
35
+ {#if unstyled}
36
+ {@render icon?.()}
45
37
  {#if typeof titleSnippet === 'function'}
46
38
  {@render titleSnippet()}
47
39
  {:else}
48
- {title}
40
+ <svelte:element
41
+ this={headingTag}
42
+ data-pw={typeof testId === 'string' ? `${testId}-title` : null}
43
+ testID={typeof testId === 'string' ? `${testId}-title` : null}>{title}</svelte:element
44
+ >
49
45
  {/if}
50
- </svelte:element>
51
- {#if typeof descriptionSnippet === 'function'}
52
- <div
53
- class="empty-state-description"
54
- data-pw={typeof testId === 'string' ? `${testId}-description` : null}
55
- testID={typeof testId === 'string' ? `${testId}-description` : null}
56
- >
46
+ {#if typeof descriptionSnippet === 'function'}
57
47
  {@render descriptionSnippet()}
58
- </div>
59
- {:else if typeof description === 'string' && description.length > 0}
60
- <div
61
- class="empty-state-description"
62
- data-pw={typeof testId === 'string' ? `${testId}-description` : null}
63
- testID={typeof testId === 'string' ? `${testId}-description` : null}
48
+ {:else if typeof description === 'string' && description.length > 0}
49
+ <div
50
+ data-pw={typeof testId === 'string' ? `${testId}-description` : null}
51
+ testID={typeof testId === 'string' ? `${testId}-description` : null}
52
+ >
53
+ {description}
54
+ </div>
55
+ {/if}
56
+ {@render children?.()}
57
+ {:else}
58
+ {#if typeof icon === 'function'}
59
+ <div class="empty-state-icon">
60
+ {@render icon()}
61
+ </div>
62
+ {/if}
63
+ <svelte:element
64
+ this={headingTag}
65
+ class="empty-state-title"
66
+ data-pw={typeof testId === 'string' ? `${testId}-title` : null}
67
+ testID={typeof testId === 'string' ? `${testId}-title` : null}
64
68
  >
65
- {description}
66
- </div>
67
- {/if}
68
- {#if typeof children === 'function'}
69
- <div class="empty-state-actions">
70
- {@render children()}
71
- </div>
69
+ {#if typeof titleSnippet === 'function'}
70
+ {@render titleSnippet()}
71
+ {:else}
72
+ {title}
73
+ {/if}
74
+ </svelte:element>
75
+ {#if typeof descriptionSnippet === 'function'}
76
+ <div
77
+ class="empty-state-description"
78
+ data-pw={typeof testId === 'string' ? `${testId}-description` : null}
79
+ testID={typeof testId === 'string' ? `${testId}-description` : null}
80
+ >
81
+ {@render descriptionSnippet()}
82
+ </div>
83
+ {:else if typeof description === 'string' && description.length > 0}
84
+ <div
85
+ class="empty-state-description"
86
+ data-pw={typeof testId === 'string' ? `${testId}-description` : null}
87
+ testID={typeof testId === 'string' ? `${testId}-description` : null}
88
+ >
89
+ {description}
90
+ </div>
91
+ {/if}
92
+ {#if typeof children === 'function'}
93
+ <div class="empty-state-actions">
94
+ {@render children()}
95
+ </div>
96
+ {/if}
72
97
  {/if}
73
98
  </div>
74
99
 
@@ -11,6 +11,10 @@ export type MandatoryEmptyStateProperties = {
11
11
  title: string;
12
12
  };
13
13
  export type OptionalEmptyStateProperties = {
14
+ /** Render caller-owned layout and named snippets without styled slot wrappers.
15
+ * Fallback title/description semantics and root test hooks remain available.
16
+ * Omit to retain the existing styled EmptyState layout. */
17
+ unstyled?: boolean;
14
18
  description?: string;
15
19
  icon?: Snippet;
16
20
  children?: Snippet;
@@ -1,9 +1,16 @@
1
1
  <script lang="ts">
2
2
  import { describeField } from '../_field/description';
3
+ import { watchFormReset } from '../_field/form-reset';
3
4
  import { provideFileInputOwner } from './context';
4
5
  import type { FileInputProperties } from './properties';
5
6
 
6
7
  let {
8
+ native = false,
9
+ name,
10
+ required,
11
+ nativeAttrs,
12
+ // eslint-disable-next-line no-useless-assignment -- Bindable output is assigned by the mounted DOM reference.
13
+ element = $bindable(),
7
14
  trigger,
8
15
  activation = 'region',
9
16
  accept,
@@ -43,8 +50,45 @@
43
50
  });
44
51
 
45
52
  let dragOver = $state(false);
46
- let inputEl: HTMLInputElement | null = $state(null);
53
+ let inputEl = $state<HTMLInputElement | null>(null);
54
+ const assignInputElement = (node: HTMLInputElement | null) => {
55
+ inputEl = node;
56
+ element = node;
57
+ };
47
58
  let pickerBusy = false;
59
+ let selectionBeforePicker: File[] | null = null;
60
+ let resetDuringPicker: Event | null = null;
61
+
62
+ // A cancelled picker must not undo a reset that happened while it was open.
63
+ // Retain the event so a consumer's later preventDefault is respected as well.
64
+ // eslint-disable-next-line no-restricted-syntax
65
+ $effect(() => {
66
+ const node = inputEl;
67
+ if (!native || !node) {
68
+ return;
69
+ }
70
+ const stop = watchFormReset(
71
+ node,
72
+ (event) => {
73
+ if (selectionBeforePicker !== null) {
74
+ resetDuringPicker = event;
75
+ }
76
+ },
77
+ () => {
78
+ if (node.form) {
79
+ return node.form;
80
+ }
81
+ const root = node.getRootNode();
82
+ const owner = root instanceof ShadowRoot ? Reflect.get(root.host, 'form') : null;
83
+ return owner instanceof HTMLFormElement ? owner : null;
84
+ }
85
+ );
86
+ return () => {
87
+ stop();
88
+ selectionBeforePicker = null;
89
+ resetDuringPicker = null;
90
+ };
91
+ });
48
92
 
49
93
  export const openFilePicker = (): void => {
50
94
  if (disabled || pickerBusy) {
@@ -117,10 +161,42 @@
117
161
  if (!(target instanceof HTMLInputElement)) {
118
162
  return;
119
163
  }
164
+ selectionBeforePicker = null;
165
+ resetDuringPicker = null;
120
166
  processFiles(target.files);
167
+ if (!native) {
168
+ target.value = '';
169
+ }
170
+ }
171
+
172
+ function prepareNativePicker(event: MouseEvent): void {
173
+ const target = event.currentTarget;
174
+ if (disabled || !(target instanceof HTMLInputElement)) {
175
+ return;
176
+ }
177
+ selectionBeforePicker = Array.from(target.files ?? []);
178
+ resetDuringPicker = null;
121
179
  target.value = '';
122
180
  }
123
181
 
182
+ function cancelNativePicker(event: Event): void {
183
+ const target = event.currentTarget;
184
+ if (target !== inputEl) {
185
+ return;
186
+ }
187
+ if (
188
+ target instanceof HTMLInputElement &&
189
+ selectionBeforePicker?.length &&
190
+ (!resetDuringPicker || resetDuringPicker.defaultPrevented)
191
+ ) {
192
+ const transfer = new DataTransfer();
193
+ selectionBeforePicker.forEach((file) => transfer.items.add(file));
194
+ target.files = transfer.files;
195
+ }
196
+ selectionBeforePicker = null;
197
+ resetDuringPicker = null;
198
+ }
199
+
124
200
  function handleDragOver(event: DragEvent): void {
125
201
  event.preventDefault();
126
202
  if (!disabled) {
@@ -163,42 +239,65 @@
163
239
  }
164
240
  </script>
165
241
 
166
- <!-- The role is a ternary Svelte cannot resolve, so it reads the element as a plain div. Whenever
167
- the tabindex renders, the role is "button" on the very same expression. -->
168
- <!-- svelte-ignore a11y_no_noninteractive_tabindex -->
169
- <div
170
- class="file-input {classes ?? ''}"
171
- class:file-input-dragover={dragOver}
172
- class:file-input-disabled={disabled}
173
- class:file-input-passive={!regionOwnsActivation}
174
- data-pw={testId}
175
- testID={testId}
176
- role={regionOwnsActivation ? 'button' : null}
177
- tabindex={regionOwnsActivation ? (disabled ? -1 : 0) : null}
178
- aria-disabled={regionOwnsActivation ? disabled : null}
179
- aria-describedby={regionOwnsActivation ? field.describedBy : null}
180
- ondragover={handleDragOver}
181
- ondragleave={handleDragLeave}
182
- ondrop={handleDrop}
183
- onkeydown={regionOwnsActivation ? handleKeyDown : null}
184
- onclick={regionOwnsActivation ? handleClick : null}
185
- >
242
+ {#if native}
186
243
  <input
187
- bind:this={inputEl}
244
+ {...nativeAttrs}
245
+ bind:this={() => inputEl, assignInputElement}
188
246
  type="file"
189
- class="file-input-hidden"
247
+ class={classes ?? ''}
248
+ class:file-input-native={true}
190
249
  {accept}
191
250
  {multiple}
192
251
  {disabled}
193
- data-pw={typeof testId === 'string' ? `${testId}-input` : null}
194
- testID={typeof testId === 'string' ? `${testId}-input` : null}
252
+ name={name ?? nativeAttrs?.name}
253
+ required={required ?? nativeAttrs?.required}
254
+ aria-invalid={nativeAttrs?.['aria-invalid'] ?? field.ariaInvalid}
255
+ aria-describedby={[nativeAttrs?.['aria-describedby'], field.describedBy]
256
+ .filter(Boolean)
257
+ .join(' ') || null}
258
+ data-pw={testId}
259
+ onclick={prepareNativePicker}
260
+ oncancel={cancelNativePicker}
195
261
  onchange={handleInputChange}
196
- tabindex="-1"
197
- aria-hidden="true"
198
262
  />
263
+ {:else}
264
+ <!-- The role is a ternary Svelte cannot resolve, so it reads the element as a plain div. Whenever
265
+ the tabindex renders, the role is "button" on the very same expression. -->
266
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex -->
267
+ <div
268
+ class="file-input {classes ?? ''}"
269
+ class:file-input-dragover={dragOver}
270
+ class:file-input-disabled={disabled}
271
+ class:file-input-passive={!regionOwnsActivation}
272
+ data-pw={testId}
273
+ testID={testId}
274
+ role={regionOwnsActivation ? 'button' : null}
275
+ tabindex={regionOwnsActivation ? (disabled ? -1 : 0) : null}
276
+ aria-disabled={regionOwnsActivation ? disabled : null}
277
+ aria-describedby={regionOwnsActivation ? field.describedBy : null}
278
+ ondragover={handleDragOver}
279
+ ondragleave={handleDragLeave}
280
+ ondrop={handleDrop}
281
+ onkeydown={regionOwnsActivation ? handleKeyDown : null}
282
+ onclick={regionOwnsActivation ? handleClick : null}
283
+ >
284
+ <input
285
+ bind:this={() => inputEl, assignInputElement}
286
+ type="file"
287
+ class="file-input-hidden"
288
+ {accept}
289
+ {multiple}
290
+ {disabled}
291
+ data-pw={typeof testId === 'string' ? `${testId}-input` : null}
292
+ testID={typeof testId === 'string' ? `${testId}-input` : null}
293
+ onchange={handleInputChange}
294
+ tabindex="-1"
295
+ aria-hidden="true"
296
+ />
199
297
 
200
- {@render trigger({ openFilePicker, dragOver, disabled, describedBy: field.describedBy })}
201
- </div>
298
+ {@render trigger?.({ openFilePicker, dragOver, disabled, describedBy: field.describedBy })}
299
+ </div>
300
+ {/if}
202
301
 
203
302
  {#if field.showsError}
204
303
  <div
@@ -234,7 +333,7 @@
234
333
  margin-top: var(--file-input-info-margin-top, 4px);
235
334
  }
236
335
 
237
- .file-input {
336
+ .file-input:where(:not(.file-input-native)) {
238
337
  display: var(--file-input-display, inline-flex);
239
338
  flex-direction: var(--file-input-flex-direction, column);
240
339
  align-items: var(--file-input-align-items, center);
@@ -260,7 +359,7 @@
260
359
  is the library's convention for a ring that needs no colour literal (Card, Pill, StatCard):
261
360
  it follows the surrounding text colour, so it clears 3:1 on the light and the dark ground
262
361
  alike and stays visible in forced-colors mode. :focus-visible keeps it off pointer clicks. */
263
- .file-input:focus-visible {
362
+ .file-input:where(:not(.file-input-native)):focus-visible {
264
363
  outline: var(--file-input-focus-outline, 2px solid currentColor);
265
364
  outline-offset: var(--file-input-focus-outline-offset, 2px);
266
365
  }
@@ -1,6 +1,6 @@
1
1
  import type { FileInputProperties } from './properties';
2
2
  declare const FileInput: import("svelte").Component<FileInputProperties, {
3
3
  openFilePicker: () => void;
4
- }, "">;
4
+ }, "element">;
5
5
  type FileInput = ReturnType<typeof FileInput>;
6
6
  export default FileInput;
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import type { HTMLInputAttributes } from 'svelte/elements';
2
3
  export type FileInputSnippetProps = {
3
4
  openFilePicker: () => void;
4
5
  dragOver: boolean;
@@ -29,6 +30,14 @@ export type FileInputProperties = {
29
30
  * announcement for the same action.
30
31
  */
31
32
  trigger: Snippet<[FileInputSnippetProps]>;
33
+ /** Render the native picker without a drop-zone wrapper. */
34
+ native?: boolean;
35
+ /** Native-mode submission name; falls back to nativeAttrs.name. */
36
+ name?: string;
37
+ /** Native-mode required state; an explicit boolean wins over nativeAttrs.required. */
38
+ required?: boolean;
39
+ element?: HTMLInputElement | null;
40
+ nativeAttrs?: Omit<HTMLInputAttributes, Extract<keyof HTMLInputAttributes, `on${string}`> | 'type' | 'class' | 'accept' | 'multiple' | 'disabled'>;
32
41
  /** Who owns the single interactive control. Defaults to `'region'`; see {@link FileInputActivation}. */
33
42
  activation?: FileInputActivation;
34
43
  accept?: string;
@@ -1,13 +1,36 @@
1
1
  <script lang="ts">
2
2
  import Img from '../Img/Img.svelte';
3
+ import Button from '../Button/Button.svelte';
3
4
  import type { IconProperties } from './properties';
4
5
 
5
- let { icon, svg, text, onclick, onkeydown, classes, testId }: IconProperties = $props();
6
+ let {
7
+ mask = false,
8
+ size,
9
+ color,
10
+ label,
11
+ icon,
12
+ svg,
13
+ text,
14
+ onclick,
15
+ onkeydown,
16
+ classes,
17
+ testId
18
+ }: IconProperties = $props();
6
19
 
7
20
  // A decorative icon is not a control. Without a click handler it keeps no button
8
21
  // role and stays out of the tab order, rather than being a focusable no-op that
9
22
  // assistive technology announces as a button.
10
23
  const interactive = $derived(typeof onclick === 'function');
24
+ const maskUrl = $derived(
25
+ `url("${(icon ?? '').replace(/["\\\n\r\f]/g, (character) => `\\${character.charCodeAt(0).toString(16)} `)}")`
26
+ );
27
+ const maskActionProperties = $derived(
28
+ typeof label === 'string'
29
+ ? { ariaLabel: label }
30
+ : typeof text === 'string'
31
+ ? { ariaLabel: text }
32
+ : {}
33
+ );
11
34
 
12
35
  function handleKeydown(event: KeyboardEvent): void {
13
36
  onkeydown?.(event);
@@ -21,29 +44,84 @@
21
44
  }
22
45
  </script>
23
46
 
24
- <div
25
- class="icon-container {classes ?? ''}"
26
- {onclick}
27
- onkeydown={handleKeydown}
28
- role={interactive ? 'button' : null}
29
- tabindex={interactive ? 0 : null}
30
- data-pw={typeof testId === 'string' ? testId : null}
31
- testID={typeof testId === 'string' ? testId : null}
32
- >
33
- {#if typeof svg === 'string' && svg.length > 0}
34
- <!-- eslint-disable svelte/no-at-html-tags -->
35
- <span class="icon-svg">{@html svg}</span>
36
- {:else if icon}
37
- <!-- Inline the SVG so currentColor strokes/fills inherit the surrounding text
38
- colour; non-SVG URLs fall back to the plain <img> render automatically. -->
39
- <Img inlineSvg src={icon} alt="" fallback="" />
40
- {/if}
41
- {#if typeof text === 'string' && text.length > 0}
42
- <div class="icon-text">{text}</div>
47
+ {#snippet maskShape()}
48
+ <span
49
+ class="icon-mask {interactive ? '' : (classes ?? '')}"
50
+ style:--icon-url={maskUrl}
51
+ style:--icon-size={typeof size === 'number' ? `${size}px` : null}
52
+ style:--icon-color={color ?? null}
53
+ role={!interactive && label ? 'img' : null}
54
+ aria-label={!interactive ? (label ?? null) : null}
55
+ aria-hidden={interactive || !label ? true : null}
56
+ data-pw={!interactive ? (testId ?? null) : null}
57
+ testID={!interactive ? (testId ?? null) : null}
58
+ ></span>
59
+ {/snippet}
60
+
61
+ {#if mask}
62
+ {#if interactive}
63
+ <span class="icon-mask-action {classes ?? ''}">
64
+ <Button unstyled {...maskActionProperties} {onclick} {onkeydown} {testId}>
65
+ {@render maskShape()}
66
+ </Button>
67
+ </span>
68
+ {:else}
69
+ {@render maskShape()}
43
70
  {/if}
44
- </div>
71
+ {:else}
72
+ <div
73
+ class="icon-container {classes ?? ''}"
74
+ {onclick}
75
+ onkeydown={handleKeydown}
76
+ role={interactive ? 'button' : null}
77
+ tabindex={interactive ? 0 : null}
78
+ data-pw={typeof testId === 'string' ? testId : null}
79
+ testID={typeof testId === 'string' ? testId : null}
80
+ >
81
+ {#if typeof svg === 'string' && svg.length > 0}
82
+ <!-- eslint-disable svelte/no-at-html-tags -->
83
+ <span class="icon-svg">{@html svg}</span>
84
+ {:else if icon}
85
+ <!-- Inline the SVG so currentColor strokes/fills inherit the surrounding text
86
+ colour; non-SVG URLs fall back to the plain <img> render automatically. -->
87
+ <Img inlineSvg src={icon} alt="" fallback="" />
88
+ {/if}
89
+ {#if typeof text === 'string' && text.length > 0}
90
+ <div class="icon-text">{text}</div>
91
+ {/if}
92
+ </div>
93
+ {/if}
45
94
 
46
95
  <style>
96
+ .icon-mask {
97
+ display: inline-block;
98
+ flex: 0 0 auto;
99
+ width: var(--icon-size, 24px);
100
+ height: var(--icon-size, 24px);
101
+ background-color: var(--icon-color, currentColor);
102
+ -webkit-mask-image: var(--icon-url);
103
+ mask-image: var(--icon-url);
104
+ -webkit-mask-size: contain;
105
+ mask-size: contain;
106
+ -webkit-mask-repeat: no-repeat;
107
+ mask-repeat: no-repeat;
108
+ -webkit-mask-position: center;
109
+ mask-position: center;
110
+ }
111
+
112
+ .icon-mask-action {
113
+ display: inline-flex;
114
+ }
115
+
116
+ .icon-mask-action > :global(button) {
117
+ display: inline-flex;
118
+ padding: 0;
119
+ border: 0;
120
+ color: inherit;
121
+ background: transparent;
122
+ cursor: pointer;
123
+ }
124
+
47
125
  .icon-container {
48
126
  display: flex;
49
127
  padding: var(--icon-container-paddding, 4px);
@@ -1,5 +1,13 @@
1
1
  export type IconProperties = OptionalIconProperties & IconEventProperties;
2
2
  export type OptionalIconProperties = {
3
+ /** Paint a monochrome asset with currentColor using a native CSS mask. */
4
+ mask?: boolean;
5
+ /** Pixel size of a mask icon. Otherwise uses --icon-size (24px by default). */
6
+ size?: number;
7
+ /** Mask color override; omitted icons inherit currentColor. */
8
+ color?: string;
9
+ /** Accessible name for a mask icon or its action. Omit for decoration. */
10
+ label?: string;
3
11
  icon?: string;
4
12
  svg?: string;
5
13
  text?: string | null;
@@ -3,7 +3,13 @@
3
3
  import type { IframeViewerProperties } from './properties';
4
4
 
5
5
  let {
6
+ unstyled = false,
6
7
  src,
8
+ nativeAttrs,
9
+ // eslint-disable-next-line no-useless-assignment -- Bindable output is assigned by the mounted DOM reference.
10
+ element = $bindable(),
11
+ onload,
12
+ onerror,
7
13
  title = 'Embedded Content',
8
14
  allowedOrigins = [],
9
15
  allow = 'fullscreen',
@@ -17,7 +23,11 @@
17
23
  onmessage = () => {}
18
24
  }: IframeViewerProperties = $props();
19
25
 
20
- let iframeEl: HTMLIFrameElement | null = $state(null);
26
+ let iframeEl = $state<HTMLIFrameElement | null>(null);
27
+ const assignFrameElement = (node: HTMLIFrameElement | null) => {
28
+ iframeEl = node;
29
+ element = node;
30
+ };
21
31
 
22
32
  export const postMessage = (message: unknown, targetOrigin: string): void => {
23
33
  iframeEl?.contentWindow?.postMessage(message, targetOrigin);
@@ -48,10 +58,16 @@
48
58
  });
49
59
  </script>
50
60
 
51
- <div class="iframe-viewer {classes ?? ''}" data-pw={testId} testID={testId}>
61
+ {#snippet frame()}
52
62
  {#if src}
53
63
  <iframe
54
- bind:this={iframeEl}
64
+ {...nativeAttrs}
65
+ {...unstyled && typeof testId === 'string' ? { 'data-pw': testId, testID: testId } : {}}
66
+ class={unstyled ? (classes ?? '') : nativeAttrs?.class}
67
+ class:iframe-unstyled={unstyled}
68
+ bind:this={() => iframeEl, assignFrameElement}
69
+ {onload}
70
+ {onerror}
55
71
  {src}
56
72
  {title}
57
73
  {allow}
@@ -61,7 +77,15 @@
61
77
  {...credentialless ? { credentialless: '' } : {}}
62
78
  ></iframe>
63
79
  {/if}
64
- </div>
80
+ {/snippet}
81
+
82
+ {#if unstyled}
83
+ {@render frame()}
84
+ {:else}
85
+ <div class="iframe-viewer {classes ?? ''}" data-pw={testId} testID={testId}>
86
+ {@render frame()}
87
+ </div>
88
+ {/if}
65
89
 
66
90
  <style>
67
91
  .iframe-viewer {
@@ -70,7 +94,7 @@
70
94
  display: flex;
71
95
  }
72
96
 
73
- iframe {
97
+ iframe:where(:not(.iframe-unstyled)) {
74
98
  width: 100%;
75
99
  height: 100%;
76
100
  border: var(--iframe-viewer-border, none);
@@ -1,6 +1,6 @@
1
1
  import type { IframeViewerProperties } from './properties';
2
2
  declare const IframeViewer: import("svelte").Component<IframeViewerProperties, {
3
3
  postMessage: (message: unknown, targetOrigin: string) => void;
4
- }, "">;
4
+ }, "element">;
5
5
  type IframeViewer = ReturnType<typeof IframeViewer>;
6
6
  export default IframeViewer;
@@ -1,11 +1,18 @@
1
+ import type { HTMLIframeAttributes } from 'svelte/elements';
1
2
  export type IframeViewerProperties = MandatoryIframeViewerProperties & OptionalIframeViewerProperties & IframeViewerEventProperties;
2
3
  export type MandatoryIframeViewerProperties = {
3
4
  /** URL loaded into the iframe. */
4
5
  src: string;
5
6
  };
6
7
  export type OptionalIframeViewerProperties = {
8
+ /** Render only the native element, without component appearance or layout wrappers. */
9
+ unstyled?: boolean;
7
10
  /** Accessible title for the iframe (default: `'Embedded Content'`). */
8
11
  title?: string;
12
+ /** Bindable native frame reference. */
13
+ element?: HTMLIFrameElement | null;
14
+ /** Native frame attributes; dedicated permission/source props retain precedence. */
15
+ nativeAttrs?: Omit<HTMLIframeAttributes, 'src' | 'title' | 'allow' | 'sandbox' | 'onload' | 'onerror'>;
9
16
  /**
10
17
  * Origins allowed to send `postMessage` events to `onMessage`. An empty array (the
11
18
  * default) processes nothing — secure by default.
@@ -32,6 +39,8 @@ export type OptionalIframeViewerProperties = {
32
39
  classes?: string;
33
40
  };
34
41
  export type IframeViewerEventProperties = {
42
+ onload?: (event: Event) => void;
43
+ onerror?: (event: Event) => void;
35
44
  /**
36
45
  * Called with the `MessageEvent` for `postMessage` events whose origin is in
37
46
  * `allowedOrigins` and whose source is the embedded iframe window.