@fieldia/viewer 0.19.1 → 0.20.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.
- package/README.md +18 -0
- package/bundle/fieldia.ar.js +2 -2
- package/bundle/fieldia.ar.js.map +2 -2
- package/bundle/fieldia.choice.js +5 -0
- package/bundle/fieldia.choice.js.map +7 -0
- package/bundle/fieldia.de.js +2 -2
- package/bundle/fieldia.de.js.map +2 -2
- package/bundle/fieldia.filters.js +5 -0
- package/bundle/fieldia.filters.js.map +7 -0
- package/bundle/fieldia.fr.js +2 -2
- package/bundle/fieldia.fr.js.map +2 -2
- package/bundle/fieldia.head.js +5 -0
- package/bundle/fieldia.head.js.map +7 -0
- package/bundle/fieldia.js +44 -44
- package/bundle/fieldia.js.map +4 -4
- package/bundle/fieldia.path.js +5 -0
- package/bundle/fieldia.path.js.map +7 -0
- package/bundle/fieldia.text.js +24 -0
- package/bundle/fieldia.text.js.map +7 -0
- package/package.json +7 -3
- package/src/index.d.mts +2 -1
- package/src/index.d.ts +2 -1
- package/src/index.js +6 -1
- package/src/index.js.map +1 -1
- package/src/index.mjs +1 -0
- package/src/index.mjs.map +1 -1
- package/src/lib/button-parts.d.mts +30 -0
- package/src/lib/button-parts.d.ts +30 -0
- package/src/lib/button-parts.js +24 -0
- package/src/lib/button-parts.js.map +1 -0
- package/src/lib/button-parts.mjs +18 -0
- package/src/lib/button-parts.mjs.map +1 -0
- package/src/lib/dialog-window.d.mts +11 -0
- package/src/lib/dialog-window.d.ts +11 -0
- package/src/lib/dialog-window.js +86 -0
- package/src/lib/dialog-window.js.map +1 -0
- package/src/lib/dialog-window.mjs +82 -0
- package/src/lib/dialog-window.mjs.map +1 -0
- package/src/lib/dialog.d.mts +14 -3
- package/src/lib/dialog.d.ts +14 -3
- package/src/lib/dialog.js +84 -14
- package/src/lib/dialog.js.map +1 -1
- package/src/lib/dialog.mjs +85 -15
- package/src/lib/dialog.mjs.map +1 -1
- package/src/lib/filter-bar.d.mts +39 -0
- package/src/lib/filter-bar.d.ts +39 -0
- package/src/lib/filter-bar.js +290 -0
- package/src/lib/filter-bar.js.map +1 -0
- package/src/lib/filter-bar.mjs +287 -0
- package/src/lib/filter-bar.mjs.map +1 -0
- package/src/lib/filter-styles.d.mts +4 -0
- package/src/lib/filter-styles.d.ts +4 -0
- package/src/lib/filter-styles.js +63 -0
- package/src/lib/filter-styles.js.map +1 -0
- package/src/lib/filter-styles.mjs +59 -0
- package/src/lib/filter-styles.mjs.map +1 -0
- package/src/lib/filters-part.d.mts +8 -0
- package/src/lib/filters-part.d.ts +8 -0
- package/src/lib/filters-part.js +14 -0
- package/src/lib/filters-part.js.map +1 -0
- package/src/lib/filters-part.mjs +9 -0
- package/src/lib/filters-part.mjs.map +1 -0
- package/src/lib/group-styles.d.mts +9 -0
- package/src/lib/group-styles.d.ts +9 -0
- package/src/lib/group-styles.js +64 -0
- package/src/lib/group-styles.js.map +1 -0
- package/src/lib/group-styles.mjs +60 -0
- package/src/lib/group-styles.mjs.map +1 -0
- package/src/lib/head-part.d.mts +15 -0
- package/src/lib/head-part.d.ts +15 -0
- package/src/lib/head-part.js +26 -0
- package/src/lib/head-part.js.map +1 -0
- package/src/lib/head-part.mjs +16 -0
- package/src/lib/head-part.mjs.map +1 -0
- package/src/lib/head-styles.d.mts +28 -0
- package/src/lib/head-styles.d.ts +28 -0
- package/src/lib/head-styles.js +320 -0
- package/src/lib/head-styles.js.map +1 -0
- package/src/lib/head-styles.mjs +316 -0
- package/src/lib/head-styles.mjs.map +1 -0
- package/src/lib/labels.d.mts +29 -0
- package/src/lib/labels.d.ts +29 -0
- package/src/lib/labels.js +16 -0
- package/src/lib/labels.js.map +1 -1
- package/src/lib/labels.mjs +16 -0
- package/src/lib/labels.mjs.map +1 -1
- package/src/lib/list-styles.d.mts +1 -1
- package/src/lib/list-styles.d.ts +1 -1
- package/src/lib/list-styles.js +88 -1
- package/src/lib/list-styles.js.map +1 -1
- package/src/lib/list-styles.mjs +88 -1
- package/src/lib/list-styles.mjs.map +1 -1
- package/src/lib/list.d.mts +16 -1
- package/src/lib/list.d.ts +16 -1
- package/src/lib/list.js +281 -51
- package/src/lib/list.js.map +1 -1
- package/src/lib/list.mjs +282 -52
- package/src/lib/list.mjs.map +1 -1
- package/src/lib/locales/ar.js +16 -0
- package/src/lib/locales/ar.js.map +1 -1
- package/src/lib/locales/ar.mjs +16 -0
- package/src/lib/locales/ar.mjs.map +1 -1
- package/src/lib/locales/de.js +16 -0
- package/src/lib/locales/de.js.map +1 -1
- package/src/lib/locales/de.mjs +16 -0
- package/src/lib/locales/de.mjs.map +1 -1
- package/src/lib/locales/fr.js +16 -0
- package/src/lib/locales/fr.js.map +1 -1
- package/src/lib/locales/fr.mjs +16 -0
- package/src/lib/locales/fr.mjs.map +1 -1
- package/src/lib/look.d.mts +1 -1
- package/src/lib/look.d.ts +1 -1
- package/src/lib/look.js +3 -0
- package/src/lib/look.js.map +1 -1
- package/src/lib/look.mjs +3 -0
- package/src/lib/look.mjs.map +1 -1
- package/src/lib/record-bar.d.mts +10 -1
- package/src/lib/record-bar.d.ts +10 -1
- package/src/lib/record-bar.js +15 -7
- package/src/lib/record-bar.js.map +1 -1
- package/src/lib/record-bar.mjs +14 -7
- package/src/lib/record-bar.mjs.map +1 -1
- package/src/lib/record-head.d.mts +58 -0
- package/src/lib/record-head.d.ts +58 -0
- package/src/lib/record-head.js +245 -0
- package/src/lib/record-head.js.map +1 -0
- package/src/lib/record-head.mjs +240 -0
- package/src/lib/record-head.mjs.map +1 -0
- package/src/lib/rich-button.d.mts +12 -0
- package/src/lib/rich-button.d.ts +12 -0
- package/src/lib/rich-button.js +186 -0
- package/src/lib/rich-button.js.map +1 -0
- package/src/lib/rich-button.mjs +183 -0
- package/src/lib/rich-button.mjs.map +1 -0
- package/src/lib/section-head.d.mts +26 -0
- package/src/lib/section-head.d.ts +26 -0
- package/src/lib/section-head.js +65 -0
- package/src/lib/section-head.js.map +1 -0
- package/src/lib/section-head.mjs +56 -0
- package/src/lib/section-head.mjs.map +1 -0
- package/src/lib/section-tools.d.mts +12 -0
- package/src/lib/section-tools.d.ts +12 -0
- package/src/lib/section-tools.js +124 -0
- package/src/lib/section-tools.js.map +1 -0
- package/src/lib/section-tools.mjs +121 -0
- package/src/lib/section-tools.mjs.map +1 -0
- package/src/lib/viewer-parts.d.mts +33 -0
- package/src/lib/viewer-parts.d.ts +33 -0
- package/src/lib/viewer-parts.js +75 -0
- package/src/lib/viewer-parts.js.map +1 -0
- package/src/lib/viewer-parts.mjs +70 -0
- package/src/lib/viewer-parts.mjs.map +1 -0
- package/src/lib/viewer.d.mts +30 -7
- package/src/lib/viewer.d.ts +30 -7
- package/src/lib/viewer.js +317 -97
- package/src/lib/viewer.js.map +1 -1
- package/src/lib/viewer.mjs +319 -99
- package/src/lib/viewer.mjs.map +1 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { drawIcon } from '@fieldia/widgets';
|
|
2
|
+
import { nothingToUndo, onlyResets } from './button-parts.mjs';
|
|
3
|
+
import { setAttr, setHidden, setText } from './dom.mjs';
|
|
4
|
+
import { installHeadStyles } from './head-styles.mjs';
|
|
5
|
+
import { hotkeyOn } from './hotkeys.mjs';
|
|
6
|
+
/**
|
|
7
|
+
* A button of the record's head, or one anywhere asking for the same: its
|
|
8
|
+
* icon alone (named by its label, which is its tooltip too); a toggle,
|
|
9
|
+
* pressed while its condition holds and showing its pressed words meanwhile;
|
|
10
|
+
* a split button — its press, then a chevron (or its own icon, Follow's gear)
|
|
11
|
+
* opening a menu of more; a menu button when it has nothing of its own to
|
|
12
|
+
* run; the primary look while the record has changes, quiet but usable
|
|
13
|
+
* otherwise — with nothing changed, Save and Close simply closes.
|
|
14
|
+
*/
|
|
15
|
+
export function richButton(context, node) {
|
|
16
|
+
const { el, form, labels } = context;
|
|
17
|
+
installHeadStyles(context.doc);
|
|
18
|
+
const own = !!node.steps?.length || node.action !== undefined;
|
|
19
|
+
const menu = node.menu?.length ? node.menu : null;
|
|
20
|
+
const look = () => (node.primaryWhenChanged ? (form.getState().dirty.length ? 'primary' : 'subtle') : node.style ?? 'secondary');
|
|
21
|
+
const words = el('bdi', { class: 'fd-button-words' }, node.label);
|
|
22
|
+
const icon = drawIcon(context.doc, node.icon, context.icons);
|
|
23
|
+
const main = el('button', { type: 'button', class: 'fd-button', 'data-node': menu && own ? undefined : node.id });
|
|
24
|
+
if (icon)
|
|
25
|
+
main.append(icon);
|
|
26
|
+
if (node.iconOnly) {
|
|
27
|
+
main.classList.add('fd-button-icon-only');
|
|
28
|
+
main.setAttribute('aria-label', node.label);
|
|
29
|
+
main.title = node.label;
|
|
30
|
+
}
|
|
31
|
+
else
|
|
32
|
+
main.append(words);
|
|
33
|
+
if (node.hotkey)
|
|
34
|
+
hotkeyOn(main, node.hotkey, node.label);
|
|
35
|
+
/** What a press of the button itself does: its steps and action — Save and Close with nothing to save only closes. */
|
|
36
|
+
const run = () => {
|
|
37
|
+
const state = form.getState();
|
|
38
|
+
if (node.primaryWhenChanged && !state.dirty.length && state.recordId != null && node.steps?.some((step) => step.do === 'save')) {
|
|
39
|
+
const steps = [...(node.steps ?? []).filter((step) => step.do !== 'save'), ...(node.action !== undefined ? [{ do: 'call', action: node.action, ...(node.params ? { params: node.params } : {}) }] : [])];
|
|
40
|
+
return form.run(steps, { id: node.id });
|
|
41
|
+
}
|
|
42
|
+
return form.runAction(node.id);
|
|
43
|
+
};
|
|
44
|
+
if (!menu) {
|
|
45
|
+
main.classList.add(`fd-button-${look()}`);
|
|
46
|
+
main.addEventListener('click', () => {
|
|
47
|
+
if (!nothingToUndo(node, form, context.say, labels))
|
|
48
|
+
void context.press(main, run);
|
|
49
|
+
});
|
|
50
|
+
context.watch(() => paint(main));
|
|
51
|
+
return main;
|
|
52
|
+
}
|
|
53
|
+
// ---- a menu beside it, or a menu alone ----
|
|
54
|
+
const id = context.uid(`${node.id}-menu`);
|
|
55
|
+
const chevron = drawIcon(context.doc, node.menuIcon ?? 'chevron-down', context.icons);
|
|
56
|
+
const opener = own ? el('button', { type: 'button', class: 'fd-button fd-split-more', id: `${id}-button`, 'aria-haspopup': 'menu', 'aria-expanded': 'false', 'aria-controls': id }) : main;
|
|
57
|
+
// Its own name, never the button's: a reader hears two buttons, not one twice.
|
|
58
|
+
const menuName = node.menuLabel ?? labels.optionsFor.replace('{label}', node.label);
|
|
59
|
+
if (own) {
|
|
60
|
+
opener.setAttribute('aria-label', menuName);
|
|
61
|
+
opener.title = menuName;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
opener.id = `${id}-button`;
|
|
65
|
+
for (const [name, value] of Object.entries({ 'aria-haspopup': 'menu', 'aria-expanded': 'false', 'aria-controls': id }))
|
|
66
|
+
opener.setAttribute(name, value);
|
|
67
|
+
}
|
|
68
|
+
if (chevron) {
|
|
69
|
+
chevron.classList.add('fd-split-icon');
|
|
70
|
+
opener.append(chevron);
|
|
71
|
+
}
|
|
72
|
+
const list = el('div', { class: 'fd-record-menu fd-button-menu', role: 'menu', id, 'aria-labelledby': opener.id, hidden: '' });
|
|
73
|
+
const items = menu.map((item) => {
|
|
74
|
+
const button = el('button', { type: 'button', role: 'menuitem', tabindex: '-1', class: 'fd-record-menu-item', 'data-node': item.id }, ...context.withIcon(item.icon, item.label ?? item.id));
|
|
75
|
+
button.addEventListener('click', () => {
|
|
76
|
+
close(true);
|
|
77
|
+
void context.press(opener, () => form.runAction(item.id));
|
|
78
|
+
});
|
|
79
|
+
return { item, button };
|
|
80
|
+
});
|
|
81
|
+
list.append(...items.map((i) => i.button));
|
|
82
|
+
const parts = own ? [main, el('span', { class: 'fd-split-rule', 'aria-hidden': 'true' }), opener] : [main];
|
|
83
|
+
const box = el('div', { class: `fd-split${own ? '' : ' fd-split-alone'}`, 'data-node': node.id, role: own ? 'group' : undefined, 'aria-label': own ? node.label : undefined }, ...parts, list);
|
|
84
|
+
const shown = () => items.filter((i) => !i.button.hidden).map((i) => i.button);
|
|
85
|
+
const outside = (event) => {
|
|
86
|
+
if (!box.contains(event.target))
|
|
87
|
+
close(false);
|
|
88
|
+
};
|
|
89
|
+
function open(at) {
|
|
90
|
+
if (!list.hidden)
|
|
91
|
+
return;
|
|
92
|
+
list.hidden = false;
|
|
93
|
+
// Under the button's start, unless that runs past the window: then from its end.
|
|
94
|
+
list.removeAttribute('data-end');
|
|
95
|
+
const room = list.getBoundingClientRect();
|
|
96
|
+
if (room.right > context.doc.documentElement.clientWidth - 4 || room.left < 4)
|
|
97
|
+
list.setAttribute('data-end', '');
|
|
98
|
+
opener.setAttribute('aria-expanded', 'true');
|
|
99
|
+
context.doc.addEventListener('pointerdown', outside, true);
|
|
100
|
+
const found = shown();
|
|
101
|
+
(at === 'first' ? found[0] : found[found.length - 1])?.focus();
|
|
102
|
+
}
|
|
103
|
+
function close(refocus) {
|
|
104
|
+
if (list.hidden)
|
|
105
|
+
return;
|
|
106
|
+
list.hidden = true;
|
|
107
|
+
opener.setAttribute('aria-expanded', 'false');
|
|
108
|
+
context.doc.removeEventListener('pointerdown', outside, true);
|
|
109
|
+
if (refocus)
|
|
110
|
+
opener.focus();
|
|
111
|
+
}
|
|
112
|
+
context.cleanups.push(() => context.doc.removeEventListener('pointerdown', outside, true));
|
|
113
|
+
opener.addEventListener('click', () => (list.hidden ? open('first') : close(false)));
|
|
114
|
+
opener.addEventListener('keydown', (event) => {
|
|
115
|
+
if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp')
|
|
116
|
+
return;
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
open(event.key === 'ArrowDown' ? 'first' : 'last');
|
|
119
|
+
});
|
|
120
|
+
if (own) {
|
|
121
|
+
main.addEventListener('click', () => {
|
|
122
|
+
if (!nothingToUndo(node, form, context.say, labels))
|
|
123
|
+
void context.press(main, run);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
list.addEventListener('keydown', (event) => {
|
|
127
|
+
const found = shown();
|
|
128
|
+
const at = found.indexOf(context.doc.activeElement);
|
|
129
|
+
const to = { ArrowDown: at + 1, ArrowUp: at - 1, Home: 0, End: found.length - 1 }[event.key];
|
|
130
|
+
if (to !== undefined) {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
found[(to + found.length) % found.length]?.focus();
|
|
133
|
+
}
|
|
134
|
+
else if (event.key === 'Escape') {
|
|
135
|
+
// Escape closes the menu, not the dialog round the form.
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
event.stopPropagation();
|
|
138
|
+
close(true);
|
|
139
|
+
}
|
|
140
|
+
else if (event.key === 'Tab')
|
|
141
|
+
close(false);
|
|
142
|
+
});
|
|
143
|
+
context.watch(() => {
|
|
144
|
+
paint(main);
|
|
145
|
+
if (own)
|
|
146
|
+
paint(opener);
|
|
147
|
+
box.setAttribute('data-look', look());
|
|
148
|
+
for (const { item, button } of items)
|
|
149
|
+
setHidden(button, form.node(item.id).invisible);
|
|
150
|
+
// A menu with nothing in it shows no chevron.
|
|
151
|
+
setHidden(opener, !items.some((i) => !i.button.hidden) && own);
|
|
152
|
+
});
|
|
153
|
+
return box;
|
|
154
|
+
/**
|
|
155
|
+
* Its look and its words now: primary or quiet, pressed or not, hidden by its condition. Undo with nothing changed is
|
|
156
|
+
* drawn idle, its tooltip saying why, and a press says it too: still a button, never greyed out without a reason.
|
|
157
|
+
*/
|
|
158
|
+
function paint(button) {
|
|
159
|
+
const at = form.node(node.id);
|
|
160
|
+
if (button === main || !own)
|
|
161
|
+
setHidden(menu ? box : button, at.invisible);
|
|
162
|
+
for (const one of ['primary', 'secondary', 'subtle', 'danger', 'link'])
|
|
163
|
+
button.classList.toggle(`fd-button-${one}`, one === look());
|
|
164
|
+
if (button === main && onlyResets(node.steps, node.action)) {
|
|
165
|
+
const idle = !form.getState().dirty.length;
|
|
166
|
+
setAttr(main, 'data-idle', idle ? '' : null);
|
|
167
|
+
if (node.iconOnly)
|
|
168
|
+
main.title = idle ? `${node.label} — ${labels.nothingChanged}` : node.label;
|
|
169
|
+
}
|
|
170
|
+
if (node.pressed === undefined || button !== main)
|
|
171
|
+
return;
|
|
172
|
+
const pressed = at.pressed === true;
|
|
173
|
+
setAttr(main, 'aria-pressed', String(pressed));
|
|
174
|
+
const said = pressed && node.pressedLabel ? node.pressedLabel : node.label;
|
|
175
|
+
if (node.iconOnly) {
|
|
176
|
+
setAttr(main, 'aria-label', said);
|
|
177
|
+
main.title = said;
|
|
178
|
+
}
|
|
179
|
+
else
|
|
180
|
+
setText(words, said);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=rich-button.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-button.mjs","sourceRoot":"","sources":["../../../../../libs/viewer/src/lib/rich-button.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAsB,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,OAAsB,EAAE,IAAgB;IACjE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACrC,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC;IAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAClD,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,CAAC,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import { type IconSet, type Widget, type WidgetLabels } from '@fieldia/widgets';
|
|
3
|
+
/** A field's own tools, kept by its wrapper for the group round it to take. */
|
|
4
|
+
export declare function keepTools(wrapper: HTMLElement, widget: Widget): void;
|
|
5
|
+
/** Whether a group draws the work item's heading: its fold control at the end, or a ⤢. */
|
|
6
|
+
export declare const workHeading: (node: SectionNode) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The tools of the one field a group holds, its label out of sight, for the
|
|
9
|
+
* group's heading: the field says what the group is, so its tools are the
|
|
10
|
+
* group's too.
|
|
11
|
+
*/
|
|
12
|
+
export declare function loneFieldTools(node: SectionNode, content: HTMLElement): HTMLElement[];
|
|
13
|
+
/** A group's own column widths and the room between them, worn by its grid (from a tablet's width up). */
|
|
14
|
+
export declare function applyTracks(grid: HTMLElement, node: SectionNode): void;
|
|
15
|
+
export interface HeadKit {
|
|
16
|
+
doc: Document;
|
|
17
|
+
labels: WidgetLabels;
|
|
18
|
+
icons?: IconSet;
|
|
19
|
+
/** The words with the icon a page names before them. */
|
|
20
|
+
withIcon(name: string | undefined, text: string): (Node | string)[];
|
|
21
|
+
el<K extends keyof HTMLElementTagNameMap>(tag: K, attrs?: Record<string, string | undefined>, ...children: (Node | string)[]): HTMLElementTagNameMap[K];
|
|
22
|
+
}
|
|
23
|
+
/** Words with `[words](address)` links among them, each text part of a text's words. */
|
|
24
|
+
export declare function wordsWithLinks(doc: Document, nodes: (Node | string)[]): (Node | string)[];
|
|
25
|
+
/** A text's help box: room for an icon at its start, the words in a paragraph beside it. */
|
|
26
|
+
export declare function helpBox(kit: HeadKit, node: TextNode, words: (Node | string)[]): HTMLElement;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SectionNode, TextNode } from '@fieldia/core';
|
|
2
|
+
import { type IconSet, type Widget, type WidgetLabels } from '@fieldia/widgets';
|
|
3
|
+
/** A field's own tools, kept by its wrapper for the group round it to take. */
|
|
4
|
+
export declare function keepTools(wrapper: HTMLElement, widget: Widget): void;
|
|
5
|
+
/** Whether a group draws the work item's heading: its fold control at the end, or a ⤢. */
|
|
6
|
+
export declare const workHeading: (node: SectionNode) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The tools of the one field a group holds, its label out of sight, for the
|
|
9
|
+
* group's heading: the field says what the group is, so its tools are the
|
|
10
|
+
* group's too.
|
|
11
|
+
*/
|
|
12
|
+
export declare function loneFieldTools(node: SectionNode, content: HTMLElement): HTMLElement[];
|
|
13
|
+
/** A group's own column widths and the room between them, worn by its grid (from a tablet's width up). */
|
|
14
|
+
export declare function applyTracks(grid: HTMLElement, node: SectionNode): void;
|
|
15
|
+
export interface HeadKit {
|
|
16
|
+
doc: Document;
|
|
17
|
+
labels: WidgetLabels;
|
|
18
|
+
icons?: IconSet;
|
|
19
|
+
/** The words with the icon a page names before them. */
|
|
20
|
+
withIcon(name: string | undefined, text: string): (Node | string)[];
|
|
21
|
+
el<K extends keyof HTMLElementTagNameMap>(tag: K, attrs?: Record<string, string | undefined>, ...children: (Node | string)[]): HTMLElementTagNameMap[K];
|
|
22
|
+
}
|
|
23
|
+
/** Words with `[words](address)` links among them, each text part of a text's words. */
|
|
24
|
+
export declare function wordsWithLinks(doc: Document, nodes: (Node | string)[]): (Node | string)[];
|
|
25
|
+
/** A text's help box: room for an icon at its start, the words in a paragraph beside it. */
|
|
26
|
+
export declare function helpBox(kit: HeadKit, node: TextNode, words: (Node | string)[]): HTMLElement;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.workHeading = void 0;
|
|
4
|
+
exports.keepTools = keepTools;
|
|
5
|
+
exports.loneFieldTools = loneFieldTools;
|
|
6
|
+
exports.applyTracks = applyTracks;
|
|
7
|
+
exports.wordsWithLinks = wordsWithLinks;
|
|
8
|
+
exports.helpBox = helpBox;
|
|
9
|
+
const widgets_1 = require("@fieldia/widgets");
|
|
10
|
+
/**
|
|
11
|
+
* A group drawn as a work item draws one: its heading's words, then its tools
|
|
12
|
+
* at the heading's end — ⤢ that shows the group alone over the record's body,
|
|
13
|
+
* ^ and ⌄ that fold it, and the tools of a field it holds alone (a Markdown
|
|
14
|
+
* text's Edit and Done) — its columns of their own widths and gap, and help
|
|
15
|
+
* in a light box with links in its words.
|
|
16
|
+
*
|
|
17
|
+
* The tools show while the group is pointed at or worked in, always while it
|
|
18
|
+
* is folded or maximised, and always where nothing can point (the
|
|
19
|
+
* stylesheet's part). Each is a named button with a tooltip. The heading with
|
|
20
|
+
* its tools is the head part's (section-tools.ts), loaded the first time a
|
|
21
|
+
* page draws one; what is here every page has.
|
|
22
|
+
*/
|
|
23
|
+
const fieldTools = new WeakMap();
|
|
24
|
+
/** A field's own tools, kept by its wrapper for the group round it to take. */
|
|
25
|
+
function keepTools(wrapper, widget) {
|
|
26
|
+
if (widget.tools?.length)
|
|
27
|
+
fieldTools.set(wrapper, widget.tools);
|
|
28
|
+
}
|
|
29
|
+
/** Whether a group draws the work item's heading: its fold control at the end, or a ⤢. */
|
|
30
|
+
const workHeading = (node) => !!node.title && node.style !== 'inline' && (node.foldAt === 'end' || node.maximise === true);
|
|
31
|
+
exports.workHeading = workHeading;
|
|
32
|
+
/**
|
|
33
|
+
* The tools of the one field a group holds, its label out of sight, for the
|
|
34
|
+
* group's heading: the field says what the group is, so its tools are the
|
|
35
|
+
* group's too.
|
|
36
|
+
*/
|
|
37
|
+
function loneFieldTools(node, content) {
|
|
38
|
+
if (!node.title || node.children.length !== 1 || node.children[0].type !== 'field')
|
|
39
|
+
return [];
|
|
40
|
+
const wrapper = content.firstElementChild;
|
|
41
|
+
if (!wrapper || wrapper.getAttribute('data-labels') !== 'hidden')
|
|
42
|
+
return [];
|
|
43
|
+
return fieldTools.get(wrapper) ?? [];
|
|
44
|
+
}
|
|
45
|
+
/** A group's own column widths and the room between them, worn by its grid (from a tablet's width up). */
|
|
46
|
+
function applyTracks(grid, node) {
|
|
47
|
+
if (node.tracks?.length) {
|
|
48
|
+
grid.setAttribute('data-tracks', '');
|
|
49
|
+
// A share of what is left never pushes past it: a long word wraps instead.
|
|
50
|
+
grid.style.setProperty('--fd-track-list', node.tracks.map((track) => (track.endsWith('fr') ? `minmax(0, ${track})` : track)).join(' '));
|
|
51
|
+
}
|
|
52
|
+
if (node.gap !== undefined)
|
|
53
|
+
grid.style.columnGap = `${node.gap}px`;
|
|
54
|
+
}
|
|
55
|
+
/** Words with `[words](address)` links among them, each text part of a text's words. */
|
|
56
|
+
function wordsWithLinks(doc, nodes) {
|
|
57
|
+
return nodes.flatMap((node) => (typeof node === 'string' ? (0, widgets_1.linkedWords)(doc, node) : [node]));
|
|
58
|
+
}
|
|
59
|
+
/** A text's help box: room for an icon at its start, the words in a paragraph beside it. */
|
|
60
|
+
function helpBox(kit, node, words) {
|
|
61
|
+
const icon = node.icon ? (0, widgets_1.drawIcon)(kit.doc, node.icon, kit.icons) : null;
|
|
62
|
+
icon?.classList.add('fd-help-box-icon');
|
|
63
|
+
return kit.el('div', { class: 'fd-help-box fd-text-help', 'data-node': node.id }, ...(icon ? [icon] : []), kit.el('p', {}, ...words));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=section-head.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-head.js","sourceRoot":"","sources":["../../../../../libs/viewer/src/lib/section-head.ts"],"names":[],"mappings":";;;AAoBA,8BAEC;AAUD,wCAKC;AAGD,kCAOC;AAYD,wCAEC;AAGD,0BAIC;AAnED,8CAAuG;AAEvG;;;;;;;;;;;;GAYG;AAEH,MAAM,UAAU,GAAG,IAAI,OAAO,EAA8B,CAAC;AAE7D,+EAA+E;AAC/E,SAAgB,SAAS,CAAC,OAAoB,EAAE,MAAc;IAC5D,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM;QAAE,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAED,0FAA0F;AAC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AAS;QAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;AACrE,CAAC;AAWD,wFAAwF;AACxF,SAAgB,cAAc,CAAC,GAAa,EAAE,KAAwB;IACpE,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAA,qBAAW,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/F,CAAC;AAED,4FAA4F;AAC5F,SAAgB,OAAO,CAAC,GAAY,EAAE,IAAc,EAAE,KAAwB;IAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,kBAAQ,EAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxE,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACxC,OAAO,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,0BAA0B,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;AACxI,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { drawIcon, linkedWords } from '@fieldia/widgets';
|
|
2
|
+
/**
|
|
3
|
+
* A group drawn as a work item draws one: its heading's words, then its tools
|
|
4
|
+
* at the heading's end — ⤢ that shows the group alone over the record's body,
|
|
5
|
+
* ^ and ⌄ that fold it, and the tools of a field it holds alone (a Markdown
|
|
6
|
+
* text's Edit and Done) — its columns of their own widths and gap, and help
|
|
7
|
+
* in a light box with links in its words.
|
|
8
|
+
*
|
|
9
|
+
* The tools show while the group is pointed at or worked in, always while it
|
|
10
|
+
* is folded or maximised, and always where nothing can point (the
|
|
11
|
+
* stylesheet's part). Each is a named button with a tooltip. The heading with
|
|
12
|
+
* its tools is the head part's (section-tools.ts), loaded the first time a
|
|
13
|
+
* page draws one; what is here every page has.
|
|
14
|
+
*/
|
|
15
|
+
const fieldTools = new WeakMap();
|
|
16
|
+
/** A field's own tools, kept by its wrapper for the group round it to take. */
|
|
17
|
+
export function keepTools(wrapper, widget) {
|
|
18
|
+
if (widget.tools?.length)
|
|
19
|
+
fieldTools.set(wrapper, widget.tools);
|
|
20
|
+
}
|
|
21
|
+
/** Whether a group draws the work item's heading: its fold control at the end, or a ⤢. */
|
|
22
|
+
export const workHeading = (node) => !!node.title && node.style !== 'inline' && (node.foldAt === 'end' || node.maximise === true);
|
|
23
|
+
/**
|
|
24
|
+
* The tools of the one field a group holds, its label out of sight, for the
|
|
25
|
+
* group's heading: the field says what the group is, so its tools are the
|
|
26
|
+
* group's too.
|
|
27
|
+
*/
|
|
28
|
+
export function loneFieldTools(node, content) {
|
|
29
|
+
if (!node.title || node.children.length !== 1 || node.children[0].type !== 'field')
|
|
30
|
+
return [];
|
|
31
|
+
const wrapper = content.firstElementChild;
|
|
32
|
+
if (!wrapper || wrapper.getAttribute('data-labels') !== 'hidden')
|
|
33
|
+
return [];
|
|
34
|
+
return fieldTools.get(wrapper) ?? [];
|
|
35
|
+
}
|
|
36
|
+
/** A group's own column widths and the room between them, worn by its grid (from a tablet's width up). */
|
|
37
|
+
export function applyTracks(grid, node) {
|
|
38
|
+
if (node.tracks?.length) {
|
|
39
|
+
grid.setAttribute('data-tracks', '');
|
|
40
|
+
// A share of what is left never pushes past it: a long word wraps instead.
|
|
41
|
+
grid.style.setProperty('--fd-track-list', node.tracks.map((track) => (track.endsWith('fr') ? `minmax(0, ${track})` : track)).join(' '));
|
|
42
|
+
}
|
|
43
|
+
if (node.gap !== undefined)
|
|
44
|
+
grid.style.columnGap = `${node.gap}px`;
|
|
45
|
+
}
|
|
46
|
+
/** Words with `[words](address)` links among them, each text part of a text's words. */
|
|
47
|
+
export function wordsWithLinks(doc, nodes) {
|
|
48
|
+
return nodes.flatMap((node) => (typeof node === 'string' ? linkedWords(doc, node) : [node]));
|
|
49
|
+
}
|
|
50
|
+
/** A text's help box: room for an icon at its start, the words in a paragraph beside it. */
|
|
51
|
+
export function helpBox(kit, node, words) {
|
|
52
|
+
const icon = node.icon ? drawIcon(kit.doc, node.icon, kit.icons) : null;
|
|
53
|
+
icon?.classList.add('fd-help-box-icon');
|
|
54
|
+
return kit.el('div', { class: 'fd-help-box fd-text-help', 'data-node': node.id }, ...(icon ? [icon] : []), kit.el('p', {}, ...words));
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=section-head.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-head.mjs","sourceRoot":"","sources":["../../../../../libs/viewer/src/lib/section-head.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAgD,MAAM,kBAAkB,CAAC;AAEvG;;;;;;;;;;;;GAYG;AAEH,MAAM,UAAU,GAAG,IAAI,OAAO,EAA8B,CAAC;AAE7D,+EAA+E;AAC/E,MAAM,UAAU,SAAS,CAAC,OAAoB,EAAE,MAAc;IAC5D,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM;QAAE,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAED,0FAA0F;AAC1F,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAiB,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,KAAK,IAAI,IA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,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/F,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,OAAO,CAAC,GAAY,EAAE,IAAc,EAAE,KAAwB;IAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxE,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACxC,OAAO,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,0BAA0B,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;AACxI,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SectionNode } from '@fieldia/core';
|
|
2
|
+
import type { HeadKit } from './section-head.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* The heading of a group with tools at its end. `show` folds and unfolds it;
|
|
5
|
+
* the section is marked folded (`fd-section-folded`) and maximised
|
|
6
|
+
* (`data-maximised`) for the stylesheet.
|
|
7
|
+
*/
|
|
8
|
+
export declare function sectionHeading(kit: HeadKit, node: SectionNode, section: HTMLElement, content: HTMLElement, description: HTMLElement | null, own: HTMLElement[]): {
|
|
9
|
+
legend: HTMLLegendElement;
|
|
10
|
+
show: (next: boolean) => void;
|
|
11
|
+
isOpen: () => boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SectionNode } from '@fieldia/core';
|
|
2
|
+
import type { HeadKit } from './section-head';
|
|
3
|
+
/**
|
|
4
|
+
* The heading of a group with tools at its end. `show` folds and unfolds it;
|
|
5
|
+
* the section is marked folded (`fd-section-folded`) and maximised
|
|
6
|
+
* (`data-maximised`) for the stylesheet.
|
|
7
|
+
*/
|
|
8
|
+
export declare function sectionHeading(kit: HeadKit, node: SectionNode, section: HTMLElement, content: HTMLElement, description: HTMLElement | null, own: HTMLElement[]): {
|
|
9
|
+
legend: HTMLLegendElement;
|
|
10
|
+
show: (next: boolean) => void;
|
|
11
|
+
isOpen: () => boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sectionHeading = sectionHeading;
|
|
4
|
+
const widgets_1 = require("@fieldia/widgets");
|
|
5
|
+
const group_styles_1 = require("./group-styles");
|
|
6
|
+
/**
|
|
7
|
+
* A group's heading as a work item draws it, with its tools at its end: ⤢ that
|
|
8
|
+
* shows the group alone over the record's body, ^ and ⌄ that fold it, and the
|
|
9
|
+
* tools of a field it holds alone. The head part's (head-part.ts).
|
|
10
|
+
*/
|
|
11
|
+
const fill = (template, values) => template.replace(/\{(\w+)\}/g, (_, key) => values[key] ?? '');
|
|
12
|
+
/**
|
|
13
|
+
* The heading of a group with tools at its end. `show` folds and unfolds it;
|
|
14
|
+
* the section is marked folded (`fd-section-folded`) and maximised
|
|
15
|
+
* (`data-maximised`) for the stylesheet.
|
|
16
|
+
*/
|
|
17
|
+
function sectionHeading(kit, node, section, content, description, own) {
|
|
18
|
+
const { el, doc, labels } = kit;
|
|
19
|
+
(0, group_styles_1.installGroupStyles)(doc);
|
|
20
|
+
const title = node.title ?? '';
|
|
21
|
+
const tools = el('span', { class: 'fd-section-tools' });
|
|
22
|
+
const legend = el('legend', { class: 'fd-section-title fd-section-head' }, el('span', { class: 'fd-section-name' }, ...kit.withIcon(node.icon, title)), tools);
|
|
23
|
+
section.setAttribute('data-head', '');
|
|
24
|
+
const icon = (name) => (0, widgets_1.drawIcon)(doc, name, kit.icons) ?? '';
|
|
25
|
+
const tool = (name, words) => {
|
|
26
|
+
const button = el('button', { type: 'button', class: 'fd-section-tool', 'data-tool': name, 'aria-label': words, title: words });
|
|
27
|
+
return button;
|
|
28
|
+
};
|
|
29
|
+
// ⤢: the group alone over the record's body, until pressed again or Escape.
|
|
30
|
+
let undo = null;
|
|
31
|
+
const big = node.maximise ? tool('maximise', fill(labels.maximiseNamed, { name: title })) : null;
|
|
32
|
+
const restore = () => {
|
|
33
|
+
undo?.();
|
|
34
|
+
undo = null;
|
|
35
|
+
if (!big)
|
|
36
|
+
return;
|
|
37
|
+
big.setAttribute('aria-pressed', 'false');
|
|
38
|
+
big.replaceChildren(icon('maximise'));
|
|
39
|
+
};
|
|
40
|
+
if (big) {
|
|
41
|
+
big.setAttribute('aria-pressed', 'false');
|
|
42
|
+
big.append(icon('maximise'));
|
|
43
|
+
big.addEventListener('click', () => {
|
|
44
|
+
if (undo)
|
|
45
|
+
return restore();
|
|
46
|
+
undo = maximise(section);
|
|
47
|
+
big.setAttribute('aria-pressed', 'true');
|
|
48
|
+
big.replaceChildren(icon('restore'));
|
|
49
|
+
big.focus();
|
|
50
|
+
});
|
|
51
|
+
section.addEventListener('keydown', (event) => {
|
|
52
|
+
if (event.key !== 'Escape' || !undo || event.defaultPrevented)
|
|
53
|
+
return;
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
event.stopPropagation();
|
|
56
|
+
restore();
|
|
57
|
+
big.focus();
|
|
58
|
+
});
|
|
59
|
+
tools.append(big);
|
|
60
|
+
}
|
|
61
|
+
// ^ and ⌄: the group folded and unfolded from its heading's end.
|
|
62
|
+
let open = node.collapsed !== true;
|
|
63
|
+
const fold = node.collapsible ? tool('fold', '') : null;
|
|
64
|
+
const show = (next) => {
|
|
65
|
+
open = next;
|
|
66
|
+
if (fold) {
|
|
67
|
+
const words = fill(open ? labels.foldNamed : labels.unfoldNamed, { name: title });
|
|
68
|
+
fold.setAttribute('aria-label', words);
|
|
69
|
+
fold.title = words;
|
|
70
|
+
fold.setAttribute('aria-expanded', String(open));
|
|
71
|
+
fold.replaceChildren(icon(open ? 'chevron-up' : 'chevron-down'));
|
|
72
|
+
}
|
|
73
|
+
content.hidden = !open;
|
|
74
|
+
if (description)
|
|
75
|
+
description.hidden = !open;
|
|
76
|
+
section.classList.toggle('fd-section-folded', !open);
|
|
77
|
+
if (!open && undo)
|
|
78
|
+
restore();
|
|
79
|
+
};
|
|
80
|
+
if (fold) {
|
|
81
|
+
fold.setAttribute('aria-controls', content.id);
|
|
82
|
+
fold.addEventListener('click', () => show(!open));
|
|
83
|
+
tools.append(fold);
|
|
84
|
+
}
|
|
85
|
+
// The tools of the field it holds alone, last.
|
|
86
|
+
tools.append(...own);
|
|
87
|
+
show(open);
|
|
88
|
+
return { legend, show, isOpen: () => open };
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The group alone over the record's body: every part beside it, and beside
|
|
92
|
+
* each part round it up to the body, out of sight; the grids round it give it
|
|
93
|
+
* their whole width. Returns how to put it all back.
|
|
94
|
+
*/
|
|
95
|
+
function maximise(section) {
|
|
96
|
+
const host = section.closest('.fd-tabpanel') ?? section.closest('.fd-content') ?? section.closest('.fd-form');
|
|
97
|
+
const unshown = [];
|
|
98
|
+
const grids = [];
|
|
99
|
+
let at = section;
|
|
100
|
+
while (at !== host && at.parentElement) {
|
|
101
|
+
const parent = at.parentElement;
|
|
102
|
+
for (const sibling of [...parent.children]) {
|
|
103
|
+
if (sibling === at || sibling.tagName === 'LEGEND' || sibling.hasAttribute('data-unshown'))
|
|
104
|
+
continue;
|
|
105
|
+
sibling.setAttribute('data-unshown', '');
|
|
106
|
+
unshown.push(sibling);
|
|
107
|
+
}
|
|
108
|
+
if (parent.classList.contains('fd-grid')) {
|
|
109
|
+
parent.setAttribute('data-maximising', '');
|
|
110
|
+
grids.push(parent);
|
|
111
|
+
}
|
|
112
|
+
at = parent;
|
|
113
|
+
}
|
|
114
|
+
section.setAttribute('data-maximised', '');
|
|
115
|
+
section.scrollIntoView?.({ block: 'nearest' });
|
|
116
|
+
return () => {
|
|
117
|
+
for (const part of unshown)
|
|
118
|
+
part.removeAttribute('data-unshown');
|
|
119
|
+
for (const grid of grids)
|
|
120
|
+
grid.removeAttribute('data-maximising');
|
|
121
|
+
section.removeAttribute('data-maximised');
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=section-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-tools.js","sourceRoot":"","sources":["../../../../../libs/viewer/src/lib/section-tools.ts"],"names":[],"mappings":";;AAkBA,wCAqEC;AAtFD,8CAA4C;AAC5C,iDAAoD;AAGpD;;;;GAIG;AAEH,MAAM,IAAI,GAAG,CAAC,QAAgB,EAAE,MAA8B,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,GAAW,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AAEzI;;;;GAIG;AACH,SAAgB,cAAc,CAAC,GAAY,EAAE,IAAiB,EAAE,OAAoB,EAAE,OAAoB,EAAE,WAA+B,EAAE,GAAkB;IAC7J,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAChC,IAAA,iCAAkB,EAAC,GAAG,CAAC,CAAC;IACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,EAAE,CAAC,QAAQ,EAAE,E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