@sanity/ui 3.3.2 → 3.3.3
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/package.json +6 -11
- package/exports/_visual-editing.ts +0 -32
- package/exports/index.ts +0 -1
- package/exports/theme.ts +0 -1
- package/src/core/_compat.ts +0 -294
- package/src/core/components/autocomplete/autocomplete.styles.tsx +0 -39
- package/src/core/components/autocomplete/autocomplete.tsx +0 -775
- package/src/core/components/autocomplete/autocompleteOption.tsx +0 -46
- package/src/core/components/autocomplete/autocompleteReducer.ts +0 -47
- package/src/core/components/autocomplete/constants.ts +0 -28
- package/src/core/components/autocomplete/index.ts +0 -2
- package/src/core/components/autocomplete/types.ts +0 -108
- package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +0 -18
- package/src/core/components/breadcrumbs/breadcrumbs.test.tsx +0 -54
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +0 -136
- package/src/core/components/breadcrumbs/index.ts +0 -1
- package/src/core/components/dialog/dialog.tsx +0 -433
- package/src/core/components/dialog/dialogContext.ts +0 -20
- package/src/core/components/dialog/dialogProvider.tsx +0 -35
- package/src/core/components/dialog/index.ts +0 -4
- package/src/core/components/dialog/styles.ts +0 -77
- package/src/core/components/dialog/useDialog.ts +0 -11
- package/src/core/components/hotkeys/hotkeys.test.tsx +0 -47
- package/src/core/components/hotkeys/hotkeys.tsx +0 -68
- package/src/core/components/hotkeys/index.ts +0 -1
- package/src/core/components/index.ts +0 -9
- package/src/core/components/menu/helpers.ts +0 -82
- package/src/core/components/menu/index.ts +0 -5
- package/src/core/components/menu/menu.spacing.test.tsx +0 -68
- package/src/core/components/menu/menu.test.tsx +0 -128
- package/src/core/components/menu/menu.tsx +0 -180
- package/src/core/components/menu/menuButton.tsx +0 -276
- package/src/core/components/menu/menuContext.ts +0 -18
- package/src/core/components/menu/menuDivider.ts +0 -24
- package/src/core/components/menu/menuGroup.spacing.test.tsx +0 -66
- package/src/core/components/menu/menuGroup.tsx +0 -237
- package/src/core/components/menu/menuItem.spacing.test.tsx +0 -62
- package/src/core/components/menu/menuItem.tsx +0 -201
- package/src/core/components/menu/useMenu.ts +0 -21
- package/src/core/components/menu/useMenuController.ts +0 -233
- package/src/core/components/skeleton/index.ts +0 -2
- package/src/core/components/skeleton/skeleton.tsx +0 -58
- package/src/core/components/skeleton/styles.ts +0 -50
- package/src/core/components/skeleton/textSkeleton.tsx +0 -122
- package/src/core/components/tab/index.ts +0 -3
- package/src/core/components/tab/tab.tsx +0 -102
- package/src/core/components/tab/tabList.test.tsx +0 -50
- package/src/core/components/tab/tabList.tsx +0 -71
- package/src/core/components/tab/tabPanel.tsx +0 -39
- package/src/core/components/toast/index.ts +0 -4
- package/src/core/components/toast/styles.ts +0 -77
- package/src/core/components/toast/toast.test.tsx +0 -106
- package/src/core/components/toast/toast.tsx +0 -199
- package/src/core/components/toast/toastContext.ts +0 -7
- package/src/core/components/toast/toastLayer.tsx +0 -52
- package/src/core/components/toast/toastProvider.tsx +0 -113
- package/src/core/components/toast/toastState.ts +0 -6
- package/src/core/components/toast/types.ts +0 -26
- package/src/core/components/toast/useToast.ts +0 -25
- package/src/core/components/tree/helpers.ts +0 -105
- package/src/core/components/tree/index.ts +0 -4
- package/src/core/components/tree/style.ts +0 -105
- package/src/core/components/tree/tree.test.tsx +0 -60
- package/src/core/components/tree/tree.tsx +0 -242
- package/src/core/components/tree/treeContext.ts +0 -10
- package/src/core/components/tree/treeGroup.tsx +0 -29
- package/src/core/components/tree/treeItem.test.tsx +0 -70
- package/src/core/components/tree/treeItem.tsx +0 -225
- package/src/core/components/tree/types.ts +0 -25
- package/src/core/components/tree/useTree.ts +0 -17
- package/src/core/constants.ts +0 -79
- package/src/core/helpers/animation.ts +0 -27
- package/src/core/helpers/element.ts +0 -55
- package/src/core/helpers/focus.ts +0 -100
- package/src/core/helpers/index.ts +0 -4
- package/src/core/helpers/scroll.ts +0 -15
- package/src/core/hooks/index.ts +0 -13
- package/src/core/hooks/useArrayProp.ts +0 -17
- package/src/core/hooks/useClickOutside.test.tsx +0 -510
- package/src/core/hooks/useClickOutside.ts +0 -118
- package/src/core/hooks/useClickOutsideEvent.test.tsx +0 -119
- package/src/core/hooks/useClickOutsideEvent.ts +0 -73
- package/src/core/hooks/useCustomValidity.ts +0 -13
- package/src/core/hooks/useDelayed.test.ts +0 -89
- package/src/core/hooks/useDelayedState.ts +0 -36
- package/src/core/hooks/useElementRect/index.ts +0 -1
- package/src/core/hooks/useElementRect/useElementRect.ts +0 -14
- package/src/core/hooks/useElementSize.ts +0 -19
- package/src/core/hooks/useForwardedRef.ts +0 -20
- package/src/core/hooks/useGlobalKeyDown.ts +0 -24
- package/src/core/hooks/useIsomorphicEffect.ts +0 -7
- package/src/core/hooks/useMatchMedia.ts +0 -28
- package/src/core/hooks/useMediaIndex/index.ts +0 -1
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +0 -37
- package/src/core/hooks/useMediaIndex/useMediaIndex.ts +0 -102
- package/src/core/hooks/useMounted.ts +0 -15
- package/src/core/hooks/usePrefersDark.hydration.test.tsx +0 -58
- package/src/core/hooks/usePrefersDark.test.tsx +0 -21
- package/src/core/hooks/usePrefersDark.ts +0 -16
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +0 -58
- package/src/core/hooks/usePrefersReducedMotion.test.tsx +0 -21
- package/src/core/hooks/usePrefersReducedMotion.ts +0 -16
- package/src/core/index.ts +0 -10
- package/src/core/lib/createGlobalScopedContext.ts +0 -37
- package/src/core/lib/globalScope.ts +0 -20
- package/src/core/lib/isRecord.ts +0 -3
- package/src/core/middleware/origin.ts +0 -47
- package/src/core/observers/elementSizeObserver.ts +0 -117
- package/src/core/observers/index.ts +0 -2
- package/src/core/observers/resizeObserver.ts +0 -9
- package/src/core/primitives/_selectable/index.ts +0 -1
- package/src/core/primitives/_selectable/selectable.tsx +0 -15
- package/src/core/primitives/_selectable/style.ts +0 -115
- package/src/core/primitives/avatar/avatar.tsx +0 -200
- package/src/core/primitives/avatar/avatarCounter.tsx +0 -91
- package/src/core/primitives/avatar/avatarStack.tsx +0 -101
- package/src/core/primitives/avatar/index.ts +0 -4
- package/src/core/primitives/avatar/styles.ts +0 -167
- package/src/core/primitives/avatar/types.ts +0 -17
- package/src/core/primitives/badge/badge.test.tsx +0 -17
- package/src/core/primitives/badge/badge.tsx +0 -72
- package/src/core/primitives/badge/index.ts +0 -1
- package/src/core/primitives/badge/styles.ts +0 -20
- package/src/core/primitives/badge/types.ts +0 -8
- package/src/core/primitives/box/box.test.tsx +0 -155
- package/src/core/primitives/box/box.tsx +0 -162
- package/src/core/primitives/box/index.ts +0 -1
- package/src/core/primitives/button/button.test.tsx +0 -86
- package/src/core/primitives/button/button.tsx +0 -214
- package/src/core/primitives/button/index.ts +0 -1
- package/src/core/primitives/button/styles.ts +0 -118
- package/src/core/primitives/card/card.tsx +0 -125
- package/src/core/primitives/card/index.ts +0 -2
- package/src/core/primitives/card/styles.ts +0 -147
- package/src/core/primitives/card/types.ts +0 -12
- package/src/core/primitives/checkbox/checkbox.tsx +0 -73
- package/src/core/primitives/checkbox/index.ts +0 -1
- package/src/core/primitives/checkbox/styles.ts +0 -128
- package/src/core/primitives/code/code.tsx +0 -56
- package/src/core/primitives/code/index.ts +0 -1
- package/src/core/primitives/code/refractor.tsx +0 -22
- package/src/core/primitives/code/styles.ts +0 -77
- package/src/core/primitives/container/container.tsx +0 -55
- package/src/core/primitives/container/index.ts +0 -2
- package/src/core/primitives/container/styles.ts +0 -23
- package/src/core/primitives/container/types.ts +0 -6
- package/src/core/primitives/flex/flex.tsx +0 -63
- package/src/core/primitives/flex/index.ts +0 -1
- package/src/core/primitives/grid/grid.test.tsx +0 -86
- package/src/core/primitives/grid/grid.tsx +0 -77
- package/src/core/primitives/grid/index.ts +0 -1
- package/src/core/primitives/heading/heading.tsx +0 -89
- package/src/core/primitives/heading/index.ts +0 -1
- package/src/core/primitives/heading/styles.ts +0 -64
- package/src/core/primitives/heading/types.ts +0 -7
- package/src/core/primitives/index.ts +0 -27
- package/src/core/primitives/inline/index.ts +0 -1
- package/src/core/primitives/inline/inline.test.tsx +0 -55
- package/src/core/primitives/inline/inline.tsx +0 -66
- package/src/core/primitives/inline/styles.ts +0 -32
- package/src/core/primitives/inline/types.ts +0 -6
- package/src/core/primitives/kbd/index.ts +0 -1
- package/src/core/primitives/kbd/kbd.tsx +0 -73
- package/src/core/primitives/label/index.ts +0 -1
- package/src/core/primitives/label/label.tsx +0 -88
- package/src/core/primitives/label/styles.ts +0 -45
- package/src/core/primitives/popover/constants.ts +0 -22
- package/src/core/primitives/popover/floating-ui/size.ts +0 -99
- package/src/core/primitives/popover/helpers.ts +0 -31
- package/src/core/primitives/popover/index.ts +0 -2
- package/src/core/primitives/popover/popover.tsx +0 -512
- package/src/core/primitives/popover/popoverCard.tsx +0 -167
- package/src/core/primitives/popover/types.ts +0 -6
- package/src/core/primitives/radio/index.ts +0 -1
- package/src/core/primitives/radio/radio.tsx +0 -51
- package/src/core/primitives/radio/styles.ts +0 -117
- package/src/core/primitives/select/index.ts +0 -1
- package/src/core/primitives/select/select.test.tsx +0 -56
- package/src/core/primitives/select/select.tsx +0 -95
- package/src/core/primitives/select/styles.ts +0 -166
- package/src/core/primitives/spinner/index.ts +0 -1
- package/src/core/primitives/spinner/spinner.tsx +0 -46
- package/src/core/primitives/stack/index.ts +0 -1
- package/src/core/primitives/stack/stack.test.tsx +0 -61
- package/src/core/primitives/stack/stack.tsx +0 -59
- package/src/core/primitives/stack/styles.ts +0 -33
- package/src/core/primitives/switch/index.ts +0 -1
- package/src/core/primitives/switch/styles.ts +0 -173
- package/src/core/primitives/switch/switch.tsx +0 -68
- package/src/core/primitives/text/index.ts +0 -1
- package/src/core/primitives/text/styles.ts +0 -74
- package/src/core/primitives/text/text.tsx +0 -90
- package/src/core/primitives/textArea/index.ts +0 -1
- package/src/core/primitives/textArea/textArea.tsx +0 -120
- package/src/core/primitives/textInput/index.ts +0 -1
- package/src/core/primitives/textInput/textInput.test.tsx +0 -52
- package/src/core/primitives/textInput/textInput.tsx +0 -398
- package/src/core/primitives/tooltip/constants.ts +0 -23
- package/src/core/primitives/tooltip/index.ts +0 -2
- package/src/core/primitives/tooltip/tooltip.test.tsx +0 -485
- package/src/core/primitives/tooltip/tooltip.tsx +0 -497
- package/src/core/primitives/tooltip/tooltipCard.tsx +0 -110
- package/src/core/primitives/tooltip/tooltipDelayGroup/index.ts +0 -4
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupContext.tsx +0 -11
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +0 -57
- package/src/core/primitives/tooltip/tooltipDelayGroup/types.ts +0 -12
- package/src/core/primitives/tooltip/tooltipDelayGroup/useTooltipDelayGroup.ts +0 -13
- package/src/core/primitives/types.ts +0 -179
- package/src/core/styles/border/borderStyle.ts +0 -56
- package/src/core/styles/border/index.ts +0 -2
- package/src/core/styles/border/types.ts +0 -10
- package/src/core/styles/box/boxStyle.ts +0 -69
- package/src/core/styles/box/index.ts +0 -2
- package/src/core/styles/box/types.ts +0 -11
- package/src/core/styles/card/_cardColorStyle.ts +0 -108
- package/src/core/styles/card/index.ts +0 -1
- package/src/core/styles/flex/flexItemStyle.ts +0 -27
- package/src/core/styles/flex/flexStyle.ts +0 -70
- package/src/core/styles/flex/index.ts +0 -3
- package/src/core/styles/flex/types.ts +0 -24
- package/src/core/styles/focusRing/index.ts +0 -25
- package/src/core/styles/font/codeFontStyle.ts +0 -13
- package/src/core/styles/font/headingFontStyle.ts +0 -13
- package/src/core/styles/font/index.ts +0 -6
- package/src/core/styles/font/labelFontStyle.ts +0 -13
- package/src/core/styles/font/responsiveFont.ts +0 -100
- package/src/core/styles/font/textAlignStyle.ts +0 -19
- package/src/core/styles/font/textFontStyle.ts +0 -13
- package/src/core/styles/font/types.ts +0 -33
- package/src/core/styles/grid/gridItemStyle.ts +0 -82
- package/src/core/styles/grid/gridStyle.ts +0 -109
- package/src/core/styles/grid/index.ts +0 -3
- package/src/core/styles/grid/types.ts +0 -37
- package/src/core/styles/helpers.ts +0 -72
- package/src/core/styles/index.ts +0 -5
- package/src/core/styles/input/index.ts +0 -2
- package/src/core/styles/input/responsiveInputPaddingStyle.ts +0 -78
- package/src/core/styles/input/textInputStyle.ts +0 -263
- package/src/core/styles/internal.ts +0 -12
- package/src/core/styles/margin/index.ts +0 -2
- package/src/core/styles/margin/marginStyle.ts +0 -22
- package/src/core/styles/margin/marginsStyle.test.ts +0 -34
- package/src/core/styles/margin/types.ts +0 -9
- package/src/core/styles/padding/index.ts +0 -2
- package/src/core/styles/padding/paddingStyle.test.ts +0 -34
- package/src/core/styles/padding/paddingStyle.ts +0 -22
- package/src/core/styles/padding/types.ts +0 -12
- package/src/core/styles/radius/index.ts +0 -2
- package/src/core/styles/radius/radiusStyle.ts +0 -23
- package/src/core/styles/radius/types.ts +0 -8
- package/src/core/styles/shadow/index.ts +0 -2
- package/src/core/styles/shadow/shadowStyle.ts +0 -29
- package/src/core/styles/shadow/types.ts +0 -6
- package/src/core/styles/types.ts +0 -8
- package/src/core/theme/index.ts +0 -5
- package/src/core/theme/theme.test.tsx +0 -77
- package/src/core/theme/themeColorProvider.tsx +0 -29
- package/src/core/theme/themeContext.ts +0 -10
- package/src/core/theme/themeProvider.tsx +0 -62
- package/src/core/theme/types.ts +0 -12
- package/src/core/theme/useRootTheme.ts +0 -18
- package/src/core/theme/useTheme.ts +0 -18
- package/src/core/types/avatar.ts +0 -14
- package/src/core/types/badge.ts +0 -12
- package/src/core/types/box.ts +0 -19
- package/src/core/types/button.ts +0 -21
- package/src/core/types/card.ts +0 -6
- package/src/core/types/component.ts +0 -32
- package/src/core/types/dialog.ts +0 -4
- package/src/core/types/flex.ts +0 -30
- package/src/core/types/grid.ts +0 -14
- package/src/core/types/gridItem.ts +0 -29
- package/src/core/types/index.ts +0 -15
- package/src/core/types/placement.ts +0 -18
- package/src/core/types/popover.ts +0 -4
- package/src/core/types/radius.ts +0 -4
- package/src/core/types/selectable.ts +0 -6
- package/src/core/types/text.ts +0 -4
- package/src/core/utils/arrow/arrow.tsx +0 -124
- package/src/core/utils/arrow/cmds.ts +0 -91
- package/src/core/utils/arrow/index.ts +0 -1
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +0 -105
- package/src/core/utils/boundaryElement/boundaryElementContext.ts +0 -7
- package/src/core/utils/boundaryElement/boundaryElementProvider.tsx +0 -24
- package/src/core/utils/boundaryElement/index.ts +0 -3
- package/src/core/utils/boundaryElement/types.ts +0 -7
- package/src/core/utils/boundaryElement/useBoundaryElement.ts +0 -26
- package/src/core/utils/conditionalWrapper/conditionalWrapper.tsx +0 -22
- package/src/core/utils/conditionalWrapper/index.ts +0 -1
- package/src/core/utils/elementQuery/elementQuery.tsx +0 -53
- package/src/core/utils/elementQuery/helpers.ts +0 -27
- package/src/core/utils/elementQuery/index.ts +0 -1
- package/src/core/utils/errorBoundary.tsx +0 -48
- package/src/core/utils/getElementRef.ts +0 -31
- package/src/core/utils/index.ts +0 -9
- package/src/core/utils/layer/getLayerContext.test.ts +0 -32
- package/src/core/utils/layer/getLayerContext.ts +0 -21
- package/src/core/utils/layer/index.ts +0 -4
- package/src/core/utils/layer/layer.test.tsx +0 -113
- package/src/core/utils/layer/layer.tsx +0 -99
- package/src/core/utils/layer/layerContext.ts +0 -7
- package/src/core/utils/layer/layerProvider.tsx +0 -111
- package/src/core/utils/layer/types.ts +0 -9
- package/src/core/utils/layer/useLayer.ts +0 -28
- package/src/core/utils/portal/index.ts +0 -4
- package/src/core/utils/portal/portal.test.tsx +0 -108
- package/src/core/utils/portal/portal.ts +0 -32
- package/src/core/utils/portal/portalContext.ts +0 -31
- package/src/core/utils/portal/portalProvider.tsx +0 -48
- package/src/core/utils/portal/types.ts +0 -9
- package/src/core/utils/portal/usePortal.ts +0 -25
- package/src/core/utils/spanWithTextOverflow.tsx +0 -10
- package/src/core/utils/srOnly/index.ts +0 -1
- package/src/core/utils/srOnly/srOnly.tsx +0 -36
- package/src/core/utils/virtualList/index.ts +0 -1
- package/src/core/utils/virtualList/virtualList.tsx +0 -201
- package/src/theme/build/_deprecated/color/_selectable/createSelectableTones.ts +0 -86
- package/src/theme/build/_deprecated/color/_solid/createSolidTones.ts +0 -58
- package/src/theme/build/_deprecated/color/button/createButtonModes.ts +0 -27
- package/src/theme/build/_deprecated/color/button/createButtonTones.ts +0 -60
- package/src/theme/build/_deprecated/color/card/createCardStates.ts +0 -66
- package/src/theme/build/_deprecated/color/color.test.ts +0 -67
- package/src/theme/build/_deprecated/color/defaults.ts +0 -391
- package/src/theme/build/_deprecated/color/factory.ts +0 -178
- package/src/theme/build/_deprecated/color/index.ts +0 -1
- package/src/theme/build/_deprecated/color/input/createInputModes.ts +0 -86
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +0 -58
- package/src/theme/build/_deprecated/color/spot/createSpot.ts +0 -23
- package/src/theme/build/buildColorTheme.test.ts +0 -185
- package/src/theme/build/buildColorTheme.ts +0 -507
- package/src/theme/build/buildTheme.test.ts +0 -89
- package/src/theme/build/buildTheme.ts +0 -36
- package/src/theme/build/colorToken/colorToken.ts +0 -19
- package/src/theme/build/colorToken/compileColorToken.ts +0 -21
- package/src/theme/build/colorToken/index.ts +0 -2
- package/src/theme/build/colorToken/types.ts +0 -6
- package/src/theme/build/index.ts +0 -3
- package/src/theme/build/lib/color-fns/blend/index.ts +0 -3
- package/src/theme/build/lib/color-fns/blend/mix.ts +0 -21
- package/src/theme/build/lib/color-fns/blend/multiply.ts +0 -18
- package/src/theme/build/lib/color-fns/blend/screen.ts +0 -18
- package/src/theme/build/lib/color-fns/color-fns.test.ts +0 -70
- package/src/theme/build/lib/color-fns/contrastRatio.ts +0 -31
- package/src/theme/build/lib/color-fns/convert.ts +0 -150
- package/src/theme/build/lib/color-fns/index.ts +0 -6
- package/src/theme/build/lib/color-fns/parse.ts +0 -60
- package/src/theme/build/lib/color-fns/rgba.ts +0 -10
- package/src/theme/build/lib/color-fns/types.ts +0 -28
- package/src/theme/build/lib/isRecord.ts +0 -3
- package/src/theme/build/lib/lazy.ts +0 -30
- package/src/theme/build/lib/utils.ts +0 -19
- package/src/theme/build/merge.ts +0 -31
- package/src/theme/build/mixThemeColor.test.ts +0 -23
- package/src/theme/build/mixThemeColor.ts +0 -53
- package/src/theme/build/renderColorTheme.ts +0 -538
- package/src/theme/build/renderColorValue.ts +0 -83
- package/src/theme/build/resolveColorTokens.ts +0 -274
- package/src/theme/build/theme.test.ts +0 -29
- package/src/theme/config/helpers.ts +0 -60
- package/src/theme/config/index.ts +0 -4
- package/src/theme/config/system.ts +0 -117
- package/src/theme/config/tokens/color/index.ts +0 -1
- package/src/theme/config/tokens/color/types.ts +0 -135
- package/src/theme/config/tokens/index.ts +0 -4
- package/src/theme/config/tokens/parseTokenKey.test.ts +0 -66
- package/src/theme/config/tokens/parseTokenKey.ts +0 -67
- package/src/theme/config/tokens/parseTokenValue.test.ts +0 -44
- package/src/theme/config/tokens/parseTokenValue.ts +0 -134
- package/src/theme/config/tokens/types.ts +0 -53
- package/src/theme/config/types.ts +0 -46
- package/src/theme/defaults/colorPalette.ts +0 -5
- package/src/theme/defaults/colorTokens.ts +0 -648
- package/src/theme/defaults/config.ts +0 -84
- package/src/theme/defaults/fonts.ts +0 -227
- package/src/theme/getScopedTheme.ts +0 -103
- package/src/theme/index.ts +0 -5
- package/src/theme/system/avatar.ts +0 -14
- package/src/theme/system/color/_constants.ts +0 -45
- package/src/theme/system/color/_helpers.ts +0 -28
- package/src/theme/system/color/_system.ts +0 -40
- package/src/theme/system/color/avatar.ts +0 -15
- package/src/theme/system/color/badge.ts +0 -16
- package/src/theme/system/color/button.ts +0 -17
- package/src/theme/system/color/color.ts +0 -34
- package/src/theme/system/color/index.ts +0 -13
- package/src/theme/system/color/input.ts +0 -25
- package/src/theme/system/color/kbd.ts +0 -8
- package/src/theme/system/color/selectable.ts +0 -12
- package/src/theme/system/color/shadow.ts +0 -7
- package/src/theme/system/color/state.ts +0 -43
- package/src/theme/system/color/syntax.ts +0 -41
- package/src/theme/system/css.ts +0 -14
- package/src/theme/system/focusRing.ts +0 -7
- package/src/theme/system/font.ts +0 -52
- package/src/theme/system/index.ts +0 -11
- package/src/theme/system/input.ts +0 -33
- package/src/theme/system/layer.ts +0 -8
- package/src/theme/system/shadow.ts +0 -19
- package/src/theme/system/styles.ts +0 -13
- package/src/theme/system/theme.ts +0 -142
- package/src/theme/system/v0/avatar.ts +0 -10
- package/src/theme/system/v0/color/_generic.ts +0 -35
- package/src/theme/system/v0/color/_system.ts +0 -18
- package/src/theme/system/v0/color/base.ts +0 -21
- package/src/theme/system/v0/color/button.ts +0 -56
- package/src/theme/system/v0/color/card.ts +0 -25
- package/src/theme/system/v0/color/color.ts +0 -51
- package/src/theme/system/v0/color/index.ts +0 -11
- package/src/theme/system/v0/color/input.ts +0 -40
- package/src/theme/system/v0/color/muted.ts +0 -37
- package/src/theme/system/v0/color/selectable.ts +0 -42
- package/src/theme/system/v0/color/solid.ts +0 -37
- package/src/theme/system/v0/color/spot.ts +0 -14
- package/src/theme/system/v0/index.ts +0 -3
- package/src/theme/system/v0/input.ts +0 -23
- package/src/theme/versioning/getTheme_v2.ts +0 -72
- package/src/theme/versioning/index.ts +0 -5
- package/src/theme/versioning/is_v0.ts +0 -6
- package/src/theme/versioning/is_v2.ts +0 -6
- package/src/theme/versioning/themeColor_v0_v2.ts +0 -250
- package/src/theme/versioning/themeColor_v2_v2_9.ts +0 -50
- package/src/theme/versioning/v0_v2.ts +0 -106
- package/src/theme/versioning/v2_v0.ts +0 -153
|
@@ -1,512 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
arrow,
|
|
3
|
-
autoPlacement,
|
|
4
|
-
autoUpdate,
|
|
5
|
-
flip,
|
|
6
|
-
hide,
|
|
7
|
-
Middleware,
|
|
8
|
-
offset,
|
|
9
|
-
RootBoundary,
|
|
10
|
-
shift,
|
|
11
|
-
useFloating,
|
|
12
|
-
} from '@floating-ui/react-dom'
|
|
13
|
-
import {ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
14
|
-
import {AnimatePresence} from 'motion/react'
|
|
15
|
-
import {
|
|
16
|
-
cloneElement,
|
|
17
|
-
forwardRef,
|
|
18
|
-
type Ref,
|
|
19
|
-
useCallback,
|
|
20
|
-
useEffect,
|
|
21
|
-
useImperativeHandle,
|
|
22
|
-
useMemo,
|
|
23
|
-
useRef,
|
|
24
|
-
useState,
|
|
25
|
-
} from 'react'
|
|
26
|
-
|
|
27
|
-
import {useElementSize, useMediaIndex, usePrefersReducedMotion} from '../../hooks'
|
|
28
|
-
import {origin} from '../../middleware/origin'
|
|
29
|
-
import {_getArrayProp} from '../../styles'
|
|
30
|
-
import {useTheme_v2} from '../../theme'
|
|
31
|
-
import {BoxOverflow, CardTone, Placement, PopoverMargins} from '../../types'
|
|
32
|
-
import {LayerProps, LayerProvider, Portal, useBoundaryElement, useLayer} from '../../utils'
|
|
33
|
-
import {getElementRef} from '../../utils/getElementRef'
|
|
34
|
-
import {ResponsiveRadiusProps, ResponsiveShadowProps} from '../types'
|
|
35
|
-
import {
|
|
36
|
-
DEFAULT_FALLBACK_PLACEMENTS,
|
|
37
|
-
DEFAULT_POPOVER_DISTANCE,
|
|
38
|
-
DEFAULT_POPOVER_MARGINS,
|
|
39
|
-
DEFAULT_POPOVER_PADDING,
|
|
40
|
-
} from './constants'
|
|
41
|
-
import {size} from './floating-ui/size'
|
|
42
|
-
import {calcCurrentWidth, calcMaxWidth} from './helpers'
|
|
43
|
-
import {PopoverCard} from './popoverCard'
|
|
44
|
-
import {PopoverUpdateCallback, PopoverWidth} from './types'
|
|
45
|
-
|
|
46
|
-
/** @public */
|
|
47
|
-
export interface PopoverProps
|
|
48
|
-
extends Omit<LayerProps, 'as'>, ResponsiveRadiusProps, ResponsiveShadowProps {
|
|
49
|
-
/** @beta */
|
|
50
|
-
__unstable_margins?: PopoverMargins
|
|
51
|
-
/**
|
|
52
|
-
* Whether the popover should animate in and out.
|
|
53
|
-
*
|
|
54
|
-
* @beta
|
|
55
|
-
* @defaultValue false
|
|
56
|
-
*/
|
|
57
|
-
animate?: boolean
|
|
58
|
-
arrow?: boolean
|
|
59
|
-
/** @deprecated Use `floatingBoundary` and/or `referenceBoundary` instead */
|
|
60
|
-
boundaryElement?: HTMLElement | null
|
|
61
|
-
children?: React.JSX.Element
|
|
62
|
-
/**
|
|
63
|
-
* When `true`, prevent overflow within the current boundary:
|
|
64
|
-
* - by flipping on its side axis
|
|
65
|
-
* - by resizing
|
|
66
|
-
/*
|
|
67
|
-
* Note that:
|
|
68
|
-
* - setting `preventOverflow` to `true` also prevents overflow on its side axis
|
|
69
|
-
* - setting `matchReferenceWidth` to `true` also causes the popover to resize
|
|
70
|
-
*
|
|
71
|
-
* @defaultValue false
|
|
72
|
-
*/
|
|
73
|
-
constrainSize?: boolean
|
|
74
|
-
content?: React.ReactNode
|
|
75
|
-
disabled?: boolean
|
|
76
|
-
fallbackPlacements?: Placement[]
|
|
77
|
-
floatingBoundary?: HTMLElement | null
|
|
78
|
-
/**
|
|
79
|
-
* When `true`, set the maximum width to match the reference element, and also prevent overflow within
|
|
80
|
-
* the current boundary by resizing.
|
|
81
|
-
*
|
|
82
|
-
* Note that setting `constrainSize` to `true` also causes the popover to resize
|
|
83
|
-
*
|
|
84
|
-
* @defaultValue false
|
|
85
|
-
*/
|
|
86
|
-
matchReferenceWidth?: boolean
|
|
87
|
-
/**
|
|
88
|
-
* When true, blocks all pointer interaction with elements beneath the popover until closed.
|
|
89
|
-
*
|
|
90
|
-
* @beta
|
|
91
|
-
* @defaultValue false
|
|
92
|
-
*/
|
|
93
|
-
modal?: boolean
|
|
94
|
-
open?: boolean
|
|
95
|
-
overflow?: BoxOverflow
|
|
96
|
-
padding?: number | number[]
|
|
97
|
-
placement?: Placement
|
|
98
|
-
/**
|
|
99
|
-
* When 'flip' (default), the placement is determined from the initial placement and the
|
|
100
|
-
* fallback placements in order. Whichever fits in the viewport first.
|
|
101
|
-
*
|
|
102
|
-
* When 'autoPlacement', the initial placement and all fallback placements are evaluated
|
|
103
|
-
* and the placement with the most viewport space available.
|
|
104
|
-
*
|
|
105
|
-
* Option is only relevant if either `constrainSize` or `preventOverflow` is `true`
|
|
106
|
-
*/
|
|
107
|
-
placementStrategy?: 'flip' | 'autoPlacement'
|
|
108
|
-
/** Whether or not to render the popover in a portal element. */
|
|
109
|
-
portal?: boolean | string
|
|
110
|
-
preventOverflow?: boolean
|
|
111
|
-
referenceBoundary?: HTMLElement | null
|
|
112
|
-
/**
|
|
113
|
-
* When defined, the popover will be positioned relative to this element.
|
|
114
|
-
* The children of the popover won't be rendered.
|
|
115
|
-
*/
|
|
116
|
-
referenceElement?: HTMLElement | null
|
|
117
|
-
scheme?: ThemeColorSchemeKey
|
|
118
|
-
tone?: CardTone
|
|
119
|
-
/** @beta */
|
|
120
|
-
updateRef?: Ref<PopoverUpdateCallback | undefined>
|
|
121
|
-
width?: PopoverWidth | PopoverWidth[]
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const ViewportOverlay = () => {
|
|
125
|
-
const {zIndex} = useLayer()
|
|
126
|
-
|
|
127
|
-
return <div style={{height: '100vh', inset: 0, position: 'fixed', width: '100vw', zIndex}} />
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* The `Popover` component is used to display some content on top of another.
|
|
132
|
-
*
|
|
133
|
-
* @public
|
|
134
|
-
*/
|
|
135
|
-
export const Popover = forwardRef(function Popover(
|
|
136
|
-
props: PopoverProps &
|
|
137
|
-
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content' | 'width'>,
|
|
138
|
-
forwardedRef: React.ForwardedRef<HTMLDivElement>,
|
|
139
|
-
): React.JSX.Element {
|
|
140
|
-
const {container, layer} = useTheme_v2()
|
|
141
|
-
const boundaryElementContext = useBoundaryElement()
|
|
142
|
-
|
|
143
|
-
const {
|
|
144
|
-
__unstable_margins: margins = DEFAULT_POPOVER_MARGINS,
|
|
145
|
-
animate: _animate = false,
|
|
146
|
-
arrow: arrowProp = false,
|
|
147
|
-
// oxlint-disable-next-line no-deprecated
|
|
148
|
-
boundaryElement: _boundaryElement,
|
|
149
|
-
children: childProp,
|
|
150
|
-
constrainSize = false,
|
|
151
|
-
content,
|
|
152
|
-
disabled,
|
|
153
|
-
fallbackPlacements: _fallbackPlacements,
|
|
154
|
-
matchReferenceWidth,
|
|
155
|
-
floatingBoundary: _floatingBoundary,
|
|
156
|
-
modal,
|
|
157
|
-
// oxlint-disable-next-line no-unused-vars
|
|
158
|
-
onActivate,
|
|
159
|
-
open,
|
|
160
|
-
overflow = 'hidden',
|
|
161
|
-
padding: paddingProp,
|
|
162
|
-
placement: placementProp = 'bottom',
|
|
163
|
-
placementStrategy = 'flip',
|
|
164
|
-
portal,
|
|
165
|
-
preventOverflow = true,
|
|
166
|
-
radius: radiusProp = 3,
|
|
167
|
-
referenceBoundary: _referenceBoundary,
|
|
168
|
-
referenceElement,
|
|
169
|
-
scheme,
|
|
170
|
-
shadow: shadowProp = 3,
|
|
171
|
-
tone = 'inherit',
|
|
172
|
-
width: widthProp = 'auto',
|
|
173
|
-
zOffset: _zOffsetProp,
|
|
174
|
-
updateRef,
|
|
175
|
-
...restProps
|
|
176
|
-
} = props
|
|
177
|
-
const boundaryElement = _boundaryElement ?? boundaryElementContext?.element
|
|
178
|
-
const fallbackPlacements =
|
|
179
|
-
_fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? 'bottom']
|
|
180
|
-
const floatingBoundary =
|
|
181
|
-
// oxlint-disable-next-line no-deprecated
|
|
182
|
-
_floatingBoundary ?? props.boundaryElement ?? boundaryElementContext.element
|
|
183
|
-
const referenceBoundary =
|
|
184
|
-
// oxlint-disable-next-line no-deprecated
|
|
185
|
-
_referenceBoundary ?? props.boundaryElement ?? boundaryElementContext.element
|
|
186
|
-
const zOffsetProp = _zOffsetProp ?? layer.popover.zOffset
|
|
187
|
-
const prefersReducedMotion = usePrefersReducedMotion()
|
|
188
|
-
const animate = prefersReducedMotion ? false : _animate
|
|
189
|
-
const boundarySize = useElementSize(boundaryElement)?.border
|
|
190
|
-
const padding = _getArrayProp(paddingProp)
|
|
191
|
-
const radius = _getArrayProp(radiusProp)
|
|
192
|
-
const shadow = _getArrayProp(shadowProp)
|
|
193
|
-
const widthArrayProp = _getArrayProp(widthProp)
|
|
194
|
-
const zOffset = _getArrayProp(zOffsetProp)
|
|
195
|
-
const ref = useRef<HTMLDivElement | null>(null)
|
|
196
|
-
const arrowRef = useRef<HTMLDivElement | null>(null)
|
|
197
|
-
const rootBoundary: RootBoundary = 'viewport'
|
|
198
|
-
|
|
199
|
-
useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(forwardedRef, () => ref.current)
|
|
200
|
-
|
|
201
|
-
const mediaIndex = useMediaIndex()
|
|
202
|
-
const boundaryWidth = constrainSize || preventOverflow ? boundarySize?.width : undefined
|
|
203
|
-
|
|
204
|
-
// Update width when
|
|
205
|
-
// - media index changes
|
|
206
|
-
// - `width` property changes
|
|
207
|
-
const width = calcCurrentWidth({
|
|
208
|
-
container,
|
|
209
|
-
mediaIndex,
|
|
210
|
-
width: widthArrayProp,
|
|
211
|
-
})
|
|
212
|
-
const widthRef = useRef(width)
|
|
213
|
-
|
|
214
|
-
useEffect(() => {
|
|
215
|
-
widthRef.current = width
|
|
216
|
-
}, [width])
|
|
217
|
-
|
|
218
|
-
// Update max width when
|
|
219
|
-
// - boundary width changes
|
|
220
|
-
// - `width` property changes
|
|
221
|
-
const maxWidth = calcMaxWidth({boundaryWidth, currentWidth: width})
|
|
222
|
-
const maxWidthRef = useRef(maxWidth)
|
|
223
|
-
|
|
224
|
-
useEffect(() => {
|
|
225
|
-
maxWidthRef.current = maxWidth
|
|
226
|
-
}, [maxWidth])
|
|
227
|
-
|
|
228
|
-
// Keep track of reference element width (see `size` middleware below)
|
|
229
|
-
const referenceWidthRef = useRef<number>(undefined)
|
|
230
|
-
|
|
231
|
-
// Force apply width & max width to floating element
|
|
232
|
-
useEffect(() => {
|
|
233
|
-
const floatingElement = ref.current
|
|
234
|
-
|
|
235
|
-
if (!open || !floatingElement) return
|
|
236
|
-
|
|
237
|
-
const referenceWidth = referenceWidthRef.current
|
|
238
|
-
|
|
239
|
-
if (matchReferenceWidth) {
|
|
240
|
-
if (referenceWidth !== undefined) {
|
|
241
|
-
floatingElement.style.width = `${referenceWidth}px`
|
|
242
|
-
}
|
|
243
|
-
} else if (width !== undefined) {
|
|
244
|
-
floatingElement.style.width = `${width}px`
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (typeof maxWidth === 'number') {
|
|
248
|
-
floatingElement.style.maxWidth = `${maxWidth}px`
|
|
249
|
-
}
|
|
250
|
-
}, [width, matchReferenceWidth, maxWidth, open])
|
|
251
|
-
|
|
252
|
-
const [referenceWidth, setReferenceWidth] = useState<number | undefined>(undefined)
|
|
253
|
-
const middleware = useMiddleware({
|
|
254
|
-
animate,
|
|
255
|
-
arrowProp,
|
|
256
|
-
arrowRef,
|
|
257
|
-
constrainSize,
|
|
258
|
-
fallbackPlacements,
|
|
259
|
-
floatingBoundary,
|
|
260
|
-
margins,
|
|
261
|
-
matchReferenceWidth,
|
|
262
|
-
maxWidthRef,
|
|
263
|
-
placementProp,
|
|
264
|
-
placementStrategy,
|
|
265
|
-
preventOverflow,
|
|
266
|
-
referenceBoundary,
|
|
267
|
-
referenceWidthRef,
|
|
268
|
-
rootBoundary,
|
|
269
|
-
setReferenceWidth,
|
|
270
|
-
widthRef,
|
|
271
|
-
})
|
|
272
|
-
|
|
273
|
-
const {x, y, middlewareData, placement, refs, strategy, update} = useFloating({
|
|
274
|
-
middleware,
|
|
275
|
-
placement: placementProp,
|
|
276
|
-
whileElementsMounted: autoUpdate,
|
|
277
|
-
elements: referenceElement
|
|
278
|
-
? {
|
|
279
|
-
reference: referenceElement,
|
|
280
|
-
}
|
|
281
|
-
: undefined,
|
|
282
|
-
})
|
|
283
|
-
|
|
284
|
-
const referenceHidden = middlewareData.hide?.referenceHidden
|
|
285
|
-
|
|
286
|
-
const arrowX = middlewareData.arrow?.x
|
|
287
|
-
const arrowY = middlewareData.arrow?.y
|
|
288
|
-
|
|
289
|
-
const originX = middlewareData['@sanity/ui/origin']?.originX
|
|
290
|
-
const originY = middlewareData['@sanity/ui/origin']?.originY
|
|
291
|
-
|
|
292
|
-
const setArrow = useCallback((arrowEl: HTMLDivElement | null) => {
|
|
293
|
-
arrowRef.current = arrowEl
|
|
294
|
-
}, [])
|
|
295
|
-
|
|
296
|
-
const setFloating = useCallback(
|
|
297
|
-
(node: HTMLDivElement | null) => {
|
|
298
|
-
ref.current = node
|
|
299
|
-
refs.setFloating(node)
|
|
300
|
-
},
|
|
301
|
-
[refs],
|
|
302
|
-
)
|
|
303
|
-
|
|
304
|
-
// If there's a child then we need to set the reference element to the cloned child ref
|
|
305
|
-
// and if child changes we make sure to update or remove the reference element.
|
|
306
|
-
useImperativeHandle(childProp ? getElementRef(childProp) : null, () => refs.reference.current)
|
|
307
|
-
|
|
308
|
-
const child = useMemo(() => {
|
|
309
|
-
// If a reference element is defined, we don't need to clone the child
|
|
310
|
-
if (referenceElement) return childProp
|
|
311
|
-
|
|
312
|
-
if (!childProp) return null
|
|
313
|
-
|
|
314
|
-
return cloneElement(childProp, {ref: refs.setReference})
|
|
315
|
-
}, [childProp, referenceElement, refs.setReference])
|
|
316
|
-
|
|
317
|
-
useImperativeHandle(updateRef, () => update, [update])
|
|
318
|
-
|
|
319
|
-
if (disabled) {
|
|
320
|
-
return childProp || <></>
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const popover = (
|
|
324
|
-
<LayerProvider zOffset={zOffset}>
|
|
325
|
-
{/* Optional transparent blocking overlay at the top-most z-index layer. Must be positioned before the below popover card. */}
|
|
326
|
-
{modal && <ViewportOverlay />}
|
|
327
|
-
|
|
328
|
-
<PopoverCard
|
|
329
|
-
{...restProps}
|
|
330
|
-
__unstable_margins={margins}
|
|
331
|
-
animate={animate}
|
|
332
|
-
arrow={arrowProp}
|
|
333
|
-
arrowRef={setArrow}
|
|
334
|
-
arrowX={arrowX}
|
|
335
|
-
arrowY={arrowY}
|
|
336
|
-
hidden={referenceHidden}
|
|
337
|
-
overflow={overflow}
|
|
338
|
-
padding={padding}
|
|
339
|
-
placement={placement}
|
|
340
|
-
radius={radius}
|
|
341
|
-
ref={setFloating}
|
|
342
|
-
scheme={scheme}
|
|
343
|
-
shadow={shadow}
|
|
344
|
-
originX={originX}
|
|
345
|
-
originY={originY}
|
|
346
|
-
strategy={strategy}
|
|
347
|
-
tone={tone}
|
|
348
|
-
width={matchReferenceWidth ? referenceWidth : width}
|
|
349
|
-
x={x}
|
|
350
|
-
y={y}
|
|
351
|
-
>
|
|
352
|
-
{content}
|
|
353
|
-
</PopoverCard>
|
|
354
|
-
</LayerProvider>
|
|
355
|
-
)
|
|
356
|
-
|
|
357
|
-
const children =
|
|
358
|
-
open &&
|
|
359
|
-
(portal ? (
|
|
360
|
-
<Portal __unstable_name={typeof portal === 'string' ? portal : undefined}>{popover}</Portal>
|
|
361
|
-
) : (
|
|
362
|
-
popover
|
|
363
|
-
))
|
|
364
|
-
|
|
365
|
-
return (
|
|
366
|
-
<>
|
|
367
|
-
{/* the popover */}
|
|
368
|
-
{animate ? <AnimatePresence>{children}</AnimatePresence> : children}
|
|
369
|
-
|
|
370
|
-
{/* the referred element */}
|
|
371
|
-
{child}
|
|
372
|
-
</>
|
|
373
|
-
)
|
|
374
|
-
})
|
|
375
|
-
Popover.displayName = 'ForwardRef(Popover)'
|
|
376
|
-
|
|
377
|
-
function useMiddleware({
|
|
378
|
-
animate,
|
|
379
|
-
arrowProp,
|
|
380
|
-
arrowRef,
|
|
381
|
-
constrainSize,
|
|
382
|
-
fallbackPlacements,
|
|
383
|
-
floatingBoundary,
|
|
384
|
-
margins,
|
|
385
|
-
matchReferenceWidth,
|
|
386
|
-
maxWidthRef,
|
|
387
|
-
placementProp,
|
|
388
|
-
placementStrategy,
|
|
389
|
-
preventOverflow,
|
|
390
|
-
referenceBoundary,
|
|
391
|
-
referenceWidthRef,
|
|
392
|
-
rootBoundary,
|
|
393
|
-
setReferenceWidth,
|
|
394
|
-
widthRef,
|
|
395
|
-
}: {
|
|
396
|
-
animate: boolean
|
|
397
|
-
arrowProp: boolean
|
|
398
|
-
arrowRef: React.RefObject<HTMLDivElement | null>
|
|
399
|
-
constrainSize: boolean
|
|
400
|
-
fallbackPlacements: Placement[]
|
|
401
|
-
floatingBoundary: HTMLElement | null
|
|
402
|
-
margins: PopoverMargins
|
|
403
|
-
matchReferenceWidth: boolean | undefined
|
|
404
|
-
maxWidthRef: React.RefObject<number | undefined>
|
|
405
|
-
placementProp: Placement
|
|
406
|
-
placementStrategy: 'flip' | 'autoPlacement'
|
|
407
|
-
preventOverflow: boolean
|
|
408
|
-
referenceBoundary: HTMLElement | null
|
|
409
|
-
referenceWidthRef: React.RefObject<number | undefined>
|
|
410
|
-
rootBoundary: RootBoundary
|
|
411
|
-
setReferenceWidth: (referenceWidth: number) => void
|
|
412
|
-
widthRef: React.RefObject<number | undefined>
|
|
413
|
-
}) {
|
|
414
|
-
return useMemo(() => {
|
|
415
|
-
const ret: Middleware[] = []
|
|
416
|
-
|
|
417
|
-
// Flip the floating element when leaving the boundary box
|
|
418
|
-
if (constrainSize || preventOverflow) {
|
|
419
|
-
if (placementStrategy === 'autoPlacement') {
|
|
420
|
-
ret.push(
|
|
421
|
-
autoPlacement({
|
|
422
|
-
allowedPlacements: [placementProp].concat(fallbackPlacements),
|
|
423
|
-
}),
|
|
424
|
-
)
|
|
425
|
-
} else {
|
|
426
|
-
ret.push(
|
|
427
|
-
flip({
|
|
428
|
-
boundary: floatingBoundary || undefined,
|
|
429
|
-
fallbackPlacements,
|
|
430
|
-
padding: DEFAULT_POPOVER_PADDING,
|
|
431
|
-
rootBoundary,
|
|
432
|
-
}),
|
|
433
|
-
)
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
// Define distance between reference and floating element
|
|
438
|
-
ret.push(offset({mainAxis: DEFAULT_POPOVER_DISTANCE}))
|
|
439
|
-
|
|
440
|
-
// Track sizes
|
|
441
|
-
if (constrainSize || matchReferenceWidth) {
|
|
442
|
-
ret.push(
|
|
443
|
-
size({
|
|
444
|
-
boundaryElement: floatingBoundary || undefined,
|
|
445
|
-
constrainSize,
|
|
446
|
-
margins,
|
|
447
|
-
matchReferenceWidth,
|
|
448
|
-
maxWidthRef,
|
|
449
|
-
padding: DEFAULT_POPOVER_PADDING,
|
|
450
|
-
referenceWidthRef,
|
|
451
|
-
setReferenceWidth,
|
|
452
|
-
widthRef,
|
|
453
|
-
}),
|
|
454
|
-
)
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
// Shift the popover so its sits within the boundary element
|
|
458
|
-
if (preventOverflow) {
|
|
459
|
-
ret.push(
|
|
460
|
-
shift({
|
|
461
|
-
boundary: floatingBoundary || undefined,
|
|
462
|
-
rootBoundary,
|
|
463
|
-
padding: DEFAULT_POPOVER_PADDING,
|
|
464
|
-
}),
|
|
465
|
-
)
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
// Place arrow
|
|
469
|
-
if (arrowProp) {
|
|
470
|
-
ret.push(
|
|
471
|
-
arrow({
|
|
472
|
-
element: arrowRef,
|
|
473
|
-
padding: DEFAULT_POPOVER_PADDING,
|
|
474
|
-
}),
|
|
475
|
-
)
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
// Determine the origin to scale from.
|
|
479
|
-
// Must be placed after `@sanity/ui/size` and `shift` middleware.
|
|
480
|
-
if (animate) {
|
|
481
|
-
ret.push(origin)
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
ret.push(
|
|
485
|
-
hide({
|
|
486
|
-
boundary: referenceBoundary || undefined,
|
|
487
|
-
padding: DEFAULT_POPOVER_PADDING,
|
|
488
|
-
strategy: 'referenceHidden',
|
|
489
|
-
}),
|
|
490
|
-
)
|
|
491
|
-
|
|
492
|
-
return ret
|
|
493
|
-
}, [
|
|
494
|
-
animate,
|
|
495
|
-
arrowProp,
|
|
496
|
-
arrowRef,
|
|
497
|
-
constrainSize,
|
|
498
|
-
fallbackPlacements,
|
|
499
|
-
floatingBoundary,
|
|
500
|
-
margins,
|
|
501
|
-
matchReferenceWidth,
|
|
502
|
-
maxWidthRef,
|
|
503
|
-
placementProp,
|
|
504
|
-
placementStrategy,
|
|
505
|
-
preventOverflow,
|
|
506
|
-
referenceBoundary,
|
|
507
|
-
referenceWidthRef,
|
|
508
|
-
rootBoundary,
|
|
509
|
-
setReferenceWidth,
|
|
510
|
-
widthRef,
|
|
511
|
-
])
|
|
512
|
-
}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import {Strategy} from '@floating-ui/react-dom'
|
|
2
|
-
import {ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
3
|
-
import {motion, type MotionProps} from 'motion/react'
|
|
4
|
-
import React, {CSSProperties, forwardRef, useMemo} from 'react'
|
|
5
|
-
import {styled} from 'styled-components'
|
|
6
|
-
|
|
7
|
-
import {POPOVER_MOTION_PROPS} from '../../constants'
|
|
8
|
-
import {BoxOverflow, CardTone, Placement, PopoverMargins, Radius} from '../../types'
|
|
9
|
-
import {Arrow, useLayer} from '../../utils'
|
|
10
|
-
import {Card, CardProps} from '../card'
|
|
11
|
-
import {Flex} from '../flex'
|
|
12
|
-
import {
|
|
13
|
-
DEFAULT_POPOVER_ARROW_HEIGHT,
|
|
14
|
-
DEFAULT_POPOVER_ARROW_RADIUS,
|
|
15
|
-
DEFAULT_POPOVER_ARROW_WIDTH,
|
|
16
|
-
DEFAULT_POPOVER_MARGINS,
|
|
17
|
-
} from './constants'
|
|
18
|
-
|
|
19
|
-
const MotionCard = styled(motion.create(Card))`
|
|
20
|
-
&:not([hidden]) {
|
|
21
|
-
display: flex;
|
|
22
|
-
}
|
|
23
|
-
flex-direction: column;
|
|
24
|
-
width: max-content;
|
|
25
|
-
min-width: min-content;
|
|
26
|
-
will-change: transform;
|
|
27
|
-
`
|
|
28
|
-
|
|
29
|
-
const MotionFlex = styled(motion.create(Flex))`
|
|
30
|
-
will-change: opacity;
|
|
31
|
-
`
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
export const PopoverCard = forwardRef(function PopoverCard(
|
|
37
|
-
props: {
|
|
38
|
-
/** @beta*/
|
|
39
|
-
__unstable_margins?: PopoverMargins
|
|
40
|
-
animate?: boolean
|
|
41
|
-
arrow: boolean
|
|
42
|
-
arrowRef: React.Ref<HTMLDivElement>
|
|
43
|
-
arrowX?: number
|
|
44
|
-
arrowY?: number
|
|
45
|
-
originX?: number
|
|
46
|
-
originY?: number
|
|
47
|
-
overflow?: BoxOverflow
|
|
48
|
-
padding?: number | number[]
|
|
49
|
-
placement: Placement
|
|
50
|
-
radius?: Radius | Radius[]
|
|
51
|
-
scheme?: ThemeColorSchemeKey
|
|
52
|
-
shadow?: number | number[]
|
|
53
|
-
strategy: Strategy
|
|
54
|
-
tone: CardTone
|
|
55
|
-
width: number | undefined
|
|
56
|
-
x: number | null
|
|
57
|
-
y: number | null
|
|
58
|
-
} & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'width'>,
|
|
59
|
-
ref: React.ForwardedRef<HTMLDivElement>,
|
|
60
|
-
) {
|
|
61
|
-
const {
|
|
62
|
-
__unstable_margins: marginsProp,
|
|
63
|
-
animate,
|
|
64
|
-
arrow,
|
|
65
|
-
arrowRef,
|
|
66
|
-
arrowX,
|
|
67
|
-
arrowY,
|
|
68
|
-
children,
|
|
69
|
-
padding,
|
|
70
|
-
placement,
|
|
71
|
-
originX,
|
|
72
|
-
originY,
|
|
73
|
-
overflow,
|
|
74
|
-
radius,
|
|
75
|
-
scheme,
|
|
76
|
-
shadow,
|
|
77
|
-
strategy,
|
|
78
|
-
style,
|
|
79
|
-
tone,
|
|
80
|
-
width,
|
|
81
|
-
x: xProp,
|
|
82
|
-
y: yProp,
|
|
83
|
-
...restProps
|
|
84
|
-
} = props
|
|
85
|
-
|
|
86
|
-
const {zIndex} = useLayer()
|
|
87
|
-
|
|
88
|
-
// Get margins: [top, right, bottom, left]
|
|
89
|
-
const margins: PopoverMargins = useMemo(
|
|
90
|
-
() => marginsProp || DEFAULT_POPOVER_MARGINS,
|
|
91
|
-
[marginsProp],
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
// Translate according to margins
|
|
95
|
-
const x = (xProp ?? 0) + margins[3]
|
|
96
|
-
const y = (yProp ?? 0) + margins[0]
|
|
97
|
-
|
|
98
|
-
const rootStyle: CSSProperties = useMemo(
|
|
99
|
-
() => ({
|
|
100
|
-
left: x,
|
|
101
|
-
originX,
|
|
102
|
-
originY,
|
|
103
|
-
position: strategy,
|
|
104
|
-
top: y,
|
|
105
|
-
width,
|
|
106
|
-
zIndex,
|
|
107
|
-
willChange: animate ? 'transform' : undefined,
|
|
108
|
-
...style,
|
|
109
|
-
}),
|
|
110
|
-
[animate, originX, originY, strategy, style, width, x, y, zIndex],
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
const arrowStyle: CSSProperties = useMemo(
|
|
114
|
-
() => ({
|
|
115
|
-
left: arrowX !== null ? arrowX : undefined,
|
|
116
|
-
top: arrowY !== null ? arrowY : undefined,
|
|
117
|
-
right: undefined,
|
|
118
|
-
bottom: undefined,
|
|
119
|
-
}),
|
|
120
|
-
[arrowX, arrowY],
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<MotionCard
|
|
125
|
-
data-ui="Popover"
|
|
126
|
-
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
127
|
-
{...(restProps as CardProps & MotionProps)}
|
|
128
|
-
data-placement={placement}
|
|
129
|
-
radius={radius}
|
|
130
|
-
ref={ref}
|
|
131
|
-
scheme={scheme}
|
|
132
|
-
shadow={shadow}
|
|
133
|
-
sizing="border"
|
|
134
|
-
style={rootStyle}
|
|
135
|
-
tone={tone}
|
|
136
|
-
variants={POPOVER_MOTION_PROPS.card}
|
|
137
|
-
transition={POPOVER_MOTION_PROPS.transition}
|
|
138
|
-
initial={animate ? ['hidden', 'initial'] : undefined}
|
|
139
|
-
animate={animate ? ['visible', 'scaleIn'] : undefined}
|
|
140
|
-
exit={animate ? ['hidden', 'scaleOut'] : undefined}
|
|
141
|
-
>
|
|
142
|
-
<MotionFlex
|
|
143
|
-
data-ui="Popover__wrapper"
|
|
144
|
-
direction="column"
|
|
145
|
-
flex={1}
|
|
146
|
-
overflow={overflow}
|
|
147
|
-
variants={POPOVER_MOTION_PROPS.children}
|
|
148
|
-
transition={POPOVER_MOTION_PROPS.transition}
|
|
149
|
-
>
|
|
150
|
-
<Flex direction="column" flex={1} padding={padding}>
|
|
151
|
-
{children}
|
|
152
|
-
</Flex>
|
|
153
|
-
</MotionFlex>
|
|
154
|
-
|
|
155
|
-
{arrow && (
|
|
156
|
-
<Arrow
|
|
157
|
-
ref={arrowRef}
|
|
158
|
-
style={arrowStyle}
|
|
159
|
-
width={DEFAULT_POPOVER_ARROW_WIDTH}
|
|
160
|
-
height={DEFAULT_POPOVER_ARROW_HEIGHT}
|
|
161
|
-
radius={DEFAULT_POPOVER_ARROW_RADIUS}
|
|
162
|
-
/>
|
|
163
|
-
)}
|
|
164
|
-
</MotionCard>
|
|
165
|
-
)
|
|
166
|
-
})
|
|
167
|
-
PopoverCard.displayName = 'ForwardRef(PopoverCard)'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './radio'
|