@abgov/jsonforms-components 2.39.0 → 2.41.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.
Files changed (2) hide show
  1. package/index.esm.js +45 -13
  2. package/package.json +2 -2
package/index.esm.js CHANGED
@@ -14,7 +14,7 @@ import isEmpty from 'lodash/isEmpty';
14
14
  import range from 'lodash/range';
15
15
  import pluralize from 'pluralize';
16
16
  import { evaluateSync, compileSync } from '@mdx-js/mdx';
17
- import { Parser } from 'expr-eval';
17
+ import { Parser } from 'expr-eval-fork';
18
18
  import Ajv from 'ajv';
19
19
  import addErrors from 'ajv-errors';
20
20
  import addFormats from 'ajv-formats';
@@ -6601,8 +6601,32 @@ const CheckBoxGroupDiv = styled.div(_t$8 || (_t$8 = _$8`
6601
6601
  }
6602
6602
  `));
6603
6603
 
6604
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6605
+ const getEnumOptions = schema => {
6606
+ var _a, _b;
6607
+ if (((_a = schema === null || schema === void 0 ? void 0 : schema.items) === null || _a === void 0 ? void 0 : _a.oneOf) && Array.isArray(schema.items.oneOf)) {
6608
+ return schema.items.oneOf;
6609
+ }
6610
+ if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && Array.isArray(schema.oneOf)) {
6611
+ return schema.oneOf;
6612
+ }
6613
+ const newSchema = schema;
6614
+ return (schema === null || schema === void 0 ? void 0 : schema.enum) || ((_b = newSchema === null || newSchema === void 0 ? void 0 : newSchema.items) === null || _b === void 0 ? void 0 : _b.enum) || [];
6615
+ };
6616
+ const getOptionValue = option => {
6617
+ return typeof option === 'string' ? option : option.const;
6618
+ };
6619
+ const getOptionLabel = option => {
6620
+ if (typeof option === 'string') {
6621
+ return option;
6622
+ }
6623
+ return option.title || option.const;
6624
+ };
6625
+ const getOptionDescription = option => {
6626
+ return typeof option === 'string' ? undefined : option.description;
6627
+ };
6604
6628
  const CheckboxGroup = props => {
6605
- var _a, _b, _c;
6629
+ var _a, _b;
6606
6630
  const {
6607
6631
  data,
6608
6632
  id,
@@ -6615,20 +6639,23 @@ const CheckboxGroup = props => {
6615
6639
  label,
6616
6640
  enabled
6617
6641
  } = props;
6618
- const newSchema = schema;
6619
- const enumData = (schema === null || schema === void 0 ? void 0 : schema.enum) || ((_a = newSchema === null || newSchema === void 0 ? void 0 : newSchema.items) === null || _a === void 0 ? void 0 : _a.enum) || [];
6642
+ const enumOptions = getEnumOptions(schema);
6620
6643
  const appliedUiSchemaOptions = merge({}, config, props.uischema.options, options);
6621
6644
  return jsx(Checkboxes, {
6622
- orientation: ((_b = uischema.options) === null || _b === void 0 ? void 0 : _b.orientation) ? (_c = uischema.options) === null || _c === void 0 ? void 0 : _c.orientation : 'vertical',
6645
+ orientation: ((_a = uischema.options) === null || _a === void 0 ? void 0 : _a.orientation) ? (_b = uischema.options) === null || _b === void 0 ? void 0 : _b.orientation : 'vertical',
6623
6646
  testId: `${label || id}-jsonforms-checkboxes`,
6624
- children: enumData.map(enumValue => {
6647
+ children: enumOptions.map(enumOption => {
6648
+ const enumValue = getOptionValue(enumOption);
6649
+ const enumLabel = getOptionLabel(enumOption);
6650
+ const enumDescription = getOptionDescription(enumOption);
6625
6651
  return jsx(GoACheckbox, Object.assign({
6626
6652
  name: enumValue,
6627
6653
  disabled: !enabled,
6628
6654
  checked: data ? data.includes(enumValue) : false,
6629
6655
  value: `${enumValue}`
6630
6656
  }, appliedUiSchemaOptions, {
6631
- text: enumValue,
6657
+ text: enumLabel,
6658
+ description: enumDescription,
6632
6659
  testId: `${enumValue}-checkbox`,
6633
6660
  onChange: (name, value) => {
6634
6661
  let newData = Array.isArray(data) ? [...data] : [];
@@ -6639,7 +6666,7 @@ const CheckboxGroup = props => {
6639
6666
  }
6640
6667
  handleChange(path, newData.length === 0 ? undefined : newData);
6641
6668
  }
6642
- }));
6669
+ }), enumValue);
6643
6670
  })
6644
6671
  });
6645
6672
  };
