@abgov/jsonforms-components 1.42.8 → 1.43.0

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
@@ -5564,8 +5564,7 @@ const mapToVisibleStep = (step, allSteps, visibleSteps) => {
5564
5564
  return step;
5565
5565
  };
5566
5566
 
5567
- const summaryLabel = 'Summary';
5568
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5567
+ // eslint-disable-next-line
5569
5568
  const getProperty = (obj, propName) => {
5570
5569
  if (obj[propName] !== undefined) return obj[propName];
5571
5570
  for (const key in obj) {
@@ -5575,8 +5574,80 @@ const getProperty = (obj, propName) => {
5575
5574
  }
5576
5575
  }
5577
5576
  };
5577
+
5578
+ const FormStepperReviewer = props => {
5579
+ var _a, _b, _c;
5580
+ const {
5581
+ uischema,
5582
+ data,
5583
+ schema,
5584
+ ajv,
5585
+ cells,
5586
+ renderers,
5587
+ visible,
5588
+ enabled,
5589
+ navigationFunc
5590
+ } = props;
5591
+ const componentProps = (_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) !== null && _b !== void 0 ? _b : {};
5592
+ const readOnly = (_c = componentProps === null || componentProps === void 0 ? void 0 : componentProps.readOnly) !== null && _c !== void 0 ? _c : false;
5593
+ const categorization = uischema;
5594
+ const categories = categorization.elements.filter(category => isVisible(category, data, '', ajv));
5595
+ return jsx(ReviewItem, {
5596
+ children: categories.map((category, index) => {
5597
+ const categoryLabel = category.label || category.i18n || 'Unknown Category';
5598
+ const testId = `${categoryLabel}-review-link`;
5599
+ return jsxs(ReviewItemSection, {
5600
+ children: [jsxs(ReviewItemHeader, {
5601
+ children: [jsx(ReviewItemTitle, {
5602
+ children: categoryLabel
5603
+ }), navigationFunc && jsx(Anchor, {
5604
+ onClick: () => navigationFunc(index + 1),
5605
+ "data-testid": testId,
5606
+ onKeyDown: e => {
5607
+ if (!readOnly && (e.key === ' ' || e.key === 'Enter')) {
5608
+ e.preventDefault();
5609
+ navigationFunc(index + 1);
5610
+ }
5611
+ },
5612
+ children: readOnly ? 'View' : 'Edit'
5613
+ })]
5614
+ }), jsx(GoAGrid, {
5615
+ minChildWidth: "600px",
5616
+ children: category.elements.filter(field => {
5617
+ var _a, _b;
5618
+ const conditionProps = (_a = field.rule) === null || _a === void 0 ? void 0 : _a.condition;
5619
+ if (conditionProps && data) {
5620
+ const canHideControlParts = (_b = conditionProps === null || conditionProps === void 0 ? void 0 : conditionProps.scope) === null || _b === void 0 ? void 0 : _b.split('/');
5621
+ const canHideControl = canHideControlParts && canHideControlParts[(canHideControlParts === null || canHideControlParts === void 0 ? void 0 : canHideControlParts.length) - 1];
5622
+ const isHidden = getProperty(data, canHideControl);
5623
+ if (!isHidden) {
5624
+ return field;
5625
+ }
5626
+ } else {
5627
+ return field;
5628
+ }
5629
+ }).map((element, index) => {
5630
+ return jsx("div", {
5631
+ children: jsx(JsonFormsDispatch, {
5632
+ "data-testid": `jsonforms-object-list-defined-elements-dispatch`,
5633
+ schema: schema,
5634
+ uischema: element,
5635
+ enabled: enabled,
5636
+ renderers: GoAReviewRenderers,
5637
+ cells: cells
5638
+ })
5639
+ }, `form-stepper-category-${index}`);
5640
+ })
5641
+ })]
5642
+ }, index);
5643
+ })
5644
+ });
5645
+ };
5646
+
5647
+ const summaryLabel = 'Summary';
5648
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5578
5649
  const FormStepper = props => {
5579
- var _a, _b, _c, _d, _e;
5650
+ var _a, _b, _c, _d;
5580
5651
  const {
5581
5652
  uischema,
5582
5653
  data,
@@ -5597,16 +5668,13 @@ const FormStepper = props => {
5597
5668
  const componentProps = (_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) !== null && _b !== void 0 ? _b : {};
5598
5669
  const optionProps = uischema.options || {};
5599
5670
  const [step, setStep] = React.useState(0);
5671
+ const [staleCategories, setStaleCategories] = React.useState(categorization.elements);
5600
5672
  const [isFormValid, setIsFormValid] = React.useState(false);
5601
5673
  const [showNextBtn, setShowNextBtn] = React.useState(true);
5602
5674
  const [isOpen, setIsOpen] = React.useState(false);
5603
5675
  const [categories, setCategories] = React.useState(categorization.elements);
5604
5676
  const [inputStatuses, setInputStatuses] = React.useState({});
5605
5677
  const [stepStatuses, setStepStatuses] = React.useState([]);
5606
- useEffect(() => {
5607
- const cats = categorization.elements.filter(category => isVisible(category, data, '', ajv));
5608
- setCategories(cats);
5609
- }, [categorization, data, ajv]);
5610
5678
  const disabledCategoryMap = categories.map(c => !isEnabled(c, data, '', ajv));
5611
5679
  const handleSubmit = () => {
5612
5680
  if (submitForm) {
@@ -5622,6 +5690,10 @@ const FormStepper = props => {
5622
5690
  return categories.map(c => deriveLabelForUISchemaElement(c, t));
5623
5691
  }, [categories, t]);
5624
5692
  useEffect(() => {}, [categories.length]);
5693
+ useEffect(() => {
5694
+ const cats = categorization.elements.filter(category => isVisible(category, data, '', ajv));
5695
+ setCategories(cats);
5696
+ }, [categorization, data, ajv]);
5625
5697
  useEffect(() => {
5626
5698
  const statuses = Array(categories.length);
5627
5699
  categories.forEach((_, i) => {
@@ -5639,6 +5711,9 @@ const FormStepper = props => {
5639
5711
  setStep((componentProps === null || componentProps === void 0 ? void 0 : componentProps.controlledNav) ? 1 : 0);
5640
5712
  // eslint-disable-next-line react-hooks/exhaustive-deps
5641
5713
  }, []);
5714
+ useEffect(() => {
5715
+ setStaleCategories(categories);
5716
+ }, [categories]);
5642
5717
  /* istanbul ignore next */
5643
5718
  if ((categories === null || categories === void 0 ? void 0 : categories.length) < 1) {
5644
5719
  // eslint-disable-next-line
@@ -5691,8 +5766,7 @@ const FormStepper = props => {
5691
5766
  const isInputInitialized = inputId => {
5692
5767
  return inputId in inputStatuses;
5693
5768
  };
5694
- const readOnly = (_c = componentProps === null || componentProps === void 0 ? void 0 : componentProps.readOnly) !== null && _c !== void 0 ? _c : false;
5695
- const isFormSubmitted = (_d = enumerators === null || enumerators === void 0 ? void 0 : enumerators.isFormSubmitted) !== null && _d !== void 0 ? _d : false;
5769
+ const isFormSubmitted = (_c = enumerators === null || enumerators === void 0 ? void 0 : enumerators.isFormSubmitted) !== null && _c !== void 0 ? _c : false;
5696
5770
  return jsx("div", {
5697
5771
  "data-testid": "form-stepper-test-wrapper",
5698
5772
  children: jsx(Visible, {
@@ -5700,8 +5774,8 @@ const FormStepper = props => {
5700
5774
  children: jsxs("div", {
5701
5775
  id: `${path || `goa`}-form-stepper`,
5702
5776
  className: "formStepper",
5703
- children: [jsxs(GoAFormStepper, {
5704
- testId: ((_e = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _e === void 0 ? void 0 : _e.testId) || 'form-stepper-test',
5777
+ children: [categories.length === staleCategories.length && jsxs(GoAFormStepper, {
5778
+ testId: ((_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.testId) || 'form-stepper-test',
5705
5779
  step: step,
5706
5780
  onChange: step => {
5707
5781
  setTab(step);
@@ -5752,57 +5826,9 @@ const FormStepper = props => {
5752
5826
  marginBottom: '1rem'
5753
5827
  },
5754
5828
  children: summaryLabel
5755
- }), jsx(ReviewItem, {
5756
- children: categories.map((category, index) => {
5757
- const categoryLabel = category.label || category.i18n || 'Unknown Category';
5758
- const testId = `${categoryLabel}-review-link`;
5759
- return jsxs(ReviewItemSection, {
5760
- children: [jsxs(ReviewItemHeader, {
5761
- children: [jsx(ReviewItemTitle, {
5762
- children: categoryLabel
5763
- }), jsx(Anchor, {
5764
- tabIndex: readOnly ? -1 : 0,
5765
- onClick: () => setPage(index + 1),
5766
- "data-testid": testId,
5767
- onKeyDown: e => {
5768
- if (!readOnly && (e.key === ' ' || e.key === 'Enter')) {
5769
- e.preventDefault();
5770
- setPage(index + 1);
5771
- }
5772
- },
5773
- children: readOnly ? 'View' : 'Edit'
5774
- })]
5775
- }), jsx("div", {
5776
- children: category.elements.filter(field => {
5777
- var _a, _b;
5778
- const conditionProps = (_a = field.rule) === null || _a === void 0 ? void 0 : _a.condition;
5779
- /* istanbul ignore next */
5780
- if (conditionProps && data) {
5781
- const canHideControlParts = (_b = conditionProps === null || conditionProps === void 0 ? void 0 : conditionProps.scope) === null || _b === void 0 ? void 0 : _b.split('/');
5782
- const canHideControl = canHideControlParts && canHideControlParts[(canHideControlParts === null || canHideControlParts === void 0 ? void 0 : canHideControlParts.length) - 1];
5783
- const isHidden = getProperty(data, canHideControl);
5784
- if (!isHidden) {
5785
- return field;
5786
- }
5787
- } else {
5788
- return field;
5789
- }
5790
- }).map((element, index) => {
5791
- return jsx("div", {
5792
- children: jsx(JsonFormsDispatch, {
5793
- "data-testid": `jsonforms-object-list-defined-elements-dispatch`,
5794
- schema: schema,
5795
- uischema: element,
5796
- enabled: enabled,
5797
- renderers: GoAReviewRenderers,
5798
- cells: cells
5799
- })
5800
- }, `form-stepper-category-${index}`);
5801
- })
5802
- })]
5803
- }, index);
5804
- })
5805
- })]
5829
+ }), jsx(FormStepperReviewer, Object.assign({
5830
+ navigationFunc: setPage
5831
+ }, props))]
5806
5832
  })]
5807
5833
  }), step !== 0 && jsxs(GoAGrid, {
5808
5834
  minChildWidth: "100px",
@@ -8008,7 +8034,7 @@ const AddressLookUpControl = props => {
8008
8034
  };
8009
8035
  useEffect(() => {
8010
8036
  const fetchSuggestions = () => __awaiter(void 0, void 0, void 0, function* () {
8011
- if (searchTerm.length > 2 && searchTerm.charAt(searchTerm.length - 1) !== ' ') {
8037
+ if (searchTerm.length > 2) {
8012
8038
  setLoading(true);
8013
8039
  setOpen(true);
8014
8040
  yield fetchAddressSuggestions(formUrl, searchTerm, isAlbertaAddress).then(response => {
@@ -8059,7 +8085,7 @@ const AddressLookUpControl = props => {
8059
8085
  } else if (key === 'ArrowUp') {
8060
8086
  setSelectedIndex(prevIndex => prevIndex > 0 ? prevIndex - 1 : suggestions.length - 1);
8061
8087
  handleInputChange('addressLine1', value);
8062
- } else if (key === 'Enter' || key === ' ' && value.length > 2) {
8088
+ } else if (key === 'Enter') {
8063
8089
  handleInputChange('addressLine1', value);
8064
8090
  setLoading(false);
8065
8091
  if (selectedIndex >= 0) {
@@ -10207,6 +10233,9 @@ const GoABaseReviewRenderers = [
10207
10233
  renderer: HelpReviewContent
10208
10234
  }];
10209
10235
  const GoAReviewRenderers = [...GoABaseReviewRenderers, {
10236
+ tester: CategorizationRendererTester,
10237
+ renderer: FormStepperReviewer
10238
+ }, {
10210
10239
  tester: FileUploaderTester,
10211
10240
  renderer: withJsonFormsControlProps(FileUploaderReview)
10212
10241
  }, {
@@ -10237,4 +10266,4 @@ const GoARenderers = [...GoABaseRenderers, {
10237
10266
  }];
10238
10267
  const GoACells = [...InputCells];
10239
10268
 
10240
- export { ADD_DATALIST_ACTION, ADD_NO_ANONYMOUS_ACTION, ADD_REGISTER_DATA_ACTION, ADD_REGISTER_DATA_ERROR, AddressLookUpControl, AddressLookUpControlReview, AddressLookUpTester, ArrayControl, ArrayControlBase, ArrayControlReview, BooleanComponent, BooleanControl, BooleanRadioComponent, BooleanRadioControl, CategorizationRendererTester, CheckboxGroup, ContextProviderC, ContextProviderClass, ContextProviderFactory, EnumCheckboxControl, EnumRadioControl, EnumSelect, FileUploader, FileUploaderReview, FileUploaderTester, FormStepper, FormStepperControl, FullNameControl, FullNameDobControl, FullNameDobReviewControl, FullNameDobTester, FullNameReviewControl, FullNameTester, GoAArrayControlRenderer, GoAArrayControlReviewRenderer, GoAArrayControlTester, GoABaseInputReviewComponent, GoABaseRenderers, GoABaseReviewRenderers, GoABooleanControl, GoABooleanControlTester, GoABooleanRadioControl, GoABooleanRadioControlTester, GoACells, GoACheckoutGroupControlTester, GoADateControl, GoADateControlTester, GoADateInput, GoADateTimeControl, GoADateTimeControlTester, GoADateTimeInput, GoAEnumCheckboxGroupControl, GoAEnumControl, GoAEnumControlTester, GoAEnumRadioGroupControl, GoAInputBaseControl, GoAInputDateControl, GoAInputDateTimeControl, GoAInputInteger, GoAInputIntegerControl, GoAInputNumberControl, GoAInputText, GoAInputTextControl, GoAInputTimeControl, GoAIntegerControl, GoAIntegerControlTester, GoAListWithDetailsControlRenderer, GoAListWithDetailsTester, GoANumberControl, GoANumberControlTester, GoANumberInput, GoARadioGroupControlTester, GoARenderers, GoAReviewRenderers, GoATextControl, GoATextControlTester, GoATimeControl, GoATimeControlTester, GoATimeInput, GoInputBaseReview, GoInputBaseReviewControl, JsonFormContext, JsonFormRegisterProvider, JsonFormsRegisterContext, ListWithDetailsControl, MultiLineText, MultiLineTextControl, MultiLineTextControlInput, MultiLineTextControlTester, RadioGroup, createDefaultAjv, enumControl, errMalformedDate, formatSin, getProperty, isAddressLookup, isFullName, isFullNameDoB, registerReducer, resolveRefs, tryResolveRefs };
10269
+ export { ADD_DATALIST_ACTION, ADD_NO_ANONYMOUS_ACTION, ADD_REGISTER_DATA_ACTION, ADD_REGISTER_DATA_ERROR, AddressLookUpControl, AddressLookUpControlReview, AddressLookUpTester, ArrayControl, ArrayControlBase, ArrayControlReview, BooleanComponent, BooleanControl, BooleanRadioComponent, BooleanRadioControl, CategorizationRendererTester, CheckboxGroup, ContextProviderC, ContextProviderClass, ContextProviderFactory, EnumCheckboxControl, EnumRadioControl, EnumSelect, FileUploader, FileUploaderReview, FileUploaderTester, FormStepper, FormStepperControl, FormStepperReviewer, FullNameControl, FullNameDobControl, FullNameDobReviewControl, FullNameDobTester, FullNameReviewControl, FullNameTester, GoAArrayControlRenderer, GoAArrayControlReviewRenderer, GoAArrayControlTester, GoABaseInputReviewComponent, GoABaseRenderers, GoABaseReviewRenderers, GoABooleanControl, GoABooleanControlTester, GoABooleanRadioControl, GoABooleanRadioControlTester, GoACells, GoACheckoutGroupControlTester, GoADateControl, GoADateControlTester, GoADateInput, GoADateTimeControl, GoADateTimeControlTester, GoADateTimeInput, GoAEnumCheckboxGroupControl, GoAEnumControl, GoAEnumControlTester, GoAEnumRadioGroupControl, GoAInputBaseControl, GoAInputDateControl, GoAInputDateTimeControl, GoAInputInteger, GoAInputIntegerControl, GoAInputNumberControl, GoAInputText, GoAInputTextControl, GoAInputTimeControl, GoAIntegerControl, GoAIntegerControlTester, GoAListWithDetailsControlRenderer, GoAListWithDetailsTester, GoANumberControl, GoANumberControlTester, GoANumberInput, GoARadioGroupControlTester, GoARenderers, GoAReviewRenderers, GoATextControl, GoATextControlTester, GoATimeControl, GoATimeControlTester, GoATimeInput, GoInputBaseReview, GoInputBaseReviewControl, JsonFormContext, JsonFormRegisterProvider, JsonFormsRegisterContext, ListWithDetailsControl, MultiLineText, MultiLineTextControl, MultiLineTextControlInput, MultiLineTextControlTester, RadioGroup, createDefaultAjv, enumControl, errMalformedDate, formatSin, isAddressLookup, isFullName, isFullNameDoB, registerReducer, resolveRefs, tryResolveRefs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.42.8",
3
+ "version": "1.43.0",
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,20 +1,11 @@
1
1
  import { GoAButtonType } from '@abgov/react-components-new';
2
- import { StatePropsOfLayout } from '@jsonforms/core';
3
- import { TranslateProps } from '@jsonforms/react';
4
- import { AjvProps } from '../../util/layout';
5
- export interface CategorizationStepperLayoutRendererProps extends StatePropsOfLayout, AjvProps, TranslateProps {
6
- }
7
- export interface FormStepperComponentProps {
8
- controlledNav?: number;
9
- readOnly?: boolean;
10
- }
2
+ import { CategorizationStepperLayoutRendererProps } from './types';
11
3
  export interface FormStepperOptionProps {
12
4
  nextButtonLabel?: string;
13
5
  nextButtonType?: GoAButtonType;
14
6
  previousButtonLabel?: string;
15
7
  previousButtonType?: GoAButtonType;
16
8
  }
17
- export declare const getProperty: any;
18
9
  export declare const FormStepper: (props: CategorizationStepperLayoutRendererProps) => JSX.Element;
19
10
  export declare const FormStepperControl: (props: CategorizationStepperLayoutRendererProps & import("@jsonforms/core").OwnPropsOfLayout) => import("react/jsx-runtime").JSX.Element;
20
11
  export default FormStepper;
@@ -0,0 +1,2 @@
1
+ import { CategorizationStepperLayoutReviewRendererProps } from './types';
2
+ export declare const FormStepperReviewer: (props: CategorizationStepperLayoutReviewRendererProps) => JSX.Element;
@@ -1,2 +1,3 @@
1
1
  export * from './FormStepperControl';
2
2
  export * from './FormStepperTester';
3
+ export * from './FormStepperReviewControl';
@@ -0,0 +1,12 @@
1
+ import { StatePropsOfLayout } from '@jsonforms/core';
2
+ import { AjvProps } from '../../util/layout';
3
+ import { TranslateProps } from '@jsonforms/react';
4
+ export interface CategorizationStepperLayoutRendererProps extends StatePropsOfLayout, AjvProps, TranslateProps {
5
+ }
6
+ export interface CategorizationStepperLayoutReviewRendererProps extends CategorizationStepperLayoutRendererProps {
7
+ navigationFunc?: (index: number) => void;
8
+ }
9
+ export interface FormStepperComponentProps {
10
+ controlledNav?: number;
11
+ readOnly?: boolean;
12
+ }
@@ -0,0 +1 @@
1
+ export declare const getProperty: any;