@abgov/jsonforms-components 1.8.1 → 1.10.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
@@ -1,15 +1,12 @@
1
1
  import { withAjvProps, materialSliderControlTester, MaterialSliderControl, materialObjectControlTester, MaterialObjectRenderer, materialAllOfControlTester, MaterialAllOfRenderer, materialAnyOfControlTester, MaterialAnyOfRenderer, materialOneOfControlTester, MaterialOneOfRenderer, materialOneOfRadioGroupControlTester, MaterialOneOfRadioGroupControl, materialOneOfEnumControlTester, MaterialOneOfEnumControl, materialHorizontalLayoutTester, materialVerticalLayoutTester, materialArrayLayoutTester, MaterialArrayLayout, materialAnyOfStringOrEnumControlTester, MaterialAnyOfStringOrEnumControl, materialEnumArrayRendererTester, MaterialEnumArrayRenderer, materialBooleanCellTester, MaterialBooleanCell, materialBooleanToggleCellTester, MaterialBooleanToggleCell, materialEnumCellTester, MaterialEnumCell, materialOneOfEnumCellTester, MaterialOneOfEnumCell } from '@jsonforms/material-renderers';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
- import { GoAFormItem, GoACallout, GoAInputDate, GoAInput, GoATextArea, GoAInputDateTime, GoAInputTime, GoADropdown, GoADropdownItem, GoARadioGroup, GoARadioItem, GoACheckbox, GoAFormStepper, GoAFormStep, GoAPages, GoAGrid, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoADetails } from '@abgov/react-components';
4
- import { Hidden, Typography, FormHelperText } from '@mui/material';
3
+ import { GoACallout, GoAInputDate, GoAFormItem, GoAInput, GoATextArea, GoAInputDateTime, GoAInputTime, GoADropdown, GoADropdownItem, GoARadioGroup, GoARadioItem, GoACheckbox, GoAFormStepper, GoAFormStep, GoAPages, GoAGrid, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoADetails } from '@abgov/react-components';
5
4
  import styled from 'styled-components';
6
5
  import { rankWith, uiTypeIs, isDateControl, isStringControl, and, optionIs, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, isDescriptionHidden, isVisible, isEnabled, deriveLabelForUISchemaElement, schemaTypeIs, formatIs, createDefaultValue, Paths, or, isObjectArrayControl, isPrimitiveArrayControl, withIncreasedRank, hasType, isControl, isCategorization, isLayout } from '@jsonforms/core';
7
6
  import { withJsonFormsRendererProps, withJsonFormsControlProps, withJsonFormsEnumProps, withTranslateProps, withJsonFormsLayoutProps, JsonFormsDispatch, useJsonForms, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
8
7
  import React, { createContext, useEffect, useState, useMemo, useContext, useCallback } from 'react';
9
8
  import merge from 'lodash/merge';
10
9
  import axios from 'axios';
11
- import TextField from '@mui/material/TextField';
12
- import Autocomplete from '@mui/material/Autocomplete';
13
10
  import isEmpty from 'lodash/isEmpty';
14
11
  import range from 'lodash/range';
15
12
  import Ajv from 'ajv';
@@ -1740,9 +1737,9 @@ $$3({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }
1740
1737
  assign: assign
1741
1738
  });
1742
1739
 
