@sveltia/ui 0.2.5 → 0.3.1

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 (120) hide show
  1. package/package/components/{core → button}/button.svelte +3 -2
  2. package/package/components/{core → button}/button.svelte.d.ts +5 -4
  3. package/package/components/{composite → button}/select-button-group.svelte +6 -3
  4. package/package/components/{composite → calendar}/calendar.svelte +9 -5
  5. package/package/components/{composite → calendar}/calendar.svelte.d.ts +1 -0
  6. package/package/components/{composite → checkbox}/checkbox-group.svelte +1 -1
  7. package/package/components/{composite → checkbox}/checkbox-group.svelte.d.ts +2 -2
  8. package/package/components/{core → checkbox}/checkbox.svelte +7 -5
  9. package/package/components/{core → checkbox}/checkbox.svelte.d.ts +4 -2
  10. package/package/components/{core → dialog}/dialog.svelte +4 -3
  11. package/package/components/{core → dialog}/dialog.svelte.d.ts +1 -0
  12. package/package/components/{composite → disclosure}/disclosure.svelte +5 -4
  13. package/package/components/{composite → disclosure}/disclosure.svelte.d.ts +2 -1
  14. package/package/components/{core/separator.svelte → divider/divider.svelte} +5 -4
  15. package/package/components/divider/divider.svelte.d.ts +29 -0
  16. package/package/components/{core → divider}/spacer.svelte +4 -0
  17. package/package/components/{core → divider}/spacer.svelte.d.ts +1 -0
  18. package/package/components/{core → drawer}/drawer.svelte +4 -3
  19. package/package/components/{core → drawer}/drawer.svelte.d.ts +1 -0
  20. package/package/components/{core → icon}/icon.svelte +5 -0
  21. package/package/components/{core → icon}/icon.svelte.d.ts +6 -2
  22. package/package/components/listbox/listbox.svelte +74 -0
  23. package/package/components/{composite → listbox}/listbox.svelte.d.ts +2 -0
  24. package/package/components/listbox/option-group.svelte +47 -0
  25. package/package/components/listbox/option-group.svelte.d.ts +38 -0
  26. package/package/components/{core → listbox}/option.svelte +34 -2
  27. package/package/components/{core → listbox}/option.svelte.d.ts +7 -3
  28. package/package/components/{core → menu}/menu-button.svelte +2 -16
  29. package/package/components/{core → menu}/menu-button.svelte.d.ts +4 -1
  30. package/package/components/{core → menu}/menu-item-checkbox.svelte +1 -0
  31. package/package/components/{core → menu}/menu-item-checkbox.svelte.d.ts +4 -1
  32. package/package/components/{composite → menu}/menu-item-group.svelte +5 -1
  33. package/package/components/{composite → menu}/menu-item-group.svelte.d.ts +1 -0
  34. package/package/components/{core → menu}/menu-item-radio.svelte +2 -0
  35. package/package/components/{core → menu}/menu-item-radio.svelte.d.ts +5 -1
  36. package/package/components/{core → menu}/menu-item.svelte +6 -6
  37. package/package/components/{core → menu}/menu-item.svelte.d.ts +4 -1
  38. package/package/components/{composite → menu}/menu.svelte +2 -1
  39. package/package/components/{composite → menu}/menu.svelte.d.ts +1 -0
  40. package/package/components/{composite → radio}/radio-group.svelte +6 -2
  41. package/package/components/{composite → radio}/radio-group.svelte.d.ts +1 -1
  42. package/package/components/{core → radio}/radio.svelte +6 -4
  43. package/package/components/{core → radio}/radio.svelte.d.ts +4 -2
  44. package/package/components/{composite → select}/combobox.svelte +7 -6
  45. package/package/components/{composite → select}/combobox.svelte.d.ts +3 -2
  46. package/package/components/{composite → select}/select.svelte +3 -1
  47. package/package/components/{composite → select}/select.svelte.d.ts +7 -3
  48. package/package/components/{core → slider}/slider.svelte +58 -47
  49. package/package/components/{core → slider}/slider.svelte.d.ts +12 -10
  50. package/package/components/{core → switch}/switch.svelte +36 -19
  51. package/package/components/{core → switch}/switch.svelte.d.ts +3 -2
  52. package/package/components/table/table-body.svelte +23 -0
  53. package/package/components/table/table-body.svelte.d.ts +34 -0
  54. package/package/components/table/table-cell.svelte +23 -0
  55. package/package/components/table/table-cell.svelte.d.ts +34 -0
  56. package/package/components/table/table-col-header.svelte +23 -0
  57. package/package/components/table/table-col-header.svelte.d.ts +34 -0
  58. package/package/components/table/table-foot.svelte +23 -0
  59. package/package/components/table/table-foot.svelte.d.ts +34 -0
  60. package/package/components/table/table-head.svelte +23 -0
  61. package/package/components/table/table-head.svelte.d.ts +34 -0
  62. package/package/components/table/table-row-header.svelte +23 -0
  63. package/package/components/table/table-row-header.svelte.d.ts +34 -0
  64. package/package/components/table/table-row.svelte +23 -0
  65. package/package/components/table/table-row.svelte.d.ts +38 -0
  66. package/package/components/table/table.svelte +44 -0
  67. package/package/components/table/table.svelte.d.ts +36 -0
  68. package/package/components/{composite → tabs}/tab-list.svelte +3 -2
  69. package/package/components/{composite → tabs}/tab-list.svelte.d.ts +6 -5
  70. package/package/components/{core → tabs}/tab-panel.svelte +1 -0
  71. package/package/components/{core → tabs}/tab-panel.svelte.d.ts +1 -0
  72. package/package/components/{core → tabs}/tab.svelte +2 -1
  73. package/package/components/{core → tabs}/tab.svelte.d.ts +1 -0
  74. package/package/components/{editor/markdown.svelte → text-field/markdown-editor.svelte} +10 -6
  75. package/package/components/text-field/markdown-editor.svelte.d.ts +26 -0
  76. package/package/components/{core → text-field}/number-input.svelte +13 -7
  77. package/package/components/{core → text-field}/number-input.svelte.d.ts +7 -3
  78. package/package/components/{core → text-field}/password-input.svelte +6 -3
  79. package/package/components/{core → text-field}/password-input.svelte.d.ts +8 -3
  80. package/package/components/{core → text-field}/search-bar.svelte +5 -2
  81. package/package/components/{core → text-field}/search-bar.svelte.d.ts +8 -3
  82. package/package/components/{core → text-field}/text-area.svelte +3 -1
  83. package/package/components/{core → text-field}/text-area.svelte.d.ts +9 -5
  84. package/package/components/{core → text-field}/text-input.svelte +6 -4
  85. package/package/components/{core → text-field}/text-input.svelte.d.ts +11 -7
  86. package/package/components/{core → toolbar}/toolbar.svelte +1 -0
  87. package/package/components/{core → toolbar}/toolbar.svelte.d.ts +2 -1
  88. package/package/components/util/app-shell.svelte +11 -40
  89. package/package/components/util/group.js +305 -0
  90. package/package/components/{core → util}/group.svelte +5 -11
  91. package/package/components/{core → util}/group.svelte.d.ts +4 -2
  92. package/package/components/util/popup.d.ts +30 -0
  93. package/package/components/{helpers → util}/popup.js +20 -25
  94. package/package/components/util/popup.svelte +14 -5
  95. package/package/components/util/{misc.d.ts → util.d.ts} +1 -0
  96. package/package/components/util/{misc.js → util.js} +15 -0
  97. package/package/index.d.ts +46 -41
  98. package/package/index.js +48 -83
  99. package/package/styles/core.scss +5 -34
  100. package/package/styles/variables.scss +6 -8
  101. package/package.json +351 -317
  102. package/package/components/composite/grid.svelte +0 -24
  103. package/package/components/composite/grid.svelte.d.ts +0 -31
  104. package/package/components/composite/listbox.svelte +0 -63
  105. package/package/components/core/grid-cell.svelte +0 -13
  106. package/package/components/core/grid-cell.svelte.d.ts +0 -29
  107. package/package/components/core/row-group.svelte +0 -13
  108. package/package/components/core/row-group.svelte.d.ts +0 -29
  109. package/package/components/core/row.svelte +0 -13
  110. package/package/components/core/row.svelte.d.ts +0 -33
  111. package/package/components/core/separator.svelte.d.ts +0 -26
  112. package/package/components/editor/markdown.svelte.d.ts +0 -25
  113. package/package/components/helpers/group.js +0 -253
  114. package/package/components/helpers/popup.d.ts +0 -30
  115. package/package/components/helpers/util.d.ts +0 -1
  116. package/package/components/helpers/util.js +0 -14
  117. package/package/components/{composite → button}/select-button-group.svelte.d.ts +4 -4
  118. /package/package/components/{core → button}/select-button.svelte +0 -0
  119. /package/package/components/{core → button}/select-button.svelte.d.ts +0 -0
  120. /package/package/components/{helpers → util}/group.d.ts +0 -0
