@gabvdl/ui 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -0
- package/dist/components/button/button.d.ts +39 -0
- package/dist/components/button/button.d.ts.map +1 -0
- package/dist/components/button/button.js +72 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/index.d.ts +5 -0
- package/dist/components/button/index.d.ts.map +1 -0
- package/dist/components/button/tooltip.d.ts +31 -0
- package/dist/components/button/tooltip.d.ts.map +1 -0
- package/dist/components/button/tooltip.js +83 -0
- package/dist/components/button/tooltip.js.map +1 -0
- package/dist/components/changelog/changelog.d.ts +52 -0
- package/dist/components/changelog/changelog.d.ts.map +1 -0
- package/dist/components/changelog/changelog.js +164 -0
- package/dist/components/changelog/changelog.js.map +1 -0
- package/dist/components/changelog/index.d.ts +3 -0
- package/dist/components/changelog/index.d.ts.map +1 -0
- package/dist/components/copy-button/copy-button.d.ts +16 -0
- package/dist/components/copy-button/copy-button.d.ts.map +1 -0
- package/dist/components/copy-button/copy-button.js +40 -0
- package/dist/components/copy-button/copy-button.js.map +1 -0
- package/dist/components/copy-button/index.d.ts +3 -0
- package/dist/components/copy-button/index.d.ts.map +1 -0
- package/dist/components/drop-zone/drop-zone.d.ts +20 -0
- package/dist/components/drop-zone/drop-zone.d.ts.map +1 -0
- package/dist/components/drop-zone/drop-zone.js +54 -0
- package/dist/components/drop-zone/drop-zone.js.map +1 -0
- package/dist/components/drop-zone/index.d.ts +5 -0
- package/dist/components/drop-zone/index.d.ts.map +1 -0
- package/dist/components/drop-zone/use-file-drop.d.ts +45 -0
- package/dist/components/drop-zone/use-file-drop.d.ts.map +1 -0
- package/dist/components/drop-zone/use-file-drop.js +97 -0
- package/dist/components/drop-zone/use-file-drop.js.map +1 -0
- package/dist/components/element-picker/element-picker-field.d.ts +30 -0
- package/dist/components/element-picker/element-picker-field.d.ts.map +1 -0
- package/dist/components/element-picker/element-picker-field.js +273 -0
- package/dist/components/element-picker/element-picker-field.js.map +1 -0
- package/dist/components/element-picker/element-picker.d.ts +45 -0
- package/dist/components/element-picker/element-picker.d.ts.map +1 -0
- package/dist/components/element-picker/element-picker.js +179 -0
- package/dist/components/element-picker/element-picker.js.map +1 -0
- package/dist/components/element-picker/element-preview.d.ts +23 -0
- package/dist/components/element-picker/element-preview.d.ts.map +1 -0
- package/dist/components/element-picker/element-preview.js +72 -0
- package/dist/components/element-picker/element-preview.js.map +1 -0
- package/dist/components/element-picker/index.d.ts +12 -0
- package/dist/components/element-picker/index.d.ts.map +1 -0
- package/dist/components/element-picker/parse.d.ts +32 -0
- package/dist/components/element-picker/parse.d.ts.map +1 -0
- package/dist/components/element-picker/parse.js +230 -0
- package/dist/components/element-picker/parse.js.map +1 -0
- package/dist/components/element-picker/types.d.ts +72 -0
- package/dist/components/element-picker/types.d.ts.map +1 -0
- package/dist/components/element-picker/use-element-picker.d.ts +56 -0
- package/dist/components/element-picker/use-element-picker.d.ts.map +1 -0
- package/dist/components/element-picker/use-element-picker.js +201 -0
- package/dist/components/element-picker/use-element-picker.js.map +1 -0
- package/dist/components/empty-state/empty-state.d.ts +16 -0
- package/dist/components/empty-state/empty-state.d.ts.map +1 -0
- package/dist/components/empty-state/empty-state.js +41 -0
- package/dist/components/empty-state/empty-state.js.map +1 -0
- package/dist/components/empty-state/index.d.ts +3 -0
- package/dist/components/empty-state/index.d.ts.map +1 -0
- package/dist/components/floating-panel/dock-context.d.ts +66 -0
- package/dist/components/floating-panel/dock-context.d.ts.map +1 -0
- package/dist/components/floating-panel/dock-context.js +96 -0
- package/dist/components/floating-panel/dock-context.js.map +1 -0
- package/dist/components/floating-panel/dock.d.ts +26 -0
- package/dist/components/floating-panel/dock.d.ts.map +1 -0
- package/dist/components/floating-panel/dock.js +46 -0
- package/dist/components/floating-panel/dock.js.map +1 -0
- package/dist/components/floating-panel/floating-panel.d.ts +69 -0
- package/dist/components/floating-panel/floating-panel.d.ts.map +1 -0
- package/dist/components/floating-panel/floating-panel.js +285 -0
- package/dist/components/floating-panel/floating-panel.js.map +1 -0
- package/dist/components/floating-panel/index.d.ts +7 -0
- package/dist/components/floating-panel/index.d.ts.map +1 -0
- package/dist/components/fuzzy-list/fuzzy-list.d.ts +96 -0
- package/dist/components/fuzzy-list/fuzzy-list.d.ts.map +1 -0
- package/dist/components/fuzzy-list/fuzzy-list.js +127 -0
- package/dist/components/fuzzy-list/fuzzy-list.js.map +1 -0
- package/dist/components/fuzzy-list/index.d.ts +4 -0
- package/dist/components/fuzzy-list/index.d.ts.map +1 -0
- package/dist/components/global-search/global-search.d.ts +78 -0
- package/dist/components/global-search/global-search.d.ts.map +1 -0
- package/dist/components/global-search/global-search.js +181 -0
- package/dist/components/global-search/global-search.js.map +1 -0
- package/dist/components/global-search/hotkey.d.ts +23 -0
- package/dist/components/global-search/hotkey.d.ts.map +1 -0
- package/dist/components/global-search/hotkey.js +41 -0
- package/dist/components/global-search/hotkey.js.map +1 -0
- package/dist/components/global-search/index.d.ts +5 -0
- package/dist/components/global-search/index.d.ts.map +1 -0
- package/dist/components/iframe-preview/iframe-preview.d.ts +64 -0
- package/dist/components/iframe-preview/iframe-preview.d.ts.map +1 -0
- package/dist/components/iframe-preview/iframe-preview.js +257 -0
- package/dist/components/iframe-preview/iframe-preview.js.map +1 -0
- package/dist/components/iframe-preview/index.d.ts +3 -0
- package/dist/components/iframe-preview/index.d.ts.map +1 -0
- package/dist/components/image-viewer/image-viewer.d.ts +30 -0
- package/dist/components/image-viewer/image-viewer.d.ts.map +1 -0
- package/dist/components/image-viewer/image-viewer.js +226 -0
- package/dist/components/image-viewer/image-viewer.js.map +1 -0
- package/dist/components/image-viewer/index.d.ts +4 -0
- package/dist/components/image-viewer/index.d.ts.map +1 -0
- package/dist/components/image-viewer/progressive-image.d.ts +20 -0
- package/dist/components/image-viewer/progressive-image.d.ts.map +1 -0
- package/dist/components/image-viewer/progressive-image.js +62 -0
- package/dist/components/image-viewer/progressive-image.js.map +1 -0
- package/dist/components/image-viewer/viewable-image.d.ts +17 -0
- package/dist/components/image-viewer/viewable-image.d.ts.map +1 -0
- package/dist/components/image-viewer/viewable-image.js +38 -0
- package/dist/components/image-viewer/viewable-image.js.map +1 -0
- package/dist/components/input/index.d.ts +3 -0
- package/dist/components/input/index.d.ts.map +1 -0
- package/dist/components/input/input.d.ts +15 -0
- package/dist/components/input/input.d.ts.map +1 -0
- package/dist/components/input/input.js +56 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/modal/index.d.ts +5 -0
- package/dist/components/modal/index.d.ts.map +1 -0
- package/dist/components/modal/modal-context.d.ts +37 -0
- package/dist/components/modal/modal-context.d.ts.map +1 -0
- package/dist/components/modal/modal-context.js +81 -0
- package/dist/components/modal/modal-context.js.map +1 -0
- package/dist/components/modal/modal.d.ts +28 -0
- package/dist/components/modal/modal.d.ts.map +1 -0
- package/dist/components/modal/modal.js +94 -0
- package/dist/components/modal/modal.js.map +1 -0
- package/dist/components/nav-2d/index.d.ts +3 -0
- package/dist/components/nav-2d/index.d.ts.map +1 -0
- package/dist/components/nav-2d/nav-2d.d.ts +59 -0
- package/dist/components/nav-2d/nav-2d.d.ts.map +1 -0
- package/dist/components/nav-2d/nav-2d.js +290 -0
- package/dist/components/nav-2d/nav-2d.js.map +1 -0
- package/dist/components/phone-preview/index.d.ts +3 -0
- package/dist/components/phone-preview/index.d.ts.map +1 -0
- package/dist/components/phone-preview/phone-preview.d.ts +45 -0
- package/dist/components/phone-preview/phone-preview.d.ts.map +1 -0
- package/dist/components/phone-preview/phone-preview.js +117 -0
- package/dist/components/phone-preview/phone-preview.js.map +1 -0
- package/dist/components/progressive-bash/index.d.ts +7 -0
- package/dist/components/progressive-bash/index.d.ts.map +1 -0
- package/dist/components/progressive-bash/parse.d.ts +88 -0
- package/dist/components/progressive-bash/parse.d.ts.map +1 -0
- package/dist/components/progressive-bash/parse.js +120 -0
- package/dist/components/progressive-bash/parse.js.map +1 -0
- package/dist/components/progressive-bash/playback.d.ts +50 -0
- package/dist/components/progressive-bash/playback.d.ts.map +1 -0
- package/dist/components/progressive-bash/playback.js +19 -0
- package/dist/components/progressive-bash/playback.js.map +1 -0
- package/dist/components/progressive-bash/progressive-bash.d.ts +97 -0
- package/dist/components/progressive-bash/progressive-bash.d.ts.map +1 -0
- package/dist/components/progressive-bash/progressive-bash.js +377 -0
- package/dist/components/progressive-bash/progressive-bash.js.map +1 -0
- package/dist/components/progressive-list/index.d.ts +3 -0
- package/dist/components/progressive-list/index.d.ts.map +1 -0
- package/dist/components/progressive-list/progressive-list.d.ts +55 -0
- package/dist/components/progressive-list/progressive-list.d.ts.map +1 -0
- package/dist/components/progressive-list/progressive-list.js +83 -0
- package/dist/components/progressive-list/progressive-list.js.map +1 -0
- package/dist/components/progressive-table/index.d.ts +3 -0
- package/dist/components/progressive-table/index.d.ts.map +1 -0
- package/dist/components/progressive-table/progressive-table.d.ts +58 -0
- package/dist/components/progressive-table/progressive-table.d.ts.map +1 -0
- package/dist/components/progressive-table/progressive-table.js +86 -0
- package/dist/components/progressive-table/progressive-table.js.map +1 -0
- package/dist/components/progressive-text/index.d.ts +3 -0
- package/dist/components/progressive-text/index.d.ts.map +1 -0
- package/dist/components/progressive-text/progressive-text.d.ts +54 -0
- package/dist/components/progressive-text/progressive-text.d.ts.map +1 -0
- package/dist/components/progressive-text/progressive-text.js +97 -0
- package/dist/components/progressive-text/progressive-text.js.map +1 -0
- package/dist/components/progressive-timeline/index.d.ts +3 -0
- package/dist/components/progressive-timeline/index.d.ts.map +1 -0
- package/dist/components/progressive-timeline/progressive-timeline.d.ts +46 -0
- package/dist/components/progressive-timeline/progressive-timeline.d.ts.map +1 -0
- package/dist/components/progressive-timeline/progressive-timeline.js +62 -0
- package/dist/components/progressive-timeline/progressive-timeline.js.map +1 -0
- package/dist/components/relative-time/index.d.ts +3 -0
- package/dist/components/relative-time/index.d.ts.map +1 -0
- package/dist/components/relative-time/relative-time.d.ts +14 -0
- package/dist/components/relative-time/relative-time.d.ts.map +1 -0
- package/dist/components/relative-time/relative-time.js +15 -0
- package/dist/components/relative-time/relative-time.js.map +1 -0
- package/dist/components/resizable-layout/index.d.ts +3 -0
- package/dist/components/resizable-layout/index.d.ts.map +1 -0
- package/dist/components/resizable-layout/resizable-layout.d.ts +113 -0
- package/dist/components/resizable-layout/resizable-layout.d.ts.map +1 -0
- package/dist/components/resizable-layout/resizable-layout.js +398 -0
- package/dist/components/resizable-layout/resizable-layout.js.map +1 -0
- package/dist/components/rich-input/compose.d.ts +13 -0
- package/dist/components/rich-input/compose.d.ts.map +1 -0
- package/dist/components/rich-input/compose.js +28 -0
- package/dist/components/rich-input/compose.js.map +1 -0
- package/dist/components/rich-input/index.d.ts +5 -0
- package/dist/components/rich-input/index.d.ts.map +1 -0
- package/dist/components/rich-input/parts.d.ts +53 -0
- package/dist/components/rich-input/parts.d.ts.map +1 -0
- package/dist/components/rich-input/parts.js +285 -0
- package/dist/components/rich-input/parts.js.map +1 -0
- package/dist/components/rich-input/rich-input.d.ts +64 -0
- package/dist/components/rich-input/rich-input.d.ts.map +1 -0
- package/dist/components/rich-input/rich-input.js +351 -0
- package/dist/components/rich-input/rich-input.js.map +1 -0
- package/dist/components/rich-input/types.d.ts +92 -0
- package/dist/components/rich-input/types.d.ts.map +1 -0
- package/dist/components/rich-input/use-draft.d.ts +9 -0
- package/dist/components/rich-input/use-draft.d.ts.map +1 -0
- package/dist/components/rich-input/use-draft.js +47 -0
- package/dist/components/rich-input/use-draft.js.map +1 -0
- package/dist/components/rich-input/use-file-upload.d.ts +18 -0
- package/dist/components/rich-input/use-file-upload.d.ts.map +1 -0
- package/dist/components/rich-input/use-file-upload.js +88 -0
- package/dist/components/rich-input/use-file-upload.js.map +1 -0
- package/dist/components/rich-input/use-guidelines.d.ts +16 -0
- package/dist/components/rich-input/use-guidelines.d.ts.map +1 -0
- package/dist/components/rich-input/use-guidelines.js +85 -0
- package/dist/components/rich-input/use-guidelines.js.map +1 -0
- package/dist/components/rich-input/use-input-history.d.ts +22 -0
- package/dist/components/rich-input/use-input-history.d.ts.map +1 -0
- package/dist/components/rich-input/use-input-history.js +61 -0
- package/dist/components/rich-input/use-input-history.js.map +1 -0
- package/dist/components/rich-input/use-mention.d.ts +24 -0
- package/dist/components/rich-input/use-mention.d.ts.map +1 -0
- package/dist/components/rich-input/use-mention.js +54 -0
- package/dist/components/rich-input/use-mention.js.map +1 -0
- package/dist/components/search-input/index.d.ts +3 -0
- package/dist/components/search-input/index.d.ts.map +1 -0
- package/dist/components/search-input/search-input.d.ts +14 -0
- package/dist/components/search-input/search-input.d.ts.map +1 -0
- package/dist/components/search-input/search-input.js +63 -0
- package/dist/components/search-input/search-input.js.map +1 -0
- package/dist/components/skeleton/index.d.ts +3 -0
- package/dist/components/skeleton/index.d.ts.map +1 -0
- package/dist/components/skeleton/skeleton.d.ts +19 -0
- package/dist/components/skeleton/skeleton.d.ts.map +1 -0
- package/dist/components/skeleton/skeleton.js +29 -0
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/spinner/index.d.ts +3 -0
- package/dist/components/spinner/index.d.ts.map +1 -0
- package/dist/components/spinner/spinner.d.ts +11 -0
- package/dist/components/spinner/spinner.d.ts.map +1 -0
- package/dist/components/spinner/spinner.js +32 -0
- package/dist/components/spinner/spinner.js.map +1 -0
- package/dist/components/status-badge/index.d.ts +3 -0
- package/dist/components/status-badge/index.d.ts.map +1 -0
- package/dist/components/status-badge/status-badge.d.ts +31 -0
- package/dist/components/status-badge/status-badge.d.ts.map +1 -0
- package/dist/components/status-badge/status-badge.js +53 -0
- package/dist/components/status-badge/status-badge.js.map +1 -0
- package/dist/components/theme/index.d.ts +5 -0
- package/dist/components/theme/index.d.ts.map +1 -0
- package/dist/components/theme/theme-toggle.d.ts +11 -0
- package/dist/components/theme/theme-toggle.d.ts.map +1 -0
- package/dist/components/theme/theme-toggle.js +57 -0
- package/dist/components/theme/theme-toggle.js.map +1 -0
- package/dist/components/theme/theme.d.ts +29 -0
- package/dist/components/theme/theme.d.ts.map +1 -0
- package/dist/components/theme/theme.js +70 -0
- package/dist/components/theme/theme.js.map +1 -0
- package/dist/components/toast/index.d.ts +3 -0
- package/dist/components/toast/index.d.ts.map +1 -0
- package/dist/components/toast/toast.d.ts +64 -0
- package/dist/components/toast/toast.d.ts.map +1 -0
- package/dist/components/toast/toast.js +155 -0
- package/dist/components/toast/toast.js.map +1 -0
- package/dist/components/virtual-list/index.d.ts +3 -0
- package/dist/components/virtual-list/index.d.ts.map +1 -0
- package/dist/components/virtual-list/virtual-list.d.ts +71 -0
- package/dist/components/virtual-list/virtual-list.d.ts.map +1 -0
- package/dist/components/virtual-list/virtual-list.js +65 -0
- package/dist/components/virtual-list/virtual-list.js.map +1 -0
- package/dist/hooks/index.d.ts +12 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +26 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.js +36 -0
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
- package/dist/hooks/use-debounced-value.d.ts +23 -0
- package/dist/hooks/use-debounced-value.d.ts.map +1 -0
- package/dist/hooks/use-debounced-value.js +19 -0
- package/dist/hooks/use-debounced-value.js.map +1 -0
- package/dist/hooks/use-intersection.d.ts +25 -0
- package/dist/hooks/use-intersection.d.ts.map +1 -0
- package/dist/hooks/use-intersection.js +38 -0
- package/dist/hooks/use-intersection.js.map +1 -0
- package/dist/hooks/use-local-storage.d.ts +12 -0
- package/dist/hooks/use-local-storage.d.ts.map +1 -0
- package/dist/hooks/use-local-storage.js +43 -0
- package/dist/hooks/use-local-storage.js.map +1 -0
- package/dist/hooks/use-long-press.d.ts +37 -0
- package/dist/hooks/use-long-press.d.ts.map +1 -0
- package/dist/hooks/use-long-press.js +39 -0
- package/dist/hooks/use-long-press.js.map +1 -0
- package/dist/hooks/use-media-query.d.ts +17 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +37 -0
- package/dist/hooks/use-media-query.js.map +1 -0
- package/dist/hooks/use-overlay.d.ts +20 -0
- package/dist/hooks/use-overlay.d.ts.map +1 -0
- package/dist/hooks/use-overlay.js +42 -0
- package/dist/hooks/use-overlay.js.map +1 -0
- package/dist/image-viewer.css +152 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +161 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/format.d.ts +19 -0
- package/dist/lib/format.d.ts.map +1 -0
- package/dist/lib/format.js +62 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/highlight.d.ts +15 -0
- package/dist/lib/highlight.d.ts.map +1 -0
- package/dist/lib/highlight.js +39 -0
- package/dist/lib/highlight.js.map +1 -0
- package/dist/lib/search.d.ts +40 -0
- package/dist/lib/search.d.ts.map +1 -0
- package/dist/lib/search.js +91 -0
- package/dist/lib/search.js.map +1 -0
- package/dist/lib/utils.d.ts +4 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +9 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/overlay.css +78 -0
- package/dist/styles.css +6 -0
- package/dist/theme.css +81 -0
- package/dist/tooltip.css +53 -0
- package/dist/virtual-list.css +29 -0
- package/package.json +77 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import * as i from "react";
|
|
2
|
+
import { parseElement as le } from "./parse.js";
|
|
3
|
+
const G = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
let ue = 0;
|
|
5
|
+
const ae = (D) => {
|
|
6
|
+
let w = G.get(D);
|
|
7
|
+
return w || (w = `el-${++ue}`, G.set(D, w)), w;
|
|
8
|
+
}, N = "data-element-picker-ignore", de = 700;
|
|
9
|
+
function pe(D = {}) {
|
|
10
|
+
const {
|
|
11
|
+
root: w,
|
|
12
|
+
multiple: R = !0,
|
|
13
|
+
value: A,
|
|
14
|
+
defaultValue: V = [],
|
|
15
|
+
onChange: X,
|
|
16
|
+
onPick: Y,
|
|
17
|
+
active: x,
|
|
18
|
+
onActiveChange: S,
|
|
19
|
+
filter: H,
|
|
20
|
+
ignoreSelector: I = `[${N}]`,
|
|
21
|
+
styleProps: O,
|
|
22
|
+
holdDelay: U = 350,
|
|
23
|
+
moveTolerance: _ = 12,
|
|
24
|
+
max: K
|
|
25
|
+
} = D, [W, j] = i.useState(!1), L = x ?? W, [z, B] = i.useState(V), P = A ?? z, [J, Q] = i.useState(null), [Z, M] = i.useState(!1), [m, ee] = i.useState(null), $ = i.useRef(null), E = i.useCallback((n) => {
|
|
26
|
+
$.current = n, Q((o) => o === n ? o : n);
|
|
27
|
+
}, []), l = i.useRef({
|
|
28
|
+
picked: P,
|
|
29
|
+
multiple: R,
|
|
30
|
+
max: K,
|
|
31
|
+
filter: H,
|
|
32
|
+
ignoreSelector: I,
|
|
33
|
+
styleProps: O,
|
|
34
|
+
onChange: X,
|
|
35
|
+
onPick: Y,
|
|
36
|
+
root: m,
|
|
37
|
+
controlled: A !== void 0,
|
|
38
|
+
stop: () => {
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
l.current = {
|
|
42
|
+
...l.current,
|
|
43
|
+
picked: P,
|
|
44
|
+
multiple: R,
|
|
45
|
+
max: K,
|
|
46
|
+
filter: H,
|
|
47
|
+
ignoreSelector: I,
|
|
48
|
+
styleProps: O,
|
|
49
|
+
onChange: X,
|
|
50
|
+
onPick: Y,
|
|
51
|
+
root: m,
|
|
52
|
+
controlled: A !== void 0
|
|
53
|
+
};
|
|
54
|
+
const te = i.useRef({
|
|
55
|
+
timer: void 0,
|
|
56
|
+
from: null,
|
|
57
|
+
on: !1,
|
|
58
|
+
/**
|
|
59
|
+
* When a touch ends in a pick, the browser replays it as a compatibility
|
|
60
|
+
* mouse sequence — pointerdown, mousedown, mouseup, *click* — on the same
|
|
61
|
+
* spot. That click would pick the element a second time, and a second pick
|
|
62
|
+
* is a deselect, so the tap would appear to do nothing at all. We stamp the
|
|
63
|
+
* pick and ignore any click landing in its wake. A stamp rather than a flag
|
|
64
|
+
* because the replay isn't guaranteed to arrive: a flag left standing would
|
|
65
|
+
* go on to eat somebody's real click.
|
|
66
|
+
*/
|
|
67
|
+
pickedAt: 0
|
|
68
|
+
});
|
|
69
|
+
i.useEffect(() => {
|
|
70
|
+
ee(w ?? (typeof document > "u" ? null : document.body));
|
|
71
|
+
}, [w]);
|
|
72
|
+
const g = i.useCallback(
|
|
73
|
+
(n) => {
|
|
74
|
+
x === void 0 && j(n), S == null || S(n);
|
|
75
|
+
},
|
|
76
|
+
[x, S]
|
|
77
|
+
), ne = i.useCallback(() => g(!0), [g]), q = i.useCallback(() => g(!1), [g]), oe = i.useCallback(() => g(!L), [L, g]);
|
|
78
|
+
l.current.stop = q;
|
|
79
|
+
const k = i.useCallback((n) => {
|
|
80
|
+
var o, t;
|
|
81
|
+
l.current.controlled || B(n), (t = (o = l.current).onChange) == null || t.call(o, n);
|
|
82
|
+
}, []), b = i.useCallback(
|
|
83
|
+
(n) => {
|
|
84
|
+
var C, d;
|
|
85
|
+
const { picked: o, multiple: t, max: u, styleProps: p, root: a } = l.current, c = ae(n);
|
|
86
|
+
if (o.some((h) => h.id === c)) {
|
|
87
|
+
k(o.filter((h) => h.id !== c));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const y = {
|
|
91
|
+
id: c,
|
|
92
|
+
element: n,
|
|
93
|
+
info: le(n, { root: a ?? void 0, styleProps: p })
|
|
94
|
+
};
|
|
95
|
+
let v = t ? [...o, y] : [y];
|
|
96
|
+
u && v.length > u && (v = v.slice(v.length - u)), k(v), (d = (C = l.current).onPick) == null || d.call(C, y);
|
|
97
|
+
},
|
|
98
|
+
[k]
|
|
99
|
+
), re = i.useCallback(
|
|
100
|
+
(n) => k(l.current.picked.filter((o) => o.id !== n)),
|
|
101
|
+
[k]
|
|
102
|
+
), ie = i.useCallback(() => k([]), [k]), se = i.useCallback((n) => P.some((o) => o.element === n), [P]), T = i.useCallback((n, o) => {
|
|
103
|
+
const { root: t, filter: u, ignoreSelector: p } = l.current;
|
|
104
|
+
if (!t) return null;
|
|
105
|
+
const a = t.ownerDocument.elementFromPoint(n, o);
|
|
106
|
+
if (!(a instanceof HTMLElement) || p && a.closest(p) || !t.contains(a) || a === t) return null;
|
|
107
|
+
if (!u) return a;
|
|
108
|
+
for (let c = a; c && c !== t; c = c.parentElement)
|
|
109
|
+
if (u(c)) return c;
|
|
110
|
+
return null;
|
|
111
|
+
}, []);
|
|
112
|
+
return i.useEffect(() => {
|
|
113
|
+
if (!L || !m) return;
|
|
114
|
+
const n = m.ownerDocument, o = n.documentElement, t = te.current;
|
|
115
|
+
t.timer = void 0, t.from = null, t.on = !1;
|
|
116
|
+
const u = (e) => {
|
|
117
|
+
const { ignoreSelector: r } = l.current;
|
|
118
|
+
return !!(r && e instanceof Element && e.closest(r));
|
|
119
|
+
}, p = (e, r) => E(T(e, r)), a = (e) => {
|
|
120
|
+
if (e.pointerType === "touch") {
|
|
121
|
+
t.on ? p(e.clientX, e.clientY) : t.from && Math.hypot(e.clientX - t.from.x, e.clientY - t.from.y) > _ && (clearTimeout(t.timer), t.from = null);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
p(e.clientX, e.clientY);
|
|
125
|
+
}, c = () => {
|
|
126
|
+
clearTimeout(t.timer), t.from = null, t.on && (t.on = !1, M(!1));
|
|
127
|
+
}, y = (e) => {
|
|
128
|
+
if (!u(e.target)) {
|
|
129
|
+
if (e.pointerType === "touch") {
|
|
130
|
+
t.from = { x: e.clientX, y: e.clientY }, t.timer = setTimeout(() => {
|
|
131
|
+
var r;
|
|
132
|
+
t.on = !0, t.from = null, M(!0), (r = navigator.vibrate) == null || r.call(navigator, 12), p(e.clientX, e.clientY);
|
|
133
|
+
}, U);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
e.preventDefault(), e.stopPropagation();
|
|
137
|
+
}
|
|
138
|
+
}, v = (e) => {
|
|
139
|
+
if (!u(e.target)) {
|
|
140
|
+
if (e.pointerType === "touch") {
|
|
141
|
+
const r = t.on;
|
|
142
|
+
c();
|
|
143
|
+
const f = T(e.clientX, e.clientY);
|
|
144
|
+
f && (b(f), t.pickedAt = performance.now()), (r || f) && E(null), e.preventDefault(), e.stopPropagation();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
e.preventDefault(), e.stopPropagation();
|
|
148
|
+
}
|
|
149
|
+
}, C = (e) => {
|
|
150
|
+
if (u(e.target) || (e.preventDefault(), e.stopPropagation(), e.detail === 0) || performance.now() - t.pickedAt < de) return;
|
|
151
|
+
const r = T(e.clientX, e.clientY);
|
|
152
|
+
r && b(r);
|
|
153
|
+
}, d = (e) => {
|
|
154
|
+
u(e.target) || (e.preventDefault(), e.stopPropagation());
|
|
155
|
+
}, h = (e) => {
|
|
156
|
+
if (!t.on) return;
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
const r = e.touches[0];
|
|
159
|
+
r && p(r.clientX, r.clientY);
|
|
160
|
+
}, F = (e) => {
|
|
161
|
+
if (e.key === "Escape") {
|
|
162
|
+
e.preventDefault(), l.current.stop();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const r = $.current;
|
|
166
|
+
if (r)
|
|
167
|
+
if (e.key === "ArrowUp") {
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
const f = r.parentElement;
|
|
170
|
+
f && f !== m.parentElement && m.contains(f) && E(f);
|
|
171
|
+
} else if (e.key === "ArrowDown") {
|
|
172
|
+
e.preventDefault();
|
|
173
|
+
const f = r.firstElementChild;
|
|
174
|
+
f instanceof HTMLElement && E(f);
|
|
175
|
+
} else (e.key === "Enter" || e.key === " ") && (e.preventDefault(), b(r));
|
|
176
|
+
}, s = { capture: !0 };
|
|
177
|
+
window.addEventListener("pointermove", a, s), window.addEventListener("pointerdown", y, s), window.addEventListener("pointerup", v, s), window.addEventListener("pointercancel", c, s), window.addEventListener("click", C, s), window.addEventListener("mousedown", d, s), window.addEventListener("mouseup", d, s), window.addEventListener("dblclick", d, s), window.addEventListener("contextmenu", d, s), window.addEventListener("keydown", F, s), n.addEventListener("touchmove", h, { passive: !1, capture: !0 });
|
|
178
|
+
const ce = o.style.cssText;
|
|
179
|
+
return o.style.cursor = "crosshair", o.style.userSelect = "none", o.style.webkitUserSelect = "none", o.style.webkitTouchCallout = "none", () => {
|
|
180
|
+
clearTimeout(t.timer), window.removeEventListener("pointermove", a, s), window.removeEventListener("pointerdown", y, s), window.removeEventListener("pointerup", v, s), window.removeEventListener("pointercancel", c, s), window.removeEventListener("click", C, s), window.removeEventListener("mousedown", d, s), window.removeEventListener("mouseup", d, s), window.removeEventListener("dblclick", d, s), window.removeEventListener("contextmenu", d, s), window.removeEventListener("keydown", F, s), n.removeEventListener("touchmove", h, { capture: !0 }), o.style.cssText = ce, E(null), M(!1);
|
|
181
|
+
};
|
|
182
|
+
}, [L, m, U, _, b, T, E]), {
|
|
183
|
+
active: L,
|
|
184
|
+
start: ne,
|
|
185
|
+
stop: q,
|
|
186
|
+
toggle: oe,
|
|
187
|
+
hovered: J,
|
|
188
|
+
holding: Z,
|
|
189
|
+
picked: P,
|
|
190
|
+
pick: b,
|
|
191
|
+
remove: re,
|
|
192
|
+
clear: ie,
|
|
193
|
+
isPicked: se,
|
|
194
|
+
root: m,
|
|
195
|
+
ignoreProps: { [N]: "" }
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
export {
|
|
199
|
+
pe as useElementPicker
|
|
200
|
+
};
|
|
201
|
+
//# sourceMappingURL=use-element-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-element-picker.js","sources":["../../../src/components/element-picker/use-element-picker.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { parseElement } from './parse';\nimport type { PickedElement } from './types';\n\n/** Stable ids, so re-picking the same node doesn't churn React keys. */\nconst IDS = new WeakMap<HTMLElement, string>();\nlet seq = 0;\nconst idOf = (el: HTMLElement) => {\n let id = IDS.get(el);\n if (!id) {\n id = `el-${++seq}`;\n IDS.set(el, id);\n }\n return id;\n};\n\nexport interface UseElementPickerOptions {\n /** The subtree you can pick from. Defaults to `document.body`. */\n root?: HTMLElement | null;\n /** Keep picking after the first hit. Default true. */\n multiple?: boolean;\n /** Controlled selection. */\n value?: PickedElement[];\n defaultValue?: PickedElement[];\n onChange?: (picked: PickedElement[]) => void;\n onPick?: (picked: PickedElement) => void;\n /** Controlled picking mode. */\n active?: boolean;\n onActiveChange?: (active: boolean) => void;\n /**\n * Which elements may be picked. When an element fails, the picker walks up to\n * the nearest ancestor that passes — so `(el) => el.matches('.card')` turns it\n * into a card picker, however deep the pointer actually lands.\n */\n filter?: (el: HTMLElement) => boolean;\n /** Subtrees the picker won't look at — your own toolbar, typically. */\n ignoreSelector?: string;\n /** Override which computed properties get captured. */\n styleProps?: string[];\n /** Touch: how long to hold before hover mode engages, in ms. Default 350. */\n holdDelay?: number;\n /** Touch: movement (px) that reads as a scroll and cancels the hold. Default 12. */\n moveTolerance?: number;\n /** Cap the selection. Picking past it drops the oldest. */\n max?: number;\n}\n\nexport interface UseElementPickerResult {\n active: boolean;\n start: () => void;\n stop: () => void;\n toggle: () => void;\n /** What the pointer is over right now — the live preview target. */\n hovered: HTMLElement | null;\n /** True while a touch hold has engaged hover mode. */\n holding: boolean;\n picked: PickedElement[];\n pick: (el: HTMLElement) => void;\n remove: (id: string) => void;\n clear: () => void;\n isPicked: (el: HTMLElement) => boolean;\n root: HTMLElement | null;\n /** Put this on any UI of your own that must stay clickable while picking. */\n ignoreProps: Record<string, string>;\n}\n\nconst IGNORE_ATTR = 'data-element-picker-ignore';\n\n/** How long after a touch pick a click is still assumed to be its replay. */\nconst COMPAT_CLICK_MS = 700;\n\n/**\n * The machinery behind {@link ElementPicker}: hover tracking, click-to-select,\n * and the press-and-hold gesture that turns a touchscreen — which has no hover\n * — into one. Use it directly when you want the behaviour without the overlay.\n */\nexport function useElementPicker(options: UseElementPickerOptions = {}): UseElementPickerResult {\n const {\n root: rootProp,\n multiple = true,\n value,\n defaultValue = [],\n onChange,\n onPick,\n active: activeProp,\n onActiveChange,\n filter,\n ignoreSelector = `[${IGNORE_ATTR}]`,\n styleProps,\n holdDelay = 350,\n moveTolerance = 12,\n max,\n } = options;\n\n const [activeState, setActiveState] = React.useState(false);\n const active = activeProp ?? activeState;\n\n const [pickedState, setPickedState] = React.useState<PickedElement[]>(defaultValue);\n const picked = value ?? pickedState;\n\n const [hovered, setHoveredState] = React.useState<HTMLElement | null>(null);\n const [holding, setHolding] = React.useState(false);\n const [root, setRoot] = React.useState<HTMLElement | null>(null);\n\n // Mirrored into a ref so the listeners below can read the hover without being\n // torn down and rebound on every pointer move.\n const hoveredRef = React.useRef<HTMLElement | null>(null);\n const setHovered = React.useCallback((el: HTMLElement | null) => {\n hoveredRef.current = el;\n setHoveredState((prev) => (prev === el ? prev : el));\n }, []);\n\n // Latest props, read from listeners that are only bound once per activation.\n // `controlled` lives here too so `commit` — and therefore `pick`, and\n // therefore the listener effect — stays referentially stable across a pick.\n const latest = React.useRef({\n picked,\n multiple,\n max,\n filter,\n ignoreSelector,\n styleProps,\n onChange,\n onPick,\n root,\n controlled: value !== undefined,\n stop: () => {},\n });\n latest.current = {\n ...latest.current,\n picked,\n multiple,\n max,\n filter,\n ignoreSelector,\n styleProps,\n onChange,\n onPick,\n root,\n controlled: value !== undefined,\n };\n\n /**\n * Gesture state, held across effect re-binds. It cannot live inside the\n * effect: a pick changes `picked`, which can re-run the effect *between* a\n * touch's pointerup and the compatibility click it triggers — and a fresh\n * object there would lose the very stamp that click has to be checked against.\n */\n const gesture = React.useRef({\n timer: undefined as ReturnType<typeof setTimeout> | undefined,\n from: null as { x: number; y: number } | null,\n on: false,\n /**\n * When a touch ends in a pick, the browser replays it as a compatibility\n * mouse sequence — pointerdown, mousedown, mouseup, *click* — on the same\n * spot. That click would pick the element a second time, and a second pick\n * is a deselect, so the tap would appear to do nothing at all. We stamp the\n * pick and ignore any click landing in its wake. A stamp rather than a flag\n * because the replay isn't guaranteed to arrive: a flag left standing would\n * go on to eat somebody's real click.\n */\n pickedAt: 0,\n });\n\n React.useEffect(() => {\n setRoot(rootProp ?? (typeof document === 'undefined' ? null : document.body));\n }, [rootProp]);\n\n const setActive = React.useCallback(\n (next: boolean) => {\n if (activeProp === undefined) setActiveState(next);\n onActiveChange?.(next);\n },\n [activeProp, onActiveChange],\n );\n\n const start = React.useCallback(() => setActive(true), [setActive]);\n const stop = React.useCallback(() => setActive(false), [setActive]);\n const toggle = React.useCallback(() => setActive(!active), [active, setActive]);\n latest.current.stop = stop;\n\n const commit = React.useCallback((next: PickedElement[]) => {\n if (!latest.current.controlled) setPickedState(next);\n latest.current.onChange?.(next);\n }, []);\n\n const pick = React.useCallback(\n (el: HTMLElement) => {\n const { picked: current, multiple: many, max: cap, styleProps: props, root: base } = latest.current;\n const id = idOf(el);\n\n // A second click on a selected element unselects it — the only way back\n // out of a mis-pick without leaving the flow.\n if (current.some((p) => p.id === id)) {\n commit(current.filter((p) => p.id !== id));\n return;\n }\n\n const entry: PickedElement = {\n id,\n element: el,\n info: parseElement(el, { root: base ?? undefined, styleProps: props }),\n };\n let next = many ? [...current, entry] : [entry];\n if (cap && next.length > cap) next = next.slice(next.length - cap);\n\n commit(next);\n latest.current.onPick?.(entry);\n },\n [commit],\n );\n\n const remove = React.useCallback(\n (id: string) => commit(latest.current.picked.filter((p) => p.id !== id)),\n [commit],\n );\n const clear = React.useCallback(() => commit([]), [commit]);\n const isPicked = React.useCallback((el: HTMLElement) => picked.some((p) => p.element === el), [picked]);\n\n /** The pickable element under a viewport point, or null. */\n const resolve = React.useCallback((x: number, y: number): HTMLElement | null => {\n const { root: base, filter: pass, ignoreSelector: ignore } = latest.current;\n if (!base) return null;\n\n // The overlay is pointer-events:none, so elementFromPoint looks straight\n // through it at the page underneath.\n const hit = base.ownerDocument.elementFromPoint(x, y);\n if (!(hit instanceof HTMLElement)) return null;\n if (ignore && hit.closest(ignore)) return null;\n if (!base.contains(hit) || hit === base) return null;\n\n if (!pass) return hit;\n // Walk up to the nearest ancestor that passes, but never past the root —\n // the root is the frame, not something you can pick.\n for (let el: HTMLElement | null = hit; el && el !== base; el = el.parentElement) {\n if (pass(el)) return el;\n }\n return null;\n }, []);\n\n // Picking mode: swallow the page's own pointer handling, track the hover, and\n // take a click as a pick.\n React.useEffect(() => {\n if (!active || !root) return;\n\n const doc = root.ownerDocument;\n const html = doc.documentElement;\n const held = gesture.current;\n held.timer = undefined;\n held.from = null;\n held.on = false;\n\n const inIgnored = (target: EventTarget | null) => {\n const { ignoreSelector: ignore } = latest.current;\n return !!(ignore && target instanceof Element && target.closest(ignore));\n };\n\n const hoverAt = (x: number, y: number) => setHovered(resolve(x, y));\n\n const onPointerMove = (e: PointerEvent) => {\n if (e.pointerType === 'touch') {\n if (held.on) {\n hoverAt(e.clientX, e.clientY);\n } else if (held.from && Math.hypot(e.clientX - held.from.x, e.clientY - held.from.y) > moveTolerance) {\n clearTimeout(held.timer); // they're scrolling, not holding\n held.from = null;\n }\n return;\n }\n hoverAt(e.clientX, e.clientY);\n };\n\n const endHold = () => {\n clearTimeout(held.timer);\n held.from = null;\n if (held.on) {\n held.on = false;\n setHolding(false);\n }\n };\n\n const onPointerDown = (e: PointerEvent) => {\n if (inIgnored(e.target)) return;\n\n if (e.pointerType === 'touch') {\n held.from = { x: e.clientX, y: e.clientY };\n held.timer = setTimeout(() => {\n held.on = true;\n held.from = null;\n setHolding(true);\n // A tick of haptics, so the hold registers without looking at the screen.\n navigator.vibrate?.(12);\n hoverAt(e.clientX, e.clientY);\n }, holdDelay);\n return;\n }\n\n // Mouse: keep the press off the page (no text selection, no drag start).\n e.preventDefault();\n e.stopPropagation();\n };\n\n const onPointerUp = (e: PointerEvent) => {\n if (inIgnored(e.target)) return;\n\n if (e.pointerType === 'touch') {\n const wasHolding = held.on;\n endHold();\n // Either way the finger lifts on the element it was previewing: a hold\n // and drag commits what's under it, a plain tap commits what it hit.\n const target = resolve(e.clientX, e.clientY);\n if (target) {\n pick(target);\n held.pickedAt = performance.now();\n }\n if (wasHolding || target) setHovered(null);\n e.preventDefault();\n e.stopPropagation();\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n };\n\n const onClick = (e: MouseEvent) => {\n if (inIgnored(e.target)) return;\n // Never let the page act on a pick — no navigation, no form submit.\n e.preventDefault();\n e.stopPropagation();\n if (e.detail === 0) return; // synthetic (keyboard) click, not a real one\n\n // The compatibility click replaying the touch we already picked from.\n if (performance.now() - held.pickedAt < COMPAT_CLICK_MS) return;\n\n const target = resolve(e.clientX, e.clientY);\n if (target) pick(target);\n };\n\n const swallow = (e: Event) => {\n if (inIgnored(e.target)) return;\n e.preventDefault();\n e.stopPropagation();\n };\n\n // Non-passive: this is what stops the page scrolling under a held finger.\n const onTouchMove = (e: TouchEvent) => {\n if (!held.on) return;\n e.preventDefault();\n const touch = e.touches[0];\n if (touch) hoverAt(touch.clientX, touch.clientY);\n };\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n latest.current.stop();\n return;\n }\n const current = hoveredRef.current;\n if (!current) return;\n\n // Walk the tree without moving the mouse — the devtools reflex.\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n const parent = current.parentElement;\n if (parent && parent !== root.parentElement && root.contains(parent)) setHovered(parent);\n } else if (e.key === 'ArrowDown') {\n e.preventDefault();\n const child = current.firstElementChild;\n if (child instanceof HTMLElement) setHovered(child);\n } else if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n pick(current);\n }\n };\n\n const opts = { capture: true } as const;\n window.addEventListener('pointermove', onPointerMove, opts);\n window.addEventListener('pointerdown', onPointerDown, opts);\n window.addEventListener('pointerup', onPointerUp, opts);\n window.addEventListener('pointercancel', endHold, opts);\n window.addEventListener('click', onClick, opts);\n window.addEventListener('mousedown', swallow, opts);\n window.addEventListener('mouseup', swallow, opts);\n window.addEventListener('dblclick', swallow, opts);\n window.addEventListener('contextmenu', swallow, opts);\n window.addEventListener('keydown', onKeyDown, opts);\n doc.addEventListener('touchmove', onTouchMove, { passive: false, capture: true });\n\n const prior = html.style.cssText;\n html.style.cursor = 'crosshair';\n html.style.userSelect = 'none';\n html.style.webkitUserSelect = 'none';\n (html.style as CSSStyleDeclaration & { webkitTouchCallout?: string }).webkitTouchCallout = 'none';\n\n return () => {\n clearTimeout(held.timer);\n window.removeEventListener('pointermove', onPointerMove, opts);\n window.removeEventListener('pointerdown', onPointerDown, opts);\n window.removeEventListener('pointerup', onPointerUp, opts);\n window.removeEventListener('pointercancel', endHold, opts);\n window.removeEventListener('click', onClick, opts);\n window.removeEventListener('mousedown', swallow, opts);\n window.removeEventListener('mouseup', swallow, opts);\n window.removeEventListener('dblclick', swallow, opts);\n window.removeEventListener('contextmenu', swallow, opts);\n window.removeEventListener('keydown', onKeyDown, opts);\n doc.removeEventListener('touchmove', onTouchMove, { capture: true });\n html.style.cssText = prior;\n setHovered(null);\n setHolding(false);\n };\n }, [active, root, holdDelay, moveTolerance, pick, resolve, setHovered]);\n\n return {\n active,\n start,\n stop,\n toggle,\n hovered,\n holding,\n picked,\n pick,\n remove,\n clear,\n isPicked,\n root,\n ignoreProps: { [IGNORE_ATTR]: '' },\n };\n}\n"],"names":["IDS","seq","idOf","el","id","IGNORE_ATTR","COMPAT_CLICK_MS","useElementPicker","options","rootProp","multiple","value","defaultValue","onChange","onPick","activeProp","onActiveChange","filter","ignoreSelector","styleProps","holdDelay","moveTolerance","max","activeState","setActiveState","React","active","pickedState","setPickedState","picked","hovered","setHoveredState","holding","setHolding","root","setRoot","hoveredRef","setHovered","prev","latest","gesture","setActive","next","start","stop","toggle","commit","_b","_a","pick","current","many","cap","props","base","p","entry","parseElement","remove","clear","isPicked","resolve","x","y","pass","ignore","hit","doc","html","held","inIgnored","target","hoverAt","onPointerMove","endHold","onPointerDown","onPointerUp","wasHolding","onClick","swallow","onTouchMove","touch","onKeyDown","parent","child","opts","prior"],"mappings":";;AA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AAC;AAAA,IACA,MAAA1B;AAAA,IACA,aAAa,EAAE,CAAC7B,CAAW,GAAG,GAAA;AAAA,EAAG;AAErC;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface EmptyStateProps {
|
|
3
|
+
/** A lucide icon (or any node) — rendered muted in a soft disc. */
|
|
4
|
+
icon?: React.ReactNode;
|
|
5
|
+
title: React.ReactNode;
|
|
6
|
+
/** One line on what to do about it. Keep it actionable. */
|
|
7
|
+
description?: React.ReactNode;
|
|
8
|
+
/** The way out — usually a `<Button>`. */
|
|
9
|
+
action?: React.ReactNode;
|
|
10
|
+
/** Tighter, for a drawer or a card. */
|
|
11
|
+
compact?: boolean;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/** "No results yet" — the centred icon + message + call to action. */
|
|
15
|
+
export declare function EmptyState({ icon, title, description, action, compact, className, }: EmptyStateProps): React.JSX.Element;
|
|
16
|
+
//# sourceMappingURL=empty-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-state.d.ts","sourceRoot":"","sources":["../../../src/components/empty-state/empty-state.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,WAAW,eAAe;IAC9B,mEAAmE;IACnE,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,0CAA0C;IAC1C,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,uCAAuC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,EACN,OAAe,EACf,SAAS,GACV,EAAE,eAAe,qBA0BjB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsxs as n, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { cn as s } from "../../lib/utils.js";
|
|
4
|
+
function u({
|
|
5
|
+
icon: r,
|
|
6
|
+
title: d,
|
|
7
|
+
description: m,
|
|
8
|
+
action: l,
|
|
9
|
+
compact: t = !1,
|
|
10
|
+
className: i
|
|
11
|
+
}) {
|
|
12
|
+
return /* @__PURE__ */ n(
|
|
13
|
+
"div",
|
|
14
|
+
{
|
|
15
|
+
className: s(
|
|
16
|
+
"flex flex-col items-center justify-center text-center",
|
|
17
|
+
t ? "gap-2 px-4 py-8" : "gap-3 px-6 py-16",
|
|
18
|
+
i
|
|
19
|
+
),
|
|
20
|
+
children: [
|
|
21
|
+
r && /* @__PURE__ */ e(
|
|
22
|
+
"div",
|
|
23
|
+
{
|
|
24
|
+
className: s(
|
|
25
|
+
"flex items-center justify-center rounded-full bg-muted text-muted-foreground [&_svg]:size-5",
|
|
26
|
+
t ? "size-9" : "size-12 [&_svg]:size-6"
|
|
27
|
+
),
|
|
28
|
+
children: r
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
/* @__PURE__ */ e("p", { className: s("font-medium text-foreground", t ? "text-sm" : "text-base"), children: d }),
|
|
32
|
+
m && /* @__PURE__ */ e("p", { className: "max-w-sm text-sm leading-relaxed text-muted-foreground", children: m }),
|
|
33
|
+
l && /* @__PURE__ */ e("div", { className: "mt-1", children: l })
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
u as EmptyState
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=empty-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-state.js","sources":["../../../src/components/empty-state/empty-state.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { cn } from '../../lib/utils';\n\nexport interface EmptyStateProps {\n /** A lucide icon (or any node) — rendered muted in a soft disc. */\n icon?: React.ReactNode;\n title: React.ReactNode;\n /** One line on what to do about it. Keep it actionable. */\n description?: React.ReactNode;\n /** The way out — usually a `<Button>`. */\n action?: React.ReactNode;\n /** Tighter, for a drawer or a card. */\n compact?: boolean;\n className?: string;\n}\n\n/** \"No results yet\" — the centred icon + message + call to action. */\nexport function EmptyState({\n icon,\n title,\n description,\n action,\n compact = false,\n className,\n}: EmptyStateProps) {\n return (\n <div\n className={cn(\n 'flex flex-col items-center justify-center text-center',\n compact ? 'gap-2 px-4 py-8' : 'gap-3 px-6 py-16',\n className,\n )}\n >\n {icon && (\n <div\n className={cn(\n 'flex items-center justify-center rounded-full bg-muted text-muted-foreground [&_svg]:size-5',\n compact ? 'size-9' : 'size-12 [&_svg]:size-6',\n )}\n >\n {icon}\n </div>\n )}\n <p className={cn('font-medium text-foreground', compact ? 'text-sm' : 'text-base')}>{title}</p>\n {description && (\n <p className=\"max-w-sm text-sm leading-relaxed text-muted-foreground\">{description}</p>\n )}\n {action && <div className=\"mt-1\">{action}</div>}\n </div>\n );\n}\n"],"names":["EmptyState","icon","title","description","action","compact","className","jsxs","cn","jsx"],"mappings":";;;AAkBO,SAASA,EAAW;AAAA,EACzB,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,WAAAC;AACF,GAAoB;AAClB,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC;AAAA,QACT;AAAA,QACAH,IAAU,oBAAoB;AAAA,QAC9BC;AAAA,MAAA;AAAA,MAGD,UAAA;AAAA,QAAAL,KACC,gBAAAQ;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAWD;AAAA,cACT;AAAA,cACAH,IAAU,WAAW;AAAA,YAAA;AAAA,YAGtB,UAAAJ;AAAA,UAAA;AAAA,QAAA;AAAA,QAGL,gBAAAQ,EAAC,OAAE,WAAWD,EAAG,+BAA+BH,IAAU,YAAY,WAAW,GAAI,UAAAH,EAAA,CAAM;AAAA,QAC1FC,KACC,gBAAAM,EAAC,KAAA,EAAE,WAAU,0DAA0D,UAAAN,GAAY;AAAA,QAEpFC,KAAU,gBAAAK,EAAC,OAAA,EAAI,WAAU,QAAQ,UAAAL,EAAA,CAAO;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG/C;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/empty-state/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/** A floating window's on-screen box, in viewport pixels. */
|
|
3
|
+
export interface FloatingGeom {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Where a panel currently lives: free-floating at a viewport box, or docked
|
|
11
|
+
* (in-flow) inside a {@link Dock} identified by `dockId`.
|
|
12
|
+
*/
|
|
13
|
+
export type PanelPlacement = ({
|
|
14
|
+
mode: 'floating';
|
|
15
|
+
} & FloatingGeom) | {
|
|
16
|
+
mode: 'docked';
|
|
17
|
+
dockId: string;
|
|
18
|
+
};
|
|
19
|
+
interface DockEntry {
|
|
20
|
+
id: string;
|
|
21
|
+
/** Live viewport rect of the dock's drop area (for hit-testing a drag). */
|
|
22
|
+
getRect: () => DOMRect | null;
|
|
23
|
+
/** Portal target for the dock's tab bar. */
|
|
24
|
+
tabBar: HTMLElement | null;
|
|
25
|
+
/** Portal target for the active panel's body. */
|
|
26
|
+
content: HTMLElement | null;
|
|
27
|
+
}
|
|
28
|
+
export interface DockContextValue {
|
|
29
|
+
registerDock: (id: string, getRect: () => DOMRect | null) => void;
|
|
30
|
+
updateDockEls: (id: string, els: {
|
|
31
|
+
tabBar: HTMLElement | null;
|
|
32
|
+
content: HTMLElement | null;
|
|
33
|
+
}) => void;
|
|
34
|
+
unregisterDock: (id: string) => void;
|
|
35
|
+
getDock: (id: string) => DockEntry | undefined;
|
|
36
|
+
/** Register a panel with its initial placement (once, at mount). */
|
|
37
|
+
registerPanel: (panelId: string, initial: PanelPlacement) => void;
|
|
38
|
+
unregisterPanel: (panelId: string) => void;
|
|
39
|
+
getPlacement: (panelId: string) => PanelPlacement | undefined;
|
|
40
|
+
setPlacement: (panelId: string, placement: PanelPlacement) => void;
|
|
41
|
+
/** Panels currently docked in `dockId`, in registration order (tab order). */
|
|
42
|
+
panelsInDock: (dockId: string) => string[];
|
|
43
|
+
activeInDock: (dockId: string) => string | undefined;
|
|
44
|
+
setActive: (dockId: string, panelId: string) => void;
|
|
45
|
+
/** Which dock (if any) contains the viewport point — used while dragging. */
|
|
46
|
+
findDockAt: (x: number, y: number) => string | null;
|
|
47
|
+
/** The dock currently highlighted as a drop target during a drag. */
|
|
48
|
+
hoverDock: string | null;
|
|
49
|
+
setHoverDock: (id: string | null) => void;
|
|
50
|
+
}
|
|
51
|
+
/** Read the enclosing {@link DockProvider}, or `null` when used standalone. */
|
|
52
|
+
export declare function useDockContext(): DockContextValue | null;
|
|
53
|
+
/**
|
|
54
|
+
* Coordinates a set of {@link FloatingPanel}s and {@link Dock}s: it owns each
|
|
55
|
+
* panel's placement (floating box vs. which dock), the per-dock tab order and
|
|
56
|
+
* active tab, and the drop-target hit-testing used while a panel is dragged.
|
|
57
|
+
*
|
|
58
|
+
* Wrap the region that contains your docks and panels in a `DockProvider`.
|
|
59
|
+
* `FloatingPanel` also works with no provider at all — it just becomes a plain
|
|
60
|
+
* standalone floating window with docking disabled.
|
|
61
|
+
*/
|
|
62
|
+
export declare function DockProvider({ children }: {
|
|
63
|
+
children: ReactNode;
|
|
64
|
+
}): import("react").JSX.Element;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=dock-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dock-context.d.ts","sourceRoot":"","sources":["../../../src/components/floating-panel/dock-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,6DAA6D;AAC7D,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,CAAC;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG,YAAY,CAAC,GACrC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvC,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,2EAA2E;IAC3E,OAAO,EAAE,MAAM,OAAO,GAAG,IAAI,CAAC;IAC9B,4CAA4C;IAC5C,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,iDAAiD;IACjD,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;IAClE,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE;QAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;QAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IACtG,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,CAAC;IAE/C,oEAAoE;IACpE,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAClE,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,cAAc,GAAG,SAAS,CAAC;IAC9D,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,KAAK,IAAI,CAAC;IAEnE,8EAA8E;IAC9E,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IAC3C,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACrD,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAErD,6EAA6E;IAC7E,UAAU,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACpD,qEAAqE;IACrE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAC3C;AAID,+EAA+E;AAC/E,wBAAgB,cAAc,IAAI,gBAAgB,GAAG,IAAI,CAExD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAuIjE"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as w } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useRef as z, useCallback as c, useMemo as F, useContext as G, createContext as J } from "react";
|
|
3
|
+
const H = J(null);
|
|
4
|
+
function N() {
|
|
5
|
+
return G(H);
|
|
6
|
+
}
|
|
7
|
+
function Q({ children: M }) {
|
|
8
|
+
const [D, f] = u({}), [s, i] = u({}), [k, d] = u([]), [v, m] = u({}), [b, R] = u(null), l = z({}), g = c((e, o) => {
|
|
9
|
+
l.current[e] = o, f((t) => t[e] ? t : { ...t, [e]: { id: e, getRect: o, tabBar: null, content: null } });
|
|
10
|
+
}, []), x = c(
|
|
11
|
+
(e, o) => {
|
|
12
|
+
f((t) => {
|
|
13
|
+
const n = t[e];
|
|
14
|
+
return !n || n.tabBar === o.tabBar && n.content === o.content ? t : { ...t, [e]: { ...n, ...o } };
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
[]
|
|
18
|
+
), P = c((e) => {
|
|
19
|
+
delete l.current[e], f((o) => {
|
|
20
|
+
if (!o[e]) return o;
|
|
21
|
+
const t = { ...o };
|
|
22
|
+
return delete t[e], t;
|
|
23
|
+
});
|
|
24
|
+
}, []), a = c((e) => D[e], [D]), C = c((e, o) => {
|
|
25
|
+
m((t) => t[e] === o ? t : { ...t, [e]: o });
|
|
26
|
+
}, []), A = c((e, o) => {
|
|
27
|
+
i((t) => t[e] ? t : { ...t, [e]: o }), d((t) => t.includes(e) ? t : [...t, e]), o.mode === "docked" && m((t) => t[o.dockId] ? t : { ...t, [o.dockId]: e });
|
|
28
|
+
}, []), B = c((e) => {
|
|
29
|
+
i((o) => {
|
|
30
|
+
if (!o[e]) return o;
|
|
31
|
+
const t = { ...o };
|
|
32
|
+
return delete t[e], t;
|
|
33
|
+
}), d((o) => o.filter((t) => t !== e));
|
|
34
|
+
}, []), h = c((e) => s[e], [s]), j = c((e, o) => {
|
|
35
|
+
i((t) => ({ ...t, [e]: o })), o.mode === "docked" && m((t) => ({ ...t, [o.dockId]: e }));
|
|
36
|
+
}, []), O = c(
|
|
37
|
+
(e) => k.filter((o) => {
|
|
38
|
+
const t = s[o];
|
|
39
|
+
return (t == null ? void 0 : t.mode) === "docked" && t.dockId === e;
|
|
40
|
+
}),
|
|
41
|
+
[k, s]
|
|
42
|
+
), S = c(
|
|
43
|
+
(e) => {
|
|
44
|
+
const o = k.filter((n) => {
|
|
45
|
+
const r = s[n];
|
|
46
|
+
return (r == null ? void 0 : r.mode) === "docked" && r.dockId === e;
|
|
47
|
+
}), t = v[e];
|
|
48
|
+
return t && o.includes(t) ? t : o[0];
|
|
49
|
+
},
|
|
50
|
+
[k, s, v]
|
|
51
|
+
), E = c((e, o) => {
|
|
52
|
+
for (const [t, n] of Object.entries(l.current)) {
|
|
53
|
+
const r = n();
|
|
54
|
+
if (r && e >= r.left && e <= r.right && o >= r.top && o <= r.bottom) return t;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}, []), q = F(
|
|
58
|
+
() => ({
|
|
59
|
+
registerDock: g,
|
|
60
|
+
updateDockEls: x,
|
|
61
|
+
unregisterDock: P,
|
|
62
|
+
getDock: a,
|
|
63
|
+
registerPanel: A,
|
|
64
|
+
unregisterPanel: B,
|
|
65
|
+
getPlacement: h,
|
|
66
|
+
setPlacement: j,
|
|
67
|
+
panelsInDock: O,
|
|
68
|
+
activeInDock: S,
|
|
69
|
+
setActive: C,
|
|
70
|
+
findDockAt: E,
|
|
71
|
+
hoverDock: b,
|
|
72
|
+
setHoverDock: R
|
|
73
|
+
}),
|
|
74
|
+
[
|
|
75
|
+
g,
|
|
76
|
+
x,
|
|
77
|
+
P,
|
|
78
|
+
a,
|
|
79
|
+
A,
|
|
80
|
+
B,
|
|
81
|
+
h,
|
|
82
|
+
j,
|
|
83
|
+
O,
|
|
84
|
+
S,
|
|
85
|
+
C,
|
|
86
|
+
E,
|
|
87
|
+
b
|
|
88
|
+
]
|
|
89
|
+
);
|
|
90
|
+
return /* @__PURE__ */ w(H.Provider, { value: q, children: M });
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
Q as DockProvider,
|
|
94
|
+
N as useDockContext
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=dock-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dock-context.js","sources":["../../../src/components/floating-panel/dock-context.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\n\n/** A floating window's on-screen box, in viewport pixels. */\nexport interface FloatingGeom {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/**\n * Where a panel currently lives: free-floating at a viewport box, or docked\n * (in-flow) inside a {@link Dock} identified by `dockId`.\n */\nexport type PanelPlacement =\n | ({ mode: 'floating' } & FloatingGeom)\n | { mode: 'docked'; dockId: string };\n\ninterface DockEntry {\n id: string;\n /** Live viewport rect of the dock's drop area (for hit-testing a drag). */\n getRect: () => DOMRect | null;\n /** Portal target for the dock's tab bar. */\n tabBar: HTMLElement | null;\n /** Portal target for the active panel's body. */\n content: HTMLElement | null;\n}\n\nexport interface DockContextValue {\n registerDock: (id: string, getRect: () => DOMRect | null) => void;\n updateDockEls: (id: string, els: { tabBar: HTMLElement | null; content: HTMLElement | null }) => void;\n unregisterDock: (id: string) => void;\n getDock: (id: string) => DockEntry | undefined;\n\n /** Register a panel with its initial placement (once, at mount). */\n registerPanel: (panelId: string, initial: PanelPlacement) => void;\n unregisterPanel: (panelId: string) => void;\n getPlacement: (panelId: string) => PanelPlacement | undefined;\n setPlacement: (panelId: string, placement: PanelPlacement) => void;\n\n /** Panels currently docked in `dockId`, in registration order (tab order). */\n panelsInDock: (dockId: string) => string[];\n activeInDock: (dockId: string) => string | undefined;\n setActive: (dockId: string, panelId: string) => void;\n\n /** Which dock (if any) contains the viewport point — used while dragging. */\n findDockAt: (x: number, y: number) => string | null;\n /** The dock currently highlighted as a drop target during a drag. */\n hoverDock: string | null;\n setHoverDock: (id: string | null) => void;\n}\n\nconst DockContext = createContext<DockContextValue | null>(null);\n\n/** Read the enclosing {@link DockProvider}, or `null` when used standalone. */\nexport function useDockContext(): DockContextValue | null {\n return useContext(DockContext);\n}\n\n/**\n * Coordinates a set of {@link FloatingPanel}s and {@link Dock}s: it owns each\n * panel's placement (floating box vs. which dock), the per-dock tab order and\n * active tab, and the drop-target hit-testing used while a panel is dragged.\n *\n * Wrap the region that contains your docks and panels in a `DockProvider`.\n * `FloatingPanel` also works with no provider at all — it just becomes a plain\n * standalone floating window with docking disabled.\n */\nexport function DockProvider({ children }: { children: ReactNode }) {\n const [docks, setDocks] = useState<Record<string, DockEntry>>({});\n const [placements, setPlacements] = useState<Record<string, PanelPlacement>>({});\n const [order, setOrder] = useState<string[]>([]);\n const [active, setActiveState] = useState<Record<string, string>>({});\n const [hoverDock, setHoverDock] = useState<string | null>(null);\n\n // getRect closures are stable per dock; keep them out of render state.\n const rects = useRef<Record<string, () => DOMRect | null>>({});\n\n const registerDock = useCallback((id: string, getRect: () => DOMRect | null) => {\n rects.current[id] = getRect;\n setDocks((d) => (d[id] ? d : { ...d, [id]: { id, getRect, tabBar: null, content: null } }));\n }, []);\n\n const updateDockEls = useCallback(\n (id: string, els: { tabBar: HTMLElement | null; content: HTMLElement | null }) => {\n setDocks((d) => {\n const cur = d[id];\n if (!cur) return d;\n if (cur.tabBar === els.tabBar && cur.content === els.content) return d;\n return { ...d, [id]: { ...cur, ...els } };\n });\n },\n [],\n );\n\n const unregisterDock = useCallback((id: string) => {\n delete rects.current[id];\n setDocks((d) => {\n if (!d[id]) return d;\n const next = { ...d };\n delete next[id];\n return next;\n });\n }, []);\n\n const getDock = useCallback((id: string) => docks[id], [docks]);\n\n const setActive = useCallback((dockId: string, panelId: string) => {\n setActiveState((a) => (a[dockId] === panelId ? a : { ...a, [dockId]: panelId }));\n }, []);\n\n const registerPanel = useCallback((panelId: string, initial: PanelPlacement) => {\n setPlacements((p) => (p[panelId] ? p : { ...p, [panelId]: initial }));\n setOrder((o) => (o.includes(panelId) ? o : [...o, panelId]));\n if (initial.mode === 'docked') {\n setActiveState((a) => (a[initial.dockId] ? a : { ...a, [initial.dockId]: panelId }));\n }\n }, []);\n\n const unregisterPanel = useCallback((panelId: string) => {\n setPlacements((p) => {\n if (!p[panelId]) return p;\n const next = { ...p };\n delete next[panelId];\n return next;\n });\n setOrder((o) => o.filter((x) => x !== panelId));\n }, []);\n\n const getPlacement = useCallback((panelId: string) => placements[panelId], [placements]);\n\n const setPlacement = useCallback((panelId: string, placement: PanelPlacement) => {\n setPlacements((p) => ({ ...p, [panelId]: placement }));\n if (placement.mode === 'docked') {\n // Docking a panel makes it the active tab of its target dock.\n setActiveState((a) => ({ ...a, [placement.dockId]: panelId }));\n }\n }, []);\n\n const panelsInDock = useCallback(\n (dockId: string) =>\n order.filter((pid) => {\n const pl = placements[pid];\n return pl?.mode === 'docked' && pl.dockId === dockId;\n }),\n [order, placements],\n );\n\n const activeInDock = useCallback(\n (dockId: string) => {\n const members = order.filter((pid) => {\n const pl = placements[pid];\n return pl?.mode === 'docked' && pl.dockId === dockId;\n });\n const cur = active[dockId];\n return cur && members.includes(cur) ? cur : members[0];\n },\n [order, placements, active],\n );\n\n const findDockAt = useCallback((x: number, y: number) => {\n for (const [id, getRect] of Object.entries(rects.current)) {\n const r = getRect();\n if (r && x >= r.left && x <= r.right && y >= r.top && y <= r.bottom) return id;\n }\n return null;\n }, []);\n\n const value = useMemo<DockContextValue>(\n () => ({\n registerDock,\n updateDockEls,\n unregisterDock,\n getDock,\n registerPanel,\n unregisterPanel,\n getPlacement,\n setPlacement,\n panelsInDock,\n activeInDock,\n setActive,\n findDockAt,\n hoverDock,\n setHoverDock,\n }),\n [\n registerDock,\n updateDockEls,\n unregisterDock,\n getDock,\n registerPanel,\n unregisterPanel,\n getPlacement,\n setPlacement,\n panelsInDock,\n activeInDock,\n setActive,\n findDockAt,\n hoverDock,\n ],\n );\n\n return <DockContext.Provider value={value}>{children}</DockContext.Provider>;\n}\n"],"names":["DockContext","createContext","useDockContext","useContext","DockProvider","children","docks","setDocks","useState","placements","setPlacements","order","setOrder","active","setActiveState","hoverDock","setHoverDock","rects","useRef","registerDock","useCallback","id","getRect","d","updateDockEls","els","cur","unregisterDock","next","getDock","setActive","dockId","panelId","a","registerPanel","initial","p","o","unregisterPanel","x","getPlacement","setPlacement","placement","panelsInDock","pid","pl","activeInDock","members","findDockAt","y","value","useMemo","jsx"],"mappings":";;AA4DA,MAAMA,IAAcC,EAAuC,IAAI;AAGxD,SAASC,IAA0C;AACxD,SAAOC,EAAWH,CAAW;AAC/B;AAWO,SAASI,EAAa,EAAE,UAAAC,KAAqC;AAClE,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAAoC,CAAA,CAAE,GAC1D,CAACC,GAAYC,CAAa,IAAIF,EAAyC,CAAA,CAAE,GACzE,CAACG,GAAOC,CAAQ,IAAIJ,EAAmB,CAAA,CAAE,GACzC,CAACK,GAAQC,CAAc,IAAIN,EAAiC,CAAA,CAAE,GAC9D,CAACO,GAAWC,CAAY,IAAIR,EAAwB,IAAI,GAGxDS,IAAQC,EAA6C,EAAE,GAEvDC,IAAeC,EAAY,CAACC,GAAYC,MAAkC;AAC9E,IAAAL,EAAM,QAAQI,CAAE,IAAIC,GACpBf,EAAS,CAACgB,MAAOA,EAAEF,CAAE,IAAIE,IAAI,EAAE,GAAGA,GAAG,CAACF,CAAE,GAAG,EAAE,IAAAA,GAAI,SAAAC,GAAS,QAAQ,MAAM,SAAS,KAAA,GAAS;AAAA,EAC5F,GAAG,CAAA,CAAE,GAECE,IAAgBJ;AAAA,IACpB,CAACC,GAAYI,MAAqE;AAChF,MAAAlB,EAAS,CAACgB,MAAM;AACd,cAAMG,IAAMH,EAAEF,CAAE;AAEhB,eADI,CAACK,KACDA,EAAI,WAAWD,EAAI,UAAUC,EAAI,YAAYD,EAAI,UAAgBF,IAC9D,EAAE,GAAGA,GAAG,CAACF,CAAE,GAAG,EAAE,GAAGK,GAAK,GAAGD,IAAI;AAAA,MACxC,CAAC;AAAA,IACH;AAAA,IACA,CAAA;AAAA,EAAC,GAGGE,IAAiBP,EAAY,CAACC,MAAe;AACjD,WAAOJ,EAAM,QAAQI,CAAE,GACvBd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MACA,gBAAAG;AAAA,MACA,SAAAE;AAAA,MACA,eAAAK;AAAA,MACA,iBAAAI;AAAA,MACA,cAAAE;AAAA,MACA,cAAAC;AAAA,MACA,cAAAE;AAAA,MACA,cAAAG;AAAA,MACA,WAAAhB;AAAA,MACA,YAAAkB;AAAA,MACA,WAAAjC;AAAA,MACA,cAAAC;AAAA,IAAA;AAAA,IAEF;AAAA,MACEG;AAAA,MACAK;AAAA,MACAG;AAAA,MACAE;AAAA,MACAK;AAAA,MACAI;AAAA,MACAE;AAAA,MACAC;AAAA,MACAE;AAAA,MACAG;AAAA,MACAhB;AAAA,MACAkB;AAAA,MACAjC;AAAA,IAAA;AAAA,EACF;AAGF,SAAO,gBAAAqC,EAACpD,EAAY,UAAZ,EAAqB,OAAAkD,GAAe,UAAA7C,EAAA,CAAS;AACvD;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface DockProps {
|
|
3
|
+
/** Stable id — the target `FloatingPanel.dockId` snaps to. */
|
|
4
|
+
id: string;
|
|
5
|
+
/**
|
|
6
|
+
* Shown when no panel is docked here. Give the dock a bounded height via
|
|
7
|
+
* `className` (e.g. `h-64` or `flex-1 min-h-0`) so it can hold a panel body.
|
|
8
|
+
*/
|
|
9
|
+
emptyState?: ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
/** Class for the tab strip (shown only when 2+ panels share the dock). */
|
|
12
|
+
tabBarClassName?: string;
|
|
13
|
+
/** Class for the panel-body region. */
|
|
14
|
+
contentClassName?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A docking target: a bounded region a {@link FloatingPanel} can snap into.
|
|
18
|
+
* When one panel is docked it fills the dock; when several share the dock they
|
|
19
|
+
* become tabs across the top and only the active one's body is shown.
|
|
20
|
+
*
|
|
21
|
+
* Must be rendered inside a {@link DockProvider} together with the panels that
|
|
22
|
+
* target it. While a panel is dragged over the dock it highlights as a drop
|
|
23
|
+
* target.
|
|
24
|
+
*/
|
|
25
|
+
export declare function Dock({ id, emptyState, className, tabBarClassName, contentClassName }: DockProps): import("react").JSX.Element;
|
|
26
|
+
//# sourceMappingURL=dock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dock.d.ts","sourceRoot":"","sources":["../../../src/components/floating-panel/dock.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAKpE,MAAM,WAAW,SAAS;IACxB,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uCAAuC;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,EAAE,SAAS,+BAgD/F"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsxs as k, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as n, useState as x, useEffect as v } from "react";
|
|
3
|
+
import { cn as s } from "../../lib/utils.js";
|
|
4
|
+
import { useDockContext as D } from "./dock-context.js";
|
|
5
|
+
function y({ id: r, emptyState: u, className: d, tabBarClassName: m, contentClassName: b }) {
|
|
6
|
+
const e = D(), c = n(null), l = n(null), a = n(null), [, g] = x(0);
|
|
7
|
+
v(() => {
|
|
8
|
+
if (e)
|
|
9
|
+
return e.registerDock(r, () => {
|
|
10
|
+
var t;
|
|
11
|
+
return ((t = c.current) == null ? void 0 : t.getBoundingClientRect()) ?? null;
|
|
12
|
+
}), e.updateDockEls(r, { tabBar: l.current, content: a.current }), g((t) => t + 1), () => e.unregisterDock(r);
|
|
13
|
+
}, [r]);
|
|
14
|
+
const i = (e == null ? void 0 : e.panelsInDock(r)) ?? [], h = i.length > 0, p = i.length > 1, f = (e == null ? void 0 : e.hoverDock) === r;
|
|
15
|
+
return /* @__PURE__ */ k(
|
|
16
|
+
"div",
|
|
17
|
+
{
|
|
18
|
+
ref: c,
|
|
19
|
+
"data-dock": r,
|
|
20
|
+
className: s(
|
|
21
|
+
"relative flex min-h-0 flex-col overflow-hidden rounded-lg border border-border bg-background transition-colors",
|
|
22
|
+
f && "border-primary ring-2 ring-primary/40",
|
|
23
|
+
d
|
|
24
|
+
),
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ o(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
ref: l,
|
|
30
|
+
className: s(
|
|
31
|
+
"flex shrink-0 items-center gap-1 overflow-x-auto border-b border-border bg-muted/40 px-1",
|
|
32
|
+
!p && "hidden",
|
|
33
|
+
m
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
/* @__PURE__ */ o("div", { ref: a, className: s("relative min-h-0 flex-1 overflow-hidden", b) }),
|
|
38
|
+
!h && /* @__PURE__ */ o("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center p-4 text-center text-xs text-muted-foreground", children: u ?? (f ? "Release to dock here" : "Drag a panel here to dock it") })
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
y as Dock
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=dock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dock.js","sources":["../../../src/components/floating-panel/dock.tsx"],"sourcesContent":["import { useEffect, useRef, useState, type ReactNode } from 'react';\n\nimport { cn } from '../../lib/utils';\nimport { useDockContext } from './dock-context';\n\nexport interface DockProps {\n /** Stable id — the target `FloatingPanel.dockId` snaps to. */\n id: string;\n /**\n * Shown when no panel is docked here. Give the dock a bounded height via\n * `className` (e.g. `h-64` or `flex-1 min-h-0`) so it can hold a panel body.\n */\n emptyState?: ReactNode;\n className?: string;\n /** Class for the tab strip (shown only when 2+ panels share the dock). */\n tabBarClassName?: string;\n /** Class for the panel-body region. */\n contentClassName?: string;\n}\n\n/**\n * A docking target: a bounded region a {@link FloatingPanel} can snap into.\n * When one panel is docked it fills the dock; when several share the dock they\n * become tabs across the top and only the active one's body is shown.\n *\n * Must be rendered inside a {@link DockProvider} together with the panels that\n * target it. While a panel is dragged over the dock it highlights as a drop\n * target.\n */\nexport function Dock({ id, emptyState, className, tabBarClassName, contentClassName }: DockProps) {\n const ctx = useDockContext();\n const rootRef = useRef<HTMLDivElement>(null);\n const tabBarRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const [, force] = useState(0);\n\n // Register the dock (rect for hit-testing) and publish its portal targets.\n useEffect(() => {\n if (!ctx) return;\n ctx.registerDock(id, () => rootRef.current?.getBoundingClientRect() ?? null);\n ctx.updateDockEls(id, { tabBar: tabBarRef.current, content: contentRef.current });\n force((n) => n + 1); // ensure panels see the mounted portal targets\n return () => ctx.unregisterDock(id);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [id]);\n\n const members = ctx?.panelsInDock(id) ?? [];\n const hasPanels = members.length > 0;\n const showTabs = members.length > 1;\n const isDropTarget = ctx?.hoverDock === id;\n\n return (\n <div\n ref={rootRef}\n data-dock={id}\n className={cn(\n 'relative flex min-h-0 flex-col overflow-hidden rounded-lg border border-border bg-background transition-colors',\n isDropTarget && 'border-primary ring-2 ring-primary/40',\n className,\n )}\n >\n <div\n ref={tabBarRef}\n className={cn(\n 'flex shrink-0 items-center gap-1 overflow-x-auto border-b border-border bg-muted/40 px-1',\n !showTabs && 'hidden',\n tabBarClassName,\n )}\n />\n <div ref={contentRef} className={cn('relative min-h-0 flex-1 overflow-hidden', contentClassName)} />\n {!hasPanels && (\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-center p-4 text-center text-xs text-muted-foreground\">\n {emptyState ?? (isDropTarget ? 'Release to dock here' : 'Drag a panel here to dock it')}\n </div>\n )}\n </div>\n );\n}\n"],"names":["Dock","id","emptyState","className","tabBarClassName","contentClassName","ctx","useDockContext","rootRef","useRef","tabBarRef","contentRef","force","useState","useEffect","_a","n","members","hasPanels","showTabs","isDropTarget","jsxs","cn","jsx"],"mappings":";;;;AA6BO,SAASA,EAAK,EAAE,IAAAC,GAAI,YAAAC,GAAY,WAAAC,GAAW,iBAAAC,GAAiB,kBAAAC,KAA+B;AAChG,QAAMC,IAAMC,EAAA,GACNC,IAAUC,EAAuB,IAAI,GACrCC,IAAYD,EAAuB,IAAI,GACvCE,IAAaF,EAAuB,IAAI,GACxC,GAAGG,CAAK,IAAIC,EAAS,CAAC;AAG5B,EAAAC,EAAU,MAAM;AACd,QAAKR;AACL,aAAAA,EAAI,aAAaL,GAAI,MAAA;;AAAM,iBAAAc,IAAAP,EAAQ,YAAR,gBAAAO,EAAiB,4BAA2B;AAAA,OAAI,GAC3ET,EAAI,cAAcL,GAAI,EAAE,QAAQS,EAAU,SAAS,SAASC,EAAW,SAAS,GAChFC,EAAM,CAACI,MAAMA,IAAI,CAAC,GACX,MAAMV,EAAI,eAAeL,CAAE;AAAA,EAEpC,GAAG,CAACA,CAAE,CAAC;AAEP,QAAMgB,KAAUX,KAAA,gBAAAA,EAAK,aAAaL,OAAO,CAAA,GACnCiB,IAAYD,EAAQ,SAAS,GAC7BE,IAAWF,EAAQ,SAAS,GAC5BG,KAAed,KAAA,gBAAAA,EAAK,eAAcL;AAExC,SACE,gBAAAoB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAKb;AAAA,MACL,aAAWP;AAAA,MACX,WAAWqB;AAAA,QACT;AAAA,QACAF,KAAgB;AAAA,QAChBjB;AAAA,MAAA;AAAA,MAGF,UAAA;AAAA,QAAA,gBAAAoB;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,KAAKb;AAAA,YACL,WAAWY;AAAA,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