@lavalogic/scoria 0.40.13 → 0.40.15

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 (143) hide show
  1. package/README.md +58 -58
  2. package/dist/Components/AccordionGroup.svelte +35 -46
  3. package/dist/Components/AccordionGroupButton.svelte +68 -76
  4. package/dist/Components/Action.svelte +103 -135
  5. package/dist/Components/AlertModal.svelte +171 -190
  6. package/dist/Components/AppointmentCalendar/AppointmentCalendar.svelte +614 -697
  7. package/dist/Components/Base/BaseModal.svelte +90 -116
  8. package/dist/Components/Base/ContextWrapper.svelte +67 -72
  9. package/dist/Components/Base/Pagination.svelte +173 -196
  10. package/dist/Components/Base/Snippets.svelte +34 -36
  11. package/dist/Components/BigRadioSet.svelte +36 -38
  12. package/dist/Components/Bubble.svelte +78 -101
  13. package/dist/Components/Button.svelte +175 -208
  14. package/dist/Components/Checkbox.svelte +75 -86
  15. package/dist/Components/CollapsibleCard.svelte +72 -87
  16. package/dist/Components/CollapsibleMenuGroup.svelte +53 -57
  17. package/dist/Components/ConditionBuilder/ConditionBuilder.svelte +39 -64
  18. package/dist/Components/Contexts/ContextMenu.svelte +141 -156
  19. package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
  20. package/dist/Components/Contexts/ContextMenuOption.svelte +53 -60
  21. package/dist/Components/Contexts/Toast.svelte +81 -86
  22. package/dist/Components/Contexts/ToastContainer.svelte +58 -62
  23. package/dist/Components/Contexts/Tooltip.svelte +36 -37
  24. package/dist/Components/DataMatrixIcon.svelte +95 -108
  25. package/dist/Components/DateInput.svelte +118 -146
  26. package/dist/Components/DatePicker.svelte +255 -294
  27. package/dist/Components/DesktopModal.svelte +70 -90
  28. package/dist/Components/Dial.svelte +167 -197
  29. package/dist/Components/DimensionInput.svelte +124 -169
  30. package/dist/Components/DragMenu/DragMenuHolder.svelte +98 -114
  31. package/dist/Components/DragMenu/DraggableCard.svelte +64 -76
  32. package/dist/Components/FileCard.svelte +21 -24
  33. package/dist/Components/FileUpload.svelte +190 -225
  34. package/dist/Components/GridInput.svelte +159 -196
  35. package/dist/Components/GridInputSet.svelte +24 -29
  36. package/dist/Components/HorizontalTabGroup.svelte +73 -89
  37. package/dist/Components/HorizontalTabGroupButton.svelte +40 -44
  38. package/dist/Components/Icon.svelte +99 -128
  39. package/dist/Components/Icons.js +357 -357
  40. package/dist/Components/InfoAlert.svelte +35 -38
  41. package/dist/Components/LoadingAnimation.svelte +691 -755
  42. package/dist/Components/LoadingModal.svelte +36 -44
  43. package/dist/Components/LoadingOverlay.svelte +22 -26
  44. package/dist/Components/Modal.svelte +204 -254
  45. package/dist/Components/MultiSelect.svelte +186 -216
  46. package/dist/Components/Nav/Nav.svelte +94 -110
  47. package/dist/Components/Nav/NavServiceMenuList.svelte +57 -61
  48. package/dist/Components/Nav/NavTab.svelte +58 -62
  49. package/dist/Components/Nav/ServiceMenuItem.svelte +103 -111
  50. package/dist/Components/Nav/ServicesNav.svelte +72 -79
  51. package/dist/Components/NumberInput.svelte +121 -155
  52. package/dist/Components/OptionCards.svelte +62 -73
  53. package/dist/Components/PageHeading.svelte +23 -25
  54. package/dist/Components/PasswordInput.svelte +69 -88
  55. package/dist/Components/PopoverButton.svelte +151 -0
  56. package/dist/Components/PopoverButton.svelte.d.ts +9 -0
  57. package/dist/Components/PopoverButtonProps.d.ts +21 -0
  58. package/dist/Components/PopoverButtonProps.js +1 -0
  59. package/dist/Components/Portal.svelte +29 -35
  60. package/dist/Components/ProgressBubble.svelte +91 -106
  61. package/dist/Components/QuerySelect.svelte +260 -346
  62. package/dist/Components/SidebarPanel.svelte +34 -36
  63. package/dist/Components/SingleSelect.svelte +196 -244
  64. package/dist/Components/StepButton.svelte +65 -70
  65. package/dist/Components/StepForm.svelte +115 -135
  66. package/dist/Components/Switch.svelte +57 -69
  67. package/dist/Components/Table/ARCHITECTURE.md +298 -298
  68. package/dist/Components/Table/Body/QuickSearchCell.svelte +578 -655
  69. package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +42 -51
  70. package/dist/Components/Table/Body/Rows/ColumnList.svelte +42 -58
  71. package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +403 -442
  72. package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +51 -78
  73. package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +165 -184
  74. package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +110 -123
  75. package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +134 -160
  76. package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +190 -231
  77. package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +82 -104
  78. package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +52 -87
  79. package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +122 -150
  80. package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +132 -159
  81. package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +190 -236
  82. package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +173 -211
  83. package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +204 -244
  84. package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +140 -177
  85. package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +188 -217
  86. package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +173 -193
  87. package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +166 -187
  88. package/dist/Components/Table/Body/Rows/TableRow.svelte +245 -288
  89. package/dist/Components/Table/Body/TableBody.svelte +141 -154
  90. package/dist/Components/Table/Headers/HighlightAllHeader.svelte +35 -41
  91. package/dist/Components/Table/Headers/SelectAllHeader.svelte +24 -30
  92. package/dist/Components/Table/Headers/TableHead.svelte +348 -402
  93. package/dist/Components/Table/Misc/ColumnPanel.svelte +37 -39
  94. package/dist/Components/Table/Misc/ColumnPanelModal.svelte +35 -39
  95. package/dist/Components/Table/Misc/FilterInput.svelte +556 -619
  96. package/dist/Components/Table/Misc/FilterPanel.svelte +170 -183
  97. package/dist/Components/Table/Misc/FilterPanelModal.svelte +25 -31
  98. package/dist/Components/Table/Misc/ShareViewModal.svelte +252 -281
  99. package/dist/Components/Table/Misc/SidePanel.svelte +32 -35
  100. package/dist/Components/Table/Misc/TableConfigurationModal.svelte +574 -629
  101. package/dist/Components/Table/Misc/TableFooter.svelte +326 -332
  102. package/dist/Components/Table/Misc/TableHorizontalBar.svelte +134 -140
  103. package/dist/Components/Table/Misc/TableSidebar.svelte +183 -198
  104. package/dist/Components/Table/Misc/TableViewDropdown.svelte +83 -103
  105. package/dist/Components/Table/Misc/ToolboxPanel.svelte +83 -100
  106. package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +88 -107
  107. package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte +163 -190
  108. package/dist/Components/Table/NestedTable.svelte +102 -128
  109. package/dist/Components/Table/Table.svelte +531 -663
  110. package/dist/Components/Test/TestContextConsumer.svelte +11 -13
  111. package/dist/Components/TextArea.svelte +95 -130
  112. package/dist/Components/TextInput.svelte +125 -176
  113. package/dist/Components/ThreeStateRadio.svelte +111 -130
  114. package/dist/Components/Touch/BoolCard.svelte +33 -45
  115. package/dist/Components/Touch/DateModal.svelte +164 -204
  116. package/dist/Components/Touch/EditCard.svelte +48 -59
  117. package/dist/Components/Touch/InfoCard.svelte +28 -31
  118. package/dist/Components/Touch/InfoTextCard.svelte +26 -28
  119. package/dist/Components/Touch/ModalExplanation.svelte +15 -17
  120. package/dist/Components/Touch/NumberKeyboard.svelte +181 -218
  121. package/dist/Components/Touch/NumberModal.svelte +59 -79
  122. package/dist/Components/Touch/PlusMinusCard.svelte +43 -46
  123. package/dist/Components/Touch/SelectModal.svelte +111 -126
  124. package/dist/Components/Touch/SummaryCard.svelte +80 -93
  125. package/dist/Components/Touch/TextAreaModal.svelte +72 -94
  126. package/dist/Components/Touch/TextModal.svelte +77 -105
  127. package/dist/Components/Touch/TouchCard.svelte +31 -33
  128. package/dist/Components/Touch/TouchModal.svelte +214 -270
  129. package/dist/Components/Touch/UtilityButton.svelte +88 -109
  130. package/dist/Components/VerticalTabGroup.svelte +60 -78
  131. package/dist/Components/VerticalTabGroupButton.svelte +54 -58
  132. package/dist/Helpers/Datamatrix.d.ts +19 -19
  133. package/dist/Helpers/Datamatrix.js +291 -291
  134. package/dist/Types/Examples/ExampleModal.svelte +31 -35
  135. package/dist/index.d.ts +2 -0
  136. package/dist/index.js +1 -0
  137. package/dist/scss/_basics.scss +12 -12
  138. package/dist/scss/_colours.scss +134 -134
  139. package/dist/scss/_mixins.scss +3392 -3392
  140. package/dist/scss/_motion.scss +57 -57
  141. package/dist/scss/_sizing.scss +85 -85
  142. package/dist/scss/_transitions.scss +8 -8
  143. package/package.json +1 -1
