@stokelp/styled-system 1.0.1

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 (148) hide show
  1. package/css/conditions.mjs +34 -0
  2. package/css/css.d.ts +9 -0
  3. package/css/css.mjs +45 -0
  4. package/css/cva.d.ts +6 -0
  5. package/css/cva.mjs +87 -0
  6. package/css/cx.d.ts +5 -0
  7. package/css/cx.mjs +15 -0
  8. package/css/index.d.ts +5 -0
  9. package/css/index.mjs +4 -0
  10. package/css/sva.d.ts +4 -0
  11. package/css/sva.mjs +41 -0
  12. package/jsx/aspect-ratio.d.ts +10 -0
  13. package/jsx/aspect-ratio.mjs +14 -0
  14. package/jsx/bleed.d.ts +10 -0
  15. package/jsx/bleed.mjs +14 -0
  16. package/jsx/box.d.ts +10 -0
  17. package/jsx/box.mjs +14 -0
  18. package/jsx/center.d.ts +10 -0
  19. package/jsx/center.mjs +14 -0
  20. package/jsx/circle.d.ts +10 -0
  21. package/jsx/circle.mjs +14 -0
  22. package/jsx/container.d.ts +10 -0
  23. package/jsx/container.mjs +14 -0
  24. package/jsx/cq.d.ts +10 -0
  25. package/jsx/cq.mjs +14 -0
  26. package/jsx/divider.d.ts +10 -0
  27. package/jsx/divider.mjs +14 -0
  28. package/jsx/factory-helper.mjs +22 -0
  29. package/jsx/factory.d.ts +3 -0
  30. package/jsx/factory.mjs +80 -0
  31. package/jsx/flex.d.ts +10 -0
  32. package/jsx/flex.mjs +14 -0
  33. package/jsx/float.d.ts +10 -0
  34. package/jsx/float.mjs +14 -0
  35. package/jsx/grid-item.d.ts +10 -0
  36. package/jsx/grid-item.mjs +14 -0
  37. package/jsx/grid.d.ts +10 -0
  38. package/jsx/grid.mjs +14 -0
  39. package/jsx/hstack.d.ts +10 -0
  40. package/jsx/hstack.mjs +14 -0
  41. package/jsx/index.d.ts +25 -0
  42. package/jsx/index.mjs +23 -0
  43. package/jsx/is-valid-prop.d.ts +11 -0
  44. package/jsx/is-valid-prop.mjs +17 -0
  45. package/jsx/link-box.d.ts +10 -0
  46. package/jsx/link-box.mjs +14 -0
  47. package/jsx/link-overlay.d.ts +10 -0
  48. package/jsx/link-overlay.mjs +14 -0
  49. package/jsx/spacer.d.ts +10 -0
  50. package/jsx/spacer.mjs +14 -0
  51. package/jsx/square.d.ts +10 -0
  52. package/jsx/square.mjs +14 -0
  53. package/jsx/stack.d.ts +10 -0
  54. package/jsx/stack.mjs +14 -0
  55. package/jsx/visually-hidden.d.ts +10 -0
  56. package/jsx/visually-hidden.mjs +14 -0
  57. package/jsx/vstack.d.ts +10 -0
  58. package/jsx/vstack.mjs +14 -0
  59. package/jsx/wrap.d.ts +10 -0
  60. package/jsx/wrap.mjs +14 -0
  61. package/package.json +56 -0
  62. package/panda.buildinfo.json +75 -0
  63. package/patterns/aspect-ratio.d.ts +21 -0
  64. package/patterns/aspect-ratio.mjs +38 -0
  65. package/patterns/bleed.d.ts +22 -0
  66. package/patterns/bleed.mjs +24 -0
  67. package/patterns/box.d.ts +21 -0
  68. package/patterns/box.mjs +15 -0
  69. package/patterns/center.d.ts +21 -0
  70. package/patterns/center.mjs +21 -0
  71. package/patterns/circle.d.ts +21 -0
  72. package/patterns/circle.mjs +25 -0
  73. package/patterns/container.d.ts +21 -0
  74. package/patterns/container.mjs +21 -0
  75. package/patterns/cq.d.ts +22 -0
  76. package/patterns/cq.mjs +21 -0
  77. package/patterns/divider.d.ts +23 -0
  78. package/patterns/divider.mjs +25 -0
  79. package/patterns/flex.d.ts +27 -0
  80. package/patterns/flex.mjs +26 -0
  81. package/patterns/float.d.ts +24 -0
  82. package/patterns/float.mjs +52 -0
  83. package/patterns/grid-item.d.ts +26 -0
  84. package/patterns/grid-item.mjs +25 -0
  85. package/patterns/grid.d.ts +25 -0
  86. package/patterns/grid.mjs +27 -0
  87. package/patterns/hstack.d.ts +22 -0
  88. package/patterns/hstack.mjs +24 -0
  89. package/patterns/index.d.ts +22 -0
  90. package/patterns/index.mjs +21 -0
  91. package/patterns/link-box.d.ts +21 -0
  92. package/patterns/link-box.mjs +22 -0
  93. package/patterns/link-overlay.d.ts +21 -0
  94. package/patterns/link-overlay.mjs +27 -0
  95. package/patterns/spacer.d.ts +21 -0
  96. package/patterns/spacer.mjs +21 -0
  97. package/patterns/square.d.ts +21 -0
  98. package/patterns/square.mjs +24 -0
  99. package/patterns/stack.d.ts +24 -0
  100. package/patterns/stack.mjs +24 -0
  101. package/patterns/visually-hidden.d.ts +21 -0
  102. package/patterns/visually-hidden.mjs +18 -0
  103. package/patterns/vstack.d.ts +22 -0
  104. package/patterns/vstack.mjs +24 -0
  105. package/patterns/wrap.d.ts +25 -0
  106. package/patterns/wrap.mjs +25 -0
  107. package/recipes/accordion.d.ts +28 -0
  108. package/recipes/accordion.mjs +56 -0
  109. package/recipes/button.d.ts +30 -0
  110. package/recipes/button.mjs +116 -0
  111. package/recipes/checkbox.d.ts +28 -0
  112. package/recipes/checkbox.mjs +52 -0
  113. package/recipes/create-recipe.mjs +82 -0
  114. package/recipes/drawer.d.ts +28 -0
  115. package/recipes/drawer.mjs +77 -0
  116. package/recipes/form-control.d.ts +28 -0
  117. package/recipes/form-control.mjs +24 -0
  118. package/recipes/form-helper-text.d.ts +28 -0
  119. package/recipes/form-helper-text.mjs +24 -0
  120. package/recipes/form-label.d.ts +28 -0
  121. package/recipes/form-label.mjs +36 -0
  122. package/recipes/heading.d.ts +30 -0
  123. package/recipes/heading.mjs +41 -0
  124. package/recipes/index.d.ts +12 -0
  125. package/recipes/index.mjs +11 -0
  126. package/recipes/switch-recipe.d.ts +28 -0
  127. package/recipes/switch-recipe.mjs +52 -0
  128. package/recipes/text.d.ts +31 -0
  129. package/recipes/text.mjs +41 -0
  130. package/recipes/textarea.d.ts +28 -0
  131. package/recipes/textarea.mjs +24 -0
  132. package/tokens/index.d.ts +9 -0
  133. package/tokens/index.mjs +1496 -0
  134. package/tokens/tokens.d.ts +63 -0
  135. package/types/composition.d.ts +111 -0
  136. package/types/conditions.d.ts +270 -0
  137. package/types/csstype.d.ts +21298 -0
  138. package/types/global.d.ts +19 -0
  139. package/types/index.d.ts +8 -0
  140. package/types/jsx.d.ts +52 -0
  141. package/types/parts.d.ts +8 -0
  142. package/types/pattern.d.ts +74 -0
  143. package/types/prop-type.d.ts +242 -0
  144. package/types/recipe.d.ts +173 -0
  145. package/types/selectors.d.ts +59 -0
  146. package/types/static-css.d.ts +51 -0
  147. package/types/style-props.d.ts +7468 -0
  148. package/types/system-types.d.ts +89 -0
