@lerx/promise-modal 0.2.3 → 0.2.4
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/index.cjs +15 -9
- package/dist/index.mjs +15 -9
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -11,7 +11,7 @@ const styleManager = require('@winglet/style-utils/styleManager');
|
|
|
11
11
|
const reactDom = require('react-dom');
|
|
12
12
|
const array = require('@winglet/common-utils/array');
|
|
13
13
|
const hoc = require('@winglet/react-utils/hoc');
|
|
14
|
-
const
|
|
14
|
+
const classNames = require('@winglet/style-utils/classNames');
|
|
15
15
|
const filter = require('@winglet/common-utils/filter');
|
|
16
16
|
const render = require('@winglet/react-utils/render');
|
|
17
17
|
const console = require('@winglet/common-utils/console');
|
|
@@ -676,12 +676,15 @@ const BackgroundFrame = ({ modalId, onChangeOrder, }) => {
|
|
|
676
676
|
event.stopPropagation();
|
|
677
677
|
}, [modal, onClose]);
|
|
678
678
|
const Background = react.useMemo(() => modal?.BackgroundComponent || BackgroundComponent, [BackgroundComponent, modal]);
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
return (jsxRuntime.jsx("div", { className: styleUtils.cx(background, {
|
|
679
|
+
const className = react.useMemo(() => modal
|
|
680
|
+
? classNames.cx(background, {
|
|
682
681
|
[active$1]: modal.closeOnBackdropClick && modal.visible,
|
|
683
682
|
[visible$1]: modal.manualDestroy ? modal.alive : modal.visible,
|
|
684
|
-
})
|
|
683
|
+
})
|
|
684
|
+
: undefined, [modal]);
|
|
685
|
+
if (!modal)
|
|
686
|
+
return null;
|
|
687
|
+
return (jsxRuntime.jsx("div", { className: className, onClick: handleClose, children: Background && (jsxRuntime.jsx(Background, { id: modal.id, type: modal.type, alive: modal.alive, visible: modal.visible, initiator: modal.initiator, manualDestroy: modal.manualDestroy, closeOnBackdropClick: modal.closeOnBackdropClick, background: modal.background, onChange: onChange, onConfirm: onConfirm, onClose: onClose, onDestroy: onDestroy, onChangeOrder: onChangeOrder, context: userDefinedContext })) }));
|
|
685
688
|
};
|
|
686
689
|
|
|
687
690
|
const AlertInner = react.memo(({ modal, handlers }) => {
|
|
@@ -790,12 +793,15 @@ const ForegroundFrame = ({ modalId, onChangeOrder, }) => {
|
|
|
790
793
|
const { context: userDefinedContext } = useUserDefinedContext();
|
|
791
794
|
const { modal, onChange, onConfirm, onClose, onDestroy } = useModal(modalId);
|
|
792
795
|
const Foreground = react.useMemo(() => modal?.ForegroundComponent || ForegroundComponent, [ForegroundComponent, modal]);
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
return (jsxRuntime.jsx("div", { className: styleUtils.cx(foreground, {
|
|
796
|
+
const className = react.useMemo(() => modal
|
|
797
|
+
? classNames.cx(foreground, {
|
|
796
798
|
[active]: modal.visible,
|
|
797
799
|
[visible]: modal.manualDestroy ? modal.alive : modal.visible,
|
|
798
|
-
})
|
|
800
|
+
})
|
|
801
|
+
: undefined, [modal]);
|
|
802
|
+
if (!modal)
|
|
803
|
+
return null;
|
|
804
|
+
return (jsxRuntime.jsx("div", { className: className, children: jsxRuntime.jsxs(Foreground, { id: modal.id, type: modal.type, alive: modal.alive, visible: modal.visible, initiator: modal.initiator, manualDestroy: modal.manualDestroy, closeOnBackdropClick: modal.closeOnBackdropClick, background: modal.background, onChange: onChange, onConfirm: onConfirm, onClose: onClose, onDestroy: onDestroy, onChangeOrder: onChangeOrder, context: userDefinedContext, children: [modal.type === 'alert' && (jsxRuntime.jsx(AlertInner, { modal: modal, handlers: { onConfirm } })), modal.type === 'confirm' && (jsxRuntime.jsx(ConfirmInner, { modal: modal, handlers: { onConfirm, onClose } })), modal.type === 'prompt' && (jsxRuntime.jsx(PromptInner, { modal: modal, handlers: { onChange, onConfirm, onClose } }))] }) }));
|
|
799
805
|
};
|
|
800
806
|
|
|
801
807
|
const useSubscribeModal = (modal) => {
|
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { styleManagerFactory, destroyScope } from '@winglet/style-utils/styleMan
|
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
10
10
|
import { map } from '@winglet/common-utils/array';
|
|
11
11
|
import { withErrorBoundary } from '@winglet/react-utils/hoc';
|
|
12
|
-
import { cx } from '@winglet/style-utils';
|
|
12
|
+
import { cx } from '@winglet/style-utils/classNames';
|
|
13
13
|
import { isString, isFunction } from '@winglet/common-utils/filter';
|
|
14
14
|
import { renderComponent } from '@winglet/react-utils/render';
|
|
15
15
|
import { printError } from '@winglet/common-utils/console';
|
|
@@ -674,12 +674,15 @@ const BackgroundFrame = ({ modalId, onChangeOrder, }) => {
|
|
|
674
674
|
event.stopPropagation();
|
|
675
675
|
}, [modal, onClose]);
|
|
676
676
|
const Background = useMemo(() => modal?.BackgroundComponent || BackgroundComponent, [BackgroundComponent, modal]);
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
return (jsx("div", { className: cx(background, {
|
|
677
|
+
const className = useMemo(() => modal
|
|
678
|
+
? cx(background, {
|
|
680
679
|
[active$1]: modal.closeOnBackdropClick && modal.visible,
|
|
681
680
|
[visible$1]: modal.manualDestroy ? modal.alive : modal.visible,
|
|
682
|
-
})
|
|
681
|
+
})
|
|
682
|
+
: undefined, [modal]);
|
|
683
|
+
if (!modal)
|
|
684
|
+
return null;
|
|
685
|
+
return (jsx("div", { className: className, onClick: handleClose, children: Background && (jsx(Background, { id: modal.id, type: modal.type, alive: modal.alive, visible: modal.visible, initiator: modal.initiator, manualDestroy: modal.manualDestroy, closeOnBackdropClick: modal.closeOnBackdropClick, background: modal.background, onChange: onChange, onConfirm: onConfirm, onClose: onClose, onDestroy: onDestroy, onChangeOrder: onChangeOrder, context: userDefinedContext })) }));
|
|
683
686
|
};
|
|
684
687
|
|
|
685
688
|
const AlertInner = memo(({ modal, handlers }) => {
|
|
@@ -788,12 +791,15 @@ const ForegroundFrame = ({ modalId, onChangeOrder, }) => {
|
|
|
788
791
|
const { context: userDefinedContext } = useUserDefinedContext();
|
|
789
792
|
const { modal, onChange, onConfirm, onClose, onDestroy } = useModal(modalId);
|
|
790
793
|
const Foreground = useMemo(() => modal?.ForegroundComponent || ForegroundComponent, [ForegroundComponent, modal]);
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
return (jsx("div", { className: cx(foreground, {
|
|
794
|
+
const className = useMemo(() => modal
|
|
795
|
+
? cx(foreground, {
|
|
794
796
|
[active]: modal.visible,
|
|
795
797
|
[visible]: modal.manualDestroy ? modal.alive : modal.visible,
|
|
796
|
-
})
|
|
798
|
+
})
|
|
799
|
+
: undefined, [modal]);
|
|
800
|
+
if (!modal)
|
|
801
|
+
return null;
|
|
802
|
+
return (jsx("div", { className: className, children: jsxs(Foreground, { id: modal.id, type: modal.type, alive: modal.alive, visible: modal.visible, initiator: modal.initiator, manualDestroy: modal.manualDestroy, closeOnBackdropClick: modal.closeOnBackdropClick, background: modal.background, onChange: onChange, onConfirm: onConfirm, onClose: onClose, onDestroy: onDestroy, onChangeOrder: onChangeOrder, context: userDefinedContext, children: [modal.type === 'alert' && (jsx(AlertInner, { modal: modal, handlers: { onConfirm } })), modal.type === 'confirm' && (jsx(ConfirmInner, { modal: modal, handlers: { onConfirm, onClose } })), modal.type === 'prompt' && (jsx(PromptInner, { modal: modal, handlers: { onChange, onConfirm, onClose } }))] }) }));
|
|
797
803
|
};
|
|
798
804
|
|
|
799
805
|
const useSubscribeModal = (modal) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lerx/promise-modal",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Universal React modal utility that can be used outside React components with promise-based results for alert, confirm, and prompt modals",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@winglet/common-utils": "^0.2.2",
|
|
69
|
-
"@winglet/react-utils": "^0.2.
|
|
70
|
-
"@winglet/style-utils": "^0.2.
|
|
69
|
+
"@winglet/react-utils": "^0.2.4",
|
|
70
|
+
"@winglet/style-utils": "^0.2.1"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@chromatic-com/storybook": "^3.2.6",
|