@sanity/ui 5.0.0-alpha.6 → 5.0.0-alpha.8

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.
Files changed (47) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/install.js +2 -1
  3. package/dist/index.d.ts +285 -116
  4. package/dist/index.js +177 -174
  5. package/dist/index.js.map +1 -1
  6. package/dist/styles.css +1 -1
  7. package/package.json +2 -2
  8. package/src/cli/install.ts +2 -1
  9. package/src/components/box/box.props.ts +7 -2
  10. package/src/components/button/button.props.ts +27 -9
  11. package/src/components/card/card.props.ts +6 -2
  12. package/src/components/checkbox/Checkbox.tsx +2 -1
  13. package/src/components/checkbox/checkbox.props.ts +11 -3
  14. package/src/components/code/code.props.ts +10 -3
  15. package/src/components/container/container.props.ts +6 -2
  16. package/src/components/{modal/Modal.tsx → dialog/Dialog.tsx} +28 -28
  17. package/src/components/{modal/modal.css → dialog/dialog.css} +11 -11
  18. package/src/components/dialog/dialog.props.ts +38 -0
  19. package/src/components/eyebrow/eyebrow.props.ts +6 -2
  20. package/src/components/flex/flex.props.ts +6 -2
  21. package/src/components/grid/grid.props.ts +6 -2
  22. package/src/components/h-stack/hStack.props.ts +3 -1
  23. package/src/components/heading/heading.props.ts +8 -2
  24. package/src/components/icon/icon.props.ts +6 -2
  25. package/src/components/icon-button/iconButton.props.ts +7 -2
  26. package/src/components/index.css +1 -1
  27. package/src/components/indicator/indicator.props.ts +6 -2
  28. package/src/components/indicator-stack/indicatorStack.props.ts +3 -1
  29. package/src/components/inline/inline.props.ts +6 -2
  30. package/src/components/label/label.props.ts +7 -1
  31. package/src/components/link/link.props.ts +4 -4
  32. package/src/components/list/list.props.ts +27 -9
  33. package/src/components/popover/popover.props.ts +14 -4
  34. package/src/components/press-area/pressArea.props.ts +3 -1
  35. package/src/components/radio/radio.props.ts +7 -2
  36. package/src/components/skip-to-content/skipToContent.props.ts +9 -3
  37. package/src/components/spinner/Spinner.tsx +1 -1
  38. package/src/components/spinner/spinner.props.ts +3 -0
  39. package/src/components/switch/switch.props.ts +7 -2
  40. package/src/components/text/text.props.ts +6 -2
  41. package/src/components/tooltip/tooltip.props.ts +12 -4
  42. package/src/components/tooltip-group/tooltipGroup.props.ts +3 -1
  43. package/src/components/v-stack/vStack.props.ts +3 -1
  44. package/src/components/visually-hidden/visuallyHidden.props.ts +6 -2
  45. package/src/index.ts +1 -1
  46. package/src/version.ts +2 -2
  47. package/src/components/modal/modal.props.ts +0 -29
@@ -11,7 +11,9 @@ import type {Responsive} from '../../types/Responsive'
11
11
 
12
12
  /** @beta */
13
13
  export interface ListProps<T extends ListTag = 'ul'> extends Pick<GapProps, 'gap'> {
14
- /** Element to render */
14
+ /**
15
+ * HTML element to render.
16
+ */
15
17
  as?: T
16
18
  }
17
19
 