1743
- let _$6 = t => t,
1744
- _t$6;
1745
- const FormFieldWrapper = styled.div(_t$6 || (_t$6 = _$6`
1740
+ let _$7 = t => t,
1741
+ _t$7;
1742
+ const FormFieldWrapper = styled.div(_t$7 || (_t$7 = _$7`
1746
1743
  margin-bottom: var(--goa-space-l);
1747
1744
  `));
1748
1745
 
@@ -2373,41 +2370,6 @@ const isValidDate = function isValidDate(date) {
2373
2370
  }
2374
2371
  };
2375
2372
 
2376
- const GoAInputBaseControl = props => {
2377
- var _a, _b, _c;
2378
- // eslint-disable-next-line
2379
- const {
2380
- id,
2381
- description,
2382
- errors,
2383
- uischema,
2384
- visible,
2385
- config,
2386
- label,
2387
- input,
2388
- required
2389
- } = props;
2390
- errors.length === 0;
2391
- const InnerComponent = input;
2392
- const labelToUpdate = getLabelText(uischema.scope, label || '');
2393
- let modifiedErrors = checkFieldValidity(props);
2394
- if (modifiedErrors === 'should be equal to one of the allowed values' && ((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.enumContext)) {
2395
- modifiedErrors = '';
2396
- }
2397
- return jsx(Hidden, {
2398
- xsUp: !visible,
2399
- children: jsx(FormFieldWrapper, {
2400
- children: jsx(GoAFormItem, {
2401
- requirement: required ? 'required' : undefined,
2402
- error: modifiedErrors,
2403
- label: (props === null || props === void 0 ? void 0 : props.noLabel) === true ? '' : labelToUpdate,
2404
- helpText: typeof ((_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.help) === 'string' ? (_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.help : '',
2405
- children: jsx(InnerComponent, Object.assign({}, props))
2406
- })
2407
- })
2408
- });
2409
- };
2410
-
2411
2373
  // Used locally for callout presentation
2412
2374
  const callout = props => {
2413
2375
  const componentProps = Object.assign({
@@ -2771,6 +2733,54 @@ const onChangeForNumericControl = props => {
2771
2733
  }
2772
2734
  };
2773
2735
 
2736
+ let _$6 = t => t,
2737
+ _t$6,
2738
+ _t2$4;
2739
+ styled.div(_t$6 || (_t$6 = _$6`
2740
+ height: 70vh;
2741
+ overflow-y: auto;
2742
+ padding-left: var(--goa-space-2xs);
2743
+ padding-right: var(--goa-space-2xs);
2744
+ `));
2745
+ const Visible = styled.div(_t2$4 || (_t2$4 = _$6`
2746
+ display: ${0};
2747
+ `), p => p.visible ? 'initial' : 'none');
2748
+
2749
+ const GoAInputBaseControl = props => {
2750
+ var _a, _b, _c;
2751
+ // eslint-disable-next-line
2752
+ const {
2753
+ id,
2754
+ description,
2755
+ errors,
2756
+ uischema,
2757
+ visible,
2758
+ config,
2759
+ label,
2760
+ input,
2761
+ required
2762
+ } = props;
2763
+ errors.length === 0;
2764
+ const InnerComponent = input;
2765
+ const labelToUpdate = getLabelText(uischema.scope, label || '');
2766
+ let modifiedErrors = checkFieldValidity(props);
2767
+ if (modifiedErrors === 'should be equal to one of the allowed values' && ((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.enumContext)) {
2768
+ modifiedErrors = '';
2769
+ }
2770
+ return jsx(Visible, {
2771
+ visible: visible,
2772
+ children: jsx(FormFieldWrapper, {
2773
+ children: jsx(GoAFormItem, {
2774
+ requirement: required ? 'required' : undefined,
2775
+ error: modifiedErrors,
2776
+ label: (props === null || props === void 0 ? void 0 : props.noLabel) === true ? '' : labelToUpdate,
2777
+ helpText: typeof ((_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.help) === 'string' ? (_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.help : '',
2778
+ children: jsx(InnerComponent, Object.assign({}, props))
2779
+ })
2780
+ })
2781
+ });
2782
+ };
2783
+
2774
2784
  const GoAInputText = props => {
2775
2785
  var _a, _b, _c, _d, _e, _f, _g;
2776
2786
  const {
@@ -3403,7 +3413,8 @@ const EnumSelectAutoComplete = props => {
3403
3413
  schema,
3404
3414
  path,
3405
3415
  handleChange,
3406
- uischema
3416
+ uischema,
3417
+ label
3407
3418
  } = props;
3408
3419
  let enumData = (schema === null || schema === void 0 ? void 0 : schema.enum) || [];
3409
3420
  const dataKey = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.enumContext) === null || _b === void 0 ? void 0 : _b.key;
@@ -3411,11 +3422,6 @@ const EnumSelectAutoComplete = props => {
3411
3422
  const location = (_f = (_e = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _e === void 0 ? void 0 : _e.enumContext) === null || _f === void 0 ? void 0 : _f.location;
3412
3423
  const type = (_h = (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.enumContext) === null || _h === void 0 ? void 0 : _h.type;
3413
3424
  const values = (_k = (_j = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _j === void 0 ? void 0 : _j.enumContext) === null || _k === void 0 ? void 0 : _k.values;
3414
- const defaultProps = {
3415
- options: enumData,
3416
- getOptionLabel: option => option
3417
- };
3418
- const [inputValue, setInputValue] = React.useState('');
3419
3425
  useEffect(() => {
3420
3426
  if (dataKey && url) {
3421
3427
  addDataByOptions(dataKey, url, location, type, values);
@@ -3425,25 +3431,25 @@ const EnumSelectAutoComplete = props => {
3425
3431
  const newData = getData(dataKey);
3426
3432
  // eslint-disable-next-line
3427
3433
  enumData = newData;
3428
- defaultProps.options = enumData;
3429
3434
  }
3430
- return jsx(Autocomplete, Object.assign({}, defaultProps, {
3431
- id: "autocomplete",
3432
- getOptionLabel: option => option,
3433
- isOptionEqualToValue: (option, value) => option.id === value.id,
3434
- value: data || null,
3435
+ return jsx(GoADropdown, {
3436
+ value: data,
3435
3437
  onChange: (name, value) => {
3436
3438
  handleChange(path, value);
3437
- setInputValue(value);
3438
3439
  },
3439
- renderInput: params => {
3440
- return jsx(TextField, Object.assign({}, params, {
3441
- variant: "outlined",
3442
- size: "small",
3443
- placeholder: schema === null || schema === void 0 ? void 0 : schema.description
3444
- }));
3445
- }
3446
- }));
3440
+ testId: `autocomplete-dropdown-${label}`,
3441
+ id: `autocomplete-dropdown-${label}`,
3442
+ width: "100%",
3443
+ filterable: true,
3444
+ relative: true,
3445
+ ariaLabel: label,
3446
+ children: enumData === null || enumData === void 0 ? void 0 : enumData.map(item => {
3447
+ return jsx(GoADropdownItem, {
3448
+ value: item,
3449
+ label: item
3450
+ }, `autocomplete-${item}`);
3451
+ })
3452
+ });
3447
3453
  };
3448
3454
  const numControlAutoComplete = props => {
3449
3455
  return jsx(GoAInputBaseControl, Object.assign({}, props, {
@@ -3575,8 +3581,8 @@ const BooleanRadioComponent = ({
3575
3581
  required,
3576
3582
  errors
3577
3583
  });
3578
- return jsx(Hidden, {
3579
- xsUp: !visible,
3584
+ return jsx(Visible, {
3585
+ visible: visible,
3580
3586
  children: jsxs(GoARadioGroup, Object.assign({
3581
3587
  error: errorsFormInput.length > 0,
3582
3588
  name: `${label}`,
@@ -3959,8 +3965,8 @@ const FormStepper = ({
3959
3965
  /*
3960
3966
  [Mar-04-2024][Paul Li] the GoAPages internal state cannot handle the hidden/display well. We need extra hide/display control to it appropriately.
3961
3967
  */
3962
- jsx(Hidden, {
3963
- xsUp: indexOfCategory !== step - 1,
3968
+ jsx(Visible, {
3969
+ visible: indexOfCategory === step - 1,
3964
3970
  children: category.elements.map((elementUiSchema, index) => {
3965
3971
  return jsx(JsonFormsDispatch, {
3966
3972
  schema: schema,
@@ -3978,8 +3984,8 @@ const FormStepper = ({
3978
3984
  const handleEdit = index => {
3979
3985
  setPage(index + 1);
3980
3986
  };
3981
- return jsx(Hidden, {
3982
- xsUp: !visible,
3987
+ return jsx(Visible, {
3988
+ visible: visible,
3983
3989
  children: jsxs("div", {
3984
3990
  id: `${path || `goa`}-form-stepper`,
3985
3991
  className: "formStepper",
@@ -4187,6 +4193,8 @@ const DeleteFileModal = ({
4187
4193
  let _$2 = t => t,
4188
4194
  _t$2,
4189
4195
  _t2$1;
4196
+ const DELAY_UPLOAD_TIMEOUT_MS = 200;
4197
+ const DELAY_DELETE_TIMEOUT_MS = 80;
4190
4198
  const FileUploader = _a => {
4191
4199
  var _b;
4192
4200
  var {
@@ -4221,7 +4229,7 @@ const FileUploader = _a => {
4221
4229
  const value = ['Loading', Array.isArray(data) ? data[1] : file === null || file === void 0 ? void 0 : file.name];
4222
4230
  handleChange(propertyId, value);
4223
4231
  };
4224
- setTimeout(handleFunction, 1);
4232
+ setTimeout(handleFunction, DELAY_UPLOAD_TIMEOUT_MS);
4225
4233
  }
4226
4234
  }
4227
4235
  function downloadFile(file) {
@@ -4304,7 +4312,10 @@ const FileUploader = _a => {
4304
4312
  onDelete: () => {
4305
4313
  setShowFileDeleteConfirmation(false);
4306
4314
  deleteFile(getFile());
4307
- handleChange(propertyId, '');
4315
+ const handleFunction = () => {
4316
+ handleChange(propertyId, '');
4317
+ };
4318
+ setTimeout(handleFunction, DELAY_DELETE_TIMEOUT_MS);
4308
4319
  }
4309
4320
  })]
4310
4321
  })
@@ -4385,9 +4396,9 @@ const ToolBarHeader = styled.div(_t2 || (_t2 = _$1`
4385
4396
  const ObjectArrayTitle = styled.h2(_t3 || (_t3 = _$1`
4386
4397
  margin-bottom: var(--goa-space-l);
4387
4398
  `));
4388
- const DisplayWrapper = styled.div(_t4 || (_t4 = _$1`
4389
- display: ${0};
4390
- `), p => p.visible ? 'initial' : 'none');
4399
+ const TextCenter = styled.div(_t4 || (_t4 = _$1`
4400
+ text-align: center;
4401
+ `));
4391
4402
 
4392
4403
  // eslint-disable-next-line
4393
4404
  const extractScopesFromUISchema = uischema => {
@@ -4445,8 +4456,7 @@ const EmptyList = ({
4445
4456
  translations
4446
4457
  }) => jsx(GoAGrid, {
4447
4458
  minChildWidth: "30ch",
4448
- children: jsx(Typography, {
4449
- align: "center",
4459
+ children: jsx(TextCenter, {
4450
4460
  children: jsx("b", {
4451
4461
  children: translations.noDataMessage
4452
4462
  })
@@ -4519,9 +4529,6 @@ const NonEmptyCellComponent = /*#__PURE__*/React.memo(function NonEmptyCellCompo
4519
4529
  enabled: enabled,
4520
4530
  renderers: renderers,
4521
4531
  cells: cells
4522
- }), jsx(FormHelperText, {
4523
- error: !isValid,
4524
- children: !isValid && errors
4525
4532
  })]
4526
4533
  });
4527
4534
  });
@@ -4624,7 +4631,7 @@ class ObjectArrayControl extends React.Component {
4624
4631
  const controlElement = uischema;
4625
4632
  // eslint-disable-next-line
4626
4633
  const listTitle = label || ((_a = uischema.options) === null || _a === void 0 ? void 0 : _a.title);
4627
- return jsxs(DisplayWrapper, {
4634
+ return jsxs(Visible, {
4628
4635
  visible: visible,
4629
4636
  "data-testid": "jsonforms-object-list-wrapper",
4630
4637
  children: [jsxs(ToolBarHeader, {
@@ -4717,8 +4724,8 @@ const ArrayControl = props => {
4717
4724
  setOpen(false);
4718
4725
  // eslint-disable-next-line
4719
4726
  }, [setOpen, path, rowData]);
4720
- return jsxs(Hidden, {
4721
- xsUp: !visible,
4727
+ return jsxs(Visible, {
4728
+ visible: visible,
4722
4729
  children: [jsx(ObjectArrayControl, Object.assign({}, props, {
4723
4730
  openDeleteDialog: openDeleteDialog
4724
4731
  })), jsx(DeleteDialog, {
@@ -4797,16 +4804,16 @@ const LayoutRenderer = ({
4797
4804
  return null;
4798
4805
  } else {
4799
4806
  if (direction === 'row') {
4800
- return jsx(Hidden, {
4801
- xsUp: !visible,
4807
+ return jsx(Visible, {
4808
+ visible: visible,
4802
4809
  children: jsx(GoAGrid, {
4803
4810
  minChildWidth: "10ch",
4804
4811
  children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
4805
4812
  })
4806
4813
  });
4807
4814
  } else {
4808
- return jsx(Hidden, {
4809
- xsUp: !visible,
4815
+ return jsx(Visible, {
4816
+ visible: visible,
4810
4817
  children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
4811
4818
  });
4812
4819
  }
@@ -4877,8 +4884,8 @@ const GoAGroupControlComponent = props => {
4877
4884
  visible
4878
4885
  } = props;
4879
4886
  const group = uischema;
4880
- return jsxs(Hidden, {
4881
- xsUp: !visible,
4887
+ return jsxs(Visible, {
4888
+ visible: visible,
4882
4889
  children: [((_b = (_a = group.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.accent) === 'thick' && jsx(GoAContainer, Object.assign({
4883
4890
  heading: group.label
4884
4891
  }, (_c = group.options) === null || _c === void 0 ? void 0 : _c.componentProps, {
@@ -4960,8 +4967,8 @@ const HelpContentComponent = _a => {
4960
4967
  children: (_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.help
4961
4968
  });
4962
4969
  };
4963
- return jsx(Hidden, {
4964
- xsUp: !visible,
4970
+ return jsx(Visible, {
4971
+ visible: visible,
4965
4972
  children: jsx(HelpContentDiv, {
4966
4973
  "aria-label": (_b = uischema.options) === null || _b === void 0 ? void 0 : _b.ariaLabel,
4967
4974
  children: jsxs("div", {
@@ -5181,7 +5188,8 @@ const ajv = new Ajv({
5181
5188
  allErrors: true,
5182
5189
  verbose: true
5183
5190
  });
5184
- ajv.addFormat('file-urn', /^urn:[a-zA-Z0-9.-]+(:[a-zA-Z0-9.-]+)*$/);
5191
+ //Example format: urn:ads:platform:file-service:v1:/files/f6de737e-c5fc-42fe-963b-28bfe14597c4
5192
+ ajv.addFormat('file-urn', /^urn:ads:platform:file-service:v[0-9]:\/files\/[a-zA-Z0-9.-]*$/);
5185
5193
 
5186
5194
  const countries = ['Argentina', 'Brazil', 'Canada', 'Denmark', 'Egypt', 'France', 'Greece', 'India', 'Japan', 'Kenya'];
5187
5195
  addData('countries', countries);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.8.1",
3
+ "version": "1.10.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,6 +1,4 @@
1
1
  export declare const DeleteDialogContent: import("styled-components").StyledComponent<"div", any, {}, never>;
2
2
  export declare const ToolBarHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
3
3
  export declare const ObjectArrayTitle: import("styled-components").StyledComponent<"h2", any, {}, never>;
4
- export declare const DisplayWrapper: import("styled-components").StyledComponent<"div", any, {
5
- visible: boolean;
6
- }, never>;
4
+ export declare const TextCenter: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,2 @@
1
+ export * from './inputControlUtils';
2
+ export * from './style-component';
@@ -1 +1,4 @@
1
1
  export declare const VerticalLayout: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const Visible: import("styled-components").StyledComponent<"div", any, {
3
+ visible: boolean | undefined;
4
+ }, never>;