@sanity/ui 3.0.0-static.10 → 3.0.0-static.12
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/_chunks-cjs/_visual-editing.js +1300 -1269
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-cjs/buildCommand.js +28 -10
- package/dist/_chunks-cjs/buildCommand.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +1298 -1263
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_visual-editing.d.mts +516 -360
- package/dist/_visual-editing.d.ts +516 -360
- package/dist/cli.js +1 -1
- package/dist/css.d.mts +258 -75
- package/dist/css.d.ts +258 -75
- package/dist/css.js +746 -752
- package/dist/css.js.map +1 -1
- package/dist/css.mjs +748 -754
- package/dist/css.mjs.map +1 -1
- package/dist/index.d.mts +1342 -871
- package/dist/index.d.ts +1342 -871
- package/dist/index.js +433 -325
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +429 -321
- package/dist/index.mjs.map +1 -1
- package/dist/sanity-palette.css +105 -1
- package/dist/sanity-palette.min.css +1 -0
- package/dist/sanity-theme.css +4571 -1
- package/dist/sanity-theme.min.css +1 -0
- package/dist/system.css +22053 -21710
- package/dist/system.min.css +1 -0
- package/dist/theme.d.mts +51 -106
- package/dist/theme.d.ts +51 -106
- package/dist/theme.js +19 -20
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +19 -20
- package/dist/theme.mjs.map +1 -1
- package/package.json +10 -5
- package/src/cli/buildCommand.ts +46 -19
- package/src/css/_comp.ts +2 -2
- package/src/css/{compile/compileStyle.ts → _compileStyle.ts} +7 -7
- package/src/css/_resp.ts +0 -1
- package/src/css/{system.style.ts → _system.style.ts} +3 -2
- package/src/css/aspects/display/display.ts +1 -0
- package/src/css/aspects/display/types.ts +2 -3
- package/src/css/aspects/flex/types.ts +4 -12
- package/src/css/aspects/flexItem/types.ts +1 -3
- package/src/css/aspects/font/font.style.ts +7 -66
- package/src/css/aspects/font/types.ts +1 -3
- package/src/css/aspects/grid/grid.ts +1 -0
- package/src/css/aspects/grid/types.ts +5 -9
- package/src/css/aspects/gridItem/gridItem.ts +1 -1
- package/src/css/aspects/gridItem/types.ts +7 -18
- package/src/css/aspects/height/height.ts +3 -4
- package/src/css/aspects/inset/inset.ts +1 -0
- package/src/css/aspects/margin/margin.ts +1 -0
- package/src/css/aspects/margin/types.ts +1 -0
- package/src/css/aspects/maxWidth/maxWidth.ts +1 -0
- package/src/css/aspects/maxWidth/types.ts +1 -0
- package/src/css/aspects/minWidth/minWidth.ts +1 -0
- package/src/css/aspects/minWidth/types.ts +2 -0
- package/src/css/aspects/overflow/overflow.ts +1 -0
- package/src/css/aspects/padding/padding.ts +1 -0
- package/src/css/aspects/pointerEvents/pointerEvents.ts +1 -0
- package/src/css/aspects/position/position.ts +1 -0
- package/src/css/aspects/shadow/shadow.style.ts +16 -41
- package/src/css/aspects/shadow/shadow.ts +1 -0
- package/src/css/aspects/textOverflow/textOverflow.ts +1 -0
- package/src/css/aspects/textOverflow/types.ts +1 -0
- package/src/css/aspects/width/types.ts +2 -0
- package/src/css/aspects/width/width.ts +1 -0
- package/src/css/compilePalette.ts +32 -0
- package/src/css/compileSystem.ts +7 -0
- package/src/css/{compile/compileTheme.ts → compileTheme.ts} +1 -0
- package/src/css/compileTheme_v3.ts +434 -0
- package/src/css/components/breadcrumbs/breadcrumbs.ts +1 -0
- package/src/css/components/dialog/dialog.ts +7 -0
- package/src/css/components/menu/menu.ts +2 -0
- package/src/css/components/skeleton/skeleton.style.ts +8 -4
- package/src/css/components/skeleton/skeleton.ts +4 -0
- package/src/css/components/skeleton/types.ts +4 -0
- package/src/css/components/toast/toast.ts +5 -0
- package/src/css/components/tree/tree.ts +1 -0
- package/src/css/composeClassNames.ts +4 -2
- package/src/css/constants.ts +11 -0
- package/src/css/index.ts +4 -3
- package/src/css/primitives/_arrow/_arrow.style.ts +6 -8
- package/src/css/primitives/_arrow/_arrow.ts +7 -0
- package/src/css/primitives/_input/input.ts +2 -0
- package/src/css/primitives/_selectable/_selectable.style.ts +24 -25
- package/src/css/primitives/_selectable/selectable.ts +1 -2
- package/src/css/primitives/avatar/avatar.style.ts +5 -8
- package/src/css/primitives/avatar/avatar.ts +6 -0
- package/src/css/primitives/avatar/types.ts +1 -0
- package/src/css/primitives/box/types.ts +1 -3
- package/src/css/primitives/button/button.style.ts +48 -15
- package/src/css/primitives/button/button.ts +4 -21
- package/src/css/primitives/button/index.ts +1 -0
- package/src/css/primitives/button/types.ts +18 -0
- package/src/css/primitives/card/card.style.ts +4 -7
- package/src/css/primitives/card/card.ts +2 -2
- package/src/css/primitives/card/types.ts +2 -2
- package/src/css/primitives/checkbox/checkbox.ts +2 -0
- package/src/css/primitives/container/container.ts +1 -0
- package/src/css/primitives/container/types.ts +1 -0
- package/src/css/primitives/kbd/kbd.ts +1 -0
- package/src/css/primitives/label/types.ts +7 -2
- package/src/css/primitives/popover/popover.ts +2 -0
- package/src/css/primitives/radio/radio.ts +1 -0
- package/src/css/primitives/select/select.ts +2 -0
- package/src/css/primitives/spinner/spinner.ts +2 -0
- package/src/css/primitives/switch/switch.ts +5 -0
- package/src/css/primitives/text/types.ts +4 -0
- package/src/css/primitives/textArea/textArea.ts +1 -0
- package/src/css/primitives/textInput/textInput.ts +1 -0
- package/src/css/primitives/token/token.style.ts +37 -36
- package/src/css/primitives/tooltip/tooltip.ts +2 -0
- package/src/css/responsiveRules.ts +12 -19
- package/src/css/scopeClassName.ts +1 -0
- package/src/css/types.ts +115 -15
- package/src/css/util.ts +5 -0
- package/src/css/utils/srOnly/srOnly.ts +1 -0
- package/src/css/varNames.ts +230 -143
- package/src/css/vars.ts +53 -22
- package/src/theme/palette/constants.ts +2 -0
- package/src/theme/palette/types.ts +3 -0
- package/src/theme/types.ts +2 -6
- package/src/theme/v0/focusRing.ts +1 -3
- package/src/theme/v0/font.ts +6 -18
- package/src/theme/v0/layer.ts +1 -3
- package/src/theme/v0/shadow.ts +2 -6
- package/src/theme/v2/avatar.ts +1 -3
- package/src/theme/v2/color/_system.ts +1 -3
- package/src/theme/v2/color/avatar.ts +2 -6
- package/src/theme/v2/color/badge.ts +2 -6
- package/src/theme/v2/color/button.ts +3 -9
- package/src/theme/v2/color/color.ts +3 -9
- package/src/theme/v2/color/input.ts +3 -9
- package/src/theme/v2/color/kbd.ts +1 -3
- package/src/theme/v2/color/selectable.ts +2 -6
- package/src/theme/v2/color/state.ts +1 -3
- package/src/theme/v2/color/syntax.ts +1 -3
- package/src/theme/v2/input.ts +1 -3
- package/src/theme/v2/theme.ts +2 -6
- package/src/theme/v3/buildTheme_v3.ts +2 -1
- package/src/theme/v3/color/color.ts +6 -4
- package/src/theme/v3/color/renderColor.ts +4 -1
- package/src/theme/v3/{defaults.ts → defaultTokens.ts} +2 -2
- package/src/theme/v3/index.ts +1 -1
- package/src/theme/v3/resolveTokens.ts +18 -18
- package/src/ui/RootClassNames.tsx +44 -0
- package/src/ui/StyleTags.tsx +3 -1
- package/src/ui/_compat/helpers.ts +72 -0
- package/src/ui/_compat/index.ts +2 -6
- package/src/ui/_compat/studioTheme.ts +7 -0
- package/src/ui/_compat/theme/themeColorProvider.tsx +2 -6
- package/src/ui/_compat/theme/themeProvider.tsx +2 -6
- package/src/ui/_compat/theme/types.ts +1 -3
- package/src/ui/_compat/theme/useRootTheme.ts +1 -3
- package/src/ui/_compat/theme/useTheme.ts +2 -6
- package/src/ui/_compat/types.ts +0 -83
- package/src/ui/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
- package/src/ui/components/autocomplete/autocomplete.tsx +86 -114
- package/src/ui/components/autocomplete/autocompleteOption.tsx +2 -0
- package/src/ui/components/autocomplete/types.ts +3 -8
- package/src/ui/components/breadcrumbs/breadcrumbs.tsx +27 -21
- package/src/ui/components/dialog/dialog.tsx +89 -291
- package/src/ui/components/dialog/dialogCard.tsx +183 -0
- package/src/ui/components/dialog/isTargetWithinScope.ts +14 -0
- package/src/ui/components/hotkeys/hotkeys.tsx +33 -15
- package/src/ui/components/menu/__workshop__/asComponent.tsx +6 -6
- package/src/ui/components/menu/menu.tsx +27 -33
- package/src/ui/components/menu/menuButton.tsx +10 -14
- package/src/ui/components/menu/menuDivider.tsx +25 -13
- package/src/ui/components/menu/menuGroup.tsx +34 -26
- package/src/ui/components/menu/menuItem.tsx +51 -40
- package/src/ui/components/skeleton/codeSkeleton.tsx +53 -0
- package/src/ui/components/skeleton/headingSkeleton.tsx +52 -0
- package/src/ui/components/skeleton/index.ts +3 -0
- package/src/ui/components/skeleton/labelSkeleton.tsx +51 -0
- package/src/ui/components/skeleton/skeleton.tsx +39 -16
- package/src/ui/components/skeleton/textSkeleton.tsx +31 -110
- package/src/ui/components/tab/tab.tsx +23 -19
- package/src/ui/components/tab/tabList.tsx +34 -33
- package/src/ui/components/tab/tabPanel.tsx +25 -19
- package/src/ui/components/toast/toast.tsx +21 -16
- package/src/ui/components/toast/toastLayer.tsx +28 -10
- package/src/ui/components/toast/toastProvider.tsx +2 -6
- package/src/ui/components/toast/types.ts +2 -6
- package/src/ui/components/toast/useToast.ts +1 -3
- package/src/ui/components/tree/tree.tsx +194 -187
- package/src/ui/components/tree/treeGroup.tsx +25 -5
- package/src/ui/components/tree/treeItem.tsx +35 -23
- package/src/ui/hooks/useClickOutside.ts +2 -6
- package/src/ui/hooks/useClickOutsideEvent.ts +3 -9
- package/src/ui/index.ts +1 -0
- package/src/ui/primitives/_selectable/selectable.tsx +33 -20
- package/src/ui/primitives/avatar/avatar.tsx +28 -31
- package/src/ui/primitives/avatar/avatarCounter.tsx +33 -25
- package/src/ui/primitives/avatar/avatarStack.tsx +31 -24
- package/src/ui/primitives/avatar/types.ts +2 -0
- package/src/ui/primitives/badge/__workshop__/props.tsx +1 -9
- package/src/ui/primitives/badge/__workshop__/tones.tsx +1 -6
- package/src/ui/primitives/badge/badge.tsx +33 -32
- package/src/ui/primitives/badge/types.ts +2 -1
- package/src/ui/primitives/box/box.tsx +59 -29
- package/src/ui/primitives/button/__workshop__/sanityUploadButton.tsx +3 -3
- package/src/ui/primitives/button/__workshop__/uploadButton.tsx +2 -1
- package/src/ui/primitives/button/button.test.tsx +1 -15
- package/src/ui/primitives/button/button.tsx +63 -70
- package/src/ui/primitives/card/__workshop__/asComponent.tsx +3 -3
- package/src/ui/primitives/card/card.tsx +22 -22
- package/src/ui/primitives/card/cardProvider.tsx +2 -0
- package/src/ui/primitives/checkbox/checkbox.tsx +26 -15
- package/src/ui/primitives/code/code.tsx +24 -22
- package/src/ui/primitives/container/container.tsx +26 -15
- package/src/ui/primitives/flex/flex.tsx +21 -19
- package/src/ui/primitives/grid/grid.tsx +21 -16
- package/src/ui/primitives/heading/heading.tsx +42 -19
- package/src/ui/primitives/inline/inline.tsx +26 -23
- package/src/ui/primitives/kbd/kbd.tsx +25 -23
- package/src/ui/primitives/label/label.tsx +29 -26
- package/src/ui/primitives/popover/popover.tsx +293 -271
- package/src/ui/primitives/popover/popoverCard.tsx +122 -120
- package/src/ui/primitives/radio/radio.tsx +30 -14
- package/src/ui/primitives/select/select.tsx +24 -16
- package/src/ui/primitives/spinner/animatedSpinnerIcon.tsx +4 -2
- package/src/ui/primitives/spinner/spinner.tsx +24 -12
- package/src/ui/primitives/stack/stack.tsx +27 -18
- package/src/ui/primitives/switch/switch.tsx +31 -14
- package/src/ui/primitives/text/text.tsx +30 -24
- package/src/ui/primitives/textArea/textArea.tsx +33 -18
- package/src/ui/primitives/textInput/textInput.tsx +28 -40
- package/src/ui/primitives/tooltip/constants.ts +1 -1
- package/src/ui/primitives/tooltip/tooltip.tsx +85 -61
- package/src/ui/primitives/tooltip/tooltipCard.tsx +89 -82
- package/src/ui/primitives/types.ts +1 -3
- package/src/ui/types/avatar.ts +3 -6
- package/src/ui/types/badge.ts +1 -3
- package/src/ui/types/button.ts +1 -3
- package/src/ui/types/card.ts +1 -3
- package/src/ui/types/dialog.ts +1 -3
- package/src/ui/types/props.ts +20 -10
- package/src/ui/utils/arrow/arrow.tsx +43 -25
- package/src/ui/utils/boundaryElement/boundaryElementProvider.tsx +2 -6
- package/src/ui/utils/boundaryElement/types.ts +1 -3
- package/src/ui/utils/boundaryElement/useBoundaryElement.ts +1 -3
- package/src/ui/utils/elementQuery/elementQuery.tsx +43 -19
- package/src/ui/utils/errorBoundary.tsx +2 -0
- package/src/ui/utils/index.ts +0 -1
- package/src/ui/utils/layer/layer.tsx +23 -93
- package/src/ui/utils/layer/layerCard.tsx +92 -0
- package/src/ui/utils/layer/layerProvider.tsx +2 -6
- package/src/ui/utils/layer/useLayer.ts +1 -3
- package/src/ui/utils/portal/portal.ts +2 -6
- package/src/ui/utils/portal/portalProvider.tsx +2 -6
- package/src/ui/utils/portal/types.ts +1 -3
- package/src/ui/utils/portal/usePortal.ts +1 -3
- package/src/ui/utils/srOnly/srOnly.tsx +25 -20
- package/src/ui/utils/virtualList/virtualList.tsx +69 -50
- package/src/css/compile/compilePalette.ts +0 -27
- package/src/css/compile/compileRule.ts +0 -97
- package/src/css/compile/compileRules.test.ts +0 -36
- package/src/css/compile/compileRules.ts +0 -43
- package/src/css/compile/compileSystem.ts +0 -10
- package/src/css/compile/compileTheme_v3.ts +0 -401
- package/src/css/compile/types.ts +0 -6
- package/src/css/components/breadcrumbs/rules.ts +0 -25
- package/src/css/components/dialog/rules.ts +0 -78
- package/src/css/components/skeleton/rules.ts +0 -113
- package/src/css/components/toast/rules.ts +0 -18
- package/src/css/components/tree/rules.ts +0 -168
- package/src/css/primitives/_selectable/_contants.ts +0 -11
- package/src/css/primitives/card/_constants.ts +0 -13
- package/src/css/primitives/popover/rules.ts +0 -5
- package/src/css/primitives/spinner/rules.ts +0 -21
- package/src/css/primitives/token/rules.ts +0 -45
- package/src/ui/utils/conditionalWrapper/conditionalWrapper.tsx +0 -23
- package/src/ui/utils/conditionalWrapper/index.ts +0 -1
|
@@ -5,45 +5,45 @@ import {
|
|
|
5
5
|
TextOverflowStyleProps,
|
|
6
6
|
TextStyleProps,
|
|
7
7
|
} from '@sanity/ui/css'
|
|
8
|
-
import {ForwardedRef, forwardRef} from 'react'
|
|
9
8
|
|
|
10
|
-
import {Props} from '../../types'
|
|
9
|
+
import {ComponentType, Props} from '../../types'
|
|
11
10
|
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
/** @public */
|
|
12
|
+
export const DEFAULT_TEXT_ELEMENT = 'div'
|
|
13
|
+
|
|
14
|
+
/** @public */
|
|
15
|
+
export type TextOwnProps = TextStyleProps & TextOverflowStyleProps
|
|
16
|
+
|
|
17
|
+
/** @public */
|
|
18
|
+
export type TextElementType = 'div' | 'label' | 'li' | 'span' | ComponentType
|
|
19
|
+
|
|
20
|
+
/** @public */
|
|
21
|
+
export type TextProps<E extends TextElementType = TextElementType> = Props<TextOwnProps, E>
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* The `Text` component is an agile, themed typographic element.
|
|
21
25
|
*
|
|
22
26
|
* @public
|
|
23
27
|
*/
|
|
24
|
-
export
|
|
25
|
-
props: Props<TextProps, 'div'>,
|
|
26
|
-
ref: ForwardedRef<HTMLDivElement>,
|
|
27
|
-
) {
|
|
28
|
+
export function Text<E extends TextElementType = typeof DEFAULT_TEXT_ELEMENT>(props: TextProps<E>) {
|
|
28
29
|
const {
|
|
29
|
-
accent
|
|
30
|
+
accent,
|
|
30
31
|
align,
|
|
31
|
-
as:
|
|
32
|
+
as: Element = DEFAULT_TEXT_ELEMENT,
|
|
32
33
|
children,
|
|
33
34
|
className,
|
|
34
35
|
flex,
|
|
35
|
-
muted
|
|
36
|
+
muted,
|
|
36
37
|
size = 2,
|
|
37
38
|
textOverflow: textOverflowProp,
|
|
38
39
|
weight,
|
|
39
|
-
...
|
|
40
|
-
} = props
|
|
40
|
+
...rest
|
|
41
|
+
} = props as TextProps<typeof DEFAULT_TEXT_ELEMENT>
|
|
41
42
|
|
|
42
43
|
return (
|
|
43
|
-
<
|
|
44
|
+
<Element
|
|
44
45
|
data-ui="Text"
|
|
45
|
-
{...
|
|
46
|
-
ref={ref}
|
|
46
|
+
{...rest}
|
|
47
47
|
className={composeClassNames(
|
|
48
48
|
className,
|
|
49
49
|
text({
|
|
@@ -56,9 +56,15 @@ export const Text = forwardRef(function Text(
|
|
|
56
56
|
}),
|
|
57
57
|
)}
|
|
58
58
|
>
|
|
59
|
-
<span
|
|
60
|
-
|
|
59
|
+
<span
|
|
60
|
+
className={textOverflow({
|
|
61
|
+
textOverflow: textOverflowProp,
|
|
62
|
+
})}
|
|
63
|
+
>
|
|
64
|
+
{children}
|
|
65
|
+
</span>
|
|
66
|
+
</Element>
|
|
61
67
|
)
|
|
62
|
-
}
|
|
68
|
+
}
|
|
63
69
|
|
|
64
|
-
Text.displayName = '
|
|
70
|
+
Text.displayName = 'Text'
|
|
@@ -3,18 +3,19 @@ import {
|
|
|
3
3
|
_inputPresentation,
|
|
4
4
|
ResponsiveProp,
|
|
5
5
|
textArea,
|
|
6
|
-
TextAreaStyleProps,
|
|
6
|
+
type TextAreaStyleProps,
|
|
7
7
|
} from '@sanity/ui/css'
|
|
8
|
-
import {Space, ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
9
|
-
import {
|
|
8
|
+
import type {Space, ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
9
|
+
import {useImperativeHandle, useRef} from 'react'
|
|
10
10
|
|
|
11
11
|
import {useCustomValidity} from '../../hooks'
|
|
12
|
-
import {Props} from '../../types'
|
|
12
|
+
import type {ComponentType, Props} from '../../types'
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
/** @public */
|
|
15
|
+
export const DEFAULT_TEXT_AREA_ELEMENT = 'textarea'
|
|
16
|
+
|
|
17
|
+
/** @public */
|
|
18
|
+
export type TextAreaOwnProps = TextAreaStyleProps & {
|
|
18
19
|
/**
|
|
19
20
|
* @beta
|
|
20
21
|
*/
|
|
@@ -25,16 +26,25 @@ export interface TextAreaProps extends TextAreaStyleProps {
|
|
|
25
26
|
weight?: ThemeFontWeightKey
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
/** @public */
|
|
30
|
+
export type TextAreaElementType = 'textarea' | ComponentType
|
|
31
|
+
|
|
32
|
+
/** @public */
|
|
33
|
+
export type TextAreaProps<E extends TextAreaElementType = TextAreaElementType> = Props<
|
|
34
|
+
TextAreaOwnProps,
|
|
35
|
+
E
|
|
36
|
+
>
|
|
37
|
+
|
|
28
38
|
/**
|
|
29
39
|
* A multiline text input.
|
|
30
40
|
*
|
|
31
41
|
* @public
|
|
32
42
|
*/
|
|
33
|
-
export
|
|
34
|
-
props:
|
|
35
|
-
forwardedRef: ForwardedRef<HTMLTextAreaElement>,
|
|
43
|
+
export function TextArea<E extends TextAreaElementType = typeof DEFAULT_TEXT_AREA_ELEMENT>(
|
|
44
|
+
props: TextAreaProps<E>,
|
|
36
45
|
) {
|
|
37
46
|
const {
|
|
47
|
+
as: Element = DEFAULT_TEXT_AREA_ELEMENT,
|
|
38
48
|
border = true,
|
|
39
49
|
customValidity,
|
|
40
50
|
disabled = false,
|
|
@@ -42,11 +52,16 @@ export const TextArea = forwardRef(function TextArea(
|
|
|
42
52
|
gap,
|
|
43
53
|
padding = 3,
|
|
44
54
|
radius = 2,
|
|
55
|
+
ref: forwardedRef,
|
|
45
56
|
space = 3,
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
// TODO: fix this
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
59
|
+
weight,
|
|
60
|
+
// TODO: fix this
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
+
__unstable_disableFocusRing,
|
|
63
|
+
...rest
|
|
64
|
+
} = props as TextAreaProps<typeof DEFAULT_TEXT_AREA_ELEMENT>
|
|
50
65
|
|
|
51
66
|
const ref = useRef<HTMLTextAreaElement | null>(null)
|
|
52
67
|
|
|
@@ -62,10 +77,10 @@ export const TextArea = forwardRef(function TextArea(
|
|
|
62
77
|
className={textArea({border, fontSize, padding, radius, gap: gap ?? space})}
|
|
63
78
|
data-ui="TextArea"
|
|
64
79
|
>
|
|
65
|
-
<
|
|
80
|
+
<Element {...rest} className={_inputElement()} disabled={disabled} ref={ref} />
|
|
66
81
|
<span className={_inputPresentation()} />
|
|
67
82
|
</span>
|
|
68
83
|
)
|
|
69
|
-
}
|
|
84
|
+
}
|
|
70
85
|
|
|
71
|
-
TextArea.displayName = '
|
|
86
|
+
TextArea.displayName = 'TextArea'
|
|
@@ -11,8 +11,6 @@ import {Space, ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
|
11
11
|
import {
|
|
12
12
|
CSSProperties,
|
|
13
13
|
ElementType,
|
|
14
|
-
ForwardedRef,
|
|
15
|
-
forwardRef,
|
|
16
14
|
isValidElement,
|
|
17
15
|
MouseEvent,
|
|
18
16
|
ReactNode,
|
|
@@ -26,41 +24,22 @@ import {isValidElementType} from 'react-is'
|
|
|
26
24
|
import {EMPTY_RECORD} from '../../constants'
|
|
27
25
|
import {useArrayProp, useCustomValidity} from '../../hooks'
|
|
28
26
|
import {isRecord} from '../../lib/isRecord'
|
|
29
|
-
import {Props} from '../../types'
|
|
27
|
+
import {ComponentType, Props} from '../../types'
|
|
30
28
|
import {Box} from '../box'
|
|
31
29
|
import {Button, ButtonProps} from '../button'
|
|
32
30
|
import {Text} from '../text'
|
|
33
31
|
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
/** @public */
|
|
33
|
+
export const DEFAULT_TEXT_INPUT_ELEMENT = 'input'
|
|
34
|
+
|
|
35
|
+
/** @public */
|
|
37
36
|
export type TextInputClearButtonProps = Omit<
|
|
38
|
-
|
|
37
|
+
ButtonProps<'button'>,
|
|
39
38
|
'as' | 'onClick' | 'onMouseDown'
|
|
40
39
|
>
|
|
41
40
|
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
*/
|
|
45
|
-
export type TextInputType =
|
|
46
|
-
| 'search'
|
|
47
|
-
| 'date'
|
|
48
|
-
| 'datetime-local'
|
|
49
|
-
| 'email'
|
|
50
|
-
| 'url'
|
|
51
|
-
| 'month'
|
|
52
|
-
| 'number'
|
|
53
|
-
| 'password'
|
|
54
|
-
| 'tel'
|
|
55
|
-
| 'time'
|
|
56
|
-
| 'text'
|
|
57
|
-
| 'week'
|
|
58
|
-
| 'color'
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @public
|
|
62
|
-
*/
|
|
63
|
-
export interface TextInputProps extends InputStyleProps {
|
|
41
|
+
/** @public */
|
|
42
|
+
export type TextInputOwnProps = InputStyleProps & {
|
|
64
43
|
/**
|
|
65
44
|
* @beta
|
|
66
45
|
*/
|
|
@@ -80,10 +59,18 @@ export interface TextInputProps extends InputStyleProps {
|
|
|
80
59
|
/** @deprecated Use `gap` instead. */
|
|
81
60
|
space?: ResponsiveProp<Space>
|
|
82
61
|
suffix?: ReactNode
|
|
83
|
-
type?: TextInputType
|
|
84
62
|
weight?: ThemeFontWeightKey
|
|
85
63
|
}
|
|
86
64
|
|
|
65
|
+
/** @public */
|
|
66
|
+
export type TextInputElementType = 'input' | ComponentType
|
|
67
|
+
|
|
68
|
+
/** @public */
|
|
69
|
+
export type TextInputProps<E extends TextInputElementType = TextInputElementType> = Props<
|
|
70
|
+
TextInputOwnProps,
|
|
71
|
+
E
|
|
72
|
+
>
|
|
73
|
+
|
|
87
74
|
const CLEAR_BUTTON_BOX_STYLE: CSSProperties = {
|
|
88
75
|
backgroundColor: 'transparent',
|
|
89
76
|
top: 0,
|
|
@@ -96,12 +83,12 @@ const CLEAR_BUTTON_BOX_STYLE: CSSProperties = {
|
|
|
96
83
|
*
|
|
97
84
|
* @public
|
|
98
85
|
*/
|
|
99
|
-
export
|
|
100
|
-
props:
|
|
101
|
-
forwardedRef: ForwardedRef<HTMLInputElement>,
|
|
86
|
+
export function TextInput<E extends TextInputElementType = typeof DEFAULT_TEXT_INPUT_ELEMENT>(
|
|
87
|
+
props: TextInputProps<E>,
|
|
102
88
|
) {
|
|
103
89
|
const {
|
|
104
90
|
__unstable_disableFocusRing,
|
|
91
|
+
as: Element = DEFAULT_TEXT_INPUT_ELEMENT,
|
|
105
92
|
border = true,
|
|
106
93
|
className,
|
|
107
94
|
clearButton,
|
|
@@ -115,14 +102,16 @@ export const TextInput = forwardRef(function TextInput(
|
|
|
115
102
|
prefix,
|
|
116
103
|
radius = 2,
|
|
117
104
|
readOnly,
|
|
105
|
+
ref: forwardedRef,
|
|
118
106
|
space = 3,
|
|
119
107
|
suffix,
|
|
120
108
|
customValidity,
|
|
121
109
|
type = 'text',
|
|
122
110
|
weight: _width, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
123
111
|
width,
|
|
124
|
-
...
|
|
125
|
-
} = props
|
|
112
|
+
...rest
|
|
113
|
+
} = props as TextInputProps<typeof DEFAULT_TEXT_INPUT_ELEMENT>
|
|
114
|
+
|
|
126
115
|
const ref = useRef<HTMLInputElement | null>(null)
|
|
127
116
|
|
|
128
117
|
const paddingArray = useArrayProp(padding)
|
|
@@ -213,9 +202,8 @@ export const TextInput = forwardRef(function TextInput(
|
|
|
213
202
|
)}
|
|
214
203
|
|
|
215
204
|
<Box as="span" flex={1} position="relative">
|
|
216
|
-
<
|
|
217
|
-
|
|
218
|
-
{...restProps}
|
|
205
|
+
<Element
|
|
206
|
+
{...rest}
|
|
219
207
|
className={_inputElement()}
|
|
220
208
|
disabled={disabled}
|
|
221
209
|
readOnly={readOnly}
|
|
@@ -281,6 +269,6 @@ export const TextInput = forwardRef(function TextInput(
|
|
|
281
269
|
)}
|
|
282
270
|
</Box>
|
|
283
271
|
)
|
|
284
|
-
}
|
|
272
|
+
}
|
|
285
273
|
|
|
286
|
-
TextInput.displayName = '
|
|
274
|
+
TextInput.displayName = 'TextInput'
|
|
@@ -13,10 +13,12 @@ import type {ThemeColorCardToneKey, ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
|
13
13
|
import {AnimatePresence} from 'framer-motion'
|
|
14
14
|
import {
|
|
15
15
|
cloneElement,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
type FocusEvent,
|
|
17
|
+
HTMLAttributes,
|
|
18
|
+
type MouseEvent as ReactMouseEvent,
|
|
19
|
+
type ReactElement,
|
|
20
|
+
type ReactNode,
|
|
21
|
+
RefAttributes,
|
|
20
22
|
useCallback,
|
|
21
23
|
useEffect,
|
|
22
24
|
useId,
|
|
@@ -32,10 +34,11 @@ import {Z_OFFSETS} from '../../constants'
|
|
|
32
34
|
import {useArrayProp, usePrefersReducedMotion} from '../../hooks'
|
|
33
35
|
import {useDelayedState} from '../../hooks/useDelayedState'
|
|
34
36
|
import {origin} from '../../middleware/origin'
|
|
35
|
-
import type {Placement, Props} from '../../types'
|
|
36
|
-
import {Layer, type
|
|
37
|
+
import type {ComponentType, Placement, Props} from '../../types'
|
|
38
|
+
import {Layer, type LayerOwnProps, Portal, useBoundaryElement, usePortal} from '../../utils'
|
|
37
39
|
import {getElementRef} from '../../utils/getElementRef'
|
|
38
|
-
import
|
|
40
|
+
import {CardProvider, useCard} from '../card'
|
|
41
|
+
import {Delay} from '../types'
|
|
39
42
|
import {
|
|
40
43
|
DEFAULT_FALLBACK_PLACEMENTS,
|
|
41
44
|
DEFAULT_TOOLTIP_DISTANCE,
|
|
@@ -44,56 +47,69 @@ import {
|
|
|
44
47
|
import {TooltipCard} from './tooltipCard'
|
|
45
48
|
import {useTooltipDelayGroup} from './tooltipDelayGroup'
|
|
46
49
|
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
50
|
+
/** @public */
|
|
51
|
+
export const DEFAULT_TOOLTIP_ELEMENT = 'div'
|
|
52
|
+
|
|
53
|
+
/** @public */
|
|
54
|
+
export type TooltipOwnProps = LayerOwnProps &
|
|
55
|
+
RadiusStyleProps &
|
|
56
|
+
ShadowStyleProps & {
|
|
57
|
+
/** @deprecated Use `fallbackPlacements` instead. */
|
|
58
|
+
allowedAutoPlacements?: Placement[]
|
|
59
|
+
/**
|
|
60
|
+
* Whether the tooltip should animate in and out.
|
|
61
|
+
*
|
|
62
|
+
* @beta
|
|
63
|
+
* @defaultValue false
|
|
64
|
+
*/
|
|
65
|
+
animate?: boolean
|
|
66
|
+
arrow?: boolean
|
|
67
|
+
boundaryElement?: HTMLElement | null
|
|
68
|
+
children?: ReactElement<HTMLAttributes<HTMLElement> & RefAttributes<HTMLElement>>
|
|
69
|
+
content?: ReactNode
|
|
70
|
+
/**
|
|
71
|
+
* Adds a delay to open or close the tooltip.
|
|
72
|
+
*
|
|
73
|
+
* If only a `number` is passed, it will be used for both opening and closing.
|
|
74
|
+
*
|
|
75
|
+
* If an object `{open: number; close:number}` is passed, it can be used to set different delays for each action.
|
|
76
|
+
*
|
|
77
|
+
* @public
|
|
78
|
+
* @defaultValue 0
|
|
79
|
+
*/
|
|
80
|
+
delay?: Delay
|
|
81
|
+
disabled?: boolean
|
|
82
|
+
fallbackPlacements?: Placement[]
|
|
83
|
+
placement?: Placement
|
|
84
|
+
/** Whether or not to render the tooltip in a portal element. */
|
|
85
|
+
portal?: boolean | string
|
|
86
|
+
scheme?: ThemeColorSchemeKey
|
|
87
|
+
tone?: ThemeColorCardToneKey
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** @public */
|
|
91
|
+
export type TooltipElementType = 'div' | 'span' | ComponentType
|
|
92
|
+
|
|
93
|
+
/** @public */
|
|
94
|
+
export type TooltipProps<E extends TooltipElementType = TooltipElementType> = Props<
|
|
95
|
+
TooltipOwnProps,
|
|
96
|
+
E
|
|
97
|
+
>
|
|
83
98
|
|
|
84
99
|
/**
|
|
85
100
|
* Tooltips display information when hovering, focusing or tapping.
|
|
86
101
|
*
|
|
87
102
|
* @public
|
|
88
103
|
*/
|
|
89
|
-
export
|
|
90
|
-
props:
|
|
91
|
-
forwardedRef: ForwardedRef<HTMLDivElement>,
|
|
104
|
+
export function Tooltip<E extends TooltipElementType = typeof DEFAULT_TOOLTIP_ELEMENT>(
|
|
105
|
+
props: TooltipProps<E>,
|
|
92
106
|
) {
|
|
93
107
|
const boundaryElementContext = useBoundaryElement()
|
|
108
|
+
|
|
94
109
|
const {
|
|
95
110
|
animate: _animate = false,
|
|
96
111
|
arrow: arrowProp = false,
|
|
112
|
+
as = DEFAULT_TOOLTIP_ELEMENT,
|
|
97
113
|
boundaryElement = boundaryElementContext?.element,
|
|
98
114
|
children: childProp,
|
|
99
115
|
className,
|
|
@@ -106,12 +122,15 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
106
122
|
placement: placementProp = 'bottom',
|
|
107
123
|
portal: portalProp,
|
|
108
124
|
radius = 3,
|
|
125
|
+
ref: forwardedRef,
|
|
109
126
|
scheme,
|
|
110
127
|
shadow = 2,
|
|
111
128
|
zOffset = Z_OFFSETS.tooltip,
|
|
112
|
-
tone,
|
|
113
|
-
...
|
|
114
|
-
} = props
|
|
129
|
+
tone = 'inherit',
|
|
130
|
+
...rest
|
|
131
|
+
} = props as TooltipProps<typeof DEFAULT_TOOLTIP_ELEMENT>
|
|
132
|
+
|
|
133
|
+
const card = useCard()
|
|
115
134
|
const prefersReducedMotion = usePrefersReducedMotion()
|
|
116
135
|
const animate = prefersReducedMotion ? false : _animate
|
|
117
136
|
const fallbackPlacements = useArrayProp(fallbackPlacementsProp)
|
|
@@ -228,42 +247,42 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
228
247
|
)
|
|
229
248
|
|
|
230
249
|
const handleBlur = useCallback(
|
|
231
|
-
(e: FocusEvent) => {
|
|
250
|
+
(e: FocusEvent<HTMLElement>) => {
|
|
232
251
|
handleIsOpenChange(false)
|
|
233
252
|
childProp?.props?.onBlur?.(e)
|
|
234
253
|
},
|
|
235
254
|
[childProp?.props, handleIsOpenChange],
|
|
236
255
|
)
|
|
237
256
|
const handleClick = useCallback(
|
|
238
|
-
(e:
|
|
257
|
+
(e: ReactMouseEvent<HTMLElement>) => {
|
|
239
258
|
handleIsOpenChange(false, true)
|
|
240
259
|
childProp?.props.onClick?.(e)
|
|
241
260
|
},
|
|
242
261
|
[childProp?.props, handleIsOpenChange],
|
|
243
262
|
)
|
|
244
263
|
const handleContextMenu = useCallback(
|
|
245
|
-
(e:
|
|
264
|
+
(e: ReactMouseEvent<HTMLElement>) => {
|
|
246
265
|
handleIsOpenChange(false, true)
|
|
247
266
|
childProp?.props.onContextMenu?.(e)
|
|
248
267
|
},
|
|
249
268
|
[childProp?.props, handleIsOpenChange],
|
|
250
269
|
)
|
|
251
270
|
const handleFocus = useCallback(
|
|
252
|
-
(e: FocusEvent) => {
|
|
271
|
+
(e: FocusEvent<HTMLElement>) => {
|
|
253
272
|
handleIsOpenChange(true)
|
|
254
273
|
childProp?.props?.onFocus?.(e)
|
|
255
274
|
},
|
|
256
275
|
[childProp?.props, handleIsOpenChange],
|
|
257
276
|
)
|
|
258
277
|
const handleMouseEnter = useCallback(
|
|
259
|
-
(e:
|
|
278
|
+
(e: ReactMouseEvent<HTMLElement>) => {
|
|
260
279
|
handleIsOpenChange(true)
|
|
261
280
|
childProp?.props?.onMouseEnter?.(e)
|
|
262
281
|
},
|
|
263
282
|
[childProp?.props, handleIsOpenChange],
|
|
264
283
|
)
|
|
265
284
|
const handleMouseLeave = useCallback(
|
|
266
|
-
(e:
|
|
285
|
+
(e: ReactMouseEvent<HTMLElement>) => {
|
|
267
286
|
handleIsOpenChange(false)
|
|
268
287
|
childProp?.props?.onMouseLeave?.(e)
|
|
269
288
|
},
|
|
@@ -364,7 +383,6 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
364
383
|
const node = (
|
|
365
384
|
<Layer
|
|
366
385
|
data-ui="Tooltip"
|
|
367
|
-
// {...restProps}
|
|
368
386
|
className={composeClassNames(className, tooltip())}
|
|
369
387
|
ref={setFloating}
|
|
370
388
|
style={{
|
|
@@ -374,12 +392,13 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
374
392
|
zOffset={zOffset}
|
|
375
393
|
>
|
|
376
394
|
<TooltipCard
|
|
377
|
-
{...
|
|
395
|
+
{...rest}
|
|
378
396
|
animate={animate}
|
|
379
397
|
arrow={arrowProp}
|
|
380
398
|
arrowRef={setArrow}
|
|
381
399
|
arrowX={arrowX}
|
|
382
400
|
arrowY={arrowY}
|
|
401
|
+
as={as}
|
|
383
402
|
originX={originX}
|
|
384
403
|
originY={originY}
|
|
385
404
|
padding={padding}
|
|
@@ -399,7 +418,12 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
399
418
|
showTooltip &&
|
|
400
419
|
(portalProp ? (
|
|
401
420
|
<Portal __unstable_name={typeof portalProp === 'string' ? portalProp : undefined}>
|
|
402
|
-
|
|
421
|
+
<CardProvider
|
|
422
|
+
tone={tone === 'inherit' ? (card?.tone ?? 'default') : tone}
|
|
423
|
+
scheme={scheme ?? 'light'}
|
|
424
|
+
>
|
|
425
|
+
{node}
|
|
426
|
+
</CardProvider>
|
|
403
427
|
</Portal>
|
|
404
428
|
) : (
|
|
405
429
|
node
|
|
@@ -414,9 +438,7 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
414
438
|
{child}
|
|
415
439
|
</>
|
|
416
440
|
)
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
Tooltip.displayName = 'ForwardRef(Tooltip)'
|
|
441
|
+
}
|
|
420
442
|
|
|
421
443
|
/**
|
|
422
444
|
* As `useEffectEvent` should never be passed to other components or hooks, this custom hook groups together the `useEffectEvent` and the `useEffect` hook using it.
|
|
@@ -464,3 +486,5 @@ function useCloseOnMouseLeave({
|
|
|
464
486
|
return () => window.removeEventListener('mousemove', handleMouseMove)
|
|
465
487
|
}, [isInsideGroup, showTooltip])
|
|
466
488
|
}
|
|
489
|
+
|
|
490
|
+
Tooltip.displayName = 'Tooltip'
|