@bamboocss/shared 1.11.1 → 1.11.2
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/astish.cjs +19 -0
- package/dist/astish.d.cts +4 -0
- package/dist/astish.d.mts +4 -0
- package/dist/astish.mjs +17 -20
- package/dist/index.cjs +1033 -0
- package/dist/index.d.cts +173 -0
- package/dist/index.d.mts +173 -0
- package/dist/index.mjs +462 -960
- package/dist/normalize-html.cjs +17 -0
- package/dist/normalize-html.d.cts +9 -0
- package/dist/normalize-html.d.mts +9 -0
- package/dist/normalize-html.mjs +11 -7
- package/dist/shared.cjs +21 -0
- package/dist/shared.d.cts +2 -0
- package/dist/shared.d.mts +2 -0
- package/dist/shared.mjs +2 -328
- package/dist/uniq-DRfJ796t.mjs +310 -0
- package/dist/uniq-DcY1asOl.d.mts +112 -0
- package/dist/uniq-i0QQ2OJM.d.cts +112 -0
- package/dist/uniq-xizdZz1Z.cjs +501 -0
- package/package.json +9 -9
- package/dist/astish.js +0 -46
- package/dist/index.js +0 -1557
- package/dist/normalize-html.js +0 -37
- package/dist/shared.js +0 -373
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
//#region src/assert.ts
|
|
2
|
+
const isString = (v) => typeof v === "string";
|
|
3
|
+
const isBoolean = (v) => typeof v === "boolean";
|
|
4
|
+
const isFunction = (v) => typeof v === "function";
|
|
5
|
+
function isObject(value) {
|
|
6
|
+
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
const isSymbol = (v) => typeof v === "symbol";
|
|
9
|
+
const isObjectOrArray = (obj) => typeof obj === "object" && obj !== null;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/memo.ts
|
|
12
|
+
const memo = (fn) => {
|
|
13
|
+
const cache = /* @__PURE__ */ new Map();
|
|
14
|
+
const get = (...args) => {
|
|
15
|
+
const key = JSON.stringify(args);
|
|
16
|
+
if (cache.has(key)) return cache.get(key);
|
|
17
|
+
const result = fn(...args);
|
|
18
|
+
cache.set(key, result);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
return get;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/compact.ts
|
|
25
|
+
function compact(value) {
|
|
26
|
+
return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value]) => value !== void 0));
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/condition.ts
|
|
30
|
+
const isBaseCondition = (v) => v === "base";
|
|
31
|
+
function filterBaseConditions(c) {
|
|
32
|
+
return c.slice().filter((v) => !isBaseCondition(v));
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/hash.ts
|
|
36
|
+
function toChar(code) {
|
|
37
|
+
return String.fromCharCode(code + (code > 25 ? 39 : 97));
|
|
38
|
+
}
|
|
39
|
+
function toName(code) {
|
|
40
|
+
let name = "";
|
|
41
|
+
let x;
|
|
42
|
+
for (x = Math.abs(code); x > 52; x = x / 52 | 0) name = toChar(x % 52) + name;
|
|
43
|
+
return toChar(x % 52) + name;
|
|
44
|
+
}
|
|
45
|
+
function toPhash(h, x) {
|
|
46
|
+
let i = x.length;
|
|
47
|
+
while (i) h = h * 33 ^ x.charCodeAt(--i);
|
|
48
|
+
return h;
|
|
49
|
+
}
|
|
50
|
+
function toHash(value) {
|
|
51
|
+
return toName(toPhash(5381, value) >>> 0);
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/important.ts
|
|
55
|
+
const importantRegex = /\s*!(important)?/i;
|
|
56
|
+
function isImportant(value) {
|
|
57
|
+
return typeof value === "string" ? importantRegex.test(value) : false;
|
|
58
|
+
}
|
|
59
|
+
function withoutImportant(value) {
|
|
60
|
+
return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;
|
|
61
|
+
}
|
|
62
|
+
function withoutSpace(str) {
|
|
63
|
+
return typeof str === "string" ? str.replaceAll(" ", "_") : str;
|
|
64
|
+
}
|
|
65
|
+
function markImportant(obj) {
|
|
66
|
+
if (typeof obj !== "object" || obj === null) return obj;
|
|
67
|
+
const result = Array.isArray(obj) ? [] : {};
|
|
68
|
+
const stack = [{
|
|
69
|
+
obj,
|
|
70
|
+
result
|
|
71
|
+
}];
|
|
72
|
+
while (stack.length > 0) {
|
|
73
|
+
const { obj, result } = stack.pop();
|
|
74
|
+
for (const [key, value] of Object.entries(obj)) if (typeof value === "string" || typeof value === "number") result[key] = `${value} !important`;
|
|
75
|
+
else if (typeof value === "object" && value !== null) {
|
|
76
|
+
const next = Array.isArray(value) ? [] : {};
|
|
77
|
+
result[key] = next;
|
|
78
|
+
stack.push({
|
|
79
|
+
obj: value,
|
|
80
|
+
result: next
|
|
81
|
+
});
|
|
82
|
+
} else result[key] = value;
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/merge-props.ts
|
|
88
|
+
const MERGE_OMIT = new Set([
|
|
89
|
+
"__proto__",
|
|
90
|
+
"constructor",
|
|
91
|
+
"prototype"
|
|
92
|
+
]);
|
|
93
|
+
function mergeProps(...sources) {
|
|
94
|
+
return sources.reduce((prev, obj) => {
|
|
95
|
+
if (!obj) return prev;
|
|
96
|
+
Object.keys(obj).forEach((key) => {
|
|
97
|
+
if (MERGE_OMIT.has(key)) return;
|
|
98
|
+
const prevValue = prev[key];
|
|
99
|
+
const value = obj[key];
|
|
100
|
+
if (isObject(prevValue) && isObject(value)) prev[key] = mergeProps(prevValue, value);
|
|
101
|
+
else prev[key] = value;
|
|
102
|
+
});
|
|
103
|
+
return prev;
|
|
104
|
+
}, {});
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/walk-object.ts
|
|
108
|
+
const isNotNullish = (element) => element != null;
|
|
109
|
+
function walkObject(target, predicate, options = {}) {
|
|
110
|
+
const { stop, getKey } = options;
|
|
111
|
+
function inner(value, path = []) {
|
|
112
|
+
if (isObjectOrArray(value)) {
|
|
113
|
+
const result = {};
|
|
114
|
+
for (const [prop, child] of Object.entries(value)) {
|
|
115
|
+
const key = getKey?.(prop, child) ?? prop;
|
|
116
|
+
const childPath = [...path, key];
|
|
117
|
+
if (stop?.(value, childPath)) return predicate(value, path);
|
|
118
|
+
const next = inner(child, childPath);
|
|
119
|
+
if (isNotNullish(next)) result[key] = next;
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
return predicate(value, path);
|
|
124
|
+
}
|
|
125
|
+
return inner(target);
|
|
126
|
+
}
|
|
127
|
+
function mapObject(obj, fn) {
|
|
128
|
+
if (Array.isArray(obj)) return obj.map((value) => fn(value));
|
|
129
|
+
if (!isObject(obj)) return fn(obj);
|
|
130
|
+
return walkObject(obj, (value) => fn(value));
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/normalize-style-object.ts
|
|
134
|
+
function toResponsiveObject(values, breakpoints) {
|
|
135
|
+
return values.reduce((acc, current, index) => {
|
|
136
|
+
const key = breakpoints[index];
|
|
137
|
+
if (current != null) acc[key] = current;
|
|
138
|
+
return acc;
|
|
139
|
+
}, {});
|
|
140
|
+
}
|
|
141
|
+
function normalizeStyleObject(styles, context, shorthand = true) {
|
|
142
|
+
const { utility, conditions } = context;
|
|
143
|
+
const { hasShorthand, resolveShorthand } = utility;
|
|
144
|
+
return walkObject(styles, (value) => {
|
|
145
|
+
return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;
|
|
146
|
+
}, {
|
|
147
|
+
stop: (value) => Array.isArray(value),
|
|
148
|
+
getKey: shorthand ? (prop) => hasShorthand ? resolveShorthand(prop) : prop : void 0
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/classname.ts
|
|
153
|
+
const fallbackCondition = {
|
|
154
|
+
shift: (v) => v,
|
|
155
|
+
finalize: (v) => v,
|
|
156
|
+
breakpoints: { keys: [] }
|
|
157
|
+
};
|
|
158
|
+
const sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\n\s]+/g, " ") : value;
|
|
159
|
+
const ENTRY_SEP = "]___[";
|
|
160
|
+
const COND_SEP = "<___>";
|
|
161
|
+
function createCss(context) {
|
|
162
|
+
const { utility, hash, grouped, conditions: conds = fallbackCondition } = context;
|
|
163
|
+
const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");
|
|
164
|
+
const hashFn = (conditions, className) => {
|
|
165
|
+
let result;
|
|
166
|
+
if (hash) {
|
|
167
|
+
const baseArray = [...conds.finalize(conditions), className];
|
|
168
|
+
result = formatClassName(utility.toHash(baseArray, toHash));
|
|
169
|
+
} else result = [...conds.finalize(conditions), formatClassName(className)].join(":");
|
|
170
|
+
return result;
|
|
171
|
+
};
|
|
172
|
+
if (grouped) return memo(({ base, ...styles } = {}) => {
|
|
173
|
+
const normalizedObject = normalizeStyleObject(Object.assign(styles, base), context);
|
|
174
|
+
const hashes = [];
|
|
175
|
+
walkObject(normalizedObject, (value, paths) => {
|
|
176
|
+
if (value == null) return;
|
|
177
|
+
const [prop, ...allConditions] = conds.shift(paths);
|
|
178
|
+
const conditions = filterBaseConditions(allConditions);
|
|
179
|
+
const parts = [`${prop}${ENTRY_SEP}value:${value}`];
|
|
180
|
+
if (conditions.length) parts.push(`cond:${conditions.join(COND_SEP)}`);
|
|
181
|
+
hashes.push(parts.join(ENTRY_SEP));
|
|
182
|
+
});
|
|
183
|
+
if (hashes.length === 0) return "";
|
|
184
|
+
hashes.sort();
|
|
185
|
+
const groupId = hashes.join("|");
|
|
186
|
+
return formatClassName(utility.toHash(["grouped", groupId], toHash));
|
|
187
|
+
});
|
|
188
|
+
return memo(({ base, ...styles } = {}) => {
|
|
189
|
+
const normalizedObject = normalizeStyleObject(Object.assign(styles, base), context);
|
|
190
|
+
const classNames = /* @__PURE__ */ new Set();
|
|
191
|
+
walkObject(normalizedObject, (value, paths) => {
|
|
192
|
+
if (value == null) return;
|
|
193
|
+
const important = isImportant(value);
|
|
194
|
+
const [prop, ...allConditions] = conds.shift(paths);
|
|
195
|
+
let className = hashFn(filterBaseConditions(allConditions), utility.transform(prop, withoutImportant(sanitize(value))).className);
|
|
196
|
+
if (important) className = `${className}!`;
|
|
197
|
+
classNames.add(className);
|
|
198
|
+
});
|
|
199
|
+
return Array.from(classNames).join(" ");
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function compactStyles(...styles) {
|
|
203
|
+
return styles.flat().filter((style) => isObject(style) && Object.keys(compact(style)).length > 0);
|
|
204
|
+
}
|
|
205
|
+
function createMergeCss(context) {
|
|
206
|
+
function resolve(styles) {
|
|
207
|
+
const allStyles = compactStyles(...styles);
|
|
208
|
+
if (allStyles.length === 1) return allStyles;
|
|
209
|
+
return allStyles.map((style) => normalizeStyleObject(style, context));
|
|
210
|
+
}
|
|
211
|
+
function mergeCss(...styles) {
|
|
212
|
+
return mergeProps(...resolve(styles));
|
|
213
|
+
}
|
|
214
|
+
function assignCss(...styles) {
|
|
215
|
+
return Object.assign({}, ...resolve(styles));
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
mergeCss: memo(mergeCss),
|
|
219
|
+
assignCss
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/hypenate-property.ts
|
|
224
|
+
const wordRegex = /([A-Z])/g;
|
|
225
|
+
const msRegex = /^ms-/;
|
|
226
|
+
const hypenateProperty = memo((property) => {
|
|
227
|
+
if (property.startsWith("--")) return property;
|
|
228
|
+
return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
|
|
229
|
+
});
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/is-css-function.ts
|
|
232
|
+
const fnRegExp = new RegExp(`^(${[
|
|
233
|
+
"min",
|
|
234
|
+
"max",
|
|
235
|
+
"clamp",
|
|
236
|
+
"calc"
|
|
237
|
+
].join("|")})\\(.*\\)`);
|
|
238
|
+
const isCssFunction = (v) => typeof v === "string" && fnRegExp.test(v);
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/is-css-unit.ts
|
|
241
|
+
const lengthUnitsPattern = `(?:${"cm,mm,Q,in,pc,pt,px,em,ex,ch,rem,lh,rlh,vw,vh,vmin,vmax,vb,vi,svw,svh,lvw,lvh,dvw,dvh,cqw,cqh,cqi,cqb,cqmin,cqmax,%".split(",").join("|")})`;
|
|
242
|
+
const lengthRegExp = new RegExp(`^[+-]?[0-9]*.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`);
|
|
243
|
+
const isCssUnit = (v) => typeof v === "string" && lengthRegExp.test(v);
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/is-css-var.ts
|
|
246
|
+
const isCssVar = (v) => typeof v === "string" && /^var\(--.+\)$/.test(v);
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/pattern-fns.ts
|
|
249
|
+
const patternFns = {
|
|
250
|
+
map: mapObject,
|
|
251
|
+
isCssFunction,
|
|
252
|
+
isCssVar,
|
|
253
|
+
isCssUnit
|
|
254
|
+
};
|
|
255
|
+
const getPatternStyles = (pattern, styles) => {
|
|
256
|
+
if (!pattern?.defaultValues) return styles;
|
|
257
|
+
const defaults = typeof pattern.defaultValues === "function" ? pattern.defaultValues(styles) : pattern.defaultValues;
|
|
258
|
+
return Object.assign({}, defaults, compact(styles));
|
|
259
|
+
};
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/slot.ts
|
|
262
|
+
const getSlotRecipes = (recipe = {}) => {
|
|
263
|
+
const init = (slot) => ({
|
|
264
|
+
className: [recipe.className, slot].filter(Boolean).join("__"),
|
|
265
|
+
base: recipe.base?.[slot] ?? {},
|
|
266
|
+
variants: {},
|
|
267
|
+
defaultVariants: recipe.defaultVariants ?? {},
|
|
268
|
+
compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []
|
|
269
|
+
});
|
|
270
|
+
const recipeParts = (recipe.slots ?? []).map((slot) => [slot, init(slot)]);
|
|
271
|
+
for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) recipeParts.forEach(([slot, slotRecipe]) => {
|
|
272
|
+
slotRecipe.variants[variantsKey] ??= {};
|
|
273
|
+
slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};
|
|
274
|
+
});
|
|
275
|
+
return Object.fromEntries(recipeParts);
|
|
276
|
+
};
|
|
277
|
+
const getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({
|
|
278
|
+
...compoundVariant,
|
|
279
|
+
css: compoundVariant.css[slotName]
|
|
280
|
+
}));
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/split-props.ts
|
|
283
|
+
function splitProps(props, ...keys) {
|
|
284
|
+
const descriptors = Object.getOwnPropertyDescriptors(props);
|
|
285
|
+
const dKeys = Object.keys(descriptors);
|
|
286
|
+
const split = (k) => {
|
|
287
|
+
const clone = {};
|
|
288
|
+
for (let i = 0; i < k.length; i++) {
|
|
289
|
+
const key = k[i];
|
|
290
|
+
if (descriptors[key]) {
|
|
291
|
+
Object.defineProperty(clone, key, descriptors[key]);
|
|
292
|
+
delete descriptors[key];
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return clone;
|
|
296
|
+
};
|
|
297
|
+
const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));
|
|
298
|
+
return keys.map(fn).concat(split(dKeys));
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/uniq.ts
|
|
302
|
+
const uniq = (...items) => {
|
|
303
|
+
const set = items.reduce((acc, currItems) => {
|
|
304
|
+
if (currItems) currItems.forEach((item) => acc.add(item));
|
|
305
|
+
return acc;
|
|
306
|
+
}, /* @__PURE__ */ new Set([]));
|
|
307
|
+
return Array.from(set);
|
|
308
|
+
};
|
|
309
|
+
//#endregion
|
|
310
|
+
export { isObjectOrArray as A, filterBaseConditions as C, isBoolean as D, memo as E, isSymbol as M, isFunction as O, toHash as S, compact as T, mergeProps as _, getPatternStyles as a, withoutImportant as b, isCssUnit as c, createCss as d, createMergeCss as f, walkObject as g, mapObject as h, getSlotRecipes as i, isString as j, isObject as k, isCssFunction as l, toResponsiveObject as m, splitProps as n, patternFns as o, normalizeStyleObject as p, getSlotCompoundVariant as r, isCssVar as s, uniq as t, hypenateProperty as u, isImportant as v, isBaseCondition as w, withoutSpace as x, markImportant as y };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
//#region src/assert.d.ts
|
|
2
|
+
declare const isString: (v: any) => v is string;
|
|
3
|
+
declare const isBoolean: (v: any) => v is boolean;
|
|
4
|
+
type AnyFunction = (...args: any[]) => any;
|
|
5
|
+
declare const isFunction: (v: any) => v is AnyFunction;
|
|
6
|
+
declare function isObject(value: any): value is Record<string, any>;
|
|
7
|
+
declare const isSymbol: (v: any) => v is symbol;
|
|
8
|
+
declare const isObjectOrArray: (obj: unknown) => obj is object;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/classname.d.ts
|
|
11
|
+
interface CreateCssContext {
|
|
12
|
+
hash?: boolean;
|
|
13
|
+
grouped?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Partial properties from the Utility class
|
|
16
|
+
*/
|
|
17
|
+
utility: {
|
|
18
|
+
prefix: string;
|
|
19
|
+
hasShorthand: boolean;
|
|
20
|
+
resolveShorthand: (prop: string) => string;
|
|
21
|
+
transform: (prop: string, value: any) => {
|
|
22
|
+
className: string;
|
|
23
|
+
};
|
|
24
|
+
toHash: (path: string[], toHash: (str: string) => string) => string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Partial properties from the Condition class
|
|
28
|
+
*/
|
|
29
|
+
conditions?: {
|
|
30
|
+
breakpoints: {
|
|
31
|
+
keys: string[];
|
|
32
|
+
};
|
|
33
|
+
shift: (paths: string[]) => string[];
|
|
34
|
+
finalize: (paths: string[]) => string[];
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
declare function createCss(context: CreateCssContext): ({
|
|
38
|
+
base,
|
|
39
|
+
...styles
|
|
40
|
+
}?: Record<string, any>) => string;
|
|
41
|
+
interface StyleObject {
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
declare function createMergeCss(context: CreateCssContext): {
|
|
45
|
+
mergeCss: (...styles: StyleObject[]) => StyleObject;
|
|
46
|
+
assignCss: (...styles: StyleObject[]) => any;
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/compact.d.ts
|
|
50
|
+
declare function compact<T extends Record<string, any>>(value: T): T;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/condition.d.ts
|
|
53
|
+
declare const isBaseCondition: (v: string) => v is "base";
|
|
54
|
+
declare function filterBaseConditions(c: string[]): string[];
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/walk-object.d.ts
|
|
57
|
+
type Predicate<R = any> = (value: any, path: string[]) => R;
|
|
58
|
+
type MappedObject<T, K> = { [Prop in keyof T]: T[Prop] extends Array<any> ? MappedObject<T[Prop][number], K>[] : T[Prop] extends Record<string, unknown> ? MappedObject<T[Prop], K> : K };
|
|
59
|
+
type WalkObjectStopFn = (value: any, path: string[]) => boolean;
|
|
60
|
+
interface WalkObjectOptions {
|
|
61
|
+
stop?: WalkObjectStopFn;
|
|
62
|
+
getKey?(prop: string, value: any): string;
|
|
63
|
+
}
|
|
64
|
+
declare function walkObject<T, K>(target: T, predicate: Predicate<K>, options?: WalkObjectOptions): MappedObject<T, ReturnType<Predicate<K>>>;
|
|
65
|
+
declare function mapObject(obj: any, fn: (value: any) => any): any;
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/hash.d.ts
|
|
68
|
+
declare function toHash(value: string): string;
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/hypenate-property.d.ts
|
|
71
|
+
declare const hypenateProperty: (property: string) => string;
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/important.d.ts
|
|
74
|
+
declare function isImportant<T extends string | number | boolean>(value: T): boolean;
|
|
75
|
+
declare function withoutImportant<T extends string | number | boolean>(value: T): string | T;
|
|
76
|
+
declare function withoutSpace<T extends string | number | boolean>(str: T): string | T;
|
|
77
|
+
type Dict$1 = Record<string, unknown>;
|
|
78
|
+
declare function markImportant(obj: Dict$1): {};
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/memo.d.ts
|
|
81
|
+
declare const memo: <T extends (...args: any[]) => any>(fn: T) => T;
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/merge-props.d.ts
|
|
84
|
+
declare function mergeProps<T extends Record<string, unknown>>(...sources: T[]): T;
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/pattern-fns.d.ts
|
|
87
|
+
declare const patternFns: {
|
|
88
|
+
map: typeof mapObject;
|
|
89
|
+
isCssFunction: (v: unknown) => boolean;
|
|
90
|
+
isCssVar: (v: unknown) => boolean;
|
|
91
|
+
isCssUnit: (v: unknown) => boolean;
|
|
92
|
+
};
|
|
93
|
+
declare const getPatternStyles: (pattern: any, styles: Record<string, any>) => any;
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/slot.d.ts
|
|
96
|
+
declare const getSlotRecipes: (recipe?: Record<string, any>) => Record<string, any>;
|
|
97
|
+
declare const getSlotCompoundVariant: <T extends {
|
|
98
|
+
css: any;
|
|
99
|
+
}>(compoundVariants: T[], slotName: string) => (T & {
|
|
100
|
+
css: any;
|
|
101
|
+
})[];
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/split-props.d.ts
|
|
104
|
+
type Dict = Record<string, unknown>;
|
|
105
|
+
type PredicateFn = (key: string) => boolean;
|
|
106
|
+
type Key = PredicateFn | string[];
|
|
107
|
+
declare function splitProps(props: Dict, ...keys: Key[]): Dict[];
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/uniq.d.ts
|
|
110
|
+
declare const uniq: <T>(...items: T[][]) => T[];
|
|
111
|
+
//#endregion
|
|
112
|
+
export { isString as A, CreateCssContext as C, isFunction as D, isBoolean as E, isObject as O, compact as S, createMergeCss as T, WalkObjectStopFn as _, getPatternStyles as a, filterBaseConditions as b, memo as c, withoutImportant as d, withoutSpace as f, WalkObjectOptions as g, MappedObject as h, getSlotRecipes as i, isSymbol as j, isObjectOrArray as k, isImportant as l, toHash as m, splitProps as n, patternFns as o, hypenateProperty as p, getSlotCompoundVariant as r, mergeProps as s, uniq as t, markImportant as u, mapObject as v, createCss as w, isBaseCondition as x, walkObject as y };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
//#region src/assert.d.ts
|
|
2
|
+
declare const isString: (v: any) => v is string;
|
|
3
|
+
declare const isBoolean: (v: any) => v is boolean;
|
|
4
|
+
type AnyFunction = (...args: any[]) => any;
|
|
5
|
+
declare const isFunction: (v: any) => v is AnyFunction;
|
|
6
|
+
declare function isObject(value: any): value is Record<string, any>;
|
|
7
|
+
declare const isSymbol: (v: any) => v is symbol;
|
|
8
|
+
declare const isObjectOrArray: (obj: unknown) => obj is object;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/classname.d.ts
|
|
11
|
+
interface CreateCssContext {
|
|
12
|
+
hash?: boolean;
|
|
13
|
+
grouped?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Partial properties from the Utility class
|
|
16
|
+
*/
|
|
17
|
+
utility: {
|
|
18
|
+
prefix: string;
|
|
19
|
+
hasShorthand: boolean;
|
|
20
|
+
resolveShorthand: (prop: string) => string;
|
|
21
|
+
transform: (prop: string, value: any) => {
|
|
22
|
+
className: string;
|
|
23
|
+
};
|
|
24
|
+
toHash: (path: string[], toHash: (str: string) => string) => string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Partial properties from the Condition class
|
|
28
|
+
*/
|
|
29
|
+
conditions?: {
|
|
30
|
+
breakpoints: {
|
|
31
|
+
keys: string[];
|
|
32
|
+
};
|
|
33
|
+
shift: (paths: string[]) => string[];
|
|
34
|
+
finalize: (paths: string[]) => string[];
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
declare function createCss(context: CreateCssContext): ({
|
|
38
|
+
base,
|
|
39
|
+
...styles
|
|
40
|
+
}?: Record<string, any>) => string;
|
|
41
|
+
interface StyleObject {
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
declare function createMergeCss(context: CreateCssContext): {
|
|
45
|
+
mergeCss: (...styles: StyleObject[]) => StyleObject;
|
|
46
|
+
assignCss: (...styles: StyleObject[]) => any;
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/compact.d.ts
|
|
50
|
+
declare function compact<T extends Record<string, any>>(value: T): T;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/condition.d.ts
|
|
53
|
+
declare const isBaseCondition: (v: string) => v is "base";
|
|
54
|
+
declare function filterBaseConditions(c: string[]): string[];
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/walk-object.d.ts
|
|
57
|
+
type Predicate<R = any> = (value: any, path: string[]) => R;
|
|
58
|
+
type MappedObject<T, K> = { [Prop in keyof T]: T[Prop] extends Array<any> ? MappedObject<T[Prop][number], K>[] : T[Prop] extends Record<string, unknown> ? MappedObject<T[Prop], K> : K };
|
|
59
|
+
type WalkObjectStopFn = (value: any, path: string[]) => boolean;
|
|
60
|
+
interface WalkObjectOptions {
|
|
61
|
+
stop?: WalkObjectStopFn;
|
|
62
|
+
getKey?(prop: string, value: any): string;
|
|
63
|
+
}
|
|
64
|
+
declare function walkObject<T, K>(target: T, predicate: Predicate<K>, options?: WalkObjectOptions): MappedObject<T, ReturnType<Predicate<K>>>;
|
|
65
|
+
declare function mapObject(obj: any, fn: (value: any) => any): any;
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/hash.d.ts
|
|
68
|
+
declare function toHash(value: string): string;
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/hypenate-property.d.ts
|
|
71
|
+
declare const hypenateProperty: (property: string) => string;
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/important.d.ts
|
|
74
|
+
declare function isImportant<T extends string | number | boolean>(value: T): boolean;
|
|
75
|
+
declare function withoutImportant<T extends string | number | boolean>(value: T): string | T;
|
|
76
|
+
declare function withoutSpace<T extends string | number | boolean>(str: T): string | T;
|
|
77
|
+
type Dict$1 = Record<string, unknown>;
|
|
78
|
+
declare function markImportant(obj: Dict$1): {};
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/memo.d.ts
|
|
81
|
+
declare const memo: <T extends (...args: any[]) => any>(fn: T) => T;
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/merge-props.d.ts
|
|
84
|
+
declare function mergeProps<T extends Record<string, unknown>>(...sources: T[]): T;
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/pattern-fns.d.ts
|
|
87
|
+
declare const patternFns: {
|
|
88
|
+
map: typeof mapObject;
|
|
89
|
+
isCssFunction: (v: unknown) => boolean;
|
|
90
|
+
isCssVar: (v: unknown) => boolean;
|
|
91
|
+
isCssUnit: (v: unknown) => boolean;
|
|
92
|
+
};
|
|
93
|
+
declare const getPatternStyles: (pattern: any, styles: Record<string, any>) => any;
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/slot.d.ts
|
|
96
|
+
declare const getSlotRecipes: (recipe?: Record<string, any>) => Record<string, any>;
|
|
97
|
+
declare const getSlotCompoundVariant: <T extends {
|
|
98
|
+
css: any;
|
|
99
|
+
}>(compoundVariants: T[], slotName: string) => (T & {
|
|
100
|
+
css: any;
|
|
101
|
+
})[];
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/split-props.d.ts
|
|
104
|
+
type Dict = Record<string, unknown>;
|
|
105
|
+
type PredicateFn = (key: string) => boolean;
|
|
106
|
+
type Key = PredicateFn | string[];
|
|
107
|
+
declare function splitProps(props: Dict, ...keys: Key[]): Dict[];
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/uniq.d.ts
|
|
110
|
+
declare const uniq: <T>(...items: T[][]) => T[];
|
|
111
|
+
//#endregion
|
|
112
|
+
export { isString as A, CreateCssContext as C, isFunction as D, isBoolean as E, isObject as O, compact as S, createMergeCss as T, WalkObjectStopFn as _, getPatternStyles as a, filterBaseConditions as b, memo as c, withoutImportant as d, withoutSpace as f, WalkObjectOptions as g, MappedObject as h, getSlotRecipes as i, isSymbol as j, isObjectOrArray as k, isImportant as l, toHash as m, splitProps as n, patternFns as o, hypenateProperty as p, getSlotCompoundVariant as r, mergeProps as s, uniq as t, markImportant as u, mapObject as v, createCss as w, isBaseCondition as x, walkObject as y };
|