@bit.rhplus/draggable-modal 0.0.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.
@@ -0,0 +1,2 @@
1
+ export default DraggableModal;
2
+ declare function DraggableModal(props: any): import("react/jsx-runtime").JSX.Element;
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { Modal } from 'antd';
4
+ import Draggable from 'react-draggable';
5
+ import './style.css';
6
+ const DraggableModal = (props) => {
7
+ const { open, onOk, onCancel, isInteractive = false, title, children } = props;
8
+ const draggleRef = React.useRef(null);
9
+ const [disabled, setDisabled] = React.useState(true);
10
+ const [bounds, setBounds] = React.useState({
11
+ left: 0,
12
+ top: 0,
13
+ bottom: 0,
14
+ right: 0,
15
+ });
16
+ React.useEffect(() => {
17
+ if (isInteractive) {
18
+ import('./interactiveStyle.css');
19
+ }
20
+ }, [isInteractive]);
21
+ const onStart = (_event, uiData) => {
22
+ const { clientWidth, clientHeight } = window.document.documentElement;
23
+ const targetRect = draggleRef.current?.getBoundingClientRect();
24
+ if (!targetRect) {
25
+ return;
26
+ }
27
+ setBounds({
28
+ left: -targetRect.left + uiData.x,
29
+ right: clientWidth - (targetRect.right - uiData.x),
30
+ top: -targetRect.top + uiData.y,
31
+ bottom: clientHeight - (targetRect.bottom - uiData.y),
32
+ });
33
+ };
34
+ return (_jsx(Modal, { ...props, mask: !isInteractive, title: _jsx("div", { style: {
35
+ width: '100%',
36
+ cursor: 'move',
37
+ }, onMouseOver: () => {
38
+ if (disabled) {
39
+ setDisabled(false);
40
+ }
41
+ }, onMouseOut: () => {
42
+ setDisabled(true);
43
+ }, onFocus: () => { }, onBlur: () => { }, end: true, children: title }), open: open, onOk: onOk, onCancel: onCancel, modalRender: (modal) => (_jsx(Draggable, { disabled: disabled, bounds: bounds, onStart: (event, uiData) => onStart(event, uiData), children: _jsx("div", { ref: draggleRef, children: modal }) })), children: _jsx(_Fragment, { children: children }) }));
44
+ };
45
+ export default DraggableModal;
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.jsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,aAAa,CAAC;AAErB,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,EAAE;IAC/B,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,GAAG,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC/E,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC;QACzC,IAAI,EAAE,CAAC;QACP,GAAG,EAAE,CAAC;QACN,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,CAAC;KACT,CAAC,CAAC;IAEH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,CAAC,wBAAwB,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAGpB,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;QACjC,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC;QACtE,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,EAAE,qBAAqB,EAAE,CAAC;QAC/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,GACR,GACG,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,3 @@
1
+ .ant-modal-wrap {
2
+ pointer-events: none !important;
3
+ }
@@ -0,0 +1,7 @@
1
+ ;
2
+ ;
3
+
4
+ export const compositions = [];
5
+ export const overview = [];
6
+
7
+ export const compositions_metadata = {"compositions":[]};
package/dist/style.css ADDED
@@ -0,0 +1,3 @@
1
+ .ant-modal-content {
2
+ box-shadow: 0px 0px 56px 0px rgba(0, 0, 0, 2.15) !important;
3
+ }
package/index.jsx ADDED
@@ -0,0 +1,83 @@
1
+ import * as React from 'react';
2
+ import { Modal } from 'antd';
3
+ import Draggable from 'react-draggable';
4
+ import './style.css';
5
+
6
+ const DraggableModal = (props) => {
7
+ const { open, onOk, onCancel, isInteractive = false, title, children } = props;
8
+ const draggleRef = React.useRef(null);
9
+ const [disabled, setDisabled] = React.useState(true);
10
+ const [bounds, setBounds] = React.useState({
11
+ left: 0,
12
+ top: 0,
13
+ bottom: 0,
14
+ right: 0,
15
+ });
16
+
17
+ React.useEffect(() => {
18
+ if (isInteractive) {
19
+ import('./interactiveStyle.css');
20
+ }
21
+ }, [isInteractive]);
22
+
23
+
24
+ const onStart = (_event, uiData) => {
25
+ const { clientWidth, clientHeight } = window.document.documentElement;
26
+ const targetRect = draggleRef.current?.getBoundingClientRect();
27
+ if (!targetRect) {
28
+ return;
29
+ }
30
+ setBounds({
31
+ left: -targetRect.left + uiData.x,
32
+ right: clientWidth - (targetRect.right - uiData.x),
33
+ top: -targetRect.top + uiData.y,
34
+ bottom: clientHeight - (targetRect.bottom - uiData.y),
35
+ });
36
+ };
37
+
38
+ return (
39
+ <Modal
40
+ {...props}
41
+ mask={!isInteractive}
42
+ title={
43
+ <div
44
+ style={{
45
+ width: '100%',
46
+ cursor: 'move',
47
+ }}
48
+ onMouseOver={() => {
49
+ if (disabled) {
50
+ setDisabled(false);
51
+ }
52
+ }}
53
+ onMouseOut={() => {
54
+ setDisabled(true);
55
+ }}
56
+ onFocus={() => { }}
57
+ onBlur={() => { }}
58
+ end
59
+ >
60
+ {title}
61
+ </div>
62
+ }
63
+ open={open}
64
+ onOk={onOk}
65
+ onCancel={onCancel}
66
+ modalRender={(modal) => (
67
+ <Draggable
68
+ disabled={disabled}
69
+ bounds={bounds}
70
+ onStart={(event, uiData) => onStart(event, uiData)}
71
+ >
72
+ <div ref={draggleRef}>{modal}</div>
73
+ </Draggable>
74
+ )}
75
+ >
76
+ <>
77
+ {children}
78
+ </>
79
+ </Modal>
80
+ );
81
+ };
82
+
83
+ export default DraggableModal;
@@ -0,0 +1,3 @@
1
+ .ant-modal-wrap {
2
+ pointer-events: none !important;
3
+ }
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@bit.rhplus/draggable-modal",
3
+ "version": "0.0.2",
4
+ "homepage": "https://bit.cloud/remote-scope/draggable-modal",
5
+ "main": "dist/index.js",
6
+ "componentId": {
7
+ "scope": "remote-scope",
8
+ "name": "draggable-modal",
9
+ "version": "0.0.2"
10
+ },
11
+ "dependencies": {
12
+ "antd": "^5.20.6",
13
+ "react-draggable": "^4.4.6"
14
+ },
15
+ "devDependencies": {
16
+ "@teambit/react.react-env": "1.0.98"
17
+ },
18
+ "peerDependencies": {
19
+ "react": "^17.0.0 || ^18.0.0"
20
+ },
21
+ "license": "SEE LICENSE IN UNLICENSED",
22
+ "optionalDependencies": {},
23
+ "peerDependenciesMeta": {},
24
+ "private": false,
25
+ "publishConfig": {
26
+ "scope": "@bit.rhplus",
27
+ "registry": "https://registry.npmjs.org/"
28
+ }
29
+ }
package/style.css ADDED
@@ -0,0 +1,3 @@
1
+ .ant-modal-content {
2
+ box-shadow: 0px 0px 56px 0px rgba(0, 0, 0, 2.15) !important;
3
+ }
@@ -0,0 +1,43 @@
1
+ declare module '*.png' {
2
+ const value: any;
3
+ export = value;
4
+ }
5
+ declare module '*.svg' {
6
+ import type { FunctionComponent, SVGProps } from 'react';
7
+
8
+ export const ReactComponent: FunctionComponent<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
11
+ const src: string;
12
+ export default src;
13
+ }
14
+
15
+ // @TODO Gilad
16
+ declare module '*.jpg' {
17
+ const value: any;
18
+ export = value;
19
+ }
20
+ declare module '*.jpeg' {
21
+ const value: any;
22
+ export = value;
23
+ }
24
+ declare module '*.gif' {
25
+ const value: any;
26
+ export = value;
27
+ }
28
+ declare module '*.bmp' {
29
+ const value: any;
30
+ export = value;
31
+ }
32
+ declare module '*.otf' {
33
+ const value: any;
34
+ export = value;
35
+ }
36
+ declare module '*.woff' {
37
+ const value: any;
38
+ export = value;
39
+ }
40
+ declare module '*.woff2' {
41
+ const value: any;
42
+ export = value;
43
+ }
@@ -0,0 +1,42 @@
1
+ declare module '*.module.css' {
2
+ const classes: { readonly [key: string]: string };
3
+ export default classes;
4
+ }
5
+ declare module '*.module.scss' {
6
+ const classes: { readonly [key: string]: string };
7
+ export default classes;
8
+ }
9
+ declare module '*.module.sass' {
10
+ const classes: { readonly [key: string]: string };
11
+ export default classes;
12
+ }
13
+
14
+ declare module '*.module.less' {
15
+ const classes: { readonly [key: string]: string };
16
+ export default classes;
17
+ }
18
+
19
+ declare module '*.less' {
20
+ const classes: { readonly [key: string]: string };
21
+ export default classes;
22
+ }
23
+
24
+ declare module '*.css' {
25
+ const classes: { readonly [key: string]: string };
26
+ export default classes;
27
+ }
28
+
29
+ declare module '*.sass' {
30
+ const classes: { readonly [key: string]: string };
31
+ export default classes;
32
+ }
33
+
34
+ declare module '*.scss' {
35
+ const classes: { readonly [key: string]: string };
36
+ export default classes;
37
+ }
38
+
39
+ declare module '*.mdx' {
40
+ const component: any;
41
+ export default component;
42
+ }