qstd 0.2.17 → 0.2.19

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.
Files changed (128) hide show
  1. package/dist/block/fns.d.ts +1 -0
  2. package/dist/block/fns.d.ts.map +1 -1
  3. package/dist/block/index.d.ts +6 -2
  4. package/dist/block/index.d.ts.map +1 -1
  5. package/dist/react/index.cjs +25 -13
  6. package/dist/react/index.js +25 -13
  7. package/package.json +2 -1
  8. package/styled-system/css/conditions.mjs +36 -0
  9. package/styled-system/css/css.d.ts +22 -0
  10. package/styled-system/css/css.mjs +45 -0
  11. package/styled-system/css/cva.d.ts +6 -0
  12. package/styled-system/css/cva.mjs +87 -0
  13. package/styled-system/css/cx.d.ts +5 -0
  14. package/styled-system/css/cx.mjs +15 -0
  15. package/styled-system/css/index.d.ts +5 -0
  16. package/styled-system/css/index.mjs +4 -0
  17. package/styled-system/css/sva.d.ts +4 -0
  18. package/styled-system/css/sva.mjs +46 -0
  19. package/styled-system/helpers.mjs +328 -0
  20. package/styled-system/jsx/aspect-ratio.d.ts +10 -0
  21. package/styled-system/jsx/aspect-ratio.mjs +14 -0
  22. package/styled-system/jsx/bleed.d.ts +10 -0
  23. package/styled-system/jsx/bleed.mjs +14 -0
  24. package/styled-system/jsx/box.d.ts +10 -0
  25. package/styled-system/jsx/box.mjs +14 -0
  26. package/styled-system/jsx/center.d.ts +10 -0
  27. package/styled-system/jsx/center.mjs +14 -0
  28. package/styled-system/jsx/circle.d.ts +10 -0
  29. package/styled-system/jsx/circle.mjs +14 -0
  30. package/styled-system/jsx/container.d.ts +10 -0
  31. package/styled-system/jsx/container.mjs +14 -0
  32. package/styled-system/jsx/cq.d.ts +10 -0
  33. package/styled-system/jsx/cq.mjs +14 -0
  34. package/styled-system/jsx/create-style-context.d.ts +54 -0
  35. package/styled-system/jsx/create-style-context.mjs +98 -0
  36. package/styled-system/jsx/divider.d.ts +10 -0
  37. package/styled-system/jsx/divider.mjs +14 -0
  38. package/styled-system/jsx/factory-helper.mjs +22 -0
  39. package/styled-system/jsx/factory.d.ts +3 -0
  40. package/styled-system/jsx/factory.mjs +89 -0
  41. package/styled-system/jsx/flex.d.ts +10 -0
  42. package/styled-system/jsx/flex.mjs +14 -0
  43. package/styled-system/jsx/float.d.ts +10 -0
  44. package/styled-system/jsx/float.mjs +14 -0
  45. package/styled-system/jsx/grid-item.d.ts +10 -0
  46. package/styled-system/jsx/grid-item.mjs +14 -0
  47. package/styled-system/jsx/grid.d.ts +10 -0
  48. package/styled-system/jsx/grid.mjs +14 -0
  49. package/styled-system/jsx/hstack.d.ts +10 -0
  50. package/styled-system/jsx/hstack.mjs +14 -0
  51. package/styled-system/jsx/index.d.ts +25 -0
  52. package/styled-system/jsx/index.mjs +23 -0
  53. package/styled-system/jsx/is-valid-prop.d.ts +11 -0
  54. package/styled-system/jsx/is-valid-prop.mjs +17 -0
  55. package/styled-system/jsx/link-overlay.d.ts +10 -0
  56. package/styled-system/jsx/link-overlay.mjs +14 -0
  57. package/styled-system/jsx/spacer.d.ts +10 -0
  58. package/styled-system/jsx/spacer.mjs +14 -0
  59. package/styled-system/jsx/square.d.ts +10 -0
  60. package/styled-system/jsx/square.mjs +14 -0
  61. package/styled-system/jsx/stack.d.ts +10 -0
  62. package/styled-system/jsx/stack.mjs +14 -0
  63. package/styled-system/jsx/visually-hidden.d.ts +10 -0
  64. package/styled-system/jsx/visually-hidden.mjs +14 -0
  65. package/styled-system/jsx/vstack.d.ts +10 -0
  66. package/styled-system/jsx/vstack.mjs +14 -0
  67. package/styled-system/jsx/wrap.d.ts +10 -0
  68. package/styled-system/jsx/wrap.mjs +14 -0
  69. package/styled-system/patterns/aspect-ratio.d.ts +20 -0
  70. package/styled-system/patterns/aspect-ratio.mjs +38 -0
  71. package/styled-system/patterns/bleed.d.ts +21 -0
  72. package/styled-system/patterns/bleed.mjs +24 -0
  73. package/styled-system/patterns/box.d.ts +20 -0
  74. package/styled-system/patterns/box.mjs +15 -0
  75. package/styled-system/patterns/center.d.ts +20 -0
  76. package/styled-system/patterns/center.mjs +21 -0
  77. package/styled-system/patterns/circle.d.ts +20 -0
  78. package/styled-system/patterns/circle.mjs +25 -0
  79. package/styled-system/patterns/container.d.ts +20 -0
  80. package/styled-system/patterns/container.mjs +21 -0
  81. package/styled-system/patterns/cq.d.ts +21 -0
  82. package/styled-system/patterns/cq.mjs +21 -0
  83. package/styled-system/patterns/divider.d.ts +22 -0
  84. package/styled-system/patterns/divider.mjs +25 -0
  85. package/styled-system/patterns/flex.d.ts +26 -0
  86. package/styled-system/patterns/flex.mjs +26 -0
  87. package/styled-system/patterns/float.d.ts +23 -0
  88. package/styled-system/patterns/float.mjs +52 -0
  89. package/styled-system/patterns/grid-item.d.ts +25 -0
  90. package/styled-system/patterns/grid-item.mjs +25 -0
  91. package/styled-system/patterns/grid.d.ts +24 -0
  92. package/styled-system/patterns/grid.mjs +27 -0
  93. package/styled-system/patterns/hstack.d.ts +21 -0
  94. package/styled-system/patterns/hstack.mjs +24 -0
  95. package/styled-system/patterns/index.d.ts +21 -0
  96. package/styled-system/patterns/index.mjs +20 -0
  97. package/styled-system/patterns/link-overlay.d.ts +20 -0
  98. package/styled-system/patterns/link-overlay.mjs +24 -0
  99. package/styled-system/patterns/spacer.d.ts +20 -0
  100. package/styled-system/patterns/spacer.mjs +21 -0
  101. package/styled-system/patterns/square.d.ts +20 -0
  102. package/styled-system/patterns/square.mjs +24 -0
  103. package/styled-system/patterns/stack.d.ts +23 -0
  104. package/styled-system/patterns/stack.mjs +24 -0
  105. package/styled-system/patterns/visually-hidden.d.ts +20 -0
  106. package/styled-system/patterns/visually-hidden.mjs +18 -0
  107. package/styled-system/patterns/vstack.d.ts +21 -0
  108. package/styled-system/patterns/vstack.mjs +24 -0
  109. package/styled-system/patterns/wrap.d.ts +24 -0
  110. package/styled-system/patterns/wrap.mjs +25 -0
  111. package/styled-system/styles.css +1733 -0
  112. package/styled-system/tokens/index.d.ts +9 -0
  113. package/styled-system/tokens/index.mjs +1976 -0
  114. package/styled-system/tokens/tokens.d.ts +60 -0
  115. package/styled-system/types/composition.d.ts +224 -0
  116. package/styled-system/types/conditions.d.ts +348 -0
  117. package/styled-system/types/csstype.d.ts +21298 -0
  118. package/styled-system/types/global.d.ts +20 -0
  119. package/styled-system/types/index.d.ts +8 -0
  120. package/styled-system/types/jsx.d.ts +67 -0
  121. package/styled-system/types/parts.d.ts +8 -0
  122. package/styled-system/types/pattern.d.ts +78 -0
  123. package/styled-system/types/prop-type.d.ts +277 -0
  124. package/styled-system/types/recipe.d.ts +181 -0
  125. package/styled-system/types/selectors.d.ts +59 -0
  126. package/styled-system/types/static-css.d.ts +56 -0
  127. package/styled-system/types/style-props.d.ts +7639 -0
  128. package/styled-system/types/system-types.d.ts +269 -0
