@rokkit/ui 1.1.17 → 1.1.19
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/MarkdownRenderer.svelte.d.ts +15 -0
- package/dist/components/AlertList.svelte.d.ts +4 -0
- package/dist/components/Avatar.svelte.d.ts +4 -0
- package/dist/components/Badge.svelte.d.ts +4 -0
- package/dist/components/BreadCrumbs.svelte.d.ts +4 -0
- package/dist/components/Button.svelte.d.ts +4 -0
- package/dist/components/ButtonGroup.svelte.d.ts +4 -0
- package/dist/components/Card.svelte.d.ts +4 -0
- package/dist/components/Carousel.svelte.d.ts +4 -0
- package/dist/components/Code.svelte.d.ts +7 -0
- package/dist/components/CodeBlock.svelte.d.ts +4 -0
- package/dist/components/CodeGroup.svelte.d.ts +4 -0
- package/dist/components/CommandPalette.svelte.d.ts +7 -0
- package/dist/components/Connector.svelte.d.ts +4 -0
- package/dist/components/Divider.svelte.d.ts +4 -0
- package/dist/components/Dropdown.svelte.d.ts +22 -0
- package/dist/components/FloatingAction.svelte.d.ts +7 -0
- package/dist/components/FloatingNavigation.svelte.d.ts +7 -0
- package/dist/components/Frame.svelte.d.ts +17 -0
- package/dist/components/Grid.svelte.d.ts +45 -0
- package/dist/components/ItemContent.svelte.d.ts +4 -0
- package/dist/components/LazyTree.svelte.d.ts +30 -0
- package/dist/components/List.svelte.d.ts +49 -0
- package/dist/components/Menu.svelte.d.ts +68 -0
- package/dist/components/Message.svelte.d.ts +4 -0
- package/dist/components/MultiSelect.svelte.d.ts +25 -0
- package/dist/components/NavContent.svelte.d.ts +4 -0
- package/dist/components/PaletteManager.svelte.d.ts +4 -0
- package/dist/components/Pill.svelte.d.ts +4 -0
- package/dist/components/ProgressBar.svelte.d.ts +4 -0
- package/dist/components/Range.svelte.d.ts +7 -0
- package/dist/components/Rating.svelte.d.ts +4 -0
- package/dist/components/ResponsiveGrid.svelte.d.ts +4 -0
- package/dist/components/Reveal.svelte.d.ts +4 -0
- package/dist/components/SearchFilter.svelte.d.ts +7 -0
- package/dist/components/Select.svelte.d.ts +26 -0
- package/dist/components/Shine.svelte.d.ts +4 -0
- package/dist/components/Stack.svelte.d.ts +4 -0
- package/dist/components/StatusList.svelte.d.ts +4 -0
- package/dist/components/Stepper.svelte.d.ts +4 -0
- package/dist/components/Swatch.svelte.d.ts +30 -0
- package/dist/components/Switch.svelte.d.ts +4 -0
- package/dist/components/Table.svelte.d.ts +4 -0
- package/dist/components/Tabs.svelte.d.ts +26 -0
- package/dist/components/Tilt.svelte.d.ts +4 -0
- package/dist/components/Timeline.svelte.d.ts +4 -0
- package/dist/components/Toggle.svelte.d.ts +7 -0
- package/dist/components/Toolbar.svelte.d.ts +8 -0
- package/dist/components/ToolbarGroup.svelte.d.ts +4 -0
- package/dist/components/Tooltip.svelte.d.ts +17 -0
- package/dist/components/Tree.svelte.d.ts +31 -0
- package/dist/components/TreeTable.svelte.d.ts +4 -0
- package/dist/components/UploadFileStatus.svelte.d.ts +19 -0
- package/dist/components/UploadProgress.svelte.d.ts +7 -0
- package/dist/components/UploadTarget.svelte.d.ts +7 -0
- package/dist/components/index.d.ts +54 -0
- package/dist/index.d.ts +6 -0
- package/dist/markdown-plugin.d.ts +13 -0
- package/dist/types/alert-list.d.ts +19 -0
- package/dist/types/avatar.d.ts +30 -0
- package/dist/types/badge.d.ts +29 -0
- package/dist/types/breadcrumbs.d.ts +34 -0
- package/dist/types/button.d.ts +63 -0
- package/dist/types/card.d.ts +29 -0
- package/dist/types/carousel.d.ts +35 -0
- package/dist/types/code.d.ts +118 -0
- package/dist/types/connector.d.ts +18 -0
- package/dist/types/divider.d.ts +16 -0
- package/dist/types/floating-action.d.ts +89 -0
- package/dist/types/floating-navigation.d.ts +66 -0
- package/dist/types/frame.d.ts +24 -0
- package/dist/types/index.d.ts +44 -0
- package/dist/types/item-content.d.ts +22 -0
- package/dist/types/list.d.ts +128 -0
- package/dist/types/menu.d.ts +53 -0
- package/dist/types/message.d.ts +42 -0
- package/dist/types/nav-content.d.ts +23 -0
- package/dist/types/palette.d.ts +98 -0
- package/dist/types/pill.d.ts +33 -0
- package/dist/types/progress-bar.d.ts +16 -0
- package/dist/types/range.d.ts +35 -0
- package/dist/types/rating.d.ts +33 -0
- package/dist/types/responsive-grid.d.ts +19 -0
- package/dist/types/reveal.d.ts +37 -0
- package/dist/types/search-filter.d.ts +43 -0
- package/dist/types/select.d.ts +114 -0
- package/dist/types/shine.d.ts +28 -0
- package/dist/types/stack.d.ts +29 -0
- package/dist/types/status-list.d.ts +35 -0
- package/dist/types/stepper.d.ts +56 -0
- package/dist/types/switch.d.ts +46 -0
- package/dist/types/table.d.ts +148 -0
- package/dist/types/tabs.d.ts +68 -0
- package/dist/types/tilt.d.ts +22 -0
- package/dist/types/timeline.d.ts +30 -0
- package/dist/types/toggle.d.ts +54 -0
- package/dist/types/toolbar.d.ts +109 -0
- package/dist/types/tooltip.d.ts +15 -0
- package/dist/types/tree-table.d.ts +79 -0
- package/dist/types/tree.d.ts +183 -0
- package/dist/types/upload-file-status.d.ts +31 -0
- package/dist/types/upload-progress.d.ts +71 -0
- package/dist/types/upload-target.d.ts +46 -0
- package/dist/utils/palette.d.ts +100 -0
- package/dist/utils/shiki.d.ts +20 -0
- package/dist/utils/upload.d.ts +21 -0
- package/package.json +14 -11
- package/src/MarkdownRenderer.svelte +6 -4
- package/src/components/Button.svelte +7 -1
- package/src/components/CommandPalette.svelte +8 -6
- package/src/components/LazyTree.svelte +3 -4
- package/src/components/List.svelte +1 -1
- package/src/components/MultiSelect.svelte +3 -3
- package/src/components/Pill.svelte +10 -5
- package/src/components/Select.svelte +3 -3
- package/src/components/Swatch.svelte +35 -8
- package/src/components/Table.svelte +2 -1
- package/src/components/Tabs.svelte +1 -2
- package/src/components/Toggle.svelte +2 -2
- package/src/components/Tree.svelte +1 -2
- package/src/components/TreeTable.svelte +2 -1
- package/src/components/UploadTarget.svelte +2 -1
- package/src/types/button.ts +8 -2
- package/src/types/tabs.ts +4 -4
- package/src/types/toggle.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.19",
|
|
4
4
|
"description": "Data driven UI components for Rokkit applications",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,33 +8,34 @@
|
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"svelte": "./src/index.ts",
|
|
11
|
-
"types": "./
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"types": "./
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
15
|
"svelte": "./src/index.ts",
|
|
16
16
|
"default": "./src/index.ts"
|
|
17
17
|
},
|
|
18
18
|
"./types": {
|
|
19
|
-
"types": "./
|
|
19
|
+
"types": "./dist/types/index.d.ts",
|
|
20
20
|
"default": "./src/types/index.ts"
|
|
21
21
|
},
|
|
22
22
|
"./utils/palette": {
|
|
23
|
-
"types": "./
|
|
23
|
+
"types": "./dist/utils/palette.d.ts",
|
|
24
24
|
"default": "./src/utils/palette.ts"
|
|
25
25
|
},
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"src",
|
|
30
|
+
"dist/**/*.d.ts",
|
|
30
31
|
"README.md",
|
|
31
32
|
"LICENSE"
|
|
32
33
|
],
|
|
33
34
|
"scripts": {
|
|
34
|
-
"prepublishOnly": "cp ../../LICENSE .",
|
|
35
|
+
"prepublishOnly": "cp ../../LICENSE . && bun run build",
|
|
35
36
|
"postpublish": "rm -f LICENSE",
|
|
36
37
|
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
37
|
-
"build": "
|
|
38
|
+
"build": "svelte-package -i src -o dist"
|
|
38
39
|
},
|
|
39
40
|
"keywords": [
|
|
40
41
|
"ui",
|
|
@@ -44,10 +45,10 @@
|
|
|
44
45
|
"dropdown"
|
|
45
46
|
],
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@rokkit/core": "1.1.
|
|
48
|
-
"@rokkit/data": "1.1.
|
|
49
|
-
"@rokkit/states": "1.1.
|
|
50
|
-
"@rokkit/actions": "1.1.
|
|
48
|
+
"@rokkit/core": "1.1.19",
|
|
49
|
+
"@rokkit/data": "1.1.19",
|
|
50
|
+
"@rokkit/states": "1.1.19",
|
|
51
|
+
"@rokkit/actions": "1.1.19",
|
|
51
52
|
"marked": "^15.0.0",
|
|
52
53
|
"dompurify": "^3.0.0"
|
|
53
54
|
},
|
|
@@ -56,6 +57,8 @@
|
|
|
56
57
|
"svelte": "^5.0.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
60
|
+
"@sveltejs/package": "^2.5.8",
|
|
61
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
59
62
|
"svelte": "^5.53.5",
|
|
60
63
|
"svelte-check": "^4.4.3",
|
|
61
64
|
"typescript": "^5.9.3"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { marked } from 'marked'
|
|
3
|
-
import type { Token, TokensList } from 'marked'
|
|
3
|
+
import type { Token, Tokens, TokensList } from 'marked'
|
|
4
4
|
import type { Component, Snippet } from 'svelte'
|
|
5
5
|
import type { MarkdownPlugin } from './markdown-plugin.js'
|
|
6
6
|
import DOMPurify from 'dompurify'
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
* - { type: 'token', token } — all other tokens
|
|
62
62
|
*/
|
|
63
63
|
type Segment =
|
|
64
|
-
| { type: 'group'; id: string; items:
|
|
64
|
+
| { type: 'group'; id: string; items: Tokens.Code[] }
|
|
65
65
|
| { type: 'token'; token: Token }
|
|
66
66
|
|
|
67
67
|
const segments = $derived.by((): Segment[] => {
|
|
@@ -69,10 +69,12 @@
|
|
|
69
69
|
|
|
70
70
|
const result: Segment[] = []
|
|
71
71
|
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
72
|
-
const groupMap = new Map<string, { type: 'group'; id: string; items:
|
|
72
|
+
const groupMap = new Map<string, { type: 'group'; id: string; items: Tokens.Code[] }>()
|
|
73
73
|
|
|
74
74
|
for (const token of tokens) {
|
|
75
75
|
const cfId = getCfGroup(token)
|
|
76
|
+
// getCfGroup only returns a non-null id for `type: 'code'` tokens,
|
|
77
|
+
// so a grouped token is always a Code token (carries lang + text).
|
|
76
78
|
if (cfId) {
|
|
77
79
|
let group = groupMap.get(cfId)
|
|
78
80
|
if (!group) {
|
|
@@ -80,7 +82,7 @@
|
|
|
80
82
|
groupMap.set(cfId, group)
|
|
81
83
|
result.push(group)
|
|
82
84
|
}
|
|
83
|
-
group.items.push(token)
|
|
85
|
+
group.items.push(token as Tokens.Code)
|
|
84
86
|
} else {
|
|
85
87
|
result.push({ type: 'token', token })
|
|
86
88
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { HTMLAnchorAttributes } from 'svelte/elements'
|
|
2
3
|
import type { ButtonProps } from '../types/button.js'
|
|
3
4
|
import { ProxyItem } from '@rokkit/states'
|
|
4
5
|
import ItemContent from './ItemContent.svelte'
|
|
@@ -25,6 +26,11 @@
|
|
|
25
26
|
const isIconOnly = $derived(Boolean(icon) && !label && !children)
|
|
26
27
|
const isDisabled = $derived(disabled || loading)
|
|
27
28
|
|
|
29
|
+
// `rest` carries `<button>` attribute types (ButtonProps extends HTMLButtonAttributes);
|
|
30
|
+
// when rendering the link variant, re-type the passthrough attrs as anchor attrs so the
|
|
31
|
+
// element-specific event-handler signatures (e.g. onclick targeting HTMLAnchorElement) line up.
|
|
32
|
+
const anchorRest = $derived(rest as HTMLAnchorAttributes)
|
|
33
|
+
|
|
28
34
|
/**
|
|
29
35
|
* Create a ProxyItem for default content rendering.
|
|
30
36
|
* Constructs a minimal item from button props.
|
|
@@ -56,7 +62,7 @@
|
|
|
56
62
|
class={className || undefined}
|
|
57
63
|
aria-label={label}
|
|
58
64
|
aria-busy={loading || undefined}
|
|
59
|
-
{...
|
|
65
|
+
{...anchorRest}
|
|
60
66
|
>
|
|
61
67
|
{#if children}
|
|
62
68
|
{@render children()}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { commands, messages } from '@rokkit/states'
|
|
3
3
|
import { dismissable } from '@rokkit/actions'
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/** Minimal command shape this palette reads (states' Command typedef isn't exported). */
|
|
6
|
+
type CommandLike = { id: string; label: string; keywords?: string[] }
|
|
7
|
+
|
|
8
|
+
let { open = $bindable(false), placeholder }: { open?: boolean; placeholder?: string } = $props()
|
|
7
9
|
|
|
8
10
|
let query = $state('')
|
|
9
11
|
let activeIndex = $state(0)
|
|
@@ -14,7 +16,7 @@
|
|
|
14
16
|
label: messages.command.label
|
|
15
17
|
})
|
|
16
18
|
|
|
17
|
-
function score(cmd, q) {
|
|
19
|
+
function score(cmd: CommandLike, q: string) {
|
|
18
20
|
const hay = `${cmd.label} ${cmd.id} ${(cmd.keywords ?? []).join(' ')}`.toLowerCase()
|
|
19
21
|
return hay.includes(q)
|
|
20
22
|
}
|
|
@@ -30,14 +32,14 @@
|
|
|
30
32
|
activeIndex = 0
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
function runAt(index) {
|
|
35
|
+
function runAt(index: number) {
|
|
34
36
|
const cmd = results[index]
|
|
35
37
|
if (!cmd) return
|
|
36
38
|
close()
|
|
37
39
|
commands.execute(cmd.id)
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
function onkeydown(event) {
|
|
42
|
+
function onkeydown(event: KeyboardEvent) {
|
|
41
43
|
if (event.key === 'ArrowDown') {
|
|
42
44
|
event.preventDefault()
|
|
43
45
|
activeIndex = Math.min(activeIndex + 1, results.length - 1)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
// @ts-nocheck
|
|
3
2
|
/**
|
|
4
3
|
* LazyTree — Tree + lazy loading.
|
|
5
4
|
*
|
|
@@ -20,7 +19,7 @@
|
|
|
20
19
|
let {
|
|
21
20
|
items = [],
|
|
22
21
|
fields = {},
|
|
23
|
-
value,
|
|
22
|
+
value = $bindable(),
|
|
24
23
|
size = 'md',
|
|
25
24
|
lineStyle = 'solid',
|
|
26
25
|
labels: userLabels = {},
|
|
@@ -34,7 +33,7 @@
|
|
|
34
33
|
items?: unknown[]
|
|
35
34
|
fields?: Record<string, string>
|
|
36
35
|
value?: unknown
|
|
37
|
-
size?:
|
|
36
|
+
size?: 'sm' | 'md' | 'lg'
|
|
38
37
|
lineStyle?: 'none' | 'solid' | 'dashed' | 'dotted'
|
|
39
38
|
labels?: Record<string, string>
|
|
40
39
|
icons?: { opened?: string; closed?: string }
|
|
@@ -51,7 +50,7 @@
|
|
|
51
50
|
|
|
52
51
|
const proxyTree = $derived(
|
|
53
52
|
new ProxyTree(items, fields, {
|
|
54
|
-
createProxy: (raw, f, key, level) =>
|
|
53
|
+
createProxy: (raw: unknown, f: Record<string, string>, key: string, level: number) =>
|
|
55
54
|
new LazyProxyItem(
|
|
56
55
|
raw,
|
|
57
56
|
f,
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
* data-select-divider — divider between groups
|
|
25
25
|
* data-path, data-selected, data-checked, data-disabled, data-open, data-size
|
|
26
26
|
*/
|
|
27
|
-
// @ts-nocheck
|
|
28
27
|
import type { ProxyItem } from '@rokkit/states'
|
|
29
28
|
import { Wrapper, ProxyTree, messages } from '@rokkit/states'
|
|
30
29
|
import { SvelteSet } from 'svelte/reactivity'
|
|
@@ -92,9 +91,10 @@
|
|
|
92
91
|
// Force groups expanded + disabled (non-navigable labels)
|
|
93
92
|
const processedItems = $derived(
|
|
94
93
|
items.map((item) => {
|
|
95
|
-
const
|
|
94
|
+
const asRecord = item as Record<string, unknown>
|
|
95
|
+
const children = asRecord[childrenField]
|
|
96
96
|
if (Array.isArray(children) && children.length > 0) {
|
|
97
|
-
return { ...
|
|
97
|
+
return { ...asRecord, expanded: true, disabled: true }
|
|
98
98
|
}
|
|
99
99
|
return item
|
|
100
100
|
})
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ProxyItem } from '@rokkit/states'
|
|
3
|
-
import { keyboard } from '@rokkit/actions'
|
|
4
3
|
import { DEFAULT_STATE_ICONS } from '@rokkit/core'
|
|
5
4
|
import type { PillIcons, PillProps } from '../types/pill.js'
|
|
6
5
|
|
|
@@ -19,13 +18,19 @@
|
|
|
19
18
|
|
|
20
19
|
const proxy = $derived(new ProxyItem(value, fields))
|
|
21
20
|
|
|
22
|
-
const keyMap = $derived(removable && !disabled ? { remove: ['Delete', 'Backspace'] } : {})
|
|
23
|
-
|
|
24
21
|
function handleRemove() {
|
|
25
22
|
if (!disabled) {
|
|
26
23
|
onremove?.(value)
|
|
27
24
|
}
|
|
28
25
|
}
|
|
26
|
+
|
|
27
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
28
|
+
if (!removable || disabled) return
|
|
29
|
+
if (event.key === 'Delete' || event.key === 'Backspace') {
|
|
30
|
+
event.preventDefault()
|
|
31
|
+
handleRemove()
|
|
32
|
+
}
|
|
33
|
+
}
|
|
29
34
|
</script>
|
|
30
35
|
|
|
31
36
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
@@ -33,8 +38,8 @@
|
|
|
33
38
|
data-pill
|
|
34
39
|
data-pill-disabled={disabled || undefined}
|
|
35
40
|
class={className || undefined}
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
role={removable && !disabled ? 'button' : undefined}
|
|
42
|
+
onkeydown={handleKeydown}
|
|
38
43
|
tabindex={removable && !disabled ? 0 : undefined}
|
|
39
44
|
>
|
|
40
45
|
{#if content}
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
* data-align — dropdown alignment
|
|
38
38
|
* data-direction — dropdown direction
|
|
39
39
|
*/
|
|
40
|
-
// @ts-nocheck
|
|
41
40
|
import type { ProxyItem } from '@rokkit/states'
|
|
42
41
|
import { Wrapper, ProxyTree, messages } from '@rokkit/states'
|
|
43
42
|
import { SvelteSet } from 'svelte/reactivity'
|
|
@@ -139,9 +138,10 @@
|
|
|
139
138
|
// Pre-process: force groups expanded + disabled (non-navigable labels)
|
|
140
139
|
const processedItems = $derived(
|
|
141
140
|
filteredItems.map((item) => {
|
|
142
|
-
const
|
|
141
|
+
const asRecord = item as Record<string, unknown>
|
|
142
|
+
const children = asRecord[childrenField]
|
|
143
143
|
if (Array.isArray(children) && children.length > 0) {
|
|
144
|
-
return { ...
|
|
144
|
+
return { ...asRecord, expanded: true, disabled: true }
|
|
145
145
|
}
|
|
146
146
|
return item
|
|
147
147
|
})
|
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { ProxyItem } from '@rokkit/states'
|
|
4
|
+
import { Wrapper, ProxyTree } from '@rokkit/states'
|
|
4
5
|
import { Navigator } from '@rokkit/actions'
|
|
5
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
|
+
|
|
6
33
|
let {
|
|
7
34
|
options = [],
|
|
8
35
|
fields: userFields = {},
|
|
@@ -11,12 +38,12 @@
|
|
|
11
38
|
shape = 'square',
|
|
12
39
|
size = 'md',
|
|
13
40
|
disabled = false,
|
|
14
|
-
label =
|
|
41
|
+
label = 'Select',
|
|
15
42
|
class: className = '',
|
|
16
43
|
onchange,
|
|
17
44
|
item: itemSnippet,
|
|
18
45
|
..._rest
|
|
19
|
-
} = $props()
|
|
46
|
+
}: SwatchProps = $props()
|
|
20
47
|
|
|
21
48
|
const proxyTree = $derived(new ProxyTree(options, userFields))
|
|
22
49
|
const wrapper = $derived(new Wrapper(proxyTree, { onselect: handleSelect }))
|
|
@@ -33,12 +60,12 @@
|
|
|
33
60
|
wrapper.moveToValue(value)
|
|
34
61
|
})
|
|
35
62
|
|
|
36
|
-
function isSelected(proxy) {
|
|
63
|
+
function isSelected(proxy: ProxyItem) {
|
|
37
64
|
if (multiple && Array.isArray(value)) return value.includes(proxy.value)
|
|
38
65
|
return proxy.value === value
|
|
39
66
|
}
|
|
40
67
|
|
|
41
|
-
function toggleMultiValue(extracted, original) {
|
|
68
|
+
function toggleMultiValue(extracted: unknown, original: unknown) {
|
|
42
69
|
const arr = Array.isArray(value) ? [...value] : []
|
|
43
70
|
const idx = arr.indexOf(extracted)
|
|
44
71
|
if (idx >= 0) arr.splice(idx, 1)
|
|
@@ -47,13 +74,13 @@
|
|
|
47
74
|
onchange?.(value, original)
|
|
48
75
|
}
|
|
49
76
|
|
|
50
|
-
function selectSingleValue(extracted, original) {
|
|
77
|
+
function selectSingleValue(extracted: unknown, original: unknown) {
|
|
51
78
|
if (extracted === value) return
|
|
52
79
|
value = extracted
|
|
53
80
|
onchange?.(extracted, original)
|
|
54
81
|
}
|
|
55
82
|
|
|
56
|
-
function handleSelect(extracted, proxy) {
|
|
83
|
+
function handleSelect(extracted: unknown, proxy: ProxyItem) {
|
|
57
84
|
if (proxy.disabled || disabled) return
|
|
58
85
|
if (multiple) toggleMultiValue(extracted, proxy.original)
|
|
59
86
|
else selectSingleValue(extracted, proxy.original)
|
|
@@ -129,7 +129,8 @@
|
|
|
129
129
|
>
|
|
130
130
|
<span data-table-header-text>{column.label ?? column.name}</span>
|
|
131
131
|
{#if column.sortable !== false}
|
|
132
|
-
{@const sortIcon =
|
|
132
|
+
{@const sortIcon =
|
|
133
|
+
icons[(column.sorted ?? 'none') as keyof TableSortIcons] ?? icons.none}
|
|
133
134
|
<span data-table-sort-icon class={sortIcon} aria-hidden="true"></span>
|
|
134
135
|
{/if}
|
|
135
136
|
</th>
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
* Tab panels are rendered separately from triggers. Only the active panel
|
|
18
18
|
* receives data-panel-active. Navigator ignores panels (no data-path on them).
|
|
19
19
|
*/
|
|
20
|
-
// @ts-nocheck
|
|
21
20
|
import type { TabsProps } from '../types/tabs.js'
|
|
22
21
|
import type { ProxyItem } from '@rokkit/states'
|
|
23
22
|
import { Wrapper, ProxyTree, messages } from '@rokkit/states'
|
|
@@ -52,7 +51,7 @@
|
|
|
52
51
|
const wrapper = $derived(
|
|
53
52
|
new Wrapper(proxyTree, {
|
|
54
53
|
onchange,
|
|
55
|
-
onselect: (v, proxy) => {
|
|
54
|
+
onselect: (v: unknown, proxy: ProxyItem) => {
|
|
56
55
|
value = v
|
|
57
56
|
onselect?.(v, proxy)
|
|
58
57
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
// @ts-nocheck
|
|
3
2
|
import type { ToggleProps } from '../types/toggle.js'
|
|
3
|
+
import type { ProxyItem } from '@rokkit/states'
|
|
4
4
|
import { Wrapper, ProxyTree, messages } from '@rokkit/states'
|
|
5
5
|
import { Navigator } from '@rokkit/actions'
|
|
6
6
|
import { resolveSnippet } from '@rokkit/core'
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
|
|
44
44
|
// ─── Selection handler ─────────────────────────────────────────────────────
|
|
45
45
|
|
|
46
|
-
function handleSelect(extractedValue, proxy) {
|
|
46
|
+
function handleSelect(extractedValue: unknown, proxy: ProxyItem) {
|
|
47
47
|
if (proxy.disabled || disabled) return
|
|
48
48
|
if (extractedValue !== value) {
|
|
49
49
|
value = extractedValue
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
// @ts-nocheck
|
|
3
2
|
/**
|
|
4
3
|
* Tree — Hierarchical data navigation with tree lines and keyboard navigation.
|
|
5
4
|
*
|
|
@@ -22,7 +21,7 @@
|
|
|
22
21
|
let {
|
|
23
22
|
items = [],
|
|
24
23
|
fields = {},
|
|
25
|
-
value,
|
|
24
|
+
value = $bindable(),
|
|
26
25
|
size = 'md',
|
|
27
26
|
lineStyle = 'solid',
|
|
28
27
|
labels: userLabels = {},
|
|
@@ -177,7 +177,8 @@
|
|
|
177
177
|
>
|
|
178
178
|
<span data-table-header-text>{column.label ?? column.name}</span>
|
|
179
179
|
{#if column.sortable !== false}
|
|
180
|
-
{@const sortIcon =
|
|
180
|
+
{@const sortIcon =
|
|
181
|
+
icons[(column.sorted ?? 'none') as keyof TableSortIcons] ?? icons.none}
|
|
181
182
|
<span data-table-sort-icon class={sortIcon} aria-hidden="true"></span>
|
|
182
183
|
{/if}
|
|
183
184
|
</th>
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* data-dragging — present when files dragged over
|
|
13
13
|
* data-disabled — when disabled
|
|
14
14
|
*/
|
|
15
|
+
import type { Snippet } from 'svelte'
|
|
15
16
|
import type { UploadTargetProps } from '../types/upload-target.js'
|
|
16
17
|
import { messages } from '@rokkit/states'
|
|
17
18
|
import { matchesAccept } from '../utils/upload.js'
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
...snippets
|
|
30
31
|
}: UploadTargetProps & { [key: string]: unknown } = $props()
|
|
31
32
|
|
|
32
|
-
const content = $derived(snippets.content as
|
|
33
|
+
const content = $derived(snippets.content as Snippet<[dragging: boolean]> | undefined)
|
|
33
34
|
|
|
34
35
|
const resolvedLabels = $derived({
|
|
35
36
|
...messages.uploadTarget,
|
package/src/types/button.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { Snippet } from 'svelte'
|
|
9
|
+
import type { HTMLButtonAttributes } from 'svelte/elements'
|
|
9
10
|
|
|
10
11
|
// =============================================================================
|
|
11
12
|
// Variant & Style Types
|
|
@@ -22,9 +23,14 @@ export type ButtonStyle = 'default' | 'outline' | 'ghost' | 'gradient' | 'link'
|
|
|
22
23
|
// =============================================================================
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
|
-
* Props for the Button component
|
|
26
|
+
* Props for the Button component.
|
|
27
|
+
*
|
|
28
|
+
* Extends native `<button>` attributes so consumers can pass `aria-*`,
|
|
29
|
+
* `onclick`, `title`, `name`, `form`, etc. The native `style` and `type`
|
|
30
|
+
* keys are omitted because this component repurposes `style` (visual
|
|
31
|
+
* treatment) and narrows `type` to the valid button types.
|
|
26
32
|
*/
|
|
27
|
-
export interface ButtonProps {
|
|
33
|
+
export interface ButtonProps extends Omit<HTMLButtonAttributes, 'style' | 'type'> {
|
|
28
34
|
/** Semantic color variant */
|
|
29
35
|
variant?: ButtonVariant
|
|
30
36
|
|
package/src/types/tabs.ts
CHANGED
|
@@ -80,11 +80,11 @@ export interface TabsProps {
|
|
|
80
80
|
/** Additional CSS classes */
|
|
81
81
|
class?: string
|
|
82
82
|
|
|
83
|
-
/** Called when selection changes */
|
|
84
|
-
onchange?: (value: unknown, item:
|
|
83
|
+
/** Called when selection changes — receives the value and the tab's ProxyItem */
|
|
84
|
+
onchange?: (value: unknown, item: ProxyItem) => void
|
|
85
85
|
|
|
86
|
-
/** Called when a tab is selected (fires on every click, including same tab) */
|
|
87
|
-
onselect?: (value: unknown, item:
|
|
86
|
+
/** Called when a tab is selected (fires on every click, including same tab) — receives the value and the tab's ProxyItem */
|
|
87
|
+
onselect?: (value: unknown, item: ProxyItem) => void
|
|
88
88
|
|
|
89
89
|
/** Called when a new tab is requested (editable mode) */
|
|
90
90
|
onadd?: () => void
|
package/src/types/toggle.ts
CHANGED
|
@@ -13,9 +13,10 @@ import type { ProxyItem } from '@rokkit/states'
|
|
|
13
13
|
// =============================================================================
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Generic toggle item -
|
|
16
|
+
* Generic toggle item — data-driven, so it accepts primitives
|
|
17
|
+
* (string/number) as well as objects with mapped fields.
|
|
17
18
|
*/
|
|
18
|
-
export type ToggleItem = Record<string, unknown>
|
|
19
|
+
export type ToggleItem = string | number | Record<string, unknown>
|
|
19
20
|
|
|
20
21
|
// =============================================================================
|
|
21
22
|
// Snippet Types
|