@sanity/ui 3.3.0 → 3.3.2
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 +12 -0
- package/dist/_visual-editing.d.mts +2 -1126
- package/dist/_visual-editing.d.ts +2 -1126
- package/dist/_visual-editing.js +3 -31
- package/dist/_visual-editing.mjs +2 -31
- package/dist/index.d.mts +555 -2769
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +555 -2769
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2982 -1934
- package/dist/index.mjs +2950 -1903
- package/dist/index.mjs.map +1 -1
- package/dist/refractor.js +16 -0
- package/dist/refractor.mjs +21 -0
- package/dist/refractor.mjs.map +1 -0
- package/dist/tabList.js +3804 -0
- package/dist/tabList.mjs +3355 -0
- package/dist/tabList.mjs.map +1 -0
- package/dist/theme.d.mts +927 -1227
- package/dist/theme.d.mts.map +1 -0
- package/dist/theme.d.ts +927 -1227
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +3 -4127
- package/dist/theme.mjs +2 -4127
- package/dist/theme2.d.mts +2 -0
- package/dist/theme2.d.ts +2 -0
- package/dist/theme2.js +4104 -0
- package/dist/theme2.mjs +3851 -0
- package/dist/theme2.mjs.map +1 -0
- package/dist/useTheme.d.mts +1451 -0
- package/dist/useTheme.d.mts.map +1 -0
- package/dist/useTheme.d.ts +1451 -0
- package/dist/useTheme.d.ts.map +1 -0
- package/exports/_visual-editing.ts +1 -0
- package/package.json +52 -168
- package/src/core/_compat.ts +30 -0
- package/src/core/components/autocomplete/autocomplete.tsx +8 -0
- package/src/core/components/autocomplete/autocompleteOption.tsx +1 -0
- package/src/core/components/breadcrumbs/breadcrumbs.test.tsx +8 -5
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +3 -0
- package/src/core/components/dialog/dialog.tsx +5 -2
- package/src/core/components/hotkeys/hotkeys.test.tsx +10 -5
- package/src/core/components/hotkeys/hotkeys.tsx +2 -0
- package/src/core/components/menu/menu.spacing.test.tsx +12 -7
- package/src/core/components/menu/menu.test.tsx +9 -6
- package/src/core/components/menu/menu.tsx +4 -2
- package/src/core/components/menu/menuButton.tsx +8 -0
- package/src/core/components/menu/menuDivider.ts +1 -0
- package/src/core/components/menu/menuGroup.spacing.test.tsx +9 -6
- package/src/core/components/menu/menuGroup.tsx +6 -2
- package/src/core/components/menu/menuItem.spacing.test.tsx +8 -5
- package/src/core/components/menu/menuItem.tsx +4 -0
- package/src/core/components/menu/useMenuController.ts +2 -0
- package/src/core/components/skeleton/skeleton.tsx +1 -0
- package/src/core/components/tab/tab.tsx +1 -0
- package/src/core/components/tab/tabList.test.tsx +7 -5
- package/src/core/components/tab/tabList.tsx +1 -0
- package/src/core/components/toast/toast.test.tsx +9 -4
- package/src/core/components/toast/toast.tsx +1 -0
- package/src/core/components/toast/toastLayer.tsx +1 -0
- package/src/core/components/tree/tree.test.tsx +10 -5
- package/src/core/components/tree/tree.tsx +2 -0
- package/src/core/components/tree/treeGroup.tsx +1 -0
- package/src/core/components/tree/treeItem.test.tsx +10 -5
- package/src/core/components/tree/treeItem.tsx +1 -0
- package/src/core/hooks/index.ts +1 -0
- 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 +9 -8
- 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 +2 -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 +3 -1
- package/src/core/primitives/box/box.test.tsx +18 -5
- package/src/core/primitives/box/box.tsx +9 -1
- package/src/core/primitives/button/button.test.tsx +10 -6
- package/src/core/primitives/button/button.tsx +4 -0
- package/src/core/primitives/button/styles.ts +1 -0
- package/src/core/primitives/card/card.tsx +2 -5
- package/src/core/primitives/card/types.ts +1 -0
- package/src/core/primitives/code/code.tsx +1 -0
- package/src/core/primitives/code/refractor.tsx +2 -0
- package/src/core/primitives/container/container.tsx +1 -0
- package/src/core/primitives/flex/flex.tsx +2 -3
- package/src/core/primitives/grid/grid.test.tsx +11 -5
- package/src/core/primitives/grid/grid.tsx +3 -0
- package/src/core/primitives/heading/heading.tsx +1 -0
- package/src/core/primitives/inline/inline.test.tsx +9 -5
- package/src/core/primitives/inline/inline.tsx +3 -0
- package/src/core/primitives/kbd/kbd.tsx +5 -1
- package/src/core/primitives/label/label.tsx +1 -0
- package/src/core/primitives/popover/popover.tsx +5 -4
- package/src/core/primitives/popover/popoverCard.tsx +1 -0
- package/src/core/primitives/popover/types.ts +0 -1
- package/src/core/primitives/select/select.test.tsx +9 -5
- package/src/core/primitives/select/select.tsx +1 -0
- package/src/core/primitives/stack/stack.test.tsx +9 -5
- package/src/core/primitives/stack/stack.tsx +2 -0
- package/src/core/primitives/stack/styles.ts +1 -0
- package/src/core/primitives/text/text.tsx +1 -0
- package/src/core/primitives/textInput/textInput.test.tsx +9 -5
- package/src/core/primitives/textInput/textInput.tsx +3 -0
- package/src/core/primitives/tooltip/tooltip.test.tsx +82 -49
- package/src/core/primitives/tooltip/tooltip.tsx +3 -1
- 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 +1 -0
- 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 +8 -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 +6 -1
- 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 +18 -0
- package/dist/_chunks-cjs/_visual-editing.js +0 -5899
- package/dist/_chunks-cjs/_visual-editing.js.map +0 -1
- package/dist/_chunks-cjs/refractor.js +0 -23
- package/dist/_chunks-cjs/refractor.js.map +0 -1
- package/dist/_chunks-es/_visual-editing.mjs +0 -5905
- package/dist/_chunks-es/_visual-editing.mjs.map +0 -1
- package/dist/_chunks-es/refractor.mjs +0 -26
- package/dist/_chunks-es/refractor.mjs.map +0 -1
- package/dist/_visual-editing.js.map +0 -1
- package/dist/_visual-editing.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/theme.js.map +0 -1
- package/dist/theme.mjs.map +0 -1
- 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__/asComponent.tsx +0 -31
- package/src/core/primitives/box/__workshop__/index.ts +0 -24
- 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,294 +0,0 @@
|
|
|
1
|
-
import {CloseIcon, SearchIcon} from '@sanity/icons'
|
|
2
|
-
import {
|
|
3
|
-
Autocomplete,
|
|
4
|
-
BaseAutocompleteOption,
|
|
5
|
-
Box,
|
|
6
|
-
Button,
|
|
7
|
-
Card,
|
|
8
|
-
Flex,
|
|
9
|
-
Heading,
|
|
10
|
-
Label,
|
|
11
|
-
Layer,
|
|
12
|
-
Portal,
|
|
13
|
-
PortalProvider,
|
|
14
|
-
Skeleton,
|
|
15
|
-
Stack,
|
|
16
|
-
Text,
|
|
17
|
-
TextSkeleton,
|
|
18
|
-
useToast,
|
|
19
|
-
} from '@sanity/ui'
|
|
20
|
-
import {useBoolean} from '@sanity/ui-workshop'
|
|
21
|
-
import {useCallback, useEffect, useMemo, useRef, useState} from 'react'
|
|
22
|
-
|
|
23
|
-
import {countriesStore} from '../__mocks__/apiStore'
|
|
24
|
-
|
|
25
|
-
export default function Fullscreen() {
|
|
26
|
-
const error = useBoolean('Error', false, 'Props')
|
|
27
|
-
|
|
28
|
-
const {push: pushToast} = useToast()
|
|
29
|
-
const [portalElement, setPortalElement] = useState<HTMLDivElement | null>(null)
|
|
30
|
-
const [closeSearchButtonElement, setCloseSearchButtonElement] =
|
|
31
|
-
useState<HTMLButtonElement | null>(null)
|
|
32
|
-
const [options, setOptions] = useState<BaseAutocompleteOption[]>([])
|
|
33
|
-
const searchRef = useRef<{cancel: () => void} | null>(null)
|
|
34
|
-
const fetchRef = useRef<{cancel: () => void} | null>(null)
|
|
35
|
-
const openSearchButtonElementRef = useRef<HTMLButtonElement | null>(null)
|
|
36
|
-
const [loading, setLoading] = useState(false)
|
|
37
|
-
const [loadingCurrentRef, setLoadingCurrentRef] = useState(false)
|
|
38
|
-
const [open, setOpen] = useState(false)
|
|
39
|
-
const [optionTitle, setOptionTitle] = useState<string | null>(null)
|
|
40
|
-
const inputRef = useRef<HTMLInputElement>(null)
|
|
41
|
-
const [query, setQuery] = useState<string | null>(null)
|
|
42
|
-
const [value, setValue] = useState<string>('')
|
|
43
|
-
|
|
44
|
-
const relatedElements = useMemo(
|
|
45
|
-
() => [closeSearchButtonElement].filter(Boolean) as HTMLElement[],
|
|
46
|
-
[closeSearchButtonElement],
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
const search = useCallback((query: string | null) => {
|
|
50
|
-
if (searchRef.current) searchRef.current.cancel()
|
|
51
|
-
searchRef.current = countriesStore.search(query || '', setOptions, setLoading)
|
|
52
|
-
}, [])
|
|
53
|
-
|
|
54
|
-
const filterOption = useCallback(() => true, [])
|
|
55
|
-
|
|
56
|
-
const handleClose = useCallback(() => setOpen(false), [])
|
|
57
|
-
|
|
58
|
-
const handleQueryChange = useCallback(
|
|
59
|
-
(query: string | null) => {
|
|
60
|
-
if (query !== null) search(query)
|
|
61
|
-
setQuery(query)
|
|
62
|
-
},
|
|
63
|
-
[search],
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
const handleOpen = useCallback(() => {
|
|
67
|
-
setValue('')
|
|
68
|
-
setOpen(true)
|
|
69
|
-
}, [])
|
|
70
|
-
|
|
71
|
-
const handleSelect = useCallback(
|
|
72
|
-
(v: string) => {
|
|
73
|
-
setOpen(false)
|
|
74
|
-
setValue(v)
|
|
75
|
-
pushToast({status: 'info', title: `Selected “${v}”`})
|
|
76
|
-
},
|
|
77
|
-
[pushToast],
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
const renderOption = useCallback((option: BaseAutocompleteOption) => {
|
|
81
|
-
return <AsyncOption documentId={option.value} />
|
|
82
|
-
}, [])
|
|
83
|
-
|
|
84
|
-
const renderPopover = useCallback(
|
|
85
|
-
(
|
|
86
|
-
props: {
|
|
87
|
-
content: React.ReactNode
|
|
88
|
-
hidden: boolean
|
|
89
|
-
onMouseEnter: () => void
|
|
90
|
-
onMouseLeave: () => void
|
|
91
|
-
},
|
|
92
|
-
ref: React.Ref<HTMLDivElement>,
|
|
93
|
-
) => {
|
|
94
|
-
if (!props.hidden && error) {
|
|
95
|
-
return (
|
|
96
|
-
<Portal>
|
|
97
|
-
<Card
|
|
98
|
-
onMouseEnter={props.onMouseEnter}
|
|
99
|
-
onMouseLeave={props.onMouseLeave}
|
|
100
|
-
padding={4}
|
|
101
|
-
style={{position: 'absolute', inset: '0 0 0 0'}}
|
|
102
|
-
tone="critical"
|
|
103
|
-
>
|
|
104
|
-
<Flex align="center" height="fill" justify="center">
|
|
105
|
-
<Text align="center" muted>
|
|
106
|
-
Something went wrong while searching
|
|
107
|
-
</Text>
|
|
108
|
-
</Flex>
|
|
109
|
-
</Card>
|
|
110
|
-
</Portal>
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (!props.hidden && query && !loading && options.length === 0) {
|
|
115
|
-
return (
|
|
116
|
-
<Portal>
|
|
117
|
-
<Card
|
|
118
|
-
onMouseEnter={props.onMouseEnter}
|
|
119
|
-
onMouseLeave={props.onMouseLeave}
|
|
120
|
-
padding={4}
|
|
121
|
-
style={{position: 'absolute', inset: '0 0 0 0'}}
|
|
122
|
-
>
|
|
123
|
-
<Flex align="center" height="fill" justify="center">
|
|
124
|
-
<Text align="center" muted>
|
|
125
|
-
No results for <strong>‘{query}’</strong>
|
|
126
|
-
</Text>
|
|
127
|
-
</Flex>
|
|
128
|
-
</Card>
|
|
129
|
-
</Portal>
|
|
130
|
-
)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return (
|
|
134
|
-
<Portal>
|
|
135
|
-
<Card
|
|
136
|
-
hidden={props.hidden}
|
|
137
|
-
onMouseEnter={props.onMouseEnter}
|
|
138
|
-
onMouseLeave={props.onMouseLeave}
|
|
139
|
-
ref={ref}
|
|
140
|
-
>
|
|
141
|
-
{props.content}
|
|
142
|
-
</Card>
|
|
143
|
-
</Portal>
|
|
144
|
-
)
|
|
145
|
-
},
|
|
146
|
-
[error, loading, options, query],
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
const renderValue = useCallback(() => {
|
|
150
|
-
if (loadingCurrentRef) {
|
|
151
|
-
return 'Loading…'
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return optionTitle || ''
|
|
155
|
-
}, [loadingCurrentRef, optionTitle])
|
|
156
|
-
|
|
157
|
-
useEffect(() => {
|
|
158
|
-
if (open) inputRef.current?.focus()
|
|
159
|
-
if (!open) openSearchButtonElementRef.current?.focus()
|
|
160
|
-
}, [open])
|
|
161
|
-
|
|
162
|
-
useEffect(() => {
|
|
163
|
-
if (fetchRef.current) fetchRef.current.cancel()
|
|
164
|
-
|
|
165
|
-
if (value) {
|
|
166
|
-
fetchRef.current = countriesStore.fetchDocument(
|
|
167
|
-
value,
|
|
168
|
-
(data) => setOptionTitle(data?.title || null),
|
|
169
|
-
setLoadingCurrentRef,
|
|
170
|
-
)
|
|
171
|
-
} else {
|
|
172
|
-
setOptionTitle(null)
|
|
173
|
-
setLoadingCurrentRef(false)
|
|
174
|
-
}
|
|
175
|
-
}, [value])
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<Card style={{display: 'flex', flexDirection: 'column', minHeight: '100%'}} tone="transparent">
|
|
179
|
-
<PortalProvider element={portalElement}>
|
|
180
|
-
<Flex direction="column" flex={1} height="fill">
|
|
181
|
-
<Card hidden={open} padding={2}>
|
|
182
|
-
<Flex align="center">
|
|
183
|
-
<Box flex={1} />
|
|
184
|
-
<Button
|
|
185
|
-
aria-label="Open search"
|
|
186
|
-
icon={SearchIcon}
|
|
187
|
-
mode="ghost"
|
|
188
|
-
onClick={handleOpen}
|
|
189
|
-
ref={openSearchButtonElementRef}
|
|
190
|
-
/>
|
|
191
|
-
</Flex>
|
|
192
|
-
</Card>
|
|
193
|
-
<Layer hidden={!open} style={{position: 'sticky', top: 0}}>
|
|
194
|
-
<Card padding={2} shadow={1}>
|
|
195
|
-
<Autocomplete
|
|
196
|
-
filterOption={filterOption}
|
|
197
|
-
icon={SearchIcon}
|
|
198
|
-
id="fullsceen-example"
|
|
199
|
-
listBox={{padding: 2}}
|
|
200
|
-
loading={loading}
|
|
201
|
-
onQueryChange={handleQueryChange}
|
|
202
|
-
onSelect={handleSelect}
|
|
203
|
-
options={options}
|
|
204
|
-
placeholder="Search"
|
|
205
|
-
radius={2}
|
|
206
|
-
ref={inputRef}
|
|
207
|
-
relatedElements={relatedElements}
|
|
208
|
-
renderOption={renderOption}
|
|
209
|
-
renderPopover={renderPopover}
|
|
210
|
-
renderValue={renderValue}
|
|
211
|
-
suffix={
|
|
212
|
-
<Box padding={1}>
|
|
213
|
-
<Button
|
|
214
|
-
aria-label="Close search"
|
|
215
|
-
icon={CloseIcon}
|
|
216
|
-
onClick={handleClose}
|
|
217
|
-
padding={2}
|
|
218
|
-
mode="bleed"
|
|
219
|
-
ref={setCloseSearchButtonElement}
|
|
220
|
-
/>
|
|
221
|
-
</Box>
|
|
222
|
-
}
|
|
223
|
-
value={value}
|
|
224
|
-
/>
|
|
225
|
-
</Card>
|
|
226
|
-
</Layer>
|
|
227
|
-
<Card flex={1} hidden={!open} ref={setPortalElement} style={{position: 'relative'}} />
|
|
228
|
-
<Box flex={1} hidden={open} padding={4}>
|
|
229
|
-
<Heading>Welcome to this app</Heading>
|
|
230
|
-
</Box>
|
|
231
|
-
</Flex>
|
|
232
|
-
</PortalProvider>
|
|
233
|
-
</Card>
|
|
234
|
-
)
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function AsyncOption(props: {
|
|
238
|
-
documentId: string
|
|
239
|
-
disabled?: boolean
|
|
240
|
-
selected?: boolean
|
|
241
|
-
tabIndex?: number
|
|
242
|
-
}) {
|
|
243
|
-
const {documentId, disabled, selected, tabIndex} = props
|
|
244
|
-
const [data, setData] = useState<{code: string; title: string} | null>(null)
|
|
245
|
-
const [loading, setLoading] = useState(false)
|
|
246
|
-
const ref = useRef<{cancel: () => void} | null>(null)
|
|
247
|
-
|
|
248
|
-
useEffect(() => {
|
|
249
|
-
if (ref.current) ref.current.cancel()
|
|
250
|
-
ref.current = countriesStore.fetchDocument(documentId, setData, setLoading)
|
|
251
|
-
}, [documentId])
|
|
252
|
-
|
|
253
|
-
return (
|
|
254
|
-
<Card
|
|
255
|
-
aria-label={data?.title}
|
|
256
|
-
data-as="a"
|
|
257
|
-
disabled={disabled}
|
|
258
|
-
padding={2}
|
|
259
|
-
radius={2}
|
|
260
|
-
selected={selected}
|
|
261
|
-
style={{lineHeight: 0}}
|
|
262
|
-
tabIndex={tabIndex}
|
|
263
|
-
>
|
|
264
|
-
<Flex align="center">
|
|
265
|
-
<Skeleton radius={2} style={{width: 35, height: 35}} />
|
|
266
|
-
<Box flex={1} marginLeft={3}>
|
|
267
|
-
<Stack space={2}>
|
|
268
|
-
{loading && (
|
|
269
|
-
<>
|
|
270
|
-
<TextSkeleton style={{maxWidth: 200}} />
|
|
271
|
-
<TextSkeleton size={1} style={{maxWidth: 120}} />
|
|
272
|
-
</>
|
|
273
|
-
)}
|
|
274
|
-
{!loading && (
|
|
275
|
-
<>
|
|
276
|
-
<Text muted={!data} textOverflow="ellipsis">
|
|
277
|
-
{data ? data.title : <>Untitled</>}
|
|
278
|
-
</Text>
|
|
279
|
-
<Text muted size={1}>
|
|
280
|
-
{data?.code}
|
|
281
|
-
</Text>
|
|
282
|
-
</>
|
|
283
|
-
)}
|
|
284
|
-
</Stack>
|
|
285
|
-
</Box>
|
|
286
|
-
<Box paddingX={2}>
|
|
287
|
-
<Label muted size={0}>
|
|
288
|
-
Country
|
|
289
|
-
</Label>
|
|
290
|
-
</Box>
|
|
291
|
-
</Flex>
|
|
292
|
-
</Card>
|
|
293
|
-
)
|
|
294
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {defineScope} from '@sanity/ui-workshop'
|
|
2
|
-
import {lazy} from 'react'
|
|
3
|
-
|
|
4
|
-
export default defineScope({
|
|
5
|
-
name: 'components/autocomplete',
|
|
6
|
-
title: 'Autocomplete',
|
|
7
|
-
stories: [
|
|
8
|
-
{
|
|
9
|
-
name: 'example',
|
|
10
|
-
title: 'Example',
|
|
11
|
-
component: lazy(() => import('./example')),
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
name: 'custom',
|
|
15
|
-
title: 'Custom',
|
|
16
|
-
component: lazy(() => import('./custom')),
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: 'async',
|
|
20
|
-
title: 'Async',
|
|
21
|
-
component: lazy(() => import('./async')),
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: 'constrained-height',
|
|
25
|
-
title: 'Constrained height',
|
|
26
|
-
component: lazy(() => import('./constrainedHeight')),
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: 'focus-and-blur',
|
|
30
|
-
title: 'Focus and blur',
|
|
31
|
-
component: lazy(() => import('./focusAndBlur')),
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: 'fullscreen',
|
|
35
|
-
title: 'Fullscreen',
|
|
36
|
-
component: lazy(() => import('./fullscreen')),
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
})
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import {Breadcrumbs, Flex, Text} from '@sanity/ui'
|
|
2
|
-
import {useSelect} from '@sanity/ui-workshop'
|
|
3
|
-
|
|
4
|
-
const BREADCRUMBS_MAX_LENGTH_OPTIONS = {
|
|
5
|
-
'(none)': 0,
|
|
6
|
-
'1': 1,
|
|
7
|
-
'2': 2,
|
|
8
|
-
'3': 3,
|
|
9
|
-
'4': 4,
|
|
10
|
-
'5': 5,
|
|
11
|
-
'6': 6,
|
|
12
|
-
'7': 7,
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default function Example() {
|
|
16
|
-
const maxLength =
|
|
17
|
-
useSelect('Max. length', BREADCRUMBS_MAX_LENGTH_OPTIONS, 0, 'Props') || undefined
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<Flex align="center" height="fill" justify="center">
|
|
21
|
-
<Breadcrumbs
|
|
22
|
-
maxLength={maxLength}
|
|
23
|
-
separator={
|
|
24
|
-
<Text muted size={1}>
|
|
25
|
-
/
|
|
26
|
-
</Text>
|
|
27
|
-
}
|
|
28
|
-
space={2}
|
|
29
|
-
>
|
|
30
|
-
<Text size={1}>
|
|
31
|
-
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
32
|
-
<a href="#">Root</a>
|
|
33
|
-
</Text>
|
|
34
|
-
<Text size={1}>
|
|
35
|
-
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
36
|
-
<a href="#">Category A</a>
|
|
37
|
-
</Text>
|
|
38
|
-
<Text size={1}>
|
|
39
|
-
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
40
|
-
<a href="#">Category B</a>
|
|
41
|
-
</Text>
|
|
42
|
-
<Text size={1}>
|
|
43
|
-
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
44
|
-
<a href="#">Category C</a>
|
|
45
|
-
</Text>
|
|
46
|
-
<Text size={1}>
|
|
47
|
-
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
48
|
-
<a href="#">Category D</a>
|
|
49
|
-
</Text>
|
|
50
|
-
<Text size={1}>
|
|
51
|
-
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
52
|
-
<a href="#">Category E</a>
|
|
53
|
-
</Text>
|
|
54
|
-
<Text size={1}>
|
|
55
|
-
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
56
|
-
<a href="#">Category F</a>
|
|
57
|
-
</Text>
|
|
58
|
-
<Text size={1}>Item</Text>
|
|
59
|
-
</Breadcrumbs>
|
|
60
|
-
</Flex>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {defineScope} from '@sanity/ui-workshop'
|
|
2
|
-
import {lazy} from 'react'
|
|
3
|
-
|
|
4
|
-
export default defineScope({
|
|
5
|
-
name: 'components/breadcrumbs',
|
|
6
|
-
title: 'Breadcrumbs',
|
|
7
|
-
stories: [
|
|
8
|
-
{
|
|
9
|
-
name: 'example',
|
|
10
|
-
title: 'Example',
|
|
11
|
-
component: lazy(() => import('./example')),
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
})
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import {useState} from 'react'
|
|
2
|
-
|
|
3
|
-
import {Button, Flex, Stack, Text} from '../../../primitives'
|
|
4
|
-
import {Layer, LayerProvider} from '../../../utils'
|
|
5
|
-
import {Menu, MenuButton, MenuItem} from '../../menu'
|
|
6
|
-
import {Dialog} from '../dialog'
|
|
7
|
-
|
|
8
|
-
export default function LayeringFocusStory() {
|
|
9
|
-
const [firstDialogOpen, setFirstDialogOpen] = useState<boolean>(false)
|
|
10
|
-
const [secondDialogOpen, setSecondDialogOpen] = useState<boolean>(false)
|
|
11
|
-
const [thirdDialogOpen, setThirdDialogOpen] = useState<boolean>(false)
|
|
12
|
-
const [fourthDialogOpen, setFourthDialogOpen] = useState<boolean>(false)
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<LayerProvider>
|
|
16
|
-
<Flex align="center" height="fill" justify="center">
|
|
17
|
-
<Layer onActivate={({activeElement}) => activeElement?.focus()}>
|
|
18
|
-
<Button
|
|
19
|
-
text="Open dialog 1"
|
|
20
|
-
onClick={() => setFirstDialogOpen(true)}
|
|
21
|
-
id="open-dialog-1-button"
|
|
22
|
-
/>
|
|
23
|
-
|
|
24
|
-
{firstDialogOpen && (
|
|
25
|
-
<Dialog
|
|
26
|
-
header="Dialog 1"
|
|
27
|
-
id="1"
|
|
28
|
-
onActivate={({activeElement}) => activeElement?.focus()}
|
|
29
|
-
onClose={() => setFirstDialogOpen(false)}
|
|
30
|
-
>
|
|
31
|
-
<Stack space={2} padding={3}>
|
|
32
|
-
<Button
|
|
33
|
-
mode="ghost"
|
|
34
|
-
text="Open dialog 2"
|
|
35
|
-
onClick={() => setSecondDialogOpen(true)}
|
|
36
|
-
id="open-dialog-2-button-1"
|
|
37
|
-
/>
|
|
38
|
-
<Button
|
|
39
|
-
mode="ghost"
|
|
40
|
-
text="Open dialog 2"
|
|
41
|
-
onClick={() => setSecondDialogOpen(true)}
|
|
42
|
-
id="open-dialog-2-button-2"
|
|
43
|
-
/>
|
|
44
|
-
<Button
|
|
45
|
-
mode="ghost"
|
|
46
|
-
text="Open dialog 2"
|
|
47
|
-
onClick={() => setSecondDialogOpen(true)}
|
|
48
|
-
id="open-dialog-2-button-3"
|
|
49
|
-
/>
|
|
50
|
-
</Stack>
|
|
51
|
-
|
|
52
|
-
{secondDialogOpen && (
|
|
53
|
-
<Dialog
|
|
54
|
-
header="Dialog 2"
|
|
55
|
-
id="2"
|
|
56
|
-
onActivate={({activeElement}) => activeElement?.focus()}
|
|
57
|
-
onClose={() => setSecondDialogOpen(false)}
|
|
58
|
-
>
|
|
59
|
-
<Stack space={2} padding={3}>
|
|
60
|
-
<Button
|
|
61
|
-
mode="ghost"
|
|
62
|
-
text="Open dialog 3"
|
|
63
|
-
onClick={() => setThirdDialogOpen(true)}
|
|
64
|
-
id="open-dialog-3-button-1"
|
|
65
|
-
/>
|
|
66
|
-
<Button
|
|
67
|
-
mode="ghost"
|
|
68
|
-
text="Open dialog 3"
|
|
69
|
-
onClick={() => setThirdDialogOpen(true)}
|
|
70
|
-
id="open-dialog-3-button-2"
|
|
71
|
-
/>
|
|
72
|
-
<Button
|
|
73
|
-
mode="ghost"
|
|
74
|
-
text="Open dialog 3"
|
|
75
|
-
onClick={() => setThirdDialogOpen(true)}
|
|
76
|
-
id="open-dialog-3-button-3"
|
|
77
|
-
/>
|
|
78
|
-
</Stack>
|
|
79
|
-
|
|
80
|
-
{thirdDialogOpen && (
|
|
81
|
-
<Dialog
|
|
82
|
-
header="Dialog 3"
|
|
83
|
-
id="3"
|
|
84
|
-
onActivate={({activeElement}) => activeElement?.focus()}
|
|
85
|
-
onClose={() => setThirdDialogOpen(false)}
|
|
86
|
-
>
|
|
87
|
-
<Stack space={2} padding={3}>
|
|
88
|
-
<MenuButton
|
|
89
|
-
id="menu"
|
|
90
|
-
button={
|
|
91
|
-
<Button mode="ghost" text="Open menu" id="open-dialog-4-menu-button" />
|
|
92
|
-
}
|
|
93
|
-
menu={
|
|
94
|
-
<Menu>
|
|
95
|
-
<MenuItem
|
|
96
|
-
text="Open dialog 4"
|
|
97
|
-
onClick={() => setFourthDialogOpen(true)}
|
|
98
|
-
/>
|
|
99
|
-
<MenuItem
|
|
100
|
-
text="Open dialog 4"
|
|
101
|
-
onClick={() => setFourthDialogOpen(true)}
|
|
102
|
-
/>
|
|
103
|
-
<MenuItem
|
|
104
|
-
text="Open dialog 4"
|
|
105
|
-
onClick={() => setFourthDialogOpen(true)}
|
|
106
|
-
/>
|
|
107
|
-
</Menu>
|
|
108
|
-
}
|
|
109
|
-
/>
|
|
110
|
-
</Stack>
|
|
111
|
-
|
|
112
|
-
{fourthDialogOpen && (
|
|
113
|
-
<Dialog
|
|
114
|
-
header="Dialog 4"
|
|
115
|
-
id="4"
|
|
116
|
-
onActivate={({activeElement}) => activeElement?.focus()}
|
|
117
|
-
onClose={() => setFourthDialogOpen(false)}
|
|
118
|
-
>
|
|
119
|
-
<Stack space={2} padding={3}>
|
|
120
|
-
<Text>👋</Text>
|
|
121
|
-
</Stack>
|
|
122
|
-
</Dialog>
|
|
123
|
-
)}
|
|
124
|
-
</Dialog>
|
|
125
|
-
)}
|
|
126
|
-
</Dialog>
|
|
127
|
-
)}
|
|
128
|
-
</Dialog>
|
|
129
|
-
)}
|
|
130
|
-
</Layer>
|
|
131
|
-
</Flex>
|
|
132
|
-
</LayerProvider>
|
|
133
|
-
)
|
|
134
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import {Box, Button, Dialog, Text} from '@sanity/ui'
|
|
2
|
-
import {useAction, useBoolean} from '@sanity/ui-workshop'
|
|
3
|
-
|
|
4
|
-
export default function AutoFocusStory() {
|
|
5
|
-
const autoFocus = useBoolean('Auto-focus', true, 'Props')
|
|
6
|
-
const open = useBoolean('Open', false, 'Props')
|
|
7
|
-
const handleClose = useAction('onClose')
|
|
8
|
-
|
|
9
|
-
if (!open) {
|
|
10
|
-
return (
|
|
11
|
-
<Box padding={4}>
|
|
12
|
-
<Text muted>Use knobs to open the dialog</Text>
|
|
13
|
-
</Box>
|
|
14
|
-
)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<Dialog
|
|
19
|
-
__unstable_autoFocus={autoFocus}
|
|
20
|
-
header="Auto-focus example"
|
|
21
|
-
id="auto-focus-example"
|
|
22
|
-
onClose={handleClose}
|
|
23
|
-
>
|
|
24
|
-
<Box padding={4}>
|
|
25
|
-
<Button text="Focusable button" />
|
|
26
|
-
</Box>
|
|
27
|
-
</Dialog>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {defineScope} from '@sanity/ui-workshop'
|
|
2
|
-
import {lazy} from 'react'
|
|
3
|
-
|
|
4
|
-
export default defineScope({
|
|
5
|
-
name: 'components/dialog',
|
|
6
|
-
title: 'Dialog',
|
|
7
|
-
stories: [
|
|
8
|
-
{name: 'props', title: 'Props', component: lazy(() => import('./props'))},
|
|
9
|
-
{name: 'nested', title: 'Nested', component: lazy(() => import('./nested'))},
|
|
10
|
-
{name: 'on-scroll', title: 'On scroll', component: lazy(() => import('./onScroll'))},
|
|
11
|
-
{name: 'layering', title: 'Layering', component: lazy(() => import('./layering'))},
|
|
12
|
-
{name: 'position', title: 'Position', component: lazy(() => import('./position'))},
|
|
13
|
-
{name: 'provider', title: 'Provider', component: lazy(() => import('./provider'))},
|
|
14
|
-
{name: 'auto-focus', title: 'AutoFocus', component: lazy(() => import('./autoFocus'))},
|
|
15
|
-
{name: 'panes', title: 'Panes', component: lazy(() => import('./panes'))},
|
|
16
|
-
{name: 'activate', title: 'Activate', component: lazy(() => import('./activate'))},
|
|
17
|
-
{name: 'wrapped', title: 'Wrapped', component: lazy(() => import('./wrapped'))},
|
|
18
|
-
],
|
|
19
|
-
})
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {Box, Card, Code, Dialog, Layer, LayerProvider, useLayer} from '@sanity/ui'
|
|
2
|
-
import {useAction} from '@sanity/ui-workshop'
|
|
3
|
-
|
|
4
|
-
export default function LayeringStory() {
|
|
5
|
-
return (
|
|
6
|
-
<Box padding={[4, 5, 6]}>
|
|
7
|
-
<LayerProvider>
|
|
8
|
-
<Layer zOffset={10} id="a">
|
|
9
|
-
<Card padding={2} shadow={2}>
|
|
10
|
-
<DebugLayer />
|
|
11
|
-
</Card>
|
|
12
|
-
</Layer>
|
|
13
|
-
<Layer zOffset={10} id="b">
|
|
14
|
-
<Card padding={2} shadow={2}>
|
|
15
|
-
<DebugLayer />
|
|
16
|
-
</Card>
|
|
17
|
-
</Layer>
|
|
18
|
-
<Dialog
|
|
19
|
-
header="Layering example"
|
|
20
|
-
id="layering-example"
|
|
21
|
-
onClose={useAction('onEscape')}
|
|
22
|
-
zOffset={100}
|
|
23
|
-
>
|
|
24
|
-
<Box padding={4}>
|
|
25
|
-
<DebugLayer />
|
|
26
|
-
</Box>
|
|
27
|
-
</Dialog>
|
|
28
|
-
</LayerProvider>
|
|
29
|
-
</Box>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function DebugLayer() {
|
|
34
|
-
const layer = useLayer()
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<Code language="json" size={1}>
|
|
38
|
-
{JSON.stringify(layer, null, 2)}
|
|
39
|
-
</Code>
|
|
40
|
-
)
|
|
41
|
-
}
|