@@ -24,11 +26,17 @@ export const listProps: Record<string, PropDef> = {
24
26
 
25
27
  /** @beta */
26
28
  export interface ListItemProps extends React.ComponentProps<'li'> {
27
- /** Composite prop for setting padding and gap */
29
+ /**
30
+ * Sets horizontal padding, gap, and minimum row height together.
31
+ */
28
32
  density?: Responsive<Density>
29
- /** Starting slot */
33
+ /**
34
+ * Slot at the left edge of the row.
35
+ */
30
36
  start?: React.ReactNode
31
- /** Ending slot */
37
+ /**
38
+ * Slot at the right edge of the row.
39
+ */
32
40
  end?: React.ReactNode
33
41
  }
34
42
 
@@ -73,9 +81,13 @@ export const listItemProps: Record<string, PropDef> = {
73
81
 
74
82
  /** @beta */
75
83
  export interface ListButtonItemProps<T extends React.ElementType = 'button'> extends ListItemProps {
76
- /** Element to render */
84
+ /**
85
+ * Element or component to render for the press target.
86
+ */
77
87
  as?: InteractiveAs<T>
78
- /** Selected state */
88
+ /**
89
+ * Marks the row as the current selection.
90
+ */
79
91
  selected?: boolean
80
92
  }
81
93
 
@@ -91,11 +103,17 @@ export const listButtonItemProps: Record<string, PropDef> = {
91
103
 
92
104
  /** @beta */
93
105
  export interface ListItemTextProps<T extends React.ElementType = 'div'> {
94
- /** Element to render */
106
+ /**
107
+ * HTML element to render.
108
+ */
95
109
  as?: T
96
- /** Title text */
110
+ /**
111
+ * Main label.
112
+ */
97
113
  title?: React.ReactNode
98
- /** Subtitle text */
114
+ /**
115
+ * Text below the title.
116
+ */
99
117
  subtitle?: React.ReactNode
100
118
  }
101
119
 
@@ -4,13 +4,23 @@ import {type PropDef} from '../../types/PropDef'
4
4
  /** @beta */
5
5
  export interface PopoverProps
6
6
  extends Omit<React.ComponentProps<'div'>, 'children' | 'content'>, PlacementProps {
7
- /** Anchor name for positioning */
7
+ /**
8
+ * Shared anchor identifier.
9
+ * @remarks Set the same value on a Tooltip and a Popover to point both at one trigger.
10
+ */
8
11
  anchorName?: React.ReactNode
9
- /** Focusable trigger element */
12
+ /**
13
+ * The trigger element.
14
+ * @remarks Popover clones it and attaches the `popovertarget` attribute that opens the floating layer.
15
+ */
10
16
  children: React.ReactElement<Record<string, unknown>>
11
- /** Popover content */
17
+ /**
18
+ * The floating content.
19
+ */
12
20
  content?: React.ReactNode
13
- /** Render tooltip in portal */
21
+ /**
22
+ * Renders the content into `document.body` through a React portal instead of inline.
23
+ */
14
24
  portal?: boolean
15
25
  }
16
26
 
@@ -3,7 +3,9 @@ import {type PropDef} from '../../types/PropDef'
3
3
 
4
4
  /** @public */
5
5
  export interface PressAreaProps<T extends React.ElementType = 'button'> {
6
- /** Element to render */
6
+ /**
7
+ * Element or component to render.
8
+ */
7
9
  as?: InteractiveAs<T>
8
10
  }
9
11
 
@@ -3,9 +3,14 @@ import {type PropDef} from '../../types/PropDef'
3
3
 
4
4
  /** @beta */
5
5
  export interface RadioProps extends React.ComponentProps<'input'>, MarginProps {
6
- /** Error state */
6
+ /**
7
+ * Applies error styling to the radio mark.
8
+ * @remarks Use when form validation fails. Pair with a visible error message. The prop is visual only.
9
+ */
7
10
  error?: boolean
8
- /** Input label */
11
+ /**
12
+ * Visible label next to the radio.
13
+ */
9
14
  label: React.ReactNode
10
15
  }
11
16
 
@@ -3,12 +3,18 @@ import {type PropDef} from '../../types/PropDef'
3
3
  /** @beta */
4
4
  export interface SkipToContentProps extends React.ComponentProps<'a'> {
5
5
  /**
6
- * Anchor href. The target element should be focusable or have `tabindex="-1"`.
6
+ * Same-page fragment to jump to.
7
+ * @remarks Note: The hash character # is required for proper linking.
7
8
  */
8
9
  href: string
9
- /** Visible/announced label */
10
+ /**
11
+ * Visible and announced text.
12
+ */
10
13
  label: string
11
- /** Use label instead */
14
+ /**
15
+ * Not accepted.
16
+ * @remarks Pass text via `label`.
17
+ */
12
18
  children?: never
13
19
  }
14
20
 
@@ -1,4 +1,4 @@
1
- import {SpinnerIcon} from '@sanity/icons'
1
+ import {SpinnerIcon} from '@sanity/icons/Spinner'
2
2
  import clsx from 'clsx'
3
3
 
4
4
  import {getProps} from '../../utils/getProps'
@@ -4,6 +4,9 @@ import type {Responsive} from '../../types/Responsive'
4
4
 
5
5
  /** @public */
6
6
  export interface SpinnerProps extends React.ComponentProps<'svg'> {
7
+ /**
8
+ * Size of the spinner icon.
9
+ */
7
10
  size?: Responsive<IconSize>
8
11
  }
9
12
 
@@ -3,9 +3,14 @@ import {type PropDef} from '../../types/PropDef'
3
3
 
4
4
  /** @beta */
5
5
  export interface SwitchProps extends React.ComponentProps<'input'>, MarginProps {
6
- /** Error state */
6
+ /**
7
+ * Applies error styling to the switch track.
8
+ * @remarks Use when form validation fails. Pair with a visible error message. The prop is visual only.
9
+ */
7
10
  error?: boolean
8
- /** Input label */
11
+ /**
12
+ * Visible label next to the switch.
13
+ */
9
14
  label: React.ReactNode
10
15
  }
11
16
 
@@ -5,9 +5,13 @@ import {TEXT_SIZE, type TextSize} from '../../types/Text'
5
5
 
6
6
  /** @public */
7
7
  export interface TextProps<T extends React.ElementType = 'span'> extends TypographyProps {
8
- /** Element to render */
8
+ /**
9
+ * HTML element to render.
10
+ */
9
11
  as?: T
10
- /** CSS **font-size** property */
12
+ /**
13
+ * Sets font size.
14
+ */
11
15
  size?: Responsive<TextSize>
12
16
  }
13
17
 
@@ -4,13 +4,21 @@ import {type PropDef} from '../../types/PropDef'
4
4
  /** @beta */
5
5
  export interface TooltipProps
6
6
  extends Omit<React.ComponentProps<'div'>, 'children' | 'content'>, PlacementProps {
7
- /** Anchor name for positioning */
7
+ /**
8
+ * Shared anchor identifier.
9
+ */
8
10
  anchorName?: React.ReactNode
9
- /** Focusable trigger element */
11
+ /**
12
+ * The trigger element.
13
+ */
10
14
  children: React.ReactElement<Record<string, unknown>>
11
- /** Tooltip content */
15
+ /**
16
+ * The tooltip label.
17
+ */
12
18
  content?: React.ReactNode
13
- /** Render tooltip in portal */
19
+ /**
20
+ * Renders the label into `document.body` through a React portal instead of inline.
21
+ */
14
22
  portal?: boolean
15
23
  }
16
24
 
@@ -2,7 +2,9 @@ import {type PropDef} from '../../types/PropDef'
2
2
 
3
3
  /** @public */
4
4
  export interface TooltipGroupProps<T extends React.ElementType = 'div'> {
5
- /** Element to render */
5
+ /**
6
+ * HTML element to render.
7
+ */
6
8
  as?: T
7
9
  }
8
10
 
@@ -3,7 +3,9 @@ import {type PropDef} from '../../types/PropDef'
3
3
 
4
4
  /** @public */
5
5
  export interface VStackProps<T extends React.ElementType = 'div'> extends Pick<GapProps, 'gap'> {
6
- /** Element to render */
6
+ /**
7
+ * HTML element or component to render.
8
+ */
7
9
  as?: T
8
10
  }
9
11
 
@@ -2,9 +2,13 @@ import {type PropDef} from '../../types/PropDef'
2
2
 
3
3
  /** @public */
4
4
  export interface VisuallyHiddenProps<T extends React.ElementType = 'span'> {
5
- /** Element to render */
5
+ /**
6
+ * HTML element to render.
7
+ */
6
8
  as?: T
7
- /** If true, element is visible on :focus-visible */
9
+ /**
10
+ * If true, the element becomes visible on `:focus-visible`.
11
+ */
8
12
  visibleOnFocus?: boolean
9
13
  }
10
14
 
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ export * from './components/card/Card'
4
4
  export * from './components/checkbox/Checkbox'
5
5
  export * from './components/code/Code'
6
6
  export * from './components/container/Container'
7
+ export * from './components/dialog/Dialog'
7
8
  export * from './components/divider/Divider'
8
9
  export * from './components/eyebrow/Eyebrow'
9
10
  export * from './components/flex/Flex'
@@ -18,7 +19,6 @@ export * from './components/inline/Inline'
18
19
  export * from './components/label/Label'
19
20
  export * from './components/link/Link'
20
21
  export * from './components/list/List'
21
- export * from './components/modal/Modal'
22
22
  export * from './components/popover/Popover'
23
23
  export * from './components/press-area/PressArea'
24
24
  export * from './components/radio/Radio'
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is generated by scripts/write-version.js. Do not edit.
2
- export const VERSION = '500alpha6'
3
- export const HASH = '71d7e5'
2
+ export const VERSION = '500alpha8'
3
+ export const HASH = 'ff7a34'
@@ -1,29 +0,0 @@
1
- import {CONTAINER_SIZE, type ContainerSize} from '../../types/Container'
2
- import {type PropDef} from '../../types/PropDef'
3
- import type {Responsive} from '../../types/Responsive'
4
-
5
- /** @beta */
6
- export interface ModalProps extends Omit<React.ComponentProps<'dialog'>, 'open'> {
7
- /** Text to be displayed as the modal's heading; optional but recommended for optimal accessibility and presentation */
8
- header?: string
9
- /** Used to set the value of open to false. Fires whenever the modal is closed, either programmatically or by the user (via Esc key, clicking background, clicking the modal's close button, or any other means.) */
10
- onClose: React.ReactEventHandler<HTMLDialogElement>
11
- /** Whether the modal is open; defaults to false. */
12
- open?: boolean
13
- /** Max width of the modal */
14
- size?: Responsive<ContainerSize>
15
- }
16
-
17
- export const modalProps: Record<string, PropDef> = {
18
- header: {
19
- type: 'string',
20
- },
21
- open: {
22
- type: 'boolean',
23
- },
24
- size: {
25
- type: 'union',
26
- className: 'container',
27
- values: CONTAINER_SIZE,
28
- },
29
- }