@oneblink/apps-react 5.7.0-beta.8 → 5.7.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.
@@ -9,6 +9,11 @@ type Props = {
|
|
9
9
|
titleClassName?: string;
|
10
10
|
bodyClassName?: string;
|
11
11
|
};
|
12
|
+
export declare const ModalContainerContext: React.Context<React.RefObject<HTMLDivElement> | null>;
|
13
|
+
export declare function ModalContainerProvider({ children, className, }: {
|
14
|
+
children: React.ReactNode;
|
15
|
+
className?: string;
|
16
|
+
}): JSX.Element;
|
12
17
|
declare function Modal({ isOpen, title, children, className, cardClassName, titleClassName, bodyClassName, actions, }: Props): JSX.Element;
|
13
18
|
declare const _default: React.MemoExoticComponent<typeof Modal>;
|
14
19
|
export default _default;
|
@@ -1,12 +1,19 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import clsx from 'clsx';
|
3
3
|
import { Modal as MuiModal } from '@mui/material';
|
4
|
+
export const ModalContainerContext = React.createContext(null);
|
5
|
+
export function ModalContainerProvider({ children, className, }) {
|
6
|
+
const modalRef = React.useRef(null);
|
7
|
+
return (React.createElement(ModalContainerContext.Provider, { value: modalRef },
|
8
|
+
React.createElement("div", { ref: modalRef, className: className }, children)));
|
9
|
+
}
|
4
10
|
function Modal({ isOpen, title, children, className, cardClassName, titleClassName, bodyClassName, actions, }) {
|
11
|
+
const ref = React.useContext(ModalContainerContext);
|
5
12
|
return (React.createElement(MuiModal, { className: clsx('modal ob-modal', className, {
|
6
13
|
'is-active': isOpen,
|
7
14
|
}), open: isOpen, slots: {
|
8
15
|
backdrop: () => React.createElement("div", { className: "modal-background-faded" }),
|
9
|
-
} },
|
16
|
+
}, container: ref === null || ref === void 0 ? void 0 : ref.current },
|
10
17
|
React.createElement("div", { className: clsx('modal-card', cardClassName) },
|
11
18
|
title && (React.createElement("header", { className: "modal-card-head" },
|
12
19
|
React.createElement("p", { className: clsx('modal-card-title', titleClassName) }, title))),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../../src/components/renderer/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAA;AAajD,SAAS,KAAK,CAAC,EACb,MAAM,EACN,KAAK,EACL,QAAQ,EACR,SAAS,EACT,aAAa,EACb,cAAc,EACd,aAAa,EACb,OAAO,GACD;IACN,OAAO,CACL,oBAAC,QAAQ,IACP,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,EAAE;YAC3C,WAAW,EAAE,MAAM;SACpB,CAAC,EACF,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE;YACL,QAAQ,EAAE,GAAG,EAAE,CAAC,6BAAK,SAAS,EAAC,wBAAwB,GAAO;SAC/D;
|
1
|
+
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../../src/components/renderer/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAA;AAajD,MAAM,CAAC,MAAM,qBAAqB,GAChC,KAAK,CAAC,aAAa,CAAyC,IAAI,CAAC,CAAA;AAEnE,MAAM,UAAU,sBAAsB,CAAC,EACrC,QAAQ,EACR,SAAS,GAIV;IACC,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAiB,IAAI,CAAC,CAAA;IAEnD,OAAO,CACL,oBAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ;QAC7C,6BAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,IACrC,QAAQ,CACL,CACyB,CAClC,CAAA;AACH,CAAC;AAED,SAAS,KAAK,CAAC,EACb,MAAM,EACN,KAAK,EACL,QAAQ,EACR,SAAS,EACT,aAAa,EACb,cAAc,EACd,aAAa,EACb,OAAO,GACD;IACN,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAA;IACnD,OAAO,CACL,oBAAC,QAAQ,IACP,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,EAAE;YAC3C,WAAW,EAAE,MAAM;SACpB,CAAC,EACF,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE;YACL,QAAQ,EAAE,GAAG,EAAE,CAAC,6BAAK,SAAS,EAAC,wBAAwB,GAAO;SAC/D,EACD,SAAS,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO;QAEvB,6BAAK,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC;YAC9C,KAAK,IAAI,CACR,gCAAQ,SAAS,EAAC,iBAAiB;gBACjC,2BAAG,SAAS,EAAE,IAAI,CAAC,kBAAkB,EAAE,cAAc,CAAC,IAAG,KAAK,CAAK,CAC5D,CACV;YACD,iCAAS,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,IACvD,QAAQ,CACD;YACT,OAAO,IAAI,gCAAQ,SAAS,EAAC,iBAAiB,IAAE,OAAO,CAAU,CAC9D,CACG,CACZ,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport clsx from 'clsx'\nimport { Modal as MuiModal } from '@mui/material'\n\ntype Props = {\n isOpen: boolean\n title?: string\n children: React.ReactNode\n actions: React.ReactNode | null\n className?: string\n cardClassName?: string\n titleClassName?: string\n bodyClassName?: string\n}\n\nexport const ModalContainerContext =\n React.createContext<React.RefObject<HTMLDivElement> | null>(null)\n\nexport function ModalContainerProvider({\n children,\n className,\n}: {\n children: React.ReactNode\n className?: string\n}) {\n const modalRef = React.useRef<HTMLDivElement>(null)\n\n return (\n <ModalContainerContext.Provider value={modalRef}>\n <div ref={modalRef} className={className}>\n {children}\n </div>\n </ModalContainerContext.Provider>\n )\n}\n\nfunction Modal({\n isOpen,\n title,\n children,\n className,\n cardClassName,\n titleClassName,\n bodyClassName,\n actions,\n}: Props) {\n const ref = React.useContext(ModalContainerContext)\n return (\n <MuiModal\n className={clsx('modal ob-modal', className, {\n 'is-active': isOpen,\n })}\n open={isOpen}\n slots={{\n backdrop: () => <div className=\"modal-background-faded\"></div>,\n }}\n container={ref?.current}\n >\n <div className={clsx('modal-card', cardClassName)}>\n {title && (\n <header className=\"modal-card-head\">\n <p className={clsx('modal-card-title', titleClassName)}>{title}</p>\n </header>\n )}\n <section className={clsx('modal-card-body', bodyClassName)}>\n {children}\n </section>\n {actions && <footer className=\"modal-card-foot\">{actions}</footer>}\n </div>\n </MuiModal>\n )\n}\n\nexport default React.memo(Modal)\n"]}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@oneblink/apps-react",
|
3
3
|
"description": "Helper functions for OneBlink apps in ReactJS.",
|
4
|
-
"version": "5.7.0
|
4
|
+
"version": "5.7.0",
|
5
5
|
"author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
|
6
6
|
"bugs": {
|
7
7
|
"url": "https://github.com/oneblink/apps-react/issues"
|