@sanity/ui 4.0.0-beta.8 → 4.0.0-next.0
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/LICENSE +1 -1
- package/README.md +21 -7
- package/dist/_chunks/getScopedTheme.cjs +4043 -0
- package/dist/_chunks/getScopedTheme.cjs.map +1 -0
- package/dist/_chunks/getScopedTheme.js +3803 -0
- package/dist/_chunks/getScopedTheme.js.map +1 -0
- package/dist/_chunks/portalProvider.cjs +3750 -0
- package/dist/_chunks/portalProvider.cjs.map +1 -0
- package/dist/_chunks/portalProvider.d.cts +1067 -0
- package/dist/_chunks/portalProvider.d.cts.map +1 -0
- package/dist/_chunks/portalProvider.d.ts +1067 -0
- package/dist/_chunks/portalProvider.d.ts.map +1 -0
- package/dist/_chunks/portalProvider.js +3300 -0
- package/dist/_chunks/portalProvider.js.map +1 -0
- package/dist/_chunks/refractor.cjs +18 -0
- package/dist/_chunks/refractor.cjs.map +1 -0
- package/dist/_chunks/refractor.js +20 -0
- package/dist/_chunks/refractor.js.map +1 -0
- package/dist/_chunks/rgba.d.cts +929 -0
- package/dist/_chunks/rgba.d.cts.map +1 -0
- package/dist/_chunks/rgba.d.ts +929 -0
- package/dist/_chunks/rgba.d.ts.map +1 -0
- package/dist/_visual-editing.cjs +4 -0
- package/dist/_visual-editing.d.cts +2 -0
- package/dist/_visual-editing.d.ts +2 -0
- package/dist/_visual-editing.js +3 -0
- package/dist/index.cjs +3007 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1275 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +708 -1188
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2964 -4783
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs +54 -0
- package/dist/theme.cjs.map +1 -0
- package/dist/theme.d.cts +278 -0
- package/dist/theme.d.cts.map +1 -0
- package/dist/theme.d.ts +278 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +53 -0
- package/dist/theme.js.map +1 -0
- package/package.json +65 -88
- package/dist/_chunks-es/Syntax.js +0 -23
- package/dist/_chunks-es/Syntax.js.map +0 -1
- package/dist/index.css +0 -1
- package/exports/index.css +0 -1
- package/exports/index.ts +0 -125
- package/src/components/autocomplete/Autocomplete.tsx +0 -665
- package/src/components/autocomplete/AutocompleteOption.tsx +0 -42
- package/src/components/autocomplete/__workshop__/Async.tsx +0 -162
- package/src/components/autocomplete/__workshop__/ConstrainedHeight.tsx +0 -121
- package/src/components/autocomplete/__workshop__/Custom.tsx +0 -91
- package/src/components/autocomplete/__workshop__/Example.tsx +0 -70
- package/src/components/autocomplete/__workshop__/FocusAndBlur.tsx +0 -39
- package/src/components/autocomplete/__workshop__/Fullscreen.tsx +0 -307
- package/src/components/autocomplete/__workshop__/index.ts +0 -41
- package/src/components/autocomplete/__workshop__/mock/apiStore.ts +0 -49
- package/src/components/autocomplete/__workshop__/mock/countries.ts +0 -245
- package/src/components/autocomplete/__workshop__/types.ts +0 -4
- package/src/components/autocomplete/autocompleteReducer.ts +0 -47
- package/src/components/autocomplete/constants.ts +0 -28
- package/src/components/autocomplete/types.ts +0 -103
- package/src/components/breadcrumbs/Breadcrumbs.tsx +0 -163
- package/src/components/breadcrumbs/__workshop__/Example.tsx +0 -48
- package/src/components/breadcrumbs/__workshop__/index.ts +0 -16
- package/src/components/dialog/Dialog.tsx +0 -230
- package/src/components/dialog/DialogCard.tsx +0 -233
- package/src/components/dialog/DialogContext.ts +0 -21
- package/src/components/dialog/DialogProvider.tsx +0 -34
- package/src/components/dialog/__workshop__/Activate.tsx +0 -141
- package/src/components/dialog/__workshop__/AutoFocus.tsx +0 -29
- package/src/components/dialog/__workshop__/Layering.tsx +0 -41
- package/src/components/dialog/__workshop__/Nested.tsx +0 -71
- package/src/components/dialog/__workshop__/OnScroll.tsx +0 -51
- package/src/components/dialog/__workshop__/Panes.tsx +0 -75
- package/src/components/dialog/__workshop__/Position.tsx +0 -30
- package/src/components/dialog/__workshop__/Props.tsx +0 -93
- package/src/components/dialog/__workshop__/Provider.tsx +0 -11
- package/src/components/dialog/__workshop__/Wrapped.tsx +0 -76
- package/src/components/dialog/__workshop__/index.ts +0 -21
- package/src/components/dialog/isTargetWithinScope.ts +0 -14
- package/src/components/dialog/types.ts +0 -2
- package/src/components/dialog/useDialog.ts +0 -11
- package/src/components/hotkeys/Hotkeys.tsx +0 -70
- package/src/components/hotkeys/__workshop__/Plain.tsx +0 -9
- package/src/components/hotkeys/__workshop__/index.ts +0 -16
- package/src/components/menu/Menu.test.tsx +0 -125
- package/src/components/menu/Menu.tsx +0 -174
- package/src/components/menu/MenuButton.tsx +0 -231
- package/src/components/menu/MenuContext.ts +0 -19
- package/src/components/menu/MenuDivider.tsx +0 -32
- package/src/components/menu/MenuGroup.tsx +0 -240
- package/src/components/menu/MenuItem.tsx +0 -153
- package/src/components/menu/__workshop__/AsComponent.tsx +0 -45
- package/src/components/menu/__workshop__/AvatarMenu.tsx +0 -36
- package/src/components/menu/__workshop__/ClosableMenuButton.tsx +0 -47
- package/src/components/menu/__workshop__/ConstrainedInBoundary.tsx +0 -133
- package/src/components/menu/__workshop__/CustomMenuItem.tsx +0 -47
- package/src/components/menu/__workshop__/CustomSelectedState.tsx +0 -35
- package/src/components/menu/__workshop__/DataProps.tsx +0 -27
- package/src/components/menu/__workshop__/DisableFocusOnClose.tsx +0 -40
- package/src/components/menu/__workshop__/Groups.tsx +0 -164
- package/src/components/menu/__workshop__/MenuButton.tsx +0 -79
- package/src/components/menu/__workshop__/MenuGroupRight.tsx +0 -73
- package/src/components/menu/__workshop__/NestedMenu.tsx +0 -22
- package/src/components/menu/__workshop__/OnCloseMenuButton.tsx +0 -50
- package/src/components/menu/__workshop__/SelectedItem.tsx +0 -69
- package/src/components/menu/__workshop__/ShouldFocus.tsx +0 -42
- package/src/components/menu/__workshop__/Tones.tsx +0 -19
- package/src/components/menu/__workshop__/index.ts +0 -91
- package/src/components/menu/helpers.ts +0 -82
- package/src/components/menu/useMenu.ts +0 -21
- package/src/components/menu/useMenuController.ts +0 -245
- package/src/components/tab/Tab.tsx +0 -135
- package/src/components/tab/TabList.tsx +0 -157
- package/src/components/tab/TabListContext.ts +0 -10
- package/src/components/tab/TabPanel.tsx +0 -94
- package/src/components/tab/__workshop__/Example.tsx +0 -135
- package/src/components/tab/__workshop__/index.ts +0 -16
- package/src/components/tab/types.ts +0 -11
- package/src/components/toast/Toast.test.tsx +0 -103
- package/src/components/toast/Toast.tsx +0 -191
- package/src/components/toast/ToastContext.ts +0 -7
- package/src/components/toast/ToastLayer.tsx +0 -54
- package/src/components/toast/ToastProvider.tsx +0 -127
- package/src/components/toast/__workshop__/Hook.tsx +0 -71
- package/src/components/toast/__workshop__/Toast.tsx +0 -26
- package/src/components/toast/__workshop__/index.ts +0 -21
- package/src/components/toast/toastState.ts +0 -6
- package/src/components/toast/types.ts +0 -24
- package/src/components/toast/useToast.ts +0 -23
- package/src/components/tree/Tree.tsx +0 -248
- package/src/components/tree/TreeContext.ts +0 -10
- package/src/components/tree/TreeGroup.tsx +0 -46
- package/src/components/tree/TreeItem.tsx +0 -236
- package/src/components/tree/__workshop__/Basic.tsx +0 -108
- package/src/components/tree/__workshop__/TabFromElement.tsx +0 -84
- package/src/components/tree/__workshop__/basic.perf.ts +0 -19
- package/src/components/tree/__workshop__/index.ts +0 -23
- package/src/components/tree/helpers.ts +0 -105
- package/src/components/tree/types.ts +0 -24
- package/src/components/tree/useTree.ts +0 -17
- package/src/components/virtualList/VirtualList.tsx +0 -254
- package/src/components/virtualList/__workshop__/ChangingProps.tsx +0 -41
- package/src/components/virtualList/__workshop__/ElementScroll.tsx +0 -43
- package/src/components/virtualList/__workshop__/InfiniteList.tsx +0 -40
- package/src/components/virtualList/__workshop__/WindowScrolll.tsx +0 -23
- package/src/components/virtualList/__workshop__/index.ts +0 -31
- package/src/core/_keys.ts +0 -26
- package/src/core/constants.ts +0 -67
- package/src/core/getElementRef.ts +0 -29
- package/src/core/helpers/animation.ts +0 -26
- package/src/core/helpers/element.ts +0 -55
- package/src/core/helpers/focus.ts +0 -92
- package/src/core/helpers/props.ts +0 -51
- package/src/core/helpers/scroll.ts +0 -15
- package/src/core/lib/createGlobalScopedContext.ts +0 -39
- package/src/core/lib/globalScope.ts +0 -19
- package/src/core/lib/isArray.ts +0 -3
- package/src/core/lib/isRecord.ts +0 -3
- package/src/core/types.ts +0 -57
- package/src/hooks/useClickOutsideEvent.test.tsx +0 -114
- package/src/hooks/useClickOutsideEvent.ts +0 -66
- package/src/hooks/useCustomValidity.ts +0 -13
- package/src/hooks/useElementSize.ts +0 -19
- package/src/hooks/useGlobalKeyDown.ts +0 -23
- package/src/hooks/useMatchMedia.ts +0 -28
- package/src/hooks/useMediaIndex/__workshop__/Test.tsx +0 -14
- package/src/hooks/useMediaIndex/__workshop__/index.ts +0 -16
- package/src/hooks/useMediaIndex/useMediaIndex.test.tsx +0 -21
- package/src/hooks/useMediaIndex/useMediaIndex.ts +0 -111
- package/src/hooks/useMounted.ts +0 -15
- package/src/hooks/usePrefersDark.hydration.test.tsx +0 -56
- package/src/hooks/usePrefersDark.test.tsx +0 -20
- package/src/hooks/usePrefersDark.ts +0 -16
- package/src/hooks/usePrefersReducedMotion.hydration.test.tsx +0 -56
- package/src/hooks/usePrefersReducedMotion.test.tsx +0 -20
- package/src/hooks/usePrefersReducedMotion.ts +0 -16
- package/src/hooks/useResponsiveProp.ts +0 -14
- package/src/hooks/useUnique.ts +0 -54
- package/src/middleware/origin.ts +0 -47
- package/src/observers/elementSize.ts +0 -114
- package/src/primitives/_syntax/LazySyntax.tsx +0 -4
- package/src/primitives/_syntax/Syntax.tsx +0 -26
- package/src/primitives/avatar/Avatar.tsx +0 -145
- package/src/primitives/avatar/AvatarCounter.tsx +0 -69
- package/src/primitives/avatar/AvatarStack.tsx +0 -77
- package/src/primitives/avatar/__workshop__/AsButton.tsx +0 -12
- package/src/primitives/avatar/__workshop__/PropsStory.tsx +0 -24
- package/src/primitives/avatar/__workshop__/Stack.tsx +0 -27
- package/src/primitives/avatar/__workshop__/WithinButton.tsx +0 -51
- package/src/primitives/avatar/__workshop__/WithinMenuItem.tsx +0 -52
- package/src/primitives/avatar/__workshop__/index.ts +0 -36
- package/src/primitives/avatar/types.ts +0 -2
- package/src/primitives/badge/Badge.test.tsx +0 -16
- package/src/primitives/badge/Badge.tsx +0 -53
- package/src/primitives/badge/__workshop__/Props.tsx +0 -27
- package/src/primitives/badge/__workshop__/Tones.tsx +0 -15
- package/src/primitives/badge/__workshop__/index.ts +0 -26
- package/src/primitives/badge/__workshop__/within-button.tsx +0 -36
- package/src/primitives/box/Box.tsx +0 -73
- package/src/primitives/box/__workshop__/Props.tsx +0 -26
- package/src/primitives/box/__workshop__/Responsive.tsx +0 -19
- package/src/primitives/box/__workshop__/index.ts +0 -21
- package/src/primitives/button/Button.test.tsx +0 -30
- package/src/primitives/button/Button.tsx +0 -148
- package/src/primitives/button/__workshop__/Custom.tsx +0 -39
- package/src/primitives/button/__workshop__/CustomIcons.tsx +0 -37
- package/src/primitives/button/__workshop__/DataProps.tsx +0 -18
- package/src/primitives/button/__workshop__/Disabled.tsx +0 -43
- package/src/primitives/button/__workshop__/MixedChildren.tsx +0 -12
- package/src/primitives/button/__workshop__/Props.tsx +0 -60
- package/src/primitives/button/__workshop__/Stacked.tsx +0 -60
- package/src/primitives/button/__workshop__/Styled1.css.ts +0 -7
- package/src/primitives/button/__workshop__/Styled1.tsx +0 -11
- package/src/primitives/button/__workshop__/TextOverflow.tsx +0 -17
- package/src/primitives/button/__workshop__/UploadButton.tsx +0 -28
- package/src/primitives/button/__workshop__/index.ts +0 -61
- package/src/primitives/button/types.ts +0 -2
- package/src/primitives/card/Card.tsx +0 -124
- package/src/primitives/card/CardContext.ts +0 -10
- package/src/primitives/card/CardInternalContext.ts +0 -10
- package/src/primitives/card/CardInternalProvider.tsx +0 -15
- package/src/primitives/card/CardProvider.tsx +0 -16
- package/src/primitives/card/__workshop__/AsButton.tsx +0 -103
- package/src/primitives/card/__workshop__/AsComponent.tsx +0 -25
- package/src/primitives/card/__workshop__/Checkered.tsx +0 -25
- package/src/primitives/card/__workshop__/DataProps.tsx +0 -25
- package/src/primitives/card/__workshop__/Interactive.tsx +0 -29
- package/src/primitives/card/__workshop__/ListNavigation.tsx +0 -78
- package/src/primitives/card/__workshop__/Props.tsx +0 -59
- package/src/primitives/card/__workshop__/Selected.tsx +0 -62
- package/src/primitives/card/__workshop__/Styled.tsx +0 -11
- package/src/primitives/card/__workshop__/Tones.tsx +0 -26
- package/src/primitives/card/__workshop__/index.ts +0 -21
- package/src/primitives/card/types.ts +0 -21
- package/src/primitives/card/useCard.ts +0 -20
- package/src/primitives/checkbox/Checkbox.tsx +0 -80
- package/src/primitives/checkbox/__workshop__/Example.tsx +0 -25
- package/src/primitives/checkbox/__workshop__/Props.tsx +0 -35
- package/src/primitives/checkbox/__workshop__/ReadOnly.tsx +0 -16
- package/src/primitives/checkbox/__workshop__/Tones.tsx +0 -26
- package/src/primitives/checkbox/__workshop__/index.ts +0 -15
- package/src/primitives/code/Code.tsx +0 -47
- package/src/primitives/code/__workshop__/OpticalAlignment.tsx +0 -25
- package/src/primitives/code/__workshop__/Props.tsx +0 -20
- package/src/primitives/code/__workshop__/index.ts +0 -21
- package/src/primitives/container/Container.tsx +0 -43
- package/src/primitives/container/__workshop__/Example.tsx +0 -16
- package/src/primitives/container/__workshop__/index.ts +0 -16
- package/src/primitives/container/types.ts +0 -6
- package/src/primitives/flex/Flex.tsx +0 -38
- package/src/primitives/flex/__workshop__/Example.tsx +0 -26
- package/src/primitives/flex/__workshop__/Gap.tsx +0 -25
- package/src/primitives/flex/__workshop__/index.ts +0 -13
- package/src/primitives/flex/__workshop__/styles.css.ts +0 -12
- package/src/primitives/grid/Grid.tsx +0 -38
- package/src/primitives/grid/__workshop__/Responsive.tsx +0 -54
- package/src/primitives/grid/__workshop__/index.ts +0 -12
- package/src/primitives/heading/Heading.tsx +0 -68
- package/src/primitives/heading/__workshop__/OpticalAlignment.tsx +0 -27
- package/src/primitives/heading/__workshop__/Plain.tsx +0 -25
- package/src/primitives/heading/__workshop__/index.ts +0 -21
- package/src/primitives/inline/Inline.tsx +0 -37
- package/src/primitives/inline/__workshop__/Plain.tsx +0 -22
- package/src/primitives/inline/__workshop__/index.ts +0 -10
- package/src/primitives/kbd/Kbd.tsx +0 -36
- package/src/primitives/kbd/__workshop__/Plain.tsx +0 -9
- package/src/primitives/kbd/__workshop__/index.ts +0 -10
- package/src/primitives/label/Label.tsx +0 -67
- package/src/primitives/label/__workshop__/OpticalAlignment.tsx +0 -27
- package/src/primitives/label/__workshop__/Plain.tsx +0 -27
- package/src/primitives/label/__workshop__/index.ts +0 -21
- package/src/primitives/layer/Layer.test.tsx +0 -110
- package/src/primitives/layer/Layer.tsx +0 -35
- package/src/primitives/layer/LayerCard.tsx +0 -90
- package/src/primitives/layer/LayerContext.ts +0 -7
- package/src/primitives/layer/LayerProvider.tsx +0 -106
- package/src/primitives/layer/__workshop__/MultipleRoots.tsx +0 -49
- package/src/primitives/layer/__workshop__/Nested.tsx +0 -107
- package/src/primitives/layer/__workshop__/ResponsiveZOffset.tsx +0 -17
- package/src/primitives/layer/__workshop__/_debug.tsx +0 -17
- package/src/primitives/layer/__workshop__/index.ts +0 -26
- package/src/primitives/layer/getLayerContext.test.ts +0 -32
- package/src/primitives/layer/getLayerContext.ts +0 -21
- package/src/primitives/layer/types.ts +0 -9
- package/src/primitives/layer/useLayer.ts +0 -24
- package/src/primitives/popover/Popover.tsx +0 -291
- package/src/primitives/popover/PopoverLayer.tsx +0 -101
- package/src/primitives/popover/__workshop__/AlignedStory.tsx +0 -75
- package/src/primitives/popover/__workshop__/MarginsStory.tsx +0 -31
- package/src/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +0 -32
- package/src/primitives/popover/__workshop__/OpenOnMountStory.tsx +0 -11
- package/src/primitives/popover/__workshop__/PlainStory.tsx +0 -67
- package/src/primitives/popover/__workshop__/RecursiveStory.tsx +0 -71
- package/src/primitives/popover/__workshop__/SidePanelStory.tsx +0 -95
- package/src/primitives/popover/__workshop__/TestStory.tsx +0 -97
- package/src/primitives/popover/__workshop__/index.ts +0 -56
- package/src/primitives/popover/__workshop__/portal-inheritance.tsx +0 -15
- package/src/primitives/popover/constants.ts +0 -20
- package/src/primitives/popover/floating-ui/size.ts +0 -75
- package/src/primitives/popover/types.ts +0 -12
- package/src/primitives/popover/useMiddleware.ts +0 -126
- package/src/primitives/radio/Radio.tsx +0 -64
- package/src/primitives/radio/__workshop__/Example.tsx +0 -63
- package/src/primitives/radio/__workshop__/Plain.tsx +0 -28
- package/src/primitives/radio/__workshop__/index.ts +0 -13
- package/src/primitives/select/Select.tsx +0 -76
- package/src/primitives/select/__workshop__/Plain.tsx +0 -37
- package/src/primitives/select/__workshop__/ReadOnly.tsx +0 -23
- package/src/primitives/select/__workshop__/index.ts +0 -13
- package/src/primitives/selectable/Selectable.tsx +0 -48
- package/src/primitives/selectable/__workshop__/DataProps.tsx +0 -24
- package/src/primitives/selectable/__workshop__/as-link.tsx +0 -13
- package/src/primitives/selectable/__workshop__/index.ts +0 -19
- package/src/primitives/skeleton/CodeSkeleton.tsx +0 -49
- package/src/primitives/skeleton/HeadingSkeleton.tsx +0 -48
- package/src/primitives/skeleton/LabelSkeleton.tsx +0 -47
- package/src/primitives/skeleton/Skeleton.tsx +0 -70
- package/src/primitives/skeleton/TextSkeleton.tsx +0 -49
- package/src/primitives/skeleton/__workshop__/Delay.tsx +0 -69
- package/src/primitives/skeleton/__workshop__/Skeleton.tsx +0 -63
- package/src/primitives/skeleton/__workshop__/index.ts +0 -13
- package/src/primitives/spinner/Spinner.tsx +0 -45
- package/src/primitives/spinner/SpinnerAnimatedIcon.tsx +0 -14
- package/src/primitives/spinner/__workshop__/Props.tsx +0 -13
- package/src/primitives/spinner/__workshop__/index.ts +0 -16
- package/src/primitives/srOnly/SrOnly.tsx +0 -33
- package/src/primitives/stack/Stack.tsx +0 -38
- package/src/primitives/stack/__workshop__/Plain.tsx +0 -30
- package/src/primitives/stack/__workshop__/index.ts +0 -16
- package/src/primitives/switch/Switch.tsx +0 -76
- package/src/primitives/switch/__workshop__/Example.tsx +0 -25
- package/src/primitives/switch/__workshop__/Props.tsx +0 -23
- package/src/primitives/switch/__workshop__/index.ts +0 -13
- package/src/primitives/text/InlineCode.tsx +0 -25
- package/src/primitives/text/Text.tsx +0 -68
- package/src/primitives/text/__workshop__/Example.tsx +0 -26
- package/src/primitives/text/__workshop__/OpticalAlignment.tsx +0 -27
- package/src/primitives/text/__workshop__/index.ts +0 -26
- package/src/primitives/text/__workshop__/inline-code.tsx +0 -13
- package/src/primitives/textArea/TextArea.tsx +0 -97
- package/src/primitives/textArea/__workshop__/Plain.tsx +0 -46
- package/src/primitives/textArea/__workshop__/index.ts +0 -16
- package/src/primitives/textInput/TextInput.tsx +0 -279
- package/src/primitives/textInput/__workshop__/ClearButton.tsx +0 -32
- package/src/primitives/textInput/__workshop__/CustomValidity.tsx +0 -17
- package/src/primitives/textInput/__workshop__/Plain.tsx +0 -102
- package/src/primitives/textInput/__workshop__/ReadOnly.tsx +0 -14
- package/src/primitives/textInput/__workshop__/States.tsx +0 -53
- package/src/primitives/textInput/__workshop__/Tones.tsx +0 -40
- package/src/primitives/textInput/__workshop__/Typed.tsx +0 -23
- package/src/primitives/textInput/__workshop__/index.ts +0 -46
- package/src/primitives/tooltip/Tooltip.test.tsx +0 -496
- package/src/primitives/tooltip/Tooltip.tsx +0 -546
- package/src/primitives/tooltip/TooltipLayer.tsx +0 -72
- package/src/primitives/tooltip/__workshop__/CustomPortal.tsx +0 -102
- package/src/primitives/tooltip/__workshop__/OverflowingBoundary.tsx +0 -74
- package/src/primitives/tooltip/__workshop__/Props.tsx +0 -107
- package/src/primitives/tooltip/__workshop__/ResizableBoundary.tsx +0 -91
- package/src/primitives/tooltip/__workshop__/index.ts +0 -31
- package/src/primitives/tooltip/constants.ts +0 -24
- package/src/primitives/tooltip/tooltipDelayGroup/TooltipDelayGroupContext.tsx +0 -13
- package/src/primitives/tooltip/tooltipDelayGroup/TooltipDelayGroupProvider.tsx +0 -96
- package/src/primitives/tooltip/tooltipDelayGroup/types.ts +0 -7
- package/src/primitives/tooltip/tooltipDelayGroup/useTooltipDelayGroup.ts +0 -13
- package/src/root/Root.tsx +0 -93
- package/src/root/RootProvider.tsx +0 -37
- package/src/root/__workshop__/Boundary.tsx +0 -43
- package/src/root/__workshop__/index.ts +0 -24
- package/src/root/__workshop__/primitives.tsx +0 -49
- package/src/root/__workshop__/tone-inheritance.tsx +0 -65
- package/src/utils/ErrorBoundary.tsx +0 -50
- package/src/utils/boundaryElement/BoundaryElementContext.ts +0 -7
- package/src/utils/boundaryElement/BoundaryElementProvider.tsx +0 -16
- package/src/utils/boundaryElement/__workshop__/Plain.tsx +0 -49
- package/src/utils/boundaryElement/__workshop__/index.ts +0 -16
- package/src/utils/boundaryElement/types.ts +0 -2
- package/src/utils/boundaryElement/useBoundaryElement.ts +0 -12
- package/src/utils/elementQuery/ElementQuery.tsx +0 -75
- package/src/utils/elementQuery/__workshop__/CustomMedia.tsx +0 -19
- package/src/utils/elementQuery/__workshop__/index.ts +0 -16
- package/src/utils/elementQuery/__workshop__/styles.css.ts +0 -31
- package/src/utils/elementQuery/helpers.ts +0 -27
- package/src/utils/portal/Portal.test.tsx +0 -105
- package/src/utils/portal/Portal.tsx +0 -42
- package/src/utils/portal/PortalContext.ts +0 -37
- package/src/utils/portal/PortalProvider.tsx +0 -38
- package/src/utils/portal/__workshop__/Named.tsx +0 -69
- package/src/utils/portal/__workshop__/index.ts +0 -16
- package/src/utils/portal/types.ts +0 -7
- package/src/utils/portal/usePortal.ts +0 -30
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import {box, BOX_STYLE_PROP_KEYS, type BoxStyleProps} from '@sanity/ui-css'
|
|
2
|
-
|
|
3
|
-
import {_splitKeys} from '../../core/_keys'
|
|
4
|
-
import type {ComponentType, Props} from '../../core/types'
|
|
5
|
-
|
|
6
|
-
/** @public */
|
|
7
|
-
export const DEFAULT_BOX_ELEMENT = 'div'
|
|
8
|
-
|
|
9
|
-
/** @public */
|
|
10
|
-
export type BoxOwnProps = BoxStyleProps
|
|
11
|
-
|
|
12
|
-
/** @public */
|
|
13
|
-
export type BoxElementType =
|
|
14
|
-
| 'a'
|
|
15
|
-
| 'article'
|
|
16
|
-
| 'aside'
|
|
17
|
-
| 'blockquote'
|
|
18
|
-
| 'body'
|
|
19
|
-
| 'button'
|
|
20
|
-
| 'details'
|
|
21
|
-
| 'div'
|
|
22
|
-
| 'header'
|
|
23
|
-
| 'fieldset'
|
|
24
|
-
| 'figure'
|
|
25
|
-
| 'figcaption'
|
|
26
|
-
| 'footer'
|
|
27
|
-
| 'form'
|
|
28
|
-
| 'html'
|
|
29
|
-
| 'iframe'
|
|
30
|
-
| 'kbd'
|
|
31
|
-
| 'label'
|
|
32
|
-
| 'legend'
|
|
33
|
-
| 'li'
|
|
34
|
-
| 'main'
|
|
35
|
-
| 'nav'
|
|
36
|
-
| 'ol'
|
|
37
|
-
| 'pre'
|
|
38
|
-
| 'section'
|
|
39
|
-
| 'span'
|
|
40
|
-
| 'summary'
|
|
41
|
-
| 'table'
|
|
42
|
-
| 'tbody'
|
|
43
|
-
| 'td'
|
|
44
|
-
| 'tfoot'
|
|
45
|
-
| 'th'
|
|
46
|
-
| 'thead'
|
|
47
|
-
| 'tr'
|
|
48
|
-
| 'ul'
|
|
49
|
-
| ComponentType
|
|
50
|
-
|
|
51
|
-
/** @public */
|
|
52
|
-
export type BoxProps<E extends BoxElementType = BoxElementType> = Props<BoxOwnProps, E>
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* The `Box` component is a basic layout wrapper component which provides utility properties
|
|
56
|
-
* for flex, margins and padding.
|
|
57
|
-
*
|
|
58
|
-
* @public
|
|
59
|
-
*/
|
|
60
|
-
export function Box<E extends BoxElementType = typeof DEFAULT_BOX_ELEMENT>(
|
|
61
|
-
props: BoxProps<E>,
|
|
62
|
-
): React.JSX.Element {
|
|
63
|
-
const [
|
|
64
|
-
styleProps,
|
|
65
|
-
{
|
|
66
|
-
as: Element = DEFAULT_BOX_ELEMENT,
|
|
67
|
-
// split DOM props
|
|
68
|
-
...domProps
|
|
69
|
-
},
|
|
70
|
-
] = _splitKeys(props as BoxProps<typeof DEFAULT_BOX_ELEMENT>, BOX_STYLE_PROP_KEYS)
|
|
71
|
-
|
|
72
|
-
return <Element data-ui="Box" {...domProps} className={box(styleProps)} />
|
|
73
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {Box, type BoxProps, Text} from '@sanity/ui'
|
|
2
|
-
import {BORDER_STYLE, BORDER_WIDTH, RADIUS, SHADOW, SPACE} from '@sanity/ui'
|
|
3
|
-
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
4
|
-
|
|
5
|
-
import {CardWrapper} from '$workshop'
|
|
6
|
-
|
|
7
|
-
export default function PropsStory(): React.JSX.Element {
|
|
8
|
-
const boxProps: BoxProps = {
|
|
9
|
-
border: useSelect('Border', BORDER_STYLE),
|
|
10
|
-
borderWidth: useSelect('Border Width', BORDER_WIDTH),
|
|
11
|
-
muted: useBoolean('Muted'),
|
|
12
|
-
padding: useSelect('Padding', SPACE),
|
|
13
|
-
radius: useSelect('Radius', RADIUS),
|
|
14
|
-
shadow: useSelect('Shadow', SHADOW),
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<CardWrapper>
|
|
19
|
-
<Box {...boxProps}>
|
|
20
|
-
<Text muted size={1}>
|
|
21
|
-
Text within box with props
|
|
22
|
-
</Text>
|
|
23
|
-
</Box>
|
|
24
|
-
</CardWrapper>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {Box, Text, vars} from '@sanity/ui'
|
|
2
|
-
|
|
3
|
-
export default function ResponsiveStory(): React.JSX.Element {
|
|
4
|
-
return (
|
|
5
|
-
<Box padding={[4, 5, 6]}>
|
|
6
|
-
<Box
|
|
7
|
-
display={['none', 'block', 'none', 'block', 'none', 'block', 'none']}
|
|
8
|
-
flex={[1, 2, 3, 4, 5, 6, 7]}
|
|
9
|
-
id="responsive-box"
|
|
10
|
-
padding={3}
|
|
11
|
-
style={{outline: `1px solid ${vars.color.border}`}}
|
|
12
|
-
>
|
|
13
|
-
<Text align="center" muted>
|
|
14
|
-
This is a box with responsive props
|
|
15
|
-
</Text>
|
|
16
|
-
</Box>
|
|
17
|
-
</Box>
|
|
18
|
-
)
|
|
19
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type {WorkshopScope} from '@sanity/ui-workshop'
|
|
2
|
-
import {lazy} from 'react'
|
|
3
|
-
|
|
4
|
-
const scope: WorkshopScope = {
|
|
5
|
-
name: 'primitives/box',
|
|
6
|
-
title: 'Box',
|
|
7
|
-
stories: [
|
|
8
|
-
{
|
|
9
|
-
name: 'props',
|
|
10
|
-
title: 'Props',
|
|
11
|
-
component: lazy(() => import('./Props')),
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
name: 'responsive',
|
|
15
|
-
title: 'Responsive',
|
|
16
|
-
component: lazy(() => import('./Responsive')),
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default scope
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {AddIcon} from '@sanity/icons'
|
|
2
|
-
import {screen} from '@testing-library/react'
|
|
3
|
-
import {describe, expect, it} from 'vitest'
|
|
4
|
-
import {axe} from 'vitest-axe'
|
|
5
|
-
|
|
6
|
-
import {render} from '$test/utils'
|
|
7
|
-
|
|
8
|
-
import {Button} from './Button'
|
|
9
|
-
|
|
10
|
-
describe('atoms/button', () => {
|
|
11
|
-
it('Axe: should have no violations', async () => {
|
|
12
|
-
const lightResult = render(<Button icon={AddIcon} text="Label" tone="positive" />, {
|
|
13
|
-
scheme: 'light',
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
expect(await axe(lightResult.container.outerHTML)).toHaveNoViolations()
|
|
17
|
-
|
|
18
|
-
const darkResult = render(<Button icon={AddIcon} text="Label" tone="positive" />, {
|
|
19
|
-
scheme: 'dark',
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
expect(await axe(darkResult.container.outerHTML)).toHaveNoViolations()
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
it('should render text', () => {
|
|
26
|
-
render(<Button text="Button text" />)
|
|
27
|
-
|
|
28
|
-
expect(screen.getByText('Button text')).toBeInTheDocument()
|
|
29
|
-
})
|
|
30
|
-
})
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
button,
|
|
3
|
-
button_loadingBox,
|
|
4
|
-
BUTTON_STYLE_PROP_KEYS,
|
|
5
|
-
type ButtonStyleProps,
|
|
6
|
-
type ResponsiveProp,
|
|
7
|
-
} from '@sanity/ui-css'
|
|
8
|
-
import type {FontTextSize} from '@sanity/ui-tokens'
|
|
9
|
-
import {isValidElement} from 'react'
|
|
10
|
-
import {isValidElementType} from 'react-is'
|
|
11
|
-
|
|
12
|
-
import {_splitKeys} from '../../core/_keys'
|
|
13
|
-
import type {ComponentType, Props} from '../../core/types'
|
|
14
|
-
import {Box} from '../box/Box'
|
|
15
|
-
import {Spinner} from '../spinner/Spinner'
|
|
16
|
-
import {Text, type TextOwnProps} from '../text/Text'
|
|
17
|
-
import {Tooltip, type TooltipProps} from '../tooltip/Tooltip'
|
|
18
|
-
|
|
19
|
-
/** @public */
|
|
20
|
-
export const DEFAULT_BUTTON_ELEMENT = 'button'
|
|
21
|
-
|
|
22
|
-
/** @public */
|
|
23
|
-
export interface ButtonOwnProps extends ButtonStyleProps {
|
|
24
|
-
'data-ui'?: string
|
|
25
|
-
'fontSize'?: ResponsiveProp<FontTextSize>
|
|
26
|
-
'icon'?: React.ElementType | React.ReactNode
|
|
27
|
-
'iconRight'?: React.ElementType | React.ReactNode
|
|
28
|
-
'loading'?: boolean
|
|
29
|
-
'muted'?: boolean
|
|
30
|
-
'pressed'?: boolean
|
|
31
|
-
/** @deprecated Use `pressed` instead. */
|
|
32
|
-
'selected'?: boolean
|
|
33
|
-
'textAlign'?: TextOwnProps['align']
|
|
34
|
-
'text'?: React.ReactNode
|
|
35
|
-
'textOverflow'?: TextOwnProps['textOverflow']
|
|
36
|
-
'textWeight'?: TextOwnProps['weight']
|
|
37
|
-
'tooltip'?: Omit<TooltipProps<'div'>, 'as' | 'children'>
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** @public */
|
|
41
|
-
export type ButtonElementType = 'a' | 'button' | 'label' | ComponentType
|
|
42
|
-
|
|
43
|
-
/** @public */
|
|
44
|
-
export type ButtonProps<E extends ButtonElementType = ButtonElementType> = Props<ButtonOwnProps, E>
|
|
45
|
-
|
|
46
|
-
/** @public */
|
|
47
|
-
export function Button<E extends ButtonElementType = typeof DEFAULT_BUTTON_ELEMENT>(
|
|
48
|
-
props: ButtonProps<E>,
|
|
49
|
-
): React.JSX.Element {
|
|
50
|
-
const [
|
|
51
|
-
styleProps,
|
|
52
|
-
{
|
|
53
|
-
as: Element = DEFAULT_BUTTON_ELEMENT,
|
|
54
|
-
children,
|
|
55
|
-
disabled,
|
|
56
|
-
fontSize = 1,
|
|
57
|
-
icon: Icon,
|
|
58
|
-
iconRight: IconRight,
|
|
59
|
-
loading,
|
|
60
|
-
muted,
|
|
61
|
-
pressed = props.selected,
|
|
62
|
-
// eslint-disable-next-line no-warning-comments
|
|
63
|
-
selected: _selected, // TODO: remove in next major version
|
|
64
|
-
text,
|
|
65
|
-
textAlign,
|
|
66
|
-
textOverflow = 'ellipsis',
|
|
67
|
-
textWeight = 'medium',
|
|
68
|
-
tooltip,
|
|
69
|
-
type = 'button',
|
|
70
|
-
// split DOM props
|
|
71
|
-
...domProps
|
|
72
|
-
},
|
|
73
|
-
] = _splitKeys(props as ButtonProps<typeof DEFAULT_BUTTON_ELEMENT>, BUTTON_STYLE_PROP_KEYS)
|
|
74
|
-
|
|
75
|
-
let href: string | undefined = undefined
|
|
76
|
-
|
|
77
|
-
if ('href' in domProps) {
|
|
78
|
-
href = typeof domProps.href === 'string' ? domProps.href : href
|
|
79
|
-
delete domProps.href
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const node = (
|
|
83
|
-
<Element
|
|
84
|
-
data-ui="Button"
|
|
85
|
-
{...domProps}
|
|
86
|
-
className={button(styleProps)}
|
|
87
|
-
data-disabled={loading || disabled ? '' : props['data-disabled']}
|
|
88
|
-
data-pressed={pressed ? '' : (props['data-pressed'] ?? props['data-selected'])}
|
|
89
|
-
disabled={Boolean(loading || disabled)}
|
|
90
|
-
// WORKAROUND: Since `a` elements don't support the `disabled` prop,
|
|
91
|
-
// we need to remove the `href` prop from the DOM props when the button is disabled.
|
|
92
|
-
// @ts-expect-error - the default element is a `button` and does not have the `href` prop
|
|
93
|
-
href={disabled ? undefined : href}
|
|
94
|
-
type={type}
|
|
95
|
-
>
|
|
96
|
-
{Boolean(loading) && (
|
|
97
|
-
<Box
|
|
98
|
-
alignItems="center"
|
|
99
|
-
as="span"
|
|
100
|
-
className={button_loadingBox()}
|
|
101
|
-
display="flex"
|
|
102
|
-
flex={1}
|
|
103
|
-
justifyContent="center"
|
|
104
|
-
width="fill"
|
|
105
|
-
>
|
|
106
|
-
<Spinner size={fontSize} />
|
|
107
|
-
</Box>
|
|
108
|
-
)}
|
|
109
|
-
|
|
110
|
-
{Icon && (
|
|
111
|
-
<Text as="span" flex="none" muted size={fontSize}>
|
|
112
|
-
{isValidElement(Icon) && Icon}
|
|
113
|
-
{isValidElementType(Icon) && <Icon />}
|
|
114
|
-
</Text>
|
|
115
|
-
)}
|
|
116
|
-
|
|
117
|
-
{text && (
|
|
118
|
-
<Box as="span" maxWidth="auto">
|
|
119
|
-
<Text
|
|
120
|
-
align={textAlign}
|
|
121
|
-
as="span"
|
|
122
|
-
muted={muted}
|
|
123
|
-
size={fontSize}
|
|
124
|
-
textOverflow={textOverflow}
|
|
125
|
-
weight={textWeight}
|
|
126
|
-
>
|
|
127
|
-
{text}
|
|
128
|
-
</Text>
|
|
129
|
-
</Box>
|
|
130
|
-
)}
|
|
131
|
-
|
|
132
|
-
{children}
|
|
133
|
-
|
|
134
|
-
{IconRight && (
|
|
135
|
-
<Text as="span" flex="none" muted size={fontSize}>
|
|
136
|
-
{isValidElement(IconRight) && IconRight}
|
|
137
|
-
{isValidElementType(IconRight) && <IconRight />}
|
|
138
|
-
</Text>
|
|
139
|
-
)}
|
|
140
|
-
</Element>
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
if (tooltip) {
|
|
144
|
-
return <Tooltip {...tooltip}>{node}</Tooltip>
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return node
|
|
148
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Avatar,
|
|
3
|
-
Badge,
|
|
4
|
-
Button,
|
|
5
|
-
BUTTON_MODES,
|
|
6
|
-
ELEMENT_TONES,
|
|
7
|
-
Flex,
|
|
8
|
-
Grid,
|
|
9
|
-
Hotkeys,
|
|
10
|
-
Stack,
|
|
11
|
-
Text,
|
|
12
|
-
} from '@sanity/ui'
|
|
13
|
-
|
|
14
|
-
export default function CustomStory(): React.JSX.Element {
|
|
15
|
-
return (
|
|
16
|
-
<Flex align="center" height="fill" justify="center" padding={4} sizing="border">
|
|
17
|
-
<Stack gap={2}>
|
|
18
|
-
{BUTTON_MODES.map((mode) => (
|
|
19
|
-
<Grid key={mode} gap={1} gridTemplateColumns={7}>
|
|
20
|
-
{ELEMENT_TONES.map((tone) => (
|
|
21
|
-
<Button key={tone} mode={mode} padding={3} tone={tone}>
|
|
22
|
-
<Stack gap={2}>
|
|
23
|
-
<Text>Text</Text>
|
|
24
|
-
<Text muted>Muted</Text>
|
|
25
|
-
<Text>
|
|
26
|
-
<code>Code</code>
|
|
27
|
-
</Text>
|
|
28
|
-
<Hotkeys keys={['mod', 'c']} />
|
|
29
|
-
<Avatar />
|
|
30
|
-
<Badge>Badge</Badge>
|
|
31
|
-
</Stack>
|
|
32
|
-
</Button>
|
|
33
|
-
))}
|
|
34
|
-
</Grid>
|
|
35
|
-
))}
|
|
36
|
-
</Stack>
|
|
37
|
-
</Flex>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {RocketIcon} from '@sanity/icons'
|
|
2
|
-
import {Button, BUTTON_MODES, Flex} from '@sanity/ui'
|
|
3
|
-
import {useSelect} from '@sanity/ui-workshop'
|
|
4
|
-
|
|
5
|
-
import {CardWrapper} from '$workshop'
|
|
6
|
-
|
|
7
|
-
export default function CustomIconsStory(): React.JSX.Element {
|
|
8
|
-
const mode = useSelect('Mode', BUTTON_MODES, 'default')
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<CardWrapper>
|
|
12
|
-
<Flex align="center" gap={2} height="fill" justify="center">
|
|
13
|
-
{/* <Inline gap={1}> */}
|
|
14
|
-
<Button fontSize={1} icon={RocketIcon} mode={mode} text="Rocket" />
|
|
15
|
-
<Button fontSize={1} icon={CustomIcon} mode={mode} text="Heart" />
|
|
16
|
-
{/* </Inline> */}
|
|
17
|
-
</Flex>
|
|
18
|
-
</CardWrapper>
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function CustomIcon() {
|
|
23
|
-
return (
|
|
24
|
-
<svg
|
|
25
|
-
fill="currentColor"
|
|
26
|
-
height="1em"
|
|
27
|
-
stroke="currentColor"
|
|
28
|
-
strokeWidth="0"
|
|
29
|
-
viewBox="0 0 24 24"
|
|
30
|
-
width="1em"
|
|
31
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
32
|
-
>
|
|
33
|
-
<path d="M0 0h24v24H0z" fill="none"></path>
|
|
34
|
-
<path d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55l-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z"></path>
|
|
35
|
-
</svg>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {Button, BUTTON_MODES, ELEMENT_TONES} from '@sanity/ui'
|
|
2
|
-
import {useSelect} from '@sanity/ui-workshop'
|
|
3
|
-
|
|
4
|
-
import {CardWrapper} from '$workshop'
|
|
5
|
-
|
|
6
|
-
export default function DataPropsStory(): React.JSX.Element {
|
|
7
|
-
const mode = useSelect('Mode', [undefined, ...BUTTON_MODES], 'default')
|
|
8
|
-
const tone = useSelect('Tone', [undefined, ...ELEMENT_TONES], 'default')
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<CardWrapper gap={3}>
|
|
12
|
-
<Button data-enabled="" mode={mode} text="Button" tone={tone} />
|
|
13
|
-
<Button data-hovered="" mode={mode} text="Button" tone={tone} />
|
|
14
|
-
<Button data-pressed="" mode={mode} text="Button" tone={tone} />
|
|
15
|
-
<Button data-selected="" mode={mode} text="Button" tone={tone} />
|
|
16
|
-
</CardWrapper>
|
|
17
|
-
)
|
|
18
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {ArrowLeftIcon, ArrowRightIcon} from '@sanity/icons'
|
|
2
|
-
import {Button, type ButtonProps, Stack, Text} from '@sanity/ui'
|
|
3
|
-
import {useBoolean} from '@sanity/ui-workshop'
|
|
4
|
-
|
|
5
|
-
import {CardWrapper} from '$workshop'
|
|
6
|
-
|
|
7
|
-
const sharedProps: ButtonProps<'button'> = {
|
|
8
|
-
icon: ArrowLeftIcon,
|
|
9
|
-
iconRight: ArrowRightIcon,
|
|
10
|
-
justify: 'space-between',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default function DisabledButtonStory(): React.JSX.Element {
|
|
14
|
-
const muted = useBoolean('Muted', false)
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<CardWrapper gap={5} width={0}>
|
|
18
|
-
<Stack gap={3}>
|
|
19
|
-
<Text size={1} weight="medium">
|
|
20
|
-
Default button
|
|
21
|
-
</Text>
|
|
22
|
-
<Button {...sharedProps} mode="default" muted={muted} text="Enabled" />
|
|
23
|
-
<Button {...sharedProps} disabled mode="default" muted={muted} text="Disabled" />
|
|
24
|
-
</Stack>
|
|
25
|
-
|
|
26
|
-
<Stack gap={3}>
|
|
27
|
-
<Text size={1} weight="medium">
|
|
28
|
-
Ghost button
|
|
29
|
-
</Text>
|
|
30
|
-
<Button {...sharedProps} mode="ghost" muted={muted} text="Enabled" />
|
|
31
|
-
<Button {...sharedProps} disabled mode="ghost" muted={muted} text="Disabled" />
|
|
32
|
-
</Stack>
|
|
33
|
-
|
|
34
|
-
<Stack gap={3}>
|
|
35
|
-
<Text size={1} weight="medium">
|
|
36
|
-
Bleed button
|
|
37
|
-
</Text>
|
|
38
|
-
<Button {...sharedProps} mode="bleed" muted={muted} text="Enabled" />
|
|
39
|
-
<Button {...sharedProps} disabled mode="bleed" muted={muted} text="Disabled" />
|
|
40
|
-
</Stack>
|
|
41
|
-
</CardWrapper>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {AddIcon} from '@sanity/icons'
|
|
2
|
-
import {Button, Flex} from '@sanity/ui'
|
|
3
|
-
|
|
4
|
-
export default function MixedChildrenStory(): React.JSX.Element {
|
|
5
|
-
return (
|
|
6
|
-
<Flex align="center" height="fill" justify="center">
|
|
7
|
-
<Button fontSize={[2, 2, 3]} icon={AddIcon} mode="ghost" padding={[3, 3, 4]} text="Create">
|
|
8
|
-
<span style={{display: 'none'}}>test</span>
|
|
9
|
-
</Button>
|
|
10
|
-
</Flex>
|
|
11
|
-
)
|
|
12
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {icons} from '@sanity/icons'
|
|
2
|
-
import {Button, Flex, type TooltipProps} from '@sanity/ui'
|
|
3
|
-
import {BUTTON_MODES, ELEMENT_TONES, FONT_TEXT_SIZE, FONT_WEIGHT, SPACE} from '@sanity/ui'
|
|
4
|
-
import {useAction, useBoolean, useSelect, useText} from '@sanity/ui-workshop'
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
CardWrapper,
|
|
8
|
-
WORKSHOP_BUTTON_TEXT_ALIGN_OPTIONS,
|
|
9
|
-
WORKSHOP_FLEX_JUSTIFY_OPTIONS,
|
|
10
|
-
WORKSHOP_ICON_SYMBOL_OPTIONS,
|
|
11
|
-
} from '$workshop'
|
|
12
|
-
|
|
13
|
-
export default function ButtonStory(): React.JSX.Element {
|
|
14
|
-
const disabled = useBoolean('Disabled')
|
|
15
|
-
const fontSize = useSelect('Font size', [undefined, ...FONT_TEXT_SIZE])
|
|
16
|
-
const gap = useSelect('Gap', [undefined, ...SPACE])
|
|
17
|
-
const icon = useSelect('Icon', WORKSHOP_ICON_SYMBOL_OPTIONS)
|
|
18
|
-
const iconRight = useSelect('Icon (right)', WORKSHOP_ICON_SYMBOL_OPTIONS)
|
|
19
|
-
const justify = useSelect('Justify', WORKSHOP_FLEX_JUSTIFY_OPTIONS)
|
|
20
|
-
const loading = useBoolean('Loading')
|
|
21
|
-
const mode = useSelect('Mode', [undefined, ...BUTTON_MODES])
|
|
22
|
-
const paddingX = useSelect('Padding X', [undefined, ...SPACE])
|
|
23
|
-
const paddingY = useSelect('Padding Y', [undefined, ...SPACE])
|
|
24
|
-
const selected = useBoolean('Selected')
|
|
25
|
-
const tone = useSelect('Tone', [undefined, ...ELEMENT_TONES])
|
|
26
|
-
const textAlign = useSelect('Text align', WORKSHOP_BUTTON_TEXT_ALIGN_OPTIONS)
|
|
27
|
-
const textProp = useText('Text', 'Text')
|
|
28
|
-
const textWeight = useSelect('Text weight', [undefined, ...FONT_WEIGHT])
|
|
29
|
-
const tooltip = useText('Tooltip text', 'Tooltip')
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<CardWrapper width={0}>
|
|
33
|
-
<Flex align="center" height="fill" justify="center">
|
|
34
|
-
<Button
|
|
35
|
-
disabled={disabled}
|
|
36
|
-
fontSize={fontSize}
|
|
37
|
-
gap={gap}
|
|
38
|
-
icon={icon && icons[icon]}
|
|
39
|
-
iconRight={iconRight && icons[iconRight]}
|
|
40
|
-
justify={justify}
|
|
41
|
-
loading={loading}
|
|
42
|
-
mode={mode}
|
|
43
|
-
paddingX={paddingX}
|
|
44
|
-
paddingY={paddingY}
|
|
45
|
-
selected={selected}
|
|
46
|
-
text={textProp}
|
|
47
|
-
textAlign={textAlign}
|
|
48
|
-
textWeight={textWeight}
|
|
49
|
-
tone={tone}
|
|
50
|
-
tooltip={
|
|
51
|
-
tooltip
|
|
52
|
-
? ({hotkeys: ['⌘', 'K'], id: 'test-button-tooltip', text: tooltip} as TooltipProps)
|
|
53
|
-
: undefined
|
|
54
|
-
}
|
|
55
|
-
onClick={useAction('onClick')}
|
|
56
|
-
/>
|
|
57
|
-
</Flex>
|
|
58
|
-
</CardWrapper>
|
|
59
|
-
)
|
|
60
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {icons} from '@sanity/icons'
|
|
2
|
-
import {
|
|
3
|
-
Box,
|
|
4
|
-
Button,
|
|
5
|
-
BUTTON_MODES,
|
|
6
|
-
Container,
|
|
7
|
-
ELEMENT_TONES,
|
|
8
|
-
Flex,
|
|
9
|
-
FONT_TEXT_SIZE,
|
|
10
|
-
SPACE,
|
|
11
|
-
Stack,
|
|
12
|
-
} from '@sanity/ui'
|
|
13
|
-
import {useAction, useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
14
|
-
|
|
15
|
-
import {CardWrapper, WORKSHOP_FLEX_JUSTIFY_OPTIONS, WORKSHOP_ICON_SYMBOL_OPTIONS} from '$workshop'
|
|
16
|
-
|
|
17
|
-
export default function StackedStory(): React.JSX.Element {
|
|
18
|
-
const disabled = useBoolean('Disabled', false)
|
|
19
|
-
const fontSize = useSelect('Font size', FONT_TEXT_SIZE)
|
|
20
|
-
const gap = useSelect('Gap', SPACE)
|
|
21
|
-
const icon = useSelect('Icon', WORKSHOP_ICON_SYMBOL_OPTIONS)
|
|
22
|
-
const iconRight = useSelect('Icon (right)', WORKSHOP_ICON_SYMBOL_OPTIONS)
|
|
23
|
-
const justify = useSelect('Justify', WORKSHOP_FLEX_JUSTIFY_OPTIONS)
|
|
24
|
-
const mode = useSelect('Mode', BUTTON_MODES)
|
|
25
|
-
const onClick = useAction('onClick')
|
|
26
|
-
const paddingX = useSelect('Padding X', SPACE)
|
|
27
|
-
const paddingY = useSelect('Padding Y', SPACE)
|
|
28
|
-
const selected = useBoolean('Selected', false)
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<CardWrapper>
|
|
32
|
-
<Flex align="center" height="fill" justify="center">
|
|
33
|
-
<Container style={{textAlign: 'center'}} width={0}>
|
|
34
|
-
<Box padding={4}>
|
|
35
|
-
<Stack gap={1}>
|
|
36
|
-
{ELEMENT_TONES.map((tone) => (
|
|
37
|
-
<Button
|
|
38
|
-
key={tone}
|
|
39
|
-
disabled={disabled}
|
|
40
|
-
fontSize={fontSize}
|
|
41
|
-
gap={gap}
|
|
42
|
-
icon={icon && icons[icon]}
|
|
43
|
-
iconRight={iconRight && icons[iconRight]}
|
|
44
|
-
justify={justify}
|
|
45
|
-
mode={mode}
|
|
46
|
-
paddingX={paddingX}
|
|
47
|
-
paddingY={paddingY}
|
|
48
|
-
selected={selected}
|
|
49
|
-
text={tone}
|
|
50
|
-
tone={tone}
|
|
51
|
-
onClick={onClick}
|
|
52
|
-
/>
|
|
53
|
-
))}
|
|
54
|
-
</Stack>
|
|
55
|
-
</Box>
|
|
56
|
-
</Container>
|
|
57
|
-
</Flex>
|
|
58
|
-
</CardWrapper>
|
|
59
|
-
)
|
|
60
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {Button, Flex} from '@sanity/ui'
|
|
2
|
-
|
|
3
|
-
import {styledButton1} from './Styled1.css'
|
|
4
|
-
|
|
5
|
-
export default function StyledButton1Story(): React.JSX.Element {
|
|
6
|
-
return (
|
|
7
|
-
<Flex align="center" height="fill" justify="center">
|
|
8
|
-
<Button as="a" className={styledButton1} href="#" text="Test" />
|
|
9
|
-
</Flex>
|
|
10
|
-
)
|
|
11
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {Button, Flex} from '@sanity/ui'
|
|
2
|
-
import {useText} from '@sanity/ui-workshop'
|
|
3
|
-
|
|
4
|
-
import {CardWrapper} from '$workshop'
|
|
5
|
-
|
|
6
|
-
export default function TextOverflowStory(): React.JSX.Element {
|
|
7
|
-
const text = useText('Text', 'Long text that should overflow')
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<CardWrapper gap={3} width={0}>
|
|
11
|
-
<Flex gap={2}>
|
|
12
|
-
<Button text={text} />
|
|
13
|
-
<Button flex="none" mode="bleed" text="Cancel" />
|
|
14
|
-
</Flex>
|
|
15
|
-
</CardWrapper>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {UploadIcon} from '@sanity/icons'
|
|
2
|
-
import {Button, Flex} from '@sanity/ui'
|
|
3
|
-
import {useCallback, useRef} from 'react'
|
|
4
|
-
|
|
5
|
-
export default function UploadButtonStory(): React.JSX.Element {
|
|
6
|
-
const inputRef = useRef<HTMLInputElement | null>(null)
|
|
7
|
-
|
|
8
|
-
const handleKeyDown = useCallback((event: React.KeyboardEvent) => {
|
|
9
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
10
|
-
inputRef.current?.click()
|
|
11
|
-
}
|
|
12
|
-
}, [])
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<Flex align="center" height="fill" justify="center">
|
|
16
|
-
<Button
|
|
17
|
-
as="label"
|
|
18
|
-
htmlFor="file"
|
|
19
|
-
icon={UploadIcon}
|
|
20
|
-
tabIndex={0}
|
|
21
|
-
text="Upload"
|
|
22
|
-
onKeyDown={handleKeyDown}
|
|
23
|
-
>
|
|
24
|
-
<input ref={inputRef} id="file" style={{display: 'none'}} type="file" />
|
|
25
|
-
</Button>
|
|
26
|
-
</Flex>
|
|
27
|
-
)
|
|
28
|
-
}
|