@zonsh/ui 0.0.0 → 0.4.1

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 (425) hide show
  1. package/LICENSE +43 -0
  2. package/README.md +81 -1
  3. package/assets/illustrations/drawing/bracket-construction-dark.svg +77 -0
  4. package/assets/illustrations/drawing/bracket-construction-filled-dark.svg +50 -0
  5. package/assets/illustrations/drawing/bracket-construction-filled.svg +50 -0
  6. package/assets/illustrations/drawing/bracket-construction.svg +77 -0
  7. package/assets/illustrations/drawing/crescent-dark.svg +28 -0
  8. package/assets/illustrations/drawing/crescent-guides-dark.svg +33 -0
  9. package/assets/illustrations/drawing/crescent-guides.svg +33 -0
  10. package/assets/illustrations/drawing/crescent.svg +28 -0
  11. package/assets/illustrations/drawing/eclipse-dark.svg +187 -0
  12. package/assets/illustrations/drawing/eclipse-guides-dark.svg +191 -0
  13. package/assets/illustrations/drawing/eclipse-guides.svg +191 -0
  14. package/assets/illustrations/drawing/eclipse.svg +187 -0
  15. package/assets/illustrations/drawing/elevation-guides-dark.svg +31 -0
  16. package/assets/illustrations/drawing/elevation-guides-plain-dark.svg +9 -0
  17. package/assets/illustrations/drawing/elevation-guides-plain.svg +9 -0
  18. package/assets/illustrations/drawing/elevation-guides.svg +31 -0
  19. package/assets/illustrations/drawing/horizon-dark.svg +30 -0
  20. package/assets/illustrations/drawing/horizon.svg +30 -0
  21. package/assets/illustrations/drawing/nib-study-dark.svg +107 -0
  22. package/assets/illustrations/drawing/nib-study-plain-dark.svg +93 -0
  23. package/assets/illustrations/drawing/nib-study-plain.svg +93 -0
  24. package/assets/illustrations/drawing/nib-study.svg +107 -0
  25. package/assets/illustrations/editorial/assistant-640.webp +0 -0
  26. package/assets/illustrations/editorial/assistant.webp +0 -0
  27. package/assets/illustrations/editorial/automation-640.webp +0 -0
  28. package/assets/illustrations/editorial/automation.webp +0 -0
  29. package/assets/illustrations/editorial/bracket-left-640.webp +0 -0
  30. package/assets/illustrations/editorial/bracket-left.webp +0 -0
  31. package/assets/illustrations/editorial/bracket-right-640.webp +0 -0
  32. package/assets/illustrations/editorial/bracket-right.webp +0 -0
  33. package/assets/illustrations/editorial/custom-software-640.webp +0 -0
  34. package/assets/illustrations/editorial/custom-software.webp +0 -0
  35. package/assets/illustrations/editorial/digitalization-640.webp +0 -0
  36. package/assets/illustrations/editorial/digitalization.webp +0 -0
  37. package/assets/illustrations/editorial/integration-640.webp +0 -0
  38. package/assets/illustrations/editorial/integration.webp +0 -0
  39. package/assets/illustrations/editorial/problem-640.webp +0 -0
  40. package/assets/illustrations/editorial/problem.webp +0 -0
  41. package/assets/illustrations/editorial/process-analysis-640.webp +0 -0
  42. package/assets/illustrations/editorial/process-analysis.webp +0 -0
  43. package/assets/illustrations/editorial/process-concept-640.webp +0 -0
  44. package/assets/illustrations/editorial/process-concept.webp +0 -0
  45. package/assets/illustrations/editorial/process-development-640.webp +0 -0
  46. package/assets/illustrations/editorial/process-development.webp +0 -0
  47. package/assets/illustrations/editorial/process-discovery-640.webp +0 -0
  48. package/assets/illustrations/editorial/process-discovery.webp +0 -0
  49. package/assets/illustrations/editorial/process-maintenance-640.webp +0 -0
  50. package/assets/illustrations/editorial/process-maintenance.webp +0 -0
  51. package/assets/illustrations/editorial/process-prototype-640.webp +0 -0
  52. package/assets/illustrations/editorial/process-prototype.webp +0 -0
  53. package/assets/illustrations/editorial/process-testing-640.webp +0 -0
  54. package/assets/illustrations/editorial/process-testing.webp +0 -0
  55. package/assets/illustrations/iso/automation-dark.svg +6 -0
  56. package/assets/illustrations/iso/automation.svg +6 -0
  57. package/assets/illustrations/iso/bar-chart-dark.svg +6 -0
  58. package/assets/illustrations/iso/bar-chart.svg +6 -0
  59. package/assets/illustrations/iso/brackets-classic-dark.svg +6 -0
  60. package/assets/illustrations/iso/brackets-classic.svg +6 -0
  61. package/assets/illustrations/iso/brackets-dark.svg +6 -0
  62. package/assets/illustrations/iso/brackets.svg +6 -0
  63. package/assets/illustrations/iso/city-dark.svg +6 -0
  64. package/assets/illustrations/iso/city.svg +6 -0
  65. package/assets/illustrations/iso/conveyor-dark.svg +6 -0
  66. package/assets/illustrations/iso/conveyor.svg +6 -0
  67. package/assets/illustrations/iso/database-dark.svg +6 -0
  68. package/assets/illustrations/iso/database.svg +6 -0
  69. package/assets/illustrations/iso/documents-dark.svg +6 -0
  70. package/assets/illustrations/iso/documents.svg +6 -0
  71. package/assets/illustrations/iso/inbox-dark.svg +6 -0
  72. package/assets/illustrations/iso/inbox.svg +6 -0
  73. package/assets/illustrations/iso/laptop-dark.svg +6 -0
  74. package/assets/illustrations/iso/laptop.svg +6 -0
  75. package/assets/illustrations/iso/monitor-dark.svg +6 -0
  76. package/assets/illustrations/iso/monitor.svg +6 -0
  77. package/assets/illustrations/iso/pipeline-dark.svg +6 -0
  78. package/assets/illustrations/iso/pipeline.svg +6 -0
  79. package/assets/illustrations/iso/platform-dark.svg +6 -0
  80. package/assets/illustrations/iso/platform.svg +6 -0
  81. package/assets/illustrations/iso/server-dark.svg +6 -0
  82. package/assets/illustrations/iso/server.svg +6 -0
  83. package/assets/illustrations/iso/spreadsheet-dark.svg +6 -0
  84. package/assets/illustrations/iso/spreadsheet.svg +6 -0
  85. package/assets/illustrations/iso/timeline-dark.svg +6 -0
  86. package/assets/illustrations/iso/timeline.svg +6 -0
  87. package/assets/illustrations/sheet/construction.svg +115 -0
  88. package/assets/illustrations/sheet/crescent.svg +40 -0
  89. package/assets/illustrations/sheet/limb.svg +42 -0
  90. package/assets/illustrations/sheet/stress-axis.svg +119 -0
  91. package/assets/illustrations/sheet/totality.svg +215 -0
  92. package/assets/illustrations/sheet/vertical-metrics.svg +43 -0
  93. package/assets/logo-left.svg +1 -0
  94. package/assets/logo-right.svg +1 -0
  95. package/assets/logo.svg +1 -0
  96. package/dist/components/_overlay.d.ts +47 -0
  97. package/dist/components/_overlay.js +59 -0
  98. package/dist/components/accordion.d.ts +32 -0
  99. package/dist/components/accordion.js +39 -0
  100. package/dist/components/alert-dialog.d.ts +45 -0
  101. package/dist/components/alert-dialog.js +56 -0
  102. package/dist/components/alert.d.ts +35 -0
  103. package/dist/components/alert.js +42 -0
  104. package/dist/components/ascii-field.d.ts +34 -0
  105. package/dist/components/ascii-field.js +410 -0
  106. package/dist/components/aspect-ratio.d.ts +14 -0
  107. package/dist/components/aspect-ratio.js +17 -0
  108. package/dist/components/avatar.d.ts +42 -0
  109. package/dist/components/avatar.js +55 -0
  110. package/dist/components/badge.d.ts +70 -0
  111. package/dist/components/badge.js +62 -0
  112. package/dist/components/bottom-nav.d.ts +86 -0
  113. package/dist/components/bottom-nav.js +175 -0
  114. package/dist/components/breadcrumb.d.ts +31 -0
  115. package/dist/components/breadcrumb.js +37 -0
  116. package/dist/components/button-group.d.ts +30 -0
  117. package/dist/components/button-group.js +47 -0
  118. package/dist/components/button.d.ts +53 -0
  119. package/dist/components/button.js +130 -0
  120. package/dist/components/calendar.d.ts +26 -0
  121. package/dist/components/calendar.js +179 -0
  122. package/dist/components/card.d.ts +42 -0
  123. package/dist/components/card.js +76 -0
  124. package/dist/components/carousel.d.ts +109 -0
  125. package/dist/components/carousel.js +231 -0
  126. package/dist/components/chart.d.ts +189 -0
  127. package/dist/components/chart.js +323 -0
  128. package/dist/components/checkbox.d.ts +23 -0
  129. package/dist/components/checkbox.js +43 -0
  130. package/dist/components/code-block.d.ts +55 -0
  131. package/dist/components/code-block.js +100 -0
  132. package/dist/components/collapsible.d.ts +20 -0
  133. package/dist/components/collapsible.js +32 -0
  134. package/dist/components/color-picker.d.ts +107 -0
  135. package/dist/components/color-picker.js +428 -0
  136. package/dist/components/combobox.d.ts +99 -0
  137. package/dist/components/combobox.js +172 -0
  138. package/dist/components/command.d.ts +132 -0
  139. package/dist/components/command.js +257 -0
  140. package/dist/components/context-menu.d.ts +29 -0
  141. package/dist/components/context-menu.js +35 -0
  142. package/dist/components/conversation.d.ts +36 -0
  143. package/dist/components/conversation.js +303 -0
  144. package/dist/components/copy-button.d.ts +55 -0
  145. package/dist/components/copy-button.js +133 -0
  146. package/dist/components/data-table.d.ts +235 -0
  147. package/dist/components/data-table.js +655 -0
  148. package/dist/components/date-picker.d.ts +160 -0
  149. package/dist/components/date-picker.js +338 -0
  150. package/dist/components/dialog.d.ts +57 -0
  151. package/dist/components/dialog.js +95 -0
  152. package/dist/components/direction.d.ts +16 -0
  153. package/dist/components/direction.js +18 -0
  154. package/dist/components/drawer.d.ts +69 -0
  155. package/dist/components/drawer.js +79 -0
  156. package/dist/components/empty.d.ts +31 -0
  157. package/dist/components/empty.js +50 -0
  158. package/dist/components/feature-list.d.ts +54 -0
  159. package/dist/components/feature-list.js +43 -0
  160. package/dist/components/field.d.ts +34 -0
  161. package/dist/components/field.js +81 -0
  162. package/dist/components/file-drop.d.ts +77 -0
  163. package/dist/components/file-drop.js +258 -0
  164. package/dist/components/filter-bar.d.ts +153 -0
  165. package/dist/components/filter-bar.js +334 -0
  166. package/dist/components/form.d.ts +35 -0
  167. package/dist/components/form.js +56 -0
  168. package/dist/components/graph.d.ts +146 -0
  169. package/dist/components/graph.js +825 -0
  170. package/dist/components/illustration.d.ts +85 -0
  171. package/dist/components/illustration.js +165 -0
  172. package/dist/components/input-group.d.ts +138 -0
  173. package/dist/components/input-group.js +312 -0
  174. package/dist/components/input.d.ts +16 -0
  175. package/dist/components/input.js +25 -0
  176. package/dist/components/item.d.ts +64 -0
  177. package/dist/components/item.js +116 -0
  178. package/dist/components/kbd.d.ts +50 -0
  179. package/dist/components/kbd.js +45 -0
  180. package/dist/components/label.d.ts +12 -0
  181. package/dist/components/label.js +24 -0
  182. package/dist/components/layout.d.ts +136 -0
  183. package/dist/components/layout.js +162 -0
  184. package/dist/components/lightbox.d.ts +100 -0
  185. package/dist/components/lightbox.js +439 -0
  186. package/dist/components/locale.d.ts +44 -0
  187. package/dist/components/locale.js +37 -0
  188. package/dist/components/logo.d.ts +54 -0
  189. package/dist/components/logo.js +96 -0
  190. package/dist/components/menu.d.ts +60 -0
  191. package/dist/components/menu.js +140 -0
  192. package/dist/components/menubar.d.ts +62 -0
  193. package/dist/components/menubar.js +223 -0
  194. package/dist/components/message.d.ts +42 -0
  195. package/dist/components/message.js +59 -0
  196. package/dist/components/meter.d.ts +31 -0
  197. package/dist/components/meter.js +27 -0
  198. package/dist/components/money-input.d.ts +80 -0
  199. package/dist/components/money-input.js +253 -0
  200. package/dist/components/native-select.d.ts +26 -0
  201. package/dist/components/native-select.js +35 -0
  202. package/dist/components/navigation-menu.d.ts +42 -0
  203. package/dist/components/navigation-menu.js +97 -0
  204. package/dist/components/number-field.d.ts +55 -0
  205. package/dist/components/number-field.js +164 -0
  206. package/dist/components/otp-field.d.ts +48 -0
  207. package/dist/components/otp-field.js +102 -0
  208. package/dist/components/pagination.d.ts +37 -0
  209. package/dist/components/pagination.js +81 -0
  210. package/dist/components/pdf-viewer.d.ts +134 -0
  211. package/dist/components/pdf-viewer.js +996 -0
  212. package/dist/components/phone-input.d.ts +79 -0
  213. package/dist/components/phone-input.js +282 -0
  214. package/dist/components/popover.d.ts +33 -0
  215. package/dist/components/popover.js +48 -0
  216. package/dist/components/preview-card.d.ts +25 -0
  217. package/dist/components/preview-card.js +22 -0
  218. package/dist/components/progress.d.ts +27 -0
  219. package/dist/components/progress.js +25 -0
  220. package/dist/components/prompt-input.d.ts +156 -0
  221. package/dist/components/prompt-input.js +415 -0
  222. package/dist/components/quote.d.ts +22 -0
  223. package/dist/components/quote.js +15 -0
  224. package/dist/components/radio-group.d.ts +18 -0
  225. package/dist/components/radio-group.js +34 -0
  226. package/dist/components/rating.d.ts +73 -0
  227. package/dist/components/rating.js +124 -0
  228. package/dist/components/reasoning.d.ts +46 -0
  229. package/dist/components/reasoning.js +73 -0
  230. package/dist/components/resizable.d.ts +47 -0
  231. package/dist/components/resizable.js +44 -0
  232. package/dist/components/response.d.ts +41 -0
  233. package/dist/components/response.js +566 -0
  234. package/dist/components/scroll-area.d.ts +33 -0
  235. package/dist/components/scroll-area.js +31 -0
  236. package/dist/components/select.d.ts +35 -0
  237. package/dist/components/select.js +71 -0
  238. package/dist/components/separator.d.ts +14 -0
  239. package/dist/components/separator.js +17 -0
  240. package/dist/components/sidebar.d.ts +163 -0
  241. package/dist/components/sidebar.js +505 -0
  242. package/dist/components/site-header.d.ts +93 -0
  243. package/dist/components/site-header.js +121 -0
  244. package/dist/components/skeleton.d.ts +31 -0
  245. package/dist/components/skeleton.js +29 -0
  246. package/dist/components/slider.d.ts +24 -0
  247. package/dist/components/slider.js +131 -0
  248. package/dist/components/sortable.d.ts +178 -0
  249. package/dist/components/sortable.js +1258 -0
  250. package/dist/components/sources.d.ts +40 -0
  251. package/dist/components/sources.js +42 -0
  252. package/dist/components/spinner.d.ts +48 -0
  253. package/dist/components/spinner.js +75 -0
  254. package/dist/components/stat.d.ts +91 -0
  255. package/dist/components/stat.js +141 -0
  256. package/dist/components/stepper.d.ts +71 -0
  257. package/dist/components/stepper.js +101 -0
  258. package/dist/components/suggestions.d.ts +20 -0
  259. package/dist/components/suggestions.js +18 -0
  260. package/dist/components/switch.d.ts +14 -0
  261. package/dist/components/switch.js +26 -0
  262. package/dist/components/table.d.ts +172 -0
  263. package/dist/components/table.js +895 -0
  264. package/dist/components/tabs.d.ts +25 -0
  265. package/dist/components/tabs.js +162 -0
  266. package/dist/components/tag.d.ts +41 -0
  267. package/dist/components/tag.js +88 -0
  268. package/dist/components/tags-input.d.ts +56 -0
  269. package/dist/components/tags-input.js +271 -0
  270. package/dist/components/textarea.d.ts +13 -0
  271. package/dist/components/textarea.js +16 -0
  272. package/dist/components/theme.d.ts +55 -0
  273. package/dist/components/theme.js +120 -0
  274. package/dist/components/time-field.d.ts +70 -0
  275. package/dist/components/time-field.js +450 -0
  276. package/dist/components/timeline.d.ts +92 -0
  277. package/dist/components/timeline.js +108 -0
  278. package/dist/components/tippy.d.ts +48 -0
  279. package/dist/components/tippy.js +648 -0
  280. package/dist/components/toast.d.ts +88 -0
  281. package/dist/components/toast.js +205 -0
  282. package/dist/components/toggle-group.d.ts +41 -0
  283. package/dist/components/toggle-group.js +140 -0
  284. package/dist/components/toggle.d.ts +23 -0
  285. package/dist/components/toggle.js +35 -0
  286. package/dist/components/tool-call.d.ts +63 -0
  287. package/dist/components/tool-call.js +68 -0
  288. package/dist/components/toolbar.d.ts +17 -0
  289. package/dist/components/toolbar.js +39 -0
  290. package/dist/components/tooltip.d.ts +42 -0
  291. package/dist/components/tooltip.js +47 -0
  292. package/dist/components/tour.d.ts +127 -0
  293. package/dist/components/tour.js +648 -0
  294. package/dist/components/tree.d.ts +75 -0
  295. package/dist/components/tree.js +649 -0
  296. package/dist/components/typography.d.ts +134 -0
  297. package/dist/components/typography.js +176 -0
  298. package/dist/components/video-player.d.ts +284 -0
  299. package/dist/components/video-player.js +1392 -0
  300. package/dist/illustration.d.ts +2 -0
  301. package/dist/illustration.js +7 -0
  302. package/dist/index.d.ts +93 -0
  303. package/dist/index.js +94 -0
  304. package/dist/lib/cn.d.ts +20 -0
  305. package/dist/lib/cn.js +38 -0
  306. package/dist/lib/code-highlight.d.ts +18 -0
  307. package/dist/lib/code-highlight.js +174 -0
  308. package/dist/lib/code-theme.d.ts +19 -0
  309. package/dist/lib/code-theme.js +140 -0
  310. package/dist/lib/collapse-row.d.ts +9 -0
  311. package/dist/lib/collapse-row.js +129 -0
  312. package/dist/lib/digit-roll.d.ts +21 -0
  313. package/dist/lib/digit-roll.js +31 -0
  314. package/dist/lib/editorial-assets.d.ts +16 -0
  315. package/dist/lib/editorial-assets.js +56 -0
  316. package/dist/lib/field-errors.d.ts +28 -0
  317. package/dist/lib/field-errors.js +24 -0
  318. package/dist/lib/field-value.d.ts +13 -0
  319. package/dist/lib/field-value.js +44 -0
  320. package/dist/lib/figure/catalog.d.ts +127 -0
  321. package/dist/lib/figure/catalog.js +130 -0
  322. package/dist/lib/figure/figures/automation.d.ts +7 -0
  323. package/dist/lib/figure/figures/automation.js +143 -0
  324. package/dist/lib/figure/figures/bar-chart.d.ts +7 -0
  325. package/dist/lib/figure/figures/bar-chart.js +99 -0
  326. package/dist/lib/figure/figures/brackets-classic.d.ts +11 -0
  327. package/dist/lib/figure/figures/brackets-classic.js +170 -0
  328. package/dist/lib/figure/figures/brackets.d.ts +8 -0
  329. package/dist/lib/figure/figures/brackets.js +84 -0
  330. package/dist/lib/figure/figures/city.d.ts +7 -0
  331. package/dist/lib/figure/figures/city.js +93 -0
  332. package/dist/lib/figure/figures/conveyor.d.ts +7 -0
  333. package/dist/lib/figure/figures/conveyor.js +97 -0
  334. package/dist/lib/figure/figures/database.d.ts +7 -0
  335. package/dist/lib/figure/figures/database.js +65 -0
  336. package/dist/lib/figure/figures/documents.d.ts +7 -0
  337. package/dist/lib/figure/figures/documents.js +83 -0
  338. package/dist/lib/figure/figures/inbox.d.ts +7 -0
  339. package/dist/lib/figure/figures/inbox.js +92 -0
  340. package/dist/lib/figure/figures/laptop.d.ts +7 -0
  341. package/dist/lib/figure/figures/laptop.js +67 -0
  342. package/dist/lib/figure/figures/monitor.d.ts +7 -0
  343. package/dist/lib/figure/figures/monitor.js +59 -0
  344. package/dist/lib/figure/figures/pipeline.d.ts +8 -0
  345. package/dist/lib/figure/figures/pipeline.js +117 -0
  346. package/dist/lib/figure/figures/platform.d.ts +7 -0
  347. package/dist/lib/figure/figures/platform.js +117 -0
  348. package/dist/lib/figure/figures/server.d.ts +7 -0
  349. package/dist/lib/figure/figures/server.js +115 -0
  350. package/dist/lib/figure/figures/spreadsheet.d.ts +7 -0
  351. package/dist/lib/figure/figures/spreadsheet.js +87 -0
  352. package/dist/lib/figure/figures/timeline.d.ts +7 -0
  353. package/dist/lib/figure/figures/timeline.js +65 -0
  354. package/dist/lib/figure/kernel.d.ts +152 -0
  355. package/dist/lib/figure/kernel.js +576 -0
  356. package/dist/lib/figure/parts.d.ts +42 -0
  357. package/dist/lib/figure/parts.js +126 -0
  358. package/dist/lib/form-reset.d.ts +11 -0
  359. package/dist/lib/form-reset.js +22 -0
  360. package/dist/lib/glide.d.ts +53 -0
  361. package/dist/lib/glide.js +138 -0
  362. package/dist/lib/graph-layout.d.ts +58 -0
  363. package/dist/lib/graph-layout.js +209 -0
  364. package/dist/lib/illustration-drawings.d.ts +89 -0
  365. package/dist/lib/illustration-drawings.js +539 -0
  366. package/dist/lib/illustration-info.d.ts +37 -0
  367. package/dist/lib/illustration-info.js +22 -0
  368. package/dist/lib/illustration-library.d.ts +87 -0
  369. package/dist/lib/illustration-library.js +352 -0
  370. package/dist/lib/logo-geometry.d.ts +29 -0
  371. package/dist/lib/logo-geometry.js +67 -0
  372. package/dist/lib/markdown-guard.d.ts +16 -0
  373. package/dist/lib/markdown-guard.js +123 -0
  374. package/dist/lib/merge-refs.d.ts +10 -0
  375. package/dist/lib/merge-refs.js +26 -0
  376. package/dist/lib/money.d.ts +73 -0
  377. package/dist/lib/money.js +343 -0
  378. package/dist/lib/motion.d.ts +6 -0
  379. package/dist/lib/motion.js +12 -0
  380. package/dist/lib/pdf-worker.d.ts +1 -0
  381. package/dist/lib/pdf-worker.js +6 -0
  382. package/dist/lib/pdf.d.ts +19 -0
  383. package/dist/lib/pdf.js +58 -0
  384. package/dist/lib/phone-countries.d.ts +1 -0
  385. package/dist/lib/phone-countries.js +281 -0
  386. package/dist/lib/phone.d.ts +90 -0
  387. package/dist/lib/phone.js +286 -0
  388. package/dist/lib/platform.d.ts +38 -0
  389. package/dist/lib/platform.js +75 -0
  390. package/dist/lib/room.d.ts +25 -0
  391. package/dist/lib/room.js +46 -0
  392. package/dist/lib/row-index.d.ts +15 -0
  393. package/dist/lib/row-index.js +136 -0
  394. package/dist/lib/table-fit.d.ts +143 -0
  395. package/dist/lib/table-fit.js +596 -0
  396. package/dist/lib/theme-script.d.ts +31 -0
  397. package/dist/lib/theme-script.js +49 -0
  398. package/dist/lib/tippy/pixels.d.ts +47 -0
  399. package/dist/lib/tippy/pixels.js +187 -0
  400. package/dist/lib/tippy/sprite.d.ts +86 -0
  401. package/dist/lib/tippy/sprite.js +753 -0
  402. package/dist/messages/de.d.ts +12 -0
  403. package/dist/messages/de.js +326 -0
  404. package/dist/styles/expressive.css +203 -0
  405. package/dist/styles/fonts.css +145 -0
  406. package/dist/styles/index.css +207 -0
  407. package/dist/styles/material.css +317 -0
  408. package/dist/styles/parts/ai.css +361 -0
  409. package/dist/styles/parts/brand.css +75 -0
  410. package/dist/styles/parts/controls.css +774 -0
  411. package/dist/styles/parts/data.css +222 -0
  412. package/dist/styles/parts/editorial.css +120 -0
  413. package/dist/styles/parts/feedback.css +340 -0
  414. package/dist/styles/parts/foundations.css +166 -0
  415. package/dist/styles/parts/graph.css +214 -0
  416. package/dist/styles/parts/inputs.css +261 -0
  417. package/dist/styles/parts/isometric.css +124 -0
  418. package/dist/styles/parts/navigation.css +424 -0
  419. package/dist/styles/parts/overlays.css +250 -0
  420. package/dist/styles/parts/pdf.css +154 -0
  421. package/dist/styles/parts/react-flow.css +519 -0
  422. package/dist/styles/tokens.css +299 -0
  423. package/dist/vite.d.ts +66 -0
  424. package/dist/vite.js +29 -0
  425. package/package.json +183 -5
