@mittwald/flow-react-components 1.5.0-next.7 → 1.5.0-next.8

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.
@@ -3,17 +3,20 @@
3
3
  import { useFormContext } from "../FormContextProvider/FormContextProvider.mjs";
4
4
  import FieldErrorView from "../../../../views/FieldErrorView.mjs";
5
5
  import { useMountedFormRootErrorComponent } from "./useMountedFormRootErrorComponent.mjs";
6
- import { jsx } from "react/jsx-runtime";
6
+ import { Fragment, jsx } from "react/jsx-runtime";
7
7
  //#region src/integrations/react-hook-form/components/FormRootError/FormRootError.tsx
8
8
  /** @flowStatus new */
9
- var FormRootError = () => {
9
+ var FormRootError = (props) => {
10
+ const { children } = props;
10
11
  const form = useFormContext().form;
11
12
  useMountedFormRootErrorComponent();
12
13
  const error = form.formState.errors.root;
13
- return /* @__PURE__ */ jsx(FieldErrorView, {
14
+ if (children === void 0) return /* @__PURE__ */ jsx(FieldErrorView, {
14
15
  renderAlert: true,
15
16
  children: error?.message
16
17
  });
18
+ if (!error) return null;
19
+ return /* @__PURE__ */ jsx(Fragment, { children: typeof children === "function" ? children(error) : children });
17
20
  };
18
21
  //#endregion
19
22
  export { FormRootError, FormRootError as default };
@@ -1 +1 @@
1
- {"version":3,"file":"FormRootError.mjs","names":[],"sources":["../../../../../../../../../src/integrations/react-hook-form/components/FormRootError/FormRootError.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { useFormContext } from \"../FormContextProvider\";\nimport FieldErrorView from \"@/views/FieldErrorView\";\nimport { useMountedFormRootErrorComponent } from \"./useMountedFormRootErrorComponent\";\n\n/** @flowStatus new */\nexport const FormRootError: FC = () => {\n const form = useFormContext().form;\n useMountedFormRootErrorComponent();\n const error = form.formState.errors.root;\n return <FieldErrorView renderAlert>{error?.message}</FieldErrorView>;\n};\n\nexport default FormRootError;\n"],"mappings":";;;;;;;;AAMA,IAAa,sBAA0B;CACrC,MAAM,OAAO,eAAe,CAAC,CAAC;CAC9B,iCAAiC;CACjC,MAAM,QAAQ,KAAK,UAAU,OAAO;CACpC,OAAO,oBAAC,gBAAD;EAAgB,aAAA;EAAa,UAAA,OAAO;CAAwB,CAAA;AACrE"}
1
+ {"version":3,"file":"FormRootError.mjs","names":[],"sources":["../../../../../../../../../src/integrations/react-hook-form/components/FormRootError/FormRootError.tsx"],"sourcesContent":["import type { FC, ReactNode } from \"react\";\nimport type { FieldErrors } from \"react-hook-form\";\nimport { useFormContext } from \"../FormContextProvider\";\nimport FieldErrorView from \"@/views/FieldErrorView\";\nimport { useMountedFormRootErrorComponent } from \"./useMountedFormRootErrorComponent\";\n\nexport type FormRootErrorValue = NonNullable<FieldErrors[\"root\"]>;\n\nexport interface FormRootErrorProps {\n /**\n * Custom content shown instead of the default alert. Rendered only while a\n * root error is set. A function receives the root error, e.g. to pick the\n * content by its `type`.\n */\n children?: ReactNode | ((error: FormRootErrorValue) => ReactNode);\n}\n\n/** @flowStatus new */\nexport const FormRootError: FC<FormRootErrorProps> = (props) => {\n const { children } = props;\n const form = useFormContext().form;\n useMountedFormRootErrorComponent();\n const error = form.formState.errors.root;\n\n if (children === undefined) {\n return <FieldErrorView renderAlert>{error?.message}</FieldErrorView>;\n }\n\n if (!error) {\n return null;\n }\n\n return <>{typeof children === \"function\" ? children(error) : children}</>;\n};\n\nexport default FormRootError;\n"],"mappings":";;;;;;;;AAkBA,IAAa,iBAAyC,UAAU;CAC9D,MAAM,EAAE,aAAa;CACrB,MAAM,OAAO,eAAe,CAAC,CAAC;CAC9B,iCAAiC;CACjC,MAAM,QAAQ,KAAK,UAAU,OAAO;CAEpC,IAAI,aAAa,KAAA,GACf,OAAO,oBAAC,gBAAD;EAAgB,aAAA;EAAa,UAAA,OAAO;CAAwB,CAAA;CAGrE,IAAI,CAAC,OACH,OAAO;CAGT,OAAO,oBAAA,UAAA,EAAA,UAAG,OAAO,aAAa,aAAa,SAAS,KAAK,IAAI,SAAW,CAAA;AAC1E"}
@@ -1,4 +1,14 @@
1
- import { FC } from 'react';
1
+ import { FC, ReactNode } from 'react';
2
+ import { FieldErrors } from 'react-hook-form';
3
+ export type FormRootErrorValue = NonNullable<FieldErrors["root"]>;
4
+ export interface FormRootErrorProps {
5
+ /**
6
+ * Custom content shown instead of the default alert. Rendered only while a
7
+ * root error is set. A function receives the root error, e.g. to pick the
8
+ * content by its `type`.
9
+ */
10
+ children?: ReactNode | ((error: FormRootErrorValue) => ReactNode);
11
+ }
2
12
  /** @flowStatus new */
3
- export declare const FormRootError: FC;
13
+ export declare const FormRootError: FC<FormRootErrorProps>;
4
14
  export default FormRootError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/flow-react-components",
3
- "version": "1.5.0-next.7",
3
+ "version": "1.5.0-next.8",
4
4
  "type": "module",
5
5
  "description": "A React implementation of Flow, mittwald’s design system",
6
6
  "homepage": "https://flow.mittwald.de",
@@ -83,9 +83,9 @@
83
83
  "@internationalized/string-compiler": "^3.4.1",
84
84
  "@lezer/common": "^1.5.2",
85
85
  "@lezer/highlight": "^1.2.3",
86
- "@mittwald/flow-icons": "^1.5.0-next.7",
86
+ "@mittwald/flow-icons": "^1.5.0-next.8",
87
87
  "@mittwald/password-tools-js": "^3.0.0",
88
- "@mittwald/react-tunnel": "^1.5.0-next.7",
88
+ "@mittwald/react-tunnel": "^1.5.0-next.8",
89
89
  "@mittwald/react-use-promise": "^4.2.2",
90
90
  "@react-aria/form": "^3.2.1",
91
91
  "@react-aria/i18n": "^3.13.1",
@@ -138,12 +138,12 @@
138
138
  "@internationalized/date": "^3.12.3",
139
139
  "@lezer/generator": "^1.8.0",
140
140
  "@lezer/lr": "^1.4.10",
141
- "@mittwald/flow-core": "1.5.0-next.7",
142
- "@mittwald/flow-design-tokens": "1.5.0-next.7",
143
- "@mittwald/flow-icons-base": "1.5.0-next.7",
141
+ "@mittwald/flow-core": "1.5.0-next.8",
142
+ "@mittwald/flow-design-tokens": "1.5.0-next.8",
143
+ "@mittwald/flow-icons-base": "1.5.0-next.8",
144
144
  "@mittwald/react-use-promise": "^4.2.2",
145
145
  "@mittwald/remote-dom-react": "1.2.2-mittwald.10",
146
- "@mittwald/typescript-config": "1.5.0-next.7",
146
+ "@mittwald/typescript-config": "1.5.0-next.8",
147
147
  "@nx/storybook": "^22.7.6",
148
148
  "@storybook/addon-a11y": "^10.5.10",
149
149
  "@storybook/addon-actions": "^9.0.8",
@@ -195,7 +195,7 @@
195
195
  },
196
196
  "peerDependencies": {
197
197
  "@internationalized/date": "^3.12.2",
198
- "@mittwald/flow-icons-pro": "1.5.0-next.7",
198
+ "@mittwald/flow-icons-pro": "1.5.0-next.8",
199
199
  "@mittwald/react-use-promise": "^4.2.2",
200
200
  "next": "^16.2.3",
201
201
  "react": "^19.2.0",
@@ -219,5 +219,5 @@
219
219
  "browserslist": [
220
220
  "baseline widely available"
221
221
  ],
222
- "gitHead": "b8197d594872c5342fb4da079a7ef473243bfea4"
222
+ "gitHead": "512563065849610b77b5b2d484ee49ccbbfeae79"
223
223
  }