@abgov/jsonforms-components 1.18.0 → 1.19.0

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
@@ -1,4 +1,4 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useCallback } from 'react';
3
3
  import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoADropdown, GoADropdownItem, GoARadioGroup, GoARadioItem, GoACheckbox, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoADetails } from '@abgov/react-components';
4
4
  import styled from 'styled-components';
@@ -2883,9 +2883,15 @@ const JsonFormRegisterProvider = ({
2883
2883
  return {
2884
2884
  isProvided: true,
2885
2885
  registerDispatch: dispatch,
2886
- selectRegisterDataByUrl: url => {
2887
- var _a;
2888
- return ((_a = registers === null || registers === void 0 ? void 0 : registers.find(r => r.url === url)) === null || _a === void 0 ? void 0 : _a.data) || [];
2886
+ selectRegisterData: criteria => {
2887
+ var _a, _b;
2888
+ if (criteria === null || criteria === void 0 ? void 0 : criteria.url) {
2889
+ return ((_a = registers === null || registers === void 0 ? void 0 : registers.find(r => r.url === criteria.url)) === null || _a === void 0 ? void 0 : _a.data) || [];
2890
+ }
2891
+ if (criteria === null || criteria === void 0 ? void 0 : criteria.urn) {
2892
+ return ((_b = registers === null || registers === void 0 ? void 0 : registers.find(r => r.urn === criteria.urn)) === null || _b === void 0 ? void 0 : _b.data) || [];
2893
+ }
2894
+ return [];
2889
2895
  },
2890
2896
  fetchRegisterByUrl: registerConfig => __awaiter(void 0, void 0, void 0, function* () {
2891
2897
  // Prevent re-freshing remote data
@@ -2932,7 +2938,10 @@ const JsonFormRegisterProvider = ({
2932
2938
  }, [dispatch, defaultRegisters]);
2933
2939
  /* The client might use the context outside of the Jsonform to provide custom register data */
2934
2940
  if (registerCtx === null || registerCtx === void 0 ? void 0 : registerCtx.isProvided) {
2935
- return children;
2941
+ // eslint-disable-next-line
2942
+ return jsx(Fragment, {
2943
+ children: children
2944
+ });
2936
2945
  }
2937
2946
  return jsx(JsonFormsRegisterContext.Provider, {
2938
2947
  value: context,
@@ -3623,7 +3632,7 @@ const GoATimeControlTester = rankWith(4, isTimeControl);
3623
3632
  const GoAInputTimeControl = withJsonFormsControlProps(GoATimeControl);
3624
3633
 
3625
3634
  function fetchRegisterConfigFromOptions(options) {
3626
- if (!(options === null || options === void 0 ? void 0 : options.url)) return undefined;
3635
+ if (!(options === null || options === void 0 ? void 0 : options.url) && !(options === null || options === void 0 ? void 0 : options.urn)) return undefined;
3627
3636
  const config = Object.assign({}, options);
3628
3637
  return config;
3629
3638
  }
@@ -3647,7 +3656,7 @@ const EnumSelect = props => {
3647
3656
  const registerConfig = fetchRegisterConfigFromOptions((_b = (_a = props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.register);
3648
3657
  let registerData = [];
3649
3658
  if (registerConfig) {
3650
- registerData = registerCtx === null || registerCtx === void 0 ? void 0 : registerCtx.selectRegisterDataByUrl(registerConfig.url);
3659
+ registerData = registerCtx === null || registerCtx === void 0 ? void 0 : registerCtx.selectRegisterData(registerConfig);
3651
3660
  }
3652
3661
  const autocompletion = ((_d = (_c = props.uischema) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.autocomplete) === true;
3653
3662
  const appliedUiSchemaOptions = merge({}, config, props.uischema.options);
@@ -4611,9 +4620,15 @@ const getFormFieldValue = (scope, data) => {
4611
4620
  value: flatten(objToArray(currentValue))
4612
4621
  } : {
4613
4622
  type: 'primitive',
4614
- value: currentValue
4623
+ value: getValue(currentValue)
4615
4624
  };
4616
4625
  };
4626
+ const getValue = currentValue => {
4627
+ if (typeof currentValue === 'boolean') {
4628
+ return currentValue ? 'Yes' : 'No';
4629
+ }
4630
+ return currentValue ? String(currentValue) : undefined;
4631
+ };
4617
4632
 
4618
4633
  const renderValue = (label, key,
4619
4634
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -4956,7 +4971,7 @@ const FormStepper = props => {
4956
4971
  })]
4957
4972
  }), jsx(Grid, {
4958
4973
  children: jsx(RenderFormReviewFields, {
4959
- elements: category.elements,
4974
+ elements: category === null || category === void 0 ? void 0 : category.elements,
4960
4975
  data: data,
4961
4976
  requiredFields: requiredFields
4962
4977
  })
@@ -4965,7 +4980,7 @@ const FormStepper = props => {
4965
4980
  })
4966
4981
  })]
4967
4982
  })]
4968
- }), step && step !== 0 && jsxs(GoAGrid, {
4983
+ }), step !== 0 && jsxs(GoAGrid, {
4969
4984
  minChildWidth: "100px",
4970
4985
  children: [jsx("div", {
4971
4986
  children: step !== 1 ? jsx(GoAButton, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
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",
@@ -3,7 +3,7 @@ import { RegisterConfig, RegisterData, JsonFormRegisterDispatch } from './action
3
3
  interface JsonFormsRegisterContextProps {
4
4
  registerDispatch: JsonFormRegisterDispatch;
5
5
  fetchRegisterByUrl: (registerConfig: RegisterConfig) => Promise<void>;
6
- selectRegisterDataByUrl: (url: string) => string[];
6
+ selectRegisterData: (registerConfig: RegisterConfig) => string[];
7
7
  isProvided: boolean;
8
8
  }
9
9
  export declare const JsonFormsRegisterContext: import("react").Context<JsonFormsRegisterContextProps | undefined>;
@@ -11,5 +11,5 @@ interface JsonFormsRegisterProviderProps {
11
11
  children: ReactNode;
12
12
  defaultRegisters: RegisterConfig[] | RegisterData | undefined;
13
13
  }
14
- export declare const JsonFormRegisterProvider: ({ children, defaultRegisters, }: JsonFormsRegisterProviderProps) => JSX.Element | ReactNode;
14
+ export declare const JsonFormRegisterProvider: ({ children, defaultRegisters, }: JsonFormsRegisterProviderProps) => JSX.Element;
15
15
  export {};
@@ -3,7 +3,7 @@ type jsonformsLabel = string | boolean | LabelDescription | undefined;
3
3
  export declare const labelToString: (label: jsonformsLabel, scope: string) => string;
4
4
  export interface InputValue {
5
5
  type: 'primitive' | 'object';
6
- value?: string[][];
6
+ value?: string | string[][];
7
7
  }
8
8
  export declare const getFormFieldValue: (scope: string, data: unknown) => InputValue;
9
9
  export {};