@@ -0,0 +1,328 @@
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) name = toChar(x % 52) + name;
26
+ return toChar(x % 52) + name;
27
+ }
28
+ function toPhash(h, x) {
29
+ let i = x.length;
30
+ while (i) h = h * 33 ^ x.charCodeAt(--i);
31
+ return h;
32
+ }
33
+ function toHash(value) {
34
+ return toName(toPhash(5381, value) >>> 0);
35
+ }
36
+
37
+ // src/important.ts
38
+ var importantRegex = /\s*!(important)?/i;
39
+ function isImportant(value) {
40
+ return typeof value === "string" ? importantRegex.test(value) : false;
41
+ }
42
+ function withoutImportant(value) {
43
+ return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;
44
+ }
45
+ function withoutSpace(str) {
46
+ return typeof str === "string" ? str.replaceAll(" ", "_") : str;
47
+ }
48
+
49
+ // src/memo.ts
50
+ var memo = (fn) => {
51
+ const cache = /* @__PURE__ */ new Map();
52
+ const get = (...args) => {
53
+ const key = JSON.stringify(args);
54
+ if (cache.has(key)) {
55
+ return cache.get(key);
56
+ }
57
+ const result = fn(...args);
58
+ cache.set(key, result);
59
+ return result;
60
+ };
61
+ return get;
62
+ };
63
+
64
+ // src/merge-props.ts
65
+ var MERGE_OMIT = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
66
+ function mergeProps(...sources) {
67
+ return sources.reduce((prev, obj) => {
68
+ if (!obj) return prev;
69
+ Object.keys(obj).forEach((key) => {
70
+ if (MERGE_OMIT.has(key)) return;
71
+ const prevValue = prev[key];
72
+ const value = obj[key];
73
+ if (isObject(prevValue) && isObject(value)) {
74
+ prev[key] = mergeProps(prevValue, value);
75
+ } else {
76
+ prev[key] = value;
77
+ }
78
+ });
79
+ return prev;
80
+ }, {});
81
+ }
82
+
83
+ // src/walk-object.ts
84
+ var 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)) {
94
+ return predicate(value, path);
95
+ }
96
+ const next = inner(child, childPath);
97
+ if (isNotNullish(next)) {
98
+ result[key] = next;
99
+ }
100
+ }
101
+ return result;
102
+ }
103
+ return predicate(value, path);
104
+ }
105
+ return inner(target);
106
+ }
107
+ function mapObject(obj, fn) {
108
+ if (Array.isArray(obj)) return obj.map((value) => fn(value));
109
+ if (!isObject(obj)) return fn(obj);
110
+ return walkObject(obj, (value) => fn(value));
111
+ }
112
+
113
+ // src/normalize-style-object.ts
114
+ function toResponsiveObject(values, breakpoints) {
115
+ return values.reduce(
116
+ (acc, current, index) => {
117
+ const key = breakpoints[index];
118
+ if (current != null) {
119
+ acc[key] = current;
120
+ }
121
+ return acc;
122
+ },
123
+ {}
124
+ );
125
+ }
126
+ function normalizeStyleObject(styles, context, shorthand = true) {
127
+ const { utility, conditions } = context;
128
+ const { hasShorthand, resolveShorthand } = utility;
129
+ return walkObject(
130
+ styles,
131
+ (value) => {
132
+ return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;
133
+ },
134
+ {
135
+ stop: (value) => Array.isArray(value),
136
+ getKey: shorthand ? (prop) => hasShorthand ? resolveShorthand(prop) : prop : void 0
137
+ }
138
+ );
139
+ }
140
+
141
+ // src/classname.ts
142
+ var fallbackCondition = {
143
+ shift: (v) => v,
144
+ finalize: (v) => v,
145
+ breakpoints: { keys: [] }
146
+ };
147
+ var sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\n\s]+/g, " ") : value;
148
+ function createCss(context) {
149
+ const { utility, hash, conditions: conds = fallbackCondition } = context;
150
+ const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");
151
+ const hashFn = (conditions, className) => {
152
+ let result;
153
+ if (hash) {
154
+ const baseArray = [...conds.finalize(conditions), className];
155
+ result = formatClassName(utility.toHash(baseArray, toHash));
156
+ } else {
157
+ const baseArray = [...conds.finalize(conditions), formatClassName(className)];
158
+ result = baseArray.join(":");
159
+ }
160
+ return result;
161
+ };
162
+ return memo(({ base, ...styles } = {}) => {
163
+ const styleObject = Object.assign(styles, base);
164
+ const normalizedObject = normalizeStyleObject(styleObject, context);
165
+ const classNames = /* @__PURE__ */ new Set();
166
+ walkObject(normalizedObject, (value, paths) => {
167
+ if (value == null) return;
168
+ const important = isImportant(value);
169
+ const [prop, ...allConditions] = conds.shift(paths);
170
+ const conditions = filterBaseConditions(allConditions);
171
+ const transformed = utility.transform(prop, withoutImportant(sanitize(value)));
172
+ let className = hashFn(conditions, transformed.className);
173
+ if (important) className = `${className}!`;
174
+ classNames.add(className);
175
+ });
176
+ return Array.from(classNames).join(" ");
177
+ });
178
+ }
179
+ function compactStyles(...styles) {
180
+ return styles.flat().filter((style) => isObject(style) && Object.keys(compact(style)).length > 0);
181
+ }
182
+ function createMergeCss(context) {
183
+ function resolve(styles) {
184
+ const allStyles = compactStyles(...styles);
185
+ if (allStyles.length === 1) return allStyles;
186
+ return allStyles.map((style) => normalizeStyleObject(style, context));
187
+ }
188
+ function mergeCss(...styles) {
189
+ return mergeProps(...resolve(styles));
190
+ }
191
+ function assignCss(...styles) {
192
+ return Object.assign({}, ...resolve(styles));
193
+ }
194
+ return { mergeCss: memo(mergeCss), assignCss };
195
+ }
196
+
197
+ // src/hypenate-property.ts
198
+ var wordRegex = /([A-Z])/g;
199
+ var msRegex = /^ms-/;
200
+ var hypenateProperty = memo((property) => {
201
+ if (property.startsWith("--")) return property;
202
+ return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
203
+ });
204
+
205
+ // src/is-css-function.ts
206
+ var fns = ["min", "max", "clamp", "calc"];
207
+ var fnRegExp = new RegExp(`^(${fns.join("|")})\\(.*\\)`);
208
+ var isCssFunction = (v) => typeof v === "string" && fnRegExp.test(v);
209
+
210
+ // src/is-css-unit.ts
211
+ 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,%";
212
+ var lengthUnitsPattern = `(?:${lengthUnits.split(",").join("|")})`;
213
+ var lengthRegExp = new RegExp(`^[+-]?[0-9]*.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`);
214
+ var isCssUnit = (v) => typeof v === "string" && lengthRegExp.test(v);
215
+
216
+ // src/is-css-var.ts
217
+ var isCssVar = (v) => typeof v === "string" && /^var\(--.+\)$/.test(v);
218
+
219
+ // src/pattern-fns.ts
220
+ var patternFns = {
221
+ map: mapObject,
222
+ isCssFunction,
223
+ isCssVar,
224
+ isCssUnit
225
+ };
226
+ var getPatternStyles = (pattern, styles) => {
227
+ if (!pattern?.defaultValues) return styles;
228
+ const defaults = typeof pattern.defaultValues === "function" ? pattern.defaultValues(styles) : pattern.defaultValues;
229
+ return Object.assign({}, defaults, compact(styles));
230
+ };
231
+
232
+ // src/slot.ts
233
+ var getSlotRecipes = (recipe = {}) => {
234
+ const init = (slot) => ({
235
+ className: [recipe.className, slot].filter(Boolean).join("__"),
236
+ base: recipe.base?.[slot] ?? {},
237
+ variants: {},
238
+ defaultVariants: recipe.defaultVariants ?? {},
239
+ compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []
240
+ });
241
+ const slots = recipe.slots ?? [];
242
+ const recipeParts = slots.map((slot) => [slot, init(slot)]);
243
+ for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) {
244
+ for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) {
245
+ recipeParts.forEach(([slot, slotRecipe]) => {
246
+ slotRecipe.variants[variantsKey] ??= {};
247
+ slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};
248
+ });
249
+ }
250
+ }
251
+ return Object.fromEntries(recipeParts);
252
+ };
253
+ var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
254
+
255
+ // src/split-props.ts
256
+ function splitProps(props, ...keys) {
257
+ const descriptors = Object.getOwnPropertyDescriptors(props);
258
+ const dKeys = Object.keys(descriptors);
259
+ const split = (k) => {
260
+ const clone = {};
261
+ for (let i = 0; i < k.length; i++) {
262
+ const key = k[i];
263
+ if (descriptors[key]) {
264
+ Object.defineProperty(clone, key, descriptors[key]);
265
+ delete descriptors[key];
266
+ }
267
+ }
268
+ return clone;
269
+ };
270
+ const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));
271
+ return keys.map(fn).concat(split(dKeys));
272
+ }
273
+
274
+ // src/uniq.ts
275
+ var uniq = (...items) => {
276
+ const set = items.reduce((acc, currItems) => {
277
+ if (currItems) {
278
+ currItems.forEach((item) => acc.add(item));
279
+ }
280
+ return acc;
281
+ }, /* @__PURE__ */ new Set([]));
282
+ return Array.from(set);
283
+ };
284
+ export {
285
+ compact,
286
+ createCss,
287
+ createMergeCss,
288
+ filterBaseConditions,
289
+ getPatternStyles,
290
+ getSlotCompoundVariant,
291
+ getSlotRecipes,
292
+ hypenateProperty,
293
+ isBaseCondition,
294
+ isObject,
295
+ mapObject,
296
+ memo,
297
+ mergeProps,
298
+ patternFns,
299
+ splitProps,
300
+ toHash,
301
+ uniq,
302
+ walkObject,
303
+ withoutSpace
304
+ };
305
+
306
+
307
+
308
+ // src/normalize-html.ts
309
+ var htmlProps = ["htmlSize", "htmlTranslate", "htmlWidth", "htmlHeight"];
310
+ function convert(key) {
311
+ return htmlProps.includes(key) ? key.replace("html", "").toLowerCase() : key;
312
+ }
313
+ function normalizeHTMLProps(props) {
314
+ return Object.fromEntries(Object.entries(props).map(([key, value]) => [convert(key), value]));
315
+ }
316
+ normalizeHTMLProps.keys = htmlProps;
317
+ export {
318
+ normalizeHTMLProps
319
+ };
320
+
321
+
322
+ export function __spreadValues(a, b) {
323
+ return { ...a, ...b }
324
+ }
325
+
326
+ export function __objRest(source, exclude) {
327
+ return Object.fromEntries(Object.entries(source).filter(([key]) => !exclude.includes(key)))
328
+ }
@@ -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,54 @@
1
+ /* eslint-disable */
2
+ import type { SlotRecipeRuntimeFn, RecipeVariantProps } from '../types/recipe';
3
+ import type { JsxHTMLProps, JsxStyleProps, Assign } from '../types/system-types';
4
+ import type { JsxFactoryOptions, ComponentProps } from '../types/jsx';
5
+ import type { ComponentType, ElementType } from 'react'
6
+
7
+ interface UnstyledProps {
8
+ unstyled?: boolean | undefined
9
+ }
10
+
11
+ type SvaFn<S extends string = any> = SlotRecipeRuntimeFn<S, any>
12
+ interface SlotRecipeFn {
13
+ __type: any
14
+ __slot: string
15
+ (props?: any): any
16
+ }
17
+ type SlotRecipe = SvaFn | SlotRecipeFn
18
+
19
+ type InferSlot<R extends SlotRecipe> = R extends SlotRecipeFn ? R['__slot'] : R extends SvaFn<infer S> ? S : never
20
+
21
+ interface WithProviderOptions<P = {}> {
22
+ defaultProps?: Partial<P> | undefined
23
+ }
24
+
25
+ type StyleContextProvider<T extends ElementType, R extends SlotRecipe> = ComponentType<
26
+ JsxHTMLProps<ComponentProps<T> & UnstyledProps, Assign<RecipeVariantProps<R>, JsxStyleProps>>
27
+ >
28
+
29
+ type StyleContextRootProvider<T extends ElementType, R extends SlotRecipe> = ComponentType<
30
+ ComponentProps<T> & UnstyledProps & RecipeVariantProps<R>
31
+ >
32
+
33
+ type StyleContextConsumer<T extends ElementType> = ComponentType<
34
+ JsxHTMLProps<ComponentProps<T> & UnstyledProps, JsxStyleProps>
35
+ >
36
+
37
+ export interface StyleContext<R extends SlotRecipe> {
38
+ withRootProvider: <T extends ElementType>(
39
+ Component: T,
40
+ options?: WithProviderOptions<ComponentProps<T>> | undefined
41
+ ) => StyleContextRootProvider<T, R>
42
+ withProvider: <T extends ElementType>(
43
+ Component: T,
44
+ slot: InferSlot<R>,
45
+ options?: JsxFactoryOptions<ComponentProps<T>> | undefined
46
+ ) => StyleContextProvider<T, R>
47
+ withContext: <T extends ElementType>(
48
+ Component: T,
49
+ slot: InferSlot<R>,
50
+ options?: JsxFactoryOptions<ComponentProps<T>> | undefined
51
+ ) => StyleContextConsumer<T>
52
+ }
53
+
54
+ export declare function createStyleContext<R extends SlotRecipe>(recipe: R): StyleContext<R>
@@ -0,0 +1,98 @@
1
+ 'use client'
2
+
3
+ import { cx, css, sva } from '../css/index.mjs';
4
+ import { styled } from './factory.mjs';
5
+ import { getDisplayName } from './factory-helper.mjs';
6
+ import { createContext, useContext, createElement, forwardRef } from 'react'
7
+
8
+ export function createStyleContext(recipe) {
9
+ const StyleContext = createContext({})
10
+ const isConfigRecipe = '__recipe__' in recipe
11
+ const svaFn = isConfigRecipe ? recipe : sva(recipe.config)
12
+
13
+ const getResolvedProps = (props, slotStyles) => {
14
+ const { unstyled, ...restProps } = props
15
+ if (unstyled) return restProps
16
+ if (isConfigRecipe) {
17
+ return { ...restProps, className: cx(slotStyles, restProps.className) }
18
+ }
19
+ return { ...slotStyles, ...restProps }
20
+ }
21
+
22
+ const withRootProvider = (Component, options) => {
23
+ const WithRootProvider = (props) => {
24
+ const [variantProps, otherProps] = svaFn.splitVariantProps(props)
25
+
26
+ const slotStyles = isConfigRecipe ? svaFn(variantProps) : svaFn.raw(variantProps)
27
+ slotStyles._classNameMap = svaFn.classNameMap
28
+
29
+ const mergedProps = options?.defaultProps
30
+ ? { ...options.defaultProps, ...otherProps }
31
+ : otherProps
32
+
33
+ return createElement(StyleContext.Provider, {
34
+ value: slotStyles,
35
+ children: createElement(Component, mergedProps)
36
+ })
37
+ }
38
+
39
+ const componentName = getDisplayName(Component)
40
+ WithRootProvider.displayName = `withRootProvider(${componentName})`
41
+
42
+ return WithRootProvider
43
+ }
44
+
45
+ const withProvider = (Component, slot, options) => {
46
+ const StyledComponent = styled(Component, {}, options)
47
+
48
+ const WithProvider = forwardRef((props, ref) => {
49
+ const [variantProps, restProps] = svaFn.splitVariantProps(props)
50
+
51
+ const slotStyles = isConfigRecipe ? svaFn(variantProps) : svaFn.raw(variantProps)
52
+ slotStyles._classNameMap = svaFn.classNameMap
53
+
54
+ const propsWithClass = { ...restProps, className: restProps.className ?? options?.defaultProps?.className }
55
+ const resolvedProps = getResolvedProps(propsWithClass, slotStyles[slot])
56
+ return createElement(StyleContext.Provider, {
57
+ value: slotStyles,
58
+ children: createElement(StyledComponent, {
59
+ ...resolvedProps,
60
+ className: cx(resolvedProps.className, slotStyles._classNameMap[slot]),
61
+ ref,
62
+ })
63
+ })
64
+ })
65
+
66
+ const componentName = getDisplayName(Component)
67
+ WithProvider.displayName = `withProvider(${componentName})`
68
+
69
+ return WithProvider
70
+ }
71
+
72
+ const withContext = (Component, slot, options) => {
73
+ const StyledComponent = styled(Component, {}, options)
74
+
75
+ const WithContext = forwardRef((props, ref) => {
76
+ const slotStyles = useContext(StyleContext)
77
+
78
+ const propsWithClass = { ...props, className: props.className ?? options?.defaultProps?.className }
79
+ const resolvedProps = getResolvedProps(propsWithClass, slotStyles[slot])
80
+ return createElement(StyledComponent, {
81
+ ...resolvedProps,
82
+ className: cx(resolvedProps.className, slotStyles._classNameMap[slot]),
83
+ ref,
84
+ })
85
+ })
86
+
87
+ const componentName = getDisplayName(Component)
88
+ WithContext.displayName = `withContext(${componentName})`
89
+
90
+ return WithContext
91
+ }
92
+
93
+ return {
94
+ withRootProvider,
95
+ withProvider,
96
+ withContext,
97
+ }
98
+ }
@@ -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>