react-pure-modal 2.3.4 → 3.0.1

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.
Files changed (43) hide show
  1. package/README.md +94 -78
  2. package/dist/index.js +1 -0
  3. package/dist/rslib.config.d.ts +2 -0
  4. package/dist/src/compounds/Backdrop.d.ts +3 -0
  5. package/dist/src/compounds/Close.d.ts +5 -0
  6. package/dist/src/compounds/Content.d.ts +5 -0
  7. package/dist/src/compounds/Footer.d.ts +5 -0
  8. package/dist/src/compounds/Header.d.ts +5 -0
  9. package/dist/src/compounds/Modal.d.ts +15 -0
  10. package/dist/src/compounds/Modal.types.d.ts +15 -0
  11. package/dist/src/compounds/ModalContext.d.ts +4 -0
  12. package/dist/src/index.d.ts +1 -0
  13. package/package.json +40 -49
  14. package/.babelrc.js +0 -12
  15. package/.eslintrc +0 -22
  16. package/.github/release-drafter-config.yml +0 -20
  17. package/.github/workflows/build.yml +0 -24
  18. package/.github/workflows/npm-publish.yml +0 -35
  19. package/.github/workflows/release-drafter.yml +0 -16
  20. package/.prettierrc +0 -19
  21. package/.travis.yml +0 -16
  22. package/@types/scheduler/tracing.d.ts +0 -22
  23. package/__tests__/__snapshots__/react-pure-modal-test.js.snap +0 -92
  24. package/__tests__/react-pure-modal-test.js +0 -44
  25. package/dist/pure-modal-content.d.ts +0 -25
  26. package/dist/react-pure-modal.d.ts +0 -20
  27. package/dist/react-pure-modal.min.css +0 -1
  28. package/dist/react-pure-modal.min.js +0 -1
  29. package/dist/types.d.ts +0 -1
  30. package/example/content.ts +0 -50
  31. package/example/example.min.js +0 -2
  32. package/example/example.min.js.LICENSE.txt +0 -109
  33. package/example/example.tsx +0 -109
  34. package/index.html +0 -22
  35. package/screencast/scrollable.gif +0 -0
  36. package/screencast/simple.gif +0 -0
  37. package/src/pure-modal-content.tsx +0 -74
  38. package/src/react-pure-modal.css +0 -123
  39. package/src/react-pure-modal.tsx +0 -256
  40. package/tsconfig.json +0 -25
  41. package/webpack.config.dev.js +0 -65
  42. package/webpack.config.js +0 -62
  43. /package/{src/types.ts → dist/@types/types.d.ts} +0 -0
