@sanity/ui 3.0.0-static.10 → 3.0.0-static.12

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 (275) hide show
  1. package/dist/_chunks-cjs/_visual-editing.js +1300 -1269
  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 +1298 -1263
  6. package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
  7. package/dist/_visual-editing.d.mts +516 -360
  8. package/dist/_visual-editing.d.ts +516 -360
  9. package/dist/cli.js +1 -1
  10. package/dist/css.d.mts +258 -75
  11. package/dist/css.d.ts +258 -75
  12. package/dist/css.js +746 -752
  13. package/dist/css.js.map +1 -1
  14. package/dist/css.mjs +748 -754
  15. package/dist/css.mjs.map +1 -1
  16. package/dist/index.d.mts +1342 -871
  17. package/dist/index.d.ts +1342 -871
  18. package/dist/index.js +433 -325
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.mjs +429 -321
  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 -21710
  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 +19 -20
  31. package/dist/theme.js.map +1 -1
  32. package/dist/theme.mjs +19 -20
  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/_resp.ts +0 -1
  39. package/src/css/{system.style.ts → _system.style.ts} +3 -2
  40. package/src/css/aspects/display/display.ts +1 -0
  41. package/src/css/aspects/display/types.ts +2 -3
  42. package/src/css/aspects/flex/types.ts +4 -12
  43. package/src/css/aspects/flexItem/types.ts +1 -3
  44. package/src/css/aspects/font/font.style.ts +7 -66
  45. package/src/css/aspects/font/types.ts +1 -3
  46. package/src/css/aspects/grid/grid.ts +1 -0
  47. package/src/css/aspects/grid/types.ts +5 -9
  48. package/src/css/aspects/gridItem/gridItem.ts +1 -1
  49. package/src/css/aspects/gridItem/types.ts +7 -18
  50. package/src/css/aspects/height/height.ts +3 -4
  51. package/src/css/aspects/inset/inset.ts +1 -0
  52. package/src/css/aspects/margin/margin.ts +1 -0
  53. package/src/css/aspects/margin/types.ts +1 -0
  54. package/src/css/aspects/maxWidth/maxWidth.ts +1 -0
  55. package/src/css/aspects/maxWidth/types.ts +1 -0
  56. package/src/css/aspects/minWidth/minWidth.ts +1 -0
  57. package/src/css/aspects/minWidth/types.ts +2 -0
  58. package/src/css/aspects/overflow/overflow.ts +1 -0
  59. package/src/css/aspects/padding/padding.ts +1 -0
  60. package/src/css/aspects/pointerEvents/pointerEvents.ts +1 -0
  61. package/src/css/aspects/position/position.ts +1 -0
  62. package/src/css/aspects/shadow/shadow.style.ts +16 -41
  63. package/src/css/aspects/shadow/shadow.ts +1 -0
  64. package/src/css/aspects/textOverflow/textOverflow.ts +1 -0
  65. package/src/css/aspects/textOverflow/types.ts +1 -0
  66. package/src/css/aspects/width/types.ts +2 -0
  67. package/src/css/aspects/width/width.ts +1 -0
  68. package/src/css/compilePalette.ts +32 -0
  69. package/src/css/compileSystem.ts +7 -0
  70. package/src/css/{compile/compileTheme.ts → compileTheme.ts} +1 -0
  71. package/src/css/compileTheme_v3.ts +434 -0
  72. package/src/css/components/breadcrumbs/breadcrumbs.ts +1 -0
  73. package/src/css/components/dialog/dialog.ts +7 -0
  74. package/src/css/components/menu/menu.ts +2 -0
  75. package/src/css/components/skeleton/skeleton.style.ts +8 -4
  76. package/src/css/components/skeleton/skeleton.ts +4 -0
  77. package/src/css/components/skeleton/types.ts +4 -0
  78. package/src/css/components/toast/toast.ts +5 -0
  79. package/src/css/components/tree/tree.ts +1 -0
  80. package/src/css/composeClassNames.ts +4 -2
  81. package/src/css/constants.ts +11 -0
  82. package/src/css/index.ts +4 -3
  83. package/src/css/primitives/_arrow/_arrow.style.ts +6 -8
  84. package/src/css/primitives/_arrow/_arrow.ts +7 -0
  85. package/src/css/primitives/_input/input.ts +2 -0
  86. package/src/css/primitives/_selectable/_selectable.style.ts +24 -25
  87. package/src/css/primitives/_selectable/selectable.ts +1 -2
  88. package/src/css/primitives/avatar/avatar.style.ts +5 -8
  89. package/src/css/primitives/avatar/avatar.ts +6 -0
  90. package/src/css/primitives/avatar/types.ts +1 -0
  91. package/src/css/primitives/box/types.ts +1 -3
  92. package/src/css/primitives/button/button.style.ts +48 -15
  93. package/src/css/primitives/button/button.ts +4 -21
  94. package/src/css/primitives/button/index.ts +1 -0
  95. package/src/css/primitives/button/types.ts +18 -0
  96. package/src/css/primitives/card/card.style.ts +4 -7
  97. package/src/css/primitives/card/card.ts +2 -2
  98. package/src/css/primitives/card/types.ts +2 -2
  99. package/src/css/primitives/checkbox/checkbox.ts +2 -0
  100. package/src/css/primitives/container/container.ts +1 -0
  101. package/src/css/primitives/container/types.ts +1 -0
  102. package/src/css/primitives/kbd/kbd.ts +1 -0
  103. package/src/css/primitives/label/types.ts +7 -2
  104. package/src/css/primitives/popover/popover.ts +2 -0
  105. package/src/css/primitives/radio/radio.ts +1 -0
  106. package/src/css/primitives/select/select.ts +2 -0
  107. package/src/css/primitives/spinner/spinner.ts +2 -0
  108. package/src/css/primitives/switch/switch.ts +5 -0
  109. package/src/css/primitives/text/types.ts +4 -0
  110. package/src/css/primitives/textArea/textArea.ts +1 -0
  111. package/src/css/primitives/textInput/textInput.ts +1 -0
  112. package/src/css/primitives/token/token.style.ts +37 -36
  113. package/src/css/primitives/tooltip/tooltip.ts +2 -0
  114. package/src/css/responsiveRules.ts +12 -19
  115. package/src/css/scopeClassName.ts +1 -0
  116. package/src/css/types.ts +115 -15
  117. package/src/css/util.ts +5 -0
  118. package/src/css/utils/srOnly/srOnly.ts +1 -0
  119. package/src/css/varNames.ts +230 -143
  120. package/src/css/vars.ts +53 -22
  121. package/src/theme/palette/constants.ts +2 -0
  122. package/src/theme/palette/types.ts +3 -0
  123. package/src/theme/types.ts +2 -6
  124. package/src/theme/v0/focusRing.ts +1 -3
  125. package/src/theme/v0/font.ts +6 -18
  126. package/src/theme/v0/layer.ts +1 -3
  127. package/src/theme/v0/shadow.ts +2 -6
  128. package/src/theme/v2/avatar.ts +1 -3
  129. package/src/theme/v2/color/_system.ts +1 -3
  130. package/src/theme/v2/color/avatar.ts +2 -6
  131. package/src/theme/v2/color/badge.ts +2 -6
  132. package/src/theme/v2/color/button.ts +3 -9
  133. package/src/theme/v2/color/color.ts +3 -9
  134. package/src/theme/v2/color/input.ts +3 -9
  135. package/src/theme/v2/color/kbd.ts +1 -3
  136. package/src/theme/v2/color/selectable.ts +2 -6
  137. package/src/theme/v2/color/state.ts +1 -3
  138. package/src/theme/v2/color/syntax.ts +1 -3
  139. package/src/theme/v2/input.ts +1 -3
  140. package/src/theme/v2/theme.ts +2 -6
  141. package/src/theme/v3/buildTheme_v3.ts +2 -1
  142. package/src/theme/v3/color/color.ts +6 -4
  143. package/src/theme/v3/color/renderColor.ts +4 -1
  144. package/src/theme/v3/{defaults.ts → defaultTokens.ts} +2 -2
  145. package/src/theme/v3/index.ts +1 -1
  146. package/src/theme/v3/resolveTokens.ts +18 -18
  147. package/src/ui/RootClassNames.tsx +44 -0
  148. package/src/ui/StyleTags.tsx +3 -1
  149. package/src/ui/_compat/helpers.ts +72 -0
  150. package/src/ui/_compat/index.ts +2 -6
  151. package/src/ui/_compat/studioTheme.ts +7 -0
  152. package/src/ui/_compat/theme/themeColorProvider.tsx +2 -6
  153. package/src/ui/_compat/theme/themeProvider.tsx +2 -6
  154. package/src/ui/_compat/theme/types.ts +1 -3
  155. package/src/ui/_compat/theme/useRootTheme.ts +1 -3
  156. package/src/ui/_compat/theme/useTheme.ts +2 -6
  157. package/src/ui/_compat/types.ts +0 -83
  158. package/src/ui/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
  159. package/src/ui/components/autocomplete/autocomplete.tsx +86 -114
  160. package/src/ui/components/autocomplete/autocompleteOption.tsx +2 -0
  161. package/src/ui/components/autocomplete/types.ts +3 -8
  162. package/src/ui/components/breadcrumbs/breadcrumbs.tsx +27 -21
  163. package/src/ui/components/dialog/dialog.tsx +89 -291
  164. package/src/ui/components/dialog/dialogCard.tsx +183 -0
  165. package/src/ui/components/dialog/isTargetWithinScope.ts +14 -0
  166. package/src/ui/components/hotkeys/hotkeys.tsx +33 -15
  167. package/src/ui/components/menu/__workshop__/asComponent.tsx +6 -6
  168. package/src/ui/components/menu/menu.tsx +27 -33
  169. package/src/ui/components/menu/menuButton.tsx +10 -14
  170. package/src/ui/components/menu/menuDivider.tsx +25 -13
  171. package/src/ui/components/menu/menuGroup.tsx +34 -26
  172. package/src/ui/components/menu/menuItem.tsx +51 -40
  173. package/src/ui/components/skeleton/codeSkeleton.tsx +53 -0
  174. package/src/ui/components/skeleton/headingSkeleton.tsx +52 -0
  175. package/src/ui/components/skeleton/index.ts +3 -0
  176. package/src/ui/components/skeleton/labelSkeleton.tsx +51 -0
  177. package/src/ui/components/skeleton/skeleton.tsx +39 -16
  178. package/src/ui/components/skeleton/textSkeleton.tsx +31 -110
  179. package/src/ui/components/tab/tab.tsx +23 -19
  180. package/src/ui/components/tab/tabList.tsx +34 -33
  181. package/src/ui/components/tab/tabPanel.tsx +25 -19
  182. package/src/ui/components/toast/toast.tsx +21 -16
  183. package/src/ui/components/toast/toastLayer.tsx +28 -10
  184. package/src/ui/components/toast/toastProvider.tsx +2 -6
  185. package/src/ui/components/toast/types.ts +2 -6
  186. package/src/ui/components/toast/useToast.ts +1 -3
  187. package/src/ui/components/tree/tree.tsx +194 -187
  188. package/src/ui/components/tree/treeGroup.tsx +25 -5
  189. package/src/ui/components/tree/treeItem.tsx +35 -23
  190. package/src/ui/hooks/useClickOutside.ts +2 -6
  191. package/src/ui/hooks/useClickOutsideEvent.ts +3 -9
  192. package/src/ui/index.ts +1 -0
  193. package/src/ui/primitives/_selectable/selectable.tsx +33 -20
  194. package/src/ui/primitives/avatar/avatar.tsx +28 -31
  195. package/src/ui/primitives/avatar/avatarCounter.tsx +33 -25
  196. package/src/ui/primitives/avatar/avatarStack.tsx +31 -24
  197. package/src/ui/primitives/avatar/types.ts +2 -0
  198. package/src/ui/primitives/badge/__workshop__/props.tsx +1 -9
  199. package/src/ui/primitives/badge/__workshop__/tones.tsx +1 -6
  200. package/src/ui/primitives/badge/badge.tsx +33 -32
  201. package/src/ui/primitives/badge/types.ts +2 -1
  202. package/src/ui/primitives/box/box.tsx +59 -29
  203. package/src/ui/primitives/button/__workshop__/sanityUploadButton.tsx +3 -3
  204. package/src/ui/primitives/button/__workshop__/uploadButton.tsx +2 -1
  205. package/src/ui/primitives/button/button.test.tsx +1 -15
  206. package/src/ui/primitives/button/button.tsx +63 -70
  207. package/src/ui/primitives/card/__workshop__/asComponent.tsx +3 -3
  208. package/src/ui/primitives/card/card.tsx +22 -22
  209. package/src/ui/primitives/card/cardProvider.tsx +2 -0
  210. package/src/ui/primitives/checkbox/checkbox.tsx +26 -15
  211. package/src/ui/primitives/code/code.tsx +24 -22
  212. package/src/ui/primitives/container/container.tsx +26 -15
  213. package/src/ui/primitives/flex/flex.tsx +21 -19
  214. package/src/ui/primitives/grid/grid.tsx +21 -16
  215. package/src/ui/primitives/heading/heading.tsx +42 -19
  216. package/src/ui/primitives/inline/inline.tsx +26 -23
  217. package/src/ui/primitives/kbd/kbd.tsx +25 -23
  218. package/src/ui/primitives/label/label.tsx +29 -26
  219. package/src/ui/primitives/popover/popover.tsx +293 -271
  220. package/src/ui/primitives/popover/popoverCard.tsx +122 -120
  221. package/src/ui/primitives/radio/radio.tsx +30 -14
  222. package/src/ui/primitives/select/select.tsx +24 -16
  223. package/src/ui/primitives/spinner/animatedSpinnerIcon.tsx +4 -2
  224. package/src/ui/primitives/spinner/spinner.tsx +24 -12
  225. package/src/ui/primitives/stack/stack.tsx +27 -18
  226. package/src/ui/primitives/switch/switch.tsx +31 -14
  227. package/src/ui/primitives/text/text.tsx +30 -24
  228. package/src/ui/primitives/textArea/textArea.tsx +33 -18
  229. package/src/ui/primitives/textInput/textInput.tsx +28 -40
  230. package/src/ui/primitives/tooltip/constants.ts +1 -1
  231. package/src/ui/primitives/tooltip/tooltip.tsx +85 -61
  232. package/src/ui/primitives/tooltip/tooltipCard.tsx +89 -82
  233. package/src/ui/primitives/types.ts +1 -3
  234. package/src/ui/types/avatar.ts +3 -6
  235. package/src/ui/types/badge.ts +1 -3
  236. package/src/ui/types/button.ts +1 -3
  237. package/src/ui/types/card.ts +1 -3
  238. package/src/ui/types/dialog.ts +1 -3
  239. package/src/ui/types/props.ts +20 -10
  240. package/src/ui/utils/arrow/arrow.tsx +43 -25
  241. package/src/ui/utils/boundaryElement/boundaryElementProvider.tsx +2 -6
  242. package/src/ui/utils/boundaryElement/types.ts +1 -3
  243. package/src/ui/utils/boundaryElement/useBoundaryElement.ts +1 -3
  244. package/src/ui/utils/elementQuery/elementQuery.tsx +43 -19
  245. package/src/ui/utils/errorBoundary.tsx +2 -0
  246. package/src/ui/utils/index.ts +0 -1
  247. package/src/ui/utils/layer/layer.tsx +23 -93
  248. package/src/ui/utils/layer/layerCard.tsx +92 -0
  249. package/src/ui/utils/layer/layerProvider.tsx +2 -6
  250. package/src/ui/utils/layer/useLayer.ts +1 -3
  251. package/src/ui/utils/portal/portal.ts +2 -6
  252. package/src/ui/utils/portal/portalProvider.tsx +2 -6
  253. package/src/ui/utils/portal/types.ts +1 -3
  254. package/src/ui/utils/portal/usePortal.ts +1 -3
  255. package/src/ui/utils/srOnly/srOnly.tsx +25 -20
  256. package/src/ui/utils/virtualList/virtualList.tsx +69 -50
  257. package/src/css/compile/compilePalette.ts +0 -27
  258. package/src/css/compile/compileRule.ts +0 -97
  259. package/src/css/compile/compileRules.test.ts +0 -36
  260. package/src/css/compile/compileRules.ts +0 -43
  261. package/src/css/compile/compileSystem.ts +0 -10
  262. package/src/css/compile/compileTheme_v3.ts +0 -401
  263. package/src/css/compile/types.ts +0 -6
  264. package/src/css/components/breadcrumbs/rules.ts +0 -25
  265. package/src/css/components/dialog/rules.ts +0 -78
  266. package/src/css/components/skeleton/rules.ts +0 -113
  267. package/src/css/components/toast/rules.ts +0 -18
  268. package/src/css/components/tree/rules.ts +0 -168
  269. package/src/css/primitives/_selectable/_contants.ts +0 -11
  270. package/src/css/primitives/card/_constants.ts +0 -13
  271. package/src/css/primitives/popover/rules.ts +0 -5
  272. package/src/css/primitives/spinner/rules.ts +0 -21
  273. package/src/css/primitives/token/rules.ts +0 -45
  274. package/src/ui/utils/conditionalWrapper/conditionalWrapper.tsx +0 -23
  275. 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.10",
