@abgov/jsonforms-components 2.3.7 → 2.3.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
@@ -3086,6 +3086,21 @@ const standardizeDate = date => {
3086
3086
  return undefined;
3087
3087
  }
3088
3088
  };
3089
+ const to12HourFormat = time24 => {
3090
+ return UTCToFullLocalTime('2025-03-22 ' + time24, true).slice(-11);
3091
+ };
3092
+ const UTCToFullLocalTime = (fullTime, useUTC = false) => {
3093
+ return new Date(fullTime).toLocaleString('en-CA', {
3094
+ hour12: true,
3095
+ year: 'numeric',
3096
+ month: '2-digit',
3097
+ day: '2-digit',
3098
+ hour: '2-digit',
3099
+ second: 'numeric',
3100
+ minute: 'numeric',
3101
+ timeZone: useUTC ? undefined : 'America/Edmonton'
3102
+ }).replace('p.m.', 'PM').replace('a.m.', 'AM');
3103
+ };
3089
3104
 
3090
3105
  /**
3091
3106
  * Checks input controls data value to determine is required and has any data.
@@ -5737,6 +5752,8 @@ const GoABaseInputReviewComponent = props => {
5737
5752
  } = props;
5738
5753
  let reviewText = data;
5739
5754
  const isBoolean = typeof data === 'boolean';
5755
+ const isTime = (schema === null || schema === void 0 ? void 0 : schema.type) === 'string' && (schema === null || schema === void 0 ? void 0 : schema.format) === 'time';
5756
+ const isDateTime = (schema === null || schema === void 0 ? void 0 : schema.type) === 'string' && (schema === null || schema === void 0 ? void 0 : schema.format) === 'date-time';
5740
5757
  const getRequiredLabelText = () => {
5741
5758
  var _a, _b;
5742
5759
  let label = '';
@@ -5779,6 +5796,12 @@ const GoABaseInputReviewComponent = props => {
5779
5796
  }
5780
5797
  }
5781
5798
  }
5799
+ if (isTime) {
5800
+ reviewText = reviewText && to12HourFormat(reviewText);
5801
+ }
5802
+ if (isDateTime) {
5803
+ reviewText = reviewText && UTCToFullLocalTime(reviewText);
5804
+ }
5782
5805
  return jsxs("div", {
5783
5806
  style: {
5784
5807
  fontWeight: '400',
@@ -7170,7 +7193,7 @@ const ApplicationStatus = ({
7170
7193
 
7171
7194
  /* eslint-disable jsx-a11y/anchor-is-valid */
