@lavalogic/scoria 0.40.1 → 0.40.3

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 (137) 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/Contexts/ContextMenu.svelte +164 -164
  17. package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
  18. package/dist/Components/Contexts/ContextMenuOption.svelte +60 -60
  19. package/dist/Components/Contexts/Toast.svelte +86 -86
  20. package/dist/Components/Contexts/ToastContainer.svelte +65 -65
  21. package/dist/Components/Contexts/Tooltip.svelte +37 -37
  22. package/dist/Components/DataMatrixIcon.svelte +112 -112
  23. package/dist/Components/DateInput.svelte +148 -148
  24. package/dist/Components/DatePicker.svelte +300 -300
  25. package/dist/Components/DesktopModal.svelte +90 -90
  26. package/dist/Components/Dial.svelte +204 -204
  27. package/dist/Components/DimensionInput.svelte +170 -170
  28. package/dist/Components/DragMenu/DragMenuHolder.svelte +119 -119
  29. package/dist/Components/DragMenu/DraggableCard.svelte +77 -77
  30. package/dist/Components/FileCard.svelte +24 -24
  31. package/dist/Components/FileUpload.svelte +236 -236
  32. package/dist/Components/GridInput.svelte +196 -196
  33. package/dist/Components/GridInputSet.svelte +29 -29
  34. package/dist/Components/HorizontalTabGroup.svelte +82 -82
  35. package/dist/Components/HorizontalTabGroupButton.svelte +44 -44
  36. package/dist/Components/Icon.svelte +128 -128
  37. package/dist/Components/Icons.js +357 -357
  38. package/dist/Components/InfoAlert.svelte +35 -35
  39. package/dist/Components/LoadingAnimation.svelte +29 -29
  40. package/dist/Components/LoadingModal.svelte +45 -45
  41. package/dist/Components/LoadingOverlay.svelte +25 -25
  42. package/dist/Components/Modal.svelte +258 -258
  43. package/dist/Components/MultiSelect.svelte +220 -220
  44. package/dist/Components/Nav/Nav.svelte +110 -110
  45. package/dist/Components/Nav/NavServiceMenuList.svelte +43 -43
  46. package/dist/Components/Nav/NavTab.svelte +62 -62
  47. package/dist/Components/Nav/ServiceMenuItem.svelte +112 -112
  48. package/dist/Components/Nav/ServicesNav.svelte +80 -80
  49. package/dist/Components/NumberInput.svelte +157 -157
  50. package/dist/Components/PageHeading.svelte +25 -25
  51. package/dist/Components/PasswordInput.svelte +88 -88
  52. package/dist/Components/Portal.svelte +36 -36
  53. package/dist/Components/ProgressBubble.svelte +107 -107
  54. package/dist/Components/QuerySelect.svelte +366 -366
  55. package/dist/Components/SingleSelect.svelte +250 -250
  56. package/dist/Components/StepButton.svelte +70 -70
  57. package/dist/Components/StepForm.svelte +140 -140
  58. package/dist/Components/Switch.svelte +69 -69
  59. package/dist/Components/Table/ARCHITECTURE.md +298 -298
  60. package/dist/Components/Table/Body/QuickSearchCell.svelte +679 -679
  61. package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +51 -51
  62. package/dist/Components/Table/Body/Rows/ColumnList.svelte +59 -59
  63. package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +454 -454
  64. package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +79 -79
  65. package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +185 -185
  66. package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +124 -124
  67. package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +163 -120
  68. package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +234 -234
  69. package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +105 -105
  70. package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +87 -87
  71. package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +160 -126
  72. package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +159 -159
  73. package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +246 -246
  74. package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +216 -216
  75. package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +252 -252
  76. package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +179 -179
  77. package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +221 -221
  78. package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +197 -197
  79. package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +190 -190
  80. package/dist/Components/Table/Body/Rows/TableRow.svelte +290 -290
  81. package/dist/Components/Table/Body/TableBody.svelte +155 -155
  82. package/dist/Components/Table/ColumnFactory.svelte.js +7 -0
  83. package/dist/Components/Table/Headers/HighlightAllHeader.svelte +41 -41
  84. package/dist/Components/Table/Headers/SelectAllHeader.svelte +30 -30
  85. package/dist/Components/Table/Headers/TableHead.svelte +415 -415
  86. package/dist/Components/Table/Misc/ColumnPanel.svelte +39 -39
  87. package/dist/Components/Table/Misc/ColumnPanelModal.svelte +39 -39
  88. package/dist/Components/Table/Misc/FilterInput.svelte +641 -641
  89. package/dist/Components/Table/Misc/FilterPanel.svelte +190 -190
  90. package/dist/Components/Table/Misc/FilterPanelModal.svelte +31 -31
  91. package/dist/Components/Table/Misc/ShareViewModal.svelte +291 -291
  92. package/dist/Components/Table/Misc/SidePanel.svelte +35 -35
  93. package/dist/Components/Table/Misc/TableConfigurationModal.svelte +644 -644
  94. package/dist/Components/Table/Misc/TableFooter.svelte +340 -340
  95. package/dist/Components/Table/Misc/TableHorizontalBar.svelte +140 -140
  96. package/dist/Components/Table/Misc/TableSidebar.svelte +200 -200
  97. package/dist/Components/Table/Misc/TableViewDropdown.svelte +105 -105
  98. package/dist/Components/Table/Misc/ToolboxPanel.svelte +100 -100
  99. package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +107 -107
  100. package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte +192 -192
  101. package/dist/Components/Table/NestedTable.svelte +130 -130
  102. package/dist/Components/Table/Table.svelte +692 -692
  103. package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.d.ts +9 -0
  104. package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.js +6 -0
  105. package/dist/Components/Table/Types/Public/ColumnOptions.d.ts +19 -0
  106. package/dist/Components/Test/TestContextConsumer.svelte +13 -13
  107. package/dist/Components/TextArea.svelte +130 -130
  108. package/dist/Components/TextInput.svelte +176 -176
  109. package/dist/Components/ThreeStateRadio.svelte +131 -131
  110. package/dist/Components/Touch/BoolCard.svelte +45 -45
  111. package/dist/Components/Touch/DateModal.svelte +209 -209
  112. package/dist/Components/Touch/EditCard.svelte +59 -59
  113. package/dist/Components/Touch/InfoCard.svelte +31 -31
  114. package/dist/Components/Touch/InfoTextCard.svelte +28 -28
  115. package/dist/Components/Touch/ModalExplanation.svelte +17 -17
  116. package/dist/Components/Touch/NumberKeyboard.svelte +225 -225
  117. package/dist/Components/Touch/NumberModal.svelte +79 -79
  118. package/dist/Components/Touch/PlusMinusCard.svelte +46 -46
  119. package/dist/Components/Touch/SelectModal.svelte +127 -127
  120. package/dist/Components/Touch/SummaryCard.svelte +93 -93
  121. package/dist/Components/Touch/TextAreaModal.svelte +95 -95
  122. package/dist/Components/Touch/TextModal.svelte +106 -106
  123. package/dist/Components/Touch/TouchCard.svelte +33 -33
  124. package/dist/Components/Touch/TouchModal.svelte +274 -274
  125. package/dist/Components/Touch/UtilityButton.svelte +109 -109
  126. package/dist/Components/VerticalTabGroup.svelte +79 -79
  127. package/dist/Components/VerticalTabGroupButton.svelte +58 -58
  128. package/dist/Helpers/Datamatrix.d.ts +19 -19
  129. package/dist/Helpers/Datamatrix.js +291 -291
  130. package/dist/Types/Examples/ExampleModal.svelte +35 -35
  131. package/dist/scss/_basics.scss +12 -12
  132. package/dist/scss/_colours.scss +134 -134
  133. package/dist/scss/_mixins.scss +3392 -3392
  134. package/dist/scss/_motion.scss +57 -57
  135. package/dist/scss/_sizing.scss +85 -85
  136. package/dist/scss/_transitions.scss +8 -8
  137. package/package.json +1 -1
