@tamagui/tailwind 3.0.0-beta.924.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.
Files changed (56) hide show
  1. package/dist/cjs/candidate.cjs +312 -137
  2. package/dist/cjs/candidate.native.cjs +342 -153
  3. package/dist/cjs/candidate.native.js +342 -153
  4. package/dist/cjs/candidate.native.js.map +1 -1
  5. package/dist/cjs/compose.cjs +383 -0
  6. package/dist/cjs/compose.native.cjs +389 -0
  7. package/dist/cjs/compose.native.js +391 -0
  8. package/dist/cjs/compose.native.js.map +1 -0
  9. package/dist/cjs/composedResolver.cjs +226 -0
  10. package/dist/cjs/composedResolver.native.cjs +255 -0
  11. package/dist/cjs/composedResolver.native.js +257 -0
  12. package/dist/cjs/composedResolver.native.js.map +1 -0
  13. package/dist/cjs/frontend.cjs +4 -11
  14. package/dist/cjs/frontend.native.cjs +5 -16
  15. package/dist/cjs/frontend.native.js +5 -16
  16. package/dist/cjs/frontend.native.js.map +1 -1
  17. package/dist/cjs/index.cjs +2 -0
  18. package/dist/cjs/index.native.cjs +2 -0
  19. package/dist/cjs/index.native.js +2 -0
  20. package/dist/cjs/index.native.js.map +1 -1
  21. package/dist/esm/candidate.mjs +314 -140
  22. package/dist/esm/candidate.mjs.map +1 -1
  23. package/dist/esm/candidate.native.js +344 -156
  24. package/dist/esm/candidate.native.js.map +1 -1
  25. package/dist/esm/compose.mjs +359 -0
  26. package/dist/esm/compose.mjs.map +1 -0
  27. package/dist/esm/compose.native.js +363 -0
  28. package/dist/esm/compose.native.js.map +1 -0
  29. package/dist/esm/composedResolver.mjs +206 -0
  30. package/dist/esm/composedResolver.mjs.map +1 -0
  31. package/dist/esm/composedResolver.native.js +233 -0
  32. package/dist/esm/composedResolver.native.js.map +1 -0
  33. package/dist/esm/frontend.mjs +4 -11
  34. package/dist/esm/frontend.mjs.map +1 -1
  35. package/dist/esm/frontend.native.js +5 -16
  36. package/dist/esm/frontend.native.js.map +1 -1
  37. package/dist/esm/index.mjs +3 -2
  38. package/dist/esm/index.mjs.map +1 -1
  39. package/dist/esm/index.native.js +3 -2
  40. package/dist/esm/index.native.js.map +1 -1
  41. package/package.json +18 -15
  42. package/src/candidate.ts +396 -60
  43. package/src/frontend.ts +3 -16
  44. package/src/index.tsx +14 -2
  45. package/src/types.ts +32 -4
  46. package/types/candidate.d.ts +2 -1
  47. package/types/candidate.d.ts.map +1 -1
  48. package/types/compose.d.ts +19 -0
  49. package/types/compose.d.ts.map +1 -0
  50. package/types/composedResolver.d.ts +19 -0
  51. package/types/composedResolver.d.ts.map +1 -0
  52. package/types/frontend.d.ts.map +1 -1
  53. package/types/index.d.ts +11 -1
  54. package/types/index.d.ts.map +1 -1
  55. package/types/types.d.ts +18 -3
  56. package/types/types.d.ts.map +1 -1
