@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.
- package/css/conditions.mjs +34 -0
- package/css/css.d.ts +9 -0
- package/css/css.mjs +45 -0
- package/css/cva.d.ts +6 -0
- package/css/cva.mjs +87 -0
- package/css/cx.d.ts +5 -0
- package/css/cx.mjs +15 -0
- package/css/index.d.ts +5 -0
- package/css/index.mjs +4 -0
- package/css/sva.d.ts +4 -0
- package/css/sva.mjs +41 -0
- package/jsx/aspect-ratio.d.ts +10 -0
- package/jsx/aspect-ratio.mjs +14 -0
- package/jsx/bleed.d.ts +10 -0
- package/jsx/bleed.mjs +14 -0
- package/jsx/box.d.ts +10 -0
- package/jsx/box.mjs +14 -0
- package/jsx/center.d.ts +10 -0
- package/jsx/center.mjs +14 -0
- package/jsx/circle.d.ts +10 -0
- package/jsx/circle.mjs +14 -0
- package/jsx/container.d.ts +10 -0
- package/jsx/container.mjs +14 -0
- package/jsx/cq.d.ts +10 -0
- package/jsx/cq.mjs +14 -0
- package/jsx/divider.d.ts +10 -0
- package/jsx/divider.mjs +14 -0
- package/jsx/factory-helper.mjs +22 -0
- package/jsx/factory.d.ts +3 -0
- package/jsx/factory.mjs +80 -0
- package/jsx/flex.d.ts +10 -0
- package/jsx/flex.mjs +14 -0
- package/jsx/float.d.ts +10 -0
- package/jsx/float.mjs +14 -0
- package/jsx/grid-item.d.ts +10 -0
- package/jsx/grid-item.mjs +14 -0
- package/jsx/grid.d.ts +10 -0
- package/jsx/grid.mjs +14 -0
- package/jsx/hstack.d.ts +10 -0
- package/jsx/hstack.mjs +14 -0
- package/jsx/index.d.ts +25 -0
- package/jsx/index.mjs +23 -0
- package/jsx/is-valid-prop.d.ts +11 -0
- package/jsx/is-valid-prop.mjs +17 -0
- package/jsx/link-box.d.ts +10 -0
- package/jsx/link-box.mjs +14 -0
- package/jsx/link-overlay.d.ts +10 -0
- package/jsx/link-overlay.mjs +14 -0
- package/jsx/spacer.d.ts +10 -0
- package/jsx/spacer.mjs +14 -0
- package/jsx/square.d.ts +10 -0
- package/jsx/square.mjs +14 -0
- package/jsx/stack.d.ts +10 -0
- package/jsx/stack.mjs +14 -0
- package/jsx/visually-hidden.d.ts +10 -0
- package/jsx/visually-hidden.mjs +14 -0
- package/jsx/vstack.d.ts +10 -0
- package/jsx/vstack.mjs +14 -0
- package/jsx/wrap.d.ts +10 -0
- package/jsx/wrap.mjs +14 -0
- package/package.json +56 -0
- package/panda.buildinfo.json +75 -0
- package/patterns/aspect-ratio.d.ts +21 -0
- package/patterns/aspect-ratio.mjs +38 -0
- package/patterns/bleed.d.ts +22 -0
- package/patterns/bleed.mjs +24 -0
- package/patterns/box.d.ts +21 -0
- package/patterns/box.mjs +15 -0
- package/patterns/center.d.ts +21 -0
- package/patterns/center.mjs +21 -0
- package/patterns/circle.d.ts +21 -0
- package/patterns/circle.mjs +25 -0
- package/patterns/container.d.ts +21 -0
- package/patterns/container.mjs +21 -0
- package/patterns/cq.d.ts +22 -0
- package/patterns/cq.mjs +21 -0
- package/patterns/divider.d.ts +23 -0
- package/patterns/divider.mjs +25 -0
- package/patterns/flex.d.ts +27 -0
- package/patterns/flex.mjs +26 -0
- package/patterns/float.d.ts +24 -0
- package/patterns/float.mjs +52 -0
- package/patterns/grid-item.d.ts +26 -0
- package/patterns/grid-item.mjs +25 -0
- package/patterns/grid.d.ts +25 -0
- package/patterns/grid.mjs +27 -0
- package/patterns/hstack.d.ts +22 -0
- package/patterns/hstack.mjs +24 -0
- package/patterns/index.d.ts +22 -0
- package/patterns/index.mjs +21 -0
- package/patterns/link-box.d.ts +21 -0
- package/patterns/link-box.mjs +22 -0
- package/patterns/link-overlay.d.ts +21 -0
- package/patterns/link-overlay.mjs +27 -0
- package/patterns/spacer.d.ts +21 -0
- package/patterns/spacer.mjs +21 -0
- package/patterns/square.d.ts +21 -0
- package/patterns/square.mjs +24 -0
- package/patterns/stack.d.ts +24 -0
- package/patterns/stack.mjs +24 -0
- package/patterns/visually-hidden.d.ts +21 -0
- package/patterns/visually-hidden.mjs +18 -0
- package/patterns/vstack.d.ts +22 -0
- package/patterns/vstack.mjs +24 -0
- package/patterns/wrap.d.ts +25 -0
- package/patterns/wrap.mjs +25 -0
- package/recipes/accordion.d.ts +28 -0
- package/recipes/accordion.mjs +56 -0
- package/recipes/button.d.ts +30 -0
- package/recipes/button.mjs +116 -0
- package/recipes/checkbox.d.ts +28 -0
- package/recipes/checkbox.mjs +52 -0
- package/recipes/create-recipe.mjs +82 -0
- package/recipes/drawer.d.ts +28 -0
- package/recipes/drawer.mjs +77 -0
- package/recipes/form-control.d.ts +28 -0
- package/recipes/form-control.mjs +24 -0
- package/recipes/form-helper-text.d.ts +28 -0
- package/recipes/form-helper-text.mjs +24 -0
- package/recipes/form-label.d.ts +28 -0
- package/recipes/form-label.mjs +36 -0
- package/recipes/heading.d.ts +30 -0
- package/recipes/heading.mjs +41 -0
- package/recipes/index.d.ts +12 -0
- package/recipes/index.mjs +11 -0
- package/recipes/switch-recipe.d.ts +28 -0
- package/recipes/switch-recipe.mjs +52 -0
- package/recipes/text.d.ts +31 -0
- package/recipes/text.mjs +41 -0
- package/recipes/textarea.d.ts +28 -0
- package/recipes/textarea.mjs +24 -0
- package/tokens/index.d.ts +9 -0
- package/tokens/index.mjs +1496 -0
- package/tokens/tokens.d.ts +63 -0
- package/types/composition.d.ts +111 -0
- package/types/conditions.d.ts +270 -0
- package/types/csstype.d.ts +21298 -0
- package/types/global.d.ts +19 -0
- package/types/index.d.ts +8 -0
- package/types/jsx.d.ts +52 -0
- package/types/parts.d.ts +8 -0
- package/types/pattern.d.ts +74 -0
- package/types/prop-type.d.ts +242 -0
- package/types/recipe.d.ts +173 -0
- package/types/selectors.d.ts +59 -0
- package/types/static-css.d.ts +51 -0
- package/types/style-props.d.ts +7468 -0
- 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
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
package/css/cx.mjs
ADDED
package/css/index.d.ts
ADDED
package/css/index.mjs
ADDED
package/css/sva.d.ts
ADDED
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
|
+
})
|
package/jsx/center.d.ts
ADDED
|
@@ -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
|
+
})
|
package/jsx/circle.d.ts
ADDED
|
@@ -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
|
+
})
|
package/jsx/divider.d.ts
ADDED
|
@@ -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>
|
package/jsx/divider.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 { 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
|
+
}
|
package/jsx/factory.d.ts
ADDED
package/jsx/factory.mjs
ADDED
|
@@ -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>
|