@sanity/ui 4.2.0 → 5.0.0-alpha.10

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 (339) hide show
  1. package/README.md +194 -28
  2. package/bin/sanity-ui.js +14 -0
  3. package/dist/_chunks-es/LazyRefractor.js +20 -0
  4. package/dist/_chunks-es/LazyRefractor.js.map +1 -0
  5. package/dist/cli/checks.js +148 -0
  6. package/dist/cli/config.js +23 -0
  7. package/dist/cli/detect.js +181 -0
  8. package/dist/cli/doctor.js +49 -0
  9. package/dist/cli/index.js +69 -0
  10. package/dist/cli/init.js +189 -0
  11. package/dist/cli/install.js +79 -0
  12. package/dist/cli/log.js +66 -0
  13. package/dist/cli/selfPackage.js +11 -0
  14. package/dist/cli/styles.js +185 -0
  15. package/dist/cli/test-utils.js +8 -0
  16. package/dist/cli/tsconfig.js +236 -0
  17. package/dist/cli/types.js +1 -0
  18. package/dist/cli/versions.js +45 -0
  19. package/dist/index.d.ts +1203 -1469
  20. package/dist/index.js +2123 -1989
  21. package/dist/index.js.map +1 -1
  22. package/dist/polyfills.d.ts +1 -0
  23. package/dist/polyfills.js +5 -0
  24. package/dist/polyfills.js.map +1 -0
  25. package/dist/styles.css +1 -547
  26. package/package.json +57 -58
  27. package/src/cli/checks.test.ts +38 -0
  28. package/src/cli/checks.ts +200 -0
  29. package/src/cli/config.ts +44 -0
  30. package/src/cli/detect.test.ts +191 -0
  31. package/src/cli/detect.ts +205 -0
  32. package/src/cli/doctor.test.ts +52 -0
  33. package/src/cli/doctor.ts +65 -0
  34. package/src/cli/index.ts +77 -0
  35. package/src/cli/init.ts +225 -0
  36. package/src/cli/install.test.ts +52 -0
  37. package/src/cli/install.ts +108 -0
  38. package/src/cli/log.ts +79 -0
  39. package/src/cli/selfPackage.ts +14 -0
  40. package/src/cli/styles.test.ts +130 -0
  41. package/src/cli/styles.ts +205 -0
  42. package/src/cli/test-utils.ts +10 -0
  43. package/src/cli/tsconfig.test.ts +174 -0
  44. package/src/cli/tsconfig.ts +282 -0
  45. package/src/cli/types.ts +77 -0
  46. package/src/cli/versions.test.ts +35 -0
  47. package/src/cli/versions.ts +41 -0
  48. package/src/components/badge/Badge.tsx +53 -0
  49. package/src/components/badge/badge.css +6 -0
  50. package/src/components/badge/badge.props.ts +31 -0
  51. package/src/components/box/Box.tsx +30 -0
  52. package/src/components/box/box.css +4 -0
  53. package/src/components/box/box.props.ts +29 -0
  54. package/src/components/button/Button.tsx +78 -0
  55. package/src/components/button/button.css +72 -0
  56. package/src/components/button/button.props.ts +122 -0
  57. package/src/components/card/Card.tsx +31 -0
  58. package/src/components/card/card.css +4 -0
  59. package/src/components/card/card.props.ts +58 -0
  60. package/src/components/checkbox/Checkbox.tsx +64 -0
  61. package/src/components/checkbox/checkbox.css +100 -0
  62. package/src/components/checkbox/checkbox.props.ts +33 -0
  63. package/src/components/code/Code.tsx +38 -0
  64. package/src/components/code/LazyRefractor.tsx +9 -0
  65. package/src/components/code/code.css +40 -0
  66. package/src/components/code/code.props.ts +44 -0
  67. package/src/components/container/Container.tsx +30 -0
  68. package/src/components/container/container.css +4 -0
  69. package/src/components/container/container.props.ts +28 -0
  70. package/src/components/dialog/Dialog.tsx +139 -0
  71. package/src/components/dialog/dialog.css +49 -0
  72. package/src/components/dialog/dialog.props.ts +45 -0
  73. package/src/components/divider/Divider.tsx +23 -0
  74. package/src/components/divider/divider.props.ts +9 -0
  75. package/src/components/eyebrow/Eyebrow.tsx +54 -0
  76. package/src/components/eyebrow/eyebrow.css +11 -0
  77. package/src/components/eyebrow/eyebrow.props.ts +28 -0
  78. package/src/components/flex/Flex.tsx +30 -0
  79. package/src/components/flex/flex.css +4 -0
  80. package/src/components/flex/flex.props.ts +33 -0
  81. package/src/components/grid/Grid.tsx +30 -0
  82. package/src/components/grid/grid.css +4 -0
  83. package/src/components/grid/grid.props.ts +33 -0
  84. package/src/components/h-stack/HStack.tsx +34 -0
  85. package/src/components/h-stack/hStack.props.ts +17 -0
  86. package/src/components/heading/Heading.tsx +54 -0
  87. package/src/components/heading/heading.css +9 -0
  88. package/src/components/heading/heading.props.ts +31 -0
  89. package/src/components/icon/Icon.tsx +24 -0
  90. package/src/components/icon/icon.css +17 -0
  91. package/src/components/icon/icon.props.ts +35 -0
  92. package/src/components/icon-button/IconButton.tsx +32 -0
  93. package/src/components/icon-button/iconButton.props.ts +31 -0
  94. package/src/components/index.css +28 -0
  95. package/src/components/indicator/Indicator.tsx +42 -0
  96. package/src/components/indicator/indicator.css +4 -0
  97. package/src/components/indicator/indicator.props.ts +24 -0
  98. package/src/components/indicator-stack/IndicatorStack.tsx +31 -0
  99. package/src/components/indicator-stack/indicator-stack.css +7 -0
  100. package/src/components/indicator-stack/indicatorStack.props.ts +15 -0
  101. package/src/components/inline/Inline.tsx +38 -0
  102. package/src/components/inline/inline.css +4 -0
  103. package/src/components/inline/inline.props.ts +100 -0
  104. package/src/components/label/Label.tsx +34 -0
  105. package/src/components/label/label.css +3 -0
  106. package/src/components/label/label.props.ts +25 -0
  107. package/src/components/link/Link.tsx +29 -0
  108. package/src/components/link/link.css +12 -0
  109. package/src/components/link/link.props.ts +23 -0
  110. package/src/components/list/List.tsx +167 -0
  111. package/src/components/list/list.css +25 -0
  112. package/src/components/list/list.props.ts +130 -0
  113. package/src/components/popover/Popover.tsx +85 -0
  114. package/src/components/popover/popover.css +21 -0
  115. package/src/components/popover/popover.props.ts +38 -0
  116. package/src/components/press-area/PressArea.tsx +29 -0
  117. package/src/components/press-area/press-area.css +22 -0
  118. package/src/components/press-area/pressArea.props.ts +16 -0
  119. package/src/components/radio/Radio.tsx +48 -0
  120. package/src/components/radio/radio.css +97 -0
  121. package/src/components/radio/radio.props.ts +25 -0
  122. package/src/components/skip-to-content/SkipToContent.tsx +35 -0
  123. package/src/components/skip-to-content/skip-to-content.css +9 -0
  124. package/src/components/skip-to-content/skipToContent.props.ts +25 -0
  125. package/src/components/spinner/Spinner.tsx +28 -0
  126. package/src/components/spinner/spinner.css +10 -0
  127. package/src/components/spinner/spinner.props.ts +19 -0
  128. package/src/components/switch/Switch.tsx +48 -0
  129. package/src/components/switch/switch.css +119 -0
  130. package/src/components/switch/switch.props.ts +25 -0
  131. package/src/components/text/Text.tsx +53 -0
  132. package/src/components/text/text.css +9 -0
  133. package/src/components/text/text.props.ts +28 -0
  134. package/src/components/tooltip/Tooltip.tsx +97 -0
  135. package/src/components/tooltip/tooltip.css +31 -0
  136. package/src/components/tooltip/tooltip.props.ts +36 -0
  137. package/src/components/tooltip-group/TooltipGroup.tsx +64 -0
  138. package/src/components/tooltip-group/tooltipGroup.props.ts +15 -0
  139. package/src/components/v-stack/VStack.tsx +32 -0
  140. package/src/components/v-stack/vStack.props.ts +17 -0
  141. package/src/components/visually-hidden/VisuallyHidden.tsx +29 -0
  142. package/src/components/visually-hidden/visually-hidden.css +9 -0
  143. package/src/components/visually-hidden/visuallyHidden.props.ts +23 -0
  144. package/src/css/classes/dynamic/flex-child.css +5 -0
  145. package/src/css/classes/dynamic/grid-child.css +8 -0
  146. package/src/css/classes/dynamic/grid-parent.css +6 -0
  147. package/src/css/classes/dynamic/height.css +5 -0
  148. package/src/css/classes/dynamic/index.css +7 -0
  149. package/src/css/classes/dynamic/line-clamp.css +5 -0
  150. package/src/css/classes/dynamic/readme.md +3 -0
  151. package/src/css/classes/dynamic/width.css +7 -0
  152. package/src/css/classes/dynamic/z-index.css +3 -0
  153. package/src/css/classes/generic/display.css +10 -0
  154. package/src/css/classes/generic/flex.css +24 -0
  155. package/src/css/classes/generic/grid.css +7 -0
  156. package/src/css/classes/generic/index.css +7 -0
  157. package/src/css/classes/generic/overflow.css +19 -0
  158. package/src/css/classes/generic/placement.css +202 -0
  159. package/src/css/classes/generic/position.css +7 -0
  160. package/src/css/classes/generic/readme.md +3 -0
  161. package/src/css/classes/generic/text-align.css +5 -0
  162. package/src/css/classes/index.css +4 -0
  163. package/src/css/classes/local/animation.css +4 -0
  164. package/src/css/classes/local/border.css +20 -0
  165. package/src/css/classes/local/index.css +6 -0
  166. package/src/css/classes/local/readme.md +3 -0
  167. package/src/css/classes/local/text-overflow.css +5 -0
  168. package/src/css/classes/local/text-trim.css +45 -0
  169. package/src/css/classes/local/tone.css +75 -0
  170. package/src/css/classes/local/top-anchor.css +4 -0
  171. package/src/css/classes/system/color.css +223 -0
  172. package/src/css/classes/system/container.css +8 -0
  173. package/src/css/classes/system/font-family.css +2 -0
  174. package/src/css/classes/system/font-weight.css +4 -0
  175. package/src/css/classes/system/gap.css +37 -0
  176. package/src/css/classes/system/index.css +10 -0
  177. package/src/css/classes/system/inset.css +56 -0
  178. package/src/css/classes/system/margin.css +148 -0
  179. package/src/css/classes/system/padding.css +78 -0
  180. package/src/css/classes/system/radius.css +10 -0
  181. package/src/css/classes/system/readme.md +3 -0
  182. package/src/css/classes/system/shadow.css +6 -0
  183. package/src/css/classes/system/typography.css +31 -0
  184. package/src/css/global/font-face.css +20 -0
  185. package/src/css/global/index.css +2 -0
  186. package/src/css/global/reset.css +76 -0
  187. package/src/css/tokens/index.css +3 -0
  188. package/src/css/tokens/opacity.css +6 -0
  189. package/src/css/tokens/semantic.css +25 -0
  190. package/src/css/tokens/surface.css +27 -0
  191. package/src/hooks/useIsClient.ts +10 -0
  192. package/src/index.css +18 -0
  193. package/src/index.ts +65 -0
  194. package/src/polyfills.ts +15 -0
  195. package/src/props/border.ts +51 -0
  196. package/src/props/flexChild.ts +29 -0
  197. package/src/props/flexParent.ts +47 -0
  198. package/src/props/gap.ts +31 -0
  199. package/src/props/gridChild.ts +50 -0
  200. package/src/props/gridParent.ts +45 -0
  201. package/src/props/height.ts +29 -0
  202. package/src/props/layout.ts +44 -0
  203. package/src/props/margin.ts +59 -0
  204. package/src/props/overflow.ts +30 -0
  205. package/src/props/padding.ts +59 -0
  206. package/src/props/placement.ts +16 -0
  207. package/src/props/position.ts +52 -0
  208. package/src/props/shadow.ts +15 -0
  209. package/src/props/tone.ts +15 -0
  210. package/src/props/typography.ts +62 -0
  211. package/src/props/width.ts +29 -0
  212. package/src/props/zIndex.ts +15 -0
  213. package/src/styles.css.d.ts +1 -0
  214. package/src/styles.css.node.js +2 -0
  215. package/src/styles.css.test.ts +24 -0
  216. package/src/types/Button.ts +8 -0
  217. package/src/types/Code.ts +6 -0
  218. package/src/types/Container.ts +3 -0
  219. package/src/types/Density.ts +3 -0
  220. package/src/types/Display.ts +11 -0
  221. package/src/types/Eyebrow.ts +3 -0
  222. package/src/types/Flex.ts +22 -0
  223. package/src/types/FontWeight.ts +3 -0
  224. package/src/types/Grid.ts +3 -0
  225. package/src/types/Heading.ts +6 -0
  226. package/src/types/Icon.ts +3 -0
  227. package/src/types/Interactive.ts +8 -0
  228. package/src/types/List.ts +2 -0
  229. package/src/types/Overflow.ts +3 -0
  230. package/src/types/Placement.ts +16 -0
  231. package/src/types/Position.ts +3 -0
  232. package/src/types/PropDef.ts +73 -0
  233. package/src/types/Radius.ts +3 -0
  234. package/src/types/Responsive.ts +10 -0
  235. package/src/types/Shadow.ts +3 -0
  236. package/src/types/Space.ts +15 -0
  237. package/src/types/Text.ts +3 -0
  238. package/src/types/TextAlign.ts +3 -0
  239. package/src/types/Tone.ts +3 -0
  240. package/src/utils/getProps.test.ts +156 -0
  241. package/src/utils/getProps.ts +156 -0
  242. package/src/utils/mergeTriggerProps.ts +66 -0
  243. package/src/utils/renderPortal.tsx +14 -0
  244. package/src/utils/suffixClassName.ts +5 -0
  245. package/src/version.ts +3 -0
  246. package/LICENSE +0 -21
  247. package/dist/_system-CTe2lb5l.d.ts +0 -40
  248. package/dist/_system-CTe2lb5l.d.ts.map +0 -1
  249. package/dist/arrow-BmX6qbAS.js +0 -170
  250. package/dist/arrow-BmX6qbAS.js.map +0 -1
  251. package/dist/autocomplete.d.ts +0 -140
  252. package/dist/autocomplete.d.ts.map +0 -1
  253. package/dist/autocomplete.js +0 -470
  254. package/dist/autocomplete.js.map +0 -1
  255. package/dist/breadcrumbs.d.ts +0 -18
  256. package/dist/breadcrumbs.d.ts.map +0 -1
  257. package/dist/breadcrumbs.js +0 -119
  258. package/dist/breadcrumbs.js.map +0 -1
  259. package/dist/button-BNyKSDyA.js +0 -180
  260. package/dist/button-BNyKSDyA.js.map +0 -1
  261. package/dist/button-dnqMFkWg.d.ts +0 -76
  262. package/dist/button-dnqMFkWg.d.ts.map +0 -1
  263. package/dist/card-C0a0wQTc.d.ts +0 -7
  264. package/dist/card-C0a0wQTc.d.ts.map +0 -1
  265. package/dist/code.d.ts +0 -20
  266. package/dist/code.d.ts.map +0 -1
  267. package/dist/code.js +0 -90
  268. package/dist/code.js.map +0 -1
  269. package/dist/codeFontStyle-84SMhFtI.js +0 -11
  270. package/dist/codeFontStyle-84SMhFtI.js.map +0 -1
  271. package/dist/component-DVlwaWB-.d.ts +0 -25
  272. package/dist/component-DVlwaWB-.d.ts.map +0 -1
  273. package/dist/element-BYgCE_iK.js +0 -51
  274. package/dist/element-BYgCE_iK.js.map +0 -1
  275. package/dist/factory-BzXTX8_Q.js +0 -3056
  276. package/dist/factory-BzXTX8_Q.js.map +0 -1
  277. package/dist/flex-DmbDG2ks.js +0 -76
  278. package/dist/flex-DmbDG2ks.js.map +0 -1
  279. package/dist/font-EtfxKPUz.d.ts +0 -49
  280. package/dist/font-EtfxKPUz.d.ts.map +0 -1
  281. package/dist/getElementRef-Jw7gY0eV.js +0 -102
  282. package/dist/getElementRef-Jw7gY0eV.js.map +0 -1
  283. package/dist/getScopedTheme-C-sZsyAz.js +0 -267
  284. package/dist/getScopedTheme-C-sZsyAz.js.map +0 -1
  285. package/dist/getTheme_v2-y09KqtEb.js +0 -487
  286. package/dist/getTheme_v2-y09KqtEb.js.map +0 -1
  287. package/dist/grid-6JSgMj1O.js +0 -115
  288. package/dist/grid-6JSgMj1O.js.map +0 -1
  289. package/dist/helpers-C8xxXAQC.js +0 -63
  290. package/dist/helpers-C8xxXAQC.js.map +0 -1
  291. package/dist/hotkeys-CaHsQlsO.js +0 -168
  292. package/dist/hotkeys-CaHsQlsO.js.map +0 -1
  293. package/dist/index.d.ts.map +0 -1
  294. package/dist/layer-Bl5R3uNR.js +0 -61
  295. package/dist/layer-Bl5R3uNR.js.map +0 -1
  296. package/dist/layer-ChlP9Ik6.d.ts +0 -242
  297. package/dist/layer-ChlP9Ik6.d.ts.map +0 -1
  298. package/dist/menu.d.ts +0 -146
  299. package/dist/menu.d.ts.map +0 -1
  300. package/dist/menu.js +0 -626
  301. package/dist/menu.js.map +0 -1
  302. package/dist/popover-B7-28L8y.js +0 -408
  303. package/dist/popover-B7-28L8y.js.map +0 -1
  304. package/dist/popover-CMlQeKn0.d.ts +0 -96
  305. package/dist/popover-CMlQeKn0.d.ts.map +0 -1
  306. package/dist/popover.d.ts +0 -2
  307. package/dist/popover.js +0 -3
  308. package/dist/refractor-CC48DwHi.js +0 -20
  309. package/dist/refractor-CC48DwHi.js.map +0 -1
  310. package/dist/responsiveFont-CilwaORG.js +0 -55
  311. package/dist/responsiveFont-CilwaORG.js.map +0 -1
  312. package/dist/rgba-BSYaEUW6.d.ts +0 -846
  313. package/dist/rgba-BSYaEUW6.d.ts.map +0 -1
  314. package/dist/selectable-B0GUIL74.d.ts +0 -7
  315. package/dist/selectable-B0GUIL74.d.ts.map +0 -1
  316. package/dist/stack-rsNFPq2-.js +0 -112
  317. package/dist/stack-rsNFPq2-.js.map +0 -1
  318. package/dist/styles-css.d.ts +0 -2
  319. package/dist/styles-css.js +0 -4
  320. package/dist/textInput-pSfQjkmx.js +0 -313
  321. package/dist/textInput-pSfQjkmx.js.map +0 -1
  322. package/dist/theme.d.ts +0 -280
  323. package/dist/theme.d.ts.map +0 -1
  324. package/dist/theme.js +0 -55
  325. package/dist/theme.js.map +0 -1
  326. package/dist/toast.d.ts +0 -73
  327. package/dist/toast.d.ts.map +0 -1
  328. package/dist/toast.js +0 -302
  329. package/dist/toast.js.map +0 -1
  330. package/dist/tooltip.d.ts +0 -88
  331. package/dist/tooltip.d.ts.map +0 -1
  332. package/dist/tooltip.js +0 -435
  333. package/dist/tooltip.js.map +0 -1
  334. package/dist/useClickOutsideEvent-wGLGWBZN.js +0 -36
  335. package/dist/useClickOutsideEvent-wGLGWBZN.js.map +0 -1
  336. package/dist/useElementSize-BJvbGHq8.js +0 -51
  337. package/dist/useElementSize-BJvbGHq8.js.map +0 -1
  338. package/dist/useLayer-D1usxIE0.js +0 -712
  339. package/dist/useLayer-D1usxIE0.js.map +0 -1
