@abgov/jsonforms-components 2.60.6 → 2.60.8

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
@@ -7270,19 +7270,29 @@ function fetchRegisterConfigFromOptions$1(options) {
7270
7270
  const config = Object.assign({}, options);
7271
7271
  return config;
7272
7272
  }
7273
+ const formattedSinPattern = /^\d{3}-\d{3}-\d{3}$/;
7274
+ const allowedSinInputPattern = /^[\d-]*$/;
7275
+ const allowedSinKeyPattern = /^[\d-]$/;
7276
+ const allowedSinControlKeys = new Set(['Backspace', 'Delete', 'Tab', 'Enter', 'Escape', 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End']);
7277
+ const formatSinForDisplay = value => value.replace(/ /g, '-');
7278
+ const formatSinForSchema = value => value.replace(/-/g, ' ');
7273
7279
  const formatSin = value => {
7274
- const inputVal = value == null ? void 0 : value.replace(/ /g, '');
7275
- let inputNumbersOnly = inputVal == null ? void 0 : inputVal.replace(/\D/g, '');
7276
- if (inputNumbersOnly.length > 16) {
7277
- inputNumbersOnly = inputNumbersOnly.substr(0, 9);
7280
+ var _digits$match$join, _digits$match;
7281
+ if (!allowedSinInputPattern.test(value)) {
7282
+ return '';
7283
+ }
7284
+ if (formattedSinPattern.test(value)) {
7285
+ return value;
7278
7286
  }
7279
- const splits = inputNumbersOnly.match(/.{1,3}/g);
7280
- let spacedNumber = '';
7281
- if (splits) {
7282
- spacedNumber = splits.join(' ');
7287
+ const digits = value == null ? void 0 : value.replace(/\D/g, '').slice(0, 9);
7288
+ return (_digits$match$join = digits == null || (_digits$match = digits.match(/.{1,3}/g)) == null ? void 0 : _digits$match.join('-')) != null ? _digits$match$join : '';
7289
+ };
7290
+ const resetInputValue = (detail, value) => {
7291
+ var _detail$event;
7292
+ const target = (_detail$event = detail.event) == null ? void 0 : _detail$event.target;
7293
+ if (target) {
7294
+ target.value = value;
7283
7295
  }
7284
- const formatVal = spacedNumber.length > 11 ? spacedNumber.slice(0, 11) : spacedNumber;
7285
- return formatVal;
7286
7296
  };
7287
7297
  const GoAInputText = props => {
7288
7298
  return jsxs(JsonFormRegisterProvider, {
@@ -7307,13 +7317,14 @@ const InnerGoAInputText = props => {
7307
7317
  setIsVisited
7308
7318
  } = props;
7309
7319
  const user = useRegisterUser();
7310
- const initialValue = data;
7320
+ const isSinField = schema.title === sinTitle;
7321
+ const initialValue = isSinField && typeof data === 'string' ? formatSinForDisplay(data) : data;
7311
7322
  const [manualInput, setManualInput] = useState(false);
7312
7323
  const [localValue, setLocalValue] = useState(initialValue);
7313
7324
  const debouncedValue = useDebounce(localValue, 300);
7314
7325
  useEffect(() => {
7315
- setLocalValue(data);
7316
- }, [data]);
7326
+ setLocalValue(isSinField && typeof data === 'string' ? formatSinForDisplay(data) : data);
7327
+ }, [data, isSinField]);
7317
7328
  useEffect(() => {
7318
7329
  if (!user || data) return;
7319
7330
  const autoPopulatedValue = schema.default || user && autoPopulateValue(user, props);
@@ -7330,11 +7341,12 @@ const InnerGoAInputText = props => {
7330
7341
  }, [schema.default]);
7331
7342
  /* istanbul ignore next */
7332
7343
  useEffect(() => {
7333
- if (debouncedValue === data) return;
7344
+ const dataForInput = isSinField && typeof data === 'string' ? formatSinForDisplay(data) : data;
7345
+ if (debouncedValue === dataForInput) return;
7334
7346
  // Only sync if debouncedValue differs from data and is not initial empty state
7335
- if (debouncedValue !== data && (debouncedValue !== '' || data !== undefined)) {
7347
+ if (debouncedValue !== dataForInput && (debouncedValue !== '' || data !== undefined)) {
7336
7348
  onChangeForInputControl({
7337
- value: debouncedValue,
7349
+ value: isSinField ? formatSinForSchema(debouncedValue) : debouncedValue,
7338
7350
  controlProps: props
7339
7351
  });
7340
7352
  }
@@ -7386,10 +7398,32 @@ const InnerGoAInputText = props => {
7386
7398
  }, [registerCtx, registerConfig]);
7387
7399
  const appliedUiSchemaOptions = Object.assign({}, config, uischema == null ? void 0 : uischema.options);
7388
7400
  const placeholder = (appliedUiSchemaOptions == null ? void 0 : appliedUiSchemaOptions.placeholder) || (schema == null ? void 0 : schema.description) || '';
7389
- const isSinField = schema.title === sinTitle;
7390
7401
  const autoCapitalize = (uischema == null || (_uischema$options5 = uischema.options) == null || (_uischema$options5 = _uischema$options5.componentProps) == null ? void 0 : _uischema$options5.autoCapitalize) === true || (uischema == null || (_uischema$options6 = uischema.options) == null ? void 0 : _uischema$options6.autoCapitalize) === true;
7391
7402
  const readOnly = (_uischema$options$com2 = uischema == null || (_uischema$options7 = uischema.options) == null || (_uischema$options7 = _uischema$options7.componentProps) == null ? void 0 : _uischema$options7.readOnly) != null ? _uischema$options$com2 : false;
7403
+ const preventInvalidSinKey = event => {
7404
+ if (!isSinField || allowedSinControlKeys.has(event.key) || event.metaKey || event.ctrlKey || event.altKey || allowedSinKeyPattern.test(event.key)) {
7405
+ return;
7406
+ }
7407
+ event.preventDefault();
7408
+ };
7409
+ const preventInvalidSinBeforeInput = event => {
7410
+ if (!isSinField) {
7411
+ return;
7412
+ }
7413
+ const data = event.nativeEvent.data;
7414
+ if (data && !allowedSinInputPattern.test(data)) {
7415
+ event.preventDefault();
7416
+ }
7417
+ };
7418
+ const preventInvalidSinPaste = event => {
7419
+ if (isSinField && !allowedSinInputPattern.test(event.clipboardData.getData('text'))) {
7420
+ event.preventDefault();
7421
+ }
7422
+ };
7392
7423
  return jsx("div", {
7424
+ onKeyDownCapture: preventInvalidSinKey,
7425
+ onBeforeInputCapture: preventInvalidSinBeforeInput,
7426
+ onPasteCapture: preventInvalidSinPaste,
7393
7427
  children: mergedOptions.length > 1 ? jsx(GoabDropdown, {
7394
7428
  name: `jsonforms-${path}-dropdown`,
7395
7429
  value: data,
@@ -7410,7 +7444,7 @@ const InnerGoAInputText = props => {
7410
7444
  value: localValue,
7411
7445
  width: width,
7412
7446
  readonly: readOnly,
7413
- maxLength: isSinField ? 11 : '',
7447
+ maxLength: isSinField ? 11 : undefined,
7414
7448
  placeholder: placeholder,
7415
7449
  name: (appliedUiSchemaOptions == null ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
7416
7450
  ariaLabel: (appliedUiSchemaOptions == null ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
@@ -7418,7 +7452,11 @@ const InnerGoAInputText = props => {
7418
7452
  }, (_uischema$options8 = uischema.options) == null ? void 0 : _uischema$options8.componentProps, {
7419
7453
  onChange: detail => {
7420
7454
  let formattedValue = detail.value;
7421
- if (schema && schema.title === sinTitle && detail.value !== '') {
7455
+ if (isSinField && !allowedSinInputPattern.test(detail.value)) {
7456
+ resetInputValue(detail, localValue);
7457
+ return;
7458
+ }
7459
+ if (isSinField && detail.value !== '') {
7422
7460
  formattedValue = formatSin(detail.value);
7423
7461
  }
7424
7462
  setLocalValue(formattedValue);
@@ -7436,6 +7474,12 @@ const InnerGoAInputText = props => {
7436
7474
  controlProps: props,
7437
7475
  value: autoCapitalize ? detail.value.toUpperCase() : detail.value
7438
7476
  });
7477
+ },
7478
+ onKeyPress: detail => {
7479
+ if (isSinField && detail.key && !allowedSinKeyPattern.test(detail.key)) {
7480
+ var _detail$event2;
7481
+ (_detail$event2 = detail.event) == null || _detail$event2.preventDefault();
7482
+ }
7439
7483
  }
7440
7484
  }, uischema == null || (_uischema$options9 = uischema.options) == null ? void 0 : _uischema$options9.componentProps))
7441
7485
  });
@@ -9063,6 +9107,8 @@ const EmptyList$1 = ({
9063
9107
  noDataMessage
9064
9108
  }) => jsx(GoabGrid, {
9065
9109
  minChildWidth: "60ch",
9110
+ mt: "l",
9111
+ mb: "l",
9066
9112
  children: jsx(TextCenter, {
9067
9113
  children: jsx("b", {
9068
9114
  children: noDataMessage
@@ -12816,25 +12862,34 @@ const GoAHorizontalLayoutComponent = ({
12816
12862
  enabled,
12817
12863
  visible
12818
12864
  }) => {
12819
- var _layout$elements, _uischema$options;
12865
+ var _uischema$options;
12820
12866
  const layout = uischema;
12821
- const hasHelpContent = (_layout$elements = layout.elements) == null ? void 0 : _layout$elements.some(element => element.type === 'HelpContent');
12867
+ const elements = layout.elements || [];
12868
+ const helpElements = elements.filter(element => element.type === 'HelpContent');
12869
+ const contentElements = elements.filter(element => element.type !== 'HelpContent');
12822
12870
  const childProps = {
12823
- elements: layout.elements,
12824
12871
  schema,
12825
12872
  path,
12826
12873
  enabled,
12827
- direction: hasHelpContent ? 'column' : 'row',
12828
12874
  visible,
12829
12875
  width: (uischema == null || (_uischema$options = uischema.options) == null ? void 0 : _uischema$options.width) || '300px',
12830
12876
  option: {
12831
12877
  space: 'xl'
12832
12878
  }
12833
12879
  };
12834
- return jsx(LayoutRenderer, Object.assign({}, childProps, {
12835
- renderers: renderers,
12836
- cells: cells
12837
- }));
12880
+ return jsxs(Fragment, {
12881
+ children: [helpElements.length > 0 && jsx(LayoutRenderer, Object.assign({}, childProps, {
12882
+ direction: "column",
12883
+ elements: helpElements,
12884
+ renderers: renderers,
12885
+ cells: cells
12886
+ })), contentElements.length > 0 && jsx(LayoutRenderer, Object.assign({}, childProps, {
12887
+ direction: "row",
12888
+ elements: contentElements,
12889
+ renderers: renderers,
12890
+ cells: cells
12891
+ }))]
12892
+ });
12838
12893
  };
12839
12894
  const GoAHorizontalReviewLayoutComponent = ({
12840
12895
  uischema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.60.6",
3
+ "version": "2.60.8",
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,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": "1.0.0",
3
- "generatedAt": "2026-04-17T15:42:29.517Z",
4
- "sourceCommit": "5149af8455ea3e52212089ed42d0e955fe2569e5",
3
+ "generatedAt": "2026-04-17T20:12:05.295Z",
4
+ "sourceCommit": "0dbb4e19e24318d32bf481fdf350f6140ad10f5b",
5
5
  "sourcePath": "libs/jsonforms-components/src/index.ts",
6
6
  "rendererCount": 33,
7
7
  "renderers": [