@abgov/jsonforms-components 2.43.1 → 2.43.3

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 +40 -35
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as runtime from 'react/jsx-runtime';
2
2
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
3
  import React, { createContext, useContext, useReducer, useMemo, useEffect, useCallback, useState, useRef, useLayoutEffect } from 'react';
4
- import { GoabFormItem, GoabInput, GoabTextArea, GoabCallout, GoabRadioGroup, GoabRadioItem, GoabCheckbox, GoabIcon, GoabGrid, GoabFormStepper, GoabFormStep, GoabPages, GoabButton, GoabModal, GoabButtonGroup, GoabBadge, GoabText, GoabTable, GoabIconButton, GoabFileUploadInput, GoabCircularProgress, GoabContainer, GoabDropdown, GoabDropdownItem, GoabDetails, GoabSpinner } from '@abgov/react-components';
4
+ import { GoabFormItem, GoabInput, GoabTextArea, GoabCallout, GoabDatePicker, GoabRadioGroup, GoabRadioItem, GoabCheckbox, GoabIcon, GoabGrid, GoabFormStepper, GoabFormStep, GoabPages, GoabButton, GoabModal, GoabButtonGroup, GoabBadge, GoabText, GoabTable, GoabIconButton, GoabFileUploadInput, GoabCircularProgress, GoabContainer, GoabDropdown, GoabDropdownItem, GoabDetails, GoabSpinner } from '@abgov/react-components';
5
5
  import styled from 'styled-components';
6
6
  import axios from 'axios';
7
7
  import get$1 from 'lodash/get';
@@ -3175,7 +3175,7 @@ const checkFieldValidity = props => {
3175
3175
  uischema,
3176
3176
  schema
3177
3177
  } = props;
3178
- const labelToUpdate = (uischema === null || uischema === void 0 ? void 0 : uischema.scope) ? convertToSentenceCase(getLabelText(uischema === null || uischema === void 0 ? void 0 : uischema.scope, label)) : label;
3178
+ const labelToUpdate = label;
3179
3179
  const extraSchema = schema;
