@adecore/ui 0.31.12 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/dist/AccentSwatches.js +290 -13
  2. package/dist/Banner.js +90 -9
  3. package/dist/Button.js +114 -22
  4. package/dist/ButtonGroup.js +62 -8
  5. package/dist/Checkbox.js +73 -4
  6. package/dist/ChoiceCards.js +205 -11
  7. package/dist/CloseButton.js +87 -7
  8. package/dist/ColorSwatch.js +132 -15
  9. package/dist/ColorWheelPicker.js +305 -71
  10. package/dist/ColumnResizeHandle.js +43 -8
  11. package/dist/DisabledReason.js +27 -8
  12. package/dist/DockShell.js +144 -37
  13. package/dist/EmptyState.js +95 -6
  14. package/dist/ErrorBoundary.js +254 -31
  15. package/dist/Field.js +349 -31
  16. package/dist/FileIcon.js +67 -6
  17. package/dist/Icon.js +38 -6
  18. package/dist/IconButton.js +176 -20
  19. package/dist/IconPicker.js +344 -73
  20. package/dist/Input.js +233 -14
  21. package/dist/Kbd.js +150 -10
  22. package/dist/LazyBoundary.js +14 -5
  23. package/dist/ListRow.js +75 -15
  24. package/dist/Meter.js +108 -5
  25. package/dist/MiddleTruncate.js +126 -45
  26. package/dist/PanelEmpty.js +64 -5
  27. package/dist/PanelHeader.js +95 -13
  28. package/dist/Pill.js +114 -19
  29. package/dist/ProjectSwitcher.js +225 -12
  30. package/dist/PromptDialog.js +352 -37
  31. package/dist/SectionLabel.js +62 -8
  32. package/dist/SegmentBar.js +197 -36
  33. package/dist/Segmented.js +130 -23
  34. package/dist/Select.js +310 -19
  35. package/dist/SelectSearch.js +344 -29
  36. package/dist/Separator.js +35 -4
  37. package/dist/ShortcutHints.js +146 -76
  38. package/dist/Skeleton.js +31 -4
  39. package/dist/Slider.js +172 -10
  40. package/dist/SlidingColumn.js +194 -34
  41. package/dist/Spinner.js +100 -3
  42. package/dist/Stepper.js +232 -11
  43. package/dist/Surface.js +62 -8
  44. package/dist/Switch.js +60 -6
  45. package/dist/TextMenu.js +212 -17
  46. package/dist/Tile.js +149 -5
  47. package/dist/Toasts.js +391 -33
  48. package/dist/Tooltip.js +153 -16
  49. package/dist/UIProvider.js +62 -15
  50. package/dist/Waveform.js +362 -93
  51. package/dist/Wipe.js +259 -34
  52. package/dist/ZoomControls.js +356 -14
  53. package/dist/class-name.js +1 -1
  54. package/dist/clipboard.js +15 -17
  55. package/dist/context-menu/index.parts.js +1 -1
  56. package/dist/dialog/index.parts.js +1 -1
  57. package/dist/dialog/parts.js +378 -29
  58. package/dist/dialog-layer.js +51 -18
  59. package/dist/error-boundary.js +19 -19
  60. package/dist/error-message.js +1 -1
  61. package/dist/field-context.js +7 -5
  62. package/dist/file-icon.js +23 -21
  63. package/dist/file-tree/helpers.js +133 -119
  64. package/dist/file-tree/index.parts.js +3 -3
  65. package/dist/file-tree/parts.js +418 -127
  66. package/dist/file-tree/style.js +1 -1
  67. package/dist/file-tree/use-file-tree-shift.js +43 -30
  68. package/dist/file-tree/use-file-tree.js +60 -18
  69. package/dist/file-tree/use-slots.js +220 -192
  70. package/dist/floating.js +2 -2
  71. package/dist/format/datetime.js +88 -38
  72. package/dist/format/duration.js +59 -53
  73. package/dist/format/index.js +1 -1
  74. package/dist/format/locale.js +76 -56
  75. package/dist/format/number.js +77 -61
  76. package/dist/format/regions.js +4 -2
  77. package/dist/format/time-zone.js +1 -1
  78. package/dist/icon-button-size.js +12 -2
  79. package/dist/icon-picker.js +70 -61
  80. package/dist/index.js +57 -57
  81. package/dist/key-value-list/index.parts.js +1 -1
  82. package/dist/key-value-list/parts.js +256 -22
  83. package/dist/lazy-landings.js +10 -10
  84. package/dist/lazy.js +84 -71
  85. package/dist/locales/en.js +80 -80
  86. package/dist/locales/nl.js +80 -80
  87. package/dist/locales.js +10 -7
  88. package/dist/menu/index.parts.js +1 -1
  89. package/dist/menu/parts.js +882 -44
  90. package/dist/merge-refs.js +8 -9
  91. package/dist/middle-truncate.js +24 -25
  92. package/dist/modality.js +27 -19
  93. package/dist/placement.js +11 -20
  94. package/dist/platform.js +6 -6
  95. package/dist/popover/index.parts.js +1 -1
  96. package/dist/popover/parts.js +173 -11
  97. package/dist/popup-layer.js +38 -17
  98. package/dist/prefetch.js +78 -79
  99. package/dist/preview-card/index.parts.js +1 -1
  100. package/dist/project-switcher-row.js +153 -12
  101. package/dist/select-row.js +69 -5
  102. package/dist/select-shared.js +6 -6
  103. package/dist/selection.js +16 -16
  104. package/dist/seti-icons.js +413 -413
  105. package/dist/settings/ConfirmDialog.js +55 -8
  106. package/dist/settings/DetailHeader.js +72 -4
  107. package/dist/settings/MasterDetail.js +119 -7
  108. package/dist/settings/SettingsDialog.js +820 -80
  109. package/dist/settings/SettingsRow.js +205 -18
  110. package/dist/settings/SettingsSection.js +96 -6
  111. package/dist/settings/index.js +7 -7
  112. package/dist/settings/target.js +7 -2
  113. package/dist/shortcut-hints.js +73 -55
  114. package/dist/shortcut.js +140 -104
  115. package/dist/step-places.js +1 -1
  116. package/dist/tabs/index.parts.js +1 -1
  117. package/dist/tabs/overflow.js +18 -18
  118. package/dist/tabs/parts.js +780 -166
  119. package/dist/testing/dedupe.js +82 -75
  120. package/dist/testing/fake-source.js +12 -12
  121. package/dist/testing/index.js +1 -1
  122. package/dist/toast-store.js +65 -46
  123. package/dist/tree/index.parts.js +1 -1
  124. package/dist/tree/parts.js +721 -94
  125. package/dist/tree/shift.js +28 -22
  126. package/dist/tree/style.js +2 -2
  127. package/dist/tree/use-tree-shift.js +178 -117
  128. package/dist/useAsyncAction.js +23 -19
  129. package/dist/useColumnResize.js +36 -34
  130. package/dist/useContentSize.js +62 -18
  131. package/dist/useMeasuredWidth.js +14 -3
  132. package/dist/useNow.js +73 -30
  133. package/dist/wipe-split.js +14 -14
  134. package/dist/workspace/DropPreview.js +60 -7
  135. package/dist/workspace/SplitView.js +1025 -441
  136. package/dist/workspace/TabStrip.js +810 -191
  137. package/dist/workspace/Workspace.js +276 -26
  138. package/dist/workspace/context.js +8 -3
  139. package/dist/workspace/geometry.js +173 -150
  140. package/dist/workspace/model.js +313 -250
  141. package/dist/workspace/preview.js +61 -61
  142. package/dist/zoom.js +2 -2
  143. package/package.json +1 -1
  144. package/src/ErrorBoundary.tsx +1 -1
  145. package/src/Field.tsx +4 -3
  146. package/src/IconPicker.tsx +3 -3
  147. package/src/LazyBoundary.tsx +2 -0
  148. package/src/MiddleTruncate.tsx +2 -2
  149. package/src/SegmentBar.tsx +2 -2
  150. package/src/Toasts.tsx +3 -1
  151. package/src/Tooltip.tsx +7 -10
  152. package/src/Waveform.tsx +3 -3
  153. package/src/file-tree/parts.tsx +6 -9
  154. package/src/file-tree/use-file-tree-shift.tsx +6 -9
  155. package/src/lazy.tsx +4 -0
  156. package/src/locales/en.ts +4 -4
  157. package/src/locales/nl.ts +5 -5
  158. package/src/settings/SettingsDialog.tsx +1 -1
  159. package/src/tree/parts.tsx +5 -8
  160. package/src/useContentSize.ts +3 -3
  161. package/src/workspace/SplitView.tsx +2 -2
  162. package/src/workspace/TabStrip.tsx +2 -3
  163. package/src/workspace/Workspace.tsx +2 -5
