praxis-kit 5.0.0 → 6.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/dist/{chunk-SKAY22CZ.js → chunk-VUULGK5M.js} +161 -72
- package/dist/contract/index.d.ts +27 -1
- package/dist/lit/index.d.ts +27 -1
- package/dist/lit/index.js +158 -76
- package/dist/preact/index.d.ts +27 -1
- package/dist/preact/index.js +147 -70
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -1
- package/dist/react/legacy.d.ts +2 -2
- package/dist/react/legacy.js +1 -1
- package/dist/{react-options-D6rRB2gJ.d.ts → react-options-AitAOrje.d.ts} +27 -1
- package/dist/solid/index.d.ts +27 -1
- package/dist/solid/index.js +138 -67
- package/dist/svelte/Polymorphic.svelte +1 -1
- package/dist/svelte/index.d.ts +32 -2
- package/dist/svelte/index.js +134 -66
- package/dist/tailwind/index.d.ts +89 -54
- package/dist/tailwind/index.js +128 -66
- package/dist/vite-plugin/index.js +14 -2
- package/dist/vue/index.d.ts +27 -1
- package/dist/vue/index.js +136 -67
- package/dist/web/index.d.ts +27 -1
- package/dist/web/index.js +158 -81
- package/package.json +4 -4
package/dist/svelte/index.js
CHANGED
|
@@ -313,6 +313,19 @@ function makeResolveTag(defaultTag) {
|
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
// ../../lib/primitive/src/rule/rule-brand.ts
|
|
317
|
+
var RULE_BRAND = /* @__PURE__ */ Symbol("praxis-kit/dynamic-rule");
|
|
318
|
+
|
|
319
|
+
// ../../lib/primitive/src/rule/is-dynamic-rule.ts
|
|
320
|
+
function isDynamicRule(rule) {
|
|
321
|
+
return isObject(rule, true) && rule[RULE_BRAND] === true;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// ../../lib/primitive/src/rule/resolve-rule.ts
|
|
325
|
+
function resolveRule(rule, context) {
|
|
326
|
+
return isDynamicRule(rule) ? rule.resolve(context) : rule;
|
|
327
|
+
}
|
|
328
|
+
|
|
316
329
|
// ../../lib/primitive/src/utils/assert-never.ts
|
|
317
330
|
function assertNever(value) {
|
|
318
331
|
throw new Error(`Unexpected value: ${String(value)}`);
|
|
@@ -494,6 +507,45 @@ var iterate = Object.freeze({
|
|
|
494
507
|
values
|
|
495
508
|
});
|
|
496
509
|
|
|
510
|
+
// ../../lib/primitive/src/utils/lru-cache.ts
|
|
511
|
+
var LRUCache = class {
|
|
512
|
+
#maxSize;
|
|
513
|
+
#store = /* @__PURE__ */ new Map();
|
|
514
|
+
constructor(maxSize) {
|
|
515
|
+
if (!Number.isInteger(maxSize) || maxSize < 1) {
|
|
516
|
+
throw new RangeError("LRUCache maxSize must be a positive integer.");
|
|
517
|
+
}
|
|
518
|
+
this.#maxSize = maxSize;
|
|
519
|
+
}
|
|
520
|
+
get(key) {
|
|
521
|
+
if (!this.#store.has(key)) return void 0;
|
|
522
|
+
const value = this.#store.get(key);
|
|
523
|
+
this.#store.delete(key);
|
|
524
|
+
this.#store.set(key, value);
|
|
525
|
+
return value;
|
|
526
|
+
}
|
|
527
|
+
set(key, value) {
|
|
528
|
+
this.#store.delete(key);
|
|
529
|
+
this.#store.set(key, value);
|
|
530
|
+
if (this.#store.size > this.#maxSize) {
|
|
531
|
+
const lru = this.#store.keys().next().value;
|
|
532
|
+
if (lru !== void 0) this.#store.delete(lru);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
has(key) {
|
|
536
|
+
return this.#store.has(key);
|
|
537
|
+
}
|
|
538
|
+
delete(key) {
|
|
539
|
+
return this.#store.delete(key);
|
|
540
|
+
}
|
|
541
|
+
get size() {
|
|
542
|
+
return this.#store.size;
|
|
543
|
+
}
|
|
544
|
+
clear() {
|
|
545
|
+
this.#store.clear();
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
|
|
497
549
|
// ../../lib/primitive/src/utils/merge-props.ts
|
|
498
550
|
function mergeProps(defaultProps, props) {
|
|
499
551
|
return {
|
|
@@ -538,28 +590,6 @@ function isTag(...args) {
|
|
|
538
590
|
return tag !== void 0 && set2.has(tag);
|
|
539
591
|
}
|
|
540
592
|
|
|
541
|
-
// ../../lib/contract/src/strict/invariant-base.ts
|
|
542
|
-
var InvariantBase = class {
|
|
543
|
-
diagnostics;
|
|
544
|
-
constructor(diagnostics) {
|
|
545
|
-
this.diagnostics = diagnostics;
|
|
546
|
-
}
|
|
547
|
-
get active() {
|
|
548
|
-
return this.diagnostics.active;
|
|
549
|
-
}
|
|
550
|
-
violate(input) {
|
|
551
|
-
this.diagnostics.error(input);
|
|
552
|
-
}
|
|
553
|
-
// Always caps at warn — never throws. ARIA 'warning' violations route here
|
|
554
|
-
// so they surface even in strict='throw' mode without aborting a render.
|
|
555
|
-
warn(input) {
|
|
556
|
-
this.diagnostics.warn(input);
|
|
557
|
-
}
|
|
558
|
-
invariant(condition, input) {
|
|
559
|
-
if (!condition) this.violate(input);
|
|
560
|
-
}
|
|
561
|
-
};
|
|
562
|
-
|
|
563
593
|
// ../../lib/contract/src/diagnostics/aria.ts
|
|
564
594
|
import { DiagnosticCategory, DiagnosticCode } from "../_shared/diagnostics.js";
|
|
565
595
|
var AriaDiagnostics = {
|
|
@@ -916,6 +946,28 @@ var SlotDiagnostics = {
|
|
|
916
946
|
}
|
|
917
947
|
};
|
|
918
948
|
|
|
949
|
+
// ../../lib/contract/src/strict/invariant-base.ts
|
|
950
|
+
var InvariantBase = class {
|
|
951
|
+
diagnostics;
|
|
952
|
+
constructor(diagnostics) {
|
|
953
|
+
this.diagnostics = diagnostics;
|
|
954
|
+
}
|
|
955
|
+
get active() {
|
|
956
|
+
return this.diagnostics.active;
|
|
957
|
+
}
|
|
958
|
+
violate(input) {
|
|
959
|
+
this.diagnostics.error(input);
|
|
960
|
+
}
|
|
961
|
+
// Always caps at warn — never throws. ARIA 'warning' violations route here
|
|
962
|
+
// so they surface even in strict='throw' mode without aborting a render.
|
|
963
|
+
warn(input) {
|
|
964
|
+
this.diagnostics.warn(input);
|
|
965
|
+
}
|
|
966
|
+
invariant(condition, input) {
|
|
967
|
+
if (!condition) this.violate(input);
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
|
|
919
971
|
// ../../lib/contract/src/aria/polymorphic-validator.ts
|
|
920
972
|
var VALID = [{ valid: true }];
|
|
921
973
|
function isIntrinsicTag(tag) {
|
|
@@ -927,8 +979,7 @@ function omitProp(obj, key) {
|
|
|
927
979
|
}
|
|
928
980
|
var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
929
981
|
#extraRules;
|
|
930
|
-
#planCache =
|
|
931
|
-
static #MAX_CACHE = 100;
|
|
982
|
+
#planCache = new LRUCache(100);
|
|
932
983
|
// Memoized AriaFix objects keyed by attribute name — the ARIA attribute set is
|
|
933
984
|
// finite so this Map is bounded and avoids recreating closures on every cache miss.
|
|
934
985
|
static #removeAttributeFixCache = /* @__PURE__ */ new Map();
|
|
@@ -1084,8 +1135,6 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1084
1135
|
if (!isNull(key)) {
|
|
1085
1136
|
const cached = this.#planCache.get(key);
|
|
1086
1137
|
if (cached !== void 0) {
|
|
1087
|
-
this.#planCache.delete(key);
|
|
1088
|
-
this.#planCache.set(key, cached);
|
|
1089
1138
|
if (cached.violations.length > 0) this.report(cached.violations);
|
|
1090
1139
|
return {
|
|
1091
1140
|
props: _AriaPolicyEngine.#applyPlan(props, cached.removals, cached.updates),
|
|
@@ -1102,10 +1151,6 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1102
1151
|
);
|
|
1103
1152
|
const plan = { removals, updates, violations: result.violations };
|
|
1104
1153
|
this.#planCache.set(key, plan);
|
|
1105
|
-
if (this.#planCache.size > _AriaPolicyEngine.#MAX_CACHE) {
|
|
1106
|
-
const lru = this.#planCache.keys().next().value;
|
|
1107
|
-
if (lru !== void 0) this.#planCache.delete(lru);
|
|
1108
|
-
}
|
|
1109
1154
|
}
|
|
1110
1155
|
return result;
|
|
1111
1156
|
}
|
|
@@ -1761,10 +1806,22 @@ var RuleValidator = class _RuleValidator extends InvariantBase {
|
|
|
1761
1806
|
|
|
1762
1807
|
// ../../lib/contract/src/children/children-evaluator.ts
|
|
1763
1808
|
var isTextLike = (child) => isString(child) || isNumber(child);
|
|
1809
|
+
function checkPositionCardinalityInvariant(rules, context) {
|
|
1810
|
+
iterate.forEach(rules, (rule) => {
|
|
1811
|
+
const { name, position, cardinality } = rule;
|
|
1812
|
+
if ((position === "first" || position === "last") && (cardinality.kind === "unbounded" || cardinality.max > 1)) {
|
|
1813
|
+
throw new RangeError(
|
|
1814
|
+
`ChildrenEvaluator [${context}]: rule "${name}" sets position="${position}" with an unbound or >1 max. position="first|last" implies max=1.`
|
|
1815
|
+
);
|
|
1816
|
+
}
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1764
1819
|
var ChildrenEvaluator = class extends InvariantBase {
|
|
1765
1820
|
#context;
|
|
1766
|
-
|
|
1767
|
-
#
|
|
1821
|
+
/** Rules with a static cardinality — normalized once, reused on every evaluate() call. */
|
|
1822
|
+
#staticRules;
|
|
1823
|
+
/** Rules whose cardinality is `dynamic(...)` — re-resolved against a ChildRuleContext per call. */
|
|
1824
|
+
#dynamicRuleInputs;
|
|
1768
1825
|
#matcher;
|
|
1769
1826
|
#ruleValidator;
|
|
1770
1827
|
#exclusiveChildren;
|
|
@@ -1772,29 +1829,39 @@ var ChildrenEvaluator = class extends InvariantBase {
|
|
|
1772
1829
|
constructor(rules, diagnostics, context = "Component", options = {}) {
|
|
1773
1830
|
super(diagnostics);
|
|
1774
1831
|
this.#context = context;
|
|
1775
|
-
this.#rules = rules.map((r) => normalizeChildRule(r));
|
|
1776
|
-
this.#ruleNames = this.#rules.map((r) => r.name);
|
|
1777
1832
|
this.#exclusiveChildren = options.exclusiveChildren ?? false;
|
|
1778
1833
|
this.#allowText = options.allowText ?? true;
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
);
|
|
1785
|
-
}
|
|
1834
|
+
const staticRuleInputs = [];
|
|
1835
|
+
const dynamicRuleInputs = [];
|
|
1836
|
+
iterate.forEach(rules, (rule) => {
|
|
1837
|
+
if (isDynamicRule(rule.cardinality)) dynamicRuleInputs.push(rule);
|
|
1838
|
+
else staticRuleInputs.push(rule);
|
|
1786
1839
|
});
|
|
1787
|
-
this.#
|
|
1840
|
+
this.#dynamicRuleInputs = dynamicRuleInputs;
|
|
1841
|
+
this.#staticRules = staticRuleInputs.map(
|
|
1842
|
+
(r) => normalizeChildRule(r)
|
|
1843
|
+
);
|
|
1788
1844
|
this.#ruleValidator = new RuleValidator(context, diagnostics);
|
|
1845
|
+
if (this.#dynamicRuleInputs.length === 0) {
|
|
1846
|
+
checkPositionCardinalityInvariant(this.#staticRules, context);
|
|
1847
|
+
this.#matcher = new RuleMatcher(this.#staticRules);
|
|
1848
|
+
} else {
|
|
1849
|
+
this.#matcher = void 0;
|
|
1850
|
+
}
|
|
1789
1851
|
}
|
|
1790
|
-
|
|
1852
|
+
/**
|
|
1853
|
+
* @param context Required when any rule has a `dynamic(...)` cardinality —
|
|
1854
|
+
* supplies the resolved tag/props those rules are evaluated against.
|
|
1855
|
+
*/
|
|
1856
|
+
evaluate(children, context) {
|
|
1791
1857
|
if (!this.active) return;
|
|
1858
|
+
const { rules, matcher } = this.#resolveRules(context);
|
|
1792
1859
|
const {
|
|
1793
1860
|
matrix,
|
|
1794
1861
|
unexpectedIndices: rawUnexpectedIndices,
|
|
1795
1862
|
ambiguousIndices
|
|
1796
|
-
} =
|
|
1797
|
-
this.#ruleValidator.validate(
|
|
1863
|
+
} = matcher.match(children);
|
|
1864
|
+
this.#ruleValidator.validate(rules, matrix, children.length);
|
|
1798
1865
|
const unexpectedIndices = new Set(
|
|
1799
1866
|
[...rawUnexpectedIndices].filter(
|
|
1800
1867
|
(ci) => isTextLike(children[ci]) ? this.#allowText === false : this.#exclusiveChildren
|
|
@@ -1808,11 +1875,28 @@ var ChildrenEvaluator = class extends InvariantBase {
|
|
|
1808
1875
|
this.violate(ContractDiagnostics.unexpectedChild(typeName, ci, this.#context));
|
|
1809
1876
|
} else {
|
|
1810
1877
|
const matches = matrix.childToRules.forward.get(ci);
|
|
1811
|
-
const names = [...matches].map((ri) =>
|
|
1878
|
+
const names = [...matches].map((ri) => rules[ri]?.name ?? `#${ri}`);
|
|
1812
1879
|
this.violate(ContractDiagnostics.ambiguousChild(typeName, ci, names, this.#context));
|
|
1813
1880
|
}
|
|
1814
1881
|
});
|
|
1815
1882
|
}
|
|
1883
|
+
#resolveRules(context) {
|
|
1884
|
+
if (this.#dynamicRuleInputs.length === 0) {
|
|
1885
|
+
return { rules: this.#staticRules, matcher: this.#matcher };
|
|
1886
|
+
}
|
|
1887
|
+
if (context === void 0) {
|
|
1888
|
+
throw new RangeError(
|
|
1889
|
+
`ChildrenEvaluator [${this.#context}]: rule(s) have a dynamic(...) cardinality \u2014 evaluate() requires a context argument to resolve them.`
|
|
1890
|
+
);
|
|
1891
|
+
}
|
|
1892
|
+
const resolvedDynamicRules = this.#dynamicRuleInputs.map((r) => {
|
|
1893
|
+
const cardinality = resolveRule(r.cardinality, context);
|
|
1894
|
+
return normalizeChildRule({ ...r, cardinality });
|
|
1895
|
+
});
|
|
1896
|
+
checkPositionCardinalityInvariant(resolvedDynamicRules, this.#context);
|
|
1897
|
+
const rules = [...this.#staticRules, ...resolvedDynamicRules];
|
|
1898
|
+
return { rules, matcher: new RuleMatcher(rules) };
|
|
1899
|
+
}
|
|
1816
1900
|
};
|
|
1817
1901
|
|
|
1818
1902
|
// ../../lib/contract/src/props/get-disabled-props.ts
|
|
@@ -2141,7 +2225,7 @@ function cva2(base, config) {
|
|
|
2141
2225
|
// ../../lib/styling/src/static-class-resolver.ts
|
|
2142
2226
|
var StaticClassResolver = class {
|
|
2143
2227
|
#baseClass;
|
|
2144
|
-
#cache =
|
|
2228
|
+
#cache = new LRUCache(200);
|
|
2145
2229
|
#resolveTag;
|
|
2146
2230
|
constructor(baseClass, tagMap) {
|
|
2147
2231
|
this.#baseClass = Array.isArray(baseClass) ? baseClass.join(" ") : baseClass;
|
|
@@ -2155,17 +2239,9 @@ var StaticClassResolver = class {
|
|
|
2155
2239
|
resolve(tag, skipTagMap = false) {
|
|
2156
2240
|
if (typeof tag !== "string" || skipTagMap) return this.#baseClass;
|
|
2157
2241
|
const cached = this.#cache.get(tag);
|
|
2158
|
-
if (cached !== void 0)
|
|
2159
|
-
this.#cache.delete(tag);
|
|
2160
|
-
this.#cache.set(tag, cached);
|
|
2161
|
-
return cached;
|
|
2162
|
-
}
|
|
2242
|
+
if (cached !== void 0) return cached;
|
|
2163
2243
|
const result = this.#resolveTag(tag);
|
|
2164
2244
|
this.#cache.set(tag, result);
|
|
2165
|
-
if (this.#cache.size > 200) {
|
|
2166
|
-
const lru = this.#cache.keys().next().value;
|
|
2167
|
-
if (lru !== void 0) this.#cache.delete(lru);
|
|
2168
|
-
}
|
|
2169
2245
|
return result;
|
|
2170
2246
|
}
|
|
2171
2247
|
};
|
|
@@ -2176,7 +2252,7 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
2176
2252
|
#recipeMap;
|
|
2177
2253
|
#variantKeys;
|
|
2178
2254
|
#precomputedClasses;
|
|
2179
|
-
#cache =
|
|
2255
|
+
#cache = new LRUCache(1e3);
|
|
2180
2256
|
constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
|
|
2181
2257
|
this.#cvaFn = cvaFn ?? null;
|
|
2182
2258
|
this.#recipeMap = Object.freeze(recipeMap ?? {});
|
|
@@ -2191,17 +2267,9 @@ var VariantClassResolver = class _VariantClassResolver {
|
|
|
2191
2267
|
if (precomputed !== void 0) return precomputed;
|
|
2192
2268
|
}
|
|
2193
2269
|
const cached = this.#cache.get(cacheKey);
|
|
2194
|
-
if (cached !== void 0)
|
|
2195
|
-
this.#cache.delete(cacheKey);
|
|
2196
|
-
this.#cache.set(cacheKey, cached);
|
|
2197
|
-
return cached;
|
|
2198
|
-
}
|
|
2270
|
+
if (cached !== void 0) return cached;
|
|
2199
2271
|
const result = this.#compute(props, recipe);
|
|
2200
2272
|
this.#cache.set(cacheKey, result);
|
|
2201
|
-
if (this.#cache.size > 1e3) {
|
|
2202
|
-
const lru = this.#cache.keys().next().value;
|
|
2203
|
-
if (lru !== void 0) this.#cache.delete(lru);
|
|
2204
|
-
}
|
|
2205
2273
|
return result;
|
|
2206
2274
|
}
|
|
2207
2275
|
#compute(props, recipe) {
|
package/dist/tailwind/index.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { Diagnostics } from '../_shared/diagnostics.js';
|
|
2
|
-
import { RequireAtLeastOne, Simplify } from 'type-fest';
|
|
2
|
+
import { RequireAtLeastOne, Simplify, ValueOf } from 'type-fest';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Canonical list of reserved layout prop names.
|
|
6
|
+
*
|
|
7
|
+
* This array is the single source of truth for every supported CSS `display`
|
|
8
|
+
* value exposed as a boolean prop. The `LayoutKey` type is derived directly
|
|
9
|
+
* from this list.
|
|
10
|
+
*
|
|
11
|
+
* To add a new display mode:
|
|
12
|
+
* 1. Add the display value here.
|
|
13
|
+
* 2. Register its layout family in `LAYOUT_FAMILY_MAP`.
|
|
14
|
+
*
|
|
15
|
+
* Prop names intentionally match the corresponding Tailwind/CSS display
|
|
16
|
+
* utilities, so no additional prop-to-class mapping is required.
|
|
17
|
+
*/
|
|
18
|
+
declare const layoutKeys: readonly ["flex", "inline-flex", "grid", "inline-grid", "block", "inline-block", "inline", "hidden", "contents", "flow-root", "list-item", "table", "inline-table", "table-caption", "table-cell", "table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row-group", "table-row"];
|
|
3
19
|
|
|
4
20
|
type StringMap<T = unknown> = Record<string, T>;
|
|
5
21
|
type AnyRecord = StringMap<unknown>;
|
|
@@ -94,35 +110,19 @@ type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
|
|
|
94
110
|
readonly _pluginProps?: TProps;
|
|
95
111
|
}>;
|
|
96
112
|
|
|
97
|
-
/**
|
|
98
|
-
* Canonical list of reserved layout prop names.
|
|
99
|
-
*
|
|
100
|
-
* This array is the single source of truth for every supported CSS `display`
|
|
101
|
-
* value exposed as a boolean prop. The `LayoutKey` type is derived directly
|
|
102
|
-
* from this list.
|
|
103
|
-
*
|
|
104
|
-
* To add a new display mode:
|
|
105
|
-
* 1. Add the display value here.
|
|
106
|
-
* 2. Register its layout family in `LAYOUT_FAMILY_MAP`.
|
|
107
|
-
*
|
|
108
|
-
* Prop names intentionally match the corresponding Tailwind/CSS display
|
|
109
|
-
* utilities, so no additional prop-to-class mapping is required.
|
|
110
|
-
*/
|
|
111
|
-
declare const layoutKeys: readonly ["flex", "inline-flex", "grid", "inline-grid", "block", "inline-block", "inline", "hidden", "contents", "flow-root", "list-item", "table", "inline-table", "table-caption", "table-cell", "table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row-group", "table-row"];
|
|
112
|
-
|
|
113
113
|
type TupleValues<T extends readonly unknown[]> = T[number];
|
|
114
|
-
type ValueOf<T> = T[keyof T];
|
|
115
114
|
type LayoutKey<T extends readonly string[]> = TupleValues<T>;
|
|
116
115
|
type LayoutFamily<M extends StringMap<string>> = ValueOf<M>;
|
|
117
|
-
type
|
|
116
|
+
type ResolvedLayout<T extends readonly string[]> = LayoutKey<T> | 'none';
|
|
118
117
|
type ExclusiveTrueProp<K extends PropertyKey> = {
|
|
119
118
|
[P in K]: Simplify<Record<P, true> & Partial<Record<Exclude<K, P>, never>>>;
|
|
120
119
|
}[K];
|
|
121
120
|
/**
|
|
122
|
-
* Mutually exclusive
|
|
121
|
+
* Mutually exclusive layout shorthand props.
|
|
123
122
|
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
123
|
+
* Exactly one layout prop may be `true`, or none at all. Multiple `true`
|
|
124
|
+
* props produce a compile-time error. If invalid props reach runtime, the
|
|
125
|
+
* resolver warns and uses the first declared layout.
|
|
126
126
|
*/
|
|
127
127
|
type LayoutProps<T extends readonly string[]> = ExclusiveTrueProp<LayoutKey<T>> | Partial<Record<LayoutKey<T>, never>>;
|
|
128
128
|
|
|
@@ -155,23 +155,76 @@ type Token<TKind extends string, TData extends object = EmptyRecord> = {
|
|
|
155
155
|
kind: TKind;
|
|
156
156
|
raw: string;
|
|
157
157
|
} & TData;
|
|
158
|
-
type
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
158
|
+
type TokenData = {
|
|
159
|
+
layout: {
|
|
160
|
+
value: LayoutKey<typeof layoutKeys>;
|
|
161
|
+
};
|
|
162
|
+
conditional: {
|
|
163
|
+
requires: Exclude<LayoutFamily<typeof LAYOUT_FAMILY_MAP>, 'none'>;
|
|
164
|
+
};
|
|
165
|
+
gap: EmptyRecord;
|
|
166
|
+
shared: EmptyRecord;
|
|
167
|
+
utility: {
|
|
168
|
+
base: string;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
type TokenMap = {
|
|
172
|
+
[K in keyof TokenData]: Token<K, TokenData[K]>;
|
|
173
|
+
};
|
|
174
|
+
type LayoutToken = TokenMap['layout'];
|
|
175
|
+
type ConditionalToken = TokenMap['conditional'];
|
|
176
|
+
type GapToken = TokenMap['gap'];
|
|
177
|
+
type SharedToken = TokenMap['shared'];
|
|
178
|
+
type UtilityToken = TokenMap['utility'];
|
|
179
|
+
type ClassifiedToken = Simplify<ValueOf<TokenMap>>;
|
|
180
|
+
|
|
181
|
+
type VariantSelection = StringMap<string>;
|
|
171
182
|
type CompoundVariant = {
|
|
172
183
|
class?: unknown;
|
|
173
184
|
} & AnyRecord;
|
|
174
185
|
|
|
186
|
+
/**
|
|
187
|
+
* The resolved display mode for a single render.
|
|
188
|
+
*
|
|
189
|
+
* Mode is owned by the display props; a display class literal in the resolved
|
|
190
|
+
* class string is a reserved-literal authoring mistake. Defaults to `'none'`
|
|
191
|
+
* when no prop is set.
|
|
192
|
+
*
|
|
193
|
+
* `family` is derived from mode: `'flex'` for flex/inline-flex, `'grid'` for
|
|
194
|
+
* grid/inline-grid, `'none'` for all other values (and when no prop is set).
|
|
195
|
+
* The evaluator uses family — not mode — for utility and gap filtering.
|
|
196
|
+
*/
|
|
197
|
+
declare class LayoutState {
|
|
198
|
+
#private;
|
|
199
|
+
constructor(mode: ResolvedLayout<typeof layoutKeys>);
|
|
200
|
+
get mode(): ResolvedLayout<typeof layoutKeys>;
|
|
201
|
+
get family(): LayoutFamily<typeof LAYOUT_FAMILY_MAP>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
type PipelineLayoutProps = LayoutProps<typeof layoutKeys>;
|
|
205
|
+
type PipelineLayout = ResolvedLayout<typeof layoutKeys>;
|
|
206
|
+
type PipelineProps = PipelineLayoutProps & AnyRecord;
|
|
207
|
+
interface PipelineInputs {
|
|
208
|
+
readonly props: PipelineProps;
|
|
209
|
+
readonly recipe: string | undefined;
|
|
210
|
+
}
|
|
211
|
+
interface PipelineResolution {
|
|
212
|
+
readonly mode: PipelineLayout;
|
|
213
|
+
readonly state: LayoutState;
|
|
214
|
+
}
|
|
215
|
+
interface PipelineTokens {
|
|
216
|
+
readonly filtered: ClassifiedToken[];
|
|
217
|
+
readonly tokens: ClassifiedToken[];
|
|
218
|
+
}
|
|
219
|
+
type TailwindPipelineArgs = [
|
|
220
|
+
tag: unknown,
|
|
221
|
+
props: PipelineInputs['props'],
|
|
222
|
+
className: ClassName | undefined,
|
|
223
|
+
recipe: PipelineInputs['recipe']
|
|
224
|
+
];
|
|
225
|
+
interface TailwindPipelineContext extends PipelineInputs, PipelineResolution, PipelineTokens {
|
|
226
|
+
}
|
|
227
|
+
|
|
175
228
|
/**
|
|
176
229
|
* Layout-aware class pipeline for Tailwind CSS utility class strings.
|
|
177
230
|
*
|
|
@@ -220,28 +273,10 @@ declare class ClassClassifier {
|
|
|
220
273
|
type DependencyRules = Record<Exclude<LayoutFamily<typeof LAYOUT_FAMILY_MAP>, 'none'>, readonly RegExp[]>;
|
|
221
274
|
declare const defaultDependencyRules: DependencyRules;
|
|
222
275
|
|
|
223
|
-
/**
|
|
224
|
-
* The resolved display mode for a single render.
|
|
225
|
-
*
|
|
226
|
-
* Mode is owned by the display props; a display class literal in the resolved
|
|
227
|
-
* class string is a reserved-literal authoring mistake. Defaults to `'none'`
|
|
228
|
-
* when no prop is set.
|
|
229
|
-
*
|
|
230
|
-
* `family` is derived from mode: `'flex'` for flex/inline-flex, `'grid'` for
|
|
231
|
-
* grid/inline-grid, `'none'` for all other values (and when no prop is set).
|
|
232
|
-
* The evaluator uses family — not mode — for utility and gap filtering.
|
|
233
|
-
*/
|
|
234
|
-
declare class LayoutState {
|
|
235
|
-
#private;
|
|
236
|
-
constructor(mode: LayoutMode<typeof layoutKeys>);
|
|
237
|
-
get mode(): LayoutMode<typeof layoutKeys>;
|
|
238
|
-
get family(): LayoutFamily<typeof LAYOUT_FAMILY_MAP>;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
276
|
declare class DependencyEvaluator {
|
|
242
277
|
private readonly rules;
|
|
243
278
|
constructor(rules: DependencyRules);
|
|
244
279
|
evaluate(token: ClassifiedToken, state: LayoutState): boolean;
|
|
245
280
|
}
|
|
246
281
|
|
|
247
|
-
export { ClassBuilder, ClassClassifier, type ClassToken, type ClassifiedToken, type CompoundVariant, type ConditionalToken, DependencyEvaluator, type DependencyRules, type GapToken, type LayoutFamily, type LayoutKey, type
|
|
282
|
+
export { ClassBuilder, ClassClassifier, type ClassToken, type ClassifiedToken, type CompoundVariant, type ConditionalToken, DependencyEvaluator, type DependencyRules, type GapToken, type LayoutFamily, type LayoutKey, type LayoutProps, LayoutState, type LayoutToken, type ResolvedLayout, type SharedToken, type TailwindPipelineArgs, type TailwindPipelineContext, type UtilityToken, type VariantSelection, createTailwindPipeline, defaultDependencyRules, layoutKeys };
|