@abgov/jsonforms-components 1.50.1 → 1.50.2

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.
Files changed (2) hide show
  1. package/index.esm.js +58 -10
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as runtime from 'react/jsx-runtime';
2
2
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
+ import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useRef, useCallback } from 'react';
3
4
  import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoARadioGroup, GoARadioItem, GoACheckbox, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoATable, GoADropdown, GoADropdownItem, GoADetails, GoASpinner } from '@abgov/react-components';
5
+ import { useJsonForms, withJsonFormsControlProps, withJsonFormsRendererProps, withJsonFormsEnumProps, withTranslateProps, JsonFormsDispatch, withJsonFormsLayoutProps, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
4
6
  import styled from 'styled-components';
5
- import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useRef, useCallback } from 'react';
6
7
  import axios from 'axios';
7
8
  import get$1 from 'lodash/get';
8
9
  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
- 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';
12
12
  import merge from 'lodash/merge';
@@ -3864,14 +3864,44 @@ const GoAInputBaseControl = props => {
3864
3864
  required,
3865
3865
  errors,
3866
3866
  path,
3867
- isStepperReview
3867
+ isStepperReview,
3868
+ id
3868
3869
  } = props;
3869
3870
  const InnerComponent = input;
3870
3871
  const labelToUpdate = getLabelText(uischema.scope, label || '');
3872
+ const ctx = useJsonForms();
3871
3873
  let modifiedErrors = checkFieldValidity(props);
3872
3874
  if (modifiedErrors === 'must be equal to one of the allowed values') {
3873
3875
  modifiedErrors = '';
3874
3876
  }
3877
+ useEffect(() => {
3878
+ var _a, _b, _c, _d;
3879
+ if ((_a = ctx.core) === null || _a === void 0 ? void 0 : _a.ajv) {
3880
+ // eslint-disable-next-line
3881
+ const newError = {
3882
+ instancePath: path,
3883
+ message: modifiedErrors,
3884
+ schemaPath: id,
3885
+ keyword: '',
3886
+ params: {}
3887
+ };
3888
+ const existingErrorIndex = (ctx.core.ajv.errors || []).findIndex(error => {
3889
+ return (error === null || error === void 0 ? void 0 : error.schemaPath) === id;
3890
+ });
3891
+ if (modifiedErrors) {
3892
+ if (existingErrorIndex > -1) {
3893
+ (ctx.core.ajv.errors || [])[existingErrorIndex] = newError;
3894
+ } else {
3895
+ ctx.core.ajv.errors = [...(ctx.core.ajv.errors || []), newError];
3896
+ }
3897
+ } else {
3898
+ if (existingErrorIndex > -1) {
3899
+ delete (ctx.core.ajv.errors || [])[existingErrorIndex];
3900
+ }
3901
+ }
3902
+ ctx.core.ajv.errors = ((_d = (_c = (_b = ctx.core) === null || _b === void 0 ? void 0 : _b.ajv) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d.filter(e => e !== null)) || [];
3903
+ }
3904
+ }, [modifiedErrors, ctx, path, id]);
3875
3905
  return jsx(JsonFormRegisterProvider, {
3876
3906
  defaultRegisters: undefined,
3877
3907
  children: jsx(Visible, {
@@ -7807,7 +7837,7 @@ const SearchBox = styled.div(_t$1 || (_t$1 = _$1`
7807
7837
  width: 100%;
7808
7838
  position: absolute;
7809
7839
 
7810
- background: var(--color-white);
7840
+ background: var(--goa-color-greyscale-white);
7811
7841
  box-shadow: 0 8px 8px rgb(0 0 0 / 20%), 0 4px 4px rgb(0 0 0 / 10%);
7812
7842
  z-index: 99;
7813
7843
  overflow: hidden auto;
@@ -7817,10 +7847,10 @@ const SearchBox = styled.div(_t$1 || (_t$1 = _$1`
7817
7847
  }
7818
7848
  .suggestion-active,
7819
7849
  .suggestions li:hover {
7820
- background-color: var(--color-primary);
7821
- color: var(--color-white);
7850
+ background-color: var(--goa-color-interactive-default);
7851
+ color: var(--goa-color-greyscale-white);
7822
7852
  cursor: pointer;
7823
- font-weight: var(--fw-bold);
7853
+ font-weight: 600;
7824
7854
  }
7825
7855
  .input-container {
7826
7856
  position: relative;
@@ -7866,13 +7896,13 @@ const ListItem = styled.li(_t6 || (_t6 = _$1`
7866
7896
  `), ({
7867
7897
  selectedIndex,
7868
7898
  index
7869
- }) => selectedIndex === index ? 'var(--color-primary)' : '', ({
7899
+ }) => selectedIndex === index ? 'var(--goa-color-interactive-default)' : '', ({
7870
7900
  selectedIndex,
7871
7901
  index
7872
- }) => selectedIndex === index ? 'var(--color-white) !important' : '', ({
7902
+ }) => selectedIndex === index ? 'var(--goa-color-greyscale-white) !important' : '', ({
7873
7903
  selectedIndex,
7874
7904
  index
7875
- }) => selectedIndex === index ? 'var(--fw-bold)' : '');
7905
+ }) => selectedIndex === index ? '600' : '');
7876
7906
 
7877
7907
  const AddressInputs = ({
7878
7908
  address,
@@ -8367,6 +8397,7 @@ const AddressLookUpControl = props => {
8367
8397
  const formCtx = useContext(JsonFormContext);
8368
8398
  const formHost = formCtx === null || formCtx === void 0 ? void 0 : formCtx.formUrl;
8369
8399
  const formUrl = `${formHost}/${ADDRESS_PATH}`;
8400
+ const ctx = useJsonForms();
8370
8401
  const autocompletion = ((_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.autocomplete) !== false;
8371
8402
  const [open, setOpen] = useState(false);
8372
8403
  const label = typeof (uischema === null || uischema === void 0 ? void 0 : uischema.label) === 'string' && uischema.label ? uischema.label : '';
@@ -8420,6 +8451,23 @@ const AddressLookUpControl = props => {
8420
8451
  showLabel: false
8421
8452
  }));
8422
8453
  };
8454
+ useEffect(() => {
8455
+ var _a;
8456
+ if ((_a = ctx.core) === null || _a === void 0 ? void 0 : _a.ajv) {
8457
+ // eslint-disable-next-line
8458
+ const newError = [];
8459
+ Object.keys(errors).forEach(err => {
8460
+ newError.push({
8461
+ instancePath: path,
8462
+ message: err,
8463
+ schemaPath: '',
8464
+ keyword: '',
8465
+ params: {}
8466
+ });
8467
+ });
8468
+ ctx.core.ajv.errors = newError;
8469
+ }
8470
+ }, [errors, ctx, path]);
8423
8471
  useEffect(() => {
8424
8472
  const fetchSuggestions = () => __awaiter(void 0, void 0, void 0, function* () {
8425
8473
  if (searchTerm.length > 2 && dropdownSelected === false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.50.1",
3
+ "version": "1.50.2",
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",