@dxos/ui-theme 0.8.4-main.fbb7a13 → 0.8.4-staging.ac66bdf99f

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 (384) hide show
  1. package/dist/lib/browser/index.mjs +766 -2802
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +766 -2802
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/plugin/node-cjs/main.css +1529 -0
  8. package/dist/plugin/node-cjs/main.css.map +7 -0
  9. package/dist/plugin/node-cjs/meta.json +1 -1
  10. package/dist/plugin/node-cjs/plugins/ThemePlugin.cjs +137 -0
  11. package/dist/plugin/node-cjs/plugins/ThemePlugin.cjs.map +7 -0
  12. package/dist/plugin/node-esm/main.css +1529 -0
  13. package/dist/plugin/node-esm/main.css.map +7 -0
  14. package/dist/plugin/node-esm/meta.json +1 -1
  15. package/dist/plugin/node-esm/plugins/ThemePlugin.mjs +105 -0
  16. package/dist/plugin/node-esm/plugins/ThemePlugin.mjs.map +7 -0
  17. package/dist/types/src/Theme.stories.d.ts +27 -0
  18. package/dist/types/src/Theme.stories.d.ts.map +1 -0
  19. package/dist/types/src/defs.d.ts +21 -0
  20. package/dist/types/src/defs.d.ts.map +1 -0
  21. package/dist/types/src/fragments/density.d.ts +4 -0
  22. package/dist/types/src/fragments/density.d.ts.map +1 -0
  23. package/dist/types/src/fragments/disabled.d.ts.map +1 -0
  24. package/dist/types/src/fragments/hover.d.ts +10 -0
  25. package/dist/types/src/fragments/hover.d.ts.map +1 -0
  26. package/dist/types/src/fragments/index.d.ts +5 -0
  27. package/dist/types/src/fragments/index.d.ts.map +1 -0
  28. package/dist/types/src/fragments/text.d.ts +2 -0
  29. package/dist/types/src/fragments/text.d.ts.map +1 -0
  30. package/dist/types/src/index.d.ts +3 -10
  31. package/dist/types/src/index.d.ts.map +1 -1
  32. package/dist/types/src/plugins/ThemePlugin.d.ts +16 -0
  33. package/dist/types/src/plugins/ThemePlugin.d.ts.map +1 -0
  34. package/dist/types/src/plugins/dark-mode.d.ts +1 -0
  35. package/dist/types/src/plugins/dark-mode.d.ts.map +1 -0
  36. package/dist/types/src/theme/components/avatar.d.ts.map +1 -0
  37. package/dist/types/src/theme/components/breadcrumb.d.ts.map +1 -0
  38. package/dist/types/src/theme/components/button.d.ts +15 -0
  39. package/dist/types/src/theme/components/button.d.ts.map +1 -0
  40. package/dist/types/src/theme/components/card.d.ts +12 -0
  41. package/dist/types/src/theme/components/card.d.ts.map +1 -0
  42. package/dist/types/src/{styles → theme}/components/dialog.d.ts +2 -0
  43. package/dist/types/src/theme/components/dialog.d.ts.map +1 -0
  44. package/dist/types/src/theme/components/focus.d.ts +6 -0
  45. package/dist/types/src/theme/components/focus.d.ts.map +1 -0
  46. package/dist/types/src/theme/components/icon-button.d.ts.map +1 -0
  47. package/dist/types/src/{styles → theme}/components/icon.d.ts +3 -0
  48. package/dist/types/src/theme/components/icon.d.ts.map +1 -0
  49. package/dist/types/src/{styles → theme}/components/index.d.ts +4 -1
  50. package/dist/types/src/theme/components/index.d.ts.map +1 -0
  51. package/dist/types/src/{styles → theme}/components/input.d.ts +25 -21
  52. package/dist/types/src/theme/components/input.d.ts.map +1 -0
  53. package/dist/types/src/theme/components/link.d.ts.map +1 -0
  54. package/dist/types/src/theme/components/list.d.ts.map +1 -0
  55. package/dist/types/src/{styles → theme}/components/main.d.ts +2 -7
  56. package/dist/types/src/theme/components/main.d.ts.map +1 -0
  57. package/dist/types/src/{styles → theme}/components/menu.d.ts +1 -1
  58. package/dist/types/src/theme/components/menu.d.ts.map +1 -0
  59. package/dist/types/src/{styles → theme}/components/message.d.ts +1 -0
  60. package/dist/types/src/theme/components/message.d.ts.map +1 -0
  61. package/dist/types/src/{styles → theme}/components/popover.d.ts +1 -1
  62. package/dist/types/src/theme/components/popover.d.ts.map +1 -0
  63. package/dist/types/src/theme/components/scroll-area.d.ts +32 -0
  64. package/dist/types/src/theme/components/scroll-area.d.ts.map +1 -0
  65. package/dist/types/src/theme/components/select.d.ts.map +1 -0
  66. package/dist/types/src/theme/components/separator.d.ts.map +1 -0
  67. package/dist/types/src/theme/components/skeleton.d.ts +7 -0
  68. package/dist/types/src/theme/components/skeleton.d.ts.map +1 -0
  69. package/dist/types/src/theme/components/splitter.d.ts +4 -0
  70. package/dist/types/src/theme/components/splitter.d.ts.map +1 -0
  71. package/dist/types/src/{styles → theme}/components/status.d.ts +1 -1
  72. package/dist/types/src/theme/components/status.d.ts.map +1 -0
  73. package/dist/types/src/theme/components/tag.d.ts.map +1 -0
  74. package/dist/types/src/theme/components/toast.d.ts.map +1 -0
  75. package/dist/types/src/theme/components/toolbar.d.ts +11 -0
  76. package/dist/types/src/theme/components/toolbar.d.ts.map +1 -0
  77. package/dist/types/src/theme/components/tooltip.d.ts.map +1 -0
  78. package/dist/types/src/theme/components/treegrid.d.ts.map +1 -0
  79. package/dist/types/src/theme/index.d.ts +4 -0
  80. package/dist/types/src/theme/index.d.ts.map +1 -0
  81. package/dist/types/src/theme/primitives/column.d.ts +29 -0
  82. package/dist/types/src/theme/primitives/column.d.ts.map +1 -0
  83. package/dist/types/src/theme/primitives/index.d.ts +3 -0
  84. package/dist/types/src/theme/primitives/index.d.ts.map +1 -0
  85. package/dist/types/src/theme/primitives/panel.d.ts +13 -0
  86. package/dist/types/src/theme/primitives/panel.d.ts.map +1 -0
  87. package/dist/types/src/theme/theme.d.ts +5 -0
  88. package/dist/types/src/theme/theme.d.ts.map +1 -0
  89. package/dist/types/src/{styles/fragments → util}/elevation.d.ts +0 -6
  90. package/dist/types/src/util/elevation.d.ts.map +1 -0
  91. package/dist/types/src/util/hash-styles.d.ts +8 -5
  92. package/dist/types/src/util/hash-styles.d.ts.map +1 -1
  93. package/dist/types/src/util/index.d.ts +3 -0
  94. package/dist/types/src/util/index.d.ts.map +1 -1
  95. package/dist/types/src/util/mx.d.ts +36 -0
  96. package/dist/types/src/util/mx.d.ts.map +1 -1
  97. package/dist/types/src/util/size.d.ts +27 -0
  98. package/dist/types/src/util/size.d.ts.map +1 -0
  99. package/dist/types/src/util/valence.d.ts +4 -0
  100. package/dist/types/src/util/valence.d.ts.map +1 -0
  101. package/dist/types/tsconfig.tsbuildinfo +1 -1
  102. package/package.json +24 -27
  103. package/src/Theme.stories.tsx +224 -0
  104. package/src/css/base/base.css +43 -0
  105. package/src/{styles/layers → css/base}/typography.css +3 -5
  106. package/src/{styles/layers → css/components}/button.css +23 -14
  107. package/src/{styles/layers → css/components}/checkbox.css +12 -8
  108. package/src/{styles/layers → css/components}/dialog.css +16 -15
  109. package/src/{styles/layers/focus-ring.css → css/components/focus.css} +60 -41
  110. package/src/css/components/icon.css +9 -0
  111. package/src/css/components/link.css +9 -0
  112. package/src/css/components/panel.css +117 -0
  113. package/src/css/components/scrollbar.css +24 -0
  114. package/src/css/components/selected.css +30 -0
  115. package/src/css/components/surface.css +34 -0
  116. package/src/css/components/tag.css +130 -0
  117. package/src/css/components/text.css +124 -0
  118. package/src/css/integrations/codemirror.css +34 -0
  119. package/src/css/integrations/tldraw.css +14 -0
  120. package/src/css/layout/main.css +205 -0
  121. package/src/{styles/layers → css/layout}/native.css +6 -4
  122. package/src/css/layout/positioning.css +19 -0
  123. package/src/{styles/layers → css/layout}/size.css +117 -109
  124. package/src/css/theme/animation.css +229 -0
  125. package/src/css/theme/border.css +23 -0
  126. package/src/css/theme/palette.css +36 -0
  127. package/src/css/theme/semantic.css +116 -0
  128. package/src/css/theme/spacing.css +147 -0
  129. package/src/css/theme/styles.css +145 -0
  130. package/src/css/theme/text.css +37 -0
  131. package/src/css/utilities.css +76 -0
  132. package/src/defs.ts +48 -0
  133. package/src/fragments/AUDIT.md +57 -0
  134. package/src/fragments/density.ts +16 -0
  135. package/src/fragments/hover.ts +18 -0
  136. package/src/fragments/index.ts +10 -0
  137. package/src/fragments/text.ts +6 -0
  138. package/src/index.ts +3 -14
  139. package/src/main.css +87 -0
  140. package/src/plugins/ThemePlugin.ts +125 -0
  141. package/src/plugins/dark-mode.ts +22 -0
  142. package/src/plugins/main.css +45 -0
  143. package/src/{styles → theme}/components/avatar.ts +12 -13
  144. package/src/theme/components/button.ts +48 -0
  145. package/src/theme/components/card.ts +102 -0
  146. package/src/{styles → theme}/components/dialog.ts +19 -10
  147. package/src/theme/components/focus.ts +33 -0
  148. package/src/{styles → theme}/components/icon-button.ts +1 -3
  149. package/src/theme/components/icon.ts +28 -0
  150. package/src/{styles → theme}/components/index.ts +4 -1
  151. package/src/theme/components/input.ts +171 -0
  152. package/src/{styles → theme}/components/link.ts +3 -4
  153. package/src/{styles → theme}/components/list.ts +5 -5
  154. package/src/{styles → theme}/components/main.ts +2 -6
  155. package/src/{styles → theme}/components/menu.ts +11 -21
  156. package/src/{styles → theme}/components/message.ts +11 -7
  157. package/src/{styles → theme}/components/popover.ts +13 -12
  158. package/src/theme/components/scroll-area.ts +115 -0
  159. package/src/{styles → theme}/components/select.ts +8 -16
  160. package/src/{styles → theme}/components/separator.ts +3 -3
  161. package/src/theme/components/skeleton.ts +23 -0
  162. package/src/theme/components/splitter.ts +20 -0
  163. package/src/{styles → theme}/components/status.ts +7 -7
  164. package/src/{styles → theme}/components/tag.ts +1 -1
  165. package/src/{styles → theme}/components/toast.ts +6 -8
  166. package/src/theme/components/toolbar.ts +35 -0
  167. package/src/{styles → theme}/components/tooltip.ts +4 -6
  168. package/src/{styles → theme}/components/treegrid.ts +9 -9
  169. package/src/{styles → theme}/index.ts +2 -2
  170. package/src/theme/primitives/column.ts +71 -0
  171. package/src/theme/primitives/index.ts +6 -0
  172. package/src/theme/primitives/panel.ts +43 -0
  173. package/src/{styles → theme}/theme.ts +27 -9
  174. package/src/typings.d.ts +3 -1
  175. package/src/{styles/fragments → util}/elevation.ts +6 -8
  176. package/src/util/hash-styles.ts +118 -98
  177. package/src/util/index.ts +3 -0
  178. package/src/util/mx.ts +165 -43
  179. package/src/util/size.ts +103 -0
  180. package/src/util/valence.ts +33 -0
  181. package/dist/plugin/node-cjs/chunk-UUMDOU7E.cjs +0 -79
  182. package/dist/plugin/node-cjs/chunk-UUMDOU7E.cjs.map +0 -7
  183. package/dist/plugin/node-cjs/chunk-ZVALPM6U.cjs +0 -1619
  184. package/dist/plugin/node-cjs/chunk-ZVALPM6U.cjs.map +0 -7
  185. package/dist/plugin/node-cjs/config/tailwind.cjs +0 -29
  186. package/dist/plugin/node-cjs/config/tailwind.cjs.map +0 -7
  187. package/dist/plugin/node-cjs/plugins/esbuild-plugin.cjs +0 -90
  188. package/dist/plugin/node-cjs/plugins/esbuild-plugin.cjs.map +0 -7
  189. package/dist/plugin/node-cjs/plugins/plugin.cjs +0 -124
  190. package/dist/plugin/node-cjs/plugins/plugin.cjs.map +0 -7
  191. package/dist/plugin/node-cjs/theme.css +0 -1418
  192. package/dist/plugin/node-cjs/theme.css.map +0 -7
  193. package/dist/plugin/node-esm/chunk-AFRHJHP4.mjs +0 -49
  194. package/dist/plugin/node-esm/chunk-AFRHJHP4.mjs.map +0 -7
  195. package/dist/plugin/node-esm/chunk-HJE6EZWE.mjs +0 -1614
  196. package/dist/plugin/node-esm/chunk-HJE6EZWE.mjs.map +0 -7
  197. package/dist/plugin/node-esm/config/tailwind.mjs +0 -8
  198. package/dist/plugin/node-esm/config/tailwind.mjs.map +0 -7
  199. package/dist/plugin/node-esm/plugins/esbuild-plugin.mjs +0 -63
  200. package/dist/plugin/node-esm/plugins/esbuild-plugin.mjs.map +0 -7
  201. package/dist/plugin/node-esm/plugins/plugin.mjs +0 -98
  202. package/dist/plugin/node-esm/plugins/plugin.mjs.map +0 -7
  203. package/dist/plugin/node-esm/theme.css +0 -1418
  204. package/dist/plugin/node-esm/theme.css.map +0 -7
  205. package/dist/types/src/Tokens.stories.d.ts +0 -10
  206. package/dist/types/src/Tokens.stories.d.ts.map +0 -1
  207. package/dist/types/src/config/index.d.ts +0 -3
  208. package/dist/types/src/config/index.d.ts.map +0 -1
  209. package/dist/types/src/config/tailwind.d.ts +0 -9
  210. package/dist/types/src/config/tailwind.d.ts.map +0 -1
  211. package/dist/types/src/config/tokens/alias-colors.d.ts +0 -21
  212. package/dist/types/src/config/tokens/alias-colors.d.ts.map +0 -1
  213. package/dist/types/src/config/tokens/index.d.ts +0 -486
  214. package/dist/types/src/config/tokens/index.d.ts.map +0 -1
  215. package/dist/types/src/config/tokens/lengths.d.ts +0 -139
  216. package/dist/types/src/config/tokens/lengths.d.ts.map +0 -1
  217. package/dist/types/src/config/tokens/physical-colors.d.ts +0 -23
  218. package/dist/types/src/config/tokens/physical-colors.d.ts.map +0 -1
  219. package/dist/types/src/config/tokens/semantic-colors.d.ts +0 -187
  220. package/dist/types/src/config/tokens/semantic-colors.d.ts.map +0 -1
  221. package/dist/types/src/config/tokens/sememes-calls.d.ts +0 -3
  222. package/dist/types/src/config/tokens/sememes-calls.d.ts.map +0 -1
  223. package/dist/types/src/config/tokens/sememes-codemirror.d.ts +0 -43
  224. package/dist/types/src/config/tokens/sememes-codemirror.d.ts.map +0 -1
  225. package/dist/types/src/config/tokens/sememes-hue.d.ts +0 -4
  226. package/dist/types/src/config/tokens/sememes-hue.d.ts.map +0 -1
  227. package/dist/types/src/config/tokens/sememes-sheet.d.ts +0 -58
  228. package/dist/types/src/config/tokens/sememes-sheet.d.ts.map +0 -1
  229. package/dist/types/src/config/tokens/sememes-system.d.ts +0 -99
  230. package/dist/types/src/config/tokens/sememes-system.d.ts.map +0 -1
  231. package/dist/types/src/config/tokens/sizes.d.ts +0 -7
  232. package/dist/types/src/config/tokens/sizes.d.ts.map +0 -1
  233. package/dist/types/src/config/tokens/types.d.ts +0 -5
  234. package/dist/types/src/config/tokens/types.d.ts.map +0 -1
  235. package/dist/types/src/plugins/esbuild-plugin.d.ts +0 -9
  236. package/dist/types/src/plugins/esbuild-plugin.d.ts.map +0 -1
  237. package/dist/types/src/plugins/plugin.d.ts +0 -20
  238. package/dist/types/src/plugins/plugin.d.ts.map +0 -1
  239. package/dist/types/src/plugins/resolveContent.d.ts +0 -2
  240. package/dist/types/src/plugins/resolveContent.d.ts.map +0 -1
  241. package/dist/types/src/styles/components/anchored-overflow.d.ts +0 -6
  242. package/dist/types/src/styles/components/anchored-overflow.d.ts.map +0 -1
  243. package/dist/types/src/styles/components/avatar.d.ts.map +0 -1
  244. package/dist/types/src/styles/components/breadcrumb.d.ts.map +0 -1
  245. package/dist/types/src/styles/components/button.d.ts +0 -19
  246. package/dist/types/src/styles/components/button.d.ts.map +0 -1
  247. package/dist/types/src/styles/components/dialog.d.ts.map +0 -1
  248. package/dist/types/src/styles/components/icon-button.d.ts.map +0 -1
  249. package/dist/types/src/styles/components/icon.d.ts.map +0 -1
  250. package/dist/types/src/styles/components/index.d.ts.map +0 -1
  251. package/dist/types/src/styles/components/input.d.ts.map +0 -1
  252. package/dist/types/src/styles/components/link.d.ts.map +0 -1
  253. package/dist/types/src/styles/components/list.d.ts.map +0 -1
  254. package/dist/types/src/styles/components/main.d.ts.map +0 -1
  255. package/dist/types/src/styles/components/menu.d.ts.map +0 -1
  256. package/dist/types/src/styles/components/message.d.ts.map +0 -1
  257. package/dist/types/src/styles/components/popover.d.ts.map +0 -1
  258. package/dist/types/src/styles/components/scroll-area.d.ts +0 -9
  259. package/dist/types/src/styles/components/scroll-area.d.ts.map +0 -1
  260. package/dist/types/src/styles/components/select.d.ts.map +0 -1
  261. package/dist/types/src/styles/components/separator.d.ts.map +0 -1
  262. package/dist/types/src/styles/components/status.d.ts.map +0 -1
  263. package/dist/types/src/styles/components/tag.d.ts.map +0 -1
  264. package/dist/types/src/styles/components/toast.d.ts.map +0 -1
  265. package/dist/types/src/styles/components/toolbar.d.ts +0 -11
  266. package/dist/types/src/styles/components/toolbar.d.ts.map +0 -1
  267. package/dist/types/src/styles/components/tooltip.d.ts.map +0 -1
  268. package/dist/types/src/styles/components/treegrid.d.ts.map +0 -1
  269. package/dist/types/src/styles/fragments/density.d.ts +0 -13
  270. package/dist/types/src/styles/fragments/density.d.ts.map +0 -1
  271. package/dist/types/src/styles/fragments/dimension.d.ts +0 -5
  272. package/dist/types/src/styles/fragments/dimension.d.ts.map +0 -1
  273. package/dist/types/src/styles/fragments/disabled.d.ts.map +0 -1
  274. package/dist/types/src/styles/fragments/elevation.d.ts.map +0 -1
  275. package/dist/types/src/styles/fragments/focus.d.ts +0 -6
  276. package/dist/types/src/styles/fragments/focus.d.ts.map +0 -1
  277. package/dist/types/src/styles/fragments/group.d.ts +0 -5
  278. package/dist/types/src/styles/fragments/group.d.ts.map +0 -1
  279. package/dist/types/src/styles/fragments/hover.d.ts +0 -17
  280. package/dist/types/src/styles/fragments/hover.d.ts.map +0 -1
  281. package/dist/types/src/styles/fragments/index.d.ts +0 -17
  282. package/dist/types/src/styles/fragments/index.d.ts.map +0 -1
  283. package/dist/types/src/styles/fragments/layout.d.ts +0 -3
  284. package/dist/types/src/styles/fragments/layout.d.ts.map +0 -1
  285. package/dist/types/src/styles/fragments/motion.d.ts +0 -2
  286. package/dist/types/src/styles/fragments/motion.d.ts.map +0 -1
  287. package/dist/types/src/styles/fragments/ornament.d.ts +0 -5
  288. package/dist/types/src/styles/fragments/ornament.d.ts.map +0 -1
  289. package/dist/types/src/styles/fragments/selected.d.ts +0 -13
  290. package/dist/types/src/styles/fragments/selected.d.ts.map +0 -1
  291. package/dist/types/src/styles/fragments/shimmer.d.ts +0 -3
  292. package/dist/types/src/styles/fragments/shimmer.d.ts.map +0 -1
  293. package/dist/types/src/styles/fragments/size.d.ts +0 -9
  294. package/dist/types/src/styles/fragments/size.d.ts.map +0 -1
  295. package/dist/types/src/styles/fragments/surface.d.ts +0 -9
  296. package/dist/types/src/styles/fragments/surface.d.ts.map +0 -1
  297. package/dist/types/src/styles/fragments/text.d.ts +0 -7
  298. package/dist/types/src/styles/fragments/text.d.ts.map +0 -1
  299. package/dist/types/src/styles/fragments/valence.d.ts +0 -13
  300. package/dist/types/src/styles/fragments/valence.d.ts.map +0 -1
  301. package/dist/types/src/styles/index.d.ts +0 -4
  302. package/dist/types/src/styles/index.d.ts.map +0 -1
  303. package/dist/types/src/styles/theme.d.ts +0 -5
  304. package/dist/types/src/styles/theme.d.ts.map +0 -1
  305. package/dist/types/src/tailwind.d.ts +0 -3
  306. package/dist/types/src/tailwind.d.ts.map +0 -1
  307. package/dist/types/src/types.d.ts +0 -3
  308. package/dist/types/src/types.d.ts.map +0 -1
  309. package/dist/types/src/util/withLogical.d.ts +0 -164
  310. package/dist/types/src/util/withLogical.d.ts.map +0 -1
  311. package/src/Tokens.stories.tsx +0 -88
  312. package/src/config/index.ts +0 -6
  313. package/src/config/tailwind.ts +0 -264
  314. package/src/config/tokens/alias-colors.ts +0 -39
  315. package/src/config/tokens/index.ts +0 -92
  316. package/src/config/tokens/lengths.ts +0 -97
  317. package/src/config/tokens/physical-colors.ts +0 -125
  318. package/src/config/tokens/semantic-colors.ts +0 -27
  319. package/src/config/tokens/sememes-calls.ts +0 -17
  320. package/src/config/tokens/sememes-codemirror.ts +0 -50
  321. package/src/config/tokens/sememes-hue.ts +0 -54
  322. package/src/config/tokens/sememes-sheet.ts +0 -62
  323. package/src/config/tokens/sememes-system.ts +0 -302
  324. package/src/config/tokens/sizes.ts +0 -10
  325. package/src/config/tokens/types.ts +0 -9
  326. package/src/docs/theme.drawio.svg +0 -635
  327. package/src/plugins/esbuild-plugin.ts +0 -65
  328. package/src/plugins/plugin.ts +0 -130
  329. package/src/plugins/resolveContent.ts +0 -51
  330. package/src/styles/components/README.md +0 -6
  331. package/src/styles/components/anchored-overflow.ts +0 -20
  332. package/src/styles/components/button.ts +0 -48
  333. package/src/styles/components/icon.ts +0 -19
  334. package/src/styles/components/input.ts +0 -177
  335. package/src/styles/components/scroll-area.ts +0 -43
  336. package/src/styles/components/toolbar.ts +0 -29
  337. package/src/styles/fragments/density.ts +0 -17
  338. package/src/styles/fragments/dimension.ts +0 -8
  339. package/src/styles/fragments/focus.ts +0 -16
  340. package/src/styles/fragments/group.ts +0 -12
  341. package/src/styles/fragments/hover.ts +0 -25
  342. package/src/styles/fragments/index.ts +0 -20
  343. package/src/styles/fragments/layout.ts +0 -7
  344. package/src/styles/fragments/motion.ts +0 -6
  345. package/src/styles/fragments/ornament.ts +0 -10
  346. package/src/styles/fragments/selected.ts +0 -45
  347. package/src/styles/fragments/shimmer.ts +0 -9
  348. package/src/styles/fragments/size.ts +0 -117
  349. package/src/styles/fragments/surface.ts +0 -29
  350. package/src/styles/fragments/text.ts +0 -12
  351. package/src/styles/fragments/valence.ts +0 -46
  352. package/src/styles/layers/README.md +0 -15
  353. package/src/styles/layers/anchored-overflow.css +0 -9
  354. package/src/styles/layers/animation.css +0 -17
  355. package/src/styles/layers/attention.css +0 -8
  356. package/src/styles/layers/base.css +0 -25
  357. package/src/styles/layers/can-scroll.css +0 -26
  358. package/src/styles/layers/drag-preview.css +0 -18
  359. package/src/styles/layers/hues.css +0 -110
  360. package/src/styles/layers/index.css +0 -26
  361. package/src/styles/layers/main.css +0 -227
  362. package/src/styles/layers/positioning.css +0 -23
  363. package/src/styles/layers/surfaces.css +0 -31
  364. package/src/styles/layers/tag.css +0 -132
  365. package/src/styles/layers/tldraw.css +0 -91
  366. package/src/styles/layers/tokens.css +0 -46
  367. package/src/tailwind.ts +0 -7
  368. package/src/theme.css +0 -9
  369. package/src/types.ts +0 -7
  370. package/src/util/withLogical.ts +0 -114
  371. /package/dist/types/src/{styles/fragments → fragments}/disabled.d.ts +0 -0
  372. /package/dist/types/src/{styles → theme}/components/avatar.d.ts +0 -0
  373. /package/dist/types/src/{styles → theme}/components/breadcrumb.d.ts +0 -0
  374. /package/dist/types/src/{styles → theme}/components/icon-button.d.ts +0 -0
  375. /package/dist/types/src/{styles → theme}/components/link.d.ts +0 -0
  376. /package/dist/types/src/{styles → theme}/components/list.d.ts +0 -0
  377. /package/dist/types/src/{styles → theme}/components/select.d.ts +0 -0
  378. /package/dist/types/src/{styles → theme}/components/separator.d.ts +0 -0
  379. /package/dist/types/src/{styles → theme}/components/tag.d.ts +0 -0
  380. /package/dist/types/src/{styles → theme}/components/toast.d.ts +0 -0
  381. /package/dist/types/src/{styles → theme}/components/tooltip.d.ts +0 -0
  382. /package/dist/types/src/{styles → theme}/components/treegrid.d.ts +0 -0
  383. /package/src/{styles/fragments → fragments}/disabled.ts +0 -0
  384. /package/src/{styles → theme}/components/breadcrumb.ts +0 -0
