@animus-ui/system 0.1.15 → 0.1.17
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 +31 -0
- package/dist/Animus.d.ts +9 -9
- package/dist/Animus.d.ts.map +1 -1
- package/dist/AnimusExtended.d.ts +17 -9
- package/dist/AnimusExtended.d.ts.map +1 -1
- package/dist/SystemBuilder.d.ts +14 -13
- package/dist/SystemBuilder.d.ts.map +1 -1
- package/dist/class-resolver.js +1 -1
- package/dist/createClassResolver-CcCgar2Z.js +360 -0
- package/dist/{createComposedFamily-C4NovMcd.js → createComposedFamily-C9ShrVy6.js} +15 -2
- package/dist/declarations.d.ts +38 -0
- package/dist/declarations.d.ts.map +1 -0
- package/dist/groups/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +308 -28
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/resolveClasses.d.ts +33 -6
- package/dist/runtime/resolveClasses.d.ts.map +1 -1
- package/dist/runtime-entry.js +2 -2
- package/dist/{size-C4gOY6lI.js → size-ZhCTPtA-.js} +12 -1
- package/dist/theme/createTheme.d.ts +30 -2
- package/dist/theme/createTheme.d.ts.map +1 -1
- package/dist/theme/resolveReferences.d.ts +6 -0
- package/dist/theme/resolveReferences.d.ts.map +1 -1
- package/dist/transforms/createTransform.d.ts +2 -0
- package/dist/transforms/createTransform.d.ts.map +1 -1
- package/dist/types/component.d.ts +12 -12
- package/dist/types/component.d.ts.map +1 -1
- package/dist/types/config.d.ts +49 -14
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/properties.d.ts +2 -2
- package/dist/types/properties.d.ts.map +1 -1
- package/dist/types/theme.d.ts +7 -1
- package/dist/types/theme.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/createClassResolver-EpwTL9Sa.js +0 -228
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import { isUnitlessProperty } from "@animus-ui/properties";
|
|
2
|
+
//#region src/runtime/is-dev.ts
|
|
3
|
+
/**
|
|
4
|
+
* The define token is tested as the initializer's own conditional, never from
|
|
5
|
+
* inside the fallback: only there can a minifier drop the dev-gated code.
|
|
6
|
+
*/
|
|
7
|
+
const IS_DEV = typeof __ANIMUS_DEV__ === "boolean" ? __ANIMUS_DEV__ : (() => {
|
|
8
|
+
try {
|
|
9
|
+
if (typeof process !== "undefined" && typeof process.env === "undefined") return true;
|
|
10
|
+
return process.env.NODE_ENV !== "production";
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
})();
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/runtime/witness.ts
|
|
17
|
+
const WITNESS_CAP = 5e3;
|
|
18
|
+
function recordWitness(component, prop, value, outcome) {
|
|
19
|
+
if (!IS_DEV) return;
|
|
20
|
+
const g = globalThis;
|
|
21
|
+
const buf = g.__ANIMUS_WITNESS__ ??= [];
|
|
22
|
+
buf.push({
|
|
23
|
+
component,
|
|
24
|
+
prop,
|
|
25
|
+
value: String(value),
|
|
26
|
+
outcome
|
|
27
|
+
});
|
|
28
|
+
if (buf.length > 5e3) buf.splice(0, buf.length - WITNESS_CAP);
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/runtime/resolveClasses.ts
|
|
32
|
+
/**
|
|
33
|
+
* A mixed property set resolves to unitless: a bare number on a length
|
|
34
|
+
* property is dropped by the parser, `px` on a unitless one shifts layout.
|
|
35
|
+
*/
|
|
36
|
+
function applyUnitFallback(value, cssProperties) {
|
|
37
|
+
if (typeof value === "number") {
|
|
38
|
+
if (cssProperties.some(isUnitlessProperty)) return String(value);
|
|
39
|
+
return `${value}px`;
|
|
40
|
+
}
|
|
41
|
+
return String(value);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The key format is fixed by the Rust css generator; a divergence here misses
|
|
45
|
+
* every static class lookup.
|
|
46
|
+
*/
|
|
47
|
+
function serializeValueKey(value) {
|
|
48
|
+
if (typeof value === "number" || typeof value === "string") return String(value);
|
|
49
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) return Object.keys(value).sort().map((k) => `${k}:${value[k]}`).join("|");
|
|
50
|
+
return String(value);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A callback, inline or configured, can tell `100` from `"100"`, so its static classes are keyed by
|
|
54
|
+
* type: a string is its JSON literal, a number its decimal text, a
|
|
55
|
+
* responsive value `{…}` its `"breakpoint":key` entries in key order. Must
|
|
56
|
+
* stay in step with the Rust css generator.
|
|
57
|
+
*/
|
|
58
|
+
function typedValueKey(value) {
|
|
59
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
60
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
61
|
+
const entries = value;
|
|
62
|
+
return `{${Object.keys(entries).sort().map((k) => `${JSON.stringify(k)}:${typedValueKey(entries[k])}`).join(",")}}`;
|
|
63
|
+
}
|
|
64
|
+
return String(value);
|
|
65
|
+
}
|
|
66
|
+
function isValidTransformResult(result) {
|
|
67
|
+
return typeof result === "string" || typeof result === "number" && Number.isFinite(result);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The domain is results that failed `isValidTransformResult`; a valid string
|
|
71
|
+
* or finite number passed here is mislabeled.
|
|
72
|
+
*/
|
|
73
|
+
function describeResultShape(result) {
|
|
74
|
+
if (result === null) return "null";
|
|
75
|
+
if (Array.isArray(result)) return "array";
|
|
76
|
+
if (typeof result === "number") return "non-finite-number";
|
|
77
|
+
return typeof result;
|
|
78
|
+
}
|
|
79
|
+
function negateCssValue(css) {
|
|
80
|
+
if (css.includes("(")) return `calc(${css} * -1)`;
|
|
81
|
+
if (css === "0" || css === "-0") return "0";
|
|
82
|
+
if (css.startsWith("-")) return css.slice(1);
|
|
83
|
+
return `-${css.startsWith("+") ? css.slice(1) : css}`;
|
|
84
|
+
}
|
|
85
|
+
/** A CSS `<number>`, exponent included. */
|
|
86
|
+
const CSS_NUMBER = String.raw`[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?`;
|
|
87
|
+
const CONTAINER_UNIT = new RegExp(`^${CSS_NUMBER}(?:cqw|cqi|cqh|cqb|cqmin|cqmax)$`);
|
|
88
|
+
const SIZE_LENGTH = new RegExp(`^${CSS_NUMBER}(?:px|rem|vh|vw|vmax|vmin|%)$`);
|
|
89
|
+
const SIZE_PROPERTY = /^(?:left|right|top|bottom|inset|width|height)$|(?:Width|Height|-width|-height)$/;
|
|
90
|
+
/**
|
|
91
|
+
* Values a strict prop's public type admits beside its tokens: zero, the
|
|
92
|
+
* keywords extraction lists for its property, container units, token
|
|
93
|
+
* references, and the lengths size properties take. Must stay in step with
|
|
94
|
+
* the extractor's rule.
|
|
95
|
+
*/
|
|
96
|
+
function isAdmittedWithoutToken(value, dc) {
|
|
97
|
+
if (typeof value === "number") return value === 0;
|
|
98
|
+
if (typeof value !== "string") return true;
|
|
99
|
+
return value === "0" || dc.keywords?.includes(value) === true || value.includes("{") || CONTAINER_UNIT.test(value) || dc.property !== void 0 && SIZE_PROPERTY.test(dc.property) && (SIZE_LENGTH.test(value) || value.startsWith("calc("));
|
|
100
|
+
}
|
|
101
|
+
function resolveEntry(value, dc) {
|
|
102
|
+
const key = String(value);
|
|
103
|
+
let scaleResolved = dc.scaleValues?.[key];
|
|
104
|
+
let negate = false;
|
|
105
|
+
if (scaleResolved == null && dc.negative && typeof value === "number" && value < 0) {
|
|
106
|
+
scaleResolved = dc.scaleValues?.[String(-value)];
|
|
107
|
+
negate = scaleResolved != null;
|
|
108
|
+
}
|
|
109
|
+
if (scaleResolved == null && dc.strict && dc.scaleValues && !isAdmittedWithoutToken(value, dc)) return { entry: value };
|
|
110
|
+
const input = scaleResolved ?? value;
|
|
111
|
+
let transformed = input;
|
|
112
|
+
if (dc.transform) {
|
|
113
|
+
try {
|
|
114
|
+
transformed = dc.transform(input);
|
|
115
|
+
} catch (cause) {
|
|
116
|
+
return { cause };
|
|
117
|
+
}
|
|
118
|
+
if (!isValidTransformResult(transformed)) return { shape: describeResultShape(transformed) };
|
|
119
|
+
}
|
|
120
|
+
let css;
|
|
121
|
+
if (typeof transformed === "number") {
|
|
122
|
+
const cssProperties = dc.properties && dc.properties.length > 0 ? dc.properties : dc.property ? [dc.property] : [];
|
|
123
|
+
css = applyUnitFallback(transformed, cssProperties);
|
|
124
|
+
} else css = String(transformed);
|
|
125
|
+
return negate ? negateCssValue(css) : css;
|
|
126
|
+
}
|
|
127
|
+
const warnedDrops = /* @__PURE__ */ new Set();
|
|
128
|
+
function warnDroppedValue(baseClassName, propName, serializedValue, customOwned) {
|
|
129
|
+
if (IS_DEV) {
|
|
130
|
+
const dedupeKey = `${baseClassName}|${propName}`;
|
|
131
|
+
if (warnedDrops.has(dedupeKey)) return;
|
|
132
|
+
warnedDrops.add(dedupeKey);
|
|
133
|
+
console.warn(customOwned ? `[animus:drop] ${baseClassName}: value ${serializedValue} on custom prop '${propName}' is none of its extracted values and the prop has no runtime slot — it will not render. A literal missing from the prop's strict scale is reported by the build as animus.props.strict-token-miss; a value passed through an untraced alias is not.` : `[animus:drop] ${baseClassName}: value ${serializedValue} on prop '${propName}' matched no static class and no dynamic slot — it will not render. If this prop should accept runtime values, ensure its dynamic config is emitted.`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A value taken from a variant default emits `--{prop}-default`, not the
|
|
138
|
+
* value, so the compose override rule misses and the parent's value wins.
|
|
139
|
+
*/
|
|
140
|
+
function applyVariantClasses(classes, baseClassName, props, config) {
|
|
141
|
+
if (!config.variants) return;
|
|
142
|
+
for (const [prop, vc] of Object.entries(config.variants)) {
|
|
143
|
+
const value = props[prop] ?? vc.default;
|
|
144
|
+
if (value != null) {
|
|
145
|
+
const isDefault = !(prop in props) && vc.default != null;
|
|
146
|
+
classes.push(`${baseClassName}--${prop}-${isDefault ? "default" : value}`);
|
|
147
|
+
recordWitness(baseClassName, prop, value, "static");
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function applyCompoundClasses(classes, props, config) {
|
|
152
|
+
if (!config.compounds) return;
|
|
153
|
+
for (const compound of config.compounds) {
|
|
154
|
+
let match = true;
|
|
155
|
+
for (const [prop, expected] of Object.entries(compound.conditions)) {
|
|
156
|
+
const current = props[prop] ?? config.variants?.[prop]?.default;
|
|
157
|
+
if (Array.isArray(expected) ? !expected.includes(current) : current !== expected) {
|
|
158
|
+
match = false;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (match) classes.push(compound.className);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function applyStateClasses(classes, baseClassName, props, config, activeStates) {
|
|
166
|
+
if (!config.states) return;
|
|
167
|
+
for (const state of config.states) if (props[state]) {
|
|
168
|
+
classes.push(`${baseClassName}--${state}`);
|
|
169
|
+
activeStates.push(state);
|
|
170
|
+
recordWitness(baseClassName, state, "true", "static");
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const warnedInvalidResults = /* @__PURE__ */ new Set();
|
|
174
|
+
function warnInvalidTransformResult(baseClassName, propName, shape) {
|
|
175
|
+
if (IS_DEV) {
|
|
176
|
+
const dedupeKey = `${baseClassName}|${propName}`;
|
|
177
|
+
if (warnedInvalidResults.has(dedupeKey)) return;
|
|
178
|
+
warnedInvalidResults.add(dedupeKey);
|
|
179
|
+
console.warn(`[animus:drop] ${baseClassName}: transform for prop '${propName}' returned ${shape} — expected string or finite number; value dropped`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const warnedThrows = /* @__PURE__ */ new Set();
|
|
183
|
+
const warnedStrictMisses = /* @__PURE__ */ new Set();
|
|
184
|
+
/** Keyed by value, like a throw: each rejected input is reported once. */
|
|
185
|
+
function warnStrictScaleMiss(baseClassName, propName, serializedValue, miss) {
|
|
186
|
+
if (IS_DEV) {
|
|
187
|
+
const dedupeKey = `${baseClassName}|${propName}|${serializedValue}`;
|
|
188
|
+
if (warnedStrictMisses.has(dedupeKey)) return;
|
|
189
|
+
warnedStrictMisses.add(dedupeKey);
|
|
190
|
+
const entry = miss.breakpoint === void 0 ? "" : ` (${String(miss.entry)} at ${miss.breakpoint})`;
|
|
191
|
+
console.warn(`[animus:drop] ${baseClassName}: value ${serializedValue} on prop '${propName}' is not a token of its strict scale${entry}; prop styling dropped`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function describeThrown(cause) {
|
|
195
|
+
try {
|
|
196
|
+
return String(cause);
|
|
197
|
+
} catch {
|
|
198
|
+
return "unprintable thrown value";
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Read as a string so the console never inspects the thrown value itself; a
|
|
203
|
+
* hostile object could rethrow from an inspecting formatter.
|
|
204
|
+
*/
|
|
205
|
+
function thrownStack(cause) {
|
|
206
|
+
try {
|
|
207
|
+
if (!(cause instanceof Error)) return void 0;
|
|
208
|
+
const stack = cause.stack;
|
|
209
|
+
return typeof stack === "string" ? stack : void 0;
|
|
210
|
+
} catch {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Keyed by value as well as prop: each distinct rejected input is reported
|
|
216
|
+
* once, so the warning never names a stale value.
|
|
217
|
+
*/
|
|
218
|
+
function warnTransformThrow(baseClassName, propName, transformName, serializedValue, cause) {
|
|
219
|
+
if (IS_DEV) {
|
|
220
|
+
const dedupeKey = `${baseClassName}|${propName}|${serializedValue}`;
|
|
221
|
+
if (warnedThrows.has(dedupeKey)) return;
|
|
222
|
+
warnedThrows.add(dedupeKey);
|
|
223
|
+
const transform = transformName ? `transform '${transformName}'` : "inline transform";
|
|
224
|
+
const stack = thrownStack(cause);
|
|
225
|
+
console.warn(`[animus:drop] ${baseClassName}: ${transform} for prop '${propName}' threw for value ${serializedValue} (${describeThrown(cause)}); prop styling dropped`, ...stack ? [stack] : []);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Resolution is staged so a drop is atomic: one entry that misses a strict
|
|
230
|
+
* scale, or one transform that throws or returns an invalid result, leaves
|
|
231
|
+
* `classes` and `dynStyle` untouched.
|
|
232
|
+
*/
|
|
233
|
+
function applyDynamicProp(classes, dynStyle, propValue, dc) {
|
|
234
|
+
const staged = [];
|
|
235
|
+
if (typeof propValue === "object" && propValue !== null && !Array.isArray(propValue)) for (const [bp, bpVal] of Object.entries(propValue)) {
|
|
236
|
+
if (bpVal == null) continue;
|
|
237
|
+
const resolved = resolveEntry(bpVal, dc);
|
|
238
|
+
if (typeof resolved !== "string") return "entry" in resolved ? {
|
|
239
|
+
...resolved,
|
|
240
|
+
breakpoint: bp
|
|
241
|
+
} : resolved;
|
|
242
|
+
staged.push(bp === "_" ? [
|
|
243
|
+
dc.slotClass,
|
|
244
|
+
dc.varName,
|
|
245
|
+
resolved
|
|
246
|
+
] : [
|
|
247
|
+
`${dc.slotClass}-${bp}`,
|
|
248
|
+
`${dc.varName}-${bp}`,
|
|
249
|
+
resolved
|
|
250
|
+
]);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
const resolved = resolveEntry(propValue, dc);
|
|
254
|
+
if (typeof resolved !== "string") return resolved;
|
|
255
|
+
staged.push([
|
|
256
|
+
dc.slotClass,
|
|
257
|
+
dc.varName,
|
|
258
|
+
resolved
|
|
259
|
+
]);
|
|
260
|
+
}
|
|
261
|
+
for (const [slotClass, varName, resolved] of staged) {
|
|
262
|
+
classes.push(slotClass);
|
|
263
|
+
dynStyle[varName] = resolved;
|
|
264
|
+
}
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* A declaration prop writes every member of the selected record. The base
|
|
269
|
+
* consuming class applies whenever the prop applies, so a value without a
|
|
270
|
+
* base key reads the base member variables an ancestor wrote, or else leaves
|
|
271
|
+
* lower layers in force. A key outside the scale drops the whole value.
|
|
272
|
+
*/
|
|
273
|
+
function applyDeclarationProp(classes, dynStyle, propValue, dc) {
|
|
274
|
+
const records = dc.declarationScaleValues;
|
|
275
|
+
const memberVars = Object.entries(dc.memberVars);
|
|
276
|
+
const responsive = typeof propValue === "object" && propValue !== null && !Array.isArray(propValue);
|
|
277
|
+
const entries = responsive ? Object.entries(propValue).filter(([, value]) => value != null) : [["_", propValue]];
|
|
278
|
+
const staged = [];
|
|
279
|
+
for (const [breakpoint, value] of entries) {
|
|
280
|
+
const key = String(value);
|
|
281
|
+
if (!Object.prototype.hasOwnProperty.call(records, key)) return responsive ? {
|
|
282
|
+
entry: value,
|
|
283
|
+
breakpoint
|
|
284
|
+
} : { entry: value };
|
|
285
|
+
staged.push([breakpoint, records[key]]);
|
|
286
|
+
}
|
|
287
|
+
if (staged.length === 0) return null;
|
|
288
|
+
classes.push(dc.slotClass);
|
|
289
|
+
for (const [breakpoint, record] of staged) {
|
|
290
|
+
const suffix = breakpoint === "_" ? "" : `-${breakpoint}`;
|
|
291
|
+
if (suffix) classes.push(`${dc.slotClass}${suffix}`);
|
|
292
|
+
for (const [member, varName] of memberVars) dynStyle[`${varName}${suffix}`] = record[member];
|
|
293
|
+
}
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
function resolveClasses(baseClassName, props, config, systemPropMap, dynamicPropConfig) {
|
|
297
|
+
const classes = [baseClassName];
|
|
298
|
+
let dynStyle;
|
|
299
|
+
applyVariantClasses(classes, baseClassName, props, config);
|
|
300
|
+
applyCompoundClasses(classes, props, config);
|
|
301
|
+
const activeStates = [];
|
|
302
|
+
applyStateClasses(classes, baseClassName, props, config, activeStates);
|
|
303
|
+
const systemPropNames = config.systemPropNames || [];
|
|
304
|
+
if (systemPropNames.length > 0) {
|
|
305
|
+
const { customPropMap, customDynamicConfig } = config;
|
|
306
|
+
for (const propName of systemPropNames) {
|
|
307
|
+
if (!(propName in props)) continue;
|
|
308
|
+
const propValue = props[propName];
|
|
309
|
+
if (propValue == null) continue;
|
|
310
|
+
const key = serializeValueKey(propValue);
|
|
311
|
+
const customOwned = customPropMap?.[propName] !== void 0 || customDynamicConfig?.[propName] !== void 0;
|
|
312
|
+
const [classMap, typedProps] = customOwned ? [customPropMap, config.typedCustomProps] : [systemPropMap, config.typedSystemProps];
|
|
313
|
+
const cls = classMap?.[propName]?.[typedProps?.includes(propName) ? typedValueKey(propValue) : key];
|
|
314
|
+
if (cls) {
|
|
315
|
+
classes.push(cls);
|
|
316
|
+
recordWitness(baseClassName, propName, key, "static");
|
|
317
|
+
} else {
|
|
318
|
+
const dc = customOwned ? customDynamicConfig?.[propName] : dynamicPropConfig?.[propName];
|
|
319
|
+
if (dc) {
|
|
320
|
+
const staged = dynStyle ?? {};
|
|
321
|
+
const failure = dc.kind === "declarations" ? applyDeclarationProp(classes, staged, propValue, dc) : applyDynamicProp(classes, staged, propValue, dc);
|
|
322
|
+
if (failure === null) {
|
|
323
|
+
dynStyle = staged;
|
|
324
|
+
recordWitness(baseClassName, propName, key, "dynamic");
|
|
325
|
+
} else {
|
|
326
|
+
if ("shape" in failure) warnInvalidTransformResult(baseClassName, propName, failure.shape);
|
|
327
|
+
else if ("entry" in failure) warnStrictScaleMiss(baseClassName, propName, key, failure);
|
|
328
|
+
else warnTransformThrow(baseClassName, propName, dc.transformName, key, failure.cause);
|
|
329
|
+
recordWitness(baseClassName, propName, key, "drop");
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
warnDroppedValue(baseClassName, propName, key, customOwned);
|
|
333
|
+
recordWitness(baseClassName, propName, key, "drop");
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return {
|
|
339
|
+
classes,
|
|
340
|
+
dynamicStyle: dynStyle,
|
|
341
|
+
activeStates
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/runtime/createClassResolver.ts
|
|
346
|
+
function serializeDynamicStyle(style) {
|
|
347
|
+
return Object.entries(style).map(([property, value]) => `${property}: ${value}`).join("; ");
|
|
348
|
+
}
|
|
349
|
+
function createClassResolver(className, config, systemPropMap, dynamicPropConfig) {
|
|
350
|
+
const resolveAttributes = (props) => {
|
|
351
|
+
const { classes, dynamicStyle } = resolveClasses(className, props || {}, config, systemPropMap, dynamicPropConfig);
|
|
352
|
+
const attributes = { class: classes.join(" ") };
|
|
353
|
+
if (dynamicStyle && Object.keys(dynamicStyle).length > 0) attributes.style = serializeDynamicStyle(dynamicStyle);
|
|
354
|
+
return attributes;
|
|
355
|
+
};
|
|
356
|
+
const resolver = (props) => resolveClasses(className, props || {}, config, systemPropMap, dynamicPropConfig).classes.join(" ");
|
|
357
|
+
return Object.assign(resolver, { attrs: resolveAttributes });
|
|
358
|
+
}
|
|
359
|
+
//#endregion
|
|
360
|
+
export { resolveClasses as n, createClassResolver as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as resolveClasses } from "./createClassResolver-
|
|
1
|
+
import { n as resolveClasses } from "./createClassResolver-CcCgar2Z.js";
|
|
2
2
|
import { t as assertRootSlot } from "./assert-root-slot-C3Lp9MNJ.js";
|
|
3
3
|
import { Children, cloneElement, createElement, forwardRef, isValidElement } from "react";
|
|
4
4
|
//#region src/runtime/index.ts
|
|
@@ -24,13 +24,23 @@ function forwardProps(props, filterProps, domProps) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
+
* React 19 carries a ref as a plain prop and warns on `element.ref`; React 18
|
|
28
|
+
* keeps it on the element and guards `props.ref` with a warning getter.
|
|
29
|
+
* Reading the descriptor never invokes either getter.
|
|
30
|
+
*/
|
|
31
|
+
function childRefOf(child) {
|
|
32
|
+
const propRef = Object.getOwnPropertyDescriptor(child.props, "ref");
|
|
33
|
+
if (propRef && !propRef.get) return propRef.value;
|
|
34
|
+
return child.ref;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
27
37
|
* The child wins every conflict: parent props spread under the child's own, so
|
|
28
38
|
* a handler declared on the child replaces the parent's instead of chaining.
|
|
29
39
|
*/
|
|
30
40
|
function renderAsChild(className, filterProps, props, ref, classes, dynamicStyle) {
|
|
31
41
|
const child = Children.only(props.children);
|
|
32
42
|
if (!isValidElement(child)) throw new Error(`${className}: asChild requires a single React element as children`);
|
|
33
|
-
const childRef = child
|
|
43
|
+
const childRef = childRefOf(child);
|
|
34
44
|
const mergedClassName = [classes.join(" "), child.props.className].filter(Boolean).join(" ");
|
|
35
45
|
const mergedStyle = dynamicStyle || props.style || child.props.style ? {
|
|
36
46
|
...props.style,
|
|
@@ -84,8 +94,11 @@ function createComponent(element, className, config, systemPropMap, dynamicPropC
|
|
|
84
94
|
if (config.variants) {
|
|
85
95
|
for (const [prop, vc] of Object.entries(config.variants)) if (vc.default != null) variantDefaults[prop] = vc.default;
|
|
86
96
|
}
|
|
97
|
+
const customTransforms = {};
|
|
98
|
+
for (const [prop, dc] of Object.entries(config.customDynamicConfig ?? {})) if (dc.transform) customTransforms[prop] = dc.transform;
|
|
87
99
|
return Object.assign(Component, {
|
|
88
100
|
variantDefaults: Object.freeze(variantDefaults),
|
|
101
|
+
customTransforms: Object.freeze(customTransforms),
|
|
89
102
|
extend: () => {
|
|
90
103
|
throw new Error(`Cannot extend extracted component "${className}" at runtime. Extensions must be authored in source code using the builder API (e.g. import the original component and call .extend() there) so the extraction pipeline can resolve them at build time.`);
|
|
91
104
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { DeclarationProp, SystemProp } from './types/config';
|
|
2
|
+
/** One key's declarations: canonical member name → CSS value. */
|
|
3
|
+
export interface DeclarationRecord {
|
|
4
|
+
[member: string]: string | number;
|
|
5
|
+
}
|
|
6
|
+
/** Scale key → that key's complete record. */
|
|
7
|
+
export interface DeclarationScaleValues {
|
|
8
|
+
[key: string]: DeclarationRecord;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* What an author can hand a declaration scale before it is validated: plain
|
|
12
|
+
* JavaScript data whose shape the types may not have enforced.
|
|
13
|
+
*/
|
|
14
|
+
export type AuthoredDeclarationValue = string | number | boolean | null | undefined | AuthoredDeclarationRecord | readonly AuthoredDeclarationValue[];
|
|
15
|
+
export interface AuthoredDeclarationRecord {
|
|
16
|
+
readonly [key: string]: AuthoredDeclarationValue;
|
|
17
|
+
}
|
|
18
|
+
export declare function isDeclarationProp(entry: SystemProp | undefined): entry is DeclarationProp;
|
|
19
|
+
/**
|
|
20
|
+
* The camelCase spelling of a CSS property, so `font-size` and `fontSize`
|
|
21
|
+
* name one member; vendor prefixes follow React's spelling (`WebkitX`,
|
|
22
|
+
* `msX`). Custom properties are not members.
|
|
23
|
+
*/
|
|
24
|
+
export declare function canonicalMemberName(name: string): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* A declaration prop with its members canonicalized. Matching its members
|
|
27
|
+
* against the effective scale happens where the system and theme meet.
|
|
28
|
+
*/
|
|
29
|
+
export declare function validateDeclarationProp(propName: string, entry: DeclarationProp): DeclarationProp;
|
|
30
|
+
/**
|
|
31
|
+
* Each record must be flat, with string or finite-number values, and every
|
|
32
|
+
* record of one scale must set the same members. Returns the records with
|
|
33
|
+
* canonical member names.
|
|
34
|
+
*/
|
|
35
|
+
export declare function validateDeclarationRecords(label: string, scale: string, values: AuthoredDeclarationValue): DeclarationScaleValues;
|
|
36
|
+
/** Every record names the members of the first; the diagnostic names the gap. */
|
|
37
|
+
export declare function assertUniformMembers(label: string, scale: string, values: DeclarationScaleValues): void;
|
|
38
|
+
//# sourceMappingURL=declarations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../src/declarations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAElE,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CACnC;AAED,8CAA8C;AAC9C,MAAM,WAAW,sBAAsB;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAChC,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,yBAAyB,GACzB,SAAS,wBAAwB,EAAE,CAAC;AAExC,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,wBAAwB,CAAC;CAClD;AAqCD,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,UAAU,GAAG,SAAS,GAC5B,KAAK,IAAI,eAAe,CAE1B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkBpE;AAyBD;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,eAAe,GACrB,eAAe,CA2BjB;AA2CD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,wBAAwB,GAC/B,sBAAsB,CAexB;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,sBAAsB,GAC7B,IAAI,CAwBN"}
|
package/dist/groups/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as borderShorthand, i as gridItemRatio, n as size, o as createScale, r as gridItem } from "../size-
|
|
1
|
+
import { a as borderShorthand, i as gridItemRatio, n as size, o as createScale, r as gridItem } from "../size-ZhCTPtA-.js";
|
|
2
2
|
//#region src/groups/index.ts
|
|
3
3
|
const color = {
|
|
4
4
|
color: {
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export { areTransformsEqual, createTransform, type NamedTransform, type Transfor
|
|
|
18
18
|
export { gridItem, gridItemRatio } from './transforms/grid';
|
|
19
19
|
export { percentageOrAbsolute, size } from './transforms/size';
|
|
20
20
|
export type { AnimusComponent, AnimusWrappedComponent, AnyBrandedComponent, ComposedFamily, SharedConfig, VariantPropsOf, } from './types/component';
|
|
21
|
-
export type { AbstractParser, BuiltInConditionAlias, BuiltInSelectorAlias, CompoundEntry, CSSPropMap, CSSProps, CustomPropConfig, Parser, ParserProps, Prop, PropertyValues, Scale, ScaleValue, SelectorAliasProps, SystemProps, ThemedCSSPropMap, ThemedCSSProps, ThemedScale, ThemedScaleValue, VariantConfig, } from './types/config';
|
|
21
|
+
export type { AbstractParser, BuiltInConditionAlias, BuiltInSelectorAlias, CompoundEntry, CSSPropMap, CSSProps, CustomPropConfig, DeclarationKey, DeclarationProp, Parser, ParserProps, Prop, PropertyValues, Scale, ScaleValue, SelectorAliasProps, SystemProp, SystemProps, ThemedCSSPropMap, ThemedCSSProps, ThemedScale, ThemedScaleValue, VariantConfig, } from './types/config';
|
|
22
22
|
export type { AbstractProps, MediaQueryMap, ResponsiveProp, ThemeProps, } from './types/props';
|
|
23
23
|
export type { ArrayScale, MapScale } from './types/scales';
|
|
24
24
|
export type { CSSObject } from './types/shared';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAGzE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,wBAAwB,EAAE,KAAK,QAAQ,EAAE,MAAM,YAA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