@sanity/ui 2.16.21 → 2.16.23
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/_chunks-cjs/_visual-editing.js +121 -1046
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-cjs/refractor.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +116 -1041
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_chunks-es/refractor.mjs.map +1 -1
- package/dist/_visual-editing.d.mts +411 -351
- package/dist/_visual-editing.d.ts +411 -351
- package/dist/index.d.mts +1107 -930
- package/dist/index.d.ts +1107 -930
- package/dist/index.js +67 -158
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -156
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +769 -681
- package/dist/theme.d.ts +769 -681
- package/dist/theme.js +47 -0
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +47 -0
- package/dist/theme.mjs.map +1 -1
- package/exports/_visual-editing.ts +1 -0
- package/package.json +50 -163
- package/src/core/_compat.ts +30 -0
- package/src/core/components/autocomplete/autocomplete.tsx +11 -4
- package/src/core/components/autocomplete/autocompleteOption.tsx +1 -0
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +1 -0
- package/src/core/components/dialog/dialog.tsx +3 -0
- package/src/core/components/hotkeys/hotkeys.tsx +1 -0
- package/src/core/components/menu/menu.test.tsx +6 -4
- package/src/core/components/menu/menu.tsx +3 -2
- package/src/core/components/menu/menuButton.tsx +8 -0
- package/src/core/components/menu/menuGroup.tsx +5 -2
- package/src/core/components/menu/menuItem.tsx +4 -0
- package/src/core/components/menu/useMenuController.ts +6 -4
- package/src/core/components/skeleton/skeleton.tsx +2 -1
- package/src/core/components/tab/tab.tsx +1 -0
- package/src/core/components/tab/tabList.tsx +1 -0
- package/src/core/components/toast/toast.test.tsx +9 -4
- package/src/core/components/toast/toast.tsx +1 -1
- package/src/core/components/toast/toastProvider.tsx +1 -1
- package/src/core/components/tree/tree.tsx +1 -0
- package/src/core/components/tree/treeGroup.tsx +1 -0
- package/src/core/components/tree/treeItem.tsx +2 -2
- package/src/core/constants.ts +2 -2
- package/src/core/hooks/useClickOutside.test.tsx +43 -15
- package/src/core/hooks/useClickOutside.ts +1 -1
- package/src/core/hooks/useClickOutsideEvent.test.tsx +8 -4
- package/src/core/hooks/useDelayed.test.ts +7 -6
- package/src/core/hooks/useElementRect/useElementRect.ts +1 -0
- package/src/core/hooks/useForwardedRef.ts +1 -0
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +2 -1
- package/src/core/hooks/usePrefersDark.hydration.test.tsx +7 -5
- package/src/core/hooks/usePrefersDark.test.tsx +3 -1
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +7 -5
- package/src/core/hooks/usePrefersReducedMotion.test.tsx +3 -1
- package/src/core/lib/createGlobalScopedContext.ts +1 -0
- package/src/core/lib/globalScope.ts +1 -0
- package/src/core/observers/elementSizeObserver.ts +1 -0
- package/src/core/primitives/avatar/avatar.tsx +1 -2
- package/src/core/primitives/avatar/avatarStack.tsx +1 -0
- package/src/core/primitives/badge/badge.test.tsx +3 -2
- package/src/core/primitives/badge/badge.tsx +2 -1
- package/src/core/primitives/box/box.tsx +2 -1
- package/src/core/primitives/button/button.test.tsx +3 -2
- package/src/core/primitives/button/button.tsx +2 -0
- package/src/core/primitives/button/styles.ts +1 -0
- package/src/core/primitives/card/card.tsx +1 -5
- package/src/core/primitives/card/types.ts +1 -0
- package/src/core/primitives/code/refractor.tsx +2 -0
- package/src/core/primitives/flex/flex.tsx +1 -3
- package/src/core/primitives/inline/inline.tsx +1 -0
- package/src/core/primitives/popover/popover.tsx +13 -4
- package/src/core/primitives/popover/popoverCard.tsx +2 -1
- package/src/core/primitives/popover/types.ts +0 -1
- package/src/core/primitives/stack/styles.ts +1 -0
- package/src/core/primitives/textInput/textInput.tsx +2 -0
- package/src/core/primitives/tooltip/tooltip.test.tsx +82 -49
- package/src/core/primitives/tooltip/tooltip.tsx +6 -1
- package/src/core/primitives/tooltip/tooltipCard.tsx +2 -1
- package/src/core/primitives/tooltip/tooltipDelayGroup/types.ts +2 -0
- package/src/core/styles/flex/types.ts +0 -1
- package/src/core/styles/font/responsiveFont.ts +0 -3
- package/src/core/styles/font/types.ts +1 -3
- package/src/core/styles/grid/gridStyle.ts +1 -0
- package/src/core/styles/margin/marginStyle.ts +1 -0
- package/src/core/styles/margin/marginsStyle.test.ts +2 -1
- package/src/core/styles/padding/paddingStyle.test.ts +2 -1
- package/src/core/styles/padding/paddingStyle.ts +1 -0
- package/src/core/theme/theme.test.tsx +7 -3
- package/src/core/theme/useRootTheme.ts +1 -0
- package/src/core/theme/useTheme.ts +2 -0
- package/src/core/utils/arrow/arrow.tsx +1 -0
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +9 -4
- package/src/core/utils/conditionalWrapper/conditionalWrapper.tsx +1 -0
- package/src/core/utils/getElementRef.ts +5 -0
- package/src/core/utils/layer/getLayerContext.test.ts +2 -0
- package/src/core/utils/layer/layer.test.tsx +9 -4
- package/src/core/utils/layer/layer.tsx +1 -0
- package/src/core/utils/layer/useLayer.ts +2 -0
- package/src/core/utils/portal/portal.test.tsx +9 -4
- package/src/core/utils/portal/portalProvider.tsx +4 -3
- package/src/core/utils/virtualList/virtualList.tsx +2 -1
- package/src/theme/build/_deprecated/color/_selectable/createSelectableTones.ts +10 -0
- package/src/theme/build/_deprecated/color/_solid/createSolidTones.ts +4 -0
- package/src/theme/build/_deprecated/color/button/createButtonModes.ts +5 -0
- package/src/theme/build/_deprecated/color/button/createButtonTones.ts +5 -0
- package/src/theme/build/_deprecated/color/card/createCardStates.ts +6 -0
- package/src/theme/build/_deprecated/color/color.test.ts +5 -1
- package/src/theme/build/_deprecated/color/defaults.ts +1 -0
- package/src/theme/build/_deprecated/color/factory.ts +36 -0
- package/src/theme/build/_deprecated/color/input/createInputModes.ts +5 -0
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +4 -0
- package/src/theme/build/_deprecated/color/spot/createSpot.ts +3 -0
- package/src/theme/build/buildColorTheme.test.ts +2 -0
- package/src/theme/build/buildColorTheme.ts +7 -0
- package/src/theme/build/buildTheme.test.ts +2 -0
- package/src/theme/build/lib/color-fns/color-fns.test.ts +3 -1
- package/src/theme/build/merge.ts +5 -0
- package/src/theme/build/mixThemeColor.test.ts +2 -0
- package/src/theme/build/renderColorTheme.ts +6 -0
- package/src/theme/build/renderColorValue.ts +0 -2
- package/src/theme/build/resolveColorTokens.ts +6 -0
- package/src/theme/build/theme.test.ts +2 -0
- package/src/theme/config/helpers.ts +5 -0
- package/src/theme/config/system.ts +2 -0
- package/src/theme/config/tokens/color/types.ts +6 -4
- package/src/theme/config/tokens/parseTokenKey.test.ts +2 -0
- package/src/theme/config/tokens/parseTokenValue.test.ts +2 -0
- package/src/theme/config/tokens/parseTokenValue.ts +1 -0
- package/src/theme/getScopedTheme.ts +5 -0
- package/src/theme/system/color/_helpers.ts +4 -0
- package/src/theme/system/theme.ts +4 -0
- package/src/theme/system/v0/color/_system.ts +1 -0
- package/src/theme/system/v0/color/button.ts +14 -0
- package/src/theme/system/v0/color/card.ts +6 -0
- package/src/theme/system/v0/color/color.ts +11 -0
- package/src/theme/system/v0/color/input.ts +6 -0
- package/src/theme/system/v0/color/muted.ts +11 -0
- package/src/theme/system/v0/color/selectable.ts +11 -0
- package/src/theme/system/v0/color/solid.ts +11 -0
- package/src/theme/system/v0/color/spot.ts +1 -0
- package/src/theme/versioning/getTheme_v2.ts +15 -0
- package/src/theme/versioning/themeColor_v0_v2.ts +7 -0
- package/src/theme/versioning/themeColor_v2_v2_9.ts +1 -0
- package/src/theme/versioning/v0_v2.ts +13 -1
- package/src/theme/versioning/v2_v0.ts +15 -0
- package/src/core/__workshop__/constants.ts +0 -293
- package/src/core/components/autocomplete/__mocks__/apiStore.ts +0 -49
- package/src/core/components/autocomplete/__mocks__/countries.ts +0 -245
- package/src/core/components/autocomplete/__workshop__/async.tsx +0 -156
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +0 -137
- package/src/core/components/autocomplete/__workshop__/custom.tsx +0 -89
- package/src/core/components/autocomplete/__workshop__/example.tsx +0 -79
- package/src/core/components/autocomplete/__workshop__/focusAndBlur.tsx +0 -36
- package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +0 -294
- package/src/core/components/autocomplete/__workshop__/index.ts +0 -39
- package/src/core/components/autocomplete/__workshop__/types.ts +0 -4
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +0 -62
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -14
- package/src/core/components/dialog/__workshop__/activate.tsx +0 -134
- package/src/core/components/dialog/__workshop__/autoFocus.tsx +0 -29
- package/src/core/components/dialog/__workshop__/index.ts +0 -19
- package/src/core/components/dialog/__workshop__/layering.tsx +0 -41
- package/src/core/components/dialog/__workshop__/nested.tsx +0 -72
- package/src/core/components/dialog/__workshop__/onScroll.tsx +0 -39
- package/src/core/components/dialog/__workshop__/panes.tsx +0 -82
- package/src/core/components/dialog/__workshop__/position.tsx +0 -30
- package/src/core/components/dialog/__workshop__/props.tsx +0 -75
- package/src/core/components/dialog/__workshop__/provider.tsx +0 -11
- package/src/core/components/dialog/__workshop__/wrapped.tsx +0 -76
- package/src/core/components/hotkeys/__workshop__/index.ts +0 -14
- package/src/core/components/hotkeys/__workshop__/plain.tsx +0 -9
- package/src/core/components/menu/__workshop__/asComponent.tsx +0 -45
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +0 -51
- package/src/core/components/menu/__workshop__/closableMenuButton.tsx +0 -46
- package/src/core/components/menu/__workshop__/constrainedInBoundary.tsx +0 -134
- package/src/core/components/menu/__workshop__/customMenuItem.tsx +0 -45
- package/src/core/components/menu/__workshop__/customSelectedState.tsx +0 -39
- package/src/core/components/menu/__workshop__/disableFocusOnClose.tsx +0 -40
- package/src/core/components/menu/__workshop__/groups.tsx +0 -156
- package/src/core/components/menu/__workshop__/index.ts +0 -89
- package/src/core/components/menu/__workshop__/menuButton.tsx +0 -80
- package/src/core/components/menu/__workshop__/menuGroupRight.tsx +0 -65
- package/src/core/components/menu/__workshop__/nestedMenu.tsx +0 -22
- package/src/core/components/menu/__workshop__/onCloseMenuButton.tsx +0 -41
- package/src/core/components/menu/__workshop__/selectedItem.tsx +0 -69
- package/src/core/components/menu/__workshop__/shouldFocus.tsx +0 -47
- package/src/core/components/menu/__workshop__/tones.tsx +0 -25
- package/src/core/components/menu/__workshop__/withoutArrow.tsx +0 -32
- package/src/core/components/skeleton/__workshop__/delay.tsx +0 -70
- package/src/core/components/skeleton/__workshop__/index.ts +0 -11
- package/src/core/components/skeleton/__workshop__/skeleton.tsx +0 -64
- package/src/core/components/tab/__workshop__/example.tsx +0 -79
- package/src/core/components/tab/__workshop__/index.ts +0 -14
- package/src/core/components/toast/__workshop__/hook.tsx +0 -71
- package/src/core/components/toast/__workshop__/index.ts +0 -19
- package/src/core/components/toast/__workshop__/toast.tsx +0 -26
- package/src/core/components/tree/__workshop__/basic.perf.ts +0 -19
- package/src/core/components/tree/__workshop__/basic.tsx +0 -105
- package/src/core/components/tree/__workshop__/index.ts +0 -21
- package/src/core/components/tree/__workshop__/tabFromElement.tsx +0 -84
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +0 -32
- package/src/core/hooks/useElementRect/__workshop__/index.ts +0 -14
- package/src/core/hooks/useMediaIndex/__workshop__/index.ts +0 -14
- package/src/core/hooks/useMediaIndex/__workshop__/test.tsx +0 -14
- package/src/core/primitives/avatar/__workshop__/asButton.tsx +0 -14
- package/src/core/primitives/avatar/__workshop__/index.ts +0 -29
- package/src/core/primitives/avatar/__workshop__/stack.tsx +0 -25
- package/src/core/primitives/avatar/__workshop__/withinButton.tsx +0 -63
- package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +0 -70
- package/src/core/primitives/badge/__workshop__/index.ts +0 -19
- package/src/core/primitives/badge/__workshop__/props.tsx +0 -30
- package/src/core/primitives/badge/__workshop__/tones.tsx +0 -21
- package/src/core/primitives/box/__workshop__/index.ts +0 -19
- package/src/core/primitives/box/__workshop__/props.tsx +0 -20
- package/src/core/primitives/box/__workshop__/responsive.tsx +0 -20
- package/src/core/primitives/button/__workshop__/custom.tsx +0 -51
- package/src/core/primitives/button/__workshop__/customIcons.tsx +0 -30
- package/src/core/primitives/button/__workshop__/disabled.tsx +0 -74
- package/src/core/primitives/button/__workshop__/index.ts +0 -59
- package/src/core/primitives/button/__workshop__/mixedChildren.tsx +0 -12
- package/src/core/primitives/button/__workshop__/props.tsx +0 -55
- package/src/core/primitives/button/__workshop__/sanityUploadButton.tsx +0 -36
- package/src/core/primitives/button/__workshop__/stacked.tsx +0 -58
- package/src/core/primitives/button/__workshop__/styled1.tsx +0 -17
- package/src/core/primitives/button/__workshop__/styled2.tsx +0 -19
- package/src/core/primitives/button/__workshop__/uploadButton.tsx +0 -28
- package/src/core/primitives/card/__workshop__/allTones.tsx +0 -25
- package/src/core/primitives/card/__workshop__/asButton.tsx +0 -107
- package/src/core/primitives/card/__workshop__/asComponent.tsx +0 -27
- package/src/core/primitives/card/__workshop__/checkered.tsx +0 -26
- package/src/core/primitives/card/__workshop__/index.ts +0 -18
- package/src/core/primitives/card/__workshop__/interactive.tsx +0 -30
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +0 -80
- package/src/core/primitives/card/__workshop__/props.tsx +0 -53
- package/src/core/primitives/card/__workshop__/selected.tsx +0 -94
- package/src/core/primitives/card/__workshop__/styled.tsx +0 -14
- package/src/core/primitives/checkbox/__workshop__/example.tsx +0 -25
- package/src/core/primitives/checkbox/__workshop__/index.ts +0 -13
- package/src/core/primitives/checkbox/__workshop__/props.tsx +0 -33
- package/src/core/primitives/checkbox/__workshop__/readOnly.tsx +0 -16
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +0 -28
- package/src/core/primitives/code/__workshop__/index.ts +0 -19
- package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/code/__workshop__/props.tsx +0 -21
- package/src/core/primitives/container/__workshop__/example.tsx +0 -20
- package/src/core/primitives/container/__workshop__/index.ts +0 -8
- package/src/core/primitives/flex/__workshop__/example.tsx +0 -34
- package/src/core/primitives/flex/__workshop__/gap.tsx +0 -25
- package/src/core/primitives/flex/__workshop__/index.ts +0 -11
- package/src/core/primitives/grid/__workshop__/index.ts +0 -10
- package/src/core/primitives/grid/__workshop__/responsive.tsx +0 -54
- package/src/core/primitives/heading/__workshop__/index.ts +0 -19
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +0 -54
- package/src/core/primitives/heading/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/inline/__workshop__/index.ts +0 -8
- package/src/core/primitives/inline/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/kbd/__workshop__/index.ts +0 -8
- package/src/core/primitives/kbd/__workshop__/plain.tsx +0 -9
- package/src/core/primitives/label/__workshop__/index.ts +0 -19
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/label/__workshop__/plain.tsx +0 -24
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +0 -77
- package/src/core/primitives/popover/__workshop__/MarginsStory.tsx +0 -31
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +0 -32
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +0 -11
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +0 -89
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +0 -97
- package/src/core/primitives/popover/__workshop__/index.ts +0 -49
- package/src/core/primitives/radio/__workshop__/example.tsx +0 -63
- package/src/core/primitives/radio/__workshop__/index.ts +0 -11
- package/src/core/primitives/radio/__workshop__/plain.tsx +0 -28
- package/src/core/primitives/select/__workshop__/index.ts +0 -11
- package/src/core/primitives/select/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/select/__workshop__/readOnly.tsx +0 -23
- package/src/core/primitives/spinner/__workshop__/Props.tsx +0 -15
- package/src/core/primitives/spinner/__workshop__/index.ts +0 -14
- package/src/core/primitives/stack/__workshop__/index.ts +0 -14
- package/src/core/primitives/stack/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/switch/__workshop__/example.tsx +0 -23
- package/src/core/primitives/switch/__workshop__/index.ts +0 -11
- package/src/core/primitives/switch/__workshop__/props.tsx +0 -21
- package/src/core/primitives/text/__workshop__/colored.tsx +0 -30
- package/src/core/primitives/text/__workshop__/example.tsx +0 -39
- package/src/core/primitives/text/__workshop__/index.ts +0 -24
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/textArea/__workshop__/index.ts +0 -14
- package/src/core/primitives/textArea/__workshop__/plain.tsx +0 -50
- package/src/core/primitives/textInput/__workshop__/clearButton.tsx +0 -30
- package/src/core/primitives/textInput/__workshop__/customValidity.tsx +0 -17
- package/src/core/primitives/textInput/__workshop__/index.ts +0 -44
- package/src/core/primitives/textInput/__workshop__/plain.tsx +0 -98
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +0 -9
- package/src/core/primitives/textInput/__workshop__/states.tsx +0 -53
- package/src/core/primitives/textInput/__workshop__/tones.tsx +0 -277
- package/src/core/primitives/textInput/__workshop__/typed.tsx +0 -23
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +0 -102
- package/src/core/primitives/tooltip/__workshop__/index.ts +0 -29
- package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +0 -74
- package/src/core/primitives/tooltip/__workshop__/props.tsx +0 -107
- package/src/core/primitives/tooltip/__workshop__/resizableBoundary.tsx +0 -86
- package/src/core/theme/__workshop__/build/Root.tsx +0 -367
- package/src/core/theme/__workshop__/build/helpers.ts +0 -46
- package/src/core/theme/__workshop__/build/story.tsx +0 -465
- package/src/core/theme/__workshop__/canvas.tsx +0 -352
- package/src/core/theme/__workshop__/color.tsx +0 -62
- package/src/core/theme/__workshop__/debug/story.tsx +0 -408
- package/src/core/theme/__workshop__/index.ts +0 -39
- package/src/core/theme/__workshop__/layer.tsx +0 -78
- package/src/core/theme/__workshop__/nestedProvider.tsx +0 -15
- package/src/core/utils/boundaryElement/__workshop__/index.ts +0 -14
- package/src/core/utils/boundaryElement/__workshop__/plain.tsx +0 -19
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +0 -30
- package/src/core/utils/elementQuery/__workshop__/index.ts +0 -14
- package/src/core/utils/layer/__workshop__/_debug.tsx +0 -17
- package/src/core/utils/layer/__workshop__/index.ts +0 -24
- package/src/core/utils/layer/__workshop__/multipleRoots.tsx +0 -49
- package/src/core/utils/layer/__workshop__/nested.tsx +0 -98
- package/src/core/utils/layer/__workshop__/responsiveZOffset.tsx +0 -13
- package/src/core/utils/portal/__workshop__/index.ts +0 -14
- package/src/core/utils/portal/__workshop__/named.tsx +0 -63
- package/src/core/utils/virtualList/__workshop__/changingProps.tsx +0 -36
- package/src/core/utils/virtualList/__workshop__/elementScroll.tsx +0 -24
- package/src/core/utils/virtualList/__workshop__/index.ts +0 -29
- package/src/core/utils/virtualList/__workshop__/infiniteList.tsx +0 -48
- package/src/core/utils/virtualList/__workshop__/windowScrolll.tsx +0 -22
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
/** @
|
|
1
|
+
/** @vitest-environment jsdom */
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* As this hook is used for top-level theming it's likely to be called while server-rendering
|
|
4
5
|
* and that's why it's worth it to have a testing suite for hydration
|
|
5
6
|
*/
|
|
6
7
|
import {waitFor} from '@testing-library/dom'
|
|
7
8
|
import {hydrateRoot} from 'react-dom/client'
|
|
9
|
+
import {afterAll, beforeAll, describe, expect, it, vi} from 'vitest'
|
|
8
10
|
|
|
9
11
|
import {usePrefersDark} from './usePrefersDark'
|
|
10
12
|
|
|
@@ -19,9 +21,10 @@ const originalMatchMedia = window.matchMedia
|
|
|
19
21
|
describe('usePrefersDark SSR hydration', () => {
|
|
20
22
|
beforeAll(() => {
|
|
21
23
|
window.matchMedia = () =>
|
|
24
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
22
25
|
({
|
|
23
|
-
addEventListener:
|
|
24
|
-
removeEventListener:
|
|
26
|
+
addEventListener: vi.fn(),
|
|
27
|
+
removeEventListener: vi.fn(),
|
|
25
28
|
matches: true,
|
|
26
29
|
}) as any
|
|
27
30
|
})
|
|
@@ -31,7 +34,7 @@ describe('usePrefersDark SSR hydration', () => {
|
|
|
31
34
|
})
|
|
32
35
|
|
|
33
36
|
it(`hydrates without any warnings`, async () => {
|
|
34
|
-
const spy =
|
|
37
|
+
const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
|
35
38
|
|
|
36
39
|
const node = document.createElement('div')
|
|
37
40
|
|
|
@@ -47,7 +50,6 @@ describe('usePrefersDark SSR hydration', () => {
|
|
|
47
50
|
// After hydration it should switch to true
|
|
48
51
|
await waitFor(() => expect(node.innerHTML).toBe('dark: <!-- -->true'))
|
|
49
52
|
|
|
50
|
-
// eslint-disable-next-line no-console
|
|
51
53
|
expect(console.error).not.toHaveBeenCalled()
|
|
52
54
|
|
|
53
55
|
spy.mockReset()
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
/** @
|
|
1
|
+
/** @vitest-environment jsdom */
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* As this hook is used for top-level theming it's likely to be called while server-rendering
|
|
4
5
|
* and that's why it's worth it to have a testing suite for hydration
|
|
5
6
|
*/
|
|
6
7
|
import {waitFor} from '@testing-library/dom'
|
|
7
8
|
import {hydrateRoot} from 'react-dom/client'
|
|
9
|
+
import {afterAll, beforeAll, describe, expect, it, vi} from 'vitest'
|
|
8
10
|
|
|
9
11
|
import {usePrefersReducedMotion} from './usePrefersReducedMotion'
|
|
10
12
|
|
|
@@ -19,9 +21,10 @@ const originalMatchMedia = window.matchMedia
|
|
|
19
21
|
describe('usePrefersReducedMotion SSR hydration', () => {
|
|
20
22
|
beforeAll(() => {
|
|
21
23
|
window.matchMedia = () =>
|
|
24
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
22
25
|
({
|
|
23
|
-
addEventListener:
|
|
24
|
-
removeEventListener:
|
|
26
|
+
addEventListener: vi.fn(),
|
|
27
|
+
removeEventListener: vi.fn(),
|
|
25
28
|
matches: true,
|
|
26
29
|
}) as any
|
|
27
30
|
})
|
|
@@ -31,7 +34,7 @@ describe('usePrefersReducedMotion SSR hydration', () => {
|
|
|
31
34
|
})
|
|
32
35
|
|
|
33
36
|
it(`hydrates without any warnings`, async () => {
|
|
34
|
-
const spy =
|
|
37
|
+
const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
|
35
38
|
|
|
36
39
|
const node = document.createElement('div')
|
|
37
40
|
|
|
@@ -47,7 +50,6 @@ describe('usePrefersReducedMotion SSR hydration', () => {
|
|
|
47
50
|
// After hydration it should switch to true
|
|
48
51
|
await waitFor(() => expect(node.innerHTML).toBe('prefers-motion: <!-- -->true'))
|
|
49
52
|
|
|
50
|
-
// eslint-disable-next-line no-console
|
|
51
53
|
expect(console.error).not.toHaveBeenCalled()
|
|
52
54
|
|
|
53
55
|
spy.mockReset()
|
|
@@ -12,6 +12,7 @@ import {type Context, createContext} from 'react'
|
|
|
12
12
|
|
|
13
13
|
import {globalScope} from './globalScope'
|
|
14
14
|
|
|
15
|
+
// oxlint-disable-next-line no-unnecessary-type-parameters
|
|
15
16
|
export function createGlobalScopedContext<ContextType, const T extends ContextType = ContextType>(
|
|
16
17
|
/**
|
|
17
18
|
* Enforce that all Symbol.for keys used for globally scoped contexts have a predictable prefix
|
|
@@ -50,6 +50,7 @@ function _createElementRectValueListener(): _ElementSizeListener {
|
|
|
50
50
|
subscribe(element, subscriber) {
|
|
51
51
|
const resizeObserver = new _ResizeObserver(([entry]) => {
|
|
52
52
|
subscriber({
|
|
53
|
+
// oxlint-disable-next-line no-deprecated
|
|
53
54
|
_contentRect: entry.contentRect,
|
|
54
55
|
border: {
|
|
55
56
|
width: entry.borderBoxSize[0].inlineSize,
|
|
@@ -77,7 +77,6 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
77
77
|
const as = ReactIs.isValidElementType(asProp) ? asProp : 'div'
|
|
78
78
|
const size = useArrayProp(sizeProp)
|
|
79
79
|
|
|
80
|
-
// eslint-disable-next-line no-warning-comments
|
|
81
80
|
// @todo: remove this
|
|
82
81
|
const avatarSize = avatar.sizes[size[0]] || avatar.sizes[0]
|
|
83
82
|
const _sizeRem = avatarSize.size
|
|
@@ -102,7 +101,7 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
102
101
|
}, [arrowPosition, arrowPositionProp])
|
|
103
102
|
|
|
104
103
|
useEffect(() => {
|
|
105
|
-
//
|
|
104
|
+
// oxlint-disable-next-line react-compiler
|
|
106
105
|
if (src) setImageFailed(false)
|
|
107
106
|
}, [src])
|
|
108
107
|
|
|
@@ -93,6 +93,7 @@ export const AvatarStack = forwardRef(function AvatarStack(
|
|
|
93
93
|
)}
|
|
94
94
|
|
|
95
95
|
{visibleChildren.map((child, childIndex) => (
|
|
96
|
+
// oxlint-disable-next-line no-array-index-key
|
|
96
97
|
<div key={String(childIndex)}>{cloneElement(child, {size})}</div>
|
|
97
98
|
))}
|
|
98
99
|
</StyledAvatarStack>
|
|
@@ -17,6 +17,7 @@ export interface BadgeProps extends BoxProps, ResponsiveRadiusProps {
|
|
|
17
17
|
as?: React.ElementType | keyof React.JSX.IntrinsicElements
|
|
18
18
|
fontSize?: number | number[]
|
|
19
19
|
/** @deprecated No longer used. */
|
|
20
|
+
// oxlint-disable-next-line no-deprecated
|
|
20
21
|
mode?: BadgeMode
|
|
21
22
|
tone?: BadgeTone
|
|
22
23
|
}
|
|
@@ -38,7 +39,7 @@ export const Badge = forwardRef(function Badge(
|
|
|
38
39
|
const {
|
|
39
40
|
children,
|
|
40
41
|
fontSize = 1,
|
|
41
|
-
//
|
|
42
|
+
// oxlint-disable-next-line no-deprecated
|
|
42
43
|
mode: _deprecated_mode,
|
|
43
44
|
padding = 1,
|
|
44
45
|
radius = 'full',
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/** @
|
|
1
|
+
/** @vitest-environment jsdom */
|
|
2
2
|
|
|
3
3
|
import {AddIcon} from '@sanity/icons'
|
|
4
4
|
import {screen} from '@testing-library/react'
|
|
5
|
-
import {
|
|
5
|
+
import {describe, expect, it} from 'vitest'
|
|
6
|
+
import {axe} from 'vitest-axe'
|
|
6
7
|
|
|
7
8
|
import {render} from '../../../../test'
|
|
8
9
|
import {Button, ButtonProps} from './button'
|
|
@@ -22,7 +22,9 @@ export interface ButtonProps extends ResponsivePaddingProps, ResponsiveRadiusPro
|
|
|
22
22
|
as?: React.ElementType | keyof React.JSX.IntrinsicElements
|
|
23
23
|
fontSize?: number | number[]
|
|
24
24
|
mode?: ButtonMode
|
|
25
|
+
// oxlint-disable-next-line no-redundant-type-constituents
|
|
25
26
|
icon?: React.ElementType | React.ReactNode
|
|
27
|
+
// oxlint-disable-next-line no-redundant-type-constituents
|
|
26
28
|
iconRight?: React.ElementType | React.ReactNode
|
|
27
29
|
justify?: FlexJustify | FlexJustify[]
|
|
28
30
|
/**
|
|
@@ -79,6 +79,7 @@ export function buttonColorStyles(
|
|
|
79
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
80
|
const defaultBoxShadow = undefined
|
|
81
81
|
|
|
82
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
82
83
|
return [
|
|
83
84
|
_cardColorStyle(baseColor, color.enabled),
|
|
84
85
|
{
|
|
@@ -23,10 +23,7 @@ import {CardStyleProps} from './types'
|
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
25
|
export interface CardProps
|
|
26
|
-
extends BoxProps,
|
|
27
|
-
ResponsiveBorderProps,
|
|
28
|
-
ResponsiveRadiusProps,
|
|
29
|
-
ResponsiveShadowProps {
|
|
26
|
+
extends BoxProps, ResponsiveBorderProps, ResponsiveRadiusProps, ResponsiveShadowProps {
|
|
30
27
|
/**
|
|
31
28
|
* Do not use in production.
|
|
32
29
|
* @beta
|
|
@@ -83,7 +80,6 @@ export const Card = forwardRef(function Card(
|
|
|
83
80
|
const rootTheme = useRootTheme()
|
|
84
81
|
const tone = toneProp === 'inherit' ? rootTheme.tone : toneProp
|
|
85
82
|
|
|
86
|
-
// eslint-disable-next-line no-warning-comments
|
|
87
83
|
// todo: Consider adding the wrapper approach for nested cards in which the tones are not changing, avoid unnecessary ThemeColorProvider
|
|
88
84
|
return (
|
|
89
85
|
<ThemeColorProvider scheme={scheme} tone={tone}>
|
|
@@ -7,11 +7,13 @@ export default function LazyRefractor(
|
|
|
7
7
|
) {
|
|
8
8
|
const {language: languageProp, value} = props
|
|
9
9
|
const language = typeof languageProp === 'string' ? languageProp : undefined
|
|
10
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
10
11
|
const registered = language ? Refractor.hasLanguage(language as any) : false
|
|
11
12
|
|
|
12
13
|
return (
|
|
13
14
|
<>
|
|
14
15
|
{!(language && registered) && <code>{value}</code>}
|
|
16
|
+
{/* oxlint-disable-next-line no-base-to-string */}
|
|
15
17
|
{language && registered && <Refractor inline language={language} value={String(value)} />}
|
|
16
18
|
</>
|
|
17
19
|
)
|
|
@@ -15,9 +15,7 @@ import {ResponsiveFlexItemProps, ResponsiveFlexProps} from '../types'
|
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
17
|
export interface FlexProps
|
|
18
|
-
extends Omit<BoxProps, 'display'>,
|
|
19
|
-
ResponsiveFlexProps,
|
|
20
|
-
ResponsiveFlexItemProps {
|
|
18
|
+
extends Omit<BoxProps, 'display'>, ResponsiveFlexProps, ResponsiveFlexItemProps {
|
|
21
19
|
gap?: number | number[]
|
|
22
20
|
}
|
|
23
21
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
useFloating,
|
|
12
12
|
} from '@floating-ui/react-dom'
|
|
13
13
|
import {ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
14
|
-
import {AnimatePresence} from '
|
|
14
|
+
import {AnimatePresence} from 'motion/react'
|
|
15
15
|
import {
|
|
16
16
|
cloneElement,
|
|
17
17
|
forwardRef,
|
|
@@ -45,9 +45,7 @@ import {PopoverUpdateCallback, PopoverWidth} from './types'
|
|
|
45
45
|
|
|
46
46
|
/** @public */
|
|
47
47
|
export interface PopoverProps
|
|
48
|
-
extends Omit<LayerProps, 'as'>,
|
|
49
|
-
ResponsiveRadiusProps,
|
|
50
|
-
ResponsiveShadowProps {
|
|
48
|
+
extends Omit<LayerProps, 'as'>, ResponsiveRadiusProps, ResponsiveShadowProps {
|
|
51
49
|
/** @beta */
|
|
52
50
|
__unstable_margins?: PopoverMargins
|
|
53
51
|
/**
|
|
@@ -120,6 +118,7 @@ export interface PopoverProps
|
|
|
120
118
|
tone?: CardTone
|
|
121
119
|
/** @beta */
|
|
122
120
|
updateRef?:
|
|
121
|
+
// oxlint-disable-next-line no-deprecated
|
|
123
122
|
| MutableRefObject<PopoverUpdateCallback | undefined>
|
|
124
123
|
| RefCallback<PopoverUpdateCallback | undefined>
|
|
125
124
|
width?: PopoverWidth | PopoverWidth[]
|
|
@@ -149,6 +148,7 @@ export const Popover = memo(
|
|
|
149
148
|
__unstable_margins: margins = DEFAULT_POPOVER_MARGINS,
|
|
150
149
|
animate: _animate = false,
|
|
151
150
|
arrow: arrowProp = false,
|
|
151
|
+
// oxlint-disable-next-line no-deprecated
|
|
152
152
|
boundaryElement = boundaryElementContext.element,
|
|
153
153
|
children: childProp,
|
|
154
154
|
constrainSize = false,
|
|
@@ -157,6 +157,7 @@ export const Popover = memo(
|
|
|
157
157
|
fallbackPlacements = props.fallbackPlacements ??
|
|
158
158
|
DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? 'bottom'],
|
|
159
159
|
matchReferenceWidth,
|
|
160
|
+
// oxlint-disable-next-line no-deprecated
|
|
160
161
|
floatingBoundary = props.boundaryElement ?? boundaryElementContext.element,
|
|
161
162
|
modal,
|
|
162
163
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -169,6 +170,7 @@ export const Popover = memo(
|
|
|
169
170
|
portal,
|
|
170
171
|
preventOverflow = true,
|
|
171
172
|
radius: radiusProp = 3,
|
|
173
|
+
// oxlint-disable-next-line no-deprecated
|
|
172
174
|
referenceBoundary = props.boundaryElement ?? boundaryElementContext.element,
|
|
173
175
|
referenceElement,
|
|
174
176
|
scheme,
|
|
@@ -276,6 +278,7 @@ export const Popover = memo(
|
|
|
276
278
|
// Track sizes
|
|
277
279
|
if (constrainSize || matchReferenceWidth) {
|
|
278
280
|
ret.push(
|
|
281
|
+
// oxlint-disable-next-line react-compiler
|
|
279
282
|
size({
|
|
280
283
|
apply({availableWidth, availableHeight, elements, referenceWidth}) {
|
|
281
284
|
// not fresh, so use refs
|
|
@@ -323,7 +326,9 @@ export const Popover = memo(
|
|
|
323
326
|
// Place arrow
|
|
324
327
|
if (arrowProp) {
|
|
325
328
|
ret.push(
|
|
329
|
+
// oxlint-disable-next-line react-compiler
|
|
326
330
|
arrow({
|
|
331
|
+
// oxlint-disable-next-line react-compiler
|
|
327
332
|
element: arrowRef,
|
|
328
333
|
padding: DEFAULT_POPOVER_PADDING,
|
|
329
334
|
}),
|
|
@@ -379,6 +384,7 @@ export const Popover = memo(
|
|
|
379
384
|
const originY = middlewareData['@sanity/ui/origin']?.originY
|
|
380
385
|
|
|
381
386
|
const setArrow = useCallback((arrowEl: HTMLDivElement | null) => {
|
|
387
|
+
// oxlint-disable-next-line react-compiler
|
|
382
388
|
arrowRef.current = arrowEl
|
|
383
389
|
}, [])
|
|
384
390
|
|
|
@@ -394,6 +400,7 @@ export const Popover = memo(
|
|
|
394
400
|
(node: HTMLElement | null) => {
|
|
395
401
|
refs.setReference(node)
|
|
396
402
|
|
|
403
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
397
404
|
const childRef = getElementRef(childProp as any)
|
|
398
405
|
|
|
399
406
|
if (typeof childRef === 'function') {
|
|
@@ -419,6 +426,7 @@ export const Popover = memo(
|
|
|
419
426
|
if (typeof updateRef === 'function') {
|
|
420
427
|
updateRef(update)
|
|
421
428
|
} else if (updateRef) {
|
|
429
|
+
// oxlint-disable-next-line react-compiler
|
|
422
430
|
updateRef.current = update
|
|
423
431
|
}
|
|
424
432
|
}
|
|
@@ -453,6 +461,7 @@ export const Popover = memo(
|
|
|
453
461
|
originY={originY}
|
|
454
462
|
strategy={strategy}
|
|
455
463
|
tone={tone}
|
|
464
|
+
// oxlint-disable-next-line react-compiler
|
|
456
465
|
width={matchReferenceWidth ? referenceWidthRef.current : width}
|
|
457
466
|
x={x}
|
|
458
467
|
y={y}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {Strategy} from '@floating-ui/react-dom'
|
|
2
2
|
import {ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
3
|
-
import {motion, type MotionProps} from '
|
|
3
|
+
import {motion, type MotionProps} from 'motion/react'
|
|
4
4
|
import React, {CSSProperties, forwardRef, memo, useMemo} from 'react'
|
|
5
5
|
import {styled} from 'styled-components'
|
|
6
6
|
|
|
@@ -124,6 +124,7 @@ export const PopoverCard = memo(
|
|
|
124
124
|
return (
|
|
125
125
|
<MotionCard
|
|
126
126
|
data-ui="Popover"
|
|
127
|
+
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
127
128
|
{...(restProps as CardProps & MotionProps)}
|
|
128
129
|
data-placement={placement}
|
|
129
130
|
radius={radius}
|
|
@@ -64,7 +64,9 @@ export interface TextInputProps {
|
|
|
64
64
|
clearButton?: boolean | TextInputClearButtonProps
|
|
65
65
|
customValidity?: string
|
|
66
66
|
fontSize?: number | number[]
|
|
67
|
+
// oxlint-disable-next-line no-redundant-type-constituents
|
|
67
68
|
icon?: React.ElementType | React.ReactNode
|
|
69
|
+
// oxlint-disable-next-line no-redundant-type-constituents
|
|
68
70
|
iconRight?: React.ElementType | React.ReactNode
|
|
69
71
|
/**
|
|
70
72
|
* @beta
|