@@ -0,0 +1,286 @@
1
+ /*
2
+ * Phone numbers for PhoneInput: E.164 ("+4915112345678"), split into a country and its national
3
+ * number, checked by length and grouped for reading. The countries come from libphonenumber's
4
+ * metadata, in phone-countries.ts (generated by `pnpm phone:data`, with what it holds); this is
5
+ * the table read and used.
6
+ */
7
+ import { latinDigits } from "./money.js";
8
+ import { PHONE_TABLE } from "./phone-countries.js";
9
+ function lengths(spec) {
10
+ const out = [];
11
+ for (const part of spec.split(",")) {
12
+ const [a, b] = part.split("-").map(Number);
13
+ for (let n = a; n <= (b ?? a); n++)
14
+ out.push(n);
15
+ }
16
+ return out;
17
+ }
18
+ function group(spec) {
19
+ if (spec.endsWith("+"))
20
+ return [Number(spec.slice(0, -1)), Infinity];
21
+ const [a, b] = spec.split("-").map(Number);
22
+ return [a, b ?? a];
23
+ }
24
+ const MAIN = new Set();
25
+ export const PHONE_COUNTRIES = PHONE_TABLE.trim()
26
+ .split("\n")
27
+ .map((line) => {
28
+ const [iso, code, len, trunk, ...rest] = line.trim().split(" ");
29
+ const dial = code.replace("*", "");
30
+ if (code.endsWith("*"))
31
+ MAIN.add(iso);
32
+ const exits = rest[0]?.startsWith("+") ? rest.shift().slice(1).split(",") : [];
33
+ const zeros = [];
34
+ while (rest[0]?.startsWith("!")) {
35
+ const [prefixes, len] = rest.shift().slice(1).split("/");
36
+ for (const prefix of prefixes.split(","))
37
+ zeros.push({ prefix, lengths: lengths(len) });
38
+ }
39
+ const leading = rest[0]?.startsWith("^") ? rest.shift().slice(1).split(",") : [];
40
+ return {
41
+ iso,
42
+ dial,
43
+ lengths: lengths(len),
44
+ trunks: trunk === "-" ? [] : trunk.replace("_", "").split("|"),
45
+ trunkApart: trunk.endsWith("_"),
46
+ exits,
47
+ zeros,
48
+ formats: rest.map((f) => {
49
+ const at = f.indexOf("=");
50
+ return {
51
+ lead: at < 0 ? null : new RegExp(`^(?:${f.slice(0, at)})`),
52
+ groups: f
53
+ .slice(at + 1)
54
+ .split(".")
55
+ .map(group),
56
+ };
57
+ }),
58
+ leading,
59
+ };
60
+ });
61
+ const BY_ISO = new Map(PHONE_COUNTRIES.map((c) => [c.iso, c]));
62
+ const BY_DIAL = new Map();
63
+ for (const c of PHONE_COUNTRIES) {
64
+ const list = BY_DIAL.get(c.dial) ?? [];
65
+ // The main country of a shared code first.
66
+ if (MAIN.has(c.iso))
67
+ list.unshift(c);
68
+ else
69
+ list.push(c);
70
+ BY_DIAL.set(c.dial, list);
71
+ }
72
+ // A territory without formats of its own (Canada, Jersey) writes numbers as its code's main
73
+ // country does, as in libphonenumber.
74
+ for (const list of BY_DIAL.values())
75
+ for (const c of list)
76
+ if (!c.formats.length && list[0] !== c) {
77
+ c.formats = list[0].formats;
78
+ c.trunkApart = list[0].trunkApart;
79
+ }
80
+ /** The country with this ISO code (any case), or undefined. */
81
+ export function phoneCountry(iso) {
82
+ return iso ? BY_ISO.get(iso.toUpperCase()) : undefined;
83
+ }
84
+ /** The countries with this calling code, the main one first. */
85
+ export function countriesWithCode(dial) {
86
+ return BY_DIAL.get(dial) ?? [];
87
+ }
88
+ /** E.164 allows 15 digits after the "+", the country code included. */
89
+ export const E164_MAX_DIGITS = 15;
90
+ /** The digits 0–9 in a text, from any script ("٠١٢" and full-width digits count). */
91
+ export function phoneDigits(text) {
92
+ return latinDigits(text.normalize("NFKC")).replace(/[^0-9]/g, "");
93
+ }
94
+ /**
95
+ * Of the countries sharing a calling code, the one a national number belongs to: the one whose
96
+ * leading digits it starts with (an area code: 416 is Canada), else the `current` country while
97
+ * the number can't tell them apart yet, else the code's main country.
98
+ */
99
+ function pickCountry(list, national, current) {
100
+ if (list.length === 1)
101
+ return list[0];
102
+ const byLeading = list.find((c) => c.leading.some((p) => national.startsWith(p)));
103
+ if (byLeading)
104
+ return byLeading;
105
+ const mine = list.find((c) => c.iso === current);
106
+ if (mine) {
107
+ // A country with no leading digits of its own can't be told from the main one.
108
+ if (mine.leading.length === 0)
109
+ return mine;
110
+ // Still one of its prefixes, as far as it goes: "41" may yet be 416, Toronto.
111
+ const undecided = mine.leading.some((p) => p.length > national.length && p.startsWith(national));
112
+ if (undecided)
113
+ return mine;
114
+ }
115
+ return list[0];
116
+ }
117
+ /**
118
+ * The country and national number of the digits after a "+": "442079460018" → GB, "2079460018".
119
+ * Calling codes are prefix-free, so the first one that matches is the one. Null while the digits
120
+ * don't start with a known code yet ("4", or "9" of "+9…").
121
+ */
122
+ export function splitInternational(digits, current) {
123
+ for (let len = 1; len <= 3 && len <= digits.length; len++) {
124
+ const list = countriesWithCode(digits.slice(0, len));
125
+ if (list.length) {
126
+ const national = digits.slice(len);
127
+ return { country: pickCountry(list, national, current), national };
128
+ }
129
+ }
130
+ return null;
131
+ }
132
+ /** An E.164 number as its country and national number; null for anything else. */
133
+ export function parsePhoneNumber(value, current) {
134
+ if (!value)
135
+ return null;
136
+ const m = /^\s*\+\s*([\d\s().-]+)$/.exec(value);
137
+ if (!m)
138
+ return null;
139
+ return splitInternational(phoneDigits(m[1]), current);
140
+ }
141
+ /** The E.164 form of a national number in a country, or null when there are no digits yet. */
142
+ export function toE164(country, national) {
143
+ return national ? `+${country.dial}${national}` : null;
144
+ }
145
+ /** The range of national numbers starting with 0 (see `PhoneCountry.zeros`) that digits are in. */
146
+ function zeroRange(digits, country) {
147
+ return country.zeros.find((z) => digits.startsWith(z.prefix));
148
+ }
149
+ /**
150
+ * The national prefixes people dial at home, at the front of what they typed: "020 7946 0018" in
151
+ * the UK starts with the trunk "0". A "0" (or "06") is one, as national numbers there don't start
152
+ * with 0 — except a few ranges (Rwanda's 06 fixed lines, India's freephone 000800), read whole once
153
+ * the digits start with one — and so is North America's "1". Others ("8" in Russia, where 812 is
154
+ * an area code) count only when the digits are a possible length without them and not with them,
155
+ * or too long.
156
+ */
157
+ export function trunkPrefix(digits, country) {
158
+ if (zeroRange(digits, country))
159
+ return "";
160
+ const { lengths } = country;
161
+ const n = digits.length;
162
+ for (const trunk of [...country.trunks].sort((a, b) => b.length - a.length)) {
163
+ if (!digits.startsWith(trunk))
164
+ continue;
165
+ if (trunk.startsWith("0") || (trunk === "1" && country.dial === "1"))
166
+ return trunk;
167
+ if (n > Math.max(...lengths))
168
+ return trunk;
169
+ if (!lengths.includes(n) && lengths.includes(n - trunk.length))
170
+ return trunk;
171
+ }
172
+ return "";
173
+ }
174
+ /** The national (significant) number of what someone typed, without the trunk prefix. */
175
+ export function nationalNumber(digits, country) {
176
+ return digits.slice(trunkPrefix(digits, country).length);
177
+ }
178
+ /** Groups of threes and fours for a number of `n` digits: 7 → 3 4, 10 → 3 3 4, 11 → 3 4 4. */
179
+ function defaultGroups(n) {
180
+ if (n <= 4)
181
+ return [n];
182
+ const r = n % 3;
183
+ if (r === 0)
184
+ return Array(n / 3).fill(3);
185
+ if (r === 1)
186
+ return [...Array((n - 4) / 3).fill(3), 4];
187
+ if (n === 5)
188
+ return [2, 3];
189
+ return [...Array((n - 8) / 3).fill(3), 4, 4];
190
+ }
191
+ /** The sizes of a format's groups for a number of `n` digits, the way its pattern would match. */
192
+ function sizesFor(groups, n) {
193
+ const fewest = groups.reduce((sum, g) => sum + g[0], 0);
194
+ // While it is being typed, each group at its shortest; past the longest, the rest joins the last.
195
+ if (n <= fewest)
196
+ return groups.map((g) => g[0]);
197
+ let rest = n - fewest;
198
+ return groups.map(([lo, hi]) => {
199
+ const size = Math.min(hi, lo + rest);
200
+ rest -= size - lo;
201
+ return size;
202
+ });
203
+ }
204
+ function groupsFor(national, country) {
205
+ const n = national.length;
206
+ const range = (f) => f.groups.reduce(([a, b], [lo, hi]) => [a + lo, b + hi], [0, 0]);
207
+ const matching = country.formats.filter((f) => !f.lead || f.lead.test(national));
208
+ if (matching.length) {
209
+ // libphonenumber's choice: the first that matches the leading digits and fits the length; while
210
+ // the number is short, the first it could still grow into; when too long, the longest.
211
+ const format = matching.find((f) => range(f)[0] <= n && n <= range(f)[1]) ??
212
+ matching.find((f) => n <= range(f)[1]) ??
213
+ matching.reduce((a, b) => (range(b)[1] > range(a)[1] ? b : a));
214
+ return sizesFor(format.groups, n);
215
+ }
216
+ // Without a pattern: grouped for the country's one length while it is being typed, else for n.
217
+ return defaultGroups(country.lengths.length === 1 ? Math.max(n, country.lengths[0]) : n);
218
+ }
219
+ /**
220
+ * A national number grouped for reading, with any trunk prefix kept in front of the first group
221
+ * (or apart, where the country writes it so: "8 912 345 67 89"): "2079460018" → "20 7946 0018",
222
+ * "02079460018" → "020 7946 0018". Digits past the pattern stay on the last group.
223
+ */
224
+ export function formatNational(digits, country) {
225
+ const trunk = trunkPrefix(digits, country);
226
+ const national = digits.slice(trunk.length);
227
+ if (!national)
228
+ return trunk;
229
+ const out = [];
230
+ let i = 0;
231
+ for (const size of groupsFor(national, country)) {
232
+ if (i >= national.length)
233
+ break;
234
+ out.push(national.slice(i, i + size));
235
+ i += size;
236
+ }
237
+ if (i < national.length)
238
+ out[out.length - 1] += national.slice(i);
239
+ out[0] = trunk + (trunk && country.trunkApart ? " " : "") + out[0];
240
+ return out.join(" ");
241
+ }
242
+ /**
243
+ * Whether a national number has one of its country's lengths, or is too short or too long; one of
244
+ * the ranges starting with 0 (`PhoneCountry.zeros`), one of that range's lengths.
245
+ */
246
+ export function checkPhoneLength(national, country) {
247
+ const n = national.length;
248
+ const lengths = zeroRange(national, country)?.lengths ?? country.lengths;
249
+ if (lengths.includes(n))
250
+ return "ok";
251
+ return n > Math.max(...lengths) ? "long" : "short";
252
+ }
253
+ /**
254
+ * What a person typed or pasted as an international number: "+44 20 7946 0018", "0044 20…",
255
+ * "+44 (0)20 7946 0018", "tel:+4420…", or after the current country's own international prefix
256
+ * ("011 44 20…" in the US). Returns the digits after the "+", or null when the text isn't written
257
+ * internationally — as for a national number that starts like an international prefix, so far
258
+ * (Korea's freephone 00798 …, Bulgaria's 00800 …).
259
+ */
260
+ export function internationalDigits(text, current) {
261
+ const t = text.normalize("NFKC").replace(/\(0\)/g, "").trim().replace(/^tel:/i, "");
262
+ if (/^[^\d+]*\+/.test(t))
263
+ return phoneDigits(t.slice(t.indexOf("+") + 1));
264
+ const digits = phoneDigits(t);
265
+ if (current?.zeros.some((z) => digits.startsWith(z.prefix) || z.prefix.startsWith(digits)))
266
+ return null;
267
+ const first = t.replace(/^[\s(]+/, "")[0];
268
+ const exits = [...(current?.exits ?? []), "00"].sort((a, b) => b.length - a.length);
269
+ for (const exit of exits)
270
+ // Not when a 0 follows: no calling code starts with one (as libphonenumber reads it).
271
+ if (digits.startsWith(exit) && digits[exit.length] !== "0" && first === exit[0])
272
+ return digits.slice(exit.length);
273
+ return null;
274
+ }
275
+ /** The region of a locale ("de-AT" → "AT", "de" → "DE", "en" → "US"), if the table has it. */
276
+ export function regionOfLocale(locale) {
277
+ if (!locale)
278
+ return undefined;
279
+ try {
280
+ const region = new Intl.Locale(locale).maximize().region;
281
+ return phoneCountry(region) ? region : undefined;
282
+ }
283
+ catch {
284
+ return undefined;
285
+ }
286
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Apple's keyboards say ⌘ where others say Ctrl. Read from User-Agent Client Hints where the
3
+ * browser has them (Chromium: "macOS"), else from `navigator.platform` (Safari, Firefox).
4
+ */
5
+ export declare function isApple(): boolean;
6
+ /** The modifier key for shortcuts on this device: "⌘" on Apple, "Ctrl" elsewhere. */
7
+ export declare const modKey: () => "Ctrl" | "⌘";
8
+ /**
9
+ * Whether a key event holds this device's shortcut modifier and not the other: ⌘ on Apple, Ctrl
10
+ * elsewhere. Not `metaKey || ctrlKey` — on a Mac, Ctrl+B and Ctrl+K move the caret in a text field.
11
+ * Read it in an event handler, never while rendering: the server cannot know the device.
12
+ */
13
+ export declare function modPressed(event: {
14
+ metaKey: boolean;
15
+ ctrlKey: boolean;
16
+ }): boolean;
17
+ /**
18
+ * The device's shortcut keys, for hints: the modifier (`mod`, "⌘" or "Ctrl"), and whether it
19
+ * has a keyboard at all (`hasKeyboard`) — not a touch-only phone or tablet, where nobody
20
+ * presses ⌘V. A tablet with a keyboard and trackpad counts as having keys. On the server, and in the first client render,
21
+ * it answers "Ctrl" with keys, then settles on the device's own answer.
22
+ */
23
+ export declare function useShortcutKeys(): {
24
+ mod: string;
25
+ hasKeyboard: boolean;
26
+ };
27
+ /** The names of the keys off Apple keyboards, as a language prints them: German "Strg", "Umschalt". */
28
+ export type KeyNames = Partial<Record<"ctrl" | "shift" | "alt" | "enter", string>>;
29
+ /**
30
+ * Each key of a shortcut as the device's keyboard prints it: `mod` is ⌘ or Ctrl, and so on.
31
+ * `names` renames the keys off Apple keyboards (Apple's are symbols in every language).
32
+ */
33
+ export declare function keyNames(keys: string[], mod: string, names?: KeyNames): string[];
34
+ /**
35
+ * A shortcut as text, the way each platform writes it in menus: run together on Apple ("⇧⌘Z",
36
+ * modifiers in Apple's order), joined with "+" elsewhere ("Ctrl+Shift+Z").
37
+ */
38
+ export declare function formatShortcut(keys: string[], mod: string, names?: KeyNames): string;
@@ -0,0 +1,75 @@
1
+ import * as React from "react";
2
+ /**
3
+ * Apple's keyboards say ⌘ where others say Ctrl. Read from User-Agent Client Hints where the
4
+ * browser has them (Chromium: "macOS"), else from `navigator.platform` (Safari, Firefox).
5
+ */
6
+ export function isApple() {
7
+ if (typeof navigator === "undefined")
8
+ return false;
9
+ const hints = navigator.userAgentData;
10
+ return /mac|iphone|ipad|ipod/i.test(hints?.platform || navigator.platform || "");
11
+ }
12
+ /** The modifier key for shortcuts on this device: "⌘" on Apple, "Ctrl" elsewhere. */
13
+ export const modKey = () => (isApple() ? "⌘" : "Ctrl");
14
+ /**
15
+ * Whether a key event holds this device's shortcut modifier and not the other: ⌘ on Apple, Ctrl
16
+ * elsewhere. Not `metaKey || ctrlKey` — on a Mac, Ctrl+B and Ctrl+K move the caret in a text field.
17
+ * Read it in an event handler, never while rendering: the server cannot know the device.
18
+ */
19
+ export function modPressed(event) {
20
+ return isApple() ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey;
21
+ }
22
+ const touchOnly = "(hover: none) and (pointer: coarse)";
23
+ const subscribeTouch = (onChange) => {
24
+ const query = window.matchMedia(touchOnly);
25
+ query.addEventListener("change", onChange);
26
+ return () => query.removeEventListener("change", onChange);
27
+ };
28
+ const noSubscribe = () => () => { };
29
+ /**
30
+ * The device's shortcut keys, for hints: the modifier (`mod`, "⌘" or "Ctrl"), and whether it
31
+ * has a keyboard at all (`hasKeyboard`) — not a touch-only phone or tablet, where nobody
32
+ * presses ⌘V. A tablet with a keyboard and trackpad counts as having keys. On the server, and in the first client render,
33
+ * it answers "Ctrl" with keys, then settles on the device's own answer.
34
+ */
35
+ export function useShortcutKeys() {
36
+ const mod = React.useSyncExternalStore(noSubscribe, modKey, () => "Ctrl");
37
+ const hasKeyboard = React.useSyncExternalStore(subscribeTouch, () => !window.matchMedia(touchOnly).matches, () => true);
38
+ return { mod, hasKeyboard };
39
+ }
40
+ /** Keys that are written differently on Apple keyboards and on others. */
41
+ const appleKeys = { mod: "⌘", shift: "⇧", alt: "⌥", ctrl: "⌃", enter: "↵" };
42
+ const otherKeys = {
43
+ mod: "Ctrl",
44
+ shift: "Shift",
45
+ alt: "Alt",
46
+ ctrl: "Ctrl",
47
+ enter: "Enter",
48
+ };
49
+ /**
50
+ * Each key of a shortcut as the device's keyboard prints it: `mod` is ⌘ or Ctrl, and so on.
51
+ * `names` renames the keys off Apple keyboards (Apple's are symbols in every language).
52
+ */
53
+ export function keyNames(keys, mod, names) {
54
+ const own = mod === "⌘"
55
+ ? appleKeys
56
+ : names
57
+ ? { ...otherKeys, ...names, mod: names.ctrl ?? otherKeys.mod }
58
+ : otherKeys;
59
+ return keys.map((key) => own[key.toLowerCase()] ?? key);
60
+ }
61
+ /**
62
+ * A shortcut as text, the way each platform writes it in menus: run together on Apple ("⇧⌘Z",
63
+ * modifiers in Apple's order), joined with "+" elsewhere ("Ctrl+Shift+Z").
64
+ */
65
+ export function formatShortcut(keys, mod, names) {
66
+ if (mod !== "⌘")
67
+ return keyNames(keys, mod, names).join("+");
68
+ const order = ["ctrl", "alt", "shift", "mod"];
69
+ const sorted = [...keys].sort((a, b) => {
70
+ const ia = order.indexOf(a.toLowerCase());
71
+ const ib = order.indexOf(b.toLowerCase());
72
+ return (ia === -1 ? order.length : ia) - (ib === -1 ? order.length : ib);
73
+ });
74
+ return keyNames(sorted, mod).join("");
75
+ }
@@ -0,0 +1,25 @@
1
+ import * as React from "react";
2
+ /** The nearest ancestor that scrolls sideways (auto/scroll), or null for the window. */
3
+ export declare function roomOf(el: Element | null): HTMLElement | null;
4
+ /**
5
+ * A collision boundary for a popup opened from `trigger`: its room's left and right edges, the
6
+ * window's top and bottom. Undefined when the trigger has no room of its own (the window).
7
+ *
8
+ * The edges are read each time the popup is positioned, not once: the room moves when the window
9
+ * resizes or the layout around it changes, and a popup kept to where the room used to be would
10
+ * open shrunk or away from its trigger.
11
+ */
12
+ export declare function roomBounds(trigger: Element | null): {
13
+ readonly x: number;
14
+ y: number;
15
+ readonly width: number;
16
+ readonly height: number;
17
+ } | undefined;
18
+ /** Lets a popup find the trigger that opened it: the trigger registers, the content reads. */
19
+ export interface TriggerRoom {
20
+ trigger: HTMLElement | null;
21
+ setTrigger: (el: HTMLElement | null) => void;
22
+ }
23
+ export declare const TriggerRoomContext: React.Context<TriggerRoom | null>;
24
+ /** State for a popup root: the trigger it opens from. Provide it with `TriggerRoomContext`. */
25
+ export declare function useTriggerRoom(): TriggerRoom;
@@ -0,0 +1,46 @@
1
+ import * as React from "react";
2
+ /*
3
+ * A popup is portalled out of the panel its trigger sits in, so by default it only keeps inside
4
+ * the window. Across, it should keep inside the room its trigger has — the nearest scrolling
5
+ * container: a side panel, a dialog body, the docs' narrowed stage. Up and down it may still use
6
+ * the window, or a short panel would crop it.
7
+ */
8
+ /** The nearest ancestor that scrolls sideways (auto/scroll), or null for the window. */
9
+ export function roomOf(el) {
10
+ let room = el?.parentElement ?? null;
11
+ while (room && room !== document.body && !/auto|scroll/.test(getComputedStyle(room).overflowX)) {
12
+ room = room.parentElement;
13
+ }
14
+ return room && room !== document.body ? room : null;
15
+ }
16
+ /**
17
+ * A collision boundary for a popup opened from `trigger`: its room's left and right edges, the
18
+ * window's top and bottom. Undefined when the trigger has no room of its own (the window).
19
+ *
20
+ * The edges are read each time the popup is positioned, not once: the room moves when the window
21
+ * resizes or the layout around it changes, and a popup kept to where the room used to be would
22
+ * open shrunk or away from its trigger.
23
+ */
24
+ export function roomBounds(trigger) {
25
+ const room = roomOf(trigger);
26
+ if (!room)
27
+ return undefined;
28
+ return {
29
+ get x() {
30
+ return room.getBoundingClientRect().left;
31
+ },
32
+ y: 0,
33
+ get width() {
34
+ return room.getBoundingClientRect().width;
35
+ },
36
+ get height() {
37
+ return window.innerHeight;
38
+ },
39
+ };
40
+ }
41
+ export const TriggerRoomContext = React.createContext(null);
42
+ /** State for a popup root: the trigger it opens from. Provide it with `TriggerRoomContext`. */
43
+ export function useTriggerRoom() {
44
+ const [trigger, setTrigger] = React.useState(null);
45
+ return React.useMemo(() => ({ trigger, setTrigger }), [trigger]);
46
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * One number per row that sorts as its value does: numbers and dates as themselves, text by its
3
+ * place among the column's texts in `collator`'s order, an empty cell below everything (first going
4
+ * up, last going down, as DataTable sorts it).
5
+ */
6
+ export declare function columnRanks(count: number, read: (index: number) => unknown, collator: Intl.Collator): Float64Array<ArrayBuffer>;
7
+ /** Every row index, ordered by the keys in turn (each ascending unless `desc`), then by index. */
8
+ export declare function sortedOrder(count: number, keys: readonly {
9
+ ranks: Float64Array;
10
+ desc: boolean;
11
+ }[]): Uint32Array<ArrayBuffer>;
12
+ /** Each row's searchable values as one line of lower-case text, as TanStack's `includesString` reads them. */
13
+ export declare function searchLines(count: number, readers: readonly ((index: number) => unknown)[]): string[];
14
+ /** The indices in `order` whose line holds `query` (ignoring case), in that order. */
15
+ export declare function matching(order: Uint32Array, lines: readonly string[], query: string): Uint32Array<ArrayBuffer>;
@@ -0,0 +1,136 @@
1
+ /*
2
+ * Sorting and searching many rows without an object per row, for DataTable's large mode: each
3
+ * sorted column becomes one number per row (its rank), each row one line of lower-case text to
4
+ * search, and an order is an array of row indices.
5
+ */
6
+ /** null, undefined, NaN and "": a cell with nothing in it. */
7
+ const isBlank = (value) => value == null || value === "" || (typeof value === "number" && Number.isNaN(value));
8
+ /** Past this many different texts in a column, they are ordered by `naturalCompare`, not the collator. */
9
+ const COLLATE_UP_TO = 50_000;
10
+ /**
11
+ * One number per row that sorts as its value does: numbers and dates as themselves, text by its
12
+ * place among the column's texts in `collator`'s order, an empty cell below everything (first going
13
+ * up, last going down, as DataTable sorts it).
14
+ */
15
+ export function columnRanks(count, read, collator) {
16
+ const ranks = new Float64Array(count);
17
+ const values = new Array(count);
18
+ let text = false;
19
+ for (let i = 0; i < count; i++) {
20
+ const value = read(i);
21
+ values[i] = value;
22
+ if (typeof value === "string" && value !== "")
23
+ text = true;
24
+ }
25
+ if (!text) {
26
+ for (let i = 0; i < count; i++) {
27
+ const value = values[i];
28
+ ranks[i] = isBlank(value)
29
+ ? -Infinity
30
+ : value instanceof Date
31
+ ? value.getTime()
32
+ : typeof value === "boolean"
33
+ ? Number(value)
34
+ : Number(value);
35
+ if (Number.isNaN(ranks[i]))
36
+ ranks[i] = -Infinity;
37
+ }
38
+ return ranks;
39
+ }
40
+ // Text (and anything mixed in with it, as its text): each different one sorted once.
41
+ const distinct = new Map();
42
+ for (let i = 0; i < count; i++)
43
+ if (!isBlank(values[i]))
44
+ distinct.set(String(values[i]), 0);
45
+ const texts = [...distinct.keys()];
46
+ if (texts.length <= COLLATE_UP_TO)
47
+ texts.sort(collator.compare);
48
+ else {
49
+ const keys = new Map(texts.map((t) => [t, foldText(t)]));
50
+ texts.sort((a, b) => naturalCompare(keys.get(a), keys.get(b)) || collator.compare(a, b));
51
+ }
52
+ texts.forEach((t, rank) => distinct.set(t, rank));
53
+ for (let i = 0; i < count; i++)
54
+ ranks[i] = isBlank(values[i]) ? -Infinity : distinct.get(String(values[i]));
55
+ return ranks;
56
+ }
57
+ /** Lower case without accents: close to the collator's first level, and fast to compare. */
58
+ const foldText = (text) => text
59
+ .normalize("NFD")
60
+ .replace(/\p{Diacritic}/gu, "")
61
+ .toLowerCase();
62
+ /** Compares runs of digits by value ("item2" before "item10") and the rest by code unit. */
63
+ function naturalCompare(a, b) {
64
+ let i = 0;
65
+ let j = 0;
66
+ while (i < a.length && j < b.length) {
67
+ const ca = a.charCodeAt(i);
68
+ const cb = b.charCodeAt(j);
69
+ if (isDigit(ca) && isDigit(cb)) {
70
+ let ei = i;
71
+ let ej = j;
72
+ while (ei < a.length && isDigit(a.charCodeAt(ei)))
73
+ ei++;
74
+ while (ej < b.length && isDigit(b.charCodeAt(ej)))
75
+ ej++;
76
+ const na = a.slice(i, ei).replace(/^0+(?=\d)/, "");
77
+ const nb = b.slice(j, ej).replace(/^0+(?=\d)/, "");
78
+ if (na.length !== nb.length)
79
+ return na.length - nb.length;
80
+ if (na !== nb)
81
+ return na < nb ? -1 : 1;
82
+ i = ei;
83
+ j = ej;
84
+ continue;
85
+ }
86
+ if (ca !== cb)
87
+ return ca - cb;
88
+ i++;
89
+ j++;
90
+ }
91
+ return a.length - i - (b.length - j);
92
+ }
93
+ const isDigit = (code) => code >= 48 && code <= 57;
94
+ /** Every row index, ordered by the keys in turn (each ascending unless `desc`), then by index. */
95
+ export function sortedOrder(count, keys) {
96
+ const order = new Uint32Array(count);
97
+ for (let i = 0; i < count; i++)
98
+ order[i] = i;
99
+ if (keys.length === 0)
100
+ return order;
101
+ return order.sort((a, b) => {
102
+ for (const { ranks, desc } of keys) {
103
+ const ra = ranks[a];
104
+ const rb = ranks[b];
105
+ if (ra !== rb)
106
+ return (ra < rb ? -1 : 1) * (desc ? -1 : 1);
107
+ }
108
+ return a - b;
109
+ });
110
+ }
111
+ /** Each row's searchable values as one line of lower-case text, as TanStack's `includesString` reads them. */
112
+ export function searchLines(count, readers) {
113
+ const lines = new Array(count);
114
+ for (let i = 0; i < count; i++) {
115
+ let line = "";
116
+ for (const read of readers) {
117
+ const value = read(i);
118
+ if (value != null)
119
+ line += `${String(value).toLowerCase()}\u0000`;
120
+ }
121
+ lines[i] = line;
122
+ }
123
+ return lines;
124
+ }
125
+ /** The indices in `order` whose line holds `query` (ignoring case), in that order. */
126
+ export function matching(order, lines, query) {
127
+ const q = query.toLowerCase();
128
+ const out = new Uint32Array(order.length);
129
+ let n = 0;
130
+ for (let k = 0; k < order.length; k++) {
131
+ const i = order[k];
132
+ if (lines[i].includes(q))
133
+ out[n++] = i;
134
+ }
135
+ return out.subarray(0, n);
136
+ }