@geoffcox/sterling-svelte 0.0.20 → 0.0.22
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/Button.constants.d.ts +2 -0
- package/Button.constants.js +2 -0
- package/Button.svelte +11 -0
- package/Button.svelte.d.ts +10 -5
- package/Button.types.d.ts +6 -2
- package/Checkbox.svelte +16 -3
- package/Checkbox.svelte.d.ts +8 -0
- package/Dialog.svelte +2 -3
- package/Dropdown.svelte +11 -2
- package/Dropdown.svelte.d.ts +6 -0
- package/Field.constants.d.ts +1 -0
- package/Field.constants.js +1 -0
- package/Field.svelte +25 -10
- package/Field.svelte.d.ts +10 -4
- package/Field.types.d.ts +4 -1
- package/Input.svelte +27 -3
- package/Input.svelte.d.ts +12 -0
- package/Label.svelte +12 -2
- package/Label.svelte.d.ts +9 -1
- package/Link.constants.d.ts +1 -0
- package/Link.constants.js +1 -0
- package/Link.svelte +11 -0
- package/Link.svelte.d.ts +8 -3
- package/Link.types.d.ts +4 -1
- package/List.constants.d.ts +1 -1
- package/List.constants.js +1 -1
- package/List.svelte +13 -10
- package/List.svelte.d.ts +6 -2
- package/ListItem.svelte +11 -2
- package/ListItem.svelte.d.ts +6 -0
- package/Menu.svelte +46 -12
- package/Menu.svelte.d.ts +26 -0
- package/MenuBar.constants.d.ts +1 -0
- package/MenuBar.constants.js +1 -0
- package/MenuBar.svelte +12 -3
- package/MenuBar.svelte.d.ts +5 -1
- package/MenuBar.types.d.ts +4 -0
- package/MenuButton.svelte +45 -11
- package/MenuButton.svelte.d.ts +12 -4
- package/MenuItem.constants.d.ts +1 -0
- package/MenuItem.constants.js +1 -0
- package/MenuItem.svelte +20 -10
- package/MenuItem.svelte.d.ts +12 -3
- package/{Menus.types.d.ts → MenuItem.types.d.ts} +0 -4
- package/MenuItem.types.js +1 -0
- package/{Menus.utils.d.ts → MenuItem.utils.d.ts} +1 -1
- package/Progress.constants.d.ts +1 -0
- package/Progress.constants.js +1 -0
- package/Progress.svelte +16 -3
- package/Progress.svelte.d.ts +15 -3
- package/Progress.types.d.ts +4 -1
- package/Radio.svelte +16 -3
- package/Radio.svelte.d.ts +8 -0
- package/Select.svelte +17 -3
- package/Select.svelte.d.ts +10 -0
- package/Slider.svelte +9 -0
- package/Slider.svelte.d.ts +6 -0
- package/Switch.svelte +14 -3
- package/Switch.svelte.d.ts +6 -0
- package/Tab.svelte +11 -2
- package/Tab.svelte.d.ts +6 -0
- package/TabList.constants.d.ts +1 -1
- package/TabList.constants.js +1 -1
- package/TabList.svelte +8 -2
- package/TabList.svelte.d.ts +4 -0
- package/TextArea.constants.d.ts +1 -0
- package/TextArea.constants.js +1 -0
- package/TextArea.svelte +22 -0
- package/TextArea.svelte.d.ts +13 -2
- package/TextArea.types.d.ts +4 -1
- package/Tooltip.constants.d.ts +1 -0
- package/Tooltip.constants.js +1 -0
- package/Tooltip.svelte +26 -10
- package/Tooltip.svelte.d.ts +7 -3
- package/Tooltip.types.d.ts +4 -3
- package/Tree.constants.d.ts +2 -2
- package/Tree.constants.js +2 -2
- package/Tree.svelte +41 -7
- package/Tree.svelte.d.ts +34 -1
- package/Tree.types.d.ts +4 -16
- package/TreeChevron.svelte +33 -2
- package/TreeChevron.svelte.d.ts +27 -0
- package/TreeItem.svelte +76 -52
- package/TreeItem.svelte.d.ts +26 -3
- package/TreeItem.types.d.ts +13 -0
- package/TreeItem.types.js +1 -0
- package/TreeItemDisplay.svelte +12 -0
- package/TreeItemDisplay.svelte.d.ts +6 -0
- package/floating-ui.constants.d.ts +1 -0
- package/floating-ui.constants.js +14 -0
- package/floating-ui.types.d.ts +2 -0
- package/floating-ui.types.js +1 -0
- package/idGenerator.d.ts +4 -0
- package/idGenerator.js +10 -0
- package/index.d.ts +19 -7
- package/index.js +14 -5
- package/package.json +21 -11
- package/theme/toggleDarkTheme.d.ts +1 -1
- package/theme/toggleDarkTheme.js +1 -1
- package/Menus.constants.d.ts +0 -2
- package/Menus.constants.js +0 -2
- /package/{Menus.types.js → MenuBar.types.js} +0 -0
- /package/{Menus.utils.js → MenuItem.utils.js} +0 -0
package/Button.svelte
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
<script>export let variant = "regular";
|
|
2
2
|
export let shape = "rounded";
|
|
3
|
+
let buttonRef;
|
|
4
|
+
export const click = () => {
|
|
5
|
+
buttonRef?.click();
|
|
6
|
+
};
|
|
7
|
+
export const blur = () => {
|
|
8
|
+
buttonRef?.blur();
|
|
9
|
+
};
|
|
10
|
+
export const focus = (options) => {
|
|
11
|
+
buttonRef?.focus(options);
|
|
12
|
+
};
|
|
3
13
|
</script>
|
|
4
14
|
|
|
5
15
|
<!--
|
|
@@ -7,6 +17,7 @@ export let shape = "rounded";
|
|
|
7
17
|
A styled HTML button element.
|
|
8
18
|
-->
|
|
9
19
|
<button
|
|
20
|
+
bind:this={buttonRef}
|
|
10
21
|
class="sterling-button"
|
|
11
22
|
class:square={shape === 'square'}
|
|
12
23
|
class:circular={shape === 'circular'}
|
package/Button.svelte.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { ButtonShape, ButtonVariant } from './Button.types';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
4
|
[x: string]: any;
|
|
6
|
-
variant?:
|
|
7
|
-
shape?:
|
|
5
|
+
variant?: "regular" | "outline" | "ghost" | undefined;
|
|
6
|
+
shape?: "circular" | "rounded" | "square" | undefined;
|
|
7
|
+
click?: (() => void) | undefined;
|
|
8
|
+
blur?: (() => void) | undefined;
|
|
9
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
8
10
|
};
|
|
9
11
|
events: {
|
|
10
12
|
blur: FocusEvent;
|
|
@@ -37,8 +39,8 @@ declare const __propDef: {
|
|
|
37
39
|
};
|
|
38
40
|
slots: {
|
|
39
41
|
default: {
|
|
40
|
-
shape:
|
|
41
|
-
variant:
|
|
42
|
+
shape: "circular" | "rounded" | "square";
|
|
43
|
+
variant: "regular" | "outline" | "ghost";
|
|
42
44
|
};
|
|
43
45
|
};
|
|
44
46
|
};
|
|
@@ -47,5 +49,8 @@ export type ButtonEvents = typeof __propDef.events;
|
|
|
47
49
|
export type ButtonSlots = typeof __propDef.slots;
|
|
48
50
|
/** A styled HTML button element. */
|
|
49
51
|
export default class Button extends SvelteComponentTyped<ButtonProps, ButtonEvents, ButtonSlots> {
|
|
52
|
+
get click(): () => void;
|
|
53
|
+
get blur(): () => void;
|
|
54
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
50
55
|
}
|
|
51
56
|
export {};
|
package/Button.types.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { BUTTON_SHAPES, BUTTON_VARIANTS } from './Button.constants';
|
|
2
|
+
type ButtonShapeTuple = typeof BUTTON_SHAPES;
|
|
3
|
+
export type ButtonShape = ButtonShapeTuple[number];
|
|
4
|
+
type ButtonVariantTuple = typeof BUTTON_VARIANTS;
|
|
5
|
+
export type ButtonVariant = ButtonVariantTuple[number];
|
|
6
|
+
export {};
|
package/Checkbox.svelte
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { idGenerator } from "./idGenerator";
|
|
2
2
|
import Label from "./Label.svelte";
|
|
3
3
|
export let checked = false;
|
|
4
4
|
export let disabled = false;
|
|
5
5
|
export let id = void 0;
|
|
6
|
+
let inputRef;
|
|
6
7
|
$: {
|
|
7
8
|
if ($$slots.default && id === void 0) {
|
|
8
|
-
id =
|
|
9
|
+
id = idGenerator.nextId("Checkbox");
|
|
9
10
|
}
|
|
10
11
|
}
|
|
12
|
+
export const blur = () => {
|
|
13
|
+
inputRef?.blur();
|
|
14
|
+
};
|
|
15
|
+
export const click = () => {
|
|
16
|
+
inputRef?.click();
|
|
17
|
+
};
|
|
18
|
+
export const focus = (options) => {
|
|
19
|
+
inputRef?.focus(options);
|
|
20
|
+
};
|
|
11
21
|
</script>
|
|
12
22
|
|
|
13
23
|
<!--
|
|
@@ -17,6 +27,7 @@ $: {
|
|
|
17
27
|
<div class="sterling-checkbox">
|
|
18
28
|
<div class="container">
|
|
19
29
|
<input
|
|
30
|
+
bind:this={inputRef}
|
|
20
31
|
{disabled}
|
|
21
32
|
{id}
|
|
22
33
|
type="checkbox"
|
|
@@ -48,7 +59,9 @@ $: {
|
|
|
48
59
|
{#if $$slots.default}
|
|
49
60
|
<div class="label">
|
|
50
61
|
<Label {disabled} for={id}>
|
|
51
|
-
<slot {checked} {disabled}
|
|
62
|
+
<slot {checked} {disabled} inputId={id} value={$$restProps.value}>
|
|
63
|
+
{$$restProps.value}
|
|
64
|
+
</slot>
|
|
52
65
|
</Label>
|
|
53
66
|
</div>
|
|
54
67
|
{/if}
|
package/Checkbox.svelte.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ declare const __propDef: {
|
|
|
5
5
|
checked?: boolean | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
id?: string | undefined;
|
|
8
|
+
blur?: (() => void) | undefined;
|
|
9
|
+
click?: (() => void) | undefined;
|
|
10
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
8
11
|
};
|
|
9
12
|
events: {
|
|
10
13
|
blur: FocusEvent;
|
|
@@ -34,6 +37,8 @@ declare const __propDef: {
|
|
|
34
37
|
default: {
|
|
35
38
|
checked: boolean;
|
|
36
39
|
disabled: boolean;
|
|
40
|
+
inputId: string | undefined;
|
|
41
|
+
value: any;
|
|
37
42
|
};
|
|
38
43
|
};
|
|
39
44
|
};
|
|
@@ -42,5 +47,8 @@ export type CheckboxEvents = typeof __propDef.events;
|
|
|
42
47
|
export type CheckboxSlots = typeof __propDef.slots;
|
|
43
48
|
/** A styled HTML input type=checkbox element. */
|
|
44
49
|
export default class Checkbox extends SvelteComponentTyped<CheckboxProps, CheckboxEvents, CheckboxSlots> {
|
|
50
|
+
get blur(): () => void;
|
|
51
|
+
get click(): () => void;
|
|
52
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
45
53
|
}
|
|
46
54
|
export {};
|
package/Dialog.svelte
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { onMount, tick } from "svelte";
|
|
2
2
|
import Button from "./Button.svelte";
|
|
3
3
|
const dialogFadeDuration = 250;
|
|
4
4
|
export let open = false;
|
|
@@ -8,7 +8,6 @@ let dialogRef;
|
|
|
8
8
|
let contentRef;
|
|
9
9
|
let formRef;
|
|
10
10
|
let closing = false;
|
|
11
|
-
const dispatch = createEventDispatcher();
|
|
12
11
|
const onDocumentClick = (event) => {
|
|
13
12
|
const targetNode = event?.target;
|
|
14
13
|
if (targetNode && !contentRef.contains(targetNode) && backdropCloses) {
|
|
@@ -89,10 +88,10 @@ A styled <dialog> element
|
|
|
89
88
|
- Props and events to make using <dialog> easier
|
|
90
89
|
-->
|
|
91
90
|
<dialog
|
|
91
|
+
bind:this={dialogRef}
|
|
92
92
|
class="dialog"
|
|
93
93
|
class:open
|
|
94
94
|
class:closing
|
|
95
|
-
bind:this={dialogRef}
|
|
96
95
|
on:close
|
|
97
96
|
on:cancel
|
|
98
97
|
{...$$restProps}
|
package/Dropdown.svelte
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script>import { computePosition, flip, offset, shift, autoUpdate } from "@floating-ui/dom";
|
|
2
2
|
import { createEventDispatcher, onMount, tick } from "svelte";
|
|
3
|
-
import { v4 as uuid } from "uuid";
|
|
4
3
|
import { clickOutside } from "./actions/clickOutside";
|
|
5
|
-
|
|
4
|
+
import { idGenerator } from "./idGenerator";
|
|
5
|
+
const popupId = idGenerator.nextId("Dropdown-popup");
|
|
6
6
|
export let composed = false;
|
|
7
7
|
export let disabled = false;
|
|
8
8
|
export let open = false;
|
|
@@ -20,6 +20,15 @@ const raiseOpen = (open2) => {
|
|
|
20
20
|
$: {
|
|
21
21
|
raiseOpen(open);
|
|
22
22
|
}
|
|
23
|
+
export const click = () => {
|
|
24
|
+
dropdownRef?.click();
|
|
25
|
+
};
|
|
26
|
+
export const blur = () => {
|
|
27
|
+
dropdownRef?.blur();
|
|
28
|
+
};
|
|
29
|
+
export const focus = (options) => {
|
|
30
|
+
dropdownRef?.focus(options);
|
|
31
|
+
};
|
|
23
32
|
let mounted = false;
|
|
24
33
|
onMount(() => {
|
|
25
34
|
mounted = true;
|
package/Dropdown.svelte.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ declare const __propDef: {
|
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
open?: boolean | undefined;
|
|
8
8
|
stayOpenOnClickAway?: boolean | undefined;
|
|
9
|
+
click?: (() => void) | undefined;
|
|
10
|
+
blur?: (() => void) | undefined;
|
|
11
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
9
12
|
};
|
|
10
13
|
events: {
|
|
11
14
|
blur: FocusEvent;
|
|
@@ -54,5 +57,8 @@ export type DropdownProps = typeof __propDef.props;
|
|
|
54
57
|
export type DropdownEvents = typeof __propDef.events;
|
|
55
58
|
export type DropdownSlots = typeof __propDef.slots;
|
|
56
59
|
export default class Dropdown extends SvelteComponentTyped<DropdownProps, DropdownEvents, DropdownSlots> {
|
|
60
|
+
get click(): () => void;
|
|
61
|
+
get blur(): () => void;
|
|
62
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
57
63
|
}
|
|
58
64
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FIELD_STATUSES: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const FIELD_STATUSES = ['none', 'info', 'success', 'warning', 'error'];
|
package/Field.svelte
CHANGED
|
@@ -7,7 +7,7 @@ export { htmlFor as for };
|
|
|
7
7
|
export let label = void 0;
|
|
8
8
|
export let message = void 0;
|
|
9
9
|
export let required = false;
|
|
10
|
-
export let
|
|
10
|
+
export let requiredReason = "This field is required";
|
|
11
11
|
export let status = "none";
|
|
12
12
|
let fieldRef;
|
|
13
13
|
let targetDisabled = false;
|
|
@@ -67,6 +67,15 @@ let usingKeyboard = keyborg.isNavigatingWithKeyboard();
|
|
|
67
67
|
const keyborgHandler = (value) => {
|
|
68
68
|
usingKeyboard = value;
|
|
69
69
|
};
|
|
70
|
+
export const click = () => {
|
|
71
|
+
fieldRef?.click();
|
|
72
|
+
};
|
|
73
|
+
export const blur = () => {
|
|
74
|
+
fieldRef?.blur();
|
|
75
|
+
};
|
|
76
|
+
export const focus = (options) => {
|
|
77
|
+
fieldRef?.focus(options);
|
|
78
|
+
};
|
|
70
79
|
onMount(() => {
|
|
71
80
|
keyborg.subscribe(keyborgHandler);
|
|
72
81
|
return () => {
|
|
@@ -81,8 +90,8 @@ const onClick = () => {
|
|
|
81
90
|
</script>
|
|
82
91
|
|
|
83
92
|
<label
|
|
84
|
-
aria-disabled={targetDisabled}
|
|
85
93
|
bind:this={fieldRef}
|
|
94
|
+
aria-disabled={targetDisabled}
|
|
86
95
|
class="sterling-field"
|
|
87
96
|
class:disabled={targetDisabled}
|
|
88
97
|
class:using-keyboard={usingKeyboard}
|
|
@@ -111,12 +120,18 @@ const onClick = () => {
|
|
|
111
120
|
on:paste
|
|
112
121
|
{...$$restProps}
|
|
113
122
|
>
|
|
114
|
-
|
|
115
|
-
<
|
|
116
|
-
|
|
123
|
+
{#if label || $$slots.label}
|
|
124
|
+
<slot name="label" disabled={targetDisabled} for={htmlFor} {forwardClick} {label} {required}>
|
|
125
|
+
<div class="label-text">
|
|
126
|
+
{label}
|
|
127
|
+
</div>
|
|
128
|
+
</slot>
|
|
129
|
+
{/if}
|
|
130
|
+
{#if $$slots.default}
|
|
131
|
+
<div class="content">
|
|
132
|
+
<slot />
|
|
117
133
|
</div>
|
|
118
|
-
|
|
119
|
-
<slot />
|
|
134
|
+
{/if}
|
|
120
135
|
{#if message}
|
|
121
136
|
<slot name="message" disabled={targetDisabled} {message} {required} {status}>
|
|
122
137
|
<div
|
|
@@ -131,9 +146,9 @@ const onClick = () => {
|
|
|
131
146
|
</slot>
|
|
132
147
|
{/if}
|
|
133
148
|
{#if required}
|
|
134
|
-
<slot name="required" {
|
|
135
|
-
<Tooltip
|
|
136
|
-
<span class="required-tip" slot="tip">{
|
|
149
|
+
<slot name="required" requiredTip={requiredReason}>
|
|
150
|
+
<Tooltip showOn="hover">
|
|
151
|
+
<span class="required-tip" slot="tip">{requiredReason}</span>
|
|
137
152
|
<div class="required">*</div>
|
|
138
153
|
</Tooltip>
|
|
139
154
|
</slot>
|
package/Field.svelte.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { FieldStatus } from './Field.types';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
4
|
[x: string]: any;
|
|
@@ -8,8 +7,11 @@ declare const __propDef: {
|
|
|
8
7
|
label?: string | undefined;
|
|
9
8
|
message?: string | undefined;
|
|
10
9
|
required?: boolean | undefined;
|
|
11
|
-
|
|
12
|
-
status?:
|
|
10
|
+
requiredReason?: string | undefined;
|
|
11
|
+
status?: string | undefined;
|
|
12
|
+
click?: (() => void) | undefined;
|
|
13
|
+
blur?: (() => void) | undefined;
|
|
14
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
13
15
|
};
|
|
14
16
|
events: {
|
|
15
17
|
blur: FocusEvent;
|
|
@@ -40,6 +42,7 @@ declare const __propDef: {
|
|
|
40
42
|
label: {
|
|
41
43
|
disabled: boolean;
|
|
42
44
|
for: string | undefined;
|
|
45
|
+
forwardClick: boolean;
|
|
43
46
|
label: string | undefined;
|
|
44
47
|
required: boolean;
|
|
45
48
|
};
|
|
@@ -48,7 +51,7 @@ declare const __propDef: {
|
|
|
48
51
|
disabled: boolean;
|
|
49
52
|
message: string | undefined;
|
|
50
53
|
required: boolean;
|
|
51
|
-
status:
|
|
54
|
+
status: string;
|
|
52
55
|
};
|
|
53
56
|
required: {
|
|
54
57
|
requiredTip: string;
|
|
@@ -59,5 +62,8 @@ export type FieldProps = typeof __propDef.props;
|
|
|
59
62
|
export type FieldEvents = typeof __propDef.events;
|
|
60
63
|
export type FieldSlots = typeof __propDef.slots;
|
|
61
64
|
export default class Field extends SvelteComponentTyped<FieldProps, FieldEvents, FieldSlots> {
|
|
65
|
+
get click(): () => void;
|
|
66
|
+
get blur(): () => void;
|
|
67
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
62
68
|
}
|
|
63
69
|
export {};
|
package/Field.types.d.ts
CHANGED
package/Input.svelte
CHANGED
|
@@ -1,14 +1,37 @@
|
|
|
1
|
-
<script>import {
|
|
1
|
+
<script>import { idGenerator } from "./idGenerator";
|
|
2
2
|
import Label from "./Label.svelte";
|
|
3
3
|
export let composed = false;
|
|
4
4
|
export let disabled = false;
|
|
5
5
|
export let id = void 0;
|
|
6
6
|
export let value = "";
|
|
7
|
+
let inputRef;
|
|
7
8
|
$: {
|
|
8
9
|
if ($$slots.default && id === void 0) {
|
|
9
|
-
id =
|
|
10
|
+
id = idGenerator.nextId("Input");
|
|
10
11
|
}
|
|
11
12
|
}
|
|
13
|
+
export const blur = () => {
|
|
14
|
+
inputRef?.blur();
|
|
15
|
+
};
|
|
16
|
+
export const click = () => {
|
|
17
|
+
inputRef?.click();
|
|
18
|
+
};
|
|
19
|
+
export const focus = (options) => {
|
|
20
|
+
inputRef?.focus();
|
|
21
|
+
};
|
|
22
|
+
export const select = () => {
|
|
23
|
+
inputRef?.select();
|
|
24
|
+
};
|
|
25
|
+
export const setSelectionRange = (start, end, direction) => {
|
|
26
|
+
inputRef?.setSelectionRange(start, end, direction);
|
|
27
|
+
};
|
|
28
|
+
export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
29
|
+
if (start && end) {
|
|
30
|
+
inputRef?.setRangeText(replacement, start, end, selectionMode);
|
|
31
|
+
} else {
|
|
32
|
+
inputRef?.setRangeText(replacement);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
12
35
|
</script>
|
|
13
36
|
|
|
14
37
|
{#if $$slots.default}
|
|
@@ -17,11 +40,12 @@ $: {
|
|
|
17
40
|
</Label>
|
|
18
41
|
{/if}
|
|
19
42
|
<input
|
|
20
|
-
bind:
|
|
43
|
+
bind:this={inputRef}
|
|
21
44
|
class="sterling-input"
|
|
22
45
|
class:composed
|
|
23
46
|
{disabled}
|
|
24
47
|
{id}
|
|
48
|
+
bind:value
|
|
25
49
|
on:blur
|
|
26
50
|
on:click
|
|
27
51
|
on:change
|
package/Input.svelte.d.ts
CHANGED
|
@@ -6,6 +6,12 @@ declare const __propDef: {
|
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
id?: string | undefined;
|
|
8
8
|
value?: string | undefined;
|
|
9
|
+
blur?: (() => void) | undefined;
|
|
10
|
+
click?: (() => void) | undefined;
|
|
11
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
12
|
+
select?: (() => void) | undefined;
|
|
13
|
+
setSelectionRange?: ((start: number | null, end: number | null, direction?: 'forward' | 'backward' | 'none') => void) | undefined;
|
|
14
|
+
setRangeText?: ((replacement: string, start?: number, end?: number, selectionMode?: SelectionMode) => void) | undefined;
|
|
9
15
|
};
|
|
10
16
|
events: {
|
|
11
17
|
blur: FocusEvent;
|
|
@@ -49,5 +55,11 @@ export type InputProps = typeof __propDef.props;
|
|
|
49
55
|
export type InputEvents = typeof __propDef.events;
|
|
50
56
|
export type InputSlots = typeof __propDef.slots;
|
|
51
57
|
export default class Input extends SvelteComponentTyped<InputProps, InputEvents, InputSlots> {
|
|
58
|
+
get blur(): () => void;
|
|
59
|
+
get click(): () => void;
|
|
60
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
61
|
+
get select(): () => void;
|
|
62
|
+
get setSelectionRange(): (start: number | null, end: number | null, direction?: "none" | "forward" | "backward" | undefined) => void;
|
|
63
|
+
get setRangeText(): (replacement: string, start?: number | undefined, end?: number | undefined, selectionMode?: SelectionMode | undefined) => void;
|
|
52
64
|
}
|
|
53
65
|
export {};
|
package/Label.svelte
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
<script>export let disabled = false;
|
|
2
|
-
|
|
2
|
+
let labelRef;
|
|
3
|
+
export const blur = () => {
|
|
4
|
+
labelRef?.blur();
|
|
5
|
+
};
|
|
6
|
+
export const click = () => {
|
|
7
|
+
labelRef?.click();
|
|
8
|
+
};
|
|
9
|
+
export const focus = (options) => {
|
|
10
|
+
labelRef?.focus();
|
|
11
|
+
};
|
|
3
12
|
</script>
|
|
4
13
|
|
|
5
14
|
<label
|
|
15
|
+
bind:this={labelRef}
|
|
6
16
|
aria-disabled={disabled}
|
|
7
17
|
class="sterling-label"
|
|
8
18
|
class:disabled
|
|
@@ -29,7 +39,7 @@ HTMLLabelElement;
|
|
|
29
39
|
on:paste
|
|
30
40
|
{...$$restProps}
|
|
31
41
|
>
|
|
32
|
-
<slot />
|
|
42
|
+
<slot {disabled} />
|
|
33
43
|
</label>
|
|
34
44
|
|
|
35
45
|
<style>
|
package/Label.svelte.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ declare const __propDef: {
|
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
disabled?: boolean | undefined;
|
|
6
|
+
blur?: (() => void) | undefined;
|
|
7
|
+
click?: (() => void) | undefined;
|
|
8
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
6
9
|
};
|
|
7
10
|
events: {
|
|
8
11
|
blur: FocusEvent;
|
|
@@ -30,12 +33,17 @@ declare const __propDef: {
|
|
|
30
33
|
[evt: string]: CustomEvent<any>;
|
|
31
34
|
};
|
|
32
35
|
slots: {
|
|
33
|
-
default: {
|
|
36
|
+
default: {
|
|
37
|
+
disabled: boolean;
|
|
38
|
+
};
|
|
34
39
|
};
|
|
35
40
|
};
|
|
36
41
|
export type LabelProps = typeof __propDef.props;
|
|
37
42
|
export type LabelEvents = typeof __propDef.events;
|
|
38
43
|
export type LabelSlots = typeof __propDef.slots;
|
|
39
44
|
export default class Label extends SvelteComponentTyped<LabelProps, LabelEvents, LabelSlots> {
|
|
45
|
+
get blur(): () => void;
|
|
46
|
+
get click(): () => void;
|
|
47
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
40
48
|
}
|
|
41
49
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LINK_VARIANTS: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const LINK_VARIANTS = ['regular', 'ghost', 'undecorated'];
|
package/Link.svelte
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
<script>export let href;
|
|
2
2
|
export let disabled = false;
|
|
3
3
|
export let variant = "regular";
|
|
4
|
+
let linkRef;
|
|
5
|
+
export const blur = () => {
|
|
6
|
+
linkRef?.blur();
|
|
7
|
+
};
|
|
8
|
+
export const click = () => {
|
|
9
|
+
linkRef?.click();
|
|
10
|
+
};
|
|
11
|
+
export const focus = (options) => {
|
|
12
|
+
linkRef?.focus();
|
|
13
|
+
};
|
|
4
14
|
</script>
|
|
5
15
|
|
|
6
16
|
<a
|
|
17
|
+
bind:this={linkRef}
|
|
7
18
|
class="sterling-link"
|
|
8
19
|
class:disabled
|
|
9
20
|
class:ghost={variant === 'ghost'}
|
package/Link.svelte.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { LinkVariant } from './Link.types';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
4
|
[x: string]: any;
|
|
6
5
|
href: string;
|
|
7
6
|
disabled?: boolean | undefined;
|
|
8
|
-
variant?:
|
|
7
|
+
variant?: string | undefined;
|
|
8
|
+
blur?: (() => void) | undefined;
|
|
9
|
+
click?: (() => void) | undefined;
|
|
10
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
9
11
|
};
|
|
10
12
|
events: {
|
|
11
13
|
blur: FocusEvent;
|
|
@@ -40,7 +42,7 @@ declare const __propDef: {
|
|
|
40
42
|
default: {
|
|
41
43
|
disabled: boolean;
|
|
42
44
|
href: string;
|
|
43
|
-
variant:
|
|
45
|
+
variant: string;
|
|
44
46
|
};
|
|
45
47
|
};
|
|
46
48
|
};
|
|
@@ -48,5 +50,8 @@ export type LinkProps = typeof __propDef.props;
|
|
|
48
50
|
export type LinkEvents = typeof __propDef.events;
|
|
49
51
|
export type LinkSlots = typeof __propDef.slots;
|
|
50
52
|
export default class Link extends SvelteComponentTyped<LinkProps, LinkEvents, LinkSlots> {
|
|
53
|
+
get blur(): () => void;
|
|
54
|
+
get click(): () => void;
|
|
55
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
51
56
|
}
|
|
52
57
|
export {};
|
package/Link.types.d.ts
CHANGED
package/List.constants.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const LIST_CONTEXT_KEY = "sterlingList";
|
package/List.constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const LIST_CONTEXT_KEY = 'sterlingList';
|
package/List.svelte
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
<script>import { createKeyborg } from "keyborg";
|
|
2
2
|
import { createEventDispatcher, onMount, setContext } from "svelte";
|
|
3
3
|
import { writable } from "svelte/store";
|
|
4
|
-
import {
|
|
5
|
-
import { listContextKey } from "./List.constants";
|
|
4
|
+
import { LIST_CONTEXT_KEY } from "./List.constants";
|
|
6
5
|
export let composed = false;
|
|
7
6
|
export let disabled = false;
|
|
8
7
|
export let horizontal = false;
|
|
9
8
|
export let selectedValue = void 0;
|
|
10
|
-
const listId = `list-${uuid()}`;
|
|
11
9
|
let listRef;
|
|
12
10
|
let lastSelectedItemRef;
|
|
13
11
|
const disabledStore = writable(disabled);
|
|
@@ -32,18 +30,24 @@ const raiseSelect = (value) => {
|
|
|
32
30
|
$: {
|
|
33
31
|
raiseSelect(selectedValue);
|
|
34
32
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
export const blur = () => {
|
|
34
|
+
listRef?.blur();
|
|
35
|
+
};
|
|
36
|
+
export const click = () => {
|
|
37
|
+
listRef?.click();
|
|
39
38
|
};
|
|
40
|
-
export const focus = () => {
|
|
39
|
+
export const focus = (options) => {
|
|
41
40
|
listRef?.focus();
|
|
42
41
|
};
|
|
43
42
|
export const scrollToSelectedItem = () => {
|
|
44
43
|
const element = getSelectedItemElement();
|
|
45
44
|
element?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
46
45
|
};
|
|
46
|
+
let keyborg = createKeyborg(window);
|
|
47
|
+
let usingKeyboard = keyborg.isNavigatingWithKeyboard();
|
|
48
|
+
const keyborgHandler = (value) => {
|
|
49
|
+
usingKeyboard = value;
|
|
50
|
+
};
|
|
47
51
|
const isElementListItem = (candidate) => {
|
|
48
52
|
return candidate && candidate.getAttribute("data-value") !== null && candidate.getAttribute("data-value") !== void 0 && candidate.getAttribute("role") === "listitem";
|
|
49
53
|
};
|
|
@@ -172,7 +176,7 @@ const onKeydown = (event) => {
|
|
|
172
176
|
}
|
|
173
177
|
}
|
|
174
178
|
};
|
|
175
|
-
setContext(
|
|
179
|
+
setContext(LIST_CONTEXT_KEY, {
|
|
176
180
|
disabled: disabledStore,
|
|
177
181
|
selectedValue: selectedValueStore,
|
|
178
182
|
horizontal: horizontalStore
|
|
@@ -194,7 +198,6 @@ A list of items where a single item can be selected.
|
|
|
194
198
|
class:disabled
|
|
195
199
|
class:horizontal
|
|
196
200
|
class:using-keyboard={usingKeyboard}
|
|
197
|
-
id={listId}
|
|
198
201
|
role="list"
|
|
199
202
|
tabindex={0}
|
|
200
203
|
on:blur
|
package/List.svelte.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ declare const __propDef: {
|
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
horizontal?: boolean | undefined;
|
|
8
8
|
selectedValue?: string | undefined;
|
|
9
|
-
|
|
9
|
+
blur?: (() => void) | undefined;
|
|
10
|
+
click?: (() => void) | undefined;
|
|
11
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
10
12
|
scrollToSelectedItem?: (() => void) | undefined;
|
|
11
13
|
selectFirstItem?: (() => boolean) | undefined;
|
|
12
14
|
selectPreviousItem?: (() => boolean) | undefined;
|
|
@@ -53,7 +55,9 @@ export type ListEvents = typeof __propDef.events;
|
|
|
53
55
|
export type ListSlots = typeof __propDef.slots;
|
|
54
56
|
/** A list of items where a single item can be selected. */
|
|
55
57
|
export default class List extends SvelteComponentTyped<ListProps, ListEvents, ListSlots> {
|
|
56
|
-
get
|
|
58
|
+
get blur(): () => void;
|
|
59
|
+
get click(): () => void;
|
|
60
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
57
61
|
get scrollToSelectedItem(): () => void;
|
|
58
62
|
get selectFirstItem(): () => boolean;
|
|
59
63
|
get selectPreviousItem(): () => boolean;
|