@sveltia/ui 0.1.0

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 (104) hide show
  1. package/LICENSE.txt +21 -0
  2. package/package/components/composite/calendar.svelte +240 -0
  3. package/package/components/composite/calendar.svelte.d.ts +27 -0
  4. package/package/components/composite/checkbox-group.svelte +43 -0
  5. package/package/components/composite/checkbox-group.svelte.d.ts +34 -0
  6. package/package/components/composite/combobox.svelte +179 -0
  7. package/package/components/composite/combobox.svelte.d.ts +47 -0
  8. package/package/components/composite/disclosure.svelte +60 -0
  9. package/package/components/composite/disclosure.svelte.d.ts +35 -0
  10. package/package/components/composite/grid.svelte +24 -0
  11. package/package/components/composite/grid.svelte.d.ts +31 -0
  12. package/package/components/composite/listbox.svelte +63 -0
  13. package/package/components/composite/listbox.svelte.d.ts +52 -0
  14. package/package/components/composite/menu-item-group.svelte +31 -0
  15. package/package/components/composite/menu-item-group.svelte.d.ts +33 -0
  16. package/package/components/composite/menu.svelte +44 -0
  17. package/package/components/composite/menu.svelte.d.ts +41 -0
  18. package/package/components/composite/radio-button-group.svelte +44 -0
  19. package/package/components/composite/radio-button-group.svelte.d.ts +36 -0
  20. package/package/components/composite/select-button-group.svelte +69 -0
  21. package/package/components/composite/select-button-group.svelte.d.ts +44 -0
  22. package/package/components/composite/select.svelte +34 -0
  23. package/package/components/composite/select.svelte.d.ts +38 -0
  24. package/package/components/composite/tab-list.svelte +76 -0
  25. package/package/components/composite/tab-list.svelte.d.ts +55 -0
  26. package/package/components/core/button.svelte +209 -0
  27. package/package/components/core/button.svelte.d.ts +113 -0
  28. package/package/components/core/checkbox.svelte +105 -0
  29. package/package/components/core/checkbox.svelte.d.ts +43 -0
  30. package/package/components/core/dialog.svelte +258 -0
  31. package/package/components/core/dialog.svelte.d.ts +73 -0
  32. package/package/components/core/grid-cell.svelte +14 -0
  33. package/package/components/core/grid-cell.svelte.d.ts +29 -0
  34. package/package/components/core/group.svelte +31 -0
  35. package/package/components/core/group.svelte.d.ts +33 -0
  36. package/package/components/core/icon.svelte +21 -0
  37. package/package/components/core/icon.svelte.d.ts +27 -0
  38. package/package/components/core/menu-button.svelte +65 -0
  39. package/package/components/core/menu-button.svelte.d.ts +36 -0
  40. package/package/components/core/menu-item-checkbox.svelte +24 -0
  41. package/package/components/core/menu-item-checkbox.svelte.d.ts +34 -0
  42. package/package/components/core/menu-item-radio.svelte +19 -0
  43. package/package/components/core/menu-item-radio.svelte.d.ts +34 -0
  44. package/package/components/core/menu-item.svelte +113 -0
  45. package/package/components/core/menu-item.svelte.d.ts +44 -0
  46. package/package/components/core/number-input.svelte +109 -0
  47. package/package/components/core/number-input.svelte.d.ts +40 -0
  48. package/package/components/core/option.svelte +57 -0
  49. package/package/components/core/option.svelte.d.ts +44 -0
  50. package/package/components/core/password-input.svelte +76 -0
  51. package/package/components/core/password-input.svelte.d.ts +36 -0
  52. package/package/components/core/radio-button.svelte +91 -0
  53. package/package/components/core/radio-button.svelte.d.ts +37 -0
  54. package/package/components/core/row-group.svelte +14 -0
  55. package/package/components/core/row-group.svelte.d.ts +29 -0
  56. package/package/components/core/row.svelte +14 -0
  57. package/package/components/core/row.svelte.d.ts +33 -0
  58. package/package/components/core/search-bar.svelte +90 -0
  59. package/package/components/core/search-bar.svelte.d.ts +49 -0
  60. package/package/components/core/select-button.svelte +29 -0
  61. package/package/components/core/select-button.svelte.d.ts +40 -0
  62. package/package/components/core/separator.svelte +28 -0
  63. package/package/components/core/separator.svelte.d.ts +26 -0
  64. package/package/components/core/spacer.svelte +22 -0
  65. package/package/components/core/spacer.svelte.d.ts +25 -0
  66. package/package/components/core/switch.svelte +80 -0
  67. package/package/components/core/switch.svelte.d.ts +37 -0
  68. package/package/components/core/tab-panel.svelte +23 -0
  69. package/package/components/core/tab-panel.svelte.d.ts +33 -0
  70. package/package/components/core/tab.svelte +20 -0
  71. package/package/components/core/tab.svelte.d.ts +33 -0
  72. package/package/components/core/text-area.svelte +90 -0
  73. package/package/components/core/text-area.svelte.d.ts +57 -0
  74. package/package/components/core/text-input.svelte +145 -0
  75. package/package/components/core/text-input.svelte.d.ts +71 -0
  76. package/package/components/core/toolbar.svelte +74 -0
  77. package/package/components/core/toolbar.svelte.d.ts +35 -0
  78. package/package/components/editor/markdown.svelte +75 -0
  79. package/package/components/editor/markdown.svelte.d.ts +25 -0
  80. package/package/components/helpers/group.d.ts +37 -0
  81. package/package/components/helpers/group.js +246 -0
  82. package/package/components/helpers/popup.d.ts +31 -0
  83. package/package/components/helpers/popup.js +134 -0
  84. package/package/components/helpers/util.d.ts +1 -0
  85. package/package/components/helpers/util.js +8 -0
  86. package/package/components/util/app-shell.svelte +282 -0
  87. package/package/components/util/app-shell.svelte.d.ts +38 -0
  88. package/package/components/util/misc.d.ts +2 -0
  89. package/package/components/util/misc.js +22 -0
  90. package/package/components/util/popup.svelte +110 -0
  91. package/package/components/util/popup.svelte.d.ts +46 -0
  92. package/package/components/util/portal.svelte +34 -0
  93. package/package/components/util/portal.svelte.d.ts +28 -0
  94. package/package/index.d.ts +40 -0
  95. package/package/index.js +65 -0
  96. package/package/locales/en.d.ts +42 -0
  97. package/package/locales/en.js +41 -0
  98. package/package/locales/ja.d.ts +42 -0
  99. package/package/locales/ja.js +41 -0
  100. package/package/styles/core.scss +134 -0
  101. package/package/styles/variables.scss +113 -0
  102. package/package/typedef.d.ts +0 -0
  103. package/package/typedef.js +0 -0
  104. package/package.json +461 -0
