@syware/jlib 0.0.0-stage → 0.1.3

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 (331) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +133 -2
  3. package/dist/all.d.ts +1 -0
  4. package/dist/all.js +75 -0
  5. package/dist/atoms/jl-avatar.css_raw.js +3 -0
  6. package/dist/atoms/jl-avatar.d.ts +52 -0
  7. package/dist/atoms/jl-avatar.js +167 -0
  8. package/dist/atoms/jl-badge.css_raw.js +3 -0
  9. package/dist/atoms/jl-badge.d.ts +32 -0
  10. package/dist/atoms/jl-badge.js +60 -0
  11. package/dist/atoms/jl-button.css_raw.js +3 -0
  12. package/dist/atoms/jl-button.d.ts +70 -0
  13. package/dist/atoms/jl-button.js +146 -0
  14. package/dist/atoms/jl-checkbox.css_raw.js +3 -0
  15. package/dist/atoms/jl-checkbox.d.ts +61 -0
  16. package/dist/atoms/jl-checkbox.js +149 -0
  17. package/dist/atoms/jl-chip.css_raw.js +3 -0
  18. package/dist/atoms/jl-chip.d.ts +59 -0
  19. package/dist/atoms/jl-chip.js +164 -0
  20. package/dist/atoms/jl-divider.css_raw.js +3 -0
  21. package/dist/atoms/jl-divider.d.ts +26 -0
  22. package/dist/atoms/jl-divider.js +59 -0
  23. package/dist/atoms/jl-icon.css_raw.js +3 -0
  24. package/dist/atoms/jl-icon.d.ts +25 -0
  25. package/dist/atoms/jl-icon.js +41 -0
  26. package/dist/atoms/jl-input.css_raw.js +3 -0
  27. package/dist/atoms/jl-input.d.ts +112 -0
  28. package/dist/atoms/jl-input.js +202 -0
  29. package/dist/atoms/jl-kbd.css_raw.js +3 -0
  30. package/dist/atoms/jl-kbd.d.ts +17 -0
  31. package/dist/atoms/jl-kbd.js +62 -0
  32. package/dist/atoms/jl-link.css_raw.js +3 -0
  33. package/dist/atoms/jl-link.d.ts +37 -0
  34. package/dist/atoms/jl-link.js +86 -0
  35. package/dist/atoms/jl-progress-ring.css_raw.js +3 -0
  36. package/dist/atoms/jl-progress-ring.d.ts +49 -0
  37. package/dist/atoms/jl-progress-ring.js +132 -0
  38. package/dist/atoms/jl-progress.css_raw.js +3 -0
  39. package/dist/atoms/jl-progress.d.ts +43 -0
  40. package/dist/atoms/jl-progress.js +109 -0
  41. package/dist/atoms/jl-rating.css_raw.js +3 -0
  42. package/dist/atoms/jl-rating.d.ts +73 -0
  43. package/dist/atoms/jl-rating.js +184 -0
  44. package/dist/atoms/jl-select.css_raw.js +3 -0
  45. package/dist/atoms/jl-select.d.ts +70 -0
  46. package/dist/atoms/jl-select.js +146 -0
  47. package/dist/atoms/jl-skeleton.css_raw.js +3 -0
  48. package/dist/atoms/jl-skeleton.d.ts +34 -0
  49. package/dist/atoms/jl-skeleton.js +63 -0
  50. package/dist/atoms/jl-slider.css_raw.js +3 -0
  51. package/dist/atoms/jl-slider.d.ts +65 -0
  52. package/dist/atoms/jl-slider.js +143 -0
  53. package/dist/atoms/jl-spinner.css_raw.js +3 -0
  54. package/dist/atoms/jl-spinner.d.ts +16 -0
  55. package/dist/atoms/jl-spinner.js +26 -0
  56. package/dist/atoms/jl-switch.css_raw.js +3 -0
  57. package/dist/atoms/jl-switch.d.ts +57 -0
  58. package/dist/atoms/jl-switch.js +125 -0
  59. package/dist/atoms/jl-textarea.css_raw.js +3 -0
  60. package/dist/atoms/jl-textarea.d.ts +81 -0
  61. package/dist/atoms/jl-textarea.js +148 -0
  62. package/dist/base/jl-element.d.ts +16 -0
  63. package/dist/base/jl-element.js +35 -0
  64. package/dist/base/jl-form-control.d.ts +29 -0
  65. package/dist/base/jl-form-control.js +44 -0
  66. package/dist/index.d.ts +119 -0
  67. package/dist/index.js +72 -0
  68. package/dist/lib/arrow.d.ts +6 -0
  69. package/dist/lib/arrow.js +15 -0
  70. package/dist/lib/attributes.d.ts +9 -0
  71. package/dist/lib/attributes.js +22 -0
  72. package/dist/lib/avatar.d.ts +11 -0
  73. package/dist/lib/avatar.js +37 -0
  74. package/dist/lib/calendar.d.ts +48 -0
  75. package/dist/lib/calendar.js +166 -0
  76. package/dist/lib/css-length.d.ts +2 -0
  77. package/dist/lib/css-length.js +8 -0
  78. package/dist/lib/define.d.ts +9 -0
  79. package/dist/lib/define.js +9 -0
  80. package/dist/lib/dom.d.ts +4 -0
  81. package/dist/lib/dom.js +16 -0
  82. package/dist/lib/files.d.ts +18 -0
  83. package/dist/lib/files.js +89 -0
  84. package/dist/lib/floating.d.ts +13 -0
  85. package/dist/lib/floating.js +127 -0
  86. package/dist/lib/fuzzy.d.ts +26 -0
  87. package/dist/lib/fuzzy.js +149 -0
  88. package/dist/lib/highlight.d.ts +5 -0
  89. package/dist/lib/highlight.js +267 -0
  90. package/dist/lib/hotkey.d.ts +9 -0
  91. package/dist/lib/hotkey.js +101 -0
  92. package/dist/lib/icon-set.d.ts +95 -0
  93. package/dist/lib/icon-set.js +97 -0
  94. package/dist/lib/icons.d.ts +12 -0
  95. package/dist/lib/icons.js +39 -0
  96. package/dist/lib/indicator.d.ts +6 -0
  97. package/dist/lib/indicator.js +18 -0
  98. package/dist/lib/keep-in-view.d.ts +5 -0
  99. package/dist/lib/keep-in-view.js +15 -0
  100. package/dist/lib/key-shortcut.d.ts +20 -0
  101. package/dist/lib/key-shortcut.js +100 -0
  102. package/dist/lib/keycaps.d.ts +8 -0
  103. package/dist/lib/keycaps.js +162 -0
  104. package/dist/lib/locale.d.ts +4 -0
  105. package/dist/lib/locale.js +13 -0
  106. package/dist/lib/nav-tree.d.ts +9 -0
  107. package/dist/lib/nav-tree.js +30 -0
  108. package/dist/lib/numeric.d.ts +20 -0
  109. package/dist/lib/numeric.js +50 -0
  110. package/dist/lib/option-filter.d.ts +29 -0
  111. package/dist/lib/option-filter.js +108 -0
  112. package/dist/lib/option-groups.d.ts +6 -0
  113. package/dist/lib/option-groups.js +26 -0
  114. package/dist/lib/options.d.ts +5 -0
  115. package/dist/lib/options.js +24 -0
  116. package/dist/lib/pagination.d.ts +9 -0
  117. package/dist/lib/pagination.js +52 -0
  118. package/dist/lib/palette.d.ts +8 -0
  119. package/dist/lib/palette.js +46 -0
  120. package/dist/lib/progress.d.ts +20 -0
  121. package/dist/lib/progress.js +33 -0
  122. package/dist/lib/rating.d.ts +7 -0
  123. package/dist/lib/rating.js +26 -0
  124. package/dist/lib/roving-index.d.ts +10 -0
  125. package/dist/lib/roving-index.js +32 -0
  126. package/dist/lib/roving.d.ts +11 -0
  127. package/dist/lib/roving.js +21 -0
  128. package/dist/lib/slots.d.ts +2 -0
  129. package/dist/lib/slots.js +6 -0
  130. package/dist/lib/sparkline.d.ts +11 -0
  131. package/dist/lib/sparkline.js +42 -0
  132. package/dist/lib/split.d.ts +12 -0
  133. package/dist/lib/split.js +37 -0
  134. package/dist/lib/surface.d.ts +7 -0
  135. package/dist/lib/surface.js +28 -0
  136. package/dist/lib/table.d.ts +30 -0
  137. package/dist/lib/table.js +110 -0
  138. package/dist/lib/tags.d.ts +14 -0
  139. package/dist/lib/tags.js +29 -0
  140. package/dist/lib/text.d.ts +5 -0
  141. package/dist/lib/text.js +13 -0
  142. package/dist/lib/tokens.d.ts +5 -0
  143. package/dist/lib/tokens.js +15 -0
  144. package/dist/lib/tree.d.ts +16 -0
  145. package/dist/lib/tree.js +89 -0
  146. package/dist/lib/trend.d.ts +3 -0
  147. package/dist/lib/trend.js +15 -0
  148. package/dist/lib/trigger.d.ts +11 -0
  149. package/dist/lib/trigger.js +34 -0
  150. package/dist/molecules/jl-accordion-item.css_raw.js +3 -0
  151. package/dist/molecules/jl-accordion-item.d.ts +34 -0
  152. package/dist/molecules/jl-accordion-item.js +82 -0
  153. package/dist/molecules/jl-accordion.css_raw.js +3 -0
  154. package/dist/molecules/jl-accordion.d.ts +27 -0
  155. package/dist/molecules/jl-accordion.js +61 -0
  156. package/dist/molecules/jl-alert.css_raw.js +3 -0
  157. package/dist/molecules/jl-alert.d.ts +38 -0
  158. package/dist/molecules/jl-alert.js +131 -0
  159. package/dist/molecules/jl-avatar-group.css_raw.js +3 -0
  160. package/dist/molecules/jl-avatar-group.d.ts +28 -0
  161. package/dist/molecules/jl-avatar-group.js +69 -0
  162. package/dist/molecules/jl-breadcrumb.css_raw.js +3 -0
  163. package/dist/molecules/jl-breadcrumb.d.ts +35 -0
  164. package/dist/molecules/jl-breadcrumb.js +126 -0
  165. package/dist/molecules/jl-calendar.css_raw.js +3 -0
  166. package/dist/molecules/jl-calendar.d.ts +101 -0
  167. package/dist/molecules/jl-calendar.js +314 -0
  168. package/dist/molecules/jl-card.css_raw.js +3 -0
  169. package/dist/molecules/jl-card.d.ts +46 -0
  170. package/dist/molecules/jl-card.js +172 -0
  171. package/dist/molecules/jl-code-block.css_raw.js +3 -0
  172. package/dist/molecules/jl-code-block.d.ts +44 -0
  173. package/dist/molecules/jl-code-block.js +106 -0
  174. package/dist/molecules/jl-combobox.css_raw.js +3 -0
  175. package/dist/molecules/jl-combobox.d.ts +120 -0
  176. package/dist/molecules/jl-combobox.js +450 -0
  177. package/dist/molecules/jl-copy-button.css_raw.js +3 -0
  178. package/dist/molecules/jl-copy-button.d.ts +31 -0
  179. package/dist/molecules/jl-copy-button.js +69 -0
  180. package/dist/molecules/jl-date-picker.css_raw.js +3 -0
  181. package/dist/molecules/jl-date-picker.d.ts +109 -0
  182. package/dist/molecules/jl-date-picker.js +322 -0
  183. package/dist/molecules/jl-empty.css_raw.js +3 -0
  184. package/dist/molecules/jl-empty.d.ts +32 -0
  185. package/dist/molecules/jl-empty.js +94 -0
  186. package/dist/molecules/jl-field.css_raw.js +3 -0
  187. package/dist/molecules/jl-field.d.ts +49 -0
  188. package/dist/molecules/jl-field.js +147 -0
  189. package/dist/molecules/jl-file-drop.css_raw.js +3 -0
  190. package/dist/molecules/jl-file-drop.d.ts +93 -0
  191. package/dist/molecules/jl-file-drop.js +366 -0
  192. package/dist/molecules/jl-list-item.css_raw.js +3 -0
  193. package/dist/molecules/jl-list-item.d.ts +56 -0
  194. package/dist/molecules/jl-list-item.js +176 -0
  195. package/dist/molecules/jl-menu.css_raw.js +3 -0
  196. package/dist/molecules/jl-menu.d.ts +62 -0
  197. package/dist/molecules/jl-menu.js +288 -0
  198. package/dist/molecules/jl-number-input.css_raw.js +3 -0
  199. package/dist/molecules/jl-number-input.d.ts +81 -0
  200. package/dist/molecules/jl-number-input.js +220 -0
  201. package/dist/molecules/jl-pagination.css_raw.js +3 -0
  202. package/dist/molecules/jl-pagination.d.ts +59 -0
  203. package/dist/molecules/jl-pagination.js +172 -0
  204. package/dist/molecules/jl-popover.css_raw.js +3 -0
  205. package/dist/molecules/jl-popover.d.ts +49 -0
  206. package/dist/molecules/jl-popover.js +152 -0
  207. package/dist/molecules/jl-radio-group.css_raw.js +3 -0
  208. package/dist/molecules/jl-radio-group.d.ts +71 -0
  209. package/dist/molecules/jl-radio-group.js +202 -0
  210. package/dist/molecules/jl-search.css_raw.js +3 -0
  211. package/dist/molecules/jl-search.d.ts +71 -0
  212. package/dist/molecules/jl-search.js +210 -0
  213. package/dist/molecules/jl-segmented.css_raw.js +3 -0
  214. package/dist/molecules/jl-segmented.d.ts +65 -0
  215. package/dist/molecules/jl-segmented.js +187 -0
  216. package/dist/molecules/jl-stat.css_raw.js +3 -0
  217. package/dist/molecules/jl-stat.d.ts +55 -0
  218. package/dist/molecules/jl-stat.js +169 -0
  219. package/dist/molecules/jl-steps.css_raw.js +3 -0
  220. package/dist/molecules/jl-steps.d.ts +44 -0
  221. package/dist/molecules/jl-steps.js +118 -0
  222. package/dist/molecules/jl-tab-panel.css_raw.js +3 -0
  223. package/dist/molecules/jl-tab-panel.d.ts +35 -0
  224. package/dist/molecules/jl-tab-panel.js +35 -0
  225. package/dist/molecules/jl-tabs.css_raw.js +3 -0
  226. package/dist/molecules/jl-tabs.d.ts +51 -0
  227. package/dist/molecules/jl-tabs.js +198 -0
  228. package/dist/molecules/jl-tag-input.css_raw.js +3 -0
  229. package/dist/molecules/jl-tag-input.d.ts +103 -0
  230. package/dist/molecules/jl-tag-input.js +429 -0
  231. package/dist/molecules/jl-timeline.css_raw.js +3 -0
  232. package/dist/molecules/jl-timeline.d.ts +28 -0
  233. package/dist/molecules/jl-timeline.js +81 -0
  234. package/dist/molecules/jl-toast.css_raw.js +3 -0
  235. package/dist/molecules/jl-toast.d.ts +75 -0
  236. package/dist/molecules/jl-toast.js +274 -0
  237. package/dist/molecules/jl-tooltip.css_raw.js +3 -0
  238. package/dist/molecules/jl-tooltip.d.ts +44 -0
  239. package/dist/molecules/jl-tooltip.js +160 -0
  240. package/dist/organisms/jl-command-palette.css_raw.js +3 -0
  241. package/dist/organisms/jl-command-palette.d.ts +60 -0
  242. package/dist/organisms/jl-command-palette.js +285 -0
  243. package/dist/organisms/jl-confirm.css_raw.js +3 -0
  244. package/dist/organisms/jl-confirm.d.ts +56 -0
  245. package/dist/organisms/jl-confirm.js +132 -0
  246. package/dist/organisms/jl-dialog.css_raw.js +3 -0
  247. package/dist/organisms/jl-dialog.d.ts +43 -0
  248. package/dist/organisms/jl-dialog.js +120 -0
  249. package/dist/organisms/jl-drawer.css_raw.js +3 -0
  250. package/dist/organisms/jl-drawer.d.ts +50 -0
  251. package/dist/organisms/jl-drawer.js +141 -0
  252. package/dist/organisms/jl-navbar.css_raw.js +3 -0
  253. package/dist/organisms/jl-navbar.d.ts +32 -0
  254. package/dist/organisms/jl-navbar.js +121 -0
  255. package/dist/organisms/jl-page-header.css_raw.js +3 -0
  256. package/dist/organisms/jl-page-header.d.ts +26 -0
  257. package/dist/organisms/jl-page-header.js +85 -0
  258. package/dist/organisms/jl-side-nav.css_raw.js +3 -0
  259. package/dist/organisms/jl-side-nav.d.ts +60 -0
  260. package/dist/organisms/jl-side-nav.js +269 -0
  261. package/dist/organisms/jl-table.css_raw.js +3 -0
  262. package/dist/organisms/jl-table.d.ts +109 -0
  263. package/dist/organisms/jl-table.js +318 -0
  264. package/dist/organisms/jl-toaster.css_raw.js +3 -0
  265. package/dist/organisms/jl-toaster.d.ts +48 -0
  266. package/dist/organisms/jl-toaster.js +142 -0
  267. package/dist/organisms/jl-tree.css_raw.js +3 -0
  268. package/dist/organisms/jl-tree.d.ts +59 -0
  269. package/dist/organisms/jl-tree.js +198 -0
  270. package/dist/styles/base.css_raw.js +3 -0
  271. package/dist/styles/control.css_raw.js +3 -0
  272. package/dist/styles/floating.css_raw.js +3 -0
  273. package/dist/styles/shared.d.ts +8 -0
  274. package/dist/styles/shared.js +14 -0
  275. package/dist/styles/tokens.css_raw.js +3 -0
  276. package/dist/templates/jl-app-shell.css_raw.js +3 -0
  277. package/dist/templates/jl-app-shell.d.ts +37 -0
  278. package/dist/templates/jl-app-shell.js +150 -0
  279. package/dist/templates/jl-split-view.css_raw.js +3 -0
  280. package/dist/templates/jl-split-view.d.ts +49 -0
  281. package/dist/templates/jl-split-view.js +149 -0
  282. package/dist/tokens.css +188 -0
  283. package/dist/types/calendar.types.d.ts +11 -0
  284. package/dist/types/files.types.d.ts +23 -0
  285. package/dist/types/floating.types.d.ts +13 -0
  286. package/dist/types/fuzzy.types.d.ts +10 -0
  287. package/dist/types/highlight.types.d.ts +6 -0
  288. package/dist/types/hotkey.types.d.ts +19 -0
  289. package/dist/types/jl-accordion.types.d.ts +2 -0
  290. package/dist/types/jl-avatar.types.d.ts +10 -0
  291. package/dist/types/jl-breadcrumb.types.d.ts +6 -0
  292. package/dist/types/jl-button.types.d.ts +3 -0
  293. package/dist/types/jl-card.types.d.ts +2 -0
  294. package/dist/types/jl-chip.types.d.ts +1 -0
  295. package/dist/types/jl-combobox.types.d.ts +8 -0
  296. package/dist/types/jl-command-palette.types.d.ts +22 -0
  297. package/dist/types/jl-confirm.types.d.ts +10 -0
  298. package/dist/types/jl-dialog.types.d.ts +1 -0
  299. package/dist/types/jl-divider.types.d.ts +2 -0
  300. package/dist/types/jl-drawer.types.d.ts +4 -0
  301. package/dist/types/jl-empty.types.d.ts +2 -0
  302. package/dist/types/jl-field.types.d.ts +2 -0
  303. package/dist/types/jl-input.types.d.ts +1 -0
  304. package/dist/types/jl-link.types.d.ts +2 -0
  305. package/dist/types/jl-menu.types.d.ts +22 -0
  306. package/dist/types/jl-navbar.types.d.ts +6 -0
  307. package/dist/types/jl-progress.types.d.ts +3 -0
  308. package/dist/types/jl-radio-group.types.d.ts +10 -0
  309. package/dist/types/jl-segmented.types.d.ts +7 -0
  310. package/dist/types/jl-select.types.d.ts +12 -0
  311. package/dist/types/jl-side-nav.types.d.ts +17 -0
  312. package/dist/types/jl-skeleton.types.d.ts +2 -0
  313. package/dist/types/jl-slider.types.d.ts +5 -0
  314. package/dist/types/jl-split-view.types.d.ts +2 -0
  315. package/dist/types/jl-stat.types.d.ts +2 -0
  316. package/dist/types/jl-steps.types.d.ts +8 -0
  317. package/dist/types/jl-switch.types.d.ts +1 -0
  318. package/dist/types/jl-table.types.d.ts +30 -0
  319. package/dist/types/jl-tabs.types.d.ts +2 -0
  320. package/dist/types/jl-timeline.types.d.ts +10 -0
  321. package/dist/types/jl-toast.types.d.ts +2 -0
  322. package/dist/types/jl-toaster.types.d.ts +23 -0
  323. package/dist/types/jl-tree.types.d.ts +26 -0
  324. package/dist/types/key-shortcut.types.d.ts +9 -0
  325. package/dist/types/keycaps.types.d.ts +7 -0
  326. package/dist/types/option-filter.types.d.ts +10 -0
  327. package/dist/types/options.types.d.ts +4 -0
  328. package/dist/types/pagination.types.d.ts +8 -0
  329. package/dist/types/roving-index.types.d.ts +2 -0
  330. package/dist/types/sparkline.types.d.ts +11 -0
  331. package/package.json +102 -4
