@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
@@ -13,16 +13,23 @@ import {
13
13
  ThemeColorSchemeKey,
14
14
  } from '@sanity/ui/theme'
15
15
 
16
- import {Properties} from '../types'
17
- import {px, rem, toBoxShadow} from '../util'
18
- import {varNames} from '../varNames'
19
- import {compileRule} from './compileRule'
16
+ import {_compileStyle} from './_compileStyle'
17
+ import {Properties} from './types'
18
+ import {px, rem, toBoxShadow} from './util'
19
+ import {varNames} from './varNames'
20
20
 
21
21
  const THEME_COLOR_SCHEMES = ['dark', 'light'] as const
22
22
  const THEME_COLOR_VARIANTS = ['tinted', 'solid'] as const
23
23
 
24
+ /** @internal */
24
25
  export function compileTheme_v3(theme: Theme_v3): string {
25
- return compileRule(':root', compileThemeProperties(theme), {keyframes: {}, media: {}})
26
+ return _compileStyle({
27
+ layers: {
28
+ theme: {
29
+ ':root': compileThemeProperties(theme),
30
+ },
31
+ },
32
+ })
26
33
  }
27
34
 
28
35
  function compileThemeProperties(theme: Theme_v3): Properties {
@@ -30,6 +37,7 @@ function compileThemeProperties(theme: Theme_v3): Properties {
30
37
  ...buildAvatarThemeProperties(theme),
31
38
  ...buildButtonThemeProperties(theme),
32
39
  [varNames.card.shadow.outline]: px(theme.card.shadow.outline),
40
+ ...buildColorThemeProperties(theme),
33
41
  ...buildContainerThemeProperties(theme),
34
42
  ...buildFontCodeThemeProperties(theme),
35
43
  ...buildFontHeadingThemeProperties(theme),
@@ -39,7 +47,6 @@ function compileThemeProperties(theme: Theme_v3): Properties {
39
47
  ...buildRadiusThemeProperties(theme),
40
48
  ...buildShadowThemeProperties(theme),
41
49
  ...buildSpaceThemeProperties(theme),
42
- ...buildColorThemeProperties(theme),
43
50
  }
44
51
  }
45
52
 
@@ -48,17 +55,17 @@ function buildAvatarThemeProperties(theme: Theme_v3): Properties {
48
55
  [varNames.avatar.focusRing.offset]: px(theme.avatar.focusRing.offset),
49
56
  [varNames.avatar.focusRing.width]: px(theme.avatar.focusRing.width),
50
57
 
51
- [varNames.avatar.sizes[0].distance]: px(theme.avatar.sizes[0].distance),
52
- [varNames.avatar.sizes[0].size]: px(theme.avatar.sizes[0].size),
58
+ [varNames.avatar.sizes[0].distance]: rem(theme.avatar.sizes[0].distance),
59
+ [varNames.avatar.sizes[0].size]: rem(theme.avatar.sizes[0].size),
53
60
 
54
- [varNames.avatar.sizes[1].distance]: px(theme.avatar.sizes[1].distance),
55
- [varNames.avatar.sizes[1].size]: px(theme.avatar.sizes[1].size),
61
+ [varNames.avatar.sizes[1].distance]: rem(theme.avatar.sizes[1].distance),
62
+ [varNames.avatar.sizes[1].size]: rem(theme.avatar.sizes[1].size),
56
63
 
57
- [varNames.avatar.sizes[2].distance]: px(theme.avatar.sizes[2].distance),
58
- [varNames.avatar.sizes[2].size]: px(theme.avatar.sizes[2].size),
64
+ [varNames.avatar.sizes[2].distance]: rem(theme.avatar.sizes[2].distance),
65
+ [varNames.avatar.sizes[2].size]: rem(theme.avatar.sizes[2].size),
59
66
 
60
- [varNames.avatar.sizes[3].distance]: px(theme.avatar.sizes[3].distance),
61
- [varNames.avatar.sizes[3].size]: px(theme.avatar.sizes[3].size),
67
+ [varNames.avatar.sizes[3].distance]: rem(theme.avatar.sizes[3].distance),
68
+ [varNames.avatar.sizes[3].size]: rem(theme.avatar.sizes[3].size),
62
69
  }
63
70
  }
