@sanity/ui 3.0.0-static.27 → 3.0.0-static.28
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/README.md +1 -1
- package/dist/_chunks-cjs/_visual-editing.cjs +710 -840
- package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
- package/dist/_chunks-cjs/refractor.cjs +2 -2
- package/dist/_chunks-cjs/refractor.cjs.map +1 -1
- package/dist/_chunks-es/_visual-editing.js +705 -834
- package/dist/_chunks-es/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/refractor.js +1 -1
- package/dist/css/layers.css +4 -0
- package/dist/css/primitives/popover/popover.css +4 -0
- package/dist/css.cjs +58 -49
- package/dist/css.cjs.map +1 -1
- package/dist/css.d.cts +13 -5
- package/dist/css.d.ts +13 -5
- package/dist/css.js +58 -49
- package/dist/css.js.map +1 -1
- package/dist/index.cjs +2006 -1824
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -0
- package/dist/index.d.cts +34 -17
- package/dist/index.d.ts +34 -17
- package/dist/index.js +2002 -1821
- package/dist/index.js.map +1 -1
- package/dist/theme.cjs +7 -7
- package/dist/theme.cjs.map +1 -1
- package/dist/theme.js +7 -7
- package/dist/theme.js.map +1 -1
- package/exports/_visual-editing.ts +1 -1
- package/package.json +10 -15
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
- package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +1 -1
- package/src/core/components/autocomplete/autocomplete.tsx +13 -17
- package/src/core/components/autocomplete/autocompleteOption.tsx +1 -1
- package/src/core/components/autocomplete/constants.ts +3 -1
- package/src/core/components/autocomplete/types.ts +1 -1
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +8 -3
- package/src/core/components/dialog/__workshop__/activate.tsx +11 -3
- package/src/core/components/dialog/__workshop__/panes.tsx +12 -5
- package/src/core/components/dialog/dialog.tsx +12 -6
- package/src/core/components/dialog/dialogCard.tsx +89 -54
- package/src/core/components/dialog/dialogContext.ts +1 -1
- package/src/core/components/dialog/dialogProvider.tsx +1 -1
- package/src/core/components/dialog/index.ts +1 -0
- package/src/core/components/dialog/isTargetWithinScope.ts +1 -1
- package/src/core/components/hotkeys/hotkeys.tsx +3 -2
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +12 -6
- package/src/core/components/menu/__workshop__/customSelectedState.tsx +1 -5
- package/src/core/components/menu/__workshop__/shouldFocus.tsx +1 -2
- package/src/core/components/menu/helpers.ts +1 -1
- package/src/core/components/menu/menu.tsx +6 -3
- package/src/core/components/menu/menuButton.tsx +5 -3
- package/src/core/components/menu/menuDivider.tsx +1 -1
- package/src/core/components/menu/menuGroup.tsx +8 -4
- package/src/core/components/menu/menuItem.tsx +4 -2
- package/src/core/components/tab/tab.tsx +2 -2
- package/src/core/components/tab/tabList.tsx +2 -2
- package/src/core/components/tab/tabPanel.tsx +2 -2
- package/src/core/components/toast/toast.tsx +7 -2
- package/src/core/components/toast/toastLayer.tsx +3 -2
- package/src/core/components/toast/toastProvider.tsx +1 -1
- package/src/core/components/tree/tree.tsx +2 -2
- package/src/core/components/tree/treeGroup.tsx +2 -2
- package/src/core/components/tree/treeItem.tsx +13 -6
- package/src/core/components/tree/types.ts +0 -1
- package/src/core/components/virtualList/virtualList.tsx +10 -5
- package/src/core/helpers/focus.ts +0 -8
- package/src/core/hooks/useArrayProp.ts +1 -1
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +1 -3
- package/src/core/hooks/useElementSize.ts +1 -1
- package/src/core/hooks/useResponsiveProp.ts +1 -1
- package/src/core/index.ts +83 -7
- package/src/core/observers/{elementSizeObserver.ts → elementSize.ts} +1 -1
- package/src/core/primitives/_selectable/index.ts +1 -0
- package/src/core/primitives/_selectable/selectable.tsx +13 -3
- package/src/core/{types/selectable.ts → primitives/_selectable/types.ts} +1 -1
- package/src/core/primitives/arrow/arrow.tsx +1 -1
- package/src/core/primitives/avatar/avatar.tsx +4 -3
- package/src/core/primitives/avatar/avatarCounter.tsx +3 -3
- package/src/core/primitives/avatar/avatarStack.tsx +4 -4
- package/src/core/primitives/avatar/types.ts +17 -0
- package/src/core/primitives/badge/badge.tsx +2 -1
- package/src/core/primitives/badge/types.ts +11 -2
- package/src/core/primitives/box/__workshop__/responsive.tsx +0 -1
- package/src/core/primitives/box/box.tsx +1 -1
- package/src/core/primitives/box/index.ts +1 -0
- package/src/core/primitives/button/__workshop__/disabled.tsx +37 -51
- package/src/core/primitives/button/__workshop__/index.ts +5 -0
- package/src/core/primitives/button/__workshop__/textOverflow.tsx +13 -0
- package/src/core/primitives/button/button.tsx +15 -14
- package/src/core/primitives/button/index.ts +1 -0
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +2 -2
- package/src/core/primitives/card/card.tsx +1 -1
- package/src/core/primitives/card/types.ts +3 -0
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +9 -1
- package/src/core/primitives/checkbox/checkbox.tsx +3 -4
- package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +17 -42
- package/src/core/primitives/code/code.tsx +1 -1
- package/src/core/primitives/container/container.tsx +1 -1
- package/src/core/primitives/flex/flex.tsx +1 -1
- package/src/core/primitives/flex/index.ts +1 -0
- package/src/core/primitives/grid/grid.tsx +1 -1
- package/src/core/primitives/grid/index.ts +1 -0
- package/src/core/primitives/heading/heading.tsx +1 -1
- package/src/core/primitives/inline/inline.tsx +1 -1
- package/src/core/primitives/kbd/kbd.tsx +1 -1
- package/src/core/primitives/label/label.tsx +1 -1
- package/src/core/primitives/layer/layer.test.tsx +1 -1
- package/src/core/primitives/layer/layer.tsx +2 -2
- package/src/core/primitives/layer/layerCard.tsx +3 -3
- package/src/core/primitives/layer/layerProvider.tsx +2 -1
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +12 -10
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +9 -8
- package/src/core/primitives/popover/constants.ts +1 -1
- package/src/core/primitives/popover/floating-ui/size.ts +1 -1
- package/src/core/primitives/popover/popover.tsx +7 -4
- package/src/core/primitives/popover/popoverLayer.tsx +2 -1
- package/src/core/primitives/popover/types.ts +5 -0
- package/src/core/primitives/radio/radio.tsx +2 -2
- package/src/core/primitives/select/select.tsx +2 -2
- package/src/core/{components → primitives}/skeleton/__workshop__/index.ts +1 -1
- package/src/core/{components → primitives}/skeleton/codeSkeleton.tsx +1 -1
- package/src/core/{components → primitives}/skeleton/headingSkeleton.tsx +1 -1
- package/src/core/{components → primitives}/skeleton/labelSkeleton.tsx +1 -1
- package/src/core/{components → primitives}/skeleton/skeleton.tsx +7 -8
- package/src/core/{components → primitives}/skeleton/textSkeleton.tsx +1 -1
- package/src/core/primitives/spinner/spinner.tsx +1 -1
- package/src/core/primitives/srOnly/srOnly.tsx +1 -1
- package/src/core/primitives/stack/stack.tsx +1 -1
- package/src/core/primitives/switch/switch.tsx +1 -6
- package/src/core/primitives/text/__workshop__/colored.tsx +2 -2
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +17 -42
- package/src/core/primitives/text/text.tsx +3 -1
- package/src/core/primitives/textArea/__workshop__/plain.tsx +2 -2
- package/src/core/primitives/textArea/textArea.tsx +2 -2
- package/src/core/primitives/textInput/textInput.tsx +3 -2
- package/src/core/primitives/tooltip/constants.ts +1 -1
- package/src/core/primitives/tooltip/tooltip.tsx +5 -3
- package/src/core/primitives/tooltip/tooltipLayer.tsx +1 -1
- package/src/core/primitives/types.ts +8 -10
- package/src/core/types/radius.ts +1 -1
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +9 -5
- package/src/core/utils/elementQuery/elementQuery.tsx +2 -2
- package/src/core/utils/portal/portal.tsx +1 -1
- package/src/css/components/dialog/dialog.css.ts +26 -1
- package/src/css/components/dialog/dialog.ts +27 -7
- package/src/css/components/skeleton/skeleton.ts +3 -1
- package/src/css/components/skeleton/types.ts +3 -1
- package/src/css/index.ts +75 -5
- package/src/css/primitives/_input/input.ts +2 -1
- package/src/css/primitives/_input/types.ts +2 -1
- package/src/css/primitives/_selectable/_selectable.css.ts +32 -24
- package/src/css/primitives/_selectable/selectable.ts +1 -1
- package/src/css/primitives/_selectable/types.ts +1 -1
- package/src/css/primitives/avatar/avatar.css.ts +8 -4
- package/src/css/primitives/avatar/avatar.ts +1 -1
- package/src/css/primitives/badge/types.ts +0 -2
- package/src/css/primitives/box/box.ts +35 -37
- package/src/css/primitives/box/types.ts +34 -36
- package/src/css/primitives/button/button.css.ts +4 -0
- package/src/css/primitives/button/button.ts +5 -2
- package/src/css/primitives/button/types.ts +4 -11
- package/src/css/primitives/card/__workshop__/color.tsx +70 -0
- package/src/css/primitives/card/__workshop__/index.ts +14 -0
- package/src/css/primitives/card/card.css.ts +4 -0
- package/src/css/primitives/code/code.ts +3 -1
- package/src/css/primitives/code/types.ts +2 -1
- package/src/css/primitives/container/container.ts +3 -1
- package/src/css/primitives/heading/heading.ts +4 -1
- package/src/css/primitives/heading/types.ts +3 -1
- package/src/css/primitives/kbd/kbd.ts +1 -1
- package/src/css/primitives/kbd/types.ts +1 -1
- package/src/css/primitives/label/label.ts +4 -1
- package/src/css/primitives/label/types.ts +3 -1
- package/src/css/primitives/switch/switch.css.ts +1 -1
- package/src/css/primitives/text/text.ts +6 -1
- package/src/css/primitives/text/types.ts +5 -2
- package/src/theme/v3/defaultFonts.ts +6 -6
- package/src/theme/v3/defaultTokens.ts +1 -1
- package/bin/sanity-ui.cjs +0 -5
- package/dist/ui.css +0 -1
- package/src/cli/buildCommand.ts +0 -10
- package/src/cli/index.ts +0 -26
- package/src/core/components/autocomplete/index.ts +0 -2
- package/src/core/components/index.ts +0 -10
- package/src/core/helpers/index.ts +0 -5
- package/src/core/hooks/index.ts +0 -13
- package/src/core/observers/index.ts +0 -2
- package/src/core/primitives/index.ts +0 -30
- package/src/core/types/avatar.ts +0 -16
- package/src/core/types/card.ts +0 -4
- package/src/core/types/index.ts +0 -15
- package/src/core/types/popover.ts +0 -4
- package/src/core/utils/index.ts +0 -4
- package/src/css/__theme/index.ts +0 -16
- package/src/css/__theme/lib/contract/buildVarContract.ts +0 -78
- package/src/css/__theme/lib/contract/index.ts +0 -4
- package/src/css/__theme/lib/contract/types.ts +0 -17
- package/src/css/__theme/resolveTheme.ts +0 -865
- package/src/css/components/index.ts +0 -6
- package/src/css/primitives/index.ts +0 -24
- package/src/css/props/index.ts +0 -37
- package/src/css/utils/srOnly/index.ts +0 -1
- /package/src/core/{global.ts → __DEV__.ts} +0 -0
- /package/src/core/{types/dialog.ts → components/dialog/types.ts} +0 -0
- /package/src/core/observers/{resizeObserver.ts → resize.ts} +0 -0
- /package/src/core/{types/badge.ts → primitives/badge/types2.ts} +0 -0
- /package/src/core/{types/box.ts → primitives/box/types.ts} +0 -0
- /package/src/core/{types/button.ts → primitives/button/types.ts} +0 -0
- /package/src/core/{types/flex.ts → primitives/flex/types.ts} +0 -0
- /package/src/core/{types/grid.ts → primitives/grid/types.ts} +0 -0
- /package/src/core/{components → primitives}/skeleton/__workshop__/delay.tsx +0 -0
- /package/src/core/{components → primitives}/skeleton/__workshop__/skeleton.tsx +0 -0
- /package/src/core/{components → primitives}/skeleton/index.ts +0 -0
- /package/src/core/types/{text.ts → textAlign.ts} +0 -0
- /package/src/css/{utils → primitives/srOnly}/index.ts +0 -0
- /package/src/css/{utils → primitives}/srOnly/srOnly.css.ts +0 -0
- /package/src/css/{utils → primitives}/srOnly/srOnly.ts +0 -0
|
@@ -13,9 +13,12 @@ import {
|
|
|
13
13
|
} from 'react'
|
|
14
14
|
import {isValidElementType} from 'react-is'
|
|
15
15
|
|
|
16
|
-
import {Box, Flex, Popover, type PopoverProps, Text} from '../../primitives'
|
|
17
16
|
import {Selectable} from '../../primitives/_selectable'
|
|
18
|
-
import
|
|
17
|
+
import {Box} from '../../primitives/box'
|
|
18
|
+
import {Flex} from '../../primitives/flex'
|
|
19
|
+
import {Popover, type PopoverProps} from '../../primitives/popover'
|
|
20
|
+
import {Text} from '../../primitives/text'
|
|
21
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
19
22
|
import {DEFAULT_MENU_ELEMENT, Menu, type MenuProps} from './menu'
|
|
20
23
|
import {useMenu} from './useMenu'
|
|
21
24
|
|
|
@@ -199,13 +202,14 @@ export function MenuGroup<E extends MenuGroupElementType = typeof DEFAULT_MENU_G
|
|
|
199
202
|
{...rest}
|
|
200
203
|
aria-pressed={as === 'button' ? withinMenu : undefined}
|
|
201
204
|
as={as}
|
|
202
|
-
data-pressed={as !== 'button' ? withinMenu : undefined}
|
|
203
|
-
data-selected={!withinMenu && active ? '' : undefined}
|
|
205
|
+
// data-pressed={as !== 'button' ? withinMenu : undefined}
|
|
206
|
+
// data-selected={!withinMenu && active ? '' : undefined}
|
|
204
207
|
onClick={handleClick}
|
|
205
208
|
onKeyDown={handleKeyDown}
|
|
206
209
|
onMouseEnter={handleMouseEnter}
|
|
207
210
|
radius={radius}
|
|
208
211
|
ref={setRootElement}
|
|
212
|
+
selected={withinMenu}
|
|
209
213
|
tabIndex={-1}
|
|
210
214
|
tone={tone}
|
|
211
215
|
type={as === 'button' ? 'button' : undefined}
|
|
@@ -19,9 +19,11 @@ import {
|
|
|
19
19
|
} from 'react'
|
|
20
20
|
import {isValidElementType} from 'react-is'
|
|
21
21
|
|
|
22
|
-
import {Box, Flex, Text} from '../../primitives'
|
|
23
22
|
import {Selectable} from '../../primitives/_selectable'
|
|
24
|
-
import
|
|
23
|
+
import {Box} from '../../primitives/box'
|
|
24
|
+
import {Flex} from '../../primitives/flex'
|
|
25
|
+
import {Text} from '../../primitives/text'
|
|
26
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
25
27
|
import {Hotkeys} from '../hotkeys'
|
|
26
28
|
import {useMenu} from './useMenu'
|
|
27
29
|
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
useRef,
|
|
11
11
|
} from 'react'
|
|
12
12
|
|
|
13
|
-
import {Button} from '../../primitives'
|
|
14
|
-
import type {ComponentType, Props} from '../../types'
|
|
13
|
+
import {Button} from '../../primitives/button'
|
|
14
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
15
15
|
|
|
16
16
|
/** @public */
|
|
17
17
|
export const DEFAULT_TAB_ELEMENT = 'button'
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
useState,
|
|
10
10
|
} from 'react'
|
|
11
11
|
|
|
12
|
-
import {Flex, type FlexOwnProps} from '../../primitives'
|
|
13
|
-
import type {ComponentType, Props} from '../../types'
|
|
12
|
+
import {Flex, type FlexOwnProps} from '../../primitives/flex'
|
|
13
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
14
14
|
import type {TabProps} from './tab'
|
|
15
15
|
|
|
16
16
|
/** @public */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {Box, type BoxOwnProps} from '../../primitives'
|
|
2
|
-
import type {ComponentType, Props} from '../../types'
|
|
1
|
+
import {Box, type BoxOwnProps} from '../../primitives/box'
|
|
2
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
3
3
|
|
|
4
4
|
/** @public */
|
|
5
5
|
export const DEFAULT_TAB_PANEL_ELEMENT = 'div'
|
|
@@ -4,8 +4,13 @@ import {motion, type Variant, type Variants} from 'framer-motion'
|
|
|
4
4
|
import type {ReactNode} from 'react'
|
|
5
5
|
|
|
6
6
|
import {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'
|
|
7
|
-
import {Box
|
|
8
|
-
import
|
|
7
|
+
import {Box} from '../../primitives/box'
|
|
8
|
+
import {Button} from '../../primitives/button'
|
|
9
|
+
import {Card} from '../../primitives/card'
|
|
10
|
+
import {Flex} from '../../primitives/flex'
|
|
11
|
+
import {Stack} from '../../primitives/stack'
|
|
12
|
+
import {Text} from '../../primitives/text'
|
|
13
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
9
14
|
|
|
10
15
|
/** @public */
|
|
11
16
|
export const DEFAULT_TOAST_ELEMENT = 'li'
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {type GapStyleProps, type PaddingStyleProps, toastLayer} from '@sanity/ui/css'
|
|
2
2
|
|
|
3
|
-
import {Grid
|
|
4
|
-
import
|
|
3
|
+
import {Grid} from '../../primitives/grid'
|
|
4
|
+
import {useLayer} from '../../primitives/layer'
|
|
5
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
5
6
|
|
|
6
7
|
/** @internal */
|
|
7
8
|
export const DEFAULT_TOAST_LAYER_ELEMENT = 'ul'
|
|
@@ -3,7 +3,7 @@ import {AnimatePresence} from 'framer-motion'
|
|
|
3
3
|
import {startTransition, useMemo, useState} from 'react'
|
|
4
4
|
|
|
5
5
|
import {useMounted} from '../../hooks/useMounted'
|
|
6
|
-
import {LayerProvider} from '../../primitives'
|
|
6
|
+
import {LayerProvider} from '../../primitives/layer'
|
|
7
7
|
import {Toast} from './toast'
|
|
8
8
|
import {ToastContext} from './toastContext'
|
|
9
9
|
import {ToastLayer, type ToastLayerProps} from './toastLayer'
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
useState,
|
|
12
12
|
} from 'react'
|
|
13
13
|
|
|
14
|
-
import {Stack} from '../../primitives'
|
|
15
|
-
import type {ComponentType, Props} from '../../types'
|
|
14
|
+
import {Stack} from '../../primitives/stack'
|
|
15
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
16
16
|
import {_findNextItemElement, _findPrevItemElement, _focusItemElement} from './helpers'
|
|
17
17
|
import {TreeContext} from './treeContext'
|
|
18
18
|
import type {TreeContextValue, TreeState} from './types'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {memo, type ReactElement} from 'react'
|
|
2
2
|
|
|
3
|
-
import {Stack} from '../../primitives'
|
|
4
|
-
import type {ComponentType, Props} from '../../types'
|
|
3
|
+
import {Stack} from '../../primitives/stack'
|
|
4
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
5
5
|
import {useTree} from './useTree'
|
|
6
6
|
|
|
7
7
|
/** @public */
|
|
@@ -15,9 +15,12 @@ import {
|
|
|
15
15
|
useRef,
|
|
16
16
|
} from 'react'
|
|
17
17
|
|
|
18
|
-
import {Box, type BoxProps, type CardOwnProps, Flex, Text} from '../../primitives'
|
|
19
18
|
import {Selectable, type SelectableElementType} from '../../primitives/_selectable'
|
|
20
|
-
import
|
|
19
|
+
import {Box, type BoxProps} from '../../primitives/box'
|
|
20
|
+
import type {CardOwnProps} from '../../primitives/card'
|
|
21
|
+
import {Flex} from '../../primitives/flex'
|
|
22
|
+
import {Text} from '../../primitives/text'
|
|
23
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
21
24
|
import {TreeContext} from './treeContext'
|
|
22
25
|
import {TreeGroup} from './treeGroup'
|
|
23
26
|
import {useTree} from './useTree'
|
|
@@ -32,6 +35,7 @@ export type TreeItemOwnProps = CardOwnProps & {
|
|
|
32
35
|
icon?: ElementType
|
|
33
36
|
/**
|
|
34
37
|
* Allows passing a custom element type to the link component
|
|
38
|
+
* @internal
|
|
35
39
|
*/
|
|
36
40
|
linkAs?: SelectableElementType
|
|
37
41
|
onClick?: MouseEventHandler<HTMLAnchorElement | HTMLLIElement>
|
|
@@ -86,9 +90,9 @@ export function TreeItem<E extends TreeItemElementType = typeof DEFAULT_TREE_ITE
|
|
|
86
90
|
const itemPath = useMemo(() => path.concat([id || '']), [id, path])
|
|
87
91
|
const itemKey = itemPath.join('/')
|
|
88
92
|
const itemState = tree.state[itemKey]
|
|
89
|
-
const focused = tree.focusedElement === rootRef.current
|
|
90
93
|
const expanded = itemState?.expanded === undefined ? expandedProp : itemState?.expanded || false
|
|
91
|
-
const
|
|
94
|
+
const focused = tree.focusedElement && tree.focusedElement === rootRef.current
|
|
95
|
+
const tabIndex = focused ? 0 : -1
|
|
92
96
|
const contextValue = useMemo(
|
|
93
97
|
() => ({...tree, level: tree.level + 1, path: itemPath}),
|
|
94
98
|
[itemPath, tree],
|
|
@@ -174,12 +178,13 @@ export function TreeItem<E extends TreeItemElementType = typeof DEFAULT_TREE_ITE
|
|
|
174
178
|
<Selectable
|
|
175
179
|
aria-expanded={expanded}
|
|
176
180
|
as={linkAs}
|
|
177
|
-
data-pressed={selected ? '' : undefined}
|
|
181
|
+
// data-pressed={selected ? '' : undefined}
|
|
178
182
|
data-ui="TreeItem__box"
|
|
179
183
|
href={href}
|
|
180
184
|
radius={radius}
|
|
181
185
|
ref={treeitemRef}
|
|
182
186
|
role="treeitem"
|
|
187
|
+
selected={selected}
|
|
183
188
|
tabIndex={tabIndex}
|
|
184
189
|
style={{
|
|
185
190
|
paddingLeft: `calc(${vars.space[2]} * ${tree.level})`,
|
|
@@ -212,9 +217,11 @@ export function TreeItem<E extends TreeItemElementType = typeof DEFAULT_TREE_ITE
|
|
|
212
217
|
>
|
|
213
218
|
<Selectable
|
|
214
219
|
as="button"
|
|
215
|
-
data-pressed={selected ? '' : undefined}
|
|
220
|
+
// data-pressed={selected ? '' : undefined}
|
|
221
|
+
data-focused={focused ? '' : undefined}
|
|
216
222
|
data-ui="TreeItem__box"
|
|
217
223
|
radius={radius}
|
|
224
|
+
selected={selected}
|
|
218
225
|
style={{
|
|
219
226
|
paddingLeft: `calc(${vars.space[2]} * ${tree.level})`,
|
|
220
227
|
}}
|
|
@@ -19,7 +19,6 @@ export interface TreeContextValue {
|
|
|
19
19
|
registerItem: (element: HTMLElement, path: string, expanded: boolean, selected: boolean) => void
|
|
20
20
|
setExpanded: (path: string, expanded: boolean) => void
|
|
21
21
|
setFocusedElement: (focusedElement: HTMLElement | null) => void
|
|
22
|
-
// space: number | number[]
|
|
23
22
|
space: ResponsiveProp<Space>
|
|
24
23
|
state: TreeState
|
|
25
24
|
}
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
useState,
|
|
11
11
|
} from 'react'
|
|
12
12
|
|
|
13
|
-
import {_isScrollable} from '../../helpers'
|
|
14
|
-
import {_ResizeObserver} from '../../observers'
|
|
15
|
-
import {Box} from '../../primitives'
|
|
16
|
-
import type {ComponentType, Props} from '../../types'
|
|
13
|
+
import {_isScrollable} from '../../helpers/scroll'
|
|
14
|
+
import {_ResizeObserver} from '../../observers/resize'
|
|
15
|
+
import {Box} from '../../primitives/box'
|
|
16
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
17
17
|
|
|
18
18
|
/** @beta */
|
|
19
19
|
export const DEFAULT_VIRTUAL_LIST_ELEMENT = 'div'
|
|
@@ -139,6 +139,11 @@ export function VirtualList<E extends VirtualListElementType = typeof DEFAULT_VI
|
|
|
139
139
|
})
|
|
140
140
|
}, [fromIndex, gapValue, itemHeight, onChange, scrollHeight, scrollTop, toIndex])
|
|
141
141
|
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
// console.log('renderItem', renderItem)
|
|
144
|
+
setItemHeight(-1)
|
|
145
|
+
}, [renderItem])
|
|
146
|
+
|
|
142
147
|
const children = useMemo(() => {
|
|
143
148
|
if (!renderItem || items.length === 0) return null
|
|
144
149
|
|
|
@@ -174,7 +179,7 @@ export function VirtualList<E extends VirtualListElementType = typeof DEFAULT_VI
|
|
|
174
179
|
insetRight={0}
|
|
175
180
|
key={key}
|
|
176
181
|
position="absolute"
|
|
177
|
-
style={{top: itemIndex * (itemHeight + gapValue)
|
|
182
|
+
style={{top: itemIndex * (itemHeight + gapValue)}}
|
|
178
183
|
>
|
|
179
184
|
{node}
|
|
180
185
|
</Box>
|
|
@@ -7,10 +7,6 @@ import {
|
|
|
7
7
|
isHTMLTextAreaElement,
|
|
8
8
|
} from './element'
|
|
9
9
|
|
|
10
|
-
// export const globalFocusState = {
|
|
11
|
-
// IgnoreUtilFocusChanges: false,
|
|
12
|
-
// }
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* @internal
|
|
16
12
|
*/
|
|
@@ -56,16 +52,12 @@ export function attemptFocus(element: HTMLElement): boolean {
|
|
|
56
52
|
return false
|
|
57
53
|
}
|
|
58
54
|
|
|
59
|
-
// globalFocusState.IgnoreUtilFocusChanges = true
|
|
60
|
-
|
|
61
55
|
try {
|
|
62
56
|
element.focus()
|
|
63
57
|
} catch {
|
|
64
58
|
// ignore
|
|
65
59
|
}
|
|
66
60
|
|
|
67
|
-
// globalFocusState.IgnoreUtilFocusChanges = false
|
|
68
|
-
|
|
69
61
|
return document.activeElement === element
|
|
70
62
|
}
|
|
71
63
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {Box, Card, Code, Container, Stack, Text, useElementRect} from '@sanity/ui'
|
|
1
|
+
import {Box, Card, Code, Container, Grid, Stack, Text, useElementRect} from '@sanity/ui'
|
|
2
2
|
import {useState} from 'react'
|
|
3
3
|
|
|
4
|
-
import {Grid} from '../../../primitives'
|
|
5
|
-
|
|
6
4
|
export default function ExampleStory() {
|
|
7
5
|
const [element, setElement] = useState<HTMLElement | null>(null)
|
|
8
6
|
const rect = useElementRect(element)
|
package/src/core/index.ts
CHANGED
|
@@ -1,8 +1,84 @@
|
|
|
1
1
|
export * from './_compat'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
2
|
+
|
|
3
|
+
// components
|
|
4
|
+
export * from './components/autocomplete/autocomplete'
|
|
5
|
+
export * from './components/autocomplete/types'
|
|
6
|
+
export * from './components/breadcrumbs'
|
|
7
|
+
export * from './components/dialog'
|
|
8
|
+
export * from './components/hotkeys'
|
|
9
|
+
export * from './components/menu'
|
|
10
|
+
export * from './components/tab'
|
|
11
|
+
export * from './components/toast'
|
|
12
|
+
export * from './components/tree'
|
|
13
|
+
export * from './components/virtualList'
|
|
14
|
+
|
|
15
|
+
// helpers
|
|
16
|
+
export * from './helpers/animation'
|
|
17
|
+
export * from './helpers/element'
|
|
18
|
+
export * from './helpers/focus'
|
|
19
|
+
export * from './helpers/props'
|
|
20
|
+
export * from './helpers/scroll'
|
|
21
|
+
|
|
22
|
+
// hooks
|
|
23
|
+
export * from './hooks/useArrayProp'
|
|
24
|
+
export * from './hooks/useClickOutside'
|
|
25
|
+
export * from './hooks/useClickOutsideEvent'
|
|
26
|
+
export * from './hooks/useCustomValidity'
|
|
27
|
+
export * from './hooks/useElementRect'
|
|
28
|
+
export * from './hooks/useElementSize'
|
|
29
|
+
export * from './hooks/useForwardedRef'
|
|
30
|
+
export * from './hooks/useGlobalKeyDown'
|
|
31
|
+
export * from './hooks/useMatchMedia'
|
|
32
|
+
export * from './hooks/useMediaIndex'
|
|
33
|
+
export * from './hooks/usePrefersDark'
|
|
34
|
+
export * from './hooks/usePrefersReducedMotion'
|
|
35
|
+
export * from './hooks/useResponsiveProp'
|
|
36
|
+
|
|
37
|
+
// observers
|
|
38
|
+
export * from './observers/elementSize'
|
|
39
|
+
export * from './observers/resize'
|
|
40
|
+
|
|
41
|
+
// primitives
|
|
42
|
+
export * from './primitives/_selectable'
|
|
43
|
+
export * from './primitives/arrow'
|
|
44
|
+
export * from './primitives/avatar'
|
|
45
|
+
export * from './primitives/badge'
|
|
46
|
+
export * from './primitives/box'
|
|
47
|
+
export * from './primitives/button'
|
|
48
|
+
export * from './primitives/card'
|
|
49
|
+
export * from './primitives/checkbox'
|
|
50
|
+
export * from './primitives/code'
|
|
51
|
+
export * from './primitives/container'
|
|
52
|
+
export * from './primitives/flex'
|
|
53
|
+
export * from './primitives/grid'
|
|
54
|
+
export * from './primitives/heading'
|
|
55
|
+
export * from './primitives/inline'
|
|
56
|
+
export * from './primitives/kbd'
|
|
57
|
+
export * from './primitives/label'
|
|
58
|
+
export * from './primitives/layer'
|
|
59
|
+
export * from './primitives/popover'
|
|
60
|
+
export * from './primitives/radio'
|
|
61
|
+
export * from './primitives/select'
|
|
62
|
+
export * from './primitives/skeleton'
|
|
63
|
+
export * from './primitives/spinner'
|
|
64
|
+
export * from './primitives/srOnly'
|
|
65
|
+
export * from './primitives/stack'
|
|
66
|
+
export * from './primitives/switch'
|
|
67
|
+
export * from './primitives/text'
|
|
68
|
+
export * from './primitives/textArea'
|
|
69
|
+
export * from './primitives/textInput'
|
|
70
|
+
export * from './primitives/tooltip'
|
|
71
|
+
export * from './primitives/types'
|
|
72
|
+
|
|
73
|
+
// utils
|
|
74
|
+
export * from './utils/boundaryElement'
|
|
75
|
+
export * from './utils/elementQuery'
|
|
76
|
+
export * from './utils/errorBoundary'
|
|
77
|
+
export * from './utils/portal'
|
|
78
|
+
|
|
79
|
+
// types
|
|
80
|
+
export * from './types/gridItem'
|
|
81
|
+
export * from './types/placement'
|
|
82
|
+
export * from './types/props'
|
|
83
|
+
export * from './types/radius'
|
|
84
|
+
export * from './types/textAlign'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {_selectable, type SelectableStyleProps} from '@sanity/ui/css'
|
|
2
|
+
import type {ThemeColorStateToneKey} from '@sanity/ui/theme'
|
|
2
3
|
|
|
3
|
-
import type {ComponentType, Props
|
|
4
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
4
5
|
import {Box, type BoxOwnProps} from '../box'
|
|
5
6
|
|
|
6
7
|
/** @internal */
|
|
@@ -11,7 +12,8 @@ export type SelectableOwnProps = BoxOwnProps &
|
|
|
11
12
|
SelectableStyleProps & {
|
|
12
13
|
disabled?: boolean
|
|
13
14
|
href?: string
|
|
14
|
-
|
|
15
|
+
selected?: boolean
|
|
16
|
+
tone?: ThemeColorStateToneKey
|
|
15
17
|
type?: 'button'
|
|
16
18
|
}
|
|
17
19
|
|
|
@@ -32,9 +34,17 @@ export function Selectable<E extends SelectableElementType = typeof DEFAULT_SELE
|
|
|
32
34
|
as = DEFAULT_SELECTABLE_ELEMENT,
|
|
33
35
|
className,
|
|
34
36
|
radius,
|
|
37
|
+
selected,
|
|
35
38
|
tone,
|
|
36
39
|
...rest
|
|
37
40
|
} = props as SelectableProps<typeof DEFAULT_SELECTABLE_ELEMENT>
|
|
38
41
|
|
|
39
|
-
return
|
|
42
|
+
return (
|
|
43
|
+
<Box
|
|
44
|
+
{...rest}
|
|
45
|
+
as={as}
|
|
46
|
+
className={_selectable({className, radius, tone})}
|
|
47
|
+
data-selected={selected ? '' : undefined}
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
40
50
|
}
|
|
@@ -2,7 +2,7 @@ import {_arrow, _arrowShape, _arrowStroke, _arrowStrokeMask, _arrowSvg, vars} fr
|
|
|
2
2
|
import {assignInlineVars} from '@vanilla-extract/dynamic'
|
|
3
3
|
import {useMemo} from 'react'
|
|
4
4
|
|
|
5
|
-
import type {ComponentType, Props} from '../../types'
|
|
5
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
6
6
|
import {compileCommands, getRoundedCommands, type Point} from './cmds'
|
|
7
7
|
|
|
8
8
|
/** @internal */
|
|
@@ -6,13 +6,14 @@ import {
|
|
|
6
6
|
avatarInitials,
|
|
7
7
|
type ResponsiveProp,
|
|
8
8
|
} from '@sanity/ui/css'
|
|
9
|
-
import type {AvatarColor, FontLabelSize} from '@sanity/ui/theme'
|
|
9
|
+
import type {AvatarColor, AvatarSize, FontLabelSize} from '@sanity/ui/theme'
|
|
10
10
|
import {useCallback, useEffect, useMemo, useState} from 'react'
|
|
11
11
|
|
|
12
|
-
import {useResponsiveProp} from '../../hooks'
|
|
13
|
-
import type {
|
|
12
|
+
import {useResponsiveProp} from '../../hooks/useResponsiveProp'
|
|
13
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
14
14
|
import {Box} from '../box'
|
|
15
15
|
import {Label} from '../label'
|
|
16
|
+
import type {AvatarPosition, AvatarStatus} from './types'
|
|
16
17
|
|
|
17
18
|
/** @public */
|
|
18
19
|
export const DEFAULT_AVATAR_ELEMENT = 'span'
|
|
@@ -2,13 +2,13 @@ import {avatarCounter, type ResponsiveProp} from '@sanity/ui/css'
|
|
|
2
2
|
import type {AvatarSize, FontLabelSize} from '@sanity/ui/theme'
|
|
3
3
|
import {useMemo} from 'react'
|
|
4
4
|
|
|
5
|
-
import {useResponsiveProp} from '../../hooks'
|
|
6
|
-
import type {ComponentType, Props} from '../../types'
|
|
5
|
+
import {useResponsiveProp} from '../../hooks/useResponsiveProp'
|
|
6
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
7
7
|
import {Box} from '../box'
|
|
8
8
|
import {Label} from '../label'
|
|
9
9
|
|
|
10
10
|
/** @public */
|
|
11
|
-
export const DEFAULT_AVATAR_COUNTER_ELEMENT = '
|
|
11
|
+
export const DEFAULT_AVATAR_COUNTER_ELEMENT = 'span'
|
|
12
12
|
|
|
13
13
|
/** @public */
|
|
14
14
|
export interface AvatarCounterOwnProps {
|
|
@@ -2,14 +2,14 @@ import {avatarStack, type ResponsiveProp} from '@sanity/ui/css'
|
|
|
2
2
|
import type {AvatarSize} from '@sanity/ui/theme'
|
|
3
3
|
import {Children, cloneElement, Fragment, isValidElement, type ReactElement} from 'react'
|
|
4
4
|
|
|
5
|
-
import {useResponsiveProp} from '../../hooks'
|
|
6
|
-
import type {ComponentType, Props} from '../../types'
|
|
5
|
+
import {useResponsiveProp} from '../../hooks/useResponsiveProp'
|
|
6
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
7
7
|
import {Box, type BoxOwnProps} from '../box'
|
|
8
8
|
import type {AvatarProps} from './avatar'
|
|
9
9
|
import {AvatarCounter} from './avatarCounter'
|
|
10
10
|
|
|
11
11
|
/** @public */
|
|
12
|
-
export const DEFAULT_AVATAR_STACK_ELEMENT = '
|
|
12
|
+
export const DEFAULT_AVATAR_STACK_ELEMENT = 'span'
|
|
13
13
|
|
|
14
14
|
/** @public */
|
|
15
15
|
export type AvatarStackChild = ReactElement<AvatarProps<'div'>> | null | undefined | false
|
|
@@ -49,7 +49,7 @@ export function AvatarStack<E extends AvatarStackElementType = typeof DEFAULT_AV
|
|
|
49
49
|
} = props as AvatarStackProps<typeof DEFAULT_AVATAR_STACK_ELEMENT>
|
|
50
50
|
|
|
51
51
|
const children = Children.toArray(childrenProp).filter(isValidElement) as ReactElement<
|
|
52
|
-
AvatarProps<'
|
|
52
|
+
AvatarProps<'span'>
|
|
53
53
|
>[]
|
|
54
54
|
const maxLength = Math.max(maxLengthProp, 0)
|
|
55
55
|
const size = useResponsiveProp(sizeProp)
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import type {AvatarSize, ThemeColorAvatarColorKey} from '@sanity/ui/theme'
|
|
2
2
|
|
|
3
|
+
export {
|
|
4
|
+
/** @deprecated Use `AvatarSize` from `@sanity/ui/theme' instead. */
|
|
5
|
+
type AvatarSize,
|
|
6
|
+
} from '@sanity/ui/theme'
|
|
7
|
+
|
|
8
|
+
/** @public */
|
|
9
|
+
export type AvatarPosition = 'top' | 'bottom' | 'inside'
|
|
10
|
+
|
|
11
|
+
/** @public */
|
|
12
|
+
// export type AvatarSize = 0 | 1 | 2 | 3
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
* @deprecated Will be removed in next major version.
|
|
17
|
+
*/
|
|
18
|
+
export type AvatarStatus = 'online' | 'editing' | 'inactive'
|
|
19
|
+
|
|
3
20
|
/**
|
|
4
21
|
* @internal
|
|
5
22
|
* @deprecated This will be removed in next major version.
|
|
@@ -2,9 +2,10 @@ import type {PaddingStyleProps, RadiusStyleProps, ResponsiveProp} from '@sanity/
|
|
|
2
2
|
import {badge} from '@sanity/ui/css'
|
|
3
3
|
import type {FontTextSize} from '@sanity/ui/theme'
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
6
6
|
import {Box} from '../box'
|
|
7
7
|
import {Text} from '../text'
|
|
8
|
+
import type {BadgeTone} from './types'
|
|
8
9
|
|
|
9
10
|
/** @public */
|
|
10
11
|
export const DEFAULT_BADGE_ELEMENT = 'span'
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {ThemeColorStateToneKey} from '@sanity/ui/theme'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @deprecated Will be removed in next major version.
|
|
6
|
+
*/
|
|
7
|
+
export type BadgeMode = 'default' | 'outline'
|
|
8
|
+
|
|
9
|
+
/** @public */
|
|
10
|
+
export type BadgeTone = ThemeColorStateToneKey
|
|
2
11
|
|
|
3
12
|
/**
|
|
4
13
|
* @internal
|
|
5
|
-
* @deprecated
|
|
14
|
+
* @deprecated Will be removed in next major version.
|
|
6
15
|
*/
|
|
7
16
|
export interface BadgeStyleProps {
|
|
8
17
|
$tone: BadgeTone
|
|
@@ -9,7 +9,6 @@ export default function ResponsiveStory() {
|
|
|
9
9
|
display={['none', 'block', 'none', 'block', 'none', 'block', 'none']}
|
|
10
10
|
flex={[1, 2, 3, 4, 5, 6, 7]}
|
|
11
11
|
padding={3}
|
|
12
|
-
sizing={['content', 'border', 'content', 'border', 'content', 'border', 'content']}
|
|
13
12
|
style={{outline: `1px solid ${vars.color.border}`}}
|
|
14
13
|
>
|
|
15
14
|
<Text align="center" muted>
|