@sveltia/ui 0.1.1 → 0.1.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 (56) hide show
  1. package/package/components/composite/calendar.svelte +1 -0
  2. package/package/components/composite/calendar.svelte.d.ts +1 -8
  3. package/package/components/composite/checkbox-group.svelte.d.ts +1 -11
  4. package/package/components/composite/combobox.svelte +14 -1
  5. package/package/components/composite/combobox.svelte.d.ts +1 -16
  6. package/package/components/composite/disclosure.svelte.d.ts +1 -10
  7. package/package/components/composite/grid.svelte.d.ts +1 -10
  8. package/package/components/composite/listbox.svelte.d.ts +7 -20
  9. package/package/components/composite/menu-item-group.svelte.d.ts +1 -11
  10. package/package/components/composite/menu.svelte.d.ts +5 -14
  11. package/package/components/composite/radio-button-group.svelte +1 -0
  12. package/package/components/composite/radio-button-group.svelte.d.ts +1 -10
  13. package/package/components/composite/select-button-group.svelte +1 -0
  14. package/package/components/composite/select-button-group.svelte.d.ts +1 -14
  15. package/package/components/composite/select.svelte.d.ts +2 -14
  16. package/package/components/composite/tab-list.svelte +4 -4
  17. package/package/components/composite/tab-list.svelte.d.ts +9 -22
  18. package/package/components/core/button.svelte +7 -7
  19. package/package/components/core/button.svelte.d.ts +25 -55
  20. package/package/components/core/checkbox.svelte.d.ts +1 -14
  21. package/package/components/core/dialog.svelte.d.ts +1 -29
  22. package/package/components/core/grid-cell.svelte.d.ts +1 -9
  23. package/package/components/core/group.svelte.d.ts +1 -11
  24. package/package/components/core/icon.svelte.d.ts +1 -8
  25. package/package/components/core/menu-button.svelte.d.ts +1 -12
  26. package/package/components/core/menu-item-checkbox.svelte.d.ts +2 -12
  27. package/package/components/core/menu-item-radio.svelte.d.ts +2 -12
  28. package/package/components/core/menu-item.svelte.d.ts +2 -17
  29. package/package/components/core/number-input.svelte.d.ts +3 -17
  30. package/package/components/core/option.svelte.d.ts +6 -21
  31. package/package/components/core/password-input.svelte.d.ts +4 -15
  32. package/package/components/core/radio-button.svelte.d.ts +1 -11
  33. package/package/components/core/row-group.svelte.d.ts +1 -9
  34. package/package/components/core/row.svelte.d.ts +1 -11
  35. package/package/components/core/search-bar.svelte.d.ts +11 -25
  36. package/package/components/core/select-button.svelte.d.ts +2 -13
  37. package/package/components/core/separator.svelte.d.ts +1 -7
  38. package/package/components/core/slider.svelte +270 -0
  39. package/package/components/core/slider.svelte.d.ts +35 -0
  40. package/package/components/core/spacer.svelte.d.ts +1 -7
  41. package/package/components/core/switch.svelte.d.ts +1 -11
  42. package/package/components/core/tab-panel.svelte.d.ts +1 -9
  43. package/package/components/core/tab.svelte.d.ts +1 -9
  44. package/package/components/core/text-area.svelte.d.ts +11 -25
  45. package/package/components/core/text-input.svelte.d.ts +15 -33
  46. package/package/components/core/toolbar.svelte.d.ts +1 -10
  47. package/package/components/editor/markdown.svelte.d.ts +1 -7
  48. package/package/components/helpers/popup.d.ts +2 -7
  49. package/package/components/helpers/popup.js +1 -1
  50. package/package/components/util/app-shell.svelte.d.ts +1 -11
  51. package/package/components/util/popup.svelte +24 -16
  52. package/package/components/util/popup.svelte.d.ts +9 -18
  53. package/package/components/util/portal.svelte.d.ts +1 -8
  54. package/package/index.d.ts +1 -0
  55. package/package/index.js +1 -0
  56. package/package.json +26 -18
