@formancy/react 0.12.0 → 0.13.0

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/index.d.mts CHANGED
@@ -170,6 +170,13 @@ interface FormancyFormProps {
170
170
  * step offers "Check your answers" in place of sending (0204). Off unless asked for.
171
171
  */
172
172
  review?: boolean;
173
+ /**
174
+ * The host's own content under a field, by the field's path (a row's field by its own, as its
175
+ * wrapper's `data-formancy-field-path` says), or nothing: in the field's wrapper, after its
176
+ * label, description, control and error, as `data-formancy-part="field-addition"` (0233). A
177
+ * constant: a new function on every render redraws every field's addition.
178
+ */
179
+ fieldAddition?: (path: string) => ReactNode;
173
180
  onSubmit?: (outcome: SubmitOutcome) => void;
174
181
  }
175
182
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/context.tsx","../src/use-field.ts","../src/use-repeater.ts","../src/use-wizard.ts","../src/use-submit.ts","../src/go-to-field.ts","../src/fields/internals.tsx","../src/form.tsx","../src/error-summary.tsx","../src/rich-text.tsx","../src/options-source.ts","../src/scanning.ts","../src/uploads.ts","../src/rich-text-editor.ts","../src/resume-notice.tsx"],"mappings":";;;;;wBAsBgB,mBACd,QACA,OACA;EAEA,QAAQ;;;;;;;EAOR,QAAQ;EACR,WAAW;oBACZ,IAAA;wBAsBe,iBAAiB;;;;;;;;;wBAkBjB,eAAe;;;UCvEd,qBAAqB;EACpC,SAAS,YAAY;EACrB,MAAM;;EAEN,cAAc;;EAEd;IAAc;IAAY;;;EAE1B;IAAc;;;;;;;;;;;;;wBAaA,SAAS,eAAe,OAAO;;;UCrB9B;EACf;;EAEA;;EAEA;;EAEA;EACA;EACA,UAAU;;EAEV,QAAQ,cAAc;;;;;;;wBAQR,YAAY,eAAe,OAAO;;;UCrBjC;EACf;EACA;;;EAGA;EACA;;EAEA,QAAQ;EACR;;EAEA,KAAK;;;;;;;wBAQS,aAAa;;;;;;;;;;;wBCTb;EAAqB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,SAAS;;KAGpB,yBAAyB,OAAO,wBAAwB;qBAIvD,wCAAsB,SAAA;;;;;;;;;wBAUnB,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UC9C3B;WACN;WACA,SAAS;aAAyB;aAAuB;;;UAGnD;;WAEN,YAAY;;WAEZ,SAAS,SAAS;;wBAGb,eAAe,WAAW,UAAU,oBAAoB"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/context.tsx","../src/use-field.ts","../src/use-repeater.ts","../src/use-wizard.ts","../src/use-submit.ts","../src/go-to-field.ts","../src/fields/internals.tsx","../src/form.tsx","../src/error-summary.tsx","../src/rich-text.tsx","../src/options-source.ts","../src/scanning.ts","../src/uploads.ts","../src/rich-text-editor.ts","../src/resume-notice.tsx"],"mappings":";;;;;wBAsBgB,mBACd,QACA,OACA;EAEA,QAAQ;;;;;;;EAOR,QAAQ;EACR,WAAW;oBACZ,IAAA;wBAsBe,iBAAiB;;;;;;;;;wBAkBjB,eAAe;;;UCvEd,qBAAqB;EACpC,SAAS,YAAY;EACrB,MAAM;;EAEN,cAAc;;EAEd;IAAc;IAAY;;;EAE1B;IAAc;;;;;;;;;;;;;wBAaA,SAAS,eAAe,OAAO;;;UCrB9B;EACf;;EAEA;;EAEA;;EAEA;EACA;EACA,UAAU;;EAEV,QAAQ,cAAc;;;;;;;wBAQR,YAAY,eAAe,OAAO;;;UCrBjC;EACf;EACA;;;EAGA;EACA;;EAEA,QAAQ;EACR;;EAEA,KAAK;;;;;;;wBAQS,aAAa;;;;;;;;;;;wBCTb;EAAqB;EAAa,QAAQ;;;;;;;;;;;wBCD1C,iBAAiB;;;;;;;;;;;;;;;;UCYhB;EACf;EACA;;KAGU,iBAAiB,cAAc;UAE1B;EACf,SAAS,QAAQ,OAAO,WAAW;EACnC,SAAS,eAAe;;UAGT;EACf;EACA,QAAQ;;EAER;;UAGe;;;;;;;EAOf,SAAS;EACT,WAAW;;;;;;;EAOX;EACA;;;;;EAKA;;;;;;;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AAU,oBAAoB"}
package/dist/index.mjs CHANGED
@@ -493,6 +493,17 @@ function Review({ onChange, children }) {
493
493
  });
