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

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "5.0.0-alpha.6",
3
+ "version": "5.0.0-alpha.7",
4
4
  "description": "Sanity UI Library",
5
5
  "keywords": [
6
6
  "components",
@@ -8,28 +8,28 @@ import {Box} from '../box/Box'
8
8
  import {Flex} from '../flex/Flex'
9
9
  import {Heading} from '../heading/Heading'
10
10
  import {IconButton} from '../icon-button/IconButton'
11
- import {type ModalProps, modalProps} from './modal.props'
11
+ import {type DialogProps, dialogProps} from './dialog.props'
12
12
 
13
- const modalClassName = suffixClassName('sui-Modal')
14
- const modalContentClassName = suffixClassName('sui-ModalContent')
15
- const modalFooterClassName = suffixClassName('sui-ModalFooter')
13
+ const dialogClassName = suffixClassName('sui-Dialog')
14
+ const dialogContentClassName = suffixClassName('sui-DialogContent')
15
+ const dialogFooterClassName = suffixClassName('sui-DialogFooter')
16
16
 
17
- function ModalRoot({open = false, size = 0, ...props}: ModalProps) {
17
+ function DialogRoot({open = false, size = 0, ...props}: DialogProps) {
18
18
  const {children, className, style, header, onClose, ...rest} = getProps(
19
19
  {size, ...props},
20
- modalProps,
20
+ dialogProps,
21
21
  )
22
22
 
23
- const modalRef = useRef<HTMLDialogElement>(null)
23
+ const dialogRef = useRef<HTMLDialogElement>(null)
24
24
  const headerId = useId()
25
25
 
26
- const modalClasses = clsx(
27
- modalClassName,
26
+ const dialogClasses = clsx(
27
+ dialogClassName,
28
28
  'sui-inset0 sui-m-auto sui-radius5 sui-shadow3 sui-p4 sui-flex-direction-column sui-gap4 sui-overflow-y-auto',
29
29
  )
30
30
 
31
31
  useEffect(() => {
32
- const dialogElement = modalRef.current
32
+ const dialogElement = dialogRef.current
33
33
  if (!dialogElement) return
34
34
 
35
35
  // `open` = `open` prop
@@ -46,7 +46,7 @@ function ModalRoot({open = false, size = 0, ...props}: ModalProps) {
46
46
  }
47
47
  }
48
48
 
49
- // Ensure the modal is closed (and thus its `open` attribute updated)
49
+ // Ensure the dialog is closed (and thus its `open` attribute updated)
50
50
  // when the component is unmounted.
51
51
  return () => {
52
52
  dialogElement.close()
@@ -56,13 +56,13 @@ function ModalRoot({open = false, size = 0, ...props}: ModalProps) {
56
56
  return (
57
57
  <dialog
58
58
  {...rest}
59
- ref={modalRef}
59
+ ref={dialogRef}
60
60
  closedby="any"
61
61
  aria-labelledby={header ? headerId : undefined}
62
62
  onClose={onClose}
63
- className={clsx(modalClasses, className)}
63
+ className={clsx(dialogClasses, className)}
64
64
  style={style}
65
- data-ui="Modal"
65
+ data-ui="Dialog"
66
66
  >
67
67
  <Flex flexShrink={0} justifyContent="space-between" alignItems="center">
68
68
  {header ? (
@@ -76,7 +76,7 @@ function ModalRoot({open = false, size = 0, ...props}: ModalProps) {
76
76
  aria-label="Close"
77
77
  level="tertiary"
78
78
  icon={CloseIcon}
79
- onClick={() => modalRef.current?.close()}
79
+ onClick={() => dialogRef.current?.close()}
80
80
  />
81
81
  </Flex>
82
82
  {children}
@@ -84,15 +84,15 @@ function ModalRoot({open = false, size = 0, ...props}: ModalProps) {
84
84
  )
85
85
  }
86
86
 
87
- function ModalContent(props: ComponentProps<'div'>) {
87
+ function DialogContent(props: ComponentProps<'div'>) {
88
88
  const {children, className, style, ...rest} = getProps(props, {})
89
89
 
90
90
  return (
91
91
  <Box
92
92
  {...rest}
93
- className={clsx(modalContentClassName, className)}
93
+ className={clsx(dialogContentClassName, className)}
94
94
  style={style}
95
- data-ui="ModalContent"
95
+ data-ui="DialogContent"
96
96
  flexGrow={1}
97
97
  overflowY="auto"
98
98
  >
@@ -101,15 +101,15 @@ function ModalContent(props: ComponentProps<'div'>) {
101
101
  )
102
102
  }
103
103
 
104
- function ModalFooter(props: ComponentProps<'div'>) {
104
+ function DialogFooter(props: ComponentProps<'div'>) {
105
105
  const {children, className, style, ...rest} = getProps(props, {})
106
106
 
107
107
  return (
108
108
  <Box
109
109
  {...rest}
110
- className={clsx(modalFooterClassName, className)}
110
+ className={clsx(dialogFooterClassName, className)}
111
111
  style={style}
112
- data-ui="ModalFooter"
112
+ data-ui="DialogFooter"
113
113
  flexShrink={0}
114
114
  >
115
115
  {children}
@@ -117,7 +117,7 @@ function ModalFooter(props: ComponentProps<'div'>) {
117
117
  )
118
118
  }
119
119
 
120
- ModalRoot.displayName = 'Modal'
120
+ DialogRoot.displayName = 'Dialog'
121
121
 
122
122
  /**
123
123
  * @beta
@@ -126,14 +126,14 @@ ModalRoot.displayName = 'Modal'
126
126
  * Modal dialogs make their containing documents inert, and render on the topmost
127
127
  * layer within that containing document; they must be dimissed before the containing
128
128
  * document and its contents become unblocked. They also trap focus within the bounds
129
- * of the modal element and its descendants.
129
+ * of the dialog element and its descendants.
130
130
  *
131
131
  * For more on dialogs and modality, refer to the HTML specification for the dialog element:
132
132
  * https://html.spec.whatwg.org/dev/interactive-elements.html#the-dialog-element
133
133
  */
134
- export const Modal = ModalRoot
134
+ export const Dialog = DialogRoot
135
135
 
136
- ModalRoot.Content = ModalContent
137
- ModalRoot.Footer = ModalFooter
136
+ DialogRoot.Content = DialogContent
137
+ DialogRoot.Footer = DialogFooter
138
138
 
139
- export type {ModalProps}
139
+ export type {DialogProps}
@@ -1,5 +1,5 @@
1
- .sui-Modal {
2
- /* Computed width is moderated by Modal's size prop, which controls max-width */
1
+ .sui-Dialog {
2
+ /* Computed width is moderated by Dialog's size prop, which controls max-width */
3
3
  width: calc(100dvw - 2rem);
4
4
  max-height: calc(100dvh - 2rem);
5
5
  transition:
@@ -9,41 +9,41 @@
9
9
  scale 150ms var(--timing-curve);
10
10
  }
11
11
 
12
- .sui-Modal:not([open]) {
12
+ .sui-Dialog:not([open]) {
13
13
  opacity: 0;
14
14
  scale: 0.9;
15
15
  }
16
16
 
17
- .sui-Modal[open] {
17
+ .sui-Dialog[open] {
18
18
  display: flex;
19
19
  opacity: 1;
20
20
  scale: 1;
21
21
  }
22
22
 
23
- .sui-Modal::backdrop {
24
- --modal-backdrop: hsl(from var(--separator-high) h s l / var(--overlay-opacity));
25
- background-color: var(--modal-backdrop);
23
+ .sui-Dialog::backdrop {
24
+ --dialog-backdrop: hsl(from var(--separator-high) h s l / var(--overlay-opacity));
25
+ background-color: var(--dialog-backdrop);
26
26
  transition:
27
27
  display 150ms allow-discrete,
28
28
  overlay 150ms allow-discrete,
29
29
  opacity 150ms var(--timing-linear);
30
30
  }
31
31
 
32
- .sui-Modal:not([open])::backdrop {
32
+ .sui-Dialog:not([open])::backdrop {
33
33
  opacity: 0;
34
34
  }
35
35
 
36
- .sui-Modal[open]::backdrop {
36
+ .sui-Dialog[open]::backdrop {
37
37
  opacity: 1;
38
38
  }
39
39
 
40
40
  @starting-style {
41
- .sui-Modal[open] {
41
+ .sui-Dialog[open] {
42
42
  opacity: 0;
43
43
  scale: 0.9;
44
44
  }
45
45
 
46
- .sui-Modal[open]::backdrop {
46
+ .sui-Dialog[open]::backdrop {
47
47
  opacity: 0;
48
48
  }
49
49
  }
@@ -3,18 +3,18 @@ import {type PropDef} from '../../types/PropDef'
3
3
  import type {Responsive} from '../../types/Responsive'
4
4
 
5
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 */
6
+ export interface DialogProps extends Omit<React.ComponentProps<'dialog'>, 'open'> {
7
+ /** Text to be displayed as the dialog's heading; optional but recommended for optimal accessibility and presentation */
8
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.) */
9
+ /** Used to set the value of open to false. Fires whenever the dialog is closed, either programmatically or by the user (via Esc key, clicking background, clicking the dialog's close button, or any other means.) */
10
10
  onClose: React.ReactEventHandler<HTMLDialogElement>
11
- /** Whether the modal is open; defaults to false. */
11
+ /** Whether the dialog is open; defaults to false. */
12
12
  open?: boolean
13
- /** Max width of the modal */
13
+ /** Max width of the dialog */
14
14
  size?: Responsive<ContainerSize>
15
15
  }
16
16
 
17
- export const modalProps: Record<string, PropDef> = {
17
+ export const dialogProps: Record<string, PropDef> = {
18
18
  header: {
19
19
  type: 'string',
20
20
  },
@@ -4,6 +4,7 @@
4
4
  @import './checkbox/checkbox.css';
5
5
  @import './code/code.css';
6
6
  @import './container/container.css';
7
+ @import './dialog/dialog.css';
7
8
  @import './eyebrow/eyebrow.css';
8
9
  @import './flex/flex.css';
9
10
  @import './grid/grid.css';
@@ -15,7 +16,6 @@
15
16
  @import './label/label.css';
16
17
  @import './link/link.css';
17
18
  @import './list/list.css';
18
- @import './modal/modal.css';
19
19
  @import './popover/popover.css';
20
20
  @import './press-area/press-area.css';
21
21
  @import './radio/radio.css';
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 = '500alpha7'
3
+ export const HASH = '47d232'