@lavalogic/scoria 0.37.44 → 0.37.46

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 (239) hide show
  1. package/README.md +58 -58
  2. package/dist/Components/AccordionGroup.svelte +46 -46
  3. package/dist/Components/AccordionGroupButton.svelte +76 -76
  4. package/dist/Components/Action.svelte +136 -136
  5. package/dist/Components/ActionProps.d.ts +2 -6
  6. package/dist/Components/AlertModal.svelte +195 -183
  7. package/dist/Components/AppointmentCalendar/AppointmentCalendar.svelte +702 -702
  8. package/dist/Components/Base/BaseModal.svelte +125 -125
  9. package/dist/Components/Base/ContextWrapper.svelte +72 -72
  10. package/dist/Components/Base/Pagination.svelte +198 -198
  11. package/dist/Components/Base/Snippets.svelte +36 -36
  12. package/dist/Components/BigRadioSet.svelte +38 -38
  13. package/dist/Components/Bubble.svelte +101 -101
  14. package/dist/Components/Button.svelte +209 -209
  15. package/dist/Components/ButtonProps.d.ts +2 -6
  16. package/dist/Components/Checkbox.svelte +86 -86
  17. package/dist/Components/CollapsibleCard.svelte +78 -78
  18. package/dist/Components/Contexts/ContextMenu.svelte +164 -164
  19. package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
  20. package/dist/Components/Contexts/ContextMenuOption.svelte +60 -60
  21. package/dist/Components/Contexts/Toast.svelte +86 -83
  22. package/dist/Components/Contexts/Toast.svelte.d.ts +8 -5
  23. package/dist/Components/Contexts/ToastContainer.svelte +65 -65
  24. package/dist/Components/Contexts/Tooltip.svelte +37 -37
  25. package/dist/Components/DataMatrixIcon.svelte +112 -112
  26. package/dist/Components/DataMatrixIconProps.d.ts +3 -13
  27. package/dist/Components/DateInput.svelte +148 -148
  28. package/dist/Components/DatePicker.svelte +300 -300
  29. package/dist/Components/DesktopModal.svelte +90 -90
  30. package/dist/Components/Dial.svelte +204 -204
  31. package/dist/Components/DialProps.d.ts +1 -18
  32. package/dist/Components/DimensionInput.svelte +170 -170
  33. package/dist/Components/DragMenu/DragMenuHolder.svelte +119 -119
  34. package/dist/Components/DragMenu/DraggableCard.svelte +77 -77
  35. package/dist/Components/FileCard.svelte +24 -24
  36. package/dist/Components/FileUpload.svelte +236 -236
  37. package/dist/Components/GridInput.svelte +196 -200
  38. package/dist/Components/GridInputSet.svelte +29 -29
  39. package/dist/Components/HorizontalTabGroup.svelte +82 -82
  40. package/dist/Components/HorizontalTabGroupButton.svelte +44 -44
  41. package/dist/Components/Icon.svelte +128 -128
  42. package/dist/Components/IconProps.d.ts +2 -7
  43. package/dist/Components/Icons.js +357 -357
  44. package/dist/Components/LoadingAnimation.svelte +29 -29
  45. package/dist/Components/LoadingModal.svelte +45 -45
  46. package/dist/Components/LoadingOverlay.svelte +25 -25
  47. package/dist/Components/LoadingOverlayProps.d.ts +3 -7
  48. package/dist/Components/Modal.svelte +258 -258
  49. package/dist/Components/ModalProps.d.ts +0 -3
  50. package/dist/Components/MultiSelect.svelte +220 -220
  51. package/dist/Components/MultiSelectCommonProps.d.ts +6 -17
  52. package/dist/Components/Nav/Nav.svelte +110 -99
  53. package/dist/Components/Nav/NavProps.d.ts +4 -11
  54. package/dist/Components/Nav/NavServiceMenuList.svelte +43 -43
  55. package/dist/Components/Nav/NavTab.svelte +62 -62
  56. package/dist/Components/Nav/ServiceMenuItem.svelte +100 -100
  57. package/dist/Components/Nav/ServicesNav.svelte +80 -80
  58. package/dist/Components/NumberInput.svelte +157 -157
  59. package/dist/Components/PageHeading.svelte +25 -25
  60. package/dist/Components/PasswordInput.svelte +88 -88
  61. package/dist/Components/Portal.svelte +36 -36
  62. package/dist/Components/ProgressBubble.svelte +107 -108
  63. package/dist/Components/ProgressBubbleProps.d.ts +3 -3
  64. package/dist/Components/QuerySelect.svelte +366 -366
  65. package/dist/Components/QuerySelectProps.d.ts +4 -14
  66. package/dist/Components/SingleSelect.svelte +250 -250
  67. package/dist/Components/SingleSelectCommonProps.d.ts +3 -19
  68. package/dist/Components/StepButton.svelte +70 -70
  69. package/dist/Components/StepForm.svelte +140 -140
  70. package/dist/Components/Switch.svelte +69 -69
  71. package/dist/Components/Table/ARCHITECTURE.md +298 -0
  72. package/dist/Components/Table/Body/QuickSearchCell.svelte +683 -694
  73. package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +51 -51
  74. package/dist/Components/Table/Body/Rows/ColumnList.svelte +59 -59
  75. package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +456 -478
  76. package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +79 -79
  77. package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +185 -188
  78. package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +124 -124
  79. package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +120 -120
  80. package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +230 -230
  81. package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +105 -105
  82. package/dist/Components/Table/Body/Rows/Columns/SelectColumn.d.ts +12 -9
  83. package/dist/Components/Table/Body/Rows/Columns/SelectTableCell.d.ts +5 -5
  84. package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +87 -87
  85. package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +126 -126
  86. package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +159 -159
  87. package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +246 -246
  88. package/dist/Components/Table/Body/Rows/Columns/TableDatePickerProps.d.ts +4 -4
  89. package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +216 -216
  90. package/dist/Components/Table/Body/Rows/Columns/TableQueryCell.d.ts +6 -5
  91. package/dist/Components/Table/Body/Rows/Columns/TableQueryColumn.d.ts +7 -6
  92. package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +252 -257
  93. package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +179 -179
  94. package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +221 -229
  95. package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte.d.ts +11 -11
  96. package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +197 -197
  97. package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +190 -190
  98. package/dist/Components/Table/Body/Rows/TableRow.svelte +290 -290
  99. package/dist/Components/Table/Body/TableBody.svelte +155 -155
  100. package/dist/Components/Table/ColumnDefinitions/ExampleItemColumnDefRepository.svelte.js +2 -3
  101. package/dist/Components/Table/ColumnFactory.svelte.d.ts +9 -11
  102. package/dist/Components/Table/ColumnFactory.svelte.js +110 -143
  103. package/dist/Components/Table/ColumnKindRegistry.d.ts +112 -0
  104. package/dist/Components/Table/ColumnKindRegistry.js +63 -0
  105. package/dist/Components/Table/Headers/HighlightAllHeader.svelte +41 -41
  106. package/dist/Components/Table/Headers/SelectAllHeader.svelte +30 -30
  107. package/dist/Components/Table/Headers/TableHead.svelte +415 -413
  108. package/dist/Components/Table/Misc/ColumnPanel.svelte +94 -94
  109. package/dist/Components/Table/Misc/ColumnPanelModal.svelte +112 -112
  110. package/dist/Components/Table/Misc/FilterInput.svelte +620 -644
  111. package/dist/Components/Table/Misc/FilterInput.svelte.d.ts +12 -12
  112. package/dist/Components/Table/Misc/FilterInputProps.d.ts +2 -2
  113. package/dist/Components/Table/Misc/FilterPanel.svelte +257 -257
  114. package/dist/Components/Table/Misc/FilterPanelModal.svelte +30 -30
  115. package/dist/Components/Table/Misc/SidePanel.svelte +35 -35
  116. package/dist/Components/Table/Misc/TableFooter.svelte +311 -311
  117. package/dist/Components/Table/Misc/TableHorizontalBar.svelte +125 -125
  118. package/dist/Components/Table/Misc/TableSidebar.svelte +157 -157
  119. package/dist/Components/Table/Misc/ToolboxPanel.svelte +100 -100
  120. package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +107 -107
  121. package/dist/Components/Table/NestedTable.svelte +130 -133
  122. package/dist/Components/Table/SubApis.svelte.d.ts +1 -5
  123. package/dist/Components/Table/SubApis.svelte.js +33 -32
  124. package/dist/Components/Table/Table.svelte +692 -745
  125. package/dist/Components/Table/TableHelpers.svelte.d.ts +6 -19
  126. package/dist/Components/Table/TableHelpers.svelte.js +6 -14
  127. package/dist/Components/Table/Types/Columns/Column.d.ts +2 -2
  128. package/dist/Components/Table/Types/Columns/DateColumn.d.ts +3 -3
  129. package/dist/Components/Table/Types/Columns/DateTableCell.d.ts +7 -7
  130. package/dist/Components/Table/Types/Columns/Definitions/Accessors/AccessorDef.svelte.d.ts +7 -8
  131. package/dist/Components/Table/Types/Columns/Definitions/Accessors/AccessorDef.svelte.js +4 -5
  132. package/dist/Components/Table/Types/Columns/Definitions/Accessors/CheckboxDef.svelte.d.ts +11 -14
  133. package/dist/Components/Table/Types/Columns/Definitions/Accessors/CheckboxDef.svelte.js +3 -4
  134. package/dist/Components/Table/Types/Columns/Definitions/Accessors/DateInputDef.svelte.d.ts +7 -11
  135. package/dist/Components/Table/Types/Columns/Definitions/Accessors/DateInputDef.svelte.js +3 -3
  136. package/dist/Components/Table/Types/Columns/Definitions/Accessors/NumberInputDef.svelte.d.ts +13 -18
  137. package/dist/Components/Table/Types/Columns/Definitions/Accessors/NumberInputDef.svelte.js +4 -5
  138. package/dist/Components/Table/Types/Columns/Definitions/Accessors/QueryDef.svelte.d.ts +5 -5
  139. package/dist/Components/Table/Types/Columns/Definitions/Accessors/QueryDef.svelte.js +2 -2
  140. package/dist/Components/Table/Types/Columns/Definitions/Accessors/SelectDef.svelte.d.ts +15 -12
  141. package/dist/Components/Table/Types/Columns/Definitions/Accessors/SelectDef.svelte.js +4 -5
  142. package/dist/Components/Table/Types/Columns/Definitions/Accessors/TextInputDef.svelte.d.ts +8 -12
  143. package/dist/Components/Table/Types/Columns/Definitions/Accessors/TextInputDef.svelte.js +3 -3
  144. package/dist/Components/Table/Types/Columns/Definitions/Actions/ActionsDef.svelte.d.ts +6 -6
  145. package/dist/Components/Table/Types/Columns/Definitions/Actions/ActionsDef.svelte.js +3 -3
  146. package/dist/Components/Table/Types/Columns/Definitions/ColumnDef.svelte.d.ts +49 -16
  147. package/dist/Components/Table/Types/Columns/Definitions/ColumnDef.svelte.js +27 -5
  148. package/dist/Components/Table/Types/Columns/Definitions/Display/AbstractDisplayDef.svelte.d.ts +7 -7
  149. package/dist/Components/Table/Types/Columns/Definitions/Display/AbstractDisplayDef.svelte.js +4 -4
  150. package/dist/Components/Table/Types/Columns/Definitions/Display/BubbleDef.svelte.d.ts +5 -5
  151. package/dist/Components/Table/Types/Columns/Definitions/Display/BubbleDef.svelte.js +2 -2
  152. package/dist/Components/Table/Types/Columns/Definitions/Display/DisplayDef.svelte.d.ts +5 -5
  153. package/dist/Components/Table/Types/Columns/Definitions/Display/DisplayDef.svelte.js +2 -2
  154. package/dist/Components/Table/Types/Columns/Definitions/Display/ProgressBarDef.svelte.d.ts +5 -5
  155. package/dist/Components/Table/Types/Columns/Definitions/Display/ProgressBarDef.svelte.js +2 -2
  156. package/dist/Components/Table/Types/Columns/Definitions/Display/ValidityDef.svelte.d.ts +5 -5
  157. package/dist/Components/Table/Types/Columns/Definitions/Display/ValidityDef.svelte.js +2 -2
  158. package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.d.ts +11 -19
  159. package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.js +4 -8
  160. package/dist/Components/Table/Types/Columns/Definitions/FilterOnly/FilterOnlyDef.svelte.d.ts +6 -7
  161. package/dist/Components/Table/Types/Columns/Definitions/FilterOnly/FilterOnlyDef.svelte.js +3 -4
  162. package/dist/Components/Table/Types/Columns/Definitions/RowSelection/RowSelectionDef.svelte.d.ts +9 -9
  163. package/dist/Components/Table/Types/Columns/Definitions/RowSelection/RowSelectionDef.svelte.js +4 -4
  164. package/dist/Components/Table/Types/Columns/ExpandTableCell.d.ts +5 -5
  165. package/dist/Components/Table/Types/Columns/ProgressBarTableCell.d.ts +6 -6
  166. package/dist/Components/Table/Types/Columns/TableCell.d.ts +7 -6
  167. package/dist/Components/Table/Types/Context/ClipboardState.svelte.d.ts +98 -0
  168. package/dist/Components/Table/Types/Context/ClipboardState.svelte.js +290 -0
  169. package/dist/Components/Table/Types/Context/ColumnLayoutState.svelte.d.ts +17 -45
  170. package/dist/Components/Table/Types/Context/ColumnLayoutState.svelte.js +17 -45
  171. package/dist/Components/Table/Types/Context/FilteringState.svelte.d.ts +9 -20
  172. package/dist/Components/Table/Types/Context/FilteringState.svelte.js +9 -20
  173. package/dist/Components/Table/Types/Context/FocusState.svelte.d.ts +23 -42
  174. package/dist/Components/Table/Types/Context/FocusState.svelte.js +32 -59
  175. package/dist/Components/Table/Types/Context/ITable.d.ts +5 -8
  176. package/dist/Components/Table/Types/Context/PreferencesState.svelte.d.ts +29 -56
  177. package/dist/Components/Table/Types/Context/PreferencesState.svelte.js +28 -55
  178. package/dist/Components/Table/Types/Context/QueryValuesState.svelte.d.ts +50 -0
  179. package/dist/Components/Table/Types/Context/QueryValuesState.svelte.js +62 -0
  180. package/dist/Components/Table/Types/Context/SelectionState.svelte.d.ts +17 -28
  181. package/dist/Components/Table/Types/Context/SelectionState.svelte.js +17 -28
  182. package/dist/Components/Table/Types/Context/SortingState.svelte.d.ts +15 -29
  183. package/dist/Components/Table/Types/Context/SortingState.svelte.js +17 -31
  184. package/dist/Components/Table/Types/Context/TableContext.svelte.d.ts +212 -325
  185. package/dist/Components/Table/Types/Context/TableContext.svelte.js +292 -706
  186. package/dist/Components/Table/Types/Context/VirtualisationState.svelte.d.ts +62 -79
  187. package/dist/Components/Table/Types/Context/VirtualisationState.svelte.js +54 -73
  188. package/dist/Components/Table/Types/DataRepository/BuiltInRemoteRepository.svelte.d.ts +16 -27
  189. package/dist/Components/Table/Types/DataRepository/BuiltInRemoteRepository.svelte.js +16 -27
  190. package/dist/Components/Table/Types/DataRepository/IDataRepository.d.ts +12 -15
  191. package/dist/Components/Table/Types/DataRepository/TableDataRepository.svelte.d.ts +15 -30
  192. package/dist/Components/Table/Types/DataRepository/TableDataRepository.svelte.js +16 -28
  193. package/dist/Components/Table/Types/Header.d.ts +4 -4
  194. package/dist/Components/Table/Types/HeaderGroup.d.ts +5 -5
  195. package/dist/Components/Table/Types/Public/index.d.ts +2 -4
  196. package/dist/Components/Table/Types/Public/index.js +2 -4
  197. package/dist/Components/Table/clipboardEscape.d.ts +32 -0
  198. package/dist/Components/Table/clipboardEscape.js +45 -0
  199. package/dist/Components/Table/createTable.svelte.d.ts +8 -18
  200. package/dist/Components/Table/createTable.svelte.js +19 -47
  201. package/dist/Components/Test/TestContextConsumer.svelte +13 -13
  202. package/dist/Components/TextArea.svelte +130 -130
  203. package/dist/Components/TextInput.svelte +176 -176
  204. package/dist/Components/ThreeStateRadio.svelte +131 -131
  205. package/dist/Components/Touch/BoolCard.svelte +45 -45
  206. package/dist/Components/Touch/DateModal.svelte +209 -209
  207. package/dist/Components/Touch/EditCard.svelte +59 -59
  208. package/dist/Components/Touch/InfoCard.svelte +31 -31
  209. package/dist/Components/Touch/InfoTextCard.svelte +28 -28
  210. package/dist/Components/Touch/ModalExplanation.svelte +17 -17
  211. package/dist/Components/Touch/NumberKeyboard.svelte +225 -225
  212. package/dist/Components/Touch/NumberModal.svelte +79 -79
  213. package/dist/Components/Touch/PlusMinusCard.svelte +46 -46
  214. package/dist/Components/Touch/SelectModal.svelte +123 -123
  215. package/dist/Components/Touch/SummaryCard.svelte +93 -93
  216. package/dist/Components/Touch/TextAreaModal.svelte +95 -95
  217. package/dist/Components/Touch/TextModal.svelte +106 -106
  218. package/dist/Components/Touch/TouchCard.svelte +33 -33
  219. package/dist/Components/Touch/TouchModal.svelte +274 -274
  220. package/dist/Components/Touch/UtilityButton.svelte +109 -109
  221. package/dist/Components/VerticalTabGroup.svelte +79 -79
  222. package/dist/Components/VerticalTabGroupButton.svelte +58 -58
  223. package/dist/Contexts/ToastContext.svelte.js +3 -4
  224. package/dist/Helpers/Datamatrix.d.ts +19 -19
  225. package/dist/Helpers/Datamatrix.js +291 -291
  226. package/dist/Helpers/Helpers.svelte.d.ts +47 -4
  227. package/dist/Helpers/Helpers.svelte.js +97 -4
  228. package/dist/Helpers/dropdownPortal.d.ts +26 -41
  229. package/dist/Helpers/dropdownPortal.js +62 -116
  230. package/dist/Types/Examples/ExampleModal.svelte +35 -35
  231. package/dist/index.d.ts +1 -2
  232. package/dist/index.js +1 -1
  233. package/dist/scss/_basics.scss +12 -12
  234. package/dist/scss/_colours.scss +134 -134
  235. package/dist/scss/_mixins.scss +3358 -3360
  236. package/dist/scss/_motion.scss +57 -57
  237. package/dist/scss/_sizing.scss +85 -85
  238. package/dist/scss/_transitions.scss +8 -8
  239. package/package.json +8 -6
