@lavalogic/scoria 0.40.1 → 0.40.2
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 +46 -46
- package/dist/Components/AccordionGroupButton.svelte +76 -76
- package/dist/Components/Action.svelte +136 -136
- package/dist/Components/AlertModal.svelte +195 -195
- package/dist/Components/AppointmentCalendar/AppointmentCalendar.svelte +729 -729
- package/dist/Components/Base/BaseModal.svelte +125 -125
- package/dist/Components/Base/ContextWrapper.svelte +72 -72
- package/dist/Components/Base/Pagination.svelte +198 -198
- package/dist/Components/Base/Snippets.svelte +36 -36
- package/dist/Components/BigRadioSet.svelte +38 -38
- package/dist/Components/Bubble.svelte +101 -101
- package/dist/Components/Button.svelte +209 -209
- package/dist/Components/Checkbox.svelte +86 -86
- package/dist/Components/CollapsibleCard.svelte +78 -78
- package/dist/Components/Contexts/ContextMenu.svelte +164 -164
- package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
- package/dist/Components/Contexts/ContextMenuOption.svelte +60 -60
- package/dist/Components/Contexts/Toast.svelte +86 -86
- package/dist/Components/Contexts/ToastContainer.svelte +65 -65
- package/dist/Components/Contexts/Tooltip.svelte +37 -37
- package/dist/Components/DataMatrixIcon.svelte +112 -112
- package/dist/Components/DateInput.svelte +148 -148
- package/dist/Components/DatePicker.svelte +300 -300
- package/dist/Components/DesktopModal.svelte +90 -90
- package/dist/Components/Dial.svelte +204 -204
- package/dist/Components/DimensionInput.svelte +170 -170
- package/dist/Components/DragMenu/DragMenuHolder.svelte +119 -119
- package/dist/Components/DragMenu/DraggableCard.svelte +77 -77
- package/dist/Components/FileCard.svelte +24 -24
- package/dist/Components/FileUpload.svelte +236 -236
- package/dist/Components/GridInput.svelte +196 -196
- package/dist/Components/GridInputSet.svelte +29 -29
- package/dist/Components/HorizontalTabGroup.svelte +82 -82
- package/dist/Components/HorizontalTabGroupButton.svelte +44 -44
- package/dist/Components/Icon.svelte +128 -128
- package/dist/Components/Icons.js +357 -357
- package/dist/Components/InfoAlert.svelte +35 -35
- package/dist/Components/LoadingAnimation.svelte +29 -29
- package/dist/Components/LoadingModal.svelte +45 -45
- package/dist/Components/LoadingOverlay.svelte +25 -25
- package/dist/Components/Modal.svelte +258 -258
- package/dist/Components/MultiSelect.svelte +220 -220
- package/dist/Components/Nav/Nav.svelte +110 -110
- package/dist/Components/Nav/NavServiceMenuList.svelte +43 -43
- package/dist/Components/Nav/NavTab.svelte +62 -62
- package/dist/Components/Nav/ServiceMenuItem.svelte +112 -112
- package/dist/Components/Nav/ServicesNav.svelte +80 -80
- package/dist/Components/NumberInput.svelte +157 -157
- package/dist/Components/PageHeading.svelte +25 -25
- package/dist/Components/PasswordInput.svelte +88 -88
- package/dist/Components/Portal.svelte +36 -36
- package/dist/Components/ProgressBubble.svelte +107 -107
- package/dist/Components/QuerySelect.svelte +366 -366
- package/dist/Components/SingleSelect.svelte +250 -250
- package/dist/Components/StepButton.svelte +70 -70
- package/dist/Components/StepForm.svelte +140 -140
- package/dist/Components/Switch.svelte +69 -69
- package/dist/Components/Table/ARCHITECTURE.md +298 -298
- package/dist/Components/Table/Body/QuickSearchCell.svelte +679 -679
- package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +51 -51
- package/dist/Components/Table/Body/Rows/ColumnList.svelte +59 -59
- package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +454 -454
- package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +79 -79
- package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +185 -185
- package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +124 -124
- package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +131 -120
- package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +234 -234
- package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +105 -105
- package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +87 -87
- package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +126 -126
- package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +159 -159
- package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +246 -246
- package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +216 -216
- package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +252 -252
- package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +179 -179
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +221 -221
- package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +197 -197
- package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +190 -190
- package/dist/Components/Table/Body/Rows/TableRow.svelte +290 -290
- package/dist/Components/Table/Body/TableBody.svelte +155 -155
- package/dist/Components/Table/ColumnFactory.svelte.js +1 -0
- package/dist/Components/Table/Headers/HighlightAllHeader.svelte +41 -41
- package/dist/Components/Table/Headers/SelectAllHeader.svelte +30 -30
- package/dist/Components/Table/Headers/TableHead.svelte +415 -415
- package/dist/Components/Table/Misc/ColumnPanel.svelte +39 -39
- package/dist/Components/Table/Misc/ColumnPanelModal.svelte +39 -39
- package/dist/Components/Table/Misc/FilterInput.svelte +641 -641
- package/dist/Components/Table/Misc/FilterPanel.svelte +190 -190
- package/dist/Components/Table/Misc/FilterPanelModal.svelte +31 -31
- package/dist/Components/Table/Misc/ShareViewModal.svelte +291 -291
- package/dist/Components/Table/Misc/SidePanel.svelte +35 -35
- package/dist/Components/Table/Misc/TableConfigurationModal.svelte +644 -644
- package/dist/Components/Table/Misc/TableFooter.svelte +340 -340
- package/dist/Components/Table/Misc/TableHorizontalBar.svelte +140 -140
- package/dist/Components/Table/Misc/TableSidebar.svelte +200 -200
- package/dist/Components/Table/Misc/TableViewDropdown.svelte +105 -105
- package/dist/Components/Table/Misc/ToolboxPanel.svelte +100 -100
- package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +107 -107
- package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte +192 -192
- package/dist/Components/Table/NestedTable.svelte +130 -130
- package/dist/Components/Table/Table.svelte +692 -692
- package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.d.ts +5 -0
- package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.js +3 -0
- package/dist/Components/Table/Types/Public/ColumnOptions.d.ts +10 -0
- package/dist/Components/Test/TestContextConsumer.svelte +13 -13
- package/dist/Components/TextArea.svelte +130 -130
- package/dist/Components/TextInput.svelte +176 -176
- package/dist/Components/ThreeStateRadio.svelte +131 -131
- package/dist/Components/Touch/BoolCard.svelte +45 -45
- package/dist/Components/Touch/DateModal.svelte +209 -209
- package/dist/Components/Touch/EditCard.svelte +59 -59
- package/dist/Components/Touch/InfoCard.svelte +31 -31
- package/dist/Components/Touch/InfoTextCard.svelte +28 -28
- package/dist/Components/Touch/ModalExplanation.svelte +17 -17
- package/dist/Components/Touch/NumberKeyboard.svelte +225 -225
- package/dist/Components/Touch/NumberModal.svelte +79 -79
- package/dist/Components/Touch/PlusMinusCard.svelte +46 -46
- package/dist/Components/Touch/SelectModal.svelte +127 -127
- package/dist/Components/Touch/SummaryCard.svelte +93 -93
- package/dist/Components/Touch/TextAreaModal.svelte +95 -95
- package/dist/Components/Touch/TextModal.svelte +106 -106
- package/dist/Components/Touch/TouchCard.svelte +33 -33
- package/dist/Components/Touch/TouchModal.svelte +274 -274
- package/dist/Components/Touch/UtilityButton.svelte +109 -109
- package/dist/Components/VerticalTabGroup.svelte +79 -79
- package/dist/Components/VerticalTabGroupButton.svelte +58 -58
- package/dist/Helpers/Datamatrix.d.ts +19 -19
- package/dist/Helpers/Datamatrix.js +291 -291
- package/dist/Types/Examples/ExampleModal.svelte +35 -35
- 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,103 +1,103 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script
|
|
4
|
-
lang="ts"
|
|
5
|
-
module
|
|
6
|
-
>
|
|
7
|
-
import { Size } from '../Types/Internal/Size.js';
|
|
8
|
-
import type { BubbleProps } from './BubbleProps.js';
|
|
9
|
-
import Icon from './Icon.svelte';
|
|
10
|
-
|
|
11
|
-
// Per-size padding/typography. Only `Size.Large` has explicit overrides;
|
|
12
|
-
// other sizes fall back to the medium defaults handled in $derived blocks
|
|
13
|
-
// below. Replaced the previous one-key `Partial<Record<Size, string>>`
|
|
14
|
-
// lookup tables with a simple `size === Size.Large` branch.
|
|
15
|
-
const LARGE_HORIZONTAL_WITH_VALUE = '1rem';
|
|
16
|
-
const LARGE_HORIZONTAL_WITHOUT_VALUE = '1.25rem';
|
|
17
|
-
const LARGE_VERTICAL = '0.5rem';
|
|
18
|
-
const LARGE_FONT_SIZE = '1.12rem';
|
|
19
|
-
const LARGE_BORDER_RADIUS = '1.75rem';
|
|
20
|
-
|
|
21
|
-
const DEFAULT_VERTICAL = '0.18rem';
|
|
22
|
-
const DEFAULT_HORIZONTAL_WITH_VALUE = '0.5rem';
|
|
23
|
-
const DEFAULT_HORIZONTAL_WITHOUT_VALUE = '0.75rem';
|
|
24
|
-
const DEFAULT_FONT_SIZE = '1rem';
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<script
|
|
28
|
-
lang="ts"
|
|
29
|
-
generics="T = unknown"
|
|
30
|
-
>
|
|
31
|
-
// `BubbleProps<T>` is intentionally annotated with `<T>` even though
|
|
32
|
-
// the interface declares `T = unknown` as a default; the explicit
|
|
33
|
-
// substitution flows the generic from `<Bubble<MyType> ...>` consumers
|
|
34
|
-
// into the destructured `options` array type. The lint rule
|
|
35
|
-
// `@typescript-eslint/no-unnecessary-type-arguments` flags this as
|
|
36
|
-
// redundant when `T` resolves to `unknown` at the lint pass, hence
|
|
37
|
-
// the disable.
|
|
38
|
-
const {
|
|
39
|
-
options,
|
|
40
|
-
value,
|
|
41
|
-
colours,
|
|
42
|
-
label,
|
|
43
|
-
size = Size.Medium,
|
|
44
|
-
bold,
|
|
45
|
-
icon,
|
|
46
|
-
onclick,
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
|
|
48
|
-
}: BubbleProps<T> = $props();
|
|
49
|
-
|
|
50
|
-
const isLarge = $derived(size === Size.Large);
|
|
51
|
-
const verticalPadding = $derived(isLarge ? LARGE_VERTICAL : DEFAULT_VERTICAL);
|
|
52
|
-
const horizontalPadding = $derived.by(() => {
|
|
53
|
-
if (value.length === 1) {
|
|
54
|
-
return isLarge ? LARGE_HORIZONTAL_WITH_VALUE : DEFAULT_HORIZONTAL_WITH_VALUE;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return isLarge ? LARGE_HORIZONTAL_WITHOUT_VALUE : DEFAULT_HORIZONTAL_WITHOUT_VALUE;
|
|
58
|
-
});
|
|
59
|
-
const fontSize = $derived(isLarge ? LARGE_FONT_SIZE : DEFAULT_FONT_SIZE);
|
|
60
|
-
|
|
61
|
-
// Precompute the label lookup once per `options`/`value` change.
|
|
62
|
-
const displayLabel = $derived(
|
|
63
|
-
options?.length ? (options.find((it) => it.value === value)?.label ?? value) : value
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
// Precompute the inline style string once per reactive input change.
|
|
67
|
-
const wrapperStyle = $derived.by(() => {
|
|
68
|
-
const colourPart = colours
|
|
69
|
-
? `background-color: ${colours.backgroundColour}; color: ${colours.colour};`
|
|
70
|
-
: '';
|
|
71
|
-
const radiusPart = isLarge ? `border-radius: ${LARGE_BORDER_RADIUS};` : '';
|
|
72
|
-
return `${colourPart} padding: var(--bubble-padding, ${verticalPadding} ${horizontalPadding}); font-size: ${fontSize}; ${radiusPart}`;
|
|
73
|
-
});
|
|
74
|
-
</script>
|
|
75
|
-
|
|
76
|
-
{#if onclick}
|
|
77
|
-
<button
|
|
78
|
-
class="contents"
|
|
79
|
-
{onclick}
|
|
80
|
-
>
|
|
81
|
-
<!-- eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -->
|
|
82
|
-
{@render bubble()}
|
|
83
|
-
</button>
|
|
84
|
-
{:else}
|
|
85
|
-
<!-- eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -->
|
|
86
|
-
{@render bubble()}
|
|
87
|
-
{/if}
|
|
88
|
-
|
|
89
|
-
{#snippet bubble()}
|
|
90
|
-
<span
|
|
91
|
-
class="bubble"
|
|
92
|
-
class:bold
|
|
93
|
-
class:hoverable={!!onclick}
|
|
94
|
-
style={wrapperStyle}
|
|
95
|
-
>{#if label}{label}: {/if}{displayLabel}{#if icon}<div class="icon">
|
|
96
|
-
<Icon {...icon} />
|
|
97
|
-
</div>{/if}</span
|
|
98
|
-
>
|
|
99
|
-
{/snippet}
|
|
100
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script
|
|
4
|
+
lang="ts"
|
|
5
|
+
module
|
|
6
|
+
>
|
|
7
|
+
import { Size } from '../Types/Internal/Size.js';
|
|
8
|
+
import type { BubbleProps } from './BubbleProps.js';
|
|
9
|
+
import Icon from './Icon.svelte';
|
|
10
|
+
|
|
11
|
+
// Per-size padding/typography. Only `Size.Large` has explicit overrides;
|
|
12
|
+
// other sizes fall back to the medium defaults handled in $derived blocks
|
|
13
|
+
// below. Replaced the previous one-key `Partial<Record<Size, string>>`
|
|
14
|
+
// lookup tables with a simple `size === Size.Large` branch.
|
|
15
|
+
const LARGE_HORIZONTAL_WITH_VALUE = '1rem';
|
|
16
|
+
const LARGE_HORIZONTAL_WITHOUT_VALUE = '1.25rem';
|
|
17
|
+
const LARGE_VERTICAL = '0.5rem';
|
|
18
|
+
const LARGE_FONT_SIZE = '1.12rem';
|
|
19
|
+
const LARGE_BORDER_RADIUS = '1.75rem';
|
|
20
|
+
|
|
21
|
+
const DEFAULT_VERTICAL = '0.18rem';
|
|
22
|
+
const DEFAULT_HORIZONTAL_WITH_VALUE = '0.5rem';
|
|
23
|
+
const DEFAULT_HORIZONTAL_WITHOUT_VALUE = '0.75rem';
|
|
24
|
+
const DEFAULT_FONT_SIZE = '1rem';
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script
|
|
28
|
+
lang="ts"
|
|
29
|
+
generics="T = unknown"
|
|
30
|
+
>
|
|
31
|
+
// `BubbleProps<T>` is intentionally annotated with `<T>` even though
|
|
32
|
+
// the interface declares `T = unknown` as a default; the explicit
|
|
33
|
+
// substitution flows the generic from `<Bubble<MyType> ...>` consumers
|
|
34
|
+
// into the destructured `options` array type. The lint rule
|
|
35
|
+
// `@typescript-eslint/no-unnecessary-type-arguments` flags this as
|
|
36
|
+
// redundant when `T` resolves to `unknown` at the lint pass, hence
|
|
37
|
+
// the disable.
|
|
38
|
+
const {
|
|
39
|
+
options,
|
|
40
|
+
value,
|
|
41
|
+
colours,
|
|
42
|
+
label,
|
|
43
|
+
size = Size.Medium,
|
|
44
|
+
bold,
|
|
45
|
+
icon,
|
|
46
|
+
onclick,
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
|
|
48
|
+
}: BubbleProps<T> = $props();
|
|
49
|
+
|
|
50
|
+
const isLarge = $derived(size === Size.Large);
|
|
51
|
+
const verticalPadding = $derived(isLarge ? LARGE_VERTICAL : DEFAULT_VERTICAL);
|
|
52
|
+
const horizontalPadding = $derived.by(() => {
|
|
53
|
+
if (value.length === 1) {
|
|
54
|
+
return isLarge ? LARGE_HORIZONTAL_WITH_VALUE : DEFAULT_HORIZONTAL_WITH_VALUE;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return isLarge ? LARGE_HORIZONTAL_WITHOUT_VALUE : DEFAULT_HORIZONTAL_WITHOUT_VALUE;
|
|
58
|
+
});
|
|
59
|
+
const fontSize = $derived(isLarge ? LARGE_FONT_SIZE : DEFAULT_FONT_SIZE);
|
|
60
|
+
|
|
61
|
+
// Precompute the label lookup once per `options`/`value` change.
|
|
62
|
+
const displayLabel = $derived(
|
|
63
|
+
options?.length ? (options.find((it) => it.value === value)?.label ?? value) : value
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// Precompute the inline style string once per reactive input change.
|
|
67
|
+
const wrapperStyle = $derived.by(() => {
|
|
68
|
+
const colourPart = colours
|
|
69
|
+
? `background-color: ${colours.backgroundColour}; color: ${colours.colour};`
|
|
70
|
+
: '';
|
|
71
|
+
const radiusPart = isLarge ? `border-radius: ${LARGE_BORDER_RADIUS};` : '';
|
|
72
|
+
return `${colourPart} padding: var(--bubble-padding, ${verticalPadding} ${horizontalPadding}); font-size: ${fontSize}; ${radiusPart}`;
|
|
73
|
+
});
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
{#if onclick}
|
|
77
|
+
<button
|
|
78
|
+
class="contents"
|
|
79
|
+
{onclick}
|
|
80
|
+
>
|
|
81
|
+
<!-- eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -->
|
|
82
|
+
{@render bubble()}
|
|
83
|
+
</button>
|
|
84
|
+
{:else}
|
|
85
|
+
<!-- eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -->
|
|
86
|
+
{@render bubble()}
|
|
87
|
+
{/if}
|
|
88
|
+
|
|
89
|
+
{#snippet bubble()}
|
|
90
|
+
<span
|
|
91
|
+
class="bubble"
|
|
92
|
+
class:bold
|
|
93
|
+
class:hoverable={!!onclick}
|
|
94
|
+
style={wrapperStyle}
|
|
95
|
+
>{#if label}{label}: {/if}{displayLabel}{#if icon}<div class="icon">
|
|
96
|
+
<Icon {...icon} />
|
|
97
|
+
</div>{/if}</span
|
|
98
|
+
>
|
|
99
|
+
{/snippet}
|
|
100
|
+
|
|
101
101
|
<style>button.contents {
|
|
102
102
|
display: contents;
|
|
103
103
|
cursor: pointer;
|
|
@@ -128,4 +128,4 @@
|
|
|
128
128
|
}
|
|
129
129
|
.bubble.bold {
|
|
130
130
|
font-weight: 700;
|
|
131
|
-
}</style>
|
|
131
|
+
}</style>
|
|
@@ -1,211 +1,211 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script
|
|
4
|
-
module
|
|
5
|
-
lang="ts"
|
|
6
|
-
>
|
|
7
|
-
import { passthrough } from '../Helpers/Helpers.svelte.js';
|
|
8
|
-
import { useTooltip } from '../Helpers/useTooltip.svelte.js';
|
|
9
|
-
import { Colour, ColourSet } from '../scss/colours.js';
|
|
10
|
-
import { Side } from '../Types/Internal/Side.js';
|
|
11
|
-
import { Size } from '../Types/Internal/Size.js';
|
|
12
|
-
import { Variant } from '../Types/Internal/Variant.js';
|
|
13
|
-
import type { ButtonProps } from './ButtonProps.js';
|
|
14
|
-
import Icon from './Icon.svelte';
|
|
15
|
-
|
|
16
|
-
const paddingSizesVertical: Record<Size, string> = {
|
|
17
|
-
[Size.Tiny]: '0.25rem',
|
|
18
|
-
[Size.Small]: '0.375rem',
|
|
19
|
-
[Size.MediumSmall]: '0.5rem',
|
|
20
|
-
// [Size.Medium]: '0.625rem',
|
|
21
|
-
[Size.Medium]: '0.90625rem',
|
|
22
|
-
[Size.MediumLarge]: '0.90625rem',
|
|
23
|
-
[Size.Large]: '0.925rem',
|
|
24
|
-
[Size.XLarge]: '1.0125rem',
|
|
25
|
-
[Size.DoubleXLarge]: '1.1rem',
|
|
26
|
-
[Size.TripleXLarge]: '1.2975rem',
|
|
27
|
-
[Size.FillWidth]: '0.75rem', // TODO decide
|
|
28
|
-
[Size.FillHeight]: '0', // TODO decide
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// TODO alter the values for these if required
|
|
32
|
-
const paddingSizesHorizontal: Record<Size, string> = {
|
|
33
|
-
[Size.Tiny]: '0.4875rem',
|
|
34
|
-
[Size.Small]: '0.8rem',
|
|
35
|
-
[Size.MediumSmall]: '0.6625rem',
|
|
36
|
-
[Size.Medium]: '0.75rem',
|
|
37
|
-
[Size.MediumLarge]: '0.8375rem',
|
|
38
|
-
[Size.Large]: '0.925rem',
|
|
39
|
-
[Size.XLarge]: '1.0125rem',
|
|
40
|
-
[Size.DoubleXLarge]: '1.1rem',
|
|
41
|
-
[Size.TripleXLarge]: '1.2975rem',
|
|
42
|
-
[Size.FillWidth]: '0.75rem', // TODO decide
|
|
43
|
-
[Size.FillHeight]: '0.75rem', // TODO decide
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// const fontSizes: Record<Size, string> = {
|
|
47
|
-
// [Size.Tiny]: '0.8rem',
|
|
48
|
-
// [Size.Small]: '0.85rem',
|
|
49
|
-
// [Size.MediumSmall]: '0.94rem',
|
|
50
|
-
// [Size.Medium]: '1rem',
|
|
51
|
-
// [Size.MediumLarge]: '1rem',
|
|
52
|
-
// [Size.Large]: '1.16rem',
|
|
53
|
-
// [Size.XLarge]: '1.32rem',
|
|
54
|
-
// [Size.DoubleXLarge]: '1.48rem',
|
|
55
|
-
// [Size.TripleXLarge]: '1.64rem',
|
|
56
|
-
// [Size.FillWidth]: '1rem', // TODO decide
|
|
57
|
-
// [Size.FillHeight]: '1rem' // TODO decide
|
|
58
|
-
// };
|
|
59
|
-
|
|
60
|
-
// TODO
|
|
61
|
-
const borderSizes: Record<Size, string> = {
|
|
62
|
-
[Size.Tiny]: '0.1875rem',
|
|
63
|
-
[Size.Small]: '0.1875rem',
|
|
64
|
-
[Size.MediumSmall]: '0.1875rem',
|
|
65
|
-
[Size.Medium]: '0.1875rem',
|
|
66
|
-
[Size.MediumLarge]: '0.1875rem',
|
|
67
|
-
[Size.Large]: '0.1875rem',
|
|
68
|
-
[Size.XLarge]: '0.1875rem',
|
|
69
|
-
[Size.DoubleXLarge]: '0.1875rem',
|
|
70
|
-
[Size.TripleXLarge]: '0.1875rem',
|
|
71
|
-
[Size.FillWidth]: '0.1875rem', // TODO decide
|
|
72
|
-
[Size.FillHeight]: '0.1875rem', // TODO decide
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const iconColours: Record<ColourSet, Colour | undefined> = {
|
|
76
|
-
[ColourSet.Primary]: Colour['$ui-white'],
|
|
77
|
-
[ColourSet.CallToAction]: Colour['$ui-white'],
|
|
78
|
-
[ColourSet.Secondary]: Colour['$ui-blue-14'],
|
|
79
|
-
[ColourSet.Auxiliary]: Colour['$font-primary'],
|
|
80
|
-
[ColourSet.Warning]: Colour['$error-border'],
|
|
81
|
-
[ColourSet.Error]: Colour['$error-border'],
|
|
82
|
-
[ColourSet.Info]: Colour['$primary-blue-13'],
|
|
83
|
-
};
|
|
84
|
-
</script>
|
|
85
|
-
|
|
86
|
-
<script lang="ts">
|
|
87
|
-
const {
|
|
88
|
-
type = 'button',
|
|
89
|
-
variant = Variant.Default,
|
|
90
|
-
toggled = false,
|
|
91
|
-
iconLeft,
|
|
92
|
-
iconTop,
|
|
93
|
-
iconRight,
|
|
94
|
-
iconBottom,
|
|
95
|
-
nowrap = false,
|
|
96
|
-
side,
|
|
97
|
-
size = Size.Medium,
|
|
98
|
-
label,
|
|
99
|
-
colourSet = ColourSet.Secondary,
|
|
100
|
-
dashed = false,
|
|
101
|
-
disabled = false,
|
|
102
|
-
fullWidth = false,
|
|
103
|
-
onclick,
|
|
104
|
-
onfocus,
|
|
105
|
-
onblur,
|
|
106
|
-
onkeydown: onkeydownProp,
|
|
107
|
-
children,
|
|
108
|
-
relative,
|
|
109
|
-
noninteractive,
|
|
110
|
-
}: ButtonProps = $props();
|
|
111
|
-
function onkeydown(e: KeyboardEvent): void {
|
|
112
|
-
passthrough(e);
|
|
113
|
-
if (document.activeElement === e.target) {
|
|
114
|
-
onkeydownProp?.(e);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Shared tooltip lifecycle: hover handlers plus unmount-time teardown so
|
|
119
|
-
// a rapidly-churning host (toolbar, table row) does not leave the global
|
|
120
|
-
// tooltip host painting against a node that no longer exists. The helper
|
|
121
|
-
// also exposes an `onclick` hook that we compose with the consumer's
|
|
122
|
-
// `onclick`. The extra `$effect` dismisses the tooltip when `disabled`
|
|
123
|
-
// flips to true mid-hover - the disabled element will not fire its own
|
|
124
|
-
// `mouseleave`.
|
|
125
|
-
const tt = useTooltip({
|
|
126
|
-
text: () => label,
|
|
127
|
-
arrow: () => side ?? Side.Left,
|
|
128
|
-
});
|
|
129
|
-
$effect(() => {
|
|
130
|
-
if (disabled) {
|
|
131
|
-
tt.onmouseleave();
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
</script>
|
|
135
|
-
|
|
136
|
-
<!-- title={label} -->
|
|
137
|
-
<!-- style="--font-size: {fontSizes[
|
|
138
|
-
size
|
|
139
|
-
]};" -->
|
|
140
|
-
<button
|
|
141
|
-
onmouseenter={tt.onmouseenter}
|
|
142
|
-
onmouseleave={tt.onmouseleave}
|
|
143
|
-
class:noninteractive
|
|
144
|
-
class:relative
|
|
145
|
-
class:default={variant === Variant.Default}
|
|
146
|
-
class:card-inner={variant === Variant.CardInner}
|
|
147
|
-
class:card={variant === Variant.Card}
|
|
148
|
-
class:call-to-action={colourSet === ColourSet.CallToAction}
|
|
149
|
-
class:primary={colourSet === ColourSet.Primary}
|
|
150
|
-
class:secondary-colour={colourSet === ColourSet.Secondary}
|
|
151
|
-
class:secondary-variant={variant === Variant.Secondary}
|
|
152
|
-
class:warning={colourSet === ColourSet.Warning}
|
|
153
|
-
class:error={colourSet === ColourSet.Error}
|
|
154
|
-
class:info={colourSet === ColourSet.Info}
|
|
155
|
-
class:fill-height={size === Size.FillHeight}
|
|
156
|
-
class:fill-width={size === Size.FillWidth}
|
|
157
|
-
style="--fallback-padding-horizontal: {paddingSizesHorizontal[
|
|
158
|
-
size
|
|
159
|
-
]}; --fallback-padding-vertical: {paddingSizesVertical[size]}; --border-width: {borderSizes[
|
|
160
|
-
size
|
|
161
|
-
]};"
|
|
162
|
-
class:dashed
|
|
163
|
-
class:full-width={fullWidth}
|
|
164
|
-
class:toolbar={variant === Variant.Toolbar}
|
|
165
|
-
class:left={side === Side.Left}
|
|
166
|
-
class:right={side === Side.Right}
|
|
167
|
-
class:top={side === Side.Top}
|
|
168
|
-
class:bottom={side === Side.Bottom}
|
|
169
|
-
class:toggled
|
|
170
|
-
class:nowrap
|
|
171
|
-
{type}
|
|
172
|
-
aria-label={label}
|
|
173
|
-
{disabled}
|
|
174
|
-
onclick={(e) => {
|
|
175
|
-
tt.onclick();
|
|
176
|
-
onclick?.(e);
|
|
177
|
-
}}
|
|
178
|
-
{onfocus}
|
|
179
|
-
{onblur}
|
|
180
|
-
{onkeydown}
|
|
181
|
-
>
|
|
182
|
-
<div class="icon-container">
|
|
183
|
-
{#if iconLeft}
|
|
184
|
-
<Icon
|
|
185
|
-
{...iconLeft}
|
|
186
|
-
colour={iconColours[colourSet]}
|
|
187
|
-
size={iconLeft.size ?? size}
|
|
188
|
-
/>
|
|
189
|
-
{/if}
|
|
190
|
-
{#if iconTop}
|
|
191
|
-
<Icon {...iconTop} />
|
|
192
|
-
{/if}
|
|
193
|
-
{#if children}
|
|
194
|
-
<span>{@render children()}</span>
|
|
195
|
-
{/if}
|
|
196
|
-
{#if iconBottom}
|
|
197
|
-
<Icon {...iconBottom} />
|
|
198
|
-
{/if}
|
|
199
|
-
{#if iconRight}
|
|
200
|
-
<Icon
|
|
201
|
-
{...iconRight}
|
|
202
|
-
colour={iconColours[colourSet]}
|
|
203
|
-
size={iconRight.size ?? size}
|
|
204
|
-
/>
|
|
205
|
-
{/if}
|
|
206
|
-
</div>
|
|
207
|
-
</button>
|
|
208
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script
|
|
4
|
+
module
|
|
5
|
+
lang="ts"
|
|
6
|
+
>
|
|
7
|
+
import { passthrough } from '../Helpers/Helpers.svelte.js';
|
|
8
|
+
import { useTooltip } from '../Helpers/useTooltip.svelte.js';
|
|
9
|
+
import { Colour, ColourSet } from '../scss/colours.js';
|
|
10
|
+
import { Side } from '../Types/Internal/Side.js';
|
|
11
|
+
import { Size } from '../Types/Internal/Size.js';
|
|
12
|
+
import { Variant } from '../Types/Internal/Variant.js';
|
|
13
|
+
import type { ButtonProps } from './ButtonProps.js';
|
|
14
|
+
import Icon from './Icon.svelte';
|
|
15
|
+
|
|
16
|
+
const paddingSizesVertical: Record<Size, string> = {
|
|
17
|
+
[Size.Tiny]: '0.25rem',
|
|
18
|
+
[Size.Small]: '0.375rem',
|
|
19
|
+
[Size.MediumSmall]: '0.5rem',
|
|
20
|
+
// [Size.Medium]: '0.625rem',
|
|
21
|
+
[Size.Medium]: '0.90625rem',
|
|
22
|
+
[Size.MediumLarge]: '0.90625rem',
|
|
23
|
+
[Size.Large]: '0.925rem',
|
|
24
|
+
[Size.XLarge]: '1.0125rem',
|
|
25
|
+
[Size.DoubleXLarge]: '1.1rem',
|
|
26
|
+
[Size.TripleXLarge]: '1.2975rem',
|
|
27
|
+
[Size.FillWidth]: '0.75rem', // TODO decide
|
|
28
|
+
[Size.FillHeight]: '0', // TODO decide
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// TODO alter the values for these if required
|
|
32
|
+
const paddingSizesHorizontal: Record<Size, string> = {
|
|
33
|
+
[Size.Tiny]: '0.4875rem',
|
|
34
|
+
[Size.Small]: '0.8rem',
|
|
35
|
+
[Size.MediumSmall]: '0.6625rem',
|
|
36
|
+
[Size.Medium]: '0.75rem',
|
|
37
|
+
[Size.MediumLarge]: '0.8375rem',
|
|
38
|
+
[Size.Large]: '0.925rem',
|
|
39
|
+
[Size.XLarge]: '1.0125rem',
|
|
40
|
+
[Size.DoubleXLarge]: '1.1rem',
|
|
41
|
+
[Size.TripleXLarge]: '1.2975rem',
|
|
42
|
+
[Size.FillWidth]: '0.75rem', // TODO decide
|
|
43
|
+
[Size.FillHeight]: '0.75rem', // TODO decide
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// const fontSizes: Record<Size, string> = {
|
|
47
|
+
// [Size.Tiny]: '0.8rem',
|
|
48
|
+
// [Size.Small]: '0.85rem',
|
|
49
|
+
// [Size.MediumSmall]: '0.94rem',
|
|
50
|
+
// [Size.Medium]: '1rem',
|
|
51
|
+
// [Size.MediumLarge]: '1rem',
|
|
52
|
+
// [Size.Large]: '1.16rem',
|
|
53
|
+
// [Size.XLarge]: '1.32rem',
|
|
54
|
+
// [Size.DoubleXLarge]: '1.48rem',
|
|
55
|
+
// [Size.TripleXLarge]: '1.64rem',
|
|
56
|
+
// [Size.FillWidth]: '1rem', // TODO decide
|
|
57
|
+
// [Size.FillHeight]: '1rem' // TODO decide
|
|
58
|
+
// };
|
|
59
|
+
|
|
60
|
+
// TODO
|
|
61
|
+
const borderSizes: Record<Size, string> = {
|
|
62
|
+
[Size.Tiny]: '0.1875rem',
|
|
63
|
+
[Size.Small]: '0.1875rem',
|
|
64
|
+
[Size.MediumSmall]: '0.1875rem',
|
|
65
|
+
[Size.Medium]: '0.1875rem',
|
|
66
|
+
[Size.MediumLarge]: '0.1875rem',
|
|
67
|
+
[Size.Large]: '0.1875rem',
|
|
68
|
+
[Size.XLarge]: '0.1875rem',
|
|
69
|
+
[Size.DoubleXLarge]: '0.1875rem',
|
|
70
|
+
[Size.TripleXLarge]: '0.1875rem',
|
|
71
|
+
[Size.FillWidth]: '0.1875rem', // TODO decide
|
|
72
|
+
[Size.FillHeight]: '0.1875rem', // TODO decide
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const iconColours: Record<ColourSet, Colour | undefined> = {
|
|
76
|
+
[ColourSet.Primary]: Colour['$ui-white'],
|
|
77
|
+
[ColourSet.CallToAction]: Colour['$ui-white'],
|
|
78
|
+
[ColourSet.Secondary]: Colour['$ui-blue-14'],
|
|
79
|
+
[ColourSet.Auxiliary]: Colour['$font-primary'],
|
|
80
|
+
[ColourSet.Warning]: Colour['$error-border'],
|
|
81
|
+
[ColourSet.Error]: Colour['$error-border'],
|
|
82
|
+
[ColourSet.Info]: Colour['$primary-blue-13'],
|
|
83
|
+
};
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<script lang="ts">
|
|
87
|
+
const {
|
|
88
|
+
type = 'button',
|
|
89
|
+
variant = Variant.Default,
|
|
90
|
+
toggled = false,
|
|
91
|
+
iconLeft,
|
|
92
|
+
iconTop,
|
|
93
|
+
iconRight,
|
|
94
|
+
iconBottom,
|
|
95
|
+
nowrap = false,
|
|
96
|
+
side,
|
|
97
|
+
size = Size.Medium,
|
|
98
|
+
label,
|
|
99
|
+
colourSet = ColourSet.Secondary,
|
|
100
|
+
dashed = false,
|
|
101
|
+
disabled = false,
|
|
102
|
+
fullWidth = false,
|
|
103
|
+
onclick,
|
|
104
|
+
onfocus,
|
|
105
|
+
onblur,
|
|
106
|
+
onkeydown: onkeydownProp,
|
|
107
|
+
children,
|
|
108
|
+
relative,
|
|
109
|
+
noninteractive,
|
|
110
|
+
}: ButtonProps = $props();
|
|
111
|
+
function onkeydown(e: KeyboardEvent): void {
|
|
112
|
+
passthrough(e);
|
|
113
|
+
if (document.activeElement === e.target) {
|
|
114
|
+
onkeydownProp?.(e);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Shared tooltip lifecycle: hover handlers plus unmount-time teardown so
|
|
119
|
+
// a rapidly-churning host (toolbar, table row) does not leave the global
|
|
120
|
+
// tooltip host painting against a node that no longer exists. The helper
|
|
121
|
+
// also exposes an `onclick` hook that we compose with the consumer's
|
|
122
|
+
// `onclick`. The extra `$effect` dismisses the tooltip when `disabled`
|
|
123
|
+
// flips to true mid-hover - the disabled element will not fire its own
|
|
124
|
+
// `mouseleave`.
|
|
125
|
+
const tt = useTooltip({
|
|
126
|
+
text: () => label,
|
|
127
|
+
arrow: () => side ?? Side.Left,
|
|
128
|
+
});
|
|
129
|
+
$effect(() => {
|
|
130
|
+
if (disabled) {
|
|
131
|
+
tt.onmouseleave();
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
</script>
|
|
135
|
+
|
|
136
|
+
<!-- title={label} -->
|
|
137
|
+
<!-- style="--font-size: {fontSizes[
|
|
138
|
+
size
|
|
139
|
+
]};" -->
|
|
140
|
+
<button
|
|
141
|
+
onmouseenter={tt.onmouseenter}
|
|
142
|
+
onmouseleave={tt.onmouseleave}
|
|
143
|
+
class:noninteractive
|
|
144
|
+
class:relative
|
|
145
|
+
class:default={variant === Variant.Default}
|
|
146
|
+
class:card-inner={variant === Variant.CardInner}
|
|
147
|
+
class:card={variant === Variant.Card}
|
|
148
|
+
class:call-to-action={colourSet === ColourSet.CallToAction}
|
|
149
|
+
class:primary={colourSet === ColourSet.Primary}
|
|
150
|
+
class:secondary-colour={colourSet === ColourSet.Secondary}
|
|
151
|
+
class:secondary-variant={variant === Variant.Secondary}
|
|
152
|
+
class:warning={colourSet === ColourSet.Warning}
|
|
153
|
+
class:error={colourSet === ColourSet.Error}
|
|
154
|
+
class:info={colourSet === ColourSet.Info}
|
|
155
|
+
class:fill-height={size === Size.FillHeight}
|
|
156
|
+
class:fill-width={size === Size.FillWidth}
|
|
157
|
+
style="--fallback-padding-horizontal: {paddingSizesHorizontal[
|
|
158
|
+
size
|
|
159
|
+
]}; --fallback-padding-vertical: {paddingSizesVertical[size]}; --border-width: {borderSizes[
|
|
160
|
+
size
|
|
161
|
+
]};"
|
|
162
|
+
class:dashed
|
|
163
|
+
class:full-width={fullWidth}
|
|
164
|
+
class:toolbar={variant === Variant.Toolbar}
|
|
165
|
+
class:left={side === Side.Left}
|
|
166
|
+
class:right={side === Side.Right}
|
|
167
|
+
class:top={side === Side.Top}
|
|
168
|
+
class:bottom={side === Side.Bottom}
|
|
169
|
+
class:toggled
|
|
170
|
+
class:nowrap
|
|
171
|
+
{type}
|
|
172
|
+
aria-label={label}
|
|
173
|
+
{disabled}
|
|
174
|
+
onclick={(e) => {
|
|
175
|
+
tt.onclick();
|
|
176
|
+
onclick?.(e);
|
|
177
|
+
}}
|
|
178
|
+
{onfocus}
|
|
179
|
+
{onblur}
|
|
180
|
+
{onkeydown}
|
|
181
|
+
>
|
|
182
|
+
<div class="icon-container">
|
|
183
|
+
{#if iconLeft}
|
|
184
|
+
<Icon
|
|
185
|
+
{...iconLeft}
|
|
186
|
+
colour={iconColours[colourSet]}
|
|
187
|
+
size={iconLeft.size ?? size}
|
|
188
|
+
/>
|
|
189
|
+
{/if}
|
|
190
|
+
{#if iconTop}
|
|
191
|
+
<Icon {...iconTop} />
|
|
192
|
+
{/if}
|
|
193
|
+
{#if children}
|
|
194
|
+
<span>{@render children()}</span>
|
|
195
|
+
{/if}
|
|
196
|
+
{#if iconBottom}
|
|
197
|
+
<Icon {...iconBottom} />
|
|
198
|
+
{/if}
|
|
199
|
+
{#if iconRight}
|
|
200
|
+
<Icon
|
|
201
|
+
{...iconRight}
|
|
202
|
+
colour={iconColours[colourSet]}
|
|
203
|
+
size={iconRight.size ?? size}
|
|
204
|
+
/>
|
|
205
|
+
{/if}
|
|
206
|
+
</div>
|
|
207
|
+
</button>
|
|
208
|
+
|
|
209
209
|
<style>.card {
|
|
210
210
|
color: #3a4952;
|
|
211
211
|
fill: #3a4952;
|
|
@@ -519,4 +519,4 @@ button.toolbar:not([disabled]).toggled.bottom {
|
|
|
519
519
|
}
|
|
520
520
|
button.toolbar:not([disabled]).toggled svg {
|
|
521
521
|
fill: #259fc7;
|
|
522
|
-
}</style>
|
|
522
|
+
}</style>
|