@abgov/jsonforms-components 2.13.4 → 2.14.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
@@ -6,7 +6,7 @@ import styled from 'styled-components';
6
6
  import axios from 'axios';
7
7
  import get$1 from 'lodash/get';
8
8
  import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, getAjv, isVisible, getControlPath, toDataPath, deriveLabelForUISchemaElement, isEnabled, schemaTypeIs, formatIs, createDefaultValue, or, isObjectArrayControl, isPrimitiveArrayControl, Paths, schemaMatches, hasType, isControl, isCategorization, isLayout } from '@jsonforms/core';
9
- import { withJsonFormsControlProps, withJsonFormsRendererProps, withJsonFormsEnumProps, withTranslateProps, JsonFormsDispatch, useJsonForms, withJsonFormsLayoutProps, withJsonFormsArrayLayoutProps, withJsonFormsAllOfProps, withJsonFormsCellProps } from '@jsonforms/react';
9
+ import { withJsonFormsControlProps, withJsonFormsEnumProps, withTranslateProps, JsonFormsDispatch, useJsonForms, withJsonFormsLayoutProps, withJsonFormsArrayLayoutProps, withJsonFormsAllOfProps, withJsonFormsCellProps } from '@jsonforms/react';
10
10
  import * as _$b from 'lodash';
11
11
  import { isEqual, isEmpty as isEmpty$1, isObject as isObject$f } from 'lodash';
12
12
  import merge from 'lodash/merge';
@@ -5237,7 +5237,7 @@ styled.h4(_t8$2 || (_t8$2 = _$9`
5237
5237
  `));
5238
5238
 
