@sanity/ui 5.0.0-alpha.2 → 5.0.0-alpha.20
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/README.md +1 -1
- package/dist/LazyRefractor-CQ22IeXB.js +19 -0
- package/dist/LazyRefractor-CQ22IeXB.js.map +1 -0
- package/dist/cli/install.js +2 -1
- package/dist/index.d.ts +825 -855
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2460 -1796
- package/dist/index.js.map +1 -1
- package/dist/polyfills.d.ts +1 -0
- package/dist/polyfills.js +5 -0
- package/dist/polyfills.js.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +16 -9
- package/src/cli/install.ts +2 -1
- package/src/components/avatar/Avatar.tsx +50 -0
- package/src/components/avatar/avatar.css +51 -0
- package/src/components/avatar/avatar.props.ts +57 -0
- package/src/components/avatar-counter/AvatarCounter.tsx +38 -0
- package/src/components/avatar-counter/avatar-counter.css +8 -0
- package/src/components/avatar-counter/avatarCounter.props.ts +44 -0
- package/src/components/avatar-stack/AvatarStack.tsx +60 -0
- package/src/components/avatar-stack/avatar-stack.css +16 -0
- package/src/components/avatar-stack/avatarStack.props.ts +20 -0
- package/src/components/badge/Badge.tsx +53 -0
- package/src/components/badge/badge.css +6 -0
- package/src/components/badge/badge.props.ts +31 -0
- package/src/components/box/box.css +5 -0
- package/src/components/box/box.props.ts +7 -2
- package/src/components/button/Button.tsx +7 -1
- package/src/components/button/button.css +51 -23
- package/src/components/button/button.props.ts +27 -9
- package/src/components/card/Card.tsx +1 -1
- package/src/components/card/card.props.ts +10 -5
- package/src/components/checkbox/Checkbox.tsx +15 -29
- package/src/components/checkbox/checkbox.css +19 -20
- package/src/components/checkbox/checkbox.props.ts +11 -12
- package/src/components/code/code.props.ts +10 -3
- package/src/components/container/Container.tsx +5 -1
- package/src/components/container/container.css +4 -0
- package/src/components/container/container.props.ts +6 -2
- package/src/components/dialog/Dialog.tsx +139 -0
- package/src/components/dialog/dialog.css +49 -0
- package/src/components/dialog/dialog.props.ts +45 -0
- package/src/components/eyebrow/eyebrow.props.ts +6 -2
- package/src/components/flex/flex.css +5 -0
- package/src/components/flex/flex.props.ts +6 -2
- package/src/components/grid/grid.css +5 -0
- package/src/components/grid/grid.props.ts +14 -3
- package/src/components/h-stack/HStack.tsx +8 -14
- package/src/components/h-stack/hStack.props.ts +5 -13
- package/src/components/heading/heading.props.ts +8 -2
- package/src/components/hotkeys/Hotkeys.tsx +29 -0
- package/src/components/hotkeys/hotkeys.css +3 -0
- package/src/components/hotkeys/hotkeys.props.ts +15 -0
- package/src/components/icon/Icon.tsx +22 -11
- package/src/components/icon/icon.props.ts +7 -3
- package/src/components/icon-button/iconButton.props.ts +7 -2
- package/src/components/index.css +12 -1
- package/src/components/indicator/indicator.css +1 -1
- package/src/components/indicator/indicator.props.ts +6 -2
- package/src/components/indicator-stack/indicatorStack.props.ts +3 -1
- package/src/components/inline/inline.props.ts +6 -2
- package/src/components/kbd/KBD.tsx +33 -0
- package/src/components/kbd/kbd.css +6 -0
- package/src/components/kbd/kbd.props.ts +20 -0
- package/src/components/link/link.props.ts +4 -4
- package/src/components/list/list.props.ts +27 -9
- package/src/components/popover/Popover.tsx +85 -0
- package/src/components/popover/popover.css +21 -0
- package/src/components/popover/popover.props.ts +38 -0
- package/src/components/press-area/pressArea.props.ts +3 -1
- package/src/components/radio/Radio.tsx +10 -28
- package/src/components/radio/radio.css +17 -32
- package/src/components/radio/radio.props.ts +1 -19
- package/src/components/select/Select.tsx +41 -0
- package/src/components/select/select.css +67 -0
- package/src/components/select/select.props.ts +18 -0
- package/src/components/skip-to-content/skipToContent.props.ts +9 -3
- package/src/components/spinner/Spinner.tsx +2 -1
- package/src/components/spinner/spinner.props.ts +3 -0
- package/src/components/switch/Switch.tsx +9 -21
- package/src/components/switch/switch.css +22 -23
- package/src/components/switch/switch.props.ts +7 -11
- package/src/components/tabs/Tabs.tsx +186 -0
- package/src/components/tabs/tabs.css +34 -0
- package/src/components/tabs/tabs.props.ts +66 -0
- package/src/components/text/text.props.ts +6 -2
- package/src/components/text-area/TextArea.tsx +32 -0
- package/src/components/text-area/text-area.css +56 -0
- package/src/components/text-area/textArea.props.ts +35 -0
- package/src/components/text-input/TextInput.tsx +32 -0
- package/src/components/text-input/text-input.css +55 -0
- package/src/components/text-input/textInput.props.ts +42 -0
- package/src/components/tooltip/Tooltip.tsx +59 -55
- package/src/components/tooltip/tooltip.css +21 -40
- package/src/components/tooltip/tooltip.props.ts +24 -8
- package/src/components/tooltip-group/TooltipGroup.tsx +2 -5
- package/src/components/tooltip-group/tooltipGroup.props.ts +3 -1
- package/src/components/v-stack/VStack.tsx +8 -14
- package/src/components/v-stack/vStack.props.ts +5 -13
- package/src/components/visually-hidden/visuallyHidden.props.ts +6 -2
- package/src/css/classes/dynamic/height.css +2 -0
- package/src/css/classes/generic/display.css +8 -8
- package/src/css/classes/generic/placement.css +105 -86
- package/src/css/classes/local/animation.css +4 -0
- package/src/css/classes/local/field-sizing.css +3 -0
- package/src/css/classes/local/index.css +3 -1
- package/src/css/classes/local/text-trim.css +11 -4
- package/src/css/classes/local/top-anchor.css +4 -0
- package/src/css/classes/system/shadow.css +6 -6
- package/src/css/classes/system/typography.css +0 -4
- package/src/css/global/reset.css +12 -1
- package/src/css/tokens/semantic.css +7 -6
- package/src/css/tokens/surface.css +80 -12
- package/src/hooks/useIsClient.ts +10 -0
- package/src/index.ts +17 -2
- package/src/polyfills.ts +17 -0
- package/src/props/formElement.ts +34 -0
- package/src/props/layout.ts +3 -3
- package/src/props/tone.ts +13 -2
- package/src/types/Avatar.ts +14 -0
- package/src/types/Eyebrow.ts +1 -1
- package/src/types/FormElement.ts +2 -0
- package/src/types/Heading.ts +1 -1
- package/src/types/TextAlign.ts +1 -1
- package/src/types/Tone.ts +2 -0
- package/src/utils/getProps.ts +1 -1
- package/src/utils/mergeTriggerProps.ts +66 -0
- package/src/utils/renderPortal.tsx +14 -0
- package/src/version.ts +2 -2
- package/dist/_chunks-es/LazyRefractor.js +0 -20
- package/dist/_chunks-es/LazyRefractor.js.map +0 -1
- package/src/components/label/Label.tsx +0 -34
- package/src/components/label/label.css +0 -3
- package/src/components/label/label.props.ts +0 -19
- package/src/css/classes/local/tone.css +0 -75
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
.sui-Dialog {
|
|
2
|
+
/* Computed width is moderated by Dialog's size prop, which controls max-width */
|
|
3
|
+
width: calc(100dvw - 2rem);
|
|
4
|
+
max-height: calc(100dvh - 2rem);
|
|
5
|
+
transition:
|
|
6
|
+
display 150ms allow-discrete,
|
|
7
|
+
overlay 150ms allow-discrete,
|
|
8
|
+
opacity 150ms var(--timing-linear),
|
|
9
|
+
scale 150ms var(--timing-curve);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.sui-Dialog:not([open]) {
|
|
13
|
+
opacity: 0;
|
|
14
|
+
scale: 0.9;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.sui-Dialog[open] {
|
|
18
|
+
display: flex;
|
|
19
|
+
opacity: 1;
|
|
20
|
+
scale: 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.sui-Dialog::backdrop {
|
|
24
|
+
--dialog-backdrop: hsl(from var(--separator-high) h s l / var(--overlay-opacity));
|
|
25
|
+
background-color: var(--dialog-backdrop);
|
|
26
|
+
transition:
|
|
27
|
+
display 150ms allow-discrete,
|
|
28
|
+
overlay 150ms allow-discrete,
|
|
29
|
+
opacity 150ms var(--timing-linear);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.sui-Dialog:not([open])::backdrop {
|
|
33
|
+
opacity: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.sui-Dialog[open]::backdrop {
|
|
37
|
+
opacity: 1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@starting-style {
|
|
41
|
+
.sui-Dialog[open] {
|
|
42
|
+
opacity: 0;
|
|
43
|
+
scale: 0.9;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sui-Dialog[open]::backdrop {
|
|
47
|
+
opacity: 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {CONTAINER_SIZE, type ContainerSize} from '../../types/Container'
|
|
2
|
+
import {type PropDef} from '../../types/PropDef'
|
|
3
|
+
import type {Responsive} from '../../types/Responsive'
|
|
4
|
+
|
|
5
|
+
/** @beta */
|
|
6
|
+
export interface DialogProps extends Omit<React.ComponentProps<'dialog'>, 'open'> {
|
|
7
|
+
/**
|
|
8
|
+
* Text for the dialog heading.
|
|
9
|
+
* @remarks Recommended for accessibility. The component sets `aria-labelledby` to the heading when you give this prop.
|
|
10
|
+
*/
|
|
11
|
+
header?: string
|
|
12
|
+
/**
|
|
13
|
+
* A function to call alongside the native `close` event.
|
|
14
|
+
* @remarks Use it to set `open` back to `false`. It runs for every close cause: the Escape key, a backdrop click, the close button, or a programmatic close.
|
|
15
|
+
*/
|
|
16
|
+
onClose: React.ReactEventHandler<HTMLDialogElement>
|
|
17
|
+
/**
|
|
18
|
+
* Toggles the dialog's open state.
|
|
19
|
+
* @remarks `true` calls `showModal()` on the element. `false` calls `close()`.
|
|
20
|
+
*/
|
|
21
|
+
open?: boolean
|
|
22
|
+
/** Sets the max width of the dialog */
|
|
23
|
+
size?: Responsive<ContainerSize>
|
|
24
|
+
/** CSS length value used to set the Dialog’s distance from the top of the viewport; Dialog is centered if not provided */
|
|
25
|
+
topAnchor?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const dialogProps: Record<string, PropDef> = {
|
|
29
|
+
header: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
},
|
|
32
|
+
open: {
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
},
|
|
35
|
+
size: {
|
|
36
|
+
type: 'union',
|
|
37
|
+
className: 'container',
|
|
38
|
+
values: CONTAINER_SIZE,
|
|
39
|
+
},
|
|
40
|
+
topAnchor: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
className: 'top-anchor',
|
|
43
|
+
variable: '--top-anchor',
|
|
44
|
+
},
|
|
45
|
+
}
|
|
@@ -5,9 +5,13 @@ import type {Responsive} from '../../types/Responsive'
|
|
|
5
5
|
|
|
6
6
|
/** @public */
|
|
7
7
|
export interface EyebrowProps<T extends React.ElementType = 'span'> extends TypographyProps {
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* HTML element to render.
|
|
10
|
+
*/
|
|
9
11
|
as?: T
|
|
10
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Sets font size. Uses the same scale as Label.
|
|
14
|
+
*/
|
|
11
15
|
size?: Responsive<EyebrowSize>
|
|
12
16
|
}
|
|
13
17
|
|
|
@@ -8,9 +8,13 @@ import type {Responsive} from '../../types/Responsive'
|
|
|
8
8
|
/** @public */
|
|
9
9
|
export interface FlexProps<T extends React.ElementType = 'div'>
|
|
10
10
|
extends FlexParentProps, GapProps, LayoutProps {
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* HTML element or component to render.
|
|
13
|
+
*/
|
|
12
14
|
as?: T
|
|
13
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* CSS `display` property.
|
|
17
|
+
*/
|
|
14
18
|
display?: Responsive<DisplayFlex>
|
|
15
19
|
}
|
|
16
20
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {flexParentProps, type FlexParentProps} from '../../props/flexParent'
|
|
1
2
|
import {type GapProps, gapProps} from '../../props/gap'
|
|
2
3
|
import {type GridParentProps, gridParentProps} from '../../props/gridParent'
|
|
3
4
|
import {type LayoutProps, layoutProps} from '../../props/layout'
|
|
@@ -7,10 +8,18 @@ import type {Responsive} from '../../types/Responsive'
|
|
|
7
8
|
|
|
8
9
|
/** @public */
|
|
9
10
|
export interface GridProps<T extends React.ElementType = 'div'>
|
|
10
|
-
extends
|
|
11
|
-
|
|
11
|
+
extends
|
|
12
|
+
Pick<FlexParentProps, 'alignItems' | 'justifyContent'>,
|
|
13
|
+
GridParentProps,
|
|
14
|
+
GapProps,
|
|
15
|
+
LayoutProps {
|
|
16
|
+
/**
|
|
17
|
+
* HTML element or component to render.
|
|
18
|
+
*/
|
|
12
19
|
as?: T
|
|
13
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* CSS `display` property.
|
|
22
|
+
*/
|
|
14
23
|
display?: Responsive<DisplayGrid>
|
|
15
24
|
}
|
|
16
25
|
|
|
@@ -23,6 +32,8 @@ export const gridProps: Record<string, PropDef> = {
|
|
|
23
32
|
className: 'display',
|
|
24
33
|
values: DISPLAY_GRID,
|
|
25
34
|
},
|
|
35
|
+
alignItems: flexParentProps['alignItems'] as PropDef,
|
|
36
|
+
justifyContent: flexParentProps['justifyContent'] as PropDef,
|
|
26
37
|
...gridParentProps,
|
|
27
38
|
...gapProps,
|
|
28
39
|
...layoutProps,
|
|
@@ -1,33 +1,27 @@
|
|
|
1
1
|
import clsx from 'clsx'
|
|
2
2
|
import type {ComponentPropsWithRef, ElementType} from 'react'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {type ComponentProps} from '../../utils/getProps'
|
|
5
5
|
import {suffixClassName} from '../../utils/suffixClassName'
|
|
6
6
|
import {Flex} from '../flex/Flex'
|
|
7
|
-
import {type HStackProps
|
|
7
|
+
import {type HStackProps} from './hStack.props'
|
|
8
8
|
|
|
9
9
|
const hStackClassName = suffixClassName('sui-HStack')
|
|
10
10
|
|
|
11
11
|
/** @public */
|
|
12
|
-
export function HStack<T extends ElementType = 'div'>(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const Component = as || 'div'
|
|
17
|
-
|
|
12
|
+
export function HStack<T extends ElementType = 'div'>({
|
|
13
|
+
className,
|
|
14
|
+
...props
|
|
15
|
+
}: HStackProps<T> & Omit<ComponentPropsWithRef<T>, keyof HStackProps<T>>) {
|
|
18
16
|
return (
|
|
19
17
|
<Flex
|
|
20
|
-
as={Component}
|
|
21
18
|
className={clsx(hStackClassName, className)}
|
|
22
|
-
style={style}
|
|
23
19
|
data-ui="HStack"
|
|
24
20
|
display="inline-flex"
|
|
25
21
|
alignItems="center"
|
|
26
22
|
flexWrap="wrap"
|
|
27
|
-
{...
|
|
28
|
-
|
|
29
|
-
{children}
|
|
30
|
-
</Flex>
|
|
23
|
+
{...(props as ComponentProps)}
|
|
24
|
+
/>
|
|
31
25
|
)
|
|
32
26
|
}
|
|
33
27
|
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {type PropDef} from '../../types/PropDef'
|
|
1
|
+
import type {FlexProps} from '../flex/flex.props'
|
|
3
2
|
|
|
4
3
|
/** @public */
|
|
5
|
-
export interface HStackProps<T extends React.ElementType = 'div'> extends Pick<
|
|
6
|
-
|
|
7
|
-
as
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const hStackProps: Record<string, PropDef> = {
|
|
11
|
-
as: {
|
|
12
|
-
type: 'string',
|
|
13
|
-
},
|
|
14
|
-
gap: gapProps['gap'] as PropDef,
|
|
15
|
-
}
|
|
4
|
+
export interface HStackProps<T extends React.ElementType = 'div'> extends Pick<
|
|
5
|
+
FlexProps<T>,
|
|
6
|
+
'as' | 'gap'
|
|
7
|
+
> {}
|
|
@@ -5,9 +5,15 @@ import type {Responsive} from '../../types/Responsive'
|
|
|
5
5
|
|
|
6
6
|
/** @public */
|
|
7
7
|
export interface HeadingProps extends TypographyProps {
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Semantic heading element to render.
|
|
10
|
+
* @remarks Always set this explicitly.
|
|
11
|
+
*/
|
|
9
12
|
as?: HeadingTag
|
|
10
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Sets font size.
|
|
15
|
+
* @remarks Independent of `as`.
|
|
16
|
+
*/
|
|
11
17
|
size?: Responsive<HeadingSize>
|
|
12
18
|
}
|
|
13
19
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
|
|
3
|
+
import {getProps} from '../../utils/getProps'
|
|
4
|
+
import {suffixClassName} from '../../utils/suffixClassName'
|
|
5
|
+
import {KBD} from '../kbd/KBD'
|
|
6
|
+
import {type HotkeysProps, hotkeysProps} from './hotkeys.props'
|
|
7
|
+
|
|
8
|
+
const hotkeysClassName = suffixClassName('sui-Hotkeys')
|
|
9
|
+
|
|
10
|
+
/** @alpha */
|
|
11
|
+
export function Hotkeys({keys, ...props}: HotkeysProps) {
|
|
12
|
+
const {className, style, ...rest} = getProps(props, hotkeysProps)
|
|
13
|
+
|
|
14
|
+
if (!keys || keys.length === 0) {
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const hotkeysClasses = clsx(hotkeysClassName, 'sui-display-inline-flex')
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<kbd className={clsx(hotkeysClasses, className)} style={style} data-ui="Hotkeys" {...rest}>
|
|
22
|
+
{keys.map((key) => (
|
|
23
|
+
<KBD key={key} text={key} />
|
|
24
|
+
))}
|
|
25
|
+
</kbd>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type {HotkeysProps}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {type PropDef} from '../../types/PropDef'
|
|
2
|
+
|
|
3
|
+
/** @public */
|
|
4
|
+
export interface HotkeysProps extends React.ComponentProps<'kbd'> {
|
|
5
|
+
/**
|
|
6
|
+
* The keys in the shortcut, in order. Each one renders as a KBD.
|
|
7
|
+
*/
|
|
8
|
+
keys?: string[]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const hotkeysProps: Record<string, PropDef> = {
|
|
12
|
+
keys: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
},
|
|
15
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import clsx from 'clsx'
|
|
2
|
+
import {cloneElement, createElement, isValidElement, type ComponentType, type SVGProps} from 'react'
|
|
2
3
|
|
|
3
4
|
import {getProps} from '../../utils/getProps'
|
|
4
5
|
import {suffixClassName} from '../../utils/suffixClassName'
|
|
@@ -7,18 +8,28 @@ import {type IconProps, iconProps} from './icon.props'
|
|
|
7
8
|
const iconClassName = suffixClassName('sui-Icon')
|
|
8
9
|
|
|
9
10
|
/** @public */
|
|
10
|
-
export function Icon({size = 2, ...props}: IconProps) {
|
|
11
|
-
const {className, style,
|
|
11
|
+
export function Icon({icon, size = 2, ...props}: IconProps) {
|
|
12
|
+
const {className, style, ...rest} = getProps({size, ...props}, iconProps)
|
|
13
|
+
const iconElement = isValidElement(icon) ? icon : null
|
|
14
|
+
const ariaLabel =
|
|
15
|
+
props['aria-label'] || (iconElement ? iconElement.props['aria-label'] : undefined)
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const svgProps = {
|
|
18
|
+
'className': clsx(
|
|
19
|
+
iconClassName,
|
|
20
|
+
'sui-display-block',
|
|
21
|
+
className,
|
|
22
|
+
iconElement ? iconElement.props.className : undefined,
|
|
23
|
+
),
|
|
24
|
+
'style': iconElement ? {...iconElement.props.style, ...style} : style,
|
|
25
|
+
'data-ui': 'Icon',
|
|
26
|
+
'aria-hidden': ariaLabel ? undefined : true,
|
|
27
|
+
...rest,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return iconElement
|
|
31
|
+
? cloneElement(iconElement, svgProps)
|
|
32
|
+
: createElement(icon as ComponentType<SVGProps<SVGSVGElement>>, svgProps)
|
|
22
33
|
}
|
|
23
34
|
|
|
24
35
|
export type {IconProps}
|
|
@@ -10,9 +10,13 @@ import type {Responsive} from '../../types/Responsive'
|
|
|
10
10
|
/** @public */
|
|
11
11
|
export interface IconProps
|
|
12
12
|
extends ComponentProps<'svg'>, Pick<TypographyProps, 'muted'>, MarginProps, ToneProps {
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The icon component to render.
|
|
15
|
+
*/
|
|
16
|
+
icon: React.ComponentType<SVGProps<SVGSVGElement>> | React.ReactElement<SVGProps<SVGSVGElement>>
|
|
17
|
+
/**
|
|
18
|
+
* Sets icon size.
|
|
19
|
+
*/
|
|
16
20
|
size?: Responsive<IconSize>
|
|
17
21
|
}
|
|
18
22
|
|
|
@@ -9,9 +9,14 @@ export interface IconButtonProps<T extends React.ElementType = 'button'> extends
|
|
|
9
9
|
ButtonProps<T>,
|
|
10
10
|
'as' | 'density' | 'level' | 'loading' | 'tone'
|
|
11
11
|
> {
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Accessible name for the button.
|
|
14
|
+
* @remarks Because IconButtons have no visible text, this is required.
|
|
15
|
+
*/
|
|
13
16
|
'aria-label': string
|
|
14
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Icon to render.
|
|
19
|
+
*/
|
|
15
20
|
'icon': React.ComponentType<SVGProps<SVGSVGElement>>
|
|
16
21
|
}
|
|
17
22
|
|
package/src/components/index.css
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
|
+
@import './avatar/avatar.css';
|
|
2
|
+
@import './avatar-counter/avatar-counter.css';
|
|
3
|
+
@import './avatar-stack/avatar-stack.css';
|
|
4
|
+
@import './badge/badge.css';
|
|
1
5
|
@import './box/box.css';
|
|
2
6
|
@import './button/button.css';
|
|
3
7
|
@import './card/card.css';
|
|
4
8
|
@import './checkbox/checkbox.css';
|
|
5
9
|
@import './code/code.css';
|
|
6
10
|
@import './container/container.css';
|
|
11
|
+
@import './dialog/dialog.css';
|
|
7
12
|
@import './eyebrow/eyebrow.css';
|
|
8
13
|
@import './flex/flex.css';
|
|
9
14
|
@import './grid/grid.css';
|
|
10
15
|
@import './heading/heading.css';
|
|
16
|
+
@import './hotkeys/hotkeys.css';
|
|
11
17
|
@import './icon/icon.css';
|
|
12
18
|
@import './indicator/indicator.css';
|
|
13
19
|
@import './indicator-stack/indicator-stack.css';
|
|
14
20
|
@import './inline/inline.css';
|
|
15
|
-
@import './
|
|
21
|
+
@import './kbd/kbd.css';
|
|
16
22
|
@import './link/link.css';
|
|
17
23
|
@import './list/list.css';
|
|
24
|
+
@import './popover/popover.css';
|
|
18
25
|
@import './press-area/press-area.css';
|
|
19
26
|
@import './radio/radio.css';
|
|
27
|
+
@import './select/select.css';
|
|
20
28
|
@import './spinner/spinner.css';
|
|
21
29
|
@import './skip-to-content/skip-to-content.css';
|
|
22
30
|
@import './switch/switch.css';
|
|
31
|
+
@import './tabs/tabs.css';
|
|
23
32
|
@import './text/text.css';
|
|
33
|
+
@import './text-area/text-area.css';
|
|
34
|
+
@import './text-input/text-input.css';
|
|
24
35
|
@import './tooltip/tooltip.css';
|
|
25
36
|
@import './visually-hidden/visually-hidden.css';
|
|
@@ -3,9 +3,13 @@ import {type PropDef} from '../../types/PropDef'
|
|
|
3
3
|
|
|
4
4
|
/** @beta */
|
|
5
5
|
export interface IndicatorProps<T extends React.ElementType = 'span'> extends ToneProps {
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* HTML element to render.
|
|
8
|
+
*/
|
|
7
9
|
as?: T
|
|
8
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Accessible label.
|
|
12
|
+
*/
|
|
9
13
|
label?: string
|
|
10
14
|
}
|
|
11
15
|
|
|
@@ -7,9 +7,13 @@ import {SPACE, type SpaceInherit} from '../../types/Space'
|
|
|
7
7
|
/** @deprecated Use HStack component instead */
|
|
8
8
|
/** @public */
|
|
9
9
|
export interface InlineProps<T extends React.ElementType = 'div'> extends PaddingProps {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* HTML element or component to render.
|
|
12
|
+
*/
|
|
11
13
|
as?: T
|
|
12
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Space between children.
|
|
16
|
+
*/
|
|
13
17
|
gap?: Responsive<SpaceInherit>
|
|
14
18
|
}
|
|
15
19
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
|
|
3
|
+
import {getProps} from '../../utils/getProps'
|
|
4
|
+
import {suffixClassName} from '../../utils/suffixClassName'
|
|
5
|
+
import {Text} from '../text/Text'
|
|
6
|
+
import {type KBDProps, kbdProps} from './kbd.props'
|
|
7
|
+
|
|
8
|
+
const kbdClassName = suffixClassName('sui-KBD')
|
|
9
|
+
|
|
10
|
+
/** @alpha */
|
|
11
|
+
export function KBD(props: KBDProps) {
|
|
12
|
+
const {className, style, text, ...rest} = getProps(props, kbdProps)
|
|
13
|
+
|
|
14
|
+
const kbdClasses = clsx(kbdClassName, 'sui-p1 sui-radius2 sui-display-inline-block')
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Text
|
|
18
|
+
as="kbd"
|
|
19
|
+
className={clsx(kbdClasses, className)}
|
|
20
|
+
style={style}
|
|
21
|
+
data-ui="KBD"
|
|
22
|
+
size={0}
|
|
23
|
+
weight="semibold"
|
|
24
|
+
muted
|
|
25
|
+
trim
|
|
26
|
+
{...rest}
|
|
27
|
+
>
|
|
28
|
+
{text}
|
|
29
|
+
</Text>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type {KBDProps}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {type PropDef} from '../../types/PropDef'
|
|
2
|
+
|
|
3
|
+
/** @public */
|
|
4
|
+
export interface KBDProps extends React.ComponentProps<'kbd'> {
|
|
5
|
+
/**
|
|
6
|
+
* Sets KBD's key label.
|
|
7
|
+
*/
|
|
8
|
+
text?: string
|
|
9
|
+
/**
|
|
10
|
+
* Not accepted.
|
|
11
|
+
* @remarks Pass the key label via `text`.
|
|
12
|
+
*/
|
|
13
|
+
children?: never
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const kbdProps: Record<string, PropDef> = {
|
|
17
|
+
text: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
},
|
|
20
|
+
}
|
|
@@ -2,12 +2,12 @@ import {type PropDef} from '../../types/PropDef'
|
|
|
2
2
|
|
|
3
3
|
/** @beta */
|
|
4
4
|
export interface LinkProps extends React.ComponentProps<'a'> {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Sets the link to `target="_blank"` and `rel="noopener noreferrer"`.
|
|
7
|
+
*/
|
|
6
8
|
openInNewTab?: boolean
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @defaultValue true
|
|
10
|
+
* Underlines the link.
|
|
11
11
|
*/
|
|
12
12
|
underlined?: boolean
|
|
13
13
|
}
|
|
@@ -11,7 +11,9 @@ import type {Responsive} from '../../types/Responsive'
|
|
|
11
11
|
|
|
12
12
|
/** @beta */
|
|
13
13
|
export interface ListProps<T extends ListTag = 'ul'> extends Pick<GapProps, 'gap'> {
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* HTML element to render.
|
|
16
|
+
*/
|
|
15
17
|
as?: T
|
|
16
18
|
}
|
|
17
19
|
|
|
@@ -24,11 +26,17 @@ export const listProps: Record<string, PropDef> = {
|
|
|
24
26
|
|
|
25
27
|
/** @beta */
|
|
26
28
|
export interface ListItemProps extends React.ComponentProps<'li'> {
|
|
27
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Sets horizontal padding, gap, and minimum row height together.
|
|
31
|
+
*/
|
|
28
32
|
density?: Responsive<Density>
|
|
29
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Slot at the left edge of the row.
|
|
35
|
+
*/
|
|
30
36
|
start?: React.ReactNode
|
|
31
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Slot at the right edge of the row.
|
|
39
|
+
*/
|
|
32
40
|
end?: React.ReactNode
|
|
33
41
|
}
|
|
34
42
|
|
|
@@ -73,9 +81,13 @@ export const listItemProps: Record<string, PropDef> = {
|
|
|
73
81
|
|
|
74
82
|
/** @beta */
|
|
75
83
|
export interface ListButtonItemProps<T extends React.ElementType = 'button'> extends ListItemProps {
|
|
76
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Element or component to render for the press target.
|
|
86
|
+
*/
|
|
77
87
|
as?: InteractiveAs<T>
|
|
78
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Marks the row as the current selection.
|
|
90
|
+
*/
|
|
79
91
|
selected?: boolean
|
|
80
92
|
}
|
|
81
93
|
|
|
@@ -91,11 +103,17 @@ export const listButtonItemProps: Record<string, PropDef> = {
|
|
|
91
103
|
|
|
92
104
|
/** @beta */
|
|
93
105
|
export interface ListItemTextProps<T extends React.ElementType = 'div'> {
|
|
94
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* HTML element to render.
|
|
108
|
+
*/
|
|
95
109
|
as?: T
|
|
96
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* Main label.
|
|
112
|
+
*/
|
|
97
113
|
title?: React.ReactNode
|
|
98
|
-
/**
|
|
114
|
+
/**
|
|
115
|
+
* Text below the title.
|
|
116
|
+
*/
|
|
99
117
|
subtitle?: React.ReactNode
|
|
100
118
|
}
|
|
101
119
|
|