praxis-kit 1.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/LICENSE +21 -0
- package/dist/chunk-KDUNVQK2.js +2059 -0
- package/dist/codemod/index.d.ts +21 -0
- package/dist/codemod/index.js +241955 -0
- package/dist/eslint/index.d.ts +84 -0
- package/dist/eslint/index.js +1068 -0
- package/dist/lit/index.d.ts +304 -0
- package/dist/lit/index.js +1887 -0
- package/dist/merge-refs-CfBqh1UO.d.ts +374 -0
- package/dist/preact/index.d.ts +292 -0
- package/dist/preact/index.js +2062 -0
- package/dist/react/index.d.ts +27 -0
- package/dist/react/index.js +197 -0
- package/dist/react/legacy.d.ts +21 -0
- package/dist/react/legacy.js +209 -0
- package/dist/solid/index.d.ts +287 -0
- package/dist/solid/index.js +1837 -0
- package/dist/svelte/index.d.ts +343 -0
- package/dist/svelte/index.js +1723 -0
- package/dist/tailwind/index.d.ts +138 -0
- package/dist/tailwind/index.js +508 -0
- package/dist/ts-plugin/index.cjs +191 -0
- package/dist/ts-plugin/index.d.cts +10 -0
- package/dist/vite-plugin/index.d.ts +395 -0
- package/dist/vite-plugin/index.js +1329 -0
- package/dist/vue/index.d.ts +309 -0
- package/dist/vue/index.js +1922 -0
- package/dist/web/index.d.ts +302 -0
- package/dist/web/index.js +1858 -0
- package/package.json +176 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { VariantMap, ClassPipelineOptions, StrictMode, ClassPlugin } from '@praxis-kit/core';
|
|
2
|
+
import { Simplify } from 'type-fest';
|
|
3
|
+
import { EmptyRecord } from '@praxis-kit/shared';
|
|
4
|
+
|
|
5
|
+
declare const LAYOUT_FAMILY_MAP: {
|
|
6
|
+
readonly flex: "flex";
|
|
7
|
+
readonly 'inline-flex': "flex";
|
|
8
|
+
readonly grid: "grid";
|
|
9
|
+
readonly 'inline-grid': "grid";
|
|
10
|
+
readonly block: "none";
|
|
11
|
+
readonly 'inline-block': "none";
|
|
12
|
+
readonly inline: "none";
|
|
13
|
+
readonly hidden: "none";
|
|
14
|
+
readonly contents: "none";
|
|
15
|
+
readonly 'flow-root': "none";
|
|
16
|
+
readonly 'list-item': "none";
|
|
17
|
+
readonly table: "none";
|
|
18
|
+
readonly 'table-caption': "none";
|
|
19
|
+
readonly 'table-cell': "none";
|
|
20
|
+
readonly 'table-column': "none";
|
|
21
|
+
readonly 'table-column-group': "none";
|
|
22
|
+
readonly 'table-footer-group': "none";
|
|
23
|
+
readonly 'table-header-group': "none";
|
|
24
|
+
readonly 'table-row-group': "none";
|
|
25
|
+
readonly 'table-row': "none";
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
declare const layoutKeys: readonly ["flex", "inline-flex", "grid", "inline-grid", "block", "inline-block", "inline", "hidden", "contents", "flow-root", "list-item", "table", "table-caption", "table-cell", "table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row-group", "table-row"];
|
|
29
|
+
|
|
30
|
+
type LayoutKey = (typeof layoutKeys)[number];
|
|
31
|
+
type LayoutFamily = (typeof LAYOUT_FAMILY_MAP)[LayoutKey];
|
|
32
|
+
type LayoutMode = LayoutKey | 'none';
|
|
33
|
+
type ExclusiveTrueProp<K extends PropertyKey> = {
|
|
34
|
+
[P in K]: Simplify<Record<P, true> & Partial<Record<Exclude<K, P>, never>>>;
|
|
35
|
+
}[K];
|
|
36
|
+
/**
|
|
37
|
+
* Mutually exclusive display shorthand props.
|
|
38
|
+
*
|
|
39
|
+
* At most one key may be `true`. Passing multiple is a compile-time error; the
|
|
40
|
+
* runtime also warns and lets the first key in declaration order take precedence.
|
|
41
|
+
*/
|
|
42
|
+
type LayoutProps = ExclusiveTrueProp<LayoutKey> | Partial<Record<LayoutKey, never>>;
|
|
43
|
+
|
|
44
|
+
type ClassToken = string;
|
|
45
|
+
type Token<TKind extends string, TData extends object = EmptyRecord> = {
|
|
46
|
+
kind: TKind;
|
|
47
|
+
raw: string;
|
|
48
|
+
} & TData;
|
|
49
|
+
type LayoutToken = Token<'layout', {
|
|
50
|
+
value: LayoutKey;
|
|
51
|
+
}>;
|
|
52
|
+
type ConditionalToken = Token<'conditional', {
|
|
53
|
+
requires: Exclude<LayoutFamily, 'none'>;
|
|
54
|
+
}>;
|
|
55
|
+
type GapToken = Token<'gap'>;
|
|
56
|
+
type UtilityToken = Token<'utility', {
|
|
57
|
+
base: string;
|
|
58
|
+
}>;
|
|
59
|
+
type ClassifiedToken = LayoutToken | ConditionalToken | GapToken | UtilityToken;
|
|
60
|
+
|
|
61
|
+
type VariantSelection = Record<string, string>;
|
|
62
|
+
type CompoundVariant = {
|
|
63
|
+
class?: unknown;
|
|
64
|
+
} & Record<string, unknown>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Layout-aware class pipeline for Tailwind CSS utility class strings.
|
|
68
|
+
*
|
|
69
|
+
* This is a `ClassPluginFactory` — the runtime calls it with the component's
|
|
70
|
+
* resolved pipeline options and strict mode. Do NOT call it yourself; pass the
|
|
71
|
+
* function reference as `styling.plugin` and let the runtime invoke it.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* // CORRECT — pass the reference; the runtime calls it
|
|
76
|
+
* createContractComponent({
|
|
77
|
+
* tag: 'div',
|
|
78
|
+
* styling: {
|
|
79
|
+
* base: 'items-center',
|
|
80
|
+
* plugin: createTailwindPipeline,
|
|
81
|
+
* },
|
|
82
|
+
* })
|
|
83
|
+
*
|
|
84
|
+
* // WRONG — calling it manually produces a ClassPlugin where a ClassPluginFactory is expected
|
|
85
|
+
* createContractComponent({
|
|
86
|
+
* tag: 'div',
|
|
87
|
+
* styling: {
|
|
88
|
+
* plugin: createTailwindPipeline({ base: 'items-center' }, false),
|
|
89
|
+
* },
|
|
90
|
+
* })
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* With the plugin active, pass any display prop (`flex`, `inline-flex`, `grid`,
|
|
94
|
+
* `inline-grid`, `block`, `hidden`, etc.) as a boolean to control the display
|
|
95
|
+
* mode. The pipeline injects the display class and strips conflicting utilities:
|
|
96
|
+
* flex-family modes strip `grid-*`; grid-family modes strip `flex-*`; all other
|
|
97
|
+
* display values (and no prop) strip both `flex-*` and `grid-*`.
|
|
98
|
+
*/
|
|
99
|
+
declare function createTailwindPipeline<V extends VariantMap = VariantMap>(options: ClassPipelineOptions<V>, strict: StrictMode): ClassPlugin<LayoutProps>;
|
|
100
|
+
|
|
101
|
+
declare class ClassBuilder {
|
|
102
|
+
#private;
|
|
103
|
+
build(tokens: ClassifiedToken[]): string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
declare class ClassClassifier {
|
|
107
|
+
#private;
|
|
108
|
+
classify(token: ClassToken): ClassifiedToken;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
type DependencyRules = Record<Exclude<LayoutFamily, 'none'>, readonly RegExp[]>;
|
|
112
|
+
declare const defaultDependencyRules: DependencyRules;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The resolved display mode for a single render.
|
|
116
|
+
*
|
|
117
|
+
* Mode is owned by the display props; a display class literal in the resolved
|
|
118
|
+
* class string is a reserved-literal authoring mistake. Defaults to `'none'`
|
|
119
|
+
* when no prop is set.
|
|
120
|
+
*
|
|
121
|
+
* `family` is derived from mode: `'flex'` for flex/inline-flex, `'grid'` for
|
|
122
|
+
* grid/inline-grid, `'none'` for all other values (and when no prop is set).
|
|
123
|
+
* The evaluator uses family — not mode — for utility and gap filtering.
|
|
124
|
+
*/
|
|
125
|
+
declare class LayoutState {
|
|
126
|
+
#private;
|
|
127
|
+
constructor(mode: LayoutMode);
|
|
128
|
+
get mode(): LayoutMode;
|
|
129
|
+
get family(): LayoutFamily;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
declare class DependencyEvaluator {
|
|
133
|
+
private readonly rules;
|
|
134
|
+
constructor(rules: DependencyRules);
|
|
135
|
+
evaluate(token: ClassifiedToken, state: LayoutState): boolean;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { ClassBuilder, ClassClassifier, type ClassToken, type ClassifiedToken, type CompoundVariant, type ConditionalToken, DependencyEvaluator, type DependencyRules, type GapToken, type LayoutFamily, type LayoutKey, type LayoutMode, type LayoutProps, LayoutState, type LayoutToken, type UtilityToken, type VariantSelection, createTailwindPipeline, defaultDependencyRules };
|
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
// ../../lib/primitive/src/utils/is-object.ts
|
|
2
|
+
function isString(value) {
|
|
3
|
+
return typeof value === "string";
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// ../../lib/primitive/src/utils/assert-never.ts
|
|
7
|
+
function assertNever(value) {
|
|
8
|
+
throw new Error(`Unexpected value: ${String(value)}`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// ../../lib/primitive/src/utils/cn.ts
|
|
12
|
+
import { clsx } from "clsx";
|
|
13
|
+
function cn(...inputs) {
|
|
14
|
+
return clsx(...inputs);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// ../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.mjs
|
|
18
|
+
import { clsx as clsx2 } from "clsx";
|
|
19
|
+
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
20
|
+
var cx = clsx2;
|
|
21
|
+
var cva = (base, config) => (props) => {
|
|
22
|
+
var _config_compoundVariants;
|
|
23
|
+
if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
24
|
+
const { variants, defaultVariants } = config;
|
|
25
|
+
const getVariantClassNames = Object.keys(variants).map((variant) => {
|
|
26
|
+
const variantProp = props === null || props === void 0 ? void 0 : props[variant];
|
|
27
|
+
const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
|
|
28
|
+
if (variantProp === null) return null;
|
|
29
|
+
const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
|
|
30
|
+
return variants[variant][variantKey];
|
|
31
|
+
});
|
|
32
|
+
const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
|
|
33
|
+
let [key, value] = param;
|
|
34
|
+
if (value === void 0) {
|
|
35
|
+
return acc;
|
|
36
|
+
}
|
|
37
|
+
acc[key] = value;
|
|
38
|
+
return acc;
|
|
39
|
+
}, {});
|
|
40
|
+
const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param) => {
|
|
41
|
+
let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
|
|
42
|
+
return Object.entries(compoundVariantOptions).every((param2) => {
|
|
43
|
+
let [key, value] = param2;
|
|
44
|
+
return Array.isArray(value) ? value.includes({
|
|
45
|
+
...defaultVariants,
|
|
46
|
+
...propsWithoutUndefined
|
|
47
|
+
}[key]) : {
|
|
48
|
+
...defaultVariants,
|
|
49
|
+
...propsWithoutUndefined
|
|
50
|
+
}[key] === value;
|
|
51
|
+
}) ? [
|
|
52
|
+
...acc,
|
|
53
|
+
cvClass,
|
|
54
|
+
cvClassName
|
|
55
|
+
] : acc;
|
|
56
|
+
}, []);
|
|
57
|
+
return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// ../../lib/styling/src/cva.ts
|
|
61
|
+
function cva2(base, config) {
|
|
62
|
+
const fn = cva(base, config);
|
|
63
|
+
return (props) => cn(fn(props));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ../../lib/styling/src/static-class-resolver.ts
|
|
67
|
+
var StaticClassResolver = class {
|
|
68
|
+
#baseClass;
|
|
69
|
+
#cache = /* @__PURE__ */ new Map();
|
|
70
|
+
#resolveTag;
|
|
71
|
+
constructor(baseClass, tagMap) {
|
|
72
|
+
this.#baseClass = Array.isArray(baseClass) ? baseClass.join(" ") : baseClass;
|
|
73
|
+
this.#resolveTag = tagMap ? (tag) => {
|
|
74
|
+
const extra = tagMap[tag];
|
|
75
|
+
if (!extra) return this.#baseClass;
|
|
76
|
+
const extraStr = Array.isArray(extra) ? extra.join(" ") : extra;
|
|
77
|
+
return `${this.#baseClass} ${extraStr}`;
|
|
78
|
+
} : () => this.#baseClass;
|
|
79
|
+
}
|
|
80
|
+
resolve(tag, skipTagMap = false) {
|
|
81
|
+
if (typeof tag !== "string" || skipTagMap) return this.#baseClass;
|
|
82
|
+
const cached = this.#cache.get(tag);
|
|
83
|
+
if (cached !== void 0) {
|
|
84
|
+
this.#cache.delete(tag);
|
|
85
|
+
this.#cache.set(tag, cached);
|
|
86
|
+
return cached;
|
|
87
|
+
}
|
|
88
|
+
const result = this.#resolveTag(tag);
|
|
89
|
+
this.#cache.set(tag, result);
|
|
90
|
+
if (this.#cache.size > 200) {
|
|
91
|
+
const lru = this.#cache.keys().next().value;
|
|
92
|
+
if (lru !== void 0) this.#cache.delete(lru);
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// ../../lib/styling/src/variant-class-resolver.ts
|
|
99
|
+
var VariantClassResolver = class _VariantClassResolver {
|
|
100
|
+
#cvaFn;
|
|
101
|
+
#presetMap;
|
|
102
|
+
#variantKeys;
|
|
103
|
+
#precomputedClasses;
|
|
104
|
+
#cache = /* @__PURE__ */ new Map();
|
|
105
|
+
constructor(cvaFn, presetMap, variantKeys, precomputedClasses) {
|
|
106
|
+
this.#cvaFn = cvaFn ?? null;
|
|
107
|
+
this.#presetMap = Object.freeze(presetMap ?? {});
|
|
108
|
+
this.#variantKeys = variantKeys ?? null;
|
|
109
|
+
this.#precomputedClasses = precomputedClasses ?? null;
|
|
110
|
+
}
|
|
111
|
+
resolve({ props, variantKey }) {
|
|
112
|
+
const normalizedKey = variantKey ?? "__none__";
|
|
113
|
+
const cacheKey = this.#createCacheKey(props, normalizedKey);
|
|
114
|
+
if (this.#precomputedClasses !== null) {
|
|
115
|
+
const precomputed = this.#precomputedClasses[cacheKey];
|
|
116
|
+
if (precomputed !== void 0) return precomputed;
|
|
117
|
+
}
|
|
118
|
+
const cached = this.#cache.get(cacheKey);
|
|
119
|
+
if (cached !== void 0) {
|
|
120
|
+
this.#cache.delete(cacheKey);
|
|
121
|
+
this.#cache.set(cacheKey, cached);
|
|
122
|
+
return cached;
|
|
123
|
+
}
|
|
124
|
+
const result = this.#compute(props, variantKey);
|
|
125
|
+
this.#cache.set(cacheKey, result);
|
|
126
|
+
if (this.#cache.size > 1e3) {
|
|
127
|
+
const lru = this.#cache.keys().next().value;
|
|
128
|
+
if (lru !== void 0) this.#cache.delete(lru);
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
#compute(props, variantKey) {
|
|
133
|
+
if (!this.#cvaFn) return "";
|
|
134
|
+
if (!variantKey) return this.#cvaFn(props);
|
|
135
|
+
const preset = this.#presetMap[variantKey];
|
|
136
|
+
if (!preset) return this.#cvaFn(props);
|
|
137
|
+
return this.#cvaFn({ ...preset, ...props });
|
|
138
|
+
}
|
|
139
|
+
// When variantKeys is provided, only those keys are included in the cache key — non-variant
|
|
140
|
+
// props (className, id, etc.) produce identical CVA output and must not fragment the cache.
|
|
141
|
+
// Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
|
|
142
|
+
// String is built incrementally to avoid a parts[] array allocation on every render.
|
|
143
|
+
#createCacheKey(props, variantKey) {
|
|
144
|
+
if (this.#variantKeys !== null) {
|
|
145
|
+
let key2 = variantKey;
|
|
146
|
+
for (const k of this.#variantKeys) {
|
|
147
|
+
if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
148
|
+
}
|
|
149
|
+
return key2;
|
|
150
|
+
}
|
|
151
|
+
let key = variantKey;
|
|
152
|
+
for (const k of Object.keys(props).sort()) {
|
|
153
|
+
key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
|
|
154
|
+
}
|
|
155
|
+
return key;
|
|
156
|
+
}
|
|
157
|
+
static #serializeValue(value) {
|
|
158
|
+
if (value === void 0) return "u";
|
|
159
|
+
if (value === null) return "n";
|
|
160
|
+
if (typeof value === "boolean") return `b:${value}`;
|
|
161
|
+
if (typeof value === "string") return `s:${value}`;
|
|
162
|
+
return `x:${String(value)}`;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// ../../lib/styling/src/create-class-pipeline.ts
|
|
167
|
+
function createClassPipeline(resolved) {
|
|
168
|
+
const baseClass = resolved.baseClassName ?? "";
|
|
169
|
+
const cvaFn = resolved.variants ? cva2("", {
|
|
170
|
+
variants: resolved.variants,
|
|
171
|
+
defaultVariants: resolved.defaultVariants,
|
|
172
|
+
compoundVariants: resolved.compoundVariants
|
|
173
|
+
}) : null;
|
|
174
|
+
const variantKeys = resolved.variants ? new Set(Object.keys(resolved.variants)) : void 0;
|
|
175
|
+
const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
|
|
176
|
+
const variantResolver = new VariantClassResolver(
|
|
177
|
+
cvaFn,
|
|
178
|
+
resolved.presetMap,
|
|
179
|
+
variantKeys,
|
|
180
|
+
resolved.precomputedClasses
|
|
181
|
+
);
|
|
182
|
+
return function resolveClasses(tag, props, className, variantKey) {
|
|
183
|
+
const staticClasses = staticResolver.resolve(tag, variantKey !== void 0);
|
|
184
|
+
const variantClasses = variantResolver.resolve({ props, variantKey });
|
|
185
|
+
if (!className)
|
|
186
|
+
return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
|
|
187
|
+
return cn(staticClasses, variantClasses, className);
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// ../tailwind/src/class-builder.ts
|
|
192
|
+
var ClassBuilder = class {
|
|
193
|
+
build(tokens) {
|
|
194
|
+
const layout = [];
|
|
195
|
+
const normal = [];
|
|
196
|
+
for (const token of tokens) {
|
|
197
|
+
switch (token.kind) {
|
|
198
|
+
case "layout": {
|
|
199
|
+
layout.push(token.raw);
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
case "utility":
|
|
203
|
+
case "gap":
|
|
204
|
+
case "conditional": {
|
|
205
|
+
normal.push(token.raw);
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
default:
|
|
209
|
+
throw assertNever(token);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return [...this.#dedupe(layout).toSorted(), ...this.#dedupe(normal)].join(" ");
|
|
213
|
+
}
|
|
214
|
+
#dedupe(arr) {
|
|
215
|
+
return [...new Set(arr)];
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// ../tailwind/src/layout-keys.ts
|
|
220
|
+
var layoutKeys = [
|
|
221
|
+
"flex",
|
|
222
|
+
"inline-flex",
|
|
223
|
+
"grid",
|
|
224
|
+
"inline-grid",
|
|
225
|
+
"block",
|
|
226
|
+
"inline-block",
|
|
227
|
+
"inline",
|
|
228
|
+
"hidden",
|
|
229
|
+
"contents",
|
|
230
|
+
"flow-root",
|
|
231
|
+
"list-item",
|
|
232
|
+
"table",
|
|
233
|
+
"table-caption",
|
|
234
|
+
"table-cell",
|
|
235
|
+
"table-column",
|
|
236
|
+
"table-column-group",
|
|
237
|
+
"table-footer-group",
|
|
238
|
+
"table-header-group",
|
|
239
|
+
"table-row-group",
|
|
240
|
+
"table-row"
|
|
241
|
+
];
|
|
242
|
+
|
|
243
|
+
// ../tailwind/src/constants.ts
|
|
244
|
+
var LAYOUT_OWNED_KEYS = new Set(layoutKeys);
|
|
245
|
+
var LAYOUT_FAMILY_MAP = {
|
|
246
|
+
flex: "flex",
|
|
247
|
+
"inline-flex": "flex",
|
|
248
|
+
grid: "grid",
|
|
249
|
+
"inline-grid": "grid",
|
|
250
|
+
block: "none",
|
|
251
|
+
"inline-block": "none",
|
|
252
|
+
inline: "none",
|
|
253
|
+
hidden: "none",
|
|
254
|
+
contents: "none",
|
|
255
|
+
"flow-root": "none",
|
|
256
|
+
"list-item": "none",
|
|
257
|
+
table: "none",
|
|
258
|
+
"table-caption": "none",
|
|
259
|
+
"table-cell": "none",
|
|
260
|
+
"table-column": "none",
|
|
261
|
+
"table-column-group": "none",
|
|
262
|
+
"table-footer-group": "none",
|
|
263
|
+
"table-header-group": "none",
|
|
264
|
+
"table-row-group": "none",
|
|
265
|
+
"table-row": "none"
|
|
266
|
+
};
|
|
267
|
+
var EMPTY_SET = /* @__PURE__ */ new Set();
|
|
268
|
+
var COMPOUND_META_KEYS = /* @__PURE__ */ new Set(["class"]);
|
|
269
|
+
|
|
270
|
+
// ../tailwind/src/class-classifier.ts
|
|
271
|
+
var CONDITIONALS = {
|
|
272
|
+
"[&.flex": "flex",
|
|
273
|
+
"[&.grid": "grid"
|
|
274
|
+
};
|
|
275
|
+
var ClassClassifier = class _ClassClassifier {
|
|
276
|
+
static #getBaseUtility(token) {
|
|
277
|
+
let depth = 0;
|
|
278
|
+
for (let i = token.length - 1; i >= 0; i--) {
|
|
279
|
+
const char = token[i];
|
|
280
|
+
if (char === "]") depth++;
|
|
281
|
+
else if (char === "[") depth--;
|
|
282
|
+
else if (char === ":" && depth === 0 && token[i - 1] !== "\\") {
|
|
283
|
+
return token.slice(i + 1);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return token;
|
|
287
|
+
}
|
|
288
|
+
classify(token) {
|
|
289
|
+
const base = _ClassClassifier.#getBaseUtility(token);
|
|
290
|
+
if (LAYOUT_OWNED_KEYS.has(base)) {
|
|
291
|
+
return {
|
|
292
|
+
kind: "layout",
|
|
293
|
+
value: base,
|
|
294
|
+
raw: token
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
for (const [prefix, requires] of Object.entries(CONDITIONALS)) {
|
|
298
|
+
if (token.startsWith(prefix)) {
|
|
299
|
+
return {
|
|
300
|
+
kind: "conditional",
|
|
301
|
+
requires,
|
|
302
|
+
raw: token
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return base === "gap" || base.startsWith("gap-") ? {
|
|
307
|
+
kind: "gap",
|
|
308
|
+
raw: token
|
|
309
|
+
} : {
|
|
310
|
+
kind: "utility",
|
|
311
|
+
base,
|
|
312
|
+
raw: token
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
// ../tailwind/src/dependency-rules.ts
|
|
318
|
+
var defaultDependencyRules = {
|
|
319
|
+
flex: [/^flex-/, /^grow/, /^shrink/, /^basis-/],
|
|
320
|
+
grid: [/^grid-/, /^col-/, /^row-/, /^auto-cols-/, /^auto-rows-/]
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
// ../tailwind/src/dependency-evaluator.ts
|
|
324
|
+
var DependencyEvaluator = class {
|
|
325
|
+
constructor(rules) {
|
|
326
|
+
this.rules = rules;
|
|
327
|
+
}
|
|
328
|
+
rules;
|
|
329
|
+
evaluate(token, state) {
|
|
330
|
+
switch (token.kind) {
|
|
331
|
+
case "layout": {
|
|
332
|
+
return token.value === state.mode;
|
|
333
|
+
}
|
|
334
|
+
case "conditional": {
|
|
335
|
+
return token.requires === state.family;
|
|
336
|
+
}
|
|
337
|
+
case "utility": {
|
|
338
|
+
for (const layout of Object.keys(this.rules)) {
|
|
339
|
+
if (this.rules[layout].some((r) => r.test(token.base))) {
|
|
340
|
+
return state.family === layout;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
case "gap": {
|
|
346
|
+
return state.family !== "none";
|
|
347
|
+
}
|
|
348
|
+
default:
|
|
349
|
+
throw assertNever(token);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
// ../tailwind/src/layout-state.ts
|
|
355
|
+
var LayoutState = class {
|
|
356
|
+
#mode;
|
|
357
|
+
#family;
|
|
358
|
+
constructor(mode) {
|
|
359
|
+
this.#mode = mode;
|
|
360
|
+
this.#family = mode === "none" ? "none" : LAYOUT_FAMILY_MAP[mode];
|
|
361
|
+
Object.freeze(this);
|
|
362
|
+
}
|
|
363
|
+
get mode() {
|
|
364
|
+
return this.#mode;
|
|
365
|
+
}
|
|
366
|
+
get family() {
|
|
367
|
+
return this.#family;
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// ../tailwind/src/create-tailwind-pipeline.ts
|
|
372
|
+
var DEV = process.env.NODE_ENV !== "production";
|
|
373
|
+
var pendingAsyncWarns = /* @__PURE__ */ new Set();
|
|
374
|
+
var asyncWarnScheduled = false;
|
|
375
|
+
function flushAsyncWarns() {
|
|
376
|
+
asyncWarnScheduled = false;
|
|
377
|
+
const messages = [...pendingAsyncWarns];
|
|
378
|
+
pendingAsyncWarns.clear();
|
|
379
|
+
for (const msg of messages) {
|
|
380
|
+
console.warn(msg);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function pipelineWarn(strict, message) {
|
|
384
|
+
if (!strict) return;
|
|
385
|
+
if (strict === "async-warn") {
|
|
386
|
+
if (pendingAsyncWarns.has(message)) return;
|
|
387
|
+
pendingAsyncWarns.add(message);
|
|
388
|
+
if (!asyncWarnScheduled) {
|
|
389
|
+
asyncWarnScheduled = true;
|
|
390
|
+
queueMicrotask(flushAsyncWarns);
|
|
391
|
+
}
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
console.warn(message);
|
|
395
|
+
}
|
|
396
|
+
var classifier = new ClassClassifier();
|
|
397
|
+
var evaluator = new DependencyEvaluator(defaultDependencyRules);
|
|
398
|
+
var builder = new ClassBuilder();
|
|
399
|
+
function normalizeVariantValue(value) {
|
|
400
|
+
if (isString(value)) return value;
|
|
401
|
+
return value.join(" ");
|
|
402
|
+
}
|
|
403
|
+
function resolveLayout(props) {
|
|
404
|
+
const active = [];
|
|
405
|
+
for (const key of layoutKeys) {
|
|
406
|
+
if (props[key]) active.push(key);
|
|
407
|
+
}
|
|
408
|
+
if (DEV && active.length > 1) {
|
|
409
|
+
console.warn(
|
|
410
|
+
`[createTailwindPipeline] Multiple display props set (${active.join(", ")}); "${active[0]}" takes precedence.`
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
return active[0] ?? "none";
|
|
414
|
+
}
|
|
415
|
+
function warnReservedLayoutLiterals(strict, tokens) {
|
|
416
|
+
if (!strict) return;
|
|
417
|
+
const reserved = [];
|
|
418
|
+
for (const token of tokens) {
|
|
419
|
+
if (token.kind === "layout") reserved.push(token.raw);
|
|
420
|
+
}
|
|
421
|
+
if (reserved.length === 0) return;
|
|
422
|
+
pipelineWarn(
|
|
423
|
+
strict,
|
|
424
|
+
`[createTailwindPipeline] Reserved display class(es) ${reserved.map((r) => `"${r}"`).join(", ")} found in resolved classes. The display mode is controlled by the display props (flex, inline-flex, grid, block, hidden, etc.), not by class strings.`
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
function getVariantConfig(options) {
|
|
428
|
+
return options.variants;
|
|
429
|
+
}
|
|
430
|
+
function getCompoundVariants(options) {
|
|
431
|
+
return options.compoundVariants ?? [];
|
|
432
|
+
}
|
|
433
|
+
function classifyTokens(className) {
|
|
434
|
+
return className.split(/\s+/).filter(Boolean).map(classifier.classify);
|
|
435
|
+
}
|
|
436
|
+
function compoundDimensions(compounds) {
|
|
437
|
+
if (compounds.length === 0) return EMPTY_SET;
|
|
438
|
+
const dims = /* @__PURE__ */ new Set();
|
|
439
|
+
for (const compound of compounds) {
|
|
440
|
+
for (const key in compound) {
|
|
441
|
+
if (!COMPOUND_META_KEYS.has(key)) dims.add(key);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return dims;
|
|
445
|
+
}
|
|
446
|
+
function getDefaultVariants(options) {
|
|
447
|
+
return options.defaultVariants;
|
|
448
|
+
}
|
|
449
|
+
function resolveActiveSelection(options, variants, props, variantKey) {
|
|
450
|
+
const preset = variantKey ? options.presetMap?.[variantKey] : void 0;
|
|
451
|
+
const defaults = getDefaultVariants(options);
|
|
452
|
+
const selection = {};
|
|
453
|
+
for (const dim in variants) {
|
|
454
|
+
const value = props[dim] ?? preset?.[dim] ?? defaults?.[dim];
|
|
455
|
+
if (value !== void 0 && value !== null) selection[dim] = String(value);
|
|
456
|
+
}
|
|
457
|
+
return selection;
|
|
458
|
+
}
|
|
459
|
+
function warnDeadVariants(strict, options, compoundDims, props, variantKey, state) {
|
|
460
|
+
if (!strict) return;
|
|
461
|
+
const variants = getVariantConfig(options);
|
|
462
|
+
if (!variants) return;
|
|
463
|
+
const selection = resolveActiveSelection(options, variants, props, variantKey);
|
|
464
|
+
for (const dim in selection) {
|
|
465
|
+
if (compoundDims.has(dim)) continue;
|
|
466
|
+
const value = selection[dim];
|
|
467
|
+
const raw = variants[dim]?.[value];
|
|
468
|
+
if (raw == null) continue;
|
|
469
|
+
const classStr = normalizeVariantValue(raw);
|
|
470
|
+
const tokens = classifyTokens(classStr);
|
|
471
|
+
if (tokens.length === 0) continue;
|
|
472
|
+
if (tokens.every((t) => !evaluator.evaluate(t, state))) {
|
|
473
|
+
pipelineWarn(
|
|
474
|
+
strict,
|
|
475
|
+
`[createTailwindPipeline] Variant "${dim}=${value}" contributes only classes stripped under layout mode "${state.mode}" ("${classStr}") \u2014 it produces nothing in this mode.`
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
function createTailwindPipeline(options, strict) {
|
|
481
|
+
const pipeline = createClassPipeline(options);
|
|
482
|
+
const compoundDims = compoundDimensions(getCompoundVariants(options));
|
|
483
|
+
return {
|
|
484
|
+
ownedKeys: LAYOUT_OWNED_KEYS,
|
|
485
|
+
pipeline(tag, props, className, variantKey) {
|
|
486
|
+
const mode = resolveLayout(props);
|
|
487
|
+
const raw = pipeline(tag, props, className, variantKey);
|
|
488
|
+
const tokens = classifyTokens(raw);
|
|
489
|
+
const state = new LayoutState(mode);
|
|
490
|
+
if (DEV) {
|
|
491
|
+
warnReservedLayoutLiterals(strict, tokens);
|
|
492
|
+
warnDeadVariants(strict, options, compoundDims, props, variantKey, state);
|
|
493
|
+
}
|
|
494
|
+
const filtered = tokens.filter((token) => evaluator.evaluate(token, state));
|
|
495
|
+
const built = builder.build(filtered);
|
|
496
|
+
if (mode === "none") return built;
|
|
497
|
+
return filtered.some((t) => t.kind === "layout" && t.value === mode) ? built : cn(mode, built);
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
export {
|
|
502
|
+
ClassBuilder,
|
|
503
|
+
ClassClassifier,
|
|
504
|
+
DependencyEvaluator,
|
|
505
|
+
LayoutState,
|
|
506
|
+
createTailwindPipeline,
|
|
507
|
+
defaultDependencyRules
|
|
508
|
+
};
|