react-ink-scripter 0.0.8 → 0.0.9
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/cjs/index.js +9 -6
- package/dist/esm/PrinterFrame.d.ts +2 -0
- package/dist/esm/index.js +7 -5
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -27,12 +27,14 @@ var IFrame = react.forwardRef(function (props, ref) {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
var PrinterFrame = function PrinterFrame(props) {
|
|
30
|
-
var _iframeRef$current2, _iframeRef$current2$c, _iframeRef$current2$c2, _iframeRef$current3, _iframeRef$current3$c, _iframeRef$current3$c2;
|
|
30
|
+
var _iframeRef$current2, _iframeRef$current2$c, _iframeRef$current2$c2, _iframeRef$current3, _iframeRef$current3$c, _iframeRef$current3$c2, _iframeRef$current4, _iframeRef$current4$c, _iframeRef$current4$c2;
|
|
31
31
|
var styleCss = props.styleCss,
|
|
32
32
|
open = props.open,
|
|
33
33
|
className = props.className,
|
|
34
34
|
children = props.children,
|
|
35
|
-
actionRef = props.actionRef
|
|
35
|
+
actionRef = props.actionRef,
|
|
36
|
+
src = props.src,
|
|
37
|
+
containerId = props.containerId;
|
|
36
38
|
var iframeRef = react.useRef(null);
|
|
37
39
|
react.useImperativeHandle(actionRef, function () {
|
|
38
40
|
return {
|
|
@@ -46,14 +48,15 @@ var PrinterFrame = function PrinterFrame(props) {
|
|
|
46
48
|
}
|
|
47
49
|
};
|
|
48
50
|
}, []);
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
+
var attachNode = containerId ? iframeRef === null || iframeRef === void 0 ? void 0 : (_iframeRef$current2 = iframeRef.current) === null || _iframeRef$current2 === void 0 ? void 0 : (_iframeRef$current2$c = _iframeRef$current2.contentWindow) === null || _iframeRef$current2$c === void 0 ? void 0 : (_iframeRef$current2$c2 = _iframeRef$current2$c.document) === null || _iframeRef$current2$c2 === void 0 ? void 0 : _iframeRef$current2$c2.getElementById(containerId) : iframeRef === null || iframeRef === void 0 ? void 0 : (_iframeRef$current3 = iframeRef.current) === null || _iframeRef$current3 === void 0 ? void 0 : (_iframeRef$current3$c = _iframeRef$current3.contentWindow) === null || _iframeRef$current3$c === void 0 ? void 0 : (_iframeRef$current3$c2 = _iframeRef$current3$c.document) === null || _iframeRef$current3$c2 === void 0 ? void 0 : _iframeRef$current3$c2.body;
|
|
52
|
+
var attachStyle = iframeRef === null || iframeRef === void 0 ? void 0 : (_iframeRef$current4 = iframeRef.current) === null || _iframeRef$current4 === void 0 ? void 0 : (_iframeRef$current4$c = _iframeRef$current4.contentWindow) === null || _iframeRef$current4$c === void 0 ? void 0 : (_iframeRef$current4$c2 = _iframeRef$current4$c.document) === null || _iframeRef$current4$c2 === void 0 ? void 0 : _iframeRef$current4$c2.head;
|
|
51
53
|
return jsxRuntime.jsxs("iframe", {
|
|
52
54
|
ref: iframeRef,
|
|
53
55
|
className: clsx("inks-iframe-root", !!open && "inks-iframe-root-open", className),
|
|
54
|
-
|
|
56
|
+
src: src,
|
|
57
|
+
children: [!!attachStyle && reactDom.createPortal(jsxRuntime.jsxs("style", {
|
|
55
58
|
children: ["\n@media print {\n .hidden-print {\n display: none !important;\n }\n}\n ", styleCss]
|
|
56
|
-
}),
|
|
59
|
+
}), attachStyle), !!attachNode && reactDom.createPortal(children, attachNode)]
|
|
57
60
|
});
|
|
58
61
|
};
|
|
59
62
|
|
|
@@ -8,6 +8,8 @@ export interface PrinterFrameProps {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
children?: ReactNode;
|
|
10
10
|
actionRef?: Ref<PrinterActions>;
|
|
11
|
+
src?: string;
|
|
12
|
+
containerId?: string;
|
|
11
13
|
}
|
|
12
14
|
export declare const PrinterFrame: (props: PrinterFrameProps) => JSX.Element;
|
|
13
15
|
export default PrinterFrame;
|
package/dist/esm/index.js
CHANGED
|
@@ -15,7 +15,7 @@ const IFrame = forwardRef((props, ref) => {
|
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
const PrinterFrame = (props) => {
|
|
18
|
-
const { styleCss, open, className, children, actionRef } = props;
|
|
18
|
+
const { styleCss, open, className, children, actionRef, src, containerId } = props;
|
|
19
19
|
const iframeRef = useRef(null);
|
|
20
20
|
useImperativeHandle(actionRef, () => {
|
|
21
21
|
return {
|
|
@@ -28,16 +28,18 @@ const PrinterFrame = (props) => {
|
|
|
28
28
|
},
|
|
29
29
|
};
|
|
30
30
|
}, []);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const attachNode = containerId
|
|
32
|
+
? iframeRef?.current?.contentWindow?.document?.getElementById(containerId)
|
|
33
|
+
: iframeRef?.current?.contentWindow?.document?.body;
|
|
34
|
+
const attachStyle = iframeRef?.current?.contentWindow?.document?.head;
|
|
35
|
+
return (jsxs("iframe", { ref: iframeRef, className: clsx("inks-iframe-root", !!open && "inks-iframe-root-open", className), src: src, children: [!!attachStyle &&
|
|
34
36
|
createPortal(jsxs("style", { children: [`
|
|
35
37
|
@media print {
|
|
36
38
|
.hidden-print {
|
|
37
39
|
display: none !important;
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
|
-
`, styleCss] }),
|
|
42
|
+
`, styleCss] }), attachStyle), !!attachNode && createPortal(children, attachNode)] }));
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
const Title = ({ value, id }) => {
|