3180
3180
  if (extraSchema && data && (extraSchema === null || extraSchema === void 0 ? void 0 : extraSchema.title) === sinTitle) {
3181
3181
  if (data.length === 11 && !validateSinWithLuhn(data)) {
@@ -3236,23 +3236,6 @@ const convertToReadableFormat = input => {
3236
3236
  }
3237
3237
  return input.replace(/([a-z])([A-Z])/g, '$1 $2').split(' ').map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(' ');
3238
3238
  };
3239
- /**
3240
- * Converts a input to sentence case (eg: incomeThresholdExample or IncomeThresholdExample)
3241
- * to 'Income threshold example' with the first letter in the sentence capitalized.
3242
- *
3243
- * @param input - The camelCase or PascalCase string (e.g., "incomeThresholdExample").
3244
- * @returns A formatted string with spaces and capitalization (e.g., "Income threshold example").
3245
- */
3246
- const convertToSentenceCase = input => {
3247
- if (!input) {
3248
- return input;
3249
- }
3250
- const convertedInput = convertToReadableFormat(input);
3251
- if (!convertedInput) return convertedInput;
3252
- const firstWord = convertedInput.split(' ').splice(0, 1);
3253
- const newWords = convertedInput.split(' ').splice(1).map(word => word.charAt(0).toLowerCase() + word.slice(1).toLowerCase()).join(' ');
3254
- return firstWord.concat(newWords).join(' ');
3255
- };
3256
3239
 
3257
3240
  var $$t = _export;
3258
3241
  var call$a = functionCall;
@@ -6251,7 +6234,7 @@ const GoAInputBaseControl = props => {
6251
6234
  skipInitialValidation
6252
6235
  } = props;
6253
6236
  const InnerComponent = input;
6254
- const labelToUpdate = convertToSentenceCase(getLabelText(uischema.scope, label || ''));
6237
+ const labelToUpdate = label || '';
6255
6238
  let modifiedErrors = checkFieldValidity(props);
6256
6239
  const formStepperCtx = useContext(JsonFormsStepperContext);
6257
6240
  const stepperState = (_a = formStepperCtx === null || formStepperCtx === void 0 ? void 0 : formStepperCtx.selectStepperState) === null || _a === void 0 ? void 0 : _a.call(formStepperCtx);
@@ -6739,6 +6722,7 @@ const Dropdown = props => {
6739
6722
  width: "100%",
6740
6723
  value: inputText,
6741
6724
  testId: `${id}-input`,
6725
+ ariaLabel: `${id}-input`,
6742
6726
  id: `${id}-input`,
6743
6727
  readonly: !isAutoCompletion,
6744
6728
  onChange: detail => {
@@ -7077,8 +7061,8 @@ const GoADateInput = props => {
7077
7061
  const today = new Date();
7078
7062
  minDate = today.toISOString().split('T')[0];
7079
7063
  }
7080
- return jsx(GoabInput, Object.assign({
7081
- type: "date",
7064
+ return jsx(GoabDatePicker, Object.assign({
7065
+ type: "calendar",
7082
7066
  error: isVisited && errors.length > 0,
7083
7067
  width: width,
7084
7068
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
@@ -7089,12 +7073,13 @@ const GoADateInput = props => {
7089
7073
  min: minDate && new Date(minDate),
7090
7074
  max: maxDate && new Date(maxDate),
7091
7075
  onChange: detail => {
7076
+ var _a;
7092
7077
  if (isVisited === false && setIsVisited) {
7093
7078
  setIsVisited();
7094
7079
  }
7095
7080
  onChangeForDateControl({
7096
- name: detail.name,
7097
- value: detail.value,
7081
+ name: (_a = detail.name) !== null && _a !== void 0 ? _a : 'date',
7082
+ value: detail.valueStr,
7098
7083
  controlProps: props
7099
7084
  });
7100
7085
  },
@@ -7777,11 +7762,17 @@ const GoABaseInputReviewComponent = props => {
7777
7762
  return null;
7778
7763
  };
7779
7764
  if (isBoolean) {
7780
- const checkboxLabel = ((_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.trim()) || convertToSentenceCase(getLastSegmentFromPointer(uischema.scope));
7765
+ let checkboxLabel = '';
7766
+ if ((_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.trim()) {
7767
+ checkboxLabel = uischema.options.text.trim();
7768
+ } else if (uischema.scope && uischema.scope.startsWith('#/')) {
7769
+ const fallbackLabel = getLastSegmentFromPointer(uischema.scope);
7770
+ checkboxLabel = fallbackLabel.charAt(0).toUpperCase() + fallbackLabel.slice(1);
7771
+ }
7781
7772
  if (((_c = uischema.options) === null || _c === void 0 ? void 0 : _c.radio) === true) {
7782
7773
  reviewText = data ? `Yes` : `No`;
7783
7774
  } else {
7784
- reviewText = data ? `Yes (${checkboxLabel.trim()})` : `No (${checkboxLabel.trim()})`;
7775
+ reviewText = data ? `Yes (${checkboxLabel})` : `No (${checkboxLabel})`;
7785
7776
  }
7786
7777
  }
7787
7778
  if (isTime) {
@@ -7794,9 +7785,17 @@ const GoABaseInputReviewComponent = props => {
7794
7785
  reviewText = jsx("ul", {
7795
7786
  children: data.map((checkbox, index) => {
7796
7787
  var _a, _b;
7797
- const checkboxLabel = ((_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.trim()) || convertToSentenceCase(getLastSegmentFromPointer(uischema.scope));
7788
+ let checkboxLabel = '';
7789
+ // Use explicit text if provided, otherwise fall back to property name from scope
7790
+ if ((_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.trim()) {
7791
+ checkboxLabel = uischema.options.text.trim();
7792
+ } else if (uischema.scope && uischema.scope.startsWith('#/')) {
7793
+ const fallbackLabel = getLastSegmentFromPointer(uischema.scope);
7794
+ // Capitalize first letter only when falling back to property name from scope
7795
+ checkboxLabel = fallbackLabel.charAt(0).toUpperCase() + fallbackLabel.slice(1);
7796
+ }
7798
7797
  return jsx("li", {
7799
- children: checkbox.trim() || checkboxLabel.trim()
7798
+ children: checkbox.trim() || checkboxLabel
7800
7799
  }, index);
7801
7800
  })
7802
7801
  });
@@ -7830,18 +7829,24 @@ const GoAInputBaseTableReview = props => {
7830
7829
  enabled,
7831
7830
  cells
7832
7831
  } = props;
7833
- const labelToUpdate = convertToSentenceCase(getLabelText(uischema.scope, label || ''));
7832
+ const labelToUpdate = label || '';
7834
7833
  let reviewText = data;
7835
7834
  const isBoolean = typeof data === 'boolean';
7836
7835
  if (isBoolean) {
7837
- const checkboxLabel = ((_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.trim()) || convertToSentenceCase(getLastSegmentFromPointer(uischema.scope));
7836
+ let checkboxLabel = '';
7837
+ if ((_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.trim()) {
7838
+ checkboxLabel = uischema.options.text.trim();
7839
+ } else if (uischema.scope && uischema.scope.startsWith('#/')) {
7840
+ const fallbackLabel = getLastSegmentFromPointer(uischema.scope);
7841
+ checkboxLabel = fallbackLabel.charAt(0).toUpperCase() + fallbackLabel.slice(1);
7842
+ }
7838
7843
  if (((_c = uischema.options) === null || _c === void 0 ? void 0 : _c.radio) === true) {
7839
7844
  reviewText = data ? `Yes` : `No`;
7840
7845
  } else {
7841
7846
  if (label !== '' || typeof label === 'boolean') {
7842
7847
  reviewText = data ? `Yes` : `No`;
7843
7848
  } else {
7844
- reviewText = data ? `Yes (${checkboxLabel.trim()})` : `No (${checkboxLabel.trim()})`;
7849
+ reviewText = data ? `Yes (${checkboxLabel})` : `No (${checkboxLabel})`;
7845
7850
  }
7846
7851
  }
7847
7852
  }
@@ -9816,7 +9821,7 @@ const FileUploader = _ref => {
9816
9821
  return jsx(Fragment, {});
9817
9822
  }
9818
9823
  const helpText = (_0 = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _0 === void 0 ? void 0 : _0.help;
9819
- const sentenceCaseLabel = convertToSentenceCase(label);
9824
+ const sentenceCaseLabel = label;
9820
9825
  const DownloadFileWidget = ({
9821
9826
  index
9822
9827
  }) => {
@@ -10597,7 +10602,7 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
10597
10602
  if (!isInReview) {
10598
10603
  return jsx("th", {
10599
10604
  children: jsxs("p", {
10600
- children: [(currentProperty === null || currentProperty === void 0 ? void 0 : currentProperty.title) || convertToSentenceCase(index), (required === null || required === void 0 ? void 0 : required.includes(value)) && jsx(RequiredSpan, {
10605
+ children: [(currentProperty === null || currentProperty === void 0 ? void 0 : currentProperty.title) || index, (required === null || required === void 0 ? void 0 : required.includes(value)) && jsx(RequiredSpan, {
10601
10606
  children: "(required)"
10602
10607
  })]
10603
10608
  })
@@ -10605,7 +10610,7 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
10605
10610
  }
10606
10611
  return jsx(TableTHHeader, {
10607
10612
  children: jsxs("p", {
10608
- children: [`${(currentProperty === null || currentProperty === void 0 ? void 0 : currentProperty.title) || convertToSentenceCase(index)}`, (required === null || required === void 0 ? void 0 : required.includes(value)) && jsxs(RequiredSpan, {
10613
+ children: [`${(currentProperty === null || currentProperty === void 0 ? void 0 : currentProperty.title) || index}`, (required === null || required === void 0 ? void 0 : required.includes(value)) && jsxs(RequiredSpan, {
10609
10614
  children: [jsx("br", {}), " (required)"]
10610
10615
  })]
10611
10616
  })
@@ -10676,7 +10681,7 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
10676
10681
  error: !!(error === null || error === void 0 ? void 0 : error.message),
10677
10682
  children: [!(required === null || required === void 0 ? void 0 : required.includes(schemaName)) && jsx(GoabDropdownItem, {
10678
10683
  value: "",
10679
- label: `-- Select ${convertToSentenceCase(schemaName)} --`
10684
+ label: `-- Select ${schemaName} --`
10680
10685
  }), dataObject.enum.map(opt => jsx(GoabDropdownItem, {
10681
10686
  value: String(opt),
10682
10687
  label: String(opt)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.43.1",
3
+ "version": "2.43.3",
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",