@sanity/ui 2.16.22 → 2.16.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks-cjs/_visual-editing.js +115 -1040
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-cjs/refractor.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +115 -1040
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_chunks-es/refractor.mjs.map +1 -1
- package/dist/_visual-editing.d.mts +411 -351
- package/dist/_visual-editing.d.ts +411 -351
- package/dist/index.d.mts +1107 -930
- package/dist/index.d.ts +1107 -930
- package/dist/index.js +64 -155
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -155
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +769 -681
- package/dist/theme.d.ts +769 -681
- package/dist/theme.js +47 -0
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +47 -0
- package/dist/theme.mjs.map +1 -1
- package/exports/_visual-editing.ts +1 -0
- package/package.json +50 -163
- package/src/core/_compat.ts +30 -0
- package/src/core/components/autocomplete/autocomplete.tsx +11 -4
- package/src/core/components/autocomplete/autocompleteOption.tsx +1 -0
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +1 -0
- package/src/core/components/dialog/dialog.tsx +3 -0
- package/src/core/components/hotkeys/hotkeys.tsx +1 -0
- package/src/core/components/menu/menu.test.tsx +6 -4
- package/src/core/components/menu/menu.tsx +3 -2
- package/src/core/components/menu/menuButton.tsx +8 -0
- package/src/core/components/menu/menuGroup.tsx +5 -2
- package/src/core/components/menu/menuItem.tsx +4 -0
- package/src/core/components/menu/useMenuController.ts +6 -4
- package/src/core/components/skeleton/skeleton.tsx +2 -1
- package/src/core/components/tab/tab.tsx +1 -0
- package/src/core/components/tab/tabList.tsx +1 -0
- package/src/core/components/toast/toast.test.tsx +9 -4
- package/src/core/components/tree/tree.tsx +1 -0
- package/src/core/components/tree/treeGroup.tsx +1 -0
- package/src/core/components/tree/treeItem.tsx +2 -2
- package/src/core/hooks/useClickOutside.test.tsx +43 -15
- package/src/core/hooks/useClickOutside.ts +1 -1
- package/src/core/hooks/useClickOutsideEvent.test.tsx +8 -4
- package/src/core/hooks/useDelayed.test.ts +7 -6
- package/src/core/hooks/useElementRect/useElementRect.ts +1 -0
- package/src/core/hooks/useForwardedRef.ts +1 -0
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +2 -1
- package/src/core/hooks/usePrefersDark.hydration.test.tsx +7 -5
- package/src/core/hooks/usePrefersDark.test.tsx +3 -1
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +7 -5
- package/src/core/hooks/usePrefersReducedMotion.test.tsx +3 -1
- package/src/core/lib/createGlobalScopedContext.ts +1 -0
- package/src/core/lib/globalScope.ts +1 -0
- package/src/core/observers/elementSizeObserver.ts +1 -0
- package/src/core/primitives/avatar/avatar.tsx +1 -2
- package/src/core/primitives/avatar/avatarStack.tsx +1 -0
- package/src/core/primitives/badge/badge.test.tsx +3 -2
- package/src/core/primitives/badge/badge.tsx +2 -1
- package/src/core/primitives/box/box.tsx +2 -1
- package/src/core/primitives/button/button.test.tsx +3 -2
- package/src/core/primitives/button/button.tsx +2 -0
- package/src/core/primitives/button/styles.ts +1 -0
- package/src/core/primitives/card/card.tsx +1 -5
- package/src/core/primitives/card/types.ts +1 -0
- package/src/core/primitives/code/refractor.tsx +2 -0
- package/src/core/primitives/flex/flex.tsx +1 -3
- package/src/core/primitives/inline/inline.tsx +1 -0
- package/src/core/primitives/popover/popover.tsx +12 -3
- package/src/core/primitives/popover/popoverCard.tsx +1 -0
- package/src/core/primitives/popover/types.ts +0 -1
- package/src/core/primitives/stack/styles.ts +1 -0
- package/src/core/primitives/textInput/textInput.tsx +2 -0
- package/src/core/primitives/tooltip/tooltip.test.tsx +82 -49
- package/src/core/primitives/tooltip/tooltip.tsx +5 -0
- package/src/core/primitives/tooltip/tooltipCard.tsx +1 -0
- package/src/core/primitives/tooltip/tooltipDelayGroup/types.ts +2 -0
- package/src/core/styles/flex/types.ts +0 -1
- package/src/core/styles/font/responsiveFont.ts +0 -3
- package/src/core/styles/font/types.ts +1 -3
- package/src/core/styles/grid/gridStyle.ts +1 -0
- package/src/core/styles/margin/marginStyle.ts +1 -0
- package/src/core/styles/margin/marginsStyle.test.ts +2 -1
- package/src/core/styles/padding/paddingStyle.test.ts +2 -1
- package/src/core/styles/padding/paddingStyle.ts +1 -0
- package/src/core/theme/theme.test.tsx +7 -3
- package/src/core/theme/useRootTheme.ts +1 -0
- package/src/core/theme/useTheme.ts +2 -0
- package/src/core/utils/arrow/arrow.tsx +1 -0
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +9 -4
- package/src/core/utils/conditionalWrapper/conditionalWrapper.tsx +1 -0
- package/src/core/utils/getElementRef.ts +5 -0
- package/src/core/utils/layer/getLayerContext.test.ts +2 -0
- package/src/core/utils/layer/layer.test.tsx +9 -4
- package/src/core/utils/layer/layer.tsx +1 -0
- package/src/core/utils/layer/useLayer.ts +2 -0
- package/src/core/utils/portal/portal.test.tsx +9 -4
- package/src/core/utils/portal/portalProvider.tsx +4 -3
- package/src/core/utils/virtualList/virtualList.tsx +2 -1
- package/src/theme/build/_deprecated/color/_selectable/createSelectableTones.ts +10 -0
- package/src/theme/build/_deprecated/color/_solid/createSolidTones.ts +4 -0
- package/src/theme/build/_deprecated/color/button/createButtonModes.ts +5 -0
- package/src/theme/build/_deprecated/color/button/createButtonTones.ts +5 -0
- package/src/theme/build/_deprecated/color/card/createCardStates.ts +6 -0
- package/src/theme/build/_deprecated/color/color.test.ts +5 -1
- package/src/theme/build/_deprecated/color/defaults.ts +1 -0
- package/src/theme/build/_deprecated/color/factory.ts +36 -0
- package/src/theme/build/_deprecated/color/input/createInputModes.ts +5 -0
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +4 -0
- package/src/theme/build/_deprecated/color/spot/createSpot.ts +3 -0
- package/src/theme/build/buildColorTheme.test.ts +2 -0
- package/src/theme/build/buildColorTheme.ts +7 -0
- package/src/theme/build/buildTheme.test.ts +2 -0
- package/src/theme/build/lib/color-fns/color-fns.test.ts +3 -1
- package/src/theme/build/merge.ts +5 -0
- package/src/theme/build/mixThemeColor.test.ts +2 -0
- package/src/theme/build/renderColorTheme.ts +6 -0
- package/src/theme/build/renderColorValue.ts +0 -2
- package/src/theme/build/resolveColorTokens.ts +6 -0
- package/src/theme/build/theme.test.ts +2 -0
- package/src/theme/config/helpers.ts +5 -0
- package/src/theme/config/system.ts +2 -0
- package/src/theme/config/tokens/color/types.ts +6 -4
- package/src/theme/config/tokens/parseTokenKey.test.ts +2 -0
- package/src/theme/config/tokens/parseTokenValue.test.ts +2 -0
- package/src/theme/config/tokens/parseTokenValue.ts +1 -0
- package/src/theme/getScopedTheme.ts +5 -0
- package/src/theme/system/color/_helpers.ts +4 -0
- package/src/theme/system/theme.ts +4 -0
- package/src/theme/system/v0/color/_system.ts +1 -0
- package/src/theme/system/v0/color/button.ts +14 -0
- package/src/theme/system/v0/color/card.ts +6 -0
- package/src/theme/system/v0/color/color.ts +11 -0
- package/src/theme/system/v0/color/input.ts +6 -0
- package/src/theme/system/v0/color/muted.ts +11 -0
- package/src/theme/system/v0/color/selectable.ts +11 -0
- package/src/theme/system/v0/color/solid.ts +11 -0
- package/src/theme/system/v0/color/spot.ts +1 -0
- package/src/theme/versioning/getTheme_v2.ts +15 -0
- package/src/theme/versioning/themeColor_v0_v2.ts +7 -0
- package/src/theme/versioning/themeColor_v2_v2_9.ts +1 -0
- package/src/theme/versioning/v0_v2.ts +13 -1
- package/src/theme/versioning/v2_v0.ts +15 -0
- package/src/core/__workshop__/constants.ts +0 -293
- package/src/core/components/autocomplete/__mocks__/apiStore.ts +0 -49
- package/src/core/components/autocomplete/__mocks__/countries.ts +0 -245
- package/src/core/components/autocomplete/__workshop__/async.tsx +0 -156
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +0 -137
- package/src/core/components/autocomplete/__workshop__/custom.tsx +0 -89
- package/src/core/components/autocomplete/__workshop__/example.tsx +0 -79
- package/src/core/components/autocomplete/__workshop__/focusAndBlur.tsx +0 -36
- package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +0 -294
- package/src/core/components/autocomplete/__workshop__/index.ts +0 -39
- package/src/core/components/autocomplete/__workshop__/types.ts +0 -4
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +0 -62
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -14
- package/src/core/components/dialog/__workshop__/activate.tsx +0 -134
- package/src/core/components/dialog/__workshop__/autoFocus.tsx +0 -29
- package/src/core/components/dialog/__workshop__/index.ts +0 -19
- package/src/core/components/dialog/__workshop__/layering.tsx +0 -41
- package/src/core/components/dialog/__workshop__/nested.tsx +0 -72
- package/src/core/components/dialog/__workshop__/onScroll.tsx +0 -39
- package/src/core/components/dialog/__workshop__/panes.tsx +0 -82
- package/src/core/components/dialog/__workshop__/position.tsx +0 -30
- package/src/core/components/dialog/__workshop__/props.tsx +0 -75
- package/src/core/components/dialog/__workshop__/provider.tsx +0 -11
- package/src/core/components/dialog/__workshop__/wrapped.tsx +0 -76
- package/src/core/components/hotkeys/__workshop__/index.ts +0 -14
- package/src/core/components/hotkeys/__workshop__/plain.tsx +0 -9
- package/src/core/components/menu/__workshop__/asComponent.tsx +0 -45
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +0 -51
- package/src/core/components/menu/__workshop__/closableMenuButton.tsx +0 -46
- package/src/core/components/menu/__workshop__/constrainedInBoundary.tsx +0 -134
- package/src/core/components/menu/__workshop__/customMenuItem.tsx +0 -45
- package/src/core/components/menu/__workshop__/customSelectedState.tsx +0 -39
- package/src/core/components/menu/__workshop__/disableFocusOnClose.tsx +0 -40
- package/src/core/components/menu/__workshop__/groups.tsx +0 -156
- package/src/core/components/menu/__workshop__/index.ts +0 -89
- package/src/core/components/menu/__workshop__/menuButton.tsx +0 -80
- package/src/core/components/menu/__workshop__/menuGroupRight.tsx +0 -65
- package/src/core/components/menu/__workshop__/nestedMenu.tsx +0 -22
- package/src/core/components/menu/__workshop__/onCloseMenuButton.tsx +0 -41
- package/src/core/components/menu/__workshop__/selectedItem.tsx +0 -69
- package/src/core/components/menu/__workshop__/shouldFocus.tsx +0 -47
- package/src/core/components/menu/__workshop__/tones.tsx +0 -25
- package/src/core/components/menu/__workshop__/withoutArrow.tsx +0 -32
- package/src/core/components/skeleton/__workshop__/delay.tsx +0 -70
- package/src/core/components/skeleton/__workshop__/index.ts +0 -11
- package/src/core/components/skeleton/__workshop__/skeleton.tsx +0 -64
- package/src/core/components/tab/__workshop__/example.tsx +0 -79
- package/src/core/components/tab/__workshop__/index.ts +0 -14
- package/src/core/components/toast/__workshop__/hook.tsx +0 -71
- package/src/core/components/toast/__workshop__/index.ts +0 -19
- package/src/core/components/toast/__workshop__/toast.tsx +0 -26
- package/src/core/components/tree/__workshop__/basic.perf.ts +0 -19
- package/src/core/components/tree/__workshop__/basic.tsx +0 -105
- package/src/core/components/tree/__workshop__/index.ts +0 -21
- package/src/core/components/tree/__workshop__/tabFromElement.tsx +0 -84
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +0 -32
- package/src/core/hooks/useElementRect/__workshop__/index.ts +0 -14
- package/src/core/hooks/useMediaIndex/__workshop__/index.ts +0 -14
- package/src/core/hooks/useMediaIndex/__workshop__/test.tsx +0 -14
- package/src/core/primitives/avatar/__workshop__/asButton.tsx +0 -14
- package/src/core/primitives/avatar/__workshop__/index.ts +0 -29
- package/src/core/primitives/avatar/__workshop__/stack.tsx +0 -25
- package/src/core/primitives/avatar/__workshop__/withinButton.tsx +0 -63
- package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +0 -70
- package/src/core/primitives/badge/__workshop__/index.ts +0 -19
- package/src/core/primitives/badge/__workshop__/props.tsx +0 -30
- package/src/core/primitives/badge/__workshop__/tones.tsx +0 -21
- package/src/core/primitives/box/__workshop__/index.ts +0 -19
- package/src/core/primitives/box/__workshop__/props.tsx +0 -20
- package/src/core/primitives/box/__workshop__/responsive.tsx +0 -20
- package/src/core/primitives/button/__workshop__/custom.tsx +0 -51
- package/src/core/primitives/button/__workshop__/customIcons.tsx +0 -30
- package/src/core/primitives/button/__workshop__/disabled.tsx +0 -74
- package/src/core/primitives/button/__workshop__/index.ts +0 -59
- package/src/core/primitives/button/__workshop__/mixedChildren.tsx +0 -12
- package/src/core/primitives/button/__workshop__/props.tsx +0 -55
- package/src/core/primitives/button/__workshop__/sanityUploadButton.tsx +0 -36
- package/src/core/primitives/button/__workshop__/stacked.tsx +0 -58
- package/src/core/primitives/button/__workshop__/styled1.tsx +0 -17
- package/src/core/primitives/button/__workshop__/styled2.tsx +0 -19
- package/src/core/primitives/button/__workshop__/uploadButton.tsx +0 -28
- package/src/core/primitives/card/__workshop__/allTones.tsx +0 -25
- package/src/core/primitives/card/__workshop__/asButton.tsx +0 -107
- package/src/core/primitives/card/__workshop__/asComponent.tsx +0 -27
- package/src/core/primitives/card/__workshop__/checkered.tsx +0 -26
- package/src/core/primitives/card/__workshop__/index.ts +0 -18
- package/src/core/primitives/card/__workshop__/interactive.tsx +0 -30
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +0 -80
- package/src/core/primitives/card/__workshop__/props.tsx +0 -53
- package/src/core/primitives/card/__workshop__/selected.tsx +0 -94
- package/src/core/primitives/card/__workshop__/styled.tsx +0 -14
- package/src/core/primitives/checkbox/__workshop__/example.tsx +0 -25
- package/src/core/primitives/checkbox/__workshop__/index.ts +0 -13
- package/src/core/primitives/checkbox/__workshop__/props.tsx +0 -33
- package/src/core/primitives/checkbox/__workshop__/readOnly.tsx +0 -16
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +0 -28
- package/src/core/primitives/code/__workshop__/index.ts +0 -19
- package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/code/__workshop__/props.tsx +0 -21
- package/src/core/primitives/container/__workshop__/example.tsx +0 -20
- package/src/core/primitives/container/__workshop__/index.ts +0 -8
- package/src/core/primitives/flex/__workshop__/example.tsx +0 -34
- package/src/core/primitives/flex/__workshop__/gap.tsx +0 -25
- package/src/core/primitives/flex/__workshop__/index.ts +0 -11
- package/src/core/primitives/grid/__workshop__/index.ts +0 -10
- package/src/core/primitives/grid/__workshop__/responsive.tsx +0 -54
- package/src/core/primitives/heading/__workshop__/index.ts +0 -19
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +0 -54
- package/src/core/primitives/heading/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/inline/__workshop__/index.ts +0 -8
- package/src/core/primitives/inline/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/kbd/__workshop__/index.ts +0 -8
- package/src/core/primitives/kbd/__workshop__/plain.tsx +0 -9
- package/src/core/primitives/label/__workshop__/index.ts +0 -19
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/label/__workshop__/plain.tsx +0 -24
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +0 -77
- package/src/core/primitives/popover/__workshop__/MarginsStory.tsx +0 -31
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +0 -32
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +0 -11
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +0 -89
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +0 -97
- package/src/core/primitives/popover/__workshop__/index.ts +0 -49
- package/src/core/primitives/radio/__workshop__/example.tsx +0 -63
- package/src/core/primitives/radio/__workshop__/index.ts +0 -11
- package/src/core/primitives/radio/__workshop__/plain.tsx +0 -28
- package/src/core/primitives/select/__workshop__/index.ts +0 -11
- package/src/core/primitives/select/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/select/__workshop__/readOnly.tsx +0 -23
- package/src/core/primitives/spinner/__workshop__/Props.tsx +0 -15
- package/src/core/primitives/spinner/__workshop__/index.ts +0 -14
- package/src/core/primitives/stack/__workshop__/index.ts +0 -14
- package/src/core/primitives/stack/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/switch/__workshop__/example.tsx +0 -23
- package/src/core/primitives/switch/__workshop__/index.ts +0 -11
- package/src/core/primitives/switch/__workshop__/props.tsx +0 -21
- package/src/core/primitives/text/__workshop__/colored.tsx +0 -30
- package/src/core/primitives/text/__workshop__/example.tsx +0 -39
- package/src/core/primitives/text/__workshop__/index.ts +0 -24
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/textArea/__workshop__/index.ts +0 -14
- package/src/core/primitives/textArea/__workshop__/plain.tsx +0 -50
- package/src/core/primitives/textInput/__workshop__/clearButton.tsx +0 -30
- package/src/core/primitives/textInput/__workshop__/customValidity.tsx +0 -17
- package/src/core/primitives/textInput/__workshop__/index.ts +0 -44
- package/src/core/primitives/textInput/__workshop__/plain.tsx +0 -98
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +0 -9
- package/src/core/primitives/textInput/__workshop__/states.tsx +0 -53
- package/src/core/primitives/textInput/__workshop__/tones.tsx +0 -277
- package/src/core/primitives/textInput/__workshop__/typed.tsx +0 -23
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +0 -102
- package/src/core/primitives/tooltip/__workshop__/index.ts +0 -29
- package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +0 -74
- package/src/core/primitives/tooltip/__workshop__/props.tsx +0 -107
- package/src/core/primitives/tooltip/__workshop__/resizableBoundary.tsx +0 -86
- package/src/core/theme/__workshop__/build/Root.tsx +0 -367
- package/src/core/theme/__workshop__/build/helpers.ts +0 -46
- package/src/core/theme/__workshop__/build/story.tsx +0 -465
- package/src/core/theme/__workshop__/canvas.tsx +0 -352
- package/src/core/theme/__workshop__/color.tsx +0 -62
- package/src/core/theme/__workshop__/debug/story.tsx +0 -408
- package/src/core/theme/__workshop__/index.ts +0 -39
- package/src/core/theme/__workshop__/layer.tsx +0 -78
- package/src/core/theme/__workshop__/nestedProvider.tsx +0 -15
- package/src/core/utils/boundaryElement/__workshop__/index.ts +0 -14
- package/src/core/utils/boundaryElement/__workshop__/plain.tsx +0 -19
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +0 -30
- package/src/core/utils/elementQuery/__workshop__/index.ts +0 -14
- package/src/core/utils/layer/__workshop__/_debug.tsx +0 -17
- package/src/core/utils/layer/__workshop__/index.ts +0 -24
- package/src/core/utils/layer/__workshop__/multipleRoots.tsx +0 -49
- package/src/core/utils/layer/__workshop__/nested.tsx +0 -98
- package/src/core/utils/layer/__workshop__/responsiveZOffset.tsx +0 -13
- package/src/core/utils/portal/__workshop__/index.ts +0 -14
- package/src/core/utils/portal/__workshop__/named.tsx +0 -63
- package/src/core/utils/virtualList/__workshop__/changingProps.tsx +0 -36
- package/src/core/utils/virtualList/__workshop__/elementScroll.tsx +0 -24
- package/src/core/utils/virtualList/__workshop__/index.ts +0 -29
- package/src/core/utils/virtualList/__workshop__/infiniteList.tsx +0 -48
- package/src/core/utils/virtualList/__workshop__/windowScrolll.tsx +0 -22
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {Box, Button, Dialog, LayerProvider, Menu, MenuButton, MenuItem} from '@sanity/ui'
|
|
2
|
-
import {useEffect, useRef, useState} from 'react'
|
|
3
|
-
|
|
4
|
-
export default function NestedStory() {
|
|
5
|
-
const [open1] = useState(true)
|
|
6
|
-
const [open2, setOpen2] = useState(false)
|
|
7
|
-
const [open3, setOpen3] = useState(false)
|
|
8
|
-
|
|
9
|
-
const dialog2Button = useRef<HTMLButtonElement>(null)
|
|
10
|
-
const dialog3Button = useRef<HTMLButtonElement>(null)
|
|
11
|
-
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (!open2) dialog2Button.current?.focus()
|
|
14
|
-
}, [open2])
|
|
15
|
-
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
if (!open3) dialog3Button.current?.focus()
|
|
18
|
-
}, [open3])
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<LayerProvider>
|
|
22
|
-
{open1 && (
|
|
23
|
-
<Dialog animate cardShadow={1} header="Dialog 1" id="dialog1">
|
|
24
|
-
<Box padding={4}>
|
|
25
|
-
<Button onClick={() => setOpen2(true)} ref={dialog2Button} text="Open Dialog 2" />
|
|
26
|
-
</Box>
|
|
27
|
-
|
|
28
|
-
{open2 && (
|
|
29
|
-
<Dialog
|
|
30
|
-
animate
|
|
31
|
-
cardShadow={2}
|
|
32
|
-
header="Dialog 2"
|
|
33
|
-
id="dialog2"
|
|
34
|
-
onClose={() => setOpen2(false)}
|
|
35
|
-
onClickOutside={() => setOpen2(false)}
|
|
36
|
-
>
|
|
37
|
-
<Box padding={4}>
|
|
38
|
-
<Button onClick={() => setOpen3(true)} ref={dialog3Button} text="Open Dialog 3" />
|
|
39
|
-
</Box>
|
|
40
|
-
|
|
41
|
-
{open3 && (
|
|
42
|
-
<Dialog
|
|
43
|
-
animate
|
|
44
|
-
cardShadow={4}
|
|
45
|
-
header="Dialog 3"
|
|
46
|
-
id="dialog3"
|
|
47
|
-
onClose={() => setOpen3(false)}
|
|
48
|
-
onClickOutside={() => setOpen3(false)}
|
|
49
|
-
>
|
|
50
|
-
<Box padding={4}>
|
|
51
|
-
<MenuButton
|
|
52
|
-
button={<Button text="Test" />}
|
|
53
|
-
id="menu3"
|
|
54
|
-
popover={{animate: true}}
|
|
55
|
-
menu={
|
|
56
|
-
<Menu>
|
|
57
|
-
<MenuItem text="Test" />
|
|
58
|
-
<MenuItem text="Test" />
|
|
59
|
-
</Menu>
|
|
60
|
-
}
|
|
61
|
-
portal
|
|
62
|
-
/>
|
|
63
|
-
</Box>
|
|
64
|
-
</Dialog>
|
|
65
|
-
)}
|
|
66
|
-
</Dialog>
|
|
67
|
-
)}
|
|
68
|
-
</Dialog>
|
|
69
|
-
)}
|
|
70
|
-
</LayerProvider>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {Box, Dialog, LayerProvider, Text} from '@sanity/ui'
|
|
2
|
-
import {useAction} from '@sanity/ui-workshop'
|
|
3
|
-
import {useEffect, useRef} from 'react'
|
|
4
|
-
|
|
5
|
-
export default function OnScrollStory() {
|
|
6
|
-
const ref = useRef<HTMLDivElement | null>(null)
|
|
7
|
-
const handleScroll = useAction('scroll')
|
|
8
|
-
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
const el = ref.current
|
|
11
|
-
|
|
12
|
-
if (!el) return
|
|
13
|
-
|
|
14
|
-
el.addEventListener('scroll', handleScroll, {passive: true})
|
|
15
|
-
|
|
16
|
-
return () => el.removeEventListener('scroll', handleScroll)
|
|
17
|
-
}, [handleScroll])
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<LayerProvider>
|
|
21
|
-
<Dialog contentRef={ref} header="On scroll example" id="on-scroll-example">
|
|
22
|
-
<Box padding={4}>
|
|
23
|
-
<Text>
|
|
24
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque at nisl at sem tempor
|
|
25
|
-
hendrerit scelerisque ut libero. Maecenas iaculis efficitur lorem, ac faucibus mi
|
|
26
|
-
imperdiet quis. Cras a consectetur erat. Fusce imperdiet, dolor et pellentesque iaculis,
|
|
27
|
-
ex quam luctus felis, non ultrices enim sem vitae quam. Duis lorem velit, lacinia at
|
|
28
|
-
rhoncus a, tempus vel neque. Vestibulum ante ipsum primis in faucibus orci luctus et
|
|
29
|
-
ultrices posuere cubilia curae; Sed id mauris quam. Nam finibus sapien non lacinia
|
|
30
|
-
ultricies. Integer fermentum tortor at pellentesque faucibus. In venenatis commodo
|
|
31
|
-
placerat. Curabitur commodo tortor libero, vel pellentesque elit luctus sodales. Donec
|
|
32
|
-
mattis tristique nunc ac lacinia. Vestibulum non pulvinar turpis, posuere consequat
|
|
33
|
-
arcu. Fusce ut urna blandit, finibus nisi a, molestie elit. Nulla sed eleifend mi.
|
|
34
|
-
</Text>
|
|
35
|
-
</Box>
|
|
36
|
-
</Dialog>
|
|
37
|
-
</LayerProvider>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import {useCallback, useState} from 'react'
|
|
2
|
-
import {styled} from 'styled-components'
|
|
3
|
-
|
|
4
|
-
import {Box, Button, Card, Flex} from '../../../primitives'
|
|
5
|
-
import {BoundaryElementProvider, PortalProvider} from '../../../utils'
|
|
6
|
-
import {Menu, MenuButton, MenuItem} from '../../menu'
|
|
7
|
-
import {Dialog} from '../dialog'
|
|
8
|
-
|
|
9
|
-
export default function PanesStory() {
|
|
10
|
-
return (
|
|
11
|
-
<Flex height="fill">
|
|
12
|
-
<Pane id="A" />
|
|
13
|
-
<Pane id="B" borderLeft />
|
|
14
|
-
</Flex>
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const PaneRoot = styled(Card)`
|
|
19
|
-
position: relative;
|
|
20
|
-
`
|
|
21
|
-
|
|
22
|
-
const PanePortal = styled.div`
|
|
23
|
-
position: absolute;
|
|
24
|
-
left: 0;
|
|
25
|
-
right: 0;
|
|
26
|
-
top: 0;
|
|
27
|
-
bottom: 0;
|
|
28
|
-
pointer-events: none;
|
|
29
|
-
|
|
30
|
-
& > * {
|
|
31
|
-
pointer-events: auto;
|
|
32
|
-
}
|
|
33
|
-
`
|
|
34
|
-
|
|
35
|
-
function Pane(props: {borderLeft?: boolean; id: string}) {
|
|
36
|
-
const {borderLeft, id} = props
|
|
37
|
-
const [element, setElement] = useState<HTMLDivElement | null>(null)
|
|
38
|
-
const [portalElement, setPortalElement] = useState<HTMLDivElement | null>(null)
|
|
39
|
-
const [dialogOpen, setDialogOpen] = useState(false)
|
|
40
|
-
|
|
41
|
-
const handleClose = useCallback(() => {
|
|
42
|
-
setDialogOpen(false)
|
|
43
|
-
}, [])
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<BoundaryElementProvider element={element}>
|
|
47
|
-
<PortalProvider element={portalElement}>
|
|
48
|
-
<PaneRoot borderLeft={borderLeft} flex={1} ref={setElement}>
|
|
49
|
-
<Box padding={4}>
|
|
50
|
-
<Button onClick={() => setDialogOpen(true)} selected={dialogOpen} text="Open dialog" />
|
|
51
|
-
</Box>
|
|
52
|
-
|
|
53
|
-
<PanePortal ref={setPortalElement} />
|
|
54
|
-
</PaneRoot>
|
|
55
|
-
|
|
56
|
-
{dialogOpen && (
|
|
57
|
-
<Dialog
|
|
58
|
-
header={`Dialog ${id}`}
|
|
59
|
-
id={id}
|
|
60
|
-
onClickOutside={handleClose}
|
|
61
|
-
onClose={handleClose}
|
|
62
|
-
position="absolute"
|
|
63
|
-
>
|
|
64
|
-
<Box padding={4}>
|
|
65
|
-
<MenuButton
|
|
66
|
-
button={<Button text="Open menu" />}
|
|
67
|
-
id={`${id}-menu`}
|
|
68
|
-
menu={
|
|
69
|
-
<Menu>
|
|
70
|
-
<MenuItem text="Item 1" />
|
|
71
|
-
<MenuItem text="Item 2" />
|
|
72
|
-
<MenuItem text="Item 3" />
|
|
73
|
-
</Menu>
|
|
74
|
-
}
|
|
75
|
-
/>
|
|
76
|
-
</Box>
|
|
77
|
-
</Dialog>
|
|
78
|
-
)}
|
|
79
|
-
</PortalProvider>
|
|
80
|
-
</BoundaryElementProvider>
|
|
81
|
-
)
|
|
82
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {ArrowDownIcon, ArrowUpIcon} from '@sanity/icons'
|
|
2
|
-
import {Box, Dialog, LayerProvider, Stack, Text} from '@sanity/ui'
|
|
3
|
-
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
4
|
-
|
|
5
|
-
import {WORKSHOP_DIALOG_POSITION_OPTIONS} from '../../../__workshop__/constants'
|
|
6
|
-
|
|
7
|
-
export default function PositionStory() {
|
|
8
|
-
const open = useBoolean('Open', true, 'Props')
|
|
9
|
-
const position = useSelect('Position', WORKSHOP_DIALOG_POSITION_OPTIONS, 'fixed', 'Props')
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<Box padding={4}>
|
|
13
|
-
<Box style={{padding: 'calc(100vh - 100px) 0'}}>
|
|
14
|
-
<Stack space={3}>
|
|
15
|
-
<Text align="center">
|
|
16
|
-
<ArrowUpIcon />
|
|
17
|
-
</Text>
|
|
18
|
-
<Text align="center">Scrollable</Text>
|
|
19
|
-
<Text align="center">
|
|
20
|
-
<ArrowDownIcon />
|
|
21
|
-
</Text>
|
|
22
|
-
</Stack>
|
|
23
|
-
|
|
24
|
-
<LayerProvider>
|
|
25
|
-
{open && <Dialog header="Position example" id="position-example" position={position} />}
|
|
26
|
-
</LayerProvider>
|
|
27
|
-
</Box>
|
|
28
|
-
</Box>
|
|
29
|
-
)
|
|
30
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {Box, Button, Dialog, LayerProvider, Stack, Text} from '@sanity/ui'
|
|
2
|
-
import {useBoolean, useSelect, useText} from '@sanity/ui-workshop'
|
|
3
|
-
import {useCallback, useRef, useState} from 'react'
|
|
4
|
-
|
|
5
|
-
import {WORKSHOP_WIDTH_OPTIONS} from '../../../__workshop__/constants'
|
|
6
|
-
|
|
7
|
-
export default function PropsStory() {
|
|
8
|
-
const header = useText('Header', 'Props example', 'Props')
|
|
9
|
-
const onClickOutside = useBoolean('Close when click outside', false, 'Props') || false
|
|
10
|
-
const hideCloseButton = useBoolean('Hide close button', false, 'Props') || false
|
|
11
|
-
const width = useSelect('Width', WORKSHOP_WIDTH_OPTIONS, 0, 'Props')
|
|
12
|
-
const [open, setOpen] = useState(false)
|
|
13
|
-
const buttonRef = useRef<HTMLButtonElement | null>(null)
|
|
14
|
-
|
|
15
|
-
const handleClose = useCallback(() => {
|
|
16
|
-
setOpen(false)
|
|
17
|
-
buttonRef.current?.focus()
|
|
18
|
-
}, [])
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<LayerProvider>
|
|
22
|
-
<Box padding={[4, 5, 6]}>
|
|
23
|
-
<Button
|
|
24
|
-
id="open-dialog-button"
|
|
25
|
-
onClick={() => setOpen(true)}
|
|
26
|
-
ref={buttonRef}
|
|
27
|
-
text="Open dialog"
|
|
28
|
-
/>
|
|
29
|
-
|
|
30
|
-
{open && (
|
|
31
|
-
<Dialog
|
|
32
|
-
__unstable_hideCloseButton={hideCloseButton}
|
|
33
|
-
header={header}
|
|
34
|
-
id="dialog"
|
|
35
|
-
onClickOutside={onClickOutside ? handleClose : undefined}
|
|
36
|
-
onClose={handleClose}
|
|
37
|
-
open={open}
|
|
38
|
-
width={width}
|
|
39
|
-
>
|
|
40
|
-
<Box padding={4}>
|
|
41
|
-
<Stack space={4}>
|
|
42
|
-
<Text>
|
|
43
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed et orci vitae diam
|
|
44
|
-
aliquet imperdiet.
|
|
45
|
-
</Text>
|
|
46
|
-
<Button id="button-1" text="Focus test" />
|
|
47
|
-
<Text>
|
|
48
|
-
Sed in hendrerit metus. Sed sapien neque, imperdiet eu justo sed, vestibulum
|
|
49
|
-
mollis dolor.
|
|
50
|
-
</Text>
|
|
51
|
-
<Button id="button-2" text="Focus test" />
|
|
52
|
-
<Text>
|
|
53
|
-
Nulla sit amet ipsum ligula. Duis sit amet velit tempor, ultricies mauris
|
|
54
|
-
dignissim, mollis enim.
|
|
55
|
-
</Text>
|
|
56
|
-
<Button id="button-3" text="Focus test" />
|
|
57
|
-
<Text>Cras quis elit non mauris faucibus molestie non non augue. </Text>
|
|
58
|
-
<Text>
|
|
59
|
-
Proin suscipit gravida sodales. Morbi vel purus molestie, rhoncus augue sit amet,
|
|
60
|
-
auctor justo.
|
|
61
|
-
</Text>
|
|
62
|
-
<Button id="button-4" text="Focus test" />
|
|
63
|
-
<Text>Proin lobortis nunc a tellus condimentum, a ultrices arcu egestas.</Text>
|
|
64
|
-
<Button id="button-5" text="Focus test" />
|
|
65
|
-
<Text>
|
|
66
|
-
Suspendisse augue nibh, euismod sit amet sapien nec, molestie dignissim magna.
|
|
67
|
-
</Text>
|
|
68
|
-
</Stack>
|
|
69
|
-
</Box>
|
|
70
|
-
</Dialog>
|
|
71
|
-
)}
|
|
72
|
-
</Box>
|
|
73
|
-
</LayerProvider>
|
|
74
|
-
)
|
|
75
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {Dialog, DialogProvider} from '@sanity/ui'
|
|
2
|
-
|
|
3
|
-
export default function ProviderStory() {
|
|
4
|
-
return (
|
|
5
|
-
<DialogProvider position="absolute" zOffset={1000}>
|
|
6
|
-
<Dialog header="Outer" id="provider-example">
|
|
7
|
-
<Dialog header="Inner" id="nested-provider-example" />
|
|
8
|
-
</Dialog>
|
|
9
|
-
</DialogProvider>
|
|
10
|
-
)
|
|
11
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import {Box, Button, Dialog, DialogProps, LayerProvider, useLayer} from '@sanity/ui'
|
|
2
|
-
import {ReactNode, useCallback, useEffect, useRef, useState} from 'react'
|
|
3
|
-
|
|
4
|
-
export default function WrappedStory() {
|
|
5
|
-
return (
|
|
6
|
-
<LayerProvider zOffset={100}>
|
|
7
|
-
<Box padding={4}>
|
|
8
|
-
<DialogButton level={0} />
|
|
9
|
-
</Box>
|
|
10
|
-
</LayerProvider>
|
|
11
|
-
)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function DialogButton(props: {level: number}) {
|
|
15
|
-
const {level} = props
|
|
16
|
-
const [open, setOpen] = useState(false)
|
|
17
|
-
|
|
18
|
-
const openRef = useRef(open)
|
|
19
|
-
const buttonRef = useRef<HTMLButtonElement>(null)
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (openRef.current !== open) {
|
|
23
|
-
openRef.current = open
|
|
24
|
-
|
|
25
|
-
if (!open) {
|
|
26
|
-
// focus the button that opened the dialog
|
|
27
|
-
// buttonRef.current?.focus()
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}, [open])
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<>
|
|
34
|
-
<Button onClick={() => setOpen(true)} ref={buttonRef} text={`Open dialog ${level + 1}`} />
|
|
35
|
-
|
|
36
|
-
{open && (
|
|
37
|
-
<WrappedDialog
|
|
38
|
-
header={`WrappedDialog ${level + 1}`}
|
|
39
|
-
id={`wrapped-${level + 1}`}
|
|
40
|
-
onClickOutside={() => setOpen(false)}
|
|
41
|
-
onClose={() => setOpen(false)}
|
|
42
|
-
>
|
|
43
|
-
<Box padding={4}>
|
|
44
|
-
<DialogButton level={level + 1} />
|
|
45
|
-
</Box>
|
|
46
|
-
</WrappedDialog>
|
|
47
|
-
)}
|
|
48
|
-
</>
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function WrappedDialog(props: DialogProps & {children?: ReactNode}) {
|
|
53
|
-
const layer = useLayer()
|
|
54
|
-
const isTopLayer = layer.size === 1
|
|
55
|
-
|
|
56
|
-
const dialogRef = useRef<HTMLDivElement>(null)
|
|
57
|
-
|
|
58
|
-
const [lastFocusedElement, setLastFocusedElement] = useState<HTMLElement | null>(null)
|
|
59
|
-
|
|
60
|
-
const handleContentFocus = useCallback(() => {
|
|
61
|
-
const containsActiveElement = dialogRef.current?.contains(document.activeElement)
|
|
62
|
-
|
|
63
|
-
if (containsActiveElement) {
|
|
64
|
-
setLastFocusedElement(document.activeElement as HTMLElement)
|
|
65
|
-
}
|
|
66
|
-
}, [])
|
|
67
|
-
|
|
68
|
-
// Set focus on the last focused element when the dialog becomes the top layer.
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
if (isTopLayer && lastFocusedElement) {
|
|
71
|
-
lastFocusedElement.focus()
|
|
72
|
-
}
|
|
73
|
-
}, [isTopLayer, lastFocusedElement])
|
|
74
|
-
|
|
75
|
-
return <Dialog {...props} data-size={layer.size} onFocus={handleContentFocus} ref={dialogRef} />
|
|
76
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {defineScope} from '@sanity/ui-workshop'
|
|
2
|
-
import {lazy} from 'react'
|
|
3
|
-
|
|
4
|
-
export default defineScope({
|
|
5
|
-
name: 'components/hotkeys',
|
|
6
|
-
title: 'Hotkeys',
|
|
7
|
-
stories: [
|
|
8
|
-
{
|
|
9
|
-
name: 'plain',
|
|
10
|
-
title: 'Plain',
|
|
11
|
-
component: lazy(() => import('./plain')),
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
})
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import {Button, Flex, Menu, MenuButton, MenuItem, Text} from '@sanity/ui'
|
|
2
|
-
import {forwardRef} from 'react'
|
|
3
|
-
|
|
4
|
-
const CustomLink = forwardRef(function CustomLink(
|
|
5
|
-
props: {req: string} & Omit<React.HTMLProps<HTMLAnchorElement>, 'as' | 'href'>,
|
|
6
|
-
ref: React.ForwardedRef<HTMLAnchorElement>,
|
|
7
|
-
): React.JSX.Element {
|
|
8
|
-
const {children, req, ...restProps} = props
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
// eslint-disable-next-line jsx-a11y/anchor-is-valid
|
|
12
|
-
<a data-required={req} {...restProps} href="#" ref={ref}>
|
|
13
|
-
{children}
|
|
14
|
-
</a>
|
|
15
|
-
)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
export default function AsComponentStory() {
|
|
19
|
-
const props = {href: '#'}
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<Flex align="center" height="fill" justify="center">
|
|
23
|
-
<MenuButton
|
|
24
|
-
button={<Button text="Menu with components" />}
|
|
25
|
-
id="test"
|
|
26
|
-
menu={
|
|
27
|
-
<Menu>
|
|
28
|
-
<MenuItem as={CustomLink} data-as="a" {...props} padding={3}>
|
|
29
|
-
<Text>Component 1</Text>
|
|
30
|
-
</MenuItem>
|
|
31
|
-
<MenuItem as={CustomLink} data-as="a" {...props} padding={3}>
|
|
32
|
-
<Text>Component 2</Text>
|
|
33
|
-
</MenuItem>
|
|
34
|
-
<MenuItem as={CustomLink} data-as="a" {...props} padding={3}>
|
|
35
|
-
<Text>Component 3</Text>
|
|
36
|
-
</MenuItem>
|
|
37
|
-
<MenuItem as={CustomLink} data-as="a" {...props} padding={3}>
|
|
38
|
-
<Text>Component 3</Text>
|
|
39
|
-
</MenuItem>
|
|
40
|
-
</Menu>
|
|
41
|
-
}
|
|
42
|
-
/>
|
|
43
|
-
</Flex>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {UsersIcon} from '@sanity/icons'
|
|
2
|
-
|
|
3
|
-
import {Avatar, Badge, Box, Button, Flex, Text} from '../../../primitives'
|
|
4
|
-
import {Hotkeys} from '../../hotkeys'
|
|
5
|
-
import {Menu} from '../menu'
|
|
6
|
-
import {MenuButton} from '../menuButton'
|
|
7
|
-
import {MenuItem} from '../menuItem'
|
|
8
|
-
|
|
9
|
-
export default function AvatarMenuStory() {
|
|
10
|
-
return (
|
|
11
|
-
<Flex align="center" height="fill" justify="center">
|
|
12
|
-
<MenuButton
|
|
13
|
-
button={<Button icon={UsersIcon} />}
|
|
14
|
-
id="avatar-menu"
|
|
15
|
-
menu={
|
|
16
|
-
<Menu>
|
|
17
|
-
<MenuItem padding={0}>
|
|
18
|
-
<Flex align="center" padding={1}>
|
|
19
|
-
<Box flex="none">
|
|
20
|
-
<Avatar color="purple" initials="JS" />
|
|
21
|
-
</Box>
|
|
22
|
-
<Box flex={1} padding={2}>
|
|
23
|
-
<Text size={1}>Jane Smith</Text>
|
|
24
|
-
</Box>
|
|
25
|
-
<Box padding={1}>
|
|
26
|
-
<Badge>Me</Badge>
|
|
27
|
-
</Box>
|
|
28
|
-
<Box padding={1}>
|
|
29
|
-
<Hotkeys keys={['Cmd', '1']} />
|
|
30
|
-
</Box>
|
|
31
|
-
</Flex>
|
|
32
|
-
</MenuItem>
|
|
33
|
-
<MenuItem padding={0}>
|
|
34
|
-
<Flex align="center" padding={1}>
|
|
35
|
-
<Box flex="none">
|
|
36
|
-
<Avatar color="magenta" initials="JS" />
|
|
37
|
-
</Box>
|
|
38
|
-
<Box flex={1} padding={2}>
|
|
39
|
-
<Text size={1}>John Doe</Text>
|
|
40
|
-
</Box>
|
|
41
|
-
<Box padding={1}>
|
|
42
|
-
<Hotkeys keys={['Cmd', '2']} />
|
|
43
|
-
</Box>
|
|
44
|
-
</Flex>
|
|
45
|
-
</MenuItem>
|
|
46
|
-
</Menu>
|
|
47
|
-
}
|
|
48
|
-
/>
|
|
49
|
-
</Flex>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {AddIcon} from '@sanity/icons'
|
|
2
|
-
import {Box, Button, Menu, MenuButton, MenuButtonProps, MenuItem, Stack} from '@sanity/ui'
|
|
3
|
-
import {useRef} from 'react'
|
|
4
|
-
|
|
5
|
-
const POPOVER_PROPS: MenuButtonProps['popover'] = {
|
|
6
|
-
constrainSize: true,
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export default function ClosableMenuButtonStory() {
|
|
10
|
-
const ref = useRef<HTMLButtonElement | null>(null)
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<Box padding={[4, 5, 6]}>
|
|
14
|
-
<Stack>
|
|
15
|
-
<MenuButton
|
|
16
|
-
button={<Button text="Open" />}
|
|
17
|
-
id="closable-example"
|
|
18
|
-
menu={
|
|
19
|
-
<Menu padding={0} space={0}>
|
|
20
|
-
<Stack padding={1} space={1}>
|
|
21
|
-
<MenuItem text="Item 1" />
|
|
22
|
-
<MenuItem text="Item 2" />
|
|
23
|
-
<MenuItem text="Item 3" />
|
|
24
|
-
<MenuItem text="Item 4" />
|
|
25
|
-
</Stack>
|
|
26
|
-
<Stack padding={1} style={{borderTop: '1px solid var(--card-border-color)'}}>
|
|
27
|
-
<Button
|
|
28
|
-
icon={AddIcon}
|
|
29
|
-
onClick={() => {
|
|
30
|
-
ref.current?.click()
|
|
31
|
-
ref.current?.focus()
|
|
32
|
-
}}
|
|
33
|
-
mode="bleed"
|
|
34
|
-
text="Add item"
|
|
35
|
-
tone="primary"
|
|
36
|
-
/>
|
|
37
|
-
</Stack>
|
|
38
|
-
</Menu>
|
|
39
|
-
}
|
|
40
|
-
popover={POPOVER_PROPS}
|
|
41
|
-
ref={ref}
|
|
42
|
-
/>
|
|
43
|
-
</Stack>
|
|
44
|
-
</Box>
|
|
45
|
-
)
|
|
46
|
-
}
|