@abgov/jsonforms-components 2.13.5 → 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
@@ -7051,6 +7051,8 @@ class ContextProviderClass {
7051
7051
  this.enumFunctions = new Map();
7052
7052
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7053
7053
  this.enumSubmitFunctions = new Map();
7054
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7055
+ this.enumSaveFunctions = new Map();
7054
7056
  this.addFormContextData = (key, data) => {
7055
7057
  this.enumValues.set(key, () => data);
7056
7058
  };
@@ -7071,10 +7073,13 @@ class ContextProviderClass {
7071
7073
  }
7072
7074
  if (props.submit) {
7073
7075
  const {
7074
- submitForm
7076
+ submitForm,
7077
+ saveForm
7075
7078
  } = props.submit;
7076
7079
  const submitFunction = submitForm;
7080
+ const saveFormFunction = saveForm;
7077
7081
  this.enumSubmitFunctions.set('submit-form', () => submitFunction);
7082
+ this.enumSaveFunctions.set('save-form', () => saveFormFunction);
7078
7083
  }
7079
7084
  if (props.data) {
7080
7085
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -7139,6 +7144,7 @@ class ContextProviderClass {
7139
7144
  data: this.enumValues,
7140
7145
  functions: this.enumFunctions,
7141
7146
  submitFunction: this.enumSubmitFunctions,
7147
+ saveFunction: this.enumSaveFunctions,
7142
7148
  addFormContextData: this.addFormContextData,
7143
7149
  getFormContextData: this.getFormContextData,
7144
7150
  getAllFormContextData: this.getAllFormContextData,
@@ -8308,6 +8314,7 @@ const BackButton = ({
8308
8314
  };
8309
8315
 
8310
8316
  const RenderPages = props => {
8317
+ var _a, _b;
8311
8318
  const {
8312
8319
  data,
8313
8320
  schema,
@@ -8330,8 +8337,11 @@ const RenderPages = props => {
8330
8337
  isValid,
8331
8338
  activeId
8332
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;
8333
8341
  const submitFormFunction = enumerators === null || enumerators === void 0 ? void 0 : enumerators.submitFunction.get('submit-form');
8334
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();
8335
8345
  const [isOpen, setIsOpen] = useState(false);
8336
8346
  const handleSubmit = () => {
8337
8347
  if (submitForm) {
@@ -8340,6 +8350,11 @@ const RenderPages = props => {
8340
8350
  setIsOpen(true);
8341
8351
  }
8342
8352
  };
8353
+ const handleSave = () => {
8354
+ if (saveForm) {
8355
+ saveForm(data);
8356
+ }
8357
+ };
8343
8358
  const onCloseModal = () => {
8344
8359
  setIsOpen(false);
8345
8360
  };
@@ -8384,7 +8399,10 @@ const RenderPages = props => {
8384
8399
  alignment: "start",
8385
8400
  children: [jsx(GoAButton, {
8386
8401
  type: "submit",
8387
- onClick: () => goToPage(activeId + 1),
8402
+ onClick: () => {
8403
+ handleSave();
8404
+ goToPage(activeId + 1);
8405
+ },
8388
8406
  disabled: !(category.isValid && category.isCompleted),
8389
8407
  testId: "pages-save-continue-btn",
8390
8408
  children: "Save and continue"
@@ -8416,13 +8434,13 @@ const RenderPages = props => {
8416
8434
  })), jsx(PageRenderPadding, {
8417
8435
  children: jsx(GoAButtonGroup, {
8418
8436
  alignment: "end",
8419
- children: jsx(GoAButton, {
8437
+ children: !hideSubmit ? jsx(GoAButton, {
8420
8438
  type: 'primary',
8421
8439
  onClick: handleSubmit,
8422
8440
  disabled: !isValid,
8423
8441
  testId: "pages-submit-btn",
8424
8442
  children: "Submit"
8425
- })
8443
+ }) : null
8426
8444
  })
8427
8445
  })]
8428
8446
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.13.5",
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",
@@ -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;