onekijs-ui 0.19.5 → 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 +62 -35
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +63 -36
- package/dist/index.module.js.map +1 -1
- package/dist/styles/typography.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/button/SubmitButton.tsx +14 -7
- package/src/components/card/FormCard.tsx +17 -4
- package/src/components/card/components/FormCardDisplayerComponent.tsx +2 -2
- package/src/components/wizard/components/FormStep.tsx +35 -22
- package/src/components/wizard/components/WizardSummaryComponent.tsx +2 -2
package/dist/index.js
CHANGED
|
@@ -1495,11 +1495,12 @@ const TooltipContent = ({ code, fields }) => {
|
|
|
1495
1495
|
if (code <= onekijsFramework.ValidationCode.Error) {
|
|
1496
1496
|
return (React.createElement(React.Fragment, null,
|
|
1497
1497
|
React.createElement("div", null,
|
|
1498
|
-
"Some fields are
|
|
1498
|
+
"Some fields are ",
|
|
1499
1499
|
code === onekijsFramework.ValidationCode.Error ? 'in error' : 'loading'),
|
|
1500
1500
|
Object.keys(fields).map((fieldName, index) => (React.createElement("div", { key: `error-${index}` },
|
|
1501
|
-
React.createElement(
|
|
1502
|
-
|
|
1501
|
+
fieldName !== onekijsFramework.FORM_GLOBAL_VALIDATION_KEY ? React.createElement(React.Fragment, null,
|
|
1502
|
+
React.createElement("b", null, "fieldName"),
|
|
1503
|
+
":") : '',
|
|
1503
1504
|
fields[fieldName])))));
|
|
1504
1505
|
}
|
|
1505
1506
|
return null;
|
|
@@ -1508,19 +1509,26 @@ const SubmitButton = React.memo((opts) => {
|
|
|
1508
1509
|
const { submitting, code, fields } = onekijsFramework.useSubmit();
|
|
1509
1510
|
const { showErrors, type = 'submit', ...props } = opts;
|
|
1510
1511
|
let disabled = props.disabled || false;
|
|
1512
|
+
let loading = false;
|
|
1513
|
+
let kind = props.kind || 'primary';
|
|
1511
1514
|
let errors = [];
|
|
1512
1515
|
if (code <= onekijsFramework.ValidationCode.Error) {
|
|
1513
1516
|
disabled = true;
|
|
1514
1517
|
if (showErrors) {
|
|
1515
1518
|
errors = Object.keys(fields);
|
|
1516
1519
|
}
|
|
1520
|
+
kind = 'danger';
|
|
1521
|
+
}
|
|
1522
|
+
if (code === onekijsFramework.ValidationCode.Loading) {
|
|
1523
|
+
loading = true;
|
|
1524
|
+
kind = 'dark';
|
|
1517
1525
|
}
|
|
1518
1526
|
// eslint-disable-next-line react/prop-types
|
|
1519
|
-
if (submitting) {
|
|
1527
|
+
if (submitting || loading) {
|
|
1520
1528
|
disabled = true;
|
|
1521
1529
|
}
|
|
1522
|
-
return (React.createElement(Tooltip, { content: errors.length > 0 ? React.createElement(TooltipContent, { code: code, fields: fields }) : undefined, placement: "top", kind:
|
|
1523
|
-
React.createElement(Button, { ...props, disabled: disabled, type: type, loading: submitting }, props.children ? props.children : 'Submit')));
|
|
1530
|
+
return (React.createElement(Tooltip, { content: errors.length > 0 && !loading ? React.createElement(TooltipContent, { code: code, fields: fields }) : undefined, placement: "top", kind: kind, delayHide: 0 },
|
|
1531
|
+
React.createElement(Button, { ...props, kind: kind, disabled: disabled, type: type, loading: submitting || loading }, props.children ? props.children : 'Submit')));
|
|
1524
1532
|
});
|
|
1525
1533
|
SubmitButton.displayName = 'SubmitButton';
|
|
1526
1534
|
|
|
@@ -1664,7 +1672,7 @@ const FormCardDisplayerComponent = (displayerProps) => {
|
|
|
1664
1672
|
return (React.createElement("div", { className: addClassname('o-displayer-card', displayerProps.className) },
|
|
1665
1673
|
React.createElement("div", { className: "o-displayer-card-title" }, displayerProps.name),
|
|
1666
1674
|
Object.values(displayerProps.children ?? {}).map((field, index) => {
|
|
1667
|
-
const Displayer = field.Displayer;
|
|
1675
|
+
const Displayer = field.Displayer ?? onekijsFramework.DefaultDisplayer;
|
|
1668
1676
|
return React.createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === total - 1, format: displayerProps.format });
|
|
1669
1677
|
})));
|
|
1670
1678
|
};
|
|
@@ -1685,6 +1693,7 @@ const FormCard = ({ name, ...cardProps }) => {
|
|
|
1685
1693
|
container: name,
|
|
1686
1694
|
});
|
|
1687
1695
|
const { hide, show, disable, enable } = fieldContainer;
|
|
1696
|
+
const initializedRef = React.useRef(false);
|
|
1688
1697
|
React.useEffect(() => {
|
|
1689
1698
|
const visible = metadata.visible ?? true;
|
|
1690
1699
|
const disabled = metadata.disabled ?? false;
|
|
@@ -1693,19 +1702,29 @@ const FormCard = ({ name, ...cardProps }) => {
|
|
|
1693
1702
|
disable();
|
|
1694
1703
|
}
|
|
1695
1704
|
else {
|
|
1696
|
-
|
|
1705
|
+
if (initializedRef.current === true) {
|
|
1706
|
+
// we only use the enable method if this is a change and not a initialization
|
|
1707
|
+
enable();
|
|
1708
|
+
}
|
|
1697
1709
|
}
|
|
1698
1710
|
hide();
|
|
1699
1711
|
}
|
|
1700
1712
|
else {
|
|
1701
|
-
|
|
1713
|
+
if (initializedRef.current === true) {
|
|
1714
|
+
// we only use the show method if this is a change and not a initialization
|
|
1715
|
+
show();
|
|
1716
|
+
}
|
|
1702
1717
|
if (disabled) {
|
|
1703
1718
|
disable();
|
|
1704
1719
|
}
|
|
1705
1720
|
else {
|
|
1706
|
-
|
|
1721
|
+
if (initializedRef.current === true) {
|
|
1722
|
+
// we only use the enable method if this is a change and not a initialization
|
|
1723
|
+
enable();
|
|
1724
|
+
}
|
|
1707
1725
|
}
|
|
1708
1726
|
}
|
|
1727
|
+
initializedRef.current = true;
|
|
1709
1728
|
}, [metadata.visible, metadata.disabled, hide, show, disable, enable]);
|
|
1710
1729
|
if (metadata.visible === false) {
|
|
1711
1730
|
return null;
|
|
@@ -11230,7 +11249,7 @@ const WizardSummaryComponent = ({ className }) => {
|
|
|
11230
11249
|
const form = onekijsFramework.useForm();
|
|
11231
11250
|
const tree = Object.values(form.getDisplayerTree());
|
|
11232
11251
|
return (React.createElement(Accordion, { className: className }, tree.map((field, index) => {
|
|
11233
|
-
const Displayer = field.Displayer;
|
|
11252
|
+
const Displayer = field.Displayer || onekijsFramework.DefaultDisplayer;
|
|
11234
11253
|
return React.createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === tree.length - 1, format: "form_summary" });
|
|
11235
11254
|
})));
|
|
11236
11255
|
};
|
|
@@ -11295,7 +11314,7 @@ const FormStep = ({ name, disabled = false, visible = true, ...stepProps }) => {
|
|
|
11295
11314
|
Displayer: (displayerProps) => {
|
|
11296
11315
|
const total = Object.values(displayerProps.children ?? {}).length;
|
|
11297
11316
|
return (React.createElement(AccordionPanel, { title: stepProps.title, initialActive: displayerProps.index === 0, initialExpand: displayerProps.index === 0 }, Object.values(displayerProps.children ?? {}).map((field, index) => {
|
|
11298
|
-
const Displayer = field.Displayer;
|
|
11317
|
+
const Displayer = field.Displayer ?? onekijsFramework.DefaultDisplayer;
|
|
11299
11318
|
return React.createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === total - 1, format: displayerProps.format });
|
|
11300
11319
|
})));
|
|
11301
11320
|
},
|
|
@@ -11309,6 +11328,7 @@ const FormStep = ({ name, disabled = false, visible = true, ...stepProps }) => {
|
|
|
11309
11328
|
},
|
|
11310
11329
|
});
|
|
11311
11330
|
const { touchAllFields, hide, show, disable, enable } = fieldContainer;
|
|
11331
|
+
const initializedRef = React.useRef(false);
|
|
11312
11332
|
React.useEffect(() => {
|
|
11313
11333
|
const visible = metadata.visible ?? true;
|
|
11314
11334
|
const disabled = metadata.disabled ?? false;
|
|
@@ -11319,44 +11339,51 @@ const FormStep = ({ name, disabled = false, visible = true, ...stepProps }) => {
|
|
|
11319
11339
|
}
|
|
11320
11340
|
else {
|
|
11321
11341
|
service.enable(name);
|
|
11322
|
-
|
|
11342
|
+
if (initializedRef.current === true) {
|
|
11343
|
+
// we only use the enable method if this is a change and not a initialization
|
|
11344
|
+
enable();
|
|
11345
|
+
}
|
|
11323
11346
|
}
|
|
11324
11347
|
service.hide(name);
|
|
11325
11348
|
hide();
|
|
11326
11349
|
}
|
|
11327
11350
|
else {
|
|
11328
11351
|
service.show(name);
|
|
11329
|
-
|
|
11352
|
+
if (initializedRef.current === true) {
|
|
11353
|
+
// we only use the show method if this is a change and not a initialization
|
|
11354
|
+
show();
|
|
11355
|
+
}
|
|
11330
11356
|
if (disabled) {
|
|
11331
11357
|
service.disable(name);
|
|
11332
11358
|
disable();
|
|
11333
11359
|
}
|
|
11334
11360
|
else {
|
|
11335
11361
|
service.enable(name);
|
|
11336
|
-
|
|
11362
|
+
if (initializedRef.current === true) {
|
|
11363
|
+
// we only use the enable method if this is a change and not a initialization
|
|
11364
|
+
enable();
|
|
11365
|
+
}
|
|
11337
11366
|
}
|
|
11338
11367
|
}
|
|
11368
|
+
initializedRef.current = true;
|
|
11339
11369
|
}, [name, metadata.visible, metadata.disabled]);
|
|
11340
|
-
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
}
|
|
11358
|
-
}
|
|
11359
|
-
}, [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]);
|
|
11360
11387
|
return (React.createElement(onekijsFramework.FormContext.Provider, { value: fieldContainer.context },
|
|
11361
11388
|
React.createElement(Step, { ...stepProps, uid: name, onTouch: touchAllFields })));
|
|
11362
11389
|
};
|