qstd 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,473 @@
1
+ // src/preset/index.ts
2
+ var preset = {
3
+ name: "qstd-preset",
4
+ globalCss: {
5
+ ":root": { colorScheme: "light dark" },
6
+ html: {
7
+ fontSize: 16,
8
+ lineHeight: 1.5,
9
+ fontFamily: "geologica, sans-serif"
10
+ }
11
+ },
12
+ theme: {
13
+ semanticTokens: {
14
+ colors: {
15
+ "text-primary": {
16
+ value: {
17
+ base: "{colors.neutral.900}",
18
+ _dark: "{colors.neutral.100}"
19
+ }
20
+ },
21
+ "text-secondary": {
22
+ value: {
23
+ base: "{colors.neutral.400}",
24
+ _dark: "{colors.neutral.400}"
25
+ }
26
+ },
27
+ "text-inverted": {
28
+ value: {
29
+ base: "{colors.neutral.100}",
30
+ _dark: "{colors.neutral.900}"
31
+ }
32
+ },
33
+ "text-alert": {
34
+ value: { base: "{colors.red.600}", _dark: "{colors.red.400}" }
35
+ },
36
+ "input-border-color": {
37
+ value: {
38
+ base: "{colors.neutral.300}",
39
+ _dark: "{colors.neutral.600}"
40
+ }
41
+ },
42
+ "input-border-color-error": {
43
+ value: { base: "{colors.red.400}", _dark: "{colors.red.400}" }
44
+ },
45
+ "input-outline-color-error": {
46
+ value: { base: "{colors.red.500}", _dark: "{colors.red.500}" }
47
+ },
48
+ "input-label-color": {
49
+ value: {
50
+ base: "{colors.neutral.400}",
51
+ _dark: "{colors.neutral.400}"
52
+ }
53
+ },
54
+ "input-label-color-lifted": {
55
+ value: { base: "{colors.blue.500}", _dark: "{colors.blue.500}" }
56
+ },
57
+ "input-label-bg": {
58
+ value: {
59
+ base: "{colors.neutral.100}",
60
+ _dark: "{colors.neutral.800}"
61
+ }
62
+ }
63
+ }
64
+ },
65
+ extend: {
66
+ breakpoints: { xs: "600px" },
67
+ keyframes: {
68
+ spin: {
69
+ from: { transform: "rotate(0deg)" },
70
+ to: { transform: "rotate(360deg)" }
71
+ },
72
+ sheen: {
73
+ from: { backgroundPositionX: "200%" },
74
+ to: { backgroundPositionX: "-200%" }
75
+ },
76
+ pulse: {
77
+ "0%": { transform: "scale(1, 1)" },
78
+ "50%": { opacity: 0.3 },
79
+ "100%": { transform: "scale(1.3)", opacity: 0 }
80
+ }
81
+ }
82
+ }
83
+ },
84
+ conditions: {
85
+ extend: {
86
+ dark: "[data-theme=dark] &",
87
+ activeMouse: "&:active:not(:focus-visible):not(:disabled)",
88
+ activeKeyboard: "&:active:focus-visible:not(:disabled)",
89
+ active: "&:active:not(:disabled), &:active:not(:focus-visible):not(:disabled), &:active:focus-visible:not(:disabled)",
90
+ hover: "&:hover:not(:disabled)",
91
+ checkbox: "& [data-checkbox]",
92
+ radioLabel: "& [data-radio-label]",
93
+ radioDisabled: "& :is(:disabled, [disabled], [data-disabled], [aria-disabled=true])",
94
+ radioSelected: "& :is([aria-selected=true], [data-selected])",
95
+ radioCircleOuter: "& [data-radio-outer]",
96
+ radioCircleInner: "& [data-radio-inner]",
97
+ radioFocusRing: "& [data-radio-focusring]",
98
+ backdrop: "[data-backdrop]:has(> &)",
99
+ path: "& path",
100
+ svg: "& svg"
101
+ }
102
+ },
103
+ utilities: {
104
+ rounded: {
105
+ values: { type: "boolean | number" },
106
+ transform(value) {
107
+ return { borderRadius: typeof value === "boolean" ? 9999 : value };
108
+ }
109
+ },
110
+ extend: {
111
+ grid: {
112
+ values: { type: "boolean" },
113
+ transform() {
114
+ return { display: "grid" };
115
+ }
116
+ },
117
+ flex: {
118
+ values: { type: "boolean" },
119
+ transform(value) {
120
+ return {
121
+ display: "flex",
122
+ ...typeof value === "string" && { flexWrap: value }
123
+ };
124
+ }
125
+ },
126
+ center: {
127
+ values: { type: "boolean" },
128
+ transform() {
129
+ return { placeContent: "center", placeItems: "center" };
130
+ }
131
+ },
132
+ relative: {
133
+ values: { type: "boolean" },
134
+ transform() {
135
+ return { position: "relative" };
136
+ }
137
+ },
138
+ absolute: {
139
+ values: { type: "boolean" },
140
+ transform() {
141
+ return { position: "absolute" };
142
+ }
143
+ },
144
+ fixed: {
145
+ values: { type: "boolean" },
146
+ transform() {
147
+ return { position: "fixed" };
148
+ }
149
+ },
150
+ sticky: {
151
+ values: { type: "boolean" },
152
+ transform() {
153
+ return { position: "sticky" };
154
+ }
155
+ },
156
+ // use br for numbers
157
+ borderRadius: {
158
+ className: "rounded",
159
+ shorthand: "br",
160
+ values: { type: "boolean | number" },
161
+ transform(value) {
162
+ return { borderRadius: typeof value === "boolean" ? 9999 : value };
163
+ }
164
+ },
165
+ size: {
166
+ values: { type: "number" },
167
+ transform(value) {
168
+ return { width: value, height: value };
169
+ }
170
+ },
171
+ pointer: {
172
+ values: { type: "boolean" },
173
+ transform() {
174
+ return { cursor: "pointer" };
175
+ }
176
+ },
177
+ strokeColor: {
178
+ values: "colors",
179
+ transform(value) {
180
+ return { "&, & path": { stroke: value } };
181
+ }
182
+ },
183
+ strokeWidth: {
184
+ values: { type: "number" },
185
+ transform(value) {
186
+ return { "&, & path": { strokeWidth: value } };
187
+ }
188
+ },
189
+ debug: {
190
+ values: { type: "boolean" },
191
+ transform(value) {
192
+ if (value === true) return { border: "1px solid red" };
193
+ if (typeof value === "string") {
194
+ const parts = value.trim().split(/\s+/);
195
+ let borderWidth = "1px", borderStyle = "solid", borderColor = "red";
196
+ parts.forEach((part) => {
197
+ if (/^\d+(\.\d+)?(px|em|rem|%|pt|pc|in|cm|mm|ex|ch|vw|vh|vmin|vmax)$/.test(
198
+ part
199
+ ))
200
+ borderWidth = part;
201
+ else if (/^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/.test(
202
+ part
203
+ ))
204
+ borderStyle = part;
205
+ else borderColor = part;
206
+ });
207
+ const isKeyword = /^(currentColor|transparent|inherit|initial|unset|revert)$/i.test(
208
+ borderColor
209
+ );
210
+ const isHex = /^#/.test(borderColor);
211
+ const isFunc = /^(rgb|rgba|hsl|hsla|lab|lch|oklab|oklch|color)\(/i.test(
212
+ borderColor
213
+ );
214
+ const isVarRef = /^var\(/.test(borderColor);
215
+ const looksLikeScaleToken = /^[a-zA-Z][\w-]*\.\d{2,3}$/.test(
216
+ borderColor
217
+ );
218
+ const looksLikeSemanticToken = /^[a-zA-Z][\w-]*-[\w-]+$/.test(
219
+ borderColor
220
+ );
221
+ const shouldWrap = !isKeyword && !isHex && !isFunc && !isVarRef && (looksLikeScaleToken || looksLikeSemanticToken);
222
+ const normalizedBorderColor = shouldWrap ? `var(--colors-${borderColor.replace(/\./g, "-")})` : borderColor;
223
+ return {
224
+ borderWidth,
225
+ borderStyle,
226
+ borderColor: normalizedBorderColor
227
+ };
228
+ }
229
+ return { border: "1px solid red" };
230
+ }
231
+ },
232
+ cols: {
233
+ transform(value) {
234
+ if (typeof value !== "string") return {};
235
+ const [templatePart, gapPart] = value.split("/").map((s) => s.trim());
236
+ const templateWords = templatePart.split(/\s+/);
237
+ let alignContent = "", gridTemplate = "", columnGap = "";
238
+ const alignmentValues = ["start", "center", "end"];
239
+ if (alignmentValues.includes(templateWords[0])) {
240
+ alignContent = templateWords[0];
241
+ if (templateWords.length > 1)
242
+ gridTemplate = templateWords.slice(1).join(" ");
243
+ } else gridTemplate = templateWords.join(" ");
244
+ if (gridTemplate) {
245
+ gridTemplate = gridTemplate.split(/\s+/).map((part) => {
246
+ if (/^\d+$/.test(part)) return `${part}fr`;
247
+ if (part === "m" || part === "mx") return "max-content";
248
+ return part;
249
+ }).join(" ");
250
+ }
251
+ if (gapPart) {
252
+ const gapValue = gapPart.trim();
253
+ columnGap = /^\d+$/.test(gapValue) ? `${gapValue}px` : gapValue;
254
+ }
255
+ const result = {};
256
+ if (alignContent) {
257
+ result.alignContent = alignContent;
258
+ result.alignItems = alignContent;
259
+ }
260
+ if (gridTemplate) result.gridTemplateColumns = gridTemplate;
261
+ if (columnGap) result.columnGap = columnGap;
262
+ return result;
263
+ }
264
+ },
265
+ rows: {
266
+ transform(value) {
267
+ if (typeof value !== "string") return {};
268
+ const [templatePart, gapPart] = value.split("/").map((s) => s.trim());
269
+ const templateWords = templatePart.split(/\s+/);
270
+ let justifyContent = "", gridTemplate = "", rowGap = "";
271
+ const justifyValues = ["start", "end", "between", "center"];
272
+ const justifyValue = justifyValues.includes(templateWords[0]) ? templateWords[0] : "";
273
+ if (justifyValue) {
274
+ justifyContent = justifyValue === "between" ? "space-between" : justifyValue;
275
+ if (templateWords.length > 1)
276
+ gridTemplate = templateWords.slice(1).join(" ");
277
+ } else gridTemplate = templateWords.join(" ");
278
+ if (gridTemplate) {
279
+ gridTemplate = gridTemplate.split(/\s+/).map((part) => {
280
+ if (/^\d+$/.test(part)) return `${part}fr`;
281
+ if (part === "m" || part === "mx") return "max-content";
282
+ return part;
283
+ }).join(" ");
284
+ }
285
+ if (gapPart) {
286
+ const gapValue = gapPart.trim();
287
+ rowGap = /^\d+$/.test(gapValue) ? `${gapValue}px` : gapValue;
288
+ }
289
+ const result = {};
290
+ if (justifyContent) {
291
+ result.justifyContent = justifyContent;
292
+ result.justifyItems = justifyContent;
293
+ }
294
+ if (gridTemplate) result.gridTemplateRows = gridTemplate;
295
+ if (rowGap) result.rowGap = rowGap;
296
+ return result;
297
+ }
298
+ },
299
+ gridAutoColumns: {
300
+ shorthand: "autoCols",
301
+ values: { type: "boolean" },
302
+ transform(value) {
303
+ return {
304
+ gridAutoFlow: "column",
305
+ gridAutoColumns: value === true ? "max-content" : value
306
+ };
307
+ }
308
+ },
309
+ placeI: {
310
+ values: { type: "boolean" },
311
+ transform(value) {
312
+ return { placeItems: value === true ? "center" : value };
313
+ }
314
+ },
315
+ placeC: {
316
+ values: { type: "boolean" },
317
+ transform(value) {
318
+ return { placeContent: value === true ? "center" : value };
319
+ }
320
+ },
321
+ placeS: {
322
+ values: { type: "boolean" },
323
+ transform(value) {
324
+ return { placeSelf: value === true ? "center" : value };
325
+ }
326
+ },
327
+ alignI: {
328
+ values: { type: "boolean" },
329
+ transform(value) {
330
+ return { alignItems: value === true ? "center" : value };
331
+ }
332
+ },
333
+ alignC: {
334
+ property: "alignContent",
335
+ values: { type: "boolean" },
336
+ transform(value) {
337
+ return { alignContent: value === true ? "center" : value };
338
+ }
339
+ },
340
+ alignS: {
341
+ values: { type: "boolean" },
342
+ transform(value) {
343
+ return { alignSelf: value === true ? "center" : value };
344
+ }
345
+ },
346
+ justifyI: {
347
+ values: { type: "boolean" },
348
+ transform(value) {
349
+ return { justifyItems: value === true ? "center" : value };
350
+ }
351
+ },
352
+ justifyC: {
353
+ values: { type: "boolean" },
354
+ transform(value) {
355
+ return { justifyContent: value === true ? "center" : value };
356
+ }
357
+ },
358
+ justifyS: {
359
+ values: { type: "boolean" },
360
+ transform(value) {
361
+ return { justifySelf: value === true ? "center" : value };
362
+ }
363
+ },
364
+ colN: {
365
+ values: { type: "number" },
366
+ transform(value) {
367
+ return { gridColumn: value };
368
+ }
369
+ },
370
+ spaceBetween: {
371
+ values: { type: "true" },
372
+ transform() {
373
+ return { justifyContent: "space-between" };
374
+ }
375
+ },
376
+ rowN: {
377
+ values: { type: "number" },
378
+ transform(value) {
379
+ return { gridRow: value };
380
+ }
381
+ },
382
+ columnGap: {
383
+ shorthand: "colG",
384
+ values: { type: "number" },
385
+ transform(value) {
386
+ return { columnGap: value };
387
+ }
388
+ },
389
+ gridColumnStart: {
390
+ shorthand: "colStart",
391
+ values: { type: "number" },
392
+ transform(value) {
393
+ return { gridColumnStart: value };
394
+ }
395
+ },
396
+ gridColumnEnd: {
397
+ shorthand: "colEnd",
398
+ values: { type: "number" },
399
+ transform(value) {
400
+ return { gridColumnEnd: value };
401
+ }
402
+ },
403
+ gridRowStart: {
404
+ shorthand: "rowStart",
405
+ values: { type: "number" },
406
+ transform(value) {
407
+ return { gridRowStart: value };
408
+ }
409
+ },
410
+ gridRowEnd: {
411
+ shorthand: "rowEnd",
412
+ values: { type: "number" },
413
+ transform(value) {
414
+ return { gridRowEnd: value };
415
+ }
416
+ },
417
+ rowGap: {
418
+ shorthand: "rowG",
419
+ values: { type: "number" },
420
+ transform(value) {
421
+ return { rowGap: value };
422
+ }
423
+ },
424
+ position: {
425
+ shorthand: "pos",
426
+ transform(value) {
427
+ return { position: value };
428
+ }
429
+ },
430
+ height: {
431
+ shorthand: "h",
432
+ values: { type: "boolean" },
433
+ transform(value) {
434
+ return { height: value === true ? "100%" : value };
435
+ }
436
+ },
437
+ width: {
438
+ shorthand: "w",
439
+ values: { type: "boolean" },
440
+ transform(value) {
441
+ return { width: value === true ? "100%" : value };
442
+ }
443
+ },
444
+ mr: {
445
+ transform(value) {
446
+ return { marginRight: value };
447
+ }
448
+ },
449
+ border: {
450
+ values: { type: "boolean" },
451
+ transform(value) {
452
+ return { border: value === true ? "1px solid red" : value };
453
+ }
454
+ },
455
+ ar: {
456
+ values: { type: "boolean" },
457
+ transform(value) {
458
+ return { aspectRatio: value === true ? 1 : value };
459
+ }
460
+ },
461
+ aspectRatio: {
462
+ shorthand: "ar",
463
+ values: { type: "boolean" },
464
+ transform(value) {
465
+ return { aspectRatio: value === true ? 1 : value };
466
+ }
467
+ }
468
+ }
469
+ }
470
+ };
471
+ var preset_default = preset;
472
+
473
+ export { preset_default as default };