@slithy/modal-parts 0.1.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,36 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import { ReactNode } from 'react';
4
+
5
+ type CloseButtonProps = {
6
+ className?: string;
7
+ disabled?: boolean;
8
+ handleClose: () => void;
9
+ icon?: ReactNode;
10
+ title?: string;
11
+ };
12
+ declare const CloseButton: ({ className, disabled, handleClose, icon, title, }: CloseButtonProps) => react_jsx_runtime.JSX.Element;
13
+
14
+ type FooterProps = {
15
+ children?: React.ReactNode;
16
+ className?: string;
17
+ } & React.HTMLAttributes<HTMLDivElement>;
18
+ declare const Footer: ({ children, className, ...htmlProps }: FooterProps) => react_jsx_runtime.JSX.Element;
19
+
20
+ type HeaderProps = {
21
+ children?: React.ReactNode;
22
+ className?: string;
23
+ } & React.HTMLAttributes<HTMLDivElement>;
24
+ declare const Header: ({ children, className, ...htmlProps }: HeaderProps) => react_jsx_runtime.JSX.Element;
25
+
26
+ type MainProps = {
27
+ children?: React.ReactNode;
28
+ className?: string;
29
+ /**
30
+ * Blocks all mouse, keyboard, and touch interactions. WARNING: Consider accessibility impact.
31
+ */
32
+ inert?: boolean;
33
+ };
34
+ declare const Main: react.ForwardRefExoticComponent<MainProps & react.RefAttributes<HTMLDivElement>>;
35
+
36
+ export { CloseButton, Footer, Header, Main };
package/dist/index.js ADDED
@@ -0,0 +1,130 @@
1
+ // src/CloseButton.tsx
2
+ import { usePointerClick } from "@slithy/utils";
3
+
4
+ // #style-inject:#style-inject
5
+ function styleInject(css, { insertAt } = {}) {
6
+ if (!css || typeof document === "undefined") return;
7
+ const head = document.head || document.getElementsByTagName("head")[0];
8
+ const style = document.createElement("style");
9
+ style.type = "text/css";
10
+ if (insertAt === "top") {
11
+ if (head.firstChild) {
12
+ head.insertBefore(style, head.firstChild);
13
+ } else {
14
+ head.appendChild(style);
15
+ }
16
+ } else {
17
+ head.appendChild(style);
18
+ }
19
+ if (style.styleSheet) {
20
+ style.styleSheet.cssText = css;
21
+ } else {
22
+ style.appendChild(document.createTextNode(css));
23
+ }
24
+ }
25
+
26
+ // src/CloseButton.css
27
+ styleInject("[data-slithy=modal-close-button] {\n align-items: center;\n background: transparent;\n border: none;\n color: inherit;\n cursor: pointer;\n display: flex;\n font-family: inherit;\n font-size: inherit;\n height: 44px;\n justify-content: center;\n left: auto;\n margin: 0;\n padding: 0;\n position: absolute;\n right: 0;\n top: 0;\n opacity: 1;\n user-select: none;\n -webkit-user-select: none;\n width: 44px;\n z-index: 1;\n}\n[data-slithy=modal-close-button]:disabled {\n cursor: default;\n opacity: 0.5;\n}\n[data-slithy=modal-close-button]:focus-visible {\n border-radius: 4px;\n box-shadow: 0 0 0 2px currentColor;\n outline: none;\n}\n@media (min-width: 768px) {\n [data-slithy=modal-close-button] {\n height: 24px;\n width: 24px;\n }\n}\n");
28
+
29
+ // src/CloseButton.tsx
30
+ import { jsx, jsxs } from "react/jsx-runtime";
31
+ var CloseButton = ({
32
+ className,
33
+ disabled,
34
+ handleClose,
35
+ icon,
36
+ title
37
+ }) => {
38
+ const pointerClick = usePointerClick(handleClose);
39
+ return /* @__PURE__ */ jsx(
40
+ "button",
41
+ {
42
+ ...pointerClick,
43
+ "aria-label": "Close",
44
+ className,
45
+ "data-slithy": "modal-close-button",
46
+ disabled,
47
+ title,
48
+ type: "button",
49
+ children: icon ?? /* @__PURE__ */ jsxs(
50
+ "svg",
51
+ {
52
+ xmlns: "http://www.w3.org/2000/svg",
53
+ width: "24",
54
+ height: "24",
55
+ viewBox: "0 0 24 24",
56
+ fill: "none",
57
+ stroke: "currentColor",
58
+ strokeWidth: "2",
59
+ strokeLinecap: "round",
60
+ strokeLinejoin: "round",
61
+ "aria-hidden": "true",
62
+ children: [
63
+ /* @__PURE__ */ jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
64
+ /* @__PURE__ */ jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
65
+ ]
66
+ }
67
+ )
68
+ }
69
+ );
70
+ };
71
+
72
+ // src/Footer.css
73
+ styleInject("[data-slithy=modal-footer] {\n border-top: 1px solid rgba(0, 0, 0, 0.25);\n box-sizing: content-box;\n position: relative;\n}\n[data-slithy=modal-footer]:empty {\n display: none;\n}\n");
74
+
75
+ // src/Footer.tsx
76
+ import { jsx as jsx2 } from "react/jsx-runtime";
77
+ var Footer = ({ children, className, ...htmlProps }) => /* @__PURE__ */ jsx2(
78
+ "div",
79
+ {
80
+ ...htmlProps,
81
+ className,
82
+ "data-slithy": "modal-footer",
83
+ "data-testid": "modal-footer",
84
+ children
85
+ }
86
+ );
87
+
88
+ // src/Header.css
89
+ styleInject("[data-slithy=modal-header] {\n border-bottom: 1px solid rgba(0, 0, 0, 0.25);\n box-sizing: content-box;\n position: relative;\n}\n");
90
+
91
+ // src/Header.tsx
92
+ import { jsx as jsx3 } from "react/jsx-runtime";
93
+ var Header = ({ children, className, ...htmlProps }) => /* @__PURE__ */ jsx3(
94
+ "div",
95
+ {
96
+ ...htmlProps,
97
+ className,
98
+ "data-slithy": "modal-header",
99
+ "data-testid": "modal-header",
100
+ children
101
+ }
102
+ );
103
+
104
+ // src/Main.tsx
105
+ import { forwardRef } from "react";
106
+
107
+ // src/Main.css
108
+ styleInject("[data-slithy=modal-main] {\n flex-grow: 1;\n min-height: 0;\n overflow-y: auto;\n overscroll-behavior-y: contain;\n touch-action: pan-y;\n user-select: text;\n -webkit-user-select: none;\n}\n");
109
+
110
+ // src/Main.tsx
111
+ import { jsx as jsx4 } from "react/jsx-runtime";
112
+ var Main = forwardRef(
113
+ ({ children, className, inert }, ref) => /* @__PURE__ */ jsx4(
114
+ "div",
115
+ {
116
+ ref,
117
+ className,
118
+ "data-slithy": "modal-main",
119
+ "data-testid": "modal-main",
120
+ inert: inert || void 0,
121
+ children
122
+ }
123
+ )
124
+ );
125
+ export {
126
+ CloseButton,
127
+ Footer,
128
+ Header,
129
+ Main
130
+ };
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@slithy/modal-parts",
3
+ "version": "0.1.2",
4
+ "description": "Layout primitives for @slithy/modal-kit modals.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/index.js",
9
+ "types": "./dist/index.d.ts"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "sideEffects": [
16
+ "*.css"
17
+ ],
18
+ "dependencies": {
19
+ "@slithy/utils": "0.3.0",
20
+ "@slithy/modal-kit": "0.1.2"
21
+ },
22
+ "peerDependencies": {
23
+ "react": "^17 || ^18 || ^19"
24
+ },
25
+ "devDependencies": {
26
+ "@testing-library/jest-dom": "^6",
27
+ "@testing-library/react": "^16",
28
+ "@types/react": "^19",
29
+ "@vitejs/plugin-react": "^6",
30
+ "@vitest/coverage-v8": "^4.1.2",
31
+ "jsdom": "^29.0.1",
32
+ "react": "^19",
33
+ "react-dom": "^19",
34
+ "tsup": "^8",
35
+ "typescript": "^5",
36
+ "vitest": "^4.1.2",
37
+ "@slithy/eslint-config": "0.0.0",
38
+ "@slithy/tsconfig": "0.0.0"
39
+ },
40
+ "author": "mjcampagna",
41
+ "license": "ISC",
42
+ "scripts": {
43
+ "clean": "rm -rf dist",
44
+ "build": "rm -rf dist && tsup",
45
+ "dev": "tsup --watch",
46
+ "typecheck": "tsc --noEmit",
47
+ "lint": "eslint .",
48
+ "test": "vitest run --passWithNoTests",
49
+ "test:watch": "vitest"
50
+ }
51
+ }