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

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 (251) hide show
  1. package/dist/_chunks-cjs/_visual-editing.js +1293 -1215
  2. package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
  3. package/dist/_chunks-cjs/buildCommand.js +28 -10
  4. package/dist/_chunks-cjs/buildCommand.js.map +1 -1
  5. package/dist/_chunks-es/_visual-editing.mjs +1284 -1202
  6. package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
  7. package/dist/_visual-editing.d.mts +528 -358
  8. package/dist/_visual-editing.d.ts +528 -358
  9. package/dist/cli.js +1 -1
  10. package/dist/css.d.mts +143 -73
  11. package/dist/css.d.ts +143 -73
  12. package/dist/css.js +329 -472
  13. package/dist/css.js.map +1 -1
  14. package/dist/css.mjs +330 -473
  15. package/dist/css.mjs.map +1 -1
  16. package/dist/index.d.mts +1362 -869
  17. package/dist/index.d.ts +1362 -869
  18. package/dist/index.js +383 -308
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.mjs +387 -312
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/sanity-palette.css +105 -1
  23. package/dist/sanity-palette.min.css +1 -0
  24. package/dist/sanity-theme.css +4571 -1
  25. package/dist/sanity-theme.min.css +1 -0
  26. package/dist/system.css +22053 -21946
  27. package/dist/system.min.css +1 -0
  28. package/dist/theme.d.mts +51 -106
  29. package/dist/theme.d.ts +51 -106
  30. package/dist/theme.js +9 -9
  31. package/dist/theme.js.map +1 -1
  32. package/dist/theme.mjs +9 -9
  33. package/dist/theme.mjs.map +1 -1
  34. package/package.json +10 -5
  35. package/src/cli/buildCommand.ts +46 -19
  36. package/src/css/_comp.ts +2 -2
  37. package/src/css/{compile/compileStyle.ts → _compileStyle.ts} +7 -7
  38. package/src/css/{system.style.ts → _system.style.ts} +3 -2
  39. package/src/css/aspects/display/display.ts +1 -0
  40. package/src/css/aspects/display/types.ts +2 -3
  41. package/src/css/aspects/flex/types.ts +4 -12
  42. package/src/css/aspects/flexItem/types.ts +1 -3
  43. package/src/css/aspects/font/types.ts +1 -3
  44. package/src/css/aspects/grid/grid.ts +1 -0
  45. package/src/css/aspects/grid/types.ts +5 -9
  46. package/src/css/aspects/gridItem/gridItem.ts +1 -1
  47. package/src/css/aspects/gridItem/types.ts +7 -18
  48. package/src/css/aspects/height/height.ts +3 -4
  49. package/src/css/aspects/inset/inset.ts +1 -0
  50. package/src/css/aspects/margin/margin.ts +1 -0
  51. package/src/css/aspects/margin/types.ts +1 -0
  52. package/src/css/aspects/maxWidth/maxWidth.ts +1 -0
  53. package/src/css/aspects/maxWidth/types.ts +1 -0
  54. package/src/css/aspects/minWidth/minWidth.ts +1 -0
  55. package/src/css/aspects/minWidth/types.ts +2 -0
  56. package/src/css/aspects/overflow/overflow.ts +1 -0
  57. package/src/css/aspects/padding/padding.ts +1 -0
  58. package/src/css/aspects/pointerEvents/pointerEvents.ts +1 -0
  59. package/src/css/aspects/position/position.ts +1 -0
  60. package/src/css/aspects/shadow/shadow.ts +1 -0
  61. package/src/css/aspects/textOverflow/textOverflow.ts +1 -0
  62. package/src/css/aspects/textOverflow/types.ts +1 -0
  63. package/src/css/aspects/width/types.ts +2 -0
  64. package/src/css/aspects/width/width.ts +1 -0
  65. package/src/css/{compile/compilePalette.ts → compilePalette.ts} +14 -10
  66. package/src/css/compileSystem.ts +7 -0
  67. package/src/css/{compile/compileTheme.ts → compileTheme.ts} +1 -0
  68. package/src/css/{compile/compileTheme_v3.ts → compileTheme_v3.ts} +123 -104
  69. package/src/css/components/breadcrumbs/breadcrumbs.ts +1 -0
  70. package/src/css/components/dialog/dialog.ts +7 -0
  71. package/src/css/components/menu/menu.ts +2 -0
  72. package/src/css/components/skeleton/skeleton.ts +4 -0
  73. package/src/css/components/skeleton/types.ts +4 -0
  74. package/src/css/components/toast/toast.ts +5 -0
  75. package/src/css/components/tree/tree.ts +1 -0
  76. package/src/css/composeClassNames.ts +4 -2
  77. package/src/css/constants.ts +2 -0
  78. package/src/css/index.ts +3 -3
  79. package/src/css/primitives/_arrow/_arrow.ts +3 -0
  80. package/src/css/primitives/_input/input.ts +2 -0
  81. package/src/css/primitives/_selectable/_selectable.style.ts +1 -2
  82. package/src/css/primitives/_selectable/selectable.ts +1 -2
  83. package/src/css/primitives/avatar/avatar.style.ts +5 -8
  84. package/src/css/primitives/avatar/avatar.ts +6 -0
  85. package/src/css/primitives/avatar/types.ts +1 -0
  86. package/src/css/primitives/box/types.ts +1 -3
  87. package/src/css/primitives/button/button.ts +4 -21
  88. package/src/css/primitives/button/index.ts +1 -0
  89. package/src/css/primitives/button/types.ts +18 -0
  90. package/src/css/primitives/card/card.style.ts +3 -6
  91. package/src/css/primitives/card/card.ts +2 -2
  92. package/src/css/primitives/card/types.ts +2 -2
  93. package/src/css/primitives/checkbox/checkbox.ts +2 -0
  94. package/src/css/primitives/container/container.ts +1 -0
  95. package/src/css/primitives/container/types.ts +1 -0
  96. package/src/css/primitives/kbd/kbd.ts +1 -0
  97. package/src/css/primitives/label/types.ts +7 -2
  98. package/src/css/primitives/popover/popover.ts +2 -0
  99. package/src/css/primitives/radio/radio.ts +1 -0
  100. package/src/css/primitives/select/select.ts +2 -0
  101. package/src/css/primitives/spinner/spinner.ts +2 -0
  102. package/src/css/primitives/switch/switch.ts +5 -0
  103. package/src/css/primitives/text/types.ts +4 -0
  104. package/src/css/primitives/textArea/textArea.ts +1 -0
  105. package/src/css/primitives/textInput/textInput.ts +1 -0
  106. package/src/css/primitives/tooltip/tooltip.ts +2 -0
  107. package/src/css/scopeClassName.ts +1 -0
  108. package/src/css/types.ts +9 -12
  109. package/src/css/util.ts +5 -0
  110. package/src/css/utils/srOnly/srOnly.ts +3 -1
  111. package/src/css/varNames.ts +131 -141
  112. package/src/css/vars.ts +1 -6
  113. package/src/theme/palette/constants.ts +2 -0
  114. package/src/theme/palette/types.ts +3 -0
  115. package/src/theme/types.ts +2 -6
  116. package/src/theme/v0/focusRing.ts +1 -3
  117. package/src/theme/v0/font.ts +6 -18
  118. package/src/theme/v0/layer.ts +1 -3
  119. package/src/theme/v0/shadow.ts +2 -6
  120. package/src/theme/v2/avatar.ts +1 -3
  121. package/src/theme/v2/color/_system.ts +1 -3
  122. package/src/theme/v2/color/avatar.ts +2 -6
  123. package/src/theme/v2/color/badge.ts +2 -6
  124. package/src/theme/v2/color/button.ts +3 -9
  125. package/src/theme/v2/color/color.ts +3 -9
  126. package/src/theme/v2/color/input.ts +3 -9
  127. package/src/theme/v2/color/kbd.ts +1 -3
  128. package/src/theme/v2/color/selectable.ts +2 -6
  129. package/src/theme/v2/color/state.ts +1 -3
  130. package/src/theme/v2/color/syntax.ts +1 -3
  131. package/src/theme/v2/input.ts +1 -3
  132. package/src/theme/v2/theme.ts +2 -6
  133. package/src/theme/v3/buildTheme_v3.ts +1 -0
  134. package/src/theme/v3/color/color.ts +6 -4
  135. package/src/theme/v3/color/renderColor.ts +4 -1
  136. package/src/theme/v3/defaultTokens.ts +1 -0
  137. package/src/theme/v3/resolveTokens.ts +9 -9
  138. package/src/ui/RootClassNames.tsx +3 -0
  139. package/src/ui/StyleTags.tsx +3 -1
  140. package/src/ui/_compat/theme/themeColorProvider.tsx +2 -6
  141. package/src/ui/_compat/theme/themeProvider.tsx +2 -6
  142. package/src/ui/_compat/theme/types.ts +1 -3
  143. package/src/ui/_compat/theme/useRootTheme.ts +1 -3
  144. package/src/ui/_compat/theme/useTheme.ts +2 -6
  145. package/src/ui/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
  146. package/src/ui/components/autocomplete/autocomplete.tsx +86 -114
  147. package/src/ui/components/autocomplete/autocompleteOption.tsx +2 -0
  148. package/src/ui/components/autocomplete/types.ts +3 -8
  149. package/src/ui/components/breadcrumbs/breadcrumbs.tsx +27 -21
  150. package/src/ui/components/dialog/dialog.tsx +89 -291
  151. package/src/ui/components/dialog/dialogCard.tsx +183 -0
  152. package/src/ui/components/dialog/isTargetWithinScope.ts +14 -0
  153. package/src/ui/components/hotkeys/hotkeys.tsx +33 -15
  154. package/src/ui/components/menu/__workshop__/asComponent.tsx +6 -6
  155. package/src/ui/components/menu/menu.tsx +27 -33
  156. package/src/ui/components/menu/menuButton.tsx +10 -14
  157. package/src/ui/components/menu/menuDivider.tsx +25 -13
  158. package/src/ui/components/menu/menuGroup.tsx +34 -26
  159. package/src/ui/components/menu/menuItem.tsx +51 -40
  160. package/src/ui/components/skeleton/codeSkeleton.tsx +53 -0
  161. package/src/ui/components/skeleton/headingSkeleton.tsx +52 -0
  162. package/src/ui/components/skeleton/index.ts +3 -0
  163. package/src/ui/components/skeleton/labelSkeleton.tsx +51 -0
  164. package/src/ui/components/skeleton/skeleton.tsx +39 -16
  165. package/src/ui/components/skeleton/textSkeleton.tsx +31 -110
  166. package/src/ui/components/tab/tab.tsx +23 -19
  167. package/src/ui/components/tab/tabList.tsx +34 -33
  168. package/src/ui/components/tab/tabPanel.tsx +25 -19
  169. package/src/ui/components/toast/toast.tsx +21 -16
  170. package/src/ui/components/toast/toastLayer.tsx +28 -10
  171. package/src/ui/components/toast/toastProvider.tsx +2 -6
  172. package/src/ui/components/toast/types.ts +2 -6
  173. package/src/ui/components/toast/useToast.ts +1 -3
  174. package/src/ui/components/tree/tree.tsx +194 -187
  175. package/src/ui/components/tree/treeGroup.tsx +25 -5
  176. package/src/ui/components/tree/treeItem.tsx +35 -23
  177. package/src/ui/hooks/useClickOutside.ts +2 -6
  178. package/src/ui/hooks/useClickOutsideEvent.ts +3 -9
  179. package/src/ui/primitives/_selectable/selectable.tsx +33 -20
  180. package/src/ui/primitives/avatar/avatar.tsx +28 -31
  181. package/src/ui/primitives/avatar/avatarCounter.tsx +33 -25
  182. package/src/ui/primitives/avatar/avatarStack.tsx +31 -24
  183. package/src/ui/primitives/avatar/types.ts +2 -0
  184. package/src/ui/primitives/badge/__workshop__/props.tsx +1 -9
  185. package/src/ui/primitives/badge/__workshop__/tones.tsx +1 -6
  186. package/src/ui/primitives/badge/badge.tsx +33 -32
  187. package/src/ui/primitives/badge/types.ts +2 -1
  188. package/src/ui/primitives/box/box.tsx +59 -29
  189. package/src/ui/primitives/button/__workshop__/sanityUploadButton.tsx +3 -3
  190. package/src/ui/primitives/button/__workshop__/uploadButton.tsx +2 -1
  191. package/src/ui/primitives/button/button.test.tsx +1 -15
  192. package/src/ui/primitives/button/button.tsx +64 -70
  193. package/src/ui/primitives/card/__workshop__/asComponent.tsx +3 -3
  194. package/src/ui/primitives/card/card.tsx +22 -22
  195. package/src/ui/primitives/card/cardProvider.tsx +2 -0
  196. package/src/ui/primitives/checkbox/checkbox.tsx +26 -15
  197. package/src/ui/primitives/code/code.tsx +24 -22
  198. package/src/ui/primitives/container/container.tsx +26 -15
  199. package/src/ui/primitives/flex/flex.tsx +21 -19
  200. package/src/ui/primitives/grid/grid.tsx +21 -16
  201. package/src/ui/primitives/heading/heading.tsx +42 -19
  202. package/src/ui/primitives/inline/inline.tsx +26 -23
  203. package/src/ui/primitives/kbd/kbd.tsx +25 -23
  204. package/src/ui/primitives/label/label.tsx +41 -26
  205. package/src/ui/primitives/popover/popover.tsx +281 -277
  206. package/src/ui/primitives/popover/popoverCard.tsx +119 -118
  207. package/src/ui/primitives/radio/radio.tsx +30 -14
  208. package/src/ui/primitives/select/select.tsx +24 -16
  209. package/src/ui/primitives/spinner/animatedSpinnerIcon.tsx +4 -2
  210. package/src/ui/primitives/spinner/spinner.tsx +24 -12
  211. package/src/ui/primitives/stack/stack.tsx +27 -18
  212. package/src/ui/primitives/switch/switch.tsx +31 -14
  213. package/src/ui/primitives/text/text.tsx +42 -24
  214. package/src/ui/primitives/textArea/textArea.tsx +33 -18
  215. package/src/ui/primitives/textInput/textInput.tsx +28 -40
  216. package/src/ui/primitives/tooltip/constants.ts +1 -1
  217. package/src/ui/primitives/tooltip/tooltip.tsx +76 -59
  218. package/src/ui/primitives/tooltip/tooltipCard.tsx +89 -82
  219. package/src/ui/primitives/types.ts +1 -3
  220. package/src/ui/types/avatar.ts +3 -6
  221. package/src/ui/types/badge.ts +1 -3
  222. package/src/ui/types/button.ts +1 -3
  223. package/src/ui/types/card.ts +1 -3
  224. package/src/ui/types/dialog.ts +1 -3
  225. package/src/ui/types/props.ts +20 -10
  226. package/src/ui/utils/arrow/arrow.tsx +40 -14
  227. package/src/ui/utils/boundaryElement/boundaryElementProvider.tsx +2 -6
  228. package/src/ui/utils/boundaryElement/types.ts +1 -3
  229. package/src/ui/utils/boundaryElement/useBoundaryElement.ts +1 -3
  230. package/src/ui/utils/elementQuery/elementQuery.tsx +36 -14
  231. package/src/ui/utils/errorBoundary.tsx +2 -0
  232. package/src/ui/utils/index.ts +0 -1
  233. package/src/ui/utils/layer/layer.tsx +23 -93
  234. package/src/ui/utils/layer/layerCard.tsx +92 -0
  235. package/src/ui/utils/layer/layerProvider.tsx +2 -6
  236. package/src/ui/utils/layer/useLayer.ts +1 -3
  237. package/src/ui/utils/portal/portal.ts +2 -6
  238. package/src/ui/utils/portal/portalProvider.tsx +2 -6
  239. package/src/ui/utils/portal/types.ts +1 -3
  240. package/src/ui/utils/portal/usePortal.ts +1 -3
  241. package/src/ui/utils/srOnly/srOnly.tsx +25 -20
  242. package/src/ui/utils/virtualList/virtualList.tsx +36 -24
  243. package/src/css/compile/compileRule.ts +0 -97
  244. package/src/css/compile/compileRules.test.ts +0 -36
  245. package/src/css/compile/compileRules.ts +0 -43
  246. package/src/css/compile/compileSystem.ts +0 -7
  247. package/src/css/compile/types.ts +0 -6
  248. package/src/css/primitives/_selectable/_contants.ts +0 -11
  249. package/src/css/primitives/card/_constants.ts +0 -13
  250. package/src/ui/utils/conditionalWrapper/conditionalWrapper.tsx +0 -23
  251. package/src/ui/utils/conditionalWrapper/index.ts +0 -1
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "3.0.0-static.11",
3
+ "version": "3.0.0-static.13",
4
4
  "keywords": [
5
- "sanity",
5
+ "react",
6
6
  "ui",
7
+ "kit",
8
+ "library",
7
9
  "primitives",
8
- "react",
9
10
  "components",
10
- "design-system"
11
+ "utils"
11
12
  ],
