@onsvisual/svelte-components 0.1.91-component.toolbar → 0.1.91

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 (31) hide show
  1. package/dist/@types/index.d.ts +0 -10
  2. package/dist/@types/inputs/AccessibleSelect/AccessibleSelect.svelte.d.ts +53 -0
  3. package/dist/@types/inputs/AccessibleSelect/options.d.ts +6 -0
  4. package/dist/@types/inputs/Button/Button.svelte.d.ts +2 -0
  5. package/dist/css/main.css +1 -1
  6. package/dist/index.js +0 -10
  7. package/dist/inputs/AccessibleSelect/AccessibleSelect.svelte +266 -0
  8. package/dist/inputs/AccessibleSelect/options.js +263 -0
  9. package/dist/inputs/Button/Button.svelte +6 -0
  10. package/package.json +5 -16
  11. package/dist/@types/inputs/ButtonGroup/ButtonGroup.svelte.d.ts +0 -33
  12. package/dist/@types/inputs/ButtonGroup/ButtonGroupItem.svelte.d.ts +0 -25
  13. package/dist/@types/inputs/Toolbar/HelpModal.svelte.d.ts +0 -19
  14. package/dist/@types/inputs/Toolbar/Icon.svelte.d.ts +0 -31
  15. package/dist/@types/inputs/Toolbar/ToolControl.svelte.d.ts +0 -27
  16. package/dist/@types/inputs/Toolbar/ToolControls.svelte.d.ts +0 -27
  17. package/dist/@types/inputs/Toolbar/Toolbar.svelte.d.ts +0 -33
  18. package/dist/@types/inputs/Toolbar/ToolbarButton.svelte.d.ts +0 -31
  19. package/dist/@types/inputs/Toolbar/ToolbarDivider.svelte.d.ts +0 -16
  20. package/dist/@types/inputs/Toolbar/ToolbarsContainer.svelte.d.ts +0 -16
  21. package/dist/inputs/ButtonGroup/ButtonGroup.svelte +0 -55
  22. package/dist/inputs/ButtonGroup/ButtonGroupItem.svelte +0 -103
  23. package/dist/inputs/Toolbar/HelpModal.svelte +0 -220
  24. package/dist/inputs/Toolbar/Icon.svelte +0 -136
  25. package/dist/inputs/Toolbar/ToolControl.svelte +0 -19
  26. package/dist/inputs/Toolbar/ToolControls.svelte +0 -8
  27. package/dist/inputs/Toolbar/Toolbar.svelte +0 -68
  28. package/dist/inputs/Toolbar/ToolbarButton.svelte +0 -161
  29. package/dist/inputs/Toolbar/ToolbarDivider.svelte +0 -27
  30. package/dist/inputs/Toolbar/ToolbarsContainer.svelte +0 -52
  31. /package/dist/layout/{BackLink → Backlink}/Backlink.svelte +0 -0
