@abgov/jsonforms-components 1.12.0 → 1.14.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,10 +1,9 @@
1
- import { withAjvProps, materialSliderControlTester, MaterialSliderControl, materialObjectControlTester, MaterialObjectRenderer, materialAllOfControlTester, MaterialAllOfRenderer, materialAnyOfControlTester, MaterialAnyOfRenderer, materialOneOfControlTester, MaterialOneOfRenderer, materialOneOfRadioGroupControlTester, MaterialOneOfRadioGroupControl, materialOneOfEnumControlTester, MaterialOneOfEnumControl, materialHorizontalLayoutTester, materialVerticalLayoutTester, materialArrayLayoutTester, MaterialArrayLayout, materialAnyOfStringOrEnumControlTester, MaterialAnyOfStringOrEnumControl, materialEnumArrayRendererTester, MaterialEnumArrayRenderer, materialBooleanCellTester, MaterialBooleanCell, materialBooleanToggleCellTester, MaterialBooleanToggleCell, materialEnumCellTester, MaterialEnumCell, materialOneOfEnumCellTester, MaterialOneOfEnumCell } from '@jsonforms/material-renderers';
2
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
2
  import React, { createContext, useContext, useEffect, useMemo, useState, useCallback } from 'react';
4
- import { GoACallout, GoAInputDate, GoAFormItem, GoAInput, GoATextArea, GoAInputDateTime, GoAInputTime, GoADropdown, GoADropdownItem, GoARadioGroup, GoARadioItem, GoACheckbox, GoAFormStepper, GoAFormStep, GoAPages, GoAGrid, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoADetails } from '@abgov/react-components';
3
+ import { GoACallout, GoAInputDate, GoAFormItem, GoAInput, GoATextArea, GoAInputDateTime, GoAInputTime, GoADropdown, GoADropdownItem, GoARadioGroup, GoARadioItem, GoACheckbox, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoADetails } from '@abgov/react-components';
5
4
  import styled from 'styled-components';
