@sanity/ui 3.3.1 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/package.json +48 -106
- 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/exports/_visual-editing.ts +0 -31
- package/exports/index.ts +0 -1
- package/exports/theme.ts +0 -1
- package/src/core/__workshop__/constants.ts +0 -293
- package/src/core/_compat.ts +0 -264
- 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/autocomplete/autocomplete.styles.tsx +0 -39
- package/src/core/components/autocomplete/autocomplete.tsx +0 -767
- package/src/core/components/autocomplete/autocompleteOption.tsx +0 -45
- 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/__workshop__/example.tsx +0 -62
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -14
- package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +0 -18
- package/src/core/components/breadcrumbs/breadcrumbs.test.tsx +0 -51
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +0 -133
- package/src/core/components/breadcrumbs/index.ts +0 -1
- 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/dialog/dialog.tsx +0 -430
- 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/__workshop__/index.ts +0 -14
- package/src/core/components/hotkeys/__workshop__/plain.tsx +0 -9
- package/src/core/components/hotkeys/hotkeys.test.tsx +0 -42
- package/src/core/components/hotkeys/hotkeys.tsx +0 -66
- package/src/core/components/hotkeys/index.ts +0 -1
- package/src/core/components/index.ts +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/menu/helpers.ts +0 -82
- package/src/core/components/menu/index.ts +0 -5
- package/src/core/components/menu/menu.spacing.test.tsx +0 -63
- package/src/core/components/menu/menu.test.tsx +0 -125
- package/src/core/components/menu/menu.tsx +0 -178
- package/src/core/components/menu/menuButton.tsx +0 -268
- package/src/core/components/menu/menuContext.ts +0 -18
- package/src/core/components/menu/menuDivider.ts +0 -23
- package/src/core/components/menu/menuGroup.spacing.test.tsx +0 -63
- package/src/core/components/menu/menuGroup.tsx +0 -233
- package/src/core/components/menu/menuItem.spacing.test.tsx +0 -59
- package/src/core/components/menu/menuItem.tsx +0 -197
- package/src/core/components/menu/useMenu.ts +0 -21
- package/src/core/components/menu/useMenuController.ts +0 -231
- 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/skeleton/index.ts +0 -2
- package/src/core/components/skeleton/skeleton.tsx +0 -57
- package/src/core/components/skeleton/styles.ts +0 -50
- package/src/core/components/skeleton/textSkeleton.tsx +0 -122
- package/src/core/components/tab/__workshop__/example.tsx +0 -79
- package/src/core/components/tab/__workshop__/index.ts +0 -14
- package/src/core/components/tab/index.ts +0 -3
- package/src/core/components/tab/tab.tsx +0 -101
- package/src/core/components/tab/tabList.test.tsx +0 -48
- package/src/core/components/tab/tabList.tsx +0 -70
- package/src/core/components/tab/tabPanel.tsx +0 -39
- 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/toast/index.ts +0 -4
- package/src/core/components/toast/styles.ts +0 -77
- package/src/core/components/toast/toast.test.tsx +0 -101
- package/src/core/components/toast/toast.tsx +0 -198
- package/src/core/components/toast/toastContext.ts +0 -7
- package/src/core/components/toast/toastLayer.tsx +0 -51
- 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/__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/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 -55
- package/src/core/components/tree/tree.tsx +0 -240
- package/src/core/components/tree/treeContext.ts +0 -10
- package/src/core/components/tree/treeGroup.tsx +0 -28
- package/src/core/components/tree/treeItem.test.tsx +0 -65
- package/src/core/components/tree/treeItem.tsx +0 -224
- 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 -12
- package/src/core/hooks/useArrayProp.ts +0 -17
- package/src/core/hooks/useClickOutside.test.tsx +0 -482
- package/src/core/hooks/useClickOutside.ts +0 -118
- package/src/core/hooks/useClickOutsideEvent.test.tsx +0 -115
- package/src/core/hooks/useClickOutsideEvent.ts +0 -73
- package/src/core/hooks/useCustomValidity.ts +0 -13
- package/src/core/hooks/useDelayed.test.ts +0 -88
- package/src/core/hooks/useDelayedState.ts +0 -36
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +0 -32
- package/src/core/hooks/useElementRect/__workshop__/index.ts +0 -14
- package/src/core/hooks/useElementRect/index.ts +0 -1
- package/src/core/hooks/useElementRect/useElementRect.ts +0 -13
- package/src/core/hooks/useElementSize.ts +0 -19
- package/src/core/hooks/useForwardedRef.ts +0 -19
- 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/__workshop__/index.ts +0 -14
- package/src/core/hooks/useMediaIndex/__workshop__/test.tsx +0 -14
- package/src/core/hooks/useMediaIndex/index.ts +0 -1
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +0 -36
- 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 -56
- package/src/core/hooks/usePrefersDark.test.tsx +0 -19
- package/src/core/hooks/usePrefersDark.ts +0 -16
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +0 -56
- package/src/core/hooks/usePrefersReducedMotion.test.tsx +0 -19
- package/src/core/hooks/usePrefersReducedMotion.ts +0 -16
- package/src/core/index.ts +0 -10
- package/src/core/lib/createGlobalScopedContext.ts +0 -36
- package/src/core/lib/globalScope.ts +0 -19
- package/src/core/lib/isRecord.ts +0 -3
- package/src/core/middleware/origin.ts +0 -47
- package/src/core/observers/elementSizeObserver.ts +0 -116
- 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/__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/avatar/avatar.tsx +0 -200
- package/src/core/primitives/avatar/avatarCounter.tsx +0 -91
- package/src/core/primitives/avatar/avatarStack.tsx +0 -100
- 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/__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/badge/badge.test.tsx +0 -16
- package/src/core/primitives/badge/badge.tsx +0 -70
- 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/__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/box/box.test.tsx +0 -142
- package/src/core/primitives/box/box.tsx +0 -154
- package/src/core/primitives/box/index.ts +0 -1
- 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/button/button.test.tsx +0 -82
- package/src/core/primitives/button/button.tsx +0 -210
- package/src/core/primitives/button/index.ts +0 -1
- package/src/core/primitives/button/styles.ts +0 -117
- 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/card/card.tsx +0 -128
- 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 -11
- 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/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/__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/code/code.tsx +0 -55
- package/src/core/primitives/code/index.ts +0 -1
- package/src/core/primitives/code/refractor.tsx +0 -20
- package/src/core/primitives/code/styles.ts +0 -77
- package/src/core/primitives/container/__workshop__/example.tsx +0 -20
- package/src/core/primitives/container/__workshop__/index.ts +0 -8
- package/src/core/primitives/container/container.tsx +0 -54
- 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/__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/flex/flex.tsx +0 -64
- package/src/core/primitives/flex/index.ts +0 -1
- package/src/core/primitives/grid/__workshop__/index.ts +0 -10
- package/src/core/primitives/grid/__workshop__/responsive.tsx +0 -54
- package/src/core/primitives/grid/grid.test.tsx +0 -80
- package/src/core/primitives/grid/grid.tsx +0 -74
- package/src/core/primitives/grid/index.ts +0 -1
- 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/heading/heading.tsx +0 -88
- 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/__workshop__/index.ts +0 -8
- package/src/core/primitives/inline/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/inline/index.ts +0 -1
- package/src/core/primitives/inline/inline.test.tsx +0 -51
- package/src/core/primitives/inline/inline.tsx +0 -63
- package/src/core/primitives/inline/styles.ts +0 -32
- package/src/core/primitives/inline/types.ts +0 -6
- package/src/core/primitives/kbd/__workshop__/index.ts +0 -8
- package/src/core/primitives/kbd/__workshop__/plain.tsx +0 -9
- package/src/core/primitives/kbd/index.ts +0 -1
- package/src/core/primitives/kbd/kbd.tsx +0 -69
- 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/label/index.ts +0 -1
- package/src/core/primitives/label/label.tsx +0 -87
- package/src/core/primitives/label/styles.ts +0 -45
- 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/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 -511
- package/src/core/primitives/popover/popoverCard.tsx +0 -166
- package/src/core/primitives/popover/types.ts +0 -7
- 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/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/__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/select/index.ts +0 -1
- package/src/core/primitives/select/select.test.tsx +0 -52
- package/src/core/primitives/select/select.tsx +0 -94
- package/src/core/primitives/select/styles.ts +0 -166
- package/src/core/primitives/spinner/__workshop__/Props.tsx +0 -15
- package/src/core/primitives/spinner/__workshop__/index.ts +0 -14
- package/src/core/primitives/spinner/index.ts +0 -1
- package/src/core/primitives/spinner/spinner.tsx +0 -46
- package/src/core/primitives/stack/__workshop__/index.ts +0 -14
- package/src/core/primitives/stack/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/stack/index.ts +0 -1
- package/src/core/primitives/stack/stack.test.tsx +0 -57
- package/src/core/primitives/stack/stack.tsx +0 -57
- package/src/core/primitives/stack/styles.ts +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/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/__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/text/index.ts +0 -1
- package/src/core/primitives/text/styles.ts +0 -74
- package/src/core/primitives/text/text.tsx +0 -89
- package/src/core/primitives/textArea/__workshop__/index.ts +0 -14
- package/src/core/primitives/textArea/__workshop__/plain.tsx +0 -50
- package/src/core/primitives/textArea/index.ts +0 -1
- package/src/core/primitives/textArea/textArea.tsx +0 -120
- 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/textInput/index.ts +0 -1
- package/src/core/primitives/textInput/textInput.test.tsx +0 -48
- package/src/core/primitives/textInput/textInput.tsx +0 -395
- 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/primitives/tooltip/constants.ts +0 -23
- package/src/core/primitives/tooltip/index.ts +0 -2
- package/src/core/primitives/tooltip/tooltip.test.tsx +0 -452
- package/src/core/primitives/tooltip/tooltip.tsx +0 -495
- package/src/core/primitives/tooltip/tooltipCard.tsx +0 -109
- 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 -10
- 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 -25
- 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 -103
- 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 -35
- package/src/core/styles/grid/gridItemStyle.ts +0 -82
- package/src/core/styles/grid/gridStyle.ts +0 -108
- 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 -21
- package/src/core/styles/margin/marginsStyle.test.ts +0 -33
- 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 -33
- package/src/core/styles/padding/paddingStyle.ts +0 -21
- 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/__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/theme/index.ts +0 -5
- package/src/core/theme/theme.test.tsx +0 -73
- 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 -17
- package/src/core/theme/useTheme.ts +0 -16
- 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 -123
- package/src/core/utils/arrow/cmds.ts +0 -91
- package/src/core/utils/arrow/index.ts +0 -1
- package/src/core/utils/boundaryElement/__workshop__/index.ts +0 -14
- package/src/core/utils/boundaryElement/__workshop__/plain.tsx +0 -19
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +0 -100
- 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 -21
- package/src/core/utils/conditionalWrapper/index.ts +0 -1
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +0 -30
- package/src/core/utils/elementQuery/__workshop__/index.ts +0 -14
- 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 -26
- package/src/core/utils/index.ts +0 -9
- 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/layer/getLayerContext.test.ts +0 -30
- 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 -108
- package/src/core/utils/layer/layer.tsx +0 -98
- 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 -26
- package/src/core/utils/portal/__workshop__/index.ts +0 -14
- package/src/core/utils/portal/__workshop__/named.tsx +0 -63
- package/src/core/utils/portal/index.ts +0 -4
- package/src/core/utils/portal/portal.test.tsx +0 -103
- 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 -47
- 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/__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
- package/src/core/utils/virtualList/index.ts +0 -1
- package/src/core/utils/virtualList/virtualList.tsx +0 -200
- package/src/theme/build/_deprecated/color/_selectable/createSelectableTones.ts +0 -76
- package/src/theme/build/_deprecated/color/_solid/createSolidTones.ts +0 -54
- package/src/theme/build/_deprecated/color/button/createButtonModes.ts +0 -22
- package/src/theme/build/_deprecated/color/button/createButtonTones.ts +0 -55
- package/src/theme/build/_deprecated/color/card/createCardStates.ts +0 -60
- package/src/theme/build/_deprecated/color/color.test.ts +0 -63
- package/src/theme/build/_deprecated/color/defaults.ts +0 -390
- package/src/theme/build/_deprecated/color/factory.ts +0 -142
- package/src/theme/build/_deprecated/color/index.ts +0 -1
- package/src/theme/build/_deprecated/color/input/createInputModes.ts +0 -81
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +0 -54
- package/src/theme/build/_deprecated/color/spot/createSpot.ts +0 -20
- package/src/theme/build/buildColorTheme.test.ts +0 -183
- package/src/theme/build/buildColorTheme.ts +0 -499
- package/src/theme/build/buildTheme.test.ts +0 -87
- 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 -68
- 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 -26
- package/src/theme/build/mixThemeColor.test.ts +0 -21
- package/src/theme/build/mixThemeColor.ts +0 -53
- package/src/theme/build/renderColorTheme.ts +0 -532
- package/src/theme/build/renderColorValue.ts +0 -85
- package/src/theme/build/resolveColorTokens.ts +0 -268
- package/src/theme/build/theme.test.ts +0 -27
- package/src/theme/config/helpers.ts +0 -55
- package/src/theme/config/index.ts +0 -4
- package/src/theme/config/system.ts +0 -115
- package/src/theme/config/tokens/color/index.ts +0 -1
- package/src/theme/config/tokens/color/types.ts +0 -133
- package/src/theme/config/tokens/index.ts +0 -4
- package/src/theme/config/tokens/parseTokenKey.test.ts +0 -64
- package/src/theme/config/tokens/parseTokenKey.ts +0 -67
- package/src/theme/config/tokens/parseTokenValue.test.ts +0 -42
- package/src/theme/config/tokens/parseTokenValue.ts +0 -133
- 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 -98
- 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 -24
- 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 -138
- 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 -17
- package/src/theme/system/v0/color/base.ts +0 -21
- package/src/theme/system/v0/color/button.ts +0 -42
- package/src/theme/system/v0/color/card.ts +0 -19
- package/src/theme/system/v0/color/color.ts +0 -40
- package/src/theme/system/v0/color/index.ts +0 -11
- package/src/theme/system/v0/color/input.ts +0 -34
- package/src/theme/system/v0/color/muted.ts +0 -26
- package/src/theme/system/v0/color/selectable.ts +0 -31
- package/src/theme/system/v0/color/solid.ts +0 -26
- package/src/theme/system/v0/color/spot.ts +0 -13
- 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 -57
- 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 -243
- package/src/theme/versioning/themeColor_v2_v2_9.ts +0 -49
- package/src/theme/versioning/v0_v2.ts +0 -94
- package/src/theme/versioning/v2_v0.ts +0 -135
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import {useCallback, useEffect, useRef, useState} from 'react'
|
|
2
|
-
|
|
3
|
-
import {_getFocusableElements, _sortElements} from './helpers'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export interface MenuController {
|
|
9
|
-
activeElement: HTMLElement | null
|
|
10
|
-
activeIndex: number
|
|
11
|
-
handleItemMouseEnter: (event: React.MouseEvent<HTMLElement>) => void
|
|
12
|
-
handleItemMouseLeave: () => void
|
|
13
|
-
handleKeyDown: (event: React.KeyboardEvent<HTMLDivElement>) => void
|
|
14
|
-
mount: (element: HTMLElement | null, selected?: boolean) => () => void
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* This controller is responsible for controlling UI menu state.
|
|
19
|
-
*
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
export function useMenuController(props: {
|
|
23
|
-
onKeyDown?: React.KeyboardEventHandler
|
|
24
|
-
originElement?: HTMLElement | null
|
|
25
|
-
shouldFocus: 'first' | 'last' | null
|
|
26
|
-
rootElementRef: React.MutableRefObject<HTMLDivElement | null>
|
|
27
|
-
}): MenuController {
|
|
28
|
-
const {onKeyDown, originElement, shouldFocus, rootElementRef} = props
|
|
29
|
-
const elementsRef = useRef<HTMLElement[]>([])
|
|
30
|
-
const [activeIndex, _setActiveIndex] = useState(-1)
|
|
31
|
-
const activeIndexRef = useRef(activeIndex)
|
|
32
|
-
const [activeElement, setActiveElement] = useState<HTMLElement | null>(null)
|
|
33
|
-
|
|
34
|
-
const setActiveIndex = useCallback((nextActiveIndex: number) => {
|
|
35
|
-
_setActiveIndex(nextActiveIndex)
|
|
36
|
-
activeIndexRef.current = nextActiveIndex
|
|
37
|
-
setActiveElement(elementsRef.current[nextActiveIndex] || null)
|
|
38
|
-
}, [])
|
|
39
|
-
|
|
40
|
-
const mount = useCallback(
|
|
41
|
-
(element: HTMLElement | null, selected?: boolean): (() => void) => {
|
|
42
|
-
if (!element) return () => undefined
|
|
43
|
-
|
|
44
|
-
if (elementsRef.current.indexOf(element) === -1) {
|
|
45
|
-
elementsRef.current.push(element)
|
|
46
|
-
_sortElements(rootElementRef.current, elementsRef.current)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (selected) {
|
|
50
|
-
const selectedIndex = elementsRef.current.indexOf(element)
|
|
51
|
-
|
|
52
|
-
setActiveIndex(selectedIndex)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return () => {
|
|
56
|
-
const idx = elementsRef.current.indexOf(element)
|
|
57
|
-
|
|
58
|
-
if (idx > -1) {
|
|
59
|
-
elementsRef.current.splice(idx, 1)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
[rootElementRef, setActiveIndex],
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
const handleKeyDown = useCallback(
|
|
67
|
-
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
68
|
-
// Move focus to the element that opened the menu before handling the `Tab` press
|
|
69
|
-
if (event.key === 'Tab') {
|
|
70
|
-
if (originElement) {
|
|
71
|
-
originElement.focus()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Move focus to the first focusable menuitem
|
|
78
|
-
if (event.key === 'Home') {
|
|
79
|
-
event.preventDefault()
|
|
80
|
-
event.stopPropagation()
|
|
81
|
-
|
|
82
|
-
const focusableElements = _getFocusableElements(elementsRef.current)
|
|
83
|
-
const el = focusableElements[0]
|
|
84
|
-
|
|
85
|
-
if (!el) return
|
|
86
|
-
|
|
87
|
-
const currentIndex = elementsRef.current.indexOf(el)
|
|
88
|
-
|
|
89
|
-
setActiveIndex(currentIndex)
|
|
90
|
-
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Move focus to the last focusable menuitem
|
|
95
|
-
if (event.key === 'End') {
|
|
96
|
-
event.preventDefault()
|
|
97
|
-
event.stopPropagation()
|
|
98
|
-
|
|
99
|
-
const focusableElements = _getFocusableElements(elementsRef.current)
|
|
100
|
-
const el = focusableElements[focusableElements.length - 1]
|
|
101
|
-
|
|
102
|
-
if (!el) return
|
|
103
|
-
|
|
104
|
-
const currentIndex = elementsRef.current.indexOf(el)
|
|
105
|
-
|
|
106
|
-
setActiveIndex(currentIndex)
|
|
107
|
-
|
|
108
|
-
return
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (event.key === 'ArrowUp') {
|
|
112
|
-
event.preventDefault()
|
|
113
|
-
event.stopPropagation()
|
|
114
|
-
|
|
115
|
-
const focusableElements = _getFocusableElements(elementsRef.current)
|
|
116
|
-
const focusableLen = focusableElements.length
|
|
117
|
-
|
|
118
|
-
if (focusableLen === 0) return
|
|
119
|
-
|
|
120
|
-
const focusedElement = elementsRef.current[activeIndexRef.current]
|
|
121
|
-
|
|
122
|
-
let focusedIndex = focusableElements.indexOf(focusedElement)
|
|
123
|
-
|
|
124
|
-
focusedIndex = (focusedIndex - 1 + focusableLen) % focusableLen
|
|
125
|
-
|
|
126
|
-
const el = focusableElements[focusedIndex]
|
|
127
|
-
const currentIndex = elementsRef.current.indexOf(el)
|
|
128
|
-
|
|
129
|
-
setActiveIndex(currentIndex)
|
|
130
|
-
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (event.key === 'ArrowDown') {
|
|
135
|
-
event.preventDefault()
|
|
136
|
-
event.stopPropagation()
|
|
137
|
-
|
|
138
|
-
const focusableElements = _getFocusableElements(elementsRef.current)
|
|
139
|
-
const focusableLen = focusableElements.length
|
|
140
|
-
|
|
141
|
-
if (focusableLen === 0) return
|
|
142
|
-
|
|
143
|
-
const focusedElement = elementsRef.current[activeIndexRef.current]
|
|
144
|
-
|
|
145
|
-
let focusedIndex = focusableElements.indexOf(focusedElement)
|
|
146
|
-
|
|
147
|
-
focusedIndex = (focusedIndex + 1) % focusableLen
|
|
148
|
-
|
|
149
|
-
const el = focusableElements[focusedIndex]
|
|
150
|
-
const currentIndex = elementsRef.current.indexOf(el)
|
|
151
|
-
|
|
152
|
-
setActiveIndex(currentIndex)
|
|
153
|
-
|
|
154
|
-
return
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (onKeyDown) {
|
|
158
|
-
onKeyDown(event)
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
[onKeyDown, originElement, setActiveIndex],
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
const handleItemMouseEnter = useCallback(
|
|
165
|
-
(event: React.MouseEvent<HTMLElement>) => {
|
|
166
|
-
const element = event.currentTarget
|
|
167
|
-
const currentIndex = elementsRef.current.indexOf(element)
|
|
168
|
-
|
|
169
|
-
setActiveIndex(currentIndex)
|
|
170
|
-
},
|
|
171
|
-
[setActiveIndex],
|
|
172
|
-
)
|
|
173
|
-
|
|
174
|
-
const handleItemMouseLeave = useCallback(() => {
|
|
175
|
-
// Set the active index to -2 to deactivate all menu items
|
|
176
|
-
// when the user moves the mouse away from the menu item.
|
|
177
|
-
// We avoid using -1 because it would focus the first menu item,
|
|
178
|
-
// which would be incorrect when the user hovers over a gap
|
|
179
|
-
// between two menu items or a menu divider.
|
|
180
|
-
setActiveIndex(-2)
|
|
181
|
-
rootElementRef.current?.focus()
|
|
182
|
-
}, [rootElementRef, setActiveIndex])
|
|
183
|
-
|
|
184
|
-
// Set focus on the currently active element
|
|
185
|
-
useEffect(() => {
|
|
186
|
-
if (!rootElementRef.current) return
|
|
187
|
-
|
|
188
|
-
const rafId = requestAnimationFrame(() => {
|
|
189
|
-
if (activeIndex === -1) {
|
|
190
|
-
if (shouldFocus === 'first') {
|
|
191
|
-
const focusableElements = _getFocusableElements(elementsRef.current)
|
|
192
|
-
const el = focusableElements[0]
|
|
193
|
-
|
|
194
|
-
if (el) {
|
|
195
|
-
const currentIndex = elementsRef.current.indexOf(el)
|
|
196
|
-
|
|
197
|
-
setActiveIndex(currentIndex)
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if (shouldFocus === 'last') {
|
|
202
|
-
const focusableElements = _getFocusableElements(elementsRef.current)
|
|
203
|
-
const el = focusableElements[focusableElements.length - 1]
|
|
204
|
-
|
|
205
|
-
if (el) {
|
|
206
|
-
const currentIndex = elementsRef.current.indexOf(el)
|
|
207
|
-
|
|
208
|
-
setActiveIndex(currentIndex)
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const element = elementsRef.current[activeIndex] || null
|
|
216
|
-
|
|
217
|
-
element?.focus()
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
return () => cancelAnimationFrame(rafId)
|
|
221
|
-
}, [activeIndex, rootElementRef, setActiveIndex, shouldFocus])
|
|
222
|
-
|
|
223
|
-
return {
|
|
224
|
-
activeElement,
|
|
225
|
-
activeIndex,
|
|
226
|
-
handleItemMouseEnter,
|
|
227
|
-
handleItemMouseLeave,
|
|
228
|
-
handleKeyDown,
|
|
229
|
-
mount,
|
|
230
|
-
}
|
|
231
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
Card,
|
|
4
|
-
CodeSkeleton,
|
|
5
|
-
Container,
|
|
6
|
-
Flex,
|
|
7
|
-
HeadingSkeleton,
|
|
8
|
-
LabelSkeleton,
|
|
9
|
-
Skeleton,
|
|
10
|
-
Stack,
|
|
11
|
-
Text,
|
|
12
|
-
TextSkeleton,
|
|
13
|
-
} from '@sanity/ui'
|
|
14
|
-
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
15
|
-
|
|
16
|
-
import {WORKSHOP_CARD_TONE_OPTIONS} from '../../../__workshop__/constants'
|
|
17
|
-
|
|
18
|
-
export default function SkeletonDelayStory() {
|
|
19
|
-
const tone = useSelect('Tone', WORKSHOP_CARD_TONE_OPTIONS, '', 'Props') || 'default'
|
|
20
|
-
const animated = useBoolean('Animated', true)
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<Box padding={[4, 5, 6]}>
|
|
24
|
-
<Container width={1}>
|
|
25
|
-
<Text muted>Delayed by 2000ms</Text>
|
|
26
|
-
<Card tone={tone} marginTop={4} padding={2} radius={2} border>
|
|
27
|
-
<Flex align="center">
|
|
28
|
-
<Skeleton
|
|
29
|
-
style={{width: 90, height: 90}}
|
|
30
|
-
radius={2}
|
|
31
|
-
animated={animated}
|
|
32
|
-
marginRight={3}
|
|
33
|
-
delay={1000}
|
|
34
|
-
/>
|
|
35
|
-
<Stack space={2} flex={1}>
|
|
36
|
-
<HeadingSkeleton
|
|
37
|
-
size={4}
|
|
38
|
-
style={{width: '100%'}}
|
|
39
|
-
radius={1}
|
|
40
|
-
animated={animated}
|
|
41
|
-
delay={1000}
|
|
42
|
-
/>
|
|
43
|
-
<TextSkeleton
|
|
44
|
-
size={1}
|
|
45
|
-
style={{width: '100%'}}
|
|
46
|
-
radius={1}
|
|
47
|
-
animated={animated}
|
|
48
|
-
delay={1000}
|
|
49
|
-
/>
|
|
50
|
-
<LabelSkeleton
|
|
51
|
-
size={1}
|
|
52
|
-
style={{width: '100%'}}
|
|
53
|
-
radius={1}
|
|
54
|
-
animated={animated}
|
|
55
|
-
delay={1000}
|
|
56
|
-
/>
|
|
57
|
-
<CodeSkeleton
|
|
58
|
-
size={1}
|
|
59
|
-
style={{width: '100%'}}
|
|
60
|
-
radius={1}
|
|
61
|
-
animated={animated}
|
|
62
|
-
delay={1000}
|
|
63
|
-
/>
|
|
64
|
-
</Stack>
|
|
65
|
-
</Flex>
|
|
66
|
-
</Card>
|
|
67
|
-
</Container>
|
|
68
|
-
</Box>
|
|
69
|
-
)
|
|
70
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {defineScope} from '@sanity/ui-workshop'
|
|
2
|
-
import {lazy} from 'react'
|
|
3
|
-
|
|
4
|
-
export default defineScope({
|
|
5
|
-
name: 'components/skeleton',
|
|
6
|
-
title: 'Skeleton',
|
|
7
|
-
stories: [
|
|
8
|
-
{name: 'skeleton', title: 'Skeleton', component: lazy(() => import('./skeleton'))},
|
|
9
|
-
{name: 'skeleton-delay', title: 'Skeleton delay', component: lazy(() => import('./delay'))},
|
|
10
|
-
],
|
|
11
|
-
})
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
Card,
|
|
4
|
-
CodeSkeleton,
|
|
5
|
-
Container,
|
|
6
|
-
Flex,
|
|
7
|
-
Grid,
|
|
8
|
-
HeadingSkeleton,
|
|
9
|
-
LabelSkeleton,
|
|
10
|
-
Skeleton,
|
|
11
|
-
Stack,
|
|
12
|
-
TextSkeleton,
|
|
13
|
-
} from '@sanity/ui'
|
|
14
|
-
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
15
|
-
|
|
16
|
-
import {WORKSHOP_CARD_TONE_OPTIONS} from '../../../__workshop__/constants'
|
|
17
|
-
|
|
18
|
-
export default function SkeletonStory() {
|
|
19
|
-
const tone = useSelect('Tone', WORKSHOP_CARD_TONE_OPTIONS, '', 'Props') || 'default'
|
|
20
|
-
const animated = useBoolean('Animated', true)
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<Box padding={[4, 5, 6]}>
|
|
24
|
-
<Container width={1}>
|
|
25
|
-
<Stack space={4}>
|
|
26
|
-
{[1, 2, 3].map((item) => (
|
|
27
|
-
<Card key={item} tone={tone} padding={2} radius={2} border>
|
|
28
|
-
<Flex align="center">
|
|
29
|
-
<Grid gap={2} columns={2} marginRight={3}>
|
|
30
|
-
<Skeleton style={{width: 40, height: 40}} radius={2} animated={animated} />
|
|
31
|
-
<Skeleton style={{width: 40, height: 40}} radius={2} animated={animated} />
|
|
32
|
-
<Skeleton style={{width: 40, height: 40}} radius={2} animated={animated} />
|
|
33
|
-
<Skeleton style={{width: 40, height: 40}} radius={2} animated={animated} />
|
|
34
|
-
</Grid>
|
|
35
|
-
<Stack space={2} flex={1}>
|
|
36
|
-
<HeadingSkeleton style={{width: '100%'}} radius={1} animated={animated} />
|
|
37
|
-
<TextSkeleton style={{width: '100%'}} radius={1} animated={animated} />
|
|
38
|
-
<LabelSkeleton style={{width: '100%'}} radius={1} animated={animated} />
|
|
39
|
-
<CodeSkeleton style={{width: '100%'}} radius={1} animated={animated} />
|
|
40
|
-
</Stack>
|
|
41
|
-
</Flex>
|
|
42
|
-
<Flex marginTop={2}>
|
|
43
|
-
<Skeleton
|
|
44
|
-
style={{height: 50}}
|
|
45
|
-
flex={1}
|
|
46
|
-
marginRight={1}
|
|
47
|
-
radius={2}
|
|
48
|
-
animated={animated}
|
|
49
|
-
/>
|
|
50
|
-
<Skeleton
|
|
51
|
-
style={{height: 50}}
|
|
52
|
-
flex={1}
|
|
53
|
-
marginLeft={1}
|
|
54
|
-
radius={2}
|
|
55
|
-
animated={animated}
|
|
56
|
-
/>
|
|
57
|
-
</Flex>
|
|
58
|
-
</Card>
|
|
59
|
-
))}
|
|
60
|
-
</Stack>
|
|
61
|
-
</Container>
|
|
62
|
-
</Box>
|
|
63
|
-
)
|
|
64
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {forwardRef, useEffect, useState} from 'react'
|
|
2
|
-
import {styled} from 'styled-components'
|
|
3
|
-
|
|
4
|
-
import {Box, BoxOwnProps, ResponsiveRadiusProps} from '../../primitives'
|
|
5
|
-
import {_getArrayProp} from '../../styles'
|
|
6
|
-
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
7
|
-
import {skeletonStyle} from './styles'
|
|
8
|
-
|
|
9
|
-
const StyledSkeleton = styled(Box)<
|
|
10
|
-
{$animated: boolean; $visible: boolean} & ResponsiveRadiusStyleProps
|
|
11
|
-
>(responsiveRadiusStyle, skeletonStyle)
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
15
|
-
* @beta
|
|
16
|
-
*/
|
|
17
|
-
export interface SkeletonProps extends ResponsiveRadiusProps, Omit<BoxOwnProps, 'children'> {
|
|
18
|
-
animated?: boolean
|
|
19
|
-
delay?: number
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
24
|
-
* @beta
|
|
25
|
-
*/
|
|
26
|
-
export const Skeleton = forwardRef(function Skeleton(
|
|
27
|
-
props: SkeletonProps & React.HTMLProps<HTMLDivElement>,
|
|
28
|
-
ref: React.Ref<HTMLDivElement>,
|
|
29
|
-
) {
|
|
30
|
-
const {animated = false, delay, radius, ...restProps} = props
|
|
31
|
-
const [visible, setVisible] = useState<boolean>(delay ? false : true)
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (!delay) {
|
|
35
|
-
return undefined
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const timeout = setTimeout(() => {
|
|
39
|
-
setVisible(true)
|
|
40
|
-
}, delay)
|
|
41
|
-
|
|
42
|
-
return () => {
|
|
43
|
-
clearTimeout(timeout)
|
|
44
|
-
}
|
|
45
|
-
}, [delay])
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<StyledSkeleton
|
|
49
|
-
{...restProps}
|
|
50
|
-
$animated={animated}
|
|
51
|
-
$radius={_getArrayProp(radius)}
|
|
52
|
-
$visible={delay ? visible : true}
|
|
53
|
-
ref={ref}
|
|
54
|
-
/>
|
|
55
|
-
)
|
|
56
|
-
})
|
|
57
|
-
Skeleton.displayName = 'ForwardRef(Skeleton)'
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {css, keyframes} from 'styled-components'
|
|
2
|
-
|
|
3
|
-
const keyframe = keyframes`
|
|
4
|
-
0% {
|
|
5
|
-
background-position: 100%;
|
|
6
|
-
}
|
|
7
|
-
100% {
|
|
8
|
-
background-position: -100%;
|
|
9
|
-
}
|
|
10
|
-
`
|
|
11
|
-
|
|
12
|
-
const animation = css`
|
|
13
|
-
background-image: linear-gradient(
|
|
14
|
-
to right,
|
|
15
|
-
var(--card-skeleton-color-from),
|
|
16
|
-
var(--card-skeleton-color-to),
|
|
17
|
-
var(--card-skeleton-color-from),
|
|
18
|
-
var(--card-skeleton-color-from),
|
|
19
|
-
var(--card-skeleton-color-from)
|
|
20
|
-
);
|
|
21
|
-
background-position: 100%;
|
|
22
|
-
background-size: 200% 100%;
|
|
23
|
-
background-attachment: fixed;
|
|
24
|
-
animation-name: ${keyframe};
|
|
25
|
-
animation-timing-function: ease-in-out;
|
|
26
|
-
animation-iteration-count: infinite;
|
|
27
|
-
animation-duration: 2000ms;
|
|
28
|
-
`
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
32
|
-
* @beta
|
|
33
|
-
*/
|
|
34
|
-
export const skeletonStyle = css<{$animated: boolean; $visible: boolean}>`
|
|
35
|
-
opacity: ${({$visible}) => ($visible ? 1 : 0)};
|
|
36
|
-
transition: opacity 200ms ease-in;
|
|
37
|
-
|
|
38
|
-
@media screen and (prefers-reduced-motion: no-preference) {
|
|
39
|
-
${({$animated}) =>
|
|
40
|
-
$animated
|
|
41
|
-
? animation
|
|
42
|
-
: css`
|
|
43
|
-
background-color: var(--card-skeleton-color-from);
|
|
44
|
-
`}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@media screen and (prefers-reduced-motion: reduce) {
|
|
48
|
-
background-color: var(--card-skeleton-color-from);
|
|
49
|
-
}
|
|
50
|
-
`
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import {getTheme_v2, ThemeFontKey} from '@sanity/ui/theme'
|
|
2
|
-
import {forwardRef} from 'react'
|
|
3
|
-
import {styled} from 'styled-components'
|
|
4
|
-
|
|
5
|
-
import {_getArrayProp, _responsive, ThemeProps} from '../../styles'
|
|
6
|
-
import {Skeleton, SkeletonProps} from './skeleton'
|
|
7
|
-
|
|
8
|
-
const StyledSkeleton = styled(Skeleton)<{$size: number[]; $style: ThemeFontKey}>((
|
|
9
|
-
props: {
|
|
10
|
-
$size: number[]
|
|
11
|
-
$style: ThemeFontKey
|
|
12
|
-
} & ThemeProps,
|
|
13
|
-
) => {
|
|
14
|
-
const {$size, $style} = props
|
|
15
|
-
const {font, media} = getTheme_v2(props.theme)
|
|
16
|
-
const fontStyle = font[$style]
|
|
17
|
-
|
|
18
|
-
const styles = _responsive(media, $size, (sizeIndex) => {
|
|
19
|
-
const fontSize = fontStyle.sizes[sizeIndex]
|
|
20
|
-
const capHeight = fontSize.lineHeight - fontSize.ascenderHeight - fontSize.descenderHeight
|
|
21
|
-
|
|
22
|
-
return {height: capHeight}
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
return styles
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
30
|
-
* @beta
|
|
31
|
-
*/
|
|
32
|
-
export interface TextSkeletonProps extends SkeletonProps {
|
|
33
|
-
size?: number | number[]
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
38
|
-
* @beta
|
|
39
|
-
*/
|
|
40
|
-
export interface LabelSkeletonProps extends SkeletonProps {
|
|
41
|
-
size?: number | number[]
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
46
|
-
* @beta
|
|
47
|
-
*/
|
|
48
|
-
export interface HeadingSkeletonProps extends SkeletonProps {
|
|
49
|
-
size?: number | number[]
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
54
|
-
* @beta
|
|
55
|
-
*/
|
|
56
|
-
export interface CodeSkeletonProps extends SkeletonProps {
|
|
57
|
-
size?: number | number[]
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
62
|
-
* @beta
|
|
63
|
-
*/
|
|
64
|
-
export const TextSkeleton = forwardRef(function TextSkeleton(
|
|
65
|
-
props: TextSkeletonProps &
|
|
66
|
-
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'height' | 'size'>,
|
|
67
|
-
ref: React.Ref<HTMLDivElement>,
|
|
68
|
-
) {
|
|
69
|
-
const {size = 2, ...restProps} = props
|
|
70
|
-
const $size = _getArrayProp(size)
|
|
71
|
-
|
|
72
|
-
return <StyledSkeleton {...restProps} $size={$size} ref={ref} $style="text" />
|
|
73
|
-
})
|
|
74
|
-
TextSkeleton.displayName = 'ForwardRef(TextSkeleton)'
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
78
|
-
* @beta
|
|
79
|
-
*/
|
|
80
|
-
export const LabelSkeleton = forwardRef(function TextSkeleton(
|
|
81
|
-
props: LabelSkeletonProps &
|
|
82
|
-
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'height' | 'size'>,
|
|
83
|
-
ref: React.Ref<HTMLDivElement>,
|
|
84
|
-
) {
|
|
85
|
-
const {size = 2, ...restProps} = props
|
|
86
|
-
const $size = _getArrayProp(size)
|
|
87
|
-
|
|
88
|
-
return <StyledSkeleton {...restProps} $size={$size} ref={ref} $style="label" />
|
|
89
|
-
})
|
|
90
|
-
LabelSkeleton.displayName = 'ForwardRef(LabelSkeleton)'
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
94
|
-
* @beta
|
|
95
|
-
*/
|
|
96
|
-
export const HeadingSkeleton = forwardRef(function TextSkeleton(
|
|
97
|
-
props: HeadingSkeletonProps &
|
|
98
|
-
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'height' | 'size'>,
|
|
99
|
-
ref: React.Ref<HTMLDivElement>,
|
|
100
|
-
) {
|
|
101
|
-
const {size = 2, ...restProps} = props
|
|
102
|
-
const $size = _getArrayProp(size)
|
|
103
|
-
|
|
104
|
-
return <StyledSkeleton {...restProps} $size={$size} ref={ref} $style="heading" />
|
|
105
|
-
})
|
|
106
|
-
HeadingSkeleton.displayName = 'ForwardRef(HeadingSkeleton)'
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
110
|
-
* @beta
|
|
111
|
-
*/
|
|
112
|
-
export const CodeSkeleton = forwardRef(function TextSkeleton(
|
|
113
|
-
props: CodeSkeletonProps &
|
|
114
|
-
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'height' | 'size'>,
|
|
115
|
-
ref: React.Ref<HTMLDivElement>,
|
|
116
|
-
) {
|
|
117
|
-
const {size = 2, ...restProps} = props
|
|
118
|
-
const $size = _getArrayProp(size)
|
|
119
|
-
|
|
120
|
-
return <StyledSkeleton {...restProps} $size={$size} ref={ref} $style="code" />
|
|
121
|
-
})
|
|
122
|
-
CodeSkeleton.displayName = 'ForwardRef(CodeSkeleton)'
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import {OkHandIcon, RocketIcon, SunIcon} from '@sanity/icons'
|
|
2
|
-
import {Box, Card, Tab, TabList, TabPanel, Text} from '@sanity/ui'
|
|
3
|
-
import {useBoolean} from '@sanity/ui-workshop'
|
|
4
|
-
import {useState} from 'react'
|
|
5
|
-
|
|
6
|
-
export default function ExampleStory() {
|
|
7
|
-
const [tab, setTab] = useState('foo')
|
|
8
|
-
const useLongTitle = useBoolean('Use long title', false, 'Props') || false
|
|
9
|
-
|
|
10
|
-
const longTitle =
|
|
11
|
-
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<Box padding={[4, 5, 6]}>
|
|
15
|
-
<TabList space={[1, 2, 3]}>
|
|
16
|
-
<Tab
|
|
17
|
-
aria-controls="example-panel-foo"
|
|
18
|
-
icon={SunIcon}
|
|
19
|
-
id="example-tab-foo"
|
|
20
|
-
label="Foo"
|
|
21
|
-
onClick={() => setTab('foo')}
|
|
22
|
-
selected={tab === 'foo'}
|
|
23
|
-
/>
|
|
24
|
-
<Tab
|
|
25
|
-
aria-controls="example-panel-bar"
|
|
26
|
-
icon={RocketIcon}
|
|
27
|
-
id="example-tab-bar"
|
|
28
|
-
label="Bar"
|
|
29
|
-
onClick={() => setTab('bar')}
|
|
30
|
-
selected={tab === 'bar'}
|
|
31
|
-
/>
|
|
32
|
-
<Tab
|
|
33
|
-
aria-controls="example-panel-baz"
|
|
34
|
-
icon={OkHandIcon}
|
|
35
|
-
id="example-tab-baz"
|
|
36
|
-
label={useLongTitle ? longTitle : 'Baz'}
|
|
37
|
-
onClick={() => setTab('baz')}
|
|
38
|
-
selected={tab === 'baz'}
|
|
39
|
-
/>
|
|
40
|
-
</TabList>
|
|
41
|
-
<TabPanel
|
|
42
|
-
aria-labelledby="example-panel-foo"
|
|
43
|
-
hidden={tab !== 'foo'}
|
|
44
|
-
id="example-panel-foo"
|
|
45
|
-
marginTop={[3, 4, 5]}
|
|
46
|
-
>
|
|
47
|
-
<Card border padding={3}>
|
|
48
|
-
<Text>
|
|
49
|
-
This is the <strong>Foo</strong> panel
|
|
50
|
-
</Text>
|
|
51
|
-
</Card>
|
|
52
|
-
</TabPanel>
|
|
53
|
-
<TabPanel
|
|
54
|
-
aria-labelledby="example-panel-bar"
|
|
55
|
-
hidden={tab !== 'bar'}
|
|
56
|
-
id="example-panel-bar"
|
|
57
|
-
marginTop={[3, 4, 5]}
|
|
58
|
-
>
|
|
59
|
-
<Card border padding={3}>
|
|
60
|
-
<Text>
|
|
61
|
-
This is the <strong>Bar</strong> panel
|
|
62
|
-
</Text>
|
|
63
|
-
</Card>
|
|
64
|
-
</TabPanel>
|
|
65
|
-
<TabPanel
|
|
66
|
-
aria-labelledby="example-panel-baz"
|
|
67
|
-
hidden={tab !== 'baz'}
|
|
68
|
-
id="example-panel-baz"
|
|
69
|
-
marginTop={[3, 4, 5]}
|
|
70
|
-
>
|
|
71
|
-
<Card border padding={3}>
|
|
72
|
-
<Text>
|
|
73
|
-
This is the <strong>Baz</strong> panel
|
|
74
|
-
</Text>
|
|
75
|
-
</Card>
|
|
76
|
-
</TabPanel>
|
|
77
|
-
</Box>
|
|
78
|
-
)
|
|
79
|
-
}
|