@jongh/ui 1.6.5
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/.storybook/index.css +1 -0
- package/.storybook/main.ts +40 -0
- package/.storybook/preview.ts +16 -0
- package/.storybook/vitest.setup.ts +9 -0
- package/.turbo/turbo-build.log +79 -0
- package/CHANGELOG.md +54 -0
- package/chromatic.config.json +6 -0
- package/eslint.config.mjs +14 -0
- package/index.html +13 -0
- package/package.json +58 -0
- package/panda.config.ts +13 -0
- package/postcss.config.cjs +3 -0
- package/preset.ts +134 -0
- package/src/component/accordion/ui/index.tsx +80 -0
- package/src/component/accordion/ui/recipe.ts +65 -0
- package/src/component/avatar/ui/index.tsx +47 -0
- package/src/component/avatar/ui/recipe.ts +30 -0
- package/src/component/button/ui/index.tsx +29 -0
- package/src/component/button/ui/recipe.ts +102 -0
- package/src/component/chip/ui/index.tsx +30 -0
- package/src/component/chip/ui/recipe.ts +112 -0
- package/src/component/dialog/ui/index.tsx +73 -0
- package/src/component/dialog/ui/recipe.ts +92 -0
- package/src/component/select/ui/index.tsx +128 -0
- package/src/component/select/ui/recipe.ts +142 -0
- package/src/component/slider/ui/index.tsx +61 -0
- package/src/component/slider/ui/recipe.ts +52 -0
- package/src/component/tabs/ui/index.tsx +61 -0
- package/src/component/tabs/ui/recipe.ts +59 -0
- package/src/hooks/createContext.tsx +34 -0
- package/src/hooks/useComposedRefs.ts +20 -0
- package/src/hooks/useControllableState.ts +87 -0
- package/src/hooks/useKeyboardEvent.ts +58 -0
- package/src/stories/accordion.stories.tsx +63 -0
- package/src/stories/avatar.stories.tsx +33 -0
- package/src/stories/button.stories.tsx +53 -0
- package/src/stories/chip.stories.tsx +69 -0
- package/src/stories/dialog.stories.tsx +134 -0
- package/src/stories/select.stories.tsx +35 -0
- package/src/stories/slider.stories.tsx +31 -0
- package/src/stories/tabs.stories.tsx +63 -0
- package/src/test/accordion.test.tsx +66 -0
- package/src/test/tabs.test.tsx +30 -0
- package/src/types/index.ts +1 -0
- package/src/utils/createStyleContext.tsx +108 -0
- package/src/utils/defineSafe.ts +46 -0
- package/src/utils/getObjectKeys.ts +20 -0
- package/src/vite-env.d.ts +1 -0
- package/storybook-static/assets/Color-F6OSRLHC-CrKta8Qx.js +1 -0
- package/storybook-static/assets/DocsRenderer-CFRXHY34-Crd9Mepd.js +586 -0
- package/storybook-static/assets/_commonjsHelpers-Cpj98o6Y.js +1 -0
- package/storybook-static/assets/accordion.stories-0Om0AnMm.js +50 -0
- package/storybook-static/assets/avatar.stories-DMDsrSks.js +16 -0
- package/storybook-static/assets/axe-Dzet_oDA.js +30 -0
- package/storybook-static/assets/button.stories-CuVC-3x-.js +40 -0
- package/storybook-static/assets/chip.stories-FBIp8XNi.js +48 -0
- package/storybook-static/assets/chunk-XP5HYGXS-D5tuasO7.js +1 -0
- package/storybook-static/assets/createLucideIcon-DmXe7Z8R.js +21 -0
- package/storybook-static/assets/dialog.stories-3WsEvXt4.js +106 -0
- package/storybook-static/assets/entry-preview-Bkgdgq1b.js +10 -0
- package/storybook-static/assets/entry-preview-docs-zLz1Es7d.js +46 -0
- package/storybook-static/assets/iframe-LPPPXabV.js +199 -0
- package/storybook-static/assets/index-Bklpsb39.js +1 -0
- package/storybook-static/assets/index-BrlJLjep.js +24 -0
- package/storybook-static/assets/index-C2tRLqin.js +41 -0
- package/storybook-static/assets/index-CBft-ReK.js +8 -0
- package/storybook-static/assets/index-CSbWd7UJ.js +1 -0
- package/storybook-static/assets/index-ClcD9ViR.js +9 -0
- package/storybook-static/assets/index-Cu4lwwaE.js +1 -0
- package/storybook-static/assets/index-Cvkemp2J.js +1 -0
- package/storybook-static/assets/index-D59aU5s_.js +240 -0
- package/storybook-static/assets/index-DNo8LKN3.js +1 -0
- package/storybook-static/assets/index-DUy19JZU.js +1 -0
- package/storybook-static/assets/index-D_35mznO.js +1 -0
- package/storybook-static/assets/index-DrFu-skq.js +6 -0
- package/storybook-static/assets/index-DvbTp2M2.js +1 -0
- package/storybook-static/assets/index-rtmQni2k.js +1 -0
- package/storybook-static/assets/jsx-runtime-BYYWji4R.js +9 -0
- package/storybook-static/assets/matchers-57EZJSQE-oeXCqs4p.js +14 -0
- package/storybook-static/assets/preview-1l6V4UsQ.js +1 -0
- package/storybook-static/assets/preview-B3PTUHS7.js +1 -0
- package/storybook-static/assets/preview-BBWR9nbA.js +1 -0
- package/storybook-static/assets/preview-BCV5r-Ja.js +1 -0
- package/storybook-static/assets/preview-BWzBA1C2.js +396 -0
- package/storybook-static/assets/preview-Bb56VplF.js +2 -0
- package/storybook-static/assets/preview-Bl8rsKRy.js +1 -0
- package/storybook-static/assets/preview-Bm-a94Ct.js +2 -0
- package/storybook-static/assets/preview-Br-h4d84.js +1 -0
- package/storybook-static/assets/preview-D77C14du.js +34 -0
- package/storybook-static/assets/preview-DC8N7cZb.css +1 -0
- package/storybook-static/assets/preview-DGUiP6tS.js +7 -0
- package/storybook-static/assets/react-18-BPs3tMGP.js +1 -0
- package/storybook-static/assets/select.stories-AN8Hb81Z.js +20 -0
- package/storybook-static/assets/slider.stories-CxOczq0y.js +12 -0
- package/storybook-static/assets/tabs.stories-BbTU4QU3.js +28 -0
- package/storybook-static/favicon.svg +1 -0
- package/storybook-static/iframe.html +666 -0
- package/storybook-static/index.html +193 -0
- package/storybook-static/index.json +1 -0
- package/storybook-static/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/project.json +1 -0
- package/storybook-static/sb-addons/a11y-12/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/a11y-12/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js +331 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js.LEGAL.txt +51 -0
- package/storybook-static/sb-addons/controls-11/manager-bundle.js +391 -0
- package/storybook-static/sb-addons/controls-11/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-backgrounds-5/manager-bundle.js +12 -0
- package/storybook-static/sb-addons/essentials-backgrounds-5/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +391 -0
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-docs-4/manager-bundle.js +230 -0
- package/storybook-static/sb-addons/essentials-docs-4/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-measure-8/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-measure-8/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-outline-9/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-outline-9/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-toolbars-7/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-toolbars-7/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-viewport-6/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-viewport-6/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/links-1/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/links-1/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +3 -0
- package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/storybook-experimental-addon-test-13/manager-bundle.js +211 -0
- package/storybook-static/sb-addons/storybook-experimental-addon-test-13/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-common-assets/favicon.svg +1 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/sb-manager/globals-module-info.js +1037 -0
- package/storybook-static/sb-manager/globals-runtime.js +40857 -0
- package/storybook-static/sb-manager/globals.js +48 -0
- package/storybook-static/sb-manager/runtime.js +11963 -0
- package/styled-system/css/conditions.mjs +36 -0
- package/styled-system/css/css.d.ts +22 -0
- package/styled-system/css/css.mjs +45 -0
- package/styled-system/css/cva.d.ts +6 -0
- package/styled-system/css/cva.mjs +87 -0
- package/styled-system/css/cx.d.ts +5 -0
- package/styled-system/css/cx.mjs +15 -0
- package/styled-system/css/index.d.ts +5 -0
- package/styled-system/css/index.mjs +4 -0
- package/styled-system/css/sva.d.ts +4 -0
- package/styled-system/css/sva.mjs +41 -0
- package/styled-system/helpers.mjs +336 -0
- package/styled-system/jsx/aspect-ratio.d.ts +10 -0
- package/styled-system/jsx/aspect-ratio.mjs +14 -0
- package/styled-system/jsx/bleed.d.ts +10 -0
- package/styled-system/jsx/bleed.mjs +14 -0
- package/styled-system/jsx/box.d.ts +10 -0
- package/styled-system/jsx/box.mjs +14 -0
- package/styled-system/jsx/center.d.ts +10 -0
- package/styled-system/jsx/center.mjs +14 -0
- package/styled-system/jsx/circle.d.ts +10 -0
- package/styled-system/jsx/circle.mjs +14 -0
- package/styled-system/jsx/container.d.ts +10 -0
- package/styled-system/jsx/container.mjs +14 -0
- package/styled-system/jsx/cq.d.ts +10 -0
- package/styled-system/jsx/cq.mjs +14 -0
- package/styled-system/jsx/divider.d.ts +10 -0
- package/styled-system/jsx/divider.mjs +14 -0
- package/styled-system/jsx/factory-helper.mjs +22 -0
- package/styled-system/jsx/factory.d.ts +3 -0
- package/styled-system/jsx/factory.mjs +80 -0
- package/styled-system/jsx/flex.d.ts +10 -0
- package/styled-system/jsx/flex.mjs +14 -0
- package/styled-system/jsx/float.d.ts +10 -0
- package/styled-system/jsx/float.mjs +14 -0
- package/styled-system/jsx/grid-item.d.ts +10 -0
- package/styled-system/jsx/grid-item.mjs +14 -0
- package/styled-system/jsx/grid.d.ts +10 -0
- package/styled-system/jsx/grid.mjs +14 -0
- package/styled-system/jsx/hstack.d.ts +10 -0
- package/styled-system/jsx/hstack.mjs +14 -0
- package/styled-system/jsx/index.d.ts +24 -0
- package/styled-system/jsx/index.mjs +22 -0
- package/styled-system/jsx/is-valid-prop.d.ts +11 -0
- package/styled-system/jsx/is-valid-prop.mjs +17 -0
- package/styled-system/jsx/link-overlay.d.ts +10 -0
- package/styled-system/jsx/link-overlay.mjs +14 -0
- package/styled-system/jsx/spacer.d.ts +10 -0
- package/styled-system/jsx/spacer.mjs +14 -0
- package/styled-system/jsx/square.d.ts +10 -0
- package/styled-system/jsx/square.mjs +14 -0
- package/styled-system/jsx/stack.d.ts +10 -0
- package/styled-system/jsx/stack.mjs +14 -0
- package/styled-system/jsx/visually-hidden.d.ts +10 -0
- package/styled-system/jsx/visually-hidden.mjs +14 -0
- package/styled-system/jsx/vstack.d.ts +10 -0
- package/styled-system/jsx/vstack.mjs +14 -0
- package/styled-system/jsx/wrap.d.ts +10 -0
- package/styled-system/jsx/wrap.mjs +14 -0
- package/styled-system/patterns/aspect-ratio.d.ts +21 -0
- package/styled-system/patterns/aspect-ratio.mjs +38 -0
- package/styled-system/patterns/bleed.d.ts +22 -0
- package/styled-system/patterns/bleed.mjs +24 -0
- package/styled-system/patterns/box.d.ts +21 -0
- package/styled-system/patterns/box.mjs +15 -0
- package/styled-system/patterns/center.d.ts +21 -0
- package/styled-system/patterns/center.mjs +21 -0
- package/styled-system/patterns/circle.d.ts +21 -0
- package/styled-system/patterns/circle.mjs +25 -0
- package/styled-system/patterns/container.d.ts +21 -0
- package/styled-system/patterns/container.mjs +21 -0
- package/styled-system/patterns/cq.d.ts +22 -0
- package/styled-system/patterns/cq.mjs +21 -0
- package/styled-system/patterns/divider.d.ts +23 -0
- package/styled-system/patterns/divider.mjs +25 -0
- package/styled-system/patterns/flex.d.ts +27 -0
- package/styled-system/patterns/flex.mjs +26 -0
- package/styled-system/patterns/float.d.ts +24 -0
- package/styled-system/patterns/float.mjs +52 -0
- package/styled-system/patterns/grid-item.d.ts +26 -0
- package/styled-system/patterns/grid-item.mjs +25 -0
- package/styled-system/patterns/grid.d.ts +25 -0
- package/styled-system/patterns/grid.mjs +27 -0
- package/styled-system/patterns/hstack.d.ts +22 -0
- package/styled-system/patterns/hstack.mjs +24 -0
- package/styled-system/patterns/index.d.ts +21 -0
- package/styled-system/patterns/index.mjs +20 -0
- package/styled-system/patterns/link-overlay.d.ts +21 -0
- package/styled-system/patterns/link-overlay.mjs +24 -0
- package/styled-system/patterns/spacer.d.ts +21 -0
- package/styled-system/patterns/spacer.mjs +21 -0
- package/styled-system/patterns/square.d.ts +21 -0
- package/styled-system/patterns/square.mjs +24 -0
- package/styled-system/patterns/stack.d.ts +24 -0
- package/styled-system/patterns/stack.mjs +24 -0
- package/styled-system/patterns/visually-hidden.d.ts +21 -0
- package/styled-system/patterns/visually-hidden.mjs +18 -0
- package/styled-system/patterns/vstack.d.ts +22 -0
- package/styled-system/patterns/vstack.mjs +24 -0
- package/styled-system/patterns/wrap.d.ts +25 -0
- package/styled-system/patterns/wrap.mjs +25 -0
- package/styled-system/tokens/index.d.ts +9 -0
- package/styled-system/tokens/index.mjs +1992 -0
- package/styled-system/tokens/tokens.d.ts +60 -0
- package/styled-system/types/composition.d.ts +164 -0
- package/styled-system/types/conditions.d.ts +274 -0
- package/styled-system/types/csstype.d.ts +21298 -0
- package/styled-system/types/global.d.ts +20 -0
- package/styled-system/types/index.d.ts +8 -0
- package/styled-system/types/jsx.d.ts +52 -0
- package/styled-system/types/parts.d.ts +8 -0
- package/styled-system/types/pattern.d.ts +78 -0
- package/styled-system/types/prop-type.d.ts +235 -0
- package/styled-system/types/recipe.d.ts +181 -0
- package/styled-system/types/selectors.d.ts +59 -0
- package/styled-system/types/static-css.d.ts +56 -0
- package/styled-system/types/style-props.d.ts +7468 -0
- package/styled-system/types/system-types.d.ts +109 -0
- package/tsconfig.json +13 -0
- package/turbo/generators/config.cjs +7 -0
- package/turbo/generators/stories.cjs +23 -0
- package/turbo/generators/templates/stories.tsx.hbs +16 -0
- package/turbo/generators/templates/ui.tsx.hbs +8 -0
- package/turbo/generators/ui.cjs +19 -0
- package/vite.config.ts +7 -0
- package/vitest.config.ts +45 -0
|
@@ -0,0 +1,36 @@
|
|
|
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,sm,smOnly,smDown,md,mdOnly,mdDown,lg,lgOnly,lgDown,xl,xlOnly,xlDown,2xl,2xlOnly,2xlDown,smToMd,smToLg,smToXl,smTo2xl,mdToLg,mdToXl,mdTo2xl,lgToXl,lgTo2xl,xlTo2xl,@/xs,@/sm,@/md,@/lg,@/xl,@/2xl,@/3xl,@/4xl,@/5xl,@/6xl,@/7xl,@/8xl,base"
|
|
4
|
+
const conditions = new Set(conditionsStr.split(','))
|
|
5
|
+
|
|
6
|
+
const conditionRegex = /^@|&|&$/
|
|
7
|
+
|
|
8
|
+
export function isCondition(value){
|
|
9
|
+
return conditions.has(value) || conditionRegex.test(value)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const underscoreRegex = /^_/
|
|
13
|
+
const conditionsSelectorRegex = /&|@/
|
|
14
|
+
|
|
15
|
+
export function finalizeConditions(paths){
|
|
16
|
+
return paths.map((path) => {
|
|
17
|
+
if (conditions.has(path)){
|
|
18
|
+
return path.replace(underscoreRegex, '')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (conditionsSelectorRegex.test(path)){
|
|
22
|
+
return `[${withoutSpace(path.trim())}]`
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return path
|
|
26
|
+
})}
|
|
27
|
+
|
|
28
|
+
export function sortConditions(paths){
|
|
29
|
+
return paths.sort((a, b) => {
|
|
30
|
+
const aa = isCondition(a)
|
|
31
|
+
const bb = isCondition(b)
|
|
32
|
+
if (aa && !bb) return 1
|
|
33
|
+
if (!aa && bb) return -1
|
|
34
|
+
return 0
|
|
35
|
+
})
|
|
36
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { SystemStyleObject } from '../types/index';
|
|
3
|
+
|
|
4
|
+
type Styles = SystemStyleObject | undefined | null | false
|
|
5
|
+
|
|
6
|
+
interface CssRawFunction {
|
|
7
|
+
(styles: Styles): SystemStyleObject
|
|
8
|
+
(styles: Styles[]): SystemStyleObject
|
|
9
|
+
(...styles: Array<Styles | Styles[]>): SystemStyleObject
|
|
10
|
+
(styles: Styles): SystemStyleObject
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface CssFunction {
|
|
14
|
+
(styles: Styles): string
|
|
15
|
+
(styles: Styles[]): string
|
|
16
|
+
(...styles: Array<Styles | Styles[]>): string
|
|
17
|
+
(styles: Styles): string
|
|
18
|
+
|
|
19
|
+
raw: CssRawFunction
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export declare const css: CssFunction;
|
|
@@ -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:asp,boxDecorationBreak:bx-db,zIndex:z,boxSizing:bx-s,objectPosition:obj-p,objectFit:obj-f,overscrollBehavior:ovs-b,overscrollBehaviorX:ovs-bx,overscrollBehaviorY:ovs-by,position:pos/1,top:top,left:left,inset:inset,insetInline:inset-x/insetX,insetBlock:inset-y/insetY,insetBlockEnd:inset-be,insetBlockStart:inset-bs,insetInlineEnd:inset-e/insetEnd/end,insetInlineStart:inset-s/insetStart/start,right:right,bottom:bottom,float:float,visibility:vis,display:d,hideFrom:hide,hideBelow:show,flexBasis:flex-b,flex:flex,flexDirection:flex-d/flexDir,flexGrow:flex-g,flexShrink:flex-sh,gridTemplateColumns:grid-tc,gridTemplateRows:grid-tr,gridColumn:grid-c,gridRow:grid-r,gridColumnStart:grid-cs,gridColumnEnd:grid-ce,gridAutoFlow:grid-af,gridAutoColumns:grid-ac,gridAutoRows:grid-ar,gap:gap,gridGap:grid-g,gridRowGap:grid-rg,gridColumnGap:grid-cg,rowGap:rg,columnGap:cg,justifyContent:jc,alignContent:ac,alignItems:ai,alignSelf:as,padding:p/1,paddingLeft:pl/1,paddingRight:pr/1,paddingTop:pt/1,paddingBottom:pb/1,paddingBlock:py/1/paddingY,paddingBlockEnd:pbe,paddingBlockStart:pbs,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:mbe,marginBlockStart:mbs,marginInline:mx/1/marginX,marginInlineEnd:me/1/marginEnd,marginInlineStart:ms/1/marginStart,spaceX:sx,spaceY:sy,outlineWidth:ring-w/ringWidth,outlineColor:ring-c/ringColor,outline:ring/1,outlineOffset:ring-o/ringOffset,divideX:dvd-x,divideY:dvd-y,divideColor:dvd-c,divideStyle:dvd-s,width:w/1,inlineSize:w-is,minWidth:min-w/minW,minInlineSize:min-w-is,maxWidth:max-w/maxW,maxInlineSize:max-w-is,height:h/1,blockSize:h-bs,minHeight:min-h/minH,minBlockSize:min-h-bs,maxHeight:max-h/maxH,maxBlockSize:max-b,color:c,fontFamily:ff,fontSize:fs,fontSizeAdjust:fs-a,fontPalette:fp,fontKerning:fk,fontFeatureSettings:ff-s,fontWeight:fw,fontSmoothing:fsmt,fontVariant:fv,fontVariantAlternates:fv-alt,fontVariantCaps:fv-caps,fontVariationSettings:fv-s,fontVariantNumeric:fv-num,letterSpacing:ls,lineHeight:lh,textAlign:ta,textDecoration:td,textDecorationColor:td-c,textEmphasisColor:te-c,textDecorationStyle:td-s,textDecorationThickness:td-t,textUnderlineOffset:tu-o,textTransform:tt,textIndent:ti,textShadow:tsh,textShadowColor:tsh-c/textShadowColor,textOverflow:tov,verticalAlign:va,wordBreak:wb,textWrap:tw,truncate:trunc,lineClamp:lc,listStyleType:li-t,listStylePosition:li-pos,listStyleImage:li-img,listStyle:li-s,backgroundPosition:bg-p/bgPosition,backgroundPositionX:bg-p-x/bgPositionX,backgroundPositionY:bg-p-y/bgPositionY,backgroundAttachment:bg-a/bgAttachment,backgroundClip:bg-cp/bgClip,background:bg/1,backgroundColor:bg-c/bgColor,backgroundOrigin:bg-o/bgOrigin,backgroundImage:bg-i/bgImage,backgroundRepeat:bg-r/bgRepeat,backgroundBlendMode:bg-bm/bgBlendMode,backgroundSize:bg-s/bgSize,backgroundGradient:bg-grad/bgGradient,textGradient:txt-grad,gradientFromPosition:grad-from-pos,gradientToPosition:grad-to-pos,gradientFrom:grad-from,gradientTo:grad-to,gradientVia:grad-via,gradientViaPosition:grad-via-pos,borderRadius:bdr/rounded,borderTopLeftRadius:bdr-tl/roundedTopLeft,borderTopRightRadius:bdr-tr/roundedTopRight,borderBottomRightRadius:bdr-br/roundedBottomRight,borderBottomLeftRadius:bdr-bl/roundedBottomLeft,borderTopRadius:bdr-t/roundedTop,borderRightRadius:bdr-r/roundedRight,borderBottomRadius:bdr-b/roundedBottom,borderLeftRadius:bdr-l/roundedLeft,borderStartStartRadius:bdr-ss/roundedStartStart,borderStartEndRadius:bdr-se/roundedStartEnd,borderStartRadius:bdr-s/roundedStart,borderEndStartRadius:bdr-es/roundedEndStart,borderEndEndRadius:bdr-ee/roundedEndEnd,borderEndRadius:bdr-e/roundedEnd,border:bd,borderWidth:bd-w,borderTopWidth:bd-t-w,borderLeftWidth:bd-l-w,borderRightWidth:bd-r-w,borderBottomWidth:bd-b-w,borderColor:bd-c,borderInline:bd-x/borderX,borderInlineWidth:bd-x-w/borderXWidth,borderInlineColor:bd-x-c/borderXColor,borderBlock:bd-y/borderY,borderBlockWidth:bd-y-w/borderYWidth,borderBlockColor:bd-y-c/borderYColor,borderLeft:bd-l,borderLeftColor:bd-l-c,borderInlineStart:bd-s/borderStart,borderInlineStartWidth:bd-s-w/borderStartWidth,borderInlineStartColor:bd-s-c/borderStartColor,borderRight:bd-r,borderRightColor:bd-r-c,borderInlineEnd:bd-e/borderEnd,borderInlineEndWidth:bd-e-w/borderEndWidth,borderInlineEndColor:bd-e-c/borderEndColor,borderTop:bd-t,borderTopColor:bd-t-c,borderBottom:bd-b,borderBottomColor:bd-b-c,borderBlockEnd:bd-be,borderBlockEndColor:bd-be-c,borderBlockStart:bd-bs,borderBlockStartColor:bd-bs-c,opacity:op,boxShadow:bx-sh/shadow,boxShadowColor:bx-sh-c/shadowColor,mixBlendMode:mix-bm,filter:filter,brightness:brightness,contrast:contrast,grayscale:grayscale,hueRotate:hue-rotate,invert:invert,saturate:saturate,sepia:sepia,dropShadow:drop-shadow,blur:blur,backdropFilter:bkdp,backdropBlur:bkdp-blur,backdropBrightness:bkdp-brightness,backdropContrast:bkdp-contrast,backdropGrayscale:bkdp-grayscale,backdropHueRotate:bkdp-hue-rotate,backdropInvert:bkdp-invert,backdropOpacity:bkdp-opacity,backdropSaturate:bkdp-saturate,backdropSepia:bkdp-sepia,borderCollapse:bd-cl,borderSpacing:bd-sp,borderSpacingX:bd-sx,borderSpacingY:bd-sy,tableLayout:tbl,transitionTimingFunction:trs-tmf,transitionDelay:trs-dly,transitionDuration:trs-dur,transitionProperty:trs-prop,transition:trs,animation:anim,animationName:anim-n,animationTimingFunction:anim-tmf,animationDuration:anim-dur,animationDelay:anim-dly,animationPlayState:anim-ps,animationComposition:anim-comp,animationFillMode:anim-fm,animationDirection:anim-dir,animationIterationCount:anim-ic,animationRange:anim-r,animationState:anim-s,animationRangeStart:anim-rs,animationRangeEnd:anim-re,animationTimeline:anim-tl,transformOrigin:trf-o,transformBox:trf-b,transformStyle:trf-s,transform:trf,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:ac-c,caretColor:ca-c,scrollBehavior:scr-bhv,scrollbar:scr-bar,scrollbarColor:scr-bar-c,scrollbarGutter:scr-bar-g,scrollbarWidth:scr-bar-w,scrollMargin:scr-m,scrollMarginLeft:scr-ml,scrollMarginRight:scr-mr,scrollMarginTop:scr-mt,scrollMarginBottom:scr-mb,scrollMarginBlock:scr-my/scrollMarginY,scrollMarginBlockEnd:scr-mbe,scrollMarginBlockStart:scr-mbt,scrollMarginInline:scr-mx/scrollMarginX,scrollMarginInlineEnd:scr-me,scrollMarginInlineStart:scr-ms,scrollPadding:scr-p,scrollPaddingBlock:scr-py/scrollPaddingY,scrollPaddingBlockStart:scr-pbs,scrollPaddingBlockEnd:scr-pbe,scrollPaddingInline:scr-px/scrollPaddingX,scrollPaddingInlineEnd:scr-pe,scrollPaddingInlineStart:scr-ps,scrollPaddingLeft:scr-pl,scrollPaddingRight:scr-pr,scrollPaddingTop:scr-pt,scrollPaddingBottom:scr-pb,scrollSnapAlign:scr-sa,scrollSnapStop:scrs-s,scrollSnapType:scrs-t,scrollSnapStrictness:scrs-strt,scrollSnapMargin:scrs-m,scrollSnapMarginTop:scrs-mt,scrollSnapMarginBottom:scrs-mb,scrollSnapMarginLeft:scrs-ml,scrollSnapMarginRight:scrs-mr,scrollSnapCoordinate:scrs-c,scrollSnapDestination:scrs-d,scrollSnapPointsX:scrs-px,scrollSnapPointsY:scrs-py,scrollSnapTypeX:scrs-tx,scrollSnapTypeY:scrs-ty,scrollTimeline:scrtl,scrollTimelineAxis:scrtl-a,scrollTimelineName:scrtl-n,touchAction:tch-a,userSelect:us,overflow:ov,overflowWrap:ov-wrap,overflowX:ov-x,overflowY:ov-y,overflowAnchor:ov-a,overflowBlock:ov-b,overflowInline:ov-i,overflowClipBox:ovcp-bx,overflowClipMargin:ovcp-m,overscrollBehaviorBlock:ovs-bb,overscrollBehaviorInline:ovs-bi,fill:fill,stroke:stk,strokeWidth:stk-w,strokeDasharray:stk-dsh,strokeDashoffset:stk-do,strokeLinecap:stk-lc,strokeLinejoin:stk-lj,strokeMiterlimit:stk-ml,strokeOpacity:stk-op,srOnly:sr,debug:debug,appearance:ap,backfaceVisibility:bfv,clipPath:cp-path,hyphens:hy,mask:msk,maskImage:msk-i,maskSize:msk-s,textSizeAdjust:txt-adj,container:cq,containerName:cq-n,containerType:cq-t,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","2xl"] }
|
|
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)
|
|
@@ -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
|
+
}
|
|
@@ -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,336 @@
|
|
|
1
|
+
// src/assert.ts
|
|
2
|
+
function isObject(value) {
|
|
3
|
+
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
var isObjectOrArray = (obj) => typeof obj === "object" && obj !== null;
|
|
6
|
+
|
|
7
|
+
// src/compact.ts
|
|
8
|
+
function compact(value) {
|
|
9
|
+
return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// src/condition.ts
|
|
13
|
+
var isBaseCondition = (v) => v === "base";
|
|
14
|
+
function filterBaseConditions(c) {
|
|
15
|
+
return c.slice().filter((v) => !isBaseCondition(v));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/hash.ts
|
|
19
|
+
function toChar(code) {
|
|
20
|
+
return String.fromCharCode(code + (code > 25 ? 39 : 97));
|
|
21
|
+
}
|
|
22
|
+
function toName(code) {
|
|
23
|
+
let name = "";
|
|
24
|
+
let x;
|
|
25
|
+
for (x = Math.abs(code); x > 52; x = x / 52 | 0)
|
|
26
|
+
name = toChar(x % 52) + name;
|
|
27
|
+
return toChar(x % 52) + name;
|
|
28
|
+
}
|
|
29
|
+
function toPhash(h, x) {
|
|
30
|
+
let i = x.length;
|
|
31
|
+
while (i)
|
|
32
|
+
h = h * 33 ^ x.charCodeAt(--i);
|
|
33
|
+
return h;
|
|
34
|
+
}
|
|
35
|
+
function toHash(value) {
|
|
36
|
+
return toName(toPhash(5381, value) >>> 0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/important.ts
|
|
40
|
+
var importantRegex = /\s*!(important)?/i;
|
|
41
|
+
function isImportant(value) {
|
|
42
|
+
return typeof value === "string" ? importantRegex.test(value) : false;
|
|
43
|
+
}
|
|
44
|
+
function withoutImportant(value) {
|
|
45
|
+
return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;
|
|
46
|
+
}
|
|
47
|
+
function withoutSpace(str) {
|
|
48
|
+
return typeof str === "string" ? str.replaceAll(" ", "_") : str;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/memo.ts
|
|
52
|
+
var memo = (fn) => {
|
|
53
|
+
const cache = /* @__PURE__ */ new Map();
|
|
54
|
+
const get = (...args) => {
|
|
55
|
+
const key = JSON.stringify(args);
|
|
56
|
+
if (cache.has(key)) {
|
|
57
|
+
return cache.get(key);
|
|
58
|
+
}
|
|
59
|
+
const result = fn(...args);
|
|
60
|
+
cache.set(key, result);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
return get;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// src/merge-props.ts
|
|
67
|
+
function mergeProps(...sources) {
|
|
68
|
+
return sources.reduce((prev, obj) => {
|
|
69
|
+
if (!obj)
|
|
70
|
+
return prev;
|
|
71
|
+
Object.keys(obj).forEach((key) => {
|
|
72
|
+
const prevValue = prev[key];
|
|
73
|
+
const value = obj[key];
|
|
74
|
+
if (isObject(prevValue) && isObject(value)) {
|
|
75
|
+
prev[key] = mergeProps(prevValue, value);
|
|
76
|
+
} else {
|
|
77
|
+
prev[key] = value;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return prev;
|
|
81
|
+
}, {});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/walk-object.ts
|
|
85
|
+
var isNotNullish = (element) => element != null;
|
|
86
|
+
function walkObject(target, predicate, options = {}) {
|
|
87
|
+
const { stop, getKey } = options;
|
|
88
|
+
function inner(value, path = []) {
|
|
89
|
+
if (isObjectOrArray(value)) {
|
|
90
|
+
const result = {};
|
|
91
|
+
for (const [prop, child] of Object.entries(value)) {
|
|
92
|
+
const key = getKey?.(prop, child) ?? prop;
|
|
93
|
+
const childPath = [...path, key];
|
|
94
|
+
if (stop?.(value, childPath)) {
|
|
95
|
+
return predicate(value, path);
|
|
96
|
+
}
|
|
97
|
+
const next = inner(child, childPath);
|
|
98
|
+
if (isNotNullish(next)) {
|
|
99
|
+
result[key] = next;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
return predicate(value, path);
|
|
105
|
+
}
|
|
106
|
+
return inner(target);
|
|
107
|
+
}
|
|
108
|
+
function mapObject(obj, fn) {
|
|
109
|
+
if (Array.isArray(obj))
|
|
110
|
+
return obj.map((value) => fn(value));
|
|
111
|
+
if (!isObject(obj))
|
|
112
|
+
return fn(obj);
|
|
113
|
+
return walkObject(obj, (value) => fn(value));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/normalize-style-object.ts
|
|
117
|
+
function toResponsiveObject(values, breakpoints) {
|
|
118
|
+
return values.reduce(
|
|
119
|
+
(acc, current, index) => {
|
|
120
|
+
const key = breakpoints[index];
|
|
121
|
+
if (current != null) {
|
|
122
|
+
acc[key] = current;
|
|
123
|
+
}
|
|
124
|
+
return acc;
|
|
125
|
+
},
|
|
126
|
+
{}
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
function normalizeStyleObject(styles, context, shorthand = true) {
|
|
130
|
+
const { utility, conditions } = context;
|
|
131
|
+
const { hasShorthand, resolveShorthand } = utility;
|
|
132
|
+
return walkObject(
|
|
133
|
+
styles,
|
|
134
|
+
(value) => {
|
|
135
|
+
return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
stop: (value) => Array.isArray(value),
|
|
139
|
+
getKey: shorthand ? (prop) => hasShorthand ? resolveShorthand(prop) : prop : void 0
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/classname.ts
|
|
145
|
+
var fallbackCondition = {
|
|
146
|
+
shift: (v) => v,
|
|
147
|
+
finalize: (v) => v,
|
|
148
|
+
breakpoints: { keys: [] }
|
|
149
|
+
};
|
|
150
|
+
var sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\n\s]+/g, " ") : value;
|
|
151
|
+
function createCss(context) {
|
|
152
|
+
const { utility, hash, conditions: conds = fallbackCondition } = context;
|
|
153
|
+
const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");
|
|
154
|
+
const hashFn = (conditions, className) => {
|
|
155
|
+
let result;
|
|
156
|
+
if (hash) {
|
|
157
|
+
const baseArray = [...conds.finalize(conditions), className];
|
|
158
|
+
result = formatClassName(utility.toHash(baseArray, toHash));
|
|
159
|
+
} else {
|
|
160
|
+
const baseArray = [...conds.finalize(conditions), formatClassName(className)];
|
|
161
|
+
result = baseArray.join(":");
|
|
162
|
+
}
|
|
163
|
+
return result;
|
|
164
|
+
};
|
|
165
|
+
return memo(({ base, ...styles } = {}) => {
|
|
166
|
+
const styleObject = Object.assign(styles, base);
|
|
167
|
+
const normalizedObject = normalizeStyleObject(styleObject, context);
|
|
168
|
+
const classNames = /* @__PURE__ */ new Set();
|
|
169
|
+
walkObject(normalizedObject, (value, paths) => {
|
|
170
|
+
if (value == null)
|
|
171
|
+
return;
|
|
172
|
+
const important = isImportant(value);
|
|
173
|
+
const [prop, ...allConditions] = conds.shift(paths);
|
|
174
|
+
const conditions = filterBaseConditions(allConditions);
|
|
175
|
+
const transformed = utility.transform(prop, withoutImportant(sanitize(value)));
|
|
176
|
+
let className = hashFn(conditions, transformed.className);
|
|
177
|
+
if (important)
|
|
178
|
+
className = `${className}!`;
|
|
179
|
+
classNames.add(className);
|
|
180
|
+
});
|
|
181
|
+
return Array.from(classNames).join(" ");
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function compactStyles(...styles) {
|
|
185
|
+
return styles.flat().filter((style) => isObject(style) && Object.keys(compact(style)).length > 0);
|
|
186
|
+
}
|
|
187
|
+
function createMergeCss(context) {
|
|
188
|
+
function resolve(styles) {
|
|
189
|
+
const allStyles = compactStyles(...styles);
|
|
190
|
+
if (allStyles.length === 1)
|
|
191
|
+
return allStyles;
|
|
192
|
+
return allStyles.map((style) => normalizeStyleObject(style, context));
|
|
193
|
+
}
|
|
194
|
+
function mergeCss(...styles) {
|
|
195
|
+
return mergeProps(...resolve(styles));
|
|
196
|
+
}
|
|
197
|
+
function assignCss(...styles) {
|
|
198
|
+
return Object.assign({}, ...resolve(styles));
|
|
199
|
+
}
|
|
200
|
+
return { mergeCss: memo(mergeCss), assignCss };
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// src/hypenate-property.ts
|
|
204
|
+
var wordRegex = /([A-Z])/g;
|
|
205
|
+
var msRegex = /^ms-/;
|
|
206
|
+
var hypenateProperty = memo((property) => {
|
|
207
|
+
if (property.startsWith("--"))
|
|
208
|
+
return property;
|
|
209
|
+
return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// src/is-css-function.ts
|
|
213
|
+
var fns = ["min", "max", "clamp", "calc"];
|
|
214
|
+
var fnRegExp = new RegExp(`^(${fns.join("|")})\\(.*\\)`);
|
|
215
|
+
var isCssFunction = (v) => typeof v === "string" && fnRegExp.test(v);
|
|
216
|
+
|
|
217
|
+
// src/is-css-unit.ts
|
|
218
|
+
var lengthUnits = "cm,mm,Q,in,pc,pt,px,em,ex,ch,rem,lh,rlh,vw,vh,vmin,vmax,vb,vi,svw,svh,lvw,lvh,dvw,dvh,cqw,cqh,cqi,cqb,cqmin,cqmax,%";
|
|
219
|
+
var lengthUnitsPattern = `(?:${lengthUnits.split(",").join("|")})`;
|
|
220
|
+
var lengthRegExp = new RegExp(`^[+-]?[0-9]*.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`);
|
|
221
|
+
var isCssUnit = (v) => typeof v === "string" && lengthRegExp.test(v);
|
|
222
|
+
|
|
223
|
+
// src/is-css-var.ts
|
|
224
|
+
var isCssVar = (v) => typeof v === "string" && /^var\(--.+\)$/.test(v);
|
|
225
|
+
|
|
226
|
+
// src/pattern-fns.ts
|
|
227
|
+
var patternFns = {
|
|
228
|
+
map: mapObject,
|
|
229
|
+
isCssFunction,
|
|
230
|
+
isCssVar,
|
|
231
|
+
isCssUnit
|
|
232
|
+
};
|
|
233
|
+
var getPatternStyles = (pattern, styles) => {
|
|
234
|
+
if (!pattern?.defaultValues)
|
|
235
|
+
return styles;
|
|
236
|
+
const defaults = typeof pattern.defaultValues === "function" ? pattern.defaultValues(styles) : pattern.defaultValues;
|
|
237
|
+
return Object.assign({}, defaults, compact(styles));
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// src/slot.ts
|
|
241
|
+
var getSlotRecipes = (recipe = {}) => {
|
|
242
|
+
const init = (slot) => ({
|
|
243
|
+
className: [recipe.className, slot].filter(Boolean).join("__"),
|
|
244
|
+
base: recipe.base?.[slot] ?? {},
|
|
245
|
+
variants: {},
|
|
246
|
+
defaultVariants: recipe.defaultVariants ?? {},
|
|
247
|
+
compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []
|
|
248
|
+
});
|
|
249
|
+
const slots = recipe.slots ?? [];
|
|
250
|
+
const recipeParts = slots.map((slot) => [slot, init(slot)]);
|
|
251
|
+
for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) {
|
|
252
|
+
for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) {
|
|
253
|
+
recipeParts.forEach(([slot, slotRecipe]) => {
|
|
254
|
+
slotRecipe.variants[variantsKey] ??= {};
|
|
255
|
+
slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return Object.fromEntries(recipeParts);
|
|
260
|
+
};
|
|
261
|
+
var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
|
|
262
|
+
|
|
263
|
+
// src/split-props.ts
|
|
264
|
+
function splitProps(props, ...keys) {
|
|
265
|
+
const descriptors = Object.getOwnPropertyDescriptors(props);
|
|
266
|
+
const dKeys = Object.keys(descriptors);
|
|
267
|
+
const split = (k) => {
|
|
268
|
+
const clone = {};
|
|
269
|
+
for (let i = 0; i < k.length; i++) {
|
|
270
|
+
const key = k[i];
|
|
271
|
+
if (descriptors[key]) {
|
|
272
|
+
Object.defineProperty(clone, key, descriptors[key]);
|
|
273
|
+
delete descriptors[key];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return clone;
|
|
277
|
+
};
|
|
278
|
+
const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));
|
|
279
|
+
return keys.map(fn).concat(split(dKeys));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// src/uniq.ts
|
|
283
|
+
var uniq = (...items) => {
|
|
284
|
+
const set = items.reduce((acc, currItems) => {
|
|
285
|
+
if (currItems) {
|
|
286
|
+
currItems.forEach((item) => acc.add(item));
|
|
287
|
+
}
|
|
288
|
+
return acc;
|
|
289
|
+
}, /* @__PURE__ */ new Set([]));
|
|
290
|
+
return Array.from(set);
|
|
291
|
+
};
|
|
292
|
+
export {
|
|
293
|
+
compact,
|
|
294
|
+
createCss,
|
|
295
|
+
createMergeCss,
|
|
296
|
+
filterBaseConditions,
|
|
297
|
+
getPatternStyles,
|
|
298
|
+
getSlotCompoundVariant,
|
|
299
|
+
getSlotRecipes,
|
|
300
|
+
hypenateProperty,
|
|
301
|
+
isBaseCondition,
|
|
302
|
+
isObject,
|
|
303
|
+
mapObject,
|
|
304
|
+
memo,
|
|
305
|
+
mergeProps,
|
|
306
|
+
patternFns,
|
|
307
|
+
splitProps,
|
|
308
|
+
toHash,
|
|
309
|
+
uniq,
|
|
310
|
+
walkObject,
|
|
311
|
+
withoutSpace
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
// src/normalize-html.ts
|
|
317
|
+
var htmlProps = ["htmlSize", "htmlTranslate", "htmlWidth", "htmlHeight"];
|
|
318
|
+
function convert(key) {
|
|
319
|
+
return htmlProps.includes(key) ? key.replace("html", "").toLowerCase() : key;
|
|
320
|
+
}
|
|
321
|
+
function normalizeHTMLProps(props) {
|
|
322
|
+
return Object.fromEntries(Object.entries(props).map(([key, value]) => [convert(key), value]));
|
|
323
|
+
}
|
|
324
|
+
normalizeHTMLProps.keys = htmlProps;
|
|
325
|
+
export {
|
|
326
|
+
normalizeHTMLProps
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
export function __spreadValues(a, b) {
|
|
331
|
+
return { ...a, ...b }
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export function __objRest(source, exclude) {
|
|
335
|
+
return Object.fromEntries(Object.entries(source).filter(([key]) => !exclude.includes(key)))
|
|
336
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { FunctionComponent } from 'react'
|
|
3
|
+
import type { AspectRatioProperties } from '../patterns/aspect-ratio';
|
|
4
|
+
import type { HTMLStyledProps } from '../types/jsx';
|
|
5
|
+
import type { DistributiveOmit } from '../types/system-types';
|
|
6
|
+
|
|
7
|
+
export interface AspectRatioProps extends AspectRatioProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof AspectRatioProperties | 'aspectRatio'> {}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export declare const AspectRatio: FunctionComponent<AspectRatioProps>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { splitProps } from '../helpers.mjs';
|
|
4
|
+
import { getAspectRatioStyle } from '../patterns/aspect-ratio.mjs';
|
|
5
|
+
import { styled } from './factory.mjs';
|
|
6
|
+
|
|
7
|
+
export const AspectRatio = /* @__PURE__ */ forwardRef(function AspectRatio(props, ref) {
|
|
8
|
+
const [patternProps, restProps] = splitProps(props, ["ratio"])
|
|
9
|
+
|
|
10
|
+
const styleProps = getAspectRatioStyle(patternProps)
|
|
11
|
+
const mergedProps = { ref, ...styleProps, ...restProps }
|
|
12
|
+
|
|
13
|
+
return createElement(styled.div, mergedProps)
|
|
14
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { FunctionComponent } from 'react'
|
|
3
|
+
import type { BleedProperties } from '../patterns/bleed';
|
|
4
|
+
import type { HTMLStyledProps } from '../types/jsx';
|
|
5
|
+
import type { DistributiveOmit } from '../types/system-types';
|
|
6
|
+
|
|
7
|
+
export interface BleedProps extends BleedProperties, DistributiveOmit<HTMLStyledProps<'div'>, keyof BleedProperties > {}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export declare const Bleed: FunctionComponent<BleedProps>
|