5239
5239
  const GoAInputBaseControl = props => {
5240
- var _a, _b;
5240
+ var _a, _b, _c, _d, _e;
5241
5241
  const {
5242
5242
  uischema,
5243
5243
  visible,
@@ -5262,11 +5262,11 @@ const GoAInputBaseControl = props => {
5262
5262
  visible: visible,
5263
5263
  children: jsx(FormFieldWrapper, {
5264
5264
  children: jsx(GoAFormItem, {
5265
- requirement: required || getRequiredIfThen(props).length > 0 ? 'required' : undefined,
5265
+ requirement: (_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.requirement) !== null && _c !== void 0 ? _c : required || getRequiredIfThen(props).length > 0 ? 'required' : undefined,
5266
5266
  error: isVisited === true ? modifiedErrors : undefined,
5267
5267
  testId: `${isStepperReview === true && 'review-base-'}${path}`,
5268
5268
  label: (props === null || props === void 0 ? void 0 : props.noLabel) === true ? '' : labelToUpdate,
5269
- helpText: typeof ((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.help) === 'string' && !isStepperReview ? (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.help : '',
5269
+ helpText: typeof ((_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.help) === 'string' && !isStepperReview ? (_e = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _e === void 0 ? void 0 : _e.help : '',
5270
5270
  children: jsx(InnerComponent, Object.assign({}, props, {
5271
5271
  isVisited,
5272
5272
  errors: modifiedErrors,
@@ -5867,7 +5867,8 @@ const GoAInputText = props => {
5867
5867
  width: width,
5868
5868
  readonly: readOnly,
5869
5869
  maxLength: isSinField ? 11 : '',
5870
- placeholder: placeholder
5870
+ placeholder: placeholder,
5871
+ ariaLabel: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`
5871
5872
  }, (_p = uischema.options) === null || _p === void 0 ? void 0 : _p.componentProps, {
5872
5873
  // maxLength={appliedUiSchemaOptions?.maxLength}
5873
5874
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
@@ -5988,15 +5989,30 @@ const callout = props => {
5988
5989
  children: componentProps.message
5989
5990
  }));
5990
5991
  };
5991
- const CalloutControl = props => {
5992
- var _a, _b;
5993
- return callout(((_b = (_a = props === null || props === void 0 ? void 0 : props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.componentProps) || {});
5992
+ const GoACalloutController = props => {
5993
+ var _a;
5994
+ const {
5995
+ uischema,
5996
+ visible,
5997
+ data
5998
+ } = props;
5999
+ let showCallout;
6000
+ if (data === undefined || Array.isArray(data) && data.length === 0) {
6001
+ showCallout = false;
6002
+ } else {
6003
+ showCallout = visible === true;
6004
+ }
6005
+ const calloutProps = ((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) || {};
6006
+ return jsx(Visible, {
6007
+ visible: showCallout,
6008
+ children: callout(calloutProps)
6009
+ });
5994
6010
  };
5995
6011
  const CalloutReviewControl = () => {
5996
6012
  return jsx(Fragment, {});
5997
6013
  };
5998
6014
  const GoACalloutControlTester = rankWith(1, uiTypeIs('Callout'));
5999
- var GoACalloutControl = withJsonFormsRendererProps(CalloutControl);
6015
+ const GoACalloutControl = withJsonFormsControlProps(GoACalloutController);
6000
6016
 
6001
6017
  const errMalformedDate = (scope, type) => {
6002
6018
  return `${type}-date for variable '${scope}' has an incorrect format.`;
@@ -7035,6 +7051,8 @@ class ContextProviderClass {
7035
7051
  this.enumFunctions = new Map();
7036
7052
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7037
7053
  this.enumSubmitFunctions = new Map();
7054
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7055
+ this.enumSaveFunctions = new Map();
7038
7056
  this.addFormContextData = (key, data) => {
7039
7057
  this.enumValues.set(key, () => data);
7040
7058
  };
@@ -7055,10 +7073,13 @@ class ContextProviderClass {
7055
7073
  }
7056
7074
  if (props.submit) {
7057
7075
  const {
7058
- submitForm
7076
+ submitForm,
7077
+ saveForm
7059
7078
  } = props.submit;
7060
7079
  const submitFunction = submitForm;
7080
+ const saveFormFunction = saveForm;
7061
7081
  this.enumSubmitFunctions.set('submit-form', () => submitFunction);
7082
+ this.enumSaveFunctions.set('save-form', () => saveFormFunction);
7062
7083
  }
7063
7084
  if (props.data) {
7064
7085
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -7123,6 +7144,7 @@ class ContextProviderClass {
7123
7144
  data: this.enumValues,
7124
7145
  functions: this.enumFunctions,
7125
7146
  submitFunction: this.enumSubmitFunctions,
7147
+ saveFunction: this.enumSaveFunctions,
7126
7148
  addFormContextData: this.addFormContextData,
7127
7149
  getFormContextData: this.getFormContextData,
7128
7150
  getAllFormContextData: this.getAllFormContextData,
@@ -8292,6 +8314,7 @@ const BackButton = ({
8292
8314
  };
8293
8315
 
8294
8316
  const RenderPages = props => {
8317
+ var _a, _b;
8295
8318
  const {
8296
8319
  data,
8297
8320
  schema,
@@ -8314,8 +8337,11 @@ const RenderPages = props => {
8314
8337
  isValid,
8315
8338
  activeId
8316
8339
  } = formStepperCtx.selectStepperState();
8340
+ const hideSubmit = (_b = (_a = props.categoryProps.uischema.options) === null || _a === void 0 ? void 0 : _a.hideSubmit) !== null && _b !== void 0 ? _b : false;
8317
8341
  const submitFormFunction = enumerators === null || enumerators === void 0 ? void 0 : enumerators.submitFunction.get('submit-form');
8318
8342
  const submitForm = submitFormFunction && submitFormFunction();
8343
+ const saveFormFunction = enumerators === null || enumerators === void 0 ? void 0 : enumerators.saveFunction.get('save-form');
8344
+ const saveForm = saveFormFunction && saveFormFunction();
8319
8345
  const [isOpen, setIsOpen] = useState(false);
8320
8346
  const handleSubmit = () => {
8321
8347
  if (submitForm) {
@@ -8324,6 +8350,11 @@ const RenderPages = props => {
8324
8350
  setIsOpen(true);
8325
8351
  }
8326
8352
  };
8353
+ const handleSave = () => {
8354
+ if (saveForm) {
8355
+ saveForm(data);
8356
+ }
8357
+ };
8327
8358
  const onCloseModal = () => {
8328
8359
  setIsOpen(false);
8329
8360
  };
@@ -8368,7 +8399,10 @@ const RenderPages = props => {
8368
8399
  alignment: "start",
8369
8400
  children: [jsx(GoAButton, {
8370
8401
  type: "submit",
8371
- onClick: () => goToPage(activeId + 1),
8402
+ onClick: () => {
8403
+ handleSave();
8404
+ goToPage(activeId + 1);
8405
+ },
8372
8406
  disabled: !(category.isValid && category.isCompleted),
8373
8407
  testId: "pages-save-continue-btn",
8374
8408
  children: "Save and continue"
@@ -8400,13 +8434,13 @@ const RenderPages = props => {
8400
8434
  })), jsx(PageRenderPadding, {
8401
8435
  children: jsx(GoAButtonGroup, {
8402
8436
  alignment: "end",
8403
- children: jsx(GoAButton, {
8437
+ children: !hideSubmit ? jsx(GoAButton, {
8404
8438
  type: 'primary',
8405
8439
  onClick: handleSubmit,
8406
8440
  disabled: !isValid,
8407
8441
  testId: "pages-submit-btn",
8408
8442
  children: "Submit"
8409
- })
8443
+ }) : null
8410
8444
  })
8411
8445
  })]
8412
8446
  })]
@@ -9477,7 +9511,7 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
9477
9511
  }
9478
9512
  });
9479
9513
  },
9480
- "aria-label": schemaName,
9514
+ ariaLabel: schemaName,
9481
9515
  width: "100%"
9482
9516
  }) : jsx(GoACallout, {
9483
9517
  type: "important",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.13.4",
3
+ "version": "2.14.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",
@@ -9,5 +9,5 @@ export interface CalloutProps {
9
9
  export declare const callout: (props: CalloutProps) => JSX.Element;
10
10
  export declare const CalloutReviewControl: () => import("react/jsx-runtime").JSX.Element;
11
11
  export declare const GoACalloutControlTester: RankedTester;
12
- declare const _default: React.ComponentType<import("@jsonforms/core").OwnPropsOfJsonFormsRenderer>;
13
- export default _default;
12
+ export declare const GoACalloutControl: React.ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
13
+ export default GoACalloutControl;
@@ -7,6 +7,7 @@ export interface enumerators {
7
7
  data: Map<string, () => any>;
8
8
  functions: Map<string, () => (file: File, propertyId: string) => void | undefined>;
9
9
  submitFunction: Map<string, () => (id: string) => void | undefined>;
10
+ saveFunction: Map<string, () => (id: string) => void | undefined>;
10
11
  addFormContextData: (key: string, data: Record<string, unknown> | unknown[]) => void;
11
12
  getFormContextData: (key: string) => Record<string, any>;
12
13
  getAllFormContextData: () => AllData;
@@ -21,6 +22,7 @@ interface FileManagement {
21
22
  }
22
23
  interface SubmitManagement {
23
24
  submitForm?: (any: any) => void;
25
+ saveForm?: (any: any) => void;
24
26
  }
25
27
  type Props = {
26
28
  children?: React.ReactNode;
@@ -35,10 +37,12 @@ export declare class ContextProviderClass {
35
37
  enumValues: Map<string, () => Record<string, any>>;
36
38
  enumFunctions: Map<string, () => ((file: File, propertyId: string) => void) | undefined>;
37
39
  enumSubmitFunctions: Map<string, () => ((data: any) => void) | undefined>;
40
+ enumSaveFunctions: Map<string, () => ((data: any) => void) | undefined>;
38
41
  baseEnumerator: {
39
42
  data: Map<string, () => Record<string, any>>;
40
43
  functions: Map<string, () => ((file: File, propertyId: string) => void) | undefined>;
41
44
  submitFunction: Map<string, () => ((data: any) => void) | undefined>;
45
+ saveFunction: Map<string, () => ((data: any) => void) | undefined>;
42
46
  addFormContextData: (key: string, data: Record<string, unknown> | unknown[]) => void;
43
47
  getFormContextData: (key: string) => Record<string, any> | undefined;
44
48
  getAllFormContextData: () => AllData;