@povio/ui 5.0.0-rc.7 → 5.0.0-rc.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/dist/Button-BPTvffuk.js +86 -0
- package/dist/{Calendar-BTjajO6i.js → Calendar-BxtOuqIM.js} +3 -3
- package/dist/{Checkbox-CV1ILXXO.js → Checkbox-DYxXYfKL.js} +3 -2
- package/dist/CheckboxCheckmark-D_uc9pon.js +44 -0
- package/dist/{ComponentGallery-Dp0kZVZM.js → ComponentGallery-Da70Y4_Q.js} +17 -17
- package/dist/{DatePicker-DOLL7mkc.js → DatePicker-wulRNGyL.js} +6 -6
- package/dist/{DatePickerInput-BLBcySA2.js → DatePickerInput-BB_vPlKu.js} +3 -3
- package/dist/{DateRangePicker-BF-1CztH.js → DateRangePicker-B0tMVREG.js} +6 -6
- package/dist/{DateTimePicker-Cj0qvJUz.js → DateTimePicker-WGMr0bEH.js} +6 -6
- package/dist/{FileInput-Br5DQaGQ.js → FileInput-DP105Iy9.js} +2 -2
- package/dist/{FileUpload--7ub3EZO.js → FileUpload-CgNDIvzg.js} +3 -3
- package/dist/{Form-BJ12MjE-.d.ts → Form-DbEWnCKc.d.ts} +1 -1
- package/dist/{FormField-B99dLt8o.js → FormField-AY25LzbW.js} +3 -96
- package/dist/{FormFieldError-DeOHHLo2.js → FormFieldError-BVAO5p7H.js} +2 -13
- package/dist/{InputItem-CIxbTxZu.js → InputItem-ZeN-aIz8.js} +11 -11
- package/dist/{Inputs-DJSKiaWY.js → Inputs-BC5q5Cvj.js} +1 -1
- package/dist/{Inputs-DA73LmLc.d.ts → Inputs-O84btFJL.d.ts} +1 -1
- package/dist/{NumberRangeInput-B8-LHfg3.js → NumberRangeInput-B_sMIpP1.js} +2 -2
- package/dist/{PaginationList-DtvuP63b.js → PaginationList-DptMNpNs.js} +1 -1
- package/dist/{Progress-B3mY9rIP.js → Progress-Du30L4_s.js} +2 -27
- package/dist/{RadioGroup-DOw3PRoX.js → RadioGroup-CUGNSJql.js} +3 -82
- package/dist/{RichTextEditor-D4yN7Wj7.js → RichTextEditor-VDOpj7sk.js} +3 -3
- package/dist/{Select-UR0ec2Ux.js → Select-B2pAfwRk.js} +2 -2
- package/dist/{Slider-CzEmKYBF.js → Slider-Clc1szFY.js} +1 -1
- package/dist/{Switch-CqnGEdeD.js → Switch-CimmMqEk.js} +3 -27
- package/dist/{Table-BN2_J_Ne.js → Table-CqepqSfe.js} +2 -1
- package/dist/{TextArea-D8WkKsGn.js → TextArea-B3teIhsJ.js} +3 -5
- package/dist/TextArea.cva-Bb73hriz.js +5 -0
- package/dist/{TimePicker-C4taAOFQ.js → TimePicker-CU_yL2sY.js} +4 -4
- package/dist/{Toast-DtG3pA61.js → Toast-DPbnLlBi.js} +1 -1
- package/dist/{ToggleGroup-DOk27fgI.js → ToggleGroup-BULVwErp.js} +1 -1
- package/dist/{Button-C5rv4Cr2.js → button.cva-rv5Uq4aW.js} +1 -84
- package/dist/{CheckboxCheckmark-CpC3wlMs.js → checkbox.cva-IfOByVLA.js} +1 -42
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/alert.js +116 -1
- package/dist/components/autocomplete.js +2 -2
- package/dist/components/button.js +1 -1
- package/dist/components/checkbox-group.js +3 -3
- package/dist/components/checkbox.js +1 -1
- package/dist/components/date-picker.js +1 -1
- package/dist/components/date-range-picker.js +1 -1
- package/dist/components/date-time-picker.js +1 -1
- package/dist/components/file-input.js +1 -1
- package/dist/components/file-upload-container.js +1 -1
- package/dist/components/file-upload.js +1 -1
- package/dist/components/form-field.js +1 -1
- package/dist/components/icon-button.js +1 -1
- package/dist/components/inline-icon-button.js +1 -1
- package/dist/components/input.js +3 -3
- package/dist/components/number-field.js +3 -3
- package/dist/components/number-range-input.js +1 -1
- package/dist/components/pagination-list.js +1 -1
- package/dist/components/pagination.js +1 -1
- package/dist/components/progress.js +1 -1
- package/dist/components/query-autocomplete.js +1 -1
- package/dist/components/query-select.js +2 -2
- package/dist/components/radio-group.js +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/slider.js +1 -1
- package/dist/components/split-button.js +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/tag.js +93 -1
- package/dist/components/text-area.js +1 -1
- package/dist/components/text-button.js +1 -1
- package/dist/components/time-picker.js +1 -1
- package/dist/components/toast.js +1 -1
- package/dist/components/toggle-button.js +1 -1
- package/dist/components/toggle-group.js +1 -1
- package/dist/components/use-toast.js +2 -2
- package/dist/config/app-canvas.d.ts +79 -0
- package/dist/config/app-canvas.js +2253 -0
- package/dist/config/ui-config.d.ts +1 -1
- package/dist/config/ui-configurator.d.ts +1 -920
- package/dist/config/ui-configurator.js +127 -1174
- package/dist/configuration.context-f_FSPWhQ.d.ts +926 -0
- package/dist/{datePickerValue.utils-DCgoSrP3.js → datePickerValue.utils-CIFHjKwv.js} +1 -1
- package/dist/{dynamicInputs-iP39lVKf.d.ts → dynamicInputs-ByVMnx4Z.d.ts} +1 -1
- package/dist/formFieldError.cva-CsXaQRHX.js +14 -0
- package/dist/formFieldHelper.cva-B8F9LmsE.js +96 -0
- package/dist/grip-vertical-BVxcjdfr.js +54 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +24 -19
- package/dist/inspection-model-LuI36xTg.js +1339 -0
- package/dist/progress.cva-WQB8BGbk.js +28 -0
- package/dist/radio.cva-DGbvTymp.js +82 -0
- package/dist/rhf/checkbox.js +1 -1
- package/dist/rhf/date-picker.js +1 -1
- package/dist/rhf/date-range-picker.js +1 -1
- package/dist/rhf/date-time-picker.js +1 -1
- package/dist/rhf/file-input.js +1 -1
- package/dist/rhf/file-upload.js +1 -1
- package/dist/rhf/inputs.d.ts +1 -1
- package/dist/rhf/number-range-input.js +1 -1
- package/dist/rhf/radio-group.js +1 -1
- package/dist/rhf/rich-text-editor.js +1 -1
- package/dist/rhf/select.js +1 -1
- package/dist/rhf/slider.js +1 -1
- package/dist/rhf/switch.js +1 -1
- package/dist/rhf/text-area.js +1 -1
- package/dist/rhf/time-picker.js +1 -1
- package/dist/rhf/toggle-group.js +1 -1
- package/dist/rhf.d.ts +2 -2
- package/dist/rhf.js +24 -19
- package/dist/rich-text-editor.js +1 -1
- package/dist/{staticDateTimeSegments-DtU63_dw.js → staticDateTimeSegments-sf_ND7zL.js} +1 -1
- package/dist/{staticSelect.utils-uHa8f_c6.js → staticSelect.utils-CzlnLPPd.js} +3 -3
- package/dist/status.cva-6HxNR4EP.js +130 -0
- package/dist/styles/app-canvas.css +733 -0
- package/dist/styles/configurator.css +19 -5
- package/dist/switch.cva-BX3HOxbL.js +27 -0
- package/dist/{table.cva-D5oQ-QvA.js → table.cva-DlMT-zLD.js} +1 -54
- package/dist/{Tag-DPg5sL1Z.js → tag.cva-B3MudLeC.js} +1 -92
- package/dist/tanstack/checkbox.js +1 -1
- package/dist/tanstack/date-picker.js +1 -1
- package/dist/tanstack/date-range-picker.js +1 -1
- package/dist/tanstack/date-time-picker.js +1 -1
- package/dist/tanstack/file-input.js +1 -1
- package/dist/tanstack/file-upload.js +1 -1
- package/dist/tanstack/form.d.ts +1 -1
- package/dist/tanstack/form.js +1 -1
- package/dist/tanstack/inputs.d.ts +2 -2
- package/dist/tanstack/inputs.js +1 -1
- package/dist/tanstack/number-range-input.js +1 -1
- package/dist/tanstack/radio-group.js +1 -1
- package/dist/tanstack/rich-text-editor.js +1 -1
- package/dist/tanstack/select.js +1 -1
- package/dist/tanstack/slider.js +1 -1
- package/dist/tanstack/switch.js +1 -1
- package/dist/tanstack/table.js +2 -2
- package/dist/tanstack/text-area.js +1 -1
- package/dist/tanstack/time-picker.js +1 -1
- package/dist/tanstack/toggle-group.js +1 -1
- package/dist/tanstack.d.ts +4 -4
- package/dist/tanstack.js +39 -31
- package/dist/{toast.runtime-cxex9e4E.js → toast.runtime-Zf-XyAC3.js} +1 -1
- package/dist/{useFieldAccessibility-ScC6Mtd5.js → useFieldAccessibility-CcBTgGfm.js} +1 -1
- package/dist/{useFormAutosave-DfuP7drj.js → useFormAutosave-BD_TFqDF.js} +1 -1
- package/dist/{useStaticInputHandoff-NeZVnci-.js → useStaticInputHandoff-kkQrc6DA.js} +1 -1
- package/dist/{useTableColumnConfig-Di0_w80v.js → useTableColumnConfig-aVUWC2Mp.js} +2 -2
- package/package.json +7 -1
- package/dist/Alert-CnvEb1D_.js +0 -244
- package/dist/token-classes-Bfcx0get.js +0 -163
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@povio/ui",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -296,6 +296,11 @@
|
|
|
296
296
|
"import": "./dist/config/ui-configurator.js",
|
|
297
297
|
"default": "./dist/config/ui-configurator.js"
|
|
298
298
|
},
|
|
299
|
+
"./app-canvas": {
|
|
300
|
+
"types": "./dist/config/app-canvas.d.ts",
|
|
301
|
+
"import": "./dist/config/app-canvas.js",
|
|
302
|
+
"default": "./dist/config/app-canvas.js"
|
|
303
|
+
},
|
|
299
304
|
"./ui-configurator/vite": {
|
|
300
305
|
"types": "./dist/config/ui-configurator-vite.d.ts",
|
|
301
306
|
"import": "./dist/config/ui-configurator-vite.js",
|
|
@@ -1328,6 +1333,7 @@
|
|
|
1328
1333
|
},
|
|
1329
1334
|
"./rich-text-editor/styles": "./dist/styles/editor.css",
|
|
1330
1335
|
"./ui-configurator/styles": "./dist/styles/configurator.css",
|
|
1336
|
+
"./app-canvas/styles": "./dist/styles/app-canvas.css",
|
|
1331
1337
|
"./color-utilities": "./dist/styles/color-utilities.css",
|
|
1332
1338
|
"./tw-ui-plugin": {
|
|
1333
1339
|
"types": "./dist/tw-ui-plugin.d.ts",
|
package/dist/Alert-CnvEb1D_.js
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { t as UIOverrides } from "./uiOverrides.context-BTCH9y5a.js";
|
|
2
|
-
import { t as IconSlot } from "./IconSlot-DSK7qNxc.js";
|
|
3
|
-
import { t as Typography } from "./Typography-LU4z2pR1.js";
|
|
4
|
-
import { t as Spinner } from "./Spinner-BeVTUzzx.js";
|
|
5
|
-
import { c } from "react/compiler-runtime";
|
|
6
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
//#region src/components/status/Alert/alert.cva.ts
|
|
8
|
-
const alertDefinition = UIOverrides.defineConfig({
|
|
9
|
-
base: ["min-h-0 overflow-hidden rounded-alert-rounding-default p-0 shadow-4"],
|
|
10
|
-
config: {
|
|
11
|
-
variants: {
|
|
12
|
-
variant: {
|
|
13
|
-
outlined: "border bg-surface-default-card text-surface-default-card-foreground",
|
|
14
|
-
contained: ""
|
|
15
|
-
},
|
|
16
|
-
color: {
|
|
17
|
-
neutral: "",
|
|
18
|
-
success: "",
|
|
19
|
-
warning: "",
|
|
20
|
-
error: ""
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
compoundVariants: [
|
|
24
|
-
{
|
|
25
|
-
variant: "outlined",
|
|
26
|
-
color: "neutral",
|
|
27
|
-
className: "border-border-default-subtle"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
variant: "outlined",
|
|
31
|
-
color: "success",
|
|
32
|
-
className: "border-surface-success-base"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
variant: "outlined",
|
|
36
|
-
color: "warning",
|
|
37
|
-
className: "border-surface-warning-base"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
variant: "outlined",
|
|
41
|
-
color: "error",
|
|
42
|
-
className: "border-border-destructive-base"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
variant: "contained",
|
|
46
|
-
color: "neutral",
|
|
47
|
-
className: "bg-surface-inverted-card text-surface-inverted-card-foreground"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
variant: "contained",
|
|
51
|
-
color: "success",
|
|
52
|
-
className: "bg-surface-success-base text-surface-success-inverted-base"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
variant: "contained",
|
|
56
|
-
color: "warning",
|
|
57
|
-
className: "bg-surface-warning-base text-surface-warning-inverted-base"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
variant: "contained",
|
|
61
|
-
color: "error",
|
|
62
|
-
className: "bg-surface-destructive-base text-surface-destructive-inverted-base"
|
|
63
|
-
}
|
|
64
|
-
],
|
|
65
|
-
defaultVariants: {
|
|
66
|
-
variant: "outlined",
|
|
67
|
-
color: "neutral"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/components/status/shared/status.cva.ts
|
|
73
|
-
const statusIconDefinition = UIOverrides.defineConfig({
|
|
74
|
-
base: ["size-icons-size shrink-0"],
|
|
75
|
-
config: {
|
|
76
|
-
variants: {
|
|
77
|
-
variant: {
|
|
78
|
-
outlined: "",
|
|
79
|
-
contained: "text-inherit"
|
|
80
|
-
},
|
|
81
|
-
color: {
|
|
82
|
-
neutral: "",
|
|
83
|
-
success: "",
|
|
84
|
-
warning: "",
|
|
85
|
-
error: ""
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
compoundVariants: [
|
|
89
|
-
{
|
|
90
|
-
variant: "outlined",
|
|
91
|
-
color: "neutral",
|
|
92
|
-
class: "text-surface-default-foreground"
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
variant: "outlined",
|
|
96
|
-
color: "success",
|
|
97
|
-
class: "text-surface-success-base"
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
variant: "outlined",
|
|
101
|
-
color: "warning",
|
|
102
|
-
class: "text-surface-warning-base"
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
variant: "outlined",
|
|
106
|
-
color: "error",
|
|
107
|
-
class: "text-surface-destructive-base"
|
|
108
|
-
}
|
|
109
|
-
],
|
|
110
|
-
defaultVariants: {
|
|
111
|
-
variant: "outlined",
|
|
112
|
-
color: "neutral"
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
const statusSeparatorDefinition = UIOverrides.defineConfig({
|
|
117
|
-
base: ["h-px shrink-0 self-stretch md:h-auto md:w-px"],
|
|
118
|
-
config: {
|
|
119
|
-
variants: {
|
|
120
|
-
variant: {
|
|
121
|
-
outlined: "",
|
|
122
|
-
contained: "hidden"
|
|
123
|
-
},
|
|
124
|
-
color: {
|
|
125
|
-
neutral: "bg-border-default-subtle",
|
|
126
|
-
success: "bg-surface-success-base",
|
|
127
|
-
warning: "bg-surface-warning-base",
|
|
128
|
-
error: "bg-surface-destructive-base"
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
defaultVariants: { color: "neutral" }
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/components/status/Alert/Alert.tsx
|
|
136
|
-
const Alert = (t0) => {
|
|
137
|
-
const $ = c(31);
|
|
138
|
-
const { variant, color, text, isLoading: t1, rightContent, hasSeparator, icon: Icon, className } = t0;
|
|
139
|
-
const isLoading = t1 === void 0 ? false : t1;
|
|
140
|
-
const alertCva = UIOverrides.useCva("alert.cva", alertDefinition);
|
|
141
|
-
const iconCva = UIOverrides.useCva("status.iconCva", statusIconDefinition);
|
|
142
|
-
const separatorCva = UIOverrides.useCva("status.separatorCva", statusSeparatorDefinition);
|
|
143
|
-
let t2;
|
|
144
|
-
if ($[0] !== alertCva || $[1] !== className || $[2] !== color || $[3] !== variant) {
|
|
145
|
-
t2 = alertCva({
|
|
146
|
-
variant,
|
|
147
|
-
color,
|
|
148
|
-
className
|
|
149
|
-
});
|
|
150
|
-
$[0] = alertCva;
|
|
151
|
-
$[1] = className;
|
|
152
|
-
$[2] = color;
|
|
153
|
-
$[3] = variant;
|
|
154
|
-
$[4] = t2;
|
|
155
|
-
} else t2 = $[4];
|
|
156
|
-
let t3;
|
|
157
|
-
if ($[5] !== isLoading) {
|
|
158
|
-
t3 = isLoading && /* @__PURE__ */ jsx(Spinner, {
|
|
159
|
-
size: "default",
|
|
160
|
-
className: "shrink-0"
|
|
161
|
-
});
|
|
162
|
-
$[5] = isLoading;
|
|
163
|
-
$[6] = t3;
|
|
164
|
-
} else t3 = $[6];
|
|
165
|
-
let t4;
|
|
166
|
-
if ($[7] !== Icon || $[8] !== color || $[9] !== iconCva || $[10] !== isLoading || $[11] !== variant) {
|
|
167
|
-
t4 = !isLoading && Icon && /* @__PURE__ */ jsx(IconSlot, {
|
|
168
|
-
icon: Icon,
|
|
169
|
-
className: iconCva({
|
|
170
|
-
variant,
|
|
171
|
-
color
|
|
172
|
-
})
|
|
173
|
-
});
|
|
174
|
-
$[7] = Icon;
|
|
175
|
-
$[8] = color;
|
|
176
|
-
$[9] = iconCva;
|
|
177
|
-
$[10] = isLoading;
|
|
178
|
-
$[11] = variant;
|
|
179
|
-
$[12] = t4;
|
|
180
|
-
} else t4 = $[12];
|
|
181
|
-
let t5;
|
|
182
|
-
if ($[13] !== text) {
|
|
183
|
-
t5 = /* @__PURE__ */ jsx(Typography, {
|
|
184
|
-
size: "large",
|
|
185
|
-
children: text
|
|
186
|
-
});
|
|
187
|
-
$[13] = text;
|
|
188
|
-
$[14] = t5;
|
|
189
|
-
} else t5 = $[14];
|
|
190
|
-
let t6;
|
|
191
|
-
if ($[15] !== t3 || $[16] !== t4 || $[17] !== t5) {
|
|
192
|
-
t6 = /* @__PURE__ */ jsxs("div", {
|
|
193
|
-
className: "flex w-full items-start gap-alert-gap-icon-to-text px-alert-side-default py-alert-height-content",
|
|
194
|
-
children: [
|
|
195
|
-
t3,
|
|
196
|
-
t4,
|
|
197
|
-
t5
|
|
198
|
-
]
|
|
199
|
-
});
|
|
200
|
-
$[15] = t3;
|
|
201
|
-
$[16] = t4;
|
|
202
|
-
$[17] = t5;
|
|
203
|
-
$[18] = t6;
|
|
204
|
-
} else t6 = $[18];
|
|
205
|
-
let t7;
|
|
206
|
-
if ($[19] !== color || $[20] !== hasSeparator || $[21] !== rightContent || $[22] !== separatorCva || $[23] !== variant) {
|
|
207
|
-
t7 = !!rightContent && /* @__PURE__ */ jsxs(Fragment, { children: [hasSeparator && /* @__PURE__ */ jsx("div", { className: separatorCva({
|
|
208
|
-
variant,
|
|
209
|
-
color
|
|
210
|
-
}) }), /* @__PURE__ */ jsx("div", {
|
|
211
|
-
className: "flex w-full shrink-0 flex-wrap items-center justify-end gap-toast-gap-action px-alert-side-default py-alert-height-actions-mobile md:w-auto md:justify-center md:py-alert-height-actions-desktop",
|
|
212
|
-
children: rightContent
|
|
213
|
-
})] });
|
|
214
|
-
$[19] = color;
|
|
215
|
-
$[20] = hasSeparator;
|
|
216
|
-
$[21] = rightContent;
|
|
217
|
-
$[22] = separatorCva;
|
|
218
|
-
$[23] = variant;
|
|
219
|
-
$[24] = t7;
|
|
220
|
-
} else t7 = $[24];
|
|
221
|
-
let t8;
|
|
222
|
-
if ($[25] !== t6 || $[26] !== t7) {
|
|
223
|
-
t8 = /* @__PURE__ */ jsxs("div", {
|
|
224
|
-
className: "flex w-auto flex-col items-center md:flex-row",
|
|
225
|
-
children: [t6, t7]
|
|
226
|
-
});
|
|
227
|
-
$[25] = t6;
|
|
228
|
-
$[26] = t7;
|
|
229
|
-
$[27] = t8;
|
|
230
|
-
} else t8 = $[27];
|
|
231
|
-
let t9;
|
|
232
|
-
if ($[28] !== t2 || $[29] !== t8) {
|
|
233
|
-
t9 = /* @__PURE__ */ jsx("div", {
|
|
234
|
-
className: t2,
|
|
235
|
-
children: t8
|
|
236
|
-
});
|
|
237
|
-
$[28] = t2;
|
|
238
|
-
$[29] = t8;
|
|
239
|
-
$[30] = t9;
|
|
240
|
-
} else t9 = $[30];
|
|
241
|
-
return t9;
|
|
242
|
-
};
|
|
243
|
-
//#endregion
|
|
244
|
-
export { alertDefinition as i, statusIconDefinition as n, statusSeparatorDefinition as r, Alert as t };
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
//#region src/configurator/inspector/token-classes.ts
|
|
2
|
-
/** Tailwind breakpoints from the Atlas base theme, in rem. */
|
|
3
|
-
const breakpoints = {
|
|
4
|
-
sm: 23.75,
|
|
5
|
-
md: 37.5,
|
|
6
|
-
lg: 80,
|
|
7
|
-
xl: 105
|
|
8
|
-
};
|
|
9
|
-
/** Utility prefix → the slots it sets, its specificity, and the theme namespace its value lives in. */
|
|
10
|
-
const utilities = [
|
|
11
|
-
[
|
|
12
|
-
"p",
|
|
13
|
-
[
|
|
14
|
-
"padding.top",
|
|
15
|
-
"padding.right",
|
|
16
|
-
"padding.bottom",
|
|
17
|
-
"padding.left"
|
|
18
|
-
],
|
|
19
|
-
0,
|
|
20
|
-
"spacing"
|
|
21
|
-
],
|
|
22
|
-
[
|
|
23
|
-
"px",
|
|
24
|
-
["padding.left", "padding.right"],
|
|
25
|
-
1,
|
|
26
|
-
"spacing"
|
|
27
|
-
],
|
|
28
|
-
[
|
|
29
|
-
"py",
|
|
30
|
-
["padding.top", "padding.bottom"],
|
|
31
|
-
1,
|
|
32
|
-
"spacing"
|
|
33
|
-
],
|
|
34
|
-
[
|
|
35
|
-
"pt",
|
|
36
|
-
["padding.top"],
|
|
37
|
-
2,
|
|
38
|
-
"spacing"
|
|
39
|
-
],
|
|
40
|
-
[
|
|
41
|
-
"pr",
|
|
42
|
-
["padding.right"],
|
|
43
|
-
2,
|
|
44
|
-
"spacing"
|
|
45
|
-
],
|
|
46
|
-
[
|
|
47
|
-
"pe",
|
|
48
|
-
["padding.right"],
|
|
49
|
-
2,
|
|
50
|
-
"spacing"
|
|
51
|
-
],
|
|
52
|
-
[
|
|
53
|
-
"pb",
|
|
54
|
-
["padding.bottom"],
|
|
55
|
-
2,
|
|
56
|
-
"spacing"
|
|
57
|
-
],
|
|
58
|
-
[
|
|
59
|
-
"pl",
|
|
60
|
-
["padding.left"],
|
|
61
|
-
2,
|
|
62
|
-
"spacing"
|
|
63
|
-
],
|
|
64
|
-
[
|
|
65
|
-
"ps",
|
|
66
|
-
["padding.left"],
|
|
67
|
-
2,
|
|
68
|
-
"spacing"
|
|
69
|
-
],
|
|
70
|
-
[
|
|
71
|
-
"gap",
|
|
72
|
-
["gap.row", "gap.column"],
|
|
73
|
-
0,
|
|
74
|
-
"spacing"
|
|
75
|
-
],
|
|
76
|
-
[
|
|
77
|
-
"gap-x",
|
|
78
|
-
["gap.column"],
|
|
79
|
-
1,
|
|
80
|
-
"spacing"
|
|
81
|
-
],
|
|
82
|
-
[
|
|
83
|
-
"gap-y",
|
|
84
|
-
["gap.row"],
|
|
85
|
-
1,
|
|
86
|
-
"spacing"
|
|
87
|
-
],
|
|
88
|
-
[
|
|
89
|
-
"rounded",
|
|
90
|
-
["radius"],
|
|
91
|
-
0,
|
|
92
|
-
"radius"
|
|
93
|
-
]
|
|
94
|
-
];
|
|
95
|
-
/** Splits `md:hover:px-4` into its variants and utility, ignoring colons inside `[...]` / `(...)`. */
|
|
96
|
-
function splitVariants(className) {
|
|
97
|
-
const parts = [];
|
|
98
|
-
let depth = 0;
|
|
99
|
-
let current = "";
|
|
100
|
-
for (const char of className) {
|
|
101
|
-
if (char === "[" || char === "(") depth++;
|
|
102
|
-
if (char === "]" || char === ")") depth--;
|
|
103
|
-
if (char === ":" && depth === 0) {
|
|
104
|
-
parts.push(current);
|
|
105
|
-
current = "";
|
|
106
|
-
} else current += char;
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
variants: parts,
|
|
110
|
-
utility: current
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
/** Breakpoint weight when every variant is an active breakpoint; `undefined` for state variants or inactive breakpoints. */
|
|
114
|
-
function variantWeight(variants, viewportWidth, rootFontSize) {
|
|
115
|
-
let weight = 0;
|
|
116
|
-
for (const variant of variants) {
|
|
117
|
-
const max = variant.startsWith("max-");
|
|
118
|
-
const size = breakpoints[max ? variant.slice(4) : variant];
|
|
119
|
-
if (size === void 0) return void 0;
|
|
120
|
-
if (!(max ? viewportWidth < size * rootFontSize : viewportWidth >= size * rootFontSize)) return void 0;
|
|
121
|
-
weight = Math.max(weight, size);
|
|
122
|
-
}
|
|
123
|
-
return weight;
|
|
124
|
-
}
|
|
125
|
-
function tokenFor(value, namespace, isKnown) {
|
|
126
|
-
const referenced = value.match(/^\[.*?var\((--[\w-]+)/)?.[1] ?? value.match(/^\((--[\w-]+)\)$/)?.[1];
|
|
127
|
-
if (referenced) return isKnown(referenced) ? referenced : void 0;
|
|
128
|
-
const name = `--${namespace}-${value}`;
|
|
129
|
-
return isKnown(name) ? name : void 0;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Resolves which theme tokens drive an element's padding, gap and radius from its rendered Tailwind classes.
|
|
133
|
-
* Only tokens accepted by `isKnown` are returned, so every result can be opened in the editor.
|
|
134
|
-
*/
|
|
135
|
-
function inspectTokens(className, isKnown, viewportWidth = Infinity, rootFontSize = 16) {
|
|
136
|
-
const winners = /* @__PURE__ */ new Map();
|
|
137
|
-
for (const raw of className.split(/\s+/).filter(Boolean)) {
|
|
138
|
-
const { variants, utility } = splitVariants(raw);
|
|
139
|
-
const weight = variantWeight(variants, viewportWidth, rootFontSize);
|
|
140
|
-
if (weight === void 0) continue;
|
|
141
|
-
const clean = utility.replace(/^!|!$/g, "");
|
|
142
|
-
for (const [prefix, slots, specificity, namespace] of utilities) {
|
|
143
|
-
if (!clean.startsWith(`${prefix}-`)) continue;
|
|
144
|
-
const token = tokenFor(clean.slice(prefix.length + 1), namespace, isKnown);
|
|
145
|
-
if (!token) continue;
|
|
146
|
-
const rank = weight * 10 + specificity;
|
|
147
|
-
for (const slot of slots) if ((winners.get(slot)?.rank ?? -1) <= rank) winners.set(slot, {
|
|
148
|
-
token,
|
|
149
|
-
rank
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
const result = {
|
|
154
|
-
padding: {},
|
|
155
|
-
gap: {}
|
|
156
|
-
};
|
|
157
|
-
for (const [slot, { token }] of winners) if (slot === "radius") result.radius = token;
|
|
158
|
-
else if (slot.startsWith("gap.")) result.gap[slot.slice(4)] = token;
|
|
159
|
-
else result.padding[slot.slice(8)] = token;
|
|
160
|
-
return result;
|
|
161
|
-
}
|
|
162
|
-
//#endregion
|
|
163
|
-
export { splitVariants as n, inspectTokens as t };
|