@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,29 @@
1
+ import {type PropDef} from '../types/PropDef'
2
+ import {type Responsive} from '../types/Responsive'
3
+
4
+ export type HeightProps = {
5
+ /** CSS **height** property */
6
+ height?: Responsive<string>
7
+ /** CSS **min-height** property */
8
+ minHeight?: Responsive<string>
9
+ /** CSS **max-height** property */
10
+ maxHeight?: Responsive<string>
11
+ }
12
+
13
+ export const heightProps: Record<string, PropDef> = {
14
+ height: {
15
+ type: 'string',
16
+ className: 'height',
17
+ variable: '--height',
18
+ },
19
+ minHeight: {
20
+ type: 'string',
21
+ className: 'min-height',
22
+ variable: '--min-height',
23
+ },
24
+ maxHeight: {
25
+ type: 'string',
26
+ className: 'max-height',
27
+ variable: '--max-height',
28
+ },
29
+ }
@@ -0,0 +1,44 @@
1
+ import {type PropDef} from '../types/PropDef'
2
+ import {type BorderProps, borderProps} from './border'
3
+ import {type FlexChildProps, flexChildProps} from './flexChild'
4
+ import {type GridChildProps, gridChildProps} from './gridChild'
5
+ import {type HeightProps, heightProps} from './height'
6
+ import {type MarginProps, marginProps} from './margin'
7
+ import {type OverflowProps, overflowProps} from './overflow'
8
+ import {type PaddingProps, paddingProps} from './padding'
9
+ import {type PositionProps, positionProps} from './position'
10
+ import {type ShadowProps, shadowProps} from './shadow'
11
+ import {type ToneProps, toneProps} from './tone'
12
+ import {type WidthProps, widthProps} from './width'
13
+ import {type ZIndexProps, zIndexProps} from './zIndex'
14
+
15
+ /** @public */
16
+ export interface LayoutProps
17
+ extends
18
+ ToneProps,
19
+ WidthProps,
20
+ HeightProps,
21
+ MarginProps,
22
+ BorderProps,
23
+ PaddingProps,
24
+ PositionProps,
25
+ OverflowProps,
26
+ FlexChildProps,
27
+ GridChildProps,
28
+ ZIndexProps,
29
+ ShadowProps {}
30
+
31
+ export const layoutProps: Record<string, PropDef> = {
32
+ ...toneProps,
33
+ ...widthProps,
34
+ ...heightProps,
35
+ ...marginProps,
36
+ ...borderProps,
37
+ ...paddingProps,
38
+ ...positionProps,
39
+ ...overflowProps,
40
+ ...flexChildProps,
41
+ ...gridChildProps,
42
+ ...shadowProps,
43
+ ...zIndexProps,
44
+ }
@@ -0,0 +1,59 @@
1
+ import {type PropDef} from '../types/PropDef'
2
+ import {type Responsive} from '../types/Responsive'
3
+ import {SPACE_AUTO_NEGATIVE, type SpaceAutoNegative} from '../types/Space'
4
+
5
+ /** @public */
6
+ export type MarginProps = {
7
+ /** CSS **margin** property */
8
+ margin?: Responsive<SpaceAutoNegative>
9
+ /** CSS **margin-left** and **margin-right** properties */
10
+ marginX?: Responsive<SpaceAutoNegative>
11
+ /** CSS **margin-top** and **margin-bottom** properties */
12
+ marginY?: Responsive<SpaceAutoNegative>
13
+ /** CSS **margin-top** property */
14
+ marginTop?: Responsive<SpaceAutoNegative>
15
+ /** CSS **margin-right** property */
16
+ marginRight?: Responsive<SpaceAutoNegative>
17
+ /** CSS **margin-bottom** property */
18
+ marginBottom?: Responsive<SpaceAutoNegative>
19
+ /** CSS **margin-left** property */
20
+ marginLeft?: Responsive<SpaceAutoNegative>
21
+ }
22
+
23
+ export const marginProps: Record<string, PropDef> = {
24
+ margin: {
25
+ type: 'union',
26
+ className: 'm',
27
+ values: SPACE_AUTO_NEGATIVE,
28
+ },
29
+ marginX: {
30
+ type: 'union',
31
+ className: 'mx',
32
+ values: SPACE_AUTO_NEGATIVE,
33
+ },
34
+ marginY: {
35
+ type: 'union',
36
+ className: 'my',
37
+ values: SPACE_AUTO_NEGATIVE,
38
+ },
39
+ marginTop: {
40
+ type: 'union',
41
+ className: 'mt',
42
+ values: SPACE_AUTO_NEGATIVE,
43
+ },
44
+ marginRight: {
45
+ type: 'union',
46
+ className: 'mr',
47
+ values: SPACE_AUTO_NEGATIVE,
48
+ },
49
+ marginBottom: {
50
+ type: 'union',
51
+ className: 'mb',
52
+ values: SPACE_AUTO_NEGATIVE,
53
+ },
54
+ marginLeft: {
55
+ type: 'union',
56
+ className: 'ml',
57
+ values: SPACE_AUTO_NEGATIVE,
58
+ },
59
+ }
@@ -0,0 +1,30 @@
1
+ import {OVERFLOW, type Overflow} from '../types/Overflow'
2
+ import {type PropDef} from '../types/PropDef'
3
+ import {type Responsive} from '../types/Responsive'
4
+
5
+ export type OverflowProps = {
6
+ /** CSS **overflow** property */
7
+ overflow?: Responsive<Overflow>
8
+ /** CSS **overflow-x** property */
9
+ overflowX?: Responsive<Overflow>
10
+ /** CSS **overflow-y** property */
11
+ overflowY?: Responsive<Overflow>
12
+ }
13
+
14
+ export const overflowProps: Record<string, PropDef> = {
15
+ overflow: {
16
+ type: 'union',
17
+ className: 'overflow',
18
+ values: OVERFLOW,
19
+ },
20
+ overflowX: {
21
+ type: 'union',
22
+ className: 'overflow-x',
23
+ values: OVERFLOW,
24
+ },
25
+ overflowY: {
26
+ type: 'union',
27
+ className: 'overflow-y',
28
+ values: OVERFLOW,
29
+ },
30
+ }
@@ -0,0 +1,59 @@
1
+ import {type PropDef} from '../types/PropDef'
2
+ import {type Responsive} from '../types/Responsive'
3
+ import {SPACE, type Space} from '../types/Space'
4
+
5
+ /** @public */
6
+ export interface PaddingProps {
7
+ /** CSS **padding** property */
8
+ padding?: Responsive<Space>
9
+ /** CSS **padding-left** and **padding-right** properties */
10
+ paddingX?: Responsive<Space>
11
+ /** CSS **padding-top** and **padding-bottom** properties */
12
+ paddingY?: Responsive<Space>
13
+ /** CSS **padding-top** property */
14
+ paddingTop?: Responsive<Space>
15
+ /** CSS **padding-right** property */
16
+ paddingRight?: Responsive<Space>
17
+ /** CSS **padding-bottom** property */
18
+ paddingBottom?: Responsive<Space>
19
+ /** CSS **padding-left** property */
20
+ paddingLeft?: Responsive<Space>
21
+ }
22
+
23
+ export const paddingProps: Record<string, PropDef> = {
24
+ padding: {
25
+ type: 'union',
26
+ className: 'p',
27
+ values: SPACE,
28
+ },
29
+ paddingX: {
30
+ type: 'union',
31
+ className: 'px',
32
+ values: SPACE,
33
+ },
34
+ paddingY: {
35
+ type: 'union',
36
+ className: 'py',
37
+ values: SPACE,
38
+ },
39
+ paddingTop: {
40
+ type: 'union',
41
+ className: 'pt',
42
+ values: SPACE,
43
+ },
44
+ paddingRight: {
45
+ type: 'union',
46
+ className: 'pr',
47
+ values: SPACE,
48
+ },
49
+ paddingBottom: {
50
+ type: 'union',
51
+ className: 'pb',
52
+ values: SPACE,
53
+ },
54
+ paddingLeft: {
55
+ type: 'union',
56
+ className: 'pl',
57
+ values: SPACE,
58
+ },
59
+ }
@@ -0,0 +1,16 @@
1
+ import {PLACEMENT, type Placement} from '../types/Placement'
2
+ import {type PropDef} from '../types/PropDef'
3
+
4
+ /** @public */
5
+ export type PlacementProps = {
6
+ /** Placement relative to anchor */
7
+ placement?: Placement
8
+ }
9
+
10
+ export const placementProps: Record<string, PropDef> = {
11
+ placement: {
12
+ type: 'union',
13
+ className: 'placement',
14
+ values: PLACEMENT,
15
+ },
16
+ }
@@ -0,0 +1,52 @@
1
+ import {POSITION, type Position} from '../types/Position'
2
+ import {type PropDef} from '../types/PropDef'
3
+ import {type Responsive} from '../types/Responsive'
4
+ import {SPACE_AUTO, type SpaceAuto} from '../types/Space'
5
+
6
+ export type PositionProps = {
7
+ /** CSS **position** property */
8
+ position?: Responsive<Position>
9
+ /** CSS **inset** property */
10
+ inset?: Responsive<SpaceAuto>
11
+ /** CSS **top** property */
12
+ top?: Responsive<SpaceAuto>
13
+ /** CSS **right** property */
14
+ right?: Responsive<SpaceAuto>
15
+ /** CSS **bottom** property */
16
+ bottom?: Responsive<SpaceAuto>
17
+ /** CSS **left** property */
18
+ left?: Responsive<SpaceAuto>
19
+ }
20
+
21
+ export const positionProps: Record<string, PropDef> = {
22
+ position: {
23
+ type: 'union',
24
+ className: 'position',
25
+ values: POSITION,
26
+ },
27
+ inset: {
28
+ type: 'union',
29
+ className: 'inset',
30
+ values: SPACE_AUTO,
31
+ },
32
+ top: {
33
+ type: 'union',
34
+ className: 'top',
35
+ values: SPACE_AUTO,
36
+ },
37
+ right: {
38
+ type: 'union',
39
+ className: 'right',
40
+ values: SPACE_AUTO,
41
+ },
42
+ bottom: {
43
+ type: 'union',
44
+ className: 'bottom',
45
+ values: SPACE_AUTO,
46
+ },
47
+ left: {
48
+ type: 'union',
49
+ className: 'left',
50
+ values: SPACE_AUTO,
51
+ },
52
+ }
@@ -0,0 +1,15 @@
1
+ import {type PropDef} from '../types/PropDef'
2
+ import {SHADOW, type Shadow} from '../types/Shadow'
3
+
4
+ export type ShadowProps = {
5
+ /** CSS **box-shadow** property */
6
+ shadow?: Shadow
7
+ }
8
+
9
+ export const shadowProps: Record<string, PropDef> = {
10
+ shadow: {
11
+ type: 'union',
12
+ className: 'shadow',
13
+ values: SHADOW,
14
+ },
15
+ }
@@ -0,0 +1,15 @@
1
+ import {type PropDef} from '../types/PropDef'
2
+ import {TONE, type Tone} from '../types/Tone'
3
+
4
+ export type ToneProps = {
5
+ /** CSS **background-color** property */
6
+ tone?: Tone
7
+ }
8
+
9
+ export const toneProps: Record<string, PropDef> = {
10
+ tone: {
11
+ type: 'union',
12
+ className: 'tone',
13
+ values: TONE,
14
+ },
15
+ }
@@ -0,0 +1,62 @@
1
+ import {FONT_WEIGHT, type FontWeight} from '../types/FontWeight'
2
+ import {type PropDef} from '../types/PropDef'
3
+ import type {Responsive} from '../types/Responsive'
4
+ import {TEXT_ALIGN, type TextAlign} from '../types/TextAlign'
5
+ import {type MarginProps, marginProps} from './margin'
6
+ import {type ToneProps, toneProps} from './tone'
7
+
8
+ /** @public */
9
+ export interface TypographyProps extends MarginProps, ToneProps {
10
+ /** CSS **text-align** property */
11
+ align?: Responsive<TextAlign>
12
+ /** CSS **color** property */
13
+ muted?: boolean
14
+ /** CSS **text-box-trim** property */
15
+ trim?: boolean
16
+ /** Number of lines to truncate */
17
+ truncate?: Responsive<number>
18
+ /** CSS **font-weight** property */
19
+ weight?: FontWeight
20
+ }
21
+
22
+ export const typographyProps: Record<string, PropDef> = {
23
+ align: {
24
+ type: 'union',
25
+ className: 'text',
26
+ values: TEXT_ALIGN,
27
+ },
28
+ muted: {
29
+ type: 'boolean',
30
+ className: 'text-muted',
31
+ inverseClassName: 'text-default',
32
+ },
33
+ trim: {
34
+ type: 'boolean',
35
+ className: 'text-trim',
36
+ inverseClassName: 'text-trim-none',
37
+ },
38
+ truncate: {
39
+ type: 'conditional',
40
+ resolve: (value) => {
41
+ if (value === 1) {
42
+ return {
43
+ type: 'number',
44
+ className: 'text-overflow',
45
+ }
46
+ } else {
47
+ return {
48
+ type: 'number',
49
+ className: 'line-clamp',
50
+ variable: '--line-clamp',
51
+ }
52
+ }
53
+ },
54
+ },
55
+ weight: {
56
+ type: 'union',
57
+ className: 'weight',
58
+ values: FONT_WEIGHT,
59
+ },
60
+ ...marginProps,
61
+ ...toneProps,
62
+ }
@@ -0,0 +1,29 @@
1
+ import {type PropDef} from '../types/PropDef'
2
+ import {type Responsive} from '../types/Responsive'
3
+
4
+ export type WidthProps = {
5
+ /** CSS **width** property */
6
+ width?: Responsive<string>
7
+ /** CSS **min-width** property */
8
+ minWidth?: Responsive<string>
9
+ /** CSS **max-width** property */
10
+ maxWidth?: Responsive<string>
11
+ }
12
+
13
+ export const widthProps: Record<string, PropDef> = {
14
+ width: {
15
+ type: 'string',
16
+ className: 'width',
17
+ variable: '--width',
18
+ },
19
+ minWidth: {
20
+ type: 'string',
21
+ className: 'min-width',
22
+ variable: '--min-width',
23
+ },
24
+ maxWidth: {
25
+ type: 'string',
26
+ className: 'max-width',
27
+ variable: '--max-width',
28
+ },
29
+ }
@@ -0,0 +1,15 @@
1
+ import type {PropDef} from '../types/PropDef'
2
+ import type {Responsive} from '../types/Responsive'
3
+
4
+ export type ZIndexProps = {
5
+ /** CSS z-index property */
6
+ zIndex?: Responsive<number>
7
+ }
8
+
9
+ export const zIndexProps: Record<string, PropDef> = {
10
+ zIndex: {
11
+ type: 'number',
12
+ className: 'z-index',
13
+ variable: '--z-index',
14
+ },
15
+ }
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,2 @@
1
+ // No-op shim for `styles.css` in runtimes that do not import `.css` file
2
+ export default ''
@@ -0,0 +1,24 @@
1
+ import {existsSync} from 'node:fs'
2
+ import {createRequire} from 'node:module'
3
+ import {dirname, join} from 'node:path'
4
+
5
+ import {describe, expect, it} from 'vitest'
6
+
7
+ const require = createRequire(import.meta.url)
8
+
9
+ describe('@sanity/ui/styles.css', () => {
10
+ it('resolves to a Node-safe shim under the node condition', () => {
11
+ const path = require.resolve('@sanity/ui/styles.css')
12
+ expect(path).toMatch(/styles\.css\.node\.js$/)
13
+ })
14
+
15
+ it('imports without throwing in Node ESM', async () => {
16
+ const mod = await import('@sanity/ui/styles.css')
17
+ expect(mod.default).toBe('')
18
+ })
19
+
20
+ it('ships the real stylesheet for browser/style resolution', () => {
21
+ const pkgRoot = dirname(require.resolve('@sanity/ui/package.json'))
22
+ expect(existsSync(join(pkgRoot, 'dist/styles.css'))).toBe(true)
23
+ })
24
+ })
@@ -0,0 +1,8 @@
1
+ export const BUTTON_DENSITY = ['regular', 'loose'] as const
2
+ export type ButtonDensity = (typeof BUTTON_DENSITY)[number]
3
+
4
+ export const BUTTON_LEVEL = ['primary', 'secondary', 'tertiary'] as const
5
+ export type ButtonLevel = (typeof BUTTON_LEVEL)[number]
6
+
7
+ export const BUTTON_TONE = ['neutral', 'critical'] as const
8
+ export type ButtonTone = (typeof BUTTON_TONE)[number]
@@ -0,0 +1,6 @@
1
+ export const CODE_TAG = ['pre', 'span'] as const
2
+ export type CodeTag = (typeof CODE_TAG)[number]
3
+
4
+ export const CODE_SIZE = [0, 1, 2, 3, 4] as const
5
+ /** @public */
6
+ export type CodeSize = (typeof CODE_SIZE)[number]
@@ -0,0 +1,3 @@
1
+ export const CONTAINER_SIZE = [0, 1, 2, 3, 4, 5] as const
2
+ /** @public */
3
+ export type ContainerSize = (typeof CONTAINER_SIZE)[number]
@@ -0,0 +1,3 @@
1
+ export const DENSITY = ['compact', 'regular', 'loose'] as const
2
+ /** @public */
3
+ export type Density = (typeof DENSITY)[number]
@@ -0,0 +1,11 @@
1
+ export const DISPLAY_BLOCK = ['block', 'inline-block', 'none'] as const
2
+ /** @public */
3
+ export type DisplayBlock = (typeof DISPLAY_BLOCK)[number]
4
+
5
+ export const DISPLAY_FLEX = ['flex', 'inline-flex', 'none'] as const
6
+ /** @public */
7
+ export type DisplayFlex = (typeof DISPLAY_FLEX)[number]
8
+
9
+ export const DISPLAY_GRID = ['grid', 'inline-grid', 'none'] as const
10
+ /** @public */
11
+ export type DisplayGrid = (typeof DISPLAY_GRID)[number]
@@ -0,0 +1,3 @@
1
+ export const EYEBROW_SIZE = [0, 1, 2, 3, 4] as const
2
+ /** @public */
3
+ export type EyebrowSize = (typeof EYEBROW_SIZE)[number]
@@ -0,0 +1,22 @@
1
+ export const ALIGN_ITEMS = ['baseline', 'center', 'flex-end', 'flex-start', 'stretch'] as const
2
+ /** @public */
3
+ export type AlignItems = (typeof ALIGN_ITEMS)[number]
4
+
5
+ export const JUSTIFY_CONTENT = [
6
+ 'flex-start',
7
+ 'flex-end',
8
+ 'center',
9
+ 'space-between',
10
+ 'space-around',
11
+ 'space-evenly',
12
+ ] as const
13
+ /** @public */
14
+ export type JustifyContent = (typeof JUSTIFY_CONTENT)[number]
15
+
16
+ export const FLEX_DIRECTION = ['row', 'row-reverse', 'column', 'column-reverse'] as const
17
+ /** @public */
18
+ export type FlexDirection = (typeof FLEX_DIRECTION)[number]
19
+
20
+ export const FLEX_WRAP = ['wrap', 'wrap-reverse', 'nowrap'] as const
21
+ /** @public */
22
+ export type FlexWrap = (typeof FLEX_WRAP)[number]
@@ -0,0 +1,3 @@
1
+ export const FONT_WEIGHT = ['regular', 'medium', 'semibold', 'bold'] as const
2
+ /** @public */
3
+ export type FontWeight = (typeof FONT_WEIGHT)[number]
@@ -0,0 +1,3 @@
1
+ export const GRID_AUTO_FLOW = ['row', 'column', 'row dense', 'column dense', 'dense'] as const
2
+ /** @public */
3
+ export type GridAutoFlow = (typeof GRID_AUTO_FLOW)[number]
@@ -0,0 +1,6 @@
1
+ export const HEADING_TAG = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const
2
+ export type HeadingTag = (typeof HEADING_TAG)[number]
3
+
4
+ export const HEADING_SIZE = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] as const
5
+ /** @public */
6
+ export type HeadingSize = (typeof HEADING_SIZE)[number]
@@ -0,0 +1,3 @@
1
+ export const ICON_SIZE = [0, 1, 2, 3, 4] as const
2
+ /** @public */
3
+ export type IconSize = (typeof ICON_SIZE)[number]
@@ -0,0 +1,8 @@
1
+ export const INTERACTIVE_TAG = ['button', 'a'] as const
2
+ export type InteractiveTag = (typeof INTERACTIVE_TAG)[number]
3
+
4
+ export type InteractiveAs<T extends React.ElementType> = T extends InteractiveTag
5
+ ? T
6
+ : T extends string
7
+ ? never
8
+ : T
@@ -0,0 +1,2 @@
1
+ export const LIST_TAG = ['ol', 'ul'] as const
2
+ export type ListTag = (typeof LIST_TAG)[number]
@@ -0,0 +1,3 @@
1
+ export const OVERFLOW = ['visible', 'hidden', 'auto', 'scroll', 'clip'] as const
2
+ /** @public */
3
+ export type Overflow = (typeof OVERFLOW)[number]
@@ -0,0 +1,16 @@
1
+ export const PLACEMENT = [
2
+ 'top',
3
+ 'top-start',
4
+ 'top-end',
5
+ 'right',
6
+ 'right-start',
7
+ 'right-end',
8
+ 'bottom',
9
+ 'bottom-start',
10
+ 'bottom-end',
11
+ 'left',
12
+ 'left-start',
13
+ 'left-end',
14
+ ] as const
15
+ /** @public */
16
+ export type Placement = (typeof PLACEMENT)[number]
@@ -0,0 +1,3 @@
1
+ export const POSITION = ['absolute', 'fixed', 'relative', 'static', 'sticky'] as const
2
+ /** @public */
3
+ export type Position = (typeof POSITION)[number]
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Prop is a boolean. If used for styling, provide a className
3
+ * to apply CSS and an inverseClassName to reset it.
4
+ */
5
+ type BooleanPropDef = {
6
+ type: 'boolean'
7
+ className?: string
8
+ inverseClassName?: string
9
+ }
10
+
11
+ /**
12
+ * Prop is a number. If used for styling, provide a className
13
+ * that references the variable for dynamic values.
14
+ */
15
+ type NumberPropDef = {
16
+ type: 'number'
17
+ className?: string
18
+ variable?: string
19
+ }
20
+
21
+ /**
22
+ * Prop is a string. If used for styling, provide a className
23
+ * that references the variable for dynamic values.
24
+ */
25
+ type StringPropDef = {
26
+ type: 'string'
27
+ className?: string
28
+ variable?: string
29
+ }
30
+
31
+ /**
32
+ * Prop is a union of values. Values are always required. If
33
+ * used for styling, provide a className.
34
+ */
35
+ type UnionPropDef<T> = {
36
+ type: 'union'
37
+ className?: string
38
+ values: readonly T[]
39
+ }
40
+
41
+ /**
42
+ * Prop is a composite of other props. Requires a union of values and
43
+ * a composition object which defines the props and their mappings.
44
+ * The values should map to the composition object's mapping keys.
45
+ */
46
+ type CompositePropDef<T> = {
47
+ type: 'composite'
48
+ values: readonly T[]
49
+ composition: Record<
50
+ string,
51
+ {
52
+ propDef: PropDef
53
+ mapping: Record<T & PropertyKey, unknown>
54
+ }
55
+ >
56
+ }
57
+
58
+ /**
59
+ * Prop is a composite of other props. Requires a resolve callback with
60
+ * a value param that returns another prop def.
61
+ */
62
+ type ConditionalPropDef<T> = {
63
+ type: 'conditional'
64
+ resolve: (value: T) => PropDef<T>
65
+ }
66
+
67
+ export type PropDef<T = unknown> =
68
+ | BooleanPropDef
69
+ | NumberPropDef
70
+ | StringPropDef
71
+ | UnionPropDef<T>
72
+ | CompositePropDef<T>
73
+ | ConditionalPropDef<T>