@sveltia/ui 0.1.2 → 0.1.4

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 (67) hide show
  1. package/package/components/composite/calendar.svelte +5 -5
  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 +22 -4
  5. package/package/components/composite/combobox.svelte.d.ts +3 -18
  6. package/package/components/composite/disclosure.svelte.d.ts +2 -11
  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 +2 -12
  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 +3 -15
  16. package/package/components/composite/tab-list.svelte.d.ts +10 -23
  17. package/package/components/core/button.svelte +18 -22
  18. package/package/components/core/button.svelte.d.ts +26 -61
  19. package/package/components/core/checkbox.svelte +4 -2
  20. package/package/components/core/checkbox.svelte.d.ts +1 -14
  21. package/package/components/core/dialog.svelte +4 -3
  22. package/package/components/core/dialog.svelte.d.ts +3 -31
  23. package/package/components/core/grid-cell.svelte.d.ts +1 -9
  24. package/package/components/core/group.svelte.d.ts +2 -12
  25. package/package/components/core/icon.svelte.d.ts +2 -9
  26. package/package/components/core/menu-button.svelte +10 -18
  27. package/package/components/core/menu-button.svelte.d.ts +9 -15
  28. package/package/components/core/menu-item-checkbox.svelte.d.ts +2 -12
  29. package/package/components/core/menu-item-radio.svelte.d.ts +2 -12
  30. package/package/components/core/menu-item.svelte +1 -1
  31. package/package/components/core/menu-item.svelte.d.ts +4 -19
  32. package/package/components/core/number-input.svelte +7 -6
  33. package/package/components/core/number-input.svelte.d.ts +3 -17
  34. package/package/components/core/option.svelte +3 -1
  35. package/package/components/core/option.svelte.d.ts +12 -21
  36. package/package/components/core/password-input.svelte +8 -3
  37. package/package/components/core/password-input.svelte.d.ts +4 -15
  38. package/package/components/core/radio-button.svelte +4 -2
  39. package/package/components/core/radio-button.svelte.d.ts +1 -11
  40. package/package/components/core/row-group.svelte.d.ts +1 -9
  41. package/package/components/core/row.svelte.d.ts +1 -11
  42. package/package/components/core/search-bar.svelte +3 -3
  43. package/package/components/core/search-bar.svelte.d.ts +12 -26
  44. package/package/components/core/select-button.svelte +2 -0
  45. package/package/components/core/select-button.svelte.d.ts +8 -13
  46. package/package/components/core/separator.svelte.d.ts +1 -7
  47. package/package/components/core/slider.svelte +270 -0
  48. package/package/components/core/slider.svelte.d.ts +35 -0
  49. package/package/components/core/spacer.svelte.d.ts +1 -7
  50. package/package/components/core/switch.svelte.d.ts +2 -12
  51. package/package/components/core/tab-panel.svelte.d.ts +1 -9
  52. package/package/components/core/tab.svelte +2 -0
  53. package/package/components/core/tab.svelte.d.ts +7 -9
  54. package/package/components/core/text-area.svelte.d.ts +12 -26
  55. package/package/components/core/text-input.svelte.d.ts +16 -34
  56. package/package/components/core/toolbar.svelte.d.ts +1 -10
  57. package/package/components/editor/markdown.svelte +4 -1
  58. package/package/components/editor/markdown.svelte.d.ts +1 -7
  59. package/package/components/helpers/popup.d.ts +2 -7
  60. package/package/components/helpers/popup.js +28 -16
  61. package/package/components/util/app-shell.svelte.d.ts +1 -11
  62. package/package/components/util/popup.svelte +24 -16
  63. package/package/components/util/popup.svelte.d.ts +10 -19
  64. package/package/components/util/portal.svelte.d.ts +1 -8
  65. package/package/index.d.ts +1 -0
  66. package/package/index.js +1 -0
  67. package/package.json +24 -16
@@ -2,26 +2,11 @@
2
2
  /** @typedef {typeof __propDef.events} OptionEvents */
3
3
  /** @typedef {typeof __propDef.slots} OptionSlots */
4
4
  /** @see https://w3c.github.io/aria/#option */
