@xaui/core 0.1.6 → 0.1.8
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 +21 -0
- package/README.md +50 -1
- package/dist/index.cjs +349 -2
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +58 -1
- package/dist/theme/index.cjs +13 -23
- package/dist/theme/index.d.cts +6 -2
- package/dist/theme/index.d.ts +6 -2
- package/dist/theme/index.js +13 -23
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bamory grams
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -269,12 +269,61 @@ const blue500 = colors.blue[500]
|
|
|
269
269
|
const red600 = colors.red[600]
|
|
270
270
|
```
|
|
271
271
|
|
|
272
|
+
## Spacing Tokens
|
|
273
|
+
|
|
274
|
+
Access the spacing scale for consistent layout:
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
import { spacing } from '@xaui/core/tokens'
|
|
278
|
+
|
|
279
|
+
const smallGap = spacing.sm // 8
|
|
280
|
+
const mediumGap = spacing.md // 16
|
|
281
|
+
const largeGap = spacing.lg // 24
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## Border Radius Tokens
|
|
285
|
+
|
|
286
|
+
Access border radius tokens:
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
import { borderRadius } from '@xaui/core/tokens'
|
|
290
|
+
|
|
291
|
+
const smallRadius = borderRadius.sm // 4
|
|
292
|
+
const mediumRadius = borderRadius.md // 8
|
|
293
|
+
const largeRadius = borderRadius.lg // 12
|
|
294
|
+
const fullRadius = borderRadius.full // 9999
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Typography Tokens
|
|
298
|
+
|
|
299
|
+
Access typography tokens:
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
import { fontSizes, fontWeights, fontFamilies } from '@xaui/core/tokens'
|
|
303
|
+
|
|
304
|
+
const headingSize = fontSizes['2xl'] // 24
|
|
305
|
+
const boldWeight = fontWeights.bold // 700
|
|
306
|
+
const bodyFont = fontFamilies.body // 'System'
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Shadow Tokens
|
|
310
|
+
|
|
311
|
+
Access shadow tokens for elevation:
|
|
312
|
+
|
|
313
|
+
```typescript
|
|
314
|
+
import { shadows } from '@xaui/core/tokens'
|
|
315
|
+
|
|
316
|
+
const cardShadow = shadows.md
|
|
317
|
+
// { shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1, shadowRadius: 4, elevation: 2 }
|
|
318
|
+
```
|
|
319
|
+
|
|
272
320
|
## TypeScript Support
|
|
273
321
|
|
|
274
322
|
All exports are fully typed for excellent IntelliSense support:
|
|
275
323
|
|
|
276
324
|
```typescript
|
|
277
|
-
import type { XUITheme } from '@xaui/core/theme'
|
|
325
|
+
import type { XUITheme, DeepPartial } from '@xaui/core/theme'
|
|
326
|
+
import type { ColorRole, SpacingScale } from '@xaui/core/tokens'
|
|
278
327
|
```
|
|
279
328
|
|
|
280
329
|
## Theme Structure
|
package/dist/index.cjs
CHANGED
|
@@ -21,16 +21,362 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
getSafeThemeColor: () => getSafeThemeColor,
|
|
24
|
-
withOpacity: () => withOpacity
|
|
24
|
+
withOpacity: () => withOpacity,
|
|
25
|
+
withPaletteNumber: () => withPaletteNumber
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(src_exports);
|
|
27
28
|
|
|
29
|
+
// src/tokens/index.ts
|
|
30
|
+
var colors = {
|
|
31
|
+
slate: {
|
|
32
|
+
50: "#f8fafc",
|
|
33
|
+
100: "#f1f5f9",
|
|
34
|
+
200: "#e2e8f0",
|
|
35
|
+
300: "#cbd5e1",
|
|
36
|
+
400: "#94a3b8",
|
|
37
|
+
500: "#64748b",
|
|
38
|
+
600: "#475569",
|
|
39
|
+
700: "#334155",
|
|
40
|
+
800: "#1e293b",
|
|
41
|
+
900: "#0f172a",
|
|
42
|
+
950: "#020617"
|
|
43
|
+
},
|
|
44
|
+
gray: {
|
|
45
|
+
50: "#f9fafb",
|
|
46
|
+
100: "#f3f4f6",
|
|
47
|
+
200: "#e5e7eb",
|
|
48
|
+
300: "#d1d5db",
|
|
49
|
+
400: "#9ca3af",
|
|
50
|
+
500: "#6b7280",
|
|
51
|
+
600: "#4b5563",
|
|
52
|
+
700: "#374151",
|
|
53
|
+
800: "#1f2937",
|
|
54
|
+
900: "#111827",
|
|
55
|
+
950: "#030712"
|
|
56
|
+
},
|
|
57
|
+
zinc: {
|
|
58
|
+
50: "#fafafa",
|
|
59
|
+
100: "#f4f4f5",
|
|
60
|
+
200: "#e4e4e7",
|
|
61
|
+
300: "#d4d4d8",
|
|
62
|
+
400: "#a1a1aa",
|
|
63
|
+
500: "#71717a",
|
|
64
|
+
600: "#52525b",
|
|
65
|
+
700: "#3f3f46",
|
|
66
|
+
800: "#27272a",
|
|
67
|
+
900: "#18181b",
|
|
68
|
+
950: "#09090b"
|
|
69
|
+
},
|
|
70
|
+
neutral: {
|
|
71
|
+
50: "#fafafa",
|
|
72
|
+
100: "#f5f5f5",
|
|
73
|
+
200: "#e5e5e5",
|
|
74
|
+
300: "#d4d4d4",
|
|
75
|
+
400: "#a3a3a3",
|
|
76
|
+
500: "#737373",
|
|
77
|
+
600: "#525252",
|
|
78
|
+
700: "#404040",
|
|
79
|
+
800: "#262626",
|
|
80
|
+
900: "#171717",
|
|
81
|
+
950: "#0a0a0a"
|
|
82
|
+
},
|
|
83
|
+
stone: {
|
|
84
|
+
50: "#fafaf9",
|
|
85
|
+
100: "#f5f5f4",
|
|
86
|
+
200: "#e7e5e4",
|
|
87
|
+
300: "#d6d3d1",
|
|
88
|
+
400: "#a8a29e",
|
|
89
|
+
500: "#78716c",
|
|
90
|
+
600: "#57534e",
|
|
91
|
+
700: "#44403c",
|
|
92
|
+
800: "#292524",
|
|
93
|
+
900: "#1c1917",
|
|
94
|
+
950: "#0c0a09"
|
|
95
|
+
},
|
|
96
|
+
red: {
|
|
97
|
+
50: "#fef2f2",
|
|
98
|
+
100: "#fee2e2",
|
|
99
|
+
200: "#fecaca",
|
|
100
|
+
300: "#fca5a5",
|
|
101
|
+
400: "#f87171",
|
|
102
|
+
500: "#ef4444",
|
|
103
|
+
600: "#dc2626",
|
|
104
|
+
700: "#b91c1c",
|
|
105
|
+
800: "#991b1b",
|
|
106
|
+
900: "#7f1d1d",
|
|
107
|
+
950: "#450a0a"
|
|
108
|
+
},
|
|
109
|
+
orange: {
|
|
110
|
+
50: "#fff7ed",
|
|
111
|
+
100: "#ffedd5",
|
|
112
|
+
200: "#fed7aa",
|
|
113
|
+
300: "#fdba74",
|
|
114
|
+
400: "#fb923c",
|
|
115
|
+
500: "#f97316",
|
|
116
|
+
600: "#ea580c",
|
|
117
|
+
700: "#c2410c",
|
|
118
|
+
800: "#9a3412",
|
|
119
|
+
900: "#7c2d12",
|
|
120
|
+
950: "#431407"
|
|
121
|
+
},
|
|
122
|
+
amber: {
|
|
123
|
+
50: "#fffbeb",
|
|
124
|
+
100: "#fef3c7",
|
|
125
|
+
200: "#fde68a",
|
|
126
|
+
300: "#fcd34d",
|
|
127
|
+
400: "#fbbf24",
|
|
128
|
+
500: "#f59e0b",
|
|
129
|
+
600: "#d97706",
|
|
130
|
+
700: "#b45309",
|
|
131
|
+
800: "#92400e",
|
|
132
|
+
900: "#78350f",
|
|
133
|
+
950: "#451a03"
|
|
134
|
+
},
|
|
135
|
+
yellow: {
|
|
136
|
+
50: "#fefce8",
|
|
137
|
+
100: "#fef9c3",
|
|
138
|
+
200: "#fef08a",
|
|
139
|
+
300: "#fde047",
|
|
140
|
+
400: "#facc15",
|
|
141
|
+
500: "#eab308",
|
|
142
|
+
600: "#ca8a04",
|
|
143
|
+
700: "#a16207",
|
|
144
|
+
800: "#854d0e",
|
|
145
|
+
900: "#713f12",
|
|
146
|
+
950: "#422006"
|
|
147
|
+
},
|
|
148
|
+
lime: {
|
|
149
|
+
50: "#f7fee7",
|
|
150
|
+
100: "#ecfccb",
|
|
151
|
+
200: "#d9f99d",
|
|
152
|
+
300: "#bef264",
|
|
153
|
+
400: "#a3e635",
|
|
154
|
+
500: "#84cc16",
|
|
155
|
+
600: "#65a30d",
|
|
156
|
+
700: "#4d7c0f",
|
|
157
|
+
800: "#3f6212",
|
|
158
|
+
900: "#365314",
|
|
159
|
+
950: "#1a2e05"
|
|
160
|
+
},
|
|
161
|
+
green: {
|
|
162
|
+
50: "#f0fdf4",
|
|
163
|
+
100: "#dcfce7",
|
|
164
|
+
200: "#bbf7d0",
|
|
165
|
+
300: "#86efac",
|
|
166
|
+
400: "#4ade80",
|
|
167
|
+
500: "#22c55e",
|
|
168
|
+
600: "#16a34a",
|
|
169
|
+
700: "#15803d",
|
|
170
|
+
800: "#166534",
|
|
171
|
+
900: "#14532d",
|
|
172
|
+
950: "#052e16"
|
|
173
|
+
},
|
|
174
|
+
emerald: {
|
|
175
|
+
50: "#ecfdf5",
|
|
176
|
+
100: "#d1fae5",
|
|
177
|
+
200: "#a7f3d0",
|
|
178
|
+
300: "#6ee7b7",
|
|
179
|
+
400: "#34d399",
|
|
180
|
+
500: "#10b981",
|
|
181
|
+
600: "#059669",
|
|
182
|
+
700: "#047857",
|
|
183
|
+
800: "#065f46",
|
|
184
|
+
900: "#064e3b",
|
|
185
|
+
950: "#022c22"
|
|
186
|
+
},
|
|
187
|
+
teal: {
|
|
188
|
+
50: "#f0fdfa",
|
|
189
|
+
100: "#ccfbf1",
|
|
190
|
+
200: "#99f6e4",
|
|
191
|
+
300: "#5eead4",
|
|
192
|
+
400: "#2dd4bf",
|
|
193
|
+
500: "#14b8a6",
|
|
194
|
+
600: "#0d9488",
|
|
195
|
+
700: "#0f766e",
|
|
196
|
+
800: "#115e59",
|
|
197
|
+
900: "#134e4a",
|
|
198
|
+
950: "#042f2e"
|
|
199
|
+
},
|
|
200
|
+
cyan: {
|
|
201
|
+
50: "#ecfeff",
|
|
202
|
+
100: "#cffafe",
|
|
203
|
+
200: "#a5f3fc",
|
|
204
|
+
300: "#67e8f9",
|
|
205
|
+
400: "#22d3ee",
|
|
206
|
+
500: "#06b6d4",
|
|
207
|
+
600: "#0891b2",
|
|
208
|
+
700: "#0e7490",
|
|
209
|
+
800: "#155e75",
|
|
210
|
+
900: "#164e63",
|
|
211
|
+
950: "#083344"
|
|
212
|
+
},
|
|
213
|
+
sky: {
|
|
214
|
+
50: "#f0f9ff",
|
|
215
|
+
100: "#e0f2fe",
|
|
216
|
+
200: "#bae6fd",
|
|
217
|
+
300: "#7dd3fc",
|
|
218
|
+
400: "#38bdf8",
|
|
219
|
+
500: "#0ea5e9",
|
|
220
|
+
600: "#0284c7",
|
|
221
|
+
700: "#0369a1",
|
|
222
|
+
800: "#075985",
|
|
223
|
+
900: "#0c4a6e",
|
|
224
|
+
950: "#082f49"
|
|
225
|
+
},
|
|
226
|
+
blue: {
|
|
227
|
+
50: "#eff6ff",
|
|
228
|
+
100: "#dbeafe",
|
|
229
|
+
200: "#bfdbfe",
|
|
230
|
+
300: "#93c5fd",
|
|
231
|
+
400: "#60a5fa",
|
|
232
|
+
500: "#3b82f6",
|
|
233
|
+
600: "#2563eb",
|
|
234
|
+
700: "#1d4ed8",
|
|
235
|
+
800: "#1e40af",
|
|
236
|
+
900: "#1e3a8a",
|
|
237
|
+
950: "#172554"
|
|
238
|
+
},
|
|
239
|
+
indigo: {
|
|
240
|
+
50: "#eef2ff",
|
|
241
|
+
100: "#e0e7ff",
|
|
242
|
+
200: "#c7d2fe",
|
|
243
|
+
300: "#a5b4fc",
|
|
244
|
+
400: "#818cf8",
|
|
245
|
+
500: "#6366f1",
|
|
246
|
+
600: "#4f46e5",
|
|
247
|
+
700: "#4338ca",
|
|
248
|
+
800: "#3730a3",
|
|
249
|
+
900: "#312e81",
|
|
250
|
+
950: "#1e1b4b"
|
|
251
|
+
},
|
|
252
|
+
violet: {
|
|
253
|
+
50: "#f5f3ff",
|
|
254
|
+
100: "#ede9fe",
|
|
255
|
+
200: "#ddd6fe",
|
|
256
|
+
300: "#c4b5fd",
|
|
257
|
+
400: "#a78bfa",
|
|
258
|
+
500: "#8b5cf6",
|
|
259
|
+
600: "#7c3aed",
|
|
260
|
+
700: "#6d28d9",
|
|
261
|
+
800: "#5b21b6",
|
|
262
|
+
900: "#4c1d95",
|
|
263
|
+
950: "#2e1065"
|
|
264
|
+
},
|
|
265
|
+
purple: {
|
|
266
|
+
50: "#faf5ff",
|
|
267
|
+
100: "#f3e8ff",
|
|
268
|
+
200: "#e9d5ff",
|
|
269
|
+
300: "#d8b4fe",
|
|
270
|
+
400: "#c084fc",
|
|
271
|
+
500: "#a855f7",
|
|
272
|
+
600: "#9333ea",
|
|
273
|
+
700: "#7e22ce",
|
|
274
|
+
800: "#6b21a8",
|
|
275
|
+
900: "#581c87",
|
|
276
|
+
950: "#3b0764"
|
|
277
|
+
},
|
|
278
|
+
fuchsia: {
|
|
279
|
+
50: "#fdf4ff",
|
|
280
|
+
100: "#fae8ff",
|
|
281
|
+
200: "#f5d0fe",
|
|
282
|
+
300: "#f0abfc",
|
|
283
|
+
400: "#e879f9",
|
|
284
|
+
500: "#d946ef",
|
|
285
|
+
600: "#c026d3",
|
|
286
|
+
700: "#a21caf",
|
|
287
|
+
800: "#86198f",
|
|
288
|
+
900: "#701a75",
|
|
289
|
+
950: "#4a044e"
|
|
290
|
+
},
|
|
291
|
+
pink: {
|
|
292
|
+
50: "#fdf2f8",
|
|
293
|
+
100: "#fce7f3",
|
|
294
|
+
200: "#fbcfe8",
|
|
295
|
+
300: "#f9a8d4",
|
|
296
|
+
400: "#f472b6",
|
|
297
|
+
500: "#ec4899",
|
|
298
|
+
600: "#db2777",
|
|
299
|
+
700: "#be185d",
|
|
300
|
+
800: "#9d174d",
|
|
301
|
+
900: "#831843",
|
|
302
|
+
950: "#500724"
|
|
303
|
+
},
|
|
304
|
+
rose: {
|
|
305
|
+
50: "#fff1f2",
|
|
306
|
+
100: "#ffe4e6",
|
|
307
|
+
200: "#fecdd3",
|
|
308
|
+
300: "#fda4af",
|
|
309
|
+
400: "#fb7185",
|
|
310
|
+
500: "#f43f5e",
|
|
311
|
+
600: "#e11d48",
|
|
312
|
+
700: "#be123c",
|
|
313
|
+
800: "#9f1239",
|
|
314
|
+
900: "#881337",
|
|
315
|
+
950: "#4c0519"
|
|
316
|
+
},
|
|
317
|
+
black: "#000000",
|
|
318
|
+
white: "#ffffff",
|
|
319
|
+
transparent: "transparent"
|
|
320
|
+
};
|
|
321
|
+
|
|
28
322
|
// src/utils/colors-utils.ts
|
|
29
323
|
function withOpacity(color, opacity) {
|
|
30
324
|
const clampedOpacity = Math.max(0, Math.min(1, opacity));
|
|
31
325
|
const alpha = Math.round(clampedOpacity * 255).toString(16).padStart(2, "0");
|
|
32
326
|
return `${color}${alpha}`;
|
|
33
327
|
}
|
|
328
|
+
var normalizeHexColor = (color) => {
|
|
329
|
+
const normalized = color.trim().toLowerCase();
|
|
330
|
+
if (!normalized.startsWith("#")) return normalized;
|
|
331
|
+
if (normalized.length === 9) return normalized.slice(0, 7);
|
|
332
|
+
if (normalized.length === 5) {
|
|
333
|
+
const [r, g, b] = normalized.slice(1, 4).split("");
|
|
334
|
+
return `#${r}${r}${g}${g}${b}${b}`;
|
|
335
|
+
}
|
|
336
|
+
return normalized;
|
|
337
|
+
};
|
|
338
|
+
var colorPalettes = Object.values(colors).filter(
|
|
339
|
+
(value) => typeof value === "object" && value !== null
|
|
340
|
+
);
|
|
341
|
+
var hexToRgb = (color) => {
|
|
342
|
+
const normalized = normalizeHexColor(color);
|
|
343
|
+
if (!normalized.startsWith("#") || normalized.length !== 7) return null;
|
|
344
|
+
const r = parseInt(normalized.slice(1, 3), 16);
|
|
345
|
+
const g = parseInt(normalized.slice(3, 5), 16);
|
|
346
|
+
const b = parseInt(normalized.slice(5, 7), 16);
|
|
347
|
+
return Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b) ? null : [r, g, b];
|
|
348
|
+
};
|
|
349
|
+
var colorDistance = (a, b) => {
|
|
350
|
+
const dr = a[0] - b[0];
|
|
351
|
+
const dg = a[1] - b[1];
|
|
352
|
+
const db = a[2] - b[2];
|
|
353
|
+
return dr * dr + dg * dg + db * db;
|
|
354
|
+
};
|
|
355
|
+
function withPaletteNumber(color, paletteNumber) {
|
|
356
|
+
const normalizedInput = normalizeHexColor(color);
|
|
357
|
+
const inputRgb = hexToRgb(normalizedInput);
|
|
358
|
+
if (!inputRgb) return color;
|
|
359
|
+
const exactPalette = colorPalettes.find(
|
|
360
|
+
(scale) => Object.values(scale).some(
|
|
361
|
+
(scaleColor) => normalizeHexColor(scaleColor) === normalizedInput
|
|
362
|
+
)
|
|
363
|
+
);
|
|
364
|
+
if (exactPalette) return exactPalette[paletteNumber];
|
|
365
|
+
let nearestPalette = null;
|
|
366
|
+
let nearestDistance = Number.POSITIVE_INFINITY;
|
|
367
|
+
for (const palette of colorPalettes) {
|
|
368
|
+
for (const swatch of Object.values(palette)) {
|
|
369
|
+
const swatchRgb = hexToRgb(swatch);
|
|
370
|
+
if (!swatchRgb) continue;
|
|
371
|
+
const distance = colorDistance(inputRgb, swatchRgb);
|
|
372
|
+
if (distance < nearestDistance) {
|
|
373
|
+
nearestDistance = distance;
|
|
374
|
+
nearestPalette = palette;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return nearestPalette ? nearestPalette[paletteNumber] : color;
|
|
379
|
+
}
|
|
34
380
|
var validThemeColors = [
|
|
35
381
|
"primary",
|
|
36
382
|
"secondary",
|
|
@@ -46,5 +392,6 @@ function getSafeThemeColor(themeColor) {
|
|
|
46
392
|
// Annotate the CommonJS export names for ESM import in node:
|
|
47
393
|
0 && (module.exports = {
|
|
48
394
|
getSafeThemeColor,
|
|
49
|
-
withOpacity
|
|
395
|
+
withOpacity,
|
|
396
|
+
withPaletteNumber
|
|
50
397
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -5,8 +5,16 @@
|
|
|
5
5
|
* @returns Color with opacity
|
|
6
6
|
*/
|
|
7
7
|
declare function withOpacity(color: string, opacity: number): string;
|
|
8
|
+
type PaletteNumber = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
|
|
9
|
+
/**
|
|
10
|
+
* Create opacity variants for a color
|
|
11
|
+
* @param color - Base color hex
|
|
12
|
+
* @param paletteNumber - Palette number (50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950)
|
|
13
|
+
* @returns Color from matched (or nearest) palette family at the requested palette number
|
|
14
|
+
*/
|
|
15
|
+
declare function withPaletteNumber(color: string, paletteNumber: PaletteNumber): string;
|
|
8
16
|
declare const validThemeColors: readonly ["primary", "secondary", "tertiary", "danger", "warning", "success", "default"];
|
|
9
17
|
declare function getSafeThemeColor(themeColor: string): ValidThemeColor;
|
|
10
18
|
type ValidThemeColor = (typeof validThemeColors)[number];
|
|
11
19
|
|
|
12
|
-
export { getSafeThemeColor, withOpacity };
|
|
20
|
+
export { getSafeThemeColor, withOpacity, withPaletteNumber };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,16 @@
|
|
|
5
5
|
* @returns Color with opacity
|
|
6
6
|
*/
|
|
7
7
|
declare function withOpacity(color: string, opacity: number): string;
|
|
8
|
+
type PaletteNumber = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
|
|
9
|
+
/**
|
|
10
|
+
* Create opacity variants for a color
|
|
11
|
+
* @param color - Base color hex
|
|
12
|
+
* @param paletteNumber - Palette number (50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950)
|
|
13
|
+
* @returns Color from matched (or nearest) palette family at the requested palette number
|
|
14
|
+
*/
|
|
15
|
+
declare function withPaletteNumber(color: string, paletteNumber: PaletteNumber): string;
|
|
8
16
|
declare const validThemeColors: readonly ["primary", "secondary", "tertiary", "danger", "warning", "success", "default"];
|
|
9
17
|
declare function getSafeThemeColor(themeColor: string): ValidThemeColor;
|
|
10
18
|
type ValidThemeColor = (typeof validThemeColors)[number];
|
|
11
19
|
|
|
12
|
-
export { getSafeThemeColor, withOpacity };
|
|
20
|
+
export { getSafeThemeColor, withOpacity, withPaletteNumber };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
colors
|
|
3
|
+
} from "./chunk-IRULUOQR.js";
|
|
4
|
+
|
|
1
5
|
// src/utils/colors-utils.ts
|
|
2
6
|
function withOpacity(color, opacity) {
|
|
3
7
|
const clampedOpacity = Math.max(0, Math.min(1, opacity));
|
|
4
8
|
const alpha = Math.round(clampedOpacity * 255).toString(16).padStart(2, "0");
|
|
5
9
|
return `${color}${alpha}`;
|
|
6
10
|
}
|
|
11
|
+
var normalizeHexColor = (color) => {
|
|
12
|
+
const normalized = color.trim().toLowerCase();
|
|
13
|
+
if (!normalized.startsWith("#")) return normalized;
|
|
14
|
+
if (normalized.length === 9) return normalized.slice(0, 7);
|
|
15
|
+
if (normalized.length === 5) {
|
|
16
|
+
const [r, g, b] = normalized.slice(1, 4).split("");
|
|
17
|
+
return `#${r}${r}${g}${g}${b}${b}`;
|
|
18
|
+
}
|
|
19
|
+
return normalized;
|
|
20
|
+
};
|
|
21
|
+
var colorPalettes = Object.values(colors).filter(
|
|
22
|
+
(value) => typeof value === "object" && value !== null
|
|
23
|
+
);
|
|
24
|
+
var hexToRgb = (color) => {
|
|
25
|
+
const normalized = normalizeHexColor(color);
|
|
26
|
+
if (!normalized.startsWith("#") || normalized.length !== 7) return null;
|
|
27
|
+
const r = parseInt(normalized.slice(1, 3), 16);
|
|
28
|
+
const g = parseInt(normalized.slice(3, 5), 16);
|
|
29
|
+
const b = parseInt(normalized.slice(5, 7), 16);
|
|
30
|
+
return Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b) ? null : [r, g, b];
|
|
31
|
+
};
|
|
32
|
+
var colorDistance = (a, b) => {
|
|
33
|
+
const dr = a[0] - b[0];
|
|
34
|
+
const dg = a[1] - b[1];
|
|
35
|
+
const db = a[2] - b[2];
|
|
36
|
+
return dr * dr + dg * dg + db * db;
|
|
37
|
+
};
|
|
38
|
+
function withPaletteNumber(color, paletteNumber) {
|
|
39
|
+
const normalizedInput = normalizeHexColor(color);
|
|
40
|
+
const inputRgb = hexToRgb(normalizedInput);
|
|
41
|
+
if (!inputRgb) return color;
|
|
42
|
+
const exactPalette = colorPalettes.find(
|
|
43
|
+
(scale) => Object.values(scale).some(
|
|
44
|
+
(scaleColor) => normalizeHexColor(scaleColor) === normalizedInput
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
if (exactPalette) return exactPalette[paletteNumber];
|
|
48
|
+
let nearestPalette = null;
|
|
49
|
+
let nearestDistance = Number.POSITIVE_INFINITY;
|
|
50
|
+
for (const palette of colorPalettes) {
|
|
51
|
+
for (const swatch of Object.values(palette)) {
|
|
52
|
+
const swatchRgb = hexToRgb(swatch);
|
|
53
|
+
if (!swatchRgb) continue;
|
|
54
|
+
const distance = colorDistance(inputRgb, swatchRgb);
|
|
55
|
+
if (distance < nearestDistance) {
|
|
56
|
+
nearestDistance = distance;
|
|
57
|
+
nearestPalette = palette;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return nearestPalette ? nearestPalette[paletteNumber] : color;
|
|
62
|
+
}
|
|
7
63
|
var validThemeColors = [
|
|
8
64
|
"primary",
|
|
9
65
|
"secondary",
|
|
@@ -18,5 +74,6 @@ function getSafeThemeColor(themeColor) {
|
|
|
18
74
|
}
|
|
19
75
|
export {
|
|
20
76
|
getSafeThemeColor,
|
|
21
|
-
withOpacity
|
|
77
|
+
withOpacity,
|
|
78
|
+
withPaletteNumber
|
|
22
79
|
};
|
package/dist/theme/index.cjs
CHANGED
|
@@ -322,44 +322,37 @@ var colors = {
|
|
|
322
322
|
var themeColors = {
|
|
323
323
|
primary: {
|
|
324
324
|
main: colors.purple[800],
|
|
325
|
-
accent: colors.purple[950],
|
|
326
325
|
foreground: colors.white,
|
|
327
326
|
background: colors.purple[200]
|
|
328
327
|
},
|
|
329
328
|
secondary: {
|
|
330
329
|
main: colors.zinc[500],
|
|
331
|
-
accent: colors.neutral[800],
|
|
332
330
|
foreground: colors.white,
|
|
333
|
-
background: colors.
|
|
331
|
+
background: colors.zinc[200]
|
|
334
332
|
},
|
|
335
333
|
tertiary: {
|
|
336
334
|
main: colors.stone[500],
|
|
337
|
-
accent: colors.orange[950],
|
|
338
335
|
foreground: colors.white,
|
|
339
|
-
background: colors.
|
|
336
|
+
background: colors.stone[100]
|
|
340
337
|
},
|
|
341
338
|
danger: {
|
|
342
339
|
main: colors.red[700],
|
|
343
|
-
accent: colors.red[950],
|
|
344
340
|
foreground: colors.white,
|
|
345
341
|
background: colors.rose[200]
|
|
346
342
|
},
|
|
347
343
|
warning: {
|
|
348
344
|
main: colors.amber[600],
|
|
349
|
-
accent: colors.amber[900],
|
|
350
345
|
foreground: colors.gray[900],
|
|
351
346
|
background: colors.amber[100]
|
|
352
347
|
},
|
|
353
348
|
success: {
|
|
354
349
|
main: colors.green[600],
|
|
355
|
-
accent: colors.green[900],
|
|
356
350
|
foreground: colors.white,
|
|
357
351
|
background: colors.green[100]
|
|
358
352
|
},
|
|
359
353
|
default: {
|
|
360
|
-
main: colors.
|
|
361
|
-
|
|
362
|
-
foreground: colors.zinc[900],
|
|
354
|
+
main: colors.zinc[900],
|
|
355
|
+
foreground: colors.white,
|
|
363
356
|
background: colors.zinc[200]
|
|
364
357
|
},
|
|
365
358
|
background: colors.white,
|
|
@@ -368,44 +361,37 @@ var themeColors = {
|
|
|
368
361
|
var darkThemeColors = {
|
|
369
362
|
primary: {
|
|
370
363
|
main: colors.purple[300],
|
|
371
|
-
accent: colors.purple[200],
|
|
372
364
|
foreground: colors.purple[950],
|
|
373
365
|
background: colors.purple[900]
|
|
374
366
|
},
|
|
375
367
|
secondary: {
|
|
376
368
|
main: colors.zinc[300],
|
|
377
|
-
accent: colors.purple[200],
|
|
378
369
|
foreground: colors.zinc[700],
|
|
379
370
|
background: colors.zinc[600]
|
|
380
371
|
},
|
|
381
372
|
tertiary: {
|
|
382
373
|
main: colors.red[200],
|
|
383
|
-
accent: colors.red[100],
|
|
384
374
|
foreground: colors.pink[950],
|
|
385
375
|
background: colors.stone[600]
|
|
386
376
|
},
|
|
387
377
|
danger: {
|
|
388
378
|
main: colors.red[300],
|
|
389
|
-
accent: colors.red[300],
|
|
390
379
|
foreground: colors.rose[950],
|
|
391
380
|
background: colors.red[800]
|
|
392
381
|
},
|
|
393
382
|
warning: {
|
|
394
383
|
main: colors.amber[400],
|
|
395
|
-
accent: colors.amber[100],
|
|
396
384
|
foreground: colors.gray[50],
|
|
397
385
|
background: colors.amber[900]
|
|
398
386
|
},
|
|
399
387
|
success: {
|
|
400
388
|
main: colors.green[400],
|
|
401
|
-
accent: colors.green[200],
|
|
402
389
|
foreground: colors.gray[50],
|
|
403
390
|
background: colors.green[900]
|
|
404
391
|
},
|
|
405
392
|
default: {
|
|
406
|
-
main: colors.
|
|
407
|
-
|
|
408
|
-
foreground: colors.stone[200],
|
|
393
|
+
main: colors.stone[200],
|
|
394
|
+
foreground: colors.zinc[900],
|
|
409
395
|
background: colors.zinc[700]
|
|
410
396
|
},
|
|
411
397
|
background: colors.zinc[900],
|
|
@@ -437,9 +423,9 @@ var baseTheme = {
|
|
|
437
423
|
none: 0,
|
|
438
424
|
xs: 0.5,
|
|
439
425
|
sm: 1,
|
|
440
|
-
md:
|
|
441
|
-
lg:
|
|
442
|
-
xl:
|
|
426
|
+
md: 1.75,
|
|
427
|
+
lg: 2.5,
|
|
428
|
+
xl: 3
|
|
443
429
|
},
|
|
444
430
|
fontSizes: {
|
|
445
431
|
xs: 12,
|
|
@@ -496,11 +482,15 @@ var baseTheme = {
|
|
|
496
482
|
}
|
|
497
483
|
};
|
|
498
484
|
var theme = {
|
|
485
|
+
palette: colors,
|
|
499
486
|
colors: themeColors,
|
|
487
|
+
mode: "light",
|
|
500
488
|
...baseTheme
|
|
501
489
|
};
|
|
502
490
|
var darkTheme = {
|
|
491
|
+
palette: colors,
|
|
503
492
|
colors: darkThemeColors,
|
|
493
|
+
mode: "dark",
|
|
504
494
|
...baseTheme
|
|
505
495
|
};
|
|
506
496
|
var defaultTheme = theme;
|
package/dist/theme/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { colors } from '../tokens/index.cjs';
|
|
2
|
+
|
|
1
3
|
type ColorScheme = {
|
|
2
4
|
main: string;
|
|
3
|
-
accent: string;
|
|
4
5
|
foreground: string;
|
|
5
6
|
background: string;
|
|
6
7
|
};
|
|
@@ -109,6 +110,8 @@ interface ThemeShadows {
|
|
|
109
110
|
};
|
|
110
111
|
}
|
|
111
112
|
interface XUITheme {
|
|
113
|
+
mode: 'light' | 'dark';
|
|
114
|
+
palette: typeof colors;
|
|
112
115
|
colors: ThemeColors;
|
|
113
116
|
spacing: ThemeSpacing;
|
|
114
117
|
borderRadius: ThemeBorderRadius;
|
|
@@ -118,7 +121,8 @@ interface XUITheme {
|
|
|
118
121
|
fontFamilies: ThemeFontFamilies;
|
|
119
122
|
shadows: ThemeShadows;
|
|
120
123
|
}
|
|
124
|
+
type PartialXUITheme = Partial<XUITheme>;
|
|
121
125
|
declare const defaultTheme: XUITheme;
|
|
122
126
|
declare const defaultDarkTheme: XUITheme;
|
|
123
127
|
|
|
124
|
-
export { type XUITheme, defaultDarkTheme, defaultTheme };
|
|
128
|
+
export { type PartialXUITheme, type XUITheme, defaultDarkTheme, defaultTheme };
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { colors } from '../tokens/index.js';
|
|
2
|
+
|
|
1
3
|
type ColorScheme = {
|
|
2
4
|
main: string;
|
|
3
|
-
accent: string;
|
|
4
5
|
foreground: string;
|
|
5
6
|
background: string;
|
|
6
7
|
};
|
|
@@ -109,6 +110,8 @@ interface ThemeShadows {
|
|
|
109
110
|
};
|
|
110
111
|
}
|
|
111
112
|
interface XUITheme {
|
|
113
|
+
mode: 'light' | 'dark';
|
|
114
|
+
palette: typeof colors;
|
|
112
115
|
colors: ThemeColors;
|
|
113
116
|
spacing: ThemeSpacing;
|
|
114
117
|
borderRadius: ThemeBorderRadius;
|
|
@@ -118,7 +121,8 @@ interface XUITheme {
|
|
|
118
121
|
fontFamilies: ThemeFontFamilies;
|
|
119
122
|
shadows: ThemeShadows;
|
|
120
123
|
}
|
|
124
|
+
type PartialXUITheme = Partial<XUITheme>;
|
|
121
125
|
declare const defaultTheme: XUITheme;
|
|
122
126
|
declare const defaultDarkTheme: XUITheme;
|
|
123
127
|
|
|
124
|
-
export { type XUITheme, defaultDarkTheme, defaultTheme };
|
|
128
|
+
export { type PartialXUITheme, type XUITheme, defaultDarkTheme, defaultTheme };
|
package/dist/theme/index.js
CHANGED
|
@@ -6,44 +6,37 @@ import {
|
|
|
6
6
|
var themeColors = {
|
|
7
7
|
primary: {
|
|
8
8
|
main: colors.purple[800],
|
|
9
|
-
accent: colors.purple[950],
|
|
10
9
|
foreground: colors.white,
|
|
11
10
|
background: colors.purple[200]
|
|
12
11
|
},
|
|
13
12
|
secondary: {
|
|
14
13
|
main: colors.zinc[500],
|
|
15
|
-
accent: colors.neutral[800],
|
|
16
14
|
foreground: colors.white,
|
|
17
|
-
background: colors.
|
|
15
|
+
background: colors.zinc[200]
|
|
18
16
|
},
|
|
19
17
|
tertiary: {
|
|
20
18
|
main: colors.stone[500],
|
|
21
|
-
accent: colors.orange[950],
|
|
22
19
|
foreground: colors.white,
|
|
23
|
-
background: colors.
|
|
20
|
+
background: colors.stone[100]
|
|
24
21
|
},
|
|
25
22
|
danger: {
|
|
26
23
|
main: colors.red[700],
|
|
27
|
-
accent: colors.red[950],
|
|
28
24
|
foreground: colors.white,
|
|
29
25
|
background: colors.rose[200]
|
|
30
26
|
},
|
|
31
27
|
warning: {
|
|
32
28
|
main: colors.amber[600],
|
|
33
|
-
accent: colors.amber[900],
|
|
34
29
|
foreground: colors.gray[900],
|
|
35
30
|
background: colors.amber[100]
|
|
36
31
|
},
|
|
37
32
|
success: {
|
|
38
33
|
main: colors.green[600],
|
|
39
|
-
accent: colors.green[900],
|
|
40
34
|
foreground: colors.white,
|
|
41
35
|
background: colors.green[100]
|
|
42
36
|
},
|
|
43
37
|
default: {
|
|
44
|
-
main: colors.
|
|
45
|
-
|
|
46
|
-
foreground: colors.zinc[900],
|
|
38
|
+
main: colors.zinc[900],
|
|
39
|
+
foreground: colors.white,
|
|
47
40
|
background: colors.zinc[200]
|
|
48
41
|
},
|
|
49
42
|
background: colors.white,
|
|
@@ -52,44 +45,37 @@ var themeColors = {
|
|
|
52
45
|
var darkThemeColors = {
|
|
53
46
|
primary: {
|
|
54
47
|
main: colors.purple[300],
|
|
55
|
-
accent: colors.purple[200],
|
|
56
48
|
foreground: colors.purple[950],
|
|
57
49
|
background: colors.purple[900]
|
|
58
50
|
},
|
|
59
51
|
secondary: {
|
|
60
52
|
main: colors.zinc[300],
|
|
61
|
-
accent: colors.purple[200],
|
|
62
53
|
foreground: colors.zinc[700],
|
|
63
54
|
background: colors.zinc[600]
|
|
64
55
|
},
|
|
65
56
|
tertiary: {
|
|
66
57
|
main: colors.red[200],
|
|
67
|
-
accent: colors.red[100],
|
|
68
58
|
foreground: colors.pink[950],
|
|
69
59
|
background: colors.stone[600]
|
|
70
60
|
},
|
|
71
61
|
danger: {
|
|
72
62
|
main: colors.red[300],
|
|
73
|
-
accent: colors.red[300],
|
|
74
63
|
foreground: colors.rose[950],
|
|
75
64
|
background: colors.red[800]
|
|
76
65
|
},
|
|
77
66
|
warning: {
|
|
78
67
|
main: colors.amber[400],
|
|
79
|
-
accent: colors.amber[100],
|
|
80
68
|
foreground: colors.gray[50],
|
|
81
69
|
background: colors.amber[900]
|
|
82
70
|
},
|
|
83
71
|
success: {
|
|
84
72
|
main: colors.green[400],
|
|
85
|
-
accent: colors.green[200],
|
|
86
73
|
foreground: colors.gray[50],
|
|
87
74
|
background: colors.green[900]
|
|
88
75
|
},
|
|
89
76
|
default: {
|
|
90
|
-
main: colors.
|
|
91
|
-
|
|
92
|
-
foreground: colors.stone[200],
|
|
77
|
+
main: colors.stone[200],
|
|
78
|
+
foreground: colors.zinc[900],
|
|
93
79
|
background: colors.zinc[700]
|
|
94
80
|
},
|
|
95
81
|
background: colors.zinc[900],
|
|
@@ -121,9 +107,9 @@ var baseTheme = {
|
|
|
121
107
|
none: 0,
|
|
122
108
|
xs: 0.5,
|
|
123
109
|
sm: 1,
|
|
124
|
-
md:
|
|
125
|
-
lg:
|
|
126
|
-
xl:
|
|
110
|
+
md: 1.75,
|
|
111
|
+
lg: 2.5,
|
|
112
|
+
xl: 3
|
|
127
113
|
},
|
|
128
114
|
fontSizes: {
|
|
129
115
|
xs: 12,
|
|
@@ -180,11 +166,15 @@ var baseTheme = {
|
|
|
180
166
|
}
|
|
181
167
|
};
|
|
182
168
|
var theme = {
|
|
169
|
+
palette: colors,
|
|
183
170
|
colors: themeColors,
|
|
171
|
+
mode: "light",
|
|
184
172
|
...baseTheme
|
|
185
173
|
};
|
|
186
174
|
var darkTheme = {
|
|
175
|
+
palette: colors,
|
|
187
176
|
colors: darkThemeColors,
|
|
177
|
+
mode: "dark",
|
|
188
178
|
...baseTheme
|
|
189
179
|
};
|
|
190
180
|
var defaultTheme = theme;
|