@lavalogic/scoria 0.38.10 → 0.38.12

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 (115) 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/AppointmentCalendar/AppointmentCalendar.svelte +702 -702
  6. package/dist/Components/Base/BaseModal.svelte +125 -125
  7. package/dist/Components/Base/ContextWrapper.svelte +72 -72
  8. package/dist/Components/Base/Pagination.svelte +198 -198
  9. package/dist/Components/Base/Snippets.svelte +36 -36
  10. package/dist/Components/BigRadioSet.svelte +38 -38
  11. package/dist/Components/Bubble.svelte +101 -101
  12. package/dist/Components/Button.svelte +209 -209
  13. package/dist/Components/Checkbox.svelte +86 -86
  14. package/dist/Components/Contexts/ContextMenu.svelte +164 -164
  15. package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
  16. package/dist/Components/Contexts/ContextMenuOption.svelte +60 -60
  17. package/dist/Components/Contexts/ToastContainer.svelte +65 -65
  18. package/dist/Components/Contexts/Tooltip.svelte +37 -37
  19. package/dist/Components/DataMatrixIcon.svelte +112 -112
  20. package/dist/Components/DateInput.svelte +148 -148
  21. package/dist/Components/DatePicker.svelte +300 -300
  22. package/dist/Components/DesktopModal.svelte +90 -90
  23. package/dist/Components/Dial.svelte +204 -204
  24. package/dist/Components/DimensionInput.svelte +170 -170
  25. package/dist/Components/DragMenu/DragMenuHolder.svelte +119 -119
  26. package/dist/Components/DragMenu/DraggableCard.svelte +77 -77
  27. package/dist/Components/FileCard.svelte +24 -24
  28. package/dist/Components/FileUpload.svelte +236 -236
  29. package/dist/Components/GridInputSet.svelte +29 -29
  30. package/dist/Components/HorizontalTabGroup.svelte +82 -82
  31. package/dist/Components/HorizontalTabGroupButton.svelte +44 -44
  32. package/dist/Components/Icon.svelte +128 -128
  33. package/dist/Components/Icons.js +357 -357
  34. package/dist/Components/LoadingAnimation.svelte +29 -29
  35. package/dist/Components/LoadingModal.svelte +45 -45
  36. package/dist/Components/LoadingOverlay.svelte +25 -25
  37. package/dist/Components/Modal.svelte +258 -258
  38. package/dist/Components/MultiSelect.svelte +220 -220
  39. package/dist/Components/Nav/NavServiceMenuList.svelte +43 -43
  40. package/dist/Components/Nav/NavTab.svelte +62 -62
  41. package/dist/Components/Nav/ServicesNav.svelte +80 -80
  42. package/dist/Components/NumberInput.svelte +157 -157
  43. package/dist/Components/PageHeading.svelte +25 -25
  44. package/dist/Components/PasswordInput.svelte +88 -88
  45. package/dist/Components/Portal.svelte +36 -36
  46. package/dist/Components/QuerySelect.svelte +366 -366
  47. package/dist/Components/SingleSelect.svelte +250 -250
  48. package/dist/Components/StepButton.svelte +70 -70
  49. package/dist/Components/StepForm.svelte +140 -140
  50. package/dist/Components/Switch.svelte +69 -69
  51. package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +51 -51
  52. package/dist/Components/Table/Body/Rows/ColumnList.svelte +59 -59
  53. package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +79 -79
  54. package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +120 -120
  55. package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +105 -105
  56. package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +87 -87
  57. package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +126 -126
  58. package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +159 -159
  59. package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +246 -246
  60. package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +216 -216
  61. package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +179 -179
  62. package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +197 -197
  63. package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +190 -190
  64. package/dist/Components/Table/Body/Rows/TableRow.svelte +290 -290
  65. package/dist/Components/Table/Headers/HighlightAllHeader.svelte +41 -41
  66. package/dist/Components/Table/Headers/SelectAllHeader.svelte +30 -30
  67. package/dist/Components/Table/Misc/FilterInput.svelte +37 -16
  68. package/dist/Components/Table/Misc/SidePanel.svelte +35 -35
  69. package/dist/Components/Table/Misc/TableConfigurationModal.svelte +71 -0
  70. package/dist/Components/Table/Misc/ToolboxPanel.svelte +100 -100
  71. package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +107 -107
  72. package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte +225 -0
  73. package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte.d.ts +26 -0
  74. package/dist/Components/Table/Misc/UpdateViewOptionsModalProps.d.ts +21 -0
  75. package/dist/Components/Table/Misc/UpdateViewOptionsModalProps.js +1 -0
  76. package/dist/Components/Table/Types/Context/TableContext.svelte.d.ts +49 -1
  77. package/dist/Components/Table/Types/Context/TableContext.svelte.js +142 -1
  78. package/dist/Components/Table/Types/DataRepository/BuiltInRemoteRepository.svelte.d.ts +2 -2
  79. package/dist/Components/Table/Types/DataRepository/BuiltInRemoteRepository.svelte.js +20 -2
  80. package/dist/Components/Table/Types/DataRepository/IDataRepository.d.ts +9 -1
  81. package/dist/Components/Table/Types/DataRepository/ILocalDataRepository.d.ts +1 -1
  82. package/dist/Components/Table/Types/DataRepository/IRemoteDataRepository.d.ts +1 -1
  83. package/dist/Components/Table/Types/DataRepository/TableDataRepository.svelte.d.ts +1 -1
  84. package/dist/Components/Table/Types/Persistence/DatatableView.d.ts +25 -0
  85. package/dist/Components/Test/TestContextConsumer.svelte +13 -13
  86. package/dist/Components/TextArea.svelte +130 -130
  87. package/dist/Components/TextInput.svelte +176 -176
  88. package/dist/Components/ThreeStateRadio.svelte +131 -131
  89. package/dist/Components/Touch/BoolCard.svelte +45 -45
  90. package/dist/Components/Touch/DateModal.svelte +209 -209
  91. package/dist/Components/Touch/EditCard.svelte +59 -59
  92. package/dist/Components/Touch/InfoCard.svelte +31 -31
  93. package/dist/Components/Touch/InfoTextCard.svelte +28 -28
  94. package/dist/Components/Touch/ModalExplanation.svelte +17 -17
  95. package/dist/Components/Touch/NumberKeyboard.svelte +225 -225
  96. package/dist/Components/Touch/NumberModal.svelte +79 -79
  97. package/dist/Components/Touch/PlusMinusCard.svelte +46 -46
  98. package/dist/Components/Touch/SummaryCard.svelte +93 -93
  99. package/dist/Components/Touch/TextAreaModal.svelte +95 -95
  100. package/dist/Components/Touch/TextModal.svelte +106 -106
  101. package/dist/Components/Touch/TouchCard.svelte +33 -33
  102. package/dist/Components/Touch/TouchModal.svelte +274 -274
  103. package/dist/Components/Touch/UtilityButton.svelte +109 -109
  104. package/dist/Components/VerticalTabGroup.svelte +79 -79
  105. package/dist/Components/VerticalTabGroupButton.svelte +58 -58
  106. package/dist/Helpers/Datamatrix.d.ts +19 -19
  107. package/dist/Helpers/Datamatrix.js +291 -291
  108. package/dist/Types/Examples/ExampleModal.svelte +35 -35
  109. package/dist/index.d.ts +1 -1
  110. package/dist/scss/_basics.scss +12 -12
  111. package/dist/scss/_colours.scss +134 -134
  112. package/dist/scss/_motion.scss +57 -57
  113. package/dist/scss/_sizing.scss +85 -85
  114. package/dist/scss/_transitions.scss +8 -8
  115. package/package.json +1 -1
