@geoffcox/sterling-svelte 0.0.21 → 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/Checkbox.svelte +2 -2
- package/Dropdown.svelte +2 -2
- package/Field.svelte +3 -3
- package/Field.svelte.d.ts +1 -1
- package/Input.svelte +2 -2
- package/List.svelte +0 -3
- package/MenuButton.svelte +3 -3
- package/MenuItem.svelte +2 -2
- package/Radio.svelte +2 -2
- package/Select.svelte +2 -2
- package/Switch.svelte +3 -3
- package/Tree.types.d.ts +0 -12
- package/TreeChevron.svelte +32 -1
- package/TreeChevron.svelte.d.ts +27 -0
- package/TreeItem.types.d.ts +13 -0
- package/TreeItem.types.js +1 -0
- package/TreeItemDisplay.svelte +1 -0
- package/idGenerator.d.ts +4 -0
- package/idGenerator.js +10 -0
- package/index.d.ts +3 -1
- package/index.js +2 -0
- package/package.json +8 -8
- package/theme/toggleDarkTheme.d.ts +1 -1
- package/theme/toggleDarkTheme.js +1 -1
package/Checkbox.svelte
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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;
|
|
@@ -6,7 +6,7 @@ export let id = void 0;
|
|
|
6
6
|
let inputRef;
|
|
7
7
|
$: {
|
|
8
8
|
if ($$slots.default && id === void 0) {
|
|
9
|
-
id =
|
|
9
|
+
id = idGenerator.nextId("Checkbox");
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
export const blur = () => {
|
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;
|
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;
|
|
@@ -146,9 +146,9 @@ const onClick = () => {
|
|
|
146
146
|
</slot>
|
|
147
147
|
{/if}
|
|
148
148
|
{#if required}
|
|
149
|
-
<slot name="required" {
|
|
149
|
+
<slot name="required" requiredTip={requiredReason}>
|
|
150
150
|
<Tooltip showOn="hover">
|
|
151
|
-
<span class="required-tip" slot="tip">{
|
|
151
|
+
<span class="required-tip" slot="tip">{requiredReason}</span>
|
|
152
152
|
<div class="required">*</div>
|
|
153
153
|
</Tooltip>
|
|
154
154
|
</slot>
|
package/Field.svelte.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare const __propDef: {
|
|
|
7
7
|
label?: string | undefined;
|
|
8
8
|
message?: string | undefined;
|
|
9
9
|
required?: boolean | undefined;
|
|
10
|
-
|
|
10
|
+
requiredReason?: string | undefined;
|
|
11
11
|
status?: string | undefined;
|
|
12
12
|
click?: (() => void) | undefined;
|
|
13
13
|
blur?: (() => void) | undefined;
|
package/Input.svelte
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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;
|
|
@@ -7,7 +7,7 @@ export let value = "";
|
|
|
7
7
|
let inputRef;
|
|
8
8
|
$: {
|
|
9
9
|
if ($$slots.default && id === void 0) {
|
|
10
|
-
id =
|
|
10
|
+
id = idGenerator.nextId("Input");
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
export const blur = () => {
|
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 { v4 as uuid } from "uuid";
|
|
5
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);
|
|
@@ -200,7 +198,6 @@ A list of items where a single item can be selected.
|
|
|
200
198
|
class:disabled
|
|
201
199
|
class:horizontal
|
|
202
200
|
class:using-keyboard={usingKeyboard}
|
|
203
|
-
id={listId}
|
|
204
201
|
role="list"
|
|
205
202
|
tabindex={0}
|
|
206
203
|
on:blur
|
package/MenuButton.svelte
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { createEventDispatcher, getContext, setContext } from "svelte";
|
|
1
|
+
<script>import { createEventDispatcher, getContext, setContext } from "svelte";
|
|
3
2
|
import { writable } from "svelte/store";
|
|
4
3
|
import Button from "./Button.svelte";
|
|
5
4
|
import Menu from "./Menu.svelte";
|
|
6
5
|
import { MENU_ITEM_CONTEXT_KEY } from "./MenuItem.constants";
|
|
7
6
|
import { focusFirstChild, focusNextChild, focusPreviousChild } from "./MenuItem.utils";
|
|
7
|
+
import { idGenerator } from "./idGenerator";
|
|
8
8
|
export let open = false;
|
|
9
9
|
export let shape = "rounded";
|
|
10
10
|
export let value;
|
|
11
11
|
export let variant = "regular";
|
|
12
|
-
const instanceId =
|
|
12
|
+
const instanceId = idGenerator.nextId("MenuButton");
|
|
13
13
|
let buttonRef;
|
|
14
14
|
let reference;
|
|
15
15
|
let prevOpen = open;
|
package/MenuItem.svelte
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script>import { createKeyborg } from "keyborg";
|
|
2
|
-
import { v4 as uuid } from "uuid";
|
|
3
2
|
import { getContext, onMount, setContext } from "svelte";
|
|
4
3
|
import { writable } from "svelte/store";
|
|
5
4
|
import { clickOutside } from "./actions/clickOutside";
|
|
@@ -14,6 +13,7 @@ import {
|
|
|
14
13
|
focusNextChild,
|
|
15
14
|
focusPreviousChild
|
|
16
15
|
} from "./MenuItem.utils";
|
|
16
|
+
import { idGenerator } from "./idGenerator";
|
|
17
17
|
export let checked = false;
|
|
18
18
|
export let composed = false;
|
|
19
19
|
export let disabled = false;
|
|
@@ -34,7 +34,7 @@ const {
|
|
|
34
34
|
onSelect = void 0
|
|
35
35
|
} = getContext(MENU_ITEM_CONTEXT_KEY) || {};
|
|
36
36
|
const { openPreviousMenu = void 0, openNextMenu = void 0 } = getContext(MENU_BAR_CONTEXT_KEY) || {};
|
|
37
|
-
const instanceId =
|
|
37
|
+
const instanceId = idGenerator.nextId("MenuItem");
|
|
38
38
|
$:
|
|
39
39
|
displayId = `${value}-display-${instanceId}`;
|
|
40
40
|
$:
|
package/Radio.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>import { onMount } from "svelte";
|
|
2
|
-
import {
|
|
2
|
+
import { idGenerator } from "./idGenerator";
|
|
3
3
|
import Label from "./Label.svelte";
|
|
4
4
|
export let checked = false;
|
|
5
5
|
export let disabled = false;
|
|
@@ -9,7 +9,7 @@ let mounted = false;
|
|
|
9
9
|
let radioRef;
|
|
10
10
|
$: {
|
|
11
11
|
if ($$slots.default && id === void 0) {
|
|
12
|
-
id =
|
|
12
|
+
id = idGenerator.nextId("Radio");
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
$: {
|
package/Select.svelte
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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";
|
|
4
|
+
import { idGenerator } from "./idGenerator";
|
|
5
5
|
import List from "./List.svelte";
|
|
6
|
-
const popupId =
|
|
6
|
+
const popupId = idGenerator.nextId("Select-popup");
|
|
7
7
|
export let composed = false;
|
|
8
8
|
export let disabled = false;
|
|
9
9
|
export let open = false;
|
package/Switch.svelte
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
<script>import
|
|
2
|
-
import
|
|
1
|
+
<script>import Label from "./Label.svelte";
|
|
2
|
+
import { idGenerator } from "./idGenerator";
|
|
3
3
|
export let checked = false;
|
|
4
4
|
export let disabled = false;
|
|
5
5
|
export let vertical = false;
|
|
6
6
|
export let onText = void 0;
|
|
7
7
|
export let offText = void 0;
|
|
8
|
-
const inputId =
|
|
8
|
+
const inputId = idGenerator.nextId("Switch");
|
|
9
9
|
let inputRef;
|
|
10
10
|
let switchWidth = 0;
|
|
11
11
|
let switchHeight = 0;
|
package/Tree.types.d.ts
CHANGED
|
@@ -14,15 +14,3 @@ export type TreeContext = {
|
|
|
14
14
|
*/
|
|
15
15
|
selectedValue: Writable<string | undefined>;
|
|
16
16
|
};
|
|
17
|
-
/**
|
|
18
|
-
* The context for a tree item.
|
|
19
|
-
*/
|
|
20
|
-
export type TreeItemContext = {
|
|
21
|
-
/**
|
|
22
|
-
* How many levels deep this tree item is in the tree hierarchy.
|
|
23
|
-
* A top level item's depth is zero.
|
|
24
|
-
*/
|
|
25
|
-
depth: number;
|
|
26
|
-
/** If the tree item is disabled */
|
|
27
|
-
disabled: Readable<boolean>;
|
|
28
|
-
};
|
package/TreeChevron.svelte
CHANGED
|
@@ -17,7 +17,38 @@ $: {
|
|
|
17
17
|
}
|
|
18
18
|
</script>
|
|
19
19
|
|
|
20
|
-
<div
|
|
20
|
+
<div
|
|
21
|
+
class="tree-chevron"
|
|
22
|
+
class:leaf={!hasChildren}
|
|
23
|
+
class:animate
|
|
24
|
+
class:expanded
|
|
25
|
+
on:blur
|
|
26
|
+
on:click
|
|
27
|
+
on:dblclick
|
|
28
|
+
on:focus
|
|
29
|
+
on:focusin
|
|
30
|
+
on:focusout
|
|
31
|
+
on:keydown
|
|
32
|
+
on:keypress
|
|
33
|
+
on:keyup
|
|
34
|
+
on:mousedown
|
|
35
|
+
on:mouseenter
|
|
36
|
+
on:mouseleave
|
|
37
|
+
on:mousemove
|
|
38
|
+
on:mouseover
|
|
39
|
+
on:mouseout
|
|
40
|
+
on:mouseup
|
|
41
|
+
on:pointercancel
|
|
42
|
+
on:pointerdown
|
|
43
|
+
on:pointerenter
|
|
44
|
+
on:pointerleave
|
|
45
|
+
on:pointermove
|
|
46
|
+
on:pointerover
|
|
47
|
+
on:pointerout
|
|
48
|
+
on:pointerup
|
|
49
|
+
on:wheel
|
|
50
|
+
{...$$restProps}
|
|
51
|
+
/>
|
|
21
52
|
|
|
22
53
|
<style>
|
|
23
54
|
.tree-chevron {
|
package/TreeChevron.svelte.d.ts
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
|
+
[x: string]: any;
|
|
4
5
|
expanded?: boolean | undefined;
|
|
5
6
|
hasChildren?: boolean | undefined;
|
|
6
7
|
};
|
|
7
8
|
events: {
|
|
9
|
+
blur: FocusEvent;
|
|
10
|
+
click: MouseEvent;
|
|
11
|
+
dblclick: MouseEvent;
|
|
12
|
+
focus: FocusEvent;
|
|
13
|
+
focusin: FocusEvent;
|
|
14
|
+
focusout: FocusEvent;
|
|
15
|
+
keydown: KeyboardEvent;
|
|
16
|
+
keypress: KeyboardEvent;
|
|
17
|
+
keyup: KeyboardEvent;
|
|
18
|
+
mousedown: MouseEvent;
|
|
19
|
+
mouseenter: MouseEvent;
|
|
20
|
+
mouseleave: MouseEvent;
|
|
21
|
+
mousemove: MouseEvent;
|
|
22
|
+
mouseover: MouseEvent;
|
|
23
|
+
mouseout: MouseEvent;
|
|
24
|
+
mouseup: MouseEvent;
|
|
25
|
+
pointercancel: PointerEvent;
|
|
26
|
+
pointerdown: PointerEvent;
|
|
27
|
+
pointerenter: PointerEvent;
|
|
28
|
+
pointerleave: PointerEvent;
|
|
29
|
+
pointermove: PointerEvent;
|
|
30
|
+
pointerover: PointerEvent;
|
|
31
|
+
pointerout: PointerEvent;
|
|
32
|
+
pointerup: PointerEvent;
|
|
33
|
+
wheel: WheelEvent;
|
|
34
|
+
} & {
|
|
8
35
|
[evt: string]: CustomEvent<any>;
|
|
9
36
|
};
|
|
10
37
|
slots: {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Readable } from 'svelte/store';
|
|
2
|
+
/**
|
|
3
|
+
* The context for a tree item.
|
|
4
|
+
*/
|
|
5
|
+
export type TreeItemContext = {
|
|
6
|
+
/**
|
|
7
|
+
* How many levels deep this tree item is in the tree hierarchy.
|
|
8
|
+
* A top level item's depth is zero.
|
|
9
|
+
*/
|
|
10
|
+
depth: number;
|
|
11
|
+
/** If the tree item is disabled */
|
|
12
|
+
disabled: Readable<boolean>;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/TreeItemDisplay.svelte
CHANGED
package/idGenerator.d.ts
ADDED
package/idGenerator.js
ADDED
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 { idGenerator } from './idGenerator';
|
|
4
5
|
export { type Theme, type ThemeActionParams } from './theme/types';
|
|
5
6
|
export { applyDarkTheme } from './theme/applyDarkTheme';
|
|
6
7
|
export { applyLightTheme } from './theme/applyLightTheme';
|
|
@@ -20,7 +21,8 @@ export type { ProgressColorful } from './Progress.types';
|
|
|
20
21
|
export type { TabListContext } from './TabList.types';
|
|
21
22
|
export type { TextAreaResize } from './TextArea.types';
|
|
22
23
|
export type { TooltipShowOn } from './Tooltip.types';
|
|
23
|
-
export type { TreeContext
|
|
24
|
+
export type { TreeContext } from './Tree.types';
|
|
25
|
+
export type { TreeItemContext } from './TreeItem.types';
|
|
24
26
|
export { BUTTON_SHAPES, BUTTON_VARIANTS } from './Button.constants';
|
|
25
27
|
export { FIELD_STATUSES } from './Field.constants';
|
|
26
28
|
export { FLOATING_PLACEMENTS } from './floating-ui.constants';
|
package/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export { clickOutside } from './actions/clickOutside';
|
|
3
3
|
export { forwardEvents } from './actions/forwardEvents';
|
|
4
4
|
export { portal } from './actions/portal';
|
|
5
|
+
// ----- functions ----- //
|
|
6
|
+
export { idGenerator } from './idGenerator';
|
|
5
7
|
// ----- theme ----- //
|
|
6
8
|
export {} from './theme/types';
|
|
7
9
|
export { applyDarkTheme } from './theme/applyDarkTheme';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geoffcox/sterling-svelte",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"author": "Geoff Cox",
|
|
5
5
|
"description": "A modern, accessible, and lightweight component library for Svelte.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,12 +21,11 @@
|
|
|
21
21
|
"@fontsource/fira-mono": "^4.5.10",
|
|
22
22
|
"@fontsource/overpass": "^4.5.10",
|
|
23
23
|
"@playwright/test": "^1.28.1",
|
|
24
|
-
"@sveltejs/adapter-auto": "^
|
|
24
|
+
"@sveltejs/adapter-auto": "^2.0.0",
|
|
25
25
|
"@sveltejs/adapter-static": "^1.0.0",
|
|
26
|
-
"@sveltejs/kit": "^1.
|
|
26
|
+
"@sveltejs/kit": "^1.5.0",
|
|
27
27
|
"@sveltejs/package": "^1.0.0",
|
|
28
28
|
"@types/lodash-es": "^4.17.6",
|
|
29
|
-
"@types/uuid": "^9.0.0",
|
|
30
29
|
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
|
31
30
|
"@typescript-eslint/parser": "^5.45.0",
|
|
32
31
|
"eslint": "^8.28.0",
|
|
@@ -36,18 +35,17 @@
|
|
|
36
35
|
"prettier": "^2.8.0",
|
|
37
36
|
"prettier-plugin-svelte": "^2.8.1",
|
|
38
37
|
"svelte": "^3.54.0",
|
|
39
|
-
"svelte-check": "^
|
|
38
|
+
"svelte-check": "^3.0.1",
|
|
40
39
|
"tslib": "^2.4.1",
|
|
41
40
|
"typescript": "^4.9.3",
|
|
42
|
-
"vite": "^4.
|
|
41
|
+
"vite": "^4.2.0",
|
|
43
42
|
"vitest": "^0.25.3"
|
|
44
43
|
},
|
|
45
44
|
"type": "module",
|
|
46
45
|
"dependencies": {
|
|
47
46
|
"@floating-ui/dom": "^1.1.0",
|
|
48
47
|
"keyborg": "^2.0.0",
|
|
49
|
-
"lodash-es": "^4.17.21"
|
|
50
|
-
"uuid": "^9.0.0"
|
|
48
|
+
"lodash-es": "^4.17.21"
|
|
51
49
|
},
|
|
52
50
|
"exports": {
|
|
53
51
|
"./package.json": "./package.json",
|
|
@@ -102,12 +100,14 @@
|
|
|
102
100
|
"./Tree.types": "./Tree.types.js",
|
|
103
101
|
"./TreeChevron.svelte": "./TreeChevron.svelte",
|
|
104
102
|
"./TreeItem.svelte": "./TreeItem.svelte",
|
|
103
|
+
"./TreeItem.types": "./TreeItem.types.js",
|
|
105
104
|
"./TreeItemDisplay.svelte": "./TreeItemDisplay.svelte",
|
|
106
105
|
"./actions/clickOutside": "./actions/clickOutside.js",
|
|
107
106
|
"./actions/forwardEvents": "./actions/forwardEvents.js",
|
|
108
107
|
"./actions/portal": "./actions/portal.js",
|
|
109
108
|
"./floating-ui.constants": "./floating-ui.constants.js",
|
|
110
109
|
"./floating-ui.types": "./floating-ui.types.js",
|
|
110
|
+
"./idGenerator": "./idGenerator.js",
|
|
111
111
|
".": "./index.js",
|
|
112
112
|
"./theme/applyDarkTheme": "./theme/applyDarkTheme.js",
|
|
113
113
|
"./theme/applyLightTheme": "./theme/applyLightTheme.js",
|
|
@@ -12,7 +12,7 @@ type Params = Omit<ThemeActionParams, 'theme'> & {
|
|
|
12
12
|
* @example ```use:toggleDarkMode={{ dark: myToggleVariable }}```
|
|
13
13
|
*/
|
|
14
14
|
export declare const toggleDarkTheme: (node: HTMLElement, params?: Params) => {
|
|
15
|
-
|
|
15
|
+
destroy(): void;
|
|
16
16
|
update(params?: Params): void;
|
|
17
17
|
};
|
|
18
18
|
export {};
|
package/theme/toggleDarkTheme.js
CHANGED
|
@@ -39,7 +39,7 @@ export const toggleDarkTheme = (node, params) => {
|
|
|
39
39
|
matchMedia.addEventListener('change', mediaChangeHandler);
|
|
40
40
|
_applyTheme(node, params);
|
|
41
41
|
return {
|
|
42
|
-
|
|
42
|
+
destroy() {
|
|
43
43
|
matchMedia.removeEventListener('change', mediaChangeHandler);
|
|
44
44
|
},
|
|
45
45
|
update(params) {
|