@@ -2,15 +2,16 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type ComponentFunction, type Theme } from '@dxos/ui-types';
6
- import { get } from '@dxos/util';
5
+ import { type ClassNameArray, type ComponentFunction, type Theme, type ThemeFunction } from '@dxos/ui-types';
6
+ import { getDeep } from '@dxos/util';
7
7
 
8
8
  import {
9
- anchoredOverflowTheme,
10
9
  avatarTheme,
11
10
  breadcrumbTheme,
12
11
  buttonTheme,
12
+ cardTheme,
13
13
  dialogTheme,
14
+ focusTheme,
14
15
  iconButtonTheme,
15
16
  iconTheme,
16
17
  inputTheme,
@@ -23,6 +24,8 @@ import {
23
24
  scrollAreaTheme,
24
25
  selectTheme,
25
26
  separatorTheme,
27
+ skeletonTheme,
28
+ splitterTheme,
26
29
  statusTheme,
27
30
  tagTheme,
28
31
  toastTheme,
@@ -30,15 +33,28 @@ import {
30
33
  tooltipTheme,
31
34
  treegridTheme,
32
35
  } from './components';
36
+ import { columnTheme, panelTheme } from './primitives';
33
37
 
34
38
  export const defaultTheme: Theme<Record<string, any>> = {
35
39
  themeName: () => 'default',
36
40
 
37
- anchoredOverflow: anchoredOverflowTheme,
41
+ //
42
+ // Primitives
43
+ //
44
+
45
+ column: columnTheme,
46
+ panel: panelTheme,
47
+
48
+ //
49
+ // Components
50
+ //
51
+
38
52
  avatar: avatarTheme,
39
53
  breadcrumb: breadcrumbTheme,
40
54
  button: buttonTheme,
55
+ card: cardTheme,
41
56
  dialog: dialogTheme,
57
+ focus: focusTheme,
42
58
  icon: iconTheme,
43
59
  iconButton: iconButtonTheme,
44
60
  input: inputTheme,
@@ -48,9 +64,11 @@ export const defaultTheme: Theme<Record<string, any>> = {
48
64
  message: messageTheme,
49
65
  menu: menuTheme,
50
66
  popover: popoverTheme,
51
- select: selectTheme,
52
67
  scrollArea: scrollAreaTheme,
68
+ select: selectTheme,
53
69
  separator: separatorTheme,
70
+ skeleton: skeletonTheme,
71
+ splitter: splitterTheme,
54
72
  status: statusTheme,
55
73
  tag: tagTheme,
56
74
  toast: toastTheme,
@@ -59,10 +77,10 @@ export const defaultTheme: Theme<Record<string, any>> = {
59
77
  treegrid: treegridTheme,
60
78
  };
61
79
 
62
- export const bindTheme = <P extends Record<string, any>>(theme: Theme<Record<string, any>>) => {
63
- return (path: string, defaultClassName: string, styleProps: P, ...options: any[]): string => {
64
- const result: Theme<P> | ComponentFunction<P> = get(theme, path);
65
- return typeof result === 'function' ? result(styleProps, ...options) : defaultClassName;
80
+ export const bindTheme = <P extends Record<string, any>>(theme: Theme<Record<string, any>>): ThemeFunction<P> => {
81
+ return (path: string, styleProps?: P, ...etc: ClassNameArray) => {
82
+ const result = getDeep<Theme<P> | ComponentFunction<P>>(theme, path.split('.'));
83
+ return typeof result === 'function' ? result(styleProps ?? ({} as P), ...etc) : undefined;
66
84
  };
67
85
  };
68
86
 
package/src/typings.d.ts CHANGED
@@ -5,4 +5,6 @@
5
5
  declare module 'fast-glob';
6
6
  declare module 'tailwindcss/stubs/config.full.js';
7
7
  declare module 'tailwindcss-radix';
8
- declare module 'tailwindcss-logical';
8
+
9
+ /** Virtual CSS entry from ThemePlugin (`virtualFileId: '@dxos-theme'`). */
10
+ declare module '@dxos-theme';
@@ -4,14 +4,12 @@
4
4
 
5
5
  import { type ComponentFragment, type Elevation, type SurfaceLevel } from '@dxos/ui-types';
6
6
 
7
- /**
8
- * @deprecated
9
- */
10
- export const contentShadow: ComponentFragment<{ elevation?: Elevation }> = (_) => ['shadow-none'];
11
-
12
- // TODO(thure): These should become tokens.
13
7
  export const surfaceShadow: ComponentFragment<{ elevation?: Elevation }> = ({ elevation }) => [
14
- elevation === 'positioned' ? 'shadow' : elevation === 'dialog' || elevation === 'toast' ? 'shadow-md' : 'shadow-none',
8
+ elevation === 'positioned'
9
+ ? 'shadow-sm'
10
+ : elevation === 'dialog' || elevation === 'toast'
11
+ ? 'shadow-md'
12
+ : 'shadow-none',
15
13
  ];
16
14
 
17
15
  export const surfaceZIndex: ComponentFragment<{ level?: SurfaceLevel; elevation?: Elevation }> = ({
@@ -20,7 +18,7 @@ export const surfaceZIndex: ComponentFragment<{ level?: SurfaceLevel; elevation?
20
18
  }) => {
21
19
  switch (level) {
22
20
  case 'tooltip':
23
- return elevation === 'dialog' ? ['z-[53]'] : elevation === 'toast' ? ['z-[43]'] : ['z-30'];
21
+ return elevation === 'dialog' ? ['z-[53]'] : elevation === 'toast' ? ['z-[43]'] : ['z-50'];
24
22
  case 'menu':
25
23
  return elevation === 'dialog' ? ['z-[52]'] : elevation === 'toast' ? ['z-[42]'] : ['z-20'];
26
24
  default:
@@ -6,163 +6,183 @@ import { type ChromaticPalette } from '@dxos/ui-types';
6
6
 
7
7
  export type Hue = ChromaticPalette | 'neutral';
8
8
 
9
- // TODO(burdon): Rename?
9
+ // TODO(burdon): Reconcile with ui-theme/theme/roles.css
10
10
  export type ColorStyles = {
11
11
  hue: Hue;
12
- text: string;
13
- icon: string;
14
- bg: string;
15
- surface: string;
16
- border: string;
12
+ fill: string; // -fill
13
+ surface: string; // -surface
14
+ surfaceText: string; // -surface-text
15
+ text: string; // -text
16
+ border: string; // -border
17
17
  };
18
18
 
19
- const neutralColor: ColorStyles = {
19
+ const neutral: ColorStyles = {
20
20
  hue: 'neutral',
21
- text: 'text-neutralFill',
22
- icon: 'text-neutralSurfaceText',
23
- bg: 'bg-neutralFill',
24
- surface: 'bg-neutralSurface',
25
- border: 'border-neutralFill',
21
+ fill: 'bg-neutral-fill',
22
+ surface: 'bg-neutral-surface',
23
+ surfaceText: 'text-neutral-surface-text',
24
+ text: 'text-neutral-text',
25
+ border: 'border-neutral-border',
26
26
  };
27
27
 
28
- // NOTE: Don't include blue/red which are used as system colors.
29
- // NOTE: Cordinated with `tag.css`.
28
+ // NOTE: Coordinated with `tag.css`.
30
29
  // https://github.com/dxos/dxos/blob/main/packages/ui/react-ui-theme/src/styles/layers/tag.css
31
- export const styles: ColorStyles[] = [
30
+ const styles: ColorStyles[] = [
31
+ {
32
+ hue: 'red',
33
+ fill: 'bg-red-fill',
34
+ surface: 'bg-red-surface',
35
+ surfaceText: 'text-red-surface-text',
36
+ text: 'text-red-text',
37
+ border: 'border-red-border',
38
+ },
32
39
  {
33
40
  hue: 'orange',
34
- text: 'text-orangeFill',
35
- icon: 'text-orangeSurfaceText',
36
- bg: 'bg-orangeFill',
37
- surface: 'bg-orangeSurface',
38
- border: 'border-orangeFill',
41
+ fill: 'bg-orange-fill',
42
+ surface: 'bg-orange-surface',
43
+ surfaceText: 'text-orange-surface-text',
44
+ text: 'text-orange-text',
45
+ border: 'border-orange-border',
39
46
  },
40
47
  {
41
48
  hue: 'amber',
42
- text: 'text-amberFill',
43
- icon: 'text-amberSurfaceText',
44
- bg: 'bg-amberFill',
45
- surface: 'bg-amberSurface',
46
- border: 'border-amberFill',
49
+ fill: 'bg-amber-fill',
50
+ surface: 'bg-amber-surface',
51
+ surfaceText: 'text-amber-surface-text',
52
+ text: 'text-amber-text',
53
+ border: 'border-amber-border',
47
54
  },
48
55
  {
49
56
  hue: 'yellow',
50
- text: 'text-yellowFill',
51
- icon: 'text-yellowSurfaceText',
52
- bg: 'bg-yellowFill',
53
- surface: 'bg-yellowSurface',
54
- border: 'border-yellowFill',
57
+ fill: 'bg-yellow-fill',
58
+ surface: 'bg-yellow-surface',
59
+ surfaceText: 'text-yellow-surface-text',
60
+ text: 'text-yellow-text',
61
+ border: 'border-yellow-border',
55
62
  },
56
63
  {
57
64
  hue: 'lime',
58
- text: 'text-limeFill',
59
- icon: 'text-limeSurfaceText',
60
- bg: 'bg-limeFill',
61
- surface: 'bg-limeSurface',
62
- border: 'border-limeFill',
65
+ fill: 'bg-lime-fill',
66
+ surface: 'bg-lime-surface',
67
+ surfaceText: 'text-lime-surface-text',
68
+ text: 'text-lime-text',
69
+ border: 'border-lime-border',
63
70
  },
64
71
  {
65
72
  hue: 'green',
66
- text: 'text-greenFill',
67
- icon: 'text-greenSurfaceText',
68
- bg: 'bg-greenFill',
69
- surface: 'bg-greenSurface',
70
- border: 'border-greenFill',
73
+ fill: 'bg-green-fill',
74
+ surface: 'bg-green-surface',
75
+ surfaceText: 'text-green-surface-text',
76
+ text: 'text-green-text',
77
+ border: 'border-green-border',
71
78
  },
72
79
  {
73
80
  hue: 'emerald',
74
- text: 'text-emeraldFill',
75
- icon: 'text-emeraldSurfaceText',
76
- bg: 'bg-emeraldFill',
77
- surface: 'bg-emeraldSurface',
78
- border: 'border-emeraldFill',
81
+ fill: 'bg-emerald-fill',
82
+ surface: 'bg-emerald-surface',
83
+ surfaceText: 'text-emerald-surface-text',
84
+ text: 'text-emerald-text',
85
+ border: 'border-emerald-border',
79
86
  },
80
87
  {
81
88
  hue: 'teal',
82
- text: 'text-tealFill',
83
- icon: 'text-tealSurfaceText',
84
- bg: 'bg-tealFill',
85
- surface: 'bg-tealSurface',
86
- border: 'border-tealFill',
89
+ fill: 'bg-teal-fill',
90
+ surface: 'bg-teal-surface',
91
+ surfaceText: 'text-teal-surface-text',
92
+ text: 'text-teal-text',
93
+ border: 'border-teal-border',
87
94
  },
88
95
  {
89
96
  hue: 'cyan',
90
- text: 'text-cyanFill',
91
- icon: 'text-cyanSurfaceText',
92
- bg: 'bg-cyanFill',
93
- surface: 'bg-cyanSurface',
94
- border: 'border-cyanFill',
97
+ fill: 'bg-cyan-fill',
98
+ surface: 'bg-cyan-surface',
99
+ surfaceText: 'text-cyan-surface-text',
100
+ text: 'text-cyan-text',
101
+ border: 'border-cyan-border',
95
102
  },
96
103
  {
97
104
  hue: 'sky',
98
- text: 'text-skyFill',
99
- icon: 'text-skySurfaceText',
100
- bg: 'bg-skyFill',
101
- surface: 'bg-skySurface',
102
- border: 'border-skyFill',
105
+ fill: 'bg-sky-fill',
106
+ surface: 'bg-sky-surface',
107
+ surfaceText: 'text-sky-surface-text',
108
+ text: 'text-sky-text',
109
+ border: 'border-sky-border',
110
+ },
111
+ {
112
+ hue: 'blue',
113
+ fill: 'bg-blue-fill',
114
+ surface: 'bg-blue-surface',
115
+ surfaceText: 'text-blue-surface-text',
116
+ text: 'text-blue-text',
117
+ border: 'border-blue-border',
103
118
  },
104
119
  {
105
120
  hue: 'indigo',
106
- text: 'text-indigoFill',
107
- icon: 'text-indigoSurfaceText',
108
- bg: 'bg-indigoFill',
109
- surface: 'bg-indigoSurface',
110
- border: 'border-indigoFill',
121
+ fill: 'bg-indigo-fill',
122
+ surface: 'bg-indigo-surface',
123
+ surfaceText: 'text-indigo-surface-text',
124
+ text: 'text-indigo-text',
125
+ border: 'border-indigo-border',
111
126
  },
112
127
  {
113
128
  hue: 'violet',
114
- text: 'text-violetFill',
115
- icon: 'text-violetSurfaceText',
116
- bg: 'bg-violetFill',
117
- surface: 'bg-violetSurface',
118
- border: 'border-violetFill',
129
+ fill: 'bg-violet-fill',
130
+ surface: 'bg-violet-surface',
131
+ surfaceText: 'text-violet-surface-text',
132
+ text: 'text-violet-text',
133
+ border: 'border-violet-border',
119
134
  },
120
135
  {
121
136
  hue: 'purple',
122
- text: 'text-purpleFill',
123
- icon: 'text-purpleSurfaceText',
124
- bg: 'bg-purpleFill',
125
- surface: 'bg-purpleSurface',
126
- border: 'border-purpleFill',
137
+ fill: 'bg-purple-fill',
138
+ surface: 'bg-purple-surface',
139
+ surfaceText: 'text-purple-surface-text',
140
+ text: 'text-purple-text',
141
+ border: 'border-purple-border',
127
142
  },
128
143
  {
129
144
  hue: 'fuchsia',
130
- text: 'text-fuchsiaFill',
131
- icon: 'text-fuchsiaSurfaceText',
132
- bg: 'bg-fuchsiaFill',
133
- surface: 'bg-fuchsiaSurface',
134
- border: 'border-fuchsiaFill',
145
+ fill: 'bg-fuchsia-fill',
146
+ surface: 'bg-fuchsia-surface',
147
+ surfaceText: 'text-fuchsia-surface-text',
148
+ text: 'text-fuchsia-text',
149
+ border: 'border-fuchsia-border',
135
150
  },
136
151
  {
137
- hue: 'rose',
138
- text: 'text-roseFill',
139
- icon: 'text-roseSurfaceText',
140
- bg: 'bg-roseFill',
141
- surface: 'bg-roseSurface',
142
- border: 'border-roseFill',
152
+ hue: 'pink',
153
+ fill: 'bg-pink-fill',
154
+ surface: 'bg-pink-surface',
155
+ surfaceText: 'text-pink-surface-text',
156
+ text: 'text-pink-text',
157
+ border: 'border-pink-border',
143
158
  },
144
159
  {
145
- hue: 'pink',
146
- text: 'text-pinkFill',
147
- icon: 'text-pinkSurfaceText',
148
- bg: 'bg-pinkFill',
149
- surface: 'bg-pinkSurface',
150
- border: 'border-pinkFill',
160
+ hue: 'rose',
161
+ fill: 'bg-rose-fill',
162
+ surface: 'bg-rose-surface',
163
+ surfaceText: 'text-rose-surface-text',
164
+ text: 'text-rose-text',
165
+ border: 'border-rose-border',
151
166
  },
152
167
  ];
153
168
 
154
- export const getStyles = (hue: string): ColorStyles => {
155
- return styles.find((color) => color.hue === hue) || neutralColor;
169
+ export const palette = {
170
+ neutral,
171
+ hues: styles,
156
172
  };
157
173
 
158
- export const getHashHue = (id: string | undefined): Hue => {
159
- return id ? styles[getHash(id) % styles.length].hue : 'neutral';
174
+ // TODO(burdon): Rename getClassNames.
175
+ export const getStyles = (hue: string): ColorStyles => {
176
+ return styles.find((color) => color.hue === hue) || neutral;
160
177
  };
161
178
 
162
179
  // TODO(thure): Reconcile with `to-fallback.ts` which exports `toHue` which overlaps a lot.
163
180
  export const getHashStyles = (id: string | undefined): ColorStyles => {
164
- const hue = getHashHue(id);
165
- return getStyles(hue);
181
+ return getStyles(getHashHue(id));
182
+ };
183
+
184
+ export const getHashHue = (id: string | undefined): Hue => {
185
+ return id ? styles[getHash(id) % styles.length].hue : 'neutral';
166
186
  };
167
187
 
168
188
  const getHash = (id: string): number => id.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);
package/src/util/index.ts CHANGED
@@ -2,5 +2,8 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
+ export * from './elevation';
5
6
  export * from './hash-styles';
6
7
  export * from './mx';
8
+ export * from './size';
9
+ export * from './valence';
package/src/util/mx.ts CHANGED
@@ -2,50 +2,172 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
+ import {
6
+ Children,
7
+ createElement,
8
+ forwardRef,
9
+ type ForwardRefExoticComponent,
10
+ type ForwardedRef,
11
+ type HTMLAttributes,
12
+ isValidElement,
13
+ type ReactNode,
14
+ type RefAttributes,
15
+ CSSProperties,
16
+ } from 'react';
5
17
  import { extendTailwindMerge, validators } from 'tailwind-merge';
6
18
 
7
- import { type WithLogicalClassGroups, withLogical } from './withLogical';
8
-
9
- type AdditionalClassGroups = 'density' | 'dx-focus-ring' | WithLogicalClassGroups;
10
-
11
- export const mx = extendTailwindMerge<AdditionalClassGroups>(
12
- {
13
- extend: {
14
- classGroups: {
15
- 'font-family': ['font-body', 'font-mono'],
16
- 'font-weight': [
17
- // App weights
18
- 'font-thin',
19
- 'font-extralight',
20
- 'font-light',
21
- 'font-normal',
22
- 'font-medium',
23
- 'font-semibold',
24
- 'font-bold',
25
- 'font-extrabold',
26
- 'font-black',
27
- // Arbitrary numbers
28
- validators.isArbitraryNumber,
29
- ],
30
- density: ['density-fine', 'density-coarse'],
31
- 'dx-focus-ring': [
32
- 'dx-focus-ring',
33
- 'dx-focus-ring-inset',
34
- 'dx-focus-ring-always',
35
- 'dx-focus-ring-inset-always',
36
- 'dx-focus-ring-group',
37
- 'dx-focus-ring-group-x',
38
- 'dx-focus-ring-group-y',
39
- 'dx-focus-ring-group-always',
40
- 'dx-focus-ring-group-x-always',
41
- 'dx-focus-ring-group-y-always',
42
- 'dx-focus-ring-inset-over-all',
43
- 'dx-focus-ring-inset-over-all-always',
44
- 'dx-focus-ring-main',
45
- 'dx-focus-ring-main-always',
46
- ],
47
- },
19
+ import { log } from '@dxos/log';
20
+ import { ThemedClassName, type ComposableProps, type SlottableProps } from '@dxos/ui-types';
21
+
22
+ type AdditionalClassGroups = 'density' | 'dx-focus-ring';
23
+
24
+ export const mx = extendTailwindMerge<AdditionalClassGroups>({
25
+ extend: {
26
+ classGroups: {
27
+ 'font-family': ['font-body', 'font-mono'],
28
+ 'font-weight': [
29
+ // App weights
30
+ 'font-thin',
31
+ 'font-extralight',
32
+ 'font-light',
33
+ 'font-normal',
34
+ 'font-medium',
35
+ 'font-semibold',
36
+ 'font-bold',
37
+ 'font-extrabold',
38
+ 'font-black',
39
+ // Arbitrary numbers
40
+ validators.isArbitraryNumber,
41
+ ],
42
+
43
+ density: ['dx-density-fine', 'dx-density-coarse'],
44
+
45
+ 'dx-focus-ring': [
46
+ 'dx-focus-ring',
47
+ 'dx-focus-ring-inset',
48
+ 'dx-focus-ring-always',
49
+ 'dx-focus-ring-inset-always',
50
+ 'dx-focus-ring-group',
51
+ 'dx-focus-ring-group-x',
52
+ 'dx-focus-ring-group-y',
53
+ 'dx-focus-ring-group-always',
54
+ 'dx-focus-ring-group-x-always',
55
+ 'dx-focus-ring-group-y-always',
56
+ 'dx-focus-ring-inset-over-all',
57
+ 'dx-focus-ring-inset-over-all-always',
58
+ 'dx-focus-ring-main',
59
+ 'dx-focus-ring-main-always',
60
+ ],
48
61
  },
49
62
  },
50
- withLogical,
51
- );
63
+ });
64
+
65
+ /**
66
+ * Reconciles className properties from a parent slot.
67
+ * - `className` is set by the Slot merge mechanism.
68
+ * - `classNames` is the consumer-facing prop for theming overrides.
69
+ * Use `composableProps` to reconcile both into a single `className`.
70
+ */
71
+ // TODO(burdon): Move to react-ui.
72
+ export const composableProps = <P extends HTMLElement = HTMLElement>(
73
+ { className, classNames, role, style, ...props }: ComposableProps,
74
+ { classNames: defaultClassNames, ...defaults }: ThemedClassName<Partial<HTMLAttributes<P>>> | undefined = {},
75
+ ) => ({
76
+ // Default props.
77
+ ...(defaults as object),
78
+
79
+ // Spread supplied props.
80
+ ...props,
81
+
82
+ // Prefer explicit role, then defaults role, then 'none'.
83
+ role: role ?? defaults.role ?? 'none',
84
+
85
+ // Merge styles.
86
+ style: { ...defaults.style, ...style } as CSSProperties,
87
+
88
+ // Compose classnames.
89
+ className: mx(defaultClassNames, className, classNames),
90
+ });
91
+
92
+ /**
93
+ * Factory for slottable components.
94
+ * The implementation receives full `HTMLAttributes<E>` so it can destructure `role`, `style`, etc.
95
+ * Consumers see only `SlottableProps<P>` — a narrow type exposing `classNames`, `className`,
96
+ * `children`, `asChild`, and the custom props `P`.
97
+ *
98
+ * @example
99
+ * ```tsx
100
+ * const MyPanel = slottable<HTMLDivElement, { border?: boolean }>(
101
+ * ({ children, asChild, border, ...props }, forwardedRef) => {
102
+ * const Comp = asChild ? Slot : Primitive.div;
103
+ * return (
104
+ * <Comp {...composableProps(props, { classNames: border && 'border' })} ref={forwardedRef}>
105
+ * {children}
106
+ * </Comp>
107
+ * );
108
+ * },
109
+ * );
110
+ * ```
111
+ */
112
+ /** Symbol used to mark components created by `composable()` or `slottable()`. */
113
+ const COMPOSABLE = Symbol.for('dxos.composable');
114
+
115
+ export function slottable<E extends HTMLElement, P extends object = {}>(
116
+ render: (props: SlottableProps<P> & HTMLAttributes<E>, forwardedRef: ForwardedRef<E>) => ReactNode,
117
+ ): ForwardRefExoticComponent<SlottableProps<P> & RefAttributes<E>> {
118
+ const wrapped = (props: SlottableProps<P> & HTMLAttributes<E>, forwardedRef: ForwardedRef<E>) => {
119
+ let warn = false;
120
+ if (props.asChild) {
121
+ try {
122
+ const child = Children.only(props.children);
123
+ if (isValidElement(child) && typeof child.type !== 'string' && !(child.type as any)[COMPOSABLE]) {
124
+ warn = true;
125
+ log.warn('slot child is not composable; create it with composable() or slottable()', {
126
+ child: (child.type as any).displayName ?? (child.type as any).name,
127
+ });
128
+ }
129
+ } catch {
130
+ // Children.only throws if not exactly one child — Slot handles this.
131
+ }
132
+ }
133
+
134
+ const result = render(props, forwardedRef);
135
+ if (warn) {
136
+ return createElement('div', { role: 'none', className: 'dx-slot-warning' }, result);
137
+ }
138
+
139
+ return result;
140
+ };
141
+
142
+ const component = forwardRef(wrapped as any) as any;
143
+ (component as any)[COMPOSABLE] = true;
144
+ return component;
145
+ }
146
+
147
+ /**
148
+ * Factory for composable (leaf) components.
149
+ * The implementation receives full `HTMLAttributes<E>` so it can destructure `role`, `style`, etc.
150
+ * Consumers see only `ComposableProps<P>` — a narrow type exposing `classNames`, `className`,
151
+ * `children`, and the custom props `P`.
152
+ *
153
+ * For generic components, use `any` for the type parameter inside `composable` and
154
+ * cast the result to restore the generic signature for consumers.
155
+ *
156
+ * @example
157
+ * ```tsx
158
+ * const Leaf = composable<HTMLButtonElement>(({ children, ...props }, forwardedRef) => {
159
+ * return (
160
+ * <button {...composableProps(props, { classNames: 'btn' })} ref={forwardedRef}>
161
+ * {children}
162
+ * </button>
163
+ * );
164
+ * });
165
+ * ```
166
+ */
167
+ export function composable<E extends HTMLElement, P extends object = {}>(
168
+ render: (props: ComposableProps<P> & HTMLAttributes<E>, forwardedRef: ForwardedRef<E>) => ReactNode,
169
+ ): ForwardRefExoticComponent<ComposableProps<P> & RefAttributes<E>> {
170
+ const component = forwardRef(render as any) as any;
171
+ (component as any)[COMPOSABLE] = true;
172
+ return component;
173
+ }