@@ -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
- return Math.min(Math.max(value, 0), Math.max(max, 0));
5
+ return Math.min(Math.max(value, 0), Math.max(max, 0));
6
6
  }
7
7
  export function shiftNeed(textRight, limit, shift) {
8
- return Math.max(0, Math.ceil(textRight + shift - limit));
8
+ return Math.max(0, Math.ceil(textRight + shift - limit));
9
9
  }
10
10
  export function maxShift(needs) {
11
- return needs.reduce((max, need) => Math.max(max, need), 0);
11
+ return needs.reduce((max, need) => Math.max(max, need), 0);
12
12
  }
13
13
  export function sidewaysDelta(step, pageWidth) {
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;
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
- if (max <= 0 || track <= 0) {
30
- return { left: 0, width: Math.max(track, 0) };
31
- }
32
- const width = Math.min(track, Math.max(MIN_THUMB, Math.round((track * view) / (view + max))));
33
- return { left: Math.round(((track - width) * clampShift(shift, max)) / max), width };
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
+ }
@@ -1,6 +1,6 @@
1
1
  export const TREE_ROW_HEIGHT = 25;
2
2
  export function treeRowStyle(selector, selected = 'data-selected') {
3
- return `
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 { jsx as _jsx } from "react/jsx-runtime";
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
- const [frame, setFrame] = useState(null);
13
- const [track, setTrack] = useState(null);
14
- const [thumb, setThumb] = useState(null);
15
- useEffect(() => {
16
- if (frame === null || track === null || thumb === null) {
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
- const range = document.createRange();
20
- let root = null;
21
- let exact = 0;
22
- let drawn = 0;
23
- let max = 0;
24
- let pending = 0;
25
- let hideTimer = 0;
26
- let scrolling = false;
27
- let near = false;
28
- const draw = () => {
29
- const shift = Math.round(exact);
30
- if (shift !== drawn) {
31
- drawn = shift;
32
- frame.style.setProperty(SHIFT_PROPERTY, `${shift}px`);
33
- }
34
- const { left, width } = shiftThumb(shift, max, track.clientWidth, frame.clientWidth);
35
- thumb.style.left = `${left}px`;
36
- thumb.style.width = `${width}px`;
37
- track.toggleAttribute('data-visible', max > 0 && (scrolling || near));
38
- };
39
- const measure = () => {
40
- pending = 0;
41
- if (root === null) {
42
- root = source.root(frame);
43
- if (root === null) {
44
- return;
45
- }
46
- rows.observe(root, { childList: true, subtree: true, characterData: true });
47
- }
48
- const drawnRows = source.rows(root);
49
- const gap = drawnRows.length === 0 ? 0 : Number.parseFloat(getComputedStyle(drawnRows[0]).columnGap) || 0;
50
- max = maxShift(drawnRows.map((row) => source.need(row, drawn, gap, range)).filter((need) => need !== null));
51
- exact = clampShift(exact, max);
52
- draw();
53
- };
54
- const schedule = () => {
55
- if (pending === 0) {
56
- pending = requestAnimationFrame(measure);
57
- }
58
- };
59
- const rows = new MutationObserver(schedule);
60
- const mounts = new MutationObserver(schedule);
61
- mounts.observe(frame, { childList: true, subtree: true });
62
- const sizes = new ResizeObserver(schedule);
63
- sizes.observe(frame);
64
- const onWheel = (event) => {
65
- const delta = sidewaysDelta(event, frame.clientWidth);
66
- if (delta === 0 || max === 0) {
67
- return;
68
- }
69
- scrolling = true;
70
- window.clearTimeout(hideTimer);
71
- hideTimer = window.setTimeout(() => {
72
- scrolling = false;
73
- draw();
74
- }, HIDE_AFTER);
75
- const next = clampShift(exact + delta, max);
76
- if (next !== exact) {
77
- event.preventDefault();
78
- exact = next;
79
- }
80
- draw();
81
- };
82
- const onPointerMove = (event) => {
83
- const bottom = track.getBoundingClientRect().bottom;
84
- const isNear = event.clientY >= bottom - NEAR_BOTTOM;
85
- if (isNear !== near) {
86
- near = isNear;
87
- draw();
88
- }
89
- };
90
- const onPointerLeave = () => {
91
- if (near) {
92
- near = false;
93
- draw();
94
- }
95
- };
96
- frame.addEventListener('wheel', onWheel, { passive: false });
97
- frame.addEventListener('pointermove', onPointerMove);
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
- root: (frame) => frame,
119
- rows: (root) => [...root.querySelectorAll('.adecore-tree-row')],
120
- need: (row, shift) => {
121
- const box = row.getBoundingClientRect();
122
- if (box.width === 0) {
123
- return null;
124
- }
125
- const parts = [...row.children].filter((child) => !child.classList.contains('adecore-tree-guide'));
126
- if (parts.length === 0) {
127
- return null;
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
+ };
@@ -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
- 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
- }
14
- catch (e) {
15
- setFailure(messageOf(e, fallback));
16
- return false;
17
- }
18
- finally {
19
- setBusy(false);
20
- }
21
- };
22
- return { busy, failure, run, fail: setFailure, clear: () => setFailure(null) };
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
+ }
@@ -1,44 +1,46 @@
1
1
  export const clampColumnSize = (options, size) => {
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));
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) => (from === 'left' || from === 'right' ? event.clientX : event.clientY);
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
- 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)));
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
- return { startResize };
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
+ };
@@ -1,21 +1,65 @@
1
- import { useCallback, useEffect, useRef, useState } from 'react';
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
- const [size, setSize] = useState({ width: 0, height: 0 });
5
- const observer = useRef(null);
6
- useEffect(() => () => observer.current?.disconnect(), []);
7
- const measure = useCallback((node) => {
8
- observer.current?.disconnect();
9
- if (node === null) {
10
- return;
11
- }
12
- const update = (width, height) => {
13
- const next = { width: Math.round(width), height: Math.round(height) };
14
- setSize((current) => (current.width === next.width && current.height === next.height ? current : next));
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
- update(node.clientWidth, node.clientHeight);
17
- observer.current = new ResizeObserver(([entry]) => update(entry.contentRect.width, entry.contentRect.height));
18
- observer.current.observe(node);
19
- }, []);
20
- return [measure, size];
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
+ }
@@ -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
- const [measure, size] = useContentSize();
5
- return [measure, size.width];
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
+ }