@sanity/ui 0.37.20 → 0.37.21
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/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/menuGroup.d.ts.map +1 -1
- package/lib/dts/src/components/skeleton/skeleton.d.ts.map +1 -1
- package/lib/dts/src/hooks/index.d.ts +1 -2
- package/lib/dts/src/hooks/index.d.ts.map +1 -1
- 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/useResponsiveProp.d.ts +6 -0
- package/lib/dts/src/hooks/useResponsiveProp.d.ts.map +1 -0
- package/lib/dts/src/index.d.ts +0 -1
- package/lib/dts/src/index.d.ts.map +1 -1
- package/lib/dts/src/primitives/_selectable/selectable.d.ts +2 -1
- 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.map +1 -1
- 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.map +1 -1
- package/lib/dts/src/primitives/select/styles.d.ts +1 -5
- 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.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.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 +2 -7
- 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/studioTheme/color.d.ts.map +1 -1
- package/lib/dts/src/utils/elementQuery/elementQuery.d.ts.map +1 -1
- package/lib/dts/src/utils/index.d.ts +1 -0
- package/lib/dts/src/utils/index.d.ts.map +1 -1
- package/lib/dts/src/utils/resizeObserver.d.ts +6 -0
- package/lib/dts/src/utils/resizeObserver.d.ts.map +1 -0
- package/lib/dts/src/utils/virtualList/virtualList.d.ts.map +1 -1
- package/lib/sanity-ui.js +570 -731
- package/lib/sanity-ui.js.map +1 -1
- package/lib/sanity-ui.modern.js +591 -762
- package/lib/sanity-ui.modern.js.map +1 -1
- package/lib/sanity-ui.module.js +566 -725
- package/lib/sanity-ui.module.js.map +1 -1
- package/package.json +11 -11
- package/src/__workshop__/color/overview.tsx +11 -9
- package/src/components/autocomplete/__workshop__/async.tsx +12 -14
- package/src/components/autocomplete/__workshop__/constrainedHeight.tsx +0 -36
- package/src/components/autocomplete/autocomplete.tsx +2 -2
- package/src/components/breadcrumbs/breadcrumbs.tsx +2 -3
- package/src/components/dialog/dialog.tsx +9 -17
- package/src/components/dialog/styles.ts +4 -4
- package/src/components/hotkeys/hotkeys.tsx +1 -3
- package/src/components/menu/__workshop__/constrainedInBoundary.tsx +14 -11
- package/src/components/menu/__workshop__/groups.tsx +1 -1
- package/src/components/menu/menuGroup.tsx +2 -3
- package/src/components/menu/menuItem.tsx +3 -3
- package/src/components/skeleton/skeleton.tsx +1 -10
- package/src/components/skeleton/textSkeleton.tsx +7 -7
- package/src/hooks/index.ts +1 -2
- package/src/hooks/useElementRect/useElementRect.ts +16 -4
- package/src/hooks/useResponsiveProp.ts +10 -0
- package/src/index.ts +0 -1
- package/src/primitives/_selectable/selectable.tsx +4 -5
- package/src/primitives/avatar/avatar.tsx +5 -7
- package/src/primitives/avatar/avatarCounter.tsx +11 -12
- package/src/primitives/avatar/avatarStack.tsx +10 -15
- package/src/primitives/avatar/styles.ts +2 -2
- package/src/primitives/badge/badge.tsx +2 -3
- package/src/primitives/box/box.tsx +25 -26
- package/src/primitives/button/button.tsx +10 -22
- package/src/primitives/card/card.tsx +7 -8
- package/src/primitives/checkbox/__workshop__/example.tsx +2 -4
- package/src/primitives/checkbox/__workshop__/props.tsx +2 -4
- package/src/primitives/checkbox/__workshop__/readOnly.tsx +2 -4
- package/src/primitives/code/__workshop__/props.tsx +1 -1
- package/src/primitives/code/code.tsx +1 -2
- package/src/primitives/container/container.tsx +1 -10
- package/src/primitives/container/styles.ts +2 -2
- package/src/primitives/container/types.ts +1 -1
- package/src/primitives/flex/flex.tsx +5 -6
- package/src/primitives/grid/__workshop__/responsive.tsx +12 -13
- package/src/primitives/grid/grid.tsx +8 -9
- package/src/primitives/heading/__workshop__/opticalAlignment.tsx +7 -19
- package/src/primitives/heading/heading.tsx +2 -3
- package/src/primitives/inline/inline.tsx +6 -12
- package/src/primitives/inline/styles.ts +2 -2
- package/src/primitives/inline/types.ts +1 -1
- package/src/primitives/kbd/kbd.tsx +1 -2
- package/src/primitives/label/label.tsx +3 -4
- package/src/primitives/popover/__workshop__/index.ts +5 -10
- package/src/primitives/popover/__workshop__/{MarginsStory.tsx → margins.tsx} +1 -1
- package/src/primitives/popover/__workshop__/{MatchReferenceWidthStory.tsx → matchReferenceWidth.tsx} +0 -0
- package/src/primitives/popover/__workshop__/{PlainStory.tsx → plain.tsx} +14 -12
- package/src/primitives/popover/__workshop__/{RecursiveStory.tsx → recursive.tsx} +1 -4
- package/src/primitives/popover/__workshop__/rightAligned.tsx +57 -0
- package/src/primitives/popover/popover.tsx +10 -29
- package/src/primitives/select/select.tsx +9 -9
- package/src/primitives/select/styles.ts +4 -10
- package/src/primitives/stack/stack.tsx +1 -2
- package/src/primitives/stack/styles.ts +3 -3
- package/src/primitives/text/__workshop__/opticalAlignment.tsx +5 -15
- package/src/primitives/text/text.tsx +2 -3
- package/src/primitives/textArea/__workshop__/plain.tsx +18 -23
- package/src/primitives/textArea/textArea.tsx +5 -21
- package/src/primitives/textInput/__workshop__/clearButton.tsx +8 -14
- package/src/primitives/textInput/__workshop__/index.ts +2 -2
- package/src/primitives/textInput/__workshop__/plain.tsx +32 -39
- package/src/primitives/textInput/__workshop__/tones.tsx +95 -234
- package/src/primitives/textInput/__workshop__/typed.tsx +2 -8
- package/src/primitives/textInput/textInput.tsx +12 -47
- package/src/primitives/tooltip/__workshop__/props.tsx +2 -7
- package/src/primitives/tooltip/tooltip.tsx +9 -19
- 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 +4 -5
- package/src/styles/flex/flexStyle.ts +6 -6
- package/src/styles/flex/types.ts +6 -6
- package/src/styles/font/responsiveFont.ts +4 -2
- package/src/styles/font/textAlignStyle.ts +2 -2
- package/src/styles/font/types.ts +3 -4
- 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 +27 -24
- package/src/styles/input/textInputStyle.ts +80 -92
- 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 +5 -2
- package/src/styles/shadow/types.ts +1 -1
- package/src/theme/studioTheme/color.ts +14 -15
- package/src/theme/studioTheme/fonts.ts +4 -4
- package/src/utils/elementQuery/elementQuery.tsx +18 -5
- package/src/utils/index.ts +1 -0
- package/src/utils/layer/layerProvider.tsx +2 -2
- package/src/{observers → utils}/resizeObserver.ts +3 -1
- package/src/utils/virtualList/virtualList.tsx +1 -3
- package/lib/dts/src/hooks/useArrayProp.d.ts +0 -7
- package/lib/dts/src/hooks/useArrayProp.d.ts.map +0 -1
- package/lib/dts/src/hooks/useElementSize.d.ts +0 -7
- package/lib/dts/src/hooks/useElementSize.d.ts.map +0 -1
- package/lib/dts/src/observers/elementSizeObserver.d.ts +0 -37
- package/lib/dts/src/observers/elementSizeObserver.d.ts.map +0 -1
- package/lib/dts/src/observers/index.d.ts +0 -3
- package/lib/dts/src/observers/index.d.ts.map +0 -1
- package/lib/dts/src/observers/resizeObserver.d.ts +0 -5
- package/lib/dts/src/observers/resizeObserver.d.ts.map +0 -1
- package/src/hooks/useArrayProp.ts +0 -23
- package/src/hooks/useElementSize.ts +0 -18
- package/src/observers/elementSizeObserver.ts +0 -116
- package/src/observers/index.ts +0 -2
- package/src/primitives/popover/__workshop__/RightAlignedStory.tsx +0 -60
- package/src/primitives/popover/__workshop__/TestStory.tsx +0 -79
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React, {forwardRef
|
|
1
|
+
import React, {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
|
-
import {useArrayProp} from '../../hooks'
|
|
4
3
|
import {Box, BoxProps} from '../box'
|
|
5
4
|
import {childrenToElementArray} from '../helpers'
|
|
6
5
|
import {inlineBaseStyle, inlineSpaceStyle} from './styles'
|
|
@@ -23,18 +22,13 @@ export const Inline = forwardRef(function Inline(
|
|
|
23
22
|
ref
|
|
24
23
|
) {
|
|
25
24
|
const {as, children: childrenProp, space, ...restProps} = props
|
|
26
|
-
|
|
27
|
-
const children = useMemo(
|
|
28
|
-
() =>
|
|
29
|
-
childrenToElementArray(childrenProp)
|
|
30
|
-
.filter(Boolean)
|
|
31
|
-
.map((child, idx) => <div key={idx}>{child}</div>),
|
|
32
|
-
[childrenProp]
|
|
33
|
-
)
|
|
25
|
+
const children = childrenToElementArray(childrenProp).filter(Boolean)
|
|
34
26
|
|
|
35
27
|
return (
|
|
36
|
-
<Root data-ui="Inline" {...restProps} $space={
|
|
37
|
-
{children
|
|
28
|
+
<Root data-ui="Inline" {...restProps} $space={space} forwardedAs={as} ref={ref}>
|
|
29
|
+
{children.map((child, idx) => (
|
|
30
|
+
<div key={idx}>{child}</div>
|
|
31
|
+
))}
|
|
38
32
|
</Root>
|
|
39
33
|
)
|
|
40
34
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {CSSObject} from 'styled-components'
|
|
2
|
-
import {rem,
|
|
2
|
+
import {getResponsiveProp, rem, responsive, ThemeProps} from '../../styles'
|
|
3
3
|
import {ResponsiveInlineSpaceStyleProps} from './types'
|
|
4
4
|
|
|
5
5
|
export function inlineBaseStyle(): CSSObject {
|
|
@@ -20,7 +20,7 @@ export function inlineBaseStyle(): CSSObject {
|
|
|
20
20
|
export function inlineSpaceStyle(props: ResponsiveInlineSpaceStyleProps & ThemeProps): CSSObject[] {
|
|
21
21
|
const {theme} = props
|
|
22
22
|
|
|
23
|
-
return
|
|
23
|
+
return responsive(theme.sanity.media, getResponsiveProp(props.$space), (spaceIndex) => {
|
|
24
24
|
const space = rem(theme.sanity.space[spaceIndex])
|
|
25
25
|
|
|
26
26
|
return {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {forwardRef} from 'react'
|
|
2
2
|
import styled, {css} from 'styled-components'
|
|
3
|
-
import {useArrayProp} from '../../hooks'
|
|
4
3
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
5
4
|
import {Box} from '../box'
|
|
6
5
|
import {Code} from '../code'
|
|
@@ -39,7 +38,7 @@ export const KBD = forwardRef(function KBD(
|
|
|
39
38
|
const {children, fontSize = 1, padding = 1, radius = 2, ...restProps} = props
|
|
40
39
|
|
|
41
40
|
return (
|
|
42
|
-
<Root data-ui="KBD" {...restProps} $radius={
|
|
41
|
+
<Root data-ui="KBD" {...restProps} $radius={radius} ref={ref}>
|
|
43
42
|
<Box as="span" padding={padding}>
|
|
44
43
|
<Code as="span" muted size={fontSize}>
|
|
45
44
|
{children}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
|
-
import {useArrayProp} from '../../hooks'
|
|
4
3
|
import {responsiveLabelFont, responsiveTextAlignStyle} from '../../styles/internal'
|
|
5
4
|
import {ThemeFontWeightKey} from '../../theme'
|
|
6
5
|
import {TextAlign} from '../../types'
|
|
@@ -26,7 +25,7 @@ export interface LabelProps {
|
|
|
26
25
|
|
|
27
26
|
const Root = styled.div<{
|
|
28
27
|
$accent?: boolean
|
|
29
|
-
$align
|
|
28
|
+
$align?: TextAlign | TextAlign[]
|
|
30
29
|
$muted: boolean
|
|
31
30
|
$size: number[]
|
|
32
31
|
}>(responsiveLabelFont, responsiveTextAlignStyle, labelBaseStyle)
|
|
@@ -69,9 +68,9 @@ export const Label = forwardRef(function Label(
|
|
|
69
68
|
data-ui="Label"
|
|
70
69
|
{...restProps}
|
|
71
70
|
$accent={accent}
|
|
72
|
-
$align={
|
|
71
|
+
$align={align}
|
|
73
72
|
$muted={muted}
|
|
74
|
-
$size={
|
|
73
|
+
$size={size}
|
|
75
74
|
$weight={weight}
|
|
76
75
|
ref={ref}
|
|
77
76
|
>
|
|
@@ -2,34 +2,29 @@ import {defineScope} from '@sanity/ui-workshop'
|
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
4
|
export default defineScope('primitives/popover', 'Popover', [
|
|
5
|
-
{
|
|
6
|
-
name: 'test',
|
|
7
|
-
title: 'Test',
|
|
8
|
-
component: lazy(() => import('./TestStory')),
|
|
9
|
-
},
|
|
10
5
|
{
|
|
11
6
|
name: 'plain',
|
|
12
7
|
title: 'Plain',
|
|
13
|
-
component: lazy(() => import('./
|
|
8
|
+
component: lazy(() => import('./plain')),
|
|
14
9
|
},
|
|
15
10
|
{
|
|
16
11
|
name: 'recursive',
|
|
17
12
|
title: 'Recursive',
|
|
18
|
-
component: lazy(() => import('./
|
|
13
|
+
component: lazy(() => import('./recursive')),
|
|
19
14
|
},
|
|
20
15
|
{
|
|
21
16
|
name: 'match-ref-width',
|
|
22
17
|
title: 'Match reference width',
|
|
23
|
-
component: lazy(() => import('./
|
|
18
|
+
component: lazy(() => import('./matchReferenceWidth')),
|
|
24
19
|
},
|
|
25
20
|
{
|
|
26
21
|
name: 'margins',
|
|
27
22
|
title: 'Margins',
|
|
28
|
-
component: lazy(() => import('./
|
|
23
|
+
component: lazy(() => import('./margins')),
|
|
29
24
|
},
|
|
30
25
|
{
|
|
31
26
|
name: 'right-aligned',
|
|
32
27
|
title: 'Right-aligned',
|
|
33
|
-
component: lazy(() => import('./
|
|
28
|
+
component: lazy(() => import('./rightAligned')),
|
|
34
29
|
},
|
|
35
30
|
])
|
|
@@ -5,7 +5,7 @@ export default function MarginsStory() {
|
|
|
5
5
|
return (
|
|
6
6
|
<Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
|
|
7
7
|
<Popover
|
|
8
|
-
__unstable_margins={[-
|
|
8
|
+
__unstable_margins={[-5, -5, -5, -5]}
|
|
9
9
|
arrow={false}
|
|
10
10
|
content={
|
|
11
11
|
<Box padding={2}>
|
package/src/primitives/popover/__workshop__/{MatchReferenceWidthStory.tsx → matchReferenceWidth.tsx}
RENAMED
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Button, Card, Popover, PortalProvider, Text} from '@sanity/ui'
|
|
2
|
-
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
2
|
+
import {useBoolean, useSelect, useText} from '@sanity/ui-workshop'
|
|
3
3
|
import React, {useState} from 'react'
|
|
4
4
|
import {
|
|
5
5
|
WORKSHOP_CONTAINER_WIDTH_OPTIONS,
|
|
@@ -9,17 +9,18 @@ import {
|
|
|
9
9
|
} from '../../../__workshop__/constants'
|
|
10
10
|
|
|
11
11
|
export default function PlainStory() {
|
|
12
|
-
const arrow = useBoolean('Arrow', true)
|
|
13
|
-
const boundaryElementFlag = useBoolean('Boundary element', true)
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
12
|
+
const arrow = useBoolean('Arrow', true, 'Props')
|
|
13
|
+
const boundaryElementFlag = useBoolean('Boundary element', true, 'Props')
|
|
14
|
+
const content = useText('Content', 'Hello, world', 'Props')
|
|
15
|
+
const constrainSize = useBoolean('Constrain size', true, 'Props')
|
|
16
|
+
const matchReferenceWidth = useBoolean('Match reference width', false, 'Props')
|
|
17
|
+
const open = useBoolean('Open', true, 'Props')
|
|
18
|
+
const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
19
|
+
const placement = useSelect('Placement', WORKSHOP_PLACEMENT_OPTIONS, 'bottom', 'Props')
|
|
20
|
+
const portal = useBoolean('Portal', true, 'Props')
|
|
21
|
+
const preventOverflow = useBoolean('Prevent overflow', true, 'Props')
|
|
22
|
+
const radius = useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 2, 'Props')
|
|
23
|
+
const width = useSelect('Width', WORKSHOP_CONTAINER_WIDTH_OPTIONS, 'auto', 'Props')
|
|
23
24
|
const [portalElement, setPortalElement] = useState<HTMLDivElement | null>(null)
|
|
24
25
|
const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)
|
|
25
26
|
|
|
@@ -45,6 +46,7 @@ export default function PlainStory() {
|
|
|
45
46
|
__unstable_margins={[1, 1, 1, 1]}
|
|
46
47
|
arrow={arrow}
|
|
47
48
|
boundaryElement={boundaryElementFlag ? boundaryElement : undefined}
|
|
49
|
+
content={<Text>{content}</Text>}
|
|
48
50
|
constrainSize={constrainSize}
|
|
49
51
|
fallbackPlacements={['top', 'bottom']}
|
|
50
52
|
matchReferenceWidth={matchReferenceWidth}
|
|
@@ -39,9 +39,7 @@ function RecursiveExample({onClose}: {onClose?: () => void}) {
|
|
|
39
39
|
}, [open])
|
|
40
40
|
|
|
41
41
|
useEffect(() => {
|
|
42
|
-
|
|
43
|
-
buttonRef.current?.focus()
|
|
44
|
-
}, 0)
|
|
42
|
+
buttonRef.current?.focus()
|
|
45
43
|
}, [])
|
|
46
44
|
|
|
47
45
|
const handleOpen = useCallback(() => setOpen(true), [])
|
|
@@ -60,7 +58,6 @@ function RecursiveExample({onClose}: {onClose?: () => void}) {
|
|
|
60
58
|
fallbackPlacements={fallbackPlacements}
|
|
61
59
|
content={<RecursiveExample onClose={handleClose} />}
|
|
62
60
|
open={open}
|
|
63
|
-
padding={1}
|
|
64
61
|
placement={fallbackPlacements[3]}
|
|
65
62
|
portal
|
|
66
63
|
tone={tones[seed]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {EllipsisVerticalIcon} from '@sanity/icons'
|
|
2
|
+
import {Box, Button, Card, Flex, Popover, Text, useClickOutside} from '@sanity/ui'
|
|
3
|
+
import React, {useCallback, useState} from 'react'
|
|
4
|
+
|
|
5
|
+
export default function RightAlignedStory() {
|
|
6
|
+
const [open, setOpen] = useState(false)
|
|
7
|
+
const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)
|
|
8
|
+
const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(null)
|
|
9
|
+
const [popoverElement, setPopoverElement] = useState<HTMLDivElement | null>(null)
|
|
10
|
+
const content = (
|
|
11
|
+
<Box overflow="auto" padding={3}>
|
|
12
|
+
<Text>
|
|
13
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque at nisl at sem tempor
|
|
14
|
+
hendrerit scelerisque ut libero. Maecenas iaculis efficitur lorem, ac faucibus mi imperdiet
|
|
15
|
+
quis. Cras a consectetur erat. Fusce imperdiet, dolor et pellentesque iaculis, ex quam
|
|
16
|
+
luctus felis, non ultrices enim sem vitae quam. Duis lorem velit, lacinia at rhoncus a,
|
|
17
|
+
tempus vel neque. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere
|
|
18
|
+
cubilia curae; Sed id mauris quam. Nam finibus sapien non lacinia ultricies. Integer
|
|
19
|
+
fermentum tortor at pellentesque faucibus. In venenatis commodo placerat. Curabitur commodo
|
|
20
|
+
tortor libero, vel pellentesque elit luctus sodales. Donec mattis tristique nunc ac lacinia.
|
|
21
|
+
Vestibulum non pulvinar turpis, posuere consequat arcu. Fusce ut urna blandit, finibus nisi
|
|
22
|
+
a, molestie elit. Nulla sed eleifend mi.
|
|
23
|
+
</Text>
|
|
24
|
+
</Box>
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const handleToggleOpen = useCallback(() => setOpen((v) => !v), [])
|
|
28
|
+
const handleClose = useCallback(() => setOpen(false), [])
|
|
29
|
+
|
|
30
|
+
useClickOutside(handleClose, [buttonElement, popoverElement])
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Box height="fill" padding={[4, 5, 6]} sizing="border">
|
|
34
|
+
<Card height="fill" padding={2} ref={setBoundaryElement} shadow={1}>
|
|
35
|
+
<Flex justify="flex-end" padding={0}>
|
|
36
|
+
<Popover
|
|
37
|
+
boundaryElement={boundaryElement}
|
|
38
|
+
constrainSize
|
|
39
|
+
content={content}
|
|
40
|
+
open={open}
|
|
41
|
+
portal
|
|
42
|
+
preventOverflow
|
|
43
|
+
ref={setPopoverElement}
|
|
44
|
+
>
|
|
45
|
+
<Button
|
|
46
|
+
icon={EllipsisVerticalIcon}
|
|
47
|
+
mode="bleed"
|
|
48
|
+
onClick={handleToggleOpen}
|
|
49
|
+
ref={setButtonElement}
|
|
50
|
+
selected={open}
|
|
51
|
+
/>
|
|
52
|
+
</Popover>
|
|
53
|
+
</Flex>
|
|
54
|
+
</Card>
|
|
55
|
+
</Box>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
cloneElement,
|
|
3
|
-
forwardRef,
|
|
4
|
-
useCallback,
|
|
5
|
-
useEffect,
|
|
6
|
-
useMemo,
|
|
7
|
-
useRef,
|
|
8
|
-
useState,
|
|
9
|
-
} from 'react'
|
|
1
|
+
import React, {cloneElement, forwardRef, useCallback, useEffect, useMemo, useState} from 'react'
|
|
10
2
|
import {usePopper} from 'react-popper'
|
|
11
3
|
import styled, {css} from 'styled-components'
|
|
12
4
|
import {EMPTY_RECORD} from '../../constants'
|
|
13
|
-
import {
|
|
5
|
+
import {useForwardedRef} from '../../hooks'
|
|
14
6
|
import {ThemeColorSchemeKey, useTheme} from '../../theme'
|
|
15
7
|
import {CardTone, Placement, PopoverMargins} from '../../types'
|
|
16
8
|
import {Layer, LayerProps, Portal, useBoundaryElement, usePortal} from '../../utils'
|
|
@@ -79,7 +71,6 @@ const PopoverCard = styled(Card)<
|
|
|
79
71
|
ResponsiveWidthStyleProps & {
|
|
80
72
|
$constrainSize?: boolean
|
|
81
73
|
$preventOverflow?: boolean
|
|
82
|
-
$width: (number | 'auto')[]
|
|
83
74
|
}
|
|
84
75
|
>(
|
|
85
76
|
({$constrainSize}) => css`
|
|
@@ -135,7 +126,7 @@ export const Popover = forwardRef(function Popover(
|
|
|
135
126
|
tether,
|
|
136
127
|
tetherOffset,
|
|
137
128
|
tone = 'inherit',
|
|
138
|
-
width
|
|
129
|
+
width = 0,
|
|
139
130
|
zOffset = theme.sanity.layer?.popover.zOffset,
|
|
140
131
|
...restProps
|
|
141
132
|
} = props
|
|
@@ -145,7 +136,6 @@ export const Popover = forwardRef(function Popover(
|
|
|
145
136
|
const [popperElement, setPopperElement] = useState<HTMLElement | null>(null)
|
|
146
137
|
const [arrowElement, setArrowElement] = useState<HTMLElement | null>(null)
|
|
147
138
|
const popperReferenceElement = referenceElementProp || referenceElement
|
|
148
|
-
const width = useArrayProp(matchReferenceWidth ? 'auto' : widthProp)
|
|
149
139
|
|
|
150
140
|
const modifiers = usePopoverModifiers({
|
|
151
141
|
allowedAutoPlacements,
|
|
@@ -196,23 +186,14 @@ export const Popover = forwardRef(function Popover(
|
|
|
196
186
|
|
|
197
187
|
const popoverStyle = useMemo(() => ({...style, ...styles.popper}), [style, styles])
|
|
198
188
|
|
|
199
|
-
const updateTimeoutRef = useRef<NodeJS.Timeout | null>(null)
|
|
200
|
-
|
|
201
189
|
useEffect(() => {
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
updateTimeoutRef.current = setTimeout(() => {
|
|
208
|
-
if (forceUpdate) {
|
|
209
|
-
try {
|
|
210
|
-
forceUpdate()
|
|
211
|
-
} catch (_) {
|
|
212
|
-
// ignore caught error
|
|
213
|
-
}
|
|
190
|
+
if (forceUpdate) {
|
|
191
|
+
try {
|
|
192
|
+
forceUpdate()
|
|
193
|
+
} catch (_) {
|
|
194
|
+
// ignore caught error
|
|
214
195
|
}
|
|
215
|
-
}
|
|
196
|
+
}
|
|
216
197
|
}, [content, forceUpdate, open, popperReferenceElement])
|
|
217
198
|
|
|
218
199
|
if (disabled) {
|
|
@@ -231,13 +212,13 @@ export const Popover = forwardRef(function Popover(
|
|
|
231
212
|
>
|
|
232
213
|
<PopoverCard
|
|
233
214
|
$constrainSize={constrainSize}
|
|
234
|
-
$width={width}
|
|
235
215
|
data-ui="PopoverCard"
|
|
236
216
|
padding={padding}
|
|
237
217
|
radius={radius}
|
|
238
218
|
scheme={scheme}
|
|
239
219
|
shadow={shadow}
|
|
240
220
|
tone={tone}
|
|
221
|
+
width={width as any}
|
|
241
222
|
>
|
|
242
223
|
{arrow && <PopoverArrow ref={setArrowElement} style={styles.arrow} />}
|
|
243
224
|
{content}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {SelectIcon} from '@sanity/icons'
|
|
2
2
|
import React, {forwardRef} from 'react'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
|
-
import {useForwardedRef, useCustomValidity
|
|
4
|
+
import {useForwardedRef, useCustomValidity} from '../../hooks'
|
|
5
5
|
import {Box} from '../box'
|
|
6
6
|
import {Text} from '../text'
|
|
7
7
|
import {selectStyle} from './styles'
|
|
@@ -20,10 +20,10 @@ export interface SelectProps {
|
|
|
20
20
|
const Root = styled.div(selectStyle.root)
|
|
21
21
|
|
|
22
22
|
const Input = styled.select<{
|
|
23
|
-
$fontSize
|
|
24
|
-
$padding
|
|
25
|
-
$radius
|
|
26
|
-
$space
|
|
23
|
+
$fontSize?: number | number[]
|
|
24
|
+
$padding?: number | number[]
|
|
25
|
+
$radius?: number | number[]
|
|
26
|
+
$space?: number | number[]
|
|
27
27
|
}>(selectStyle.input)
|
|
28
28
|
|
|
29
29
|
const IconBox = styled(Box)(selectStyle.iconBox)
|
|
@@ -57,10 +57,10 @@ export const Select = forwardRef(function Select(
|
|
|
57
57
|
data-read-only={!disabled && readOnly ? '' : undefined}
|
|
58
58
|
data-ui="Select"
|
|
59
59
|
{...restProps}
|
|
60
|
-
$fontSize={
|
|
61
|
-
$padding={
|
|
62
|
-
$radius={
|
|
63
|
-
$space={
|
|
60
|
+
$fontSize={fontSize}
|
|
61
|
+
$padding={padding}
|
|
62
|
+
$radius={radius}
|
|
63
|
+
$space={space}
|
|
64
64
|
disabled={disabled || readOnly}
|
|
65
65
|
ref={ref}
|
|
66
66
|
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {css, CSSObject, FlattenSimpleInterpolation} from 'styled-components'
|
|
2
|
-
import {rem,
|
|
2
|
+
import {getResponsiveProp, rem, responsive, ThemeProps} from '../../styles'
|
|
3
3
|
import {
|
|
4
4
|
focusRingBorderStyle,
|
|
5
5
|
focusRingStyle,
|
|
@@ -100,23 +100,17 @@ function textSize(size: ThemeFontSize) {
|
|
|
100
100
|
return {fontSize: rem(size.fontSize), lineHeight: rem(size.lineHeight)}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
function inputTextSizeStyle(props: {$fontSize
|
|
103
|
+
function inputTextSizeStyle(props: {$fontSize?: number | number[]} & ThemeProps) {
|
|
104
104
|
const {theme, $fontSize} = props
|
|
105
105
|
const {sizes} = theme.sanity.fonts.text
|
|
106
106
|
|
|
107
|
-
return
|
|
107
|
+
return responsive(theme.sanity.media, getResponsiveProp($fontSize), (sizeIndex) =>
|
|
108
108
|
textSize(sizes[sizeIndex] || sizes[2])
|
|
109
109
|
)
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
function inputStyle(): Array<
|
|
113
|
-
| ((
|
|
114
|
-
props: ResponsiveRadiusStyleProps & {
|
|
115
|
-
$fontSize: number[]
|
|
116
|
-
$padding: number[]
|
|
117
|
-
$space: number[]
|
|
118
|
-
} & ThemeProps
|
|
119
|
-
) => CSSObject[])
|
|
113
|
+
| ((props: ResponsiveRadiusStyleProps & ThemeProps) => CSSObject[])
|
|
120
114
|
| ((props: ThemeProps) => FlattenSimpleInterpolation)
|
|
121
115
|
> {
|
|
122
116
|
return [
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
|
-
import {useArrayProp} from '../../hooks'
|
|
4
3
|
import {Box, BoxProps} from '../box'
|
|
5
4
|
import {stackBaseStyle, responsiveStackSpaceStyle, ResponsiveStackSpaceStyleProps} from './styles'
|
|
6
5
|
|
|
@@ -28,7 +27,7 @@ export const Stack = forwardRef(function Stack(
|
|
|
28
27
|
data-as={typeof as === 'string' ? as : undefined}
|
|
29
28
|
data-ui="Stack"
|
|
30
29
|
{...restProps}
|
|
31
|
-
$space={
|
|
30
|
+
$space={space}
|
|
32
31
|
forwardedAs={as}
|
|
33
32
|
ref={ref}
|
|
34
33
|
/>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {CSSObject} from 'styled-components'
|
|
2
|
-
import {rem,
|
|
2
|
+
import {getResponsiveProp, rem, responsive, ThemeProps} from '../../styles'
|
|
3
3
|
|
|
4
4
|
export interface ResponsiveStackSpaceStyleProps {
|
|
5
|
-
$space
|
|
5
|
+
$space?: number | number[]
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
const BASE_STYLE: CSSObject = {
|
|
@@ -26,7 +26,7 @@ export function responsiveStackSpaceStyle(
|
|
|
26
26
|
const {theme} = props
|
|
27
27
|
const {media, space} = theme.sanity
|
|
28
28
|
|
|
29
|
-
return
|
|
29
|
+
return responsive(media, getResponsiveProp(props.$space), (spaceIndex) => ({
|
|
30
30
|
gridGap: rem(space[spaceIndex]),
|
|
31
31
|
}))
|
|
32
32
|
}
|
|
@@ -8,41 +8,31 @@ export default function OpticalAlignment() {
|
|
|
8
8
|
<Stack space={1}>
|
|
9
9
|
<Flex>
|
|
10
10
|
<Card padding={0} scheme="dark">
|
|
11
|
-
<Text
|
|
12
|
-
Hamburgefonstiv M
|
|
13
|
-
</Text>
|
|
11
|
+
<Text size={4}>Hamburgefonstiv M</Text>
|
|
14
12
|
</Card>
|
|
15
13
|
</Flex>
|
|
16
14
|
|
|
17
15
|
<Flex>
|
|
18
16
|
<Card padding={0} scheme="dark">
|
|
19
|
-
<Text
|
|
20
|
-
Hamburgefonstiv M
|
|
21
|
-
</Text>
|
|
17
|
+
<Text size={3}>Hamburgefonstiv M</Text>
|
|
22
18
|
</Card>
|
|
23
19
|
</Flex>
|
|
24
20
|
|
|
25
21
|
<Flex>
|
|
26
22
|
<Card padding={0} scheme="dark">
|
|
27
|
-
<Text
|
|
28
|
-
Hamburgefonstiv M
|
|
29
|
-
</Text>
|
|
23
|
+
<Text size={2}>Hamburgefonstiv M</Text>
|
|
30
24
|
</Card>
|
|
31
25
|
</Flex>
|
|
32
26
|
|
|
33
27
|
<Flex>
|
|
34
28
|
<Card padding={0} scheme="dark">
|
|
35
|
-
<Text
|
|
36
|
-
Hamburgefonstiv M
|
|
37
|
-
</Text>
|
|
29
|
+
<Text size={1}>Hamburgefonstiv M</Text>
|
|
38
30
|
</Card>
|
|
39
31
|
</Flex>
|
|
40
32
|
|
|
41
33
|
<Flex>
|
|
42
34
|
<Card padding={0} scheme="dark">
|
|
43
|
-
<Text
|
|
44
|
-
Hamburgefonstiv M
|
|
45
|
-
</Text>
|
|
35
|
+
<Text size={0}>Hamburgefonstiv M</Text>
|
|
46
36
|
</Card>
|
|
47
37
|
</Flex>
|
|
48
38
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
|
-
import {useArrayProp} from '../../hooks'
|
|
4
3
|
import {
|
|
5
4
|
ResponsiveFontStyleProps,
|
|
6
5
|
responsiveTextAlignStyle,
|
|
@@ -70,10 +69,10 @@ export const Text = forwardRef(function Text(
|
|
|
70
69
|
data-ui="Text"
|
|
71
70
|
{...restProps}
|
|
72
71
|
$accent={accent}
|
|
73
|
-
$align={
|
|
72
|
+
$align={align}
|
|
74
73
|
$muted={muted}
|
|
75
74
|
ref={ref}
|
|
76
|
-
$size={
|
|
75
|
+
$size={size}
|
|
77
76
|
$weight={weight}
|
|
78
77
|
>
|
|
79
78
|
<span>{children}</span>
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Container, Flex, Stack, Text, TextArea} from '@sanity/ui'
|
|
2
2
|
import {useBoolean, useSelect, useText} from '@sanity/ui-workshop'
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import {
|
|
5
|
-
WORKSHOP_CARD_TONE_OPTIONS,
|
|
6
5
|
WORKSHOP_FONT_WEIGHT_OPTIONS,
|
|
7
6
|
WORKSHOP_RADIUS_OPTIONS,
|
|
8
7
|
WORKSHOP_SPACE_OPTIONS,
|
|
@@ -10,8 +9,6 @@ import {
|
|
|
10
9
|
} from '../../../__workshop__/constants'
|
|
11
10
|
|
|
12
11
|
export default function PlainStory() {
|
|
13
|
-
const tone = useSelect('Tone', WORKSHOP_CARD_TONE_OPTIONS)
|
|
14
|
-
|
|
15
12
|
const border = useBoolean('Border', true, 'Props')
|
|
16
13
|
const customValidity = useText('Custom validity', '', 'Props') || undefined
|
|
17
14
|
const disabled = useBoolean('Disabled', false, 'Props')
|
|
@@ -25,25 +22,23 @@ export default function PlainStory() {
|
|
|
25
22
|
return (
|
|
26
23
|
<Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
|
|
27
24
|
<Container width={0}>
|
|
28
|
-
<
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
</Stack>
|
|
46
|
-
</Card>
|
|
25
|
+
<Stack space={3}>
|
|
26
|
+
<Text as="label" htmlFor="text-area-example" size={1} weight="semibold">
|
|
27
|
+
TextArea
|
|
28
|
+
</Text>
|
|
29
|
+
<TextArea
|
|
30
|
+
border={border}
|
|
31
|
+
customValidity={customValidity}
|
|
32
|
+
disabled={disabled}
|
|
33
|
+
fontSize={fontSize}
|
|
34
|
+
id="text-area-example"
|
|
35
|
+
padding={padding}
|
|
36
|
+
placeholder={placeholder}
|
|
37
|
+
radius={radius}
|
|
38
|
+
readOnly={readOnly}
|
|
39
|
+
weight={weight}
|
|
40
|
+
/>
|
|
41
|
+
</Stack>
|
|
47
42
|
</Container>
|
|
48
43
|
</Flex>
|
|
49
44
|
)
|