@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,13 +1,13 @@
1
- <svelte:options runes />
2
-
3
- <script lang="ts">
4
- import { TestContext } from '../../Contexts/TestContext.svelte.js';
5
- import { getContext } from 'svelte';
6
-
7
- const testContext = getContext<TestContext>(TestContext.identifier);
8
- </script>
9
-
10
- <h1>counter 1: {testContext.value1.value}</h1>
11
- <p>Ref wrapper 1 is incremented every time you click the button</p>
12
- <h2>counter 2: {testContext.value2.value}</h2>
13
- <p>ref wrapper 2 adds ref wrapper 1's value every time ref wrapper 1's value is divisible by 3</p>
1
+ <svelte:options runes />
2
+
3
+ <script lang="ts">
4
+ import { TestContext } from '../../Contexts/TestContext.svelte.js';
5
+ import { getContext } from 'svelte';
6
+
7
+ const testContext = getContext<TestContext>(TestContext.identifier);
8
+ </script>
9
+
10
+ <h1>counter 1: {testContext.value1.value}</h1>
11
+ <p>Ref wrapper 1 is incremented every time you click the button</p>
12
+ <h2>counter 2: {testContext.value2.value}</h2>
13
+ <p>ref wrapper 2 adds ref wrapper 1's value every time ref wrapper 1's value is divisible by 3</p>
@@ -1,132 +1,132 @@
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 { TextAreaProps } from './TextAreaProps.js';
9
-
10
- let {
11
- value = $bindable(''),
12
- labelTop,
13
- labelRight,
14
- placeholder,
15
- maxWidth = false,
16
- required = false,
17
- variant = InputVariant.Default,
18
- selectNone = false,
19
- noresize = false,
20
- uppercase = false,
21
- disabled,
22
- invalid = false,
23
- showErrorColours = true,
24
- optional = false,
25
- leftIcon,
26
- rightIcon,
27
- onLeftIconClick,
28
- onRightIconClick,
29
- rows = 4,
30
-
31
- textAreaRef = $bindable(),
32
- autocomplete,
33
- spellcheck,
34
- onblur,
35
- onfocus,
36
- // No default `onkeydown` - see TextInput.svelte for the rationale.
37
- // The legacy default (`passthrough`) blurred the textarea on every
38
- // alphanumeric keystroke and made the field unusable.
39
- onkeydown,
40
- oninput,
41
- }: TextAreaProps = $props();
42
-
43
- const isInvalid = $derived(showErrorColours && ((required && value.trim() === '') || invalid));
44
- </script>
45
-
46
- <label
47
- class:for-modal={variant === InputVariant.Modal}
48
- class:max-width={maxWidth}
49
- >
50
- {#if labelTop && variant !== InputVariant.Modal}
51
- <span
52
- class="top-label"
53
- class:for-default={variant === InputVariant.Default}
54
- class:invalid={isInvalid}
55
- >{labelTop}{#if optional}<i>&nbsp;- optional</i>{/if}</span
56
- >
57
- {#if variant === InputVariant.Default}
58
- <span
59
- aria-hidden="true"
60
- class="border"
61
- class:invalid={isInvalid}
62
- >{labelTop}{#if optional}<i>&nbsp;- optional</i>{/if}</span
63
- >
64
- {/if}
65
- {/if}
66
- <div
67
- class="icon-container"
68
- class:for-modal={variant == InputVariant.Modal}
69
- >
70
- {#if leftIcon}
71
- <Icon
72
- name={leftIcon.name}
73
- size={leftIcon.size ?? Size.Medium}
74
- colour={leftIcon.colour}
75
- float
76
- left={cssLength('0.75rem')}
77
- top={cssLength('50%')}
78
- anchorX={cssLength('0')}
79
- anchorY={cssLength('-50%')}
80
- clickable={!!onLeftIconClick}
81
- onclick={onLeftIconClick}
82
- />
83
- {/if}
84
- <textarea
85
- class:noresize
86
- class:uppercase
87
- class:invalid={isInvalid}
88
- class:select-none={selectNone}
89
- class:left-pad={leftIcon != undefined}
90
- class:right-pad={rightIcon != undefined}
91
- class:for-modal={variant == InputVariant.Modal}
92
- class:max-width={maxWidth}
93
- autocomplete={autocomplete ?? 'off'}
94
- spellcheck={spellcheck ?? true}
95
- aria-invalid={isInvalid || undefined}
96
- bind:value
97
- {onblur}
98
- {onfocus}
99
- {onkeydown}
100
- {oninput}
101
- {rows}
102
- bind:this={textAreaRef}
103
- {placeholder}
104
- {required}
105
- {disabled}
106
- ></textarea>
107
- {#if rightIcon}
108
- <Icon
109
- name={rightIcon.name}
110
- size={rightIcon.size ?? Size.Medium}
111
- colour={rightIcon.colour}
112
- float
113
- right={cssLength(variant == InputVariant.Modal ? '1rem' : '0.5rem')}
114
- top={cssLength('50%')}
115
- anchorX={cssLength('0')}
116
- anchorY={cssLength('-50%')}
117
- clickable={!!onRightIconClick}
118
- onclick={onRightIconClick}
119
- />
120
- {/if}
121
- {#if labelRight}
122
- <span
123
- class="right-label"
124
- class:for-modal={variant == InputVariant.Modal}>{labelRight}</span
125
- >
126
- {/if}
127
- </div>
128
- </label>
129
-
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 { TextAreaProps } from './TextAreaProps.js';
9
+
10
+ let {
11
+ value = $bindable(''),
12
+ labelTop,
13
+ labelRight,
14
+ placeholder,
15
+ maxWidth = false,
16
+ required = false,
17
+ variant = InputVariant.Default,
18
+ selectNone = false,
19
+ noresize = false,
20
+ uppercase = false,
21
+ disabled,
22
+ invalid = false,
23
+ showErrorColours = true,
24
+ optional = false,
25
+ leftIcon,
26
+ rightIcon,
27
+ onLeftIconClick,
28
+ onRightIconClick,
29
+ rows = 4,
30
+
31
+ textAreaRef = $bindable(),
32
+ autocomplete,
33
+ spellcheck,
34
+ onblur,
35
+ onfocus,
36
+ // No default `onkeydown` - see TextInput.svelte for the rationale.
37
+ // The legacy default (`passthrough`) blurred the textarea on every
38
+ // alphanumeric keystroke and made the field unusable.
39
+ onkeydown,
40
+ oninput,
41
+ }: TextAreaProps = $props();
42
+
43
+ const isInvalid = $derived(showErrorColours && ((required && value.trim() === '') || invalid));
44
+ </script>
45
+
46
+ <label
47
+ class:for-modal={variant === InputVariant.Modal}
48
+ class:max-width={maxWidth}
49
+ >
50
+ {#if labelTop && variant !== InputVariant.Modal}
51
+ <span
52
+ class="top-label"
53
+ class:for-default={variant === InputVariant.Default}
54
+ class:invalid={isInvalid}
55
+ >{labelTop}{#if optional}<i>&nbsp;- optional</i>{/if}</span
56
+ >
57
+ {#if variant === InputVariant.Default}
58
+ <span
59
+ aria-hidden="true"
60
+ class="border"
61
+ class:invalid={isInvalid}
62
+ >{labelTop}{#if optional}<i>&nbsp;- optional</i>{/if}</span
63
+ >
64
+ {/if}
65
+ {/if}
66
+ <div
67
+ class="icon-container"
68
+ class:for-modal={variant == InputVariant.Modal}
69
+ >
70
+ {#if leftIcon}
71
+ <Icon
72
+ name={leftIcon.name}
73
+ size={leftIcon.size ?? Size.Medium}
74
+ colour={leftIcon.colour}
75
+ float
76
+ left={cssLength('0.75rem')}
77
+ top={cssLength('50%')}
78
+ anchorX={cssLength('0')}
79
+ anchorY={cssLength('-50%')}
80
+ clickable={!!onLeftIconClick}
81
+ onclick={onLeftIconClick}
82
+ />
83
+ {/if}
84
+ <textarea
85
+ class:noresize
86
+ class:uppercase
87
+ class:invalid={isInvalid}
88
+ class:select-none={selectNone}
89
+ class:left-pad={leftIcon != undefined}
90
+ class:right-pad={rightIcon != undefined}
91
+ class:for-modal={variant == InputVariant.Modal}
92
+ class:max-width={maxWidth}
93
+ autocomplete={autocomplete ?? 'off'}
94
+ spellcheck={spellcheck ?? true}
95
+ aria-invalid={isInvalid || undefined}
96
+ bind:value
97
+ {onblur}
98
+ {onfocus}
99
+ {onkeydown}
100
+ {oninput}
101
+ {rows}
102
+ bind:this={textAreaRef}
103
+ {placeholder}
104
+ {required}
105
+ {disabled}
106
+ ></textarea>
107
+ {#if rightIcon}
108
+ <Icon
109
+ name={rightIcon.name}
110
+ size={rightIcon.size ?? Size.Medium}
111
+ colour={rightIcon.colour}
112
+ float
113
+ right={cssLength(variant == InputVariant.Modal ? '1rem' : '0.5rem')}
114
+ top={cssLength('50%')}
115
+ anchorX={cssLength('0')}
116
+ anchorY={cssLength('-50%')}
117
+ clickable={!!onRightIconClick}
118
+ onclick={onRightIconClick}
119
+ />
120
+ {/if}
121
+ {#if labelRight}
122
+ <span
123
+ class="right-label"
124
+ class:for-modal={variant == InputVariant.Modal}>{labelRight}</span
125
+ >
126
+ {/if}
127
+ </div>
128
+ </label>
129
+
130
130
  <style>textarea {
131
131
  box-sizing: border-box;
132
132
  height: 100%;
@@ -340,4 +340,4 @@ span.border.invalid {
340
340
  .textarea-error-wrapper.for-modal {
341
341
  position: relative;
342
342
  height: 100%;
343
- }</style>
343
+ }</style>
@@ -1,178 +1,178 @@
1
- <svelte:options runes />
2
-
3
- <script lang="ts">
4
- import { cssLength, isValidEmailAddress } from '../Helpers/Helpers.svelte.js';
5
- import { Colour, ColourSet } from '../scss/colours.js';
6
- import { InputVariant } from '../Types/Internal/InputVariant.js';
7
- import { Size } from '../Types/Internal/Size.js';
8
- import Action from './Action.svelte';
9
- import Icon from './Icon.svelte';
10
- import type { TextInputProps } from './TextInputProps.js';
11
- let {
12
- id,
13
- value = $bindable(''),
14
- labelTop,
15
- optional,
16
- labelRight,
17
- placeholder,
18
- required = false,
19
- variant = InputVariant.Default,
20
- selectNone = false,
21
- uppercase = false,
22
- disabled = false,
23
- invalid = false,
24
- showErrorColours = true,
25
- rightIconDisabled = false,
26
- leftIcon,
27
- rightIcon,
28
- type,
29
- onLeftIconClick,
30
- onRightIconClick,
31
- inputRef = $bindable(),
32
- 'data-type': dataType,
33
- autocomplete,
34
- spellcheck,
35
- onblur,
36
- onfocus,
37
- // No default `onkeydown`. The legacy default was `passthrough`,
38
- // a helper that BLURS the target on every alphanumeric key (it is
39
- // a barcode-scanner aid intended for buttons - note the
40
- // `as HTMLButtonElement` cast inside it). Applied to a text input
41
- // it makes the field unusable: each keystroke blurs the input
42
- // before the value can update, so users see nothing as they type.
43
- // Inputs should accept keystrokes by default; consumers that want
44
- // the barcode-blur behaviour explicitly pass
45
- // `onkeydown={passthrough}` (preferably renamed to
46
- // `blurOnAlphanumeric` in a future patch).
47
- onkeydown,
48
- oninput,
49
- }: TextInputProps = $props();
50
-
51
- const isInvalid = $derived(
52
- showErrorColours &&
53
- !disabled &&
54
- ((required &&
55
- (!value?.trim() ||
56
- (type == 'email' &&
57
- value.length >= 3 &&
58
- value.includes('@') &&
59
- !isValidEmailAddress(value)))) ||
60
- invalid)
61
- );
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
- {#if onLeftIconClick}
95
- <div class="left-icon">
96
- <Action
97
- noTabIndex
98
- colourSet={ColourSet.Auxiliary}
99
- icon={leftIcon}
100
- size={Size.Medium}
101
- onclick={onLeftIconClick}
102
- />
103
- </div>
104
- {:else}
105
- <Icon
106
- name={leftIcon.name}
107
- size={leftIcon.size ?? Size.Medium}
108
- colour={leftIcon.colour}
109
- float
110
- left={cssLength('0.75rem')}
111
- top={cssLength('50%')}
112
- anchorX={cssLength('0')}
113
- anchorY={cssLength('-50%')}
114
- />
115
- {/if}
116
- {/if}
117
- <input
118
- {id}
119
- class:for-default={variant === InputVariant.Default}
120
- class:uppercase
121
- class:invalid={isInvalid}
122
- class:select-none={selectNone}
123
- class:left-pad={leftIcon != undefined}
124
- class:right-pad={rightIcon != undefined}
125
- class:for-modal={variant == InputVariant.Modal}
126
- data-type={dataType}
127
- type={type ?? 'text'}
128
- autocomplete={autocomplete ?? (type === 'email' ? 'email' : 'off')}
129
- spellcheck={spellcheck ?? false}
130
- aria-invalid={isInvalid || undefined}
131
- bind:value
132
- {onblur}
133
- {onfocus}
134
- {onkeydown}
135
- {oninput}
136
- bind:this={inputRef}
137
- {placeholder}
138
- {required}
139
- {disabled}
140
- />
141
- {#if rightIcon}
142
- <div class="right-icon">
143
- {#if onRightIconClick}
144
- <Action
145
- noTabIndex
146
- colourSet={ColourSet.Auxiliary}
147
- disabled={rightIconDisabled}
148
- icon={rightIcon}
149
- size={Size.Medium}
150
- onclick={onRightIconClick}
151
- />
152
- {:else}
153
- <Icon
154
- name={rightIcon.name}
155
- size={rightIcon.size ?? Size.Medium}
156
- colour={rightIcon.colour ?? Colour['$font-disabled']}
157
- float
158
- right={cssLength(variant == InputVariant.Modal ? '1rem' : '0.5rem')}
159
- top={cssLength('50%')}
160
- anchorX={cssLength('0')}
161
- anchorY={cssLength('-50%')}
162
- />
163
- {/if}
164
- </div>
165
- {/if}
166
- {#if labelRight}
167
- <span
168
- class="right-label"
169
- class:for-modal={variant == InputVariant.Modal}>{labelRight}</span
170
- >
171
- {/if}
172
- </div>
173
- </label>
174
- </div>
175
-
1
+ <svelte:options runes />
2
+
3
+ <script lang="ts">
4
+ import { cssLength, isValidEmailAddress } from '../Helpers/Helpers.svelte.js';
5
+ import { Colour, ColourSet } from '../scss/colours.js';
6
+ import { InputVariant } from '../Types/Internal/InputVariant.js';
7
+ import { Size } from '../Types/Internal/Size.js';
8
+ import Action from './Action.svelte';
9
+ import Icon from './Icon.svelte';
10
+ import type { TextInputProps } from './TextInputProps.js';
11
+ let {
12
+ id,
13
+ value = $bindable(''),
14
+ labelTop,
15
+ optional,
16
+ labelRight,
17
+ placeholder,
18
+ required = false,
19
+ variant = InputVariant.Default,
20
+ selectNone = false,
21
+ uppercase = false,
22
+ disabled = false,
23
+ invalid = false,
24
+ showErrorColours = true,
25
+ rightIconDisabled = false,
26
+ leftIcon,
27
+ rightIcon,
28
+ type,
29
+ onLeftIconClick,
30
+ onRightIconClick,
31
+ inputRef = $bindable(),
32
+ 'data-type': dataType,
33
+ autocomplete,
34
+ spellcheck,
35
+ onblur,
36
+ onfocus,
37
+ // No default `onkeydown`. The legacy default was `passthrough`,
38
+ // a helper that BLURS the target on every alphanumeric key (it is
39
+ // a barcode-scanner aid intended for buttons - note the
40
+ // `as HTMLButtonElement` cast inside it). Applied to a text input
41
+ // it makes the field unusable: each keystroke blurs the input
42
+ // before the value can update, so users see nothing as they type.
43
+ // Inputs should accept keystrokes by default; consumers that want
44
+ // the barcode-blur behaviour explicitly pass
45
+ // `onkeydown={passthrough}` (preferably renamed to
46
+ // `blurOnAlphanumeric` in a future patch).
47
+ onkeydown,
48
+ oninput,
49
+ }: TextInputProps = $props();
50
+
51
+ const isInvalid = $derived(
52
+ showErrorColours &&
53
+ !disabled &&
54
+ ((required &&
55
+ (!value?.trim() ||
56
+ (type == 'email' &&
57
+ value.length >= 3 &&
58
+ value.includes('@') &&
59
+ !isValidEmailAddress(value)))) ||
60
+ invalid)
61
+ );
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
+ {#if onLeftIconClick}
95
+ <div class="left-icon">
96
+ <Action
97
+ noTabIndex
98
+ colourSet={ColourSet.Auxiliary}
99
+ icon={leftIcon}
100
+ size={Size.Medium}
101
+ onclick={onLeftIconClick}
102
+ />
103
+ </div>
104
+ {:else}
105
+ <Icon
106
+ name={leftIcon.name}
107
+ size={leftIcon.size ?? Size.Medium}
108
+ colour={leftIcon.colour}
109
+ float
110
+ left={cssLength('0.75rem')}
111
+ top={cssLength('50%')}
112
+ anchorX={cssLength('0')}
113
+ anchorY={cssLength('-50%')}
114
+ />
115
+ {/if}
116
+ {/if}
117
+ <input
118
+ {id}
119
+ class:for-default={variant === InputVariant.Default}
120
+ class:uppercase
121
+ class:invalid={isInvalid}
122
+ class:select-none={selectNone}
123
+ class:left-pad={leftIcon != undefined}
124
+ class:right-pad={rightIcon != undefined}
125
+ class:for-modal={variant == InputVariant.Modal}
126
+ data-type={dataType}
127
+ type={type ?? 'text'}
128
+ autocomplete={autocomplete ?? (type === 'email' ? 'email' : 'off')}
129
+ spellcheck={spellcheck ?? false}
130
+ aria-invalid={isInvalid || undefined}
131
+ bind:value
132
+ {onblur}
133
+ {onfocus}
134
+ {onkeydown}
135
+ {oninput}
136
+ bind:this={inputRef}
137
+ {placeholder}
138
+ {required}
139
+ {disabled}
140
+ />
141
+ {#if rightIcon}
142
+ <div class="right-icon">
143
+ {#if onRightIconClick}
144
+ <Action
145
+ noTabIndex
146
+ colourSet={ColourSet.Auxiliary}
147
+ disabled={rightIconDisabled}
148
+ icon={rightIcon}
149
+ size={Size.Medium}
150
+ onclick={onRightIconClick}
151
+ />
152
+ {:else}
153
+ <Icon
154
+ name={rightIcon.name}
155
+ size={rightIcon.size ?? Size.Medium}
156
+ colour={rightIcon.colour ?? Colour['$font-disabled']}
157
+ float
158
+ right={cssLength(variant == InputVariant.Modal ? '1rem' : '0.5rem')}
159
+ top={cssLength('50%')}
160
+ anchorX={cssLength('0')}
161
+ anchorY={cssLength('-50%')}
162
+ />
163
+ {/if}
164
+ </div>
165
+ {/if}
166
+ {#if labelRight}
167
+ <span
168
+ class="right-label"
169
+ class:for-modal={variant == InputVariant.Modal}>{labelRight}</span
170
+ >
171
+ {/if}
172
+ </div>
173
+ </label>
174
+ </div>
175
+
176
176
  <style>input {
177
177
  box-sizing: border-box;
178
178
  height: 100%;
@@ -406,4 +406,4 @@ label.for-table input {
406
406
 
407
407
  td {
408
408
  --input-border: none;
409
- }</style>
409
+ }</style>