@sanity/ui 3.0.0-static.13 → 3.0.0-static.14

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/dist/cli.js CHANGED
@@ -335,7 +335,7 @@ class CAC extends events.EventEmitter {
335
335
  }
336
336
  }
337
337
  const cac = (name = "") => new CAC(name);
338
- var version = "3.0.0-static.13";
338
+ var version = "3.0.0-static.14";
339
339
  const cli = cac("ui");
340
340
  cli.command("build").option("--cwd [cwd]", "Working directory").option("--outDir [outDir]", "Output directory").action(async (options) => {
341
341
  const {
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createColorTheme as createColorTheme$1, hexToRgb as hexToRgb$1, hslToRgb as hslToRgb$1, multiply as multiply$1, parseColor as parseColor$1, rgbToHex as rgbToHex$1, rgbToHsl as rgbToHsl$1, rgba as rgba$1, screen as screen$1, buildTheme_v3 } from "@sanity/ui/theme";
2
- import { isHTMLAnchorElement, isHTMLInputElement, isHTMLButtonElement, isHTMLSelectElement, isHTMLTextAreaElement, isHTMLElement, EMPTY_ARRAY, useElementSize, Code, _isEnterToClickElement, Card, Text, useArrayProp, EMPTY_RECORD, Box, Button, Stack, Popover, TextInput, AnimatedSpinnerIcon, useClickOutsideEvent, Flex, containsOrEqualsElement, usePortal, useBoundaryElement, useLayer, useGlobalKeyDown, createGlobalScopedContext, usePrefersReducedMotion, Portal, Z_OFFSETS, Container, Layer, Grid, LayerProvider, isRecord, Selectable, useCard } from "./_chunks-es/_visual-editing.mjs";
2
+ import { isHTMLAnchorElement, isHTMLInputElement, isHTMLButtonElement, isHTMLSelectElement, isHTMLTextAreaElement, isHTMLElement, EMPTY_ARRAY, useElementSize, Code, _isEnterToClickElement, Card, Text, useArrayProp, EMPTY_RECORD, Box, Button, Stack, Popover, TextInput, AnimatedSpinnerIcon, useClickOutsideEvent, Flex, containsOrEqualsElement, usePortal, useBoundaryElement, useLayer, useGlobalKeyDown, createGlobalScopedContext, usePrefersReducedMotion, Z_OFFSETS, Portal, Container, Layer, Grid, LayerProvider, isRecord, Selectable, useCard } from "./_chunks-es/_visual-editing.mjs";
3
3
  import { Arrow, Avatar, AvatarCounter, AvatarStack, Badge, BoundaryElementProvider, CardProvider, Checkbox, DEFAULT_ARROW_ELEMENT, DEFAULT_AVATAR_COUNTER_ELEMENT, DEFAULT_AVATAR_ELEMENT, DEFAULT_AVATAR_STACK_ELEMENT, DEFAULT_BADGE_ELEMENT, DEFAULT_BOX_ELEMENT, DEFAULT_BUTTON_ELEMENT, DEFAULT_CARD_ELEMENT, DEFAULT_CHECKBOX_ELEMENT, DEFAULT_CODE_ELEMENT, DEFAULT_CONTAINER_ELEMENT, DEFAULT_ELEMENT_QUERY_ELEMENT, DEFAULT_FLEX_ELEMENT, DEFAULT_GRID_ELEMENT, DEFAULT_HEADING_ELEMENT, DEFAULT_HOTKEYS_ELEMENT, DEFAULT_INLINE_ELEMENT, DEFAULT_KBD_ELEMENT, DEFAULT_LABEL_ELEMENT, DEFAULT_LAYER_ELEMENT, DEFAULT_MENU_DIVIDER_ELEMENT, DEFAULT_MENU_ELEMENT, DEFAULT_MENU_GROUP_ELEMENT, DEFAULT_MENU_ITEM_ELEMENT, DEFAULT_POPOVER_ELEMENT, DEFAULT_RADIO_ELEMENT, DEFAULT_SELECT_ELEMENT, DEFAULT_SPINNER_ELEMENT, DEFAULT_SR_ONLY_ELEMENT, DEFAULT_STACK_ELEMENT, DEFAULT_SWITCH_ELEMENT, DEFAULT_TAB_ELEMENT, DEFAULT_TAB_LIST_ELEMENT, DEFAULT_TEXT_AREA_ELEMENT, DEFAULT_TEXT_ELEMENT, DEFAULT_TEXT_INPUT_ELEMENT, DEFAULT_TOOLTIP_ELEMENT, DEFAULT_VIRTUAL_LIST_ELEMENT, ElementQuery, Heading, Hotkeys, Inline, KBD, Label, Menu, MenuDivider, MenuGroup, MenuItem, PortalProvider, Radio, Select, Spinner, SrOnly, Switch, Tab, TabList, TextArea, ThemeColorProvider, ThemeProvider, Tooltip, TooltipDelayGroupContext, TooltipDelayGroupProvider, VirtualList, _ResizeObserver, _elementSizeObserver, _getArrayProp, _isScrollable, studioTheme, useCustomValidity, useMatchMedia, useMediaIndex, usePrefersDark, useRootTheme, useTheme, useTheme_v2, useTooltipDelayGroup } from "./_chunks-es/_visual-editing.mjs";
4
4
  import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
5
5
  import { ChevronDownIcon, CloseIcon, ToggleArrowRightIcon } from "@sanity/icons";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "3.0.0-static.13",
3
+ "version": "3.0.0-static.14",
4
4
  "keywords": [
5
5
  "react",
6
6
  "ui",
@@ -27,7 +27,7 @@ import {Z_OFFSETS} from '../../constants'
27
27
  import {useArrayProp, usePrefersReducedMotion} from '../../hooks'
28
28
  import {origin} from '../../middleware/origin'
29
29
  import type {ComponentType, Placement, PopoverMargins, Props} from '../../types'
30
- import {type LayerOwnProps, LayerProvider, Portal, useBoundaryElement, useLayer} from '../../utils'
30
+ import {type LayerOwnProps, Portal, useBoundaryElement, useLayer} from '../../utils'
31
31
  import {CardProvider, useCard} from '../card'
32
32
  import {
33
33
  DEFAULT_FALLBACK_PLACEMENTS,
@@ -36,7 +36,7 @@ import {
36
36
  DEFAULT_POPOVER_PADDING,
37
37
  } from './constants'
38
38
  import {size} from './floating-ui/size'
39
- import {PopoverCard} from './popoverCard'
39
+ import {PopoverLayer} from './popoverLayer'
40
40
  import type {PopoverUpdateCallback} from './types'
41
41
 
42
42
  /** @public */
@@ -353,12 +353,12 @@ export function Popover<E extends PopoverElementType = typeof DEFAULT_POPOVER_EL
353
353
  }
354
354
 
355
355
  const popover = (
356
- <LayerProvider zOffset={zOffset}>
356
+ <>
357
357
  {/* Optional transparent blocking overlay at the top-most z-index layer. Must be positioned
358
358
  before the below popover card. */}
359
359
  {modal && <ViewportOverlay />}
360
360
 
361
- <PopoverCard
361
+ <PopoverLayer
362
362
  {...rest}
363
363
  __unstable_margins={margins}
364
364
  animate={animate}
@@ -381,10 +381,11 @@ export function Popover<E extends PopoverElementType = typeof DEFAULT_POPOVER_EL
381
381
  strategy={strategy}
382
382
  x={x}
383
383
  y={y}
384
+ zOffset={zOffset}
384
385
  >
385
386
  {content}
386
- </PopoverCard>
387
- </LayerProvider>
387
+ </PopoverLayer>
388
+ </>
388
389
  )
389
390
 
390
391
  const children =
@@ -5,8 +5,8 @@ import {CSSProperties, ForwardedRef, useMemo} from 'react'
5
5
 
6
6
  import {POPOVER_MOTION_PROPS} from '../../constants'
7
7
  import {Placement, PopoverMargins, Props} from '../../types'
8
- import {Arrow, useLayer} from '../../utils'
9
- import {Card, CardElementType, CardOwnProps} from '../card'
8
+ import {Arrow, Layer, LayerOwnProps} from '../../utils'
9
+ import {CardElementType} from '../card'
10
10
  import {Flex} from '../flex'
11
11
  import {
12
12
  DEFAULT_POPOVER_ARROW_HEIGHT,
@@ -16,10 +16,10 @@ import {
16
16
  } from './constants'
17
17
 
18
18
  /** @internal */
19
- export const DEFAULT_POPOVER_CARD_ELEMENT = 'div'
19
+ export const DEFAULT_POPOVER_LAYER_ELEMENT = 'div'
20
20
 
21
21
  /** @internal */
22
- export type PopoverCardOwnProps = CardOwnProps & {
22
+ export type PopoverLayerOwnProps = LayerOwnProps & {
23
23
  /** @beta*/
24
24
  __unstable_margins?: PopoverMargins
25
25
  animate?: boolean
@@ -37,20 +37,20 @@ export type PopoverCardOwnProps = CardOwnProps & {
37
37
  }
38
38
 
39
39
  /** @internal */
40
- export type PopoverCardElementType = CardElementType
40
+ export type PopoverLayerElementType = CardElementType
41
41
 
42
42
  /** @internal */
43
- export type PopoverCardProps<E extends PopoverCardElementType = PopoverCardElementType> = Props<
44
- PopoverCardOwnProps,
43
+ export type PopoverLayerProps<E extends PopoverLayerElementType = PopoverLayerElementType> = Props<
44
+ PopoverLayerOwnProps,
45
45
  E
46
46
  >
47
47
 
48
- const MotionCard = motion.create(Card)
48
+ const MotionLayer = motion.create(Layer)
49
49
 
50
50
  /** @internal */
51
- export function PopoverCard<E extends PopoverCardElementType = typeof DEFAULT_POPOVER_CARD_ELEMENT>(
52
- props: PopoverCardProps<E>,
53
- ) {
51
+ export function PopoverLayer<
52
+ E extends PopoverLayerElementType = typeof DEFAULT_POPOVER_LAYER_ELEMENT,
53
+ >(props: PopoverLayerProps<E>) {
54
54
  const {
55
55
  __unstable_margins: marginsProp,
56
56
  animate,
@@ -58,7 +58,7 @@ export function PopoverCard<E extends PopoverCardElementType = typeof DEFAULT_PO
58
58
  arrowRef,
59
59
  arrowX,
60
60
  arrowY,
61
- as = DEFAULT_POPOVER_CARD_ELEMENT,
61
+ as = DEFAULT_POPOVER_LAYER_ELEMENT,
62
62
  children,
63
63
  maxWidth,
64
64
  padding,
@@ -75,9 +75,7 @@ export function PopoverCard<E extends PopoverCardElementType = typeof DEFAULT_PO
75
75
  x: xProp,
76
76
  y: yProp,
77
77
  ...rest
78
- } = props as PopoverCardProps<typeof DEFAULT_POPOVER_CARD_ELEMENT>
79
-
80
- const layer = useLayer()
78
+ } = props as PopoverLayerProps<typeof DEFAULT_POPOVER_LAYER_ELEMENT>
81
79
 
82
80
  // Get margins: [top, right, bottom, left]
83
81
  const margins: PopoverMargins = useMemo(
@@ -94,14 +92,12 @@ export function PopoverCard<E extends PopoverCardElementType = typeof DEFAULT_PO
94
92
  left: x,
95
93
  originX,
96
94
  originY,
97
- position: strategy,
98
95
  top: y,
99
96
  width: referenceWidth,
100
- zIndex: layer.zIndex ?? 100,
101
97
  willChange: animate ? 'transform' : undefined,
102
98
  ...style,
103
99
  }),
104
- [animate, layer.zIndex, originX, originY, referenceWidth, strategy, style, x, y],
100
+ [animate, originX, originY, referenceWidth, style, x, y],
105
101
  )
106
102
 
107
103
  const arrowStyle: CSSProperties = useMemo(
@@ -115,7 +111,7 @@ export function PopoverCard<E extends PopoverCardElementType = typeof DEFAULT_PO
115
111
  )
116
112
 
117
113
  return (
118
- <MotionCard
114
+ <MotionLayer
119
115
  className={popoverCard()}
120
116
  data-ui="Popover"
121
117
  {...rest}
@@ -124,6 +120,7 @@ export function PopoverCard<E extends PopoverCardElementType = typeof DEFAULT_PO
124
120
  data-placement={placement}
125
121
  direction="column"
126
122
  display="flex"
123
+ position={strategy}
127
124
  radius={radius}
128
125
  shadow={shadow}
129
126
  sizing="border"
@@ -156,8 +153,8 @@ export function PopoverCard<E extends PopoverCardElementType = typeof DEFAULT_PO
156
153
  radius={DEFAULT_POPOVER_ARROW_RADIUS}
157
154
  />
158
155
  )}
159
- </MotionCard>
156
+ </MotionLayer>
160
157
  )
161
158
  }
162
159
 
163
- PopoverCard.displayName = 'PopoverCard'
160
+ PopoverLayer.displayName = 'PopoverCard'
@@ -35,7 +35,7 @@ import {useArrayProp, usePrefersReducedMotion} from '../../hooks'
35
35
  import {useDelayedState} from '../../hooks/useDelayedState'
36
36
  import {origin} from '../../middleware/origin'
37
37
  import type {ComponentType, Placement, Props} from '../../types'
38
- import {Layer, type LayerOwnProps, Portal, useBoundaryElement, usePortal} from '../../utils'
38
+ import {type LayerOwnProps, Portal, useBoundaryElement, usePortal} from '../../utils'
39
39
  import {getElementRef} from '../../utils/getElementRef'
40
40
  import {CardProvider, useCard} from '../card'
41
41
  import {Delay} from '../types'
@@ -44,8 +44,8 @@ import {
44
44
  DEFAULT_TOOLTIP_DISTANCE,
45
45
  DEFAULT_TOOLTIP_PADDING,
46
46
  } from './constants'
47
- import {TooltipCard} from './tooltipCard'
48
47
  import {useTooltipDelayGroup} from './tooltipDelayGroup'
48
+ import {TooltipLayer} from './tooltipLayer'
49
49
 
50
50
  /** @public */
51
51
  export const DEFAULT_TOOLTIP_ELEMENT = 'div'
@@ -381,37 +381,33 @@ export function Tooltip<E extends TooltipElementType = typeof DEFAULT_TOOLTIP_EL
381
381
  if (disabled) return child
382
382
 
383
383
  const node = (
384
- <Layer
384
+ <TooltipLayer
385
385
  data-ui="Tooltip"
386
+ {...rest}
387
+ animate={animate}
388
+ arrow={arrowProp}
389
+ arrowRef={setArrow}
390
+ arrowX={arrowX}
391
+ arrowY={arrowY}
392
+ as={as}
386
393
  className={composeClassNames(className, tooltip())}
394
+ originX={originX}
395
+ originY={originY}
396
+ padding={padding}
397
+ placement={placement}
398
+ radius={radius}
387
399
  ref={setFloating}
400
+ scheme={scheme}
401
+ shadow={shadow}
388
402
  style={{
389
403
  ...floatingStyles,
390
404
  maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : undefined,
391
405
  }}
406
+ tone={tone}
392
407
  zOffset={zOffset}
393
408
  >
394
- <TooltipCard
395
- {...rest}
396
- animate={animate}
397
- arrow={arrowProp}
398
- arrowRef={setArrow}
399
- arrowX={arrowX}
400
- arrowY={arrowY}
401
- as={as}
402
- originX={originX}
403
- originY={originY}
404
- padding={padding}
405
- placement={placement}
406
- radius={radius}
407
- ref={setFloating}
408
- scheme={scheme}
409
- shadow={shadow}
410
- tone={tone}
411
- >
412
- {content}
413
- </TooltipCard>
414
- </Layer>
409
+ {content}
410
+ </TooltipLayer>
415
411
  )
416
412
 
417
413
  const children =
@@ -4,8 +4,7 @@ import {type CSSProperties, ForwardedRef, useMemo} from 'react'
4
4
 
5
5
  import {POPOVER_MOTION_PROPS} from '../../constants'
6
6
  import {Placement, Props} from '../../types'
7
- import {Arrow} from '../../utils'
8
- import {Card, CardOwnProps} from '../card'
7
+ import {Arrow, Layer, LayerOwnProps} from '../../utils'
9
8
  import {
10
9
  DEFAULT_TOOLTIP_ARROW_HEIGHT,
11
10
  DEFAULT_TOOLTIP_ARROW_RADIUS,
@@ -13,10 +12,10 @@ import {
13
12
  } from './constants'
14
13
 
15
14
  /* @internal */
16
- export const DEFAULT_TOOLTIP_CARD_ELEMENT = 'div'
15
+ export const DEFAULT_TOOLTIP_LAYER_ELEMENT = 'div'
17
16
 
18
17
  /* @internal */
19
- export interface TooltipCardOwnProps extends CardOwnProps {
18
+ export interface TooltipLayerOwnProps extends LayerOwnProps {
20
19
  animate?: boolean
21
20
  arrow: boolean
22
21
  arrowRef: ForwardedRef<HTMLDivElement>
@@ -28,29 +27,27 @@ export interface TooltipCardOwnProps extends CardOwnProps {
28
27
  }
29
28
 
30
29
  /** @internal */
31
- export type TooltipCardElementType = 'div'
30
+ export type TooltipLayerElementType = 'div'
32
31
 
33
32
  /** @internal */
34
- export type TooltipCardProps<E extends TooltipCardElementType = TooltipCardElementType> = Props<
35
- TooltipCardOwnProps,
33
+ export type TooltipLayerProps<E extends TooltipLayerElementType = TooltipLayerElementType> = Props<
34
+ TooltipLayerOwnProps,
36
35
  E
37
36
  >
38
37
 
39
- const MotionCard = motion.create(Card)
38
+ const MotionLayer = motion.create(Layer)
40
39
 
41
- /**
42
- * @internal
43
- */
44
- export function TooltipCard<E extends TooltipCardElementType = typeof DEFAULT_TOOLTIP_CARD_ELEMENT>(
45
- props: TooltipCardProps<E>,
46
- ) {
40
+ /** @internal */
41
+ export function TooltipLayer<
42
+ E extends TooltipLayerElementType = typeof DEFAULT_TOOLTIP_LAYER_ELEMENT,
43
+ >(props: TooltipLayerProps<E>) {
47
44
  const {
48
45
  animate,
49
46
  arrow,
50
47
  arrowRef,
51
48
  arrowX,
52
49
  arrowY,
53
- as = DEFAULT_TOOLTIP_CARD_ELEMENT,
50
+ as = DEFAULT_TOOLTIP_LAYER_ELEMENT,
54
51
  children,
55
52
  originX,
56
53
  originY,
@@ -62,7 +59,7 @@ export function TooltipCard<E extends TooltipCardElementType = typeof DEFAULT_TO
62
59
  style,
63
60
  tone = 'inherit',
64
61
  ...rest
65
- } = props as TooltipCardProps<typeof DEFAULT_TOOLTIP_CARD_ELEMENT>
62
+ } = props as TooltipLayerProps<typeof DEFAULT_TOOLTIP_LAYER_ELEMENT>
66
63
 
67
64
  const rootStyle: CSSProperties = useMemo(
68
65
  () => ({
@@ -85,7 +82,7 @@ export function TooltipCard<E extends TooltipCardElementType = typeof DEFAULT_TO
85
82
  )
86
83
 
87
84
  return (
88
- <MotionCard
85
+ <MotionLayer
89
86
  data-ui="Tooltip__card"
90
87
  {...rest}
91
88
  as={as}
@@ -115,8 +112,8 @@ export function TooltipCard<E extends TooltipCardElementType = typeof DEFAULT_TO
115
112
  radius={DEFAULT_TOOLTIP_ARROW_RADIUS}
116
113
  />
117
114
  )}
118
- </MotionCard>
115
+ </MotionLayer>
119
116
  )
120
117
  }
121
118
 
122
- TooltipCard.displayName = 'TooltipCard'
119
+ TooltipLayer.displayName = 'TooltipLayer'