@@ -1,114 +1,114 @@
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;
59
- }
60
- return;
61
- }
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.
73
- // eslint-disable-next-line svelte/no-dom-manipulating
74
- svgContainer.replaceChildren(local);
75
- lastSvg = source;
76
- }
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
-
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;
59
+ }
60
+ return;
61
+ }
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.
73
+ // eslint-disable-next-line svelte/no-dom-manipulating
74
+ svgContainer.replaceChildren(local);
75
+ lastSvg = source;
76
+ }
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
+
112
112
  <style>button {
113
113
  display: contents;
114
114
  cursor: pointer;
@@ -118,4 +118,4 @@ div.fit {
118
118
  background-color: #ffffff;
119
119
  display: flex;
120
120
  padding: 0.5rem;
121
- }</style>
121
+ }</style>
@@ -27,11 +27,6 @@ export type DataMatrixSvg = SVGSVGElement & {
27
27
  * icon path bypasses the SVG sanitiser; only use it with statically
28
28
  * declared `PartialIconProps` values, never with user-derived input.
29
29
  *
30
- * Phase 7.7 (BREAKING): introduced as a defensive widening. The previous
31
- * single-shape `icon: DataMatrixSvg` prop was deferred in Phase 5; the
32
- * discriminator lands now so future consumers can opt into the
33
- * icon-props path without another breaking change. Existing call sites
34
- * migrate from `icon={svg}` to `icon={{ kind: 'svg', svg }}`.
35
30
  */
36
31
  export type DataMatrixIconInput = {
37
32
  kind: 'svg';
@@ -53,14 +48,9 @@ export type DataMatrixIconInput = {
53
48
  */
54
49
  export interface DataMatrixIconProps {
55
50
  /**
56
- * Discriminated icon input. Pass `{ kind: 'svg', svg }` for the
57
- * traditional barcode path (output of `DATAMatrix()`), or
58
- * `{ kind: 'icon-props', iconProps }` to render a placeholder
59
- * {@link Icon} instead.
60
- *
61
- * BREAKING (Phase 7.7): was `DataMatrixSvg`; now the discriminated
62
- * `DataMatrixIconInput`. Migrate by wrapping existing SVG values:
63
- * `icon={svg}` -> `icon={{ kind: 'svg', svg }}`.
51
+ * Discriminated icon input. Pass `{ kind: 'svg', svg }` for the barcode
52
+ * path (output of `DATAMatrix()`), or `{ kind: 'icon-props', iconProps }`
53
+ * to render an {@link Icon} placeholder instead.
64
54
  */
65
55
  icon: DataMatrixIconInput;
66
56
  /** When true, render inside a `<button>` and forward right-click via `oncontextmenu`. */
@@ -1,150 +1,150 @@
1
- <svelte:options runes />
2
-
3
- <script
4
- lang="ts"
5
- module
6
- >
7
- import { cssLength, passthrough } from '../Helpers/Helpers.svelte.js';
8
- import { InputVariant } from '../Types/Internal/InputVariant.js';
9
- import { Size } from '../Types/Internal/Size.js';
10
- import type { DateInputProps } from './DateInputProps.js';
11
- import Icon from './Icon.svelte';
12
-
13
- function openPicker(ref: HTMLInputElement | undefined): void {
14
- ref?.showPicker();
15
- }
16
-
17
- function submitAncestorForm(e: KeyboardEvent): void {
18
- if (e.key !== 'Enter') {
19
- return;
20
- }
21
- e.preventDefault();
22
- const target = e.target as HTMLElement | undefined;
23
- const form = target?.closest('form') as HTMLFormElement | undefined;
24
- form?.requestSubmit();
25
- }
26
- </script>
27
-
28
- <script lang="ts">
29
- let {
30
- value = $bindable(''),
31
- label,
32
- placeholder,
33
- required = false,
34
- optional,
35
- variant = InputVariant.Default,
36
- min,
37
- max,
38
- type,
39
- disabled,
40
- leftIcon,
41
- rightIcon,
42
- inputRef = $bindable(),
43
- invalid,
44
- onblur,
45
- onfocus,
46
- onchange,
47
- }: DateInputProps = $props();
48
-
49
- // Null-safe: a fresh `<DateInput>` with no value passes `value=null`
50
- // through the prop. The old `value.trim()` crashed with "Cannot read
51
- // properties of null (reading 'trim')" the moment a required, empty
52
- // DateInput rendered inside e.g. the Order Details collapsible card.
53
- const isInvalid = $derived((required && !value?.trim()) || invalid);
54
-
55
- function onkeydown(e: KeyboardEvent): void {
56
- if (e.key === 'Enter') {
57
- submitAncestorForm(e);
58
- return;
59
- }
60
- passthrough(e);
61
- }
62
-
63
- function ondblclick(): void {
64
- openPicker(inputRef);
65
- }
66
-
67
- function onauxclick(e: MouseEvent): void {
68
- e.preventDefault();
69
- openPicker(inputRef);
70
- }
71
-
72
- function handleChange(e: Event): void {
73
- const next = (e.target as HTMLInputElement).value;
74
- void onchange?.(next === '' ? null : (next as never));
75
- }
76
- </script>
77
-
78
- <div
79
- class="error-wrapper"
80
- class:for-modal={variant == InputVariant.Modal}
81
- class:for-table={variant == InputVariant.Table}
82
- >
83
- <label class:for-modal={variant == InputVariant.Modal}>
84
- {#if label}
85
- <span
86
- class="top-label"
87
- class:for-default={variant === InputVariant.Default}
88
- class:invalid={isInvalid}
89
- >{label}{#if optional}<i>&nbsp;- optional</i>{/if}</span
90
- >
91
- {#if variant === InputVariant.Default}
92
- <span
93
- aria-hidden="true"
94
- class="border"
95
- class:invalid={isInvalid}
96
- >{label}{#if optional}<i>&nbsp;- optional</i>{/if}</span
97
- >
98
- {/if}
99
- {/if}
100
- <div class="icon-container">
101
- {#if leftIcon}
102
- <Icon
103
- name={leftIcon.name}
104
- size={leftIcon.size ?? Size.Medium}
105
- float
106
- left={cssLength('0.75rem')}
107
- top={cssLength('50%')}
108
- anchorX={cssLength('0')}
109
- anchorY={cssLength('-50%')}
110
- />
111
- {/if}
112
- <input
113
- step={type === 'datetime-local' ? 1 : 'any'}
114
- class:invalid={isInvalid}
115
- class:left-pad={leftIcon != undefined}
116
- class:right-pad={rightIcon != undefined}
117
- aria-invalid={isInvalid || undefined}
118
- {type}
119
- bind:value
120
- {onblur}
121
- {onfocus}
122
- {ondblclick}
123
- {onauxclick}
124
- bind:this={inputRef}
125
- {min}
126
- {max}
127
- {placeholder}
128
- {required}
129
- {disabled}
130
- {onkeydown}
131
- onchange={handleChange}
132
- />
133
- {#if rightIcon}
134
- <Icon
135
- name={rightIcon.name}
136
- size={rightIcon.size ?? Size.Medium}
137
- float
138
- right={cssLength('0.5rem')}
139
- top={cssLength('50%')}
140
- anchorX={cssLength('0')}
141
- anchorY={cssLength('-50%')}
142
- />
143
- {/if}
144
- </div>
145
- </label>
146
- </div>
147
-
1
+ <svelte:options runes />
2
+
3
+ <script
4
+ lang="ts"
5
+ module
6
+ >
7
+ import { cssLength, passthrough } from '../Helpers/Helpers.svelte.js';
8
+ import { InputVariant } from '../Types/Internal/InputVariant.js';
9
+ import { Size } from '../Types/Internal/Size.js';
10
+ import type { DateInputProps } from './DateInputProps.js';
11
+ import Icon from './Icon.svelte';
12
+
13
+ function openPicker(ref: HTMLInputElement | undefined): void {
14
+ ref?.showPicker();
15
+ }
16
+
17
+ function submitAncestorForm(e: KeyboardEvent): void {
18
+ if (e.key !== 'Enter') {
19
+ return;
20
+ }
21
+ e.preventDefault();
22
+ const target = e.target as HTMLElement | undefined;
23
+ const form = target?.closest('form') as HTMLFormElement | undefined;
24
+ form?.requestSubmit();
25
+ }
26
+ </script>
27
+
28
+ <script lang="ts">
29
+ let {
30
+ value = $bindable(''),
31
+ label,
32
+ placeholder,
33
+ required = false,
34
+ optional,
35
+ variant = InputVariant.Default,
36
+ min,
37
+ max,
38
+ type,
39
+ disabled,
40
+ leftIcon,
41
+ rightIcon,
42
+ inputRef = $bindable(),
43
+ invalid,
44
+ onblur,
45
+ onfocus,
46
+ onchange,
47
+ }: DateInputProps = $props();
48
+
49
+ // Null-safe: a fresh `<DateInput>` with no value passes `value=null`
50
+ // through the prop. The old `value.trim()` crashed with "Cannot read
51
+ // properties of null (reading 'trim')" the moment a required, empty
52
+ // DateInput rendered inside e.g. the Order Details collapsible card.
53
+ const isInvalid = $derived((required && !value?.trim()) || invalid);
54
+
55
+ function onkeydown(e: KeyboardEvent): void {
56
+ if (e.key === 'Enter') {
57
+ submitAncestorForm(e);
58
+ return;
59
+ }
60
+ passthrough(e);
61
+ }
62
+
63
+ function ondblclick(): void {
64
+ openPicker(inputRef);
65
+ }
66
+
67
+ function onauxclick(e: MouseEvent): void {
68
+ e.preventDefault();
69
+ openPicker(inputRef);
70
+ }
71
+
72
+ function handleChange(e: Event): void {
73
+ const next = (e.target as HTMLInputElement).value;
74
+ void onchange?.(next === '' ? null : (next as never));
75
+ }
76
+ </script>
77
+
78
+ <div
79
+ class="error-wrapper"
80
+ class:for-modal={variant == InputVariant.Modal}
81
+ class:for-table={variant == InputVariant.Table}
82
+ >
83
+ <label class:for-modal={variant == InputVariant.Modal}>
84
+ {#if label}
85
+ <span
86
+ class="top-label"
87
+ class:for-default={variant === InputVariant.Default}
88
+ class:invalid={isInvalid}
89
+ >{label}{#if optional}<i>&nbsp;- optional</i>{/if}</span
90
+ >
91
+ {#if variant === InputVariant.Default}
92
+ <span
93
+ aria-hidden="true"
94
+ class="border"
95
+ class:invalid={isInvalid}
96
+ >{label}{#if optional}<i>&nbsp;- optional</i>{/if}</span
97
+ >
98
+ {/if}
99
+ {/if}
100
+ <div class="icon-container">
101
+ {#if leftIcon}
102
+ <Icon
103
+ name={leftIcon.name}
104
+ size={leftIcon.size ?? Size.Medium}
105
+ float
106
+ left={cssLength('0.75rem')}
107
+ top={cssLength('50%')}
108
+ anchorX={cssLength('0')}
109
+ anchorY={cssLength('-50%')}
110
+ />
111
+ {/if}
112
+ <input
113
+ step={type === 'datetime-local' ? 1 : 'any'}
114
+ class:invalid={isInvalid}
115
+ class:left-pad={leftIcon != undefined}
116
+ class:right-pad={rightIcon != undefined}
117
+ aria-invalid={isInvalid || undefined}
118
+ {type}
119
+ bind:value
120
+ {onblur}
121
+ {onfocus}
122
+ {ondblclick}
123
+ {onauxclick}
124
+ bind:this={inputRef}
125
+ {min}
126
+ {max}
127
+ {placeholder}
128
+ {required}
129
+ {disabled}
130
+ {onkeydown}
131
+ onchange={handleChange}
132
+ />
133
+ {#if rightIcon}
134
+ <Icon
135
+ name={rightIcon.name}
136
+ size={rightIcon.size ?? Size.Medium}
137
+ float
138
+ right={cssLength('0.5rem')}
139
+ top={cssLength('50%')}
140
+ anchorX={cssLength('0')}
141
+ anchorY={cssLength('-50%')}
142
+ />
143
+ {/if}
144
+ </div>
145
+ </label>
146
+ </div>
147
+
148
148
  <style>input {
149
149
  box-sizing: border-box;
150
150
  height: 100%;
@@ -374,4 +374,4 @@ label.for-table {
374
374
  }
375
375
  label.for-table input {
376
376
  height: unset;
377
- }</style>
377
+ }</style>