@abgov/jsonforms-components 1.53.7 → 1.53.9

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
@@ -2635,7 +2635,7 @@ const invalidSin = 'Social insurance number is invalid';
2635
2635
  * @param words
2636
2636
  * @returns sentence word string.
2637
2637
  */
2638
- const capitalizeFirstLetter = words => {
2638
+ const capitalizeFirstLetter$1 = words => {
2639
2639
  const value = words.charAt(0).toUpperCase() + words.slice(1).toLowerCase();
2640
2640
  return value;
2641
2641
  };
@@ -2661,7 +2661,7 @@ const controlScopeMatchesLabel = (scope, label) => {
2661
2661
  const getLabelText = (scope, label) => {
2662
2662
  let labelToUpdate = '';
2663
2663
  if (controlScopeMatchesLabel(scope, label || '') && !areAllUppercase(label)) {
2664
- labelToUpdate = capitalizeFirstLetter(label || '');
2664
+ labelToUpdate = capitalizeFirstLetter$1(label || '');
2665
2665
  } else {
2666
2666
  labelToUpdate = label || '';
2667
2667
  }
@@ -2709,7 +2709,7 @@ const checkFieldValidity = props => {
2709
2709
  uischema,
2710
2710
  schema
2711
2711
  } = props;
2712
- const labelToUpdate = getLabelText(uischema.scope, label);
2712
+ const labelToUpdate = (uischema === null || uischema === void 0 ? void 0 : uischema.scope) ? getLabelText(uischema === null || uischema === void 0 ? void 0 : uischema.scope, label) : label;
2713
2713
  const extraSchema = schema;
2714
2714
  if (extraSchema && data && (extraSchema === null || extraSchema === void 0 ? void 0 : extraSchema.title) === sinTitle) {
2715
2715
  if (data.length === 11 && !validateSinWithLuhn(data)) {
@@ -2991,7 +2991,7 @@ const onChangeForInputControl = props => {
2991
2991
  handleChange,
2992
2992
  path
2993
2993
  } = controlProps;
2994
- handleChange(path, value);
2994
+ handleChange(path, value === '' ? undefined : value);
2995
2995
  };
2996
2996
  /**
2997
2997
  * Helper function to process onChange event for Date controls.
@@ -4062,7 +4062,7 @@ let _$8 = t => t,
4062
4062
  _t$8,
4063
4063
  _t2$5,
4064
4064
  _t3$4,
4065
- _t4$3;
4065
+ _t4$4;
4066
4066
  const GoADropdownTextbox = styled.div(_t$8 || (_t$8 = _$8`
4067
4067
  border-radius: var(--goa-space-2xs);
4068
4068
  box-shadow: ${0};
@@ -4102,7 +4102,7 @@ const GoADropdownListContainer = styled.div(_t3$4 || (_t3$4 = _$8`
4102
4102
  scrollbar-color: #a8a8a8 var(--goa-color-greyscale-100) !important;
4103
4103
  }
4104
4104
  `), p => p.optionListMaxHeight || '272px');
4105
- const GoADropdownListOption = styled.div(_t4$3 || (_t4$3 = _$8`
4105
+ const GoADropdownListOption = styled.div(_t4$4 || (_t4$4 = _$8`
4106
4106
  padding: var(--goa-space-2xs) var(--goa-space-s);
4107
4107
  text-overflow: ellipsis;
4108
4108
  color: ${0} !important;
@@ -4470,9 +4470,6 @@ const GoAInputText = props => {
4470
4470
  // maxLength={appliedUiSchemaOptions?.maxLength}
4471
4471
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4472
4472
  testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4473
- // Don't use handleChange in the onChange event, use the keyPress or onBlur.
4474
- // If you use it onChange along with keyPress event it will cause a
4475
- // side effect that causes the validation to render when it shouldn't.
4476
4473
  onChange: (name, value) => {
4477
4474
  let formattedValue = value;
4478
4475
  if (schema && schema.title === sinTitle && value !== '') {
@@ -5363,7 +5360,7 @@ let _$5 = t => t,
5363
5360
  _t$5,
5364
5361
  _t2$4,
5365
5362
  _t3$3,
5366
- _t4$2,
5363
+ _t4$3,
5367
5364
  _t5$2,
5368
5365
  _t6$2,
5369
5366
  _t7$1,
@@ -5399,7 +5396,7 @@ const ReviewItemHeader = styled.div(_t3$3 || (_t3$3 = _$5`
5399
5396
  justify-content: space-between;
5400
5397
  margin-bottom: var(--goa-space-xl);
5401
5398
  `));
5402
- const ReviewItemTitle = styled.div(_t4$2 || (_t4$2 = _$5`
5399
+ const ReviewItemTitle = styled.div(_t4$3 || (_t4$3 = _$5`
5403
5400
  font-size: var(--goa-space-l);
5404
5401
  line-height: var(--goa-space-xl);
5405
5402
  font-weight: 300;
@@ -6385,7 +6382,8 @@ const DeleteFileModal = ({
6385
6382
  let _$3 = t => t,
6386
6383
  _t$3,
6387
6384
  _t2$3,
6388
- _t3$2;
6385
+ _t3$2,
6386
+ _t4$2;
6389
6387
  const DELAY_UPLOAD_TIMEOUT_MS = 5;
6390
6388
  const DELAY_DELETE_TIMEOUT_MS = 5;
6391
6389
  const FileUploaderReview = props => {
@@ -6394,7 +6392,7 @@ const FileUploaderReview = props => {
6394
6392
  }));
6395
6393
  };
6396
6394
  const FileUploader = _a => {
6397
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
6395
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
6398
6396
  var {
6399
6397
  data,
6400
6398
  path,
@@ -6467,6 +6465,7 @@ const FileUploader = _a => {
6467
6465
  if (!enumerators) {
6468
6466
  return jsx(Fragment, {});
6469
6467
  }
6468
+ const helpText = (_p = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _p === void 0 ? void 0 : _p.help;
6470
6469
  const sentenceCaseLabel = convertToSentenceCase(label);
6471
6470
  return jsxs(FileUploaderStyle, {
6472
6471
  id: "file-upload",
@@ -6485,6 +6484,8 @@ const FileUploader = _a => {
6485
6484
  maxFileSize: maxFileSize,
6486
6485
  accept: accept
6487
6486
  })
6487
+ }), helpText && jsx(HelpText, {
6488
+ children: helpText
6488
6489
  }), jsx("div", {
6489
6490
  children: Array.isArray(data) && data[0] === 'Loading' ? jsx(GoAModal, {
6490
6491
  open: Array.isArray(data) && data[0] === 'Loading',
@@ -6542,7 +6543,12 @@ const FileUploader = _a => {
6542
6543
  })]
6543
6544
  });
6544
6545
  };
6545
- const AttachmentBorderDisabled = styled.div(_t$3 || (_t$3 = _$3`
6546
+ const HelpText = styled.div(_t$3 || (_t$3 = _$3`
6547
+ margin-top: var(--goa-space-xs);
6548
+ font-size: var(--goa-font-size-3);
6549
+ color: var(--goa-color-text-secondary);
6550
+ `));
6551
+ const AttachmentBorderDisabled = styled.div(_t2$3 || (_t2$3 = _$3`
6546
6552
  display: flex;
6547
6553
  flex-direction: row;
6548
6554
  border: var(--goa-border-width-s) solid #dcdcdc;
@@ -6551,7 +6557,7 @@ const AttachmentBorderDisabled = styled.div(_t$3 || (_t$3 = _$3`
6551
6557
  width: fit-content;
6552
6558
  background-color: #f1f1f1;
6553
6559
  `));
6554
- const AttachmentBorder = styled.div(_t2$3 || (_t2$3 = _$3`
6560
+ const AttachmentBorder = styled.div(_t3$2 || (_t3$2 = _$3`
6555
6561
  display: flex;
6556
6562
  flex-direction: row;
6557
6563
  border: var(--goa-border-width-s) solid #dcdcdc;
@@ -6560,7 +6566,7 @@ const AttachmentBorder = styled.div(_t2$3 || (_t2$3 = _$3`
6560
6566
  width: fit-content;
6561
6567
  margin-top: var(--goa-space-2xs);
6562
6568
  `));
6563
- const FileUploaderStyle = styled.div(_t3$2 || (_t3$2 = _$3`
6569
+ const FileUploaderStyle = styled.div(_t4$2 || (_t4$2 = _$3`
6564
6570
  margin-bottom: var(--goa-space-l);
6565
6571
  .label {
6566
6572
  display: block;
@@ -6784,7 +6790,8 @@ let _$2 = t => t,
6784
6790
  _t11,
6785
6791
  _t12,
6786
6792
  _t13,
6787
- _t14;
6793
+ _t14,
6794
+ _t15;
6788
6795
  const DeleteDialogContent = styled.div(_t$2 || (_t$2 = _$2`
6789
6796
  margin-bottom: var(--goa-space-m);
6790
6797
  `));
@@ -6804,47 +6811,52 @@ const ObjectArrayTitle = styled.h3(_t4$1 || (_t4$1 = _$2`
6804
6811
  font-size: var(--goa-font-size-2);
6805
6812
  }
6806
6813
  `));
6807
- const TextCenter = styled.div(_t5$1 || (_t5$1 = _$2`
6814
+ const RequiredSpan = styled.span(_t5$1 || (_t5$1 = _$2`
6815
+ color: #666666;
6816
+ font-weight: var(--goa-font-weight-regular);
6817
+ font-size: var(--goa-font-size-2);
6818
+ `));
6819
+ const TextCenter = styled.div(_t6$1 || (_t6$1 = _$2`
6808
6820
  text-align: center;
6809
6821
  `));
6810
- const SideMenuItem = styled.div(_t6$1 || (_t6$1 = _$2`
6822
+ const SideMenuItem = styled.div(_t7 || (_t7 = _$2`
6811
6823
  &:hover {
6812
6824
  background: #f1f1f1;
6813
6825
  }
6814
6826
  `));
6815
- const RowFlex = styled.div(_t7 || (_t7 = _$2`
6827
+ const RowFlex = styled.div(_t8 || (_t8 = _$2`
6816
6828
  display: flex;
6817
6829
  align-items: stretch;
6818
6830
  `));
6819
- const RowFlexMenu = styled.div(_t8 || (_t8 = _$2`
6831
+ const RowFlexMenu = styled.div(_t9 || (_t9 = _$2`
6820
6832
  display: flex;
6821
6833
  flex-direction: row;
6822
6834
  border-bottom: 1px solid #dcdcdc;
6823
6835
  `));
6824
- const FlexTabs = styled.div(_t9 || (_t9 = _$2`
6836
+ const FlexTabs = styled.div(_t10 || (_t10 = _$2`
6825
6837
  flex-direction: column;
6826
6838
  flex: 1;
6827
6839
  overflow-y: auto !important;
6828
6840
  margin-right: 1.5rem;
6829
6841
  `));
6830
- const FlexForm = styled.div(_t10 || (_t10 = _$2`
6842
+ const FlexForm = styled.div(_t11 || (_t11 = _$2`
6831
6843
  flex-direction: column;
6832
6844
  margin: 1.5rem 0;
6833
6845
  flex: 3;
6834
6846
  `));
6835
- const TabName = styled.div(_t11 || (_t11 = _$2`
6847
+ const TabName = styled.div(_t12 || (_t12 = _$2`
6836
6848
  margin: 1rem 0 1rem 1rem;
6837
6849
  font-weight: 700;
6838
6850
  `));
6839
- const Trash = styled.div(_t12 || (_t12 = _$2`
6851
+ const Trash = styled.div(_t13 || (_t13 = _$2`
6840
6852
  margin: 0.75rem 1.25rem 0.75rem 0.75rem;
6841
6853
  margin-left: auto;
6842
6854
  `));
6843
- const ListContainer = styled.div(_t13 || (_t13 = _$2`
6855
+ const ListContainer = styled.div(_t14 || (_t14 = _$2`
6844
6856
  padding: 0 1.5rem 0 0;
6845
6857
  border: 1px solid #dcdcdc;
6846
6858
  `));
6847
- const TableTHHeader = styled.th(_t14 || (_t14 = _$2`
6859
+ const TableTHHeader = styled.th(_t15 || (_t15 = _$2`
6848
6860
  background-color: var(--goa-color-greyscale-100) !important;
6849
6861
  `));
6850
6862
 
@@ -6919,7 +6931,7 @@ const ObjectArrayToolBar = /*#__PURE__*/React.memo(function TableToolbar({
6919
6931
  "aria-label": translations.addAriaLabel,
6920
6932
  onClick: addItem(path, createDefaultValue(schema, rootSchema)),
6921
6933
  type: (_c = (_b = uischema.options) === null || _b === void 0 ? void 0 : _b.addButtonType) !== null && _c !== void 0 ? _c : 'primary',
6922
- children: ((_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.addButtonText) || capitalizeFirstLetter(`Add ${arrayLabel}`)
6934
+ children: ((_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.addButtonText) || capitalizeFirstLetter$1(`Add ${arrayLabel}`)
6923
6935
  })
6924
6936
  })
6925
6937
  });
@@ -6946,7 +6958,13 @@ function objectListReducer(state, action) {
6946
6958
  category
6947
6959
  } = action.payload;
6948
6960
  const newCategories = Object.assign({}, categories);
6949
- newCategories[name].data = category;
6961
+ if (!newCategories[name]) {
6962
+ newCategories[name] = {
6963
+ data: category
6964
+ };
6965
+ } else {
6966
+ newCategories[name].data = category;
6967
+ }
6950
6968
  return Object.assign(Object.assign({}, state), {
6951
6969
  categories: newCategories
6952
6970
  });
@@ -7081,8 +7099,12 @@ const ctxToNonEmptyCellProps$1 = (ctx, ownProps) => {
7081
7099
  handleChange: ownProps.handleChange
7082
7100
  };
7083
7101
  };
7102
+ function capitalizeFirstLetter(str) {
7103
+ if (!str) return ''; // Handle empty strings
7104
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
7105
+ }
7084
7106
  const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellComponent(props) {
7085
- var _a;
7107
+ var _a, _b;
7086
7108
  const {
7087
7109
  schema,
7088
7110
  enabled,
@@ -7098,10 +7120,11 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
7098
7120
  errors
7099
7121
  } = props;
7100
7122
  const properties = (schema === null || schema === void 0 ? void 0 : schema.items) && 'properties' in schema.items && schema.items.properties || {};
7123
+ const required = (_a = schema.items) === null || _a === void 0 ? void 0 : _a.required;
7101
7124
  return jsxs(NonEmptyCellStyle, {
7102
7125
  children: [
7103
7126
  // eslint-disable-next-line
7104
- (_a = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _a === void 0 ? void 0 : _a.map(element => {
7127
+ (_b = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _b === void 0 ? void 0 : _b.map(element => {
7105
7128
  return jsx(JsonFormsDispatch, {
7106
7129
  "data-testid": `jsonforms-object-list-defined-elements-dispatch`,
7107
7130
  schema: schema,
@@ -7118,8 +7141,10 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
7118
7141
  children: [Object.keys(properties).map((key, index) => {
7119
7142
  if (!isInReview) {
7120
7143
  return jsx("th", {
7121
- children: jsx("p", {
7122
- children: convertToSentenceCase(key)
7144
+ children: jsxs("p", {
7145
+ children: [convertToSentenceCase(key), (required === null || required === void 0 ? void 0 : required.includes(key)) && jsx(RequiredSpan, {
7146
+ children: "(required)"
7147
+ })]
7123
7148
  })
7124
7149
  }, index);
7125
7150
  }
@@ -7143,21 +7168,26 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
7143
7168
  var _a;
7144
7169
  const dataObject = properties[element];
7145
7170
  const schemaName = element;
7171
+ const currentData = data && data[num] ? data[num][element] : '';
7146
7172
  const error = errors === null || errors === void 0 ? void 0 : errors.find(
7147
7173
  // eslint-disable-next-line
7148
7174
  e => e.instancePath === `/${props.rowPath.replace(/\./g, '/')}/${i}/${element}`);
7175
+ if ((error === null || error === void 0 ? void 0 : error.message.includes('must NOT have fewer')) && required.find(r => r === schemaName) && (isEmptyBoolean(schema, currentData) || isEmptyNumber(schema, currentData))) {
7176
+ error.message = `${capitalizeFirstLetter(schemaName)} is required`;
7177
+ }
7149
7178
  return jsx("td", {
7150
7179
  children: isInReview ? jsx("div", {
7151
7180
  "data-testid": `#/properties/${schemaName}-input-${i}-review`,
7152
- children: data && data[num] ? data[num][element] : ''
7181
+ children: currentData
7153
7182
  }) : jsx(GoAFormItem, {
7154
7183
  error: (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '',
7155
7184
  mb: errorRow && !error && '2xl' || 'xs',
7156
7185
  children: dataObject.type === 'number' || dataObject.type === 'string' && !dataObject.enum ? jsx(GoAInput, {
7186
+ error: (error === null || error === void 0 ? void 0 : error.message.length) > 0,
7157
7187
  type: dataObject.type === 'number' ? 'number' : 'text',
7158
7188
  id: schemaName,
7159
7189
  name: schemaName,
7160
- value: data && data[num] ? data[num][element] : '',
7190
+ value: currentData,
7161
7191
  testId: `#/properties/${schemaName}-input-${i}`,
7162
7192
  onChange: (name, value) => {
7163
7193
  handleChange(rowPath, {
@@ -7329,7 +7359,7 @@ const ObjectArrayControl = props => {
7329
7359
  });
7330
7360
  currentCategory.data = newCategoryData;
7331
7361
  }
7332
- if ((currentCategory === null || currentCategory === void 0 ? void 0 : currentCategory.count) > 0) currentCategory.count--;
7362
+ if ((currentCategory === null || currentCategory === void 0 ? void 0 : currentCategory.count) && (currentCategory === null || currentCategory === void 0 ? void 0 : currentCategory.count) > 0) currentCategory.count--;
7333
7363
  let handleChangeData = Object.keys(newCategoryData).map(key => {
7334
7364
  return newCategoryData[key];
7335
7365
  });
@@ -7345,12 +7375,14 @@ const ObjectArrayControl = props => {
7345
7375
  }
7346
7376
  });
7347
7377
  };
7378
+ //eslint-disable-next-line
7348
7379
  const handleChangeWithData = (path, value) => {
7380
+ var _a;
7349
7381
  if (path) {
7350
7382
  const categories = registers.categories;
7351
- const currentCategory = categories[path].data;
7383
+ const currentCategory = ((_a = categories[path]) === null || _a === void 0 ? void 0 : _a.data) || {};
7352
7384
  const newData = {};
7353
- const allKeys = Object.keys(value).concat(Object.keys(currentCategory));
7385
+ const allKeys = Object.keys(value).concat(Object.keys(currentCategory || []));
7354
7386
  const allKeysUnique = allKeys.filter((a, b) => allKeys.indexOf(a) === b);
7355
7387
  Object.keys(allKeysUnique).forEach(num => {
7356
7388
  if (!newData[num]) {
@@ -7360,7 +7392,7 @@ const ObjectArrayControl = props => {
7360
7392
  newData[num][path] = currentCategory[num][path];
7361
7393
  });
7362
7394
  value[num] && Object.keys(value[num]).forEach(path => {
7363
- newData[num][path] = value[num][path] || currentCategory[num] && currentCategory[num][path];
7395
+ newData[num][path] = value[num][path] !== undefined ? value[num][path] : currentCategory[num] && currentCategory[num][path];
7364
7396
  });
7365
7397
  });
7366
7398
  const handleChangeData = Object.keys(newData).map(key => {
@@ -7401,8 +7433,10 @@ const ObjectArrayControl = props => {
7401
7433
  visible: visible,
7402
7434
  "data-testid": "jsonforms-object-list-wrapper",
7403
7435
  children: [jsxs(ToolBarHeader, {
7404
- children: [isInReview && listTitle && jsx("b", {
7405
- children: listTitle
7436
+ children: [isInReview && listTitle && jsxs("b", {
7437
+ children: [listTitle, " ", jsx("span", {
7438
+ children: additionalProps.required && '(required)'
7439
+ })]
7406
7440
  }), !isInReview && listTitle && jsxs(ObjectArrayTitle, {
7407
7441
  children: [listTitle, " ", jsx("span", {
7408
7442
  children: additionalProps.required && '(required)'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.53.7",
3
+ "version": "1.53.9",
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,7 +7,7 @@ export interface Categories {
7
7
  [category: string]: Category;
8
8
  }
9
9
  interface Category {
10
- count: number;
10
+ count?: number;
11
11
  data: StateData;
12
12
  }
13
13
  interface Value {
@@ -3,6 +3,7 @@ export declare const DeleteDialogContent: import("styled-components/dist/types")
3
3
  export declare const NonEmptyCellStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
4
4
  export declare const ToolBarHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
5
5
  export declare const ObjectArrayTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
6
+ export declare const RequiredSpan: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
6
7
  export declare const TextCenter: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
7
8
  export declare const SideMenuItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
8
9
  export declare const RowFlex: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;