onekijs-ui 0.19.5 → 0.19.6

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
@@ -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 in ",
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("b", null, fieldName),
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: "danger", delayHide: 0 },
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