onekijs-ui 0.19.6 → 0.19.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.
package/dist/index.js CHANGED
@@ -1672,7 +1672,7 @@ const FormCardDisplayerComponent = (displayerProps) => {
1672
1672
  return (React.createElement("div", { className: addClassname('o-displayer-card', displayerProps.className) },
1673
1673
  React.createElement("div", { className: "o-displayer-card-title" }, displayerProps.name),
1674
1674
  Object.values(displayerProps.children ?? {}).map((field, index) => {
1675
- const Displayer = field.Displayer;
1675
+ const Displayer = field.Displayer ?? onekijsFramework.DefaultDisplayer;
1676
1676
  return React.createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === total - 1, format: displayerProps.format });
1677
1677
  })));
1678
1678
  };
@@ -1693,6 +1693,7 @@ const FormCard = ({ name, ...cardProps }) => {
1693
1693
  container: name,
1694
1694
  });
1695
1695
  const { hide, show, disable, enable } = fieldContainer;
1696
+ const initializedRef = React.useRef(false);
1696
1697
  React.useEffect(() => {
1697
1698
  const visible = metadata.visible ?? true;
1698
1699
  const disabled = metadata.disabled ?? false;
@@ -1701,19 +1702,29 @@ const FormCard = ({ name, ...cardProps }) => {
1701
1702
  disable();
1702
1703
  }
1703
1704
  else {
1704
- enable();
1705
+ if (initializedRef.current === true) {
1706
+ // we only use the enable method if this is a change and not a initialization
1707
+ enable();
1708
+ }
1705
1709
  }
1706
1710
  hide();
1707
1711
  }
1708
1712
  else {
1709
- show();
1713
+ if (initializedRef.current === true) {
1714
+ // we only use the show method if this is a change and not a initialization
1715
+ show();
1716
+ }
1710
1717
  if (disabled) {
1711
1718
  disable();
1712
1719
  }
1713
1720
  else {
1714
- enable();
1721
+ if (initializedRef.current === true) {
1722
+ // we only use the enable method if this is a change and not a initialization
1723
+ enable();
1724
+ }
1715
1725
  }
1716
1726
  }
1727
+ initializedRef.current = true;
1717
1728
  }, [metadata.visible, metadata.disabled, hide, show, disable, enable]);
1718
1729
  if (metadata.visible === false) {
1719
1730
  return null;
@@ -11238,7 +11249,7 @@ const WizardSummaryComponent = ({ className }) => {
11238
11249
  const form = onekijsFramework.useForm();
11239
11250
  const tree = Object.values(form.getDisplayerTree());
11240
11251
  return (React.createElement(Accordion, { className: className }, tree.map((field, index) => {
11241
- const Displayer = field.Displayer;
11252
+ const Displayer = field.Displayer || onekijsFramework.DefaultDisplayer;
11242
11253
  return React.createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === tree.length - 1, format: "form_summary" });
11243
11254
  })));
11244
11255
  };
@@ -11303,7 +11314,7 @@ const FormStep = ({ name, disabled = false, visible = true, ...stepProps }) => {
11303
11314
  Displayer: (displayerProps) => {
11304
11315
  const total = Object.values(displayerProps.children ?? {}).length;
11305
11316
  return (React.createElement(AccordionPanel, { title: stepProps.title, initialActive: displayerProps.index === 0, initialExpand: displayerProps.index === 0 }, Object.values(displayerProps.children ?? {}).map((field, index) => {
11306
- const Displayer = field.Displayer;
11317
+ const Displayer = field.Displayer ?? onekijsFramework.DefaultDisplayer;
11307
11318
  return React.createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === total - 1, format: displayerProps.format });
11308
11319
  })));
11309
11320
  },
@@ -11317,6 +11328,7 @@ const FormStep = ({ name, disabled = false, visible = true, ...stepProps }) => {
11317
11328
  },
11318
11329
  });
11319
11330
  const { touchAllFields, hide, show, disable, enable } = fieldContainer;
11331
+ const initializedRef = React.useRef(false);
11320
11332
  React.useEffect(() => {
11321
11333
  const visible = metadata.visible ?? true;
11322
11334
  const disabled = metadata.disabled ?? false;
@@ -11327,44 +11339,51 @@ const FormStep = ({ name, disabled = false, visible = true, ...stepProps }) => {
11327
11339
  }
11328
11340
  else {
11329
11341
  service.enable(name);
11330
- enable();
11342
+ if (initializedRef.current === true) {
11343
+ // we only use the enable method if this is a change and not a initialization
11344
+ enable();
11345
+ }
11331
11346
  }
11332
11347
  service.hide(name);
11333
11348
  hide();
11334
11349
  }
11335
11350
  else {
11336
11351
  service.show(name);
11337
- show();
11352
+ if (initializedRef.current === true) {
11353
+ // we only use the show method if this is a change and not a initialization
11354
+ show();
11355
+ }
11338
11356
  if (disabled) {
11339
11357
  service.disable(name);
11340
11358
  disable();
11341
11359
  }
11342
11360
  else {
11343
11361
  service.enable(name);
11344
- enable();
11362
+ if (initializedRef.current === true) {
11363
+ // we only use the enable method if this is a change and not a initialization
11364
+ enable();
11365
+ }
11345
11366
  }
11346
11367
  }
11368
+ initializedRef.current = true;
11347
11369
  }, [name, metadata.visible, metadata.disabled]);
11348
- React.useEffect(() => {
11349
- if (!visible) {
11350
- if (disabled) {
11351
- disable();
11352
- }
11353
- else {
11354
- enable();
11355
- }
11356
- hide();
11357
- }
11358
- else {
11359
- show();
11360
- if (disabled) {
11361
- disable();
11362
- }
11363
- else {
11364
- enable();
11365
- }
11366
- }
11367
- }, [visible, disabled, hide, show, disable, enable]);
11370
+ // useEffect(() => {
11371
+ // if (!visible) {
11372
+ // if (disabled) {
11373
+ // disable();
11374
+ // } else {
11375
+ // enable();
11376
+ // }
11377
+ // hide();
11378
+ // } else {
11379
+ // show();
11380
+ // if (disabled) {
11381
+ // disable();
11382
+ // } else {
11383
+ // enable();
11384
+ // }
11385
+ // }
11386
+ // }, [visible, disabled, hide, show, disable, enable]);
11368
11387
  return (React.createElement(onekijsFramework.FormContext.Provider, { value: fieldContainer.context },
11369
11388
  React.createElement(Step, { ...stepProps, uid: name, onTouch: touchAllFields })));
11370
11389
  };