@rokkit/ui 1.0.0-next.99 → 1.0.2
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/README.md +159 -1
- package/package.json +52 -53
- package/src/MarkdownRenderer.svelte +106 -0
- package/src/components/AlertList.svelte +59 -0
- package/src/components/Avatar.svelte +68 -0
- package/src/components/Badge.svelte +57 -0
- package/src/components/BreadCrumbs.svelte +94 -0
- package/src/components/Button.svelte +91 -0
- package/src/components/ButtonGroup.svelte +9 -0
- package/src/components/Card.svelte +71 -0
- package/src/components/Carousel.svelte +169 -0
- package/src/components/Code.svelte +189 -0
- package/src/components/Connector.svelte +46 -0
- package/src/components/Divider.svelte +24 -0
- package/src/components/Dropdown.svelte +202 -0
- package/src/components/FloatingAction.svelte +367 -0
- package/src/components/FloatingNavigation.svelte +256 -0
- package/src/components/Grid.svelte +128 -0
- package/src/components/ItemContent.svelte +25 -0
- package/src/components/LazyTree.svelte +171 -0
- package/src/components/List.svelte +224 -0
- package/src/components/Menu.svelte +270 -0
- package/src/components/Message.svelte +75 -0
- package/src/components/MultiSelect.svelte +367 -0
- package/src/components/NavContent.svelte +42 -0
- package/src/components/PaletteManager.svelte +360 -0
- package/src/components/Pill.svelte +83 -0
- package/src/components/ProgressBar.svelte +31 -0
- package/src/components/Range.svelte +346 -0
- package/src/components/Rating.svelte +115 -0
- package/src/components/ResponsiveGrid.svelte +34 -0
- package/src/components/Reveal.svelte +46 -0
- package/src/components/SearchFilter.svelte +88 -0
- package/src/components/Select.svelte +424 -0
- package/src/components/Shine.svelte +87 -0
- package/src/components/Stack.svelte +38 -0
- package/src/components/StatusList.svelte +18 -0
- package/src/components/Stepper.svelte +174 -0
- package/src/components/Swatch.svelte +102 -0
- package/src/components/Switch.svelte +71 -0
- package/src/components/Table.svelte +245 -0
- package/src/components/Tabs.svelte +202 -0
- package/src/components/Tilt.svelte +68 -0
- package/src/components/Timeline.svelte +61 -0
- package/src/components/Toggle.svelte +93 -0
- package/src/components/Toolbar.svelte +306 -0
- package/src/components/ToolbarGroup.svelte +17 -0
- package/src/components/Tooltip.svelte +121 -0
- package/src/components/Tree.svelte +143 -0
- package/src/components/UploadFileStatus.svelte +102 -0
- package/src/components/UploadProgress.svelte +127 -0
- package/src/components/UploadTarget.svelte +126 -0
- package/src/components/index.ts +50 -0
- package/src/index.ts +61 -0
- package/src/markdown-plugin.ts +12 -0
- package/src/types/button.ts +86 -0
- package/src/types/code.ts +46 -0
- package/src/types/floating-action.ts +123 -0
- package/src/types/floating-navigation.ts +80 -0
- package/src/types/index.ts +58 -0
- package/src/types/list.ts +200 -0
- package/src/types/menu.ts +95 -0
- package/src/types/palette.ts +160 -0
- package/src/types/range.ts +51 -0
- package/src/types/search-filter.ts +67 -0
- package/src/types/select.ts +176 -0
- package/src/types/switch.ts +68 -0
- package/src/types/table.ts +219 -0
- package/src/types/tabs.ts +103 -0
- package/src/types/timeline.ts +53 -0
- package/src/types/toggle.ts +68 -0
- package/src/types/toolbar.ts +167 -0
- package/src/types/tooltip.ts +21 -0
- package/src/types/tree.ts +250 -0
- package/src/types/upload-file-status.ts +45 -0
- package/src/types/upload-progress.ts +111 -0
- package/src/types/upload-target.ts +71 -0
- package/src/utils/palette.ts +618 -0
- package/src/utils/shiki.ts +114 -0
- package/src/utils/upload.js +145 -0
- package/LICENSE +0 -21
- package/src/index.js +0 -8
- package/src/wrappers.js +0 -2
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SearchFilter Component Types
|
|
3
|
+
*
|
|
4
|
+
* Provides types for the standalone SearchFilter component.
|
|
5
|
+
* Parses user input into structured filter objects using parseFilters() from @rokkit/data.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Filter Types
|
|
10
|
+
// =============================================================================
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A parsed filter condition.
|
|
14
|
+
*/
|
|
15
|
+
export interface FilterObject {
|
|
16
|
+
/** Column to filter (undefined = search all columns) */
|
|
17
|
+
column?: string
|
|
18
|
+
|
|
19
|
+
/** Comparison operator */
|
|
20
|
+
operator: string
|
|
21
|
+
|
|
22
|
+
/** Filter value */
|
|
23
|
+
value: string | number | RegExp
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// =============================================================================
|
|
27
|
+
// Snippet Types
|
|
28
|
+
// =============================================================================
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Snippet for custom filter tag rendering.
|
|
32
|
+
* Parameters: filter, remove callback
|
|
33
|
+
*/
|
|
34
|
+
export type SearchFilterTagSnippet = import('svelte').Snippet<[FilterObject, () => void]>
|
|
35
|
+
|
|
36
|
+
// =============================================================================
|
|
37
|
+
// Component Props
|
|
38
|
+
// =============================================================================
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Props for the SearchFilter component.
|
|
42
|
+
*/
|
|
43
|
+
export interface SearchFilterProps {
|
|
44
|
+
/** Parsed filter array (bindable) */
|
|
45
|
+
filters?: FilterObject[]
|
|
46
|
+
|
|
47
|
+
/** Debounce delay in ms — default: 300 */
|
|
48
|
+
debounce?: number
|
|
49
|
+
|
|
50
|
+
/** Input placeholder text */
|
|
51
|
+
placeholder?: string
|
|
52
|
+
|
|
53
|
+
/** Column name hints for autocomplete (future use) */
|
|
54
|
+
columns?: string[]
|
|
55
|
+
|
|
56
|
+
/** Called when filters change */
|
|
57
|
+
onfilter?: (filters: FilterObject[]) => void
|
|
58
|
+
|
|
59
|
+
/** Additional CSS classes */
|
|
60
|
+
class?: string
|
|
61
|
+
|
|
62
|
+
/** Size variant */
|
|
63
|
+
size?: 'sm' | 'md' | 'lg'
|
|
64
|
+
|
|
65
|
+
/** Custom filter tag snippet */
|
|
66
|
+
tag?: SearchFilterTagSnippet
|
|
67
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Select Component Types
|
|
3
|
+
*
|
|
4
|
+
* Provides types for the data-driven Select and MultiSelect components.
|
|
5
|
+
* Field mapping and data access is handled by ProxyItem from @rokkit/states.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Snippet } from 'svelte'
|
|
9
|
+
import type { ProxyItem } from '@rokkit/states'
|
|
10
|
+
import { DEFAULT_STATE_ICONS } from '@rokkit/core'
|
|
11
|
+
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// Select Item Types
|
|
14
|
+
// =============================================================================
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Generic select item - can be any object with mapped fields
|
|
18
|
+
*/
|
|
19
|
+
export type SelectItem = Record<string, unknown>
|
|
20
|
+
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// Legacy types — retained while PaletteManager still uses old snippet API
|
|
23
|
+
// =============================================================================
|
|
24
|
+
|
|
25
|
+
/** @deprecated Legacy handlers — will be removed when PaletteManager migrates to Navigator stack */
|
|
26
|
+
export interface SelectItemHandlers {
|
|
27
|
+
onclick: () => void
|
|
28
|
+
onkeydown: (event: KeyboardEvent) => void
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// Snippet Types — ProxyItem-based API
|
|
33
|
+
// =============================================================================
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Snippet type for rendering a single option in the dropdown.
|
|
37
|
+
* The component renders the focusable wrapper; the snippet renders the inner content.
|
|
38
|
+
* Navigator handles click selection via data-path — no handlers needed in snippet.
|
|
39
|
+
*/
|
|
40
|
+
export type SelectOptionSnippet = Snippet<[ProxyItem]>
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Snippet type for rendering a group header label.
|
|
44
|
+
*/
|
|
45
|
+
export type SelectGroupLabelSnippet = Snippet<[ProxyItem]>
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Snippet type for rendering the selected value display in the trigger button.
|
|
49
|
+
*/
|
|
50
|
+
export type SelectValueSnippet = Snippet<[ProxyItem]>
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Snippet type for rendering selected values in MultiSelect trigger.
|
|
54
|
+
* Receives the array of selected ProxyItems.
|
|
55
|
+
*/
|
|
56
|
+
export type MultiSelectValueSnippet = Snippet<[ProxyItem[]]>
|
|
57
|
+
|
|
58
|
+
// =============================================================================
|
|
59
|
+
// Component Props Types
|
|
60
|
+
// =============================================================================
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Common props shared between Select and MultiSelect
|
|
64
|
+
*/
|
|
65
|
+
export interface SelectBaseProps {
|
|
66
|
+
/** Array of select options or groups */
|
|
67
|
+
options?: SelectItem[]
|
|
68
|
+
|
|
69
|
+
/** Field mapping — overrides BASE_FIELDS defaults (text → 'label', value → 'value', …) */
|
|
70
|
+
fields?: Record<string, string>
|
|
71
|
+
|
|
72
|
+
/** Placeholder text when no selection */
|
|
73
|
+
placeholder?: string
|
|
74
|
+
|
|
75
|
+
/** Size variant */
|
|
76
|
+
size?: 'sm' | 'md' | 'lg'
|
|
77
|
+
|
|
78
|
+
/** Dropdown alignment relative to trigger */
|
|
79
|
+
align?: 'left' | 'right' | 'start' | 'end'
|
|
80
|
+
|
|
81
|
+
/** Dropdown slide direction */
|
|
82
|
+
direction?: 'up' | 'down'
|
|
83
|
+
|
|
84
|
+
/** Maximum visible rows in dropdown (default: 5) */
|
|
85
|
+
maxRows?: number
|
|
86
|
+
|
|
87
|
+
/** Whether the select is disabled */
|
|
88
|
+
disabled?: boolean
|
|
89
|
+
|
|
90
|
+
/** Additional CSS classes on root element */
|
|
91
|
+
class?: string
|
|
92
|
+
|
|
93
|
+
/** Icons for select states (dropdown arrow, check, remove) */
|
|
94
|
+
icons?: SelectStateIcons
|
|
95
|
+
|
|
96
|
+
/** Custom snippet for rendering options in dropdown */
|
|
97
|
+
option?: SelectOptionSnippet
|
|
98
|
+
|
|
99
|
+
/** Custom snippet for rendering group labels */
|
|
100
|
+
groupLabel?: SelectGroupLabelSnippet
|
|
101
|
+
|
|
102
|
+
/** Enable typeahead filter input in dropdown header */
|
|
103
|
+
filterable?: boolean
|
|
104
|
+
|
|
105
|
+
/** Placeholder text for the filter input */
|
|
106
|
+
filterPlaceholder?: string
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Props for the Select component (single selection)
|
|
111
|
+
*/
|
|
112
|
+
export interface SelectProps extends SelectBaseProps {
|
|
113
|
+
/** Currently selected value (bindable) — extracted via item[fields.value] */
|
|
114
|
+
value?: unknown
|
|
115
|
+
|
|
116
|
+
/** Currently selected raw item (bindable) — full object from options array */
|
|
117
|
+
selected?: SelectItem | null
|
|
118
|
+
|
|
119
|
+
/** Called when selection changes */
|
|
120
|
+
onchange?: (value: unknown, item: SelectItem) => void
|
|
121
|
+
|
|
122
|
+
/** Custom snippet for rendering the selected value in the trigger */
|
|
123
|
+
selectedValue?: SelectValueSnippet
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Props for the MultiSelect component (multiple selection)
|
|
128
|
+
*/
|
|
129
|
+
export interface MultiSelectProps extends SelectBaseProps {
|
|
130
|
+
/** Currently selected values (bindable) - extracted primitives */
|
|
131
|
+
value?: unknown[]
|
|
132
|
+
|
|
133
|
+
/** Currently selected items (bindable) - full item objects for convenience */
|
|
134
|
+
selected?: SelectItem[]
|
|
135
|
+
|
|
136
|
+
/** Called when selection changes */
|
|
137
|
+
onchange?: (values: unknown[], items: SelectItem[]) => void
|
|
138
|
+
|
|
139
|
+
/** Maximum number of tags to show before collapsing to count */
|
|
140
|
+
maxDisplay?: number
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// =============================================================================
|
|
144
|
+
// State Icons
|
|
145
|
+
// =============================================================================
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Icons configuration for select expand/collapse and selection states.
|
|
149
|
+
*/
|
|
150
|
+
export interface SelectStateIcons {
|
|
151
|
+
/** Icon class for dropdown arrow (open state) */
|
|
152
|
+
opened?: string
|
|
153
|
+
/** Icon class for dropdown arrow (closed state) */
|
|
154
|
+
closed?: string
|
|
155
|
+
/** Icon class for selected item indicator */
|
|
156
|
+
checked?: string
|
|
157
|
+
/** Icon class for tag remove button (MultiSelect) */
|
|
158
|
+
remove?: string
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Default state icons — uses semantic names from @rokkit/core
|
|
163
|
+
* that get resolved to actual icon classes via UnoCSS shortcuts.
|
|
164
|
+
*/
|
|
165
|
+
export const defaultSelectStateIcons: SelectStateIcons = {
|
|
166
|
+
opened: DEFAULT_STATE_ICONS.selector.opened,
|
|
167
|
+
closed: DEFAULT_STATE_ICONS.selector.closed,
|
|
168
|
+
checked: DEFAULT_STATE_ICONS.checkbox.checked,
|
|
169
|
+
remove: DEFAULT_STATE_ICONS.action.remove
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// =============================================================================
|
|
173
|
+
// Helper Functions
|
|
174
|
+
// =============================================================================
|
|
175
|
+
|
|
176
|
+
export { getSnippet } from './menu.js'
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Switch Component Types
|
|
3
|
+
*
|
|
4
|
+
* Provides types for the iOS-style Switch component.
|
|
5
|
+
* Field mapping and data access is handled by ProxyItem from @rokkit/states.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Field Mapping Types
|
|
10
|
+
// =============================================================================
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Field mapping configuration for switch option data.
|
|
14
|
+
* Maps custom data field names to the component's expected properties.
|
|
15
|
+
*/
|
|
16
|
+
export interface SwitchFields {
|
|
17
|
+
text?: string
|
|
18
|
+
value?: string
|
|
19
|
+
icon?: string
|
|
20
|
+
disabled?: string
|
|
21
|
+
description?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// =============================================================================
|
|
25
|
+
// Switch Item Types
|
|
26
|
+
// =============================================================================
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A switch option — can be any object, primitive, or boolean.
|
|
30
|
+
* Processed through ProxyItem for field resolution.
|
|
31
|
+
*/
|
|
32
|
+
export type SwitchItem = Record<string, unknown> | string | number | boolean
|
|
33
|
+
|
|
34
|
+
// =============================================================================
|
|
35
|
+
// Component Props Types
|
|
36
|
+
// =============================================================================
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Props for the Switch component
|
|
40
|
+
*/
|
|
41
|
+
export interface SwitchProps {
|
|
42
|
+
/**
|
|
43
|
+
* Exactly two options. First = off/unchecked. Second = on/checked.
|
|
44
|
+
* @default [false, true]
|
|
45
|
+
*/
|
|
46
|
+
options?: [SwitchItem, SwitchItem]
|
|
47
|
+
|
|
48
|
+
/** Field mapping configuration */
|
|
49
|
+
fields?: SwitchFields
|
|
50
|
+
|
|
51
|
+
/** Currently selected value */
|
|
52
|
+
value?: unknown
|
|
53
|
+
|
|
54
|
+
/** Called when the switch changes */
|
|
55
|
+
onchange?: (value: unknown, item: SwitchItem) => void
|
|
56
|
+
|
|
57
|
+
/** Whether to show text labels beside the track */
|
|
58
|
+
showLabels?: boolean
|
|
59
|
+
|
|
60
|
+
/** Size variant */
|
|
61
|
+
size?: 'sm' | 'md' | 'lg'
|
|
62
|
+
|
|
63
|
+
/** Whether the switch is disabled */
|
|
64
|
+
disabled?: boolean
|
|
65
|
+
|
|
66
|
+
/** Additional CSS classes */
|
|
67
|
+
class?: string
|
|
68
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Table Component Types
|
|
3
|
+
*
|
|
4
|
+
* Provides types for the data-driven Table component.
|
|
5
|
+
* Supports flat tables with sortable columns, row selection, and keyboard navigation.
|
|
6
|
+
* Field mapping and data access is handled by ProxyItem from @rokkit/states per cell.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { DEFAULT_STATE_ICONS } from '@rokkit/core'
|
|
10
|
+
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// Column Types
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Column definition for the Table component.
|
|
17
|
+
* Can be auto-derived from data or provided explicitly.
|
|
18
|
+
*/
|
|
19
|
+
export interface TableColumn {
|
|
20
|
+
/** Data key for this column */
|
|
21
|
+
name: string
|
|
22
|
+
|
|
23
|
+
/** Display header text (defaults to name) */
|
|
24
|
+
label?: string
|
|
25
|
+
|
|
26
|
+
/** Data type (auto-derived: 'string', 'number', etc.) */
|
|
27
|
+
type?: string
|
|
28
|
+
|
|
29
|
+
/** Whether this column is sortable — default: true */
|
|
30
|
+
sortable?: boolean
|
|
31
|
+
|
|
32
|
+
/** Current sort direction */
|
|
33
|
+
sorted?: 'none' | 'ascending' | 'descending'
|
|
34
|
+
|
|
35
|
+
/** CSS width (e.g., '200px', '20%') */
|
|
36
|
+
width?: string
|
|
37
|
+
|
|
38
|
+
/** Text alignment */
|
|
39
|
+
align?: 'left' | 'center' | 'right'
|
|
40
|
+
|
|
41
|
+
/** Field mapping — maps ProxyItem slots to data keys */
|
|
42
|
+
fields?: {
|
|
43
|
+
text?: string
|
|
44
|
+
icon?: string
|
|
45
|
+
badge?: string
|
|
46
|
+
description?: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Value formatter for display */
|
|
50
|
+
formatter?: (value: unknown, row: Record<string, unknown>) => string
|
|
51
|
+
|
|
52
|
+
/** Icon formatter — transforms icon field value to icon class */
|
|
53
|
+
iconFormatter?: (value: unknown) => string
|
|
54
|
+
|
|
55
|
+
/** Named snippet for custom cell rendering */
|
|
56
|
+
snippet?: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// =============================================================================
|
|
60
|
+
// Sort Types
|
|
61
|
+
// =============================================================================
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Represents the sort state for a single column.
|
|
65
|
+
*/
|
|
66
|
+
export interface SortState {
|
|
67
|
+
/** Column name */
|
|
68
|
+
column: string
|
|
69
|
+
|
|
70
|
+
/** Sort direction */
|
|
71
|
+
direction: 'ascending' | 'descending'
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// =============================================================================
|
|
75
|
+
// Field Mapping Types
|
|
76
|
+
// =============================================================================
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Row-level field mapping configuration.
|
|
80
|
+
*/
|
|
81
|
+
export interface TableFields {
|
|
82
|
+
/** Field for row value used in selection matching — default: 'id' */
|
|
83
|
+
value?: string
|
|
84
|
+
|
|
85
|
+
/** Field for disabled state — default: 'disabled' */
|
|
86
|
+
disabled?: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Default row-level field mapping values.
|
|
91
|
+
*/
|
|
92
|
+
export const defaultTableFields: Required<TableFields> = {
|
|
93
|
+
value: 'id',
|
|
94
|
+
disabled: 'disabled'
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// =============================================================================
|
|
98
|
+
// Sort Icons
|
|
99
|
+
// =============================================================================
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Icons for sort state indicators.
|
|
103
|
+
*/
|
|
104
|
+
export interface TableSortIcons {
|
|
105
|
+
/** Icon for unsorted column */
|
|
106
|
+
none?: string
|
|
107
|
+
|
|
108
|
+
/** Icon for ascending sort */
|
|
109
|
+
ascending?: string
|
|
110
|
+
|
|
111
|
+
/** Icon for descending sort */
|
|
112
|
+
descending?: string
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Default sort icons from @rokkit/core state icons.
|
|
117
|
+
*/
|
|
118
|
+
export const defaultTableSortIcons: TableSortIcons = {
|
|
119
|
+
none: DEFAULT_STATE_ICONS.sort.none,
|
|
120
|
+
ascending: DEFAULT_STATE_ICONS.sort.ascending,
|
|
121
|
+
descending: DEFAULT_STATE_ICONS.sort.descending
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// =============================================================================
|
|
125
|
+
// Snippet Types
|
|
126
|
+
// =============================================================================
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Snippet for custom header rendering.
|
|
130
|
+
* Parameters: columns, sortState
|
|
131
|
+
*/
|
|
132
|
+
export type TableHeaderSnippet = import('svelte').Snippet<[TableColumn[], SortState[]]>
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Snippet for custom row rendering.
|
|
136
|
+
* Parameters: row, columns, index, isSelected
|
|
137
|
+
*/
|
|
138
|
+
export type TableRowSnippet = import('svelte').Snippet<
|
|
139
|
+
[Record<string, unknown>, TableColumn[], number, boolean]
|
|
140
|
+
>
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Snippet for custom cell rendering.
|
|
144
|
+
* Parameters: value, column, row
|
|
145
|
+
*/
|
|
146
|
+
export type TableCellSnippet = import('svelte').Snippet<
|
|
147
|
+
[unknown, TableColumn, Record<string, unknown>]
|
|
148
|
+
>
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Snippet for empty state.
|
|
152
|
+
*/
|
|
153
|
+
export type TableEmptySnippet = import('svelte').Snippet<[]>
|
|
154
|
+
|
|
155
|
+
// =============================================================================
|
|
156
|
+
// Component Props
|
|
157
|
+
// =============================================================================
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Props for the Table component.
|
|
161
|
+
*/
|
|
162
|
+
export interface TableProps {
|
|
163
|
+
/** Data array — each object is a row */
|
|
164
|
+
data?: Record<string, unknown>[]
|
|
165
|
+
|
|
166
|
+
/** Column definitions (auto-derived from data if not provided) */
|
|
167
|
+
columns?: TableColumn[]
|
|
168
|
+
|
|
169
|
+
/** Currently selected row value (single-select) */
|
|
170
|
+
value?: unknown
|
|
171
|
+
|
|
172
|
+
/** Currently selected row values (multi-select, bindable) */
|
|
173
|
+
values?: unknown[]
|
|
174
|
+
|
|
175
|
+
/** Selection mode: 'single' (default), 'multi', or false (no selection) */
|
|
176
|
+
selectable?: 'single' | 'multi' | false
|
|
177
|
+
|
|
178
|
+
/** Table caption for accessibility */
|
|
179
|
+
caption?: string
|
|
180
|
+
|
|
181
|
+
/** Size variant */
|
|
182
|
+
size?: 'sm' | 'md' | 'lg'
|
|
183
|
+
|
|
184
|
+
/** Enable alternating row colors */
|
|
185
|
+
striped?: boolean
|
|
186
|
+
|
|
187
|
+
/** Enable responsive card layout on mobile (< 640px) */
|
|
188
|
+
responsive?: boolean
|
|
189
|
+
|
|
190
|
+
/** Whether the entire table is disabled */
|
|
191
|
+
disabled?: boolean
|
|
192
|
+
|
|
193
|
+
/** Row-level field mapping */
|
|
194
|
+
fields?: TableFields
|
|
195
|
+
|
|
196
|
+
/** Called when a row is selected */
|
|
197
|
+
onselect?: (value: unknown, row: Record<string, unknown>) => void
|
|
198
|
+
|
|
199
|
+
/** Called when sort state changes */
|
|
200
|
+
onsort?: (sortState: SortState[]) => void
|
|
201
|
+
|
|
202
|
+
/** Additional CSS classes */
|
|
203
|
+
class?: string
|
|
204
|
+
|
|
205
|
+
/** Sort indicator icons */
|
|
206
|
+
icons?: TableSortIcons
|
|
207
|
+
|
|
208
|
+
/** Custom header snippet */
|
|
209
|
+
header?: TableHeaderSnippet
|
|
210
|
+
|
|
211
|
+
/** Custom row snippet */
|
|
212
|
+
row?: TableRowSnippet
|
|
213
|
+
|
|
214
|
+
/** Custom cell snippet */
|
|
215
|
+
cell?: TableCellSnippet
|
|
216
|
+
|
|
217
|
+
/** Empty state snippet */
|
|
218
|
+
empty?: TableEmptySnippet
|
|
219
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tabs Component Types
|
|
3
|
+
*
|
|
4
|
+
* Provides types for the data-driven Tabs component.
|
|
5
|
+
* Field mapping and data access is handled by ProxyItem from @rokkit/states.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Snippet } from 'svelte'
|
|
9
|
+
import type { ProxyItem } from '@rokkit/states'
|
|
10
|
+
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// Tabs Item Types
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Generic tab item - can be any object with mapped fields
|
|
17
|
+
*/
|
|
18
|
+
export type TabsItem = Record<string, unknown>
|
|
19
|
+
|
|
20
|
+
// =============================================================================
|
|
21
|
+
// Snippet Types — ProxyItem-based API
|
|
22
|
+
// =============================================================================
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Snippet type for rendering tab triggers (headers).
|
|
26
|
+
* The component renders the focusable wrapper; the snippet renders the inner content.
|
|
27
|
+
* Navigator handles click selection via data-path — no handlers needed in snippet.
|
|
28
|
+
* Receives the ProxyItem and whether this item is currently selected.
|
|
29
|
+
*/
|
|
30
|
+
export type TabsItemSnippet = Snippet<[ProxyItem, boolean]>
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Snippet type for rendering tab panel content.
|
|
34
|
+
*/
|
|
35
|
+
export type TabsPanelSnippet = Snippet<[ProxyItem]>
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Snippet type for rendering the empty state.
|
|
39
|
+
*/
|
|
40
|
+
export type TabsEmptySnippet = Snippet<[]>
|
|
41
|
+
|
|
42
|
+
// =============================================================================
|
|
43
|
+
// Component Props Types
|
|
44
|
+
// =============================================================================
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Props for the Tabs component
|
|
48
|
+
*/
|
|
49
|
+
export interface TabsProps {
|
|
50
|
+
/** Array of tab options */
|
|
51
|
+
options?: TabsItem[]
|
|
52
|
+
|
|
53
|
+
/** Field mapping — overrides BASE_FIELDS defaults (text → 'label', value → 'value', …) */
|
|
54
|
+
fields?: Record<string, string>
|
|
55
|
+
|
|
56
|
+
/** Currently selected tab value */
|
|
57
|
+
value?: unknown
|
|
58
|
+
|
|
59
|
+
/** Orientation of the tab list */
|
|
60
|
+
orientation?: 'horizontal' | 'vertical'
|
|
61
|
+
|
|
62
|
+
/** Position of the tab list relative to panels */
|
|
63
|
+
position?: 'before' | 'after'
|
|
64
|
+
|
|
65
|
+
/** Alignment of tabs within the tab list */
|
|
66
|
+
align?: 'start' | 'center' | 'end'
|
|
67
|
+
|
|
68
|
+
/** Accessible name for the tab list */
|
|
69
|
+
name?: string
|
|
70
|
+
|
|
71
|
+
/** Whether tabs can be added/removed */
|
|
72
|
+
editable?: boolean
|
|
73
|
+
|
|
74
|
+
/** Placeholder text when no tab is selected */
|
|
75
|
+
placeholder?: string
|
|
76
|
+
|
|
77
|
+
/** Whether the entire tab component is disabled */
|
|
78
|
+
disabled?: boolean
|
|
79
|
+
|
|
80
|
+
/** Additional CSS classes */
|
|
81
|
+
class?: string
|
|
82
|
+
|
|
83
|
+
/** Called when selection changes */
|
|
84
|
+
onchange?: (value: unknown, item: TabsItem) => void
|
|
85
|
+
|
|
86
|
+
/** Called when a tab is selected (fires on every click, including same tab) */
|
|
87
|
+
onselect?: (value: unknown, item: TabsItem) => void
|
|
88
|
+
|
|
89
|
+
/** Called when a new tab is requested (editable mode) */
|
|
90
|
+
onadd?: () => void
|
|
91
|
+
|
|
92
|
+
/** Called when a tab removal is requested (editable mode) */
|
|
93
|
+
onremove?: (value: unknown) => void
|
|
94
|
+
|
|
95
|
+
/** Custom snippet for rendering tab triggers */
|
|
96
|
+
tabItem?: TabsItemSnippet
|
|
97
|
+
|
|
98
|
+
/** Custom snippet for rendering tab panel content */
|
|
99
|
+
tabPanel?: TabsPanelSnippet
|
|
100
|
+
|
|
101
|
+
/** Custom snippet for rendering the empty state */
|
|
102
|
+
empty?: TabsEmptySnippet
|
|
103
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeline Component Types
|
|
3
|
+
*
|
|
4
|
+
* View-only vertical steps for instructions, changelogs,
|
|
5
|
+
* or process visualization. No interaction.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Snippet } from 'svelte'
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Field Mapping Types
|
|
11
|
+
// =============================================================================
|
|
12
|
+
|
|
13
|
+
export interface TimelineFields {
|
|
14
|
+
label?: string
|
|
15
|
+
icon?: string
|
|
16
|
+
subtext?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const defaultTimelineFields: Required<TimelineFields> = {
|
|
20
|
+
label: 'label',
|
|
21
|
+
icon: 'icon',
|
|
22
|
+
subtext: 'description'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// =============================================================================
|
|
26
|
+
// Component Props Types
|
|
27
|
+
// =============================================================================
|
|
28
|
+
|
|
29
|
+
export interface TimelineIcons {
|
|
30
|
+
/** Icon class for completed state (default: i-lucide:check) */
|
|
31
|
+
completed?: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const defaultTimelineIcons: Required<TimelineIcons> = {
|
|
35
|
+
completed: 'i-lucide:check'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface TimelineProps {
|
|
39
|
+
/** Array of timeline items */
|
|
40
|
+
items?: Record<string, unknown>[]
|
|
41
|
+
|
|
42
|
+
/** Field mapping configuration */
|
|
43
|
+
fields?: TimelineFields
|
|
44
|
+
|
|
45
|
+
/** Custom icons */
|
|
46
|
+
icons?: TimelineIcons
|
|
47
|
+
|
|
48
|
+
/** Additional CSS class */
|
|
49
|
+
class?: string
|
|
50
|
+
|
|
51
|
+
/** Custom content snippet for each item: (item, index) */
|
|
52
|
+
content?: Snippet<[Record<string, unknown>, number]>
|
|
53
|
+
}
|