@powerhousedao/document-engineering 1.40.1 → 1.40.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/table/components/focus-trap.d.ts +25 -0
- package/dist/src/table/components/focus-trap.d.ts.map +1 -0
- package/dist/src/table/components/focus-trap.js +46 -0
- package/dist/src/table/components/focus-trap.js.map +1 -0
- package/dist/src/table/components/table-focus-trap.js +1 -1
- package/dist/src/table/components/table-focus-trap.js.map +1 -1
- package/dist/src/ui/components/confirm/confirm.js +1 -1
- package/dist/src/ui/components/confirm/confirm.js.map +1 -1
- package/dist/src/ui/components/confirm/imperative-confirm.d.ts +25 -0
- package/dist/src/ui/components/confirm/imperative-confirm.d.ts.map +1 -0
- package/dist/src/ui/components/confirm/imperative-confirm.js +55 -0
- package/dist/src/ui/components/confirm/imperative-confirm.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Options } from 'focus-trap';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Thin React wrapper around the ESM `focus-trap` package, providing the subset of
|
|
5
|
+
* `focus-trap-react`'s API used by this package (`active` + `focusTrapOptions`).
|
|
6
|
+
* `focus-trap-react` is published as CommonJS and calls `require('react')`, which breaks
|
|
7
|
+
* in consumers that bundle this package's ESM output with `react` marked as external.
|
|
8
|
+
*
|
|
9
|
+
* Like `focus-trap-react`, the single child element is cloned and receives a ref so
|
|
10
|
+
* the focus trap targets the child directly without adding a wrapper DOM node.
|
|
11
|
+
*/
|
|
12
|
+
export interface FocusTrapProps {
|
|
13
|
+
active: boolean;
|
|
14
|
+
focusTrapOptions?: Options;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
type MutableRefObject<T> = {
|
|
18
|
+
current: T;
|
|
19
|
+
};
|
|
20
|
+
type ChildRef = ((instance: HTMLElement | null) => void) | MutableRefObject<HTMLElement | null> | null | undefined;
|
|
21
|
+
export declare const FocusTrap: ({ active, focusTrapOptions, children }: FocusTrapProps) => import("react").ReactElement<{
|
|
22
|
+
ref?: ChildRef;
|
|
23
|
+
}, string | import("react").JSXElementConstructor<any>>;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=focus-trap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-trap.d.ts","sourceRoot":"","sources":["../../../../src/table/components/focus-trap.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,OAAO,EAAmB,MAAM,YAAY,CAAA;AAC/F,OAAO,EAA0C,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAA;AAEjG;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,CAAA;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,KAAK,gBAAgB,CAAC,CAAC,IAAI;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,CAAA;AACzC,KAAK,QAAQ,GAAG,CAAC,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;AAElH,eAAO,MAAM,SAAS,GAAI,wCAAwC,cAAc;UAgClD,QAAQ;uDAerC,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createFocusTrap } from 'focus-trap';
|
|
2
|
+
import { Children, cloneElement, isValidElement, useEffect, useRef } from 'react';
|
|
3
|
+
export const FocusTrap = ({ active, focusTrapOptions, children }) => {
|
|
4
|
+
const elementRef = useRef(null);
|
|
5
|
+
const trapRef = useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (!active) {
|
|
8
|
+
if (trapRef.current) {
|
|
9
|
+
trapRef.current.deactivate();
|
|
10
|
+
trapRef.current = null;
|
|
11
|
+
}
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const node = elementRef.current;
|
|
15
|
+
if (!node)
|
|
16
|
+
return;
|
|
17
|
+
const trap = createFocusTrap(node, focusTrapOptions);
|
|
18
|
+
trapRef.current = trap;
|
|
19
|
+
trap.activate();
|
|
20
|
+
return () => {
|
|
21
|
+
trap.deactivate();
|
|
22
|
+
if (trapRef.current === trap) {
|
|
23
|
+
trapRef.current = null;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
// focus-trap-react only (re)creates the trap on active toggle; options are read at
|
|
27
|
+
// creation time only, matching that behavior.
|
|
28
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
+
}, [active]);
|
|
30
|
+
const child = Children.only(children);
|
|
31
|
+
if (!isValidElement(child)) {
|
|
32
|
+
throw new Error('FocusTrap: children must be a single valid React element.');
|
|
33
|
+
}
|
|
34
|
+
const originalRef = child.props.ref;
|
|
35
|
+
const mergedRef = (node) => {
|
|
36
|
+
elementRef.current = node;
|
|
37
|
+
if (typeof originalRef === 'function') {
|
|
38
|
+
originalRef(node);
|
|
39
|
+
}
|
|
40
|
+
else if (originalRef && typeof originalRef === 'object' && 'current' in originalRef) {
|
|
41
|
+
originalRef.current = node;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return cloneElement(child, { ref: mergedRef });
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=focus-trap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-trap.js","sourceRoot":"","sources":["../../../../src/table/components/focus-trap.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqD,eAAe,EAAE,MAAM,YAAY,CAAA;AAC/F,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAkB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAoBjG,MAAM,CAAC,MAAM,SAAS,GAAG,CA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CAAC,OAAO,GAAG,IAAI,CAAA;QACzB,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;YACtC,WAAW,CAAC,IAAI,CAAC,CAAA;QACnB,CAAC;aAAM,IAAI,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,SAAS,IAAI,WAAW,EAAE,CAAC;YACtF,WAAW,CAAC,OAAO,GAAG,IAAI,CAAA;QAC5B,CAAC;IACH,CAAC,CAAA;IAED,OAAO,YAAY,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAA;AAChD,CAAC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { FocusTrap } from 'focus-trap
|
|
2
|
+
import { FocusTrap } from './focus-trap.js';
|
|
3
3
|
import { useRef } from 'react';
|
|
4
4
|
import { useOnClickOutside } from 'usehooks-ts';
|
|
5
5
|
import { useInternalTableState } from './table-provider/table-provider.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-focus-trap.js","sourceRoot":"","sources":["../../../../src/table/components/table-focus-trap.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"table-focus-trap.js","sourceRoot":"","sources":["../../../../src/table/components/table-focus-trap.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAkB,MAAM,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAE1E,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE;IACrE,MAAM,EACJ,KAAK,EAAE,EAAE,iBAAiB,EAAE,EAC5B,GAAG,GACJ,GAAG,qBAAqB,EAAE,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C3B,gBAAgB,EAAE;gBAChB,iBAAiB,EAAE,IAAI;gBACvB,iBAAiB,EAAE,KAAK;aACzB,YAEA,QAAQ,GACC,GACR,CACP,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { confirmable, createConfirmation } from '
|
|
2
|
+
import { confirmable, createConfirmation } from './imperative-confirm.js';
|
|
3
3
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from './alert-dialog.js';
|
|
4
4
|
const ConfirmDialog = ({ show, proceed, title, description, confirmLabel = 'Continue', cancelLabel = 'Cancel', confirmVariant = 'default', cancelVariant = 'secondary', }) => {
|
|
5
5
|
return (_jsx(AlertDialog, { open: show, children: _jsxs(AlertDialogContent, { className: show ? 'animate-in' : 'animate-out', onOpenAutoFocus: (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm.js","sourceRoot":"","sources":["../../../../../src/ui/components/confirm/confirm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAA2B,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"confirm.js","sourceRoot":"","sources":["../../../../../src/ui/components/confirm/confirm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAA2B,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAClG,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,mBAAmB,CAAA;AAa1B,MAAM,aAAa,GAAG,CAAC,EACrB,IAAI,EACJ,OAAO,EACP,KAAK,EACL,WAAW,EACX,YAAY,GAAG,UAAU,EACzB,WAAW,GAAG,QAAQ,EACtB,cAAc,GAAG,SAAS,EAC1B,aAAa,GAAG,WAAW,GACiB,EAAE,EAAE;IAChD,OAAO,CACL,KAAC,WAAW,IAAC,IAAI,EAAE,IAAI,YACrB,MAAC,kBAAkB,IACjB,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,EAC9C,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE;gBACrB,CAAC,CAAC,cAAc,EAAE,CAAA;YACpB,CAAC,aAED,MAAC,iBAAiB,eAChB,KAAC,gBAAgB,cAAE,KAAK,GAAoB,EAC5C,KAAC,sBAAsB,cAAE,WAAW,GAA0B,IAC5C,EACpB,MAAC,iBAAiB,eAChB,KAAC,iBAAiB,IAChB,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,GAAG,EAAE;gCACZ,OAAO,CAAC,KAAK,CAAC,CAAA;4BAChB,CAAC,YAEA,WAAW,GACM,EACpB,KAAC,iBAAiB,IAChB,SAAS,QACT,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,GAAG,EAAE;gCACZ,OAAO,CAAC,IAAI,CAAC,CAAA;4BACf,CAAC,YAEA,YAAY,GACK,IACF,IACD,GACT,CACf,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,kBAAkB,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ComponentType } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* ESM-native reimplementation of the minimal `react-confirm` surface used by this package.
|
|
4
|
+
* `react-confirm` is published as CommonJS and calls `require('react')`, which breaks in
|
|
5
|
+
* consumers that bundle this package's ESM output with `react` marked as external.
|
|
6
|
+
* This module is API-compatible with react-confirm's default `createConfirmation`
|
|
7
|
+
* (DOM-tree mounter) for the subset of functionality used by `confirm.tsx`.
|
|
8
|
+
*/
|
|
9
|
+
export type ConfirmDialogProps<P, R> = {
|
|
10
|
+
dismiss: () => void;
|
|
11
|
+
proceed: (value: R) => void;
|
|
12
|
+
cancel: (value?: unknown) => void;
|
|
13
|
+
show: boolean;
|
|
14
|
+
} & P;
|
|
15
|
+
export type ConfirmDialog<P, R> = ComponentType<ConfirmDialogProps<P, R>>;
|
|
16
|
+
type ConfirmableInjected<R> = {
|
|
17
|
+
dispose: () => void;
|
|
18
|
+
resolve: (value: R) => void;
|
|
19
|
+
reject: (value?: unknown) => void;
|
|
20
|
+
};
|
|
21
|
+
type ConfirmableComponent<P, R> = ComponentType<P & ConfirmableInjected<R>>;
|
|
22
|
+
export declare const confirmable: <P, R>(Component: ConfirmDialog<P, R>) => ConfirmableComponent<P, R>;
|
|
23
|
+
export declare const createConfirmation: <P, R>(Component: ConfirmableComponent<P, R>, unmountDelay?: number, mountingNode?: HTMLElement) => ((props: P) => Promise<R>);
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=imperative-confirm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imperative-confirm.d.ts","sourceRoot":"","sources":["../../../../../src/ui/components/confirm/imperative-confirm.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAY,MAAM,OAAO,CAAA;AAGpD;;;;;;GAMG;AAEH,MAAM,MAAM,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;IACrC,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;IAC3B,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACjC,IAAI,EAAE,OAAO,CAAA;CACd,GAAG,CAAC,CAAA;AAEL,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI,aAAa,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAEzE,KAAK,mBAAmB,CAAC,CAAC,IAAI;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;IAC3B,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CAClC,CAAA;AAED,KAAK,oBAAoB,CAAC,CAAC,EAAE,CAAC,IAAI,aAAa,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAA;AAE3E,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,CAAC,EAAE,WAAW,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAsB3F,CAAA;AAKD,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,CAAC,EACrC,WAAW,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,EACrC,eAAc,MAAiC,EAC/C,eAAe,WAAW,KACzB,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAsC3B,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { createRoot } from 'react-dom/client';
|
|
4
|
+
export const confirmable = (Component) => {
|
|
5
|
+
const Confirmable = ({ dispose, reject, resolve, ...other }) => {
|
|
6
|
+
const [show, setShow] = useState(true);
|
|
7
|
+
const dismiss = () => {
|
|
8
|
+
setShow(false);
|
|
9
|
+
dispose();
|
|
10
|
+
};
|
|
11
|
+
const cancel = (value) => {
|
|
12
|
+
setShow(false);
|
|
13
|
+
reject(value);
|
|
14
|
+
};
|
|
15
|
+
const proceed = (value) => {
|
|
16
|
+
setShow(false);
|
|
17
|
+
resolve(value);
|
|
18
|
+
};
|
|
19
|
+
return _jsx(Component, { cancel: cancel, dismiss: dismiss, proceed: proceed, show: show, ...other });
|
|
20
|
+
};
|
|
21
|
+
return Confirmable;
|
|
22
|
+
};
|
|
23
|
+
const DEFAULT_UNMOUNT_DELAY_MS = 1000;
|
|
24
|
+
export const createConfirmation = (Component, unmountDelay = DEFAULT_UNMOUNT_DELAY_MS, mountingNode) => {
|
|
25
|
+
return (props) => {
|
|
26
|
+
let record;
|
|
27
|
+
const dispose = () => {
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
if (!record)
|
|
30
|
+
return;
|
|
31
|
+
const { wrapper, root } = record;
|
|
32
|
+
root.unmount();
|
|
33
|
+
if (wrapper.parentNode) {
|
|
34
|
+
wrapper.parentNode.removeChild(wrapper);
|
|
35
|
+
}
|
|
36
|
+
record = undefined;
|
|
37
|
+
}, unmountDelay);
|
|
38
|
+
};
|
|
39
|
+
const promise = new Promise((resolve, reject) => {
|
|
40
|
+
const host = mountingNode ?? document.body;
|
|
41
|
+
const wrapper = host.appendChild(document.createElement('div'));
|
|
42
|
+
const root = createRoot(wrapper);
|
|
43
|
+
record = { wrapper, root };
|
|
44
|
+
root.render(_jsx(Component, { ...props, dispose: dispose, resolve: resolve, reject: reject }));
|
|
45
|
+
});
|
|
46
|
+
return promise.then((result) => {
|
|
47
|
+
dispose();
|
|
48
|
+
return result;
|
|
49
|
+
}, (error) => {
|
|
50
|
+
dispose();
|
|
51
|
+
return Promise.reject(error);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=imperative-confirm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imperative-confirm.js","sourceRoot":"","sources":["../../../../../src/ui/components/confirm/imperative-confirm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsB,QAAQ,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,EAAa,UAAU,EAAE,MAAM,kBAAkB,CAAA;AA2BxD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAO,SAA8B,EAA8B,EAAE;IAC9F,MAAM,WAAW,GAAG,CAAC,EAAE,OAAO,EAAE,MA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