@bouku/modal 0.0.5 → 0.0.7

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.
@@ -1,8 +1,17 @@
1
- import { ModalProps } from "./normal";
2
1
  import { FormBuilderField, FormData, FormSchema, PresetName } from "@bouku/form";
2
+ import type { ReactNode } from "react";
3
+ import type { Component } from "@bouku/core";
4
+ type ModalProps = Component & {
5
+ title: string;
6
+ subtitle?: ReactNode;
7
+ redirect?: {
8
+ label: string;
9
+ to: string;
10
+ };
11
+ };
3
12
  type Props<T extends FormData = FormData, P extends PresetName | undefined = undefined> = {
4
13
  fields: FormBuilderField[][];
5
- initialData?: Partial<T>;
14
+ initialData?: Partial<FormSchema<T, P>>;
6
15
  submitLabel?: string;
7
16
  validator?: (data: FormSchema<T, P>) => {
8
17
  success: boolean;
@@ -12,6 +21,7 @@ type Props<T extends FormData = FormData, P extends PresetName | undefined = und
12
21
  code?: string;
13
22
  message?: string;
14
23
  }>;
24
+ oops?: (message: string) => void;
15
25
  } & Omit<ModalProps, "children">;
16
26
  /**
17
27
  * Form Modal component.
@@ -19,7 +29,7 @@ type Props<T extends FormData = FormData, P extends PresetName | undefined = und
19
29
  * Combines a standard modal layout with a form builder.
20
30
  * Wraps @bouko/form `FormBuilder` for form handling.
21
31
  **/
22
- export declare function FormModal({ style, fields, initialData, submitLabel, submit, ...props }: Props): import("react/jsx-runtime").JSX.Element;
32
+ export declare function FormModal<T extends FormData = FormData, P extends PresetName | undefined = undefined>({ style, fields, initialData, submitLabel, submit, oops, ...props }: Props<T, P>): import("react/jsx-runtime").JSX.Element;
23
33
  export default FormModal;
24
34
  /**
25
35
  * Problems:
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FormModal = FormModal;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const normal_1 = require("./normal");
6
+ const notify_1 = require("@bouku/notify");
6
7
  const form_1 = require("@bouku/form");
7
8
  /**
8
9
  * Form Modal component.
@@ -10,7 +11,7 @@ const form_1 = require("@bouku/form");
10
11
  * Combines a standard modal layout with a form builder.
11
12
  * Wraps @bouko/form `FormBuilder` for form handling.
12
13
  **/
13
- function FormModal({ style, fields, initialData, submitLabel, submit, ...props }) {
14
- return ((0, jsx_runtime_1.jsx)(normal_1.Modal, { ...props, children: (0, jsx_runtime_1.jsx)(form_1.FormBuilder, { style: style, fields: fields, initialData: initialData, submitLabel: submitLabel, submit: submit }) }));
14
+ function FormModal({ style, fields, initialData, submitLabel, submit, oops, ...props }) {
15
+ return ((0, jsx_runtime_1.jsx)(normal_1.Modal, { ...props, children: (0, jsx_runtime_1.jsx)(form_1.FormBuilder, { style: style, fields: fields, initialData: initialData, submitLabel: submitLabel, submit: submit, oops: oops ?? ((msg) => (0, notify_1.isToasterMounted)() ? notify_1.toast.error(msg) : console.log(msg)) }) }));
15
16
  }
16
17
  exports.default = FormModal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bouku/modal",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "MIT",
@@ -23,6 +23,7 @@
23
23
  "@bouku/animate": "^0.0.1",
24
24
  "@bouku/core": "^0.4.1",
25
25
  "@bouku/form": "^0.1.9",
26
+ "@bouku/notify": "^0.0.2",
26
27
  "clsx": "^2.1.1",
27
28
  "formeact": "^0.0.3",
28
29
  "framer-motion": "^12.16.0",