@likec4/styles 1.27.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/LICENSE +21 -0
- package/README.md +46 -0
- package/build.config.ts +27 -0
- package/dev.ts +36 -0
- package/dist/css/conditions.mjs +36 -0
- package/dist/css/css.d.ts +22 -0
- package/dist/css/css.mjs +45 -0
- package/dist/css/cva.d.ts +6 -0
- package/dist/css/cva.mjs +87 -0
- package/dist/css/cx.d.ts +5 -0
- package/dist/css/cx.mjs +15 -0
- package/dist/css/index.d.ts +5 -0
- package/dist/css/index.mjs +4 -0
- package/dist/css/sva.d.ts +4 -0
- package/dist/css/sva.mjs +41 -0
- package/dist/helpers.mjs +336 -0
- package/dist/jsx/aspect-ratio.d.ts +10 -0
- package/dist/jsx/aspect-ratio.mjs +14 -0
- package/dist/jsx/bleed.d.ts +10 -0
- package/dist/jsx/bleed.mjs +14 -0
- package/dist/jsx/box.d.ts +10 -0
- package/dist/jsx/box.mjs +14 -0
- package/dist/jsx/center.d.ts +10 -0
- package/dist/jsx/center.mjs +14 -0
- package/dist/jsx/circle.d.ts +10 -0
- package/dist/jsx/circle.mjs +14 -0
- package/dist/jsx/container.d.ts +10 -0
- package/dist/jsx/container.mjs +14 -0
- package/dist/jsx/cq.d.ts +10 -0
- package/dist/jsx/cq.mjs +14 -0
- package/dist/jsx/divider.d.ts +10 -0
- package/dist/jsx/divider.mjs +14 -0
- package/dist/jsx/factory-helper.mjs +22 -0
- package/dist/jsx/factory.d.ts +3 -0
- package/dist/jsx/factory.mjs +80 -0
- package/dist/jsx/flex.d.ts +10 -0
- package/dist/jsx/flex.mjs +14 -0
- package/dist/jsx/float.d.ts +10 -0
- package/dist/jsx/float.mjs +14 -0
- package/dist/jsx/grid-item.d.ts +10 -0
- package/dist/jsx/grid-item.mjs +14 -0
- package/dist/jsx/grid.d.ts +10 -0
- package/dist/jsx/grid.mjs +14 -0
- package/dist/jsx/hstack.d.ts +10 -0
- package/dist/jsx/hstack.mjs +14 -0
- package/dist/jsx/index.d.ts +24 -0
- package/dist/jsx/index.mjs +22 -0
- package/dist/jsx/is-valid-prop.d.ts +11 -0
- package/dist/jsx/is-valid-prop.mjs +17 -0
- package/dist/jsx/link-overlay.d.ts +10 -0
- package/dist/jsx/link-overlay.mjs +14 -0
- package/dist/jsx/spacer.d.ts +10 -0
- package/dist/jsx/spacer.mjs +14 -0
- package/dist/jsx/square.d.ts +10 -0
- package/dist/jsx/square.mjs +14 -0
- package/dist/jsx/stack.d.ts +10 -0
- package/dist/jsx/stack.mjs +14 -0
- package/dist/jsx/visually-hidden.d.ts +10 -0
- package/dist/jsx/visually-hidden.mjs +14 -0
- package/dist/jsx/vstack.d.ts +10 -0
- package/dist/jsx/vstack.mjs +14 -0
- package/dist/jsx/wrap.d.ts +10 -0
- package/dist/jsx/wrap.mjs +14 -0
- package/dist/patterns/aspect-ratio.d.ts +21 -0
- package/dist/patterns/aspect-ratio.mjs +38 -0
- package/dist/patterns/bleed.d.ts +22 -0
- package/dist/patterns/bleed.mjs +24 -0
- package/dist/patterns/box.d.ts +21 -0
- package/dist/patterns/box.mjs +15 -0
- package/dist/patterns/center.d.ts +21 -0
- package/dist/patterns/center.mjs +21 -0
- package/dist/patterns/circle.d.ts +21 -0
- package/dist/patterns/circle.mjs +25 -0
- package/dist/patterns/container.d.ts +21 -0
- package/dist/patterns/container.mjs +21 -0
- package/dist/patterns/cq.d.ts +22 -0
- package/dist/patterns/cq.mjs +21 -0
- package/dist/patterns/divider.d.ts +23 -0
- package/dist/patterns/divider.mjs +25 -0
- package/dist/patterns/flex.d.ts +27 -0
- package/dist/patterns/flex.mjs +26 -0
- package/dist/patterns/float.d.ts +24 -0
- package/dist/patterns/float.mjs +52 -0
- package/dist/patterns/grid-item.d.ts +26 -0
- package/dist/patterns/grid-item.mjs +25 -0
- package/dist/patterns/grid.d.ts +25 -0
- package/dist/patterns/grid.mjs +27 -0
- package/dist/patterns/hstack.d.ts +22 -0
- package/dist/patterns/hstack.mjs +24 -0
- package/dist/patterns/index.d.ts +21 -0
- package/dist/patterns/index.mjs +20 -0
- package/dist/patterns/link-overlay.d.ts +21 -0
- package/dist/patterns/link-overlay.mjs +24 -0
- package/dist/patterns/spacer.d.ts +21 -0
- package/dist/patterns/spacer.mjs +21 -0
- package/dist/patterns/square.d.ts +21 -0
- package/dist/patterns/square.mjs +24 -0
- package/dist/patterns/stack.d.ts +24 -0
- package/dist/patterns/stack.mjs +24 -0
- package/dist/patterns/visually-hidden.d.ts +21 -0
- package/dist/patterns/visually-hidden.mjs +18 -0
- package/dist/patterns/vstack.d.ts +22 -0
- package/dist/patterns/vstack.mjs +24 -0
- package/dist/patterns/wrap.d.ts +25 -0
- package/dist/patterns/wrap.mjs +25 -0
- package/dist/recipes/action-btn.d.ts +43 -0
- package/dist/recipes/action-btn.mjs +41 -0
- package/dist/recipes/create-recipe.mjs +82 -0
- package/dist/recipes/index.d.ts +2 -0
- package/dist/recipes/index.mjs +1 -0
- package/dist/styles.css +1601 -0
- package/dist/tokens/index.d.ts +9 -0
- package/dist/tokens/index.mjs +5044 -0
- package/dist/tokens/tokens.d.ts +45 -0
- package/dist/types/composition.d.ts +164 -0
- package/dist/types/conditions.d.ts +328 -0
- package/dist/types/csstype.d.ts +21298 -0
- package/dist/types/global.d.ts +20 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/jsx.d.ts +52 -0
- package/dist/types/parts.d.ts +8 -0
- package/dist/types/pattern.d.ts +78 -0
- package/dist/types/prop-type.d.ts +232 -0
- package/dist/types/recipe.d.ts +181 -0
- package/dist/types/selectors.d.ts +59 -0
- package/dist/types/static-css.d.ts +56 -0
- package/dist/types/style-props.d.ts +7499 -0
- package/dist/types/system-types.d.ts +193 -0
- package/package.json +85 -0
- package/panda.config.ts +6 -0
- package/postcss.d.mts +6 -0
- package/postcss.mjs +2 -0
- package/preset.d.mts +2746 -0
- package/preset.mjs +2746 -0
- package/preset.ts +3 -0
- package/vite.d.mts +5 -0
- package/vite.mjs +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-2025 Denis Davydkov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# `@likec4/styles
|
|
2
|
+
|
|
3
|
+
Shared utilities for [PandaCSS](https://panda-css.com/)
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -D @likec4/style-preset @likec4/styles @pandacss/dev
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Configure your `panda.config.ts`:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { defineConfig } from '@pandacss/dev'
|
|
15
|
+
|
|
16
|
+
export default defineConfig({
|
|
17
|
+
// Whether to use css reset
|
|
18
|
+
importMap: '@likec4/styles',
|
|
19
|
+
presets: [
|
|
20
|
+
'@likec4/style-preset',
|
|
21
|
+
],
|
|
22
|
+
jsxFramework: 'react',
|
|
23
|
+
include: [
|
|
24
|
+
'./src/**/*.{js,jsx,ts,tsx}',
|
|
25
|
+
// TODO: will be replaced with ship info
|
|
26
|
+
'../diagram/src/**/*.{js,jsx,ts,tsx}',
|
|
27
|
+
],
|
|
28
|
+
})
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
TODO: configure PostCSS or use cli
|
|
32
|
+
|
|
33
|
+
Vite config:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import pandaCss from '@pandacss/dev/postcss'
|
|
37
|
+
|
|
38
|
+
//...
|
|
39
|
+
css: {
|
|
40
|
+
postcss: {
|
|
41
|
+
plugins: [
|
|
42
|
+
pandaCss(),
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
```
|
package/build.config.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import spawn from 'nano-spawn'
|
|
2
|
+
import { defineBuildConfig } from 'unbuild'
|
|
3
|
+
|
|
4
|
+
export default defineBuildConfig({
|
|
5
|
+
entries: [
|
|
6
|
+
'preset.ts',
|
|
7
|
+
],
|
|
8
|
+
outDir: '.',
|
|
9
|
+
clean: false,
|
|
10
|
+
stub: false,
|
|
11
|
+
declaration: 'node16',
|
|
12
|
+
failOnWarn: false,
|
|
13
|
+
alias: {
|
|
14
|
+
'@likec4/style-preset/src': '@likec4/style-preset',
|
|
15
|
+
},
|
|
16
|
+
rollup: {
|
|
17
|
+
inlineDependencies: true,
|
|
18
|
+
resolve: {
|
|
19
|
+
exportConditions: ['sources'],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
hooks: {
|
|
23
|
+
async 'build:before'(ctx) {
|
|
24
|
+
await spawn('pnpm', ['generate'])
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
})
|
package/dev.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import likec4preset from '@likec4/style-preset/src'
|
|
2
|
+
import {
|
|
3
|
+
pluginRemoveNegativeSpacing,
|
|
4
|
+
pluginStrictTokensScope,
|
|
5
|
+
} from '@pandabox/panda-plugins'
|
|
6
|
+
import { type Config, defineConfig as pandaDefineConfig } from '@pandacss/dev'
|
|
7
|
+
|
|
8
|
+
export function defineConfig(config: Config) {
|
|
9
|
+
return pandaDefineConfig({
|
|
10
|
+
// Whether to use css reset
|
|
11
|
+
importMap: {
|
|
12
|
+
css: '@likec4/styles/css',
|
|
13
|
+
recipes: '@likec4/styles/recipes',
|
|
14
|
+
patterns: '@likec4/styles/patterns',
|
|
15
|
+
jsx: '@likec4/styles/jsx',
|
|
16
|
+
},
|
|
17
|
+
presets: [
|
|
18
|
+
likec4preset,
|
|
19
|
+
],
|
|
20
|
+
// hash: isProduction,
|
|
21
|
+
// globalVars: {},
|
|
22
|
+
// hash: true,
|
|
23
|
+
strictTokens: true,
|
|
24
|
+
jsxFramework: 'react',
|
|
25
|
+
logLevel: 'info',
|
|
26
|
+
plugins: [
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
// pluginRemoveUnusedCss(),
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
pluginStrictTokensScope({ categories: ['fonts', 'colors', 'animations', 'easings'] }),
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
pluginRemoveNegativeSpacing({ spacingTokenType: true, tokenType: true }),
|
|
33
|
+
],
|
|
34
|
+
...config,
|
|
35
|
+
})
|
|
36
|
+
}
|
|
@@ -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,_complete,_incomplete,_dragging,_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,_grabbed,_underValue,_overValue,_atValue,_default,_optional,_open,_closed,_fullscreen,_loading,_hidden,_current,_currentPage,_currentStep,_today,_unavailable,_rangeStart,_rangeEnd,_now,_topmost,_motionReduce,_motionSafe,_print,_landscape,_portrait,_dark,_light,_osDark,_osLight,_highContrast,_lessContrast,_moreContrast,_ltr,_rtl,_scrollbar,_scrollbarThumb,_scrollbarTrack,_horizontal,_vertical,_icon,_starting,_reduceGraphics,_reduceGraphicsOnPan,_noReduceGraphics,_whenPanning,_smallZoom,_compoundTransparent,_edgeActive,_whenHovered,_whenSelected,_whenDimmed,_whenFocused,_shapeSizeXs,_shapeSizeSm,_shapeSizeMd,_shapeSizeLg,_shapeSizeXl,_shapeRectangle,_shapePerson,_shapeBrowser,_shapeMobile,_shapeCylinder,_shapeStorage,_shapeQueue,xs,xsOnly,xsDown,sm,smOnly,smDown,md,mdOnly,mdDown,lg,lgOnly,lgDown,xl,xlOnly,xlDown,xsToSm,xsToMd,xsToLg,xsToXl,smToMd,smToLg,smToXl,mdToLg,mdToXl,lgToXl,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;
|
package/dist/css/css.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createCss, createMergeCss, hypenateProperty, withoutSpace } from '../helpers.mjs';
|
|
2
|
+
import { sortConditions, finalizeConditions } from './conditions.mjs';
|
|
3
|
+
|
|
4
|
+
const utilities = "aspectRatio: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:transition-fast,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,cursor:cursor,likec4Palette:likec4-palette,likec4RelationPalette:likec4-relation-color,textStyle:textStyle,animationStyle:animationStyle"
|
|
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","xs","sm","md","lg","xl"] }
|
|
27
|
+
},
|
|
28
|
+
utility: {
|
|
29
|
+
|
|
30
|
+
transform: (prop, value) => {
|
|
31
|
+
const key = resolveShorthand(prop)
|
|
32
|
+
const propKey = classNameByProp.get(key) || hypenateProperty(key)
|
|
33
|
+
return { className: `${propKey}_${withoutSpace(value)}` }
|
|
34
|
+
},
|
|
35
|
+
hasShorthand: true,
|
|
36
|
+
toHash: (path, hashFn) => hashFn(path.join(":")),
|
|
37
|
+
resolveShorthand: resolveShorthand,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const cssFn = createCss(context)
|
|
42
|
+
export const css = (...styles) => cssFn(mergeCss(...styles))
|
|
43
|
+
css.raw = (...styles) => mergeCss(...styles)
|
|
44
|
+
|
|
45
|
+
export const { mergeCss, assignCss } = createMergeCss(context)
|
package/dist/css/cva.mjs
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { compact, mergeProps, memo, splitProps, uniq } from '../helpers.mjs';
|
|
2
|
+
import { css, mergeCss } from './css.mjs';
|
|
3
|
+
|
|
4
|
+
const defaults = (conf) => ({
|
|
5
|
+
base: {},
|
|
6
|
+
variants: {},
|
|
7
|
+
defaultVariants: {},
|
|
8
|
+
compoundVariants: [],
|
|
9
|
+
...conf,
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
export function cva(config) {
|
|
13
|
+
const { base, variants, defaultVariants, compoundVariants } = defaults(config)
|
|
14
|
+
const getVariantProps = (variants) => ({ ...defaultVariants, ...compact(variants) })
|
|
15
|
+
|
|
16
|
+
function resolve(props = {}) {
|
|
17
|
+
const computedVariants = getVariantProps(props)
|
|
18
|
+
let variantCss = { ...base }
|
|
19
|
+
for (const [key, value] of Object.entries(computedVariants)) {
|
|
20
|
+
if (variants[key]?.[value]) {
|
|
21
|
+
variantCss = mergeCss(variantCss, variants[key][value])
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const compoundVariantCss = getCompoundVariantCss(compoundVariants, computedVariants)
|
|
25
|
+
return mergeCss(variantCss, compoundVariantCss)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function merge(__cva) {
|
|
29
|
+
const override = defaults(__cva.config)
|
|
30
|
+
const variantKeys = uniq(__cva.variantKeys, Object.keys(variants))
|
|
31
|
+
return cva({
|
|
32
|
+
base: mergeCss(base, override.base),
|
|
33
|
+
variants: Object.fromEntries(
|
|
34
|
+
variantKeys.map((key) => [key, mergeCss(variants[key], override.variants[key])]),
|
|
35
|
+
),
|
|
36
|
+
defaultVariants: mergeProps(defaultVariants, override.defaultVariants),
|
|
37
|
+
compoundVariants: [...compoundVariants, ...override.compoundVariants],
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function cvaFn(props) {
|
|
42
|
+
return css(resolve(props))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const variantKeys = Object.keys(variants)
|
|
46
|
+
|
|
47
|
+
function splitVariantProps(props) {
|
|
48
|
+
return splitProps(props, variantKeys)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const variantMap = Object.fromEntries(Object.entries(variants).map(([key, value]) => [key, Object.keys(value)]))
|
|
52
|
+
|
|
53
|
+
return Object.assign(memo(cvaFn), {
|
|
54
|
+
__cva__: true,
|
|
55
|
+
variantMap,
|
|
56
|
+
variantKeys,
|
|
57
|
+
raw: resolve,
|
|
58
|
+
config,
|
|
59
|
+
merge,
|
|
60
|
+
splitVariantProps,
|
|
61
|
+
getVariantProps
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function getCompoundVariantCss(compoundVariants, variantMap) {
|
|
66
|
+
let result = {}
|
|
67
|
+
compoundVariants.forEach((compoundVariant) => {
|
|
68
|
+
const isMatching = Object.entries(compoundVariant).every(([key, value]) => {
|
|
69
|
+
if (key === 'css') return true
|
|
70
|
+
|
|
71
|
+
const values = Array.isArray(value) ? value : [value]
|
|
72
|
+
return values.some((value) => variantMap[key] === value)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
if (isMatching) {
|
|
76
|
+
result = mergeCss(result, compoundVariant.css)
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
return result
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function assertCompoundVariant(name, compoundVariants, variants, prop) {
|
|
84
|
+
if (compoundVariants.length > 0 && typeof variants?.[prop] === 'object') {
|
|
85
|
+
throw new Error(`[recipe:${name}:${prop}] Conditions are not supported when using compound variants.`)
|
|
86
|
+
}
|
|
87
|
+
}
|
package/dist/css/cx.d.ts
ADDED
package/dist/css/cx.mjs
ADDED
package/dist/css/sva.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { compact, getSlotRecipes, memo, splitProps } from '../helpers.mjs';
|
|
2
|
+
import { cva } from './cva.mjs';
|
|
3
|
+
import { cx } from './cx.mjs';
|
|
4
|
+
|
|
5
|
+
const slotClass = (className, slot) => className + '__' + slot
|
|
6
|
+
|
|
7
|
+
export function sva(config) {
|
|
8
|
+
const slots = Object.entries(getSlotRecipes(config)).map(([slot, slotCva]) => [slot, cva(slotCva)])
|
|
9
|
+
const defaultVariants = config.defaultVariants ?? {}
|
|
10
|
+
|
|
11
|
+
function svaFn(props) {
|
|
12
|
+
const result = slots.map(([slot, cvaFn]) => [slot, cx(cvaFn(props), config.className && slotClass(config.className, slot))])
|
|
13
|
+
return Object.fromEntries(result)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function raw(props) {
|
|
17
|
+
const result = slots.map(([slot, cvaFn]) => [slot, cvaFn.raw(props)])
|
|
18
|
+
return Object.fromEntries(result)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const variants = config.variants ?? {};
|
|
22
|
+
const variantKeys = Object.keys(variants);
|
|
23
|
+
|
|
24
|
+
function splitVariantProps(props) {
|
|
25
|
+
return splitProps(props, variantKeys);
|
|
26
|
+
}
|
|
27
|
+
const getVariantProps = (variants) => ({ ...(defaultVariants || {}), ...compact(variants) })
|
|
28
|
+
|
|
29
|
+
const variantMap = Object.fromEntries(
|
|
30
|
+
Object.entries(variants).map(([key, value]) => [key, Object.keys(value)])
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return Object.assign(memo(svaFn), {
|
|
34
|
+
__cva__: false,
|
|
35
|
+
raw,
|
|
36
|
+
variantMap,
|
|
37
|
+
variantKeys,
|
|
38
|
+
splitVariantProps,
|
|
39
|
+
getVariantProps,
|
|
40
|
+
})
|
|
41
|
+
}
|