@gramlot/gramlot 0.3.41 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/assets/icons/align-center.svg +4 -0
  2. package/assets/icons/align-justify.svg +4 -0
  3. package/assets/icons/align-left.svg +4 -0
  4. package/assets/icons/align-right.svg +4 -0
  5. package/assets/icons/applications.svg +4 -0
  6. package/assets/icons/archive.svg +4 -0
  7. package/assets/icons/attachment.svg +4 -0
  8. package/assets/icons/bold.svg +4 -0
  9. package/assets/icons/book.svg +4 -0
  10. package/assets/icons/bookmark.svg +4 -0
  11. package/assets/icons/calendar.svg +4 -0
  12. package/assets/icons/cancel.svg +4 -0
  13. package/assets/icons/chart.svg +4 -1
  14. package/assets/icons/chat.svg +4 -0
  15. package/assets/icons/clock.svg +4 -0
  16. package/assets/icons/code.svg +4 -0
  17. package/assets/icons/collapse.svg +4 -0
  18. package/assets/icons/columns.svg +4 -0
  19. package/assets/icons/confirm.svg +4 -0
  20. package/assets/icons/copy.svg +4 -0
  21. package/assets/icons/cut.svg +4 -0
  22. package/assets/icons/database.svg +4 -0
  23. package/assets/icons/delete.svg +4 -0
  24. package/assets/icons/detach.svg +4 -0
  25. package/assets/icons/document.svg +4 -0
  26. package/assets/icons/download.svg +4 -0
  27. package/assets/icons/duplicate.svg +4 -0
  28. package/assets/icons/edit.svg +4 -0
  29. package/assets/icons/eraser.svg +4 -0
  30. package/assets/icons/expand.svg +4 -0
  31. package/assets/icons/export.svg +4 -0
  32. package/assets/icons/eye.svg +4 -0
  33. package/assets/icons/filter.svg +4 -0
  34. package/assets/icons/first.svg +4 -0
  35. package/assets/icons/folder.svg +4 -0
  36. package/assets/icons/group.svg +4 -0
  37. package/assets/icons/help.svg +4 -0
  38. package/assets/icons/home.svg +4 -0
  39. package/assets/icons/horizontal-rule.svg +4 -0
  40. package/assets/icons/image.svg +4 -0
  41. package/assets/icons/import.svg +4 -0
  42. package/assets/icons/indent.svg +4 -0
  43. package/assets/icons/info.svg +4 -0
  44. package/assets/icons/inspector.svg +4 -0
  45. package/assets/icons/italic.svg +4 -0
  46. package/assets/icons/last.svg +4 -0
  47. package/assets/icons/layers.svg +4 -0
  48. package/assets/icons/link.svg +4 -0
  49. package/assets/icons/list-bulleted.svg +4 -0
  50. package/assets/icons/list-numbered.svg +4 -0
  51. package/assets/icons/list.svg +4 -0
  52. package/assets/icons/lock.svg +4 -0
  53. package/assets/icons/logout.svg +4 -0
  54. package/assets/icons/navigation.svg +4 -0
  55. package/assets/icons/new.svg +4 -0
  56. package/assets/icons/next.svg +4 -0
  57. package/assets/icons/open.svg +4 -0
  58. package/assets/icons/outdent.svg +4 -0
  59. package/assets/icons/palette.svg +4 -0
  60. package/assets/icons/panel-bottom.svg +4 -0
  61. package/assets/icons/panel-left.svg +4 -0
  62. package/assets/icons/panel-right.svg +4 -0
  63. package/assets/icons/panel-top.svg +4 -0
  64. package/assets/icons/paragraph.svg +4 -0
  65. package/assets/icons/paste.svg +4 -0
  66. package/assets/icons/pause.svg +4 -0
  67. package/assets/icons/pin.svg +4 -0
  68. package/assets/icons/play.svg +4 -0
  69. package/assets/icons/previous.svg +4 -0
  70. package/assets/icons/print.svg +4 -0
  71. package/assets/icons/redo.svg +4 -0
  72. package/assets/icons/refresh.svg +4 -0
  73. package/assets/icons/save.svg +4 -0
  74. package/assets/icons/search.svg +4 -0
  75. package/assets/icons/select-all.svg +4 -0
  76. package/assets/icons/send.svg +4 -0
  77. package/assets/icons/settings.svg +4 -0
  78. package/assets/icons/sort-ascending.svg +4 -0
  79. package/assets/icons/sort-descending.svg +4 -0
  80. package/assets/icons/stop.svg +4 -0
  81. package/assets/icons/strikethrough.svg +4 -0
  82. package/assets/icons/table.svg +4 -0
  83. package/assets/icons/tree.svg +4 -0
  84. package/assets/icons/underline.svg +4 -0
  85. package/assets/icons/undo.svg +4 -0
  86. package/assets/icons/unlock.svg +4 -0
  87. package/assets/icons/upload.svg +4 -0
  88. package/assets/icons/user.svg +4 -0
  89. package/assets/icons/warning.svg +4 -0
  90. package/assets/icons/zoom-in.svg +4 -0
  91. package/assets/icons/zoom-out.svg +4 -0
  92. package/dist/components/charts/__init__.py +1 -1
  93. package/dist/components/charts/assets/index.js +1 -1
  94. package/dist/components/charts/assets/libraries/vega.js +11 -11
  95. package/dist/components/charts/grammar.json +2032 -72
  96. package/dist/components/editors/__init__.py +1 -1
  97. package/dist/components/editors/assets/collection.js +1 -1
  98. package/dist/components/editors/assets/index.js +1 -1
  99. package/dist/components/editors/assets/libraries/codemirror.js +30 -31
  100. package/dist/components/editors/assets/libraries/jodit.js +453 -447
  101. package/dist/components/editors/commands.json +113 -1
  102. package/dist/components/editors/grammar.json +12 -5
  103. package/dist/components/grid/__init__.py +1 -1
  104. package/dist/components/grid/assets/index.js +1 -1
  105. package/dist/components/grid/commands.json +4 -6
  106. package/dist/components/grid/grammar.json +112 -0
  107. package/dist/components/inputs/__init__.py +1 -1
  108. package/dist/components/inputs/assets/index.js +1 -1
  109. package/dist/components/inputs/grammar.json +5165 -359
  110. package/dist/components/layout/__init__.py +1 -1
  111. package/dist/components/layout/assets/collection.js +1 -0
  112. package/dist/components/layout/assets/index.js +1 -1
  113. package/dist/components/layout/grammar.json +433 -4
  114. package/dist/components/tree/__init__.py +1 -1
  115. package/dist/components/tree/assets/index.js +1 -1
  116. package/dist/components/tree/grammar.json +51 -0
  117. package/dist/components/typst/__init__.py +1 -1
  118. package/dist/components/typst/assets/collection.js +6 -6
  119. package/dist/components/typst/assets/index.js +1 -1
  120. package/dist/components/uploads/__init__.py +1 -1
  121. package/dist/components/uploads/assets/index.js +1 -1
  122. package/dist/components/uploads/grammar.json +66 -0
  123. package/dist/declared-collections.js +1 -1
  124. package/dist/gramlot.js +5486 -2029
  125. package/dist/gramlot.min.js +361 -138
  126. package/dist/libraries.json +6 -4
  127. package/dist/standard-collections.js +1 -1
  128. package/dist/standard-grammar.js +1 -1
  129. package/package.json +6 -2
  130. package/src/binding/ask-dialog.js +17 -3
  131. package/src/binding/providers.js +3 -2
  132. package/src/binding/remote.js +41 -6
  133. package/src/binding/runtime.js +30 -3
  134. package/src/builder/gramlot-builder.d.ts +3 -1
  135. package/src/builder/gramlot-builder.js +77 -26
  136. package/src/builder/source.js +78 -15
  137. package/src/builder/xml-recipe.js +144 -0
  138. package/src/chat-file-types.js +13 -0
  139. package/src/chat.d.ts +1 -0
  140. package/src/chat.js +35 -25
  141. package/src/commands.d.ts +1 -1
  142. package/src/commands.js +1 -1
  143. package/src/components/border-container.js +64 -6
  144. package/src/components/buttons.js +26 -31
  145. package/src/components/chart-bar3d-options.js +0 -1
  146. package/src/components/chart-boxplot-options.js +1 -1
  147. package/src/components/chart-candlestick-options.js +1 -1
  148. package/src/components/chart-engines/echarts-options.js +6 -5
  149. package/src/components/chart-engines/echarts.js +27 -10
  150. package/src/components/chart-engines/plotly-map.js +1 -1
  151. package/src/components/chart-engines/plotly.js +21 -14
  152. package/src/components/chart-engines/uplot.js +17 -11
  153. package/src/components/chart-engines/vega.js +17 -11
  154. package/src/components/chart-funnel-options.js +1 -1
  155. package/src/components/chart-geographic-options.js +2 -2
  156. package/src/components/chart-heatmap-options.js +1 -1
  157. package/src/components/chart-map-bar3d-options.js +2 -2
  158. package/src/components/chart-map-options.js +2 -2
  159. package/src/components/chart-pane.js +5 -5
  160. package/src/components/chart-parallel-options.js +1 -1
  161. package/src/components/chart-radar-options.js +1 -1
  162. package/src/components/chart-renderer.js +6 -1
  163. package/src/components/chart-sankey-options.js +1 -1
  164. package/src/components/chart-spatial-options.js +6 -2
  165. package/src/components/chart-sunburst-options.js +13 -1
  166. package/src/components/chart-theme.js +14 -0
  167. package/src/components/chart-treemap-options.js +1 -1
  168. package/src/components/chart-type-data.js +24 -4
  169. package/src/components/charts.js +7 -6
  170. package/src/components/check-box-text-editor.js +1 -0
  171. package/src/components/check-box-text.js +2 -0
  172. package/src/components/check-box-tree.js +1 -1
  173. package/src/components/choice-editor.js +5 -4
  174. package/src/components/choice-field-styles.js +9 -1
  175. package/src/components/code-mirror-engine.js +19 -5
  176. package/src/components/code-mirror-gramlot.js +85 -0
  177. package/src/components/code-mirror.js +3 -2
  178. package/src/components/drawing.js +43 -14
  179. package/src/components/editor-commands.js +69 -0
  180. package/src/components/editor-options.js +1 -1
  181. package/src/components/editors.js +5 -3
  182. package/src/components/form-tray-pane.js +18 -0
  183. package/src/components/graphical-ranges.js +190 -0
  184. package/src/components/grid-check-sets.js +39 -3
  185. package/src/components/grid-footer.js +6 -1
  186. package/src/components/grid-header-interaction.js +3 -3
  187. package/src/components/grid-styles.js +30 -5
  188. package/src/components/grid-tools.js +15 -7
  189. package/src/components/grid.js +109 -15
  190. package/src/components/html-editor-commands.js +61 -0
  191. package/src/components/html-editor.js +18 -3
  192. package/src/components/inputs.js +94 -23
  193. package/src/components/jodit-engine.js +110 -7
  194. package/src/components/layout.js +3 -2
  195. package/src/components/menus.js +89 -26
  196. package/src/components/numeric-range.js +39 -0
  197. package/src/components/selected-container.js +123 -64
  198. package/src/components/tab-bar.js +389 -0
  199. package/src/components/toolbar-icon-style.js +22 -0
  200. package/src/components/toolbar-overflow.js +74 -12
  201. package/src/components/tray-base.js +528 -0
  202. package/src/components/tray-pane.js +41 -518
  203. package/src/components/tree.js +56 -4
  204. package/src/components/typed-editor.js +5 -2
  205. package/src/components/typst-preview.js +3 -3
  206. package/src/components/upload-blocks.js +88 -0
  207. package/src/components/upload-engine.js +21 -31
  208. package/src/components/uploader.js +168 -47
  209. package/src/editing-session.js +2 -1
  210. package/src/gramlot.js +6 -3
  211. package/src/handlers/dom-handler.d.ts +2 -0
  212. package/src/handlers/dom-handler.js +9 -0
  213. package/src/handlers/rpc-handler.d.ts +1 -1
  214. package/src/handlers/rpc-handler.js +2 -0
  215. package/src/handlers/source-handler.d.ts +5 -3
  216. package/src/handlers/source-handler.js +31 -13
  217. package/src/icons.js +84 -0
  218. package/src/ide-runtime.js +3 -1
  219. package/src/index-page-runtime.js +20 -5
  220. package/src/index-page-styles.js +1 -1
  221. package/src/index-theme.js +210 -3
  222. package/src/index.d.ts +7 -2
  223. package/src/index.js +7 -2
  224. package/src/libraries.js +4 -4
  225. package/src/object-extract.d.ts +7 -0
  226. package/src/object-extract.js +31 -0
  227. package/src/renderer/attributes.js +1 -1
  228. package/src/renderer/gramlot-renderer.d.ts +2 -2
  229. package/src/renderer/gramlot-renderer.js +4 -1
  230. package/src/server/chat-attachments.js +139 -0
  231. package/src/server/chat.d.ts +33 -0
  232. package/src/server/chat.js +168 -0
  233. package/src/server/database-selectors.d.ts +6 -0
  234. package/src/server/database-selectors.js +13 -0
  235. package/src/server/gramlot-file-server.js +6 -1
  236. package/src/server/gramlot-server.d.ts +19 -3
  237. package/src/server/gramlot-server.js +149 -19
  238. package/src/server/index-page.d.ts +10 -0
  239. package/src/server/index-page.js +92 -8
  240. package/src/server/index.d.ts +1 -1
  241. package/src/server/index.js +1 -1
  242. package/src/server/page-base.js +4 -0
  243. package/src/server/page-store.d.ts +21 -0
  244. package/src/server/page-store.js +219 -0
  245. package/src/server/page.d.ts +6 -1
  246. package/src/server/page.js +5 -1
  247. package/src/server/store-recipe.js +102 -0
  248. package/src/server/toolbar-icon-name.d.ts +93 -0
  249. package/src/server/upload.d.ts +2 -0
  250. package/src/server/upload.js +36 -18
  251. package/src/server/visual-editor.js +4 -2
  252. package/src/tree-store.d.ts +5 -1
  253. package/src/tree-store.js +11 -2
  254. package/src/view/choice-focus.js +17 -0
  255. package/src/view/html.js +21 -1
  256. package/src/view/labelbox.js +6 -1
  257. package/src/view/menu.js +9 -3
  258. package/src/visual-editor.d.ts +1 -0
  259. package/src/visual-editor.js +10 -5
  260. package/themes/gramlot-base/theme.css +60 -28
  261. package/themes/gramlot-compact/theme.css +2 -0
  262. package/themes/gramlot-index/icons/align-center.svg +4 -0
  263. package/themes/gramlot-index/icons/align-justify.svg +4 -0
  264. package/themes/gramlot-index/icons/align-left.svg +4 -0
  265. package/themes/gramlot-index/icons/align-right.svg +4 -0
  266. package/themes/gramlot-index/icons/applications.svg +4 -0
  267. package/themes/gramlot-index/icons/archive.svg +4 -0
  268. package/themes/gramlot-index/icons/attachment.svg +4 -0
  269. package/themes/gramlot-index/icons/bold.svg +4 -0
  270. package/themes/gramlot-index/icons/book.svg +4 -0
  271. package/themes/gramlot-index/icons/bookmark.svg +4 -0
  272. package/themes/gramlot-index/icons/calendar.svg +4 -0
  273. package/themes/gramlot-index/icons/cancel.svg +4 -0
  274. package/themes/gramlot-index/icons/chart.svg +4 -0
  275. package/themes/gramlot-index/icons/chat.svg +4 -0
  276. package/themes/gramlot-index/icons/clock.svg +4 -0
  277. package/themes/gramlot-index/icons/code.svg +4 -0
  278. package/themes/gramlot-index/icons/collapse.svg +4 -0
  279. package/themes/gramlot-index/icons/columns.svg +4 -0
  280. package/themes/gramlot-index/icons/confirm.svg +4 -0
  281. package/themes/gramlot-index/icons/copy.svg +4 -0
  282. package/themes/gramlot-index/icons/cut.svg +4 -0
  283. package/themes/gramlot-index/icons/database.svg +4 -0
  284. package/themes/gramlot-index/icons/delete.svg +4 -0
  285. package/themes/gramlot-index/icons/detach.svg +4 -0
  286. package/themes/gramlot-index/icons/document.svg +4 -0
  287. package/themes/gramlot-index/icons/download.svg +4 -0
  288. package/themes/gramlot-index/icons/duplicate.svg +4 -0
  289. package/themes/gramlot-index/icons/edit.svg +4 -0
  290. package/themes/gramlot-index/icons/eraser.svg +4 -0
  291. package/themes/gramlot-index/icons/expand.svg +4 -0
  292. package/themes/gramlot-index/icons/export.svg +4 -0
  293. package/themes/gramlot-index/icons/eye.svg +4 -0
  294. package/themes/gramlot-index/icons/filter.svg +4 -0
  295. package/themes/gramlot-index/icons/first.svg +4 -0
  296. package/themes/gramlot-index/icons/folder.svg +4 -0
  297. package/themes/gramlot-index/icons/group.svg +4 -0
  298. package/themes/gramlot-index/icons/help.svg +4 -0
  299. package/themes/gramlot-index/icons/home.svg +4 -0
  300. package/themes/gramlot-index/icons/horizontal-rule.svg +4 -0
  301. package/themes/gramlot-index/icons/image.svg +4 -0
  302. package/themes/gramlot-index/icons/import.svg +4 -0
  303. package/themes/gramlot-index/icons/indent.svg +4 -0
  304. package/themes/gramlot-index/icons/info.svg +4 -0
  305. package/themes/gramlot-index/icons/inspector.svg +4 -0
  306. package/themes/gramlot-index/icons/italic.svg +4 -0
  307. package/themes/gramlot-index/icons/last.svg +4 -0
  308. package/themes/gramlot-index/icons/layers.svg +4 -0
  309. package/themes/gramlot-index/icons/link.svg +4 -0
  310. package/themes/gramlot-index/icons/list-bulleted.svg +4 -0
  311. package/themes/gramlot-index/icons/list-numbered.svg +4 -0
  312. package/themes/gramlot-index/icons/list.svg +4 -0
  313. package/themes/gramlot-index/icons/lock.svg +4 -0
  314. package/themes/gramlot-index/icons/logout.svg +4 -0
  315. package/themes/gramlot-index/icons/navigation.svg +4 -0
  316. package/themes/gramlot-index/icons/new.svg +4 -0
  317. package/themes/gramlot-index/icons/next.svg +4 -0
  318. package/themes/gramlot-index/icons/open.svg +4 -0
  319. package/themes/gramlot-index/icons/outdent.svg +4 -0
  320. package/themes/gramlot-index/icons/palette.svg +4 -0
  321. package/themes/gramlot-index/icons/panel-bottom.svg +4 -0
  322. package/themes/gramlot-index/icons/panel-left.svg +4 -0
  323. package/themes/gramlot-index/icons/panel-right.svg +4 -0
  324. package/themes/gramlot-index/icons/panel-top.svg +4 -0
  325. package/themes/gramlot-index/icons/paragraph.svg +4 -0
  326. package/themes/gramlot-index/icons/paste.svg +4 -0
  327. package/themes/gramlot-index/icons/pause.svg +4 -0
  328. package/themes/gramlot-index/icons/pin.svg +4 -0
  329. package/themes/gramlot-index/icons/play.svg +4 -0
  330. package/themes/gramlot-index/icons/previous.svg +4 -0
  331. package/themes/gramlot-index/icons/print.svg +4 -0
  332. package/themes/gramlot-index/icons/redo.svg +4 -0
  333. package/themes/gramlot-index/icons/refresh.svg +4 -0
  334. package/themes/gramlot-index/icons/save.svg +4 -0
  335. package/themes/gramlot-index/icons/search.svg +4 -0
  336. package/themes/gramlot-index/icons/select-all.svg +4 -0
  337. package/themes/gramlot-index/icons/send.svg +4 -0
  338. package/themes/gramlot-index/icons/settings.svg +4 -0
  339. package/themes/gramlot-index/icons/sort-ascending.svg +4 -0
  340. package/themes/gramlot-index/icons/sort-descending.svg +4 -0
  341. package/themes/gramlot-index/icons/stop.svg +4 -0
  342. package/themes/gramlot-index/icons/strikethrough.svg +4 -0
  343. package/themes/gramlot-index/icons/table.svg +4 -0
  344. package/themes/gramlot-index/icons/tree.svg +4 -0
  345. package/themes/gramlot-index/icons/underline.svg +4 -0
  346. package/themes/gramlot-index/icons/undo.svg +4 -0
  347. package/themes/gramlot-index/icons/unlock.svg +4 -0
  348. package/themes/gramlot-index/icons/upload.svg +4 -0
  349. package/themes/gramlot-index/icons/user.svg +4 -0
  350. package/themes/gramlot-index/icons/warning.svg +4 -0
  351. package/themes/gramlot-index/icons/zoom-in.svg +4 -0
  352. package/themes/gramlot-index/icons/zoom-out.svg +4 -0
  353. package/themes/gramlot-index/icons.json +93 -0
  354. package/themes/gramlot-index/theme.css +24 -0
  355. package/themes/joanna/theme.css +2 -0
  356. package/themes/mela/theme.css +2 -0
  357. package/themes/mimi/theme.css +2 -0
  358. package/tools/gramlot-tools-inspector.js +11 -3
