@sanity/ui 3.0.0-static.27 → 3.0.0-static.29
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 +5 -8
- package/dist/_chunks-cjs/_visual-editing.cjs +744 -874
- 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 +788 -917
- package/dist/_chunks-es/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/refractor.js +1 -1
- package/dist/{css.cjs → css/index.cjs} +72 -53
- package/dist/css/index.cjs.map +1 -0
- package/dist/css/index.css +1 -0
- package/dist/{css.d.ts → css/index.d.cts} +26 -8
- package/dist/{css.d.cts → css/index.d.ts} +26 -8
- package/dist/{css.js → css/index.js} +72 -53
- package/dist/css/index.js.map +1 -0
- package/dist/css/layers.css +4 -0
- package/dist/css/primitives/popover/popover.css +4 -0
- package/dist/index.cjs +2049 -1811
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -26
- package/dist/index.d.ts +62 -26
- package/dist/index.js +2056 -1819
- 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 +14 -19
- 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 +15 -19
- 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 +21 -17
- package/src/core/components/toast/toastLayer.tsx +3 -2
- package/src/core/components/toast/toastProvider.tsx +15 -11
- 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 +84 -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/root/Root.tsx +89 -0
- package/src/core/primitives/root/__workshop__/boundary.tsx +5 -0
- package/src/core/primitives/root/__workshop__/index.ts +8 -0
- package/src/core/primitives/root/index.ts +1 -0
- 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/components/toast/toast.css.ts +1 -0
- package/src/css/defaultTheme.css.ts +55 -2
- package/src/css/index.ts +77 -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/root/index.ts +2 -0
- package/src/css/primitives/root/root.css.ts +15 -0
- package/src/css/primitives/root/root.ts +17 -0
- package/src/css/primitives/root/types.ts +10 -0
- 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/css.cjs.map +0 -1
- package/dist/css.js.map +0 -1
- 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
|
@@ -1,18 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BoundaryElementProvider,
|
|
3
|
+
Box,
|
|
4
|
+
Card,
|
|
5
|
+
type CardTone,
|
|
6
|
+
Flex,
|
|
7
|
+
Popover,
|
|
8
|
+
type PopoverProps,
|
|
9
|
+
type PopoverUpdateCallback,
|
|
10
|
+
Stack,
|
|
11
|
+
Text,
|
|
12
|
+
} from '@sanity/ui'
|
|
1
13
|
import {useSelect} from '@sanity/ui-workshop'
|
|
2
14
|
import {useCallback, useEffect, useRef, useState} from 'react'
|
|
3
15
|
|
|
4
16
|
import {WORKSHOP_CARD_TONE_OPTIONS} from '$workshop'
|
|
5
17
|
|
|
6
|
-
import type {CardTone} from '../../../types'
|
|
7
|
-
import {BoundaryElementProvider} from '../../../utils'
|
|
8
|
-
import {Box} from '../../box'
|
|
9
|
-
import {Card} from '../../card'
|
|
10
|
-
import {Flex} from '../../flex'
|
|
11
|
-
import {Stack} from '../../stack'
|
|
12
|
-
import {Text} from '../../text'
|
|
13
|
-
import {Popover, type PopoverProps} from '../popover'
|
|
14
|
-
import type {PopoverUpdateCallback} from '../types'
|
|
15
|
-
|
|
16
18
|
const SIDE_PANEL_WIDTH = {
|
|
17
19
|
sm: 300,
|
|
18
20
|
md: 400,
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BoundaryElementProvider,
|
|
3
|
+
Button,
|
|
4
|
+
Card,
|
|
5
|
+
Popover,
|
|
6
|
+
type PopoverUpdateCallback,
|
|
7
|
+
PortalProvider,
|
|
8
|
+
Text,
|
|
9
|
+
} from '@sanity/ui'
|
|
1
10
|
import {useBoolean, useSelect, useText} from '@sanity/ui-workshop'
|
|
2
11
|
import {useRef, useState} from 'react'
|
|
3
12
|
|
|
4
13
|
import {
|
|
5
14
|
WORKSHOP_CONTAINER_WIDTH_OPTIONS,
|
|
6
|
-
// WORKSHOP_CONTAINER_WIDTH_OPTIONS,
|
|
7
15
|
WORKSHOP_PLACEMENT_OPTIONS,
|
|
8
16
|
WORKSHOP_RADIUS_OPTIONS,
|
|
9
17
|
} from '$workshop'
|
|
10
18
|
|
|
11
|
-
import {BoundaryElementProvider, PortalProvider} from '../../../utils'
|
|
12
|
-
import {Button} from '../../button'
|
|
13
|
-
import {Card} from '../../card'
|
|
14
|
-
import {Text} from '../../text'
|
|
15
|
-
import {Popover} from '../popover'
|
|
16
|
-
import type {PopoverUpdateCallback} from '../types'
|
|
17
|
-
|
|
18
19
|
export default function TestStory(): React.JSX.Element {
|
|
19
20
|
const [portalElement, setPortalElement] = useState<HTMLDivElement | null>(null)
|
|
20
21
|
const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)
|
|
@@ -25,10 +25,13 @@ import {
|
|
|
25
25
|
} from 'react'
|
|
26
26
|
|
|
27
27
|
import {Z_OFFSETS} from '../../constants'
|
|
28
|
-
import {usePrefersReducedMotion
|
|
28
|
+
import {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'
|
|
29
|
+
import {useResponsiveProp} from '../../hooks/useResponsiveProp'
|
|
29
30
|
import {origin} from '../../middleware/origin'
|
|
30
|
-
import type {
|
|
31
|
-
import {
|
|
31
|
+
import type {Placement} from '../../types/placement'
|
|
32
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
33
|
+
import {useBoundaryElement} from '../../utils/boundaryElement'
|
|
34
|
+
import {Portal} from '../../utils/portal'
|
|
32
35
|
import {CardProvider, useCard} from '../card'
|
|
33
36
|
import {type LayerOwnProps, useLayer} from '../layer'
|
|
34
37
|
import {
|
|
@@ -39,7 +42,7 @@ import {
|
|
|
39
42
|
} from './constants'
|
|
40
43
|
import {size} from './floating-ui/size'
|
|
41
44
|
import {PopoverLayer} from './popoverLayer'
|
|
42
|
-
import type {PopoverUpdateCallback} from './types'
|
|
45
|
+
import type {PopoverMargins, PopoverUpdateCallback} from './types'
|
|
43
46
|
|
|
44
47
|
/** @public */
|
|
45
48
|
export const DEFAULT_POPOVER_ELEMENT = 'div'
|
|
@@ -4,7 +4,7 @@ import {motion} from 'framer-motion'
|
|
|
4
4
|
import {type CSSProperties, type ForwardedRef, useMemo} from 'react'
|
|
5
5
|
|
|
6
6
|
import {POPOVER_MOTION_PROPS} from '../../constants'
|
|
7
|
-
import type {Placement
|
|
7
|
+
import type {Placement} from '../../types/placement'
|
|
8
8
|
import {Arrow} from '../arrow'
|
|
9
9
|
import {Flex} from '../flex'
|
|
10
10
|
import {Layer, type LayerOwnProps, type LayerProps} from '../layer'
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
DEFAULT_POPOVER_ARROW_WIDTH,
|
|
15
15
|
DEFAULT_POPOVER_MARGINS,
|
|
16
16
|
} from './constants'
|
|
17
|
+
import type {PopoverMargins} from './types'
|
|
17
18
|
|
|
18
19
|
/** @internal */
|
|
19
20
|
export const DEFAULT_POPOVER_LAYER_ELEMENT = 'div'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {radio, radioInput, radioPresentation} from '@sanity/ui/css'
|
|
2
2
|
import {useImperativeHandle, useRef} from 'react'
|
|
3
3
|
|
|
4
|
-
import {useCustomValidity} from '../../hooks'
|
|
5
|
-
import type {ComponentType, Props} from '../../types'
|
|
4
|
+
import {useCustomValidity} from '../../hooks/useCustomValidity'
|
|
5
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
6
6
|
|
|
7
7
|
/** @public */
|
|
8
8
|
export const DEFAULT_RADIO_ELEMENT = 'input'
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {box, root, type RootStyleProps} from '@sanity/ui/css'
|
|
2
|
+
import {useCallback, useImperativeHandle, useRef, useState} from 'react'
|
|
3
|
+
|
|
4
|
+
import {ToastProvider} from '../../components/toast'
|
|
5
|
+
import type {Props} from '../../types/props'
|
|
6
|
+
import {BoundaryElementProvider} from '../../utils/boundaryElement'
|
|
7
|
+
import {PortalProvider} from '../../utils/portal'
|
|
8
|
+
import {Box, type BoxOwnProps} from '../box'
|
|
9
|
+
import {CardProvider} from '../card'
|
|
10
|
+
import {LayerProvider} from '../layer'
|
|
11
|
+
|
|
12
|
+
/** @public */
|
|
13
|
+
export const DEFAULT_ROOT_ELEMENT = 'html'
|
|
14
|
+
|
|
15
|
+
/** @public */
|
|
16
|
+
export interface RootOwnProps extends BoxOwnProps, RootStyleProps {}
|
|
17
|
+
|
|
18
|
+
/** @public */
|
|
19
|
+
export type RootElementType = 'html' | 'body' | 'div'
|
|
20
|
+
|
|
21
|
+
/** @public */
|
|
22
|
+
export type RootProps<E extends RootElementType = RootElementType> = Props<RootOwnProps, E>
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The `Root` component.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export function Root<E extends RootElementType = typeof DEFAULT_ROOT_ELEMENT>(props: RootProps<E>) {
|
|
30
|
+
const {
|
|
31
|
+
as: as = DEFAULT_ROOT_ELEMENT,
|
|
32
|
+
children,
|
|
33
|
+
className,
|
|
34
|
+
height = 'fill',
|
|
35
|
+
ref: forwardedRef,
|
|
36
|
+
scheme = 'light',
|
|
37
|
+
tone = 'transparent',
|
|
38
|
+
...rest
|
|
39
|
+
} = props as RootProps<typeof DEFAULT_ROOT_ELEMENT>
|
|
40
|
+
|
|
41
|
+
const ref = useRef<HTMLHtmlElement | null>(null)
|
|
42
|
+
|
|
43
|
+
useImperativeHandle<HTMLHtmlElement | null, HTMLHtmlElement | null>(
|
|
44
|
+
forwardedRef,
|
|
45
|
+
() => ref.current,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
const [portalElement, setPortalElement] = useState<HTMLElement | null>(null)
|
|
49
|
+
const [boundaryElement, setBoundaryElement] = useState<HTMLElement | null>(null)
|
|
50
|
+
|
|
51
|
+
const handleRef = useCallback((el: HTMLHtmlElement | null) => {
|
|
52
|
+
setBoundaryElement(el)
|
|
53
|
+
ref.current = el
|
|
54
|
+
}, [])
|
|
55
|
+
|
|
56
|
+
let node = (
|
|
57
|
+
<LayerProvider>
|
|
58
|
+
<CardProvider scheme={scheme} tone={tone}>
|
|
59
|
+
<ToastProvider>
|
|
60
|
+
<BoundaryElementProvider element={boundaryElement}>
|
|
61
|
+
<PortalProvider element={portalElement}>{children}</PortalProvider>
|
|
62
|
+
</BoundaryElementProvider>
|
|
63
|
+
<div data-portal="" ref={setPortalElement} />
|
|
64
|
+
</ToastProvider>
|
|
65
|
+
</CardProvider>
|
|
66
|
+
</LayerProvider>
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if (as === 'html') {
|
|
70
|
+
node = <body className={box({height, margin: 0})}>{node}</body>
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Box
|
|
75
|
+
as={as}
|
|
76
|
+
data-ui="Root"
|
|
77
|
+
{...rest}
|
|
78
|
+
className={root({
|
|
79
|
+
className,
|
|
80
|
+
height,
|
|
81
|
+
scheme,
|
|
82
|
+
tone,
|
|
83
|
+
})}
|
|
84
|
+
ref={handleRef}
|
|
85
|
+
>
|
|
86
|
+
{node}
|
|
87
|
+
</Box>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Root'
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
import type {Space} from '@sanity/ui/theme'
|
|
10
10
|
import {useImperativeHandle, useRef} from 'react'
|
|
11
11
|
|
|
12
|
-
import {useCustomValidity} from '../../hooks'
|
|
13
|
-
import type {ComponentType, Props} from '../../types'
|
|
12
|
+
import {useCustomValidity} from '../../hooks/useCustomValidity'
|
|
13
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
14
14
|
import {Box} from '../box'
|
|
15
15
|
import {Text} from '../text'
|
|
16
16
|
|
|
@@ -2,7 +2,7 @@ import {defineScope} from '@sanity/ui-workshop'
|
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
4
|
export default defineScope({
|
|
5
|
-
name: '
|
|
5
|
+
name: 'primitives/skeleton',
|
|
6
6
|
title: 'Skeleton',
|
|
7
7
|
stories: [
|
|
8
8
|
{name: 'skeleton', title: 'Skeleton', component: lazy(() => import('./skeleton'))},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {codeSkeleton, type ResponsiveProp} from '@sanity/ui/css'
|
|
2
2
|
import type {FontCodeSize} from '@sanity/ui/theme'
|
|
3
3
|
|
|
4
|
-
import type {Props} from '../../types'
|
|
4
|
+
import type {Props} from '../../types/props'
|
|
5
5
|
import {Skeleton, type SkeletonElementType, type SkeletonOwnProps} from './skeleton'
|
|
6
6
|
|
|
7
7
|
/** @beta */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {headingSkeleton, type ResponsiveProp} from '@sanity/ui/css'
|
|
2
2
|
import type {FontHeadingSize} from '@sanity/ui/theme'
|
|
3
3
|
|
|
4
|
-
import type {Props} from '../../types'
|
|
4
|
+
import type {Props} from '../../types/props'
|
|
5
5
|
import {Skeleton, type SkeletonElementType, type SkeletonOwnProps} from './skeleton'
|
|
6
6
|
|
|
7
7
|
/** @beta */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {labelSkeleton, type ResponsiveProp} from '@sanity/ui/css'
|
|
2
2
|
import type {FontLabelSize} from '@sanity/ui/theme'
|
|
3
3
|
|
|
4
|
-
import type {Props} from '../../types'
|
|
4
|
+
import type {Props} from '../../types/props'
|
|
5
5
|
import {Skeleton, type SkeletonElementType, type SkeletonOwnProps} from './skeleton'
|
|
6
6
|
|
|
7
7
|
/** @beta */
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {skeleton, type SkeletonStyleProps} from '@sanity/ui/css'
|
|
2
2
|
import {useEffect, useState} from 'react'
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import type {ComponentType, Props} from '../../types'
|
|
4
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
6
5
|
|
|
7
6
|
/** @beta */
|
|
8
7
|
export const DEFAULT_SKELETON_ELEMENT = 'div'
|
|
@@ -11,11 +10,10 @@ export const DEFAULT_SKELETON_ELEMENT = 'div'
|
|
|
11
10
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
12
11
|
* @beta
|
|
13
12
|
*/
|
|
14
|
-
export type SkeletonOwnProps =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
13
|
+
export type SkeletonOwnProps = SkeletonStyleProps & {
|
|
14
|
+
animated?: boolean
|
|
15
|
+
delay?: number
|
|
16
|
+
}
|
|
19
17
|
|
|
20
18
|
/** @beta */
|
|
21
19
|
export type SkeletonElementType = 'div' | 'span' | ComponentType
|
|
@@ -34,6 +32,7 @@ export function Skeleton<E extends SkeletonElementType = typeof DEFAULT_SKELETON
|
|
|
34
32
|
props: SkeletonProps<E>,
|
|
35
33
|
) {
|
|
36
34
|
const {
|
|
35
|
+
as: As = DEFAULT_SKELETON_ELEMENT,
|
|
37
36
|
animated = false,
|
|
38
37
|
className,
|
|
39
38
|
delay,
|
|
@@ -58,7 +57,7 @@ export function Skeleton<E extends SkeletonElementType = typeof DEFAULT_SKELETON
|
|
|
58
57
|
}, [delay])
|
|
59
58
|
|
|
60
59
|
return (
|
|
61
|
-
<
|
|
60
|
+
<As
|
|
62
61
|
data-ui="Skeleton"
|
|
63
62
|
{...rest}
|
|
64
63
|
className={skeleton({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {type ResponsiveProp, textSkeleton} from '@sanity/ui/css'
|
|
2
2
|
import type {FontTextSize} from '@sanity/ui/theme'
|
|
3
3
|
|
|
4
|
-
import type {Props} from '../../types'
|
|
4
|
+
import type {Props} from '../../types/props'
|
|
5
5
|
import {Skeleton, type SkeletonElementType, type SkeletonOwnProps} from './skeleton'
|
|
6
6
|
|
|
7
7
|
/** @beta */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {type ResponsiveProp, spinner} from '@sanity/ui/css'
|
|
2
2
|
import type {FontTextSize} from '@sanity/ui/theme'
|
|
3
3
|
|
|
4
|
-
import type {ComponentType, Props} from '../../types'
|
|
4
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
5
5
|
import {Text} from '../text'
|
|
6
6
|
import {AnimatedSpinnerIcon} from './animatedSpinnerIcon'
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {type ResponsiveProp, stack} from '@sanity/ui/css'
|
|
2
2
|
import type {Space} from '@sanity/ui/theme'
|
|
3
3
|
|
|
4
|
-
import type {Props} from '../../types'
|
|
4
|
+
import type {Props} from '../../types/props'
|
|
5
5
|
import {Box, type BoxElementType, type BoxOwnProps} from '../box'
|
|
6
6
|
|
|
7
7
|
/** @public */
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from '@sanity/ui/css'
|
|
8
8
|
import {useEffect, useImperativeHandle, useRef} from 'react'
|
|
9
9
|
|
|
10
|
-
import type {ComponentType, Props} from '../../types'
|
|
10
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
11
11
|
import {Box} from '../box'
|
|
12
12
|
|
|
13
13
|
/** @public */
|
|
@@ -36,7 +36,6 @@ export function Switch<E extends SwitchElementType = typeof DEFAULT_SWITCH_ELEME
|
|
|
36
36
|
) {
|
|
37
37
|
const {
|
|
38
38
|
as: Element = DEFAULT_SWITCH_ELEMENT,
|
|
39
|
-
checked,
|
|
40
39
|
className,
|
|
41
40
|
disabled,
|
|
42
41
|
indeterminate,
|
|
@@ -63,8 +62,6 @@ export function Switch<E extends SwitchElementType = typeof DEFAULT_SWITCH_ELEME
|
|
|
63
62
|
return (
|
|
64
63
|
<Box
|
|
65
64
|
className={_switch({className})}
|
|
66
|
-
data-checked={checked ? '' : undefined}
|
|
67
|
-
data-indeterminate={indeterminate ? '' : undefined}
|
|
68
65
|
data-ui="Switch"
|
|
69
66
|
display="block"
|
|
70
67
|
position="relative"
|
|
@@ -72,9 +69,7 @@ export function Switch<E extends SwitchElementType = typeof DEFAULT_SWITCH_ELEME
|
|
|
72
69
|
>
|
|
73
70
|
<Element
|
|
74
71
|
{...rest}
|
|
75
|
-
checked={indeterminate !== true && checked}
|
|
76
72
|
className={_switchElement()}
|
|
77
|
-
data-disabled={disabled ? '' : undefined}
|
|
78
73
|
data-read-only={!disabled && readOnly ? '' : undefined}
|
|
79
74
|
disabled={disabled || readOnly}
|
|
80
75
|
type="checkbox"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Flex, Text} from '@sanity/ui'
|
|
2
|
-
import {
|
|
2
|
+
import {vars} from '@sanity/ui/css'
|
|
3
3
|
import type {AvatarColor} from '@sanity/ui/theme'
|
|
4
4
|
import {useSelect} from '@sanity/ui-workshop'
|
|
5
5
|
import {styled} from 'styled-components'
|
|
@@ -7,7 +7,7 @@ import {styled} from 'styled-components'
|
|
|
7
7
|
import {WORKSHOP_AVATAR_COLOR_OPTIONS} from '$workshop'
|
|
8
8
|
|
|
9
9
|
const ColoredText = styled(Text)<{$color: AvatarColor}>`
|
|
10
|
-
${
|
|
10
|
+
${vars.color.fg.slice(4, -1)}: ${({$color}) => vars.color.avatar[$color].bg};
|
|
11
11
|
`
|
|
12
12
|
|
|
13
13
|
export default function ColoredTextStory() {
|
|
@@ -1,48 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {Box,
|
|
1
|
+
import {CropIcon} from '@sanity/icons'
|
|
2
|
+
import {Box, Stack, Text} from '@sanity/ui'
|
|
3
|
+
import {vars} from '@sanity/ui/css'
|
|
4
|
+
import {FONT_TEXT_SIZE} from '@sanity/ui/theme'
|
|
3
5
|
|
|
4
6
|
export default function OpticalAlignment() {
|
|
5
7
|
return (
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
<Text size={
|
|
11
|
-
|
|
12
|
-
</Flex>
|
|
13
|
-
|
|
14
|
-
<Flex>
|
|
15
|
-
<Card padding={0} tone="neutral">
|
|
16
|
-
<Text size={3}>Hamburgefonstiv M</Text>
|
|
17
|
-
</Card>
|
|
18
|
-
</Flex>
|
|
19
|
-
|
|
20
|
-
<Flex>
|
|
21
|
-
<Card padding={0} tone="neutral">
|
|
22
|
-
<Text size={2}>Hamburgefonstiv M</Text>
|
|
23
|
-
</Card>
|
|
24
|
-
</Flex>
|
|
25
|
-
|
|
26
|
-
<Flex>
|
|
27
|
-
<Card padding={0} tone="neutral">
|
|
28
|
-
<Text size={1}>Hamburgefonstiv M</Text>
|
|
29
|
-
</Card>
|
|
30
|
-
</Flex>
|
|
31
|
-
|
|
32
|
-
<Flex>
|
|
33
|
-
<Card padding={0} tone="neutral">
|
|
34
|
-
<Text size={0}>Hamburgefonstiv M</Text>
|
|
35
|
-
</Card>
|
|
36
|
-
</Flex>
|
|
37
|
-
|
|
38
|
-
<Flex>
|
|
39
|
-
<Card padding={2} tone="neutral">
|
|
40
|
-
<Text>
|
|
41
|
-
<AddCircleIcon />
|
|
8
|
+
<Stack gap={4} padding={[4, 5, 6]}>
|
|
9
|
+
{FONT_TEXT_SIZE.map((size) => (
|
|
10
|
+
<Box display="flex" gap={2} key={size}>
|
|
11
|
+
<div style={{outline: `0.5px solid ${vars.color.tinted.suggest.border[4]}`}}>
|
|
12
|
+
<Text size={size}>
|
|
13
|
+
<CropIcon />
|
|
42
14
|
</Text>
|
|
43
|
-
</
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
15
|
+
</div>
|
|
16
|
+
<div style={{outline: `0.5px solid ${vars.color.tinted.suggest.border[4]}`}}>
|
|
17
|
+
<Text size={size}>Hamburgefonstiv M</Text>
|
|
18
|
+
</div>
|
|
19
|
+
</Box>
|
|
20
|
+
))}
|
|
21
|
+
</Stack>
|
|
47
22
|
)
|
|
48
23
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {text, textOverflow, type TextOverflowStyleProps, type TextStyleProps} from '@sanity/ui/css'
|
|
2
2
|
|
|
3
|
-
import type {ComponentType, Props} from '../../types'
|
|
3
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
4
4
|
|
|
5
5
|
/** @public */
|
|
6
6
|
export const DEFAULT_TEXT_ELEMENT = 'div'
|
|
@@ -39,6 +39,7 @@ export function Text<E extends TextElementType = typeof DEFAULT_TEXT_ELEMENT>(pr
|
|
|
39
39
|
children,
|
|
40
40
|
className,
|
|
41
41
|
flex,
|
|
42
|
+
maxWidth = 'fill',
|
|
42
43
|
muted,
|
|
43
44
|
size = 2,
|
|
44
45
|
textOverflow: textOverflowProp,
|
|
@@ -55,6 +56,7 @@ export function Text<E extends TextElementType = typeof DEFAULT_TEXT_ELEMENT>(pr
|
|
|
55
56
|
accent,
|
|
56
57
|
align,
|
|
57
58
|
flex,
|
|
59
|
+
maxWidth,
|
|
58
60
|
muted,
|
|
59
61
|
size,
|
|
60
62
|
weight,
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
import type {Space} from '@sanity/ui/theme'
|
|
9
9
|
import {useImperativeHandle, useRef} from 'react'
|
|
10
10
|
|
|
11
|
-
import {useCustomValidity} from '../../hooks'
|
|
12
|
-
import type {ComponentType, Props} from '../../types'
|
|
11
|
+
import {useCustomValidity} from '../../hooks/useCustomValidity'
|
|
12
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
13
13
|
|
|
14
14
|
/** @public */
|
|
15
15
|
export const DEFAULT_TEXT_AREA_ELEMENT = 'textarea'
|
|
@@ -23,9 +23,10 @@ import {
|
|
|
23
23
|
import {isValidElementType} from 'react-is'
|
|
24
24
|
|
|
25
25
|
import {EMPTY_RECORD} from '../../constants'
|
|
26
|
-
import {useCustomValidity
|
|
26
|
+
import {useCustomValidity} from '../../hooks/useCustomValidity'
|
|
27
|
+
import {useResponsiveProp} from '../../hooks/useResponsiveProp'
|
|
27
28
|
import {isRecord} from '../../lib/isRecord'
|
|
28
|
-
import type {ComponentType, Props} from '../../types'
|
|
29
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
29
30
|
import {Box} from '../box'
|
|
30
31
|
import {Button, type ButtonProps} from '../button'
|
|
31
32
|
import {Text} from '../text'
|
|
@@ -31,12 +31,14 @@ import {
|
|
|
31
31
|
import {useEffectEvent} from 'use-effect-event'
|
|
32
32
|
|
|
33
33
|
import {Z_OFFSETS} from '../../constants'
|
|
34
|
-
import {usePrefersReducedMotion} from '../../hooks'
|
|
35
34
|
import {useDelayedState} from '../../hooks/useDelayedState'
|
|
35
|
+
import {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'
|
|
36
36
|
import {origin} from '../../middleware/origin'
|
|
37
|
-
import type {
|
|
38
|
-
import {
|
|
37
|
+
import type {Placement} from '../../types/placement'
|
|
38
|
+
import type {ComponentType, Props} from '../../types/props'
|
|
39
|
+
import {useBoundaryElement} from '../../utils/boundaryElement'
|
|
39
40
|
import {getElementRef} from '../../utils/getElementRef'
|
|
41
|
+
import {Portal, usePortal} from '../../utils/portal'
|
|
40
42
|
import {CardProvider, useCard} from '../card'
|
|
41
43
|
import type {LayerOwnProps} from '../layer'
|
|
42
44
|
import type {Delay} from '../types'
|
|
@@ -2,7 +2,7 @@ import {motion, type MotionStyle} from 'framer-motion'
|
|
|
2
2
|
import {type CSSProperties, type ForwardedRef, useMemo} from 'react'
|
|
3
3
|
|
|
4
4
|
import {POPOVER_MOTION_PROPS} from '../../constants'
|
|
5
|
-
import type {Placement} from '../../types'
|
|
5
|
+
import type {Placement} from '../../types/placement'
|
|
6
6
|
import {Arrow} from '../arrow'
|
|
7
7
|
import {Layer, type LayerOwnProps, type LayerProps} from '../layer'
|
|
8
8
|
import {
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AlignItems,
|
|
3
|
+
BoxHeight,
|
|
4
|
+
BoxOverflow,
|
|
5
|
+
BoxSizing,
|
|
3
6
|
Flex,
|
|
4
7
|
FlexDirection,
|
|
5
8
|
FlexWrap,
|
|
9
|
+
GridAutoCols,
|
|
10
|
+
GridAutoFlow,
|
|
11
|
+
GridAutoRows,
|
|
6
12
|
GridItemColumn,
|
|
7
13
|
GridItemColumnEnd,
|
|
8
14
|
GridItemColumnStart,
|
|
@@ -11,17 +17,9 @@ import type {
|
|
|
11
17
|
GridItemRowStart,
|
|
12
18
|
JustifyContent,
|
|
13
19
|
} from '@sanity/ui/css'
|
|
20
|
+
import type {Radius} from '@sanity/ui/theme'
|
|
14
21
|
|
|
15
|
-
import type {
|
|
16
|
-
BoxDisplay,
|
|
17
|
-
BoxHeight,
|
|
18
|
-
BoxOverflow,
|
|
19
|
-
BoxSizing,
|
|
20
|
-
GridAutoCols,
|
|
21
|
-
GridAutoFlow,
|
|
22
|
-
GridAutoRows,
|
|
23
|
-
Radius,
|
|
24
|
-
} from '../types'
|
|
22
|
+
import type {BoxDisplay} from './box/types'
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
25
|
* @public
|