@maelstrom-futurism/modal 0.7.4-beta.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.
- package/LICENSE.md +21 -0
- package/dist/Modal.d.ts +10 -0
- package/dist/Modal.d.ts.map +1 -0
- package/dist/Modal.js +15 -0
- package/dist/Modal.js.map +1 -0
- package/dist/Modal.styles.d.ts +6 -0
- package/dist/Modal.styles.d.ts.map +1 -0
- package/dist/Modal.styles.js +57 -0
- package/dist/Modal.styles.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/useModal.d.ts +8 -0
- package/dist/useModal.d.ts.map +1 -0
- package/dist/useModal.js +12 -0
- package/dist/useModal.js.map +1 -0
- package/package.json +40 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2025 OSMstudios
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/Modal.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
interface ModalProps {
|
|
3
|
+
title?: string;
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
isShowing?: boolean | (() => void);
|
|
6
|
+
hide: () => void;
|
|
7
|
+
}
|
|
8
|
+
declare const Modal: ({ title, children, isShowing, hide }: ModalProps) => ReactNode | null;
|
|
9
|
+
export default Modal;
|
|
10
|
+
//# sourceMappingURL=Modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../src/Modal.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAczC,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,SAAS,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IACnC,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,QAAA,MAAM,KAAK,GAAI,sCAEZ,UAAU,KAAI,SAAS,GAAG,IAqC5B,CAAA;AAED,eAAe,KAAK,CAAC"}
|
package/dist/Modal.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import ReactDOM from "react-dom";
|
|
3
|
+
import { useTheme } from "@maelstrom-futurism/core";
|
|
4
|
+
import { modalOverlay, modalWrapper, modal, modalHeader, modalCloseButton, } from "./Modal.styles";
|
|
5
|
+
import { css } from "@emotion/react";
|
|
6
|
+
const Modal = ({ title, children, isShowing, hide }) => {
|
|
7
|
+
const theme = useTheme();
|
|
8
|
+
const modalModStyle = css `
|
|
9
|
+
color: black;
|
|
10
|
+
border-radius: ${theme.borderRadius};
|
|
11
|
+
`;
|
|
12
|
+
return isShowing ? ReactDOM.createPortal(_jsxs(_Fragment, { children: [_jsx("div", { css: modalOverlay, onClick: () => hide() }), _jsx("div", { css: modalWrapper, "aria-modal": true, "aria-hidden": true, tabIndex: -1, role: "dialog", children: _jsxs("div", { css: [modal, modalModStyle], children: [_jsxs("div", { css: modalHeader, children: [_jsx("div", { className: "title", children: title }), _jsx("button", { type: "button", css: modalCloseButton, "data-dismiss": "modal", "aria-label": "Close", onClick: hide, children: _jsx("span", { "aria-hidden": "true", children: "\u00D7" }) })] }), children] }) })] }), document.body) : null;
|
|
13
|
+
};
|
|
14
|
+
export default Modal;
|
|
15
|
+
//# sourceMappingURL=Modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../src/Modal.tsx"],"names":[],"mappings":";AACA,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,WAAW,EACX,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAWrC,MAAM,KAAK,GAAG,CAAC,EACb,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EACrB,EAAqB,EAAE;IAClC,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,MAAM,aAAa,GAAG,GAAG,CAAA;;qBAEN,KAAK,CAAC,YAAY;GACpC,CAAC;IAEF,OAAO,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CACtC,8BACE,cAAK,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,GAAI,EACjD,cACE,GAAG,EAAE,YAAY,2CAGjB,QAAQ,EAAE,CAAC,CAAC,EACZ,IAAI,EAAC,QAAQ,YAEb,eAAK,GAAG,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,aAC9B,eAAK,GAAG,EAAE,WAAW,aACnB,cAAK,SAAS,EAAC,OAAO,YAAE,KAAK,GAAO,EACpC,iBACE,IAAI,EAAC,QAAQ,EACb,GAAG,EAAE,gBAAgB,kBACR,OAAO,gBACT,OAAO,EAClB,OAAO,EAAE,IAAI,YAEb,8BAAkB,MAAM,uBAAe,GAChC,IACL,EAEL,QAAQ,IACL,GACF,IACL,EACH,QAAQ,CAAC,IAAI,CACd,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAA;AAED,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const modalOverlay: import("@emotion/react").SerializedStyles;
|
|
2
|
+
export declare const modalWrapper: import("@emotion/react").SerializedStyles;
|
|
3
|
+
export declare const modal: import("@emotion/react").SerializedStyles;
|
|
4
|
+
export declare const modalHeader: import("@emotion/react").SerializedStyles;
|
|
5
|
+
export declare const modalCloseButton: import("@emotion/react").SerializedStyles;
|
|
6
|
+
//# sourceMappingURL=Modal.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.styles.d.ts","sourceRoot":"","sources":["../src/Modal.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,2CASxB,CAAC;AAEF,eAAO,MAAM,YAAY,2CAKxB,CAAC;AAEF,eAAO,MAAM,KAAK,2CAajB,CAAC;AAEF,eAAO,MAAM,WAAW,2CAUvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,2CAa5B,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { css } from "@emotion/react";
|
|
2
|
+
export const modalOverlay = css `
|
|
3
|
+
position: fixed;
|
|
4
|
+
top: 0;
|
|
5
|
+
left: 0;
|
|
6
|
+
z-index: 1040;
|
|
7
|
+
width: 100vw;
|
|
8
|
+
height: 100vh;
|
|
9
|
+
background-color: #000;
|
|
10
|
+
opacity: 0.5;
|
|
11
|
+
`;
|
|
12
|
+
export const modalWrapper = css `
|
|
13
|
+
z-index: 1050;
|
|
14
|
+
overflow-x: hidden;
|
|
15
|
+
overflow-y: auto;
|
|
16
|
+
outline: 0;
|
|
17
|
+
`;
|
|
18
|
+
export const modal = css `
|
|
19
|
+
z-index: 1060;
|
|
20
|
+
background: white;
|
|
21
|
+
color: black;
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: 50%;
|
|
24
|
+
left: 50%;
|
|
25
|
+
transform: translate(-50%, -50%);
|
|
26
|
+
margin: 1.75rem auto;
|
|
27
|
+
max-width: 500px;
|
|
28
|
+
min-width: 300px;
|
|
29
|
+
min-height: 200px;
|
|
30
|
+
padding: 1rem 0.75rem;
|
|
31
|
+
`;
|
|
32
|
+
export const modalHeader = css `
|
|
33
|
+
display: flex;
|
|
34
|
+
justify-content: flex-end;
|
|
35
|
+
padding: 0.15rem 0 0.5rem 0;
|
|
36
|
+
|
|
37
|
+
.title {
|
|
38
|
+
font-weight: bold;
|
|
39
|
+
text-transform: uppercase;
|
|
40
|
+
flex-grow: 1;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
export const modalCloseButton = css `
|
|
44
|
+
font-size: 1.4rem;
|
|
45
|
+
font-weight: 700;
|
|
46
|
+
line-height: 1;
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
color: #000;
|
|
49
|
+
opacity: 0.3;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
border: none;
|
|
52
|
+
|
|
53
|
+
&:hover {
|
|
54
|
+
opacity: 1;
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
//# sourceMappingURL=Modal.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.styles.js","sourceRoot":"","sources":["../src/Modal.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;;;;;CAS9B,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;CAK9B,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;;;;;;;CAavB,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAA;;;;;;;;;;CAU7B,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAA;;;;;;;;;;;;;CAalC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
interface RenderModalProps {
|
|
3
|
+
title?: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare const useModal: () => [(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void, (props: RenderModalProps) => ReactNode, boolean];
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=useModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useModal.d.ts","sourceRoot":"","sources":["../src/useModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAGnD,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,QAAQ,QAAO,CAC1B,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,KAAK,IAAI,EAChE,CAAC,KAAK,EAAE,gBAAgB,KAAK,SAAS,EACtC,OAAO,CAmBR,CAAC"}
|
package/dist/useModal.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import Modal from "./Modal";
|
|
4
|
+
export const useModal = () => {
|
|
5
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
6
|
+
function toggle() {
|
|
7
|
+
setIsVisible(!isVisible);
|
|
8
|
+
}
|
|
9
|
+
const RenderModal = ({ title, children }) => (_jsx(_Fragment, { children: isVisible && (_jsx(Modal, { title: title, hide: toggle, isShowing: isVisible, children: children })) }));
|
|
10
|
+
return [toggle, RenderModal, isVisible];
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useModal.js","sourceRoot":"","sources":["../src/useModal.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAa,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,KAAK,MAAM,SAAS,CAAC;AAO5B,MAAM,CAAC,MAAM,QAAQ,GAAG,GAItB,EAAE;IACF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAElD,SAAS,MAAM;QACb,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,WAAW,GAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAoB,EAAa,EAAE,CAAC,CACvE,4BACG,SAAS,IAAI,CACZ,KAAC,KAAK,IAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,YACpD,QAAQ,GACH,CACT,GACA,CACJ,CAAC;IAEF,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;AAC1C,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maelstrom-futurism/modal",
|
|
3
|
+
"version": "0.7.4-beta.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"typings": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"test": "vitest run --coverage",
|
|
21
|
+
"test:dev": "vitest",
|
|
22
|
+
"prepublishOnly": "npm run build"
|
|
23
|
+
},
|
|
24
|
+
"author": "Dawson Goodell <dawsong@osmstudios.com>",
|
|
25
|
+
"homepage": "https://osmstudios.com",
|
|
26
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/DawsonG/maelstrom-futurism.git",
|
|
30
|
+
"directory": "packages/modal"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@maelstrom-futurism/core": "^0.7.4-beta.2"
|
|
34
|
+
},
|
|
35
|
+
"peerDependences": {
|
|
36
|
+
"react": ">= 18.0.0",
|
|
37
|
+
"react-dom": ">= 18.0.0"
|
|
38
|
+
},
|
|
39
|
+
"gitHead": "09d05a402ed22c9cec10177af4d8dcdc17ea864c"
|
|
40
|
+
}
|