@sanity/ui 5.0.0-alpha.24 → 5.0.0-alpha.26
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/index.d.ts +145 -147
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +256 -179
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/avatar/avatar.props.ts +4 -2
- package/src/components/avatar-counter/avatarCounter.props.ts +4 -2
- package/src/components/avatar-stack/avatarStack.props.ts +4 -2
- package/src/components/badge/Badge.tsx +2 -5
- package/src/components/badge/badge.props.ts +15 -15
- package/src/components/box/Box.tsx +2 -5
- package/src/components/box/box.props.ts +18 -12
- package/src/components/button/Button.tsx +2 -2
- package/src/components/button/button.props.ts +49 -43
- package/src/components/card/Card.tsx +2 -2
- package/src/components/card/card.props.ts +19 -13
- package/src/components/checkbox/Checkbox.tsx +3 -2
- package/src/components/checkbox/checkbox.props.ts +4 -2
- package/src/components/code/code.props.ts +5 -3
- package/src/components/container/Container.tsx +2 -2
- package/src/components/container/container.props.ts +17 -11
- package/src/components/dialog/Dialog.tsx +13 -7
- package/src/components/dialog/dialog.props.ts +11 -3
- package/src/components/divider/divider.props.ts +4 -2
- package/src/components/eyebrow/Eyebrow.tsx +2 -5
- package/src/components/eyebrow/eyebrow.props.ts +19 -12
- package/src/components/flex/Flex.tsx +2 -5
- package/src/components/flex/flex.props.ts +19 -12
- package/src/components/grid/Grid.tsx +2 -5
- package/src/components/grid/grid.props.ts +20 -16
- package/src/components/h-stack/HStack.tsx +2 -5
- package/src/components/h-stack/hStack.props.ts +7 -4
- package/src/components/heading/Heading.tsx +2 -5
- package/src/components/heading/heading.props.ts +18 -13
- package/src/components/hotkeys/hotkeys.props.ts +4 -2
- package/src/components/icon/icon.props.ts +3 -3
- package/src/components/icon-button/IconButton.tsx +2 -4
- package/src/components/icon-button/iconButton.props.ts +17 -17
- package/src/components/index.css +1 -0
- package/src/components/indicator/Indicator.tsx +2 -2
- package/src/components/indicator/indicator.props.ts +17 -11
- package/src/components/indicator-stack/IndicatorStack.tsx +2 -4
- package/src/components/indicator-stack/indicatorStack.props.ts +13 -7
- package/src/components/inline/Inline.tsx +2 -2
- package/src/components/inline/inline.props.ts +17 -11
- package/src/components/kbd/kbd.props.ts +4 -2
- package/src/components/link/link.props.ts +4 -2
- package/src/components/list/List.tsx +47 -97
- package/src/components/list/list.css +28 -9
- package/src/components/list/list.props.ts +59 -68
- package/src/components/popover/popover.props.ts +7 -5
- package/src/components/press-area/PressArea.tsx +2 -4
- package/src/components/press-area/press-area.css +9 -3
- package/src/components/press-area/pressArea.props.ts +13 -7
- package/src/components/radio/radio.props.ts +2 -1
- package/src/components/search-input/SearchInput.tsx +90 -0
- package/src/components/search-input/search-input.css +125 -0
- package/src/components/search-input/searchInput.props.ts +18 -0
- package/src/components/select/Select.tsx +6 -1
- package/src/components/select/select.css +10 -12
- package/src/components/select/select.props.ts +4 -2
- package/src/components/skip-to-content/skipToContent.props.ts +4 -2
- package/src/components/spinner/spinner.props.ts +4 -2
- package/src/components/switch/switch.props.ts +4 -2
- package/src/components/tabs/tabs.props.ts +8 -9
- package/src/components/text/Text.tsx +2 -5
- package/src/components/text/text.props.ts +19 -12
- package/src/components/text-area/textArea.props.ts +4 -5
- package/src/components/text-input/textInput.props.ts +5 -3
- package/src/components/tooltip/tooltip.props.ts +7 -5
- package/src/components/tooltip-group/TooltipGroup.tsx +8 -9
- package/src/components/tooltip-group/tooltipGroup.props.ts +13 -7
- package/src/components/v-stack/VStack.tsx +2 -5
- package/src/components/v-stack/vStack.props.ts +7 -4
- package/src/components/visually-hidden/VisuallyHidden.tsx +2 -4
- package/src/components/visually-hidden/visuallyHidden.props.ts +18 -12
- package/src/index.ts +1 -0
- package/src/types/Interactive.ts +3 -1
- package/src/types/Polymorphic.ts +9 -0
- package/src/types/Tone.ts +1 -1
- package/src/utils/composeRefs.test.ts +130 -0
- package/src/utils/composeRefs.ts +52 -0
- package/src/utils/getProps.test.ts +18 -0
- package/src/utils/getProps.ts +31 -16
- package/src/version.ts +2 -2
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
.sui-SearchInput {
|
|
2
|
+
--background-color: var(--backdrop);
|
|
3
|
+
--border-color: var(--separator-high);
|
|
4
|
+
--color: var(--foreground-high);
|
|
5
|
+
background-color: var(--background-color);
|
|
6
|
+
border: 1px solid var(--border-color);
|
|
7
|
+
font: var(--form-element-text);
|
|
8
|
+
color: var(--color);
|
|
9
|
+
/* Use text-indent to clear the search icon */
|
|
10
|
+
text-indent: var(--space-4);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.sui-SearchInput::placeholder {
|
|
14
|
+
color: oklch(from var(--color) l c h / var(--placeholder-opacity));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Hide webkit default clear button */
|
|
18
|
+
.sui-SearchInput::-webkit-search-cancel-button,
|
|
19
|
+
.sui-SearchInput::-webkit-search-decoration {
|
|
20
|
+
-webkit-appearance: none;
|
|
21
|
+
appearance: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Search icon
|
|
26
|
+
*/
|
|
27
|
+
.sui-SearchInput-Icon {
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
top: calc(anchor(top));
|
|
30
|
+
bottom: calc(anchor(bottom));
|
|
31
|
+
left: calc(anchor(left) + 1px);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.sui-SearchInput-Icon svg {
|
|
35
|
+
--background-color: var(--backdrop);
|
|
36
|
+
background-color: var(--background-color);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Shift search icon's left inset when SearchInput uses loose density */
|
|
40
|
+
.sui-SearchInput.sui-px3 + .sui-SearchInput-Icon {
|
|
41
|
+
left: calc(anchor(left) + 3px);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Loading icon (replaces search icon in icon slot when loading)
|
|
46
|
+
*/
|
|
47
|
+
.sui-SearchInput[aria-busy="true"] + .sui-SearchInput-Icon svg {
|
|
48
|
+
background: transparent;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Custom clear button
|
|
53
|
+
*/
|
|
54
|
+
.sui-SearchInput-Clear {
|
|
55
|
+
top: calc(anchor(top));
|
|
56
|
+
bottom: calc(anchor(bottom));
|
|
57
|
+
right: calc(anchor(right) - 3px);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Hide clear button when SearchInput has no value (placeholder shown) or is read-only */
|
|
61
|
+
.sui-SearchInput:is(:placeholder-shown, :read-only) + .sui-SearchInput-Icon + .sui-SearchInput-Clear {
|
|
62
|
+
display: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Override SearchInput’s padding-right (set by the density prop) so input value clears
|
|
66
|
+
* the space occupied by the clear button when shown */
|
|
67
|
+
.sui-SearchInput:not(:placeholder-shown, :read-only) {
|
|
68
|
+
padding-right: 25px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.sui-SearchInput-Clear [data-ui="PressArea"] {
|
|
72
|
+
inline-size: 25px;
|
|
73
|
+
aspect-ratio: 1;
|
|
74
|
+
border-radius: var(--radius-1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.sui-SearchInput-Clear [data-ui="PressArea"] svg {
|
|
78
|
+
--background-color: var(--backdrop);
|
|
79
|
+
background-color: var(--background-color);
|
|
80
|
+
border-radius: var(--radius-2);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.sui-SearchInput-Clear [data-ui="PressArea"]:hover svg {
|
|
84
|
+
--background-color: var(--background-high);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.sui-SearchInput-Clear [data-ui="PressArea"]:focus-visible {
|
|
88
|
+
outline: var(--focus-outline);
|
|
89
|
+
outline-offset: var(--focus-offset);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Hover - uses relative border/background colours to darken/lighten
|
|
94
|
+
*/
|
|
95
|
+
.sui-SearchInput:hover {
|
|
96
|
+
border-color: light-dark(
|
|
97
|
+
oklch(from var(--border-color) calc(l - var(--hover-lightness-delta)) c h),
|
|
98
|
+
oklch(from var(--border-color) calc(l + var(--hover-lightness-delta)) c h)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Disabled, read only
|
|
104
|
+
*/
|
|
105
|
+
.sui-SearchInput:is(:disabled, :read-only) {
|
|
106
|
+
--background-color: var(--inert-background);
|
|
107
|
+
--border-color: var(--separator-low);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.sui-SearchInput:disabled {
|
|
111
|
+
--color: var(--inert-foreground);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.sui-SearchInput:is(:disabled, :read-only) + .sui-SearchInput-Icon svg {
|
|
115
|
+
--background-color: transparent;
|
|
116
|
+
color: var(--inert-foreground);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Focus
|
|
121
|
+
*/
|
|
122
|
+
.sui-SearchInput:focus-visible {
|
|
123
|
+
outline: var(--focus-outline);
|
|
124
|
+
outline-offset: var(--focus-offset);
|
|
125
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type {ComponentProps} from 'react'
|
|
2
|
+
|
|
3
|
+
import {formElementDensityProps, type FormElementDensityProps} from '../../props/formElement'
|
|
4
|
+
import {type PropDef} from '../../types/PropDef'
|
|
5
|
+
|
|
6
|
+
/** @public */
|
|
7
|
+
export interface SearchInputProps
|
|
8
|
+
extends FormElementDensityProps, Omit<ComponentProps<'input'>, 'type'> {
|
|
9
|
+
/* True when search results are pending */
|
|
10
|
+
loading?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const searchInputProps: Record<string, PropDef> = {
|
|
14
|
+
loading: {
|
|
15
|
+
type: 'boolean',
|
|
16
|
+
},
|
|
17
|
+
...formElementDensityProps,
|
|
18
|
+
}
|
|
@@ -8,6 +8,7 @@ import {Icon} from '../icon/Icon'
|
|
|
8
8
|
import {type SelectProps, selectProps} from './select.props'
|
|
9
9
|
|
|
10
10
|
const selectClassName = suffixClassName('sui-Select')
|
|
11
|
+
const selectIconClassName = suffixClassName('sui-Select-Icon')
|
|
11
12
|
|
|
12
13
|
/** @public */
|
|
13
14
|
export function Select({density = 'regular', hasError = false, ...props}: SelectProps) {
|
|
@@ -31,7 +32,11 @@ export function Select({density = 'regular', hasError = false, ...props}: Select
|
|
|
31
32
|
>
|
|
32
33
|
{children}
|
|
33
34
|
</select>
|
|
34
|
-
<div
|
|
35
|
+
<div
|
|
36
|
+
className={clsx(selectIconClassName, iconClasses)}
|
|
37
|
+
data-ui="Select-Icon"
|
|
38
|
+
style={{positionAnchor: anchorName}}
|
|
39
|
+
>
|
|
35
40
|
<Icon icon={SelectIcon} size={1} />
|
|
36
41
|
</div>
|
|
37
42
|
</>
|
|
@@ -8,16 +8,17 @@
|
|
|
8
8
|
color: var(--color);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
--background-color: var(--backdrop);
|
|
13
|
-
background-color: var(--background-color);
|
|
11
|
+
.sui-Select-Icon {
|
|
14
12
|
pointer-events: none;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
bottom: calc(anchor(bottom) + 1px);
|
|
13
|
+
top: calc(anchor(top));
|
|
14
|
+
bottom: calc(anchor(bottom));
|
|
18
15
|
right: calc(anchor(right) + 2px);
|
|
19
16
|
}
|
|
20
17
|
|
|
18
|
+
.sui-Select-Icon svg {
|
|
19
|
+
--background-color: var(--backdrop);
|
|
20
|
+
background-color: var(--background-color);
|
|
21
|
+
}
|
|
21
22
|
/**
|
|
22
23
|
* Error
|
|
23
24
|
*/
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
--color: var(--error-foreground);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
.sui-Select[aria-invalid="true"] +
|
|
30
|
+
.sui-Select[aria-invalid="true"] + .sui-Select-Icon svg {
|
|
30
31
|
color: var(--error-foreground);
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -50,11 +51,8 @@
|
|
|
50
51
|
pointer-events: none;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
.sui-Select:disabled +
|
|
54
|
-
--background-color:
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.sui-Select:disabled + [data-ui="Select-icon"] svg {
|
|
54
|
+
.sui-Select:disabled + .sui-Select-Icon svg {
|
|
55
|
+
--background-color: transparent;
|
|
58
56
|
color: var(--inert-foreground);
|
|
59
57
|
}
|
|
60
58
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type {ComponentProps} from 'react'
|
|
2
|
+
|
|
1
3
|
import {formElementDensityProps, type FormElementDensityProps} from '../../props/formElement'
|
|
2
|
-
import
|
|
4
|
+
import type {PropDef} from '../../types/PropDef'
|
|
3
5
|
|
|
4
6
|
/** @public */
|
|
5
|
-
export interface SelectProps extends
|
|
7
|
+
export interface SelectProps extends ComponentProps<'select'>, FormElementDensityProps {
|
|
6
8
|
/**
|
|
7
9
|
* Used to trigger styling for invalid states.
|
|
8
10
|
* @remarks Use when form validation fails. Pair with a visible error message.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type {ComponentProps} from 'react'
|
|
2
|
+
|
|
3
|
+
import type {PropDef} from '../../types/PropDef'
|
|
2
4
|
|
|
3
5
|
/** @beta */
|
|
4
|
-
export interface SkipToContentProps extends
|
|
6
|
+
export interface SkipToContentProps extends ComponentProps<'a'> {
|
|
5
7
|
/**
|
|
6
8
|
* Same-page fragment to jump to.
|
|
7
9
|
* @remarks Note: The hash character # is required for proper linking.
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type {ComponentProps} from 'react'
|
|
2
|
+
|
|
1
3
|
import {ICON_SIZE, type IconSize} from '../../types/Icon'
|
|
2
|
-
import
|
|
4
|
+
import type {PropDef} from '../../types/PropDef'
|
|
3
5
|
import type {Responsive} from '../../types/Responsive'
|
|
4
6
|
|
|
5
7
|
/** @public */
|
|
6
|
-
export interface SpinnerProps extends
|
|
8
|
+
export interface SpinnerProps extends ComponentProps<'svg'> {
|
|
7
9
|
/**
|
|
8
10
|
* Size of the spinner icon.
|
|
9
11
|
*/
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type {ComponentProps} from 'react'
|
|
2
|
+
|
|
3
|
+
import type {PropDef} from '../../types/PropDef'
|
|
2
4
|
|
|
3
5
|
/** @beta */
|
|
4
|
-
export interface SwitchProps extends
|
|
6
|
+
export interface SwitchProps extends ComponentProps<'input'> {
|
|
5
7
|
/**
|
|
6
8
|
* Applies error styling to the switch track for invalid states.
|
|
7
9
|
* @remarks Use when form validation fails. Pair with a visible error message.
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type {ComponentProps, ReactNode, ElementType} from 'react'
|
|
2
|
+
|
|
1
3
|
import type {LayoutProps} from '../../props/layout'
|
|
2
4
|
import {toneProps, type ToneProps} from '../../props/tone'
|
|
3
|
-
import
|
|
5
|
+
import type {PropDef} from '../../types/PropDef'
|
|
4
6
|
|
|
5
7
|
/** @public */
|
|
6
|
-
export interface TabsProps extends
|
|
8
|
+
export interface TabsProps extends ComponentProps<'div'> {
|
|
7
9
|
/** The `value` of the active Tabs.Tab */
|
|
8
10
|
value: string
|
|
9
11
|
/** An updater function to set `value` - will be invoked with the `value` of the selected Tabs.Tab */
|
|
@@ -22,17 +24,15 @@ type TabsListLabelProps =
|
|
|
22
24
|
| {'aria-label': string; 'aria-labelledby'?: never}
|
|
23
25
|
|
|
24
26
|
/** @public */
|
|
25
|
-
export type TabsListProps = Omit<
|
|
27
|
+
export type TabsListProps = Omit<ComponentProps<'div'>, 'id' | 'role'> & TabsListLabelProps
|
|
26
28
|
|
|
27
29
|
export const tabsListProps: Record<string, PropDef> = {}
|
|
28
30
|
|
|
29
31
|
/** @public */
|
|
30
32
|
export interface TabProps
|
|
31
|
-
extends
|
|
32
|
-
Omit<React.ComponentProps<'button'>, 'aria-disabled' | 'disabled' | 'id' | 'role'>,
|
|
33
|
-
ToneProps {
|
|
33
|
+
extends Omit<ComponentProps<'button'>, 'aria-disabled' | 'disabled' | 'id' | 'role'>, ToneProps {
|
|
34
34
|
/** Optional icon for the tab */
|
|
35
|
-
icon?:
|
|
35
|
+
icon?: ElementType | ReactNode
|
|
36
36
|
/** Text label to display in the tab */
|
|
37
37
|
label: string
|
|
38
38
|
/** Unique string used to identify this tab and its matching Tabs.Panel */
|
|
@@ -53,8 +53,7 @@ export const tabProps: Record<string, PropDef> = {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/** @public */
|
|
56
|
-
export interface TabsPanelProps
|
|
57
|
-
extends Omit<React.ComponentProps<'div'>, 'id' | 'role'>, LayoutProps {
|
|
56
|
+
export interface TabsPanelProps extends Omit<ComponentProps<'div'>, 'id' | 'role'>, LayoutProps {
|
|
58
57
|
/** Unique string used to identify this panel and its matching Tabs.Tab */
|
|
59
58
|
value: string
|
|
60
59
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx from 'clsx'
|
|
2
|
-
import type {
|
|
2
|
+
import type {ElementType} from 'react'
|
|
3
3
|
|
|
4
4
|
import {getProps} from '../../utils/getProps'
|
|
5
5
|
import {suffixClassName} from '../../utils/suffixClassName'
|
|
@@ -8,10 +8,7 @@ import {type TextProps, textProps} from './text.props'
|
|
|
8
8
|
const textClassName = suffixClassName('sui-Text')
|
|
9
9
|
|
|
10
10
|
/** @public */
|
|
11
|
-
export function Text<T extends ElementType = 'span'>({
|
|
12
|
-
size = 2,
|
|
13
|
-
...props
|
|
14
|
-
}: TextProps<T> & Omit<ComponentPropsWithRef<T>, keyof TextProps<T>>) {
|
|
11
|
+
export function Text<T extends ElementType = 'span'>({size = 2, ...props}: TextProps<T>) {
|
|
15
12
|
const {as, children, className, style, ...rest} = getProps({size, ...props}, textProps)
|
|
16
13
|
const Component = as || 'span'
|
|
17
14
|
|
|
@@ -1,22 +1,29 @@
|
|
|
1
|
+
import type {ElementType} from 'react'
|
|
2
|
+
|
|
1
3
|
import {marginProps, type MarginProps} from '../../props/margin'
|
|
2
4
|
import {toneProps, type ToneProps} from '../../props/tone'
|
|
3
5
|
import {type TypographyProps, typographyProps} from '../../props/typography'
|
|
4
|
-
import
|
|
6
|
+
import type {Polymorphic} from '../../types/Polymorphic'
|
|
7
|
+
import type {PropDef} from '../../types/PropDef'
|
|
5
8
|
import type {Responsive} from '../../types/Responsive'
|
|
6
9
|
import {TEXT_SIZE, type TextSize} from '../../types/Text'
|
|
7
10
|
|
|
8
11
|
/** @public */
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
export type TextProps<T extends ElementType = 'span'> = Polymorphic<
|
|
13
|
+
T,
|
|
14
|
+
MarginProps &
|
|
15
|
+
ToneProps &
|
|
16
|
+
TypographyProps & {
|
|
17
|
+
/**
|
|
18
|
+
* HTML element to render.
|
|
19
|
+
*/
|
|
20
|
+
as?: T
|
|
21
|
+
/**
|
|
22
|
+
* Sets font size.
|
|
23
|
+
*/
|
|
24
|
+
size?: Responsive<TextSize>
|
|
25
|
+
}
|
|
26
|
+
>
|
|
20
27
|
|
|
21
28
|
export const textProps: Record<string, PropDef> = {
|
|
22
29
|
as: {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
+
import type {ComponentProps} from 'react'
|
|
2
|
+
|
|
1
3
|
import {formElementDensityProps, type FormElementDensityProps} from '../../props/formElement'
|
|
2
4
|
import {type HeightProps, heightProps} from '../../props/height'
|
|
3
|
-
import
|
|
5
|
+
import type {PropDef} from '../../types/PropDef'
|
|
4
6
|
|
|
5
7
|
/** @public */
|
|
6
8
|
export interface TextAreaProps
|
|
7
|
-
extends
|
|
8
|
-
React.ComponentProps<'textarea'>,
|
|
9
|
-
FormElementDensityProps,
|
|
10
|
-
Pick<HeightProps, 'maxHeight'> {
|
|
9
|
+
extends ComponentProps<'textarea'>, FormElementDensityProps, Pick<HeightProps, 'maxHeight'> {
|
|
11
10
|
/**
|
|
12
11
|
* Sizes the textarea to its content via the CSS `field-sizing` property.
|
|
13
12
|
*/
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type {ComponentProps, HTMLInputTypeAttribute} from 'react'
|
|
2
|
+
|
|
1
3
|
import {formElementDensityProps, type FormElementDensityProps} from '../../props/formElement'
|
|
2
|
-
import
|
|
4
|
+
import type {PropDef} from '../../types/PropDef'
|
|
3
5
|
|
|
4
6
|
export const TEXT_INPUT_EXCLUDED_TYPES = [
|
|
5
7
|
'button',
|
|
@@ -18,11 +20,11 @@ export const TEXT_INPUT_EXCLUDED_TYPES = [
|
|
|
18
20
|
export type TextInputExcludedTypes = (typeof TEXT_INPUT_EXCLUDED_TYPES)[number]
|
|
19
21
|
|
|
20
22
|
/** @public */
|
|
21
|
-
export type TextInputType = Exclude<
|
|
23
|
+
export type TextInputType = Exclude<HTMLInputTypeAttribute, TextInputExcludedTypes>
|
|
22
24
|
|
|
23
25
|
/** @public */
|
|
24
26
|
export interface TextInputProps
|
|
25
|
-
extends Omit<
|
|
27
|
+
extends Omit<ComponentProps<'input'>, 'type'>, FormElementDensityProps {
|
|
26
28
|
/**
|
|
27
29
|
* Used to trigger styling for invalid states.
|
|
28
30
|
* @remarks Use when form validation fails. Pair with a visible error message.
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
+
import type {ComponentProps, ReactElement, ReactNode} from 'react'
|
|
2
|
+
|
|
1
3
|
import {type PlacementProps, placementProps} from '../../props/placement'
|
|
2
|
-
import
|
|
4
|
+
import type {PropDef} from '../../types/PropDef'
|
|
3
5
|
|
|
4
6
|
/** @beta */
|
|
5
7
|
export interface TooltipProps
|
|
6
|
-
extends Omit<
|
|
8
|
+
extends Omit<ComponentProps<'div'>, 'children' | 'content'>, PlacementProps {
|
|
7
9
|
/**
|
|
8
10
|
* Shared anchor identifier.
|
|
9
11
|
*/
|
|
10
|
-
anchorName?:
|
|
12
|
+
anchorName?: ReactNode
|
|
11
13
|
/**
|
|
12
14
|
* The trigger element.
|
|
13
15
|
*/
|
|
14
|
-
children:
|
|
16
|
+
children: ReactElement<Record<string, unknown>>
|
|
15
17
|
/**
|
|
16
18
|
* The tooltip label.
|
|
17
19
|
*/
|
|
18
|
-
content?:
|
|
20
|
+
content?: ReactNode
|
|
19
21
|
/**
|
|
20
22
|
* Renders the label into `document.body` through a React portal instead of inline.
|
|
21
23
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import clsx from 'clsx'
|
|
2
|
-
import {type
|
|
2
|
+
import {type ElementType, useRef, useState} from 'react'
|
|
3
3
|
|
|
4
|
+
import {composeRefs} from '../../utils/composeRefs'
|
|
4
5
|
import {getProps} from '../../utils/getProps'
|
|
5
6
|
import {suffixClassName} from '../../utils/suffixClassName'
|
|
6
7
|
import {type TooltipGroupProps, tooltipGroupProps} from './tooltipGroup.props'
|
|
@@ -8,12 +9,10 @@ import {type TooltipGroupProps, tooltipGroupProps} from './tooltipGroup.props'
|
|
|
8
9
|
const tooltipGroupClassName = suffixClassName('sui-TooltipGroup')
|
|
9
10
|
|
|
10
11
|
/** @public */
|
|
11
|
-
export function TooltipGroup<T extends ElementType = 'div'>(
|
|
12
|
-
|
|
13
|
-
) {
|
|
14
|
-
const {as, children, className, style, ...rest} = getProps(props, tooltipGroupProps)
|
|
12
|
+
export function TooltipGroup<T extends ElementType = 'div'>(props: TooltipGroupProps<T>) {
|
|
13
|
+
const {as, children, className, style, ref, ...rest} = getProps(props, tooltipGroupProps)
|
|
15
14
|
const Component = as || 'div'
|
|
16
|
-
const
|
|
15
|
+
const tooltipGroupRef = useRef<HTMLElement>(null)
|
|
17
16
|
const [isActive, setIsActive] = useState(false)
|
|
18
17
|
|
|
19
18
|
const handleTransitionEnd = (e: TransitionEvent) => {
|
|
@@ -33,7 +32,7 @@ export function TooltipGroup<T extends ElementType = 'div'>(
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
const handleBlur = (e: FocusEvent) => {
|
|
36
|
-
if (
|
|
35
|
+
if (tooltipGroupRef.current && tooltipGroupRef.current.contains(e.relatedTarget as Node)) {
|
|
37
36
|
return
|
|
38
37
|
}
|
|
39
38
|
|
|
@@ -49,12 +48,12 @@ export function TooltipGroup<T extends ElementType = 'div'>(
|
|
|
49
48
|
'--tooltip-delay-group': '0ms',
|
|
50
49
|
}),
|
|
51
50
|
}}
|
|
51
|
+
{...rest}
|
|
52
52
|
data-ui="TooltipGroup"
|
|
53
|
-
ref={ref}
|
|
53
|
+
ref={composeRefs(tooltipGroupRef, ref)}
|
|
54
54
|
onTransitionEnd={handleTransitionEnd}
|
|
55
55
|
onMouseLeave={handleMouseLeave}
|
|
56
56
|
onBlur={handleBlur}
|
|
57
|
-
{...rest}
|
|
58
57
|
>
|
|
59
58
|
{children}
|
|
60
59
|
</Component>
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type {ElementType} from 'react'
|
|
2
|
+
|
|
3
|
+
import type {Polymorphic} from '../../types/Polymorphic'
|
|
4
|
+
import type {PropDef} from '../../types/PropDef'
|
|
2
5
|
|
|
3
6
|
/** @public */
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export type TooltipGroupProps<T extends ElementType = 'div'> = Polymorphic<
|
|
8
|
+
T,
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* HTML element to render.
|
|
12
|
+
*/
|
|
13
|
+
as?: T
|
|
14
|
+
}
|
|
15
|
+
>
|
|
10
16
|
|
|
11
17
|
export const tooltipGroupProps: Record<string, PropDef> = {
|
|
12
18
|
as: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx from 'clsx'
|
|
2
|
-
import type {
|
|
2
|
+
import type {ElementType} from 'react'
|
|
3
3
|
|
|
4
4
|
import type {ComponentProps} from '../../utils/getProps'
|
|
5
5
|
import {suffixClassName} from '../../utils/suffixClassName'
|
|
@@ -9,10 +9,7 @@ import {type VStackProps} from './vStack.props'
|
|
|
9
9
|
const vStackClassName = suffixClassName('sui-VStack')
|
|
10
10
|
|
|
11
11
|
/** @public */
|
|
12
|
-
export function VStack<T extends ElementType = 'div'>({
|
|
13
|
-
className,
|
|
14
|
-
...props
|
|
15
|
-
}: VStackProps<T> & Omit<ComponentPropsWithRef<T>, keyof VStackProps<T>>) {
|
|
12
|
+
export function VStack<T extends ElementType = 'div'>({className, ...props}: VStackProps<T>) {
|
|
16
13
|
return (
|
|
17
14
|
<Flex
|
|
18
15
|
className={clsx(vStackClassName, className)}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type {ElementType} from 'react'
|
|
2
|
+
|
|
3
|
+
import type {Polymorphic} from '../../types/Polymorphic'
|
|
1
4
|
import type {FlexProps} from '../flex/flex.props'
|
|
2
5
|
|
|
3
6
|
/** @public */
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
'as' | 'gap'
|
|
7
|
-
>
|
|
7
|
+
export type VStackProps<T extends ElementType = 'div'> = Polymorphic<
|
|
8
|
+
T,
|
|
9
|
+
Pick<FlexProps<T>, 'as' | 'gap'>
|
|
10
|
+
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx from 'clsx'
|
|
2
|
-
import type {
|
|
2
|
+
import type {ElementType} from 'react'
|
|
3
3
|
|
|
4
4
|
import {getProps} from '../../utils/getProps'
|
|
5
5
|
import {suffixClassName} from '../../utils/suffixClassName'
|
|
@@ -8,9 +8,7 @@ import {type VisuallyHiddenProps, visuallyHiddenProps} from './visuallyHidden.pr
|
|
|
8
8
|
const visuallyHiddenClassName = suffixClassName('sui-VisuallyHidden')
|
|
9
9
|
|
|
10
10
|
/** @public */
|
|
11
|
-
export function VisuallyHidden<T extends ElementType = 'span'>(
|
|
12
|
-
props: VisuallyHiddenProps<T> & Omit<ComponentPropsWithRef<T>, keyof VisuallyHiddenProps<T>>,
|
|
13
|
-
) {
|
|
11
|
+
export function VisuallyHidden<T extends ElementType = 'span'>(props: VisuallyHiddenProps<T>) {
|
|
14
12
|
const {as, children, className, style, ...rest} = getProps(props, visuallyHiddenProps)
|
|
15
13
|
const Component = as || 'span'
|
|
16
14
|
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type {ElementType} from 'react'
|
|
2
|
+
|
|
3
|
+
import type {Polymorphic} from '../../types/Polymorphic'
|
|
4
|
+
import type {PropDef} from '../../types/PropDef'
|
|
2
5
|
|
|
3
6
|
/** @public */
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
export type VisuallyHiddenProps<T extends ElementType = 'span'> = Polymorphic<
|
|
8
|
+
T,
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* HTML element to render.
|
|
12
|
+
*/
|
|
13
|
+
as?: T
|
|
14
|
+
/**
|
|
15
|
+
* If true, the element becomes visible on `:focus-visible`.
|
|
16
|
+
*/
|
|
17
|
+
visibleOnFocus?: boolean
|
|
18
|
+
}
|
|
19
|
+
>
|
|
14
20
|
|
|
15
21
|
export const visuallyHiddenProps: Record<string, PropDef> = {
|
|
16
22
|
as: {
|
|
@@ -18,6 +24,6 @@ export const visuallyHiddenProps: Record<string, PropDef> = {
|
|
|
18
24
|
},
|
|
19
25
|
visibleOnFocus: {
|
|
20
26
|
type: 'boolean',
|
|
21
|
-
className: '
|
|
27
|
+
className: 'visually-hidden-visible',
|
|
22
28
|
},
|
|
23
29
|
}
|
package/src/index.ts
CHANGED
|
@@ -73,3 +73,4 @@ export type {Space, SpaceAuto, SpaceAutoNegative, SpaceInherit} from './types/Sp
|
|
|
73
73
|
export type {TextSize} from './types/Text'
|
|
74
74
|
export type {TextAlign} from './types/TextAlign'
|
|
75
75
|
export type {Tone} from './types/Tone'
|
|
76
|
+
export * from './components/search-input/SearchInput'
|
package/src/types/Interactive.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type {ElementType} from 'react'
|
|
2
|
+
|
|
1
3
|
export const INTERACTIVE_TAG = ['button', 'a'] as const
|
|
2
4
|
export type InteractiveTag = (typeof INTERACTIVE_TAG)[number]
|
|
3
5
|
|
|
4
|
-
export type InteractiveAs<T extends
|
|
6
|
+
export type InteractiveAs<T extends ElementType> = T extends InteractiveTag
|
|
5
7
|
? T
|
|
6
8
|
: T extends string
|
|
7
9
|
? never
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type {ComponentPropsWithRef, ElementType} from 'react'
|
|
2
|
+
|
|
3
|
+
export type Polymorphic<T extends ElementType, Props extends object> = Props &
|
|
4
|
+
Omit<
|
|
5
|
+
T extends (props: infer AsProps, ...args: never) => unknown
|
|
6
|
+
? AsProps
|
|
7
|
+
: ComponentPropsWithRef<T>,
|
|
8
|
+
keyof Props
|
|
9
|
+
>
|
package/src/types/Tone.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const TONE = ['neutral', 'positive', 'suggest', 'caution', 'critical'] as const
|
|
2
|
-
export const TONE_WITH_DEFAULT = ['default', ...TONE]
|
|
2
|
+
export const TONE_WITH_DEFAULT = ['default', ...TONE] as const
|
|
3
3
|
/** @public */
|
|
4
4
|
export type Tone = (typeof TONE)[number]
|
|
5
5
|
export type ToneWithDefault = (typeof TONE_WITH_DEFAULT)[number]
|