@rokkit/ui 1.4.1 → 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.
Files changed (41) hide show
  1. package/dist/components/CodeGroup.svelte +0 -1
  2. package/dist/components/CommandPalette.svelte +2 -1
  3. package/dist/components/CommandPalette.svelte.d.ts +2 -5
  4. package/dist/components/Dropdown.svelte +3 -22
  5. package/dist/components/Dropdown.svelte.d.ts +2 -20
  6. package/dist/components/Grid.svelte +2 -13
  7. package/dist/components/Grid.svelte.d.ts +2 -43
  8. package/dist/components/LazyTree.svelte +2 -15
  9. package/dist/components/LazyTree.svelte.d.ts +2 -28
  10. package/dist/components/List.svelte +3 -19
  11. package/dist/components/List.svelte.d.ts +2 -47
  12. package/dist/components/Menu.svelte +3 -24
  13. package/dist/components/Menu.svelte.d.ts +2 -66
  14. package/dist/components/MultiSelect.svelte +3 -24
  15. package/dist/components/MultiSelect.svelte.d.ts +2 -23
  16. package/dist/components/Select.svelte +3 -25
  17. package/dist/components/Select.svelte.d.ts +2 -24
  18. package/dist/components/Swatch.svelte +1 -26
  19. package/dist/components/Swatch.svelte.d.ts +1 -27
  20. package/dist/components/Tabs.svelte +7 -1
  21. package/dist/components/Tabs.svelte.d.ts +2 -0
  22. package/dist/components/Toggle.svelte +6 -1
  23. package/dist/components/Toggle.svelte.d.ts +2 -0
  24. package/dist/components/Tree.svelte +2 -12
  25. package/dist/components/Tree.svelte.d.ts +2 -29
  26. package/dist/types/chat.d.ts +15 -0
  27. package/dist/types/command-palette.d.ts +18 -0
  28. package/dist/types/command-palette.js +7 -0
  29. package/dist/types/grid.d.ts +37 -0
  30. package/dist/types/grid.js +8 -0
  31. package/dist/types/index.d.ts +4 -0
  32. package/dist/types/index.js +8 -0
  33. package/dist/types/list.d.ts +22 -55
  34. package/dist/types/menu.d.ts +9 -2
  35. package/dist/types/select.d.ts +52 -62
  36. package/dist/types/snippets.d.ts +55 -0
  37. package/dist/types/snippets.js +16 -0
  38. package/dist/types/swatch.d.ts +41 -0
  39. package/dist/types/swatch.js +8 -0
  40. package/dist/types/tree.d.ts +34 -66
  41. package/package.json +9 -8
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Swatch Component Types
3
+ *
4
+ * A group of selectable colour swatches. Options may be primitives (hex or
5
+ * colour-name strings) or objects whose fill/stroke/value are read through the
6
+ * usual field mapping.
7
+ */
8
+ import type { Snippet } from 'svelte';
9
+ import type { ProxyItem } from '@rokkit/states';
10
+ /**
11
+ * Props for the Swatch component.
12
+ *
13
+ * `Swatch.svelte` annotates its own `$props()` with this interface, so the two
14
+ * cannot drift.
15
+ */
16
+ export interface SwatchProps {
17
+ /** Color options — primitives (hex/name strings) or objects with mapped fields */
18
+ options?: Array<string | number | Record<string, unknown>>;
19
+ /** Field mapping for object options (value, fill, stroke, …) */
20
+ fields?: Record<string, string>;
21
+ /** Selected value (bindable). Array when `multiple`. */
22
+ value?: unknown;
23
+ /** Allow multiple selection */
24
+ multiple?: boolean;
25
+ /** Swatch shape */
26
+ shape?: 'square' | 'circle';
27
+ /** Size variant */
28
+ size?: 'sm' | 'md' | 'lg';
29
+ /** Disable the whole group */
30
+ disabled?: boolean;
31
+ /** Accessible group label */
32
+ label?: string;
33
+ /** Additional CSS classes */
34
+ class?: string;
35
+ /** Called when selection changes */
36
+ onchange?: (value: unknown, item: unknown) => void;
37
+ /** Custom snippet for rendering a swatch (receives proxy + selected) */
38
+ item?: Snippet<[ProxyItem, boolean]>;
39
+ /** Remaining props are spread through */
40
+ [key: string]: unknown;
41
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Swatch Component Types
3
+ *
4
+ * A group of selectable colour swatches. Options may be primitives (hex or
5
+ * colour-name strings) or objects whose fill/stroke/value are read through the
6
+ * usual field mapping.
7
+ */
8
+ export {};
@@ -5,7 +5,8 @@
5
5
  * Supports hierarchical data with expand/collapse, tree lines, and custom icons.
6
6
  * Field mapping and data access is handled by ProxyItem from @rokkit/states.
7
7
  */
8
- import type { Snippet } from 'svelte';
8
+ import type { ItemSnippets } from './snippets.js';
9
+ import type { ProxyItem } from '@rokkit/states';
9
10
  /**
10
11
  * Field mapping configuration for tree data — what the consumer passes
11
12
  * to the Tree component. Both `expanded` and `level` are optional here
@@ -87,82 +88,49 @@ export interface TreeStateIcons {
87
88
  */
88
89
  export declare const defaultTreeStateIcons: TreeStateIcons;
89
90
  /**
90
- * Handlers passed to custom item snippets
91
- */
92
- export interface TreeItemHandlers {
93
- /** Call to trigger item selection */
94
- onclick: () => void;
95
- /** Call to toggle expand/collapse */
96
- ontoggle: () => void;
97
- /** Forward keyboard events for accessibility */
98
- onkeydown: (event: KeyboardEvent) => void;
99
- }
100
- /**
101
- * Snippet type for rendering tree nodes.
102
- * Parameters: item, fields, handlers, isActive, isExpanded, level
103
- */
104
- export type TreeItemSnippet = Snippet<[
105
- TreeItem,
106
- TreeFields,
107
- TreeItemHandlers,
108
- boolean,
109
- boolean,
110
- number
111
- ]>;
112
- /**
113
- * Snippet type for rendering the expand/collapse icon
114
- * Parameters: isExpanded, hasChildren, icons
115
- */
116
- export type TreeToggleSnippet = Snippet<[boolean, boolean, TreeStateIcons]>;
117
- /**
118
- * Snippet type for rendering tree line connectors
119
- * Parameters: lineType
91
+ * Props for the Tree component
120
92
  */
121
- export type TreeConnectorSnippet = Snippet<[TreeLineType]>;
122
93
  /**
123
- * Props for the Tree component
94
+ * Props for the Tree component.
95
+ *
96
+ * `Tree.svelte` annotates its own `$props()` with this interface, so the two
97
+ * cannot drift — which is how the previous version came to describe
98
+ * `multiselect`, `expanded`, `selected`, `expandAll`, `active` and four
99
+ * callbacks the component never read.
124
100
  */
125
- export interface TreeProps {
101
+ export interface TreeProps extends ItemSnippets {
126
102
  /** Array of tree items (hierarchical) */
127
- items?: TreeItem[];
103
+ items?: unknown[];
128
104
  /** Field mapping configuration */
129
- fields?: TreeFields;
130
- /** Currently selected value */
105
+ fields?: Record<string, string>;
106
+ /** Selected value (bindable) */
131
107
  value?: unknown;
132
108
  /** Size variant */
133
- size?: 'sm' | 'md' | 'lg';
134
- /** Tree line connector style — 'none' hides lines, 'solid'|'dashed'|'dotted' set the line style */
109
+ size?: string;
110
+ /** Connector style — 'none' hides the lines */
135
111
  lineStyle?: 'none' | 'solid' | 'dashed' | 'dotted';
136
- /** Enable multiple item selection (Ctrl+click toggle, Shift+click range) */
137
- multiselect?: boolean;
138
- /** Which nodes are expanded (bindable) - keyed by node value */
139
- expanded?: Record<string, boolean>;
140
- /** Selected items array (bindable) - populated in multiselect mode */
141
- selected?: unknown[];
142
- /** Expand all nodes by default */
143
- expandAll?: boolean;
144
- /** Active item value - Tree looks up item by this value to highlight it */
145
- active?: unknown;
112
+ /** Accessible label overrides */
113
+ labels?: Record<string, string>;
146
114
  /** Icons for expand/collapse states */
147
- icons?: TreeStateIcons;
148
- /** Called when an item is selected */
149
- onselect?: (value: unknown, item: TreeItem) => void;
150
- /** Called when selected items change in multiselect mode */
151
- onselectedchange?: (selected: unknown[]) => void;
152
- /** Called when expanded state changes */
153
- onexpandedchange?: (expanded: Record<string, boolean>) => void;
154
- /** Called when a node is toggled */
155
- ontoggle?: (value: unknown, item: TreeItem, isExpanded: boolean) => void;
156
- /** Called when expanding a node with unloaded children (children: true). Returns the children array. */
157
- onloadchildren?: (value: unknown, item: TreeItem) => Promise<TreeItem[]>;
115
+ icons?: {
116
+ opened?: string;
117
+ closed?: string;
118
+ };
119
+ /** Called when an item is selected, with the item's `ProxyItem` */
120
+ onselect?: (value: unknown, proxy: ProxyItem) => void;
158
121
  /** Additional CSS classes */
159
122
  class?: string;
160
- /** Custom snippet for rendering tree items */
161
- item?: TreeItemSnippet;
162
- /** Custom snippet for rendering expand/collapse toggle */
163
- toggle?: TreeToggleSnippet;
164
- /** Custom snippet for rendering tree line connectors */
165
- connector?: TreeConnectorSnippet;
123
+ }
124
+ /**
125
+ * Props for the LazyTree component — Tree plus on-demand child loading.
126
+ */
127
+ export interface LazyTreeProps extends TreeProps {
128
+ /** Size variant */
129
+ size?: 'sm' | 'md' | 'lg';
130
+ /** Called to fetch the children of a node being expanded */
131
+ onlazyload?: (current?: unknown) => Promise<unknown[]>;
132
+ /** Whether more nodes remain to load */
133
+ hasMore?: boolean;
166
134
  }
167
135
  /**
168
136
  * Constructs an array of line types for tree visualization.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/ui",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "Data driven UI components for Rokkit applications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,6 +34,7 @@
34
34
  "prepublishOnly": "cp ../../LICENSE . && bun run build && node ../../config/pack-repoint.mjs",
35
35
  "postpublish": "node ../../config/pack-repoint.mjs --restore && rm -f LICENSE",
36
36
  "check": "svelte-check --tsconfig ./tsconfig.json",
37
+ "check:types": "tsc --noEmit",
37
38
  "build": "svelte-package -i src -o dist"
38
39
  },
39
40
  "keywords": [
@@ -44,12 +45,12 @@
44
45
  "dropdown"
45
46
  ],
46
47
  "dependencies": {
47
- "@rokkit/core": "1.4.1",
48
- "@rokkit/data": "1.4.1",
49
- "@rokkit/states": "1.4.1",
50
- "@rokkit/actions": "1.4.1",
48
+ "@rokkit/core": "1.5.0",
49
+ "@rokkit/data": "1.5.0",
50
+ "@rokkit/states": "1.5.0",
51
+ "@rokkit/actions": "1.5.0",
51
52
  "marked": "^15.0.0",
52
- "dompurify": "^3.0.0"
53
+ "dompurify": "^3.4.13"
53
54
  },
54
55
  "peerDependencies": {
55
56
  "shiki": "^3.23.0",
@@ -58,8 +59,8 @@
58
59
  "devDependencies": {
59
60
  "@sveltejs/package": "^2.5.8",
60
61
  "@sveltejs/vite-plugin-svelte": "^6.2.4",
61
- "svelte": "^5.53.5",
62
- "svelte-check": "^4.4.3",
62
+ "svelte": "^5.55.7",
63
+ "svelte-check": "^4.7.6",
63
64
  "typescript": "^5.9.3"
64
65
  }
65
66
  }