@@ -0,0 +1,270 @@
1
+ <!--
2
+ @component
3
+ @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range
4
+ @see https://w3c.github.io/aria/#slider
5
+ @see https://www.w3.org/WAI/ARIA/apg/patterns/slider/
6
+ @see https://www.w3.org/WAI/ARIA/apg/patterns/slider-multithumb/
7
+ -->
8
+ <script>
9
+ import { createEventDispatcher, onMount } from 'svelte';
10
+
11
+ /**
12
+ * CSS class name on the button.
13
+ * @type {String}
14
+ */
15
+ let className = '';
16
+
17
+ export { className as class };
18
+
19
+ export let value = 0;
20
+ export let sliderLabel = '';
21
+ export let values = undefined;
22
+ export let sliderLabels = [];
23
+ export let min = 0;
24
+ export let max = 100;
25
+ export let step = 1;
26
+ export let optionLabels = [];
27
+
28
+ $: multiThumb = !!values;
29
+
30
+ const dispatch = createEventDispatcher();
31
+ /** @type {(HTMLElement|undefined)} */
32
+ let base = undefined;
33
+ let barWidth = 0;
34
+ let positionList = [];
35
+ let valueList = [];
36
+ let startX = 0;
37
+ let startScreenX = 0;
38
+ const sliderPositions = [0, 0];
39
+ let dragging = false;
40
+ let targetValueIndex = 0;
41
+
42
+ const dragSlider = (diff) => {
43
+ if (diff >= 0 && diff <= barWidth) {
44
+ const fromIndex = positionList.findLastIndex((s) => s <= diff);
45
+ const toIndex = positionList.findIndex((s) => diff <= s);
46
+
47
+ const index =
48
+ Math.abs(positionList[fromIndex] - diff) < Math.abs(positionList[toIndex] - diff)
49
+ ? fromIndex
50
+ : toIndex;
51
+
52
+ if (
53
+ sliderPositions[targetValueIndex] === positionList[index] ||
54
+ (multiThumb &&
55
+ ((targetValueIndex === 0 && sliderPositions[1] <= positionList[index]) ||
56
+ (targetValueIndex === 1 && sliderPositions[0] >= positionList[index])))
57
+ ) {
58
+ return;
59
+ }
60
+
61
+ sliderPositions[targetValueIndex] = positionList[index];
62
+
63
+ if (multiThumb) {
64
+ values[targetValueIndex] = valueList[index];
65
+ dispatch('change', { values });
66
+ } else {
67
+ value = valueList[index];
68
+ dispatch('change', { value });
69
+ }
70
+ }
71
+ };
72
+
73
+ const onKeyDown = (event, valueIndex = 0) => {
74
+ const { key, shiftKey, altKey, ctrlKey, metaKey } = event;
75
+
76
+ if (shiftKey || altKey || ctrlKey || metaKey) {
77
+ return;
78
+ }
79
+
80
+ let index = -1;
81
+
82
+ if (['ArrowDown', 'ArrowLeft'].includes(key)) {
83
+ if (value > min) {
84
+ index = valueList.indexOf(value) - 1;
85
+ }
86
+
87
+ event.preventDefault();
88
+ event.stopPropagation();
89
+ }
90
+
91
+ if (['ArrowUp', 'ArrowRight'].includes(key)) {
92
+ if (value < max) {
93
+ index = valueList.indexOf(value) + 1;
94
+ }
95
+
96
+ event.preventDefault();
97
+ event.stopPropagation();
98
+ }
99
+
100
+ if (index > -1) {
101
+ if (
102
+ multiThumb &&
103
+ ((targetValueIndex === 0 && sliderPositions[1] <= positionList[index]) ||
104
+ (targetValueIndex === 1 && sliderPositions[0] >= positionList[index]))
105
+ ) {
106
+ return;
107
+ }
108
+
109
+ sliderPositions[valueIndex] = positionList[index];
110
+
111
+ if (multiThumb) {
112
+ values[valueIndex] = valueList[index];
113
+ dispatch('change', { values });
114
+ } else {
115
+ value = valueList[index];
116
+ dispatch('change', { value });
117
+ }
118
+ }
119
+ };
120
+
121
+ const onMouseDown = (event, valueIndex = 0) => {
122
+ const { clientX, screenX } = event;
123
+
124
+ dragging = true;
125
+ startX = clientX - base.getBoundingClientRect().x;
126
+ startScreenX = screenX;
127
+ targetValueIndex = valueIndex;
128
+ };
129
+
130
+ const onMouseMove = (event) => {
131
+ if (dragging) {
132
+ dragSlider(startX + (event.screenX - startScreenX));
133
+ }
134
+ };
135
+
136
+ const onClick = (event) => {
137
+ if (!multiThumb && !dragging) {
138
+ dragSlider(event.layerX);
139
+ }
140
+
141
+ if (dragging) {
142
+ dragging = false;
143
+ }
144
+ };
145
+
146
+ onMount(() => {
147
+ barWidth = base.clientWidth;
148
+
149
+ const stepCount = (max - min) / step + 1;
150
+ const stepWidth = barWidth / (stepCount - 1);
151
+
152
+ valueList = new Array(stepCount).fill(0).map((_, index) => index * step + min, 10);
153
+ positionList = new Array(stepCount).fill(0).map((_, index) => index * stepWidth);
154
+
155
+ if (multiThumb) {
156
+ sliderPositions[0] = positionList[valueList.indexOf(values[0])];
157
+ sliderPositions[1] = positionList[valueList.indexOf(values[1])];
158
+ } else {
159
+ sliderPositions[0] = positionList[valueList.indexOf(value)];
160
+ }
161
+ });
162
+ </script>
163
+
164
+ <svelte:body
165
+ on:mousemove={onMouseMove}
166
+ on:click={() => {
167
+ dragging = false;
168
+ }}
169
+ />
170
+
171
+ <!-- svelte-ignore a11y-click-events-have-key-events -->
172
+ <div class="sui slider {className}" on:click|preventDefault|stopPropagation>
173
+ <!-- svelte-ignore a11y-click-events-have-key-events -->
174
+ <div
175
+ class="base"
176
+ bind:this={base}
177
+ on:click|preventDefault|stopPropagation={(event) => {
178
+ onClick(event);
179
+ }}
180
+ >
181
+ <div
182
+ class="bar"
183
+ style:left="{multiThumb ? sliderPositions[0] : 0}px"
184
+ style:width="{multiThumb ? sliderPositions[1] - sliderPositions[0] : sliderPositions[0]}px"
185
+ />
186
+ <div
187
+ role="slider"
188
+ tabindex="0"
189
+ aria-label={multiThumb ? sliderLabels[0] || '' : sliderLabel}
190
+ aria-valuemin={min}
191
+ aria-valuemax={max}
192
+ aria-valuenow={value}
193
+ style:left="{sliderPositions[0]}px"
194
+ on:mousedown={(event) => {
195
+ onMouseDown(event, 0);
196
+ }}
197
+ on:keydown={(event) => {
198
+ onKeyDown(event, 0);
199
+ }}
200
+ />
201
+ {#if multiThumb}
202
+ <div
203
+ role="slider"
204
+ tabindex="0"
205
+ aria-label={sliderLabels[1] || ''}
206
+ aria-valuemin={min}
207
+ aria-valuemax={max}
208
+ aria-valuenow={value}
209
+ style:left="{sliderPositions[1]}px"
210
+ on:mousedown={(event) => {
211
+ onMouseDown(event, 1);
212
+ }}
213
+ on:keydown={(event) => {
214
+ onKeyDown(event, 1);
215
+ }}
216
+ />
217
+ {/if}
218
+ {#if optionLabels.length}
219
+ {#each optionLabels as label, index}
220
+ <span
221
+ class="label"
222
+ role="presentation"
223
+ style:left="{(barWidth / (optionLabels.length - 1)) * index}px"
224
+ >
225
+ {label}
226
+ </span>
227
+ {/each}
228
+ {/if}
229
+ </div>
230
+ </div>
231
+
232
+ <style>.slider {
233
+ position: relative;
234
+ display: inline-block;
235
+ padding: 16px;
236
+ }
237
+
238
+ .base {
239
+ position: relative;
240
+ width: var(--slider-base-width, 200px);
241
+ height: 8px;
242
+ border-radius: 8px;
243
+ background-color: var(--control-border-color);
244
+ }
245
+
246
+ .bar {
247
+ position: absolute;
248
+ top: 0;
249
+ height: 8px;
250
+ border-radius: 8px;
251
+ background-color: var(--primary-accent-color-lighter);
252
+ }
253
+
254
+ [role=slider] {
255
+ position: absolute;
256
+ top: 0;
257
+ border-radius: 8px;
258
+ width: 16px;
259
+ height: 16px;
260
+ background-color: var(--primary-accent-color-foreground);
261
+ cursor: pointer;
262
+ transform: translate(-8px, -4px);
263
+ }
264
+
265
+ .label {
266
+ position: absolute;
267
+ top: 12px;
268
+ transform: translateX(-50%);
269
+ font-size: 10px;
270
+ }</style>
@@ -0,0 +1,35 @@
1
+ /** @typedef {typeof __propDef.props} SliderProps */
2
+ /** @typedef {typeof __propDef.events} SliderEvents */
3
+ /** @typedef {typeof __propDef.slots} SliderSlots */
4
+ /**
5
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range
6
+ * @see https://w3c.github.io/aria/#slider
7
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/slider/
8
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/slider-multithumb/
9
+ */
10
+ export default class Slider {
11
+ }
12
+ export type SliderProps = typeof __propDef.props;
13
+ export type SliderEvents = typeof __propDef.events;
14
+ export type SliderSlots = typeof __propDef.slots;
15
+ declare const __propDef: {
16
+ props: {
17
+ class?: string;
18
+ value?: number;
19
+ min?: number;
20
+ max?: number;
21
+ step?: number;
22
+ sliderLabel?: string;
23
+ values?: any;
24
+ sliderLabels?: any[];
25
+ optionLabels?: any[];
26
+ };
27
+ events: {
28
+ click: MouseEvent;
29
+ change: CustomEvent<any>;
30
+ } & {
31
+ [evt: string]: CustomEvent<any>;
32
+ };
33
+ slots: {};
34
+ };
35
+ export {};
@@ -1,17 +1,11 @@
1
1
  /** @typedef {typeof __propDef.props} SpacerProps */
2
2
  /** @typedef {typeof __propDef.events} SpacerEvents */
3
3
  /** @typedef {typeof __propDef.slots} SpacerSlots */
4
- export default class Spacer extends SvelteComponentTyped<{
5
- class?: string;
6
- flex?: boolean;
7
- }, {
8
- [evt: string]: CustomEvent<any>;
9
- }, {}> {
4
+ export default class Spacer {
10
5
  }
11
6
  export type SpacerProps = typeof __propDef.props;
12
7
  export type SpacerEvents = typeof __propDef.events;
13
8
  export type SpacerSlots = typeof __propDef.slots;
14
- import { SvelteComponentTyped } from "svelte";
15
9
  declare const __propDef: {
16
10
  props: {
17
11
  class?: string;
@@ -5,21 +5,11 @@
5
5
  * @see https://w3c.github.io/aria/#switch
6
6
  * @see https://w3c.github.io/aria-practices/#switch
7
7
  */
8
- export default class Switch extends SvelteComponentTyped<{
9
- class?: string;
10
- label?: string;
11
- disabled?: boolean;
12
- checked?: boolean;
13
- }, {
14
- [evt: string]: CustomEvent<any>;
15
- }, {
16
- default: {};
17
- }> {
8
+ export default class Switch {
18
9
  }
19
10
  export type SwitchProps = typeof __propDef.props;
20
11
  export type SwitchEvents = typeof __propDef.events;
21
12
  export type SwitchSlots = typeof __propDef.slots;
22
- import { SvelteComponentTyped } from "svelte";
23
13
  declare const __propDef: {
24
14
  props: {
25
15
  class?: string;
@@ -5,19 +5,11 @@
5
5
  * @see https://w3c.github.io/aria/#tabpanel
6
6
  * @see https://w3c.github.io/aria-practices/#tabpanel
7
7
  */
8
- export default class TabPanel extends SvelteComponentTyped<{
9
- [x: string]: any;
10
- class?: string;
11
- }, {
12
- [evt: string]: CustomEvent<any>;
13
- }, {
14
- default: {};
15
- }> {
8
+ export default class TabPanel {
16
9
  }
17
10
  export type TabPanelProps = typeof __propDef.props;
18
11
  export type TabPanelEvents = typeof __propDef.events;
19
12
  export type TabPanelSlots = typeof __propDef.slots;
20
- import { SvelteComponentTyped } from "svelte";
21
13
  declare const __propDef: {
22
14
  props: {
23
15
  [x: string]: any;
@@ -5,19 +5,11 @@
5
5
  * @see https://w3c.github.io/aria/#tab
6
6
  * @see https://w3c.github.io/aria-practices/#tabpanel
7
7
  */
8
- export default class Tab extends SvelteComponentTyped<{
9
- [x: string]: any;
10
- class?: string;
11
- }, {
12
- [evt: string]: CustomEvent<any>;
13
- }, {
14
- default: {};
15
- }> {
8
+ export default class Tab {
16
9
  }
17
10
  export type TabProps = typeof __propDef.props;
18
11
  export type TabEvents = typeof __propDef.events;
19
12
  export type TabSlots = typeof __propDef.slots;
20
- import { SvelteComponentTyped } from "svelte";
21
13
  declare const __propDef: {
22
14
  props: {
23
15
  [x: string]: any;
@@ -2,40 +2,26 @@
2
2
  /** @typedef {typeof __propDef.events} TextAreaEvents */
3
3
  /** @typedef {typeof __propDef.slots} TextAreaSlots */
4
4
  /** @see https://w3c.github.io/aria/#textbox */
5
- export default class TextArea extends SvelteComponentTyped<{
6
- [x: string]: any;
7
- class?: string;
8
- name?: string;
9
- element?: HTMLTextAreaElement;
10
- value?: string;
11
- autoResize?: boolean;
12
- }, {
13
- click: MouseEvent;
14
- input: Event;
15
- keypress: KeyboardEvent;
16
- } & {
17
- [evt: string]: CustomEvent<any>;
18
- }, {}> {
5
+ export default class TextArea {
19
6
  /**accessor*/
20
- set class(arg: string);
21
- get class(): string;
7
+ set class(arg: any);
8
+ get class(): any;
22
9
  /**accessor*/
23
- set element(arg: HTMLTextAreaElement);
24
- get element(): HTMLTextAreaElement;
10
+ set element(arg: any);
11
+ get element(): any;
25
12
  /**accessor*/
26
- set name(arg: string);
27
- get name(): string;
13
+ set name(arg: any);
14
+ get name(): any;
28
15
  /**accessor*/
29
- set value(arg: string);
30
- get value(): string;
16
+ set value(arg: any);
17
+ get value(): any;
31
18
  /**accessor*/
32
- set autoResize(arg: boolean);
33
- get autoResize(): boolean;
19
+ set autoResize(arg: any);
20
+ get autoResize(): any;
34
21
  }
35
22
  export type TextAreaProps = typeof __propDef.props;
36
23
  export type TextAreaEvents = typeof __propDef.events;
37
24
  export type TextAreaSlots = typeof __propDef.slots;
38
- import { SvelteComponentTyped } from "svelte";
39
25
  declare const __propDef: {
40
26
  props: {
41
27
  [x: string]: any;
@@ -2,50 +2,32 @@
2
2
  /** @typedef {typeof __propDef.events} TextInputEvents */
3
3
  /** @typedef {typeof __propDef.slots} TextInputSlots */
4
4
  /** @see https://w3c.github.io/aria/#textbox */
5
- export default class TextInput extends SvelteComponentTyped<{
6
- [x: string]: any;
7
- class?: string;
8
- name?: string;
9
- element?: HTMLInputElement;
10
- role?: "textbox" | "searchbox" | "combobox" | "spinbutton";
11
- disabled?: boolean;
12
- value?: string;
13
- readOnly?: boolean;
14
- }, {
15
- input: Event;
16
- keydown: KeyboardEvent;
17
- keyup: KeyboardEvent;
18
- keypress: KeyboardEvent;
19
- change: Event;
20
- } & {
21
- [evt: string]: CustomEvent<any>;
22
- }, {}> {
5
+ export default class TextInput {
23
6
  /**accessor*/
24
- set class(arg: string);
25
- get class(): string;
7
+ set class(arg: any);
8
+ get class(): any;
26
9
  /**accessor*/
27
- set element(arg: HTMLInputElement);
28
- get element(): HTMLInputElement;
10
+ set element(arg: any);
11
+ get element(): any;
29
12
  /**accessor*/
30
- set role(arg: "textbox" | "searchbox" | "combobox" | "spinbutton");
31
- get role(): "textbox" | "searchbox" | "combobox" | "spinbutton";
13
+ set role(arg: any);
14
+ get role(): any;
32
15
  /**accessor*/
33
- set readOnly(arg: boolean);
34
- get readOnly(): boolean;
16
+ set readOnly(arg: any);
17
+ get readOnly(): any;
35
18
  /**accessor*/
36
- set disabled(arg: boolean);
37
- get disabled(): boolean;
19
+ set disabled(arg: any);
20
+ get disabled(): any;
38
21
  /**accessor*/
39
- set name(arg: string);
40
- get name(): string;
22
+ set name(arg: any);
23
+ get name(): any;
41
24
  /**accessor*/
42
- set value(arg: string);
43
- get value(): string;
25
+ set value(arg: any);
26
+ get value(): any;
44
27
  }
45
28
  export type TextInputProps = typeof __propDef.props;
46
29
  export type TextInputEvents = typeof __propDef.events;
47
30
  export type TextInputSlots = typeof __propDef.slots;
48
- import { SvelteComponentTyped } from "svelte";
49
31
  declare const __propDef: {
50
32
  props: {
51
33
  [x: string]: any;
@@ -5,20 +5,11 @@
5
5
  * @see https://w3c.github.io/aria/#toolbar
6
6
  * @see https://w3c.github.io/aria-practices/#toolbar
7
7
  */
8
- export default class Toolbar extends SvelteComponentTyped<{
9
- [x: string]: any;
10
- class?: string;
11
- orientation?: "vertical" | "horizontal";
12
- }, {
13
- [evt: string]: CustomEvent<any>;
14
- }, {
15
- default: {};
16
- }> {
8
+ export default class Toolbar {
17
9
  }
18
10
  export type ToolbarProps = typeof __propDef.props;
19
11
  export type ToolbarEvents = typeof __propDef.events;
20
12
  export type ToolbarSlots = typeof __propDef.slots;
21
- import { SvelteComponentTyped } from "svelte";
22
13
  declare const __propDef: {
23
14
  props: {
24
15
  [x: string]: any;
@@ -1,17 +1,11 @@
1
1
  /** @typedef {typeof __propDef.props} MarkdownProps */
2
2
  /** @typedef {typeof __propDef.events} MarkdownEvents */
3
3
  /** @typedef {typeof __propDef.slots} MarkdownSlots */
4
- export default class Markdown extends SvelteComponentTyped<{
5
- disabled?: boolean;
6
- value?: string;
7
- }, {
8
- [evt: string]: CustomEvent<any>;
9
- }, {}> {
4
+ export default class Markdown {
10
5
  }
11
6
  export type MarkdownProps = typeof __propDef.props;
12
7
  export type MarkdownEvents = typeof __propDef.events;
13
8
  export type MarkdownSlots = typeof __propDef.slots;
14
- import { SvelteComponentTyped } from "svelte";
15
9
  declare const __propDef: {
16
10
  props: {
17
11
  disabled?: boolean;
@@ -11,13 +11,8 @@ declare class Popup {
11
11
  * @param {PopupPosition} position
12
12
  */
13
13
  constructor(anchorElement: HTMLElement, popupElement: HTMLElement, position: PopupPosition);
14
- open: import("svelte/store").Writable<boolean>;
15
- style: import("svelte/store").Writable<{
16
- inset: any;
17
- zIndex: any;
18
- width: any;
19
- height: any;
20
- }>;
14
+ open: any;
15
+ style: any;
21
16
  observer: IntersectionObserver;
22
17
  anchorElement: HTMLElement;
23
18
  popupElement: HTMLElement;
@@ -104,7 +104,7 @@ class Popup {
104
104
  this.open.subscribe((open) => {
105
105
  if (open) {
106
106
  this.checkPosition();
107
- } else {
107
+ } else if (this.anchorElement.getAttribute('aria-expanded') === 'true') {
108
108
  this.anchorElement.focus();
109
109
  }
110
110
 
@@ -6,21 +6,11 @@
6
6
  * dark/light mode switching. This component has to be placed directly under `<body>` (or
7
7
  * `<div style="display:contents">` in a SvelteKit app).
8
8
  */
9
- export default class AppShell extends SvelteComponentTyped<{
10
- [x: string]: never;
11
- }, {
12
- dragover: DragEvent;
13
- drop: DragEvent;
14
- } & {
15
- [evt: string]: CustomEvent<any>;
16
- }, {
17
- default: {};
18
- }> {
9
+ export default class AppShell {
19
10
  }
20
11
  export type AppShellProps = typeof __propDef.props;
21
12
  export type AppShellEvents = typeof __propDef.events;
22
13
  export type AppShellSlots = typeof __propDef.slots;
23
- import { SvelteComponentTyped } from "svelte";
24
14
  declare const __propDef: {
25
15
  props: {
26
16
  [x: string]: never;
@@ -43,25 +43,33 @@
43
43
  }
44
44
  }
45
45
 
46
+ const openDialog = () => {
47
+ window.clearTimeout(closeDialogTimer);
48
+ (document.querySelector('.sui.app-shell') || document.body).appendChild(dialog);
49
+ showContent = true;
50
+ dialog.showModal();
51
+
52
+ window.requestAnimationFrame(() => {
53
+ showDialog = true;
54
+ });
55
+ };
56
+
57
+ const closeDialog = () => {
58
+ showDialog = false;
59
+
60
+ closeDialogTimer = window.setTimeout(() => {
61
+ showContent = false;
62
+ dialog?.close();
63
+ dialog?.remove();
64
+ }, 500);
65
+ };
66
+
46
67
  $: {
47
68
  if (dialog) {
48
69
  if ($open) {
49
- window.clearTimeout(closeDialogTimer);
50
- (document.querySelector('.sui.app-shell') || document.body).appendChild(dialog);
51
- showContent = true;
52
- dialog.showModal();
53
-
54
- window.requestAnimationFrame(() => {
55
- showDialog = true;
56
- });
70
+ openDialog();
57
71
  } else {
58
- showDialog = false;
59
-
60
- closeDialogTimer = window.setTimeout(() => {
61
- showContent = false;
62
- dialog?.close();
63
- dialog?.remove();
64
- }, 500);
72
+ closeDialog();
65
73
  }
66
74
  }
67
75
  }
@@ -77,7 +85,7 @@
77
85
  });
78
86
  </script>
79
87
 
80
- <dialog class="sui popup" bind:this={dialog} class:open={showDialog}>
88
+ <dialog class="sui popup" bind:this={dialog} class:open={showDialog} {...$$restProps}>
81
89
  <!-- Prevent the first item in the slot, e.g. a menu item, from being focused by adding `tabindex`
82
90
  to the container -->
83
91
  <!-- svelte-ignore a11y-no-noninteractive-tabindex -->