@gramlot/gramlot 0.3.40 → 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 (279) 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/assets/libraries/prosemirror.js +1 -1
  83. package/dist/components/editors/grammar.json +6 -1
  84. package/dist/components/grid/__init__.py +1 -1
  85. package/dist/components/grid/assets/index.js +1 -1
  86. package/dist/components/grid/commands.json +4 -6
  87. package/dist/components/grid/grammar.json +51 -0
  88. package/dist/components/inputs/__init__.py +1 -1
  89. package/dist/components/inputs/assets/index.js +1 -1
  90. package/dist/components/inputs/grammar.json +4987 -216
  91. package/dist/components/layout/__init__.py +1 -1
  92. package/dist/components/layout/assets/index.js +1 -1
  93. package/dist/components/layout/grammar.json +69 -4
  94. package/dist/components/tree/__init__.py +1 -1
  95. package/dist/components/tree/assets/index.js +1 -1
  96. package/dist/components/tree/grammar.json +16 -0
  97. package/dist/components/typst/__init__.py +1 -1
  98. package/dist/components/typst/assets/collection.js +6 -6
  99. package/dist/components/typst/assets/index.js +1 -1
  100. package/dist/components/uploads/__init__.py +1 -1
  101. package/dist/components/uploads/assets/index.js +1 -1
  102. package/dist/components/uploads/grammar.json +66 -0
  103. package/dist/declared-collections.js +1 -1
  104. package/dist/gramlot.js +4007 -1256
  105. package/dist/gramlot.min.js +329 -131
  106. package/dist/libraries.json +1 -0
  107. package/dist/standard-collections.js +1 -1
  108. package/dist/standard-grammar.js +1 -1
  109. package/package.json +3 -1
  110. package/src/binding/ask-dialog.js +17 -3
  111. package/src/binding/data-binder.js +5 -0
  112. package/src/binding/providers.js +1 -1
  113. package/src/binding/runtime.js +6 -3
  114. package/src/builder/chart-icon.js +2 -0
  115. package/src/builder/gramlot-builder.d.ts +3 -1
  116. package/src/builder/gramlot-builder.js +26 -9
  117. package/src/builder/source.js +12 -3
  118. package/src/builder/xml-recipe.js +144 -0
  119. package/src/chat-file-types.js +13 -0
  120. package/src/chat.js +23 -25
  121. package/src/commands.d.ts +1 -1
  122. package/src/commands.js +1 -1
  123. package/src/components/border-container.js +64 -6
  124. package/src/components/buttons.js +26 -31
  125. package/src/components/chart-geographic-options.js +1 -1
  126. package/src/components/chart-pane.js +5 -5
  127. package/src/components/chart-spatial-options.js +5 -1
  128. package/src/components/check-box-text-editor.js +1 -0
  129. package/src/components/check-box-text.js +2 -0
  130. package/src/components/choice-editor.js +3 -2
  131. package/src/components/choice-field-styles.js +9 -1
  132. package/src/components/code-mirror-engine.js +18 -5
  133. package/src/components/code-mirror-gramlot.js +85 -0
  134. package/src/components/code-mirror.js +3 -2
  135. package/src/components/drawing.js +43 -14
  136. package/src/components/editor-options.js +1 -1
  137. package/src/components/graphical-ranges.js +177 -0
  138. package/src/components/grid-footer.js +6 -1
  139. package/src/components/grid-styles.js +11 -2
  140. package/src/components/grid-tools.js +15 -7
  141. package/src/components/grid.js +69 -8
  142. package/src/components/inputs.js +93 -23
  143. package/src/components/jodit-engine.js +3 -1
  144. package/src/components/menus.js +83 -25
  145. package/src/components/numeric-range.js +39 -0
  146. package/src/components/selected-container.js +109 -63
  147. package/src/components/tab-bar.js +371 -0
  148. package/src/components/toolbar-icon-style.js +22 -0
  149. package/src/components/toolbar-overflow.js +74 -12
  150. package/src/components/tree.js +12 -3
  151. package/src/components/typst-preview.js +3 -3
  152. package/src/components/upload-blocks.js +88 -0
  153. package/src/components/upload-engine.js +21 -31
  154. package/src/components/uploader.js +168 -47
  155. package/src/gramlot.js +6 -3
  156. package/src/handlers/dom-handler.d.ts +2 -0
  157. package/src/handlers/dom-handler.js +9 -0
  158. package/src/handlers/rpc-handler.d.ts +1 -1
  159. package/src/handlers/rpc-handler.js +2 -0
  160. package/src/handlers/source-handler.d.ts +5 -3
  161. package/src/handlers/source-handler.js +31 -13
  162. package/src/icons.js +84 -0
  163. package/src/index-page-runtime.js +9 -2
  164. package/src/index-page-styles.js +1 -1
  165. package/src/index-theme.js +210 -3
  166. package/src/index.d.ts +5 -1
  167. package/src/index.js +5 -1
  168. package/src/libraries.js +1 -1
  169. package/src/page-store-connection.js +44 -7
  170. package/src/renderer/gramlot-renderer.js +4 -1
  171. package/src/server/chat-attachments.js +139 -0
  172. package/src/server/chat.d.ts +31 -0
  173. package/src/server/chat.js +157 -0
  174. package/src/server/database-selectors.d.ts +6 -0
  175. package/src/server/database-selectors.js +13 -0
  176. package/src/server/gramlot-file-server.js +6 -1
  177. package/src/server/gramlot-server.d.ts +19 -3
  178. package/src/server/gramlot-server.js +144 -18
  179. package/src/server/index-page.d.ts +10 -0
  180. package/src/server/index-page.js +73 -8
  181. package/src/server/index.d.ts +1 -1
  182. package/src/server/index.js +1 -1
  183. package/src/server/page-base.js +4 -0
  184. package/src/server/page-store.d.ts +21 -0
  185. package/src/server/page-store.js +219 -0
  186. package/src/server/page.d.ts +6 -1
  187. package/src/server/page.js +5 -1
  188. package/src/server/store-recipe.js +102 -0
  189. package/src/server/toolbar-icon-name.d.ts +76 -0
  190. package/src/server/upload.d.ts +2 -0
  191. package/src/server/upload.js +36 -18
  192. package/src/server/visual-editor.js +4 -2
  193. package/src/tree-store.d.ts +5 -1
  194. package/src/tree-store.js +11 -2
  195. package/src/view/choice-focus.js +17 -0
  196. package/src/view/html.js +21 -1
  197. package/src/view/menu.js +9 -3
  198. package/src/visual-editor.js +6 -2
  199. package/themes/gramlot-base/theme.css +53 -28
  200. package/themes/gramlot-compact/theme.css +2 -0
  201. package/themes/gramlot-index/icons/applications.svg +4 -0
  202. package/themes/gramlot-index/icons/archive.svg +4 -0
  203. package/themes/gramlot-index/icons/attachment.svg +4 -0
  204. package/themes/gramlot-index/icons/book.svg +4 -0
  205. package/themes/gramlot-index/icons/bookmark.svg +4 -0
  206. package/themes/gramlot-index/icons/calendar.svg +4 -0
  207. package/themes/gramlot-index/icons/cancel.svg +4 -0
  208. package/themes/gramlot-index/icons/chart.svg +4 -0
  209. package/themes/gramlot-index/icons/chat.svg +4 -0
  210. package/themes/gramlot-index/icons/clock.svg +4 -0
  211. package/themes/gramlot-index/icons/code.svg +4 -0
  212. package/themes/gramlot-index/icons/collapse.svg +4 -0
  213. package/themes/gramlot-index/icons/columns.svg +4 -0
  214. package/themes/gramlot-index/icons/confirm.svg +4 -0
  215. package/themes/gramlot-index/icons/copy.svg +4 -0
  216. package/themes/gramlot-index/icons/cut.svg +4 -0
  217. package/themes/gramlot-index/icons/database.svg +4 -0
  218. package/themes/gramlot-index/icons/delete.svg +4 -0
  219. package/themes/gramlot-index/icons/detach.svg +4 -0
  220. package/themes/gramlot-index/icons/document.svg +4 -0
  221. package/themes/gramlot-index/icons/download.svg +4 -0
  222. package/themes/gramlot-index/icons/duplicate.svg +4 -0
  223. package/themes/gramlot-index/icons/edit.svg +4 -0
  224. package/themes/gramlot-index/icons/expand.svg +4 -0
  225. package/themes/gramlot-index/icons/export.svg +4 -0
  226. package/themes/gramlot-index/icons/eye.svg +4 -0
  227. package/themes/gramlot-index/icons/filter.svg +4 -0
  228. package/themes/gramlot-index/icons/first.svg +4 -0
  229. package/themes/gramlot-index/icons/folder.svg +4 -0
  230. package/themes/gramlot-index/icons/group.svg +4 -0
  231. package/themes/gramlot-index/icons/help.svg +4 -0
  232. package/themes/gramlot-index/icons/home.svg +4 -0
  233. package/themes/gramlot-index/icons/import.svg +4 -0
  234. package/themes/gramlot-index/icons/info.svg +4 -0
  235. package/themes/gramlot-index/icons/inspector.svg +4 -0
  236. package/themes/gramlot-index/icons/last.svg +4 -0
  237. package/themes/gramlot-index/icons/layers.svg +4 -0
  238. package/themes/gramlot-index/icons/link.svg +4 -0
  239. package/themes/gramlot-index/icons/list.svg +4 -0
  240. package/themes/gramlot-index/icons/lock.svg +4 -0
  241. package/themes/gramlot-index/icons/logout.svg +4 -0
  242. package/themes/gramlot-index/icons/navigation.svg +4 -0
  243. package/themes/gramlot-index/icons/new.svg +4 -0
  244. package/themes/gramlot-index/icons/next.svg +4 -0
  245. package/themes/gramlot-index/icons/open.svg +4 -0
  246. package/themes/gramlot-index/icons/palette.svg +4 -0
  247. package/themes/gramlot-index/icons/panel-bottom.svg +4 -0
  248. package/themes/gramlot-index/icons/panel-left.svg +4 -0
  249. package/themes/gramlot-index/icons/panel-right.svg +4 -0
  250. package/themes/gramlot-index/icons/panel-top.svg +4 -0
  251. package/themes/gramlot-index/icons/paste.svg +4 -0
  252. package/themes/gramlot-index/icons/pause.svg +4 -0
  253. package/themes/gramlot-index/icons/pin.svg +4 -0
  254. package/themes/gramlot-index/icons/play.svg +4 -0
  255. package/themes/gramlot-index/icons/previous.svg +4 -0
  256. package/themes/gramlot-index/icons/print.svg +4 -0
  257. package/themes/gramlot-index/icons/redo.svg +4 -0
  258. package/themes/gramlot-index/icons/refresh.svg +4 -0
  259. package/themes/gramlot-index/icons/save.svg +4 -0
  260. package/themes/gramlot-index/icons/search.svg +4 -0
  261. package/themes/gramlot-index/icons/send.svg +4 -0
  262. package/themes/gramlot-index/icons/settings.svg +4 -0
  263. package/themes/gramlot-index/icons/sort-ascending.svg +4 -0
  264. package/themes/gramlot-index/icons/sort-descending.svg +4 -0
  265. package/themes/gramlot-index/icons/stop.svg +4 -0
  266. package/themes/gramlot-index/icons/table.svg +4 -0
  267. package/themes/gramlot-index/icons/tree.svg +4 -0
  268. package/themes/gramlot-index/icons/undo.svg +4 -0
  269. package/themes/gramlot-index/icons/unlock.svg +4 -0
  270. package/themes/gramlot-index/icons/upload.svg +4 -0
  271. package/themes/gramlot-index/icons/user.svg +4 -0
  272. package/themes/gramlot-index/icons/warning.svg +4 -0
  273. package/themes/gramlot-index/icons/zoom-in.svg +4 -0
  274. package/themes/gramlot-index/icons/zoom-out.svg +4 -0
  275. package/themes/gramlot-index/icons.json +76 -0
  276. package/themes/gramlot-index/theme.css +21 -0
  277. package/themes/joanna/theme.css +2 -0
  278. package/themes/mela/theme.css +2 -0
  279. package/themes/mimi/theme.css +2 -0