5
- export default class Option extends SvelteComponentTyped<{
6
- [x: string]: any;
7
- class?: string;
8
- selected?: boolean;
9
- }, {
10
- click: MouseEvent;
11
- dragover: DragEvent;
12
- dragleave: DragEvent;
13
- dragend: DragEvent;
14
- drop: DragEvent;
15
- } & {
16
- [evt: string]: CustomEvent<any>;
17
- }, {
18
- default: {};
19
- }> {
5
+ export default class Option {
20
6
  }
21
7
  export type OptionProps = typeof __propDef.props;
22
8
  export type OptionEvents = typeof __propDef.events;
23
9
  export type OptionSlots = typeof __propDef.slots;
24
- import { SvelteComponentTyped } from "svelte";
25
10
  declare const __propDef: {
26
11
  props: {
27
12
  [x: string]: any;
@@ -29,16 +14,22 @@ declare const __propDef: {
29
14
  selected?: boolean;
30
15
  };
31
16
  events: {
32
- click: MouseEvent;
33
- dragover: DragEvent;
34
- dragleave: DragEvent;
35
- dragend: DragEvent;
36
- drop: DragEvent;
17
+ click: any;
18
+ dragover: any;
19
+ dragleave: any;
20
+ dragend: any;
21
+ drop: any;
37
22
  } & {
38
23
  [evt: string]: CustomEvent<any>;
39
24
  };
40
25
  slots: {
26
+ 'start-icon': {
27
+ slot: string;
28
+ };
41
29
  default: {};
30
+ 'end-icon': {
31
+ slot: string;
32
+ };
42
33
  };
43
34
  };
44
35
  export {};
@@ -5,6 +5,7 @@
5
5
  <script>
6
6
  import { _ } from 'svelte-i18n';
7
7
  import Button from './button.svelte';
8
+ import Icon from './icon.svelte';
8
9
  import TextInput from './text-input.svelte';
9
10
 
10
11
  /**
@@ -44,12 +45,16 @@
44
45
  <Button
45
46
  class="iconic"
46
47
  pressed={passwordVisible}
47
- iconLabel={$_('sui.password_input.show_password')}
48
- iconName={passwordVisible ? 'visibility_off' : 'visibility'}
49
48
  on:click={() => {
50
49
  passwordVisible = !passwordVisible;
51
50
  }}
52
- />
51
+ >
52
+ <Icon
53
+ slot="start-icon"
54
+ name={passwordVisible ? 'visibility_off' : 'visibility'}
55
+ label={$_('sui.password_input.show_password')}
56
+ />
57
+ </Button>
53
58
  </div>
54
59
 
55
60
  <style>.password-input {
@@ -2,22 +2,11 @@
2
2
  /** @typedef {typeof __propDef.events} PasswordInputEvents */
3
3
  /** @typedef {typeof __propDef.slots} PasswordInputSlots */
4
4
  /** @see https://w3c.github.io/aria/#textbox */
5
- export default class PasswordInput extends SvelteComponentTyped<{
6
- [x: string]: any;
7
- class?: string;
8
- value?: string;
9
- }, {
10
- input: Event;
11
- keypress: KeyboardEvent;
12
- change: Event;
13
- } & {
14
- [evt: string]: CustomEvent<any>;
15
- }, {}> {
5
+ export default class PasswordInput {
16
6
  }
17
7
  export type PasswordInputProps = typeof __propDef.props;
18
8
  export type PasswordInputEvents = typeof __propDef.events;
19
9
  export type PasswordInputSlots = typeof __propDef.slots;
20
- import { SvelteComponentTyped } from "svelte";
21
10
  declare const __propDef: {
22
11
  props: {
23
12
  [x: string]: any;
@@ -25,9 +14,9 @@ declare const __propDef: {
25
14
  value?: (string | undefined);
26
15
  };
27
16
  events: {
28
- input: Event;
29
- keypress: KeyboardEvent;
30
- change: Event;
17
+ input: any;
18
+ keypress: any;
19
+ change: any;
31
20
  } & {
32
21
  [evt: string]: CustomEvent<any>;
33
22
  };
@@ -6,6 +6,7 @@
6
6
  <script>
7
7
  import { getRandomId } from '../helpers/util';
8
8
  import Button from './button.svelte';
9
+ import Icon from './icon.svelte';
9
10
 
10
11
  /**
11
12
  * CSS class name on the button.
@@ -44,7 +45,6 @@
44
45
  >
45
46
  <Button
46
47
  {id}
47
- iconName="circle"
48
48
  role="radio"
49
49
  aria-checked={selected}
50
50
  aria-labelledby="{id}-label"
@@ -53,7 +53,9 @@
53
53
  event.preventDefault();
54
54
  selected = !selected;
55
55
  }}
56
- />
56
+ >
57
+ <Icon slot="start-icon" name="circle" />
58
+ </Button>
57
59
  <label id="{id}-label">
58
60
  <slot />
59
61
  </label>
@@ -5,21 +5,11 @@
5
5
  * @see https://w3c.github.io/aria/#radio
6
6
  * @see https://w3c.github.io/aria-practices/#radiobutton
7
7
  */
8
- export default class RadioButton extends SvelteComponentTyped<{
9
- class?: string;
10
- name?: string;
11
- value?: string;
12
- selected?: boolean;
13
- }, {
14
- [evt: string]: CustomEvent<any>;
15
- }, {
16
- default: {};
17
- }> {
8
+ export default class RadioButton {
18
9
  }
19
10
  export type RadioButtonProps = typeof __propDef.props;
20
11
  export type RadioButtonEvents = typeof __propDef.events;
21
12
  export type RadioButtonSlots = typeof __propDef.slots;
22
- import { SvelteComponentTyped } from "svelte";
23
13
  declare const __propDef: {
24
14
  props: {
25
15
  class?: string;
@@ -1,19 +1,11 @@
1
1
  /** @typedef {typeof __propDef.props} RowGroupProps */
2
2
  /** @typedef {typeof __propDef.events} RowGroupEvents */
3
3
  /** @typedef {typeof __propDef.slots} RowGroupSlots */
4
- export default class RowGroup extends SvelteComponentTyped<{
5
- [x: string]: any;
6
- class?: string;
7
- }, {
8
- [evt: string]: CustomEvent<any>;
9
- }, {
10
- default: {};
11
- }> {
4
+ export default class RowGroup {
12
5
  }
13
6
  export type RowGroupProps = typeof __propDef.props;
14
7
  export type RowGroupEvents = typeof __propDef.events;
15
8
  export type RowGroupSlots = typeof __propDef.slots;
16
- import { SvelteComponentTyped } from "svelte";
17
9
  declare const __propDef: {
18
10
  props: {
19
11
  [x: string]: any;
@@ -1,21 +1,11 @@
1
1
  /** @typedef {typeof __propDef.props} RowProps */
2
2
  /** @typedef {typeof __propDef.events} RowEvents */
3
3
  /** @typedef {typeof __propDef.slots} RowSlots */
4
- export default class Row extends SvelteComponentTyped<{
5
- [x: string]: any;
6
- class?: string;
7
- }, {
8
- click: MouseEvent;
9
- } & {
10
- [evt: string]: CustomEvent<any>;
11
- }, {
12
- default: {};
13
- }> {
4
+ export default class Row {
14
5
  }
15
6
  export type RowProps = typeof __propDef.props;
16
7
  export type RowEvents = typeof __propDef.events;
17
8
  export type RowSlots = typeof __propDef.slots;
18
- import { SvelteComponentTyped } from "svelte";
19
9
  declare const __propDef: {
20
10
  props: {
21
11
  [x: string]: any;
@@ -47,8 +47,6 @@
47
47
  {#if value}
48
48
  <Button
49
49
  class="ternary iconic"
50
- iconName="close"
51
- iconLabel={$_('sui._.clear')}
52
50
  on:click={() => {
53
51
  value = '';
54
52
  input.element.focus();
@@ -58,7 +56,9 @@
58
56
  input.element.dispatchEvent(new KeyboardEvent('change'));
59
57
  });
60
58
  }}
61
- />
59
+ >
60
+ <Icon slot="start-icon" name="close" label={$_('sui._.clear')} />
61
+ </Button>
62
62
  {/if}
63
63
  </div>
64
64
 
@@ -2,45 +2,31 @@
2
2
  /** @typedef {typeof __propDef.events} SearchBarEvents */
3
3
  /** @typedef {typeof __propDef.slots} SearchBarSlots */
4
4
  /** @see https://w3c.github.io/aria/#search */
5
- export default class SearchBar extends SvelteComponentTyped<{
6
- [x: string]: any;
7
- class?: string;
8
- focus?: () => void;
9
- value?: string;
10
- }, {
11
- input: Event;
12
- keydown: KeyboardEvent;
13
- keyup: KeyboardEvent;
14
- keypress: KeyboardEvent;
15
- change: Event;
16
- } & {
17
- [evt: string]: CustomEvent<any>;
18
- }, {}> {
19
- get focus(): () => void;
5
+ export default class SearchBar {
6
+ get focus(): any;
20
7
  /**accessor*/
21
- set class(arg: string);
22
- get class(): string;
8
+ set class(arg: any);
9
+ get class(): any;
23
10
  /**accessor*/
24
- set value(arg: string);
25
- get value(): string;
11
+ set value(arg: any);
12
+ get value(): any;
26
13
  }
27
14
  export type SearchBarProps = typeof __propDef.props;
28
15
  export type SearchBarEvents = typeof __propDef.events;
29
16
  export type SearchBarSlots = typeof __propDef.slots;
30
- import { SvelteComponentTyped } from "svelte";
31
17
  declare const __propDef: {
32
18
  props: {
33
19
  [x: string]: any;
34
- class?: string;
35
20
  focus?: () => void;
21
+ class?: string;
36
22
  value?: string;
37
23
  };
38
24
  events: {
39
- input: Event;
40
- keydown: KeyboardEvent;
41
- keyup: KeyboardEvent;
42
- keypress: KeyboardEvent;
43
- change: Event;
25
+ input: any;
26
+ keydown: any;
27
+ keyup: any;
28
+ keypress: any;
29
+ change: any;
44
30
  } & {
45
31
  [evt: string]: CustomEvent<any>;
46
32
  };
@@ -25,5 +25,7 @@
25
25
  {...$$restProps}
26
26
  on:click
27
27
  >
28
+ <slot name="start-icon" slot="start-icon" />
28
29
  <slot />
30
+ <slot name="end-icon" slot="end-icon" />
29
31
  </Button>
@@ -6,22 +6,11 @@
6
6
  * @see https://w3c.github.io/aria/#radio
7
7
  * @see https://w3c.github.io/aria-practices/#radiobutton
8
8
  */
9
- export default class SelectButton extends SvelteComponentTyped<{
10
- [x: string]: any;
11
- class?: string;
12
- selected?: boolean;
13
- }, {
14
- click: MouseEvent;
15
- } & {
16
- [evt: string]: CustomEvent<any>;
17
- }, {
18
- default: {};
19
- }> {
9
+ export default class SelectButton {
20
10
  }
21
11
  export type SelectButtonProps = typeof __propDef.props;
22
12
  export type SelectButtonEvents = typeof __propDef.events;
23
13
  export type SelectButtonSlots = typeof __propDef.slots;
24
- import { SvelteComponentTyped } from "svelte";
25
14
  declare const __propDef: {
26
15
  props: {
27
16
  [x: string]: any;
@@ -29,12 +18,18 @@ declare const __propDef: {
29
18
  selected?: boolean;
30
19
  };
31
20
  events: {
32
- click: MouseEvent;
21
+ click: any;
33
22
  } & {
34
23
  [evt: string]: CustomEvent<any>;
35
24
  };
36
25
  slots: {
26
+ 'start-icon': {
27
+ slot: string;
28
+ };
37
29
  default: {};
30
+ 'end-icon': {
31
+ slot: string;
32
+ };
38
33
  };
39
34
  };
40
35
  export {};
@@ -2,17 +2,11 @@
2
2
  /** @typedef {typeof __propDef.events} SeparatorEvents */
3
3
  /** @typedef {typeof __propDef.slots} SeparatorSlots */
4
4
  /** @see https://w3c.github.io/aria/#separator */
5
- export default class Separator extends SvelteComponentTyped<{
6
- class?: string;
7
- orientation?: string;
8
- }, {
9
- [evt: string]: CustomEvent<any>;
10
- }, {}> {
5
+ export default class Separator {
11
6
  }
12
7
  export type SeparatorProps = typeof __propDef.props;
13
8
  export type SeparatorEvents = typeof __propDef.events;
14
9
  export type SeparatorSlots = typeof __propDef.slots;
15
- import { SvelteComponentTyped } from "svelte";
16
10
  declare const __propDef: {
17
11
  props: {
18
12
  class?: string;
@@ -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;