@forgeax/app-shell 0.42.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react.d.ts +20 -1
- package/dist/react.js +112 -0
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -51,6 +51,25 @@ interface PointerDragSessionOptions<Session> {
|
|
|
51
51
|
readonly stopPropagation?: boolean;
|
|
52
52
|
readonly draggingClassName?: string;
|
|
53
53
|
}
|
|
54
|
+
type ThresholdPointerDragFinishReason = 'pointerup' | 'pointercancel' | 'cancel' | 'dispose' | 'error';
|
|
55
|
+
interface ThresholdPointerDragSessionOptions<Session> {
|
|
56
|
+
readonly target: Window;
|
|
57
|
+
readonly pointerId: number;
|
|
58
|
+
readonly startX: number;
|
|
59
|
+
readonly startY: number;
|
|
60
|
+
readonly threshold: number;
|
|
61
|
+
readonly begin: (event: globalThis.PointerEvent) => Session | null;
|
|
62
|
+
readonly move: (session: Session, event: globalThis.PointerEvent) => void;
|
|
63
|
+
readonly end?: (session: Session, reason: ThresholdPointerDragFinishReason) => void;
|
|
64
|
+
readonly onSettled?: (reason: ThresholdPointerDragFinishReason, started: boolean) => void;
|
|
65
|
+
readonly registerCancel?: (cancel: () => void) => void | (() => void);
|
|
66
|
+
}
|
|
67
|
+
interface ThresholdPointerDragSession {
|
|
68
|
+
cancel(): void;
|
|
69
|
+
dispose(): void;
|
|
70
|
+
}
|
|
71
|
+
/** Own one post-pointerdown threshold arm and its global listener lifecycle. */
|
|
72
|
+
declare function installThresholdPointerDragSession<Session>(options: ThresholdPointerDragSessionOptions<Session>): ThresholdPointerDragSession;
|
|
54
73
|
/** Own one imperative pointer-capture drag session and its balanced teardown. */
|
|
55
74
|
declare function installPointerDragSession<Session>(options: PointerDragSessionOptions<Session>): () => void;
|
|
56
75
|
type AnchoredResizeDirection = 'subtract' | 'add';
|
|
@@ -214,4 +233,4 @@ interface ShellSlotProps extends HTMLAttributes<HTMLElement> {
|
|
|
214
233
|
/** Structural shell marker that preserves the caller's semantic element. */
|
|
215
234
|
declare function ShellSlot({ as, name, ...props }: ShellSlotProps): ReactElement;
|
|
216
235
|
|
|
217
|
-
export { type AnchoredResizeDirection, AnchoredResizeHandle, type AnchoredResizeHandleProps, type AnchoredResizeSession, DetachedPanelBoundary, type DetachedPanelBoundaryProps, DetachedSurfaceFrame, type DetachedSurfaceFrameProps, DetachedSurfaceStatus, type DetachedSurfaceStatusProps, type DetachedSurfaceStatusTone, type DockLayoutControlBinding, type DockLayoutControlBindingOptions, DockLayoutMenu, type DockLayoutMenuPanel, type DockLayoutMenuProps, FloatingMenu, type FloatingMenuAnchor, type FloatingMenuPoint, type FloatingMenuProps, type PanelContentPadding, type PanelContentPolicy, type PanelContentScroll, type PanelContentTone, PanelEmptyState, type PanelEmptyStateProps, PanelSurface, type PanelSurfaceProps, type PersistentSizeStorage, type PersistentSizeStore, type PersistentSizeStoreOptions, type PersistentSizeUpdate, type PointerDragFinishReason, type PointerDragSessionOptions, ResizeHandle, type ResizeHandleProps, ShellSlot, type ShellSlotElement, type ShellSlotProps, SlotDebugOverlay, SurfacePlaceholder, type SurfacePlaceholderProps, SurfaceRegion, type SurfaceRegionProps, applyAnchoredResizeDelta, beginAnchoredResize, createPersistentSizeStore, hashSlotHue, installPointerDragSession, isSlotDebugEnabled, useDockLayoutControlBinding, useLocalSize, usePersistentSizeStore };
|
|
236
|
+
export { type AnchoredResizeDirection, AnchoredResizeHandle, type AnchoredResizeHandleProps, type AnchoredResizeSession, DetachedPanelBoundary, type DetachedPanelBoundaryProps, DetachedSurfaceFrame, type DetachedSurfaceFrameProps, DetachedSurfaceStatus, type DetachedSurfaceStatusProps, type DetachedSurfaceStatusTone, type DockLayoutControlBinding, type DockLayoutControlBindingOptions, DockLayoutMenu, type DockLayoutMenuPanel, type DockLayoutMenuProps, FloatingMenu, type FloatingMenuAnchor, type FloatingMenuPoint, type FloatingMenuProps, type PanelContentPadding, type PanelContentPolicy, type PanelContentScroll, type PanelContentTone, PanelEmptyState, type PanelEmptyStateProps, PanelSurface, type PanelSurfaceProps, type PersistentSizeStorage, type PersistentSizeStore, type PersistentSizeStoreOptions, type PersistentSizeUpdate, type PointerDragFinishReason, type PointerDragSessionOptions, ResizeHandle, type ResizeHandleProps, ShellSlot, type ShellSlotElement, type ShellSlotProps, SlotDebugOverlay, SurfacePlaceholder, type SurfacePlaceholderProps, SurfaceRegion, type SurfaceRegionProps, type ThresholdPointerDragFinishReason, type ThresholdPointerDragSession, type ThresholdPointerDragSessionOptions, applyAnchoredResizeDelta, beginAnchoredResize, createPersistentSizeStore, hashSlotHue, installPointerDragSession, installThresholdPointerDragSession, isSlotDebugEnabled, useDockLayoutControlBinding, useLocalSize, usePersistentSizeStore };
|
package/dist/react.js
CHANGED
|
@@ -723,6 +723,117 @@ function acquireElementClassLease(element, tokens) {
|
|
|
723
723
|
if (records?.size === 0) elementClassLeases.delete(element);
|
|
724
724
|
};
|
|
725
725
|
}
|
|
726
|
+
function installThresholdPointerDragSession(options) {
|
|
727
|
+
const threshold = Number.isFinite(options.threshold) ? Math.max(0, options.threshold) : 0;
|
|
728
|
+
let disposed = false;
|
|
729
|
+
let settled = false;
|
|
730
|
+
let settledReason = null;
|
|
731
|
+
let starting = false;
|
|
732
|
+
let active = null;
|
|
733
|
+
let unregisterCancel = null;
|
|
734
|
+
const removeListeners = () => {
|
|
735
|
+
options.target.removeEventListener("pointermove", onPointerMove, true);
|
|
736
|
+
options.target.removeEventListener("pointerup", onPointerFinish, true);
|
|
737
|
+
options.target.removeEventListener("pointercancel", onPointerFinish, true);
|
|
738
|
+
};
|
|
739
|
+
const releaseCancelRegistration = () => {
|
|
740
|
+
const unregister = unregisterCancel;
|
|
741
|
+
unregisterCancel = null;
|
|
742
|
+
try {
|
|
743
|
+
unregister?.();
|
|
744
|
+
} catch {
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
const settle = (reason) => {
|
|
748
|
+
if (settled) return;
|
|
749
|
+
settled = true;
|
|
750
|
+
settledReason = reason;
|
|
751
|
+
removeListeners();
|
|
752
|
+
releaseCancelRegistration();
|
|
753
|
+
const current = active;
|
|
754
|
+
active = null;
|
|
755
|
+
if (current !== null) {
|
|
756
|
+
try {
|
|
757
|
+
options.end?.(current, reason);
|
|
758
|
+
} catch {
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
try {
|
|
762
|
+
options.onSettled?.(reason, current !== null);
|
|
763
|
+
} catch {
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
function onPointerMove(event) {
|
|
767
|
+
if (settled || event.pointerId !== options.pointerId) return;
|
|
768
|
+
if (active === null) {
|
|
769
|
+
if (starting) return;
|
|
770
|
+
if (Math.hypot(event.clientX - options.startX, event.clientY - options.startY) < threshold) return;
|
|
771
|
+
starting = true;
|
|
772
|
+
let candidate;
|
|
773
|
+
try {
|
|
774
|
+
candidate = options.begin(event);
|
|
775
|
+
} catch {
|
|
776
|
+
starting = false;
|
|
777
|
+
settle("error");
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
starting = false;
|
|
781
|
+
if (candidate === null) {
|
|
782
|
+
settle("cancel");
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
if (settled) {
|
|
786
|
+
try {
|
|
787
|
+
options.end?.(candidate, settledReason ?? "dispose");
|
|
788
|
+
} catch {
|
|
789
|
+
}
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
active = candidate;
|
|
793
|
+
}
|
|
794
|
+
const current = active;
|
|
795
|
+
if (current === null) return;
|
|
796
|
+
try {
|
|
797
|
+
options.move(current, event);
|
|
798
|
+
} catch {
|
|
799
|
+
settle("error");
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
function onPointerFinish(event) {
|
|
803
|
+
if (settled || event.pointerId !== options.pointerId) return;
|
|
804
|
+
settle(event.type === "pointercancel" ? "pointercancel" : "pointerup");
|
|
805
|
+
}
|
|
806
|
+
options.target.addEventListener("pointermove", onPointerMove, true);
|
|
807
|
+
options.target.addEventListener("pointerup", onPointerFinish, true);
|
|
808
|
+
options.target.addEventListener("pointercancel", onPointerFinish, true);
|
|
809
|
+
if (options.registerCancel) {
|
|
810
|
+
let registered;
|
|
811
|
+
try {
|
|
812
|
+
registered = options.registerCancel(() => settle("cancel"));
|
|
813
|
+
} catch {
|
|
814
|
+
settle("error");
|
|
815
|
+
registered = void 0;
|
|
816
|
+
}
|
|
817
|
+
if (registered) {
|
|
818
|
+
if (settled) {
|
|
819
|
+
try {
|
|
820
|
+
registered();
|
|
821
|
+
} catch {
|
|
822
|
+
}
|
|
823
|
+
} else {
|
|
824
|
+
unregisterCancel = registered;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
return {
|
|
829
|
+
cancel: () => settle("cancel"),
|
|
830
|
+
dispose: () => {
|
|
831
|
+
if (disposed) return;
|
|
832
|
+
disposed = true;
|
|
833
|
+
settle("dispose");
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
}
|
|
726
837
|
function installPointerDragSession(options) {
|
|
727
838
|
const { element } = options;
|
|
728
839
|
let disposed = false;
|
|
@@ -1324,6 +1435,7 @@ export {
|
|
|
1324
1435
|
createPersistentSizeStore,
|
|
1325
1436
|
hashSlotHue,
|
|
1326
1437
|
installPointerDragSession,
|
|
1438
|
+
installThresholdPointerDragSession,
|
|
1327
1439
|
isSlotDebugEnabled,
|
|
1328
1440
|
useDockLayoutControlBinding,
|
|
1329
1441
|
useLocalSize,
|