@abgov/jsonforms-components 1.22.3 → 1.23.1

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/index.esm.js CHANGED
@@ -4880,6 +4880,7 @@ const FormStepper = props => {
4880
4880
  const submitForm = submitFormFunction && submitFormFunction();
4881
4881
  const categorization = uischema;
4882
4882
  const allCategories = JSON.parse(JSON.stringify(categorization));
4883
+ const componentProps = (_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) !== null && _b !== void 0 ? _b : {};
4883
4884
  const [step, setStep] = React.useState(0);
4884
4885
  const [isFormValid, setIsFormValid] = React.useState(false);
4885
4886
  const [showNextBtn, setShowNextBtn] = React.useState(true);
@@ -4918,10 +4919,9 @@ const FormStepper = props => {
4918
4919
  setIsFormValid(isValid);
4919
4920
  }, [ajv, data, schema]);
4920
4921
  useEffect(() => {
4921
- var _a, _b;
4922
4922
  // Override the "controlled Navigation", if property is supplied
4923
4923
  // Default: no controlled nav.
4924
- setStep(((_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.controlledNav) ? 1 : 0);
4924
+ setStep((componentProps === null || componentProps === void 0 ? void 0 : componentProps.controlledNav) ? 1 : 0);
4925
4925
  // eslint-disable-next-line react-hooks/exhaustive-deps
4926
4926
  }, []);
4927
4927
  if ((categories === null || categories === void 0 ? void 0 : categories.length) < 1) {
@@ -4960,7 +4960,7 @@ const FormStepper = props => {
4960
4960
  const isInputInitialized = inputId => {
4961
4961
  return inputId in inputStatuses;
4962
4962
  };
4963
- const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4963
+ const readOnly = (_c = componentProps === null || componentProps === void 0 ? void 0 : componentProps.readOnly) !== null && _c !== void 0 ? _c : false;
4964
4964
  const isFormSubmitted = (_d = enumerators === null || enumerators === void 0 ? void 0 : enumerators.isFormSubmitted) !== null && _d !== void 0 ? _d : false;
4965
4965
  return jsx("div", {
4966
4966
  "data-testid": "form-stepper-test-wrapper",
@@ -5051,7 +5051,7 @@ const FormStepper = props => {
5051
5051
  minChildWidth: "100px",
5052
5052
  children: [jsx("div", {
5053
5053
  children: step !== 1 ? jsx(GoAButton, {
5054
- type: "secondary",
5054
+ type: (componentProps === null || componentProps === void 0 ? void 0 : componentProps.previousButtonType) ? componentProps === null || componentProps === void 0 ? void 0 : componentProps.previousButtonType : 'secondary',
5055
5055
  disabled: disabledCategoryMap[step - 1],
5056
5056
  onClick: () => {
5057
5057
  const element = document.getElementById(`${path || `goa`}-form-stepper`);
@@ -5061,11 +5061,11 @@ const FormStepper = props => {
5061
5061
  prevPage(step, disabledCategoryMap);
5062
5062
  },
5063
5063
  testId: "prev-button",
5064
- children: "Previous"
5064
+ children: (componentProps === null || componentProps === void 0 ? void 0 : componentProps.previousButtonLabel) ? componentProps === null || componentProps === void 0 ? void 0 : componentProps.previousButtonLabel : 'Previous'
5065
5065
  }) : jsx("div", {})
5066
5066
  }), jsxs(RightAlignmentDiv, {
5067
5067
  children: [step !== null && showNextBtn && jsx(GoAButton, {
5068
- type: "primary",
5068
+ type: (componentProps === null || componentProps === void 0 ? void 0 : componentProps.nextButtonType) ? componentProps === null || componentProps === void 0 ? void 0 : componentProps.nextButtonType : 'primary',
5069
5069
  disabled: disabledCategoryMap[step - 1],
5070
5070
  onClick: () => {
5071
5071
  const element = document.getElementById(`${path || `goa`}-form-stepper`);
@@ -5075,10 +5075,10 @@ const FormStepper = props => {
5075
5075
  nextPage(step, disabledCategoryMap);
5076
5076
  },
5077
5077
  testId: "next-button",
5078
- children: "Next"
5078
+ children: (componentProps === null || componentProps === void 0 ? void 0 : componentProps.nextButtonLabel) ? componentProps === null || componentProps === void 0 ? void 0 : componentProps.nextButtonLabel : 'Next'
5079
5079
  }), !showNextBtn && !isFormSubmitted && jsx("div", {
5080
5080
  children: jsx(GoAButton, {
5081
- type: "primary",
5081
+ type: 'primary',
5082
5082
  onClick: handleSubmit,
5083
5083
  disabled: !isFormValid,
5084
5084
  testId: "stepper-submit-btn",
@@ -5382,8 +5382,9 @@ const ObjectArrayToolBar = /*#__PURE__*/React.memo(function TableToolbar({
5382
5382
  rootSchema,
5383
5383
  uischema
5384
5384
  }) {
5385
- var _a, _b;
5385
+ var _a, _b, _c, _d;
5386
5386
  const buttonPosition = ((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.addButtonPosition) || 'left';
5387
+ const arrayLabel = getLabelText(uischema.scope, label);
5387
5388
  return jsx(Fragment, {
5388
5389
  children: jsx("div", {
5389
5390
  style: {
@@ -5394,7 +5395,8 @@ const ObjectArrayToolBar = /*#__PURE__*/React.memo(function TableToolbar({
5394
5395
  testId: `object-array-toolbar-${label}`,
5395
5396
  "aria-label": translations.addAriaLabel,
5396
5397
  onClick: addItem(path, createDefaultValue(schema, rootSchema)),
5397
- children: ((_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.addButtonText) || 'Add'
5398
+ type: (_c = (_b = uischema.options) === null || _b === void 0 ? void 0 : _b.addButtonType) !== null && _c !== void 0 ? _c : 'primary',
5399
+ children: ((_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.addButtonText) || capitalizeFirstLetter(`Add ${arrayLabel}`)
5398
5400
  })
5399
5401
  })
5400
5402
  });
@@ -5981,7 +5983,7 @@ const RenderLink = props => {
5981
5983
  };
5982
5984
 
5983
5985
  const HelpContentComponent = _a => {
5984
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
5986
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
5985
5987
  var {
5986
5988
  isParent = true
5987
5989
  } = _a,
@@ -6019,24 +6021,25 @@ const HelpContentComponent = _a => {
6019
6021
  alt: alt
6020
6022
  });
6021
6023
  };
6024
+ const textVariant = !((_c = uischema.options) === null || _c === void 0 ? void 0 : _c.variant) || ((_d = uischema.options) === null || _d === void 0 ? void 0 : _d.variant) !== 'details' && ((_e = uischema.options) === null || _e === void 0 ? void 0 : _e.variant) !== 'link';
6022
6025
  return jsx(Visible, {
6023
6026
  visible: visible,
6024
6027
  children: jsx(HelpContentDiv, {
6025
- "aria-label": (_c = uischema.options) === null || _c === void 0 ? void 0 : _c.ariaLabel,
6028
+ "aria-label": (_f = uischema.options) === null || _f === void 0 ? void 0 : _f.ariaLabel,
6026
6029
  children: jsxs("div", {
6027
6030
  className: marginClass,
6028
- children: [label && !((_d = uischema.options) === null || _d === void 0 ? void 0 : _d.variant) && ((_e = uischema.options) === null || _e === void 0 ? void 0 : _e.variant) !== 'details' && jsxs("div", {
6031
+ children: [label && (!((_g = uischema.options) === null || _g === void 0 ? void 0 : _g.variant) || ((_h = uischema.options) === null || _h === void 0 ? void 0 : _h.variant) === 'link') && jsxs("div", {
6029
6032
  className: labelClass,
6030
6033
  "data-testid": label,
6031
6034
  children: [label, jsx("br", {})]
6032
- }), ((_f = uischema.options) === null || _f === void 0 ? void 0 : _f.variant) && ((_g = uischema.options) === null || _g === void 0 ? void 0 : _g.variant) === 'img' && renderImage(uischema.options), ((_h = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _h === void 0 ? void 0 : _h.link) && link !== '' && RenderLink(uischema === null || uischema === void 0 ? void 0 : uischema.options), (!((_j = uischema.options) === null || _j === void 0 ? void 0 : _j.variant) || ((_k = uischema.options) === null || _k === void 0 ? void 0 : _k.variant) !== 'details') && !link && renderHelp(), ((_l = uischema.options) === null || _l === void 0 ? void 0 : _l.variant) && ((_m = uischema.options) === null || _m === void 0 ? void 0 : _m.variant) === 'details' && jsxs(GoADetails, {
6035
+ }), ((_j = uischema.options) === null || _j === void 0 ? void 0 : _j.variant) && ((_k = uischema.options) === null || _k === void 0 ? void 0 : _k.variant) === 'img' && renderImage(uischema.options), ((_l = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _l === void 0 ? void 0 : _l.variant) && ((_m = uischema.options) === null || _m === void 0 ? void 0 : _m.variant) === 'link' && link && RenderLink(uischema === null || uischema === void 0 ? void 0 : uischema.options), textVariant && renderHelp(), ((_o = uischema.options) === null || _o === void 0 ? void 0 : _o.variant) && ((_p = uischema.options) === null || _p === void 0 ? void 0 : _p.variant) === 'details' && jsxs(GoADetails, {
6033
6036
  heading: label ? label : '',
6034
6037
  mt: "3xs",
6035
6038
  mb: "none",
6036
- children: [renderHelp(), (uischema === null || uischema === void 0 ? void 0 : uischema.elements) && ((_o = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _o === void 0 ? void 0 : _o.length) > 0 && jsx(HelpContents, {
6039
+ children: [renderHelp(), (uischema === null || uischema === void 0 ? void 0 : uischema.elements) && ((_q = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _q === void 0 ? void 0 : _q.length) > 0 && jsx(HelpContents, {
6037
6040
  elements: uischema === null || uischema === void 0 ? void 0 : uischema.elements
6038
6041
  })]
6039
- }), (uischema === null || uischema === void 0 ? void 0 : uischema.elements) && (uischema === null || uischema === void 0 ? void 0 : uischema.elements.length) > 0 && ((_p = uischema.options) === null || _p === void 0 ? void 0 : _p.variant) !== 'details' && jsx(HelpContents, {
6042
+ }), (uischema === null || uischema === void 0 ? void 0 : uischema.elements) && (uischema === null || uischema === void 0 ? void 0 : uischema.elements.length) > 0 && ((_r = uischema.options) === null || _r === void 0 ? void 0 : _r.variant) !== 'details' && jsx(HelpContents, {
6040
6043
  elements: uischema.elements,
6041
6044
  isParent: false
6042
6045
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.22.3",
3
+ "version": "1.23.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Government of Alberta - React renderers for JSON Forms based on the design system.",
6
6
  "repository": "https://github.com/GovAlta/adsp-monorepo",
@@ -1,8 +1,17 @@
1
+ import { GoAButtonType } from '@abgov/react-components-new';
1
2
  import { StatePropsOfLayout } from '@jsonforms/core';
2
3
  import { TranslateProps } from '@jsonforms/react';
3
4
  import { AjvProps } from '../../util/layout';
4
5
  export interface CategorizationStepperLayoutRendererProps extends StatePropsOfLayout, AjvProps, TranslateProps {
5
6
  }
7
+ export interface FormStepperComponentProps {
8
+ nextButtonLabel?: string;
9
+ nextButtonType?: GoAButtonType;
10
+ previousButtonLabel?: string;
11
+ previousButtonType?: GoAButtonType;
12
+ controlledNav?: number;
13
+ readOnly?: boolean;
14
+ }
6
15
  export declare const FormStepper: (props: CategorizationStepperLayoutRendererProps) => JSX.Element;
7
16
  export declare const FormStepperControl: (props: CategorizationStepperLayoutRendererProps & import("@jsonforms/core").OwnPropsOfLayout) => import("react/jsx-runtime").JSX.Element;
8
17
  export default FormStepper;