From cbba152f9cc3b666f11fc9ae962747b8c49dce97 Mon Sep 17 00:00:00 2001 From: Daniel Kuhn Date: Wed, 4 Sep 2024 15:56:56 +0200 Subject: [PATCH 1/2] Refactor defaultProps to default parameters --- packages/table-plugin/src/HTMLTable.tsx | 18 +++--------------- packages/table-plugin/src/types.ts | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/packages/table-plugin/src/HTMLTable.tsx b/packages/table-plugin/src/HTMLTable.tsx index 9f23503..fdffba4 100644 --- a/packages/table-plugin/src/HTMLTable.tsx +++ b/packages/table-plugin/src/HTMLTable.tsx @@ -259,15 +259,15 @@ export const HTMLTable = function HTMLTable({ cssRules, html, sourceBaseUrl, - animationType, + animationType = 'animated', computeHeuristicContentHeight = defaultComputeHeuristicContentHeight, computeContainerHeight = defaultComputeContainerHeight, webViewProps: userWebViewProps, style, onLinkPress, - animationDuration, + animationDuration = DEFAULT_TRANSITION_DURATION, htmlAttribs, - maxScale, + maxScale = 1, ...stats }: HTMLTableProps) { const onDOMLinkPress = useCallback( @@ -331,18 +331,6 @@ const propTypes: Record = { displayMode: PropTypes.oneOf(['flex', 'expand']) }; -const defaultProps = { - animationDuration: DEFAULT_TRANSITION_DURATION, - animationType: 'animated', - computeHeuristicContentHeight: defaultComputeHeuristicContentHeight, - computeContainerHeight: defaultComputeContainerHeight, - maxScale: 1 -}; - Object.defineProperty(HTMLTable, 'propTypes', { value: propTypes }); - -Object.defineProperty(HTMLTable, 'defaultProps', { - value: defaultProps -}); diff --git a/packages/table-plugin/src/types.ts b/packages/table-plugin/src/types.ts index 2a6a7f8..d2cd913 100644 --- a/packages/table-plugin/src/types.ts +++ b/packages/table-plugin/src/types.ts @@ -234,7 +234,7 @@ export interface TableConfig { * * @defaultValue 1 */ - maxScale?: boolean; + maxScale?: number; /** * Container style. From 88f1d56a4ace850d9cab7de585515d092b735121 Mon Sep 17 00:00:00 2001 From: Daniel Kuhn Date: Wed, 4 Sep 2024 16:24:14 +0200 Subject: [PATCH 2/2] Remove propTypes --- packages/heuristic-table-plugin/package.json | 2 - packages/iframe-plugin/package.json | 4 +- packages/table-plugin/package.json | 4 +- packages/table-plugin/src/HTMLTable.tsx | 50 -------------------- 4 files changed, 2 insertions(+), 58 deletions(-) diff --git a/packages/heuristic-table-plugin/package.json b/packages/heuristic-table-plugin/package.json index 23d3057..db4a8d7 100644 --- a/packages/heuristic-table-plugin/package.json +++ b/packages/heuristic-table-plugin/package.json @@ -61,9 +61,7 @@ "typescript": "~4.4.2" }, "dependencies": { - "@types/prop-types": "^15.7.4", "@types/ramda": "^0.27.44", - "prop-types": "^15.7.2", "ramda": "^0.27.1" }, "peerDependencies": { diff --git a/packages/iframe-plugin/package.json b/packages/iframe-plugin/package.json index bf1503c..fc7f050 100644 --- a/packages/iframe-plugin/package.json +++ b/packages/iframe-plugin/package.json @@ -62,9 +62,7 @@ }, "dependencies": { "@formidable-webview/webshell": "^2.6.0", - "@native-html/plugins-core": "workspace:*", - "@types/prop-types": "^15.7.4", - "prop-types": "^15.7.2" + "@native-html/plugins-core": "workspace:*" }, "peerDependencies": { "react": ">= 16.8.0", diff --git a/packages/table-plugin/package.json b/packages/table-plugin/package.json index c7a8b99..ccf8766 100644 --- a/packages/table-plugin/package.json +++ b/packages/table-plugin/package.json @@ -66,9 +66,7 @@ }, "dependencies": { "@formidable-webview/webshell": "2.6.0", - "@native-html/plugins-core": "workspace:*", - "@types/prop-types": "^15.7.4", - "prop-types": "^15.7.2" + "@native-html/plugins-core": "workspace:*" }, "peerDependencies": { "react": ">= 16.8.0", diff --git a/packages/table-plugin/src/HTMLTable.tsx b/packages/table-plugin/src/HTMLTable.tsx index fdffba4..aae743c 100644 --- a/packages/table-plugin/src/HTMLTable.tsx +++ b/packages/table-plugin/src/HTMLTable.tsx @@ -1,5 +1,4 @@ import React, { useMemo, useRef, useLayoutEffect, useCallback } from 'react'; -import PropTypes from 'prop-types'; import { Platform, StyleSheet, @@ -50,30 +49,6 @@ function animateNextFrames(duration?: number) { }); } -const tableStylePropTypeSpec: Record = { - linkColor: PropTypes.string, - fontFamily: PropTypes.string, - fontSizePx: PropTypes.number, - tdBorderColor: PropTypes.string, - thBorderColor: PropTypes.string, - trOddBackground: PropTypes.string, - trOddColor: PropTypes.string, - trEvenBackground: PropTypes.string, - trEvenColor: PropTypes.string, - rowsBorderWidthPx: PropTypes.number, - columnsBorderWidthPx: PropTypes.number, - outerBorderColor: PropTypes.string, - outerBorderWidthPx: PropTypes.number, - cellPaddingEm: PropTypes.number, - fitContainerWidth: PropTypes.bool, - fitContainerHeight: PropTypes.bool, - selectableText: PropTypes.bool, - thEvenBackground: PropTypes.string, - thEvenColor: PropTypes.string, - thOddBackground: PropTypes.string, - thOddColor: PropTypes.string -}; - function findHeight({ computeContainerHeight, computeHeuristicContentHeight, @@ -309,28 +284,3 @@ export const HTMLTable = function HTMLTable({ ); }; - -const propTypes: Record = { - animationDuration: PropTypes.number.isRequired, - animationType: PropTypes.oneOf(['none', 'animated', 'layout']), - computeContainerHeight: PropTypes.func.isRequired, - computeHeuristicContentHeight: PropTypes.func.isRequired, - html: PropTypes.string.isRequired, - numOfChars: PropTypes.number.isRequired, - numOfColumns: PropTypes.number.isRequired, - numOfRows: PropTypes.number.isRequired, - WebView: PropTypes.elementType.isRequired, - onLinkPress: PropTypes.func, - style: PropTypes.any, - tableStyleSpecs: PropTypes.shape(tableStylePropTypeSpec), - cssRules: PropTypes.string, - webViewProps: PropTypes.object, - sourceBaseUrl: PropTypes.string, - maxScale: PropTypes.number.isRequired, - htmlAttribs: PropTypes.any, - displayMode: PropTypes.oneOf(['flex', 'expand']) -}; - -Object.defineProperty(HTMLTable, 'propTypes', { - value: propTypes -});