@tamagui/tailwind 0.0.0-bootstrap.0 → 3.0.0-beta.643.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.
Files changed (77) hide show
  1. package/dist/cjs/candidate.cjs +385 -0
  2. package/dist/cjs/candidate.native.cjs +431 -0
  3. package/dist/cjs/candidate.native.js +433 -0
  4. package/dist/cjs/candidate.native.js.map +1 -0
  5. package/dist/cjs/frontend.cjs +80 -0
  6. package/dist/cjs/frontend.native.cjs +95 -0
  7. package/dist/cjs/frontend.native.js +97 -0
  8. package/dist/cjs/frontend.native.js.map +1 -0
  9. package/dist/cjs/index.cjs +39 -0
  10. package/dist/cjs/index.native.cjs +41 -0
  11. package/dist/cjs/index.native.js +43 -0
  12. package/dist/cjs/index.native.js.map +1 -0
  13. package/dist/cjs/styled.cjs +30 -0
  14. package/dist/cjs/styled.native.cjs +32 -0
  15. package/dist/cjs/styled.native.js +34 -0
  16. package/dist/cjs/styled.native.js.map +1 -0
  17. package/dist/cjs/types.cjs +17 -0
  18. package/dist/cjs/types.native.cjs +19 -0
  19. package/dist/cjs/types.native.js +21 -0
  20. package/dist/cjs/types.native.js.map +1 -0
  21. package/dist/cjs/vite/state.cjs +249 -0
  22. package/dist/cjs/vite/state.native.cjs +331 -0
  23. package/dist/cjs/vite/state.native.js +333 -0
  24. package/dist/cjs/vite/state.native.js.map +1 -0
  25. package/dist/cjs/vite.cjs +148 -0
  26. package/dist/cjs/vite.native.cjs +188 -0
  27. package/dist/cjs/vite.native.js +190 -0
  28. package/dist/cjs/vite.native.js.map +1 -0
  29. package/dist/esm/candidate.mjs +360 -0
  30. package/dist/esm/candidate.mjs.map +1 -0
  31. package/dist/esm/candidate.native.js +404 -0
  32. package/dist/esm/candidate.native.js.map +1 -0
  33. package/dist/esm/frontend.mjs +57 -0
  34. package/dist/esm/frontend.mjs.map +1 -0
  35. package/dist/esm/frontend.native.js +70 -0
  36. package/dist/esm/frontend.native.js.map +1 -0
  37. package/dist/esm/index.mjs +11 -0
  38. package/dist/esm/index.mjs.map +1 -0
  39. package/dist/esm/index.native.js +11 -0
  40. package/dist/esm/index.native.js.map +1 -0
  41. package/dist/esm/styled.mjs +10 -0
  42. package/dist/esm/styled.mjs.map +1 -0
  43. package/dist/esm/styled.native.js +10 -0
  44. package/dist/esm/styled.native.js.map +1 -0
  45. package/dist/esm/types.mjs +0 -0
  46. package/dist/esm/types.native.js +0 -0
  47. package/dist/esm/vite/state.mjs +215 -0
  48. package/dist/esm/vite/state.mjs.map +1 -0
  49. package/dist/esm/vite/state.native.js +295 -0
  50. package/dist/esm/vite/state.native.js.map +1 -0
  51. package/dist/esm/vite.mjs +116 -0
  52. package/dist/esm/vite.mjs.map +1 -0
  53. package/dist/esm/vite.native.js +154 -0
  54. package/dist/esm/vite.native.js.map +1 -0
  55. package/package.json +88 -5
  56. package/src/candidate.ts +527 -0
  57. package/src/frontend.ts +116 -0
  58. package/src/index.tsx +24 -0
  59. package/src/styled.tsx +52 -0
  60. package/src/types.ts +226 -0
  61. package/src/vite/state.ts +274 -0
  62. package/src/vite.ts +204 -0
  63. package/types/candidate.d.ts +23 -0
  64. package/types/candidate.d.ts.map +1 -0
  65. package/types/frontend.d.ts +20 -0
  66. package/types/frontend.d.ts.map +1 -0
  67. package/types/index.d.ts +8 -0
  68. package/types/index.d.ts.map +1 -0
  69. package/types/styled.d.ts +12 -0
  70. package/types/styled.d.ts.map +1 -0
  71. package/types/types.d.ts +158 -0
  72. package/types/types.d.ts.map +1 -0
  73. package/types/vite/state.d.ts +28 -0
  74. package/types/vite/state.d.ts.map +1 -0
  75. package/types/vite.d.ts +20 -0
  76. package/types/vite.d.ts.map +1 -0
  77. package/README.md +0 -1
