@rokkit/ui 1.4.2 → 1.5.0
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/dist/components/CodeGroup.svelte +0 -1
- package/dist/components/CommandPalette.svelte +2 -1
- package/dist/components/CommandPalette.svelte.d.ts +2 -5
- package/dist/components/Dropdown.svelte +3 -22
- package/dist/components/Dropdown.svelte.d.ts +2 -20
- package/dist/components/Grid.svelte +2 -13
- package/dist/components/Grid.svelte.d.ts +2 -43
- package/dist/components/LazyTree.svelte +2 -15
- package/dist/components/LazyTree.svelte.d.ts +2 -28
- package/dist/components/List.svelte +3 -19
- package/dist/components/List.svelte.d.ts +2 -47
- package/dist/components/Menu.svelte +3 -24
- package/dist/components/Menu.svelte.d.ts +2 -66
- package/dist/components/MultiSelect.svelte +3 -24
- package/dist/components/MultiSelect.svelte.d.ts +2 -23
- package/dist/components/Select.svelte +3 -25
- package/dist/components/Select.svelte.d.ts +2 -24
- package/dist/components/Swatch.svelte +1 -26
- package/dist/components/Swatch.svelte.d.ts +1 -27
- package/dist/components/Tabs.svelte +7 -1
- package/dist/components/Tabs.svelte.d.ts +2 -0
- package/dist/components/Toggle.svelte +6 -1
- package/dist/components/Toggle.svelte.d.ts +2 -0
- package/dist/components/Tree.svelte +2 -12
- package/dist/components/Tree.svelte.d.ts +2 -29
- package/dist/types/chat.d.ts +15 -0
- package/dist/types/command-palette.d.ts +18 -0
- package/dist/types/command-palette.js +7 -0
- package/dist/types/grid.d.ts +37 -0
- package/dist/types/grid.js +8 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +8 -0
- package/dist/types/list.d.ts +22 -55
- package/dist/types/menu.d.ts +9 -2
- package/dist/types/select.d.ts +52 -62
- package/dist/types/snippets.d.ts +55 -0
- package/dist/types/snippets.js +16 -0
- package/dist/types/swatch.d.ts +41 -0
- package/dist/types/swatch.js +8 -0
- package/dist/types/tree.d.ts +34 -66
- package/package.json +5 -5
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { commands, messages } from '@rokkit/states'
|
|
3
3
|
import { dismissable } from '@rokkit/actions'
|
|
4
|
+
import type { CommandPaletteProps } from '../types/command-palette.js'
|
|
4
5
|
|
|
5
6
|
/** Minimal command shape this palette reads (states' Command typedef isn't exported). */
|
|
6
7
|
type CommandLike = { id: string; label: string; keywords?: string[] }
|
|
7
8
|
|
|
8
|
-
let { open = $bindable(false), placeholder }:
|
|
9
|
+
let { open = $bindable(false), placeholder }: CommandPaletteProps = $props()
|
|
9
10
|
|
|
10
11
|
let query = $state('')
|
|
11
12
|
let activeIndex = $state(0)
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
placeholder?: string;
|
|
4
|
-
};
|
|
5
|
-
declare const CommandPalette: import("svelte").Component<$$ComponentProps, {}, "open">;
|
|
1
|
+
import type { CommandPaletteProps } from '../types/command-palette.js';
|
|
2
|
+
declare const CommandPalette: import("svelte").Component<CommandPaletteProps, {}, "open">;
|
|
6
3
|
type CommandPalette = ReturnType<typeof CommandPalette>;
|
|
7
4
|
export default CommandPalette;
|
|
@@ -20,15 +20,10 @@
|
|
|
20
20
|
* data-align — panel alignment (start | end)
|
|
21
21
|
* data-direction — panel direction (down | up)
|
|
22
22
|
*/
|
|
23
|
-
// @ts-nocheck
|
|
24
23
|
import { ProxyTree, Wrapper, messages } from '@rokkit/states'
|
|
25
24
|
import { Navigator, Trigger } from '@rokkit/actions'
|
|
26
25
|
import { DEFAULT_STATE_ICONS } from '@rokkit/core'
|
|
27
|
-
|
|
28
|
-
interface DropdownIcons {
|
|
29
|
-
opened?: string
|
|
30
|
-
closed?: string
|
|
31
|
-
}
|
|
26
|
+
import type { DropdownProps, SelectStateIcons } from '../types/select.js'
|
|
32
27
|
|
|
33
28
|
let {
|
|
34
29
|
items = [],
|
|
@@ -41,24 +36,10 @@
|
|
|
41
36
|
showArrow = true,
|
|
42
37
|
align = 'start',
|
|
43
38
|
direction = 'down',
|
|
44
|
-
icons: userIcons = {} as
|
|
39
|
+
icons: userIcons = {} as SelectStateIcons,
|
|
45
40
|
onchange,
|
|
46
41
|
class: className = ''
|
|
47
|
-
}:
|
|
48
|
-
items?: unknown[]
|
|
49
|
-
fields?: Record<string, string>
|
|
50
|
-
value?: unknown
|
|
51
|
-
placeholder?: string
|
|
52
|
-
icon?: string
|
|
53
|
-
size?: string
|
|
54
|
-
disabled?: boolean
|
|
55
|
-
showArrow?: boolean
|
|
56
|
-
align?: 'start' | 'end'
|
|
57
|
-
direction?: 'up' | 'down'
|
|
58
|
-
icons?: DropdownIcons
|
|
59
|
-
onchange?: (value: unknown, item: unknown) => void
|
|
60
|
-
class?: string
|
|
61
|
-
} = $props()
|
|
42
|
+
}: DropdownProps = $props()
|
|
62
43
|
|
|
63
44
|
const icons = $derived({ ...DEFAULT_STATE_ICONS.selector, ...userIcons })
|
|
64
45
|
|
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
closed?: string;
|
|
4
|
-
}
|
|
5
|
-
type $$ComponentProps = {
|
|
6
|
-
items?: unknown[];
|
|
7
|
-
fields?: Record<string, string>;
|
|
8
|
-
value?: unknown;
|
|
9
|
-
placeholder?: string;
|
|
10
|
-
icon?: string;
|
|
11
|
-
size?: string;
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
showArrow?: boolean;
|
|
14
|
-
align?: 'start' | 'end';
|
|
15
|
-
direction?: 'up' | 'down';
|
|
16
|
-
icons?: DropdownIcons;
|
|
17
|
-
onchange?: (value: unknown, item: unknown) => void;
|
|
18
|
-
class?: string;
|
|
19
|
-
};
|
|
20
|
-
declare const Dropdown: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
1
|
+
import type { DropdownProps } from '../types/select.js';
|
|
2
|
+
declare const Dropdown: import("svelte").Component<DropdownProps, {}, "value">;
|
|
21
3
|
type Dropdown = ReturnType<typeof Dropdown>;
|
|
22
4
|
export default Dropdown;
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
import { Navigator } from '@rokkit/actions'
|
|
33
33
|
import { resolveSnippet, ITEM_SNIPPET } from '@rokkit/core'
|
|
34
34
|
import ItemContent from './ItemContent.svelte'
|
|
35
|
+
import type { GridProps } from '../types/grid.js'
|
|
35
36
|
|
|
36
37
|
let {
|
|
37
38
|
items = [],
|
|
@@ -45,19 +46,7 @@
|
|
|
45
46
|
onselect,
|
|
46
47
|
class: className = '',
|
|
47
48
|
...snippets
|
|
48
|
-
}:
|
|
49
|
-
items?: unknown[]
|
|
50
|
-
fields?: Record<string, string>
|
|
51
|
-
value?: unknown
|
|
52
|
-
size?: string
|
|
53
|
-
disabled?: boolean
|
|
54
|
-
minSize?: string
|
|
55
|
-
gap?: string
|
|
56
|
-
label?: string
|
|
57
|
-
onselect?: (value: unknown, proxy: ProxyItem) => void
|
|
58
|
-
class?: string
|
|
59
|
-
[key: string]: unknown
|
|
60
|
-
} = $props()
|
|
49
|
+
}: GridProps = $props()
|
|
61
50
|
|
|
62
51
|
// ─── Wrapper ──────────────────────────────────────────────────────────────
|
|
63
52
|
|
|
@@ -1,45 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Architecture:
|
|
5
|
-
* Wrapper — owns focusedKey $state + flatView $derived
|
|
6
|
-
* Navigator — attaches DOM event handlers, calls wrapper[action](path)
|
|
7
|
-
* horizontal orientation (ArrowLeft/ArrowRight navigation)
|
|
8
|
-
* flatView loop — single flat {#each} rendering items as grid tiles
|
|
9
|
-
*
|
|
10
|
-
* Snippet customization:
|
|
11
|
-
* itemContent — replaces inner content of <button> for each tile
|
|
12
|
-
* [named] — per-item override via item.snippet = 'name'; falls back to itemContent
|
|
13
|
-
*
|
|
14
|
-
* Snippets receive (proxy) only — the <button> wrapper with data-path is
|
|
15
|
-
* always rendered by this component, so snippets never need to handle navigation.
|
|
16
|
-
*
|
|
17
|
-
* Data attributes on rendered elements:
|
|
18
|
-
* data-grid — root container
|
|
19
|
-
* data-grid-item — each tile button
|
|
20
|
-
* data-path — required by Navigator for click detection + scroll
|
|
21
|
-
* data-active — highlights current value match
|
|
22
|
-
* data-disabled — disabled state
|
|
23
|
-
* data-size — size variant
|
|
24
|
-
*
|
|
25
|
-
* CSS custom properties:
|
|
26
|
-
* --grid-min-size — minimum tile width for auto-fill
|
|
27
|
-
* --grid-gap — grid gap
|
|
28
|
-
*/
|
|
29
|
-
import type { ProxyItem } from '@rokkit/states';
|
|
30
|
-
type $$ComponentProps = {
|
|
31
|
-
items?: unknown[];
|
|
32
|
-
fields?: Record<string, string>;
|
|
33
|
-
value?: unknown;
|
|
34
|
-
size?: string;
|
|
35
|
-
disabled?: boolean;
|
|
36
|
-
minSize?: string;
|
|
37
|
-
gap?: string;
|
|
38
|
-
label?: string;
|
|
39
|
-
onselect?: (value: unknown, proxy: ProxyItem) => void;
|
|
40
|
-
class?: string;
|
|
41
|
-
[key: string]: unknown;
|
|
42
|
-
};
|
|
43
|
-
declare const Grid: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
1
|
+
import type { GridProps } from '../types/grid.js';
|
|
2
|
+
declare const Grid: import("svelte").Component<GridProps, {}, "value">;
|
|
44
3
|
type Grid = ReturnType<typeof Grid>;
|
|
45
4
|
export default Grid;
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* Default item content: icon + label + badge + shortcut (no avatar/description).
|
|
9
9
|
* Parent nodes hide their icon by default.
|
|
10
10
|
*/
|
|
11
|
-
import type { ProxyItem } from '@rokkit/states'
|
|
12
11
|
import { LazyWrapper, LazyProxyItem, ProxyTree, messages } from '@rokkit/states'
|
|
13
12
|
import { Navigator } from '@rokkit/actions'
|
|
14
13
|
import { DEFAULT_STATE_ICONS, resolveSnippet, ITEM_SNIPPET } from '@rokkit/core'
|
|
15
14
|
import ItemContent from './ItemContent.svelte'
|
|
16
15
|
import Connector from './Connector.svelte'
|
|
17
16
|
import Button from './Button.svelte'
|
|
17
|
+
import type { LazyTreeProps } from '../types/tree.js'
|
|
18
18
|
|
|
19
19
|
let {
|
|
20
20
|
items = [],
|
|
@@ -29,20 +29,7 @@
|
|
|
29
29
|
hasMore = false,
|
|
30
30
|
class: className = '',
|
|
31
31
|
...snippets
|
|
32
|
-
}:
|
|
33
|
-
items?: unknown[]
|
|
34
|
-
fields?: Record<string, string>
|
|
35
|
-
value?: unknown
|
|
36
|
-
size?: 'sm' | 'md' | 'lg'
|
|
37
|
-
lineStyle?: 'none' | 'solid' | 'dashed' | 'dotted'
|
|
38
|
-
labels?: Record<string, string>
|
|
39
|
-
icons?: { opened?: string; closed?: string }
|
|
40
|
-
onselect?: (value: unknown, proxy: ProxyItem) => void
|
|
41
|
-
onlazyload?: (current?: unknown) => Promise<unknown[]>
|
|
42
|
-
hasMore?: boolean
|
|
43
|
-
class?: string
|
|
44
|
-
[key: string]: unknown
|
|
45
|
-
} = $props()
|
|
32
|
+
}: LazyTreeProps = $props()
|
|
46
33
|
|
|
47
34
|
const labels = $derived({ ...messages.tree, ...userLabels })
|
|
48
35
|
|
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Same as Tree but uses LazyProxyItem via createProxy factory
|
|
5
|
-
* so nodes with children: true fetch on expand.
|
|
6
|
-
*
|
|
7
|
-
* Default item content: icon + label + badge + shortcut (no avatar/description).
|
|
8
|
-
* Parent nodes hide their icon by default.
|
|
9
|
-
*/
|
|
10
|
-
import type { ProxyItem } from '@rokkit/states';
|
|
11
|
-
type $$ComponentProps = {
|
|
12
|
-
items?: unknown[];
|
|
13
|
-
fields?: Record<string, string>;
|
|
14
|
-
value?: unknown;
|
|
15
|
-
size?: 'sm' | 'md' | 'lg';
|
|
16
|
-
lineStyle?: 'none' | 'solid' | 'dashed' | 'dotted';
|
|
17
|
-
labels?: Record<string, string>;
|
|
18
|
-
icons?: {
|
|
19
|
-
opened?: string;
|
|
20
|
-
closed?: string;
|
|
21
|
-
};
|
|
22
|
-
onselect?: (value: unknown, proxy: ProxyItem) => void;
|
|
23
|
-
onlazyload?: (current?: unknown) => Promise<unknown[]>;
|
|
24
|
-
hasMore?: boolean;
|
|
25
|
-
class?: string;
|
|
26
|
-
[key: string]: unknown;
|
|
27
|
-
};
|
|
28
|
-
declare const LazyTree: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
1
|
+
import type { LazyTreeProps } from '../types/tree.js';
|
|
2
|
+
declare const LazyTree: import("svelte").Component<LazyTreeProps, {}, "value">;
|
|
29
3
|
type LazyTree = ReturnType<typeof LazyTree>;
|
|
30
4
|
export default LazyTree;
|
|
@@ -32,11 +32,7 @@
|
|
|
32
32
|
import { Navigator } from '@rokkit/actions'
|
|
33
33
|
import { DEFAULT_STATE_ICONS, resolveSnippet, ITEM_SNIPPET, GROUP_SNIPPET } from '@rokkit/core'
|
|
34
34
|
import ItemContent from './ItemContent.svelte'
|
|
35
|
-
|
|
36
|
-
interface ListIcons {
|
|
37
|
-
opened?: string
|
|
38
|
-
closed?: string
|
|
39
|
-
}
|
|
35
|
+
import type { ListProps, ListStateIcons } from '../types/list.js'
|
|
40
36
|
|
|
41
37
|
let {
|
|
42
38
|
items = [],
|
|
@@ -46,23 +42,11 @@
|
|
|
46
42
|
disabled = false,
|
|
47
43
|
collapsible = false,
|
|
48
44
|
label = messages.list.label,
|
|
49
|
-
icons: userIcons = {} as
|
|
45
|
+
icons: userIcons = {} as ListStateIcons,
|
|
50
46
|
onselect,
|
|
51
47
|
class: className = '',
|
|
52
48
|
...snippets
|
|
53
|
-
}:
|
|
54
|
-
items?: unknown[]
|
|
55
|
-
fields?: Record<string, string>
|
|
56
|
-
value?: unknown
|
|
57
|
-
size?: string
|
|
58
|
-
disabled?: boolean
|
|
59
|
-
collapsible?: boolean
|
|
60
|
-
label?: string
|
|
61
|
-
icons?: ListIcons
|
|
62
|
-
onselect?: (value: unknown, proxy: ProxyItem) => void
|
|
63
|
-
class?: string
|
|
64
|
-
[key: string]: unknown
|
|
65
|
-
} = $props()
|
|
49
|
+
}: ListProps = $props()
|
|
66
50
|
|
|
67
51
|
const icons = $derived({ ...DEFAULT_STATE_ICONS.accordion, ...userIcons })
|
|
68
52
|
|
|
@@ -1,49 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Architecture:
|
|
5
|
-
* Wrapper — owns focusedKey $state + flatView $derived
|
|
6
|
-
* Navigator — attaches DOM event handlers, calls wrapper[action](path)
|
|
7
|
-
* owns focus + scrollIntoView after every keyboard action
|
|
8
|
-
* flatView loop — single flat {#each}, no nested groups in template
|
|
9
|
-
*
|
|
10
|
-
* Snippet customization:
|
|
11
|
-
* itemContent — replaces inner content of <a>/<button> for leaf items
|
|
12
|
-
* groupContent — replaces inner content of group header <button>
|
|
13
|
-
* [named] — per-item override via item.snippet = 'name'; falls back to itemContent
|
|
14
|
-
*
|
|
15
|
-
* Snippets receive (proxy) only — the <a>/<button> wrapper with data-path is
|
|
16
|
-
* always rendered by this component, so snippets never need to handle navigation.
|
|
17
|
-
*
|
|
18
|
-
* Data attributes on rendered elements:
|
|
19
|
-
* data-path — required by Navigator for click detection + scroll
|
|
20
|
-
* data-level — nesting depth (1=root); theme CSS uses for indentation
|
|
21
|
-
* data-accordion-trigger — tells Navigator to dispatch toggle (not select) on click
|
|
22
|
-
* data-list-item — theme hook for leaf items
|
|
23
|
-
* data-list-item-icon — icon span inside leaf items
|
|
24
|
-
* data-list-group — theme hook for group headers
|
|
25
|
-
* data-list-group-icon — icon span inside group headers
|
|
26
|
-
* data-active — highlights current value match
|
|
27
|
-
* data-disabled — disabled state
|
|
28
|
-
*/
|
|
29
|
-
import type { ProxyItem } from '@rokkit/states';
|
|
30
|
-
interface ListIcons {
|
|
31
|
-
opened?: string;
|
|
32
|
-
closed?: string;
|
|
33
|
-
}
|
|
34
|
-
type $$ComponentProps = {
|
|
35
|
-
items?: unknown[];
|
|
36
|
-
fields?: Record<string, string>;
|
|
37
|
-
value?: unknown;
|
|
38
|
-
size?: string;
|
|
39
|
-
disabled?: boolean;
|
|
40
|
-
collapsible?: boolean;
|
|
41
|
-
label?: string;
|
|
42
|
-
icons?: ListIcons;
|
|
43
|
-
onselect?: (value: unknown, proxy: ProxyItem) => void;
|
|
44
|
-
class?: string;
|
|
45
|
-
[key: string]: unknown;
|
|
46
|
-
};
|
|
47
|
-
declare const List: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
1
|
+
import type { ListProps } from '../types/list.js';
|
|
2
|
+
declare const List: import("svelte").Component<ListProps, {}, "value">;
|
|
48
3
|
type List = ReturnType<typeof List>;
|
|
49
4
|
export default List;
|
|
@@ -42,17 +42,12 @@
|
|
|
42
42
|
* data-align — dropdown alignment
|
|
43
43
|
* data-direction — dropdown direction
|
|
44
44
|
*/
|
|
45
|
-
// @ts-nocheck
|
|
46
45
|
import type { ProxyItem } from '@rokkit/states'
|
|
47
46
|
import { Wrapper, ProxyTree, messages } from '@rokkit/states'
|
|
48
47
|
import { Navigator, Trigger } from '@rokkit/actions'
|
|
49
48
|
import { DEFAULT_STATE_ICONS, resolveSnippet, ITEM_SNIPPET, GROUP_SNIPPET } from '@rokkit/core'
|
|
50
49
|
import ItemContent from './ItemContent.svelte'
|
|
51
|
-
|
|
52
|
-
interface MenuIcons {
|
|
53
|
-
opened?: string
|
|
54
|
-
closed?: string
|
|
55
|
-
}
|
|
50
|
+
import type { MenuProps, MenuStateIcons } from '../types/menu.js'
|
|
56
51
|
|
|
57
52
|
let {
|
|
58
53
|
items = [],
|
|
@@ -66,27 +61,11 @@
|
|
|
66
61
|
showArrow = true,
|
|
67
62
|
align = 'start',
|
|
68
63
|
direction = 'down',
|
|
69
|
-
icons: userIcons = {} as
|
|
64
|
+
icons: userIcons = {} as MenuStateIcons,
|
|
70
65
|
onselect,
|
|
71
66
|
class: className = '',
|
|
72
67
|
...snippets
|
|
73
|
-
}:
|
|
74
|
-
items?: unknown[]
|
|
75
|
-
fields?: Record<string, string>
|
|
76
|
-
value?: unknown
|
|
77
|
-
size?: string
|
|
78
|
-
disabled?: boolean
|
|
79
|
-
collapsible?: boolean
|
|
80
|
-
label?: string
|
|
81
|
-
icon?: string
|
|
82
|
-
showArrow?: boolean
|
|
83
|
-
align?: 'start' | 'end'
|
|
84
|
-
direction?: 'up' | 'down'
|
|
85
|
-
icons?: MenuIcons
|
|
86
|
-
onselect?: (value: unknown, proxy: ProxyItem) => void
|
|
87
|
-
class?: string
|
|
88
|
-
[key: string]: unknown
|
|
89
|
-
} = $props()
|
|
68
|
+
}: MenuProps = $props()
|
|
90
69
|
|
|
91
70
|
const icons = $derived({ ...DEFAULT_STATE_ICONS.selector, ...userIcons })
|
|
92
71
|
|
|
@@ -1,68 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Architecture:
|
|
5
|
-
* Trigger — manages open/close from trigger button (click, Enter, Escape, click-outside)
|
|
6
|
-
* Wrapper — owns focusedKey $state + flatView $derived (cancel/blur overridden to close)
|
|
7
|
-
* Navigator — attaches DOM event handlers on dropdown, calls wrapper[action](path)
|
|
8
|
-
* flatView loop — single flat {#each}, same as List
|
|
9
|
-
*
|
|
10
|
-
* The dropdown content is identical to List: same flatView loop, same snippet system,
|
|
11
|
-
* same collapsible groups. The only additions are trigger, alignment, and direction.
|
|
12
|
-
*
|
|
13
|
-
* Snippet customization (same as List):
|
|
14
|
-
* itemContent — replaces inner content of <button> for leaf items
|
|
15
|
-
* groupContent — replaces inner content of group header <button>
|
|
16
|
-
* [named] — per-item override via item.snippet = 'name'; falls back to itemContent
|
|
17
|
-
*
|
|
18
|
-
* Data attributes on rendered elements:
|
|
19
|
-
* data-menu — root container
|
|
20
|
-
* data-menu-trigger — trigger button
|
|
21
|
-
* data-menu-label — trigger label text
|
|
22
|
-
* data-menu-icon — trigger icon
|
|
23
|
-
* data-menu-arrow — trigger dropdown arrow
|
|
24
|
-
* data-menu-dropdown — dropdown container
|
|
25
|
-
* data-menu-item — leaf items (like data-list-item)
|
|
26
|
-
* data-menu-item-icon — icon span inside leaf items
|
|
27
|
-
* data-menu-item-text — text span inside leaf items
|
|
28
|
-
* data-menu-group — group headers (like data-list-group)
|
|
29
|
-
* data-menu-group-icon — icon span inside group headers
|
|
30
|
-
* data-menu-group-text — text span inside group headers
|
|
31
|
-
* data-menu-expand-icon — expand/collapse chevron in group headers
|
|
32
|
-
* data-menu-separator — separator
|
|
33
|
-
* data-menu-spacer — spacer
|
|
34
|
-
* data-path — required by Navigator for click detection + scroll
|
|
35
|
-
* data-level — nesting depth (1=root)
|
|
36
|
-
* data-accordion-trigger — tells Navigator to dispatch toggle on click
|
|
37
|
-
* data-active — highlights current value match
|
|
38
|
-
* data-disabled — disabled state
|
|
39
|
-
* data-open — dropdown is open
|
|
40
|
-
* data-size — size variant
|
|
41
|
-
* data-align — dropdown alignment
|
|
42
|
-
* data-direction — dropdown direction
|
|
43
|
-
*/
|
|
44
|
-
import type { ProxyItem } from '@rokkit/states';
|
|
45
|
-
interface MenuIcons {
|
|
46
|
-
opened?: string;
|
|
47
|
-
closed?: string;
|
|
48
|
-
}
|
|
49
|
-
type $$ComponentProps = {
|
|
50
|
-
items?: unknown[];
|
|
51
|
-
fields?: Record<string, string>;
|
|
52
|
-
value?: unknown;
|
|
53
|
-
size?: string;
|
|
54
|
-
disabled?: boolean;
|
|
55
|
-
collapsible?: boolean;
|
|
56
|
-
label?: string;
|
|
57
|
-
icon?: string;
|
|
58
|
-
showArrow?: boolean;
|
|
59
|
-
align?: 'start' | 'end';
|
|
60
|
-
direction?: 'up' | 'down';
|
|
61
|
-
icons?: MenuIcons;
|
|
62
|
-
onselect?: (value: unknown, proxy: ProxyItem) => void;
|
|
63
|
-
class?: string;
|
|
64
|
-
[key: string]: unknown;
|
|
65
|
-
};
|
|
66
|
-
declare const Menu: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
1
|
+
import type { MenuProps } from '../types/menu.js';
|
|
2
|
+
declare const Menu: import("svelte").Component<MenuProps, {}, "">;
|
|
67
3
|
type Menu = ReturnType<typeof Menu>;
|
|
68
4
|
export default Menu;
|
|
@@ -30,13 +30,7 @@
|
|
|
30
30
|
import { Navigator, Trigger } from '@rokkit/actions'
|
|
31
31
|
import { DEFAULT_STATE_ICONS, resolveSnippet, ITEM_SNIPPET, GROUP_SNIPPET } from '@rokkit/core'
|
|
32
32
|
import ItemContent from './ItemContent.svelte'
|
|
33
|
-
|
|
34
|
-
interface MultiSelectIcons {
|
|
35
|
-
opened?: string
|
|
36
|
-
closed?: string
|
|
37
|
-
checked?: string
|
|
38
|
-
remove?: string
|
|
39
|
-
}
|
|
33
|
+
import type { MultiSelectProps, SelectStateIcons } from '../types/select.js'
|
|
40
34
|
|
|
41
35
|
let {
|
|
42
36
|
items = [],
|
|
@@ -49,26 +43,11 @@
|
|
|
49
43
|
maxDisplay = 3,
|
|
50
44
|
align = 'start',
|
|
51
45
|
direction = 'down',
|
|
52
|
-
icons: userIcons = {} as
|
|
46
|
+
icons: userIcons = {} as SelectStateIcons,
|
|
53
47
|
onchange,
|
|
54
48
|
class: className = '',
|
|
55
49
|
...snippets
|
|
56
|
-
}:
|
|
57
|
-
items?: unknown[]
|
|
58
|
-
fields?: Record<string, string>
|
|
59
|
-
value?: unknown[]
|
|
60
|
-
selected?: unknown[]
|
|
61
|
-
placeholder?: string
|
|
62
|
-
size?: string
|
|
63
|
-
disabled?: boolean
|
|
64
|
-
maxDisplay?: number
|
|
65
|
-
align?: 'start' | 'end'
|
|
66
|
-
direction?: 'up' | 'down'
|
|
67
|
-
icons?: MultiSelectIcons
|
|
68
|
-
onchange?: (values: unknown[], items: unknown[]) => void
|
|
69
|
-
class?: string
|
|
70
|
-
[key: string]: unknown
|
|
71
|
-
} = $props()
|
|
50
|
+
}: MultiSelectProps = $props()
|
|
72
51
|
|
|
73
52
|
const icons = $derived({
|
|
74
53
|
...DEFAULT_STATE_ICONS.selector,
|
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
closed?: string;
|
|
4
|
-
checked?: string;
|
|
5
|
-
remove?: string;
|
|
6
|
-
}
|
|
7
|
-
type $$ComponentProps = {
|
|
8
|
-
items?: unknown[];
|
|
9
|
-
fields?: Record<string, string>;
|
|
10
|
-
value?: unknown[];
|
|
11
|
-
selected?: unknown[];
|
|
12
|
-
placeholder?: string;
|
|
13
|
-
size?: string;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
maxDisplay?: number;
|
|
16
|
-
align?: 'start' | 'end';
|
|
17
|
-
direction?: 'up' | 'down';
|
|
18
|
-
icons?: MultiSelectIcons;
|
|
19
|
-
onchange?: (values: unknown[], items: unknown[]) => void;
|
|
20
|
-
class?: string;
|
|
21
|
-
[key: string]: unknown;
|
|
22
|
-
};
|
|
23
|
-
declare const MultiSelect: import("svelte").Component<$$ComponentProps, {}, "value" | "selected">;
|
|
1
|
+
import type { MultiSelectProps } from '../types/select.js';
|
|
2
|
+
declare const MultiSelect: import("svelte").Component<MultiSelectProps, {}, "value" | "selected">;
|
|
24
3
|
type MultiSelect = ReturnType<typeof MultiSelect>;
|
|
25
4
|
export default MultiSelect;
|
|
@@ -43,12 +43,7 @@
|
|
|
43
43
|
import { Navigator, Trigger } from '@rokkit/actions'
|
|
44
44
|
import { DEFAULT_STATE_ICONS, resolveSnippet, ITEM_SNIPPET, GROUP_SNIPPET } from '@rokkit/core'
|
|
45
45
|
import ItemContent from './ItemContent.svelte'
|
|
46
|
-
|
|
47
|
-
interface SelectIcons {
|
|
48
|
-
opened?: string
|
|
49
|
-
closed?: string
|
|
50
|
-
checked?: string
|
|
51
|
-
}
|
|
46
|
+
import type { SelectProps, SelectStateIcons } from '../types/select.js'
|
|
52
47
|
|
|
53
48
|
let {
|
|
54
49
|
items = [],
|
|
@@ -63,28 +58,11 @@
|
|
|
63
58
|
align = 'start',
|
|
64
59
|
direction = 'down',
|
|
65
60
|
maxRows = 8,
|
|
66
|
-
icons: userIcons = {} as
|
|
61
|
+
icons: userIcons = {} as SelectStateIcons,
|
|
67
62
|
onchange,
|
|
68
63
|
class: className = '',
|
|
69
64
|
...snippets
|
|
70
|
-
}:
|
|
71
|
-
items?: unknown[]
|
|
72
|
-
fields?: Record<string, string>
|
|
73
|
-
value?: unknown
|
|
74
|
-
selected?: unknown
|
|
75
|
-
placeholder?: string
|
|
76
|
-
size?: string
|
|
77
|
-
disabled?: boolean
|
|
78
|
-
filterable?: boolean
|
|
79
|
-
filterPlaceholder?: string
|
|
80
|
-
align?: 'start' | 'end'
|
|
81
|
-
direction?: 'up' | 'down'
|
|
82
|
-
maxRows?: number
|
|
83
|
-
icons?: SelectIcons
|
|
84
|
-
onchange?: (value: unknown, item: unknown) => void
|
|
85
|
-
class?: string
|
|
86
|
-
[key: string]: unknown
|
|
87
|
-
} = $props()
|
|
65
|
+
}: SelectProps = $props()
|
|
88
66
|
|
|
89
67
|
const icons = $derived({
|
|
90
68
|
...DEFAULT_STATE_ICONS.selector,
|
|
@@ -1,26 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
closed?: string;
|
|
4
|
-
checked?: string;
|
|
5
|
-
}
|
|
6
|
-
type $$ComponentProps = {
|
|
7
|
-
items?: unknown[];
|
|
8
|
-
fields?: Record<string, string>;
|
|
9
|
-
value?: unknown;
|
|
10
|
-
selected?: unknown;
|
|
11
|
-
placeholder?: string;
|
|
12
|
-
size?: string;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
filterable?: boolean;
|
|
15
|
-
filterPlaceholder?: string;
|
|
16
|
-
align?: 'start' | 'end';
|
|
17
|
-
direction?: 'up' | 'down';
|
|
18
|
-
maxRows?: number;
|
|
19
|
-
icons?: SelectIcons;
|
|
20
|
-
onchange?: (value: unknown, item: unknown) => void;
|
|
21
|
-
class?: string;
|
|
22
|
-
[key: string]: unknown;
|
|
23
|
-
};
|
|
24
|
-
declare const Select: import("svelte").Component<$$ComponentProps, {}, "value" | "selected">;
|
|
1
|
+
import type { SelectProps } from '../types/select.js';
|
|
2
|
+
declare const Select: import("svelte").Component<SelectProps, {}, "value" | "selected">;
|
|
25
3
|
type Select = ReturnType<typeof Select>;
|
|
26
4
|
export default Select;
|
|
@@ -1,34 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte'
|
|
3
2
|
import type { ProxyItem } from '@rokkit/states'
|
|
4
3
|
import { Wrapper, ProxyTree } from '@rokkit/states'
|
|
5
4
|
import { Navigator } from '@rokkit/actions'
|
|
5
|
+
import type { SwatchProps } from '../types/swatch.js'
|
|
6
6
|
|
|
7
|
-
interface SwatchProps {
|
|
8
|
-
/** Color options — primitives (hex/name strings) or objects with mapped fields */
|
|
9
|
-
options?: Array<string | number | Record<string, unknown>>
|
|
10
|
-
/** Field mapping for object options (value, fill, stroke, …) */
|
|
11
|
-
fields?: Record<string, string>
|
|
12
|
-
/** Selected value (bindable). Array when `multiple`. */
|
|
13
|
-
value?: unknown
|
|
14
|
-
/** Allow multiple selection */
|
|
15
|
-
multiple?: boolean
|
|
16
|
-
/** Swatch shape */
|
|
17
|
-
shape?: 'square' | 'circle'
|
|
18
|
-
/** Size variant */
|
|
19
|
-
size?: 'sm' | 'md' | 'lg'
|
|
20
|
-
/** Disable the whole group */
|
|
21
|
-
disabled?: boolean
|
|
22
|
-
/** Accessible group label */
|
|
23
|
-
label?: string
|
|
24
|
-
/** Additional CSS classes */
|
|
25
|
-
class?: string
|
|
26
|
-
/** Called when selection changes */
|
|
27
|
-
onchange?: (value: unknown, item: unknown) => void
|
|
28
|
-
/** Custom snippet for rendering a swatch (receives proxy + selected) */
|
|
29
|
-
item?: Snippet<[ProxyItem, boolean]>
|
|
30
|
-
[key: string]: unknown
|
|
31
|
-
}
|
|
32
7
|
|
|
33
8
|
let {
|
|
34
9
|
options = [],
|