@@ -0,0 +1,34 @@
1
+ /** @typedef {typeof __propDef.props} MenuItemRadioProps */
2
+ /** @typedef {typeof __propDef.events} MenuItemRadioEvents */
3
+ /** @typedef {typeof __propDef.slots} MenuItemRadioSlots */
4
+ /** @see https://w3c.github.io/aria/#menuitemradio */
5
+ export default class MenuItemRadio extends SvelteComponentTyped<{
6
+ [x: string]: any;
7
+ class?: string;
8
+ }, {
9
+ click: MouseEvent;
10
+ } & {
11
+ [evt: string]: CustomEvent<any>;
12
+ }, {
13
+ default: {};
14
+ }> {
15
+ }
16
+ export type MenuItemRadioProps = typeof __propDef.props;
17
+ export type MenuItemRadioEvents = typeof __propDef.events;
18
+ export type MenuItemRadioSlots = typeof __propDef.slots;
19
+ import { SvelteComponentTyped } from "svelte";
20
+ declare const __propDef: {
21
+ props: {
22
+ [x: string]: any;
23
+ class?: string;
24
+ };
25
+ events: {
26
+ click: MouseEvent;
27
+ } & {
28
+ [evt: string]: CustomEvent<any>;
29
+ };
30
+ slots: {
31
+ default: {};
32
+ };
33
+ };
34
+ export {};
@@ -0,0 +1,113 @@
1
+ <!--
2
+ @component
3
+ @see https://w3c.github.io/aria/#menuitem
4
+ -->
5
+ <script>
6
+ import { writable } from 'svelte/store';
7
+ import Menu from '../composite/menu.svelte';
8
+ import Popup from '../util/popup.svelte';
9
+ import Button from './button.svelte';
10
+ import Icon from './icon.svelte';
11
+
12
+ let className = '';
13
+
14
+ export { className as class };
15
+
16
+ /** @type {('menuitem'|'menuitemcheckbox'|'menuitemradio')} */
17
+ export let role = 'menuitem';
18
+
19
+ export let label = '';
20
+
21
+ export let iconName = '';
22
+
23
+ export let iconLabel = '';
24
+
25
+ export let checked = false;
26
+
27
+ /** @type {Button} */
28
+ let buttonComponent;
29
+ let isPopupOpen = writable(false);
30
+
31
+ $: hasChildren = role === 'menuitem' && $$slots.default;
32
+ </script>
33
+
34
+ <div class="sui menuitem {className}">
35
+ <Button
36
+ {role}
37
+ aria-checked={checked}
38
+ aria-haspopup={hasChildren ? 'menu' : undefined}
39
+ aria-expanded={$isPopupOpen ? true : undefined}
40
+ {...$$restProps}
41
+ bind:this={buttonComponent}
42
+ on:click
43
+ on:mouseenter={() => {
44
+ isPopupOpen.set(true);
45
+ }}
46
+ on:mouseleave={() => {
47
+ isPopupOpen.set(false);
48
+ }}
49
+ >
50
+ {#if iconName}
51
+ <Icon name={iconName} label={iconLabel} />
52
+ {/if}
53
+ {#if label}
54
+ <span class="label">{label}</span>
55
+ {/if}
56
+ {#if role === 'menuitemradio' || role === 'menuitemcheckbox'}
57
+ <span class="icon-outer">
58
+ {#if checked}
59
+ <Icon name="check" />
60
+ {/if}
61
+ </span>
62
+ {/if}
63
+ {#if hasChildren}
64
+ <span class="icon-outer">
65
+ <Icon name="chevron_right" />
66
+ </span>
67
+ {/if}
68
+ </Button>
69
+ {#if hasChildren}
70
+ <Popup anchor={buttonComponent?.element} position="right-top" bind:open={isPopupOpen}>
71
+ <Menu>
72
+ <slot />
73
+ </Menu>
74
+ </Popup>
75
+ {/if}
76
+ </div>
77
+
78
+ <style>.menuitem {
79
+ position: relative;
80
+ }
81
+ .menuitem :global(button) {
82
+ display: flex;
83
+ justify-content: space-between !important;
84
+ border-radius: 4px;
85
+ padding: 0 16px;
86
+ width: 100%;
87
+ min-width: 160px;
88
+ height: var(--option--medium--height);
89
+ }
90
+ .menuitem :global(button[aria-checked="true"]) :global(.icon) {
91
+ color: var(--primary-accent-color-lighter);
92
+ }
93
+ .menuitem :global(button:hover),
94
+ .menuitem :global(button:focus) {
95
+ color: var(--highlight-foreground-color);
96
+ background-color: var(--highlight-background-color);
97
+ }
98
+ .menuitem:hover > :global([role="menu"]) {
99
+ opacity: 1;
100
+ }
101
+ .menuitem > :global([role="menu"]) {
102
+ position: absolute;
103
+ inset: 2px auto auto calc(100% + 4px);
104
+ }
105
+ .menuitem > :global([role="menu"]):hover {
106
+ opacity: 1;
107
+ }
108
+
109
+ .icon-outer {
110
+ flex: none;
111
+ width: 24px;
112
+ height: 24px;
113
+ }</style>
@@ -0,0 +1,44 @@
1
+ /** @typedef {typeof __propDef.props} MenuItemProps */
2
+ /** @typedef {typeof __propDef.events} MenuItemEvents */
3
+ /** @typedef {typeof __propDef.slots} MenuItemSlots */
4
+ /** @see https://w3c.github.io/aria/#menuitem */
5
+ export default class MenuItem extends SvelteComponentTyped<{
6
+ [x: string]: any;
7
+ class?: string;
8
+ label?: string;
9
+ role?: "menuitem" | "menuitemcheckbox" | "menuitemradio";
10
+ iconName?: string;
11
+ iconLabel?: string;
12
+ checked?: boolean;
13
+ }, {
14
+ click: MouseEvent;
15
+ } & {
16
+ [evt: string]: CustomEvent<any>;
17
+ }, {
18
+ default: {};
19
+ }> {
20
+ }
21
+ export type MenuItemProps = typeof __propDef.props;
22
+ export type MenuItemEvents = typeof __propDef.events;
23
+ export type MenuItemSlots = typeof __propDef.slots;
24
+ import { SvelteComponentTyped } from "svelte";
25
+ declare const __propDef: {
26
+ props: {
27
+ [x: string]: any;
28
+ class?: string;
29
+ label?: string;
30
+ role?: ('menuitem' | 'menuitemcheckbox' | 'menuitemradio');
31
+ iconName?: string;
32
+ iconLabel?: string;
33
+ checked?: boolean;
34
+ };
35
+ events: {
36
+ click: MouseEvent;
37
+ } & {
38
+ [evt: string]: CustomEvent<any>;
39
+ };
40
+ slots: {
41
+ default: {};
42
+ };
43
+ };
44
+ export {};
@@ -0,0 +1,109 @@
1
+ <!--
2
+ @component
3
+ @see https://w3c.github.io/aria/#textbox
4
+ -->
5
+ <script>
6
+ import { _ } from 'svelte-i18n';
7
+ import Button from './button.svelte';
8
+ import TextInput from './text-input.svelte';
9
+
10
+ /**
11
+ * CSS class name on the button.
12
+ * @type {String}
13
+ */
14
+ let className = '';
15
+
16
+ export { className as class };
17
+
18
+ /** @type {(String|undefined)} */
19
+ export let value = undefined;
20
+
21
+ export let min = undefined;
22
+ export let max = undefined;
23
+ export let step = 1;
24
+
25
+ let component;
26
+
27
+ const decrease = () => {
28
+ if (typeof min === 'number' && Number(value || 0) === min) {
29
+ return;
30
+ }
31
+
32
+ value = String(Number(value || 0) - step);
33
+ };
34
+
35
+ const increase = () => {
36
+ if (typeof min === 'number' && Number(value || 0) === max) {
37
+ return;
38
+ }
39
+
40
+ value = String(Number(value || 0) + step);
41
+ };
42
+ </script>
43
+
44
+ <div class="sui number-input {className}">
45
+ <TextInput
46
+ bind:this={component}
47
+ bind:value
48
+ role="spinbutton"
49
+ aria-valuenow={Number(value || 0)}
50
+ aria-invalid={Number.isNaN(Number(value))}
51
+ {...$$restProps}
52
+ on:keydown={(event) => {
53
+ const { key, ctrlKey, metaKey, altKey, shiftKey } = event;
54
+
55
+ if (key === 'ArrowDown' && !ctrlKey && !metaKey && !altKey && !shiftKey) {
56
+ event.preventDefault();
57
+ decrease();
58
+ }
59
+
60
+ if (key === 'ArrowUp' && !ctrlKey && !metaKey && !altKey && !shiftKey) {
61
+ event.preventDefault();
62
+ increase();
63
+ }
64
+ }}
65
+ on:keypress
66
+ on:input
67
+ />
68
+ <Button
69
+ class="iconic"
70
+ disabled={Number.isNaN(Number(value))}
71
+ iconLabel={$_('sui.number_input.decrease')}
72
+ iconName={'arrow_downward'}
73
+ on:click={() => {
74
+ decrease();
75
+ }}
76
+ />
77
+ <Button
78
+ class="iconic"
79
+ disabled={Number.isNaN(Number(value))}
80
+ iconLabel={$_('sui.number_input.increase')}
81
+ iconName={'arrow_upward'}
82
+ on:click={() => {
83
+ increase();
84
+ }}
85
+ />
86
+ </div>
87
+
88
+ <style>.number-input {
89
+ width: 100%;
90
+ display: inline-flex;
91
+ align-items: center;
92
+ }
93
+ .number-input :global(input) {
94
+ border-radius: 4px 0 0 4px;
95
+ }
96
+ .number-input :global(button) {
97
+ flex: none;
98
+ margin-left: -1px;
99
+ border-width: 1px;
100
+ border-color: var(--control-border-color);
101
+ width: 32px;
102
+ height: var(--input--medium--height);
103
+ }
104
+ .number-input :global(button):last-child {
105
+ border-radius: 0 4px 4px 0;
106
+ }
107
+ .number-input :global(button) :global(.icon) {
108
+ font-size: 20px;
109
+ }</style>
@@ -0,0 +1,40 @@
1
+ /** @typedef {typeof __propDef.props} NumberInputProps */
2
+ /** @typedef {typeof __propDef.events} NumberInputEvents */
3
+ /** @typedef {typeof __propDef.slots} NumberInputSlots */
4
+ /** @see https://w3c.github.io/aria/#textbox */
5
+ export default class NumberInput extends SvelteComponentTyped<{
6
+ [x: string]: any;
7
+ class?: string;
8
+ value?: string;
9
+ min?: any;
10
+ max?: any;
11
+ step?: number;
12
+ }, {
13
+ keypress: KeyboardEvent;
14
+ input: Event;
15
+ } & {
16
+ [evt: string]: CustomEvent<any>;
17
+ }, {}> {
18
+ }
19
+ export type NumberInputProps = typeof __propDef.props;
20
+ export type NumberInputEvents = typeof __propDef.events;
21
+ export type NumberInputSlots = typeof __propDef.slots;
22
+ import { SvelteComponentTyped } from "svelte";
23
+ declare const __propDef: {
24
+ props: {
25
+ [x: string]: any;
26
+ class?: string;
27
+ value?: (string | undefined);
28
+ min?: any;
29
+ max?: any;
30
+ step?: number;
31
+ };
32
+ events: {
33
+ keypress: KeyboardEvent;
34
+ input: Event;
35
+ } & {
36
+ [evt: string]: CustomEvent<any>;
37
+ };
38
+ slots: {};
39
+ };
40
+ export {};
@@ -0,0 +1,57 @@
1
+ <!--
2
+ @component
3
+ @see https://w3c.github.io/aria/#option
4
+ -->
5
+ <script>
6
+ import Button from './button.svelte';
7
+ import Icon from './icon.svelte';
8
+
9
+ /**
10
+ * CSS class name on the button.
11
+ * @type {String}
12
+ */
13
+ let className = '';
14
+
15
+ export { className as class };
16
+
17
+ export let selected = false;
18
+ </script>
19
+
20
+ <div class="sui option {className}">
21
+ <Button
22
+ role="option"
23
+ aria-selected={selected}
24
+ {...$$restProps}
25
+ on:click
26
+ on:dragover
27
+ on:dragleave
28
+ on:dragend
29
+ on:drop
30
+ >
31
+ <slot />
32
+ {#if selected}
33
+ <Icon class="check" name="check" />
34
+ {/if}
35
+ </Button>
36
+ </div>
37
+
38
+ <style>.option {
39
+ display: contents;
40
+ }
41
+ .option :global([role="option"]) {
42
+ flex: none;
43
+ display: flex;
44
+ justify-content: space-between;
45
+ gap: 4px;
46
+ border-radius: 4px;
47
+ padding: 0 8px 0 16px;
48
+ width: 100%;
49
+ height: var(--option--medium--height);
50
+ }
51
+ .option :global([role="option"]:hover) {
52
+ color: var(--highlight-foreground-color);
53
+ background-color: var(--highlight-background-color);
54
+ }
55
+ .option :global([role="option"][aria-selected="true"]) :global(.icon) {
56
+ color: var(--primary-accent-color-lighter);
57
+ }</style>
@@ -0,0 +1,44 @@
1
+ /** @typedef {typeof __propDef.props} OptionProps */
2
+ /** @typedef {typeof __propDef.events} OptionEvents */
3
+ /** @typedef {typeof __propDef.slots} OptionSlots */
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
+ }> {
20
+ }
21
+ export type OptionProps = typeof __propDef.props;
22
+ export type OptionEvents = typeof __propDef.events;
23
+ export type OptionSlots = typeof __propDef.slots;
24
+ import { SvelteComponentTyped } from "svelte";
25
+ declare const __propDef: {
26
+ props: {
27
+ [x: string]: any;
28
+ class?: string;
29
+ selected?: boolean;
30
+ };
31
+ events: {
32
+ click: MouseEvent;
33
+ dragover: DragEvent;
34
+ dragleave: DragEvent;
35
+ dragend: DragEvent;
36
+ drop: DragEvent;
37
+ } & {
38
+ [evt: string]: CustomEvent<any>;
39
+ };
40
+ slots: {
41
+ default: {};
42
+ };
43
+ };
44
+ export {};
@@ -0,0 +1,76 @@
1
+ <!--
2
+ @component
3
+ @see https://w3c.github.io/aria/#textbox
4
+ -->
5
+ <script>
6
+ import { _ } from 'svelte-i18n';
7
+ import Button from './button.svelte';
8
+ import TextInput from './text-input.svelte';
9
+
10
+ /**
11
+ * CSS class name on the button.
12
+ * @type {String}
13
+ */
14
+ let className = '';
15
+
16
+ export { className as class };
17
+
18
+ /** @type {(String|undefined)} */
19
+ export let value = undefined;
20
+
21
+ /**
22
+ * @type {TextInput}
23
+ */
24
+ let inputComponent;
25
+ let passwordVisible = false;
26
+
27
+ $: {
28
+ if (inputComponent) {
29
+ inputComponent.element.setAttribute('type', passwordVisible ? 'text' : 'password');
30
+ }
31
+ }
32
+ </script>
33
+
34
+ <div class="sui password-input {className}">
35
+ <TextInput
36
+ bind:this={inputComponent}
37
+ bind:value
38
+ type="password"
39
+ {...$$restProps}
40
+ on:input
41
+ on:keypress
42
+ on:change
43
+ />
44
+ <Button
45
+ class="iconic"
46
+ pressed={passwordVisible}
47
+ iconLabel={$_('sui.password_input.show_password')}
48
+ iconName={passwordVisible ? 'visibility_off' : 'visibility'}
49
+ on:click={() => {
50
+ passwordVisible = !passwordVisible;
51
+ }}
52
+ />
53
+ </div>
54
+
55
+ <style>.password-input {
56
+ width: 100%;
57
+ display: inline-flex;
58
+ align-items: center;
59
+ }
60
+ .password-input :global(input) {
61
+ border-radius: 4px 0 0 4px;
62
+ }
63
+ .password-input :global(button) {
64
+ flex: none;
65
+ margin-left: -1px;
66
+ border-width: 1px;
67
+ border-color: var(--control-border-color);
68
+ height: var(--input--medium--height);
69
+ aspect-ratio: 1/1;
70
+ }
71
+ .password-input :global(button):last-child {
72
+ border-radius: 0 4px 4px 0;
73
+ }
74
+ .password-input :global(button) :global(.icon) {
75
+ font-size: 20px;
76
+ }</style>
@@ -0,0 +1,36 @@
1
+ /** @typedef {typeof __propDef.props} PasswordInputProps */
2
+ /** @typedef {typeof __propDef.events} PasswordInputEvents */
3
+ /** @typedef {typeof __propDef.slots} PasswordInputSlots */
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
+ }, {}> {
16
+ }
17
+ export type PasswordInputProps = typeof __propDef.props;
18
+ export type PasswordInputEvents = typeof __propDef.events;
19
+ export type PasswordInputSlots = typeof __propDef.slots;
20
+ import { SvelteComponentTyped } from "svelte";
21
+ declare const __propDef: {
22
+ props: {
23
+ [x: string]: any;
24
+ class?: string;
25
+ value?: (string | undefined);
26
+ };
27
+ events: {
28
+ input: Event;
29
+ keypress: KeyboardEvent;
30
+ change: Event;
31
+ } & {
32
+ [evt: string]: CustomEvent<any>;
33
+ };
34
+ slots: {};
35
+ };
36
+ export {};
@@ -0,0 +1,91 @@
1
+ <!--
2
+ @component
3
+ @see https://w3c.github.io/aria/#radio
4
+ @see https://w3c.github.io/aria-practices/#radiobutton
5
+ -->
6
+ <script>
7
+ import { getRandomId } from '../helpers/util';
8
+ import Button from './button.svelte';
9
+
10
+ /**
11
+ * CSS class name on the button.
12
+ * @type {String}
13
+ */
14
+ let className = '';
15
+
16
+ export { className as class };
17
+
18
+ /** @type {String} */
19
+ export let name = '';
20
+
21
+ /** @type {(String|undefined)} */
22
+ export let value = undefined;
23
+
24
+ /** @type {Boolean} */
25
+ export let selected = false;
26
+
27
+ const id = getRandomId('checkbox');
28
+ /** @type {Button} */
29
+ let buttonComponent;
30
+ </script>
31
+
32
+ {#if name && value && selected}
33
+ <input type="hidden" {name} {value} />
34
+ {/if}
35
+
36
+ <!-- svelte-ignore a11y-click-events-have-key-events -->
37
+ <span
38
+ class="sui radio-button {className}"
39
+ on:click={(event) => {
40
+ if (!event.target.matches('button')) {
41
+ buttonComponent.element.click();
42
+ }
43
+ }}
44
+ >
45
+ <Button
46
+ {id}
47
+ iconName="circle"
48
+ role="radio"
49
+ aria-checked={selected}
50
+ aria-labelledby="{id}-label"
51
+ bind:this={buttonComponent}
52
+ on:click={(event) => {
53
+ event.preventDefault();
54
+ selected = !selected;
55
+ }}
56
+ />
57
+ <label id="{id}-label">
58
+ <slot />
59
+ </label>
60
+ </span>
61
+
62
+ <style>.radio-button {
63
+ display: inline-flex;
64
+ align-items: center;
65
+ gap: 8px;
66
+ color: inherit;
67
+ cursor: pointer;
68
+ -webkit-user-select: none;
69
+ user-select: none;
70
+ }
71
+ .radio-button :global(button) {
72
+ justify-content: center;
73
+ overflow: hidden;
74
+ border-width: 2px;
75
+ border-color: var(--control-border-color);
76
+ border-radius: 24px;
77
+ width: 24px;
78
+ height: 24px;
79
+ color: var(--primary-accent-color-lighter);
80
+ transition: all 200ms;
81
+ }
82
+ .radio-button :global(button) :global(.icon) {
83
+ font-size: 16px;
84
+ font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 48;
85
+ }
86
+ .radio-button :global(button[aria-checked="true"]) {
87
+ color: var(--primary-accent-color-lighter);
88
+ }
89
+ .radio-button :global(button[aria-checked="false"]) {
90
+ color: transparent;
91
+ }</style>
@@ -0,0 +1,37 @@
1
+ /** @typedef {typeof __propDef.props} RadioButtonProps */
2
+ /** @typedef {typeof __propDef.events} RadioButtonEvents */
3
+ /** @typedef {typeof __propDef.slots} RadioButtonSlots */
4
+ /**
5
+ * @see https://w3c.github.io/aria/#radio
6
+ * @see https://w3c.github.io/aria-practices/#radiobutton
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
+ }> {
18
+ }
19
+ export type RadioButtonProps = typeof __propDef.props;
20
+ export type RadioButtonEvents = typeof __propDef.events;
21
+ export type RadioButtonSlots = typeof __propDef.slots;
22
+ import { SvelteComponentTyped } from "svelte";
23
+ declare const __propDef: {
24
+ props: {
25
+ class?: string;
26
+ name?: string;
27
+ value?: (string | undefined);
28
+ selected?: boolean;
29
+ };
30
+ events: {
31
+ [evt: string]: CustomEvent<any>;
32
+ };
33
+ slots: {
34
+ default: {};
35
+ };
36
+ };
37
+ export {};
@@ -0,0 +1,14 @@
1
+ <script>
2
+ /**
3
+ * CSS class name on the button.
4
+ * @type {String}
5
+ */
6
+ // eslint-disable-next-line padding-line-between-statements
7
+ let className = 'tbody';
8
+
9
+ export { className as class };
10
+ </script>
11
+
12
+ <div role="rowgroup" class="sui row-group {className}" {...$$restProps}>
13
+ <slot />
14
+ </div>