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