@@ -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;
@@ -1,9 +1,17 @@
1
1
  /** Shared popup/permanent menu presentation. Source and execution stay in bindings. */
2
2
  import {labelboxContent, labelboxPresentation} from '../view/labelbox.js';
3
+ import {projectToolbarIconStyle} from './toolbar-icon-style.js';
3
4
  import {projectParameters} from './parameters.js';
4
5
  import {positionPopup} from './popup.js';
5
6
  import {ToolbarOverflow} from './toolbar-overflow.js';
6
7
 
8
+ // Keyboard navigation and presentation follow the visible bar. Command binding
9
+ // and Source ownership continue to follow the original menu hierarchy.
10
+ function containingMenu(element) {
11
+ const menu = element.parentElement?.closest('gramlot-menu');
12
+ return menu?.hasAttribute('data-menu-inline') ? menu.parentMenu : menu ?? null;
13
+ }
14
+
7
15
  export function MenuContainer(HTMLElement) {
8
16
  return class extends HTMLElement {
9
17
  #events; #observer; #active = null; #previous = []; #opener = null;
@@ -20,6 +28,10 @@ export function MenuContainer(HTMLElement) {
20
28
  :host([role=toolbar]){display:flex;gap:var(--gramlot-toolbar-gap,4px);align-items:center}
21
29
  :host([role=menu]) ::slotted([role=separator]){margin:5px 7px 5px 2.5rem;border-top:1px solid var(--gramlot-border-control,#888)}
22
30
  :host([role=toolbar][aria-orientation=horizontal]) ::slotted([role=separator]){border-top:0;border-left:1px solid var(--gramlot-border-control,#888);align-self:stretch;margin:4px}
31
+ :host([role=toolbar][aria-orientation=vertical]) ::slotted([role=separator]){border-left:0;border-top:1px solid var(--gramlot-border-control,#888);align-self:stretch;margin:4px}
32
+ :host([data-menu-inline]){display:inline-flex;position:static;inset:auto;align-items:center;gap:var(--gramlot-toolbar-gap,4px);margin:0;padding:0;border:0;box-shadow:none;background:transparent;width:max-content;max-width:none;max-height:none;overflow:visible}
33
+ :host([data-menu-inline=vertical]){flex-direction:column}
34
+ :host([data-menu-inline]) ::slotted(*){flex-shrink:0}
23
35
  :host([hidden]){display:none!important} slot{display:contents} .status{padding:.4em;opacity:.75}
24
36
  .status:empty{display:none} button{font:inherit}`;
25
37
  this.#slot = doc.createElement('slot');
@@ -36,12 +48,12 @@ export function MenuContainer(HTMLElement) {
36
48
  }
37
49
  get permanent() { return this.parameters.presentation === 'bar'; }
38
50
  get opened() { return this.permanent || this.#opened; }
39
- get items() { return [...this.querySelectorAll('gramlot-menu-line')].filter(item => item.menuOwner===this && !item.parameters.group); }
51
+ get items() { return [...this.querySelectorAll('gramlot-menu-line')].filter(item => item.menuOwner===this && !item.parameters.group && !item.hasAttribute('data-menu-expanded')); }
40
52
  get overflow() { return this.#overflow; }
41
53
  isOverflowed(item) { return this.#overflow.contains(item); }
42
54
  get visibleItems() { return this.items.filter(item => labelboxPresentation(item).slot!=='suppressed' && !item.hidden && !item.closest('[hidden]') && item.getAttribute('role') !== 'separator'); }
43
55
  get usableItems() { return this.visibleItems.filter(item => !item.disabled); }
44
- get parentMenu() { return this.parentElement?.closest('gramlot-menu') ?? null; }
56
+ get parentMenu() { return containingMenu(this); }
45
57
  connectedCallback() {
46
58
  this.#observer = new this.ownerDocument.defaultView.MutationObserver(() => {this.refreshItems();this.#overflow.schedule();});
47
59
  this.#observer.observe(this, {childList:true, subtree:true, characterData:true, attributes:true, attributeFilter:['hidden','disabled']});
@@ -54,7 +66,7 @@ export function MenuContainer(HTMLElement) {
54
66
  projectAttributes(attrs) {
55
67
  const rest = projectParameters(this, attrs);
56
68
  this.#modifierKeys();
57
- if(!Number.isFinite(this.parameters.iconSize)||this.parameters.iconSize<=0)throw new TypeError('menu iconSize must be positive');
69
+ if(!Number.isFinite(this.parameters.icon_size)||this.parameters.icon_size<=0)throw new TypeError('menu icon_size must be positive');
58
70
  this.setAttribute('role', this.permanent ? 'toolbar' : 'menu');
59
71
  this.setAttribute('aria-orientation', this.permanent ? this.parameters.orientation : 'vertical');
60
72
  this.tabIndex = -1;
@@ -62,7 +74,7 @@ export function MenuContainer(HTMLElement) {
62
74
  else this.setAttribute('popover','manual');
63
75
  this.refreshItems();
64
76
  this.#overflow.schedule();
65
- return rest;
77
+ return projectToolbarIconStyle(this, rest);
66
78
  }
67
79
  #modifierKeys() {
68
80
  const value=this.parameters.modifiers;
@@ -112,6 +124,7 @@ export function MenuContainer(HTMLElement) {
112
124
  this.refreshItems();
113
125
  }
114
126
  refreshItems() {
127
+ if (this.hasAttribute('data-menu-inline')) return;
115
128
  for(const group of this.querySelectorAll('gramlot-menu-line'))if(group.menuOwner===this && group.parameters.group)group.refreshAvailability();
116
129
  for(const item of this.items)item.refreshAvailability();
117
130
  const usable = this.usableItems;
@@ -126,7 +139,7 @@ export function MenuContainer(HTMLElement) {
126
139
  const next = this.#previous.slice(index+1).find(item => usable.includes(item))
127
140
  ?? this.#previous.slice(0,index).reverse().find(item => usable.includes(item));
128
141
  this.#active = next ?? null;
129
- if (this.opened && this.status !== 'loading') {
142
+ if (this.opened && this.contains(this.ownerDocument.activeElement) && this.status !== 'loading') {
130
143
  if (next) next.focus();
131
144
  else if (this.permanent) this.focus(); else this.close();
132
145
  }
@@ -159,7 +172,8 @@ export function MenuContainer(HTMLElement) {
159
172
  focusEntry(last = false) {
160
173
  const usable = this.usableItems;
161
174
  const target = usable[last ? usable.length-1 : 0];
162
- if (target) { this.#active=target; target.focus(); } else this.focus();
175
+ if (target) { this.#active=target; target.focus(); }
176
+ else (this.querySelector('[autofocus]') ?? this).focus();
163
177
  }
164
178
  close(restore = true) {
165
179
  for (const child of this.querySelectorAll('gramlot-menu')) if (!child.permanent) child.close(false);
@@ -177,10 +191,10 @@ export function MenuContainer(HTMLElement) {
177
191
  else if (restore && this.#opener?.isConnected) this.#opener.focus();
178
192
  }
179
193
  #key(event) {
180
- if (event.defaultPrevented || event.composedPath().find(node => node.localName === 'gramlot-menu') !== this) return;
194
+ if (event.defaultPrevented || event.composedPath().find(node => node.localName === 'gramlot-menu' && !node.hasAttribute('data-menu-inline')) !== this) return;
181
195
  const item = event.composedPath().find(node => this.items.includes(node));
182
196
  // Embedded editors retain their editing and Tab behavior.
183
- if (!item && event.target !== this) return;
197
+ if (!item && event.target !== this && (event.key !== 'Escape' || this.permanent)) return;
184
198
  const inOverflow=item && this.isOverflowed(item);
185
199
  const items=this.usableItems.filter(entry=>this.isOverflowed(entry)===Boolean(inOverflow)), index=items.indexOf(item);
186
200
  const nextKey=this.permanent && !inOverflow && this.parameters.orientation==='horizontal' ? 'ArrowRight':'ArrowDown';
@@ -230,21 +244,33 @@ export function menuLine(Base) {
230
244
  background:transparent;cursor:pointer;line-height:1.2;white-space:nowrap}
231
245
  :host button.toolbar-button .icon{display:inline-flex;align-items:center;justify-content:center;
232
246
  width:var(--gramlot-toolbar-icon-size);height:var(--gramlot-toolbar-icon-size);font-size:var(--gramlot-toolbar-icon-size);line-height:1}
233
- #control.toolbar-button.icon-only{--gramlot-button-icon-size:var(--gramlot-toolbar-icon-size)}
247
+ #control.toolbar-button.icon-only{--gramlot-button-icon-size:var(--gramlot-toolbar-icon-size);border:0;background:transparent}
248
+ :host(:not([data-menu-group-rows])) #control.toolbar-button.icon-only{
249
+ min-height:max(calc(var(--gramlot-toolbar-icon-size) + 8px),var(--gramlot-touch-target,0px));padding-block:3px}
250
+ #control.toolbar-button.icon-only:hover:not(:disabled){background:color-mix(in srgb,currentColor 17%,transparent)}
251
+ #control.toolbar-button.icon-only:is([aria-checked=true],[aria-expanded=true]){background:var(--gramlot-selected,Highlight)}
252
+ @media(forced-colors:active){#control.toolbar-button.icon-only{background:ButtonFace;border:1px solid ButtonText}#control.toolbar-button.icon-only[aria-checked=true]{background:Highlight;color:HighlightText}}
253
+ :host button.toolbar-button:not([aria-checked=true]):not([aria-expanded=true]) .icon img{color-scheme:var(--gramlot-toolbar-icon-scheme,inherit)}
254
+ .icon{position:relative;color:var(--gramlot-toolbar-icon-color,inherit)}
255
+ .menu-caption{opacity:var(--gramlot-icon-opacity,1)}
256
+ .icon[data-badge]::after{content:attr(data-badge);position:absolute;inset-block-start:-.3em;inset-inline-end:-.6em;
257
+ min-width:1.3em;padding:0 .22em;box-sizing:border-box;border-radius:1em;text-align:center;font:600 10px/1.3 system-ui;
258
+ background:var(--gramlot-icon-badge-background,var(--gramlot-tab-badge-background,var(--gramlot-brand-blue,#3766b5)));color:var(--gramlot-tab-badge-color,white);pointer-events:none}
234
259
  :host button.toolbar-button .icon:empty{display:none}
235
260
  :host button.toolbar-button:hover:not(:disabled){background:color-mix(in srgb,currentColor 10%,transparent)}
236
- :host button.toolbar-button:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-2px}
261
+ :host button.toolbar-button:focus-visible{outline:1px solid var(--gramlot-focus-ring,Highlight);outline-offset:-1px}
237
262
  :host button.toolbar-button[aria-checked=true],:host button.toolbar-button[aria-expanded=true]{background:var(--gramlot-selected,color-mix(in srgb,currentColor 14%,transparent))}
238
263
  :host button.toolbar-button:disabled{opacity:.45;cursor:default}
239
264
  :host button.toolbar-below{flex-direction:column;gap:3px;min-width:54px}
240
265
  :host button.toolbar-below .menu-caption{font-size:11px;line-height:1.2}
241
266
  :host button.toolbar-tooltip .menu-caption{display:none}
242
267
  :host button.toolbar-button .menu-check{display:none}
243
- :host button.toolbar-tooltip .menu-arrow{position:static;flex:0 0 8px;margin-inline-start:2px;font-size:12px;line-height:1}
244
- :host button.toolbar-below .menu-arrow{position:absolute;inset:4px 3px auto auto;font-size:12px}`;
268
+ :host button.toolbar-button .icon > .menu-arrow{position:absolute;right:0;bottom:1px;
269
+ width:0;height:0;border-inline:4px solid transparent;border-top:5px solid currentColor;
270
+ filter:drop-shadow(0 0 1px var(--gramlot-field-background,Canvas));font-size:0;pointer-events:none}`;
245
271
  style.textContent+=`
246
272
  :host([role=group]){display:block;min-width:0}
247
- :host([role=group]) .control-box{display:none}
273
+ :host([role=group]) .control-box,:host([role=separator]) .control-box,:host([data-menu-expanded]) .control-box{display:none}
248
274
  .menu-group{display:flex;align-items:center;gap:var(--gramlot-toolbar-gap,4px);flex-wrap:nowrap}
249
275
  .menu-group ::slotted(*){flex-shrink:0}
250
276
  .menu-group[hidden]{display:none}
@@ -270,11 +296,10 @@ export function menuLine(Base) {
270
296
  });
271
297
  this.addEventListener('pointerleave',()=>clearTimeout(this.#hover));
272
298
  }
273
- get menuOwner() { return this.parentElement?.closest('gramlot-menu') ?? null; }
299
+ get menuOwner() { return containingMenu(this); }
274
300
  get submenu() { return [...this.children].map(labelboxContent).find(child=>child?.localName==='gramlot-menu') ?? null; }
275
301
  get entryCaption() { return this.parameters.caption ?? this.#registry?.label ?? ''; }
276
- get entryIcon() { return this.parameters.icon || this.parameters.iconSrc ? this.parameters.icon : this.#registry?.icon; }
277
- get entryIconSrc() { return this.parameters.icon || this.parameters.iconSrc ? this.parameters.iconSrc : this.#registry?.iconSrc; }
302
+ get entryIcon() { return this.parameters.icon || this.#registry?.icon; }
278
303
  get occurrence() { return this.parameters.code ?? this.sourceLabel; }
279
304
  setCommandDefinition(definition, sourceLabel) {
280
305
  this.#registry=definition; this.sourceLabel=sourceLabel; this.#render();
@@ -282,14 +307,18 @@ export function menuLine(Base) {
282
307
  projectAttributes(attrs,adapt) {
283
308
  const rest=super.projectAttributes(attrs,adapt);
284
309
  this.#accessibleLabel=attrs['aria-label'];
285
- if(this.parameters.iconSize!=null&&(!Number.isFinite(this.parameters.iconSize)||this.parameters.iconSize<=0))throw new TypeError('menuline iconSize must be positive');
310
+ if(this.parameters.icon_size!=null&&(!Number.isFinite(this.parameters.icon_size)||this.parameters.icon_size<=0))throw new TypeError('menuline icon_size must be positive');
311
+ if (this.parameters.expandInBar != null && !Number.isFinite(this.parameters.expandInBar)) throw new TypeError('menuline expandInBar must be finite');
286
312
  this.#authoredDisabled=Boolean(this.parameters.disabled);
287
- this.#render(); this.menuOwner?.refreshItems(); this.menuOwner?.overflow.schedule(); return rest;
313
+ this.#render(); this.menuOwner?.refreshItems(); const owner = this.menuOwner;
314
+ owner?.overflow.schedule();
315
+ if (owner && !owner.permanent) owner.parentMenu?.overflow.schedule();
316
+ return projectToolbarIconStyle(this, rest);
288
317
  }
289
318
  #render() {
290
319
  const separator=[...this.childNodes].filter(node=>node.nodeType===3)
291
320
  .map(node=>node.textContent).join('').trim()==='-' && !this.parameters.command;
292
- this.setAttribute('role',this.parameters.group?'group':separator?'separator':this.parameters.checked==null?'menuitem':'menuitemcheckbox');
321
+ this.setAttribute('role',this.hasAttribute('data-menu-expanded')?'presentation':this.parameters.group?'group':separator?'separator':this.parameters.checked==null?'menuitem':'menuitemcheckbox');
293
322
  this.#group.hidden=!this.parameters.group;
294
323
  this.setAttribute('aria-disabled',String(this.#authoredDisabled));
295
324
  if (this.parameters.checked!=null) {
@@ -299,10 +328,14 @@ export function menuLine(Base) {
299
328
  this.#check.textContent=this.parameters.checked ? '✓':'';
300
329
  this.#caption.textContent=this.parameters.command && !this.#registry ? '???':this.entryCaption;
301
330
  this.caption.hidden=true;
302
- this.renderIcon(this.entryIcon, this.entryIconSrc);
331
+ this.renderIcon(this.entryIcon);
332
+ const badge = this.parameters.badge;
333
+ if (badge == null || badge === '') this.icon.removeAttribute('data-badge');
334
+ else this.icon.dataset.badge = String(badge);
335
+ this.icon.style.setProperty('--gramlot-icon-badge-background', this.parameters.badge_color ?? '');
303
336
  const tooltip=this.parameters.tooltip ?? this.#registry?.tooltip ?? this.entryCaption;
304
- this.control.title=tooltip;
305
- this.control.setAttribute('aria-label',this.#accessibleLabel ?? (this.entryCaption || tooltip));
337
+ const label = this.#accessibleLabel ?? (this.entryCaption || tooltip);
338
+ this.control.setAttribute('aria-label', this.icon.hasAttribute('data-badge') ? label + ' ' + badge : label);
306
339
  if (this.submenu) this.control.setAttribute('aria-haspopup','menu');
307
340
  else this.control.removeAttribute('aria-haspopup');
308
341
  this.refreshAvailability();
@@ -316,18 +349,26 @@ export function menuLine(Base) {
316
349
  }
317
350
  return owner?.parameters[name];
318
351
  };
352
+ const tooltipOwner = this.closest('gramlot-menu')?.closest('gramlot-menu[role=toolbar]');
353
+ const showTooltip = owner?.parameters.showTooltip ?? tooltipOwner?.parameters.showTooltip ?? true;
354
+ this.control.title = showTooltip ? (this.parameters.tooltip ?? this.#registry?.tooltip ?? this.entryCaption) : '';
319
355
  const toolbar=Boolean(owner?.permanent && !popup);
320
356
  const labelPosition=inherited('labelPosition');
321
- this.control.classList.toggle('toolbar-button',toolbar);
357
+ const standardButton = toolbar && this.classList.contains('button--standard');
358
+ this.control.classList.toggle('standard-button', standardButton);
359
+ this.control.classList.toggle('toolbar-button',toolbar && !standardButton);
322
360
  this.control.classList.toggle('toolbar-below',toolbar && labelPosition==='below');
323
361
  this.control.classList.toggle('toolbar-tooltip',toolbar && labelPosition==='tooltip');
324
- if(toolbar)this.control.style.setProperty('--gramlot-toolbar-icon-size',`${inherited('iconSize')}px`);
362
+ if(toolbar)this.control.style.setProperty('--gramlot-toolbar-icon-size',`${inherited('icon_size')}px`);
325
363
  else this.control.style.removeProperty('--gramlot-toolbar-icon-size');
326
364
  this.toggleAttribute('data-menu-group-rows',Boolean(popup || owner?.parameters.orientation==='vertical'));
327
365
  this.control.classList.toggle('menu-row', popup);
328
- this.#arrow.textContent = this.submenu ? (toolbar && labelPosition==='tooltip' ? '⌄' : popup || owner?.parameters.orientation==='vertical' ? '›' : '▾') : '';
366
+ this.#arrow.textContent = this.submenu ? (popup ? '›' : '▾') : '';
367
+ const arrowParent = toolbar && this.submenu && (this.entryIcon || this.entryIconSrc) ? this.icon : this.control;
368
+ if (this.#arrow.parentNode !== arrowParent) arrowParent.append(this.#arrow);
329
369
  const disabled=this.#authoredDisabled || this.getAttribute('role')==='separator'
330
370
  || Boolean(this.parameters.command && !this.#registry)
371
+ || Boolean(this.parentElement?.closest('gramlot-menu-line[data-menu-expanded]')?.disabled)
331
372
  || ['loading','error'].includes(owner?.status)
332
373
  || Boolean(this.closest('gramlot-drop-down-button')?.parameters.disabled);
333
374
  if(this.control.disabled!==disabled)this.control.disabled=disabled;
@@ -336,6 +377,23 @@ export function menuLine(Base) {
336
377
  get disabled() {
337
378
  for(let p=this.parentElement;p && p!==this.menuOwner;p=p.parentElement)if(p.localName==='gramlot-menu-line' && p.parameters.disabled)return true;
338
379
  return this.control.disabled || Boolean(this.closest('gramlot-drop-down-button')?.parameters.disabled); }
380
+ showInBar(expanded, orientation) {
381
+ const submenu = this.submenu;
382
+ this.toggleAttribute('data-menu-expanded', expanded);
383
+ if (expanded) {
384
+ submenu.setAttribute('data-menu-inline', orientation);
385
+ this.setAttribute('role', 'presentation');
386
+ submenu.setAttribute('role', 'group');
387
+ } else {
388
+ submenu?.removeAttribute('data-menu-inline');
389
+ submenu?.setAttribute('role', 'menu');
390
+ this.setAttribute('role', this.parameters.checked == null ? 'menuitem' : 'menuitemcheckbox');
391
+ }
392
+ const owner = expanded ? this.menuOwner : submenu;
393
+ for (const child of submenu?.querySelectorAll('gramlot-menu-line') ?? []) {
394
+ if (child.menuOwner === owner) child.refreshAvailability();
395
+ }
396
+ }
339
397
  set disabled(value) { this.control.disabled=Boolean(value); }
340
398
  attachCommand() { this.#render(); }
341
399
  releaseCommand() { clearTimeout(this.#hover); this.submenu?.close(false); }
@@ -0,0 +1,39 @@
1
+ export const numericRangeParameters = {
2
+ value: {dtype: 'R', default: 0, binding: 'twoWay'},
3
+ min: {dtype: 'R', default: 0, binding: 'read', target: 'control'},
4
+ max: {dtype: 'R', default: 100, binding: 'read', target: 'control'},
5
+ step: {dtype: 'R', default: 1, binding: 'read', target: 'control'}
6
+ };
7
+
8
+ // The native range owns step rounding, clamping and keyboard interaction.
9
+ export function numericRange(Base) {
10
+ return class extends Base {
11
+ #sourceContext;
12
+ #correcting = false;
13
+
14
+ setSourceContext(context) { this.#sourceContext = context; }
15
+ createControl() {
16
+ const control = this.ownerDocument.createElement('input');
17
+ control.type = 'range';
18
+ return control;
19
+ }
20
+ readControlValue() { return this.control.valueAsNumber; }
21
+ writeControlValue(value) {
22
+ this.control.value = String(value);
23
+ const corrected = this.control.valueAsNumber;
24
+ if (!this.#correcting && Number.isFinite(value) && corrected !== value) {
25
+ this.#correcting = true;
26
+ try { this.#sourceContext.writeParameter('value', corrected); }
27
+ finally { this.#correcting = false; }
28
+ }
29
+ }
30
+ projectAttributes(attrs, adapt) {
31
+ const previous = this.parameters;
32
+ const rest = super.projectAttributes(attrs, adapt);
33
+ if (previous && ['min', 'max', 'step'].some(name => previous[name] !== this.parameters[name])) {
34
+ this.writeControlValue(this.parameters.value);
35
+ }
36
+ return rest;
37
+ }
38
+ };
39
+ }