@sanity/ui 4.0.0-beta.8 → 4.0.0-next.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/LICENSE +1 -1
- package/README.md +21 -7
- package/dist/_chunks/getScopedTheme.cjs +4043 -0
- package/dist/_chunks/getScopedTheme.cjs.map +1 -0
- package/dist/_chunks/getScopedTheme.js +3803 -0
- package/dist/_chunks/getScopedTheme.js.map +1 -0
- package/dist/_chunks/refractor.cjs +18 -0
- package/dist/_chunks/refractor.cjs.map +1 -0
- package/dist/_chunks/refractor.js +20 -0
- package/dist/_chunks/refractor.js.map +1 -0
- package/dist/_chunks/rgba.d.cts +929 -0
- package/dist/_chunks/rgba.d.cts.map +1 -0
- package/dist/_chunks/rgba.d.ts +929 -0
- package/dist/_chunks/rgba.d.ts.map +1 -0
- package/dist/index.cjs +6243 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2332 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +1767 -1190
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6134 -4725
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs +54 -0
- package/dist/theme.cjs.map +1 -0
- package/dist/theme.d.cts +278 -0
- package/dist/theme.d.cts.map +1 -0
- package/dist/theme.d.ts +278 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +53 -0
- package/dist/theme.js.map +1 -0
- package/package.json +55 -86
- package/dist/_chunks-es/Syntax.js +0 -23
- package/dist/_chunks-es/Syntax.js.map +0 -1
- package/dist/index.css +0 -1
- package/exports/index.css +0 -1
- package/exports/index.ts +0 -125
- package/src/components/autocomplete/Autocomplete.tsx +0 -665
- package/src/components/autocomplete/AutocompleteOption.tsx +0 -42
- package/src/components/autocomplete/__workshop__/Async.tsx +0 -162
- package/src/components/autocomplete/__workshop__/ConstrainedHeight.tsx +0 -121
- package/src/components/autocomplete/__workshop__/Custom.tsx +0 -91
- package/src/components/autocomplete/__workshop__/Example.tsx +0 -70
- package/src/components/autocomplete/__workshop__/FocusAndBlur.tsx +0 -39
- package/src/components/autocomplete/__workshop__/Fullscreen.tsx +0 -307
- package/src/components/autocomplete/__workshop__/index.ts +0 -41
- package/src/components/autocomplete/__workshop__/mock/apiStore.ts +0 -49
- package/src/components/autocomplete/__workshop__/mock/countries.ts +0 -245
- package/src/components/autocomplete/__workshop__/types.ts +0 -4
- package/src/components/autocomplete/autocompleteReducer.ts +0 -47
- package/src/components/autocomplete/constants.ts +0 -28
- package/src/components/autocomplete/types.ts +0 -103
- package/src/components/breadcrumbs/Breadcrumbs.tsx +0 -163
- package/src/components/breadcrumbs/__workshop__/Example.tsx +0 -48
- package/src/components/breadcrumbs/__workshop__/index.ts +0 -16
- package/src/components/dialog/Dialog.tsx +0 -230
- package/src/components/dialog/DialogCard.tsx +0 -233
- package/src/components/dialog/DialogContext.ts +0 -21
- package/src/components/dialog/DialogProvider.tsx +0 -34
- package/src/components/dialog/__workshop__/Activate.tsx +0 -141
- package/src/components/dialog/__workshop__/AutoFocus.tsx +0 -29
- package/src/components/dialog/__workshop__/Layering.tsx +0 -41
- package/src/components/dialog/__workshop__/Nested.tsx +0 -71
- package/src/components/dialog/__workshop__/OnScroll.tsx +0 -51
- package/src/components/dialog/__workshop__/Panes.tsx +0 -75
- package/src/components/dialog/__workshop__/Position.tsx +0 -30
- package/src/components/dialog/__workshop__/Props.tsx +0 -93
- package/src/components/dialog/__workshop__/Provider.tsx +0 -11
- package/src/components/dialog/__workshop__/Wrapped.tsx +0 -76
- package/src/components/dialog/__workshop__/index.ts +0 -21
- package/src/components/dialog/isTargetWithinScope.ts +0 -14
- package/src/components/dialog/types.ts +0 -2
- package/src/components/dialog/useDialog.ts +0 -11
- package/src/components/hotkeys/Hotkeys.tsx +0 -70
- package/src/components/hotkeys/__workshop__/Plain.tsx +0 -9
- package/src/components/hotkeys/__workshop__/index.ts +0 -16
- package/src/components/menu/Menu.test.tsx +0 -125
- package/src/components/menu/Menu.tsx +0 -174
- package/src/components/menu/MenuButton.tsx +0 -231
- package/src/components/menu/MenuContext.ts +0 -19
- package/src/components/menu/MenuDivider.tsx +0 -32
- package/src/components/menu/MenuGroup.tsx +0 -240
- package/src/components/menu/MenuItem.tsx +0 -153
- package/src/components/menu/__workshop__/AsComponent.tsx +0 -45
- package/src/components/menu/__workshop__/AvatarMenu.tsx +0 -36
- package/src/components/menu/__workshop__/ClosableMenuButton.tsx +0 -47
- package/src/components/menu/__workshop__/ConstrainedInBoundary.tsx +0 -133
- package/src/components/menu/__workshop__/CustomMenuItem.tsx +0 -47
- package/src/components/menu/__workshop__/CustomSelectedState.tsx +0 -35
- package/src/components/menu/__workshop__/DataProps.tsx +0 -27
- package/src/components/menu/__workshop__/DisableFocusOnClose.tsx +0 -40
- package/src/components/menu/__workshop__/Groups.tsx +0 -164
- package/src/components/menu/__workshop__/MenuButton.tsx +0 -79
- package/src/components/menu/__workshop__/MenuGroupRight.tsx +0 -73
- package/src/components/menu/__workshop__/NestedMenu.tsx +0 -22
- package/src/components/menu/__workshop__/OnCloseMenuButton.tsx +0 -50
- package/src/components/menu/__workshop__/SelectedItem.tsx +0 -69
- package/src/components/menu/__workshop__/ShouldFocus.tsx +0 -42
- package/src/components/menu/__workshop__/Tones.tsx +0 -19
- package/src/components/menu/__workshop__/index.ts +0 -91
- package/src/components/menu/helpers.ts +0 -82
- package/src/components/menu/useMenu.ts +0 -21
- package/src/components/menu/useMenuController.ts +0 -245
- package/src/components/tab/Tab.tsx +0 -135
- package/src/components/tab/TabList.tsx +0 -157
- package/src/components/tab/TabListContext.ts +0 -10
- package/src/components/tab/TabPanel.tsx +0 -94
- package/src/components/tab/__workshop__/Example.tsx +0 -135
- package/src/components/tab/__workshop__/index.ts +0 -16
- package/src/components/tab/types.ts +0 -11
- package/src/components/toast/Toast.test.tsx +0 -103
- package/src/components/toast/Toast.tsx +0 -191
- package/src/components/toast/ToastContext.ts +0 -7
- package/src/components/toast/ToastLayer.tsx +0 -54
- package/src/components/toast/ToastProvider.tsx +0 -127
- package/src/components/toast/__workshop__/Hook.tsx +0 -71
- package/src/components/toast/__workshop__/Toast.tsx +0 -26
- package/src/components/toast/__workshop__/index.ts +0 -21
- package/src/components/toast/toastState.ts +0 -6
- package/src/components/toast/types.ts +0 -24
- package/src/components/toast/useToast.ts +0 -23
- package/src/components/tree/Tree.tsx +0 -248
- package/src/components/tree/TreeContext.ts +0 -10
- package/src/components/tree/TreeGroup.tsx +0 -46
- package/src/components/tree/TreeItem.tsx +0 -236
- package/src/components/tree/__workshop__/Basic.tsx +0 -108
- package/src/components/tree/__workshop__/TabFromElement.tsx +0 -84
- package/src/components/tree/__workshop__/basic.perf.ts +0 -19
- package/src/components/tree/__workshop__/index.ts +0 -23
- package/src/components/tree/helpers.ts +0 -105
- package/src/components/tree/types.ts +0 -24
- package/src/components/tree/useTree.ts +0 -17
- package/src/components/virtualList/VirtualList.tsx +0 -254
- package/src/components/virtualList/__workshop__/ChangingProps.tsx +0 -41
- package/src/components/virtualList/__workshop__/ElementScroll.tsx +0 -43
- package/src/components/virtualList/__workshop__/InfiniteList.tsx +0 -40
- package/src/components/virtualList/__workshop__/WindowScrolll.tsx +0 -23
- package/src/components/virtualList/__workshop__/index.ts +0 -31
- package/src/core/_keys.ts +0 -26
- package/src/core/constants.ts +0 -67
- package/src/core/getElementRef.ts +0 -29
- package/src/core/helpers/animation.ts +0 -26
- package/src/core/helpers/element.ts +0 -55
- package/src/core/helpers/focus.ts +0 -92
- package/src/core/helpers/props.ts +0 -51
- package/src/core/helpers/scroll.ts +0 -15
- package/src/core/lib/createGlobalScopedContext.ts +0 -39
- package/src/core/lib/globalScope.ts +0 -19
- package/src/core/lib/isArray.ts +0 -3
- package/src/core/lib/isRecord.ts +0 -3
- package/src/core/types.ts +0 -57
- package/src/hooks/useClickOutsideEvent.test.tsx +0 -114
- package/src/hooks/useClickOutsideEvent.ts +0 -66
- package/src/hooks/useCustomValidity.ts +0 -13
- package/src/hooks/useElementSize.ts +0 -19
- package/src/hooks/useGlobalKeyDown.ts +0 -23
- package/src/hooks/useMatchMedia.ts +0 -28
- package/src/hooks/useMediaIndex/__workshop__/Test.tsx +0 -14
- package/src/hooks/useMediaIndex/__workshop__/index.ts +0 -16
- package/src/hooks/useMediaIndex/useMediaIndex.test.tsx +0 -21
- package/src/hooks/useMediaIndex/useMediaIndex.ts +0 -111
- package/src/hooks/useMounted.ts +0 -15
- package/src/hooks/usePrefersDark.hydration.test.tsx +0 -56
- package/src/hooks/usePrefersDark.test.tsx +0 -20
- package/src/hooks/usePrefersDark.ts +0 -16
- package/src/hooks/usePrefersReducedMotion.hydration.test.tsx +0 -56
- package/src/hooks/usePrefersReducedMotion.test.tsx +0 -20
- package/src/hooks/usePrefersReducedMotion.ts +0 -16
- package/src/hooks/useResponsiveProp.ts +0 -14
- package/src/hooks/useUnique.ts +0 -54
- package/src/middleware/origin.ts +0 -47
- package/src/observers/elementSize.ts +0 -114
- package/src/primitives/_syntax/LazySyntax.tsx +0 -4
- package/src/primitives/_syntax/Syntax.tsx +0 -26
- package/src/primitives/avatar/Avatar.tsx +0 -145
- package/src/primitives/avatar/AvatarCounter.tsx +0 -69
- package/src/primitives/avatar/AvatarStack.tsx +0 -77
- package/src/primitives/avatar/__workshop__/AsButton.tsx +0 -12
- package/src/primitives/avatar/__workshop__/PropsStory.tsx +0 -24
- package/src/primitives/avatar/__workshop__/Stack.tsx +0 -27
- package/src/primitives/avatar/__workshop__/WithinButton.tsx +0 -51
- package/src/primitives/avatar/__workshop__/WithinMenuItem.tsx +0 -52
- package/src/primitives/avatar/__workshop__/index.ts +0 -36
- package/src/primitives/avatar/types.ts +0 -2
- package/src/primitives/badge/Badge.test.tsx +0 -16
- package/src/primitives/badge/Badge.tsx +0 -53
- package/src/primitives/badge/__workshop__/Props.tsx +0 -27
- package/src/primitives/badge/__workshop__/Tones.tsx +0 -15
- package/src/primitives/badge/__workshop__/index.ts +0 -26
- package/src/primitives/badge/__workshop__/within-button.tsx +0 -36
- package/src/primitives/box/Box.tsx +0 -73
- package/src/primitives/box/__workshop__/Props.tsx +0 -26
- package/src/primitives/box/__workshop__/Responsive.tsx +0 -19
- package/src/primitives/box/__workshop__/index.ts +0 -21
- package/src/primitives/button/Button.test.tsx +0 -30
- package/src/primitives/button/Button.tsx +0 -148
- package/src/primitives/button/__workshop__/Custom.tsx +0 -39
- package/src/primitives/button/__workshop__/CustomIcons.tsx +0 -37
- package/src/primitives/button/__workshop__/DataProps.tsx +0 -18
- package/src/primitives/button/__workshop__/Disabled.tsx +0 -43
- package/src/primitives/button/__workshop__/MixedChildren.tsx +0 -12
- package/src/primitives/button/__workshop__/Props.tsx +0 -60
- package/src/primitives/button/__workshop__/Stacked.tsx +0 -60
- package/src/primitives/button/__workshop__/Styled1.css.ts +0 -7
- package/src/primitives/button/__workshop__/Styled1.tsx +0 -11
- package/src/primitives/button/__workshop__/TextOverflow.tsx +0 -17
- package/src/primitives/button/__workshop__/UploadButton.tsx +0 -28
- package/src/primitives/button/__workshop__/index.ts +0 -61
- package/src/primitives/button/types.ts +0 -2
- package/src/primitives/card/Card.tsx +0 -124
- package/src/primitives/card/CardContext.ts +0 -10
- package/src/primitives/card/CardInternalContext.ts +0 -10
- package/src/primitives/card/CardInternalProvider.tsx +0 -15
- package/src/primitives/card/CardProvider.tsx +0 -16
- package/src/primitives/card/__workshop__/AsButton.tsx +0 -103
- package/src/primitives/card/__workshop__/AsComponent.tsx +0 -25
- package/src/primitives/card/__workshop__/Checkered.tsx +0 -25
- package/src/primitives/card/__workshop__/DataProps.tsx +0 -25
- package/src/primitives/card/__workshop__/Interactive.tsx +0 -29
- package/src/primitives/card/__workshop__/ListNavigation.tsx +0 -78
- package/src/primitives/card/__workshop__/Props.tsx +0 -59
- package/src/primitives/card/__workshop__/Selected.tsx +0 -62
- package/src/primitives/card/__workshop__/Styled.tsx +0 -11
- package/src/primitives/card/__workshop__/Tones.tsx +0 -26
- package/src/primitives/card/__workshop__/index.ts +0 -21
- package/src/primitives/card/types.ts +0 -21
- package/src/primitives/card/useCard.ts +0 -20
- package/src/primitives/checkbox/Checkbox.tsx +0 -80
- package/src/primitives/checkbox/__workshop__/Example.tsx +0 -25
- package/src/primitives/checkbox/__workshop__/Props.tsx +0 -35
- package/src/primitives/checkbox/__workshop__/ReadOnly.tsx +0 -16
- package/src/primitives/checkbox/__workshop__/Tones.tsx +0 -26
- package/src/primitives/checkbox/__workshop__/index.ts +0 -15
- package/src/primitives/code/Code.tsx +0 -47
- package/src/primitives/code/__workshop__/OpticalAlignment.tsx +0 -25
- package/src/primitives/code/__workshop__/Props.tsx +0 -20
- package/src/primitives/code/__workshop__/index.ts +0 -21
- package/src/primitives/container/Container.tsx +0 -43
- package/src/primitives/container/__workshop__/Example.tsx +0 -16
- package/src/primitives/container/__workshop__/index.ts +0 -16
- package/src/primitives/container/types.ts +0 -6
- package/src/primitives/flex/Flex.tsx +0 -38
- package/src/primitives/flex/__workshop__/Example.tsx +0 -26
- package/src/primitives/flex/__workshop__/Gap.tsx +0 -25
- package/src/primitives/flex/__workshop__/index.ts +0 -13
- package/src/primitives/flex/__workshop__/styles.css.ts +0 -12
- package/src/primitives/grid/Grid.tsx +0 -38
- package/src/primitives/grid/__workshop__/Responsive.tsx +0 -54
- package/src/primitives/grid/__workshop__/index.ts +0 -12
- package/src/primitives/heading/Heading.tsx +0 -68
- package/src/primitives/heading/__workshop__/OpticalAlignment.tsx +0 -27
- package/src/primitives/heading/__workshop__/Plain.tsx +0 -25
- package/src/primitives/heading/__workshop__/index.ts +0 -21
- package/src/primitives/inline/Inline.tsx +0 -37
- package/src/primitives/inline/__workshop__/Plain.tsx +0 -22
- package/src/primitives/inline/__workshop__/index.ts +0 -10
- package/src/primitives/kbd/Kbd.tsx +0 -36
- package/src/primitives/kbd/__workshop__/Plain.tsx +0 -9
- package/src/primitives/kbd/__workshop__/index.ts +0 -10
- package/src/primitives/label/Label.tsx +0 -67
- package/src/primitives/label/__workshop__/OpticalAlignment.tsx +0 -27
- package/src/primitives/label/__workshop__/Plain.tsx +0 -27
- package/src/primitives/label/__workshop__/index.ts +0 -21
- package/src/primitives/layer/Layer.test.tsx +0 -110
- package/src/primitives/layer/Layer.tsx +0 -35
- package/src/primitives/layer/LayerCard.tsx +0 -90
- package/src/primitives/layer/LayerContext.ts +0 -7
- package/src/primitives/layer/LayerProvider.tsx +0 -106
- package/src/primitives/layer/__workshop__/MultipleRoots.tsx +0 -49
- package/src/primitives/layer/__workshop__/Nested.tsx +0 -107
- package/src/primitives/layer/__workshop__/ResponsiveZOffset.tsx +0 -17
- package/src/primitives/layer/__workshop__/_debug.tsx +0 -17
- package/src/primitives/layer/__workshop__/index.ts +0 -26
- package/src/primitives/layer/getLayerContext.test.ts +0 -32
- package/src/primitives/layer/getLayerContext.ts +0 -21
- package/src/primitives/layer/types.ts +0 -9
- package/src/primitives/layer/useLayer.ts +0 -24
- package/src/primitives/popover/Popover.tsx +0 -291
- package/src/primitives/popover/PopoverLayer.tsx +0 -101
- package/src/primitives/popover/__workshop__/AlignedStory.tsx +0 -75
- package/src/primitives/popover/__workshop__/MarginsStory.tsx +0 -31
- package/src/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +0 -32
- package/src/primitives/popover/__workshop__/OpenOnMountStory.tsx +0 -11
- package/src/primitives/popover/__workshop__/PlainStory.tsx +0 -67
- package/src/primitives/popover/__workshop__/RecursiveStory.tsx +0 -71
- package/src/primitives/popover/__workshop__/SidePanelStory.tsx +0 -95
- package/src/primitives/popover/__workshop__/TestStory.tsx +0 -97
- package/src/primitives/popover/__workshop__/index.ts +0 -56
- package/src/primitives/popover/__workshop__/portal-inheritance.tsx +0 -15
- package/src/primitives/popover/constants.ts +0 -20
- package/src/primitives/popover/floating-ui/size.ts +0 -75
- package/src/primitives/popover/types.ts +0 -12
- package/src/primitives/popover/useMiddleware.ts +0 -126
- package/src/primitives/radio/Radio.tsx +0 -64
- package/src/primitives/radio/__workshop__/Example.tsx +0 -63
- package/src/primitives/radio/__workshop__/Plain.tsx +0 -28
- package/src/primitives/radio/__workshop__/index.ts +0 -13
- package/src/primitives/select/Select.tsx +0 -76
- package/src/primitives/select/__workshop__/Plain.tsx +0 -37
- package/src/primitives/select/__workshop__/ReadOnly.tsx +0 -23
- package/src/primitives/select/__workshop__/index.ts +0 -13
- package/src/primitives/selectable/Selectable.tsx +0 -48
- package/src/primitives/selectable/__workshop__/DataProps.tsx +0 -24
- package/src/primitives/selectable/__workshop__/as-link.tsx +0 -13
- package/src/primitives/selectable/__workshop__/index.ts +0 -19
- package/src/primitives/skeleton/CodeSkeleton.tsx +0 -49
- package/src/primitives/skeleton/HeadingSkeleton.tsx +0 -48
- package/src/primitives/skeleton/LabelSkeleton.tsx +0 -47
- package/src/primitives/skeleton/Skeleton.tsx +0 -70
- package/src/primitives/skeleton/TextSkeleton.tsx +0 -49
- package/src/primitives/skeleton/__workshop__/Delay.tsx +0 -69
- package/src/primitives/skeleton/__workshop__/Skeleton.tsx +0 -63
- package/src/primitives/skeleton/__workshop__/index.ts +0 -13
- package/src/primitives/spinner/Spinner.tsx +0 -45
- package/src/primitives/spinner/SpinnerAnimatedIcon.tsx +0 -14
- package/src/primitives/spinner/__workshop__/Props.tsx +0 -13
- package/src/primitives/spinner/__workshop__/index.ts +0 -16
- package/src/primitives/srOnly/SrOnly.tsx +0 -33
- package/src/primitives/stack/Stack.tsx +0 -38
- package/src/primitives/stack/__workshop__/Plain.tsx +0 -30
- package/src/primitives/stack/__workshop__/index.ts +0 -16
- package/src/primitives/switch/Switch.tsx +0 -76
- package/src/primitives/switch/__workshop__/Example.tsx +0 -25
- package/src/primitives/switch/__workshop__/Props.tsx +0 -23
- package/src/primitives/switch/__workshop__/index.ts +0 -13
- package/src/primitives/text/InlineCode.tsx +0 -25
- package/src/primitives/text/Text.tsx +0 -68
- package/src/primitives/text/__workshop__/Example.tsx +0 -26
- package/src/primitives/text/__workshop__/OpticalAlignment.tsx +0 -27
- package/src/primitives/text/__workshop__/index.ts +0 -26
- package/src/primitives/text/__workshop__/inline-code.tsx +0 -13
- package/src/primitives/textArea/TextArea.tsx +0 -97
- package/src/primitives/textArea/__workshop__/Plain.tsx +0 -46
- package/src/primitives/textArea/__workshop__/index.ts +0 -16
- package/src/primitives/textInput/TextInput.tsx +0 -279
- package/src/primitives/textInput/__workshop__/ClearButton.tsx +0 -32
- package/src/primitives/textInput/__workshop__/CustomValidity.tsx +0 -17
- package/src/primitives/textInput/__workshop__/Plain.tsx +0 -102
- package/src/primitives/textInput/__workshop__/ReadOnly.tsx +0 -14
- package/src/primitives/textInput/__workshop__/States.tsx +0 -53
- package/src/primitives/textInput/__workshop__/Tones.tsx +0 -40
- package/src/primitives/textInput/__workshop__/Typed.tsx +0 -23
- package/src/primitives/textInput/__workshop__/index.ts +0 -46
- package/src/primitives/tooltip/Tooltip.test.tsx +0 -496
- package/src/primitives/tooltip/Tooltip.tsx +0 -546
- package/src/primitives/tooltip/TooltipLayer.tsx +0 -72
- package/src/primitives/tooltip/__workshop__/CustomPortal.tsx +0 -102
- package/src/primitives/tooltip/__workshop__/OverflowingBoundary.tsx +0 -74
- package/src/primitives/tooltip/__workshop__/Props.tsx +0 -107
- package/src/primitives/tooltip/__workshop__/ResizableBoundary.tsx +0 -91
- package/src/primitives/tooltip/__workshop__/index.ts +0 -31
- package/src/primitives/tooltip/constants.ts +0 -24
- package/src/primitives/tooltip/tooltipDelayGroup/TooltipDelayGroupContext.tsx +0 -13
- package/src/primitives/tooltip/tooltipDelayGroup/TooltipDelayGroupProvider.tsx +0 -96
- package/src/primitives/tooltip/tooltipDelayGroup/types.ts +0 -7
- package/src/primitives/tooltip/tooltipDelayGroup/useTooltipDelayGroup.ts +0 -13
- package/src/root/Root.tsx +0 -93
- package/src/root/RootProvider.tsx +0 -37
- package/src/root/__workshop__/Boundary.tsx +0 -43
- package/src/root/__workshop__/index.ts +0 -24
- package/src/root/__workshop__/primitives.tsx +0 -49
- package/src/root/__workshop__/tone-inheritance.tsx +0 -65
- package/src/utils/ErrorBoundary.tsx +0 -50
- package/src/utils/boundaryElement/BoundaryElementContext.ts +0 -7
- package/src/utils/boundaryElement/BoundaryElementProvider.tsx +0 -16
- package/src/utils/boundaryElement/__workshop__/Plain.tsx +0 -49
- package/src/utils/boundaryElement/__workshop__/index.ts +0 -16
- package/src/utils/boundaryElement/types.ts +0 -2
- package/src/utils/boundaryElement/useBoundaryElement.ts +0 -12
- package/src/utils/elementQuery/ElementQuery.tsx +0 -75
- package/src/utils/elementQuery/__workshop__/CustomMedia.tsx +0 -19
- package/src/utils/elementQuery/__workshop__/index.ts +0 -16
- package/src/utils/elementQuery/__workshop__/styles.css.ts +0 -31
- package/src/utils/elementQuery/helpers.ts +0 -27
- package/src/utils/portal/Portal.test.tsx +0 -105
- package/src/utils/portal/Portal.tsx +0 -42
- package/src/utils/portal/PortalContext.ts +0 -37
- package/src/utils/portal/PortalProvider.tsx +0 -38
- package/src/utils/portal/__workshop__/Named.tsx +0 -69
- package/src/utils/portal/__workshop__/index.ts +0 -16
- package/src/utils/portal/types.ts +0 -7
- package/src/utils/portal/usePortal.ts +0 -30
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import {autoUpdate, type RootBoundary, useFloating} from '@floating-ui/react-dom'
|
|
2
|
-
import {type MaxWidth, popover as popoverCss, type ResponsiveProp} from '@sanity/ui-css'
|
|
3
|
-
import {AnimatePresence} from 'motion/react'
|
|
4
|
-
import {
|
|
5
|
-
cloneElement,
|
|
6
|
-
type ForwardedRef,
|
|
7
|
-
type ReactElement,
|
|
8
|
-
type ReactNode,
|
|
9
|
-
type Ref,
|
|
10
|
-
use,
|
|
11
|
-
useCallback,
|
|
12
|
-
useImperativeHandle,
|
|
13
|
-
useMemo,
|
|
14
|
-
useRef,
|
|
15
|
-
} from 'react'
|
|
16
|
-
|
|
17
|
-
import {Z_OFFSETS} from '../../core/constants'
|
|
18
|
-
import {getElementRef} from '../../core/getElementRef'
|
|
19
|
-
import type {Assign, Placement} from '../../core/types'
|
|
20
|
-
import {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'
|
|
21
|
-
import {BoundaryElementContext} from '../../utils/boundaryElement/BoundaryElementContext'
|
|
22
|
-
import {Portal} from '../../utils/portal/Portal'
|
|
23
|
-
import {useLayer} from '../layer/useLayer'
|
|
24
|
-
import {
|
|
25
|
-
DEFAULT_FALLBACK_PLACEMENTS,
|
|
26
|
-
DEFAULT_POPOVER_DISTANCE,
|
|
27
|
-
DEFAULT_POPOVER_MARGINS,
|
|
28
|
-
} from './constants'
|
|
29
|
-
import {PopoverLayer, type PopoverLayerOwnProps, type PopoverLayerProps} from './PopoverLayer'
|
|
30
|
-
import type {PopoverMargins, PopoverUpdateCallback} from './types'
|
|
31
|
-
import {useMiddleware} from './useMiddleware'
|
|
32
|
-
|
|
33
|
-
/** @public */
|
|
34
|
-
export type PopoverOwnProps = Omit<PopoverLayerOwnProps, 'maxWidth'> & {
|
|
35
|
-
/** @beta */
|
|
36
|
-
__unstable_distance?: number
|
|
37
|
-
/**
|
|
38
|
-
* @beta
|
|
39
|
-
* @deprecated Will be removed in the next major version */
|
|
40
|
-
__unstable_margins?: PopoverMargins
|
|
41
|
-
/** @beta */
|
|
42
|
-
__unstable_shift?: number
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated Will be removed in the next major version
|
|
45
|
-
*/
|
|
46
|
-
arrow?: boolean
|
|
47
|
-
children?: ReactElement<{ref: ForwardedRef<HTMLElement>}>
|
|
48
|
-
/**
|
|
49
|
-
* When `true`, prevent overflow within the current boundary:
|
|
50
|
-
* - by flipping on its side axis
|
|
51
|
-
* - by resizing
|
|
52
|
-
*
|
|
53
|
-
* Note that:
|
|
54
|
-
* - setting `preventOverflow` to `true` also prevents overflow on its side axis
|
|
55
|
-
* - setting `matchReferenceWidth` to `true` also causes the popover to resize
|
|
56
|
-
*
|
|
57
|
-
* @defaultValue false
|
|
58
|
-
*/
|
|
59
|
-
constrainSize?: boolean
|
|
60
|
-
content?: ReactNode
|
|
61
|
-
disabled?: boolean
|
|
62
|
-
fallbackPlacements?: Placement[]
|
|
63
|
-
floatingBoundary?: HTMLElement | null
|
|
64
|
-
/**
|
|
65
|
-
* When `true`, set the maximum width to match the reference element, and also prevent overflow within
|
|
66
|
-
* the current boundary by resizing.
|
|
67
|
-
*
|
|
68
|
-
* Note that setting `constrainSize` to `true` also causes the popover to resize
|
|
69
|
-
*
|
|
70
|
-
* @defaultValue false
|
|
71
|
-
*/
|
|
72
|
-
matchReferenceWidth?: boolean
|
|
73
|
-
/**
|
|
74
|
-
* When true, blocks all pointer interaction with elements beneath the popover until closed.
|
|
75
|
-
*
|
|
76
|
-
* @beta
|
|
77
|
-
* @defaultValue false
|
|
78
|
-
*/
|
|
79
|
-
modal?: boolean
|
|
80
|
-
open?: boolean
|
|
81
|
-
placement?: Placement
|
|
82
|
-
/**
|
|
83
|
-
* When 'flip' (default), the placement is determined from the initial placement and the
|
|
84
|
-
* fallback placements in order. Whichever fits in the viewport first.
|
|
85
|
-
*
|
|
86
|
-
* When 'autoPlacement', the initial placement and all fallback placements are evaluated
|
|
87
|
-
* and the placement with the most viewport space available.
|
|
88
|
-
*
|
|
89
|
-
* Option is only relevant if either `constrainSize` or `preventOverflow` is `true`
|
|
90
|
-
*/
|
|
91
|
-
placementStrategy?: 'flip' | 'autoPlacement'
|
|
92
|
-
/** Whether or not to render the popover in a portal element. */
|
|
93
|
-
portal?: boolean | string
|
|
94
|
-
preventOverflow?: boolean
|
|
95
|
-
referenceBoundary?: HTMLElement | null
|
|
96
|
-
/**
|
|
97
|
-
* When defined, the popover will be positioned relative to this element.
|
|
98
|
-
* The children of the popover won't be rendered.
|
|
99
|
-
*/
|
|
100
|
-
referenceElement?: HTMLElement | null
|
|
101
|
-
/** @beta */
|
|
102
|
-
updateRef?: Ref<PopoverUpdateCallback | undefined>
|
|
103
|
-
width?: ResponsiveProp<MaxWidth>
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** @public */
|
|
107
|
-
export type PopoverElementType = 'div'
|
|
108
|
-
|
|
109
|
-
/** @public */
|
|
110
|
-
export type PopoverProps = Assign<PopoverLayerProps, PopoverOwnProps>
|
|
111
|
-
|
|
112
|
-
function ViewportOverlay() {
|
|
113
|
-
const {zIndex} = useLayer()
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<div
|
|
117
|
-
style={{
|
|
118
|
-
position: 'fixed',
|
|
119
|
-
inset: 0,
|
|
120
|
-
width: '100vw',
|
|
121
|
-
height: '100vh',
|
|
122
|
-
zIndex,
|
|
123
|
-
}}
|
|
124
|
-
/>
|
|
125
|
-
)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* The `Popover` component is used to display some content on top of another.
|
|
130
|
-
*
|
|
131
|
-
* @public
|
|
132
|
-
*/
|
|
133
|
-
export function Popover(props: PopoverProps): React.JSX.Element {
|
|
134
|
-
const {
|
|
135
|
-
// Remove `__unstable_margins` prop in next major version
|
|
136
|
-
__unstable_margins: _margins = DEFAULT_POPOVER_MARGINS,
|
|
137
|
-
__unstable_distance: distance = DEFAULT_POPOVER_DISTANCE,
|
|
138
|
-
__unstable_shift: shift = 0,
|
|
139
|
-
animate: _animate = false,
|
|
140
|
-
// Remove `arrow` prop in next major version
|
|
141
|
-
arrow: _arrow,
|
|
142
|
-
children: childProp,
|
|
143
|
-
className,
|
|
144
|
-
constrainSize = false,
|
|
145
|
-
content,
|
|
146
|
-
disabled,
|
|
147
|
-
fallbackPlacements: _fallbackPlacements,
|
|
148
|
-
matchReferenceWidth,
|
|
149
|
-
floatingBoundary: _floatingBoundary,
|
|
150
|
-
modal,
|
|
151
|
-
onActivate,
|
|
152
|
-
open,
|
|
153
|
-
overflow = 'hidden',
|
|
154
|
-
padding,
|
|
155
|
-
placement: placement = 'bottom',
|
|
156
|
-
placementStrategy = 'flip',
|
|
157
|
-
portal = true,
|
|
158
|
-
preventOverflow = true,
|
|
159
|
-
radius = 4,
|
|
160
|
-
ref: forwardedRef,
|
|
161
|
-
referenceBoundary: _referenceBoundary,
|
|
162
|
-
referenceElement,
|
|
163
|
-
shadow = 3,
|
|
164
|
-
width: widthProp = 'auto',
|
|
165
|
-
zOffset = Z_OFFSETS.popover,
|
|
166
|
-
updateRef,
|
|
167
|
-
...rest
|
|
168
|
-
} = props
|
|
169
|
-
const fallbackPlacements =
|
|
170
|
-
_fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? 'bottom']
|
|
171
|
-
const floatingBoundary = _floatingBoundary ?? use(BoundaryElementContext)
|
|
172
|
-
const referenceBoundary = _referenceBoundary ?? use(BoundaryElementContext)
|
|
173
|
-
|
|
174
|
-
const prefersReducedMotion = usePrefersReducedMotion()
|
|
175
|
-
const animate = prefersReducedMotion ? false : _animate
|
|
176
|
-
|
|
177
|
-
const ref = useRef<HTMLDivElement | null>(null)
|
|
178
|
-
|
|
179
|
-
const rootBoundary: RootBoundary = 'viewport'
|
|
180
|
-
|
|
181
|
-
useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(forwardedRef, () => ref.current)
|
|
182
|
-
|
|
183
|
-
// Keep track of reference element width (see `size` middleware below)
|
|
184
|
-
const referenceWidthRef = useRef<number>(undefined)
|
|
185
|
-
|
|
186
|
-
const middleware = useMiddleware({
|
|
187
|
-
animate,
|
|
188
|
-
constrainSize,
|
|
189
|
-
distance,
|
|
190
|
-
fallbackPlacements,
|
|
191
|
-
floatingBoundary,
|
|
192
|
-
matchReferenceWidth,
|
|
193
|
-
placement,
|
|
194
|
-
placementStrategy,
|
|
195
|
-
preventOverflow,
|
|
196
|
-
referenceBoundary,
|
|
197
|
-
referenceWidthRef,
|
|
198
|
-
rootBoundary,
|
|
199
|
-
shift,
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
const {x, y, middlewareData, refs, strategy, update} = useFloating({
|
|
203
|
-
middleware,
|
|
204
|
-
placement: placement,
|
|
205
|
-
whileElementsMounted: autoUpdate,
|
|
206
|
-
elements: referenceElement
|
|
207
|
-
? {
|
|
208
|
-
reference: referenceElement,
|
|
209
|
-
}
|
|
210
|
-
: undefined,
|
|
211
|
-
})
|
|
212
|
-
|
|
213
|
-
const referenceHidden = middlewareData.hide?.referenceHidden
|
|
214
|
-
|
|
215
|
-
const originX = middlewareData['@sanity/ui/origin']?.originX
|
|
216
|
-
const originY = middlewareData['@sanity/ui/origin']?.originY
|
|
217
|
-
|
|
218
|
-
const setFloating = useCallback(
|
|
219
|
-
(node: HTMLDivElement | null) => {
|
|
220
|
-
ref.current = node
|
|
221
|
-
refs.setFloating(node)
|
|
222
|
-
},
|
|
223
|
-
[refs],
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
// If there's a child then we need to set the reference element to the cloned child ref
|
|
227
|
-
// and if child changes we make sure to update or remove the reference element.
|
|
228
|
-
useImperativeHandle(childProp ? getElementRef(childProp) : null, () => refs.reference.current)
|
|
229
|
-
|
|
230
|
-
const child = useMemo(() => {
|
|
231
|
-
// If a reference element is defined, we don't need to clone the child
|
|
232
|
-
if (referenceElement) return childProp
|
|
233
|
-
|
|
234
|
-
if (!childProp) return null
|
|
235
|
-
|
|
236
|
-
return cloneElement(childProp, {ref: refs.setReference})
|
|
237
|
-
}, [childProp, referenceElement, refs.setReference])
|
|
238
|
-
|
|
239
|
-
useImperativeHandle(updateRef, () => update, [update])
|
|
240
|
-
|
|
241
|
-
if (disabled) {
|
|
242
|
-
return childProp || <></>
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const node = (
|
|
246
|
-
<>
|
|
247
|
-
{/* Optional transparent blocking overlay at the top-most z-index layer. Must be positioned
|
|
248
|
-
before the below popover card. */}
|
|
249
|
-
{modal && <ViewportOverlay />}
|
|
250
|
-
|
|
251
|
-
<PopoverLayer
|
|
252
|
-
{...rest}
|
|
253
|
-
ref={setFloating}
|
|
254
|
-
animate={animate}
|
|
255
|
-
className={popoverCss({className})}
|
|
256
|
-
hidden={referenceHidden}
|
|
257
|
-
maxWidth={widthProp}
|
|
258
|
-
originX={originX}
|
|
259
|
-
originY={originY}
|
|
260
|
-
overflow={overflow}
|
|
261
|
-
padding={padding}
|
|
262
|
-
radius={radius}
|
|
263
|
-
shadow={shadow}
|
|
264
|
-
strategy={strategy}
|
|
265
|
-
x={x}
|
|
266
|
-
y={y}
|
|
267
|
-
zOffset={zOffset}
|
|
268
|
-
>
|
|
269
|
-
{content}
|
|
270
|
-
</PopoverLayer>
|
|
271
|
-
</>
|
|
272
|
-
)
|
|
273
|
-
|
|
274
|
-
let children = open ? node : null
|
|
275
|
-
|
|
276
|
-
if (open && portal) {
|
|
277
|
-
children = (
|
|
278
|
-
<Portal __unstable_name={typeof portal === 'string' ? portal : undefined}>{node}</Portal>
|
|
279
|
-
)
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
return (
|
|
283
|
-
<>
|
|
284
|
-
{/* the popover */}
|
|
285
|
-
{animate ? <AnimatePresence>{children}</AnimatePresence> : children}
|
|
286
|
-
|
|
287
|
-
{/* the referred element */}
|
|
288
|
-
{child}
|
|
289
|
-
</>
|
|
290
|
-
)
|
|
291
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type {Strategy} from '@floating-ui/react-dom'
|
|
2
|
-
import {popover_card} from '@sanity/ui-css'
|
|
3
|
-
import {type HTMLMotionProps, motion} from 'motion/react'
|
|
4
|
-
import {useMemo} from 'react'
|
|
5
|
-
|
|
6
|
-
import {POPOVER_MOTION_PROPS} from '../../core/constants'
|
|
7
|
-
import type {Assign} from '../../core/types'
|
|
8
|
-
import {Flex} from '../flex/Flex'
|
|
9
|
-
import {Layer, type LayerOwnProps} from '../layer/Layer'
|
|
10
|
-
|
|
11
|
-
/** @internal */
|
|
12
|
-
export interface PopoverLayerOwnProps extends LayerOwnProps {
|
|
13
|
-
/**
|
|
14
|
-
* Whether the popover should animate in and out.
|
|
15
|
-
*
|
|
16
|
-
* @beta
|
|
17
|
-
* @defaultValue false
|
|
18
|
-
*/
|
|
19
|
-
animate?: boolean
|
|
20
|
-
children?: React.ReactNode
|
|
21
|
-
originX?: number
|
|
22
|
-
originY?: number
|
|
23
|
-
referenceWidth?: number
|
|
24
|
-
strategy?: Strategy
|
|
25
|
-
x?: number
|
|
26
|
-
y?: number
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** @public */
|
|
30
|
-
export type PopoverLayerProps = Assign<HTMLMotionProps<'div'>, PopoverLayerOwnProps>
|
|
31
|
-
|
|
32
|
-
/** @internal */
|
|
33
|
-
export function PopoverLayer(props: PopoverLayerProps): React.JSX.Element {
|
|
34
|
-
const {
|
|
35
|
-
animate = false,
|
|
36
|
-
children,
|
|
37
|
-
maxWidth,
|
|
38
|
-
padding,
|
|
39
|
-
originX,
|
|
40
|
-
originY,
|
|
41
|
-
overflow,
|
|
42
|
-
radius,
|
|
43
|
-
referenceWidth,
|
|
44
|
-
shadow,
|
|
45
|
-
strategy,
|
|
46
|
-
style,
|
|
47
|
-
tone = 'inherit',
|
|
48
|
-
x,
|
|
49
|
-
y,
|
|
50
|
-
...rest
|
|
51
|
-
} = props
|
|
52
|
-
|
|
53
|
-
const rootStyle = useMemo(
|
|
54
|
-
() => ({
|
|
55
|
-
left: x,
|
|
56
|
-
originX,
|
|
57
|
-
originY,
|
|
58
|
-
top: y,
|
|
59
|
-
width: referenceWidth,
|
|
60
|
-
willChange: animate ? 'transform' : undefined,
|
|
61
|
-
...style,
|
|
62
|
-
}),
|
|
63
|
-
[animate, originX, originY, referenceWidth, style, x, y],
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<Layer
|
|
68
|
-
className={popover_card()}
|
|
69
|
-
data-ui="Popover"
|
|
70
|
-
{...rest}
|
|
71
|
-
animate={animate ? ['visible', 'scaleIn'] : undefined}
|
|
72
|
-
as={motion.div}
|
|
73
|
-
display="flex"
|
|
74
|
-
exit={animate ? ['hidden', 'scaleOut'] : undefined}
|
|
75
|
-
flexDirection="column"
|
|
76
|
-
initial={animate ? ['hidden', 'initial'] : undefined}
|
|
77
|
-
position={strategy}
|
|
78
|
-
radius={radius}
|
|
79
|
-
shadow={shadow}
|
|
80
|
-
sizing="border"
|
|
81
|
-
style={rootStyle}
|
|
82
|
-
tone={tone}
|
|
83
|
-
transition={POPOVER_MOTION_PROPS.transition}
|
|
84
|
-
variants={POPOVER_MOTION_PROPS.card}
|
|
85
|
-
>
|
|
86
|
-
<Flex
|
|
87
|
-
data-ui="Popover__wrapper"
|
|
88
|
-
direction="column"
|
|
89
|
-
flex={1}
|
|
90
|
-
maxWidth={maxWidth}
|
|
91
|
-
overflow={overflow}
|
|
92
|
-
radius={radius}
|
|
93
|
-
tabIndex={-1}
|
|
94
|
-
>
|
|
95
|
-
<Flex direction="column" flex={1} padding={padding}>
|
|
96
|
-
{children}
|
|
97
|
-
</Flex>
|
|
98
|
-
</Flex>
|
|
99
|
-
</Layer>
|
|
100
|
-
)
|
|
101
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {EllipsisVerticalIcon} from '@sanity/icons'
|
|
2
|
-
import {Button, Card, CONTAINER, Flex, Popover, Text, useClickOutsideEvent} from '@sanity/ui'
|
|
3
|
-
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
4
|
-
import {useCallback, useRef, useState} from 'react'
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
WORKSHOP_FLEX_ALIGN_OPTIONS,
|
|
8
|
-
WORKSHOP_FLEX_JUSTIFY_OPTIONS,
|
|
9
|
-
WORKSHOP_PLACEMENT_OPTIONS,
|
|
10
|
-
} from '$workshop'
|
|
11
|
-
|
|
12
|
-
export default function AlignedStory(): React.JSX.Element {
|
|
13
|
-
const constrainSize = useBoolean('Constrain size', false)
|
|
14
|
-
const placement = useSelect('Placement', WORKSHOP_PLACEMENT_OPTIONS)
|
|
15
|
-
const portal = useBoolean('Portal', true)
|
|
16
|
-
const width = useSelect('Width', CONTAINER, 'auto')
|
|
17
|
-
const flexAlign = useSelect('Align', WORKSHOP_FLEX_ALIGN_OPTIONS)
|
|
18
|
-
const flexJustify = useSelect('Justify', WORKSHOP_FLEX_JUSTIFY_OPTIONS)
|
|
19
|
-
|
|
20
|
-
const [open, setOpen] = useState(false)
|
|
21
|
-
const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)
|
|
22
|
-
const buttonElementRef = useRef<HTMLButtonElement | null>(null)
|
|
23
|
-
const popoverElementRef = useRef<HTMLDivElement | null>(null)
|
|
24
|
-
|
|
25
|
-
const content = (
|
|
26
|
-
<Text size={1}>
|
|
27
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque at nisl at sem tempor
|
|
28
|
-
hendrerit scelerisque ut libero. Maecenas iaculis efficitur lorem, ac faucibus mi imperdiet
|
|
29
|
-
quis. Cras a consectetur erat. Fusce imperdiet, dolor et pellentesque iaculis, ex quam luctus
|
|
30
|
-
felis, non ultrices enim sem vitae quam. Duis lorem velit, lacinia at rhoncus a, tempus vel
|
|
31
|
-
neque. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae;
|
|
32
|
-
Sed id mauris quam. Nam finibus sapien non lacinia ultricies. Integer fermentum tortor at
|
|
33
|
-
pellentesque faucibus. In venenatis commodo placerat. Curabitur commodo tortor libero, vel
|
|
34
|
-
pellentesque elit luctus sodales. Donec mattis tristique nunc ac lacinia. Vestibulum non
|
|
35
|
-
pulvinar turpis, posuere consequat arcu. Fusce ut urna blandit, finibus nisi a, molestie elit.
|
|
36
|
-
Nulla sed eleifend mi.
|
|
37
|
-
</Text>
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
const handleToggleOpen = useCallback(() => setOpen((v) => !v), [])
|
|
41
|
-
|
|
42
|
-
useClickOutsideEvent(
|
|
43
|
-
() => setOpen(false),
|
|
44
|
-
() => [buttonElementRef.current, popoverElementRef.current],
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<Card height="fill" padding={[4, 5, 6]} sizing="border" tone="transparent">
|
|
49
|
-
<Card ref={setBoundaryElement} height="fill" padding={2} shadow={1} sizing="border">
|
|
50
|
-
<Flex align={flexAlign} height="fill" justify={flexJustify}>
|
|
51
|
-
<Popover
|
|
52
|
-
ref={popoverElementRef}
|
|
53
|
-
constrainSize={constrainSize}
|
|
54
|
-
content={content}
|
|
55
|
-
floatingBoundary={boundaryElement}
|
|
56
|
-
open={open}
|
|
57
|
-
overflow="auto"
|
|
58
|
-
padding={3}
|
|
59
|
-
placement={placement}
|
|
60
|
-
portal={portal}
|
|
61
|
-
width={width}
|
|
62
|
-
>
|
|
63
|
-
<Button
|
|
64
|
-
ref={buttonElementRef}
|
|
65
|
-
icon={EllipsisVerticalIcon}
|
|
66
|
-
mode="bleed"
|
|
67
|
-
selected={open}
|
|
68
|
-
onClick={handleToggleOpen}
|
|
69
|
-
/>
|
|
70
|
-
</Popover>
|
|
71
|
-
</Flex>
|
|
72
|
-
</Card>
|
|
73
|
-
</Card>
|
|
74
|
-
)
|
|
75
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {Box, Card, Container, Flex, Popover, Text} from '@sanity/ui'
|
|
2
|
-
|
|
3
|
-
export default function MarginsStory(): React.JSX.Element {
|
|
4
|
-
return (
|
|
5
|
-
<Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
|
|
6
|
-
<Popover
|
|
7
|
-
__unstable_margins={[-8, 8, -8, 8]}
|
|
8
|
-
arrow={false}
|
|
9
|
-
content={
|
|
10
|
-
<Box padding={2}>
|
|
11
|
-
<Text align="center" muted size={1}>
|
|
12
|
-
Popover
|
|
13
|
-
</Text>
|
|
14
|
-
</Box>
|
|
15
|
-
}
|
|
16
|
-
matchReferenceWidth
|
|
17
|
-
open
|
|
18
|
-
placement="bottom-start"
|
|
19
|
-
// radius={0}
|
|
20
|
-
>
|
|
21
|
-
<Container width={0}>
|
|
22
|
-
<Card muted padding={2} shadow={1}>
|
|
23
|
-
<Text align="center" muted size={1}>
|
|
24
|
-
Reference
|
|
25
|
-
</Text>
|
|
26
|
-
</Card>
|
|
27
|
-
</Container>
|
|
28
|
-
</Popover>
|
|
29
|
-
</Flex>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {Box, Button, Container, Flex, Popover, Stack, Text} from '@sanity/ui'
|
|
2
|
-
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
3
|
-
|
|
4
|
-
import {WORKSHOP_PLACEMENT_OPTIONS} from '$workshop'
|
|
5
|
-
|
|
6
|
-
export default function MatchReferenceWidthStory(): React.JSX.Element {
|
|
7
|
-
const arrow = useBoolean('Arrow', true)
|
|
8
|
-
const placement = useSelect('Placement', WORKSHOP_PLACEMENT_OPTIONS, 'bottom')
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
|
|
12
|
-
<Popover
|
|
13
|
-
arrow={arrow}
|
|
14
|
-
content={
|
|
15
|
-
<Box padding={3}>
|
|
16
|
-
<Text size={1}>Content</Text>
|
|
17
|
-
</Box>
|
|
18
|
-
}
|
|
19
|
-
matchReferenceWidth
|
|
20
|
-
open
|
|
21
|
-
placement={placement}
|
|
22
|
-
radius={2}
|
|
23
|
-
>
|
|
24
|
-
<Container width={0}>
|
|
25
|
-
<Stack>
|
|
26
|
-
<Button fontSize={1} mode="ghost" selected text="Button" />
|
|
27
|
-
</Stack>
|
|
28
|
-
</Container>
|
|
29
|
-
</Popover>
|
|
30
|
-
</Flex>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {Button, Card, Popover, Text} from '@sanity/ui'
|
|
2
|
-
|
|
3
|
-
export default function OpenOnMountStory(): React.JSX.Element {
|
|
4
|
-
return (
|
|
5
|
-
<Card height="fill" padding={3} sizing="border">
|
|
6
|
-
<Popover content={<Text size={1}>popover content</Text>} open padding={3} tone="default">
|
|
7
|
-
<Button text="This button is the popover reference" />
|
|
8
|
-
</Popover>
|
|
9
|
-
</Card>
|
|
10
|
-
)
|
|
11
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {Button, Card, CONTAINER, Popover, PortalProvider, RADIUS, SPACE, Text} from '@sanity/ui'
|
|
2
|
-
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
3
|
-
import {useState} from 'react'
|
|
4
|
-
|
|
5
|
-
import {WORKSHOP_PLACEMENT_OPTIONS} from '$workshop'
|
|
6
|
-
|
|
7
|
-
export default function PlainStory(): React.JSX.Element {
|
|
8
|
-
const arrow = useBoolean('Arrow', true)
|
|
9
|
-
const boundaryElementFlag = useBoolean('Boundary element', true)
|
|
10
|
-
const constrainSize = useBoolean('Constrain size', true)
|
|
11
|
-
const matchReferenceWidth = useBoolean('Match reference width', false)
|
|
12
|
-
const open = useBoolean('Open', true)
|
|
13
|
-
const padding = useSelect('Padding', SPACE, 3)
|
|
14
|
-
const placement = useSelect('Placement', WORKSHOP_PLACEMENT_OPTIONS, 'bottom')
|
|
15
|
-
const portal = useBoolean('Portal', true)
|
|
16
|
-
const preventOverflow = useBoolean('Prevent overflow', true)
|
|
17
|
-
const radius = useSelect('Radius', RADIUS, 2)
|
|
18
|
-
const width = useSelect('Width', CONTAINER, 'auto')
|
|
19
|
-
|
|
20
|
-
const [portalElement, setPortalElement] = useState<HTMLDivElement | null>(null)
|
|
21
|
-
const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<Card height="fill" padding={3} sizing="border">
|
|
25
|
-
<PortalProvider element={portalElement}>
|
|
26
|
-
<Text align="center" muted size={1}>
|
|
27
|
-
Scroll this box to reveal the popover
|
|
28
|
-
</Text>
|
|
29
|
-
<div
|
|
30
|
-
ref={setBoundaryElement}
|
|
31
|
-
style={{
|
|
32
|
-
height: 'calc(100vh - 120px)',
|
|
33
|
-
position: 'absolute',
|
|
34
|
-
top: 0,
|
|
35
|
-
left: 0,
|
|
36
|
-
margin: 60,
|
|
37
|
-
overflow: 'auto',
|
|
38
|
-
outline: '1px solid red',
|
|
39
|
-
width: 'calc(100vw - 120px)',
|
|
40
|
-
}}
|
|
41
|
-
>
|
|
42
|
-
<div style={{padding: '150vh 0', textAlign: 'center'}}>
|
|
43
|
-
<Popover
|
|
44
|
-
__unstable_margins={[1, 1, 1, 1]}
|
|
45
|
-
arrow={arrow}
|
|
46
|
-
constrainSize={constrainSize}
|
|
47
|
-
content={<Text size={1}>popover content</Text>}
|
|
48
|
-
fallbackPlacements={['top', 'bottom']}
|
|
49
|
-
floatingBoundary={boundaryElementFlag ? boundaryElement : undefined}
|
|
50
|
-
matchReferenceWidth={matchReferenceWidth}
|
|
51
|
-
open={open}
|
|
52
|
-
padding={padding}
|
|
53
|
-
placement={placement}
|
|
54
|
-
portal={portal}
|
|
55
|
-
preventOverflow={preventOverflow}
|
|
56
|
-
radius={radius}
|
|
57
|
-
width={width}
|
|
58
|
-
>
|
|
59
|
-
<Button text="This button is the popover reference" />
|
|
60
|
-
</Popover>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
<div ref={setPortalElement} />
|
|
64
|
-
</PortalProvider>
|
|
65
|
-
</Card>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import {Button, Flex, LayerProvider, type Placement, Popover, useLayer} from '@sanity/ui'
|
|
2
|
-
import {CARD_TONES} from '@sanity/ui'
|
|
3
|
-
import {useCallback, useEffect, useMemo, useRef, useState} from 'react'
|
|
4
|
-
|
|
5
|
-
export default function RecursiveStory(): React.JSX.Element {
|
|
6
|
-
return (
|
|
7
|
-
<Flex align="center" height="fill" justify="center" padding={[4, 5, 6]} sizing="border">
|
|
8
|
-
<LayerProvider>
|
|
9
|
-
<RecursiveExample />
|
|
10
|
-
</LayerProvider>
|
|
11
|
-
</Flex>
|
|
12
|
-
)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const placements: Placement[] = ['top', 'right', 'bottom', 'left']
|
|
16
|
-
|
|
17
|
-
function RecursiveExample({onClose}: {onClose?: () => void}) {
|
|
18
|
-
const [open, setOpen] = useState(false)
|
|
19
|
-
const buttonRef = useRef<HTMLButtonElement | null>(null)
|
|
20
|
-
const {isTopLayer} = useLayer()
|
|
21
|
-
const [toneSeed] = useState(() => Math.floor(Math.random() * CARD_TONES.length))
|
|
22
|
-
const [placementSeed] = useState(() => Math.floor(Math.random() * placements.length))
|
|
23
|
-
const fallbackPlacements = useMemo(() => {
|
|
24
|
-
const before = placements.slice(placementSeed)
|
|
25
|
-
const after = placements.slice(0, placementSeed)
|
|
26
|
-
|
|
27
|
-
return before.concat(after)
|
|
28
|
-
}, [placementSeed])
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (open === false) buttonRef.current?.focus()
|
|
32
|
-
}, [open])
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
setTimeout(() => {
|
|
36
|
-
buttonRef.current?.focus()
|
|
37
|
-
}, 0)
|
|
38
|
-
}, [])
|
|
39
|
-
|
|
40
|
-
const handleOpen = useCallback(() => setOpen(true), [])
|
|
41
|
-
const handleClose = useCallback(() => setOpen(false), [])
|
|
42
|
-
|
|
43
|
-
const handleKeyDown = useCallback(
|
|
44
|
-
(event: React.KeyboardEvent<HTMLButtonElement>) => {
|
|
45
|
-
if (!isTopLayer) return
|
|
46
|
-
if (event.key === 'Escape' && onClose) onClose()
|
|
47
|
-
},
|
|
48
|
-
[isTopLayer, onClose],
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<Popover
|
|
53
|
-
content={<RecursiveExample onClose={handleClose} />}
|
|
54
|
-
fallbackPlacements={fallbackPlacements}
|
|
55
|
-
open={open}
|
|
56
|
-
padding={1}
|
|
57
|
-
placement={fallbackPlacements[3]}
|
|
58
|
-
portal
|
|
59
|
-
tone={CARD_TONES[toneSeed]}
|
|
60
|
-
>
|
|
61
|
-
<Button
|
|
62
|
-
ref={buttonRef}
|
|
63
|
-
// disabled={!isTopLayer}
|
|
64
|
-
mode="bleed"
|
|
65
|
-
text="Open"
|
|
66
|
-
onClick={handleOpen}
|
|
67
|
-
onKeyDown={handleKeyDown}
|
|
68
|
-
/>
|
|
69
|
-
</Popover>
|
|
70
|
-
)
|
|
71
|
-
}
|