@geoffcox/sterling-svelte 0.0.26 → 0.0.27
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.svelte +79 -24
- package/Button.svelte.d.ts +1 -0
- package/Checkbox.svelte +44 -19
- package/Checkbox.svelte.d.ts +1 -0
- package/ColorPicker.constants.d.ts +1 -0
- package/ColorPicker.constants.js +1 -0
- package/ColorPicker.svelte +226 -0
- package/ColorPicker.svelte.d.ts +22 -0
- package/ColorPicker.types.d.ts +4 -0
- package/ColorPicker.types.js +1 -0
- package/Dialog.svelte +10 -10
- package/Dropdown.svelte +87 -55
- package/Dropdown.svelte.d.ts +4 -0
- package/Field.svelte +31 -31
- package/HexColorSliders.svelte +150 -0
- package/HexColorSliders.svelte.d.ts +22 -0
- package/HslColorSliders.svelte +187 -0
- package/HslColorSliders.svelte.d.ts +22 -0
- package/Input.svelte +49 -21
- package/Input.svelte.d.ts +2 -1
- package/Label.svelte +3 -3
- package/Link.svelte +63 -17
- package/Link.svelte.d.ts +1 -0
- package/List.svelte +28 -16
- package/List.svelte.d.ts +1 -0
- package/List.types.d.ts +4 -3
- package/ListItem.svelte +29 -10
- package/ListItem.svelte.d.ts +1 -1
- package/Menu.svelte +7 -7
- package/MenuBar.svelte +1 -1
- package/MenuButton.svelte +3 -5
- package/MenuItem.svelte +33 -11
- package/MenuItem.svelte.d.ts +1 -0
- package/MenuItemDisplay.svelte +7 -1
- package/MenuSeparator.svelte +3 -3
- package/Popover.svelte +66 -51
- package/Popover.svelte.d.ts +4 -2
- package/Progress.svelte +14 -14
- package/Radio.svelte +42 -16
- package/Radio.svelte.d.ts +1 -0
- package/RgbColorSliders.svelte +161 -0
- package/RgbColorSliders.svelte.d.ts +22 -0
- package/Select.svelte +30 -24
- package/Slider.svelte +108 -118
- package/Slider.svelte.d.ts +1 -0
- package/Switch.svelte +97 -34
- package/Switch.svelte.d.ts +1 -0
- package/Tab.svelte +52 -29
- package/TabList.svelte +21 -10
- package/TabList.svelte.d.ts +1 -0
- package/TabList.types.d.ts +1 -0
- package/TextArea.svelte +45 -20
- package/TextArea.svelte.d.ts +3 -2
- package/Tooltip.svelte +12 -11
- package/Tree.svelte +34 -21
- package/Tree.svelte.d.ts +2 -0
- package/Tree.types.d.ts +1 -0
- package/TreeChevron.svelte +1 -1
- package/TreeItem.svelte +40 -9
- package/TreeItem.svelte.d.ts +2 -0
- package/TreeItemDisplay.svelte +26 -8
- package/TreeItemDisplay.svelte.d.ts +2 -0
- package/actions/clickOutside.js +1 -1
- package/actions/trapKeyboardFocus.d.ts +3 -0
- package/actions/trapKeyboardFocus.js +52 -0
- package/floating-ui.types.d.ts +2 -0
- package/index.d.ts +8 -3
- package/index.js +7 -2
- package/package.json +10 -1
- package/theme/applyTheme.js +3 -2
- package/theme/colors.d.ts +1 -0
- package/theme/colors.js +28 -13
- package/theme/darkTheme.js +130 -87
- package/theme/lightTheme.js +107 -87
package/Tree.svelte
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
import { writable } from "svelte/store";
|
|
3
3
|
import { TREE_CONTEXT_KEY } from "./Tree.constants";
|
|
4
4
|
import { usingKeyboard } from "./stores/usingKeyboard";
|
|
5
|
+
export let colorful = false;
|
|
5
6
|
export let composed = false;
|
|
6
7
|
export let disabled = false;
|
|
7
8
|
export let selectedValue = void 0;
|
|
8
9
|
export let expandedValues = [];
|
|
9
10
|
let treeRef;
|
|
10
|
-
const
|
|
11
|
-
const expandedValuesStore = writable(expandedValues);
|
|
11
|
+
const colorfulStore = writable(colorful);
|
|
12
12
|
const disabledStore = writable(disabled);
|
|
13
|
+
const expandedValuesStore = writable(expandedValues);
|
|
14
|
+
const selectedValueStore = writable(selectedValue);
|
|
13
15
|
export const blur = () => {
|
|
14
16
|
treeRef?.blur();
|
|
15
17
|
};
|
|
@@ -37,13 +39,17 @@ $: {
|
|
|
37
39
|
expandedValues = $expandedValuesStore;
|
|
38
40
|
raiseExpandCollapse($expandedValuesStore);
|
|
39
41
|
}
|
|
42
|
+
$: {
|
|
43
|
+
colorfulStore.set(colorful);
|
|
44
|
+
}
|
|
40
45
|
$: {
|
|
41
46
|
disabledStore.set(disabled);
|
|
42
47
|
}
|
|
43
48
|
setContext(TREE_CONTEXT_KEY, {
|
|
49
|
+
colorful: colorfulStore,
|
|
50
|
+
disabled: disabledStore,
|
|
44
51
|
expandedValues: expandedValuesStore,
|
|
45
|
-
selectedValue: selectedValueStore
|
|
46
|
-
disabled: disabledStore
|
|
52
|
+
selectedValue: selectedValueStore
|
|
47
53
|
});
|
|
48
54
|
</script>
|
|
49
55
|
|
|
@@ -52,6 +58,7 @@ setContext(TREE_CONTEXT_KEY, {
|
|
|
52
58
|
bind:this={treeRef}
|
|
53
59
|
aria-disabled={disabled}
|
|
54
60
|
class="sterling-tree"
|
|
61
|
+
class:colorful
|
|
55
62
|
class:composed
|
|
56
63
|
class:disabled
|
|
57
64
|
class:using-keyboard={$usingKeyboard}
|
|
@@ -86,23 +93,23 @@ setContext(TREE_CONTEXT_KEY, {
|
|
|
86
93
|
on:pointerover
|
|
87
94
|
on:pointerout
|
|
88
95
|
on:pointerup
|
|
89
|
-
on:wheel
|
|
96
|
+
on:wheel|passive
|
|
90
97
|
{...$$restProps}
|
|
91
98
|
>
|
|
92
99
|
<div class="container">
|
|
93
|
-
<slot {composed} {disabled} />
|
|
100
|
+
<slot {colorful} {composed} {disabled} />
|
|
94
101
|
</div>
|
|
95
102
|
</div>
|
|
96
103
|
|
|
97
104
|
<style>
|
|
98
105
|
.sterling-tree {
|
|
99
|
-
background-color: var(--stsv-
|
|
100
|
-
border-color: var(--stsv-
|
|
101
|
-
border-radius: var(--stsv-
|
|
102
|
-
border-style: var(--stsv-
|
|
103
|
-
border-width: var(--stsv-
|
|
106
|
+
background-color: var(--stsv-common__background-color);
|
|
107
|
+
border-color: var(--stsv-common__border-color);
|
|
108
|
+
border-radius: var(--stsv-common__border-radius);
|
|
109
|
+
border-style: var(--stsv-common__border-style);
|
|
110
|
+
border-width: var(--stsv-common__border-width);
|
|
104
111
|
box-sizing: border-box;
|
|
105
|
-
color: var(--stsv-
|
|
112
|
+
color: var(--stsv-common__color);
|
|
106
113
|
height: 100%;
|
|
107
114
|
overflow-x: hidden;
|
|
108
115
|
overflow-y: auto;
|
|
@@ -111,17 +118,17 @@ setContext(TREE_CONTEXT_KEY, {
|
|
|
111
118
|
}
|
|
112
119
|
|
|
113
120
|
.sterling-tree:hover {
|
|
114
|
-
border-color: var(--stsv-
|
|
115
|
-
color: var(--stsv-
|
|
121
|
+
border-color: var(--stsv-input__border-color--hover);
|
|
122
|
+
color: var(--stsv-input__color--hover);
|
|
116
123
|
}
|
|
117
124
|
|
|
118
125
|
.sterling-tree.using-keyboard:focus-within {
|
|
119
|
-
border-color: var(--stsv-
|
|
120
|
-
color: var(--stsv-
|
|
121
|
-
outline-color: var(--stsv-
|
|
122
|
-
outline-offset: var(--stsv-
|
|
123
|
-
outline-style: var(--stsv-
|
|
124
|
-
outline-width: var(--stsv-
|
|
126
|
+
border-color: var(--stsv-button__border-color--focus);
|
|
127
|
+
color: var(--stsv-input__color--focus);
|
|
128
|
+
outline-color: var(--stsv-common__outline-color);
|
|
129
|
+
outline-offset: var(--stsv-common__outline-offset);
|
|
130
|
+
outline-style: var(--stsv-common__outline-style);
|
|
131
|
+
outline-width: var(--stsv-common__outline-width);
|
|
125
132
|
}
|
|
126
133
|
|
|
127
134
|
.sterling-tree.composed,
|
|
@@ -147,7 +154,13 @@ setContext(TREE_CONTEXT_KEY, {
|
|
|
147
154
|
}
|
|
148
155
|
|
|
149
156
|
.container::after {
|
|
150
|
-
background:
|
|
157
|
+
background: repeating-linear-gradient(
|
|
158
|
+
45deg,
|
|
159
|
+
var(--stsv-common__background-color1--disabled),
|
|
160
|
+
var(--stsv-common__background-color1--disabled) 3px,
|
|
161
|
+
var(--stsv-common__background-color2--disabled) 3px,
|
|
162
|
+
var(--stsv-common__background-color2--disabled) 6px
|
|
163
|
+
);
|
|
151
164
|
bottom: 0;
|
|
152
165
|
content: '';
|
|
153
166
|
left: 0;
|
package/Tree.svelte.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
+
colorful?: boolean | undefined;
|
|
5
6
|
composed?: boolean | undefined;
|
|
6
7
|
disabled?: boolean | undefined;
|
|
7
8
|
selectedValue?: string | undefined;
|
|
@@ -48,6 +49,7 @@ declare const __propDef: {
|
|
|
48
49
|
};
|
|
49
50
|
slots: {
|
|
50
51
|
default: {
|
|
52
|
+
colorful: boolean;
|
|
51
53
|
composed: boolean;
|
|
52
54
|
disabled: boolean;
|
|
53
55
|
};
|
package/Tree.types.d.ts
CHANGED
package/TreeChevron.svelte
CHANGED
package/TreeItem.svelte
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { slide } from "svelte/transition";
|
|
3
3
|
import { TREE_CONTEXT_KEY, TREE_ITEM_CONTEXT_KEY } from "./Tree.constants";
|
|
4
4
|
import TreeItemDisplay from "./TreeItemDisplay.svelte";
|
|
5
|
-
import { writable } from "svelte/store";
|
|
5
|
+
import { readable, writable } from "svelte/store";
|
|
6
6
|
import { prefersReducedMotion } from "./stores/prefersReducedMotion";
|
|
7
7
|
export let disabled = false;
|
|
8
|
+
export let label = void 0;
|
|
8
9
|
export let value;
|
|
9
10
|
const slidNoOp = (node, params) => {
|
|
10
11
|
return { delay: 0, duration: 0 };
|
|
@@ -12,11 +13,17 @@ const slidNoOp = (node, params) => {
|
|
|
12
13
|
$:
|
|
13
14
|
slideMotion = !$prefersReducedMotion ? slide : slidNoOp;
|
|
14
15
|
const {
|
|
16
|
+
colorful,
|
|
17
|
+
disabled: treeDisabled,
|
|
15
18
|
expandedValues,
|
|
16
|
-
selectedValue
|
|
17
|
-
disabled: treeDisabled
|
|
19
|
+
selectedValue
|
|
18
20
|
} = getContext(TREE_CONTEXT_KEY);
|
|
19
|
-
const { depth = 0 } = getContext(TREE_ITEM_CONTEXT_KEY) || {
|
|
21
|
+
const { depth = 0 } = getContext(TREE_ITEM_CONTEXT_KEY) || {
|
|
22
|
+
colorful: readable(false),
|
|
23
|
+
disabled: readable(false),
|
|
24
|
+
expandedValues: readable([]),
|
|
25
|
+
selectedValue: readable(void 0)
|
|
26
|
+
};
|
|
20
27
|
let treeItemRef;
|
|
21
28
|
$:
|
|
22
29
|
hasChildren = $$slots.default;
|
|
@@ -244,6 +251,7 @@ A item in a Tree displaying the item and children.
|
|
|
244
251
|
aria-expanded={expanded}
|
|
245
252
|
bind:this={treeItemRef}
|
|
246
253
|
class="sterling-tree-item"
|
|
254
|
+
class:colorful={$colorful}
|
|
247
255
|
class:disabled={_disabled}
|
|
248
256
|
data-value={value}
|
|
249
257
|
role="treeitem"
|
|
@@ -277,7 +285,7 @@ A item in a Tree displaying the item and children.
|
|
|
277
285
|
on:pointerover
|
|
278
286
|
on:pointerout
|
|
279
287
|
on:pointerup
|
|
280
|
-
on:wheel
|
|
288
|
+
on:wheel|passive
|
|
281
289
|
{...$$restProps}
|
|
282
290
|
>
|
|
283
291
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
@@ -289,10 +297,33 @@ A item in a Tree displaying the item and children.
|
|
|
289
297
|
on:keydown={onKeydown}
|
|
290
298
|
>
|
|
291
299
|
<slot name="item" {depth} disabled={_disabled} {expanded} {hasChildren} {selected} {value}>
|
|
292
|
-
<TreeItemDisplay
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
300
|
+
<TreeItemDisplay
|
|
301
|
+
colorful={$colorful}
|
|
302
|
+
{depth}
|
|
303
|
+
disabled={_disabled}
|
|
304
|
+
{expanded}
|
|
305
|
+
{hasChildren}
|
|
306
|
+
{selected}
|
|
307
|
+
{value}
|
|
308
|
+
>
|
|
309
|
+
<svelte:fragment
|
|
310
|
+
let:colorful
|
|
311
|
+
let:depth
|
|
312
|
+
let:disabled
|
|
313
|
+
let:expanded
|
|
314
|
+
let:hasChildren
|
|
315
|
+
let:selected
|
|
316
|
+
let:value
|
|
317
|
+
>
|
|
318
|
+
<slot
|
|
319
|
+
name="label"
|
|
320
|
+
{colorful}
|
|
321
|
+
{depth}
|
|
322
|
+
{disabled}
|
|
323
|
+
{expanded}
|
|
324
|
+
{hasChildren}
|
|
325
|
+
{selected}
|
|
326
|
+
{value}>{label || value}</slot
|
|
296
327
|
>
|
|
297
328
|
</svelte:fragment>
|
|
298
329
|
</TreeItemDisplay>
|
package/TreeItem.svelte.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ declare const __propDef: {
|
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
disabled?: boolean | undefined;
|
|
6
|
+
label?: string | undefined;
|
|
6
7
|
value: string;
|
|
7
8
|
collapse?: (() => boolean) | undefined;
|
|
8
9
|
expand?: (() => boolean) | undefined;
|
|
@@ -60,6 +61,7 @@ declare const __propDef: {
|
|
|
60
61
|
value: string;
|
|
61
62
|
};
|
|
62
63
|
label: {
|
|
64
|
+
colorful: import("svelte/store").Readable<boolean>;
|
|
63
65
|
depth: number;
|
|
64
66
|
disabled: boolean;
|
|
65
67
|
expanded: boolean;
|
package/TreeItemDisplay.svelte
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { TREE_CONTEXT_KEY } from "./Tree.constants";
|
|
3
3
|
import TreeChevron from "./TreeChevron.svelte";
|
|
4
4
|
import { readable } from "svelte/store";
|
|
5
|
+
export let colorful = false;
|
|
5
6
|
export let depth = 0;
|
|
6
7
|
export let disabled = false;
|
|
7
8
|
export let expanded = false;
|
|
@@ -26,6 +27,7 @@ export const focus = (options) => {
|
|
|
26
27
|
<div
|
|
27
28
|
bind:this={divRef}
|
|
28
29
|
class="sterling-tree-item-display"
|
|
30
|
+
class:colorful
|
|
29
31
|
class:disabled={disabled && !$treeDisabled}
|
|
30
32
|
class:item-disabled={disabled}
|
|
31
33
|
class:expanded
|
|
@@ -61,11 +63,11 @@ export const focus = (options) => {
|
|
|
61
63
|
on:pointerover
|
|
62
64
|
on:pointerout
|
|
63
65
|
on:pointerup
|
|
64
|
-
on:wheel
|
|
66
|
+
on:wheel|passive
|
|
65
67
|
{...$$restProps}
|
|
66
68
|
>
|
|
67
69
|
<TreeChevron {expanded} {hasChildren} />
|
|
68
|
-
<slot {depth} {disabled} {expanded} {hasChildren} {selected} {value} />
|
|
70
|
+
<slot {colorful} {depth} {disabled} {expanded} {hasChildren} {selected} {value} />
|
|
69
71
|
</div>
|
|
70
72
|
|
|
71
73
|
<style>
|
|
@@ -74,7 +76,7 @@ export const focus = (options) => {
|
|
|
74
76
|
align-items: center;
|
|
75
77
|
background-color: transparent;
|
|
76
78
|
box-sizing: border-box;
|
|
77
|
-
color: var(--stsv-
|
|
79
|
+
color: var(--stsv-input__color);
|
|
78
80
|
display: grid;
|
|
79
81
|
grid-template-columns: auto 1fr;
|
|
80
82
|
column-gap: 0.25em;
|
|
@@ -89,13 +91,23 @@ export const focus = (options) => {
|
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
.sterling-tree-item-display:not(.item-disabled):not(.selected):hover {
|
|
92
|
-
background-color: var(--stsv-
|
|
93
|
-
color: var(--stsv-
|
|
94
|
+
background-color: var(--stsv-button__background-color--hover);
|
|
95
|
+
color: var(--stsv-button__color--hover);
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
.sterling-tree-item-display.selected {
|
|
97
|
-
background-color: var(--stsv-
|
|
98
|
-
color: var(--stsv-
|
|
99
|
+
background-color: var(--stsv-button__background-color--active);
|
|
100
|
+
color: var(--stsv-button__color--active);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.sterling-tree-item-display.colorful:not(.item-disabled):not(.selected):hover {
|
|
104
|
+
background-color: var(--stsv-button--colorful__background-color--hover);
|
|
105
|
+
color: var(--stsv-button--colorful__color--hover);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.sterling-tree-item-display.colorful.selected {
|
|
109
|
+
background-color: var(--stsv-button--colorful__background-color--active);
|
|
110
|
+
color: var(--stsv-button--colorful__color--active);
|
|
99
111
|
}
|
|
100
112
|
|
|
101
113
|
.sterling-tree-item-display.disabled {
|
|
@@ -104,7 +116,13 @@ export const focus = (options) => {
|
|
|
104
116
|
}
|
|
105
117
|
|
|
106
118
|
.sterling-tree-item-display::after {
|
|
107
|
-
background:
|
|
119
|
+
background: repeating-linear-gradient(
|
|
120
|
+
45deg,
|
|
121
|
+
var(--stsv-common__background-color1--disabled),
|
|
122
|
+
var(--stsv-common__background-color1--disabled) 3px,
|
|
123
|
+
var(--stsv-common__background-color2--disabled) 3px,
|
|
124
|
+
var(--stsv-common__background-color2--disabled) 6px
|
|
125
|
+
);
|
|
108
126
|
bottom: 0;
|
|
109
127
|
content: '';
|
|
110
128
|
left: 0;
|
|
@@ -2,6 +2,7 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
+
colorful?: boolean | undefined;
|
|
5
6
|
depth?: number | undefined;
|
|
6
7
|
disabled?: boolean | undefined;
|
|
7
8
|
expanded?: boolean | undefined;
|
|
@@ -49,6 +50,7 @@ declare const __propDef: {
|
|
|
49
50
|
};
|
|
50
51
|
slots: {
|
|
51
52
|
default: {
|
|
53
|
+
colorful: boolean;
|
|
52
54
|
depth: number;
|
|
53
55
|
disabled: boolean;
|
|
54
56
|
expanded: boolean;
|
package/actions/clickOutside.js
CHANGED
|
@@ -9,7 +9,7 @@ export const clickOutside = (node, params) => {
|
|
|
9
9
|
const targetNode = event?.target;
|
|
10
10
|
if (targetNode &&
|
|
11
11
|
!node.contains(targetNode) &&
|
|
12
|
-
(!ignoreOthers || ignoreOthers.every((x) => !x.contains(targetNode)))) {
|
|
12
|
+
(!ignoreOthers || ignoreOthers.filter(Boolean).every((x) => !x.contains(targetNode)))) {
|
|
13
13
|
node.dispatchEvent(new CustomEvent('click_outside', {
|
|
14
14
|
detail: { mouseEvent: event }
|
|
15
15
|
}));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const getFirstFocusable = (node) => {
|
|
2
|
+
// we can't select [tabIndex] as many elements don't have tabIndex as a declared property
|
|
3
|
+
// but do default to tabIndex >= 0.
|
|
4
|
+
const nodes = node.querySelectorAll('*');
|
|
5
|
+
const elements = Array.from(nodes)
|
|
6
|
+
.map((n) => n)
|
|
7
|
+
.filter((n) => n.tabIndex !== undefined && n.tabIndex >= 0);
|
|
8
|
+
return elements.length > 0 ? elements[0] : null;
|
|
9
|
+
};
|
|
10
|
+
const getLastFocusable = (node) => {
|
|
11
|
+
// we can't select [tabIndex] as many elements don't have tabIndex as a declared property
|
|
12
|
+
// but do default to tabIndex >= 0.
|
|
13
|
+
const nodes = node.querySelectorAll('*');
|
|
14
|
+
const elements = Array.from(nodes)
|
|
15
|
+
.map((n) => n)
|
|
16
|
+
.filter((n) => n.tabIndex !== undefined && n.tabIndex >= 0);
|
|
17
|
+
return elements.length > 0 ? elements[elements.length - 1] : null;
|
|
18
|
+
};
|
|
19
|
+
export const trapKeyboardFocus = (node) => {
|
|
20
|
+
const onKeydown = (e) => {
|
|
21
|
+
let handledFocus = false;
|
|
22
|
+
if (e.key === 'Tab') {
|
|
23
|
+
if (e.shiftKey) {
|
|
24
|
+
const firstFocusable = getFirstFocusable(node);
|
|
25
|
+
if (document.activeElement === firstFocusable) {
|
|
26
|
+
const lastFocusable = getLastFocusable(node);
|
|
27
|
+
lastFocusable?.focus();
|
|
28
|
+
handledFocus = true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const lastFocusable = getLastFocusable(node);
|
|
33
|
+
if (document.activeElement === lastFocusable) {
|
|
34
|
+
const firstFocusable = getFirstFocusable(node);
|
|
35
|
+
firstFocusable?.focus();
|
|
36
|
+
handledFocus = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (handledFocus) {
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
node.addEventListener('keydown', onKeydown);
|
|
47
|
+
return {
|
|
48
|
+
destroy: () => {
|
|
49
|
+
node.removeEventListener('keydown', onKeydown);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
package/floating-ui.types.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { clickOutside } from './actions/clickOutside';
|
|
2
2
|
export { forwardEvents } from './actions/forwardEvents';
|
|
3
3
|
export { portal } from './actions/portal';
|
|
4
|
+
export { trapKeyboardFocus } from './actions/trapKeyboardFocus';
|
|
4
5
|
export { idGenerator } from './idGenerator';
|
|
5
6
|
export { type Theme, type ThemeActionParams } from './theme/types';
|
|
6
7
|
export { applyDarkTheme } from './theme/applyDarkTheme';
|
|
@@ -8,11 +9,11 @@ export { applyLightTheme } from './theme/applyLightTheme';
|
|
|
8
9
|
export { applyTheme } from './theme/applyTheme';
|
|
9
10
|
export { darkTheme } from './theme/darkTheme';
|
|
10
11
|
export { lightTheme } from './theme/lightTheme';
|
|
11
|
-
export { neutralColors, lightStatusColors, darkStatusColors } from './theme/colors';
|
|
12
|
+
export { neutralColors, lightStatusColors, darkStatusColors, blueColors as blueAccentColors } from './theme/colors';
|
|
12
13
|
export { toggleDarkTheme } from './theme/toggleDarkTheme';
|
|
13
14
|
export type { ButtonVariant, ButtonShape } from './Button.types';
|
|
14
15
|
export type { FieldStatus } from './Field.types';
|
|
15
|
-
export type { FloatingPlacement } from './floating-ui.types';
|
|
16
|
+
export type { FloatingPlacement, FloatingOffsetOptions } from './floating-ui.types';
|
|
16
17
|
export type { LinkVariant } from './Link.types';
|
|
17
18
|
export type { ListContext } from './List.types';
|
|
18
19
|
export type { MenuBarContext } from './MenuBar.types';
|
|
@@ -37,9 +38,12 @@ export { TOOLTIP_SHOW_ONS } from './Tooltip.constants';
|
|
|
37
38
|
export { TREE_CONTEXT_KEY as treeContextKey, TREE_ITEM_CONTEXT_KEY as treeItemContextKey } from './Tree.constants';
|
|
38
39
|
import Button from './Button.svelte';
|
|
39
40
|
import Checkbox from './Checkbox.svelte';
|
|
41
|
+
import ColorPicker from './ColorPicker.svelte';
|
|
40
42
|
import Dialog from './Dialog.svelte';
|
|
41
43
|
import Dropdown from './Dropdown.svelte';
|
|
42
44
|
import Field from './Field.svelte';
|
|
45
|
+
import HexColorSliders from './HexColorSliders.svelte';
|
|
46
|
+
import HslColorSliders from './HslColorSliders.svelte';
|
|
43
47
|
import Input from './Input.svelte';
|
|
44
48
|
import Label from './Label.svelte';
|
|
45
49
|
import Link from './Link.svelte';
|
|
@@ -54,6 +58,7 @@ import MenuSeparator from './MenuSeparator.svelte';
|
|
|
54
58
|
import Popover from './Popover.svelte';
|
|
55
59
|
import Progress from './Progress.svelte';
|
|
56
60
|
import Radio from './Radio.svelte';
|
|
61
|
+
import RgbColorSliders from './RgbColorSliders.svelte';
|
|
57
62
|
import Select from './Select.svelte';
|
|
58
63
|
import Slider from './Slider.svelte';
|
|
59
64
|
import Switch from './Switch.svelte';
|
|
@@ -65,4 +70,4 @@ import Tree from './Tree.svelte';
|
|
|
65
70
|
import TreeChevron from './TreeChevron.svelte';
|
|
66
71
|
import TreeItem from './TreeItem.svelte';
|
|
67
72
|
import TreeItemDisplay from './TreeItemDisplay.svelte';
|
|
68
|
-
export { Button, Checkbox, Dialog, Dropdown, Field, Input, Label, Link, List, ListItem, Menu, MenuBar, MenuButton, MenuItem, MenuItemDisplay, MenuSeparator, Popover, Progress, Radio, Select, Slider, Switch, Tab, TabList, TextArea, Tooltip, Tree, TreeChevron, TreeItem, TreeItemDisplay };
|
|
73
|
+
export { Button, Checkbox, ColorPicker, Dialog, Dropdown, Field, HexColorSliders, HslColorSliders, Input, Label, Link, List, ListItem, Menu, MenuBar, MenuButton, MenuItem, MenuItemDisplay, MenuSeparator, Popover, Progress, Radio, RgbColorSliders, Select, Slider, Switch, Tab, TabList, TextArea, Tooltip, Tree, TreeChevron, TreeItem, TreeItemDisplay };
|
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export { clickOutside } from './actions/clickOutside';
|
|
3
3
|
export { forwardEvents } from './actions/forwardEvents';
|
|
4
4
|
export { portal } from './actions/portal';
|
|
5
|
+
export { trapKeyboardFocus } from './actions/trapKeyboardFocus';
|
|
5
6
|
// ----- functions ----- //
|
|
6
7
|
export { idGenerator } from './idGenerator';
|
|
7
8
|
// ----- theme ----- //
|
|
@@ -11,7 +12,7 @@ export { applyLightTheme } from './theme/applyLightTheme';
|
|
|
11
12
|
export { applyTheme } from './theme/applyTheme';
|
|
12
13
|
export { darkTheme } from './theme/darkTheme';
|
|
13
14
|
export { lightTheme } from './theme/lightTheme';
|
|
14
|
-
export { neutralColors, lightStatusColors, darkStatusColors } from './theme/colors';
|
|
15
|
+
export { neutralColors, lightStatusColors, darkStatusColors, blueColors as blueAccentColors } from './theme/colors';
|
|
15
16
|
export { toggleDarkTheme } from './theme/toggleDarkTheme';
|
|
16
17
|
// ----- Component constants ----- //
|
|
17
18
|
export { BUTTON_SHAPES, BUTTON_VARIANTS } from './Button.constants';
|
|
@@ -29,9 +30,12 @@ export { TREE_CONTEXT_KEY as treeContextKey, TREE_ITEM_CONTEXT_KEY as treeItemCo
|
|
|
29
30
|
// ----- Components ----- //
|
|
30
31
|
import Button from './Button.svelte';
|
|
31
32
|
import Checkbox from './Checkbox.svelte';
|
|
33
|
+
import ColorPicker from './ColorPicker.svelte';
|
|
32
34
|
import Dialog from './Dialog.svelte';
|
|
33
35
|
import Dropdown from './Dropdown.svelte';
|
|
34
36
|
import Field from './Field.svelte';
|
|
37
|
+
import HexColorSliders from './HexColorSliders.svelte';
|
|
38
|
+
import HslColorSliders from './HslColorSliders.svelte';
|
|
35
39
|
import Input from './Input.svelte';
|
|
36
40
|
import Label from './Label.svelte';
|
|
37
41
|
import Link from './Link.svelte';
|
|
@@ -46,6 +50,7 @@ import MenuSeparator from './MenuSeparator.svelte';
|
|
|
46
50
|
import Popover from './Popover.svelte';
|
|
47
51
|
import Progress from './Progress.svelte';
|
|
48
52
|
import Radio from './Radio.svelte';
|
|
53
|
+
import RgbColorSliders from './RgbColorSliders.svelte';
|
|
49
54
|
import Select from './Select.svelte';
|
|
50
55
|
import Slider from './Slider.svelte';
|
|
51
56
|
import Switch from './Switch.svelte';
|
|
@@ -57,4 +62,4 @@ import Tree from './Tree.svelte';
|
|
|
57
62
|
import TreeChevron from './TreeChevron.svelte';
|
|
58
63
|
import TreeItem from './TreeItem.svelte';
|
|
59
64
|
import TreeItemDisplay from './TreeItemDisplay.svelte';
|
|
60
|
-
export { Button, Checkbox, Dialog, Dropdown, Field, Input, Label, Link, List, ListItem, Menu, MenuBar, MenuButton, MenuItem, MenuItemDisplay, MenuSeparator, Popover, Progress, Radio, Select, Slider, Switch, Tab, TabList, TextArea, Tooltip, Tree, TreeChevron, TreeItem, TreeItemDisplay };
|
|
65
|
+
export { Button, Checkbox, ColorPicker, Dialog, Dropdown, Field, HexColorSliders, HslColorSliders, Input, Label, Link, List, ListItem, Menu, MenuBar, MenuButton, MenuItem, MenuItemDisplay, MenuSeparator, Popover, Progress, Radio, RgbColorSliders, Select, Slider, Switch, Tab, TabList, TextArea, Tooltip, Tree, TreeChevron, TreeItem, TreeItemDisplay };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geoffcox/sterling-svelte",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"author": "Geoff Cox",
|
|
5
5
|
"description": "A modern, accessible, and lightweight component library for Svelte.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@sveltejs/kit": "^1.5.0",
|
|
27
27
|
"@sveltejs/package": "^1.0.0",
|
|
28
28
|
"@types/lodash-es": "^4.17.6",
|
|
29
|
+
"@types/tinycolor2": "^1.4.3",
|
|
29
30
|
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
|
30
31
|
"@typescript-eslint/parser": "^5.45.0",
|
|
31
32
|
"eslint": "^8.28.0",
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
},
|
|
44
45
|
"type": "module",
|
|
45
46
|
"dependencies": {
|
|
47
|
+
"@ctrl/tinycolor": "^3.6.0",
|
|
46
48
|
"@floating-ui/dom": "^1.1.0",
|
|
47
49
|
"keyborg": "^2.0.0",
|
|
48
50
|
"lodash-es": "^4.17.21"
|
|
@@ -53,11 +55,16 @@
|
|
|
53
55
|
"./Button.svelte": "./Button.svelte",
|
|
54
56
|
"./Button.types": "./Button.types.js",
|
|
55
57
|
"./Checkbox.svelte": "./Checkbox.svelte",
|
|
58
|
+
"./ColorPicker.constants": "./ColorPicker.constants.js",
|
|
59
|
+
"./ColorPicker.svelte": "./ColorPicker.svelte",
|
|
60
|
+
"./ColorPicker.types": "./ColorPicker.types.js",
|
|
56
61
|
"./Dialog.svelte": "./Dialog.svelte",
|
|
57
62
|
"./Dropdown.svelte": "./Dropdown.svelte",
|
|
58
63
|
"./Field.constants": "./Field.constants.js",
|
|
59
64
|
"./Field.svelte": "./Field.svelte",
|
|
60
65
|
"./Field.types": "./Field.types.js",
|
|
66
|
+
"./HexColorSliders.svelte": "./HexColorSliders.svelte",
|
|
67
|
+
"./HslColorSliders.svelte": "./HslColorSliders.svelte",
|
|
61
68
|
"./Input.svelte": "./Input.svelte",
|
|
62
69
|
"./Label.svelte": "./Label.svelte",
|
|
63
70
|
"./Link.constants": "./Link.constants.js",
|
|
@@ -83,6 +90,7 @@
|
|
|
83
90
|
"./Progress.svelte": "./Progress.svelte",
|
|
84
91
|
"./Progress.types": "./Progress.types.js",
|
|
85
92
|
"./Radio.svelte": "./Radio.svelte",
|
|
93
|
+
"./RgbColorSliders.svelte": "./RgbColorSliders.svelte",
|
|
86
94
|
"./Select.svelte": "./Select.svelte",
|
|
87
95
|
"./Slider.svelte": "./Slider.svelte",
|
|
88
96
|
"./Switch.svelte": "./Switch.svelte",
|
|
@@ -106,6 +114,7 @@
|
|
|
106
114
|
"./actions/clickOutside": "./actions/clickOutside.js",
|
|
107
115
|
"./actions/forwardEvents": "./actions/forwardEvents.js",
|
|
108
116
|
"./actions/portal": "./actions/portal.js",
|
|
117
|
+
"./actions/trapKeyboardFocus": "./actions/trapKeyboardFocus.js",
|
|
109
118
|
"./floating-ui.constants": "./floating-ui.constants.js",
|
|
110
119
|
"./floating-ui.types": "./floating-ui.types.js",
|
|
111
120
|
"./idGenerator": "./idGenerator.js",
|
package/theme/applyTheme.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const _applyTheme = (node, theme) => {
|
|
2
2
|
Object.keys(theme).map((key) => {
|
|
3
|
-
node.style.setProperty(key
|
|
3
|
+
node.style.setProperty(`--${key}`, theme[key] ? `${theme[key]}` : null);
|
|
4
4
|
});
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
@@ -12,7 +12,8 @@ export const applyTheme = (node, params) => {
|
|
|
12
12
|
return {
|
|
13
13
|
update: (params) => {
|
|
14
14
|
if (params) {
|
|
15
|
-
|
|
15
|
+
const element = params.atDocumentRoot ? document.documentElement : node;
|
|
16
|
+
_applyTheme(element, params?.theme);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
};
|
package/theme/colors.d.ts
CHANGED
package/theme/colors.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export const neutralColors = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
color0: 'hsl(0, 0%, 0%)',
|
|
3
|
+
color1: 'hsl(0, 0%, 12%)',
|
|
4
|
+
color2: 'hsl(0, 0%, 15%)',
|
|
5
|
+
color3: 'hsl(0, 0%, 20%)',
|
|
6
|
+
color4: 'hsl(0, 0%, 30%)',
|
|
7
|
+
color5: 'hsl(0, 0%, 45%)',
|
|
8
|
+
color6: 'hsl(0, 0%, 60%)',
|
|
9
|
+
color7: 'hsl(0, 0%, 75%)',
|
|
10
|
+
color8: 'hsl(0, 0%, 85%)',
|
|
11
|
+
color9: 'hsl(0, 0%, 92%)',
|
|
12
|
+
color10: 'hsl(0, 0%, 96%)',
|
|
13
|
+
color11: 'hsl(0, 0%, 98%)',
|
|
14
|
+
color12: 'hsl(0, 0%, 100%)'
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* Status colors for a light theme.
|
|
@@ -65,3 +65,18 @@ export const darkStatusColors = {
|
|
|
65
65
|
color: 'hsl(5, 100%, 50%)'
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
+
export const blueColors = {
|
|
69
|
+
color0: 'hsl(204, 100%, 0%)',
|
|
70
|
+
color1: 'hsl(204, 100%, 18%)',
|
|
71
|
+
color2: 'hsl(204, 100%, 25%)',
|
|
72
|
+
color3: 'hsl(204, 100%, 30%)',
|
|
73
|
+
color4: 'hsl(204, 100%, 35%)',
|
|
74
|
+
color5: 'hsl(204, 100%, 42%)',
|
|
75
|
+
color6: 'hsl(204, 100%, 50%)',
|
|
76
|
+
color7: 'hsl(204, 100%, 60%)',
|
|
77
|
+
color8: 'hsl(204, 100%, 70%)',
|
|
78
|
+
color9: 'hsl(204, 100%, 80%)',
|
|
79
|
+
color10: 'hsl(204, 100%, 90%)',
|
|
80
|
+
color11: 'hsl(204, 100%, 98%)',
|
|
81
|
+
color12: 'hsl(204, 100%, 100%)'
|
|
82
|
+
};
|