@@ -0,0 +1,431 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var candidate_exports = {};
25
+ __export(candidate_exports, {
26
+ getStyleGrammarConfig: () => getStyleGrammarConfig,
27
+ isTokenValueProp: () => isTokenValueProp,
28
+ preprocessTailwindClassName: () => preprocessTailwindClassName,
29
+ setInAuthoredOrder: () => setInAuthoredOrder
30
+ });
31
+ module.exports = __toCommonJS(candidate_exports);
32
+ var import_constants = require("@tamagui/constants");
33
+ var import_internal_runtime = require("@tamagui/core/internal-runtime");
34
+ var import_runtime = require("@tamagui/style-grammar/runtime");
35
+ var styleGrammarConfigCache = /* @__PURE__ */ new WeakMap();
36
+ function getStyleGrammarConfig(config) {
37
+ var cached = styleGrammarConfigCache.get(config);
38
+ if (cached) return cached;
39
+ var view = (0, import_runtime.createGrammarConfigView)(config);
40
+ styleGrammarConfigCache.set(config, view);
41
+ return view;
42
+ }
43
+ function isTokenValueProp(prop) {
44
+ return (0, import_runtime.getTokenCategory)(prop) !== null;
45
+ }
46
+ function arbitraryValue(inner) {
47
+ var px = /^(-?\d*\.?\d+)px$/.exec(inner);
48
+ if (px) return Number(px[1]);
49
+ if (/^-?\d*\.?\d+$/.test(inner)) return Number(inner);
50
+ return inner;
51
+ }
52
+ function tailwindSizingValue(prop, value) {
53
+ if (value === "full") return "100%";
54
+ if (value === "auto") return "auto";
55
+ if (value === "screen") return /[Hh]eight/.test(prop) ? "100vh" : "100vw";
56
+ if (value === "min") return "min-content";
57
+ if (value === "max") return "max-content";
58
+ if (value === "fit") return "fit-content";
59
+ var frac = /^(\d+)\/(\d+)$/.exec(value);
60
+ if (frac && Number(frac[2]) !== 0) {
61
+ return `${Number(frac[1]) / Number(frac[2]) * 100}%`;
62
+ }
63
+ return null;
64
+ }
65
+ function borderDimValue(raw) {
66
+ var inner = raw;
67
+ if (raw.length > 1 && raw[0] === "[" && raw[raw.length - 1] === "]") {
68
+ inner = (0, import_runtime.decodeArbitrary)(raw.slice(1, -1));
69
+ }
70
+ var px = /^(-?\d*\.?\d+)px$/.exec(inner);
71
+ if (px) return Number.parseFloat(px[1]);
72
+ if (/^-?\d*\.?\d+$/.test(inner)) return Number(inner);
73
+ return inner;
74
+ }
75
+ function expandBorderCandidate(parsed, value) {
76
+ var _parsed_entry;
77
+ var prefix = parsed.prefix;
78
+ if (!prefix) return null;
79
+ if (prefix.startsWith("rounded-")) {
80
+ var props = import_runtime.radiusCornerProps[prefix.slice("rounded-".length)];
81
+ if (!props || props.length === 1) return null;
82
+ var out = {};
83
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
84
+ try {
85
+ for (var _iterator = props[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
86
+ var p = _step.value;
87
+ out[p] = value;
88
+ }
89
+ } catch (err) {
90
+ _didIteratorError = true;
91
+ _iteratorError = err;
92
+ } finally {
93
+ try {
94
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
95
+ _iterator.return();
96
+ }
97
+ } finally {
98
+ if (_didIteratorError) {
99
+ throw _iteratorError;
100
+ }
101
+ }
102
+ }
103
+ return out;
104
+ }
105
+ var m = /^border-([trblxy])$/.exec(prefix);
106
+ if (!m) return null;
107
+ var sides = import_runtime.borderSideSuffix[m[1]];
108
+ var suffix = ((_parsed_entry = parsed.entry) === null || _parsed_entry === void 0 ? void 0 : _parsed_entry.prop.endsWith("Width")) ? "Width" : "Color";
109
+ var out1 = {};
110
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
111
+ try {
112
+ for (var _iterator1 = sides[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
113
+ var side = _step1.value;
114
+ out1[`border${side}${suffix}`] = value;
115
+ }
116
+ } catch (err) {
117
+ _didIteratorError1 = true;
118
+ _iteratorError1 = err;
119
+ } finally {
120
+ try {
121
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
122
+ _iterator1.return();
123
+ }
124
+ } finally {
125
+ if (_didIteratorError1) {
126
+ throw _iteratorError1;
127
+ }
128
+ }
129
+ }
130
+ return out1;
131
+ }
132
+ function tailwindClassToFlatProp(parsed) {
133
+ var _parsed_prefix;
134
+ if (parsed.kind !== "dynamic" || !parsed.entry || parsed.rawValue === void 0) {
135
+ return null;
136
+ }
137
+ var prop = parsed.entry.prop;
138
+ var category = parsed.entry.tokenCategory;
139
+ var value = parsed.rawValue;
140
+ if (prop.endsWith("Width") && ((_parsed_prefix = parsed.prefix) === null || _parsed_prefix === void 0 ? void 0 : _parsed_prefix.startsWith("border"))) {
141
+ if (parsed.valueKind === "token") {
142
+ value = `${parsed.negative ? "-" : ""}${value}`;
143
+ } else if (parsed.valueKind === "arbitrary") {
144
+ value = borderDimValue(value);
145
+ } else {
146
+ return null;
147
+ }
148
+ return {
149
+ key: prop,
150
+ value
151
+ };
152
+ }
153
+ if (prop === "fontFamily") {
154
+ var famValue;
155
+ if (value.length > 2 && value[0] === "[" && value[value.length - 1] === "]") {
156
+ famValue = (0, import_runtime.decodeArbitrary)(value.slice(1, -1));
157
+ } else {
158
+ var generic = {
159
+ sans: "sans-serif",
160
+ serif: "serif",
161
+ mono: "monospace"
162
+ };
163
+ famValue = parsed.valueKind === "token" ? value : generic[value] || value;
164
+ }
165
+ return {
166
+ key: "fontFamily",
167
+ value: famValue
168
+ };
169
+ }
170
+ if (prop === "fontSize") {
171
+ var fsValue;
172
+ if (value.length > 2 && value[0] === "[" && value[value.length - 1] === "]") {
173
+ fsValue = arbitraryValue((0, import_runtime.decodeArbitrary)(value.slice(1, -1)));
174
+ } else {
175
+ fsValue = value;
176
+ }
177
+ return {
178
+ key: "fontSize",
179
+ value: fsValue
180
+ };
181
+ }
182
+ if (prop === "lineHeight") {
183
+ var lhValue;
184
+ if (value.length > 2 && value[0] === "[" && value[value.length - 1] === "]") {
185
+ var inner = (0, import_runtime.decodeArbitrary)(value.slice(1, -1));
186
+ lhValue = /^-?\d*\.?\d+px$/.test(inner) ? Number.parseFloat(inner) : inner;
187
+ } else {
188
+ lhValue = value;
189
+ }
190
+ return {
191
+ key: "lineHeight",
192
+ value: lhValue
193
+ };
194
+ }
195
+ if (prop === "letterSpacing") {
196
+ var lsValue;
197
+ if (value.length > 2 && value[0] === "[" && value[value.length - 1] === "]") {
198
+ lsValue = arbitraryValue((0, import_runtime.decodeArbitrary)(value.slice(1, -1)));
199
+ } else {
200
+ lsValue = value;
201
+ }
202
+ return {
203
+ key: "letterSpacing",
204
+ value: lsValue
205
+ };
206
+ }
207
+ if (prop === "boxShadow" && value[0] === "[" && value[value.length - 1] === "]") {
208
+ return {
209
+ key: "boxShadow",
210
+ value: (0, import_runtime.decodeArbitrary)(value.slice(1, -1))
211
+ };
212
+ }
213
+ if (value.length > 2 && value[0] === "[" && value[value.length - 1] === "]") {
214
+ var inner1 = (0, import_runtime.decodeArbitrary)(value.slice(1, -1));
215
+ if (inner1 === "") return null;
216
+ return {
217
+ key: prop,
218
+ value: arbitraryValue(inner1)
219
+ };
220
+ }
221
+ if (category === "size" && parsed.valueKind !== "token") {
222
+ var sized = tailwindSizingValue(prop, value);
223
+ if (sized != null) {
224
+ return {
225
+ key: prop,
226
+ value: sized
227
+ };
228
+ }
229
+ }
230
+ var opacitySuffix = "";
231
+ if (category === "color" && typeof value === "string") {
232
+ var suffix = (0, import_runtime.splitColorOpacitySuffix)(value);
233
+ if (suffix.kind === "invalid") {
234
+ return {
235
+ key: prop,
236
+ value
237
+ };
238
+ }
239
+ if (suffix.kind === "valid") {
240
+ opacitySuffix = value.slice(suffix.name.length);
241
+ value = suffix.name;
242
+ }
243
+ }
244
+ if (import_runtime.percentUtilityProps.has(prop) && /^\d+$/.test(value)) {
245
+ value = Number(value) / 100;
246
+ } else if (/^\d+(\.\d+)?$/.test(value)) {
247
+ if (category === "zIndex" && parsed.valueKind === "convenience") {
248
+ value = Number(value);
249
+ } else if (category) {
250
+ value = `${parsed.negative ? "-" : ""}${value}`;
251
+ } else {
252
+ value = Number(value);
253
+ }
254
+ } else if (typeof value === "string") {
255
+ if (category && !((category === "space" || category === "size" || category === "radius") && (0, import_runtime.getSafeAreaEdge)(value))) {
256
+ value = `${parsed.negative ? "-" : ""}${value}`;
257
+ }
258
+ }
259
+ if (opacitySuffix && typeof value === "string") {
260
+ value = `${value}${opacitySuffix}`;
261
+ }
262
+ if (parsed.negative && !category) {
263
+ if (typeof value === "number") value = -value;
264
+ else if (typeof value === "string" && value[0] !== "-") value = `-${value}`;
265
+ }
266
+ return {
267
+ key: prop,
268
+ value
269
+ };
270
+ }
271
+ var classPlanCache = /* @__PURE__ */ new WeakMap();
272
+ function getClassPlanCache(grammarConfig) {
273
+ var cache = classPlanCache.get(grammarConfig);
274
+ if (!cache) {
275
+ cache = /* @__PURE__ */ new Map();
276
+ classPlanCache.set(grammarConfig, cache);
277
+ }
278
+ return cache;
279
+ }
280
+ function createPlanEntry(property, value, modifiers) {
281
+ if (modifiers.length === 0) return [property, value];
282
+ var payload = (0, import_internal_runtime.plainValueToPayload)(value, property);
283
+ if (payload === null) return null;
284
+ return [null, (0, import_internal_runtime.createFrontendProgram)(property, {
285
+ base: null,
286
+ clauses: [{
287
+ modifiers,
288
+ payload
289
+ }]
290
+ })];
291
+ }
292
+ function computeClassPlan(cls, grammarConfig) {
293
+ var groupMarker = /^group(?:\/([A-Za-z0-9_-]+))?$/.exec(cls);
294
+ if (groupMarker) {
295
+ return {
296
+ entries: [["group", groupMarker[1] || true]],
297
+ preserveRawClass: import_constants.isWeb
298
+ };
299
+ }
300
+ var containerMarker = /^@container(-size)?(?:\/([A-Za-z0-9_-]+))?$/.exec(cls);
301
+ if (containerMarker) {
302
+ var isSize = containerMarker[1] !== void 0;
303
+ var name = containerMarker[2];
304
+ var entries = [];
305
+ if (name) entries.push(["containerName", name]);
306
+ if (isSize) {
307
+ entries.push(["containerType", "size"]);
308
+ } else if (name) {
309
+ entries.push(["containerType", "inline-size"]);
310
+ } else {
311
+ entries.push(["container", true]);
312
+ }
313
+ return {
314
+ entries,
315
+ preserveRawClass: import_constants.isWeb
316
+ };
317
+ }
318
+ var classification = (0, import_runtime.classifyCandidate)(cls, grammarConfig);
319
+ if (classification.kind === "passthrough") {
320
+ return import_constants.isWeb ? "raw" : null;
321
+ }
322
+ var parsed = classification.parsed;
323
+ var util = parsed.kind === "utility" ? parsed.properties : null;
324
+ if (util) {
325
+ var entries1 = [];
326
+ for (var p in util) {
327
+ var entry = createPlanEntry(p, util[p], parsed.modifiers);
328
+ if (!entry) return "raw";
329
+ entries1.push(entry);
330
+ }
331
+ return entries1;
332
+ }
333
+ var flatProp = tailwindClassToFlatProp(parsed);
334
+ if (flatProp) {
335
+ var expanded = expandBorderCandidate(parsed, flatProp.value);
336
+ if (expanded) {
337
+ var entries2 = [];
338
+ for (var p1 in expanded) {
339
+ var entry1 = createPlanEntry(p1, expanded[p1], parsed.modifiers);
340
+ if (!entry1) return "raw";
341
+ entries2.push(entry1);
342
+ }
343
+ return entries2;
344
+ }
345
+ var entry2 = createPlanEntry(flatProp.key, flatProp.value, parsed.modifiers);
346
+ return entry2 ? [entry2] : "raw";
347
+ }
348
+ return "raw";
349
+ }
350
+ var warnedNativePassthroughCandidates = /* @__PURE__ */ new Set();
351
+ function setInAuthoredOrder(target, key, value) {
352
+ if (key in target) delete target[key];
353
+ target[key] = value;
354
+ }
355
+ function preprocessTailwindClassName(props, config) {
356
+ var preservePassthroughPosition = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
357
+ var className = props.className;
358
+ if (!className || typeof className !== "string") {
359
+ return props;
360
+ }
361
+ var classes = className.split(/\s+/).filter(Boolean);
362
+ var result = {};
363
+ var grammarConfig = getStyleGrammarConfig(config);
364
+ var plans = getClassPlanCache(grammarConfig);
365
+ var classPlans = classes.map(function(cls2) {
366
+ var plan2 = plans.get(cls2);
367
+ if (plan2 === void 0) {
368
+ plan2 = computeClassPlan(cls2, grammarConfig);
369
+ plans.set(cls2, plan2);
370
+ }
371
+ return plan2;
372
+ });
373
+ var hasOwnedStyleCandidate = preservePassthroughPosition && classPlans.some(function(plan2) {
374
+ return Array.isArray(plan2);
375
+ });
376
+ var frontendProgramIndex = 0;
377
+ var passthroughIndex = 0;
378
+ var regularClasses = [];
379
+ var preserveRawClass = function(cls2) {
380
+ if (hasOwnedStyleCandidate) {
381
+ result[`${import_internal_runtime.STYLE_FRONTEND_PASSTHROUGH_PREFIX}${passthroughIndex++}`] = cls2;
382
+ } else {
383
+ regularClasses.push(cls2);
384
+ }
385
+ };
386
+ var applyEntry = function(param) {
387
+ var [key2, value] = param;
388
+ if (key2 === null) {
389
+ result[`__tamagui_frontend_program_${frontendProgramIndex++}`] = value;
390
+ } else {
391
+ setInAuthoredOrder(result, key2, value);
392
+ }
393
+ };
394
+ for (var key in props) {
395
+ if (key !== "className") {
396
+ setInAuthoredOrder(result, key, props[key]);
397
+ continue;
398
+ }
399
+ for (var classIndex = 0; classIndex < classes.length; classIndex++) {
400
+ var cls = classes[classIndex];
401
+ var plan = classPlans[classIndex];
402
+ if (plan === null) {
403
+ if (process.env.NODE_ENV !== "production" && !warnedNativePassthroughCandidates.has(cls)) {
404
+ warnedNativePassthroughCandidates.add(cls);
405
+ console.warn(`[tamagui] Tailwind candidate "${cls}" is web-only and was dropped on native. Use a Tamagui grammar candidate or a native style prop for cross-platform output.`);
406
+ }
407
+ continue;
408
+ }
409
+ if (plan === "raw") {
410
+ preserveRawClass(cls);
411
+ continue;
412
+ }
413
+ if (!Array.isArray(plan)) {
414
+ if (plan.preserveRawClass) {
415
+ preserveRawClass(cls);
416
+ }
417
+ for (var i = 0; i < plan.entries.length; i++) {
418
+ applyEntry(plan.entries[i]);
419
+ }
420
+ continue;
421
+ }
422
+ for (var i1 = 0; i1 < plan.length; i1++) {
423
+ applyEntry(plan[i1]);
424
+ }
425
+ }
426
+ if (regularClasses.length > 0) {
427
+ result.className = regularClasses.join(" ");
428
+ }
429
+ }
430
+ return result;
431
+ }