@sanity-labs/ui-poc 0.0.1-alpha.7 → 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 +114 -49
- package/dist/index.js.map +1 -1
- package/dist/styles.css +397 -903
- package/dist/utilities.css +383 -104
- package/package.json +2 -2
- 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 +24 -11
- 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/classes/index.css +4 -0
- 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/font-face.css +20 -0
- package/src/css/global/index.css +2 -0
- package/src/css/global/reset.css +70 -0
- package/src/css/index.css +3 -7
- package/src/css/tokens/border.css +3 -0
- package/src/css/tokens/index.css +2 -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 +397 -903
- package/src/types/PropDef.ts +11 -5
- package/src/types/Shadow.ts +2 -0
- package/src/types/Tone.ts +9 -4
- package/src/utils/getProps.test.ts +2 -2
- package/src/utils/getProps.ts +74 -42
- 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 -32
- 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 -9
- package/dist/__tmp__/src/utils/getProps.d.ts.map +0 -1
- package/src/css/global.css +0 -103
- 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,33 +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
|
-
let className = componentProps?.className || "", style = componentProps?.style || {};
|
|
262
|
-
const restProps = {};
|
|
263
|
-
for (const key in componentProps) {
|
|
264
|
-
if (!propDefs?.[key] || !("className" in propDefs[key]) && !("composition" in propDefs[key])) {
|
|
265
|
-
restProps[key] = componentProps[key];
|
|
266
|
-
continue;
|
|
267
|
-
}
|
|
268
|
-
if (Array.isArray(componentProps[key]))
|
|
269
|
-
for (let i = 0, len = Math.min(componentProps[key].length, BREAKPOINTS_LENGTH); i < len; i++)
|
|
270
|
-
className = classNames(className, getClassName(componentProps[key][i], propDefs[key], i)), style = { ...style, ...getStyle(componentProps[key][i], propDefs[key], i) };
|
|
271
|
-
else
|
|
272
|
-
className = classNames(className, getClassName(componentProps[key], propDefs[key])), style = { ...style, ...getStyle(componentProps[key], propDefs[key]) };
|
|
273
|
-
}
|
|
274
|
-
return { ...restProps, className, style };
|
|
275
|
-
}
|
|
276
|
-
function getClassName(prop, propDef, bp) {
|
|
277
|
-
return propDef.type === "composite" && propDef.composition[prop] ? bp ? propDef.composition[prop].split(" ").map((className) => `${className}-bp-${bp}`).join(" ") : propDef.composition[prop] : propDef.type === "union" && propDef.values?.includes(prop) ? `${PREFIX}-${propDef.className}${typeof prop == "string" ? `-${prop}` : prop}${bp ? `-bp-${bp}` : ""}` : propDef.type === "string" || propDef.type === "number" ? `${PREFIX}-${propDef.className}${bp ? `-bp-${bp}` : ""}` : propDef.type === "boolean" ? `${PREFIX}-${prop ? propDef.className : propDef.inverse}${bp ? `-bp-${bp}` : ""}` : "";
|
|
278
|
-
}
|
|
279
|
-
function getStyle(prop, propDef, bp) {
|
|
280
|
-
return propDef.type === "string" || propDef.type === "number" ? {
|
|
281
|
-
[`${propDef.variable}${bp ? `-bp-${bp}` : ""}`]: prop
|
|
282
|
-
} : {};
|
|
283
|
-
}
|
|
284
|
-
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 = {
|
|
285
324
|
as: {
|
|
286
325
|
type: "string"
|
|
287
326
|
},
|
|
@@ -299,7 +338,7 @@ function Box({
|
|
|
299
338
|
const { as, children, className, style, ...rest } = getProps({ display, ...props }, boxProps);
|
|
300
339
|
return /* @__PURE__ */ jsx(as || "div", { className: classNames("sui-Box", className), style, "data-ui": "Box", ...rest, children });
|
|
301
340
|
}
|
|
302
|
-
const cardProps = {
|
|
341
|
+
const DENSITY = ["compact", "regular", "loose"], cardProps = {
|
|
303
342
|
as: {
|
|
304
343
|
type: "string"
|
|
305
344
|
},
|
|
@@ -310,10 +349,24 @@ const cardProps = {
|
|
|
310
349
|
},
|
|
311
350
|
density: {
|
|
312
351
|
type: "composite",
|
|
352
|
+
values: DENSITY,
|
|
313
353
|
composition: {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
354
|
+
padding: {
|
|
355
|
+
propDef: paddingProps.padding,
|
|
356
|
+
mapping: {
|
|
357
|
+
compact: 3,
|
|
358
|
+
regular: 4,
|
|
359
|
+
loose: 5
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
radius: {
|
|
363
|
+
propDef: borderProps.radius,
|
|
364
|
+
mapping: {
|
|
365
|
+
compact: 2,
|
|
366
|
+
regular: 3,
|
|
367
|
+
loose: 4
|
|
368
|
+
}
|
|
369
|
+
}
|
|
317
370
|
}
|
|
318
371
|
},
|
|
319
372
|
...toneProps,
|
|
@@ -321,22 +374,33 @@ const cardProps = {
|
|
|
321
374
|
};
|
|
322
375
|
function Card({
|
|
323
376
|
density = "regular",
|
|
324
|
-
tone = "
|
|
325
|
-
toneLevel = "normal",
|
|
377
|
+
tone = "none",
|
|
326
378
|
...props
|
|
327
379
|
}) {
|
|
328
|
-
const { as, children, className, style, ...rest } = getProps(
|
|
329
|
-
|
|
330
|
-
|
|
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
|
+
}
|
|
331
390
|
);
|
|
332
|
-
return /* @__PURE__ */ jsx(as || "div", { className: classNames("sui-Card", className), style, "data-ui": "Card", ...rest, children });
|
|
333
391
|
}
|
|
334
|
-
|
|
392
|
+
const dividerProps = {
|
|
393
|
+
...marginProps
|
|
394
|
+
};
|
|
395
|
+
function Divider(props) {
|
|
396
|
+
const { className, style, ...rest } = getProps(props, dividerProps);
|
|
335
397
|
return /* @__PURE__ */ jsx(
|
|
336
398
|
"hr",
|
|
337
399
|
{
|
|
338
|
-
className: "sui-Divider sui-border-
|
|
339
|
-
|
|
400
|
+
className: classNames("sui-Divider sui-border-none sui-border-top", className),
|
|
401
|
+
style,
|
|
402
|
+
"data-ui": "Divider",
|
|
403
|
+
...rest
|
|
340
404
|
}
|
|
341
405
|
);
|
|
342
406
|
}
|
|
@@ -476,7 +540,8 @@ const FONT_WEIGHT = ["regular", "medium", "semibold", "bold"], TEXT_ALIGN = ["le
|
|
|
476
540
|
className: "weight",
|
|
477
541
|
values: FONT_WEIGHT
|
|
478
542
|
},
|
|
479
|
-
...marginProps
|
|
543
|
+
...marginProps,
|
|
544
|
+
...toneProps
|
|
480
545
|
}, HEADING_TAG = ["h1", "h2", "h3", "h4", "h5", "h6"], HEADING_SIZE = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], headingProps = {
|
|
481
546
|
as: {
|
|
482
547
|
type: "union",
|
|
@@ -494,7 +559,7 @@ function Heading({
|
|
|
494
559
|
weight = "bold",
|
|
495
560
|
...props
|
|
496
561
|
}) {
|
|
497
|
-
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";
|
|
498
563
|
return props.lineClamp && props.trim ? /* @__PURE__ */ jsx(
|
|
499
564
|
Component,
|
|
500
565
|
{
|
|
@@ -530,7 +595,7 @@ function Text({
|
|
|
530
595
|
size = 2,
|
|
531
596
|
...props
|
|
532
597
|
}) {
|
|
533
|
-
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";
|
|
534
599
|
return props.lineClamp && props.trim ? /* @__PURE__ */ jsx(
|
|
535
600
|
Component,
|
|
536
601
|
{
|