@@ -1,24 +0,0 @@
1
- <script>
2
- import { activateGroup } from '../helpers/group';
3
-
4
- /**
5
- * CSS class name on the button.
6
- * @type {string}
7
- */
8
- let className = '';
9
-
10
- export { className as class };
11
-
12
- /** @type {HTMLElement?} */
13
- export let element = undefined;
14
- </script>
15
-
16
- <div
17
- role="grid"
18
- class="sui grid {className}"
19
- {...$$restProps}
20
- bind:this={element}
21
- use:activateGroup
22
- >
23
- <slot />
24
- </div>
@@ -1,31 +0,0 @@
1
- /** @typedef {typeof __propDef.props} GridProps */
2
- /** @typedef {typeof __propDef.events} GridEvents */
3
- /** @typedef {typeof __propDef.slots} GridSlots */
4
- export default class Grid extends SvelteComponentTyped<{
5
- [x: string]: any;
6
- class?: string;
7
- element?: HTMLElement;
8
- }, {
9
- [evt: string]: CustomEvent<any>;
10
- }, {
11
- default: {};
12
- }> {
13
- }
14
- export type GridProps = typeof __propDef.props;
15
- export type GridEvents = typeof __propDef.events;
16
- export type GridSlots = typeof __propDef.slots;
17
- import { SvelteComponentTyped } from "svelte";
18
- declare const __propDef: {
19
- props: {
20
- [x: string]: any;
21
- class?: string;
22
- element?: HTMLElement | null;
23
- };
24
- events: {
25
- [evt: string]: CustomEvent<any>;
26
- };
27
- slots: {
28
- default: {};
29
- };
30
- };
31
- export {};
@@ -1,63 +0,0 @@
1
- <!--
2
- @component
3
- @see https://w3c.github.io/aria/#listbox
4
- @see https://www.w3.org/WAI/ARIA/apg/patterns/listbox/
5
- -->
6
- <svelte:options accessors={true} />
7
-
8
- <script>
9
- import { activateGroup } from '../helpers/group';
10
-
11
- /**
12
- * CSS class name on the button.
13
- * @type {string}
14
- */
15
- let className = '';
16
-
17
- export { className as class };
18
-
19
- /** @type {HTMLElement?} */
20
- export let element = undefined;
21
-
22
- export let multiple = false;
23
- </script>
24
-
25
- <div
26
- class="sui listbox {className}"
27
- role="listbox"
28
- tabindex="0"
29
- aria-multiselectable={multiple}
30
- {...$$restProps}
31
- bind:this={element}
32
- on:click
33
- on:select
34
- use:activateGroup
35
- >
36
- <slot />
37
- </div>
38
-
39
- <style>[role=listbox] {
40
- display: flex;
41
- flex-direction: column;
42
- color: inherit;
43
- margin: 0;
44
- border-width: 1px;
45
- border-color: var(--secondary-control-border-color);
46
- border-radius: 4px;
47
- padding: 4px;
48
- }
49
- [role=listbox] :global([role="separator"]) {
50
- margin: 4px;
51
- }
52
- [role=listbox] :global([role="group"]):not(:first-child) {
53
- margin-top: 16px;
54
- }
55
- [role=listbox] :global([role="group"]):not(:last-child) {
56
- margin-bottom: 16px;
57
- }
58
- [role=listbox] :global([role="group"]) :global(.title) {
59
- margin: 0 8px 8px;
60
- color: var(--secondary-foreground-color);
61
- font-size: var(--font-size--x-small);
62
- text-transform: uppercase;
63
- }</style>
@@ -1,13 +0,0 @@
1
- <script>
2
- /**
3
- * CSS class name on the button.
4
- * @type {string}
5
- */
6
- let className = '';
7
-
8
- export { className as class };
9
- </script>
10
-
11
- <div role="gridcell" class="sui grid-cell {className}" {...$$restProps}>
12
- <slot />
13
- </div>
@@ -1,29 +0,0 @@
1
- /** @typedef {typeof __propDef.props} GridCellProps */
2
- /** @typedef {typeof __propDef.events} GridCellEvents */
3
- /** @typedef {typeof __propDef.slots} GridCellSlots */
4
- export default class GridCell extends SvelteComponentTyped<{
5
- [x: string]: any;
6
- class?: string;
7
- }, {
8
- [evt: string]: CustomEvent<any>;
9
- }, {
10
- default: {};
11
- }> {
12
- }
13
- export type GridCellProps = typeof __propDef.props;
14
- export type GridCellEvents = typeof __propDef.events;
15
- export type GridCellSlots = typeof __propDef.slots;
16
- import { SvelteComponentTyped } from "svelte";
17
- declare const __propDef: {
18
- props: {
19
- [x: string]: any;
20
- class?: string;
21
- };
22
- events: {
23
- [evt: string]: CustomEvent<any>;
24
- };
25
- slots: {
26
- default: {};
27
- };
28
- };
29
- export {};
@@ -1,13 +0,0 @@
1
- <script>
2
- /**
3
- * CSS class name on the button.
4
- * @type {string}
5
- */
6
- let className = 'tbody';
7
-
8
- export { className as class };
9
- </script>
10
-
11
- <div role="rowgroup" class="sui row-group {className}" {...$$restProps}>
12
- <slot />
13
- </div>
@@ -1,29 +0,0 @@
1
- /** @typedef {typeof __propDef.props} RowGroupProps */
2
- /** @typedef {typeof __propDef.events} RowGroupEvents */
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
- }> {
12
- }
13
- export type RowGroupProps = typeof __propDef.props;
14
- export type RowGroupEvents = typeof __propDef.events;
15
- export type RowGroupSlots = typeof __propDef.slots;
16
- import { SvelteComponentTyped } from "svelte";
17
- declare const __propDef: {
18
- props: {
19
- [x: string]: any;
20
- class?: string;
21
- };
22
- events: {
23
- [evt: string]: CustomEvent<any>;
24
- };
25
- slots: {
26
- default: {};
27
- };
28
- };
29
- export {};
@@ -1,13 +0,0 @@
1
- <script>
2
- /**
3
- * CSS class name on the button.
4
- * @type {string}
5
- */
6
- let className = '';
7
-
8
- export { className as class };
9
- </script>
10
-
11
- <div role="row" tabindex="0" class="sui row {className}" {...$$restProps} on:click>
12
- <slot />
13
- </div>
@@ -1,33 +0,0 @@
1
- /** @typedef {typeof __propDef.props} RowProps */
2
- /** @typedef {typeof __propDef.events} RowEvents */
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
- }> {
14
- }
15
- export type RowProps = typeof __propDef.props;
16
- export type RowEvents = typeof __propDef.events;
17
- export type RowSlots = typeof __propDef.slots;
18
- import { SvelteComponentTyped } from "svelte";
19
- declare const __propDef: {
20
- props: {
21
- [x: string]: any;
22
- class?: string;
23
- };
24
- events: {
25
- click: MouseEvent;
26
- } & {
27
- [evt: string]: CustomEvent<any>;
28
- };
29
- slots: {
30
- default: {};
31
- };
32
- };
33
- export {};
@@ -1,26 +0,0 @@
1
- /** @typedef {typeof __propDef.props} SeparatorProps */
2
- /** @typedef {typeof __propDef.events} SeparatorEvents */
3
- /** @typedef {typeof __propDef.slots} SeparatorSlots */
4
- /** @see https://w3c.github.io/aria/#separator */
5
- export default class Separator extends SvelteComponentTyped<{
6
- class?: string;
7
- orientation?: "horizontal" | "vertical";
8
- }, {
9
- [evt: string]: CustomEvent<any>;
10
- }, {}> {
11
- }
12
- export type SeparatorProps = typeof __propDef.props;
13
- export type SeparatorEvents = typeof __propDef.events;
14
- export type SeparatorSlots = typeof __propDef.slots;
15
- import { SvelteComponentTyped } from "svelte";
16
- declare const __propDef: {
17
- props: {
18
- class?: string;
19
- orientation?: ('horizontal' | 'vertical');
20
- };
21
- events: {
22
- [evt: string]: CustomEvent<any>;
23
- };
24
- slots: {};
25
- };
26
- export {};
@@ -1,25 +0,0 @@
1
- /** @typedef {typeof __propDef.props} MarkdownProps */
2
- /** @typedef {typeof __propDef.events} MarkdownEvents */
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
- }, {}> {
10
- }
11
- export type MarkdownProps = typeof __propDef.props;
12
- export type MarkdownEvents = typeof __propDef.events;
13
- export type MarkdownSlots = typeof __propDef.slots;
14
- import { SvelteComponentTyped } from "svelte";
15
- declare const __propDef: {
16
- props: {
17
- disabled?: boolean;
18
- value?: string | null;
19
- };
20
- events: {
21
- [evt: string]: CustomEvent<any>;
22
- };
23
- slots: {};
24
- };
25
- export {};
@@ -1,253 +0,0 @@
1
- import { sleep } from '../util/misc';
2
- import { getRandomId } from './util';
3
-
4
- const config = {
5
- grid: {
6
- orientation: 'vertical',
7
- childRoles: ['row'],
8
- childSelectedAttr: 'aria-selected',
9
- },
10
- listbox: {
11
- orientation: 'vertical',
12
- childRoles: ['option'],
13
- childSelectedAttr: 'aria-selected',
14
- },
15
- menu: {
16
- orientation: 'vertical',
17
- childRoles: ['menuitem', 'menuitemcheckbox', 'menuitemradio'],
18
- childSelectedAttr: 'aria-checked',
19
- },
20
- menubar: {
21
- orientation: 'horizontal',
22
- childRoles: ['menuitem', 'menuitemcheckbox', 'menuitemradio'],
23
- childSelectedAttr: 'aria-checked',
24
- },
25
- radiogroup: {
26
- orientation: 'horizontal',
27
- childRoles: ['radio'],
28
- childSelectedAttr: 'aria-checked',
29
- },
30
- tablist: {
31
- orientation: 'horizontal',
32
- childRoles: ['tab'],
33
- childSelectedAttr: 'aria-selected',
34
- },
35
- };
36
-
37
- /**
38
- * Implement keyboard and mouse interactions for a grouping composite widget.
39
- */
40
- class Group {
41
- /**
42
- *
43
- * @param {HTMLElement} parent Parent element.
44
- * @todo Check for added elements probably with `MutationObserver`.
45
- */
46
- constructor(parent) {
47
- this.parent = parent;
48
- this.role = parent.getAttribute('role');
49
- this.grid = this.role === 'listbox' && parent.matches('.grid');
50
- this.multi = this.parent.getAttribute('aria-multiselectable') === 'true';
51
- this.id = getRandomId(this.role);
52
- this.parentGroupSelector = `[role="group"], [role="${this.role}"]`;
53
-
54
- const { orientation, childSelectedAttr } = config[this.role];
55
-
56
- this.orientation = this.grid
57
- ? 'horizontal'
58
- : this.parent.getAttribute('aria-orientation') || orientation;
59
- this.childSelectedAttr = childSelectedAttr;
60
-
61
- const { allMembers } = this;
62
-
63
- const hasSelected = allMembers.some((element) =>
64
- element.matches(`[${childSelectedAttr}="true"]`),
65
- );
66
-
67
- allMembers.forEach((element, index) => {
68
- const isSelected = element.matches(`[${childSelectedAttr}="true"]`);
69
- const controls = document.querySelector(`#${element.getAttribute('aria-controls')}`);
70
-
71
- element.id ||= `${this.id}-item-${index}`;
72
- element.tabIndex ||= isSelected || (!hasSelected && index === 0) ? 0 : -1;
73
- element.setAttribute(this.childSelectedAttr, String(isSelected));
74
- controls?.setAttribute('aria-labelledby', element.id);
75
- controls?.setAttribute('aria-hidden', String(!isSelected));
76
- });
77
-
78
- parent.addEventListener('click', (event) => {
79
- if (/** @type {HTMLElement} */ (event.target).matches(this.selector)) {
80
- this.onClick(event);
81
- }
82
- });
83
-
84
- parent.addEventListener('keydown', (event) => {
85
- this.onKeyDown(event);
86
- });
87
- }
88
-
89
- /** @type {string} */
90
- get selector() {
91
- const roles = config[this.role].childRoles;
92
-
93
- return roles ? roles.map((role) => `[role="${role}"]`).join(',') : '';
94
- }
95
-
96
- /** @type {HTMLElement[]} */
97
- get allMembers() {
98
- // @ts-ignore
99
- return [...this.parent.querySelectorAll(this.selector)];
100
- }
101
-
102
- /** @type {HTMLElement[]} */
103
- get activeMembers() {
104
- return this.allMembers.filter((element) => !element.matches('[aria-disabled="true"]'));
105
- }
106
-
107
- /**
108
- *
109
- * @param {MouseEvent} event `click` event.
110
- */
111
- onClick(event) {
112
- // eslint-disable-next-line prefer-destructuring
113
- const target = /** @type {HTMLButtonElement} */ (event.target);
114
-
115
- if (!target.matches(this.selector)) {
116
- return;
117
- }
118
-
119
- const targetParentGroup = target.closest(this.parentGroupSelector);
120
-
121
- this.allMembers.forEach((element) => {
122
- const isTarget = element === target;
123
-
124
- element.tabIndex = element === target ? 0 : -1;
125
-
126
- // Groups can be nested, e.g. `menu` > `group` > `menuitem`, so check if the parent is the
127
- // same as the target’s parent
128
- if (
129
- (element.matches('[role="radio"], [role="menuitemradio"]') ||
130
- (element.matches('[role="row"], [role="option"], [role="tab"]') && !this.multi)) &&
131
- element.closest(this.parentGroupSelector) === targetParentGroup
132
- ) {
133
- element.setAttribute(this.childSelectedAttr, String(isTarget));
134
- }
135
-
136
- const controls = element.getAttribute('aria-controls');
137
-
138
- if (controls) {
139
- document.getElementById(controls)?.setAttribute('aria-hidden', String(!isTarget));
140
- }
141
- });
142
-
143
- this.parent.dispatchEvent(
144
- new CustomEvent('select', {
145
- detail: {
146
- value: target.value,
147
- name: target.name,
148
- },
149
- }),
150
- );
151
- }
152
-
153
- /**
154
- *
155
- * @param {KeyboardEvent} event `keydown` event.
156
- */
157
- onKeyDown(event) {
158
- // eslint-disable-next-line prefer-destructuring
159
- const target = /** @type {HTMLElement} */ (event.target);
160
- const { key, ctrlKey, metaKey, shiftKey, altKey } = event;
161
-
162
- if (target.matches(this.selector) && !ctrlKey && !metaKey && !shiftKey && !altKey) {
163
- if ([' ', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) {
164
- event.preventDefault();
165
- }
166
-
167
- if (key === ' ' || (key === 'Enter' && !target.matches('button'))) {
168
- event.preventDefault();
169
- target.click();
170
-
171
- return;
172
- }
173
-
174
- const { allMembers, activeMembers } = this;
175
- let index;
176
- let newTarget;
177
-
178
- if (this.grid) {
179
- const colCount = Math.floor(this.parent.clientWidth / target.clientWidth);
180
-
181
- index = allMembers.indexOf(target);
182
-
183
- if (key === 'ArrowUp' && index > 0) {
184
- newTarget = allMembers[index - colCount];
185
- }
186
-
187
- if (key === 'ArrowDown' && index < allMembers.length - 1) {
188
- newTarget = allMembers[index + colCount];
189
- }
190
-
191
- if (key === 'ArrowLeft' && index > 0) {
192
- newTarget = allMembers[index - 1];
193
- }
194
-
195
- if (key === 'ArrowRight' && index < allMembers.length - 1) {
196
- newTarget = allMembers[index + 1];
197
- }
198
-
199
- if (newTarget?.getAttribute('aria-disabled') === 'true') {
200
- newTarget = undefined;
201
- }
202
- } else {
203
- index = activeMembers.indexOf(target);
204
-
205
- if (key === (this.orientation === 'horizontal' ? 'ArrowLeft' : 'ArrowUp')) {
206
- if (index > 0) {
207
- // Previous member
208
- newTarget = activeMembers[index - 1];
209
- }
210
-
211
- if (index === 0) {
212
- // Last member
213
- newTarget = activeMembers[activeMembers.length - 1];
214
- }
215
- }
216
-
217
- if (key === (this.orientation === 'horizontal' ? 'ArrowRight' : 'ArrowDown')) {
218
- if (index < activeMembers.length - 1) {
219
- // Next member
220
- newTarget = activeMembers[index + 1];
221
- }
222
-
223
- if (index === activeMembers.length - 1) {
224
- // First member
225
- [newTarget] = activeMembers;
226
- }
227
- }
228
- }
229
-
230
- if (newTarget && newTarget !== target) {
231
- activeMembers.forEach((element) => {
232
- element.tabIndex = element === newTarget ? 0 : -1;
233
- });
234
-
235
- newTarget.focus();
236
- }
237
- }
238
- }
239
- }
240
-
241
- /**
242
- * Activate a new group.
243
- * @param {...any} args Arguments.
244
- */
245
- export const activateGroup = (...args) => {
246
- (async () => {
247
- // Wait a bit before the relevant components, including the `aria-controls` target are mounted
248
- await sleep(100);
249
-
250
- // @ts-ignore
251
- return new Group(...args);
252
- })();
253
- };
@@ -1,30 +0,0 @@
1
- export function activatePopup(...args: any[]): Popup;
2
- /**
3
- *
4
- */
5
- declare class Popup {
6
- /**
7
- *
8
- * @param {HTMLElement} anchorElement
9
- * @param {HTMLElement} popupElement
10
- * @param {PopupPosition} position
11
- */
12
- constructor(anchorElement: HTMLElement, popupElement: HTMLElement, position: PopupPosition);
13
- open: import("svelte/store").Writable<boolean>;
14
- style: import("svelte/store").Writable<{
15
- inset: any;
16
- zIndex: any;
17
- width: any;
18
- height: any;
19
- }>;
20
- observer: IntersectionObserver;
21
- anchorElement: HTMLElement;
22
- popupElement: HTMLElement;
23
- position: PopupPosition;
24
- id: string;
25
- /**
26
- * Continue checking the position in case the window or parent element resizes.
27
- */
28
- checkPosition(): void;
29
- }
30
- export {};
@@ -1 +0,0 @@
1
- export function getRandomId(prefix?: string, length?: number): string;
@@ -1,14 +0,0 @@
1
- /**
2
- * Get a random ID that can be used for elements.
3
- * @param {string} [prefix] Prefix to be added to the ID, e.g. `popup`.
4
- * @param {number} [length] Number of characters to be used in the ID.
5
- * @returns {string} Generated ID.
6
- */
7
- export const getRandomId = (prefix = '', length = 7) =>
8
- [
9
- prefix,
10
- new Array(length)
11
- .fill()
12
- .map(() => '0123456789abcdef'[Math.floor(Math.random() * 12)])
13
- .join(''),
14
- ].join('-');
@@ -7,10 +7,10 @@
7
7
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/radio/
8
8
  */
9
9
  export default class SelectButtonGroup extends SvelteComponentTyped<{
10
- class?: string;
11
- element?: HTMLElement;
12
10
  disabled?: boolean;
13
11
  value?: string;
12
+ class?: string;
13
+ element?: HTMLElement;
14
14
  ariaLabel?: string;
15
15
  }, {
16
16
  change: CustomEvent<any>;
@@ -26,10 +26,10 @@ export type SelectButtonGroupSlots = typeof __propDef.slots;
26
26
  import { SvelteComponentTyped } from "svelte";
27
27
  declare const __propDef: {
28
28
  props: {
29
- class?: string;
30
- element?: HTMLElement | null;
31
29
  disabled?: boolean;
32
30
  value?: string;
31
+ class?: string;
32
+ element?: HTMLElement | null;
33
33
  ariaLabel?: string;
34
34
  };
35
35
  events: {
File without changes