motionwind-core 2.1.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/README.md +44 -0
- package/dist/adapter.cjs +31 -0
- package/dist/adapter.cjs.map +1 -0
- package/dist/adapter.d.cts +14 -0
- package/dist/adapter.d.ts +14 -0
- package/dist/adapter.js +3 -0
- package/dist/adapter.js.map +1 -0
- package/dist/chunk-A7EAMXLY.js +1098 -0
- package/dist/chunk-A7EAMXLY.js.map +1 -0
- package/dist/chunk-IJZCYKTO.js +352 -0
- package/dist/chunk-IJZCYKTO.js.map +1 -0
- package/dist/chunk-P6FC2RDE.js +25 -0
- package/dist/chunk-P6FC2RDE.js.map +1 -0
- package/dist/chunk-ULRTFOGX.js +28 -0
- package/dist/chunk-ULRTFOGX.js.map +1 -0
- package/dist/chunk-Z5I36REG.js +411 -0
- package/dist/chunk-Z5I36REG.js.map +1 -0
- package/dist/config.cjs +30 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -0
- package/dist/index.cjs +1970 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/parser.cjs +1690 -0
- package/dist/parser.cjs.map +1 -0
- package/dist/parser.d.cts +21 -0
- package/dist/parser.d.ts +21 -0
- package/dist/parser.js +6 -0
- package/dist/parser.js.map +1 -0
- package/dist/recipes.cjs +359 -0
- package/dist/recipes.cjs.map +1 -0
- package/dist/recipes.d.cts +19 -0
- package/dist/recipes.d.ts +19 -0
- package/dist/recipes.js +4 -0
- package/dist/recipes.js.map +1 -0
- package/dist/registry.cjs +421 -0
- package/dist/registry.cjs.map +1 -0
- package/dist/registry.d.cts +1 -0
- package/dist/registry.d.ts +1 -0
- package/dist/registry.js +3 -0
- package/dist/registry.js.map +1 -0
- package/dist/types-BYtWWSgh.d.cts +185 -0
- package/dist/types-BYtWWSgh.d.ts +185 -0
- package/llms.txt +77 -0
- package/package.json +96 -0
|
@@ -0,0 +1,1098 @@
|
|
|
1
|
+
import { GESTURE_KEYS, GESTURE_MAP, EASING_MAP } from './chunk-Z5I36REG.js';
|
|
2
|
+
import { BUILT_IN_PRESETS } from './chunk-IJZCYKTO.js';
|
|
3
|
+
|
|
4
|
+
// src/parser.ts
|
|
5
|
+
var CACHE_MAX = 1e3;
|
|
6
|
+
var cache = /* @__PURE__ */ new Map();
|
|
7
|
+
function presetClasses(value) {
|
|
8
|
+
return (typeof value === "string" ? value.split(/\s+/) : [...value]).filter(
|
|
9
|
+
Boolean
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
function availablePresets(config) {
|
|
13
|
+
const pluginPresets = Object.assign(
|
|
14
|
+
{},
|
|
15
|
+
...(config?.plugins ?? []).map((plugin) => plugin.presets ?? {})
|
|
16
|
+
);
|
|
17
|
+
return { ...BUILT_IN_PRESETS, ...pluginPresets, ...config?.presets ?? {} };
|
|
18
|
+
}
|
|
19
|
+
function expandConfiguredTokens(className, config, diagnostics) {
|
|
20
|
+
const presets = availablePresets(config);
|
|
21
|
+
const output = [];
|
|
22
|
+
const expand = (token, stack) => {
|
|
23
|
+
if (!token.startsWith("animate-preset-")) {
|
|
24
|
+
const durationName = token.startsWith("animate-duration-") ? token.slice("animate-duration-".length) : "";
|
|
25
|
+
const duration = durationName ? config?.tokens?.durations?.[durationName] : void 0;
|
|
26
|
+
if (duration !== void 0) {
|
|
27
|
+
output.push(`animate-duration-${duration}`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const easingName = token.startsWith("animate-ease-") ? token.slice("animate-ease-".length) : "";
|
|
31
|
+
const easing = easingName ? config?.tokens?.easings?.[easingName] : void 0;
|
|
32
|
+
if (Array.isArray(easing)) {
|
|
33
|
+
output.push(`animate-ease-[${easing.join(",")}]`);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const springName = token.startsWith("animate-spring-") ? token.slice("animate-spring-".length) : "";
|
|
37
|
+
const spring = springName ? config?.tokens?.springs?.[springName] : void 0;
|
|
38
|
+
if (spring) {
|
|
39
|
+
output.push("animate-spring");
|
|
40
|
+
if (spring.stiffness !== void 0)
|
|
41
|
+
output.push(`animate-stiffness-${spring.stiffness}`);
|
|
42
|
+
if (spring.damping !== void 0)
|
|
43
|
+
output.push(`animate-damping-${spring.damping}`);
|
|
44
|
+
if (spring.bounce !== void 0)
|
|
45
|
+
output.push(`animate-bounce-${spring.bounce}`);
|
|
46
|
+
if (spring.mass !== void 0)
|
|
47
|
+
output.push(`animate-mass-${spring.mass}`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
output.push(token);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const name = token.slice("animate-preset-".length);
|
|
54
|
+
const preset = presets[name];
|
|
55
|
+
if (!preset) {
|
|
56
|
+
diagnostics.push({
|
|
57
|
+
code: "unknown-preset",
|
|
58
|
+
message: `Unknown motionwind preset "${name}".`,
|
|
59
|
+
severity: config?.strict ? "error" : "warning",
|
|
60
|
+
token
|
|
61
|
+
});
|
|
62
|
+
output.push(token);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (stack.includes(name) || stack.length >= 8) {
|
|
66
|
+
diagnostics.push({
|
|
67
|
+
code: "circular-preset",
|
|
68
|
+
message: `Circular motionwind preset expansion: ${[...stack, name].join(" \u2192 ")}.`,
|
|
69
|
+
severity: "error",
|
|
70
|
+
token
|
|
71
|
+
});
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
for (const expanded of presetClasses(preset))
|
|
75
|
+
expand(expanded, [...stack, name]);
|
|
76
|
+
};
|
|
77
|
+
for (const token of className.split(/\s+/).filter(Boolean)) expand(token, []);
|
|
78
|
+
return output;
|
|
79
|
+
}
|
|
80
|
+
function mergePatch(patch, gestures, transition, viewport, dragConfig, layoutConfig, scroll, variants, variantState) {
|
|
81
|
+
for (const [key, values] of Object.entries(patch.gestures ?? {})) {
|
|
82
|
+
gestures[key] = {
|
|
83
|
+
...gestures[key] ?? {},
|
|
84
|
+
...values ?? {}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
Object.assign(transition, patch.transition);
|
|
88
|
+
Object.assign(viewport, patch.viewport);
|
|
89
|
+
Object.assign(dragConfig, patch.dragConfig);
|
|
90
|
+
Object.assign(layoutConfig, patch.layoutConfig);
|
|
91
|
+
if (patch.scroll) {
|
|
92
|
+
Object.assign(scroll, patch.scroll);
|
|
93
|
+
if (patch.scroll.values)
|
|
94
|
+
scroll.values = { ...scroll.values, ...patch.scroll.values };
|
|
95
|
+
}
|
|
96
|
+
for (const [name, values] of Object.entries(patch.variants ?? {})) {
|
|
97
|
+
variants[name] = { ...variants[name] ?? {}, ...values };
|
|
98
|
+
}
|
|
99
|
+
Object.assign(variantState, patch.variantState);
|
|
100
|
+
}
|
|
101
|
+
var TAILWIND_ANIMATE_CLASSES = /* @__PURE__ */ new Set([
|
|
102
|
+
"animate-spin",
|
|
103
|
+
"animate-ping",
|
|
104
|
+
"animate-pulse",
|
|
105
|
+
"animate-bounce",
|
|
106
|
+
"animate-none"
|
|
107
|
+
]);
|
|
108
|
+
function cacheSet(key, value) {
|
|
109
|
+
if (cache.size >= CACHE_MAX) {
|
|
110
|
+
const firstKey = cache.keys().next().value;
|
|
111
|
+
if (firstKey !== void 0) cache.delete(firstKey);
|
|
112
|
+
}
|
|
113
|
+
cache.set(key, value);
|
|
114
|
+
}
|
|
115
|
+
var UNIT_MAP = {
|
|
116
|
+
pct: "%",
|
|
117
|
+
px: "px",
|
|
118
|
+
vh: "vh",
|
|
119
|
+
vw: "vw",
|
|
120
|
+
rem: "rem",
|
|
121
|
+
em: "em",
|
|
122
|
+
dvh: "dvh",
|
|
123
|
+
svh: "svh",
|
|
124
|
+
lvh: "lvh"
|
|
125
|
+
};
|
|
126
|
+
function parseNumericWithUnit(str, sign) {
|
|
127
|
+
if (str === "auto") return "auto";
|
|
128
|
+
for (const [suffix, unit] of Object.entries(UNIT_MAP)) {
|
|
129
|
+
if (str.endsWith(suffix)) {
|
|
130
|
+
const numPart = str.slice(0, -suffix.length);
|
|
131
|
+
const n2 = Number(numPart);
|
|
132
|
+
if (isNaN(n2)) return null;
|
|
133
|
+
return `${n2 * sign}${unit}`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const n = Number(str);
|
|
137
|
+
if (isNaN(n)) return null;
|
|
138
|
+
return n * sign;
|
|
139
|
+
}
|
|
140
|
+
var ARBITRARY_VALUE_ALLOWLIST = /* @__PURE__ */ new Set([
|
|
141
|
+
"x",
|
|
142
|
+
"y",
|
|
143
|
+
"z",
|
|
144
|
+
"scale",
|
|
145
|
+
"scaleX",
|
|
146
|
+
"scaleY",
|
|
147
|
+
"scaleZ",
|
|
148
|
+
"rotate",
|
|
149
|
+
"rotateX",
|
|
150
|
+
"rotateY",
|
|
151
|
+
"rotateZ",
|
|
152
|
+
"skew",
|
|
153
|
+
"skewX",
|
|
154
|
+
"skewY",
|
|
155
|
+
"originX",
|
|
156
|
+
"originY",
|
|
157
|
+
"originZ",
|
|
158
|
+
"perspective",
|
|
159
|
+
"opacity",
|
|
160
|
+
"filter",
|
|
161
|
+
"backdropFilter",
|
|
162
|
+
"clipPath",
|
|
163
|
+
"width",
|
|
164
|
+
"height",
|
|
165
|
+
"top",
|
|
166
|
+
"left",
|
|
167
|
+
"right",
|
|
168
|
+
"bottom",
|
|
169
|
+
"padding",
|
|
170
|
+
"margin",
|
|
171
|
+
"gap",
|
|
172
|
+
"borderRadius",
|
|
173
|
+
"borderTopLeftRadius",
|
|
174
|
+
"borderTopRightRadius",
|
|
175
|
+
"borderBottomLeftRadius",
|
|
176
|
+
"borderBottomRightRadius",
|
|
177
|
+
"borderWidth",
|
|
178
|
+
"fontSize",
|
|
179
|
+
"letterSpacing",
|
|
180
|
+
"lineHeight",
|
|
181
|
+
"backgroundColor",
|
|
182
|
+
"color",
|
|
183
|
+
"borderColor",
|
|
184
|
+
"boxShadow",
|
|
185
|
+
"textShadow",
|
|
186
|
+
"zIndex",
|
|
187
|
+
"pathLength",
|
|
188
|
+
"pathOffset",
|
|
189
|
+
"pathSpacing"
|
|
190
|
+
]);
|
|
191
|
+
function parsePropertyValue(raw) {
|
|
192
|
+
if (raw.startsWith("[") && raw.endsWith("]")) {
|
|
193
|
+
const inner = raw.slice(1, -1);
|
|
194
|
+
const eqIdx = inner.indexOf("=");
|
|
195
|
+
if (eqIdx === -1) return null;
|
|
196
|
+
const key = inner.slice(0, eqIdx);
|
|
197
|
+
if (!ARBITRARY_VALUE_ALLOWLIST.has(key)) return null;
|
|
198
|
+
const val = inner.slice(eqIdx + 1);
|
|
199
|
+
const num = Number(val);
|
|
200
|
+
return { key, value: isNaN(num) ? val : num };
|
|
201
|
+
}
|
|
202
|
+
let negative = false;
|
|
203
|
+
let str = raw;
|
|
204
|
+
if (str.startsWith("-")) {
|
|
205
|
+
negative = true;
|
|
206
|
+
str = str.slice(1);
|
|
207
|
+
}
|
|
208
|
+
const sign = negative ? -1 : 1;
|
|
209
|
+
const keyframeMatch = str.match(/^(\w+(?:-\w+)?)-\[([^\]]+)\]$/);
|
|
210
|
+
if (keyframeMatch) {
|
|
211
|
+
const propName = keyframeMatch[1];
|
|
212
|
+
const valuesStr = keyframeMatch[2];
|
|
213
|
+
const propKey = normalizePropertyName(propName);
|
|
214
|
+
if (propKey) {
|
|
215
|
+
const rawValues = valuesStr.split(",").reduce((acc, v) => {
|
|
216
|
+
const t = v.trim();
|
|
217
|
+
if (t) acc.push(t);
|
|
218
|
+
return acc;
|
|
219
|
+
}, []);
|
|
220
|
+
if (rawValues.length > 0) {
|
|
221
|
+
const scaleProps = /* @__PURE__ */ new Set([
|
|
222
|
+
"scale",
|
|
223
|
+
"scaleX",
|
|
224
|
+
"scaleY",
|
|
225
|
+
"scaleZ",
|
|
226
|
+
"opacity",
|
|
227
|
+
"brightness",
|
|
228
|
+
"contrast",
|
|
229
|
+
"saturate"
|
|
230
|
+
]);
|
|
231
|
+
const parsed = [];
|
|
232
|
+
let valid = true;
|
|
233
|
+
for (const rv of rawValues) {
|
|
234
|
+
const unitVal = parseNumericWithUnit(rv, 1);
|
|
235
|
+
if (unitVal === null) {
|
|
236
|
+
valid = false;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
if (typeof unitVal === "number" && scaleProps.has(propKey)) {
|
|
240
|
+
parsed.push(unitVal / 100);
|
|
241
|
+
} else {
|
|
242
|
+
parsed.push(unitVal);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (valid) {
|
|
246
|
+
return { key: propKey, value: parsed };
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (str.startsWith("scale-z-")) {
|
|
252
|
+
const n = Number(str.slice(8));
|
|
253
|
+
if (!isNaN(n)) return { key: "scaleZ", value: n / 100 * sign };
|
|
254
|
+
}
|
|
255
|
+
if (str.startsWith("scale-x-")) {
|
|
256
|
+
const n = Number(str.slice(8));
|
|
257
|
+
if (!isNaN(n)) return { key: "scaleX", value: n / 100 * sign };
|
|
258
|
+
}
|
|
259
|
+
if (str.startsWith("scale-y-")) {
|
|
260
|
+
const n = Number(str.slice(8));
|
|
261
|
+
if (!isNaN(n)) return { key: "scaleY", value: n / 100 * sign };
|
|
262
|
+
}
|
|
263
|
+
if (str.startsWith("scale-")) {
|
|
264
|
+
const n = Number(str.slice(6));
|
|
265
|
+
if (!isNaN(n)) return { key: "scale", value: n / 100 * sign };
|
|
266
|
+
}
|
|
267
|
+
if (str.startsWith("rotate-x-")) {
|
|
268
|
+
const n = Number(str.slice(9));
|
|
269
|
+
if (!isNaN(n)) return { key: "rotateX", value: n * sign };
|
|
270
|
+
}
|
|
271
|
+
if (str.startsWith("rotate-y-")) {
|
|
272
|
+
const n = Number(str.slice(9));
|
|
273
|
+
if (!isNaN(n)) return { key: "rotateY", value: n * sign };
|
|
274
|
+
}
|
|
275
|
+
if (str.startsWith("rotate-")) {
|
|
276
|
+
const n = Number(str.slice(7));
|
|
277
|
+
if (!isNaN(n)) return { key: "rotate", value: n * sign };
|
|
278
|
+
}
|
|
279
|
+
if (str.startsWith("skew-x-")) {
|
|
280
|
+
const n = Number(str.slice(7));
|
|
281
|
+
if (!isNaN(n)) return { key: "skewX", value: n * sign };
|
|
282
|
+
}
|
|
283
|
+
if (str.startsWith("skew-y-")) {
|
|
284
|
+
const n = Number(str.slice(7));
|
|
285
|
+
if (!isNaN(n)) return { key: "skewY", value: n * sign };
|
|
286
|
+
}
|
|
287
|
+
if (str.startsWith("skew-")) {
|
|
288
|
+
const n = Number(str.slice(5));
|
|
289
|
+
if (!isNaN(n)) return { key: "skew", value: n * sign };
|
|
290
|
+
}
|
|
291
|
+
if (str.startsWith("origin-x-")) {
|
|
292
|
+
const n = Number(str.slice(9));
|
|
293
|
+
if (!isNaN(n)) return { key: "originX", value: n / 100 * sign };
|
|
294
|
+
}
|
|
295
|
+
if (str.startsWith("origin-y-")) {
|
|
296
|
+
const n = Number(str.slice(9));
|
|
297
|
+
if (!isNaN(n)) return { key: "originY", value: n / 100 * sign };
|
|
298
|
+
}
|
|
299
|
+
if (str.startsWith("origin-z-")) {
|
|
300
|
+
const n = Number(str.slice(9));
|
|
301
|
+
if (!isNaN(n)) return { key: "originZ", value: n * sign };
|
|
302
|
+
}
|
|
303
|
+
if (str.startsWith("perspective-")) {
|
|
304
|
+
const n = Number(str.slice(12));
|
|
305
|
+
if (!isNaN(n)) return { key: "perspective", value: n * sign };
|
|
306
|
+
}
|
|
307
|
+
if (str.startsWith("x-")) {
|
|
308
|
+
const val = parseNumericWithUnit(str.slice(2), sign);
|
|
309
|
+
if (val !== null) return { key: "x", value: val };
|
|
310
|
+
}
|
|
311
|
+
if (str.startsWith("y-")) {
|
|
312
|
+
const val = parseNumericWithUnit(str.slice(2), sign);
|
|
313
|
+
if (val !== null) return { key: "y", value: val };
|
|
314
|
+
}
|
|
315
|
+
if (str.startsWith("z-")) {
|
|
316
|
+
const suffix = str.slice(2);
|
|
317
|
+
if (suffix === "auto") return { key: "zIndex", value: "auto" };
|
|
318
|
+
const zn = Number(suffix);
|
|
319
|
+
if (!isNaN(zn) && [0, 10, 20, 30, 40, 50].includes(zn))
|
|
320
|
+
return { key: "zIndex", value: zn };
|
|
321
|
+
}
|
|
322
|
+
if (str.startsWith("z-")) {
|
|
323
|
+
const val = parseNumericWithUnit(str.slice(2), sign);
|
|
324
|
+
if (val !== null) return { key: "z", value: val };
|
|
325
|
+
}
|
|
326
|
+
if (str.startsWith("opacity-")) {
|
|
327
|
+
const n = Number(str.slice(8));
|
|
328
|
+
if (!isNaN(n)) return { key: "opacity", value: n / 100 * sign };
|
|
329
|
+
}
|
|
330
|
+
if (str.startsWith("blur-")) {
|
|
331
|
+
const n = Number(str.slice(5));
|
|
332
|
+
if (!isNaN(n))
|
|
333
|
+
return { key: "filter", value: `blur(${Math.max(0, n * sign)}px)` };
|
|
334
|
+
}
|
|
335
|
+
if (str.startsWith("brightness-")) {
|
|
336
|
+
const n = Number(str.slice(11));
|
|
337
|
+
if (!isNaN(n))
|
|
338
|
+
return {
|
|
339
|
+
key: "filter",
|
|
340
|
+
value: `brightness(${Math.max(0, n / 100 * sign)})`
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
if (str.startsWith("contrast-")) {
|
|
344
|
+
const n = Number(str.slice(9));
|
|
345
|
+
if (!isNaN(n))
|
|
346
|
+
return {
|
|
347
|
+
key: "filter",
|
|
348
|
+
value: `contrast(${Math.max(0, n / 100 * sign)})`
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
if (str.startsWith("saturate-")) {
|
|
352
|
+
const n = Number(str.slice(9));
|
|
353
|
+
if (!isNaN(n))
|
|
354
|
+
return {
|
|
355
|
+
key: "filter",
|
|
356
|
+
value: `saturate(${Math.max(0, n / 100 * sign)})`
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
if (str.startsWith("grayscale-")) {
|
|
360
|
+
const n = Number(str.slice(10));
|
|
361
|
+
if (!isNaN(n))
|
|
362
|
+
return {
|
|
363
|
+
key: "filter",
|
|
364
|
+
value: `grayscale(${Math.max(0, n / 100 * sign)})`
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
if (str.startsWith("sepia-")) {
|
|
368
|
+
const n = Number(str.slice(6));
|
|
369
|
+
if (!isNaN(n))
|
|
370
|
+
return {
|
|
371
|
+
key: "filter",
|
|
372
|
+
value: `sepia(${Math.max(0, n / 100 * sign)})`
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
if (str.startsWith("invert-")) {
|
|
376
|
+
const n = Number(str.slice(7));
|
|
377
|
+
if (!isNaN(n))
|
|
378
|
+
return {
|
|
379
|
+
key: "filter",
|
|
380
|
+
value: `invert(${Math.max(0, n / 100 * sign)})`
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
if (str.startsWith("hue-rotate-")) {
|
|
384
|
+
const n = Number(str.slice(11));
|
|
385
|
+
if (!isNaN(n))
|
|
386
|
+
return { key: "filter", value: `hue-rotate(${n * sign}deg)` };
|
|
387
|
+
}
|
|
388
|
+
if (str.startsWith("drop-shadow-")) {
|
|
389
|
+
const val = str.slice(12);
|
|
390
|
+
if (val.startsWith("[") && val.endsWith("]")) {
|
|
391
|
+
return {
|
|
392
|
+
key: "filter",
|
|
393
|
+
value: `drop-shadow(${val.slice(1, -1).replace(/_/g, " ")})`
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
if (str.startsWith("backdrop-blur-")) {
|
|
398
|
+
const n = Number(str.slice(14));
|
|
399
|
+
if (!isNaN(n))
|
|
400
|
+
return {
|
|
401
|
+
key: "backdropFilter",
|
|
402
|
+
value: `blur(${Math.max(0, n * sign)}px)`
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
if (str.startsWith("clip-")) {
|
|
406
|
+
const val = str.slice(5);
|
|
407
|
+
if (val.startsWith("[") && val.endsWith("]")) {
|
|
408
|
+
return { key: "clipPath", value: val.slice(1, -1) };
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (str.startsWith("rounded-tl-")) {
|
|
412
|
+
const n = Number(str.slice(11));
|
|
413
|
+
if (!isNaN(n)) return { key: "borderTopLeftRadius", value: n * sign };
|
|
414
|
+
}
|
|
415
|
+
if (str.startsWith("rounded-tr-")) {
|
|
416
|
+
const n = Number(str.slice(11));
|
|
417
|
+
if (!isNaN(n)) return { key: "borderTopRightRadius", value: n * sign };
|
|
418
|
+
}
|
|
419
|
+
if (str.startsWith("rounded-bl-")) {
|
|
420
|
+
const n = Number(str.slice(11));
|
|
421
|
+
if (!isNaN(n)) return { key: "borderBottomLeftRadius", value: n * sign };
|
|
422
|
+
}
|
|
423
|
+
if (str.startsWith("rounded-br-")) {
|
|
424
|
+
const n = Number(str.slice(11));
|
|
425
|
+
if (!isNaN(n)) return { key: "borderBottomRightRadius", value: n * sign };
|
|
426
|
+
}
|
|
427
|
+
if (str.startsWith("rounded-")) {
|
|
428
|
+
const n = Number(str.slice(8));
|
|
429
|
+
if (!isNaN(n)) return { key: "borderRadius", value: n * sign };
|
|
430
|
+
}
|
|
431
|
+
if (str.startsWith("w-")) {
|
|
432
|
+
const val = parseNumericWithUnit(str.slice(2), sign);
|
|
433
|
+
if (val !== null) return { key: "width", value: val };
|
|
434
|
+
}
|
|
435
|
+
if (str.startsWith("h-")) {
|
|
436
|
+
const val = parseNumericWithUnit(str.slice(2), sign);
|
|
437
|
+
if (val !== null) return { key: "height", value: val };
|
|
438
|
+
}
|
|
439
|
+
if (str.startsWith("top-")) {
|
|
440
|
+
const val = parseNumericWithUnit(str.slice(4), sign);
|
|
441
|
+
if (val !== null) return { key: "top", value: val };
|
|
442
|
+
}
|
|
443
|
+
if (str.startsWith("left-")) {
|
|
444
|
+
const val = parseNumericWithUnit(str.slice(5), sign);
|
|
445
|
+
if (val !== null) return { key: "left", value: val };
|
|
446
|
+
}
|
|
447
|
+
if (str.startsWith("right-")) {
|
|
448
|
+
const val = parseNumericWithUnit(str.slice(6), sign);
|
|
449
|
+
if (val !== null) return { key: "right", value: val };
|
|
450
|
+
}
|
|
451
|
+
if (str.startsWith("bottom-")) {
|
|
452
|
+
const val = parseNumericWithUnit(str.slice(7), sign);
|
|
453
|
+
if (val !== null) return { key: "bottom", value: val };
|
|
454
|
+
}
|
|
455
|
+
if (str.startsWith("p-")) {
|
|
456
|
+
const val = parseNumericWithUnit(str.slice(2), sign);
|
|
457
|
+
if (val !== null) return { key: "padding", value: val };
|
|
458
|
+
}
|
|
459
|
+
if (str.startsWith("m-")) {
|
|
460
|
+
const val = parseNumericWithUnit(str.slice(2), sign);
|
|
461
|
+
if (val !== null) return { key: "margin", value: val };
|
|
462
|
+
}
|
|
463
|
+
if (str.startsWith("gap-")) {
|
|
464
|
+
const val = parseNumericWithUnit(str.slice(4), sign);
|
|
465
|
+
if (val !== null) return { key: "gap", value: val };
|
|
466
|
+
}
|
|
467
|
+
if (str.startsWith("text-size-")) {
|
|
468
|
+
const val = parseNumericWithUnit(str.slice(10), sign);
|
|
469
|
+
if (val !== null) return { key: "fontSize", value: val };
|
|
470
|
+
}
|
|
471
|
+
if (str.startsWith("tracking-")) {
|
|
472
|
+
const val = parseNumericWithUnit(str.slice(9), sign);
|
|
473
|
+
if (val !== null) return { key: "letterSpacing", value: val };
|
|
474
|
+
}
|
|
475
|
+
if (str.startsWith("leading-")) {
|
|
476
|
+
const val = parseNumericWithUnit(str.slice(8), sign);
|
|
477
|
+
if (val !== null) return { key: "lineHeight", value: val };
|
|
478
|
+
}
|
|
479
|
+
if (str.startsWith("border-w-")) {
|
|
480
|
+
const n = Number(str.slice(9));
|
|
481
|
+
if (!isNaN(n)) return { key: "borderWidth", value: n * sign };
|
|
482
|
+
}
|
|
483
|
+
if (str.startsWith("path-length-")) {
|
|
484
|
+
const n = Number(str.slice(12));
|
|
485
|
+
if (!isNaN(n)) return { key: "pathLength", value: n * sign };
|
|
486
|
+
}
|
|
487
|
+
if (str.startsWith("path-offset-")) {
|
|
488
|
+
const n = Number(str.slice(12));
|
|
489
|
+
if (!isNaN(n)) return { key: "pathOffset", value: n * sign };
|
|
490
|
+
}
|
|
491
|
+
if (str.startsWith("path-spacing-")) {
|
|
492
|
+
const n = Number(str.slice(13));
|
|
493
|
+
if (!isNaN(n)) return { key: "pathSpacing", value: n * sign };
|
|
494
|
+
}
|
|
495
|
+
if (str.startsWith("bg-")) {
|
|
496
|
+
const color = str.slice(3);
|
|
497
|
+
if (isValidColor(color)) {
|
|
498
|
+
return { key: "backgroundColor", value: color };
|
|
499
|
+
}
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
if (str.startsWith("text-shadow-")) {
|
|
503
|
+
const val = str.slice(12);
|
|
504
|
+
if (val.startsWith("[") && val.endsWith("]")) {
|
|
505
|
+
return {
|
|
506
|
+
key: "textShadow",
|
|
507
|
+
value: val.slice(1, -1).replace(/_/g, " ")
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
if (str.startsWith("text-")) {
|
|
512
|
+
const color = str.slice(5);
|
|
513
|
+
if (isValidColor(color)) {
|
|
514
|
+
return { key: "color", value: color };
|
|
515
|
+
}
|
|
516
|
+
return null;
|
|
517
|
+
}
|
|
518
|
+
if (str.startsWith("border-")) {
|
|
519
|
+
const color = str.slice(7);
|
|
520
|
+
if (isValidColor(color)) {
|
|
521
|
+
return { key: "borderColor", value: color };
|
|
522
|
+
}
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
if (str.startsWith("shadow-")) {
|
|
526
|
+
const val = str.slice(7);
|
|
527
|
+
if (val.startsWith("[") && val.endsWith("]")) {
|
|
528
|
+
return { key: "boxShadow", value: val.slice(1, -1) };
|
|
529
|
+
}
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
return null;
|
|
533
|
+
}
|
|
534
|
+
var HEX_COLOR_RE = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
|
|
535
|
+
var FUNC_COLOR_RE = /^(?:rgb|rgba|hsl|hsla)\(.+\)$/;
|
|
536
|
+
function isValidColor(color) {
|
|
537
|
+
return HEX_COLOR_RE.test(color) || FUNC_COLOR_RE.test(color);
|
|
538
|
+
}
|
|
539
|
+
function normalizePropertyName(name) {
|
|
540
|
+
const map = {
|
|
541
|
+
scale: "scale",
|
|
542
|
+
"scale-x": "scaleX",
|
|
543
|
+
"scale-y": "scaleY",
|
|
544
|
+
"scale-z": "scaleZ",
|
|
545
|
+
rotate: "rotate",
|
|
546
|
+
"rotate-x": "rotateX",
|
|
547
|
+
"rotate-y": "rotateY",
|
|
548
|
+
x: "x",
|
|
549
|
+
y: "y",
|
|
550
|
+
z: "z",
|
|
551
|
+
opacity: "opacity",
|
|
552
|
+
"skew-x": "skewX",
|
|
553
|
+
"skew-y": "skewY",
|
|
554
|
+
skew: "skew",
|
|
555
|
+
w: "width",
|
|
556
|
+
h: "height",
|
|
557
|
+
rounded: "borderRadius",
|
|
558
|
+
"rounded-tl": "borderTopLeftRadius",
|
|
559
|
+
"rounded-tr": "borderTopRightRadius",
|
|
560
|
+
"rounded-bl": "borderBottomLeftRadius",
|
|
561
|
+
"rounded-br": "borderBottomRightRadius",
|
|
562
|
+
"origin-x": "originX",
|
|
563
|
+
"origin-y": "originY",
|
|
564
|
+
"origin-z": "originZ",
|
|
565
|
+
perspective: "perspective"
|
|
566
|
+
};
|
|
567
|
+
return map[name] ?? null;
|
|
568
|
+
}
|
|
569
|
+
function normalizeScrollProp(name) {
|
|
570
|
+
const n = name.toLowerCase().replace(/-/g, "");
|
|
571
|
+
const map = {
|
|
572
|
+
x: "x",
|
|
573
|
+
y: "y",
|
|
574
|
+
z: "z",
|
|
575
|
+
opacity: "opacity",
|
|
576
|
+
rotate: "rotate",
|
|
577
|
+
rotatex: "rotateX",
|
|
578
|
+
rotatey: "rotateY",
|
|
579
|
+
scale: "scale",
|
|
580
|
+
scalex: "scaleX",
|
|
581
|
+
scaley: "scaleY"
|
|
582
|
+
};
|
|
583
|
+
return map[n] ?? null;
|
|
584
|
+
}
|
|
585
|
+
function parseScrollValue(raw) {
|
|
586
|
+
const m = raw.match(/^([\w-]+?)-\[([^\]]+)\]$/);
|
|
587
|
+
if (!m) return null;
|
|
588
|
+
const key = normalizeScrollProp(m[1]);
|
|
589
|
+
if (!key) return null;
|
|
590
|
+
const parts = m[2].split(",").map((v) => Number(v.trim()));
|
|
591
|
+
if (parts.length < 2 || parts.some((n) => isNaN(n))) return null;
|
|
592
|
+
return { key, value: parts };
|
|
593
|
+
}
|
|
594
|
+
function classifyToken(token, gestures, transition, viewport, dragConfig, layoutConfig, scroll, variants, variantState) {
|
|
595
|
+
if (!token.startsWith("animate-")) return false;
|
|
596
|
+
const rest = token.slice(8);
|
|
597
|
+
const colonIdx = rest.indexOf(":");
|
|
598
|
+
if (colonIdx !== -1) {
|
|
599
|
+
const gesturePrefix = rest.slice(0, colonIdx);
|
|
600
|
+
const propValueStr = rest.slice(colonIdx + 1);
|
|
601
|
+
if (gesturePrefix === "scroll") {
|
|
602
|
+
const parsed = parseScrollValue(propValueStr);
|
|
603
|
+
if (parsed) {
|
|
604
|
+
scroll.values[parsed.key] = parsed.value;
|
|
605
|
+
return true;
|
|
606
|
+
}
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
if (gesturePrefix.startsWith("variant-")) {
|
|
610
|
+
const variantName = gesturePrefix.slice(8);
|
|
611
|
+
const parsed = parsePropertyValue(propValueStr);
|
|
612
|
+
if (variantName && parsed) {
|
|
613
|
+
if (!variants[variantName]) variants[variantName] = {};
|
|
614
|
+
const bucket = variants[variantName];
|
|
615
|
+
if ((parsed.key === "filter" || parsed.key === "backdropFilter") && typeof parsed.value === "string" && typeof bucket[parsed.key] === "string") {
|
|
616
|
+
bucket[parsed.key] += ` ${parsed.value}`;
|
|
617
|
+
} else {
|
|
618
|
+
bucket[parsed.key] = parsed.value;
|
|
619
|
+
}
|
|
620
|
+
return true;
|
|
621
|
+
}
|
|
622
|
+
return false;
|
|
623
|
+
}
|
|
624
|
+
if (GESTURE_KEYS.has(gesturePrefix)) {
|
|
625
|
+
const gestureKey = GESTURE_MAP[gesturePrefix];
|
|
626
|
+
const parsed = parsePropertyValue(propValueStr);
|
|
627
|
+
if (parsed) {
|
|
628
|
+
if (!gestures[gestureKey]) gestures[gestureKey] = {};
|
|
629
|
+
if ((parsed.key === "filter" || parsed.key === "backdropFilter") && typeof parsed.value === "string" && typeof gestures[gestureKey][parsed.key] === "string") {
|
|
630
|
+
gestures[gestureKey][parsed.key] += ` ${parsed.value}`;
|
|
631
|
+
} else {
|
|
632
|
+
if (process.env.NODE_ENV !== "production" && gestures[gestureKey][parsed.key] !== void 0) {
|
|
633
|
+
console.warn(
|
|
634
|
+
`[motionwind] Duplicate property "${parsed.key}" in "${gestureKey}" (class "${token}"). The last value will be used.`
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
gestures[gestureKey][parsed.key] = parsed.value;
|
|
638
|
+
}
|
|
639
|
+
return true;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return false;
|
|
643
|
+
}
|
|
644
|
+
if (rest.startsWith("duration-")) {
|
|
645
|
+
const ms = Number(rest.slice(9));
|
|
646
|
+
if (!isNaN(ms)) {
|
|
647
|
+
transition.duration = ms / 1e3;
|
|
648
|
+
return true;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
if (rest.startsWith("delay-children-")) {
|
|
652
|
+
const ms = Number(rest.slice(15));
|
|
653
|
+
if (!isNaN(ms)) {
|
|
654
|
+
transition.delayChildren = ms / 1e3;
|
|
655
|
+
return true;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
if (rest.startsWith("delay-")) {
|
|
659
|
+
const ms = Number(rest.slice(6));
|
|
660
|
+
if (!isNaN(ms)) {
|
|
661
|
+
transition.delay = ms / 1e3;
|
|
662
|
+
return true;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
if (rest.startsWith("ease-[") && rest.endsWith("]")) {
|
|
666
|
+
const inner = rest.slice(6, -1);
|
|
667
|
+
const values = inner.split(",").map((v) => Number(v.trim()));
|
|
668
|
+
if (values.length === 4 && values.every((v) => !isNaN(v))) {
|
|
669
|
+
transition.ease = values;
|
|
670
|
+
return true;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
if (rest.startsWith("ease-steps-")) {
|
|
674
|
+
const n = Number(rest.slice(11));
|
|
675
|
+
if (!isNaN(n) && n > 0) {
|
|
676
|
+
transition.ease = `steps(${n})`;
|
|
677
|
+
return true;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
for (const [suffix, easeValue] of Object.entries(EASING_MAP)) {
|
|
681
|
+
if (rest === suffix) {
|
|
682
|
+
transition.ease = easeValue;
|
|
683
|
+
return true;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
if (rest === "spring") {
|
|
687
|
+
transition.type = "spring";
|
|
688
|
+
return true;
|
|
689
|
+
}
|
|
690
|
+
if (rest.startsWith("stiffness-")) {
|
|
691
|
+
const n = Number(rest.slice(10));
|
|
692
|
+
if (!isNaN(n)) {
|
|
693
|
+
transition.stiffness = n;
|
|
694
|
+
return true;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
if (rest.startsWith("damping-")) {
|
|
698
|
+
const n = Number(rest.slice(8));
|
|
699
|
+
if (!isNaN(n)) {
|
|
700
|
+
transition.damping = n;
|
|
701
|
+
return true;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
if (rest.startsWith("bounce-")) {
|
|
705
|
+
const n = Number(rest.slice(7));
|
|
706
|
+
if (!isNaN(n)) {
|
|
707
|
+
transition.bounce = n / 100;
|
|
708
|
+
return true;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
if (rest.startsWith("mass-")) {
|
|
712
|
+
const n = Number(rest.slice(5));
|
|
713
|
+
if (!isNaN(n)) {
|
|
714
|
+
transition.mass = n / 10;
|
|
715
|
+
return true;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
if (rest === "repeat-infinite") {
|
|
719
|
+
transition.repeat = Infinity;
|
|
720
|
+
return true;
|
|
721
|
+
}
|
|
722
|
+
if (rest === "repeat-reverse") {
|
|
723
|
+
transition.repeatType = "reverse";
|
|
724
|
+
return true;
|
|
725
|
+
}
|
|
726
|
+
if (rest === "repeat-mirror") {
|
|
727
|
+
transition.repeatType = "mirror";
|
|
728
|
+
return true;
|
|
729
|
+
}
|
|
730
|
+
if (rest.startsWith("repeat-delay-")) {
|
|
731
|
+
const ms = Number(rest.slice(13));
|
|
732
|
+
if (!isNaN(ms)) {
|
|
733
|
+
transition.repeatDelay = ms / 1e3;
|
|
734
|
+
return true;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
if (rest.startsWith("repeat-")) {
|
|
738
|
+
const n = Number(rest.slice(7));
|
|
739
|
+
if (!isNaN(n)) {
|
|
740
|
+
transition.repeat = n;
|
|
741
|
+
return true;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
if (rest === "stagger-reverse") {
|
|
745
|
+
transition.staggerDirection = -1;
|
|
746
|
+
return true;
|
|
747
|
+
}
|
|
748
|
+
if (rest.startsWith("stagger-")) {
|
|
749
|
+
const ms = Number(rest.slice(8));
|
|
750
|
+
if (!isNaN(ms)) {
|
|
751
|
+
transition.staggerChildren = ms / 1e3;
|
|
752
|
+
return true;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
if (rest === "when-before") {
|
|
756
|
+
transition.when = "beforeChildren";
|
|
757
|
+
return true;
|
|
758
|
+
}
|
|
759
|
+
if (rest === "when-after") {
|
|
760
|
+
transition.when = "afterChildren";
|
|
761
|
+
return true;
|
|
762
|
+
}
|
|
763
|
+
if (rest.startsWith("rest-speed-")) {
|
|
764
|
+
const n = Number(rest.slice(11));
|
|
765
|
+
if (!isNaN(n)) {
|
|
766
|
+
transition.restSpeed = n;
|
|
767
|
+
return true;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
if (rest.startsWith("rest-delta-")) {
|
|
771
|
+
const n = Number(rest.slice(11));
|
|
772
|
+
if (!isNaN(n)) {
|
|
773
|
+
transition.restDelta = n;
|
|
774
|
+
return true;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
if (rest.startsWith("times-[") && rest.endsWith("]")) {
|
|
778
|
+
const inner = rest.slice(7, -1);
|
|
779
|
+
const values = inner.split(",").map((v) => Number(v.trim()));
|
|
780
|
+
if (!values.some(isNaN)) {
|
|
781
|
+
transition.times = values;
|
|
782
|
+
return true;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
if (rest === "once") {
|
|
786
|
+
viewport.once = true;
|
|
787
|
+
return true;
|
|
788
|
+
}
|
|
789
|
+
if (rest === "amount-all") {
|
|
790
|
+
viewport.amount = "all";
|
|
791
|
+
return true;
|
|
792
|
+
}
|
|
793
|
+
if (rest.startsWith("amount-")) {
|
|
794
|
+
const n = Number(rest.slice(7));
|
|
795
|
+
if (!isNaN(n)) {
|
|
796
|
+
viewport.amount = n / 100;
|
|
797
|
+
return true;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
if (rest.startsWith("margin-")) {
|
|
801
|
+
const n = Number(rest.slice(7));
|
|
802
|
+
if (!isNaN(n)) {
|
|
803
|
+
viewport.margin = `${n}px`;
|
|
804
|
+
return true;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
if (rest === "scroll-axis-x") {
|
|
808
|
+
scroll.axis = "x";
|
|
809
|
+
return true;
|
|
810
|
+
}
|
|
811
|
+
if (rest === "scroll-axis-y") {
|
|
812
|
+
scroll.axis = "y";
|
|
813
|
+
return true;
|
|
814
|
+
}
|
|
815
|
+
if (rest === "scroll-container") {
|
|
816
|
+
scroll.container = true;
|
|
817
|
+
return true;
|
|
818
|
+
}
|
|
819
|
+
if (rest.startsWith("scroll-offset-[") && rest.endsWith("]")) {
|
|
820
|
+
const inner = rest.slice(15, -1);
|
|
821
|
+
const parts = inner.split(",").map((p) => p.trim().replace(/_/g, " "));
|
|
822
|
+
if (parts.length === 2) {
|
|
823
|
+
scroll.offset = [parts[0], parts[1]];
|
|
824
|
+
return true;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
if (rest.startsWith("from-")) {
|
|
828
|
+
const name = rest.slice(5);
|
|
829
|
+
if (name && !/\s/.test(name)) {
|
|
830
|
+
variantState.initial = name;
|
|
831
|
+
return true;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
if (rest.startsWith("to-")) {
|
|
835
|
+
const name = rest.slice(3);
|
|
836
|
+
if (name && !/\s/.test(name)) {
|
|
837
|
+
variantState.animate = name;
|
|
838
|
+
return true;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
if (rest.startsWith("exit-")) {
|
|
842
|
+
const name = rest.slice(5);
|
|
843
|
+
if (name && !/\s/.test(name)) {
|
|
844
|
+
variantState.exit = name;
|
|
845
|
+
return true;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
if (rest === "drag-x") {
|
|
849
|
+
dragConfig.drag = "x";
|
|
850
|
+
return true;
|
|
851
|
+
}
|
|
852
|
+
if (rest === "drag-y") {
|
|
853
|
+
dragConfig.drag = "y";
|
|
854
|
+
return true;
|
|
855
|
+
}
|
|
856
|
+
if (rest === "drag-both") {
|
|
857
|
+
dragConfig.drag = true;
|
|
858
|
+
return true;
|
|
859
|
+
}
|
|
860
|
+
if (rest.startsWith("drag-elastic-")) {
|
|
861
|
+
const n = Number(rest.slice(13));
|
|
862
|
+
if (!isNaN(n)) {
|
|
863
|
+
dragConfig.dragElastic = n / 100;
|
|
864
|
+
return true;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
if (rest === "drag-snap") {
|
|
868
|
+
dragConfig.dragSnapToOrigin = true;
|
|
869
|
+
return true;
|
|
870
|
+
}
|
|
871
|
+
if (rest === "drag-no-momentum") {
|
|
872
|
+
dragConfig.dragMomentum = false;
|
|
873
|
+
return true;
|
|
874
|
+
}
|
|
875
|
+
if (rest === "drag-lock") {
|
|
876
|
+
dragConfig.dragDirectionLock = true;
|
|
877
|
+
return true;
|
|
878
|
+
}
|
|
879
|
+
if (rest.startsWith("drag-constraint-")) {
|
|
880
|
+
const sub = rest.slice(16);
|
|
881
|
+
const sides = {
|
|
882
|
+
"t-": "top",
|
|
883
|
+
"l-": "left",
|
|
884
|
+
"r-": "right",
|
|
885
|
+
"b-": "bottom"
|
|
886
|
+
};
|
|
887
|
+
for (const [prefix, side] of Object.entries(sides)) {
|
|
888
|
+
if (sub.startsWith(prefix)) {
|
|
889
|
+
const n = Number(sub.slice(2));
|
|
890
|
+
if (!isNaN(n)) {
|
|
891
|
+
if (!dragConfig.dragConstraints) dragConfig.dragConstraints = {};
|
|
892
|
+
dragConfig.dragConstraints[side] = n;
|
|
893
|
+
return true;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
if (rest === "layout") {
|
|
899
|
+
layoutConfig.layout = true;
|
|
900
|
+
return true;
|
|
901
|
+
}
|
|
902
|
+
if (rest === "layout-position") {
|
|
903
|
+
layoutConfig.layout = "position";
|
|
904
|
+
return true;
|
|
905
|
+
}
|
|
906
|
+
if (rest === "layout-size") {
|
|
907
|
+
layoutConfig.layout = "size";
|
|
908
|
+
return true;
|
|
909
|
+
}
|
|
910
|
+
if (rest === "layout-preserve") {
|
|
911
|
+
layoutConfig.layout = "preserve-aspect";
|
|
912
|
+
return true;
|
|
913
|
+
}
|
|
914
|
+
if (rest === "layout-scroll") {
|
|
915
|
+
layoutConfig.layoutScroll = true;
|
|
916
|
+
return true;
|
|
917
|
+
}
|
|
918
|
+
if (rest === "layout-root") {
|
|
919
|
+
layoutConfig.layoutRoot = true;
|
|
920
|
+
return true;
|
|
921
|
+
}
|
|
922
|
+
if (rest.startsWith("layout-id-")) {
|
|
923
|
+
const id = rest.slice(10);
|
|
924
|
+
if (id && !/\s/.test(id)) {
|
|
925
|
+
layoutConfig.layoutId = id;
|
|
926
|
+
return true;
|
|
927
|
+
}
|
|
928
|
+
return false;
|
|
929
|
+
}
|
|
930
|
+
return false;
|
|
931
|
+
}
|
|
932
|
+
function parseMotionClasses(className, config) {
|
|
933
|
+
const cached = config ? void 0 : cache.get(className);
|
|
934
|
+
if (cached) return cached;
|
|
935
|
+
const diagnostics = [];
|
|
936
|
+
const tokens = expandConfiguredTokens(className, config, diagnostics);
|
|
937
|
+
const tailwind = [];
|
|
938
|
+
const gestures = {};
|
|
939
|
+
const transition = {};
|
|
940
|
+
const viewport = {};
|
|
941
|
+
const dragConfig = {};
|
|
942
|
+
const layoutConfig = {};
|
|
943
|
+
const scroll = { axis: "y", container: false, values: {} };
|
|
944
|
+
const variants = {};
|
|
945
|
+
const variantState = {};
|
|
946
|
+
let reducedMotionPolicy = void 0;
|
|
947
|
+
for (const token of tokens) {
|
|
948
|
+
let innerToken = token;
|
|
949
|
+
if (token.startsWith("motion-reduce:")) {
|
|
950
|
+
reducedMotionPolicy = "reduce";
|
|
951
|
+
innerToken = token.slice("motion-reduce:".length);
|
|
952
|
+
} else if (token.startsWith("motion-safe:")) {
|
|
953
|
+
reducedMotionPolicy = "safe";
|
|
954
|
+
innerToken = token.slice("motion-safe:".length);
|
|
955
|
+
}
|
|
956
|
+
if (!innerToken) continue;
|
|
957
|
+
let consumed = classifyToken(
|
|
958
|
+
innerToken,
|
|
959
|
+
gestures,
|
|
960
|
+
transition,
|
|
961
|
+
viewport,
|
|
962
|
+
dragConfig,
|
|
963
|
+
layoutConfig,
|
|
964
|
+
scroll,
|
|
965
|
+
variants,
|
|
966
|
+
variantState
|
|
967
|
+
);
|
|
968
|
+
if (!consumed) {
|
|
969
|
+
const easingName = innerToken.startsWith("animate-ease-") ? innerToken.slice("animate-ease-".length) : "";
|
|
970
|
+
const easing = easingName ? config?.tokens?.easings?.[easingName] : void 0;
|
|
971
|
+
if (typeof easing === "string") {
|
|
972
|
+
transition.ease = easing;
|
|
973
|
+
consumed = true;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
if (!consumed) {
|
|
977
|
+
for (const plugin of config?.plugins ?? []) {
|
|
978
|
+
const patch = plugin.transformToken?.(innerToken, { config });
|
|
979
|
+
if (!patch) continue;
|
|
980
|
+
mergePatch(
|
|
981
|
+
patch,
|
|
982
|
+
gestures,
|
|
983
|
+
transition,
|
|
984
|
+
viewport,
|
|
985
|
+
dragConfig,
|
|
986
|
+
layoutConfig,
|
|
987
|
+
scroll,
|
|
988
|
+
variants,
|
|
989
|
+
variantState
|
|
990
|
+
);
|
|
991
|
+
consumed = true;
|
|
992
|
+
break;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
if (!consumed) {
|
|
996
|
+
if (innerToken.startsWith("animate-") && !TAILWIND_ANIMATE_CLASSES.has(innerToken)) {
|
|
997
|
+
diagnostics.push({
|
|
998
|
+
code: "unknown-class",
|
|
999
|
+
message: `Unrecognized motionwind class "${innerToken}".`,
|
|
1000
|
+
severity: config?.strict ? "error" : "warning",
|
|
1001
|
+
token: innerToken
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
if (process.env.NODE_ENV !== "production" && innerToken.startsWith("animate-") && !TAILWIND_ANIMATE_CLASSES.has(innerToken)) {
|
|
1005
|
+
console.warn(
|
|
1006
|
+
`[motionwind] Unrecognized class "${innerToken}". It starts with "animate-" but doesn't match any known pattern.`
|
|
1007
|
+
);
|
|
1008
|
+
}
|
|
1009
|
+
tailwind.push(innerToken);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
const hasMotion = Object.keys(gestures).length > 0 || Object.keys(transition).length > 0 || Object.keys(viewport).length > 0 || Object.keys(dragConfig).length > 0 || Object.keys(layoutConfig).length > 0 || Object.keys(scroll.values).length > 0 || Object.keys(variants).length > 0 || Object.keys(variantState).length > 0;
|
|
1013
|
+
const result = {
|
|
1014
|
+
tailwindClasses: tailwind.join(" "),
|
|
1015
|
+
gestures,
|
|
1016
|
+
transition,
|
|
1017
|
+
viewport,
|
|
1018
|
+
dragConfig,
|
|
1019
|
+
layoutConfig,
|
|
1020
|
+
scroll,
|
|
1021
|
+
variants,
|
|
1022
|
+
variantState,
|
|
1023
|
+
hasMotion,
|
|
1024
|
+
...reducedMotionPolicy !== void 0 && { reducedMotionPolicy },
|
|
1025
|
+
diagnostics
|
|
1026
|
+
};
|
|
1027
|
+
for (const plugin of config?.plugins ?? []) {
|
|
1028
|
+
const pluginDiagnostics = plugin.diagnose?.(className, result, { config }) ?? [];
|
|
1029
|
+
diagnostics.push(
|
|
1030
|
+
...pluginDiagnostics.map((diagnostic) => ({
|
|
1031
|
+
...diagnostic,
|
|
1032
|
+
plugin: plugin.name
|
|
1033
|
+
}))
|
|
1034
|
+
);
|
|
1035
|
+
}
|
|
1036
|
+
if (!config) cacheSet(className, result);
|
|
1037
|
+
return result;
|
|
1038
|
+
}
|
|
1039
|
+
function clearParserCache() {
|
|
1040
|
+
cache.clear();
|
|
1041
|
+
}
|
|
1042
|
+
function freshAccumulators() {
|
|
1043
|
+
return {
|
|
1044
|
+
gestures: {},
|
|
1045
|
+
transition: {},
|
|
1046
|
+
viewport: {},
|
|
1047
|
+
dragConfig: {},
|
|
1048
|
+
layoutConfig: {},
|
|
1049
|
+
scroll: { axis: "y", container: false, values: {} },
|
|
1050
|
+
variants: {},
|
|
1051
|
+
variantState: {}
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
function classifyMotionToken(token, config) {
|
|
1055
|
+
if (token.startsWith("motion-reduce:") || token.startsWith("motion-safe:")) {
|
|
1056
|
+
const inner = token.startsWith("motion-reduce:") ? token.slice("motion-reduce:".length) : token.slice("motion-safe:".length);
|
|
1057
|
+
return inner ? classifyMotionToken(inner, config) : "tailwind";
|
|
1058
|
+
}
|
|
1059
|
+
if (!token.startsWith("animate-")) return "tailwind";
|
|
1060
|
+
if (TAILWIND_ANIMATE_CLASSES.has(token)) return "tailwind";
|
|
1061
|
+
if (config || token.startsWith("animate-preset-")) {
|
|
1062
|
+
const parsed = parseMotionClasses(token, config);
|
|
1063
|
+
if (!parsed.hasMotion) return "unknown";
|
|
1064
|
+
if (Object.keys(parsed.variantState).length || Object.keys(parsed.variants).length)
|
|
1065
|
+
return "variant";
|
|
1066
|
+
if (Object.keys(parsed.gestures).length) return "gesture";
|
|
1067
|
+
if (Object.keys(parsed.viewport).length) return "viewport";
|
|
1068
|
+
if (Object.keys(parsed.scroll.values).length) return "scroll";
|
|
1069
|
+
if (Object.keys(parsed.dragConfig).length) return "drag";
|
|
1070
|
+
if (Object.keys(parsed.layoutConfig).length) return "layout";
|
|
1071
|
+
return "transition";
|
|
1072
|
+
}
|
|
1073
|
+
const a = freshAccumulators();
|
|
1074
|
+
const consumed = classifyToken(
|
|
1075
|
+
token,
|
|
1076
|
+
a.gestures,
|
|
1077
|
+
a.transition,
|
|
1078
|
+
a.viewport,
|
|
1079
|
+
a.dragConfig,
|
|
1080
|
+
a.layoutConfig,
|
|
1081
|
+
a.scroll,
|
|
1082
|
+
a.variants,
|
|
1083
|
+
a.variantState
|
|
1084
|
+
);
|
|
1085
|
+
if (!consumed) return "unknown";
|
|
1086
|
+
if (token.startsWith("animate-scroll")) return "scroll";
|
|
1087
|
+
if (token.startsWith("animate-variant-")) return "variant";
|
|
1088
|
+
if (Object.keys(a.variantState).length) return "variant";
|
|
1089
|
+
if (Object.keys(a.gestures).length) return "gesture";
|
|
1090
|
+
if (Object.keys(a.viewport).length) return "viewport";
|
|
1091
|
+
if (Object.keys(a.dragConfig).length) return "drag";
|
|
1092
|
+
if (Object.keys(a.layoutConfig).length) return "layout";
|
|
1093
|
+
return "transition";
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
export { classifyMotionToken, clearParserCache, parseMotionClasses };
|
|
1097
|
+
//# sourceMappingURL=chunk-A7EAMXLY.js.map
|
|
1098
|
+
//# sourceMappingURL=chunk-A7EAMXLY.js.map
|