@lavalogic/scoria 0.39.2 → 0.40.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 (141) 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/AlertModal.svelte +195 -195
  6. package/dist/Components/AppointmentCalendar/AppointmentCalendar.svelte +729 -729
  7. package/dist/Components/Base/BaseModal.svelte +125 -125
  8. package/dist/Components/Base/ContextWrapper.svelte +72 -72
  9. package/dist/Components/Base/Pagination.svelte +198 -198
  10. package/dist/Components/Base/Snippets.svelte +36 -36
  11. package/dist/Components/BigRadioSet.svelte +38 -38
  12. package/dist/Components/Bubble.svelte +101 -101
  13. package/dist/Components/Button.svelte +209 -209
  14. package/dist/Components/Checkbox.svelte +86 -86
  15. package/dist/Components/CollapsibleCard.svelte +78 -78
  16. package/dist/Components/ConditionBuilder/ConditionBuilder.svelte +212 -0
  17. package/dist/Components/ConditionBuilder/ConditionBuilder.svelte.d.ts +25 -0
  18. package/dist/Components/ConditionBuilder/ConditionBuilderProps.d.ts +45 -0
  19. package/dist/Components/ConditionBuilder/ConditionBuilderProps.js +1 -0
  20. package/dist/Components/ConditionBuilder/ConditionTree.d.ts +27 -0
  21. package/dist/Components/ConditionBuilder/ConditionTree.js +9 -0
  22. package/dist/Components/Contexts/ContextMenu.svelte +164 -164
  23. package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
  24. package/dist/Components/Contexts/ContextMenuOption.svelte +60 -60
  25. package/dist/Components/Contexts/Toast.svelte +86 -86
  26. package/dist/Components/Contexts/ToastContainer.svelte +65 -65
  27. package/dist/Components/Contexts/Tooltip.svelte +37 -37
  28. package/dist/Components/DataMatrixIcon.svelte +112 -112
  29. package/dist/Components/DateInput.svelte +148 -148
  30. package/dist/Components/DatePicker.svelte +300 -300
  31. package/dist/Components/DesktopModal.svelte +90 -90
  32. package/dist/Components/Dial.svelte +204 -204
  33. package/dist/Components/DimensionInput.svelte +170 -170
  34. package/dist/Components/DragMenu/DragMenuHolder.svelte +119 -119
  35. package/dist/Components/DragMenu/DraggableCard.svelte +77 -77
  36. package/dist/Components/FileCard.svelte +24 -24
  37. package/dist/Components/FileUpload.svelte +236 -236
  38. package/dist/Components/GridInput.svelte +196 -196
  39. package/dist/Components/GridInputSet.svelte +29 -29
  40. package/dist/Components/HorizontalTabGroup.svelte +82 -82
  41. package/dist/Components/HorizontalTabGroupButton.svelte +44 -44
  42. package/dist/Components/Icon.svelte +128 -128
  43. package/dist/Components/Icons.js +357 -357
  44. package/dist/Components/InfoAlert.svelte +35 -35
  45. package/dist/Components/LoadingAnimation.svelte +29 -29
  46. package/dist/Components/LoadingModal.svelte +45 -45
  47. package/dist/Components/LoadingOverlay.svelte +25 -25
  48. package/dist/Components/Modal.svelte +258 -258
  49. package/dist/Components/MultiSelect.svelte +220 -220
  50. package/dist/Components/Nav/Nav.svelte +110 -110
  51. package/dist/Components/Nav/NavServiceMenuList.svelte +43 -43
  52. package/dist/Components/Nav/NavTab.svelte +62 -62
  53. package/dist/Components/Nav/ServiceMenuItem.svelte +112 -112
  54. package/dist/Components/Nav/ServicesNav.svelte +80 -80
  55. package/dist/Components/NumberInput.svelte +157 -157
  56. package/dist/Components/PageHeading.svelte +25 -25
  57. package/dist/Components/PasswordInput.svelte +88 -88
  58. package/dist/Components/Portal.svelte +36 -36
  59. package/dist/Components/ProgressBubble.svelte +107 -107
  60. package/dist/Components/QuerySelect.svelte +366 -366
  61. package/dist/Components/SingleSelect.svelte +250 -250
  62. package/dist/Components/StepButton.svelte +70 -70
  63. package/dist/Components/StepForm.svelte +140 -140
  64. package/dist/Components/Switch.svelte +69 -69
  65. package/dist/Components/Table/ARCHITECTURE.md +298 -298
  66. package/dist/Components/Table/Body/QuickSearchCell.svelte +679 -679
  67. package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +51 -51
  68. package/dist/Components/Table/Body/Rows/ColumnList.svelte +59 -59
  69. package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +454 -454
  70. package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +79 -79
  71. package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +185 -185
  72. package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +124 -124
  73. package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +120 -120
  74. package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +234 -234
  75. package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +105 -105
  76. package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +87 -87
  77. package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +126 -126
  78. package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +159 -159
  79. package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +246 -246
  80. package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +216 -216
  81. package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +252 -252
  82. package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +179 -179
  83. package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +221 -221
  84. package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +197 -197
  85. package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +190 -190
  86. package/dist/Components/Table/Body/Rows/TableRow.svelte +290 -290
  87. package/dist/Components/Table/Body/TableBody.svelte +155 -155
  88. package/dist/Components/Table/Headers/HighlightAllHeader.svelte +41 -41
  89. package/dist/Components/Table/Headers/SelectAllHeader.svelte +30 -30
  90. package/dist/Components/Table/Headers/TableHead.svelte +415 -415
  91. package/dist/Components/Table/Misc/ColumnPanel.svelte +39 -39
  92. package/dist/Components/Table/Misc/ColumnPanelModal.svelte +39 -39
  93. package/dist/Components/Table/Misc/FilterInput.svelte +641 -641
  94. package/dist/Components/Table/Misc/FilterPanel.svelte +190 -190
  95. package/dist/Components/Table/Misc/FilterPanelModal.svelte +31 -31
  96. package/dist/Components/Table/Misc/ShareViewModal.svelte +291 -291
  97. package/dist/Components/Table/Misc/SidePanel.svelte +35 -35
  98. package/dist/Components/Table/Misc/TableConfigurationModal.svelte +644 -644
  99. package/dist/Components/Table/Misc/TableFooter.svelte +340 -340
  100. package/dist/Components/Table/Misc/TableHorizontalBar.svelte +140 -140
  101. package/dist/Components/Table/Misc/TableSidebar.svelte +200 -200
  102. package/dist/Components/Table/Misc/TableViewDropdown.svelte +105 -105
  103. package/dist/Components/Table/Misc/ToolboxPanel.svelte +100 -100
  104. package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +107 -107
  105. package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte +192 -192
  106. package/dist/Components/Table/NestedTable.svelte +130 -130
  107. package/dist/Components/Table/Table.svelte +692 -692
  108. package/dist/Components/Test/TestContextConsumer.svelte +13 -13
  109. package/dist/Components/TextArea.svelte +130 -130
  110. package/dist/Components/TextInput.svelte +176 -176
  111. package/dist/Components/ThreeStateRadio.svelte +131 -131
  112. package/dist/Components/Touch/BoolCard.svelte +45 -45
  113. package/dist/Components/Touch/DateModal.svelte +209 -209
  114. package/dist/Components/Touch/EditCard.svelte +59 -59
  115. package/dist/Components/Touch/InfoCard.svelte +31 -31
  116. package/dist/Components/Touch/InfoTextCard.svelte +28 -28
  117. package/dist/Components/Touch/ModalExplanation.svelte +17 -17
  118. package/dist/Components/Touch/NumberKeyboard.svelte +225 -225
  119. package/dist/Components/Touch/NumberModal.svelte +79 -79
  120. package/dist/Components/Touch/PlusMinusCard.svelte +46 -46
  121. package/dist/Components/Touch/SelectModal.svelte +127 -127
  122. package/dist/Components/Touch/SummaryCard.svelte +93 -93
  123. package/dist/Components/Touch/TextAreaModal.svelte +95 -95
  124. package/dist/Components/Touch/TextModal.svelte +106 -106
  125. package/dist/Components/Touch/TouchCard.svelte +33 -33
  126. package/dist/Components/Touch/TouchModal.svelte +274 -274
  127. package/dist/Components/Touch/UtilityButton.svelte +109 -109
  128. package/dist/Components/VerticalTabGroup.svelte +79 -79
  129. package/dist/Components/VerticalTabGroupButton.svelte +58 -58
  130. package/dist/Helpers/Datamatrix.d.ts +19 -19
  131. package/dist/Helpers/Datamatrix.js +291 -291
  132. package/dist/Types/Examples/ExampleModal.svelte +35 -35
  133. package/dist/index.d.ts +3 -0
  134. package/dist/index.js +2 -0
  135. package/dist/scss/_basics.scss +12 -12
  136. package/dist/scss/_colours.scss +134 -134
  137. package/dist/scss/_mixins.scss +3392 -3392
  138. package/dist/scss/_motion.scss +57 -57
  139. package/dist/scss/_sizing.scss +85 -85
  140. package/dist/scss/_transitions.scss +8 -8
  141. package/package.json +1 -1
