@tamagui/tailwind 0.0.0-bootstrap.0 → 3.0.0-beta.1097.1
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/cjs/candidate.cjs +540 -0
- package/dist/cjs/candidate.native.cjs +578 -0
- package/dist/cjs/candidate.native.js +580 -0
- package/dist/cjs/candidate.native.js.map +1 -0
- package/dist/cjs/compose.cjs +352 -0
- package/dist/cjs/compose.native.cjs +358 -0
- package/dist/cjs/compose.native.js +360 -0
- package/dist/cjs/compose.native.js.map +1 -0
- package/dist/cjs/composedResolver.cjs +175 -0
- package/dist/cjs/composedResolver.native.cjs +201 -0
- package/dist/cjs/composedResolver.native.js +203 -0
- package/dist/cjs/composedResolver.native.js.map +1 -0
- package/dist/cjs/frontend.cjs +54 -0
- package/dist/cjs/frontend.native.cjs +62 -0
- package/dist/cjs/frontend.native.js +64 -0
- package/dist/cjs/frontend.native.js.map +1 -0
- package/dist/cjs/index.cjs +38 -0
- package/dist/cjs/index.native.cjs +40 -0
- package/dist/cjs/index.native.js +42 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/styled.cjs +29 -0
- package/dist/cjs/styled.native.cjs +31 -0
- package/dist/cjs/styled.native.js +33 -0
- package/dist/cjs/styled.native.js.map +1 -0
- package/dist/cjs/types.cjs +16 -0
- package/dist/cjs/types.native.cjs +18 -0
- package/dist/cjs/types.native.js +20 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/cjs/vite/state.cjs +249 -0
- package/dist/cjs/vite/state.native.cjs +331 -0
- package/dist/cjs/vite/state.native.js +333 -0
- package/dist/cjs/vite/state.native.js.map +1 -0
- package/dist/cjs/vite.cjs +147 -0
- package/dist/cjs/vite.native.cjs +187 -0
- package/dist/cjs/vite.native.js +189 -0
- package/dist/cjs/vite.native.js.map +1 -0
- package/dist/esm/candidate.mjs +514 -0
- package/dist/esm/candidate.mjs.map +1 -0
- package/dist/esm/candidate.native.js +550 -0
- package/dist/esm/candidate.native.js.map +1 -0
- package/dist/esm/compose.mjs +328 -0
- package/dist/esm/compose.mjs.map +1 -0
- package/dist/esm/compose.native.js +332 -0
- package/dist/esm/compose.native.js.map +1 -0
- package/dist/esm/composedResolver.mjs +155 -0
- package/dist/esm/composedResolver.mjs.map +1 -0
- package/dist/esm/composedResolver.native.js +179 -0
- package/dist/esm/composedResolver.native.js.map +1 -0
- package/dist/esm/frontend.mjs +32 -0
- package/dist/esm/frontend.mjs.map +1 -0
- package/dist/esm/frontend.native.js +38 -0
- package/dist/esm/frontend.native.js.map +1 -0
- package/dist/esm/index.mjs +11 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +11 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/styled.mjs +10 -0
- package/dist/esm/styled.mjs.map +1 -0
- package/dist/esm/styled.native.js +10 -0
- package/dist/esm/styled.native.js.map +1 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/types.native.js +0 -0
- package/dist/esm/vite/state.mjs +216 -0
- package/dist/esm/vite/state.mjs.map +1 -0
- package/dist/esm/vite/state.native.js +296 -0
- package/dist/esm/vite/state.native.js.map +1 -0
- package/dist/esm/vite.mjs +116 -0
- package/dist/esm/vite.mjs.map +1 -0
- package/dist/esm/vite.native.js +154 -0
- package/dist/esm/vite.native.js.map +1 -0
- package/package.json +90 -5
- package/src/candidate.ts +805 -0
- package/src/frontend.ts +73 -0
- package/src/index.tsx +35 -0
- package/src/styled.tsx +52 -0
- package/src/types.ts +249 -0
- package/src/vite/state.ts +274 -0
- package/src/vite.ts +204 -0
- package/types/candidate.d.ts +18 -0
- package/types/candidate.d.ts.map +1 -0
- package/types/compose.d.ts +19 -0
- package/types/compose.d.ts.map +1 -0
- package/types/composedResolver.d.ts +18 -0
- package/types/composedResolver.d.ts.map +1 -0
- package/types/frontend.d.ts +19 -0
- package/types/frontend.d.ts.map +1 -0
- package/types/index.d.ts +17 -0
- package/types/index.d.ts.map +1 -0
- package/types/styled.d.ts +12 -0
- package/types/styled.d.ts.map +1 -0
- package/types/types.d.ts +169 -0
- package/types/types.d.ts.map +1 -0
- package/types/vite/state.d.ts +28 -0
- package/types/vite/state.d.ts.map +1 -0
- package/types/vite.d.ts +20 -0
- package/types/vite.d.ts.map +1 -0
- package/README.md +0 -1
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var candidate_exports = {};
|
|
22
|
+
__export(candidate_exports, {
|
|
23
|
+
getStyleGrammarConfig: () => getStyleGrammarConfig,
|
|
24
|
+
getTailwindClassPlan: () => getTailwindClassPlan,
|
|
25
|
+
isTokenValueProp: () => isTokenValueProp,
|
|
26
|
+
resolveTailwindCandidate: () => resolveTailwindCandidate,
|
|
27
|
+
resolveTailwindClassName: () => resolveTailwindClassName,
|
|
28
|
+
setInAuthoredOrder: () => setInAuthoredOrder
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(candidate_exports);
|
|
31
|
+
var import_constants = require("@tamagui/constants");
|
|
32
|
+
var import_helpers = require("@tamagui/helpers");
|
|
33
|
+
var import_internal_runtime = require("@tamagui/core/internal-runtime");
|
|
34
|
+
var import_compose = require("./compose.cjs");
|
|
35
|
+
var import_composedResolver = require("./composedResolver.cjs");
|
|
36
|
+
var import_runtime = require("@tamagui/style-grammar/runtime");
|
|
37
|
+
var import_candidate = require("@tamagui/style-grammar/tooling/candidate");
|
|
38
|
+
const styleGrammarConfigCache = /* @__PURE__ */ new WeakMap();
|
|
39
|
+
function getStyleGrammarConfig(config) {
|
|
40
|
+
const cached = styleGrammarConfigCache.get(config);
|
|
41
|
+
const revision = config[import_runtime.configRevisionSymbol]?.revision || 0;
|
|
42
|
+
if (cached && cached.revision === revision) return cached.value;
|
|
43
|
+
const view = (0, import_runtime.createGrammarConfigView)(config);
|
|
44
|
+
styleGrammarConfigCache.set(config, {
|
|
45
|
+
revision,
|
|
46
|
+
value: view
|
|
47
|
+
});
|
|
48
|
+
return view;
|
|
49
|
+
}
|
|
50
|
+
function isTokenValueProp(prop) {
|
|
51
|
+
return (0, import_runtime.getTokenCategory)(prop) !== null;
|
|
52
|
+
}
|
|
53
|
+
function arbitraryValue(inner, prop) {
|
|
54
|
+
const px = /^(-?\d*\.?\d+)px$/.exec(inner);
|
|
55
|
+
if (px) return prop && import_helpers.stylePropsUnitless[prop] ? inner : Number(px[1]);
|
|
56
|
+
if (/^-?\d*\.?\d+$/.test(inner)) return Number(inner);
|
|
57
|
+
return inner;
|
|
58
|
+
}
|
|
59
|
+
function unwrapArbitraryValue(raw) {
|
|
60
|
+
return arbitraryValue(raw.length > 1 && raw[0] === "[" && raw[raw.length - 1] === "]" ? (0, import_candidate.decodeArbitrary)(raw.slice(1, -1)) : raw);
|
|
61
|
+
}
|
|
62
|
+
function tailwindSizingValue(prop, value) {
|
|
63
|
+
if (value === "full") return "100%";
|
|
64
|
+
if (value === "auto") return "auto";
|
|
65
|
+
if (value === "screen") return /[Hh]eight|[Bb]lock/.test(prop) ? "100vh" : "100vw";
|
|
66
|
+
if (value === "min") return "min-content";
|
|
67
|
+
if (value === "max") return "max-content";
|
|
68
|
+
if (value === "fit") return "fit-content";
|
|
69
|
+
const frac = /^(\d+)\/(\d+)$/.exec(value);
|
|
70
|
+
if (frac && Number(frac[2]) !== 0) return `${Number(frac[1]) / Number(frac[2]) * 100}%`;
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
function expansionProps(parsed) {
|
|
74
|
+
const prefix = parsed.prefix;
|
|
75
|
+
if (!prefix) return null;
|
|
76
|
+
if (prefix === "size") return import_runtime.sizeUtilityProps;
|
|
77
|
+
if (prefix === "translate") return ["x", "y"];
|
|
78
|
+
if (prefix === "skew") return ["skewX", "skewY"];
|
|
79
|
+
if (prefix === "inset-x" || prefix === "inset-y") return import_runtime.insetAxisProps[prefix.slice(6)];
|
|
80
|
+
if (prefix.startsWith("rounded-")) {
|
|
81
|
+
const props = import_runtime.radiusCornerProps[prefix.slice(8)];
|
|
82
|
+
if (!props || props.length === 1) return null;
|
|
83
|
+
return props;
|
|
84
|
+
}
|
|
85
|
+
const m = /^border-([trblxy])$/.exec(prefix);
|
|
86
|
+
if (!m) return null;
|
|
87
|
+
const sides = import_runtime.borderSideSuffix[m[1]];
|
|
88
|
+
const suffix = parsed.entry?.prop.endsWith("Width") ? "Width" : "Color";
|
|
89
|
+
return sides.map((side) => `border${side}${suffix}`);
|
|
90
|
+
}
|
|
91
|
+
function tailwindClassToFlatProp(parsed, grammarConfig) {
|
|
92
|
+
if (parsed.kind !== "dynamic" || !parsed.entry || parsed.rawValue === void 0) return null;
|
|
93
|
+
const prop = parsed.entry.prop;
|
|
94
|
+
const category = parsed.entry.tokenCategory;
|
|
95
|
+
let value = parsed.rawValue;
|
|
96
|
+
if (parsed.negative && value === "0" && parsed.convenience !== "angle") return {
|
|
97
|
+
key: prop,
|
|
98
|
+
value: 0
|
|
99
|
+
};
|
|
100
|
+
if (parsed.convenience === "zero") return {
|
|
101
|
+
key: prop,
|
|
102
|
+
value: 0
|
|
103
|
+
};
|
|
104
|
+
if (parsed.convenience === "angle") return {
|
|
105
|
+
key: prop,
|
|
106
|
+
value: `${parsed.negative ? "-" : ""}${value}deg`
|
|
107
|
+
};
|
|
108
|
+
if ((prop === "x" || prop === "y") && parsed.valueKind !== "token") {
|
|
109
|
+
const sized = tailwindSizingValue(prop, value);
|
|
110
|
+
if (sized != null) return {
|
|
111
|
+
key: prop,
|
|
112
|
+
value: parsed.negative && sized[0] !== "-" ? `-${sized}` : sized
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
if (prop === "lineHeight" && /^\d+(?:\.\d+)?$/.test(value)) return {
|
|
116
|
+
key: prop,
|
|
117
|
+
value: Number(value) * 4
|
|
118
|
+
};
|
|
119
|
+
if (prop === "gridTemplateColumns" && /^\d+$/.test(value)) return {
|
|
120
|
+
key: prop,
|
|
121
|
+
value: `repeat(${value}, minmax(0, 1fr))`
|
|
122
|
+
};
|
|
123
|
+
if (prop === "gridColumn" && /^\d+$/.test(value)) return {
|
|
124
|
+
key: prop,
|
|
125
|
+
value: `span ${value} / span ${value}`
|
|
126
|
+
};
|
|
127
|
+
if (prop === "gridRow" && /^\d+$/.test(value)) return {
|
|
128
|
+
key: prop,
|
|
129
|
+
value: `span ${value} / span ${value}`
|
|
130
|
+
};
|
|
131
|
+
if ((prop === "gridColumnStart" || prop === "gridColumnEnd" || prop === "gridRowStart" || prop === "gridRowEnd") && /^\d+$/.test(value)) return {
|
|
132
|
+
key: prop,
|
|
133
|
+
value: Number(value)
|
|
134
|
+
};
|
|
135
|
+
if (prop.endsWith("Width") && parsed.prefix?.startsWith("border")) {
|
|
136
|
+
if (parsed.valueKind === "token") {
|
|
137
|
+
value = `${parsed.negative ? "-" : ""}${value}`;
|
|
138
|
+
if (grammarConfig && parsed.entry?.tokenCategory) value = (0, import_candidate.resolveTokenName)(grammarConfig, parsed.entry.tokenCategory, value) ?? value;
|
|
139
|
+
} else if (parsed.valueKind === "arbitrary") value = unwrapArbitraryValue(value);
|
|
140
|
+
else return null;
|
|
141
|
+
return {
|
|
142
|
+
key: prop,
|
|
143
|
+
value
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (prop === "fontFamily") {
|
|
147
|
+
let famValue;
|
|
148
|
+
if (value.length > 2 && value[0] === "[" && value[value.length - 1] === "]") famValue = (0, import_candidate.decodeArbitrary)(value.slice(1, -1));
|
|
149
|
+
else famValue = parsed.valueKind === "token" ? value : {
|
|
150
|
+
sans: "sans-serif",
|
|
151
|
+
serif: "serif",
|
|
152
|
+
mono: "monospace"
|
|
153
|
+
}[value] || value;
|
|
154
|
+
return {
|
|
155
|
+
key: "fontFamily",
|
|
156
|
+
value: famValue
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (prop === "fontSize") {
|
|
160
|
+
let fsValue;
|
|
161
|
+
if (value.length > 2 && value[0] === "[" && value[value.length - 1] === "]") fsValue = arbitraryValue((0, import_candidate.decodeArbitrary)(value.slice(1, -1)));
|
|
162
|
+
else fsValue = value;
|
|
163
|
+
return {
|
|
164
|
+
key: "fontSize",
|
|
165
|
+
value: fsValue
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
if (prop === "lineHeight") {
|
|
169
|
+
let lhValue;
|
|
170
|
+
if (value.length > 2 && value[0] === "[" && value[value.length - 1] === "]") {
|
|
171
|
+
const inner = (0, import_candidate.decodeArbitrary)(value.slice(1, -1));
|
|
172
|
+
lhValue = /^-?\d*\.?\d+px$/.test(inner) ? Number.parseFloat(inner) : inner;
|
|
173
|
+
} else lhValue = value;
|
|
174
|
+
return {
|
|
175
|
+
key: "lineHeight",
|
|
176
|
+
value: lhValue
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
if (prop === "letterSpacing") {
|
|
180
|
+
let lsValue;
|
|
181
|
+
if (value.length > 2 && value[0] === "[" && value[value.length - 1] === "]") lsValue = arbitraryValue((0, import_candidate.decodeArbitrary)(value.slice(1, -1)));
|
|
182
|
+
else lsValue = value;
|
|
183
|
+
return {
|
|
184
|
+
key: "letterSpacing",
|
|
185
|
+
value: lsValue
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
if (prop === "boxShadow" && value[0] === "[" && value[value.length - 1] === "]") return {
|
|
189
|
+
key: "boxShadow",
|
|
190
|
+
value: (0, import_candidate.decodeArbitrary)(value.slice(1, -1))
|
|
191
|
+
};
|
|
192
|
+
if (value.length > 2 && value[0] === "[" && value[value.length - 1] === "]") {
|
|
193
|
+
const inner = (0, import_candidate.decodeArbitrary)(value.slice(1, -1));
|
|
194
|
+
if (inner === "") return null;
|
|
195
|
+
let resolved = arbitraryValue(inner, prop);
|
|
196
|
+
if ((prop === "rotate" || prop === "rotateX" || prop === "rotateY" || prop === "rotateZ" || prop === "skewX" || prop === "skewY") && typeof resolved === "number") resolved = `${resolved}deg`;
|
|
197
|
+
if (parsed.negative) {
|
|
198
|
+
if (typeof resolved === "number") resolved = -resolved;
|
|
199
|
+
else if (resolved[0] !== "-") resolved = `-${resolved}`;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
key: prop,
|
|
203
|
+
value: resolved
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
if (parsed.valueKind !== "token" && (category === "size" || parsed.convenience === "sizing-keyword")) {
|
|
207
|
+
const sized = tailwindSizingValue(prop, value);
|
|
208
|
+
if (sized != null) return {
|
|
209
|
+
key: prop,
|
|
210
|
+
value: parsed.negative && sized[0] !== "-" ? `-${sized}` : sized
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
let opacitySuffix = "";
|
|
214
|
+
if (category === "color" && typeof value === "string") {
|
|
215
|
+
const suffix = (0, import_runtime.splitColorOpacitySuffix)(value);
|
|
216
|
+
if (suffix.kind === "invalid") return {
|
|
217
|
+
key: prop,
|
|
218
|
+
value
|
|
219
|
+
};
|
|
220
|
+
if (suffix.kind === "valid") {
|
|
221
|
+
opacitySuffix = value.slice(suffix.name.length);
|
|
222
|
+
value = suffix.name;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (import_runtime.percentUtilityProps.has(prop) && /^\d+$/.test(value)) value = Number(value) / 100;
|
|
226
|
+
else if (/^\d+(\.\d+)?$/.test(value)) if (category === "zIndex" && parsed.valueKind === "convenience") value = Number(value) * (parsed.negative ? -1 : 1);
|
|
227
|
+
else if (category) {
|
|
228
|
+
value = `${parsed.negative ? "-" : ""}${value}`;
|
|
229
|
+
if (grammarConfig) value = (0, import_candidate.resolveTokenName)(grammarConfig, category, value) ?? value;
|
|
230
|
+
} else value = Number(value);
|
|
231
|
+
else if (typeof value === "string") {
|
|
232
|
+
if (category && !((category === "space" || category === "size" || category === "radius") && (0, import_runtime.getSafeAreaEdge)(value))) value = `${parsed.negative ? "-" : ""}${value}`;
|
|
233
|
+
}
|
|
234
|
+
if (opacitySuffix && typeof value === "string") value = `${value}${opacitySuffix}`;
|
|
235
|
+
if (parsed.negative && !category) {
|
|
236
|
+
if (typeof value === "number") value = -value;
|
|
237
|
+
else if (typeof value === "string" && value[0] !== "-") value = `-${value}`;
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
key: prop,
|
|
241
|
+
value
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
const classPlanCache = /* @__PURE__ */ new WeakMap();
|
|
245
|
+
const nativeTarget = !import_constants.isWeb || false;
|
|
246
|
+
const cssGridProps = /* @__PURE__ */ new Set([
|
|
247
|
+
"gridTemplateColumns",
|
|
248
|
+
"gridColumn",
|
|
249
|
+
"gridColumnStart",
|
|
250
|
+
"gridColumnEnd",
|
|
251
|
+
"gridRow",
|
|
252
|
+
"gridRowStart",
|
|
253
|
+
"gridRowEnd"
|
|
254
|
+
]);
|
|
255
|
+
const nativeUnsupportedProps = /* @__PURE__ */ new Set([
|
|
256
|
+
"objectFit",
|
|
257
|
+
"order",
|
|
258
|
+
"overflowX",
|
|
259
|
+
"overflowY",
|
|
260
|
+
"textOverflow",
|
|
261
|
+
"whiteSpace",
|
|
262
|
+
"visibility"
|
|
263
|
+
]);
|
|
264
|
+
const nativeUnsupportedSizingValues = /* @__PURE__ */ new Set([
|
|
265
|
+
"screen",
|
|
266
|
+
"min",
|
|
267
|
+
"max",
|
|
268
|
+
"fit"
|
|
269
|
+
]);
|
|
270
|
+
const nativeUnsupportedDisplayValues = /* @__PURE__ */ new Set([
|
|
271
|
+
"block",
|
|
272
|
+
"inline",
|
|
273
|
+
"inline-flex"
|
|
274
|
+
]);
|
|
275
|
+
const nativeUnsupportedPositionValues = /* @__PURE__ */ new Set(["fixed", "sticky"]);
|
|
276
|
+
function shouldGateNative(parsed) {
|
|
277
|
+
if (!nativeTarget) return false;
|
|
278
|
+
const properties = parsed.properties || {};
|
|
279
|
+
if (process.env.TAMAGUI_CSS_GRID !== "1" && (parsed.entry && cssGridProps.has(parsed.entry.prop) || properties.display === "grid" || Object.keys(properties).some((prop) => cssGridProps.has(prop)))) return true;
|
|
280
|
+
if (parsed.entry && nativeUnsupportedProps.has(parsed.entry.prop) || Object.keys(properties).some((prop) => nativeUnsupportedProps.has(prop))) return true;
|
|
281
|
+
if (parsed.convenience === "sizing-keyword" && nativeUnsupportedSizingValues.has(parsed.rawValue || "")) return true;
|
|
282
|
+
return nativeUnsupportedDisplayValues.has(String(properties.display)) || nativeUnsupportedPositionValues.has(String(properties.position)) || properties.overflow === "auto" || properties.cursor !== void 0 && properties.cursor !== "auto" && properties.cursor !== "pointer";
|
|
283
|
+
}
|
|
284
|
+
function getClassPlanCache(grammarConfig) {
|
|
285
|
+
let cache = classPlanCache.get(grammarConfig);
|
|
286
|
+
if (!cache) {
|
|
287
|
+
cache = /* @__PURE__ */ new Map();
|
|
288
|
+
classPlanCache.set(grammarConfig, cache);
|
|
289
|
+
}
|
|
290
|
+
return cache;
|
|
291
|
+
}
|
|
292
|
+
function createPlanEntry(property, value, modifiers) {
|
|
293
|
+
if (modifiers.length === 0) return [property, value];
|
|
294
|
+
const payload = (0, import_internal_runtime.plainValueToPayload)(value, property);
|
|
295
|
+
if (payload === null) return null;
|
|
296
|
+
let condition = "";
|
|
297
|
+
for (let index = 0; index < modifiers.length; index++) {
|
|
298
|
+
if (index) condition += ":";
|
|
299
|
+
condition += modifiers[index];
|
|
300
|
+
}
|
|
301
|
+
return [
|
|
302
|
+
property,
|
|
303
|
+
payload,
|
|
304
|
+
condition,
|
|
305
|
+
modifiers
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
const shorthandResets = {
|
|
309
|
+
padding: [
|
|
310
|
+
"paddingTop",
|
|
311
|
+
"paddingRight",
|
|
312
|
+
"paddingBottom",
|
|
313
|
+
"paddingLeft",
|
|
314
|
+
"paddingStart",
|
|
315
|
+
"paddingEnd",
|
|
316
|
+
"paddingInlineStart",
|
|
317
|
+
"paddingInlineEnd",
|
|
318
|
+
"paddingBlockStart",
|
|
319
|
+
"paddingBlockEnd",
|
|
320
|
+
"paddingHorizontal",
|
|
321
|
+
"paddingVertical",
|
|
322
|
+
"paddingInline",
|
|
323
|
+
"paddingBlock"
|
|
324
|
+
],
|
|
325
|
+
margin: [
|
|
326
|
+
"marginTop",
|
|
327
|
+
"marginRight",
|
|
328
|
+
"marginBottom",
|
|
329
|
+
"marginLeft",
|
|
330
|
+
"marginStart",
|
|
331
|
+
"marginEnd",
|
|
332
|
+
"marginInlineStart",
|
|
333
|
+
"marginInlineEnd",
|
|
334
|
+
"marginBlockStart",
|
|
335
|
+
"marginBlockEnd",
|
|
336
|
+
"marginHorizontal",
|
|
337
|
+
"marginVertical",
|
|
338
|
+
"marginInline",
|
|
339
|
+
"marginBlock"
|
|
340
|
+
],
|
|
341
|
+
gap: ["rowGap", "columnGap"],
|
|
342
|
+
borderRadius: [
|
|
343
|
+
"borderTopLeftRadius",
|
|
344
|
+
"borderTopRightRadius",
|
|
345
|
+
"borderBottomLeftRadius",
|
|
346
|
+
"borderBottomRightRadius",
|
|
347
|
+
"borderTopStartRadius",
|
|
348
|
+
"borderTopEndRadius",
|
|
349
|
+
"borderBottomStartRadius",
|
|
350
|
+
"borderBottomEndRadius",
|
|
351
|
+
"borderStartStartRadius",
|
|
352
|
+
"borderStartEndRadius",
|
|
353
|
+
"borderEndStartRadius",
|
|
354
|
+
"borderEndEndRadius"
|
|
355
|
+
],
|
|
356
|
+
borderWidth: [
|
|
357
|
+
"borderTopWidth",
|
|
358
|
+
"borderRightWidth",
|
|
359
|
+
"borderBottomWidth",
|
|
360
|
+
"borderLeftWidth",
|
|
361
|
+
"borderStartWidth",
|
|
362
|
+
"borderEndWidth",
|
|
363
|
+
"borderInlineStartWidth",
|
|
364
|
+
"borderInlineEndWidth",
|
|
365
|
+
"borderBlockStartWidth",
|
|
366
|
+
"borderBlockEndWidth",
|
|
367
|
+
"borderInlineWidth",
|
|
368
|
+
"borderBlockWidth"
|
|
369
|
+
],
|
|
370
|
+
borderColor: [
|
|
371
|
+
"borderTopColor",
|
|
372
|
+
"borderRightColor",
|
|
373
|
+
"borderBottomColor",
|
|
374
|
+
"borderLeftColor",
|
|
375
|
+
"borderStartColor",
|
|
376
|
+
"borderEndColor",
|
|
377
|
+
"borderInlineStartColor",
|
|
378
|
+
"borderInlineEndColor",
|
|
379
|
+
"borderBlockStartColor",
|
|
380
|
+
"borderBlockEndColor",
|
|
381
|
+
"borderInlineColor",
|
|
382
|
+
"borderBlockColor"
|
|
383
|
+
]
|
|
384
|
+
};
|
|
385
|
+
function attachShorthandResets(entries, modifiers) {
|
|
386
|
+
if (import_constants.isWeb || modifiers.length > 0) return entries;
|
|
387
|
+
const unsets = [];
|
|
388
|
+
for (let i = 0; i < entries.length; i++) {
|
|
389
|
+
const resets = shorthandResets[entries[i][0]];
|
|
390
|
+
if (!resets) continue;
|
|
391
|
+
for (let j = 0; j < resets.length; j++) unsets.push([resets[j], "unset"]);
|
|
392
|
+
}
|
|
393
|
+
return unsets.length === 0 ? entries : unsets.concat(entries);
|
|
394
|
+
}
|
|
395
|
+
function computeClassPlan(cls, grammarConfig) {
|
|
396
|
+
const groupMarker = /^group(?:\/([A-Za-z0-9_-]+))?$/.exec(cls);
|
|
397
|
+
if (groupMarker) return {
|
|
398
|
+
entries: [["group", groupMarker[1] || true]],
|
|
399
|
+
preserveRawClass: import_constants.isWeb
|
|
400
|
+
};
|
|
401
|
+
const containerMarker = /^@container(-size)?(?:\/([A-Za-z0-9_-]+))?$/.exec(cls);
|
|
402
|
+
if (containerMarker) {
|
|
403
|
+
const isSize = containerMarker[1] !== void 0;
|
|
404
|
+
const name = containerMarker[2];
|
|
405
|
+
const entries = [];
|
|
406
|
+
entries.push(["container", name || true]);
|
|
407
|
+
if (isSize) entries.push(["containerType", "size"]);
|
|
408
|
+
return {
|
|
409
|
+
entries,
|
|
410
|
+
preserveRawClass: import_constants.isWeb
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
const classification = (0, import_candidate.classifyCandidate)(cls, grammarConfig);
|
|
414
|
+
if (classification.kind === "passthrough") return import_constants.isWeb ? "raw" : null;
|
|
415
|
+
const parsed = classification.parsed;
|
|
416
|
+
if (!nativeTarget && parsed.entry?.prop === "perspective") return "raw";
|
|
417
|
+
if (shouldGateNative(parsed)) return null;
|
|
418
|
+
if (parsed.entry?.prop === "flex" && parsed.rawValue) {
|
|
419
|
+
const fraction = /^(\d+)\/(\d+)$/.exec(parsed.rawValue);
|
|
420
|
+
if (fraction && Number(fraction[2]) !== 0) {
|
|
421
|
+
const basis = `${Number(fraction[1]) / Number(fraction[2]) * 100}%`;
|
|
422
|
+
const entries = [
|
|
423
|
+
createPlanEntry("flexGrow", 1, parsed.modifiers),
|
|
424
|
+
createPlanEntry("flexShrink", 1, parsed.modifiers),
|
|
425
|
+
createPlanEntry("flexBasis", basis, parsed.modifiers)
|
|
426
|
+
];
|
|
427
|
+
return entries.every(Boolean) ? entries : "raw";
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
const util = parsed.kind === "utility" ? parsed.properties : null;
|
|
431
|
+
if (util) {
|
|
432
|
+
const entries = [];
|
|
433
|
+
for (const p in util) {
|
|
434
|
+
const entry = createPlanEntry(p, nativeTarget && p === "transform" && util[p] === "none" ? [] : util[p], parsed.modifiers);
|
|
435
|
+
if (!entry) return "raw";
|
|
436
|
+
entries.push(entry);
|
|
437
|
+
}
|
|
438
|
+
return attachShorthandResets(entries, parsed.modifiers);
|
|
439
|
+
}
|
|
440
|
+
const expandedProps = expansionProps(parsed);
|
|
441
|
+
if (expandedProps) {
|
|
442
|
+
const entries = [];
|
|
443
|
+
for (const prop of expandedProps) {
|
|
444
|
+
const flatProp2 = tailwindClassToFlatProp({
|
|
445
|
+
...parsed,
|
|
446
|
+
entry: parsed.entry ? {
|
|
447
|
+
...parsed.entry,
|
|
448
|
+
prop
|
|
449
|
+
} : parsed.entry
|
|
450
|
+
}, grammarConfig);
|
|
451
|
+
if (!flatProp2) return "raw";
|
|
452
|
+
const entry = createPlanEntry(flatProp2.key, flatProp2.value, parsed.modifiers);
|
|
453
|
+
if (!entry) return "raw";
|
|
454
|
+
entries.push(entry);
|
|
455
|
+
}
|
|
456
|
+
return attachShorthandResets(entries, parsed.modifiers);
|
|
457
|
+
}
|
|
458
|
+
const flatProp = tailwindClassToFlatProp(parsed, grammarConfig);
|
|
459
|
+
if (flatProp) {
|
|
460
|
+
const entry = createPlanEntry(flatProp.key, flatProp.value, parsed.modifiers);
|
|
461
|
+
return entry ? attachShorthandResets([entry], parsed.modifiers) : "raw";
|
|
462
|
+
}
|
|
463
|
+
return "raw";
|
|
464
|
+
}
|
|
465
|
+
function getTailwindClassPlan(candidate, config) {
|
|
466
|
+
const grammarConfig = getStyleGrammarConfig(config);
|
|
467
|
+
const plans = getClassPlanCache(grammarConfig);
|
|
468
|
+
let plan = plans.get(candidate);
|
|
469
|
+
if (plan === void 0) {
|
|
470
|
+
plan = computeClassPlan(candidate, grammarConfig);
|
|
471
|
+
plans.set(candidate, plan);
|
|
472
|
+
}
|
|
473
|
+
return plan;
|
|
474
|
+
}
|
|
475
|
+
function resolveTailwindCandidate(candidate, config, sink) {
|
|
476
|
+
const composed = (0, import_compose.tryCompose)(candidate, getStyleGrammarConfig(config), sink);
|
|
477
|
+
if (composed !== void 0) return composed;
|
|
478
|
+
const plan = getTailwindClassPlan(candidate, config);
|
|
479
|
+
if (plan === "raw") return true;
|
|
480
|
+
if (plan === null) return null;
|
|
481
|
+
const parent = Array.isArray(plan) ? null : plan;
|
|
482
|
+
const entries = parent ? parent.entries : plan;
|
|
483
|
+
for (let index = 0; index < entries.length; index++) {
|
|
484
|
+
const entry = entries[index];
|
|
485
|
+
const transformTokenCategory = entry[0] === "x" || entry[0] === "y" ? "space" : entry[0] === "perspective" ? "perspective" : null;
|
|
486
|
+
const transformValue = transformTokenCategory && typeof entry[1] === "string" ? config.tokensParsed?.[transformTokenCategory]?.[entry[1]]?.val ?? entry[1] : entry[1];
|
|
487
|
+
if ((0, import_compose.noteTailwindTransform)(sink, [
|
|
488
|
+
entry[0],
|
|
489
|
+
transformValue,
|
|
490
|
+
entry[2],
|
|
491
|
+
entry[3]
|
|
492
|
+
])) continue;
|
|
493
|
+
if (entry[0] === "boxShadow" && typeof entry[1] === "string") (0, import_compose.noteBoxShadow)(sink, config.tokensParsed?.boxShadow?.[entry[1]]?.val ?? entry[1], entry[3] || []);
|
|
494
|
+
sink(entry);
|
|
495
|
+
}
|
|
496
|
+
return parent?.preserveRawClass || false;
|
|
497
|
+
}
|
|
498
|
+
function resolveTailwindClassName(className, config) {
|
|
499
|
+
const result = {};
|
|
500
|
+
let composedProps = null;
|
|
501
|
+
let rawClassName = "";
|
|
502
|
+
const sink = (entry) => {
|
|
503
|
+
const [key, value, condition] = entry;
|
|
504
|
+
if (key.charCodeAt(0) === 95 && key.charCodeAt(1) === 95) {
|
|
505
|
+
composedProps ||= {};
|
|
506
|
+
composedProps[key] = (0, import_internal_runtime.mergeFrontendCondition)(composedProps[key], value, condition);
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
if (condition === void 0) {
|
|
510
|
+
const resets = shorthandResets[key];
|
|
511
|
+
if (resets) for (let i = 0; i < resets.length; i++) delete result[resets[i]];
|
|
512
|
+
}
|
|
513
|
+
setInAuthoredOrder(result, key, (0, import_internal_runtime.mergeFrontendCondition)(result[key], value, condition));
|
|
514
|
+
};
|
|
515
|
+
let start = 0;
|
|
516
|
+
for (let index = 0; index <= className.length; index++) {
|
|
517
|
+
if (index !== className.length && className.charCodeAt(index) > 32) continue;
|
|
518
|
+
if (start === index) {
|
|
519
|
+
start = index + 1;
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
const candidate = className.slice(start, index);
|
|
523
|
+
if (resolveTailwindCandidate(candidate, config, sink)) rawClassName = rawClassName ? `${rawClassName} ${candidate}` : candidate;
|
|
524
|
+
start = index + 1;
|
|
525
|
+
}
|
|
526
|
+
if (composedProps) {
|
|
527
|
+
const composed = (0, import_composedResolver.composedResolver)(composedProps);
|
|
528
|
+
for (const key in composed) setInAuthoredOrder(result, key, composed[key]);
|
|
529
|
+
}
|
|
530
|
+
if (rawClassName) result.className = rawClassName;
|
|
531
|
+
return result;
|
|
532
|
+
}
|
|
533
|
+
function setInAuthoredOrder(target, key, value) {
|
|
534
|
+
if (value === "unset") {
|
|
535
|
+
delete target[key];
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
if (key in target) delete target[key];
|
|
539
|
+
target[key] = value;
|
|
540
|
+
}
|