@@ -1,3 +1,4 @@
1
+ import icons from '../../themes/gramlot-index/icons.json' with {type:'json'};
1
2
  import {GridColumnFilters} from './grid-column-filters.js';
2
3
  import {Bag} from '@genrojs/bag';
3
4
  import {SVG_NS} from '../renderer/attributes.js';
@@ -21,6 +22,20 @@ import {gridSearch} from './grid-search.js';
21
22
  import {SearchBox} from './grid-search-box.js';
22
23
  import structureGrammar from './grid-grammar.json' with {type: 'json'};
23
24
 
25
+ // Built-in texts by language of the page locale; English when the language has none.
26
+ const TEXTS = {
27
+ en: {empty:'No rows', reorder:'Drag to reorder',
28
+ sort:'Click: ascending / descending · Shift-click: add or reverse this column without changing the others · Numbers show sort priority · Drag to reorder',
29
+ resizeColumn:'Drag to resize · Arrow keys adjust width',
30
+ resizeRow:'Drag to resize row · Double-click or Home resets · Arrow keys adjust height', deleteRow:'Delete row',
31
+ checkAll:'Check or uncheck all rows'},
32
+ it: {empty:'Nessuna riga', reorder:'Trascina per riordinare',
33
+ sort:'Clic: crescente / decrescente · Maiusc-clic: aggiunge o inverte questa colonna senza cambiare le altre · I numeri indicano la priorità di ordinamento · Trascina per riordinare',
34
+ resizeColumn:'Trascina per ridimensionare · Le frecce regolano la larghezza',
35
+ resizeRow:'Trascina per ridimensionare la riga · Doppio clic o Home ripristina · Le frecce regolano l\u2019altezza', deleteRow:'Cancella riga',
36
+ checkAll:'Seleziona o deseleziona tutte le righe'},
37
+ };
38
+
24
39
  /** First grid: explicit Bag row representation and a separately observable Data struct. */
