@sanity/ui 3.3.1 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_visual-editing.d.mts +2 -1126
- package/dist/_visual-editing.d.ts +2 -1126
- package/dist/_visual-editing.js +3 -31
- package/dist/_visual-editing.mjs +2 -31
- package/dist/index.d.mts +555 -2769
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +555 -2769
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2982 -1934
- package/dist/index.mjs +2950 -1903
- package/dist/index.mjs.map +1 -1
- package/dist/refractor.js +16 -0
- package/dist/refractor.mjs +21 -0
- package/dist/refractor.mjs.map +1 -0
- package/dist/tabList.js +3804 -0
- package/dist/tabList.mjs +3355 -0
- package/dist/tabList.mjs.map +1 -0
- package/dist/theme.d.mts +927 -1227
- package/dist/theme.d.mts.map +1 -0
- package/dist/theme.d.ts +927 -1227
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +3 -4127
- package/dist/theme.mjs +2 -4127
- package/dist/theme2.d.mts +2 -0
- package/dist/theme2.d.ts +2 -0
- package/dist/theme2.js +4104 -0
- package/dist/theme2.mjs +3851 -0
- package/dist/theme2.mjs.map +1 -0
- package/dist/useTheme.d.mts +1451 -0
- package/dist/useTheme.d.mts.map +1 -0
- package/dist/useTheme.d.ts +1451 -0
- package/dist/useTheme.d.ts.map +1 -0
- package/exports/_visual-editing.ts +1 -0
- package/package.json +49 -102
- package/src/core/_compat.ts +30 -0
- package/src/core/components/autocomplete/autocomplete.tsx +8 -0
- package/src/core/components/autocomplete/autocompleteOption.tsx +1 -0
- package/src/core/components/breadcrumbs/breadcrumbs.test.tsx +8 -5
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +3 -0
- package/src/core/components/dialog/dialog.tsx +5 -2
- package/src/core/components/hotkeys/hotkeys.test.tsx +10 -5
- package/src/core/components/hotkeys/hotkeys.tsx +2 -0
- package/src/core/components/menu/menu.spacing.test.tsx +12 -7
- package/src/core/components/menu/menu.test.tsx +9 -6
- package/src/core/components/menu/menu.tsx +4 -2
- package/src/core/components/menu/menuButton.tsx +8 -0
- package/src/core/components/menu/menuDivider.ts +1 -0
- package/src/core/components/menu/menuGroup.spacing.test.tsx +9 -6
- package/src/core/components/menu/menuGroup.tsx +6 -2
- package/src/core/components/menu/menuItem.spacing.test.tsx +8 -5
- package/src/core/components/menu/menuItem.tsx +4 -0
- package/src/core/components/menu/useMenuController.ts +2 -0
- package/src/core/components/skeleton/skeleton.tsx +1 -0
- package/src/core/components/tab/tab.tsx +1 -0
- package/src/core/components/tab/tabList.test.tsx +7 -5
- 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 -0
- package/src/core/components/toast/toastLayer.tsx +1 -0
- package/src/core/components/tree/tree.test.tsx +10 -5
- package/src/core/components/tree/tree.tsx +2 -0
- package/src/core/components/tree/treeGroup.tsx +1 -0
- package/src/core/components/tree/treeItem.test.tsx +10 -5
- package/src/core/components/tree/treeItem.tsx +1 -0
- package/src/core/hooks/index.ts +1 -0
- 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 +9 -8
- 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 +2 -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 +3 -1
- package/src/core/primitives/box/box.test.tsx +18 -5
- package/src/core/primitives/box/box.tsx +9 -1
- package/src/core/primitives/button/button.test.tsx +10 -6
- package/src/core/primitives/button/button.tsx +4 -0
- package/src/core/primitives/button/styles.ts +1 -0
- package/src/core/primitives/card/card.tsx +2 -5
- package/src/core/primitives/card/types.ts +1 -0
- package/src/core/primitives/code/code.tsx +1 -0
- package/src/core/primitives/code/refractor.tsx +2 -0
- package/src/core/primitives/container/container.tsx +1 -0
- package/src/core/primitives/flex/flex.tsx +2 -3
- package/src/core/primitives/grid/grid.test.tsx +11 -5
- package/src/core/primitives/grid/grid.tsx +3 -0
- package/src/core/primitives/heading/heading.tsx +1 -0
- package/src/core/primitives/inline/inline.test.tsx +9 -5
- package/src/core/primitives/inline/inline.tsx +3 -0
- package/src/core/primitives/kbd/kbd.tsx +5 -1
- package/src/core/primitives/label/label.tsx +1 -0
- package/src/core/primitives/popover/popover.tsx +5 -4
- package/src/core/primitives/popover/popoverCard.tsx +1 -0
- package/src/core/primitives/popover/types.ts +0 -1
- package/src/core/primitives/select/select.test.tsx +9 -5
- package/src/core/primitives/select/select.tsx +1 -0
- package/src/core/primitives/stack/stack.test.tsx +9 -5
- package/src/core/primitives/stack/stack.tsx +2 -0
- package/src/core/primitives/stack/styles.ts +1 -0
- package/src/core/primitives/text/text.tsx +1 -0
- package/src/core/primitives/textInput/textInput.test.tsx +9 -5
- package/src/core/primitives/textInput/textInput.tsx +3 -0
- package/src/core/primitives/tooltip/tooltip.test.tsx +82 -49
- package/src/core/primitives/tooltip/tooltip.tsx +3 -1
- package/src/core/primitives/tooltip/tooltipCard.tsx +1 -0
- 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 +1 -0
- 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 +8 -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 +6 -1
- 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 +18 -0
- package/dist/_chunks-cjs/_visual-editing.js +0 -5899
- package/dist/_chunks-cjs/_visual-editing.js.map +0 -1
- package/dist/_chunks-cjs/refractor.js +0 -23
- package/dist/_chunks-cjs/refractor.js.map +0 -1
- package/dist/_chunks-es/_visual-editing.mjs +0 -5905
- package/dist/_chunks-es/_visual-editing.mjs.map +0 -1
- package/dist/_chunks-es/refractor.mjs +0 -26
- package/dist/_chunks-es/refractor.mjs.map +0 -1
- package/dist/_visual-editing.js.map +0 -1
- package/dist/_visual-editing.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/theme.js.map +0 -1
- package/dist/theme.mjs.map +0 -1
- 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__/asComponent.tsx +0 -31
- package/src/core/primitives/box/__workshop__/index.ts +0 -24
- 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,156 +0,0 @@
|
|
|
1
|
-
import {EarthAmericasIcon, SearchIcon} from '@sanity/icons'
|
|
2
|
-
import {
|
|
3
|
-
Autocomplete,
|
|
4
|
-
BaseAutocompleteOption,
|
|
5
|
-
Box,
|
|
6
|
-
Card,
|
|
7
|
-
Code,
|
|
8
|
-
Flex,
|
|
9
|
-
LayerProvider,
|
|
10
|
-
Stack,
|
|
11
|
-
Text,
|
|
12
|
-
} from '@sanity/ui'
|
|
13
|
-
import {useCallback, useEffect, useRef, useState} from 'react'
|
|
14
|
-
|
|
15
|
-
import {countriesStore} from '../__mocks__/apiStore'
|
|
16
|
-
|
|
17
|
-
export default function AsyncStory() {
|
|
18
|
-
const [options, setOptions] = useState<BaseAutocompleteOption[]>([])
|
|
19
|
-
const [loading, setLoading] = useState(false)
|
|
20
|
-
const searchRef = useRef<{cancel: () => void} | null>(null)
|
|
21
|
-
const fetchRef = useRef<{cancel: () => void} | null>(null)
|
|
22
|
-
const [query, setQuery] = useState<string | null>(null)
|
|
23
|
-
const [value, setValue] = useState('')
|
|
24
|
-
const [optionTitle, setOptionTitle] = useState<string | null>(null)
|
|
25
|
-
const [loadingCurrentRef, setLoadingCurrentRef] = useState(false)
|
|
26
|
-
|
|
27
|
-
const doSearch = useCallback((query: string | null) => {
|
|
28
|
-
if (searchRef.current) searchRef.current.cancel()
|
|
29
|
-
searchRef.current = countriesStore.search(query || '', setOptions, setLoading)
|
|
30
|
-
}, [])
|
|
31
|
-
|
|
32
|
-
const filterOption = useCallback(() => true, [])
|
|
33
|
-
|
|
34
|
-
const handleQueryChange = useCallback(
|
|
35
|
-
(query: string | null) => {
|
|
36
|
-
setQuery(query)
|
|
37
|
-
|
|
38
|
-
if (query !== null) {
|
|
39
|
-
doSearch(query)
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
[doSearch],
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
const handleOpenButtonClick = useCallback(() => {
|
|
46
|
-
if (!value) {
|
|
47
|
-
doSearch('')
|
|
48
|
-
}
|
|
49
|
-
}, [doSearch, value])
|
|
50
|
-
|
|
51
|
-
const renderValue = useCallback(() => {
|
|
52
|
-
if (loadingCurrentRef) {
|
|
53
|
-
return 'Loading…'
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return optionTitle || ''
|
|
57
|
-
}, [loadingCurrentRef, optionTitle])
|
|
58
|
-
|
|
59
|
-
const renderOption = useCallback((option: BaseAutocompleteOption) => {
|
|
60
|
-
return <AsyncOption documentId={option.value} />
|
|
61
|
-
}, [])
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (fetchRef.current) fetchRef.current.cancel()
|
|
65
|
-
|
|
66
|
-
if (value) {
|
|
67
|
-
fetchRef.current = countriesStore.fetchDocument(
|
|
68
|
-
value,
|
|
69
|
-
(data) => setOptionTitle(data?.title || null),
|
|
70
|
-
setLoadingCurrentRef,
|
|
71
|
-
)
|
|
72
|
-
} else {
|
|
73
|
-
setOptionTitle(null)
|
|
74
|
-
setLoadingCurrentRef(false)
|
|
75
|
-
}
|
|
76
|
-
}, [value])
|
|
77
|
-
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
if (optionTitle) doSearch(optionTitle)
|
|
80
|
-
}, [doSearch, optionTitle])
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<Box paddingX={[4, 5, 6]} paddingY={[5, 6, 7]}>
|
|
84
|
-
<Stack space={[3, 3, 4]}>
|
|
85
|
-
<Text as="label" htmlFor="async" size={[1, 1, 2]} weight="medium">
|
|
86
|
-
Country
|
|
87
|
-
</Text>
|
|
88
|
-
<LayerProvider zOffset={100}>
|
|
89
|
-
<Autocomplete
|
|
90
|
-
disabled={loadingCurrentRef}
|
|
91
|
-
filterOption={filterOption}
|
|
92
|
-
icon={value ? EarthAmericasIcon : SearchIcon}
|
|
93
|
-
id="async"
|
|
94
|
-
loading={loading}
|
|
95
|
-
onChange={setValue}
|
|
96
|
-
onQueryChange={handleQueryChange}
|
|
97
|
-
openButton={{onClick: handleOpenButtonClick}}
|
|
98
|
-
options={options}
|
|
99
|
-
placeholder="Search"
|
|
100
|
-
renderOption={renderOption}
|
|
101
|
-
renderValue={renderValue}
|
|
102
|
-
value={value}
|
|
103
|
-
/>
|
|
104
|
-
</LayerProvider>
|
|
105
|
-
|
|
106
|
-
<Card overflow="auto" padding={3} radius={2} tone="transparent">
|
|
107
|
-
<Code language="json" size={1}>
|
|
108
|
-
{JSON.stringify({loading, options, query, value}, null, 2)}
|
|
109
|
-
</Code>
|
|
110
|
-
</Card>
|
|
111
|
-
</Stack>
|
|
112
|
-
</Box>
|
|
113
|
-
)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function AsyncOption(props: {
|
|
117
|
-
documentId: string
|
|
118
|
-
disabled?: boolean
|
|
119
|
-
selected?: boolean
|
|
120
|
-
tabIndex?: number
|
|
121
|
-
}) {
|
|
122
|
-
const {documentId, disabled, selected, tabIndex} = props
|
|
123
|
-
const [data, setData] = useState<{title: string} | null>(null)
|
|
124
|
-
const [loading, setLoading] = useState(false)
|
|
125
|
-
const ref = useRef<{cancel: () => void} | null>(null)
|
|
126
|
-
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
if (ref.current) ref.current.cancel()
|
|
129
|
-
ref.current = countriesStore.fetchDocument(documentId, setData, setLoading)
|
|
130
|
-
}, [documentId])
|
|
131
|
-
|
|
132
|
-
return (
|
|
133
|
-
<Card
|
|
134
|
-
data-as="button"
|
|
135
|
-
disabled={disabled}
|
|
136
|
-
padding={3}
|
|
137
|
-
radius={1}
|
|
138
|
-
selected={selected}
|
|
139
|
-
tabIndex={tabIndex}
|
|
140
|
-
>
|
|
141
|
-
<Flex gap={3}>
|
|
142
|
-
<Text>
|
|
143
|
-
<EarthAmericasIcon />
|
|
144
|
-
</Text>
|
|
145
|
-
|
|
146
|
-
{loading && (
|
|
147
|
-
<Text muted>
|
|
148
|
-
<>Loading…</>
|
|
149
|
-
</Text>
|
|
150
|
-
)}
|
|
151
|
-
|
|
152
|
-
{!loading && <Text muted={!data}>{data ? data.title : <>Untitled</>}</Text>}
|
|
153
|
-
</Flex>
|
|
154
|
-
</Card>
|
|
155
|
-
)
|
|
156
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Autocomplete,
|
|
3
|
-
BoundaryElementProvider,
|
|
4
|
-
Box,
|
|
5
|
-
Card,
|
|
6
|
-
Container,
|
|
7
|
-
LayerProvider,
|
|
8
|
-
Stack,
|
|
9
|
-
Text,
|
|
10
|
-
} from '@sanity/ui'
|
|
11
|
-
import {useCallback, useState} from 'react'
|
|
12
|
-
|
|
13
|
-
import {Popover} from '../../../primitives'
|
|
14
|
-
import countries from '../__mocks__/countries'
|
|
15
|
-
import {AutocompleteProps} from '../autocomplete'
|
|
16
|
-
import {ExampleOption} from './types'
|
|
17
|
-
|
|
18
|
-
export default function ConstrainedHeightStory() {
|
|
19
|
-
const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<Card height="fill" tone="transparent">
|
|
23
|
-
<Container height="fill" padding={3} sizing="border" width={1}>
|
|
24
|
-
<Card
|
|
25
|
-
height="fill"
|
|
26
|
-
ref={setBoundaryElement}
|
|
27
|
-
radius={3}
|
|
28
|
-
shadow={3}
|
|
29
|
-
style={{position: 'relative'}}
|
|
30
|
-
// style={{position: 'absolute', top: 12, right: 12, bottom: 12, left: 12}}
|
|
31
|
-
>
|
|
32
|
-
<Box height="fill" overflow="auto" padding={[4, 4, 5]} sizing="border">
|
|
33
|
-
<Stack space={5}>
|
|
34
|
-
<BoundaryElementProvider element={boundaryElement}>
|
|
35
|
-
<ConstrainedHeightExampleField id="example-1" label="Example 1" />
|
|
36
|
-
<ConstrainedHeightExampleField id="example-2" label="Example 2" />
|
|
37
|
-
<ConstrainedHeightExampleField id="example-3" label="Example 3" />
|
|
38
|
-
<ConstrainedHeightExampleField id="example-4" label="Example 4" />
|
|
39
|
-
<ConstrainedHeightExampleField id="example-5" label="Example 5" />
|
|
40
|
-
<ConstrainedHeightExampleField id="example-6" label="Example 6" />
|
|
41
|
-
<ConstrainedHeightExampleField id="example-7" label="Example 7" />
|
|
42
|
-
<ConstrainedHeightExampleField id="example-8" label="Example 8" />
|
|
43
|
-
<ConstrainedHeightExampleField id="example-9" label="Example 9" />
|
|
44
|
-
</BoundaryElementProvider>
|
|
45
|
-
</Stack>
|
|
46
|
-
</Box>
|
|
47
|
-
</Card>
|
|
48
|
-
</Container>
|
|
49
|
-
</Card>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function ConstrainedHeightExampleField({id, label}: {id: string; label: string}) {
|
|
54
|
-
const [value, setValue] = useState('')
|
|
55
|
-
|
|
56
|
-
const renderOption = useCallback((option: ExampleOption) => {
|
|
57
|
-
return (
|
|
58
|
-
<Card
|
|
59
|
-
as="a"
|
|
60
|
-
data-qa={`option-${option.value}`}
|
|
61
|
-
href="#"
|
|
62
|
-
key={option.value}
|
|
63
|
-
onClick={(event) => event.preventDefault()}
|
|
64
|
-
padding={3}
|
|
65
|
-
radius={2}
|
|
66
|
-
>
|
|
67
|
-
<Text textOverflow="ellipsis">{option.title}</Text>
|
|
68
|
-
</Card>
|
|
69
|
-
)
|
|
70
|
-
}, [])
|
|
71
|
-
|
|
72
|
-
const renderValue = useCallback((currentValue: string, option?: ExampleOption) => {
|
|
73
|
-
return option ? option.title : currentValue
|
|
74
|
-
}, [])
|
|
75
|
-
|
|
76
|
-
const filterOption = useCallback((query: string, option: ExampleOption) => {
|
|
77
|
-
return option.title.toLowerCase().indexOf(query.toLowerCase()) > -1
|
|
78
|
-
}, [])
|
|
79
|
-
|
|
80
|
-
const options = countries.map((item) => ({value: item.code, title: item.name}))
|
|
81
|
-
|
|
82
|
-
const renderPopover: AutocompleteProps['renderPopover'] = useCallback(
|
|
83
|
-
(
|
|
84
|
-
popoverProps: {
|
|
85
|
-
content: React.JSX.Element | null
|
|
86
|
-
hidden: boolean
|
|
87
|
-
inputElement: HTMLInputElement | null
|
|
88
|
-
onMouseEnter: () => void
|
|
89
|
-
onMouseLeave: () => void
|
|
90
|
-
},
|
|
91
|
-
popoverRef: React.Ref<HTMLDivElement>,
|
|
92
|
-
) => {
|
|
93
|
-
const {hidden, inputElement, ...restProps} = popoverProps
|
|
94
|
-
|
|
95
|
-
if (hidden) return null
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<Popover
|
|
99
|
-
{...restProps}
|
|
100
|
-
arrow={false}
|
|
101
|
-
constrainSize
|
|
102
|
-
matchReferenceWidth
|
|
103
|
-
open
|
|
104
|
-
overflow="auto"
|
|
105
|
-
placement="bottom-start"
|
|
106
|
-
radius={1}
|
|
107
|
-
ref={popoverRef}
|
|
108
|
-
referenceElement={inputElement}
|
|
109
|
-
/>
|
|
110
|
-
)
|
|
111
|
-
},
|
|
112
|
-
[],
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<Stack space={3}>
|
|
117
|
-
<Text size={1} weight="medium">
|
|
118
|
-
{label}
|
|
119
|
-
</Text>
|
|
120
|
-
<LayerProvider zOffset={100}>
|
|
121
|
-
<Autocomplete
|
|
122
|
-
filterOption={filterOption}
|
|
123
|
-
id={id}
|
|
124
|
-
onChange={setValue}
|
|
125
|
-
openButton
|
|
126
|
-
options={options}
|
|
127
|
-
placeholder="Search"
|
|
128
|
-
radius={1}
|
|
129
|
-
renderOption={renderOption}
|
|
130
|
-
renderPopover={renderPopover}
|
|
131
|
-
renderValue={renderValue}
|
|
132
|
-
value={value}
|
|
133
|
-
/>
|
|
134
|
-
</LayerProvider>
|
|
135
|
-
</Stack>
|
|
136
|
-
)
|
|
137
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import {Autocomplete, Box, Button, Card, Code, Container, Stack, Text} from '@sanity/ui'
|
|
2
|
-
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
3
|
-
import {useCallback, useState} from 'react'
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
WORKSHOP_RADIUS_OPTIONS,
|
|
7
|
-
WORKSHOP_SPACE_OPTIONS,
|
|
8
|
-
WORKSHOP_TEXT_SIZE_OPTIONS,
|
|
9
|
-
} from '../../../__workshop__/constants'
|
|
10
|
-
import countries from '../__mocks__/countries'
|
|
11
|
-
import {ExampleOption} from './types'
|
|
12
|
-
|
|
13
|
-
export default function CustomStory() {
|
|
14
|
-
const data: ExampleOption[] = countries.map((d) => ({value: d.code, title: d.name}))
|
|
15
|
-
const border = useBoolean('Border', true, 'Props')
|
|
16
|
-
const disabled = useBoolean('Disabled', false, 'Props')
|
|
17
|
-
const fontSize = Number(useSelect('Font size', WORKSHOP_TEXT_SIZE_OPTIONS, 2, 'Props'))
|
|
18
|
-
const openButton = useBoolean('Open button', true, 'Props')
|
|
19
|
-
const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
20
|
-
const radius = Number(useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 2, 'Props'))
|
|
21
|
-
const readOnly = useBoolean('Read only', false, 'Props')
|
|
22
|
-
const [value, setValue] = useState('')
|
|
23
|
-
|
|
24
|
-
const renderOption = useCallback(
|
|
25
|
-
(option: ExampleOption) => (
|
|
26
|
-
<Card
|
|
27
|
-
as="a"
|
|
28
|
-
data-qa={`option-${option.value}`}
|
|
29
|
-
href="#"
|
|
30
|
-
key={option.value}
|
|
31
|
-
onClick={(event) => event.preventDefault()}
|
|
32
|
-
padding={padding}
|
|
33
|
-
radius={radius - 1}
|
|
34
|
-
>
|
|
35
|
-
<Text size={fontSize}>{option.title}</Text>
|
|
36
|
-
</Card>
|
|
37
|
-
),
|
|
38
|
-
[fontSize, padding, radius],
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
const renderValue = useCallback((currentValue: string, option?: ExampleOption) => {
|
|
42
|
-
return option ? option.title : currentValue
|
|
43
|
-
}, [])
|
|
44
|
-
|
|
45
|
-
const filterOption = useCallback((query: string, option: ExampleOption) => {
|
|
46
|
-
return option.title.toLowerCase().indexOf(query.toLowerCase()) > -1
|
|
47
|
-
}, [])
|
|
48
|
-
|
|
49
|
-
const options = data.map((item) => ({value: item.value, title: item.title}))
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<Box paddingX={[4, 5, 6]} paddingY={[5, 6, 7]}>
|
|
53
|
-
<Container width={0}>
|
|
54
|
-
<Stack space={5}>
|
|
55
|
-
<Stack space={3}>
|
|
56
|
-
<Text as="label" htmlFor="custom" id="custom-label" size={1} weight="medium">
|
|
57
|
-
Country
|
|
58
|
-
</Text>
|
|
59
|
-
<Autocomplete
|
|
60
|
-
aria-describedby="custom-label"
|
|
61
|
-
border={border}
|
|
62
|
-
disabled={disabled}
|
|
63
|
-
filterOption={filterOption}
|
|
64
|
-
fontSize={fontSize}
|
|
65
|
-
id="custom"
|
|
66
|
-
onChange={setValue}
|
|
67
|
-
openButton={openButton}
|
|
68
|
-
options={options}
|
|
69
|
-
padding={padding}
|
|
70
|
-
placeholder="Search"
|
|
71
|
-
radius={radius}
|
|
72
|
-
readOnly={readOnly}
|
|
73
|
-
renderOption={renderOption}
|
|
74
|
-
renderValue={renderValue}
|
|
75
|
-
value={value}
|
|
76
|
-
/>
|
|
77
|
-
</Stack>
|
|
78
|
-
|
|
79
|
-
<Card padding={3} radius={2} tone="transparent">
|
|
80
|
-
<Code size={1}>{JSON.stringify(value)}</Code>
|
|
81
|
-
</Card>
|
|
82
|
-
<Box>
|
|
83
|
-
<Button id="set-value-btn" onClick={() => setValue('NO')} text="Set to NO" />
|
|
84
|
-
</Box>
|
|
85
|
-
</Stack>
|
|
86
|
-
</Container>
|
|
87
|
-
</Box>
|
|
88
|
-
)
|
|
89
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import {Autocomplete, Box, Card, Container, Stack, Text} from '@sanity/ui'
|
|
2
|
-
import {useBoolean, useSelect, useText} from '@sanity/ui-workshop'
|
|
3
|
-
import {PerfTestProps, usePerfTest} from '@sanity/ui-workshop/plugin-perf'
|
|
4
|
-
import {fireEvent} from '@testing-library/dom'
|
|
5
|
-
import {useCallback, useMemo, useState} from 'react'
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
WORKSHOP_CARD_TONE_OPTIONS,
|
|
9
|
-
WORKSHOP_RADIUS_OPTIONS,
|
|
10
|
-
WORKSHOP_SPACE_OPTIONS,
|
|
11
|
-
WORKSHOP_TEXT_SIZE_OPTIONS,
|
|
12
|
-
} from '../../../__workshop__/constants'
|
|
13
|
-
import countries from '../__mocks__/countries'
|
|
14
|
-
|
|
15
|
-
const typingPerfTest: PerfTestProps<HTMLInputElement> = {
|
|
16
|
-
name: 'typing',
|
|
17
|
-
title: 'Typing',
|
|
18
|
-
description: 'This test types one character at a time',
|
|
19
|
-
run({target}) {
|
|
20
|
-
const text = 'Hello, world & Hello, world & Hello, world'
|
|
21
|
-
const len = text.length
|
|
22
|
-
|
|
23
|
-
for (let i = 0; i < len; i += 1) {
|
|
24
|
-
const value = text.slice(0, i + 1)
|
|
25
|
-
|
|
26
|
-
fireEvent.change(target, {target: {value}})
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default function ExampleStory() {
|
|
32
|
-
const {ref, Wrapper} = usePerfTest(typingPerfTest)
|
|
33
|
-
|
|
34
|
-
const layoutTone = useSelect('Layout tone', WORKSHOP_CARD_TONE_OPTIONS, 'default', 'Layout')
|
|
35
|
-
const options = useMemo(() => countries.map((country) => ({value: country.code})), [])
|
|
36
|
-
const border = useBoolean('Border', true, 'Props')
|
|
37
|
-
const customValidity = useText('Custom validity', '', 'Props') || undefined
|
|
38
|
-
const disabled = useBoolean('Disabled', false, 'Props')
|
|
39
|
-
const fontSize = Number(useSelect('Font size', WORKSHOP_TEXT_SIZE_OPTIONS, 2, 'Props'))
|
|
40
|
-
const openButton = useBoolean('Open button', false, 'Props')
|
|
41
|
-
const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
42
|
-
const radius = Number(useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 2, 'Props'))
|
|
43
|
-
const readOnly = useBoolean('Read only', false, 'Props')
|
|
44
|
-
const [value, setValue] = useState('')
|
|
45
|
-
|
|
46
|
-
const handleChange = useCallback((value: string) => setValue(value), [])
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<Card height="fill" tone={layoutTone}>
|
|
50
|
-
<Container width={1}>
|
|
51
|
-
<Box paddingX={[4, 5, 6]} paddingY={[5, 6, 7]}>
|
|
52
|
-
<Stack space={3}>
|
|
53
|
-
<Text as="label" htmlFor="default" size={1} weight="medium">
|
|
54
|
-
Country code
|
|
55
|
-
</Text>
|
|
56
|
-
<Wrapper>
|
|
57
|
-
<Autocomplete
|
|
58
|
-
border={border}
|
|
59
|
-
customValidity={customValidity}
|
|
60
|
-
disabled={disabled}
|
|
61
|
-
fontSize={fontSize}
|
|
62
|
-
onChange={handleChange}
|
|
63
|
-
id="default"
|
|
64
|
-
openButton={openButton}
|
|
65
|
-
options={options}
|
|
66
|
-
padding={padding}
|
|
67
|
-
placeholder="Search"
|
|
68
|
-
radius={radius}
|
|
69
|
-
readOnly={readOnly}
|
|
70
|
-
ref={ref}
|
|
71
|
-
value={value}
|
|
72
|
-
/>
|
|
73
|
-
</Wrapper>
|
|
74
|
-
</Stack>
|
|
75
|
-
</Box>
|
|
76
|
-
</Container>
|
|
77
|
-
</Card>
|
|
78
|
-
)
|
|
79
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {Autocomplete, Box, Button, Card, Code, Stack} from '@sanity/ui'
|
|
2
|
-
import {useCallback, useState} from 'react'
|
|
3
|
-
|
|
4
|
-
export default function FocusAndBlurStory() {
|
|
5
|
-
const [value, setValue] = useState('')
|
|
6
|
-
const [log, setLog] = useState<string[]>([])
|
|
7
|
-
const handleBlur = useCallback(() => setLog((v) => v.concat(['blur'])), [])
|
|
8
|
-
const handleFocus = useCallback(() => setLog((v) => v.concat(['focus'])), [])
|
|
9
|
-
const handleClear = useCallback(() => setLog([]), [])
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<Box padding={[4, 5, 6]}>
|
|
13
|
-
<Stack space={3}>
|
|
14
|
-
<Autocomplete
|
|
15
|
-
id="focus-and-blur"
|
|
16
|
-
onBlur={handleBlur}
|
|
17
|
-
onChange={setValue}
|
|
18
|
-
onFocus={handleFocus}
|
|
19
|
-
openButton
|
|
20
|
-
options={[{value: 'foo'}, {value: 'bar'}]}
|
|
21
|
-
placeholder="Search"
|
|
22
|
-
value={value}
|
|
23
|
-
/>
|
|
24
|
-
<Stack space={3}>
|
|
25
|
-
<Card overflow="auto" padding={3} radius={2} tone="transparent">
|
|
26
|
-
<Code id="focus-and-blur-log" language="json" size={1}>
|
|
27
|
-
{JSON.stringify(log)}
|
|
28
|
-
</Code>
|
|
29
|
-
</Card>
|
|
30
|
-
|
|
31
|
-
<Button id="focus-and-blur-clear-btn" mode="ghost" onClick={handleClear} text="Clear" />
|
|
32
|
-
</Stack>
|
|
33
|
-
</Stack>
|
|
34
|
-
</Box>
|
|
35
|
-
)
|
|
36
|
-
}
|