64
71
 
@@ -72,110 +79,122 @@ function buildButtonThemeProperties(theme: Theme_v3): Properties {
72
79
 
73
80
  function buildContainerThemeProperties(theme: Theme_v3): Properties {
74
81
  return {
75
- [varNames.container[0]]: px(theme.container[0]),
76
- [varNames.container[1]]: px(theme.container[1]),
77
- [varNames.container[2]]: px(theme.container[2]),
78
- [varNames.container[3]]: px(theme.container[3]),
79
- [varNames.container[4]]: px(theme.container[4]),
80
- [varNames.container[5]]: px(theme.container[5]),
82
+ [varNames.container[0]]: rem(theme.container[0]),
83
+ [varNames.container[1]]: rem(theme.container[1]),
84
+ [varNames.container[2]]: rem(theme.container[2]),
85
+ [varNames.container[3]]: rem(theme.container[3]),
86
+ [varNames.container[4]]: rem(theme.container[4]),
87
+ [varNames.container[5]]: rem(theme.container[5]),
81
88
  }
82
89
  }
83
90
 
84
91
  function buildFontCodeThemeProperties(theme: Theme_v3): Properties {
92
+ const v = varNames.font.code
93
+ const t = theme.font.code
94
+
85
95
  const props: Properties = {
86
- [varNames.font.code.family]: theme.font.code.family,
87
- [varNames.font.code.featureSettings]: theme.font.code.featureSettings,
88
- [varNames.font.code.weights.regular]: `${theme.font.code.weights.regular}`,
89
- [varNames.font.code.weights.medium]: `${theme.font.code.weights.medium}`,
90
- [varNames.font.code.weights.semibold]: `${theme.font.code.weights.semibold}`,
91
- [varNames.font.code.weights.bold]: `${theme.font.code.weights.bold}`,
96
+ [v.family]: t.family,
97
+ [v.featureSettings]: t.featureSettings || 'normal',
98
+ [v.weights.regular]: t.weights.regular,
99
+ [v.weights.medium]: t.weights.medium,
100
+ [v.weights.semibold]: t.weights.semibold,
101
+ [v.weights.bold]: t.weights.bold,
92
102
  }
93
103
 
94
104
  for (const size of FONT_CODE_SIZE) {
95
- const v = varNames.font.code.sizes[size]
96
- const t = theme.font.code.sizes[size]
97
-
98
- props[v.fontSize] = rem(t.fontSize)
99
- props[v.lineHeight] = rem(t.lineHeight)
100
- props[v.ascenderHeight] = px(t.ascenderHeight)
101
- props[v.descenderHeight] = px(t.descenderHeight)
102
- props[v.letterSpacing] = px(t.letterSpacing)
103
- props[v.iconSize] = px(t.iconSize)
105
+ const _v = varNames.font.code.sizes[size]
106
+ const _t = theme.font.code.sizes[size]
107
+
108
+ props[_v.fontSize] = rem(_t.fontSize)
109
+ props[_v.lineHeight] = rem(_t.lineHeight)
110
+ props[_v.ascenderHeight] = rem(_t.ascenderHeight)
111
+ props[_v.descenderHeight] = rem(_t.descenderHeight)
112
+ props[_v.letterSpacing] = rem(_t.letterSpacing)
113
+ props[_v.iconSize] = rem(_t.iconSize)
104
114
  }
105
115
 
106
116
  return props
107
117
  }
108
118
 
109
119
  function buildFontHeadingThemeProperties(theme: Theme_v3): Properties {
120
+ const v = varNames.font.heading
121
+ const t = theme.font.heading
122
+
110
123
  const props: Properties = {
111
- [varNames.font.heading.family]: theme.font.heading.family,
112
- [varNames.font.heading.featureSettings]: theme.font.heading.featureSettings,
113
- [varNames.font.heading.weights.regular]: `${theme.font.heading.weights.regular}`,
114
- [varNames.font.heading.weights.medium]: `${theme.font.heading.weights.medium}`,
115
- [varNames.font.heading.weights.semibold]: `${theme.font.heading.weights.semibold}`,
116
- [varNames.font.heading.weights.bold]: `${theme.font.heading.weights.bold}`,
124
+ [v.family]: t.family,
125
+ [v.featureSettings]: t.featureSettings,
126
+ [v.weights.regular]: t.weights.regular,
127
+ [v.weights.medium]: t.weights.medium,
128
+ [v.weights.semibold]: t.weights.semibold,
129
+ [v.weights.bold]: t.weights.bold,
117
130
  }
118
131
 
119
132
  for (const size of FONT_HEADING_SIZE) {
120
- const v = varNames.font.heading.sizes[size]
121
- const t = theme.font.heading.sizes[size]
122
-
123
- props[v.fontSize] = rem(t.fontSize)
124
- props[v.lineHeight] = rem(t.lineHeight)
125
- props[v.ascenderHeight] = px(t.ascenderHeight)
126
- props[v.descenderHeight] = px(t.descenderHeight)
127
- props[v.letterSpacing] = px(t.letterSpacing)
128
- props[v.iconSize] = px(t.iconSize)
133
+ const _v = v.sizes[size]
134
+ const _t = t.sizes[size]
135
+
136
+ props[_v.fontSize] = rem(_t.fontSize)
137
+ props[_v.lineHeight] = rem(_t.lineHeight)
138
+ props[_v.ascenderHeight] = rem(_t.ascenderHeight)
139
+ props[_v.descenderHeight] = rem(_t.descenderHeight)
140
+ props[_v.letterSpacing] = rem(_t.letterSpacing)
141
+ props[_v.iconSize] = rem(_t.iconSize)
129
142
  }
130
143
 
131
144
  return props
132
145
  }
133
146
 
134
147
  function buildFontLabelThemeProperties(theme: Theme_v3): Properties {
148
+ const v = varNames.font.label
149
+ const t = theme.font.label
150
+
135
151
  const props: Properties = {
136
- [varNames.font.label.family]: theme.font.label.family,
137
- [varNames.font.label.featureSettings]: theme.font.label.featureSettings,
138
- [varNames.font.label.weights.regular]: `${theme.font.label.weights.regular}`,
139
- [varNames.font.label.weights.medium]: `${theme.font.label.weights.medium}`,
140
- [varNames.font.label.weights.semibold]: `${theme.font.label.weights.semibold}`,
141
- [varNames.font.label.weights.bold]: `${theme.font.label.weights.bold}`,
152
+ [v.family]: t.family,
153
+ [v.featureSettings]: t.featureSettings,
154
+ [v.weights.regular]: t.weights.regular,
155
+ [v.weights.medium]: t.weights.medium,
156
+ [v.weights.semibold]: t.weights.semibold,
157
+ [v.weights.bold]: t.weights.bold,
142
158
  }
143
159
 
144
160
  for (const size of FONT_LABEL_SIZE) {
145
- const v = varNames.font.label.sizes[size]
146
- const t = theme.font.label.sizes[size]
147
-
148
- props[v.fontSize] = rem(t.fontSize)
149
- props[v.lineHeight] = rem(t.lineHeight)
150
- props[v.ascenderHeight] = px(t.ascenderHeight)
151
- props[v.descenderHeight] = px(t.descenderHeight)
152
- props[v.letterSpacing] = px(t.letterSpacing)
153
- props[v.iconSize] = px(t.iconSize)
161
+ const _v = v.sizes[size]
162
+ const _t = t.sizes[size]
163
+
164
+ props[_v.fontSize] = rem(_t.fontSize)
165
+ props[_v.lineHeight] = rem(_t.lineHeight)
166
+ props[_v.ascenderHeight] = rem(_t.ascenderHeight)
167
+ props[_v.descenderHeight] = rem(_t.descenderHeight)
168
+ props[_v.letterSpacing] = rem(_t.letterSpacing)
169
+ props[_v.iconSize] = rem(_t.iconSize)
154
170
  }
155
171
 
156
172
  return props
157
173
  }
158
174
 
159
175
  function buildFontTextThemeProperties(theme: Theme_v3): Properties {
176
+ const v = varNames.font.text
177
+ const t = theme.font.text
178
+
160
179
  const props: Properties = {
161
- [varNames.font.text.family]: theme.font.text.family,
162
- [varNames.font.text.featureSettings]: theme.font.text.featureSettings,
163
- [varNames.font.text.weights.regular]: `${theme.font.text.weights.regular}`,
164
- [varNames.font.text.weights.medium]: `${theme.font.text.weights.medium}`,
165
- [varNames.font.text.weights.semibold]: `${theme.font.text.weights.semibold}`,
166
- [varNames.font.text.weights.bold]: `${theme.font.text.weights.bold}`,
180
+ [v.family]: t.family,
181
+ [v.featureSettings]: t.featureSettings,
182
+ [v.weights.regular]: t.weights.regular,
183
+ [v.weights.medium]: t.weights.medium,
184
+ [v.weights.semibold]: t.weights.semibold,
185
+ [v.weights.bold]: t.weights.bold,
167
186
  }
168
187
 
169
188
  for (const size of FONT_TEXT_SIZE) {
170
- const v = varNames.font.text.sizes[size]
171
- const t = theme.font.text.sizes[size]
172
-
173
- props[v.fontSize] = rem(t.fontSize)
174
- props[v.lineHeight] = rem(t.lineHeight)
175
- props[v.ascenderHeight] = px(t.ascenderHeight)
176
- props[v.descenderHeight] = px(t.descenderHeight)
177
- props[v.letterSpacing] = px(t.letterSpacing)
178
- props[v.iconSize] = px(t.iconSize)
189
+ const _v = v.sizes[size]
190
+ const _t = t.sizes[size]
191
+
192
+ props[_v.fontSize] = rem(_t.fontSize)
193
+ props[_v.lineHeight] = rem(_t.lineHeight)
194
+ props[_v.ascenderHeight] = rem(_t.ascenderHeight)
195
+ props[_v.descenderHeight] = rem(_t.descenderHeight)
196
+ props[_v.letterSpacing] = rem(_t.letterSpacing)
197
+ props[_v.iconSize] = rem(_t.iconSize)
179
198
  }
180
199
 
181
200
  return props
@@ -186,20 +205,20 @@ function buildInputThemeProperties(theme: Theme_v3): Properties {
186
205
  [varNames.input.border.width]: px(theme.input.border.width),
187
206
  [varNames.input.checkbox.focusRing.offset]: px(theme.input.checkbox.focusRing.offset),
188
207
  [varNames.input.checkbox.focusRing.width]: px(theme.input.checkbox.focusRing.width),
189
- [varNames.input.checkbox.size]: px(theme.input.checkbox.size),
208
+ [varNames.input.checkbox.size]: rem(theme.input.checkbox.size),
190
209
  [varNames.input.radio.focusRing.offset]: px(theme.input.radio.focusRing.offset),
191
210
  [varNames.input.radio.focusRing.width]: px(theme.input.radio.focusRing.width),
192
- [varNames.input.radio.markSize]: px(theme.input.radio.markSize),
193
- [varNames.input.radio.size]: px(theme.input.radio.size),
211
+ [varNames.input.radio.markSize]: rem(theme.input.radio.markSize),
212
+ [varNames.input.radio.size]: rem(theme.input.radio.size),
194
213
  [varNames.input.select.focusRing.offset]: px(theme.input.select.focusRing.offset),
195
214
  [varNames.input.select.focusRing.width]: px(theme.input.select.focusRing.width),
196
215
  [varNames.input.switch.focusRing.offset]: px(theme.input.switch.focusRing.offset),
197
216
  [varNames.input.switch.focusRing.width]: px(theme.input.switch.focusRing.width),
198
- [varNames.input.switch.height]: px(theme.input.switch.height),
199
- [varNames.input.switch.padding]: px(theme.input.switch.padding),
217
+ [varNames.input.switch.height]: rem(theme.input.switch.height),
218
+ [varNames.input.switch.padding]: rem(theme.input.switch.padding),
200
219
  [varNames.input.switch.transitionDurationMs]: `${theme.input.switch.transitionDurationMs}ms`,
201
220
  [varNames.input.switch.transitionTimingFunction]: theme.input.switch.transitionTimingFunction,
202
- [varNames.input.switch.width]: px(theme.input.switch.width),
221
+ [varNames.input.switch.width]: rem(theme.input.switch.width),
203
222
  [varNames.input.text.focusRing.offset]: px(theme.input.text.focusRing.offset),
204
223
  [varNames.input.text.focusRing.width]: px(theme.input.text.focusRing.width),
205
224
  }
@@ -207,13 +226,13 @@ function buildInputThemeProperties(theme: Theme_v3): Properties {
207
226
 
208
227
  function buildRadiusThemeProperties(theme: Theme_v3): Properties {
209
228
  return {
210
- [varNames.radius[0]]: rem(theme.radius[0]),
211
- [varNames.radius[1]]: rem(theme.radius[1]),
212
- [varNames.radius[2]]: rem(theme.radius[2]),
213
- [varNames.radius[3]]: rem(theme.radius[3]),
214
- [varNames.radius[4]]: rem(theme.radius[4]),
215
- [varNames.radius[5]]: rem(theme.radius[5]),
216
- [varNames.radius[6]]: rem(theme.radius[6]),
229
+ [varNames.radius[0]]: px(theme.radius[0]),
230
+ [varNames.radius[1]]: px(theme.radius[1]),
231
+ [varNames.radius[2]]: px(theme.radius[2]),
232
+ [varNames.radius[3]]: px(theme.radius[3]),
233
+ [varNames.radius[4]]: px(theme.radius[4]),
234
+ [varNames.radius[5]]: px(theme.radius[5]),
235
+ [varNames.radius[6]]: px(theme.radius[6]),
217
236
  }
218
237
  }
219
238
 
@@ -247,17 +266,17 @@ function buildShadowThemeProperties(theme: Theme_v3): Properties {
247
266
 
248
267
  function buildSpaceThemeProperties(theme: Theme_v3): Properties {
249
268
  return {
250
- [varNames.space[0]]: rem(theme.space[0]),
251
- [varNames.space[0.5]]: rem(theme.space[1] / 2),
252
- [varNames.space[1]]: rem(theme.space[1]),
253
- [varNames.space[2]]: rem(theme.space[2]),
254
- [varNames.space[3]]: rem(theme.space[3]),
255
- [varNames.space[4]]: rem(theme.space[4]),
256
- [varNames.space[5]]: rem(theme.space[5]),
257
- [varNames.space[6]]: rem(theme.space[6]),
258
- [varNames.space[7]]: rem(theme.space[7]),
259
- [varNames.space[8]]: rem(theme.space[8]),
260
- [varNames.space[9]]: rem(theme.space[9]),
269
+ [varNames.space[0]]: px(theme.space[0]),
270
+ [varNames.space[0.5]]: px(theme.space[1] / 2),
271
+ [varNames.space[1]]: px(theme.space[1]),
272
+ [varNames.space[2]]: px(theme.space[2]),
273
+ [varNames.space[3]]: px(theme.space[3]),
274
+ [varNames.space[4]]: px(theme.space[4]),
275
+ [varNames.space[5]]: px(theme.space[5]),
276
+ [varNames.space[6]]: px(theme.space[6]),
277
+ [varNames.space[7]]: px(theme.space[7]),
278
+ [varNames.space[8]]: px(theme.space[8]),
279
+ [varNames.space[9]]: px(theme.space[9]),
261
280
  }
262
281
  }
263
282
 
@@ -1,5 +1,6 @@
1
1
  import {_comp} from '../../_comp'
2
2
 
3
+ /** @public */
3
4
  export function breadcrumbs(): string | undefined {
4
5
  return _comp('breadcrumbs')
5
6
  }
@@ -1,30 +1,37 @@
1
1
  import {_comp} from '../../_comp'
2
2
  import {inset} from '../../aspects'
3
3
 
4
+ /** @public */
4
5
  export function dialog(): string | undefined {
5
6
  return _comp('dialog', inset({inset: 0}))
6
7
  }
7
8
 
9
+ /** @public */
8
10
  export function dialogContainer(): string | undefined {
9
11
  return _comp('dialog-container')
10
12
  }
11
13
 
14
+ /** @public */
12
15
  export function dialogCardRoot(): string | undefined {
13
16
  return _comp('dialog-card-root')
14
17
  }
15
18
 
19
+ /** @public */
16
20
  export function dialogLayout(): string | undefined {
17
21
  return _comp('dialog-layout')
18
22
  }
19
23
 
24
+ /** @public */
20
25
  export function dialogHeader(): string | undefined {
21
26
  return _comp('dialog-header')
22
27
  }
23
28
 
29
+ /** @public */
24
30
  export function dialogContent(): string | undefined {
25
31
  return _comp('dialog-content')
26
32
  }
27
33
 
34
+ /** @public */
28
35
  export function dialogFooter(): string | undefined {
29
36
  return _comp('dialog-footer')
30
37
  }
@@ -1,9 +1,11 @@
1
1
  import {_comp} from '../../_comp'
2
2
 
3
+ /** @public */
3
4
  export function menu(): string | undefined {
4
5
  return _comp('menu')
5
6
  }
6
7
 
8
+ /** @public */
7
9
  export function menuDivider(): string | undefined {
8
10
  return _comp('menu-divider')
9
11
  }
@@ -14,18 +14,22 @@ export function skeleton(props: SkeletonStyleProps): string | undefined {
14
14
  return _comp('skeleton', radius(props))
15
15
  }
16
16
 
17
+ /** @beta */
17
18
  export function codeSkeleton(props: CodeSkeletonStyleProps): string | undefined {
18
19
  return _comp('font-skeleton', _resp('code-skeleton', props.size))
19
20
  }
20
21
 
22
+ /** @beta */
21
23
  export function headingSkeleton(props: HeadingSkeletonStyleProps): string | undefined {
22
24
  return _comp('font-skeleton', _resp('heading-skeleton', props.size))
23
25
  }
24
26
 
27
+ /** @beta */
25
28
  export function labelSkeleton(props: LabelSkeletonStyleProps): string | undefined {
26
29
  return _comp('font-skeleton', _resp('label-skeleton', props.size))
27
30
  }
28
31
 
32
+ /** @beta */
29
33
  export function textSkeleton(props: TextSkeletonStyleProps): string | undefined {
30
34
  return _comp('font-skeleton', _resp('text-skeleton', props.size))
31
35
  }
@@ -9,18 +9,22 @@ export interface SkeletonStyleProps extends RadiusStyleProps {
9
9
  // visible?: boolean
10
10
  }
11
11
 
12
+ /** @beta */
12
13
  export interface CodeSkeletonStyleProps {
13
14
  size?: ResponsiveProp<FontCodeSize>
14
15
  }
15
16
 
17
+ /** @beta */
16
18
  export interface HeadingSkeletonStyleProps {
17
19
  size?: ResponsiveProp<FontHeadingSize>
18
20
  }
19
21
 
22
+ /** @beta */
20
23
  export interface LabelSkeletonStyleProps {
21
24
  size?: ResponsiveProp<FontLabelSize>
22
25
  }
23
26
 
27
+ /** @beta */
24
28
  export interface TextSkeletonStyleProps {
25
29
  size?: ResponsiveProp<FontTextSize>
26
30
  }
@@ -1,21 +1,26 @@
1
1
  import {_comp} from '../../_comp'
2
2
 
3
+ /** @public */
3
4
  export function toastLayer() {
4
5
  return _comp('toast-layer')
5
6
  }
6
7
 
8
+ /** @public */
7
9
  export function toast() {
8
10
  return _comp('toast')
9
11
  }
10
12
 
13
+ /** @public */
11
14
  export function toastLoadingBar() {
12
15
  return _comp('toast-loading-bar')
13
16
  }
14
17
 
18
+ /** @public */
15
19
  export function toastLoadingBarProgress() {
16
20
  return _comp('toast-loading-bar-progress')
17
21
  }
18
22
 
23
+ /** @public */
19
24
  export function toastLoadingBarMask() {
20
25
  return _comp('toast-loading-bar-mask')
21
26
  }
@@ -1,5 +1,6 @@
1
1
  import {_comp} from '../../_comp'
2
2
 
3
+ /** @beta */
3
4
  export function treeItem(): string | undefined {
4
5
  return _comp('tree-item')
5
6
  }
@@ -1,4 +1,5 @@
1
- export function getClassNames(...classNames: Array<string | false | undefined>): string[] {
1
+ /** @internal */
2
+ export function _getClassNames(...classNames: Array<string | false | undefined>): string[] {
2
3
  return classNames
3
4
  .map((n) => typeof n === 'string' && n.trim())
4
5
  .filter(Boolean)
@@ -6,10 +7,11 @@ export function getClassNames(...classNames: Array<string | false | undefined>):
6
7
  .split(' ')
7
8
  }
8
9
 
10
+ /** @public */
9
11
  export function composeClassNames(
10
12
  ...classNames: Array<string | false | undefined>
11
13
  ): string | undefined {
12
- return unique(getClassNames(...classNames)).join(' ') || undefined
14
+ return unique(_getClassNames(...classNames)).join(' ') || undefined
13
15
  }
14
16
 
15
17
  function unique<T>(array: T[]): T[] {
@@ -1,3 +1,4 @@
1
+ /** @public */
1
2
  export const BREAKPOINTS = {
2
3
  1: 360,
3
4
  2: 600,
@@ -7,4 +8,5 @@ export const BREAKPOINTS = {
7
8
  6: 2400,
8
9
  }
9
10
 
11
+ /** @public */
10
12
  export const PREFIX = 's-'
package/src/css/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export * from './aspects'
2
- export * from './compile/compilePalette'
3
- export * from './compile/compileSystem'
4
- export * from './compile/compileTheme'
2
+ export * from './compilePalette'
3
+ export * from './compileSystem'
4
+ export * from './compileTheme'
5
5
  export * from './components/breadcrumbs'
6
6
  export * from './components/dialog'
7
7
  export * from './components/menu'
@@ -5,14 +5,17 @@ export function _arrow(): string | undefined {
5
5
  return _comp('arrow')
6
6
  }
7
7
 
8
+ /** @internal */
8
9
  export function _arrowStroke(): string | undefined {
9
10
  return _comp('arrow-stroke')
10
11
  }
11
12
 
13
+ /** @internal */
12
14
  export function _arrowStrokeMask(): string | undefined {
13
15
  return _comp('arrow-stroke-mask')
14
16
  }
15
17
 
18
+ /** @internal */
16
19
  export function _arrowShape(): string | undefined {
17
20
  return _comp('arrow-shape')
18
21
  }
@@ -16,10 +16,12 @@ export function _input(props: InputStyleProps): string | undefined {
16
16
  )
17
17
  }
18
18
 
19
+ /** @internal */
19
20
  export function _inputElement(): string | undefined {
20
21
  return _comp('input-element')
21
22
  }
22
23
 
24
+ /** @internal */
23
25
  export function _inputPresentation(): string | undefined {
24
26
  return _comp('input-presentation')
25
27
  }
@@ -3,7 +3,6 @@ import {THEME_COLOR_STATE_TONES} from '@sanity/ui/theme'
3
3
  import {Properties, Style, StyleRules} from '../../types'
4
4
  import {varNames} from '../../varNames'
5
5
  import {vars} from '../../vars'
6
- import {toneMap} from './_contants'
7
6
 
8
7
  const primitive: StyleRules = {
9
8
  '.selectable': {
@@ -89,7 +88,7 @@ function buildSelectableTones(): Record<string, Properties> {
89
88
  const target = varNames.color
90
89
  const source = vars.color
91
90
 
92
- rules[`&.${toneMap[tone]}`] = {
91
+ rules[`&.${tone}`] = {
93
92
  [target.tinted.bg[0]]: source.tinted[tone].bg[0],
94
93
  [target.tinted.bg[1]]: source.tinted[tone].bg[1],
95
94
  [target.tinted.bg[2]]: source.tinted[tone].bg[2],
@@ -1,9 +1,8 @@
1
1
  import {_comp} from '../../_comp'
2
2
  import {radius} from '../../aspects'
3
- import {toneMap} from './_contants'
4
3
  import {SelectableStyleProps} from './types'
5
4
 
6
5
  /** @internal */
7
6
  export function _selectable(props: SelectableStyleProps): string | undefined {
8
- return _comp('selectable', toneMap[props.tone ?? 'default'], radius(props))
7
+ return _comp('selectable', props.tone ?? 'default', radius(props))
9
8
  }
@@ -7,6 +7,8 @@ import {vars} from '../../vars'
7
7
 
8
8
  const primitive: StyleRules = {
9
9
  '.avatar': {
10
+ [varNames.color.fg]: vars.color.avatar.fg,
11
+
10
12
  'backgroundColor': vars.color.avatar.bg,
11
13
  'position': 'relative',
12
14
  'boxSizing': 'border-box',
@@ -19,12 +21,7 @@ const primitive: StyleRules = {
19
21
  'borderRadius': vars.avatar.size,
20
22
 
21
23
  '@nest': {
22
- '&[data-status="inactive"]': {
23
- opacity: 0.5,
24
- },
25
-
26
- // &:is(button)
27
- '&:is(button)': {
24
+ 'button&': {
28
25
  WebkitFontSmoothing: 'inherit',
29
26
  appearance: 'none',
30
27
  margin: 0,
@@ -35,12 +32,12 @@ const primitive: StyleRules = {
35
32
  outline: 'none',
36
33
  },
37
34
 
38
- '&:is(button):focus': {
35
+ 'button&:focus': {
39
36
  outline: 'var(--avatar-focus-ring-width) solid var(--color-focus-ring)',
40
37
  outlineOffset: 'var(--avatar-focus-ring-offset)',
41
38
  },
42
39
 
43
- '&:is(button):focus:not(:focus-visible)': {
40
+ 'button&:focus:not(:focus-visible)': {
44
41
  boxShadow: 'none',
45
42
  },
46
43
 
@@ -2,26 +2,32 @@ import {_comp} from '../../_comp'
2
2
  import {_resp} from '../../_resp'
3
3
  import {AvatarStyleProps} from './types'
4
4
 
5
+ /** @public */
5
6
  export function avatar(props: AvatarStyleProps): string | undefined {
6
7
  return _comp('avatar', props.color || 'gray', _resp('avatar', props.size))
7
8
  }
8
9
 
10
+ /** @public */
9
11
  export function avatarArrow(): string | undefined {
10
12
  return _comp('avatar-arrow')
11
13
  }
12
14
 
15
+ /** @public */
13
16
  export function avatarInitials(): string | undefined {
14
17
  return _comp('avatar-initials')
15
18
  }
16
19
 
20
+ /** @public */
17
21
  export function avatarImage(): string | undefined {
18
22
  return _comp('avatar-image')
19
23
  }
20
24
 
25
+ /** @public */
21
26
  export function avatarCounter(props: {size?: AvatarStyleProps['size']}): string | undefined {
22
27
  return _comp('avatar-counter', _resp('avatar', props.size))
23
28
  }
24
29
 
30
+ /** @public */
25
31
  export function avatarStack(props: {size?: AvatarStyleProps['size']}): string | undefined {
26
32
  return _comp('avatar-stack', _resp('avatar', props.size))
27
33
  }