@sanity/ui 3.0.0-static.26 → 3.0.0-static.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/_chunks-cjs/_visual-editing.cjs +674 -804
- package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
- package/dist/_chunks-cjs/refractor.cjs +2 -2
- package/dist/_chunks-cjs/refractor.cjs.map +1 -1
- package/dist/_chunks-es/_visual-editing.js +652 -781
- package/dist/_chunks-es/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/refractor.js +1 -1
- package/dist/_visual-editing.d.cts +1 -0
- package/dist/_visual-editing.d.ts +1 -0
- package/dist/css/layers.css +4 -0
- package/dist/css/primitives/popover/popover.css +4 -0
- package/dist/css.cjs +59 -50
- package/dist/css.cjs.map +1 -1
- package/dist/css.d.cts +14 -6
- package/dist/css.d.ts +14 -6
- package/dist/css.js +59 -50
- package/dist/css.js.map +1 -1
- package/dist/index.cjs +1995 -1813
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -0
- package/dist/index.d.cts +35 -17
- package/dist/index.d.ts +35 -17
- package/dist/index.js +2013 -1832
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs +2605 -1075
- package/dist/theme.cjs.map +1 -1
- package/dist/theme.d.cts +1 -1
- package/dist/theme.d.ts +1 -1
- package/dist/theme.js +2689 -1159
- package/dist/theme.js.map +1 -1
- package/exports/_visual-editing.ts +2 -2
- package/package.json +20 -38
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
- package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +1 -1
- package/src/core/components/autocomplete/autocomplete.tsx +13 -17
- package/src/core/components/autocomplete/autocompleteOption.tsx +1 -1
- package/src/core/components/autocomplete/constants.ts +3 -1
- package/src/core/components/autocomplete/types.ts +1 -1
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +8 -3
- package/src/core/components/dialog/__workshop__/activate.tsx +11 -3
- package/src/core/components/dialog/__workshop__/panes.tsx +12 -5
- package/src/core/components/dialog/dialog.tsx +12 -13
- package/src/core/components/dialog/dialogCard.tsx +89 -53
- package/src/core/components/dialog/dialogContext.ts +1 -1
- package/src/core/components/dialog/dialogProvider.tsx +1 -1
- package/src/core/components/dialog/index.ts +1 -0
- package/src/core/components/dialog/isTargetWithinScope.ts +1 -1
- package/src/core/components/hotkeys/hotkeys.tsx +3 -2
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +12 -6
- package/src/core/components/menu/__workshop__/customSelectedState.tsx +1 -5
- package/src/core/components/menu/__workshop__/shouldFocus.tsx +1 -2
- package/src/core/components/menu/helpers.ts +1 -1
- package/src/core/components/menu/menu.tsx +6 -4
- package/src/core/components/menu/menuButton.tsx +5 -3
- package/src/core/components/menu/menuDivider.tsx +1 -1
- package/src/core/components/menu/menuGroup.tsx +8 -4
- package/src/core/components/menu/menuItem.tsx +4 -2
- package/src/core/components/tab/tab.tsx +2 -2
- package/src/core/components/tab/tabList.tsx +2 -2
- package/src/core/components/tab/tabPanel.tsx +2 -2
- package/src/core/components/toast/toast.tsx +7 -2
- package/src/core/components/toast/toastLayer.tsx +2 -2
- package/src/core/components/toast/toastProvider.tsx +1 -1
- package/src/core/components/tree/tree.tsx +2 -2
- package/src/core/components/tree/treeGroup.tsx +2 -2
- package/src/core/components/tree/treeItem.tsx +13 -6
- package/src/core/components/tree/types.ts +0 -1
- package/src/core/{utils → components}/virtualList/__workshop__/index.ts +1 -1
- package/src/core/{utils → components}/virtualList/virtualList.tsx +10 -5
- package/src/core/helpers/focus.ts +0 -8
- package/src/core/hooks/useArrayProp.ts +1 -1
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +1 -3
- package/src/core/hooks/useElementSize.ts +1 -1
- package/src/core/hooks/useResponsiveProp.ts +1 -1
- package/src/core/index.ts +83 -7
- package/src/core/observers/{elementSizeObserver.ts → elementSize.ts} +1 -1
- package/src/core/primitives/_selectable/index.ts +1 -0
- package/src/core/primitives/_selectable/selectable.tsx +13 -3
- package/src/core/{types/selectable.ts → primitives/_selectable/types.ts} +1 -1
- package/src/core/{utils → primitives}/arrow/arrow.tsx +1 -1
- package/src/core/primitives/avatar/avatar.tsx +4 -3
- package/src/core/primitives/avatar/avatarCounter.tsx +3 -3
- package/src/core/primitives/avatar/avatarStack.tsx +4 -4
- package/src/core/primitives/avatar/types.ts +17 -0
- package/src/core/primitives/badge/badge.tsx +4 -2
- package/src/core/primitives/badge/types.ts +11 -2
- package/src/core/primitives/box/__workshop__/responsive.tsx +0 -1
- package/src/core/primitives/box/box.tsx +1 -1
- package/src/core/primitives/box/index.ts +1 -0
- package/src/core/primitives/button/__workshop__/disabled.tsx +37 -51
- package/src/core/primitives/button/__workshop__/index.ts +5 -0
- package/src/core/primitives/button/__workshop__/textOverflow.tsx +13 -0
- package/src/core/primitives/button/button.tsx +15 -14
- package/src/core/primitives/button/index.ts +1 -0
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +2 -2
- package/src/core/primitives/card/card.tsx +1 -1
- package/src/core/primitives/card/types.ts +3 -0
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +9 -1
- package/src/core/primitives/checkbox/checkbox.tsx +3 -4
- package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +17 -42
- package/src/core/primitives/code/code.tsx +1 -1
- package/src/core/primitives/container/container.tsx +1 -1
- package/src/core/primitives/flex/flex.tsx +1 -1
- package/src/core/primitives/flex/index.ts +1 -0
- package/src/core/primitives/grid/grid.tsx +1 -1
- package/src/core/primitives/grid/index.ts +1 -0
- package/src/core/primitives/heading/heading.tsx +1 -1
- package/src/core/primitives/inline/inline.tsx +1 -1
- package/src/core/primitives/kbd/kbd.tsx +1 -1
- package/src/core/primitives/label/label.tsx +1 -1
- package/src/core/{utils → primitives}/layer/__workshop__/index.ts +1 -1
- package/src/core/{utils → primitives}/layer/layer.test.tsx +1 -1
- package/src/core/{utils → primitives}/layer/layer.tsx +2 -2
- package/src/core/{utils → primitives}/layer/layerCard.tsx +3 -3
- package/src/core/{utils → primitives}/layer/layerProvider.tsx +2 -1
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +12 -9
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +9 -8
- package/src/core/primitives/popover/constants.ts +1 -1
- package/src/core/primitives/popover/floating-ui/size.ts +1 -1
- package/src/core/primitives/popover/popover.tsx +8 -4
- package/src/core/primitives/popover/popoverLayer.tsx +4 -2
- package/src/core/primitives/popover/types.ts +5 -0
- package/src/core/primitives/radio/radio.tsx +2 -2
- package/src/core/primitives/select/select.tsx +2 -2
- package/src/core/{components → primitives}/skeleton/__workshop__/index.ts +1 -1
- package/src/core/{components → primitives}/skeleton/codeSkeleton.tsx +1 -1
- package/src/core/{components → primitives}/skeleton/headingSkeleton.tsx +1 -1
- package/src/core/{components → primitives}/skeleton/labelSkeleton.tsx +1 -1
- package/src/core/{components → primitives}/skeleton/skeleton.tsx +7 -8
- package/src/core/{components → primitives}/skeleton/textSkeleton.tsx +1 -1
- package/src/core/primitives/spinner/spinner.tsx +1 -1
- package/src/core/{utils → primitives}/srOnly/srOnly.tsx +1 -1
- package/src/core/primitives/stack/stack.tsx +2 -1
- package/src/core/primitives/switch/switch.tsx +2 -7
- package/src/core/primitives/text/__workshop__/colored.tsx +2 -2
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +17 -42
- package/src/core/primitives/text/text.tsx +3 -1
- package/src/core/primitives/textArea/__workshop__/plain.tsx +2 -2
- package/src/core/primitives/textArea/textArea.tsx +2 -2
- package/src/core/primitives/textInput/textInput.tsx +3 -2
- package/src/core/primitives/tooltip/constants.ts +1 -1
- package/src/core/primitives/tooltip/tooltip.tsx +6 -3
- package/src/core/primitives/tooltip/tooltipLayer.tsx +3 -2
- package/src/core/primitives/types.ts +8 -10
- package/src/core/types/radius.ts +1 -1
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +9 -5
- package/src/core/utils/elementQuery/elementQuery.tsx +2 -2
- package/src/core/utils/getElementRef.ts +1 -0
- package/src/core/utils/portal/portal.tsx +1 -1
- package/src/css/components/dialog/dialog.css.ts +26 -1
- package/src/css/components/dialog/dialog.ts +27 -7
- package/src/css/components/skeleton/skeleton.ts +3 -1
- package/src/css/components/skeleton/types.ts +3 -1
- package/src/css/index.ts +75 -5
- package/src/css/primitives/_input/input.ts +2 -1
- package/src/css/primitives/_input/types.ts +2 -1
- package/src/css/primitives/_selectable/_selectable.css.ts +32 -24
- package/src/css/primitives/_selectable/selectable.ts +1 -1
- package/src/css/primitives/_selectable/types.ts +1 -1
- package/src/css/primitives/avatar/avatar.css.ts +11 -2
- package/src/css/primitives/avatar/avatar.ts +1 -1
- package/src/css/primitives/badge/badge.css.ts +2 -1
- package/src/css/primitives/badge/types.ts +0 -2
- package/src/css/primitives/box/box.ts +35 -37
- package/src/css/primitives/box/types.ts +34 -36
- package/src/css/primitives/button/button.css.ts +4 -0
- package/src/css/primitives/button/button.ts +5 -2
- package/src/css/primitives/button/types.ts +4 -11
- package/src/css/primitives/card/__workshop__/color.tsx +70 -0
- package/src/css/primitives/card/__workshop__/index.ts +14 -0
- package/src/css/primitives/card/card.css.ts +4 -0
- package/src/css/primitives/code/code.ts +3 -1
- package/src/css/primitives/code/types.ts +2 -1
- package/src/css/primitives/container/container.ts +3 -1
- package/src/css/primitives/heading/heading.ts +4 -1
- package/src/css/primitives/heading/types.ts +3 -1
- package/src/css/primitives/kbd/kbd.ts +1 -1
- package/src/css/primitives/kbd/types.ts +1 -1
- package/src/css/primitives/label/label.css.ts +1 -0
- package/src/css/primitives/label/label.ts +4 -1
- package/src/css/primitives/label/types.ts +3 -1
- package/src/css/primitives/switch/switch.css.ts +1 -1
- package/src/css/primitives/text/text.ts +6 -1
- package/src/css/primitives/text/types.ts +5 -2
- package/src/css/props/width/types.ts +1 -1
- package/src/css/props/width/width.css.ts +3 -0
- package/src/theme/v2/build/buildTheme.test.ts +8 -8
- package/src/theme/v2/build/buildTheme.ts +32 -7
- package/src/theme/v3/defaultFonts.ts +6 -6
- package/src/theme/v3/defaultTokens.ts +1 -1
- package/bin/sanity-ui.cjs +0 -5
- package/dist/ui.css +0 -1
- package/src/cli/buildCommand.ts +0 -10
- package/src/cli/index.ts +0 -26
- package/src/core/components/autocomplete/index.ts +0 -2
- package/src/core/components/index.ts +0 -9
- package/src/core/helpers/index.ts +0 -5
- package/src/core/hooks/index.ts +0 -13
- package/src/core/observers/index.ts +0 -2
- package/src/core/primitives/index.ts +0 -27
- package/src/core/types/avatar.ts +0 -16
- package/src/core/types/card.ts +0 -4
- package/src/core/types/index.ts +0 -15
- package/src/core/types/popover.ts +0 -4
- package/src/core/utils/index.ts +0 -8
- package/src/css/__theme/index.ts +0 -16
- package/src/css/__theme/lib/contract/buildVarContract.ts +0 -78
- package/src/css/__theme/lib/contract/index.ts +0 -4
- package/src/css/__theme/lib/contract/types.ts +0 -17
- package/src/css/__theme/resolveTheme.ts +0 -865
- package/src/css/components/index.ts +0 -6
- package/src/css/primitives/index.ts +0 -24
- package/src/css/props/index.ts +0 -37
- package/src/css/utils/srOnly/index.ts +0 -1
- /package/src/core/{global.ts → __DEV__.ts} +0 -0
- /package/src/core/{types/dialog.ts → components/dialog/types.ts} +0 -0
- /package/src/core/{utils → components}/virtualList/__workshop__/changingProps.tsx +0 -0
- /package/src/core/{utils → components}/virtualList/__workshop__/elementScroll.tsx +0 -0
- /package/src/core/{utils → components}/virtualList/__workshop__/infiniteList.tsx +0 -0
- /package/src/core/{utils → components}/virtualList/__workshop__/windowScrolll.tsx +0 -0
- /package/src/core/{utils → components}/virtualList/index.ts +0 -0
- /package/src/core/observers/{resizeObserver.ts → resize.ts} +0 -0
- /package/src/core/{utils → primitives}/arrow/cmds.ts +0 -0
- /package/src/core/{utils → primitives}/arrow/index.ts +0 -0
- /package/src/core/{types/badge.ts → primitives/badge/types2.ts} +0 -0
- /package/src/core/{types/box.ts → primitives/box/types.ts} +0 -0
- /package/src/core/{types/button.ts → primitives/button/types.ts} +0 -0
- /package/src/core/{types/flex.ts → primitives/flex/types.ts} +0 -0
- /package/src/core/{types/grid.ts → primitives/grid/types.ts} +0 -0
- /package/src/core/{utils → primitives}/layer/__workshop__/_debug.tsx +0 -0
- /package/src/core/{utils → primitives}/layer/__workshop__/multipleRoots.tsx +0 -0
- /package/src/core/{utils → primitives}/layer/__workshop__/nested.tsx +0 -0
- /package/src/core/{utils → primitives}/layer/__workshop__/responsiveZOffset.tsx +0 -0
- /package/src/core/{utils → primitives}/layer/getLayerContext.test.ts +0 -0
- /package/src/core/{utils → primitives}/layer/getLayerContext.ts +0 -0
- /package/src/core/{utils → primitives}/layer/index.ts +0 -0
- /package/src/core/{utils → primitives}/layer/layerContext.ts +0 -0
- /package/src/core/{utils → primitives}/layer/types.ts +0 -0
- /package/src/core/{utils → primitives}/layer/useLayer.ts +0 -0
- /package/src/core/{components → primitives}/skeleton/__workshop__/delay.tsx +0 -0
- /package/src/core/{components → primitives}/skeleton/__workshop__/skeleton.tsx +0 -0
- /package/src/core/{components → primitives}/skeleton/index.ts +0 -0
- /package/src/core/{utils → primitives}/srOnly/index.ts +0 -0
- /package/src/core/types/{text.ts → textAlign.ts} +0 -0
- /package/src/css/{utils → primitives/srOnly}/index.ts +0 -0
- /package/src/css/{utils → primitives}/srOnly/srOnly.css.ts +0 -0
- /package/src/css/{utils → primitives}/srOnly/srOnly.ts +0 -0
|
@@ -2,9 +2,10 @@ import type {PaddingStyleProps, RadiusStyleProps, ResponsiveProp} from '@sanity/
|
|
|
2
2
|
import {badge} from '@sanity/ui/css'
|
|
3
3
|
import type {FontTextSize} from '@sanity/ui/theme'
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
6
6
|
import {Box} from '../box'
|
|
7
7
|
import {Text} from '../text'
|
|
8
|
+
import type {BadgeTone} from './types'
|
|
8
9
|
|
|
9
10
|
/** @public */
|
|
10
11
|
export const DEFAULT_BADGE_ELEMENT = 'span'
|
|
@@ -47,10 +48,11 @@ export function Badge<E extends BadgeElementType = typeof DEFAULT_BADGE_ELEMENT>
|
|
|
47
48
|
{...rest}
|
|
48
49
|
as={as}
|
|
49
50
|
className={badge({className, tone})}
|
|
50
|
-
display="
|
|
51
|
+
display="flex"
|
|
51
52
|
maxWidth="fill"
|
|
52
53
|
padding={padding}
|
|
53
54
|
radius={radius}
|
|
55
|
+
width="min"
|
|
54
56
|
>
|
|
55
57
|
<Text size={fontSize}>{children}</Text>
|
|
56
58
|
</Box>
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {ThemeColorStateToneKey} from '@sanity/ui/theme'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @deprecated Will be removed in next major version.
|
|
6
|
+
*/
|
|
7
|
+
export type BadgeMode = 'default' | 'outline'
|
|
8
|
+
|
|
9
|
+
/** @public */
|
|
10
|
+
export type BadgeTone = ThemeColorStateToneKey
|
|
2
11
|
|
|
3
12
|
/**
|
|
4
13
|
* @internal
|
|
5
|
-
* @deprecated
|
|
14
|
+
* @deprecated Will be removed in next major version.
|
|
6
15
|
*/
|
|
7
16
|
export interface BadgeStyleProps {
|
|
8
17
|
$tone: BadgeTone
|
|
@@ -9,7 +9,6 @@ export default function ResponsiveStory() {
|
|
|
9
9
|
display={['none', 'block', 'none', 'block', 'none', 'block', 'none']}
|
|
10
10
|
flex={[1, 2, 3, 4, 5, 6, 7]}
|
|
11
11
|
padding={3}
|
|
12
|
-
sizing={['content', 'border', 'content', 'border', 'content', 'border', 'content']}
|
|
13
12
|
style={{outline: `1px solid ${vars.color.border}`}}
|
|
14
13
|
>
|
|
15
14
|
<Text align="center" muted>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {SquareIcon} from '@sanity/icons'
|
|
2
|
+
import {useBoolean} from '@sanity/ui-workshop'
|
|
2
3
|
|
|
3
4
|
import {Card} from '../../card/card'
|
|
4
5
|
import {Container} from '../../container/container'
|
|
@@ -15,60 +16,45 @@ const DEFAULT_PROPS = {
|
|
|
15
16
|
iconRight: SquareIcon,
|
|
16
17
|
} as const
|
|
17
18
|
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
<Container width={2}>
|
|
21
|
-
<Stack gap={4}>
|
|
22
|
-
<Grid columns={COLUMNS} gap={GAP}>
|
|
23
|
-
<Text size={1} weight="semibold">
|
|
24
|
-
Default
|
|
25
|
-
</Text>
|
|
26
|
-
<Text size={1} weight="semibold">
|
|
27
|
-
Ghost
|
|
28
|
-
</Text>
|
|
29
|
-
<Text size={1} weight="semibold">
|
|
30
|
-
Bleed
|
|
31
|
-
</Text>
|
|
32
|
-
</Grid>
|
|
19
|
+
export default function DisabledButtonStory() {
|
|
20
|
+
const muted = useBoolean('Muted', false)
|
|
33
21
|
|
|
34
|
-
|
|
22
|
+
return (
|
|
23
|
+
<Card padding={5}>
|
|
24
|
+
<Container width={2}>
|
|
25
|
+
<Stack gap={4}>
|
|
35
26
|
<Grid columns={COLUMNS} gap={GAP}>
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<Button {...DEFAULT_PROPS} disabled mode="ghost" muted text="Disabled (muted)" />
|
|
46
|
-
</Stack>
|
|
47
|
-
|
|
48
|
-
<Stack gap={2}>
|
|
49
|
-
<Button {...DEFAULT_PROPS} mode="bleed" text="Enabled" />
|
|
50
|
-
<Button {...DEFAULT_PROPS} mode="bleed" disabled text="Disabled" />
|
|
51
|
-
<Button {...DEFAULT_PROPS} disabled mode="bleed" muted text="Disabled (muted)" />
|
|
52
|
-
</Stack>
|
|
27
|
+
<Text size={1} weight="semibold">
|
|
28
|
+
Default
|
|
29
|
+
</Text>
|
|
30
|
+
<Text size={1} weight="semibold">
|
|
31
|
+
Ghost
|
|
32
|
+
</Text>
|
|
33
|
+
<Text size={1} weight="semibold">
|
|
34
|
+
Bleed
|
|
35
|
+
</Text>
|
|
53
36
|
</Grid>
|
|
54
|
-
</Stack>
|
|
55
|
-
</Stack>
|
|
56
|
-
</Container>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export default function DisabledButtonStory() {
|
|
61
|
-
return (
|
|
62
|
-
<Stack>
|
|
63
|
-
<Stack gap={4}>
|
|
64
|
-
<Card padding={5} scheme="light">
|
|
65
|
-
<Layout />
|
|
66
|
-
</Card>
|
|
67
37
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
38
|
+
<Stack gap={2}>
|
|
39
|
+
<Grid columns={COLUMNS} gap={GAP}>
|
|
40
|
+
<Stack gap={2}>
|
|
41
|
+
<Button {...DEFAULT_PROPS} mode="default" muted={muted} text="Enabled" />
|
|
42
|
+
<Button {...DEFAULT_PROPS} disabled mode="default" muted={muted} text="Disabled" />
|
|
43
|
+
</Stack>
|
|
44
|
+
|
|
45
|
+
<Stack gap={2}>
|
|
46
|
+
<Button {...DEFAULT_PROPS} mode="ghost" muted={muted} text="Enabled" />
|
|
47
|
+
<Button {...DEFAULT_PROPS} disabled mode="ghost" muted={muted} text="Disabled" />
|
|
48
|
+
</Stack>
|
|
49
|
+
|
|
50
|
+
<Stack gap={2}>
|
|
51
|
+
<Button {...DEFAULT_PROPS} mode="bleed" muted={muted} text="Enabled" />
|
|
52
|
+
<Button {...DEFAULT_PROPS} mode="bleed" disabled muted={muted} text="Disabled" />
|
|
53
|
+
</Stack>
|
|
54
|
+
</Grid>
|
|
55
|
+
</Stack>
|
|
56
|
+
</Stack>
|
|
57
|
+
</Container>
|
|
58
|
+
</Card>
|
|
73
59
|
)
|
|
74
60
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {Button, Flex} from '@sanity/ui'
|
|
2
|
+
import {useText} from '@sanity/ui-workshop'
|
|
3
|
+
|
|
4
|
+
export default function TextOverflowStory() {
|
|
5
|
+
const text = useText('Text', 'Long text that should overflow')
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<Flex gap={1} padding={4}>
|
|
9
|
+
<Button flex={1} text={text} />
|
|
10
|
+
<Button mode="bleed" text="Cancel" />
|
|
11
|
+
</Flex>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
@@ -12,11 +12,12 @@ import type {FontTextSize, Space} from '@sanity/ui/theme'
|
|
|
12
12
|
import {type ElementType as ReactElementType, isValidElement, type ReactNode} from 'react'
|
|
13
13
|
import {isValidElementType} from 'react-is'
|
|
14
14
|
|
|
15
|
-
import type {
|
|
15
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
16
16
|
import {Box} from '../box'
|
|
17
17
|
import {Spinner} from '../spinner'
|
|
18
18
|
import type {TextOwnProps} from '../text'
|
|
19
19
|
import {Text} from '../text'
|
|
20
|
+
import type {ButtonTextAlign} from './types'
|
|
20
21
|
|
|
21
22
|
/** @public */
|
|
22
23
|
export const DEFAULT_BUTTON_ELEMENT = 'button'
|
|
@@ -63,7 +64,6 @@ export function Button<E extends ButtonElementType = typeof DEFAULT_BUTTON_ELEME
|
|
|
63
64
|
children,
|
|
64
65
|
className,
|
|
65
66
|
disabled,
|
|
66
|
-
display = 'inline-flex',
|
|
67
67
|
flex,
|
|
68
68
|
fontSize = 1,
|
|
69
69
|
gap = props.space ?? props.padding ?? 3,
|
|
@@ -106,7 +106,7 @@ export function Button<E extends ButtonElementType = typeof DEFAULT_BUTTON_ELEME
|
|
|
106
106
|
<Element
|
|
107
107
|
data-ui="Button"
|
|
108
108
|
{...rest}
|
|
109
|
-
className={button({className,
|
|
109
|
+
className={button({className, flex, mode, radius, tone, width})}
|
|
110
110
|
data-disabled={loading || disabled ? '' : undefined}
|
|
111
111
|
data-selected={selected ? '' : undefined}
|
|
112
112
|
disabled={Boolean(loading || disabled)}
|
|
@@ -154,17 +154,18 @@ export function Button<E extends ButtonElementType = typeof DEFAULT_BUTTON_ELEME
|
|
|
154
154
|
)}
|
|
155
155
|
|
|
156
156
|
{text && (
|
|
157
|
-
<
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
157
|
+
<Box as="span" maxWidth="auto">
|
|
158
|
+
<Text
|
|
159
|
+
align={textAlign}
|
|
160
|
+
as="span"
|
|
161
|
+
muted={muted}
|
|
162
|
+
size={fontSize}
|
|
163
|
+
textOverflow={textOverflow}
|
|
164
|
+
weight={textWeight}
|
|
165
|
+
>
|
|
166
|
+
{text}
|
|
167
|
+
</Text>
|
|
168
|
+
</Box>
|
|
168
169
|
)}
|
|
169
170
|
|
|
170
171
|
{IconRightComponent && (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Box, Card, Flex,
|
|
1
|
+
import {Box, Card, Flex, Text} from '@sanity/ui'
|
|
2
2
|
|
|
3
3
|
import {Stack} from '../../stack'
|
|
4
4
|
|
|
@@ -66,7 +66,7 @@ function List2() {
|
|
|
66
66
|
function Preview() {
|
|
67
67
|
return (
|
|
68
68
|
<Flex align="center" gap={2}>
|
|
69
|
-
<
|
|
69
|
+
<Box muted radius="full" style={{width: 33, height: 33}} />
|
|
70
70
|
<Stack flex={1} gap={2}>
|
|
71
71
|
<Text size={1} weight="medium">
|
|
72
72
|
Preview
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {card, type CardStyleProps} from '@sanity/ui/css'
|
|
2
2
|
|
|
3
|
-
import type {Props} from '../../types'
|
|
3
|
+
import type {Props} from '../../types/props'
|
|
4
4
|
import {Box, type BoxElementType, type BoxOwnProps} from '../box'
|
|
5
5
|
import {CardProvider} from './cardProvider'
|
|
6
6
|
import {useCard} from './useCard'
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type {ThemeColorCardToneKey, ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
2
2
|
import type {ComponentType, ReactNode} from 'react'
|
|
3
3
|
|
|
4
|
+
/** @public */
|
|
5
|
+
export type CardTone = ThemeColorCardToneKey | 'inherit'
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* @internal
|
|
6
9
|
* @deprecated Use `CardStyleProps` from `@sanity/ui/css` instead.
|
|
@@ -6,7 +6,15 @@ export default function MultipleTonesStory() {
|
|
|
6
6
|
<Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
|
|
7
7
|
<Stack gap={1}>
|
|
8
8
|
{THEME_COLOR_CARD_TONES.map((tone) => (
|
|
9
|
-
<Card
|
|
9
|
+
<Card
|
|
10
|
+
alignItems="center"
|
|
11
|
+
as="label"
|
|
12
|
+
display="flex"
|
|
13
|
+
gap={2}
|
|
14
|
+
padding={3}
|
|
15
|
+
radius={3}
|
|
16
|
+
tone={tone}
|
|
17
|
+
>
|
|
10
18
|
<Checkbox />
|
|
11
19
|
<Text muted size={1}>
|
|
12
20
|
{tone}
|
|
@@ -2,8 +2,8 @@ import {CheckmarkIcon, RemoveIcon} from '@sanity/icons'
|
|
|
2
2
|
import {checkbox, checkboxInput, checkboxPresentation} from '@sanity/ui/css'
|
|
3
3
|
import {useEffect, useImperativeHandle, useRef} from 'react'
|
|
4
4
|
|
|
5
|
-
import {useCustomValidity} from '../../hooks'
|
|
6
|
-
import type {ComponentType, Props} from '../../types'
|
|
5
|
+
import {useCustomValidity} from '../../hooks/useCustomValidity'
|
|
6
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
7
7
|
|
|
8
8
|
/** @public */
|
|
9
9
|
export const DEFAULT_CHECKBOX_ELEMENT = 'input'
|
|
@@ -33,7 +33,6 @@ export function Checkbox<E extends CheckboxElementType = typeof DEFAULT_CHECKBOX
|
|
|
33
33
|
) {
|
|
34
34
|
const {
|
|
35
35
|
as: Element = DEFAULT_CHECKBOX_ELEMENT,
|
|
36
|
-
checked,
|
|
37
36
|
className,
|
|
38
37
|
disabled,
|
|
39
38
|
indeterminate,
|
|
@@ -64,9 +63,9 @@ export function Checkbox<E extends CheckboxElementType = typeof DEFAULT_CHECKBOX
|
|
|
64
63
|
<span className={checkbox({className})} data-ui="Checkbox" style={style}>
|
|
65
64
|
<Element
|
|
66
65
|
{...rest}
|
|
67
|
-
checked={checked}
|
|
68
66
|
className={checkboxInput()}
|
|
69
67
|
data-invalid={customValidity ? '' : undefined}
|
|
68
|
+
data-read-only={!disabled && readOnly ? '' : undefined}
|
|
70
69
|
disabled={disabled || readOnly}
|
|
71
70
|
type="checkbox"
|
|
72
71
|
readOnly={readOnly}
|
|
@@ -1,48 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {Box,
|
|
1
|
+
import {CropIcon} from '@sanity/icons'
|
|
2
|
+
import {Box, Code, Stack} from '@sanity/ui'
|
|
3
|
+
import {vars} from '@sanity/ui/css'
|
|
4
|
+
import {FONT_CODE_SIZE} from '@sanity/ui/theme'
|
|
3
5
|
|
|
4
6
|
export default function OpticalAlignment() {
|
|
5
7
|
return (
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
<Code size={
|
|
11
|
-
|
|
12
|
-
</Flex>
|
|
13
|
-
|
|
14
|
-
<Flex>
|
|
15
|
-
<Card padding={0} scheme="dark">
|
|
16
|
-
<Code size={3}>Hamburgefonstiv M</Code>
|
|
17
|
-
</Card>
|
|
18
|
-
</Flex>
|
|
19
|
-
|
|
20
|
-
<Flex>
|
|
21
|
-
<Card padding={0} scheme="dark">
|
|
22
|
-
<Code size={2}>Hamburgefonstiv M</Code>
|
|
23
|
-
</Card>
|
|
24
|
-
</Flex>
|
|
25
|
-
|
|
26
|
-
<Flex>
|
|
27
|
-
<Card padding={0} scheme="dark">
|
|
28
|
-
<Code size={1}>Hamburgefonstiv M</Code>
|
|
29
|
-
</Card>
|
|
30
|
-
</Flex>
|
|
31
|
-
|
|
32
|
-
<Flex>
|
|
33
|
-
<Card padding={0} scheme="dark">
|
|
34
|
-
<Code size={0}>Hamburgefonstiv M</Code>
|
|
35
|
-
</Card>
|
|
36
|
-
</Flex>
|
|
37
|
-
|
|
38
|
-
<Flex>
|
|
39
|
-
<Card padding={2} scheme="dark">
|
|
40
|
-
<Code>
|
|
41
|
-
<AddCircleIcon />
|
|
8
|
+
<Stack gap={3} padding={[4, 5, 6]}>
|
|
9
|
+
{FONT_CODE_SIZE.map((size) => (
|
|
10
|
+
<Box display="flex" gap={2} key={size}>
|
|
11
|
+
<div style={{outline: `0.5px solid ${vars.color.tinted.suggest.border[4]}`}}>
|
|
12
|
+
<Code size={size}>
|
|
13
|
+
<CropIcon />
|
|
42
14
|
</Code>
|
|
43
|
-
</
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
15
|
+
</div>
|
|
16
|
+
<div style={{outline: `0.5px solid ${vars.color.tinted.suggest.border[4]}`}}>
|
|
17
|
+
<Code size={size}>Hamburgefonstiv M</Code>
|
|
18
|
+
</div>
|
|
19
|
+
</Box>
|
|
20
|
+
))}
|
|
21
|
+
</Stack>
|
|
47
22
|
)
|
|
48
23
|
}
|
|
@@ -2,7 +2,7 @@ import {code, type CodeStyleProps, type ResponsiveProp} from '@sanity/ui/css'
|
|
|
2
2
|
import type {FontCodeSize} from '@sanity/ui/theme'
|
|
3
3
|
import {lazy, Suspense} from 'react'
|
|
4
4
|
|
|
5
|
-
import type {ComponentType, Props} from '../../types'
|
|
5
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
6
6
|
|
|
7
7
|
const LazyRefractor = lazy(() => import('./refractor'))
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {ResponsiveProp} from '@sanity/ui/css'
|
|
2
2
|
import type {Space} from '@sanity/ui/theme'
|
|
3
3
|
|
|
4
|
-
import type {Props} from '../../types'
|
|
4
|
+
import type {Props} from '../../types/props'
|
|
5
5
|
import {Box, type BoxElementType, type BoxOwnProps} from '../box'
|
|
6
6
|
|
|
7
7
|
/** @public */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {kbd, type RadiusStyleProps, type ResponsiveProp} from '@sanity/ui/css'
|
|
2
2
|
import type {FontTextSize} from '@sanity/ui/theme'
|
|
3
3
|
|
|
4
|
-
import type {ComponentType, Props} from '../../types'
|
|
4
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
5
5
|
import {Box, type BoxElementType, type BoxOwnProps} from '../box'
|
|
6
6
|
import {Text} from '../text'
|
|
7
7
|
|
|
@@ -5,7 +5,7 @@ import {LayerContext} from './layerContext'
|
|
|
5
5
|
import type {LayerContextValue} from './types'
|
|
6
6
|
import {useLayer} from './useLayer'
|
|
7
7
|
|
|
8
|
-
describe('
|
|
8
|
+
describe('primitives/layer', () => {
|
|
9
9
|
describe('useLayer', () => {
|
|
10
10
|
it('should get context value', async () => {
|
|
11
11
|
const log = vi.fn()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {ResponsiveProp} from '@sanity/ui/css'
|
|
2
2
|
|
|
3
|
-
import type {CardElementType, CardOwnProps} from '../../primitives'
|
|
4
|
-
import type {Props} from '../../types'
|
|
3
|
+
import type {CardElementType, CardOwnProps} from '../../primitives/card'
|
|
4
|
+
import type {Props} from '../../types/props'
|
|
5
5
|
import {LayerCard} from './layerCard'
|
|
6
6
|
import {LayerProvider} from './layerProvider'
|
|
7
7
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {type FocusEvent, useCallback, useEffect, useImperativeHandle, useRef} from 'react'
|
|
2
2
|
|
|
3
3
|
import {EMPTY_RECORD} from '../../constants'
|
|
4
|
-
import {containsOrEqualsElement, isHTMLElement} from '../../helpers'
|
|
5
|
-
import {Card, type CardElementType} from '../../primitives'
|
|
6
|
-
import type {Props} from '../../types'
|
|
4
|
+
import {containsOrEqualsElement, isHTMLElement} from '../../helpers/element'
|
|
5
|
+
import {Card, type CardElementType} from '../../primitives/card'
|
|
6
|
+
import type {Props} from '../../types/props'
|
|
7
7
|
import type {LayerElementType, LayerOwnProps} from './layer'
|
|
8
8
|
import {useLayer} from './useLayer'
|
|
9
9
|
|
|
@@ -9,7 +9,8 @@ import {
|
|
|
9
9
|
useState,
|
|
10
10
|
} from 'react'
|
|
11
11
|
|
|
12
|
-
import {useMediaIndex
|
|
12
|
+
import {useMediaIndex} from '../../hooks/useMediaIndex'
|
|
13
|
+
import {useResponsiveProp} from '../../hooks/useResponsiveProp'
|
|
13
14
|
import {getLayerContext} from './getLayerContext'
|
|
14
15
|
import {LayerContext} from './layerContext'
|
|
15
16
|
import type {LayerContextValue} from './types'
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BoundaryElementProvider,
|
|
3
|
+
Box,
|
|
4
|
+
Card,
|
|
5
|
+
type CardTone,
|
|
6
|
+
Flex,
|
|
7
|
+
Popover,
|
|
8
|
+
type PopoverProps,
|
|
9
|
+
type PopoverUpdateCallback,
|
|
10
|
+
Stack,
|
|
11
|
+
Text,
|
|
12
|
+
} from '@sanity/ui'
|
|
1
13
|
import {useSelect} from '@sanity/ui-workshop'
|
|
2
14
|
import {useCallback, useEffect, useRef, useState} from 'react'
|
|
3
15
|
|
|
4
16
|
import {WORKSHOP_CARD_TONE_OPTIONS} from '$workshop'
|
|
5
|
-
import type {CardTone} from '../../../types'
|
|
6
|
-
import {BoundaryElementProvider} from '../../../utils'
|
|
7
|
-
import {Box} from '../../box'
|
|
8
|
-
import {Card} from '../../card'
|
|
9
|
-
import {Flex} from '../../flex'
|
|
10
|
-
import {Stack} from '../../stack'
|
|
11
|
-
import {Text} from '../../text'
|
|
12
|
-
import {Popover, type PopoverProps} from '../popover'
|
|
13
|
-
import type {PopoverUpdateCallback} from '../types'
|
|
14
17
|
|
|
15
18
|
const SIDE_PANEL_WIDTH = {
|
|
16
19
|
sm: 300,
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BoundaryElementProvider,
|
|
3
|
+
Button,
|
|
4
|
+
Card,
|
|
5
|
+
Popover,
|
|
6
|
+
type PopoverUpdateCallback,
|
|
7
|
+
PortalProvider,
|
|
8
|
+
Text,
|
|
9
|
+
} from '@sanity/ui'
|
|
1
10
|
import {useBoolean, useSelect, useText} from '@sanity/ui-workshop'
|
|
2
11
|
import {useRef, useState} from 'react'
|
|
3
12
|
|
|
4
13
|
import {
|
|
5
14
|
WORKSHOP_CONTAINER_WIDTH_OPTIONS,
|
|
6
|
-
// WORKSHOP_CONTAINER_WIDTH_OPTIONS,
|
|
7
15
|
WORKSHOP_PLACEMENT_OPTIONS,
|
|
8
16
|
WORKSHOP_RADIUS_OPTIONS,
|
|
9
17
|
} from '$workshop'
|
|
10
18
|
|
|
11
|
-
import {BoundaryElementProvider, PortalProvider} from '../../../utils'
|
|
12
|
-
import {Button} from '../../button'
|
|
13
|
-
import {Card} from '../../card'
|
|
14
|
-
import {Text} from '../../text'
|
|
15
|
-
import {Popover} from '../popover'
|
|
16
|
-
import type {PopoverUpdateCallback} from '../types'
|
|
17
|
-
|
|
18
19
|
export default function TestStory(): React.JSX.Element {
|
|
19
20
|
const [portalElement, setPortalElement] = useState<HTMLDivElement | null>(null)
|
|
20
21
|
const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)
|