@@ -1,92 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Should be closed 1`] = `null`;
4
-
5
- exports[`Should contain width attribute 1`] = `
6
- <div
7
- className="pure-modal-backdrop"
8
- onMouseDown={[Function]}
9
- >
10
- <div
11
- className="pure-modal 0.5"
12
- style={
13
- Object {
14
- "transform": "translate(0px, 0px)",
15
- "transition": "none",
16
- "width": "400px",
17
- }
18
- }
19
- >
20
- <span>
21
- Some content of modal
22
- </span>
23
- </div>
24
- </div>
25
- `;
26
-
27
- exports[`Should show content 1`] = `
28
- <div
29
- className="pure-modal-backdrop"
30
- onMouseDown={[Function]}
31
- >
32
- <div
33
- className="pure-modal 0.5"
34
- style={
35
- Object {
36
- "transform": "translate(0px, 0px)",
37
- "transition": "none",
38
- "width": undefined,
39
- }
40
- }
41
- >
42
- <div
43
- className="panel panel-default "
44
- >
45
- <div
46
- className="panel-heading"
47
- />
48
- <div
49
- className="panel-body scrollable"
50
- >
51
- <span>
52
- Some content of modal
53
- </span>
54
- </div>
55
- <div
56
- className="close"
57
- onClick={[Function]}
58
- style={
59
- Object {
60
- "margin": "",
61
- "position": "absolute",
62
- }
63
- }
64
- >
65
- ×
66
- </div>
67
- </div>
68
- </div>
69
- </div>
70
- `;
71
-
72
- exports[`Should show only content 1`] = `
73
- <div
74
- className="pure-modal-backdrop"
75
- onMouseDown={[Function]}
76
- >
77
- <div
78
- className="pure-modal 0.5"
79
- style={
80
- Object {
81
- "transform": "translate(0px, 0px)",
82
- "transition": "none",
83
- "width": undefined,
84
- }
85
- }
86
- >
87
- <span>
88
- Some content of modal
89
- </span>
90
- </div>
91
- </div>
92
- `;
@@ -1,44 +0,0 @@
1
- import React from 'react';
2
- import Modal from '../dist/react-pure-modal.min.js';
3
- import renderer from 'react-test-renderer';
4
-
5
- const mockMath = Object.create(global.Math);
6
- mockMath.random = () => 0.5;
7
- global.Math = mockMath;
8
-
9
- it('Should be null without props', () => {
10
- const component = renderer.create(<Modal />);
11
- expect(component.toJSON()).toBeNull();
12
- });
13
-
14
- it('Should be closed', () => {
15
- const component = renderer.create(<Modal isOpen={false} />);
16
- expect(component.toJSON()).toMatchSnapshot();
17
- });
18
-
19
- it('Should show content', () => {
20
- const component = renderer.create(
21
- <Modal isOpen>
22
- <span>Some content of modal</span>
23
- </Modal>
24
- );
25
- expect(component.toJSON()).toMatchSnapshot();
26
- });
27
-
28
- it('Should show only content', () => {
29
- const component = renderer.create(
30
- <Modal replace isOpen>
31
- <span>Some content of modal</span>
32
- </Modal>
33
- );
34
- expect(component.toJSON()).toMatchSnapshot();
35
- });
36
-
37
- it('Should contain width attribute', () => {
38
- const component = renderer.create(
39
- <Modal replace width="400px" isOpen>
40
- <span>Some content of modal</span>
41
- </Modal>
42
- );
43
- expect(component.toJSON()).toMatchSnapshot();
44
- });
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- import type { MouseOrTouch } from './types';
3
- declare type Props = {
4
- replace: boolean;
5
- children: JSX.Element;
6
- onDragStart?: (event: MouseOrTouch) => unknown;
7
- onDragEnd?: (event: MouseOrTouch) => unknown;
8
- onClose?: (event: React.MouseEvent<HTMLDivElement>) => void;
9
- bodyClass?: string;
10
- header?: JSX.Element | string;
11
- footer?: JSX.Element | string;
12
- closeButton: JSX.Element | string;
13
- closeButtonPosition: string;
14
- draggable: boolean;
15
- };
16
- declare function PureModalContent(props: Props): JSX.Element;
17
- declare namespace PureModalContent {
18
- var defaultProps: {
19
- closeButton: string;
20
- closeButtonPosition: string;
21
- replace: boolean;
22
- draggable: boolean;
23
- };
24
- }
25
- export default PureModalContent;
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import './react-pure-modal.css';
3
- declare type Props = {
4
- children: JSX.Element;
5
- replace?: boolean;
6
- className?: string;
7
- header?: JSX.Element | string;
8
- footer?: JSX.Element | string;
9
- scrollable?: boolean;
10
- draggable?: boolean;
11
- width?: string;
12
- isOpen?: boolean;
13
- onClose?: Function;
14
- closeButton?: JSX.Element | string;
15
- closeButtonPosition?: string;
16
- portal?: boolean;
17
- };
18
- declare function PureModal(props: Props): React.JSX.Element | null;
19
- declare const _default: React.MemoExoticComponent<typeof PureModal>;
20
- export default _default;
@@ -1 +0,0 @@
1
- .body-modal-fix{height:100%;width:100%;overflow:hidden}.pure-modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:rgba(0,0,0,.4);display:flex;flex-direction:column;justify-content:center;align-items:center}.backdrop-overflow-hidden{overflow:hidden!important}.pure-modal-backdrop .pure-modal{width:300px;max-width:100%;box-sizing:border-box;transition:all .2s ease-in-out;max-height:100%}.pure-modal.auto-height{position:static}.pure-modal-backdrop.scrollable{overflow-y:auto}.pure-modal-backdrop .panel{display:grid;grid-template-rows:repeat(3,min-content)}.pure-modal-backdrop:not(.scrollable) .panel{grid-template-rows:min-content minmax(0,1fr) min-content;max-height:-moz-available;max-height:-webkit-fill-available;max-height:fill-available;height:100%}.pure-modal>*>*{flex:0 0 auto}.pure-modal>*>.scrollable{overflow-x:hidden;overflow-scrolling:touch}@media (max-width:480px){.pure-modal-backdrop .pure-modal{width:100%}}.pure-modal .panel-body{background-color:#fff}.pure-modal .panel-heading{background:#f0f0f0}.pure-modal .panel-title{padding:12px 45px 12px 15px;margin:0}.pure-modal .close{right:10px;top:10px;z-index:1;background:hsla(0,0%,94.1%,.8);width:30px;color:#8c8c8c;transition:color .1s ease-in-out;height:30px;border-radius:15px;text-align:center;line-height:30px;cursor:pointer}.pure-modal .panel-heading .close:hover{color:#000}.pure-modal .panel-body{padding:15px}.pure-modal .panel-footer{padding:12px 45px 12px 15px;background:#f0f0f0}.pure-modal .panel-body,.pure-modal .panel-footer,.pure-modal .panel-title{word-break:break-all}.pure-modal-backdrop .additional-row,.pure-modal-backdrop:not(.scrollable) .additional-row{display:grid;grid-template-rows:min-content minmax(0,1fr) min-content min-content}
@@ -1 +0,0 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("react-dom"));else if("function"==typeof define&&define.amd)define(["react","react-dom"],t);else{var o="object"==typeof exports?t(require("react"),require("react-dom")):t(e.react,e["react-dom"]);for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(this,((e,t)=>(()=>{var o={494:()=>{},156:t=>{"use strict";t.exports=e},111:e=>{"use strict";e.exports=t}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,a),r.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var o in t)a.o(t,o)&&!a.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";a.r(r),a.d(r,{default:()=>s});var e=a(156),t=a.n(e),o=a(111);function n(e){const{children:o,replace:n,bodyClass:a,header:r,footer:c,onDragStart:l,onDragEnd:s,onClose:u,closeButton:i,closeButtonPosition:d}=e;return n?o:t().createElement("div",{className:"panel panel-default "+("bottom"===d?"additional-row":"")},t().createElement("div",{className:"panel-heading",onTouchStart:l,onMouseDown:l,onTouchEnd:s,onMouseUp:s},r&&t().createElement("h3",{className:"panel-title"},r)),t().createElement("div",{className:a},o),c&&t().createElement("div",{className:"panel-footer"},c),t().createElement("div",{className:"close",onClick:u,style:{position:"header"===d?"absolute":"static",margin:"bottom"===d?"10px auto":""}},i))}n.defaultProps={closeButton:"×",closeButtonPosition:"header",replace:!1,draggable:!1};const c=n;a(494);function l(n){const a=(0,e.useId)(),[r,l]=(0,e.useState)(!1),[s,u]=(0,e.useState)(null),[i,d]=(0,e.useState)(null),[p,m]=(0,e.useState)(0),[f,g]=(0,e.useState)(0),[v,h]=(0,e.useState)(0),[b,y]=(0,e.useState)(0),{isOpen:E,onClose:S}=n,T=(0,e.useCallback)((()=>{document.body.classList.remove("body-modal-fix")}),[]);(0,e.useEffect)((()=>(E&&(document.addEventListener("keydown",x),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),document.body.classList.add("body-modal-fix")),()=>{document.querySelector(".pure-modal")||(document.removeEventListener("keydown",x),T(),u(null),d(null),m(0),g(0),h(0),y(0))})),[E]);const x=(0,e.useCallback)((e=>{const t=document.querySelectorAll(".pure-modal"),o=t.length>1,n=t[t.length-1];return!(o&&!n.className.includes(a))&&(!("Escape"!==e.key||!document.activeElement)&&(P(e),!0))}),[P,a]);if(!E)return null;function P(e){e&&(e.stopPropagation(),e.preventDefault()),null==S||S({isPassive:Boolean(e)})}function j(e){return e instanceof TouchEvent&&e.changedTouches.length>0?{pageX:e.changedTouches[0].pageX,pageY:e.changedTouches[0].pageY}:e instanceof MouseEvent?{pageX:e.pageX,pageY:e.pageY}:{pageX:0,pageY:0}}function M(e){if(e instanceof TouchEvent&&e.changedTouches&&e.changedTouches.length>1)return B();e.preventDefault();const{pageX:t,pageY:o}=j(e);"number"==typeof s&&"number"==typeof i&&(m(t-s-v),g(o-i-b))}function B(){return l(!1)}const{children:D,replace:N=!1,className:k,header:w,footer:C,scrollable:X=!0,draggable:Y=!1,width:q,closeButton:L,closeButtonPosition:O,portal:_=!1}=n;let $=["pure-modal-backdrop"],A=["pure-modal",a],H=["panel-body"];k&&(A=A.concat(k)),X?H=H.concat("scrollable"):($=$.concat("scrollable"),A=A.concat("auto-height")),Y&&($=$.concat("backdrop-overflow-hidden"));const I=t().createElement("div",{className:$.join(" "),onMouseDown:function(e){if(e){if(!e.target.classList.contains("pure-modal-backdrop"))return;e.stopPropagation(),e.preventDefault()}P(e)},onTouchMove:r?M:void 0,onMouseMove:r?M:void 0},t().createElement("div",{className:A.join(" "),style:{transform:`translate(${p}px, ${f}px)`,transition:"none",width:q}},t().createElement(c,{replace:N,header:w,footer:C,onDragStart:Y?function(e){if(e instanceof TouchEvent&&e.changedTouches&&e.changedTouches.length>1)return;e.preventDefault();const{pageX:t,pageY:o}=j(e),{top:n,left:a}=e.currentTarget.getBoundingClientRect();l(!0),u("number"==typeof s?s:a),d("number"==typeof i?i:n),h(t-a),y(o-n)}:void 0,onDragEnd:Y?B:void 0,onClose:P,bodyClass:H.join(" "),closeButton:L,closeButtonPosition:O},D)));return _?(0,o.createPortal)(I,document.body):I}const s=t().memo(l)})(),r})()));
package/dist/types.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare type MouseOrTouch = React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>;
@@ -1,50 +0,0 @@
1
- export const smallContent = `
2
- <p>
3
- Ut bibendum dolor a mi ultrices venenatis ac a mi. Sed imperdiet ipsum sodales odio
4
- scelerisque, vel lobortis est rutrum. Sed sagittis iaculis lorem id mattis. Sed ultricies
5
- condimentum rhoncus. Phasellus rhoncus turpis nec odio egestas, quis pellentesque quam
6
- aliquam. In sodales erat iaculis libero molestie, vel commodo nisl congue. Maecenas
7
- scelerisque, ligula et elementum sagittis, felis dui semper tortor, eget euismod enim enim
8
- vitae ante. Nullam suscipit accumsan mi non blandit. Curabitur viverra risus sed feugiat
9
- aliquet. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac
10
- turpis egestas. Aliquam ipsum diam, pulvinar sit amet lectus at, congue vulputate eros.
11
- Donec id libero quam.
12
- </p>
13
- `;
14
-
15
- export const largeContent = `
16
- <p>
17
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla ex a feugiat
18
- blandit. Sed tempor placerat dui et hendrerit. Nunc fringilla vel orci at lacinia. Duis
19
- vitae nulla sit amet justo faucibus ornare. Nunc nec lacinia dolor. Vestibulum egestas
20
- condimentum ante, id semper sem facilisis eu. Sed aliquam eget est eget finibus. Quisque
21
- vehicula massa et elit maximus, vel euismod erat lacinia. Morbi ut risus eget nunc feugiat
22
- cursus.
23
- </p>
24
- <p>
25
- Pellentesque quis metus eu urna feugiat auctor. Fusce accumsan mi nibh, porttitor lacinia
26
- est egestas vel. Maecenas nibh odio, volutpat quis tincidunt eget, lacinia a lorem. Etiam
27
- ullamcorper turpis a ultrices auctor. Cras quis tortor turpis. Class aptent taciti
28
- sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nullam porta
29
- sagittis congue. Maecenas volutpat lacus eu lectus dapibus, nec eleifend ipsum luctus.
30
- Etiam ac lobortis ligula, id porta lectus. Curabitur eget leo ut sapien ullamcorper
31
- sagittis.
32
- </p>
33
- <p>
34
- Suspendisse commodo nisl in neque tempus pellentesque. Nullam magna turpis, fringilla
35
- sollicitudin maximus non, consectetur ac quam. Ut sit amet tortor ornare, tincidunt ante
36
- non, tempor mauris. Proin vestibulum purus vel felis pellentesque varius. Sed eget
37
- volutpat dui. Curabitur quis nunc facilisis, euismod justo placerat, sagittis nunc.
38
- Phasellus sagittis felis urna, sed sodales odio auctor sit amet. Etiam id metus quis velit
39
- ullamcorper consequat. Fusce posuere ultricies felis, at vestibulum turpis egestas et.
40
- </p>
41
- <p>
42
- In hac habitasse platea dictumst. Quisque fringilla elit vel ante tristique, quis commodo
43
- turpis tincidunt. Phasellus mi sapien, lobortis sed blandit quis, suscipit ut odio.
44
- Vivamus venenatis arcu nulla, non molestie ipsum ullamcorper eu. Duis suscipit
45
- sollicitudin purus, eu consequat magna fringilla eget. Sed a varius dui. Donec at nisi
46
- tortor. Vivamus ultrices risus eu maximus fermentum. Curabitur et tempus turpis. Curabitur
47
- tincidunt porttitor imperdiet. Pellentesque hendrerit finibus mi, et rhoncus ex vestibulum
48
- nec. Integer fermentum quis elit eget faucibus.
49
- </p>
50
- `;