@@ -0,0 +1,34 @@
1
+ import { withoutSpace } from '../helpers.mjs';
2
+
3
+ const conditionsStr = "_hover,_focus,_focusWithin,_focusVisible,_disabled,_active,_visited,_target,_readOnly,_readWrite,_empty,_checked,_enabled,_expanded,_highlighted,_before,_after,_firstLetter,_firstLine,_marker,_selection,_file,_backdrop,_first,_last,_only,_even,_odd,_firstOfType,_lastOfType,_onlyOfType,_peerFocus,_peerHover,_peerActive,_peerFocusWithin,_peerFocusVisible,_peerDisabled,_peerChecked,_peerInvalid,_peerExpanded,_peerPlaceholderShown,_groupFocus,_groupHover,_groupActive,_groupFocusWithin,_groupFocusVisible,_groupDisabled,_groupChecked,_groupExpanded,_groupInvalid,_indeterminate,_required,_valid,_invalid,_autofill,_inRange,_outOfRange,_placeholder,_placeholderShown,_pressed,_selected,_default,_optional,_open,_closed,_fullscreen,_loading,_currentPage,_currentStep,_motionReduce,_motionSafe,_print,_landscape,_portrait,_dark,_light,_osDark,_osLight,_highContrast,_lessContrast,_moreContrast,_ltr,_rtl,_scrollbar,_scrollbarThumb,_scrollbarTrack,_horizontal,_vertical,_starting,_collapsed,_current,_hidden,_today,_underValue,sm,smOnly,smDown,md,mdOnly,mdDown,lg,lgOnly,lgDown,xl,xlOnly,xlDown,smToMd,smToLg,smToXl,mdToLg,mdToXl,lgToXl,@/2xl,@/3xl,@/4xl,@/5xl,@/6xl,@/7xl,@/8xl,@/lg,@/md,@/sm,@/xl,@/xs,base"
4
+ const conditions = new Set(conditionsStr.split(','))
5
+
6
+ export function isCondition(value){
7
+ return conditions.has(value) || /^@|&|&$/.test(value)
8
+ }
9
+
10
+ const underscoreRegex = /^_/
11
+ const conditionsSelectorRegex = /&|@/
12
+
13
+ export function finalizeConditions(paths){
14
+ return paths.map((path) => {
15
+ if (conditions.has(path)){
16
+ return path.replace(underscoreRegex, '')
17
+ }
18
+
19
+ if (conditionsSelectorRegex.test(path)){
20
+ return `[${withoutSpace(path.trim())}]`
21
+ }
22
+
23
+ return path
24
+ })}
25
+
26
+ export function sortConditions(paths){
27
+ return paths.sort((a, b) => {
28
+ const aa = isCondition(a)
29
+ const bb = isCondition(b)
30
+ if (aa && !bb) return 1
31
+ if (!aa && bb) return -1
32
+ return 0
33
+ })
34
+ }
package/css/css.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /* eslint-disable */
2
+ import type { SystemStyleObject } from '../types/index';
3
+
4
+ interface CssFunction {
5
+ (...styles: Array<SystemStyleObject | undefined | null | false>): string
6
+ raw: (...styles: Array<SystemStyleObject | undefined | null | false>) => SystemStyleObject
7
+ }
8
+
9
+ export declare const css: CssFunction;
package/css/css.mjs ADDED
@@ -0,0 +1,45 @@
1
+ import { createCss, createMergeCss, hypenateProperty, withoutSpace } from '../helpers.mjs';
2
+ import { sortConditions, finalizeConditions } from './conditions.mjs';
3
+
4
+ const utilities = "aspectRatio:aspect,boxDecorationBreak:decoration,zIndex:z,boxSizing:box,objectPosition:obj-pos,objectFit:obj-fit,overscrollBehavior:overscroll,overscrollBehaviorX:overscroll-x,overscrollBehaviorY:overscroll-y,position:pos/1,top:top,left:left,insetInline:inset-x/insetX,insetBlock:inset-y/insetY,inset:inset,insetBlockEnd:inset-b,insetBlockStart:inset-t,insetInlineEnd:end/insetEnd/1,insetInlineStart:start/insetStart/1,right:right,bottom:bottom,float:float,visibility:vis,display:d,hideFrom:hide,hideBelow:show,flexBasis:basis,flex:flex,flexDirection:flex/flexDir,flexGrow:grow,flexShrink:shrink,gridTemplateColumns:grid-cols,gridTemplateRows:grid-rows,gridColumn:col-span,gridRow:row-span,gridColumnStart:col-start,gridColumnEnd:col-end,gridAutoFlow:grid-flow,gridAutoColumns:auto-cols,gridAutoRows:auto-rows,gap:gap,gridGap:gap,gridRowGap:gap-x,gridColumnGap:gap-y,rowGap:gap-x,columnGap:gap-y,justifyContent:justify,alignContent:content,alignItems:items,alignSelf:self,padding:p/1,paddingLeft:pl/1,paddingRight:pr/1,paddingTop:pt/1,paddingBottom:pb/1,paddingBlock:py/1/paddingY,paddingBlockEnd:pb,paddingBlockStart:pt,paddingInline:px/paddingX/1,paddingInlineEnd:pe/1/paddingEnd,paddingInlineStart:ps/1/paddingStart,marginLeft:ml/1,marginRight:mr/1,marginTop:mt/1,marginBottom:mb/1,margin:m/1,marginBlock:my/1/marginY,marginBlockEnd:mb,marginBlockStart:mt,marginInline:mx/1/marginX,marginInlineEnd:me/1/marginEnd,marginInlineStart:ms/1/marginStart,spaceX:space-x,spaceY:space-y,outlineWidth:ring-width/ringWidth,outlineColor:ring-color/ringColor,outline:ring/1,outlineOffset:ring-offset/ringOffset,divideX:divide-x,divideY:divide-y,divideColor:divide-color,divideStyle:divide-style,width:w/1,inlineSize:w,minWidth:min-w/minW,minInlineSize:min-w,maxWidth:max-w/maxW,maxInlineSize:max-w,height:h/1,blockSize:h,minHeight:min-h/minH,minBlockSize:min-h,maxHeight:max-h/maxH,maxBlockSize:max-b,color:text,fontFamily:font,fontSize:fs,fontWeight:fw,fontSmoothing:smoothing,fontVariantNumeric:numeric,letterSpacing:tracking,lineHeight:leading,textAlign:text-align,textDecoration:text-decor,textDecorationColor:text-decor-color,textEmphasisColor:text-emphasis-color,textDecorationStyle:decoration-style,textDecorationThickness:decoration-thickness,textUnderlineOffset:underline-offset,textTransform:text-transform,textIndent:indent,textShadow:text-shadow,textShadowColor:text-shadow/textShadowColor,textOverflow:text-overflow,verticalAlign:v-align,wordBreak:break,textWrap:text-wrap,truncate:truncate,lineClamp:clamp,listStyleType:list-type,listStylePosition:list-pos,listStyleImage:list-img,backgroundPosition:bg-pos/bgPosition,backgroundPositionX:bg-pos-x/bgPositionX,backgroundPositionY:bg-pos-y/bgPositionY,backgroundAttachment:bg-attach/bgAttachment,backgroundClip:bg-clip/bgClip,background:bg/1,backgroundColor:bg/bgColor,backgroundOrigin:bg-origin/bgOrigin,backgroundImage:bg-img/bgImage,backgroundRepeat:bg-repeat/bgRepeat,backgroundBlendMode:bg-blend/bgBlendMode,backgroundSize:bg-size/bgSize,backgroundGradient:bg-gradient/bgGradient,textGradient:text-gradient,gradientFromPosition:gradient-from-pos,gradientToPosition:gradient-to-pos,gradientFrom:gradient-from,gradientTo:gradient-to,gradientVia:gradient-via,gradientViaPosition:gradient-via-pos,borderRadius:rounded/1,borderTopLeftRadius:rounded-tl/roundedTopLeft,borderTopRightRadius:rounded-tr/roundedTopRight,borderBottomRightRadius:rounded-br/roundedBottomRight,borderBottomLeftRadius:rounded-bl/roundedBottomLeft,borderTopRadius:rounded-t/roundedTop,borderRightRadius:rounded-r/roundedRight,borderBottomRadius:rounded-b/roundedBottom,borderLeftRadius:rounded-l/roundedLeft,borderStartStartRadius:rounded-ss/roundedStartStart,borderStartEndRadius:rounded-se/roundedStartEnd,borderStartRadius:rounded-s/roundedStart,borderEndStartRadius:rounded-es/roundedEndStart,borderEndEndRadius:rounded-ee/roundedEndEnd,borderEndRadius:rounded-e/roundedEnd,border:border,borderWidth:border-w,borderTopWidth:border-tw,borderLeftWidth:border-lw,borderRightWidth:border-rw,borderBottomWidth:border-bw,borderColor:border,borderInline:border-x/borderX,borderInlineWidth:border-x/borderXWidth,borderInlineColor:border-x/borderXColor,borderBlock:border-y/borderY,borderBlockWidth:border-y/borderYWidth,borderBlockColor:border-y/borderYColor,borderLeft:border-l,borderLeftColor:border-l,borderInlineStart:border-s/borderStart,borderInlineStartWidth:border-s/borderStartWidth,borderInlineStartColor:border-s/borderStartColor,borderRight:border-r,borderRightColor:border-r,borderInlineEnd:border-e/borderEnd,borderInlineEndWidth:border-e/borderEndWidth,borderInlineEndColor:border-e/borderEndColor,borderTop:border-t,borderTopColor:border-t,borderBottom:border-b,borderBottomColor:border-b,borderBlockEnd:border-be,borderBlockEndColor:border-be,borderBlockStart:border-bs,borderBlockStartColor:border-bs,boxShadow:shadow/1,boxShadowColor:shadow-color/shadowColor,mixBlendMode:mix-blend,filter:filter,brightness:brightness,contrast:contrast,grayscale:grayscale,hueRotate:hue-rotate,invert:invert,saturate:saturate,sepia:sepia,dropShadow:drop-shadow,blur:blur,backdropFilter:backdrop,backdropBlur:backdrop-blur,backdropBrightness:backdrop-brightness,backdropContrast:backdrop-contrast,backdropGrayscale:backdrop-grayscale,backdropHueRotate:backdrop-hue-rotate,backdropInvert:backdrop-invert,backdropOpacity:backdrop-opacity,backdropSaturate:backdrop-saturate,backdropSepia:backdrop-sepia,borderCollapse:border,borderSpacing:border-spacing,borderSpacingX:border-spacing-x,borderSpacingY:border-spacing-y,tableLayout:table,transitionTimingFunction:ease,transitionDelay:delay,transitionDuration:duration,transitionProperty:transition-prop,transition:transition,animation:animation,animationName:animation-name,animationTimingFunction:animation-ease,animationDuration:animation-duration,animationDelay:animation-delay,transformOrigin:origin,rotate:rotate,rotateX:rotate-x,rotateY:rotate-y,rotateZ:rotate-z,scale:scale,scaleX:scale-x,scaleY:scale-y,translate:translate,translateX:translate-x/x,translateY:translate-y/y,translateZ:translate-z/z,accentColor:accent,caretColor:caret,scrollBehavior:scroll,scrollbar:scrollbar,scrollMargin:scroll-m,scrollMarginLeft:scroll-ml,scrollMarginRight:scroll-mr,scrollMarginTop:scroll-mt,scrollMarginBottom:scroll-mb,scrollMarginBlock:scroll-my/scrollMarginY,scrollMarginBlockEnd:scroll-mb,scrollMarginBlockStart:scroll-mt,scrollMarginInline:scroll-mx/scrollMarginX,scrollMarginInlineEnd:scroll-me,scrollMarginInlineStart:scroll-ms,scrollPadding:scroll-p,scrollPaddingBlock:scroll-pb/scrollPaddingY,scrollPaddingBlockStart:scroll-pt,scrollPaddingBlockEnd:scroll-pb,scrollPaddingInline:scroll-px/scrollPaddingX,scrollPaddingInlineEnd:scroll-pe,scrollPaddingInlineStart:scroll-ps,scrollPaddingLeft:scroll-pl,scrollPaddingRight:scroll-pr,scrollPaddingTop:scroll-pt,scrollPaddingBottom:scroll-pb,scrollSnapAlign:snap-align,scrollSnapStop:snap-stop,scrollSnapType:snap-type,scrollSnapStrictness:snap-strictness,scrollSnapMargin:snap-m,scrollSnapMarginTop:snap-mt,scrollSnapMarginBottom:snap-mb,scrollSnapMarginLeft:snap-ml,scrollSnapMarginRight:snap-mr,touchAction:touch,userSelect:select,fill:fill,stroke:stroke,strokeWidth:stroke-w,srOnly:sr,debug:debug,appearance:appearance,backfaceVisibility:backface,clipPath:clip-path,hyphens:hyphens,mask:mask,maskImage:mask-image,maskSize:mask-size,textSizeAdjust:text-adjust,container:cq,containerName:cq-name,containerType:cq-type,boxSize:size,textStyle:textStyle"
5
+
6
+ const classNameByProp = new Map()
7
+ const shorthands = new Map()
8
+ utilities.split(',').forEach((utility) => {
9
+ const [prop, meta] = utility.split(':')
10
+ const [className, ...shorthandList] = meta.split('/')
11
+ classNameByProp.set(prop, className)
12
+ if (shorthandList.length) {
13
+ shorthandList.forEach((shorthand) => {
14
+ shorthands.set(shorthand === '1' ? className : shorthand, prop)
15
+ })
16
+ }
17
+ })
18
+
19
+ const resolveShorthand = (prop) => shorthands.get(prop) || prop
20
+
21
+ const context = {
22
+
23
+ conditions: {
24
+ shift: sortConditions,
25
+ finalize: finalizeConditions,
26
+ breakpoints: { keys: ["base","sm","md","lg","xl"] }
27
+ },
28
+ utility: {
29
+
30
+ transform: (prop, value) => {
31
+ const key = resolveShorthand(prop)
32
+ const propKey = classNameByProp.get(key) || hypenateProperty(key)
33
+ return { className: `${propKey}_${withoutSpace(value)}` }
34
+ },
35
+ hasShorthand: true,
36
+ toHash: (path, hashFn) => hashFn(path.join(":")),
37
+ resolveShorthand: resolveShorthand,
38
+ }
39
+ }
40
+
41
+ const cssFn = createCss(context)
42
+ export const css = (...styles) => cssFn(mergeCss(...styles))
43
+ css.raw = (...styles) => mergeCss(...styles)
44
+
45
+ export const { mergeCss, assignCss } = createMergeCss(context)
package/css/cva.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /* eslint-disable */
2
+ import type { RecipeCreatorFn } from '../types/recipe';
3
+
4
+ export declare const cva: RecipeCreatorFn
5
+
6
+ export type { RecipeVariant, RecipeVariantProps } from '../types/recipe';
package/css/cva.mjs ADDED
@@ -0,0 +1,87 @@
1
+ import { compact, mergeProps, memo, splitProps, uniq } from '../helpers.mjs';
2
+ import { css, mergeCss } from './css.mjs';
3
+
4
+ const defaults = (conf) => ({
5
+ base: {},
6
+ variants: {},
7
+ defaultVariants: {},
8
+ compoundVariants: [],
9
+ ...conf,
10
+ })
11
+
12
+ export function cva(config) {
13
+ const { base, variants, defaultVariants, compoundVariants } = defaults(config)
14
+ const getVariantProps = (variants) => ({ ...defaultVariants, ...compact(variants) })
15
+
16
+ function resolve(props = {}) {
17
+ const computedVariants = getVariantProps(props)
18
+ let variantCss = { ...base }
19
+ for (const [key, value] of Object.entries(computedVariants)) {
20
+ if (variants[key]?.[value]) {
21
+ variantCss = mergeCss(variantCss, variants[key][value])
22
+ }
23
+ }
24
+ const compoundVariantCss = getCompoundVariantCss(compoundVariants, computedVariants)
25
+ return mergeCss(variantCss, compoundVariantCss)
26
+ }
27
+
28
+ function merge(__cva) {
29
+ const override = defaults(__cva.config)
30
+ const variantKeys = uniq(__cva.variantKeys, Object.keys(variants))
31
+ return cva({
32
+ base: mergeCss(base, override.base),
33
+ variants: Object.fromEntries(
34
+ variantKeys.map((key) => [key, mergeCss(variants[key], override.variants[key])]),
35
+ ),
36
+ defaultVariants: mergeProps(defaultVariants, override.defaultVariants),
37
+ compoundVariants: [...compoundVariants, ...override.compoundVariants],
38
+ })
39
+ }
40
+
41
+ function cvaFn(props) {
42
+ return css(resolve(props))
43
+ }
44
+
45
+ const variantKeys = Object.keys(variants)
46
+
47
+ function splitVariantProps(props) {
48
+ return splitProps(props, variantKeys)
49
+ }
50
+
51
+ const variantMap = Object.fromEntries(Object.entries(variants).map(([key, value]) => [key, Object.keys(value)]))
52
+
53
+ return Object.assign(memo(cvaFn), {
54
+ __cva__: true,
55
+ variantMap,
56
+ variantKeys,
57
+ raw: resolve,
58
+ config,
59
+ merge,
60
+ splitVariantProps,
61
+ getVariantProps
62
+ })
63
+ }
64
+
65
+ export function getCompoundVariantCss(compoundVariants, variantMap) {
66
+ let result = {}
67
+ compoundVariants.forEach((compoundVariant) => {
68
+ const isMatching = Object.entries(compoundVariant).every(([key, value]) => {
69
+ if (key === 'css') return true
70
+
71
+ const values = Array.isArray(value) ? value : [value]
72
+ return values.some((value) => variantMap[key] === value)
73
+ })
74
+
75
+ if (isMatching) {
76
+ result = mergeCss(result, compoundVariant.css)
77
+ }
78
+ })
79
+
80
+ return result
81
+ }
82
+
83
+ export function assertCompoundVariant(name, compoundVariants, variants, prop) {
84
+ if (compoundVariants.length > 0 && typeof variants?.[prop] === 'object') {
85
+ throw new Error(`[recipe:${name}:${prop}] Conditions are not supported when using compound variants.`)
86
+ }
87
+ }
package/css/cx.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /* eslint-disable */
2
+ type Argument = string | boolean | null | undefined
3
+
4
+ /** Conditionally join classNames into a single string */
5
+ export declare function cx(...args: Argument[]): string
package/css/cx.mjs ADDED
@@ -0,0 +1,15 @@
1
+ function cx() {
2
+ let str = '',
3
+ i = 0,
4
+ arg
5
+
6
+ for (; i < arguments.length; ) {
7
+ if ((arg = arguments[i++]) && typeof arg === 'string') {
8
+ str && (str += ' ')
9
+ str += arg
10
+ }
11
+ }
12
+ return str
13
+ }
14
+
15
+ export { cx }
package/css/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /* eslint-disable */
2
+ export * from './css';
3
+ export * from './cx';
4
+ export * from './cva';
5
+ export * from './sva';
package/css/index.mjs ADDED
@@ -0,0 +1,4 @@
1
+ export * from './css.mjs';
2
+ export * from './cx.mjs';
3
+ export * from './cva.mjs';
4
+ export * from './sva.mjs';
package/css/sva.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /* eslint-disable */
2
+ import type { SlotRecipeCreatorFn } from '../types/recipe';
3
+
4
+ export declare const sva: SlotRecipeCreatorFn
package/css/sva.mjs ADDED
@@ -0,0 +1,41 @@
1
+ import { compact, getSlotRecipes, memo, splitProps } from '../helpers.mjs';
2
+ import { cva } from './cva.mjs';
3
+ import { cx } from './cx.mjs';
4
+
5
+ const slotClass = (className, slot) => className + '__' + slot
6
+
7
+ export function sva(config) {
8
+ const slots = Object.entries(getSlotRecipes(config)).map(([slot, slotCva]) => [slot, cva(slotCva)])
9
+ const defaultVariants = config.defaultVariants ?? {}
10
+
11
+ function svaFn(props) {
12
+ const result = slots.map(([slot, cvaFn]) => [slot, cx(cvaFn(props), config.className && slotClass(config.className, slot))])
13
+ return Object.fromEntries(result)
14
+ }
15
+
16
+ function raw(props) {
17
+ const result = slots.map(([slot, cvaFn]) => [slot, cvaFn.raw(props)])
18
+ return Object.fromEntries(result)
19
+ }
20
+
21
+ const variants = config.variants ?? {};
22
+ const variantKeys = Object.keys(variants);
23
+
24
+ function splitVariantProps(props) {
25
+ return splitProps(props, variantKeys);
26
+ }
27
+ const getVariantProps = (variants) => ({ ...(defaultVariants || {}), ...compact(variants) })
28
+
29
+ const variantMap = Object.fromEntries(
30
+ Object.entries(variants).map(([key, value]) => [key, Object.keys(value)])
31
+ );
32
+
33
+ return Object.assign(memo(svaFn), {
34
+ __cva__: false,
35
+ raw,
36
+ variantMap,
37
+ variantKeys,
38
+ splitVariantProps,
39
+ getVariantProps,
40
+ })
41
+ }
@@ -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
+ import { mergeCss } from '../css/css.mjs';
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
+ })
package/jsx/bleed.d.ts ADDED
@@ -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>
package/jsx/bleed.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import { createElement, forwardRef } from 'react'
2
+ import { mergeCss } from '../css/css.mjs';
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
+ })
package/jsx/box.d.ts ADDED
@@ -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>
package/jsx/box.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import { createElement, forwardRef } from 'react'
2
+ import { mergeCss } from '../css/css.mjs';
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>
package/jsx/center.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import { createElement, forwardRef } from 'react'
2
+ import { mergeCss } from '../css/css.mjs';
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>
package/jsx/circle.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import { createElement, forwardRef } from 'react'
2
+ import { mergeCss } from '../css/css.mjs';
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
+ import { mergeCss } from '../css/css.mjs';
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
+ })
package/jsx/cq.d.ts ADDED
@@ -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>
package/jsx/cq.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import { createElement, forwardRef } from 'react'
2
+ import { mergeCss } from '../css/css.mjs';
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
+ import { mergeCss } from '../css/css.mjs';
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,3 @@
1
+ /* eslint-disable */
2
+ import type { Styled } from '../types/jsx';
3
+ export declare const styled: Styled
@@ -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()
package/jsx/flex.d.ts ADDED
@@ -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>
package/jsx/flex.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import { createElement, forwardRef } from 'react'
2
+ import { mergeCss } from '../css/css.mjs';
3
+ import { splitProps } from '../helpers.mjs';
4
+ import { getFlexStyle } from '../patterns/flex.mjs';
5
+ import { styled } from './factory.mjs';
6
+
7
+ export const Flex = /* @__PURE__ */ forwardRef(function Flex(props, ref) {
8
+ const [patternProps, restProps] = splitProps(props, ["align","justify","direction","wrap","basis","grow","shrink"])
9
+
10
+ const styleProps = getFlexStyle(patternProps)
11
+ const mergedProps = { ref, ...styleProps, ...restProps }
12
+
13
+ return createElement(styled.div, mergedProps)
14
+ })
package/jsx/float.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+ import type { FunctionComponent } from 'react'
3
+ import type { FloatProperties } from '../patterns/float';
4
+ import type { HTMLStyledProps } from '../types/jsx';
5
+ import type { DistributiveOmit } from '../types/system-types';
6
+
7
+ export interface FloatProps extends FloatProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof FloatProperties > {}
8
+
9
+
10
+ export declare const Float: FunctionComponent<FloatProps>