diff --git a/e2e/tests/plugin-form-Nested.spec.ts b/e2e/tests/plugin-form-Nested.spec.ts index fbc8ff273..dc52c4825 100644 --- a/e2e/tests/plugin-form-Nested.spec.ts +++ b/e2e/tests/plugin-form-Nested.spec.ts @@ -1,4 +1,4 @@ -import { Page, expect, test } from '@playwright/test' +import { type Page, expect, test } from '@playwright/test' test.describe.configure({ mode: 'serial' }) diff --git a/e2e/tests/plugin-view_selector-car_garage.spec.ts b/e2e/tests/plugin-view_selector-car_garage.spec.ts index 65da2eeb8..4446bc6ab 100644 --- a/e2e/tests/plugin-view_selector-car_garage.spec.ts +++ b/e2e/tests/plugin-view_selector-car_garage.spec.ts @@ -69,9 +69,11 @@ test('View selector - car garage', async ({ page }) => { page.getByRole('tab', { name: 'car Dimensions' }) ).toBeVisible() - await page.getByTestId('form-text-widget-Next control date').last() + await page + .getByTestId('form-text-widget-Next control date') + .last() - .fill('2025-06-31') + .fill('2025-06-31') await page.getByRole('button', { name: 'Submit' }).click() await expect(page.getByRole('alert')).toHaveText(['Document updated']) await page diff --git a/e2e/tsconfig.json b/e2e/tsconfig.json index b3fd4e82e..e5569fb1e 100644 --- a/e2e/tsconfig.json +++ b/e2e/tsconfig.json @@ -1,9 +1,5 @@ { "extends": "../tsconfig.json", - "include": [ - "tests" - ], - "exclude": [ - "node_modules" - ] + "include": ["tests"], + "exclude": ["node_modules"] } diff --git a/example/src/App.tsx b/example/src/App.tsx index 16e213146..0a6b0e0e0 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -3,13 +3,13 @@ import { DMApplicationProvider, DmssAPI, EntityView, - ErrorResponse, - TApplication, + type ErrorResponse, + type TApplication, } from '@development-framework/dm-core' import { Button, Card, Icon, Typography } from '@equinor/eds-core-react' import { refresh } from '@equinor/eds-icons' -import { AxiosError } from 'axios' +import type { AxiosError } from 'axios' import { useContext, useEffect, useState } from 'react' import { RouterProvider, createBrowserRouter } from 'react-router-dom' import ViewPage from './ViewPage' diff --git a/example/src/ViewPage.tsx b/example/src/ViewPage.tsx index 76abb78f7..c79f6ce7b 100644 --- a/example/src/ViewPage.tsx +++ b/example/src/ViewPage.tsx @@ -2,7 +2,7 @@ import { EntityView, ErrorGroup, Loading, - TValidEntity, + type TValidEntity, useDocument, } from '@development-framework/dm-core' import { Typography } from '@equinor/eds-core-react' diff --git a/example/src/plugins/marmo-ui/containers/views/SignalPlot.tsx b/example/src/plugins/marmo-ui/containers/views/SignalPlot.tsx index ed4f7a678..bcb0bee43 100644 --- a/example/src/plugins/marmo-ui/containers/views/SignalPlot.tsx +++ b/example/src/plugins/marmo-ui/containers/views/SignalPlot.tsx @@ -1,7 +1,7 @@ import { - IUIPlugin, + type IUIPlugin, Loading, - TGenericObject, + type TGenericObject, useDocument, } from '@development-framework/dm-core' // @ts-ignore diff --git a/example/src/plugins/marmo-ui/containers/views/SignalTable/SignalTable.tsx b/example/src/plugins/marmo-ui/containers/views/SignalTable/SignalTable.tsx index 29c4dfb87..3182abc6c 100644 --- a/example/src/plugins/marmo-ui/containers/views/SignalTable/SignalTable.tsx +++ b/example/src/plugins/marmo-ui/containers/views/SignalTable/SignalTable.tsx @@ -9,9 +9,9 @@ import { chevron_left, chevron_right } from '@equinor/eds-icons' import { useState } from 'react' import { - IUIPlugin, + type IUIPlugin, Loading, - TGenericObject, + type TGenericObject, useDocument, } from '@development-framework/dm-core' import { PaginationWrapper, SectionWrapper } from './styles' @@ -86,6 +86,7 @@ const SignalTable = (props: { document: TGenericObject }) => { {rows .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) .map((row: any) => ( + // biome-ignore lint/a11y/useSemanticElements: {columns.map((column) => { const value = row[column.id] diff --git a/example/src/plugins/marmo-ui/index.tsx b/example/src/plugins/marmo-ui/index.tsx index 8c373ac7a..72c278711 100644 --- a/example/src/plugins/marmo-ui/index.tsx +++ b/example/src/plugins/marmo-ui/index.tsx @@ -1,14 +1,14 @@ -import { TUiPluginMap } from '@development-framework/dm-core' +import type { TUiPluginMap } from '@development-framework/dm-core' //views import { SignalPlot } from './containers/views/SignalPlot' import { SignalTable } from './containers/views/SignalTable/SignalTable' -export default ({ +export default { 'marmo-ess-plot-view': { component: SignalPlot, }, 'marmo-ess-table-view': { component: SignalTable, }, -} as TUiPluginMap) +} as TUiPluginMap diff --git a/example/tsconfig.json b/example/tsconfig.json index d9a0c4ae1..5b3a000fa 100644 --- a/example/tsconfig.json +++ b/example/tsconfig.json @@ -3,20 +3,14 @@ "baseUrl": "./src", "incremental": true, "paths": { - "@development-framework/dm-core/*": [ - "../packages/dm-core/src/*" - ], + "@development-framework/dm-core/*": ["../packages/dm-core/src/*"], "@development-framework/dm-core-plugins/*": [ "../packages/dm-core-plugins/src/*" ] }, "target": "ESNext", "useDefineForClassFields": true, - "lib": [ - "ES2020", - "DOM", - "DOM.Iterable" - ], + "lib": ["ES2020", "DOM", "DOM.Iterable"], "allowJs": true, "skipLibCheck": true, "esModuleInterop": false, @@ -30,17 +24,8 @@ "isolatedModules": true, "noEmit": true, "jsx": "react-jsx", - "types": [ - "vite/client", - "vite-plugin-svgr/client", - "node" - ] + "types": ["vite/client", "vite-plugin-svgr/client", "node"] }, - "include": [ - "src" - ], - "exclude": [ - "node_modules", - "tsconfig.tsbuildinfo" - ] + "include": ["src"], + "exclude": ["node_modules", "tsconfig.tsbuildinfo"] } diff --git a/packages/dm-core-plugins/package.json b/packages/dm-core-plugins/package.json index 40d0114be..1a3013415 100644 --- a/packages/dm-core-plugins/package.json +++ b/packages/dm-core-plugins/package.json @@ -4,56 +4,53 @@ "version": "1.57.0", "main": "dist/index.js", "dependencies": { - "@dnd-kit/core": "^6.0.8", - "@dnd-kit/modifiers": "^6.0.1", - "@dnd-kit/sortable": "^7.0.2", + "@dnd-kit/core": "^6.3.1", + "@dnd-kit/modifiers": "^9.0.0", + "@dnd-kit/sortable": "^10.0.0", "@development-framework/dm-core": "^1.46.0", - "@equinor/eds-core-react": ">0.33.0", - "@equinor/eds-icons": ">0.19.3", - "@equinor/eds-tokens": ">0.9.0", - "axios": "^1.4.0", - "dompurify": "^3.0.6", - "highlight.js": "^11.8.0", + "@equinor/eds-core-react": "^0.42.5", + "@equinor/eds-icons": "^0.21.0", + "@equinor/eds-tokens": "^0.9.2", + "axios": "^1.7.9", + "dompurify": "^3.2.3", + "highlight.js": "^11.10.0", "lodash": "^4.17.21", - "luxon": "^3.4.3", - "mermaid": "^10.0.0", - "react-hook-form": "^7.48.2", - "react-toastify": "^9.1.3", - "ts-node": "^10.9.1", - "yaml": "^2.3.2" + "luxon": "^3.5.0", + "mermaid": "^11.4.1", + "react-hook-form": "^7.54.0", + "react-toastify": "^10.0.6", + "ts-node": "^10.9.2", + "yaml": "^2.6.1" }, "devDependencies": { - "@biomejs/biome": "1.4.1", - "@testing-library/dom": "^9.2.0", - "@testing-library/react": "^14.0.0", - "@testing-library/user-event": "14.4.3", - "@types/dompurify": "^3.0.4", - "@types/jest": "^29.5.0", - "@types/js-yaml": "^4.0.5", - "@types/lodash": "^4.14.202", - "@types/luxon": "^3.3.3", - "@types/node": "^20.10.0", - "@types/react-dom": "^18.2.7", + "@biomejs/biome": "1.9.4", + "@testing-library/dom": "^10.4.0", + "@testing-library/react": "^16.1.0", + "@testing-library/user-event": "14.5.2", + "@types/dompurify": "^3.2.0", + "@types/jest": "^29.5.14", + "@types/js-yaml": "^4.0.9", + "@types/lodash": "^4.17.13", + "@types/luxon": "^3.4.2", + "@types/node": "^22.10.2", + "@types/react-dom": "^19.0.2", "@types/react-router-dom": "^5.3.3", - "@types/styled-components": "^5.1.26", - "jest": "^29.5.0", - "jest-environment-jsdom": "^29.5.0", - "react-router-dom": ">=5.1.2", - "shx": " 0.3.4", - "ts-jest": "^29.1.0", - "ts-loader": "^9.3.1", - "typescript": "^5.1.6" + "@types/styled-components": "^5.1.34", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", + "react-router-dom": "^7.0.2", + "shx": "0.3.4", + "ts-jest": "^29.2.5", + "ts-loader": "^9.5.1", + "typescript": "^5.7.2" }, "peerDependencies": { - "@types/react": "^18.2.8", + "@types/react": "^18.2.20", "react": "^18.2.0", "react-dom": "^18.2.0", - "styled-components": ">=5.1.0" + "styled-components": "^6.1.13" }, - "files": [ - "blueprints", - "dist" - ], + "files": ["blueprints", "dist"], "types": "dist/index.d.ts", "scripts": { "prebuild": "shx rm -rf dist", diff --git a/packages/dm-core-plugins/src/blueprint-hierarchy/BlueprintHierarchyPlugin.tsx b/packages/dm-core-plugins/src/blueprint-hierarchy/BlueprintHierarchyPlugin.tsx index fe6519755..0fca8b512 100644 --- a/packages/dm-core-plugins/src/blueprint-hierarchy/BlueprintHierarchyPlugin.tsx +++ b/packages/dm-core-plugins/src/blueprint-hierarchy/BlueprintHierarchyPlugin.tsx @@ -1,15 +1,15 @@ import { useEffect, useState } from 'react' import { - DmssAPI, - IUIPlugin, + type DmssAPI, + type IUIPlugin, Loading, useApplication, useDocument, } from '@development-framework/dm-core' import MermaidWrapper from './MermaidWrapper' -import { Node, dfs, loader } from './loader' -import { TAttributeType } from './types' +import { type Node, dfs, loader } from './loader' +import type { TAttributeType } from './types' const classElement = (node: Node) => { const primitiveAttributeElements = node diff --git a/packages/dm-core-plugins/src/blueprint-hierarchy/loader.tsx b/packages/dm-core-plugins/src/blueprint-hierarchy/loader.tsx index d80ffd235..23be0ad1f 100644 --- a/packages/dm-core-plugins/src/blueprint-hierarchy/loader.tsx +++ b/packages/dm-core-plugins/src/blueprint-hierarchy/loader.tsx @@ -1,4 +1,4 @@ -import { IBlueprintType, TAttributeType } from './types' +import type { IBlueprintType, TAttributeType } from './types' export class Node { public attribute: TAttributeType diff --git a/packages/dm-core-plugins/src/blueprint/BlueprintAttribute.tsx b/packages/dm-core-plugins/src/blueprint/BlueprintAttribute.tsx index 8a0e74e8c..890311991 100644 --- a/packages/dm-core-plugins/src/blueprint/BlueprintAttribute.tsx +++ b/packages/dm-core-plugins/src/blueprint/BlueprintAttribute.tsx @@ -3,11 +3,11 @@ import { EPrimitiveTypes, INPUT_FIELD_WIDTH, Select, - TGenericObject, + type TGenericObject, truncatePathString, } from '@development-framework/dm-core' import { Input, Label, Radio, Switch, TextField } from '@equinor/eds-core-react' -import { ChangeEvent } from 'react' +import type { ChangeEvent } from 'react' import { Stack } from '../common' type TAttribute = { diff --git a/packages/dm-core-plugins/src/blueprint/BlueprintPlugin.tsx b/packages/dm-core-plugins/src/blueprint/BlueprintPlugin.tsx index 3732b08c6..cefda950c 100644 --- a/packages/dm-core-plugins/src/blueprint/BlueprintPlugin.tsx +++ b/packages/dm-core-plugins/src/blueprint/BlueprintPlugin.tsx @@ -1,14 +1,14 @@ import { INPUT_FIELD_WIDTH, - IUIPlugin, + type IUIPlugin, Loading, - TBlueprint, + type TBlueprint, useDocument, } from '@development-framework/dm-core' import { Button, Icon, TextField, Typography } from '@equinor/eds-core-react' import { save, undo } from '@equinor/eds-icons' import { isEqual } from 'lodash' -import { ChangeEvent, useEffect, useMemo, useState } from 'react' +import { type ChangeEvent, useEffect, useMemo, useState } from 'react' import styled from 'styled-components' import { Stack } from '../common' import { BlueprintAttributeList } from './BlueprintAttributeList' diff --git a/packages/dm-core-plugins/src/common/AddRowButton/AddRowButton.tsx b/packages/dm-core-plugins/src/common/AddRowButton/AddRowButton.tsx index d24c83b51..3f7dc61ab 100644 --- a/packages/dm-core-plugins/src/common/AddRowButton/AddRowButton.tsx +++ b/packages/dm-core-plugins/src/common/AddRowButton/AddRowButton.tsx @@ -1,7 +1,6 @@ import { Icon } from '@equinor/eds-core-react' import { add } from '@equinor/eds-icons' import { tokens } from '@equinor/eds-tokens' -import React from 'react' import styled from 'styled-components' const StyledButton = styled.button` diff --git a/packages/dm-core-plugins/src/common/CollapseExpandButton/CollapseExpandButton.tsx b/packages/dm-core-plugins/src/common/CollapseExpandButton/CollapseExpandButton.tsx index 05fdfad07..238701069 100644 --- a/packages/dm-core-plugins/src/common/CollapseExpandButton/CollapseExpandButton.tsx +++ b/packages/dm-core-plugins/src/common/CollapseExpandButton/CollapseExpandButton.tsx @@ -1,6 +1,6 @@ import { Button, - ButtonProps, + type ButtonProps, EdsProvider, Icon, Tooltip, @@ -8,7 +8,7 @@ import { import { chevron_right } from '@equinor/eds-icons' import styled from 'styled-components' -const StyledButton = styled(Button)<{ expanded: boolean }>` +const StyledButton = styled(Button)<{ $expanded: boolean }>` span { transition: transform ease-in-out 0.2s; transform: ${(props) => (props.expanded ? 'rotate(90deg)' : 'none')}; @@ -30,7 +30,7 @@ export function CollapseExpandButton(props: CollapseExpandButtonProps) { aria-expanded={isExpanded} aria-controls={props.controls} aria-label={isExpanded ? 'Collapse item' : 'Expand item'} - expanded={isExpanded} + $expanded={isExpanded} variant='ghost_icon' color={color} onClick={setIsExpanded} diff --git a/packages/dm-core-plugins/src/common/Datepicker/Calendar.tsx b/packages/dm-core-plugins/src/common/Datepicker/Calendar.tsx index 6091843c9..1df49e485 100644 --- a/packages/dm-core-plugins/src/common/Datepicker/Calendar.tsx +++ b/packages/dm-core-plugins/src/common/Datepicker/Calendar.tsx @@ -13,11 +13,11 @@ import { chevron_up, } from '@equinor/eds-icons' import { DateTime } from 'luxon' -import { ReactElement, useEffect, useState } from 'react' +import { type ReactElement, useEffect, useState } from 'react' import { Stack } from '../Stack/Stack' import { CALENDAR_MONTHS, - DateSelection, + type DateSelection, THIS_MONTH, THIS_YEAR, calendar, @@ -136,6 +136,7 @@ export const Calendar = (props: CalendarProps): ReactElement => { { const { diff --git a/packages/dm-core-plugins/src/common/Message/styles.ts b/packages/dm-core-plugins/src/common/Message/styles.ts index 738a70153..143e94574 100644 --- a/packages/dm-core-plugins/src/common/Message/styles.ts +++ b/packages/dm-core-plugins/src/common/Message/styles.ts @@ -1,6 +1,6 @@ import styled from 'styled-components' -import { MessageTypes } from './types' +import type { MessageTypes } from './types' export const StyledMessage = styled.div<{ type: MessageTypes }>` display: flex; diff --git a/packages/dm-core-plugins/src/common/Message/types.ts b/packages/dm-core-plugins/src/common/Message/types.ts index 792bc82c3..71eefd933 100644 --- a/packages/dm-core-plugins/src/common/Message/types.ts +++ b/packages/dm-core-plugins/src/common/Message/types.ts @@ -1,11 +1,10 @@ import { - IconData, + type IconData, check_circle_outlined, error_outlined, info_circle, warning_outlined, } from '@equinor/eds-icons' -import React from 'react' export type MessageTypes = 'success' | 'error' | 'info' | 'warning' diff --git a/packages/dm-core-plugins/src/common/SortableList/SortableContext.tsx b/packages/dm-core-plugins/src/common/SortableList/SortableContext.tsx index a897c042e..8b6a8cb92 100644 --- a/packages/dm-core-plugins/src/common/SortableList/SortableContext.tsx +++ b/packages/dm-core-plugins/src/common/SortableList/SortableContext.tsx @@ -1,6 +1,6 @@ import { DndContext, - DragEndEvent, + type DragEndEvent, KeyboardSensor, PointerSensor, closestCenter, @@ -9,7 +9,7 @@ import { } from '@dnd-kit/core' import { restrictToVerticalAxis } from '@dnd-kit/modifiers' import { arrayMove, sortableKeyboardCoordinates } from '@dnd-kit/sortable' -import { SortableContextProps } from './types' +import type { SortableContextProps } from './types' export const SortableContext = ({ items, diff --git a/packages/dm-core-plugins/src/common/SortableList/SortableItem/SortableItem.tsx b/packages/dm-core-plugins/src/common/SortableList/SortableItem/SortableItem.tsx index c969ccfab..eb0f85124 100644 --- a/packages/dm-core-plugins/src/common/SortableList/SortableItem/SortableItem.tsx +++ b/packages/dm-core-plugins/src/common/SortableList/SortableItem/SortableItem.tsx @@ -3,7 +3,7 @@ import { CSS } from '@dnd-kit/utilities' import { Button, Icon } from '@equinor/eds-core-react' import { drag_handle } from '@equinor/eds-icons' import React from 'react' -import { SortableItemProps } from './types' +import type { SortableItemProps } from './types' export const SortableItem = ({ children, @@ -25,6 +25,7 @@ export const SortableItem = ({ return React.Children.only( React.cloneElement(children as React.ReactElement, { + // @ts-expect-error setNodeRef: setNodeRef, style: draggableStyle, dragHandle: () => ( diff --git a/packages/dm-core-plugins/src/common/SortableList/SortableItem/types.ts b/packages/dm-core-plugins/src/common/SortableList/SortableItem/types.ts index 130d2aee0..391b2b681 100644 --- a/packages/dm-core-plugins/src/common/SortableList/SortableItem/types.ts +++ b/packages/dm-core-plugins/src/common/SortableList/SortableItem/types.ts @@ -1,4 +1,4 @@ -import { ReactNode } from 'react' +import type { ReactNode } from 'react' export type SortableItemProps = { children: ReactNode diff --git a/packages/dm-core-plugins/src/common/SortableList/SortableList.tsx b/packages/dm-core-plugins/src/common/SortableList/SortableList.tsx index 40b477056..88c74748c 100644 --- a/packages/dm-core-plugins/src/common/SortableList/SortableList.tsx +++ b/packages/dm-core-plugins/src/common/SortableList/SortableList.tsx @@ -1,6 +1,6 @@ import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable' -import { SortableListProps } from './types' +import type { SortableListProps } from './types' export const SortableList = ({ items, children }: SortableListProps) => { return ( diff --git a/packages/dm-core-plugins/src/common/SortableList/types.ts b/packages/dm-core-plugins/src/common/SortableList/types.ts index 9f661b8c4..236bd3457 100644 --- a/packages/dm-core-plugins/src/common/SortableList/types.ts +++ b/packages/dm-core-plugins/src/common/SortableList/types.ts @@ -1,4 +1,4 @@ -import { ReactNode } from 'react' +import type { ReactNode } from 'react' export type SortableListProps = { items: any[] diff --git a/packages/dm-core-plugins/src/common/Stack/Stack.tsx b/packages/dm-core-plugins/src/common/Stack/Stack.tsx index 3338458ce..91de9c13c 100644 --- a/packages/dm-core-plugins/src/common/Stack/Stack.tsx +++ b/packages/dm-core-plugins/src/common/Stack/Stack.tsx @@ -1,13 +1,7 @@ -import { forwardRef } from 'react' import { StyledStack } from './styles' -import { StackProps, defaultProps } from './types' +import { type StackProps, defaultProps } from './types' -export const Stack = forwardRef((props: StackProps, ref) => { +export const Stack = (props: StackProps) => { const mergedProps = { ...defaultProps, ...props } - return ( - } - {...mergedProps} - /> - ) -}) + return +} diff --git a/packages/dm-core-plugins/src/common/Stack/styles.ts b/packages/dm-core-plugins/src/common/Stack/styles.ts index a5a8e4bf1..2f2356f08 100644 --- a/packages/dm-core-plugins/src/common/Stack/styles.ts +++ b/packages/dm-core-plugins/src/common/Stack/styles.ts @@ -1,8 +1,18 @@ import styled, { css } from 'styled-components' -import { StackProps } from './types' +import type { StackProps } from './types' -export const StyledStack = styled.div` +const props_to_pass: string[] = [ + 'children', + 'style', + 'date-testid', + 'id', + 'className', +] + +export const StyledStack = styled('div').withConfig({ + shouldForwardProp: (propName) => props_to_pass.includes(propName), +})` display: ${(props) => (props.inline ? 'inline-flex' : 'flex')}; flex-direction: ${(props) => props.direction}; flex-grow: ${(props) => props.grow}; diff --git a/packages/dm-core-plugins/src/common/Stack/types.ts b/packages/dm-core-plugins/src/common/Stack/types.ts index 931386424..fc2e1bc43 100644 --- a/packages/dm-core-plugins/src/common/Stack/types.ts +++ b/packages/dm-core-plugins/src/common/Stack/types.ts @@ -1,4 +1,4 @@ -import React from 'react' +import type React from 'react' export type AlignDefaultTypes = | 'center' @@ -51,7 +51,7 @@ export interface StackProps extends React.ComponentPropsWithRef<'div'> { minHeight?: number scrollY?: boolean scrollX?: boolean - as?: keyof JSX.IntrinsicElements + as?: keyof React.JSX.IntrinsicElements } export const defaultProps: StackProps = { diff --git a/packages/dm-core-plugins/src/common/TooltipButton.tsx b/packages/dm-core-plugins/src/common/TooltipButton.tsx index ec044dc83..a6f59465c 100644 --- a/packages/dm-core-plugins/src/common/TooltipButton.tsx +++ b/packages/dm-core-plugins/src/common/TooltipButton.tsx @@ -1,6 +1,5 @@ import { Button, EdsProvider, Icon, Tooltip } from '@equinor/eds-core-react' -import { IconData } from '@equinor/eds-icons' -import React from 'react' +import type { IconData } from '@equinor/eds-icons' type Prefix = { [K in keyof T as `${P}-${string & K}`]: T[K] diff --git a/packages/dm-core-plugins/src/data-grid/DataCell/DataCell.tsx b/packages/dm-core-plugins/src/data-grid/DataCell/DataCell.tsx index 398da490b..e9807f056 100644 --- a/packages/dm-core-plugins/src/data-grid/DataCell/DataCell.tsx +++ b/packages/dm-core-plugins/src/data-grid/DataCell/DataCell.tsx @@ -1,7 +1,7 @@ import { Checkbox } from '@equinor/eds-core-react' -import { ChangeEvent } from 'react' +import type { ChangeEvent } from 'react' import * as Styled from '../styles' -import { DataGridConfig } from '../types' +import type { DataGridConfig } from '../types' type DataCellProps = { attributeType: string @@ -21,7 +21,11 @@ export function DataCell(props: DataCellProps) { function parseValue(event: ChangeEvent) { const { value, checked } = event.target if (attributeType === 'number') { - return value === '' ? undefined : value === '-' ? '-' : parseFloat(value) + return value === '' + ? undefined + : value === '-' + ? '-' + : Number.parseFloat(value) } if (attributeType === 'boolean') { return checked diff --git a/packages/dm-core-plugins/src/data-grid/DataGrid.tsx b/packages/dm-core-plugins/src/data-grid/DataGrid.tsx index 779262d32..6103b6dce 100644 --- a/packages/dm-core-plugins/src/data-grid/DataGrid.tsx +++ b/packages/dm-core-plugins/src/data-grid/DataGrid.tsx @@ -7,9 +7,9 @@ import { DataGridPagination } from './DataGridPagination/DataGridPagination' import { HeaderCell } from './HeaderCell/HeaderCell' import * as Styled from './styles' import { - DataGridConfig, - DataGridProps, - TFunctionalityChecks, + type DataGridConfig, + type DataGridProps, + type TFunctionalityChecks, defaultConfig, } from './types' import * as utils from './utils' @@ -68,7 +68,7 @@ export function DataGrid(props: DataGridProps) { ? data.length > 0 ? data[0].length : 0 - : parseInt(functionality.columnDimensions, 10) + : Number.parseInt(functionality.columnDimensions, 10) : ['1'] updateColumnLabels(columnsLength) updateRowLabels(data?.length) diff --git a/packages/dm-core-plugins/src/data-grid/DataGridActions/DataGridActions.tsx b/packages/dm-core-plugins/src/data-grid/DataGridActions/DataGridActions.tsx index 3e1a29dd8..9ac2f8aec 100644 --- a/packages/dm-core-plugins/src/data-grid/DataGridActions/DataGridActions.tsx +++ b/packages/dm-core-plugins/src/data-grid/DataGridActions/DataGridActions.tsx @@ -23,7 +23,7 @@ import { useState } from 'react' import { Stack } from '../../common' import { createSyntheticFileDownload } from '../../utils' import * as Styled from '../styles' -import { DataGridConfig, TFunctionalityChecks } from '../types' +import type { DataGridConfig, TFunctionalityChecks } from '../types' import { DataGridImportDialog } from './DataGridImportDialog/DataGridImportDialog' type DataGridActionsProps = { diff --git a/packages/dm-core-plugins/src/data-grid/DataGridActions/DataGridImportDialog/DataGridImportDialog.tsx b/packages/dm-core-plugins/src/data-grid/DataGridActions/DataGridImportDialog/DataGridImportDialog.tsx index dd4e3a09d..721c54802 100644 --- a/packages/dm-core-plugins/src/data-grid/DataGridActions/DataGridImportDialog/DataGridImportDialog.tsx +++ b/packages/dm-core-plugins/src/data-grid/DataGridActions/DataGridImportDialog/DataGridImportDialog.tsx @@ -7,7 +7,7 @@ import { } from '@equinor/eds-core-react' import { useState } from 'react' import { Message, Skeleton, Stack } from '../../../common' -import { DataGridImportDialogProps } from './types' +import type { DataGridImportDialogProps } from './types' import { checkAndParseToAttributeType, checkDimensions } from './utils' export function DataGridImportDialog(props: DataGridImportDialogProps) { diff --git a/packages/dm-core-plugins/src/data-grid/DataGridActions/DataGridImportDialog/utils.ts b/packages/dm-core-plugins/src/data-grid/DataGridActions/DataGridImportDialog/utils.ts index cf2615d08..059b0b9b7 100644 --- a/packages/dm-core-plugins/src/data-grid/DataGridActions/DataGridImportDialog/utils.ts +++ b/packages/dm-core-plugins/src/data-grid/DataGridActions/DataGridImportDialog/utils.ts @@ -8,7 +8,7 @@ export async function checkAndParseToAttributeType( function parseValue(value: any, rowIndex: number, colIndex: number) { if (attributeType === 'number') { - const parsedValue = parseFloat(value.replace(',', '.')) + const parsedValue = Number.parseFloat(value.replace(',', '.')) if (Number.isNaN(parsedValue)) { errors.push( `Data in cell ${colIndex + 1}, row ${ @@ -62,11 +62,11 @@ export async function checkDimensions( const isMultiDimensional: boolean = dimensions?.includes(',') || false if (definedColumns === '*' && definedRows === '*') return [] const definedColumnsAmount = - definedColumns !== '*' ? parseInt(definedColumns, 10) : '*' + definedColumns !== '*' ? Number.parseInt(definedColumns, 10) : '*' const definedRowsAmount = !isMultiDimensional ? definedColumnsAmount : definedRows !== '*' - ? parseInt(definedRows, 10) + ? Number.parseInt(definedRows, 10) : '*' const dataColumnsLength = data[0].length const dataRowsLength = data.length diff --git a/packages/dm-core-plugins/src/data-grid/DataGridPagination/DataGridPagination.tsx b/packages/dm-core-plugins/src/data-grid/DataGridPagination/DataGridPagination.tsx index 1d376e77c..45e200a71 100644 --- a/packages/dm-core-plugins/src/data-grid/DataGridPagination/DataGridPagination.tsx +++ b/packages/dm-core-plugins/src/data-grid/DataGridPagination/DataGridPagination.tsx @@ -1,6 +1,5 @@ import { Icon, Typography } from '@equinor/eds-core-react' import { chevron_left, chevron_right } from '@equinor/eds-icons' -import React from 'react' import { Stack } from '../../common' import * as Styled from '../styles' diff --git a/packages/dm-core-plugins/src/data-grid/DataGridPlugin.tsx b/packages/dm-core-plugins/src/data-grid/DataGridPlugin.tsx index 6897b360e..28b5df766 100644 --- a/packages/dm-core-plugins/src/data-grid/DataGridPlugin.tsx +++ b/packages/dm-core-plugins/src/data-grid/DataGridPlugin.tsx @@ -1,7 +1,7 @@ import { - IUIPlugin, - TAttribute, - TGenericObject, + type IUIPlugin, + type TAttribute, + type TGenericObject, useApplication, useBlueprint, useDocument, @@ -11,7 +11,7 @@ import { undo } from '@equinor/eds-icons' import { useEffect, useState } from 'react' import { Stack } from '../common' import { DataGrid } from './DataGrid' -import { DataGridConfig, defaultConfig } from './types' +import { type DataGridConfig, defaultConfig } from './types' import { getFunctionalityVariables, reverseData } from './utils' export function DataGridPlugin(props: IUIPlugin) { @@ -40,7 +40,7 @@ export function DataGridPlugin(props: IUIPlugin) { ? data.length > 0 ? data[0].length : 0 - : parseInt(functionality.columnDimensions, 10) + : Number.parseInt(functionality.columnDimensions, 10) : 1 return columnLength } diff --git a/packages/dm-core-plugins/src/data-grid/HeaderCell/HeaderCell.tsx b/packages/dm-core-plugins/src/data-grid/HeaderCell/HeaderCell.tsx index 55cb2f462..2846bfec5 100644 --- a/packages/dm-core-plugins/src/data-grid/HeaderCell/HeaderCell.tsx +++ b/packages/dm-core-plugins/src/data-grid/HeaderCell/HeaderCell.tsx @@ -1,6 +1,7 @@ -import { Icon, Menu, Typography } from '@equinor/eds-core-react' +import { Icon, Menu, Tooltip } from '@equinor/eds-core-react' import { add as addIcon, delete_to_trash } from '@equinor/eds-icons' -import React, { useState } from 'react' +import { useState } from 'react' +import { ConditionalWrapper } from '../../utils' import * as Styled from '../styles' type HeaderCellProps = { @@ -57,34 +58,39 @@ export function HeaderCell(props: HeaderCellProps) { selected={index === selected} tabIndex={0} > - {label} - - {!props.editable ? ( - - {type === 'column' ? 'Columns' : 'Rows'} are pre-defined and cannot - be deleted or added. - - ) : ( - <> - props.delete(index)}> - Delete {type} - - add(index)}> - Add 1 {type}{' '} - {type === 'column' ? 'left' : 'above'} - - add(index + 1)}> - Add 1 {type}{' '} - {type === 'column' ? 'right' : 'below'} - - + ( + + {child} + )} - + > + {label} + + {props.editable && ( + + props.delete(index)}> + Delete {type} + + add(index)}> + Add 1 {type}{' '} + {type === 'column' ? 'left' : 'above'} + + add(index + 1)}> + Add 1 {type}{' '} + {type === 'column' ? 'right' : 'below'} + + + )} ) } diff --git a/packages/dm-core-plugins/src/data-grid/utils.ts b/packages/dm-core-plugins/src/data-grid/utils.ts index c45ff9f90..0cebefad7 100644 --- a/packages/dm-core-plugins/src/data-grid/utils.ts +++ b/packages/dm-core-plugins/src/data-grid/utils.ts @@ -1,4 +1,8 @@ -import { DataGridConfig, PredefinedLabels, TFunctionalityChecks } from './types' +import type { + DataGridConfig, + PredefinedLabels, + TFunctionalityChecks, +} from './types' const predefinedLabels: PredefinedLabels[] = ['...ABC', '...ZYX', '...123'] diff --git a/packages/dm-core-plugins/src/explorer/ExplorerPlugin.tsx b/packages/dm-core-plugins/src/explorer/ExplorerPlugin.tsx index f767635e8..0c263b097 100644 --- a/packages/dm-core-plugins/src/explorer/ExplorerPlugin.tsx +++ b/packages/dm-core-plugins/src/explorer/ExplorerPlugin.tsx @@ -1,8 +1,8 @@ import { EBlueprint, EntityView, - TNodeWrapperProps, - TreeNode, + type TNodeWrapperProps, + type TreeNode, TreeView, useApplication, } from '@development-framework/dm-core' diff --git a/packages/dm-core-plugins/src/explorer/components/Sidebar.tsx b/packages/dm-core-plugins/src/explorer/components/Sidebar.tsx index 1844cfbce..874bdf999 100644 --- a/packages/dm-core-plugins/src/explorer/components/Sidebar.tsx +++ b/packages/dm-core-plugins/src/explorer/components/Sidebar.tsx @@ -1,5 +1,5 @@ import { useLocalStorage } from '@development-framework/dm-core' -import { ReactNode, useEffect, useRef } from 'react' +import { type ReactNode, useEffect, useRef } from 'react' const [minWidth, maxWidth, defaultWidth] = [200, 500, 250] diff --git a/packages/dm-core-plugins/src/explorer/components/context-menu/NodeRightClickMenu.tsx b/packages/dm-core-plugins/src/explorer/components/context-menu/NodeRightClickMenu.tsx index be98b62a4..544877dd6 100644 --- a/packages/dm-core-plugins/src/explorer/components/context-menu/NodeRightClickMenu.tsx +++ b/packages/dm-core-plugins/src/explorer/components/context-menu/NodeRightClickMenu.tsx @@ -1,6 +1,6 @@ import { CopyLinkDialog, - TNodeWrapperProps, + type TNodeWrapperProps, } from '@development-framework/dm-core' import { Menu } from '@equinor/eds-core-react' import { useState } from 'react' diff --git a/packages/dm-core-plugins/src/explorer/components/context-menu/getMenuItems.tsx b/packages/dm-core-plugins/src/explorer/components/context-menu/getMenuItems.tsx index 87a557026..5f8fc7e2c 100644 --- a/packages/dm-core-plugins/src/explorer/components/context-menu/getMenuItems.tsx +++ b/packages/dm-core-plugins/src/explorer/components/context-menu/getMenuItems.tsx @@ -1,6 +1,5 @@ -import { EBlueprint, TreeNode } from '@development-framework/dm-core' +import { EBlueprint, type TreeNode } from '@development-framework/dm-core' import { Menu } from '@equinor/eds-core-react' -import React from 'react' import { toast } from 'react-toastify' import { downloadNode } from '../../downloadNode' import { EDialog } from '../../types' diff --git a/packages/dm-core-plugins/src/explorer/components/dialogs/AppendEntityDialog.tsx b/packages/dm-core-plugins/src/explorer/components/dialogs/AppendEntityDialog.tsx index f8acb9f2f..f7b51192f 100644 --- a/packages/dm-core-plugins/src/explorer/components/dialogs/AppendEntityDialog.tsx +++ b/packages/dm-core-plugins/src/explorer/components/dialogs/AppendEntityDialog.tsx @@ -1,9 +1,13 @@ -import { Dialog, ErrorResponse, TreeNode } from '@development-framework/dm-core' +import { + Dialog, + type ErrorResponse, + type TreeNode, +} from '@development-framework/dm-core' import { Button, Progress } from '@equinor/eds-core-react' -import { AxiosError } from 'axios' +import type { AxiosError } from 'axios' import { useState } from 'react' import { toast } from 'react-toastify' -import { EDialog } from '../../types' +import type { EDialog } from '../../types' import { STANDARD_DIALOG_WIDTH } from '../context-menu/NodeRightClickMenu' type TProps = { diff --git a/packages/dm-core-plugins/src/explorer/components/dialogs/DeleteDialog.tsx b/packages/dm-core-plugins/src/explorer/components/dialogs/DeleteDialog.tsx index 8c2753517..3fc1986fb 100644 --- a/packages/dm-core-plugins/src/explorer/components/dialogs/DeleteDialog.tsx +++ b/packages/dm-core-plugins/src/explorer/components/dialogs/DeleteDialog.tsx @@ -1,14 +1,14 @@ import { Dialog, - ErrorResponse, - TreeNode, + type ErrorResponse, + type TreeNode, useApplication, } from '@development-framework/dm-core' import { Button, Progress } from '@equinor/eds-core-react' -import { AxiosError } from 'axios' +import type { AxiosError } from 'axios' import { useState } from 'react' import { toast } from 'react-toastify' -import { EDialog } from '../../types' +import type { EDialog } from '../../types' import { STANDARD_DIALOG_HEIGHT, STANDARD_DIALOG_WIDTH, diff --git a/packages/dm-core-plugins/src/explorer/components/dialogs/EditACLDialog.tsx b/packages/dm-core-plugins/src/explorer/components/dialogs/EditACLDialog.tsx index 4ebf167ee..07a4d90cd 100644 --- a/packages/dm-core-plugins/src/explorer/components/dialogs/EditACLDialog.tsx +++ b/packages/dm-core-plugins/src/explorer/components/dialogs/EditACLDialog.tsx @@ -1,9 +1,9 @@ import { AccessControlListComponent, Dialog, - TreeNode, + type TreeNode, } from '@development-framework/dm-core' -import { EDialog } from '../../types' +import type { EDialog } from '../../types' import { STANDARD_DIALOG_WIDTH } from '../context-menu/NodeRightClickMenu' type TProps = { diff --git a/packages/dm-core-plugins/src/explorer/components/dialogs/NewBlueprintDialog.tsx b/packages/dm-core-plugins/src/explorer/components/dialogs/NewBlueprintDialog.tsx index de70f88ab..a6eb6fc17 100644 --- a/packages/dm-core-plugins/src/explorer/components/dialogs/NewBlueprintDialog.tsx +++ b/packages/dm-core-plugins/src/explorer/components/dialogs/NewBlueprintDialog.tsx @@ -1,15 +1,15 @@ import { Dialog, EBlueprint, - ErrorResponse, + type ErrorResponse, INPUT_FIELD_WIDTH, - TreeNode, + type TreeNode, } from '@development-framework/dm-core' import { Button, Progress, TextField } from '@equinor/eds-core-react' -import { AxiosError } from 'axios' -import React, { useState } from 'react' +import type { AxiosError } from 'axios' +import { useState } from 'react' import { toast } from 'react-toastify' -import { EDialog } from '../../types' +import type { EDialog } from '../../types' import { STANDARD_DIALOG_HEIGHT, STANDARD_DIALOG_WIDTH, diff --git a/packages/dm-core-plugins/src/explorer/components/dialogs/NewEntityDialog.tsx b/packages/dm-core-plugins/src/explorer/components/dialogs/NewEntityDialog.tsx index 0189f2b36..271b7d2f5 100644 --- a/packages/dm-core-plugins/src/explorer/components/dialogs/NewEntityDialog.tsx +++ b/packages/dm-core-plugins/src/explorer/components/dialogs/NewEntityDialog.tsx @@ -1,17 +1,17 @@ import { BlueprintPicker, Dialog, - ErrorResponse, - TAttribute, - TBlueprint, - TreeNode, + type ErrorResponse, + type TAttribute, + type TBlueprint, + type TreeNode, useApplication, } from '@development-framework/dm-core' import { Button, Progress, TextField } from '@equinor/eds-core-react' -import { AxiosError } from 'axios' +import type { AxiosError } from 'axios' import { useEffect, useState } from 'react' import { toast } from 'react-toastify' -import { EDialog } from '../../types' +import type { EDialog } from '../../types' import { STANDARD_DIALOG_HEIGHT, STANDARD_DIALOG_WIDTH, diff --git a/packages/dm-core-plugins/src/explorer/components/dialogs/NewFolderDialog.tsx b/packages/dm-core-plugins/src/explorer/components/dialogs/NewFolderDialog.tsx index 51bda68fe..b8d068a53 100644 --- a/packages/dm-core-plugins/src/explorer/components/dialogs/NewFolderDialog.tsx +++ b/packages/dm-core-plugins/src/explorer/components/dialogs/NewFolderDialog.tsx @@ -1,15 +1,15 @@ import { Dialog, - ErrorResponse, + type ErrorResponse, INPUT_FIELD_WIDTH, - TreeNode, + type TreeNode, useApplication, } from '@development-framework/dm-core' import { Button, Progress, TextField } from '@equinor/eds-core-react' -import { AxiosError } from 'axios' -import React, { useState } from 'react' +import type { AxiosError } from 'axios' +import { useState } from 'react' import { toast } from 'react-toastify' -import { EDialog } from '../../types' +import type { EDialog } from '../../types' import { STANDARD_DIALOG_HEIGHT, STANDARD_DIALOG_WIDTH, diff --git a/packages/dm-core-plugins/src/explorer/downloadNode.ts b/packages/dm-core-plugins/src/explorer/downloadNode.ts index 639726a09..808fad328 100644 --- a/packages/dm-core-plugins/src/explorer/downloadNode.ts +++ b/packages/dm-core-plugins/src/explorer/downloadNode.ts @@ -1,5 +1,5 @@ -import { TreeNode } from '@development-framework/dm-core' -import { AxiosResponse } from 'axios' +import type { TreeNode } from '@development-framework/dm-core' +import type { AxiosResponse } from 'axios' import { createSyntheticFileDownload } from '../utils' export function downloadNode(node: TreeNode) { diff --git a/packages/dm-core-plugins/src/file/DownloadFileButton.tsx b/packages/dm-core-plugins/src/file/DownloadFileButton.tsx index 67d673fdf..8f78b7016 100644 --- a/packages/dm-core-plugins/src/file/DownloadFileButton.tsx +++ b/packages/dm-core-plugins/src/file/DownloadFileButton.tsx @@ -1,11 +1,11 @@ import { - ErrorResponse, + type ErrorResponse, Loading, - TFileEntity, + type TFileEntity, useApplication, } from '@development-framework/dm-core' import { Button } from '@equinor/eds-core-react' -import { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios' +import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios' import { useEffect, useState } from 'react' import { ErrorGroup } from './ErrorGroup' diff --git a/packages/dm-core-plugins/src/file/FilePlugin.tsx b/packages/dm-core-plugins/src/file/FilePlugin.tsx index 7ad1004e4..d31293622 100644 --- a/packages/dm-core-plugins/src/file/FilePlugin.tsx +++ b/packages/dm-core-plugins/src/file/FilePlugin.tsx @@ -1,9 +1,9 @@ import { EBlueprint, - IUIPlugin, + type IUIPlugin, Loading, - TFileEntity, - TStorageReference, + type TFileEntity, + type TStorageReference, splitAddress, useDocument, } from '@development-framework/dm-core' diff --git a/packages/dm-core-plugins/src/file/UploadFileButton.tsx b/packages/dm-core-plugins/src/file/UploadFileButton.tsx index 0bd13a510..685aabeec 100644 --- a/packages/dm-core-plugins/src/file/UploadFileButton.tsx +++ b/packages/dm-core-plugins/src/file/UploadFileButton.tsx @@ -1,10 +1,10 @@ import { - TStorageReference, + type TStorageReference, useApplication, } from '@development-framework/dm-core' import { Button, Progress } from '@equinor/eds-core-react' -import { AxiosError } from 'axios' -import { ChangeEvent, useEffect, useRef, useState } from 'react' +import type { AxiosError } from 'axios' +import { type ChangeEvent, useEffect, useRef, useState } from 'react' import { ErrorGroup } from './ErrorGroup' export interface UploadButtonProps { diff --git a/packages/dm-core-plugins/src/form/FormPlugin.tsx b/packages/dm-core-plugins/src/form/FormPlugin.tsx index f40291e32..d5590b22c 100644 --- a/packages/dm-core-plugins/src/form/FormPlugin.tsx +++ b/packages/dm-core-plugins/src/form/FormPlugin.tsx @@ -1,7 +1,7 @@ import { - IUIPlugin, + type IUIPlugin, Loading, - TGenericObject, + type TGenericObject, useDocument, } from '@development-framework/dm-core' import { Form } from './components/Form' @@ -37,7 +37,7 @@ export const FormPlugin = (props: IUIPlugin) => { formData={document} onSubmit={handleOnSubmit} onChange={props?.onChange && handleOnChange} - showSubmitButton={!props?.onChange ?? true} + showSubmitButton={!props?.onChange} /> ) } diff --git a/packages/dm-core-plugins/src/form/components/AddObject.tsx b/packages/dm-core-plugins/src/form/components/AddObject.tsx index 8099b23be..bb2b3b467 100644 --- a/packages/dm-core-plugins/src/form/components/AddObject.tsx +++ b/packages/dm-core-plugins/src/form/components/AddObject.tsx @@ -1,5 +1,8 @@ -import { ErrorResponse, useApplication } from '@development-framework/dm-core' -import { AxiosError, AxiosResponse } from 'axios' +import { + type ErrorResponse, + useApplication, +} from '@development-framework/dm-core' +import type { AxiosError, AxiosResponse } from 'axios' import { useFormContext } from 'react-hook-form' import { useRegistryContext } from '../context/RegistryContext' import GhostTextButton from './GhostTextButton' diff --git a/packages/dm-core-plugins/src/form/components/AddStorageUncontained.tsx b/packages/dm-core-plugins/src/form/components/AddStorageUncontained.tsx index dab0f96a3..e57393ea5 100644 --- a/packages/dm-core-plugins/src/form/components/AddStorageUncontained.tsx +++ b/packages/dm-core-plugins/src/form/components/AddStorageUncontained.tsx @@ -1,5 +1,5 @@ import { splitAddress, useApplication } from '@development-framework/dm-core' -import { AxiosResponse } from 'axios' +import type { AxiosResponse } from 'axios' import { useFormContext } from 'react-hook-form' import { useRegistryContext } from '../context/RegistryContext' import GhostTextButton from './GhostTextButton' diff --git a/packages/dm-core-plugins/src/form/components/AttributeList.tsx b/packages/dm-core-plugins/src/form/components/AttributeList.tsx index 31ced9b93..89662d5e7 100644 --- a/packages/dm-core-plugins/src/form/components/AttributeList.tsx +++ b/packages/dm-core-plugins/src/form/components/AttributeList.tsx @@ -1,4 +1,4 @@ -import { +import type { TAttribute, TBlueprint, TStorageRecipe, diff --git a/packages/dm-core-plugins/src/form/components/DynamicTable.tsx b/packages/dm-core-plugins/src/form/components/DynamicTable.tsx index 2869101f1..4cc9306f5 100644 --- a/packages/dm-core-plugins/src/form/components/DynamicTable.tsx +++ b/packages/dm-core-plugins/src/form/components/DynamicTable.tsx @@ -1,5 +1,5 @@ import { Table } from '@equinor/eds-core-react' -import React, { MouseEventHandler } from 'react' +import type { MouseEventHandler } from 'react' type TColumn = { name: string; accessor: string } diff --git a/packages/dm-core-plugins/src/form/components/Form.tsx b/packages/dm-core-plugins/src/form/components/Form.tsx index b23627357..efb7ede6e 100644 --- a/packages/dm-core-plugins/src/form/components/Form.tsx +++ b/packages/dm-core-plugins/src/form/components/Form.tsx @@ -3,9 +3,9 @@ import { useEffect, useState } from 'react' import { EBlueprint, Loading, - TAttribute, - TGenericObject, - TUiRecipe, + type TAttribute, + type TGenericObject, + type TUiRecipe, findRecipe, useApplication, useBlueprint, @@ -18,7 +18,7 @@ import styled from 'styled-components' import { Stack } from '../../common' import { ConditionalWrapper } from '../../utils' import { RegistryProvider } from '../context/RegistryContext' -import { TFormConfig, TFormProps, TUiAttributeObject } from '../types' +import type { TFormConfig, TFormProps, TUiAttributeObject } from '../types' import { getCanOpenOrExpand, isPrimitiveType } from '../utils' import { AttributeList } from './AttributeList' @@ -230,7 +230,6 @@ export const Form = (props: TFormProps) => { {config.closeable && ( diff --git a/packages/dm-core-plugins/src/view_selector/TabsContent.tsx b/packages/dm-core-plugins/src/view_selector/TabsContent.tsx index 308ff174c..554d69f79 100644 --- a/packages/dm-core-plugins/src/view_selector/TabsContent.tsx +++ b/packages/dm-core-plugins/src/view_selector/TabsContent.tsx @@ -1,11 +1,10 @@ import { - TGenericObject, - TOnOpen, + type TGenericObject, + type TOnOpen, ViewCreator, } from '@development-framework/dm-core' -import * as React from 'react' import { LazyLoad, Stack } from '../common' -import { TItemData } from './types' +import type { TItemData } from './types' export const TabsContent = (props: { type: string diff --git a/packages/dm-core-plugins/src/view_selector/TabsPlugin.tsx b/packages/dm-core-plugins/src/view_selector/TabsPlugin.tsx index e815a48d9..29a7a967d 100644 --- a/packages/dm-core-plugins/src/view_selector/TabsPlugin.tsx +++ b/packages/dm-core-plugins/src/view_selector/TabsPlugin.tsx @@ -1,9 +1,8 @@ -import { IUIPlugin } from '@development-framework/dm-core' -import * as React from 'react' +import type { IUIPlugin } from '@development-framework/dm-core' import { Stack } from '../common' import { Tabs } from './Tabs' import { TabsContent } from './TabsContent' -import { TViewSelectorConfig } from './types' +import type { TViewSelectorConfig } from './types' import { useViewSelector } from './useViewSelector' export const TabsPlugin = ( diff --git a/packages/dm-core-plugins/src/view_selector/styles.ts b/packages/dm-core-plugins/src/view_selector/styles.ts index ad069011e..eb6300aec 100644 --- a/packages/dm-core-plugins/src/view_selector/styles.ts +++ b/packages/dm-core-plugins/src/view_selector/styles.ts @@ -1,6 +1,6 @@ import styled, { css } from 'styled-components' -export const CustomToggle = styled.div<{ expanded: boolean }>` +export const CustomToggle = styled.div<{ $expanded: boolean }>` width: 72px; display: grid; place-items: center; @@ -9,8 +9,8 @@ export const CustomToggle = styled.div<{ expanded: boolean }>` transition: ease-in-out all 0.2s; } - ${({ expanded }) => - expanded && + ${({ $expanded }) => + $expanded && css` svg { transform: rotate(180deg); diff --git a/packages/dm-core-plugins/src/view_selector/types.tsx b/packages/dm-core-plugins/src/view_selector/types.tsx index eb71f3719..4af9531f9 100644 --- a/packages/dm-core-plugins/src/view_selector/types.tsx +++ b/packages/dm-core-plugins/src/view_selector/types.tsx @@ -1,4 +1,4 @@ -import { +import type { TInlineRecipeViewConfig, TReferenceViewConfig, TViewConfig, diff --git a/packages/dm-core-plugins/src/view_selector/useViewSelector.tsx b/packages/dm-core-plugins/src/view_selector/useViewSelector.tsx index ec92dffbe..9ad152f0b 100644 --- a/packages/dm-core-plugins/src/view_selector/useViewSelector.tsx +++ b/packages/dm-core-plugins/src/view_selector/useViewSelector.tsx @@ -1,15 +1,14 @@ import { - ErrorResponse, - TGenericObject, - TInlineRecipeViewConfig, - TOnOpen, - TReferenceViewConfig, - TViewConfig, + type ErrorResponse, + type TGenericObject, + type TInlineRecipeViewConfig, + type TOnOpen, + type TReferenceViewConfig, + type TViewConfig, useDocument, } from '@development-framework/dm-core' -import * as React from 'react' import { useEffect, useState } from 'react' -import { TItemData, TViewSelectorConfig, TViewSelectorItem } from './types' +import type { TItemData, TViewSelectorConfig, TViewSelectorItem } from './types' interface IUseViewSelector { addView: TOnOpen diff --git a/packages/dm-core-plugins/src/yaml/YamlPlugin.tsx b/packages/dm-core-plugins/src/yaml/YamlPlugin.tsx index d3de159dc..817117856 100644 --- a/packages/dm-core-plugins/src/yaml/YamlPlugin.tsx +++ b/packages/dm-core-plugins/src/yaml/YamlPlugin.tsx @@ -1,19 +1,19 @@ import { ErrorGroup, Loading, - TGenericObject, + type TGenericObject, useDocument, } from '@development-framework/dm-core' import { Icon, Popover, TextField, Tooltip } from '@equinor/eds-core-react' import { close, copy, edit, filter_alt, save } from '@equinor/eds-icons' import DOMPurify from 'dompurify' import hljs from 'highlight.js' -import { ChangeEvent, useMemo, useRef, useState } from 'react' +import { type ChangeEvent, useMemo, useRef, useState } from 'react' import { toast } from 'react-toastify' import YAML from 'yaml' import { Stack } from '../common' import { ActionButton, ActionsWrapper, CodeContainer } from './styles' -import { YamlPluginProps, defaultConfig } from './types' +import { type YamlPluginProps, defaultConfig } from './types' export const YamlPlugin = (props: YamlPluginProps) => { const { idReference, config: userConfig } = props @@ -104,7 +104,7 @@ export const YamlPlugin = (props: YamlPluginProps) => { {isEditMode ? ( - + @@ -126,7 +126,7 @@ export const YamlPlugin = (props: YamlPluginProps) => { aria-controls='depth-popover' aria-expanded={isDepthPopoverOpen} aria-haspopup - bg='yellow' + $bg='yellow' id='depth-popover-anchor' onClick={() => setIsDepthPopoverOpen(!isDepthPopoverOpen)} ref={depthPopoverTrigger} @@ -155,7 +155,7 @@ export const YamlPlugin = (props: YamlPluginProps) => { {config.editable && ( - setIsEditMode(true)}> + setIsEditMode(true)}> diff --git a/packages/dm-core-plugins/src/yaml/styles.ts b/packages/dm-core-plugins/src/yaml/styles.ts index b365bdc64..6228df236 100644 --- a/packages/dm-core-plugins/src/yaml/styles.ts +++ b/packages/dm-core-plugins/src/yaml/styles.ts @@ -10,7 +10,7 @@ export const ActionsWrapper = styled.div` right: 0; ` -export const ActionButton = styled.button<{ bg?: 'green' | 'yellow' }>` +export const ActionButton = styled.button<{ $bg?: 'green' | 'yellow' }>` position: relative; width: 3rem; height: 3rem; @@ -25,14 +25,14 @@ export const ActionButton = styled.button<{ bg?: 'green' | 'yellow' }>` justify-content: center; align-items: center; cursor: pointer; - ${({ bg }) => - bg === 'green' && + ${({ $bg }) => + $bg === 'green' && css` background: rgba(193, 231, 193, 1); color: rgba(19, 38, 52, 1); `} - ${({ bg }) => - bg === 'yellow' && + ${({ $bg }) => + $bg === 'yellow' && css` background: rgba(255, 218, 168, 1); color: rgba(19, 38, 52, 1); diff --git a/packages/dm-core-plugins/src/yaml/types.ts b/packages/dm-core-plugins/src/yaml/types.ts index a22f8ccd6..bbd2f4511 100644 --- a/packages/dm-core-plugins/src/yaml/types.ts +++ b/packages/dm-core-plugins/src/yaml/types.ts @@ -1,4 +1,4 @@ -import { IUIPlugin } from '@development-framework/dm-core' +import type { IUIPlugin } from '@development-framework/dm-core' export type TLanguages = 'json' | 'yaml' diff --git a/packages/dm-core-plugins/tsconfig.json b/packages/dm-core-plugins/tsconfig.json index 6af76437c..75d01ada5 100644 --- a/packages/dm-core-plugins/tsconfig.json +++ b/packages/dm-core-plugins/tsconfig.json @@ -5,13 +5,6 @@ "incremental": true, "jsx": "react-jsx" }, - "include": [ - "src", - "src/**/*.json" - ], - "exclude": [ - "node_modules", - "src/**/*.spec.ts", - "dist" - ] + "include": ["src", "src/**/*.json"], + "exclude": ["node_modules", "src/**/*.spec.ts", "dist"] } diff --git a/packages/dm-core/jestSetup.js b/packages/dm-core/jestSetup.js index d8b34dc3b..096b4c435 100644 --- a/packages/dm-core/jestSetup.js +++ b/packages/dm-core/jestSetup.js @@ -1,5 +1,4 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const crypto = require('crypto') +const crypto = await import('node:crypto') Object.defineProperty(window, 'crypto', { value: crypto, diff --git a/packages/dm-core/src/ApplicationContext.tsx b/packages/dm-core/src/ApplicationContext.tsx index bc2075fc2..a7d7d08b7 100644 --- a/packages/dm-core/src/ApplicationContext.tsx +++ b/packages/dm-core/src/ApplicationContext.tsx @@ -1,8 +1,9 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import React, { - Dispatch, - ReactNode, - SetStateAction, +import { + type Dispatch, + type ReactNode, + type SetStateAction, + createContext, useContext, useEffect, useState, @@ -10,11 +11,11 @@ import React, { import { AuthContext } from 'react-oauth2-code-pkce' import { ToastContainer } from 'react-toastify' import 'react-toastify/dist/ReactToastify.css' -import { Tree, TreeNode } from './domain/Tree' +import { Tree, type TreeNode } from './domain/Tree' import { DmJobAPI } from './services' import DmssAPI from './services/api/DmssAPI' import GlobalStyle from './styles/global' -import { IUIPlugin, TApplication, TRole, TUiPluginMap } from './types' +import type { IUIPlugin, TApplication, TRole, TUiPluginMap } from './types' import { ErrorGroup } from './utils/ErrorBoundary' const DEFAULT_ROLE: TRole = { @@ -23,7 +24,7 @@ const DEFAULT_ROLE: TRole = { label: 'Anonymous', } const queryClient = new QueryClient() -export const ApplicationContext = React.createContext< +export const ApplicationContext = createContext< | { name: string dmssAPI: DmssAPI diff --git a/packages/dm-core/src/components/AccessControl/ACLOwnerPanel.tsx b/packages/dm-core/src/components/AccessControl/ACLOwnerPanel.tsx index c9c68be7e..f5be74623 100644 --- a/packages/dm-core/src/components/AccessControl/ACLOwnerPanel.tsx +++ b/packages/dm-core/src/components/AccessControl/ACLOwnerPanel.tsx @@ -1,7 +1,6 @@ import { Input, Typography } from '@equinor/eds-core-react' -import React from 'react' import { Stack } from '../../layout' -import { AccessControlList, AccessLevel } from '../../services' +import { type AccessControlList, AccessLevel } from '../../services' import { ACLSelect } from './ACLSelect' interface IACLOwnerPanelProps { diff --git a/packages/dm-core/src/components/AccessControl/ACLSelect.tsx b/packages/dm-core/src/components/AccessControl/ACLSelect.tsx index 3171c60cb..e2ede64d4 100644 --- a/packages/dm-core/src/components/AccessControl/ACLSelect.tsx +++ b/packages/dm-core/src/components/AccessControl/ACLSelect.tsx @@ -1,4 +1,3 @@ -import React from 'react' import { AccessLevel } from '../../services' import { Select } from '../Select' diff --git a/packages/dm-core/src/components/AccessControl/ACLUserRolesPanel.tsx b/packages/dm-core/src/components/AccessControl/ACLUserRolesPanel.tsx index d86ca1853..f3580a7c3 100644 --- a/packages/dm-core/src/components/AccessControl/ACLUserRolesPanel.tsx +++ b/packages/dm-core/src/components/AccessControl/ACLUserRolesPanel.tsx @@ -6,9 +6,9 @@ import { TextField, } from '@equinor/eds-core-react' import { close } from '@equinor/eds-icons' -import React, { useState } from 'react' +import { useState } from 'react' import { Stack } from '../../layout' -import { AccessControlList, AccessLevel } from '../../services' +import { type AccessControlList, AccessLevel } from '../../services' import { ACLSelect } from './ACLSelect' interface IURPanelProps { diff --git a/packages/dm-core/src/components/AccessControl/AccessControlListComponent.tsx b/packages/dm-core/src/components/AccessControl/AccessControlListComponent.tsx index a66bf0841..a0edb79de 100644 --- a/packages/dm-core/src/components/AccessControl/AccessControlListComponent.tsx +++ b/packages/dm-core/src/components/AccessControl/AccessControlListComponent.tsx @@ -1,14 +1,13 @@ import { Button, Checkbox, Icon, Progress, Tabs } from '@equinor/eds-core-react' import { save } from '@equinor/eds-icons' -import React, { useEffect, useState } from 'react' - -import { AxiosError, AxiosResponse } from 'axios' +import type { AxiosError, AxiosResponse } from 'axios' +import { useEffect, useState } from 'react' import { toast } from 'react-toastify' import { useApplication } from '../../ApplicationContext' import { useLocalStorage } from '../../hooks/useLocalStorage' import { Stack } from '../../layout' -import { AccessControlList, AccessLevel } from '../../services' -import { TUserIdMapping } from '../../types' +import { type AccessControlList, AccessLevel } from '../../services' +import type { TUserIdMapping } from '../../types' import { getTokenWithUserReadAccess, getUsernameMappingFromUserId, diff --git a/packages/dm-core/src/components/CopyLinkDialog/CopyLinkDialog.tsx b/packages/dm-core/src/components/CopyLinkDialog/CopyLinkDialog.tsx index 5e21a8ef8..a4716a836 100644 --- a/packages/dm-core/src/components/CopyLinkDialog/CopyLinkDialog.tsx +++ b/packages/dm-core/src/components/CopyLinkDialog/CopyLinkDialog.tsx @@ -8,18 +8,18 @@ import { Tooltip, } from '@equinor/eds-core-react' import { folder_open } from '@equinor/eds-icons' -import { AxiosError } from 'axios' -import { ChangeEvent, useContext, useState } from 'react' +import type { AxiosError } from 'axios' +import { type ChangeEvent, useContext, useState } from 'react' import { toast } from 'react-toastify' import { AuthContext, Dialog, EBlueprint, EntityPickerDialog, - ErrorResponse, - TEntityPickerReturn, - TLinkReference, - TValidEntity, + type ErrorResponse, + type TEntityPickerReturn, + type TLinkReference, + type TValidEntity, truncatePathString, useApplication, useDocument, diff --git a/packages/dm-core/src/components/CopyLinkDialog/utils.ts b/packages/dm-core/src/components/CopyLinkDialog/utils.ts index 762ab147b..e8fc76456 100644 --- a/packages/dm-core/src/components/CopyLinkDialog/utils.ts +++ b/packages/dm-core/src/components/CopyLinkDialog/utils.ts @@ -1,4 +1,4 @@ -import { EBlueprint, TMeta, TValidEntity } from '../../' +import { EBlueprint, type TMeta, type TValidEntity } from '../../' export function setMetaInDocument( document: TValidEntity, diff --git a/packages/dm-core/src/components/Dropdown.tsx b/packages/dm-core/src/components/Dropdown.tsx index a61bb32a5..9a7212fb9 100644 --- a/packages/dm-core/src/components/Dropdown.tsx +++ b/packages/dm-core/src/components/Dropdown.tsx @@ -1,9 +1,9 @@ import { Checkbox, Icon, InputWrapper } from '@equinor/eds-core-react' import { arrow_drop_down, arrow_drop_up } from '@equinor/eds-icons' import { - Dispatch, - ReactElement, - SetStateAction, + type Dispatch, + type ReactElement, + type SetStateAction, useEffect, useRef, useState, diff --git a/packages/dm-core/src/components/EntityView.tsx b/packages/dm-core/src/components/EntityView.tsx index 62b921383..f3892570a 100644 --- a/packages/dm-core/src/components/EntityView.tsx +++ b/packages/dm-core/src/components/EntityView.tsx @@ -1,9 +1,9 @@ -import React, { Suspense, memo, useState } from 'react' +import { Suspense, memo, useState } from 'react' import { Typography } from '@equinor/eds-core-react' import { useRecipe } from '../hooks' import { Stack } from '../layout' -import { IUIPlugin, TUiRecipe } from '../types' +import type { IUIPlugin, TUiRecipe } from '../types' import { ErrorBoundary, ErrorGroup } from '../utils/ErrorBoundary' import { Loading } from './Loading' import RefreshButton from './RefreshButton' diff --git a/packages/dm-core/src/components/NewEntityButton.tsx b/packages/dm-core/src/components/NewEntityButton.tsx index f15b967c4..a94e334a4 100644 --- a/packages/dm-core/src/components/NewEntityButton.tsx +++ b/packages/dm-core/src/components/NewEntityButton.tsx @@ -1,16 +1,16 @@ import { Button, Input, Label, Progress } from '@equinor/eds-core-react' -import { AxiosError, AxiosResponse } from 'axios' -import React, { useEffect, useState } from 'react' +import type { AxiosError, AxiosResponse } from 'axios' +import { useEffect, useState } from 'react' import { toast } from 'react-toastify' import { useApplication } from '../ApplicationContext' -import { TGenericObject, TReference } from '../types' +import type { TGenericObject, TReference } from '../types' import { INPUT_FIELD_WIDTH } from '../utils/variables' import { Dialog } from './Dialog' import { BlueprintPicker, DestinationPicker, EntityPickerDialog, - TEntityPickerReturn, + type TEntityPickerReturn, } from './Pickers' // TODO fix this component - the component is not working due to a hook error somewhere, probably in the context diff --git a/packages/dm-core/src/components/Pickers/BlueprintPicker.tsx b/packages/dm-core/src/components/Pickers/BlueprintPicker.tsx index 47fb06c90..1b0abbbf8 100644 --- a/packages/dm-core/src/components/Pickers/BlueprintPicker.tsx +++ b/packages/dm-core/src/components/Pickers/BlueprintPicker.tsx @@ -14,10 +14,10 @@ import { Progress, Tooltip, } from '@equinor/eds-core-react' -import { Variants } from '@equinor/eds-core-react/dist/types/components/types' +import type { Variants } from '@equinor/eds-core-react/dist/types/components/types' import { add } from '@equinor/eds-icons' import { useApplication } from '../../ApplicationContext' -import { TreeNode } from '../../domain/Tree' +import type { TreeNode } from '../../domain/Tree' import { truncatePathString } from '../../utils/truncatePathString' import { Dialog } from '../Dialog' import { TreeView } from '../TreeView' diff --git a/packages/dm-core/src/components/Pickers/DestinationPicker.tsx b/packages/dm-core/src/components/Pickers/DestinationPicker.tsx index 55d567ec9..9618fe291 100644 --- a/packages/dm-core/src/components/Pickers/DestinationPicker.tsx +++ b/packages/dm-core/src/components/Pickers/DestinationPicker.tsx @@ -5,7 +5,7 @@ import { TREE_DIALOG_HEIGHT, TREE_DIALOG_WIDTH, } from '../../utils/variables' -import { TNodeWrapperProps, TreeView } from '../TreeView' +import { type TNodeWrapperProps, TreeView } from '../TreeView' import { Button, @@ -16,7 +16,7 @@ import { } from '@equinor/eds-core-react' import styled from 'styled-components' import { useApplication } from '../../ApplicationContext' -import { Tree, TreeNode } from '../../domain/Tree' +import { Tree, type TreeNode } from '../../domain/Tree' import { truncatePathString } from '../../utils/truncatePathString' import { Dialog } from '../Dialog' diff --git a/packages/dm-core/src/components/Pickers/EntityPickerDialog.tsx b/packages/dm-core/src/components/Pickers/EntityPickerDialog.tsx index 4fe771060..ce373b59d 100644 --- a/packages/dm-core/src/components/Pickers/EntityPickerDialog.tsx +++ b/packages/dm-core/src/components/Pickers/EntityPickerDialog.tsx @@ -1,22 +1,21 @@ -import { ChangeEvent, useEffect, useState } from 'react' - import { Button, Checkbox, EdsProvider, Progress, } from '@equinor/eds-core-react' +import { type ChangeEvent, useEffect, useState } from 'react' import { toast } from 'react-toastify' import styled from 'styled-components' import { useApplication } from '../../ApplicationContext' import { EBlueprint } from '../../Enums' -import { Tree, TreeNode } from '../../domain/Tree' +import { Tree, type TreeNode } from '../../domain/Tree' import { Stack } from '../../layout' -import { TValidEntity } from '../../types' +import type { TValidEntity } from '../../types' import { truncatePathString } from '../../utils/truncatePathString' import { TREE_DIALOG_HEIGHT, TREE_DIALOG_WIDTH } from '../../utils/variables' import { Dialog } from '../Dialog' -import { TNodeWrapperProps, TreeView } from '../TreeView' +import { type TNodeWrapperProps, TreeView } from '../TreeView' const Wrapper = styled.div<{ cursor?: string }>` display: flex; diff --git a/packages/dm-core/src/components/Pickers/EntityPickerDropdown.tsx b/packages/dm-core/src/components/Pickers/EntityPickerDropdown.tsx index 8a3627f0d..4e8f968f0 100644 --- a/packages/dm-core/src/components/Pickers/EntityPickerDropdown.tsx +++ b/packages/dm-core/src/components/Pickers/EntityPickerDropdown.tsx @@ -1,4 +1,4 @@ -import { ChangeEvent } from 'react' +import type { ChangeEvent } from 'react' import { useSearch } from '../../hooks/useSearch' import { Select } from '../Select' @@ -15,7 +15,7 @@ export const EntityPickerDropdown = (props: {