@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,80 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Position on the screen edge
|
|
5
|
+
*/
|
|
6
|
+
export type FloatingNavigationPosition = 'left' | 'right' | 'top' | 'bottom'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Size variant
|
|
10
|
+
*/
|
|
11
|
+
export type FloatingNavigationSize = 'sm' | 'md' | 'lg'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A single navigation item
|
|
15
|
+
*/
|
|
16
|
+
export type FloatingNavigationItem = Record<string, unknown>
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Custom snippet for rendering a navigation item
|
|
20
|
+
*/
|
|
21
|
+
export type FloatingNavigationItemSnippet = Snippet<
|
|
22
|
+
[item: FloatingNavigationItem, proxy: { text: string; icon: string; active: boolean }]
|
|
23
|
+
>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Icons for the FloatingNavigation pin button
|
|
27
|
+
*/
|
|
28
|
+
export interface FloatingNavigationIcons {
|
|
29
|
+
/** Icon for pin action */
|
|
30
|
+
pin?: string
|
|
31
|
+
/** Icon for unpin action */
|
|
32
|
+
unpin?: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Props for the FloatingNavigation component
|
|
37
|
+
*/
|
|
38
|
+
export interface FloatingNavigationProps {
|
|
39
|
+
/** Navigation items (data-driven) */
|
|
40
|
+
items?: FloatingNavigationItem[]
|
|
41
|
+
|
|
42
|
+
/** Field mapping configuration */
|
|
43
|
+
fields?: Record<string, string>
|
|
44
|
+
|
|
45
|
+
/** Custom icons for pin/unpin */
|
|
46
|
+
icons?: FloatingNavigationIcons
|
|
47
|
+
|
|
48
|
+
/** Active item value (bindable) */
|
|
49
|
+
value?: unknown
|
|
50
|
+
|
|
51
|
+
/** Screen edge to anchor to */
|
|
52
|
+
position?: FloatingNavigationPosition
|
|
53
|
+
|
|
54
|
+
/** Whether nav is pinned open (bindable) */
|
|
55
|
+
pinned?: boolean
|
|
56
|
+
|
|
57
|
+
/** Auto-track active section via IntersectionObserver */
|
|
58
|
+
observe?: boolean
|
|
59
|
+
|
|
60
|
+
/** IntersectionObserver config */
|
|
61
|
+
observerOptions?: IntersectionObserverInit
|
|
62
|
+
|
|
63
|
+
/** Size variant */
|
|
64
|
+
size?: FloatingNavigationSize
|
|
65
|
+
|
|
66
|
+
/** Accessible label */
|
|
67
|
+
label?: string
|
|
68
|
+
|
|
69
|
+
/** Called when an item is selected */
|
|
70
|
+
onselect?: (value: unknown, item: FloatingNavigationItem) => void
|
|
71
|
+
|
|
72
|
+
/** Called when pin state changes */
|
|
73
|
+
onpinchange?: (pinned: boolean) => void
|
|
74
|
+
|
|
75
|
+
/** Custom snippet for rendering items */
|
|
76
|
+
item?: FloatingNavigationItemSnippet
|
|
77
|
+
|
|
78
|
+
/** Additional CSS classes */
|
|
79
|
+
class?: string
|
|
80
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Button Types
|
|
2
|
+
export * from './button.js'
|
|
3
|
+
|
|
4
|
+
// Code Types
|
|
5
|
+
export * from './code.js'
|
|
6
|
+
|
|
7
|
+
// Menu Types
|
|
8
|
+
export * from './menu.js'
|
|
9
|
+
|
|
10
|
+
// Select Types
|
|
11
|
+
export * from './select.js'
|
|
12
|
+
|
|
13
|
+
// Toolbar Types
|
|
14
|
+
export * from './toolbar.js'
|
|
15
|
+
|
|
16
|
+
// Tabs Types
|
|
17
|
+
export * from './tabs.js'
|
|
18
|
+
|
|
19
|
+
// Toggle Types
|
|
20
|
+
export * from './toggle.js'
|
|
21
|
+
|
|
22
|
+
// Switch Types
|
|
23
|
+
export * from './switch.js'
|
|
24
|
+
|
|
25
|
+
// List Types
|
|
26
|
+
export * from './list.js'
|
|
27
|
+
|
|
28
|
+
// Tree Types
|
|
29
|
+
export * from './tree.js'
|
|
30
|
+
|
|
31
|
+
// Floating Action Types
|
|
32
|
+
export * from './floating-action.js'
|
|
33
|
+
|
|
34
|
+
// Palette Types
|
|
35
|
+
export * from './palette.js'
|
|
36
|
+
|
|
37
|
+
// Table Types
|
|
38
|
+
export * from './table.js'
|
|
39
|
+
|
|
40
|
+
// SearchFilter Types
|
|
41
|
+
export * from './search-filter.js'
|
|
42
|
+
|
|
43
|
+
// Range Types
|
|
44
|
+
export * from './range.js'
|
|
45
|
+
|
|
46
|
+
// Timeline Types
|
|
47
|
+
export * from './timeline.js'
|
|
48
|
+
|
|
49
|
+
// FloatingNavigation Types
|
|
50
|
+
export * from './floating-navigation.js'
|
|
51
|
+
|
|
52
|
+
// Upload Types
|
|
53
|
+
export * from './upload-target.js'
|
|
54
|
+
export * from './upload-file-status.js'
|
|
55
|
+
export * from './upload-progress.js'
|
|
56
|
+
|
|
57
|
+
// Tooltip Types
|
|
58
|
+
export * from './tooltip.js'
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List Component Types
|
|
3
|
+
*
|
|
4
|
+
* Provides types for the data-driven List component.
|
|
5
|
+
* Supports navigation links, button items, and grouped items with collapsible sections.
|
|
6
|
+
* Field mapping and data access is handled by ProxyItem from @rokkit/states.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { DEFAULT_STATE_ICONS } from '@rokkit/core'
|
|
10
|
+
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// Field Mapping Types
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Field mapping configuration for list data.
|
|
17
|
+
*/
|
|
18
|
+
export interface ListFields {
|
|
19
|
+
/** Field for display text - default: 'text' */
|
|
20
|
+
text?: string
|
|
21
|
+
|
|
22
|
+
/** Field for the value to use for selection matching - default: 'value' */
|
|
23
|
+
value?: string
|
|
24
|
+
|
|
25
|
+
/** Field for navigation URL (renders as <a>) - default: 'href' */
|
|
26
|
+
href?: string
|
|
27
|
+
|
|
28
|
+
/** Field for icon class name - default: 'icon' */
|
|
29
|
+
icon?: string
|
|
30
|
+
|
|
31
|
+
/** Field for secondary descriptive text - default: 'description' */
|
|
32
|
+
description?: string
|
|
33
|
+
|
|
34
|
+
/** Field for aria-label override - default: 'label' */
|
|
35
|
+
label?: string
|
|
36
|
+
|
|
37
|
+
/** Field for disabled state - default: 'disabled' */
|
|
38
|
+
disabled?: string
|
|
39
|
+
|
|
40
|
+
/** Field for children array (for grouping) - default: 'children' */
|
|
41
|
+
children?: string
|
|
42
|
+
|
|
43
|
+
/** Field for custom snippet name - default: 'snippet' */
|
|
44
|
+
snippet?: string
|
|
45
|
+
|
|
46
|
+
/** Field for badge/indicator content - default: 'badge' */
|
|
47
|
+
badge?: string
|
|
48
|
+
|
|
49
|
+
/** Field for tooltip text (HTML title attribute) - default: 'title' */
|
|
50
|
+
title?: string
|
|
51
|
+
|
|
52
|
+
/** Nested field mapping for children - default: inherits parent */
|
|
53
|
+
fields?: ListFields
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Default field mapping values
|
|
58
|
+
*/
|
|
59
|
+
export const defaultListFields: Required<Omit<ListFields, 'fields'>> = {
|
|
60
|
+
text: 'text',
|
|
61
|
+
value: 'value',
|
|
62
|
+
href: 'href',
|
|
63
|
+
icon: 'icon',
|
|
64
|
+
description: 'description',
|
|
65
|
+
label: 'label',
|
|
66
|
+
disabled: 'disabled',
|
|
67
|
+
children: 'children',
|
|
68
|
+
snippet: 'snippet',
|
|
69
|
+
badge: 'badge',
|
|
70
|
+
title: 'title'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// =============================================================================
|
|
74
|
+
// List Item Types
|
|
75
|
+
// =============================================================================
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Generic list item - can be any object with mapped fields
|
|
79
|
+
*/
|
|
80
|
+
export type ListItem = Record<string, unknown>
|
|
81
|
+
|
|
82
|
+
// =============================================================================
|
|
83
|
+
// Snippet Types
|
|
84
|
+
// =============================================================================
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Handlers passed to custom item snippets
|
|
88
|
+
*/
|
|
89
|
+
export interface ListItemHandlers {
|
|
90
|
+
/** Call to trigger item selection (for button items) */
|
|
91
|
+
onclick: () => void
|
|
92
|
+
/** Forward keyboard events for accessibility */
|
|
93
|
+
onkeydown: (event: KeyboardEvent) => void
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Snippet type for rendering list items.
|
|
98
|
+
* Parameters: item, fields, handlers, isActive
|
|
99
|
+
*/
|
|
100
|
+
export type ListItemSnippet = import('svelte').Snippet<
|
|
101
|
+
[ListItem, ListFields, ListItemHandlers, boolean]
|
|
102
|
+
>
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Snippet type for rendering group labels
|
|
106
|
+
* Parameters: item (group), fields, toggleExpanded, isExpanded
|
|
107
|
+
*/
|
|
108
|
+
export type ListGroupLabelSnippet = import('svelte').Snippet<
|
|
109
|
+
[ListItem, ListFields, () => void, boolean]
|
|
110
|
+
>
|
|
111
|
+
|
|
112
|
+
// =============================================================================
|
|
113
|
+
// Component Props Types
|
|
114
|
+
// =============================================================================
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Props for the List component
|
|
118
|
+
*/
|
|
119
|
+
export interface ListProps {
|
|
120
|
+
/** Array of list items or groups */
|
|
121
|
+
items?: ListItem[]
|
|
122
|
+
|
|
123
|
+
/** Field mapping configuration */
|
|
124
|
+
fields?: ListFields
|
|
125
|
+
|
|
126
|
+
/** Currently selected value (for highlighting button items) */
|
|
127
|
+
value?: unknown
|
|
128
|
+
|
|
129
|
+
/** Size variant */
|
|
130
|
+
size?: 'sm' | 'md' | 'lg'
|
|
131
|
+
|
|
132
|
+
/** Whether the entire list is disabled */
|
|
133
|
+
disabled?: boolean
|
|
134
|
+
|
|
135
|
+
/** Whether groups can be collapsed */
|
|
136
|
+
collapsible?: boolean
|
|
137
|
+
|
|
138
|
+
/** Enable multiple item selection (Ctrl+click toggle, Shift+click range) */
|
|
139
|
+
multiselect?: boolean
|
|
140
|
+
|
|
141
|
+
/** Which groups are expanded (bindable) - keyed by group value/text */
|
|
142
|
+
expanded?: Record<string, boolean>
|
|
143
|
+
|
|
144
|
+
/** Selected items array (bindable) - populated in multiselect mode */
|
|
145
|
+
selected?: unknown[]
|
|
146
|
+
|
|
147
|
+
/** Active item value - List looks up item by this value to highlight it */
|
|
148
|
+
active?: unknown
|
|
149
|
+
|
|
150
|
+
/** Called when a button item is selected */
|
|
151
|
+
onselect?: (value: unknown, item: ListItem) => void
|
|
152
|
+
|
|
153
|
+
/** Called when selected items change in multiselect mode */
|
|
154
|
+
onselectedchange?: (selected: unknown[]) => void
|
|
155
|
+
|
|
156
|
+
/** Called when expanded state changes (for bindable expanded) */
|
|
157
|
+
onexpandedchange?: (expanded: Record<string, boolean>) => void
|
|
158
|
+
|
|
159
|
+
/** Additional CSS classes */
|
|
160
|
+
class?: string
|
|
161
|
+
|
|
162
|
+
/** Icons for list group states (expand/collapse arrow) */
|
|
163
|
+
icons?: ListStateIcons
|
|
164
|
+
|
|
165
|
+
/** Custom snippet for rendering list items */
|
|
166
|
+
item?: ListItemSnippet
|
|
167
|
+
|
|
168
|
+
/** Custom snippet for rendering group labels/headers */
|
|
169
|
+
groupLabel?: ListGroupLabelSnippet
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// =============================================================================
|
|
173
|
+
// State Icons
|
|
174
|
+
// =============================================================================
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Icons configuration for list collapsible group states.
|
|
178
|
+
* Keys match the naming convention in @rokkit/core DEFAULT_STATE_ICONS.
|
|
179
|
+
*/
|
|
180
|
+
export interface ListStateIcons {
|
|
181
|
+
/** Icon class for expanded group */
|
|
182
|
+
opened?: string
|
|
183
|
+
/** Icon class for collapsed group */
|
|
184
|
+
closed?: string
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Default state icons — uses semantic names from @rokkit/core
|
|
189
|
+
* that get resolved to actual icon classes via UnoCSS shortcuts.
|
|
190
|
+
*/
|
|
191
|
+
export const defaultListStateIcons: ListStateIcons = {
|
|
192
|
+
opened: DEFAULT_STATE_ICONS.accordion.opened,
|
|
193
|
+
closed: DEFAULT_STATE_ICONS.accordion.closed
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// =============================================================================
|
|
197
|
+
// Helper Functions
|
|
198
|
+
// =============================================================================
|
|
199
|
+
|
|
200
|
+
export { getSnippet } from './menu.js'
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Menu Component Types
|
|
3
|
+
*
|
|
4
|
+
* The new Menu uses the same Wrapper + Navigator stack as List.
|
|
5
|
+
* Trigger action manages open/close. Dropdown content is identical to List.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ProxyItem } from '@rokkit/states'
|
|
9
|
+
import { DEFAULT_STATE_ICONS } from '@rokkit/core'
|
|
10
|
+
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// Component Props Types
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Props for the Menu component.
|
|
17
|
+
* Content props (items, fields, value, size, disabled, collapsible, icons, onselect, class, snippets)
|
|
18
|
+
* are identical to List. Additional props: label, icon, showArrow, align, direction.
|
|
19
|
+
*/
|
|
20
|
+
export interface MenuProps {
|
|
21
|
+
/** Array of items (same as List: supports groups, separators, nested children) */
|
|
22
|
+
items?: unknown[]
|
|
23
|
+
|
|
24
|
+
/** Field mapping — overrides BASE_FIELDS defaults (label → 'label', value → 'value', …) */
|
|
25
|
+
fields?: Record<string, string>
|
|
26
|
+
|
|
27
|
+
/** Current active value (highlights matching item) */
|
|
28
|
+
value?: unknown
|
|
29
|
+
|
|
30
|
+
/** Size variant */
|
|
31
|
+
size?: 'sm' | 'md' | 'lg'
|
|
32
|
+
|
|
33
|
+
/** Whether the entire menu is disabled */
|
|
34
|
+
disabled?: boolean
|
|
35
|
+
|
|
36
|
+
/** Whether groups are collapsible (same as List) */
|
|
37
|
+
collapsible?: boolean
|
|
38
|
+
|
|
39
|
+
/** Trigger button label text */
|
|
40
|
+
label?: string
|
|
41
|
+
|
|
42
|
+
/** Trigger button icon class */
|
|
43
|
+
icon?: string
|
|
44
|
+
|
|
45
|
+
/** Whether to show dropdown arrow indicator on trigger */
|
|
46
|
+
showArrow?: boolean
|
|
47
|
+
|
|
48
|
+
/** Dropdown alignment relative to trigger */
|
|
49
|
+
align?: 'start' | 'end'
|
|
50
|
+
|
|
51
|
+
/** Dropdown direction */
|
|
52
|
+
direction?: 'up' | 'down'
|
|
53
|
+
|
|
54
|
+
/** Icons for expand/collapse states */
|
|
55
|
+
icons?: MenuStateIcons
|
|
56
|
+
|
|
57
|
+
/** Called when a leaf item is selected */
|
|
58
|
+
onselect?: (value: unknown, proxy: ProxyItem) => void
|
|
59
|
+
|
|
60
|
+
/** Additional CSS classes */
|
|
61
|
+
class?: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// =============================================================================
|
|
65
|
+
// State Icons
|
|
66
|
+
// =============================================================================
|
|
67
|
+
|
|
68
|
+
export interface MenuStateIcons {
|
|
69
|
+
/** Icon class for open state */
|
|
70
|
+
opened?: string
|
|
71
|
+
/** Icon class for closed state */
|
|
72
|
+
closed?: string
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const defaultMenuStateIcons: MenuStateIcons = {
|
|
76
|
+
opened: DEFAULT_STATE_ICONS.selector.opened,
|
|
77
|
+
closed: DEFAULT_STATE_ICONS.selector.closed
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// =============================================================================
|
|
81
|
+
// Snippet Utilities
|
|
82
|
+
// =============================================================================
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Retrieve a named snippet from a snippets record, with type/null safety.
|
|
86
|
+
*/
|
|
87
|
+
export function getSnippet<T>(
|
|
88
|
+
snippets: Record<string, T | undefined>,
|
|
89
|
+
name: string | null
|
|
90
|
+
): T | null {
|
|
91
|
+
if (name === null) return null
|
|
92
|
+
const snippet = snippets[name]
|
|
93
|
+
if (snippet !== undefined && typeof snippet === 'function') return snippet
|
|
94
|
+
return null
|
|
95
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte'
|
|
2
|
+
import type { ColorRole, Shades } from '../utils/palette.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for a complete color palette
|
|
6
|
+
*/
|
|
7
|
+
export interface PaletteConfig {
|
|
8
|
+
/** Name of the palette (e.g., "Vibrant", "Ocean", "Custom 1") */
|
|
9
|
+
name: string
|
|
10
|
+
/** Mapping of color roles to Tailwind color names or hex values */
|
|
11
|
+
mapping: Partial<Record<ColorRole, string>>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A preset palette (built-in)
|
|
16
|
+
*/
|
|
17
|
+
export interface PalettePreset {
|
|
18
|
+
/** Display name */
|
|
19
|
+
name: string
|
|
20
|
+
/** Tailwind color name */
|
|
21
|
+
color: string
|
|
22
|
+
/** Preview hex color (usually the 500 shade) */
|
|
23
|
+
preview: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Icons for the PaletteManager component
|
|
28
|
+
*/
|
|
29
|
+
export interface PaletteManagerIcons {
|
|
30
|
+
/** Icon for the save button */
|
|
31
|
+
save?: string
|
|
32
|
+
/** Icon for the apply/check button */
|
|
33
|
+
check?: string
|
|
34
|
+
/** Icon for the presets toggle */
|
|
35
|
+
presets?: string
|
|
36
|
+
/** Icon for the hex input toggle */
|
|
37
|
+
hex?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Props for the PaletteManager component
|
|
42
|
+
*/
|
|
43
|
+
export interface PaletteManagerProps {
|
|
44
|
+
/** Current palette configuration (bindable) */
|
|
45
|
+
value?: PaletteConfig
|
|
46
|
+
|
|
47
|
+
/** Built-in preset palettes */
|
|
48
|
+
presets?: PalettePreset[]
|
|
49
|
+
|
|
50
|
+
/** User-saved custom palettes */
|
|
51
|
+
custom?: PaletteConfig[]
|
|
52
|
+
|
|
53
|
+
/** localStorage key for persistence */
|
|
54
|
+
storageKey?: string
|
|
55
|
+
|
|
56
|
+
/** Roles to show in the editor */
|
|
57
|
+
roles?: ColorRole[]
|
|
58
|
+
|
|
59
|
+
/** Custom icons */
|
|
60
|
+
icons?: PaletteManagerIcons
|
|
61
|
+
|
|
62
|
+
/** Auto-apply changes in real-time */
|
|
63
|
+
autoApply?: boolean
|
|
64
|
+
|
|
65
|
+
/** Show preset selector */
|
|
66
|
+
showPresets?: boolean
|
|
67
|
+
|
|
68
|
+
/** Show save button */
|
|
69
|
+
showSave?: boolean
|
|
70
|
+
|
|
71
|
+
/** Compact mode (fewer controls) */
|
|
72
|
+
compact?: boolean
|
|
73
|
+
|
|
74
|
+
/** Additional CSS classes */
|
|
75
|
+
class?: string
|
|
76
|
+
|
|
77
|
+
/** Called when palette changes */
|
|
78
|
+
onchange?: (palette: PaletteConfig) => void
|
|
79
|
+
|
|
80
|
+
/** Called when user saves a custom palette */
|
|
81
|
+
onsave?: (palette: PaletteConfig) => void
|
|
82
|
+
|
|
83
|
+
/** Called when palette is applied */
|
|
84
|
+
onapply?: (palette: PaletteConfig) => void
|
|
85
|
+
|
|
86
|
+
/** Custom snippet for rendering a color role row */
|
|
87
|
+
roleRow?: PaletteRoleRowSnippet
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Handlers passed to custom role row snippet
|
|
92
|
+
*/
|
|
93
|
+
export interface PaletteRoleRowHandlers {
|
|
94
|
+
onColorChange: (color: string) => void
|
|
95
|
+
onHexInput: (hex: string) => void
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Custom snippet for rendering a palette role row
|
|
100
|
+
*/
|
|
101
|
+
export type PaletteRoleRowSnippet = Snippet<
|
|
102
|
+
[role: ColorRole, currentColor: string, shades: Shades, handlers: PaletteRoleRowHandlers]
|
|
103
|
+
>
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Default color roles to display
|
|
107
|
+
*/
|
|
108
|
+
export const defaultRoles: ColorRole[] = [
|
|
109
|
+
'primary',
|
|
110
|
+
'secondary',
|
|
111
|
+
'accent',
|
|
112
|
+
'surface',
|
|
113
|
+
'success',
|
|
114
|
+
'warning',
|
|
115
|
+
'danger',
|
|
116
|
+
'info'
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Default palette presets using Tailwind colors
|
|
121
|
+
*/
|
|
122
|
+
export const defaultPresets: PalettePreset[] = [
|
|
123
|
+
{ name: 'Slate', color: 'slate', preview: '#64748b' },
|
|
124
|
+
{ name: 'Gray', color: 'gray', preview: '#6b7280' },
|
|
125
|
+
{ name: 'Zinc', color: 'zinc', preview: '#71717a' },
|
|
126
|
+
{ name: 'Red', color: 'red', preview: '#ef4444' },
|
|
127
|
+
{ name: 'Orange', color: 'orange', preview: '#f97316' },
|
|
128
|
+
{ name: 'Amber', color: 'amber', preview: '#f59e0b' },
|
|
129
|
+
{ name: 'Yellow', color: 'yellow', preview: '#eab308' },
|
|
130
|
+
{ name: 'Lime', color: 'lime', preview: '#84cc16' },
|
|
131
|
+
{ name: 'Green', color: 'green', preview: '#22c55e' },
|
|
132
|
+
{ name: 'Emerald', color: 'emerald', preview: '#10b981' },
|
|
133
|
+
{ name: 'Teal', color: 'teal', preview: '#14b8a6' },
|
|
134
|
+
{ name: 'Cyan', color: 'cyan', preview: '#06b6d4' },
|
|
135
|
+
{ name: 'Sky', color: 'sky', preview: '#0ea5e9' },
|
|
136
|
+
{ name: 'Blue', color: 'blue', preview: '#3b82f6' },
|
|
137
|
+
{ name: 'Indigo', color: 'indigo', preview: '#6366f1' },
|
|
138
|
+
{ name: 'Violet', color: 'violet', preview: '#8b5cf6' },
|
|
139
|
+
{ name: 'Purple', color: 'purple', preview: '#a855f7' },
|
|
140
|
+
{ name: 'Fuchsia', color: 'fuchsia', preview: '#d946ef' },
|
|
141
|
+
{ name: 'Pink', color: 'pink', preview: '#ec4899' },
|
|
142
|
+
{ name: 'Rose', color: 'rose', preview: '#f43f5e' }
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Default palette configuration
|
|
147
|
+
*/
|
|
148
|
+
export const defaultPaletteConfig: PaletteConfig = {
|
|
149
|
+
name: 'Default',
|
|
150
|
+
mapping: {
|
|
151
|
+
primary: 'orange',
|
|
152
|
+
secondary: 'pink',
|
|
153
|
+
accent: 'sky',
|
|
154
|
+
surface: 'slate',
|
|
155
|
+
success: 'green',
|
|
156
|
+
warning: 'amber',
|
|
157
|
+
danger: 'red',
|
|
158
|
+
info: 'cyan'
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Range Component Types
|
|
3
|
+
*
|
|
4
|
+
* Custom slider with single or dual-handle modes,
|
|
5
|
+
* tick marks, drag interaction, and keyboard support.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Component Props Types
|
|
10
|
+
// =============================================================================
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Props for the Range component
|
|
14
|
+
*/
|
|
15
|
+
export interface RangeProps {
|
|
16
|
+
/** Current value in single mode (bindable) */
|
|
17
|
+
value?: number
|
|
18
|
+
|
|
19
|
+
/** Lower bound value in range mode (bindable) */
|
|
20
|
+
lower?: number
|
|
21
|
+
|
|
22
|
+
/** Upper bound value in range mode (bindable) */
|
|
23
|
+
upper?: number
|
|
24
|
+
|
|
25
|
+
/** Minimum value (default: 0) */
|
|
26
|
+
min?: number
|
|
27
|
+
|
|
28
|
+
/** Maximum value (default: 100) */
|
|
29
|
+
max?: number
|
|
30
|
+
|
|
31
|
+
/** Step increment (default: 1, 0 = continuous) */
|
|
32
|
+
step?: number
|
|
33
|
+
|
|
34
|
+
/** Whether to show dual handles for range selection */
|
|
35
|
+
range?: boolean
|
|
36
|
+
|
|
37
|
+
/** Number of tick divisions (default: 0 = no ticks) */
|
|
38
|
+
ticks?: number
|
|
39
|
+
|
|
40
|
+
/** Show label every N ticks (default: 0 = show all) */
|
|
41
|
+
labelSkip?: number
|
|
42
|
+
|
|
43
|
+
/** Disabled state */
|
|
44
|
+
disabled?: boolean
|
|
45
|
+
|
|
46
|
+
/** Called when value changes */
|
|
47
|
+
onchange?: (value: number | [number, number]) => void
|
|
48
|
+
|
|
49
|
+
/** Additional CSS class */
|
|
50
|
+
class?: string
|
|
51
|
+
}
|