@openg2p/registry-widgets 1.1.0-dev.11 → 1.1.0-dev.12

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 +1 @@
1
- {"version":3,"file":"SectionsContainer.d.ts","sourceRoot":"","sources":["../../src/components/SectionsContainer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAmB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAOpE,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,QAAQ,GAAG,YAAY,CAAC;AAEnE,uHAAuH;AACvH,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7B,qEAAqE;IACrE,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,qFAAqF;IACrF,kBAAkB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAClD;;;OAGG;IACD,iBAAiB,IAAI,cAAc,EAAE,CAAC;CACvC;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IACpD,UAAU,CAAC,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAChD,aAAa,CAAC,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAClE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,wGAAwG;IACxG,OAAO,CAAC,EAAE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BAAoB,CAAC,eAAe,CAAC,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAClE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,wGAAwG;IACxG,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;IAEpE,wHAAwH;IACxH,oBAAoB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrE,0JAA0J;IAC1J,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACpD;AAoFD;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,yMAa/B,sBAAsB,4CAkVxB,CAAC"}
package/dist/index.esm.js CHANGED
@@ -5196,6 +5196,11 @@ const SectionsContainer = ({ sections, dataSourceRequestHandler: propDataSourceR
5196
5196
  // Stable ref for namespace so formHandle useMemo doesn't depend on the (possibly inline) function identity
5197
5197
  const namespaceRef = useRef(namespace);
5198
5198
  namespaceRef.current = namespace;
5199
+ // Stable ref for sections so formHandle useMemo doesn't depend on the (possibly unstable) array reference.
5200
+ // Without this, an inline sections={[...]} prop would recreate formHandle every render, causing
5201
+ // onFormReady to fire every render → host setState → infinite re-render loop.
5202
+ const safeSectionsRef = useRef(safeSections);
5203
+ safeSectionsRef.current = safeSections;
5199
5204
  // Stable refs so formHandle closure can access current mode and accordion setter without stale captures
5200
5205
  const modeRef = useRef(mode);
5201
5206
  modeRef.current = mode;
@@ -5244,6 +5249,9 @@ const SectionsContainer = ({ sections, dataSourceRequestHandler: propDataSourceR
5244
5249
  }, [mode, safeSections.length, expandedSectionIndex]);
5245
5250
  const UNSAVED_CHANGES_ERROR = 'Unsaved changes detected. Please save all sections before submitting.';
5246
5251
  // Form handle for onFormReady - allows host to validate and get all section data from its own Submit button
5252
+ // IMPORTANT: safeSections is intentionally accessed via safeSectionsRef.current (not closed over directly)
5253
+ // so that this memo never depends on the sections array reference. This prevents an infinite re-render
5254
+ // loop when the host passes an unstable sections prop (e.g. inline array or derived state).
5247
5255
  const formHandle = useMemo(() => {
5248
5256
  const getValues = () => store.getState().widget?.values || {};
5249
5257
  const getNamespace = (section, index) => {
@@ -5265,10 +5273,11 @@ const SectionsContainer = ({ sections, dataSourceRequestHandler: propDataSourceR
5265
5273
  if (modeRef.current !== 'IntakeForm')
5266
5274
  checkNoUnsavedChanges();
5267
5275
  const values = getValues();
5276
+ const sections = safeSectionsRef.current;
5268
5277
  let allValid = true;
5269
5278
  let firstInvalidIndex = null;
5270
- for (let i = 0; i < safeSections.length; i++) {
5271
- const section = safeSections[i];
5279
+ for (let i = 0; i < sections.length; i++) {
5280
+ const section = sections[i];
5272
5281
  const ns = getNamespace(section, i);
5273
5282
  const sectionToValidate = ns ? namespaceSectionConfig(section, ns) : section;
5274
5283
  const valid = sectionValidate(sectionToValidate, values, dispatch);
@@ -5288,10 +5297,11 @@ const SectionsContainer = ({ sections, dataSourceRequestHandler: propDataSourceR
5288
5297
  if (modeRef.current !== 'IntakeForm')
5289
5298
  checkNoUnsavedChanges();
5290
5299
  const values = getValues();
5300
+ const sections = safeSectionsRef.current;
5291
5301
  const results = [];
5292
5302
  let firstInvalidIndex = null;
5293
- for (let i = 0; i < safeSections.length; i++) {
5294
- const section = safeSections[i];
5303
+ for (let i = 0; i < sections.length; i++) {
5304
+ const section = sections[i];
5295
5305
  const ns = getNamespace(section, i);
5296
5306
  const sectionToValidate = ns ? namespaceSectionConfig(section, ns) : section;
5297
5307
  const valid = sectionValidate(sectionToValidate, values, dispatch);
@@ -5313,16 +5323,18 @@ const SectionsContainer = ({ sections, dataSourceRequestHandler: propDataSourceR
5313
5323
  },
5314
5324
  getStructuredData: () => {
5315
5325
  const values = getValues();
5326
+ const sections = safeSectionsRef.current;
5316
5327
  const results = [];
5317
- for (let i = 0; i < safeSections.length; i++) {
5318
- const section = safeSections[i];
5328
+ for (let i = 0; i < sections.length; i++) {
5329
+ const section = sections[i];
5319
5330
  const ns = getNamespace(section, i);
5320
5331
  results.push(buildSectionChanges(section, values, ns));
5321
5332
  }
5322
5333
  return results;
5323
5334
  },
5324
5335
  };
5325
- }, [store, dispatch, safeSections]);
5336
+ // eslint-disable-next-line react-hooks/exhaustive-deps
5337
+ }, [store, dispatch]); // safeSections intentionally omitted — accessed via safeSectionsRef
5326
5338
  // Call onFormReady when form is ready (sections loaded)
5327
5339
  useEffect(() => {
5328
5340
  if (onFormReady && safeSections.length > 0) {