@sanity/ui 0.37.12 → 0.37.14-next.6
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/lib/dts/src/components/autocomplete/autocomplete.d.ts +2 -2
- package/lib/dts/src/components/autocomplete/autocomplete.d.ts.map +1 -1
- package/lib/dts/src/components/autocomplete/autocomplete.styles.d.ts +1 -1
- package/lib/dts/src/components/autocomplete/autocomplete.styles.d.ts.map +1 -1
- package/lib/dts/src/components/autocomplete/constants.d.ts +0 -4
- package/lib/dts/src/components/autocomplete/constants.d.ts.map +1 -1
- package/lib/dts/src/components/breadcrumbs/breadcrumbs.d.ts.map +1 -1
- package/lib/dts/src/components/dialog/dialog.d.ts.map +1 -1
- package/lib/dts/src/components/dialog/styles.d.ts +1 -1
- package/lib/dts/src/components/dialog/styles.d.ts.map +1 -1
- package/lib/dts/src/components/hotkeys/hotkeys.d.ts.map +1 -1
- package/lib/dts/src/components/menu/menuButton.d.ts.map +1 -1
- package/lib/dts/src/components/menu/menuGroup.d.ts.map +1 -1
- package/lib/dts/src/components/menu/menuItem.d.ts.map +1 -1
- package/lib/dts/src/components/skeleton/skeleton.d.ts.map +1 -1
- package/lib/dts/src/constants.d.ts +10 -0
- package/lib/dts/src/constants.d.ts.map +1 -1
- package/lib/dts/src/hooks/_internal/useUnique.d.ts +2 -3
- package/lib/dts/src/hooks/_internal/useUnique.d.ts.map +1 -1
- package/lib/dts/src/hooks/index.d.ts +2 -1
- package/lib/dts/src/hooks/index.d.ts.map +1 -1
- package/lib/dts/src/hooks/useArrayProp.d.ts +7 -0
- package/lib/dts/src/hooks/useArrayProp.d.ts.map +1 -0
- package/lib/dts/src/hooks/useElementRect/useElementRect.d.ts +1 -1
- package/lib/dts/src/hooks/useElementRect/useElementRect.d.ts.map +1 -1
- package/lib/dts/src/hooks/useElementSize.d.ts +7 -0
- package/lib/dts/src/hooks/useElementSize.d.ts.map +1 -0
- package/lib/dts/src/index.d.ts +1 -0
- package/lib/dts/src/index.d.ts.map +1 -1
- package/lib/dts/src/observers/elementSizeObserver.d.ts +37 -0
- package/lib/dts/src/observers/elementSizeObserver.d.ts.map +1 -0
- package/lib/dts/src/observers/index.d.ts +3 -0
- package/lib/dts/src/observers/index.d.ts.map +1 -0
- package/lib/dts/src/observers/resizeObserver.d.ts +5 -0
- package/lib/dts/src/observers/resizeObserver.d.ts.map +1 -0
- package/lib/dts/src/primitives/_selectable/selectable.d.ts +1 -2
- package/lib/dts/src/primitives/_selectable/selectable.d.ts.map +1 -1
- package/lib/dts/src/primitives/avatar/avatar.d.ts.map +1 -1
- package/lib/dts/src/primitives/avatar/avatarCounter.d.ts +1 -0
- package/lib/dts/src/primitives/avatar/avatarCounter.d.ts.map +1 -1
- package/lib/dts/src/primitives/avatar/avatarStack.d.ts +1 -0
- package/lib/dts/src/primitives/avatar/avatarStack.d.ts.map +1 -1
- package/lib/dts/src/primitives/avatar/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/badge/badge.d.ts.map +1 -1
- package/lib/dts/src/primitives/box/box.d.ts.map +1 -1
- package/lib/dts/src/primitives/button/button.d.ts.map +1 -1
- package/lib/dts/src/primitives/card/card.d.ts.map +1 -1
- package/lib/dts/src/primitives/code/code.d.ts.map +1 -1
- package/lib/dts/src/primitives/container/container.d.ts.map +1 -1
- package/lib/dts/src/primitives/container/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/container/types.d.ts +1 -1
- package/lib/dts/src/primitives/container/types.d.ts.map +1 -1
- package/lib/dts/src/primitives/flex/flex.d.ts.map +1 -1
- package/lib/dts/src/primitives/grid/grid.d.ts.map +1 -1
- package/lib/dts/src/primitives/heading/heading.d.ts.map +1 -1
- package/lib/dts/src/primitives/inline/inline.d.ts.map +1 -1
- package/lib/dts/src/primitives/inline/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/inline/types.d.ts +1 -1
- package/lib/dts/src/primitives/inline/types.d.ts.map +1 -1
- package/lib/dts/src/primitives/kbd/kbd.d.ts.map +1 -1
- package/lib/dts/src/primitives/label/label.d.ts.map +1 -1
- package/lib/dts/src/primitives/popover/popover.d.ts +6 -5
- package/lib/dts/src/primitives/popover/popover.d.ts.map +1 -1
- package/lib/dts/src/primitives/popover/{arrow.d.ts → popoverArrow.d.ts} +1 -1
- package/lib/dts/src/primitives/popover/popoverArrow.d.ts.map +1 -0
- package/lib/dts/src/primitives/popover/popoverCard.d.ts +33 -0
- package/lib/dts/src/primitives/popover/popoverCard.d.ts.map +1 -0
- package/lib/dts/src/primitives/select/styles.d.ts +5 -1
- package/lib/dts/src/primitives/select/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/stack/stack.d.ts.map +1 -1
- package/lib/dts/src/primitives/stack/styles.d.ts +1 -1
- package/lib/dts/src/primitives/stack/styles.d.ts.map +1 -1
- package/lib/dts/src/primitives/text/text.d.ts.map +1 -1
- package/lib/dts/src/primitives/textArea/textArea.d.ts.map +1 -1
- package/lib/dts/src/primitives/textInput/textInput.d.ts.map +1 -1
- package/lib/dts/src/primitives/tooltip/tooltip.d.ts +2 -0
- package/lib/dts/src/primitives/tooltip/tooltip.d.ts.map +1 -1
- package/lib/dts/src/primitives/tooltip/tooltipArrow.d.ts.map +1 -1
- package/lib/dts/src/primitives/types.d.ts +1 -1
- package/lib/dts/src/primitives/types.d.ts.map +1 -1
- package/lib/dts/src/styles/border/types.d.ts +5 -5
- package/lib/dts/src/styles/border/types.d.ts.map +1 -1
- package/lib/dts/src/styles/box/types.d.ts +4 -4
- package/lib/dts/src/styles/box/types.d.ts.map +1 -1
- package/lib/dts/src/styles/flex/flexItemStyle.d.ts.map +1 -1
- package/lib/dts/src/styles/flex/types.d.ts +6 -6
- package/lib/dts/src/styles/flex/types.d.ts.map +1 -1
- package/lib/dts/src/styles/font/responsiveFont.d.ts +1 -1
- package/lib/dts/src/styles/font/responsiveFont.d.ts.map +1 -1
- package/lib/dts/src/styles/font/types.d.ts +3 -3
- package/lib/dts/src/styles/font/types.d.ts.map +1 -1
- package/lib/dts/src/styles/grid/types.d.ts +14 -14
- package/lib/dts/src/styles/grid/types.d.ts.map +1 -1
- package/lib/dts/src/styles/helpers.d.ts +4 -4
- package/lib/dts/src/styles/helpers.d.ts.map +1 -1
- package/lib/dts/src/styles/input/responsiveInputPaddingStyle.d.ts +12 -12
- package/lib/dts/src/styles/input/responsiveInputPaddingStyle.d.ts.map +1 -1
- package/lib/dts/src/styles/input/textInputStyle.d.ts +4 -1
- package/lib/dts/src/styles/input/textInputStyle.d.ts.map +1 -1
- package/lib/dts/src/styles/margin/types.d.ts +7 -7
- package/lib/dts/src/styles/margin/types.d.ts.map +1 -1
- package/lib/dts/src/styles/padding/types.d.ts +7 -7
- package/lib/dts/src/styles/padding/types.d.ts.map +1 -1
- package/lib/dts/src/styles/radius/types.d.ts +1 -1
- package/lib/dts/src/styles/radius/types.d.ts.map +1 -1
- package/lib/dts/src/styles/shadow/shadowStyle.d.ts.map +1 -1
- package/lib/dts/src/styles/shadow/types.d.ts +1 -1
- package/lib/dts/src/styles/shadow/types.d.ts.map +1 -1
- package/lib/dts/src/theme/lib/theme/fonts.d.ts +1 -3
- package/lib/dts/src/theme/lib/theme/fonts.d.ts.map +1 -1
- package/lib/dts/src/theme/studioTheme/fonts.d.ts.map +1 -1
- package/lib/dts/src/types/index.d.ts +2 -1
- package/lib/dts/src/types/index.d.ts.map +1 -1
- package/lib/dts/src/types/placement.d.ts +7 -0
- package/lib/dts/src/types/placement.d.ts.map +1 -0
- package/lib/dts/src/types/text.d.ts +5 -0
- package/lib/dts/src/types/text.d.ts.map +1 -0
- package/lib/dts/src/utils/elementQuery/elementQuery.d.ts.map +1 -1
- package/lib/dts/src/utils/index.d.ts +0 -1
- package/lib/dts/src/utils/index.d.ts.map +1 -1
- package/lib/dts/src/utils/virtualList/virtualList.d.ts.map +1 -1
- package/lib/sanity-ui.js +1214 -1054
- package/lib/sanity-ui.js.map +1 -1
- package/lib/{sanity-ui.modern.js → sanity-ui.modern.mjs} +1246 -1120
- package/lib/sanity-ui.modern.mjs.map +1 -0
- package/lib/sanity-ui.module.js +1106 -947
- package/lib/sanity-ui.module.js.map +1 -1
- package/package.json +11 -12
- package/src/__workshop__/color/overview.tsx +9 -11
- package/src/components/autocomplete/__workshop__/async.tsx +14 -12
- package/src/components/autocomplete/__workshop__/constrainedHeight.tsx +36 -0
- package/src/components/autocomplete/autocomplete.styles.tsx +0 -6
- package/src/components/autocomplete/autocomplete.tsx +14 -7
- package/src/components/autocomplete/constants.ts +3 -8
- package/src/components/breadcrumbs/breadcrumbs.tsx +3 -2
- package/src/components/dialog/dialog.tsx +17 -9
- package/src/components/dialog/styles.ts +3 -3
- package/src/components/hotkeys/hotkeys.tsx +3 -1
- package/src/components/menu/__workshop__/constrainedInBoundary.tsx +11 -14
- package/src/components/menu/__workshop__/groups.tsx +1 -1
- package/src/components/menu/menuButton.tsx +21 -13
- package/src/components/menu/menuGroup.tsx +3 -2
- package/src/components/menu/menuItem.tsx +4 -5
- package/src/components/skeleton/skeleton.tsx +10 -1
- package/src/components/skeleton/textSkeleton.tsx +7 -7
- package/src/constants.ts +17 -0
- package/src/hooks/_internal/useUnique.ts +4 -5
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useArrayProp.ts +23 -0
- package/src/hooks/useElementRect/useElementRect.ts +4 -16
- package/src/hooks/useElementSize.ts +18 -0
- package/src/index.ts +1 -0
- package/src/observers/elementSizeObserver.ts +116 -0
- package/src/observers/index.ts +2 -0
- package/src/{utils → observers}/resizeObserver.ts +1 -4
- package/src/primitives/_selectable/selectable.tsx +5 -4
- package/src/primitives/avatar/avatar.tsx +7 -5
- package/src/primitives/avatar/avatarCounter.tsx +14 -12
- package/src/primitives/avatar/avatarStack.tsx +19 -13
- package/src/primitives/avatar/styles.ts +2 -2
- package/src/primitives/badge/badge.tsx +3 -2
- package/src/primitives/box/box.tsx +27 -26
- package/src/primitives/button/button.tsx +22 -10
- package/src/primitives/card/card.tsx +13 -11
- package/src/primitives/checkbox/__workshop__/example.tsx +4 -2
- package/src/primitives/checkbox/__workshop__/props.tsx +4 -2
- package/src/primitives/checkbox/__workshop__/readOnly.tsx +4 -2
- package/src/primitives/code/__workshop__/props.tsx +1 -1
- package/src/primitives/code/code.tsx +2 -1
- package/src/primitives/container/container.tsx +10 -1
- package/src/primitives/container/styles.ts +2 -2
- package/src/primitives/container/types.ts +1 -1
- package/src/primitives/flex/flex.tsx +6 -5
- package/src/primitives/grid/__workshop__/responsive.tsx +13 -12
- package/src/primitives/grid/grid.tsx +9 -8
- package/src/primitives/heading/__workshop__/opticalAlignment.tsx +19 -7
- package/src/primitives/heading/heading.tsx +3 -2
- package/src/primitives/inline/inline.tsx +12 -6
- package/src/primitives/inline/styles.ts +2 -2
- package/src/primitives/inline/types.ts +1 -1
- package/src/primitives/kbd/kbd.tsx +2 -1
- package/src/primitives/label/label.tsx +4 -3
- package/src/primitives/popover/__workshop__/{margins.tsx → MarginsStory.tsx} +1 -1
- package/src/primitives/popover/__workshop__/{matchReferenceWidth.tsx → MatchReferenceWidthStory.tsx} +0 -0
- package/src/primitives/popover/__workshop__/{plain.tsx → PlainStory.tsx} +13 -14
- package/src/primitives/popover/__workshop__/{recursive.tsx → RecursiveStory.tsx} +4 -1
- package/src/primitives/popover/__workshop__/RightAlignedStory.tsx +61 -0
- package/src/primitives/popover/__workshop__/TestStory.tsx +80 -0
- package/src/primitives/popover/__workshop__/index.ts +10 -5
- package/src/primitives/popover/popover.tsx +245 -193
- package/src/primitives/popover/{arrow.tsx → popoverArrow.tsx} +5 -5
- package/src/primitives/popover/popoverCard.tsx +160 -0
- package/src/primitives/select/select.tsx +9 -9
- package/src/primitives/select/styles.ts +10 -4
- package/src/primitives/stack/stack.tsx +2 -1
- package/src/primitives/stack/styles.ts +3 -3
- package/src/primitives/text/__workshop__/opticalAlignment.tsx +15 -5
- package/src/primitives/text/text.tsx +3 -2
- package/src/primitives/textArea/__workshop__/plain.tsx +23 -18
- package/src/primitives/textArea/textArea.tsx +17 -5
- package/src/primitives/textInput/__workshop__/clearButton.tsx +14 -8
- package/src/primitives/textInput/__workshop__/index.ts +2 -2
- package/src/primitives/textInput/__workshop__/plain.tsx +39 -32
- package/src/primitives/textInput/__workshop__/tones.tsx +97 -75
- package/src/primitives/textInput/__workshop__/typed.tsx +8 -2
- package/src/primitives/textInput/textInput.tsx +43 -12
- package/src/primitives/tooltip/__workshop__/props.tsx +7 -1
- package/src/primitives/tooltip/tooltip.tsx +162 -85
- package/src/primitives/tooltip/tooltipArrow.tsx +25 -10
- package/src/primitives/types.ts +1 -1
- package/src/styles/border/borderStyle.ts +6 -6
- package/src/styles/border/types.ts +5 -5
- package/src/styles/box/boxStyle.ts +5 -5
- package/src/styles/box/types.ts +4 -4
- package/src/styles/flex/flexItemStyle.ts +5 -4
- package/src/styles/flex/flexStyle.ts +6 -6
- package/src/styles/flex/types.ts +6 -6
- package/src/styles/font/responsiveFont.ts +7 -27
- package/src/styles/font/textAlignStyle.ts +2 -2
- package/src/styles/font/types.ts +4 -3
- package/src/styles/grid/gridItemStyle.ts +7 -7
- package/src/styles/grid/gridStyle.ts +9 -9
- package/src/styles/grid/types.ts +14 -14
- package/src/styles/helpers.ts +9 -9
- package/src/styles/input/responsiveInputPaddingStyle.ts +24 -27
- package/src/styles/input/textInputStyle.ts +89 -79
- package/src/styles/margin/marginStyle.ts +8 -8
- package/src/styles/margin/marginsStyle.test.ts +1 -1
- package/src/styles/margin/types.ts +7 -7
- package/src/styles/padding/paddingStyle.test.ts +1 -1
- package/src/styles/padding/paddingStyle.ts +8 -8
- package/src/styles/padding/types.ts +7 -7
- package/src/styles/radius/radiusStyle.ts +2 -2
- package/src/styles/radius/types.ts +1 -1
- package/src/styles/shadow/shadowStyle.ts +2 -5
- package/src/styles/shadow/types.ts +1 -1
- package/src/theme/lib/theme/fonts.ts +1 -3
- package/src/theme/studioTheme/fonts.ts +5 -9
- package/src/types/index.ts +2 -2
- package/src/types/placement.ts +18 -0
- package/src/types/text.ts +4 -0
- package/src/utils/elementQuery/elementQuery.tsx +5 -18
- package/src/utils/index.ts +0 -1
- package/src/utils/layer/layer.tsx +1 -1
- package/src/utils/layer/layerProvider.tsx +2 -2
- package/src/utils/virtualList/virtualList.tsx +8 -7
- package/lib/dts/src/hooks/useResponsiveProp.d.ts +0 -6
- package/lib/dts/src/hooks/useResponsiveProp.d.ts.map +0 -1
- package/lib/dts/src/primitives/popover/arrow.d.ts.map +0 -1
- package/lib/dts/src/primitives/popover/modifiers/getPopoverModifiers.d.ts +0 -4
- package/lib/dts/src/primitives/popover/modifiers/getPopoverModifiers.d.ts.map +0 -1
- package/lib/dts/src/primitives/popover/modifiers/index.d.ts +0 -2
- package/lib/dts/src/primitives/popover/modifiers/index.d.ts.map +0 -1
- package/lib/dts/src/primitives/popover/modifiers/types.d.ts +0 -18
- package/lib/dts/src/primitives/popover/modifiers/types.d.ts.map +0 -1
- package/lib/dts/src/primitives/popover/modifiers/usePopoverModifiers.d.ts +0 -4
- package/lib/dts/src/primitives/popover/modifiers/usePopoverModifiers.d.ts.map +0 -1
- package/lib/dts/src/types/common.d.ts +0 -11
- package/lib/dts/src/types/common.d.ts.map +0 -1
- package/lib/dts/src/utils/resizeObserver.d.ts +0 -6
- package/lib/dts/src/utils/resizeObserver.d.ts.map +0 -1
- package/lib/sanity-ui.modern.js.map +0 -1
- package/src/hooks/useResponsiveProp.ts +0 -10
- package/src/primitives/popover/__workshop__/rightAligned.tsx +0 -57
- package/src/primitives/popover/modifiers/getPopoverModifiers.ts +0 -137
- package/src/primitives/popover/modifiers/index.ts +0 -1
- package/src/primitives/popover/modifiers/types.ts +0 -18
- package/src/primitives/popover/modifiers/usePopoverModifiers.ts +0 -58
- package/src/types/common.ts +0 -12
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import {Box, Card, Container, Stack, Text, TextInput} from '@sanity/ui'
|
|
2
|
+
import {useBoolean} from '@sanity/ui-workshop'
|
|
2
3
|
import React from 'react'
|
|
3
4
|
|
|
4
5
|
export default function TonesStory() {
|
|
6
|
+
const transparentTone = useBoolean('Transparent', true)
|
|
7
|
+
const primaryTone = useBoolean('Primary', true)
|
|
8
|
+
const positiveTone = useBoolean('Positive', true)
|
|
9
|
+
const cautionTone = useBoolean('Caution', true)
|
|
10
|
+
const criticalTone = useBoolean('Critical', true)
|
|
11
|
+
|
|
5
12
|
return (
|
|
6
13
|
<Container width={1}>
|
|
7
14
|
<Stack padding={[3, 4, 5]} space={4}>
|
|
@@ -20,81 +27,96 @@ export default function TonesStory() {
|
|
|
20
27
|
}
|
|
21
28
|
/>
|
|
22
29
|
</Card>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
30
|
+
|
|
31
|
+
{transparentTone && (
|
|
32
|
+
<Card padding={3} tone="transparent">
|
|
33
|
+
<TextInput
|
|
34
|
+
placeholder="transparent"
|
|
35
|
+
prefix={
|
|
36
|
+
<Box padding={3}>
|
|
37
|
+
<Text>prefix</Text>
|
|
38
|
+
</Box>
|
|
39
|
+
}
|
|
40
|
+
suffix={
|
|
41
|
+
<Box padding={3}>
|
|
42
|
+
<Text>suffix</Text>
|
|
43
|
+
</Box>
|
|
44
|
+
}
|
|
45
|
+
/>
|
|
46
|
+
</Card>
|
|
47
|
+
)}
|
|
48
|
+
|
|
49
|
+
{primaryTone && (
|
|
50
|
+
<Card padding={3} tone="primary">
|
|
51
|
+
<TextInput
|
|
52
|
+
placeholder="primary"
|
|
53
|
+
prefix={
|
|
54
|
+
<Box padding={3}>
|
|
55
|
+
<Text>prefix</Text>
|
|
56
|
+
</Box>
|
|
57
|
+
}
|
|
58
|
+
suffix={
|
|
59
|
+
<Box padding={3}>
|
|
60
|
+
<Text>suffix</Text>
|
|
61
|
+
</Box>
|
|
62
|
+
}
|
|
63
|
+
/>
|
|
64
|
+
</Card>
|
|
65
|
+
)}
|
|
66
|
+
|
|
67
|
+
{positiveTone && (
|
|
68
|
+
<Card padding={3} tone="positive">
|
|
69
|
+
<TextInput
|
|
70
|
+
placeholder="positive"
|
|
71
|
+
prefix={
|
|
72
|
+
<Box padding={3}>
|
|
73
|
+
<Text>prefix</Text>
|
|
74
|
+
</Box>
|
|
75
|
+
}
|
|
76
|
+
suffix={
|
|
77
|
+
<Box padding={3}>
|
|
78
|
+
<Text>suffix</Text>
|
|
79
|
+
</Box>
|
|
80
|
+
}
|
|
81
|
+
/>
|
|
82
|
+
</Card>
|
|
83
|
+
)}
|
|
84
|
+
|
|
85
|
+
{cautionTone && (
|
|
86
|
+
<Card padding={3} tone="caution">
|
|
87
|
+
<TextInput
|
|
88
|
+
placeholder="caution"
|
|
89
|
+
prefix={
|
|
90
|
+
<Box padding={3}>
|
|
91
|
+
<Text>prefix</Text>
|
|
92
|
+
</Box>
|
|
93
|
+
}
|
|
94
|
+
suffix={
|
|
95
|
+
<Box padding={3}>
|
|
96
|
+
<Text>suffix</Text>
|
|
97
|
+
</Box>
|
|
98
|
+
}
|
|
99
|
+
/>
|
|
100
|
+
</Card>
|
|
101
|
+
)}
|
|
102
|
+
|
|
103
|
+
{criticalTone && (
|
|
104
|
+
<Card padding={3} tone="critical">
|
|
105
|
+
<TextInput
|
|
106
|
+
placeholder="critical"
|
|
107
|
+
prefix={
|
|
108
|
+
<Box padding={3}>
|
|
109
|
+
<Text>prefix</Text>
|
|
110
|
+
</Box>
|
|
111
|
+
}
|
|
112
|
+
suffix={
|
|
113
|
+
<Box padding={3}>
|
|
114
|
+
<Text>suffix</Text>
|
|
115
|
+
</Box>
|
|
116
|
+
}
|
|
117
|
+
/>
|
|
118
|
+
</Card>
|
|
119
|
+
)}
|
|
98
120
|
</Stack>
|
|
99
121
|
</Container>
|
|
100
122
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {TextInput} from '@sanity/ui'
|
|
1
|
+
import {Box, Container, TextInput} from '@sanity/ui'
|
|
2
2
|
import {useSelect} from '@sanity/ui-workshop'
|
|
3
3
|
import React, {useCallback, useState} from 'react'
|
|
4
4
|
import {WORKSHOP_TEXT_INPUT_TYPE_OPTIONS} from '../../../__workshop__/constants'
|
|
@@ -12,5 +12,11 @@ export default function TypedStory() {
|
|
|
12
12
|
setValue(event.currentTarget.value)
|
|
13
13
|
}, [])
|
|
14
14
|
|
|
15
|
-
return
|
|
15
|
+
return (
|
|
16
|
+
<Box padding={4}>
|
|
17
|
+
<Container width={1}>
|
|
18
|
+
<TextInput onChange={handleChange} type={type} value={value} />
|
|
19
|
+
</Container>
|
|
20
|
+
</Box>
|
|
21
|
+
)
|
|
16
22
|
}
|
|
@@ -3,7 +3,7 @@ import React, {createElement, forwardRef, isValidElement, useCallback, useMemo}
|
|
|
3
3
|
import {isValidElementType} from 'react-is'
|
|
4
4
|
import styled from 'styled-components'
|
|
5
5
|
import {EMPTY_RECORD} from '../../constants'
|
|
6
|
-
import {useForwardedRef, useCustomValidity
|
|
6
|
+
import {useArrayProp, useForwardedRef, useCustomValidity} from '../../hooks'
|
|
7
7
|
import {
|
|
8
8
|
responsiveRadiusStyle,
|
|
9
9
|
ResponsiveRadiusStyleProps,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
textInputRepresentationStyle,
|
|
17
17
|
textInputRootStyle,
|
|
18
18
|
} from '../../styles/internal'
|
|
19
|
-
import {ThemeFontWeightKey} from '../../theme'
|
|
19
|
+
import {ThemeFontWeightKey, useRootTheme} from '../../theme'
|
|
20
20
|
import {Box} from '../box'
|
|
21
21
|
import {Button, ButtonProps} from '../button'
|
|
22
22
|
import {Card} from '../card'
|
|
@@ -72,7 +72,7 @@ export interface TextInputProps {
|
|
|
72
72
|
|
|
73
73
|
const CLEAR_BUTTON_BOX_STYLE: React.CSSProperties = {zIndex: 2}
|
|
74
74
|
|
|
75
|
-
const Root = styled.span(textInputRootStyle)
|
|
75
|
+
const Root = styled(Card).attrs({forwardedAs: 'span'})(textInputRootStyle)
|
|
76
76
|
|
|
77
77
|
const InputRoot = styled.span`
|
|
78
78
|
flex: 1;
|
|
@@ -118,6 +118,12 @@ const LeftBox = styled(Box)`
|
|
|
118
118
|
left: 0;
|
|
119
119
|
`
|
|
120
120
|
|
|
121
|
+
const RightBox = styled(Box)`
|
|
122
|
+
position: absolute;
|
|
123
|
+
top: 0;
|
|
124
|
+
right: 0;
|
|
125
|
+
`
|
|
126
|
+
|
|
121
127
|
const RightCard = styled(Card)`
|
|
122
128
|
background-color: transparent;
|
|
123
129
|
position: absolute;
|
|
@@ -136,7 +142,7 @@ export const TextInput = forwardRef(function TextInput(
|
|
|
136
142
|
border = true,
|
|
137
143
|
clearButton,
|
|
138
144
|
disabled = false,
|
|
139
|
-
fontSize = 2,
|
|
145
|
+
fontSize: fontSizeProp = 2,
|
|
140
146
|
icon,
|
|
141
147
|
iconRight,
|
|
142
148
|
onClear,
|
|
@@ -144,16 +150,22 @@ export const TextInput = forwardRef(function TextInput(
|
|
|
144
150
|
prefix,
|
|
145
151
|
radius: radiusProp = 1,
|
|
146
152
|
readOnly,
|
|
147
|
-
space = 3,
|
|
153
|
+
space: spaceProp = 3,
|
|
148
154
|
suffix,
|
|
149
155
|
customValidity,
|
|
150
156
|
type = 'text',
|
|
157
|
+
weight,
|
|
151
158
|
...restProps
|
|
152
159
|
} = props
|
|
153
160
|
|
|
154
161
|
const ref = useForwardedRef(forwardedRef)
|
|
155
|
-
|
|
156
|
-
const
|
|
162
|
+
|
|
163
|
+
const rootTheme = useRootTheme()
|
|
164
|
+
|
|
165
|
+
const fontSize = useArrayProp(fontSizeProp)
|
|
166
|
+
const padding = useArrayProp(paddingProp)
|
|
167
|
+
const radius = useArrayProp(radiusProp)
|
|
168
|
+
const space = useArrayProp(spaceProp)
|
|
157
169
|
|
|
158
170
|
// Transient properties
|
|
159
171
|
const $hasClearButton = Boolean(clearButton)
|
|
@@ -202,6 +214,8 @@ export const TextInput = forwardRef(function TextInput(
|
|
|
202
214
|
$hasPrefix={$hasPrefix}
|
|
203
215
|
$hasSuffix={$hasSuffix}
|
|
204
216
|
$radius={radius}
|
|
217
|
+
$tone={rootTheme.tone}
|
|
218
|
+
data-tone={rootTheme.tone}
|
|
205
219
|
>
|
|
206
220
|
{icon && (
|
|
207
221
|
<LeftBox padding={padding}>
|
|
@@ -213,16 +227,27 @@ export const TextInput = forwardRef(function TextInput(
|
|
|
213
227
|
)}
|
|
214
228
|
|
|
215
229
|
{!$hasClearButton && iconRight && (
|
|
216
|
-
<
|
|
230
|
+
<RightBox padding={padding}>
|
|
217
231
|
<Text size={fontSize}>
|
|
218
232
|
{isValidElement(iconRight) && iconRight}
|
|
219
233
|
{isValidElementType(iconRight) && createElement(iconRight)}
|
|
220
234
|
</Text>
|
|
221
|
-
</
|
|
235
|
+
</RightBox>
|
|
222
236
|
)}
|
|
223
237
|
</Presentation>
|
|
224
238
|
),
|
|
225
|
-
[
|
|
239
|
+
[
|
|
240
|
+
border,
|
|
241
|
+
fontSize,
|
|
242
|
+
icon,
|
|
243
|
+
iconRight,
|
|
244
|
+
padding,
|
|
245
|
+
radius,
|
|
246
|
+
rootTheme.tone,
|
|
247
|
+
$hasClearButton,
|
|
248
|
+
$hasPrefix,
|
|
249
|
+
$hasSuffix,
|
|
250
|
+
]
|
|
226
251
|
)
|
|
227
252
|
|
|
228
253
|
// Render clear button (memoized)
|
|
@@ -303,25 +328,31 @@ export const TextInput = forwardRef(function TextInput(
|
|
|
303
328
|
)
|
|
304
329
|
|
|
305
330
|
return (
|
|
306
|
-
<Root data-ui="TextInput">
|
|
331
|
+
<Root data-ui="TextInput" tone={rootTheme.tone}>
|
|
307
332
|
{prefixNode}
|
|
333
|
+
|
|
308
334
|
<InputRoot>
|
|
309
335
|
<Input
|
|
310
336
|
data-as="input"
|
|
337
|
+
data-tone={rootTheme.tone}
|
|
311
338
|
{...restProps}
|
|
339
|
+
$fontSize={fontSize}
|
|
312
340
|
$iconLeft={$hasIcon}
|
|
313
341
|
$iconRight={$hasIconRight || $hasClearButton}
|
|
314
342
|
$padding={padding}
|
|
315
343
|
$space={space}
|
|
316
|
-
$
|
|
344
|
+
$tone={rootTheme.tone}
|
|
345
|
+
$weight={weight}
|
|
317
346
|
disabled={disabled}
|
|
318
347
|
readOnly={readOnly}
|
|
319
348
|
ref={ref}
|
|
320
349
|
type={type}
|
|
321
350
|
/>
|
|
351
|
+
|
|
322
352
|
{presentationNode}
|
|
323
353
|
{clearButtonNode}
|
|
324
354
|
</InputRoot>
|
|
355
|
+
|
|
325
356
|
{suffixNode}
|
|
326
357
|
</Root>
|
|
327
358
|
)
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import {Box, Button, Card, Flex, Text, Tooltip} from '@sanity/ui'
|
|
2
|
+
import {useSelect} from '@sanity/ui-workshop'
|
|
2
3
|
import React from 'react'
|
|
4
|
+
import {WORKSHOP_PLACEMENT_OPTIONS, WORKSHOP_SHADOW_OPTIONS} from '../../../__workshop__/constants'
|
|
3
5
|
|
|
4
6
|
export default function PropsStory() {
|
|
7
|
+
const placement = useSelect('Placement', WORKSHOP_PLACEMENT_OPTIONS, 'top')
|
|
8
|
+
const shadow = useSelect('Shadow', WORKSHOP_SHADOW_OPTIONS, 2)
|
|
9
|
+
|
|
5
10
|
return (
|
|
6
11
|
<Card height="fill">
|
|
7
12
|
<Flex align="center" height="fill" justify="center" padding={4} sizing="border">
|
|
@@ -11,8 +16,9 @@ export default function PropsStory() {
|
|
|
11
16
|
<Text size={1}>Tooltip content</Text>
|
|
12
17
|
</Box>
|
|
13
18
|
}
|
|
14
|
-
placement=
|
|
19
|
+
placement={placement}
|
|
15
20
|
portal
|
|
21
|
+
shadow={shadow}
|
|
16
22
|
>
|
|
17
23
|
<Button mode="bleed" text="Hover me" />
|
|
18
24
|
</Tooltip>
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
arrow,
|
|
3
|
+
autoUpdate,
|
|
4
|
+
flip,
|
|
5
|
+
offset,
|
|
6
|
+
shift,
|
|
7
|
+
useFloating,
|
|
8
|
+
Middleware,
|
|
9
|
+
RootBoundary,
|
|
10
|
+
} from '@floating-ui/react-dom'
|
|
11
|
+
import React, {
|
|
12
|
+
cloneElement,
|
|
13
|
+
forwardRef,
|
|
14
|
+
useCallback,
|
|
15
|
+
useEffect,
|
|
16
|
+
useMemo,
|
|
17
|
+
useRef,
|
|
18
|
+
useState,
|
|
19
|
+
CSSProperties,
|
|
20
|
+
ForwardedRef,
|
|
21
|
+
} from 'react'
|
|
3
22
|
import styled from 'styled-components'
|
|
4
|
-
import {
|
|
23
|
+
import {FLOATING_STATIC_SIDES} from '../../constants'
|
|
24
|
+
import {useArrayProp, useForwardedRef} from '../../hooks'
|
|
5
25
|
import {ThemeColorSchemeKey, useTheme} from '../../theme'
|
|
6
26
|
import {Placement} from '../../types'
|
|
7
27
|
import {Layer, LayerProps, Portal, useBoundaryElement} from '../../utils'
|
|
@@ -12,6 +32,7 @@ import {TooltipArrow} from './tooltipArrow'
|
|
|
12
32
|
* @public
|
|
13
33
|
*/
|
|
14
34
|
export interface TooltipProps extends Omit<LayerProps, 'as'> {
|
|
35
|
+
/** @deprecated Use `fallbackPlacements` instead. */
|
|
15
36
|
allowedAutoPlacements?: Placement[]
|
|
16
37
|
boundaryElement?: HTMLElement | null
|
|
17
38
|
children?: React.ReactElement
|
|
@@ -21,6 +42,7 @@ export interface TooltipProps extends Omit<LayerProps, 'as'> {
|
|
|
21
42
|
placement?: Placement
|
|
22
43
|
portal?: boolean | string
|
|
23
44
|
scheme?: ThemeColorSchemeKey
|
|
45
|
+
shadow?: number | number[]
|
|
24
46
|
}
|
|
25
47
|
|
|
26
48
|
const Root = styled(Layer)`
|
|
@@ -37,54 +59,88 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
37
59
|
const boundaryElementContext = useBoundaryElement()
|
|
38
60
|
const theme = useTheme()
|
|
39
61
|
const {
|
|
40
|
-
allowedAutoPlacements,
|
|
41
62
|
boundaryElement = boundaryElementContext?.element,
|
|
42
|
-
children,
|
|
63
|
+
children: childProp,
|
|
43
64
|
content,
|
|
44
65
|
disabled,
|
|
45
|
-
fallbackPlacements,
|
|
46
|
-
placement = 'bottom',
|
|
66
|
+
fallbackPlacements: fallbackPlacementsProp,
|
|
67
|
+
placement: placementProp = 'bottom',
|
|
47
68
|
portal,
|
|
48
69
|
scheme,
|
|
70
|
+
shadow = 2,
|
|
49
71
|
zOffset = theme.sanity.layer?.tooltip.zOffset,
|
|
50
72
|
...restProps
|
|
51
73
|
} = props
|
|
74
|
+
const fallbackPlacements = useArrayProp(fallbackPlacementsProp)
|
|
52
75
|
const forwardedRef = useForwardedRef(ref)
|
|
53
76
|
const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null)
|
|
54
|
-
const
|
|
55
|
-
const
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
const arrowRef = useRef<HTMLDivElement | null>(null)
|
|
78
|
+
const rootBoundary: RootBoundary = 'viewport'
|
|
79
|
+
|
|
80
|
+
const middleware = useMemo(() => {
|
|
81
|
+
const ret: Middleware[] = []
|
|
82
|
+
|
|
83
|
+
// Flip the floating element when leaving the boundary box
|
|
84
|
+
ret.push(
|
|
85
|
+
flip({
|
|
86
|
+
boundary: boundaryElement || undefined,
|
|
87
|
+
fallbackPlacements,
|
|
88
|
+
padding: 4,
|
|
89
|
+
rootBoundary,
|
|
90
|
+
})
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
// Define distance between reference and floating element
|
|
94
|
+
ret.push(offset({mainAxis: 3}))
|
|
95
|
+
|
|
96
|
+
// Shift the tooltip so its sits with the boundary eleement
|
|
97
|
+
ret.push(
|
|
98
|
+
shift({
|
|
99
|
+
boundary: boundaryElement || undefined,
|
|
100
|
+
rootBoundary,
|
|
101
|
+
padding: 4,
|
|
102
|
+
})
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
// Place arrow
|
|
106
|
+
ret.push(arrow({element: arrowRef, padding: 2}))
|
|
107
|
+
|
|
108
|
+
return ret
|
|
109
|
+
}, [boundaryElement, fallbackPlacements])
|
|
110
|
+
|
|
111
|
+
const {x, y, placement, reference, floating, middlewareData, update, strategy} = useFloating({
|
|
112
|
+
middleware,
|
|
113
|
+
placement: placementProp,
|
|
114
|
+
whileElementsMounted: autoUpdate,
|
|
86
115
|
})
|
|
87
|
-
|
|
116
|
+
|
|
117
|
+
const rootStyle: CSSProperties = useMemo(
|
|
118
|
+
() => ({
|
|
119
|
+
position: strategy,
|
|
120
|
+
top: y ?? 0,
|
|
121
|
+
left: x ?? 0,
|
|
122
|
+
}),
|
|
123
|
+
[strategy, x, y]
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
const staticSide = placement && FLOATING_STATIC_SIDES[placement.split('-')[0]]
|
|
127
|
+
|
|
128
|
+
const arrowX = middlewareData.arrow?.x
|
|
129
|
+
const arrowY = middlewareData.arrow?.y
|
|
130
|
+
|
|
131
|
+
const arrowStyle: CSSProperties = useMemo(() => {
|
|
132
|
+
const style: CSSProperties = {
|
|
133
|
+
left: arrowX !== null ? arrowX : undefined,
|
|
134
|
+
top: arrowY !== null ? arrowY : undefined,
|
|
135
|
+
right: undefined,
|
|
136
|
+
bottom: undefined,
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (staticSide) style[staticSide] = -15
|
|
140
|
+
|
|
141
|
+
return style
|
|
142
|
+
}, [arrowX, arrowY, staticSide])
|
|
143
|
+
|
|
88
144
|
const [isOpen, setIsOpen] = useState(false)
|
|
89
145
|
const handleBlur = useCallback(() => setIsOpen(false), [])
|
|
90
146
|
const handleFocus = useCallback(() => setIsOpen(true), [])
|
|
@@ -117,16 +173,6 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
117
173
|
}
|
|
118
174
|
}, [isOpen, referenceElement])
|
|
119
175
|
|
|
120
|
-
useEffect(() => {
|
|
121
|
-
if (forceUpdate) {
|
|
122
|
-
try {
|
|
123
|
-
forceUpdate()
|
|
124
|
-
} catch (_) {
|
|
125
|
-
// ignore caught error
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}, [forceUpdate, content])
|
|
129
|
-
|
|
130
176
|
// Close when `disabled` changes to `true`
|
|
131
177
|
useEffect(() => {
|
|
132
178
|
if (disabled) setIsOpen(false)
|
|
@@ -137,54 +183,85 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
137
183
|
if (!content) setIsOpen(false)
|
|
138
184
|
}, [content])
|
|
139
185
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
{
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
186
|
+
// Update reference
|
|
187
|
+
useEffect(() => reference(referenceElement), [reference, referenceElement])
|
|
188
|
+
|
|
189
|
+
const setArrow = useCallback(
|
|
190
|
+
(arrowEl: HTMLDivElement | null) => {
|
|
191
|
+
arrowRef.current = arrowEl
|
|
192
|
+
update()
|
|
193
|
+
},
|
|
194
|
+
[update]
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
const setFloating = useCallback(
|
|
198
|
+
(node: HTMLDivElement | null) => {
|
|
199
|
+
forwardedRef.current = node
|
|
200
|
+
floating(node)
|
|
201
|
+
},
|
|
202
|
+
[floating, forwardedRef]
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
const childRef: ForwardedRef<HTMLElement | null> = (childProp as any)?.ref
|
|
206
|
+
|
|
207
|
+
const setReference = useCallback(
|
|
208
|
+
(node: HTMLElement | null) => {
|
|
209
|
+
if (typeof childRef === 'function') {
|
|
210
|
+
childRef(node)
|
|
211
|
+
} else if (childRef) {
|
|
212
|
+
childRef.current = node
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// childRef.current = node
|
|
216
|
+
setReferenceElement(node)
|
|
217
|
+
},
|
|
218
|
+
[childRef]
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
const child = useMemo(() => {
|
|
222
|
+
if (!childProp) return null
|
|
223
|
+
|
|
224
|
+
return cloneElement(childProp, {
|
|
225
|
+
onBlur: handleBlur,
|
|
226
|
+
onFocus: handleFocus,
|
|
227
|
+
onMouseEnter: handleMouseEnter,
|
|
228
|
+
onMouseLeave: handleMouseLeave,
|
|
229
|
+
ref: setReference,
|
|
230
|
+
})
|
|
231
|
+
}, [childProp, handleBlur, handleFocus, handleMouseEnter, handleMouseLeave, setReference])
|
|
232
|
+
|
|
233
|
+
if (!child) return <></>
|
|
234
|
+
|
|
235
|
+
if (disabled) return child
|
|
236
|
+
|
|
237
|
+
const root = (
|
|
238
|
+
<Root data-ui="Tooltip" {...restProps} ref={setFloating} style={rootStyle} zOffset={zOffset}>
|
|
239
|
+
<Card
|
|
240
|
+
data-ui="Tooltip__card"
|
|
241
|
+
data-placement={placement}
|
|
242
|
+
radius={2}
|
|
243
|
+
scheme={scheme}
|
|
244
|
+
shadow={shadow}
|
|
245
|
+
>
|
|
169
246
|
{content}
|
|
170
|
-
<TooltipArrow ref={
|
|
247
|
+
<TooltipArrow ref={setArrow} style={arrowStyle} />
|
|
171
248
|
</Card>
|
|
172
249
|
</Root>
|
|
173
250
|
)
|
|
174
251
|
|
|
175
252
|
return (
|
|
176
253
|
<>
|
|
177
|
-
{
|
|
254
|
+
{child}
|
|
178
255
|
|
|
179
256
|
{isOpen && (
|
|
180
257
|
<>
|
|
181
|
-
{portal
|
|
258
|
+
{portal ? (
|
|
182
259
|
<Portal __unstable_name={typeof portal === 'string' ? portal : undefined}>
|
|
183
|
-
{
|
|
260
|
+
{root}
|
|
184
261
|
</Portal>
|
|
262
|
+
) : (
|
|
263
|
+
root
|
|
185
264
|
)}
|
|
186
|
-
|
|
187
|
-
{!portal && popperNode}
|
|
188
265
|
</>
|
|
189
266
|
)}
|
|
190
267
|
</>
|