@@ -1,67 +1,63 @@
1
- <svelte:options runes />
2
-
3
- <!--
4
- @component
5
- Live region for the {@link ToastContext}. Iterates the context's
6
- queue and renders one `Toast` per message, providing the
7
- copy-to-clipboard callback (the container owns the clipboard logic
8
- because the toast itself only knows the message it should copy).
9
-
10
- The wrapping `<section>` carries `role="region"` plus
11
- `aria-live="polite"` so multiple toast appearances are announced as
12
- a single rolling region without interrupting the user; individual
13
- `Toast` elements override `aria-live` to `assertive` for hard errors.
14
-
15
- Mounted once at the app root by `ContextWrapper`; consumers should
16
- not render this directly.
17
- -->
18
- <script lang="ts">
19
- import { ToastContext } from '../../Contexts/ToastContext.svelte.js';
20
- import { devCatch } from '../../Helpers/Helpers.svelte.js';
21
- import { Validity } from '../../Types/Internal/Validity.js';
22
- import { getContext } from 'svelte';
23
- import Toast from './Toast.svelte';
24
-
25
- const toastContext = getContext<ToastContext>(ToastContext.identifier);
26
-
27
- function copyDataToClipboard(text: string): void {
28
- // `navigator.clipboard` is `undefined` on insecure (HTTP)
29
- // origins and in some embedded WebViews. The compile-time
30
- // type says it is always defined, hence the eslint disable;
31
- // the runtime check is the load-bearing one.
32
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
33
- if (!navigator.clipboard) {
34
- toastContext.toast({
35
- result: Validity.Invalid,
36
- message: 'Cannot Copy in an Insecure Connection',
37
- copyable: false,
38
- });
39
- return;
40
- }
41
-
42
- navigator.clipboard.writeText(text).catch(devCatch);
1
+ <svelte:options runes />
2
+
3
+ <!--
4
+ @component
5
+ Live region for the {@link ToastContext}. Iterates the context's
6
+ queue and renders one `Toast` per message, providing the
7
+ copy-to-clipboard callback (the container owns the clipboard logic
8
+ because the toast itself only knows the message it should copy).
9
+
10
+ The wrapping `<section>` carries `role="region"` plus
11
+ `aria-live="polite"` so multiple toast appearances are announced as
12
+ a single rolling region without interrupting the user; individual
13
+ `Toast` elements override `aria-live` to `assertive` for hard errors.
14
+
15
+ Mounted once at the app root by `ContextWrapper`; consumers should
16
+ not render this directly.
17
+ -->
18
+ <script lang="ts">import { ToastContext } from "../../Contexts/ToastContext.svelte.js";
19
+ import { devCatch } from "../../Helpers/Helpers.svelte.js";
20
+ import { Validity } from "../../Types/Internal/Validity.js";
21
+ import { getContext } from "svelte";
22
+ import Toast from "./Toast.svelte";
23
+ const toastContext = getContext(ToastContext.identifier);
24
+ function copyDataToClipboard(text) {
25
+ // `navigator.clipboard` is `undefined` on insecure (HTTP)
26
+ // origins and in some embedded WebViews. The compile-time
27
+ // type says it is always defined, hence the eslint disable;
28
+ // the runtime check is the load-bearing one.
29
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
30
+ if (!navigator.clipboard) {
43
31
  toastContext.toast({
44
- result: Validity.Info,
45
- message: 'Message copied to clipboard',
46
- copyable: false,
32
+ result: Validity.Invalid,
33
+ message: "Cannot Copy in an Insecure Connection",
34
+ copyable: false
47
35
  });
36
+ return;
48
37
  }
49
- </script>
50
-
51
- <section
52
- aria-live="polite"
53
- aria-label="Notifications"
54
- >
55
- {#each toastContext.toasts as toast (toast.id)}
56
- <Toast
57
- {toast}
58
- copy={() => {
59
- copyDataToClipboard(toast.getVerbose?.() ?? toast.message);
60
- }}
61
- />
62
- {/each}
63
- </section>
64
-
38
+ navigator.clipboard.writeText(text).catch(devCatch);
39
+ toastContext.toast({
40
+ result: Validity.Info,
41
+ message: "Message copied to clipboard",
42
+ copyable: false
43
+ });
44
+ }
45
+ </script>
46
+
47
+ <section
48
+ aria-live="polite"
49
+ aria-label="Notifications"
50
+ >
51
+ {#each toastContext.toasts as toast (toast.id)}
52
+ <Toast
53
+ {toast}
54
+ copy={() => {
55
+ copyDataToClipboard(toast.getVerbose?.() ?? toast.message);
56
+ }}
57
+ />
58
+ {/each}
59
+ </section>
60
+
65
61
  <style>section {
66
62
  user-select: none;
67
63
  gap: 0.5rem;
@@ -73,4 +69,4 @@ not render this directly.
73
69
  justify-content: flex-end;
74
70
  align-items: flex-end;
75
71
  z-index: 99999;
76
- }</style>
72
+ }</style>
@@ -1,39 +1,38 @@
1
- <svelte:options runes />
2
-
3
- <!--
4
- @component
5
- Visual host for `TooltipContext`. Renders a fixed-position tooltip at
6
- the coordinates the context exposes, with a CSS arrow that points
7
- back toward the anchored element on the configured side.
8
-
9
- The tooltip just appears and disappears; no transition is applied,
10
- which is the conservative choice for `prefers-reduced-motion`. Reads
11
- the context with `getContext` and relies on `ContextWrapper` to have
12
- set it up at the app root.
13
- -->
14
- <script lang="ts">
15
- import { TooltipContext } from '../../Contexts/TooltipContext.svelte.js';
16
- import { Side } from '../../Types/Internal/Side.js';
17
- import { getContext } from 'svelte';
18
- const tooltipContext = getContext<TooltipContext>(TooltipContext.identifier);
19
- </script>
20
-
21
- {#if tooltipContext.isShowingTooltip}
22
- <div
23
- role="tooltip"
24
- style="--y: {tooltipContext.y}px; --x: {tooltipContext.x}px;"
25
- class="tooltip-wrapper"
26
- class:top-arrow={tooltipContext.anchor === Side.Top}
27
- class:bottom-arrow={tooltipContext.anchor === Side.Bottom}
28
- class:left-arrow={tooltipContext.anchor === Side.Left}
29
- class:right-arrow={tooltipContext.anchor === Side.Right}
30
- >
31
- <div class="tooltip">
32
- {tooltipContext.text}
33
- </div>
34
- </div>
35
- {/if}
36
-
1
+ <svelte:options runes />
2
+
3
+ <!--
4
+ @component
5
+ Visual host for `TooltipContext`. Renders a fixed-position tooltip at
6
+ the coordinates the context exposes, with a CSS arrow that points
7
+ back toward the anchored element on the configured side.
8
+
9
+ The tooltip just appears and disappears; no transition is applied,
10
+ which is the conservative choice for `prefers-reduced-motion`. Reads
11
+ the context with `getContext` and relies on `ContextWrapper` to have
12
+ set it up at the app root.
13
+ -->
14
+ <script lang="ts">import { TooltipContext } from "../../Contexts/TooltipContext.svelte.js";
15
+ import { Side } from "../../Types/Internal/Side.js";
16
+ import { getContext } from "svelte";
17
+ const tooltipContext = getContext(TooltipContext.identifier);
18
+ </script>
19
+
20
+ {#if tooltipContext.isShowingTooltip}
21
+ <div
22
+ role="tooltip"
23
+ style="--y: {tooltipContext.y}px; --x: {tooltipContext.x}px;"
24
+ class="tooltip-wrapper"
25
+ class:top-arrow={tooltipContext.anchor === Side.Top}
26
+ class:bottom-arrow={tooltipContext.anchor === Side.Bottom}
27
+ class:left-arrow={tooltipContext.anchor === Side.Left}
28
+ class:right-arrow={tooltipContext.anchor === Side.Right}
29
+ >
30
+ <div class="tooltip">
31
+ {tooltipContext.text}
32
+ </div>
33
+ </div>
34
+ {/if}
35
+
37
36
  <style>.tooltip-wrapper {
38
37
  position: fixed;
39
38
  z-index: 99999;
@@ -123,4 +122,4 @@ set it up at the app root.
123
122
  transform: rotate(45deg);
124
123
  background-color: #3a4952;
125
124
  border: solid 2px #dae0e5;
126
- }</style>
125
+ }</style>
@@ -1,114 +1,101 @@
1
- <svelte:options runes />
2
-
3
- <script lang="ts">
4
- import { passthrough } from '../Helpers/Helpers.svelte.js';
5
- import type { DataMatrixIconProps } from './DataMatrixIconProps.js';
6
- import Icon from './Icon.svelte';
7
-
8
- const {
9
- icon,
10
- interactive = false,
11
- title,
12
- oncontextmenu,
13
- ariaLabel = 'Edit Barcode Value',
14
- }: DataMatrixIconProps = $props();
15
-
16
- let svgContainer = $state<HTMLDivElement | null>(null);
17
-
18
- // Track the last SVG we mounted so the effect only re-runs when the
19
- // underlying SVG identity changes. Repeated parent renders that hand
20
- // back the same node should NOT force a DOM replacement; each replace
21
- // forces layout, which becomes expensive with many barcodes on a screen.
22
- let lastSvg: SVGSVGElement | undefined = undefined;
23
-
24
- /**
25
- * Defensively sanitise the SVG before mounting it.
26
- *
27
- * SECURITY: although the prop is branded `DataMatrixSvg` to discourage
28
- * arbitrary callers, the brand is type-only. As defence in depth we
29
- * strip `<script>` nodes plus any `on*` / `href` / `xlink:href`
30
- * attributes from the cloned tree before it enters the document. This
31
- * neutralises stored-XSS sinks (`<script>`, `<image href="javascript:...">`,
32
- * inline event handlers) without depending on caller discipline.
33
- */
34
- function sanitiseSvg(node: SVGSVGElement): void {
35
- node.querySelectorAll('script').forEach((s) => {
36
- s.remove();
37
- });
38
- node.querySelectorAll('*').forEach((el) => {
39
- for (const attr of [...el.attributes]) {
40
- const lower = attr.name.toLowerCase();
41
- if (lower.startsWith('on') || lower === 'href' || lower === 'xlink:href') {
42
- el.removeAttribute(attr.name);
43
- }
44
- }
45
- });
46
- }
47
-
48
- $effect(() => {
49
- if (icon.kind !== 'svg') {
50
- // icon-props branch renders an <Icon> below; nothing for the
51
- // SVG mount effect to do, and we clear the stale mount so a
52
- // later toggle back to kind: 'svg' re-mounts correctly.
53
- if (svgContainer != null && lastSvg !== undefined) {
54
- // Mirror of the mount path below; `replaceChildren()` is the
55
- // cheapest way to detach the previously cloned SVG.
56
- // eslint-disable-next-line svelte/no-dom-manipulating
57
- svgContainer.replaceChildren();
58
- lastSvg = undefined;
1
+ <svelte:options runes />
2
+
3
+ <script lang="ts">import { passthrough } from "../Helpers/Helpers.svelte.js";
4
+ import Icon from "./Icon.svelte";
5
+ const { icon, interactive = false, title, oncontextmenu, ariaLabel = "Edit Barcode Value" } = $props();
6
+ let svgContainer = $state(null);
7
+ // Track the last SVG we mounted so the effect only re-runs when the
8
+ // underlying SVG identity changes. Repeated parent renders that hand
9
+ // back the same node should NOT force a DOM replacement; each replace
10
+ // forces layout, which becomes expensive with many barcodes on a screen.
11
+ let lastSvg = undefined;
12
+ /**
13
+ * Defensively sanitise the SVG before mounting it.
14
+ *
15
+ * SECURITY: although the prop is branded `DataMatrixSvg` to discourage
16
+ * arbitrary callers, the brand is type-only. As defence in depth we
17
+ * strip `<script>` nodes plus any `on*` / `href` / `xlink:href`
18
+ * attributes from the cloned tree before it enters the document. This
19
+ * neutralises stored-XSS sinks (`<script>`, `<image href="javascript:...">`,
20
+ * inline event handlers) without depending on caller discipline.
21
+ */
22
+ function sanitiseSvg(node) {
23
+ node.querySelectorAll("script").forEach((s) => {
24
+ s.remove();
25
+ });
26
+ node.querySelectorAll("*").forEach((el) => {
27
+ for (const attr of [...el.attributes]) {
28
+ const lower = attr.name.toLowerCase();
29
+ if (lower.startsWith("on") || lower === "href" || lower === "xlink:href") {
30
+ el.removeAttribute(attr.name);
59
31
  }
60
- return;
61
32
  }
62
- const source = icon.svg;
63
- if (svgContainer != null && source !== lastSvg) {
64
- // Clone so we never mutate the consumer-supplied node. If the
65
- // same SVG is rendered into multiple DataMatrixIcon instances or
66
- // reused elsewhere the original keeps its original attributes.
67
- const local = source.cloneNode(true) as SVGSVGElement;
68
- sanitiseSvg(local);
69
- local.setAttribute('width', '64');
70
- local.setAttribute('height', '64');
71
- // `replaceChildren` is cheaper than `innerHTML = ''` + `appendChild`:
72
- // it skips the HTML parse step and only touches the child list.
33
+ });
34
+ }
35
+ $effect(() => {
36
+ if (icon.kind !== "svg") {
37
+ // icon-props branch renders an <Icon> below; nothing for the
38
+ // SVG mount effect to do, and we clear the stale mount so a
39
+ // later toggle back to kind: 'svg' re-mounts correctly.
40
+ if (svgContainer != null && lastSvg !== undefined) {
41
+ // Mirror of the mount path below; `replaceChildren()` is the
42
+ // cheapest way to detach the previously cloned SVG.
73
43
  // eslint-disable-next-line svelte/no-dom-manipulating
74
- svgContainer.replaceChildren(local);
75
- lastSvg = source;
44
+ svgContainer.replaceChildren();
45
+ lastSvg = undefined;
76
46
  }
77
- });
78
- </script>
79
-
80
- {#if interactive}
81
- <button
82
- aria-label={ariaLabel}
83
- onkeydown={passthrough}
84
- title="Right click to edit barcode value for the {title} command"
85
- oncontextmenu={(e) => {
86
- if (oncontextmenu) {
87
- e.preventDefault();
88
- oncontextmenu(e);
89
- }
90
- }}
91
- >
92
- <div
93
- class="fit"
94
- bind:this={svgContainer}
95
- >
96
- {#if icon.kind === 'icon-props'}
97
- <Icon {...icon.iconProps} />
98
- {/if}
99
- </div>
100
- </button>
101
- {:else}
102
- <div
103
- class="fit"
104
- bind:this={svgContainer}
105
- >
106
- {#if icon.kind === 'icon-props'}
107
- <Icon {...icon.iconProps} />
108
- {/if}
109
- </div>
110
- {/if}
111
-
47
+ return;
48
+ }
49
+ const source = icon.svg;
50
+ if (svgContainer != null && source !== lastSvg) {
51
+ // Clone so we never mutate the consumer-supplied node. If the
52
+ // same SVG is rendered into multiple DataMatrixIcon instances or
53
+ // reused elsewhere the original keeps its original attributes.
54
+ const local = source.cloneNode(true);
55
+ sanitiseSvg(local);
56
+ local.setAttribute("width", "64");
57
+ local.setAttribute("height", "64");
58
+ // `replaceChildren` is cheaper than `innerHTML = ''` + `appendChild`:
59
+ // it skips the HTML parse step and only touches the child list.
60
+ // eslint-disable-next-line svelte/no-dom-manipulating
61
+ svgContainer.replaceChildren(local);
62
+ lastSvg = source;
63
+ }
64
+ });
65
+ </script>
66
+
67
+ {#if interactive}
68
+ <button
69
+ aria-label={ariaLabel}
70
+ onkeydown={passthrough}
71
+ title="Right click to edit barcode value for the {title} command"
72
+ oncontextmenu={(e) => {
73
+ if (oncontextmenu) {
74
+ e.preventDefault();
75
+ oncontextmenu(e);
76
+ }
77
+ }}
78
+ >
79
+ <div
80
+ class="fit"
81
+ bind:this={svgContainer}
82
+ >
83
+ {#if icon.kind === 'icon-props'}
84
+ <Icon {...icon.iconProps} />
85
+ {/if}
86
+ </div>
87
+ </button>
88
+ {:else}
89
+ <div
90
+ class="fit"
91
+ bind:this={svgContainer}
92
+ >
93
+ {#if icon.kind === 'icon-props'}
94
+ <Icon {...icon.iconProps} />
95
+ {/if}
96
+ </div>
97
+ {/if}
98
+
112
99
  <style>button {
113
100
  display: contents;
114
101
  cursor: pointer;
@@ -118,4 +105,4 @@ div.fit {
118
105
  background-color: #ffffff;
119
106
  display: flex;
120
107
  padding: 0.5rem;
121
- }</style>
108
+ }</style>