@@ -9079,14 +9106,12 @@ const TaskList = ({
9079
9106
  "data-testid": testid,
9080
9107
  children: [title && jsx(GoAText, {
9081
9108
  size: "heading-xl",
9082
- ml: "xl",
9083
9109
  mb: "xl",
9084
9110
  children: title
9085
9111
  }), subtitle && jsx(GoAText, {
9086
9112
  size: "heading-l",
9087
9113
  mt: "none",
9088
9114
  mb: "xl",
9089
- ml: "xl",
9090
9115
  children: subtitle
9091
9116
  }), jsx(ApplicationStatus, {
9092
9117
  completedGroups: completedPages,
@@ -11062,6 +11087,13 @@ $$1({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
11062
11087
  });
11063
11088
 
11064
11089
  const _excluded$1 = ["label", "path", "schema", "rootSchema", "uischema", "errors", "openDeleteDialog", "visible", "enabled", "cells", "data", "config"];
11090
+ const getItemsTitle = schema => {
11091
+ const items = schema === null || schema === void 0 ? void 0 : schema.items;
11092
+ if (items && !Array.isArray(items) && typeof items === 'object') {
11093
+ return items.title;
11094
+ }
11095
+ return undefined;
11096
+ };
11065
11097
  // eslint-disable-next-line
11066
11098
  const extractScopesFromUISchema = uischema => {
11067
11099
  var _a, _b, _c, _d, _e, _f;
@@ -11486,7 +11518,7 @@ const ObjectArrayList = ({
11486
11518
  ref: rightRef,
11487
11519
  tabIndex: -1,
11488
11520
  children: [jsx(ObjectArrayTitle, {
11489
- children: pluralize.singular(listTitle || '')
11521
+ children: listTitle
11490
11522
  }), jsx(NonEmptyList, {
11491
11523
  childPath: Paths.compose(path, `${currentIndex}`),
11492
11524
  rowIndex: currentIndex,
@@ -11551,7 +11583,7 @@ class ListWithDetailControl extends React.Component {
11551
11583
  };
11552
11584
  }
11553
11585
  render() {
11554
- var _a;
11586
+ var _a, _b, _c, _d, _e;
11555
11587
  const _this$props = this.props,
11556
11588
  {
11557
11589
  label,
@@ -11570,7 +11602,7 @@ class ListWithDetailControl extends React.Component {
11570
11602
  additionalProps = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
11571
11603
  const controlElement = uischema;
11572
11604
  // eslint-disable-next-line
11573
- const listTitle = label || ((_a = uischema.options) === null || _a === void 0 ? void 0 : _a.title);
11605
+ const listTitle = (_e = (_d = (_c = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.label) !== null && _a !== void 0 ? _a : (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : getItemsTitle(schema)) !== null && _d !== void 0 ? _d : schema === null || schema === void 0 ? void 0 : schema.title) !== null && _e !== void 0 ? _e : label;
11574
11606
  return jsxs(Visible, {
11575
11607
  visible: visible,
11576
11608
  "data-testid": "jsonforms-object-list-wrapper",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.39.0",
3
+ "version": "2.41.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",
@@ -13,7 +13,7 @@
13
13
  "ajv-errors": "^3.0.0",
14
14
  "ajv-formats": "^3.0.1",
15
15
  "@mdx-js/mdx": "^3.1.0",
16
- "expr-eval": "^2.0.2",
16
+ "expr-eval-fork": "^3.0.1",
17
17
  "pluralize": "^8.0.0"
18
18
  },
19
19
  "dependencies": {