@@ -0,0 +1,389 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var compose_exports = {};
24
+ __export(compose_exports, {
25
+ noteBoxShadow: () => noteBoxShadow,
26
+ noteTailwindTransform: () => noteTailwindTransform,
27
+ tryCompose: () => tryCompose
28
+ });
29
+ module.exports = __toCommonJS(compose_exports);
30
+ var import_internal_runtime = require("@tamagui/core/internal-runtime");
31
+ var import_runtime = require("@tamagui/style-grammar/runtime");
32
+ var import_candidate = require("@tamagui/style-grammar/tooling/candidate");
33
+ var import_constants = require("@tamagui/constants");
34
+ var transformProps = new Set([
35
+ "perspective",
36
+ "rotateX",
37
+ "rotateY",
38
+ "rotateZ",
39
+ "skewX",
40
+ "skewY"
41
+ ]);
42
+ var nativeTarget = !import_constants.isWeb || true;
43
+ var linearTo = {
44
+ t: "to top",
45
+ tr: "to top right",
46
+ r: "to right",
47
+ br: "to bottom right",
48
+ b: "to bottom",
49
+ bl: "to bottom left",
50
+ l: "to left",
51
+ tl: "to top left"
52
+ };
53
+ var colorKeywords = {
54
+ transparent: "transparent",
55
+ current: "currentColor",
56
+ inherit: "inherit",
57
+ black: "black",
58
+ white: "white"
59
+ };
60
+ var dropShadowPresets = {
61
+ xs: {
62
+ geometry: "0 1px 1px",
63
+ defaultColor: "rgb(0 0 0 / 0.05)"
64
+ },
65
+ sm: {
66
+ geometry: "0 1px 2px",
67
+ defaultColor: "rgb(0 0 0 / 0.15)"
68
+ },
69
+ md: {
70
+ geometry: "0 3px 3px",
71
+ defaultColor: "rgb(0 0 0 / 0.12)"
72
+ },
73
+ lg: {
74
+ geometry: "0 4px 4px",
75
+ defaultColor: "rgb(0 0 0 / 0.15)"
76
+ },
77
+ xl: {
78
+ geometry: "0 9px 7px",
79
+ defaultColor: "rgb(0 0 0 / 0.1)"
80
+ },
81
+ "2xl": {
82
+ geometry: "0 25px 25px",
83
+ defaultColor: "rgb(0 0 0 / 0.15)"
84
+ },
85
+ none: {
86
+ geometry: "0 0 0",
87
+ defaultColor: "transparent"
88
+ }
89
+ };
90
+ var textShadowPresets = {
91
+ "2xs": {
92
+ offset: {
93
+ width: 0,
94
+ height: 1
95
+ },
96
+ radius: 0,
97
+ defaultColor: "rgb(0 0 0 / 0.15)"
98
+ },
99
+ xs: {
100
+ offset: {
101
+ width: 0,
102
+ height: 1
103
+ },
104
+ radius: 1,
105
+ defaultColor: "rgb(0 0 0 / 0.2)"
106
+ },
107
+ none: {
108
+ offset: {
109
+ width: 0,
110
+ height: 0
111
+ },
112
+ radius: 0,
113
+ defaultColor: "transparent"
114
+ }
115
+ };
116
+ var insetShadowPresets = {
117
+ "2xs": {
118
+ geometry: "inset 0 1px 0",
119
+ defaultColor: "rgb(0 0 0 / 0.05)"
120
+ },
121
+ xs: {
122
+ geometry: "inset 0 1px 1px",
123
+ defaultColor: "rgb(0 0 0 / 0.05)"
124
+ },
125
+ sm: {
126
+ geometry: "inset 0 2px 4px",
127
+ defaultColor: "rgb(0 0 0 / 0.05)"
128
+ },
129
+ none: {
130
+ geometry: "",
131
+ defaultColor: "transparent"
132
+ }
133
+ };
134
+ var filterPropMap = {
135
+ blur: "__filter_blur",
136
+ brightness: "__filter_brightness",
137
+ contrast: "__filter_contrast",
138
+ grayscale: "__filter_grayscale",
139
+ "hue-rotate": "__filter_hueRotate",
140
+ invert: "__filter_invert",
141
+ saturate: "__filter_saturate",
142
+ sepia: "__filter_sepia"
143
+ };
144
+ function composerKind(core) {
145
+ var first = core.charCodeAt(0);
146
+ if (first === 100) return core.startsWith("drop-shadow-") ? "drop-shadow" : null;
147
+ if (first === 102) return core.startsWith("from-") ? "from" : null;
148
+ if (first === 118) return core.startsWith("via-") ? "via" : null;
149
+ if (first === 116) {
150
+ if (core.startsWith("text-shadow-")) return "text-shadow";
151
+ return core.startsWith("to-") ? "to" : null;
152
+ }
153
+ if (first === 98) {
154
+ if (core.startsWith("bg-linear-to-")) return "image";
155
+ return core.startsWith("blur-") || core.startsWith("brightness-") ? "filter" : null;
156
+ }
157
+ if (first === 114) {
158
+ if (core.startsWith("ring-offset-")) return "ring-offset";
159
+ return core === "ring" || core.startsWith("ring-") ? "ring" : null;
160
+ }
161
+ if (first === 99) return core.startsWith("contrast-") ? "filter" : null;
162
+ if (first === 103) return core === "grayscale" || core.startsWith("grayscale-") ? "filter" : null;
163
+ if (first === 104) return core.startsWith("hue-rotate-") ? "filter" : null;
164
+ if (first === 105) return core.startsWith("inset-ring") ? "inset-ring" : core.startsWith("inset-shadow-") ? "inset-shadow" : core === "invert" || core.startsWith("invert-") ? "filter" : null;
165
+ if (first === 115) {
166
+ if (core.startsWith("shadow-")) return "shadow-color";
167
+ return core.startsWith("saturate-") || core === "sepia" || core.startsWith("sepia-") ? "filter" : null;
168
+ }
169
+ return null;
170
+ }
171
+ function filterPart(core) {
172
+ if (core.startsWith("blur-")) {
173
+ var value = {
174
+ none: 0,
175
+ xs: 4,
176
+ sm: 8,
177
+ md: 12,
178
+ lg: 16,
179
+ xl: 24,
180
+ "2xl": 40,
181
+ "3xl": 64
182
+ }[core.slice(5)];
183
+ return value === void 0 ? null : ["blur", `${value}px`];
184
+ }
185
+ for (var _i = 0, _iter = [
186
+ "brightness",
187
+ "contrast",
188
+ "saturate"
189
+ ]; _i < _iter.length; _i++) {
190
+ var name = _iter[_i];
191
+ if (!core.startsWith(`${name}-`)) continue;
192
+ var value1 = core.slice(name.length + 1);
193
+ if (!/^\d+$/.test(value1)) return null;
194
+ return [name, `${value1}%`];
195
+ }
196
+ for (var _i1 = 0, _iter1 = [
197
+ "grayscale",
198
+ "invert",
199
+ "sepia"
200
+ ]; _i1 < _iter1.length; _i1++) {
201
+ var name1 = _iter1[_i1];
202
+ if (core === name1) return [name1, "100%"];
203
+ if (!core.startsWith(`${name1}-`)) continue;
204
+ var value2 = core.slice(name1.length + 1);
205
+ if (!/^\d+$/.test(value2)) return null;
206
+ return [name1, `${value2}%`];
207
+ }
208
+ if (core.startsWith("hue-rotate-")) {
209
+ var value3 = core.slice(11);
210
+ if (!/^\d+$/.test(value3)) return null;
211
+ return ["hue-rotate", `${value3}deg`];
212
+ }
213
+ return null;
214
+ }
215
+ function resolveColor(raw, config) {
216
+ if (raw.length > 1 && raw[0] === "[" && raw[raw.length - 1] === "]") return (0, import_candidate.decodeArbitrary)(raw.slice(1, -1)) || null;
217
+ if (raw.endsWith("%")) return null;
218
+ var keyword = colorKeywords[raw];
219
+ if (keyword) return keyword;
220
+ var suffix = (0, import_runtime.splitColorOpacitySuffix)(raw);
221
+ var name = suffix.kind === "none" ? raw : suffix.name;
222
+ if (!(0, import_candidate.hasTokenName)(config, "color", name)) return null;
223
+ return raw;
224
+ }
225
+ function emit(sink, property, value, modifiers) {
226
+ if (modifiers.length === 0) {
227
+ sink([property, value]);
228
+ return;
229
+ }
230
+ var _plainValueToPayload;
231
+ var payload = (_plainValueToPayload = (0, import_internal_runtime.plainValueToPayload)(value, property)) !== null && _plainValueToPayload !== void 0 ? _plainValueToPayload : value;
232
+ if (payload === null) return;
233
+ var condition = modifiers[0];
234
+ for (var index = 1; index < modifiers.length; index++) condition += `:${modifiers[index]}`;
235
+ sink([
236
+ property,
237
+ payload,
238
+ condition,
239
+ modifiers
240
+ ]);
241
+ }
242
+ function ringWidth(raw) {
243
+ if (raw === "inset") return null;
244
+ if (/^\d+$/.test(raw)) return `${raw}px`;
245
+ if (raw.length > 1 && raw[0] === "[" && raw[raw.length - 1] === "]") {
246
+ var inner = (0, import_candidate.decodeArbitrary)(raw.slice(1, -1));
247
+ if (/^-?(?:\d+|\d*\.\d+)$/.test(inner)) return `${inner}px`;
248
+ if (/^-?(?:\d+|\d*\.\d+)px$/.test(inner)) return inner;
249
+ return null;
250
+ }
251
+ return null;
252
+ }
253
+ function tryCompose(candidate, config, sink) {
254
+ var modified = candidate.indexOf(":") !== -1;
255
+ var split = modified ? (0, import_candidate.splitCandidate)(candidate) : null;
256
+ if (modified && !split) return void 0;
257
+ var core = split ? split.base : candidate;
258
+ if (!core) return void 0;
259
+ var kind = composerKind(core);
260
+ if (kind == null) return void 0;
261
+ var modifiers = split ? split.modifiers.map(import_runtime.canonicalClauseModifier) : [];
262
+ if (kind === "filter") {
263
+ var part = filterPart(core);
264
+ if (!part) return true;
265
+ if (nativeTarget && part[0] !== "brightness" && !import_constants.isAndroid) return null;
266
+ var prop = filterPropMap[part[0]];
267
+ if (prop) emit(sink, prop, part[1], modifiers);
268
+ return false;
269
+ }
270
+ if (kind === "drop-shadow") {
271
+ if (nativeTarget && !import_constants.isAndroid) return null;
272
+ var raw = core.slice(12);
273
+ var shadow = dropShadowPresets[raw];
274
+ if (shadow) {
275
+ emit(sink, "__dropShadowGeometry", shadow.geometry, modifiers);
276
+ emit(sink, "__dropShadowDefaultColor", shadow.defaultColor, modifiers);
277
+ } else {
278
+ var color = resolveColor(raw, config);
279
+ if (color == null) return void 0;
280
+ emit(sink, "__dropShadowColor", color, modifiers);
281
+ }
282
+ return false;
283
+ }
284
+ if (kind === "text-shadow") {
285
+ var raw1 = core.slice(12);
286
+ var geometry = textShadowPresets[raw1];
287
+ if (geometry) {
288
+ if (modifiers.length > 0) return nativeTarget ? null : void 0;
289
+ emit(sink, "__textShadow_preset", geometry, modifiers);
290
+ } else {
291
+ var _classified_parsed_entry;
292
+ var resolved = resolveColor(raw1, config);
293
+ var classified = resolved == null ? (0, import_candidate.classifyCandidate)(core, config) : null;
294
+ var color1 = resolved !== null && resolved !== void 0 ? resolved : (classified === null || classified === void 0 ? void 0 : classified.kind) === "tamagui" && ((_classified_parsed_entry = classified.parsed.entry) === null || _classified_parsed_entry === void 0 ? void 0 : _classified_parsed_entry.prop) === "textShadowColor" ? raw1 : null;
295
+ if (color1 == null) return void 0;
296
+ emit(sink, "__textShadow_color", color1, modifiers);
297
+ }
298
+ return false;
299
+ }
300
+ if (kind === "inset-ring") {
301
+ var raw2 = core === "inset-ring" ? "" : core.slice(11);
302
+ var width = raw2 === "" ? "1px" : ringWidth(raw2);
303
+ if (width != null) emit(sink, "__insetRingWidth", width, modifiers);
304
+ else {
305
+ var color2 = resolveColor(raw2, config);
306
+ if (color2 == null) return void 0;
307
+ emit(sink, "__insetRingColor", color2, modifiers);
308
+ }
309
+ return false;
310
+ }
311
+ if (kind === "inset-shadow") {
312
+ var raw3 = core.slice(13);
313
+ var shadow1 = insetShadowPresets[raw3];
314
+ if (shadow1) {
315
+ emit(sink, "__insetShadowGeometry", shadow1.geometry, modifiers);
316
+ emit(sink, "__insetShadowDefaultColor", shadow1.defaultColor, modifiers);
317
+ } else {
318
+ var color3 = resolveColor(raw3, config);
319
+ if (color3 == null) return void 0;
320
+ emit(sink, "__insetShadowColor", color3, modifiers);
321
+ }
322
+ return false;
323
+ }
324
+ if (kind === "shadow-color") {
325
+ var raw4 = core.slice(7);
326
+ var color4 = resolveColor(raw4, config);
327
+ if (color4 == null || raw4[0] === "[" && /\s/.test(color4.replace(/\([^)]*\)/g, ""))) return void 0;
328
+ emit(sink, "__shadowColor", color4, modifiers);
329
+ return false;
330
+ }
331
+ if (kind === "ring-offset") {
332
+ var raw5 = core.slice(12);
333
+ var width1 = ringWidth(raw5);
334
+ if (width1 != null) {
335
+ emit(sink, "__ringOffsetWidth", width1, modifiers);
336
+ return false;
337
+ }
338
+ var color5 = resolveColor(raw5, config);
339
+ if (color5 == null) return void 0;
340
+ emit(sink, "__ringOffsetColor", color5, modifiers);
341
+ return false;
342
+ }
343
+ if (kind === "image") {
344
+ var dir = linearTo[core.slice(13)];
345
+ if (!dir) return true;
346
+ emit(sink, "__gradientDirection", dir, modifiers);
347
+ return false;
348
+ }
349
+ if (kind === "from" || kind === "via" || kind === "to") {
350
+ var raw6 = core.slice(kind.length + 1);
351
+ var prop1 = kind === "from" ? "__gradientFrom" : kind === "via" ? "__gradientVia" : "__gradientTo";
352
+ if (/^\d+(?:\.\d+)?%$/.test(raw6)) {
353
+ emit(sink, `${prop1}Position`, raw6, modifiers);
354
+ return false;
355
+ }
356
+ var color6 = resolveColor(raw6, config);
357
+ if (color6 == null) return true;
358
+ emit(sink, prop1, color6, modifiers);
359
+ return false;
360
+ }
361
+ if (core === "ring") {
362
+ emit(sink, "__ring", "1px", modifiers);
363
+ return false;
364
+ }
365
+ if (core === "ring-inset") {
366
+ emit(sink, "__ringInset", true, modifiers);
367
+ return false;
368
+ }
369
+ var raw7 = core.slice(5);
370
+ var width2 = ringWidth(raw7);
371
+ if (width2 != null) {
372
+ emit(sink, "__ring", width2, modifiers);
373
+ return false;
374
+ }
375
+ var color7 = resolveColor(raw7, config);
376
+ if (color7 == null) return true;
377
+ emit(sink, "__ringColor", color7, modifiers);
378
+ return false;
379
+ }
380
+ function noteTailwindTransform(sink, entry) {
381
+ if (!transformProps.has(entry[0])) return false;
382
+ emit(sink, `__transform_${entry[0]}`, entry[1], entry[3] || []);
383
+ return true;
384
+ }
385
+ function noteBoxShadow(sink, value, modifiers) {
386
+ if (typeof value !== "string" || value === "unset") return;
387
+ if (value.indexOf(" ") === -1 && value !== "none" && !value.startsWith("inset")) return;
388
+ emit(sink, "__shadow", value, modifiers);
389
+ }