@sanity/ui 2.10.0-corel.0 → 3.0.0-static.1
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/bin/ui.js +6 -0
- package/dist/_chunks-cjs/buildCommand.js +3542 -0
- package/dist/_chunks-cjs/buildCommand.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +25 -0
- package/dist/cli.js.map +1 -0
- package/dist/css.d.mts +1062 -0
- package/dist/css.d.ts +1062 -0
- package/dist/css.esm.js +3794 -0
- package/dist/css.esm.js.map +1 -0
- package/dist/css.js +3794 -0
- package/dist/css.js.map +1 -0
- package/dist/css.mjs +3794 -0
- package/dist/css.mjs.map +1 -0
- package/dist/index.d.mts +240 -221
- package/dist/index.d.ts +240 -221
- package/dist/index.esm.js +3033 -4536
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3037 -4541
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3033 -4536
- package/dist/index.mjs.map +1 -1
- package/dist/sanity-theme.css +25 -0
- package/dist/system.css +3385 -0
- package/dist/theme.d.mts +84 -22
- package/dist/theme.d.ts +84 -22
- package/dist/theme.esm.js +1718 -656
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +1757 -693
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +1718 -656
- package/dist/theme.mjs.map +1 -1
- package/exports/css.ts +1 -0
- package/package.json +45 -24
- package/src/core/__workshop__/constants.ts +28 -19
- package/src/core/_compat/index.ts +2 -0
- package/src/core/{styles → _compat/styles}/border/borderStyle.ts +6 -0
- package/src/core/{styles → _compat/styles}/border/types.ts +1 -0
- package/src/core/{styles → _compat/styles}/box/boxStyle.ts +7 -1
- package/src/core/{styles → _compat/styles}/box/types.ts +1 -1
- package/src/core/{styles → _compat/styles}/card/_cardColorStyle.ts +2 -10
- package/src/core/{styles → _compat/styles}/flex/flexItemStyle.ts +1 -1
- package/src/core/{styles → _compat/styles}/flex/flexStyle.ts +0 -18
- package/src/core/{styles → _compat/styles}/flex/types.ts +1 -3
- package/src/core/{styles → _compat/styles}/font/types.ts +1 -1
- package/src/core/{styles → _compat/styles}/grid/gridStyle.ts +0 -10
- package/src/core/{styles → _compat/styles}/grid/types.ts +1 -1
- package/src/core/{styles → _compat/styles}/helpers.ts +10 -1
- package/src/core/{styles → _compat/styles}/input/textInputStyle.ts +2 -2
- package/src/core/{styles → _compat/styles}/radius/types.ts +1 -1
- package/src/core/{styles → _compat/styles}/shadow/shadowStyle.ts +1 -1
- package/src/core/components/autocomplete/__workshop__/custom.tsx +5 -4
- package/src/core/components/autocomplete/__workshop__/example.tsx +3 -2
- package/src/core/components/autocomplete/autocomplete.tsx +17 -9
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +1 -3
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -5
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +14 -9
- package/src/core/components/dialog/__workshop__/props.tsx +2 -0
- package/src/core/components/dialog/dialog.tsx +73 -92
- package/src/core/components/hotkeys/hotkeys.tsx +18 -29
- package/src/core/components/menu/menu.tsx +13 -12
- package/src/core/components/menu/menuDivider.tsx +16 -0
- package/src/core/components/menu/menuGroup.tsx +10 -8
- package/src/core/components/menu/menuItem.tsx +23 -14
- package/src/core/components/skeleton/skeleton.tsx +14 -20
- package/src/core/components/skeleton/textSkeleton.tsx +72 -48
- package/src/core/components/tab/tab.tsx +5 -7
- package/src/core/components/tab/tabList.tsx +5 -21
- package/src/core/components/tab/tabPanel.tsx +1 -0
- package/src/core/components/toast/toast.tsx +31 -16
- package/src/core/components/toast/toastProvider.tsx +23 -23
- package/src/core/components/tree/tree.tsx +7 -2
- package/src/core/components/tree/treeGroup.tsx +4 -1
- package/src/core/components/tree/treeItem.tsx +44 -35
- package/src/core/components/tree/types.ts +5 -1
- package/src/core/hooks/useArrayProp.ts +1 -1
- package/src/core/index.ts +0 -1
- package/src/core/lib/styled/elements.ts +135 -0
- package/src/core/lib/styled/index.ts +2 -0
- package/src/core/lib/styled/members.ts +15 -0
- package/src/core/lib/styled/styled.ts +79 -0
- package/src/core/primitives/_selectable/selectable.tsx +27 -14
- package/src/core/primitives/avatar/avatar.tsx +38 -39
- package/src/core/primitives/avatar/avatarCounter.tsx +2 -2
- package/src/core/primitives/avatar/avatarStack.tsx +2 -2
- package/src/core/primitives/avatar/styles.ts +2 -2
- package/src/core/primitives/badge/__workshop__/tones.tsx +9 -16
- package/src/core/primitives/badge/badge.tsx +18 -20
- package/src/core/primitives/box/box.tsx +65 -74
- package/src/core/primitives/button/__workshop__/props.tsx +5 -2
- package/src/core/primitives/button/__workshop__/stacked.tsx +2 -1
- package/src/core/primitives/button/button.tsx +38 -45
- package/src/core/primitives/button/styles.ts +5 -5
- package/src/core/primitives/card/RootCardContext.ts +3 -0
- package/src/core/primitives/card/__workshop__/props.tsx +2 -2
- package/src/core/primitives/card/card.tsx +37 -42
- package/src/core/primitives/checkbox/checkbox.tsx +6 -8
- package/src/core/primitives/code/code.tsx +22 -13
- package/src/core/primitives/code/styles.ts +1 -1
- package/src/core/primitives/container/container.tsx +7 -15
- package/src/core/primitives/container/styles.ts +1 -1
- package/src/core/primitives/flex/flex.tsx +6 -31
- package/src/core/primitives/grid/grid.tsx +6 -19
- package/src/core/primitives/heading/heading.tsx +24 -28
- package/src/core/primitives/heading/styles.ts +2 -2
- package/src/core/primitives/inline/inline.tsx +18 -18
- package/src/core/primitives/inline/styles.ts +1 -1
- package/src/core/primitives/kbd/kbd.tsx +30 -37
- package/src/core/primitives/label/label.tsx +15 -9
- package/src/core/primitives/label/styles.ts +2 -2
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +2 -2
- package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +0 -1
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +2 -1
- package/src/core/primitives/popover/popover.tsx +21 -15
- package/src/core/primitives/popover/popoverCard.tsx +36 -38
- package/src/core/primitives/radio/radio.tsx +1 -1
- package/src/core/primitives/radio/styles.ts +3 -3
- package/src/core/primitives/select/select.tsx +1 -1
- package/src/core/primitives/select/styles.ts +3 -3
- package/src/core/primitives/spinner/__workshop__/Props.tsx +2 -1
- package/src/core/primitives/spinner/animatedSpinnerIcon.tsx +16 -0
- package/src/core/primitives/spinner/spinner.tsx +8 -22
- package/src/core/primitives/stack/stack.tsx +12 -10
- package/src/core/primitives/stack/styles.ts +1 -1
- package/src/core/primitives/switch/styles.ts +11 -11
- package/src/core/primitives/switch/switch.tsx +20 -21
- package/src/core/primitives/text/styles.ts +2 -3
- package/src/core/primitives/text/text.tsx +18 -25
- package/src/core/primitives/textArea/__workshop__/plain.tsx +2 -2
- package/src/core/primitives/textArea/textArea.tsx +3 -3
- package/src/core/primitives/textInput/__workshop__/plain.tsx +4 -3
- package/src/core/primitives/textInput/textInput.tsx +111 -125
- package/src/core/primitives/tooltip/tooltip.test.tsx +1 -0
- package/src/core/primitives/tooltip/tooltip.tsx +13 -13
- package/src/core/primitives/tooltip/tooltipCard.tsx +15 -14
- package/src/core/primitives/types.ts +36 -16
- package/src/core/theme/__workshop__/build/story.tsx +2 -4
- package/src/core/theme/useTheme.ts +1 -1
- package/src/core/types/avatar.ts +6 -1
- package/src/core/types/box.ts +22 -16
- package/src/core/types/button.ts +1 -0
- package/src/core/types/flex.ts +27 -26
- package/src/core/types/grid.ts +17 -12
- package/src/core/types/gridItem.ts +32 -24
- package/src/core/types/radius.ts +7 -4
- package/src/core/types/text.ts +7 -4
- package/src/core/utils/arrow/arrow.tsx +1 -1
- package/src/core/utils/layer/layer.tsx +28 -11
- package/src/core/utils/srOnly/srOnly.tsx +1 -1
- package/src/core/utils/virtualList/virtualList.tsx +1 -1
- package/src/css/_resp.ts +28 -0
- package/src/css/cli/buildCommand.ts +36 -0
- package/src/css/cli/index.ts +38 -0
- package/src/css/compile/compileRule.ts +58 -0
- package/src/css/compile/compileRules.ts +56 -0
- package/src/css/compile/compileSystem.ts +7 -0
- package/src/css/compile/compileTheme.ts +512 -0
- package/src/css/components/breadcrumbs/breadcrumbs.ts +5 -0
- package/src/css/components/breadcrumbs/index.ts +1 -0
- package/src/css/components/breadcrumbs/rules.ts +25 -0
- package/src/css/components/dialog/classes.ts +29 -0
- package/src/css/components/dialog/index.ts +1 -0
- package/src/css/components/dialog/rules.ts +75 -0
- package/src/css/components/menu/index.ts +1 -0
- package/src/css/components/menu/menu.ts +5 -0
- package/src/css/components/menu/rules.ts +10 -0
- package/src/css/components/skeleton/index.ts +2 -0
- package/src/css/components/skeleton/rules.ts +106 -0
- package/src/css/components/skeleton/skeleton.ts +31 -0
- package/src/css/components/skeleton/types.ts +24 -0
- package/src/css/components/toast/rules.ts +68 -0
- package/src/css/components/tree/index.ts +1 -0
- package/src/css/components/tree/rules.ts +167 -0
- package/src/css/components/tree/tree.ts +5 -0
- package/src/css/composeClassNames.ts +3 -0
- package/src/css/index.ts +51 -0
- package/src/css/primitives/avatar/avatar.ts +32 -0
- package/src/css/primitives/avatar/index.ts +2 -0
- package/src/css/primitives/avatar/rules.ts +190 -0
- package/src/css/primitives/avatar/types.ts +9 -0
- package/src/css/primitives/badge/badge.ts +8 -0
- package/src/css/primitives/badge/index.ts +2 -0
- package/src/css/primitives/badge/rules.ts +25 -0
- package/src/css/primitives/badge/types.ts +8 -0
- package/src/css/primitives/box/box.ts +38 -0
- package/src/css/primitives/box/index.ts +2 -0
- package/src/css/primitives/box/rules.ts +25 -0
- package/src/css/primitives/box/types.ts +48 -0
- package/src/css/primitives/button/button.ts +26 -0
- package/src/css/primitives/button/index.ts +1 -0
- package/src/css/primitives/button/rules.ts +58 -0
- package/src/css/primitives/card/card.ts +21 -0
- package/src/css/primitives/card/index.ts +1 -0
- package/src/css/primitives/card/rules.ts +241 -0
- package/src/css/primitives/checkbox/__styles.ts +129 -0
- package/src/css/primitives/checkbox/checkbox.ts +9 -0
- package/src/css/primitives/checkbox/index.ts +1 -0
- package/src/css/primitives/checkbox/rules.ts +136 -0
- package/src/css/primitives/code/code.ts +9 -0
- package/src/css/primitives/code/index.ts +2 -0
- package/src/css/primitives/code/rules.ts +71 -0
- package/src/css/primitives/code/types.ts +10 -0
- package/src/css/primitives/container/container.ts +7 -0
- package/src/css/primitives/container/index.ts +2 -0
- package/src/css/primitives/container/rules.ts +8 -0
- package/src/css/primitives/container/types.ts +6 -0
- package/src/css/primitives/heading/heading.ts +16 -0
- package/src/css/primitives/heading/index.ts +2 -0
- package/src/css/primitives/heading/rules.ts +84 -0
- package/src/css/primitives/heading/types.ts +12 -0
- package/src/css/primitives/kbd/index.ts +2 -0
- package/src/css/primitives/kbd/kbd.ts +7 -0
- package/src/css/primitives/kbd/rules.ts +20 -0
- package/src/css/primitives/kbd/types.ts +5 -0
- package/src/css/primitives/label/index.ts +2 -0
- package/src/css/primitives/label/label.ts +16 -0
- package/src/css/primitives/label/rules.ts +85 -0
- package/src/css/primitives/label/types.ts +12 -0
- package/src/css/primitives/popover/index.ts +1 -0
- package/src/css/primitives/popover/popover.ts +5 -0
- package/src/css/primitives/popover/rules.ts +5 -0
- package/src/css/primitives/radio/index.ts +1 -0
- package/src/css/primitives/radio/radio.ts +5 -0
- package/src/css/primitives/radio/rules.ts +5 -0
- package/src/css/primitives/select/index.ts +1 -0
- package/src/css/primitives/select/rules.ts +5 -0
- package/src/css/primitives/select/select.ts +5 -0
- package/src/css/primitives/selectable/__style.ts +117 -0
- package/src/css/primitives/selectable/index.ts +2 -0
- package/src/css/primitives/selectable/rules.ts +27 -0
- package/src/css/primitives/selectable/selectable.ts +9 -0
- package/src/css/primitives/selectable/types.ts +6 -0
- package/src/css/primitives/spinner/index.ts +1 -0
- package/src/css/primitives/spinner/rules.ts +20 -0
- package/src/css/primitives/spinner/spinner.ts +9 -0
- package/src/css/primitives/switch/index.ts +1 -0
- package/src/css/primitives/switch/rules.ts +132 -0
- package/src/css/primitives/switch/switch.ts +5 -0
- package/src/css/primitives/text/index.ts +2 -0
- package/src/css/primitives/text/rules.ts +75 -0
- package/src/css/primitives/text/text.ts +16 -0
- package/src/css/primitives/text/types.ts +11 -0
- package/src/css/primitives/textArea/index.ts +1 -0
- package/src/css/primitives/textArea/rules.ts +5 -0
- package/src/css/primitives/textArea/textArea.ts +5 -0
- package/src/css/primitives/textInput/index.ts +2 -0
- package/src/css/primitives/textInput/rules.ts +321 -0
- package/src/css/primitives/textInput/textInput.ts +15 -0
- package/src/css/primitives/textInput/types.ts +8 -0
- package/src/css/primitives/token/rules.ts +45 -0
- package/src/css/primitives/tooltip/index.ts +1 -0
- package/src/css/primitives/tooltip/rules.ts +17 -0
- package/src/css/primitives/tooltip/tooltip.ts +9 -0
- package/src/css/responsiveRules.ts +25 -0
- package/src/css/rules.ts +99 -0
- package/src/css/styles/border/border.ts +22 -0
- package/src/css/styles/border/index.ts +2 -0
- package/src/css/styles/border/rules.ts +24 -0
- package/src/css/styles/border/types.ts +10 -0
- package/src/css/styles/display/rules.ts +62 -0
- package/src/css/styles/flex/flex.ts +20 -0
- package/src/css/styles/flex/index.ts +2 -0
- package/src/css/styles/flex/rules.ts +28 -0
- package/src/css/styles/flex/types.ts +35 -0
- package/src/css/styles/flexItem/flexItem.ts +8 -0
- package/src/css/styles/flexItem/index.ts +2 -0
- package/src/css/styles/flexItem/rules.ts +11 -0
- package/src/css/styles/flexItem/types.ts +11 -0
- package/src/css/styles/font/font.ts +17 -0
- package/src/css/styles/font/index.ts +2 -0
- package/src/css/styles/font/rules.ts +148 -0
- package/src/css/styles/font/types.ts +12 -0
- package/src/css/styles/gap/gap.ts +8 -0
- package/src/css/styles/gap/index.ts +2 -0
- package/src/css/styles/gap/rules.ts +33 -0
- package/src/css/styles/gap/types.ts +9 -0
- package/src/css/styles/grid/grid.ts +13 -0
- package/src/css/styles/grid/index.ts +2 -0
- package/src/css/styles/grid/rules.ts +146 -0
- package/src/css/styles/grid/types.ts +29 -0
- package/src/css/styles/gridItem/gridItem.ts +15 -0
- package/src/css/styles/gridItem/index.ts +2 -0
- package/src/css/styles/gridItem/rules.ts +96 -0
- package/src/css/styles/gridItem/types.ts +41 -0
- package/src/css/styles/height/rules.ts +7 -0
- package/src/css/styles/margin/index.ts +2 -0
- package/src/css/styles/margin/margin.ts +15 -0
- package/src/css/styles/margin/rules.ts +63 -0
- package/src/css/styles/margin/types.ts +11 -0
- package/src/css/styles/maxWidth/index.ts +2 -0
- package/src/css/styles/maxWidth/maxWidth.ts +6 -0
- package/src/css/styles/maxWidth/rules.ts +36 -0
- package/src/css/styles/maxWidth/types.ts +6 -0
- package/src/css/styles/outline/rules.ts +7 -0
- package/src/css/styles/overflow/index.ts +2 -0
- package/src/css/styles/overflow/overflow.ts +11 -0
- package/src/css/styles/overflow/rules.ts +9 -0
- package/src/css/styles/overflow/types.ts +11 -0
- package/src/css/styles/padding/index.ts +2 -0
- package/src/css/styles/padding/padding.ts +15 -0
- package/src/css/styles/padding/rules.ts +61 -0
- package/src/css/styles/padding/types.ts +12 -0
- package/src/css/styles/pointerEvents/index.ts +2 -0
- package/src/css/styles/pointerEvents/pointerEvents.ts +6 -0
- package/src/css/styles/pointerEvents/rules.ts +11 -0
- package/src/css/styles/pointerEvents/types.ts +7 -0
- package/src/css/styles/position/index.ts +2 -0
- package/src/css/styles/position/position.ts +7 -0
- package/src/css/styles/position/rules.ts +31 -0
- package/src/css/styles/position/types.ts +13 -0
- package/src/css/styles/radius/index.ts +2 -0
- package/src/css/styles/radius/radius.ts +8 -0
- package/src/css/styles/radius/rules.ts +13 -0
- package/src/css/styles/radius/types.ts +7 -0
- package/src/css/styles/shadow/rules.ts +53 -0
- package/src/css/styles/width/index.ts +2 -0
- package/src/css/styles/width/rules.ts +7 -0
- package/src/css/styles/width/types.ts +8 -0
- package/src/css/styles/width/width.ts +6 -0
- package/src/css/types.ts +626 -0
- package/src/css/varNames.ts +381 -0
- package/src/css/vars.ts +399 -0
- package/src/theme/build/_deprecated/color/factory.ts +1 -1
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
- package/src/theme/build/buildColorTheme.ts +39 -45
- package/src/theme/build/renderColorTheme.ts +65 -239
- package/src/theme/build/resolveColorTokens.ts +115 -51
- package/src/theme/config/tokens/color/types.ts +18 -4
- package/src/theme/defaults/colorTokens.ts +10 -17
- package/src/theme/defaults/config.ts +1 -1
- package/src/theme/getScopedTheme.ts +2 -9
- package/src/theme/system/_constants.ts +25 -0
- package/src/theme/system/_types.ts +41 -0
- package/src/theme/system/color/_constants.ts +0 -8
- package/src/theme/system/color/badge.ts +7 -3
- package/src/theme/system/index.ts +2 -0
- package/src/theme/system/v0/color/_system.ts +4 -8
- package/src/theme/system/v0/color/color.ts +2 -3
- package/src/theme/versioning/themeColor_v0_v2.ts +0 -26
- package/src/theme/versioning/v0_v2.ts +0 -4
- package/dist/_chunks-cjs/getTheme_v2.js +0 -342
- package/dist/_chunks-cjs/getTheme_v2.js.map +0 -1
- package/dist/_chunks-es/getTheme_v2.mjs +0 -343
- package/dist/_chunks-es/getTheme_v2.mjs.map +0 -1
- package/dist/_legacy/getTheme_v2.esm.js +0 -343
- package/dist/_legacy/getTheme_v2.esm.js.map +0 -1
- package/src/core/components/autocomplete/autocomplete.styles.tsx +0 -38
- package/src/core/components/breadcrumbs/__workshop__/buttons.tsx +0 -58
- package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +0 -5
- package/src/core/components/dialog/styles.ts +0 -76
- package/src/core/components/menu/menuDivider.ts +0 -12
- package/src/core/components/skeleton/styles.ts +0 -50
- package/src/core/components/toast/styles.ts +0 -61
- package/src/core/components/tree/style.ts +0 -104
- package/src/core/primitives/_selectable/style.ts +0 -114
- package/src/core/primitives/card/styles.ts +0 -146
- package/src/core/primitives/checkbox/styles.ts +0 -127
- /package/src/core/{styles → _compat/styles}/border/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/box/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/card/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/flex/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/focusRing/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/codeFontStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/headingFontStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/labelFontStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/responsiveFont.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/textAlignStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/textFontStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/grid/gridItemStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/grid/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/input/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/input/responsiveInputPaddingStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/internal.ts +0 -0
- /package/src/core/{styles → _compat/styles}/margin/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/margin/marginStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/margin/marginsStyle.test.ts +0 -0
- /package/src/core/{styles → _compat/styles}/margin/types.ts +0 -0
- /package/src/core/{styles → _compat/styles}/padding/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/padding/paddingStyle.test.ts +0 -0
- /package/src/core/{styles → _compat/styles}/padding/paddingStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/padding/types.ts +0 -0
- /package/src/core/{styles → _compat/styles}/radius/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/radius/radiusStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/shadow/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/shadow/types.ts +0 -0
- /package/src/core/{styles → _compat/styles}/types.ts +0 -0
- /package/src/core/{_compat.ts → _compat/types.ts} +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import {ChevronDownIcon} from '@sanity/icons'
|
|
2
|
+
import {ResponsiveProp} from '@sanity/ui/css'
|
|
3
|
+
import {FontTextSize, Space} from '@sanity/ui/theme'
|
|
2
4
|
import {
|
|
3
5
|
ChangeEvent,
|
|
4
6
|
ElementType,
|
|
@@ -32,8 +34,8 @@ import {
|
|
|
32
34
|
Text,
|
|
33
35
|
TextInput,
|
|
34
36
|
} from '../../primitives'
|
|
37
|
+
import {AnimatedSpinnerIcon} from '../../primitives/spinner/animatedSpinnerIcon'
|
|
35
38
|
import {Radius} from '../../types'
|
|
36
|
-
import {AnimatedSpinnerIcon, ListBox, Root} from './autocomplete.styles'
|
|
37
39
|
import {AutocompleteOption} from './autocompleteOption'
|
|
38
40
|
import {autocompleteReducer} from './autocompleteReducer'
|
|
39
41
|
import {
|
|
@@ -50,7 +52,7 @@ export interface AutocompleteProps<Option extends BaseAutocompleteOption = BaseA
|
|
|
50
52
|
border?: boolean
|
|
51
53
|
customValidity?: string
|
|
52
54
|
filterOption?: (query: string, option: Option) => boolean
|
|
53
|
-
fontSize?:
|
|
55
|
+
fontSize?: ResponsiveProp<FontTextSize>
|
|
54
56
|
icon?: ElementType | ReactNode
|
|
55
57
|
id: string
|
|
56
58
|
/** @beta */
|
|
@@ -65,7 +67,8 @@ export interface AutocompleteProps<Option extends BaseAutocompleteOption = BaseA
|
|
|
65
67
|
openOnFocus?: boolean
|
|
66
68
|
/** The options to render. */
|
|
67
69
|
options?: Option[]
|
|
68
|
-
padding?:
|
|
70
|
+
padding?: ResponsiveProp<Space>
|
|
71
|
+
// padding?: number | number[]
|
|
69
72
|
popover?: Omit<PopoverProps, 'content' | 'onMouseEnter' | 'onMouseLeave' | 'open'> &
|
|
70
73
|
Omit<HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content' | 'ref' | 'width'>
|
|
71
74
|
prefix?: ReactNode
|
|
@@ -466,11 +469,16 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
466
469
|
if (v === 1) return 1
|
|
467
470
|
if (v === 2) return 1
|
|
468
471
|
|
|
469
|
-
return v - 2
|
|
472
|
+
return (v as Space) - 2
|
|
470
473
|
}),
|
|
471
474
|
[padding],
|
|
472
475
|
)
|
|
473
|
-
|
|
476
|
+
|
|
477
|
+
const openButtonPadding = useMemo(
|
|
478
|
+
() => padding.map((v) => Math.max((v as Space) - 1, 0)),
|
|
479
|
+
[padding],
|
|
480
|
+
)
|
|
481
|
+
|
|
474
482
|
const openButtonProps: AutocompleteOpenButtonProps = useMemo(
|
|
475
483
|
() => (typeof openButton === 'object' ? openButton : EMPTY_RECORD),
|
|
476
484
|
[openButton],
|
|
@@ -576,7 +584,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
576
584
|
if (filteredOptions.length === 0) return null
|
|
577
585
|
|
|
578
586
|
return (
|
|
579
|
-
<
|
|
587
|
+
<Box
|
|
580
588
|
data-ui="AutoComplete__results"
|
|
581
589
|
onKeyDown={handleListBoxKeyDown}
|
|
582
590
|
padding={1}
|
|
@@ -613,7 +621,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
613
621
|
)
|
|
614
622
|
})}
|
|
615
623
|
</Stack>
|
|
616
|
-
</
|
|
624
|
+
</Box>
|
|
617
625
|
)
|
|
618
626
|
}, [
|
|
619
627
|
activeValue,
|
|
@@ -678,7 +686,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
678
686
|
])
|
|
679
687
|
|
|
680
688
|
return (
|
|
681
|
-
<
|
|
689
|
+
<div
|
|
682
690
|
data-ui="Autocomplete"
|
|
683
691
|
onBlur={handleRootBlur}
|
|
684
692
|
onFocus={handleRootFocus}
|
|
@@ -687,7 +695,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
687
695
|
>
|
|
688
696
|
{input}
|
|
689
697
|
{results}
|
|
690
|
-
</
|
|
698
|
+
</div>
|
|
691
699
|
)
|
|
692
700
|
})
|
|
693
701
|
|
|
@@ -19,15 +19,13 @@ export default function Example() {
|
|
|
19
19
|
return (
|
|
20
20
|
<Flex align="center" height="fill" justify="center">
|
|
21
21
|
<Breadcrumbs
|
|
22
|
-
gapX={1}
|
|
23
|
-
gapY={3}
|
|
24
22
|
maxLength={maxLength}
|
|
25
23
|
separator={
|
|
26
24
|
<Text muted size={1}>
|
|
27
25
|
/
|
|
28
26
|
</Text>
|
|
29
27
|
}
|
|
30
|
-
|
|
28
|
+
space={2}
|
|
31
29
|
>
|
|
32
30
|
<Text size={1}>
|
|
33
31
|
<a href="#">Root</a>
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
+
import {breadcrumbs, composeClassNames, GapStyleProps} from '@sanity/ui/css'
|
|
2
|
+
import {Space} from '@sanity/ui/theme'
|
|
1
3
|
import {Children, forwardRef, isValidElement, useCallback, useMemo, useRef, useState} from 'react'
|
|
2
4
|
import {useClickOutsideEvent} from '../../hooks'
|
|
3
5
|
import {Box, Button, ButtonProps, Flex, Popover, Stack, Text} from '../../primitives'
|
|
4
|
-
import {Root} from './breadcrumbs.styles'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @beta
|
|
8
9
|
*/
|
|
9
|
-
export interface BreadcrumbsProps {
|
|
10
|
+
export interface BreadcrumbsProps extends GapStyleProps {
|
|
10
11
|
expandButton?: Omit<ButtonProps, 'onClick' | 'selected'>
|
|
11
|
-
gap?: number | number[]
|
|
12
|
-
gapX?: number | number[]
|
|
13
|
-
gapY?: number | number[]
|
|
14
12
|
maxLength?: number
|
|
15
13
|
separator?: React.ReactNode
|
|
16
14
|
/** @deprecated - Use `gap`, `gapX`, `gapY` instead */
|
|
@@ -26,11 +24,12 @@ export const Breadcrumbs = forwardRef(function Breadcrumbs(
|
|
|
26
24
|
) {
|
|
27
25
|
const {
|
|
28
26
|
children,
|
|
27
|
+
className,
|
|
29
28
|
expandButton: expandButtonProps,
|
|
30
29
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
31
30
|
gap: _gapProp,
|
|
32
|
-
gapX = props.gap ?? props.space ?? 2,
|
|
33
|
-
gapY = props.gap ?? props.space ?? 2,
|
|
31
|
+
gapX = props.gap ?? (props.space as Space | undefined) ?? 2,
|
|
32
|
+
gapY = props.gap ?? (props.space as Space | undefined) ?? 2,
|
|
34
33
|
maxLength,
|
|
35
34
|
separator,
|
|
36
35
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -91,7 +90,12 @@ export const Breadcrumbs = forwardRef(function Breadcrumbs(
|
|
|
91
90
|
const len = items.length
|
|
92
91
|
|
|
93
92
|
return (
|
|
94
|
-
<
|
|
93
|
+
<nav
|
|
94
|
+
data-ui="Breadcrumbs"
|
|
95
|
+
{...restProps}
|
|
96
|
+
className={composeClassNames(className, breadcrumbs())}
|
|
97
|
+
ref={ref}
|
|
98
|
+
>
|
|
95
99
|
<Flex align="flex-start" as="ol" gapX={gapX} gapY={gapY} wrap="wrap">
|
|
96
100
|
{items.map((item, itemIndex) => (
|
|
97
101
|
<Flex align="flex-start" as="li" gapX={gapX} gapY={gapY} key={itemIndex}>
|
|
@@ -100,7 +104,8 @@ export const Breadcrumbs = forwardRef(function Breadcrumbs(
|
|
|
100
104
|
</Flex>
|
|
101
105
|
))}
|
|
102
106
|
</Flex>
|
|
103
|
-
</
|
|
107
|
+
</nav>
|
|
104
108
|
)
|
|
105
109
|
})
|
|
110
|
+
|
|
106
111
|
Breadcrumbs.displayName = 'ForwardRef(Breadcrumbs)'
|
|
@@ -4,6 +4,7 @@ import {useCallback, useRef, useState} from 'react'
|
|
|
4
4
|
import {WORKSHOP_WIDTH_OPTIONS} from '../../../__workshop__/constants'
|
|
5
5
|
|
|
6
6
|
export default function PropsStory() {
|
|
7
|
+
const animate = useBoolean('Animate', false, 'Props')
|
|
7
8
|
const header = useText('Header', 'Props example', 'Props')
|
|
8
9
|
const onClickOutside = useBoolean('Close when click outside', false, 'Props') || false
|
|
9
10
|
const hideCloseButton = useBoolean('Hide close button', false, 'Props') || false
|
|
@@ -29,6 +30,7 @@ export default function PropsStory() {
|
|
|
29
30
|
{open && (
|
|
30
31
|
<Dialog
|
|
31
32
|
__unstable_hideCloseButton={hideCloseButton}
|
|
33
|
+
animate={animate}
|
|
32
34
|
header={header}
|
|
33
35
|
id="dialog"
|
|
34
36
|
onClickOutside={onClickOutside ? handleClose : undefined}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import {CloseIcon} from '@sanity/icons'
|
|
2
|
+
import {
|
|
3
|
+
composeClassNames,
|
|
4
|
+
ContainerStyleProps,
|
|
5
|
+
dialog,
|
|
6
|
+
dialogCardRoot,
|
|
7
|
+
dialogContainer,
|
|
8
|
+
dialogContent,
|
|
9
|
+
dialogFooter,
|
|
10
|
+
dialogHeader,
|
|
11
|
+
dialogLayout,
|
|
12
|
+
PaddingStyleProps,
|
|
13
|
+
} from '@sanity/ui/css'
|
|
2
14
|
import {ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
3
15
|
import {forwardRef, useCallback, useEffect, useImperativeHandle, useRef} from 'react'
|
|
4
|
-
import {styled} from 'styled-components'
|
|
5
16
|
import {
|
|
6
17
|
containsOrEqualsElement,
|
|
7
18
|
focusFirstDescendant,
|
|
@@ -15,24 +26,15 @@ import {
|
|
|
15
26
|
usePrefersReducedMotion,
|
|
16
27
|
} from '../../hooks'
|
|
17
28
|
import {Box, Button, Card, Container, Flex, Text} from '../../primitives'
|
|
18
|
-
import {ResponsivePaddingProps, ResponsiveWidthProps} from '../../primitives/types'
|
|
19
|
-
import {responsivePaddingStyle, ResponsivePaddingStyleProps} from '../../styles/internal'
|
|
20
29
|
import {useTheme_v2} from '../../theme'
|
|
21
30
|
import {DialogPosition, Radius} from '../../types'
|
|
22
31
|
import {Layer, LayerProps, Portal, useBoundaryElement, useLayer, usePortal} from '../../utils'
|
|
23
|
-
import {
|
|
24
|
-
animationDialogStyle,
|
|
25
|
-
AnimationDialogStyleProps,
|
|
26
|
-
dialogStyle,
|
|
27
|
-
responsiveDialogPositionStyle,
|
|
28
|
-
ResponsiveDialogPositionStyleProps,
|
|
29
|
-
} from './styles'
|
|
30
32
|
import {useDialog} from './useDialog'
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* @public
|
|
34
36
|
*/
|
|
35
|
-
export interface DialogProps extends
|
|
37
|
+
export interface DialogProps extends PaddingStyleProps, ContainerStyleProps {
|
|
36
38
|
/**
|
|
37
39
|
* @beta
|
|
38
40
|
*/
|
|
@@ -41,6 +43,13 @@ export interface DialogProps extends ResponsivePaddingProps, ResponsiveWidthProp
|
|
|
41
43
|
* @beta
|
|
42
44
|
*/
|
|
43
45
|
__unstable_hideCloseButton?: boolean
|
|
46
|
+
/**
|
|
47
|
+
* Whether the dialog should animate in on mount.
|
|
48
|
+
*
|
|
49
|
+
* @beta
|
|
50
|
+
* @defaultValue false
|
|
51
|
+
*/
|
|
52
|
+
animate?: boolean
|
|
44
53
|
cardRadius?: Radius | Radius[]
|
|
45
54
|
cardShadow?: number | number[]
|
|
46
55
|
contentRef?: React.ForwardedRef<HTMLDivElement>
|
|
@@ -55,16 +64,9 @@ export interface DialogProps extends ResponsivePaddingProps, ResponsiveWidthProp
|
|
|
55
64
|
position?: DialogPosition | DialogPosition[]
|
|
56
65
|
scheme?: ThemeColorSchemeKey
|
|
57
66
|
zOffset?: number | number[]
|
|
58
|
-
/**
|
|
59
|
-
* Whether the dialog should animate in on mount.
|
|
60
|
-
*
|
|
61
|
-
* @beta
|
|
62
|
-
* @defaultValue false
|
|
63
|
-
*/
|
|
64
|
-
animate?: boolean
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
interface DialogCardProps extends
|
|
69
|
+
interface DialogCardProps extends ContainerStyleProps {
|
|
68
70
|
/**
|
|
69
71
|
* @beta
|
|
70
72
|
*/
|
|
@@ -99,55 +101,6 @@ function isTargetWithinScope(
|
|
|
99
101
|
)
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
const Root = styled(Layer)<
|
|
103
|
-
ResponsiveDialogPositionStyleProps & ResponsivePaddingStyleProps & AnimationDialogStyleProps
|
|
104
|
-
>(responsivePaddingStyle, dialogStyle, responsiveDialogPositionStyle, animationDialogStyle)
|
|
105
|
-
|
|
106
|
-
const DialogContainer = styled(Container)`
|
|
107
|
-
&:not([hidden]) {
|
|
108
|
-
display: flex;
|
|
109
|
-
}
|
|
110
|
-
width: 100%;
|
|
111
|
-
height: 100%;
|
|
112
|
-
flex-direction: column;
|
|
113
|
-
align-items: center;
|
|
114
|
-
justify-content: center;
|
|
115
|
-
`
|
|
116
|
-
|
|
117
|
-
const DialogCardRoot = styled(Card)`
|
|
118
|
-
&:not([hidden]) {
|
|
119
|
-
display: flex;
|
|
120
|
-
}
|
|
121
|
-
width: 100%;
|
|
122
|
-
min-height: 0;
|
|
123
|
-
max-height: 100%;
|
|
124
|
-
overflow: hidden;
|
|
125
|
-
overflow: clip;
|
|
126
|
-
`
|
|
127
|
-
|
|
128
|
-
const DialogLayout = styled(Flex)`
|
|
129
|
-
flex: 1;
|
|
130
|
-
min-height: 0;
|
|
131
|
-
width: 100%;
|
|
132
|
-
`
|
|
133
|
-
|
|
134
|
-
const DialogHeader = styled(Box)`
|
|
135
|
-
position: relative;
|
|
136
|
-
z-index: 2;
|
|
137
|
-
`
|
|
138
|
-
|
|
139
|
-
const DialogContent = styled(Box)`
|
|
140
|
-
position: relative;
|
|
141
|
-
z-index: 1;
|
|
142
|
-
overflow: auto;
|
|
143
|
-
outline: none;
|
|
144
|
-
`
|
|
145
|
-
|
|
146
|
-
const DialogFooter = styled(Box)`
|
|
147
|
-
position: relative;
|
|
148
|
-
z-index: 3;
|
|
149
|
-
`
|
|
150
|
-
|
|
151
104
|
const DialogCard = forwardRef(function DialogCard(
|
|
152
105
|
props: DialogCardProps,
|
|
153
106
|
forwardedRef: React.ForwardedRef<HTMLDivElement>,
|
|
@@ -236,11 +189,26 @@ const DialogCard = forwardRef(function DialogCard(
|
|
|
236
189
|
)
|
|
237
190
|
|
|
238
191
|
return (
|
|
239
|
-
<
|
|
240
|
-
|
|
241
|
-
|
|
192
|
+
<Container
|
|
193
|
+
align="center"
|
|
194
|
+
className={dialogContainer()}
|
|
195
|
+
data-ui="DialogCard"
|
|
196
|
+
direction="column"
|
|
197
|
+
display="flex"
|
|
198
|
+
justify="center"
|
|
199
|
+
width={width}
|
|
200
|
+
>
|
|
201
|
+
<Card
|
|
202
|
+
className={dialogCardRoot()}
|
|
203
|
+
display="flex"
|
|
204
|
+
radius={radius}
|
|
205
|
+
ref={ref}
|
|
206
|
+
scheme={scheme}
|
|
207
|
+
shadow={shadow}
|
|
208
|
+
>
|
|
209
|
+
<Flex className={dialogLayout()} direction="column" flex={1}>
|
|
242
210
|
{showHeader && (
|
|
243
|
-
<
|
|
211
|
+
<Box className={dialogHeader()} position="relative">
|
|
244
212
|
<Flex align="flex-start" padding={3}>
|
|
245
213
|
<Box flex={1} padding={2}>
|
|
246
214
|
{header && (
|
|
@@ -262,17 +230,26 @@ const DialogCard = forwardRef(function DialogCard(
|
|
|
262
230
|
</Box>
|
|
263
231
|
)}
|
|
264
232
|
</Flex>
|
|
265
|
-
</
|
|
233
|
+
</Box>
|
|
266
234
|
)}
|
|
267
|
-
|
|
268
|
-
|
|
235
|
+
<Box
|
|
236
|
+
className={dialogContent()}
|
|
237
|
+
flex={1}
|
|
238
|
+
overflow="auto"
|
|
239
|
+
position="relative"
|
|
240
|
+
ref={contentRef}
|
|
241
|
+
tabIndex={-1}
|
|
242
|
+
>
|
|
269
243
|
{children}
|
|
270
|
-
</
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
244
|
+
</Box>
|
|
245
|
+
{footer && (
|
|
246
|
+
<Box className={dialogFooter()} position="relative">
|
|
247
|
+
{footer}
|
|
248
|
+
</Box>
|
|
249
|
+
)}
|
|
250
|
+
</Flex>
|
|
251
|
+
</Card>
|
|
252
|
+
</Container>
|
|
276
253
|
)
|
|
277
254
|
})
|
|
278
255
|
|
|
@@ -284,10 +261,11 @@ DialogCard.displayName = 'ForwardRef(DialogCard)'
|
|
|
284
261
|
* @public
|
|
285
262
|
*/
|
|
286
263
|
export const Dialog = forwardRef(function Dialog(
|
|
287
|
-
props: DialogProps &
|
|
264
|
+
props: DialogProps &
|
|
265
|
+
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'id' | 'rows' | 'width' | 'wrap'>,
|
|
288
266
|
ref: React.Ref<HTMLDivElement>,
|
|
289
267
|
) {
|
|
290
|
-
const
|
|
268
|
+
const context = useDialog()
|
|
291
269
|
const {layer} = useTheme_v2()
|
|
292
270
|
const {
|
|
293
271
|
__unstable_autoFocus: autoFocus = true,
|
|
@@ -295,6 +273,7 @@ export const Dialog = forwardRef(function Dialog(
|
|
|
295
273
|
cardRadius: cardRadiusProp = 4,
|
|
296
274
|
cardShadow = 3,
|
|
297
275
|
children,
|
|
276
|
+
className,
|
|
298
277
|
contentRef,
|
|
299
278
|
footer,
|
|
300
279
|
header,
|
|
@@ -303,12 +282,12 @@ export const Dialog = forwardRef(function Dialog(
|
|
|
303
282
|
onClickOutside,
|
|
304
283
|
onClose,
|
|
305
284
|
onFocus,
|
|
306
|
-
padding
|
|
285
|
+
padding = 3,
|
|
307
286
|
portal: portalProp,
|
|
308
|
-
position: positionProp =
|
|
287
|
+
position: positionProp = context.position || 'fixed',
|
|
309
288
|
scheme,
|
|
310
289
|
width: widthProp = 0,
|
|
311
|
-
zOffset: zOffsetProp =
|
|
290
|
+
zOffset: zOffsetProp = context.zOffset || layer.dialog.zOffset,
|
|
312
291
|
animate: _animate = false,
|
|
313
292
|
...restProps
|
|
314
293
|
} = props
|
|
@@ -318,7 +297,6 @@ export const Dialog = forwardRef(function Dialog(
|
|
|
318
297
|
const portalElement = portalProp ? portal.elements?.[portalProp] || null : portal.element
|
|
319
298
|
const boundaryElement = useBoundaryElement().element
|
|
320
299
|
const cardRadius = useArrayProp(cardRadiusProp)
|
|
321
|
-
const padding = useArrayProp(paddingProp)
|
|
322
300
|
const position = useArrayProp(positionProp)
|
|
323
301
|
const width = useArrayProp(widthProp)
|
|
324
302
|
const zOffset = useArrayProp(zOffsetProp)
|
|
@@ -386,18 +364,20 @@ export const Dialog = forwardRef(function Dialog(
|
|
|
386
364
|
|
|
387
365
|
return (
|
|
388
366
|
<Portal __unstable_name={portalProp}>
|
|
389
|
-
<
|
|
367
|
+
<Layer
|
|
390
368
|
{...restProps}
|
|
391
|
-
$animate={animate}
|
|
392
|
-
$padding={padding}
|
|
393
|
-
$position={position}
|
|
394
369
|
aria-labelledby={labelId}
|
|
395
370
|
aria-modal
|
|
371
|
+
className={composeClassNames(className, dialog())}
|
|
372
|
+
data-animate={animate ? '' : undefined}
|
|
396
373
|
data-ui="Dialog"
|
|
374
|
+
display="flex"
|
|
397
375
|
id={id}
|
|
398
376
|
onActivate={onActivate}
|
|
399
377
|
onClick={handleRootClick}
|
|
400
378
|
onFocus={handleFocus}
|
|
379
|
+
padding={padding}
|
|
380
|
+
position={position}
|
|
401
381
|
ref={ref}
|
|
402
382
|
role="dialog"
|
|
403
383
|
zOffset={zOffset}
|
|
@@ -422,8 +402,9 @@ export const Dialog = forwardRef(function Dialog(
|
|
|
422
402
|
{children}
|
|
423
403
|
</DialogCard>
|
|
424
404
|
<div ref={postDivRef} tabIndex={0} />
|
|
425
|
-
</
|
|
405
|
+
</Layer>
|
|
426
406
|
</Portal>
|
|
427
407
|
)
|
|
428
408
|
})
|
|
409
|
+
|
|
429
410
|
Dialog.displayName = 'ForwardRef(Dialog)'
|
|
@@ -1,43 +1,31 @@
|
|
|
1
|
+
import {RadiusStyleProps, ResponsiveProp} from '@sanity/ui/css'
|
|
2
|
+
import {FontTextSize, Space} from '@sanity/ui/theme'
|
|
1
3
|
import {forwardRef} from 'react'
|
|
2
|
-
import {styled} from 'styled-components'
|
|
3
4
|
import {useArrayProp} from '../../hooks'
|
|
4
|
-
import {Inline, KBD} from '../../primitives'
|
|
5
|
-
import {Radius} from '../../types'
|
|
5
|
+
import {Box, Inline, KBD} from '../../primitives'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
|
-
export interface HotkeysProps {
|
|
11
|
-
fontSize?:
|
|
12
|
-
padding?:
|
|
13
|
-
|
|
14
|
-
space?: number | number[]
|
|
10
|
+
export interface HotkeysProps extends RadiusStyleProps {
|
|
11
|
+
fontSize?: ResponsiveProp<FontTextSize>
|
|
12
|
+
padding?: ResponsiveProp<Space>
|
|
13
|
+
space?: ResponsiveProp<Space>
|
|
15
14
|
keys?: string[]
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
const Root = styled.kbd`
|
|
19
|
-
font: inherit;
|
|
20
|
-
padding: 1px;
|
|
21
|
-
|
|
22
|
-
&:not([hidden]) {
|
|
23
|
-
display: block;
|
|
24
|
-
}
|
|
25
|
-
`
|
|
26
|
-
|
|
27
|
-
const Key = styled(KBD)`
|
|
28
|
-
&:not([hidden]) {
|
|
29
|
-
display: block;
|
|
30
|
-
}
|
|
31
|
-
`
|
|
32
|
-
|
|
33
17
|
/**
|
|
34
18
|
* Represent hotkeys (a keyboard combination) with semantic `<kbd>` elements.
|
|
35
19
|
*
|
|
36
20
|
* @public
|
|
37
21
|
*/
|
|
38
22
|
export const Hotkeys = forwardRef(function Hotkeys(
|
|
39
|
-
props: HotkeysProps &
|
|
40
|
-
|
|
23
|
+
props: HotkeysProps &
|
|
24
|
+
Omit<
|
|
25
|
+
React.HTMLProps<HTMLDivElement>,
|
|
26
|
+
'as' | 'display' | 'height' | 'ref' | 'rows' | 'size' | 'width' | 'wrap'
|
|
27
|
+
>,
|
|
28
|
+
ref: React.Ref<HTMLDivElement>,
|
|
41
29
|
) {
|
|
42
30
|
const {fontSize, keys, padding, radius, space: spaceProp = 0.5, ...restProps} = props
|
|
43
31
|
const space = useArrayProp(spaceProp)
|
|
@@ -47,15 +35,16 @@ export const Hotkeys = forwardRef(function Hotkeys(
|
|
|
47
35
|
}
|
|
48
36
|
|
|
49
37
|
return (
|
|
50
|
-
<
|
|
38
|
+
<Box as="kbd" data-ui="Hotkeys" {...restProps} display="flex" gap={spaceProp} ref={ref}>
|
|
51
39
|
<Inline as="span" space={space}>
|
|
52
40
|
{keys.map((key, i) => (
|
|
53
|
-
<
|
|
41
|
+
<KBD display="block" fontSize={fontSize} key={i} padding={padding} radius={radius}>
|
|
54
42
|
{key}
|
|
55
|
-
</
|
|
43
|
+
</KBD>
|
|
56
44
|
))}
|
|
57
45
|
</Inline>
|
|
58
|
-
</
|
|
46
|
+
</Box>
|
|
59
47
|
)
|
|
60
48
|
})
|
|
49
|
+
|
|
61
50
|
Hotkeys.displayName = 'ForwardRef(Hotkeys)'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import {PaddingStyleProps, ResponsiveProp} from '@sanity/ui/css'
|
|
2
|
+
import {Space} from '@sanity/ui/theme'
|
|
1
3
|
import {forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef} from 'react'
|
|
2
|
-
import {styled} from 'styled-components'
|
|
3
4
|
import {useClickOutsideEvent, useGlobalKeyDown} from '../../hooks'
|
|
4
5
|
import {Box, Stack} from '../../primitives'
|
|
5
|
-
import {ResponsivePaddingProps} from '../../primitives/types'
|
|
6
6
|
import {useLayer} from '../../utils'
|
|
7
7
|
import {MenuContext, MenuContextValue} from './menuContext'
|
|
8
8
|
import {useMenuController} from './useMenuController'
|
|
@@ -10,7 +10,7 @@ import {useMenuController} from './useMenuController'
|
|
|
10
10
|
/**
|
|
11
11
|
* @public
|
|
12
12
|
*/
|
|
13
|
-
export interface MenuProps extends
|
|
13
|
+
export interface MenuProps extends PaddingStyleProps {
|
|
14
14
|
/**
|
|
15
15
|
* @deprecated Use `shouldFocus="first"` instead.
|
|
16
16
|
*/
|
|
@@ -26,21 +26,20 @@ export interface MenuProps extends ResponsivePaddingProps {
|
|
|
26
26
|
originElement?: HTMLElement | null
|
|
27
27
|
registerElement?: (el: HTMLElement) => () => void
|
|
28
28
|
shouldFocus?: 'first' | 'last' | null
|
|
29
|
-
space?:
|
|
29
|
+
space?: ResponsiveProp<Space>
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const Root = styled(Box)`
|
|
33
|
-
outline: none;
|
|
34
|
-
overflow: auto;
|
|
35
|
-
`
|
|
36
|
-
|
|
37
32
|
/**
|
|
38
33
|
* The `Menu` component is a building block for application menus.
|
|
39
34
|
*
|
|
40
35
|
* @public
|
|
41
36
|
*/
|
|
42
37
|
export const Menu = forwardRef(function Menu(
|
|
43
|
-
props: MenuProps &
|
|
38
|
+
props: MenuProps &
|
|
39
|
+
Omit<
|
|
40
|
+
React.HTMLProps<HTMLDivElement>,
|
|
41
|
+
'as' | 'height' | 'role' | 'rows' | 'tabIndex' | 'width' | 'wrap'
|
|
42
|
+
>,
|
|
44
43
|
forwardedRef: React.ForwardedRef<HTMLDivElement>,
|
|
45
44
|
) {
|
|
46
45
|
const {
|
|
@@ -155,17 +154,19 @@ export const Menu = forwardRef(function Menu(
|
|
|
155
154
|
|
|
156
155
|
return (
|
|
157
156
|
<MenuContext.Provider value={value}>
|
|
158
|
-
<
|
|
157
|
+
<Box
|
|
159
158
|
data-ui="Menu"
|
|
160
159
|
{...restProps}
|
|
161
160
|
onKeyDown={handleKeyDown}
|
|
161
|
+
overflow="auto"
|
|
162
|
+
outline="none"
|
|
162
163
|
padding={padding}
|
|
163
164
|
ref={handleRefChange}
|
|
164
165
|
role="menu"
|
|
165
166
|
tabIndex={-1}
|
|
166
167
|
>
|
|
167
168
|
<Stack space={space}>{children}</Stack>
|
|
168
|
-
</
|
|
169
|
+
</Box>
|
|
169
170
|
</MenuContext.Provider>
|
|
170
171
|
)
|
|
171
172
|
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {composeClassNames, menuDivider} from '@sanity/ui/css'
|
|
2
|
+
import {forwardRef, HTMLProps} from 'react'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export const MenuDivider = forwardRef(function MenuDivider(
|
|
8
|
+
props: HTMLProps<HTMLHRElement>,
|
|
9
|
+
ref: React.ForwardedRef<HTMLHRElement>,
|
|
10
|
+
) {
|
|
11
|
+
const {className, ...restProps} = props
|
|
12
|
+
|
|
13
|
+
return <hr {...restProps} className={composeClassNames(className, menuDivider())} ref={ref} />
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
MenuDivider.displayName = 'MenuDivider'
|