6
- import { rankWith, uiTypeIs, isDateControl, isStringControl, and, optionIs, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, isDescriptionHidden, isVisible, isEnabled, deriveLabelForUISchemaElement, schemaTypeIs, formatIs, createDefaultValue, Paths, or, isObjectArrayControl, isPrimitiveArrayControl, withIncreasedRank, hasType, isControl, isCategorization, isLayout } from '@jsonforms/core';
7
- import { withJsonFormsRendererProps, withJsonFormsControlProps, withJsonFormsEnumProps, withTranslateProps, JsonFormsDispatch, withJsonFormsLayoutProps, useJsonForms, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
5
+ import { rankWith, uiTypeIs, isDateControl, isStringControl, and, optionIs, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, isDescriptionHidden, getAjv, isVisible, isEnabled, deriveLabelForUISchemaElement, schemaTypeIs, formatIs, createDefaultValue, Paths, or, isObjectArrayControl, isPrimitiveArrayControl, withIncreasedRank, hasType, isControl, isCategorization, isLayout } from '@jsonforms/core';
6
+ import { withJsonFormsRendererProps, withJsonFormsControlProps, withJsonFormsEnumProps, withTranslateProps, useJsonForms, JsonFormsDispatch, withJsonFormsLayoutProps, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
8
7
  import merge from 'lodash/merge';
9
8
  import axios from 'axios';
10
9
  import isEmpty$1 from 'lodash/isEmpty';
@@ -3684,6 +3683,57 @@ const BooleanRadioControl = props => jsx(GoAInputBaseControl, Object.assign({},
3684
3683
  const GoABooleanRadioControlTester = rankWith(3, and(isBooleanControl, optionIs('radio', true)));
3685
3684
  const GoABooleanRadioControl = withJsonFormsControlProps(BooleanRadioControl);
3686
3685
 
3686
+ const renderLayoutElements = (elements, schema, path, enabled, renderers, cells) => {
3687
+ return elements.map((child, index) => jsx("div", {
3688
+ children: jsx(JsonFormsDispatch, {
3689
+ uischema: child,
3690
+ schema: schema,
3691
+ path: path,
3692
+ enabled: enabled,
3693
+ renderers: renderers,
3694
+ cells: cells
3695
+ }, path)
3696
+ }, index));
3697
+ };
3698
+ const withAjvProps = Component => function WithAjvProps(props) {
3699
+ const ctx = useJsonForms();
3700
+ const ajv = getAjv({
3701
+ jsonforms: Object.assign({}, ctx)
3702
+ });
3703
+ return jsx(Component, Object.assign({}, props, {
3704
+ ajv: ajv
3705
+ }));
3706
+ };
3707
+ const LayoutRenderer = ({
3708
+ elements,
3709
+ schema,
3710
+ path,
3711
+ enabled,
3712
+ direction,
3713
+ renderers,
3714
+ cells,
3715
+ visible
3716
+ }) => {
3717
+ if (isEmpty$1(elements)) {
3718
+ return null;
3719
+ } else {
3720
+ if (direction === 'row') {
3721
+ return jsx(Visible, {
3722
+ visible: visible,
3723
+ children: jsx(GoAGrid, {
3724
+ minChildWidth: "10ch",
3725
+ children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
3726
+ })
3727
+ });
3728
+ } else {
3729
+ return jsx(Visible, {
3730
+ visible: visible,
3731
+ children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
3732
+ });
3733
+ }
3734
+ }
3735
+ };
3736
+
3687
3737
  let _$5 = t => t,
3688
3738
  _t$5,
3689
3739
  _t2$3;
@@ -4922,49 +4972,7 @@ const InputCells = [{
4922
4972
  cell: withJsonFormsCellProps(GoAIntegerCell)
4923
4973
  }];
4924
4974
 
4925
- const renderLayoutElements = (elements, schema, path, enabled, renderers, cells) => {
4926
- return elements.map((child, index) => jsx("div", {
4927
- children: jsx(JsonFormsDispatch, {
4928
- uischema: child,
4929
- schema: schema,
4930
- path: path,
4931
- enabled: enabled,
4932
- renderers: renderers,
4933
- cells: cells
4934
- }, path)
4935
- }, index));
4936
- };
4937
- const LayoutRenderer = ({
4938
- elements,
4939
- schema,
4940
- path,
4941
- enabled,
4942
- direction,
4943
- renderers,
4944
- cells,
4945
- visible
4946
- }) => {
4947
- if (isEmpty$1(elements)) {
4948
- return null;
4949
- } else {
4950
- if (direction === 'row') {
4951
- return jsx(Visible, {
4952
- visible: visible,
4953
- children: jsx(GoAGrid, {
4954
- minChildWidth: "10ch",
4955
- children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
4956
- })
4957
- });
4958
- } else {
4959
- return jsx(Visible, {
4960
- visible: visible,
4961
- children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
4962
- });
4963
- }
4964
- }
4965
- };
4966
-
4967
- rankWith(2, uiTypeIs('HorizontalLayout'));
4975
+ const GoAHorizontalLayoutTester = rankWith(2, uiTypeIs('HorizontalLayout'));
4968
4976
  const GoAHorizontalLayoutComponent = ({
4969
4977
  uischema,
4970
4978
  renderers,
@@ -5013,6 +5021,7 @@ const GoAVerticalLayoutComponent = ({
5013
5021
  cells: cells
5014
5022
  }));
5015
5023
  };
5024
+ const GoAlVerticalLayoutTester = rankWith(1, uiTypeIs('VerticalLayout'));
5016
5025
  const GoAVerticalLayout = withJsonFormsLayoutProps(GoAVerticalLayoutComponent, true);
5017
5026
 
5018
5027
  const groupTester = rankWith(1, uiTypeIs('Group'));
@@ -5366,21 +5375,6 @@ const GoABaseRenderers = [
5366
5375
  }, {
5367
5376
  tester: GoACalloutControlTester,
5368
5377
  renderer: GoACalloutControl
5369
- }, {
5370
- tester: materialSliderControlTester,
5371
- renderer: MaterialSliderControl
5372
- }, {
5373
- tester: materialObjectControlTester,
5374
- renderer: MaterialObjectRenderer
5375
- }, {
5376
- tester: materialAllOfControlTester,
5377
- renderer: MaterialAllOfRenderer
5378
- }, {
5379
- tester: materialAnyOfControlTester,
5380
- renderer: MaterialAnyOfRenderer
5381
- }, {
5382
- tester: materialOneOfControlTester,
5383
- renderer: MaterialOneOfRenderer
5384
5378
  }, {
5385
5379
  tester: GoARadioGroupControlTester,
5386
5380
  renderer: GoAEnumRadioGroupControl
@@ -5396,40 +5390,22 @@ const GoABaseRenderers = [
5396
5390
  }, {
5397
5391
  tester: GoAListWithDetailsTester,
5398
5392
  renderer: GoAArrayControlRenderer
5399
- }, {
5400
- tester: materialOneOfRadioGroupControlTester,
5401
- renderer: MaterialOneOfRadioGroupControl
5402
- }, {
5403
- tester: materialOneOfEnumControlTester,
5404
- renderer: MaterialOneOfEnumControl
5405
5393
  },
5406
5394
  // layouts
5407
5395
  {
5408
5396
  tester: GoAGroupLayoutTester,
5409
5397
  renderer: GoAGroupControl
5410
5398
  }, {
5411
- tester: materialHorizontalLayoutTester,
5399
+ tester: GoAHorizontalLayoutTester,
5412
5400
  renderer: GoAHorizontalLayout
5413
5401
  }, {
5414
- tester: materialVerticalLayoutTester,
5402
+ tester: GoAlVerticalLayoutTester,
5415
5403
  renderer: GoAVerticalLayout
5416
- }, {
5417
- tester: materialArrayLayoutTester,
5418
- renderer: MaterialArrayLayout
5419
5404
  },
5420
5405
  // additional
5421
5406
  {
5422
5407
  tester: GoAErrorControlTester,
5423
5408
  renderer: GoAErrorControl
5424
- }, {
5425
- tester: materialAnyOfStringOrEnumControlTester,
5426
- renderer: MaterialAnyOfStringOrEnumControl
5427
- }, {
5428
- tester: materialEnumArrayRendererTester,
5429
- renderer: MaterialEnumArrayRenderer
5430
- }, {
5431
- tester: materialEnumArrayRendererTester,
5432
- renderer: MaterialEnumArrayRenderer
5433
5409
  }, {
5434
5410
  tester: MultiLineTextControlTester,
5435
5411
  renderer: MultiLineTextControl
@@ -5444,18 +5420,6 @@ const GoARenderers = [...GoABaseRenderers, {
5444
5420
  tester: FileUploaderTester,
5445
5421
  renderer: withJsonFormsControlProps(FileUploader)
5446
5422
  }];
5447
- const GoACells = [{
5448
- tester: materialBooleanCellTester,
5449
- cell: MaterialBooleanCell
5450
- }, {
5451
- tester: materialBooleanToggleCellTester,
5452
- cell: MaterialBooleanToggleCell
5453
- }, {
5454
- tester: materialEnumCellTester,
5455
- cell: MaterialEnumCell
5456
- }, {
5457
- tester: materialOneOfEnumCellTester,
5458
- cell: MaterialOneOfEnumCell
5459
- }, ...InputCells];
5423
+ const GoACells = [...InputCells];
5460
5424
 
5461
5425
  export { ContextProvider, GoABaseRenderers, GoACells, GoARenderers, JsonFormContext, addData, addDataByOptions, addDataByUrl, ajv, getAllData, getData };
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.12.0",
3
+ "version": "1.14.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",
7
7
  "peerDependencies": {
8
8
  "@abgov/react-components": "^4.18.1",
9
9
  "@jsonforms/core": "^3.1.0",
10
- "@jsonforms/material-renderers": "^3.1.0",
11
10
  "@jsonforms/react": "^3.1.0",
12
- "@mui/material": "^5.15.10",
13
11
  "react": "^18.0.0",
14
- "ajv": "^6.12.6"
12
+ "ajv": "^6.12.6",
13
+ "ajv8": "npm:ajv@^8.6.1"
15
14
  },
16
15
  "dependencies": {
17
16
  "axios": "^1.6.7",
@@ -1,11 +1,10 @@
1
- import React from 'react';
2
1
  import { StatePropsOfLayout } from '@jsonforms/core';
3
2
  import { TranslateProps } from '@jsonforms/react';
4
- import { AjvProps } from '@jsonforms/material-renderers';
3
+ import { AjvProps } from '../../util/layout';
5
4
  export interface CategorizationStepperLayoutRendererProps extends StatePropsOfLayout, AjvProps, TranslateProps {
6
5
  data: unknown;
7
6
  }
8
7
  export declare const FormStepper: (props: CategorizationStepperLayoutRendererProps) => JSX.Element;
9
8
  export declare const flattenObject: (obj: Record<string, string>) => Record<string, string>;
10
- export declare const FormStepperControl: (props: CategorizationStepperLayoutRendererProps & import("@jsonforms/core").OwnPropsOfLayout) => React.JSX.Element;
9
+ export declare const FormStepperControl: (props: CategorizationStepperLayoutRendererProps & import("@jsonforms/core").OwnPropsOfLayout) => import("react/jsx-runtime").JSX.Element;
11
10
  export default FormStepper;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { ControlProps, OwnPropsOfEnum, RankedTester } from '@jsonforms/core';
3
3
  import { TranslateProps } from '@jsonforms/react';
4
4
  import { WithInputProps } from './type';
5
- import { WithOptionLabel } from '@jsonforms/material-renderers';
5
+ import { WithOptionLabel } from '../../util';
6
6
  import { EnumCellProps, WithClassname } from '@jsonforms/core';
7
7
  type EnumSelectProp = EnumCellProps & WithClassname & TranslateProps & WithInputProps;
8
8
  export declare const EnumSelect: (props: EnumSelectProp) => JSX.Element;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { ControlProps, OwnPropsOfEnum, RankedTester } from '@jsonforms/core';
3
3
  import { TranslateProps } from '@jsonforms/react';
4
4
  import { WithInputProps } from './type';
5
- import { WithOptionLabel } from '@jsonforms/material-renderers';
5
+ import { WithOptionLabel } from '../../util';
6
6
  import { EnumCellProps, WithClassname } from '@jsonforms/core';
7
7
  type RadioGroupProp = EnumCellProps & WithClassname & TranslateProps & WithInputProps;
8
8
  export declare const RadioGroup: (props: RadioGroupProp) => JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { LayoutProps, RankedTester } from '@jsonforms/core';
3
- export declare const materialHorizontalLayoutTester: RankedTester;
3
+ export declare const GoAHorizontalLayoutTester: RankedTester;
4
4
  export declare const GoAHorizontalLayoutComponent: ({ uischema, renderers, cells, schema, path, enabled, visible, }: LayoutProps) => import("react/jsx-runtime").JSX.Element;
5
5
  export declare const GoAHorizontalLayout: React.ComponentType<LayoutProps & import("@jsonforms/core").OwnPropsOfLayout>;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
- import { LayoutProps } from '@jsonforms/core';
2
+ import { LayoutProps, RankedTester } from '@jsonforms/core';
3
3
  export declare const GoAVerticalLayoutComponent: ({ uischema, schema, path, enabled, renderers, cells, visible, }: LayoutProps) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const GoAlVerticalLayoutTester: RankedTester;
4
5
  export declare const GoAVerticalLayout: React.ComponentType<LayoutProps & import("@jsonforms/core").OwnPropsOfLayout>;
@@ -1,2 +1,4 @@
1
1
  export * from './inputControlUtils';
2
2
  export * from './style-component';
3
+ export * from './type';
4
+ export * from './stringUtils';
@@ -1,8 +1,15 @@
1
+ import React, { ComponentType } from 'react';
1
2
  import type { UISchemaElement } from '@jsonforms/core';
2
3
  import { JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry, JsonSchema, OwnPropsOfRenderer } from '@jsonforms/core';
4
+ import Ajv from 'ajv8';
5
+ export type Ajv8 = Ajv;
3
6
  export declare const renderLayoutElements: (elements: UISchemaElement[], schema?: JsonSchema, path?: string, enabled?: boolean, renderers?: JsonFormsRendererRegistryEntry[], cells?: JsonFormsCellRendererRegistryEntry[]) => import("react/jsx-runtime").JSX.Element[];
4
7
  export interface LayoutRendererProps extends OwnPropsOfRenderer {
5
8
  elements: UISchemaElement[];
6
9
  direction: 'row' | 'column';
7
10
  }
11
+ export interface AjvProps {
12
+ ajv: Ajv;
13
+ }
14
+ export declare const withAjvProps: <P extends object>(Component: React.ComponentType<AjvProps & P>) => (props: P) => import("react/jsx-runtime").JSX.Element;
8
15
  export declare const LayoutRenderer: ({ elements, schema, path, enabled, direction, renderers, cells, visible, }: LayoutRendererProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,6 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { EnumOption } from '@jsonforms/core';
3
+ export interface WithOptionLabel {
4
+ getOptionLabel?(option: EnumOption): string;
5
+ renderOption?(props: React.HTMLAttributes<HTMLLIElement>, option: EnumOption): ReactNode;
6
+ }