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