@lavalogic/scoria 0.40.13 → 0.40.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -58
- package/dist/Components/AccordionGroup.svelte +35 -46
- package/dist/Components/AccordionGroupButton.svelte +68 -76
- package/dist/Components/Action.svelte +103 -135
- package/dist/Components/AlertModal.svelte +171 -190
- package/dist/Components/AppointmentCalendar/AppointmentCalendar.svelte +614 -697
- package/dist/Components/Base/BaseModal.svelte +90 -116
- package/dist/Components/Base/ContextWrapper.svelte +67 -72
- package/dist/Components/Base/Pagination.svelte +173 -196
- package/dist/Components/Base/Snippets.svelte +34 -36
- package/dist/Components/BigRadioSet.svelte +36 -38
- package/dist/Components/Bubble.svelte +78 -101
- package/dist/Components/Button.svelte +175 -208
- package/dist/Components/Checkbox.svelte +75 -86
- package/dist/Components/CollapsibleCard.svelte +72 -87
- package/dist/Components/CollapsibleMenuGroup.svelte +53 -57
- package/dist/Components/ConditionBuilder/ConditionBuilder.svelte +39 -64
- package/dist/Components/Contexts/ContextMenu.svelte +141 -156
- package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
- package/dist/Components/Contexts/ContextMenuOption.svelte +53 -60
- package/dist/Components/Contexts/Toast.svelte +81 -86
- package/dist/Components/Contexts/ToastContainer.svelte +58 -62
- package/dist/Components/Contexts/Tooltip.svelte +36 -37
- package/dist/Components/DataMatrixIcon.svelte +95 -108
- package/dist/Components/DateInput.svelte +118 -146
- package/dist/Components/DatePicker.svelte +255 -294
- package/dist/Components/DesktopModal.svelte +70 -90
- package/dist/Components/Dial.svelte +167 -197
- package/dist/Components/DimensionInput.svelte +124 -169
- package/dist/Components/DragMenu/DragMenuHolder.svelte +98 -114
- package/dist/Components/DragMenu/DraggableCard.svelte +64 -76
- package/dist/Components/FileCard.svelte +21 -24
- package/dist/Components/FileUpload.svelte +190 -225
- package/dist/Components/GridInput.svelte +159 -196
- package/dist/Components/GridInputSet.svelte +24 -29
- package/dist/Components/HorizontalTabGroup.svelte +73 -89
- package/dist/Components/HorizontalTabGroupButton.svelte +40 -44
- package/dist/Components/Icon.svelte +99 -128
- package/dist/Components/Icons.js +357 -357
- package/dist/Components/InfoAlert.svelte +35 -38
- package/dist/Components/LoadingAnimation.svelte +691 -755
- package/dist/Components/LoadingModal.svelte +36 -44
- package/dist/Components/LoadingOverlay.svelte +22 -26
- package/dist/Components/Modal.svelte +204 -254
- package/dist/Components/MultiSelect.svelte +186 -216
- package/dist/Components/Nav/Nav.svelte +94 -110
- package/dist/Components/Nav/NavServiceMenuList.svelte +57 -61
- package/dist/Components/Nav/NavTab.svelte +58 -62
- package/dist/Components/Nav/ServiceMenuItem.svelte +103 -111
- package/dist/Components/Nav/ServicesNav.svelte +72 -79
- package/dist/Components/NumberInput.svelte +121 -155
- package/dist/Components/OptionCards.svelte +62 -73
- package/dist/Components/PageHeading.svelte +23 -25
- package/dist/Components/PasswordInput.svelte +69 -88
- package/dist/Components/PopoverButton.svelte +151 -0
- package/dist/Components/PopoverButton.svelte.d.ts +9 -0
- package/dist/Components/PopoverButtonProps.d.ts +21 -0
- package/dist/Components/PopoverButtonProps.js +1 -0
- package/dist/Components/Portal.svelte +29 -35
- package/dist/Components/ProgressBubble.svelte +91 -106
- package/dist/Components/QuerySelect.svelte +260 -346
- package/dist/Components/SidebarPanel.svelte +34 -36
- package/dist/Components/SingleSelect.svelte +196 -244
- package/dist/Components/StepButton.svelte +65 -70
- package/dist/Components/StepForm.svelte +115 -135
- package/dist/Components/Switch.svelte +57 -69
- package/dist/Components/Table/ARCHITECTURE.md +298 -298
- package/dist/Components/Table/Body/QuickSearchCell.svelte +578 -655
- package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +42 -51
- package/dist/Components/Table/Body/Rows/ColumnList.svelte +42 -58
- package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +403 -442
- package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +51 -78
- package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +165 -184
- package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +110 -123
- package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +134 -160
- package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +190 -231
- package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +82 -104
- package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +52 -87
- package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +122 -150
- package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +132 -159
- package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +190 -236
- package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +173 -211
- package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +204 -244
- package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +140 -177
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +188 -217
- package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +173 -193
- package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +166 -187
- package/dist/Components/Table/Body/Rows/TableRow.svelte +245 -288
- package/dist/Components/Table/Body/TableBody.svelte +141 -154
- package/dist/Components/Table/Headers/HighlightAllHeader.svelte +35 -41
- package/dist/Components/Table/Headers/SelectAllHeader.svelte +24 -30
- package/dist/Components/Table/Headers/TableHead.svelte +348 -402
- package/dist/Components/Table/Misc/ColumnPanel.svelte +37 -39
- package/dist/Components/Table/Misc/ColumnPanelModal.svelte +35 -39
- package/dist/Components/Table/Misc/FilterInput.svelte +556 -619
- package/dist/Components/Table/Misc/FilterPanel.svelte +170 -183
- package/dist/Components/Table/Misc/FilterPanelModal.svelte +25 -31
- package/dist/Components/Table/Misc/ShareViewModal.svelte +252 -281
- package/dist/Components/Table/Misc/SidePanel.svelte +32 -35
- package/dist/Components/Table/Misc/TableConfigurationModal.svelte +574 -629
- package/dist/Components/Table/Misc/TableFooter.svelte +326 -332
- package/dist/Components/Table/Misc/TableHorizontalBar.svelte +134 -140
- package/dist/Components/Table/Misc/TableSidebar.svelte +183 -198
- package/dist/Components/Table/Misc/TableViewDropdown.svelte +83 -103
- package/dist/Components/Table/Misc/ToolboxPanel.svelte +83 -100
- package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +88 -107
- package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte +163 -190
- package/dist/Components/Table/NestedTable.svelte +102 -128
- package/dist/Components/Table/Table.svelte +531 -663
- package/dist/Components/Test/TestContextConsumer.svelte +11 -13
- package/dist/Components/TextArea.svelte +95 -130
- package/dist/Components/TextInput.svelte +125 -176
- package/dist/Components/ThreeStateRadio.svelte +111 -130
- package/dist/Components/Touch/BoolCard.svelte +33 -45
- package/dist/Components/Touch/DateModal.svelte +164 -204
- package/dist/Components/Touch/EditCard.svelte +48 -59
- package/dist/Components/Touch/InfoCard.svelte +28 -31
- package/dist/Components/Touch/InfoTextCard.svelte +26 -28
- package/dist/Components/Touch/ModalExplanation.svelte +15 -17
- package/dist/Components/Touch/NumberKeyboard.svelte +181 -218
- package/dist/Components/Touch/NumberModal.svelte +59 -79
- package/dist/Components/Touch/PlusMinusCard.svelte +43 -46
- package/dist/Components/Touch/SelectModal.svelte +111 -126
- package/dist/Components/Touch/SummaryCard.svelte +80 -93
- package/dist/Components/Touch/TextAreaModal.svelte +72 -94
- package/dist/Components/Touch/TextModal.svelte +77 -105
- package/dist/Components/Touch/TouchCard.svelte +31 -33
- package/dist/Components/Touch/TouchModal.svelte +214 -270
- package/dist/Components/Touch/UtilityButton.svelte +88 -109
- package/dist/Components/VerticalTabGroup.svelte +60 -78
- package/dist/Components/VerticalTabGroupButton.svelte +54 -58
- package/dist/Helpers/Datamatrix.d.ts +19 -19
- package/dist/Helpers/Datamatrix.js +291 -291
- package/dist/Types/Examples/ExampleModal.svelte +31 -35
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/scss/_basics.scss +12 -12
- package/dist/scss/_colours.scss +134 -134
- package/dist/scss/_mixins.scss +3392 -3392
- package/dist/scss/_motion.scss +57 -57
- package/dist/scss/_sizing.scss +85 -85
- package/dist/scss/_transitions.scss +8 -8
- package/package.json +1 -1
|
@@ -1,38 +1,36 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<!--
|
|
4
|
-
@component
|
|
5
|
-
A titled card laid out as a fixed-width menu column beside a main content
|
|
6
|
-
area. Both regions are supplied by the consumer as snippets (`menu` and the
|
|
7
|
-
default `children`), so the component only owns the framing and layout.
|
|
8
|
-
-->
|
|
9
|
-
<script lang="ts">
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
</section>
|
|
35
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<!--
|
|
4
|
+
@component
|
|
5
|
+
A titled card laid out as a fixed-width menu column beside a main content
|
|
6
|
+
area. Both regions are supplied by the consumer as snippets (`menu` and the
|
|
7
|
+
default `children`), so the component only owns the framing and layout.
|
|
8
|
+
-->
|
|
9
|
+
<script lang="ts">let { title, subtitle, menu, children, menuWidth = "14rem" } = $props();
|
|
10
|
+
export {};
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<section class="sidebar-panel">
|
|
14
|
+
<header class="heading">
|
|
15
|
+
<h2>{title}</h2>
|
|
16
|
+
{#if subtitle}
|
|
17
|
+
<span class="subtitle">{subtitle}</span>
|
|
18
|
+
{/if}
|
|
19
|
+
</header>
|
|
20
|
+
|
|
21
|
+
<div class="body">
|
|
22
|
+
<aside
|
|
23
|
+
class="menu"
|
|
24
|
+
style="--menu-width: {menuWidth};"
|
|
25
|
+
>
|
|
26
|
+
{@render menu()}
|
|
27
|
+
</aside>
|
|
28
|
+
<div class="main">
|
|
29
|
+
{@render children()}
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</section>
|
|
33
|
+
|
|
36
34
|
<style>.sidebar-panel {
|
|
37
35
|
display: flex;
|
|
38
36
|
flex-flow: column nowrap;
|
|
@@ -82,4 +80,4 @@ default `children`), so the component only owns the framing and layout.
|
|
|
82
80
|
flex-flow: column nowrap;
|
|
83
81
|
gap: 1.5rem;
|
|
84
82
|
padding: 1.5rem;
|
|
85
|
-
}</style>
|
|
83
|
+
}</style>
|
|
@@ -1,252 +1,204 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script
|
|
4
|
-
lang="ts"
|
|
5
|
-
generics="V extends object, VP extends ValueProp<V>"
|
|
6
|
-
>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
minHeight,
|
|
33
|
-
clearable = false,
|
|
34
|
-
required = false,
|
|
35
|
-
invalid = false,
|
|
36
|
-
borderless = false,
|
|
37
|
-
lazyDropdown = false,
|
|
38
|
-
forceUpwards = false,
|
|
39
|
-
inputId = generateWeakId(),
|
|
40
|
-
value: selectedValue,
|
|
41
|
-
onchange,
|
|
42
|
-
onfocus,
|
|
43
|
-
onCreateOption,
|
|
44
|
-
}: SingleSelectProps<V, VP> = $props();
|
|
45
|
-
|
|
46
|
-
// Single source of truth for the current value. The previous code mixed
|
|
47
|
-
// `$derived` and `$effect.pre`, which fired a redundant assignment on mount.
|
|
48
|
-
const currentValue = $derived(selectedValue);
|
|
49
|
-
let ref = $state<Svelecte | undefined>();
|
|
50
|
-
let wrapperRef: HTMLDivElement | undefined = $state();
|
|
51
|
-
|
|
52
|
-
const an = $derived(name && vowels.has(name.at(0)?.toLocaleLowerCase() ?? '') ? 'an' : 'a');
|
|
53
|
-
|
|
54
|
-
const isInvalid = $derived((required && !currentValue) || invalid);
|
|
55
|
-
|
|
56
|
-
let hasAutoFocused = $state(false);
|
|
57
|
-
|
|
58
|
-
// ResizeObserver-driven height. Replaces the layout-forcing
|
|
59
|
-
// `getBoundingClientRect()` call that used to run inside a `$derived`.
|
|
60
|
-
let dropdownBottom = $state(0);
|
|
61
|
-
$effect(() => {
|
|
62
|
-
if (!wrapperRef) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const ro = new ResizeObserver((entries) => {
|
|
66
|
-
const entry = entries[0];
|
|
67
|
-
dropdownBottom = entry.borderBoxSize[0].blockSize;
|
|
68
|
-
});
|
|
69
|
-
ro.observe(wrapperRef);
|
|
70
|
-
return () => {
|
|
71
|
-
ro.disconnect();
|
|
72
|
-
};
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script
|
|
4
|
+
lang="ts"
|
|
5
|
+
generics="V extends object, VP extends ValueProp<V>"
|
|
6
|
+
>import { devCatch, generateWeakId, vowels } from "../Helpers/Helpers.svelte.js";
|
|
7
|
+
import { attachDropdownPortal } from "../Helpers/dropdownPortal.js";
|
|
8
|
+
import { Colour, ColourSet } from "../scss/colours.js";
|
|
9
|
+
import { Size } from "../Types/Internal/Size.js";
|
|
10
|
+
import Svelecte from "svelecte";
|
|
11
|
+
import { onMount, tick } from "svelte";
|
|
12
|
+
import Action from "./Action.svelte";
|
|
13
|
+
const { label, options, labelProp, valueProp, focusOnLoad = false, searchable = true, creatable = false, createFilter, disabled, width, height, name = "Item", valueAsObject, minHeight, clearable = false, required = false, invalid = false, borderless = false, lazyDropdown = false, forceUpwards = false, inputId = generateWeakId(), value: selectedValue, onchange, onfocus, onCreateOption } = $props();
|
|
14
|
+
// Single source of truth for the current value. The previous code mixed
|
|
15
|
+
// `$derived` and `$effect.pre`, which fired a redundant assignment on mount.
|
|
16
|
+
const currentValue = $derived(selectedValue);
|
|
17
|
+
let ref = $state();
|
|
18
|
+
let wrapperRef = $state();
|
|
19
|
+
const an = $derived(name && vowels.has(name.at(0)?.toLocaleLowerCase() ?? "") ? "an" : "a");
|
|
20
|
+
const isInvalid = $derived(required && !currentValue || invalid);
|
|
21
|
+
let hasAutoFocused = $state(false);
|
|
22
|
+
// ResizeObserver-driven height. Replaces the layout-forcing
|
|
23
|
+
// `getBoundingClientRect()` call that used to run inside a `$derived`.
|
|
24
|
+
let dropdownBottom = $state(0);
|
|
25
|
+
$effect(() => {
|
|
26
|
+
if (!wrapperRef) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const ro = new ResizeObserver((entries) => {
|
|
30
|
+
const entry = entries[0];
|
|
31
|
+
dropdownBottom = entry.borderBoxSize[0].blockSize;
|
|
73
32
|
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
33
|
+
ro.observe(wrapperRef);
|
|
34
|
+
return () => {
|
|
35
|
+
ro.disconnect();
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
function forceShowDropdown(input) {
|
|
39
|
+
if (focusOnLoad && !hasAutoFocused) {
|
|
40
|
+
hasAutoFocused = true;
|
|
41
|
+
input.click();
|
|
80
42
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
// rotation / clear icon visibility below.
|
|
100
|
-
const observer = new MutationObserver((mutations: Array<MutationRecord>) => {
|
|
101
|
-
for (let i = mutations.length - 1; i > -1; i--) {
|
|
102
|
-
const mutation = mutations[i];
|
|
103
|
-
if (mutation.attributeName === 'class') {
|
|
104
|
-
isExpanded = dropdownRef?.classList.contains('is-open') ?? false;
|
|
105
|
-
}
|
|
43
|
+
}
|
|
44
|
+
let isExpanded = $state(false);
|
|
45
|
+
onMount(() => {
|
|
46
|
+
if (focusOnLoad) {
|
|
47
|
+
tick().then(() => {
|
|
48
|
+
ref?.focus();
|
|
49
|
+
}).catch(devCatch);
|
|
50
|
+
}
|
|
51
|
+
const input = document.getElementById(inputId);
|
|
52
|
+
const svelecteRoot = input?.closest("div.svelecte");
|
|
53
|
+
const dropdownRef = svelecteRoot?.querySelector(".sv_dropdown") ?? undefined;
|
|
54
|
+
// HACK callback for is-open on/off. Drives the chevron
|
|
55
|
+
// rotation / clear icon visibility below.
|
|
56
|
+
const observer = new MutationObserver((mutations) => {
|
|
57
|
+
for (let i = mutations.length - 1; i > -1; i--) {
|
|
58
|
+
const mutation = mutations[i];
|
|
59
|
+
if (mutation.attributeName === "class") {
|
|
60
|
+
isExpanded = dropdownRef?.classList.contains("is-open") ?? false;
|
|
106
61
|
}
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
if (dropdownRef) {
|
|
110
|
-
observer.observe(dropdownRef, { attributes: true });
|
|
111
62
|
}
|
|
112
|
-
|
|
113
|
-
// Teleport the dropdown to `document.body` while open so it
|
|
114
|
-
// escapes every ancestor `overflow` / `transform` / `z-index`
|
|
115
|
-
// stacking context (filter-panel groups, sticky table strips,
|
|
116
|
-
// modals, etc.). The portal helper also auto-flips upwards
|
|
117
|
-
// when there is not enough space below the trigger and
|
|
118
|
-
// repositions on scroll / resize. See
|
|
119
|
-
// `Helpers/dropdownPortal.ts` for the full rationale.
|
|
120
|
-
const detachPortal = attachDropdownPortal({
|
|
121
|
-
getTrigger: () => svelecteRoot,
|
|
122
|
-
getDropdown: () => dropdownRef,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
return () => {
|
|
126
|
-
observer.disconnect();
|
|
127
|
-
detachPortal();
|
|
128
|
-
};
|
|
129
63
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return value !== null && typeof value === 'object';
|
|
64
|
+
if (dropdownRef) {
|
|
65
|
+
observer.observe(dropdownRef, { attributes: true });
|
|
133
66
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
{
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
{
|
|
196
|
-
|
|
197
|
-
{
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
{
|
|
242
|
-
|
|
243
|
-
{
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
</div>
|
|
249
|
-
|
|
67
|
+
// Teleport the dropdown to `document.body` while open so it
|
|
68
|
+
// escapes every ancestor `overflow` / `transform` / `z-index`
|
|
69
|
+
// stacking context (filter-panel groups, sticky table strips,
|
|
70
|
+
// modals, etc.). The portal helper also auto-flips upwards
|
|
71
|
+
// when there is not enough space below the trigger and
|
|
72
|
+
// repositions on scroll / resize. See
|
|
73
|
+
// `Helpers/dropdownPortal.ts` for the full rationale.
|
|
74
|
+
const detachPortal = attachDropdownPortal({
|
|
75
|
+
getTrigger: () => svelecteRoot,
|
|
76
|
+
getDropdown: () => dropdownRef
|
|
77
|
+
});
|
|
78
|
+
return () => {
|
|
79
|
+
observer.disconnect();
|
|
80
|
+
detachPortal();
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
function isObject(value) {
|
|
84
|
+
return value !== null && typeof value === "object";
|
|
85
|
+
}
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<div
|
|
89
|
+
class="select-wrapper"
|
|
90
|
+
class:no-border={borderless}
|
|
91
|
+
style={`${width ? `--input-width: ${width};` : ''}${height ? `--input-height: ${height};` : ''} --dropdown-bottom: calc(${dropdownBottom}px + 1px); --sv-min-height: ${minHeight ?? '2rem'};`}
|
|
92
|
+
class:invalid={isInvalid}
|
|
93
|
+
class:force-upwards={forceUpwards}
|
|
94
|
+
bind:this={wrapperRef}
|
|
95
|
+
>
|
|
96
|
+
{#if label}
|
|
97
|
+
<label for={inputId}>
|
|
98
|
+
<span
|
|
99
|
+
>{label}{#if !required} - <i>optional</i>{/if}</span
|
|
100
|
+
>
|
|
101
|
+
<span class="border"
|
|
102
|
+
>{label}{#if !required} - <i>optional</i>{/if}</span
|
|
103
|
+
>
|
|
104
|
+
</label>
|
|
105
|
+
{/if}
|
|
106
|
+
|
|
107
|
+
<Svelecte
|
|
108
|
+
{createFilter}
|
|
109
|
+
{disabled}
|
|
110
|
+
{name}
|
|
111
|
+
onFocus={(target: HTMLInputElement) => {
|
|
112
|
+
forceShowDropdown(target);
|
|
113
|
+
onfocus?.(target);
|
|
114
|
+
}}
|
|
115
|
+
bind:this={ref}
|
|
116
|
+
{valueAsObject}
|
|
117
|
+
{inputId}
|
|
118
|
+
{required}
|
|
119
|
+
valueField={valueProp}
|
|
120
|
+
labelField={labelProp}
|
|
121
|
+
virtualList={false}
|
|
122
|
+
{options}
|
|
123
|
+
{creatable}
|
|
124
|
+
searchProps={{ keepSelectionInList: true }}
|
|
125
|
+
{onCreateOption}
|
|
126
|
+
placeholder="Please Select {name ? `${an} ${name}` : ''}"
|
|
127
|
+
{lazyDropdown}
|
|
128
|
+
value={// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
|
+
currentValue as Array<any>}
|
|
130
|
+
onChange={(newValue: V | null) => {
|
|
131
|
+
// svelecte always emits the full option object regardless of
|
|
132
|
+
// `valueAsObject`. Map to the shape the discriminated variant
|
|
133
|
+
// promised: primitive for AsPrimitive, object for AsObject.
|
|
134
|
+
if (valueAsObject) {
|
|
135
|
+
void (onchange as (v: V | null) => void | Promise<void>)(newValue);
|
|
136
|
+
} else {
|
|
137
|
+
const primitive = newValue == null ? null : newValue[valueProp];
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
139
|
+
void (onchange as (v: V[VP] | null) => void | Promise<void>)(primitive);
|
|
140
|
+
}
|
|
141
|
+
}}
|
|
142
|
+
{searchable}
|
|
143
|
+
selectOnTab
|
|
144
|
+
keepSelectionInList
|
|
145
|
+
deselectMode={clearable ? 'toggle' : 'none'}
|
|
146
|
+
>
|
|
147
|
+
{#snippet option(opt)}<span class="dropdown-item"> {(opt as V)[labelProp]}</span>{/snippet}
|
|
148
|
+
|
|
149
|
+
{#snippet append()}
|
|
150
|
+
<div class="icons">
|
|
151
|
+
{#if clearable && currentValue}
|
|
152
|
+
<Action
|
|
153
|
+
noTabIndex
|
|
154
|
+
onclick={(e: MouseEvent) => {
|
|
155
|
+
if (isExpanded) {
|
|
156
|
+
e.stopPropagation();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
void onchange(null);
|
|
160
|
+
}}
|
|
161
|
+
{disabled}
|
|
162
|
+
colourSet={ColourSet.Auxiliary}
|
|
163
|
+
size={Size.Small}
|
|
164
|
+
icon={{
|
|
165
|
+
name: 'close-menu-cross',
|
|
166
|
+
colour: Colour['$ui-blue-10'],
|
|
167
|
+
}}
|
|
168
|
+
/>
|
|
169
|
+
{/if}
|
|
170
|
+
|
|
171
|
+
<Action
|
|
172
|
+
noTabIndex
|
|
173
|
+
colourSet={ColourSet.Auxiliary}
|
|
174
|
+
size={Size.Small}
|
|
175
|
+
{disabled}
|
|
176
|
+
icon={{
|
|
177
|
+
name: isExpanded ? 'chevron-up' : 'chevron-down',
|
|
178
|
+
colour: Colour['$ui-blue-10'],
|
|
179
|
+
}}
|
|
180
|
+
/>
|
|
181
|
+
</div>
|
|
182
|
+
{/snippet}
|
|
183
|
+
{#snippet toggleIcon()}
|
|
184
|
+
<div class="nothing"></div>
|
|
185
|
+
{/snippet}
|
|
186
|
+
|
|
187
|
+
{#snippet selection(/*_selectedOptions: Array<any>*/)}
|
|
188
|
+
<span
|
|
189
|
+
class="selection"
|
|
190
|
+
class:invalid={isInvalid}
|
|
191
|
+
>
|
|
192
|
+
{#if isObject(selectedValue)}
|
|
193
|
+
{selectedValue[labelProp]}
|
|
194
|
+
{:else}
|
|
195
|
+
{options.find((it) => it[valueProp] === selectedValue)?.[labelProp]}
|
|
196
|
+
{/if}
|
|
197
|
+
</span>
|
|
198
|
+
{/snippet}
|
|
199
|
+
</Svelecte>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
250
202
|
<style>.select-wrapper {
|
|
251
203
|
min-width: var(--input-min-width, 12rem);
|
|
252
204
|
width: var(--input-width, 100%);
|
|
@@ -409,4 +361,4 @@ div.icons {
|
|
|
409
361
|
}
|
|
410
362
|
:global(.dropdown-item) .toggle-icon.yes {
|
|
411
363
|
opacity: 1;
|
|
412
|
-
}</style>
|
|
364
|
+
}</style>
|