@jcsoftdev/ui 0.2.3 → 0.3.0

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 (375) hide show
  1. package/CHANGELOG.md +288 -7
  2. package/README.md +2 -1
  3. package/bin/ui-theme.mjs +1151 -25
  4. package/dist/ai/attachment/attachment.js +1 -1
  5. package/dist/ai/chat-list/group.js +3 -1
  6. package/dist/ai/conversation/conversation.js +1 -1
  7. package/dist/ai/internal/use-copy.d.ts +1 -5
  8. package/dist/ai/internal/use-copy.js +1 -32
  9. package/dist/ai/markdown/parse.js +59 -17
  10. package/dist/ai/source/source.js +1 -1
  11. package/dist/atoms/avatar/avatar.d.ts +13 -3
  12. package/dist/atoms/avatar/avatar.js +40 -2
  13. package/dist/atoms/avatar/index.d.ts +1 -1
  14. package/dist/atoms/avatar/index.js +3 -1
  15. package/dist/atoms/button/button.d.ts +4 -1
  16. package/dist/atoms/button/button.js +4 -2
  17. package/dist/atoms/checkbox/checkbox.d.ts +8 -3
  18. package/dist/atoms/checkbox/checkbox.js +23 -2
  19. package/dist/atoms/chip/chip.d.ts +9 -3
  20. package/dist/atoms/chip/chip.js +26 -4
  21. package/dist/atoms/chip/index.d.ts +1 -1
  22. package/dist/atoms/chip/index.js +4 -1
  23. package/dist/atoms/status-dot/index.d.ts +1 -1
  24. package/dist/atoms/status-dot/status-dot.d.ts +4 -2
  25. package/dist/atoms/status-dot/status-dot.js +5 -1
  26. package/dist/charts/bar-chart/bar-race-chart.js +1 -0
  27. package/dist/charts/beeswarm-chart/beeswarm-chart.js +1 -1
  28. package/dist/charts/chord-chart/chord-chart.js +13 -5
  29. package/dist/charts/core/cartesian/cartesian-chart.d.ts +1 -1
  30. package/dist/charts/core/cartesian/cartesian-chart.js +48 -11
  31. package/dist/charts/core/cartesian/layout.d.ts +6 -1
  32. package/dist/charts/core/cartesian/layout.js +14 -5
  33. package/dist/charts/core/cartesian/marks.d.ts +2 -2
  34. package/dist/charts/core/cartesian/marks.js +1 -1
  35. package/dist/charts/core/cartesian/types.d.ts +28 -2
  36. package/dist/charts/core/category-explorer.d.ts +2 -2
  37. package/dist/charts/core/category-explorer.js +8 -4
  38. package/dist/charts/core/chart-dock.d.ts +26 -0
  39. package/dist/charts/core/chart-dock.js +45 -0
  40. package/dist/charts/core/chart-frame.d.ts +9 -2
  41. package/dist/charts/core/chart-frame.js +105 -25
  42. package/dist/charts/core/distribution/explorer.d.ts +5 -2
  43. package/dist/charts/core/distribution/explorer.js +12 -5
  44. package/dist/charts/core/distribution/xy-points.js +1 -1
  45. package/dist/charts/core/index.d.ts +3 -0
  46. package/dist/charts/core/index.js +3 -0
  47. package/dist/charts/core/leave-grace.d.ts +11 -0
  48. package/dist/charts/core/leave-grace.js +26 -0
  49. package/dist/charts/core/nearest.d.ts +14 -0
  50. package/dist/charts/core/nearest.js +22 -0
  51. package/dist/charts/core/plot-overlay.js +9 -3
  52. package/dist/charts/core/pointer.test-utils.d.ts +38 -0
  53. package/dist/charts/core/pointer.test-utils.js +123 -0
  54. package/dist/charts/core/tooltip.d.ts +25 -2
  55. package/dist/charts/core/tooltip.js +115 -40
  56. package/dist/charts/core/touch-select.d.ts +20 -0
  57. package/dist/charts/core/touch-select.js +184 -0
  58. package/dist/charts/core/types.d.ts +8 -4
  59. package/dist/charts/core/types.js +5 -0
  60. package/dist/charts/core/use-index-navigation.d.ts +17 -6
  61. package/dist/charts/core/use-index-navigation.js +47 -10
  62. package/dist/charts/donut-chart/donut-chart.d.ts +5 -1
  63. package/dist/charts/donut-chart/donut-chart.js +40 -1
  64. package/dist/charts/donut-chart/slice-labels.d.ts +20 -0
  65. package/dist/charts/donut-chart/slice-labels.js +20 -0
  66. package/dist/charts/dumbbell-chart/dumbbell-chart.js +6 -3
  67. package/dist/charts/fill-gauge-chart/fill-gauge-chart.js +1 -0
  68. package/dist/charts/funnel-chart/funnel-chart.js +2 -1
  69. package/dist/charts/gauge-chart/gauge-chart.js +2 -1
  70. package/dist/charts/heatmap-chart/heatmap-chart.d.ts +4 -1
  71. package/dist/charts/heatmap-chart/heatmap-chart.js +3 -1
  72. package/dist/charts/heatmap-chart/heatmap-grid.d.ts +4 -1
  73. package/dist/charts/heatmap-chart/heatmap-grid.js +3 -1
  74. package/dist/charts/hex-tile-map/hex-tile-map.js +124 -115
  75. package/dist/charts/hierarchy-morph/hierarchy-morph.js +2 -1
  76. package/dist/charts/icicle-chart/icicle-chart.js +7 -9
  77. package/dist/charts/lollipop-chart/lollipop-chart.js +6 -3
  78. package/dist/charts/maps/geo/map-viewport.js +1 -1
  79. package/dist/charts/polar-area-chart/polar-area-chart.js +42 -12
  80. package/dist/charts/progress-units/progress-units.js +1 -0
  81. package/dist/charts/radar-chart/radar-chart.js +1 -1
  82. package/dist/charts/radial-bar-chart/radial-bar-chart.js +2 -1
  83. package/dist/charts/range-area-chart/range-area-chart.js +3 -2
  84. package/dist/charts/sankey-chart/sankey-chart.js +12 -4
  85. package/dist/charts/tree-chart/tree-chart.js +1 -0
  86. package/dist/charts/treemap-chart/treemap-chart.js +2 -7
  87. package/dist/charts/waterfall-chart/waterfall-chart.js +6 -3
  88. package/dist/containers/action-bar/action-bar.d.ts +11 -2
  89. package/dist/containers/action-bar/action-bar.js +4 -1
  90. package/dist/containers/card/card.d.ts +21 -3
  91. package/dist/containers/card/card.js +20 -5
  92. package/dist/containers/grid/grid.d.ts +15 -0
  93. package/dist/containers/grid/grid.js +24 -0
  94. package/dist/containers/grid/index.d.ts +1 -0
  95. package/dist/containers/grid/index.js +4 -0
  96. package/dist/containers/index.d.ts +3 -0
  97. package/dist/containers/index.js +3 -0
  98. package/dist/containers/kpi/kpi.d.ts +13 -2
  99. package/dist/containers/kpi/kpi.js +86 -24
  100. package/dist/containers/kpi-group/index.d.ts +1 -1
  101. package/dist/containers/kpi-group/index.js +3 -1
  102. package/dist/containers/kpi-group/kpi-group.d.ts +9 -1
  103. package/dist/containers/kpi-group/kpi-group.js +11 -1
  104. package/dist/containers/page/index.d.ts +1 -0
  105. package/dist/containers/page/index.js +4 -0
  106. package/dist/containers/page/page.d.ts +7 -0
  107. package/dist/containers/page/page.js +14 -0
  108. package/dist/containers/page-header/page-header.d.ts +8 -3
  109. package/dist/containers/page-header/page-header.js +35 -8
  110. package/dist/containers/responsive-list/responsive-list.d.ts +1 -1
  111. package/dist/containers/responsive-list/responsive-list.js +6 -3
  112. package/dist/containers/stack/index.d.ts +1 -0
  113. package/dist/containers/stack/index.js +6 -0
  114. package/dist/containers/stack/stack.d.ts +15 -0
  115. package/dist/containers/stack/stack.js +43 -0
  116. package/dist/forms/copy-field/copy-field.d.ts +17 -0
  117. package/dist/forms/copy-field/copy-field.js +72 -0
  118. package/dist/forms/copy-field/index.d.ts +1 -0
  119. package/dist/forms/copy-field/index.js +4 -0
  120. package/dist/forms/emoji-picker/emoji-picker.js +1 -1
  121. package/dist/forms/form/form.d.ts +15 -0
  122. package/dist/forms/form/form.js +29 -0
  123. package/dist/forms/form/index.d.ts +1 -0
  124. package/dist/forms/form/index.js +10 -0
  125. package/dist/forms/index.d.ts +2 -0
  126. package/dist/forms/index.js +2 -0
  127. package/dist/forms/input/index.d.ts +1 -1
  128. package/dist/forms/input/index.js +3 -2
  129. package/dist/forms/input/input.d.ts +6 -2
  130. package/dist/forms/input/input.js +9 -3
  131. package/dist/glass/crystal-map.d.ts +70 -0
  132. package/dist/glass/crystal-map.js +88 -0
  133. package/dist/glass/displacement-map.d.ts +117 -0
  134. package/dist/glass/displacement-map.js +201 -0
  135. package/dist/glass/index.d.ts +8 -0
  136. package/dist/glass/index.js +63 -0
  137. package/dist/glass/lens-crystal.d.ts +29 -0
  138. package/dist/glass/lens-crystal.js +161 -0
  139. package/dist/glass/lens-dispersion.d.ts +11 -0
  140. package/dist/glass/lens-dispersion.js +19 -0
  141. package/dist/glass/liquid-glass.d.ts +41 -0
  142. package/dist/glass/liquid-glass.js +256 -0
  143. package/dist/glass/liquid-motion.d.ts +53 -0
  144. package/dist/glass/liquid-motion.js +302 -0
  145. package/dist/glass/liquid-options.d.ts +162 -0
  146. package/dist/glass/liquid-options.js +179 -0
  147. package/dist/glass/refraction.d.ts +100 -0
  148. package/dist/glass/refraction.js +714 -0
  149. package/dist/glass/specular-map.d.ts +26 -0
  150. package/dist/glass/specular-map.js +75 -0
  151. package/dist/glass/spring.d.ts +79 -0
  152. package/dist/glass/spring.js +58 -0
  153. package/dist/glass/support.d.ts +13 -0
  154. package/dist/glass/support.js +14 -0
  155. package/dist/glass/use-glass-refraction.d.ts +8 -0
  156. package/dist/glass/use-glass-refraction.js +16 -0
  157. package/dist/i18n/strings.d.ts +24 -0
  158. package/dist/i18n/strings.js +18 -2
  159. package/dist/icons/index.d.ts +2 -0
  160. package/dist/icons/index.js +4 -0
  161. package/dist/icons/key.d.ts +2 -0
  162. package/dist/icons/key.js +12 -0
  163. package/dist/icons/webhook.d.ts +2 -0
  164. package/dist/icons/webhook.js +12 -0
  165. package/dist/liquid/index.d.ts +3 -0
  166. package/dist/liquid/index.js +29 -0
  167. package/dist/navigation/breadcrumbs/breadcrumbs.d.ts +29 -0
  168. package/dist/navigation/breadcrumbs/breadcrumbs.js +70 -0
  169. package/dist/navigation/breadcrumbs/index.d.ts +1 -0
  170. package/dist/navigation/breadcrumbs/index.js +6 -0
  171. package/dist/navigation/index.d.ts +1 -0
  172. package/dist/navigation/index.js +1 -0
  173. package/dist/navigation/segmented/index.d.ts +1 -1
  174. package/dist/navigation/segmented/model.d.ts +5 -0
  175. package/dist/navigation/segmented/model.js +6 -0
  176. package/dist/navigation/segmented/segmented.d.ts +17 -3
  177. package/dist/navigation/segmented/segmented.js +20 -4
  178. package/dist/overlays/context-menu/context-menu.d.ts +9 -1
  179. package/dist/overlays/context-menu/context-menu.js +4 -1
  180. package/dist/overlays/dialog/dialog.d.ts +9 -1
  181. package/dist/overlays/dialog/dialog.js +3 -0
  182. package/dist/overlays/drawer/drawer.d.ts +9 -1
  183. package/dist/overlays/drawer/drawer.js +3 -0
  184. package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +9 -1
  185. package/dist/overlays/dropdown-menu/dropdown-menu.js +3 -1
  186. package/dist/overlays/hover-card/hover-card.d.ts +10 -1
  187. package/dist/overlays/hover-card/hover-card.js +4 -1
  188. package/dist/overlays/popover/popover.d.ts +9 -1
  189. package/dist/overlays/popover/popover.js +3 -0
  190. package/dist/palette/command-palette/command-palette.d.ts +12 -2
  191. package/dist/palette/command-palette/command-palette.js +5 -0
  192. package/dist/primitives/command/command.d.ts +3 -2
  193. package/dist/primitives/command/command.js +2 -0
  194. package/dist/primitives/menu/menu.js +1 -1
  195. package/dist/primitives/popper/popper.js +5 -0
  196. package/dist/rich-text/rich-text-editor.js +94 -8
  197. package/dist/rich-text/sanitize.js +70 -20
  198. package/dist/shell/app-shell/app-shell.d.ts +17 -0
  199. package/dist/shell/app-shell/app-shell.js +44 -4
  200. package/dist/shell/bottom-nav/bottom-nav.d.ts +34 -0
  201. package/dist/shell/bottom-nav/bottom-nav.js +124 -0
  202. package/dist/shell/bottom-nav/index.d.ts +2 -0
  203. package/dist/shell/bottom-nav/index.js +9 -0
  204. package/dist/shell/bottom-nav/split.d.ts +11 -0
  205. package/dist/shell/bottom-nav/split.js +10 -0
  206. package/dist/shell/sidebar/sidebar.d.ts +16 -2
  207. package/dist/shell/sidebar/sidebar.js +46 -4
  208. package/dist/shell/topbar/topbar.d.ts +20 -9
  209. package/dist/shell/topbar/topbar.js +16 -9
  210. package/dist/states/empty-state/empty-state.d.ts +3 -1
  211. package/dist/states/empty-state/empty-state.js +9 -1
  212. package/dist/states/error-state/error-state.d.ts +3 -1
  213. package/dist/states/error-state/error-state.js +2 -0
  214. package/dist/states/index.d.ts +1 -0
  215. package/dist/states/index.js +1 -0
  216. package/dist/states/live-status-bar/index.d.ts +1 -0
  217. package/dist/states/live-status-bar/index.js +6 -0
  218. package/dist/states/live-status-bar/live-status-bar.d.ts +17 -0
  219. package/dist/states/live-status-bar/live-status-bar.js +49 -0
  220. package/dist/states/offline-banner/offline-banner.d.ts +3 -1
  221. package/dist/states/offline-banner/offline-banner.js +8 -4
  222. package/dist/utils/class-groups.js +17 -0
  223. package/dist/utils/index.d.ts +1 -0
  224. package/dist/utils/index.js +2 -0
  225. package/dist/utils/material.d.ts +13 -0
  226. package/dist/utils/material.js +6 -0
  227. package/dist/utils/tone.d.ts +8 -0
  228. package/dist/utils/tone.js +17 -0
  229. package/dist/utils/use-copy.d.ts +5 -0
  230. package/dist/utils/use-copy.js +35 -0
  231. package/icons/svg/key.svg +5 -0
  232. package/icons/svg/webhook.svg +5 -0
  233. package/package.json +31 -21
  234. package/scripts/build-theme.d.mts +22 -0
  235. package/scripts/build-theme.mjs +236 -4
  236. package/src/ai/attachment/attachment.tsx +1 -1
  237. package/src/ai/chat-list/group.ts +3 -1
  238. package/src/ai/conversation/conversation.tsx +1 -1
  239. package/src/ai/internal/use-copy.ts +1 -38
  240. package/src/ai/markdown/parse.ts +74 -17
  241. package/src/ai/source/source.tsx +1 -1
  242. package/src/atoms/avatar/avatar.tsx +57 -4
  243. package/src/atoms/avatar/index.ts +8 -1
  244. package/src/atoms/button/button.tsx +8 -3
  245. package/src/atoms/checkbox/checkbox.tsx +30 -3
  246. package/src/atoms/chip/chip.tsx +37 -5
  247. package/src/atoms/chip/index.ts +7 -1
  248. package/src/atoms/status-dot/index.ts +1 -0
  249. package/src/atoms/status-dot/status-dot.tsx +15 -3
  250. package/src/charts/README.md +21 -0
  251. package/src/charts/bar-chart/bar-race-chart.tsx +1 -0
  252. package/src/charts/beeswarm-chart/beeswarm-chart.tsx +1 -1
  253. package/src/charts/chord-chart/chord-chart.tsx +13 -5
  254. package/src/charts/core/cartesian/cartesian-chart.tsx +55 -10
  255. package/src/charts/core/cartesian/layout.ts +29 -10
  256. package/src/charts/core/cartesian/marks.tsx +3 -3
  257. package/src/charts/core/cartesian/types.ts +30 -2
  258. package/src/charts/core/category-explorer.tsx +12 -6
  259. package/src/charts/core/chart-dock.tsx +68 -0
  260. package/src/charts/core/chart-frame.tsx +116 -27
  261. package/src/charts/core/distribution/explorer.tsx +17 -7
  262. package/src/charts/core/distribution/xy-points.tsx +1 -1
  263. package/src/charts/core/index.ts +3 -0
  264. package/src/charts/core/leave-grace.ts +35 -0
  265. package/src/charts/core/nearest.ts +38 -0
  266. package/src/charts/core/plot-overlay.tsx +9 -3
  267. package/src/charts/core/pointer.test-utils.ts +146 -0
  268. package/src/charts/core/tooltip.tsx +129 -15
  269. package/src/charts/core/touch-select.ts +250 -0
  270. package/src/charts/core/types.ts +13 -4
  271. package/src/charts/core/use-index-navigation.ts +70 -11
  272. package/src/charts/donut-chart/donut-chart.tsx +53 -3
  273. package/src/charts/donut-chart/slice-labels.ts +39 -0
  274. package/src/charts/dumbbell-chart/dumbbell-chart.tsx +8 -3
  275. package/src/charts/fill-gauge-chart/fill-gauge-chart.tsx +1 -0
  276. package/src/charts/funnel-chart/funnel-chart.tsx +2 -1
  277. package/src/charts/gauge-chart/gauge-chart.tsx +2 -1
  278. package/src/charts/heatmap-chart/heatmap-chart.tsx +5 -0
  279. package/src/charts/heatmap-chart/heatmap-grid.tsx +5 -1
  280. package/src/charts/hex-tile-map/hex-tile-map.tsx +6 -1
  281. package/src/charts/hierarchy-morph/hierarchy-morph.tsx +2 -1
  282. package/src/charts/icicle-chart/icicle-chart.tsx +8 -9
  283. package/src/charts/lollipop-chart/lollipop-chart.tsx +8 -3
  284. package/src/charts/maps/geo/map-viewport.tsx +1 -1
  285. package/src/charts/polar-area-chart/polar-area-chart.tsx +37 -12
  286. package/src/charts/progress-units/progress-units.tsx +1 -0
  287. package/src/charts/radar-chart/radar-chart.tsx +1 -1
  288. package/src/charts/radial-bar-chart/radial-bar-chart.tsx +2 -1
  289. package/src/charts/range-area-chart/range-area-chart.tsx +3 -2
  290. package/src/charts/sankey-chart/sankey-chart.tsx +12 -4
  291. package/src/charts/tree-chart/tree-chart.tsx +1 -0
  292. package/src/charts/treemap-chart/treemap-chart.tsx +2 -7
  293. package/src/charts/waterfall-chart/waterfall-chart.tsx +8 -3
  294. package/src/containers/action-bar/action-bar.tsx +13 -2
  295. package/src/containers/card/card.tsx +43 -4
  296. package/src/containers/grid/grid.tsx +37 -0
  297. package/src/containers/grid/index.ts +1 -0
  298. package/src/containers/index.ts +3 -0
  299. package/src/containers/kpi/kpi.tsx +116 -22
  300. package/src/containers/kpi-group/index.ts +7 -1
  301. package/src/containers/kpi-group/kpi-group.tsx +26 -1
  302. package/src/containers/page/index.ts +1 -0
  303. package/src/containers/page/page.tsx +17 -0
  304. package/src/containers/page-header/page-header.tsx +38 -8
  305. package/src/containers/responsive-list/responsive-list.tsx +7 -4
  306. package/src/containers/stack/index.ts +7 -0
  307. package/src/containers/stack/stack.tsx +55 -0
  308. package/src/forms/copy-field/copy-field.tsx +88 -0
  309. package/src/forms/copy-field/index.ts +1 -0
  310. package/src/forms/emoji-picker/emoji-picker.tsx +1 -1
  311. package/src/forms/form/form.tsx +46 -0
  312. package/src/forms/form/index.ts +8 -0
  313. package/src/forms/index.ts +2 -0
  314. package/src/forms/input/index.ts +1 -1
  315. package/src/forms/input/input.tsx +14 -3
  316. package/src/glass/crystal-map.ts +150 -0
  317. package/src/glass/displacement-map.ts +317 -0
  318. package/src/glass/index.ts +43 -0
  319. package/src/glass/lens-crystal.ts +226 -0
  320. package/src/glass/lens-dispersion.ts +34 -0
  321. package/src/glass/liquid-glass.tsx +371 -0
  322. package/src/glass/liquid-motion.ts +395 -0
  323. package/src/glass/liquid-options.ts +306 -0
  324. package/src/glass/refraction.ts +1010 -0
  325. package/src/glass/specular-map.ts +95 -0
  326. package/src/glass/spring.ts +98 -0
  327. package/src/glass/support.ts +27 -0
  328. package/src/glass/use-glass-refraction.ts +21 -0
  329. package/src/i18n/strings.ts +24 -0
  330. package/src/icons/index.ts +2 -0
  331. package/src/icons/key.tsx +13 -0
  332. package/src/icons/webhook.tsx +13 -0
  333. package/src/liquid/index.ts +24 -0
  334. package/src/navigation/breadcrumbs/breadcrumbs.tsx +103 -0
  335. package/src/navigation/breadcrumbs/index.ts +8 -0
  336. package/src/navigation/index.ts +1 -0
  337. package/src/navigation/segmented/index.ts +1 -0
  338. package/src/navigation/segmented/model.ts +11 -0
  339. package/src/navigation/segmented/segmented.tsx +45 -6
  340. package/src/overlays/context-menu/context-menu.tsx +11 -1
  341. package/src/overlays/dialog/dialog.tsx +10 -0
  342. package/src/overlays/drawer/drawer.tsx +10 -0
  343. package/src/overlays/dropdown-menu/dropdown-menu.tsx +10 -1
  344. package/src/overlays/hover-card/hover-card.tsx +12 -1
  345. package/src/overlays/popover/popover.tsx +10 -0
  346. package/src/palette/command-palette/command-palette.tsx +15 -1
  347. package/src/primitives/command/command.tsx +4 -0
  348. package/src/primitives/menu/menu.tsx +1 -1
  349. package/src/primitives/popper/popper.tsx +10 -0
  350. package/src/rich-text/rich-text-editor.tsx +116 -13
  351. package/src/rich-text/sanitize.ts +94 -23
  352. package/src/shell/app-shell/app-shell.tsx +60 -4
  353. package/src/shell/bottom-nav/bottom-nav.tsx +187 -0
  354. package/src/shell/bottom-nav/index.ts +8 -0
  355. package/src/shell/bottom-nav/split.ts +20 -0
  356. package/src/shell/sidebar/sidebar.tsx +51 -5
  357. package/src/shell/topbar/topbar.tsx +81 -58
  358. package/src/states/empty-state/empty-state.tsx +11 -1
  359. package/src/states/error-state/error-state.tsx +4 -0
  360. package/src/states/index.ts +1 -0
  361. package/src/states/live-status-bar/index.ts +6 -0
  362. package/src/states/live-status-bar/live-status-bar.tsx +62 -0
  363. package/src/states/offline-banner/offline-banner.tsx +13 -5
  364. package/src/utils/class-groups.ts +17 -0
  365. package/src/utils/index.ts +1 -0
  366. package/src/utils/material.ts +16 -0
  367. package/src/utils/tone.ts +29 -0
  368. package/src/utils/use-copy.ts +38 -0
  369. package/styles/Theme.kt +64 -3
  370. package/styles/base.css +51 -0
  371. package/styles/tailwind.css +833 -0
  372. package/styles/theme.css +546 -4
  373. package/styles/tokens.css +788 -15
  374. package/tokens/default.json +918 -29
  375. package/scripts/build-theme.d.ts +0 -18