@@ -0,0 +1,3 @@
1
+ // src/atoms/jl-progress-ring.css?raw
2
+ var jl_progress_ring_default = ":host {\n display: inline-flex;\n flex: none;\n vertical-align: middle;\n --size: 40px;\n --done: 0;\n --color: var(--jl-accent);\n --track: var(--jl-surface-3);\n}\n\n:host([tone=\"ok\"]) {\n --color: var(--jl-ok);\n}\n\n:host([tone=\"warn\"]) {\n --color: var(--jl-warn);\n}\n\n:host([tone=\"danger\"]) {\n --color: var(--jl-danger);\n}\n\n.ring {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--size);\n height: var(--size);\n}\n\n.svg {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n /* The arc starts at the top, as a clock's hand. */\n transform: rotate(-90deg);\n}\n\n.track {\n stroke: var(--track);\n}\n\n.arc {\n stroke: var(--color);\n stroke-dasharray: 100;\n stroke-dashoffset: calc(100 - var(--done));\n stroke-linecap: round;\n transition: stroke-dashoffset var(--jl-slow) var(--jl-ease);\n}\n\n/* At zero, the round cap would still draw a dot at the top. */\n:host([empty]) .arc {\n visibility: hidden;\n}\n\n:host([indeterminate]) .arc {\n stroke-dashoffset: 72;\n transition: none;\n}\n\n:host([indeterminate]) .svg {\n animation: turn 0.9s linear infinite;\n}\n\n.percent {\n position: relative;\n color: var(--jl-text);\n font-size: calc(var(--size) * 0.24);\n font-variant-numeric: tabular-nums;\n font-weight: 700;\n line-height: 1;\n}\n\n@keyframes turn {\n from {\n transform: rotate(-90deg);\n }\n\n to {\n transform: rotate(270deg);\n }\n}\n\n/* Without motion, an endless ring stays still: a quarter of it shows that work goes on. */\n@media (prefers-reduced-motion: reduce) {\n :host([indeterminate]) .svg {\n animation: none;\n }\n}\n";
3
+ export { jl_progress_ring_default as default };
@@ -0,0 +1,49 @@
1
+ import { JlElement } from '../base/jl-element';
2
+ import type { ProgressTone } from '../types/jl-progress.types';
3
+ /**
4
+ * How far a task has gone, as a ring: `value` out of `max`, the percentage in its centre with `show-value`.
5
+ * Without a value, the ring turns: the work has no known end. Fits in buttons, cards and table cells.
6
+ */
7
+ export declare class JlProgressRing extends JlElement {
8
+ static readonly selector = "jl-progress-ring";
9
+ /** How much is done, out of `max`; `null` (no attribute) for work of unknown length. */
10
+ readonly value: Readonly<Readonly<{
11
+ get(): number | null;
12
+ set(setter: number | ((prevState: number | null) => number | null) | null): void;
13
+ }>>;
14
+ readonly max: Readonly<Readonly<{
15
+ get(): number;
16
+ set(setter: number | ((prevState: number) => number)): void;
17
+ }>>;
18
+ /** The ring's width and height, in pixels. */
19
+ readonly size: Readonly<Readonly<{
20
+ get(): number;
21
+ set(setter: number | ((prevState: number) => number)): void;
22
+ }>>;
23
+ /** The width of the ring's stroke, in pixels. */
24
+ readonly thickness: Readonly<Readonly<{
25
+ get(): number;
26
+ set(setter: number | ((prevState: number) => number)): void;
27
+ }>>;
28
+ readonly tone: Readonly<Readonly<{
29
+ get(): ProgressTone;
30
+ set(setter: ((prevState: ProgressTone) => ProgressTone) | ProgressTone): void;
31
+ }>>;
32
+ /** Prints the percentage in the centre: for rings of 40 pixels and more. */
33
+ readonly showValue: Readonly<Readonly<{
34
+ get(): boolean;
35
+ set(setter: boolean | ((prevState: boolean) => boolean)): void;
36
+ }>>;
37
+ /** The ring's name for screen readers: what is in progress. */
38
+ readonly label: Readonly<Readonly<{
39
+ get(): string;
40
+ set(setter: string | ((prevState: string) => string)): void;
41
+ }>>;
42
+ private readonly _refs;
43
+ private readonly _svg;
44
+ templateHtml(): Node;
45
+ templateCss(): string;
46
+ private buildSvg;
47
+ private renderGeometry;
48
+ private renderValue;
49
+ }
@@ -0,0 +1,132 @@
1
+ import { BASE_STYLES } from "../styles/shared.js";
2
+ import { JlElement } from "../base/jl-element.js";
3
+ import { oneOf } from "../lib/attributes.js";
4
+ import { optionalNumber, percentLabel, percentOf, progressRatio, ringGeometry } from "../lib/progress.js";
5
+ import { PROGRESS_TONES } from "./jl-progress.js";
6
+ import jl_progress_ring_default from "./jl-progress-ring.css_raw.js";
7
+ import { css } from "@jadis/core";
8
+ import { jsx } from "@jadis/core/jsx-runtime";
9
+ // src/atoms/jl-progress-ring.tsx
10
+ var SVG_NS = "http://www.w3.org/2000/svg";
11
+ var DEFAULT_MAX = 100;
12
+ var DEFAULT_SIZE = 40;
13
+ var DEFAULT_THICKNESS = 4;
14
+ var PATH_LENGTH = 100;
15
+ var DEFAULT_NAME = "Progress";
16
+ function svgElement(tag, attributes) {
17
+ const element = document.createElementNS(SVG_NS, tag);
18
+ for (const [name, value] of Object.entries(attributes)) element.setAttribute(name, value);
19
+ return element;
20
+ }
21
+ /**
22
+ * How far a task has gone, as a ring: `value` out of `max`, the percentage in its centre with `show-value`.
23
+ * Without a value, the ring turns: the work has no known end. Fits in buttons, cards and table cells.
24
+ */
25
+ var JlProgressRing = class extends JlElement {
26
+ static selector = "jl-progress-ring";
27
+ /** How much is done, out of `max`; `null` (no attribute) for work of unknown length. */
28
+ value = this.useChange(null, () => this.renderValue(), {
29
+ attribute: "value",
30
+ parse: optionalNumber
31
+ });
32
+ max = this.useChange(DEFAULT_MAX, () => this.renderValue(), { attribute: "max" });
33
+ /** The ring's width and height, in pixels. */
34
+ size = this.useChange(DEFAULT_SIZE, () => this.renderGeometry(), { attribute: "size" });
35
+ /** The width of the ring's stroke, in pixels. */
36
+ thickness = this.useChange(DEFAULT_THICKNESS, () => this.renderGeometry(), { attribute: "thickness" });
37
+ tone = this.useChange("accent", (value) => this.reflect("tone", value), {
38
+ attribute: "tone",
39
+ parse: oneOf(PROGRESS_TONES, "accent")
40
+ });
41
+ /** Prints the percentage in the centre: for rings of 40 pixels and more. */
42
+ showValue = this.useChange(false, (value) => {
43
+ this._refs.percent.hidden = !value;
44
+ }, { attribute: "show-value" });
45
+ /** The ring's name for screen readers: what is in progress. */
46
+ label = this.useChange("", (value) => this._refs.ring.setAttribute("aria-label", value === "" ? DEFAULT_NAME : value), { attribute: "label" });
47
+ _refs = this.useRefs((ref) => ({
48
+ percent: ref(".percent"),
49
+ ring: ref(".ring")
50
+ }));
51
+ _svg = {
52
+ arc: null,
53
+ root: null,
54
+ track: null
55
+ };
56
+ templateHtml() {
57
+ const ring = /* @__PURE__ */ jsx("span", {
58
+ class: "ring",
59
+ role: "progressbar",
60
+ "aria-valuemin": "0",
61
+ attrs: { part: "base" },
62
+ children: /* @__PURE__ */ jsx("span", {
63
+ class: "percent",
64
+ "aria-hidden": "true",
65
+ hidden: true
66
+ })
67
+ });
68
+ ring.prepend(this.buildSvg());
69
+ return ring;
70
+ }
71
+ templateCss() {
72
+ return css`${BASE_STYLES}${jl_progress_ring_default}`;
73
+ }
74
+ buildSvg() {
75
+ const root = svgElement("svg", {
76
+ "aria-hidden": "true",
77
+ class: "svg"
78
+ });
79
+ const track = svgElement("circle", {
80
+ class: "track",
81
+ fill: "none"
82
+ });
83
+ const arc = svgElement("circle", {
84
+ class: "arc",
85
+ fill: "none",
86
+ pathLength: String(PATH_LENGTH)
87
+ });
88
+ root.append(track, arc);
89
+ Object.assign(this._svg, {
90
+ arc,
91
+ root,
92
+ track
93
+ });
94
+ return root;
95
+ }
96
+ renderGeometry() {
97
+ const { root, track, arc } = this._svg;
98
+ if (root === null || track === null || arc === null) return;
99
+ const size = this.size.get();
100
+ const { center, radius, stroke } = ringGeometry(size, this.thickness.get());
101
+ root.setAttribute("viewBox", `0 0 ${size} ${size}`);
102
+ for (const circle of [track, arc]) {
103
+ circle.setAttribute("cx", String(center));
104
+ circle.setAttribute("cy", String(center));
105
+ circle.setAttribute("r", String(radius));
106
+ circle.setAttribute("stroke-width", String(stroke));
107
+ }
108
+ this.style.setProperty("--size", `${size}px`);
109
+ }
110
+ renderValue() {
111
+ const value = this.value.get();
112
+ const ring = this._refs.ring;
113
+ const max = this.max.get();
114
+ ring.setAttribute("aria-valuemax", String(max));
115
+ this.reflect("indeterminate", value === null);
116
+ this.reflect("empty", value !== null && progressRatio(value, max) === 0);
117
+ if (value === null) {
118
+ ring.removeAttribute("aria-valuenow");
119
+ ring.removeAttribute("aria-valuetext");
120
+ this.style.removeProperty("--done");
121
+ this._refs.percent.textContent = "";
122
+ return;
123
+ }
124
+ const ratio = progressRatio(value, max);
125
+ ring.setAttribute("aria-valuenow", String(value));
126
+ ring.setAttribute("aria-valuetext", percentLabel(ratio));
127
+ this.style.setProperty("--done", String(percentOf(ratio)));
128
+ this._refs.percent.textContent = percentLabel(ratio);
129
+ }
130
+ };
131
+ JlProgressRing.register();
132
+ export { JlProgressRing };
@@ -0,0 +1,3 @@
1
+ // src/atoms/jl-progress.css?raw
2
+ var jl_progress_default = ":host {\n display: block;\n --height: 8px;\n --color: var(--jl-accent);\n}\n\n:host([size=\"sm\"]) {\n --height: 4px;\n}\n\n:host([tone=\"ok\"]) {\n --color: var(--jl-ok);\n}\n\n:host([tone=\"warn\"]) {\n --color: var(--jl-warn);\n}\n\n:host([tone=\"danger\"]) {\n --color: var(--jl-danger);\n}\n\n.header {\n display: flex;\n align-items: baseline;\n gap: 12px;\n margin-bottom: 8px;\n font-size: var(--jl-font-sm);\n line-height: 1.4;\n}\n\n.label {\n flex: 1;\n min-width: 0;\n color: var(--jl-text-2);\n font-weight: 600;\n}\n\n.percent {\n margin-left: auto;\n color: var(--jl-muted);\n font-variant-numeric: tabular-nums;\n}\n\n.track {\n position: relative;\n height: var(--height);\n overflow: hidden;\n border-radius: var(--jl-radius-pill);\n background: var(--jl-surface-3);\n}\n\n.bar {\n width: 0;\n height: 100%;\n border-radius: inherit;\n background: var(--color);\n transition: width var(--jl-slow) var(--jl-ease);\n}\n\n:host([indeterminate]) .bar {\n position: absolute;\n inset: 0 auto 0 0;\n width: 40%;\n animation: travel 1.3s var(--jl-ease) infinite;\n}\n\n@keyframes travel {\n from {\n transform: translateX(-100%);\n }\n\n to {\n transform: translateX(250%);\n }\n}\n\n/* Without motion, an endless bar is drawn still and faded: work goes on, its end is unknown. */\n@media (prefers-reduced-motion: reduce) {\n :host([indeterminate]) .bar {\n width: 100%;\n opacity: 0.35;\n animation: none;\n }\n}\n";
3
+ export { jl_progress_default as default };
@@ -0,0 +1,43 @@
1
+ import { JlElement } from '../base/jl-element';
2
+ import type { ProgressSize, ProgressTone } from '../types/jl-progress.types';
3
+ export declare const PROGRESS_TONES: readonly ProgressTone[];
4
+ export declare const PROGRESS_SIZES: readonly ProgressSize[];
5
+ /**
6
+ * How far a task has gone, as a bar: `value` out of `max`. Without a value, the work has no known end and the bar
7
+ * runs back and forth. A `label` above names it; `show-value` prints the percentage.
8
+ */
9
+ export declare class JlProgress extends JlElement {
10
+ static readonly selector = "jl-progress";
11
+ /** How much is done, out of `max`; `null` (no attribute) for work of unknown length. */
12
+ readonly value: Readonly<Readonly<{
13
+ get(): number | null;
14
+ set(setter: number | ((prevState: number | null) => number | null) | null): void;
15
+ }>>;
16
+ readonly max: Readonly<Readonly<{
17
+ get(): number;
18
+ set(setter: number | ((prevState: number) => number)): void;
19
+ }>>;
20
+ readonly tone: Readonly<Readonly<{
21
+ get(): ProgressTone;
22
+ set(setter: ((prevState: ProgressTone) => ProgressTone) | ProgressTone): void;
23
+ }>>;
24
+ readonly size: Readonly<Readonly<{
25
+ get(): ProgressSize;
26
+ set(setter: ((prevState: ProgressSize) => ProgressSize) | ProgressSize): void;
27
+ }>>;
28
+ /** Shown above the bar, and the bar's name for screen readers. */
29
+ readonly label: Readonly<Readonly<{
30
+ get(): string;
31
+ set(setter: string | ((prevState: string) => string)): void;
32
+ }>>;
33
+ /** Prints the percentage above the bar, at the end. */
34
+ readonly showValue: Readonly<Readonly<{
35
+ get(): boolean;
36
+ set(setter: boolean | ((prevState: boolean) => boolean)): void;
37
+ }>>;
38
+ private readonly _refs;
39
+ templateHtml(): Node;
40
+ templateCss(): string;
41
+ private render;
42
+ private renderHeader;
43
+ }
@@ -0,0 +1,109 @@
1
+ import { BASE_STYLES } from "../styles/shared.js";
2
+ import { JlElement } from "../base/jl-element.js";
3
+ import { oneOf } from "../lib/attributes.js";
4
+ import { optionalNumber, percentLabel, percentOf, progressRatio } from "../lib/progress.js";
5
+ import jl_progress_default from "./jl-progress.css_raw.js";
6
+ import { css } from "@jadis/core";
7
+ import { jsx, jsxs } from "@jadis/core/jsx-runtime";
8
+ // src/atoms/jl-progress.tsx
9
+ var PROGRESS_TONES = [
10
+ "accent",
11
+ "ok",
12
+ "warn",
13
+ "danger"
14
+ ];
15
+ var PROGRESS_SIZES = ["md", "sm"];
16
+ var DEFAULT_MAX = 100;
17
+ var DEFAULT_NAME = "Progress";
18
+ /**
19
+ * How far a task has gone, as a bar: `value` out of `max`. Without a value, the work has no known end and the bar
20
+ * runs back and forth. A `label` above names it; `show-value` prints the percentage.
21
+ */
22
+ var JlProgress = class extends JlElement {
23
+ static selector = "jl-progress";
24
+ /** How much is done, out of `max`; `null` (no attribute) for work of unknown length. */
25
+ value = this.useChange(null, () => this.render(), {
26
+ attribute: "value",
27
+ parse: optionalNumber
28
+ });
29
+ max = this.useChange(DEFAULT_MAX, () => this.render(), { attribute: "max" });
30
+ tone = this.useChange("accent", (value) => this.reflect("tone", value), {
31
+ attribute: "tone",
32
+ parse: oneOf(PROGRESS_TONES, "accent")
33
+ });
34
+ size = this.useChange("md", (value) => this.reflect("size", value), {
35
+ attribute: "size",
36
+ parse: oneOf(PROGRESS_SIZES, "md")
37
+ });
38
+ /** Shown above the bar, and the bar's name for screen readers. */
39
+ label = this.useChange("", () => this.renderHeader(), { attribute: "label" });
40
+ /** Prints the percentage above the bar, at the end. */
41
+ showValue = this.useChange(false, () => this.renderHeader(), { attribute: "show-value" });
42
+ _refs = this.useRefs((ref) => ({
43
+ bar: ref(".bar"),
44
+ header: ref(".header"),
45
+ label: ref(".label"),
46
+ percent: ref(".percent"),
47
+ track: ref(".track")
48
+ }));
49
+ templateHtml() {
50
+ return /* @__PURE__ */ jsxs("div", {
51
+ class: "progress",
52
+ attrs: { part: "base" },
53
+ children: [/* @__PURE__ */ jsxs("div", {
54
+ class: "header",
55
+ hidden: true,
56
+ children: [/* @__PURE__ */ jsx("span", {
57
+ class: "label",
58
+ id: "label"
59
+ }), /* @__PURE__ */ jsx("span", {
60
+ class: "percent",
61
+ "aria-hidden": "true"
62
+ })]
63
+ }), /* @__PURE__ */ jsx("div", {
64
+ class: "track",
65
+ role: "progressbar",
66
+ "aria-valuemin": "0",
67
+ children: /* @__PURE__ */ jsx("div", { class: "bar" })
68
+ })]
69
+ });
70
+ }
71
+ templateCss() {
72
+ return css`${BASE_STYLES}${jl_progress_default}`;
73
+ }
74
+ render() {
75
+ const value = this.value.get();
76
+ const track = this._refs.track;
77
+ const max = this.max.get();
78
+ track.setAttribute("aria-valuemax", String(max));
79
+ this.reflect("indeterminate", value === null);
80
+ if (value === null) {
81
+ track.removeAttribute("aria-valuenow");
82
+ track.removeAttribute("aria-valuetext");
83
+ this._refs.bar.style.removeProperty("width");
84
+ this._refs.percent.textContent = "";
85
+ return;
86
+ }
87
+ const ratio = progressRatio(value, max);
88
+ track.setAttribute("aria-valuenow", String(value));
89
+ track.setAttribute("aria-valuetext", percentLabel(ratio));
90
+ this._refs.bar.style.width = `${percentOf(ratio)}%`;
91
+ this._refs.percent.textContent = percentLabel(ratio);
92
+ }
93
+ renderHeader() {
94
+ const label = this.label.get();
95
+ const track = this._refs.track;
96
+ this._refs.label.textContent = label;
97
+ this._refs.percent.hidden = !this.showValue.get();
98
+ this._refs.header.hidden = label === "" && !this.showValue.get();
99
+ if (label === "") {
100
+ track.removeAttribute("aria-labelledby");
101
+ track.setAttribute("aria-label", DEFAULT_NAME);
102
+ return;
103
+ }
104
+ track.removeAttribute("aria-label");
105
+ track.setAttribute("aria-labelledby", "label");
106
+ }
107
+ };
108
+ JlProgress.register();
109
+ export { JlProgress, PROGRESS_SIZES, PROGRESS_TONES };
@@ -0,0 +1,3 @@
1
+ // src/atoms/jl-rating.css?raw
2
+ var jl_rating_default = ":host {\n display: inline-flex;\n vertical-align: middle;\n --color: var(--jl-accent);\n --empty: var(--jl-faint);\n}\n\n.rating {\n display: inline-flex;\n padding: 2px;\n border-radius: var(--jl-radius-xs);\n cursor: pointer;\n}\n\n.icons {\n display: inline-flex;\n gap: 2px;\n}\n\n.icon {\n display: inline-flex;\n color: var(--empty);\n transition:\n color var(--jl-fast) var(--jl-ease),\n transform var(--jl-fast) var(--jl-ease);\n}\n\n.icon svg {\n fill: transparent;\n transition: fill var(--jl-fast) var(--jl-ease);\n}\n\n.icon.on {\n color: var(--color);\n}\n\n.icon.on svg {\n fill: currentColor;\n}\n\n/* The score a click would give: the same colour, lighter, so it reads as a proposal. */\n:host([previewing]) .icon.on {\n color: color-mix(in srgb, var(--color) 55%, transparent);\n}\n\n:host(:not([readonly]):not([disabled])) .icon:hover {\n transform: scale(1.12);\n}\n\n:host([invalid]) .icon:not(.on) {\n color: var(--jl-danger);\n}\n\n:host([readonly]) .rating {\n cursor: default;\n}\n\n:host([disabled]) .rating {\n cursor: not-allowed;\n opacity: 0.5;\n}\n";
3
+ export { jl_rating_default as default };
@@ -0,0 +1,73 @@
1
+ import { JlFormControl } from '../base/jl-form-control';
2
+ import type { ControlSize } from '../types/options.types';
3
+ /**
4
+ * A row of stars (or hearts, or any icon) to give a score: a click, the arrows or a digit set it, and choosing the
5
+ * score already given clears it. Hovering previews the score a click would give.
6
+ */
7
+ export declare class JlRating extends JlFormControl {
8
+ static readonly selector = "jl-rating";
9
+ readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
10
+ change: number;
11
+ }>>;
12
+ readonly value: Readonly<Readonly<{
13
+ get(): number;
14
+ set(setter: number | ((prevState: number) => number)): void;
15
+ }>>;
16
+ /** How many icons the scale has. */
17
+ readonly max: Readonly<Readonly<{
18
+ get(): number;
19
+ set(setter: number | ((prevState: number) => number)): void;
20
+ }>>;
21
+ /** Shows a score that cannot be changed: an average, a review. */
22
+ readonly readonly: Readonly<Readonly<{
23
+ get(): boolean;
24
+ set(setter: boolean | ((prevState: boolean) => boolean)): void;
25
+ }>>;
26
+ readonly icon: Readonly<Readonly<{
27
+ get(): string;
28
+ set(setter: string | ((prevState: string) => string)): void;
29
+ }>>;
30
+ readonly size: Readonly<Readonly<{
31
+ get(): ControlSize;
32
+ set(setter: ((prevState: ControlSize) => ControlSize) | ControlSize): void;
33
+ }>>;
34
+ /** The name screen readers give the scale. */
35
+ readonly label: Readonly<Readonly<{
36
+ get(): string;
37
+ set(setter: string | ((prevState: string) => string)): void;
38
+ }>>;
39
+ readonly required: Readonly<Readonly<{
40
+ get(): boolean;
41
+ set(setter: boolean | ((prevState: boolean) => boolean)): void;
42
+ }>>;
43
+ readonly disabled: Readonly<Readonly<{
44
+ get(): boolean;
45
+ set(setter: boolean | ((prevState: boolean) => boolean)): void;
46
+ }>>;
47
+ /** Draws the empty icons in the danger colour, for an error the page found itself. */
48
+ readonly invalid: Readonly<Readonly<{
49
+ get(): boolean;
50
+ set(setter: boolean | ((prevState: boolean) => boolean)): void;
51
+ }>>;
52
+ private readonly _state;
53
+ private readonly _refs;
54
+ focus(options?: FocusOptions): void;
55
+ templateHtml(): Node;
56
+ templateCss(): string;
57
+ onConnect(): void;
58
+ protected resetValue(): void;
59
+ protected setDisabledByForm(disabled: boolean): void;
60
+ private canChange;
61
+ private onKey;
62
+ private onChoose;
63
+ private onHover;
64
+ private iconValueAt;
65
+ private setPreview;
66
+ /** The value as the scale shows it: never past its end. */
67
+ private current;
68
+ private commit;
69
+ private renderIcons;
70
+ private renderValue;
71
+ private renderValidity;
72
+ private renderDisabled;
73
+ }
@@ -0,0 +1,184 @@
1
+ import { BASE_STYLES } from "../styles/shared.js";
2
+ import { JlFormControl } from "../base/jl-form-control.js";
3
+ import { clampedNumber, oneOf } from "../lib/attributes.js";
4
+ import { iconElement, registerIcons } from "../lib/icons.js";
5
+ import { CONTROL_SIZES } from "../lib/options.js";
6
+ import { ratingAfterChoice, ratingAfterKey } from "../lib/rating.js";
7
+ import jl_rating_default from "./jl-rating.css_raw.js";
8
+ import { css } from "@jadis/core";
9
+ import { Star } from "lucide";
10
+ import { jsx } from "@jadis/core/jsx-runtime";
11
+ // src/atoms/jl-rating.tsx
12
+ registerIcons({ star: Star });
13
+ var ICON_SIZES = {
14
+ lg: 26,
15
+ md: 20,
16
+ sm: 16
17
+ };
18
+ var DEFAULT_MAX = 5;
19
+ var MAX_LIMIT = 10;
20
+ var NO_PREVIEW = 0;
21
+ var DEFAULT_LABEL = "Rating";
22
+ var VALUE_MISSING = "Choose a rating.";
23
+ /**
24
+ * A row of stars (or hearts, or any icon) to give a score: a click, the arrows or a digit set it, and choosing the
25
+ * score already given clears it. Hovering previews the score a click would give.
26
+ */
27
+ var JlRating = class extends JlFormControl {
28
+ static selector = "jl-rating";
29
+ events = this.useEvents();
30
+ value = this.useChange(0, () => this.renderValue(), {
31
+ attribute: "value",
32
+ parse: clampedNumber(0, 0, MAX_LIMIT)
33
+ });
34
+ /** How many icons the scale has. */
35
+ max = this.useChange(DEFAULT_MAX, () => this.renderIcons(), {
36
+ attribute: "max",
37
+ parse: clampedNumber(DEFAULT_MAX, 1, MAX_LIMIT)
38
+ });
39
+ /** Shows a score that cannot be changed: an average, a review. */
40
+ readonly = this.useChange(false, (value) => {
41
+ this.reflect("readonly", value);
42
+ this._refs.slider.toggleAttribute("aria-readonly", value);
43
+ }, { attribute: "readonly" });
44
+ icon = this.useChange("star", () => this.renderIcons(), { attribute: "icon" });
45
+ size = this.useChange("md", (value) => {
46
+ this.reflect("size", value);
47
+ this.renderIcons();
48
+ }, {
49
+ attribute: "size",
50
+ parse: oneOf(CONTROL_SIZES, "md")
51
+ });
52
+ /** The name screen readers give the scale. */
53
+ label = this.useChange(DEFAULT_LABEL, (value) => {
54
+ this._refs.slider.setAttribute("aria-label", value === "" ? DEFAULT_LABEL : value);
55
+ }, { attribute: "label" });
56
+ required = this.useChange(false, (value) => {
57
+ this._refs.slider.toggleAttribute("aria-required", value);
58
+ this.renderValidity();
59
+ }, { attribute: "required" });
60
+ disabled = this.useChange(false, (value) => this.renderDisabled(value), { attribute: "disabled" });
61
+ /** Draws the empty icons in the danger colour, for an error the page found itself. */
62
+ invalid = this.useChange(false, (value) => {
63
+ this.reflect("invalid", value);
64
+ this._refs.slider.toggleAttribute("aria-invalid", value);
65
+ }, { attribute: "invalid" });
66
+ _state = {
67
+ formDisabled: false,
68
+ preview: NO_PREVIEW
69
+ };
70
+ _refs = this.useRefs((ref) => ({
71
+ icons: ref(".icons"),
72
+ slider: ref(".rating")
73
+ }));
74
+ focus(options) {
75
+ this._refs.slider.focus(options);
76
+ }
77
+ templateHtml() {
78
+ return /* @__PURE__ */ jsx("div", {
79
+ class: "rating",
80
+ role: "slider",
81
+ tabIndex: 0,
82
+ "aria-valuenow": "0",
83
+ "aria-valuemin": "0",
84
+ attrs: { part: "base" },
85
+ children: /* @__PURE__ */ jsx("span", { class: "icons" })
86
+ });
87
+ }
88
+ templateCss() {
89
+ return css`${BASE_STYLES}${jl_rating_default}`;
90
+ }
91
+ onConnect() {
92
+ const slider = this._refs.slider;
93
+ this.on(slider, "keydown", (event) => this.onKey(event));
94
+ this.on(slider, "click", (event) => this.onChoose(event));
95
+ this.on(slider, "pointermove", (event) => this.onHover(event));
96
+ this.on(slider, "pointerleave", () => this.setPreview(NO_PREVIEW));
97
+ }
98
+ resetValue() {
99
+ this.value.set(clampedNumber(0, 0, MAX_LIMIT)(this.getAttribute("value")));
100
+ }
101
+ setDisabledByForm(disabled) {
102
+ this._state.formDisabled = disabled;
103
+ this.whenRendered(() => this.renderDisabled(this.disabled.get()));
104
+ }
105
+ canChange() {
106
+ return !this.readonly.get() && !this.disabled.get() && !this._state.formDisabled;
107
+ }
108
+ onKey(event) {
109
+ if (!this.canChange()) return;
110
+ const next = ratingAfterKey(this.current(), event.key, this.max.get());
111
+ if (next === null) return;
112
+ event.preventDefault();
113
+ this.commit(next);
114
+ }
115
+ onChoose(event) {
116
+ const chosen = this.iconValueAt(event);
117
+ if (chosen === null || !this.canChange()) return;
118
+ this.setPreview(NO_PREVIEW);
119
+ this.commit(ratingAfterChoice(this.current(), chosen));
120
+ }
121
+ onHover(event) {
122
+ if (!this.canChange()) return;
123
+ this.setPreview(this.iconValueAt(event) ?? NO_PREVIEW);
124
+ }
125
+ iconValueAt(event) {
126
+ const icon = event.target.closest("[data-value]");
127
+ return icon === null ? null : Number(icon.dataset.value);
128
+ }
129
+ setPreview(preview) {
130
+ if (preview === this._state.preview) return;
131
+ this._state.preview = preview;
132
+ this.renderValue();
133
+ }
134
+ /** The value as the scale shows it: never past its end. */
135
+ current() {
136
+ return Math.min(this.value.get(), this.max.get());
137
+ }
138
+ commit(value) {
139
+ if (value === this.current()) return;
140
+ this.value.set(value);
141
+ this.events.emit("change", value);
142
+ }
143
+ renderIcons() {
144
+ const name = this.icon.get() === "" ? "star" : this.icon.get();
145
+ const size = ICON_SIZES[this.size.get()];
146
+ const icons = Array.from({ length: this.max.get() }, (_, index) => /* @__PURE__ */ jsx("span", {
147
+ class: "icon",
148
+ "data-value": String(index + 1),
149
+ children: iconElement(name, size)
150
+ }));
151
+ this._refs.icons.replaceChildren(...icons);
152
+ this.renderValue();
153
+ }
154
+ renderValue() {
155
+ const value = this.current();
156
+ const max = this.max.get();
157
+ const preview = this._state.preview;
158
+ const shown = preview === NO_PREVIEW ? value : preview;
159
+ for (const icon of this._refs.icons.querySelectorAll("[data-value]")) icon.classList.toggle("on", Number(icon.dataset.value) <= shown);
160
+ this.reflect("previewing", preview !== NO_PREVIEW);
161
+ const slider = this._refs.slider;
162
+ slider.setAttribute("aria-valuenow", String(value));
163
+ slider.setAttribute("aria-valuemax", String(max));
164
+ slider.setAttribute("aria-valuetext", value === 0 ? "No rating" : `${value} of ${max}`);
165
+ this.internals.setFormValue(String(value));
166
+ this.renderValidity();
167
+ }
168
+ renderValidity() {
169
+ if (this.required.get() && this.current() === 0) {
170
+ this.internals.setValidity({ valueMissing: true }, VALUE_MISSING, this._refs.slider);
171
+ return;
172
+ }
173
+ this.internals.setValidity({});
174
+ }
175
+ renderDisabled(disabled) {
176
+ const off = disabled || this._state.formDisabled;
177
+ this.reflect("disabled", disabled);
178
+ this._refs.slider.tabIndex = off ? -1 : 0;
179
+ this._refs.slider.toggleAttribute("aria-disabled", off);
180
+ this.setPreview(NO_PREVIEW);
181
+ }
182
+ };
183
+ JlRating.register();
184
+ export { JlRating };
@@ -0,0 +1,3 @@
1
+ // src/atoms/jl-select.css?raw
2
+ var jl_select_default = ":host {\n display: block;\n}\n\n/* The select covers the whole frame, chevron included, so a click anywhere opens it. */\n.control {\n position: relative;\n padding: 0;\n}\n\n.native {\n padding: 0 36px 0 12px;\n border-radius: inherit;\n text-overflow: ellipsis;\n cursor: pointer;\n appearance: none;\n}\n\n.native:disabled {\n cursor: not-allowed;\n}\n\n:host([placeholder-shown]) .native {\n color: var(--jl-faint);\n}\n\n/* The list keeps the text colour even while the placeholder greys the closed field. */\noption,\noptgroup {\n background: var(--jl-surface);\n color: var(--jl-text);\n}\n\n.chevron {\n position: absolute;\n right: 12px;\n color: var(--jl-muted);\n pointer-events: none;\n}\n\n:host([disabled]) .chevron {\n color: var(--jl-faint);\n}\n";
3
+ export { jl_select_default as default };