@rokkit/core 1.0.0-next.14 → 1.0.0-next.140
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/LICENSE +1 -1
- package/README.md +121 -1
- package/dist/calendar.d.ts +10 -0
- package/dist/colors/index.d.ts +47 -0
- package/dist/connector.d.ts +8 -0
- package/dist/constants.d.ts +88 -0
- package/dist/events.d.ts +12 -0
- package/dist/field-mapper.d.ts +60 -0
- package/dist/index.d.ts +13 -0
- package/dist/key-event-map.d.ts +18 -0
- package/dist/mapped-items.d.ts +14 -0
- package/dist/mapping.d.ts +14 -0
- package/dist/nested.d.ts +9 -0
- package/dist/string.d.ts +59 -0
- package/dist/theme.d.ts +96 -0
- package/dist/ticks.d.ts +10 -0
- package/dist/types.d.ts +300 -0
- package/dist/utils.d.ts +93 -0
- package/dist/vite/icon-collections.d.ts +32 -0
- package/dist/vite/index.d.ts +1 -0
- package/package.json +31 -39
- package/src/calendar.js +44 -0
- package/src/colors/extra.json +16 -0
- package/src/colors/index.ts +24 -0
- package/src/colors/syntax.json +42 -0
- package/src/colors/tailwind.json +275 -0
- package/src/connector.js +34 -0
- package/src/constants.js +186 -107
- package/src/events.js +32 -0
- package/src/field-mapper.js +147 -0
- package/src/index.js +19 -27
- package/src/key-event-map.js +35 -0
- package/src/mapped-items.js +22 -0
- package/src/mapping.js +21 -0
- package/src/nested.js +28 -0
- package/src/string.js +97 -0
- package/src/theme.ts +206 -0
- package/src/ticks.js +26 -0
- package/src/types.js +160 -0
- package/src/utils.js +255 -0
- package/src/vite/icon-collections.js +73 -0
- package/src/vite/index.js +1 -0
- package/src/Accordion.svelte +0 -80
- package/src/Alerts.svelte +0 -39
- package/src/DropDown.svelte +0 -82
- package/src/DropSearch.svelte +0 -67
- package/src/EditableTabs.svelte +0 -31
- package/src/Icon.svelte +0 -15
- package/src/List-Discard.svelte +0 -48
- package/src/List.svelte +0 -65
- package/src/ListActions.svelte +0 -35
- package/src/NavTabs.svelte +0 -0
- package/src/NestedList.svelte +0 -77
- package/src/Overlay.svelte +0 -4
- package/src/PageNavigator.svelte +0 -94
- package/src/ResponsiveGrid.svelte +0 -73
- package/src/Scrollable.svelte +0 -8
- package/src/Searchable.svelte +0 -19
- package/src/Sidebar.svelte +0 -5
- package/src/Slider.svelte +0 -17
- package/src/SpinList.svelte +0 -48
- package/src/SplitPane.svelte +0 -109
- package/src/SplitView.svelte +0 -44
- package/src/Splitter.svelte +0 -95
- package/src/TabItem.svelte +0 -27
- package/src/TabItems.svelte +0 -34
- package/src/Tabs.svelte +0 -49
- package/src/Tree.svelte +0 -45
- package/src/actions/dismissable.js +0 -24
- package/src/actions/fillable.js +0 -114
- package/src/actions/hierarchy.js +0 -180
- package/src/actions/index.js +0 -7
- package/src/actions/navigable.js +0 -43
- package/src/actions/navigator.js +0 -179
- package/src/actions/pannable.js +0 -50
- package/src/actions/swipeable.js +0 -56
- package/src/actions/themeable.js +0 -23
- package/src/items/Collapsible.svelte +0 -51
- package/src/items/Connector.svelte +0 -26
- package/src/items/Link.svelte +0 -18
- package/src/items/Node.svelte +0 -52
- package/src/items/Pill.svelte +0 -19
- package/src/items/Separator.svelte +0 -1
- package/src/items/Summary.svelte +0 -27
- package/src/items/Text.svelte +0 -21
- package/src/items/index.js +0 -8
- package/src/list.js +0 -14
- package/src/mocks/Custom.svelte +0 -7
- package/src/mocks/index.js +0 -10
- package/src/stores/alerts.js +0 -3
- package/src/stores/index.js +0 -6
- package/src/stores/persist.js +0 -63
- package/src/stores/theme.js +0 -34
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
{
|
|
2
|
+
"amber": {
|
|
3
|
+
"50": "#fffbeb",
|
|
4
|
+
"100": "#fef3c7",
|
|
5
|
+
"200": "#fde68a",
|
|
6
|
+
"300": "#fcd34d",
|
|
7
|
+
"400": "#fbbf24",
|
|
8
|
+
"500": "#f59e0b",
|
|
9
|
+
"600": "#d97706",
|
|
10
|
+
"700": "#b45309",
|
|
11
|
+
"800": "#92400e",
|
|
12
|
+
"900": "#78350f",
|
|
13
|
+
"950": "#451a03"
|
|
14
|
+
},
|
|
15
|
+
"blue": {
|
|
16
|
+
"50": "#eff6ff",
|
|
17
|
+
"100": "#dbeafe",
|
|
18
|
+
"200": "#bfdbfe",
|
|
19
|
+
"300": "#93c5fd",
|
|
20
|
+
"400": "#60a5fa",
|
|
21
|
+
"500": "#3b82f6",
|
|
22
|
+
"600": "#2563eb",
|
|
23
|
+
"700": "#1d4ed8",
|
|
24
|
+
"800": "#1e40af",
|
|
25
|
+
"900": "#1e3a8a",
|
|
26
|
+
"950": "#172554"
|
|
27
|
+
},
|
|
28
|
+
"cyan": {
|
|
29
|
+
"50": "#ecfeff",
|
|
30
|
+
"100": "#cffafe",
|
|
31
|
+
"200": "#a5f3fc",
|
|
32
|
+
"300": "#67e8f9",
|
|
33
|
+
"400": "#22d3ee",
|
|
34
|
+
"500": "#06b6d4",
|
|
35
|
+
"600": "#0891b2",
|
|
36
|
+
"700": "#0e7490",
|
|
37
|
+
"800": "#155e75",
|
|
38
|
+
"900": "#164e63",
|
|
39
|
+
"950": "#083344"
|
|
40
|
+
},
|
|
41
|
+
"emerald": {
|
|
42
|
+
"50": "#ecfdf5",
|
|
43
|
+
"100": "#d1fae5",
|
|
44
|
+
"200": "#a7f3d0",
|
|
45
|
+
"300": "#6ee7b7",
|
|
46
|
+
"400": "#34d399",
|
|
47
|
+
"500": "#10b981",
|
|
48
|
+
"600": "#059669",
|
|
49
|
+
"700": "#047857",
|
|
50
|
+
"800": "#065f46",
|
|
51
|
+
"900": "#064e3b",
|
|
52
|
+
"950": "#022c22"
|
|
53
|
+
},
|
|
54
|
+
"fuscia": {
|
|
55
|
+
"50": "#fdf4ff",
|
|
56
|
+
"100": "#fae8ff",
|
|
57
|
+
"200": "#f5d0fe",
|
|
58
|
+
"300": "#f0abfc",
|
|
59
|
+
"400": "#e879f9",
|
|
60
|
+
"500": "#d946ef",
|
|
61
|
+
"600": "#c026d3",
|
|
62
|
+
"700": "#a21caf",
|
|
63
|
+
"800": "#86198f",
|
|
64
|
+
"900": "#701a75",
|
|
65
|
+
"950": "#4a044e"
|
|
66
|
+
},
|
|
67
|
+
"gray": {
|
|
68
|
+
"50": "#f9fafb",
|
|
69
|
+
"100": "#f3f4f6",
|
|
70
|
+
"200": "#e5e7eb",
|
|
71
|
+
"300": "#d1d5db",
|
|
72
|
+
"400": "#9ca3af",
|
|
73
|
+
"500": "#6b7280",
|
|
74
|
+
"600": "#4b5563",
|
|
75
|
+
"700": "#374151",
|
|
76
|
+
"800": "#1f2937",
|
|
77
|
+
"900": "#111827",
|
|
78
|
+
"950": "#00060c"
|
|
79
|
+
},
|
|
80
|
+
"green": {
|
|
81
|
+
"50": "#f0fdf4",
|
|
82
|
+
"100": "#dcfce7",
|
|
83
|
+
"200": "#bbf7d0",
|
|
84
|
+
"300": "#86efac",
|
|
85
|
+
"400": "#4ade80",
|
|
86
|
+
"500": "#22c55e",
|
|
87
|
+
"600": "#16a34a",
|
|
88
|
+
"700": "#15803d",
|
|
89
|
+
"800": "#166534",
|
|
90
|
+
"900": "#14532d",
|
|
91
|
+
"950": "#052e16"
|
|
92
|
+
},
|
|
93
|
+
"indigo": {
|
|
94
|
+
"50": "#eef2ff",
|
|
95
|
+
"100": "#e0e7ff",
|
|
96
|
+
"200": "#c7d2fe",
|
|
97
|
+
"300": "#a5b4fc",
|
|
98
|
+
"400": "#818cf8",
|
|
99
|
+
"500": "#6366f1",
|
|
100
|
+
"600": "#4f46e5",
|
|
101
|
+
"700": "#4338ca",
|
|
102
|
+
"800": "#3730a3",
|
|
103
|
+
"900": "#312e81",
|
|
104
|
+
"950": "#1e1b4b"
|
|
105
|
+
},
|
|
106
|
+
"lime": {
|
|
107
|
+
"50": "#f7fee7",
|
|
108
|
+
"100": "#ecfccb",
|
|
109
|
+
"200": "#d9f99d",
|
|
110
|
+
"300": "#bef264",
|
|
111
|
+
"400": "#a3e635",
|
|
112
|
+
"500": "#84cc16",
|
|
113
|
+
"600": "#65a30d",
|
|
114
|
+
"700": "#4d7c0f",
|
|
115
|
+
"800": "#3f6212",
|
|
116
|
+
"900": "#365314",
|
|
117
|
+
"950": "#1a2e05"
|
|
118
|
+
},
|
|
119
|
+
"orange": {
|
|
120
|
+
"50": "#fff7ed",
|
|
121
|
+
"100": "#ffedd5",
|
|
122
|
+
"200": "#fed7aa",
|
|
123
|
+
"300": "#fdba74",
|
|
124
|
+
"400": "#fb923c",
|
|
125
|
+
"500": "#f97316",
|
|
126
|
+
"600": "#ea580c",
|
|
127
|
+
"700": "#c2410c",
|
|
128
|
+
"800": "#9a3412",
|
|
129
|
+
"900": "#7c2d12",
|
|
130
|
+
"950": "#431407"
|
|
131
|
+
},
|
|
132
|
+
"pink": {
|
|
133
|
+
"50": "#fdf2f8",
|
|
134
|
+
"100": "#fce7f3",
|
|
135
|
+
"200": "#fbcfe8",
|
|
136
|
+
"300": "#f9a8d4",
|
|
137
|
+
"400": "#f472b6",
|
|
138
|
+
"500": "#ec4899",
|
|
139
|
+
"600": "#db2777",
|
|
140
|
+
"700": "#be185d",
|
|
141
|
+
"800": "#9d174d",
|
|
142
|
+
"900": "#831843",
|
|
143
|
+
"950": "#500724"
|
|
144
|
+
},
|
|
145
|
+
"purple": {
|
|
146
|
+
"50": "#faf5ff",
|
|
147
|
+
"100": "#f3e8ff",
|
|
148
|
+
"200": "#e9d5ff",
|
|
149
|
+
"300": "#d8b4fe",
|
|
150
|
+
"400": "#c084fc",
|
|
151
|
+
"500": "#a855f7",
|
|
152
|
+
"600": "#9333ea",
|
|
153
|
+
"700": "#7e22ce",
|
|
154
|
+
"800": "#6b21a8",
|
|
155
|
+
"900": "#581c87",
|
|
156
|
+
"950": "#3b0764"
|
|
157
|
+
},
|
|
158
|
+
"red": {
|
|
159
|
+
"50": "#fef2f2",
|
|
160
|
+
"100": "#fee2e2",
|
|
161
|
+
"200": "#fecaca",
|
|
162
|
+
"300": "#fca5a5",
|
|
163
|
+
"400": "#f87171",
|
|
164
|
+
"500": "#ef4444",
|
|
165
|
+
"600": "#dc2626",
|
|
166
|
+
"700": "#b91c1c",
|
|
167
|
+
"800": "#991b1b",
|
|
168
|
+
"900": "#7f1d1d",
|
|
169
|
+
"950": "#450a0a"
|
|
170
|
+
},
|
|
171
|
+
"rose": {
|
|
172
|
+
"50": "#fff1f2",
|
|
173
|
+
"100": "#ffe4e6",
|
|
174
|
+
"200": "#fecdd3",
|
|
175
|
+
"300": "#fda4af",
|
|
176
|
+
"400": "#fb7185",
|
|
177
|
+
"500": "#f43f5e",
|
|
178
|
+
"600": "#e11d48",
|
|
179
|
+
"700": "#be123c",
|
|
180
|
+
"800": "#9f1239",
|
|
181
|
+
"900": "#881337",
|
|
182
|
+
"950": "#4c0519"
|
|
183
|
+
},
|
|
184
|
+
"sky": {
|
|
185
|
+
"50": "#f0f9ff",
|
|
186
|
+
"100": "#e0f2fe",
|
|
187
|
+
"200": "#bae6fd",
|
|
188
|
+
"300": "#7dd3fc",
|
|
189
|
+
"400": "#38bdf8",
|
|
190
|
+
"500": "#0ea5e9",
|
|
191
|
+
"600": "#0284c7",
|
|
192
|
+
"700": "#0369a1",
|
|
193
|
+
"800": "#075985",
|
|
194
|
+
"900": "#0c4a6e",
|
|
195
|
+
"950": "#082f49"
|
|
196
|
+
},
|
|
197
|
+
"slate": {
|
|
198
|
+
"50": "#f8fafc",
|
|
199
|
+
"100": "#f1f5f9",
|
|
200
|
+
"200": "#e2e8f0",
|
|
201
|
+
"300": "#cbd5e0",
|
|
202
|
+
"400": "#94a3b8",
|
|
203
|
+
"500": "#64748b",
|
|
204
|
+
"600": "#475569",
|
|
205
|
+
"700": "#334155",
|
|
206
|
+
"800": "#1e293b",
|
|
207
|
+
"900": "#0f172a",
|
|
208
|
+
"950": "#020617"
|
|
209
|
+
},
|
|
210
|
+
"stone": {
|
|
211
|
+
"50": "#fafaf9",
|
|
212
|
+
"100": "#f5f5f4",
|
|
213
|
+
"200": "#e7e5e4",
|
|
214
|
+
"300": "#d6d3d1",
|
|
215
|
+
"400": "#a8a29e",
|
|
216
|
+
"500": "#78716c",
|
|
217
|
+
"600": "#57534e",
|
|
218
|
+
"700": "#44403c",
|
|
219
|
+
"800": "#292524",
|
|
220
|
+
"900": "#1c1917",
|
|
221
|
+
"950": "#0c0a09"
|
|
222
|
+
},
|
|
223
|
+
"teal": {
|
|
224
|
+
"50": "#f0fdfa",
|
|
225
|
+
"100": "#ccfbf1",
|
|
226
|
+
"200": "#99f6e4",
|
|
227
|
+
"300": "#5eead4",
|
|
228
|
+
"400": "#2dd4bf",
|
|
229
|
+
"500": "#14b8a6",
|
|
230
|
+
"600": "#0d9488",
|
|
231
|
+
"700": "#0f766e",
|
|
232
|
+
"800": "#115e59",
|
|
233
|
+
"900": "#134e4a",
|
|
234
|
+
"950": "#042f2e"
|
|
235
|
+
},
|
|
236
|
+
"violet": {
|
|
237
|
+
"50": "#f5f3ff",
|
|
238
|
+
"100": "#ede9fe",
|
|
239
|
+
"200": "#ddd6fe",
|
|
240
|
+
"300": "#c4b5fd",
|
|
241
|
+
"400": "#a78bfa",
|
|
242
|
+
"500": "#8b5cf6",
|
|
243
|
+
"600": "#7c3aed",
|
|
244
|
+
"700": "#6d28d9",
|
|
245
|
+
"800": "#5b21b6",
|
|
246
|
+
"900": "#4c1d95",
|
|
247
|
+
"950": "#2e1065"
|
|
248
|
+
},
|
|
249
|
+
"yellow": {
|
|
250
|
+
"50": "#fefce8",
|
|
251
|
+
"100": "#fef9c3",
|
|
252
|
+
"200": "#fef08a",
|
|
253
|
+
"300": "#fde047",
|
|
254
|
+
"400": "#facc15",
|
|
255
|
+
"500": "#eab308",
|
|
256
|
+
"600": "#ca8a04",
|
|
257
|
+
"700": "#a16207",
|
|
258
|
+
"800": "#854d0e",
|
|
259
|
+
"900": "#713f12",
|
|
260
|
+
"950": "#422006"
|
|
261
|
+
},
|
|
262
|
+
"zinc": {
|
|
263
|
+
"50": "#fafafa",
|
|
264
|
+
"100": "#f4f4f5",
|
|
265
|
+
"200": "#e4e4e7",
|
|
266
|
+
"300": "#d4d4d8",
|
|
267
|
+
"400": "#a1a1aa",
|
|
268
|
+
"500": "#71717a",
|
|
269
|
+
"600": "#52525b",
|
|
270
|
+
"700": "#3f3f46",
|
|
271
|
+
"800": "#27272a",
|
|
272
|
+
"900": "#18181b",
|
|
273
|
+
"950": "#000000"
|
|
274
|
+
}
|
|
275
|
+
}
|
package/src/connector.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const LINE_TYPES = {
|
|
2
|
+
CHILD: 'child',
|
|
3
|
+
LAST: 'last',
|
|
4
|
+
SIBLING: 'sibling',
|
|
5
|
+
EMPTY: 'empty',
|
|
6
|
+
ICON: 'icon'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const nextType = {
|
|
10
|
+
[LINE_TYPES.CHILD]: LINE_TYPES.SIBLING,
|
|
11
|
+
[LINE_TYPES.LAST]: LINE_TYPES.EMPTY,
|
|
12
|
+
[LINE_TYPES.SIBLING]: LINE_TYPES.SIBLING,
|
|
13
|
+
[LINE_TYPES.EMPTY]: LINE_TYPES.EMPTY
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Constructs an array of line types for tree visualization
|
|
18
|
+
* @param {boolean} hasChildren - Whether the node has children
|
|
19
|
+
* @param {import('./types').LineType[]} parentTypes - Types from parent nodes
|
|
20
|
+
* @param {import('./types').LineType} position - Current position type
|
|
21
|
+
* @returns {import('./types').LineType[]} Array of line types
|
|
22
|
+
*/
|
|
23
|
+
export function getLineTypes(hasChildren = false, parentTypes = [], position = LINE_TYPES.CHILD) {
|
|
24
|
+
return parentTypes
|
|
25
|
+
.reduce((acc, type, index) => {
|
|
26
|
+
// For all but the last parent type, convert to next type
|
|
27
|
+
if (index < parentTypes.length - 1) {
|
|
28
|
+
return [...acc, nextType[type]]
|
|
29
|
+
}
|
|
30
|
+
// For the last parent type, use the position
|
|
31
|
+
return [...acc, position]
|
|
32
|
+
}, [])
|
|
33
|
+
.concat(hasChildren ? LINE_TYPES.ICON : LINE_TYPES.EMPTY)
|
|
34
|
+
}
|
package/src/constants.js
CHANGED
|
@@ -1,102 +1,170 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { defaultColors, syntaxColors, shades, defaultPalette } from './colors/index'
|
|
2
|
+
export const DATA_IMAGE_REGEX = /^data:image\/(jpeg|png|gif|bmp|webp|svg\+xml)/i
|
|
3
|
+
|
|
4
|
+
// ─── Snippet names ────────────────────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
export const ITEM_SNIPPET = 'itemContent'
|
|
7
|
+
export const GROUP_SNIPPET = 'groupContent'
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use BASE_FIELDS from @rokkit/core instead.
|
|
10
|
+
* Retained for legacy ListController/FieldMapper/Proxy consumers (Toolbar, Table).
|
|
11
|
+
* Will be removed when those components migrate to Wrapper+Navigator.
|
|
12
|
+
* @type {import('./types).FieldMapping} Fields
|
|
13
|
+
*/
|
|
14
|
+
export const DEFAULT_FIELDS = {
|
|
15
|
+
id: 'id',
|
|
16
|
+
href: 'href',
|
|
17
|
+
icon: 'icon',
|
|
18
|
+
text: 'text',
|
|
19
|
+
value: 'value',
|
|
20
|
+
keywords: 'keywords',
|
|
21
|
+
children: 'children',
|
|
22
|
+
iconPrefix: null,
|
|
23
|
+
image: 'image',
|
|
24
|
+
summary: 'summary',
|
|
25
|
+
notes: 'notes',
|
|
26
|
+
props: 'props',
|
|
27
|
+
target: 'target',
|
|
28
|
+
state: 'state',
|
|
29
|
+
level: 'level',
|
|
30
|
+
parent: 'parent',
|
|
31
|
+
currency: 'currency',
|
|
32
|
+
label: 'label',
|
|
33
|
+
component: 'component', // to be deprecated in favour of snippet
|
|
34
|
+
snippet: 'snippet',
|
|
35
|
+
disabled: 'disabled',
|
|
36
|
+
/* flag fields */
|
|
37
|
+
deleted: '_deleted',
|
|
38
|
+
expanded: '_expanded',
|
|
39
|
+
selected: '_selected'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ─── BASE_FIELDS ─────────────────────────────────────────────────────────────
|
|
43
|
+
// Canonical field mapping for ProxyItem and all Wrapper+Navigator components.
|
|
44
|
+
// Semantic keys map to common raw data keys for backward compatibility.
|
|
45
|
+
|
|
46
|
+
export const BASE_FIELDS = {
|
|
47
|
+
// Identity
|
|
48
|
+
id: 'id',
|
|
49
|
+
value: 'value',
|
|
50
|
+
// Display
|
|
51
|
+
label: 'label',
|
|
52
|
+
icon: 'icon',
|
|
53
|
+
avatar: 'image',
|
|
54
|
+
subtext: 'description',
|
|
55
|
+
tooltip: 'title',
|
|
56
|
+
badge: 'badge',
|
|
57
|
+
shortcut: 'shortcut',
|
|
58
|
+
// Structure
|
|
59
|
+
children: 'children',
|
|
60
|
+
type: 'type',
|
|
61
|
+
snippet: 'snippet',
|
|
62
|
+
href: 'href',
|
|
63
|
+
hrefTarget: 'target',
|
|
64
|
+
// State
|
|
65
|
+
disabled: 'disabled',
|
|
66
|
+
expanded: 'expanded',
|
|
67
|
+
selected: 'selected'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const LEGACY_KEY_MAP = {
|
|
71
|
+
description: 'subtext',
|
|
72
|
+
title: 'tooltip',
|
|
73
|
+
image: 'avatar',
|
|
74
|
+
target: 'hrefTarget'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Remap legacy field-override keys to their BASE_FIELDS semantic equivalents.
|
|
79
|
+
* e.g. { text: 'name' } → { label: 'name' }
|
|
80
|
+
*
|
|
81
|
+
* @param {Record<string, string> | null | undefined} fields
|
|
82
|
+
* @returns {Record<string, string>}
|
|
83
|
+
*/
|
|
84
|
+
export function normalizeFields(fields) {
|
|
85
|
+
if (!fields || typeof fields !== 'object') return {}
|
|
86
|
+
const result = {}
|
|
87
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
88
|
+
result[LEGACY_KEY_MAP[key] ?? key] = value
|
|
89
|
+
}
|
|
90
|
+
return result
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const DEFAULT_ICONS = [
|
|
2
94
|
'accordion-opened',
|
|
3
95
|
'accordion-closed',
|
|
4
96
|
'action-remove',
|
|
97
|
+
'action-cancel',
|
|
98
|
+
'action-retry',
|
|
5
99
|
'action-add',
|
|
6
100
|
'action-clear',
|
|
7
101
|
'action-search',
|
|
8
102
|
'action-close',
|
|
9
|
-
'action-
|
|
103
|
+
'action-copy',
|
|
104
|
+
'action-copysuccess',
|
|
105
|
+
'action-check',
|
|
106
|
+
'action-pin',
|
|
107
|
+
'action-save',
|
|
108
|
+
'action-unpin',
|
|
10
109
|
'node-opened',
|
|
11
110
|
'node-closed',
|
|
111
|
+
'folder-opened',
|
|
112
|
+
'folder-closed',
|
|
12
113
|
'selector-opened',
|
|
13
114
|
'selector-closed',
|
|
115
|
+
'menu-opened',
|
|
116
|
+
'menu-closed',
|
|
14
117
|
'checkbox-checked',
|
|
15
118
|
'checkbox-unchecked',
|
|
16
119
|
'checkbox-unknown',
|
|
17
120
|
'rating-filled',
|
|
18
121
|
'rating-empty',
|
|
122
|
+
'rating-half',
|
|
19
123
|
'radio-off',
|
|
20
124
|
'radio-on',
|
|
21
125
|
'mode-dark',
|
|
22
126
|
'mode-light',
|
|
127
|
+
'mode-system',
|
|
23
128
|
'navigate-left',
|
|
24
129
|
'navigate-right',
|
|
25
130
|
'navigate-up',
|
|
26
|
-
'navigate-down'
|
|
131
|
+
'navigate-down',
|
|
132
|
+
'palette-hex',
|
|
133
|
+
'palette-presets',
|
|
134
|
+
'state-error',
|
|
135
|
+
'state-warning',
|
|
136
|
+
'state-success',
|
|
137
|
+
'state-info',
|
|
138
|
+
'state-unknown',
|
|
139
|
+
'badge-fail',
|
|
140
|
+
'badge-warn',
|
|
141
|
+
'badge-pass',
|
|
142
|
+
'badge-unknown',
|
|
143
|
+
'sort-none',
|
|
144
|
+
'sort-ascending',
|
|
145
|
+
'sort-descending',
|
|
146
|
+
'validity-failed',
|
|
147
|
+
'validity-passed',
|
|
148
|
+
'validity-unknown',
|
|
149
|
+
'validity-warning',
|
|
150
|
+
'alert-clear',
|
|
151
|
+
'alert-unread',
|
|
152
|
+
'align-horizontal-left',
|
|
153
|
+
'align-horizontal-right',
|
|
154
|
+
'align-horizontal-center',
|
|
155
|
+
'align-vertical-top',
|
|
156
|
+
'align-vertical-bottom',
|
|
157
|
+
'align-vertical-middle'
|
|
27
158
|
]
|
|
28
159
|
|
|
29
|
-
|
|
30
|
-
// 'accordion-opened',
|
|
31
|
-
// 'accordion-closed',
|
|
32
|
-
// 'action-remove',
|
|
33
|
-
// 'action-add',
|
|
34
|
-
// 'action-clear',
|
|
35
|
-
// 'action-search',
|
|
36
|
-
// 'action-close',
|
|
37
|
-
// 'node-opened',
|
|
38
|
-
// 'node-closed',
|
|
39
|
-
// 'checkbox-checked',
|
|
40
|
-
// 'checkbox-unchecked',
|
|
41
|
-
// 'checkbox-unknown',
|
|
42
|
-
// 'rating-filled',
|
|
43
|
-
// 'rating-empty',
|
|
44
|
-
// 'rating-half',
|
|
45
|
-
// 'radio-off',
|
|
46
|
-
// 'radio-on',
|
|
47
|
-
// 'folder-closed',
|
|
48
|
-
// 'folder-opened',
|
|
49
|
-
// 'navigate-up',
|
|
50
|
-
// 'navigate-down',
|
|
51
|
-
// 'navigate-left',
|
|
52
|
-
// 'navigate-right',
|
|
53
|
-
// 'selector-closed',
|
|
54
|
-
// 'selector-opened',
|
|
55
|
-
// 'mode-dark',
|
|
56
|
-
// 'mode-light'
|
|
57
|
-
// ]
|
|
58
|
-
|
|
59
|
-
export const defaultOptions = {
|
|
160
|
+
export const DEFAULT_OPTIONS = {
|
|
60
161
|
id: 'id',
|
|
61
162
|
label: 'label',
|
|
62
163
|
value: 'value',
|
|
63
164
|
checked: 'checked'
|
|
64
165
|
}
|
|
65
166
|
|
|
66
|
-
|
|
67
|
-
* Structure to map custom fields for rendering
|
|
68
|
-
*
|
|
69
|
-
* @typedef FieldMapping
|
|
70
|
-
* @property {string} [id='id'] - Unique id for the item
|
|
71
|
-
* @property {string} [text='text'] - Attribute to identify the text to render
|
|
72
|
-
* @property {string} [url='url'] - Attribute to identify a URL
|
|
73
|
-
* @property {string} [icon='icon'] - Attribute to identify an icon class to render
|
|
74
|
-
* @property {string} [image='image'] - Attribute to identify an image to render
|
|
75
|
-
* @property {string} [children='children'] - Attribute to identify children of the current item
|
|
76
|
-
* @property {string} [summary='summary']
|
|
77
|
-
* @property {string} [notes='notes']
|
|
78
|
-
* @property {string} [props='props']
|
|
79
|
-
* @property {string} [isOpen='_open'] - Attribute to identify if the current item is open
|
|
80
|
-
* @property {string} [isDeleted='_deleted'] - Attribute to identify if the current item is deleted
|
|
81
|
-
* @property {FieldMapping} [fields] - Field mapping to be used on children in the next level
|
|
82
|
-
*/
|
|
83
|
-
export const defaultFields = {
|
|
84
|
-
id: 'id',
|
|
85
|
-
url: 'url',
|
|
86
|
-
text: 'text',
|
|
87
|
-
children: 'data',
|
|
88
|
-
icon: 'icon',
|
|
89
|
-
image: 'image',
|
|
90
|
-
component: 'component',
|
|
91
|
-
summary: 'summary',
|
|
92
|
-
notes: 'notes',
|
|
93
|
-
props: 'props',
|
|
94
|
-
target: 'target',
|
|
95
|
-
isOpen: '_open',
|
|
96
|
-
isDeleted: '_deleted'
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export const defaultKeyMap = {
|
|
167
|
+
export const DEFAULT_KEYMAP = {
|
|
100
168
|
ArrowRight: 'open',
|
|
101
169
|
ArrowLeft: 'close',
|
|
102
170
|
ArrowDown: 'down',
|
|
@@ -105,45 +173,56 @@ export const defaultKeyMap = {
|
|
|
105
173
|
Escape: 'deselect'
|
|
106
174
|
}
|
|
107
175
|
|
|
176
|
+
export const DEFAULT_THEME_MAPPING = {
|
|
177
|
+
surface: 'slate',
|
|
178
|
+
primary: 'orange',
|
|
179
|
+
secondary: 'pink',
|
|
180
|
+
accent: 'sky',
|
|
181
|
+
success: 'green',
|
|
182
|
+
warning: 'yellow',
|
|
183
|
+
danger: 'red',
|
|
184
|
+
error: 'red',
|
|
185
|
+
info: 'cyan'
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export const TONE_MAP = {
|
|
189
|
+
z0: 50,
|
|
190
|
+
z1: 100,
|
|
191
|
+
z2: 200,
|
|
192
|
+
z3: 300,
|
|
193
|
+
z4: 400,
|
|
194
|
+
z5: 500,
|
|
195
|
+
z6: 600,
|
|
196
|
+
z7: 700,
|
|
197
|
+
z8: 800,
|
|
198
|
+
z9: 900,
|
|
199
|
+
z10: 950
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Splits an icon name into its group and key components.
|
|
203
|
+
* @param {string} name - The icon name to split.
|
|
204
|
+
* @returns {{ group: string, key: string, value: string }} An object containing the group, key, and value of the icon name.
|
|
205
|
+
*/
|
|
206
|
+
function splitIconName(name) {
|
|
207
|
+
const parts = name.split('-')
|
|
208
|
+
const group = parts.slice(0, parts.length - 1).join('-')
|
|
209
|
+
return { group, key: parts[parts.length - 1], value: name }
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Generate a state icon mapping from a list of icon names
|
|
214
|
+
*
|
|
215
|
+
* @param {string[]} icons
|
|
216
|
+
* @returns {import('./types').StateIcons}
|
|
217
|
+
*/
|
|
108
218
|
export function stateIconsFromNames(icons) {
|
|
109
|
-
return icons
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
{}
|
|
117
|
-
)
|
|
219
|
+
return icons.map(splitIconName).reduce(
|
|
220
|
+
(acc, { group, key, value }) => ({
|
|
221
|
+
...acc,
|
|
222
|
+
[group]: { ...acc[group], [key]: value }
|
|
223
|
+
}),
|
|
224
|
+
{}
|
|
225
|
+
)
|
|
118
226
|
}
|
|
119
227
|
|
|
120
|
-
export const
|
|
121
|
-
// export const defaultStateIcons = {
|
|
122
|
-
// accordion: {
|
|
123
|
-
// opened: 'accordion-opened',
|
|
124
|
-
// closed: 'accordion-closed'
|
|
125
|
-
// },
|
|
126
|
-
// item: {
|
|
127
|
-
// remove: 'item-remove',
|
|
128
|
-
// add: 'item-add',
|
|
129
|
-
// clear: 'item-clear',
|
|
130
|
-
// search: 'item-search'
|
|
131
|
-
// },
|
|
132
|
-
// node: {
|
|
133
|
-
// opened: 'node-opened',
|
|
134
|
-
// closed: 'node-closed'
|
|
135
|
-
// },
|
|
136
|
-
// list: {
|
|
137
|
-
// selector: 'list-selector'
|
|
138
|
-
// },
|
|
139
|
-
// checkbox: {
|
|
140
|
-
// checked: 'checkbox-checked',
|
|
141
|
-
// unchecked: 'checkbox-unchecked',
|
|
142
|
-
// unknown: 'checkbox-unknown'
|
|
143
|
-
// },
|
|
144
|
-
// rating: { filled: 'rating-filled', empty: 'rating-empty' },
|
|
145
|
-
// radio: {
|
|
146
|
-
// off: 'radio-off',
|
|
147
|
-
// on: 'radio-on'
|
|
148
|
-
// }
|
|
149
|
-
// }
|
|
228
|
+
export const DEFAULT_STATE_ICONS = stateIconsFromNames(DEFAULT_ICONS)
|
package/src/events.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { noop } from './utils.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates an emitter object from the given properties.
|
|
5
|
+
*
|
|
6
|
+
* - Filters attributes that start with 'on' and are functions,
|
|
7
|
+
* - Returns an object with keys that are the event names (without the 'on' prefix)
|
|
8
|
+
* - If a default event is not present in the props, it will be set to a no-op function.
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} props - The properties object to filter.
|
|
11
|
+
* @param {Array<string>} defaults - An array of default events.
|
|
12
|
+
* @returns {import('./types.js').EventHandlers} The emitter object.
|
|
13
|
+
*/
|
|
14
|
+
export function createEmitter(props, defaults = []) {
|
|
15
|
+
const emit = {}
|
|
16
|
+
|
|
17
|
+
// Filter and add functions that start with 'on'
|
|
18
|
+
Object.entries(props)
|
|
19
|
+
.filter(([key, value]) => key.startsWith('on') && typeof value === 'function')
|
|
20
|
+
.forEach(([key, value]) => {
|
|
21
|
+
emit[key.slice(2)] = value
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
// Add default events with no-op function if not present
|
|
25
|
+
defaults.forEach((event) => {
|
|
26
|
+
if (!emit[event]) {
|
|
27
|
+
emit[event] = noop
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
return emit
|
|
32
|
+
}
|