From f8b6aa2d9ec1572701032512bbc21f33ba3e7804 Mon Sep 17 00:00:00 2001 From: Artyom Date: Sat, 25 Sep 2021 21:29:57 +0300 Subject: [PATCH 1/2] [FIX] child key error --- src/Form.tsx | 4 ++-- src/cells/AntdCellHorizontalLayout.tsx | 1 + src/controls/AntdRadioGroupControl.tsx | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Form.tsx b/src/Form.tsx index cf295e8..45cb145 100644 --- a/src/Form.tsx +++ b/src/Form.tsx @@ -228,8 +228,8 @@ export const Form = observer((props) => { } return ( {}}> - {viewKindObs.elements.map((el: IViewKindElement) => ( - + {viewKindObs.elements.map((el: IViewKindElement, idx: number) => ( + ))} ); diff --git a/src/cells/AntdCellHorizontalLayout.tsx b/src/cells/AntdCellHorizontalLayout.tsx index 624feea..ed4c887 100644 --- a/src/cells/AntdCellHorizontalLayout.tsx +++ b/src/cells/AntdCellHorizontalLayout.tsx @@ -69,6 +69,7 @@ export const AntdCellHorizontalLayoutRenderer: React.FC = ({ {(viewKindElement.elements || []).map((e: IViewKindElement, idx: number) => ( = (props) => { - {(uiOptions as any[]).map((optionValue) => ( - {optionValue} + {(uiOptions as any[]).map((optionValue, idx: number) => ( + + {optionValue} + ))} From 6c4934df939ca1a6862af7c06a7c2cbc773d9524 Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Sun, 26 Sep 2021 23:10:47 +0300 Subject: [PATCH 2/2] [refactor] GH-26 Add TS return types --- src/Form.tsx | 5 +++-- src/UnknownRenderer.tsx | 2 +- src/cells/AntdCellCardLayout.tsx | 2 +- src/cells/AntdCellG2.tsx | 2 +- src/cells/AntdSimpleCells.tsx | 20 ++++++++---------- src/cells/TinyMCECell.tsx | 2 +- src/controls/AntdEnumControl.tsx | 2 +- src/data-controls/TabControlRenderer.tsx | 2 +- src/data-controls/TreeRenderer.tsx | 2 -- src/formatters/baseFormatters.tsx | 21 +++++++++---------- src/icons/index.ts | 2 +- src/icons/utils.ts | 6 +++--- src/layouts/AntdFormLayout.tsx | 13 +----------- src/layouts/SplitPaneLayout.tsx | 2 +- src/table/BaseTableArrayControlRenderer.tsx | 2 +- src/table/TableCell.tsx | 2 +- src/table/basetable/BaseTableMenu.tsx | 2 +- src/table/basetable/TableHeader.tsx | 2 +- src/table/basetable/TableSettingMenu.tsx | 9 +++++++- src/util/ContextToProps.tsx | 22 ++++++++++---------- src/util/layout.tsx | 8 ++++++- src/validation/base-validation-functions.tsx | 2 +- 22 files changed, 65 insertions(+), 67 deletions(-) diff --git a/src/Form.tsx b/src/Form.tsx index 45cb145..70f1faf 100644 --- a/src/Form.tsx +++ b/src/Form.tsx @@ -21,6 +21,7 @@ import { MstContext } from './MstContext'; import { UnknownRenderer } from './UnknownRenderer'; import { RankedTester } from './testers'; import { IViewDescr, IViewDescrElement, IViewKind, IViewKindElement } from './models/uischema'; +import { JsObject } from '@agentlab/sparql-jsld-client'; export interface ControlComponent { data: any; @@ -83,7 +84,7 @@ export interface DispatchCellProps extends RenderProps { [key: string]: any; } -export function mstJsonLdIds(o: any) { +export function mstJsonLdIds(o: JsObject): JsObject | undefined { if (o) return { '@id': o['@id'], '@type': o['@type'] }; else return undefined; } @@ -180,7 +181,7 @@ export const FormsDispatch = observer((props) => { } }); -export function ErrorFallback({ error, resetErrorBoundary }: FallbackProps) { +export function ErrorFallback({ error, resetErrorBoundary }: FallbackProps): JSX.Element { return (

Something went wrong:

diff --git a/src/UnknownRenderer.tsx b/src/UnknownRenderer.tsx index fde78a2..ca1c447 100644 --- a/src/UnknownRenderer.tsx +++ b/src/UnknownRenderer.tsx @@ -26,7 +26,7 @@ export interface UnknownRendererProps { * A renderer that will be used in case no other renderer is applicable. */ export class UnknownRenderer extends Component { - render() { + render(): JSX.Element { return (
No applicable {this.props.type} found for element with id={this.props.elementId} and type= diff --git a/src/cells/AntdCellCardLayout.tsx b/src/cells/AntdCellCardLayout.tsx index 76bbf73..bdc2b57 100644 --- a/src/cells/AntdCellCardLayout.tsx +++ b/src/cells/AntdCellCardLayout.tsx @@ -17,7 +17,7 @@ import { Card } from 'antd'; import { DispatchCell } from '../DispatchCell'; import './cell.css'; -export const AntdCellCardLayout = (props: any) => { +export const AntdCellCardLayout = (props: any): JSX.Element => { const { viewKind, viewKindElement, viewDescr, viewDescrElement, schema, data, id } = props; const createCardChilds = () => viewKindElement.elements diff --git a/src/cells/AntdCellG2.tsx b/src/cells/AntdCellG2.tsx index 0003177..f9972ca 100644 --- a/src/cells/AntdCellG2.tsx +++ b/src/cells/AntdCellG2.tsx @@ -10,7 +10,7 @@ const template: any = { 'https://www.wildberries.ru/catalog/16170086/detail.aspx': '/img/chart_3.png', 'https://www.wildberries.ru/catalog/18247707/detail.aspx': '/img/chart_4.png', }; -export const AntdCellG2 = (props: any) => { +export const AntdCellG2 = (props: any): JSX.Element => { return ; }; diff --git a/src/cells/AntdSimpleCells.tsx b/src/cells/AntdSimpleCells.tsx index 03100f0..86df2ea 100644 --- a/src/cells/AntdSimpleCells.tsx +++ b/src/cells/AntdSimpleCells.tsx @@ -7,10 +7,8 @@ * * SPDX-License-Identifier: GPL-3.0-only ********************************************************************************/ -import { get } from 'lodash-es'; - import React from 'react'; -import { Button, Card, Image, Row, Col, Rate } from 'antd'; +import { Button, Image, Rate } from 'antd'; import { rankWith, @@ -37,7 +35,7 @@ import './cell.css'; /** * AntdBooleanCell */ -export const AntdBooleanCell = (props: any) => { +export const AntdBooleanCell = (props: any): JSX.Element => { return ; }; export const antdBooleanCellTester: RankedTester = rankWith(2, isBooleanControl); @@ -46,7 +44,7 @@ export const AntdBooleanCellWithStore = withStoreToCellProps(AntdBooleanCell); /** * AntdButtonCell */ -export const AntdButtonCell = (props: any) => { +export const AntdButtonCell = (props: any): JSX.Element => { const options = props.uiOptions; return (