@sveltia/ui 0.2.0 → 0.2.2
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.
- package/package/components/composite/calendar.svelte +239 -0
- package/package/components/composite/calendar.svelte.d.ts +27 -0
- package/package/components/composite/checkbox-group.svelte +43 -0
- package/package/components/composite/checkbox-group.svelte.d.ts +34 -0
- package/package/components/composite/combobox.svelte +208 -0
- package/package/components/composite/combobox.svelte.d.ts +47 -0
- package/package/components/composite/disclosure.svelte +60 -0
- package/package/components/composite/disclosure.svelte.d.ts +35 -0
- package/package/components/composite/grid.svelte +24 -0
- package/package/components/composite/grid.svelte.d.ts +31 -0
- package/package/components/composite/listbox.svelte +63 -0
- package/package/components/composite/listbox.svelte.d.ts +52 -0
- package/package/components/composite/menu-item-group.svelte +31 -0
- package/package/components/composite/menu-item-group.svelte.d.ts +33 -0
- package/package/components/composite/menu.svelte +44 -0
- package/package/components/composite/menu.svelte.d.ts +41 -0
- package/package/components/composite/radio-button-group.svelte +45 -0
- package/package/components/composite/radio-button-group.svelte.d.ts +36 -0
- package/package/components/composite/select-button-group.svelte +71 -0
- package/package/components/composite/select-button-group.svelte.d.ts +44 -0
- package/package/components/composite/select.svelte +34 -0
- package/package/components/composite/select.svelte.d.ts +38 -0
- package/package/components/composite/tab-list.svelte +76 -0
- package/package/components/composite/tab-list.svelte.d.ts +55 -0
- package/package/components/core/button.svelte +222 -0
- package/package/components/core/button.svelte.d.ts +109 -0
- package/package/components/core/checkbox.svelte +114 -0
- package/package/components/core/checkbox.svelte.d.ts +45 -0
- package/package/components/core/dialog.svelte +288 -0
- package/package/components/core/dialog.svelte.d.ts +73 -0
- package/package/components/core/drawer.svelte +338 -0
- package/package/components/core/drawer.svelte.d.ts +59 -0
- package/package/components/core/grid-cell.svelte +14 -0
- package/package/components/core/grid-cell.svelte.d.ts +29 -0
- package/package/components/core/group.svelte +31 -0
- package/package/components/core/group.svelte.d.ts +33 -0
- package/package/components/core/icon.svelte +21 -0
- package/package/components/core/icon.svelte.d.ts +27 -0
- package/package/components/core/menu-button.svelte +57 -0
- package/package/components/core/menu-button.svelte.d.ts +46 -0
- package/package/components/core/menu-item-checkbox.svelte +24 -0
- package/package/components/core/menu-item-checkbox.svelte.d.ts +34 -0
- package/package/components/core/menu-item-radio.svelte +19 -0
- package/package/components/core/menu-item-radio.svelte.d.ts +34 -0
- package/package/components/core/menu-item.svelte +113 -0
- package/package/components/core/menu-item.svelte.d.ts +44 -0
- package/package/components/core/number-input.svelte +112 -0
- package/package/components/core/number-input.svelte.d.ts +42 -0
- package/package/components/core/option.svelte +65 -0
- package/package/components/core/option.svelte.d.ts +60 -0
- package/package/components/core/password-input.svelte +81 -0
- package/package/components/core/password-input.svelte.d.ts +36 -0
- package/package/components/core/radio-button.svelte +93 -0
- package/package/components/core/radio-button.svelte.d.ts +37 -0
- package/package/components/core/row-group.svelte +14 -0
- package/package/components/core/row-group.svelte.d.ts +29 -0
- package/package/components/core/row.svelte +14 -0
- package/package/components/core/row.svelte.d.ts +33 -0
- package/package/components/core/search-bar.svelte +91 -0
- package/package/components/core/search-bar.svelte.d.ts +49 -0
- package/package/components/core/select-button.svelte +31 -0
- package/package/components/core/select-button.svelte.d.ts +52 -0
- package/package/components/core/separator.svelte +28 -0
- package/package/components/core/separator.svelte.d.ts +26 -0
- package/package/components/core/slider.svelte +271 -0
- package/package/components/core/slider.svelte.d.ts +51 -0
- package/package/components/core/spacer.svelte +22 -0
- package/package/components/core/spacer.svelte.d.ts +25 -0
- package/package/components/core/switch.svelte +86 -0
- package/package/components/core/switch.svelte.d.ts +37 -0
- package/package/components/core/tab-panel.svelte +23 -0
- package/package/components/core/tab-panel.svelte.d.ts +33 -0
- package/package/components/core/tab.svelte +22 -0
- package/package/components/core/tab.svelte.d.ts +45 -0
- package/package/components/core/text-area.svelte +90 -0
- package/package/components/core/text-area.svelte.d.ts +57 -0
- package/package/components/core/text-input.svelte +146 -0
- package/package/components/core/text-input.svelte.d.ts +71 -0
- package/package/components/core/toolbar.svelte +74 -0
- package/package/components/core/toolbar.svelte.d.ts +35 -0
- package/package/components/editor/markdown.svelte +78 -0
- package/package/components/editor/markdown.svelte.d.ts +25 -0
- package/package/components/helpers/group.d.ts +37 -0
- package/package/components/helpers/group.js +246 -0
- package/package/components/helpers/popup.d.ts +31 -0
- package/package/components/helpers/popup.js +165 -0
- package/package/components/helpers/util.d.ts +1 -0
- package/package/components/helpers/util.js +8 -0
- package/package/components/util/app-shell.svelte +354 -0
- package/package/components/util/app-shell.svelte.d.ts +38 -0
- package/package/components/util/misc.d.ts +2 -0
- package/package/components/util/misc.js +22 -0
- package/package/components/util/popup.svelte +155 -0
- package/package/components/util/popup.svelte.d.ts +53 -0
- package/package/components/util/portal.svelte +34 -0
- package/package/components/util/portal.svelte.d.ts +28 -0
- package/package/index.d.ts +43 -0
- package/package/index.js +68 -0
- package/package/locales/en.d.ts +42 -0
- package/package/locales/en.js +41 -0
- package/package/locales/ja.d.ts +42 -0
- package/package/locales/ja.js +41 -0
- package/package/styles/core.scss +134 -0
- package/package/styles/variables.scss +184 -0
- package/package/typedef.d.ts +0 -0
- package/package/typedef.js +0 -0
- package/package.json +2 -3
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
@see https://w3c.github.io/aria/#switch
|
|
4
|
+
@see https://w3c.github.io/aria-practices/#switch
|
|
5
|
+
-->
|
|
6
|
+
<script>
|
|
7
|
+
/**
|
|
8
|
+
* CSS class name on the button.
|
|
9
|
+
* @type {String}
|
|
10
|
+
*/
|
|
11
|
+
let className = '';
|
|
12
|
+
|
|
13
|
+
export { className as class };
|
|
14
|
+
|
|
15
|
+
export let label = '';
|
|
16
|
+
|
|
17
|
+
export let checked = false;
|
|
18
|
+
|
|
19
|
+
export let disabled = false;
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<label class="sui switch {className}" class:disabled>
|
|
23
|
+
<input type="checkbox" role="switch" bind:checked {disabled} />
|
|
24
|
+
<span />
|
|
25
|
+
{#if label}
|
|
26
|
+
{label}
|
|
27
|
+
{:else}
|
|
28
|
+
<slot />
|
|
29
|
+
{/if}
|
|
30
|
+
</label>
|
|
31
|
+
|
|
32
|
+
<style>label {
|
|
33
|
+
display: inline-flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
gap: 8px;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
-webkit-user-select: none;
|
|
38
|
+
user-select: none;
|
|
39
|
+
}
|
|
40
|
+
label.disabled {
|
|
41
|
+
cursor: default;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
input {
|
|
45
|
+
position: absolute;
|
|
46
|
+
left: -99999px;
|
|
47
|
+
}
|
|
48
|
+
input:focus + span {
|
|
49
|
+
background-color: var(--highlight-background-color);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
input:checked + span {
|
|
53
|
+
background-color: var(--primary-accent-color);
|
|
54
|
+
border-color: transparent;
|
|
55
|
+
}
|
|
56
|
+
input:checked + span::before {
|
|
57
|
+
transform: translateX(22px);
|
|
58
|
+
background-color: var(--primary-accent-color-foreground);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
input:disabled + span {
|
|
62
|
+
opacity: 0.4;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
span {
|
|
66
|
+
position: relative;
|
|
67
|
+
width: 42px;
|
|
68
|
+
height: 20px;
|
|
69
|
+
padding: 2px;
|
|
70
|
+
display: inline-block;
|
|
71
|
+
border-radius: 16px;
|
|
72
|
+
background-color: var(--control-border-color);
|
|
73
|
+
transition: all 200ms;
|
|
74
|
+
}
|
|
75
|
+
span:hover {
|
|
76
|
+
background-color: var(--highlight-background-color);
|
|
77
|
+
}
|
|
78
|
+
span::before {
|
|
79
|
+
display: inline-block;
|
|
80
|
+
width: 16px;
|
|
81
|
+
height: 16px;
|
|
82
|
+
border-radius: 16px;
|
|
83
|
+
background-color: var(--primary-accent-color-foreground);
|
|
84
|
+
transition: all 200ms;
|
|
85
|
+
content: "";
|
|
86
|
+
}</style>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} SwitchProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} SwitchEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} SwitchSlots */
|
|
4
|
+
/**
|
|
5
|
+
* @see https://w3c.github.io/aria/#switch
|
|
6
|
+
* @see https://w3c.github.io/aria-practices/#switch
|
|
7
|
+
*/
|
|
8
|
+
export default class Switch extends SvelteComponentTyped<{
|
|
9
|
+
label?: string;
|
|
10
|
+
class?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
checked?: boolean;
|
|
13
|
+
}, {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
}, {
|
|
16
|
+
default: {};
|
|
17
|
+
}> {
|
|
18
|
+
}
|
|
19
|
+
export type SwitchProps = typeof __propDef.props;
|
|
20
|
+
export type SwitchEvents = typeof __propDef.events;
|
|
21
|
+
export type SwitchSlots = typeof __propDef.slots;
|
|
22
|
+
import { SvelteComponentTyped } from "svelte";
|
|
23
|
+
declare const __propDef: {
|
|
24
|
+
props: {
|
|
25
|
+
label?: string;
|
|
26
|
+
class?: string;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
checked?: boolean;
|
|
29
|
+
};
|
|
30
|
+
events: {
|
|
31
|
+
[evt: string]: CustomEvent<any>;
|
|
32
|
+
};
|
|
33
|
+
slots: {
|
|
34
|
+
default: {};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
@see https://w3c.github.io/aria/#tabpanel
|
|
4
|
+
@see https://w3c.github.io/aria-practices/#tabpanel
|
|
5
|
+
-->
|
|
6
|
+
<script>
|
|
7
|
+
/**
|
|
8
|
+
* CSS class name on the button.
|
|
9
|
+
* @type {String}
|
|
10
|
+
*/
|
|
11
|
+
// eslint-disable-next-line padding-line-between-statements
|
|
12
|
+
let className = '';
|
|
13
|
+
|
|
14
|
+
export { className as class };
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<div class="sui tabpanel {className}" role="tabpanel" {...$$restProps}>
|
|
18
|
+
<slot />
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<style>.tabpanel[aria-hidden=true], .tabpanel:not([aria-hidden]) {
|
|
22
|
+
display: none;
|
|
23
|
+
}</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} TabPanelProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} TabPanelEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} TabPanelSlots */
|
|
4
|
+
/**
|
|
5
|
+
* @see https://w3c.github.io/aria/#tabpanel
|
|
6
|
+
* @see https://w3c.github.io/aria-practices/#tabpanel
|
|
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
|
+
}> {
|
|
16
|
+
}
|
|
17
|
+
export type TabPanelProps = typeof __propDef.props;
|
|
18
|
+
export type TabPanelEvents = typeof __propDef.events;
|
|
19
|
+
export type TabPanelSlots = typeof __propDef.slots;
|
|
20
|
+
import { SvelteComponentTyped } from "svelte";
|
|
21
|
+
declare const __propDef: {
|
|
22
|
+
props: {
|
|
23
|
+
[x: string]: any;
|
|
24
|
+
class?: string;
|
|
25
|
+
};
|
|
26
|
+
events: {
|
|
27
|
+
[evt: string]: CustomEvent<any>;
|
|
28
|
+
};
|
|
29
|
+
slots: {
|
|
30
|
+
default: {};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
@see https://w3c.github.io/aria/#tab
|
|
4
|
+
@see https://w3c.github.io/aria-practices/#tabpanel
|
|
5
|
+
-->
|
|
6
|
+
<script>
|
|
7
|
+
import Button from './button.svelte';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* CSS class name on the button.
|
|
11
|
+
* @type {String}
|
|
12
|
+
*/
|
|
13
|
+
let className = '';
|
|
14
|
+
|
|
15
|
+
export { className as class };
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<Button role="tab" class="sui tab {className}" {...$$restProps}>
|
|
19
|
+
<slot name="start-icon" slot="start-icon" />
|
|
20
|
+
<slot />
|
|
21
|
+
<slot name="end-icon" slot="end-icon" />
|
|
22
|
+
</Button>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} TabProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} TabEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} TabSlots */
|
|
4
|
+
/**
|
|
5
|
+
* @see https://w3c.github.io/aria/#tab
|
|
6
|
+
* @see https://w3c.github.io/aria-practices/#tabpanel
|
|
7
|
+
*/
|
|
8
|
+
export default class Tab extends SvelteComponentTyped<{
|
|
9
|
+
[x: string]: any;
|
|
10
|
+
class?: string;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {
|
|
14
|
+
'start-icon': {
|
|
15
|
+
slot: string;
|
|
16
|
+
};
|
|
17
|
+
default: {};
|
|
18
|
+
'end-icon': {
|
|
19
|
+
slot: string;
|
|
20
|
+
};
|
|
21
|
+
}> {
|
|
22
|
+
}
|
|
23
|
+
export type TabProps = typeof __propDef.props;
|
|
24
|
+
export type TabEvents = typeof __propDef.events;
|
|
25
|
+
export type TabSlots = typeof __propDef.slots;
|
|
26
|
+
import { SvelteComponentTyped } from "svelte";
|
|
27
|
+
declare const __propDef: {
|
|
28
|
+
props: {
|
|
29
|
+
[x: string]: any;
|
|
30
|
+
class?: string;
|
|
31
|
+
};
|
|
32
|
+
events: {
|
|
33
|
+
[evt: string]: CustomEvent<any>;
|
|
34
|
+
};
|
|
35
|
+
slots: {
|
|
36
|
+
'start-icon': {
|
|
37
|
+
slot: string;
|
|
38
|
+
};
|
|
39
|
+
default: {};
|
|
40
|
+
'end-icon': {
|
|
41
|
+
slot: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
@see https://w3c.github.io/aria/#textbox
|
|
4
|
+
-->
|
|
5
|
+
<svelte:options accessors={true} />
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
/**
|
|
9
|
+
* CSS class name on the button.
|
|
10
|
+
* @type {String}
|
|
11
|
+
*/
|
|
12
|
+
// eslint-disable-next-line padding-line-between-statements
|
|
13
|
+
let className = '';
|
|
14
|
+
|
|
15
|
+
export { className as class };
|
|
16
|
+
|
|
17
|
+
/** @type {(HTMLTextAreaElement|undefined)} */
|
|
18
|
+
export let element = undefined;
|
|
19
|
+
|
|
20
|
+
export let name = '';
|
|
21
|
+
|
|
22
|
+
/** @type {(String|undefined)} */
|
|
23
|
+
export let value = undefined;
|
|
24
|
+
|
|
25
|
+
export let autoResize = false;
|
|
26
|
+
|
|
27
|
+
/** @type {(String|undefined)} */
|
|
28
|
+
let height;
|
|
29
|
+
|
|
30
|
+
const resizeTextarea = () => {
|
|
31
|
+
height = 'auto';
|
|
32
|
+
|
|
33
|
+
window.requestAnimationFrame(() => {
|
|
34
|
+
height = value && element?.scrollHeight ? `${element.scrollHeight + 4}px` : undefined;
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
$: {
|
|
39
|
+
if (value && autoResize) {
|
|
40
|
+
resizeTextarea();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<div class="sui text-area {className}">
|
|
46
|
+
<textarea
|
|
47
|
+
name={name || undefined}
|
|
48
|
+
{...$$restProps}
|
|
49
|
+
style:height
|
|
50
|
+
bind:this={element}
|
|
51
|
+
on:click
|
|
52
|
+
on:input
|
|
53
|
+
on:keypress
|
|
54
|
+
on:input={() => {
|
|
55
|
+
value = element.value;
|
|
56
|
+
}}>{value}</textarea
|
|
57
|
+
>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<style>.text-area {
|
|
61
|
+
width: 100%;
|
|
62
|
+
display: inline-flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
textarea {
|
|
67
|
+
display: block;
|
|
68
|
+
margin: 0;
|
|
69
|
+
border-width: 1px;
|
|
70
|
+
border-color: var(--control-border-color);
|
|
71
|
+
border-radius: var(--input--medium--border-radius);
|
|
72
|
+
background-color: var(--control-background-color);
|
|
73
|
+
padding: 8px;
|
|
74
|
+
width: 100%;
|
|
75
|
+
min-height: 8em;
|
|
76
|
+
color: inherit;
|
|
77
|
+
font-family: inherit;
|
|
78
|
+
font-size: inherit;
|
|
79
|
+
line-height: 1.75;
|
|
80
|
+
resize: vertical;
|
|
81
|
+
transition: all 200ms;
|
|
82
|
+
}
|
|
83
|
+
textarea:focus {
|
|
84
|
+
border-color: var(--primary-accent-color);
|
|
85
|
+
}
|
|
86
|
+
textarea:disabled {
|
|
87
|
+
background-color: var(--disabled-background-color);
|
|
88
|
+
opacity: 0.4;
|
|
89
|
+
cursor: default;
|
|
90
|
+
}</style>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} TextAreaProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} TextAreaEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} TextAreaSlots */
|
|
4
|
+
/** @see https://w3c.github.io/aria/#textbox */
|
|
5
|
+
export default class TextArea extends SvelteComponentTyped<{
|
|
6
|
+
[x: string]: any;
|
|
7
|
+
class?: string;
|
|
8
|
+
element?: HTMLTextAreaElement;
|
|
9
|
+
name?: string;
|
|
10
|
+
value?: string;
|
|
11
|
+
autoResize?: boolean;
|
|
12
|
+
}, {
|
|
13
|
+
click: MouseEvent;
|
|
14
|
+
input: Event;
|
|
15
|
+
keypress: KeyboardEvent;
|
|
16
|
+
} & {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
}, {}> {
|
|
19
|
+
/**accessor*/
|
|
20
|
+
set class(arg: string);
|
|
21
|
+
get class(): string;
|
|
22
|
+
/**accessor*/
|
|
23
|
+
set element(arg: HTMLTextAreaElement);
|
|
24
|
+
get element(): HTMLTextAreaElement;
|
|
25
|
+
/**accessor*/
|
|
26
|
+
set name(arg: string);
|
|
27
|
+
get name(): string;
|
|
28
|
+
/**accessor*/
|
|
29
|
+
set value(arg: string);
|
|
30
|
+
get value(): string;
|
|
31
|
+
/**accessor*/
|
|
32
|
+
set autoResize(arg: boolean);
|
|
33
|
+
get autoResize(): boolean;
|
|
34
|
+
}
|
|
35
|
+
export type TextAreaProps = typeof __propDef.props;
|
|
36
|
+
export type TextAreaEvents = typeof __propDef.events;
|
|
37
|
+
export type TextAreaSlots = typeof __propDef.slots;
|
|
38
|
+
import { SvelteComponentTyped } from "svelte";
|
|
39
|
+
declare const __propDef: {
|
|
40
|
+
props: {
|
|
41
|
+
[x: string]: any;
|
|
42
|
+
class?: string;
|
|
43
|
+
element?: (HTMLTextAreaElement | undefined);
|
|
44
|
+
name?: string;
|
|
45
|
+
value?: (string | undefined);
|
|
46
|
+
autoResize?: boolean;
|
|
47
|
+
};
|
|
48
|
+
events: {
|
|
49
|
+
click: MouseEvent;
|
|
50
|
+
input: Event;
|
|
51
|
+
keypress: KeyboardEvent;
|
|
52
|
+
} & {
|
|
53
|
+
[evt: string]: CustomEvent<any>;
|
|
54
|
+
};
|
|
55
|
+
slots: {};
|
|
56
|
+
};
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
@see https://w3c.github.io/aria/#textbox
|
|
4
|
+
-->
|
|
5
|
+
<svelte:options accessors={true} />
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import { getRandomId } from '../helpers/util';
|
|
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 {(HTMLInputElement|undefined)} */
|
|
19
|
+
export let element = undefined;
|
|
20
|
+
|
|
21
|
+
/** @type {('textbox'|'searchbox'|'combobox'|'spinbutton')} */
|
|
22
|
+
export let role = 'textbox';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Whether the textbox is editable.
|
|
26
|
+
*/
|
|
27
|
+
export let readOnly = false;
|
|
28
|
+
|
|
29
|
+
export let disabled = false;
|
|
30
|
+
|
|
31
|
+
export let name = '';
|
|
32
|
+
|
|
33
|
+
/** @type {(String|undefined)} */
|
|
34
|
+
export let value = undefined;
|
|
35
|
+
|
|
36
|
+
const id = getRandomId('input');
|
|
37
|
+
let ariaLabel = '';
|
|
38
|
+
|
|
39
|
+
$: {
|
|
40
|
+
// Replace `aria-label` with a visible label if `<input placeholder>` is not defined
|
|
41
|
+
if ('aria-label' in $$restProps && !('placeholder' in $$restProps)) {
|
|
42
|
+
ariaLabel = $$restProps['aria-label'];
|
|
43
|
+
delete $$restProps['aria-label'];
|
|
44
|
+
$$restProps['aria-labelledby'] = `${id}-label`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<div class="sui text-input {className}">
|
|
50
|
+
<input
|
|
51
|
+
type="text"
|
|
52
|
+
{role}
|
|
53
|
+
name={name || undefined}
|
|
54
|
+
tabindex={disabled ? -1 : 0}
|
|
55
|
+
{readOnly}
|
|
56
|
+
aria-readonly={readOnly ? true : undefined}
|
|
57
|
+
{disabled}
|
|
58
|
+
aria-disabled={disabled ? true : undefined}
|
|
59
|
+
{...$$restProps}
|
|
60
|
+
bind:this={element}
|
|
61
|
+
bind:value
|
|
62
|
+
on:input
|
|
63
|
+
on:keydown
|
|
64
|
+
on:keyup
|
|
65
|
+
on:keypress
|
|
66
|
+
on:change
|
|
67
|
+
/>
|
|
68
|
+
{#if ariaLabel}
|
|
69
|
+
<span id="{id}-label" class="label" class:hidden={!!value}>
|
|
70
|
+
{ariaLabel}
|
|
71
|
+
</span>
|
|
72
|
+
{/if}
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<style>.text-input {
|
|
76
|
+
position: relative;
|
|
77
|
+
width: 100%;
|
|
78
|
+
display: inline-flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
input {
|
|
83
|
+
z-index: 1;
|
|
84
|
+
display: inline-block;
|
|
85
|
+
flex: auto;
|
|
86
|
+
border-width: 1px;
|
|
87
|
+
border-color: var(--control-border-color);
|
|
88
|
+
border-radius: var(--input--medium--border-radius);
|
|
89
|
+
padding: 0 8px;
|
|
90
|
+
min-width: 0;
|
|
91
|
+
height: var(--input--medium--height);
|
|
92
|
+
background-color: var(--control-background-color);
|
|
93
|
+
color: inherit;
|
|
94
|
+
font-family: inherit;
|
|
95
|
+
font-size: inherit;
|
|
96
|
+
line-height: 30px;
|
|
97
|
+
transition: all 200ms;
|
|
98
|
+
}
|
|
99
|
+
input:focus {
|
|
100
|
+
border-color: var(--primary-accent-color);
|
|
101
|
+
}
|
|
102
|
+
input:read-only {
|
|
103
|
+
color: var(--tertiary-foreground-color);
|
|
104
|
+
border-color: var(--control-border-color) !important;
|
|
105
|
+
}
|
|
106
|
+
input:disabled {
|
|
107
|
+
background-color: var(--disabled-background-color);
|
|
108
|
+
opacity: 0.4;
|
|
109
|
+
cursor: default;
|
|
110
|
+
}
|
|
111
|
+
input[aria-invalid=true] {
|
|
112
|
+
border-color: deeppink;
|
|
113
|
+
}
|
|
114
|
+
input ~ :global(button) {
|
|
115
|
+
flex: none;
|
|
116
|
+
margin-left: -1px;
|
|
117
|
+
border-width: 1px;
|
|
118
|
+
border-color: var(--control-border-color);
|
|
119
|
+
height: var(--input--medium--height);
|
|
120
|
+
aspect-ratio: 1/1;
|
|
121
|
+
}
|
|
122
|
+
input ~ :global(button):last-child {
|
|
123
|
+
border-radius: 0 4px 4px 0;
|
|
124
|
+
}
|
|
125
|
+
input ~ :global(button) :global(.icon) {
|
|
126
|
+
font-size: var(--font-size--xx-large);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.label {
|
|
130
|
+
position: absolute;
|
|
131
|
+
inset: 0 8px;
|
|
132
|
+
z-index: 2;
|
|
133
|
+
display: flex;
|
|
134
|
+
justify-content: var(--input-label-align, flex-start);
|
|
135
|
+
align-items: center;
|
|
136
|
+
color: var(--primary-foreground-color);
|
|
137
|
+
opacity: 0.5;
|
|
138
|
+
pointer-events: none;
|
|
139
|
+
}
|
|
140
|
+
.label.hidden {
|
|
141
|
+
opacity: 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
input:focus + .label {
|
|
145
|
+
opacity: 0;
|
|
146
|
+
}</style>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} TextInputProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} TextInputEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} TextInputSlots */
|
|
4
|
+
/** @see https://w3c.github.io/aria/#textbox */
|
|
5
|
+
export default class TextInput extends SvelteComponentTyped<{
|
|
6
|
+
[x: string]: any;
|
|
7
|
+
class?: string;
|
|
8
|
+
element?: HTMLInputElement;
|
|
9
|
+
role?: "textbox" | "searchbox" | "combobox" | "spinbutton";
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
name?: string;
|
|
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
|
+
}, {}> {
|
|
23
|
+
/**accessor*/
|
|
24
|
+
set class(arg: string);
|
|
25
|
+
get class(): string;
|
|
26
|
+
/**accessor*/
|
|
27
|
+
set element(arg: HTMLInputElement);
|
|
28
|
+
get element(): HTMLInputElement;
|
|
29
|
+
/**accessor*/
|
|
30
|
+
set role(arg: "textbox" | "searchbox" | "combobox" | "spinbutton");
|
|
31
|
+
get role(): "textbox" | "searchbox" | "combobox" | "spinbutton";
|
|
32
|
+
/**accessor*/
|
|
33
|
+
set readOnly(arg: boolean);
|
|
34
|
+
get readOnly(): boolean;
|
|
35
|
+
/**accessor*/
|
|
36
|
+
set disabled(arg: boolean);
|
|
37
|
+
get disabled(): boolean;
|
|
38
|
+
/**accessor*/
|
|
39
|
+
set name(arg: string);
|
|
40
|
+
get name(): string;
|
|
41
|
+
/**accessor*/
|
|
42
|
+
set value(arg: string);
|
|
43
|
+
get value(): string;
|
|
44
|
+
}
|
|
45
|
+
export type TextInputProps = typeof __propDef.props;
|
|
46
|
+
export type TextInputEvents = typeof __propDef.events;
|
|
47
|
+
export type TextInputSlots = typeof __propDef.slots;
|
|
48
|
+
import { SvelteComponentTyped } from "svelte";
|
|
49
|
+
declare const __propDef: {
|
|
50
|
+
props: {
|
|
51
|
+
[x: string]: any;
|
|
52
|
+
class?: string;
|
|
53
|
+
element?: (HTMLInputElement | undefined);
|
|
54
|
+
role?: ('textbox' | 'searchbox' | 'combobox' | 'spinbutton');
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
name?: string;
|
|
57
|
+
value?: (string | undefined);
|
|
58
|
+
readOnly?: boolean;
|
|
59
|
+
};
|
|
60
|
+
events: {
|
|
61
|
+
input: Event;
|
|
62
|
+
keydown: KeyboardEvent;
|
|
63
|
+
keyup: KeyboardEvent;
|
|
64
|
+
keypress: KeyboardEvent;
|
|
65
|
+
change: Event;
|
|
66
|
+
} & {
|
|
67
|
+
[evt: string]: CustomEvent<any>;
|
|
68
|
+
};
|
|
69
|
+
slots: {};
|
|
70
|
+
};
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
@see https://w3c.github.io/aria/#toolbar
|
|
4
|
+
@see https://w3c.github.io/aria-practices/#toolbar
|
|
5
|
+
-->
|
|
6
|
+
<script>
|
|
7
|
+
/**
|
|
8
|
+
* CSS class name on the button.
|
|
9
|
+
* @type {String}
|
|
10
|
+
*/
|
|
11
|
+
// eslint-disable-next-line padding-line-between-statements
|
|
12
|
+
let className = '';
|
|
13
|
+
|
|
14
|
+
export { className as class };
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Define the `aria-orientation` property on the toolbar element.
|
|
18
|
+
* @type {('horizontal'|'vertical')}
|
|
19
|
+
*/
|
|
20
|
+
export let orientation = 'horizontal';
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<div
|
|
24
|
+
class="sui toolbar {orientation} {className}"
|
|
25
|
+
role="toolbar"
|
|
26
|
+
aria-orientation={orientation}
|
|
27
|
+
{...$$restProps}
|
|
28
|
+
>
|
|
29
|
+
<slot />
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<style>[role=toolbar] {
|
|
33
|
+
--toolbar-size: 40px;
|
|
34
|
+
flex: none !important;
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
gap: 8px;
|
|
38
|
+
padding: 8px;
|
|
39
|
+
}
|
|
40
|
+
[role=toolbar].primary {
|
|
41
|
+
--toolbar-size: 48px;
|
|
42
|
+
background-color: var(--secondary-background-color);
|
|
43
|
+
}
|
|
44
|
+
[role=toolbar].secondary {
|
|
45
|
+
background-color: var(--tertiary-background-color);
|
|
46
|
+
}
|
|
47
|
+
[role=toolbar][aria-orientation=horizontal] {
|
|
48
|
+
height: var(--toolbar-size);
|
|
49
|
+
}
|
|
50
|
+
[role=toolbar][aria-orientation=vertical] {
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
width: var(--toolbar-size);
|
|
53
|
+
}
|
|
54
|
+
[role=toolbar]:not(:last-child) {
|
|
55
|
+
border-width: 0 0 1px;
|
|
56
|
+
border-color: var(--primary-border-color);
|
|
57
|
+
}
|
|
58
|
+
[role=toolbar] :global(button[role="button"][aria-pressed="true"]),
|
|
59
|
+
[role=toolbar] :global(button[role="button"][aria-checked="true"]) {
|
|
60
|
+
background-color: var(--highlight-background-color);
|
|
61
|
+
}
|
|
62
|
+
[role=toolbar] :global(h2) {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
gap: 8px;
|
|
66
|
+
margin: 0;
|
|
67
|
+
padding: 0 8px;
|
|
68
|
+
font-size: var(--font-size--large);
|
|
69
|
+
}
|
|
70
|
+
[role=toolbar] :global(h2) :global(span) {
|
|
71
|
+
font-size: var(--font-size--small);
|
|
72
|
+
font-weight: normal;
|
|
73
|
+
opacity: 0.8;
|
|
74
|
+
}</style>
|