@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.
Files changed (143) hide show
  1. package/README.md +58 -58
  2. package/dist/Components/AccordionGroup.svelte +35 -46
  3. package/dist/Components/AccordionGroupButton.svelte +68 -76
  4. package/dist/Components/Action.svelte +103 -135
  5. package/dist/Components/AlertModal.svelte +171 -190
  6. package/dist/Components/AppointmentCalendar/AppointmentCalendar.svelte +614 -697
  7. package/dist/Components/Base/BaseModal.svelte +90 -116
  8. package/dist/Components/Base/ContextWrapper.svelte +67 -72
  9. package/dist/Components/Base/Pagination.svelte +173 -196
  10. package/dist/Components/Base/Snippets.svelte +34 -36
  11. package/dist/Components/BigRadioSet.svelte +36 -38
  12. package/dist/Components/Bubble.svelte +78 -101
  13. package/dist/Components/Button.svelte +175 -208
  14. package/dist/Components/Checkbox.svelte +75 -86
  15. package/dist/Components/CollapsibleCard.svelte +72 -87
  16. package/dist/Components/CollapsibleMenuGroup.svelte +53 -57
  17. package/dist/Components/ConditionBuilder/ConditionBuilder.svelte +39 -64
  18. package/dist/Components/Contexts/ContextMenu.svelte +141 -156
  19. package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
  20. package/dist/Components/Contexts/ContextMenuOption.svelte +53 -60
  21. package/dist/Components/Contexts/Toast.svelte +81 -86
  22. package/dist/Components/Contexts/ToastContainer.svelte +58 -62
  23. package/dist/Components/Contexts/Tooltip.svelte +36 -37
  24. package/dist/Components/DataMatrixIcon.svelte +95 -108
  25. package/dist/Components/DateInput.svelte +118 -146
  26. package/dist/Components/DatePicker.svelte +255 -294
  27. package/dist/Components/DesktopModal.svelte +70 -90
  28. package/dist/Components/Dial.svelte +167 -197
  29. package/dist/Components/DimensionInput.svelte +124 -169
  30. package/dist/Components/DragMenu/DragMenuHolder.svelte +98 -114
  31. package/dist/Components/DragMenu/DraggableCard.svelte +64 -76
  32. package/dist/Components/FileCard.svelte +21 -24
  33. package/dist/Components/FileUpload.svelte +190 -225
  34. package/dist/Components/GridInput.svelte +159 -196
  35. package/dist/Components/GridInputSet.svelte +24 -29
  36. package/dist/Components/HorizontalTabGroup.svelte +73 -89
  37. package/dist/Components/HorizontalTabGroupButton.svelte +40 -44
  38. package/dist/Components/Icon.svelte +99 -128
  39. package/dist/Components/Icons.js +357 -357
  40. package/dist/Components/InfoAlert.svelte +35 -38
  41. package/dist/Components/LoadingAnimation.svelte +691 -755
  42. package/dist/Components/LoadingModal.svelte +36 -44
  43. package/dist/Components/LoadingOverlay.svelte +22 -26
  44. package/dist/Components/Modal.svelte +204 -254
  45. package/dist/Components/MultiSelect.svelte +186 -216
  46. package/dist/Components/Nav/Nav.svelte +94 -110
  47. package/dist/Components/Nav/NavServiceMenuList.svelte +57 -61
  48. package/dist/Components/Nav/NavTab.svelte +58 -62
  49. package/dist/Components/Nav/ServiceMenuItem.svelte +103 -111
  50. package/dist/Components/Nav/ServicesNav.svelte +72 -79
  51. package/dist/Components/NumberInput.svelte +121 -155
  52. package/dist/Components/OptionCards.svelte +62 -73
  53. package/dist/Components/PageHeading.svelte +23 -25
  54. package/dist/Components/PasswordInput.svelte +69 -88
  55. package/dist/Components/PopoverButton.svelte +151 -0
  56. package/dist/Components/PopoverButton.svelte.d.ts +9 -0
  57. package/dist/Components/PopoverButtonProps.d.ts +21 -0
  58. package/dist/Components/PopoverButtonProps.js +1 -0
  59. package/dist/Components/Portal.svelte +29 -35
  60. package/dist/Components/ProgressBubble.svelte +91 -106
  61. package/dist/Components/QuerySelect.svelte +260 -346
  62. package/dist/Components/SidebarPanel.svelte +34 -36
  63. package/dist/Components/SingleSelect.svelte +196 -244
  64. package/dist/Components/StepButton.svelte +65 -70
  65. package/dist/Components/StepForm.svelte +115 -135
  66. package/dist/Components/Switch.svelte +57 -69
  67. package/dist/Components/Table/ARCHITECTURE.md +298 -298
  68. package/dist/Components/Table/Body/QuickSearchCell.svelte +578 -655
  69. package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +42 -51
  70. package/dist/Components/Table/Body/Rows/ColumnList.svelte +42 -58
  71. package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +403 -442
  72. package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +51 -78
  73. package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +165 -184
  74. package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +110 -123
  75. package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +134 -160
  76. package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +190 -231
  77. package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +82 -104
  78. package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +52 -87
  79. package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +122 -150
  80. package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +132 -159
  81. package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +190 -236
  82. package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +173 -211
  83. package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +204 -244
  84. package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +140 -177
  85. package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +188 -217
  86. package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +173 -193
  87. package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +166 -187
  88. package/dist/Components/Table/Body/Rows/TableRow.svelte +245 -288
  89. package/dist/Components/Table/Body/TableBody.svelte +141 -154
  90. package/dist/Components/Table/Headers/HighlightAllHeader.svelte +35 -41
  91. package/dist/Components/Table/Headers/SelectAllHeader.svelte +24 -30
  92. package/dist/Components/Table/Headers/TableHead.svelte +348 -402
  93. package/dist/Components/Table/Misc/ColumnPanel.svelte +37 -39
  94. package/dist/Components/Table/Misc/ColumnPanelModal.svelte +35 -39
  95. package/dist/Components/Table/Misc/FilterInput.svelte +556 -619
  96. package/dist/Components/Table/Misc/FilterPanel.svelte +170 -183
  97. package/dist/Components/Table/Misc/FilterPanelModal.svelte +25 -31
  98. package/dist/Components/Table/Misc/ShareViewModal.svelte +252 -281
  99. package/dist/Components/Table/Misc/SidePanel.svelte +32 -35
  100. package/dist/Components/Table/Misc/TableConfigurationModal.svelte +574 -629
  101. package/dist/Components/Table/Misc/TableFooter.svelte +326 -332
  102. package/dist/Components/Table/Misc/TableHorizontalBar.svelte +134 -140
  103. package/dist/Components/Table/Misc/TableSidebar.svelte +183 -198
  104. package/dist/Components/Table/Misc/TableViewDropdown.svelte +83 -103
  105. package/dist/Components/Table/Misc/ToolboxPanel.svelte +83 -100
  106. package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +88 -107
  107. package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte +163 -190
  108. package/dist/Components/Table/NestedTable.svelte +102 -128
  109. package/dist/Components/Table/Table.svelte +531 -663
  110. package/dist/Components/Test/TestContextConsumer.svelte +11 -13
  111. package/dist/Components/TextArea.svelte +95 -130
  112. package/dist/Components/TextInput.svelte +125 -176
  113. package/dist/Components/ThreeStateRadio.svelte +111 -130
  114. package/dist/Components/Touch/BoolCard.svelte +33 -45
  115. package/dist/Components/Touch/DateModal.svelte +164 -204
  116. package/dist/Components/Touch/EditCard.svelte +48 -59
  117. package/dist/Components/Touch/InfoCard.svelte +28 -31
  118. package/dist/Components/Touch/InfoTextCard.svelte +26 -28
  119. package/dist/Components/Touch/ModalExplanation.svelte +15 -17
  120. package/dist/Components/Touch/NumberKeyboard.svelte +181 -218
  121. package/dist/Components/Touch/NumberModal.svelte +59 -79
  122. package/dist/Components/Touch/PlusMinusCard.svelte +43 -46
  123. package/dist/Components/Touch/SelectModal.svelte +111 -126
  124. package/dist/Components/Touch/SummaryCard.svelte +80 -93
  125. package/dist/Components/Touch/TextAreaModal.svelte +72 -94
  126. package/dist/Components/Touch/TextModal.svelte +77 -105
  127. package/dist/Components/Touch/TouchCard.svelte +31 -33
  128. package/dist/Components/Touch/TouchModal.svelte +214 -270
  129. package/dist/Components/Touch/UtilityButton.svelte +88 -109
  130. package/dist/Components/VerticalTabGroup.svelte +60 -78
  131. package/dist/Components/VerticalTabGroupButton.svelte +54 -58
  132. package/dist/Helpers/Datamatrix.d.ts +19 -19
  133. package/dist/Helpers/Datamatrix.js +291 -291
  134. package/dist/Types/Examples/ExampleModal.svelte +31 -35
  135. package/dist/index.d.ts +2 -0
  136. package/dist/index.js +1 -0
  137. package/dist/scss/_basics.scss +12 -12
  138. package/dist/scss/_colours.scss +134 -134
  139. package/dist/scss/_mixins.scss +3392 -3392
  140. package/dist/scss/_motion.scss +57 -57
  141. package/dist/scss/_sizing.scss +85 -85
  142. package/dist/scss/_transitions.scss +8 -8
  143. 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,37 @@
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
+ >import AccordionGroupButton from "./AccordionGroupButton.svelte";
7
+ import { cubicOut } from "svelte/easing";
8
+ import { slide } from "svelte/transition";
9
+ import { usePrefersReducedMotion } from "../Helpers/prefersReducedMotion.svelte.js";
10
+ let { tabs, selected, noRadius = false, grow = false } = $props();
11
+ const reducedMotion = usePrefersReducedMotion();
12
+ const slideDuration = $derived(reducedMotion.matches ? 0 : 200);
13
+ </script>
14
+
15
+ <div
16
+ class="wrapper"
17
+ class:no-radius={noRadius}
18
+ class:grow
19
+ >
20
+ {#each tabs as option (option.label)}
21
+ {@const isSelected = selected === option}
22
+ <AccordionGroupButton
23
+ {option}
24
+ {noRadius}
25
+ selected={isSelected}
26
+ />
27
+ {#if isSelected}
28
+ <div transition:slide={{ duration: slideDuration, easing: cubicOut }}>
29
+ {@render selected.content(selected.args)}
30
+ </div>
31
+ {/if}
32
+ {/each}
33
+ </div>
34
+
46
35
  <style>.wrapper {
47
36
  box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.1333333333);
48
37
  border-radius: 4px;
@@ -86,4 +75,4 @@
86
75
  flex-grow: 1;
87
76
  overflow: visible;
88
77
  border-radius: 0 4px 0 4px;
89
- }</style>
78
+ }</style>
@@ -1,78 +1,70 @@
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
+ >import { useAsyncFlag } from "../Helpers/AsyncFlag.svelte.js";
7
+ import { Colour } from "../scss/colours.js";
8
+ import { Size } from "../Types/Internal/Size.js";
9
+ import Icon from "./Icon.svelte";
10
+ const { option, selected: isSelected, noRadius = false } = $props();
11
+ const isValid = useAsyncFlag(() => option.isValid, true);
12
+ const disabled = useAsyncFlag(() => option.disabled, false);
13
+ const isVisible = useAsyncFlag(() => option.visible, true);
14
+ </script>
15
+
16
+ <!--
17
+ Single-button row: the whole header is one interactive element, with the
18
+ expand chevron rendered as decorative content of that same button. This
19
+ resolves the previous a11y issue (a nested toggle inside the row read as
20
+ two interactive elements). The `extras` snippet is intentionally placed
21
+ OUTSIDE the button so that consumers passing interactive content into
22
+ `extras` don't create nested-button markup.
23
+ -->
24
+ <div
25
+ class="tab-wrapper"
26
+ class:isSelected
27
+ class:invalid={!isValid.value}
28
+ class:hidden={!isVisible.value}
29
+ class:no-radius={noRadius}
30
+ >
31
+ <button
32
+ type="button"
33
+ class="tab"
34
+ disabled={disabled.value}
35
+ aria-expanded={isSelected}
36
+ aria-label={isSelected ? 'Collapse section' : 'Expand section'}
37
+ onclick={() => {
38
+ option.onclick();
39
+ }}
40
+ >
41
+ {#if typeof option.label == 'string'}
42
+ <span class="label">{option.label}</span>
43
+ {:else}
44
+ {@render option.label()}
45
+ {/if}
46
+ <div class="spacer"></div>
47
+
48
+ {#if !isValid.value}
49
+ <Icon
50
+ name="error"
51
+ colour={Colour['$error-border']}
52
+ size={Size.Small}
53
+ />
54
+ {/if}
55
+ <Icon
56
+ name={isSelected ? 'circle-minus' : 'circle-plus'}
57
+ colour={Colour['$primary-blue-13']}
58
+ size={Size.Medium}
59
+ />
60
+ </button>
61
+ {#if option.extras}
62
+ <div class="extras">
63
+ {@render option.extras()}
64
+ </div>
65
+ {/if}
66
+ </div>
67
+
76
68
  <style>.tab-wrapper {
77
69
  position: relative;
78
70
  background-color: #f4f7f9;
@@ -119,4 +111,4 @@
119
111
  align-items: center;
120
112
  gap: 1.5rem;
121
113
  pointer-events: auto;
122
- }</style>
114
+ }</style>
@@ -1,138 +1,106 @@
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
- }
1
+ <svelte:options runes />
2
+
3
+ <script
4
+ module
5
+ lang="ts"
6
+ >import { passthrough } from "../Helpers/Helpers.svelte.js";
7
+ import { useTooltip } from "../Helpers/useTooltip.svelte.js";
8
+ import { Shape } from "../Types/Internal/Shape.js";
9
+ import { Side } from "../Types/Internal/Side.js";
10
+ import { Size } from "../Types/Internal/Size.js";
11
+ import { ColourSet } from "../scss/colours.js";
12
+ import Icon from "./Icon.svelte";
13
+ const paddings = {
14
+ [Shape.Rectangle]: {
15
+ [Size.Tiny]: .125,
16
+ [Size.Small]: .1875,
17
+ [Size.MediumSmall]: .3125,
18
+ [Size.Medium]: .375,
19
+ [Size.MediumLarge]: .5,
20
+ [Size.Large]: .625,
21
+ [Size.XLarge]: .6875,
22
+ [Size.DoubleXLarge]: .8125,
23
+ [Size.TripleXLarge]: .875,
24
+ [Size.FillWidth]: -1,
25
+ [Size.FillHeight]: -1
26
+ },
27
+ [Shape.Circle]: {
28
+ [Size.Tiny]: .1875,
29
+ [Size.Small]: .5,
30
+ [Size.MediumSmall]: .875,
31
+ [Size.Medium]: 1.0625,
32
+ [Size.MediumLarge]: 1.375,
33
+ [Size.Large]: 1.75,
34
+ [Size.XLarge]: 1.9375,
35
+ [Size.DoubleXLarge]: 2.25,
36
+ [Size.TripleXLarge]: 2.4375,
37
+ [Size.FillWidth]: -1,
38
+ [Size.FillHeight]: -1
85
39
  }
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
-
40
+ };
41
+ </script>
42
+
43
+ <script lang="ts">const { icon, id, border = false, shape = Shape.Rectangle, label, colourSet = ColourSet.Secondary, size = Size.Medium, paddingSize, type = "button", noTabIndex = false, disabled, backgroundColour, hoverBackgroundColour, "data-type": dataType, onfocus, onblur, onclick, onkeydown: onkeydownProp, style = "", side, "aria-expanded": ariaExpanded, "aria-controls": ariaControls } = $props();
44
+ const iconSize = $derived(icon.size ?? size);
45
+ const pad = $derived.by(() => {
46
+ const padSize = paddingSize ?? size;
47
+ return padSize === Size.FillWidth ? "" : `${paddings[shape][padSize]}rem`;
48
+ });
49
+ function onkeydown(e) {
50
+ passthrough(e);
51
+ if (document.activeElement === e.target) {
52
+ onkeydownProp?.(e);
53
+ }
54
+ }
55
+ // Shared tooltip lifecycle: hover handlers plus unmount-time teardown.
56
+ // Action lives inside short-lived hosts (table rows, modal panels,
57
+ // accordion content) so the cleanup is load-bearing - without it,
58
+ // churn leaves the global tooltip painting against a node that no
59
+ // longer exists.
60
+ const tt = useTooltip({
61
+ text: () => label,
62
+ arrow: () => side ?? Side.Left
63
+ });
64
+ </script>
65
+
66
+ <button
67
+ {id}
68
+ onmouseenter={tt.onmouseenter}
69
+ onmouseleave={tt.onmouseleave}
70
+ tabindex={noTabIndex ? -1 : undefined}
71
+ data-type={dataType}
72
+ style="{pad ? `--pad: ${pad};` : ''} {backgroundColour
73
+ ? `--background-colour: ${backgroundColour};`
74
+ : ``} {hoverBackgroundColour
75
+ ? `--hover-background-colour: ${hoverBackgroundColour};`
76
+ : ``}{style}"
77
+ class:border
78
+ class:circular={shape === Shape.Circle}
79
+ class:primary={colourSet === ColourSet.Primary}
80
+ class:secondary={colourSet === ColourSet.Secondary}
81
+ class:auxiliary={colourSet === ColourSet.Auxiliary}
82
+ class:info={colourSet === ColourSet.Info}
83
+ class:error={colourSet === ColourSet.Error}
84
+ class:fill-width={size === Size.FillWidth}
85
+ class:fill-height={size === Size.FillHeight}
86
+ {type}
87
+ {disabled}
88
+ {onfocus}
89
+ {onblur}
90
+ {onkeydown}
91
+ onclick={(e) => {
92
+ tt.onclick();
93
+ onclick?.(e);
94
+ }}
95
+ aria-label={label}
96
+ aria-expanded={ariaExpanded}
97
+ aria-controls={ariaControls}
98
+ ><Icon
99
+ {...icon}
100
+ size={iconSize}
101
+ /></button
102
+ >
103
+
136
104
  <style>button {
137
105
  color: #3a4952;
138
106
  fill: #3a4952;
@@ -228,4 +196,4 @@ button.circular {
228
196
  button {
229
197
  padding: var(--pad);
230
198
  cursor: pointer;
231
- }</style>
199
+ }</style>