@@ -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>
@@ -1,133 +1,133 @@
1
- <svelte:options runes />
2
-
3
- <script
4
- lang="ts"
5
- module
6
- >
7
- import { Colour, ColourSet } from '../scss/colours.js';
8
- import { Ternary } from '../Types/Internal/Ternary.js';
9
- import Action from './Action.svelte';
10
- import type { ThreeStateRadioProps } from './ThreeStateRadioProps.js';
11
- </script>
12
-
13
- <script lang="ts">
14
- let {
15
- value = $bindable(Ternary.Neutral),
16
- label,
17
- disabled,
18
- isValid,
19
- onchange,
20
- noDisabled = false,
21
- yesDisabled = false,
22
- neutralDisabled = false,
23
- noLabel,
24
- yesLabel,
25
- neutralLabel,
26
- noIcon,
27
- yesIcon,
28
- neutralIcon,
29
- }: ThreeStateRadioProps = $props();
30
-
31
- function setValue(next: Ternary): void {
32
- if (next === value) {
33
- return;
34
- }
35
- value = next;
36
- void onchange?.(next);
37
- }
38
- </script>
39
-
40
- <div
41
- class="text-label"
42
- class:invalid={isValid === false}
43
- >
44
- {#if label != undefined}
45
- <span>{label}</span>
46
- {/if}
47
-
48
- <div
49
- class="radios"
50
- role="radiogroup"
51
- aria-label={label}
52
- >
53
- <label>
54
- <Action
55
- disabled={disabled || noDisabled}
56
- colourSet={value === Ternary.False ? ColourSet.Primary : ColourSet.Auxiliary}
57
- icon={{
58
- name: 'circle-cross',
59
- ...noIcon,
60
- colour: value === Ternary.False ? undefined : Colour['$ui-blue-5'],
61
- }}
62
- label={noLabel ?? 'No'}
63
- onclick={() => {
64
- setValue(Ternary.False);
65
- }}
66
- />
67
- <input
68
- disabled={disabled || noDisabled}
69
- type="radio"
70
- value="0"
71
- checked={value === Ternary.False}
72
- aria-label={noLabel ?? 'No'}
73
- onchange={() => {
74
- setValue(Ternary.False);
75
- }}
76
- />
77
- </label>
78
- <label>
79
- <Action
80
- disabled={disabled || neutralDisabled}
81
- colourSet={value === Ternary.Neutral ? ColourSet.Primary : ColourSet.Auxiliary}
82
- icon={{
83
- name: 'database',
84
- ...neutralIcon,
85
- colour: value === Ternary.Neutral ? undefined : Colour['$ui-blue-5'],
86
- }}
87
- label={neutralLabel ?? 'Allow system to decide'}
88
- onclick={() => {
89
- setValue(Ternary.Neutral);
90
- }}
91
- />
92
- <input
93
- disabled={disabled || neutralDisabled}
94
- type="radio"
95
- value="-1"
96
- checked={value === Ternary.Neutral}
97
- aria-label={neutralLabel ?? 'Allow system to decide'}
98
- onchange={() => {
99
- setValue(Ternary.Neutral);
100
- }}
101
- />
102
- </label>
103
- <label>
104
- <Action
105
- disabled={disabled || yesDisabled}
106
- colourSet={value === Ternary.True ? ColourSet.Primary : ColourSet.Auxiliary}
107
- icon={{
108
- name: 'circle-tick',
109
- ...yesIcon,
110
- colour: value === Ternary.True ? undefined : Colour['$ui-blue-5'],
111
- }}
112
- label={yesLabel ?? 'Yes'}
113
- onclick={() => {
114
- setValue(Ternary.True);
115
- }}
116
- />
117
- <input
118
- disabled={disabled || yesDisabled}
119
- type="radio"
120
- value="1"
121
- checked={value === Ternary.True}
122
- aria-label={yesLabel ?? 'Yes'}
123
- onchange={() => {
124
- setValue(Ternary.True);
125
- }}
126
- />
127
- </label>
128
- </div>
129
- </div>
130
-
1
+ <svelte:options runes />
2
+
3
+ <script
4
+ lang="ts"
5
+ module
6
+ >
7
+ import { Colour, ColourSet } from '../scss/colours.js';
8
+ import { Ternary } from '../Types/Internal/Ternary.js';
9
+ import Action from './Action.svelte';
10
+ import type { ThreeStateRadioProps } from './ThreeStateRadioProps.js';
11
+ </script>
12
+
13
+ <script lang="ts">
14
+ let {
15
+ value = $bindable(Ternary.Neutral),
16
+ label,
17
+ disabled,
18
+ isValid,
19
+ onchange,
20
+ noDisabled = false,
21
+ yesDisabled = false,
22
+ neutralDisabled = false,
23
+ noLabel,
24
+ yesLabel,
25
+ neutralLabel,
26
+ noIcon,
27
+ yesIcon,
28
+ neutralIcon,
29
+ }: ThreeStateRadioProps = $props();
30
+
31
+ function setValue(next: Ternary): void {
32
+ if (next === value) {
33
+ return;
34
+ }
35
+ value = next;
36
+ void onchange?.(next);
37
+ }
38
+ </script>
39
+
40
+ <div
41
+ class="text-label"
42
+ class:invalid={isValid === false}
43
+ >
44
+ {#if label != undefined}
45
+ <span>{label}</span>
46
+ {/if}
47
+
48
+ <div
49
+ class="radios"
50
+ role="radiogroup"
51
+ aria-label={label}
52
+ >
53
+ <label>
54
+ <Action
55
+ disabled={disabled || noDisabled}
56
+ colourSet={value === Ternary.False ? ColourSet.Primary : ColourSet.Auxiliary}
57
+ icon={{
58
+ name: 'circle-cross',
59
+ ...noIcon,
60
+ colour: value === Ternary.False ? undefined : Colour['$ui-blue-5'],
61
+ }}
62
+ label={noLabel ?? 'No'}
63
+ onclick={() => {
64
+ setValue(Ternary.False);
65
+ }}
66
+ />
67
+ <input
68
+ disabled={disabled || noDisabled}
69
+ type="radio"
70
+ value="0"
71
+ checked={value === Ternary.False}
72
+ aria-label={noLabel ?? 'No'}
73
+ onchange={() => {
74
+ setValue(Ternary.False);
75
+ }}
76
+ />
77
+ </label>
78
+ <label>
79
+ <Action
80
+ disabled={disabled || neutralDisabled}
81
+ colourSet={value === Ternary.Neutral ? ColourSet.Primary : ColourSet.Auxiliary}
82
+ icon={{
83
+ name: 'database',
84
+ ...neutralIcon,
85
+ colour: value === Ternary.Neutral ? undefined : Colour['$ui-blue-5'],
86
+ }}
87
+ label={neutralLabel ?? 'Allow system to decide'}
88
+ onclick={() => {
89
+ setValue(Ternary.Neutral);
90
+ }}
91
+ />
92
+ <input
93
+ disabled={disabled || neutralDisabled}
94
+ type="radio"
95
+ value="-1"
96
+ checked={value === Ternary.Neutral}
97
+ aria-label={neutralLabel ?? 'Allow system to decide'}
98
+ onchange={() => {
99
+ setValue(Ternary.Neutral);
100
+ }}
101
+ />
102
+ </label>
103
+ <label>
104
+ <Action
105
+ disabled={disabled || yesDisabled}
106
+ colourSet={value === Ternary.True ? ColourSet.Primary : ColourSet.Auxiliary}
107
+ icon={{
108
+ name: 'circle-tick',
109
+ ...yesIcon,
110
+ colour: value === Ternary.True ? undefined : Colour['$ui-blue-5'],
111
+ }}
112
+ label={yesLabel ?? 'Yes'}
113
+ onclick={() => {
114
+ setValue(Ternary.True);
115
+ }}
116
+ />
117
+ <input
118
+ disabled={disabled || yesDisabled}
119
+ type="radio"
120
+ value="1"
121
+ checked={value === Ternary.True}
122
+ aria-label={yesLabel ?? 'Yes'}
123
+ onchange={() => {
124
+ setValue(Ternary.True);
125
+ }}
126
+ />
127
+ </label>
128
+ </div>
129
+ </div>
130
+
131
131
  <style>.text-label {
132
132
  box-sizing: border-box;
133
133
  height: max(var(--input-height, 3rem), 2rem);
@@ -198,4 +198,4 @@ input {
198
198
  clip-path: rect(0 0 0 0);
199
199
  white-space: nowrap;
200
200
  border: 0;
201
- }</style>
201
+ }</style>