@bouku/modal 0.0.4 → 0.0.5
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/state/index.d.ts +4 -2
- package/dist/state/index.js +5 -3
- package/dist/state/provider.d.ts +2 -2
- package/dist/state/provider.js +1 -1
- package/dist/ui/components/_.d.ts +1 -1
- package/dist/ui/components/_.js +14 -5
- package/dist/ui/components/button.d.ts +5 -4
- package/dist/ui/components/button.js +3 -3
- package/dist/ui/layouts/normal.d.ts +1 -1
- package/package.json +3 -3
- package/dist/state/root.d.ts +0 -14
- package/dist/state/root.js +0 -22
package/dist/state/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ModalConfig } from "./context";
|
|
2
|
-
import type { ComponentProps } from "react";
|
|
2
|
+
import type { ReactNode, ComponentProps } from "react";
|
|
3
|
+
import { type ButtonProps } from "../ui/components/button";
|
|
3
4
|
type ArgsFor<P> = {} extends P ? [props?: P] : [props: P];
|
|
4
5
|
type ActiveModal<T extends ModalConfig> = {
|
|
5
6
|
[K in keyof T]: {
|
|
@@ -9,12 +10,13 @@ type ActiveModal<T extends ModalConfig> = {
|
|
|
9
10
|
}[keyof T];
|
|
10
11
|
export declare const createModalSystem: <T extends ModalConfig>(config: T) => {
|
|
11
12
|
ModalProvider: (props: {
|
|
12
|
-
children:
|
|
13
|
+
children: ReactNode;
|
|
13
14
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
useModal: () => {
|
|
15
16
|
active: ActiveModal<T> | null;
|
|
16
17
|
openModal: <K extends keyof T>(id: K, ...args: ArgsFor<ComponentProps<T[K]>>) => void;
|
|
17
18
|
closeModal: () => void;
|
|
18
19
|
};
|
|
20
|
+
ModalButton: (props: ButtonProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
19
21
|
};
|
|
20
22
|
export { useRawModal } from "./context";
|
package/dist/state/index.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useRawModal = exports.createModalSystem = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const provider_1 = require("./provider");
|
|
6
5
|
const context_1 = require("./context");
|
|
6
|
+
const provider_1 = require("./provider");
|
|
7
|
+
const button_1 = require("../ui/components/button");
|
|
7
8
|
const createModalSystem = (config) => ({
|
|
8
9
|
ModalProvider: (props) => ((0, jsx_runtime_1.jsx)(provider_1.ModalProvider, { config: config, ...props })),
|
|
9
10
|
useModal: () => {
|
|
@@ -12,11 +13,12 @@ const createModalSystem = (config) => ({
|
|
|
12
13
|
openModal(id, args[0]);
|
|
13
14
|
}
|
|
14
15
|
return {
|
|
15
|
-
active: active,
|
|
16
|
+
active: active,
|
|
16
17
|
openModal: open,
|
|
17
18
|
closeModal
|
|
18
19
|
};
|
|
19
|
-
}
|
|
20
|
+
},
|
|
21
|
+
ModalButton: (props) => ((0, jsx_runtime_1.jsx)(button_1.ModalButton, { ...props }))
|
|
20
22
|
});
|
|
21
23
|
exports.createModalSystem = createModalSystem;
|
|
22
24
|
var context_2 = require("./context");
|
package/dist/state/provider.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type ModalConfig } from "./context";
|
|
3
3
|
export declare function ModalProvider<T extends ModalConfig>({ config, children }: {
|
|
4
4
|
config: T;
|
|
5
5
|
children: ReactNode;
|
package/dist/state/provider.js
CHANGED
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.ModalProvider = ModalProvider;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
const animate_1 = require("@bouku/animate");
|
|
8
7
|
const context_1 = require("./context");
|
|
8
|
+
const animate_1 = require("@bouku/animate");
|
|
9
9
|
function ModalProvider({ config, children }) {
|
|
10
10
|
const [active, setActive] = (0, react_1.useState)(null);
|
|
11
11
|
const openModal = (id, props) => setActive({ id, props: props ?? {} });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./button";
|
package/dist/ui/components/_.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4
15
|
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports
|
|
7
|
-
var button_1 = require("./button");
|
|
8
|
-
Object.defineProperty(exports, "ModalButton", { enumerable: true, get: function () { return __importDefault(button_1).default; } });
|
|
17
|
+
__exportStar(require("./button"), exports);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { type ModalConfig } from "../../state/context";
|
|
1
2
|
import type { ReactNode } from "react";
|
|
2
3
|
import type { JsonMap } from "ts-helper-kit";
|
|
3
|
-
type ButtonProps = {
|
|
4
|
-
id:
|
|
4
|
+
export type ButtonProps<T extends ModalConfig> = {
|
|
5
|
+
id: keyof T;
|
|
5
6
|
params?: JsonMap;
|
|
6
7
|
variant?: "surface" | "accent";
|
|
7
8
|
icon?: ReactNode;
|
|
8
9
|
children?: ReactNode;
|
|
10
|
+
disabled?: boolean;
|
|
9
11
|
};
|
|
10
|
-
export
|
|
11
|
-
export {};
|
|
12
|
+
export declare function ModalButton<T extends ModalConfig>({ id, params, ...props }: ButtonProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.ModalButton = ModalButton;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const context_1 = require("../../state/context");
|
|
7
6
|
const core_1 = require("@bouku/core");
|
|
7
|
+
const context_1 = require("../../state/context");
|
|
8
8
|
function ModalButton({ id, params, ...props }) {
|
|
9
9
|
const { openModal } = (0, context_1.useRawModal)();
|
|
10
|
-
return ((0, jsx_runtime_1.jsx)(core_1.Button, { ...props, action: () => openModal(id, params) }));
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(core_1.Button, { ...props, action: () => openModal(id.toString(), params) }));
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bouku/modal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@bouku/animate": "^0.0.1",
|
|
24
|
-
"@bouku/core": "^0.
|
|
25
|
-
"@bouku/form": "^0.1.
|
|
24
|
+
"@bouku/core": "^0.4.1",
|
|
25
|
+
"@bouku/form": "^0.1.9",
|
|
26
26
|
"clsx": "^2.1.1",
|
|
27
27
|
"formeact": "^0.0.3",
|
|
28
28
|
"framer-motion": "^12.16.0",
|
package/dist/state/root.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Root Modal component
|
|
3
|
-
*
|
|
4
|
-
* Injected into the root layout in a hidden state,
|
|
5
|
-
* then when a modal is opened this is displayed and wraps
|
|
6
|
-
* the new modal with a backdrop.
|
|
7
|
-
**/
|
|
8
|
-
export default function RootModal(): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
/**
|
|
10
|
-
* Problems:
|
|
11
|
-
*
|
|
12
|
-
* - Perfect `useModal`
|
|
13
|
-
* - Perfect `Animation`
|
|
14
|
-
**/
|
package/dist/state/root.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.default = RootModal;
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const context_1 = require("./context");
|
|
7
|
-
const react_1 = require("@bouko/react");
|
|
8
|
-
/**
|
|
9
|
-
* Root Modal component
|
|
10
|
-
*
|
|
11
|
-
* Injected into the root layout in a hidden state,
|
|
12
|
-
* then when a modal is opened this is displayed and wraps
|
|
13
|
-
* the new modal with a backdrop.
|
|
14
|
-
**/
|
|
15
|
-
function RootModal() {
|
|
16
|
-
const { activeId, modal } = (0, context_1.useModal)();
|
|
17
|
-
return ((0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { mode: "wait", children: modal && ((0, jsx_runtime_1.jsx)(react_1.Animation, { style: styles.backdrop, children: (0, jsx_runtime_1.jsx)("div", { className: styles.content, children: modal }) }, activeId)) }));
|
|
18
|
-
}
|
|
19
|
-
const styles = {
|
|
20
|
-
backdrop: "fixed inset-0 flex justify-center items-center bg-background-light/60 dark:bg-background-dark/60 z-[99]",
|
|
21
|
-
content: "max-w-[80%] max-h-[85%] bg-background border border-border rounded-lg shadow-soft"
|
|
22
|
-
};
|