@cedarjs/forms 7.0.0 → 7.0.1-next.307

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.
@@ -81,5 +81,5 @@ export interface FieldErrorProps extends React.ComponentPropsWithoutRef<'span'>
81
81
  *
82
82
  * @see {@link https://react-hook-form.com/get-started#Handleerrors}
83
83
  */
84
- export declare const FieldError: ({ name, render, ...rest }: FieldErrorProps) => string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
84
+ export declare const FieldError: ({ name, render, ...rest }: FieldErrorProps) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
85
85
  //# sourceMappingURL=FieldError.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FieldError.d.ts","sourceRoot":"","sources":["../src/FieldError.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;IAC5C;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,eAAgB,SAAQ,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC;IAC7E;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,KAAK,CAAC,SAAS,CAAA;CAC3D;AAYD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,UAAU,GAAI,2BAA2B,eAAe,iGAsDpE,CAAA"}
1
+ {"version":3,"file":"FieldError.d.ts","sourceRoot":"","sources":["../src/FieldError.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;IAC5C;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,eAAgB,SAAQ,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC;IAC7E;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,KAAK,CAAC,SAAS,CAAA;CAC3D;AAYD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,UAAU,GAAI,2BAA2B,eAAe,oSAsDpE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../src/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAIzC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAI/E,MAAM,WAAW,SAAS,CACxB,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,CACjC,SAAQ,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7D,KAAK,CAAC,EAAE,GAAG,CAAA;IACX;;;;;;;;;;;;;;;;;;;OAmBG;IACH,WAAW,CAAC,EAAE,aAAa,CAAC,YAAY,EAAE,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AAK,CAAC,EAAE,KAAK,CAAC,kBAAkB,KAC7B,IAAI,CAAA;CACV;AA2DD,eAAO,MAAM,IAAI,EAA4B,CAC3C,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,QAAQ,GAAG,GAAG,EACd,kBAAkB,GAAG,YAAY,EAEjC,KAAK,EAAE,SAAS,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,CAAC,GAC1D,KAAK,CAAC,aAAa,CAAC,eAAe,CAAC,KACnC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA"}
package/dist/Form.js CHANGED
@@ -25,7 +25,12 @@ function FormInner({
25
25
  /* @__PURE__ */ React.createElement(
26
26
  ServerErrorsContext.Provider,
27
27
  {
28
- value: errorProps?.graphQLErrors?.[0]?.extensions?.properties?.messages || {}
28
+ value: (
29
+ // Apollo Client 4 stores GraphQL errors in `errors`
30
+ // (`CombinedGraphQLErrors`); `graphQLErrors` is the Apollo Client 3
31
+ // shape, kept for tests, Storybook mocks and other GraphQL clients
32
+ errorProps?.graphQLErrors?.[0]?.extensions?.properties?.messages || errorProps?.errors?.[0]?.extensions?.properties?.messages || {}
33
+ )
29
34
  },
30
35
  /* @__PURE__ */ React.createElement(FormProvider, { ...formMethods }, children)
31
36
  )
@@ -12,8 +12,16 @@ export interface ServerError extends Error {
12
12
  }
13
13
  export interface RWGqlError {
14
14
  message: string;
15
- graphQLErrors: readonly GraphQLFormattedError[];
16
- networkError: Error | ServerParseError | ServerError | null;
15
+ /**
16
+ * GraphQL errors as exposed by Apollo Client 4's `CombinedGraphQLErrors`
17
+ */
18
+ errors?: readonly GraphQLFormattedError[];
19
+ /**
20
+ * GraphQL errors in the Apollo Client 3 shape. Kept so tests, Storybook
21
+ * mocks and other GraphQL clients that use this shape keep working
22
+ */
23
+ graphQLErrors?: readonly GraphQLFormattedError[];
24
+ networkError?: Error | ServerParseError | ServerError | null;
17
25
  }
18
26
  export type RwGqlErrorProperties = Record<string, Record<string, string[]>>;
19
27
  interface Form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M,CAAA;IAC1B,aAAa,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CACpC;AAED;;;GAGG;AACH,QAAA,MAAM,SAAS,GAAI,oIAUhB,cAAc,6BAmFhB,CAAA;AAED,eAAe,SAAS,CAAA"}
package/dist/FormError.js CHANGED
@@ -15,14 +15,21 @@ const FormError = ({
15
15
  }
16
16
  let rootMessage = error.message;
17
17
  const messages = [];
18
- const hasGraphQLError = !!error.graphQLErrors?.[0];
19
- const hasNetworkError = !!error.networkError && Object.keys(error.networkError).length > 0;
18
+ const graphQLErrors = error.graphQLErrors?.length ? error.graphQLErrors : error.errors ?? [];
19
+ const hasGraphQLError = !!graphQLErrors[0];
20
+ const networkError = error.networkError ?? ("bodyText" in error || "result" in error ? (
21
+ // `RWGqlError` is a loose interface over what GraphQL clients throw;
22
+ // when the object has server-error fields the error itself is the
23
+ // network error
24
+ error
25
+ ) : null);
26
+ const hasNetworkError = !!networkError && Object.keys(networkError).length > 0;
20
27
  if (hasGraphQLError) {
21
- rootMessage = error.graphQLErrors[0].message ?? "Something went wrong";
22
- if (error.graphQLErrors[0]?.extensions?.code === "BAD_USER_INPUT") {
28
+ rootMessage = graphQLErrors[0].message ?? "Something went wrong";
29
+ if (graphQLErrors[0]?.extensions?.code === "BAD_USER_INPUT") {
23
30
  rootMessage = "Errors prevented this form from being saved";
24
31
  }
25
- const properties = error.graphQLErrors[0].extensions?.["properties"];
32
+ const properties = graphQLErrors[0].extensions?.["properties"];
26
33
  const propertyMessages = properties?.["messages"];
27
34
  if (propertyMessages) {
28
35
  for (const e in propertyMessages) {
@@ -33,11 +40,11 @@ const FormError = ({
33
40
  }
34
41
  } else if (hasNetworkError) {
35
42
  rootMessage = rootMessage ?? "An error has occurred";
36
- if (Object.prototype.hasOwnProperty.call(error.networkError, "bodyText")) {
37
- const netErr = error.networkError;
43
+ if ("bodyText" in networkError) {
44
+ const netErr = networkError;
38
45
  messages.push(`${netErr.name}: ${netErr.bodyText}`);
39
- } else if (Object.prototype.hasOwnProperty.call(error.networkError, "result")) {
40
- const netErr = error.networkError;
46
+ } else if ("result" in networkError) {
47
+ const netErr = networkError;
41
48
  netErr.result.errors?.forEach((error2) => {
42
49
  if (typeof error2.message === "string") {
43
50
  if (error2.message.indexOf(";") >= 0) {
package/dist/Submit.d.ts CHANGED
@@ -10,7 +10,5 @@ import React from 'react';
10
10
  * </Form>
11
11
  * ```
12
12
  */
13
- export declare const Submit: React.ForwardRefExoticComponent<Omit<Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
14
- ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
15
- }, "type">, "ref"> & React.RefAttributes<HTMLButtonElement>>;
13
+ export declare const Submit: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "type">, "ref"> & React.RefAttributes<HTMLButtonElement>>;
16
14
  //# sourceMappingURL=Submit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Submit.d.ts","sourceRoot":"","sources":["../src/Submit.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM;;4DAG6C,CAAA"}
1
+ {"version":3,"file":"Submit.d.ts","sourceRoot":"","sources":["../src/Submit.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,gMAG6C,CAAA"}
@@ -19,7 +19,7 @@ export declare const useRegister: <T, Element extends HTMLTextAreaElement | HTML
19
19
  }, ref?: React.ForwardedRef<T>, emptyAs?: EmptyAsValue) => {
20
20
  ref: (element: T) => void;
21
21
  onBlur: React.FocusEventHandler<Element>;
22
- onChange: React.ChangeEventHandler<Element>;
22
+ onChange: React.ChangeEventHandler<Element, globalThis.Element>;
23
23
  name: string;
24
24
  min?: string | number;
25
25
  max?: string | number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/forms",
3
- "version": "7.0.0",
3
+ "version": "7.0.1-next.307",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -36,24 +36,24 @@
36
36
  "react-hook-form": "7.88.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@cedarjs/framework-tools": "7.0.0",
39
+ "@cedarjs/framework-tools": "7.0.1-next.307",
40
40
  "@testing-library/dom": "10.4.2",
41
41
  "@testing-library/jest-dom": "6.9.1",
42
42
  "@testing-library/react": "16.3.3",
43
43
  "@testing-library/user-event": "14.6.7",
44
44
  "@types/pascalcase": "1.0.3",
45
- "@types/react": "^18.2.55",
46
- "@types/react-dom": "^18.2.19",
45
+ "@types/react": "^19.2.0",
46
+ "@types/react-dom": "^19.2.0",
47
47
  "concurrently": "9.2.4",
48
48
  "nodemon": "3.1.14",
49
49
  "publint": "0.3.24",
50
- "react": "18.3.1",
51
- "react-dom": "18.3.1",
50
+ "react": "19.3.0",
51
+ "react-dom": "19.3.0",
52
52
  "typescript": "5.9.3",
53
53
  "vitest": "4.1.11"
54
54
  },
55
55
  "peerDependencies": {
56
- "react": "18.3.1"
56
+ "react": "19.3.0"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=24"