7172
7195
  const TableOfContents = props => {
7173
- var _a;
7196
+ var _a, _b;
7174
7197
  const testid = 'table-of-contents';
7175
7198
  return jsx(PageBorder, {
7176
7199
  children: jsxs("div", {
@@ -7183,8 +7206,8 @@ const TableOfContents = props => {
7183
7206
  children: props.subtitle
7184
7207
  }), jsx(GoATable, {
7185
7208
  width: "100%",
7186
- children: jsx("tbody", {
7187
- children: (_a = props.categories) === null || _a === void 0 ? void 0 : _a.map((category, index) => {
7209
+ children: jsxs("tbody", {
7210
+ children: [(_a = props.categories) === null || _a === void 0 ? void 0 : _a.map((category, index) => {
7188
7211
  return jsxs("tr", {
7189
7212
  children: [jsx(TocPageRef, {
7190
7213
  children: jsx("a", {
@@ -7200,7 +7223,28 @@ const TableOfContents = props => {
7200
7223
  children: getCategoryStatusBadge(category)
7201
7224
  })]
7202
7225
  });
7203
- })
7226
+ }), jsxs("tr", {
7227
+ children: [jsx(TocPageRef, {
7228
+ children: jsx("a", {
7229
+ "data-testid": `page-ref-${(_b = props.categories) === null || _b === void 0 ? void 0 : _b.length}`,
7230
+ href: "#",
7231
+ onClick: e => {
7232
+ var _a;
7233
+ e.preventDefault();
7234
+ props.onClick((_a = props.categories) === null || _a === void 0 ? void 0 : _a.length);
7235
+ },
7236
+ children: jsx("b", {
7237
+ children: "Summary"
7238
+ })
7239
+ })
7240
+ }), jsxs(CategoryStatus, {
7241
+ children: [jsx(GoABadge, {
7242
+ type: props.isValid ? 'success' : 'information',
7243
+ content: props.isValid ? 'Completed' : 'Incomplete',
7244
+ ariaLabel: props.isValid ? 'Completed' : 'Incomplete'
7245
+ }), props.isValid]
7246
+ })]
7247
+ })]
7204
7248
  })
7205
7249
  })]
7206
7250
  })
@@ -7446,7 +7490,8 @@ const FormPagesView = props => {
7446
7490
  } = formStepperCtx;
7447
7491
  const {
7448
7492
  categories,
7449
- activeId
7493
+ activeId,
7494
+ isValid
7450
7495
  } = formStepperCtx.selectStepperState();
7451
7496
  useEffect(() => {
7452
7497
  validatePage(activeId);
@@ -7476,7 +7521,8 @@ const FormPagesView = props => {
7476
7521
  categories,
7477
7522
  onClick: handleGoToPage,
7478
7523
  title: (_b = (_a = props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.title,
7479
- subtitle: (_d = (_c = props.uischema) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.subtitle
7524
+ subtitle: (_d = (_c = props.uischema) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.subtitle,
7525
+ isValid: isValid
7480
7526
  };
7481
7527
  return jsx(TableOfContents, Object.assign({}, tocProps));
7482
7528
  } else {
@@ -9770,6 +9816,27 @@ const HelpContentTester = rankWith(1, uiTypeIs('HelpContent'));
9770
9816
  const HelpContent = withJsonFormsControlProps(HelpContentComponent);
9771
9817
  const HelpReviewContent = withJsonFormsControlProps(HelpContentReviewComponent);
9772
9818
 
9819
+ /**
9820
+ * A helper util to return a value at a certain delay. The delay is reset if the value arg changes
9821
+ * @param value value to be returned after a period of delay
9822
+ * @param delay time in ms to apply the delay
9823
+ * @returns value after the delay timer
9824
+ */
9825
+ function useDebounce(value, delay) {
9826
+ const [debouncedValue, setDebouncedValue] = useState(value);
9827
+ useEffect(() => {
9828
+ // Update debounced value after delay
9829
+ const handler = setTimeout(() => {
9830
+ setDebouncedValue(value);
9831
+ }, delay);
9832
+ // Cancel the timeout if value changes (also on delay change or unmount)
9833
+ return () => {
9834
+ clearTimeout(handler);
9835
+ };
9836
+ }, [value, delay]);
9837
+ return debouncedValue;
9838
+ }
9839
+
9773
9840
  const ADDRESS_PATH = 'api/gateway/v1/address/v1/find';
9774
9841
  const AddressLookUpControl = props => {
9775
9842
  var _a, _b, _c, _d, _e, _f, _g;
@@ -9802,7 +9869,6 @@ const AddressLookUpControl = props => {
9802
9869
  }
9803
9870
  const [address, setAddress] = useState(data || defaultAddress);
9804
9871
  const [searchTerm, setSearchTerm] = useState('');
9805
- const [saveSearchTerm, setSaveSearchTerm] = useState(false);
9806
9872
  const [suggestions, setSuggestions] = useState([]);
9807
9873
  const [loading, setLoading] = useState(false);
9808
9874
  const [errors, setErrors] = useState({});
@@ -9812,6 +9878,7 @@ const AddressLookUpControl = props => {
9812
9878
  setAddress(updatedAddress);
9813
9879
  handleChange(path, updatedAddress);
9814
9880
  };
9881
+ const debouncedRenderAddress = useDebounce(searchTerm, 500);
9815
9882
  const [selectedIndex, setSelectedIndex] = useState(0);
9816
9883
  const dropdownRef = useRef(null);
9817
9884
  const handleInputChange = (field, value) => {
@@ -9847,11 +9914,8 @@ const AddressLookUpControl = props => {
9847
9914
  }));
9848
9915
  };
9849
9916
  useEffect(() => {
9850
- if (saveSearchTerm) {
9851
- handleInputChange('addressLine1', searchTerm);
9852
- setSaveSearchTerm(false);
9853
- }
9854
- }, [saveSearchTerm]); // eslint-disable-line react-hooks/exhaustive-deps
9917
+ handleInputChange('addressLine1', searchTerm);
9918
+ }, [debouncedRenderAddress]); // eslint-disable-line react-hooks/exhaustive-deps
9855
9919
  useEffect(() => {
9856
9920
  const fetchSuggestions = () => __awaiter(void 0, void 0, void 0, function* () {
9857
9921
  if (searchTerm.length > 2 && dropdownSelected === false) {
@@ -9875,7 +9939,6 @@ const AddressLookUpControl = props => {
9875
9939
  }, [searchTerm]); // eslint-disable-line react-hooks/exhaustive-deps
9876
9940
  const handleDropdownChange = value => {
9877
9941
  setSearchTerm(value);
9878
- setSaveSearchTerm(true);
9879
9942
  };
9880
9943
  const handleSuggestionClick = suggestion => {
9881
9944
  const suggestAddress = mapSuggestionToAddress(suggestion);
@@ -10059,6 +10122,7 @@ const AddressViews = ({
10059
10122
  children: [jsx(GoAFormItem, {
10060
10123
  label: "Address line 1",
10061
10124
  error: (data === null || data === void 0 ? void 0 : data.addressLine1) === undefined ? 'addressLine1 is required' : '',
10125
+ requirement: "required",
10062
10126
  children: jsx(TextWrap, {
10063
10127
  children: data === null || data === void 0 ? void 0 : data.addressLine1
10064
10128
  })
@@ -10074,12 +10138,14 @@ const AddressViews = ({
10074
10138
  children: [jsx(GoAFormItem, {
10075
10139
  error: (data === null || data === void 0 ? void 0 : data.municipality) === undefined ? 'city is required' : '',
10076
10140
  label: "City",
10141
+ requirement: "required",
10077
10142
  children: jsx(TextWrap, {
10078
10143
  children: data === null || data === void 0 ? void 0 : data.municipality
10079
10144
  })
10080
10145
  }), jsx(GoAFormItem, {
10081
10146
  error: (data === null || data === void 0 ? void 0 : data.postalCode) === undefined ? 'postalCode is required' : '',
10082
10147
  label: "Postal Code",
10148
+ requirement: "required",
10083
10149
  children: jsx(TextWrap, {
10084
10150
  children: data === null || data === void 0 ? void 0 : data.postalCode
10085
10151
  })
@@ -10090,6 +10156,7 @@ const AddressViews = ({
10090
10156
  children: [jsxs(GoAFormItem, {
10091
10157
  label: "Province",
10092
10158
  error: !isAlbertaAddress && (data === null || data === void 0 ? void 0 : data.subdivisionCode) === undefined ? 'Province is required' : '',
10159
+ requirement: "required",
10093
10160
  children: [isAlbertaAddress && jsx("div", {
10094
10161
  "data-testid": "address-form-province-view",
10095
10162
  children: "Alberta"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.3.7",
3
+ "version": "2.3.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",
@@ -5,6 +5,7 @@ export interface TocProps {
5
5
  onClick: (id: number) => void;
6
6
  title: string | undefined;
7
7
  subtitle: string | undefined;
8
+ isValid: boolean;
8
9
  }
9
10
  export declare const TableOfContents: (props: TocProps) => JSX.Element;
10
11
  export declare const TableOfContentsTester: RankedTester;
@@ -1 +1,3 @@
1
1
  export declare const standardizeDate: (date: Date | string) => string | undefined;
2
+ export declare const to12HourFormat: (time24: string) => string;
3
+ export declare const UTCToFullLocalTime: (fullTime: string, useUTC?: boolean) => string;
@@ -2,3 +2,4 @@ export * from './inputControlUtils';
2
2
  export * from './style-component';
3
3
  export * from './type';
4
4
  export * from './stringUtils';
5
+ export * from './dateUtils';
@@ -0,0 +1,9 @@
1
+ type DebounceValueType = string | boolean | number | Record<string, unknown>;
2
+ /**
3
+ * A helper util to return a value at a certain delay. The delay is reset if the value arg changes
4
+ * @param value value to be returned after a period of delay
5
+ * @param delay time in ms to apply the delay
6
+ * @returns value after the delay timer
7
+ */
8
+ export declare function useDebounce(value: DebounceValueType, delay: number): DebounceValueType;
9
+ export {};