@conalog/ds-svelte 1.0.0-alpha.1 → 1.0.0-alpha.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/SUPPORT.json +22 -1
- package/dist/DashboardWidget.svelte +875 -0
- package/dist/dashboard-widget-drag.mjs +148 -0
- package/dist/display.css +7 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.mjs +1 -0
- package/package.json +2 -2
- package/release-source.json +2 -2
|
@@ -0,0 +1,875 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { tick } from 'svelte';
|
|
3
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
4
|
+
import ActionButton from './ActionButton.svelte';
|
|
5
|
+
import Modal from './Modal.svelte';
|
|
6
|
+
import { attachDashboardWidgetDrag } from './dashboard-widget-drag.mjs';
|
|
7
|
+
import './display.css';
|
|
8
|
+
import './draft.css';
|
|
9
|
+
|
|
10
|
+
const id = $props.id();
|
|
11
|
+
let {
|
|
12
|
+
label, items = $bindable(), selected = $bindable(), editing = false,
|
|
13
|
+
choices = [], moveHandle, more, emphasized = false,
|
|
14
|
+
} = $props();
|
|
15
|
+
|
|
16
|
+
let card = $state();
|
|
17
|
+
let header = $state();
|
|
18
|
+
let dialogOpen = $state(false);
|
|
19
|
+
let editor = $state.raw();
|
|
20
|
+
let announcement = $state('');
|
|
21
|
+
let mountedKey = $state();
|
|
22
|
+
const panelBodies = new SvelteMap();
|
|
23
|
+
let visibleBody;
|
|
24
|
+
let focusOwner;
|
|
25
|
+
let widgets = $derived.by(() => {
|
|
26
|
+
if (typeof label !== 'string' || !label.trim()) throw new TypeError('DashboardWidget requires an accessible name');
|
|
27
|
+
for (const list of [items, choices]) {
|
|
28
|
+
if (!Array.isArray(list) || (list === items && !list.length) ||
|
|
29
|
+
list.some(item => !item || typeof item.id !== 'string' || !item.id.trim() ||
|
|
30
|
+
typeof item.label !== 'string' || !item.label.trim() || typeof item.content !== 'function' ||
|
|
31
|
+
(item.layout !== undefined && !['standard', 'canvas', 'control'].includes(item.layout))) ||
|
|
32
|
+
new Set(list.map(item => item.id)).size !== list.length) {
|
|
33
|
+
throw new TypeError('DashboardWidget requires uniquely identified widgets with titles, content and valid layouts');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return items;
|
|
37
|
+
});
|
|
38
|
+
let active = $derived(widgets.find(item => item.id === selected) ?? widgets[0]);
|
|
39
|
+
// Only the tab strip follows the display order. Moving a live panel can reload embedded content.
|
|
40
|
+
let panels = $derived(widgets.map((item, index) => ({ item, index, key: item.id }))
|
|
41
|
+
.sort((left, right) => left.key < right.key ? -1 : Number(left.key > right.key)));
|
|
42
|
+
let multiple = $derived(widgets.length > 1);
|
|
43
|
+
let layout = $derived(multiple && active.layout === 'control' ? 'standard' : (active.layout ?? 'standard'));
|
|
44
|
+
let available = $derived(choices.filter(choice => !widgets.some(item => item.id === choice.id)));
|
|
45
|
+
let canAdd = $derived(available.length > 0);
|
|
46
|
+
let hasHeader = $derived(layout !== 'control' || editing);
|
|
47
|
+
let dragEnabled = $derived(editing && multiple);
|
|
48
|
+
let canOpenEditor = $derived(editing && editor && (editor.key === undefined
|
|
49
|
+
? canAdd : multiple && widgets.some(item => item.id === editor.key)));
|
|
50
|
+
|
|
51
|
+
$effect(() => {
|
|
52
|
+
select(active.id);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
$effect(() => {
|
|
56
|
+
if (editor && dialogOpen && !canOpenEditor) void closeEditor(editor);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
$effect.pre(() => {
|
|
60
|
+
const key = active.id;
|
|
61
|
+
// Remember nested focus before Svelte replaces a snippet or parks the current body.
|
|
62
|
+
void active.content;
|
|
63
|
+
void active.actions;
|
|
64
|
+
focusOwner?.recordFrame();
|
|
65
|
+
if (visibleBody && visibleBody.key !== key) {
|
|
66
|
+
visibleBody.stopOverlayGuard = keepParkedOverlaysClosed(visibleBody.element);
|
|
67
|
+
focusOwner?.blurWithin(visibleBody.element);
|
|
68
|
+
moveBody(visibleBody, visibleBody.parking);
|
|
69
|
+
visibleBody = undefined;
|
|
70
|
+
}
|
|
71
|
+
// Only mount the next body once the previous controls have left the host form.
|
|
72
|
+
mountedKey = key;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
$effect(() => {
|
|
76
|
+
const body = panelBodies.get(mountedKey);
|
|
77
|
+
if (body && body !== visibleBody) {
|
|
78
|
+
body.stopOverlayGuard?.();
|
|
79
|
+
moveBody(body, body.panel, body.anchor);
|
|
80
|
+
visibleBody = body;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
function rememberBody(element) {
|
|
85
|
+
const owner = element.ownerDocument;
|
|
86
|
+
const panel = element.parentElement;
|
|
87
|
+
const key = panel.dataset.widgetPanel;
|
|
88
|
+
// A connected, separate tree isolates radio groups and keeps snippet updates valid.
|
|
89
|
+
const parkingHost = owner.createElement('div');
|
|
90
|
+
parkingHost.hidden = true;
|
|
91
|
+
parkingHost.inert = true;
|
|
92
|
+
const parking = parkingHost.attachShadow({ mode: 'closed' }).appendChild(owner.createElement('div'));
|
|
93
|
+
panel.append(parkingHost);
|
|
94
|
+
const body = { key, element, panel, anchor: owner.createComment(''), parking };
|
|
95
|
+
element.after(body.anchor);
|
|
96
|
+
panelBodies.set(key, body);
|
|
97
|
+
visibleBody = body;
|
|
98
|
+
return () => {
|
|
99
|
+
if (visibleBody === body) visibleBody = undefined;
|
|
100
|
+
panelBodies.delete(key);
|
|
101
|
+
body.stopOverlayGuard?.();
|
|
102
|
+
body.anchor.remove();
|
|
103
|
+
if (element.parentNode === body.parking) element.remove();
|
|
104
|
+
parkingHost.remove();
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function* elementAndShadowHosts(element) {
|
|
109
|
+
let target = element;
|
|
110
|
+
while (target) {
|
|
111
|
+
yield target;
|
|
112
|
+
const root = target.getRootNode();
|
|
113
|
+
target = root.nodeType === 11 ? root.host : undefined;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function keepParkedOverlaysClosed(body) {
|
|
118
|
+
const listeners = new AbortController();
|
|
119
|
+
const tracked = new WeakSet();
|
|
120
|
+
const contains = element => [...elementAndShadowHosts(element)].some(target => body.contains(target));
|
|
121
|
+
|
|
122
|
+
function dismiss(element) {
|
|
123
|
+
// Native modal dialogs escape ancestor inertness and can still block the document.
|
|
124
|
+
if (element.localName === 'dialog' && element.open) element.close();
|
|
125
|
+
if (element.hidePopover && element.matches(':popover-open')) element.hidePopover();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function visit(element) {
|
|
129
|
+
dismiss(element);
|
|
130
|
+
if (element.shadowRoot) observe(element.shadowRoot);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const changes = new MutationObserver(records => {
|
|
134
|
+
for (const record of records) {
|
|
135
|
+
if (record.type === 'attributes' && contains(record.target)) dismiss(record.target);
|
|
136
|
+
for (const node of record.addedNodes) {
|
|
137
|
+
if (node.nodeType !== 1 || !contains(node)) continue;
|
|
138
|
+
visit(node);
|
|
139
|
+
node.querySelectorAll('*').forEach(visit);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
function observe(tree) {
|
|
145
|
+
if (tracked.has(tree)) return;
|
|
146
|
+
tracked.add(tree);
|
|
147
|
+
changes.observe(tree, { subtree: true, childList: true, attributeFilter: ['open'] });
|
|
148
|
+
tree.addEventListener('beforetoggle', event => {
|
|
149
|
+
if (event.newState === 'open' && event.target.hasAttribute('popover') && contains(event.target)) {
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
}
|
|
152
|
+
}, { capture: true, signal: listeners.signal });
|
|
153
|
+
tree.addEventListener('toggle', event => {
|
|
154
|
+
if (event.newState === 'open' && contains(event.target)) dismiss(event.target);
|
|
155
|
+
}, { capture: true, signal: listeners.signal });
|
|
156
|
+
tree.querySelectorAll('*').forEach(visit);
|
|
157
|
+
}
|
|
158
|
+
observe(body);
|
|
159
|
+
return () => {
|
|
160
|
+
listeners.abort();
|
|
161
|
+
changes.disconnect();
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function moveBody(body, destination, before = null) {
|
|
166
|
+
if (body.element.isConnected && destination.isConnected && typeof destination.moveBefore === 'function') {
|
|
167
|
+
destination.moveBefore(body.element, before);
|
|
168
|
+
} else {
|
|
169
|
+
destination.insertBefore(body.element, before);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function reveal(scroller, item) {
|
|
174
|
+
if (!item) return;
|
|
175
|
+
const { left, right, width } = scroller.getBoundingClientRect();
|
|
176
|
+
if (!width) return;
|
|
177
|
+
const localPixels = scroller.offsetWidth / width;
|
|
178
|
+
const bounds = item.getBoundingClientRect();
|
|
179
|
+
const rtl = getComputedStyle(scroller).direction === 'rtl';
|
|
180
|
+
if (bounds.left < left && (bounds.right <= right || !rtl)) scroller.scrollLeft += (bounds.left - left) * localPixels;
|
|
181
|
+
else if (bounds.right > right) scroller.scrollLeft += (bounds.right - right) * localPixels;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function trackTabStrip(rail) {
|
|
185
|
+
const scroller = rail.parentElement;
|
|
186
|
+
const selectedItem = () => rail.querySelector(':scope > .dw-tab-item[data-active]');
|
|
187
|
+
|
|
188
|
+
function keepTabVisible() {
|
|
189
|
+
if (rail.querySelector('[data-held]') || scroller.matches(':active')) return;
|
|
190
|
+
const focused = scroller.getRootNode().activeElement;
|
|
191
|
+
const target = scroller.contains(focused) ? focused.closest('.dw-tab-item') ?? focused : selectedItem();
|
|
192
|
+
reveal(scroller, target);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function measure() {
|
|
196
|
+
const selected = selectedItem();
|
|
197
|
+
const label = selected?.querySelector('.dw-label');
|
|
198
|
+
const railBounds = rail.getBoundingClientRect();
|
|
199
|
+
if (!label || !railBounds.width) {
|
|
200
|
+
rail.removeAttribute('data-indicator-ready');
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const bounds = label.getBoundingClientRect();
|
|
204
|
+
const deleteBounds = selected.querySelector('.dw-remove')?.getBoundingClientRect();
|
|
205
|
+
const start = deleteBounds?.width ? Math.min(bounds.left, deleteBounds.left) : bounds.left;
|
|
206
|
+
const end = deleteBounds?.width ? Math.max(bounds.right, deleteBounds.right) : bounds.right;
|
|
207
|
+
const localPixels = rail.offsetWidth / railBounds.width;
|
|
208
|
+
rail.style.setProperty('--ink-left', (start - railBounds.left) * localPixels + 'px');
|
|
209
|
+
rail.style.setProperty('--ink-width', (end - start) * localPixels + 'px');
|
|
210
|
+
rail.setAttribute('data-indicator-ready', '');
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
measure();
|
|
214
|
+
keepTabVisible();
|
|
215
|
+
const observer = new ResizeObserver(entries => {
|
|
216
|
+
measure();
|
|
217
|
+
if (entries.some(entry => entry.target === scroller) || !scroller.matches(':hover')) keepTabVisible();
|
|
218
|
+
});
|
|
219
|
+
function observeTabSizes() {
|
|
220
|
+
observer.disconnect();
|
|
221
|
+
for (const element of [scroller, rail, ...rail.querySelectorAll('.dw-tab-item, .dw-label, .dw-remove')]) {
|
|
222
|
+
observer.observe(element);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
observeTabSizes();
|
|
226
|
+
const tabChanges = new MutationObserver(records => {
|
|
227
|
+
if (records.some(record => record.type === 'childList' &&
|
|
228
|
+
(record.target === rail || record.target.matches?.('.dw-tab-item')))) observeTabSizes();
|
|
229
|
+
measure();
|
|
230
|
+
keepTabVisible();
|
|
231
|
+
});
|
|
232
|
+
tabChanges.observe(rail, { childList: true, characterData: true, subtree: true, attributeFilter: ['data-active'] });
|
|
233
|
+
|
|
234
|
+
let frame;
|
|
235
|
+
function onFocusOut(event) {
|
|
236
|
+
if (scroller.contains(event.relatedTarget)) return;
|
|
237
|
+
cancelAnimationFrame(frame);
|
|
238
|
+
frame = requestAnimationFrame(keepTabVisible);
|
|
239
|
+
}
|
|
240
|
+
scroller.addEventListener('focusout', onFocusOut);
|
|
241
|
+
return () => {
|
|
242
|
+
observer.disconnect();
|
|
243
|
+
tabChanges.disconnect();
|
|
244
|
+
scroller.removeEventListener('focusout', onFocusOut);
|
|
245
|
+
cancelAnimationFrame(frame);
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function fitActionLabels(actions) {
|
|
250
|
+
// Some engines ignore an intrinsic minimum when a button has a fixed height.
|
|
251
|
+
const resize = new ResizeObserver(entries => {
|
|
252
|
+
for (const { target, borderBoxSize, contentRect } of entries) {
|
|
253
|
+
const button = target.closest('[data-ds-button="action-button"]');
|
|
254
|
+
const height = borderBoxSize?.[0]?.blockSize ?? contentRect.height;
|
|
255
|
+
button?.style.setProperty('--dw-action-label-height', height + 'px');
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
const observeLabels = () => {
|
|
259
|
+
resize.disconnect();
|
|
260
|
+
for (const label of actions.querySelectorAll(':scope > [data-ds-button="action-button"] [data-ds-label]')) {
|
|
261
|
+
resize.observe(label);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
observeLabels();
|
|
265
|
+
const children = new MutationObserver(observeLabels);
|
|
266
|
+
children.observe(actions, { childList: true });
|
|
267
|
+
return () => {
|
|
268
|
+
resize.disconnect();
|
|
269
|
+
children.disconnect();
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function rememberKeyboardFocus(event) {
|
|
274
|
+
if (event.target.matches(':focus-visible')) event.currentTarget.setAttribute('data-keyboard-focus', '');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function clearKeyboardFocus(event) {
|
|
278
|
+
if (!event.currentTarget.contains(event.relatedTarget)) event.currentTarget.removeAttribute('data-keyboard-focus');
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
async function focusTab(key) {
|
|
282
|
+
await tick();
|
|
283
|
+
focusRenderedTab(key);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function focusRenderedTab(key) {
|
|
287
|
+
if (!card?.isConnected) return;
|
|
288
|
+
const currentHeader = header?.isConnected ? header : undefined;
|
|
289
|
+
const tab = [...(currentHeader?.querySelectorAll('[data-widget-tab]') ?? [])]
|
|
290
|
+
.find(button => button.dataset.widgetTab === key);
|
|
291
|
+
const target = tab ?? currentHeader?.querySelector('[data-widget-title]') ?? card;
|
|
292
|
+
target.focus({ preventScroll: true });
|
|
293
|
+
const viewport = currentHeader?.parentElement;
|
|
294
|
+
if (viewport) {
|
|
295
|
+
const bounds = viewport.getBoundingClientRect();
|
|
296
|
+
const visible = target.getBoundingClientRect();
|
|
297
|
+
const localPixels = bounds.height ? viewport.offsetHeight / bounds.height : 0;
|
|
298
|
+
if (visible.top < bounds.top) viewport.scrollTop += (visible.top - bounds.top) * localPixels;
|
|
299
|
+
else if (visible.bottom > bounds.bottom) viewport.scrollTop += (visible.bottom - bounds.bottom) * localPixels;
|
|
300
|
+
}
|
|
301
|
+
if (tab) reveal(tab.closest('.dw-scroll'), tab.parentElement);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function keepOwnedFocus(surface) {
|
|
305
|
+
const document = surface.ownerDocument;
|
|
306
|
+
const view = document.defaultView;
|
|
307
|
+
function currentFocus() {
|
|
308
|
+
let target = surface.getRootNode().activeElement;
|
|
309
|
+
while (target?.shadowRoot?.activeElement) target = target.shadowRoot.activeElement;
|
|
310
|
+
return target;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function focusBoundary(element) {
|
|
314
|
+
let childCard;
|
|
315
|
+
for (const target of elementAndShadowHosts(element)) {
|
|
316
|
+
let owner = target.closest('.dw-card');
|
|
317
|
+
while (owner && owner !== surface) {
|
|
318
|
+
childCard = owner;
|
|
319
|
+
owner = owner.parentElement?.closest('.dw-card');
|
|
320
|
+
}
|
|
321
|
+
if (owner === surface) return childCard ?? element;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
let previous;
|
|
326
|
+
let nestedListeners;
|
|
327
|
+
function unavailable(element) {
|
|
328
|
+
if (!focusBoundary(element) || element.matches(':disabled')) return true;
|
|
329
|
+
for (const target of elementAndShadowHosts(element)) {
|
|
330
|
+
if (target.closest('[hidden], [inert]')) return true;
|
|
331
|
+
}
|
|
332
|
+
// A closed details element can leave layout boxes for its hidden descendants.
|
|
333
|
+
return element.checkVisibility ? !element.checkVisibility({ visibilityProperty: true })
|
|
334
|
+
: !element.getClientRects().length || view.getComputedStyle(element).visibility !== 'visible';
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
async function restore(lost) {
|
|
338
|
+
stop();
|
|
339
|
+
await tick();
|
|
340
|
+
if (surface !== card || !surface.isConnected || editor) return;
|
|
341
|
+
const focused = currentFocus() ?? document.activeElement;
|
|
342
|
+
if ((focused === document.body || focusBoundary(focused) === lost) && unavailable(lost)) {
|
|
343
|
+
focusRenderedTab(active.id);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const observer = new MutationObserver(records => {
|
|
348
|
+
if (!previous) return;
|
|
349
|
+
const changedVisibility = records.some(record => record.type === 'attributes' &&
|
|
350
|
+
[...elementAndShadowHosts(previous)].some(target => record.target.contains(target)));
|
|
351
|
+
if ((!focusBoundary(previous) || changedVisibility) && unavailable(previous)) void restore(previous);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
function stop() {
|
|
355
|
+
previous = undefined;
|
|
356
|
+
observer.disconnect();
|
|
357
|
+
nestedListeners?.abort();
|
|
358
|
+
surface.removeAttribute('data-keyboard-focus-within');
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function track(target) {
|
|
362
|
+
const boundary = focusBoundary(target);
|
|
363
|
+
if (previous !== boundary) stop();
|
|
364
|
+
if (!boundary || boundary === surface) return;
|
|
365
|
+
surface.toggleAttribute('data-keyboard-focus-within', target.matches(':focus-visible'));
|
|
366
|
+
if (previous === boundary) return;
|
|
367
|
+
previous = boundary;
|
|
368
|
+
const changes = {
|
|
369
|
+
subtree: true, childList: true, attributeFilter: ['hidden', 'disabled', 'inert', 'open', 'class', 'style'],
|
|
370
|
+
};
|
|
371
|
+
observer.observe(surface, changes);
|
|
372
|
+
const root = surface.getRootNode();
|
|
373
|
+
nestedListeners = new AbortController();
|
|
374
|
+
const options = { capture: true, signal: nestedListeners.signal };
|
|
375
|
+
for (let tree = boundary.getRootNode(); tree !== root; tree = tree.host.getRootNode()) {
|
|
376
|
+
observer.observe(tree, changes);
|
|
377
|
+
tree.addEventListener('focusin', onFocusIn, options);
|
|
378
|
+
tree.addEventListener('focusout', onFocusOut, options);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function trackFocusedFrame() {
|
|
383
|
+
const focused = currentFocus();
|
|
384
|
+
const boundary = focusBoundary(focused);
|
|
385
|
+
if (focused?.localName === 'iframe' && boundary && boundary !== previous && document.hasFocus()) {
|
|
386
|
+
// Some engines update activeElement after the blur handler and the host update.
|
|
387
|
+
if (unavailable(boundary)) void restore(boundary);
|
|
388
|
+
else track(focused);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const owner = {
|
|
393
|
+
recordFrame: trackFocusedFrame,
|
|
394
|
+
blurWithin(container) {
|
|
395
|
+
const focused = currentFocus();
|
|
396
|
+
if ([...elementAndShadowHosts(focused)].some(target => container.contains(target))) focused.blur();
|
|
397
|
+
},
|
|
398
|
+
};
|
|
399
|
+
focusOwner = owner;
|
|
400
|
+
|
|
401
|
+
const listeners = new AbortController();
|
|
402
|
+
const options = { capture: true, signal: listeners.signal };
|
|
403
|
+
let frame;
|
|
404
|
+
view.addEventListener('blur', () => {
|
|
405
|
+
trackFocusedFrame();
|
|
406
|
+
queueMicrotask(() => {
|
|
407
|
+
if (!listeners.signal.aborted) trackFocusedFrame();
|
|
408
|
+
});
|
|
409
|
+
view.cancelAnimationFrame(frame);
|
|
410
|
+
frame = view.requestAnimationFrame(trackFocusedFrame);
|
|
411
|
+
}, { signal: listeners.signal });
|
|
412
|
+
function onFocusIn(event) {
|
|
413
|
+
track(event.composedPath()[0]);
|
|
414
|
+
}
|
|
415
|
+
function onFocusOut(event) {
|
|
416
|
+
const target = focusBoundary(event.composedPath()[0]);
|
|
417
|
+
if (!target || target !== previous) return;
|
|
418
|
+
const { relatedTarget } = event;
|
|
419
|
+
if (relatedTarget && relatedTarget !== document.body) {
|
|
420
|
+
stop();
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
// A browser can dispatch focusout before removing or hiding the target.
|
|
424
|
+
queueMicrotask(() => {
|
|
425
|
+
if (previous !== target || focusBoundary(currentFocus()) === target) return;
|
|
426
|
+
if (unavailable(target)) void restore(target);
|
|
427
|
+
else stop();
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
surface.addEventListener('focusin', onFocusIn, options);
|
|
431
|
+
surface.addEventListener('focusout', onFocusOut, options);
|
|
432
|
+
track(currentFocus());
|
|
433
|
+
return () => {
|
|
434
|
+
if (focusOwner === owner) focusOwner = undefined;
|
|
435
|
+
stop();
|
|
436
|
+
view.cancelAnimationFrame(frame);
|
|
437
|
+
listeners.abort();
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function select(key) {
|
|
442
|
+
if (selected !== key) selected = key;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
async function reorder(key, destination) {
|
|
446
|
+
const source = widgets.findIndex(item => item.id === key);
|
|
447
|
+
if (!dragEnabled || source < 0 || destination < 0 || destination >= widgets.length || source === destination) return;
|
|
448
|
+
const reordered = [...widgets];
|
|
449
|
+
const [item] = reordered.splice(source, 1);
|
|
450
|
+
reordered.splice(destination, 0, item);
|
|
451
|
+
select(active.id);
|
|
452
|
+
items = reordered;
|
|
453
|
+
await focusTab(key);
|
|
454
|
+
announcement = `${item.label} 탭을 ${reordered.length}개 중 ${destination + 1}번째로 이동했습니다.`;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function navigate(event, index) {
|
|
458
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey) return;
|
|
459
|
+
const rtl = getComputedStyle(event.currentTarget).direction === 'rtl';
|
|
460
|
+
const step = event.key === 'ArrowRight' ? (rtl ? -1 : 1) : (rtl ? 1 : -1);
|
|
461
|
+
const arrows = event.key === 'ArrowLeft' || event.key === 'ArrowRight';
|
|
462
|
+
if (event.altKey) {
|
|
463
|
+
if (!arrows || !dragEnabled) return;
|
|
464
|
+
event.preventDefault();
|
|
465
|
+
void reorder(widgets[index].id, index + step);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
if (event.key === 'Delete' && dragEnabled) {
|
|
469
|
+
event.preventDefault();
|
|
470
|
+
openEditor(widgets[index].id, event.currentTarget);
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
if (!arrows && event.key !== 'Home' && event.key !== 'End') return;
|
|
474
|
+
event.preventDefault();
|
|
475
|
+
const next = arrows ? (index + step + widgets.length) % widgets.length
|
|
476
|
+
: (event.key === 'Home' ? 0 : widgets.length - 1);
|
|
477
|
+
select(widgets[next].id);
|
|
478
|
+
void focusTab(widgets[next].id);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function openEditor(key, trigger) {
|
|
482
|
+
editor = { key, trigger, completed: false };
|
|
483
|
+
dialogOpen = true;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
async function closeEditor(request) {
|
|
487
|
+
if (editor !== request) return;
|
|
488
|
+
editor = undefined;
|
|
489
|
+
dialogOpen = false;
|
|
490
|
+
if (request.completed) return;
|
|
491
|
+
await tick();
|
|
492
|
+
if (!card?.isConnected || editor) return;
|
|
493
|
+
const document = card.ownerDocument;
|
|
494
|
+
const focused = card.getRootNode().activeElement ?? document.activeElement;
|
|
495
|
+
if (focused === document.body || focused === card ||
|
|
496
|
+
(request.key !== undefined && focused === request.trigger)) {
|
|
497
|
+
await focusTab(widgets.some(item => item.id === request.key) ? request.key : active.id);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
async function addWidget(request, item) {
|
|
502
|
+
if (editor !== request || !editing || !available.some(choice => choice.id === item.id)) return;
|
|
503
|
+
request.completed = true;
|
|
504
|
+
dialogOpen = false;
|
|
505
|
+
items = [...widgets, item];
|
|
506
|
+
selected = item.id;
|
|
507
|
+
await focusTab(item.id);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
async function deleteWidget(request, target) {
|
|
511
|
+
if (editor !== request || !dragEnabled || !target) return;
|
|
512
|
+
const index = widgets.indexOf(target);
|
|
513
|
+
if (index < 0) return;
|
|
514
|
+
const next = target === active ? (widgets[index + 1] ?? widgets[index - 1]) : active;
|
|
515
|
+
request.completed = true;
|
|
516
|
+
dialogOpen = false;
|
|
517
|
+
items = widgets.filter(item => item !== target);
|
|
518
|
+
selected = next.id;
|
|
519
|
+
await focusTab(next.id);
|
|
520
|
+
}
|
|
521
|
+
</script>
|
|
522
|
+
|
|
523
|
+
<section class="dw-card" data-ds-component="dashboard-widget" aria-label={label} tabindex="-1" bind:this={card} {@attach keepOwnedFocus}
|
|
524
|
+
data-ds-display={`dashboard-widget-${layout}-${editing ? 'edit' : 'view'}`}
|
|
525
|
+
data-layout={layout} data-editing={editing || undefined} data-emphasized={editing && emphasized || undefined}>
|
|
526
|
+
<div class="dw-content">
|
|
527
|
+
{#if hasHeader}
|
|
528
|
+
<header class="dw-header" data-multiple={multiple || undefined} bind:this={header}>
|
|
529
|
+
{#if editing}
|
|
530
|
+
<div class="dw-move">{@render moveHandle?.()}</div>
|
|
531
|
+
{/if}
|
|
532
|
+
<div class="dw-header-content">
|
|
533
|
+
<div class="dw-scroll" {@attach scroller => dragEnabled ? attachDashboardWidgetDrag(scroller, reorder) : undefined}>
|
|
534
|
+
{#if multiple}
|
|
535
|
+
<div class="dw-rail" role="tablist" aria-label={label} {@attach trackTabStrip}>
|
|
536
|
+
{#each widgets as item, index (item.id)}
|
|
537
|
+
<div class="dw-tab-item" role="presentation" data-active={item === active || undefined}
|
|
538
|
+
onfocusin={rememberKeyboardFocus} onfocusout={clearKeyboardFocus}>
|
|
539
|
+
<button class="dw-tab" type="button" role="tab" data-widget-tab={item.id}
|
|
540
|
+
id={`${id}-tab-${index}`} aria-controls={`${id}-panel-${index}`}
|
|
541
|
+
aria-selected={item === active} tabindex={item === active ? 0 : -1} title={item.label}
|
|
542
|
+
onclick={() => select(item.id)} onkeydown={event => navigate(event, index)}>
|
|
543
|
+
<span class="dw-label">{item.label}</span>
|
|
544
|
+
</button>
|
|
545
|
+
{#if editing}
|
|
546
|
+
<button class="dw-edit-button dw-remove" type="button" aria-label={`${item.label} 탭 삭제`}
|
|
547
|
+
aria-haspopup="dialog" tabindex={item === active ? 0 : -1}
|
|
548
|
+
onclick={event => openEditor(item.id, event.currentTarget)}>
|
|
549
|
+
<span class="dw-glyph" aria-hidden="true">×</span>
|
|
550
|
+
</button>
|
|
551
|
+
{/if}
|
|
552
|
+
</div>
|
|
553
|
+
{/each}
|
|
554
|
+
</div>
|
|
555
|
+
{:else}
|
|
556
|
+
<h2 class="dw-title dw-label" data-widget-title tabindex="-1" title={active.label}>{active.label}</h2>
|
|
557
|
+
{/if}
|
|
558
|
+
{#if editing}
|
|
559
|
+
<button class="dw-edit-button dw-add" type="button" aria-label="위젯 탭 추가"
|
|
560
|
+
aria-haspopup="dialog" disabled={!canAdd} onclick={event => openEditor(undefined, event.currentTarget)}>
|
|
561
|
+
<span class="dw-glyph" aria-hidden="true">+</span>
|
|
562
|
+
</button>
|
|
563
|
+
{/if}
|
|
564
|
+
</div>
|
|
565
|
+
{#if active.actions}
|
|
566
|
+
<div class="dw-actions" {@attach fitActionLabels}>{@render active.actions()}</div>
|
|
567
|
+
{/if}
|
|
568
|
+
</div>
|
|
569
|
+
{#if editing}
|
|
570
|
+
<div class="dw-more">{@render more?.()}</div>
|
|
571
|
+
{/if}
|
|
572
|
+
</header>
|
|
573
|
+
{/if}
|
|
574
|
+
{#each panels as { item, index, key } (key)}
|
|
575
|
+
{@const isActive = key === active.id}
|
|
576
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex (여러 탭이 있을 때 선택된 tabpanel에만 탭 정지점을 둡니다.) -->
|
|
577
|
+
<div class="dw-panel" data-widget-panel={key} hidden={!isActive} role={multiple ? 'tabpanel' : undefined}
|
|
578
|
+
id={`${id}-panel-${index}`} aria-labelledby={multiple ? `${id}-tab-${index}` : undefined}
|
|
579
|
+
tabindex={multiple && isActive ? 0 : undefined}>
|
|
580
|
+
{#if key === (mountedKey ?? active.id) || panelBodies.has(key)}
|
|
581
|
+
<div class="dw-body" {@attach rememberBody}>{@render item.content()}</div>
|
|
582
|
+
{/if}
|
|
583
|
+
</div>
|
|
584
|
+
{/each}
|
|
585
|
+
</div>
|
|
586
|
+
<span class="dw-announcement" aria-live="polite">{announcement}</span>
|
|
587
|
+
</section>
|
|
588
|
+
|
|
589
|
+
{#each editor ? [editor] : [] as request (request)}
|
|
590
|
+
{@const removing = widgets.find(item => item.id === request.key)}
|
|
591
|
+
<Modal title={removing ? `‘${removing.label}’ 탭을 삭제할까요?` : '위젯 탭 추가'}
|
|
592
|
+
open={dialogOpen && Boolean(canOpenEditor)}
|
|
593
|
+
onclose={() => closeEditor(request)}>
|
|
594
|
+
{#if removing}
|
|
595
|
+
<p>이 카드에서 선택한 위젯 탭을 삭제합니다.</p>
|
|
596
|
+
{:else}
|
|
597
|
+
<ul class="dw-choices">
|
|
598
|
+
{#each available as item (item.id)}
|
|
599
|
+
<li><ActionButton label={item.label} color="neutral" variant="outline" onclick={() => addWidget(request, item)} /></li>
|
|
600
|
+
{/each}
|
|
601
|
+
</ul>
|
|
602
|
+
{/if}
|
|
603
|
+
{#snippet footer()}
|
|
604
|
+
<div class="dw-dialog-actions">
|
|
605
|
+
<!-- svelte-ignore a11y_autofocus (삭제 확인을 열 때 취소에 먼저 포커스합니다.) -->
|
|
606
|
+
<button class="dw-cancel" type="button" autofocus onclick={() => dialogOpen = false}>취소</button>
|
|
607
|
+
{#if removing}
|
|
608
|
+
<ActionButton label="삭제" color="critical" onclick={() => deleteWidget(request, removing)} />
|
|
609
|
+
{/if}
|
|
610
|
+
</div>
|
|
611
|
+
{/snippet}
|
|
612
|
+
</Modal>
|
|
613
|
+
{/each}
|
|
614
|
+
|
|
615
|
+
<style>
|
|
616
|
+
.dw-card {
|
|
617
|
+
position: relative;
|
|
618
|
+
display: flex;
|
|
619
|
+
flex-direction: column;
|
|
620
|
+
box-sizing: border-box;
|
|
621
|
+
block-size: 100%;
|
|
622
|
+
min-inline-size: 0;
|
|
623
|
+
background: var(--ds-display-container-background-color);
|
|
624
|
+
border-radius: var(--ds-display-container-border-radius);
|
|
625
|
+
overflow: clip;
|
|
626
|
+
}
|
|
627
|
+
.dw-card::after {
|
|
628
|
+
content: '';
|
|
629
|
+
position: absolute;
|
|
630
|
+
inset: 0;
|
|
631
|
+
border: var(--ds-display-container-border-width) solid var(--ds-display-container-border-color);
|
|
632
|
+
border-radius: inherit;
|
|
633
|
+
pointer-events: none;
|
|
634
|
+
}
|
|
635
|
+
.dw-card[data-editing]:is([data-emphasized], :global([data-keyboard-focus-within]), :has(:focus-visible)) {
|
|
636
|
+
outline: var(--ds-display-container-outline-width) solid var(--ds-display-container-outline-color);
|
|
637
|
+
}
|
|
638
|
+
.dw-card[data-editing]:is([data-emphasized], :global([data-keyboard-focus-within]), :has(:focus-visible))::after {
|
|
639
|
+
border-color: transparent;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
.dw-header {
|
|
643
|
+
--tool-size: 0px;
|
|
644
|
+
flex: none;
|
|
645
|
+
display: grid;
|
|
646
|
+
container-type: inline-size;
|
|
647
|
+
grid-template-columns: var(--ds-display-header-padding-inline) var(--tool-size) minmax(0, 1fr)
|
|
648
|
+
var(--tool-size) var(--ds-display-header-padding-inline);
|
|
649
|
+
grid-template-rows: minmax(var(--ds-display-header-min-height), auto);
|
|
650
|
+
align-items: start;
|
|
651
|
+
padding-block: var(--ds-display-header-padding-block);
|
|
652
|
+
}
|
|
653
|
+
.dw-card[data-editing] > .dw-content > .dw-header { --tool-size: var(--ds-display-card-tool-width); }
|
|
654
|
+
.dw-card[data-layout="control"] > .dw-content > .dw-header {
|
|
655
|
+
padding-block-end: 0;
|
|
656
|
+
}
|
|
657
|
+
.dw-move, .dw-more {
|
|
658
|
+
grid-row: 1;
|
|
659
|
+
display: grid;
|
|
660
|
+
place-items: center;
|
|
661
|
+
block-size: var(--ds-display-card-tool-height);
|
|
662
|
+
}
|
|
663
|
+
.dw-move { grid-column: 2; }
|
|
664
|
+
.dw-more { grid-column: 4; }
|
|
665
|
+
.dw-header-content {
|
|
666
|
+
grid-area: 1 / 3;
|
|
667
|
+
display: flex;
|
|
668
|
+
flex-wrap: wrap;
|
|
669
|
+
align-items: center;
|
|
670
|
+
column-gap: var(--ds-display-header-column-gap);
|
|
671
|
+
row-gap: var(--ds-display-header-padding-block);
|
|
672
|
+
}
|
|
673
|
+
.dw-header:not([data-multiple]) .dw-header-content {
|
|
674
|
+
/* Measure against the full header so wrapping is stable throughout the edit transition. */
|
|
675
|
+
--dw-edit-content-width: max(0px, calc(100cqi - 2 * (var(--ds-display-card-tool-width)
|
|
676
|
+
+ var(--ds-display-header-padding-block))));
|
|
677
|
+
}
|
|
678
|
+
.dw-header[data-multiple] .dw-header-content { display: contents; }
|
|
679
|
+
.dw-scroll {
|
|
680
|
+
flex: 1 1 clamp(0px, calc(100% - var(--dw-edit-content-width, 100%)
|
|
681
|
+
+ 2 * var(--ds-display-edit-button-width)), 100%);
|
|
682
|
+
display: flex;
|
|
683
|
+
align-items: center;
|
|
684
|
+
min-inline-size: 0;
|
|
685
|
+
min-block-size: var(--ds-display-header-min-height);
|
|
686
|
+
overflow-x: auto;
|
|
687
|
+
scrollbar-width: none;
|
|
688
|
+
container-type: inline-size;
|
|
689
|
+
}
|
|
690
|
+
.dw-header[data-multiple] .dw-scroll { grid-area: 1 / 3; }
|
|
691
|
+
.dw-rail {
|
|
692
|
+
position: relative;
|
|
693
|
+
display: flex;
|
|
694
|
+
flex: none;
|
|
695
|
+
align-items: center;
|
|
696
|
+
padding-inline-start: var(--ds-display-container-border-width);
|
|
697
|
+
}
|
|
698
|
+
.dw-tab-item { position: relative; display: flex; align-items: center; flex: none; }
|
|
699
|
+
.dw-tab-item:has(> .dw-remove) {
|
|
700
|
+
padding-inline-end: calc(var(--ds-display-edit-button-width) + var(--ds-display-tab-padding-inline));
|
|
701
|
+
}
|
|
702
|
+
.dw-label {
|
|
703
|
+
display: block;
|
|
704
|
+
overflow: hidden;
|
|
705
|
+
white-space: nowrap;
|
|
706
|
+
text-overflow: ellipsis;
|
|
707
|
+
}
|
|
708
|
+
.dw-title, .dw-tab {
|
|
709
|
+
color: var(--ds-display-title-color);
|
|
710
|
+
font: var(--ds-display-title-font-weight) var(--ds-display-title-font-size)/var(--ds-display-title-line-height) var(--ds-display-title-font-family);
|
|
711
|
+
letter-spacing: var(--ds-display-title-letter-spacing);
|
|
712
|
+
}
|
|
713
|
+
.dw-title { margin: 0; min-inline-size: 0; }
|
|
714
|
+
.dw-tab, .dw-edit-button {
|
|
715
|
+
border: 0;
|
|
716
|
+
background: transparent;
|
|
717
|
+
cursor: pointer;
|
|
718
|
+
}
|
|
719
|
+
.dw-tab {
|
|
720
|
+
min-inline-size: 0;
|
|
721
|
+
max-inline-size: max(48px, calc(100cqi - 2 * var(--ds-display-edit-button-width)));
|
|
722
|
+
block-size: var(--ds-display-tab-height);
|
|
723
|
+
padding: 0 var(--ds-display-tab-padding-inline);
|
|
724
|
+
border-radius: var(--ds-display-edit-button-border-radius);
|
|
725
|
+
color: var(--ds-display-inactive-tab-color);
|
|
726
|
+
}
|
|
727
|
+
.dw-tab:has(+ .dw-remove) { padding-inline-end: 0; }
|
|
728
|
+
.dw-tab:is([aria-selected="true"], :hover) { color: var(--ds-display-tab-color); }
|
|
729
|
+
.dw-tab-item[data-active]::before {
|
|
730
|
+
content: '';
|
|
731
|
+
position: absolute;
|
|
732
|
+
inset: auto var(--ds-display-tab-padding-inline) 0;
|
|
733
|
+
border-block-end: var(--ds-display-tab-border-width) solid var(--ds-display-tab-border-color);
|
|
734
|
+
pointer-events: none;
|
|
735
|
+
}
|
|
736
|
+
.dw-rail:global([data-indicator-ready]) .dw-tab-item[data-active]::before { content: none; }
|
|
737
|
+
.dw-rail:global([data-indicator-ready])::before {
|
|
738
|
+
content: '';
|
|
739
|
+
position: absolute;
|
|
740
|
+
inset-block-end: 0;
|
|
741
|
+
left: var(--ink-left);
|
|
742
|
+
inline-size: var(--ink-width);
|
|
743
|
+
border-block-end: var(--ds-display-tab-border-width) solid var(--ds-display-tab-border-color);
|
|
744
|
+
pointer-events: none;
|
|
745
|
+
z-index: 1;
|
|
746
|
+
}
|
|
747
|
+
[data-editing] .dw-tab {
|
|
748
|
+
user-select: none;
|
|
749
|
+
-webkit-touch-callout: none;
|
|
750
|
+
touch-action: pan-y pinch-zoom;
|
|
751
|
+
}
|
|
752
|
+
.dw-tab-item:global([data-held]) {
|
|
753
|
+
border-radius: var(--ds-display-edit-button-border-radius);
|
|
754
|
+
background: var(--ds-display-tab-background-color);
|
|
755
|
+
}
|
|
756
|
+
.dw-tab-item:global([data-held]) .dw-tab { cursor: grabbing; }
|
|
757
|
+
.dw-tab-item:global([data-drop])::after {
|
|
758
|
+
content: '';
|
|
759
|
+
position: absolute;
|
|
760
|
+
inset-block: var(--ds-display-header-column-gap);
|
|
761
|
+
border-inline-start: var(--ds-display-drop-indicator-border-width) solid var(--ds-display-drop-indicator-border-color);
|
|
762
|
+
pointer-events: none;
|
|
763
|
+
}
|
|
764
|
+
.dw-tab-item:global([data-drop="before"])::after { inset-inline-start: 0; }
|
|
765
|
+
.dw-tab-item:global([data-drop="after"])::after { inset-inline-end: 0; }
|
|
766
|
+
.dw-edit-button {
|
|
767
|
+
display: inline-grid;
|
|
768
|
+
place-items: center;
|
|
769
|
+
flex: none;
|
|
770
|
+
inline-size: var(--ds-display-edit-button-width);
|
|
771
|
+
block-size: var(--ds-display-edit-button-height);
|
|
772
|
+
padding: 0;
|
|
773
|
+
color: var(--ds-display-edit-button-color);
|
|
774
|
+
border-radius: var(--ds-display-edit-button-border-radius);
|
|
775
|
+
}
|
|
776
|
+
.dw-edit-button:is(:hover, :focus-visible) { background: var(--ds-display-edit-button-background-color); }
|
|
777
|
+
.dw-edit-button:disabled { color: var(--ds-draft-fg-disabled); cursor: default; background: transparent; }
|
|
778
|
+
.dw-glyph { font: 16px/1 system-ui, sans-serif; }
|
|
779
|
+
.dw-remove {
|
|
780
|
+
position: absolute;
|
|
781
|
+
inset-inline-end: var(--ds-display-tab-padding-inline);
|
|
782
|
+
max-inline-size: var(--remove-width, 0px);
|
|
783
|
+
visibility: var(--remove-visibility, hidden);
|
|
784
|
+
overflow: clip;
|
|
785
|
+
}
|
|
786
|
+
.dw-rail:not(:has(:global([data-held]))) .dw-tab-item:is(:hover, :global([data-keyboard-focus]), :has(:focus-visible)) {
|
|
787
|
+
--remove-width: var(--ds-display-edit-button-width);
|
|
788
|
+
--remove-visibility: visible;
|
|
789
|
+
}
|
|
790
|
+
@media (hover: none) {
|
|
791
|
+
.dw-rail:not(:has(:global([data-held]))) .dw-tab-item[data-active] {
|
|
792
|
+
--remove-width: var(--ds-display-edit-button-width);
|
|
793
|
+
--remove-visibility: visible;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
.dw-tab:focus-visible, .dw-edit-button:focus-visible {
|
|
797
|
+
outline: var(--ds-display-tab-outline-width) solid var(--ds-display-tab-outline-color);
|
|
798
|
+
outline-offset: calc(-1 * var(--ds-display-tab-outline-width));
|
|
799
|
+
}
|
|
800
|
+
.dw-actions {
|
|
801
|
+
display: flex;
|
|
802
|
+
flex: 0 0 auto;
|
|
803
|
+
flex-wrap: wrap;
|
|
804
|
+
justify-content: end;
|
|
805
|
+
align-items: center;
|
|
806
|
+
max-inline-size: min(100%, var(--dw-edit-content-width, 100%));
|
|
807
|
+
overflow-wrap: anywhere;
|
|
808
|
+
gap: var(--ds-display-header-column-gap);
|
|
809
|
+
margin-inline-start: auto;
|
|
810
|
+
}
|
|
811
|
+
.dw-actions > :global([data-ds-button="action-button"]) {
|
|
812
|
+
min-block-size: var(--dw-action-label-height, max-content);
|
|
813
|
+
max-inline-size: 100%;
|
|
814
|
+
}
|
|
815
|
+
.dw-header[data-multiple] .dw-actions {
|
|
816
|
+
grid-area: 2 / 1 / auto / -1;
|
|
817
|
+
margin-inline: var(--ds-display-action-row-padding-inline);
|
|
818
|
+
margin-block-start: var(--ds-display-header-padding-block);
|
|
819
|
+
}
|
|
820
|
+
.dw-content {
|
|
821
|
+
display: flex;
|
|
822
|
+
flex: 1 1 auto;
|
|
823
|
+
flex-direction: column;
|
|
824
|
+
min-block-size: 0;
|
|
825
|
+
overflow: auto;
|
|
826
|
+
}
|
|
827
|
+
.dw-panel {
|
|
828
|
+
flex: 1 0 auto;
|
|
829
|
+
min-block-size: 0;
|
|
830
|
+
}
|
|
831
|
+
.dw-panel:focus-visible {
|
|
832
|
+
outline: var(--ds-display-tab-outline-width) solid var(--ds-display-tab-outline-color);
|
|
833
|
+
outline-offset: calc(-1 * var(--ds-display-tab-outline-width));
|
|
834
|
+
}
|
|
835
|
+
.dw-body {
|
|
836
|
+
box-sizing: border-box;
|
|
837
|
+
display: flex;
|
|
838
|
+
flex-direction: column;
|
|
839
|
+
min-block-size: 100%;
|
|
840
|
+
padding: var(--ds-display-body-padding-block-start) var(--ds-display-body-padding-inline) var(--ds-display-body-padding-block-end);
|
|
841
|
+
}
|
|
842
|
+
.dw-card[data-layout="canvas"] > .dw-content > .dw-panel > .dw-body { block-size: 100%; }
|
|
843
|
+
.dw-card[data-layout="control"] > .dw-content > .dw-panel > .dw-body {
|
|
844
|
+
justify-content: center;
|
|
845
|
+
}
|
|
846
|
+
.dw-card[data-layout="control"][data-editing] > .dw-content > .dw-panel > .dw-body {
|
|
847
|
+
padding-block-start: max(0px, calc(var(--ds-display-body-padding-block-start)
|
|
848
|
+
- var(--ds-display-header-min-height) - var(--ds-display-header-padding-block)));
|
|
849
|
+
}
|
|
850
|
+
.dw-announcement {
|
|
851
|
+
position: absolute;
|
|
852
|
+
inline-size: 1px;
|
|
853
|
+
block-size: 1px;
|
|
854
|
+
overflow: hidden;
|
|
855
|
+
clip-path: inset(50%);
|
|
856
|
+
white-space: nowrap;
|
|
857
|
+
}
|
|
858
|
+
.dw-choices { display: flex; flex-wrap: wrap; gap: var(--ds-draft-dimension-x2); margin: 0; padding: 0; list-style: none; }
|
|
859
|
+
.dw-dialog-actions { display: flex; justify-content: end; gap: var(--ds-draft-dimension-x2); }
|
|
860
|
+
.dw-cancel {
|
|
861
|
+
min-block-size: var(--ds-draft-dimension-x8);
|
|
862
|
+
padding: 0 var(--ds-draft-dimension-x3);
|
|
863
|
+
border: 0;
|
|
864
|
+
border-radius: var(--ds-draft-radius-r2);
|
|
865
|
+
color: var(--ds-draft-fg-neutral);
|
|
866
|
+
background: var(--ds-draft-bg-neutral-weak);
|
|
867
|
+
font: inherit;
|
|
868
|
+
cursor: pointer;
|
|
869
|
+
}
|
|
870
|
+
.dw-cancel:hover { background: var(--ds-draft-bg-neutral-weak-pressed); }
|
|
871
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
872
|
+
.dw-header { transition: grid-template-columns 160ms ease-out; }
|
|
873
|
+
.dw-rail::before { transition: left 200ms ease-out, inline-size 200ms ease-out; }
|
|
874
|
+
}
|
|
875
|
+
</style>
|