@discourser/design-system 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +213 -0
- package/dist/index.cjs +1250 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +456 -0
- package/dist/index.d.ts +456 -0
- package/dist/index.js +1234 -0
- package/dist/index.js.map +1 -0
- package/package.json +123 -0
- package/styled-system/css/conditions.mjs +36 -0
- package/styled-system/css/css.d.ts +22 -0
- package/styled-system/css/css.mjs +45 -0
- package/styled-system/css/cva.d.ts +6 -0
- package/styled-system/css/cva.mjs +87 -0
- package/styled-system/css/cx.d.ts +5 -0
- package/styled-system/css/cx.mjs +15 -0
- package/styled-system/css/index.d.ts +5 -0
- package/styled-system/css/index.mjs +4 -0
- package/styled-system/css/sva.d.ts +4 -0
- package/styled-system/css/sva.mjs +41 -0
- package/styled-system/helpers.mjs +336 -0
- package/styled-system/jsx/aspect-ratio.d.ts +10 -0
- package/styled-system/jsx/aspect-ratio.mjs +14 -0
- package/styled-system/jsx/bleed.d.ts +10 -0
- package/styled-system/jsx/bleed.mjs +14 -0
- package/styled-system/jsx/box.d.ts +10 -0
- package/styled-system/jsx/box.mjs +14 -0
- package/styled-system/jsx/center.d.ts +10 -0
- package/styled-system/jsx/center.mjs +14 -0
- package/styled-system/jsx/circle.d.ts +10 -0
- package/styled-system/jsx/circle.mjs +14 -0
- package/styled-system/jsx/container.d.ts +10 -0
- package/styled-system/jsx/container.mjs +14 -0
- package/styled-system/jsx/cq.d.ts +10 -0
- package/styled-system/jsx/cq.mjs +14 -0
- package/styled-system/jsx/divider.d.ts +10 -0
- package/styled-system/jsx/divider.mjs +14 -0
- package/styled-system/jsx/factory-helper.mjs +22 -0
- package/styled-system/jsx/factory.d.ts +3 -0
- package/styled-system/jsx/factory.mjs +80 -0
- package/styled-system/jsx/flex.d.ts +10 -0
- package/styled-system/jsx/flex.mjs +14 -0
- package/styled-system/jsx/float.d.ts +10 -0
- package/styled-system/jsx/float.mjs +14 -0
- package/styled-system/jsx/grid-item.d.ts +10 -0
- package/styled-system/jsx/grid-item.mjs +14 -0
- package/styled-system/jsx/grid.d.ts +10 -0
- package/styled-system/jsx/grid.mjs +14 -0
- package/styled-system/jsx/hstack.d.ts +10 -0
- package/styled-system/jsx/hstack.mjs +14 -0
- package/styled-system/jsx/index.d.ts +24 -0
- package/styled-system/jsx/index.mjs +22 -0
- package/styled-system/jsx/is-valid-prop.d.ts +11 -0
- package/styled-system/jsx/is-valid-prop.mjs +17 -0
- package/styled-system/jsx/link-overlay.d.ts +10 -0
- package/styled-system/jsx/link-overlay.mjs +14 -0
- package/styled-system/jsx/spacer.d.ts +10 -0
- package/styled-system/jsx/spacer.mjs +14 -0
- package/styled-system/jsx/square.d.ts +10 -0
- package/styled-system/jsx/square.mjs +14 -0
- package/styled-system/jsx/stack.d.ts +10 -0
- package/styled-system/jsx/stack.mjs +14 -0
- package/styled-system/jsx/visually-hidden.d.ts +10 -0
- package/styled-system/jsx/visually-hidden.mjs +14 -0
- package/styled-system/jsx/vstack.d.ts +10 -0
- package/styled-system/jsx/vstack.mjs +14 -0
- package/styled-system/jsx/wrap.d.ts +10 -0
- package/styled-system/jsx/wrap.mjs +14 -0
- package/styled-system/patterns/aspect-ratio.d.ts +21 -0
- package/styled-system/patterns/aspect-ratio.mjs +38 -0
- package/styled-system/patterns/bleed.d.ts +22 -0
- package/styled-system/patterns/bleed.mjs +24 -0
- package/styled-system/patterns/box.d.ts +21 -0
- package/styled-system/patterns/box.mjs +15 -0
- package/styled-system/patterns/center.d.ts +21 -0
- package/styled-system/patterns/center.mjs +21 -0
- package/styled-system/patterns/circle.d.ts +21 -0
- package/styled-system/patterns/circle.mjs +25 -0
- package/styled-system/patterns/container.d.ts +21 -0
- package/styled-system/patterns/container.mjs +21 -0
- package/styled-system/patterns/cq.d.ts +22 -0
- package/styled-system/patterns/cq.mjs +21 -0
- package/styled-system/patterns/divider.d.ts +23 -0
- package/styled-system/patterns/divider.mjs +25 -0
- package/styled-system/patterns/flex.d.ts +27 -0
- package/styled-system/patterns/flex.mjs +26 -0
- package/styled-system/patterns/float.d.ts +24 -0
- package/styled-system/patterns/float.mjs +52 -0
- package/styled-system/patterns/grid-item.d.ts +26 -0
- package/styled-system/patterns/grid-item.mjs +25 -0
- package/styled-system/patterns/grid.d.ts +25 -0
- package/styled-system/patterns/grid.mjs +27 -0
- package/styled-system/patterns/hstack.d.ts +22 -0
- package/styled-system/patterns/hstack.mjs +24 -0
- package/styled-system/patterns/index.d.ts +21 -0
- package/styled-system/patterns/index.mjs +20 -0
- package/styled-system/patterns/link-overlay.d.ts +21 -0
- package/styled-system/patterns/link-overlay.mjs +24 -0
- package/styled-system/patterns/spacer.d.ts +21 -0
- package/styled-system/patterns/spacer.mjs +21 -0
- package/styled-system/patterns/square.d.ts +21 -0
- package/styled-system/patterns/square.mjs +24 -0
- package/styled-system/patterns/stack.d.ts +24 -0
- package/styled-system/patterns/stack.mjs +24 -0
- package/styled-system/patterns/visually-hidden.d.ts +21 -0
- package/styled-system/patterns/visually-hidden.mjs +18 -0
- package/styled-system/patterns/vstack.d.ts +22 -0
- package/styled-system/patterns/vstack.mjs +24 -0
- package/styled-system/patterns/wrap.d.ts +25 -0
- package/styled-system/patterns/wrap.mjs +25 -0
- package/styled-system/recipes/button.d.ts +39 -0
- package/styled-system/recipes/button.mjs +40 -0
- package/styled-system/recipes/card.d.ts +39 -0
- package/styled-system/recipes/card.mjs +36 -0
- package/styled-system/recipes/create-recipe.mjs +82 -0
- package/styled-system/recipes/dialog.d.ts +35 -0
- package/styled-system/recipes/dialog.mjs +63 -0
- package/styled-system/recipes/icon-button.d.ts +39 -0
- package/styled-system/recipes/icon-button.mjs +39 -0
- package/styled-system/recipes/index.d.ts +7 -0
- package/styled-system/recipes/index.mjs +6 -0
- package/styled-system/recipes/input.d.ts +40 -0
- package/styled-system/recipes/input.mjs +40 -0
- package/styled-system/recipes/switch-control.d.ts +35 -0
- package/styled-system/recipes/switch-control.mjs +53 -0
- package/styled-system/recipes/switch.d.ts +35 -0
- package/styled-system/recipes/switch.mjs +53 -0
- package/styled-system/tokens/index.d.ts +9 -0
- package/styled-system/tokens/index.mjs +924 -0
- package/styled-system/tokens/tokens.d.ts +48 -0
- package/styled-system/types/composition.d.ts +164 -0
- package/styled-system/types/conditions.d.ts +306 -0
- package/styled-system/types/csstype.d.ts +21298 -0
- package/styled-system/types/global.d.ts +20 -0
- package/styled-system/types/index.d.ts +8 -0
- package/styled-system/types/jsx.d.ts +52 -0
- package/styled-system/types/parts.d.ts +8 -0
- package/styled-system/types/pattern.d.ts +78 -0
- package/styled-system/types/prop-type.d.ts +224 -0
- package/styled-system/types/recipe.d.ts +181 -0
- package/styled-system/types/selectors.d.ts +59 -0
- package/styled-system/types/static-css.d.ts +56 -0
- package/styled-system/types/style-props.d.ts +7468 -0
- package/styled-system/types/system-types.d.ts +109 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
// src/assert.ts
|
|
2
|
+
function isObject(value) {
|
|
3
|
+
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
var isObjectOrArray = (obj) => typeof obj === "object" && obj !== null;
|
|
6
|
+
|
|
7
|
+
// src/compact.ts
|
|
8
|
+
function compact(value) {
|
|
9
|
+
return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// src/condition.ts
|
|
13
|
+
var isBaseCondition = (v) => v === "base";
|
|
14
|
+
function filterBaseConditions(c) {
|
|
15
|
+
return c.slice().filter((v) => !isBaseCondition(v));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/hash.ts
|
|
19
|
+
function toChar(code) {
|
|
20
|
+
return String.fromCharCode(code + (code > 25 ? 39 : 97));
|
|
21
|
+
}
|
|
22
|
+
function toName(code) {
|
|
23
|
+
let name = "";
|
|
24
|
+
let x;
|
|
25
|
+
for (x = Math.abs(code); x > 52; x = x / 52 | 0)
|
|
26
|
+
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)
|
|
32
|
+
h = h * 33 ^ x.charCodeAt(--i);
|
|
33
|
+
return h;
|
|
34
|
+
}
|
|
35
|
+
function toHash(value) {
|
|
36
|
+
return toName(toPhash(5381, value) >>> 0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/important.ts
|
|
40
|
+
var importantRegex = /\s*!(important)?/i;
|
|
41
|
+
function isImportant(value) {
|
|
42
|
+
return typeof value === "string" ? importantRegex.test(value) : false;
|
|
43
|
+
}
|
|
44
|
+
function withoutImportant(value) {
|
|
45
|
+
return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;
|
|
46
|
+
}
|
|
47
|
+
function withoutSpace(str) {
|
|
48
|
+
return typeof str === "string" ? str.replaceAll(" ", "_") : str;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/memo.ts
|
|
52
|
+
var memo = (fn) => {
|
|
53
|
+
const cache = /* @__PURE__ */ new Map();
|
|
54
|
+
const get = (...args) => {
|
|
55
|
+
const key = JSON.stringify(args);
|
|
56
|
+
if (cache.has(key)) {
|
|
57
|
+
return cache.get(key);
|
|
58
|
+
}
|
|
59
|
+
const result = fn(...args);
|
|
60
|
+
cache.set(key, result);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
return get;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// src/merge-props.ts
|
|
67
|
+
function mergeProps(...sources) {
|
|
68
|
+
return sources.reduce((prev, obj) => {
|
|
69
|
+
if (!obj)
|
|
70
|
+
return prev;
|
|
71
|
+
Object.keys(obj).forEach((key) => {
|
|
72
|
+
const prevValue = prev[key];
|
|
73
|
+
const value = obj[key];
|
|
74
|
+
if (isObject(prevValue) && isObject(value)) {
|
|
75
|
+
prev[key] = mergeProps(prevValue, value);
|
|
76
|
+
} else {
|
|
77
|
+
prev[key] = value;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return prev;
|
|
81
|
+
}, {});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/walk-object.ts
|
|
85
|
+
var isNotNullish = (element) => element != null;
|
|
86
|
+
function walkObject(target, predicate, options = {}) {
|
|
87
|
+
const { stop, getKey } = options;
|
|
88
|
+
function inner(value, path = []) {
|
|
89
|
+
if (isObjectOrArray(value)) {
|
|
90
|
+
const result = {};
|
|
91
|
+
for (const [prop, child] of Object.entries(value)) {
|
|
92
|
+
const key = getKey?.(prop, child) ?? prop;
|
|
93
|
+
const childPath = [...path, key];
|
|
94
|
+
if (stop?.(value, childPath)) {
|
|
95
|
+
return predicate(value, path);
|
|
96
|
+
}
|
|
97
|
+
const next = inner(child, childPath);
|
|
98
|
+
if (isNotNullish(next)) {
|
|
99
|
+
result[key] = next;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
return predicate(value, path);
|
|
105
|
+
}
|
|
106
|
+
return inner(target);
|
|
107
|
+
}
|
|
108
|
+
function mapObject(obj, fn) {
|
|
109
|
+
if (Array.isArray(obj))
|
|
110
|
+
return obj.map((value) => fn(value));
|
|
111
|
+
if (!isObject(obj))
|
|
112
|
+
return fn(obj);
|
|
113
|
+
return walkObject(obj, (value) => fn(value));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/normalize-style-object.ts
|
|
117
|
+
function toResponsiveObject(values, breakpoints) {
|
|
118
|
+
return values.reduce(
|
|
119
|
+
(acc, current, index) => {
|
|
120
|
+
const key = breakpoints[index];
|
|
121
|
+
if (current != null) {
|
|
122
|
+
acc[key] = current;
|
|
123
|
+
}
|
|
124
|
+
return acc;
|
|
125
|
+
},
|
|
126
|
+
{}
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
function normalizeStyleObject(styles, context, shorthand = true) {
|
|
130
|
+
const { utility, conditions } = context;
|
|
131
|
+
const { hasShorthand, resolveShorthand } = utility;
|
|
132
|
+
return walkObject(
|
|
133
|
+
styles,
|
|
134
|
+
(value) => {
|
|
135
|
+
return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
stop: (value) => Array.isArray(value),
|
|
139
|
+
getKey: shorthand ? (prop) => hasShorthand ? resolveShorthand(prop) : prop : void 0
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/classname.ts
|
|
145
|
+
var fallbackCondition = {
|
|
146
|
+
shift: (v) => v,
|
|
147
|
+
finalize: (v) => v,
|
|
148
|
+
breakpoints: { keys: [] }
|
|
149
|
+
};
|
|
150
|
+
var sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\n\s]+/g, " ") : value;
|
|
151
|
+
function createCss(context) {
|
|
152
|
+
const { utility, hash, conditions: conds = fallbackCondition } = context;
|
|
153
|
+
const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");
|
|
154
|
+
const hashFn = (conditions, className) => {
|
|
155
|
+
let result;
|
|
156
|
+
if (hash) {
|
|
157
|
+
const baseArray = [...conds.finalize(conditions), className];
|
|
158
|
+
result = formatClassName(utility.toHash(baseArray, toHash));
|
|
159
|
+
} else {
|
|
160
|
+
const baseArray = [...conds.finalize(conditions), formatClassName(className)];
|
|
161
|
+
result = baseArray.join(":");
|
|
162
|
+
}
|
|
163
|
+
return result;
|
|
164
|
+
};
|
|
165
|
+
return memo(({ base, ...styles } = {}) => {
|
|
166
|
+
const styleObject = Object.assign(styles, base);
|
|
167
|
+
const normalizedObject = normalizeStyleObject(styleObject, context);
|
|
168
|
+
const classNames = /* @__PURE__ */ new Set();
|
|
169
|
+
walkObject(normalizedObject, (value, paths) => {
|
|
170
|
+
if (value == null)
|
|
171
|
+
return;
|
|
172
|
+
const important = isImportant(value);
|
|
173
|
+
const [prop, ...allConditions] = conds.shift(paths);
|
|
174
|
+
const conditions = filterBaseConditions(allConditions);
|
|
175
|
+
const transformed = utility.transform(prop, withoutImportant(sanitize(value)));
|
|
176
|
+
let className = hashFn(conditions, transformed.className);
|
|
177
|
+
if (important)
|
|
178
|
+
className = `${className}!`;
|
|
179
|
+
classNames.add(className);
|
|
180
|
+
});
|
|
181
|
+
return Array.from(classNames).join(" ");
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function compactStyles(...styles) {
|
|
185
|
+
return styles.flat().filter((style) => isObject(style) && Object.keys(compact(style)).length > 0);
|
|
186
|
+
}
|
|
187
|
+
function createMergeCss(context) {
|
|
188
|
+
function resolve(styles) {
|
|
189
|
+
const allStyles = compactStyles(...styles);
|
|
190
|
+
if (allStyles.length === 1)
|
|
191
|
+
return allStyles;
|
|
192
|
+
return allStyles.map((style) => normalizeStyleObject(style, context));
|
|
193
|
+
}
|
|
194
|
+
function mergeCss(...styles) {
|
|
195
|
+
return mergeProps(...resolve(styles));
|
|
196
|
+
}
|
|
197
|
+
function assignCss(...styles) {
|
|
198
|
+
return Object.assign({}, ...resolve(styles));
|
|
199
|
+
}
|
|
200
|
+
return { mergeCss: memo(mergeCss), assignCss };
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// src/hypenate-property.ts
|
|
204
|
+
var wordRegex = /([A-Z])/g;
|
|
205
|
+
var msRegex = /^ms-/;
|
|
206
|
+
var hypenateProperty = memo((property) => {
|
|
207
|
+
if (property.startsWith("--"))
|
|
208
|
+
return property;
|
|
209
|
+
return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// src/is-css-function.ts
|
|
213
|
+
var fns = ["min", "max", "clamp", "calc"];
|
|
214
|
+
var fnRegExp = new RegExp(`^(${fns.join("|")})\\(.*\\)`);
|
|
215
|
+
var isCssFunction = (v) => typeof v === "string" && fnRegExp.test(v);
|
|
216
|
+
|
|
217
|
+
// src/is-css-unit.ts
|
|
218
|
+
var lengthUnits = "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,%";
|
|
219
|
+
var lengthUnitsPattern = `(?:${lengthUnits.split(",").join("|")})`;
|
|
220
|
+
var lengthRegExp = new RegExp(`^[+-]?[0-9]*.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`);
|
|
221
|
+
var isCssUnit = (v) => typeof v === "string" && lengthRegExp.test(v);
|
|
222
|
+
|
|
223
|
+
// src/is-css-var.ts
|
|
224
|
+
var isCssVar = (v) => typeof v === "string" && /^var\(--.+\)$/.test(v);
|
|
225
|
+
|
|
226
|
+
// src/pattern-fns.ts
|
|
227
|
+
var patternFns = {
|
|
228
|
+
map: mapObject,
|
|
229
|
+
isCssFunction,
|
|
230
|
+
isCssVar,
|
|
231
|
+
isCssUnit
|
|
232
|
+
};
|
|
233
|
+
var getPatternStyles = (pattern, styles) => {
|
|
234
|
+
if (!pattern?.defaultValues)
|
|
235
|
+
return styles;
|
|
236
|
+
const defaults = typeof pattern.defaultValues === "function" ? pattern.defaultValues(styles) : pattern.defaultValues;
|
|
237
|
+
return Object.assign({}, defaults, compact(styles));
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// src/slot.ts
|
|
241
|
+
var getSlotRecipes = (recipe = {}) => {
|
|
242
|
+
const init = (slot) => ({
|
|
243
|
+
className: [recipe.className, slot].filter(Boolean).join("__"),
|
|
244
|
+
base: recipe.base?.[slot] ?? {},
|
|
245
|
+
variants: {},
|
|
246
|
+
defaultVariants: recipe.defaultVariants ?? {},
|
|
247
|
+
compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []
|
|
248
|
+
});
|
|
249
|
+
const slots = recipe.slots ?? [];
|
|
250
|
+
const recipeParts = slots.map((slot) => [slot, init(slot)]);
|
|
251
|
+
for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) {
|
|
252
|
+
for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) {
|
|
253
|
+
recipeParts.forEach(([slot, slotRecipe]) => {
|
|
254
|
+
slotRecipe.variants[variantsKey] ??= {};
|
|
255
|
+
slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return Object.fromEntries(recipeParts);
|
|
260
|
+
};
|
|
261
|
+
var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
|
|
262
|
+
|
|
263
|
+
// src/split-props.ts
|
|
264
|
+
function splitProps(props, ...keys) {
|
|
265
|
+
const descriptors = Object.getOwnPropertyDescriptors(props);
|
|
266
|
+
const dKeys = Object.keys(descriptors);
|
|
267
|
+
const split = (k) => {
|
|
268
|
+
const clone = {};
|
|
269
|
+
for (let i = 0; i < k.length; i++) {
|
|
270
|
+
const key = k[i];
|
|
271
|
+
if (descriptors[key]) {
|
|
272
|
+
Object.defineProperty(clone, key, descriptors[key]);
|
|
273
|
+
delete descriptors[key];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return clone;
|
|
277
|
+
};
|
|
278
|
+
const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));
|
|
279
|
+
return keys.map(fn).concat(split(dKeys));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// src/uniq.ts
|
|
283
|
+
var uniq = (...items) => {
|
|
284
|
+
const set = items.reduce((acc, currItems) => {
|
|
285
|
+
if (currItems) {
|
|
286
|
+
currItems.forEach((item) => acc.add(item));
|
|
287
|
+
}
|
|
288
|
+
return acc;
|
|
289
|
+
}, /* @__PURE__ */ new Set([]));
|
|
290
|
+
return Array.from(set);
|
|
291
|
+
};
|
|
292
|
+
export {
|
|
293
|
+
compact,
|
|
294
|
+
createCss,
|
|
295
|
+
createMergeCss,
|
|
296
|
+
filterBaseConditions,
|
|
297
|
+
getPatternStyles,
|
|
298
|
+
getSlotCompoundVariant,
|
|
299
|
+
getSlotRecipes,
|
|
300
|
+
hypenateProperty,
|
|
301
|
+
isBaseCondition,
|
|
302
|
+
isObject,
|
|
303
|
+
mapObject,
|
|
304
|
+
memo,
|
|
305
|
+
mergeProps,
|
|
306
|
+
patternFns,
|
|
307
|
+
splitProps,
|
|
308
|
+
toHash,
|
|
309
|
+
uniq,
|
|
310
|
+
walkObject,
|
|
311
|
+
withoutSpace
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
// src/normalize-html.ts
|
|
317
|
+
var htmlProps = ["htmlSize", "htmlTranslate", "htmlWidth", "htmlHeight"];
|
|
318
|
+
function convert(key) {
|
|
319
|
+
return htmlProps.includes(key) ? key.replace("html", "").toLowerCase() : key;
|
|
320
|
+
}
|
|
321
|
+
function normalizeHTMLProps(props) {
|
|
322
|
+
return Object.fromEntries(Object.entries(props).map(([key, value]) => [convert(key), value]));
|
|
323
|
+
}
|
|
324
|
+
normalizeHTMLProps.keys = htmlProps;
|
|
325
|
+
export {
|
|
326
|
+
normalizeHTMLProps
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
export function __spreadValues(a, b) {
|
|
331
|
+
return { ...a, ...b }
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export function __objRest(source, exclude) {
|
|
335
|
+
return Object.fromEntries(Object.entries(source).filter(([key]) => !exclude.includes(key)))
|
|
336
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { FunctionComponent } from 'react'
|
|
3
|
+
import type { AspectRatioProperties } from '../patterns/aspect-ratio';
|
|
4
|
+
import type { HTMLStyledProps } from '../types/jsx';
|
|
5
|
+
import type { DistributiveOmit } from '../types/system-types';
|
|
6
|
+
|
|
7
|
+
export interface AspectRatioProps extends AspectRatioProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof AspectRatioProperties | 'aspectRatio'> {}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export declare const AspectRatio: FunctionComponent<AspectRatioProps>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { splitProps } from '../helpers.mjs';
|
|
4
|
+
import { getAspectRatioStyle } from '../patterns/aspect-ratio.mjs';
|
|
5
|
+
import { styled } from './factory.mjs';
|
|
6
|
+
|
|
7
|
+
export const AspectRatio = /* @__PURE__ */ forwardRef(function AspectRatio(props, ref) {
|
|
8
|
+
const [patternProps, restProps] = splitProps(props, ["ratio"])
|
|
9
|
+
|
|
10
|
+
const styleProps = getAspectRatioStyle(patternProps)
|
|
11
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
12
|
+
|
|
13
|
+
return createElement(styled.div, mergedProps)
|
|
14
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { FunctionComponent } from 'react'
|
|
3
|
+
import type { BleedProperties } from '../patterns/bleed';
|
|
4
|
+
import type { HTMLStyledProps } from '../types/jsx';
|
|
5
|
+
import type { DistributiveOmit } from '../types/system-types';
|
|
6
|
+
|
|
7
|
+
export interface BleedProps extends BleedProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof BleedProperties > {}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export declare const Bleed: FunctionComponent<BleedProps>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { splitProps } from '../helpers.mjs';
|
|
4
|
+
import { getBleedStyle } from '../patterns/bleed.mjs';
|
|
5
|
+
import { styled } from './factory.mjs';
|
|
6
|
+
|
|
7
|
+
export const Bleed = /* @__PURE__ */ forwardRef(function Bleed(props, ref) {
|
|
8
|
+
const [patternProps, restProps] = splitProps(props, ["inline","block"])
|
|
9
|
+
|
|
10
|
+
const styleProps = getBleedStyle(patternProps)
|
|
11
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
12
|
+
|
|
13
|
+
return createElement(styled.div, mergedProps)
|
|
14
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { FunctionComponent } from 'react'
|
|
3
|
+
import type { BoxProperties } from '../patterns/box';
|
|
4
|
+
import type { HTMLStyledProps } from '../types/jsx';
|
|
5
|
+
import type { DistributiveOmit } from '../types/system-types';
|
|
6
|
+
|
|
7
|
+
export interface BoxProps extends BoxProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof BoxProperties > {}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export declare const Box: FunctionComponent<BoxProps>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { splitProps } from '../helpers.mjs';
|
|
4
|
+
import { getBoxStyle } from '../patterns/box.mjs';
|
|
5
|
+
import { styled } from './factory.mjs';
|
|
6
|
+
|
|
7
|
+
export const Box = /* @__PURE__ */ forwardRef(function Box(props, ref) {
|
|
8
|
+
const [patternProps, restProps] = splitProps(props, [])
|
|
9
|
+
|
|
10
|
+
const styleProps = getBoxStyle(patternProps)
|
|
11
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
12
|
+
|
|
13
|
+
return createElement(styled.div, mergedProps)
|
|
14
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { FunctionComponent } from 'react'
|
|
3
|
+
import type { CenterProperties } from '../patterns/center';
|
|
4
|
+
import type { HTMLStyledProps } from '../types/jsx';
|
|
5
|
+
import type { DistributiveOmit } from '../types/system-types';
|
|
6
|
+
|
|
7
|
+
export interface CenterProps extends CenterProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof CenterProperties > {}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export declare const Center: FunctionComponent<CenterProps>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { splitProps } from '../helpers.mjs';
|
|
4
|
+
import { getCenterStyle } from '../patterns/center.mjs';
|
|
5
|
+
import { styled } from './factory.mjs';
|
|
6
|
+
|
|
7
|
+
export const Center = /* @__PURE__ */ forwardRef(function Center(props, ref) {
|
|
8
|
+
const [patternProps, restProps] = splitProps(props, ["inline"])
|
|
9
|
+
|
|
10
|
+
const styleProps = getCenterStyle(patternProps)
|
|
11
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
12
|
+
|
|
13
|
+
return createElement(styled.div, mergedProps)
|
|
14
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { FunctionComponent } from 'react'
|
|
3
|
+
import type { CircleProperties } from '../patterns/circle';
|
|
4
|
+
import type { HTMLStyledProps } from '../types/jsx';
|
|
5
|
+
import type { DistributiveOmit } from '../types/system-types';
|
|
6
|
+
|
|
7
|
+
export interface CircleProps extends CircleProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof CircleProperties > {}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export declare const Circle: FunctionComponent<CircleProps>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { splitProps } from '../helpers.mjs';
|
|
4
|
+
import { getCircleStyle } from '../patterns/circle.mjs';
|
|
5
|
+
import { styled } from './factory.mjs';
|
|
6
|
+
|
|
7
|
+
export const Circle = /* @__PURE__ */ forwardRef(function Circle(props, ref) {
|
|
8
|
+
const [patternProps, restProps] = splitProps(props, ["size"])
|
|
9
|
+
|
|
10
|
+
const styleProps = getCircleStyle(patternProps)
|
|
11
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
12
|
+
|
|
13
|
+
return createElement(styled.div, mergedProps)
|
|
14
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { FunctionComponent } from 'react'
|
|
3
|
+
import type { ContainerProperties } from '../patterns/container';
|
|
4
|
+
import type { HTMLStyledProps } from '../types/jsx';
|
|
5
|
+
import type { DistributiveOmit } from '../types/system-types';
|
|
6
|
+
|
|
7
|
+
export interface ContainerProps extends ContainerProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof ContainerProperties > {}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export declare const Container: FunctionComponent<ContainerProps>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { splitProps } from '../helpers.mjs';
|
|
4
|
+
import { getContainerStyle } from '../patterns/container.mjs';
|
|
5
|
+
import { styled } from './factory.mjs';
|
|
6
|
+
|
|
7
|
+
export const Container = /* @__PURE__ */ forwardRef(function Container(props, ref) {
|
|
8
|
+
const [patternProps, restProps] = splitProps(props, [])
|
|
9
|
+
|
|
10
|
+
const styleProps = getContainerStyle(patternProps)
|
|
11
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
12
|
+
|
|
13
|
+
return createElement(styled.div, mergedProps)
|
|
14
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { FunctionComponent } from 'react'
|
|
3
|
+
import type { CqProperties } from '../patterns/cq';
|
|
4
|
+
import type { HTMLStyledProps } from '../types/jsx';
|
|
5
|
+
import type { DistributiveOmit } from '../types/system-types';
|
|
6
|
+
|
|
7
|
+
export interface CqProps extends CqProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof CqProperties > {}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export declare const Cq: FunctionComponent<CqProps>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { splitProps } from '../helpers.mjs';
|
|
4
|
+
import { getCqStyle } from '../patterns/cq.mjs';
|
|
5
|
+
import { styled } from './factory.mjs';
|
|
6
|
+
|
|
7
|
+
export const Cq = /* @__PURE__ */ forwardRef(function Cq(props, ref) {
|
|
8
|
+
const [patternProps, restProps] = splitProps(props, ["name","type"])
|
|
9
|
+
|
|
10
|
+
const styleProps = getCqStyle(patternProps)
|
|
11
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
12
|
+
|
|
13
|
+
return createElement(styled.div, mergedProps)
|
|
14
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { FunctionComponent } from 'react'
|
|
3
|
+
import type { DividerProperties } from '../patterns/divider';
|
|
4
|
+
import type { HTMLStyledProps } from '../types/jsx';
|
|
5
|
+
import type { DistributiveOmit } from '../types/system-types';
|
|
6
|
+
|
|
7
|
+
export interface DividerProps extends DividerProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof DividerProperties > {}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export declare const Divider: FunctionComponent<DividerProps>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { splitProps } from '../helpers.mjs';
|
|
4
|
+
import { getDividerStyle } from '../patterns/divider.mjs';
|
|
5
|
+
import { styled } from './factory.mjs';
|
|
6
|
+
|
|
7
|
+
export const Divider = /* @__PURE__ */ forwardRef(function Divider(props, ref) {
|
|
8
|
+
const [patternProps, restProps] = splitProps(props, ["orientation","thickness","color"])
|
|
9
|
+
|
|
10
|
+
const styleProps = getDividerStyle(patternProps)
|
|
11
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
12
|
+
|
|
13
|
+
return createElement(styled.div, mergedProps)
|
|
14
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isCssProperty } from './is-valid-prop.mjs';
|
|
2
|
+
|
|
3
|
+
export const defaultShouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && !isCssProperty(prop)
|
|
4
|
+
|
|
5
|
+
export const composeShouldForwardProps = (tag, shouldForwardProp) =>
|
|
6
|
+
tag.__shouldForwardProps__ && shouldForwardProp
|
|
7
|
+
? (propName) => tag.__shouldForwardProps__(propName) && shouldForwardProp(propName)
|
|
8
|
+
: shouldForwardProp
|
|
9
|
+
|
|
10
|
+
export const composeCvaFn = (cvaA, cvaB) => {
|
|
11
|
+
if (cvaA && !cvaB) return cvaA
|
|
12
|
+
if (!cvaA && cvaB) return cvaB
|
|
13
|
+
if ((cvaA.__cva__ && cvaB.__cva__) || (cvaA.__recipe__ && cvaB.__recipe__)) return cvaA.merge(cvaB)
|
|
14
|
+
const error = new TypeError('Cannot merge cva with recipe. Please use either cva or recipe.')
|
|
15
|
+
TypeError.captureStackTrace?.(error)
|
|
16
|
+
throw error
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const getDisplayName = (Component) => {
|
|
20
|
+
if (typeof Component === 'string') return Component
|
|
21
|
+
return Component?.displayName || Component?.name || 'Component'
|
|
22
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createElement, forwardRef, useMemo } from 'react'
|
|
2
|
+
import { css, cx, cva } from '../css/index.mjs';
|
|
3
|
+
import { defaultShouldForwardProp, composeShouldForwardProps, composeCvaFn, getDisplayName } from './factory-helper.mjs';
|
|
4
|
+
import { splitProps, normalizeHTMLProps } from '../helpers.mjs';
|
|
5
|
+
import { isCssProperty } from './is-valid-prop.mjs';
|
|
6
|
+
|
|
7
|
+
function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
8
|
+
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
9
|
+
|
|
10
|
+
const forwardFn = options.shouldForwardProp || defaultShouldForwardProp
|
|
11
|
+
const shouldForwardProp = (prop) => forwardFn(prop, cvaFn.variantKeys)
|
|
12
|
+
|
|
13
|
+
const defaultProps = Object.assign(
|
|
14
|
+
options.dataAttr && configOrCva.__name__ ? { 'data-recipe': configOrCva.__name__ } : {},
|
|
15
|
+
options.defaultProps,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn)
|
|
19
|
+
const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp)
|
|
20
|
+
const __base__ = Dynamic.__base__ || Dynamic
|
|
21
|
+
|
|
22
|
+
const StyledComponent = /* @__PURE__ */ forwardRef(function StyledComponent(props, ref) {
|
|
23
|
+
const { as: Element = __base__, children, ...restProps } = props
|
|
24
|
+
|
|
25
|
+
const combinedProps = useMemo(() => Object.assign({}, defaultProps, restProps), [restProps])
|
|
26
|
+
|
|
27
|
+
const [htmlProps, forwardedProps, variantProps, styleProps, elementProps] = useMemo(() => {
|
|
28
|
+
return splitProps(combinedProps, normalizeHTMLProps.keys, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty)
|
|
29
|
+
}, [combinedProps])
|
|
30
|
+
|
|
31
|
+
function recipeClass() {
|
|
32
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
33
|
+
const compoundVariantStyles = __cvaFn__.__getCompoundVariantCss__?.(variantProps)
|
|
34
|
+
return cx(__cvaFn__(variantProps, false), css(compoundVariantStyles, propStyles, cssStyles), combinedProps.className)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function cvaClass() {
|
|
38
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
39
|
+
const cvaStyles = __cvaFn__.raw(variantProps)
|
|
40
|
+
return cx(css(cvaStyles, propStyles, cssStyles), combinedProps.className)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
44
|
+
|
|
45
|
+
return createElement(Element, {
|
|
46
|
+
ref,
|
|
47
|
+
...forwardedProps,
|
|
48
|
+
...elementProps,
|
|
49
|
+
...normalizeHTMLProps(htmlProps),
|
|
50
|
+
className: classes(),
|
|
51
|
+
}, combinedProps.children ?? children)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const name = getDisplayName(__base__)
|
|
55
|
+
|
|
56
|
+
StyledComponent.displayName = `styled.${name}`
|
|
57
|
+
StyledComponent.__cva__ = __cvaFn__
|
|
58
|
+
StyledComponent.__base__ = __base__
|
|
59
|
+
StyledComponent.__shouldForwardProps__ = shouldForwardProp
|
|
60
|
+
|
|
61
|
+
return StyledComponent
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function createJsxFactory() {
|
|
65
|
+
const cache = new Map()
|
|
66
|
+
|
|
67
|
+
return new Proxy(styledFn, {
|
|
68
|
+
apply(_, __, args) {
|
|
69
|
+
return styledFn(...args)
|
|
70
|
+
},
|
|
71
|
+
get(_, el) {
|
|
72
|
+
if (!cache.has(el)) {
|
|
73
|
+
cache.set(el, styledFn(el))
|
|
74
|
+
}
|
|
75
|
+
return cache.get(el)
|
|
76
|
+
},
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const styled = /* @__PURE__ */ createJsxFactory()
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { FunctionComponent } from 'react'
|
|
3
|
+
import type { FlexProperties } from '../patterns/flex';
|
|
4
|
+
import type { HTMLStyledProps } from '../types/jsx';
|
|
5
|
+
import type { DistributiveOmit } from '../types/system-types';
|
|
6
|
+
|
|
7
|
+
export interface FlexProps extends FlexProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof FlexProperties > {}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export declare const Flex: FunctionComponent<FlexProps>
|