@sanity/ui 3.3.2 → 3.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +8 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -16
- package/dist/index.mjs +16 -16
- package/dist/index.mjs.map +1 -1
- package/dist/tabList.js +2 -2
- package/dist/tabList.mjs +2 -2
- package/dist/tabList.mjs.map +1 -1
- package/dist/useTheme.d.mts +3 -3
- package/dist/useTheme.d.mts.map +1 -1
- package/dist/useTheme.d.ts +3 -3
- package/dist/useTheme.d.ts.map +1 -1
- package/package.json +8 -13
- 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,118 +0,0 @@
|
|
|
1
|
-
import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
|
|
2
|
-
import {css} from 'styled-components'
|
|
3
|
-
|
|
4
|
-
import {ThemeProps} from '../../styles'
|
|
5
|
-
import {_cardColorStyle} from '../../styles/card'
|
|
6
|
-
import {focusRingBorderStyle, focusRingStyle} from '../../styles/internal'
|
|
7
|
-
import {ButtonMode, ButtonTone, ButtonWidth} from '../../types'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export function buttonBaseStyles(
|
|
13
|
-
props: {$width?: ButtonWidth} & ThemeProps,
|
|
14
|
-
): ReturnType<typeof css> {
|
|
15
|
-
const {$width} = props
|
|
16
|
-
const {style} = getTheme_v2(props.theme)
|
|
17
|
-
|
|
18
|
-
return css`
|
|
19
|
-
${style?.button};
|
|
20
|
-
|
|
21
|
-
-webkit-font-smoothing: inherit;
|
|
22
|
-
appearance: none;
|
|
23
|
-
display: inline-flex;
|
|
24
|
-
align-items: center;
|
|
25
|
-
font: inherit;
|
|
26
|
-
border: 0;
|
|
27
|
-
outline: none;
|
|
28
|
-
user-select: none;
|
|
29
|
-
text-decoration: none;
|
|
30
|
-
border: 0;
|
|
31
|
-
box-sizing: border-box;
|
|
32
|
-
padding: 0;
|
|
33
|
-
margin: 0;
|
|
34
|
-
white-space: nowrap;
|
|
35
|
-
text-align: left;
|
|
36
|
-
position: relative;
|
|
37
|
-
vertical-align: top;
|
|
38
|
-
|
|
39
|
-
${$width === 'fill' &&
|
|
40
|
-
css`
|
|
41
|
-
width: -moz-available;
|
|
42
|
-
width: -webkit-fill-available;
|
|
43
|
-
width: stretch;
|
|
44
|
-
`}
|
|
45
|
-
|
|
46
|
-
& > span {
|
|
47
|
-
display: block;
|
|
48
|
-
flex: 1;
|
|
49
|
-
min-width: 0;
|
|
50
|
-
border-radius: inherit;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
&::-moz-focus-inner {
|
|
54
|
-
border: 0;
|
|
55
|
-
padding: 0;
|
|
56
|
-
}
|
|
57
|
-
`
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function combineBoxShadow(...boxShadows: (string | undefined)[]): string {
|
|
61
|
-
return boxShadows.filter(Boolean).join(',')
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @internal
|
|
66
|
-
*/
|
|
67
|
-
export function buttonColorStyles(
|
|
68
|
-
props: {$mode: ButtonMode; $tone: ButtonTone} & ThemeProps,
|
|
69
|
-
): CSSObject[] {
|
|
70
|
-
const {$mode} = props
|
|
71
|
-
const {button, color: baseColor, style} = getTheme_v2(props.theme)
|
|
72
|
-
const shadow = props.$mode === 'ghost'
|
|
73
|
-
const mode = baseColor.button[$mode] || baseColor.button.default
|
|
74
|
-
const color = mode[props.$tone] || mode.default
|
|
75
|
-
const border = {
|
|
76
|
-
width: button.border.width,
|
|
77
|
-
color: 'var(--card-border-color)',
|
|
78
|
-
}
|
|
79
|
-
// const defaultBoxShadow = `inset 0px -1.5px 0px ${buttonTheme.border.width}px color-mix(in srgb, var(--card-border-color) 25%, var(--card-bg-color))`
|
|
80
|
-
const defaultBoxShadow = undefined
|
|
81
|
-
|
|
82
|
-
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
83
|
-
return [
|
|
84
|
-
_cardColorStyle(baseColor, color.enabled),
|
|
85
|
-
{
|
|
86
|
-
'backgroundColor': 'var(--card-bg-color)',
|
|
87
|
-
'color': 'var(--card-fg-color)',
|
|
88
|
-
'boxShadow': focusRingBorderStyle(border),
|
|
89
|
-
'&:disabled, &[data-disabled="true"]': _cardColorStyle(baseColor, color.disabled),
|
|
90
|
-
"&:not([data-disabled='true'])": {
|
|
91
|
-
'boxShadow': combineBoxShadow(
|
|
92
|
-
focusRingBorderStyle(border),
|
|
93
|
-
shadow ? defaultBoxShadow : undefined,
|
|
94
|
-
),
|
|
95
|
-
'&:focus': {
|
|
96
|
-
boxShadow: focusRingStyle({
|
|
97
|
-
base: baseColor,
|
|
98
|
-
border: {width: 2, color: baseColor.bg},
|
|
99
|
-
focusRing: button.focusRing,
|
|
100
|
-
}),
|
|
101
|
-
},
|
|
102
|
-
'&:focus:not(:focus-visible)': {
|
|
103
|
-
boxShadow: combineBoxShadow(
|
|
104
|
-
focusRingBorderStyle(border),
|
|
105
|
-
shadow ? defaultBoxShadow : undefined,
|
|
106
|
-
),
|
|
107
|
-
},
|
|
108
|
-
'@media (hover: hover)': {
|
|
109
|
-
'&:hover': _cardColorStyle(baseColor, color.hovered),
|
|
110
|
-
'&:active': _cardColorStyle(baseColor, color.pressed),
|
|
111
|
-
'&[data-hovered]': _cardColorStyle(baseColor, color.hovered),
|
|
112
|
-
},
|
|
113
|
-
'&[data-selected]': _cardColorStyle(baseColor, color.pressed),
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
style?.button?.root,
|
|
117
|
-
].filter(Boolean) as CSSObject[]
|
|
118
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import {ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
2
|
-
import {forwardRef} from 'react'
|
|
3
|
-
import {isValidElementType} from 'react-is'
|
|
4
|
-
import {styled} from 'styled-components'
|
|
5
|
-
|
|
6
|
-
import {_getArrayProp} from '../../styles'
|
|
7
|
-
import {
|
|
8
|
-
responsiveBorderStyle,
|
|
9
|
-
ResponsiveBorderStyleProps,
|
|
10
|
-
responsiveRadiusStyle,
|
|
11
|
-
ResponsiveRadiusStyleProps,
|
|
12
|
-
responsiveShadowStyle,
|
|
13
|
-
ResponsiveShadowStyleProps,
|
|
14
|
-
} from '../../styles/internal'
|
|
15
|
-
import {ThemeColorProvider, useRootTheme} from '../../theme'
|
|
16
|
-
import {CardTone, ElementType, Props} from '../../types'
|
|
17
|
-
import {Box, BoxOwnProps} from '../box'
|
|
18
|
-
import {ResponsiveBorderProps, ResponsiveRadiusProps, ResponsiveShadowProps} from '../types'
|
|
19
|
-
import {cardStyle} from './styles'
|
|
20
|
-
import {CardStyleProps} from './types'
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
export interface CardOwnProps
|
|
26
|
-
extends BoxOwnProps, ResponsiveBorderProps, ResponsiveRadiusProps, ResponsiveShadowProps {
|
|
27
|
-
/**
|
|
28
|
-
* Do not use in production.
|
|
29
|
-
* @beta
|
|
30
|
-
*/
|
|
31
|
-
__unstable_checkered?: boolean
|
|
32
|
-
/**
|
|
33
|
-
* Do not use in production.
|
|
34
|
-
* @beta
|
|
35
|
-
*/
|
|
36
|
-
__unstable_focusRing?: boolean
|
|
37
|
-
disabled?: boolean
|
|
38
|
-
muted?: boolean
|
|
39
|
-
pressed?: boolean
|
|
40
|
-
scheme?: ThemeColorSchemeKey
|
|
41
|
-
selected?: boolean
|
|
42
|
-
tone?: CardTone
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
export type CardProps<E extends ElementType = 'div'> = Props<CardOwnProps, E>
|
|
49
|
-
|
|
50
|
-
const StyledCard = styled(Box)<
|
|
51
|
-
CardStyleProps &
|
|
52
|
-
ResponsiveRadiusStyleProps &
|
|
53
|
-
ResponsiveBorderStyleProps &
|
|
54
|
-
ResponsiveShadowStyleProps
|
|
55
|
-
>(responsiveBorderStyle, responsiveRadiusStyle, responsiveShadowStyle, cardStyle)
|
|
56
|
-
|
|
57
|
-
const CardComponent = forwardRef(function Card(
|
|
58
|
-
props: CardOwnProps & {as?: ElementType} & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height'>,
|
|
59
|
-
ref: React.ForwardedRef<HTMLDivElement>,
|
|
60
|
-
) {
|
|
61
|
-
const {
|
|
62
|
-
__unstable_checkered: checkered = false,
|
|
63
|
-
__unstable_focusRing: focusRing = false,
|
|
64
|
-
as: asProp,
|
|
65
|
-
border,
|
|
66
|
-
borderTop,
|
|
67
|
-
borderRight,
|
|
68
|
-
borderBottom,
|
|
69
|
-
borderLeft,
|
|
70
|
-
muted,
|
|
71
|
-
pressed,
|
|
72
|
-
radius = 0,
|
|
73
|
-
scheme,
|
|
74
|
-
selected,
|
|
75
|
-
shadow,
|
|
76
|
-
tone: toneProp = 'default',
|
|
77
|
-
...restProps
|
|
78
|
-
} = props
|
|
79
|
-
|
|
80
|
-
const as = isValidElementType(asProp) ? asProp : 'div'
|
|
81
|
-
const rootTheme = useRootTheme()
|
|
82
|
-
const tone = toneProp === 'inherit' ? rootTheme.tone : toneProp
|
|
83
|
-
|
|
84
|
-
// todo: Consider adding the wrapper approach for nested cards in which the tones are not changing, avoid unnecessary ThemeColorProvider
|
|
85
|
-
return (
|
|
86
|
-
<ThemeColorProvider scheme={scheme} tone={tone}>
|
|
87
|
-
<StyledCard
|
|
88
|
-
data-as={typeof as === 'string' ? as : undefined}
|
|
89
|
-
data-scheme={rootTheme.scheme}
|
|
90
|
-
data-ui="Card"
|
|
91
|
-
data-tone={tone}
|
|
92
|
-
{...restProps}
|
|
93
|
-
$border={_getArrayProp(border)}
|
|
94
|
-
$borderTop={_getArrayProp(borderTop)}
|
|
95
|
-
$borderRight={_getArrayProp(borderRight)}
|
|
96
|
-
$borderBottom={_getArrayProp(borderBottom)}
|
|
97
|
-
$borderLeft={_getArrayProp(borderLeft)}
|
|
98
|
-
$checkered={checkered}
|
|
99
|
-
$focusRing={focusRing}
|
|
100
|
-
$muted={muted}
|
|
101
|
-
$radius={_getArrayProp(radius)}
|
|
102
|
-
$shadow={_getArrayProp(shadow)}
|
|
103
|
-
$tone={tone}
|
|
104
|
-
data-checkered={checkered ? '' : undefined}
|
|
105
|
-
data-pressed={pressed ? '' : undefined}
|
|
106
|
-
data-selected={selected ? '' : undefined}
|
|
107
|
-
forwardedAs={as}
|
|
108
|
-
ref={ref}
|
|
109
|
-
selected={selected}
|
|
110
|
-
/>
|
|
111
|
-
</ThemeColorProvider>
|
|
112
|
-
)
|
|
113
|
-
})
|
|
114
|
-
CardComponent.displayName = 'ForwardRef(Card)'
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* The `Card` component acts much like a `Box`, but with a background and foreground color.
|
|
118
|
-
* Components within a `Card` inherit its colors.
|
|
119
|
-
*
|
|
120
|
-
* @public
|
|
121
|
-
*/
|
|
122
|
-
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
123
|
-
export const Card = CardComponent as unknown as <E extends ElementType = 'div'>(
|
|
124
|
-
props: CardProps<E>,
|
|
125
|
-
) => React.JSX.Element
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import {getTheme_v2} from '@sanity/ui/theme'
|
|
2
|
-
import {css} from 'styled-components'
|
|
3
|
-
|
|
4
|
-
import {ThemeProps} from '../../styles'
|
|
5
|
-
import {_cardColorStyle} from '../../styles/card'
|
|
6
|
-
import {focusRingStyle} from '../../styles/focusRing'
|
|
7
|
-
import {CardStyleProps} from './types'
|
|
8
|
-
|
|
9
|
-
export function cardStyle(
|
|
10
|
-
props: CardStyleProps & ThemeProps,
|
|
11
|
-
): Array<ReturnType<typeof css> | (() => ReturnType<typeof css>)> {
|
|
12
|
-
return [cardBaseStyle(props), cardColorStyle(props)]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function cardBaseStyle(props: CardStyleProps & ThemeProps): ReturnType<typeof css> {
|
|
16
|
-
const {$checkered} = props
|
|
17
|
-
const {space} = getTheme_v2(props.theme)
|
|
18
|
-
|
|
19
|
-
return css`
|
|
20
|
-
${$checkered &&
|
|
21
|
-
css`
|
|
22
|
-
background-size: ${space[3]}px ${space[3]}px;
|
|
23
|
-
background-position: 50% 50%;
|
|
24
|
-
background-image: var(--card-bg-image);
|
|
25
|
-
`}
|
|
26
|
-
|
|
27
|
-
&[data-as='button'] {
|
|
28
|
-
-webkit-font-smoothing: inherit;
|
|
29
|
-
appearance: none;
|
|
30
|
-
outline: none;
|
|
31
|
-
font: inherit;
|
|
32
|
-
text-align: inherit;
|
|
33
|
-
border: 0;
|
|
34
|
-
width: -moz-available;
|
|
35
|
-
width: -webkit-fill-available;
|
|
36
|
-
width: stretch;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/* &:is(a) */
|
|
40
|
-
&[data-as='a'] {
|
|
41
|
-
outline: none;
|
|
42
|
-
text-decoration: none;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/* &:is(pre) */
|
|
46
|
-
&[data-as='pre'] {
|
|
47
|
-
font: inherit;
|
|
48
|
-
}
|
|
49
|
-
`
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function cardColorStyle(props: CardStyleProps & ThemeProps): ReturnType<typeof css> {
|
|
53
|
-
const {$checkered, $focusRing, $muted} = props
|
|
54
|
-
const {card, color, style} = getTheme_v2(props.theme)
|
|
55
|
-
const border = {width: card.border.width, color: 'var(--card-border-color)'}
|
|
56
|
-
|
|
57
|
-
return css`
|
|
58
|
-
color-scheme: ${color._dark ? 'dark' : 'light'};
|
|
59
|
-
|
|
60
|
-
${_cardColorStyle(color, color, $checkered)}
|
|
61
|
-
|
|
62
|
-
background-color: ${$muted ? 'var(--card-muted-bg-color)' : 'var(--card-bg-color)'};
|
|
63
|
-
color: var(--card-fg-color);
|
|
64
|
-
|
|
65
|
-
/* &:is(button) */
|
|
66
|
-
&[data-as='button'] {
|
|
67
|
-
--card-focus-ring-box-shadow: none;
|
|
68
|
-
|
|
69
|
-
cursor: default;
|
|
70
|
-
box-shadow: var(--card-focus-ring-box-shadow);
|
|
71
|
-
|
|
72
|
-
&:disabled {
|
|
73
|
-
${_cardColorStyle(color, color.selectable.default.disabled, $checkered)}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
&:not(:disabled) {
|
|
77
|
-
&[data-pressed] {
|
|
78
|
-
${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
&[data-selected] {
|
|
82
|
-
${_cardColorStyle(color, color.selectable.default.selected, $checkered)}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
@media (hover: hover) {
|
|
86
|
-
&:not([data-pressed]):not([data-selected]) {
|
|
87
|
-
&[data-hovered],
|
|
88
|
-
&:hover {
|
|
89
|
-
${_cardColorStyle(color, color.selectable.default.hovered, $checkered)}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
&:active {
|
|
93
|
-
${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
&:focus-visible {
|
|
99
|
-
--card-focus-ring-box-shadow: ${$focusRing
|
|
100
|
-
? focusRingStyle({base: color, border, focusRing: card.focusRing})
|
|
101
|
-
: undefined};
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/* &:is(a) */
|
|
107
|
-
&[data-as='a'] {
|
|
108
|
-
cursor: pointer;
|
|
109
|
-
box-shadow: var(--card-focus-ring-box-shadow);
|
|
110
|
-
|
|
111
|
-
&[data-disabled] {
|
|
112
|
-
${_cardColorStyle(color, color.selectable.default.disabled, $checkered)}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
&:not([data-disabled]) {
|
|
116
|
-
&[data-pressed] {
|
|
117
|
-
${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
&[data-selected] {
|
|
121
|
-
${_cardColorStyle(color, color.selectable.default.selected, $checkered)}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
@media (hover: hover) {
|
|
125
|
-
&:not([data-pressed]):not([data-selected]) {
|
|
126
|
-
&[data-hovered],
|
|
127
|
-
&:hover {
|
|
128
|
-
${_cardColorStyle(color, color.selectable.default.hovered, $checkered)}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
&:active {
|
|
132
|
-
${_cardColorStyle(color, color.selectable.default.pressed, $checkered)}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
&:focus-visible {
|
|
138
|
-
--card-focus-ring-box-shadow: ${$focusRing
|
|
139
|
-
? focusRingStyle({base: color, border, focusRing: card.focusRing})
|
|
140
|
-
: undefined};
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
${style?.card?.root}
|
|
146
|
-
`
|
|
147
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import {CheckmarkIcon, RemoveIcon} from '@sanity/icons'
|
|
2
|
-
import {forwardRef, useEffect, useImperativeHandle, useRef} from 'react'
|
|
3
|
-
import {styled} from 'styled-components'
|
|
4
|
-
|
|
5
|
-
import {useCustomValidity} from '../../hooks'
|
|
6
|
-
import {checkboxBaseStyles, inputElementStyles} from './styles'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export interface CheckboxProps {
|
|
12
|
-
indeterminate?: boolean
|
|
13
|
-
customValidity?: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const StyledCheckbox = styled.div(checkboxBaseStyles)
|
|
17
|
-
const Input = styled.input(inputElementStyles)
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Checkboxes allow the user to select one or more items from a set.
|
|
21
|
-
*
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
export const Checkbox = forwardRef(function Checkbox(
|
|
25
|
-
props: Omit<React.HTMLProps<HTMLInputElement>, 'as' | 'type'> & CheckboxProps,
|
|
26
|
-
forwardedRef: React.ForwardedRef<HTMLInputElement>,
|
|
27
|
-
) {
|
|
28
|
-
const {
|
|
29
|
-
checked,
|
|
30
|
-
className,
|
|
31
|
-
disabled,
|
|
32
|
-
indeterminate,
|
|
33
|
-
customValidity,
|
|
34
|
-
readOnly,
|
|
35
|
-
style,
|
|
36
|
-
...restProps
|
|
37
|
-
} = props
|
|
38
|
-
const ref = useRef<HTMLInputElement | null>(null)
|
|
39
|
-
|
|
40
|
-
useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(
|
|
41
|
-
forwardedRef,
|
|
42
|
-
() => ref.current,
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (ref.current) {
|
|
47
|
-
// Set the indeterminate state
|
|
48
|
-
ref.current.indeterminate = indeterminate || false
|
|
49
|
-
}
|
|
50
|
-
}, [indeterminate])
|
|
51
|
-
|
|
52
|
-
useCustomValidity(ref, customValidity)
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<StyledCheckbox className={className} data-ui="Checkbox" style={style}>
|
|
56
|
-
<Input
|
|
57
|
-
data-read-only={!disabled && readOnly ? '' : undefined}
|
|
58
|
-
data-error={customValidity ? '' : undefined}
|
|
59
|
-
{...restProps}
|
|
60
|
-
checked={checked}
|
|
61
|
-
disabled={disabled || readOnly}
|
|
62
|
-
type="checkbox"
|
|
63
|
-
readOnly={readOnly}
|
|
64
|
-
ref={ref}
|
|
65
|
-
/>
|
|
66
|
-
<span>
|
|
67
|
-
<CheckmarkIcon />
|
|
68
|
-
<RemoveIcon />
|
|
69
|
-
</span>
|
|
70
|
-
</StyledCheckbox>
|
|
71
|
-
)
|
|
72
|
-
})
|
|
73
|
-
Checkbox.displayName = 'ForwardRef(Checkbox)'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './checkbox'
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import {getTheme_v2} from '@sanity/ui/theme'
|
|
2
|
-
import {css} from 'styled-components'
|
|
3
|
-
|
|
4
|
-
import {rem, ThemeProps} from '../../styles'
|
|
5
|
-
import {focusRingBorderStyle, focusRingStyle} from '../../styles/internal'
|
|
6
|
-
|
|
7
|
-
export function checkboxBaseStyles(): ReturnType<typeof css> {
|
|
8
|
-
return css`
|
|
9
|
-
position: relative;
|
|
10
|
-
display: inline-block;
|
|
11
|
-
`
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function inputElementStyles(props: ThemeProps): ReturnType<typeof css> {
|
|
15
|
-
const {color, input, radius} = getTheme_v2(props.theme)
|
|
16
|
-
const {focusRing} = input.checkbox
|
|
17
|
-
|
|
18
|
-
return css`
|
|
19
|
-
position: absolute;
|
|
20
|
-
top: 0;
|
|
21
|
-
left: 0;
|
|
22
|
-
width: 100%;
|
|
23
|
-
height: 100%;
|
|
24
|
-
outline: none;
|
|
25
|
-
opacity: 0;
|
|
26
|
-
z-index: 1;
|
|
27
|
-
padding: 0;
|
|
28
|
-
margin: 0;
|
|
29
|
-
|
|
30
|
-
& + span {
|
|
31
|
-
position: relative;
|
|
32
|
-
display: block;
|
|
33
|
-
height: ${rem(input.checkbox.size)};
|
|
34
|
-
width: ${rem(input.checkbox.size)};
|
|
35
|
-
box-sizing: border-box;
|
|
36
|
-
box-shadow: ${focusRingBorderStyle({
|
|
37
|
-
color: color.input.default.enabled.border,
|
|
38
|
-
width: input.border.width,
|
|
39
|
-
})};
|
|
40
|
-
border-radius: ${rem(radius[2])};
|
|
41
|
-
line-height: 1;
|
|
42
|
-
background-color: ${color.input.default.enabled.bg};
|
|
43
|
-
|
|
44
|
-
& > svg {
|
|
45
|
-
display: block;
|
|
46
|
-
position: absolute;
|
|
47
|
-
opacity: 0;
|
|
48
|
-
height: 100%;
|
|
49
|
-
width: 100%;
|
|
50
|
-
|
|
51
|
-
& > path {
|
|
52
|
-
vector-effect: non-scaling-stroke;
|
|
53
|
-
stroke-width: 1.5px !important;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&:checked + span {
|
|
59
|
-
background: ${color.input.default.enabled.fg};
|
|
60
|
-
box-shadow: ${focusRingBorderStyle({
|
|
61
|
-
color: color.input.default.enabled.fg,
|
|
62
|
-
width: input.border.width,
|
|
63
|
-
})};
|
|
64
|
-
color: ${color.input.default.enabled.bg};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/* focus */
|
|
68
|
-
&:not(:disabled):focus:focus-visible + span {
|
|
69
|
-
box-shadow: ${focusRingStyle({focusRing})};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/* focus when checked - uses a different offset */
|
|
73
|
-
&:not(:disabled):focus:focus-visible&:checked + span {
|
|
74
|
-
box-shadow: ${focusRingStyle({focusRing: {width: 1, offset: 1}})};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
&[data-error] + span {
|
|
78
|
-
background-color: ${color.input.invalid.enabled.border};
|
|
79
|
-
box-shadow: ${focusRingBorderStyle({
|
|
80
|
-
width: input.border.width,
|
|
81
|
-
color: color.input.invalid.enabled.muted.bg,
|
|
82
|
-
})};
|
|
83
|
-
color: ${color.input.default.disabled.fg};
|
|
84
|
-
}
|
|
85
|
-
&[data-error]&:checked + span {
|
|
86
|
-
background-color: ${color.input.invalid.enabled.muted.bg};
|
|
87
|
-
color: ${color.input.default.enabled.bg};
|
|
88
|
-
}
|
|
89
|
-
&[data-error]&:checked&:not(:disabled):focus:focus-visible + span {
|
|
90
|
-
box-shadow: ${focusRingStyle({
|
|
91
|
-
border: {width: input.border.width, color: color.input.invalid.readOnly.muted.bg},
|
|
92
|
-
focusRing: {width: 1, offset: 1},
|
|
93
|
-
})};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
&:disabled + span {
|
|
97
|
-
background-color: ${color.input.default.disabled.bg};
|
|
98
|
-
box-shadow: ${focusRingBorderStyle({
|
|
99
|
-
width: input.border.width,
|
|
100
|
-
color: color.input.default.disabled.border,
|
|
101
|
-
})};
|
|
102
|
-
color: ${color.input.default.disabled.fg};
|
|
103
|
-
}
|
|
104
|
-
&:disabled&:checked + span {
|
|
105
|
-
background-color: ${color.input.default.disabled.muted.bg};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
&[data-read-only] + span {
|
|
109
|
-
background-color: ${color.input.default.readOnly.bg};
|
|
110
|
-
box-shadow: ${focusRingBorderStyle({
|
|
111
|
-
width: input.border.width,
|
|
112
|
-
color: color.input.default.readOnly.border,
|
|
113
|
-
})};
|
|
114
|
-
color: ${color.input.default.readOnly.fg};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
&[data-read-only]&:checked + span {
|
|
118
|
-
background-color: ${color.input.default.readOnly.muted.bg};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
&:checked + span > svg:first-child {
|
|
122
|
-
opacity: 1;
|
|
123
|
-
}
|
|
124
|
-
&:indeterminate + span > svg:last-child {
|
|
125
|
-
opacity: 1;
|
|
126
|
-
}
|
|
127
|
-
`
|
|
128
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {forwardRef, lazy, Suspense} from 'react'
|
|
2
|
-
import {styled} from 'styled-components'
|
|
3
|
-
|
|
4
|
-
import {_getArrayProp} from '../../styles'
|
|
5
|
-
import {responsiveCodeFontStyle, ResponsiveFontStyleProps} from '../../styles/internal'
|
|
6
|
-
import {ElementType, Props} from '../../types'
|
|
7
|
-
import {codeBaseStyle} from './styles'
|
|
8
|
-
|
|
9
|
-
const LazyRefractor = lazy(() => import('./refractor'))
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export interface CodeOwnProps {
|
|
15
|
-
/** Define the language to use for syntax highlighting. */
|
|
16
|
-
language?: string
|
|
17
|
-
size?: number | number[]
|
|
18
|
-
weight?: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
export type CodeProps<E extends ElementType = 'pre'> = Props<CodeOwnProps, E>
|
|
25
|
-
|
|
26
|
-
const StyledCode = styled.pre<ResponsiveFontStyleProps>(codeBaseStyle, responsiveCodeFontStyle)
|
|
27
|
-
|
|
28
|
-
const CodeComponent = forwardRef(function Code(
|
|
29
|
-
props: CodeOwnProps & {as?: ElementType} & Omit<React.HTMLProps<HTMLElement>, 'as' | 'size'>,
|
|
30
|
-
ref: React.ForwardedRef<HTMLElement>,
|
|
31
|
-
) {
|
|
32
|
-
const {children, language, size = 2, weight, ...restProps} = props
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<StyledCode
|
|
36
|
-
data-ui="Code"
|
|
37
|
-
{...restProps}
|
|
38
|
-
$size={_getArrayProp(size)}
|
|
39
|
-
$weight={weight}
|
|
40
|
-
ref={ref}
|
|
41
|
-
>
|
|
42
|
-
<Suspense fallback={<code>{children}</code>}>
|
|
43
|
-
<LazyRefractor language={language} value={children} />
|
|
44
|
-
</Suspense>
|
|
45
|
-
</StyledCode>
|
|
46
|
-
)
|
|
47
|
-
})
|
|
48
|
-
CodeComponent.displayName = 'ForwardRef(Code)'
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @public
|
|
52
|
-
*/
|
|
53
|
-
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
54
|
-
export const Code = CodeComponent as unknown as <E extends ElementType = 'pre'>(
|
|
55
|
-
props: CodeProps<E>,
|
|
56
|
-
) => React.JSX.Element
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './code'
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {hasLanguage, Refractor} from 'react-refractor'
|
|
2
|
-
|
|
3
|
-
export default function LazyRefractor(
|
|
4
|
-
props: Partial<Pick<React.ComponentProps<typeof Refractor>, 'language'>> & {
|
|
5
|
-
value: React.ReactNode
|
|
6
|
-
},
|
|
7
|
-
) {
|
|
8
|
-
const {language: languageProp, value} = props
|
|
9
|
-
const language = typeof languageProp === 'string' ? languageProp : undefined
|
|
10
|
-
// oxlint-disable-next-line no-unnecessary-type-assertion, no-unsafe-type-assertion
|
|
11
|
-
const registered = language ? hasLanguage(language as any) : false
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<>
|
|
15
|
-
{!(language && registered) && <code>{value}</code>}
|
|
16
|
-
{/* oxlint-disable-next-line no-base-to-string */}
|
|
17
|
-
{language && registered && <Refractor inline language={language} value={String(value)} />}
|
|
18
|
-
</>
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
LazyRefractor.displayName = 'LazyRefractor'
|