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