@sanity/ui 3.0.0-static.33 → 3.0.0-static.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/_chunks-cjs/_visual-editing.cjs +263 -375
- package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
- package/dist/_chunks-cjs/refractor.cjs.map +1 -1
- package/dist/_chunks-es/_visual-editing.js +263 -377
- package/dist/_chunks-es/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/refractor.js.map +1 -1
- package/dist/_visual-editing.cjs +0 -2
- package/dist/_visual-editing.cjs.map +1 -1
- package/dist/_visual-editing.d.cts +34 -85
- package/dist/_visual-editing.d.ts +34 -85
- package/dist/_visual-editing.js +2 -4
- package/dist/css/index.cjs +12 -12
- package/dist/css/index.cjs.map +1 -1
- package/dist/css/index.css +1 -1
- package/dist/css/index.d.cts +383 -13934
- package/dist/css/index.d.ts +383 -13934
- package/dist/css/index.js +12 -12
- package/dist/css/index.js.map +1 -1
- package/dist/index.cjs +241 -366
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +107 -817
- package/dist/index.d.ts +107 -817
- package/dist/index.js +243 -360
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs +367 -4288
- package/dist/theme.cjs.map +1 -1
- package/dist/theme.d.cts +180 -1582
- package/dist/theme.d.ts +180 -1582
- package/dist/theme.js +371 -4292
- package/dist/theme.js.map +1 -1
- package/exports/_visual-editing.ts +0 -2
- package/package.json +3 -4
- package/src/core/Root.tsx +4 -2
- package/src/core/RootProvider.tsx +4 -4
- package/src/core/__workshop__/boundary.tsx +1 -1
- package/src/core/__workshop__/index.ts +5 -3
- package/src/core/components/autocomplete/__workshop__/async.tsx +1 -1
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
- package/src/core/components/autocomplete/__workshop__/custom.tsx +2 -2
- package/src/core/components/autocomplete/__workshop__/example.tsx +2 -2
- package/src/core/components/autocomplete/__workshop__/focusAndBlur.tsx +1 -1
- package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +1 -1
- package/src/core/components/autocomplete/__workshop__/index.ts +5 -3
- package/src/core/components/autocomplete/__workshop__/mock/apiStore.ts +1 -1
- package/src/core/components/autocomplete/__workshop__/mock/countries.ts +1 -1
- package/src/core/components/autocomplete/autocomplete.tsx +2 -2
- package/src/core/components/autocomplete/autocompleteOption.tsx +2 -2
- package/src/core/components/autocomplete/constants.ts +2 -2
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +1 -1
- package/src/core/components/breadcrumbs/__workshop__/index.ts +5 -3
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +6 -11
- package/src/core/components/dialog/__workshop__/activate.tsx +1 -1
- package/src/core/components/dialog/__workshop__/autoFocus.tsx +1 -1
- package/src/core/components/dialog/__workshop__/index.ts +5 -3
- package/src/core/components/dialog/__workshop__/layering.tsx +1 -1
- package/src/core/components/dialog/__workshop__/nested.tsx +2 -3
- package/src/core/components/dialog/__workshop__/onScroll.tsx +1 -1
- package/src/core/components/dialog/__workshop__/panes.tsx +1 -1
- package/src/core/components/dialog/__workshop__/position.tsx +1 -1
- package/src/core/components/dialog/__workshop__/props.tsx +1 -1
- package/src/core/components/dialog/__workshop__/provider.tsx +1 -1
- package/src/core/components/dialog/__workshop__/wrapped.tsx +1 -1
- package/src/core/components/dialog/dialog.tsx +5 -6
- package/src/core/components/dialog/dialogCard.tsx +2 -2
- package/src/core/components/dialog/dialogContext.ts +3 -4
- package/src/core/components/dialog/dialogProvider.tsx +2 -2
- package/src/core/components/hotkeys/__workshop__/index.ts +5 -3
- package/src/core/components/hotkeys/__workshop__/plain.tsx +1 -1
- package/src/core/components/hotkeys/hotkeys.tsx +4 -15
- package/src/core/components/menu/__workshop__/asComponent.tsx +1 -1
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +1 -1
- package/src/core/components/menu/__workshop__/closableMenuButton.tsx +1 -1
- package/src/core/components/menu/__workshop__/constrainedInBoundary.tsx +3 -3
- package/src/core/components/menu/__workshop__/customMenuItem.tsx +1 -1
- package/src/core/components/menu/__workshop__/customSelectedState.tsx +1 -1
- package/src/core/components/menu/__workshop__/disableFocusOnClose.tsx +1 -1
- package/src/core/components/menu/__workshop__/groups.tsx +1 -1
- package/src/core/components/menu/__workshop__/index.ts +5 -3
- package/src/core/components/menu/__workshop__/menuButton.tsx +2 -2
- package/src/core/components/menu/__workshop__/menuGroupRight.tsx +1 -1
- package/src/core/components/menu/__workshop__/nestedMenu.tsx +1 -1
- package/src/core/components/menu/__workshop__/onCloseMenuButton.tsx +1 -1
- package/src/core/components/menu/__workshop__/selectedItem.tsx +1 -1
- package/src/core/components/menu/__workshop__/shouldFocus.tsx +1 -1
- package/src/core/components/menu/__workshop__/tones.tsx +3 -3
- package/src/core/components/menu/__workshop__/withoutArrow.tsx +1 -1
- package/src/core/components/menu/menu.test.tsx +2 -1
- package/src/core/components/menu/menu.tsx +7 -22
- package/src/core/components/menu/menuButton.tsx +4 -50
- package/src/core/components/menu/menuContext.ts +3 -15
- package/src/core/components/menu/menuDivider.tsx +2 -2
- package/src/core/components/menu/menuGroup.tsx +10 -15
- package/src/core/components/menu/menuItem.tsx +7 -18
- package/src/core/components/tab/__workshop__/example.tsx +1 -1
- package/src/core/components/tab/__workshop__/index.ts +5 -3
- package/src/core/components/tab/tab.tsx +6 -4
- package/src/core/components/tab/tabList.tsx +3 -8
- package/src/core/components/tab/tabPanel.tsx +2 -2
- package/src/core/components/toast/__workshop__/hook.tsx +1 -1
- package/src/core/components/toast/__workshop__/index.ts +5 -3
- package/src/core/components/toast/__workshop__/toast.tsx +1 -1
- package/src/core/components/toast/toast.test.tsx +2 -1
- package/src/core/components/toast/toast.tsx +2 -2
- package/src/core/components/toast/toastContext.ts +4 -4
- package/src/core/components/toast/toastLayer.tsx +3 -3
- package/src/core/components/tree/__workshop__/basic.perf.ts +1 -1
- package/src/core/components/tree/__workshop__/basic.tsx +1 -1
- package/src/core/components/tree/__workshop__/index.ts +5 -3
- package/src/core/components/tree/__workshop__/tabFromElement.tsx +1 -1
- package/src/core/components/tree/tree.tsx +8 -9
- package/src/core/components/tree/treeContext.ts +4 -4
- package/src/core/components/tree/treeGroup.tsx +6 -8
- package/src/core/components/tree/treeItem.tsx +4 -4
- package/src/core/components/tree/types.ts +1 -1
- package/src/core/components/virtualList/__workshop__/changingProps.tsx +1 -1
- package/src/core/components/virtualList/__workshop__/elementScroll.tsx +1 -1
- package/src/core/components/virtualList/__workshop__/index.ts +5 -3
- package/src/core/components/virtualList/__workshop__/infiniteList.tsx +1 -1
- package/src/core/components/virtualList/__workshop__/windowScrolll.tsx +1 -1
- package/src/core/components/virtualList/virtualList.tsx +2 -2
- package/src/core/constants.ts +0 -18
- package/src/core/hooks/useMediaIndex/__workshop__/index.ts +5 -3
- package/src/core/hooks/useMediaIndex/__workshop__/test.tsx +1 -1
- package/src/core/hooks/useMediaIndex/useMediaIndex.ts +6 -1
- package/src/core/index.ts +1 -24
- package/src/core/lib/createGlobalScopedContext.ts +1 -1
- package/src/core/lib/globalScope.ts +1 -1
- package/src/core/observers/elementSize.ts +1 -1
- package/src/core/primitives/arrow/arrow.tsx +2 -2
- package/src/core/primitives/avatar/__workshop__/asButton.tsx +1 -1
- package/src/core/primitives/avatar/__workshop__/index.ts +5 -3
- package/src/core/primitives/avatar/__workshop__/stack.tsx +1 -1
- package/src/core/primitives/avatar/__workshop__/withinButton.tsx +1 -1
- package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +1 -1
- package/src/core/primitives/avatar/avatar.tsx +3 -10
- package/src/core/primitives/avatar/avatarCounter.tsx +2 -2
- package/src/core/primitives/avatar/avatarStack.tsx +2 -4
- package/src/core/primitives/avatar/types.ts +0 -32
- package/src/core/primitives/badge/__workshop__/index.ts +5 -3
- package/src/core/primitives/badge/__workshop__/props.tsx +1 -1
- package/src/core/primitives/badge/__workshop__/tones.tsx +3 -3
- package/src/core/primitives/badge/badge.test.tsx +2 -1
- package/src/core/primitives/badge/badge.tsx +12 -11
- package/src/core/primitives/box/__workshop__/index.ts +5 -3
- package/src/core/primitives/box/__workshop__/props.tsx +1 -1
- package/src/core/primitives/box/__workshop__/responsive.tsx +1 -1
- package/src/core/primitives/box/box.tsx +28 -32
- package/src/core/primitives/button/__workshop__/custom.tsx +5 -5
- package/src/core/primitives/button/__workshop__/customIcons.tsx +1 -1
- package/src/core/primitives/button/__workshop__/disabled.tsx +3 -3
- package/src/core/primitives/button/__workshop__/index.ts +5 -3
- package/src/core/primitives/button/__workshop__/mixedChildren.tsx +1 -1
- package/src/core/primitives/button/__workshop__/props.tsx +1 -1
- package/src/core/primitives/button/__workshop__/sanityUploadButton.tsx +1 -1
- package/src/core/primitives/button/__workshop__/stacked.tsx +1 -1
- package/src/core/primitives/button/__workshop__/styled1.tsx +1 -1
- package/src/core/primitives/button/__workshop__/styled2.tsx +1 -1
- package/src/core/primitives/button/__workshop__/textOverflow.tsx +1 -1
- package/src/core/primitives/button/__workshop__/uploadButton.tsx +1 -1
- package/src/core/primitives/button/button.test.tsx +2 -1
- package/src/core/primitives/button/button.tsx +4 -7
- package/src/core/primitives/button/types.ts +0 -20
- package/src/core/primitives/card/__workshop__/asButton.tsx +2 -2
- package/src/core/primitives/card/__workshop__/asComponent.tsx +1 -1
- package/src/core/primitives/card/__workshop__/checkered.tsx +3 -3
- package/src/core/primitives/card/__workshop__/index.ts +5 -3
- package/src/core/primitives/card/__workshop__/interactive.tsx +1 -1
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +1 -1
- package/src/core/primitives/card/__workshop__/props.tsx +1 -1
- package/src/core/primitives/card/__workshop__/selected.tsx +1 -1
- package/src/core/primitives/card/__workshop__/styled.tsx +1 -1
- package/src/core/primitives/card/__workshop__/tones.tsx +3 -3
- package/src/core/primitives/card/card.tsx +4 -2
- package/src/core/primitives/card/cardContext.ts +1 -1
- package/src/core/primitives/card/cardProvider.tsx +4 -4
- package/src/core/primitives/card/types.ts +5 -19
- package/src/core/primitives/checkbox/__workshop__/example.tsx +1 -1
- package/src/core/primitives/checkbox/__workshop__/index.ts +5 -3
- package/src/core/primitives/checkbox/__workshop__/props.tsx +1 -1
- package/src/core/primitives/checkbox/__workshop__/readOnly.tsx +1 -1
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +3 -3
- package/src/core/primitives/checkbox/checkbox.tsx +2 -2
- package/src/core/primitives/code/__workshop__/index.ts +5 -3
- package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +1 -1
- package/src/core/primitives/code/__workshop__/props.tsx +1 -1
- package/src/core/primitives/code/code.tsx +4 -2
- package/src/core/primitives/code/refractor.tsx +1 -1
- package/src/core/primitives/container/__workshop__/example.tsx +1 -1
- package/src/core/primitives/container/__workshop__/index.ts +5 -3
- package/src/core/primitives/container/container.tsx +2 -2
- package/src/core/primitives/flex/__workshop__/example.tsx +1 -1
- package/src/core/primitives/flex/__workshop__/gap.tsx +1 -1
- package/src/core/primitives/flex/__workshop__/index.ts +5 -3
- package/src/core/primitives/flex/flex.tsx +4 -2
- package/src/core/primitives/grid/__workshop__/index.ts +5 -3
- package/src/core/primitives/grid/__workshop__/responsive.tsx +3 -3
- package/src/core/primitives/grid/grid.tsx +4 -2
- package/src/core/primitives/heading/__workshop__/index.ts +5 -3
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +1 -1
- package/src/core/primitives/heading/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/heading/heading.tsx +2 -4
- package/src/core/primitives/inline/__workshop__/index.ts +5 -3
- package/src/core/primitives/inline/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/inline/inline.tsx +4 -11
- package/src/core/primitives/kbd/__workshop__/index.ts +5 -3
- package/src/core/primitives/kbd/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/kbd/kbd.tsx +4 -2
- package/src/core/primitives/label/__workshop__/index.ts +5 -3
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +1 -1
- package/src/core/primitives/label/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/label/label.tsx +2 -4
- package/src/core/primitives/layer/__workshop__/_debug.tsx +1 -1
- package/src/core/primitives/layer/__workshop__/index.ts +5 -3
- package/src/core/primitives/layer/__workshop__/multipleRoots.tsx +1 -1
- package/src/core/primitives/layer/__workshop__/nested.tsx +1 -1
- package/src/core/primitives/layer/__workshop__/responsiveZOffset.tsx +1 -1
- package/src/core/primitives/layer/layer.test.tsx +2 -1
- package/src/core/primitives/layer/layer.tsx +2 -2
- package/src/core/primitives/layer/layerCard.tsx +2 -2
- package/src/core/primitives/layer/layerContext.ts +4 -4
- package/src/core/primitives/layer/layerProvider.tsx +2 -10
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +2 -2
- package/src/core/primitives/popover/__workshop__/MarginsStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +2 -2
- package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +3 -3
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +3 -3
- package/src/core/primitives/popover/__workshop__/index.ts +5 -3
- package/src/core/primitives/popover/popover.tsx +4 -9
- package/src/core/primitives/popover/popoverLayer.tsx +2 -2
- package/src/core/primitives/radio/__workshop__/example.tsx +1 -1
- package/src/core/primitives/radio/__workshop__/index.ts +5 -3
- package/src/core/primitives/radio/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/radio/radio.tsx +2 -2
- package/src/core/primitives/select/__workshop__/index.ts +5 -3
- package/src/core/primitives/select/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/select/__workshop__/readOnly.tsx +1 -1
- package/src/core/primitives/select/select.tsx +5 -15
- package/src/core/primitives/selectable/selectable.tsx +4 -4
- package/src/core/primitives/skeleton/__workshop__/delay.tsx +1 -1
- package/src/core/primitives/skeleton/__workshop__/index.ts +5 -3
- package/src/core/primitives/skeleton/__workshop__/skeleton.tsx +2 -2
- package/src/core/primitives/skeleton/codeSkeleton.tsx +2 -2
- package/src/core/primitives/skeleton/headingSkeleton.tsx +2 -2
- package/src/core/primitives/skeleton/labelSkeleton.tsx +2 -2
- package/src/core/primitives/skeleton/skeleton.tsx +2 -2
- package/src/core/primitives/skeleton/textSkeleton.tsx +2 -2
- package/src/core/primitives/spinner/__workshop__/Props.tsx +1 -1
- package/src/core/primitives/spinner/__workshop__/index.ts +5 -3
- package/src/core/primitives/spinner/animatedSpinnerIcon.tsx +2 -2
- package/src/core/primitives/spinner/spinner.tsx +2 -2
- package/src/core/primitives/srOnly/srOnly.tsx +2 -2
- package/src/core/primitives/stack/__workshop__/index.ts +5 -3
- package/src/core/primitives/stack/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/stack/stack.tsx +5 -10
- package/src/core/primitives/switch/__workshop__/example.tsx +1 -1
- package/src/core/primitives/switch/__workshop__/index.ts +5 -3
- package/src/core/primitives/switch/__workshop__/props.tsx +1 -1
- package/src/core/primitives/switch/switch.tsx +2 -2
- package/src/core/primitives/text/__workshop__/colored.tsx +1 -1
- package/src/core/primitives/text/__workshop__/example.tsx +1 -1
- package/src/core/primitives/text/__workshop__/index.ts +5 -3
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +1 -1
- package/src/core/primitives/text/text.tsx +4 -4
- package/src/core/primitives/textArea/__workshop__/index.ts +5 -3
- package/src/core/primitives/textArea/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/textArea/textArea.tsx +5 -15
- package/src/core/primitives/textInput/__workshop__/clearButton.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/customValidity.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/index.ts +5 -3
- package/src/core/primitives/textInput/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/states.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/tones.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/typed.tsx +1 -1
- package/src/core/primitives/textInput/textInput.tsx +6 -9
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +1 -1
- package/src/core/primitives/tooltip/__workshop__/index.ts +5 -3
- package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +1 -1
- package/src/core/primitives/tooltip/__workshop__/props.tsx +1 -1
- package/src/core/primitives/tooltip/__workshop__/resizableBoundary.tsx +1 -1
- package/src/core/primitives/tooltip/constants.ts +1 -1
- package/src/core/primitives/tooltip/tooltip.test.tsx +2 -4
- package/src/core/primitives/tooltip/tooltip.tsx +5 -9
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupContext.tsx +4 -2
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +5 -3
- package/src/core/primitives/tooltip/tooltipLayer.tsx +2 -2
- package/src/core/{types/props.ts → types.ts} +27 -0
- package/src/core/utils/boundaryElement/__workshop__/index.ts +5 -3
- package/src/core/utils/boundaryElement/__workshop__/plain.tsx +1 -1
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +2 -1
- package/src/core/utils/boundaryElement/boundaryElementContext.ts +7 -4
- package/src/core/utils/boundaryElement/boundaryElementProvider.tsx +2 -2
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +1 -1
- package/src/core/utils/elementQuery/__workshop__/index.ts +5 -3
- package/src/core/utils/elementQuery/elementQuery.tsx +2 -2
- package/src/core/utils/getElementRef.ts +1 -1
- package/src/core/utils/portal/__workshop__/index.ts +5 -3
- package/src/core/utils/portal/__workshop__/named.tsx +1 -1
- package/src/core/utils/portal/portal.test.tsx +2 -1
- package/src/core/utils/portal/portalContext.ts +5 -2
- package/src/core/utils/portal/portalProvider.tsx +5 -9
- package/src/css/_responsiveClassName.ts +2 -2
- package/src/css/_style.css.ts +1 -1
- package/src/css/components/breadcrumbs/breadcrumbs.css.ts +1 -1
- package/src/css/components/dialog/dialog.css.ts +9 -17
- package/src/css/components/menu/menu.css.ts +2 -2
- package/src/css/components/menu/menu.ts +2 -2
- package/src/css/components/skeleton/skeleton.css.ts +2 -6
- package/src/css/components/toast/toast.css.ts +2 -2
- package/src/css/components/toast/toast.ts +2 -2
- package/src/css/components/tree/tree.css.ts +1 -1
- package/src/css/components/tree/tree.ts +1 -1
- package/src/css/defaultTheme.css.ts +59 -60
- package/src/css/layers.css.ts +4 -1
- package/src/css/primitives/_arrow/_arrow.css.ts +5 -5
- package/src/css/primitives/_input/_input.css.ts +4 -4
- package/src/css/primitives/_selectable/_selectable.css.ts +4 -4
- package/src/css/primitives/_selectable/types.ts +2 -2
- package/src/css/primitives/avatar/avatar.css.ts +10 -10
- package/src/css/primitives/badge/badge.css.ts +4 -4
- package/src/css/primitives/badge/types.ts +8 -2
- package/src/css/primitives/box/box.css.ts +2 -2
- package/src/css/primitives/button/button.css.ts +6 -6
- package/src/css/primitives/button/button.ts +2 -2
- package/src/css/primitives/button/types.ts +3 -3
- package/src/css/primitives/card/__workshop__/color.tsx +9 -9
- package/src/css/primitives/card/__workshop__/index.ts +5 -3
- package/src/css/primitives/card/card.css.ts +12 -18
- package/src/css/primitives/card/types.ts +3 -3
- package/src/css/primitives/checkbox/checkbox.css.ts +3 -3
- package/src/css/primitives/checkbox/checkbox.ts +3 -3
- package/src/css/primitives/code/code.css.ts +4 -3
- package/src/css/primitives/code/types.ts +3 -4
- package/src/css/primitives/container/container.css.ts +1 -1
- package/src/css/primitives/heading/heading.css.ts +5 -4
- package/src/css/primitives/heading/types.ts +3 -6
- package/src/css/primitives/kbd/kbd.css.ts +1 -1
- package/src/css/primitives/label/label.css.ts +5 -4
- package/src/css/primitives/label/types.ts +0 -8
- package/src/css/primitives/popover/popover.css.ts +2 -2
- package/src/css/primitives/popover/popover.ts +2 -2
- package/src/css/primitives/radio/radio.css.ts +3 -3
- package/src/css/primitives/radio/radio.ts +3 -3
- package/src/css/primitives/root/root.css.ts +1 -1
- package/src/css/primitives/root/root.ts +1 -1
- package/src/css/primitives/root/types.ts +3 -3
- package/src/css/primitives/select/select.css.ts +3 -3
- package/src/css/primitives/spinner/spinner.css.ts +2 -6
- package/src/css/primitives/spinner/spinner.ts +2 -2
- package/src/css/primitives/srOnly/srOnly.css.ts +1 -1
- package/src/css/primitives/srOnly/srOnly.ts +1 -1
- package/src/css/primitives/stack/stack.css.ts +1 -1
- package/src/css/primitives/stack/stack.ts +1 -1
- package/src/css/primitives/switch/switch.css.ts +5 -5
- package/src/css/primitives/text/text.css.ts +5 -4
- package/src/css/primitives/text/types.ts +3 -5
- package/src/css/primitives/textArea/textArea.css.ts +1 -1
- package/src/css/primitives/textInput/textInput.css.ts +4 -4
- package/src/css/primitives/tooltip/tooltip.css.ts +1 -1
- package/src/css/props/alignItems/alignItems.ts +1 -1
- package/src/css/props/border/border.ts +1 -16
- package/src/css/props/boxSizing/boxSizing.css.ts +2 -1
- package/src/css/props/boxSizing/boxSizing.ts +0 -3
- package/src/css/props/display/display.ts +1 -10
- package/src/css/props/flex/flex.ts +1 -1
- package/src/css/props/flexDirection/flexDirection.ts +1 -1
- package/src/css/props/flexWrap/flexWrap.ts +1 -1
- package/src/css/props/font/font.css.ts +3 -2
- package/src/css/props/font/font.ts +1 -1
- package/src/css/props/gap/gap.ts +1 -1
- package/src/css/props/gridAutoColumns/gridAutoColumns.css.ts +2 -2
- package/src/css/props/gridAutoColumns/gridAutoColumns.ts +2 -2
- package/src/css/props/gridAutoColumns/types.ts +0 -10
- package/src/css/props/gridAutoFlow/gridAutoFlow.ts +2 -2
- package/src/css/props/gridAutoFlow/types.ts +0 -4
- package/src/css/props/gridAutoRows/gridAutoRows.ts +2 -2
- package/src/css/props/gridAutoRows/types.ts +0 -4
- package/src/css/props/gridColumn/gridColumn.ts +3 -3
- package/src/css/props/gridColumn/types.ts +0 -10
- package/src/css/props/gridColumnEnd/gridColumnEnd.ts +3 -3
- package/src/css/props/gridColumnEnd/types.ts +0 -10
- package/src/css/props/gridColumnStart/gridColumnStart.ts +3 -6
- package/src/css/props/gridColumnStart/types.ts +0 -10
- package/src/css/props/gridRow/gridRow.ts +3 -3
- package/src/css/props/gridRow/types.ts +0 -10
- package/src/css/props/gridRowEnd/gridRowEnd.ts +3 -3
- package/src/css/props/gridRowEnd/types.ts +0 -10
- package/src/css/props/gridRowStart/gridRowStart.ts +3 -3
- package/src/css/props/gridRowStart/types.ts +0 -10
- package/src/css/props/gridTemplateColumns/gridTemplateColumns.ts +2 -2
- package/src/css/props/gridTemplateColumns/types.ts +0 -10
- package/src/css/props/gridTemplateRows/gridTemplateRows.ts +2 -2
- package/src/css/props/gridTemplateRows/types.ts +0 -10
- package/src/css/props/height/height.ts +1 -1
- package/src/css/props/height/types.ts +0 -6
- package/src/css/props/inset/inset.ts +1 -1
- package/src/css/props/justifyContent/justifyContent.ts +1 -1
- package/src/css/props/margin/margin.ts +1 -1
- package/src/css/props/maxWidth/maxWidth.ts +1 -1
- package/src/css/props/minHeight/minHeight.ts +1 -1
- package/src/css/props/minWidth/minWidth.ts +1 -1
- package/src/css/props/outline/outline.ts +1 -1
- package/src/css/props/overflow/overflow.ts +1 -1
- package/src/css/props/overflow/types.ts +0 -6
- package/src/css/props/padding/padding.ts +1 -1
- package/src/css/props/pointerEvents/pointerEvents.ts +1 -1
- package/src/css/props/position/position.ts +1 -1
- package/src/css/props/radius/radius.ts +1 -1
- package/src/css/props/shadow/shadow.ts +1 -1
- package/src/css/props/textAlign/textAlign.ts +1 -1
- package/src/css/props/textOverflow/textOverflow.ts +1 -1
- package/src/css/props/width/width.ts +1 -1
- package/src/css/types.ts +225 -53
- package/src/css/util.ts +2 -2
- package/src/css/vars.css.ts +33 -36
- package/src/theme/{v3/_parseColorToken.ts → _parseColorToken.ts} +2 -2
- package/src/theme/buildTheme.ts +33 -0
- package/src/theme/constants.ts +90 -0
- package/src/theme/defaults/color.ts +197 -0
- package/src/theme/{v2/defaults/config.ts → defaults/common.ts} +3 -16
- package/src/theme/{v3/defaultFonts.ts → defaults/fonts.ts} +2 -2
- package/src/theme/index.ts +4 -5
- package/src/theme/{v3/resolveTokens.ts → resolveTokens.ts} +15 -15
- package/src/theme/types.ts +355 -15
- package/src/core/__DEV__.ts +0 -5
- package/src/core/_compat/helpers.ts +0 -72
- package/src/core/_compat/styles/_responsive.ts +0 -19
- package/src/core/_compat/theme/theme.test.tsx +0 -73
- package/src/core/_compat/theme/themeColorProvider.tsx +0 -24
- package/src/core/_compat/theme/themeContext.ts +0 -10
- package/src/core/_compat/theme/themeProvider.tsx +0 -68
- package/src/core/_compat/theme/types.ts +0 -10
- package/src/core/_compat/theme/useRootTheme.ts +0 -15
- package/src/core/_compat/theme/useTheme.ts +0 -12
- package/src/core/_compat/types.ts +0 -191
- package/src/core/hooks/useArrayProp.ts +0 -26
- package/src/core/hooks/useClickOutside.test.tsx +0 -481
- package/src/core/hooks/useClickOutside.ts +0 -113
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +0 -30
- package/src/core/hooks/useElementRect/__workshop__/index.ts +0 -14
- package/src/core/hooks/useElementRect/useElementRect.ts +0 -13
- package/src/core/hooks/useForwardedRef.ts +0 -19
- package/src/core/hooks/useIsomorphicEffect.ts +0 -7
- package/src/core/primitives/badge/types.ts +0 -18
- package/src/core/primitives/box/types.ts +0 -22
- package/src/core/primitives/flex/types.ts +0 -27
- package/src/core/primitives/grid/types.ts +0 -17
- package/src/core/primitives/selectable/types.ts +0 -7
- package/src/core/primitives/types.ts +0 -153
- package/src/core/types/gridItem.ts +0 -32
- package/src/core/types/placement.ts +0 -18
- package/src/core/types/radius.ts +0 -7
- package/src/core/types/textAlign.ts +0 -7
- package/src/core/utils/spanWithTextOverflow.tsx +0 -10
- package/src/theme/getScopedTheme.ts +0 -88
- package/src/theme/v0/avatar.ts +0 -10
- package/src/theme/v0/color/_generic.ts +0 -35
- package/src/theme/v0/color/_system.ts +0 -17
- package/src/theme/v0/color/base.ts +0 -21
- package/src/theme/v0/color/button.ts +0 -42
- package/src/theme/v0/color/card.ts +0 -19
- package/src/theme/v0/color/color.ts +0 -40
- package/src/theme/v0/color/index.ts +0 -11
- package/src/theme/v0/color/input.ts +0 -34
- package/src/theme/v0/color/muted.ts +0 -26
- package/src/theme/v0/color/selectable.ts +0 -31
- package/src/theme/v0/color/solid.ts +0 -26
- package/src/theme/v0/color/spot.ts +0 -13
- package/src/theme/v0/css.ts +0 -10
- package/src/theme/v0/focusRing.ts +0 -5
- package/src/theme/v0/font.ts +0 -40
- package/src/theme/v0/index.ts +0 -10
- package/src/theme/v0/input.ts +0 -23
- package/src/theme/v0/layer.ts +0 -6
- package/src/theme/v0/shadow.ts +0 -15
- package/src/theme/v0/styles.ts +0 -13
- package/src/theme/v0/theme.ts +0 -72
- package/src/theme/v2/avatar.ts +0 -12
- package/src/theme/v2/build/_deprecated/color/_selectable/createSelectableTones.ts +0 -76
- package/src/theme/v2/build/_deprecated/color/_solid/createSolidTones.ts +0 -54
- package/src/theme/v2/build/_deprecated/color/button/createButtonModes.ts +0 -22
- package/src/theme/v2/build/_deprecated/color/button/createButtonTones.ts +0 -55
- package/src/theme/v2/build/_deprecated/color/card/createCardStates.ts +0 -60
- package/src/theme/v2/build/_deprecated/color/color.test.ts +0 -63
- package/src/theme/v2/build/_deprecated/color/defaults.ts +0 -390
- package/src/theme/v2/build/_deprecated/color/factory.ts +0 -141
- package/src/theme/v2/build/_deprecated/color/index.ts +0 -1
- package/src/theme/v2/build/_deprecated/color/input/createInputModes.ts +0 -86
- package/src/theme/v2/build/_deprecated/color/muted/createMuted.ts +0 -54
- package/src/theme/v2/build/_deprecated/color/spot/createSpot.ts +0 -20
- package/src/theme/v2/build/buildColorTheme.test.ts +0 -185
- package/src/theme/v2/build/buildColorTheme.ts +0 -494
- package/src/theme/v2/build/buildTheme.test.ts +0 -89
- package/src/theme/v2/build/buildTheme.ts +0 -37
- package/src/theme/v2/build/colorToken/colorToken.ts +0 -19
- package/src/theme/v2/build/colorToken/compileColorToken.ts +0 -21
- package/src/theme/v2/build/colorToken/index.ts +0 -2
- package/src/theme/v2/build/colorToken/types.ts +0 -6
- package/src/theme/v2/build/index.ts +0 -3
- package/src/theme/v2/build/lib/color-fns/blend/index.ts +0 -3
- package/src/theme/v2/build/lib/color-fns/blend/mix.ts +0 -21
- package/src/theme/v2/build/lib/color-fns/blend/multiply.ts +0 -18
- package/src/theme/v2/build/lib/color-fns/blend/screen.ts +0 -18
- package/src/theme/v2/build/lib/color-fns/color-fns.test.ts +0 -68
- package/src/theme/v2/build/lib/color-fns/contrastRatio.ts +0 -34
- package/src/theme/v2/build/lib/color-fns/convert.ts +0 -150
- package/src/theme/v2/build/lib/color-fns/index.ts +0 -6
- package/src/theme/v2/build/lib/color-fns/parse.ts +0 -60
- package/src/theme/v2/build/lib/color-fns/rgba.ts +0 -14
- package/src/theme/v2/build/lib/color-fns/types.ts +0 -28
- package/src/theme/v2/build/lib/isRecord.ts +0 -3
- package/src/theme/v2/build/lib/utils.ts +0 -19
- package/src/theme/v2/build/merge.ts +0 -28
- package/src/theme/v2/build/mixThemeColor.test.ts +0 -23
- package/src/theme/v2/build/mixThemeColor.ts +0 -53
- package/src/theme/v2/build/renderColorTheme.ts +0 -532
- package/src/theme/v2/build/renderColorValue.ts +0 -85
- package/src/theme/v2/build/resolveColorTokens.ts +0 -268
- package/src/theme/v2/color/_constants.ts +0 -45
- package/src/theme/v2/color/_helpers.ts +0 -24
- package/src/theme/v2/color/_system.ts +0 -38
- package/src/theme/v2/color/avatar.ts +0 -11
- package/src/theme/v2/color/badge.ts +0 -12
- package/src/theme/v2/color/button.ts +0 -11
- package/src/theme/v2/color/color.ts +0 -28
- package/src/theme/v2/color/index.ts +0 -13
- package/src/theme/v2/color/input.ts +0 -23
- package/src/theme/v2/color/kbd.ts +0 -6
- package/src/theme/v2/color/selectable.ts +0 -8
- package/src/theme/v2/color/shadow.ts +0 -7
- package/src/theme/v2/color/state.ts +0 -41
- package/src/theme/v2/color/syntax.ts +0 -39
- package/src/theme/v2/config/helpers.ts +0 -48
- package/src/theme/v2/config/index.ts +0 -4
- package/src/theme/v2/config/system.ts +0 -114
- package/src/theme/v2/config/tokens/color/index.ts +0 -1
- package/src/theme/v2/config/tokens/color/types.ts +0 -137
- package/src/theme/v2/config/tokens/index.ts +0 -3
- package/src/theme/v2/config/tokens/parseTokenValue.test.ts +0 -44
- package/src/theme/v2/config/tokens/parseTokenValue.ts +0 -133
- package/src/theme/v2/config/tokens/types.ts +0 -53
- package/src/theme/v2/config/types.ts +0 -47
- package/src/theme/v2/defaults/colorPalette.ts +0 -5
- package/src/theme/v2/defaults/colorTokens.ts +0 -648
- package/src/theme/v2/defaults/fonts.ts +0 -227
- package/src/theme/v2/index.ts +0 -6
- package/src/theme/v2/input.ts +0 -31
- package/src/theme/v2/theme.ts +0 -45
- package/src/theme/v3/_constants.ts +0 -29
- package/src/theme/v3/buildTheme_v3.ts +0 -39
- package/src/theme/v3/color/_constants.ts +0 -15
- package/src/theme/v3/color/avatar.ts +0 -14
- package/src/theme/v3/color/card.ts +0 -79
- package/src/theme/v3/color/color.ts +0 -98
- package/src/theme/v3/color/element.ts +0 -19
- package/src/theme/v3/color/index.ts +0 -7
- package/src/theme/v3/color/token.ts +0 -32
- package/src/theme/v3/color/tokens.ts +0 -5
- package/src/theme/v3/defaultTokens.ts +0 -199
- package/src/theme/v3/index.ts +0 -9
- package/src/theme/v3/palette/constants.ts +0 -15
- package/src/theme/v3/palette/index.ts +0 -2
- package/src/theme/v3/palette/types.ts +0 -7
- package/src/theme/v3/tokens.ts +0 -16
- package/src/theme/v3/types.ts +0 -133
- package/src/theme/versioning/getTheme_v2.ts +0 -58
- package/src/theme/versioning/index.ts +0 -1
- package/src/theme/versioning/is_v0.ts +0 -7
- package/src/theme/versioning/is_v2.ts +0 -7
- package/src/theme/versioning/themeColor_v0_v2.ts +0 -245
- package/src/theme/versioning/themeColor_v2_v2_9.ts +0 -49
- package/src/theme/versioning/themeColor_v3_v2.ts +0 -383
- package/src/theme/versioning/v0_v2.ts +0 -95
- package/src/theme/versioning/v2_v0.ts +0 -127
- package/src/theme/versioning/v3_v2.ts +0 -130
- /package/src/theme/{v3/merge.ts → merge.ts} +0 -0
|
@@ -3,7 +3,7 @@ import type {FontTextSize, Space} from '@sanity/ui/theme'
|
|
|
3
3
|
|
|
4
4
|
import {Box} from '../../primitives/box/box'
|
|
5
5
|
import {KBD} from '../../primitives/kbd/kbd'
|
|
6
|
-
import type {ComponentType, Props} from '../../types
|
|
6
|
+
import type {ComponentType, Props} from '../../types'
|
|
7
7
|
|
|
8
8
|
/** @public */
|
|
9
9
|
export const DEFAULT_HOTKEYS_ELEMENT = 'kbd'
|
|
@@ -12,8 +12,6 @@ export const DEFAULT_HOTKEYS_ELEMENT = 'kbd'
|
|
|
12
12
|
export interface HotkeysOwnProps extends GapStyleProps, RadiusStyleProps {
|
|
13
13
|
fontSize?: ResponsiveProp<FontTextSize>
|
|
14
14
|
padding?: ResponsiveProp<Space>
|
|
15
|
-
/** @deprecated Use `gap` instead. */
|
|
16
|
-
space?: ResponsiveProp<Space>
|
|
17
15
|
keys?: string[]
|
|
18
16
|
}
|
|
19
17
|
|
|
@@ -33,17 +31,16 @@ export type HotkeysProps<E extends HotkeysElementType = HotkeysElementType> = Pr
|
|
|
33
31
|
*/
|
|
34
32
|
export function Hotkeys<E extends HotkeysElementType = typeof DEFAULT_HOTKEYS_ELEMENT>(
|
|
35
33
|
props: HotkeysProps<E>,
|
|
36
|
-
) {
|
|
34
|
+
): React.JSX.Element | undefined {
|
|
37
35
|
const {
|
|
38
36
|
as = DEFAULT_HOTKEYS_ELEMENT,
|
|
39
37
|
fontSize,
|
|
40
|
-
gap,
|
|
38
|
+
gap = 1,
|
|
41
39
|
gapX,
|
|
42
40
|
gapY,
|
|
43
41
|
keys,
|
|
44
42
|
padding,
|
|
45
43
|
radius,
|
|
46
|
-
space = 1,
|
|
47
44
|
...rest
|
|
48
45
|
} = props as HotkeysProps<typeof DEFAULT_HOTKEYS_ELEMENT>
|
|
49
46
|
|
|
@@ -52,15 +49,7 @@ export function Hotkeys<E extends HotkeysElementType = typeof DEFAULT_HOTKEYS_EL
|
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
return (
|
|
55
|
-
<Box
|
|
56
|
-
as={as}
|
|
57
|
-
data-ui="Hotkeys"
|
|
58
|
-
{...rest}
|
|
59
|
-
display="flex"
|
|
60
|
-
gap={gap ?? space}
|
|
61
|
-
gapX={gapX}
|
|
62
|
-
gapY={gapY}
|
|
63
|
-
>
|
|
52
|
+
<Box as={as} data-ui="Hotkeys" {...rest} display="flex" gap={gap} gapX={gapX} gapY={gapY}>
|
|
64
53
|
{keys.map((key, i) => (
|
|
65
54
|
<KBD fontSize={fontSize} key={i} padding={padding} radius={radius}>
|
|
66
55
|
{key}
|
|
@@ -7,7 +7,7 @@ const POPOVER_PROPS: MenuButtonProps['popover'] = {
|
|
|
7
7
|
constrainSize: true,
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export default function ClosableMenuButtonStory() {
|
|
10
|
+
export default function ClosableMenuButtonStory(): React.JSX.Element {
|
|
11
11
|
const ref = useRef<HTMLButtonElement | null>(null)
|
|
12
12
|
|
|
13
13
|
return (
|
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
MenuButton,
|
|
10
10
|
type MenuButtonProps,
|
|
11
11
|
MenuItem,
|
|
12
|
-
type SelectableTone,
|
|
13
12
|
Text,
|
|
14
13
|
} from '@sanity/ui'
|
|
14
|
+
import type {ElementTone} from '@sanity/ui/theme'
|
|
15
15
|
import {useState} from 'react'
|
|
16
16
|
|
|
17
17
|
const POPOVER_PROPS: MenuButtonProps['popover'] = {
|
|
@@ -20,7 +20,7 @@ const POPOVER_PROPS: MenuButtonProps['popover'] = {
|
|
|
20
20
|
portal: true,
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const items: {tone:
|
|
23
|
+
const items: {tone: ElementTone; message: string}[] = [
|
|
24
24
|
{
|
|
25
25
|
tone: 'critical',
|
|
26
26
|
message: 'Critical message',
|
|
@@ -91,7 +91,7 @@ const items: {tone: SelectableTone; message: string}[] = [
|
|
|
91
91
|
},
|
|
92
92
|
]
|
|
93
93
|
|
|
94
|
-
export default function ConstrainedInBoundaryStory() {
|
|
94
|
+
export default function ConstrainedInBoundaryStory(): React.JSX.Element {
|
|
95
95
|
const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)
|
|
96
96
|
|
|
97
97
|
return (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Box, Card, LayerProvider, Menu, MenuDivider, MenuItem, Stack, Text} from '@sanity/ui'
|
|
2
2
|
|
|
3
|
-
export default function CustomMenuItemStory() {
|
|
3
|
+
export default function CustomMenuItemStory(): React.JSX.Element {
|
|
4
4
|
return (
|
|
5
5
|
<Box padding={[4, 5, 6]}>
|
|
6
6
|
<Card radius={3} shadow={2}>
|
|
@@ -8,7 +8,7 @@ const selectedOptions = {
|
|
|
8
8
|
false: false,
|
|
9
9
|
} as const
|
|
10
10
|
|
|
11
|
-
export default function CustomSelectedStateStory() {
|
|
11
|
+
export default function CustomSelectedStateStory(): React.JSX.Element {
|
|
12
12
|
const selected = useSelect('Selected', selectedOptions, false)
|
|
13
13
|
|
|
14
14
|
return (
|
|
@@ -7,7 +7,7 @@ const POPOVER_PROPS: MenuButtonProps['popover'] = {
|
|
|
7
7
|
matchReferenceWidth: true,
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export default function DisableFocusOnCloseStory() {
|
|
10
|
+
export default function DisableFocusOnCloseStory(): React.JSX.Element {
|
|
11
11
|
const disableRestoreFocusOnClose = useBoolean('Disable restore focus on close', false)
|
|
12
12
|
|
|
13
13
|
return (
|
|
@@ -25,7 +25,7 @@ const NESTED_POPOVER_PROPS: MenuButtonProps['popover'] = {
|
|
|
25
25
|
preventOverflow: true,
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export default function GroupsStory() {
|
|
28
|
+
export default function GroupsStory(): React.JSX.Element {
|
|
29
29
|
return (
|
|
30
30
|
<Box padding={[4, 5, 6]}>
|
|
31
31
|
<Card padding={1} radius={3} shadow={1}>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {WorkshopScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const scope: WorkshopScope = {
|
|
5
5
|
name: 'components/menu',
|
|
6
6
|
title: 'Menu',
|
|
7
7
|
stories: [
|
|
@@ -86,4 +86,6 @@ export default defineScope({
|
|
|
86
86
|
component: lazy(() => import('./customSelectedState')),
|
|
87
87
|
},
|
|
88
88
|
],
|
|
89
|
-
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default scope
|
|
@@ -16,7 +16,7 @@ import {useMemo} from 'react'
|
|
|
16
16
|
|
|
17
17
|
import {WORKSHOP_CARD_TONE_OPTIONS} from '$workshop'
|
|
18
18
|
|
|
19
|
-
export default function MenuButtonStory() {
|
|
19
|
+
export default function MenuButtonStory(): React.JSX.Element {
|
|
20
20
|
const layoutTone = useSelect('Layout tone', WORKSHOP_CARD_TONE_OPTIONS, 'default')
|
|
21
21
|
const portal = useBoolean('Portal', false)
|
|
22
22
|
|
|
@@ -31,7 +31,7 @@ export default function MenuButtonStory() {
|
|
|
31
31
|
return (
|
|
32
32
|
<Card height="fill" tone={layoutTone}>
|
|
33
33
|
<Box padding={[4, 5, 6]}>
|
|
34
|
-
<Grid
|
|
34
|
+
<Grid gridTemplateColumns={3} gap={2}>
|
|
35
35
|
<Button id="prev-button" mode="ghost" text="Prev" />
|
|
36
36
|
<LayerProvider>
|
|
37
37
|
<MenuButton
|
|
@@ -26,7 +26,7 @@ const POPOVER_PROPS: MenuButtonProps['popover'] = {
|
|
|
26
26
|
preventOverflow: true,
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export default function MenuGroupRightStory() {
|
|
29
|
+
export default function MenuGroupRightStory(): React.JSX.Element {
|
|
30
30
|
return (
|
|
31
31
|
<Card height="fill" tone="transparent">
|
|
32
32
|
<Flex align="center" height="fill" padding={4} sizing="border">
|
|
@@ -14,7 +14,7 @@ const POPOVER_PROPS: MenuButtonProps['popover'] = {
|
|
|
14
14
|
constrainSize: true,
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export default function OnCloseMenuButton() {
|
|
17
|
+
export default function OnCloseMenuButton(): React.JSX.Element {
|
|
18
18
|
const {push} = useToast()
|
|
19
19
|
|
|
20
20
|
const handleClose = useCallback(() => {
|
|
@@ -18,7 +18,7 @@ const POPOVER_PROPS: MenuButtonProps['popover'] = {
|
|
|
18
18
|
|
|
19
19
|
const INITIAL_INDEX = 1
|
|
20
20
|
|
|
21
|
-
export default function SelectedItemStory() {
|
|
21
|
+
export default function SelectedItemStory(): React.JSX.Element {
|
|
22
22
|
const [selectedIndex, setSelectedIndex] = useState(INITIAL_INDEX)
|
|
23
23
|
|
|
24
24
|
return (
|
|
@@ -9,7 +9,7 @@ const ITEMS = [...Array(8).keys()].map((num) => ({
|
|
|
9
9
|
|
|
10
10
|
const OPTIONS = {first: 'first', last: 'last'}
|
|
11
11
|
|
|
12
|
-
export default function ShouldFocusStory() {
|
|
12
|
+
export default function ShouldFocusStory(): React.JSX.Element {
|
|
13
13
|
const shouldFocus = useSelect<keyof typeof OPTIONS>('Should focus', OPTIONS, 'first')
|
|
14
14
|
|
|
15
15
|
const [popoverOpen, setPopoverOpen] = useState<boolean>(false)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {CubeIcon} from '@sanity/icons'
|
|
2
2
|
import {Box, Card, LayerProvider, Menu, MenuItem} from '@sanity/ui'
|
|
3
|
-
import {
|
|
3
|
+
import {ELEMENT_TONES} from '@sanity/ui/theme'
|
|
4
4
|
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
5
5
|
|
|
6
6
|
import {WORKSHOP_CARD_TONE_OPTIONS} from '$workshop'
|
|
7
7
|
|
|
8
|
-
export default function TonesStory() {
|
|
8
|
+
export default function TonesStory(): React.JSX.Element {
|
|
9
9
|
const disabled = useBoolean('Disabled', false)
|
|
10
10
|
const parentTone = useSelect('Parent tone', WORKSHOP_CARD_TONE_OPTIONS, 'default')
|
|
11
11
|
|
|
@@ -14,7 +14,7 @@ export default function TonesStory() {
|
|
|
14
14
|
<Box padding={[4, 5, 6]}>
|
|
15
15
|
<Card radius={3} shadow={3} tone={parentTone}>
|
|
16
16
|
<Menu>
|
|
17
|
-
{
|
|
17
|
+
{ELEMENT_TONES.map((tone) => (
|
|
18
18
|
<MenuItem disabled={disabled} icon={CubeIcon} key={tone} text={tone} tone={tone} />
|
|
19
19
|
))}
|
|
20
20
|
</Menu>
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import {type MouseEvent, useCallback, useMemo} from 'react'
|
|
4
4
|
import {describe, expect, it, vi} from 'vitest'
|
|
5
5
|
|
|
6
|
-
import {render} from '
|
|
6
|
+
import {render} from '$test/utils'
|
|
7
|
+
|
|
7
8
|
import {MenuContext, type MenuContextValue} from './menuContext'
|
|
8
9
|
import {useMenu} from './useMenu'
|
|
9
10
|
|
|
@@ -7,7 +7,7 @@ import {useGlobalKeyDown} from '../../hooks/useGlobalKeyDown'
|
|
|
7
7
|
import {Box} from '../../primitives/box/box'
|
|
8
8
|
import {useLayer} from '../../primitives/layer/useLayer'
|
|
9
9
|
import {Stack} from '../../primitives/stack/stack'
|
|
10
|
-
import type {ComponentType, Props} from '../../types
|
|
10
|
+
import type {ComponentType, Props} from '../../types'
|
|
11
11
|
import {MenuContext, type MenuContextValue} from './menuContext'
|
|
12
12
|
import {useMenuController} from './useMenuController'
|
|
13
13
|
|
|
@@ -16,14 +16,6 @@ export const DEFAULT_MENU_ELEMENT = 'div'
|
|
|
16
16
|
|
|
17
17
|
/** @public */
|
|
18
18
|
export type MenuOwnProps = PaddingStyleProps & {
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated Use `shouldFocus="first"` instead.
|
|
21
|
-
*/
|
|
22
|
-
'focusFirst'?: boolean
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated Use `shouldFocus="last"` instead.
|
|
25
|
-
*/
|
|
26
|
-
'focusLast'?: boolean
|
|
27
19
|
'gap'?: ResponsiveProp<Space>
|
|
28
20
|
'onClickOutside'?: (event: MouseEvent) => void
|
|
29
21
|
'onEscape'?: () => void
|
|
@@ -32,10 +24,7 @@ export type MenuOwnProps = PaddingStyleProps & {
|
|
|
32
24
|
'originElement'?: HTMLElement | null
|
|
33
25
|
'registerElement'?: (el: HTMLElement) => () => void
|
|
34
26
|
'shouldFocus'?: 'first' | 'last' | null
|
|
35
|
-
/** @deprecated Use `gap` property instead. */
|
|
36
|
-
'space'?: ResponsiveProp<Space>
|
|
37
27
|
'aria-labelledby'?: string
|
|
38
|
-
// 'onBlurCapture'?: (event: FocusEvent) => void
|
|
39
28
|
}
|
|
40
29
|
|
|
41
30
|
/** @public */
|
|
@@ -49,16 +38,14 @@ export type MenuProps<E extends MenuElementType = MenuElementType> = Props<MenuO
|
|
|
49
38
|
*
|
|
50
39
|
* @public
|
|
51
40
|
*/
|
|
52
|
-
export function Menu<E extends MenuElementType = typeof DEFAULT_MENU_ELEMENT>(
|
|
41
|
+
export function Menu<E extends MenuElementType = typeof DEFAULT_MENU_ELEMENT>(
|
|
42
|
+
props: MenuProps<E>,
|
|
43
|
+
): React.JSX.Element {
|
|
53
44
|
const {
|
|
54
45
|
as = DEFAULT_MENU_ELEMENT,
|
|
55
46
|
children,
|
|
56
47
|
className,
|
|
57
|
-
|
|
58
|
-
focusFirst,
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
60
|
-
focusLast,
|
|
61
|
-
gap,
|
|
48
|
+
gap = 1,
|
|
62
49
|
onClickOutside,
|
|
63
50
|
onEscape,
|
|
64
51
|
onItemClick,
|
|
@@ -69,12 +56,10 @@ export function Menu<E extends MenuElementType = typeof DEFAULT_MENU_ELEMENT>(pr
|
|
|
69
56
|
ref: forwardedRef,
|
|
70
57
|
registerElement,
|
|
71
58
|
shouldFocus: _shouldFocus,
|
|
72
|
-
space = 1,
|
|
73
59
|
...rest
|
|
74
60
|
} = props as MenuProps<typeof DEFAULT_MENU_ELEMENT>
|
|
75
61
|
|
|
76
|
-
const shouldFocus =
|
|
77
|
-
_shouldFocus ?? ((props.focusFirst && 'first') || (props.focusLast && 'last') || null)
|
|
62
|
+
const shouldFocus = _shouldFocus ?? null
|
|
78
63
|
|
|
79
64
|
const ref = useRef<HTMLDivElement | null>(null)
|
|
80
65
|
|
|
@@ -187,7 +172,7 @@ export function Menu<E extends MenuElementType = typeof DEFAULT_MENU_ELEMENT>(pr
|
|
|
187
172
|
role="menu"
|
|
188
173
|
tabIndex={-1}
|
|
189
174
|
>
|
|
190
|
-
<Stack gap={gap
|
|
175
|
+
<Stack gap={gap}>{children}</Stack>
|
|
191
176
|
</Box>
|
|
192
177
|
</MenuContext.Provider>
|
|
193
178
|
)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {Radius, ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
2
1
|
import {
|
|
3
2
|
cloneElement,
|
|
4
3
|
type FocusEvent,
|
|
@@ -16,8 +15,7 @@ import {
|
|
|
16
15
|
|
|
17
16
|
import type {ButtonProps} from '../../primitives/button/button'
|
|
18
17
|
import {Popover, type PopoverProps} from '../../primitives/popover/popover'
|
|
19
|
-
import type {
|
|
20
|
-
import type {Props} from '../../types/props'
|
|
18
|
+
import type {Props} from '../../types'
|
|
21
19
|
import type {MenuProps} from './menu'
|
|
22
20
|
|
|
23
21
|
/** @public */
|
|
@@ -26,37 +24,13 @@ export type MenuButtonProps = {
|
|
|
26
24
|
* @beta Do not use in production.
|
|
27
25
|
*/
|
|
28
26
|
__unstable_disableRestoreFocusOnClose?: boolean
|
|
29
|
-
/**
|
|
30
|
-
* @deprecated Use `popover={{boundaryElement: element}}` instead.
|
|
31
|
-
*/
|
|
32
|
-
boundaryElement?: HTMLElement
|
|
33
27
|
button: ReactElement<ButtonProps>
|
|
34
28
|
id: string
|
|
35
29
|
menu?: ReactElement
|
|
36
30
|
onClose?: () => void
|
|
37
31
|
onOpen?: () => void
|
|
38
|
-
/**
|
|
39
|
-
* @deprecated Use `popover={{placement: 'top'}}` instead.
|
|
40
|
-
*/
|
|
41
|
-
placement?: Placement
|
|
42
32
|
popover?: Omit<PopoverProps, 'content' | 'open'>
|
|
43
|
-
|
|
44
|
-
* @deprecated Use `popover={{scheme: 'dark'}}` instead.
|
|
45
|
-
*/
|
|
46
|
-
popoverScheme?: ThemeColorSchemeKey
|
|
47
|
-
/**
|
|
48
|
-
* @deprecated Use `popover={{radius: 2}}` instead.
|
|
49
|
-
*/
|
|
50
|
-
popoverRadius?: Radius | Radius[]
|
|
51
|
-
/**
|
|
52
|
-
* @beta Do not use in production.
|
|
53
|
-
* @deprecated Use `popover={{portal: true}}` instead.
|
|
54
|
-
*/
|
|
55
|
-
portal?: boolean
|
|
56
|
-
/**
|
|
57
|
-
* @deprecated Use `popover={{preventOverflow: true}}` instead.
|
|
58
|
-
*/
|
|
59
|
-
preventOverflow?: boolean
|
|
33
|
+
|
|
60
34
|
ref?: ForwardedRef<HTMLButtonElement | null>
|
|
61
35
|
}
|
|
62
36
|
|
|
@@ -65,21 +39,15 @@ export type MenuButtonProps = {
|
|
|
65
39
|
*
|
|
66
40
|
* @public
|
|
67
41
|
*/
|
|
68
|
-
export function MenuButton(props: MenuButtonProps) {
|
|
42
|
+
export function MenuButton(props: MenuButtonProps): React.JSX.Element {
|
|
69
43
|
const {
|
|
70
44
|
__unstable_disableRestoreFocusOnClose: disableRestoreFocusOnClose = false,
|
|
71
|
-
boundaryElement: deprecated_boundaryElement,
|
|
72
45
|
button: buttonProp,
|
|
73
46
|
id,
|
|
74
47
|
menu: menuProp,
|
|
75
48
|
onClose,
|
|
76
49
|
onOpen,
|
|
77
|
-
placement: deprecated_placement,
|
|
78
|
-
popoverScheme: deprecated_popoverScheme,
|
|
79
|
-
portal: deprecated_portal = true,
|
|
80
50
|
popover,
|
|
81
|
-
popoverRadius: deprecated_popoverRadius,
|
|
82
|
-
preventOverflow: deprecated_preventOverflow,
|
|
83
51
|
ref: forwardedRef,
|
|
84
52
|
} = props
|
|
85
53
|
const [open, setOpen] = useState(false)
|
|
@@ -243,24 +211,10 @@ export function MenuButton(props: MenuButtonProps) {
|
|
|
243
211
|
|
|
244
212
|
const popoverProps: MenuButtonProps['popover'] = useMemo(
|
|
245
213
|
() => ({
|
|
246
|
-
boundaryElement: deprecated_boundaryElement,
|
|
247
214
|
overflow: 'auto',
|
|
248
|
-
placement: deprecated_placement,
|
|
249
|
-
portal: deprecated_portal,
|
|
250
|
-
preventOverflow: deprecated_preventOverflow,
|
|
251
|
-
radius: deprecated_popoverRadius,
|
|
252
|
-
scheme: deprecated_popoverScheme,
|
|
253
215
|
...(popover || {}),
|
|
254
216
|
}),
|
|
255
|
-
[
|
|
256
|
-
deprecated_boundaryElement,
|
|
257
|
-
deprecated_placement,
|
|
258
|
-
deprecated_popoverRadius,
|
|
259
|
-
deprecated_popoverScheme,
|
|
260
|
-
deprecated_portal,
|
|
261
|
-
deprecated_preventOverflow,
|
|
262
|
-
popover,
|
|
263
|
-
],
|
|
217
|
+
[popover],
|
|
264
218
|
)
|
|
265
219
|
|
|
266
220
|
return (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {type MouseEvent as ReactMouseEvent} from 'react'
|
|
1
|
+
import {type Context, type MouseEvent as ReactMouseEvent} from 'react'
|
|
2
2
|
|
|
3
3
|
import {createGlobalScopedContext} from '../../lib/createGlobalScopedContext'
|
|
4
4
|
|
|
@@ -13,19 +13,7 @@ export interface MenuContextValue {
|
|
|
13
13
|
onItemMouseEnter?: (event: ReactMouseEvent<HTMLElement>) => void
|
|
14
14
|
onItemMouseLeave?: (event: ReactMouseEvent<HTMLElement>) => void
|
|
15
15
|
registerElement?: (el: HTMLElement) => () => void
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Use `onItemMouseEnter` instead
|
|
19
|
-
*/
|
|
20
|
-
onMouseEnter: (event: ReactMouseEvent<HTMLElement>) => void
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated Use `onItemMouseLeave` instead
|
|
24
|
-
*/
|
|
25
|
-
onMouseLeave: (event: ReactMouseEvent<HTMLElement>) => void
|
|
26
16
|
}
|
|
27
17
|
|
|
28
|
-
export const MenuContext
|
|
29
|
-
'@sanity/ui/
|
|
30
|
-
null,
|
|
31
|
-
)
|
|
18
|
+
export const MenuContext: Context<MenuContextValue | null> =
|
|
19
|
+
createGlobalScopedContext<MenuContextValue | null>('@sanity/ui/v3/menu', null)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {menuDivider} from '@sanity/ui/css'
|
|
2
2
|
|
|
3
|
-
import type {ComponentType, Props} from '../../types
|
|
3
|
+
import type {ComponentType, Props} from '../../types'
|
|
4
4
|
|
|
5
5
|
/** @public */
|
|
6
6
|
export const DEFAULT_MENU_DIVIDER_ELEMENT = 'hr'
|
|
@@ -21,7 +21,7 @@ export type MenuDividerProps<E extends MenuDividerElementType = MenuDividerEleme
|
|
|
21
21
|
/** @public */
|
|
22
22
|
export function MenuDivider<E extends MenuDividerElementType = typeof DEFAULT_MENU_DIVIDER_ELEMENT>(
|
|
23
23
|
props: MenuDividerProps<E>,
|
|
24
|
-
) {
|
|
24
|
+
): React.JSX.Element {
|
|
25
25
|
const {
|
|
26
26
|
as: Element = DEFAULT_MENU_DIVIDER_ELEMENT,
|
|
27
27
|
className,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ChevronRightIcon} from '@sanity/icons'
|
|
2
2
|
import type {RadiusStyleProps, ResponsiveProp} from '@sanity/ui/css'
|
|
3
|
-
import type {FontTextSize, Space
|
|
3
|
+
import type {ElementTone, FontTextSize, Space} from '@sanity/ui/theme'
|
|
4
4
|
import {
|
|
5
5
|
type ElementType,
|
|
6
6
|
isValidElement,
|
|
@@ -18,7 +18,7 @@ import {Flex} from '../../primitives/flex/flex'
|
|
|
18
18
|
import {Popover, type PopoverProps} from '../../primitives/popover/popover'
|
|
19
19
|
import {Selectable} from '../../primitives/selectable/selectable'
|
|
20
20
|
import {Text} from '../../primitives/text/text'
|
|
21
|
-
import type {ComponentType, Props} from '../../types
|
|
21
|
+
import type {ComponentType, Props} from '../../types'
|
|
22
22
|
import {DEFAULT_MENU_ELEMENT, Menu, type MenuProps} from './menu'
|
|
23
23
|
import {useMenu} from './useMenu'
|
|
24
24
|
|
|
@@ -44,10 +44,8 @@ export type MenuGroupOwnProps = RadiusStyleProps & {
|
|
|
44
44
|
>
|
|
45
45
|
padding?: ResponsiveProp<Space>
|
|
46
46
|
popover?: Omit<PopoverProps, 'content' | 'open'>
|
|
47
|
-
/** @deprecated Use `gap` instead. */
|
|
48
|
-
space?: ResponsiveProp<Space>
|
|
49
47
|
text?: ReactNode
|
|
50
|
-
tone?:
|
|
48
|
+
tone?: ElementTone
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
/** @public */
|
|
@@ -62,36 +60,33 @@ export type MenuGroupProps<E extends MenuGroupElementType = MenuGroupElementType
|
|
|
62
60
|
/** @public */
|
|
63
61
|
export function MenuGroup<E extends MenuGroupElementType = typeof DEFAULT_MENU_GROUP_ELEMENT>(
|
|
64
62
|
props: MenuGroupProps<E>,
|
|
65
|
-
) {
|
|
63
|
+
): React.JSX.Element {
|
|
66
64
|
const {
|
|
67
65
|
as = DEFAULT_MENU_GROUP_ELEMENT,
|
|
68
66
|
children,
|
|
69
67
|
fontSize = 1,
|
|
70
|
-
gap,
|
|
68
|
+
gap = 3,
|
|
71
69
|
icon: IconComponent,
|
|
72
70
|
menu: menuProps,
|
|
73
71
|
onClick,
|
|
74
72
|
padding = 3,
|
|
75
73
|
popover,
|
|
76
74
|
radius = 2,
|
|
77
|
-
space = 3,
|
|
78
75
|
text,
|
|
79
76
|
tone = 'default',
|
|
80
77
|
...rest
|
|
81
78
|
} = props as MenuGroupProps<typeof DEFAULT_MENU_GROUP_ELEMENT>
|
|
82
79
|
|
|
83
|
-
const menu = useMenu()
|
|
84
|
-
|
|
85
80
|
const {
|
|
86
81
|
activeElement,
|
|
87
82
|
mount,
|
|
88
83
|
onClickOutside,
|
|
89
84
|
onEscape,
|
|
90
85
|
onItemClick,
|
|
91
|
-
onItemMouseEnter
|
|
86
|
+
onItemMouseEnter,
|
|
92
87
|
registerElement,
|
|
93
|
-
} =
|
|
94
|
-
|
|
88
|
+
} = useMenu()
|
|
89
|
+
|
|
95
90
|
const [rootElement, setRootElement] = useState<HTMLButtonElement | HTMLDivElement | null>(null)
|
|
96
91
|
const [open, setOpen] = useState(false)
|
|
97
92
|
const [shouldFocus, setShouldFocus] = useState<'first' | 'last' | null>(null)
|
|
@@ -101,7 +96,7 @@ export function MenuGroup<E extends MenuGroupElementType = typeof DEFAULT_MENU_G
|
|
|
101
96
|
const handleMouseEnter = useCallback(
|
|
102
97
|
(event: MouseEvent<HTMLElement>) => {
|
|
103
98
|
setWithinMenu(false)
|
|
104
|
-
onItemMouseEnter(event)
|
|
99
|
+
onItemMouseEnter?.(event)
|
|
105
100
|
setOpen(true)
|
|
106
101
|
},
|
|
107
102
|
[onItemMouseEnter],
|
|
@@ -214,7 +209,7 @@ export function MenuGroup<E extends MenuGroupElementType = typeof DEFAULT_MENU_G
|
|
|
214
209
|
tone={tone}
|
|
215
210
|
type={as === 'button' ? 'button' : undefined}
|
|
216
211
|
>
|
|
217
|
-
<Flex gap={gap
|
|
212
|
+
<Flex gap={gap} padding={padding}>
|
|
218
213
|
{IconComponent && (
|
|
219
214
|
<Text size={fontSize}>
|
|
220
215
|
{isValidElement(IconComponent) && IconComponent}
|