@stokelp/styled-system 2.127.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/conditions.d.ts +7 -0
- package/css/conditions.js +32 -0
- package/css/css.d.ts +6 -6
- package/css/css.js +63 -0
- package/css/cva.d.ts +3 -4
- package/css/cva.js +51 -0
- package/css/cx.d.ts +5 -4
- package/css/{cx.mjs → cx.js} +5 -4
- package/css/first-that-works.d.ts +22 -0
- package/css/first-that-works.js +1 -0
- package/css/index.d.ts +8 -5
- package/css/index.js +8 -0
- package/css/keyframes.d.ts +5 -0
- package/css/keyframes.js +8 -0
- package/css/position-try.d.ts +5 -0
- package/css/position-try.js +11 -0
- package/css/sva.d.ts +2 -3
- package/css/sva.js +49 -0
- package/css/view-transition.d.ts +7 -0
- package/css/view-transition.js +18 -0
- package/dist/panda/buildinfo.json +20580 -0
- package/dist/panda/lib.json +15 -0
- package/dist/panda/preset.mjs +9505 -0
- package/helpers.d.ts +67 -0
- package/helpers.js +624 -0
- package/jsx/aspect-ratio.d.ts +5 -8
- package/jsx/aspect-ratio.js +11 -0
- package/jsx/bleed.d.ts +6 -9
- package/jsx/bleed.js +11 -0
- package/jsx/box.d.ts +6 -9
- package/jsx/box.js +11 -0
- package/jsx/center.d.ts +6 -9
- package/jsx/center.js +11 -0
- package/jsx/circle.d.ts +6 -9
- package/jsx/circle.js +11 -0
- package/jsx/container.d.ts +6 -9
- package/jsx/container.js +11 -0
- package/jsx/cq.d.ts +6 -9
- package/jsx/cq.js +11 -0
- package/jsx/create-recipe-context.d.ts +31 -0
- package/jsx/create-recipe-context.js +38 -0
- package/jsx/create-slot-recipe-context.d.ts +49 -0
- package/jsx/create-slot-recipe-context.js +124 -0
- package/jsx/divider.d.ts +6 -9
- package/jsx/divider.js +11 -0
- package/jsx/factory.d.ts +3 -3
- package/jsx/factory.js +91 -0
- package/jsx/flex.d.ts +6 -9
- package/jsx/flex.js +11 -0
- package/jsx/float.d.ts +6 -9
- package/jsx/float.js +11 -0
- package/jsx/grid-item.d.ts +6 -9
- package/jsx/grid-item.js +11 -0
- package/jsx/grid.d.ts +6 -9
- package/jsx/grid.js +11 -0
- package/jsx/helper.d.ts +34 -0
- package/jsx/helper.js +92 -0
- package/jsx/hstack.d.ts +6 -9
- package/jsx/hstack.js +11 -0
- package/jsx/index.d.ts +25 -25
- package/jsx/index.js +24 -0
- package/jsx/is-valid-prop.d.ts +5 -10
- package/jsx/is-valid-prop.js +12 -0
- package/jsx/link-overlay.d.ts +6 -9
- package/jsx/link-overlay.js +11 -0
- package/jsx/spacer.d.ts +6 -9
- package/jsx/spacer.js +11 -0
- package/jsx/square.d.ts +6 -9
- package/jsx/square.js +11 -0
- package/jsx/stack.d.ts +6 -9
- package/jsx/stack.js +11 -0
- package/jsx/visually-hidden.d.ts +6 -9
- package/jsx/visually-hidden.js +11 -0
- package/jsx/vstack.d.ts +6 -9
- package/jsx/vstack.js +11 -0
- package/jsx/wrap.d.ts +6 -9
- package/jsx/wrap.js +11 -0
- package/package.json +32 -18
- package/patterns/aspect-ratio.d.ts +8 -9
- package/patterns/aspect-ratio.js +37 -0
- package/patterns/bleed.d.ts +9 -10
- package/patterns/bleed.js +30 -0
- package/patterns/box.d.ts +8 -11
- package/patterns/box.js +16 -0
- package/patterns/center.d.ts +8 -9
- package/patterns/center.js +22 -0
- package/patterns/circle.d.ts +8 -9
- package/patterns/circle.js +26 -0
- package/patterns/container.d.ts +8 -11
- package/patterns/container.js +26 -0
- package/patterns/cq.d.ts +10 -10
- package/patterns/cq.js +24 -0
- package/patterns/divider.d.ts +11 -11
- package/patterns/divider.js +31 -0
- package/patterns/flex.d.ts +14 -15
- package/patterns/flex.js +27 -0
- package/patterns/float.d.ts +12 -12
- package/patterns/float.js +78 -0
- package/patterns/grid-item.d.ts +13 -14
- package/patterns/grid-item.js +26 -0
- package/patterns/grid.d.ts +13 -13
- package/patterns/grid.js +30 -0
- package/patterns/hstack.d.ts +9 -10
- package/patterns/hstack.js +27 -0
- package/patterns/index.d.ts +20 -21
- package/patterns/index.js +20 -0
- package/patterns/link-overlay.d.ts +8 -11
- package/patterns/link-overlay.js +25 -0
- package/patterns/runtime.js +25 -0
- package/patterns/spacer.d.ts +9 -9
- package/patterns/spacer.js +25 -0
- package/patterns/square.d.ts +8 -9
- package/patterns/square.js +25 -0
- package/patterns/stack.d.ts +11 -12
- package/patterns/stack.js +30 -0
- package/patterns/visually-hidden.d.ts +8 -11
- package/patterns/visually-hidden.js +19 -0
- package/patterns/vstack.d.ts +9 -10
- package/patterns/vstack.js +27 -0
- package/patterns/wrap.d.ts +12 -13
- package/patterns/wrap.js +26 -0
- package/recipes/accordion.d.ts +10 -26
- package/recipes/accordion.js +5 -0
- package/recipes/action-card.d.ts +9 -26
- package/recipes/action-card.js +5 -0
- package/recipes/alert.d.ts +10 -28
- package/recipes/alert.js +5 -0
- package/recipes/app-navigation-language-select.d.ts +12 -34
- package/recipes/app-navigation-language-select.js +5 -0
- package/recipes/app-navigation.d.ts +10 -28
- package/recipes/app-navigation.js +5 -0
- package/recipes/avatar-group.d.ts +8 -26
- package/recipes/avatar-group.js +5 -0
- package/recipes/avatar.d.ts +11 -30
- package/recipes/avatar.js +5 -0
- package/recipes/breadcrumb.d.ts +9 -24
- package/recipes/breadcrumb.js +5 -0
- package/recipes/button-filter.d.ts +8 -27
- package/recipes/button-filter.js +5 -0
- package/recipes/button.d.ts +10 -37
- package/recipes/button.js +5 -0
- package/recipes/chat-document-message.d.ts +8 -27
- package/recipes/chat-document-message.js +5 -0
- package/recipes/chat-message.d.ts +10 -33
- package/recipes/chat-message.js +5 -0
- package/recipes/chat-profile-avatar.d.ts +9 -29
- package/recipes/chat-profile-avatar.js +5 -0
- package/recipes/chat-text-input.d.ts +8 -27
- package/recipes/chat-text-input.js +5 -0
- package/recipes/chat.d.ts +9 -26
- package/recipes/chat.js +5 -0
- package/recipes/checkbox-card.d.ts +10 -26
- package/recipes/checkbox-card.js +5 -0
- package/recipes/checkbox-group.d.ts +7 -24
- package/recipes/checkbox-group.js +5 -0
- package/recipes/checkbox.d.ts +10 -26
- package/recipes/checkbox.js +5 -0
- package/recipes/chip.d.ts +11 -32
- package/recipes/chip.js +5 -0
- package/recipes/collapsible.d.ts +9 -24
- package/recipes/collapsible.js +5 -0
- package/recipes/combobox.d.ts +11 -27
- package/recipes/combobox.js +5 -0
- package/recipes/datepicker.d.ts +9 -24
- package/recipes/datepicker.js +5 -0
- package/recipes/dialog.d.ts +9 -24
- package/recipes/dialog.js +5 -0
- package/recipes/drawer.d.ts +10 -26
- package/recipes/drawer.js +5 -0
- package/recipes/flag.d.ts +8 -26
- package/recipes/flag.js +5 -0
- package/recipes/form-control.d.ts +8 -27
- package/recipes/form-control.js +5 -0
- package/recipes/form-helper-text.d.ts +8 -27
- package/recipes/form-helper-text.js +5 -0
- package/recipes/form-label.d.ts +10 -28
- package/recipes/form-label.js +5 -0
- package/recipes/heading.d.ts +10 -28
- package/recipes/heading.js +5 -0
- package/recipes/highlighted-input.d.ts +9 -26
- package/recipes/highlighted-input.js +5 -0
- package/recipes/icon-button.d.ts +10 -37
- package/recipes/icon-button.js +5 -0
- package/recipes/icon.d.ts +8 -26
- package/recipes/icon.js +5 -0
- package/recipes/illustration.d.ts +9 -29
- package/recipes/illustration.js +5 -0
- package/recipes/index.d.ts +62 -63
- package/recipes/index.js +62 -0
- package/recipes/input-addon.d.ts +8 -27
- package/recipes/input-addon.js +5 -0
- package/recipes/input-group.d.ts +8 -27
- package/recipes/input-group.js +5 -0
- package/recipes/input.d.ts +9 -29
- package/recipes/input.js +5 -0
- package/recipes/menu.d.ts +10 -26
- package/recipes/menu.js +5 -0
- package/recipes/mobile-navigation.d.ts +10 -28
- package/recipes/mobile-navigation.js +5 -0
- package/recipes/pagination.d.ts +9 -26
- package/recipes/pagination.js +5 -0
- package/recipes/phone-number-input.d.ts +9 -29
- package/recipes/phone-number-input.js +5 -0
- package/recipes/popover.d.ts +9 -24
- package/recipes/popover.js +5 -0
- package/recipes/price-tag.d.ts +10 -26
- package/recipes/price-tag.js +5 -0
- package/recipes/product-card-catalog.d.ts +9 -26
- package/recipes/product-card-catalog.js +5 -0
- package/recipes/radio-button-group.d.ts +10 -26
- package/recipes/radio-button-group.js +5 -0
- package/recipes/radio-card-group.d.ts +10 -26
- package/recipes/radio-card-group.js +5 -0
- package/recipes/radio-group.d.ts +10 -26
- package/recipes/radio-group.js +5 -0
- package/recipes/runtime.js +133 -0
- package/recipes/select-language.d.ts +10 -26
- package/recipes/select-language.js +5 -0
- package/recipes/select.d.ts +11 -27
- package/recipes/select.js +5 -0
- package/recipes/status-tag-select.d.ts +11 -30
- package/recipes/status-tag-select.js +5 -0
- package/recipes/steps.d.ts +9 -24
- package/recipes/steps.js +5 -0
- package/recipes/switch-card.d.ts +10 -26
- package/recipes/switch-card.js +5 -0
- package/recipes/switch-recipe.d.ts +10 -26
- package/recipes/switch-recipe.js +5 -0
- package/recipes/table-container.d.ts +7 -24
- package/recipes/table-container.js +5 -0
- package/recipes/table-empty-row.d.ts +7 -24
- package/recipes/table-empty-row.js +5 -0
- package/recipes/table-group-title.d.ts +8 -26
- package/recipes/table-group-title.js +5 -0
- package/recipes/table.d.ts +9 -24
- package/recipes/table.js +5 -0
- package/recipes/tabs-chip.d.ts +9 -29
- package/recipes/tabs-chip.js +5 -0
- package/recipes/tabs.d.ts +11 -30
- package/recipes/tabs.js +5 -0
- package/recipes/tag.d.ts +11 -32
- package/recipes/tag.js +5 -0
- package/recipes/text.d.ts +12 -30
- package/recipes/text.js +5 -0
- package/recipes/textarea.d.ts +7 -24
- package/recipes/textarea.js +5 -0
- package/recipes/tooltip.d.ts +9 -24
- package/recipes/tooltip.js +5 -0
- package/tokens/index.d.ts +4 -5
- package/tokens/index.js +18 -0
- package/types/index.d.ts +6 -8
- package/types/jsx.d.ts +37 -28
- package/types/pattern.d.ts +18 -70
- package/types/recipe.d.ts +58 -150
- package/types/register.d.ts +40 -0
- package/types/system.d.ts +1816 -0
- package/types/tokens.d.ts +72 -0
- package/css/conditions.mjs +0 -36
- package/css/css.mjs +0 -45
- package/css/cva.mjs +0 -87
- package/css/index.mjs +0 -4
- package/css/sva.mjs +0 -46
- package/helpers.mjs +0 -328
- package/jsx/aspect-ratio.mjs +0 -14
- package/jsx/bleed.mjs +0 -14
- package/jsx/box.mjs +0 -14
- package/jsx/center.mjs +0 -14
- package/jsx/circle.mjs +0 -14
- package/jsx/container.mjs +0 -14
- package/jsx/cq.mjs +0 -14
- package/jsx/create-style-context.d.ts +0 -54
- package/jsx/create-style-context.mjs +0 -118
- package/jsx/divider.mjs +0 -14
- package/jsx/factory-helper.mjs +0 -22
- package/jsx/factory.mjs +0 -89
- package/jsx/flex.mjs +0 -14
- package/jsx/float.mjs +0 -14
- package/jsx/grid-item.mjs +0 -14
- package/jsx/grid.mjs +0 -14
- package/jsx/hstack.mjs +0 -14
- package/jsx/index.mjs +0 -23
- package/jsx/is-valid-prop.mjs +0 -17
- package/jsx/link-overlay.mjs +0 -14
- package/jsx/spacer.mjs +0 -14
- package/jsx/square.mjs +0 -14
- package/jsx/stack.mjs +0 -14
- package/jsx/visually-hidden.mjs +0 -14
- package/jsx/vstack.mjs +0 -14
- package/jsx/wrap.mjs +0 -14
- package/panda.buildinfo.json +0 -471
- package/patterns/aspect-ratio.mjs +0 -38
- package/patterns/bleed.mjs +0 -24
- package/patterns/box.mjs +0 -15
- package/patterns/center.mjs +0 -21
- package/patterns/circle.mjs +0 -25
- package/patterns/container.mjs +0 -21
- package/patterns/cq.mjs +0 -21
- package/patterns/divider.mjs +0 -25
- package/patterns/flex.mjs +0 -26
- package/patterns/float.mjs +0 -52
- package/patterns/grid-item.mjs +0 -25
- package/patterns/grid.mjs +0 -27
- package/patterns/hstack.mjs +0 -24
- package/patterns/index.mjs +0 -20
- package/patterns/link-overlay.mjs +0 -24
- package/patterns/spacer.mjs +0 -25
- package/patterns/square.mjs +0 -24
- package/patterns/stack.mjs +0 -24
- package/patterns/visually-hidden.mjs +0 -18
- package/patterns/vstack.mjs +0 -24
- package/patterns/wrap.mjs +0 -25
- package/recipes/accordion.mjs +0 -57
- package/recipes/action-card.mjs +0 -45
- package/recipes/alert.mjs +0 -57
- package/recipes/app-navigation-language-select.mjs +0 -109
- package/recipes/app-navigation.mjs +0 -84
- package/recipes/avatar-group.mjs +0 -32
- package/recipes/avatar.mjs +0 -57
- package/recipes/breadcrumb.mjs +0 -45
- package/recipes/button-filter.mjs +0 -24
- package/recipes/button.mjs +0 -212
- package/recipes/chat-document-message.mjs +0 -24
- package/recipes/chat-message.mjs +0 -36
- package/recipes/chat-profile-avatar.mjs +0 -31
- package/recipes/chat-text-input.mjs +0 -24
- package/recipes/chat.mjs +0 -45
- package/recipes/checkbox-card.mjs +0 -73
- package/recipes/checkbox-group.mjs +0 -24
- package/recipes/checkbox.mjs +0 -57
- package/recipes/chip.mjs +0 -76
- package/recipes/collapsible.mjs +0 -45
- package/recipes/combobox.mjs +0 -101
- package/recipes/create-recipe.mjs +0 -82
- package/recipes/datepicker.mjs +0 -133
- package/recipes/dialog.mjs +0 -69
- package/recipes/drawer.mjs +0 -78
- package/recipes/flag.mjs +0 -33
- package/recipes/form-control.mjs +0 -24
- package/recipes/form-helper-text.mjs +0 -24
- package/recipes/form-label.mjs +0 -50
- package/recipes/heading.mjs +0 -41
- package/recipes/highlighted-input.mjs +0 -45
- package/recipes/icon-button.mjs +0 -233
- package/recipes/icon.mjs +0 -34
- package/recipes/illustration.mjs +0 -37
- package/recipes/index.mjs +0 -62
- package/recipes/input-addon.mjs +0 -24
- package/recipes/input-group.mjs +0 -24
- package/recipes/input.mjs +0 -30
- package/recipes/menu.mjs +0 -93
- package/recipes/mobile-navigation.mjs +0 -56
- package/recipes/pagination.mjs +0 -41
- package/recipes/phone-number-input.mjs +0 -30
- package/recipes/popover.mjs +0 -69
- package/recipes/price-tag.mjs +0 -51
- package/recipes/product-card-catalog.mjs +0 -73
- package/recipes/radio-button-group.mjs +0 -62
- package/recipes/radio-card-group.mjs +0 -77
- package/recipes/radio-group.mjs +0 -61
- package/recipes/select-language.mjs +0 -98
- package/recipes/select.mjs +0 -101
- package/recipes/status-tag-select.mjs +0 -108
- package/recipes/steps.mjs +0 -69
- package/recipes/switch-card.mjs +0 -69
- package/recipes/switch-recipe.mjs +0 -53
- package/recipes/table-container.mjs +0 -24
- package/recipes/table-empty-row.mjs +0 -24
- package/recipes/table-group-title.mjs +0 -32
- package/recipes/table.mjs +0 -61
- package/recipes/tabs-chip.mjs +0 -35
- package/recipes/tabs.mjs +0 -63
- package/recipes/tag.mjs +0 -61
- package/recipes/text.mjs +0 -41
- package/recipes/textarea.mjs +0 -24
- package/recipes/tooltip.mjs +0 -49
- package/tokens/index.mjs +0 -1728
- package/tokens/tokens.d.ts +0 -63
- package/types/composition.d.ts +0 -227
- package/types/conditions.d.ts +0 -300
- package/types/csstype.d.ts +0 -22570
- package/types/global.d.ts +0 -20
- package/types/parts.d.ts +0 -8
- package/types/prop-type.d.ts +0 -251
- package/types/selectors.d.ts +0 -59
- package/types/static-css.d.ts +0 -56
- package/types/style-props.d.ts +0 -8089
- package/types/system-types.d.ts +0 -151
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react';
|
|
2
|
+
import { aspectRatio } from '../patterns/aspect-ratio.js';
|
|
3
|
+
import { splitProps } from '../helpers.js';
|
|
4
|
+
import { styled } from './factory.js';
|
|
5
|
+
|
|
6
|
+
export const AspectRatio = /* @__PURE__ */ forwardRef(function AspectRatio(props, ref) {
|
|
7
|
+
const [patternProps, restProps] = splitProps(props, aspectRatio.propKeys)
|
|
8
|
+
const styleProps = aspectRatio.raw(patternProps)
|
|
9
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
10
|
+
return createElement(styled["div"], mergedProps)
|
|
11
|
+
})
|
package/jsx/bleed.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { DistributiveOmit } from '../types/system-types';
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { BleedProperties } from '../patterns/bleed.js';
|
|
3
|
+
import type { HTMLStyledProps } from '../types/jsx.js';
|
|
4
|
+
import type { DistributiveOmit } from '../types/system.js';
|
|
6
5
|
|
|
7
|
-
export interface BleedProps extends BleedProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof BleedProperties
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const Bleed: FunctionComponent<BleedProps>
|
|
6
|
+
export interface BleedProps extends BleedProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof BleedProperties> {}
|
|
7
|
+
export declare const Bleed: FunctionComponent<BleedProps>;
|
package/jsx/bleed.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react';
|
|
2
|
+
import { bleed } from '../patterns/bleed.js';
|
|
3
|
+
import { splitProps } from '../helpers.js';
|
|
4
|
+
import { styled } from './factory.js';
|
|
5
|
+
|
|
6
|
+
export const Bleed = /* @__PURE__ */ forwardRef(function Bleed(props, ref) {
|
|
7
|
+
const [patternProps, restProps] = splitProps(props, bleed.propKeys)
|
|
8
|
+
const styleProps = bleed.raw(patternProps)
|
|
9
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
10
|
+
return createElement(styled["div"], mergedProps)
|
|
11
|
+
})
|
package/jsx/box.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { DistributiveOmit } from '../types/system-types';
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { BoxProperties } from '../patterns/box.js';
|
|
3
|
+
import type { HTMLStyledProps } from '../types/jsx.js';
|
|
4
|
+
import type { DistributiveOmit } from '../types/system.js';
|
|
6
5
|
|
|
7
|
-
export interface BoxProps extends BoxProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof BoxProperties
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const Box: FunctionComponent<BoxProps>
|
|
6
|
+
export interface BoxProps extends BoxProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof BoxProperties> {}
|
|
7
|
+
export declare const Box: FunctionComponent<BoxProps>;
|
package/jsx/box.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react';
|
|
2
|
+
import { box } from '../patterns/box.js';
|
|
3
|
+
import { splitProps } from '../helpers.js';
|
|
4
|
+
import { styled } from './factory.js';
|
|
5
|
+
|
|
6
|
+
export const Box = /* @__PURE__ */ forwardRef(function Box(props, ref) {
|
|
7
|
+
const [patternProps, restProps] = splitProps(props, box.propKeys)
|
|
8
|
+
const styleProps = box.raw(patternProps)
|
|
9
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
10
|
+
return createElement(styled["div"], mergedProps)
|
|
11
|
+
})
|
package/jsx/center.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { DistributiveOmit } from '../types/system-types';
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { CenterProperties } from '../patterns/center.js';
|
|
3
|
+
import type { HTMLStyledProps } from '../types/jsx.js';
|
|
4
|
+
import type { DistributiveOmit } from '../types/system.js';
|
|
6
5
|
|
|
7
|
-
export interface CenterProps extends CenterProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof CenterProperties
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const Center: FunctionComponent<CenterProps>
|
|
6
|
+
export interface CenterProps extends CenterProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof CenterProperties> {}
|
|
7
|
+
export declare const Center: FunctionComponent<CenterProps>;
|
package/jsx/center.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react';
|
|
2
|
+
import { center } from '../patterns/center.js';
|
|
3
|
+
import { splitProps } from '../helpers.js';
|
|
4
|
+
import { styled } from './factory.js';
|
|
5
|
+
|
|
6
|
+
export const Center = /* @__PURE__ */ forwardRef(function Center(props, ref) {
|
|
7
|
+
const [patternProps, restProps] = splitProps(props, center.propKeys)
|
|
8
|
+
const styleProps = center.raw(patternProps)
|
|
9
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
10
|
+
return createElement(styled["div"], mergedProps)
|
|
11
|
+
})
|
package/jsx/circle.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { DistributiveOmit } from '../types/system-types';
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { CircleProperties } from '../patterns/circle.js';
|
|
3
|
+
import type { HTMLStyledProps } from '../types/jsx.js';
|
|
4
|
+
import type { DistributiveOmit } from '../types/system.js';
|
|
6
5
|
|
|
7
|
-
export interface CircleProps extends CircleProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof CircleProperties
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const Circle: FunctionComponent<CircleProps>
|
|
6
|
+
export interface CircleProps extends CircleProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof CircleProperties> {}
|
|
7
|
+
export declare const Circle: FunctionComponent<CircleProps>;
|
package/jsx/circle.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react';
|
|
2
|
+
import { circle } from '../patterns/circle.js';
|
|
3
|
+
import { splitProps } from '../helpers.js';
|
|
4
|
+
import { styled } from './factory.js';
|
|
5
|
+
|
|
6
|
+
export const Circle = /* @__PURE__ */ forwardRef(function Circle(props, ref) {
|
|
7
|
+
const [patternProps, restProps] = splitProps(props, circle.propKeys)
|
|
8
|
+
const styleProps = circle.raw(patternProps)
|
|
9
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
10
|
+
return createElement(styled["div"], mergedProps)
|
|
11
|
+
})
|
package/jsx/container.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { DistributiveOmit } from '../types/system-types';
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { ContainerProperties } from '../patterns/container.js';
|
|
3
|
+
import type { HTMLStyledProps } from '../types/jsx.js';
|
|
4
|
+
import type { DistributiveOmit } from '../types/system.js';
|
|
6
5
|
|
|
7
|
-
export interface ContainerProps extends ContainerProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof ContainerProperties
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const Container: FunctionComponent<ContainerProps>
|
|
6
|
+
export interface ContainerProps extends ContainerProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof ContainerProperties> {}
|
|
7
|
+
export declare const Container: FunctionComponent<ContainerProps>;
|
package/jsx/container.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react';
|
|
2
|
+
import { container } from '../patterns/container.js';
|
|
3
|
+
import { splitProps } from '../helpers.js';
|
|
4
|
+
import { styled } from './factory.js';
|
|
5
|
+
|
|
6
|
+
export const Container = /* @__PURE__ */ forwardRef(function Container(props, ref) {
|
|
7
|
+
const [patternProps, restProps] = splitProps(props, container.propKeys)
|
|
8
|
+
const styleProps = container.raw(patternProps)
|
|
9
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
10
|
+
return createElement(styled["div"], mergedProps)
|
|
11
|
+
})
|
package/jsx/cq.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { DistributiveOmit } from '../types/system-types';
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { CqProperties } from '../patterns/cq.js';
|
|
3
|
+
import type { HTMLStyledProps } from '../types/jsx.js';
|
|
4
|
+
import type { DistributiveOmit } from '../types/system.js';
|
|
6
5
|
|
|
7
|
-
export interface CqProps extends CqProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof CqProperties
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const Cq: FunctionComponent<CqProps>
|
|
6
|
+
export interface CqProps extends CqProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof CqProperties> {}
|
|
7
|
+
export declare const Cq: FunctionComponent<CqProps>;
|
package/jsx/cq.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react';
|
|
2
|
+
import { cq } from '../patterns/cq.js';
|
|
3
|
+
import { splitProps } from '../helpers.js';
|
|
4
|
+
import { styled } from './factory.js';
|
|
5
|
+
|
|
6
|
+
export const Cq = /* @__PURE__ */ forwardRef(function Cq(props, ref) {
|
|
7
|
+
const [patternProps, restProps] = splitProps(props, cq.propKeys)
|
|
8
|
+
const styleProps = cq.raw(patternProps)
|
|
9
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
10
|
+
return createElement(styled["div"], mergedProps)
|
|
11
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RecipeDefinition, RecipeRuntimeFn, RecipeSelection, RecipeVariantRecord } from '../types/recipe.js';
|
|
2
|
+
import type { Assign, JsxHTMLProps, JsxStyleProps } from '../types/system.js';
|
|
3
|
+
import type { AsProps, ComponentProps, DataAttrs, JsxFactoryOptions, UnstyledProps, WithForwardedProps } from '../types/jsx.js';
|
|
4
|
+
import type { ElementType, JSX, Provider } from 'react';
|
|
5
|
+
|
|
6
|
+
export type AnyRecipeDefinition = RecipeDefinition<RecipeVariantRecord>;
|
|
7
|
+
export interface RuntimeRecipeFn {
|
|
8
|
+
__type: unknown;
|
|
9
|
+
(props?: never): string;
|
|
10
|
+
}
|
|
11
|
+
export type RecipeContextRecipe = RecipeRuntimeFn<any, any, any> | RuntimeRecipeFn | AnyRecipeDefinition;
|
|
12
|
+
export type RecipePropsOf<R extends RecipeContextRecipe> = R extends RuntimeRecipeFn ? R['__type'] : R extends RecipeRuntimeFn<infer P, any, any> ? P : R extends RecipeDefinition<infer T> ? RecipeSelection<T> : never;
|
|
13
|
+
export type RecipeContextComponentProps<
|
|
14
|
+
T extends ElementType,
|
|
15
|
+
R extends RecipeContextRecipe,
|
|
16
|
+
F extends string
|
|
17
|
+
> = JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, WithForwardedProps<Assign<RecipePropsOf<R>, JsxStyleProps>, T, F>>;
|
|
18
|
+
export type RecipeContextComponent<
|
|
19
|
+
T extends ElementType,
|
|
20
|
+
R extends RecipeContextRecipe,
|
|
21
|
+
F extends string = never
|
|
22
|
+
> = (props: RecipeContextComponentProps<T, R, F>) => JSX.Element;
|
|
23
|
+
export interface RecipeContext<R extends RecipeContextRecipe> {
|
|
24
|
+
withContext: <
|
|
25
|
+
T extends ElementType,
|
|
26
|
+
F extends string = never
|
|
27
|
+
>(Component: T, options?: JsxFactoryOptions<ComponentProps<T>, F> | undefined) => RecipeContextComponent<T, R, F>;
|
|
28
|
+
PropsProvider: Provider<Partial<RecipePropsOf<R>> & DataAttrs>;
|
|
29
|
+
usePropsContext: () => RecipePropsOf<R> | undefined;
|
|
30
|
+
}
|
|
31
|
+
export declare function createRecipeContext<R extends RecipeContextRecipe>(recipeInput: R): RecipeContext<R>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, createElement, forwardRef } from 'react';
|
|
4
|
+
import { styled } from './factory.js';
|
|
5
|
+
import { getDisplayName, mergeDefaultProps } from './helper.js';
|
|
6
|
+
|
|
7
|
+
function resolveRecipe(recipe) {
|
|
8
|
+
if (recipe == null) throw new Error('createRecipeContext requires a recipe')
|
|
9
|
+
if (recipe.__recipe__ === true || recipe.__cva__ === true) return recipe
|
|
10
|
+
if (recipe.base || recipe.variants || recipe.defaultVariants || recipe.compoundVariants) return recipe
|
|
11
|
+
throw new Error('createRecipeContext requires a recipe')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function createRecipeContext(recipeInput) {
|
|
15
|
+
const recipe = resolveRecipe(recipeInput)
|
|
16
|
+
const PropsContext = createContext(undefined)
|
|
17
|
+
const usePropsContext = () => useContext(PropsContext)
|
|
18
|
+
|
|
19
|
+
const withContext = (Component, options) => {
|
|
20
|
+
const StyledComponent = styled(Component, recipe, options)
|
|
21
|
+
const componentName = getDisplayName(Component)
|
|
22
|
+
|
|
23
|
+
const WithContext = forwardRef(function WithContext(inProps, ref) {
|
|
24
|
+
const propsContext = usePropsContext()
|
|
25
|
+
const props = propsContext ? mergeDefaultProps(propsContext, inProps) : inProps
|
|
26
|
+
return createElement(StyledComponent, { ...props, ref })
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
WithContext.displayName = `withContext(${componentName})`
|
|
30
|
+
return WithContext
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
withContext,
|
|
35
|
+
PropsProvider: PropsContext.Provider,
|
|
36
|
+
usePropsContext,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { RecipeSelection, SlotRecipeDefinition, SlotRecipeRuntimeFn, SlotRecipeVariantRecord } from '../types/recipe.js';
|
|
2
|
+
import type { Assign, JsxHTMLProps, JsxStyleProps } from '../types/system.js';
|
|
3
|
+
import type { AsProps, ComponentProps, DataAttrs, JsxFactoryOptions, UnstyledProps, WithForwardedProps } from '../types/jsx.js';
|
|
4
|
+
import type { ElementType, JSX, Provider } from 'react';
|
|
5
|
+
|
|
6
|
+
export type AnySlotRecipeDefinition = SlotRecipeDefinition<string, SlotRecipeVariantRecord<string>>;
|
|
7
|
+
export interface RuntimeSlotRecipeFn {
|
|
8
|
+
__type: unknown;
|
|
9
|
+
__slot: string;
|
|
10
|
+
(props?: never): unknown;
|
|
11
|
+
}
|
|
12
|
+
export type SlotRecipeContextInput = SlotRecipeRuntimeFn<string, any, any, any> | RuntimeSlotRecipeFn | AnySlotRecipeDefinition;
|
|
13
|
+
export type SlotNameOf<R extends SlotRecipeContextInput> = R extends RuntimeSlotRecipeFn ? R['__slot'] : R extends SlotRecipeRuntimeFn<infer S, any, any, any> ? S : R extends SlotRecipeDefinition<infer S, any> ? S : string;
|
|
14
|
+
export type SlotRecipePropsOf<R extends SlotRecipeContextInput> = R extends RuntimeSlotRecipeFn ? R['__type'] : R extends SlotRecipeRuntimeFn<any, infer P, any, any> ? P : R extends SlotRecipeDefinition<any, infer T> ? RecipeSelection<T> : never;
|
|
15
|
+
export interface WithProviderOptions<P = {}> {
|
|
16
|
+
defaultProps?: (Partial<P> & DataAttrs) | undefined;
|
|
17
|
+
}
|
|
18
|
+
export type SlotRecipeProviderProps<
|
|
19
|
+
T extends ElementType,
|
|
20
|
+
R extends SlotRecipeContextInput,
|
|
21
|
+
F extends string
|
|
22
|
+
> = JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, WithForwardedProps<Assign<SlotRecipePropsOf<R>, JsxStyleProps>, T, F>>;
|
|
23
|
+
export type SlotRecipeProviderComponent<
|
|
24
|
+
T extends ElementType,
|
|
25
|
+
R extends SlotRecipeContextInput,
|
|
26
|
+
F extends string = never
|
|
27
|
+
> = (props: SlotRecipeProviderProps<T, R, F>) => JSX.Element;
|
|
28
|
+
export type SlotRecipeRootProviderComponent<
|
|
29
|
+
T extends ElementType,
|
|
30
|
+
R extends SlotRecipeContextInput
|
|
31
|
+
> = (props: ComponentProps<T> & UnstyledProps & SlotRecipePropsOf<R>) => JSX.Element;
|
|
32
|
+
export type SlotRecipeConsumerComponent<
|
|
33
|
+
T extends ElementType,
|
|
34
|
+
F extends string = never
|
|
35
|
+
> = (props: JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, WithForwardedProps<JsxStyleProps, T, F>>) => JSX.Element;
|
|
36
|
+
export interface SlotRecipeContext<R extends SlotRecipeContextInput> {
|
|
37
|
+
withRootProvider: <T extends ElementType>(Component: T, options?: WithProviderOptions<ComponentProps<T>> | undefined) => SlotRecipeRootProviderComponent<T, R>;
|
|
38
|
+
withProvider: <
|
|
39
|
+
T extends ElementType,
|
|
40
|
+
F extends string = never
|
|
41
|
+
>(Component: T, slot: SlotNameOf<R>, options?: JsxFactoryOptions<ComponentProps<T>, F> | undefined) => SlotRecipeProviderComponent<T, R, F>;
|
|
42
|
+
withContext: <
|
|
43
|
+
T extends ElementType,
|
|
44
|
+
F extends string = never
|
|
45
|
+
>(Component: T, slot: SlotNameOf<R>, options?: JsxFactoryOptions<ComponentProps<T>, F> | undefined) => SlotRecipeConsumerComponent<T, F>;
|
|
46
|
+
PropsProvider: Provider<Partial<SlotRecipePropsOf<R>> & DataAttrs>;
|
|
47
|
+
usePropsContext: () => SlotRecipePropsOf<R> | undefined;
|
|
48
|
+
}
|
|
49
|
+
export declare function createSlotRecipeContext<R extends SlotRecipeContextInput>(recipeInput: R): SlotRecipeContext<R>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, createElement, forwardRef } from 'react';
|
|
4
|
+
import { cx, sva } from '../css/index.js';
|
|
5
|
+
import { styled } from './factory.js';
|
|
6
|
+
import { getDisplayName, mergeDefaultProps } from './helper.js';
|
|
7
|
+
|
|
8
|
+
function createSafeContext(contextName) {
|
|
9
|
+
const Context = createContext(undefined)
|
|
10
|
+
const useStyleContext = (componentName, slot) => {
|
|
11
|
+
const context = useContext(Context)
|
|
12
|
+
if (context === undefined) {
|
|
13
|
+
const componentInfo = componentName ? `Component "${componentName}"` : 'A component'
|
|
14
|
+
const slotInfo = slot ? ` (slot: "${slot}")` : ''
|
|
15
|
+
throw new Error(`${componentInfo}${slotInfo} cannot access ${contextName} because it's missing its Provider.`)
|
|
16
|
+
}
|
|
17
|
+
return context
|
|
18
|
+
}
|
|
19
|
+
return [Context, useStyleContext]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function resolveSlotRecipe(recipe) {
|
|
23
|
+
if (recipe == null) throw new Error('createSlotRecipeContext requires a slot recipe')
|
|
24
|
+
if (typeof recipe.splitVariantProps === 'function') return recipe
|
|
25
|
+
if (recipe.slots) return recipe
|
|
26
|
+
throw new Error('createSlotRecipeContext requires a slot recipe')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function createSlotRecipeContext(recipeInput) {
|
|
30
|
+
const recipe = resolveSlotRecipe(recipeInput)
|
|
31
|
+
const isRuntimeRecipe = typeof recipe.splitVariantProps === 'function'
|
|
32
|
+
const isConfigRecipe = isRuntimeRecipe && recipe.__recipe__ !== undefined
|
|
33
|
+
const recipeName = isRuntimeRecipe && recipe.__name__ ? recipe.__name__ : undefined
|
|
34
|
+
const contextName = recipeName ? `createSlotRecipeContext("${recipeName}")` : 'createSlotRecipeContext'
|
|
35
|
+
const [SlotStylesContext, useSlotStylesContext] = createSafeContext(contextName)
|
|
36
|
+
const PropsContext = createContext(undefined)
|
|
37
|
+
const usePropsContext = () => useContext(PropsContext)
|
|
38
|
+
const withPropsContext = (props, propsContext) =>
|
|
39
|
+
propsContext ? mergeDefaultProps(propsContext, props) : props
|
|
40
|
+
const slotRecipeFn = isRuntimeRecipe ? recipe : sva(recipe.config ?? recipe)
|
|
41
|
+
|
|
42
|
+
const resolveProps = (props, slotStyles) => {
|
|
43
|
+
const { unstyled, ...restProps } = props
|
|
44
|
+
if (unstyled) return restProps
|
|
45
|
+
if (isConfigRecipe) return { ...restProps, className: cx(slotStyles, restProps.className) }
|
|
46
|
+
return { ...slotStyles, ...restProps }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const resolveSlots = (variantProps) => {
|
|
50
|
+
const styles = isConfigRecipe ? slotRecipeFn(variantProps) : slotRecipeFn.raw(variantProps)
|
|
51
|
+
if (!isConfigRecipe) styles._classNameMap = slotRecipeFn.classNameMap
|
|
52
|
+
return styles
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const withRootProvider = (Component, options) => {
|
|
56
|
+
const WithRootProvider = (inProps) => {
|
|
57
|
+
const props = withPropsContext(inProps, usePropsContext())
|
|
58
|
+
const [variantProps, otherProps] = slotRecipeFn.splitVariantProps(props)
|
|
59
|
+
const resolvedSlots = resolveSlots(variantProps)
|
|
60
|
+
const mergedProps = options?.defaultProps ? mergeDefaultProps(options.defaultProps, otherProps) : otherProps
|
|
61
|
+
return createElement(SlotStylesContext.Provider, {
|
|
62
|
+
value: resolvedSlots,
|
|
63
|
+
children: createElement(Component, mergedProps),
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
const componentName = getDisplayName(Component)
|
|
67
|
+
WithRootProvider.displayName = `withRootProvider(${componentName})`
|
|
68
|
+
return WithRootProvider
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const withProvider = (Component, slot, options) => {
|
|
72
|
+
const StyledComponent = styled(Component, {}, options)
|
|
73
|
+
const WithProvider = forwardRef(function WithProvider(inProps, ref) {
|
|
74
|
+
const props = withPropsContext(inProps, usePropsContext())
|
|
75
|
+
const [variantProps, restProps] = slotRecipeFn.splitVariantProps(props)
|
|
76
|
+
const resolvedSlots = resolveSlots(variantProps)
|
|
77
|
+
if (restProps.className == null && options?.defaultProps?.className) restProps.className = options.defaultProps.className
|
|
78
|
+
const resolvedProps = resolveProps(restProps, resolvedSlots[slot])
|
|
79
|
+
options?.forwardProps?.forEach((key) => {
|
|
80
|
+
if (key in variantProps) resolvedProps[key] = variantProps[key]
|
|
81
|
+
})
|
|
82
|
+
return createElement(SlotStylesContext.Provider, {
|
|
83
|
+
value: resolvedSlots,
|
|
84
|
+
children: createElement(StyledComponent, {
|
|
85
|
+
...resolvedProps,
|
|
86
|
+
className: cx(resolvedProps.className, resolvedSlots._classNameMap?.[slot]),
|
|
87
|
+
'data-slot': slot,
|
|
88
|
+
ref,
|
|
89
|
+
}),
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
const componentName = getDisplayName(Component)
|
|
93
|
+
WithProvider.displayName = `withProvider(${componentName})`
|
|
94
|
+
return WithProvider
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const withContext = (Component, slot, options) => {
|
|
98
|
+
const StyledComponent = styled(Component, {}, options)
|
|
99
|
+
const componentName = getDisplayName(Component)
|
|
100
|
+
const WithContext = forwardRef(function WithContext(props, ref) {
|
|
101
|
+
const resolvedSlots = useSlotStylesContext(componentName, slot)
|
|
102
|
+
const nextProps = props.className == null && options?.defaultProps?.className
|
|
103
|
+
? { ...props, className: options.defaultProps.className }
|
|
104
|
+
: props
|
|
105
|
+
const resolvedProps = resolveProps(nextProps, resolvedSlots[slot])
|
|
106
|
+
return createElement(StyledComponent, {
|
|
107
|
+
...resolvedProps,
|
|
108
|
+
className: cx(resolvedProps.className, resolvedSlots._classNameMap?.[slot]),
|
|
109
|
+
'data-slot': slot,
|
|
110
|
+
ref,
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
WithContext.displayName = `withContext(${componentName})`
|
|
114
|
+
return WithContext
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
withRootProvider,
|
|
119
|
+
withProvider,
|
|
120
|
+
withContext,
|
|
121
|
+
PropsProvider: PropsContext.Provider,
|
|
122
|
+
usePropsContext,
|
|
123
|
+
}
|
|
124
|
+
}
|
package/jsx/divider.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { DistributiveOmit } from '../types/system-types';
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { DividerProperties } from '../patterns/divider.js';
|
|
3
|
+
import type { HTMLStyledProps } from '../types/jsx.js';
|
|
4
|
+
import type { DistributiveOmit } from '../types/system.js';
|
|
6
5
|
|
|
7
|
-
export interface DividerProps extends DividerProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof DividerProperties
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const Divider: FunctionComponent<DividerProps>
|
|
6
|
+
export interface DividerProps extends DividerProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof DividerProperties> {}
|
|
7
|
+
export declare const Divider: FunctionComponent<DividerProps>;
|
package/jsx/divider.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react';
|
|
2
|
+
import { divider } from '../patterns/divider.js';
|
|
3
|
+
import { splitProps } from '../helpers.js';
|
|
4
|
+
import { styled } from './factory.js';
|
|
5
|
+
|
|
6
|
+
export const Divider = /* @__PURE__ */ forwardRef(function Divider(props, ref) {
|
|
7
|
+
const [patternProps, restProps] = splitProps(props, divider.propKeys)
|
|
8
|
+
const styleProps = divider.raw(patternProps)
|
|
9
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
10
|
+
return createElement(styled["div"], mergedProps)
|
|
11
|
+
})
|
package/jsx/factory.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const styled: Styled
|
|
1
|
+
import type { Styled } from '../types/jsx.js';
|
|
2
|
+
|
|
3
|
+
export declare const styled: Styled;
|
package/jsx/factory.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react';
|
|
2
|
+
import { cx, cva } from '../css/index.js';
|
|
3
|
+
import { composeCvaFn, composeShouldForwardProps, getDisplayName, serializeSplitStyles, mergeDefaultProps, splitJsxProps } from './helper.js';
|
|
4
|
+
import { isCssProperty } from './is-valid-prop.js';
|
|
5
|
+
|
|
6
|
+
function styledFn(BaseComponent, recipeOrConfig = {}, options = {}) {
|
|
7
|
+
const recipeFn = recipeOrConfig.__cva__ || recipeOrConfig.__recipe__ ? recipeOrConfig : cva(recipeOrConfig)
|
|
8
|
+
const composedRecipeFn = composeCvaFn(BaseComponent.__cva__, recipeFn)
|
|
9
|
+
const getRaw = composedRecipeFn.__memoizedRaw__ || composedRecipeFn.raw
|
|
10
|
+
const variantKeys = composedRecipeFn.variantKeys
|
|
11
|
+
const variantSet = new Set(variantKeys)
|
|
12
|
+
const forwardFn = options.shouldForwardProp || ((prop) => !variantSet.has(prop) && !isCssProperty(prop))
|
|
13
|
+
const forwardProps = options.forwardProps
|
|
14
|
+
const forwardPropSet = forwardProps?.length ? new Set(forwardProps) : void 0
|
|
15
|
+
const shouldForwardProp = forwardPropSet
|
|
16
|
+
? (prop) => forwardPropSet.has(prop) || forwardFn(prop, variantKeys)
|
|
17
|
+
: (prop) => forwardFn(prop, variantKeys)
|
|
18
|
+
|
|
19
|
+
const dataProps = options.dataAttr && recipeOrConfig.__name__ ? { 'data-recipe': recipeOrConfig.__name__ } : {}
|
|
20
|
+
const defaultProps = Object.assign(dataProps, options.defaultProps)
|
|
21
|
+
const hasDefaultProps = Object.keys(defaultProps).length > 0
|
|
22
|
+
|
|
23
|
+
const shouldForward = composeShouldForwardProps(BaseComponent, shouldForwardProp)
|
|
24
|
+
const DefaultElement = BaseComponent.__base__ || BaseComponent
|
|
25
|
+
|
|
26
|
+
const StyledComponent = /* @__PURE__ */ forwardRef(function StyledComponent(props, ref) {
|
|
27
|
+
const Element = props.as === void 0 ? DefaultElement : props.as
|
|
28
|
+
const unstyled = props.unstyled
|
|
29
|
+
const children = props.children
|
|
30
|
+
let combinedProps = props
|
|
31
|
+
if (hasDefaultProps) {
|
|
32
|
+
const { as, unstyled, children, ...restProps } = props
|
|
33
|
+
combinedProps = mergeDefaultProps(defaultProps, restProps)
|
|
34
|
+
}
|
|
35
|
+
const [htmlProps, forwardedProps, variantProps, propStyles, cssStyles, elementProps] = splitJsxProps(
|
|
36
|
+
combinedProps,
|
|
37
|
+
shouldForward,
|
|
38
|
+
variantSet,
|
|
39
|
+
isCssProperty,
|
|
40
|
+
)
|
|
41
|
+
const hasStyles = propStyles || cssStyles !== void 0
|
|
42
|
+
let className
|
|
43
|
+
if (unstyled) {
|
|
44
|
+
className = cx(hasStyles && serializeSplitStyles(propStyles, cssStyles), combinedProps.className)
|
|
45
|
+
} else if (recipeOrConfig.__recipe__) {
|
|
46
|
+
const compoundVariantClasses = composedRecipeFn.__getCompoundVariantClasses__?.(variantProps)
|
|
47
|
+
className = cx(
|
|
48
|
+
composedRecipeFn(variantProps, false),
|
|
49
|
+
compoundVariantClasses,
|
|
50
|
+
hasStyles && serializeSplitStyles(propStyles, cssStyles),
|
|
51
|
+
combinedProps.className,
|
|
52
|
+
)
|
|
53
|
+
} else {
|
|
54
|
+
className = cx(
|
|
55
|
+
hasStyles ? serializeSplitStyles(propStyles, cssStyles, getRaw(variantProps)) : composedRecipeFn(variantProps),
|
|
56
|
+
combinedProps.className,
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return createElement(Element, {
|
|
61
|
+
ref,
|
|
62
|
+
...forwardedProps,
|
|
63
|
+
...elementProps,
|
|
64
|
+
...htmlProps,
|
|
65
|
+
className,
|
|
66
|
+
}, children ?? combinedProps.children)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const name = getDisplayName(DefaultElement)
|
|
70
|
+
StyledComponent.displayName = `styled.${name}`
|
|
71
|
+
StyledComponent.__cva__ = composedRecipeFn
|
|
72
|
+
StyledComponent.__base__ = DefaultElement
|
|
73
|
+
StyledComponent.__shouldForwardProps__ = shouldForwardProp
|
|
74
|
+
|
|
75
|
+
return StyledComponent
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function createJsxFactory() {
|
|
79
|
+
const cache = new Map()
|
|
80
|
+
return new Proxy(styledFn, {
|
|
81
|
+
apply(_, __, args) {
|
|
82
|
+
return styledFn(...args)
|
|
83
|
+
},
|
|
84
|
+
get(_, el) {
|
|
85
|
+
if (!cache.has(el)) cache.set(el, styledFn(el))
|
|
86
|
+
return cache.get(el)
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const styled = /* @__PURE__ */ createJsxFactory()
|
package/jsx/flex.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { DistributiveOmit } from '../types/system-types';
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { FlexProperties } from '../patterns/flex.js';
|
|
3
|
+
import type { HTMLStyledProps } from '../types/jsx.js';
|
|
4
|
+
import type { DistributiveOmit } from '../types/system.js';
|
|
6
5
|
|
|
7
|
-
export interface FlexProps extends FlexProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof FlexProperties
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const Flex: FunctionComponent<FlexProps>
|
|
6
|
+
export interface FlexProps extends FlexProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof FlexProperties> {}
|
|
7
|
+
export declare const Flex: FunctionComponent<FlexProps>;
|
package/jsx/flex.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react';
|
|
2
|
+
import { flex } from '../patterns/flex.js';
|
|
3
|
+
import { splitProps } from '../helpers.js';
|
|
4
|
+
import { styled } from './factory.js';
|
|
5
|
+
|
|
6
|
+
export const Flex = /* @__PURE__ */ forwardRef(function Flex(props, ref) {
|
|
7
|
+
const [patternProps, restProps] = splitProps(props, flex.propKeys)
|
|
8
|
+
const styleProps = flex.raw(patternProps)
|
|
9
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
10
|
+
return createElement(styled["div"], mergedProps)
|
|
11
|
+
})
|
package/jsx/float.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { DistributiveOmit } from '../types/system-types';
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { FloatProperties } from '../patterns/float.js';
|
|
3
|
+
import type { HTMLStyledProps } from '../types/jsx.js';
|
|
4
|
+
import type { DistributiveOmit } from '../types/system.js';
|
|
6
5
|
|
|
7
|
-
export interface FloatProps extends FloatProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof FloatProperties
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const Float: FunctionComponent<FloatProps>
|
|
6
|
+
export interface FloatProps extends FloatProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof FloatProperties> {}
|
|
7
|
+
export declare const Float: FunctionComponent<FloatProps>;
|
package/jsx/float.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react';
|
|
2
|
+
import { float } from '../patterns/float.js';
|
|
3
|
+
import { splitProps } from '../helpers.js';
|
|
4
|
+
import { styled } from './factory.js';
|
|
5
|
+
|
|
6
|
+
export const Float = /* @__PURE__ */ forwardRef(function Float(props, ref) {
|
|
7
|
+
const [patternProps, restProps] = splitProps(props, float.propKeys)
|
|
8
|
+
const styleProps = float.raw(patternProps)
|
|
9
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
10
|
+
return createElement(styled["div"], mergedProps)
|
|
11
|
+
})
|