12
13
  "homepage": "https://www.sanity.io/",
13
14
  "bugs": {
@@ -108,8 +109,13 @@
108
109
  "@juggle/resize-observer": "^3.4.0",
109
110
  "@sanity/color": "^3.0.6",
110
111
  "@sanity/icons": "^3.7.0",
112
+ "cssnano": "^7.0.7",
111
113
  "csstype": "^3.1.3",
112
114
  "framer-motion": "^12.9.7",
115
+ "gzip-size": "^7.0.0",
116
+ "postcss": "^8.5.3",
117
+ "prettier": "^3.5.3",
118
+ "pretty-bytes": "^7.0.0",
113
119
  "react-compiler-runtime": "19.1.0-rc.1",
114
120
  "react-refractor": "^2.2.0",
115
121
  "use-effect-event": "^1.0.2"
@@ -181,7 +187,6 @@
181
187
  "magic-string": "^0.30.17",
182
188
  "module-alias": "^2.2.3",
183
189
  "npm-run-all2": "^5.0.2",
184
- "prettier": "^3.5.3",
185
190
  "react": "^19.1.0",
186
191
  "react-dom": "^19.1.0",
187
192
  "react-is": "^19.1.0",
@@ -1,48 +1,75 @@
1
+ /* eslint-disable no-console */
2
+
1
3
  import {compilePalette, compileSystem, compileTheme} from '@sanity/ui/css'
2
4
  import {buildTheme_v3, RootTheme} from '@sanity/ui/theme'
5
+ import cssnano from 'cssnano'
3
6
  import fs from 'fs/promises'
7
+ import {gzipSizeSync} from 'gzip-size'
4
8
  import path from 'path'
9
+ import postcss from 'postcss'
10
+ import {format, resolveConfig} from 'prettier'
11
+ import prettyBytes from 'pretty-bytes'
12
+
13
+ async function minify(css: string) {
14
+ return postcss([cssnano()]).process(css, {from: undefined})
15
+ }
16
+
17
+ async function prettify(css: string) {
18
+ const options = await resolveConfig(__dirname)
19
+
20
+ if (!options) {
21
+ throw new Error('Prettier config not found')
22
+ }
23
+
24
+ return format(css, {...options, filepath: 'index.css', printWidth: 9999})
25
+ }
26
+
27
+ function prettySize(str: string) {
28
+ return `${prettyBytes(str.length)} / ${prettyBytes(gzipSizeSync(str))}`
29
+ }
5
30
 
6
31
  async function buildPalette(outDir: string) {
7
32
  const css = compilePalette()
33
+ const minified = await minify(css)
34
+ const prettified = await prettify(css)
8
35
 
9
36
  await fs.mkdir(outDir, {recursive: true})
37
+ await fs.writeFile(path.resolve(outDir, 'sanity-palette.css'), prettified, 'utf-8')
38
+ await fs.writeFile(path.resolve(outDir, 'sanity-palette.min.css'), minified.css, 'utf-8')
10
39
 
11
- await fs.writeFile(path.resolve(outDir, 'sanity-palette.css'), css, 'utf-8')
12
-
13
- // eslint-disable-next-line no-console
14
- console.log('- sanity-palette.css')
40
+ console.log(`- built sanity-palette.css (${prettySize(prettified)})`)
41
+ console.log(`- built sanity-palette.min.css (${prettySize(minified.css)})`)
15
42
  }
16
43
 
17
44
  async function buildTheme(outDir: string) {
18
- const css = compileTheme({v3: buildTheme_v3()} as RootTheme)
45
+ const css = await prettify(compileTheme({v3: buildTheme_v3()} as RootTheme))
46
+ const minified = await minify(css)
47
+ const prettified = await prettify(css)
19
48
 
20
49
  await fs.mkdir(outDir, {recursive: true})
50
+ await fs.writeFile(path.resolve(outDir, 'sanity-theme.css'), prettified, 'utf-8')
51
+ await fs.writeFile(path.resolve(outDir, 'sanity-theme.min.css'), minified.css, 'utf-8')
21
52
 
22
- await fs.writeFile(path.resolve(outDir, 'sanity-theme.css'), css, 'utf-8')
23
-
24
- // eslint-disable-next-line no-console
25
- console.log('- sanity-theme.css')
53
+ console.log(`- built sanity-theme.css (${prettySize(prettified)})`)
54
+ console.log(`- built sanity-theme.min.css (${prettySize(minified.css)})`)
26
55
  }
27
56
 
28
57
  async function buildSystem(outDir: string) {
29
- const css = compileSystem()
58
+ const css = await prettify(compileSystem())
59
+ const minified = await minify(css)
60
+ const prettified = await prettify(css)
30
61
 
31
62
  await fs.mkdir(outDir, {recursive: true})
63
+ await fs.writeFile(path.resolve(outDir, 'system.css'), prettified, 'utf-8')
64
+ await fs.writeFile(path.resolve(outDir, 'system.min.css'), minified.css, 'utf-8')
32
65
 
33
- await fs.writeFile(path.resolve(outDir, 'system.css'), css, 'utf-8')
34
-
35
- // eslint-disable-next-line no-console
36
- console.log('- system.css')
66
+ console.log(`- built system.css (${prettySize(prettified)})`)
67
+ console.log(`- built system.min.css (${prettySize(minified.css)})`)
37
68
  }
38
69
 
39
70
  export async function buildCommand(options: {cwd?: string; outDir?: string}): Promise<void> {
40
71
  const cwd = options.cwd ?? process.cwd()
41
72
  const outDir = options.outDir ?? path.resolve(cwd, 'dist')
42
73
 
43
- await buildPalette(outDir)
44
-
45
- await buildTheme(outDir)
46
-
47
- await buildSystem(outDir)
74
+ await Promise.all([buildPalette(outDir), buildTheme(outDir), buildSystem(outDir)])
48
75
  }
package/src/css/_comp.ts CHANGED
@@ -1,9 +1,9 @@
1
- import {getClassNames} from './composeClassNames'
1
+ import {_getClassNames} from './composeClassNames'
2
2
  import {scopeClassName} from './scopeClassName'
3
3
 
4
4
  export function _comp(...classNames: Array<string | false | undefined>): string | undefined {
5
5
  return (
6
- getClassNames(...classNames)
6
+ _getClassNames(...classNames)
7
7
  .filter(Boolean)
8
8
  .map(scopeClassName)
9
9
  .join(' ') || undefined
@@ -1,9 +1,9 @@
1
- import {PREFIX} from '../constants'
2
- import {Properties, PropertiesWithVarsAndNested, Style, StyleRules} from '../types'
3
- import {isArray} from '../util'
1
+ import {PREFIX} from './constants'
2
+ import {Properties, PropertiesWithVarsAndNested, Style, StyleRules} from './types'
3
+ import {isArray} from './util'
4
4
 
5
- /** @public */
6
- export function compileStyle(style: Style): string {
5
+ /** @internal */
6
+ export function _compileStyle(style: Style): string {
7
7
  let css = ''
8
8
 
9
9
  if (style.rules) {
@@ -20,7 +20,7 @@ export function compileStyle(style: Style): string {
20
20
  keyframesCss += `}\n`
21
21
  }
22
22
 
23
- keyframesCss += `\n}\n`
23
+ keyframesCss += `\n}\n\n`
24
24
 
25
25
  css += keyframesCss
26
26
  }
@@ -39,7 +39,7 @@ export function compileStyle(style: Style): string {
39
39
  return css
40
40
  }
41
41
 
42
- function compileStyleRules(rules: StyleRules) {
42
+ export function compileStyleRules(rules: StyleRules) {
43
43
  let css = ''
44
44
 
45
45
  const mediaMap = new Map<
@@ -67,8 +67,9 @@ import {tooltipStyle} from './primitives/tooltip/tooltip.style'
67
67
  import {type Style} from './types'
68
68
  import {srOnlyStyle} from './utils/srOnly/srOnly.style'
69
69
 
70
- export const systemStyle: Style = _mergeStyles([
71
- // NOTE: order matters in CSS
70
+ /** @internal */
71
+ export const _systemStyle: Style = _mergeStyles([
72
+ // NOTE: Order matters in CSS!
72
73
 
73
74
  {
74
75
  // define order of layers
@@ -2,6 +2,7 @@ import {_resp} from '../../_resp'
2
2
  import {composeClassNames} from '../../composeClassNames'
3
3
  import {DisplayStyleProps} from './types'
4
4
 
5
+ /** @internal */
5
6
  export function display(props: DisplayStyleProps): string | undefined {
6
7
  return composeClassNames(_resp(undefined, props.display))
7
8
  }
@@ -1,8 +1,6 @@
1
1
  import {ResponsiveProp} from '../../types'
2
2
 
3
- /**
4
- * @public
5
- */
3
+ /** @public */
6
4
  export type Display =
7
5
  | 'block'
8
6
  | 'inline-block'
@@ -12,6 +10,7 @@ export type Display =
12
10
  | 'inline-grid'
13
11
  | 'none'
14
12
 
13
+ /** @public */
15
14
  export interface DisplayStyleProps {
16
15
  display?: ResponsiveProp<Display>
17
16
  }
@@ -1,18 +1,12 @@
1
1
  import {ResponsiveProp} from '../../types'
2
2
 
3
- /**
4
- * @public
5
- */
3
+ /** @public */
6
4
  export type FlexAlign = 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch'
7
5
 
8
- /**
9
- * @public
10
- */
6
+ /** @public */
11
7
  export type FlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse'
12
8
 
13
- /**
14
- * @public
15
- */
9
+ /** @public */
16
10
  export type FlexJustify =
17
11
  | 'flex-start'
18
12
  | 'flex-end'
@@ -21,9 +15,7 @@ export type FlexJustify =
21
15
  | 'space-around'
22
16
  | 'space-evenly'
23
17
 
24
- /**
25
- * @public
26
- */
18
+ /** @public */
27
19
  export type FlexWrap = 'wrap' | 'wrap-reverse' | 'nowrap'
28
20
 
29
21
  /** @public */
@@ -1,8 +1,6 @@
1
1
  import {ResponsiveProp} from '../../types'
2
2
 
3
- /**
4
- * @public
5
- */
3
+ /** @public */
6
4
  export type FlexValue =
7
5
  | 'none'
8
6
  | 'auto'
@@ -1,8 +1,6 @@
1
1
  import {FontWeight} from '@sanity/ui/theme'
2
2
 
3
- /**
4
- * @public
5
- */
3
+ /** @public */
6
4
  export type TextAlign = 'left' | 'right' | 'center' | 'justify' | 'initial'
7
5
 
8
6
  /** @public */
@@ -2,6 +2,7 @@ import {_resp} from '../../_resp'
2
2
  import {composeClassNames} from '../../composeClassNames'
3
3
  import {GridStyleProps} from './types'
4
4
 
5
+ /** @internal */
5
6
  export function grid(props: GridStyleProps): string | undefined {
6
7
  return composeClassNames(
7
8
  _resp('auto-cols', props.autoCols),
@@ -1,22 +1,18 @@
1
1
  import {ResponsiveProp} from '../../types'
2
2
 
3
- /**
4
- * @public
5
- */
3
+ /** @public */
6
4
  export type GridAutoRows = 'auto' | 'min' | 'max' | 'fr'
7
5
 
8
- /**
9
- * @public
10
- */
6
+ /** @public */
11
7
  export type GridAutoCols = 'auto' | 'min' | 'max' | 'fr'
12
8
 
13
- /**
14
- * @public
15
- */
9
+ /** @public */
16
10
  export type GridAutoFlow = 'row' | 'column' | 'row dense' | 'column dense'
17
11
 
12
+ /** @public */
18
13
  export type Columns = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
19
14
 
15
+ /** @public */
20
16
  export type Rows = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
21
17
 
22
18
  /** @public */
@@ -2,7 +2,7 @@ import {_resp} from '../../_resp'
2
2
  import {composeClassNames} from '../../composeClassNames'
3
3
  import {GridItemStyleProps} from './types'
4
4
 
5
- /** @public */
5
+ /** @internal */
6
6
  export function gridItem(props: GridItemStyleProps): string | undefined {
7
7
  return composeClassNames(
8
8
  _resp(`col`, props.column),
@@ -1,35 +1,24 @@
1
1
  import {ResponsiveProp} from '../../types'
2
2
 
3
- /**
4
- * @public
5
- */
3
+ /** @public */
6
4
  export type GridItemColumn = 'auto' | 'full' | number
7
5
 
8
- /**
9
- * @public
10
- */
6
+ /** @public */
11
7
  export type GridItemColumnStart = 'auto' | number
12
8
 
13
- /**
14
- * @public
15
- */
9
+ /** @public */
16
10
  export type GridItemColumnEnd = 'auto' | number
17
11
 
18
- /**
19
- * @public
20
- */
12
+ /** @public */
21
13
  export type GridItemRow = 'auto' | 'full' | number
22
14
 
23
- /**
24
- * @public
25
- */
15
+ /** @public */
26
16
  export type GridItemRowStart = 'auto' | number
27
17
 
28
- /**
29
- * @public
30
- */
18
+ /** @public */
31
19
  export type GridItemRowEnd = 'auto' | number
32
20
 
21
+ /** @public */
33
22
  export interface GridItemStyleProps {
34
23
  column?: ResponsiveProp<GridItemColumn>
35
24
  columnStart?: ResponsiveProp<GridItemColumnStart>
@@ -2,16 +2,15 @@ import {_resp} from '../../_resp'
2
2
  import {composeClassNames} from '../../composeClassNames'
3
3
  import {ResponsiveProp} from '../../types'
4
4
 
5
- /**
6
- * @public
7
- */
5
+ /** @public */
8
6
  export type BoxHeight = 'stretch' | 'fill'
9
7
 
8
+ /** @public */
10
9
  export interface HeightStyleProps {
11
10
  height?: ResponsiveProp<BoxHeight>
12
11
  }
13
12
 
14
- /** @public */
13
+ /** @internal */
15
14
  export function height(props: HeightStyleProps): string | undefined {
16
15
  return composeClassNames(_resp(`h`, props.height))
17
16
  }
@@ -2,6 +2,7 @@ import {_resp} from '../../_resp'
2
2
  import {composeClassNames} from '../../composeClassNames'
3
3
  import {InsetStyleProps} from './types'
4
4
 
5
+ /** @internal */
5
6
  export function inset(props: InsetStyleProps): string | undefined {
6
7
  return composeClassNames(
7
8
  _resp('inset', props.inset),
@@ -2,6 +2,7 @@ import {_resp} from '../../_resp'
2
2
  import {composeClassNames} from '../../composeClassNames'
3
3
  import {MarginStyleProps} from './types'
4
4
 
5
+ /** @internal */
5
6
  export function margin(props: MarginStyleProps): string | undefined {
6
7
  return composeClassNames(
7
8
  _resp('m', props.margin),
@@ -1,5 +1,6 @@
1
1
  import {ResponsiveProp} from '../../types'
2
2
 
3
+ /** @public */
3
4
  export interface MarginStyleProps {
4
5
  margin?: ResponsiveProp<number>
5
6
  marginTop?: ResponsiveProp<number>
@@ -1,6 +1,7 @@
1
1
  import {_resp} from '../../_resp'
2
2
  import {MaxWidthStyleProps} from './types'
3
3
 
4
+ /** @internal */
4
5
  export function maxWidth(props: MaxWidthStyleProps): string {
5
6
  return _resp('max-w', props.maxWidth) ?? ''
6
7
  }
@@ -2,6 +2,7 @@ import {ContainerWidth} from '@sanity/ui/theme'
2
2
 
3
3
  import {ResponsiveProp} from '../../types'
4
4
 
5
+ /** @public */
5
6
  export interface MaxWidthStyleProps {
6
7
  maxWidth?: ResponsiveProp<ContainerWidth | 'auto' | 'fill'>
7
8
  }
@@ -1,6 +1,7 @@
1
1
  import {_resp} from '../../_resp'
2
2
  import {MinWidthStyleProps} from './types'
3
3
 
4
+ /** @internal */
4
5
  export function minWidth(props: MinWidthStyleProps): string {
5
6
  return _resp('min-w', props.minWidth) ?? ''
6
7
  }
@@ -1,7 +1,9 @@
1
1
  import {ResponsiveProp} from '../../types'
2
2
 
3
+ /** @public */
3
4
  export type MinWidth = 0 | 'auto' | 'full' | 'min' | 'max' | 'fit'
4
5
 
6
+ /** @public */
5
7
  export interface MinWidthStyleProps {
6
8
  minWidth?: ResponsiveProp<MinWidth>
7
9
  }
@@ -2,6 +2,7 @@ import {_resp} from '../../_resp'
2
2
  import {composeClassNames} from '../../composeClassNames'
3
3
  import {OverflowStyleProps} from './types'
4
4
 
5
+ /** @internal */
5
6
  export function overflow(props: OverflowStyleProps): string | undefined {
6
7
  return composeClassNames(
7
8
  _resp(`overflow`, props.overflow),
@@ -2,6 +2,7 @@ import {_resp} from '../../_resp'
2
2
  import {composeClassNames} from '../../composeClassNames'
3
3
  import {PaddingStyleProps} from './types'
4
4
 
5
+ /** @internal */
5
6
  export function padding(props: PaddingStyleProps): string | undefined {
6
7
  return composeClassNames(
7
8
  _resp('p', props.padding),
@@ -1,6 +1,7 @@
1
1
  import {composeClassNames} from '../../composeClassNames'
2
2
  import {PointerEventsStyleProps} from './types'
3
3
 
4
+ /** @internal */
4
5
  export function pointerEvents(props: PointerEventsStyleProps): string | undefined {
5
6
  return composeClassNames(props.pointerEvents && `pointer-events-${props.pointerEvents}`)
6
7
  }
@@ -2,6 +2,7 @@ import {_resp} from '../../_resp'
2
2
  import {composeClassNames} from '../../composeClassNames'
3
3
  import {PositionStyleProps} from './types'
4
4
 
5
+ /** @internal */
5
6
  export function position(props: PositionStyleProps): string | undefined {
6
7
  return composeClassNames(_resp('position', props.position))
7
8
  }
@@ -2,6 +2,7 @@ import {_resp} from '../../_resp'
2
2
  import {composeClassNames} from '../../composeClassNames'
3
3
  import {ShadowStyleProps} from './types'
4
4
 
5
+ /** @internal */
5
6
  export function shadow(props: ShadowStyleProps): string | undefined {
6
7
  return composeClassNames(_resp('shadow', props.shadow))
7
8
  }
@@ -1,6 +1,7 @@
1
1
  import {_comp} from '../../_comp'
2
2
  import {TextOverflowStyleProps} from './types'
3
3
 
4
+ /** @internal */
4
5
  export function textOverflow(props: TextOverflowStyleProps): string | undefined {
5
6
  return _comp(props.textOverflow && `text-overflow-${props.textOverflow}`)
6
7
  }
@@ -1,3 +1,4 @@
1
+ /** @internal */
1
2
  export interface TextOverflowStyleProps {
2
3
  /**
3
4
  * Controls how overflowing text is treated.
@@ -2,8 +2,10 @@ import {ContainerWidth} from '@sanity/ui/theme'
2
2
 
3
3
  import {ResponsiveProp} from '../../types'
4
4
 
5
+ /** @public */
5
6
  export type Width = ContainerWidth | 'fill'
6
7
 
8
+ /** @public */
7
9
  export interface WidthStyleProps {
8
10
  width?: ResponsiveProp<Width>
9
11
  }
@@ -1,6 +1,7 @@
1
1
  import {_resp} from '../../_resp'
2
2
  import {WidthStyleProps} from './types'
3
3
 
4
+ /** @internal */
4
5
  export function width(props: WidthStyleProps): string {
5
6
  return _resp('w', props.width) ?? ''
6
7
  }
@@ -1,23 +1,27 @@
1
1
  import {color} from '@sanity/color'
2
2
  import {HUES, TINTS} from '@sanity/ui/theme'
3
3
 
4
- import {varNames} from '../varNames'
5
- import {compileRule} from './compileRule'
4
+ import {_compileStyle} from './_compileStyle'
5
+ import {Properties} from './types'
6
+ import {varNames} from './varNames'
6
7
 
8
+ /** @internal */
7
9
  export function compilePalette(): string {
8
- const props: Record<string, string> = {
9
- ...compileHues(),
10
+ return _compileStyle({
11
+ layers: {
12
+ theme: {
13
+ ':root': compilePaletteProperties(),
14
+ },
15
+ },
16
+ })
17
+ }
10
18
 
19
+ function compilePaletteProperties() {
20
+ const rules: Properties = {
11
21
  [varNames.black]: color.black.hex,
12
22
  [varNames.white]: color.white.hex,
13
23
  }
14
24
 
15
- return compileRule(':root', props, {keyframes: {}, media: {}})
16
- }
17
-
18
- function compileHues() {
19
- const rules: Record<string, string> = {}
20
-
21
25
  for (const hue of HUES) {
22
26
  for (const tint of TINTS) {
23
27
  rules[varNames[hue][tint]] = color[hue][tint].hex
@@ -0,0 +1,7 @@
1
+ import {_compileStyle} from './_compileStyle'
2
+ import {_systemStyle} from './_system.style'
3
+
4
+ /** @internal */
5
+ export function compileSystem(): string {
6
+ return _compileStyle(_systemStyle)
7
+ }
@@ -2,6 +2,7 @@ import {type RootTheme} from '@sanity/ui/theme'
2
2
 
3
3
  import {compileTheme_v3} from './compileTheme_v3'
4
4
 
5
+ /** @internal */
5
6
  export function compileTheme(theme: RootTheme): string {
6
7
  if (theme.v3) {
7
8
  return compileTheme_v3(theme.v3)