@@ -0,0 +1,38 @@
1
+ import clsx from 'clsx'
2
+ import {type ComponentPropsWithRef, lazy, Suspense} from 'react'
3
+
4
+ import {type CodeTag} from '../../types/Code'
5
+ import {getProps} from '../../utils/getProps'
6
+ import {suffixClassName} from '../../utils/suffixClassName'
7
+ import {type CodeProps, codeProps} from './code.props'
8
+
9
+ const LazyRefractor = lazy(() => import('./LazyRefractor'))
10
+
11
+ const codeClassName = suffixClassName('sui-Code')
12
+
13
+ /** @public */
14
+ export function Code<T extends CodeTag = 'pre'>({
15
+ size = 2,
16
+ ...props
17
+ }: CodeProps<T> & Omit<ComponentPropsWithRef<T>, keyof CodeProps<T>>) {
18
+ const {as, children, className, language, style, ...rest} = getProps({size, ...props}, codeProps)
19
+ const Component = as || 'pre'
20
+
21
+ if (!language) {
22
+ return (
23
+ <Component className={clsx(codeClassName, className)} style={style} data-ui="Code" {...rest}>
24
+ <code>{children}</code>
25
+ </Component>
26
+ )
27
+ }
28
+
29
+ return (
30
+ <Component className={clsx(codeClassName, className)} style={style} data-ui="Code" {...rest}>
31
+ <Suspense fallback={<code>{children}</code>}>
32
+ <LazyRefractor language={language} value={children} />
33
+ </Suspense>
34
+ </Component>
35
+ )
36
+ }
37
+
38
+ export type {CodeProps}
@@ -0,0 +1,9 @@
1
+ import {hasLanguage, Refractor, type RefractorProps} from 'react-refractor'
2
+
3
+ export default function LazyRefractor({language, value}: RefractorProps) {
4
+ if (!hasLanguage(language)) {
5
+ return <code>{value}</code>
6
+ }
7
+
8
+ return <Refractor inline language={language} value={value} />
9
+ }
@@ -0,0 +1,40 @@
1
+ .sui-Code {
2
+ --code-color: light-dark(var(--gray-700), var(--gray-400));
3
+ color: var(--code-color);
4
+ }
5
+
6
+ .sui-Code .atrule { color: light-dark(var(--purple-600), var(--purple-400)); }
7
+ .sui-Code .attr-name { color: light-dark(var(--green-600), var(--green-400)); }
8
+ .sui-Code .attr-value { color: light-dark(var(--yellow-700), var(--yellow-400)); }
9
+ .sui-Code .attribute { color: light-dark(var(--yellow-700), var(--yellow-400)); }
10
+ .sui-Code .boolean { color: light-dark(var(--purple-600), var(--purple-400)); }
11
+ .sui-Code .builtin { color: light-dark(var(--purple-600), var(--purple-400)); }
12
+ .sui-Code .cdata { color: light-dark(var(--yellow-700), var(--yellow-400)); }
13
+ .sui-Code .char { color: light-dark(var(--yellow-700), var(--yellow-400)); }
14
+ .sui-Code .class { color: light-dark(var(--orange-600), var(--orange-400)); }
15
+ .sui-Code .class-name { color: light-dark(var(--cyan-600), var(--cyan-400)); }
16
+ .sui-Code .comment { color: light-dark(var(--gray-700), var(--gray-400)); opacity: 0.75; }
17
+ .sui-Code .constant { color: light-dark(var(--purple-600), var(--purple-400)); }
18
+ .sui-Code .deleted { color: light-dark(var(--red-700), var(--red-400)); }
19
+ .sui-Code .entity { color: light-dark(var(--red-700), var(--red-400)); }
20
+ .sui-Code .function { color: light-dark(var(--green-600), var(--green-400)); }
21
+ .sui-Code .hexcode { color: light-dark(var(--blue-600), var(--blue-400)); }
22
+ .sui-Code .id { color: light-dark(var(--purple-600), var(--purple-400)); }
23
+ .sui-Code .important { color: light-dark(var(--purple-600), var(--purple-400)); }
24
+ .sui-Code .inserted { color: light-dark(var(--green-600), var(--green-400)); }
25
+ .sui-Code .keyword { color: light-dark(var(--magenta-600), var(--magenta-400)); }
26
+ .sui-Code .number { color: light-dark(var(--purple-600), var(--purple-400)); }
27
+ .sui-Code .operator { color: light-dark(var(--magenta-600), var(--magenta-400)); }
28
+ .sui-Code .prolog { color: light-dark(var(--gray-700), var(--gray-400)); }
29
+ .sui-Code .property { color: light-dark(var(--blue-600), var(--blue-400)); }
30
+ .sui-Code .pseudo-class { color: light-dark(var(--yellow-700), var(--yellow-400)); }
31
+ .sui-Code .pseudo-element { color: light-dark(var(--yellow-700), var(--yellow-400)); }
32
+ .sui-Code .punctuation { color: light-dark(var(--gray-700), var(--gray-400)); }
33
+ .sui-Code .regex { color: light-dark(var(--blue-600), var(--blue-400)); }
34
+ .sui-Code .selector { color: light-dark(var(--red-700), var(--red-400)); }
35
+ .sui-Code .string { color: light-dark(var(--yellow-700), var(--yellow-400)); }
36
+ .sui-Code .symbol { color: light-dark(var(--purple-600), var(--purple-400)); }
37
+ .sui-Code .tag { color: light-dark(var(--red-700), var(--red-400)); }
38
+ .sui-Code .unit { color: light-dark(var(--orange-600), var(--orange-400)); }
39
+ .sui-Code .url { color: light-dark(var(--red-700), var(--red-400)); }
40
+ .sui-Code .variable { color: light-dark(var(--red-700), var(--red-400)); }
@@ -0,0 +1,44 @@
1
+ import {marginProps} from '../../props/margin'
2
+ import {type TypographyProps, typographyProps} from '../../props/typography'
3
+ import {CODE_SIZE, CODE_TAG, type CodeSize, type CodeTag} from '../../types/Code'
4
+ import {type PropDef} from '../../types/PropDef'
5
+ import type {Responsive} from '../../types/Responsive'
6
+
7
+ /** @public */
8
+ export interface CodeProps<T extends CodeTag = 'pre'> extends Omit<
9
+ TypographyProps,
10
+ 'align' | 'truncate' | 'tone'
11
+ > {
12
+ /**
13
+ * HTML element or component to render.
14
+ * @remarks The defined element wraps an inner `<code>` tag.
15
+ */
16
+ as?: T
17
+ /**
18
+ * Refractor language for syntax highlighting.
19
+ */
20
+ language?: string
21
+ /**
22
+ * Sets font size.
23
+ */
24
+ size?: Responsive<CodeSize>
25
+ }
26
+
27
+ export const codeProps: Record<string, PropDef> = {
28
+ as: {
29
+ type: 'union',
30
+ values: CODE_TAG,
31
+ },
32
+ language: {
33
+ type: 'string',
34
+ },
35
+ size: {
36
+ type: 'union',
37
+ className: 'text-code',
38
+ values: CODE_SIZE,
39
+ },
40
+ muted: typographyProps['muted'] as PropDef,
41
+ trim: typographyProps['trim'] as PropDef,
42
+ weight: typographyProps['weight'] as PropDef,
43
+ ...marginProps,
44
+ }
@@ -0,0 +1,30 @@
1
+ import clsx from 'clsx'
2
+ import type {ComponentPropsWithRef, ElementType} from 'react'
3
+
4
+ import {getProps} from '../../utils/getProps'
5
+ import {suffixClassName} from '../../utils/suffixClassName'
6
+ import {type ContainerProps, containerProps} from './container.props'
7
+
8
+ const containerClassName = suffixClassName('sui-Container')
9
+
10
+ /** @public */
11
+ export function Container<T extends ElementType = 'div'>({
12
+ marginX = 'auto',
13
+ ...props
14
+ }: ContainerProps<T> & Omit<ComponentPropsWithRef<T>, keyof ContainerProps<T>>) {
15
+ const {as, children, className, style, ...rest} = getProps({marginX, ...props}, containerProps)
16
+ const Component = as || 'div'
17
+
18
+ return (
19
+ <Component
20
+ className={clsx(containerClassName, className)}
21
+ style={style}
22
+ data-ui="Container"
23
+ {...rest}
24
+ >
25
+ {children}
26
+ </Component>
27
+ )
28
+ }
29
+
30
+ export type {ContainerProps}
@@ -0,0 +1,4 @@
1
+ .sui-Container[class*='sui-tone'] {
2
+ --container-background: var(--background-low);
3
+ background-color: var(--container-background);
4
+ }
@@ -0,0 +1,28 @@
1
+ import {type LayoutProps, layoutProps} from '../../props/layout'
2
+ import {CONTAINER_SIZE, type ContainerSize} from '../../types/Container'
3
+ import {type PropDef} from '../../types/PropDef'
4
+ import type {Responsive} from '../../types/Responsive'
5
+
6
+ /** @public */
7
+ export interface ContainerProps<T extends React.ElementType = 'div'> extends LayoutProps {
8
+ /**
9
+ * HTML element or component to render.
10
+ */
11
+ as?: T
12
+ /**
13
+ * Maximum width of the container.
14
+ */
15
+ size?: Responsive<ContainerSize>
16
+ }
17
+
18
+ export const containerProps: Record<string, PropDef> = {
19
+ as: {
20
+ type: 'string',
21
+ },
22
+ size: {
23
+ type: 'union',
24
+ className: 'container',
25
+ values: CONTAINER_SIZE,
26
+ },
27
+ ...layoutProps,
28
+ }
@@ -0,0 +1,139 @@
1
+ import {CloseIcon} from '@sanity/icons/Close'
2
+ import clsx from 'clsx'
3
+ import {type ComponentProps, useEffect, useId, useRef} from 'react'
4
+
5
+ import {getProps} from '../../utils/getProps'
6
+ import {suffixClassName} from '../../utils/suffixClassName'
7
+ import {Box} from '../box/Box'
8
+ import {Flex} from '../flex/Flex'
9
+ import {Heading} from '../heading/Heading'
10
+ import {IconButton} from '../icon-button/IconButton'
11
+ import {type DialogProps, dialogProps} from './dialog.props'
12
+
13
+ const dialogClassName = suffixClassName('sui-Dialog')
14
+ const dialogContentClassName = suffixClassName('sui-DialogContent')
15
+ const dialogFooterClassName = suffixClassName('sui-DialogFooter')
16
+
17
+ function DialogRoot({open = false, size = 0, ...props}: DialogProps) {
18
+ const {children, className, style, header, onClose, ...rest} = getProps(
19
+ {size, ...props},
20
+ dialogProps,
21
+ )
22
+
23
+ const dialogRef = useRef<HTMLDialogElement>(null)
24
+ const headerId = useId()
25
+
26
+ const dialogClasses = clsx(
27
+ dialogClassName,
28
+ `${props.topAnchor ? 'sui-mx-auto' : 'sui-m-auto'} sui-radius5 sui-shadow3 sui-p4 sui-flex-direction-column sui-gap4 sui-overflow-y-auto`,
29
+ )
30
+
31
+ useEffect(() => {
32
+ const dialogElement = dialogRef.current
33
+ if (!dialogElement) return
34
+
35
+ // `open` = `open` prop
36
+ // dialogElement.open = the `open` attribute on the HTML dialog element
37
+ // The prop and the attribute are manipulated independently, thus they
38
+ // can get out of sync if not handled within this effect.
39
+ if (open) {
40
+ if (!dialogElement.open) {
41
+ dialogElement.showModal()
42
+ }
43
+ } else {
44
+ if (dialogElement.open) {
45
+ dialogElement.close()
46
+ }
47
+ }
48
+
49
+ // Ensure the dialog is closed (and thus its `open` attribute updated)
50
+ // when the component is unmounted.
51
+ return () => {
52
+ dialogElement.close()
53
+ }
54
+ }, [open])
55
+
56
+ return (
57
+ <dialog
58
+ {...rest}
59
+ ref={dialogRef}
60
+ closedby="any"
61
+ aria-labelledby={header ? headerId : undefined}
62
+ onClose={onClose}
63
+ className={clsx(dialogClasses, className)}
64
+ style={style}
65
+ data-ui="Dialog"
66
+ >
67
+ <Flex flexShrink={0} justifyContent="space-between" alignItems="center">
68
+ {header ? (
69
+ <Heading trim size={1} id={headerId}>
70
+ {header}
71
+ </Heading>
72
+ ) : (
73
+ <div />
74
+ )}
75
+ <IconButton
76
+ aria-label="Close"
77
+ level="tertiary"
78
+ icon={CloseIcon}
79
+ onClick={() => dialogRef.current?.close()}
80
+ />
81
+ </Flex>
82
+ {children}
83
+ </dialog>
84
+ )
85
+ }
86
+
87
+ function DialogContent(props: ComponentProps<'div'>) {
88
+ const {children, className, style, ...rest} = getProps(props, {})
89
+
90
+ return (
91
+ <Box
92
+ {...rest}
93
+ className={clsx(dialogContentClassName, className)}
94
+ style={style}
95
+ data-ui="DialogContent"
96
+ flexGrow={1}
97
+ overflowY="auto"
98
+ >
99
+ {children}
100
+ </Box>
101
+ )
102
+ }
103
+
104
+ function DialogFooter(props: ComponentProps<'div'>) {
105
+ const {children, className, style, ...rest} = getProps(props, {})
106
+
107
+ return (
108
+ <Box
109
+ {...rest}
110
+ className={clsx(dialogFooterClassName, className)}
111
+ style={style}
112
+ data-ui="DialogFooter"
113
+ flexShrink={0}
114
+ >
115
+ {children}
116
+ </Box>
117
+ )
118
+ }
119
+
120
+ DialogRoot.displayName = 'Dialog'
121
+
122
+ /**
123
+ * @beta
124
+ *
125
+ * Renders a modal dialog element — should not be used for nonmodal dialogs.
126
+ * Modal dialogs make their containing documents inert, and render on the topmost
127
+ * layer within that containing document; they must be dimissed before the containing
128
+ * document and its contents become unblocked. They also trap focus within the bounds
129
+ * of the dialog element and its descendants.
130
+ *
131
+ * For more on dialogs and modality, refer to the HTML specification for the dialog element:
132
+ * https://html.spec.whatwg.org/dev/interactive-elements.html#the-dialog-element
133
+ */
134
+ export const Dialog = DialogRoot
135
+
136
+ DialogRoot.Content = DialogContent
137
+ DialogRoot.Footer = DialogFooter
138
+
139
+ export type {DialogProps}
@@ -0,0 +1,49 @@
1
+ .sui-Dialog {
2
+ /* Computed width is moderated by Dialog's size prop, which controls max-width */
3
+ width: calc(100dvw - 2rem);
4
+ max-height: calc(100dvh - 2rem);
5
+ transition:
6
+ display 150ms allow-discrete,
7
+ overlay 150ms allow-discrete,
8
+ opacity 150ms var(--timing-linear),
9
+ scale 150ms var(--timing-curve);
10
+ }
11
+
12
+ .sui-Dialog:not([open]) {
13
+ opacity: 0;
14
+ scale: 0.9;
15
+ }
16
+
17
+ .sui-Dialog[open] {
18
+ display: flex;
19
+ opacity: 1;
20
+ scale: 1;
21
+ }
22
+
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
+ transition:
27
+ display 150ms allow-discrete,
28
+ overlay 150ms allow-discrete,
29
+ opacity 150ms var(--timing-linear);
30
+ }
31
+
32
+ .sui-Dialog:not([open])::backdrop {
33
+ opacity: 0;
34
+ }
35
+
36
+ .sui-Dialog[open]::backdrop {
37
+ opacity: 1;
38
+ }
39
+
40
+ @starting-style {
41
+ .sui-Dialog[open] {
42
+ opacity: 0;
43
+ scale: 0.9;
44
+ }
45
+
46
+ .sui-Dialog[open]::backdrop {
47
+ opacity: 0;
48
+ }
49
+ }
@@ -0,0 +1,45 @@
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 DialogProps extends Omit<React.ComponentProps<'dialog'>, 'open'> {
7
+ /**
8
+ * Text for the dialog heading.
9
+ * @remarks Recommended for accessibility. The component sets `aria-labelledby` to the heading when you give this prop.
10
+ */
11
+ header?: string
12
+ /**
13
+ * A function to call alongside the native `close` event.
14
+ * @remarks Use it to set `open` back to `false`. It runs for every close cause: the Escape key, a backdrop click, the close button, or a programmatic close.
15
+ */
16
+ onClose: React.ReactEventHandler<HTMLDialogElement>
17
+ /**
18
+ * Toggles the dialog's open state.
19
+ * @remarks `true` calls `showModal()` on the element. `false` calls `close()`.
20
+ */
21
+ open?: boolean
22
+ /** Sets the max width of the dialog */
23
+ size?: Responsive<ContainerSize>
24
+ /** CSS length value used to set the Dialog’s distance from the top of the viewport; Dialog is centered if not provided */
25
+ topAnchor?: string
26
+ }
27
+
28
+ export const dialogProps: Record<string, PropDef> = {
29
+ header: {
30
+ type: 'string',
31
+ },
32
+ open: {
33
+ type: 'boolean',
34
+ },
35
+ size: {
36
+ type: 'union',
37
+ className: 'container',
38
+ values: CONTAINER_SIZE,
39
+ },
40
+ topAnchor: {
41
+ type: 'string',
42
+ className: 'top-anchor',
43
+ variable: '--top-anchor',
44
+ },
45
+ }
@@ -0,0 +1,23 @@
1
+ import clsx from 'clsx'
2
+
3
+ import {getProps} from '../../utils/getProps'
4
+ import {suffixClassName} from '../../utils/suffixClassName'
5
+ import {type DividerProps, dividerProps} from './divider.props'
6
+
7
+ const dividerClassName = suffixClassName('sui-Divider')
8
+
9
+ /** @public */
10
+ export function Divider(props: DividerProps) {
11
+ const {className, style, ...rest} = getProps(props, dividerProps)
12
+
13
+ return (
14
+ <hr
15
+ className={clsx(dividerClassName, 'sui-border-none sui-border-top', className)}
16
+ style={style}
17
+ data-ui="Divider"
18
+ {...rest}
19
+ />
20
+ )
21
+ }
22
+
23
+ export type {DividerProps}
@@ -0,0 +1,9 @@
1
+ import {type MarginProps, marginProps} from '../../props/margin'
2
+ import {type PropDef} from '../../types/PropDef'
3
+
4
+ /** @public */
5
+ export interface DividerProps extends React.ComponentProps<'hr'>, MarginProps {}
6
+
7
+ export const dividerProps: Record<string, PropDef> = {
8
+ ...marginProps,
9
+ }
@@ -0,0 +1,54 @@
1
+ import clsx from 'clsx'
2
+ import type {ComponentPropsWithRef, ElementType} from 'react'
3
+
4
+ import {getProps} from '../../utils/getProps'
5
+ import {suffixClassName} from '../../utils/suffixClassName'
6
+ import {type EyebrowProps, eyebrowProps} from './eyebrow.props'
7
+
8
+ const eyebrowClassName = suffixClassName('sui-Eyebrow')
9
+
10
+ /** @public */
11
+ export function Eyebrow<T extends ElementType = 'span'>({
12
+ size = 2,
13
+ weight = 'semibold',
14
+ ...props
15
+ }: EyebrowProps<T> & Omit<ComponentPropsWithRef<T>, keyof EyebrowProps<T>>) {
16
+ const {as, children, className, style, ...rest} = getProps({size, weight, ...props}, eyebrowProps)
17
+ const Component = as || 'span'
18
+
19
+ if (props.truncate && props.trim) {
20
+ return (
21
+ <Component
22
+ className={clsx(
23
+ eyebrowClassName,
24
+ className?.replace('sui-line-clamp', '').replace('sui-text-overflow', ''),
25
+ )}
26
+ style={style}
27
+ data-ui="Eyebrow"
28
+ {...rest}
29
+ >
30
+ <span
31
+ className={clsx(
32
+ 'sui-overflow-hidden',
33
+ props.truncate === 1 ? 'sui-text-overflow' : 'sui-line-clamp',
34
+ )}
35
+ >
36
+ {children}
37
+ </span>
38
+ </Component>
39
+ )
40
+ }
41
+
42
+ return (
43
+ <Component
44
+ className={clsx(eyebrowClassName, props.truncate && 'sui-overflow-hidden', className)}
45
+ style={style}
46
+ data-ui="Eyebrow"
47
+ {...rest}
48
+ >
49
+ {children}
50
+ </Component>
51
+ )
52
+ }
53
+
54
+ export type {EyebrowProps}
@@ -0,0 +1,11 @@
1
+ .sui-Eyebrow {
2
+ --eyebrow-color: var(--foreground-high);
3
+ color: var(--eyebrow-color);
4
+ text-transform: uppercase;
5
+ letter-spacing: 0.5px;
6
+ }
7
+
8
+ .sui-Eyebrow:where(.sui-text-muted) {
9
+ --eyebrow-color-muted: var(--foreground-low);
10
+ color: var(--eyebrow-color-muted);
11
+ }
@@ -0,0 +1,28 @@
1
+ import {type TypographyProps, typographyProps} from '../../props/typography'
2
+ import {EYEBROW_SIZE, type EyebrowSize} from '../../types/Eyebrow'
3
+ import {type PropDef} from '../../types/PropDef'
4
+ import type {Responsive} from '../../types/Responsive'
5
+
6
+ /** @public */
7
+ export interface EyebrowProps<T extends React.ElementType = 'span'> extends TypographyProps {
8
+ /**
9
+ * HTML element to render.
10
+ */
11
+ as?: T
12
+ /**
13
+ * Sets font size. Uses the same scale as Label.
14
+ */
15
+ size?: Responsive<EyebrowSize>
16
+ }
17
+
18
+ export const eyebrowProps: Record<string, PropDef> = {
19
+ as: {
20
+ type: 'string',
21
+ },
22
+ size: {
23
+ type: 'union',
24
+ className: 'text-eyebrow',
25
+ values: EYEBROW_SIZE,
26
+ },
27
+ ...typographyProps,
28
+ }
@@ -0,0 +1,30 @@
1
+ import clsx from 'clsx'
2
+ import type {ComponentPropsWithRef, ElementType} from 'react'
3
+
4
+ import {getProps} from '../../utils/getProps'
5
+ import {suffixClassName} from '../../utils/suffixClassName'
6
+ import {type FlexProps, flexProps} from './flex.props'
7
+
8
+ const flexClassName = suffixClassName('sui-Flex')
9
+
10
+ /** @public */
11
+ export function Flex<T extends ElementType = 'div'>({
12
+ display = 'flex',
13
+ minHeight = '0',
14
+ minWidth = '0',
15
+ ...props
16
+ }: FlexProps<T> & Omit<ComponentPropsWithRef<T>, keyof FlexProps<T>>) {
17
+ const {as, children, className, style, ...rest} = getProps(
18
+ {display, minHeight, minWidth, ...props},
19
+ flexProps,
20
+ )
21
+ const Component = as || 'div'
22
+
23
+ return (
24
+ <Component className={clsx(flexClassName, className)} style={style} data-ui="Flex" {...rest}>
25
+ {children}
26
+ </Component>
27
+ )
28
+ }
29
+
30
+ export type {FlexProps}
@@ -0,0 +1,4 @@
1
+ .sui-Flex[class*='sui-tone'] {
2
+ --flex-background: var(--background-low);
3
+ background-color: var(--flex-background);
4
+ }
@@ -0,0 +1,33 @@
1
+ import {type FlexParentProps, flexParentProps} from '../../props/flexParent'
2
+ import {type GapProps, gapProps} from '../../props/gap'
3
+ import {type LayoutProps, layoutProps} from '../../props/layout'
4
+ import {DISPLAY_FLEX, type DisplayFlex} from '../../types/Display'
5
+ import {type PropDef} from '../../types/PropDef'
6
+ import type {Responsive} from '../../types/Responsive'
7
+
8
+ /** @public */
9
+ export interface FlexProps<T extends React.ElementType = 'div'>
10
+ extends FlexParentProps, GapProps, LayoutProps {
11
+ /**
12
+ * HTML element or component to render.
13
+ */
14
+ as?: T
15
+ /**
16
+ * CSS `display` property.
17
+ */
18
+ display?: Responsive<DisplayFlex>
19
+ }
20
+
21
+ export const flexProps: Record<string, PropDef> = {
22
+ as: {
23
+ type: 'string',
24
+ },
25
+ display: {
26
+ type: 'union',
27
+ className: 'display',
28
+ values: DISPLAY_FLEX,
29
+ },
30
+ ...flexParentProps,
31
+ ...gapProps,
32
+ ...layoutProps,
33
+ }
@@ -0,0 +1,30 @@
1
+ import clsx from 'clsx'
2
+ import type {ComponentPropsWithRef, ElementType} from 'react'
3
+
4
+ import {getProps} from '../../utils/getProps'
5
+ import {suffixClassName} from '../../utils/suffixClassName'
6
+ import {type GridProps, gridProps} from './grid.props'
7
+
8
+ const gridClassName = suffixClassName('sui-Grid')
9
+
10
+ /** @public */
11
+ export function Grid<T extends ElementType = 'div'>({
12
+ display = 'grid',
13
+ minHeight = '0',
14
+ minWidth = '0',
15
+ ...props
16
+ }: GridProps<T> & Omit<ComponentPropsWithRef<T>, keyof GridProps<T>>) {
17
+ const {as, children, className, style, ...rest} = getProps(
18
+ {display, minHeight, minWidth, ...props},
19
+ gridProps,
20
+ )
21
+ const Component = as || 'div'
22
+
23
+ return (
24
+ <Component className={clsx(gridClassName, className)} style={style} data-ui="Grid" {...rest}>
25
+ {children}
26
+ </Component>
27
+ )
28
+ }
29
+
30
+ export type {GridProps}
@@ -0,0 +1,4 @@
1
+ .sui-Grid[class*='sui-tone'] {
2
+ --grid-background: var(--background-low);
3
+ background-color: var(--grid-background);
4
+ }