flexdesk 0.18.1 → 0.18.2
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.
- package/CHANGELOG.md +20 -0
- package/css/flexdesk.css +50 -0
- package/dist/flexdesk.css +50 -0
- package/dist/flow.js +21 -9
- package/dist/flow.js.map +2 -2
- package/docs/components/flow-editors.md +20 -0
- package/package.json +1 -1
- package/src/flow/kit/settings_panel.js +24 -9
|
@@ -81,6 +81,26 @@ be used is disabled and its reason is shown next to it, not only in a tooltip.
|
|
|
81
81
|
`extra` holds the editor's own fields (a port shown as a setting) and notes,
|
|
82
82
|
placed with `after: '<key>'` or `at: 'start'`.
|
|
83
83
|
|
|
84
|
+
### A flat panel: `variant: 'sheet'` (0.18.2)
|
|
85
|
+
|
|
86
|
+
`createSettingsPanel({ ..., variant: 'sheet' })` draws the panel flat, as one
|
|
87
|
+
section of a page of them: no fill and no icon chip, the title and the
|
|
88
|
+
description in a margin at the left, the id line, findings, slots and fields
|
|
89
|
+
beside them. Two sheets in a row are split by a rule, so a settings page built of
|
|
90
|
+
several panels (one per subject: *Run*, *Solver*, *Metadata*) reads as one form.
|
|
91
|
+
Narrower than 560px the margin goes above the fields. Everything else is the
|
|
92
|
+
card's: `show()`, the repaints, focus, findings and slots behave the same.
|
|
93
|
+
`variant` is `'card'` (the default) or `'sheet'`; any other value is refused when
|
|
94
|
+
the panel is created.
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
for (const section of sections) {
|
|
98
|
+
const panel = createSettingsPanel({ widgets, host: page, variant: 'sheet', onChange: section.write });
|
|
99
|
+
panel.show({ title: section.title, description: section.hint, type: { config_schema: section.schema },
|
|
100
|
+
value: section.read() });
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
84
104
|
**The widgets.** A schema type with no `x-ui-widget` draws its plain control: an
|
|
85
105
|
`enum` a select (writing the enum's own value, so a number stays a number), a
|
|
86
106
|
string a text box, a number a number box, a boolean a checkbox, an object with
|
package/package.json
CHANGED
|
@@ -50,13 +50,20 @@ const TITLE = 'data-twm-flow-title';
|
|
|
50
50
|
* @param {string} [o.valuesNote] the picker's footer sentence
|
|
51
51
|
* @param {(step: object) => object[]|null} [o.columns] a step's input columns (a data flow)
|
|
52
52
|
* @param {HTMLElement} [o.host] appended here when given
|
|
53
|
+
* @param {'card'|'sheet'} [o.variant] 'card' (the default): a raised panel, its header above
|
|
54
|
+
* its fields. 'sheet': flat, one section of a page of them — the title and the description
|
|
55
|
+
* in a margin at the left, the fields beside them, a rule between two sheets (0.18.2)
|
|
53
56
|
*/
|
|
54
57
|
export function createSettingsPanel({ widgets, references = {}, strings = null, services = null, readOnly = false,
|
|
55
58
|
onChange = null, onRename = null, onFocusLost = null, values = null,
|
|
56
|
-
valuesNote = null, columns = null, host = null } = {}) {
|
|
59
|
+
valuesNote = null, columns = null, host = null, variant = 'card' } = {}) {
|
|
57
60
|
if (!widgets?.get) throw new Error('createSettingsPanel needs a widget registry (createWidgetRegistry()).');
|
|
61
|
+
if (variant !== 'card' && variant !== 'sheet') {
|
|
62
|
+
throw new Error(`createSettingsPanel's variant is 'card' or 'sheet', not ${JSON.stringify(variant)}.`);
|
|
63
|
+
}
|
|
64
|
+
const sheet = variant === 'sheet';
|
|
58
65
|
const S = createStrings(strings);
|
|
59
|
-
const root = el('section', 'twm-flow-panel');
|
|
66
|
+
const root = el('section', sheet ? 'twm-flow-panel twm-flow-panel--sheet' : 'twm-flow-panel');
|
|
60
67
|
root.setAttribute('role', 'region');
|
|
61
68
|
root.setAttribute('aria-label', say(S, 'settings'));
|
|
62
69
|
if (host) host.appendChild(root);
|
|
@@ -167,15 +174,23 @@ export function createSettingsPanel({ widgets, references = {}, strings = null,
|
|
|
167
174
|
root.replaceChildren();
|
|
168
175
|
if (!spec) return;
|
|
169
176
|
if (isReadOnly() && readOnlyReason()) root.appendChild(el('p', 'twm-flow-panel__readonly', readOnlyReason()));
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
177
|
+
// A sheet sets the header and the description in its margin, the rest beside them
|
|
178
|
+
const margin = sheet ? el('div', 'twm-flow-panel__margin') : root;
|
|
179
|
+
const body = sheet ? el('div', 'twm-flow-panel__body') : root;
|
|
180
|
+
if (sheet) {
|
|
181
|
+
const grid = el('div', 'twm-flow-panel__sheet');
|
|
182
|
+
grid.append(margin, body);
|
|
183
|
+
root.appendChild(grid);
|
|
184
|
+
}
|
|
185
|
+
margin.appendChild(paintHeader());
|
|
186
|
+
if (spec.description) margin.appendChild(el('p', 'twm-flow-panel__description', spec.description));
|
|
187
|
+
if (spec.idLine) body.appendChild(el('div', 'twm-flow-panel__id', spec.idLine));
|
|
173
188
|
findingsBox = el('ul', 'twm-flow-panel__findings');
|
|
174
189
|
findingsBox.hidden = true;
|
|
175
|
-
|
|
190
|
+
body.appendChild(findingsBox);
|
|
176
191
|
slotBefore = el('div', 'twm-flow-panel__slot');
|
|
177
192
|
slotBefore.dataset.slot = 'before';
|
|
178
|
-
|
|
193
|
+
body.appendChild(slotBefore);
|
|
179
194
|
|
|
180
195
|
const list = el('div', 'twm-flow-panel__fields');
|
|
181
196
|
allFields = Array.isArray(spec.fields) ? spec.fields : fieldsFromSchema(spec.type?.config_schema);
|
|
@@ -213,10 +228,10 @@ export function createSettingsPanel({ widgets, references = {}, strings = null,
|
|
|
213
228
|
const anchor = placed(e);
|
|
214
229
|
if (anchor === null || !keys.has(anchor)) drawExtra(e);
|
|
215
230
|
}
|
|
216
|
-
|
|
231
|
+
body.appendChild(list);
|
|
217
232
|
slotAfter = el('div', 'twm-flow-panel__slot');
|
|
218
233
|
slotAfter.dataset.slot = 'after';
|
|
219
|
-
|
|
234
|
+
body.appendChild(slotAfter);
|
|
220
235
|
paintSlots();
|
|
221
236
|
applyFindings();
|
|
222
237
|
}
|