@gramlot/gramlot 0.3.41 → 0.4.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 (276) hide show
  1. package/assets/icons/applications.svg +4 -0
  2. package/assets/icons/archive.svg +4 -0
  3. package/assets/icons/attachment.svg +4 -0
  4. package/assets/icons/book.svg +4 -0
  5. package/assets/icons/bookmark.svg +4 -0
  6. package/assets/icons/calendar.svg +4 -0
  7. package/assets/icons/cancel.svg +4 -0
  8. package/assets/icons/chart.svg +4 -1
  9. package/assets/icons/chat.svg +4 -0
  10. package/assets/icons/clock.svg +4 -0
  11. package/assets/icons/code.svg +4 -0
  12. package/assets/icons/collapse.svg +4 -0
  13. package/assets/icons/columns.svg +4 -0
  14. package/assets/icons/confirm.svg +4 -0
  15. package/assets/icons/copy.svg +4 -0
  16. package/assets/icons/cut.svg +4 -0
  17. package/assets/icons/database.svg +4 -0
  18. package/assets/icons/delete.svg +4 -0
  19. package/assets/icons/detach.svg +4 -0
  20. package/assets/icons/document.svg +4 -0
  21. package/assets/icons/download.svg +4 -0
  22. package/assets/icons/duplicate.svg +4 -0
  23. package/assets/icons/edit.svg +4 -0
  24. package/assets/icons/expand.svg +4 -0
  25. package/assets/icons/export.svg +4 -0
  26. package/assets/icons/eye.svg +4 -0
  27. package/assets/icons/filter.svg +4 -0
  28. package/assets/icons/first.svg +4 -0
  29. package/assets/icons/folder.svg +4 -0
  30. package/assets/icons/group.svg +4 -0
  31. package/assets/icons/help.svg +4 -0
  32. package/assets/icons/home.svg +4 -0
  33. package/assets/icons/import.svg +4 -0
  34. package/assets/icons/info.svg +4 -0
  35. package/assets/icons/inspector.svg +4 -0
  36. package/assets/icons/last.svg +4 -0
  37. package/assets/icons/layers.svg +4 -0
  38. package/assets/icons/link.svg +4 -0
  39. package/assets/icons/list.svg +4 -0
  40. package/assets/icons/lock.svg +4 -0
  41. package/assets/icons/logout.svg +4 -0
  42. package/assets/icons/navigation.svg +4 -0
  43. package/assets/icons/new.svg +4 -0
  44. package/assets/icons/next.svg +4 -0
  45. package/assets/icons/open.svg +4 -0
  46. package/assets/icons/palette.svg +4 -0
  47. package/assets/icons/panel-bottom.svg +4 -0
  48. package/assets/icons/panel-left.svg +4 -0
  49. package/assets/icons/panel-right.svg +4 -0
  50. package/assets/icons/panel-top.svg +4 -0
  51. package/assets/icons/paste.svg +4 -0
  52. package/assets/icons/pause.svg +4 -0
  53. package/assets/icons/pin.svg +4 -0
  54. package/assets/icons/play.svg +4 -0
  55. package/assets/icons/previous.svg +4 -0
  56. package/assets/icons/print.svg +4 -0
  57. package/assets/icons/redo.svg +4 -0
  58. package/assets/icons/refresh.svg +4 -0
  59. package/assets/icons/save.svg +4 -0
  60. package/assets/icons/search.svg +4 -0
  61. package/assets/icons/send.svg +4 -0
  62. package/assets/icons/settings.svg +4 -0
  63. package/assets/icons/sort-ascending.svg +4 -0
  64. package/assets/icons/sort-descending.svg +4 -0
  65. package/assets/icons/stop.svg +4 -0
  66. package/assets/icons/table.svg +4 -0
  67. package/assets/icons/tree.svg +4 -0
  68. package/assets/icons/undo.svg +4 -0
  69. package/assets/icons/unlock.svg +4 -0
  70. package/assets/icons/upload.svg +4 -0
  71. package/assets/icons/user.svg +4 -0
  72. package/assets/icons/warning.svg +4 -0
  73. package/assets/icons/zoom-in.svg +4 -0
  74. package/assets/icons/zoom-out.svg +4 -0
  75. package/dist/components/charts/__init__.py +1 -1
  76. package/dist/components/charts/assets/index.js +1 -1
  77. package/dist/components/charts/assets/libraries/vega.js +11 -11
  78. package/dist/components/editors/__init__.py +1 -1
  79. package/dist/components/editors/assets/index.js +1 -1
  80. package/dist/components/editors/assets/libraries/codemirror.js +30 -31
  81. package/dist/components/editors/assets/libraries/jodit.js +3 -1
  82. package/dist/components/editors/grammar.json +6 -1
  83. package/dist/components/grid/__init__.py +1 -1
  84. package/dist/components/grid/assets/index.js +1 -1
  85. package/dist/components/grid/commands.json +4 -6
  86. package/dist/components/grid/grammar.json +51 -0
  87. package/dist/components/inputs/__init__.py +1 -1
  88. package/dist/components/inputs/assets/index.js +1 -1
  89. package/dist/components/inputs/grammar.json +4987 -216
  90. package/dist/components/layout/__init__.py +1 -1
  91. package/dist/components/layout/assets/index.js +1 -1
  92. package/dist/components/layout/grammar.json +69 -4
  93. package/dist/components/tree/__init__.py +1 -1
  94. package/dist/components/tree/assets/index.js +1 -1
  95. package/dist/components/tree/grammar.json +16 -0
  96. package/dist/components/typst/__init__.py +1 -1
  97. package/dist/components/typst/assets/collection.js +6 -6
  98. package/dist/components/typst/assets/index.js +1 -1
  99. package/dist/components/uploads/__init__.py +1 -1
  100. package/dist/components/uploads/assets/index.js +1 -1
  101. package/dist/components/uploads/grammar.json +66 -0
  102. package/dist/declared-collections.js +1 -1
  103. package/dist/gramlot.js +3961 -1249
  104. package/dist/gramlot.min.js +329 -131
  105. package/dist/libraries.json +1 -0
  106. package/dist/standard-collections.js +1 -1
  107. package/dist/standard-grammar.js +1 -1
  108. package/package.json +3 -1
  109. package/src/binding/ask-dialog.js +17 -3
  110. package/src/binding/providers.js +1 -1
  111. package/src/binding/runtime.js +6 -3
  112. package/src/builder/chart-icon.js +2 -0
  113. package/src/builder/gramlot-builder.d.ts +3 -1
  114. package/src/builder/gramlot-builder.js +26 -9
  115. package/src/builder/source.js +12 -3
  116. package/src/builder/xml-recipe.js +144 -0
  117. package/src/chat-file-types.js +13 -0
  118. package/src/chat.js +23 -25
  119. package/src/commands.d.ts +1 -1
  120. package/src/commands.js +1 -1
  121. package/src/components/border-container.js +64 -6
  122. package/src/components/buttons.js +26 -31
  123. package/src/components/chart-geographic-options.js +1 -1
  124. package/src/components/chart-pane.js +5 -5
  125. package/src/components/chart-spatial-options.js +5 -1
  126. package/src/components/check-box-text-editor.js +1 -0
  127. package/src/components/check-box-text.js +2 -0
  128. package/src/components/choice-editor.js +3 -2
  129. package/src/components/choice-field-styles.js +9 -1
  130. package/src/components/code-mirror-engine.js +18 -5
  131. package/src/components/code-mirror-gramlot.js +85 -0
  132. package/src/components/code-mirror.js +3 -2
  133. package/src/components/drawing.js +43 -14
  134. package/src/components/editor-options.js +1 -1
  135. package/src/components/graphical-ranges.js +177 -0
  136. package/src/components/grid-footer.js +6 -1
  137. package/src/components/grid-styles.js +11 -2
  138. package/src/components/grid-tools.js +15 -7
  139. package/src/components/grid.js +69 -8
  140. package/src/components/inputs.js +93 -23
  141. package/src/components/jodit-engine.js +3 -1
  142. package/src/components/menus.js +83 -25
  143. package/src/components/numeric-range.js +39 -0
  144. package/src/components/selected-container.js +109 -63
  145. package/src/components/tab-bar.js +371 -0
  146. package/src/components/toolbar-icon-style.js +22 -0
  147. package/src/components/toolbar-overflow.js +74 -12
  148. package/src/components/tree.js +12 -3
  149. package/src/components/typst-preview.js +3 -3
  150. package/src/components/upload-blocks.js +88 -0
  151. package/src/components/upload-engine.js +21 -31
  152. package/src/components/uploader.js +168 -47
  153. package/src/gramlot.js +6 -3
  154. package/src/handlers/dom-handler.d.ts +2 -0
  155. package/src/handlers/dom-handler.js +9 -0
  156. package/src/handlers/rpc-handler.d.ts +1 -1
  157. package/src/handlers/rpc-handler.js +2 -0
  158. package/src/handlers/source-handler.d.ts +5 -3
  159. package/src/handlers/source-handler.js +31 -13
  160. package/src/icons.js +84 -0
  161. package/src/index-page-runtime.js +9 -2
  162. package/src/index-page-styles.js +1 -1
  163. package/src/index-theme.js +210 -3
  164. package/src/index.d.ts +5 -1
  165. package/src/index.js +5 -1
  166. package/src/libraries.js +1 -1
  167. package/src/renderer/gramlot-renderer.js +4 -1
  168. package/src/server/chat-attachments.js +139 -0
  169. package/src/server/chat.d.ts +31 -0
  170. package/src/server/chat.js +157 -0
  171. package/src/server/database-selectors.d.ts +6 -0
  172. package/src/server/database-selectors.js +13 -0
  173. package/src/server/gramlot-file-server.js +6 -1
  174. package/src/server/gramlot-server.d.ts +19 -3
  175. package/src/server/gramlot-server.js +144 -18
  176. package/src/server/index-page.d.ts +10 -0
  177. package/src/server/index-page.js +73 -8
  178. package/src/server/index.d.ts +1 -1
  179. package/src/server/index.js +1 -1
  180. package/src/server/page-base.js +4 -0
  181. package/src/server/page-store.d.ts +21 -0
  182. package/src/server/page-store.js +219 -0
  183. package/src/server/page.d.ts +6 -1
  184. package/src/server/page.js +5 -1
  185. package/src/server/store-recipe.js +102 -0
  186. package/src/server/toolbar-icon-name.d.ts +76 -0
  187. package/src/server/upload.d.ts +2 -0
  188. package/src/server/upload.js +36 -18
  189. package/src/server/visual-editor.js +4 -2
  190. package/src/tree-store.d.ts +5 -1
  191. package/src/tree-store.js +11 -2
  192. package/src/view/choice-focus.js +17 -0
  193. package/src/view/html.js +21 -1
  194. package/src/view/menu.js +9 -3
  195. package/src/visual-editor.js +6 -2
  196. package/themes/gramlot-base/theme.css +53 -28
  197. package/themes/gramlot-compact/theme.css +2 -0
  198. package/themes/gramlot-index/icons/applications.svg +4 -0
  199. package/themes/gramlot-index/icons/archive.svg +4 -0
  200. package/themes/gramlot-index/icons/attachment.svg +4 -0
  201. package/themes/gramlot-index/icons/book.svg +4 -0
  202. package/themes/gramlot-index/icons/bookmark.svg +4 -0
  203. package/themes/gramlot-index/icons/calendar.svg +4 -0
  204. package/themes/gramlot-index/icons/cancel.svg +4 -0
  205. package/themes/gramlot-index/icons/chart.svg +4 -0
  206. package/themes/gramlot-index/icons/chat.svg +4 -0
  207. package/themes/gramlot-index/icons/clock.svg +4 -0
  208. package/themes/gramlot-index/icons/code.svg +4 -0
  209. package/themes/gramlot-index/icons/collapse.svg +4 -0
  210. package/themes/gramlot-index/icons/columns.svg +4 -0
  211. package/themes/gramlot-index/icons/confirm.svg +4 -0
  212. package/themes/gramlot-index/icons/copy.svg +4 -0
  213. package/themes/gramlot-index/icons/cut.svg +4 -0
  214. package/themes/gramlot-index/icons/database.svg +4 -0
  215. package/themes/gramlot-index/icons/delete.svg +4 -0
  216. package/themes/gramlot-index/icons/detach.svg +4 -0
  217. package/themes/gramlot-index/icons/document.svg +4 -0
  218. package/themes/gramlot-index/icons/download.svg +4 -0
  219. package/themes/gramlot-index/icons/duplicate.svg +4 -0
  220. package/themes/gramlot-index/icons/edit.svg +4 -0
  221. package/themes/gramlot-index/icons/expand.svg +4 -0
  222. package/themes/gramlot-index/icons/export.svg +4 -0
  223. package/themes/gramlot-index/icons/eye.svg +4 -0
  224. package/themes/gramlot-index/icons/filter.svg +4 -0
  225. package/themes/gramlot-index/icons/first.svg +4 -0
  226. package/themes/gramlot-index/icons/folder.svg +4 -0
  227. package/themes/gramlot-index/icons/group.svg +4 -0
  228. package/themes/gramlot-index/icons/help.svg +4 -0
  229. package/themes/gramlot-index/icons/home.svg +4 -0
  230. package/themes/gramlot-index/icons/import.svg +4 -0
  231. package/themes/gramlot-index/icons/info.svg +4 -0
  232. package/themes/gramlot-index/icons/inspector.svg +4 -0
  233. package/themes/gramlot-index/icons/last.svg +4 -0
  234. package/themes/gramlot-index/icons/layers.svg +4 -0
  235. package/themes/gramlot-index/icons/link.svg +4 -0
  236. package/themes/gramlot-index/icons/list.svg +4 -0
  237. package/themes/gramlot-index/icons/lock.svg +4 -0
  238. package/themes/gramlot-index/icons/logout.svg +4 -0
  239. package/themes/gramlot-index/icons/navigation.svg +4 -0
  240. package/themes/gramlot-index/icons/new.svg +4 -0
  241. package/themes/gramlot-index/icons/next.svg +4 -0
  242. package/themes/gramlot-index/icons/open.svg +4 -0
  243. package/themes/gramlot-index/icons/palette.svg +4 -0
  244. package/themes/gramlot-index/icons/panel-bottom.svg +4 -0
  245. package/themes/gramlot-index/icons/panel-left.svg +4 -0
  246. package/themes/gramlot-index/icons/panel-right.svg +4 -0
  247. package/themes/gramlot-index/icons/panel-top.svg +4 -0
  248. package/themes/gramlot-index/icons/paste.svg +4 -0
  249. package/themes/gramlot-index/icons/pause.svg +4 -0
  250. package/themes/gramlot-index/icons/pin.svg +4 -0
  251. package/themes/gramlot-index/icons/play.svg +4 -0
  252. package/themes/gramlot-index/icons/previous.svg +4 -0
  253. package/themes/gramlot-index/icons/print.svg +4 -0
  254. package/themes/gramlot-index/icons/redo.svg +4 -0
  255. package/themes/gramlot-index/icons/refresh.svg +4 -0
  256. package/themes/gramlot-index/icons/save.svg +4 -0
  257. package/themes/gramlot-index/icons/search.svg +4 -0
  258. package/themes/gramlot-index/icons/send.svg +4 -0
  259. package/themes/gramlot-index/icons/settings.svg +4 -0
  260. package/themes/gramlot-index/icons/sort-ascending.svg +4 -0
  261. package/themes/gramlot-index/icons/sort-descending.svg +4 -0
  262. package/themes/gramlot-index/icons/stop.svg +4 -0
  263. package/themes/gramlot-index/icons/table.svg +4 -0
  264. package/themes/gramlot-index/icons/tree.svg +4 -0
  265. package/themes/gramlot-index/icons/undo.svg +4 -0
  266. package/themes/gramlot-index/icons/unlock.svg +4 -0
  267. package/themes/gramlot-index/icons/upload.svg +4 -0
  268. package/themes/gramlot-index/icons/user.svg +4 -0
  269. package/themes/gramlot-index/icons/warning.svg +4 -0
  270. package/themes/gramlot-index/icons/zoom-in.svg +4 -0
  271. package/themes/gramlot-index/icons/zoom-out.svg +4 -0
  272. package/themes/gramlot-index/icons.json +76 -0
  273. package/themes/gramlot-index/theme.css +21 -0
  274. package/themes/joanna/theme.css +2 -0
  275. package/themes/mela/theme.css +2 -0
  276. package/themes/mimi/theme.css +2 -0
