@abgov/jsonforms-components 1.40.1 → 1.40.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.
package/index.esm.js CHANGED
@@ -6,7 +6,7 @@ import axios from 'axios';
6
6
  import get$1 from 'lodash/get';
7
7
  import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, getAjv, isVisible, isEnabled, deriveLabelForUISchemaElement, schemaTypeIs, formatIs, createDefaultValue, Paths, or, isObjectArrayControl, isPrimitiveArrayControl, isControl, isScoped, hasType, isCategorization, isLayout } from '@jsonforms/core';
8
8
  import { withJsonFormsControlProps, withJsonFormsRendererProps, withJsonFormsEnumProps, withTranslateProps, useJsonForms, JsonFormsDispatch, withJsonFormsLayoutProps, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
9
- import { isEqual, isObject as isObject$e } from 'lodash';
9
+ import { isEqual, isEmpty as isEmpty$2, isObject as isObject$e } from 'lodash';
10
10
  import merge from 'lodash/merge';
11
11
  import isEmpty$1 from 'lodash/isEmpty';
12
12
  import range from 'lodash/range';
@@ -2465,12 +2465,19 @@ const StepperContext = /*#__PURE__*/createContext({
2465
2465
  const isEmpty = value => {
2466
2466
  return value === undefined || value === null || typeof value === 'string' && value.length < 1;
2467
2467
  };
2468
- const getCompletionStatus = (table, step) => {
2468
+ const getCompletionStatus = (table, step, isFormChanged = false) => {
2469
2469
  const nonEmptyCount = getNonEmptyCount(table, step);
2470
+ const requiredCount = getRequiredCount(table, step);
2470
2471
  if (nonEmptyCount === 0) {
2471
- return undefined;
2472
+ if (!isFormChanged) {
2473
+ return undefined;
2474
+ }
2475
+ if (requiredCount === 0) {
2476
+ return 'complete';
2477
+ } else {
2478
+ return 'incomplete';
2479
+ }
2472
2480
  }
2473
- const requiredCount = getRequiredCount(table, step);
2474
2481
  const requiredNonEmptyCount = getNonEmptyRequiredCount(table, step);
2475
2482
  if (requiredNonEmptyCount === requiredCount) {
2476
2483
  return 'complete';
@@ -2478,7 +2485,9 @@ const getCompletionStatus = (table, step) => {
2478
2485
  return 'incomplete';
2479
2486
  };
2480
2487
  const getNonEmptyCount = (table, step) => {
2481
- const nonEmptyStatuses = Object.keys(table).filter(k => table[k].step === step && !isEmpty(table[k].value));
2488
+ const nonEmptyStatuses = Object.keys(table).filter(k => {
2489
+ return table[k].step === step && !isEmpty(table[k].value);
2490
+ });
2482
2491
  return nonEmptyStatuses.length;
2483
2492
  };
2484
2493
  const getRequiredCount = (table, step) => {
@@ -4415,6 +4424,7 @@ const ESCAPE_KEY = 'Escape';
4415
4424
  const ARROW_DOWN_KEY = 'ArrowDown';
4416
4425
  const ARROW_UP_KEY = 'ArrowUp';
4417
4426
  const TAB_KEY = 'Tab';
4427
+ const SPACE_KEY = ' ';
4418
4428
 
4419
4429
  let _$7 = t => t,
4420
4430
  _t$7,
@@ -4461,7 +4471,7 @@ const GoADropdownListContainer = styled.div(_t3$4 || (_t3$4 = _$7`
4461
4471
  }
4462
4472
  &:hover {
4463
4473
  background-color: var(--goa-color-interactive-hover) !important;
4464
- color: white !important;
4474
+ color: var(--goa-color-text-light) !important;
4465
4475
  }
4466
4476
  `), p => p.optionListMaxHeight || '272px');
4467
4477
  const GoADropdownListOption = styled.div(_t4$2 || (_t4$2 = _$7`
@@ -4488,7 +4498,7 @@ const GoADropdownListOption = styled.div(_t4$2 || (_t4$2 = _$7`
4488
4498
  }
4489
4499
  &:focus-within {
4490
4500
  caret-color: transparent;
4491
- color: ${0} !important;
4501
+ color: 'var(--goa-color-text-light) !important';
4492
4502
  background-color: var(--goa-color-interactive-hover) !important;
4493
4503
  }
4494
4504
  .dropDownListItem:focus-visible {
@@ -4496,7 +4506,7 @@ const GoADropdownListOption = styled.div(_t4$2 || (_t4$2 = _$7`
4496
4506
  outline: none !important;
4497
4507
  color: ${0};
4498
4508
  }
4499
- `), p => p.isSelected ? 'white' : 'var(--goa-color-greyscale-black)', p => p.isSelected ? 'var(--goa-color-interactive-default)' : '#fff', p => p.isSelected ? 'var(--goa-color-interactive-hover)' : 'var(--goa-color-greyscale-100) !important', p => p.isSelected ? 'var(--goa-color-interactive-default)' : 'var(--goa-color-interactive-hover) !important', p => p.isSelected ? 'var(--goa-color-interactive-hover)' : 'var(--goa-color-greyscale-100) !important', p => p.isSelected ? 'var(--goa-color-interactive-default)' : 'var(--goa-color-interactive-hover) !important', p => p.isSelected ? 'white' : 'var(--goa-color-interactive-hover)', p => p.isSelected ? 'white' : 'var(--goa-color-interactive-hover) !important');
4509
+ `), p => p.isSelected ? 'var(--goa-color-text-light)' : 'var(--goa-color-greyscale-black)', p => p.isSelected ? 'var(--goa-color-interactive-default)' : '#fff', p => p.isSelected ? 'var(--goa-color-interactive-hover)' : 'var(--goa-color-greyscale-100) !important', p => p.isSelected ? 'var(--goa-color-interactive-default)' : 'var(--goa-color-interactive-hover) !important', p => p.isSelected ? 'var(--goa-color-interactive-hover)' : 'var(--goa-color-greyscale-100) !important', p => p.isSelected ? 'var(--goa-color-interactive-default)' : 'var(--goa-color-interactive-hover) !important', p => p.isSelected ? 'var(--goa-color-text-light)' : 'var(--goa-color-interactive-hover) !important');
4500
4510
 
4501
4511
  const isValidKey = keyCode => {
4502
4512
  if (keyCode === 'Shift' || keyCode === 'Alt') return false;
@@ -4582,7 +4592,7 @@ const Dropdown = props => {
4582
4592
  /* istanbul ignore next */
4583
4593
  const handleKeyDown = e => {
4584
4594
  var _a, _b, _c;
4585
- if (e.key === ENTER_KEY) {
4595
+ if (e.key === ENTER_KEY || e.key === SPACE_KEY) {
4586
4596
  setIsOpen(previousIsOpen => !previousIsOpen);
4587
4597
  const el = document.getElementById(`${PREFIX}-${label}-${(_a = items.at(0)) === null || _a === void 0 ? void 0 : _a.value}`);
4588
4598
  setElementFocus(e, el, false);
@@ -4619,7 +4629,7 @@ const Dropdown = props => {
4619
4629
  };
4620
4630
  const handDropDownItemOnKeyDown = (e, item) => {
4621
4631
  var _a, _b, _c, _d;
4622
- if (e.key === ENTER_KEY) {
4632
+ if (e.key === ENTER_KEY || e.key === SPACE_KEY) {
4623
4633
  updateDropDownData(item);
4624
4634
  const inputEl = document.getElementById(`${id}-input`);
4625
4635
  if (inputEl) {
@@ -5593,7 +5603,7 @@ const FormStepper = props => {
5593
5603
  useEffect(() => {
5594
5604
  const statuses = Array(categories.length);
5595
5605
  categories.forEach((_, i) => {
5596
- statuses[i] = getCompletionStatus(inputStatuses, i + 1);
5606
+ statuses[i] = isEmpty$2(stepStatuses[i]) ? getCompletionStatus(inputStatuses, i + 1) : stepStatuses[i];
5597
5607
  });
5598
5608
  setStepStatuses(statuses);
5599
5609
  }, [inputStatuses, categories]);
@@ -5613,7 +5623,7 @@ const FormStepper = props => {
5613
5623
  return jsx(Fragment, {});
5614
5624
  }
5615
5625
  function nextPage(page, disabled) {
5616
- const pageStatus = getCompletionStatus(inputStatuses, page);
5626
+ const pageStatus = getCompletionStatus(inputStatuses, page, true);
5617
5627
  const statuses = [...stepStatuses];
5618
5628
  statuses[page - 1] = pageStatus ? pageStatus : 'incomplete';
5619
5629
  setStepStatuses(statuses);
@@ -5625,6 +5635,10 @@ const FormStepper = props => {
5625
5635
  setPage(page);
5626
5636
  }
5627
5637
  function prevPage(page, disabled) {
5638
+ const pageStatus = getCompletionStatus(inputStatuses, page, true);
5639
+ const statuses = [...stepStatuses];
5640
+ statuses[page - 1] = pageStatus ? pageStatus : 'incomplete';
5641
+ setStepStatuses(statuses);
5628
5642
  page--;
5629
5643
  while (page >= 0 && disabled[page - 1]) {
5630
5644
  /* istanbul ignore next */
@@ -8266,7 +8280,7 @@ const NameInputs = ({
8266
8280
  testId: "wrapper",
8267
8281
  children: [jsx(GoAFormItem, {
8268
8282
  testId: "formitem-first-name",
8269
- label: "First Name",
8283
+ label: "First name",
8270
8284
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('firstName')) ? 'required' : undefined,
8271
8285
  error: (_a = errors === null || errors === void 0 ? void 0 : errors['firstName']) !== null && _a !== void 0 ? _a : '',
8272
8286
  children: jsx(GoAInput, {
@@ -8284,7 +8298,7 @@ const NameInputs = ({
8284
8298
  })
8285
8299
  }), jsx(GoAFormItem, {
8286
8300
  testId: "formitem-middle-name",
8287
- label: "Middle Name",
8301
+ label: "Middle name",
8288
8302
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('middleName')) ? 'required' : undefined,
8289
8303
  children: jsx(GoAInput, {
8290
8304
  type: "text",
@@ -8297,7 +8311,7 @@ const NameInputs = ({
8297
8311
  })
8298
8312
  }), jsx(GoAFormItem, {
8299
8313
  testId: "formitem-last-name",
8300
- label: "Last Name",
8314
+ label: "Last name",
8301
8315
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('lastName')) ? 'required' : undefined,
8302
8316
  error: (_b = errors === null || errors === void 0 ? void 0 : errors['lastName']) !== null && _b !== void 0 ? _b : '',
8303
8317
  children: jsx(GoAInput, {
@@ -8465,7 +8479,7 @@ const FullNameDobControl = props => {
8465
8479
  minChildWidth: "0ch",
8466
8480
  gap: "s",
8467
8481
  children: [jsx(GoAFormItem, {
8468
- label: "First Name",
8482
+ label: "First name",
8469
8483
  requirement: ((_a = schema === null || schema === void 0 ? void 0 : schema.required) === null || _a === void 0 ? void 0 : _a.includes('firstName')) ? 'required' : undefined,
8470
8484
  error: (_b = errors === null || errors === void 0 ? void 0 : errors['firstName']) !== null && _b !== void 0 ? _b : '',
8471
8485
  children: jsx(GoAInput, {
@@ -8485,7 +8499,7 @@ const FullNameDobControl = props => {
8485
8499
  width: "100%"
8486
8500
  })
8487
8501
  }), jsx(GoAFormItem, {
8488
- label: "Middle Name",
8502
+ label: "Middle name",
8489
8503
  requirement: ((_c = schema === null || schema === void 0 ? void 0 : schema.required) === null || _c === void 0 ? void 0 : _c.includes('middleName')) ? 'required' : undefined,
8490
8504
  children: jsx(GoAInput, {
8491
8505
  type: "text",
@@ -8497,7 +8511,7 @@ const FullNameDobControl = props => {
8497
8511
  width: "100%"
8498
8512
  })
8499
8513
  }), jsx(GoAFormItem, {
8500
- label: "Last Name",
8514
+ label: "Last name",
8501
8515
  requirement: ((_d = schema === null || schema === void 0 ? void 0 : schema.required) === null || _d === void 0 ? void 0 : _d.includes('lastName')) ? 'required' : undefined,
8502
8516
  error: (_e = errors === null || errors === void 0 ? void 0 : errors['lastName']) !== null && _e !== void 0 ? _e : '',
8503
8517
  children: jsx(GoAInput, {
@@ -8518,7 +8532,7 @@ const FullNameDobControl = props => {
8518
8532
  minChildWidth: "0ch",
8519
8533
  gap: "s",
8520
8534
  children: jsx(GoAFormItem, {
8521
- label: "Date of Birth",
8535
+ label: "Date of birth",
8522
8536
  error: (_f = errors === null || errors === void 0 ? void 0 : errors['dateOfBirth']) !== null && _f !== void 0 ? _f : '',
8523
8537
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('dateOfBirth')) ? 'required' : undefined,
8524
8538
  children: jsx(GoAInput, {
@@ -8550,20 +8564,20 @@ const FullNameDobReviewControl = props => {
8550
8564
  minChildWidth: "0ch",
8551
8565
  gap: "s",
8552
8566
  children: [jsx(GoAFormItem, {
8553
- label: "First Name",
8567
+ label: "First name",
8554
8568
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('firstName')) ? 'required' : undefined,
8555
8569
  children: jsx("div", {
8556
8570
  "data-testid": `firstName-control-${props.id}`,
8557
8571
  children: (_a = props.data) === null || _a === void 0 ? void 0 : _a.firstName
8558
8572
  })
8559
8573
  }), jsx(GoAFormItem, {
8560
- label: "Middle Name",
8574
+ label: "Middle name",
8561
8575
  children: jsx("div", {
8562
8576
  "data-testid": `middleName-control-${props.id}`,
8563
8577
  children: (_b = props.data) === null || _b === void 0 ? void 0 : _b.middleName
8564
8578
  })
8565
8579
  }), jsx(GoAFormItem, {
8566
- label: "Last Name",
8580
+ label: "Last name",
8567
8581
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('lastName')) ? 'required' : undefined,
8568
8582
  children: jsx("div", {
8569
8583
  "data-testid": `lastName-control-${props.id}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.40.1",
3
+ "version": "1.40.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",
@@ -32,3 +32,6 @@ export declare const ESCAPE_KEY = "Escape";
32
32
  export declare const ARROW_DOWN_KEY = "ArrowDown";
33
33
  export declare const ARROW_UP_KEY = "ArrowUp";
34
34
  export declare const TAB_KEY = "Tab";
35
+ export declare const SPACE_KEY = " ";
36
+ export declare const ALT_KEY = "Alt";
37
+ export declare const SHIFT_KEY = "Shift";
@@ -15,5 +15,5 @@ export declare const StepperContext: import("react").Context<{
15
15
  isInitialized: (_: string) => boolean;
16
16
  stepId: number;
17
17
  }>;
18
- export declare const getCompletionStatus: (table: StatusTable, step: number) => GoAFormStepStatusType | undefined;
18
+ export declare const getCompletionStatus: (table: StatusTable, step: number, isFormChanged?: boolean) => GoAFormStepStatusType | undefined;
19
19
  export declare const logRequiredFields: (table: StatusTable, step: number) => void;