@@ -1,4 +1,8 @@
1
1
  import type { ComponentPropsWithoutRef } from "react";
2
- export interface InputProps extends ComponentPropsWithoutRef<"input"> {
2
+ export type InputSize = "md" | "lg";
3
+ export declare const inputSizeClasses: Readonly<Record<InputSize, string>>;
4
+ export interface InputProps extends Omit<ComponentPropsWithoutRef<"input">, "size"> {
5
+ /** `lg` is the thumb-friendly height of the large `Button`. */
6
+ size?: InputSize;
3
7
  }
4
- export declare function Input({ className, ...props }: InputProps): import("react").JSX.Element;
8
+ export declare function Input({ size, className, ...props }: InputProps): import("react").JSX.Element;
@@ -1,11 +1,16 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { cn } from "../../utils/cn.js";
3
- function Input({ className, ...props }) {
3
+ const inputSizeClasses = {
4
+ md: "h-input px-3",
5
+ lg: "h-control-lg px-4 text-fs-140"
6
+ };
7
+ function Input({ size = "md", className, ...props }) {
4
8
  return /* @__PURE__ */ jsx(
5
9
  "input",
6
10
  {
7
11
  className: cn(
8
- "h-input w-full min-w-0 rounded-input border-control bg-surface-control px-3 text-control text-ink placeholder:text-ink-3 focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 aria-[invalid=true]:border-danger",
12
+ "w-full min-w-0 rounded-input border-control bg-surface-control text-control text-ink placeholder:text-ink-3 focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 aria-[invalid=true]:border-danger",
13
+ inputSizeClasses[size],
9
14
  className
10
15
  ),
11
16
  ...props
@@ -13,5 +18,6 @@ function Input({ className, ...props }) {
13
18
  );
14
19
  }
15
20
  export {
16
- Input
21
+ Input,
22
+ inputSizeClasses
17
23
  };
@@ -0,0 +1,70 @@
1
+ import { type DisplacementField } from "./displacement-map.js";
2
+ /**
3
+ * The crystal lens: a thick, clear, convex lens that minifies the backdrop. Every output pixel at
4
+ * `p` (measured from the centre of the surface) shows the backdrop at `p + (g(t) - 1) p` with `g(t)
5
+ * = 1 + (gMax - 1) s(t)`, `s(t) = 0.3 + 0.3 t^2 + 0.4 t^6` and `t` the superellipse radial coordinate (1 at
6
+ * the silhouette). The pull is mild in the middle and grows steeply towards the rim, like the
7
+ * side of a ball lens. A radial map `p -> p g(|p|)` with `g >= 1` and `g' >= 0` has the Jacobian
8
+ * determinant `g (g + t g')`, which is at least 1, so it cannot fold back on itself however large
9
+ * `gMax` is: this is what lets the crystal minify by a factor of three at the rim where the other
10
+ * profiles must stay under a slope of one.
11
+ *
12
+ * The samples lie outside the surface (a minifying lens sees a wider area than it covers), so the
13
+ * map is rasterised over the surface plus a margin on every side; the engine lays the filter on a
14
+ * layer that large and clips it back to the silhouette.
15
+ */
16
+ export declare const CRYSTAL_EXPONENT = 2.5;
17
+ /** Weights of the constant (even minification), quadratic (whole-surface) and sixth-power (rim) parts of the crystal lens. */
18
+ export declare const CRYSTAL_WEIGHTS: {
19
+ readonly flat: 0.3;
20
+ readonly whole: 0.3;
21
+ readonly rim: 0.4;
22
+ };
23
+ /** `gMax - 1` per unit of `refraction`: how much more the rim minifies than the middle. */
24
+ export declare const CRYSTAL_GAIN = 1.3;
25
+ /** Largest source offset of the crystal lens, in px (bounds the margin and the filter area). */
26
+ export declare const CRYSTAL_MAX_OFFSET = 260;
27
+ /** `s(t)` of the crystal lens. */
28
+ export declare const crystalShape: (t: number) => number;
29
+ /** Radial coordinate of a point of a surface: 1 on the superellipse touching the middle of each side, held there beyond it. */
30
+ export declare function crystalRadius(px: number, py: number, hx: number, hy: number): number;
31
+ /**
32
+ * Largest source offset of the crystal lens, in px, for a surface and a `refraction` of 0 to 2
33
+ * (1.67 is a thick lens, 2 the thickest the margin allows).
34
+ */
35
+ export declare function crystalAmplitude(width: number, height: number, refraction: number): number;
36
+ export interface CrystalMapOptions {
37
+ width: number;
38
+ height: number;
39
+ /** Source offset at the silhouette, in px, from {@link crystalAmplitude}; sets the margin. */
40
+ amplitude: number;
41
+ /**
42
+ * Map pixels per CSS pixel. Default 1, between 0.5 and 2: the field is smooth and most of it lies
43
+ * in the margin the layer clips away, so a large lens can go below one.
44
+ */
45
+ dpr?: number;
46
+ /** Margin past the surface, in px. Default {@link crystalMargin} of `amplitude`. */
47
+ margin?: number;
48
+ /**
49
+ * Margin past each side of the surface, in px (default: `margin` on all four). A surface inside
50
+ * a clipping ancestor (an `overflow` or `clip-path` stage) only has the backdrop within it: a
51
+ * layer that reaches past the clip is cut by the browser and its filter is shifted, so the map
52
+ * covers only the backdrop that exists, and the offsets are clamped so no sample lands beyond it.
53
+ */
54
+ room?: Partial<Record<"left" | "right" | "top" | "bottom", number>>;
55
+ /** Largest factor the offset is multiplied by (chromatic dispersion pulls red this much further). Default 1. */
56
+ reach?: number;
57
+ }
58
+ /**
59
+ * Margin, in px, the crystal layer extends past the surface on every side: the largest offset,
60
+ * plus what chromatic dispersion adds to it.
61
+ */
62
+ export declare const crystalMargin: (amplitude: number, dispersion?: number) => number;
63
+ /**
64
+ * Displacement field of the crystal lens over the surface and its margin: red and green carry
65
+ * `s(t) p / half` (so `scale = 2 amplitude 255/254` restores the offset), blue is 255 (no soft
66
+ * band: a crystal is not frosted). The size of `data` is the surface plus twice the margin.
67
+ */
68
+ export declare function computeCrystalField({ width, height, amplitude, dpr, margin, room, reach, }: CrystalMapOptions): DisplacementField;
69
+ /** Crystal map as a PNG `data:` URI for `feImage` (browser only, cached). */
70
+ export declare function createCrystalMap(options: CrystalMapOptions): string;
@@ -0,0 +1,88 @@
1
+ import { cachedMap, clamp } from "./displacement-map.js";
2
+ const CRYSTAL_EXPONENT = 2.5;
3
+ const CRYSTAL_WEIGHTS = { flat: 0.3, whole: 0.3, rim: 0.4 };
4
+ const CRYSTAL_GAIN = 1.3;
5
+ const CRYSTAL_MAX_OFFSET = 260;
6
+ const crystalShape = (t) => CRYSTAL_WEIGHTS.flat + CRYSTAL_WEIGHTS.whole * t ** 2 + CRYSTAL_WEIGHTS.rim * t ** 6;
7
+ function crystalRadius(px, py, hx, hy) {
8
+ const u = Math.abs(px) / hx;
9
+ const v = Math.abs(py) / hy;
10
+ return Math.min((u ** CRYSTAL_EXPONENT + v ** CRYSTAL_EXPONENT) ** (1 / CRYSTAL_EXPONENT), 1);
11
+ }
12
+ function crystalAmplitude(width, height, refraction) {
13
+ const half = Math.max(width, height) / 2;
14
+ return Math.min(clamp(refraction, 0, 2) * CRYSTAL_GAIN * half, CRYSTAL_MAX_OFFSET);
15
+ }
16
+ const EDGE_SLACK = 3;
17
+ const crystalMargin = (amplitude, dispersion = 0) => Math.ceil(amplitude * (1 + Math.max(dispersion, 0))) + 2;
18
+ function computeCrystalField({
19
+ width,
20
+ height,
21
+ amplitude,
22
+ dpr = 1,
23
+ margin,
24
+ room,
25
+ reach = 1
26
+ }) {
27
+ const ratio = clamp(dpr, 0.5, 2);
28
+ const w = Math.max(1, width);
29
+ const h = Math.max(1, height);
30
+ const m = margin ?? crystalMargin(amplitude);
31
+ const free = (side) => Math.max(room?.[side] ?? m, 0);
32
+ const [left, right, top, bottom] = [free("left"), free("right"), free("top"), free("bottom")];
33
+ const pw = Math.max(1, Math.round((w + left + right) * ratio));
34
+ const ph = Math.max(1, Math.round((h + top + bottom) * ratio));
35
+ const rx = pw / (w + left + right);
36
+ const ry = ph / (h + top + bottom);
37
+ const data = new Uint8ClampedArray(pw * ph * 4);
38
+ const hx = w / 2;
39
+ const hy = h / 2;
40
+ const half = Math.max(hx, hy);
41
+ const slack = room ? EDGE_SLACK : 0;
42
+ const bounded = room !== void 0;
43
+ const [minX, maxX] = [-hx - left + slack, hx + right - slack];
44
+ const [minY, maxY] = [-hy - top + slack, hy + bottom - slack];
45
+ const unit = Math.max(amplitude, 1e-6);
46
+ const f = Math.max(reach, 1);
47
+ const within = (p, offset, lo, hi) => clamp((bounded ? clamp(offset, (lo - p) / f, (hi - p) / f) : offset) / unit, -1, 1);
48
+ for (let j = 0; j < ph; j++) {
49
+ const py = (j + 0.5) / ry - top - hy;
50
+ for (let i = 0; i < pw; i++) {
51
+ const px = (i + 0.5) / rx - left - hx;
52
+ const s = crystalShape(crystalRadius(px, py, hx, hy));
53
+ const o = (j * pw + i) * 4;
54
+ data[o] = 128 + within(px, s * px * amplitude / half, minX, maxX) * 127;
55
+ data[o + 1] = 128 + within(py, s * py * amplitude / half, minY, maxY) * 127;
56
+ data[o + 2] = 255;
57
+ data[o + 3] = 255;
58
+ }
59
+ }
60
+ return { width: pw, height: ph, data };
61
+ }
62
+ function createCrystalMap(options) {
63
+ const key = [
64
+ options.width,
65
+ options.height,
66
+ Math.round(options.amplitude),
67
+ options.dpr ?? 1,
68
+ options.margin ?? 0,
69
+ options.reach ?? 1,
70
+ options.room?.left ?? -1,
71
+ options.room?.right ?? -1,
72
+ options.room?.top ?? -1,
73
+ options.room?.bottom ?? -1
74
+ ].map((n) => Math.round(n * 100) / 100).join("x");
75
+ return cachedMap(`c${key}`, () => computeCrystalField(options));
76
+ }
77
+ export {
78
+ CRYSTAL_EXPONENT,
79
+ CRYSTAL_GAIN,
80
+ CRYSTAL_MAX_OFFSET,
81
+ CRYSTAL_WEIGHTS,
82
+ computeCrystalField,
83
+ createCrystalMap,
84
+ crystalAmplitude,
85
+ crystalMargin,
86
+ crystalRadius,
87
+ crystalShape
88
+ };
@@ -0,0 +1,117 @@
1
+ export interface DisplacementMapOptions {
2
+ width: number;
3
+ height: number;
4
+ /** Corner radius of the glass shape, in px. */
5
+ radius: number;
6
+ /** Width of the refracting bevel, in px, for `coverage: "rim"`; the centre stays undistorted. */
7
+ bezel: number;
8
+ /**
9
+ * `"full"` (default) bends the backdrop over the whole surface, strongest at the rim and
10
+ * gentle but never zero towards the centre (a squarish pillow); `"dome"` does the same with
11
+ * round contours, a drop that is flatter in the middle; `"rim"` only across the bevel.
12
+ */
13
+ coverage?: LensCoverage;
14
+ /** Width of the rim, in px, over which the veil and the blur ease off (blue channel). Default: `bezel`. */
15
+ soft?: number;
16
+ /** Largest offset of the whole-surface profiles, in px. Default {@link FULL_CAP}. */
17
+ cap?: number;
18
+ /** Device pixel ratio the map is rasterised at. Default 1, capped at 2. */
19
+ dpr?: number;
20
+ }
21
+ export type LensCoverage = "full" | "rim" | "dome" | "crystal";
22
+ /** The shape of the lens; `coverage` is the older name of the same option. */
23
+ export type LensProfile = LensCoverage;
24
+ /** Whether a profile bends the whole surface (everything but the rim band). */
25
+ export declare const isWhole: (coverage: LensCoverage) => coverage is "full" | "dome";
26
+ export interface DisplacementField {
27
+ /** Width and height of `data` in pixels (CSS size times the capped ratio). */
28
+ width: number;
29
+ height: number;
30
+ /**
31
+ * RGBA, row major. Red and green carry the horizontal and vertical source offset (128 is zero);
32
+ * blue carries how soft the backdrop is there: 255 in the middle, easing down to 0 at the edge,
33
+ * so the lens shows the backdrop sharp and lively along the rim and frosted under the text.
34
+ */
35
+ data: Uint8ClampedArray;
36
+ }
37
+ export declare const clamp: (value: number, min: number, max: number, ceil?: number) => number;
38
+ /** How much of the legibility veil is left at the very edge of the rim. */
39
+ export declare const VEIL_FLOOR = 0.5;
40
+ /**
41
+ * Bevel width of a surface, in px. `"rim"`: a little more than its corner radius, so the bend
42
+ * reads as a drop. `"full"`: half the short side, the whole surface.
43
+ */
44
+ export declare function bezelFor(radius: number, width: number, height: number, coverage?: LensCoverage): number;
45
+ /**
46
+ * Largest source offset of the lens, as a fraction of the bevel width (`"rim"`). The profile falls
47
+ * at most 1.5 times its amplitude per bevel width, so 0.58 keeps the mapping `depth +
48
+ * offset(depth)` strictly increasing (slope 0.87 < 1). Above 1 it folds back on itself: several
49
+ * output pixels then sample the same source pixels in reverse order, and straight stripes break
50
+ * into a repeating sawtooth along the walls. That fold, not the map resolution, was the serrated
51
+ * edge of the first lenses.
52
+ */
53
+ export declare const MAX_OFFSET = 0.58;
54
+ /**
55
+ * Full coverage is a dome over a superellipse radial coordinate: with `u = x / hx`, `v = y / hy`
56
+ * and `r = (|u|^N + |v|^N)^(1/N)`, a pixel is pulled towards the centre along the gradient of `r` in
57
+ * the normalised (u, v) plane (perpendicular to the contours of the superellipse) by `A (r / r_corner)^1.5`. The gradient is
58
+ * continuous everywhere except the exact centre, where the pull is zero, so there is no crease:
59
+ * a field built from the distance to the nearest edge, or from each axis on its own, has its
60
+ * pull flip direction along the diagonals of the shape and the glass reads as a four-faced
61
+ * pyramid. `N = 3` keeps the contours between an ellipse (a round drop) and a rounded rectangle
62
+ * (a slab). The slope of the pull is at most 2A / (r_corner^2 h) along an axis, so A is at most
63
+ * 0.55 of the smaller half size (fold-free), and at most {@link FULL_CAP} px so a large surface
64
+ * does not smear.
65
+ */
66
+ export declare const FULL_FRACTION = 0.55;
67
+ /** Exponent of the superellipse radial coordinate of the full lens. */
68
+ export declare const FULL_EXPONENT = 3;
69
+ /** Largest offset of the full lens, in px. */
70
+ export declare const FULL_CAP = 24;
71
+ /**
72
+ * Shape of the two whole-surface profiles: the exponent `N` of the radial coordinate
73
+ * `(|u|^N + |v|^N)^(1/N)` (3: squarish, 2: round) and the power `p` of the pull `A t^p`, with
74
+ * `t` the radial coordinate over its value at the corners.
75
+ */
76
+ export declare const WHOLE_SHAPES: {
77
+ readonly full: {
78
+ readonly exponent: 3;
79
+ readonly power: 1.5;
80
+ };
81
+ readonly dome: {
82
+ readonly exponent: 2;
83
+ readonly power: 2;
84
+ };
85
+ };
86
+ /** Offset amplitude of the lens along each axis, in px. */
87
+ export declare function lensAmplitude(width: number, height: number, bezel: number, coverage?: LensCoverage, cap?: number): {
88
+ x: number;
89
+ y: number;
90
+ };
91
+ /** `scale` of the displacement filter: the offset is half of it (128 is neutral). */
92
+ export declare function scaleFor(width: number, height: number, bezel: number, coverage?: LensCoverage, cap?: number): number;
93
+ /**
94
+ * `"full"`: the table of the dome, `(x / half size)^2` from the centre (0) to the edge (1).
95
+ *
96
+ * `"rim"`: lateral displacement across the bevel, 1 at the outer edge and 0 at the inner one: `1 -
97
+ * smoothstep(x)`, with x running from the outer edge inwards. It starts flat (the outermost
98
+ * pixels show one clean shifted copy of the backdrop, like the rim of a drop), bends most at the
99
+ * middle of the bevel and eases to zero, so the lens meets the clear centre without a seam. Its
100
+ * slope never exceeds 1.5, which is what keeps {@link MAX_OFFSET} fold-free.
101
+ */
102
+ export declare function lensProfile(coverage?: LensCoverage): Float32Array;
103
+ /**
104
+ * Displacement field of a rounded rectangle, from its signed distance function: zero in the
105
+ * middle, and across the rim a source offset pointing into the shape whose length follows
106
+ * {@link lensProfile} and whose direction is the inward surface normal (straight edges pull
107
+ * along the axis, corners along the radius). Pure, so it runs anywhere.
108
+ */
109
+ export declare function computeDisplacementField({ width, height, radius, bezel, coverage, soft, cap, dpr, }: DisplacementMapOptions): DisplacementField;
110
+ /**
111
+ * Displacement map for `feDisplacementMap`, as a PNG `data:` URI for `feImage`. Browser only
112
+ * (it rasterises on a canvas); results are kept in a small cache, so reopening a dialog of the
113
+ * same size costs nothing.
114
+ */
115
+ export declare function createDisplacementMap(options: DisplacementMapOptions): string;
116
+ /** Rasterises a field to a PNG `data:` URI, kept in a small cache shared by every map. */
117
+ export declare function cachedMap(key: string, compute: () => DisplacementField): string;
@@ -0,0 +1,201 @@
1
+ const isWhole = (coverage) => coverage !== "rim" && coverage !== "crystal";
2
+ const clamp = (value, min, max, ceil = Number.POSITIVE_INFINITY) => Math.min(Math.max(value, min), max, ceil);
3
+ const VEIL_FLOOR = 0.5;
4
+ function bezelFor(radius, width, height, coverage = "full") {
5
+ const short = Math.min(width, height);
6
+ if (coverage === "full" || coverage === "dome") return Math.max(1, short / 2);
7
+ return clamp(radius * 1.2, 14, Math.max(8, short * 0.45), 56);
8
+ }
9
+ const MAX_OFFSET = 0.58;
10
+ const FULL_FRACTION = 0.55;
11
+ const FULL_EXPONENT = 3;
12
+ const FULL_CAP = 24;
13
+ const WHOLE_SHAPES = {
14
+ full: { exponent: FULL_EXPONENT, power: 1.5 },
15
+ dome: { exponent: 2, power: 2 }
16
+ };
17
+ function lensAmplitude(width, height, bezel, coverage = "full", cap = FULL_CAP) {
18
+ if (coverage === "rim" || coverage === "crystal") {
19
+ const a2 = MAX_OFFSET * bezel;
20
+ return { x: a2, y: a2 };
21
+ }
22
+ const a = Math.min(Math.min(width, height) / 2 * FULL_FRACTION, Math.max(cap, 1));
23
+ return { x: a, y: a };
24
+ }
25
+ function scaleFor(width, height, bezel, coverage = "full", cap = FULL_CAP) {
26
+ const { x, y } = lensAmplitude(width, height, bezel, coverage, cap);
27
+ return 2 * Math.max(x, y, 1) * 255 / 254;
28
+ }
29
+ const PROFILE_SAMPLES = 64;
30
+ let profile;
31
+ let quadratic;
32
+ function lensProfile(coverage = "rim") {
33
+ if (coverage !== "rim") {
34
+ if (quadratic) return quadratic;
35
+ quadratic = new Float32Array(PROFILE_SAMPLES).map((_, i) => (i / (PROFILE_SAMPLES - 1)) ** 2);
36
+ return quadratic;
37
+ }
38
+ if (profile) return profile;
39
+ const out = new Float32Array(PROFILE_SAMPLES);
40
+ for (let i = 0; i < PROFILE_SAMPLES; i++) {
41
+ const x = i / (PROFILE_SAMPLES - 1);
42
+ out[i] = 1 - x * x * (3 - 2 * x);
43
+ }
44
+ profile = out;
45
+ return out;
46
+ }
47
+ function computeDisplacementField({
48
+ width,
49
+ height,
50
+ radius,
51
+ bezel,
52
+ coverage = "rim",
53
+ soft,
54
+ cap,
55
+ dpr = 1
56
+ }) {
57
+ const ratio = clamp(dpr, 1, 2);
58
+ const w = Math.max(1, width);
59
+ const h = Math.max(1, height);
60
+ const full = isWhole(coverage);
61
+ const shape = WHOLE_SHAPES[coverage === "dome" ? "dome" : "full"];
62
+ const corner = 2 ** (1 / shape.exponent);
63
+ const rim = clamp(full ? soft ?? bezelFor(radius, w, h, "rim") : bezel, 1, Math.min(w, h) / 2);
64
+ const r = clamp(radius, 0, Math.min(w, h) / 2);
65
+ const pw = Math.max(1, Math.round(w * ratio));
66
+ const ph = Math.max(1, Math.round(h * ratio));
67
+ const rx = pw / w;
68
+ const ry = ph / h;
69
+ const data = new Uint8ClampedArray(pw * ph * 4);
70
+ new Uint32Array(data.buffer).fill(4294934656);
71
+ const band = Math.min(pw, Math.ceil(rim * ratio) + 1);
72
+ const table = lensProfile("rim");
73
+ const last = table.length - 1;
74
+ const hx = w / 2;
75
+ const hy = h / 2;
76
+ const amp = lensAmplitude(w, h, bezel, coverage, cap);
77
+ const norm = Math.max(amp.x, amp.y, 1);
78
+ const columnPull = new Float64Array(full ? pw : 0);
79
+ const columnShape = new Float64Array(full ? pw : 0);
80
+ for (let i = 0; full && i < pw; i++) {
81
+ const px = (i + 0.5) / rx - hx;
82
+ const au = Math.abs(px) / hx;
83
+ columnPull[i] = Math.sign(px) * au ** (shape.exponent - 1);
84
+ columnShape[i] = au ** shape.exponent;
85
+ }
86
+ for (let j = 0; j < ph; j++) {
87
+ const py = (j + 0.5) / ry - hy;
88
+ const inner = Math.abs(py) < hy - rim;
89
+ const av = Math.abs(py) / hy;
90
+ const gv = full ? Math.sign(py) * av ** (shape.exponent - 1) : 0;
91
+ const vn = av ** shape.exponent;
92
+ for (let i = 0; i < pw; i++) {
93
+ if (!full && inner && i === band) i = Math.max(band, pw - band);
94
+ const px = (i + 0.5) / rx - hx;
95
+ const o = (j * pw + i) * 4;
96
+ if (full) {
97
+ const gx = columnPull[i];
98
+ const g = Math.hypot(gx, gv);
99
+ const t = Math.min((columnShape[i] + vn) ** (1 / shape.exponent) / corner, 1);
100
+ const pull = g > 0 ? t ** shape.power / g : 0;
101
+ data[o] = 128 - gx * pull * 127 * (amp.x / norm);
102
+ data[o + 1] = 128 - gv * pull * 127 * (amp.y / norm);
103
+ data[o + 3] = 255;
104
+ if (inner && Math.abs(px) < hx - rim) {
105
+ data[o + 2] = 255;
106
+ continue;
107
+ }
108
+ }
109
+ const qx = Math.abs(px) - (hx - r);
110
+ const qy = Math.abs(py) - (hy - r);
111
+ const out = Math.hypot(Math.max(qx, 0), Math.max(qy, 0));
112
+ const depth = r - (out + Math.min(Math.max(qx, qy), 0));
113
+ let dx = 0;
114
+ let dy = 0;
115
+ let veil = 1;
116
+ if (full) {
117
+ if (depth > 0 && depth < rim) {
118
+ const x = depth / rim;
119
+ veil = x * x * (3 - 2 * x);
120
+ }
121
+ data[o + 2] = veil * 255;
122
+ continue;
123
+ }
124
+ if (depth > 0 && depth < rim) {
125
+ const x = depth / rim;
126
+ veil = x * x * (3 - 2 * x);
127
+ const at = depth / rim * last;
128
+ const lo = Math.floor(at);
129
+ const m = table[lo] * (1 - (at - lo)) + table[Math.min(lo + 1, last)] * (at - lo);
130
+ const sx = px < 0 ? -1 : 1;
131
+ const sy = py < 0 ? -1 : 1;
132
+ let nx = 0;
133
+ let ny = 0;
134
+ if (qx > 0 && qy > 0) {
135
+ nx = sx * qx / out;
136
+ ny = sy * qy / out;
137
+ } else if (qx > qy) nx = sx;
138
+ else ny = sy;
139
+ dx = -nx * m;
140
+ dy = -ny * m;
141
+ }
142
+ data[o] = 128 + dx * 127 * (amp.x / norm);
143
+ data[o + 1] = 128 + dy * 127 * (amp.y / norm);
144
+ data[o + 2] = veil * 255;
145
+ data[o + 3] = 255;
146
+ }
147
+ }
148
+ return { width: pw, height: ph, data };
149
+ }
150
+ const cache = /* @__PURE__ */ new Map();
151
+ const CACHE_SIZE = 16;
152
+ function createDisplacementMap(options) {
153
+ const key = [
154
+ options.width,
155
+ options.height,
156
+ options.radius,
157
+ options.bezel,
158
+ options.soft ?? 0,
159
+ // The offset is encoded relative to the largest one, so it only shows in the map below 1 px.
160
+ Math.min(
161
+ lensAmplitude(options.width, options.height, options.bezel, options.coverage, options.cap).x,
162
+ 1
163
+ ),
164
+ options.dpr ?? 1
165
+ ].map((n) => Math.round(n * 100) / 100).join("x");
166
+ return cachedMap(`d${options.coverage ?? "rim"}${key}`, () => computeDisplacementField(options));
167
+ }
168
+ function cachedMap(key, compute) {
169
+ const hit = cache.get(key);
170
+ if (hit) return hit;
171
+ const field = compute();
172
+ const canvas = document.createElement("canvas");
173
+ canvas.width = field.width;
174
+ canvas.height = field.height;
175
+ const context = canvas.getContext("2d");
176
+ if (!context) return "";
177
+ const image = context.createImageData(field.width, field.height);
178
+ image.data.set(field.data);
179
+ context.putImageData(image, 0, 0);
180
+ const uri = canvas.toDataURL("image/png");
181
+ cache.set(key, uri);
182
+ if (cache.size > CACHE_SIZE) cache.delete(cache.keys().next().value);
183
+ return uri;
184
+ }
185
+ export {
186
+ FULL_CAP,
187
+ FULL_EXPONENT,
188
+ FULL_FRACTION,
189
+ MAX_OFFSET,
190
+ VEIL_FLOOR,
191
+ WHOLE_SHAPES,
192
+ bezelFor,
193
+ cachedMap,
194
+ clamp,
195
+ computeDisplacementField,
196
+ createDisplacementMap,
197
+ isWhole,
198
+ lensAmplitude,
199
+ lensProfile,
200
+ scaleFor
201
+ };
@@ -0,0 +1,8 @@
1
+ export { CRYSTAL_GAIN, CRYSTAL_MAX_OFFSET, computeCrystalField, crystalAmplitude, crystalMargin, crystalRadius, crystalShape, } from "./crystal-map.js";
2
+ export { computeDisplacementField, createDisplacementMap, type DisplacementField, type DisplacementMapOptions, type LensCoverage, lensProfile, } from "./displacement-map.js";
3
+ export { LiquidGlass, startLiquidGlass } from "./liquid-glass.js";
4
+ export { LIQUID_DEFAULTS, LIQUID_MOTIONS, LIQUID_PRESET_CLEAR, LIQUID_PRESET_CRYSTAL, LIQUID_PRESET_REGULAR, LIQUID_PRESET_THICK, LIQUID_PRESETS, type LiquidGlassOptions, type LiquidInteractive, type LiquidMotion, type LiquidPresetName, type LiquidProfile, liquidStyle, liquidVars, mergeLiquid, } from "./liquid-options.js";
5
+ export { applyGlassRefraction, type GlassRefractionOptions } from "./refraction.js";
6
+ export { computeSpecularField, createSpecularMap, type SpecularMapOptions, } from "./specular-map.js";
7
+ export { supportsBackdropRefraction } from "./support.js";
8
+ export { useGlassRefraction } from "./use-glass-refraction.js";
@@ -0,0 +1,63 @@
1
+ import {
2
+ CRYSTAL_GAIN,
3
+ CRYSTAL_MAX_OFFSET,
4
+ computeCrystalField,
5
+ crystalAmplitude,
6
+ crystalMargin,
7
+ crystalRadius,
8
+ crystalShape
9
+ } from "./crystal-map.js";
10
+ import {
11
+ computeDisplacementField,
12
+ createDisplacementMap,
13
+ lensProfile
14
+ } from "./displacement-map.js";
15
+ import { LiquidGlass, startLiquidGlass } from "./liquid-glass.js";
16
+ import {
17
+ LIQUID_DEFAULTS,
18
+ LIQUID_MOTIONS,
19
+ LIQUID_PRESET_CLEAR,
20
+ LIQUID_PRESET_CRYSTAL,
21
+ LIQUID_PRESET_REGULAR,
22
+ LIQUID_PRESET_THICK,
23
+ LIQUID_PRESETS,
24
+ liquidStyle,
25
+ liquidVars,
26
+ mergeLiquid
27
+ } from "./liquid-options.js";
28
+ import { applyGlassRefraction } from "./refraction.js";
29
+ import {
30
+ computeSpecularField,
31
+ createSpecularMap
32
+ } from "./specular-map.js";
33
+ import { supportsBackdropRefraction } from "./support.js";
34
+ import { useGlassRefraction } from "./use-glass-refraction.js";
35
+ export {
36
+ CRYSTAL_GAIN,
37
+ CRYSTAL_MAX_OFFSET,
38
+ LIQUID_DEFAULTS,
39
+ LIQUID_MOTIONS,
40
+ LIQUID_PRESETS,
41
+ LIQUID_PRESET_CLEAR,
42
+ LIQUID_PRESET_CRYSTAL,
43
+ LIQUID_PRESET_REGULAR,
44
+ LIQUID_PRESET_THICK,
45
+ LiquidGlass,
46
+ applyGlassRefraction,
47
+ computeCrystalField,
48
+ computeDisplacementField,
49
+ computeSpecularField,
50
+ createDisplacementMap,
51
+ createSpecularMap,
52
+ crystalAmplitude,
53
+ crystalMargin,
54
+ crystalRadius,
55
+ crystalShape,
56
+ lensProfile,
57
+ liquidStyle,
58
+ liquidVars,
59
+ mergeLiquid,
60
+ startLiquidGlass,
61
+ supportsBackdropRefraction,
62
+ useGlassRefraction
63
+ };
@@ -0,0 +1,29 @@
1
+ /** What the engine hands the crystal lens of one installed filter. */
2
+ export interface CrystalContext {
3
+ element: HTMLElement;
4
+ /** Id of the SVG filter, and the CSS that comes before it in `backdrop-filter`. */
5
+ id: string;
6
+ blur: string;
7
+ /** The surface's own inline `backdrop-filter` before the engine touched it. */
8
+ original: string;
9
+ filter: SVGFilterElement;
10
+ image: Element;
11
+ /** The layer or the skin was removed from the surface: install again. */
12
+ reinstall: () => void;
13
+ /** The backdrop room around the surface changed: rebuild the map. */
14
+ resize: () => void;
15
+ }
16
+ export interface CrystalLens {
17
+ /** Lays the map out for a size; returns the filter scale, or `undefined` when nothing changed. */
18
+ update(width: number, height: number, radius: number, refraction: number, dispersion: number, dpr: number): number | undefined;
19
+ /** Removes the layer and the skin and gives the surface its own styles back. */
20
+ undo(): void;
21
+ }
22
+ /**
23
+ * The crystal lens samples the backdrop outside the surface (it minifies), which a filter on the
24
+ * surface itself cannot see. So the filter goes on a layer that extends past the surface by the
25
+ * largest offset, clipped back to the silhouette; the surface's own backdrop filter, background and
26
+ * inset shadows move to (or under) that layer's siblings, because the layer must be the lowest
27
+ * thing in the surface. Its own lazy chunk: the engine imports it only for a crystal surface.
28
+ */
29
+ export declare function installCrystal({ element, id, blur, original, filter, image, reinstall, resize, }: CrystalContext): CrystalLens;