@@ -0,0 +1,177 @@
1
+ import {SVG_NS} from '../renderer/attributes.js';
2
+ import {NativeControl} from './bases.js';
3
+ import {FieldState} from './field-state.js';
4
+ import {Labelbox} from './labelbox.js';
5
+ import {numericRange, numericRangeParameters} from './numeric-range.js';
6
+ import {defineComponent} from './registry.js';
7
+
8
+ function svg(doc, tag, attrs) {
9
+ const node = doc.createElementNS(SVG_NS, tag);
10
+ for (const [name, value] of Object.entries(attrs)) node.setAttribute(name, value);
11
+ return node;
12
+ }
13
+
14
+ // Pointer geometry belongs to the illustrated surface. The underlying range still
15
+ // provides the single focus stop, accessible value, keyboard steps and Data events.
16
+ function graphicalRange(Base) {
17
+ return class extends numericRange(Base) {
18
+ #drag;
19
+
20
+ constructor() {
21
+ super();
22
+ const doc = this.ownerDocument;
23
+ const style = doc.createElement('style');
24
+ style.textContent = `
25
+ .option{position:relative;display:inline-flex;max-width:100%;vertical-align:middle;
26
+ border-radius:var(--gramlot-radius-sm,4px);color:var(--gramlot-action,Highlight);
27
+ touch-action:none;user-select:none;cursor:pointer}
28
+ .option:has(.knob){border-radius:50%}
29
+ .option:not(.pointer-focus):has(input:focus-visible){outline:1px solid var(--gramlot-focus-ring,Highlight);outline-offset:-1px}
30
+ .option:has(:disabled){opacity:.45;cursor:default}
31
+ .option input[type=range]{position:absolute;inset:0;margin:0;width:100%;height:100%;opacity:0;pointer-events:none}
32
+ .range-art{display:block;pointer-events:none;max-width:100%}
33
+ .knob{width:5rem;height:5rem;border-radius:50%}
34
+ .dial-track{stroke:var(--gramlot-border-control,GrayText)}
35
+ .dial-face{fill:var(--gramlot-field-background,Canvas);stroke:var(--gramlot-border,GrayText)}
36
+ .dial-value{fill:var(--gramlot-ink,CanvasText);font:600 12px system-ui;font-variant-numeric:tabular-nums}
37
+ .rating{border-radius:var(--gramlot-radius-sm,4px);display:inline-flex;align-items:center;min-height:max(2rem,var(--gramlot-touch-target,0px))}
38
+ .rating svg{width:1.65rem;height:1.65rem;stroke-width:1.6;stroke-linejoin:round;stroke:var(--gramlot-border-control,GrayText);fill:none}
39
+ .rating svg[data-filled]{stroke:currentColor;fill:currentColor}
40
+ `;
41
+ this.shadowRoot.append(style);
42
+ this.surface = this.control.parentElement;
43
+ this.surface.append(this.createArt(doc));
44
+ this.control.addEventListener('input', () => this.paint());
45
+ this.control.addEventListener('blur', () => this.surface.classList.remove('pointer-focus'));
46
+ this.control.addEventListener('keydown', event => {
47
+ this.surface.classList.remove('pointer-focus');
48
+ if (this.control.readOnly && ['ArrowLeft','ArrowRight','ArrowUp','ArrowDown','Home','End','PageUp','PageDown'].includes(event.key)) event.preventDefault();
49
+ });
50
+ this.surface.addEventListener('pointerdown', event => {
51
+ if (this.#drag || !event.isPrimary || event.button !== 0 || this.control.disabled || this.control.readOnly) return;
52
+ event.preventDefault();
53
+ this.surface.classList.add('pointer-focus');
54
+ this.control.focus({preventScroll:true});
55
+ this.surface.setPointerCapture(event.pointerId);
56
+ this.#drag = {id:event.pointerId, start:this.control.value};
57
+ this.#move(event);
58
+ });
59
+ this.surface.addEventListener('pointermove', event => this.#move(event));
60
+ this.surface.addEventListener('pointerup', event => {
61
+ if (this.#drag?.id !== event.pointerId) return;
62
+ this.#move(event);
63
+ const changed = this.control.value !== this.#drag.start;
64
+ this.#drag = null;
65
+ if (changed) this.#emit('change');
66
+ });
67
+ for (const type of ['pointercancel','lostpointercapture']) this.surface.addEventListener(type, event => {
68
+ if (this.#drag?.id === event.pointerId) this.#cancel();
69
+ });
70
+ }
71
+ #emit(type) {
72
+ this.control.dispatchEvent(new this.ownerDocument.defaultView.Event(type, {bubbles:true}));
73
+ }
74
+ #move(event) {
75
+ if (this.#drag?.id !== event.pointerId) return;
76
+ const value = this.valueAt(event, this.surface.getBoundingClientRect());
77
+ if (value == null) return;
78
+ const previous = this.control.value;
79
+ this.control.valueAsNumber = value;
80
+ if (this.control.value !== previous) this.#emit('input');
81
+ }
82
+ #cancel() {
83
+ if (!this.#drag) return;
84
+ const {id,start} = this.#drag;
85
+ this.#drag = null;
86
+ if (this.surface.hasPointerCapture(id)) this.surface.releasePointerCapture(id);
87
+ if (this.control.value !== start) {
88
+ this.control.value = start;
89
+ this.#emit('input');
90
+ }
91
+ }
92
+ releaseControl() {
93
+ this.#cancel();
94
+ super.releaseControl();
95
+ }
96
+ projectAttributes(attrs, adapt) {
97
+ const rest = super.projectAttributes(attrs, adapt);
98
+ if (this.control.disabled || this.control.readOnly) this.#cancel();
99
+ this.paint();
100
+ return rest;
101
+ }
102
+ writeControlValue(value) {
103
+ super.writeControlValue(value);
104
+ this.paint();
105
+ }
106
+ };
107
+ }
108
+
109
+ export const Knob = defineComponent({
110
+ name:'knob', tag:'gramlot-knob', base:NativeControl, mixins:[Labelbox, FieldState], sourceContext:true,
111
+ parameters:{...numericRangeParameters, showValue:{dtype:'B', default:false, binding:'read'}},
112
+ implementation:Base => class extends graphicalRange(Base) {
113
+ createArt(doc) {
114
+ const art = svg(doc,'svg',{class:'range-art knob',viewBox:'0 0 72 72','aria-hidden':true});
115
+ const arc = {d:'M16.201 55.799a28 28 0 1 1 39.598 0',fill:'none','stroke-width':4,'stroke-linecap':'round',pathLength:1};
116
+ this.progress = svg(doc,'path',{...arc,stroke:'currentColor'});
117
+ this.indicator = svg(doc,'path',{d:'M36 16v5',stroke:'currentColor','stroke-width':3,'stroke-linecap':'round'});
118
+ this.number = svg(doc,'text',{class:'dial-value',x:36,y:40,'text-anchor':'middle'});
119
+ art.append(svg(doc,'path',{...arc,class:'dial-track'}),this.progress,
120
+ svg(doc,'circle',{class:'dial-face',cx:36,cy:36,r:23}),this.indicator,this.number);
121
+ return art;
122
+ }
123
+ valueAt(event, box) {
124
+ const x = event.clientX - box.left - box.width / 2;
125
+ const y = box.top + box.height / 2 - event.clientY;
126
+ if (Math.hypot(x,y) < Math.min(box.width,box.height) * 0.12) return null;
127
+ const angle = Math.atan2(x,y) * 180 / Math.PI;
128
+ const fraction = (Math.max(-135, Math.min(135,angle)) + 135) / 270;
129
+ return Number(this.control.min) + fraction * (Number(this.control.max) - Number(this.control.min));
130
+ }
131
+ paint() {
132
+ const value = this.control.valueAsNumber, min = Number(this.control.min), max = Number(this.control.max);
133
+ const fraction = max > min ? (value - min) / (max - min) : 0;
134
+ this.progress.setAttribute('stroke-dasharray', fraction + ' 1');
135
+ this.indicator.setAttribute('transform', 'rotate(' + (fraction*270-135) + ' 36 36)');
136
+ this.number.textContent = this.parameters.showValue ? value.toLocaleString(this.closest('[lang]')?.lang || this.pageContext?.locale,
137
+ {maximumSignificantDigits:21}) : '';
138
+ }
139
+ }
140
+ });
141
+
142
+ export const StarRating = defineComponent({
143
+ name:'starRating', tag:'gramlot-star-rating', base:NativeControl, mixins:[Labelbox,FieldState], sourceContext:true,
144
+ parameters:{
145
+ value:{dtype:'L', default:0, binding:'twoWay'},
146
+ max:{dtype:'L', default:5, binding:'read', target:'control'}
147
+ },
148
+ implementation:Base => class extends graphicalRange(Base) {
149
+ createArt(doc) {
150
+ this.control.min = '0';
151
+ this.control.step = '1';
152
+ this.stars = doc.createElement('span');
153
+ this.stars.className = 'range-art rating';
154
+ this.stars.setAttribute('aria-hidden','true');
155
+ return this.stars;
156
+ }
157
+ valueAt(event, box) {
158
+ const x = this.matches(':dir(rtl)') ? box.right - event.clientX : event.clientX - box.left;
159
+ const count = this.stars.childElementCount;
160
+ return Math.max(0, Math.min(count, Math.ceil(x * count / box.width)));
161
+ }
162
+ paint() {
163
+ const count = Number(this.control.max);
164
+ if (!Number.isSafeInteger(count) || count < 1) throw new RangeError('starRating max must be a positive integer');
165
+ while (this.stars.childElementCount > count) this.stars.lastElementChild.remove();
166
+ while (this.stars.childElementCount < count) {
167
+ const star = svg(this.ownerDocument, 'svg', {viewBox:'0 0 24 24'});
168
+ star.append(svg(this.ownerDocument, 'path', {
169
+ d:'m12 2.8 2.8 5.7 6.3.9-4.6 4.5 1.1 6.3-5.6-3-5.6 3 1.1-6.3-4.6-4.5 6.3-.9z'
170
+ }));
171
+ this.stars.append(star);
172
+ }
173
+ const value = this.control.valueAsNumber;
174
+ Array.from(this.stars.children).forEach((star,index) => star.toggleAttribute('data-filled', index < value));
175
+ }
176
+ }
177
+ });
@@ -53,7 +53,7 @@ export class GridFooter {
53
53
  cell(field) { return this.#row.querySelector(`td[data-field="${field}"]`); }
54
54
 
55
55
  /** `footer` is false, true or a caption; `columns` are the displayed columns. */
56
- configure(footer, columns, rowHeaders) {
56
+ configure(footer, columns, rowHeaders, rowDelete) {
57
57
  this.#caption = footer;
58
58
  this.#columns = columns;
59
59
  if (footer === false) this.#frame.remove();
@@ -73,6 +73,11 @@ export class GridFooter {
73
73
  cell.classList.toggle('numeric', Boolean(column.totalize));
74
74
  cells.push(cell);
75
75
  }
76
+ if (rowDelete) {
77
+ const action = document.createElement('td');
78
+ action.setAttribute('role', 'cell');
79
+ cells.push(action);
80
+ }
76
81
  this.#row.replaceChildren(...cells);
77
82
  }
78
83
 
@@ -2,6 +2,11 @@
2
2
  * A JS stylesheet module keeps the same source usable in Node and browser builds.
3
3
  */
4
4
  export const gridStyles = `
5
+ .row-delete{text-align:center}
6
+ .row-delete button{display:inline-grid;place-items:center;padding:.15em .3em;border:0;border-radius:var(--gramlot-radius-sm,4px);background:transparent;color:inherit;cursor:pointer}
7
+ .row-delete button:hover{background:var(--gramlot-button-hover,ButtonFace)}
8
+ .row-delete button:focus-visible{outline:1px solid var(--gramlot-focus-ring,Highlight);outline-offset:-1px}
9
+ .row-delete img{width:1em;height:1em}
5
10
  .column-filter{position:absolute;inset-inline-end:8px;top:50%;transform:translateY(-50%);border:0;background:transparent;color:inherit;cursor:pointer;padding:2px;margin-inline-start:4px;vertical-align:middle;line-height:0;opacity:.6}
6
11
  th:has(.column-filter){padding-inline-end:28px}
7
12
  .column-filter svg{width:13px;height:13px;fill:none;stroke:currentColor;stroke-width:1.5}
@@ -183,8 +188,12 @@ th:has(.column-filter){padding-inline-end:28px}
183
188
  .cell-scroll:focus-visible { outline: 1px solid var(--gramlot-focus-ring, Highlight); outline-offset: -1px; }
184
189
  tbody tr { background: var(--gramlot-grid-background, var(--gramlot-surface, Canvas)); }
185
190
  tbody tr.alternate { background: var(--gramlot-grid-row-alt-background, var(--gramlot-surface-subtle, Canvas)); }
186
- tbody tr[aria-selected=true] { background: var(--gramlot-grid-selected-background, var(--gramlot-selected, Highlight)); }
187
- tbody tr:hover { background: var(--gramlot-grid-row-hover-background, var(--gramlot-selected, Highlight)); }
191
+ tbody tr[aria-selected=true] {
192
+ background: var(--gramlot-grid-selected-background, var(--gramlot-selected, Highlight));
193
+ outline: 2px solid var(--gramlot-action, Highlight);
194
+ outline-offset: -2px;
195
+ }
196
+ tbody tr:hover:not([aria-selected=true]) { background: var(--gramlot-grid-row-hover-background, var(--gramlot-selected, Highlight)); }
188
197
  th[data-field] { padding-inline-end: 14px; cursor: grab; user-select: none; }
189
198
  th[data-field]:hover { background-color: color-mix(in srgb, var(--gramlot-grid-header-background) 92%, var(--gramlot-grid-header-color)); }
190
199
  th:focus-visible, .column-resize:focus-visible { outline: 2px solid var(--gramlot-focus-ring, Highlight); outline-offset: -2px; }
@@ -17,12 +17,12 @@ let excelEngine = null;
17
17
 
18
18
  /** Grid toolbar commands of the `grid` namespace, delivered to the frame's target grid by publication. */
19
19
  export const GRID_COMMANDS = Object.freeze({
20
- export: {label:'Export', publish:'export', icon:'⇩', tooltip:'Export the visible rows'},
21
- printRows: {label:'Print', publish:'printRows', icon:'⎙', tooltip:'Print the visible rows'},
20
+ export: {label:'Export', publish:'export', icon:'download', tooltip:'Export the visible rows'},
21
+ printRows: {label:'Print', publish:'printRows', icon:'print', tooltip:'Print the visible rows'},
22
22
  lineNumbers: {label:'Line numbers', publish:'lineNumbers', tooltip:'Show or hide the row numbers'},
23
- addrow: {label:'Add row', publish:'addrow', icon:'+', tooltip:'Add a row'},
24
- duprow: {label:'Duplicate', publish:'duprow', icon:'⧉', tooltip:'Duplicate the selected rows'},
25
- delrow: {label:'Delete', publish:'delrow', icon:'−', tooltip:'Delete the selected rows'},
23
+ addrow: {label:'New row', publish:'addrow', tooltip:'Add a row'},
24
+ duprow: {label:'Duplicate', publish:'duprow', icon:'duplicate', tooltip:'Duplicate the selected rows'},
25
+ delrow: {label:'Delete', publish:'delrow', tooltip:'Delete the selected rows'},
26
26
  });
27
27
 
28
28
  // Commands that change rows: they require at least one editable column.
@@ -33,7 +33,13 @@ const SELECTION_COMMANDS = new Set(['grid:duprow', 'grid:delrow']);
33
33
  /** Register the grid command group on one Gramlot page. */
34
34
  export function registerGridCommands(gramlot) {
35
35
  const group = gramlot.commands.registerGroup('grid', {description:'Grid toolbar tools'});
36
- for (const [name, definition] of Object.entries(GRID_COMMANDS)) group.register(name, definition);
36
+ const italian = gramlot.locale?.split('-')[0].toLowerCase() === 'it';
37
+ const labels = italian ? {
38
+ addrow:{label:'Nuova riga', tooltip:'Aggiungi una riga'},
39
+ delrow:{label:'Cancella', tooltip:'Cancella le righe selezionate'},
40
+ duprow:{label:'Duplica', tooltip:'Duplica le righe selezionate'},
41
+ } : {};
42
+ for (const [name, definition] of Object.entries(GRID_COMMANDS)) group.register(name, {...definition, ...labels[name]});
37
43
  }
38
44
 
39
45
  function csvField(text) {
@@ -206,8 +212,10 @@ export class GridTools {
206
212
  }
207
213
 
208
214
  /** Remove the selected rows at their paths in the store; an editing session records each removal. */
215
+ deleteRow(label) { this.source.data.popNode(this.#rowPath(label)); }
216
+
209
217
  deleteRows() {
210
- for (const label of this.#host.selected().map(node => node.label)) this.source.data.popNode(this.#rowPath(label));
218
+ for (const node of this.#host.selected()) this.deleteRow(node.label);
211
219
  }
212
220
 
213
221
  /** Edit tools declared in the grid's frame require an editable column; selection tools a selection mode. */
@@ -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';
@@ -29,6 +30,8 @@ export const Grid = defineComponent({
29
30
  viewport: {dtype:'X', nullable:true, default:null, binding:'write'},
30
31
  sortRequest: {dtype:'T', default:'', binding:'write'},
31
32
  storepath: {dtype: 'T'}, structpath: {dtype: 'T'}, rowMode: {dtype: 'T'},
33
+ delrow: {dtype:'T', nullable:true, default:null},
34
+ delrow_label: {dtype:'T', nullable:true, default:null, binding:'read'},
32
35
  rowHeaders: {dtype:'B', default:false, binding:'read'},
33
36
  footer: {dtype:['B','T'], default:false, binding:'read'},
34
37
  selectionMode: {dtype:'T', default:'multi', binding:'read'},
@@ -253,8 +256,8 @@ export const Grid = defineComponent({
253
256
  this.control.style.setProperty('--grid-scrollbar-width', width);
254
257
  }
255
258
  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)));
259
+ for (const handle of this.#head.querySelectorAll('.column-resize')) {
260
+ handle.setAttribute('aria-valuenow', String(Math.round(handle.parentElement.getBoundingClientRect().width)));
258
261
  }
259
262
  for (const row of this.#rows.values()) {
260
263
  const handle = row.querySelector('.row-height-handle');
@@ -511,6 +514,10 @@ export const Grid = defineComponent({
511
514
  const store = this.#collectionStore();
512
515
  this.#formulas.configure(model, this.#collectionView, store);
513
516
  this.#requireStoredCriteria();
517
+ if (this.parameters.delrow !== null && this.parameters.delrow !== 'row') throw new TypeError("grid delrow requires 'row'");
518
+ if (this.parameters.delrow === 'row' && !model.columns.some(column => column.edit)) {
519
+ throw new TypeError("grid tool 'grid:delrow' requires an editable column");
520
+ }
514
521
  this.#tools.requireEditableTools(model.columns);
515
522
  this.#selection.prune();
516
523
  const structureChanged = this.#structureDirty;
@@ -536,10 +543,10 @@ export const Grid = defineComponent({
536
543
  gridSearch(this.#context.sourceNode).update(this.#collectionView,
537
544
  model.columns.filter(column => !column.check && !this.#formulas.viewFields.has(column.field)));
538
545
  const rowHeaders = this.parameters.rowHeaders || this.parameters.rowResize;
539
- const signature = JSON.stringify([model.groups, rowHeaders, this.parameters.columnFilters, this.parameters.footer]);
546
+ const signature = JSON.stringify([model.groups, rowHeaders, this.parameters.delrow, this.parameters.delrow_label, this.parameters.columnFilters, this.parameters.footer]);
540
547
  this.#rowHeaders = rowHeaders;
541
548
  if (signature !== this.#signature) {
542
- this.#footer.configure(this.parameters.footer, model.columns, rowHeaders);
549
+ this.#footer.configure(this.parameters.footer, model.columns, rowHeaders, this.parameters.delrow === 'row');
543
550
  this.#renderHeader(model);
544
551
  this.#signature = signature;
545
552
  }
@@ -549,7 +556,7 @@ export const Grid = defineComponent({
549
556
  this.#renderSort();
550
557
  this.#renderWindow(true);
551
558
  this.#renderSelection();
552
- this.control.setAttribute('aria-colcount', String(model.columns.length + Number(this.#rowHeaders)));
559
+ this.control.setAttribute('aria-colcount', String(this.#columnCount(model.columns)));
553
560
  this.control.setAttribute('aria-rowcount', String(this.#headerRows + Math.max(this.#rowLayout.count, 1)));
554
561
  this.#scheduleLayout();
555
562
  }
@@ -587,6 +594,14 @@ export const Grid = defineComponent({
587
594
  return Object.fromEntries(node.staticValue.getNodes().filter(cell => !(cell.staticValue instanceof Bag)).map(cell => [cell.label, cell.staticValue]));
588
595
  }
589
596
  #renderSelection() {
597
+ const source = this.#context.sourceNode;
598
+ if (source.getAttr('frameTarget')) {
599
+ const remove = source.parentNode.parentNode?.value.getNode('top.bar.delrow');
600
+ if (remove?.getAttr('command') === 'grid:delrow') {
601
+ const disabled = this.#selection.current === null;
602
+ if (remove.getAttr('disabled') !== disabled) remove.setAttr({disabled});
603
+ }
604
+ }
590
605
  const mode = this.#selectionMode();
591
606
  if (mode === 'multi') this.control.setAttribute('aria-multiselectable', 'true');
592
607
  else this.control.removeAttribute('aria-multiselectable');
@@ -638,7 +653,7 @@ export const Grid = defineComponent({
638
653
  #renderSort() {
639
654
  const criteria = this.#windowInfo() ? parseSort(this.#windowInfo().sortedBy) : this.#collectionView.criteria;
640
655
  this.#sizeRowHeader();
641
- for (const header of this.#head.querySelectorAll('th[scope=col]')) {
656
+ for (const header of this.#head.querySelectorAll('th[data-field]')) {
642
657
  const index = criteria.findIndex(item => item.field === header.dataset.field);
643
658
  header.removeAttribute('aria-sort');
644
659
  if (index < 0) {
@@ -729,9 +744,17 @@ export const Grid = defineComponent({
729
744
  (grouped ? bottom : top).append(header(col.name, 1, 1, 'col', index++, col.align));
730
745
  }
731
746
  }
747
+ if (this.parameters.delrow === 'row') {
748
+ const action = doc.createElement('th');
749
+ action.scope = 'col'; action.rowSpan = this.#headerRows;
750
+ action.setAttribute('role', 'columnheader');
751
+ action.setAttribute('aria-label', this.#deleteCaption());
752
+ top.append(action);
753
+ }
732
754
  this.#head.replaceChildren(top, ...(grouped ? [bottom] : []));
733
755
  if (focusedField) this.#head.querySelector(`th[data-field="${focusedField}"]${resizeFocused ? ' .column-resize' : ''}`)?.focus({preventScroll:true});
734
756
  const widths = model.columns.map(column => column.width ?? 'var(--gramlot-grid-column-width, 10rem)');
757
+ if (this.parameters.delrow === 'row') widths.push('var(--gramlot-grid-action-width, 2.5rem)');
735
758
  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
759
  this.control.style.setProperty('--grid-columns-width', `calc(${widths.join(' + ')})`);
737
760
  // Identical colgroups and table constraints keep one CSS sizing policy for both areas.
@@ -747,6 +770,11 @@ export const Grid = defineComponent({
747
770
  }
748
771
  return element;
749
772
  }));
773
+ if (this.parameters.delrow === 'row') {
774
+ const group = doc.createElement('colgroup'), col = doc.createElement('col');
775
+ col.style.width = 'var(--gramlot-grid-action-width, 2.5rem)';
776
+ group.append(col); table.insertBefore(group, table.querySelector('thead,tbody,tfoot'));
777
+ }
750
778
  if (this.#rowHeaders) {
751
779
  const group = doc.createElement('colgroup'), col = doc.createElement('col');
752
780
  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 +782,38 @@ export const Grid = defineComponent({
754
782
  }
755
783
  }
756
784
  }
785
+ #columnCount(columns) {
786
+ return columns.length + Number(this.#rowHeaders) + Number(this.parameters.delrow === 'row');
787
+ }
788
+
789
+ #deleteCaption() {
790
+ return this.parameters.delrow_label ?? (this.#context.locale.split('-')[0].toLowerCase() === 'it' ? 'Cancella riga' : 'Delete row');
791
+ }
792
+
793
+ #renderRowAction(tr, label, columnCount) {
794
+ let cell = tr.querySelector('.row-delete');
795
+ if (this.parameters.delrow !== 'row') { cell?.remove(); return; }
796
+ if (!cell) {
797
+ cell = this.ownerDocument.createElement('td');
798
+ cell.className = 'row-delete';
799
+ cell.setAttribute('role', 'cell');
800
+ const button = this.ownerDocument.createElement('button');
801
+ button.type = 'button';
802
+ const icon = this.ownerDocument.createElement('img');
803
+ icon.src = icons.delete; icon.alt = '';
804
+ button.append(icon);
805
+ button.addEventListener('click', event => {
806
+ event.stopPropagation();
807
+ this.#tools.deleteRow(label);
808
+ });
809
+ cell.append(button); tr.append(cell);
810
+ }
811
+ cell.setAttribute('aria-colindex', String(columnCount));
812
+ const button = cell.firstElementChild;
813
+ button.title = this.#deleteCaption();
814
+ button.setAttribute('aria-label', button.title);
815
+ }
816
+
757
817
  #renderRows(rows, columns, start) {
758
818
  this.#rowInteraction.cancel();
759
819
 
@@ -828,6 +888,7 @@ export const Grid = defineComponent({
828
888
  existing.delete(column.field);
829
889
  }
830
890
  for (const td of existing.values()) td.remove();
891
+ this.#renderRowAction(tr, label, this.#columnCount(columns));
831
892
  tr.setAttribute('aria-rowindex', String(this.#headerRows + start + keep.size + 1));
832
893
  this.#renderCells(tr, cells, node);
833
894
  this.#cellEditor.decorate(tr, label);
@@ -840,8 +901,8 @@ export const Grid = defineComponent({
840
901
  if (!rows.length && this.#rowLayout.count === 0 && !this.parameters.loading) {
841
902
  const tr = this.ownerDocument.createElement('tr'), td = this.ownerDocument.createElement('td');
842
903
  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);
904
+ td.setAttribute('role', 'cell'); td.setAttribute('aria-colspan', String(this.#columnCount(columns)));
905
+ td.className = 'empty'; td.colSpan = this.#columnCount(columns); td.textContent = 'No rows'; tr.append(td); this.#body.append(tr);
845
906
  }
846
907
  }
847
908
  #renderCells(row, cells, node) {
@@ -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
  }
@@ -252,5 +322,5 @@ export const CheckBoxText = defineComponent({
252
322
  }, implementation: checkBoxChoices
253
323
  });
254
324
  export default defineCollection({name: 'inputs', dependencies:[tree], components: [EditingStatus, Textbox, Checkbox, RadioButtonText,
255
- TextBoxArea, Passwordbox, RadioButton, Colorpicker, HorizontalSlider, VerticalSlider,
325
+ TextBoxArea, Passwordbox, RadioButton, Colorpicker, HorizontalSlider, VerticalSlider, Knob, StarRating,
256
326
  NumberTextBox, DateTextBox, TimeTextBox, FilteringSelect, CallbackSelect, ComboBox, DbSelect, DbComboBox, CheckBoxText, DateCalendar]});
@@ -17,7 +17,9 @@ import css from 'jodit/es2021/jodit.min.css';
17
17
  import {randomId} from '../random-id.js';
18
18
  import {prepareHtmlDocument} from './html-document.js';
19
19
 
20
- const theme=`.jodit-container,.jodit-popup,.jodit-dialog{--jd-color-background-default:var(--gramlot-surface,white);--jd-color-panel:var(--gramlot-surface-subtle,#eee);--jd-color-text-icons:var(--gramlot-ink,#222);--jd-color-separator:var(--gramlot-border-control,#aaa);--jd-color-button-background-hover:var(--gramlot-selected,#ddd);--jd-color-background-active:var(--gramlot-selected,#ddd);--jd-color-background-gray:var(--gramlot-surface-subtle,#eee);--jd-color-background-light-gray:var(--gramlot-surface-subtle,#eee);--jd-color-background-button-hover:var(--gramlot-selected,#ddd);--jd-color-border:var(--gramlot-border-control,#aaa);--jd-color-text:var(--gramlot-ink,#222);--jd-color-icon:var(--gramlot-ink,#222);--jd-border-radius-default:var(--gramlot-radius-sm,4px)}.jodit-toolbar-button__button:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight)}`;
20
+ const theme=`.jodit-container,.jodit-popup,.jodit-dialog{--jd-color-background-default:var(--gramlot-surface,white);--jd-color-panel:var(--gramlot-surface-subtle,#eee);--jd-color-text-icons:var(--gramlot-ink,#222);--jd-color-separator:var(--gramlot-border-control,#aaa);--jd-color-button-background-hover:var(--gramlot-selected,#ddd);--jd-color-background-active:var(--gramlot-selected,#ddd);--jd-color-background-gray:var(--gramlot-surface-subtle,#eee);--jd-color-background-light-gray:var(--gramlot-surface-subtle,#eee);--jd-color-background-button-hover:var(--gramlot-selected,#ddd);--jd-color-border:var(--gramlot-border-control,#aaa);--jd-color-text:var(--gramlot-ink,#222);--jd-color-icon:var(--gramlot-ink,#222);--jd-border-radius-default:var(--gramlot-radius-sm,4px)}
21
+ .jodit-popup .jodit-ui-input{--jd-color-white:var(--gramlot-field-background,Field);color:var(--gramlot-ink,FieldText)}
22
+ .jodit-toolbar-button__button:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight)}`;
21
23
  const styles=new WeakSet();
22
24
  export function createHtmlEditor(host) {
23
25
  const document=host.ownerDocument, window=document.defaultView;