@@ -1,25 +0,0 @@
1
- /** @typedef {typeof __propDef.props} ButtonGroupItemProps */
2
- /** @typedef {typeof __propDef.events} ButtonGroupItemEvents */
3
- /** @typedef {typeof __propDef.slots} ButtonGroupItemSlots */
4
- export default class ButtonGroupItem extends SvelteComponentTyped<{
5
- label?: string;
6
- value?: string;
7
- }, {
8
- [evt: string]: CustomEvent<any>;
9
- }, {}> {
10
- }
11
- export type ButtonGroupItemProps = typeof __propDef.props;
12
- export type ButtonGroupItemEvents = typeof __propDef.events;
13
- export type ButtonGroupItemSlots = typeof __propDef.slots;
14
- import { SvelteComponentTyped } from "svelte";
15
- declare const __propDef: {
16
- props: {
17
- label?: string;
18
- value?: string;
19
- };
20
- events: {
21
- [evt: string]: CustomEvent<any>;
22
- };
23
- slots: {};
24
- };
25
- export {};
@@ -1,19 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- triggerElement?: HTMLElement | null;
5
- onClose: () => void;
6
- };
7
- events: {
8
- [evt: string]: CustomEvent<any>;
9
- };
10
- slots: {
11
- default: {};
12
- };
13
- };
14
- export type HelpModalProps = typeof __propDef.props;
15
- export type HelpModalEvents = typeof __propDef.events;
16
- export type HelpModalSlots = typeof __propDef.slots;
17
- export default class HelpModal extends SvelteComponentTyped<HelpModalProps, HelpModalEvents, HelpModalSlots> {
18
- }
19
- export {};
@@ -1,31 +0,0 @@
1
- /** @typedef {typeof __propDef.props} IconProps */
2
- /** @typedef {typeof __propDef.events} IconEvents */
3
- /** @typedef {typeof __propDef.slots} IconSlots */
4
- export default class Icon extends SvelteComponentTyped<{
5
- selected?: boolean;
6
- type?: string;
7
- marginLeft?: boolean;
8
- marginRight?: boolean;
9
- disabled?: boolean;
10
- }, {
11
- [evt: string]: CustomEvent<any>;
12
- }, {}> {
13
- }
14
- export type IconProps = typeof __propDef.props;
15
- export type IconEvents = typeof __propDef.events;
16
- export type IconSlots = typeof __propDef.slots;
17
- import { SvelteComponentTyped } from "svelte";
18
- declare const __propDef: {
19
- props: {
20
- selected?: boolean;
21
- type?: string;
22
- marginLeft?: boolean;
23
- marginRight?: boolean;
24
- disabled?: boolean;
25
- };
26
- events: {
27
- [evt: string]: CustomEvent<any>;
28
- };
29
- slots: {};
30
- };
31
- export {};
@@ -1,27 +0,0 @@
1
- /** @typedef {typeof __propDef.props} ToolControlProps */
2
- /** @typedef {typeof __propDef.events} ToolControlEvents */
3
- /** @typedef {typeof __propDef.slots} ToolControlSlots */
4
- export default class ToolControl extends SvelteComponentTyped<{
5
- id?: string;
6
- }, {
7
- [evt: string]: CustomEvent<any>;
8
- }, {
9
- default: {};
10
- }> {
11
- }
12
- export type ToolControlProps = typeof __propDef.props;
13
- export type ToolControlEvents = typeof __propDef.events;
14
- export type ToolControlSlots = typeof __propDef.slots;
15
- import { SvelteComponentTyped } from "svelte";
16
- declare const __propDef: {
17
- props: {
18
- id?: string;
19
- };
20
- events: {
21
- [evt: string]: CustomEvent<any>;
22
- };
23
- slots: {
24
- default: {};
25
- };
26
- };
27
- export {};
@@ -1,27 +0,0 @@
1
- /** @typedef {typeof __propDef.props} ToolControlsProps */
2
- /** @typedef {typeof __propDef.events} ToolControlsEvents */
3
- /** @typedef {typeof __propDef.slots} ToolControlsSlots */
4
- export default class ToolControls extends SvelteComponentTyped<{
5
- [x: string]: never;
6
- }, {
7
- [evt: string]: CustomEvent<any>;
8
- }, {
9
- default: {};
10
- }> {
11
- }
12
- export type ToolControlsProps = typeof __propDef.props;
13
- export type ToolControlsEvents = typeof __propDef.events;
14
- export type ToolControlsSlots = typeof __propDef.slots;
15
- import { SvelteComponentTyped } from "svelte";
16
- declare const __propDef: {
17
- props: {
18
- [x: string]: never;
19
- };
20
- events: {
21
- [evt: string]: CustomEvent<any>;
22
- };
23
- slots: {
24
- default: {};
25
- };
26
- };
27
- export {};
@@ -1,33 +0,0 @@
1
- /** @typedef {typeof __propDef.props} ToolbarProps */
2
- /** @typedef {typeof __propDef.events} ToolbarEvents */
3
- /** @typedef {typeof __propDef.slots} ToolbarSlots */
4
- export default class Toolbar extends SvelteComponentTyped<{
5
- classes?: string;
6
- ariaLabel?: string;
7
- orientation?: "horizontal" | "vertical";
8
- }, {
9
- [evt: string]: CustomEvent<any>;
10
- }, {
11
- default: {};
12
- controls: {};
13
- }> {
14
- }
15
- export type ToolbarProps = typeof __propDef.props;
16
- export type ToolbarEvents = typeof __propDef.events;
17
- export type ToolbarSlots = typeof __propDef.slots;
18
- import { SvelteComponentTyped } from "svelte";
19
- declare const __propDef: {
20
- props: {
21
- classes?: string;
22
- ariaLabel?: string;
23
- orientation?: 'horizontal' | 'vertical';
24
- };
25
- events: {
26
- [evt: string]: CustomEvent<any>;
27
- };
28
- slots: {
29
- default: {};
30
- controls: {};
31
- };
32
- };
33
- export {};
@@ -1,31 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- id?: string;
5
- icon?: string;
6
- label?: string;
7
- disabled?: boolean;
8
- classes?: string;
9
- helpText?: string | null;
10
- selected?: boolean;
11
- custom?: boolean;
12
- hasAriaControls?: boolean;
13
- sticky?: boolean;
14
- transient?: boolean;
15
- };
16
- events: {
17
- click: CustomEvent<any>;
18
- } & {
19
- [evt: string]: CustomEvent<any>;
20
- };
21
- slots: {
22
- custom: {};
23
- default: {};
24
- };
25
- };
26
- export type ToolbarButtonProps = typeof __propDef.props;
27
- export type ToolbarButtonEvents = typeof __propDef.events;
28
- export type ToolbarButtonSlots = typeof __propDef.slots;
29
- export default class ToolbarButton extends SvelteComponentTyped<ToolbarButtonProps, ToolbarButtonEvents, ToolbarButtonSlots> {
30
- }
31
- export {};
@@ -1,16 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- classes?: string;
5
- };
6
- events: {
7
- [evt: string]: CustomEvent<any>;
8
- };
9
- slots: {};
10
- };
11
- export type ToolbarDividerProps = typeof __propDef.props;
12
- export type ToolbarDividerEvents = typeof __propDef.events;
13
- export type ToolbarDividerSlots = typeof __propDef.slots;
14
- export default class ToolbarDivider extends SvelteComponentTyped<ToolbarDividerProps, ToolbarDividerEvents, ToolbarDividerSlots> {
15
- }
16
- export {};
@@ -1,16 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: Record<string, never>;
4
- events: {
5
- [evt: string]: CustomEvent<any>;
6
- };
7
- slots: {
8
- default: {};
9
- };
10
- };
11
- export type ToolbarsContainerProps = typeof __propDef.props;
12
- export type ToolbarsContainerEvents = typeof __propDef.events;
13
- export type ToolbarsContainerSlots = typeof __propDef.slots;
14
- export default class ToolbarsContainer extends SvelteComponentTyped<ToolbarsContainerProps, ToolbarsContainerEvents, ToolbarsContainerSlots> {
15
- }
16
- export {};
@@ -1,55 +0,0 @@
1
- <script>
2
- import { setContext } from "svelte";
3
- import { writable } from "svelte/store";
4
-
5
- export let name = "";
6
- export let legend = "";
7
- export let value;
8
- export let visuallyHideLegend = false;
9
-
10
- // create the store
11
- const selectedValue = writable(value);
12
-
13
- // Sync the store with the prop on mount and when the prop changes
14
- $: selectedValue.set(value);
15
-
16
- // When store changes and update prop
17
-
18
- $: if ($selectedValue !== value) {
19
- value = $selectedValue;
20
- }
21
-
22
- // Create a context to share with child Button components
23
- setContext("buttonGroup", {
24
- groupName: name,
25
- selectedValue,
26
- });
27
- </script>
28
-
29
- <fieldset class="button-group">
30
- {#if legend}
31
- <legend class:ons-u-vh="{visuallyHideLegend}">{legend}</legend>
32
- {/if}
33
- <div class="buttons">
34
- <slot />
35
- </div>
36
- </fieldset>
37
-
38
- <style>
39
- .button-group {
40
- display: inline-block;
41
- }
42
-
43
- legend {
44
- font-weight: bold;
45
- margin-bottom: 0.5rem;
46
- }
47
-
48
- .buttons {
49
- display: flex;
50
- gap: 8px;
51
- background: #f5f5f6;
52
- padding: 4px;
53
- border-radius: 8px;
54
- justify-content: space-between;
55
- }</style>
@@ -1,103 +0,0 @@
1
- <script>
2
- import { getContext } from "svelte";
3
-
4
- export let value = "";
5
- export let label = "";
6
-
7
- // Get the parent ButtonGroup context
8
- const buttonGroup = getContext("buttonGroup");
9
- const { selectedValue } = buttonGroup;
10
-
11
- // Reactive variable to track selection
12
- let selected = false;
13
-
14
- // Subscribe to selectedValue store
15
- $: selectedValue.subscribe(($selectedValue) => {
16
- selected = $selectedValue === value;
17
- });
18
-
19
- function handleClick() {
20
- selectedValue.set(value); // Update the store
21
- }
22
-
23
- let buttonRef;
24
-
25
- function handleKeydown(event) {
26
- const buttons = Array.from(document.querySelectorAll(`[name="${buttonGroup.groupName}"]`));
27
- const currentIndex = buttons.indexOf(buttonRef);
28
-
29
- let newIndex = -1;
30
-
31
- if (event.key === "ArrowRight" || event.key === "ArrowDown") {
32
- newIndex = (currentIndex + 1) % buttons.length;
33
- } else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
34
- newIndex = (currentIndex - 1 + buttons.length) % buttons.length;
35
- } else if (event.key === "Enter" || event.key === " ") {
36
- handleClick();
37
- return;
38
- }
39
-
40
- if (newIndex !== -1) {
41
- buttons[newIndex].focus();
42
- }
43
- }
44
- </script>
45
-
46
- <div class="button-container">
47
- <input
48
- type="radio"
49
- id="{value}"
50
- name="{buttonGroup.groupName}"
51
- value="{value}"
52
- checked="{selected}"
53
- class="radio-input"
54
- on:click="{handleClick}"
55
- on:keydown="{handleKeydown}"
56
- aria-checked="{selected}"
57
- tabindex="0"
58
- bind:this="{buttonRef}"
59
- />
60
- <label for="{value}" class="button" class:selected="{selected}" on:click="{handleClick}">
61
- {label || value}
62
- </label>
63
- </div>
64
-
65
- <style>
66
- .button-container {
67
- display: flex;
68
- }
69
-
70
- .radio-input {
71
- position: absolute;
72
- opacity: 0;
73
- width: 0;
74
- height: 0;
75
- }
76
-
77
- .button {
78
- flex-grow: 0;
79
- padding: 4px 8px;
80
- border: none;
81
- background: transparent;
82
- font-size: 14px;
83
- cursor: pointer;
84
- border-radius: 6px;
85
- transition: background 0.2s ease, color 0.2s ease;
86
- color: #707071;
87
- text-align: center;
88
- }
89
-
90
- .button:hover {
91
- background-color: #e8e8e8;
92
- }
93
-
94
- .button:focus {
95
- box-shadow: orange 0 0 0 2px;
96
- }
97
-
98
- .button.selected {
99
- background: white;
100
- font-weight: bold;
101
- color: #206095;
102
- box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.2);
103
- }</style>
@@ -1,220 +0,0 @@
1
- <script>import { getContext } from "svelte";
2
- import { get } from "svelte/store";
3
- import { fly } from "svelte/transition";
4
- import Checkbox from "../Checkbox/Checkbox.svelte";
5
- import Button from "../Button/Button.svelte";
6
- export let triggerElement = null;
7
- export let onClose;
8
- // Retrieve the stores from context
9
- const activeModalId = getContext("activeModalId");
10
- // Access button IDs from context
11
- const { buttonIds } = getContext("buttonIds");
12
- const showHelpModals = getContext("showHelpModals");
13
- let modalPosition = { top: 0, left: 0 };
14
- let notchPosition = { left: 0 };
15
- let dontShowMeAgain = false;
16
- $: if (triggerElement) {
17
- const rect = triggerElement.getBoundingClientRect();
18
- // Calculate the modal's position
19
- const spaceBelow = window.innerHeight - rect.bottom;
20
- const spaceAbove = rect.top;
21
- const spaceRight = window.innerWidth - rect.right;
22
- // Default to position below the trigger element
23
- modalPosition = {
24
- // top: rect.bottom + window.scrollY + 10,
25
- top: window.scrollY + 55,
26
- left: window.scrollX - 10,
27
- };
28
- // Align notch with the center of the trigger element
29
- notchPosition = {
30
- left: window.scrollX - modalPosition.left + rect.width / 2 - 10,
31
- right: "auto",
32
- };
33
- // If there's not enough space below, position above
34
- if (spaceBelow < 200 && spaceAbove > 200) {
35
- modalPosition.top = rect.top + window.scrollY - 10;
36
- }
37
- // Adjust if close to the right edge
38
- if (spaceRight < 300) {
39
- modalPosition.left = window.scrollX - 300; // Adjust for modal width
40
- notchPosition = {
41
- left: "auto",
42
- right: -340,
43
- };
44
- }
45
- }
46
- // Update localStorage if "Don't show me again" is checked
47
- function disableHelpModalsPermanently() {
48
- localStorage.setItem("showHelpModals", "false");
49
- sessionStorage.setItem("showHelpModals", "false");
50
- $showHelpModals = false;
51
- }
52
- // Hide modals until refresh
53
- function hideHelpModalsUntilRefresh() {
54
- sessionStorage.setItem("showHelpModals", "false");
55
- $showHelpModals = false;
56
- }
57
- // Navigate to the next modal
58
- function nextModal() {
59
- const ids = get(buttonIds);
60
- const currentIndex = ids.indexOf($activeModalId);
61
- if (currentIndex !== -1 && currentIndex < ids.length - 1) {
62
- activeModalId.set(ids[currentIndex + 1]);
63
- console.log("Navigating to next modal:", ids[currentIndex + 1]);
64
- }
65
- if (dontShowMeAgain) {
66
- disableHelpModalsPermanently(); // Disable help modals permanently
67
- }
68
- }
69
- function handleSkip() {
70
- if (dontShowMeAgain) {
71
- disableHelpModalsPermanently(); // Disable help modals permanently
72
- }
73
- else {
74
- hideHelpModalsUntilRefresh();
75
- }
76
- }
77
- // Navigate to the previous modal
78
- function previousModal() {
79
- const ids = get(buttonIds);
80
- const currentIndex = ids.indexOf($activeModalId);
81
- if (currentIndex > 0) {
82
- activeModalId.set(ids[currentIndex - 1]);
83
- console.log("Navigating to previous modal:", ids[currentIndex - 1]);
84
- }
85
- if (dontShowMeAgain) {
86
- disableHelpModalsPermanently(); // Disable help modals permanently
87
- }
88
- }
89
- function handleKeydown(event) {
90
- if (event.key === "Escape")
91
- onClose();
92
- }
93
- </script>
94
-
95
- <svelte:window on:keydown="{handleKeydown}" />
96
- {#if $showHelpModals}
97
- <div
98
- class="help-modal-wrapper"
99
- style="top: {modalPosition.top}px; left: {modalPosition.left}px;"
100
- transition:fly="{{ duration: 200, y: 10 }}"
101
- >
102
- <!-- Notch -->
103
- <div
104
- class="help-modal-notch"
105
- style="left: {notchPosition.left}px;right: {notchPosition.right}px;"
106
- ></div>
107
-
108
- <!-- Modal Content -->
109
- <div class="help-modal" role="dialog" aria-modal="true">
110
- <slot />
111
- <button class="close-button" on:click="{onClose}" aria-label="Close help">×</button>
112
-
113
- <div class="ons-padding-4">
114
- <Checkbox
115
- id="dontShowMeAgain"
116
- label="Don't show me again"
117
- bind:checked="{dontShowMeAgain}"
118
- compact
119
- />
120
- </div>
121
- <div class="ons-grid--flex ons-grid--between ons-grid--vertical-center">
122
- <button class="btn-link" on:click="{handleSkip}" aria-label="Skip instructions">Skip</button
123
- >
124
- {#if $buttonIds.indexOf($activeModalId) > 0}
125
- <span style="margin-left:auto; margin-right:10px">
126
- <Button variant="secondary" on:click="{previousModal}">Back</Button>
127
- </span>
128
- {/if}
129
-
130
- {#if $buttonIds.indexOf($activeModalId) != $buttonIds.length - 1}
131
- <Button on:click="{nextModal}">Next</Button>
132
- {/if}
133
- {#if $buttonIds.indexOf($activeModalId) == $buttonIds.length - 1}
134
- <Button on:click="{hideHelpModalsUntilRefresh}">Get started</Button>
135
- {/if}
136
- </div>
137
- </div>
138
- </div>
139
- {/if}
140
-
141
- <style>
142
- .help-modal-wrapper {
143
- position: absolute;
144
- z-index: 10;
145
- }
146
-
147
- .help-modal-notch {
148
- position: absolute;
149
- top: -10px;
150
- width: 0;
151
- height: 0;
152
- border-left: 10px solid transparent;
153
- border-right: 10px solid transparent;
154
- border-bottom: 10px solid white;
155
- z-index: 1;
156
- }
157
-
158
- .help-modal {
159
- position: absolute;
160
- flex-direction: column;
161
- justify-content: center;
162
- align-items: flex-start;
163
- padding: 16px;
164
- isolation: isolate;
165
-
166
- width: 360px;
167
-
168
- background: #ffffff;
169
- box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.25);
170
- border-radius: 16px;
171
-
172
- /* Inside auto layout */
173
- flex: none;
174
- order: 2;
175
- flex-grow: 0;
176
- }
177
-
178
- .close-button {
179
- position: absolute;
180
- top: 0.5rem;
181
- right: 0.5rem;
182
- background: none;
183
- border: none;
184
- font-size: 1.25rem;
185
- color: #666;
186
- cursor: pointer;
187
- }
188
-
189
- .close-button:hover {
190
- color: #333;
191
- }
192
-
193
- .ons-padding-4 {
194
- padding-top: var(--4-units, 16px);
195
- padding-bottom: var(--4-units, 16px);
196
- }
197
-
198
- button.btn-link {
199
- line-height: 1.3;
200
- color: var(--link, #206095);
201
- background: none;
202
- margin: 0;
203
- padding: 0;
204
- border: none;
205
- text-decoration: underline;
206
- text-decoration-thickness: 1px;
207
- text-underline-position: under;
208
- }
209
- button.btn-link:hover {
210
- color: var(--link-hover, #003c57) !important;
211
- text-decoration-thickness: 2px;
212
- }
213
- button.btn-link:focus {
214
- background-color: #fbc900 !important;
215
- box-shadow: 0 -2px #fbc900, 0 4px #222;
216
- color: #222 !important;
217
- outline: 3px solid transparent;
218
- outline-offset: 1px;
219
- text-decoration: none;
220
- }</style>