@geoffcox/sterling-svelte 0.0.25 → 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 +88 -47
- package/Dropdown.svelte.d.ts +4 -0
- package/Field.svelte +34 -46
- 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 +31 -30
- 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 +92 -121
- package/Menu.svelte.d.ts +8 -2
- package/MenuBar.svelte +77 -32
- package/MenuBar.types.d.ts +2 -2
- package/MenuButton.svelte +48 -28
- package/MenuItem.constants.d.ts +1 -0
- package/MenuItem.constants.js +1 -0
- package/MenuItem.svelte +202 -139
- package/MenuItem.svelte.d.ts +7 -3
- package/MenuItem.types.d.ts +14 -5
- package/MenuItem.utils.d.ts +2 -0
- package/MenuItem.utils.js +16 -0
- package/MenuItemDisplay.svelte +9 -2
- package/MenuItemDisplay.svelte.d.ts +1 -0
- package/MenuSeparator.svelte +3 -3
- package/Popover.svelte +68 -64
- 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 +50 -32
- 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 +53 -30
- package/TabList.svelte +23 -28
- package/TabList.svelte.d.ts +1 -0
- package/TabList.types.d.ts +1 -1
- package/TextArea.svelte +45 -20
- package/TextArea.svelte.d.ts +3 -2
- package/Tooltip.svelte +12 -11
- package/Tree.svelte +37 -35
- package/Tree.svelte.d.ts +2 -0
- package/Tree.types.d.ts +1 -0
- package/TreeChevron.svelte +1 -1
- package/TreeItem.svelte +47 -10
- 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 +10 -5
- package/index.js +8 -3
- package/package.json +12 -1
- package/stores/prefersReducedMotion.d.ts +1 -0
- package/stores/prefersReducedMotion.js +10 -0
- package/stores/usingKeyboard.d.ts +1 -0
- package/stores/usingKeyboard.js +13 -0
- 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/TreeItem.svelte
CHANGED
|
@@ -2,15 +2,28 @@
|
|
|
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
|
+
import { prefersReducedMotion } from "./stores/prefersReducedMotion";
|
|
6
7
|
export let disabled = false;
|
|
8
|
+
export let label = void 0;
|
|
7
9
|
export let value;
|
|
10
|
+
const slidNoOp = (node, params) => {
|
|
11
|
+
return { delay: 0, duration: 0 };
|
|
12
|
+
};
|
|
13
|
+
$:
|
|
14
|
+
slideMotion = !$prefersReducedMotion ? slide : slidNoOp;
|
|
8
15
|
const {
|
|
16
|
+
colorful,
|
|
17
|
+
disabled: treeDisabled,
|
|
9
18
|
expandedValues,
|
|
10
|
-
selectedValue
|
|
11
|
-
disabled: treeDisabled
|
|
19
|
+
selectedValue
|
|
12
20
|
} = getContext(TREE_CONTEXT_KEY);
|
|
13
|
-
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
|
+
};
|
|
14
27
|
let treeItemRef;
|
|
15
28
|
$:
|
|
16
29
|
hasChildren = $$slots.default;
|
|
@@ -238,6 +251,7 @@ A item in a Tree displaying the item and children.
|
|
|
238
251
|
aria-expanded={expanded}
|
|
239
252
|
bind:this={treeItemRef}
|
|
240
253
|
class="sterling-tree-item"
|
|
254
|
+
class:colorful={$colorful}
|
|
241
255
|
class:disabled={_disabled}
|
|
242
256
|
data-value={value}
|
|
243
257
|
role="treeitem"
|
|
@@ -271,7 +285,7 @@ A item in a Tree displaying the item and children.
|
|
|
271
285
|
on:pointerover
|
|
272
286
|
on:pointerout
|
|
273
287
|
on:pointerup
|
|
274
|
-
on:wheel
|
|
288
|
+
on:wheel|passive
|
|
275
289
|
{...$$restProps}
|
|
276
290
|
>
|
|
277
291
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
@@ -283,17 +297,40 @@ A item in a Tree displaying the item and children.
|
|
|
283
297
|
on:keydown={onKeydown}
|
|
284
298
|
>
|
|
285
299
|
<slot name="item" {depth} disabled={_disabled} {expanded} {hasChildren} {selected} {value}>
|
|
286
|
-
<TreeItemDisplay
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
|
290
327
|
>
|
|
291
328
|
</svelte:fragment>
|
|
292
329
|
</TreeItemDisplay>
|
|
293
330
|
</slot>
|
|
294
331
|
</div>
|
|
295
332
|
{#if expanded && hasChildren}
|
|
296
|
-
<div class="children" transition:
|
|
333
|
+
<div class="children" transition:slideMotion={{ duration: 200 }} role="group">
|
|
297
334
|
<slot {depth} {selected} {value} />
|
|
298
335
|
</div>
|
|
299
336
|
{/if}
|
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,15 +9,15 @@ 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';
|
|
19
|
-
export type { MenuItemContext, MenuItemRegistration } from './MenuItem.types';
|
|
20
|
+
export type { MenuItemContext, MenuItemRegistration, MenuItemRole } from './MenuItem.types';
|
|
20
21
|
export type { ProgressColorful } from './Progress.types';
|
|
21
22
|
export type { TabListContext } from './TabList.types';
|
|
22
23
|
export type { TextAreaResize } from './TextArea.types';
|
|
@@ -29,7 +30,7 @@ export { FLOATING_PLACEMENTS } from './floating-ui.constants';
|
|
|
29
30
|
export { LINK_VARIANTS } from './Link.constants';
|
|
30
31
|
export { LIST_CONTEXT_KEY } from './List.constants';
|
|
31
32
|
export { MENU_BAR_CONTEXT_KEY } from './MenuBar.constants';
|
|
32
|
-
export { MENU_ITEM_CONTEXT_KEY } from './MenuItem.constants';
|
|
33
|
+
export { MENU_ITEM_CONTEXT_KEY, MENU_ITEM_ROLES } from './MenuItem.constants';
|
|
33
34
|
export { PROGRESS_COLORFULS } from './Progress.constants';
|
|
34
35
|
export { TAB_LIST_CONTEXT_KEY } from './TabList.constants';
|
|
35
36
|
export { TEXT_AREA_RESIZES } from './TextArea.constants';
|
|
@@ -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';
|
|
@@ -20,7 +21,7 @@ export { FLOATING_PLACEMENTS } from './floating-ui.constants';
|
|
|
20
21
|
export { LINK_VARIANTS } from './Link.constants';
|
|
21
22
|
export { LIST_CONTEXT_KEY } from './List.constants';
|
|
22
23
|
export { MENU_BAR_CONTEXT_KEY } from './MenuBar.constants';
|
|
23
|
-
export { MENU_ITEM_CONTEXT_KEY } from './MenuItem.constants';
|
|
24
|
+
export { MENU_ITEM_CONTEXT_KEY, MENU_ITEM_ROLES } from './MenuItem.constants';
|
|
24
25
|
export { PROGRESS_COLORFULS } from './Progress.constants';
|
|
25
26
|
export { TAB_LIST_CONTEXT_KEY } from './TabList.constants';
|
|
26
27
|
export { TEXT_AREA_RESIZES } from './TextArea.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,10 +114,13 @@
|
|
|
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",
|
|
112
121
|
".": "./index.js",
|
|
122
|
+
"./stores/prefersReducedMotion": "./stores/prefersReducedMotion.js",
|
|
123
|
+
"./stores/usingKeyboard": "./stores/usingKeyboard.js",
|
|
113
124
|
"./theme/applyDarkTheme": "./theme/applyDarkTheme.js",
|
|
114
125
|
"./theme/applyLightTheme": "./theme/applyLightTheme.js",
|
|
115
126
|
"./theme/applyTheme": "./theme/applyTheme.js",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const prefersReducedMotion: import("svelte/store").Writable<boolean>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
export const prefersReducedMotion = writable(false, (set) => {
|
|
3
|
+
const matchMedia = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
4
|
+
set(matchMedia.matches);
|
|
5
|
+
const mediaChangeHandler = (e) => set(e.matches);
|
|
6
|
+
matchMedia.addEventListener('change', mediaChangeHandler);
|
|
7
|
+
return () => {
|
|
8
|
+
matchMedia.removeEventListener('change', mediaChangeHandler);
|
|
9
|
+
};
|
|
10
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const usingKeyboard: import("svelte/store").Writable<boolean>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createKeyborg } from 'keyborg';
|
|
2
|
+
import { writable } from 'svelte/store';
|
|
3
|
+
export const usingKeyboard = writable(false, (set) => {
|
|
4
|
+
let keyborg = createKeyborg(window);
|
|
5
|
+
set(keyborg.isNavigatingWithKeyboard());
|
|
6
|
+
const keyborgHandler = (value) => {
|
|
7
|
+
set(value);
|
|
8
|
+
};
|
|
9
|
+
keyborg.subscribe(keyborgHandler);
|
|
10
|
+
return () => {
|
|
11
|
+
keyborg.unsubscribe(keyborgHandler);
|
|
12
|
+
};
|
|
13
|
+
});
|
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
|
+
};
|