From db9de446c45df1fbfd55729086d613088eef3e36 Mon Sep 17 00:00:00 2001 From: Ovidijus Parsiunas Date: Sun, 12 Nov 2023 16:57:36 +0000 Subject: [PATCH] 1.0.15 - optimizing TypeScript API to not have to use enums for properties --- component/package-lock.json | 4 +- component/package.json | 2 +- component/src/activeTable.ts | 4 +- component/src/enums/defaultColumnTypes.ts | 10 +++++ component/src/types/columnType.ts | 4 +- .../columnSettings/columnSettingsUtils.ts | 5 ++- other-packages/react/package-lock.json | 18 ++++---- other-packages/react/package.json | 4 +- website/docs/docs/installation.mdx | 2 +- website/docs/examples/design.mdx | 6 +-- website/docs/examples/files.mdx | 2 +- website/package-lock.json | 42 +++++++++---------- website/package.json | 2 +- 13 files changed, 58 insertions(+), 47 deletions(-) diff --git a/component/package-lock.json b/component/package-lock.json index b6695181..55dcb230 100644 --- a/component/package-lock.json +++ b/component/package-lock.json @@ -1,12 +1,12 @@ { "name": "active-table", - "version": "1.0.14", + "version": "1.0.15", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "active-table", - "version": "1.0.14", + "version": "1.0.15", "license": "MIT", "dependencies": { "lit": "^2.2.4" diff --git a/component/package.json b/component/package.json index ce0e75f3..a5ace509 100644 --- a/component/package.json +++ b/component/package.json @@ -1,6 +1,6 @@ { "name": "active-table", - "version": "1.0.14", + "version": "1.0.15", "description": "Framework agnostic table component for editable data experience", "main": "./dist/activeTable.js", "module": "./dist/activeTable.js", diff --git a/component/src/activeTable.ts b/component/src/activeTable.ts index a37d49f3..a09d0033 100644 --- a/component/src/activeTable.ts +++ b/component/src/activeTable.ts @@ -30,12 +30,12 @@ import {StickyPropsUtils} from './utils/stickyProps/stickyPropsUtils'; import {ExportSingleFile, Files, ImportOptions} from './types/files'; import {ActiveOverlayElements} from './types/activeOverlayElements'; import {CellHighlightUtils} from './utils/color/cellHighlightUtils'; +import {DEFAULT_COLUMN_TYPES_STR} from './enums/defaultColumnTypes'; import {ColumnsSettingsMap} from './types/columnsSettingsInternal'; import {ExportFile, ImportFile} from './types/fileTriggerMethods'; import {customElement, property, state} from 'lit/decorators.js'; import {RowDropdownSettings} from './types/rowDropdownSettings'; import {StripedRowsInternal} from './types/stripedRowsInternal'; -import {DEFAULT_COLUMN_TYPES} from './enums/defaultColumnTypes'; import {DefaultCellHoverColors} from './types/cellStateColors'; import {WindowElement} from './elements/window/windowElement'; import {UserKeyEventsState} from './types/userKeyEventsState'; @@ -268,7 +268,7 @@ export class ActiveTable extends LitElement { isColumnResizable?: boolean; @property({type: Array}) - availableDefaultColumnTypes?: DEFAULT_COLUMN_TYPES[]; // this will reduce the default types to ones included here + availableDefaultColumnTypes?: DEFAULT_COLUMN_TYPES_STR[]; // this will reduce the default types to ones included here @property({type: Array}) customColumnTypes?: ColumnTypes; // additional custom column types diff --git a/component/src/enums/defaultColumnTypes.ts b/component/src/enums/defaultColumnTypes.ts index 051941ea..25b41954 100644 --- a/component/src/enums/defaultColumnTypes.ts +++ b/component/src/enums/defaultColumnTypes.ts @@ -8,3 +8,13 @@ export enum DEFAULT_COLUMN_TYPES { SELECT = 'Select', LABEL = 'Label', } + +export type DEFAULT_COLUMN_TYPES_STR = + | 'Text' + | 'Number' + | 'Currency' + | 'Date d-m-y' + | 'Date m-d-y' + | 'Checkbox' + | 'Select' + | 'Label'; diff --git a/component/src/types/columnType.ts b/component/src/types/columnType.ts index 95c5a64d..8df89f93 100644 --- a/component/src/types/columnType.ts +++ b/component/src/types/columnType.ts @@ -1,5 +1,5 @@ import {LabelOptions, SelectOptions, CellDropdownT} from './cellDropdown'; -import {DEFAULT_COLUMN_TYPES} from '../enums/defaultColumnTypes'; +import {DEFAULT_COLUMN_TYPES_STR} from '../enums/defaultColumnTypes'; import {CustomTextProcessing} from './customTextProcessing'; import {IconSettings} from './dropdownButtonItem'; import {Calendar} from './calendarFunctionality'; @@ -10,7 +10,7 @@ import {Sorting} from './sorting'; // This is to be used by the client exclusively // can reuse one of the existing icons -export type ColumnIconSettings = InterfacesUnion<{reusableIconName: DEFAULT_COLUMN_TYPES} | IconSettings>; +export type ColumnIconSettings = InterfacesUnion<{reusableIconName: DEFAULT_COLUMN_TYPES_STR} | IconSettings>; interface Parent { name: string; diff --git a/component/src/utils/columnSettings/columnSettingsUtils.ts b/component/src/utils/columnSettings/columnSettingsUtils.ts index 575f9ea4..40491827 100644 --- a/component/src/utils/columnSettings/columnSettingsUtils.ts +++ b/component/src/utils/columnSettings/columnSettingsUtils.ts @@ -12,12 +12,13 @@ import {DefaultColumnsSettings} from '../../types/columnsSettingsDefault'; import {ColumnSettingsBorderUtils} from './columnSettingsBorderUtils'; import {ColumnSettingsStyleUtils} from './columnSettingsStyleUtils'; import {ColumnSettingsWidthUtils} from './columnSettingsWidthUtils'; +import {DEFAULT_COLUMN_TYPES} from '../../enums/defaultColumnTypes'; import {ColumnTypesUtils} from '../columnType/columnTypesUtils'; import {ResetColumnStructure} from './resetColumnStructure'; import {CellElement} from '../../elements/cell/cellElement'; import {GenericObject} from '../../types/genericObject'; -import {ActiveTable} from '../../activeTable'; import {EMPTY_STRING} from '../../consts/text'; +import {ActiveTable} from '../../activeTable'; export class ColumnSettingsUtils { private static updateSizer(at: ActiveTable, columnIndex: number) { @@ -118,7 +119,7 @@ export class ColumnSettingsUtils { private static setDefaultTypeProperties(at: ActiveTable) { const {_defaultColumnsSettings} = at; - _defaultColumnsSettings.availableDefaultColumnTypes = at.availableDefaultColumnTypes; + _defaultColumnsSettings.availableDefaultColumnTypes = at.availableDefaultColumnTypes as DEFAULT_COLUMN_TYPES[]; _defaultColumnsSettings.customColumnTypes = at.customColumnTypes; _defaultColumnsSettings.defaultColumnTypeName = at.defaultColumnTypeName; _defaultColumnsSettings.types = ColumnTypesUtils.getProcessedTypes(_defaultColumnsSettings); diff --git a/other-packages/react/package-lock.json b/other-packages/react/package-lock.json index f73f79ac..698f082c 100644 --- a/other-packages/react/package-lock.json +++ b/other-packages/react/package-lock.json @@ -1,16 +1,16 @@ { "name": "active-table-react", - "version": "1.0.14", + "version": "1.0.15", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "active-table-react", - "version": "1.0.14", + "version": "1.0.15", "license": "MIT", "dependencies": { "@lit-labs/react": "^1.1.1", - "active-table": "1.0.14" + "active-table": "1.0.15" }, "devDependencies": { "@types/react": "^18.0.28", @@ -67,9 +67,9 @@ "integrity": "sha512-NfQ4gyz38SL8sDNrSixxU2Os1a5xcdFxipAFxYEuLUlvU2uDwS4NUpsImcf1//SlWItCVMMLiylsxbmNMToV/g==" }, "node_modules/active-table": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/active-table/-/active-table-1.0.14.tgz", - "integrity": "sha512-xj8/GhnQEVvuPl/Zp3TJp1G8vqGS0uuFNiKIIhwQEmeCNvdPERum0smmFrGQs15rW+F6W2TkbkPMPNTUluWxAw==", + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/active-table/-/active-table-1.0.15.tgz", + "integrity": "sha512-AjEqJ5KeRrCioS/rqLLmXbOlOWM8YVP8fm0f2zshQFJTsVbEQMZ3Ud37hq03LZ6Yk7sjV7nuAJQ/JiV1TtmUpA==", "dependencies": { "lit": "^2.2.4" } @@ -200,9 +200,9 @@ "integrity": "sha512-NfQ4gyz38SL8sDNrSixxU2Os1a5xcdFxipAFxYEuLUlvU2uDwS4NUpsImcf1//SlWItCVMMLiylsxbmNMToV/g==" }, "active-table": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/active-table/-/active-table-1.0.14.tgz", - "integrity": "sha512-xj8/GhnQEVvuPl/Zp3TJp1G8vqGS0uuFNiKIIhwQEmeCNvdPERum0smmFrGQs15rW+F6W2TkbkPMPNTUluWxAw==", + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/active-table/-/active-table-1.0.15.tgz", + "integrity": "sha512-AjEqJ5KeRrCioS/rqLLmXbOlOWM8YVP8fm0f2zshQFJTsVbEQMZ3Ud37hq03LZ6Yk7sjV7nuAJQ/JiV1TtmUpA==", "requires": { "lit": "^2.2.4" } diff --git a/other-packages/react/package.json b/other-packages/react/package.json index 3880f96a..7b0960fe 100644 --- a/other-packages/react/package.json +++ b/other-packages/react/package.json @@ -1,6 +1,6 @@ { "name": "active-table-react", - "version": "1.0.14", + "version": "1.0.15", "description": "Active Table wrapper for React", "main": "./dist/activeTable.js", "module": "./dist/activeTable.js", @@ -33,7 +33,7 @@ "license": "MIT", "dependencies": { "@lit-labs/react": "^1.1.1", - "active-table": "1.0.14" + "active-table": "1.0.15" }, "devDependencies": { "@types/react": "^18.0.28", diff --git a/website/docs/docs/installation.mdx b/website/docs/docs/installation.mdx index 8f9d2bd0..16df8218 100644 --- a/website/docs/docs/installation.mdx +++ b/website/docs/docs/installation.mdx @@ -19,5 +19,5 @@ npm install active-table-react Access the component via CDN: ``` -https://unpkg.com/active-table@1.0.14/dist/activeTable.bundle.js +https://unpkg.com/active-table@1.0.15/dist/activeTable.bundle.js ``` diff --git a/website/docs/examples/design.mdx b/website/docs/examples/design.mdx index a8130af1..0c5ac89b 100644 --- a/website/docs/examples/design.mdx +++ b/website/docs/examples/design.mdx @@ -8,7 +8,7 @@ Basic examples to help you get started with Active Table. ### Unique column types {#uniqueColumnTypes} -This example makes use of the [`customColumnsSettings`](../docs/column#customColumnsSettings) property to set static types for individual columns. The _Date Created_ +This example makes use of the [`customColumnsSettings`](/docs/column#customColumnsSettings) property to set static types for individual columns. The _Date Created_ column has two available date formats. import TableContainerProgrammaticUpdates from '@site/src/components/table/tableContainerProgrammaticUpdates'; @@ -197,8 +197,8 @@ Table configuration for a dark design. ### Dynamic updates {#dynamicUpdates} -The programmatic cell update functionality is provided by the [`updateCell`](../docs/methods#updateCell) method that exists on the component element reference. -The example additionally makes use of properties like [`customColumnsSettings`](../docs/column#customColumnsSettings) and [`stripedRows`](../docs/row#stripedRows) +The programmatic cell update functionality is provided by the [`updateCell`](/docs/methods#updateCell) method that exists on the component element reference. +The example additionally makes use of properties like [`customColumnsSettings`](/docs/column#customColumnsSettings) and [`stripedRows`](/docs/row#stripedRows) to set a stock related look. Whilst all of the columns are set to not be editable, the _Stock_ column allows its data to be changed and its rows to be sorted. diff --git a/website/docs/examples/files.mdx b/website/docs/examples/files.mdx index f0d67f77..2c3cf2ea 100644 --- a/website/docs/examples/files.mdx +++ b/website/docs/examples/files.mdx @@ -79,7 +79,7 @@ declare global { ## Examples -React project that uses a package bundler - should work similarly for other [Frameworks](./frameworks): +React project that uses a package bundler - should work similarly for other [Frameworks](/examples/frameworks): [Click for Live Example](https://codesandbox.io/s/active-table-react-xlsx-h3j7rq?file=/src/App.tsx) diff --git a/website/package-lock.json b/website/package-lock.json index 26060c9e..a12789be 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -12,7 +12,7 @@ "@docusaurus/preset-classic": "^2.3.0", "@docusaurus/theme-search-algolia": "^2.3.1", "@mdx-js/react": "^1.6.22", - "active-table-react": "^1.0.14", + "active-table-react": "^1.0.15", "clsx": "^1.2.1", "prism-react-renderer": "^1.3.5", "react": "^17.0.2", @@ -3547,9 +3547,9 @@ } }, "node_modules/@types/trusted-types": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.5.tgz", - "integrity": "sha512-I3pkr8j/6tmQtKV/ZzHtuaqYSQvyjGRKH4go60Rr0IDLlFxuRT5V32uvB1mecM5G1EVAUyF/4r4QZ1GHgz+mxA==" + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.6.tgz", + "integrity": "sha512-HYtNooPvUY9WAVRBr4u+4Qa9fYD1ze2IUlAD3HoA6oehn1taGwBx3Oa52U4mTslTS+GAExKpaFu39Y5xUEwfjg==" }, "node_modules/@types/unist": { "version": "2.0.6", @@ -3777,20 +3777,20 @@ } }, "node_modules/active-table": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/active-table/-/active-table-1.0.14.tgz", - "integrity": "sha512-xj8/GhnQEVvuPl/Zp3TJp1G8vqGS0uuFNiKIIhwQEmeCNvdPERum0smmFrGQs15rW+F6W2TkbkPMPNTUluWxAw==", + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/active-table/-/active-table-1.0.15.tgz", + "integrity": "sha512-AjEqJ5KeRrCioS/rqLLmXbOlOWM8YVP8fm0f2zshQFJTsVbEQMZ3Ud37hq03LZ6Yk7sjV7nuAJQ/JiV1TtmUpA==", "dependencies": { "lit": "^2.2.4" } }, "node_modules/active-table-react": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/active-table-react/-/active-table-react-1.0.14.tgz", - "integrity": "sha512-KcA3Pa90go52BcakEzqELHNCpFMbVMHYeN9M05PDLHvtIf4kzljPzodrM593QM4ABG0FMpY0i9NTZ9uJVqczCQ==", + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/active-table-react/-/active-table-react-1.0.15.tgz", + "integrity": "sha512-PQqDpEagz7DZS6s5peXMATw5w0/YCBR8s/tj4VyDn2VBy9U/M6BE26X3osc9hpkGcbT0K08wz2Hf5xc6jvdDYg==", "dependencies": { "@lit-labs/react": "^1.1.1", - "active-table": "1.0.14" + "active-table": "1.0.15" }, "peerDependencies": { "react": ">=16.8.0 || >=17.0.0 || >=18.0.0" @@ -15352,9 +15352,9 @@ } }, "@types/trusted-types": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.5.tgz", - "integrity": "sha512-I3pkr8j/6tmQtKV/ZzHtuaqYSQvyjGRKH4go60Rr0IDLlFxuRT5V32uvB1mecM5G1EVAUyF/4r4QZ1GHgz+mxA==" + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.6.tgz", + "integrity": "sha512-HYtNooPvUY9WAVRBr4u+4Qa9fYD1ze2IUlAD3HoA6oehn1taGwBx3Oa52U4mTslTS+GAExKpaFu39Y5xUEwfjg==" }, "@types/unist": { "version": "2.0.6", @@ -15564,20 +15564,20 @@ "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==" }, "active-table": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/active-table/-/active-table-1.0.14.tgz", - "integrity": "sha512-xj8/GhnQEVvuPl/Zp3TJp1G8vqGS0uuFNiKIIhwQEmeCNvdPERum0smmFrGQs15rW+F6W2TkbkPMPNTUluWxAw==", + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/active-table/-/active-table-1.0.15.tgz", + "integrity": "sha512-AjEqJ5KeRrCioS/rqLLmXbOlOWM8YVP8fm0f2zshQFJTsVbEQMZ3Ud37hq03LZ6Yk7sjV7nuAJQ/JiV1TtmUpA==", "requires": { "lit": "^2.2.4" } }, "active-table-react": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/active-table-react/-/active-table-react-1.0.14.tgz", - "integrity": "sha512-KcA3Pa90go52BcakEzqELHNCpFMbVMHYeN9M05PDLHvtIf4kzljPzodrM593QM4ABG0FMpY0i9NTZ9uJVqczCQ==", + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/active-table-react/-/active-table-react-1.0.15.tgz", + "integrity": "sha512-PQqDpEagz7DZS6s5peXMATw5w0/YCBR8s/tj4VyDn2VBy9U/M6BE26X3osc9hpkGcbT0K08wz2Hf5xc6jvdDYg==", "requires": { "@lit-labs/react": "^1.1.1", - "active-table": "1.0.14" + "active-table": "1.0.15" } }, "address": { diff --git a/website/package.json b/website/package.json index 1f76678e..88c60bf6 100644 --- a/website/package.json +++ b/website/package.json @@ -18,7 +18,7 @@ "@docusaurus/preset-classic": "^2.3.0", "@docusaurus/theme-search-algolia": "^2.3.1", "@mdx-js/react": "^1.6.22", - "active-table-react": "^1.0.14", + "active-table-react": "^1.0.15", "clsx": "^1.2.1", "prism-react-renderer": "^1.3.5", "react": "^17.0.2",