@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,6 +1,5 @@
|
|
|
1
1
|
import {AnimatePresence, motion, type Variants} from 'framer-motion'
|
|
2
2
|
import {useMemo, useRef, useState, startTransition, useEffect} from 'react'
|
|
3
|
-
import {styled} from 'styled-components'
|
|
4
3
|
import {POPOVER_MOTION_CONTENT_OPACITY_PROPERTY} from '../../constants'
|
|
5
4
|
import {useMounted} from '../../hooks/useMounted'
|
|
6
5
|
import {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'
|
|
@@ -27,24 +26,6 @@ export interface ToastProviderProps {
|
|
|
27
26
|
zOffset?: number | number[]
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
const Root = styled(Layer)`
|
|
31
|
-
position: fixed;
|
|
32
|
-
top: 0;
|
|
33
|
-
left: 0;
|
|
34
|
-
right: 0;
|
|
35
|
-
bottom: 0;
|
|
36
|
-
pointer-events: none;
|
|
37
|
-
`
|
|
38
|
-
|
|
39
|
-
const ToastContainer = styled.div`
|
|
40
|
-
box-sizing: border-box;
|
|
41
|
-
position: absolute;
|
|
42
|
-
right: 0;
|
|
43
|
-
bottom: 0;
|
|
44
|
-
max-width: 420px;
|
|
45
|
-
width: 100%;
|
|
46
|
-
`
|
|
47
|
-
|
|
48
29
|
let toastId = 0
|
|
49
30
|
|
|
50
31
|
/**
|
|
@@ -153,8 +134,27 @@ export function ToastProvider(props: ToastProviderProps): React.ReactElement {
|
|
|
153
134
|
<ToastContext.Provider value={value}>
|
|
154
135
|
{children}
|
|
155
136
|
{mounted && (
|
|
156
|
-
<
|
|
157
|
-
|
|
137
|
+
<Layer
|
|
138
|
+
// root
|
|
139
|
+
data-ui="ToastProvider"
|
|
140
|
+
inset={0}
|
|
141
|
+
pointerEvents="none"
|
|
142
|
+
position="fixed"
|
|
143
|
+
zOffset={zOffset}
|
|
144
|
+
width="fill"
|
|
145
|
+
>
|
|
146
|
+
<Box
|
|
147
|
+
// container
|
|
148
|
+
position="absolute"
|
|
149
|
+
sizing="border"
|
|
150
|
+
style={{
|
|
151
|
+
// todo: move to css?
|
|
152
|
+
right: 0,
|
|
153
|
+
bottom: 0,
|
|
154
|
+
maxWidth: 420,
|
|
155
|
+
}}
|
|
156
|
+
width="fill"
|
|
157
|
+
>
|
|
158
158
|
<Box padding={padding} paddingX={paddingX} paddingY={paddingY}>
|
|
159
159
|
<AnimatePresence initial={false}>
|
|
160
160
|
{state.map(({dismiss, id, params}) => (
|
|
@@ -183,8 +183,8 @@ export function ToastProvider(props: ToastProviderProps): React.ReactElement {
|
|
|
183
183
|
))}
|
|
184
184
|
</AnimatePresence>
|
|
185
185
|
</Box>
|
|
186
|
-
</
|
|
187
|
-
</
|
|
186
|
+
</Box>
|
|
187
|
+
</Layer>
|
|
188
188
|
)}
|
|
189
189
|
</ToastContext.Provider>
|
|
190
190
|
)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {ResponsiveProp} from '@sanity/ui/css'
|
|
2
|
+
import {Space} from '@sanity/ui/theme'
|
|
1
3
|
import {
|
|
2
4
|
forwardRef,
|
|
3
5
|
memo,
|
|
@@ -18,7 +20,7 @@ import {TreeContextValue, TreeState} from './types'
|
|
|
18
20
|
* @beta
|
|
19
21
|
*/
|
|
20
22
|
export interface TreeProps {
|
|
21
|
-
space?:
|
|
23
|
+
space?: ResponsiveProp<Space>
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/**
|
|
@@ -28,7 +30,10 @@ export interface TreeProps {
|
|
|
28
30
|
export const Tree = memo(
|
|
29
31
|
forwardRef(function Tree(
|
|
30
32
|
props: TreeProps &
|
|
31
|
-
Omit<
|
|
33
|
+
Omit<
|
|
34
|
+
React.HTMLProps<HTMLDivElement>,
|
|
35
|
+
'align' | 'as' | 'height' | 'ref' | 'rows' | 'role' | 'width' | 'wrap'
|
|
36
|
+
>,
|
|
32
37
|
forwardedRef: React.ForwardedRef<HTMLDivElement>,
|
|
33
38
|
): React.ReactElement {
|
|
34
39
|
const {children, space = 1, onFocus, ...restProps} = props
|
|
@@ -8,7 +8,10 @@ export interface TreeGroupProps {
|
|
|
8
8
|
|
|
9
9
|
export const TreeGroup = memo(function TreeGroup(
|
|
10
10
|
props: TreeGroupProps &
|
|
11
|
-
Omit<
|
|
11
|
+
Omit<
|
|
12
|
+
React.HTMLProps<HTMLDivElement>,
|
|
13
|
+
'as' | 'height' | 'ref' | 'role' | 'rows' | 'width' | 'wrap'
|
|
14
|
+
>,
|
|
12
15
|
): React.ReactElement {
|
|
13
16
|
const {children, expanded = false, ...restProps} = props
|
|
14
17
|
const tree = useTree()
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import {ToggleArrowRightIcon} from '@sanity/icons'
|
|
2
|
-
import {
|
|
2
|
+
import {composeClassNames, ResponsiveProp, treeItem} from '@sanity/ui/css'
|
|
3
|
+
import {Space, ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
3
4
|
import {memo, useCallback, useEffect, useId, useMemo, useRef} from 'react'
|
|
4
|
-
import {styled} from 'styled-components'
|
|
5
5
|
import {Box, BoxProps, Flex, Text} from '../../primitives'
|
|
6
|
-
import {
|
|
7
|
-
treeItemRootStyle,
|
|
8
|
-
treeItemRootColorStyle,
|
|
9
|
-
treeItemBoxStyle,
|
|
10
|
-
TreeItemBoxStyleProps,
|
|
11
|
-
} from './style'
|
|
12
6
|
import {TreeContext} from './treeContext'
|
|
13
7
|
import {TreeGroup} from './treeGroup'
|
|
14
8
|
import {useTree} from './useTree'
|
|
@@ -25,30 +19,25 @@ export interface TreeItemProps {
|
|
|
25
19
|
*/
|
|
26
20
|
linkAs?: BoxProps['as']
|
|
27
21
|
padding?: number | number[]
|
|
28
|
-
space?:
|
|
22
|
+
space?: ResponsiveProp<Space>
|
|
29
23
|
text?: React.ReactNode
|
|
30
24
|
weight?: ThemeFontWeightKey
|
|
31
25
|
}
|
|
32
26
|
|
|
33
|
-
const Root = memo(styled.li(treeItemRootStyle, treeItemRootColorStyle))
|
|
34
|
-
|
|
35
|
-
const TreeItemBox = styled(Box).attrs({forwardedAs: 'a'})<TreeItemBoxStyleProps>(treeItemBoxStyle)
|
|
36
|
-
|
|
37
|
-
const ToggleArrowText = styled(Text)`
|
|
38
|
-
& > svg {
|
|
39
|
-
transition: transform 100ms;
|
|
40
|
-
}
|
|
41
|
-
`
|
|
42
|
-
|
|
43
27
|
/**
|
|
44
28
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
45
29
|
* @beta
|
|
46
30
|
*/
|
|
47
31
|
export const TreeItem = memo(function TreeItem(
|
|
48
|
-
props: TreeItemProps &
|
|
32
|
+
props: TreeItemProps &
|
|
33
|
+
Omit<
|
|
34
|
+
React.HTMLProps<HTMLDivElement>,
|
|
35
|
+
'as' | 'height' | 'ref' | 'role' | 'rows' | 'width' | 'wrap'
|
|
36
|
+
>,
|
|
49
37
|
): React.ReactElement {
|
|
50
38
|
const {
|
|
51
39
|
children,
|
|
40
|
+
className,
|
|
52
41
|
expanded: expandedProp = false,
|
|
53
42
|
fontSize = 1,
|
|
54
43
|
href,
|
|
@@ -64,7 +53,7 @@ export const TreeItem = memo(function TreeItem(
|
|
|
64
53
|
weight,
|
|
65
54
|
...restProps
|
|
66
55
|
} = props
|
|
67
|
-
const rootRef = useRef<
|
|
56
|
+
const rootRef = useRef<HTMLDivElement | null>(null)
|
|
68
57
|
const treeitemRef = useRef<HTMLDivElement | null>(null)
|
|
69
58
|
const tree = useTree()
|
|
70
59
|
const {path, registerItem, setExpanded, setFocusedElement} = tree
|
|
@@ -82,7 +71,7 @@ export const TreeItem = memo(function TreeItem(
|
|
|
82
71
|
)
|
|
83
72
|
|
|
84
73
|
const handleClick = useCallback(
|
|
85
|
-
(event: React.MouseEvent<
|
|
74
|
+
(event: React.MouseEvent<HTMLDivElement>) => {
|
|
86
75
|
if (onClick) onClick(event)
|
|
87
76
|
|
|
88
77
|
const target = event.target
|
|
@@ -118,9 +107,9 @@ export const TreeItem = memo(function TreeItem(
|
|
|
118
107
|
}, [expanded, itemPath, registerItem, selected])
|
|
119
108
|
|
|
120
109
|
const content = (
|
|
121
|
-
<Flex padding={padding}>
|
|
110
|
+
<Flex gap={space} padding={padding}>
|
|
122
111
|
<Box
|
|
123
|
-
marginRight={space}
|
|
112
|
+
// marginRight={space}
|
|
124
113
|
style={{
|
|
125
114
|
visibility: IconComponent || children ? 'visible' : 'hidden',
|
|
126
115
|
pointerEvents: 'none',
|
|
@@ -132,9 +121,14 @@ export const TreeItem = memo(function TreeItem(
|
|
|
132
121
|
</Text>
|
|
133
122
|
)}
|
|
134
123
|
{!IconComponent && (
|
|
135
|
-
<
|
|
124
|
+
<Text
|
|
125
|
+
// ToggleArrowText
|
|
126
|
+
muted={muted}
|
|
127
|
+
size={fontSize}
|
|
128
|
+
weight={weight}
|
|
129
|
+
>
|
|
136
130
|
<ToggleArrowRightIcon style={{transform: expanded ? 'rotate(90deg)' : undefined}} />
|
|
137
|
-
</
|
|
131
|
+
</Text>
|
|
138
132
|
)}
|
|
139
133
|
</Box>
|
|
140
134
|
<Box flex={1}>
|
|
@@ -147,18 +141,20 @@ export const TreeItem = memo(function TreeItem(
|
|
|
147
141
|
|
|
148
142
|
if (href) {
|
|
149
143
|
return (
|
|
150
|
-
<
|
|
144
|
+
<Box
|
|
151
145
|
data-selected={selected ? '' : undefined}
|
|
152
146
|
data-tree-id={id}
|
|
153
147
|
data-tree-key={itemKey}
|
|
154
148
|
data-ui="TreeItem"
|
|
155
149
|
{...restProps}
|
|
150
|
+
as="li"
|
|
151
|
+
className={composeClassNames(className, treeItem())}
|
|
156
152
|
onClick={handleClick}
|
|
157
153
|
ref={rootRef}
|
|
158
154
|
role="none"
|
|
159
155
|
>
|
|
160
|
-
<
|
|
161
|
-
$level={tree.level}
|
|
156
|
+
<Box
|
|
157
|
+
// $level={tree.level}
|
|
162
158
|
aria-expanded={expanded}
|
|
163
159
|
as={linkAs}
|
|
164
160
|
data-ui="TreeItem__box"
|
|
@@ -166,19 +162,23 @@ export const TreeItem = memo(function TreeItem(
|
|
|
166
162
|
ref={treeitemRef}
|
|
167
163
|
role="treeitem"
|
|
168
164
|
tabIndex={tabIndex}
|
|
165
|
+
// todo
|
|
166
|
+
style={{
|
|
167
|
+
paddingLeft: `calc(var(--space-2) * ${tree.level})`,
|
|
168
|
+
}}
|
|
169
169
|
>
|
|
170
170
|
{content}
|
|
171
|
-
</
|
|
171
|
+
</Box>
|
|
172
172
|
|
|
173
173
|
<TreeContext.Provider value={contextValue}>
|
|
174
174
|
{children && <TreeGroup hidden={!expanded}>{children}</TreeGroup>}
|
|
175
175
|
</TreeContext.Provider>
|
|
176
|
-
</
|
|
176
|
+
</Box>
|
|
177
177
|
)
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
return (
|
|
181
|
-
<
|
|
181
|
+
<Box
|
|
182
182
|
data-selected={selected ? '' : undefined}
|
|
183
183
|
data-ui="TreeItem"
|
|
184
184
|
data-tree-id={id}
|
|
@@ -191,14 +191,23 @@ export const TreeItem = memo(function TreeItem(
|
|
|
191
191
|
role="treeitem"
|
|
192
192
|
tabIndex={tabIndex}
|
|
193
193
|
>
|
|
194
|
-
<
|
|
194
|
+
<Box
|
|
195
|
+
// $level={tree.level}
|
|
196
|
+
as="div"
|
|
197
|
+
data-ui="TreeItem__box"
|
|
198
|
+
// todo
|
|
199
|
+
style={{
|
|
200
|
+
paddingLeft: `calc(var(--space-2) * ${tree.level})`,
|
|
201
|
+
}}
|
|
202
|
+
>
|
|
195
203
|
{content}
|
|
196
|
-
</
|
|
204
|
+
</Box>
|
|
197
205
|
|
|
198
206
|
<TreeContext.Provider value={contextValue}>
|
|
199
207
|
{children && <TreeGroup expanded={expanded}>{children}</TreeGroup>}
|
|
200
208
|
</TreeContext.Provider>
|
|
201
|
-
</
|
|
209
|
+
</Box>
|
|
202
210
|
)
|
|
203
211
|
})
|
|
212
|
+
|
|
204
213
|
TreeItem.displayName = 'Memo(TreeItem)'
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {ResponsiveProp} from '@sanity/ui/css'
|
|
2
|
+
import {Space} from '@sanity/ui/theme'
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* @beta
|
|
3
6
|
*/
|
|
@@ -16,6 +19,7 @@ export interface TreeContextValue {
|
|
|
16
19
|
registerItem: (element: HTMLElement, path: string, expanded: boolean, selected: boolean) => void
|
|
17
20
|
setExpanded: (path: string, expanded: boolean) => void
|
|
18
21
|
setFocusedElement: (focusedElement: HTMLElement | null) => void
|
|
19
|
-
space: number | number[]
|
|
22
|
+
// space: number | number[]
|
|
23
|
+
space: ResponsiveProp<Space>
|
|
20
24
|
state: TreeState
|
|
21
25
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export const elements = [
|
|
2
|
+
'a',
|
|
3
|
+
'abbr',
|
|
4
|
+
'address',
|
|
5
|
+
'area',
|
|
6
|
+
'article',
|
|
7
|
+
'aside',
|
|
8
|
+
'audio',
|
|
9
|
+
'b',
|
|
10
|
+
'base',
|
|
11
|
+
'bdi',
|
|
12
|
+
'bdo',
|
|
13
|
+
'big',
|
|
14
|
+
'blockquote',
|
|
15
|
+
'body',
|
|
16
|
+
'br',
|
|
17
|
+
'button',
|
|
18
|
+
'canvas',
|
|
19
|
+
'caption',
|
|
20
|
+
'cite',
|
|
21
|
+
'code',
|
|
22
|
+
'col',
|
|
23
|
+
'colgroup',
|
|
24
|
+
'data',
|
|
25
|
+
'datalist',
|
|
26
|
+
'dd',
|
|
27
|
+
'del',
|
|
28
|
+
'details',
|
|
29
|
+
'dfn',
|
|
30
|
+
'dialog',
|
|
31
|
+
'div',
|
|
32
|
+
'dl',
|
|
33
|
+
'dt',
|
|
34
|
+
'em',
|
|
35
|
+
'embed',
|
|
36
|
+
'fieldset',
|
|
37
|
+
'figcaption',
|
|
38
|
+
'figure',
|
|
39
|
+
'footer',
|
|
40
|
+
'form',
|
|
41
|
+
'h1',
|
|
42
|
+
'h2',
|
|
43
|
+
'h3',
|
|
44
|
+
'h4',
|
|
45
|
+
'h5',
|
|
46
|
+
'h6',
|
|
47
|
+
'header',
|
|
48
|
+
'hgroup',
|
|
49
|
+
'hr',
|
|
50
|
+
'html',
|
|
51
|
+
'i',
|
|
52
|
+
'iframe',
|
|
53
|
+
'img',
|
|
54
|
+
'input',
|
|
55
|
+
'ins',
|
|
56
|
+
'kbd',
|
|
57
|
+
'keygen',
|
|
58
|
+
'label',
|
|
59
|
+
'legend',
|
|
60
|
+
'li',
|
|
61
|
+
'link',
|
|
62
|
+
'main',
|
|
63
|
+
'map',
|
|
64
|
+
'mark',
|
|
65
|
+
'menu',
|
|
66
|
+
'menuitem',
|
|
67
|
+
'meta',
|
|
68
|
+
'meter',
|
|
69
|
+
'nav',
|
|
70
|
+
'noscript',
|
|
71
|
+
'object',
|
|
72
|
+
'ol',
|
|
73
|
+
'optgroup',
|
|
74
|
+
'option',
|
|
75
|
+
'output',
|
|
76
|
+
'p',
|
|
77
|
+
'param',
|
|
78
|
+
'picture',
|
|
79
|
+
'pre',
|
|
80
|
+
'progress',
|
|
81
|
+
'q',
|
|
82
|
+
'rp',
|
|
83
|
+
'rt',
|
|
84
|
+
'ruby',
|
|
85
|
+
's',
|
|
86
|
+
'samp',
|
|
87
|
+
'script',
|
|
88
|
+
'section',
|
|
89
|
+
'select',
|
|
90
|
+
'small',
|
|
91
|
+
'source',
|
|
92
|
+
'span',
|
|
93
|
+
'strong',
|
|
94
|
+
'style',
|
|
95
|
+
'sub',
|
|
96
|
+
'summary',
|
|
97
|
+
'sup',
|
|
98
|
+
'table',
|
|
99
|
+
'tbody',
|
|
100
|
+
'td',
|
|
101
|
+
'textarea',
|
|
102
|
+
'tfoot',
|
|
103
|
+
'th',
|
|
104
|
+
'thead',
|
|
105
|
+
'time',
|
|
106
|
+
'tr',
|
|
107
|
+
'track',
|
|
108
|
+
'u',
|
|
109
|
+
'ul',
|
|
110
|
+
'use',
|
|
111
|
+
'var',
|
|
112
|
+
'video',
|
|
113
|
+
'wbr', // SVG
|
|
114
|
+
'circle',
|
|
115
|
+
'clipPath',
|
|
116
|
+
'defs',
|
|
117
|
+
'ellipse',
|
|
118
|
+
'foreignObject',
|
|
119
|
+
'g',
|
|
120
|
+
'image',
|
|
121
|
+
'line',
|
|
122
|
+
'linearGradient',
|
|
123
|
+
'marker',
|
|
124
|
+
'mask',
|
|
125
|
+
'path',
|
|
126
|
+
'pattern',
|
|
127
|
+
'polygon',
|
|
128
|
+
'polyline',
|
|
129
|
+
'radialGradient',
|
|
130
|
+
'rect',
|
|
131
|
+
'stop',
|
|
132
|
+
'svg',
|
|
133
|
+
'text',
|
|
134
|
+
'tspan',
|
|
135
|
+
] as const
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
css as _css,
|
|
3
|
+
createGlobalStyle as _createGlobalStyle,
|
|
4
|
+
type ExecutionContext as _ExecutionContext,
|
|
5
|
+
keyframes as _keyframes,
|
|
6
|
+
// ThemeProvider as _ThemeProvider,
|
|
7
|
+
useTheme as _useTheme,
|
|
8
|
+
} from 'styled-components'
|
|
9
|
+
|
|
10
|
+
export const createGlobalStyle = _createGlobalStyle
|
|
11
|
+
export const css = _css
|
|
12
|
+
export type ExecutionContext = _ExecutionContext
|
|
13
|
+
export const keyframes = _keyframes
|
|
14
|
+
// export const ThemeProvider = _ThemeProvider
|
|
15
|
+
export const useTheme = _useTheme
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
+
|
|
4
|
+
import {createElement, forwardRef} from 'react'
|
|
5
|
+
import {styled as _styled} from 'styled-components'
|
|
6
|
+
import {elements} from './elements'
|
|
7
|
+
|
|
8
|
+
const baseStyled = (tagName: string): any => {
|
|
9
|
+
const m = (_strings: TemplateStringsArray, ..._interpolations: any[]) => {
|
|
10
|
+
const Styled = forwardRef(function Styled(props: any, ref: any) {
|
|
11
|
+
const {as, forwardedAs, ...rest} = props
|
|
12
|
+
|
|
13
|
+
const sanitizedProps = Object.fromEntries(
|
|
14
|
+
Object.entries(rest)
|
|
15
|
+
.filter(([, val]) => Boolean(val) && (!isArray(val) || val.length > 0))
|
|
16
|
+
.map(([key, val]) => {
|
|
17
|
+
if (key.startsWith('$')) {
|
|
18
|
+
return [`data-${toSnakeCase(key.slice(1))}`, val]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return [key, val]
|
|
22
|
+
}),
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const t = as ?? tagName
|
|
26
|
+
|
|
27
|
+
return createElement(t, {...sanitizedProps, as: forwardedAs, ref})
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
Styled.displayName = `Styled(${typeof tagName === 'function' ? (tagName as any).displayName : tagName})`
|
|
31
|
+
|
|
32
|
+
return Styled
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
m['attrs'] = (attrs: any) => {
|
|
36
|
+
return (_strings: TemplateStringsArray, ..._interpolations: any[]) => {
|
|
37
|
+
const StyledAttrs = forwardRef(function StyledAttrs(_props: any, ref: any) {
|
|
38
|
+
const props = {...attrs, ..._props}
|
|
39
|
+
const {as, forwardedAs, ...rest} = props
|
|
40
|
+
|
|
41
|
+
const sanitizedProps = Object.fromEntries(
|
|
42
|
+
Object.entries(rest)
|
|
43
|
+
.filter(([, val]) => Boolean(val) && (!isArray(val) || val.length > 0))
|
|
44
|
+
.map(([key, val]) => {
|
|
45
|
+
if (key.startsWith('$')) {
|
|
46
|
+
return [`data-${toSnakeCase(key.slice(1))}`, val]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return [key, val]
|
|
50
|
+
}),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
const t = as ?? tagName
|
|
54
|
+
|
|
55
|
+
return createElement(t, {...sanitizedProps, as: forwardedAs, ref})
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
StyledAttrs.displayName = `StyledAttrs(${typeof tagName === 'function' ? (tagName as any).displayName : tagName})`
|
|
59
|
+
|
|
60
|
+
return StyledAttrs
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return m
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const styled = baseStyled as typeof _styled
|
|
68
|
+
|
|
69
|
+
for (const tagName of elements) {
|
|
70
|
+
;(styled as any)[tagName] = baseStyled(tagName)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function toSnakeCase(str: string): string {
|
|
74
|
+
return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function isArray(value: unknown): value is unknown[] {
|
|
78
|
+
return Array.isArray(value)
|
|
79
|
+
}
|
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import {composeClassNames, selectable, SelectableStyleProps} from '@sanity/ui/css'
|
|
2
|
+
import {ForwardedRef, forwardRef, HTMLProps} from 'react'
|
|
3
|
+
import {SelectableTone} from '../../types'
|
|
4
|
+
import {Box, BoxProps} from '../box'
|
|
5
|
+
|
|
6
|
+
/** @internal */
|
|
7
|
+
export interface SelectableProps extends BoxProps, SelectableStyleProps {
|
|
8
|
+
tone?: SelectableTone
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** @internal */
|
|
12
|
+
export const Selectable = forwardRef(function Selectable(
|
|
13
|
+
props: SelectableProps & Omit<HTMLProps<HTMLDivElement>, 'as' | 'height' | 'wrap' | 'width'>,
|
|
14
|
+
ref: ForwardedRef<HTMLDivElement>,
|
|
15
|
+
) {
|
|
16
|
+
const {className, radius, tone, ...restProps} = props
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Box
|
|
20
|
+
{...restProps}
|
|
21
|
+
className={composeClassNames(className, selectable({radius, tone}))}
|
|
22
|
+
ref={ref}
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
Selectable.displayName = 'ForwardRef(Selectable)'
|