package/README.md CHANGED
@@ -1,58 +1,58 @@
1
- # Svelte library
2
-
3
- Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
4
-
5
- Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
6
-
7
- ## Creating a project
8
-
9
- If you're seeing this, you've probably already done this step. Congrats!
10
-
11
- ```sh
12
- # create a new project in the current directory
13
- npx sv create
14
-
15
- # create a new project in my-app
16
- npx sv create my-app
17
- ```
18
-
19
- ## Developing
20
-
21
- Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
22
-
23
- ```sh
24
- npm run dev
25
-
26
- # or start the server and open the app in a new browser tab
27
- npm run dev -- --open
28
- ```
29
-
30
- Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
31
-
32
- ## Building
33
-
34
- To build your library:
35
-
36
- ```sh
37
- npm pack
38
- ```
39
-
40
- To create a production version of your showcase app:
41
-
42
- ```sh
43
- npm run build
44
- ```
45
-
46
- You can preview the production build with `npm run preview`.
47
-
48
- > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
49
-
50
- ## Publishing
51
-
52
- Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
53
-
54
- To publish your library to [npm](https://www.npmjs.com):
55
-
56
- ```sh
57
- npm publish
58
- ```
1
+ # Svelte library
2
+
3
+ Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
4
+
5
+ Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
6
+
7
+ ## Creating a project
8
+
9
+ If you're seeing this, you've probably already done this step. Congrats!
10
+
11
+ ```sh
12
+ # create a new project in the current directory
13
+ npx sv create
14
+
15
+ # create a new project in my-app
16
+ npx sv create my-app
17
+ ```
18
+
19
+ ## Developing
20
+
21
+ Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
22
+
23
+ ```sh
24
+ npm run dev
25
+
26
+ # or start the server and open the app in a new browser tab
27
+ npm run dev -- --open
28
+ ```
29
+
30
+ Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
31
+
32
+ ## Building
33
+
34
+ To build your library:
35
+
36
+ ```sh
37
+ npm pack
38
+ ```
39
+
40
+ To create a production version of your showcase app:
41
+
42
+ ```sh
43
+ npm run build
44
+ ```
45
+
46
+ You can preview the production build with `npm run preview`.
47
+
48
+ > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
49
+
50
+ ## Publishing
51
+
52
+ Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
53
+
54
+ To publish your library to [npm](https://www.npmjs.com):
55
+
56
+ ```sh
57
+ npm publish
58
+ ```
@@ -1,48 +1,48 @@
1
- <svelte:options runes />
2
-
3
- <script
4
- lang="ts"
5
- generics="CommonDenominator"
6
- >
7
- import AccordionGroupButton from './AccordionGroupButton.svelte';
8
-
9
- import { cubicOut } from 'svelte/easing';
10
- import { slide } from 'svelte/transition';
11
- import { usePrefersReducedMotion } from '../Helpers/prefersReducedMotion.svelte.js';
12
- import type { AccordionGroupProps } from './AccordionGroupProps.js';
13
-
14
- let {
15
- // name: _name, //FIXME why is this not implemented?
16
- tabs,
17
- selected,
18
- noRadius = false,
19
- grow = false,
20
- }: AccordionGroupProps<CommonDenominator> = $props();
21
-
22
- const reducedMotion = usePrefersReducedMotion();
23
- const slideDuration = $derived(reducedMotion.matches ? 0 : 200);
24
- </script>
25
-
26
- <div
27
- class="wrapper"
28
- class:no-radius={noRadius}
29
- class:grow
30
- >
31
- {#each tabs as option (option.label)}
32
- {@const isSelected = selected === option}
33
- <AccordionGroupButton
34
- {option}
35
- {noRadius}
36
- selected={isSelected}
37
- />
38
- {#if isSelected}
39
- <div transition:slide={{ duration: slideDuration, easing: cubicOut }}>
40
- {@render selected.content(selected.args)}
41
- </div>
42
- {/if}
43
- {/each}
44
- </div>
45
-
1
+ <svelte:options runes />
2
+
3
+ <script
4
+ lang="ts"
5
+ generics="CommonDenominator"
6
+ >
7
+ import AccordionGroupButton from './AccordionGroupButton.svelte';
8
+
9
+ import { cubicOut } from 'svelte/easing';
10
+ import { slide } from 'svelte/transition';
11
+ import { usePrefersReducedMotion } from '../Helpers/prefersReducedMotion.svelte.js';
12
+ import type { AccordionGroupProps } from './AccordionGroupProps.js';
13
+
14
+ let {
15
+ // name: _name, //FIXME why is this not implemented?
16
+ tabs,
17
+ selected,
18
+ noRadius = false,
19
+ grow = false,
20
+ }: AccordionGroupProps<CommonDenominator> = $props();
21
+
22
+ const reducedMotion = usePrefersReducedMotion();
23
+ const slideDuration = $derived(reducedMotion.matches ? 0 : 200);
24
+ </script>
25
+
26
+ <div
27
+ class="wrapper"
28
+ class:no-radius={noRadius}
29
+ class:grow
30
+ >
31
+ {#each tabs as option (option.label)}
32
+ {@const isSelected = selected === option}
33
+ <AccordionGroupButton
34
+ {option}
35
+ {noRadius}
36
+ selected={isSelected}
37
+ />
38
+ {#if isSelected}
39
+ <div transition:slide={{ duration: slideDuration, easing: cubicOut }}>
40
+ {@render selected.content(selected.args)}
41
+ </div>
42
+ {/if}
43
+ {/each}
44
+ </div>
45
+
46
46
  <style>.wrapper {
47
47
  box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.1333333333);
48
48
  border-radius: 4px;
@@ -86,4 +86,4 @@
86
86
  flex-grow: 1;
87
87
  overflow: visible;
88
88
  border-radius: 0 4px 0 4px;
89
- }</style>
89
+ }</style>
@@ -1,78 +1,78 @@
1
- <svelte:options runes />
2
-
3
- <script
4
- lang="ts"
5
- generics="Args"
6
- >
7
- import { useAsyncFlag } from '../Helpers/AsyncFlag.svelte.js';
8
- import { Colour } from '../scss/colours.js';
9
- import { Size } from '../Types/Internal/Size.js';
10
- import type { AccordionGroupButtonProps } from './AccordionGroupButtonProps.js';
11
- import Icon from './Icon.svelte';
12
-
13
- const {
14
- option,
15
- selected: isSelected,
16
- noRadius = false,
17
- }: AccordionGroupButtonProps<Args> = $props();
18
-
19
- const isValid = useAsyncFlag(() => option.isValid, true);
20
- const disabled = useAsyncFlag(() => option.disabled, false);
21
- const isVisible = useAsyncFlag(() => option.visible, true);
22
- </script>
23
-
24
- <!--
25
- Single-button row: the whole header is one interactive element, with the
26
- expand chevron rendered as decorative content of that same button. This
27
- resolves the previous a11y issue (a nested toggle inside the row read as
28
- two interactive elements). The `extras` snippet is intentionally placed
29
- OUTSIDE the button so that consumers passing interactive content into
30
- `extras` don't create nested-button markup.
31
- -->
32
- <div
33
- class="tab-wrapper"
34
- class:isSelected
35
- class:invalid={!isValid.value}
36
- class:hidden={!isVisible.value}
37
- class:no-radius={noRadius}
38
- >
39
- <button
40
- type="button"
41
- class="tab"
42
- disabled={disabled.value}
43
- aria-expanded={isSelected}
44
- aria-label={isSelected ? 'Collapse section' : 'Expand section'}
45
- onclick={() => {
46
- option.onclick();
47
- }}
48
- >
49
- {#if typeof option.label == 'string'}
50
- <span class="label">{option.label}</span>
51
- {:else}
52
- {@render option.label()}
53
- {/if}
54
- <div class="spacer"></div>
55
-
56
- {#if !isValid.value}
57
- <Icon
58
- name="error"
59
- colour={Colour['$error-border']}
60
- size={Size.Small}
61
- />
62
- {/if}
63
- <Icon
64
- name={isSelected ? 'circle-minus' : 'circle-plus'}
65
- colour={Colour['$primary-blue-13']}
66
- size={Size.Medium}
67
- />
68
- </button>
69
- {#if option.extras}
70
- <div class="extras">
71
- {@render option.extras()}
72
- </div>
73
- {/if}
74
- </div>
75
-
1
+ <svelte:options runes />
2
+
3
+ <script
4
+ lang="ts"
5
+ generics="Args"
6
+ >
7
+ import { useAsyncFlag } from '../Helpers/AsyncFlag.svelte.js';
8
+ import { Colour } from '../scss/colours.js';
9
+ import { Size } from '../Types/Internal/Size.js';
10
+ import type { AccordionGroupButtonProps } from './AccordionGroupButtonProps.js';
11
+ import Icon from './Icon.svelte';
12
+
13
+ const {
14
+ option,
15
+ selected: isSelected,
16
+ noRadius = false,
17
+ }: AccordionGroupButtonProps<Args> = $props();
18
+
19
+ const isValid = useAsyncFlag(() => option.isValid, true);
20
+ const disabled = useAsyncFlag(() => option.disabled, false);
21
+ const isVisible = useAsyncFlag(() => option.visible, true);
22
+ </script>
23
+
24
+ <!--
25
+ Single-button row: the whole header is one interactive element, with the
26
+ expand chevron rendered as decorative content of that same button. This
27
+ resolves the previous a11y issue (a nested toggle inside the row read as
28
+ two interactive elements). The `extras` snippet is intentionally placed
29
+ OUTSIDE the button so that consumers passing interactive content into
30
+ `extras` don't create nested-button markup.
31
+ -->
32
+ <div
33
+ class="tab-wrapper"
34
+ class:isSelected
35
+ class:invalid={!isValid.value}
36
+ class:hidden={!isVisible.value}
37
+ class:no-radius={noRadius}
38
+ >
39
+ <button
40
+ type="button"
41
+ class="tab"
42
+ disabled={disabled.value}
43
+ aria-expanded={isSelected}
44
+ aria-label={isSelected ? 'Collapse section' : 'Expand section'}
45
+ onclick={() => {
46
+ option.onclick();
47
+ }}
48
+ >
49
+ {#if typeof option.label == 'string'}
50
+ <span class="label">{option.label}</span>
51
+ {:else}
52
+ {@render option.label()}
53
+ {/if}
54
+ <div class="spacer"></div>
55
+
56
+ {#if !isValid.value}
57
+ <Icon
58
+ name="error"
59
+ colour={Colour['$error-border']}
60
+ size={Size.Small}
61
+ />
62
+ {/if}
63
+ <Icon
64
+ name={isSelected ? 'circle-minus' : 'circle-plus'}
65
+ colour={Colour['$primary-blue-13']}
66
+ size={Size.Medium}
67
+ />
68
+ </button>
69
+ {#if option.extras}
70
+ <div class="extras">
71
+ {@render option.extras()}
72
+ </div>
73
+ {/if}
74
+ </div>
75
+
76
76
  <style>.tab-wrapper {
77
77
  position: relative;
78
78
  background-color: #f4f7f9;
@@ -119,4 +119,4 @@
119
119
  align-items: center;
120
120
  gap: 1.5rem;
121
121
  pointer-events: auto;
122
- }</style>
122
+ }</style>
@@ -1,138 +1,138 @@
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 { Shape } from '../Types/Internal/Shape.js';
10
- import { Side } from '../Types/Internal/Side.js';
11
- import { Size } from '../Types/Internal/Size.js';
12
- import { ColourSet } from '../scss/colours.js';
13
- import type { ActionProps } from './ActionProps.js';
14
- import Icon from './Icon.svelte';
15
-
16
- const paddings: Record<Shape, Record<Size, number>> = {
17
- [Shape.Rectangle]: {
18
- [Size.Tiny]: 0.125,
19
- [Size.Small]: 0.1875,
20
- [Size.MediumSmall]: 0.3125,
21
- [Size.Medium]: 0.375,
22
- [Size.MediumLarge]: 0.5,
23
- [Size.Large]: 0.625,
24
- [Size.XLarge]: 0.6875,
25
- [Size.DoubleXLarge]: 0.8125,
26
- [Size.TripleXLarge]: 0.875,
27
- [Size.FillWidth]: -1,
28
- [Size.FillHeight]: -1,
29
- },
30
- [Shape.Circle]: {
31
- [Size.Tiny]: 0.1875,
32
- [Size.Small]: 0.5,
33
- [Size.MediumSmall]: 0.875,
34
- [Size.Medium]: 1.0625,
35
- [Size.MediumLarge]: 1.375,
36
- [Size.Large]: 1.75,
37
- [Size.XLarge]: 1.9375,
38
- [Size.DoubleXLarge]: 2.25,
39
- [Size.TripleXLarge]: 2.4375,
40
- [Size.FillWidth]: -1,
41
- [Size.FillHeight]: -1,
42
- },
43
- };
44
- </script>
45
-
46
- <script lang="ts">
47
- const {
48
- icon,
49
- id,
50
- border = false,
51
- shape = Shape.Rectangle,
52
- label,
53
- colourSet = ColourSet.Secondary,
54
- size = Size.Medium,
55
- paddingSize,
56
- type = 'button',
57
- noTabIndex = false,
58
- disabled,
59
- backgroundColour,
60
- hoverBackgroundColour,
61
- 'data-type': dataType,
62
- onfocus,
63
- onblur,
64
- onclick,
65
- onkeydown: onkeydownProp,
66
- style = '',
67
- side,
68
- 'aria-expanded': ariaExpanded,
69
- 'aria-controls': ariaControls,
70
- }: ActionProps = $props();
71
-
72
- const iconSize: Size = $derived(icon.size ?? size);
73
-
74
- const pad: string = $derived.by(() => {
75
- const padSize = paddingSize ?? size;
76
- return padSize === Size.FillWidth ? '' : `${paddings[shape][padSize]}rem`;
77
- });
78
-
79
- function onkeydown(e: KeyboardEvent) {
80
- passthrough(e);
81
-
82
- if (document.activeElement === e.target) {
83
- onkeydownProp?.(e);
84
- }
85
- }
86
-
87
- // Shared tooltip lifecycle: hover handlers plus unmount-time teardown.
88
- // Action lives inside short-lived hosts (table rows, modal panels,
89
- // accordion content) so the cleanup is load-bearing - without it,
90
- // churn leaves the global tooltip painting against a node that no
91
- // longer exists.
92
- const tt = useTooltip({
93
- text: () => label,
94
- arrow: () => side ?? Side.Left,
95
- });
96
- </script>
97
-
98
- <button
99
- {id}
100
- onmouseenter={tt.onmouseenter}
101
- onmouseleave={tt.onmouseleave}
102
- tabindex={noTabIndex ? -1 : undefined}
103
- data-type={dataType}
104
- style="{pad ? `--pad: ${pad};` : ''} {backgroundColour
105
- ? `--background-colour: ${backgroundColour};`
106
- : ``} {hoverBackgroundColour
107
- ? `--hover-background-colour: ${hoverBackgroundColour};`
108
- : ``}{style}"
109
- class:border
110
- class:circular={shape === Shape.Circle}
111
- class:primary={colourSet === ColourSet.Primary}
112
- class:secondary={colourSet === ColourSet.Secondary}
113
- class:auxiliary={colourSet === ColourSet.Auxiliary}
114
- class:info={colourSet === ColourSet.Info}
115
- class:error={colourSet === ColourSet.Error}
116
- class:fill-width={size === Size.FillWidth}
117
- class:fill-height={size === Size.FillHeight}
118
- {type}
119
- {disabled}
120
- {onfocus}
121
- {onblur}
122
- {onkeydown}
123
- onclick={(e) => {
124
- tt.onclick();
125
- onclick?.(e);
126
- }}
127
- aria-label={label}
128
- aria-expanded={ariaExpanded}
129
- aria-controls={ariaControls}
130
- ><Icon
131
- {...icon}
132
- size={iconSize}
133
- /></button
134
- >
135
-
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 { Shape } from '../Types/Internal/Shape.js';
10
+ import { Side } from '../Types/Internal/Side.js';
11
+ import { Size } from '../Types/Internal/Size.js';
12
+ import { ColourSet } from '../scss/colours.js';
13
+ import type { ActionProps } from './ActionProps.js';
14
+ import Icon from './Icon.svelte';
15
+
16
+ const paddings: Record<Shape, Record<Size, number>> = {
17
+ [Shape.Rectangle]: {
18
+ [Size.Tiny]: 0.125,
19
+ [Size.Small]: 0.1875,
20
+ [Size.MediumSmall]: 0.3125,
21
+ [Size.Medium]: 0.375,
22
+ [Size.MediumLarge]: 0.5,
23
+ [Size.Large]: 0.625,
24
+ [Size.XLarge]: 0.6875,
25
+ [Size.DoubleXLarge]: 0.8125,
26
+ [Size.TripleXLarge]: 0.875,
27
+ [Size.FillWidth]: -1,
28
+ [Size.FillHeight]: -1,
29
+ },
30
+ [Shape.Circle]: {
31
+ [Size.Tiny]: 0.1875,
32
+ [Size.Small]: 0.5,
33
+ [Size.MediumSmall]: 0.875,
34
+ [Size.Medium]: 1.0625,
35
+ [Size.MediumLarge]: 1.375,
36
+ [Size.Large]: 1.75,
37
+ [Size.XLarge]: 1.9375,
38
+ [Size.DoubleXLarge]: 2.25,
39
+ [Size.TripleXLarge]: 2.4375,
40
+ [Size.FillWidth]: -1,
41
+ [Size.FillHeight]: -1,
42
+ },
43
+ };
44
+ </script>
45
+
46
+ <script lang="ts">
47
+ const {
48
+ icon,
49
+ id,
50
+ border = false,
51
+ shape = Shape.Rectangle,
52
+ label,
53
+ colourSet = ColourSet.Secondary,
54
+ size = Size.Medium,
55
+ paddingSize,
56
+ type = 'button',
57
+ noTabIndex = false,
58
+ disabled,
59
+ backgroundColour,
60
+ hoverBackgroundColour,
61
+ 'data-type': dataType,
62
+ onfocus,
63
+ onblur,
64
+ onclick,
65
+ onkeydown: onkeydownProp,
66
+ style = '',
67
+ side,
68
+ 'aria-expanded': ariaExpanded,
69
+ 'aria-controls': ariaControls,
70
+ }: ActionProps = $props();
71
+
72
+ const iconSize: Size = $derived(icon.size ?? size);
73
+
74
+ const pad: string = $derived.by(() => {
75
+ const padSize = paddingSize ?? size;
76
+ return padSize === Size.FillWidth ? '' : `${paddings[shape][padSize]}rem`;
77
+ });
78
+
79
+ function onkeydown(e: KeyboardEvent) {
80
+ passthrough(e);
81
+
82
+ if (document.activeElement === e.target) {
83
+ onkeydownProp?.(e);
84
+ }
85
+ }
86
+
87
+ // Shared tooltip lifecycle: hover handlers plus unmount-time teardown.
88
+ // Action lives inside short-lived hosts (table rows, modal panels,
89
+ // accordion content) so the cleanup is load-bearing - without it,
90
+ // churn leaves the global tooltip painting against a node that no
91
+ // longer exists.
92
+ const tt = useTooltip({
93
+ text: () => label,
94
+ arrow: () => side ?? Side.Left,
95
+ });
96
+ </script>
97
+
98
+ <button
99
+ {id}
100
+ onmouseenter={tt.onmouseenter}
101
+ onmouseleave={tt.onmouseleave}
102
+ tabindex={noTabIndex ? -1 : undefined}
103
+ data-type={dataType}
104
+ style="{pad ? `--pad: ${pad};` : ''} {backgroundColour
105
+ ? `--background-colour: ${backgroundColour};`
106
+ : ``} {hoverBackgroundColour
107
+ ? `--hover-background-colour: ${hoverBackgroundColour};`
108
+ : ``}{style}"
109
+ class:border
110
+ class:circular={shape === Shape.Circle}
111
+ class:primary={colourSet === ColourSet.Primary}
112
+ class:secondary={colourSet === ColourSet.Secondary}
113
+ class:auxiliary={colourSet === ColourSet.Auxiliary}
114
+ class:info={colourSet === ColourSet.Info}
115
+ class:error={colourSet === ColourSet.Error}
116
+ class:fill-width={size === Size.FillWidth}
117
+ class:fill-height={size === Size.FillHeight}
118
+ {type}
119
+ {disabled}
120
+ {onfocus}
121
+ {onblur}
122
+ {onkeydown}
123
+ onclick={(e) => {
124
+ tt.onclick();
125
+ onclick?.(e);
126
+ }}
127
+ aria-label={label}
128
+ aria-expanded={ariaExpanded}
129
+ aria-controls={ariaControls}
130
+ ><Icon
131
+ {...icon}
132
+ size={iconSize}
133
+ /></button
134
+ >
135
+
136
136
  <style>button {
137
137
  color: #3a4952;
138
138
  fill: #3a4952;
@@ -228,4 +228,4 @@ button.circular {
228
228
  button {
229
229
  padding: var(--pad);
230
230
  cursor: pointer;
231
- }</style>
231
+ }</style>