25
40
  export const Grid = defineComponent({
26
41
  name: 'grid', tag: 'gramlot-grid', base: Container, sourceContext: true, subTags: 'struct,div',
@@ -29,6 +44,10 @@ export const Grid = defineComponent({
29
44
  viewport: {dtype:'X', nullable:true, default:null, binding:'write'},
30
45
  sortRequest: {dtype:'T', default:'', binding:'write'},
31
46
  storepath: {dtype: 'T'}, structpath: {dtype: 'T'}, rowMode: {dtype: 'T'},
47
+ delrow: {dtype:'T', nullable:true, default:null},
48
+ delrow_label: {dtype:'T', nullable:true, default:null, binding:'read'},
49
+ emptyText: {dtype:'T', nullable:true, default:null, binding:'read'},
50
+ autoHeight: {dtype:'B', default:false, binding:'read'},
32
51
  rowHeaders: {dtype:'B', default:false, binding:'read'},
33
52
  footer: {dtype:['B','T'], default:false, binding:'read'},
34
53
  selectionMode: {dtype:'T', default:'multi', binding:'read'},
@@ -252,9 +271,14 @@ export const Grid = defineComponent({
252
271
  if (this.control.style.getPropertyValue('--grid-scrollbar-width') !== width) {
253
272
  this.control.style.setProperty('--grid-scrollbar-width', width);
254
273
  }
274
+ // clientWidth rounds a fractional width; a box wider than the real width adds a horizontal scrollbar.
275
+ const visible = `${Math.floor(this.#bodyViewport.getBoundingClientRect().width) - gutter}px`;
276
+ if (this.control.style.getPropertyValue('--grid-viewport-width') !== visible) {
277
+ this.control.style.setProperty('--grid-viewport-width', visible);
278
+ }
255
279
  this.#sizeRowHeader();
256
- for (const header of this.#head.querySelectorAll('th[scope=col]')) {
257
- header.querySelector('.column-resize').setAttribute('aria-valuenow', String(Math.round(header.getBoundingClientRect().width)));
280
+ for (const handle of this.#head.querySelectorAll('.column-resize')) {
281
+ handle.setAttribute('aria-valuenow', String(Math.round(handle.parentElement.getBoundingClientRect().width)));
258
282
  }
259
283
  for (const row of this.#rows.values()) {
260
284
  const handle = row.querySelector('.row-height-handle');
@@ -407,11 +431,11 @@ export const Grid = defineComponent({
407
431
  parameters:() => this.parameters, document:this.ownerDocument});
408
432
  if (this.isConnected) this.#tools.connect();
409
433
  this.#columnFilters.setSourceContext(context);
410
- this.#checkSets = new GridCheckSets(context.sourceNode, this.#body,
434
+ this.#checkSets = new GridCheckSets(context.sourceNode, this.#body, this.#head,
411
435
  () => this.#structure?.columns ?? [],
412
436
  element => { const label = this.#labelOf(element); return label === null ? undefined : this.#rowNodes([label])[0]; },
413
437
  (node,field) => this.#collectionView.value(node,field),
414
- () => this.parameters.setFilter, () => this.#collectionView);
438
+ () => this.parameters.setFilter, () => this.#collectionView, () => this.#windowInfo() !== null);
415
439
  if (this.isConnected) this.#checkSets.connect();
416
440
  this.#cellEditor = new GridCellEditor(this, context, (row, field) => this.#rows.get(row)?.querySelector(`td[data-field="${field}"]`),
417
441
  () => ({labels:() => this.#collectionStore().getRows().map(row => row.label), window:this.#windowInfo()}),
@@ -511,6 +535,10 @@ export const Grid = defineComponent({
511
535
  const store = this.#collectionStore();
512
536
  this.#formulas.configure(model, this.#collectionView, store);
513
537
  this.#requireStoredCriteria();
538
+ if (this.parameters.delrow !== null && this.parameters.delrow !== 'row') throw new TypeError("grid delrow requires 'row'");
539
+ if (this.parameters.delrow === 'row' && !model.columns.some(column => column.edit)) {
540
+ throw new TypeError("grid tool 'grid:delrow' requires an editable column");
541
+ }
514
542
  this.#tools.requireEditableTools(model.columns);
515
543
  this.#selection.prune();
516
544
  const structureChanged = this.#structureDirty;
@@ -535,11 +563,13 @@ export const Grid = defineComponent({
535
563
  // View values (#, += and their dependents) derive from the order: they are not searchable.
536
564
  gridSearch(this.#context.sourceNode).update(this.#collectionView,
537
565
  model.columns.filter(column => !column.check && !this.#formulas.viewFields.has(column.field)));
566
+ // The grid takes the height of its rows; a max_height style caps it and the body scrolls.
567
+ this.toggleAttribute('data-auto-height', this.parameters.autoHeight);
538
568
  const rowHeaders = this.parameters.rowHeaders || this.parameters.rowResize;
539
- const signature = JSON.stringify([model.groups, rowHeaders, this.parameters.columnFilters, this.parameters.footer]);
569
+ const signature = JSON.stringify([model.groups, rowHeaders, this.parameters.delrow, this.parameters.delrow_label, this.parameters.columnFilters, this.parameters.footer]);
540
570
  this.#rowHeaders = rowHeaders;
541
571
  if (signature !== this.#signature) {
542
- this.#footer.configure(this.parameters.footer, model.columns, rowHeaders);
572
+ this.#footer.configure(this.parameters.footer, model.columns, rowHeaders, this.parameters.delrow === 'row');
543
573
  this.#renderHeader(model);
544
574
  this.#signature = signature;
545
575
  }
@@ -547,9 +577,10 @@ export const Grid = defineComponent({
547
577
  this.#declareDerived(structureChanged);
548
578
  this.#columnFilters.update(this.#collectionView, model.columns, this.parameters.columnFilters, this.#context.format);
549
579
  this.#renderSort();
580
+ this.#checkSets.projectHeaders();
550
581
  this.#renderWindow(true);
551
582
  this.#renderSelection();
552
- this.control.setAttribute('aria-colcount', String(model.columns.length + Number(this.#rowHeaders)));
583
+ this.control.setAttribute('aria-colcount', String(this.#columnCount(model.columns)));
553
584
  this.control.setAttribute('aria-rowcount', String(this.#headerRows + Math.max(this.#rowLayout.count, 1)));
554
585
  this.#scheduleLayout();
555
586
  }
@@ -587,6 +618,14 @@ export const Grid = defineComponent({
587
618
  return Object.fromEntries(node.staticValue.getNodes().filter(cell => !(cell.staticValue instanceof Bag)).map(cell => [cell.label, cell.staticValue]));
588
619
  }
589
620
  #renderSelection() {
621
+ const source = this.#context.sourceNode;
622
+ if (source.getAttr('frameTarget')) {
623
+ const remove = source.parentNode.parentNode?.value.getNode('top.bar.delrow');
624
+ if (remove?.getAttr('command') === 'grid:delrow') {
625
+ const disabled = this.#selection.current === null;
626
+ if (remove.getAttr('disabled') !== disabled) remove.setAttr({disabled});
627
+ }
628
+ }
590
629
  const mode = this.#selectionMode();
591
630
  if (mode === 'multi') this.control.setAttribute('aria-multiselectable', 'true');
592
631
  else this.control.removeAttribute('aria-multiselectable');
@@ -638,7 +677,7 @@ export const Grid = defineComponent({
638
677
  #renderSort() {
639
678
  const criteria = this.#windowInfo() ? parseSort(this.#windowInfo().sortedBy) : this.#collectionView.criteria;
640
679
  this.#sizeRowHeader();
641
- for (const header of this.#head.querySelectorAll('th[scope=col]')) {
680
+ for (const header of this.#head.querySelectorAll('th[data-field]')) {
642
681
  const index = criteria.findIndex(item => item.field === header.dataset.field);
643
682
  header.removeAttribute('aria-sort');
644
683
  if (index < 0) {
@@ -674,10 +713,11 @@ export const Grid = defineComponent({
674
713
  const caption = doc.createElement('span');
675
714
  caption.className = 'column-caption'; caption.textContent = text; cell.replaceChildren(caption);
676
715
  const column = model.columns[index];
716
+ if (column.check === 'multiple') cell.prepend(this.#checkSets.headerInput(column, `${column.title ?? column.name}: ${this.#texts().checkAll}`));
677
717
  cell.dataset.field = column.field;
678
718
  cell.draggable = true; cell.tabIndex = 0;
679
719
  cell.setAttribute('aria-label', column.title ?? column.name);
680
- cell.title = column.check ? (column.title ?? column.name) + ' · Drag to reorder' : 'Click: ascending / descending · Shift-click: add or reverse this column without changing the others · Numbers show sort priority · Drag to reorder';
720
+ cell.title = column.check ? `${column.title ?? column.name} · ${this.#texts().reorder}` : this.#texts().sort;
681
721
  const indicator = doc.createElementNS(SVG_NS, 'svg');
682
722
  indicator.classList.add('sort-indicator'); indicator.setAttribute('viewBox', '0 0 16 16');
683
723
  indicator.setAttribute('aria-hidden', 'true');
@@ -690,7 +730,7 @@ export const Grid = defineComponent({
690
730
  handle.setAttribute('aria-orientation', 'vertical');
691
731
  handle.setAttribute('aria-valuemin', '40');
692
732
  handle.setAttribute('aria-label', `Resize ${column.name}`);
693
- handle.title = 'Drag to resize · Arrow keys adjust width';
733
+ handle.title = this.#texts().resizeColumn;
694
734
  cell.append(handle);
695
735
  }
696
736
  return cell;
@@ -709,7 +749,7 @@ export const Grid = defineComponent({
709
749
  handle.className = 'column-resize'; handle.tabIndex = 0;
710
750
  handle.setAttribute('role', 'separator'); handle.setAttribute('aria-orientation', 'vertical');
711
751
  handle.setAttribute('aria-label', 'Resize row numbers');
712
- handle.title = 'Drag to resize · Arrow keys adjust width';
752
+ handle.title = this.#texts().resizeColumn;
713
753
  corner.append(probe, handle); top.append(corner);
714
754
  }
715
755
  let index = 0;
@@ -729,9 +769,17 @@ export const Grid = defineComponent({
729
769
  (grouped ? bottom : top).append(header(col.name, 1, 1, 'col', index++, col.align));
730
770
  }
731
771
  }
772
+ if (this.parameters.delrow === 'row') {
773
+ const action = doc.createElement('th');
774
+ action.scope = 'col'; action.rowSpan = this.#headerRows;
775
+ action.setAttribute('role', 'columnheader');
776
+ action.setAttribute('aria-label', this.#deleteCaption());
777
+ top.append(action);
778
+ }
732
779
  this.#head.replaceChildren(top, ...(grouped ? [bottom] : []));
733
780
  if (focusedField) this.#head.querySelector(`th[data-field="${focusedField}"]${resizeFocused ? ' .column-resize' : ''}`)?.focus({preventScroll:true});
734
781
  const widths = model.columns.map(column => column.width ?? 'var(--gramlot-grid-column-width, 10rem)');
782
+ if (this.parameters.delrow === 'row') widths.push('var(--gramlot-grid-action-width, 2.5rem)');
735
783
  if (this.#rowHeaders) widths.unshift('max(var(--grid-row-header-min-width, 0px), var(--grid-row-header-width, var(--gramlot-grid-row-header-width, 44px)))');
736
784
  this.control.style.setProperty('--grid-columns-width', `calc(${widths.join(' + ')})`);
737
785
  // Identical colgroups and table constraints keep one CSS sizing policy for both areas.
@@ -747,6 +795,11 @@ export const Grid = defineComponent({
747
795
  }
748
796
  return element;
749
797
  }));
798
+ if (this.parameters.delrow === 'row') {
799
+ const group = doc.createElement('colgroup'), col = doc.createElement('col');
800
+ col.style.width = 'var(--gramlot-grid-action-width, 2.5rem)';
801
+ group.append(col); table.insertBefore(group, table.querySelector('thead,tbody,tfoot'));
802
+ }
750
803
  if (this.#rowHeaders) {
751
804
  const group = doc.createElement('colgroup'), col = doc.createElement('col');
752
805
  col.style.width = 'max(var(--grid-row-header-min-width, 0px), var(--grid-row-header-width, var(--gramlot-grid-row-header-width, 44px)))';
@@ -754,6 +807,42 @@ export const Grid = defineComponent({
754
807
  }
755
808
  }
756
809
  }
810
+ #columnCount(columns) {
811
+ return columns.length + Number(this.#rowHeaders) + Number(this.parameters.delrow === 'row');
812
+ }
813
+
814
+ #deleteCaption() {
815
+ return this.parameters.delrow_label ?? this.#texts().deleteRow;
816
+ }
817
+ #texts() {
818
+ const language = this.#context.locale.split('-')[0].toLowerCase();
819
+ return TEXTS[language] ?? TEXTS.en;
820
+ }
821
+
822
+ #renderRowAction(tr, label, columnCount) {
823
+ let cell = tr.querySelector('.row-delete');
824
+ if (this.parameters.delrow !== 'row') { cell?.remove(); return; }
825
+ if (!cell) {
826
+ cell = this.ownerDocument.createElement('td');
827
+ cell.className = 'row-delete';
828
+ cell.setAttribute('role', 'cell');
829
+ const button = this.ownerDocument.createElement('button');
830
+ button.type = 'button';
831
+ const icon = this.ownerDocument.createElement('img');
832
+ icon.src = icons.delete; icon.alt = '';
833
+ button.append(icon);
834
+ button.addEventListener('click', event => {
835
+ event.stopPropagation();
836
+ this.#tools.deleteRow(label);
837
+ });
838
+ cell.append(button); tr.append(cell);
839
+ }
840
+ cell.setAttribute('aria-colindex', String(columnCount));
841
+ const button = cell.firstElementChild;
842
+ button.title = this.#deleteCaption();
843
+ button.setAttribute('aria-label', button.title);
844
+ }
845
+
757
846
  #renderRows(rows, columns, start) {
758
847
  this.#rowInteraction.cancel();
759
848
 
@@ -794,7 +883,7 @@ export const Grid = defineComponent({
794
883
  handle.className = 'row-height-handle'; handle.tabIndex = 0;
795
884
  handle.setAttribute('role', 'separator');
796
885
  handle.setAttribute('aria-orientation', 'horizontal');
797
- handle.title = 'Drag to resize row · Double-click or Home resets · Arrow keys adjust height';
886
+ handle.title = this.#texts().resizeRow;
798
887
  heading.append(handle);
799
888
  }
800
889
  handle.setAttribute('aria-label', `Resize row ${start + keep.size + 1}`);
@@ -821,13 +910,14 @@ export const Grid = defineComponent({
821
910
  if (capped) content.tabIndex = 0; else content.removeAttribute('tabindex');
822
911
  td.style.textAlign = column.align;
823
912
  td.style.whiteSpace = column.white_space ?? '';
824
- td.style.overflowWrap = column.white_space === 'pre-wrap' || column.white_space === 'normal' ? 'anywhere' : '';
913
+ td.style.overflowWrap = column.white_space === 'pre-wrap' || column.white_space === 'normal' ? 'break-word' : '';
825
914
  td.setAttribute('aria-colindex', String(index + 1 + offset));
826
915
  td.classList.toggle('numeric', ['L', 'R', 'N'].includes(column.dtype));
827
916
  if (tr.cells[index + offset] !== td) tr.insertBefore(td, tr.cells[index + offset] ?? null);
828
917
  existing.delete(column.field);
829
918
  }
830
919
  for (const td of existing.values()) td.remove();
920
+ this.#renderRowAction(tr, label, this.#columnCount(columns));
831
921
  tr.setAttribute('aria-rowindex', String(this.#headerRows + start + keep.size + 1));
832
922
  this.#renderCells(tr, cells, node);
833
923
  this.#cellEditor.decorate(tr, label);
@@ -840,8 +930,12 @@ export const Grid = defineComponent({
840
930
  if (!rows.length && this.#rowLayout.count === 0 && !this.parameters.loading) {
841
931
  const tr = this.ownerDocument.createElement('tr'), td = this.ownerDocument.createElement('td');
842
932
  tr.setAttribute('role', 'row'); tr.setAttribute('aria-rowindex', String(this.#headerRows + 1));
843
- td.setAttribute('role', 'cell'); td.setAttribute('aria-colspan', String(columns.length + Number(this.#rowHeaders)));
844
- td.className = 'empty'; td.colSpan = columns.length + Number(this.#rowHeaders); td.textContent = 'No rows'; tr.append(td); this.#body.append(tr);
933
+ td.setAttribute('role', 'cell'); td.setAttribute('aria-colspan', String(this.#columnCount(columns)));
934
+ td.className = 'empty'; td.colSpan = this.#columnCount(columns);
935
+ // The text box has the visible width and stays at the left edge, so the text is centred on what the user sees.
936
+ const text = this.ownerDocument.createElement('div');
937
+ text.className = 'empty-text'; text.textContent = this.parameters.emptyText ?? this.#texts().empty;
938
+ td.append(text); tr.append(td); this.#body.append(tr);
845
939
  }
846
940
  }
847
941
  #renderCells(row, cells, node) {
@@ -0,0 +1,61 @@
1
+ /** Commands of the `htmlEditor` namespace, delivered by publication to the frame's htmlEditorCanvas. */
2
+ export const HTML_EDITOR_COMMANDS = Object.freeze({
3
+ undo: {label:'Undo', publish:'undo', icon:'undo'},
4
+ redo: {label:'Redo', publish:'redo', icon:'redo'},
5
+ paragraph: {label:'Paragraph', publish:'paragraph', icon:'paragraph', tooltip:'Block format'},
6
+ bold: {label:'Bold', publish:'bold', icon:'bold'},
7
+ italic: {label:'Italic', publish:'italic', icon:'italic'},
8
+ underline: {label:'Underline', publish:'underline', icon:'underline'},
9
+ strikethrough: {label:'Strikethrough', publish:'strikethrough', icon:'strikethrough'},
10
+ color: {label:'Color', publish:'color', icon:'palette', tooltip:'Text and background color'},
11
+ eraser: {label:'Clear formatting', publish:'eraser', icon:'eraser'},
12
+ ul: {label:'Bulleted list', publish:'ul', icon:'list-bulleted'},
13
+ ol: {label:'Numbered list', publish:'ol', icon:'list-numbered'},
14
+ outdent: {label:'Decrease indent', publish:'outdent', icon:'outdent'},
15
+ indent: {label:'Increase indent', publish:'indent', icon:'indent'},
16
+ align: {label:'Align', publish:'align', icon:'align-left'},
17
+ link: {label:'Link', publish:'link', icon:'link', tooltip:'Insert or edit a link'},
18
+ image: {label:'Image', publish:'image', icon:'image', tooltip:'Insert an image'},
19
+ table: {label:'Table', publish:'table', icon:'table', tooltip:'Insert a table'},
20
+ hr: {label:'Horizontal line', publish:'hr', icon:'horizontal-rule'},
21
+ find: {label:'Find', publish:'find', icon:'search', tooltip:'Find and replace'},
22
+ selectall: {label:'Select all', publish:'selectall', icon:'select-all'},
23
+ });
24
+
25
+ /** Block formats of `htmlEditor:paragraph`, by `tag` parameter, in menu order. */
26
+ export const HTML_EDITOR_BLOCKS = Object.freeze({p:'Paragraph', h1:'Heading 1', h2:'Heading 2', h3:'Heading 3',
27
+ h4:'Heading 4', blockquote:'Quote', pre:'Code'});
28
+
29
+ /** Alignments of `htmlEditor:align`, by `value` parameter, with their captions and icons. */
30
+ export const HTML_EDITOR_ALIGNMENTS = Object.freeze({left:['Left', 'align-left'], center:['Center', 'align-center'],
31
+ right:['Right', 'align-right'], justify:['Justify', 'align-justify']});
32
+
33
+ /**
34
+ * The standard toolbar, in order: a command name, `-` for a divider, or a submenu
35
+ * `[name, parameter, choices]` with one line of the command for each choice.
36
+ */
37
+ export const HTML_EDITOR_TOOLBAR = Object.freeze(['undo', 'redo', '-', ['paragraph', 'tag', 'blocks'], 'bold', 'italic',
38
+ 'underline', 'strikethrough', 'color', 'eraser', '-', 'ul', 'ol', 'outdent', 'indent', ['align', 'value', 'alignments'],
39
+ '-', 'link', 'image', 'table', 'hr', '-', 'find', 'selectall']);
40
+
41
+ /** Register the htmlEditor command group on one Gramlot page. */
42
+ export function registerHtmlEditorCommands(gramlot) {
43
+ const group = gramlot.commands.registerGroup('htmlEditor', {description:'HTML editor toolbar commands'});
44
+ for (const [name, definition] of Object.entries(HTML_EDITOR_COMMANDS)) group.register(name, definition);
45
+ }
46
+
47
+ /** Compose the standard toolbar lines in `bar`, a `menu(presentation="bar")` Source node. */
48
+ export function htmlEditorToolbar(bar) {
49
+ const choices = {blocks:Object.fromEntries(Object.entries(HTML_EDITOR_BLOCKS).map(([key, caption]) => [key, [caption, null]])),
50
+ alignments:HTML_EDITOR_ALIGNMENTS};
51
+ HTML_EDITOR_TOOLBAR.forEach((entry, index) => {
52
+ if (entry === '-') { bar.menuline('-', {node_label:`divider_${index}`}); return; }
53
+ if (typeof entry === 'string') { bar.menuline({command:`htmlEditor:${entry}`, node_label:entry}); return; }
54
+ const [name, parameter, list] = entry, definition = HTML_EDITOR_COMMANDS[name];
55
+ const menu = bar.menuline({caption:definition.label, icon:definition.icon, node_label:name}).menu();
56
+ for (const [key, [caption, icon]] of Object.entries(choices[list])) {
57
+ menu.menuline({command:`htmlEditor:${name}`, caption, parameters:{[parameter]:key}, node_label:key,
58
+ ...(icon === null ? {} : {icon})});
59
+ }
60
+ });
61
+ }
@@ -3,6 +3,8 @@ import {loadLibrary} from '../libraries.js';
3
3
  import {defineComponent} from './registry.js';
4
4
  import {Labelbox} from './labelbox.js';
5
5
  import {FieldState} from './field-state.js';
6
+ import {EditorCommands} from './editor-commands.js';
7
+ import {HTML_EDITOR_COMMANDS} from './html-editor-commands.js';
6
8
 
7
9
  let engineModule;
8
10
  function HtmlControl(HTMLElement) {
@@ -22,7 +24,11 @@ function HtmlControl(HTMLElement) {
22
24
  });
23
25
  }
24
26
  get liveWrites() {return true;}
25
- connectedCallback() {this.load();}
27
+ setSourceContext(context) {
28
+ this.commands=new EditorCommands(context,'htmlEditor',Object.fromEntries(Object.keys(HTML_EDITOR_COMMANDS)
29
+ .map(name=>[name,message=>this.engine?.execute(name,message)])));
30
+ }
31
+ connectedCallback() {this.commands.connect();this.load();}
26
32
  load() {
27
33
  const generation=++this.#generation;
28
34
  this.engine?.destroy();this.engine=null;
@@ -31,6 +37,7 @@ function HtmlControl(HTMLElement) {
31
37
  if (generation!==this.#generation || !this.isConnected) return;
32
38
  this.control.textContent='';
33
39
  this.engine=module.createHtmlEditor(this);
40
+ this.editorStateChanged();
34
41
  }).catch(error=>{
35
42
  if (generation!==this.#generation) return;
36
43
  this.control.textContent=`HTML editor could not start: ${error.message}`;
@@ -57,13 +64,21 @@ function HtmlControl(HTMLElement) {
57
64
  this.#value=value;
58
65
  this.control.dispatchEvent(new this.ownerDocument.defaultView.Event('input',{bubbles:true}));
59
66
  }
67
+ /** Write the state of the frame's htmlEditor commands. Called by the engine after a selection or history change. */
68
+ editorStateChanged() {if(this.engine)this.commands.refresh((name,parameters)=>this.engine.commandState(name,parameters));}
69
+ /** The element where a command popup opens: the activated menuline, or the editing area when it is not shown (toolbar overflow). */
70
+ commandAnchor(sender) {
71
+ const element=this.commands.runtime.renderer.getDomNode(sender);
72
+ return element?.getClientRects().length ? element : this.control;
73
+ }
60
74
  editorBlurred() {this.control.dispatchEvent(new this.ownerDocument.defaultView.Event('change',{bubbles:true}));}
61
75
  undo() {return this.engine ? this.engine.undo() : false;}
62
76
  redo() {return this.engine ? this.engine.redo() : false;}
63
77
  focus() {if (!this.parameters.disabled) this.engine?.focus();}
64
- releaseControl() {++this.#generation;this.engine?.destroy();this.engine=null;super.releaseControl();}
78
+ releaseControl() {++this.#generation;this.commands.disconnect();this.engine?.destroy();this.engine=null;super.releaseControl();}
65
79
  };
66
80
  }
67
81
  HtmlControl.parameters={disabled:{dtype:'B',default:false,binding:'read'},readonly:{dtype:'B',default:false,binding:'read'},live:{dtype:'B',default:true,binding:'read'}};
68
- export const HtmlEditor=defineComponent({name:'htmlEditor',tag:'gramlot-html-editor',base:HtmlControl,mixins:[Labelbox,FieldState],
82
+ /** The editing area of `htmlEditor`, which composes it in the center of a framePane with the htmlEditor toolbar. */
83
+ export const HtmlEditorCanvas=defineComponent({name:'htmlEditorCanvas',tag:'gramlot-html-editor-canvas',base:HtmlControl,sourceContext:true,mixins:[Labelbox,FieldState],
69
84
  parameters:{value:{dtype:'T',default:'',binding:'twoWay'}},implementation:Base=>class extends Base {}});
@@ -2,6 +2,8 @@ import tree from './tree.js';
2
2
  import {checkBoxChoices} from './check-box-text.js';
3
3
  import {EditingStatus} from './editing-status.js';
4
4
  import {defineComponent, defineCollection} from './registry.js';
5
+ import {numericRange, numericRangeParameters} from './numeric-range.js';
6
+ import {Knob, StarRating} from './graphical-ranges.js';
5
7
  import {NativeControl, ChoiceGroup} from './bases.js';
6
8
  import {Labelbox} from './labelbox.js';
7
9
  import {TypedEditor, numberEditor, dateEditor, timeEditor} from './typed-editor.js';
@@ -120,42 +122,110 @@ export const Colorpicker = defineComponent({
120
122
  implementation: textEditor('input', 'color')
121
123
  });
122
124
  const rangeParameters = {
123
- value: {dtype: 'R', default: 0, binding: 'twoWay'},
124
- min: {dtype: 'R', default: 0, binding: 'read', target: 'control'},
125
- max: {dtype: 'R', default: 100, binding: 'read', target: 'control'},
126
- step: {dtype: 'R', default: 1, binding: 'read', target: 'control'}
125
+ thin: {dtype:'B', default:false, binding:'read'},
126
+ showValue: {dtype:'B', default:false, binding:'read'},
127
+ ...numericRangeParameters
127
128
  };
128
129
  function rangeEditor(vertical) {
129
- return Base => class extends Base {
130
- #sourceContext;
131
- #correcting = false;
132
- setSourceContext(context) { this.#sourceContext = context; }
130
+ return Base => class extends numericRange(Base) {
131
+ #bubble;
132
+ #dragEvents;
133
+
134
+ constructor() {
135
+ super();
136
+ const doc = this.ownerDocument;
137
+ const style = doc.createElement('style');
138
+ style.textContent = `
139
+ :host([data-thin]) input{appearance:none;background:transparent;border:0;padding:0}
140
+ :host([data-thin]) input::-webkit-slider-runnable-track{block-size:2px;background:var(--gramlot-border-control,GrayText);border-radius:2px}
141
+ :host([data-thin]) input::-webkit-slider-thumb{appearance:none;inline-size:12px;block-size:12px;margin-block-start:-5px;
142
+ background:var(--gramlot-action,Highlight);border-radius:50%}
143
+ :host([data-thin]) input::-moz-range-track{block-size:2px;background:var(--gramlot-border-control,GrayText)}
144
+ :host([data-thin]) input::-moz-range-thumb{width:12px;height:12px;border:0;border-radius:50%;background:var(--gramlot-action,Highlight)}
145
+ :host([data-thin]) input[type=range]{min-block-size:max(32px,var(--gramlot-touch-target,0px))}
146
+ .range-anchor{display:inline-flex;position:relative;vertical-align:middle;max-width:100%;${vertical ? '' : 'width:100%'}}
147
+ .range-anchor input{margin:0}
148
+ .range-value{position:absolute;pointer-events:none;padding:3px 7px;border-radius:4px;white-space:nowrap;
149
+ z-index:1;font:600 13px/1.25 system-ui;font-variant-numeric:tabular-nums;
150
+ background:var(--gramlot-ink,CanvasText);color:var(--gramlot-surface,Canvas);
151
+ ${vertical ? 'left:100%;bottom:var(--range-position);transform:translateY(50%)' :
152
+ 'bottom:calc(50% + 10px);inset-inline-start:var(--range-position);transform:translateX(-50%)'}}
153
+ ${vertical ? '' : '.range-anchor:dir(rtl) .range-value{transform:translateX(50%)}'}
154
+ .range-value[hidden]{display:none}
155
+ `;
156
+ this.shadowRoot.append(style);
157
+ this.control.addEventListener('pointerdown', event => {
158
+ if (!this.parameters.showValue || !event.isPrimary || event.button !== 0) return;
159
+ this.#hideValue();
160
+ const win = doc.defaultView;
161
+ this.#dragEvents = new win.AbortController();
162
+ const options = {capture:true, signal:this.#dragEvents.signal};
163
+ for (const type of ['pointerup','pointercancel']) win.addEventListener(type, end => {
164
+ if (end.pointerId === event.pointerId) this.#hideValue();
165
+ }, options);
166
+ win.addEventListener('blur', () => this.#hideValue(), options);
167
+ this.#showValue();
168
+ });
169
+ this.control.addEventListener('blur', () => this.#hideValue());
170
+ this.control.addEventListener('keydown', event => {
171
+ if (this.parameters.showValue && ['ArrowLeft','ArrowRight','ArrowUp','ArrowDown','PageUp','PageDown','Home','End'].includes(event.key)) {
172
+ this.#showValue();
173
+ }
174
+ });
175
+ this.control.addEventListener('input', () => this.#updateValue());
176
+ }
177
+ #showValue() {
178
+ this.#bubble.hidden = false;
179
+ this.#updateValue();
180
+ }
181
+ #updateValue() {
182
+ if (!this.#bubble || this.#bubble.hidden) return;
183
+ const control = this.control;
184
+ const min = Number(control.min), max = Number(control.max);
185
+ const fraction = max > min ? (control.valueAsNumber - min) / (max - min) : 0;
186
+ const radius = this.parameters.thin ? 6 : 8;
187
+ this.#bubble.style.setProperty('--range-position', `calc(${fraction * 100}% + ${(1 - 2 * fraction) * radius}px)`);
188
+ this.#bubble.textContent = control.valueAsNumber.toLocaleString(this.closest('[lang]')?.lang || this.pageContext.locale,
189
+ {maximumSignificantDigits:21});
190
+ }
191
+ #hideValue() {
192
+ this.#dragEvents?.abort();
193
+ this.#dragEvents = null;
194
+ if (this.#bubble) this.#bubble.hidden = true;
195
+ }
196
+ #prepareBubble() {
197
+ const anchor = this.ownerDocument.createElement('span');
198
+ anchor.className = 'range-anchor';
199
+ this.control.before(anchor);
200
+ this.#bubble = this.ownerDocument.createElement('span');
201
+ this.#bubble.className = 'range-value';
202
+ this.#bubble.hidden = true;
203
+ this.#bubble.setAttribute('aria-hidden','true');
204
+ anchor.append(this.control, this.#bubble);
205
+ }
206
+ releaseControl() {
207
+ this.#hideValue();
208
+ super.releaseControl();
209
+ }
133
210
  projectAttributes(attrs, adapt) {
134
- const previous = this.parameters;
135
211
  const rest = super.projectAttributes(attrs, adapt);
136
- if (previous && ['min', 'max', 'step'].some(name => previous[name] !== this.parameters[name])) {
137
- this.writeControlValue(this.parameters.value);
138
- }
212
+ this.toggleAttribute('data-thin', this.parameters.thin);
213
+ if (this.parameters.showValue && !this.#bubble) this.#prepareBubble();
214
+ if (!this.parameters.showValue || this.parameters.disabled) this.#hideValue();
215
+ else this.#updateValue();
139
216
  return rest;
140
217
  }
141
218
  createControl() {
142
- const control = this.ownerDocument.createElement('input');
143
- control.type = 'range';
219
+ const control = super.createControl();
144
220
  if (vertical) {
145
221
  control.style.cssText = 'writing-mode:vertical-lr;direction:rtl;width:var(--gramlot-slider-width,1.5rem);height:var(--gramlot-slider-height,10rem)';
146
222
  control.setAttribute('aria-orientation', 'vertical');
147
223
  } else control.style.width = '100%';
148
224
  return control;
149
225
  }
150
- readControlValue() { return this.control.valueAsNumber; }
151
226
  writeControlValue(value) {
152
- this.control.value = String(value);
153
- const corrected = this.control.valueAsNumber;
154
- if (!this.#correcting && Number.isFinite(value) && Number.isFinite(corrected) && corrected !== value) {
155
- this.#correcting = true;
156
- try { this.#sourceContext.writeParameter('value', corrected); }
157
- finally { this.#correcting = false; }
158
- }
227
+ super.writeControlValue(value);
228
+ this.#updateValue();
159
229
  }
160
230
  };
161
231
  }
@@ -241,6 +311,7 @@ export const CheckBoxText = defineComponent({
241
311
  cols: {dtype: 'L', default: 1, binding: 'read'},
242
312
  popup: {dtype: 'B', default: false, binding: 'read'},
243
313
  hierarchical: {dtype: 'B', default: false, binding: 'read'},
314
+ eagerCheck: {dtype: 'B', default: false, binding: 'read'},
244
315
  checkChildren: {dtype: 'B', default: true, binding: 'read'},
245
316
  identifier: {dtype: 'T', binding: 'read'},
246
317
  labelAttribute: {dtype: 'T', binding: 'read'},
@@ -252,5 +323,5 @@ export const CheckBoxText = defineComponent({
252
323
  }, implementation: checkBoxChoices
253
324
  });
254
325
  export default defineCollection({name: 'inputs', dependencies:[tree], components: [EditingStatus, Textbox, Checkbox, RadioButtonText,
255
- TextBoxArea, Passwordbox, RadioButton, Colorpicker, HorizontalSlider, VerticalSlider,
326
+ TextBoxArea, Passwordbox, RadioButton, Colorpicker, HorizontalSlider, VerticalSlider, Knob, StarRating,
256
327
  NumberTextBox, DateTextBox, TimeTextBox, FilteringSelect, CallbackSelect, ComboBox, DbSelect, DbComboBox, CheckBoxText, DateCalendar]});