@abgov/jsonforms-components 1.49.1 → 1.50.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
@@ -5,7 +5,7 @@ import styled from 'styled-components';
5
5
  import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useRef, useCallback } from 'react';
6
6
  import axios from 'axios';
7
7
  import get$1 from 'lodash/get';
8
- import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, getAjv, isVisible, toDataPath, deriveLabelForUISchemaElement, isEnabled, schemaTypeIs, formatIs, createDefaultValue, Paths, or, isObjectArrayControl, isPrimitiveArrayControl, isControl, isScoped, hasType, isCategorization, isLayout } from '@jsonforms/core';
8
+ import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, getAjv, isVisible, toDataPath, deriveLabelForUISchemaElement, isEnabled, schemaTypeIs, formatIs, createDefaultValue, Paths, or, isObjectArrayControl, isPrimitiveArrayControl, schemaMatches, hasType, isControl, isCategorization, isLayout } from '@jsonforms/core';
9
9
  import { withJsonFormsControlProps, withJsonFormsRendererProps, withJsonFormsEnumProps, withTranslateProps, useJsonForms, JsonFormsDispatch, withJsonFormsLayoutProps, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
10
10
  import * as _$b from 'lodash';
11
11
  import { isEqual, isObject as isObject$f } from 'lodash';
@@ -5288,7 +5288,7 @@ const ReviewLayoutRenderer = ({
5288
5288
  };
5289
5289
  const ReviewGrid = styled.div(_t$6 || (_t$6 = _$6`
5290
5290
  display: grid;
5291
- grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
5291
+ grid-template-columns: repeat(auto-fit, minmax(250px, calc(50% - 8px)));
5292
5292
  gap: 16px;
5293
5293
  `));
5294
5294
 
@@ -5805,6 +5805,10 @@ const stepperReducer = (state, action) => {
5805
5805
  } = state;
5806
5806
  const lastId = categories[categories.length - 1].id;
5807
5807
  switch (action.type) {
5808
+ case 'update/uischema':
5809
+ {
5810
+ return Object.assign({}, action.payload.state);
5811
+ }
5808
5812
  case 'page/next':
5809
5813
  {
5810
5814
  state.activeId += 1;
@@ -5998,6 +6002,16 @@ const JsonFormsStepperContextProvider = ({
5998
6002
  }
5999
6003
  };
6000
6004
  }, [ctx === null || ctx === void 0 ? void 0 : ctx.core, stepperDispatch, stepperState]);
6005
+ useEffect(() => {
6006
+ if ((context === null || context === void 0 ? void 0 : context.isProvided) === true) {
6007
+ stepperDispatch({
6008
+ type: 'update/uischema',
6009
+ payload: {
6010
+ state: createStepperContextInitData(StepperProps)
6011
+ }
6012
+ });
6013
+ }
6014
+ }, [StepperProps.uischema]);
6001
6015
  return jsx(JsonFormsStepperContext.Provider, {
6002
6016
  value: context,
6003
6017
  children: children
@@ -8685,21 +8699,9 @@ const isPropertiesMatch = (obj, props, isExactMatch) => {
8685
8699
  return false;
8686
8700
  };
8687
8701
  const createSchemaMatchTester = (props, isExactMatch = false) => {
8688
- return (uischema, schema, context) => {
8689
- if (!isControl(uischema) || !isScoped(uischema)) {
8690
- return false;
8691
- }
8692
- if ((schema === null || schema === void 0 ? void 0 : schema.properties) && isObject$f(schema === null || schema === void 0 ? void 0 : schema.properties)) {
8693
- const propertyFromScope = uischema['scope'].split('/').pop();
8694
- if (isObject$f(schema.properties[propertyFromScope]) && 'properties' in schema.properties[propertyFromScope]) {
8695
- const objToTest = schema.properties[propertyFromScope]['properties'];
8696
- if (objToTest && isPropertiesMatch(objToTest, props, isExactMatch)) {
8697
- return true;
8698
- }
8699
- }
8700
- }
8701
- return false;
8702
- };
8702
+ return schemaMatches(schema => {
8703
+ return schema && isPropertiesMatch(schema.properties, props, isExactMatch);
8704
+ });
8703
8705
  };
8704
8706
 
8705
8707
  const isAddressLookup = createSchemaMatchTester(['addressLine2', 'municipality', 'addressLine1', 'subdivisionCode', 'postalCode']);
@@ -8872,28 +8874,7 @@ const FullNameControl = props => {
8872
8874
  });
8873
8875
  };
8874
8876
 
8875
- const isFullNameSchema = obj => {
8876
- if (isObject$f(obj)) {
8877
- const keys = Object.keys(obj);
8878
- return ['firstName', 'middleName', 'lastName'].every(attr => keys.includes(attr)) && keys.length === 3;
8879
- }
8880
- return false;
8881
- };
8882
- const isFullName = (uischema, schema, context) => {
8883
- if (!isControl(uischema) || !isScoped(uischema)) {
8884
- return false;
8885
- }
8886
- if ((schema === null || schema === void 0 ? void 0 : schema.properties) && isObject$f(schema === null || schema === void 0 ? void 0 : schema.properties)) {
8887
- const propertyFromScope = uischema['scope'].split('/').pop();
8888
- if (isObject$f(schema.properties[propertyFromScope]) && 'properties' in schema.properties[propertyFromScope]) {
8889
- const objToTest = schema.properties[propertyFromScope]['properties'];
8890
- if (objToTest && isFullNameSchema(objToTest)) {
8891
- return true;
8892
- }
8893
- }
8894
- }
8895
- return false;
8896
- };
8877
+ const isFullName = createSchemaMatchTester(['firstName', 'middleName', 'lastName'], true);
8897
8878
  const FullNameTester = rankWith(4, isFullName);
8898
8879
 
8899
8880
  const FullNameDobControl = props => {
@@ -9105,28 +9086,7 @@ const FullNameDobReviewControl = props => {
9105
9086
  });
9106
9087
  };
9107
9088
 
9108
- const isFullNameDoBSchema = obj => {
9109
- if (isObject$f(obj)) {
9110
- const keys = Object.keys(obj);
9111
- return ['firstName', 'middleName', 'lastName', 'dateOfBirth'].every(attr => keys.includes(attr)) && keys.length === 4;
9112
- }
9113
- return false;
9114
- };
9115
- const isFullNameDoB = (uischema, schema, context) => {
9116
- if (!isControl(uischema) || !isScoped(uischema)) {
9117
- return false;
9118
- }
9119
- if ((schema === null || schema === void 0 ? void 0 : schema.properties) && isObject$f(schema === null || schema === void 0 ? void 0 : schema.properties)) {
9120
- const propertyFromScope = uischema['scope'].split('/').pop();
9121
- if (isObject$f(schema.properties[propertyFromScope]) && 'properties' in schema.properties[propertyFromScope]) {
9122
- const objToTest = schema.properties[propertyFromScope]['properties'];
9123
- if (objToTest && isFullNameDoBSchema(objToTest)) {
9124
- return true;
9125
- }
9126
- }
9127
- }
9128
- return false;
9129
- };
9089
+ const isFullNameDoB = createSchemaMatchTester(['firstName', 'middleName', 'lastName', 'dateOfBirth'], true);
9130
9090
  const FullNameDobTester = rankWith(4, isFullNameDoB);
9131
9091
 
9132
9092
  const GoATextCell = props => jsx(GoAInputText, Object.assign({}, props));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.49.1",
3
+ "version": "1.50.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",
@@ -22,5 +22,10 @@ export type StepperAction = {
22
22
  payload: {
23
23
  errors?: ErrorObject[];
24
24
  };
25
+ } | {
26
+ type: 'update/uischema';
27
+ payload: {
28
+ state: StepperContextDataType;
29
+ };
25
30
  };
26
31
  export declare const stepperReducer: (state: StepperContextDataType, action: StepperAction) => StepperContextDataType;
@@ -1,3 +1,3 @@
1
- import { RankedTester, UISchemaElement, JsonSchema, TesterContext } from '@jsonforms/core';
2
- export declare const isFullName: (uischema: UISchemaElement, schema: JsonSchema, context: TesterContext) => boolean;
1
+ import { RankedTester } from '@jsonforms/core';
2
+ export declare const isFullName: import("@jsonforms/core").Tester;
3
3
  export declare const FullNameTester: RankedTester;
@@ -1,3 +1,3 @@
1
- import { RankedTester, UISchemaElement, JsonSchema, TesterContext } from '@jsonforms/core';
2
- export declare const isFullNameDoB: (uischema: UISchemaElement, schema: JsonSchema, context: TesterContext) => boolean;
1
+ import { RankedTester } from '@jsonforms/core';
2
+ export declare const isFullNameDoB: import("@jsonforms/core").Tester;
3
3
  export declare const FullNameDobTester: RankedTester;