3
+ "version": "3.0.0-static.12",
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<
package/src/css/_resp.ts CHANGED
@@ -1,4 +1,3 @@
1
- // import {scopeClassName as _} from './scopeClassName'
2
1
  import {ResponsiveProp} from './types'
3
2
 
4
3
  function _(className: string) {
@@ -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,10 +1,8 @@
1
- // import {responsiveRules} from '../../responsiveRules'
2
1
  import {_responsiveRule} from '../../_responsiveRule'
3
2
  import {Style, StyleRules} from '../../types'
4
3
 
5
- export const rules: StyleRules = {
4
+ export const primitive: StyleRules = {
6
5
  '.font': {
7
- // 'position': 'relative',
8
6
  'fontFamily': 'var(--font-family)',
9
7
  'fontFeatureSettings': 'var(--font-feature-settings)',
10
8
  'fontSize': 'var(--font-size)',
@@ -71,81 +69,24 @@ export const rules: StyleRules = {
71
69
  },
72
70
  }
73
71
 
74
- // align
75
-
76
- _responsiveRule(rules, `text-align-initial`, {
72
+ _responsiveRule(primitive, `text-align-initial`, {
77
73
  textAlign: 'initial',
78
74
  })
79
75
 
80
- _responsiveRule(rules, `text-align-left`, {
76
+ _responsiveRule(primitive, `text-align-left`, {
81
77
  textAlign: 'left',
82
78
  })
83
79
 
84
- _responsiveRule(rules, `text-align-center`, {
80
+ _responsiveRule(primitive, `text-align-center`, {
85
81
  textAlign: 'center',
86
82
  })
87
83
 
88
- _responsiveRule(rules, `text-align-right`, {
84
+ _responsiveRule(primitive, `text-align-right`, {
89
85
  textAlign: 'right',
90
86
  })
91
87
 
92
- _responsiveRule(rules, `text-align-justify`, {
88
+ _responsiveRule(primitive, `text-align-justify`, {
93
89
  textAlign: 'justify',
94
90
  })
95
91
 
96
- export const fontStyle: Style = {layers: {primitive: rules}}
97
-
98
- // .font {
99
- // position: relative;
100
- // font-family: var(--font-family);
101
- // font-size: var(--font-size);
102
- // line-height: var(--font-line-height);
103
- // letter-spacing: var(--font-letter-spacing);
104
- // font-weight: var(--font-weight);
105
- // transform: translateY(var(--font-descender-height));
106
- // padding: 1px 0;
107
- // margin: 0;
108
-
109
- // --font-negative-height: calc(var(--font-ascender-height) + var(--font-descender-height));
110
- // --font-cap-height: calc(var(--font-line-height) - var(--font-negative-height));
111
- // --font-icon-offset: calc((var(--font-cap-height) - var(--font-icon-size)) / 2);
112
- // --font-custom-icon-size: calc((var(--font-size) * 1.125) / 2) * 2 + 1;
113
- // --font-custom-icon-offset: calc((var(--font-cap-height) - var(--font-custom-icon-size)) / 2);
114
-
115
- // &:before {
116
- // content: '';
117
- // display: block;
118
- // height: 0;
119
- // margin-top: calc(0px - var(--font-negative-height) - 1px);
120
- // }
121
-
122
- // &:after {
123
- // content: '';
124
- // display: block;
125
- // height: 0;
126
- // margin-bottom: -1px;
127
- // }
128
-
129
- // & > code,
130
- // & > span {
131
- // display: block;
132
- // }
133
-
134
- // &:not([hidden]) {
135
- // display: block;
136
- // }
137
-
138
- // & svg:not([data-sanity-icon]) {
139
- // /* todo */
140
- // font-size: var(--font-custom-icon-size);
141
- // /* font-size: calc(var(--font-custom-icon-size) / 16 * 1rem); */
142
- // margin: var(--font-custom-icon-offset);
143
- // }
144
-
145
- // & [data-sanity-icon] {
146
- // /* todo */
147
- // font-size: var(--font-icon-size);
148
- // /* font-size: calc(var(--font-icon-size) / 16 * 1rem); */
149
- // margin: var(--font-icon-offset);
150
- // }
151
- // }
92
+ export const fontStyle: Style = {layers: {primitive}}
@@ -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
  }
@@ -1,49 +1,24 @@
1
+ import {SHADOW} from '@sanity/ui/theme'
2
+
1
3
  import {_responsiveRule} from '../../_responsiveRule'
2
4
  import type {Style, StyleRules} from '../../types'
3
5
  import {vars} from '../../vars'
4
6
 
5
7
  const util: StyleRules = {}
6
8
 
7
- _responsiveRule(util, 'shadow-0', {boxShadow: 'none'})
8
- _responsiveRule(util, 'shadow-1', {
9
- boxShadow: [
10
- `var(--shadow-outline) ${vars.color.shadow.outline}`,
11
- `var(--shadow-1-umbra) ${vars.color.shadow.umbra}`,
12
- `var(--shadow-1-penumbra) ${vars.color.shadow.penumbra}`,
13
- `var(--shadow-1-ambient) ${vars.color.shadow.ambient}`,
14
- ].join(', '),
15
- })
16
- _responsiveRule(util, 'shadow-2', {
17
- boxShadow: [
18
- `var(--shadow-outline) ${vars.color.shadow.outline}`,
19
- `var(--shadow-2-umbra) ${vars.color.shadow.umbra}`,
20
- `var(--shadow-2-penumbra) ${vars.color.shadow.penumbra}`,
21
- `var(--shadow-2-ambient) ${vars.color.shadow.ambient}`,
22
- ].join(', '),
23
- })
24
- _responsiveRule(util, 'shadow-3', {
25
- boxShadow: [
26
- `var(--shadow-outline) ${vars.color.shadow.outline}`,
27
- `var(--shadow-3-umbra) ${vars.color.shadow.umbra}`,
28
- `var(--shadow-3-penumbra) ${vars.color.shadow.penumbra}`,
29
- `var(--shadow-3-ambient) ${vars.color.shadow.ambient}`,
30
- ].join(', '),
31
- })
32
- _responsiveRule(util, 'shadow-4', {
33
- boxShadow: [
34
- `var(--shadow-outline) ${vars.color.shadow.outline}`,
35
- `var(--shadow-4-umbra) ${vars.color.shadow.umbra}`,
36
- `var(--shadow-4-penumbra) ${vars.color.shadow.penumbra}`,
37
- `var(--shadow-4-ambient) ${vars.color.shadow.ambient}`,
38
- ].join(', '),
39
- })
40
- _responsiveRule(util, 'shadow-5', {
41
- boxShadow: [
42
- `var(--shadow-outline) ${vars.color.shadow.outline}`,
43
- `var(--shadow-5-umbra) ${vars.color.shadow.umbra}`,
44
- `var(--shadow-5-penumbra) ${vars.color.shadow.penumbra}`,
45
- `var(--shadow-5-ambient) ${vars.color.shadow.ambient}`,
46
- ].join(', '),
47
- })
9
+ for (const shadow of SHADOW) {
10
+ if (shadow === 0) {
11
+ _responsiveRule(util, 'shadow-0', {boxShadow: 'none'})
12
+ } else {
13
+ _responsiveRule(util, `shadow-${shadow}`, {
14
+ boxShadow: [
15
+ `0 0 0 ${vars.card.shadow.outline} ${vars.color.shadow.outline}`,
16
+ `${vars.shadow[shadow].umbra} ${vars.color.shadow.umbra}`,
17
+ `${vars.shadow[shadow].penumbra} ${vars.color.shadow.penumbra}`,
18
+ `${vars.shadow[shadow].ambient} ${vars.color.shadow.ambient}`,
19
+ ].join(', '),
20
+ })
21
+ }
22
+ }
48
23
 
49
24
  export const shadowStyle: Style = {layers: {util}}