@adecore/ui 0.31.12 → 0.32.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/dist/AccentSwatches.js +290 -13
- package/dist/Banner.js +90 -9
- package/dist/Button.js +114 -22
- package/dist/ButtonGroup.js +62 -8
- package/dist/Checkbox.js +73 -4
- package/dist/ChoiceCards.js +205 -11
- package/dist/CloseButton.js +87 -7
- package/dist/ColorSwatch.js +132 -15
- package/dist/ColorWheelPicker.js +305 -71
- package/dist/ColumnResizeHandle.js +43 -8
- package/dist/DisabledReason.js +27 -8
- package/dist/DockShell.js +144 -37
- package/dist/EmptyState.js +95 -6
- package/dist/ErrorBoundary.js +254 -31
- package/dist/Field.js +349 -31
- package/dist/FileIcon.js +67 -6
- package/dist/Icon.js +38 -6
- package/dist/IconButton.js +176 -20
- package/dist/IconPicker.js +344 -73
- package/dist/Input.js +233 -14
- package/dist/Kbd.js +150 -10
- package/dist/LazyBoundary.js +14 -5
- package/dist/ListRow.js +75 -15
- package/dist/Meter.js +108 -5
- package/dist/MiddleTruncate.js +126 -45
- package/dist/PanelEmpty.js +64 -5
- package/dist/PanelHeader.js +95 -13
- package/dist/Pill.js +114 -19
- package/dist/ProjectSwitcher.js +225 -12
- package/dist/PromptDialog.js +352 -37
- package/dist/SectionLabel.js +62 -8
- package/dist/SegmentBar.js +197 -36
- package/dist/Segmented.js +130 -23
- package/dist/Select.js +310 -19
- package/dist/SelectSearch.js +344 -29
- package/dist/Separator.js +35 -4
- package/dist/ShortcutHints.js +146 -76
- package/dist/Skeleton.js +31 -4
- package/dist/Slider.js +172 -10
- package/dist/SlidingColumn.js +194 -34
- package/dist/Spinner.js +100 -3
- package/dist/Stepper.js +232 -11
- package/dist/Surface.js +62 -8
- package/dist/Switch.js +60 -6
- package/dist/TextMenu.js +212 -17
- package/dist/Tile.js +149 -5
- package/dist/Toasts.js +391 -33
- package/dist/Tooltip.js +153 -16
- package/dist/UIProvider.js +62 -15
- package/dist/Waveform.js +362 -93
- package/dist/Wipe.js +259 -34
- package/dist/ZoomControls.js +356 -14
- package/dist/class-name.js +1 -1
- package/dist/clipboard.js +15 -17
- package/dist/context-menu/index.parts.js +1 -1
- package/dist/dialog/index.parts.js +1 -1
- package/dist/dialog/parts.js +378 -29
- package/dist/dialog-layer.js +51 -18
- package/dist/error-boundary.js +19 -19
- package/dist/error-message.js +1 -1
- package/dist/field-context.js +7 -5
- package/dist/file-icon.js +23 -21
- package/dist/file-tree/helpers.js +133 -119
- package/dist/file-tree/index.parts.js +3 -3
- package/dist/file-tree/parts.js +418 -127
- package/dist/file-tree/style.js +1 -1
- package/dist/file-tree/use-file-tree-shift.js +43 -30
- package/dist/file-tree/use-file-tree.js +60 -18
- package/dist/file-tree/use-slots.js +220 -192
- package/dist/floating.js +2 -2
- package/dist/format/datetime.js +88 -38
- package/dist/format/duration.js +59 -53
- package/dist/format/index.js +1 -1
- package/dist/format/locale.js +76 -56
- package/dist/format/number.js +77 -61
- package/dist/format/regions.js +4 -2
- package/dist/format/time-zone.js +1 -1
- package/dist/icon-button-size.js +12 -2
- package/dist/icon-picker.js +70 -61
- package/dist/index.js +57 -57
- package/dist/key-value-list/index.parts.js +1 -1
- package/dist/key-value-list/parts.js +256 -22
- package/dist/lazy-landings.js +10 -10
- package/dist/lazy.js +84 -71
- package/dist/locales/en.js +80 -80
- package/dist/locales/nl.js +80 -80
- package/dist/locales.js +10 -7
- package/dist/menu/index.parts.js +1 -1
- package/dist/menu/parts.js +882 -44
- package/dist/merge-refs.js +8 -9
- package/dist/middle-truncate.js +24 -25
- package/dist/modality.js +27 -19
- package/dist/placement.js +11 -20
- package/dist/platform.js +6 -6
- package/dist/popover/index.parts.js +1 -1
- package/dist/popover/parts.js +173 -11
- package/dist/popup-layer.js +38 -17
- package/dist/prefetch.js +78 -79
- package/dist/preview-card/index.parts.js +1 -1
- package/dist/project-switcher-row.js +153 -12
- package/dist/select-row.js +69 -5
- package/dist/select-shared.js +6 -6
- package/dist/selection.js +16 -16
- package/dist/seti-icons.js +413 -413
- package/dist/settings/ConfirmDialog.js +55 -8
- package/dist/settings/DetailHeader.js +72 -4
- package/dist/settings/MasterDetail.js +119 -7
- package/dist/settings/SettingsDialog.js +820 -80
- package/dist/settings/SettingsRow.js +205 -18
- package/dist/settings/SettingsSection.js +96 -6
- package/dist/settings/index.js +7 -7
- package/dist/settings/target.js +7 -2
- package/dist/shortcut-hints.js +73 -55
- package/dist/shortcut.js +140 -104
- package/dist/step-places.js +1 -1
- package/dist/tabs/index.parts.js +1 -1
- package/dist/tabs/overflow.js +18 -18
- package/dist/tabs/parts.js +780 -166
- package/dist/testing/dedupe.js +82 -75
- package/dist/testing/fake-source.js +12 -12
- package/dist/testing/index.js +1 -1
- package/dist/toast-store.js +65 -46
- package/dist/tree/index.parts.js +1 -1
- package/dist/tree/parts.js +721 -94
- package/dist/tree/shift.js +28 -22
- package/dist/tree/style.js +2 -2
- package/dist/tree/use-tree-shift.js +178 -117
- package/dist/useAsyncAction.js +23 -19
- package/dist/useColumnResize.js +36 -34
- package/dist/useContentSize.js +62 -18
- package/dist/useMeasuredWidth.js +14 -3
- package/dist/useNow.js +73 -30
- package/dist/wipe-split.js +14 -14
- package/dist/workspace/DropPreview.js +60 -7
- package/dist/workspace/SplitView.js +1025 -441
- package/dist/workspace/TabStrip.js +810 -191
- package/dist/workspace/Workspace.js +276 -26
- package/dist/workspace/context.js +8 -3
- package/dist/workspace/geometry.js +173 -150
- package/dist/workspace/model.js +313 -250
- package/dist/workspace/preview.js +61 -61
- package/dist/zoom.js +2 -2
- package/package.json +1 -1
- package/src/ErrorBoundary.tsx +1 -1
- package/src/Field.tsx +4 -3
- package/src/IconPicker.tsx +3 -3
- package/src/LazyBoundary.tsx +2 -0
- package/src/MiddleTruncate.tsx +2 -2
- package/src/SegmentBar.tsx +2 -2
- package/src/Toasts.tsx +3 -1
- package/src/Tooltip.tsx +7 -10
- package/src/Waveform.tsx +3 -3
- package/src/file-tree/parts.tsx +6 -9
- package/src/file-tree/use-file-tree-shift.tsx +6 -9
- package/src/lazy.tsx +4 -0
- package/src/locales/en.ts +4 -4
- package/src/locales/nl.ts +5 -5
- package/src/settings/SettingsDialog.tsx +1 -1
- package/src/tree/parts.tsx +5 -8
- package/src/useContentSize.ts +3 -3
- package/src/workspace/SplitView.tsx +2 -2
- package/src/workspace/TabStrip.tsx +2 -3
- package/src/workspace/Workspace.tsx +2 -5
package/dist/tree/shift.js
CHANGED
|
@@ -2,33 +2,39 @@ export const SHIFT_PROPERTY = '--adecore-tree-shift';
|
|
|
2
2
|
const LINE_WIDTH = 16;
|
|
3
3
|
const MIN_THUMB = 24;
|
|
4
4
|
export function clampShift(value, max) {
|
|
5
|
-
|
|
5
|
+
return Math.min(Math.max(value, 0), Math.max(max, 0));
|
|
6
6
|
}
|
|
7
7
|
export function shiftNeed(textRight, limit, shift) {
|
|
8
|
-
|
|
8
|
+
return Math.max(0, Math.ceil(textRight + shift - limit));
|
|
9
9
|
}
|
|
10
10
|
export function maxShift(needs) {
|
|
11
|
-
|
|
11
|
+
return needs.reduce((max, need) => Math.max(max, need), 0);
|
|
12
12
|
}
|
|
13
13
|
export function sidewaysDelta(step, pageWidth) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
const swapped = step.shiftKey && step.deltaX === 0;
|
|
15
|
+
const sideways = swapped ? step.deltaY : step.deltaX;
|
|
16
|
+
const across = swapped ? 0 : step.deltaY;
|
|
17
|
+
if (sideways === 0 || Math.abs(sideways) <= Math.abs(across)) {
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
if (step.deltaMode === 1) {
|
|
21
|
+
return sideways * LINE_WIDTH;
|
|
22
|
+
}
|
|
23
|
+
if (step.deltaMode === 2) {
|
|
24
|
+
return sideways * pageWidth;
|
|
25
|
+
}
|
|
26
|
+
return sideways;
|
|
27
27
|
}
|
|
28
28
|
export function shiftThumb(shift, max, track, view) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
29
|
+
if (max <= 0 || track <= 0) {
|
|
30
|
+
return {
|
|
31
|
+
left: 0,
|
|
32
|
+
width: Math.max(track, 0)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const width = Math.min(track, Math.max(MIN_THUMB, Math.round(track * view / (view + max))));
|
|
36
|
+
return {
|
|
37
|
+
left: Math.round((track - width) * clampShift(shift, max) / max),
|
|
38
|
+
width
|
|
39
|
+
};
|
|
40
|
+
}
|
package/dist/tree/style.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const TREE_ROW_HEIGHT = 25;
|
|
2
2
|
export function treeRowStyle(selector, selected = 'data-selected') {
|
|
3
|
-
|
|
3
|
+
return `
|
|
4
4
|
${selector} {
|
|
5
5
|
box-sizing: border-box;
|
|
6
6
|
display: flex;
|
|
@@ -26,4 +26,4 @@ export function treeRowStyle(selector, selected = 'data-selected') {
|
|
|
26
26
|
${selector}[data-joined-end="true"] { border-end-start-radius: 0; border-end-end-radius: 0; }
|
|
27
27
|
${selector}:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
|
28
28
|
`;
|
|
29
|
-
}
|
|
29
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
import { clampShift, maxShift, SHIFT_PROPERTY, shiftNeed, shiftThumb, sidewaysDelta } from './shift.js';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
const HIDE_AFTER = 900;
|
|
5
6
|
const NEAR_BOTTOM = 16;
|
|
6
7
|
/*
|
|
@@ -9,125 +10,185 @@ const NEAR_BOTTOM = 16;
|
|
|
9
10
|
* shift instead of a scroll keeps every row's background and the vertical scroll where they are.
|
|
10
11
|
*/
|
|
11
12
|
export function useTreeShift(source, resetKey) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const $ = _c(12);
|
|
14
|
+
const [frame, setFrame] = useState(null);
|
|
15
|
+
const [track, setTrack] = useState(null);
|
|
16
|
+
const [thumb, setThumb] = useState(null);
|
|
17
|
+
let t0;
|
|
18
|
+
if ($[0] !== frame || $[1] !== source || $[2] !== thumb || $[3] !== track) {
|
|
19
|
+
t0 = () => {
|
|
20
|
+
if (frame === null || track === null || thumb === null) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const range = document.createRange();
|
|
24
|
+
let root = null;
|
|
25
|
+
let exact = 0;
|
|
26
|
+
let drawn = 0;
|
|
27
|
+
let max = 0;
|
|
28
|
+
let pending = 0;
|
|
29
|
+
let hideTimer = 0;
|
|
30
|
+
let scrolling = false;
|
|
31
|
+
let near = false;
|
|
32
|
+
const draw = () => {
|
|
33
|
+
const shift = Math.round(exact);
|
|
34
|
+
if (shift !== drawn) {
|
|
35
|
+
drawn = shift;
|
|
36
|
+
frame.style.setProperty(SHIFT_PROPERTY, `${shift}px`);
|
|
37
|
+
}
|
|
38
|
+
const {
|
|
39
|
+
left,
|
|
40
|
+
width
|
|
41
|
+
} = shiftThumb(shift, max, track.clientWidth, frame.clientWidth);
|
|
42
|
+
thumb.style.left = `${left}px`;
|
|
43
|
+
thumb.style.width = `${width}px`;
|
|
44
|
+
track.toggleAttribute("data-visible", max > 0 && (scrolling || near));
|
|
45
|
+
};
|
|
46
|
+
const measure = () => {
|
|
47
|
+
pending = 0;
|
|
48
|
+
if (root === null) {
|
|
49
|
+
root = source.root(frame);
|
|
50
|
+
if (root === null) {
|
|
17
51
|
return;
|
|
52
|
+
}
|
|
53
|
+
rows.observe(root, {
|
|
54
|
+
childList: true,
|
|
55
|
+
subtree: true,
|
|
56
|
+
characterData: true
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const drawnRows = source.rows(root);
|
|
60
|
+
const gap = drawnRows.length === 0 ? 0 : Number.parseFloat(getComputedStyle(drawnRows[0]).columnGap) || 0;
|
|
61
|
+
max = maxShift(drawnRows.map(row => source.need(row, drawn, gap, range)).filter(_temp));
|
|
62
|
+
exact = clampShift(exact, max);
|
|
63
|
+
draw();
|
|
64
|
+
};
|
|
65
|
+
const schedule = () => {
|
|
66
|
+
if (pending === 0) {
|
|
67
|
+
pending = requestAnimationFrame(measure);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const rows = new MutationObserver(schedule);
|
|
71
|
+
const mounts = new MutationObserver(schedule);
|
|
72
|
+
mounts.observe(frame, {
|
|
73
|
+
childList: true,
|
|
74
|
+
subtree: true
|
|
75
|
+
});
|
|
76
|
+
const sizes = new ResizeObserver(schedule);
|
|
77
|
+
sizes.observe(frame);
|
|
78
|
+
const onWheel = event => {
|
|
79
|
+
const delta = sidewaysDelta(event, frame.clientWidth);
|
|
80
|
+
if (delta === 0 || max === 0) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
scrolling = true;
|
|
84
|
+
window.clearTimeout(hideTimer);
|
|
85
|
+
hideTimer = window.setTimeout(() => {
|
|
86
|
+
scrolling = false;
|
|
87
|
+
draw();
|
|
88
|
+
}, HIDE_AFTER);
|
|
89
|
+
const next = clampShift(exact + delta, max);
|
|
90
|
+
if (next !== exact) {
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
exact = next;
|
|
18
93
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
frame.addEventListener('pointerleave', onPointerLeave);
|
|
99
|
-
schedule();
|
|
100
|
-
return () => {
|
|
101
|
-
frame.removeEventListener('wheel', onWheel);
|
|
102
|
-
frame.removeEventListener('pointermove', onPointerMove);
|
|
103
|
-
frame.removeEventListener('pointerleave', onPointerLeave);
|
|
104
|
-
rows.disconnect();
|
|
105
|
-
mounts.disconnect();
|
|
106
|
-
sizes.disconnect();
|
|
107
|
-
cancelAnimationFrame(pending);
|
|
108
|
-
window.clearTimeout(hideTimer);
|
|
109
|
-
frame.style.removeProperty(SHIFT_PROPERTY);
|
|
110
|
-
track.removeAttribute('data-visible');
|
|
111
|
-
};
|
|
112
|
-
}, [frame, track, thumb, source, resetKey]);
|
|
113
|
-
const bar = (_jsx("div", { "aria-hidden": true, className: "adecore-tree-shift", children: _jsx("div", { ref: setTrack, className: "adecore-tree-shift-track", children: _jsx("div", { ref: setThumb, className: "adecore-tree-shift-thumb" }) }) }));
|
|
114
|
-
return { attach: setFrame, bar };
|
|
94
|
+
draw();
|
|
95
|
+
};
|
|
96
|
+
const onPointerMove = event_0 => {
|
|
97
|
+
const bottom = track.getBoundingClientRect().bottom;
|
|
98
|
+
const isNear = event_0.clientY >= bottom - NEAR_BOTTOM;
|
|
99
|
+
if (isNear !== near) {
|
|
100
|
+
near = isNear;
|
|
101
|
+
draw();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const onPointerLeave = () => {
|
|
105
|
+
if (near) {
|
|
106
|
+
near = false;
|
|
107
|
+
draw();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
frame.addEventListener("wheel", onWheel, {
|
|
111
|
+
passive: false
|
|
112
|
+
});
|
|
113
|
+
frame.addEventListener("pointermove", onPointerMove);
|
|
114
|
+
frame.addEventListener("pointerleave", onPointerLeave);
|
|
115
|
+
schedule();
|
|
116
|
+
return () => {
|
|
117
|
+
frame.removeEventListener("wheel", onWheel);
|
|
118
|
+
frame.removeEventListener("pointermove", onPointerMove);
|
|
119
|
+
frame.removeEventListener("pointerleave", onPointerLeave);
|
|
120
|
+
rows.disconnect();
|
|
121
|
+
mounts.disconnect();
|
|
122
|
+
sizes.disconnect();
|
|
123
|
+
cancelAnimationFrame(pending);
|
|
124
|
+
window.clearTimeout(hideTimer);
|
|
125
|
+
frame.style.removeProperty(SHIFT_PROPERTY);
|
|
126
|
+
track.removeAttribute("data-visible");
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
$[0] = frame;
|
|
130
|
+
$[1] = source;
|
|
131
|
+
$[2] = thumb;
|
|
132
|
+
$[3] = track;
|
|
133
|
+
$[4] = t0;
|
|
134
|
+
} else {
|
|
135
|
+
t0 = $[4];
|
|
136
|
+
}
|
|
137
|
+
let t1;
|
|
138
|
+
if ($[5] !== frame || $[6] !== resetKey || $[7] !== source || $[8] !== thumb || $[9] !== track) {
|
|
139
|
+
t1 = [frame, track, thumb, source, resetKey];
|
|
140
|
+
$[5] = frame;
|
|
141
|
+
$[6] = resetKey;
|
|
142
|
+
$[7] = source;
|
|
143
|
+
$[8] = thumb;
|
|
144
|
+
$[9] = track;
|
|
145
|
+
$[10] = t1;
|
|
146
|
+
} else {
|
|
147
|
+
t1 = $[10];
|
|
148
|
+
}
|
|
149
|
+
useEffect(t0, t1);
|
|
150
|
+
let t2;
|
|
151
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
152
|
+
const bar = /*#__PURE__*/_jsx("div", {
|
|
153
|
+
"aria-hidden": true,
|
|
154
|
+
className: "adecore-tree-shift",
|
|
155
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
156
|
+
ref: setTrack,
|
|
157
|
+
className: "adecore-tree-shift-track",
|
|
158
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
159
|
+
ref: setThumb,
|
|
160
|
+
className: "adecore-tree-shift-thumb"
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
});
|
|
164
|
+
t2 = {
|
|
165
|
+
attach: setFrame,
|
|
166
|
+
bar
|
|
167
|
+
};
|
|
168
|
+
$[11] = t2;
|
|
169
|
+
} else {
|
|
170
|
+
t2 = $[11];
|
|
171
|
+
}
|
|
172
|
+
return t2;
|
|
115
173
|
}
|
|
116
174
|
/* The rows of `Tree.Root`: everything a row holds slides, so a row reaches as far as its last part. */
|
|
175
|
+
function _temp(need) {
|
|
176
|
+
return need !== null;
|
|
177
|
+
}
|
|
117
178
|
export const TREE_ROWS = {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
const reach = Math.max(...parts.map((part) => part.getBoundingClientRect().right));
|
|
130
|
-
const limit = box.right - (Number.parseFloat(getComputedStyle(row).paddingInlineEnd) || 0);
|
|
131
|
-
return shiftNeed(reach, limit, shift);
|
|
179
|
+
root: frame => frame,
|
|
180
|
+
rows: root => [...root.querySelectorAll('.adecore-tree-row')],
|
|
181
|
+
need: (row, shift) => {
|
|
182
|
+
const box = row.getBoundingClientRect();
|
|
183
|
+
if (box.width === 0) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
const parts = [...row.children].filter(child => !child.classList.contains('adecore-tree-guide'));
|
|
187
|
+
if (parts.length === 0) {
|
|
188
|
+
return null;
|
|
132
189
|
}
|
|
133
|
-
|
|
190
|
+
const reach = Math.max(...parts.map(part => part.getBoundingClientRect().right));
|
|
191
|
+
const limit = box.right - (Number.parseFloat(getComputedStyle(row).paddingInlineEnd) || 0);
|
|
192
|
+
return shiftNeed(reach, limit, shift);
|
|
193
|
+
}
|
|
194
|
+
};
|
package/dist/useAsyncAction.js
CHANGED
|
@@ -2,22 +2,26 @@ import { useState } from 'react';
|
|
|
2
2
|
import { messageOf } from './error-message.js';
|
|
3
3
|
/* One step a surface waits on: the button goes quiet while it runs and the reason stays on screen when it does not. */
|
|
4
4
|
export function useAsyncAction(fallback) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
const [busy, setBusy] = useState(false);
|
|
6
|
+
const [failure, setFailure] = useState(null);
|
|
7
|
+
const run = async work => {
|
|
8
|
+
setBusy(true);
|
|
9
|
+
setFailure(null);
|
|
10
|
+
try {
|
|
11
|
+
await work();
|
|
12
|
+
return true;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
setFailure(messageOf(e, fallback));
|
|
15
|
+
return false;
|
|
16
|
+
} finally {
|
|
17
|
+
setBusy(false);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
busy,
|
|
22
|
+
failure,
|
|
23
|
+
run,
|
|
24
|
+
fail: setFailure,
|
|
25
|
+
clear: () => setFailure(null)
|
|
26
|
+
};
|
|
27
|
+
}
|
package/dist/useColumnResize.js
CHANGED
|
@@ -1,44 +1,46 @@
|
|
|
1
1
|
export const clampColumnSize = (options, size) => {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const max = Math.max(options.min, options.max?.() ?? Number.MAX_SAFE_INTEGER);
|
|
3
|
+
return Math.max(options.min, Math.min(Math.round(size), max));
|
|
4
4
|
};
|
|
5
5
|
/* Where the pointer sits on the axis this edge belongs to. */
|
|
6
|
-
const along = (from, event) =>
|
|
6
|
+
const along = (from, event) => from === 'left' || from === 'right' ? event.clientX : event.clientY;
|
|
7
7
|
/*
|
|
8
8
|
* One resizable column or row: a handle that drags the size its owner keeps. The handle takes the
|
|
9
9
|
* pointer capture, so the drag survives leaving the few pixels it is wide, and `[data-resizing]` on
|
|
10
10
|
* the column turns off any transition on that size for as long as it lasts.
|
|
11
11
|
*/
|
|
12
12
|
export const useColumnResize = (ref, options) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
const onUp = () => {
|
|
28
|
-
handle.removeEventListener('pointermove', onMove);
|
|
29
|
-
handle.removeEventListener('pointerup', onUp);
|
|
30
|
-
handle.removeEventListener('pointercancel', onUp);
|
|
31
|
-
handle.removeEventListener('lostpointercapture', onUp);
|
|
32
|
-
if (handle.hasPointerCapture(event.pointerId)) {
|
|
33
|
-
handle.releasePointerCapture(event.pointerId);
|
|
34
|
-
}
|
|
35
|
-
column?.removeAttribute('data-resizing');
|
|
36
|
-
};
|
|
37
|
-
handle.setPointerCapture(event.pointerId);
|
|
38
|
-
handle.addEventListener('pointermove', onMove);
|
|
39
|
-
handle.addEventListener('pointerup', onUp);
|
|
40
|
-
handle.addEventListener('pointercancel', onUp);
|
|
41
|
-
handle.addEventListener('lostpointercapture', onUp);
|
|
13
|
+
const startResize = event => {
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
const handle = event.currentTarget;
|
|
16
|
+
const column = ref.current;
|
|
17
|
+
const rect = column?.getBoundingClientRect();
|
|
18
|
+
const size = (options.from === 'left' || options.from === 'right' ? rect?.width : rect?.height) ?? options.size;
|
|
19
|
+
const start = along(options.from, event);
|
|
20
|
+
/* The far edge grows as the pointer comes towards it; the near edge grows as it goes away. */
|
|
21
|
+
const growsTowardsAnchor = options.from === 'right' || options.from === 'bottom';
|
|
22
|
+
column?.setAttribute('data-resizing', 'true');
|
|
23
|
+
const onMove = move => {
|
|
24
|
+
const delta = along(options.from, move) - start;
|
|
25
|
+
options.onSize(clampColumnSize(options, size + (growsTowardsAnchor ? -delta : delta)));
|
|
42
26
|
};
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
const onUp = () => {
|
|
28
|
+
handle.removeEventListener('pointermove', onMove);
|
|
29
|
+
handle.removeEventListener('pointerup', onUp);
|
|
30
|
+
handle.removeEventListener('pointercancel', onUp);
|
|
31
|
+
handle.removeEventListener('lostpointercapture', onUp);
|
|
32
|
+
if (handle.hasPointerCapture(event.pointerId)) {
|
|
33
|
+
handle.releasePointerCapture(event.pointerId);
|
|
34
|
+
}
|
|
35
|
+
column?.removeAttribute('data-resizing');
|
|
36
|
+
};
|
|
37
|
+
handle.setPointerCapture(event.pointerId);
|
|
38
|
+
handle.addEventListener('pointermove', onMove);
|
|
39
|
+
handle.addEventListener('pointerup', onUp);
|
|
40
|
+
handle.addEventListener('pointercancel', onUp);
|
|
41
|
+
handle.addEventListener('lostpointercapture', onUp);
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
startResize
|
|
45
|
+
};
|
|
46
|
+
};
|
package/dist/useContentSize.js
CHANGED
|
@@ -1,21 +1,65 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
3
|
/* Whole pixels, so a frame fitted into the space lands on them too. */
|
|
3
4
|
export function useContentSize() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
const $ = _c(6);
|
|
6
|
+
let t0;
|
|
7
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
8
|
+
t0 = {
|
|
9
|
+
width: 0,
|
|
10
|
+
height: 0
|
|
11
|
+
};
|
|
12
|
+
$[0] = t0;
|
|
13
|
+
} else {
|
|
14
|
+
t0 = $[0];
|
|
15
|
+
}
|
|
16
|
+
const [size, setSize] = useState(t0);
|
|
17
|
+
const observer = useRef(null);
|
|
18
|
+
let t1;
|
|
19
|
+
let t2;
|
|
20
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
21
|
+
t1 = () => () => observer.current?.disconnect();
|
|
22
|
+
t2 = [];
|
|
23
|
+
$[1] = t1;
|
|
24
|
+
$[2] = t2;
|
|
25
|
+
} else {
|
|
26
|
+
t1 = $[1];
|
|
27
|
+
t2 = $[2];
|
|
28
|
+
}
|
|
29
|
+
useEffect(t1, t2);
|
|
30
|
+
let t3;
|
|
31
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
32
|
+
t3 = node => {
|
|
33
|
+
observer.current?.disconnect();
|
|
34
|
+
if (node === null) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const update = (width, height) => {
|
|
38
|
+
const next = {
|
|
39
|
+
width: Math.round(width),
|
|
40
|
+
height: Math.round(height)
|
|
15
41
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
42
|
+
setSize(current => current.width === next.width && current.height === next.height ? current : next);
|
|
43
|
+
};
|
|
44
|
+
update(node.clientWidth, node.clientHeight);
|
|
45
|
+
observer.current = new ResizeObserver(t4 => {
|
|
46
|
+
const [entry] = t4;
|
|
47
|
+
return update(entry.contentRect.width, entry.contentRect.height);
|
|
48
|
+
});
|
|
49
|
+
observer.current.observe(node);
|
|
50
|
+
};
|
|
51
|
+
$[3] = t3;
|
|
52
|
+
} else {
|
|
53
|
+
t3 = $[3];
|
|
54
|
+
}
|
|
55
|
+
const measure = t3;
|
|
56
|
+
let t4;
|
|
57
|
+
if ($[4] !== size) {
|
|
58
|
+
t4 = [measure, size];
|
|
59
|
+
$[4] = size;
|
|
60
|
+
$[5] = t4;
|
|
61
|
+
} else {
|
|
62
|
+
t4 = $[5];
|
|
63
|
+
}
|
|
64
|
+
return t4;
|
|
65
|
+
}
|
package/dist/useMeasuredWidth.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
1
2
|
import { useContentSize } from './useContentSize.js';
|
|
2
3
|
/* A plot draws in real pixels rather than a stretched view box, so what it draws lands on whole ones. */
|
|
3
4
|
export function useMeasuredWidth() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const $ = _c(3);
|
|
6
|
+
const [measure, size] = useContentSize();
|
|
7
|
+
let t0;
|
|
8
|
+
if ($[0] !== measure || $[1] !== size.width) {
|
|
9
|
+
t0 = [measure, size.width];
|
|
10
|
+
$[0] = measure;
|
|
11
|
+
$[1] = size.width;
|
|
12
|
+
$[2] = t0;
|
|
13
|
+
} else {
|
|
14
|
+
t0 = $[2];
|
|
15
|
+
}
|
|
16
|
+
return t0;
|
|
17
|
+
}
|