@@ -1,159 +1,159 @@
1
- <svelte:options runes />
2
-
3
- <script lang="ts">
4
- import { cssLength } from '../Helpers/Helpers.svelte.js';
5
- import { InputVariant } from '../Types/Internal/InputVariant.js';
6
- import { Size } from '../Types/Internal/Size.js';
7
- import Icon from './Icon.svelte';
8
- import type { NumberInputProps } from './NumberInputProps.js';
9
- let {
10
- id,
11
- value = $bindable(null),
12
- min,
13
- max,
14
- labelTop,
15
- labelRight,
16
- placeholder,
17
- required = false,
18
- variant = InputVariant.Default,
19
- decimal = false,
20
- invalid = false,
21
- showErrorColours = true,
22
- disabled,
23
- optional,
24
- leftIcon,
25
- rightIcon,
26
- onLeftIconClick,
27
- onRightIconClick,
28
-
29
- onblur,
30
- onfocus,
31
- // No default `onkeydown` - see TextInput.svelte for the rationale.
32
- // The legacy default (`passthrough`) blurred the input on every
33
- // alphanumeric keystroke and made the field unusable.
34
- onkeydown,
35
- oninput,
36
-
37
- inputRef = $bindable(),
38
- 'data-type': dataType,
39
- }: NumberInputProps = $props();
40
-
41
- function clamp(e: Event): void {
42
- const raw = (e.target as HTMLInputElement).value;
43
- if (raw === '') {
44
- if (value !== null) {
45
- value = null;
46
- }
47
- return;
48
- }
49
- const next = Number(raw);
50
- if (isNaN(next)) {
51
- return;
52
- }
53
- const lo = min ?? -Infinity;
54
- const hi = max ?? Infinity;
55
- const clamped = Math.max(lo, Math.min(hi, next));
56
- if (clamped !== value) {
57
- value = clamped;
58
- }
59
- }
60
-
61
- const isInvalid = $derived(showErrorColours && ((required && value == null) || invalid));
62
- </script>
63
-
64
- <div
65
- class="error-wrapper"
66
- class:for-modal={variant == InputVariant.Modal}
67
- class:for-table={variant == InputVariant.Table}
68
- >
69
- <label
70
- class:for-modal={variant == InputVariant.Modal}
71
- class:for-table={variant == InputVariant.Table}
72
- >
73
- {#if labelTop}
74
- <span
75
- class="top-label"
76
- class:for-default={variant === InputVariant.Default}
77
- class:invalid={isInvalid}
78
- >{labelTop}{#if optional}<i>&nbsp;- optional</i>{/if}</span
79
- >
80
- {#if variant === InputVariant.Default}
81
- <span
82
- aria-hidden="true"
83
- class="border"
84
- class:invalid={isInvalid}
85
- >{labelTop}{#if optional}<i>&nbsp;- optional</i>{/if}</span
86
- >
87
- {/if}
88
- {/if}
89
- <div
90
- class="icon-container"
91
- class:for-modal={variant == InputVariant.Modal}
92
- >
93
- {#if leftIcon}
94
- <Icon
95
- name={leftIcon.name}
96
- size={leftIcon.size ?? Size.Medium}
97
- colour={leftIcon.colour}
98
- float
99
- left={cssLength('0.75rem')}
100
- top={cssLength('50%')}
101
- anchorX={cssLength('0')}
102
- anchorY={cssLength('-50%')}
103
- clickable={!!onLeftIconClick}
104
- onclick={onLeftIconClick}
105
- />
106
- {/if}
107
- <input
108
- {id}
109
- class:invalid={isInvalid}
110
- class:for-default={variant === InputVariant.Default}
111
- data-type={dataType}
112
- class:left-pad={leftIcon != undefined}
113
- class:right-pad={rightIcon != undefined || (labelRight && variant == InputVariant.Modal)}
114
- class:for-modal={variant == InputVariant.Modal}
115
- type="number"
116
- aria-invalid={isInvalid || undefined}
117
- bind:value
118
- {onblur}
119
- {onfocus}
120
- {onkeydown}
121
- oninput={(e) => {
122
- clamp(e);
123
- oninput?.(e);
124
- }}
125
- bind:this={inputRef}
126
- {placeholder}
127
- {required}
128
- {disabled}
129
- {min}
130
- {max}
131
- step={decimal ? 0.01 : 1}
132
- />
133
- {#if rightIcon}
134
- <Icon
135
- name={rightIcon.name}
136
- size={rightIcon.size ?? Size.Medium}
137
- colour={rightIcon.colour}
138
- float
139
- right={cssLength(variant == InputVariant.Modal ? '1rem' : '0.5rem')}
140
- top={cssLength('50%')}
141
- anchorX={cssLength('0')}
142
- anchorY={cssLength('-50%')}
143
- clickable={!!onRightIconClick}
144
- onclick={onRightIconClick}
145
- />
146
- {/if}
147
- {#if labelRight}
148
- <span
149
- class="right-label inset"
150
- class:for-modal={variant == InputVariant.Modal}>{labelRight}</span
151
- >
152
- {/if}
153
- </div>
154
- </label>
155
- </div>
156
-
1
+ <svelte:options runes />
2
+
3
+ <script lang="ts">
4
+ import { cssLength } from '../Helpers/Helpers.svelte.js';
5
+ import { InputVariant } from '../Types/Internal/InputVariant.js';
6
+ import { Size } from '../Types/Internal/Size.js';
7
+ import Icon from './Icon.svelte';
8
+ import type { NumberInputProps } from './NumberInputProps.js';
9
+ let {
10
+ id,
11
+ value = $bindable(null),
12
+ min,
13
+ max,
14
+ labelTop,
15
+ labelRight,
16
+ placeholder,
17
+ required = false,
18
+ variant = InputVariant.Default,
19
+ decimal = false,
20
+ invalid = false,
21
+ showErrorColours = true,
22
+ disabled,
23
+ optional,
24
+ leftIcon,
25
+ rightIcon,
26
+ onLeftIconClick,
27
+ onRightIconClick,
28
+
29
+ onblur,
30
+ onfocus,
31
+ // No default `onkeydown` - see TextInput.svelte for the rationale.
32
+ // The legacy default (`passthrough`) blurred the input on every
33
+ // alphanumeric keystroke and made the field unusable.
34
+ onkeydown,
35
+ oninput,
36
+
37
+ inputRef = $bindable(),
38
+ 'data-type': dataType,
39
+ }: NumberInputProps = $props();
40
+
41
+ function clamp(e: Event): void {
42
+ const raw = (e.target as HTMLInputElement).value;
43
+ if (raw === '') {
44
+ if (value !== null) {
45
+ value = null;
46
+ }
47
+ return;
48
+ }
49
+ const next = Number(raw);
50
+ if (isNaN(next)) {
51
+ return;
52
+ }
53
+ const lo = min ?? -Infinity;
54
+ const hi = max ?? Infinity;
55
+ const clamped = Math.max(lo, Math.min(hi, next));
56
+ if (clamped !== value) {
57
+ value = clamped;
58
+ }
59
+ }
60
+
61
+ const isInvalid = $derived(showErrorColours && ((required && value == null) || invalid));
62
+ </script>
63
+
64
+ <div
65
+ class="error-wrapper"
66
+ class:for-modal={variant == InputVariant.Modal}
67
+ class:for-table={variant == InputVariant.Table}
68
+ >
69
+ <label
70
+ class:for-modal={variant == InputVariant.Modal}
71
+ class:for-table={variant == InputVariant.Table}
72
+ >
73
+ {#if labelTop}
74
+ <span
75
+ class="top-label"
76
+ class:for-default={variant === InputVariant.Default}
77
+ class:invalid={isInvalid}
78
+ >{labelTop}{#if optional}<i>&nbsp;- optional</i>{/if}</span
79
+ >
80
+ {#if variant === InputVariant.Default}
81
+ <span
82
+ aria-hidden="true"
83
+ class="border"
84
+ class:invalid={isInvalid}
85
+ >{labelTop}{#if optional}<i>&nbsp;- optional</i>{/if}</span
86
+ >
87
+ {/if}
88
+ {/if}
89
+ <div
90
+ class="icon-container"
91
+ class:for-modal={variant == InputVariant.Modal}
92
+ >
93
+ {#if leftIcon}
94
+ <Icon
95
+ name={leftIcon.name}
96
+ size={leftIcon.size ?? Size.Medium}
97
+ colour={leftIcon.colour}
98
+ float
99
+ left={cssLength('0.75rem')}
100
+ top={cssLength('50%')}
101
+ anchorX={cssLength('0')}
102
+ anchorY={cssLength('-50%')}
103
+ clickable={!!onLeftIconClick}
104
+ onclick={onLeftIconClick}
105
+ />
106
+ {/if}
107
+ <input
108
+ {id}
109
+ class:invalid={isInvalid}
110
+ class:for-default={variant === InputVariant.Default}
111
+ data-type={dataType}
112
+ class:left-pad={leftIcon != undefined}
113
+ class:right-pad={rightIcon != undefined || (labelRight && variant == InputVariant.Modal)}
114
+ class:for-modal={variant == InputVariant.Modal}
115
+ type="number"
116
+ aria-invalid={isInvalid || undefined}
117
+ bind:value
118
+ {onblur}
119
+ {onfocus}
120
+ {onkeydown}
121
+ oninput={(e) => {
122
+ clamp(e);
123
+ oninput?.(e);
124
+ }}
125
+ bind:this={inputRef}
126
+ {placeholder}
127
+ {required}
128
+ {disabled}
129
+ {min}
130
+ {max}
131
+ step={decimal ? 0.01 : 1}
132
+ />
133
+ {#if rightIcon}
134
+ <Icon
135
+ name={rightIcon.name}
136
+ size={rightIcon.size ?? Size.Medium}
137
+ colour={rightIcon.colour}
138
+ float
139
+ right={cssLength(variant == InputVariant.Modal ? '1rem' : '0.5rem')}
140
+ top={cssLength('50%')}
141
+ anchorX={cssLength('0')}
142
+ anchorY={cssLength('-50%')}
143
+ clickable={!!onRightIconClick}
144
+ onclick={onRightIconClick}
145
+ />
146
+ {/if}
147
+ {#if labelRight}
148
+ <span
149
+ class="right-label inset"
150
+ class:for-modal={variant == InputVariant.Modal}>{labelRight}</span
151
+ >
152
+ {/if}
153
+ </div>
154
+ </label>
155
+ </div>
156
+
157
157
  <style>input {
158
158
  box-sizing: border-box;
159
159
  height: 100%;
@@ -393,4 +393,4 @@ input::-webkit-outer-spin-button,
393
393
  input::-webkit-inner-spin-button {
394
394
  -webkit-appearance: none;
395
395
  margin: 0;
396
- }</style>
396
+ }</style>
@@ -1,27 +1,27 @@
1
- <svelte:options runes />
2
-
3
- <script lang="ts">
4
- import type { PageHeadingProps } from './PageHeadingProps.js';
5
-
6
- let { children, subtitle, extras }: PageHeadingProps = $props();
7
- </script>
8
-
9
- <div class="outer">
10
- <div class="column">
11
- <h1>{@render children()}</h1>
12
- <div class="one-line">
13
- {#if subtitle}
14
- {@render subtitle()}
15
- {/if}
16
- </div>
17
- </div>
18
- {#if extras}
19
- <div class="buttons">
20
- {@render extras()}
21
- </div>
22
- {/if}
23
- </div>
24
-
1
+ <svelte:options runes />
2
+
3
+ <script lang="ts">
4
+ import type { PageHeadingProps } from './PageHeadingProps.js';
5
+
6
+ let { children, subtitle, extras }: PageHeadingProps = $props();
7
+ </script>
8
+
9
+ <div class="outer">
10
+ <div class="column">
11
+ <h1>{@render children()}</h1>
12
+ <div class="one-line">
13
+ {#if subtitle}
14
+ {@render subtitle()}
15
+ {/if}
16
+ </div>
17
+ </div>
18
+ {#if extras}
19
+ <div class="buttons">
20
+ {@render extras()}
21
+ </div>
22
+ {/if}
23
+ </div>
24
+
25
25
  <style>.outer {
26
26
  padding: 1.5rem;
27
27
  display: flex;
@@ -65,4 +65,4 @@
65
65
  fill: #647d8e;
66
66
  color: #647d8e;
67
67
  font-size: 0.875rem;
68
- }</style>
68
+ }</style>
@@ -1,90 +1,90 @@
1
- <svelte:options runes />
2
-
3
- <script lang="ts">
4
- import { cssLength } from '../Helpers/Helpers.svelte.js';
5
- import { ColourSet } from '../scss/colours.js';
6
- import { Size } from '../Types/Internal/Size.js';
7
- import Action from './Action.svelte';
8
- import Icon from './Icon.svelte';
9
- import type { PasswordInputProps } from './PasswordInputProps.js';
10
- let {
11
- value = $bindable(''),
12
- label = undefined,
13
- placeholder = undefined,
14
- required = false,
15
- disabled = undefined,
16
- showInput = $bindable(false),
17
- leftIcon = undefined,
18
- inputRef = $bindable(),
19
- autocomplete = 'current-password',
20
- onblur,
21
- onfocus,
22
- // No default `onkeydown` - see TextInput.svelte for the rationale.
23
- // The legacy default (`passthrough`) blurred the input on every
24
- // alphanumeric keystroke and made the field unusable.
25
- onkeydown,
26
- }: PasswordInputProps = $props();
27
-
28
- function toggleVisibility(): void {
29
- showInput = !showInput;
30
- inputRef?.focus();
31
- }
32
- </script>
33
-
34
- <div class="error-wrapper">
35
- <label>
36
- {#if label}
37
- <span class="for-default">{label}</span>
38
- <span
39
- aria-hidden="true"
40
- class="border">{label}</span
41
- >
42
- {/if}
43
- <div class="icon-container">
44
- {#if leftIcon}
45
- <Icon
46
- name={leftIcon.name}
47
- size={leftIcon.size ?? Size.Medium}
48
- float
49
- left={cssLength('0.75rem')}
50
- top={cssLength('50%')}
51
- anchorX={cssLength('0')}
52
- anchorY={cssLength('-50%')}
53
- />
54
- {/if}
55
- <input
56
- class="for-default"
57
- class:left-pad={leftIcon != undefined}
58
- class:right-pad={true}
59
- type={showInput ? 'text' : 'password'}
60
- {autocomplete}
61
- autocapitalize="none"
62
- autocorrect="off"
63
- spellcheck="false"
64
- data-form-type="password"
65
- bind:value
66
- bind:this={inputRef}
67
- {onblur}
68
- {onfocus}
69
- {onkeydown}
70
- {placeholder}
71
- {required}
72
- {disabled}
73
- />
74
-
75
- <div class="right-icon">
76
- <Action
77
- label={showInput ? 'Hide password' : 'Show password'}
78
- colourSet={showInput ? ColourSet.Secondary : ColourSet.Auxiliary}
79
- icon={{ name: showInput ? 'visibility-off' : 'visibility' }}
80
- size={Size.MediumSmall}
81
- onclick={toggleVisibility}
82
- />
83
- </div>
84
- </div>
85
- </label>
86
- </div>
87
-
1
+ <svelte:options runes />
2
+
3
+ <script lang="ts">
4
+ import { cssLength } from '../Helpers/Helpers.svelte.js';
5
+ import { ColourSet } from '../scss/colours.js';
6
+ import { Size } from '../Types/Internal/Size.js';
7
+ import Action from './Action.svelte';
8
+ import Icon from './Icon.svelte';
9
+ import type { PasswordInputProps } from './PasswordInputProps.js';
10
+ let {
11
+ value = $bindable(''),
12
+ label = undefined,
13
+ placeholder = undefined,
14
+ required = false,
15
+ disabled = undefined,
16
+ showInput = $bindable(false),
17
+ leftIcon = undefined,
18
+ inputRef = $bindable(),
19
+ autocomplete = 'current-password',
20
+ onblur,
21
+ onfocus,
22
+ // No default `onkeydown` - see TextInput.svelte for the rationale.
23
+ // The legacy default (`passthrough`) blurred the input on every
24
+ // alphanumeric keystroke and made the field unusable.
25
+ onkeydown,
26
+ }: PasswordInputProps = $props();
27
+
28
+ function toggleVisibility(): void {
29
+ showInput = !showInput;
30
+ inputRef?.focus();
31
+ }
32
+ </script>
33
+
34
+ <div class="error-wrapper">
35
+ <label>
36
+ {#if label}
37
+ <span class="for-default">{label}</span>
38
+ <span
39
+ aria-hidden="true"
40
+ class="border">{label}</span
41
+ >
42
+ {/if}
43
+ <div class="icon-container">
44
+ {#if leftIcon}
45
+ <Icon
46
+ name={leftIcon.name}
47
+ size={leftIcon.size ?? Size.Medium}
48
+ float
49
+ left={cssLength('0.75rem')}
50
+ top={cssLength('50%')}
51
+ anchorX={cssLength('0')}
52
+ anchorY={cssLength('-50%')}
53
+ />
54
+ {/if}
55
+ <input
56
+ class="for-default"
57
+ class:left-pad={leftIcon != undefined}
58
+ class:right-pad={true}
59
+ type={showInput ? 'text' : 'password'}
60
+ {autocomplete}
61
+ autocapitalize="none"
62
+ autocorrect="off"
63
+ spellcheck="false"
64
+ data-form-type="password"
65
+ bind:value
66
+ bind:this={inputRef}
67
+ {onblur}
68
+ {onfocus}
69
+ {onkeydown}
70
+ {placeholder}
71
+ {required}
72
+ {disabled}
73
+ />
74
+
75
+ <div class="right-icon">
76
+ <Action
77
+ label={showInput ? 'Hide password' : 'Show password'}
78
+ colourSet={showInput ? ColourSet.Secondary : ColourSet.Auxiliary}
79
+ icon={{ name: showInput ? 'visibility-off' : 'visibility' }}
80
+ size={Size.MediumSmall}
81
+ onclick={toggleVisibility}
82
+ />
83
+ </div>
84
+ </div>
85
+ </label>
86
+ </div>
87
+
88
88
  <style>input {
89
89
  box-sizing: border-box;
90
90
  height: 100%;
@@ -318,4 +318,4 @@ label.for-table input {
318
318
 
319
319
  td {
320
320
  --input-border: none;
321
- }</style>
321
+ }</style>
@@ -1,36 +1,36 @@
1
- <svelte:options runes />
2
-
3
- <script lang="ts">
4
- import { browser } from '$app/environment';
5
- import type { PortalProps } from './PortalProps.js';
6
-
7
- let { target = browser ? globalThis.document.body : undefined, children }: PortalProps = $props();
8
-
9
- let ref: HTMLElement | undefined = $state();
10
- let lastTarget: HTMLElement | undefined;
11
-
12
- $effect(() => {
13
- // Identity guard: only re-parent when `target` actually changes.
14
- // `appendChild` already moves the node when called, so this avoids
15
- // unnecessary detach/attach when an upstream `$state` target
16
- // re-fires the effect without changing identity.
17
- if (target && ref && target !== lastTarget) {
18
- if (target.ownerDocument === globalThis.document) {
19
- target.appendChild(ref);
20
- lastTarget = target;
21
- }
22
- }
23
-
24
- // Cleanup is necessary, not redundant: without it, the appended
25
- // node would remain inside `target` after the Portal unmounts,
26
- // because `target` outlives the component.
27
- return () => {
28
- ref?.parentNode?.removeChild(ref);
29
- lastTarget = undefined;
30
- };
31
- });
32
- </script>
33
-
34
- <div bind:this={ref}>
35
- {@render children()}
36
- </div>
1
+ <svelte:options runes />
2
+
3
+ <script lang="ts">
4
+ import { browser } from '$app/environment';
5
+ import type { PortalProps } from './PortalProps.js';
6
+
7
+ let { target = browser ? globalThis.document.body : undefined, children }: PortalProps = $props();
8
+
9
+ let ref: HTMLElement | undefined = $state();
10
+ let lastTarget: HTMLElement | undefined;
11
+
12
+ $effect(() => {
13
+ // Identity guard: only re-parent when `target` actually changes.
14
+ // `appendChild` already moves the node when called, so this avoids
15
+ // unnecessary detach/attach when an upstream `$state` target
16
+ // re-fires the effect without changing identity.
17
+ if (target && ref && target !== lastTarget) {
18
+ if (target.ownerDocument === globalThis.document) {
19
+ target.appendChild(ref);
20
+ lastTarget = target;
21
+ }
22
+ }
23
+
24
+ // Cleanup is necessary, not redundant: without it, the appended
25
+ // node would remain inside `target` after the Portal unmounts,
26
+ // because `target` outlives the component.
27
+ return () => {
28
+ ref?.parentNode?.removeChild(ref);
29
+ lastTarget = undefined;
30
+ };
31
+ });
32
+ </script>
33
+
34
+ <div bind:this={ref}>
35
+ {@render children()}
36
+ </div>