@sanity-labs/ui-poc 0.0.1-alpha.8 → 0.0.1-alpha.9
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/dist/components.css +36 -54
- package/dist/index.d.ts +28 -19
- package/dist/index.js +98 -75
- package/dist/index.js.map +1 -1
- package/dist/styles.css +367 -860
- package/dist/utilities.css +329 -37
- package/package.json +1 -1
- package/src/components/box/Box.tsx +1 -12
- package/src/components/box/box.css +5 -0
- package/src/components/box/box.props.ts +11 -2
- package/src/components/card/Card.tsx +8 -7
- package/src/components/card/card.css +5 -52
- package/src/components/card/card.props.ts +5 -7
- package/src/components/divider/Divider.tsx +10 -3
- package/src/components/divider/divider.props.tsx +9 -0
- package/src/components/flex/Flex.tsx +1 -15
- package/src/components/flex/flex.css +5 -0
- package/src/components/flex/flex.props.ts +14 -4
- package/src/components/grid/Grid.tsx +1 -15
- package/src/components/grid/grid.css +5 -0
- package/src/components/grid/grid.props.ts +14 -4
- package/src/components/heading/Heading.tsx +2 -2
- package/src/components/heading/heading.css +9 -0
- package/src/components/index.css +5 -0
- package/src/components/text/Text.tsx +3 -13
- package/src/components/text/text.css +9 -0
- package/src/components/text/text.props.ts +12 -2
- package/src/css/classes/dynamic/readme.md +3 -0
- package/src/css/{utilities → classes}/generic/display.css +0 -3
- package/src/css/{utilities → classes}/generic/index.css +0 -3
- package/src/css/classes/generic/readme.md +3 -0
- package/src/css/{utilities → classes}/index.css +2 -1
- package/src/css/classes/local/border.css +16 -0
- package/src/css/classes/local/index.css +3 -0
- package/src/css/classes/local/readme.md +3 -0
- package/src/css/classes/local/tone.css +48 -0
- package/src/css/classes/system/readme.md +3 -0
- package/src/css/global/reset.css +4 -0
- package/src/css/index.css +1 -1
- package/src/css/tokens/border.css +3 -0
- package/src/css/tokens/index.css +1 -0
- package/src/css/tokens/tone.css +28 -12
- package/src/props/layout.ts +4 -1
- package/src/props/shadow.ts +15 -0
- package/src/props/tone.ts +1 -7
- package/src/props/typography.ts +3 -1
- package/src/styles.css +359 -857
- package/src/types/PropDef.ts +4 -3
- package/src/types/Shadow.ts +2 -0
- package/src/types/Tone.ts +9 -4
- package/src/utils/getProps.ts +8 -8
- package/dist/__tmp__/src/components/box/Box.d.ts +0 -14
- package/dist/__tmp__/src/components/box/Box.d.ts.map +0 -1
- package/dist/__tmp__/src/components/box/box.props.d.ts +0 -3
- package/dist/__tmp__/src/components/box/box.props.d.ts.map +0 -1
- package/dist/__tmp__/src/components/card/Card.d.ts +0 -5
- package/dist/__tmp__/src/components/card/Card.d.ts.map +0 -1
- package/dist/__tmp__/src/components/card/card.props.d.ts +0 -19
- package/dist/__tmp__/src/components/card/card.props.d.ts.map +0 -1
- package/dist/__tmp__/src/components/divider/Divider.d.ts +0 -3
- package/dist/__tmp__/src/components/divider/Divider.d.ts.map +0 -1
- package/dist/__tmp__/src/components/flex/Flex.d.ts +0 -16
- package/dist/__tmp__/src/components/flex/Flex.d.ts.map +0 -1
- package/dist/__tmp__/src/components/flex/flex.props.d.ts +0 -3
- package/dist/__tmp__/src/components/flex/flex.props.d.ts.map +0 -1
- package/dist/__tmp__/src/components/grid/Grid.d.ts +0 -16
- package/dist/__tmp__/src/components/grid/Grid.d.ts.map +0 -1
- package/dist/__tmp__/src/components/grid/grid.props.d.ts +0 -3
- package/dist/__tmp__/src/components/grid/grid.props.d.ts.map +0 -1
- package/dist/__tmp__/src/components/heading/Heading.d.ts +0 -5
- package/dist/__tmp__/src/components/heading/Heading.d.ts.map +0 -1
- package/dist/__tmp__/src/components/heading/heading.props.d.ts +0 -12
- package/dist/__tmp__/src/components/heading/heading.props.d.ts.map +0 -1
- package/dist/__tmp__/src/components/text/Text.d.ts +0 -13
- package/dist/__tmp__/src/components/text/Text.d.ts.map +0 -1
- package/dist/__tmp__/src/components/text/text.props.d.ts +0 -3
- package/dist/__tmp__/src/components/text/text.props.d.ts.map +0 -1
- package/dist/__tmp__/src/index.d.ts +0 -8
- package/dist/__tmp__/src/index.d.ts.map +0 -1
- package/dist/__tmp__/src/props/border.d.ts +0 -19
- package/dist/__tmp__/src/props/border.d.ts.map +0 -1
- package/dist/__tmp__/src/props/flexChild.d.ts +0 -12
- package/dist/__tmp__/src/props/flexChild.d.ts.map +0 -1
- package/dist/__tmp__/src/props/flexParent.d.ts +0 -15
- package/dist/__tmp__/src/props/flexParent.d.ts.map +0 -1
- package/dist/__tmp__/src/props/gap.d.ts +0 -13
- package/dist/__tmp__/src/props/gap.d.ts.map +0 -1
- package/dist/__tmp__/src/props/gridChild.d.ts +0 -18
- package/dist/__tmp__/src/props/gridChild.d.ts.map +0 -1
- package/dist/__tmp__/src/props/gridParent.d.ts +0 -17
- package/dist/__tmp__/src/props/gridParent.d.ts.map +0 -1
- package/dist/__tmp__/src/props/height.d.ts +0 -12
- package/dist/__tmp__/src/props/height.d.ts.map +0 -1
- package/dist/__tmp__/src/props/layout.d.ts +0 -15
- package/dist/__tmp__/src/props/layout.d.ts.map +0 -1
- package/dist/__tmp__/src/props/margin.d.ts +0 -21
- package/dist/__tmp__/src/props/margin.d.ts.map +0 -1
- package/dist/__tmp__/src/props/overflow.d.ts +0 -13
- package/dist/__tmp__/src/props/overflow.d.ts.map +0 -1
- package/dist/__tmp__/src/props/padding.d.ts +0 -21
- package/dist/__tmp__/src/props/padding.d.ts.map +0 -1
- package/dist/__tmp__/src/props/position.d.ts +0 -22
- package/dist/__tmp__/src/props/position.d.ts.map +0 -1
- package/dist/__tmp__/src/props/tone.d.ts +0 -9
- package/dist/__tmp__/src/props/tone.d.ts.map +0 -1
- package/dist/__tmp__/src/props/typography.d.ts +0 -18
- package/dist/__tmp__/src/props/typography.d.ts.map +0 -1
- package/dist/__tmp__/src/props/width.d.ts +0 -12
- package/dist/__tmp__/src/props/width.d.ts.map +0 -1
- package/dist/__tmp__/src/types/Density.d.ts +0 -3
- package/dist/__tmp__/src/types/Density.d.ts.map +0 -1
- package/dist/__tmp__/src/types/Display.d.ts +0 -7
- package/dist/__tmp__/src/types/Display.d.ts.map +0 -1
- package/dist/__tmp__/src/types/Flex.d.ts +0 -9
- package/dist/__tmp__/src/types/Flex.d.ts.map +0 -1
- package/dist/__tmp__/src/types/FontWeight.d.ts +0 -3
- package/dist/__tmp__/src/types/FontWeight.d.ts.map +0 -1
- package/dist/__tmp__/src/types/Grid.d.ts +0 -3
- package/dist/__tmp__/src/types/Grid.d.ts.map +0 -1
- package/dist/__tmp__/src/types/Heading.d.ts +0 -5
- package/dist/__tmp__/src/types/Heading.d.ts.map +0 -1
- package/dist/__tmp__/src/types/Overflow.d.ts +0 -3
- package/dist/__tmp__/src/types/Overflow.d.ts.map +0 -1
- package/dist/__tmp__/src/types/Position.d.ts +0 -3
- package/dist/__tmp__/src/types/Position.d.ts.map +0 -1
- package/dist/__tmp__/src/types/PropDef.d.ts +0 -34
- package/dist/__tmp__/src/types/PropDef.d.ts.map +0 -1
- package/dist/__tmp__/src/types/Radius.d.ts +0 -3
- package/dist/__tmp__/src/types/Radius.d.ts.map +0 -1
- package/dist/__tmp__/src/types/Responsive.d.ts +0 -16
- package/dist/__tmp__/src/types/Responsive.d.ts.map +0 -1
- package/dist/__tmp__/src/types/Space.d.ts +0 -5
- package/dist/__tmp__/src/types/Space.d.ts.map +0 -1
- package/dist/__tmp__/src/types/Text.d.ts +0 -3
- package/dist/__tmp__/src/types/Text.d.ts.map +0 -1
- package/dist/__tmp__/src/types/TextAlign.d.ts +0 -3
- package/dist/__tmp__/src/types/TextAlign.d.ts.map +0 -1
- package/dist/__tmp__/src/types/Tone.d.ts +0 -5
- package/dist/__tmp__/src/types/Tone.d.ts.map +0 -1
- package/dist/__tmp__/src/utils/getProps.d.ts +0 -13
- package/dist/__tmp__/src/utils/getProps.d.ts.map +0 -1
- package/src/css/utilities/generic/border.css +0 -11
- package/src/css/utilities/generic/text-muted.css +0 -2
- /package/src/css/{utilities → classes}/dynamic/flex-child.css +0 -0
- /package/src/css/{utilities → classes}/dynamic/grid-child.css +0 -0
- /package/src/css/{utilities → classes}/dynamic/grid-parent.css +0 -0
- /package/src/css/{utilities → classes}/dynamic/height.css +0 -0
- /package/src/css/{utilities → classes}/dynamic/index.css +0 -0
- /package/src/css/{utilities → classes}/dynamic/line-clamp.css +0 -0
- /package/src/css/{utilities → classes}/dynamic/width.css +0 -0
- /package/src/css/{utilities → classes}/dynamic/z-index.css +0 -0
- /package/src/css/{utilities → classes}/generic/flex.css +0 -0
- /package/src/css/{utilities → classes}/generic/grid.css +0 -0
- /package/src/css/{utilities → classes}/generic/overflow.css +0 -0
- /package/src/css/{utilities → classes}/generic/position.css +0 -0
- /package/src/css/{utilities → classes}/generic/text-align.css +0 -0
- /package/src/css/{utilities/generic → classes/local}/text-trim.css +0 -0
- /package/src/css/{utilities/tokenized → classes/system}/color.css +0 -0
- /package/src/css/{utilities/tokenized → classes/system}/container.css +0 -0
- /package/src/css/{utilities/tokenized → classes/system}/fontFamily.css +0 -0
- /package/src/css/{utilities/tokenized → classes/system}/fontWeight.css +0 -0
- /package/src/css/{utilities/tokenized → classes/system}/gap.css +0 -0
- /package/src/css/{utilities/tokenized → classes/system}/index.css +0 -0
- /package/src/css/{utilities/tokenized → classes/system}/inset.css +0 -0
- /package/src/css/{utilities/tokenized → classes/system}/margin.css +0 -0
- /package/src/css/{utilities/tokenized → classes/system}/padding.css +0 -0
- /package/src/css/{utilities/tokenized → classes/system}/radius.css +0 -0
- /package/src/css/{utilities/tokenized → classes/system}/shadow.css +0 -0
- /package/src/css/{utilities/tokenized → classes/system}/typography.css +0 -0
package/dist/components.css
CHANGED
|
@@ -1,56 +1,38 @@
|
|
|
1
|
+
.sui-Box {
|
|
2
|
+
/* Box has no tone by default, therefore we set --tone-surface as transparent */
|
|
3
|
+
--tone-surface: transparent;
|
|
4
|
+
background-color: var(--tone-surface);
|
|
5
|
+
}
|
|
1
6
|
.sui-Card {
|
|
2
|
-
background
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
--
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.sui-
|
|
23
|
-
--
|
|
24
|
-
--
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
--
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
--surface-tone: var(--tone-caution-normal-surface);
|
|
34
|
-
--strong-surface-tone: var(--tone-caution-strong-surface);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.sui-Card:where(.sui-tone-critical) {
|
|
38
|
-
--surface-tone: var(--tone-critical-normal-surface);
|
|
39
|
-
--strong-surface-tone: var(--tone-critical-strong-surface);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** -----------------------------------
|
|
43
|
-
* TONE: application of custom properties by tone level
|
|
44
|
-
* ---------------------------------*/
|
|
45
|
-
|
|
46
|
-
.sui-Card:where(.sui-tone-level-muted) {
|
|
47
|
-
border-color: var(--surface-tone);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.sui-Card:where(.sui-tone-level-normal) {
|
|
51
|
-
background-color: var(--surface-tone);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.sui-Card:where(.sui-tone-level-strong) {
|
|
55
|
-
background-color: var(--strong-surface-tone);
|
|
7
|
+
/* Card is always used with tone, therefore we can apply background and border colors
|
|
8
|
+
* by default without setting fallback custom properties.
|
|
9
|
+
* Note that border width/style is applied by .sui-border, used by default on Card */
|
|
10
|
+
background-color: var(--tone-surface);
|
|
11
|
+
border-color: var(--tone-separator);
|
|
12
|
+
}
|
|
13
|
+
.sui-Flex {
|
|
14
|
+
/* Flex has no tone by default, therefore we set --tone-surface as transparent */
|
|
15
|
+
--tone-surface: transparent;
|
|
16
|
+
background-color: var(--tone-surface);
|
|
17
|
+
}
|
|
18
|
+
.sui-Grid {
|
|
19
|
+
/* Grid has no tone by default, therefore we set --tone-surface as transparent */
|
|
20
|
+
--tone-surface: transparent;
|
|
21
|
+
background-color: var(--tone-surface);
|
|
22
|
+
}
|
|
23
|
+
.sui-Heading {
|
|
24
|
+
--tone-text-default: light-dark(var(--gray-800), var(--gray-200));
|
|
25
|
+
color: var(--tone-text, var(--tone-text-default));
|
|
26
|
+
}
|
|
27
|
+
.sui-Heading:where(.sui-text-muted) {
|
|
28
|
+
--tone-text-muted-default: light-dark(var(--gray-600), var(--gray-400));
|
|
29
|
+
color: var(--tone-text-muted, var(--tone-text-muted-default));
|
|
30
|
+
}
|
|
31
|
+
.sui-Text {
|
|
32
|
+
--tone-text-default: light-dark(var(--gray-800), var(--gray-200));
|
|
33
|
+
color: var(--tone-text, var(--tone-text-default));
|
|
34
|
+
}
|
|
35
|
+
.sui-Text:where(.sui-text-muted) {
|
|
36
|
+
--tone-text-muted-default: light-dark(var(--gray-600), var(--gray-400));
|
|
37
|
+
color: var(--tone-text-muted, var(--tone-text-muted-default));
|
|
56
38
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare function Box<T extends React_2.ElementType = 'div'>({
|
|
|
27
27
|
}: BoxProps<T> & Omit<React_2.ComponentPropsWithRef<T>, keyof BoxProps<T>>): JSX.Element
|
|
28
28
|
|
|
29
29
|
/** @public */
|
|
30
|
-
|
|
30
|
+
declare interface BoxProps<T extends React.ElementType> extends LayoutProps {
|
|
31
31
|
/** Element to render */
|
|
32
32
|
as?: T
|
|
33
33
|
/** CSS **display** property */
|
|
@@ -38,20 +38,17 @@ export declare interface BoxProps<T extends React_2.ElementType> extends LayoutP
|
|
|
38
38
|
export declare function Card<T extends React_2.ElementType = 'div'>({
|
|
39
39
|
density,
|
|
40
40
|
tone,
|
|
41
|
-
toneLevel,
|
|
42
41
|
...props
|
|
43
42
|
}: CardProps<T> & Omit<React_2.ComponentPropsWithRef<T>, keyof CardProps<T>>): JSX.Element
|
|
44
43
|
|
|
45
44
|
/** @public */
|
|
46
|
-
declare interface CardProps<T extends React.ElementType> extends MarginProps {
|
|
45
|
+
declare interface CardProps<T extends React.ElementType> extends MarginProps, ToneProps {
|
|
47
46
|
/** Element to render */
|
|
48
47
|
as?: T
|
|
49
48
|
/** CSS **display** property */
|
|
50
49
|
display?: Responsive<DisplayBlock>
|
|
51
50
|
/** Composite prop for setting padding and border radius */
|
|
52
51
|
density?: Responsive<Density>
|
|
53
|
-
tone?: Tone
|
|
54
|
-
toneLevel?: ToneLevel
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
declare const DENSITY: readonly ['compact', 'regular', 'loose']
|
|
@@ -71,7 +68,10 @@ declare type DisplayFlex = (typeof DISPLAY_FLEX)[number]
|
|
|
71
68
|
declare type DisplayGrid = (typeof DISPLAY_GRID)[number]
|
|
72
69
|
|
|
73
70
|
/** @public */
|
|
74
|
-
export declare function Divider(): JSX.Element
|
|
71
|
+
export declare function Divider(props: DividerProps): JSX.Element
|
|
72
|
+
|
|
73
|
+
/** @public */
|
|
74
|
+
declare interface DividerProps extends React.ComponentProps<'hr'>, MarginProps {}
|
|
75
75
|
|
|
76
76
|
/** @public */
|
|
77
77
|
export declare function Flex<T extends React_2.ElementType = 'div'>({
|
|
@@ -106,7 +106,7 @@ declare type FlexParentProps = {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/** @public */
|
|
109
|
-
|
|
109
|
+
declare interface FlexProps<T extends React.ElementType>
|
|
110
110
|
extends FlexParentProps, GapProps, LayoutProps {
|
|
111
111
|
/** Element to render */
|
|
112
112
|
as?: T
|
|
@@ -168,7 +168,7 @@ declare type GridParentProps = {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
/** @public */
|
|
171
|
-
|
|
171
|
+
declare interface GridProps<T extends React.ElementType>
|
|
172
172
|
extends GridParentProps, GapProps, LayoutProps {
|
|
173
173
|
/** Element to render */
|
|
174
174
|
as?: T
|
|
@@ -177,7 +177,7 @@ export declare interface GridProps<T extends React_2.ElementType>
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/** @public */
|
|
180
|
-
export declare function Heading<T extends React_2.ElementType = '
|
|
180
|
+
export declare function Heading<T extends React_2.ElementType = 'h2'>({
|
|
181
181
|
size,
|
|
182
182
|
weight,
|
|
183
183
|
...props
|
|
@@ -230,7 +230,8 @@ declare interface LayoutProps
|
|
|
230
230
|
PositionProps,
|
|
231
231
|
OverflowProps,
|
|
232
232
|
FlexChildProps,
|
|
233
|
-
GridChildProps
|
|
233
|
+
GridChildProps,
|
|
234
|
+
ShadowProps {}
|
|
234
235
|
|
|
235
236
|
declare type MarginProps = {
|
|
236
237
|
/** CSS **margin** property */
|
|
@@ -329,6 +330,11 @@ declare type Responsive<T> =
|
|
|
329
330
|
length: 7
|
|
330
331
|
})
|
|
331
332
|
|
|
333
|
+
declare type ShadowProps = {
|
|
334
|
+
/** CSS **box-shadow** property */
|
|
335
|
+
shadow?: string
|
|
336
|
+
}
|
|
337
|
+
|
|
332
338
|
declare const SPACE: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
333
339
|
|
|
334
340
|
declare type Space = (typeof SPACE)[number]
|
|
@@ -338,7 +344,7 @@ declare const SPACE_AUTO: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'auto']
|
|
|
338
344
|
declare type SpaceAuto = (typeof SPACE_AUTO)[number]
|
|
339
345
|
|
|
340
346
|
/** @public */
|
|
341
|
-
declare function Text_2<T extends React_2.ElementType = '
|
|
347
|
+
declare function Text_2<T extends React_2.ElementType = 'span'>({
|
|
342
348
|
size,
|
|
343
349
|
...props
|
|
344
350
|
}: TextProps<T> & Omit<React_2.ComponentPropsWithRef<T>, keyof TextProps<T>>): JSX.Element
|
|
@@ -351,7 +357,7 @@ declare const TEXT_SIZE: readonly [0, 1, 2, 3, 4]
|
|
|
351
357
|
declare type TextAlign = (typeof TEXT_ALIGN)[number]
|
|
352
358
|
|
|
353
359
|
/** @public */
|
|
354
|
-
|
|
360
|
+
declare interface TextProps<T extends React.ElementType> extends TypographyProps {
|
|
355
361
|
/** Element to render */
|
|
356
362
|
as?: T
|
|
357
363
|
/** CSS **font-size** property */
|
|
@@ -360,21 +366,24 @@ export declare interface TextProps<T extends React_2.ElementType> extends Typogr
|
|
|
360
366
|
|
|
361
367
|
declare type TextSize = (typeof TEXT_SIZE)[number]
|
|
362
368
|
|
|
363
|
-
declare const TONE: readonly [
|
|
369
|
+
declare const TONE: readonly [
|
|
370
|
+
'none',
|
|
371
|
+
'neutral',
|
|
372
|
+
'primary',
|
|
373
|
+
'positive',
|
|
374
|
+
'suggest',
|
|
375
|
+
'caution',
|
|
376
|
+
'critical',
|
|
377
|
+
]
|
|
364
378
|
|
|
365
379
|
declare type Tone = (typeof TONE)[number]
|
|
366
380
|
|
|
367
|
-
declare const TONE_LEVEL: string[]
|
|
368
|
-
|
|
369
|
-
declare type ToneLevel = (typeof TONE_LEVEL)[number]
|
|
370
|
-
|
|
371
381
|
declare type ToneProps = {
|
|
372
382
|
/** CSS **background-color** property */
|
|
373
383
|
tone?: Tone
|
|
374
|
-
toneLevel?: ToneLevel
|
|
375
384
|
}
|
|
376
385
|
|
|
377
|
-
declare interface TypographyProps extends MarginProps {
|
|
386
|
+
declare interface TypographyProps extends MarginProps, ToneProps {
|
|
378
387
|
/** CSS **text-align** property */
|
|
379
388
|
align?: TextAlign
|
|
380
389
|
/** CSS **-webkit-line-clamp** property */
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import classNames from "classnames";
|
|
3
|
+
const PREFIX = "sui", BREAKPOINTS_LENGTH = 7;
|
|
4
|
+
function getProps(componentProps, propDefs) {
|
|
5
|
+
const { allComponentProps, allPropDefs } = flattenCompositeProps(componentProps, propDefs), restProps = {};
|
|
6
|
+
let className = componentProps?.className || "", style = componentProps?.style || {};
|
|
7
|
+
for (const key in allComponentProps) {
|
|
8
|
+
const propDef = allPropDefs?.[key], propValue = allComponentProps[key];
|
|
9
|
+
if (!propDef || !("className" in propDef) || !propDef.className) {
|
|
10
|
+
restProps[key] = propValue;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(propValue))
|
|
14
|
+
for (let i = 0, len = Math.min(propValue.length, BREAKPOINTS_LENGTH); i < len; i++)
|
|
15
|
+
className = classNames(className, getClassName(propValue[i], propDef, i)), style = { ...style, ...getStyle(propValue[i], propDef, i) };
|
|
16
|
+
else
|
|
17
|
+
className = classNames(className, getClassName(propValue, propDef)), style = { ...style, ...getStyle(propValue, propDef) };
|
|
18
|
+
}
|
|
19
|
+
return { ...restProps, className, style };
|
|
20
|
+
}
|
|
21
|
+
function getClassName(propValue, propDef, bp) {
|
|
22
|
+
return propDef.type === "union" && propDef.values?.includes(propValue) ? `${PREFIX}-${propDef.className}${typeof propValue == "string" ? `-${propValue}` : propValue}${bp ? `-bp-${bp}` : ""}` : propDef.type === "string" || propDef.type === "number" ? `${PREFIX}-${propDef.className}${bp ? `-bp-${bp}` : ""}` : propDef.type === "boolean" ? `${PREFIX}-${propValue ? propDef.className : propDef.inverse}${bp ? `-bp-${bp}` : ""}` : "";
|
|
23
|
+
}
|
|
24
|
+
function getStyle(propValue, propDef, bp) {
|
|
25
|
+
return propDef.type === "string" || propDef.type === "number" ? {
|
|
26
|
+
[`${propDef.variable}${bp ? `-bp-${bp}` : ""}`]: propValue
|
|
27
|
+
} : {};
|
|
28
|
+
}
|
|
29
|
+
function flattenCompositeProps(componentProps, propDefs) {
|
|
30
|
+
const props = {
|
|
31
|
+
allComponentProps: {},
|
|
32
|
+
allPropDefs: {}
|
|
33
|
+
};
|
|
34
|
+
for (const key in componentProps)
|
|
35
|
+
if (propDefs?.[key] && propDefs?.[key].type === "composite")
|
|
36
|
+
for (const compositeKey in propDefs?.[key].composition) {
|
|
37
|
+
const compositeValue = getCompositeValue(componentProps[key], propDefs[key], compositeKey);
|
|
38
|
+
props.allComponentProps[compositeKey] = compositeValue, props.allPropDefs[compositeKey] = propDefs[key].composition[compositeKey]?.propDef;
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
props.allComponentProps[key] = componentProps[key], props.allPropDefs[key] = propDefs?.[key];
|
|
42
|
+
return props;
|
|
43
|
+
}
|
|
44
|
+
function getCompositeValue(propValue, propDef, key) {
|
|
45
|
+
if (!("composition" in propDef))
|
|
46
|
+
return;
|
|
47
|
+
const mapping = propDef.composition[key]?.mapping;
|
|
48
|
+
let compositeValue;
|
|
49
|
+
if (Array.isArray(propValue)) {
|
|
50
|
+
compositeValue = [];
|
|
51
|
+
for (let i = 0, len = propValue.length; i < len; i++)
|
|
52
|
+
compositeValue[i] = mapping?.[propValue[i]];
|
|
53
|
+
} else
|
|
54
|
+
compositeValue = mapping?.[propValue];
|
|
55
|
+
return compositeValue;
|
|
56
|
+
}
|
|
3
57
|
const RADIUS = [0, 1, 2, 3, 4, 5, 6, "full"], borderProps = {
|
|
4
58
|
border: {
|
|
5
59
|
type: "boolean",
|
|
@@ -218,16 +272,25 @@ const RADIUS = [0, 1, 2, 3, 4, 5, 6, "full"], borderProps = {
|
|
|
218
272
|
className: "z-index",
|
|
219
273
|
variable: "--z-index"
|
|
220
274
|
}
|
|
221
|
-
},
|
|
275
|
+
}, SHADOW = [0, 1, 2, 3, 4, 5], shadowProps = {
|
|
276
|
+
shadow: {
|
|
277
|
+
type: "union",
|
|
278
|
+
className: "shadow",
|
|
279
|
+
values: SHADOW
|
|
280
|
+
}
|
|
281
|
+
}, TONE = [
|
|
282
|
+
"none",
|
|
283
|
+
"neutral",
|
|
284
|
+
"primary",
|
|
285
|
+
"positive",
|
|
286
|
+
"suggest",
|
|
287
|
+
"caution",
|
|
288
|
+
"critical"
|
|
289
|
+
], toneProps = {
|
|
222
290
|
tone: {
|
|
223
291
|
type: "union",
|
|
224
292
|
className: "tone",
|
|
225
293
|
values: TONE
|
|
226
|
-
},
|
|
227
|
-
toneLevel: {
|
|
228
|
-
type: "union",
|
|
229
|
-
className: "tone-level",
|
|
230
|
-
values: TONE_LEVEL
|
|
231
294
|
}
|
|
232
295
|
}, widthProps = {
|
|
233
296
|
width: {
|
|
@@ -255,62 +318,9 @@ const RADIUS = [0, 1, 2, 3, 4, 5, 6, "full"], borderProps = {
|
|
|
255
318
|
...positionProps,
|
|
256
319
|
...overflowProps,
|
|
257
320
|
...flexChildProps,
|
|
258
|
-
...gridChildProps
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const { allComponentProps, allPropDefs } = flattenCompositeProps(componentProps, propDefs), restProps = {};
|
|
262
|
-
let className = componentProps?.className || "", style = componentProps?.style || {};
|
|
263
|
-
for (const key in allComponentProps) {
|
|
264
|
-
const propDef = allPropDefs?.[key], propValue = allComponentProps[key];
|
|
265
|
-
if (!propDef || !("className" in propDef) || !propDef.className) {
|
|
266
|
-
restProps[key] = propValue;
|
|
267
|
-
continue;
|
|
268
|
-
}
|
|
269
|
-
if (Array.isArray(propValue))
|
|
270
|
-
for (let i = 0, len = Math.min(propValue.length, BREAKPOINTS_LENGTH); i < len; i++)
|
|
271
|
-
className = classNames(className, getClassName(propValue[i], propDef, i)), style = { ...style, ...getStyle(propValue[i], propDef, i) };
|
|
272
|
-
else
|
|
273
|
-
className = classNames(className, getClassName(propValue, propDef)), style = { ...style, ...getStyle(propValue, propDef) };
|
|
274
|
-
}
|
|
275
|
-
return { ...restProps, className, style };
|
|
276
|
-
}
|
|
277
|
-
function getClassName(propValue, propDef, bp) {
|
|
278
|
-
return propDef.type === "union" && propDef.values?.includes(propValue) ? `${PREFIX}-${propDef.className}${typeof propValue == "string" ? `-${propValue}` : propValue}${bp ? `-bp-${bp}` : ""}` : propDef.type === "string" || propDef.type === "number" ? `${PREFIX}-${propDef.className}${bp ? `-bp-${bp}` : ""}` : propDef.type === "boolean" ? `${PREFIX}-${propValue ? propDef.className : propDef.inverse}${bp ? `-bp-${bp}` : ""}` : "";
|
|
279
|
-
}
|
|
280
|
-
function getStyle(propValue, propDef, bp) {
|
|
281
|
-
return propDef.type === "string" || propDef.type === "number" ? {
|
|
282
|
-
[`${propDef.variable}${bp ? `-bp-${bp}` : ""}`]: propValue
|
|
283
|
-
} : {};
|
|
284
|
-
}
|
|
285
|
-
function flattenCompositeProps(componentProps, propDefs) {
|
|
286
|
-
const props = {
|
|
287
|
-
allComponentProps: {},
|
|
288
|
-
allPropDefs: {}
|
|
289
|
-
};
|
|
290
|
-
for (const key in componentProps)
|
|
291
|
-
if (propDefs?.[key] && propDefs?.[key].type === "composite")
|
|
292
|
-
for (const compositeKey in propDefs?.[key].composition) {
|
|
293
|
-
const compositeValue = getCompositeValue(componentProps[key], propDefs[key], compositeKey);
|
|
294
|
-
props.allComponentProps[compositeKey] = compositeValue, props.allPropDefs[compositeKey] = propDefs[key].composition[compositeKey]?.propDef;
|
|
295
|
-
}
|
|
296
|
-
else
|
|
297
|
-
props.allComponentProps[key] = componentProps[key], props.allPropDefs[key] = propDefs?.[key];
|
|
298
|
-
return props;
|
|
299
|
-
}
|
|
300
|
-
function getCompositeValue(propValue, propDef, key) {
|
|
301
|
-
if (!("composition" in propDef))
|
|
302
|
-
return;
|
|
303
|
-
const mapping = propDef.composition[key]?.mapping;
|
|
304
|
-
let compositeValue;
|
|
305
|
-
if (Array.isArray(propValue)) {
|
|
306
|
-
compositeValue = [];
|
|
307
|
-
for (let i = 0, len = propValue.length; i < len; i++)
|
|
308
|
-
compositeValue[i] = mapping?.[propValue[i]];
|
|
309
|
-
} else
|
|
310
|
-
compositeValue = mapping?.[propValue];
|
|
311
|
-
return compositeValue;
|
|
312
|
-
}
|
|
313
|
-
const boxProps = {
|
|
321
|
+
...gridChildProps,
|
|
322
|
+
...shadowProps
|
|
323
|
+
}, DISPLAY_BLOCK = ["block", "inline-block", "none"], DISPLAY_FLEX = ["flex", "inline-flex", "none"], DISPLAY_GRID = ["grid", "inline-grid", "none"], boxProps = {
|
|
314
324
|
as: {
|
|
315
325
|
type: "string"
|
|
316
326
|
},
|
|
@@ -328,7 +338,7 @@ function Box({
|
|
|
328
338
|
const { as, children, className, style, ...rest } = getProps({ display, ...props }, boxProps);
|
|
329
339
|
return /* @__PURE__ */ jsx(as || "div", { className: classNames("sui-Box", className), style, "data-ui": "Box", ...rest, children });
|
|
330
340
|
}
|
|
331
|
-
const cardProps = {
|
|
341
|
+
const DENSITY = ["compact", "regular", "loose"], cardProps = {
|
|
332
342
|
as: {
|
|
333
343
|
type: "string"
|
|
334
344
|
},
|
|
@@ -339,6 +349,7 @@ const cardProps = {
|
|
|
339
349
|
},
|
|
340
350
|
density: {
|
|
341
351
|
type: "composite",
|
|
352
|
+
values: DENSITY,
|
|
342
353
|
composition: {
|
|
343
354
|
padding: {
|
|
344
355
|
propDef: paddingProps.padding,
|
|
@@ -363,22 +374,33 @@ const cardProps = {
|
|
|
363
374
|
};
|
|
364
375
|
function Card({
|
|
365
376
|
density = "regular",
|
|
366
|
-
tone = "
|
|
367
|
-
toneLevel = "normal",
|
|
377
|
+
tone = "none",
|
|
368
378
|
...props
|
|
369
379
|
}) {
|
|
370
|
-
const { as, children, className, style, ...rest } = getProps(
|
|
371
|
-
|
|
372
|
-
|
|
380
|
+
const { as, children, className, style, ...rest } = getProps({ density, tone, ...props }, cardProps);
|
|
381
|
+
return /* @__PURE__ */ jsx(
|
|
382
|
+
as || "div",
|
|
383
|
+
{
|
|
384
|
+
className: classNames("sui-Card sui-border", className),
|
|
385
|
+
style,
|
|
386
|
+
"data-ui": "Card",
|
|
387
|
+
...rest,
|
|
388
|
+
children
|
|
389
|
+
}
|
|
373
390
|
);
|
|
374
|
-
return /* @__PURE__ */ jsx(as || "div", { className: classNames("sui-Card", className), style, "data-ui": "Card", ...rest, children });
|
|
375
391
|
}
|
|
376
|
-
|
|
392
|
+
const dividerProps = {
|
|
393
|
+
...marginProps
|
|
394
|
+
};
|
|
395
|
+
function Divider(props) {
|
|
396
|
+
const { className, style, ...rest } = getProps(props, dividerProps);
|
|
377
397
|
return /* @__PURE__ */ jsx(
|
|
378
398
|
"hr",
|
|
379
399
|
{
|
|
380
|
-
className: "sui-Divider sui-border-
|
|
381
|
-
|
|
400
|
+
className: classNames("sui-Divider sui-border-none sui-border-top", className),
|
|
401
|
+
style,
|
|
402
|
+
"data-ui": "Divider",
|
|
403
|
+
...rest
|
|
382
404
|
}
|
|
383
405
|
);
|
|
384
406
|
}
|
|
@@ -518,7 +540,8 @@ const FONT_WEIGHT = ["regular", "medium", "semibold", "bold"], TEXT_ALIGN = ["le
|
|
|
518
540
|
className: "weight",
|
|
519
541
|
values: FONT_WEIGHT
|
|
520
542
|
},
|
|
521
|
-
...marginProps
|
|
543
|
+
...marginProps,
|
|
544
|
+
...toneProps
|
|
522
545
|
}, HEADING_TAG = ["h1", "h2", "h3", "h4", "h5", "h6"], HEADING_SIZE = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], headingProps = {
|
|
523
546
|
as: {
|
|
524
547
|
type: "union",
|
|
@@ -536,7 +559,7 @@ function Heading({
|
|
|
536
559
|
weight = "bold",
|
|
537
560
|
...props
|
|
538
561
|
}) {
|
|
539
|
-
const { as, children, className, style, ...rest } = getProps({ size, weight, ...props }, headingProps), Component = as || "
|
|
562
|
+
const { as, children, className, style, ...rest } = getProps({ size, weight, ...props }, headingProps), Component = as || "h2";
|
|
540
563
|
return props.lineClamp && props.trim ? /* @__PURE__ */ jsx(
|
|
541
564
|
Component,
|
|
542
565
|
{
|
|
@@ -572,7 +595,7 @@ function Text({
|
|
|
572
595
|
size = 2,
|
|
573
596
|
...props
|
|
574
597
|
}) {
|
|
575
|
-
const { as, children, className, style, ...rest } = getProps({ size, ...props }, textProps), Component = as || "
|
|
598
|
+
const { as, children, className, style, ...rest } = getProps({ size, ...props }, textProps), Component = as || "span";
|
|
576
599
|
return props.lineClamp && props.trim ? /* @__PURE__ */ jsx(
|
|
577
600
|
Component,
|
|
578
601
|
{
|