494
494
  }
495
495
  //#endregion
496
+ //#region src/field-addition.tsx
497
+ const FieldAdditionContext = createContext(void 0);
498
+ function FieldAdditionSlot({ path }) {
499
+ const content = useContext(FieldAdditionContext)?.(path);
500
+ if (content === void 0 || content === null || typeof content === "boolean") return null;
501
+ return /* @__PURE__ */ jsx("div", {
502
+ "data-formancy-part": "field-addition",
503
+ children: content
504
+ });
505
+ }
506
+ //#endregion
496
507
  //#region src/fields/internals.tsx
497
508
  function ErrorText({ field }) {
498
509
  const text = useFormText();
@@ -518,7 +529,8 @@ function FieldShell({ path, field, label, children }) {
518
529
  }),
519
530
  /* @__PURE__ */ jsx(Description, { field }),
520
531
  children,
521
- field.touched && field.errors.length > 0 ? /* @__PURE__ */ jsx(ErrorText, { field }) : null
532
+ field.touched && field.errors.length > 0 ? /* @__PURE__ */ jsx(ErrorText, { field }) : null,
533
+ /* @__PURE__ */ jsx(FieldAdditionSlot, { path })
522
534
  ]
523
535
  });
524
536
  }
@@ -1016,7 +1028,8 @@ function RadioGroupField({ path, label }) {
1016
1028
  })]
1017
1029
  }, option.value);
1018
1030
  }),
1019
- showError ? /* @__PURE__ */ jsx(ErrorText, { field }) : null
1031
+ showError ? /* @__PURE__ */ jsx(ErrorText, { field }) : null,
1032
+ /* @__PURE__ */ jsx(FieldAdditionSlot, { path })
1020
1033
  ]
1021
1034
  });
1022
1035
  }
@@ -1722,7 +1735,8 @@ function SelectBoxesField({ path, label }) {
1722
1735
  },
1723
1736
  children: text("options.retry")
1724
1737
  }) : null,
1725
- showError ? /* @__PURE__ */ jsx(ErrorText, { field }) : null
1738
+ showError ? /* @__PURE__ */ jsx(ErrorText, { field }) : null,
1739
+ /* @__PURE__ */ jsx(FieldAdditionSlot, { path })
1726
1740
  ]
1727
1741
  });
1728
1742
  }
@@ -1834,7 +1848,8 @@ function RankingField({ path, label }) {
1834
1848
  })
1835
1849
  }, option.value))
1836
1850
  }),
1837
- showError ? /* @__PURE__ */ jsx(ErrorText, { field }) : null
1851
+ showError ? /* @__PURE__ */ jsx(ErrorText, { field }) : null,
1852
+ /* @__PURE__ */ jsx(FieldAdditionSlot, { path })
1838
1853
  ]
1839
1854
  });
1840
1855
  }
@@ -1898,7 +1913,8 @@ function MatrixField({ path, label }) {
1898
1913
  })]
1899
1914
  }, row.value))
1900
1915
  }),
1901
- showError ? /* @__PURE__ */ jsx(ErrorText, { field }) : null
1916
+ showError ? /* @__PURE__ */ jsx(ErrorText, { field }) : null,
1917
+ /* @__PURE__ */ jsx(FieldAdditionSlot, { path })
1902
1918
  ]
1903
1919
  });
1904
1920
  }
@@ -2361,7 +2377,11 @@ const DEFAULT_COMPONENTS = {
2361
2377
  //#endregion
2362
2378
  //#region src/form.tsx
2363
2379
  function FormancyForm(props) {
2364
- return useFormEngine().wizard() === void 0 ? /* @__PURE__ */ jsx(FlatForm, { ...props }) : /* @__PURE__ */ jsx(PagedForm, { ...props });
2380
+ const engine = useFormEngine();
2381
+ return /* @__PURE__ */ jsx(FieldAdditionContext.Provider, {
2382
+ value: props.fieldAddition,
2383
+ children: engine.wizard() === void 0 ? /* @__PURE__ */ jsx(FlatForm, { ...props }) : /* @__PURE__ */ jsx(PagedForm, { ...props })
2384
+ });
2365
2385
  }
2366
2386
  function FlatForm(props) {
2367
2387
  const review = useReview();