diff --git a/.prettierrc b/.prettierrc index 5528f1141dd..3c695c929f6 100644 --- a/.prettierrc +++ b/.prettierrc @@ -6,7 +6,7 @@ "useTabs": false, "semi": false, "bracketSameLine": false, - "trailingComma": "es5", + "trailingComma": "all", "overrides": [ { "files": ".yarnrc.yml", diff --git a/packages/dnb-design-system-portal/.lintstagedrc b/packages/dnb-design-system-portal/.lintstagedrc index 3eb33f0e22f..b45e06968c0 100644 --- a/packages/dnb-design-system-portal/.lintstagedrc +++ b/packages/dnb-design-system-portal/.lintstagedrc @@ -1,5 +1,5 @@ { - "*.js": [ + "*.{js,ts,tsx}": [ "yarn prettier:js:staged", "yarn lint:js:staged" ], @@ -7,7 +7,7 @@ "yarn lint:styles:staged", "yarn test:staged" ], - "*.{json,md}": [ + "*.{json,md,mdx}": [ "yarn prettier:other:staged" ] } diff --git a/packages/dnb-design-system-portal/.prettierrc b/packages/dnb-design-system-portal/.prettierrc index d0a95358513..587f2705ece 100644 --- a/packages/dnb-design-system-portal/.prettierrc +++ b/packages/dnb-design-system-portal/.prettierrc @@ -6,5 +6,5 @@ "useTabs": false, "semi": false, "bracketSameLine": false, - "trailingComma": "es5" + "trailingComma": "all" } diff --git a/packages/dnb-design-system-portal/above_the_line_medium.js b/packages/dnb-design-system-portal/above_the_line_medium.js index 42c5a345c80..c2418479ee5 100644 --- a/packages/dnb-design-system-portal/above_the_line_medium.js +++ b/packages/dnb-design-system-portal/above_the_line_medium.js @@ -1,21 +1,30 @@ -import _extends from "@babel/runtime/helpers/esm/extends"; +import _extends from '@babel/runtime/helpers/esm/extends' -var _path; +var _path -import React from 'react'; +import React from 'react' -const above_the_line_medium = props => React.createElement("svg", _extends({ - xmlns: "http://www.w3.org/2000/svg", - width: 24, - height: 24, - fill: "none", - viewBox: "0 0 24 24" -}, props), _path || (_path = React.createElement("path", { - stroke: "#000", - strokeLinecap: "round", - strokeLinejoin: "round", - strokeWidth: 1.5, - d: "M12 21V9m0 0-4 4m4-4s2.243 2.047 4 4M2 3.5h2m4 0h2m4 0h2m4 0h2" -}))); +const above_the_line_medium = (props) => + React.createElement( + 'svg', + _extends( + { + xmlns: 'http://www.w3.org/2000/svg', + width: 24, + height: 24, + fill: 'none', + viewBox: '0 0 24 24', + }, + props, + ), + _path || + (_path = React.createElement('path', { + stroke: '#000', + strokeLinecap: 'round', + strokeLinejoin: 'round', + strokeWidth: 1.5, + d: 'M12 21V9m0 0-4 4m4-4s2.243 2.047 4 4M2 3.5h2m4 0h2m4 0h2m4 0h2', + })), + ) -export default above_the_line_medium; \ No newline at end of file +export default above_the_line_medium diff --git a/packages/dnb-design-system-portal/gatsby-node.js b/packages/dnb-design-system-portal/gatsby-node.js index 9f69116d4d9..734b3af47a4 100644 --- a/packages/dnb-design-system-portal/gatsby-node.js +++ b/packages/dnb-design-system-portal/gatsby-node.js @@ -191,7 +191,7 @@ exports.onCreateWebpackConfig = ({ 'global.STYLE_IMPORT_PATH': JSON.stringify( PREBUILD_EXISTS ? '@dnb/eufemia/build/style/dnb-ui-core.min.css' - : '@dnb/eufemia/src/style/core' + : '@dnb/eufemia/src/style/core', ), }), @@ -203,7 +203,7 @@ exports.onCreateWebpackConfig = ({ if (PREBUILD_EXISTS && stage === 'build-javascript') { if (PREBUILD_EXISTS && !isCI) { reporter.warn( - 'šŸ˜± There is a "dnb-eufemia/build" in your local repo. It is used durnig your local Portal build! \nKeep in mind, the code from "dnb-eufemia/build" may be outdated. \n\nšŸ‘‰ You can remove the build with: "yarn build:clean"\n\n' + 'šŸ˜± There is a "dnb-eufemia/build" in your local repo. It is used durnig your local Portal build! \nKeep in mind, the code from "dnb-eufemia/build" may be outdated. \n\nšŸ‘‰ You can remove the build with: "yarn build:clean"\n\n', ) } @@ -211,9 +211,9 @@ exports.onCreateWebpackConfig = ({ plugins.normalModuleReplacement(/@dnb\/eufemia\/src/, (resource) => { resource.request = resource.request.replace( /@dnb\/eufemia\/src(.*)/, - '@dnb/eufemia/build$1' + '@dnb/eufemia/build$1', ) - }) + }), ) } diff --git a/packages/dnb-design-system-portal/package.json b/packages/dnb-design-system-portal/package.json index 56dcbeb7596..04b73568a36 100644 --- a/packages/dnb-design-system-portal/package.json +++ b/packages/dnb-design-system-portal/package.json @@ -9,32 +9,36 @@ "scripts": { "build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 gatsby build", "build:ci": "yarn build:version && gatsby build --prefix-paths", - "build:visual-test": "SKIP_IMAGE_PROCESSING=1 IS_VISUAL_TEST=1 NODE_OPTIONS=--max-old-space-size=8192 gatsby build --no-uglify", "build:version": "node ./scripts/version.js --new-version", + "build:visual-test": "SKIP_IMAGE_PROCESSING=1 IS_VISUAL_TEST=1 NODE_OPTIONS=--max-old-space-size=8192 gatsby build --no-uglify", "clean": "gatsby clean", - "precommit": "yarn lint-staged", "lint": "eslint --quiet ./src", - "lint-staged": "lint-staged", - "lint:ci": "NODE_ENV=test yarn lint:js && yarn lint:styles", + "lint:ci": "NODE_ENV=test yarn lint:js && yarn lint:styles && yarn prettier:diff && yarn prettier:package", "lint:js": "yarn lint --fix", "lint:js:staged": "eslint --quiet --fix", "lint:styles": "stylelint './src/**/*.scss'", "lint:styles:staged": "stylelint './src/**/*.scss'", + "lint-staged": "lint-staged", + "precommit": "yarn lint-staged", + "prettier:diff": "prettier --list-different '**/*.{md,mdx,js,ts,tsx}'", + "prettier:package": "prettier-package-json --list-different ./package.json", + "prettier:package:write": "prettier-package-json --write ./package.json", + "prettier:write": "prettier --log-level warn --write '**/*.{md,mdx,js,ts,tsx}'", "reset": "yarn clean && rm -rf ./node_modules", "serve": "gatsby serve -p 8000", "start": "cross-env NODE_OPTIONS=--max-old-space-size=8192 gatsby develop", "test": "jest", + "test:ci": "jest --ci --passWithNoTests", "test:e2e": "yarn playwright test", - "test:e2e:watch": "playwright test --ui", "test:e2e:ci": "start-server-and-test serve 8000 test:e2e", - "test:watch": "jest --watch", - "test:ci": "jest --ci --passWithNoTests", - "test:staged": "jest --bail --findRelatedTests ", + "test:e2e:watch": "playwright test --ui", "test:screenshots": "yarn workspace @dnb/eufemia test:screenshots", "test:screenshots:ci": "start-server-and-test serve 8000 'yarn workspace @dnb/eufemia test:screenshots:ci'", + "test:staged": "jest --bail --findRelatedTests ", "test:types": "tsc --noEmit", "test:types:watch": "tsc --noEmit --watch", - "test:update": "jest --updateSnapshot" + "test:update": "jest --updateSnapshot", + "test:watch": "jest --watch" }, "dependencies": { "@dnb/eufemia": "workspace:*", @@ -99,6 +103,8 @@ "ora": "5.4.1", "postcss": "8.3.11", "postcss-preset-env": "6.7.0", + "prettier": "3.0.3", + "prettier-package-json": "2.8.0", "prism-react-renderer": "1.3.3", "process": "0.11.10", "prop-types": "15.7.2", @@ -117,8 +123,8 @@ "unist-util-visit": "^2" }, "buildVersion": "[LOCAL BUILD]", - "releaseVersion": "[LOCAL BUILD]", "changelogVersion": "[LOCAL BUILD]", + "releaseVersion": "[LOCAL BUILD]", "volta": { "extends": "../../package.json" } diff --git a/packages/dnb-design-system-portal/scripts/version.js b/packages/dnb-design-system-portal/scripts/version.js index e182f4388b0..c8bd1560c6c 100644 --- a/packages/dnb-design-system-portal/scripts/version.js +++ b/packages/dnb-design-system-portal/scripts/version.js @@ -13,7 +13,7 @@ const { const init = async () => { if (!isCI) { console.log( - 'You may only set a new deploy version on a CI environment!' + 'You may only set a new deploy version on a CI environment!', ) return false } @@ -73,7 +73,7 @@ async function createNewChangelogVersion() { const packageJson = await fs.readJson(file) const changelogFilePath = path.resolve( __dirname, - '../src/docs/EUFEMIA_CHANGELOG.mdx' + '../src/docs/EUFEMIA_CHANGELOG.mdx', ) const content = await fs.readFile(changelogFilePath, 'utf-8') @@ -87,7 +87,7 @@ async function createNewChangelogVersion() { await fs.writeFile(file, JSON.stringify(packageJson, null, 2)) } catch (e) { console.warn( - `Failed to create new static version file! \n${e.message}` + `Failed to create new static version file! \n${e.message}`, ) } } diff --git a/packages/dnb-design-system-portal/src/core/PortalHead.tsx b/packages/dnb-design-system-portal/src/core/PortalHead.tsx index c9b2f1fd8aa..1a6c4ed4934 100644 --- a/packages/dnb-design-system-portal/src/core/PortalHead.tsx +++ b/packages/dnb-design-system-portal/src/core/PortalHead.tsx @@ -18,7 +18,7 @@ export const renderBody = + />, ) } diff --git a/packages/dnb-design-system-portal/src/core/PortalLayout.tsx b/packages/dnb-design-system-portal/src/core/PortalLayout.tsx index 15269a17606..79a5f7d00f7 100644 --- a/packages/dnb-design-system-portal/src/core/PortalLayout.tsx +++ b/packages/dnb-design-system-portal/src/core/PortalLayout.tsx @@ -99,7 +99,7 @@ export default function PortalLayout(props: PortalLayoutProps) { } return acc }, - { ...currentFm } + { ...currentFm }, ) // Ensure heading levels are reset before each page renders @@ -117,7 +117,7 @@ export default function PortalLayout(props: PortalLayoutProps) { } const makeUseOfCategory = Boolean( - !mdx?.frontmatter?.title && mdx?.frontmatter?.showTabs + !mdx?.frontmatter?.title && mdx?.frontmatter?.showTabs, ) const rootPath = '/' + (makeUseOfCategory ? category?.fields?.slug : mdx?.fields?.slug) diff --git a/packages/dnb-design-system-portal/src/core/PortalSkeleton.tsx b/packages/dnb-design-system-portal/src/core/PortalSkeleton.tsx index 8ccc23be74c..bae3e77c9cf 100644 --- a/packages/dnb-design-system-portal/src/core/PortalSkeleton.tsx +++ b/packages/dnb-design-system-portal/src/core/PortalSkeleton.tsx @@ -24,7 +24,7 @@ function setSkeletonEnabled(skeleton) { try { window.localStorage.setItem( 'skeleton-enabled', - String(skeleton ? true : false) + String(skeleton ? true : false), ) } catch (e) { // diff --git a/packages/dnb-design-system-portal/src/docs/brand/development/import-styles.mdx b/packages/dnb-design-system-portal/src/docs/brand/development/import-styles.mdx index f2fe1575b83..82cb227c111 100644 --- a/packages/dnb-design-system-portal/src/docs/brand/development/import-styles.mdx +++ b/packages/dnb-design-system-portal/src/docs/brand/development/import-styles.mdx @@ -23,6 +23,6 @@ import { Theme } from '@dnb/eufemia/shared' render( - + , ) ``` diff --git a/packages/dnb-design-system-portal/src/docs/contribute/getting-started/make-and-run-tests.mdx b/packages/dnb-design-system-portal/src/docs/contribute/getting-started/make-and-run-tests.mdx index 4873a4c8a33..e6c407b84b6 100644 --- a/packages/dnb-design-system-portal/src/docs/contribute/getting-started/make-and-run-tests.mdx +++ b/packages/dnb-design-system-portal/src/docs/contribute/getting-started/make-and-run-tests.mdx @@ -98,11 +98,11 @@ describe('Button scss', () => { (themeName) => { const css = loadScss( require.resolve( - `../style/themes/dnb-button-theme-${themeName}.scss` - ) + `../style/themes/dnb-button-theme-${themeName}.scss`, + ), ) expect(css).toMatchSnapshot() - } + }, ) }) ``` @@ -123,7 +123,7 @@ describe('Breadcrumb aria', () => { ]} variant="collapse" isCollapsed={false} - /> + />, ) expect(await axeComponent(Component)).toHaveNoViolations() }) diff --git a/packages/dnb-design-system-portal/src/docs/contribute/getting-started/making-changes.mdx b/packages/dnb-design-system-portal/src/docs/contribute/getting-started/making-changes.mdx index 09e9d8271ae..14e8fbfbef5 100644 --- a/packages/dnb-design-system-portal/src/docs/contribute/getting-started/making-changes.mdx +++ b/packages/dnb-design-system-portal/src/docs/contribute/getting-started/making-changes.mdx @@ -107,7 +107,7 @@ function MyComponent(props: ComponentAllProps) { const { myString } = extendPropsWithContext( props, defaultProps, - context.getTranslation(props).MyComponent // details below šŸ‘‡ + context.getTranslation(props).MyComponent, // details below šŸ‘‡ // ... ) @@ -140,7 +140,7 @@ function MyComponent(props: ComponentAllProps) { const { myParam, ...rest } = extendPropsWithContext( props, defaultProps, - context.MyComponent + context.MyComponent, // ... ) @@ -204,7 +204,7 @@ function MyComponent(props: ComponentAllProps) { const { myParam, className, ...rest } = extendPropsWithContext( props, - defaultProps + defaultProps, // ... ) @@ -215,7 +215,7 @@ function MyComponent(props: ComponentAllProps) { rest.className = classnames( 'dnb-my-component', createSpacingClasses(props), - className + className, ) // Spread the ...rest on your root element @@ -254,7 +254,7 @@ function MyComponent(props: ComponentAllProps) { const { skeleton, className, ...rest } = extendPropsWithContext( props, defaultProps, - { skeleton: context?.skeleton } + { skeleton: context?.skeleton }, // ... ) @@ -266,7 +266,7 @@ function MyComponent(props: ComponentAllProps) { 'shape', skeleton, context, - className + className, ) // Use skeleton and spread the ...rest diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/anchor/properties.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/anchor/properties.mdx index 222affb427a..94da8c1c052 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/anchor/properties.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/anchor/properties.mdx @@ -27,7 +27,7 @@ import { Link } from 'gatsby' render( Link - + , ) ``` @@ -47,6 +47,6 @@ render(
element to scroll to
- + , ) ``` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/autocomplete/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/autocomplete/Examples.tsx index 19c352f90ac..69730cb0832 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/autocomplete/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/autocomplete/Examples.tsx @@ -123,7 +123,7 @@ export const AutocompleteDynamicallyUpdatedData = () => ( return () => clearTimeout(timeout) }, { value }, - 250 + 250, ) } return ( diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/dialog/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/dialog/Examples.tsx index 05b2012159e..055954464fc 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/dialog/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/dialog/Examples.tsx @@ -305,7 +305,7 @@ export const DialogConfirmScrollableContent = () => { onOpen={() => { if ( document.documentElement.classList.contains( - 'scroll-to-bottom' + 'scroll-to-bottom', ) ) { scrollRef.current.scrollTop = 100000 diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/drawer/visual-tests/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/drawer/visual-tests/Examples.tsx index 1bc8e543105..941fc671ca5 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/drawer/visual-tests/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/drawer/visual-tests/Examples.tsx @@ -25,30 +25,30 @@ export const DrawerScrollViewSetup = () => ( scrollRef={scrollRef} onOpen={() => { const innerOverflowY = window.getComputedStyle( - innerRef.current + innerRef.current, ).overflowY const contentElem = scrollRef.current.querySelector( - '.dnb-drawer__content' + '.dnb-drawer__content', ) const contentOverflowY = window.getComputedStyle(contentElem)?.overflowY const scxrollOverflowY = window.getComputedStyle( - scrollRef.current + scrollRef.current, ).overflowY if (contentOverflowY !== 'visible') { setErrorMessage( '.dnb-drawer__content was "' + contentOverflowY + - '" and not "visible"' + '" and not "visible"', ) } else if (innerOverflowY !== 'visible') { setErrorMessage( '.dnb-drawer__inner was "' + innerOverflowY + - '" and not "visible"' + '" and not "visible"', ) } else if (scxrollOverflowY !== 'auto') { setErrorMessage('.dnb-scroll-view was not "auto"') diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/dropdown/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/dropdown/Examples.tsx index 67c81a2ba34..f99012d5118 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/dropdown/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/dropdown/Examples.tsx @@ -32,7 +32,9 @@ const Wrapper = styled.div` margin-right: 1rem; } [data-visual-test] { - > :not(.dnb-dropdown--is-popup):not(.dnb-dropdown--independent-width):not(.dnb-dropdown--stretch) + > :not(.dnb-dropdown--is-popup):not( + .dnb-dropdown--independent-width + ):not(.dnb-dropdown--stretch) .dnb-dropdown__shell { width: var(--dropdown-width); } @@ -221,7 +223,7 @@ export const DropdownEllipsisOverflow = () => ( export const DropdownDirections = () => { const visualTestProps = ( - enabled: boolean + enabled: boolean, ): VisibleWhenVisualTestReturn => { if (!enabled) { return {} @@ -255,7 +257,7 @@ export const DropdownDirections = () => { ]} {...visualTestProps( globalThis.IS_TEST && - window.location.search.includes('item-directions') + window.location.search.includes('item-directions'), )} /> @@ -321,7 +323,7 @@ export const DropdownTertiary = () => ( export const DropdownMoreMenu = () => { const visualTestProps = ( - enabled: boolean + enabled: boolean, ): VisibleWhenVisualTestReturn => { if (!enabled) { return {} @@ -353,7 +355,7 @@ export const DropdownMoreMenu = () => { right="small" {...visualTestProps( globalThis.IS_TEST && - window.location.search.includes('left-side') + window.location.search.includes('left-side'), )} /> { right="small" {...visualTestProps( globalThis.IS_TEST && - window.location.search.includes('right-side') + window.location.search.includes('right-side'), )} /> ( export const DropdownCustomEvent = () => { const visualTestProps = ( - enabled: boolean + enabled: boolean, ): VisibleWhenVisualTestReturn => { if (!enabled) { return {} @@ -497,7 +499,7 @@ export const DropdownCustomEvent = () => { } {...visualTestProps( globalThis.IS_TEST && - window.location.search.includes('action_menu-custom') + window.location.search.includes('action_menu-custom'), )} /> ) diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/global-status/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/global-status/Examples.tsx index 4b0468c7a3c..6397231e60a 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/global-status/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/global-status/Examples.tsx @@ -94,7 +94,7 @@ export const GlobalStatusCoupling = () => ( status={errorMessage} on_blur={({ value }) => { setErrorMessage( - value.length <= 4 ? 'With a message shown' : null + value.length <= 4 ? 'With a message shown' : null, ) }} globalStatus={{ id: 'main-status' }} diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/icon/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/icon/Examples.tsx index 4bad29142f1..cd4db01fc7c 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/icon/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/icon/Examples.tsx @@ -133,7 +133,7 @@ export const AllPrimaryIcons = () => { bottom="small" /> ) - } + }, )} ) @@ -170,7 +170,7 @@ export const AllSecondaryIcons = () => { bottom="small" /> ) - } + }, )} ) diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/input-masked/properties.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/input-masked/properties.mdx index 5f64b9dda0a..8054d9bef82 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/input-masked/properties.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/input-masked/properties.mdx @@ -96,7 +96,7 @@ render( mask={emailMask} placeholder="@." keep_placeholder={true} - /> + />, ) ``` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/number-format/info.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/number-format/info.mdx index 7fb890124f5..097a1dd8a7c 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/number-format/info.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/number-format/info.mdx @@ -49,7 +49,7 @@ render( text 123 table etc. - + , ) ``` @@ -79,7 +79,7 @@ function Component() { render( - + , ) ``` @@ -136,7 +136,7 @@ import { Provider } from '@dnb/eufemia/shared' render( - + , ) ``` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/Examples.tsx index 32538d5b5b0..579118932cd 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/Examples.tsx @@ -23,7 +23,9 @@ const LargePage = styled.div` background-color: ${(props) => props.color || 'tomato'}; font-size: 15vw; font-weight: var(--font-weight-bold); - font-feature-settings: 'pnum' on, 'lnum' on; + font-feature-settings: + 'pnum' on, + 'lnum' on; color: var(--color-white); ` @@ -61,9 +63,12 @@ export const PaginationExampleCentered = () => ( {({ pageNumber, setContent }) => { // simulate server communication delay - const timeout = setTimeout(() => { - setContent(pageNumber, {pageNumber}) - }, Math.ceil(Math.random() * 500)) + const timeout = setTimeout( + () => { + setContent(pageNumber, {pageNumber}) + }, + Math.ceil(Math.random() * 500), + ) return () => clearTimeout(timeout) }} @@ -100,7 +105,7 @@ export const InfinityPaginationTable = ({ tableItems, ...props }) => { const onToggleExpanded = ( { ssn: _ssn }, - { pageNumber, element = null, onExpanded = null } + { pageNumber, element = null, onExpanded = null }, ) => { const index = tableItems.findIndex(({ ssn }) => ssn === _ssn) if (index > -1) { @@ -130,7 +135,7 @@ export const InfinityPaginationTable = ({ tableItems, ...props }) => { // set the startup height const onMounted = (items) => { items.forEach(({ element: { current: element }, expanded }) => - setHeight({ element, expanded, animation: false }) + setHeight({ element, expanded, animation: false }), ) } @@ -155,15 +160,18 @@ export const InfinityPaginationTable = ({ tableItems, ...props }) => { // simulate server delay clearTimeout(serverDelayTimeout) - serverDelayTimeout = setTimeout(() => { - if (pageNumber === currentPage) { - // once we set current page, we force a re-render, and sync of data - // but only if we are on the same page - forceRerender(new Date().getTime()) - } else { - setLocalPage(pageNumber) - } - }, Math.ceil(Math.random() * 1e3)) // simulate random delay + serverDelayTimeout = setTimeout( + () => { + if (pageNumber === currentPage) { + // once we set current page, we force a re-render, and sync of data + // but only if we are on the same page + forceRerender(new Date().getTime()) + } else { + setLocalPage(pageNumber) + } + }, + Math.ceil(Math.random() * 1e3), + ) // simulate random delay } return ( @@ -372,7 +380,9 @@ const TableRow = styled.tr` transform: translateY(-10px); opacity: 0; - transition: height 400ms ease-out, opacity 600ms ease-out, + transition: + height 400ms ease-out, + opacity 600ms ease-out, transform 400ms ease-out; td { @@ -411,7 +421,9 @@ const TableData = styled.td` .dnb-p { cursor: text; - font-feature-settings: 'pnum' on, 'lnum' on; + font-feature-settings: + 'pnum' on, + 'lnum' on; font-weight: var(--font-weight-bold); font-size: var(--font-size-large); @@ -447,7 +459,7 @@ const setHeight = ({ element, expanded = false, animation = true }) => { element.style.height = '1px' } window.requestAnimationFrame( - () => (element.style.height = newHeight) + () => (element.style.height = newHeight), ) }) } diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/infinity-scroller/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/infinity-scroller/Examples.tsx index b4338678c7f..22a3e0db025 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/infinity-scroller/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/infinity-scroller/Examples.tsx @@ -45,7 +45,9 @@ const LargePage = styled.div` background-color: ${(props) => props.color || 'tomato'}; font-size: 15vw; font-weight: var(--font-weight-bold); - font-feature-settings: 'pnum' on, 'lnum' on; + font-feature-settings: + 'pnum' on, + 'lnum' on; color: var(--color-white); ` @@ -60,9 +62,12 @@ export const PaginationExampleInfinityLoadButton = () => ( min_wait_time={0} on_load={({ pageNumber, setContent }) => { // simulate server communication delay - const timeout = setTimeout(() => { - setContent(pageNumber, {pageNumber}) - }, Math.ceil(Math.random() * 500)) + const timeout = setTimeout( + () => { + setContent(pageNumber, {pageNumber}) + }, + Math.ceil(Math.random() * 500), + ) return () => clearTimeout(timeout) }} @@ -84,16 +89,19 @@ export const PaginationExampleInfinityIndicator = () => ( min_wait_time={0} on_load={({ pageNumber, setContent }) => { // simulate server communication delay - const timeout = setTimeout(() => { - setContent(pageNumber, {pageNumber}) - }, Math.ceil(Math.random() * 500)) + const timeout = setTimeout( + () => { + setContent(pageNumber, {pageNumber}) + }, + Math.ceil(Math.random() * 500), + ) return () => clearTimeout(timeout) }} on_end={({ pageNumber, setContent }) => { setContent( pageNumber, - End + End, ) }} /> @@ -110,20 +118,23 @@ export const PaginationExampleInfinityUnknown = () => ( min_wait_time={0} on_load={({ pageNumber, setContent, endInfinity }) => { // simulate server communication delay - const timeout = setTimeout(() => { - if (pageNumber > 10) { - endInfinity() - } else { - setContent(pageNumber, {pageNumber}) - } - }, Math.ceil(Math.random() * 1e3)) + const timeout = setTimeout( + () => { + if (pageNumber > 10) { + endInfinity() + } else { + setContent(pageNumber, {pageNumber}) + } + }, + Math.ceil(Math.random() * 1e3), + ) return () => clearTimeout(timeout) }} on_end={({ pageNumber, setContent }) => { setContent( pageNumber, - End + End, ) }} /> @@ -190,7 +201,7 @@ export const InfinityPaginationTable = ({ tableItems, ...props }) => { const onToggleExpanded = ( { ssn: _ssn }, - { pageNumber, element = null, onExpanded = null } + { pageNumber, element = null, onExpanded = null }, ) => { const index = tableItems.findIndex(({ ssn }) => ssn === _ssn) if (index > -1) { @@ -220,7 +231,7 @@ export const InfinityPaginationTable = ({ tableItems, ...props }) => { // set the startup height const onMounted = (items) => { items.forEach(({ element: { current: element }, expanded }) => - setHeight({ element, expanded, animation: false }) + setHeight({ element, expanded, animation: false }), ) } @@ -245,15 +256,18 @@ export const InfinityPaginationTable = ({ tableItems, ...props }) => { // simulate server delay clearTimeout(serverDelayTimeout) - serverDelayTimeout = setTimeout(() => { - if (pageNumber === currentPage) { - // once we set current page, we force a re-render, and sync of data - // but only if we are on the same page - forceRerender(new Date().getTime()) - } else { - setLocalPage(pageNumber) - } - }, Math.ceil(Math.random() * 1e3)) // simulate random delay + serverDelayTimeout = setTimeout( + () => { + if (pageNumber === currentPage) { + // once we set current page, we force a re-render, and sync of data + // but only if we are on the same page + forceRerender(new Date().getTime()) + } else { + setLocalPage(pageNumber) + } + }, + Math.ceil(Math.random() * 1e3), + ) // simulate random delay } return ( @@ -461,7 +475,9 @@ const TableRow = styled.tr` transform: translateY(-10px); opacity: 0; - transition: height 400ms ease-out, opacity 600ms ease-out, + transition: + height 400ms ease-out, + opacity 600ms ease-out, transform 400ms ease-out; td { @@ -500,7 +516,9 @@ const TableData = styled.td` .dnb-p { cursor: text; - font-feature-settings: 'pnum' on, 'lnum' on; + font-feature-settings: + 'pnum' on, + 'lnum' on; font-weight: var(--font-weight-bold); font-size: var(--font-size-large); @@ -546,7 +564,7 @@ const setHeight = ({ element.style.height = '1px' } window.requestAnimationFrame( - () => (element.style.height = newHeight) + () => (element.style.height = newHeight), ) }) } diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/infinity-scroller/info.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/infinity-scroller/info.mdx index d56a4bb71e8..cd345b7fa8c 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/infinity-scroller/info.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/infinity-scroller/info.mdx @@ -63,7 +63,7 @@ render( on_change={({ pageNumber, setContent }) => { setContent(pageNumber, ReactComponent) }} - /> + />, ) ``` @@ -87,7 +87,7 @@ render( on_change={({ pageNumber }) => { setLocalPage(pageNumber) }} - /> + />, ) ``` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/info.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/info.mdx index 72025132283..fafb4434c5a 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/info.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/pagination/info.mdx @@ -36,7 +36,7 @@ render( {() => { return ReactComponent }} - + , ) ``` @@ -52,7 +52,7 @@ render( {({ pageNumber, setContent }) => { setContent(pageNumber, ReactComponent) }} - + , ) ``` @@ -69,7 +69,7 @@ render( on_change={({ pageNumber, setContent }) => { setContent(pageNumber, ReactComponent) }} - /> + />, ) ``` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/progress-indicator/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/progress-indicator/Examples.tsx index 1d7dee509c8..4b0d7b08234 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/progress-indicator/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/progress-indicator/Examples.tsx @@ -94,12 +94,12 @@ export const ProgressIndicatorCircularRandomTransitionExample = () => ( const random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min const [progress, setProgressIndicator] = React.useState( - random(1, 100) + random(1, 100), ) React.useEffect(() => { const timer = setInterval( () => setProgressIndicator(random(1, 100)), - 1e3 + 1e3, ) return () => clearInterval(timer) }) @@ -126,7 +126,7 @@ export const ProgressIndicatorCircularRandomOnCompleteExample = () => ( React.useEffect(() => { const timer = setInterval( () => setVisible(!visible), - random(2400, 4200) + random(2400, 4200), ) return () => clearTimeout(timer) }) @@ -250,12 +250,12 @@ export const ProgressIndicatorLinearRandomTransitionExample = () => ( const random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min const [progress, setProgressIndicator] = React.useState( - random(1, 100) + random(1, 100), ) React.useEffect(() => { const timer = setInterval( () => setProgressIndicator(random(1, 100)), - 1e3 + 1e3, ) return () => clearInterval(timer) }) @@ -276,7 +276,7 @@ export const ProgressIndicatorLinearRandomOnCompleteExample = () => ( React.useEffect(() => { const timer = setInterval( () => setVisible(!visible), - random(2400, 4200) + random(2400, 4200), ) return () => clearTimeout(timer) }) diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/space/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/space/Examples.tsx index 7d0b2200887..bfe8ddabd53 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/space/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/space/Examples.tsx @@ -376,7 +376,7 @@ const VisualSpace = ({ label = null, children, ...rest }) => { const style = window.getComputedStyle(elem.children[0]) const top = parseFloat(style.getPropertyValue('margin-top')) const bottom = parseFloat( - style.getPropertyValue('margin-bottom') + style.getPropertyValue('margin-bottom'), ) let spaceInPixels = top diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/table/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/table/Examples.tsx index 1dcec2f613d..0f2f33e530a 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/table/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/table/Examples.tsx @@ -382,7 +382,7 @@ export const TableVariantFixed = () => ( export const TableStackedContainer = () => { const isFullscreen = /data-visual-test|fullscreen/.test( - globalThis?.location?.href + globalThis?.location?.href, ) return ( ( export const TableSticky = () => { const isFullscreen = /data-visual-test|fullscreen/.test( - globalThis?.location?.href + globalThis?.location?.href, ) const isVisibleWhenVisualTest = globalThis.IS_TEST return ( diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/table/info.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/table/info.mdx index f84d0a4ec08..b4835be9065 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/table/info.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/table/info.mdx @@ -48,7 +48,7 @@ import { Table } from '@dnb/eufemia' render( - + , ) ``` @@ -98,7 +98,7 @@ export const YourComponent = () => { column3: { modes: ['asc', 'off'] }, // will only allow one direction column4: {}, // etc. }, - defaultOptions + defaultOptions, ) // Use these properties for your custom sorting logic diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/tag/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/tag/Examples.tsx index 9efbdbe226f..d6cb95aad30 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/tag/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/tag/Examples.tsx @@ -73,7 +73,7 @@ export const TagMultipleRemovable = () => ( const handleDelete = (tagToDelete) => () => { setTagData((tags) => - tags.filter((tag) => tag.key !== tagToDelete.key) + tags.filter((tag) => tag.key !== tagToDelete.key), ) } diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/Examples.tsx index 0946de48b8c..69f60056a1f 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/Examples.tsx @@ -126,7 +126,7 @@ export const UploadRemoveFile = () => ( setImages([...images]) reader = null }, - false + false, ) reader.readAsDataURL(file) @@ -178,7 +178,7 @@ export const UploadIsLoading = () => ( setFiles( files.map((fileItem) => { return { ...fileItem, isLoading: checked } - }) + }), ) } > @@ -198,7 +198,7 @@ export const UploadErrorMessage = () => ( {() => { const Component = () => { const { files, setFiles } = Upload.useUpload( - 'upload-error-message' + 'upload-error-message', ) return ( @@ -219,7 +219,7 @@ export const UploadErrorMessage = () => ( ? 'custom error message' : null, } - }) + }), ) }} > @@ -239,7 +239,7 @@ export const UploadAcceptedFormats = () => ( {() => { const Component = () => { const { files, setFiles } = Upload.useUpload( - 'upload-accepted-formats' + 'upload-accepted-formats', ) if (files.length) { diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/info.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/info.mdx index 8db20b23384..506565f0c36 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/info.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/info.mdx @@ -25,7 +25,7 @@ function YourComponent() { fileItem.errorMessage = 'Your message from the backend' } return fileItem - }) + }), ) }, [fileNameFromBackend]) diff --git a/packages/dnb-design-system-portal/src/docs/uilib/elements.mdx b/packages/dnb-design-system-portal/src/docs/uilib/elements.mdx index 3c5536d4c14..463db18521f 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/elements.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/elements.mdx @@ -41,7 +41,7 @@ render(

My Paragraph

LinkLink - + , ) ``` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/elements/lists.mdx b/packages/dnb-design-system-portal/src/docs/uilib/elements/lists.mdx index 6d74b08bb6b..801622ba6cd 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/elements/lists.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/elements/lists.mdx @@ -28,7 +28,7 @@ import { Ol } from '@dnb/eufemia' render(
  1. Item
  2. -
+ , ) ``` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Field/base-input-components/String/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Field/base-input-components/String/Examples.tsx index cccf14e20d3..8851e87d4fd 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Field/base-input-components/String/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Field/base-input-components/String/Examples.tsx @@ -293,10 +293,10 @@ export const AsynchronousExternalValidator = () => { resolve( value.length < 5 ? new FormError('At least 5 characters') - : undefined + : undefined, ), - 1500 - ) + 1500, + ), ) } onChange={(value) => console.log('onChange', value)} @@ -335,10 +335,10 @@ export const AsynchronousExternalBlurValidator = () => { resolve( value.length < 5 ? new FormError('At least 5 characters') - : undefined + : undefined, ), - 1500 - ) + 1500, + ), ) } onChange={(value) => console.log('onChange', value)} diff --git a/packages/dnb-design-system-portal/src/docs/uilib/helpers/classes/visual-tests.js b/packages/dnb-design-system-portal/src/docs/uilib/helpers/classes/visual-tests.js index ee1e6bdb356..a72864b3393 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/helpers/classes/visual-tests.js +++ b/packages/dnb-design-system-portal/src/docs/uilib/helpers/classes/visual-tests.js @@ -16,7 +16,7 @@ export default function VisibleWhenVisualTests() { try { const range = new Range() const textNode = document.querySelector( - '[data-visual-test="helper-selection"] p' + '[data-visual-test="helper-selection"] p', ).childNodes[0] range.setStart(textNode, 0) range.setEnd(textNode, Math.floor(textNode.length / 2)) diff --git a/packages/dnb-design-system-portal/src/docs/uilib/intro/14-helpers.mdx b/packages/dnb-design-system-portal/src/docs/uilib/intro/14-helpers.mdx index 26e5a6ce6b5..e48bb1958c3 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/intro/14-helpers.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/intro/14-helpers.mdx @@ -23,7 +23,7 @@ import { Section } from '@dnb/eufemia' render(
Visual DNB Section -
+ , ) ``` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/usage/accessibility/examples/skip-link-example.tsx b/packages/dnb-design-system-portal/src/docs/uilib/usage/accessibility/examples/skip-link-example.tsx index fac3c1b5a34..3cdcb32b57f 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/usage/accessibility/examples/skip-link-example.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/usage/accessibility/examples/skip-link-example.tsx @@ -17,7 +17,7 @@ const ChangeStylesOfSkipLink = styled.div` export default function SkipLinkExample() { const onClick = (e: React.MouseEvent) => { const element = document.querySelector( - 'a.dnb-skip-link' + 'a.dnb-skip-link', ) as HTMLAnchorElement try { element.focus() diff --git a/packages/dnb-design-system-portal/src/docs/uilib/usage/best-practices/for-styling.mdx b/packages/dnb-design-system-portal/src/docs/uilib/usage/best-practices/for-styling.mdx index 385fc4f9f7b..ef8baa505e1 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/usage/best-practices/for-styling.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/usage/best-practices/for-styling.mdx @@ -45,7 +45,9 @@ For the "logical" groups we recommend the following rational order principle: color: #111; /* Typography */ - font: normal 1rem Helvetica, sans-serif; + font: + normal 1rem Helvetica, + sans-serif; line-height: 1.5rem; text-align: left; diff --git a/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/localization.mdx b/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/localization.mdx index 2557341543c..c447219b9c7 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/localization.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/localization.mdx @@ -35,7 +35,7 @@ const myLocale = 'en-GB' render( Eufemia components - + , ) ``` @@ -49,7 +49,7 @@ render( - + , ) ``` @@ -70,7 +70,7 @@ render( }} > Eufemia components - + , ) ``` @@ -132,7 +132,7 @@ render( }} > Eufemia components - + , ) ``` @@ -179,7 +179,7 @@ render( > - + , ) ``` @@ -249,7 +249,7 @@ import customTranslation from './locales/sv-SE' render( Eufemia components - + , ) ``` @@ -277,6 +277,6 @@ render( ... - + , ) ``` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/provider-info.mdx b/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/provider-info.mdx index a7097dedd25..ce68facb1a8 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/provider-info.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/provider-info.mdx @@ -16,7 +16,7 @@ render( ... - + , ) ``` @@ -69,7 +69,7 @@ render( text 123 table etc. - + , ) ``` @@ -113,7 +113,7 @@ render( English 1234 - + , ) ``` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/styling/legacy-styling.js b/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/styling/legacy-styling.js index e9df9a19bc6..845f6e950cd 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/styling/legacy-styling.js +++ b/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/styling/legacy-styling.js @@ -47,7 +47,7 @@ const LegacyCodeStyling = () => ( className={classnames( CoreStyleExample, 'dnb-core-style', - 'dnb-dev-grid' + 'dnb-dev-grid', )} > {'
'} @@ -71,7 +71,7 @@ const LegacyCodeStyling = () => ( SpacingExample, 'dnb-core-style', 'dnb-spacing', - 'dnb-dev-grid' + 'dnb-dev-grid', )} > {'
'} diff --git a/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/theming/theme/info.mdx b/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/theming/theme/info.mdx index d4122c90e25..fe028e96897 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/theming/theme/info.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/usage/customisation/theming/theme/info.mdx @@ -23,7 +23,7 @@ render( - + , ) ``` @@ -56,7 +56,7 @@ import { Theme } from '@dnb/eufemia/shared' render( - + , ) ``` @@ -123,6 +123,6 @@ render( Only shown in Sbanken then or Eiendom theme ā€“ that also includes the fictive variant="blue". - + , ) ``` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/usage/layout/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/usage/layout/Examples.tsx index 777b724aa7c..a4add3586ff 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/usage/layout/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/usage/layout/Examples.tsx @@ -11,7 +11,7 @@ import { Code, Button } from '@dnb/eufemia/src' const useWindowWidth = () => { const [innerWidth, setWidth] = React.useState( - typeof window !== 'undefined' ? window.innerWidth : 0 + typeof window !== 'undefined' ? window.innerWidth : 0, ) React.useEffect(() => { @@ -38,7 +38,7 @@ export const MediaQueryUseMedia = () => ( {JSON.stringify( { isSmall, isMedium, isLarge, isSSR, innerWidth }, null, - 2 + 2, )} diff --git a/packages/dnb-design-system-portal/src/e2e/color-table.spec.ts b/packages/dnb-design-system-portal/src/e2e/color-table.spec.ts index 7dc153040ab..e5bb777d072 100644 --- a/packages/dnb-design-system-portal/src/e2e/color-table.spec.ts +++ b/packages/dnb-design-system-portal/src/e2e/color-table.spec.ts @@ -12,7 +12,7 @@ test.afterEach(async ({ page }) => { test.describe('Colors for UI', () => { test.beforeEach(async ({ page }) => { await page.goto( - '/quickguide-designer/colors?data-visual-test&eufemia-theme=ui' + '/quickguide-designer/colors?data-visual-test&eufemia-theme=ui', ) // Check if app is mounted @@ -23,11 +23,11 @@ test.describe('Colors for UI', () => { test('table should have correct color', async ({ page }) => { await expect( - page.locator('.dnb-table__scroll-view table tbody tr td').first() + page.locator('.dnb-table__scroll-view table tbody tr td').first(), ).toHaveCSS('color', 'rgb(0, 52, 62)') const lastCellText = await page.textContent( - '.dnb-table__scroll-view table tbody tr td:last-of-type' + '.dnb-table__scroll-view table tbody tr td:last-of-type', ) expect(lastCellText).toContain('--color-ocean-green') }) @@ -36,7 +36,7 @@ test.describe('Colors for UI', () => { test.describe('Colors for Sbanken', () => { test.beforeEach(async ({ page }) => { await page.goto( - '/quickguide-designer/colors?data-visual-test&eufemia-theme=sbanken' + '/quickguide-designer/colors?data-visual-test&eufemia-theme=sbanken', ) // Check if app is mounted @@ -47,11 +47,11 @@ test.describe('Colors for Sbanken', () => { test('table should have correct color', async ({ page }) => { await expect( - page.locator('.dnb-table__scroll-view table tbody tr td').first() + page.locator('.dnb-table__scroll-view table tbody tr td').first(), ).toHaveCSS('color', 'rgb(28, 27, 78)') const lastCellText = await page.textContent( - '.dnb-table__scroll-view table tbody tr td:last-of-type' + '.dnb-table__scroll-view table tbody tr td:last-of-type', ) expect(lastCellText).toContain('--sb-color-purple') }) diff --git a/packages/dnb-design-system-portal/src/e2e/pageHeading.spec.ts b/packages/dnb-design-system-portal/src/e2e/pageHeading.spec.ts index d2830bc24fe..22d0a3d9e57 100644 --- a/packages/dnb-design-system-portal/src/e2e/pageHeading.spec.ts +++ b/packages/dnb-design-system-portal/src/e2e/pageHeading.spec.ts @@ -16,30 +16,30 @@ test.describe('Page Heading', () => { const firstElementTagName = await page.$eval( '#tabbar-content > *', - (element) => element.tagName + (element) => element.tagName, ) expect(firstElementTagName).toBe('H1') const secondElementTagName = await page.$eval( '#tabbar-content > h1 ~ p ~ *', - (element) => element.tagName + (element) => element.tagName, ) expect(secondElementTagName).toBe('H2') const thirdElementTagName = await page.$eval( '#tabbar-content > h1 ~ p ~ *', - (element) => element.tagName + (element) => element.tagName, ) expect(thirdElementTagName).toBe('H2') // App should re-render await page.click( - '#portal-sidebar-menu ul li a[href*="/uilib/components/"]:first-child' + '#portal-sidebar-menu ul li a[href*="/uilib/components/"]:first-child', ) const reRenderedElementTagName = await page.$eval( '#tabbar-content > h1 ~ p ~ *', - (element) => element.tagName + (element) => element.tagName, ) expect(reRenderedElementTagName).toBe('H2') }) diff --git a/packages/dnb-design-system-portal/src/e2e/pageLists.spec.ts b/packages/dnb-design-system-portal/src/e2e/pageLists.spec.ts index 5b7792d5a86..8fbcc612f27 100644 --- a/packages/dnb-design-system-portal/src/e2e/pageLists.spec.ts +++ b/packages/dnb-design-system-portal/src/e2e/pageLists.spec.ts @@ -20,14 +20,14 @@ test.describe('Page Lists', () => { test('should have same amount of components', async ({ page }) => { const listLength = await page .locator( - '#portal-sidebar-menu ul li:has(> a[href*="/uilib/components"]) ~ li:is(.l-3, .l-4):has(> a[href*="/components"]):has(> a:not([href*="/fragments"]))' + '#portal-sidebar-menu ul li:has(> a[href*="/uilib/components"]) ~ li:is(.l-3, .l-4):has(> a[href*="/components"]):has(> a:not([href*="/fragments"]))', ) .count() await expect( page.locator( - '#tabbar-content h2:has(a[href*="/uilib/components/"])' - ) + '#tabbar-content h2:has(a[href*="/uilib/components/"])', + ), ).toHaveCount(listLength) }) }) @@ -51,14 +51,14 @@ test.describe('Page Lists', () => { test('should have same amount of extensions', async ({ page }) => { const listLength = await page .locator( - '#portal-sidebar-menu ul li:has(> a[href*="/uilib/extensions"]) ~ li.l-3:has(> a[href*="/uilib/extensions/"])' + '#portal-sidebar-menu ul li:has(> a[href*="/uilib/extensions"]) ~ li.l-3:has(> a[href*="/uilib/extensions/"])', ) .count() await expect( page.locator( - '#tabbar-content h2:has(a[href*="/uilib/extensions/"])' - ) + '#tabbar-content h2:has(a[href*="/uilib/extensions/"])', + ), ).toHaveCount(listLength) }) }) @@ -82,13 +82,13 @@ test.describe('Page Lists', () => { test('should have same amount of elements', async ({ page }) => { const listLength = await page .locator( - '#portal-sidebar-menu ul li.l-2:has(> a[href*="/uilib/elements"]) ~ li:has(> a[href*="/uilib/elements"])' + '#portal-sidebar-menu ul li.l-2:has(> a[href*="/uilib/elements"]) ~ li:has(> a[href*="/uilib/elements"])', ) .count() await expect( page.locator( - '#tabbar-content ul li:has(a[href*="/uilib/elements/"])' - ) + '#tabbar-content ul li:has(a[href*="/uilib/elements/"])', + ), ).toHaveCount(listLength) }) }) diff --git a/packages/dnb-design-system-portal/src/e2e/pageNavigation.spec.ts b/packages/dnb-design-system-portal/src/e2e/pageNavigation.spec.ts index f45991ce891..f654a7eae74 100644 --- a/packages/dnb-design-system-portal/src/e2e/pageNavigation.spec.ts +++ b/packages/dnb-design-system-portal/src/e2e/pageNavigation.spec.ts @@ -12,7 +12,7 @@ test.describe('Page Navigation', () => { test('noscript element should be visible', async ({ page }) => { await expect(page.locator('noscript').first()).toHaveCSS( 'display', - 'block' + 'block', ) }) @@ -51,7 +51,7 @@ test.describe('Page Navigation', () => { expect(heading).toContain('Components') const accordionLinkText = await page.textContent( - 'a[href="/uilib/components/accordion"]' + 'a[href="/uilib/components/accordion"]', ) expect(accordionLinkText).toContain('Accordion') }) @@ -107,7 +107,7 @@ test.describe('Page Navigation', () => { await element?.click() await page.click('nav a[href="/uilib/components/button/"]') await page.click( - 'main a[href="/uilib/components/button/properties/"]' + 'main a[href="/uilib/components/button/properties/"]', ) await page.waitForURL('**/uilib/components/button/properties/') await page.waitForSelector('#dnb-drawer-list__portal', { @@ -136,7 +136,7 @@ test.describe('Page Navigation', () => { expect(heading).toContain('Components') const accordionLinkText = await page.textContent( - 'a[href="/uilib/components/accordion"]' + 'a[href="/uilib/components/accordion"]', ) expect(accordionLinkText).toContain('Accordion') }) diff --git a/packages/dnb-design-system-portal/src/e2e/responsiveness.spec.ts b/packages/dnb-design-system-portal/src/e2e/responsiveness.spec.ts index 0c7d862e013..e5696ead4b4 100644 --- a/packages/dnb-design-system-portal/src/e2e/responsiveness.spec.ts +++ b/packages/dnb-design-system-portal/src/e2e/responsiveness.spec.ts @@ -16,18 +16,18 @@ test.describe('Responsiveness', () => { }) => { await expect(page.locator('nav#portal-sidebar-menu')).toHaveCSS( 'display', - 'block' + 'block', ) await page.setViewportSize({ width: 375, height: 667 }) // Set viewport size to iPhone 6 dimensions await expect(page.locator('nav#portal-sidebar-menu')).toHaveCSS( 'display', - 'none' + 'none', ) await page.click('#toggle-sidebar-menu') await page.click( - 'nav#portal-sidebar-menu a[href="/uilib/about-the-lib/"]' + 'nav#portal-sidebar-menu a[href="/uilib/about-the-lib/"]', ) // Check if app is mounted diff --git a/packages/dnb-design-system-portal/src/e2e/themeSwitch.spec.ts b/packages/dnb-design-system-portal/src/e2e/themeSwitch.spec.ts index b666d91349a..c753ef48a74 100644 --- a/packages/dnb-design-system-portal/src/e2e/themeSwitch.spec.ts +++ b/packages/dnb-design-system-portal/src/e2e/themeSwitch.spec.ts @@ -21,13 +21,13 @@ test.describe('Theme', () => { test('should have no preload link', async ({ page }) => { expect( - await page.locator('link[href^="/ui."][rel="preload"]').count() + await page.locator('link[href^="/ui."][rel="preload"]').count(), ).toEqual(0) }) test('should have one default theme loaded', async ({ page }) => { expect(await page.locator('style[data-href^="/ui."]').count()).toEqual( - 1 + 1, ) }) @@ -40,11 +40,11 @@ test.describe('Theme', () => { state: 'attached', }) expect(await page.locator('link[href^="/sbanken."]').count()).toEqual( - 1 + 1, ) expect(await page.locator('style[data-href^="/ui."]').count()).toEqual( - 0 + 0, ) }) @@ -55,7 +55,7 @@ test.describe('Theme', () => { const localStorageData = await page.evaluate(() => { return JSON.parse( - window.localStorage.getItem('eufemia-theme') || '{}' + window.localStorage.getItem('eufemia-theme') || '{}', ) }) @@ -75,7 +75,7 @@ test.describe('Theme', () => { }) const uiCssFileCount = await page.$$eval( 'link[href^="/ui."][rel="stylesheet"]', - (elements) => elements.length + (elements) => elements.length, ) expect(uiCssFileCount).toBe(1) @@ -89,7 +89,7 @@ test.describe('Theme', () => { await page.click('#change-theme-portal ul li:nth-child(3)') const sbankenCssAfterTemplateExists = await page.$( - '#eufemia-style-theme + link[href^="/sbanken."][rel="stylesheet"]' + '#eufemia-style-theme + link[href^="/sbanken."][rel="stylesheet"]', ) expect(sbankenCssAfterTemplateExists).toBeTruthy() @@ -97,7 +97,7 @@ test.describe('Theme', () => { await page.click('#change-theme-portal ul li:first-child') const uiCssAfterTemplateExists = await page.$( - '#eufemia-style-theme + link[href^="/ui."][rel="stylesheet"]' + '#eufemia-style-theme + link[href^="/ui."][rel="stylesheet"]', ) expect(uiCssAfterTemplateExists).toBeTruthy() }) diff --git a/packages/dnb-design-system-portal/src/e2e/typography.spec.ts b/packages/dnb-design-system-portal/src/e2e/typography.spec.ts index d1efcf97ca1..e550431296f 100644 --- a/packages/dnb-design-system-portal/src/e2e/typography.spec.ts +++ b/packages/dnb-design-system-portal/src/e2e/typography.spec.ts @@ -12,7 +12,7 @@ test.afterEach(async ({ page }) => { test.describe('Typography for UI', () => { test.beforeEach(async ({ page }) => { await page.goto( - '/quickguide-designer/fonts?data-visual-test&eufemia-theme=ui' + '/quickguide-designer/fonts?data-visual-test&eufemia-theme=ui', ) // Check if app is mounted @@ -99,7 +99,7 @@ test.describe('Typography for UI', () => { test.describe('Typography for Sbanken', () => { test.beforeEach(async ({ page }) => { await page.goto( - '/quickguide-designer/fonts?data-visual-test&eufemia-theme=sbanken' + '/quickguide-designer/fonts?data-visual-test&eufemia-theme=sbanken', ) // Check if app is mounted diff --git a/packages/dnb-design-system-portal/src/shared/menu/Card.js b/packages/dnb-design-system-portal/src/shared/menu/Card.js index 86d57551b5e..5a1b0f68cd3 100644 --- a/packages/dnb-design-system-portal/src/shared/menu/Card.js +++ b/packages/dnb-design-system-portal/src/shared/menu/Card.js @@ -39,14 +39,14 @@ export default class Card extends React.PureComponent {
  • { acc[slug] = { url: `/${slug}/`, @@ -81,7 +81,7 @@ function MainMenu() { } return acc }, - {} + {}, ) return ( diff --git a/packages/dnb-design-system-portal/src/shared/menu/SearchBar.js b/packages/dnb-design-system-portal/src/shared/menu/SearchBar.js index 54e22e5c25d..4160bc7b62e 100644 --- a/packages/dnb-design-system-portal/src/shared/menu/SearchBar.js +++ b/packages/dnb-design-system-portal/src/shared/menu/SearchBar.js @@ -40,7 +40,7 @@ export const SearchBarInput = () => { ?.search(value) .then(({ hits }) => { updateData( - makeHitsHumanFriendly({ hits, setHidden, emptyData }) + makeHitsHumanFriendly({ hits, setHidden, emptyData }), ) hideIndicator() }) @@ -49,7 +49,7 @@ export const SearchBarInput = () => { hideIndicator() }) }, - { value } + { value }, ) showIndicator() } @@ -155,7 +155,7 @@ const makeHitsHumanFriendly = ({ hits, setHidden }) => { }} > {value} - + , ) } }) diff --git a/packages/dnb-design-system-portal/src/shared/menu/SidebarMenu.tsx b/packages/dnb-design-system-portal/src/shared/menu/SidebarMenu.tsx index a7f47891fe2..111cd64a9cd 100644 --- a/packages/dnb-design-system-portal/src/shared/menu/SidebarMenu.tsx +++ b/packages/dnb-design-system-portal/src/shared/menu/SidebarMenu.tsx @@ -105,7 +105,7 @@ export default function SidebarLayout({ showAll, pathPrefix, }), - location + location, ) .filter(({ title, menuTitle }) => title || menuTitle) .map( @@ -122,7 +122,7 @@ export default function SidebarLayout({ isInsideActiveCategory, subheadings, }, - nr + nr, ) => { const props = { level, @@ -138,7 +138,7 @@ export default function SidebarLayout({ } return - } + }, ) return ( @@ -149,7 +149,7 @@ export default function SidebarLayout({ navStyle, 'dnb-scrollbar-appearance', isOpen && 'show-mobile-menu', - isClosing && 'hide-mobile-menu' + isClosing && 'hide-mobile-menu', )} ref={scrollRef} > @@ -222,7 +222,7 @@ const ThemeBadge = ({ theme, ...props }: { theme: ThemeNames }) => { @@ -294,7 +294,7 @@ function ListItem({ isInsideActivePath && 'is-inside-active-path', isInsideActiveCategory && !isInsideActivePath && 'is-inside', status && `status-${status}`, - className + className, )} ref={ref} style={ @@ -313,7 +313,7 @@ function ListItem({ 'dnb-anchor--no-underline', 'dnb-anchor--no-radius', 'dnb-anchor--no-hover', - icon && graphics[icon] ? 'has-icon' : null + icon && graphics[icon] ? 'has-icon' : null, )} {...params} > @@ -383,7 +383,7 @@ const prepareNav = ({ node: { fields: { slug }, }, - }) => slug + }) => slug, ) .filter((slug) => slug !== '/') // preorder @@ -416,7 +416,7 @@ const prepareNav = ({ } } }, - { items: [] } + { items: [] }, ) let countLevels = 0 @@ -437,7 +437,7 @@ const prepareNav = ({ node: { fields: { slug }, }, - }) => slug === slugPath + }) => slug === slugPath, ) const level = slug.split('/').filter(Boolean).length @@ -484,7 +484,7 @@ const prepareNav = ({ list // reorder regarding potential manually defined order .sort(({ _order: oA }, { _order: oB }) => - oA < oB ? -1 : oA > oB ? 1 : 0 + oA < oB ? -1 : oA > oB ? 1 : 0, ) return list @@ -553,7 +553,7 @@ function groupNavItems(navItems: NavItem[], location: Location) { function getActiveStatusForItem( currentPath: string, - { path: itemPath, showTabs, tabs }: NavItem + { path: itemPath, showTabs, tabs }: NavItem, ) { const portalSlug = itemPath.split('/').filter(Boolean)[0] ?? '' const categorySlug = itemPath.split('/').filter(Boolean)[1] ?? '' @@ -564,13 +564,13 @@ function getActiveStatusForItem( const isInsideActivePath = checkIfActivePath( currentPath, itemPath, - isActive + isActive, ) const isInsideActiveCategory = checkIfActiveCategory( currentPath, startOfCurrentPath, - isInsideActivePath + isInsideActivePath, ) return { isActive, isInsideActiveCategory, isInsideActivePath } @@ -579,7 +579,7 @@ function getActiveStatusForItem( function checkIfActiveCategory( currentPath: string, startOfCurrentPath: string, - isInsideActivePath?: boolean + isInsideActivePath?: boolean, ) { return ( !isInsideActivePath && @@ -590,7 +590,7 @@ function checkIfActiveCategory( function checkIfActivePath( currentPath: string, itemPath: string, - isActive?: boolean + isActive?: boolean, ) { return !isActive && (currentPath + '/').startsWith(itemPath + '/') } @@ -599,7 +599,7 @@ function checkIfActiveItem( currentPath: string, itemPath: string, showTabs?: boolean, - tabs?: NavItemTabs[] + tabs?: NavItemTabs[], ): boolean { if (!showTabs) { return itemPath === currentPath @@ -618,7 +618,7 @@ function checkIfActiveItem( const lastSlug = slugs[slugs.length - 1] const currentPathWithoutTabSlug = currentPath.replace( `/${lastSlug}`, - '' + '', ) if (itemPath === currentPathWithoutTabSlug) { diff --git a/packages/dnb-design-system-portal/src/shared/menu/SidebarMenuContext.js b/packages/dnb-design-system-portal/src/shared/menu/SidebarMenuContext.js index 0abec7fa157..b899f74ad96 100644 --- a/packages/dnb-design-system-portal/src/shared/menu/SidebarMenuContext.js +++ b/packages/dnb-design-system-portal/src/shared/menu/SidebarMenuContext.js @@ -64,7 +64,7 @@ export class SidebarMenuProvider extends React.PureComponent { } }, 100) // after animation is done }, - this.state.isOpen ? 260 : 10 + this.state.isOpen ? 260 : 10, ) if (this.state.isOpen) { this.setState({ diff --git a/packages/dnb-design-system-portal/src/shared/menu/StickyMenuBar.js b/packages/dnb-design-system-portal/src/shared/menu/StickyMenuBar.js index 6ddf80c3544..e2c3a89e819 100644 --- a/packages/dnb-design-system-portal/src/shared/menu/StickyMenuBar.js +++ b/packages/dnb-design-system-portal/src/shared/menu/StickyMenuBar.js @@ -56,7 +56,7 @@ export default function StickyMenuBar({ headerStyle, hideSidebarToggleButton && hideSidebarToggleButtonStyle, 'sticky-menu', - 'dev-grid' + 'dev-grid', )} >
    @@ -80,7 +80,7 @@ export default function StickyMenuBar({ {slogan} diff --git a/packages/dnb-design-system-portal/src/shared/menu/ToggleGrid.tsx b/packages/dnb-design-system-portal/src/shared/menu/ToggleGrid.tsx index 1fed63744e6..1520746ee56 100644 --- a/packages/dnb-design-system-portal/src/shared/menu/ToggleGrid.tsx +++ b/packages/dnb-design-system-portal/src/shared/menu/ToggleGrid.tsx @@ -20,7 +20,7 @@ function makeGridVisible(showGrid = true) { function isGridVisible() { return Boolean( typeof window !== 'undefined' && - parseFloat(window.localStorage.getItem('showGrid')) + parseFloat(window.localStorage.getItem('showGrid')), ) } diff --git a/packages/dnb-design-system-portal/src/shared/parts/Layout.tsx b/packages/dnb-design-system-portal/src/shared/parts/Layout.tsx index b09fd1d1a37..eb8997614b5 100644 --- a/packages/dnb-design-system-portal/src/shared/parts/Layout.tsx +++ b/packages/dnb-design-system-portal/src/shared/parts/Layout.tsx @@ -148,7 +148,7 @@ const Content = ({ contentStyle, 'dnb-app-content', fullscreen && 'fullscreen-page', - className + className, )} > {children} diff --git a/packages/dnb-design-system-portal/src/shared/parts/ListSummaryFromEdges.tsx b/packages/dnb-design-system-portal/src/shared/parts/ListSummaryFromEdges.tsx index 0ee43a883f6..e77d487a882 100644 --- a/packages/dnb-design-system-portal/src/shared/parts/ListSummaryFromEdges.tsx +++ b/packages/dnb-design-system-portal/src/shared/parts/ListSummaryFromEdges.tsx @@ -37,7 +37,7 @@ export default function ListSummaryFromEdges({ fields: { slug }, }, }, - i + i, ) => { return ( @@ -64,7 +64,7 @@ export default function ListSummaryFromEdges({ ) } - } + }, ) return <>{jsx} diff --git a/packages/dnb-design-system-portal/src/shared/parts/TableOfContents.tsx b/packages/dnb-design-system-portal/src/shared/parts/TableOfContents.tsx index 55a9ef77cf3..d18412db763 100644 --- a/packages/dnb-design-system-portal/src/shared/parts/TableOfContents.tsx +++ b/packages/dnb-design-system-portal/src/shared/parts/TableOfContents.tsx @@ -21,7 +21,7 @@ type TableOfContentsProps = { const TableOfContents = ({ edges }: TableOfContentsProps) => { const orderedContents = edges .sort((edgeA, edgeB) => - edgeA.node.frontmatter.order > edgeB.node.frontmatter.order ? 1 : -1 + edgeA.node.frontmatter.order > edgeB.node.frontmatter.order ? 1 : -1, ) .map(({ node }) => node.tableOfContents.items) .reduce>((allContent, currentContent) => { diff --git a/packages/dnb-design-system-portal/src/shared/parts/icons/ListAllIcons.js b/packages/dnb-design-system-portal/src/shared/parts/icons/ListAllIcons.js index bea225fe560..1c98060499b 100644 --- a/packages/dnb-design-system-portal/src/shared/parts/icons/ListAllIcons.js +++ b/packages/dnb-design-system-portal/src/shared/parts/icons/ListAllIcons.js @@ -116,9 +116,7 @@ export default class ListAllIcons extends React.PureComponent { element="figcaption" useSlug={iconName} > - - {iconName} - + {iconName}

    {tags.length > 0 ? tags.join(', ') : '(no tags)'}

    @@ -142,7 +140,7 @@ export default class ListAllIcons extends React.PureComponent {
      {this.renderListItem(icons)}
    - ) + ), ) } else { return ( diff --git a/packages/dnb-design-system-portal/src/shared/tags/CodeBlock.tsx b/packages/dnb-design-system-portal/src/shared/tags/CodeBlock.tsx index 8b4ffa0b1cc..1a00bc4e239 100644 --- a/packages/dnb-design-system-portal/src/shared/tags/CodeBlock.tsx +++ b/packages/dnb-design-system-portal/src/shared/tags/CodeBlock.tsx @@ -46,7 +46,7 @@ const CodeBlock = ({
    @@ -68,7 +68,7 @@ const CodeBlock = ({
    @@ -211,7 +211,7 @@ class LiveCode extends React.PureComponent<
    @@ -227,14 +227,14 @@ class LiveCode extends React.PureComponent< onFocus={() => { if (this._editorElementRef.current) { this._editorElementRef.current.classList.add( - 'dnb-pre--focus' + 'dnb-pre--focus', ) } }} onBlur={() => { if (this._editorElementRef.current) { this._editorElementRef.current.classList.remove( - 'dnb-pre--focus' + 'dnb-pre--focus', ) } }} diff --git a/packages/dnb-design-system-portal/src/shared/tags/Tabbar.tsx b/packages/dnb-design-system-portal/src/shared/tags/Tabbar.tsx index 83857e020f2..c7a365e8694 100644 --- a/packages/dnb-design-system-portal/src/shared/tags/Tabbar.tsx +++ b/packages/dnb-design-system-portal/src/shared/tags/Tabbar.tsx @@ -38,7 +38,7 @@ export default function Tabbar({ children, }: TabbarProps) { const [wasFullscreen, setFullscreen] = React.useState( - /fullscreen/.test(location.search) + /fullscreen/.test(location.search), ) const openFullscreen = () => { @@ -74,7 +74,7 @@ export default function Tabbar({ (tabs || defaultTabs) // remove the tab if it is hidden in frontmatter .filter( - ({ title }) => !hideTabs?.find(({ title: t }) => t === title) + ({ title }) => !hideTabs?.find(({ title: t }) => t === title), ) .map(({ key, ...rest }) => { const search = cleanFullscreen(location.search) diff --git a/packages/dnb-design-system-portal/src/shared/tags/Table.tsx b/packages/dnb-design-system-portal/src/shared/tags/Table.tsx index 2b2a5686f18..fff5588d983 100644 --- a/packages/dnb-design-system-portal/src/shared/tags/Table.tsx +++ b/packages/dnb-design-system-portal/src/shared/tags/Table.tsx @@ -18,7 +18,7 @@ export default function Table({ children }) { // make sure we get the table children children = recursiveFind(children, (child: React.ReactElement) => - child.type === 'table' ? child.props.children : false + child.type === 'table' ? child.props.children : false, ) || children children = recursiveMap( @@ -46,7 +46,7 @@ export default function Table({ children }) { } return child - } + }, ) return ( @@ -84,7 +84,7 @@ function recursiveFind(children: ChildrenWithChildren, func) { function recursiveMap( children: ChildrenWithChildren, - func = null + func = null, ): Array { return React.Children.map(children, (child: React.ReactNode) => { if (!React.isValidElement(child)) { @@ -95,7 +95,7 @@ function recursiveMap( child = React.cloneElement( child, null, - recursiveMap(child.props.children, func) + recursiveMap(child.props.children, func), ) } diff --git a/packages/dnb-design-system-portal/src/uilib/search/__tests__/searchQuery.test.ts b/packages/dnb-design-system-portal/src/uilib/search/__tests__/searchQuery.test.ts index dea6a48a134..b73ee7a3416 100644 --- a/packages/dnb-design-system-portal/src/uilib/search/__tests__/searchQuery.test.ts +++ b/packages/dnb-design-system-portal/src/uilib/search/__tests__/searchQuery.test.ts @@ -22,7 +22,9 @@ describe('searchQuery', () => { it('should skip node when no title is found', () => { expect( - transformer(makeNode({ fields: { slug: '/page' }, frontmatter: {} })) + transformer( + makeNode({ fields: { slug: '/page' }, frontmatter: {} }), + ), ).toHaveLength(0) }) @@ -32,8 +34,8 @@ describe('searchQuery', () => { makeNode({ fields: { slug: '/page' }, frontmatter: { skipSearch: true }, - }) - ) + }), + ), ).toHaveLength(0) }) @@ -44,8 +46,8 @@ describe('searchQuery', () => { fields: { slug: '/page' }, frontmatter: {}, headings: [{ value: 'Heading 1', depth: 1 }], - }) - ) + }), + ), ).toEqual([{ headings: [], slug: '/page', title: 'Heading 1' }]) }) @@ -59,8 +61,8 @@ describe('searchQuery', () => { { value: 'Heading 1', depth: 1 }, { value: 'Heading 2', depth: 2 }, ], - }) - ) + }), + ), ).toEqual([ { slug: '/page', @@ -88,8 +90,8 @@ describe('searchQuery', () => { fields: { slug: '/page' }, frontmatter: { search: 'search string' }, headings: [{ value: 'Heading 1', depth: 1 }], - }) - ) + }), + ), ).toEqual([ { slug: '/page', @@ -120,8 +122,8 @@ describe('searchQuery', () => { headings: [{ value: 'Heading 2', depth: 1 }], }, ], - }) - ) + }), + ), ).toEqual([ { category: { @@ -153,8 +155,8 @@ describe('searchQuery', () => { headings: [{ value: 'Heading 2', depth: 1 }], }, ], - }) - ) + }), + ), ).toEqual([ { category: { @@ -186,8 +188,8 @@ describe('searchQuery', () => { headings: [{ value: 'Heading 1', depth: 1 }], }, ], - }) - ) + }), + ), ).toEqual([ { category: { diff --git a/packages/dnb-design-system-portal/src/uilib/search/remark-headings-plugin.js b/packages/dnb-design-system-portal/src/uilib/search/remark-headings-plugin.js index 6091913f9af..37befb2dc78 100644 --- a/packages/dnb-design-system-portal/src/uilib/search/remark-headings-plugin.js +++ b/packages/dnb-design-system-portal/src/uilib/search/remark-headings-plugin.js @@ -61,7 +61,7 @@ function makeHeadingsResolver({ reporter, cache, store, - } + }, ) if (!result) { diff --git a/packages/dnb-design-system-portal/src/uilib/search/searchHelpers.js b/packages/dnb-design-system-portal/src/uilib/search/searchHelpers.js index 97bb616f7b3..9dcb13c0253 100644 --- a/packages/dnb-design-system-portal/src/uilib/search/searchHelpers.js +++ b/packages/dnb-design-system-portal/src/uilib/search/searchHelpers.js @@ -16,7 +16,7 @@ const getIndexName = (currentBranch) => { const runQueriesWhen = (currentBranch) => { if ((process.env.ALGOLIA_API_KEY || '').length === 0) { console.info( - 'If you want to submit searchable data to Algolia, you need to request access keys and put them in a local .env file.' + 'If you want to submit searchable data to Algolia, you need to request access keys and put them in a local .env file.', ) return false } diff --git a/packages/dnb-design-system-portal/src/uilib/search/searchQuery.js b/packages/dnb-design-system-portal/src/uilib/search/searchQuery.js index 5a3cbde16db..02ebb33a863 100644 --- a/packages/dnb-design-system-portal/src/uilib/search/searchQuery.js +++ b/packages/dnb-design-system-portal/src/uilib/search/searchQuery.js @@ -51,7 +51,7 @@ const flatten = (arr) => fields: { slug }, frontmatter: { skipSearch }, }, - }) => !slug.includes('not_in_use') && skipSearch !== true + }) => !slug.includes('not_in_use') && skipSearch !== true, ) .map( ({ @@ -91,7 +91,7 @@ const flatten = (arr) => const category = siblings .reverse() .find(({ fields: { slug: _slug } }) => - slug.includes(_slug) + slug.includes(_slug), ) let newTitle = null @@ -149,7 +149,7 @@ const flatten = (arr) => } return result - } + }, ) .filter(Boolean) diff --git a/packages/dnb-eufemia/.lintstagedrc b/packages/dnb-eufemia/.lintstagedrc index 37b5c0c0eb7..a987171161f 100644 --- a/packages/dnb-eufemia/.lintstagedrc +++ b/packages/dnb-eufemia/.lintstagedrc @@ -1,6 +1,5 @@ { - "*.js": [ - "yarn prettier:js:staged", + "*.{js,ts,tsx}": [ "yarn lint:js:staged" ], "*.scss": [ @@ -10,7 +9,7 @@ "yarn lint:styles:staged", "yarn test:staged" ], - "*.{json,md}": [ + "*.{json,md,mdx}": [ "yarn prettier:other" ] } diff --git a/packages/dnb-eufemia/.prettierrc b/packages/dnb-eufemia/.prettierrc index 5490f6ff104..071343de25c 100644 --- a/packages/dnb-eufemia/.prettierrc +++ b/packages/dnb-eufemia/.prettierrc @@ -6,7 +6,7 @@ "useTabs": false, "semi": false, "bracketSameLine": false, - "trailingComma": "es5", + "trailingComma": "all", "overrides": [ { "files": "*.d.ts", diff --git a/packages/dnb-eufemia/package.json b/packages/dnb-eufemia/package.json index 2b95091c3e5..dd797624511 100644 --- a/packages/dnb-eufemia/package.json +++ b/packages/dnb-eufemia/package.json @@ -25,11 +25,9 @@ "postbuild:ci": "./scripts/postbuild/postbuild.sh", "build:cjs": "./scripts/postbuild/babel-cjs.sh", "build:clean": "rm -rf build", - "postbuild:commit": "babel-node --extensions .js,.ts,.tsx ./scripts/figma/tasks/commitChanges", "build:copy": "./scripts/postbuild/copy-build-artifacts.sh", "build:es": "./scripts/postbuild/babel-es.sh", "build:esm": "./scripts/postbuild/babel-esm.sh", - "prebuild:figma:ci": "yarn figma", "build:pack": "yarn build && yarn publish:prepare && cd ./build && yarn pack", "build:packages": "./scripts/postbuild/build-packages.sh", "build:prebuild": "babel-node --extensions .js,.ts,.tsx ./scripts/prebuild/runPrepub", @@ -39,7 +37,6 @@ "build:types:docs": "./scripts/prebuild/generate-types-docs.sh", "build:types:esm": "yarn tsc --project tsconfig.definitions.json --declarationDir ./build/esm --rootDir src", "build:types:generate": "./scripts/prebuild/generate-types.sh", - "precommit": "yarn lint-staged", "dev:packages": "nodemon --exec 'yarn build:packages && yarn build:copy' --ext js,html,json,css,scss --watch './src/**/*' --ignore './umd/*'", "dev:resources": "nodemon --exec 'babel-node --extensions .js,.ts,.tsx ./scripts/prebuild/resources/makeResourcesPackage' --ext js,html,json,css,scss --watch './build/style/**/*' --watch './scripts/**/*' --ignore '*.json'", "dev:tasks": "nodemon --exec 'babel-node --extensions .js,.ts,.tsx ./scripts/prebuild/dev' --watch 'rollup.config.js' --ext ts,js,html,json,css,scss --watch './src/components/**/*' --watch './scripts/**/*' --ignore '*.json'", @@ -48,48 +45,54 @@ "figma:icons:dev": "nodemon --exec 'babel-node --extensions .js,.ts,.tsx ./scripts/figma/updateIcons' --ignore '*.svg' --ignore '*.json'", "figma:refetch": "yarn figma --force-refetch", "figma:reset": "babel-node --extensions .js,.ts,.tsx ./scripts/figma/resetIcons && babel-node --extensions .js,.ts,.tsx ./scripts/tools/convertIcons", - "icons:dev": "nodemon --exec 'babel-node --extensions .js,.ts,.tsx ./scripts/tools/convertIcons' --ext ts --ignore '/icons/**' --ignore '*.json'", "icons:convert": "babel-node --extensions .js,.ts,.tsx ./scripts/tools/convertIcons && babel-node --extensions .js,.ts,.tsx ./scripts/figma/updateIcons", - "jest": "cross-env NODE_ICU_DATA=../../node_modules/full-icu jest", + "icons:dev": "nodemon --exec 'babel-node --extensions .js,.ts,.tsx ./scripts/tools/convertIcons' --ext ts --ignore '/icons/**' --ignore '*.json'", + "jest": "cross-env NODE_ICU_DATA=../../node_modules/full-icu NODE_OPTIONS=--experimental-vm-modules jest", "lint": "eslint --quiet ./src ./scripts", - "lint-staged": "lint-staged -d", - "lint:ci": "yarn lint:js && yarn lint:styles", + "lint:ci": "yarn lint:js && yarn lint:styles && yarn prettier:diff && yarn prettier:package", "lint:ci-needs-to-be-used-when-lint:lockfile-works": "yarn lint:lockfile && yarn lint:js && yarn lint:styles", "lint:js": "yarn lint --fix", "lint:js:staged": "eslint --quiet --fix", "lint:lockfile": "yarn lockfile-lint --path ../../yarn.lock --type yarn --validate-https --allowed-hosts yarn github.com codeload.github.com", "lint:styles": "stylelint './src/**/*{.stories.*,.scss}'", "lint:styles:staged": "stylelint './src/**/*{.stories.*,.scss}'", + "lint-staged": "lint-staged -d", "make-properties": "babel-node --extensions .js,.ts,.tsx ./scripts/prebuild/makeProperties", + "postbuild:commit": "babel-node --extensions .js,.ts,.tsx ./scripts/figma/tasks/commitChanges", + "prebuild:figma:ci": "yarn figma", + "precommit": "yarn lint-staged", + "prettier:diff": "prettier --list-different '{scripts,src}/**/*.{md,mdx,js,ts,tsx}'", + "prettier:js:staged": "prettier --config ./.prettierrc --log-level warn '{scripts,src}/**/*.{js,ts,tsx}'", + "prettier:js:write": "prettier --log-level warn --write '{scripts,src}/**/*.{js,ts,tsx}'", + "prettier:other": "prettier --log-level warn './src/**/*.{json,md,mdx}' && yarn prettier:package", + "prettier:other:staged": "prettier --log-level warn './**/*.{json,md,mdx}'", + "prettier:other:write": "prettier --log-level warn --write './src/**/*.{json,md,mdx}' && yarn prettier:package", + "prettier:package": "prettier-package-json --list-different ./package.json", + "prettier:package:write": "prettier-package-json --write ./package.json", + "prettier:styles:staged": "prettier --log-level warn --parser scss './src/**/*.scss'", + "prettier:styles:write": "prettier --log-level warn --parser scss --write './src/**/*.scss'", + "prettier:write": "yarn prettier:js:write && yarn prettier:styles:write", "publish:ci": "yarn publish:prepare && ./scripts/postbuild/publish-release.sh", "publish:dry": "dotenv semantic-release --no-ci --dry-run", "publish:prepare": "./scripts/postbuild/publish-prepare.sh", "reset": "rm -rf ./node_modules ./build", "skeleton:font": "nodemon --exec 'babel-node --extensions .js,.ts,.tsx ./scripts/tools/createSkeletonFont.js'", "start": "storybook dev -s / -p 8002 --ci --no-release-notes --no-version-updates", - "test": "jest", - "test:auto-generated-types": "jest ./postTypeGeneration.test.ts --ci --testPathIgnorePatterns=[]", - "test:ci": "jest --ci", - "test:postbuild": "jest ./postbuild.test.ts --ci --testPathIgnorePatterns=[]", - "test:screenshots": "jest --config=./jest.config.screenshots.js --maxWorkers=1 --detectOpenHandles --testPathPattern ", - "test:screenshots:ci": "jest --config=./jest.config.screenshots.js --ci --bail --maxWorkers=1", + "test": "yarn jest", + "test:auto-generated-types": "yarn jest ./postTypeGeneration.test.ts --ci --testPathIgnorePatterns=[]", + "test:ci": "yarn jest --ci", + "test:postbuild": "yarn jest ./postbuild.test.ts --ci --testPathIgnorePatterns=[]", + "test:screenshots": "yarn jest --config=./jest.config.screenshots.js --maxWorkers=1 --detectOpenHandles --testPathPattern ", + "test:screenshots:ci": "yarn jest --config=./jest.config.screenshots.js --ci --bail --maxWorkers=1", "test:screenshots:ci:update": "yarn test:screenshots:ci --maxWorkers=1 --updateSnapshot", "test:screenshots:reset": "find . -name '*.snap.png' -type f|xargs rm -f && yarn test:screenshots", - "test:screenshots:update": "jest --config=./jest.config.screenshots.js --maxWorkers=1 --updateSnapshot --testPathPattern ", + "test:screenshots:update": "yarn jest --config=./jest.config.screenshots.js --maxWorkers=1 --updateSnapshot --testPathPattern ", "test:screenshots:watch": "JEST_IMAGE_SNAPSHOT_TRACK_OBSOLETE=1 jest --config=./jest.config.screenshots.js --watchAll --detectOpenHandles --testPathPattern ", - "test:staged": "jest --bail --findRelatedTests ", + "test:staged": "yarn jest --bail --findRelatedTests ", "test:types": "tsc --noEmit", "test:types:watch": "tsc --noEmit --watch", - "test:update": "jest --updateSnapshot", - "test:watch": "jest --watchAll --testPathPattern ", - "prettier:diff": "prettier --list-different '{scripts,src}/**/*.{md,js}'", - "prettier:js": "prettier --loglevel warn --write '{scripts,src}/**/*.js'", - "prettier:js:staged": "prettier --config ./.prettierrc --loglevel warn", - "prettier:other": "prettier --loglevel warn --write './src/**/*.{json,md}' && yarn prettier:package", - "prettier:other:staged": "prettier --loglevel warn", - "prettier:package": "prettier-package-json --write ./package.json", - "prettier:styles": "prettier --loglevel warn --parser scss --write './src/**/*.scss'", - "prettier:styles:staged": "prettier --loglevel warn --parser scss" + "test:update": "yarn jest --updateSnapshot", + "test:watch": "yarn jest --watchAll --testPathPattern " }, "sideEffects": [ "*.css", @@ -191,7 +194,7 @@ "eslint": "8.17.0", "eslint-plugin-import": "2.26.0", "eslint-plugin-jsx-a11y": "6.5.1", - "eslint-plugin-prettier": "4.0.0", + "eslint-plugin-prettier": "5.0.0", "eslint-plugin-react": "7.30.0", "eslint-plugin-react-hooks": "4.5.0", "eslint-plugin-security": "1.5.0", @@ -228,8 +231,8 @@ "postcss": "8.3.11", "postcss-calc": "8.0.0", "postcss-preset-env": "6.7.0", - "prettier": "2.4.1", - "prettier-package-json": "2.6.0", + "prettier": "3.0.3", + "prettier-package-json": "2.8.0", "process": "0.11.10", "prop-types": "15.7.2", "react": "18.2.0", diff --git a/packages/dnb-eufemia/scripts/figma/FigmaAPI.ts b/packages/dnb-eufemia/scripts/figma/FigmaAPI.ts index b419e13cc1a..86f72d3f9a8 100644 --- a/packages/dnb-eufemia/scripts/figma/FigmaAPI.ts +++ b/packages/dnb-eufemia/scripts/figma/FigmaAPI.ts @@ -24,7 +24,7 @@ export const fetchFigmaIcons = async ({ }: FetchFigmaIconsOptions = {}) => { if (!figmaFile) { return log.info( - '> Figma: No "FIGMA_ICONS_FILE" defined, skipped to run fetchFigmaIcons' + '> Figma: No "FIGMA_ICONS_FILE" defined, skipped to run fetchFigmaIcons', ) } diff --git a/packages/dnb-eufemia/scripts/figma/helpers/__tests__/docHelpers.test.js b/packages/dnb-eufemia/scripts/figma/helpers/__tests__/docHelpers.test.js index 7894c96772b..d168e446882 100644 --- a/packages/dnb-eufemia/scripts/figma/helpers/__tests__/docHelpers.test.js +++ b/packages/dnb-eufemia/scripts/figma/helpers/__tests__/docHelpers.test.js @@ -30,11 +30,11 @@ describe('FigmaDoc', () => { expect(start).toHaveBeenCalledTimes(1) expect(start).toHaveBeenCalledWith( - expect.stringContaining('Fetching the figma doc') + expect.stringContaining('Fetching the figma doc'), ) expect(succeed).toHaveBeenCalledTimes(1) expect(succeed).toHaveBeenCalledWith( - expect.stringContaining('Using old Figma document') + expect.stringContaining('Using old Figma document'), ) }) }) diff --git a/packages/dnb-eufemia/scripts/figma/helpers/docHelpers.js b/packages/dnb-eufemia/scripts/figma/helpers/docHelpers.js index 5188f3d1b9b..4d8b73a8f08 100644 --- a/packages/dnb-eufemia/scripts/figma/helpers/docHelpers.js +++ b/packages/dnb-eufemia/scripts/figma/helpers/docHelpers.js @@ -58,7 +58,7 @@ export const fetchColors = (fills) => { }) .reduce((acc, c) => { acc.push( - Color([c.r * 255, c.g * 255, c.b * 255, c.a]).hex() + Color([c.r * 255, c.g * 255, c.b * 255, c.a]).hex(), // .rgb() // .string() ) @@ -80,7 +80,7 @@ export const findAll = ( childrenKey, objToFindBy, objToIgnoreBy = null, - findFirst = false + findFirst = false, ) => { const objToReturn = [] if (!tree) return objToReturn @@ -100,12 +100,12 @@ export const findAll = ( // ) // make sure we match all const findSuccess = findKeys.every((key) => - isEqualWith(tree[key], objToFindBy[key], customizer) + isEqualWith(tree[key], objToFindBy[key], customizer), ) if (objToIgnoreBy) { const ignoreKeys = Object.keys(objToIgnoreBy) ignoreSuccess = ignoreKeys.some((key) => - isEqualWith(tree[key], objToIgnoreBy[key], customizer) + isEqualWith(tree[key], objToIgnoreBy[key], customizer), ) } if (findSuccess && !ignoreSuccess) { @@ -165,7 +165,7 @@ const saveLiveVersionOfFigmaDoc = async ({ figmaFile, version }) => { JSON.stringify({ ...existingLockFileContent, ...newLockFileContent, - }) + }), ) } catch (e) { log.fail('Could not create a new "version.lock" file', e) @@ -196,7 +196,7 @@ export const getFigmaDoc = async ({ !localFile ) { ErrorHandler( - 'No Figma file defined. Make sure there is a .env file with a valid "figmaFile" defined!' + 'No Figma file defined. Make sure there is a .env file with a valid "figmaFile" defined!', ) } @@ -229,17 +229,17 @@ export const getFigmaDoc = async ({ const localVersion = await getLocalVersionFromLockFile({ figmaFile }) log.info( - `> Figma: Comparing old vs new version. (local version is ${localVersion})` + `> Figma: Comparing old vs new version. (local version is ${localVersion})`, ) if (localVersion === liveVersion) { log.succeed( - `> Figma: No newer version available. Both the local and online versions are ${liveVersion}` + `> Figma: No newer version available. Both the local and online versions are ${liveVersion}`, ) return false } else { log.succeed( - `> Figma: There is a new version available: ${liveVersion}` + `> Figma: There is a new version available: ${liveVersion}`, ) await saveLiveVersionOfFigmaDoc({ figmaFile, @@ -270,7 +270,7 @@ export const getFigmaDoc = async ({ ErrorHandler( 'Failed to client.file(figmaFile) and write the result with writeFile', e, - ERROR_HARMLESS + ERROR_HARMLESS, ) } } else { @@ -312,7 +312,7 @@ export const getFigmaUrlByImageIds = async ({ export const streamToDisk = ( { file = '.tmp/file.json', url }, - { errorExceptionType = ERROR_HARMLESS } + { errorExceptionType = ERROR_HARMLESS }, ) => new Promise((resolve, reject) => { const streamHandler = ({ localFile, oldContent = null }) => { @@ -325,8 +325,8 @@ export const streamToDisk = ( ErrorHandler( 'Failed on createWriteStream', err, - errorExceptionType - ) + errorExceptionType, + ), ) }) .on('finish', async () => { @@ -337,7 +337,7 @@ export const streamToDisk = ( if (isEmpty) { ErrorHandler( - `streamToDisk failed because the stream did not end with content by using the url: ${url}` + `streamToDisk failed because the stream did not end with content by using the url: ${url}`, ) } @@ -362,12 +362,16 @@ export const streamToDisk = ( await fs.unlink(localFile) } catch (err) { reject( - ErrorHandler('Failed on unlink', err, errorExceptionType) + ErrorHandler('Failed on unlink', err, errorExceptionType), ) } reject( - ErrorHandler('Failed on streamToDisk', err, errorExceptionType) + ErrorHandler( + 'Failed on streamToDisk', + err, + errorExceptionType, + ), ) }) } @@ -381,7 +385,7 @@ export const streamToDisk = ( ? fs.readFile(localFile, 'utf-8', (err, oldContent) => { if (err) { reject( - ErrorHandler('Failed on readFile', err, errorExceptionType) + ErrorHandler('Failed on readFile', err, errorExceptionType), ) } diff --git a/packages/dnb-eufemia/scripts/figma/resetIcons.ts b/packages/dnb-eufemia/scripts/figma/resetIcons.ts index b74374554e9..8a86dd7e21f 100644 --- a/packages/dnb-eufemia/scripts/figma/resetIcons.ts +++ b/packages/dnb-eufemia/scripts/figma/resetIcons.ts @@ -19,14 +19,14 @@ export const runFigmaReset = async () => { } const svgLockFile = path.resolve( __dirname, - '../../src/icons/icons-svg.lock' + '../../src/icons/icons-svg.lock', ) if (fs.existsSync(svgLockFile)) { await fs.unlink(svgLockFile) } const pdfLockFile = path.resolve( __dirname, - '../../src/icons/icons-pdf.lock' + '../../src/icons/icons-pdf.lock', ) if (fs.existsSync(pdfLockFile)) { await fs.unlink(pdfLockFile) @@ -44,5 +44,5 @@ runFigmaReset().then(() => ignoreBranchCheck: true, }).then(() => { log.succeed('Resetting Figma is done') - }) + }), ) diff --git a/packages/dnb-eufemia/scripts/figma/tasks/__tests__/assetsExtractors.test.ts b/packages/dnb-eufemia/scripts/figma/tasks/__tests__/assetsExtractors.test.ts index 5f7c52bdbb3..9adffb4abb4 100644 --- a/packages/dnb-eufemia/scripts/figma/tasks/__tests__/assetsExtractors.test.ts +++ b/packages/dnb-eufemia/scripts/figma/tasks/__tests__/assetsExtractors.test.ts @@ -16,10 +16,10 @@ import { } from '../assetsExtractors' const localFile = require.resolve( - '../../helpers/__tests__/files/FigmaTestDoc.json' + '../../helpers/__tests__/files/FigmaTestDoc.json', ) const iconsLockFile = require.resolve( - '../../helpers/__tests__/files/icons-svg.lock' + '../../helpers/__tests__/files/icons-svg.lock', ) afterEach(() => { @@ -164,7 +164,7 @@ describe('assetsExtractors', () => { expect(config).toHaveProperty('imageUrlExpireAfterDays') expect(config).toHaveProperty('destDir') expect(config.iconsLockFile).toContain( - 'packages/dnb-eufemia/src/icons/icons-svg.lock' + 'packages/dnb-eufemia/src/icons/icons-svg.lock', ) expect(config.destDir).toContain('/packages/dnb-eufemia/assets/icons') }) @@ -206,18 +206,18 @@ describe('assetsExtractors', () => { expect(fs.rmdir).toHaveBeenNthCalledWith( 1, expect.stringContaining( - '/packages/dnb-eufemia/assets/icons/dnb/objects' - ) + '/packages/dnb-eufemia/assets/icons/dnb/objects', + ), ) expect(runCommand).toHaveBeenCalledTimes(1) expect(runCommand).toHaveBeenNthCalledWith( 1, - expect.stringContaining('yarn vd-tool -c -in') + expect.stringContaining('yarn vd-tool -c -in'), ) expect(runCommand).toHaveBeenNthCalledWith( 1, - expect.stringContaining('/packages/dnb-eufemia/assets/icons/dnb') + expect.stringContaining('/packages/dnb-eufemia/assets/icons/dnb'), ) expect(tar.create).toHaveBeenCalledTimes(3) @@ -228,29 +228,29 @@ describe('assetsExtractors', () => { file: expect.stringContaining('/assets/icons/dnb/tmp.tgz'), gzip: true, }, - ['bell_medium.xml', 'bell.xml'] + ['bell_medium.xml', 'bell.xml'], ) expect(tar.create).toHaveBeenNthCalledWith( 2, { cwd: expect.stringContaining('/assets/icons'), file: expect.stringContaining( - '/assets/icons/dnb/eufemia-icons-xml.tgz' + '/assets/icons/dnb/eufemia-icons-xml.tgz', ), gzip: true, }, - ['bell_medium.xml', 'bell.xml'] + ['bell_medium.xml', 'bell.xml'], ) expect(tar.create).toHaveBeenNthCalledWith( 3, { cwd: expect.stringContaining('/assets/icons'), file: expect.stringContaining( - '/assets/icons/dnb/eufemia-icons-xml-categorized.tgz' + '/assets/icons/dnb/eufemia-icons-xml-categorized.tgz', ), gzip: true, }, - ['objects/bell_medium.xml', 'objects/bell.xml'] + ['objects/bell_medium.xml', 'objects/bell.xml'], ) }) @@ -261,143 +261,143 @@ describe('assetsExtractors', () => { expect(start).toHaveBeenNthCalledWith( 3, expect.stringContaining( - 'Starting to fetch 2 icons from the "Icons" Canvas' - ) + 'Starting to fetch 2 icons from the "Icons" Canvas', + ), ) expect(info).toHaveBeenCalledTimes(9) expect(info).toHaveBeenNthCalledWith( 1, expect.stringContaining( - 'Saved file bell_medium.svg (ID=2:63, CREATED=1577836800000)' - ) + 'Saved file bell_medium.svg (ID=2:63, CREATED=1577836800000)', + ), ) expect(info).toHaveBeenNthCalledWith( 2, expect.stringContaining( - 'Saved file bell.svg (ID=41:2, CREATED=1577836800000)' - ) + 'Saved file bell.svg (ID=41:2, CREATED=1577836800000)', + ), ) expect(info).toHaveBeenNthCalledWith( 3, expect.stringContaining( - 'finished fetching SVGs icons by using frameIconsFactory. Processed 2 files along with 2 new files.' - ) + 'finished fetching SVGs icons by using frameIconsFactory. Processed 2 files along with 2 new files.', + ), ) expect(info).toHaveBeenNthCalledWith( 4, - expect.stringContaining('Icon was optimized: bell_medium.svg') + expect.stringContaining('Icon was optimized: bell_medium.svg'), ) expect(info).toHaveBeenNthCalledWith( 5, - expect.stringContaining('Icon was optimized: bell.svg') + expect.stringContaining('Icon was optimized: bell.svg'), ) expect(info).toHaveBeenNthCalledWith( 6, - expect.stringContaining('started to create eufemia-icons-xml.tgz') + expect.stringContaining('started to create eufemia-icons-xml.tgz'), ) expect(info).toHaveBeenNthCalledWith( 7, - expect.stringContaining('convert SVG to XML') + expect.stringContaining('convert SVG to XML'), ) expect(info).toHaveBeenNthCalledWith( 8, expect.stringContaining( - '/dnb-eufemia/src/icons/dnb/icons-svg.lock file got generated' - ) + '/dnb-eufemia/src/icons/dnb/icons-svg.lock file got generated', + ), ) expect(info).toHaveBeenNthCalledWith( 9, - expect.stringContaining('icons-meta.json file got generated') + expect.stringContaining('icons-meta.json file got generated'), ) expect(succeed).toHaveBeenCalledTimes(2) expect(succeed).toHaveBeenNthCalledWith( 1, - expect.stringContaining('Using old Figma document') + expect.stringContaining('Using old Figma document'), ) expect(succeed).toHaveBeenNthCalledWith( 2, - expect.stringContaining('finished to create eufemia-icons-xml.tgz') + expect.stringContaining('finished to create eufemia-icons-xml.tgz'), ) expect(fs.move).toHaveBeenCalledTimes(2) expect(fs.move).toHaveBeenNthCalledWith( 1, expect.stringContaining('/assets/icons/dnb/bell_medium.xml'), - expect.stringContaining('/assets/icons/dnb/objects/bell_medium.xml') + expect.stringContaining('/assets/icons/dnb/objects/bell_medium.xml'), ) expect(fs.move).toHaveBeenNthCalledWith( 2, expect.stringContaining('/assets/icons/dnb/bell.xml'), - expect.stringContaining('/assets/icons/dnb/objects/bell.xml') + expect.stringContaining('/assets/icons/dnb/objects/bell.xml'), ) expect(fs.unlink).toHaveBeenCalledTimes(5) expect(fs.unlink).toHaveBeenNthCalledWith( 1, - expect.stringContaining('/assets/icons/dnb/tmp.tgz') + expect.stringContaining('/assets/icons/dnb/tmp.tgz'), ) expect(fs.unlink).toHaveBeenNthCalledWith( 2, - expect.stringContaining('/assets/icons/dnb/objects/bell_medium.xml') + expect.stringContaining('/assets/icons/dnb/objects/bell_medium.xml'), ) expect(fs.unlink).toHaveBeenNthCalledWith( 3, - expect.stringContaining('/assets/icons/dnb/objects/bell.xml') + expect.stringContaining('/assets/icons/dnb/objects/bell.xml'), ) expect(fs.unlink).toHaveBeenNthCalledWith( 4, - expect.stringContaining('/assets/icons/dnb/bell_medium.xml') + expect.stringContaining('/assets/icons/dnb/bell_medium.xml'), ) expect(fs.unlink).toHaveBeenNthCalledWith( 5, - expect.stringContaining('/assets/icons/dnb/bell.xml') + expect.stringContaining('/assets/icons/dnb/bell.xml'), ) expect(fs.readFile).toHaveBeenCalledTimes(8) expect(fs.readFile).toHaveBeenNthCalledWith( 1, expect.stringContaining( - '/scripts/figma/helpers/__tests__/files/FigmaTestDoc.json' - ) + '/scripts/figma/helpers/__tests__/files/FigmaTestDoc.json', + ), ) expect(fs.readFile).toHaveBeenNthCalledWith( 2, expect.stringContaining( - '/scripts/figma/helpers/__tests__/files/icons-svg.lock' + '/scripts/figma/helpers/__tests__/files/icons-svg.lock', ), - 'utf-8' + 'utf-8', ) expect(fs.readFile).toHaveBeenNthCalledWith( 3, expect.stringContaining('/assets/icons/dnb/bell_medium.svg'), 'utf-8', - expect.any(Function) + expect.any(Function), ) expect(fs.readFile).toHaveBeenNthCalledWith( 4, expect.stringContaining('/assets/icons/dnb/bell_medium.svg'), - 'utf-8' + 'utf-8', ) expect(fs.readFile).toHaveBeenNthCalledWith( 5, expect.stringContaining('/assets/icons/dnb/bell.svg'), 'utf-8', - expect.any(Function) + expect.any(Function), ) expect(fs.readFile).toHaveBeenNthCalledWith( 6, expect.stringContaining('/assets/icons/dnb/bell.svg'), - 'utf-8' + 'utf-8', ) expect(fs.readFile).toHaveBeenNthCalledWith( 7, expect.stringContaining('/assets/icons/dnb/bell_medium.svg'), - 'utf-8' + 'utf-8', ) expect(fs.readFile).toHaveBeenNthCalledWith( 8, expect.stringContaining('/assets/icons/dnb/bell.svg'), - 'utf-8' + 'utf-8', ) expect(fs.writeFile).toHaveBeenCalledTimes(4) @@ -405,24 +405,24 @@ describe('assetsExtractors', () => { expect(fs.writeFile).toHaveBeenNthCalledWith( 1, expect.stringContaining( - '/dnb-eufemia/assets/icons/dnb/bell_medium.svg' + '/dnb-eufemia/assets/icons/dnb/bell_medium.svg', ), expect.stringContaining( - `` - ) + ``, + ), ) expect(fs.writeFile).toHaveBeenNthCalledWith( 2, expect.stringContaining('/dnb-eufemia/assets/icons/dnb/bell.svg'), expect.stringContaining( - `` - ) + ``, + ), ) expect(fs.writeFile).toHaveBeenNthCalledWith( 3, expect.stringContaining('/dnb-eufemia/src/icons/dnb/icons-svg.lock'), expect.stringContaining( - formatIconsMetaFile({ + await formatIconsMetaFile({ 'bell_medium.svg': { iconName: 'bell_medium', name: 'bell', @@ -449,14 +449,14 @@ describe('assetsExtractors', () => { created: 1577836800000, updated: 1577836800000, }, - }) - ) + }), + ), ) expect(fs.writeFile).toHaveBeenNthCalledWith( 4, expect.stringContaining('/dnb-eufemia/src/icons/icons-meta.json'), expect.stringContaining( - formatIconsMetaFile({ + await formatIconsMetaFile({ bell_medium: { tags: [ 'component-tag-24', @@ -485,8 +485,8 @@ describe('assetsExtractors', () => { variant: 'primary', category: 'objects', }, - }) - ) + }), + ), ) expect(result).toHaveLength(2) @@ -520,7 +520,7 @@ describe('assetsExtractors', () => { url: 'file:./12b63b85ba08cf1588a42fb69cb9654c', variant: 'primary', }, - ]) + ]), ) }) }) diff --git a/packages/dnb-eufemia/scripts/figma/tasks/assetsExtractors.ts b/packages/dnb-eufemia/scripts/figma/tasks/assetsExtractors.ts index c08b3481f1d..cb80c5f07b1 100644 --- a/packages/dnb-eufemia/scripts/figma/tasks/assetsExtractors.ts +++ b/packages/dnb-eufemia/scripts/figma/tasks/assetsExtractors.ts @@ -61,7 +61,7 @@ type IconsConfig = { export function IconsConfig(overwrite: IconsConfig = {}) { if (overwrite?.assetsDir && /^\//.test(overwrite.assetsDir)) { log.fail( - ErrorHandler('assetsDir should not start with a slash (/dir)') + ErrorHandler('assetsDir should not start with a slash (/dir)'), ) } @@ -77,13 +77,13 @@ export function IconsConfig(overwrite: IconsConfig = {}) { const destDir = path.resolve( __dirname, '../../../assets/icons', - overwrite?.assetsDir || '' + overwrite?.assetsDir || '', ) const iconsLockFile = path.resolve( __dirname, '../../../src/icons', overwrite?.assetsDir || '', - 'icons-svg.lock' + 'icons-svg.lock', ) return { @@ -102,7 +102,10 @@ export function IconsConfig(overwrite: IconsConfig = {}) { } const prettierrc = JSON.parse( - fs.readFileSync(path.resolve(__dirname, '../../../.prettierrc'), 'utf-8') + fs.readFileSync( + path.resolve(__dirname, '../../../.prettierrc'), + 'utf-8', + ), ) export const extractIcons = async ({ @@ -128,7 +131,7 @@ export const extractIcons = async ({ }) log.start( - '> Figma: started to fetch SVGs icons by using frameIconsFactory' + '> Figma: started to fetch SVGs icons by using frameIconsFactory', ) const { listOfProcessedFiles, listWithNewFiles } = @@ -142,7 +145,7 @@ export const extractIcons = async ({ }) log.info( - `> Figma: finished fetching SVGs icons by using frameIconsFactory. Processed ${listOfProcessedFiles.length} files along with ${listWithNewFiles.length} new files.` + `> Figma: finished fetching SVGs icons by using frameIconsFactory. Processed ${listOfProcessedFiles.length} files along with ${listWithNewFiles.length} new files.`, ) if (listWithNewFiles.length > 0) { @@ -216,7 +219,7 @@ async function collectIconsFromFigmaDoc({ listWithNewFiles.push(...newFiles) return files - } + }, ) runDiffControll({ controllStorageLists }) @@ -235,7 +238,7 @@ const runDiffControll = ({ controllStorageLists }) => { const getDiff = (a, b) => a.filter( ({ name }) => - !b.some(({ name: n }) => removeSizes(n) === removeSizes(name)) + !b.some(({ name: n }) => removeSizes(n) === removeSizes(name)), ) controllStorageLists.forEach((cur, i, arr) => { @@ -254,8 +257,8 @@ const runDiffControll = ({ controllStorageLists }) => { `> Figma: Detected a difference between the frames!. Here are the differences:\n ${JSON.stringify( collectDiff, null, - 4 - )}` + 4, + )}`, ) } } @@ -303,7 +306,7 @@ const frameIconsFactory = async ({ const underlineLimit = 4 if (iconName.split(/_/g).length > underlineLimit) { log.fail( - `${iconName} was skipped, cause it had more than ${underlineLimit} parts on name split by _` + `${iconName} was skipped, cause it had more than ${underlineLimit} parts on name split by _`, ) return acc } @@ -320,7 +323,7 @@ const frameIconsFactory = async ({ return acc }, - [] + [], ) // check if lock file exists @@ -335,7 +338,7 @@ const frameIconsFactory = async ({ const listOfCachedIconUrls = Object.entries(oldLockFileContent) .filter( ([file, { id, url, slug }]) => - file && id && url && slug === md5(figmaFile + frameId) + file && id && url && slug === md5(figmaFile + frameId), ) // define the same format as we get from "getFigmaUrlByImageIds" .map(([file, { id, url, updated }]) => ({ @@ -352,7 +355,7 @@ const frameIconsFactory = async ({ if (found) { // Check if created has passed 30 days const countDays = Math.ceil( - (Date.now() - found.updated) / (1e3 * 60 * 60 * 24) + (Date.now() - found.updated) / (1e3 * 60 * 60 * 24), ) const outdated = countDays > imageUrlExpireAfterDays @@ -365,7 +368,7 @@ const frameIconsFactory = async ({ }) log.start( - `> Figma: Starting to fetch ${iconIdsToFetchFrom.length} icons from the "${originalFrameName}" Canvas` + `> Figma: Starting to fetch ${iconIdsToFetchFrom.length} icons from the "${originalFrameName}" Canvas`, ) // go and load additional images @@ -374,7 +377,7 @@ const frameIconsFactory = async ({ figmaFile, ids: iconIdsToFetchFrom.map(({ id }) => id), params: { format }, - }) + }), ).map(([id, url]) => ({ id, url, @@ -397,7 +400,7 @@ const frameIconsFactory = async ({ // clean the list of icons we will process .map(({ id, url }) => { const existingObject = listOfIconObjectsFromDoc.find( - ({ id: i }) => i === id + ({ id: i }) => i === id, ) return { @@ -421,11 +424,11 @@ const frameIconsFactory = async ({ return acc }, - rawListOfIconsToProcess + rawListOfIconsToProcess, ) log.start( - `> Figma: Starting to fetch process ${listOfIconsToProcess.length} icons` + `> Figma: Starting to fetch process ${listOfIconsToProcess.length} icons`, ) const listOfProcessedFiles = ( @@ -480,7 +483,7 @@ const frameIconsFactory = async ({ // Check if created has passed 30 days const countDays = Math.ceil( (Date.now() - lockFileFrameContent?.updated) / - (1e3 * 60 * 60 * 24) + (1e3 * 60 * 60 * 24), ) if (countDays > imageUrlExpireAfterDays) { existsAndIsValid = false @@ -491,7 +494,7 @@ const frameIconsFactory = async ({ ret.updated = lockFileFrameContent?.updated log.info( - `> Figma: File already exists: ${iconFile} (ID=${id}, CREATED=${ret.created})` + `> Figma: File already exists: ${iconFile} (ID=${id}, CREATED=${ret.created})`, ) existingFiles.push(ret) @@ -503,7 +506,7 @@ const frameIconsFactory = async ({ }, { errorExceptionType: ERROR_HARMLESS, - } + }, ) let streamResult = null @@ -519,8 +522,8 @@ const frameIconsFactory = async ({ if (streamResult === 'ACCESS_DENIED') { log.fail( ErrorHandler( - `> Figma: Failed to stream content of (${iconName}): ${content}` - ) + `> Figma: Failed to stream content of (${iconName}): ${content}`, + ), ) } @@ -539,7 +542,7 @@ const frameIconsFactory = async ({ newFiles.push(ret) log.info( - `> Figma: Saved file ${iconFile} (ID=${id}, CREATED=${ret.created})` + `> Figma: Saved file ${iconFile} (ID=${id}, CREATED=${ret.created})`, ) } } @@ -548,7 +551,7 @@ const frameIconsFactory = async ({ } catch (e) { log.fail(ErrorHandler('Failed to process new icons', e)) } - } + }, ) ).filter(Boolean) @@ -577,15 +580,15 @@ const prerenderIconName = (name, size = null) => { iconName = iconRenameList.reduce( (acc, cur) => (cur.from === acc ? cur.to : acc), - iconName + iconName, ) const isReservedWord = reservedJavaScriptWords.some( - (name) => name === iconName + (name) => name === iconName, ) if (isReservedWord) { log.fail( - `\nReserved name found for icon "${iconName}" ā€“ it got renamed to "${iconName}_1".\n\n\n` + `\nReserved name found for icon "${iconName}" ā€“ it got renamed to "${iconName}_1".\n\n\n`, ) iconName = `${iconName}_1` } @@ -645,7 +648,7 @@ const makeMetaFile = async ({ suffix ? iconName.replace(NAME_SEPARATOR + suffix, '') : iconName, - iconName + iconName, ) tags = tags.filter((item, index) => { if (item === cleanedName) { @@ -676,10 +679,10 @@ const makeMetaFile = async ({ } return acc }, - {} + {}, ) - await saveToFile(iconsMetaFile, formatIconsMetaFile(data)) + await saveToFile(iconsMetaFile, await formatIconsMetaFile(data)) log.info('> Figma: icons-meta.json file got generated') } @@ -720,7 +723,7 @@ const createXMLTarBundles = async ({ ({ iconFile, ...rest }) => { const iconFileXML = iconFile.replace(/\.svg$/, '.xml') return { iconFile, iconFileXML, ...rest } - } + }, ) await convertSvgToXml() @@ -741,7 +744,7 @@ const createXMLTarBundles = async ({ await runCommand(`yarn vd-tool -c -in ${destDir}`) } catch (error) { log.fail( - `> Figma: failed to convert SVG to XML in ${destDir}\n\n${error}` + `> Figma: failed to convert SVG to XML in ${destDir}\n\n${error}`, ) } } @@ -757,7 +760,7 @@ const createXMLTarBundles = async ({ async function hasSizeChanged() { const fileList = listOfProcessedFiles.map( - ({ iconFileXML }) => iconFileXML + ({ iconFileXML }) => iconFileXML, ) const tmp = path.resolve(destDir, 'tmp.tgz') @@ -767,7 +770,7 @@ const createXMLTarBundles = async ({ cwd: destDir, file: tmp, }, - fileList + fileList, ) const tmpSize = (await fs.stat(tmp)).size @@ -778,7 +781,7 @@ const createXMLTarBundles = async ({ async function createTarWithoutCategories() { const fileList = listOfProcessedFiles.map( - ({ iconFileXML }) => iconFileXML + ({ iconFileXML }) => iconFileXML, ) await create( @@ -787,7 +790,7 @@ const createXMLTarBundles = async ({ cwd: destDir, file: tarFile, }, - fileList + fileList, ) } @@ -801,11 +804,11 @@ const createXMLTarBundles = async ({ if (fs.existsSync(source)) { await fs.move(source, dest) } - } + }, ) const fileList = listOfProcessedFiles.map( - ({ category, iconFileXML }) => `${category}/${iconFileXML}` + ({ category, iconFileXML }) => `${category}/${iconFileXML}`, ) const tarFile = path.resolve(destDir, outputNameCategorized) @@ -815,7 +818,7 @@ const createXMLTarBundles = async ({ cwd: destDir, file: tarFile, }, - fileList + fileList, ) // Empty category dir @@ -893,7 +896,7 @@ const insertInlineStylesToSVG = (svg) => { if (acc.includes(val)) { acc = acc.replace( /(fill|stroke)="([^"]*)"/g, - `style="$1:var(${key})" $1="$2"` + `style="$1:var(${key})" $1="$2"`, ) } return acc @@ -929,7 +932,7 @@ export const readIconsLockFile = async ({ file }) => { if (fs.existsSync(file)) { try { return JSON.parse( - (await fs.readFile(file, 'utf-8')) || '{}' + (await fs.readFile(file, 'utf-8')) || '{}', ) as IconsLockFileMap } catch (e) { log.fail('Failed to read the lock file and parse the result') @@ -940,17 +943,17 @@ export const readIconsLockFile = async ({ file }) => { return {} as IconsLockFileMap } export const saveIconsLockFile = async ({ file, data }) => { - await saveToFile(file, formatIconsMetaFile(data)) + await saveToFile(file, await formatIconsMetaFile(data)) log.info(`> Figma: ${file} file got generated`) } const iconsMetaFile = path.resolve( __dirname, - '../../../src/icons/icons-meta.json' + '../../../src/icons/icons-meta.json', ) -export const formatIconsMetaFile = (data) => { - return prettier.format(JSON.stringify(data), { +export const formatIconsMetaFile = async (data) => { + return await prettier.format(JSON.stringify(data), { ...prettierrc, filepath: iconsMetaFile, }) diff --git a/packages/dnb-eufemia/scripts/figma/tasks/makeStyleFromFigmaDoc.js b/packages/dnb-eufemia/scripts/figma/tasks/makeStyleFromFigmaDoc.js index be2ddfc9f48..ee4ab22cff1 100644 --- a/packages/dnb-eufemia/scripts/figma/tasks/makeStyleFromFigmaDoc.js +++ b/packages/dnb-eufemia/scripts/figma/tasks/makeStyleFromFigmaDoc.js @@ -34,7 +34,7 @@ export const makeScssFromFigmaDoc = ( prependKey = null, subkeyToFind = null, doReturnExpression = false, - } = {} + } = {}, ) => { if (!value) return null @@ -121,7 +121,7 @@ const findexistingSassVars = ({ const index = entries.find( ([key]) => key === `${prependKey}-${keyToFind}` || - key === `${prependKey}-${subkeyToFind}-${keyToFind}` + key === `${prependKey}-${subkeyToFind}-${keyToFind}`, ) let res = index && index.length > 0 ? index[1] : null if (typeof res === 'string') { diff --git a/packages/dnb-eufemia/scripts/figma/tasks/makeStylePrettier.js b/packages/dnb-eufemia/scripts/figma/tasks/makeStylePrettier.js index 7f9ccbfdea7..a4ce613f341 100644 --- a/packages/dnb-eufemia/scripts/figma/tasks/makeStylePrettier.js +++ b/packages/dnb-eufemia/scripts/figma/tasks/makeStylePrettier.js @@ -5,8 +5,8 @@ import prettier from 'prettier' -export const makeStylePrettier = (style) => - prettier.format(style, { +export const makeStylePrettier = async (style) => + await prettier.format(style, { filepath: `file.scss`, printWidth: 75, tabWidth: 2, diff --git a/packages/dnb-eufemia/scripts/lib/error.ts b/packages/dnb-eufemia/scripts/lib/error.ts index df5fc6ddc64..8e788bc794e 100644 --- a/packages/dnb-eufemia/scripts/lib/error.ts +++ b/packages/dnb-eufemia/scripts/lib/error.ts @@ -11,7 +11,7 @@ type ErrorHandlerMessage = string function ErrorHandler( message: ErrorHandlerMessage, error = null, - code = ERROR_HARMLESS + code = ERROR_HARMLESS, ): string { if (error === null && typeof message !== 'string') { error = message diff --git a/packages/dnb-eufemia/scripts/postbuild/__tests__/postbuild.test.ts b/packages/dnb-eufemia/scripts/postbuild/__tests__/postbuild.test.ts index 3c921cf745a..b19a62a6705 100644 --- a/packages/dnb-eufemia/scripts/postbuild/__tests__/postbuild.test.ts +++ b/packages/dnb-eufemia/scripts/postbuild/__tests__/postbuild.test.ts @@ -34,9 +34,9 @@ describe('type definitions', () => { fs.existsSync( path.resolve( packpath.self(), - `build${stage}/components/Input.d.ts` - ) - ) + `build${stage}/components/Input.d.ts`, + ), + ), ).toBe(true) // To ensure babel did not compile the d.ts file @@ -44,16 +44,16 @@ describe('type definitions', () => { fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/components/input/Input.d.ts` + `build${stage}/components/input/Input.d.ts`, ), - 'utf-8' - ) + 'utf-8', + ), ).toMatch(/export interface/g) // Test the output of js files const file = path.resolve( packpath.self(), - `build${stage}/components/input/Input.d.ts` + `build${stage}/components/input/Input.d.ts`, ) expect(fs.existsSync(file)).toBe(true) @@ -61,10 +61,10 @@ describe('type definitions', () => { const content = fs.readFileSync(file, 'utf-8') expect(content).toContain('export interface InputProps') expect(content).toContain( - "extends Omit, 'ref'>," + "extends Omit, 'ref'>,", ) expect(content).toContain('SpacingProps') - } + }, ) it.each(buildStages)( @@ -75,11 +75,11 @@ describe('type definitions', () => { // Test the output of tsx files const tsxFile = path.resolve( packpath.self(), - `build${stage}/components/breadcrumb/Breadcrumb.tsx` + `build${stage}/components/breadcrumb/Breadcrumb.tsx`, ) const dtsFile = path.resolve( packpath.self(), - `build${stage}/components/breadcrumb/Breadcrumb.d.ts` + `build${stage}/components/breadcrumb/Breadcrumb.d.ts`, ) expect(fs.existsSync(tsxFile)).toBe(false) @@ -87,7 +87,7 @@ describe('type definitions', () => { const content = fs.readFileSync(dtsFile, 'utf-8') expect(content).toContain('export interface BreadcrumbProps') - } + }, ) }) @@ -122,7 +122,7 @@ describe('babel build', () => { // In case the git CLI command fails, we do not want to break the run console.error( 'Could not run the CLI command to get the commited files (getCommittedFiles)', - error + error, ) } }) @@ -134,22 +134,25 @@ describe('babel build', () => { { const content = fs.readFileSync( path.resolve(packpath.self(), `build${stage}/index.js`), - 'utf-8' + 'utf-8', ) expect(content).toContain( - 'Object.defineProperty(exports, "__esModule", {' + 'Object.defineProperty(exports, "__esModule", {', ) expect(content).toContain(`var _default = {};`) // Has extra cjs package expect( fs.existsSync( - path.resolve(packpath.self(), `build${stage}/package.json`) - ) + path.resolve( + packpath.self(), + `build${stage}/package.json`, + ), + ), ).toBe(true) const packageJson = fs.readJsonSync( - path.resolve(packpath.self(), `build${stage}/package.json`) + path.resolve(packpath.self(), `build${stage}/package.json`), ) expect(packageJson.type).toBe('commonjs') @@ -159,9 +162,9 @@ describe('babel build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/components/input/Input.js` + `build${stage}/components/input/Input.js`, ), - 'utf-8' + 'utf-8', ) expect(content).toContain('class Input extends') expect(content).toMatch(/^"use strict";/g) @@ -171,9 +174,9 @@ describe('babel build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/components/breadcrumb/Breadcrumb.js` + `build${stage}/components/breadcrumb/Breadcrumb.js`, ), - 'utf-8' + 'utf-8', ) expect(content).toContain('var _default = Breadcrumb') expect(content).toMatch(/^"use strict";/g) @@ -188,7 +191,7 @@ describe('babel build', () => { { const content = fs.readFileSync( path.resolve(packpath.self(), `build${stage}/index.js`), - 'utf-8' + 'utf-8', ) expect(content).toContain('export default {};') } @@ -197,14 +200,14 @@ describe('babel build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/components/input/Input.js` + `build${stage}/components/input/Input.js`, ), - 'utf-8' + 'utf-8', ) expect(content).toContain('export default class Input extends') expect(content).not.toContain('core-js/modules/es') expect(content).toContain( - 'import _extends from "@babel/runtime/helpers/esm/extends";' + 'import _extends from "@babel/runtime/helpers/esm/extends";', ) } @@ -212,13 +215,13 @@ describe('babel build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/components/breadcrumb/Breadcrumb.js` + `build${stage}/components/breadcrumb/Breadcrumb.js`, ), - 'utf-8' + 'utf-8', ) expect(content).toContain('export default Breadcrumb;') expect(content).toContain( - 'import _extends from "@babel/runtime/helpers/esm/extends";' + 'import _extends from "@babel/runtime/helpers/esm/extends";', ) } } @@ -229,7 +232,7 @@ describe('babel build', () => { { const content = fs.readFileSync( path.resolve(packpath.self(), `build${stage}/index.js`), - 'utf-8' + 'utf-8', ) expect(content).toContain('export default {};') } @@ -238,14 +241,14 @@ describe('babel build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/components/input/Input.js` + `build${stage}/components/input/Input.js`, ), - 'utf-8' + 'utf-8', ) expect(content).toMatch(/export default class Input extends/g) expect(content).not.toContain('core-js/modules/es') expect(content).toContain( - 'import _extends from "@babel/runtime/helpers/esm/extends";' + 'import _extends from "@babel/runtime/helpers/esm/extends";', ) } @@ -253,14 +256,14 @@ describe('babel build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/components/breadcrumb/Breadcrumb.js` + `build${stage}/components/breadcrumb/Breadcrumb.js`, ), - 'utf-8' + 'utf-8', ) expect(content).toContain('export default Breadcrumb;') expect(content).not.toContain('core-js/modules/es') expect(content).toContain( - 'import _extends from "@babel/runtime/helpers/esm/extends";' + 'import _extends from "@babel/runtime/helpers/esm/extends";', ) } } @@ -271,8 +274,8 @@ describe('babel build', () => { expect( fs.existsSync( - path.resolve(packpath.self(), `build${stage}/components/Input.js`) - ) + path.resolve(packpath.self(), `build${stage}/components/Input.js`), + ), ).toBe(true) }) }) @@ -288,9 +291,9 @@ describe('rollup build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/dnb-ui-lib.min.mjs` + `build${stage}/dnb-ui-lib.min.mjs`, ), - 'utf-8' + 'utf-8', ) expect(content).toContain(`import*as `) expect(content).toContain(` from"react-dom";`) @@ -305,9 +308,9 @@ describe('rollup build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/dnb-ui-lib.min.js` + `build${stage}/dnb-ui-lib.min.js`, ), - 'utf-8' + 'utf-8', ) expect(content).toContain('require("react")') expect(content).toContain('require("react-dom")') @@ -326,9 +329,9 @@ describe('style build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/style/dnb-ui-basis.scss` + `build${stage}/style/dnb-ui-basis.scss`, ), - 'utf-8' + 'utf-8', ) expect(content).toContain(`@import './core/scopes.scss';`) expect(content).toContain(` @@ -336,7 +339,7 @@ describe('style build', () => { @include bodyDefault(); }`) expect(content).toContain( - `@import './core/helper-classes/helper-classes.scss';` + `@import './core/helper-classes/helper-classes.scss';`, ) } @@ -344,15 +347,15 @@ describe('style build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/style/themes/theme-ui/ui-theme-basis.scss` + `build${stage}/style/themes/theme-ui/ui-theme-basis.scss`, ), - 'utf-8' + 'utf-8', ) expect(content).toContain(`@import './properties.scss';`) expect(content).toContain(`@import './fonts.scss';`) expect(content).toContain(`@import './ui-theme-elements.scss';`) expect(content).not.toContain( - `@import '../../dnb-ui-elements.scss';` + `@import '../../dnb-ui-elements.scss';`, ) } @@ -360,15 +363,15 @@ describe('style build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/style/themes/theme-sbanken/sbanken-theme-basis.scss` + `build${stage}/style/themes/theme-sbanken/sbanken-theme-basis.scss`, ), - 'utf-8' + 'utf-8', ) expect(content).toContain(`@import './properties.scss';`) expect(content).toContain(`@import './fonts.scss';`) expect(content).toContain(`@import './sbanken-theme-elements.scss';`) expect(content).not.toContain( - `@import '../../dnb-ui-elements.scss';` + `@import '../../dnb-ui-elements.scss';`, ) } @@ -376,15 +379,15 @@ describe('style build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/style/dnb-ui-core.css` + `build${stage}/style/dnb-ui-core.css`, ), - 'utf-8' + 'utf-8', ) expect(content).toMatch( - /\.dnb-core-style {([\r\n][^}]*)+font-family: var\(--font-family-default\);/ + /\.dnb-core-style {([\r\n][^}]*)+font-family: var\(--font-family-default\);/, ) expect(content).toMatch( - /html {([\r\n][^}]*)+line-height: var\(--line-height-basis\);/ + /html {([\r\n][^}]*)+line-height: var\(--line-height-basis\);/, ) } @@ -392,15 +395,15 @@ describe('style build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/style/dnb-ui-basis.css` + `build${stage}/style/dnb-ui-basis.css`, ), - 'utf-8' + 'utf-8', ) expect(content).toMatch( - /\.dnb-core-style {([\r\n][^}]*)+font-family: var\(--font-family-default\);/ + /\.dnb-core-style {([\r\n][^}]*)+font-family: var\(--font-family-default\);/, ) expect(content).not.toMatch( - /html {([\r\n][^}]*)+line-height: var\(--line-height-basis\);/ + /html {([\r\n][^}]*)+line-height: var\(--line-height-basis\);/, ) } @@ -408,17 +411,17 @@ describe('style build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/style/themes/theme-ui/ui-theme-basis.css` + `build${stage}/style/themes/theme-ui/ui-theme-basis.css`, ), - 'utf-8' + 'utf-8', ) expect(content).toContain( - `--font-family-default: "DNB", sans-serif;` + `--font-family-default: "DNB", sans-serif;`, ) expect(content).toContain(`.dnb-typo-regular`) expect(content).toContain(`@font-face`) expect(content).toContain( - `src: url("../../../assets/fonts/dnb/DNB-Regular.woff2") format("woff2"),` + `src: url("../../../assets/fonts/dnb/DNB-Regular.woff2") format("woff2"),`, ) expect(content).toContain(` .dnb-p { @@ -437,9 +440,9 @@ describe('style build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/style/themes/theme-sbanken/sbanken-theme-basis.css` + `build${stage}/style/themes/theme-sbanken/sbanken-theme-basis.css`, ), - 'utf-8' + 'utf-8', ) expect(content).toContain(`font-family: MaisonNeueHeadings;`) expect(content).toContain(` @@ -459,9 +462,9 @@ describe('style build', () => { const content = fs.readFileSync( path.resolve( packpath.self(), - `build${stage}/style/themes/theme-sbanken/sbanken-theme-components.css` + `build${stage}/style/themes/theme-sbanken/sbanken-theme-components.css`, ), - 'utf-8' + 'utf-8', ) expect(content).toContain(`.dnb-button {`) } diff --git a/packages/dnb-eufemia/scripts/postbuild/__tests__/prepareForRelease.test.js b/packages/dnb-eufemia/scripts/postbuild/__tests__/prepareForRelease.test.js index fa5df60c1f2..ba90caa5027 100644 --- a/packages/dnb-eufemia/scripts/postbuild/__tests__/prepareForRelease.test.js +++ b/packages/dnb-eufemia/scripts/postbuild/__tests__/prepareForRelease.test.js @@ -45,7 +45,7 @@ if(typeof window !== 'undefined'){ window.Eufemia = window.Eufemia || {}; window.Eufemia.version = '0.0.0-development'; } -`) +`), ) }) }) @@ -53,7 +53,7 @@ if(typeof window !== 'undefined'){ describe('package.json', () => { const packageJsonFile = path.resolve( packpath.self(), - 'build/package.json' + 'build/package.json', ) let packageJson = {} @@ -86,7 +86,7 @@ describe('package.json', () => { 'style/**/*', 'es/style/**/*', 'esm/style/**/*', - ]) + ]), ) }) @@ -95,7 +95,7 @@ describe('package.json', () => { expect.objectContaining({ react: expect.anything(), 'react-dom': expect.anything(), - }) + }), ) }) @@ -107,7 +107,7 @@ describe('package.json', () => { it('has publishConfig', () => { expect(packageJson.publishConfig).toEqual( - expect.objectContaining({ access: 'public' }) + expect.objectContaining({ access: 'public' }), ) }) }) diff --git a/packages/dnb-eufemia/scripts/postbuild/getNextReleaseVersion.js b/packages/dnb-eufemia/scripts/postbuild/getNextReleaseVersion.js index d16b7a333e6..c015b2f5696 100644 --- a/packages/dnb-eufemia/scripts/postbuild/getNextReleaseVersion.js +++ b/packages/dnb-eufemia/scripts/postbuild/getNextReleaseVersion.js @@ -28,7 +28,7 @@ async function getNextReleaseVersion() { try { const log = await runCommand(command) const nextVersion = log.match( - /The next release version is ([^\n]*)/ + /The next release version is ([^\n]*)/, )?.[1] if (nextVersion) { @@ -40,8 +40,8 @@ async function getNextReleaseVersion() { } else { console.warn( `The current git branch ${branchName} is not one of the release branches ${releaseBranches.join( - ',' - )}` + ',', + )}`, ) } diff --git a/packages/dnb-eufemia/scripts/postbuild/postbuild.sh b/packages/dnb-eufemia/scripts/postbuild/postbuild.sh index 47ae664b081..ab81c866dfe 100755 --- a/packages/dnb-eufemia/scripts/postbuild/postbuild.sh +++ b/packages/dnb-eufemia/scripts/postbuild/postbuild.sh @@ -5,7 +5,7 @@ set -e # Exit immediately if a command exits with a non-zero status. echo 'Postbuild started ...' yarn build:types:generate -yarn prettier:other +yarn prettier:other:write yarn build:cjs yarn build:es yarn build:esm diff --git a/packages/dnb-eufemia/scripts/postbuild/prepareForRelease.js b/packages/dnb-eufemia/scripts/postbuild/prepareForRelease.js index 83f5364cb7a..b78ecf46c71 100644 --- a/packages/dnb-eufemia/scripts/postbuild/prepareForRelease.js +++ b/packages/dnb-eufemia/scripts/postbuild/prepareForRelease.js @@ -49,11 +49,11 @@ export async function cleanupPackage({ packageString, filepath }) { const prettierrc = JSON.parse( await fs.readFile( path.resolve(packpath.self(), '.prettierrc'), - 'utf-8' - ) + 'utf-8', + ), ) - return prettier.format(JSON.stringify(packageJson), { + return await prettier.format(JSON.stringify(packageJson), { ...prettierrc, filepath, }) @@ -94,7 +94,7 @@ if(typeof window !== 'undefined'){ if (require.main === module) { console.info( - `prepareForRelease: Has written version ${version} to files` + `prepareForRelease: Has written version ${version} to files`, ) } } catch (e) { diff --git a/packages/dnb-eufemia/scripts/postbuild/publish-prepare.sh b/packages/dnb-eufemia/scripts/postbuild/publish-prepare.sh index 8c3d6ba8796..bc5b08e8937 100755 --- a/packages/dnb-eufemia/scripts/postbuild/publish-prepare.sh +++ b/packages/dnb-eufemia/scripts/postbuild/publish-prepare.sh @@ -8,6 +8,6 @@ babel-node --extensions .js,.ts,.tsx ./scripts/postbuild/prepareForRelease.js echo 'Testing the postbuild before publish ...' -jest ./prepareForRelease.test.js --ci --testPathIgnorePatterns=[] +NODE_OPTIONS=--experimental-vm-modules jest ./prepareForRelease.test.js --ci --testPathIgnorePatterns=[] echo 'Prepare before publish is done!' diff --git a/packages/dnb-eufemia/scripts/prebuild/audit/prepareForAudit.js b/packages/dnb-eufemia/scripts/prebuild/audit/prepareForAudit.js index 323acef17ff..a7cbd6f2ad4 100644 --- a/packages/dnb-eufemia/scripts/prebuild/audit/prepareForAudit.js +++ b/packages/dnb-eufemia/scripts/prebuild/audit/prepareForAudit.js @@ -20,7 +20,7 @@ function renameDependencies(direction = 'auto') { return async () => { const filepath = path.resolve(packpath.self(), './package.json') const packageJson = JSON.parse( - (await fs.readFile(filepath)).toString() + (await fs.readFile(filepath)).toString(), ) if (direction === 'auto' && packageJson.devDependencies) { @@ -37,7 +37,7 @@ function renameDependencies(direction = 'auto') { delete packageJson.devDependencies } else throw new Error( - 'Could not rename pkg key! There has to exist: devDependencies' + 'Could not rename pkg key! There has to exist: devDependencies', ) } break @@ -50,7 +50,7 @@ function renameDependencies(direction = 'auto') { delete packageJson.optionalDependencies } else throw new Error( - 'Could not rename pkg key! There has to exist: optionalDependencies' + 'Could not rename pkg key! There has to exist: optionalDependencies', ) } break @@ -62,12 +62,12 @@ function renameDependencies(direction = 'auto') { const prettierrc = JSON.parse( await fs.readFile( path.resolve(packpath.self(), '.prettierrc'), - 'utf-8' - ) + 'utf-8', + ), ) const newPackageJson = JSON.stringify(packageJson, null, 2) - const formattedPackageJson = prettier.format(newPackageJson, { + const formattedPackageJson = await prettier.format(newPackageJson, { ...prettierrc, filepath, }) diff --git a/packages/dnb-eufemia/scripts/prebuild/commitToBranch.js b/packages/dnb-eufemia/scripts/prebuild/commitToBranch.js index c2e6697aea4..1802b6b5e31 100644 --- a/packages/dnb-eufemia/scripts/prebuild/commitToBranch.js +++ b/packages/dnb-eufemia/scripts/prebuild/commitToBranch.js @@ -60,13 +60,13 @@ const getRequiredBranchName = async ({ if ( requiredBranch && !requiredBranch.some((name) => - (name instanceof RegExp ? name : new RegExp(name)).test(branchName) + (name instanceof RegExp ? name : new RegExp(name)).test(branchName), ) ) { log.fail( `The current branch (${branchName}) was not the required one: ${requiredBranch.join( - ' or ' - )}` + ' or ', + )}`, ) return false } @@ -106,8 +106,8 @@ const commitToBranch = async ({ Array.isArray(filePathsIncludelist) ? filePathsIncludelist.join('|') : filePathsIncludelist, - 'g' - ).test(f) + 'g', + ).test(f), ) // check if the changes where in the files directories @@ -116,7 +116,7 @@ const commitToBranch = async ({ if (hasChanges) { if (config.user && config.user.name && config.user.email) { log.info( - `Commit: Add Git user: ${config.user.name}, ${config.user.email}` + `Commit: Add Git user: ${config.user.name}, ${config.user.email}`, ) await repo.addConfig('user.name', config.user.name) await repo.addConfig('user.email', config.user.email) @@ -140,7 +140,7 @@ const commitToBranch = async ({ isFeature ? 'feat:' : 'chore:' } some ${what} got added/changed during CI | ${files.join(', ')}${ skipCI ? ' [skip ci]' : '' - }` + }`, ).trim() log.info(`Commit: ${commitMessage}`) @@ -158,7 +158,7 @@ const commitToBranch = async ({ await repo.push('origin', branchName, force ? ['--force'] : null) log.succeed( - `Commit: These ${what} were successfully updated/added: ${files}` + `Commit: These ${what} were successfully updated/added: ${files}`, ) return files diff --git a/packages/dnb-eufemia/scripts/prebuild/index.ts b/packages/dnb-eufemia/scripts/prebuild/index.ts index 3e72c965ca2..0fd493ef039 100644 --- a/packages/dnb-eufemia/scripts/prebuild/index.ts +++ b/packages/dnb-eufemia/scripts/prebuild/index.ts @@ -91,7 +91,7 @@ export const cleanupLib = async ({ preventDelete = false } = {}) => { ], { force: true, - } + }, ) } } diff --git a/packages/dnb-eufemia/scripts/prebuild/resources/makeResourcesPackage.js b/packages/dnb-eufemia/scripts/prebuild/resources/makeResourcesPackage.js index 0659b100a6f..e42435e7af6 100644 --- a/packages/dnb-eufemia/scripts/prebuild/resources/makeResourcesPackage.js +++ b/packages/dnb-eufemia/scripts/prebuild/resources/makeResourcesPackage.js @@ -30,7 +30,7 @@ export default async function makeResourcesPackage() { const copyStylePackages = ( src = './build/style/**/*.css', - { returnResult = false } = {} + { returnResult = false } = {}, ) => new Promise((resolve, reject) => { log.start('> PrePublish: copy style resources') @@ -45,7 +45,7 @@ const copyStylePackages = ( ? transform('utf8', (result) => resolve(result)) : gulp.dest('./dnb-ui-resources/style', { cwd: ROOT_DIR, - }) + }), ) .on('end', resolve) .on('error', reject) @@ -55,7 +55,7 @@ const copyStylePackages = ( }) const copyFonts = ( - src = ['./assets/fonts/dnb/*', '!./assets/fonts/dnb/*.zip'] + src = ['./assets/fonts/dnb/*', '!./assets/fonts/dnb/*.zip'], ) => new Promise((resolve, reject) => { log.start('> PrePublish: copy fonts resources') @@ -67,7 +67,7 @@ const copyFonts = ( .pipe( gulp.dest('./dnb-ui-resources/resources/fonts', { cwd: ROOT_DIR, - }) + }), ) .on('end', resolve) .on('error', reject) @@ -77,7 +77,7 @@ const copyFonts = ( }) const copyBrowser = ( - src = ['./assets/browser/*', '!./assets/browser/*.zip'] + src = ['./assets/browser/*', '!./assets/browser/*.zip'], ) => new Promise((resolve, reject) => { log.start('> PrePublish: copy browser resources') @@ -89,7 +89,7 @@ const copyBrowser = ( .pipe( gulp.dest('./dnb-ui-resources/resources/browser', { cwd: ROOT_DIR, - }) + }), ) .on('end', resolve) .on('error', reject) @@ -99,7 +99,7 @@ const copyBrowser = ( }) const copyUMD = ( - src = ['./build/umd/*', '../../node_modules/react/umd/*'] + src = ['./build/umd/*', '../../node_modules/react/umd/*'], ) => new Promise((resolve, reject) => { log.start('> PrePublish: copy UMD resources') @@ -111,7 +111,7 @@ const copyUMD = ( .pipe( gulp.dest('./dnb-ui-resources/umd', { cwd: ROOT_DIR, - }) + }), ) .on('end', resolve) .on('error', reject) @@ -134,7 +134,7 @@ To make usage of the content, copy the \`style\`, \`umd\` and \`resources\` fold For documentation, visit: https://eufemia.dnb.no/ License: Apache 2.0 with Commons Clause -` +`, ) } @@ -151,7 +151,7 @@ const createTar = async () => { gzip: true, file: path.resolve(distPath, 'dnb-ui-resources.tgz'), }, - ['./dnb-ui-resources'] + ['./dnb-ui-resources'], ) } diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/convertSvgToJsx.test.tsx b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/convertSvgToJsx.test.tsx index c7aea6ad8bf..f32501756c7 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/convertSvgToJsx.test.tsx +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/convertSvgToJsx.test.tsx @@ -24,7 +24,7 @@ beforeAll(async () => { destPath: path.resolve(__dirname, './test-files/dist'), customIconsLockFilePath: path.resolve( __dirname, - './test-files/dnb/icons-svg.lock' + './test-files/dnb/icons-svg.lock', ), }) jest.useFakeTimers() @@ -61,7 +61,7 @@ describe('run convertSvgToJsx to convert ES6 to ES5', () => { const index = await import( path.resolve( __dirname, - 'test-files/dist/dnb/primary_icons_medium.ts' + 'test-files/dist/dnb/primary_icons_medium.ts', ) ) expect(index).toMatchSnapshot() diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/generateTypes.test.js b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/generateTypes.test.js index 74a05cf81dd..3c9c54c2a43 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/generateTypes.test.js +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/generateTypes.test.js @@ -13,7 +13,7 @@ describe('generateTypes', () => { const docsDir = nodePath.resolve( __dirname, '../generateTypes/__tests__', - '__mocks__' + '__mocks__', ) const file = nodePath.resolve(docsDir, 'PrimaryComponent.js') const [{ destFile, definitionContent }] = await createTypes([file], { @@ -30,7 +30,7 @@ describe('generateTypes', () => { const docsDir = nodePath.resolve( __dirname, '../generateTypes/__tests__', - '__mocks__' + '__mocks__', ) const file = nodePath.resolve(docsDir, 'SecondaryComponent.js') const [{ destFile, definitionContent }] = await createTypes([file], { diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makeLibStyles.test.ts b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makeLibStyles.test.ts index 448b0b681f8..c81c4849227 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makeLibStyles.test.ts +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makeLibStyles.test.ts @@ -25,13 +25,13 @@ if (isCI) { './src/components/button/style/dnb-button.scss', { returnResult: true, - } + }, ) global.files = await runFactory( './src/components/button/style/dnb-button.scss', { returnFiles: true, - } + }, ) }) @@ -55,10 +55,10 @@ if (isCI) { it('includes correct files', () => { expect(global.files).toHaveLength(2) expect(global.files[0]).toContain( - '/components/button/style/dnb-button.css' + '/components/button/style/dnb-button.css', ) expect(global.files[1]).toContain( - '/components/button/style/dnb-button.min.css' + '/components/button/style/dnb-button.min.css', ) }) }) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makeMainStyle.test.ts b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makeMainStyle.test.ts index d4a495166f2..ec8dc7b575a 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makeMainStyle.test.ts +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makeMainStyle.test.ts @@ -45,13 +45,13 @@ if (isCI) { './src/style/themes/theme-ui/ui-theme-components.scss', { returnResult: true, - } + }, ) global.files = await runFactory( './src/style/themes/theme-ui/ui-theme-components.scss', { returnFiles: true, - } + }, ) }) @@ -70,7 +70,7 @@ if (isCI) { it('should contain a non minified and a minified content', () => { expect(global.components[0]).toContain( - 'ATTENTION: This file is auto generated' + 'ATTENTION: This file is auto generated', ) expect(global.components[1]).toMatch(/^:root{--/) }) @@ -78,10 +78,10 @@ if (isCI) { it('includes correct files', () => { expect(global.files).toHaveLength(2) expect(global.files[0]).toContain( - '/style/themes/theme-ui/ui-theme-components.css' + '/style/themes/theme-ui/ui-theme-components.css', ) expect(global.files[1]).toContain( - '/style/themes/theme-ui/ui-theme-components.min.css' + '/style/themes/theme-ui/ui-theme-components.min.css', ) }) }) @@ -92,7 +92,7 @@ if (isCI) { './src/style/dnb-ui-elements.scss', { returnResult: true, - } + }, ) }) @@ -108,7 +108,7 @@ if (isCI) { './src/style/themes/theme-ui/ui-theme-basis.scss', { returnResult: true, - } + }, ) }) @@ -119,10 +119,10 @@ if (isCI) { it('has to have correct custom properties', () => { expect(global.theme[0]).toMatch( - new RegExp('--color-sea-green:\\s?#007272;') + new RegExp('--color-sea-green:\\s?#007272;'), ) expect(global.theme[0]).toMatch( - new RegExp('color:\\s?var\\(--color-sea-green\\);') + new RegExp('color:\\s?var\\(--color-sea-green\\);'), ) expect(global.theme[0]).not.toMatch(new RegExp('color:\\s?#007272;')) expect(global.theme[0]).not.toContain('fuchsia') @@ -130,7 +130,7 @@ if (isCI) { it('has to have correct core path to fonts', () => { expect(global.theme[0]).toMatch( - new RegExp('("|\\()../../../assets/fonts/dnb/') + new RegExp('("|\\()../../../assets/fonts/dnb/'), ) }) }) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makePropertiesFile.test.ts b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makePropertiesFile.test.ts index 573a0cf467c..8cd79495c9e 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makePropertiesFile.test.ts +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makePropertiesFile.test.ts @@ -37,7 +37,7 @@ describe('Properties for sbanken', () => { it('has to validate', () => { expect(global.sbanken).toMatchSnapshot() expect(global.sbanken).toContain( - `'--sb-font-family-default': '"Roboto", "Helvetica", "Arial", sans-serif'` + `'--sb-font-family-default': '"Roboto", "Helvetica", "Arial", sans-serif'`, ) }) }) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makeReleaseVersion.test.ts b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makeReleaseVersion.test.ts index 5287bc0628c..8716522d34b 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makeReleaseVersion.test.ts +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/makeReleaseVersion.test.ts @@ -77,7 +77,7 @@ describe('makeReleaseVersion', () => { expect(fs.writeFile).toHaveBeenCalledTimes(1) expect(fs.writeFile).toHaveBeenLastCalledWith( expect.stringContaining('src/shared/Eufemia.js'), - expect.stringContaining(`return '123456789'`) + expect.stringContaining(`return '123456789'`), ) }) @@ -94,11 +94,11 @@ describe('makeReleaseVersion', () => { expect(fs.writeFile).toHaveBeenCalledTimes(1) expect(fs.writeFile).toHaveBeenLastCalledWith( expect.stringContaining('src/shared/Eufemia.js'), - expect.stringContaining(`return 'release'`) + expect.stringContaining(`return 'release'`), ) expect(fs.writeFile).toHaveBeenLastCalledWith( expect.stringContaining('src/shared/Eufemia.js'), - expect.stringContaining(`export const version = 'release'`) + expect.stringContaining(`export const version = 'release'`), ) }) }) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/postTypeGeneration.test.ts b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/postTypeGeneration.test.ts index 467a8aca3dd..a696e573f36 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/postTypeGeneration.test.ts +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/postTypeGeneration.test.ts @@ -9,7 +9,7 @@ describe('generateTypes did generate', () => { it('Input index', async () => { const content = await fs.readFile( require.resolve('@dnb/eufemia/src/components/Input.d.ts'), - 'utf-8' + 'utf-8', ) expect(content).toContain('export default Input') }) @@ -17,7 +17,7 @@ describe('generateTypes did generate', () => { it('Input components', async () => { const content = await fs.readFile( require.resolve('@dnb/eufemia/src/components/input/Input.d.ts'), - 'utf-8' + 'utf-8', ) expect(content).toContain('export interface InputProps') }) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/prepareTemplates.test.ts b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/prepareTemplates.test.ts index c4569b03f9f..15a154bc4a5 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/prepareTemplates.test.ts +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/prepareTemplates.test.ts @@ -76,42 +76,42 @@ describe('prepareTemplates', () => { expect(writeFile).toHaveBeenNthCalledWith( 9, dest9, - expect.stringContaining(`export default {}`) + expect.stringContaining(`export default {}`), ) expect(writeFile).toHaveBeenNthCalledWith( 9, dest9, expect.stringContaining( - `export { ComponentA, ComponentB, ElementA, ElementB }` - ) + `export { ComponentA, ComponentB, ElementA, ElementB }`, + ), ) expect(writeFile).toHaveBeenNthCalledWith( 9, dest9, expect.stringContaining( - `import ElementB from './elements/element-b'` - ) + `import ElementB from './elements/element-b'`, + ), ) expect(writeFile).toHaveBeenNthCalledWith( 9, dest9, expect.stringContaining( - `import ElementA from './elements/element-a'` - ) + `import ElementA from './elements/element-a'`, + ), ) expect(writeFile).toHaveBeenNthCalledWith( 9, dest9, expect.stringContaining( - `import ComponentB from './components/component-b/ComponentB'` - ) + `import ComponentB from './components/component-b/ComponentB'`, + ), ) expect(writeFile).toHaveBeenNthCalledWith( 9, dest9, expect.stringContaining( - `import ComponentA from './components/component-a/ComponentA'` - ) + `import ComponentA from './components/component-a/ComponentA'`, + ), ) }) @@ -128,20 +128,20 @@ describe('prepareTemplates', () => { 1, dest1, expect.stringContaining( - `import ComponentA from './component-a/ComponentA'` - ) + `import ComponentA from './component-a/ComponentA'`, + ), ) expect(writeFile).toHaveBeenNthCalledWith( 1, dest1, expect.stringContaining( - `import ComponentB from './component-b/ComponentB'` - ) + `import ComponentB from './component-b/ComponentB'`, + ), ) expect(writeFile).toHaveBeenNthCalledWith( 1, dest1, - expect.stringContaining(`export { ComponentA, ComponentB }`) + expect.stringContaining(`export { ComponentA, ComponentB }`), ) const dest2 = expect.stringContaining('/src/components/lib.ts') @@ -149,25 +149,25 @@ describe('prepareTemplates', () => { 2, dest2, expect.stringContaining( - `import ComponentA from './component-a/ComponentA'` - ) + `import ComponentA from './component-a/ComponentA'`, + ), ) expect(writeFile).toHaveBeenNthCalledWith( 2, dest2, expect.stringContaining( - `import ComponentB from './component-b/ComponentB'` - ) + `import ComponentB from './component-b/ComponentB'`, + ), ) expect(writeFile).toHaveBeenNthCalledWith( 2, dest2, - expect.stringContaining(`export { ComponentA, ComponentB }`) + expect.stringContaining(`export { ComponentA, ComponentB }`), ) expect(writeFile).toHaveBeenNthCalledWith( 2, dest2, - expect.stringContaining(`return { ComponentA, ComponentB }`) + expect.stringContaining(`return { ComponentA, ComponentB }`), ) const dest3 = expect.stringContaining('/src/components/ComponentA.ts') @@ -175,18 +175,18 @@ describe('prepareTemplates', () => { 3, dest3, expect.stringContaining( - `import ComponentA from './component-a/ComponentA'` - ) + `import ComponentA from './component-a/ComponentA'`, + ), ) expect(writeFile).toHaveBeenNthCalledWith( 3, dest3, - expect.stringContaining(`export * from './component-a/ComponentA'`) + expect.stringContaining(`export * from './component-a/ComponentA'`), ) expect(writeFile).toHaveBeenNthCalledWith( 3, dest3, - expect.stringContaining(`export default ComponentA`) + expect.stringContaining(`export default ComponentA`), ) const dest4 = expect.stringContaining('/src/components/ComponentB.ts') @@ -194,18 +194,18 @@ describe('prepareTemplates', () => { 4, dest4, expect.stringContaining( - `import ComponentB from './component-b/ComponentB'` - ) + `import ComponentB from './component-b/ComponentB'`, + ), ) expect(writeFile).toHaveBeenNthCalledWith( 4, dest4, - expect.stringContaining(`export * from './component-b/ComponentB'`) + expect.stringContaining(`export * from './component-b/ComponentB'`), ) expect(writeFile).toHaveBeenNthCalledWith( 4, dest4, - expect.stringContaining(`export default ComponentB`) + expect.stringContaining(`export default ComponentB`), ) }) @@ -221,14 +221,14 @@ describe('prepareTemplates', () => { expect(writeFile).toHaveBeenNthCalledWith( 1, dest1, - expect.stringContaining(`export { FragmentA, FragmentB }`) + expect.stringContaining(`export { FragmentA, FragmentB }`), ) const dest2 = expect.stringContaining('/src/fragments/lib.ts') expect(writeFile).toHaveBeenNthCalledWith( 2, dest2, - expect.stringContaining(`return { FragmentA, FragmentB }`) + expect.stringContaining(`return { FragmentA, FragmentB }`), ) const dest3 = expect.stringContaining('/fragments/FragmentA.ts') @@ -236,15 +236,15 @@ describe('prepareTemplates', () => { 3, dest3, expect.stringContaining( - `import FragmentA from './fragment-a/FragmentA'` - ) + `import FragmentA from './fragment-a/FragmentA'`, + ), ) const dest4 = expect.stringContaining('/fragments/FragmentB.ts') expect(writeFile).toHaveBeenNthCalledWith( 4, dest4, - expect.stringContaining(`export * from './fragment-b/FragmentB'`) + expect.stringContaining(`export * from './fragment-b/FragmentB'`), ) }) @@ -260,14 +260,14 @@ describe('prepareTemplates', () => { expect(writeFile).toHaveBeenNthCalledWith( 1, dest1, - expect.stringContaining(`export { ElementA, ElementB }`) + expect.stringContaining(`export { ElementA, ElementB }`), ) const dest2 = expect.stringContaining('/src/elements/lib.ts') expect(writeFile).toHaveBeenNthCalledWith( 2, dest2, - expect.stringContaining(`return { ElementA, ElementB }`) + expect.stringContaining(`return { ElementA, ElementB }`), ) }) @@ -283,14 +283,14 @@ describe('prepareTemplates', () => { expect(writeFile).toHaveBeenNthCalledWith( 1, dest1, - expect.stringContaining(`export { ExtensionA, ExtensionB }`) + expect.stringContaining(`export { ExtensionA, ExtensionB }`), ) const dest2 = expect.stringContaining('/src/extensions/lib.ts') expect(writeFile).toHaveBeenNthCalledWith( 2, dest2, - expect.stringContaining(`return { ExtensionA, ExtensionB }`) + expect.stringContaining(`return { ExtensionA, ExtensionB }`), ) }) }) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/themeFactory.test.ts b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/themeFactory.test.ts index 88609c50319..888ee8214f0 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/themeFactory.test.ts +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/__tests__/themeFactory.test.ts @@ -19,7 +19,7 @@ jest.mock('fs-extra', () => { jest.requireActual('../themeFactory') return `${editAdvice.replace( '', - 'components' + 'components', )}${insertBelowAdvice}` } @@ -162,12 +162,12 @@ describe('runFactory', () => { expect(fs.writeFile).toHaveBeenNthCalledWith( 1, './theme-sbanken/sbanken-theme-components.scss', - expect.any(String) + expect.any(String), ) expect(fs.writeFile).toHaveBeenNthCalledWith( 2, './theme-ui/ui-theme-components.scss', - expect.any(String) + expect.any(String), ) expect(result).toMatchInlineSnapshot(` " @@ -204,7 +204,7 @@ const make = async ({ scssOutputPath, targetFile }) => { filesToFindGlob: [ path.resolve( __dirname, - '../../../../src/{components,fragments}/**/style/themes/**/*-theme-*.scss' + '../../../../src/{components,fragments}/**/style/themes/**/*-theme-*.scss', ), ], returnResult: true, diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/convertSvgToJsx.ts b/packages/dnb-eufemia/scripts/prebuild/tasks/convertSvgToJsx.ts index c5cf6ab3aa6..27d2153b4d9 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/convertSvgToJsx.ts +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/convertSvgToJsx.ts @@ -52,11 +52,11 @@ export default async function convertSvgToJsx({ ], { force: true, - } + }, ) log.info( - '> PrePublish: deleted all svg files before converting "svg to jsx"!' + '> PrePublish: deleted all svg files before converting "svg to jsx"!', ) } @@ -65,7 +65,7 @@ export default async function convertSvgToJsx({ path.dirname(path.resolve(ROOT_DIR, srcPath, '../')), { withFileTypes: true, - } + }, ) ) .filter((dir) => dir.isDirectory()) @@ -73,7 +73,7 @@ export default async function convertSvgToJsx({ await asyncForEach(dirs, async (assetsDir) => { log.start( - `> PrePublish: converting "svg to jsx" for "${assetsDir}" as started ...` + `> PrePublish: converting "svg to jsx" for "${assetsDir}" as started ...`, ) const icons: TransformedIcons = await transformSvg({ @@ -88,7 +88,7 @@ export default async function convertSvgToJsx({ log.succeed( `> PrePublish: Converting "svg to jsx" for "${assetsDir}" is done (converted ${ icons.length - } icons with ${icons.length / sizes.length} in total)` + } icons with ${icons.length / sizes.length} in total)`, ) await controllRoutine(icons) @@ -97,7 +97,7 @@ export default async function convertSvgToJsx({ const controllRoutine = async (icons: TransformedIcons) => { const sizes = Object.values(ICON_SIZES).filter(({ suffix }) => - Boolean(suffix) + Boolean(suffix), ) sizes.forEach(({ suffix: size }) => { @@ -113,7 +113,7 @@ const controllRoutine = async (icons: TransformedIcons) => { log.fail( `The icon "${origName}" was not found with another size${ origName.endsWith(size) ? '' : ` (${size})` - }! They should be looked up. The failure can be in several places.` + }! They should be looked up. The failure can be in several places.`, ) } }) @@ -155,7 +155,7 @@ const transformSvgToReact = ({ srcPath, destPath }) => { .pipe( rename((path) => { path.extname = '.tsx' - }) + }), ) .pipe(gulp.dest(destPath, { cwd: ROOT_DIR })) .on('end', resolve) @@ -179,7 +179,7 @@ const transformToJsx = (content, file): PromiseLike => { try { content = content.replace( /clip[0-9]+/g, - `clip-${md5(filename).substring(0, 6)}` + `clip-${md5(filename).substring(0, 6)}`, ) return new Promise((resolve, reject) => svgr( @@ -194,29 +194,30 @@ const transformToJsx = (content, file): PromiseLike => { */ plugins: ['@svgr/plugin-jsx'], }, - { componentName } + { componentName }, ) - .then((res) => { + .then(async (res) => { log.info(`> PrePublish: Icon was converted: ${basename}`) resolve( '/** This file is auto generated by convertSvgToJsx.ts */\n\n' + - prettier - .format(res, { + ( + await prettier.format(res, { ...prettierrc, parser: 'babel', }) + ) // This is a fix, so the Rollup ESM export does export React.createElement, and not only createElement with a named import .replace( new RegExp(`import \\* as React from 'react'`, 'g'), - `import React from 'react'` - ) + `import React from 'react'`, + ), ) }) - .catch(reject) + .catch(reject), ) } catch (e) { log.fail( - `> PrePublish: convertSvgToJsx conversion of "${basename}" failed` + `> PrePublish: convertSvgToJsx conversion of "${basename}" failed`, ) throw e } @@ -283,12 +284,12 @@ const generateIndexFile = async ({ ({ name, filename }) => `import ${name} from '.${ assetsDir === '' ? `/${FALLBACK}` : '' - }/${filename}'` + }/${filename}'`, ) .join('\n') const _keys = icons.map(({ name }) => name).join(', ') - const indexContent = prettier.format( + const indexContent = await prettier.format( `/** This file is auto generated by convertSvgToJsx.ts */ ${_imports} @@ -298,7 +299,7 @@ const generateIndexFile = async ({ { ...prettierrc, parser: 'babel', - } + }, ) try { @@ -306,7 +307,7 @@ const generateIndexFile = async ({ ROOT_DIR, destPath, assetsDir, - `index.ts` + `index.ts`, ) await fs.writeFile(indexFile, indexContent) @@ -329,7 +330,7 @@ const generateGroupFiles = async ({ // from the svg lock file we can generate groups out of the "bundleName" const groups: Record> = Object.entries( - lockFileContent + lockFileContent, ).reduce((acc, [file, { bundleName }]) => { acc[bundleName] = acc[bundleName] || [] const basename = path.basename(file) @@ -338,7 +339,7 @@ const generateGroupFiles = async ({ ROOT_DIR, destPath, assetsDir, - `${filename}.tsx` + `${filename}.tsx`, ) // make sure the file actually exists @@ -360,23 +361,23 @@ const generateGroupFiles = async ({ Object.entries(groups), async ([groupName, entries]) => { entries = entries.sort(({ name: a }, { name: b }) => - a > b ? 1 : -1 + a > b ? 1 : -1, ) const groupFile = path.resolve( ROOT_DIR, destPath, assetsDir, - `${groupName}.ts` + `${groupName}.ts`, ) const _imports = entries .map( - ({ name, filename }) => `import ${name} from './${filename}'` + ({ name, filename }) => `import ${name} from './${filename}'`, ) .join('\n') const _keys = entries.map(({ name }) => name).join(', ') - const groupFileContent = prettier.format( + const groupFileContent = await prettier.format( `/** This file is auto generated by convertSvgToJsx.ts */ ${_imports} @@ -386,11 +387,11 @@ const generateGroupFiles = async ({ { ...prettierrc, parser: 'babel', - } + }, ) await fs.writeFile(groupFile, groupFileContent) - } + }, ) } catch (e) { throw new Error(e) @@ -404,7 +405,7 @@ const generateFallbackIndexFiles = async ({ }: ForwardParams) => { try { await asyncForEach(Object.entries(icons), async ([, { filename }]) => { - const indexFileContent = prettier.format( + const indexFileContent = await prettier.format( `/** This file is auto generated by convertSvgToJsx.ts */ import icon from './${assetsDir}/${filename}' @@ -413,7 +414,7 @@ const generateFallbackIndexFiles = async ({ { ...prettierrc, parser: 'babel', - } + }, ) const indexFile = path.resolve(ROOT_DIR, destPath, `${filename}.ts`) @@ -426,5 +427,8 @@ const generateFallbackIndexFiles = async ({ } const prettierrc = JSON.parse( - fs.readFileSync(path.resolve(__dirname, '../../../.prettierrc'), 'utf-8') + fs.readFileSync( + path.resolve(__dirname, '../../../.prettierrc'), + 'utf-8', + ), ) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes.js b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes.js index 3199cc46004..7121620e745 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes.js +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes.js @@ -54,12 +54,12 @@ export default async function generateTypes({ export const createTypes = async ( listOfAllFiles, - { isTest = false, ...opts } = {} + { isTest = false, ...opts } = {}, ) => { try { const prettierrc = await fs.readJSON( nodePath.resolve('./.prettierrc'), - 'utf-8' + 'utf-8', ) // "prettier.format" does not handle "overwrites", so we merge it manually @@ -109,7 +109,7 @@ export const createTypes = async ( if (collectProps.findIndex((k) => k === key) === -1) { if (!sharedProps.includes(key)) { log.fail( - `The property "${key}" is not defined in PropTypes!\nComponent: ${componentName}\nFile: ${file}\n\n` + `The property "${key}" is not defined in PropTypes!\nComponent: ${componentName}\nFile: ${file}\n\n`, ) } } @@ -216,13 +216,13 @@ export const createTypes = async ( ], ], ...babelPluginConfigDefaults, - } + }, ) definitionContent = codeWithTransformedTypes } - definitionContent = prettier.format(definitionContent, { + definitionContent = await prettier.format(definitionContent, { ...prettierrc, filepath: 'file.d.ts', }) @@ -246,7 +246,7 @@ function existsInGit(destFile) { return new Promise((resolve, reject) => { try { exec(`git show HEAD~1:${destFile}`, (error, stdout, stderr) => - resolve(!(error || stderr)) + resolve(!(error || stderr)), ) } catch (e) { log.fail(e) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/__tests__/babelPluginCorrectTypes.test.js b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/__tests__/babelPluginCorrectTypes.test.js index 2d35b038097..9d0f3997b85 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/__tests__/babelPluginCorrectTypes.test.js +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/__tests__/babelPluginCorrectTypes.test.js @@ -13,7 +13,7 @@ describe('babelPluginCorrectTypes', () => { it('has to match snapshot', async () => { const file = nodePath.resolve( __dirname, - '__mocks__/PrimaryComponent.js' + '__mocks__/PrimaryComponent.js', ) const sourceDir = nodePath.dirname(file) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/__tests__/babelPluginExtendTypes.test.js b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/__tests__/babelPluginExtendTypes.test.js index 0ecc1bf9a02..6c3c8abf665 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/__tests__/babelPluginExtendTypes.test.js +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/__tests__/babelPluginExtendTypes.test.js @@ -12,11 +12,11 @@ describe('babelPluginExtendTypes', () => { it('has to match snapshot', async () => { const targetFile = nodePath.resolve( __dirname, - '__mocks__/PrimaryComponent.d.ts' + '__mocks__/PrimaryComponent.d.ts', ) const file = nodePath.resolve( __dirname, - '__mocks__/PrimaryComponent.js' + '__mocks__/PrimaryComponent.js', ) const { code } = await transformFileAsync(targetFile, { diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/__tests__/babelPluginPropTypesRelations.test.js b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/__tests__/babelPluginPropTypesRelations.test.js index 4750d7a6b4f..a01ce63730d 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/__tests__/babelPluginPropTypesRelations.test.js +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/__tests__/babelPluginPropTypesRelations.test.js @@ -12,7 +12,7 @@ describe('babelPluginPropTypesRelations', () => { it('has to match snapshot', async () => { const file = nodePath.resolve( __dirname, - '__mocks__/PrimaryComponent.js' + '__mocks__/PrimaryComponent.js', ) const sourceDir = nodePath.dirname(file) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/babelPluginExtendTypes.js b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/babelPluginExtendTypes.js index 9e9eeb81b79..b98da93be5b 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/babelPluginExtendTypes.js +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/babelPluginExtendTypes.js @@ -145,7 +145,7 @@ export function babelPluginExtendTypes(babel, { file } = {}) { } }, }) - } + }, ) } }, @@ -163,8 +163,8 @@ function inertClassProperty({ t, path, property, value, type }) { : null, null, false, - true - ) + true, + ), ) } diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/babelPluginIncludeDocs.js b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/babelPluginIncludeDocs.js index 8f368772a98..a5f4ada930b 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/babelPluginIncludeDocs.js +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/babelPluginIncludeDocs.js @@ -1,6 +1,6 @@ export function babelPluginIncludeDocs( plugin, - { docs, onComplete = null, insertLeadingComment = null } + { docs, onComplete = null, insertLeadingComment = null }, ) { if (!docs) { return {} // stop here @@ -30,8 +30,8 @@ export function babelPluginIncludeDocs( 'leading', insertLeadingComment === true ? `*\n * NB: Do not change the docs (comments) in here. The docs are updated during build time by "generateTypes.js" and "fetchPropertiesFromDocs.js".\n ` - : insertLeadingComment - ) + : insertLeadingComment, + ), ) } } diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/babelPluginPropTypesRelations.js b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/babelPluginPropTypesRelations.js index 11bd25c192d..0ba1b932174 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/babelPluginPropTypesRelations.js +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/babelPluginPropTypesRelations.js @@ -168,7 +168,7 @@ export function babelPluginPropTypesRelations(babel, { sourceDir }) { const code = fs.readFileSync( nodePath.resolve(sourceDir, sourceFile + '.js'), - 'utf-8' + 'utf-8', ) ast = parse(code, babylonConfigDefaults) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/fetchPropertiesFromDocs.js b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/fetchPropertiesFromDocs.js index cfd41093c72..1e64e929735 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/fetchPropertiesFromDocs.js +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/generateTypes/fetchPropertiesFromDocs.js @@ -16,7 +16,7 @@ import { const ROOT_DIR = path.resolve( path.dirname(require.resolve('dnb-design-system-portal/package.json')), - 'src/docs/uilib' + 'src/docs/uilib', ) /** @@ -30,20 +30,20 @@ const ROOT_DIR = path.resolve( function extractPathParts({ file }) { const basename = path.basename(file) const componentName = toPascalCase( - toSnakeCase(basename.replace(path.extname(file), '')) + toSnakeCase(basename.replace(path.extname(file), '')), ) const tmpComponentName = toKebabCase(componentName) const firstPartOfFilename = tmpComponentName.split('-')[0] const parts = file .split('/') .map((name) => - toKebabCase(path.basename(name).replace(path.extname(file), '')) + toKebabCase(path.basename(name).replace(path.extname(file), '')), ) const componentDir = parts.find((path) => new RegExp( - `(${firstPartOfFilename}-|^${firstPartOfFilename}$)` - ).test(path) + `(${firstPartOfFilename}-|^${firstPartOfFilename}$)`, + ).test(path), ) || '' const index = parts.findIndex((part) => part === componentDir) const groupDir = parts[index - 1] || '' @@ -209,13 +209,13 @@ async function extractorFactory({ let cleanedKey = propName.replace( /<[^<]*>([^<]*)<\/[^<]*>/g, - '$1' + '$1', ) // removes e.g. defined as ** // Drop empty types if (cleanedKey.trim() === '') { log.fail( - `This file below has an empty prop-type entry!\n${file}\n\n` + `This file below has an empty prop-type entry!\n${file}\n\n`, ) return // skip here } @@ -236,7 +236,7 @@ async function extractorFactory({ if (description) { collection[cleanedKey] = description } - } + }, ) if (process.env.NODE_ENV !== 'test') { @@ -244,7 +244,7 @@ async function extractorFactory({ } return collection - } + }, ) const docs = collections diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/makeLibStyles.js b/packages/dnb-eufemia/scripts/prebuild/tasks/makeLibStyles.js index 04b86eb1043..0f78063d4d5 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/makeLibStyles.js +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/makeLibStyles.js @@ -29,7 +29,7 @@ export default async function makeLibStyles() { await runFactory('./src/components/**/style/**/dnb-*.scss') await runFactory('./src/extensions/**/style/**/dnb-*.scss') log.succeed( - `> PrePublish: "makeLibStyles" converting sass to css done` + `> PrePublish: "makeLibStyles" converting sass to css done`, ) } catch (e) { throw new Error(e) @@ -38,7 +38,7 @@ export default async function makeLibStyles() { export const runFactory = ( src, - { returnResult = false, returnFiles = false } = {} + { returnResult = false, returnFiles = false } = {}, ) => new Promise((resolve, reject) => { log.start(`> PrePublish: converting sass to css | ${src}`) @@ -62,13 +62,13 @@ export const runFactory = ( .pipe( rename({ extname: '.css', - }) + }), ) .pipe( transform( 'utf8', - transformPaths('../../../../assets/', '../../../assets/') - ) + transformPaths('../../../../assets/', '../../../assets/'), + ), ) .pipe(transform('utf8', transformPostcss(postcssConfig({ sass })))) .pipe(cloneSink) @@ -80,14 +80,14 @@ export const runFactory = ( stream.pipe( gulp.dest(`./build/${dest}/`, { cwd: ROOT_DIR, - }) + }), ) } // so tests can test the minified code if (returnResult) { stream.pipe( - transform('utf8', transformCssnano({ reduceIdents: false })) + transform('utf8', transformCssnano({ reduceIdents: false })), ) } @@ -98,8 +98,8 @@ export const runFactory = ( .pipe( transform( 'utf8', - transformPaths('../../../../assets/', '../../../assets/') - ) + transformPaths('../../../../assets/', '../../../assets/'), + ), ) .pipe( returnResult || returnFiles @@ -115,7 +115,7 @@ export const runFactory = ( }) : gulp.dest(`./build/${dest}/`, { cwd: ROOT_DIR, - }) + }), ) .on('end', resolve) .on('error', reject) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/makeMainStyle.js b/packages/dnb-eufemia/scripts/prebuild/tasks/makeMainStyle.js index 89251f67c76..ec70645dcfc 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/makeMainStyle.js +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/makeMainStyle.js @@ -29,7 +29,7 @@ export default async function makeMainStyle() { // this way we avoid cross "includePaths" and the result is: // Now a custom theme can overwrite existing CSS Custom Properties const listWithThemesToProcess = await globby( - './src/style/themes/theme-*/*-theme-*.scss' + './src/style/themes/theme-*/*-theme-*.scss', ) await asyncForEach(listWithThemesToProcess, async (themeFile) => { // in order to keep the folder structure, we have to add these asterisks @@ -38,7 +38,7 @@ export default async function makeMainStyle() { }) const listWithPackagesToProcess = await globby( - './src/style/**/*-ui-*.scss' + './src/style/**/*-ui-*.scss', ) await asyncForEach(listWithPackagesToProcess, async (packageFile) => { // in order to keep the folder structure, we have to add these asterisks @@ -47,13 +47,13 @@ export default async function makeMainStyle() { }) log.succeed( - '> PrePublish: "makeMainStyle" transforming style modules done' + '> PrePublish: "makeMainStyle" transforming style modules done', ) } export const runFactory = ( src, - { returnResult = false, returnFiles = false } = {} + { returnResult = false, returnFiles = false } = {}, ) => new Promise((resolve, reject) => { log.start('> PrePublish: transforming main style') @@ -69,7 +69,7 @@ export const runFactory = ( .pipe( rename({ extname: '.css', - }) + }), ) .pipe(transform('utf8', transformPostcss(postcssConfig({ sass })))) .pipe(cloneSink) @@ -81,14 +81,14 @@ export const runFactory = ( stream.pipe( gulp.dest('./build/style', { cwd: ROOT_DIR, - }) + }), ) } // so tests can test the minified code if (returnResult) { stream.pipe( - transform('utf8', transformCssnano({ reduceIdents: false })) + transform('utf8', transformCssnano({ reduceIdents: false })), ) } @@ -97,7 +97,7 @@ export const runFactory = ( stream .pipe( - transform('utf8', transformPaths('../../assets/', '../assets/')) + transform('utf8', transformPaths('../../assets/', '../assets/')), ) .pipe( returnResult || returnFiles @@ -113,7 +113,7 @@ export const runFactory = ( }) : gulp.dest('./build/style', { cwd: ROOT_DIR, - }) + }), ) .on('end', resolve) .on('error', reject) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/makePropertiesFile.js b/packages/dnb-eufemia/scripts/prebuild/tasks/makePropertiesFile.js index 00d78493c82..7f4f4e4ba96 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/makePropertiesFile.js +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/makePropertiesFile.js @@ -17,11 +17,11 @@ export default async function makePropertiesFile() { await runFactory() log.succeed( - '> PrePublish: "makePropertiesFile" creating properties file done' + '> PrePublish: "makePropertiesFile" creating properties file done', ) } -const transformModulesContent = (content) => { +const transformModulesContent = async (content) => { const variables = content .split('\n') .map((s) => s.trim()) @@ -37,7 +37,7 @@ const transformModulesContent = (content) => { return ( String( - prettier.format( + await prettier.format( `/** This file is auto generated by makePropertiesFile.js */ export default ${JSON.stringify(variables, null, 2)}`, @@ -46,8 +46,8 @@ export default ${JSON.stringify(variables, null, 2)}`, semi: true, trailingComma: 'none', singleQuote: true, - } - ) + }, + ), ).trim() + ' // prettier-ignore\n' // so manual changes not removes the semi ) } @@ -68,7 +68,7 @@ export const runFactory = ({ .pipe( rename({ extname: '.js', - }) + }), ) .pipe( returnResult @@ -76,7 +76,7 @@ export const runFactory = ({ : gulp.dest('./src/style/themes/', { overwrite: true, cwd: ROOT_DIR, - }) + }), ) .on('end', resolve) .on('error', reject) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/prepareTemplates.js b/packages/dnb-eufemia/scripts/prebuild/tasks/prepareTemplates.js index 76b0e0d3ded..a1b50afb02b 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/prepareTemplates.js +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/prepareTemplates.js @@ -12,7 +12,10 @@ import { ErrorHandler, log } from '../../lib' import { asyncForEach } from '../../tools' const prettierrc = JSON.parse( - fs.readFileSync(path.resolve(__dirname, '../../../.prettierrc'), 'utf-8') + fs.readFileSync( + path.resolve(__dirname, '../../../.prettierrc'), + 'utf-8', + ), ) const isCLI = require.main === module @@ -37,7 +40,7 @@ export const processComponents = async () => { templateListToExtendBy: 'Template', srcFile: path.resolve( __dirname, - '../../../src/core/templates/components-index-template.js' + '../../../src/core/templates/components-index-template.js', ), destFile: path.resolve(__dirname, '../../../src/components/index.ts'), filesToFindGlob: path.resolve(__dirname, '../../../src/components/'), @@ -48,23 +51,23 @@ export const processComponents = async () => { (res) => { if (isCLI) { log.succeed( - '> PrePublish: Created the index template with all the components' + '> PrePublish: Created the index template with all the components', ) } return res - } + }, ) await runFactory({ ...componentsTemplateConfig, srcFile: path.resolve( __dirname, - '../../../src/core/templates/components-lib-template.js' + '../../../src/core/templates/components-lib-template.js', ), destFile: path.resolve(__dirname, '../../../src/components/lib.ts'), }).then((res) => { if (isCLI) { log.succeed( - '> PrePublish: Created the index template with all the components' + '> PrePublish: Created the index template with all the components', ) } return res @@ -73,14 +76,14 @@ export const processComponents = async () => { ...componentsTemplateConfig, srcFile: path.resolve( __dirname, - '../../../src/core/templates/component-export-template.js' + '../../../src/core/templates/component-export-template.js', ), destFile: false, destPath: path.resolve(__dirname, '../../../src/components'), }).then((res) => { if (isCLI) { log.succeed( - '> PrePublish: Created the index template with all the components' + '> PrePublish: Created the index template with all the components', ) } return res @@ -96,7 +99,7 @@ export const processFragments = async () => { templateListToExtendBy: 'Template', srcFile: path.resolve( __dirname, - '../../../src/core/templates/components-index-template.js' + '../../../src/core/templates/components-index-template.js', ), destFile: path.resolve(__dirname, '../../../src/fragments/index.ts'), filesToFindGlob: path.resolve(__dirname, '../../../src/fragments/'), @@ -106,7 +109,7 @@ export const processFragments = async () => { await runFactory(fragmentsTemplateConfig).then((res) => { if (isCLI) { log.succeed( - '> PrePublish: Created the index template with all the fragments' + '> PrePublish: Created the index template with all the fragments', ) } return res @@ -115,13 +118,13 @@ export const processFragments = async () => { ...fragmentsTemplateConfig, srcFile: path.resolve( __dirname, - '../../../src/core/templates/fragments-lib-template.js' + '../../../src/core/templates/fragments-lib-template.js', ), destFile: path.resolve(__dirname, '../../../src/fragments/lib.ts'), }).then((res) => { if (isCLI) { log.succeed( - '> PrePublish: Created the index template with all the fragments' + '> PrePublish: Created the index template with all the fragments', ) } return res @@ -130,14 +133,14 @@ export const processFragments = async () => { ...fragmentsTemplateConfig, srcFile: path.resolve( __dirname, - '../../../src/core/templates/fragment-export-template.js' + '../../../src/core/templates/fragment-export-template.js', ), destFile: false, destPath: path.resolve(__dirname, '../../../src/fragments'), }).then((res) => { if (isCLI) { log.succeed( - '> PrePublish: Created the index template with all the fragments' + '> PrePublish: Created the index template with all the fragments', ) } return res @@ -151,7 +154,7 @@ export const processElements = async () => { templateListToExtendBy: 'Template', srcFile: path.resolve( __dirname, - '../../../src/core/templates/elements-index-template.js' + '../../../src/core/templates/elements-index-template.js', ), destFile: path.resolve(__dirname, '../../../src/elements/index.ts'), filesToFindGlob: path.resolve(__dirname, '../../../src/elements/'), @@ -176,7 +179,7 @@ export const processElements = async () => { ...elementsTemplateConfig, srcFile: path.resolve( __dirname, - '../../../src/core/templates/elements-lib-template.js' + '../../../src/core/templates/elements-lib-template.js', ), destFile: path.resolve(__dirname, '../../../src/elements/lib.ts'), processToNamesIgnoreList: ['index', 'lib', 'Element'], @@ -191,14 +194,14 @@ export const processElements = async () => { filesToFindGlobByUsingFolders: true, srcFile: path.resolve( __dirname, - '../../../src/core/templates/element-export-template.js' + '../../../src/core/templates/element-export-template.js', ), destFile: false, destPath: path.resolve(__dirname, '../../../src/elements'), }).then((res) => { if (isCLI) { log.succeed( - '> PrePublish: Created the index template with all the elements' + '> PrePublish: Created the index template with all the elements', ) } return res @@ -214,7 +217,7 @@ export const processExtensions = async () => { templateListToExtendBy: 'Template', srcFile: path.resolve( __dirname, - '../../../src/core/templates/components-index-template.js' + '../../../src/core/templates/components-index-template.js', ), destFile: path.resolve(__dirname, '../../../src/extensions/index.ts'), filesToFindGlob: path.resolve(__dirname, '../../../src/extensions/'), @@ -233,7 +236,7 @@ export const processExtensions = async () => { ...{ srcFile: path.resolve( __dirname, - '../../../src/core/templates/extensions-lib-template.js' + '../../../src/core/templates/extensions-lib-template.js', ), destFile: path.resolve(__dirname, '../../../src/extensions/lib.ts'), }, @@ -253,7 +256,7 @@ export const processMainIndex = async ({ components, elements }) => { templateListToExtendBy: 'Template', srcFile: path.resolve( __dirname, - '../../../src/core/templates/main-index-template.js' + '../../../src/core/templates/main-index-template.js', ), destFile: path.resolve(__dirname, '../../../src/index.ts'), filesToFindGlob: [...components, ...elements], @@ -295,7 +298,7 @@ export const runFactory = async ({ }) if (filesToFindGlobByUsingFolders) { filesToFindGlob = filesToFindGlob.filter(({ source }) => - fs.lstatSync(source).isDirectory() + fs.lstatSync(source).isDirectory(), ) } else { filesToFindGlob = filesToFindGlob @@ -328,7 +331,7 @@ export const runFactory = async ({ await asyncForEach(filesToFindGlob, async ({ file }) => { const destFile = path.resolve( destPath, - `${camelCase(file, { pascalCase: true })}.ts` + `${camelCase(file, { pascalCase: true })}.ts`, ) try { @@ -338,20 +341,20 @@ export const runFactory = async ({ // 1. replace templateListToExtendBy .replace( new RegExp(templateListToExtendBy, 'g'), - camelCase(file, { pascalCase: true }) + camelCase(file, { pascalCase: true }), ) // 2. replace templateListToExtendBy, but lower case .replace( new RegExp(templateListToExtendBy.toLowerCase(), 'g'), - file + file, ) await fs.writeFile( destFile, - prettier.format(`${autoAdvice}${content}`, { + await prettier.format(`${autoAdvice}${content}`, { ...prettierrc, parser: 'babel', - }) + }), ) } catch (e) { log.fail(`There was an error on creating ${destFile}!`) @@ -369,7 +372,7 @@ export const runFactory = async ({ new RegExp(templateObjectToFill, 'g'), `{ ${filesToFindGlob .map(({ file }) => camelCase(file, { pascalCase: true })) - .join(', ')} }` + .join(', ')} }`, ) // 2. replace templateListToExtend .replace( @@ -379,11 +382,11 @@ export const runFactory = async ({ let res = templateListToExtend .replace( new RegExp(templateListToExtendBy, 'g'), - camelCase(file, { pascalCase: true }) + camelCase(file, { pascalCase: true }), ) .replace( new RegExp(templateListToExtendBy.toLowerCase(), 'g'), - file + file, ) // in case we have a type to replace @@ -405,15 +408,15 @@ export const runFactory = async ({ return res }) - .join('\n') + .join('\n'), ) try { await fs.writeFile( destFile, - prettier.format(`${autoAdvice}${content}`, { + await prettier.format(`${autoAdvice}${content}`, { ...prettierrc, parser: 'babel', - }) + }), ) } catch (e) { log.fail(`There was an error on creating ${destFile}!`) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/styleFactory.ts b/packages/dnb-eufemia/scripts/prebuild/tasks/styleFactory.ts index 06432594494..95edf41c766 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/styleFactory.ts +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/styleFactory.ts @@ -10,7 +10,10 @@ import prettier from 'prettier' import { ErrorHandler, log } from '../../lib' const prettierrc = JSON.parse( - fs.readFileSync(path.resolve(__dirname, '../../../.prettierrc'), 'utf-8') + fs.readFileSync( + path.resolve(__dirname, '../../../.prettierrc'), + 'utf-8', + ), ) const fallbackPrefix = 'dnb' @@ -30,7 +33,7 @@ const runStyleFactory = async () => { await runFactory({ scssOutputFile: path.resolve( __dirname, - `../../../src/style/${fallbackPrefix}-ui-components.scss` + `../../../src/style/${fallbackPrefix}-ui-components.scss`, ), customContent: ` @import './core/utilities.scss'; @@ -46,7 +49,7 @@ const runStyleFactory = async () => { }).then(() => { if (require.main === module) { log.succeed( - '> PrePublish: "styleFactory" Created the style file with all the components' + '> PrePublish: "styleFactory" Created the style file with all the components', ) } }) @@ -55,7 +58,7 @@ const runStyleFactory = async () => { await runFactory({ scssOutputFile: path.resolve( __dirname, - `../../../src/style/${fallbackPrefix}-ui-elements.scss` + `../../../src/style/${fallbackPrefix}-ui-elements.scss`, ), customContent: ` @import './core/utilities.scss';`, @@ -69,7 +72,7 @@ const runStyleFactory = async () => { }).then(() => { if (require.main === module) { log.succeed( - '> PrePublish: "styleFactory" Created the style file with all the elements' + '> PrePublish: "styleFactory" Created the style file with all the elements', ) } }) @@ -78,7 +81,7 @@ const runStyleFactory = async () => { await runFactory({ scssOutputFile: path.resolve( __dirname, - `../../../src/style/${fallbackPrefix}-ui-fragments.scss` + `../../../src/style/${fallbackPrefix}-ui-fragments.scss`, ), customContent: ` @import './core/utilities.scss'; @@ -93,7 +96,7 @@ const runStyleFactory = async () => { }).then(() => { if (require.main === module) { log.succeed( - '> PrePublish: "styleFactory" Created the style file with all the fragments' + '> PrePublish: "styleFactory" Created the style file with all the fragments', ) } }) @@ -102,7 +105,7 @@ const runStyleFactory = async () => { await runFactory({ scssOutputFile: path.resolve( __dirname, - `../../../src/style/${fallbackPrefix}-ui-extensions.scss` + `../../../src/style/${fallbackPrefix}-ui-extensions.scss`, ), customContent: ` @import './core/utilities.scss'; @@ -140,7 +143,7 @@ const runFactory = async ({ if (processOnlyList) { const processedList = await globby(processOnlyList) filesToFindGlob = filesToFindGlob.filter((source) => - processedList.some((file) => file.indexOf(source) !== -1) + processedList.some((file) => file.indexOf(source) !== -1), ) } } catch (e) { @@ -163,10 +166,10 @@ const runFactory = async ({ // make sure we have newline at the end - because of StyleLint "no-missing-end-of-source-newline" await fs.writeFile( scssOutputFile, - prettier.format(`${autoAdvice}${customContent}${content}\n`, { + await prettier.format(`${autoAdvice}${customContent}${content}\n`, { ...prettierrc, filepath: scssOutputFile, - }) + }), ) } catch (e) { log.fail(`There was an error on creating ${scssOutputFile}!`) diff --git a/packages/dnb-eufemia/scripts/prebuild/tasks/themeFactory.ts b/packages/dnb-eufemia/scripts/prebuild/tasks/themeFactory.ts index 8c56d97939f..e2ef2b1a73c 100644 --- a/packages/dnb-eufemia/scripts/prebuild/tasks/themeFactory.ts +++ b/packages/dnb-eufemia/scripts/prebuild/tasks/themeFactory.ts @@ -23,7 +23,10 @@ type FallbackFilesParams = { } const prettierrc = JSON.parse( - fs.readFileSync(path.resolve(__dirname, '../../../.prettierrc'), 'utf-8') + fs.readFileSync( + path.resolve(__dirname, '../../../.prettierrc'), + 'utf-8', + ), ) const runThemeFactory = async () => { @@ -43,7 +46,7 @@ const runThemeFactory = async () => { filesToFindGlob: [ path.resolve( __dirname, - '../../../src/{components,fragments}/**/style/themes/**/*-theme-*.scss' + '../../../src/{components,fragments}/**/style/themes/**/*-theme-*.scss', ), ...processToNamesIgnoreList, ], @@ -53,7 +56,7 @@ const runThemeFactory = async () => { }).then(() => { if (require.main === module) { log.succeed( - '> PrePublish: "themeFactory" Created the themes files with all the components, elements, fragments and extensions' + '> PrePublish: "themeFactory" Created the themes files with all the components, elements, fragments and extensions', ) } }) @@ -63,7 +66,7 @@ const runThemeFactory = async () => { filesToFindGlob: [ path.resolve( __dirname, - '../../../src/elements/**/style/themes/**/*-theme-*.scss' + '../../../src/elements/**/style/themes/**/*-theme-*.scss', ), ...processToNamesIgnoreList, ], @@ -73,7 +76,7 @@ const runThemeFactory = async () => { }).then(() => { if (require.main === module) { log.succeed( - '> PrePublish: "themeFactory" Created the themes files with all the components, elements, fragments and extensions' + '> PrePublish: "themeFactory" Created the themes files with all the components, elements, fragments and extensions', ) } }) @@ -83,7 +86,7 @@ const runThemeFactory = async () => { filesToFindGlob: [ path.resolve( __dirname, - '../../../src/extensions/**/style/themes/**/*-theme-*.scss' + '../../../src/extensions/**/style/themes/**/*-theme-*.scss', ), ...processToNamesIgnoreList, ], @@ -93,7 +96,7 @@ const runThemeFactory = async () => { }).then(() => { if (require.main === module) { log.succeed( - '> PrePublish: "themeFactory" Created the themes files with all the components, elements, fragments and extensions' + '> PrePublish: "themeFactory" Created the themes files with all the components, elements, fragments and extensions', ) } }) @@ -130,9 +133,8 @@ export const runFactory = async ({ returnResult = false, }) => { const themeSources = await getThemeSources(filesToFindGlob) - const themesWithRelatedFiles = await collecetRelatedThemeFiles( - themeSources - ) + const themesWithRelatedFiles = + await collecetRelatedThemeFiles(themeSources) const collectedOutput = {} @@ -143,10 +145,10 @@ export const runFactory = async ({ } await fs.writeFile( file, - prettier.format(fileContent, { + await prettier.format(fileContent, { ...prettierrc, filepath: file, - }) + }), ) } @@ -158,9 +160,9 @@ export const runFactory = async ({ if (!fs.existsSync(file)) { fileContent = `${editAdvice.replace( '', - targetFile + targetFile, )}\n\n${customContent}\n\n${insertBelowAdvice}\n\n${files.join( - '' + '', )}` await write(file, fileContent) @@ -177,7 +179,7 @@ export const runFactory = async ({ fileContent = fileContent.replace( new RegExp(`(\\/\\*\\*[^]*${insertBelowTitle}[^]*\\*\\/)([^]*)`), - `$1\n\n${updatedFiles.join('')}\n` + `$1\n\n${updatedFiles.join('')}\n`, ) if (returnResult) { @@ -214,14 +216,14 @@ function getFallbackFiles({ if (fallbackThemeName) { const fallbackIndex = themesWithRelatedFiles.findIndex( - ({ name }) => fallbackThemeName === name + ({ name }) => fallbackThemeName === name, ) if (fallbackIndex >= 0) { files = [ ...files, ...themesWithRelatedFiles[fallbackIndex].files.filter((file) => { return !files.includes( - file.replace(`-${fallbackThemeName}`, `-${currentThemeName}`) + file.replace(`-${fallbackThemeName}`, `-${currentThemeName}`), ) }), ] @@ -289,8 +291,8 @@ async function collecetRelatedThemeFiles(themeSources: ThemeSources) { acc.push( `\n@import '${source.replace( new RegExp(`${path}/src/`, 'g'), - '../../../' - )}';` + '../../../', + )}';`, ) return acc }, []) diff --git a/packages/dnb-eufemia/scripts/tools/cliTools.js b/packages/dnb-eufemia/scripts/tools/cliTools.js index 0c833b0df96..a4323d039e7 100644 --- a/packages/dnb-eufemia/scripts/tools/cliTools.js +++ b/packages/dnb-eufemia/scripts/tools/cliTools.js @@ -29,7 +29,7 @@ const getCommittedFiles = async (countCommits = 10) => { try { const files = ( await runCommand( - `git config diff.renames 0 && git show --pretty="format:" --name-only HEAD...HEAD~${countCommits}` + `git config diff.renames 0 && git show --pretty="format:" --name-only HEAD...HEAD~${countCommits}`, ) ) .split('\n') diff --git a/packages/dnb-eufemia/scripts/tools/createSkeletonFont.js b/packages/dnb-eufemia/scripts/tools/createSkeletonFont.js index d095db3e41f..63789a89e93 100644 --- a/packages/dnb-eufemia/scripts/tools/createSkeletonFont.js +++ b/packages/dnb-eufemia/scripts/tools/createSkeletonFont.js @@ -29,7 +29,7 @@ asyncForEach( const sourcePath = path.resolve( __dirname, '../../assets/fonts/dnb/', - soruceFile + soruceFile, ) const familyName = `${fontName}Skeleton` @@ -67,7 +67,7 @@ asyncForEach( log.fail(`Failed: ${fileName}-${styleName}`) console.error(e) } - } + }, ) const createChar = (s) => s.charCodeAt(0) @@ -134,7 +134,7 @@ async function minifyFonts() { const fontmin = new Fontmin() fontmin.src( - path.resolve(__dirname, '../../assets/fonts/dnb/skeleton/*.otf') + path.resolve(__dirname, '../../assets/fonts/dnb/skeleton/*.otf'), ) fontmin.use(Fontmin.otf2ttf()) @@ -142,7 +142,7 @@ async function minifyFonts() { fontmin.use(Fontmin.ttf2woff2()) fontmin.dest( - path.resolve(__dirname, '../../assets/fonts/dnb/skeleton/') + path.resolve(__dirname, '../../assets/fonts/dnb/skeleton/'), ) fontmin.run(function (err) { diff --git a/packages/dnb-eufemia/scripts/tools/index.ts b/packages/dnb-eufemia/scripts/tools/index.ts index 378411933e8..99789bb95a4 100644 --- a/packages/dnb-eufemia/scripts/tools/index.ts +++ b/packages/dnb-eufemia/scripts/tools/index.ts @@ -7,16 +7,20 @@ export type AsyncForEachCallback = ( item: Array[number], i: number, - array: Array + array: Array, ) => unknown export async function asyncForEach( array: Array, - callback: AsyncForEachCallback + callback: AsyncForEachCallback, ) { let res = [] for (let i = 0, l = array.length; i < l; ++i) { - const cur = await callback(array[i] as typeof array[number], i, array) + const cur = await callback( + array[i] as (typeof array)[number], + i, + array, + ) if (typeof cur !== 'undefined') { res = res.concat(cur) } diff --git a/packages/dnb-eufemia/src/components/accordion/Accordion.tsx b/packages/dnb-eufemia/src/components/accordion/Accordion.tsx index 6007aee8a80..ef6b9295252 100644 --- a/packages/dnb-eufemia/src/components/accordion/Accordion.tsx +++ b/packages/dnb-eufemia/src/components/accordion/Accordion.tsx @@ -174,7 +174,7 @@ function Accordion({ // States ordered last here to make sure that the getInitialExpandedState have access to the store const [previousExpanded, setPreviousExpanded] = useState(props.expanded) const [expanded, setExpanded] = useState( - getInitialExpandedState() + getInitialExpandedState(), ) // replacement for getDerivedStateFromProps @@ -314,7 +314,7 @@ function Accordion({ nestedContext as Record, // internal context { skeleton: globalContext?.skeleton }, globalContext.Accordion, // global context - globalContext.translation.Accordion + globalContext.translation.Accordion, ) if (expandedState === undefined && globalContext.Accordion) { @@ -365,7 +365,7 @@ function Accordion({ prerender && 'dnb-accordion--prerender', createSpacingClasses(extendedProps), className, - _className + _className, ), } as HTMLProps @@ -380,7 +380,7 @@ function Accordion({ props, accordionDefaultProps, { expanded, group }, - context + context, ) const accordionContext = { @@ -403,13 +403,13 @@ function Accordion({
    {findElementInChildren( children, - (cur) => cur.type === AccordionHeader + (cur) => cur.type === AccordionHeader, ) ? null : ( )} {findElementInChildren( children, - (cur) => cur.type === AccordionContent + (cur) => cur.type === AccordionContent, ) ? ( children ) : ( diff --git a/packages/dnb-eufemia/src/components/accordion/AccordionContent.tsx b/packages/dnb-eufemia/src/components/accordion/AccordionContent.tsx index 764cf0ff09f..04cc43345a5 100644 --- a/packages/dnb-eufemia/src/components/accordion/AccordionContent.tsx +++ b/packages/dnb-eufemia/src/components/accordion/AccordionContent.tsx @@ -63,7 +63,7 @@ export default function AccordionContent(props: AccordionContentProps) { const containerElement = getPreviousSibling( 'dnb-accordion-group--single-container', - contentElem + contentElem, ) as HTMLElement if (no_animation) { @@ -153,7 +153,7 @@ export default function AccordionContent(props: AccordionContentProps) { 'aria-labelledby': `${id}-header`, className: classnames( 'dnb-accordion__content__inner', - createSpacingClasses(rest) + createSpacingClasses(rest), ), } as HTMLProps diff --git a/packages/dnb-eufemia/src/components/accordion/AccordionGroup.tsx b/packages/dnb-eufemia/src/components/accordion/AccordionGroup.tsx index f3abbdbaf6a..ddac78cd79d 100644 --- a/packages/dnb-eufemia/src/components/accordion/AccordionGroup.tsx +++ b/packages/dnb-eufemia/src/components/accordion/AccordionGroup.tsx @@ -50,7 +50,7 @@ const AccordionGroup = (props: AccordionGroupProps) => { props, accordionDefaultProps, context.Accordion, - context.getTranslation(props).Accordion + context.getTranslation(props).Accordion, ) const { @@ -80,7 +80,7 @@ const AccordionGroup = (props: AccordionGroupProps) => { isTrue(single_container) && 'dnb-accordion-group--single-container', createSpacingClasses(extendedProps), className, - _className + _className, ) const params = { diff --git a/packages/dnb-eufemia/src/components/accordion/AccordionHeader.tsx b/packages/dnb-eufemia/src/components/accordion/AccordionHeader.tsx index aac63142f6d..a2705c24cee 100644 --- a/packages/dnb-eufemia/src/components/accordion/AccordionHeader.tsx +++ b/packages/dnb-eufemia/src/components/accordion/AccordionHeader.tsx @@ -37,7 +37,7 @@ function AccordionHeaderTitle({ {children} @@ -57,7 +57,7 @@ function AccordionHeaderDescription({ {children} @@ -77,7 +77,7 @@ function AccordionHeaderContainer({ {children} @@ -197,7 +197,9 @@ export const AccordionHeader = ({ } function onClickHandler( - event: React.MouseEvent | React.KeyboardEvent + event: + | React.MouseEvent + | React.KeyboardEvent, ) { const { id, group } = context @@ -226,7 +228,7 @@ export const AccordionHeader = ({ const extendedProps = extendPropsWithContext( props, accordionHeaderDefaultProps, - context as Record + context as Record, ) const { @@ -338,7 +340,7 @@ export const AccordionHeader = ({ // position the icon to the right, if the element is not in the beginning if (icon_position === undefined) { const iconIndex = partsToRender.findIndex( - (c) => c.type === AccordionHeaderIcon + (c) => c.type === AccordionHeaderIcon, ) // because of the container at the beginning, we use 1 if (iconIndex > 1) { @@ -365,7 +367,7 @@ export const AccordionHeader = ({ no_animation && 'dnb-accordion__header--no-animation', createSkeletonClass('font', skeleton, context), createSpacingClasses(rest), - className + className, ), disabled, ...rest, diff --git a/packages/dnb-eufemia/src/components/accordion/AccordionStore.ts b/packages/dnb-eufemia/src/components/accordion/AccordionStore.ts index 8d5c04bd9d9..14725d3af4f 100644 --- a/packages/dnb-eufemia/src/components/accordion/AccordionStore.ts +++ b/packages/dnb-eufemia/src/components/accordion/AccordionStore.ts @@ -95,7 +95,7 @@ export class Store { if ( Object.prototype.hasOwnProperty.call( window.localStorage, - storeId + storeId, ) ) { return JSON.parse(window.localStorage.getItem(storeId)) diff --git a/packages/dnb-eufemia/src/components/accordion/__tests__/Accordion.test.tsx b/packages/dnb-eufemia/src/components/accordion/__tests__/Accordion.test.tsx index ab1bb923375..6e4773bf165 100644 --- a/packages/dnb-eufemia/src/components/accordion/__tests__/Accordion.test.tsx +++ b/packages/dnb-eufemia/src/components/accordion/__tests__/Accordion.test.tsx @@ -28,19 +28,19 @@ describe('Accordion component', () => { expect( document .querySelector('.dnb-accordion__header') - .getAttribute('aria-expanded') + .getAttribute('aria-expanded'), ).toBe('false') fireEvent.click(document.querySelector('.dnb-accordion__header')) // we could send inn the event data structure like this: , { target: { expanded: true } } expect( document .querySelector('.dnb-accordion__header') - .getAttribute('aria-expanded') + .getAttribute('aria-expanded'), ).toBe('true') rerender() expect( document .querySelector('.dnb-accordion__header') - .getAttribute('aria-expanded') + .getAttribute('aria-expanded'), ).toBe('false') }) @@ -53,7 +53,7 @@ describe('Accordion component', () => { on_change={my_event} onChange={myEvent} expanded={false} - /> + />, ) // first click @@ -73,22 +73,22 @@ describe('Accordion component', () => { const { rerender } = render( string content - + , ) expect(document.querySelector('.dnb-p').textContent).toBe( - 'string content' + 'string content', ) rerender( no string content - + , ) expect(document.querySelector('.dnb-p')).toBeFalsy() expect(document.querySelector('.no-string').textContent).toBe( - 'no string content' + 'no string content', ) }) @@ -97,7 +97,7 @@ describe('Accordion component', () => { rerender() expect( - document.querySelector('.dnb-accordion__header') + document.querySelector('.dnb-accordion__header'), ).toHaveAttribute('disabled') }) @@ -106,10 +106,10 @@ describe('Accordion component', () => { expect( Array.from( - document.querySelector('.dnb-accordion__header').classList - ) + document.querySelector('.dnb-accordion__header').classList, + ), ).toEqual( - expect.arrayContaining(['dnb-accordion__header--no-animation']) + expect.arrayContaining(['dnb-accordion__header--no-animation']), ) }) @@ -121,34 +121,34 @@ describe('Accordion component', () => { closed: AddIcon, expanded: SubtractIcon, }} - /> + />, ) const { container: c1 } = render() const { container: c2 } = render() expect(document.querySelector('.dnb-accordion svg').outerHTML).toBe( - c1.innerHTML + c1.innerHTML, ) fireEvent.click(document.querySelector('.dnb-accordion__header')) expect(document.querySelector('.dnb-accordion svg').outerHTML).toBe( - c2.innerHTML + c2.innerHTML, ) }) it('supports default outlined variant', () => { render() expect(document.querySelector('.dnb-accordion').classList).toContain( - 'dnb-accordion__variant--outlined' + 'dnb-accordion__variant--outlined', ) }) it('supports plain variant', () => { render() expect(document.querySelector('.dnb-accordion').classList).toContain( - 'dnb-accordion__variant--plain' + 'dnb-accordion__variant--plain', ) }) @@ -157,16 +157,16 @@ describe('Accordion component', () => { expect( Array.from( - document.querySelector('.dnb-accordion__content').classList - ) + document.querySelector('.dnb-accordion__content').classList, + ), ).toEqual(expect.arrayContaining(['dnb-height-animation--hidden'])) fireEvent.click(document.querySelector('.dnb-accordion__header')) expect( Array.from( - document.querySelector('.dnb-accordion__content').classList - ) + document.querySelector('.dnb-accordion__content').classList, + ), ).toEqual(expect.arrayContaining(['dnb-height-animation--is-in-dom'])) }) @@ -221,14 +221,14 @@ describe('Accordion group component', () => { Accordion 2 - + , ) expect( - document.querySelector('#accordion-1 .dnb-accordion__content') + document.querySelector('#accordion-1 .dnb-accordion__content'), ).toBeInTheDocument() expect( - document.querySelector('#accordion-2 .dnb-accordion__content') + document.querySelector('#accordion-2 .dnb-accordion__content'), ).toBeFalsy() }) @@ -255,11 +255,11 @@ describe('Accordion group component', () => { data-prop="value-2" attributes={{ 'data-attr': 'value' }} /> - + , ) fireEvent.click( - document.querySelector('#accordion-1 .dnb-accordion__header') + document.querySelector('#accordion-1 .dnb-accordion__header'), ) expect(my_event).toHaveBeenCalled() expect(my_event.mock.calls[0][0].id).toBe('accordion-1') @@ -267,13 +267,13 @@ describe('Accordion group component', () => { expect(myEvent.mock.calls.length).toBe(1) fireEvent.click( - document.querySelector('#accordion-2 .dnb-accordion__header') + document.querySelector('#accordion-2 .dnb-accordion__header'), ) expect(my_event.mock.calls[1][0].id).toBe('accordion-2') expect(my_event.mock.calls[1][0].expanded).toBe(true) fireEvent.click( - document.querySelector('#accordion-1 .dnb-accordion__header') + document.querySelector('#accordion-1 .dnb-accordion__header'), ) expect(my_event.mock.calls[2][0].expanded).toBe(true) }) @@ -335,64 +335,64 @@ describe('Accordion container component', () => { render() expect(document.querySelector('button#increment').textContent).toBe( - '1' + '1', ) fireEvent.click(document.querySelector('button#increment')) expect(document.querySelector('button#increment').textContent).toBe( - '2' + '2', ) expect(document.querySelector('div#mounted-1')).toBeFalsy() expect(document.querySelector('div#mounted-2').textContent).toBe( - 'true' + 'true', ) expect(document.querySelector('div#mounted-3')).toBeFalsy() expect( document .querySelector('#accordion-2 .dnb-accordion__header') - .getAttribute('aria-expanded') + .getAttribute('aria-expanded'), ).toBe('true') fireEvent.click( - document.querySelector('#accordion-1 .dnb-accordion__header') + document.querySelector('#accordion-1 .dnb-accordion__header'), ) fireEvent.click(document.querySelector('button#increment')) expect(document.querySelector('button#increment').textContent).toBe( - '3' + '3', ) expect(document.querySelector('div#mounted-1').textContent).toBe( - 'true' + 'true', ) expect(document.querySelector('div#mounted-2').textContent).toBe( - 'true' + 'true', ) expect(document.querySelector('div#mounted-3')).toBeFalsy() fireEvent.click( - document.querySelector('#accordion-2 .dnb-accordion__header') + document.querySelector('#accordion-2 .dnb-accordion__header'), ) fireEvent.click(document.querySelector('button#increment')) expect(document.querySelector('button#increment').textContent).toBe( - '4' + '4', ) expect(document.querySelector('div#mounted-3')).toBeFalsy() fireEvent.click( - document.querySelector('#accordion-3 .dnb-accordion__header') + document.querySelector('#accordion-3 .dnb-accordion__header'), ) fireEvent.click(document.querySelector('button#increment')) expect(document.querySelector('button#increment').textContent).toBe( - '5' + '5', ) expect(document.querySelector('div#mounted-3').textContent).toBe( - 'true' + 'true', ) }) @@ -407,13 +407,13 @@ describe('Accordion container component', () => { jest.spyOn(contentElem, 'offsetTop', 'get').mockReturnValue(48) fireEvent.click( - document.querySelector('#accordion-1 .dnb-accordion__header') + document.querySelector('#accordion-1 .dnb-accordion__header'), ) expect( document .querySelector('.dnb-accordion-group--single-container') - .getAttribute('style') + .getAttribute('style'), ).toBe('transition-duration: 1ms; min-height: 6rem;') }) }) @@ -426,7 +426,7 @@ describe('Accordion scss', () => { it('have to match default theme snapshot', () => { const css = loadScss( - require.resolve('../style/themes/dnb-accordion-theme-ui.scss') + require.resolve('../style/themes/dnb-accordion-theme-ui.scss'), ) expect(css).toMatchSnapshot() }) diff --git a/packages/dnb-eufemia/src/components/accordion/style/dnb-accordion.scss b/packages/dnb-eufemia/src/components/accordion/style/dnb-accordion.scss index 4451daeb60d..e23bd7e618e 100644 --- a/packages/dnb-eufemia/src/components/accordion/style/dnb-accordion.scss +++ b/packages/dnb-eufemia/src/components/accordion/style/dnb-accordion.scss @@ -122,7 +122,8 @@ width: 100%; will-change: height; - transition: height 400ms var(--accordion-easing), + transition: + height 400ms var(--accordion-easing), opacity 600ms var(--accordion-easing); &__inner { diff --git a/packages/dnb-eufemia/src/components/anchor/Anchor.tsx b/packages/dnb-eufemia/src/components/anchor/Anchor.tsx index 5cf63d96811..77c6661b728 100644 --- a/packages/dnb-eufemia/src/components/anchor/Anchor.tsx +++ b/packages/dnb-eufemia/src/components/anchor/Anchor.tsx @@ -48,7 +48,7 @@ export function AnchorInstance(localProps: AnchorAllProps) { defaultProps, { skeleton: context?.skeleton }, context?.getTranslation(localProps as AnchorAllProps).Anchor, - context?.Anchor + context?.Anchor, ) // deprecated: inner_ref is still needed to support Button's usage of Anchor @@ -113,7 +113,7 @@ export function AnchorInstance(localProps: AnchorAllProps) { 'dnb-anchor--no-icon', typeof children !== 'string' && 'dnb-anchor--has-icon', prefix && 'dnb-anchor--icon-left', - suffix && 'dnb-anchor--icon-right' + suffix && 'dnb-anchor--icon-right', )} {...attributes} innerRef={innerRef} @@ -140,13 +140,13 @@ export function AnchorInstance(localProps: AnchorAllProps) { const Anchor = React.forwardRef( (props: AnchorAllProps, ref: React.RefObject) => { return - } + }, ) export default Anchor export function scrollToHashHandler( - e: React.MouseEvent + e: React.MouseEvent, ) { const element = e.currentTarget as HTMLAnchorElement const href = element.getAttribute('href') @@ -176,7 +176,7 @@ export function scrollToHashHandler( e.preventDefault() const scrollPadding = parseFloat( - window.getComputedStyle(document.documentElement).scrollPaddingTop + window.getComputedStyle(document.documentElement).scrollPaddingTop, ) const top = getOffsetTop(anchorElem) - scrollPadding || 0 diff --git a/packages/dnb-eufemia/src/components/anchor/__tests__/Anchor.screenshot.test.ts b/packages/dnb-eufemia/src/components/anchor/__tests__/Anchor.screenshot.test.ts index e8ceb444cf1..645fe91204d 100644 --- a/packages/dnb-eufemia/src/components/anchor/__tests__/Anchor.screenshot.test.ts +++ b/packages/dnb-eufemia/src/components/anchor/__tests__/Anchor.screenshot.test.ts @@ -222,7 +222,7 @@ describe.each(['ui', 'sbanken'])( expect(screenshot).toMatchImageSnapshot() }) } - } + }, ) describe.each(['ui', 'sbanken'])( @@ -250,5 +250,5 @@ describe.each(['ui', 'sbanken'])( }) expect(screenshot).toMatchImageSnapshot() }) - } + }, ) diff --git a/packages/dnb-eufemia/src/components/anchor/__tests__/Anchor.test.tsx b/packages/dnb-eufemia/src/components/anchor/__tests__/Anchor.test.tsx index 241bbcb80eb..31fa6839459 100644 --- a/packages/dnb-eufemia/src/components/anchor/__tests__/Anchor.test.tsx +++ b/packages/dnb-eufemia/src/components/anchor/__tests__/Anchor.test.tsx @@ -28,10 +28,10 @@ describe('Anchor element', () => { render( text - + , ) expect(document.querySelector('a').getAttribute('id')).toBe( - 'unique-id' + 'unique-id', ) }) @@ -39,12 +39,12 @@ describe('Anchor element', () => { render( text - + , ) expect( document.querySelector('#unique-id-tooltip.dnb-tooltip__content') - .textContent + .textContent, ).toBe('Tooltip') }) @@ -52,13 +52,13 @@ describe('Anchor element', () => { render( text - + , ) const element = document.getElementById('unique-id') expect(element.getAttribute('aria-describedby')).toBe( - 'unique-id-tooltip' + 'unique-id-tooltip', ) }) @@ -66,7 +66,7 @@ describe('Anchor element', () => { render( text - + , ) const element = document.getElementById('unique-id') @@ -74,7 +74,7 @@ describe('Anchor element', () => { expect( document.querySelector('#unique-id-tooltip.dnb-tooltip__content') - .parentElement.classList + .parentElement.classList, ).toContain('dnb-tooltip--active') }) @@ -82,10 +82,10 @@ describe('Anchor element', () => { render( text - + , ) expect( - document.querySelector('.dnb-anchor--no-icon') + document.querySelector('.dnb-anchor--no-icon'), ).toBeInTheDocument() }) @@ -95,7 +95,7 @@ describe('Anchor element', () => { render( text - + , ) act(() => { @@ -108,7 +108,7 @@ describe('Anchor element', () => { const { rerender } = render( text - + , ) const id = ( @@ -116,7 +116,7 @@ describe('Anchor element', () => { ).getAttribute('aria-describedby') expect( (document.body.querySelector('#' + id) as HTMLAnchorElement) - .textContent + .textContent, ).toBe('Opens a new Window') const title = 'External site' @@ -124,13 +124,13 @@ describe('Anchor element', () => { rerender( text - + , ) expect( (document.querySelector('a') as HTMLAnchorElement).getAttribute( - 'title' - ) + 'title', + ), ).toBe(title) expect(document.body.querySelector('#' + id)).toBe(null) }) @@ -139,7 +139,7 @@ describe('Anchor element', () => { render( text - + , ) expect(document.querySelector('[rel="external"]')).toBeInTheDocument() }) @@ -153,10 +153,10 @@ describe('Anchor element', () => { render( text - + , ) expect( - document.querySelector('.dnb-anchor--icon-left') + document.querySelector('.dnb-anchor--icon-left'), ).toBeInTheDocument() }) @@ -164,10 +164,10 @@ describe('Anchor element', () => { render( text - + , ) expect( - document.querySelector('.dnb-anchor--icon-right') + document.querySelector('.dnb-anchor--icon-right'), ).toBeInTheDocument() }) @@ -175,10 +175,10 @@ describe('Anchor element', () => { render( text - + , ) expect( - document.querySelector('.dnb-anchor--icon-left') + document.querySelector('.dnb-anchor--icon-left'), ).toBeInTheDocument() }) @@ -186,10 +186,10 @@ describe('Anchor element', () => { render( text - + , ) expect( - document.querySelector('.dnb-anchor--no-icon') + document.querySelector('.dnb-anchor--no-icon'), ).toBeInTheDocument() }) }) @@ -205,10 +205,10 @@ describe('Anchor scss', () => { (themeName) => { const css = loadScss( require.resolve( - `../style/themes/dnb-anchor-theme-${themeName}.scss` - ) + `../style/themes/dnb-anchor-theme-${themeName}.scss`, + ), ) expect(css).toMatchSnapshot() - } + }, ) }) diff --git a/packages/dnb-eufemia/src/components/anchor/__tests__/AnchorScroll.test.tsx b/packages/dnb-eufemia/src/components/anchor/__tests__/AnchorScroll.test.tsx index ae43334b198..60c77fa50f1 100644 --- a/packages/dnb-eufemia/src/components/anchor/__tests__/AnchorScroll.test.tsx +++ b/packages/dnb-eufemia/src/components/anchor/__tests__/AnchorScroll.test.tsx @@ -29,7 +29,7 @@ describe('Anchor with scrollToHashHandler', () => { text - + , ) const element = document.querySelector('a') @@ -57,7 +57,7 @@ describe('Anchor with scrollToHashHandler', () => { text - + , ) const element = document.querySelector('a') @@ -82,7 +82,7 @@ describe('Anchor with scrollToHashHandler', () => { text - + , ) const element = document.querySelector('a') @@ -103,7 +103,7 @@ describe('Anchor with scrollToHashHandler', () => { render( text - + , ) const element = document.querySelector('a') @@ -127,7 +127,7 @@ describe('Anchor with scrollToHashHandler', () => { text - + , ) const element = document.querySelector('a') diff --git a/packages/dnb-eufemia/src/components/anchor/style/anchor-mixins.scss b/packages/dnb-eufemia/src/components/anchor/style/anchor-mixins.scss index 12824ba8d72..31e8a25d0fb 100644 --- a/packages/dnb-eufemia/src/components/anchor/style/anchor-mixins.scss +++ b/packages/dnb-eufemia/src/components/anchor/style/anchor-mixins.scss @@ -105,7 +105,9 @@ @mixin anchorBackground($color, $overflow: 0.125em) { @if $overflow { - box-shadow: inset 100vw 100vw 0 0 $color, -$overflow 0 0 0 $color, + box-shadow: + inset 100vw 100vw 0 0 $color, + -$overflow 0 0 0 $color, $overflow 0 0 0 $color; } @else { box-shadow: inset 100vw 100vw 0 0 $color; @@ -164,7 +166,9 @@ background-image: inherit; - transition: transform 0.3s ease-out, filter 1s ease-in-out; + transition: + transform 0.3s ease-out, + filter 1s ease-in-out; transform-origin: bottom; } @@ -200,7 +204,9 @@ } } - transition: box-shadow 200ms ease-in-out, border-radius 200ms ease-in-out, + transition: + box-shadow 200ms ease-in-out, + border-radius 200ms ease-in-out, background 200ms ease-in-out; [data-visual-test-wrapper] & { diff --git a/packages/dnb-eufemia/src/components/anchor/style/themes/dnb-anchor-theme-sbanken.scss b/packages/dnb-eufemia/src/components/anchor/style/themes/dnb-anchor-theme-sbanken.scss index 5bd8756472a..2ccd1f915ec 100644 --- a/packages/dnb-eufemia/src/components/anchor/style/themes/dnb-anchor-theme-sbanken.scss +++ b/packages/dnb-eufemia/src/components/anchor/style/themes/dnb-anchor-theme-sbanken.scss @@ -107,7 +107,9 @@ } } - &:not(.dnb-anchor--no-underline):not(.dnb-anchor--has-icon):not(.anchor-hash):not(.dnb-anchor--inline):not(.dnb-anchor--no-style) { + &:not(.dnb-anchor--no-underline):not(.dnb-anchor--has-icon):not( + .anchor-hash + ):not(.dnb-anchor--inline):not(.dnb-anchor--no-style) { &:not(.dnb-anchor--icon-left) { &::before { text-decoration-color: var(--sb-color-green-dark); diff --git a/packages/dnb-eufemia/src/components/autocomplete/Autocomplete.js b/packages/dnb-eufemia/src/components/autocomplete/Autocomplete.js index a6ad01bfe1b..2e407b59116 100644 --- a/packages/dnb-eufemia/src/components/autocomplete/Autocomplete.js +++ b/packages/dnb-eufemia/src/components/autocomplete/Autocomplete.js @@ -190,7 +190,7 @@ export default class Autocomplete extends React.PureComponent { PropTypes.arrayOf(PropTypes.string), ]), }), - ]) + ]), ), ]), search_in_word_index: PropTypes.oneOfType([ @@ -365,7 +365,7 @@ class AutocompleteInstance extends React.PureComponent { dataItem.search_content || dataItem, { separator: ' ', - } + }, ) if (typeof searchWord !== 'string' && Array.isArray(searchWord)) { return AutocompleteInstance.parseDataItem(searchWord) @@ -452,7 +452,7 @@ class AutocompleteInstance extends React.PureComponent { this.setState({}, () => { const inputValue = AutocompleteInstance.getCurrentDataTitle( this.context.drawerList.selected_item, - this.context.drawerList.original_data + this.context.drawerList.original_data, ) this.setState({ inputValue, @@ -587,12 +587,12 @@ class AutocompleteInstance extends React.PureComponent { runFilterToHighlight = ( { fillDataIfEmpty = false, ...options } = {}, - value = this.state.inputValue + value = this.state.inputValue, ) => { // do not filter or highlight if the current selected item is the same as the input value const possibleTitle = AutocompleteInstance.getCurrentDataTitle( this.context.drawerList.selected_item, - this.context.drawerList.original_data + this.context.drawerList.original_data, ) if (value === possibleTitle) { @@ -678,7 +678,7 @@ class AutocompleteInstance extends React.PureComponent { }, { overwriteOriginalData: true, - } + }, ) } @@ -759,7 +759,7 @@ class AutocompleteInstance extends React.PureComponent { this.resetSelectionItem() } } - } + }, ) this.context.drawerList.setData( @@ -783,12 +783,12 @@ class AutocompleteInstance extends React.PureComponent { this.showAllItems() } } - } + }, ) }, { overwriteOriginalData: true, - } + }, ) return this @@ -907,7 +907,7 @@ class AutocompleteInstance extends React.PureComponent { clearTimeout(this._blurTimeout) this._blurTimeout = setTimeout( resetAfterClose, - DrawerList.blurDelay + DrawerList.blurDelay, ) // only to let the animation pass, before we make the effect. Else this would be a visible change } } @@ -1065,7 +1065,7 @@ class AutocompleteInstance extends React.PureComponent { overwriteSearchIndex = false, data = this.context.drawerList.original_data, } = {}, - cb + cb, ) { this._cacheMemory = {} @@ -1080,7 +1080,7 @@ class AutocompleteInstance extends React.PureComponent { searchIndex, _listenForPropChanges: false, }, - cb + cb, ) return searchIndex @@ -1101,7 +1101,7 @@ class AutocompleteInstance extends React.PureComponent { ignore_events: false, // we also have to reset this one }) }, 10) // make sure we reset once the rerender of DrawerList is done, because then we keep the active_item at it's position by using key="down" - } + }, ) } @@ -1124,7 +1124,7 @@ class AutocompleteInstance extends React.PureComponent { this.context.drawerList.selected_item, { scrollTo: false, - } + }, ) } @@ -1163,7 +1163,7 @@ class AutocompleteInstance extends React.PureComponent { ...this.getEventObjects('on_change'), }) } - } + }, ) } @@ -1172,7 +1172,7 @@ class AutocompleteInstance extends React.PureComponent { const inputValue = AutocompleteInstance.getCurrentDataTitle( this.context.drawerList.selected_item, - this.context.drawerList.original_data + this.context.drawerList.original_data, ) clearTimeout(this._selectTimeout) @@ -1208,7 +1208,7 @@ class AutocompleteInstance extends React.PureComponent { disableHighlighting = false, skipFilter = false, skipReorder = false, - } = {} + } = {}, ) => { if (data) { searchIndex = this.setSearchIndex({ data }) @@ -1250,7 +1250,7 @@ class AutocompleteInstance extends React.PureComponent { // if the uses reached word 3, then we go inside words as well const regexWord = new RegExp( wordIndex > inWordIndex ? `${word}` : `(${wordCond})${word}`, - 'i' + 'i', ) if (regexWord.test(contentChunk)) { @@ -1274,7 +1274,7 @@ class AutocompleteInstance extends React.PureComponent { // and give a score for each one wordScore += ( contentChunk.match( - new RegExp(`(${wordCond})${escapeRegexChars(word)}`, 'ig') + new RegExp(`(${wordCond})${escapeRegexChars(word)}`, 'ig'), ) || [] ).length @@ -1283,7 +1283,7 @@ class AutocompleteInstance extends React.PureComponent { // Check if the first chunk starts the first written word const isFirstWord = new RegExp( `^${escapeRegexChars(searchWords[0])}`, - 'i' + 'i', ).test(contentChunk.split(' ')[0]) // If yes, add the amount of possible words + 1 @@ -1360,7 +1360,7 @@ class AutocompleteInstance extends React.PureComponent { if (/[\d\w]/.test(char)) { segment = segment.replace( new RegExp(`(${char})`, 'gi'), - `${strS}$1${strE}` + `${strS}$1${strE}`, ) } }) @@ -1368,12 +1368,12 @@ class AutocompleteInstance extends React.PureComponent { if (wordIndex > inWordIndex) { segment = segment.replace( new RegExp(`(${word})`, 'gi'), - `${strS}$1${strE}` + `${strS}$1${strE}`, ) } else { segment = segment.replace( new RegExp(`(${wordCond})(${word})`, 'gi'), - `$1${strS}$2${strE}` + `$1${strS}$2${strE}`, ) } } @@ -1421,7 +1421,7 @@ class AutocompleteInstance extends React.PureComponent { result = React.cloneElement( originalChild, { key: 'clone' + cacheHash + idx }, - result + result, ) } } @@ -1457,7 +1457,7 @@ class AutocompleteInstance extends React.PureComponent { if (!this.skipReorder && !skipReorder) { searchIndex = searchIndex.sort( - ({ totalScore: a }, { totalScore: b }) => b - a + ({ totalScore: a }, { totalScore: b }) => b - a, ) } @@ -1506,7 +1506,7 @@ class AutocompleteInstance extends React.PureComponent { hasFocus: false, }) }, 1) // we have to wait in order to make sure the focus situation is cleared up - } + }, ) } @@ -1565,18 +1565,18 @@ class AutocompleteInstance extends React.PureComponent { { inputValue: AutocompleteInstance.getCurrentDataTitle( selected_item, - this.context.drawerList.data + this.context.drawerList.data, ), skipFocusDuringChange: false, _listenForPropChanges: false, }, - () => this.setFocusOnInput() + () => this.setFocusOnInput(), ) } else { this.setState({ inputValue: AutocompleteInstance.getCurrentDataTitle( selected_item, - this.context.drawerList.data + this.context.drawerList.data, ), _listenForPropChanges: false, }) @@ -1637,7 +1637,7 @@ class AutocompleteInstance extends React.PureComponent { const { active_item, selected_item } = this.context.drawerList const currentDataItem = getCurrentData( active_item, - this.context.drawerList.data + this.context.drawerList.data, ) return ( @@ -1662,7 +1662,7 @@ class AutocompleteInstance extends React.PureComponent { Autocomplete.defaultProps, this.context.getTranslation(this.props).Autocomplete, includeValidProps(this.context.FormRow), - this.context.Autocomplete + this.context.Autocomplete, )) const { @@ -1774,7 +1774,7 @@ class AutocompleteInstance extends React.PureComponent { 'dnb-form-component', createSpacingClasses(props), _className, - className + className, ), } @@ -1840,7 +1840,7 @@ class AutocompleteInstance extends React.PureComponent { inputParams['aria-describedby'] = combineDescribedBy( inputParams, showStatus ? id + '-status' : null, - suffix ? id + '-suffix' : null + suffix ? id + '-suffix' : null, ) } @@ -1880,7 +1880,7 @@ class AutocompleteInstance extends React.PureComponent { const suffixValue = getCurrentData( selected_item, - this.context.drawerList.original_data + this.context.drawerList.original_data, )?.suffix_value const innerId = suffixValue && showStatus ? `${id}-inner` : null @@ -1986,7 +1986,7 @@ class AutocompleteInstance extends React.PureComponent { id={id} className={classnames( 'dnb-autocomplete__root', - drawer_class + drawer_class, )} portal_class={portal_class} list_class="dnb-autocomplete__list" diff --git a/packages/dnb-eufemia/src/components/autocomplete/__tests__/Autocomplete.test.tsx b/packages/dnb-eufemia/src/components/autocomplete/__tests__/Autocomplete.test.tsx index cd616705c0d..6ba9ba806e3 100644 --- a/packages/dnb-eufemia/src/components/autocomplete/__tests__/Autocomplete.test.tsx +++ b/packages/dnb-eufemia/src/components/autocomplete/__tests__/Autocomplete.test.tsx @@ -62,12 +62,12 @@ describe('Autocomplete component', () => { opened input_value="the g th" {...mockProps} - /> + />, ) expect( - document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML + document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML, ).toBe( - /* html */ `
  • The Godfather the godfather The Godfather
  • ` + /* html */ `
  • The Godfather the godfather The Godfather
  • `, ) }) @@ -90,7 +90,7 @@ describe('Autocomplete component', () => { it('has correct options after filter', () => { render( - + , ) toggle() @@ -100,13 +100,13 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll( - 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)' - ).length + 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)', + ).length, ).toBe(1) expect( document.querySelector( - 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)' - ).textContent + 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)', + ).textContent, ).toBe(mockData[0]) // check "cc" @@ -115,8 +115,8 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll( - 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)' - ).length + 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)', + ).length, ).toBe(2) // check "bb cc" @@ -125,12 +125,12 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[1]) expect( document.querySelectorAll( - 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)' - ).length + 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)', + ).length, ).toBe(2) // check "aa cc" @@ -139,7 +139,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[0]) // check inside words @@ -148,12 +148,12 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[1]) expect( - document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML + document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML, ).toBe( - /* html */ `
  • BB cc zethx
  • ` + /* html */ `
  • BB cc zethx
  • `, ) // check "invalid" @@ -162,7 +162,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe('Ingen alternativer') }) @@ -174,30 +174,30 @@ describe('Autocomplete component', () => { jest.spyOn(window, 'getComputedStyle').mockImplementation(() => style) const { rerender } = render( - + , ) const styleElement = document.querySelector( - '.dnb-drawer-list__portal__style' + '.dnb-drawer-list__portal__style', ) await waitFor(() => { expect(styleElement.getAttribute('style')).toBe( - 'width: 64px; --drawer-list-width: 4rem; top: 0px; left: 0px;' + 'width: 64px; --drawer-list-width: 4rem; top: 0px; left: 0px;', ) }) rerender( - + , ) expect(styleElement.getAttribute('style')).toBe( - 'width: 320px; --drawer-list-width: 20rem; top: 0px; left: 0px;' + 'width: 320px; --drawer-list-width: 20rem; top: 0px; left: 0px;', ) const element = document.querySelector('.dnb-drawer-list') expect(Array.from(element.classList)).toContain( - 'dnb-drawer-list--independent-width' + 'dnb-drawer-list--independent-width', ) }) @@ -224,13 +224,13 @@ describe('Autocomplete component', () => { let index = 1 const { rerender } = render( - + , ) const assertInputValue = () => { expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe(mockData[index].selected_value) } @@ -238,7 +238,7 @@ describe('Autocomplete component', () => { index = 2 rerender( - + , ) assertInputValue() @@ -250,29 +250,29 @@ describe('Autocomplete component', () => { document .querySelectorAll('.dnb-drawer-list__option')[1] .querySelector( - '.dnb-drawer-list__option__item.dnb-drawer-list__option__suffix' - ).textContent + '.dnb-drawer-list__option__item.dnb-drawer-list__option__suffix', + ).textContent, ).toBe('b suffix') expect( document .querySelectorAll('.dnb-drawer-list__option')[2] .querySelector( - '.dnb-drawer-list__option__item.dnb-drawer-list__option__suffix' - ).textContent + '.dnb-drawer-list__option__item.dnb-drawer-list__option__suffix', + ).textContent, ).toBe(mockData[2].suffix_value) }) it('will not open drawer-list when click on suffix_value and is disabled', () => { render( - + , ) fireEvent.click( - document.querySelector('.dnb-autocomplete__suffix_value') + document.querySelector('.dnb-autocomplete__suffix_value'), ) expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).not.toContain('dnb-autocomplete--opened') expect(document.activeElement.tagName).toBe('BODY') @@ -282,14 +282,14 @@ describe('Autocomplete component', () => { render() expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).not.toContain('dnb-autocomplete--opened') fireEvent.click( - document.querySelector('.dnb-autocomplete__suffix_value') + document.querySelector('.dnb-autocomplete__suffix_value'), ) expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).toContain('dnb-autocomplete--opened') expect(document.activeElement.tagName).toBe('INPUT') @@ -306,11 +306,11 @@ describe('Autocomplete component', () => { show_submit_button stretch value={1} - /> + />, ) expect( - document.querySelector('.dnb-autocomplete__inner') + document.querySelector('.dnb-autocomplete__inner'), ).toHaveAttribute('id') }) }) @@ -322,7 +322,7 @@ describe('Autocomplete component', () => { search_in_word_index="1" show_submit_button {...mockProps} - /> + />, ) toggle() @@ -332,7 +332,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[1]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -340,7 +340,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[1]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -348,7 +348,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe('Ingen alternativer') }) @@ -359,7 +359,7 @@ describe('Autocomplete component', () => { show_submit_button ariaLiveDelay={1} {...mockProps} - /> + />, ) toggle() @@ -375,7 +375,7 @@ describe('Autocomplete component', () => { expect(nodes[nodes.length - 1].textContent).toBe('1 alternativer') expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[1]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -389,7 +389,7 @@ describe('Autocomplete component', () => { const content = (mockData[2] as DrawerListDataObject).content expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe((content as string[]).join('')) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -402,7 +402,7 @@ describe('Autocomplete component', () => { expect(nodes2[nodes2.length - 1].textContent).toBe('3 alternativer') expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe((content as string[]).join('')) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -413,11 +413,11 @@ describe('Autocomplete component', () => { const nodes3 = document.querySelectorAll('.dnb-sr-only') expect(nodes3[nodes3.length - 1].textContent).toBe( - 'Ingen alternativer' + 'Ingen alternativer', ) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe('Ingen alternativer') }) @@ -430,7 +430,7 @@ describe('Autocomplete component', () => { ] render( - + , ) toggle() @@ -439,9 +439,9 @@ describe('Autocomplete component', () => { target: { value: 'bb' }, }) expect( - document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML + document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML, ).toBe( - '
  • item bb
  • ' + '
  • item bb
  • ', ) // First result direction @@ -449,9 +449,9 @@ describe('Autocomplete component', () => { target: { value: 'cc bb' }, }) expect( - document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML + document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML, ).toBe( - '
  • item cc
  • ' + '
  • item cc
  • ', ) // Second result direction @@ -459,9 +459,9 @@ describe('Autocomplete component', () => { target: { value: 'bb cc' }, }) expect( - document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML + document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML, ).toBe( - '
  • item bb
  • ' + '
  • item bb
  • ', ) // With three matches, we prioritize the second one to be on the first place @@ -469,9 +469,9 @@ describe('Autocomplete component', () => { target: { value: 'cc bb more' }, }) expect( - document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML + document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML, ).toBe( - '
  • item cc second
  • ' + '
  • item cc second
  • ', ) // Do not find item, as there is defined a search_content @@ -480,7 +480,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe('Ingen alternativer') }) @@ -490,46 +490,46 @@ describe('Autocomplete component', () => { }) render( - + , ) toggle() expect(document.querySelectorAll('.dnb-sr-only')[0].textContent).toBe( - '' + '', ) // simulate changes keydown(40) // down expect(document.querySelectorAll('.dnb-sr-only')[0].textContent).toBe( - 'AA c' + 'AA c', ) // simulate changes keydown(40) // down expect(document.querySelectorAll('.dnb-sr-only')[0].textContent).toBe( - 'BB cc zethx' + 'BB cc zethx', ) // simulate changes keydown(40) // down expect(document.querySelectorAll('.dnb-sr-only')[0].textContent).toBe( - 'CCcc' + 'CCcc', ) act(() => { document.dispatchEvent( new KeyboardEvent('keydown', { keyCode: 13, // enter - }) + }), ) }) expect(document.querySelectorAll('.dnb-sr-only')[0].textContent).toBe( - 'Valgt: CCcc' + 'Valgt: CCcc', ) // simulate changes @@ -537,7 +537,7 @@ describe('Autocomplete component', () => { keydown(38) // up expect(document.querySelectorAll('.dnb-sr-only')[0].textContent).toBe( - 'BB cc zethx' + 'BB cc zethx', ) // eslint-disable-next-line @@ -549,7 +549,7 @@ describe('Autocomplete component', () => { keydown(38) // up expect(document.querySelectorAll('.dnb-sr-only')[0].textContent).toBe( - '' + '', ) }) @@ -564,7 +564,7 @@ describe('Autocomplete component', () => { ] render( - + , ) toggle() @@ -574,7 +574,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe('Ingen alternativer') fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -582,7 +582,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[0]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -590,7 +590,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[1]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -598,7 +598,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[2]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -606,7 +606,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[3]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -614,7 +614,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[4]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -622,7 +622,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[5]) }) @@ -640,7 +640,7 @@ describe('Autocomplete component', () => { search_numbers show_submit_button {...mockProps} - /> + />, ) toggle() @@ -650,12 +650,12 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[1]) expect( - document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML + document.querySelectorAll('li.dnb-drawer-list__option')[0].outerHTML, ).toBe( - /* html */ `
  • 2223 33 44425
  • ` + /* html */ `
  • 2223 33 44425
  • `, ) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -663,7 +663,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[1]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -671,7 +671,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[2]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -679,7 +679,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[3]) }) @@ -693,7 +693,7 @@ describe('Autocomplete component', () => { search_numbers search_in_word_index={1} {...mockProps} - /> + />, ) toggle() @@ -703,7 +703,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[0]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -711,7 +711,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[0]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -719,7 +719,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[0]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -727,7 +727,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[2]) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -735,8 +735,8 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll( - 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)' - ).length + 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)', + ).length, ).toBe(3) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -744,7 +744,7 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe(mockData[0]) }) @@ -752,7 +752,7 @@ describe('Autocomplete component', () => { let elem render( - + , ) // check "cc" @@ -762,38 +762,38 @@ describe('Autocomplete component', () => { const content = (mockData[2] as DrawerListDataObject).content expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe((content as string[]).join('')) expect( document.querySelectorAll( - 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)' - ).length + 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)', + ).length, ).toBe(2) expect( - document.querySelector('li.dnb-drawer-list__option--focus') + document.querySelector('li.dnb-drawer-list__option--focus'), ).not.toBeInTheDocument() // then simulate changes keydown(40) // down expect( - document.querySelectorAll('li.dnb-drawer-list__option')[0].classList + document.querySelectorAll('li.dnb-drawer-list__option')[0].classList, ).toContain('dnb-drawer-list__option--focus') // then simulate changes keydown(40) // down expect( - document.querySelectorAll('li.dnb-drawer-list__option')[1].classList + document.querySelectorAll('li.dnb-drawer-list__option')[1].classList, ).toContain('dnb-drawer-list__option--focus') expect( document .querySelectorAll('li.dnb-drawer-list__option')[1] - .getAttribute('id') + .getAttribute('id'), ).toBe( document .querySelector('.dnb-input__input') - .getAttribute('aria-activedescendant') + .getAttribute('aria-activedescendant'), ) // check "cc bb" @@ -802,19 +802,19 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll( - 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)' - ).length + 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)', + ).length, ).toBe(2) expect( - document.querySelector('li.dnb-autocomplete__show-all').textContent + document.querySelector('li.dnb-autocomplete__show-all').textContent, ).toBe('Vis alt') expect( - document.querySelectorAll('li.dnb-drawer-list__option').length + document.querySelectorAll('li.dnb-drawer-list__option').length, ).toBe(3) expect( document .querySelectorAll('li.dnb-drawer-list__option')[1] - .getAttribute('aria-selected') + .getAttribute('aria-selected'), ).toBe('true') elem = document.querySelectorAll('li.dnb-drawer-list__option')[1] @@ -838,7 +838,7 @@ describe('Autocomplete component', () => { data={mockData} show_submit_button {...mockProps} - /> + />, ) toggle() @@ -848,8 +848,8 @@ describe('Autocomplete component', () => { }) expect( document.querySelectorAll( - 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)' - ).length + 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)', + ).length, ).toBe(3) }) @@ -862,9 +862,9 @@ describe('Autocomplete component', () => { expect( elem .querySelector( - 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)' + 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)', ) - .getAttribute('aria-expanded') + .getAttribute('aria-expanded'), ).toBe('true') }) @@ -878,8 +878,8 @@ describe('Autocomplete component', () => { expect( elem.querySelectorAll( - 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)' - ).length + 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)', + ).length, ).toBe(3) }) @@ -899,7 +899,7 @@ describe('Autocomplete component', () => { expect( document .querySelector('button.dnb-input__submit-button__button') - .getAttribute('type') + .getAttribute('type'), ).toBe('button') }) @@ -910,8 +910,8 @@ describe('Autocomplete component', () => { expect( document.querySelectorAll( - 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)' - ).length + 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)', + ).length, ).toBe(mockData.length) }) @@ -932,7 +932,7 @@ describe('Autocomplete component', () => { data={mockData} show_submit_button {...mockProps} - /> + />, ) document.querySelector('input').focus() @@ -968,11 +968,11 @@ describe('Autocomplete component', () => { expect(on_hide).toHaveBeenCalledTimes(1) expect(on_hide.mock.calls[0][0].attributes).toMatchObject(params) expect(on_hide.mock.calls[0][0].event).toEqual( - new KeyboardEvent('keydown', {}) + new KeyboardEvent('keydown', {}), ) expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).not.toContain('dnb-autocomplete--opened') // ensure we blur only once @@ -984,13 +984,13 @@ describe('Autocomplete component', () => { expect(on_show.mock.calls[1][0].attributes).toMatchObject(params) expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).toContain('dnb-autocomplete--opened') keydown(27) // esc expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).not.toContain('dnb-autocomplete--opened') toggle() @@ -1005,7 +1005,7 @@ describe('Autocomplete component', () => { expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe(data[value]) const newValue = 1 @@ -1015,7 +1015,7 @@ describe('Autocomplete component', () => { expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe(newData[newValue]) }) @@ -1027,15 +1027,15 @@ describe('Autocomplete component', () => { placeholder="placeholder" value={null} data={mockData} - /> + />, ) expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe('') expect( - document.querySelector('.dnb-input__placeholder').textContent + document.querySelector('.dnb-input__placeholder').textContent, ).toBe('placeholder') value = 1 @@ -1045,12 +1045,12 @@ describe('Autocomplete component', () => { placeholder="placeholder" value={value} data={mockData} - /> + />, ) expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe(mockData[value]) rerender( @@ -1059,12 +1059,12 @@ describe('Autocomplete component', () => { placeholder="placeholder" value={undefined} data={mockData} - /> + />, ) expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe('') value = 0 @@ -1074,12 +1074,12 @@ describe('Autocomplete component', () => { placeholder="placeholder" value={value} data={mockData} - /> + />, ) expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe(mockData[value]) rerender( @@ -1088,12 +1088,12 @@ describe('Autocomplete component', () => { placeholder="placeholder" value={null} data={mockData} - /> + />, ) expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe('') }) @@ -1111,7 +1111,7 @@ describe('Autocomplete component', () => { on_change={on_change} data={mockData} {...mockProps} - /> + />, ) fireEvent.focus(document.querySelector('input')) @@ -1131,7 +1131,7 @@ describe('Autocomplete component', () => { document.dispatchEvent( new KeyboardEvent('keydown', { keyCode: 13, // enter - }) + }), ) fireEvent.blur(document.querySelector('input')) expect(on_blur).toHaveBeenCalledTimes(0) @@ -1139,7 +1139,7 @@ describe('Autocomplete component', () => { // Make a selection fireEvent.click( - document.querySelectorAll('li.dnb-drawer-list__option')[1] + document.querySelectorAll('li.dnb-drawer-list__option')[1], ) expect(on_change).toHaveBeenCalledTimes(1) @@ -1186,7 +1186,7 @@ describe('Autocomplete component', () => { on_change={on_change} on_type={on_type} data={mockData} - /> + />, ) // 1. Make first a selected_item change @@ -1197,7 +1197,7 @@ describe('Autocomplete component', () => { on_type={on_type} data={mockData} value={2} - /> + />, ) // 2. Then update the data @@ -1208,7 +1208,7 @@ describe('Autocomplete component', () => { on_type={on_type} data={newMockData} value={2} - /> + />, ) // 3. And change the value again @@ -1219,13 +1219,13 @@ describe('Autocomplete component', () => { on_type={on_type} data={newMockData} value={1} - /> + />, ) // It should not trigger the resetSelectionItem method expect(on_change).toHaveBeenCalledTimes(0) expect(document.querySelector('input').value).toBe( - newMockData[1].content + newMockData[1].content, ) // Reset data and value @@ -1236,7 +1236,7 @@ describe('Autocomplete component', () => { on_type={on_type} data={mockData} value={null} - /> + />, ) fireEvent.change(document.querySelector('input'), { @@ -1245,7 +1245,7 @@ describe('Autocomplete component', () => { // Make a selection fireEvent.click( - document.querySelectorAll('li.dnb-drawer-list__option')[1] + document.querySelectorAll('li.dnb-drawer-list__option')[1], ) expect(document.querySelector('input').value).toBe(mockData[1].content) @@ -1270,13 +1270,13 @@ describe('Autocomplete component', () => { // Make a selection fireEvent.click( - document.querySelectorAll('li.dnb-drawer-list__option')[1] + document.querySelectorAll('li.dnb-drawer-list__option')[1], ) expect(on_change).toHaveBeenCalledTimes(3) expect(on_change.mock.calls[2][0].data).toEqual(newMockData[1]) expect(document.querySelector('input').value).toBe( - newMockData[1].content + newMockData[1].content, ) }) @@ -1298,7 +1298,7 @@ describe('Autocomplete component', () => { show_submit_button data={mockData} on_change={on_change} - /> + />, ) // open first @@ -1311,7 +1311,7 @@ describe('Autocomplete component', () => { document.dispatchEvent( new KeyboardEvent('keydown', { keyCode: 13, // enter - }) + }), ) }) } @@ -1320,7 +1320,7 @@ describe('Autocomplete component', () => { expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe('A value') expect(on_change.mock.calls[0][0].data.selected_key).toBe('a') @@ -1332,12 +1332,12 @@ describe('Autocomplete component', () => { data={mockData} on_change={on_change} value="b" - /> + />, ) expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe('B value') toggle() @@ -1345,7 +1345,7 @@ describe('Autocomplete component', () => { expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe('C value') expect(on_change.mock.calls[1][0].data.selected_key).toBe('c') @@ -1357,12 +1357,12 @@ describe('Autocomplete component', () => { data={mockData} on_change={on_change} value="id-123" - /> + />, ) expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe('123 value') toggle() @@ -1370,7 +1370,7 @@ describe('Autocomplete component', () => { expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe('456 value') expect(on_change.mock.calls[2][0].data.selected_key).toBe('id-456') rerender( @@ -1381,12 +1381,12 @@ describe('Autocomplete component', () => { data={mockData} on_change={on_change} value={123} - /> + />, ) expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe('') }) @@ -1408,7 +1408,7 @@ describe('Autocomplete component', () => { fireEvent.mouseDown(document.querySelector('.dnb-input__input')) expect( - document.querySelectorAll('li.dnb-drawer-list__option').length + document.querySelectorAll('li.dnb-drawer-list__option').length, ).toBe(3) fireEvent.focus(document.querySelector('.dnb-input__input')) @@ -1420,13 +1420,13 @@ describe('Autocomplete component', () => { keydown(40) // down expect( - document.querySelector('li.dnb-drawer-list__option--focus') + document.querySelector('li.dnb-drawer-list__option--focus'), ).toBeInTheDocument() closeAndReopen() expect( - document.querySelector('li.dnb-drawer-list__option--focus') !== null + document.querySelector('li.dnb-drawer-list__option--focus') !== null, ).toBe(shouldHaveActiveItem) fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -1434,20 +1434,20 @@ describe('Autocomplete component', () => { }) expect( - document.querySelector('li.dnb-drawer-list__option--focus') + document.querySelector('li.dnb-drawer-list__option--focus'), ).not.toBeInTheDocument() keydown(40) // down expect( - document.querySelector('li.dnb-drawer-list__option--focus') + document.querySelector('li.dnb-drawer-list__option--focus'), ).toBeInTheDocument() closeAndReopen() // This here is what we expect expect( - document.querySelector('li.dnb-drawer-list__option--focus') !== null + document.querySelector('li.dnb-drawer-list__option--focus') !== null, ).toBe(shouldHaveActiveItemWhenEmpty) // This also opens the drawer-list @@ -1459,21 +1459,21 @@ describe('Autocomplete component', () => { document.dispatchEvent( new KeyboardEvent('keydown', { keyCode: 13, // enter - }) + }), ) closeAndReopen() // Now we have a selected item expect( - document.querySelector('li.dnb-drawer-list__option--selected') + document.querySelector('li.dnb-drawer-list__option--selected'), ).toBeInTheDocument() expect( - document.querySelector('li.dnb-drawer-list__option--focus') + document.querySelector('li.dnb-drawer-list__option--focus'), ).toBeInTheDocument() expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe('CC cc') fireEvent.change(document.querySelector('.dnb-input__input'), { @@ -1484,10 +1484,10 @@ describe('Autocomplete component', () => { // This here is what we expect expect( - document.querySelector('li.dnb-drawer-list__option--focus') !== null + document.querySelector('li.dnb-drawer-list__option--focus') !== null, ).toBe(shouldHaveActiveItemWhenEmpty) expect( - document.querySelector('li.dnb-drawer-list__option--selected') + document.querySelector('li.dnb-drawer-list__option--selected'), ).not.toBeInTheDocument() cleanup() @@ -1602,7 +1602,7 @@ describe('Autocomplete component', () => { .querySelector('button') expect(buttonElem.textContent).toBe( - 'Bla gjennom alternativer, lukk med esc knappen' + 'Bla gjennom alternativer, lukk med esc knappen', ) expect(buttonElem).toBeInTheDocument() expect(buttonElem.getAttribute('tabindex')).toBe('-1') @@ -1610,19 +1610,19 @@ describe('Autocomplete component', () => { fireEvent.click(buttonElem) expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).toContain('dnb-autocomplete--opened') expect(Array.from(document.activeElement.classList)).toContain( - 'dnb-drawer-list__options' + 'dnb-drawer-list__options', ) fireEvent.click(buttonElem) expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).not.toContain('dnb-autocomplete--opened') expect(Array.from(document.activeElement.classList)).toContain( - 'dnb-input__input' + 'dnb-input__input', ) }) @@ -1635,45 +1635,45 @@ describe('Autocomplete component', () => { }) expect(Array.from(document.activeElement.classList)).toContain( - 'dnb-input__input' + 'dnb-input__input', ) expect( document.querySelectorAll( - 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)' - ).length + 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)', + ).length, ).toBe(mockData.length - 1) document.querySelector('input').focus() expect(Array.from(document.activeElement.classList)).toContain( - 'dnb-input__input' + 'dnb-input__input', ) fireEvent.click( - document.querySelector('li.dnb-autocomplete__show-all') + document.querySelector('li.dnb-autocomplete__show-all'), ) expect( - document.querySelectorAll('li.dnb-drawer-list__option')[1].classList + document.querySelectorAll('li.dnb-drawer-list__option')[1].classList, ).toContain('dnb-drawer-list__option--focus') expect(Array.from(document.activeElement.classList)).toContain( - 'dnb-input__input' + 'dnb-input__input', ) expect( document.querySelectorAll( - 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)' - ).length + 'li.dnb-drawer-list__option:not(.dnb-autocomplete__show-all)', + ).length, ).toBe(mockData.length) fireEvent.blur(document.querySelector('input')) fireEvent.click( - document.querySelectorAll('li.dnb-drawer-list__option')[0] + document.querySelectorAll('li.dnb-drawer-list__option')[0], ) expect(Array.from(document.activeElement.classList)).toContain( - 'dnb-input__input' + 'dnb-input__input', ) }) @@ -1683,20 +1683,20 @@ describe('Autocomplete component', () => { fireEvent.mouseDown(document.querySelector('.dnb-input__input')) expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).toContain('dnb-autocomplete--opened') // close keydown(27) // esc expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).not.toContain('dnb-autocomplete--opened') fireEvent.mouseDown(document.querySelector('.dnb-input__input')) expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).toContain('dnb-autocomplete--opened') }) @@ -1711,19 +1711,19 @@ describe('Autocomplete component', () => { on_change={on_change} data={mockData} {...mockProps} - /> + />, ) fireEvent.focus(document.querySelector('input')) expect(on_focus).toHaveBeenCalledTimes(1) expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).toContain('dnb-autocomplete--opened') // Make a selection fireEvent.click( - document.querySelectorAll('li.dnb-drawer-list__option')[1] + document.querySelectorAll('li.dnb-drawer-list__option')[1], ) expect(on_change).toHaveBeenCalledTimes(1) @@ -1739,14 +1739,14 @@ describe('Autocomplete component', () => { data={mockData} show_submit_button {...mockProps} - /> + />, ) // first open toggle() expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).toContain('dnb-autocomplete--opened') act(() => { @@ -1756,14 +1756,14 @@ describe('Autocomplete component', () => { expect(on_hide).toHaveBeenCalledTimes(1) expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).not.toContain('dnb-autocomplete--opened') // reopen toggle() expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).toContain('dnb-autocomplete--opened') preventClose = true @@ -1776,7 +1776,7 @@ describe('Autocomplete component', () => { // we are still open expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).toContain('dnb-autocomplete--opened') }) @@ -1788,7 +1788,7 @@ describe('Autocomplete component', () => { data={mockData} show_submit_button {...mockProps} - /> + />, ) toggle() @@ -1804,7 +1804,7 @@ describe('Autocomplete component', () => { expect( document .querySelectorAll('li.dnb-drawer-list__option')[0] - .querySelector('.dnb-drawer-list__option__inner').outerHTML + .querySelector('.dnb-drawer-list__option__inner').outerHTML, ).toBe(result) }) @@ -1812,7 +1812,7 @@ describe('Autocomplete component', () => { const replaceData = ['aaa'] const { rerender } = render( - + , ) keydown(40) // down @@ -1822,7 +1822,7 @@ describe('Autocomplete component', () => { }) expect( - document.querySelectorAll('li.dnb-drawer-list__option').length + document.querySelectorAll('li.dnb-drawer-list__option').length, ).toBe(2) // update data @@ -1833,11 +1833,11 @@ describe('Autocomplete component', () => { }) expect( - document.querySelectorAll('li.dnb-drawer-list__option').length + document.querySelectorAll('li.dnb-drawer-list__option').length, ).toBe(1) expect( document.querySelectorAll('li.dnb-drawer-list__option')[0] - .textContent + .textContent, ).toBe('aaa') }) @@ -1852,7 +1852,7 @@ describe('Autocomplete component', () => { on_type={on_type} data={mockData} {...mockProps} - /> + />, ) keydown(40) // down @@ -1863,7 +1863,7 @@ describe('Autocomplete component', () => { const callOne = on_type.mock.calls[0][0] expect( - document.querySelectorAll('li.dnb-drawer-list__option').length + document.querySelectorAll('li.dnb-drawer-list__option').length, ).toBe(3) expect(on_type).toHaveBeenCalledTimes(1) expect(callOne.value).toBe('aa') @@ -1880,7 +1880,7 @@ describe('Autocomplete component', () => { const callTwo = on_type.mock.calls[1][0] expect( - document.querySelectorAll('li.dnb-drawer-list__option').length + document.querySelectorAll('li.dnb-drawer-list__option').length, ).toBe(1) expect(on_type).toHaveBeenCalledTimes(2) expect(callTwo.dataList.length).toBe(1) @@ -1904,13 +1904,13 @@ describe('Autocomplete component', () => { let index = 1 const { rerender } = render( - + , ) const assert = () => { expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe(mockData[index].selected_value) } @@ -1959,12 +1959,12 @@ describe('Autocomplete component', () => { }) fireEvent.click( - document.querySelectorAll('li.dnb-drawer-list__option')[1] + document.querySelectorAll('li.dnb-drawer-list__option')[1], ) expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe('c value') }) @@ -1972,7 +1972,7 @@ describe('Autocomplete component', () => { render() expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe(mockData[props.value]) }) @@ -1985,7 +1985,7 @@ describe('Autocomplete component', () => { expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe(mockData[props.value]) }) @@ -1997,10 +1997,10 @@ describe('Autocomplete component', () => { title={title} show_submit_button {...mockProps} - /> + />, ) expect( - document.querySelector('.dnb-input__placeholder').textContent + document.querySelector('.dnb-input__placeholder').textContent, ).toBe(title) }) @@ -2012,11 +2012,11 @@ describe('Autocomplete component', () => { value={value} show_submit_button {...mockProps} - /> + />, ) expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe(mockData[value]) }) @@ -2036,13 +2036,13 @@ describe('Autocomplete component', () => { expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe(mockData[newValue]) }) it('has a disabled attribute, once we set disabled to true', () => { const { rerender } = render( - + , ) rerender( { show_submit_button {...mockProps} disabled={true} - /> + />, ) expect( document.querySelector( - 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)' - ) + 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)', + ), ).toHaveAttribute('disabled') expect( document .querySelector( - 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)' + 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)', ) .querySelector('.dnb-icon') - .getAttribute('data-testid') + .getAttribute('data-testid'), ).toContain('chevron down') }) @@ -2081,15 +2081,15 @@ describe('Autocomplete component', () => { onChange={onChange} /> )} - /> + />, ) expect(document.querySelector('input')).toBeInTheDocument() expect( - Array.from(document.querySelector('input').classList) + Array.from(document.querySelector('input').classList), ).toContain('dnb-autocomplete__input') expect( - document.querySelector('input').getAttribute('aria-label') + document.querySelector('input').getAttribute('aria-label'), ).toBe('label') const value = 'new value' @@ -2133,13 +2133,13 @@ describe('Autocomplete component', () => { await userEvent.tab() expect(Array.from(document.activeElement.classList)).toContain( - 'first-anchor' + 'first-anchor', ) await userEvent.tab() expect(Array.from(document.activeElement.classList)).toContain( - 'second-anchor' + 'second-anchor', ) }) @@ -2162,7 +2162,7 @@ describe('Autocomplete component', () => { data={mockData} {...mockProps} submit_element={} - /> + />, ) rerender( { {...mockProps} submit_element={} disabled={true} - /> + />, ) expect( document.querySelector( - 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)' - ) + 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)', + ), ).toHaveAttribute('disabled') expect( document .querySelector( - 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)' + 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)', ) - .querySelector('.dnb-icon') + .querySelector('.dnb-icon'), ).toBeInTheDocument() expect( document .querySelector( - 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)' + 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)', ) .querySelector('.dnb-icon') - .getAttribute('data-testid') + .getAttribute('data-testid'), ).toContain('bell') }) @@ -2201,8 +2201,8 @@ describe('Autocomplete component', () => { // open first fireEvent.click( document.querySelector( - 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)' - ) + 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)', + ), ) await testDirectionObserver() @@ -2215,21 +2215,21 @@ describe('Autocomplete component', () => { {...mockProps} status="status text" show_submit_button - /> + />, ) expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).toContain('dnb-autocomplete__status--error') expect(document.querySelector('.dnb-form-status').classList).toContain( - 'dnb-form-status--error' + 'dnb-form-status--error', ) expect(document.querySelector('.dnb-input').classList).toContain( - 'dnb-input__status--error' + 'dnb-input__status--error', ) expect( document.querySelector('button.dnb-input__submit-button__button') - .classList + .classList, ).toContain('dnb-button__status--error') }) @@ -2241,21 +2241,21 @@ describe('Autocomplete component', () => { status="status text" status_state="error" show_submit_button - /> + />, ) expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).toContain('dnb-autocomplete__status--error') expect(document.querySelector('.dnb-form-status').classList).toContain( - 'dnb-form-status--error' + 'dnb-form-status--error', ) expect(document.querySelector('.dnb-input').classList).toContain( - 'dnb-input__status--error' + 'dnb-input__status--error', ) expect( document.querySelector('button.dnb-input__submit-button__button') - .classList + .classList, ).toContain('dnb-button__status--error') }) @@ -2267,21 +2267,21 @@ describe('Autocomplete component', () => { status="status text" status_state="info" show_submit_button - /> + />, ) expect( - document.querySelector('.dnb-autocomplete').classList + document.querySelector('.dnb-autocomplete').classList, ).toContain('dnb-autocomplete__status--info') expect(document.querySelector('.dnb-form-status').classList).toContain( - 'dnb-form-status--info' + 'dnb-form-status--info', ) expect(document.querySelector('.dnb-input').classList).toContain( - 'dnb-input__status--info' + 'dnb-input__status--info', ) expect( document.querySelector('button.dnb-input__submit-button__button') - .classList + .classList, ).toContain('dnb-button__status--info') }) @@ -2297,12 +2297,12 @@ describe('Autocomplete component', () => { render( - + , ) const element = document.querySelector('.dnb-autocomplete') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['class']) @@ -2331,7 +2331,7 @@ describe('Autocomplete markup', () => { skip_portal: true, } const CheckComponent = render( - + , ) expect( @@ -2340,7 +2340,7 @@ describe('Autocomplete markup', () => { 'aria-valid-attr-value': { enabled: false }, 'aria-required-children': { enabled: false }, }, - }) + }), ).toHaveNoViolations() }) }) @@ -2353,7 +2353,7 @@ describe('Autocomplete scss', () => { it('have to match default theme snapshot', () => { const css = loadScss( - require.resolve('../style/themes/dnb-autocomplete-theme-ui.scss') + require.resolve('../style/themes/dnb-autocomplete-theme-ui.scss'), ) expect(css).toMatchSnapshot() }) @@ -2368,7 +2368,7 @@ const keydown = (keyCode) => { const toggle = () => { fireEvent.click( document.querySelector( - 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)' - ) + 'button.dnb-input__submit-button__button:not(.dnb-input__clear-button)', + ), ) } diff --git a/packages/dnb-eufemia/src/components/autocomplete/stories/Autocomplete.stories.tsx b/packages/dnb-eufemia/src/components/autocomplete/stories/Autocomplete.stories.tsx index 33a719e6280..5e1f35dc8f0 100644 --- a/packages/dnb-eufemia/src/components/autocomplete/stories/Autocomplete.stories.tsx +++ b/packages/dnb-eufemia/src/components/autocomplete/stories/Autocomplete.stories.tsx @@ -91,7 +91,7 @@ export function UpdateEachOther() { setSelectedAccountsB( accounts.filter(({ selected_id }) => { return selected_id !== account?.selected_id - }) + }), ) }} /> @@ -105,7 +105,7 @@ export function UpdateEachOther() { setSelectedAccountsA( accounts.filter(({ selected_id }) => { return selected_id !== account?.selected_id - }) + }), ) }} /> @@ -204,7 +204,7 @@ const AutocompleteWithState = () => { return () => clearTimeout(timeout) }, { value, results }, - 1e3 + 1e3, ) }} /> @@ -787,7 +787,7 @@ function UpdateDataExample() { size="small" on_click={() => { const updatedSelectedData = selectedData.filter( - (data) => item.selected_value !== data.selected_value + (data) => item.selected_value !== data.selected_value, ) setSelectedData(updatedSelectedData) setChoiceData( @@ -795,9 +795,9 @@ function UpdateDataExample() { (data) => updatedSelectedData.findIndex( ({ selected_value: updatedValue }) => - updatedValue === data?.selected_value - ) === -1 - ) + updatedValue === data?.selected_value, + ) === -1, + ), ) }} > @@ -819,8 +819,8 @@ function UpdateDataExample() { // update our choices setChoiceData( choiceData.filter( - (item) => item.selected_value !== data.selected_value - ) + (item) => item.selected_value !== data.selected_value, + ), ) // we could have used updateData @@ -830,7 +830,7 @@ function UpdateDataExample() { if ( selectedData.findIndex( ({ selected_value }) => - selected_value === data.selected_value + selected_value === data.selected_value, ) === -1 ) { setSelectedData([...selectedData, data]) diff --git a/packages/dnb-eufemia/src/components/avatar/Avatar.tsx b/packages/dnb-eufemia/src/components/avatar/Avatar.tsx index f48725d1020..5d2d0e74bc0 100644 --- a/packages/dnb-eufemia/src/components/avatar/Avatar.tsx +++ b/packages/dnb-eufemia/src/components/avatar/Avatar.tsx @@ -100,7 +100,7 @@ const Avatar = (localProps: AvatarProps & SpacingProps) => { defaultProps, context?.Avatar, { skeleton: context?.skeleton }, - avatarGroupContext + avatarGroupContext, ) const { @@ -135,7 +135,7 @@ const Avatar = (localProps: AvatarProps & SpacingProps) => { if (!avatarGroupContext && !hasLabel) { warn( - `Avatar group required: An Avatar requires an Avatar.Group with label description as a parent component. This is to ensure correct semantic and accessibility.` + `Avatar group required: An Avatar requires an Avatar.Group with label description as a parent component. This is to ensure correct semantic and accessibility.`, ) } @@ -149,7 +149,7 @@ const Avatar = (localProps: AvatarProps & SpacingProps) => { `dnb-avatar--size-${size || 'medium'}`, skeletonClasses, spacingClasses, - className + className, )} {...props} > diff --git a/packages/dnb-eufemia/src/components/avatar/AvatarGroup.tsx b/packages/dnb-eufemia/src/components/avatar/AvatarGroup.tsx index 5d9268614e5..8855b5973a0 100644 --- a/packages/dnb-eufemia/src/components/avatar/AvatarGroup.tsx +++ b/packages/dnb-eufemia/src/components/avatar/AvatarGroup.tsx @@ -88,7 +88,7 @@ const AvatarGroup = (localProps: AvatarGroupProps & SpacingProps) => { context?.AvatarGroup, { skeleton: context?.skeleton, - } + }, ) const maxElements = @@ -132,7 +132,7 @@ const AvatarGroup = (localProps: AvatarGroupProps & SpacingProps) => { className={classnames( 'dnb-avatar__group', spacingClasses, - className + className, )} {...attributes} > @@ -170,7 +170,7 @@ function ElementsHidden(props: ElementsHiddenProps) { {children} diff --git a/packages/dnb-eufemia/src/components/avatar/__tests__/Avatar.test.tsx b/packages/dnb-eufemia/src/components/avatar/__tests__/Avatar.test.tsx index 0bbeb4a6f14..0d4054febc5 100644 --- a/packages/dnb-eufemia/src/components/avatar/__tests__/Avatar.test.tsx +++ b/packages/dnb-eufemia/src/components/avatar/__tests__/Avatar.test.tsx @@ -13,7 +13,7 @@ describe('Avatar', () => { render( - + , ) expect(document.querySelector('.dnb-avatar')).toBeInTheDocument() @@ -24,7 +24,7 @@ describe('Avatar', () => { render( {children} - + , ) expect(screen.queryAllByText(children)[0]).toBeInTheDocument() @@ -35,7 +35,7 @@ describe('Avatar', () => { render( {children} - + , ) expect(screen.queryByText('E')).toBeInTheDocument() @@ -47,7 +47,7 @@ describe('Avatar', () => { render( {children} - + , ) expect(screen.queryByText(children)).toBeInTheDocument() @@ -59,7 +59,7 @@ describe('Avatar', () => { - + , ) expect(screen.queryByTestId('confetti icon')).toBeInTheDocument() @@ -70,7 +70,7 @@ describe('Avatar', () => { render( - + , ) expect(screen.queryByRole('img').getAttribute('src')).toBe(img_src) @@ -81,7 +81,7 @@ describe('Avatar', () => { render( - + , ) expect(screen.getByAltText(img_alt)).toBeInTheDocument() @@ -103,7 +103,7 @@ describe('Avatar', () => { render( - + , ) const image = screen.queryByRole('img') @@ -134,10 +134,10 @@ describe('Avatar', () => { render( A - + , ) expect( - document.getElementsByClassName(skeletonClassName) + document.getElementsByClassName(skeletonClassName), ).toHaveLength(1) }) @@ -149,11 +149,11 @@ describe('Avatar', () => { A - + , ) expect( - document.getElementsByClassName(skeletonClassName) + document.getElementsByClassName(skeletonClassName), ).toHaveLength(1) }) @@ -167,12 +167,12 @@ describe('Avatar', () => { alt={img_alt} src="/dnb/android-chrome-192x192.png" /> - + , ) const element = document.querySelector('.dnb-avatar') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['class']) @@ -192,7 +192,7 @@ describe('Avatar', () => { A B C - + , ) expect(screen.queryByText(label)).toBeInTheDocument() @@ -205,7 +205,7 @@ describe('Avatar', () => { A B C - + , ) expect(screen.queryByTestId('react-node')).toBeInTheDocument() }) @@ -216,7 +216,7 @@ describe('Avatar', () => { A B C - + , ) const avatarsDisplayed = @@ -233,7 +233,7 @@ describe('Avatar', () => { A B C - + , ) const avatarsDisplayed = @@ -250,14 +250,14 @@ describe('Avatar', () => { A B C - + , ) const avatarsDisplayed = document.getElementsByClassName('dnb-avatar') expect( - document.querySelector('.dnb-avatar__group--elements-left') + document.querySelector('.dnb-avatar__group--elements-left'), ).not.toBeInTheDocument() expect(avatarsDisplayed).toHaveLength(3) @@ -269,14 +269,14 @@ describe('Avatar', () => { A B C - + , ) const avatarsDisplayed = document.getElementsByClassName('dnb-avatar') expect( - document.querySelector('.dnb-avatar__group--elements-left') + document.querySelector('.dnb-avatar__group--elements-left'), ).not.toBeInTheDocument() expect(avatarsDisplayed).toHaveLength(3) }) @@ -287,14 +287,14 @@ describe('Avatar', () => { A B C - + , ) const avatarsDisplayed = document.getElementsByClassName('dnb-avatar') expect( - document.querySelector('.dnb-avatar__group--elements-left') + document.querySelector('.dnb-avatar__group--elements-left'), ).not.toBeInTheDocument() expect(avatarsDisplayed).toHaveLength(3) }) @@ -304,14 +304,14 @@ describe('Avatar', () => { A B - + , ) const avatarsDisplayed = document.getElementsByClassName('dnb-avatar') expect( - document.querySelector('.dnb-avatar__group--elements-left') + document.querySelector('.dnb-avatar__group--elements-left'), ).not.toBeInTheDocument() expect(avatarsDisplayed).toHaveLength(2) }) @@ -324,14 +324,14 @@ describe('Avatar', () => { C D E - + , ) const avatarsDisplayed = document.getElementsByClassName('dnb-avatar') expect( - document.querySelector('.dnb-avatar__group--elements-left') + document.querySelector('.dnb-avatar__group--elements-left'), ).toBeInTheDocument() expect(avatarsDisplayed).toHaveLength(3) }) @@ -353,7 +353,7 @@ describe('Avatar scss', () => { it('have to match default theme snapshot', () => { const css = loadScss( - require.resolve('../style/themes/dnb-avatar-theme-ui.scss') + require.resolve('../style/themes/dnb-avatar-theme-ui.scss'), ) expect(css).toMatchSnapshot() }) diff --git a/packages/dnb-eufemia/src/components/avatar/style/index.d.ts b/packages/dnb-eufemia/src/components/avatar/style/index.d.ts index e400b4a3433..2dfade00e25 100644 --- a/packages/dnb-eufemia/src/components/avatar/style/index.d.ts +++ b/packages/dnb-eufemia/src/components/avatar/style/index.d.ts @@ -3,4 +3,4 @@ * */ -import './dnb-avatar.scss' +import './dnb-avatar.scss'; diff --git a/packages/dnb-eufemia/src/components/avatar/style/themes/dnb-avatar-theme-sbanken.scss b/packages/dnb-eufemia/src/components/avatar/style/themes/dnb-avatar-theme-sbanken.scss index de9b3d2d8f7..a4d43e5531c 100644 --- a/packages/dnb-eufemia/src/components/avatar/style/themes/dnb-avatar-theme-sbanken.scss +++ b/packages/dnb-eufemia/src/components/avatar/style/themes/dnb-avatar-theme-sbanken.scss @@ -37,5 +37,6 @@ &__group { --avatar-font-size-left--medium: var(--font-size-basis); --avatar-font-size-left--large: var(--font-size-medium); - --avatar-font-size-left--x-large: var(--font-size-medium);} + --avatar-font-size-left--x-large: var(--font-size-medium); + } } diff --git a/packages/dnb-eufemia/src/components/badge/Badge.tsx b/packages/dnb-eufemia/src/components/badge/Badge.tsx index 7a961ba4b1f..089c687185a 100644 --- a/packages/dnb-eufemia/src/components/badge/Badge.tsx +++ b/packages/dnb-eufemia/src/components/badge/Badge.tsx @@ -87,7 +87,7 @@ function Badge(localProps: BadgeAndSpacingProps) { localProps, defaultProps, context?.Badge, - { skeleton: context?.skeleton } + { skeleton: context?.skeleton }, ) const { @@ -132,12 +132,12 @@ function Badge(localProps: BadgeAndSpacingProps) { if (variantIsNotification && !contentIsNum) { warn( - `Type of content should be a number: A notification badge is best suited to display content of type number.` + `Type of content should be a number: A notification badge is best suited to display content of type number.`, ) } if (!label && contentIsNum) { warn( - `Label required: A Badge with a number as content requires a label describing the content of the badge. This is to ensure correct semantic and accessibility.` + `Label required: A Badge with a number as content requires a label describing the content of the badge. This is to ensure correct semantic and accessibility.`, ) } @@ -151,7 +151,7 @@ function Badge(localProps: BadgeAndSpacingProps) { vertical && `dnb-badge--vertical-${vertical}`, skeletonClasses, spacingClasses, - className + className, )} {...props} > diff --git a/packages/dnb-eufemia/src/components/badge/__tests__/Badge.test.tsx b/packages/dnb-eufemia/src/components/badge/__tests__/Badge.test.tsx index 151889ee6f1..56ee410b6dc 100644 --- a/packages/dnb-eufemia/src/components/badge/__tests__/Badge.test.tsx +++ b/packages/dnb-eufemia/src/components/badge/__tests__/Badge.test.tsx @@ -63,7 +63,7 @@ describe('Badge', () => { A - + , ) expect(screen.queryByTestId('confetti icon')).toBeInTheDocument() @@ -80,7 +80,7 @@ describe('Badge', () => { process.env.NODE_ENV = 'development' global.console.log = jest.fn() render( - + , ) expect(global.console.log).not.toBeCalled() }) @@ -112,12 +112,12 @@ describe('Badge', () => { top="2rem" aria-label="Info about the badge" content="content" - /> + />, ) const element = document.querySelector('.dnb-badge') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['role', 'class', 'aria-label']) @@ -140,7 +140,7 @@ describe('Badge', () => { render( - + , ) const element = document.querySelector('.dnb-badge') @@ -158,7 +158,7 @@ describe('Badge', () => { render() expect( - document.getElementsByClassName('dnb-badge--variant-information') + document.getElementsByClassName('dnb-badge--variant-information'), ).toHaveLength(1) }) }) @@ -179,7 +179,7 @@ describe('Badge scss', () => { it('have to match default theme snapshot', () => { const css = loadScss( - require.resolve('../style/themes/dnb-badge-theme-ui.scss') + require.resolve('../style/themes/dnb-badge-theme-ui.scss'), ) expect(css).toMatchSnapshot() }) diff --git a/packages/dnb-eufemia/src/components/breadcrumb/Breadcrumb.tsx b/packages/dnb-eufemia/src/components/breadcrumb/Breadcrumb.tsx index b28a87db50e..d0b3d696ded 100644 --- a/packages/dnb-eufemia/src/components/breadcrumb/Breadcrumb.tsx +++ b/packages/dnb-eufemia/src/components/breadcrumb/Breadcrumb.tsx @@ -148,7 +148,7 @@ const Breadcrumb = (localProps: BreadcrumbProps & SpacingProps) => { defaultProps, context?.translation?.Breadcrumb, context?.Breadcrumb, - { skeleton: context?.skeleton } + { skeleton: context?.skeleton }, ) const { @@ -203,7 +203,7 @@ const Breadcrumb = (localProps: BreadcrumbProps & SpacingProps) => { 'dnb-breadcrumb', skeletonClasses, spacingClasses, - className + className, )} {...props} > diff --git a/packages/dnb-eufemia/src/components/breadcrumb/BreadcrumbItem.tsx b/packages/dnb-eufemia/src/components/breadcrumb/BreadcrumbItem.tsx index b109f645d7a..d6aa42ab99f 100644 --- a/packages/dnb-eufemia/src/components/breadcrumb/BreadcrumbItem.tsx +++ b/packages/dnb-eufemia/src/components/breadcrumb/BreadcrumbItem.tsx @@ -88,7 +88,7 @@ const BreadcrumbItem = (localProps: BreadcrumbItemProps) => { } = extendPropsWithContext( localProps, defaultProps, - context?.BreadcrumbItem + context?.BreadcrumbItem, ) const currentIcon: IconIcon = diff --git a/packages/dnb-eufemia/src/components/breadcrumb/BreadcrumbMultiple.tsx b/packages/dnb-eufemia/src/components/breadcrumb/BreadcrumbMultiple.tsx index c4c5f6c43d7..7081372e1ed 100644 --- a/packages/dnb-eufemia/src/components/breadcrumb/BreadcrumbMultiple.tsx +++ b/packages/dnb-eufemia/src/components/breadcrumb/BreadcrumbMultiple.tsx @@ -47,7 +47,7 @@ export const BreadcrumbMultiple = ({ {React.Children.toArray(items) .filter((item) => React.isValidElement(item)) .map((item: React.ReactElement, i) => - React.cloneElement(item, { key: i, itemNr: i }) + React.cloneElement(item, { key: i, itemNr: i }), )} diff --git a/packages/dnb-eufemia/src/components/breadcrumb/__tests__/Breadcrumb.test.tsx b/packages/dnb-eufemia/src/components/breadcrumb/__tests__/Breadcrumb.test.tsx index c98762f8785..feae23f1264 100644 --- a/packages/dnb-eufemia/src/components/breadcrumb/__tests__/Breadcrumb.test.tsx +++ b/packages/dnb-eufemia/src/components/breadcrumb/__tests__/Breadcrumb.test.tsx @@ -29,7 +29,7 @@ describe('Breadcrumb', () => { { href: '/page1', text: 'Page 1' }, { href: '/page1/page2', text: 'Page 2' }, ]} - /> + />, ) expect(screen.queryByText('Home')).toBeInTheDocument() @@ -41,7 +41,7 @@ describe('Breadcrumb', () => { it('renders a breadcrumb with a single item by data prop', () => { render( - + , ) expect(screen.queryByText('Page 2')).toBeInTheDocument() @@ -54,7 +54,7 @@ describe('Breadcrumb', () => { - + , ) expect(screen.queryByText('Home')).toBeInTheDocument() @@ -68,7 +68,7 @@ describe('Breadcrumb', () => { render( - + , ) expect(screen.queryByText('Page item #1')).toBeInTheDocument() @@ -96,7 +96,7 @@ describe('Breadcrumb', () => { {null} {null} - + , ) expect(screen.queryByText('Page item #1')).toBeInTheDocument() @@ -111,7 +111,7 @@ describe('Breadcrumb', () => { render( - + , ) expect(screen.queryAllByRole('link')).toHaveLength(1) @@ -133,17 +133,17 @@ describe('Breadcrumb', () => { variant="collapse" isCollapsed={overrideCollapse} onClick={jest.fn()} - /> + />, ) expect( - document.querySelector('.dnb-breadcrumb__animation') + document.querySelector('.dnb-breadcrumb__animation'), ).not.toBeInTheDocument() fireEvent.click(screen.getByRole('button')) expect( - document.querySelector('.dnb-breadcrumb__animation') + document.querySelector('.dnb-breadcrumb__animation'), ).not.toBeInTheDocument() }) @@ -155,12 +155,12 @@ describe('Breadcrumb', () => { { href: '/page1', text: 'Page 1' }, { href: '/page1/page2', text: 'Last Item' }, ]} - /> + />, ) const lastElem = screen.getByText('Last Item') expect( - lastElem.parentElement.parentElement.getAttribute('aria-current') + lastElem.parentElement.parentElement.getAttribute('aria-current'), ).toBe('page') }) @@ -172,13 +172,13 @@ describe('Breadcrumb', () => { { href: '/page1', text: 'Current Item', variant: 'current' }, { href: '/page1/page2', text: 'Page 2' }, ]} - /> + />, ) const currentItem = screen.getByText('Current Item') expect( - currentItem.parentElement.parentElement.getAttribute('aria-current') + currentItem.parentElement.parentElement.getAttribute('aria-current'), ).toBe('page') }) @@ -192,13 +192,13 @@ describe('Breadcrumb', () => { { href: '/page1', text: 'Page 1' }, { href: '/page1/page2', text: 'Page 2' }, ]} - /> + />, ) fireEvent.click(screen.getByRole('button')) expect( - document.querySelector('.dnb-breadcrumb__animation') + document.querySelector('.dnb-breadcrumb__animation'), ).toBeDefined() }) @@ -208,7 +208,7 @@ describe('Breadcrumb', () => { render( - + , ) expect(screen.getByRole('button').className).toMatch(skeletonClassName) @@ -223,12 +223,12 @@ describe('Breadcrumb', () => { { href: '/page1/page2', text: 'Page 2' }, ]} top="2rem" - /> + />, ) const element = document.querySelector('.dnb-breadcrumb') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['aria-label', 'class']) @@ -288,11 +288,11 @@ describe('Breadcrumb', () => { const skeletonClassName = 'dnb-skeleton' render( - + , ) expect(screen.getByRole('button').className).toMatch( - skeletonClassName + skeletonClassName, ) }) @@ -302,11 +302,11 @@ describe('Breadcrumb', () => { render( - + , ) expect(screen.getByRole('button').className).toMatch( - skeletonClassName + skeletonClassName, ) }) @@ -320,7 +320,7 @@ describe('Breadcrumb', () => { ]} variant="collapse" isCollapsed={false} - /> + />, ) const items = document.querySelectorAll('.dnb-breadcrumb__item') @@ -343,7 +343,7 @@ describe('Breadcrumb aria', () => { ]} variant="collapse" isCollapsed={false} - /> + />, ) expect(await axeComponent(Component)).toHaveNoViolations() }) diff --git a/packages/dnb-eufemia/src/components/button/Button.js b/packages/dnb-eufemia/src/components/button/Button.js index ec4cfadf50d..33539c05b35 100644 --- a/packages/dnb-eufemia/src/components/button/Button.js +++ b/packages/dnb-eufemia/src/components/button/Button.js @@ -93,7 +93,7 @@ export default class Button extends React.PureComponent { Button.defaultProps, { skeleton: this.context?.skeleton }, includeValidProps(this.context.FormRow), - this.context.Button + this.context.Button, ) const { @@ -141,7 +141,7 @@ export default class Button extends React.PureComponent { ) { warn( `Icon required: A Tertiary Button requires an icon to be WCAG compliant in most cases, because variant tertiary has no underline. -(Override this warning using icon={false}, or consider using one of the other variants)` +(Override this warning using icon={false}, or consider using one of the other variants)`, ) } @@ -200,12 +200,12 @@ export default class Button extends React.PureComponent { createSkeletonClass( variant === 'tertiary' ? 'font' : 'shape', skeleton, - this.context + this.context, ), createSpacingClasses(props), class_name, className, - props.href || props.to ? '' : null // dnb-anchor--no-underline dnb-anchor--no-hover + props.href || props.to ? '' : null, // dnb-anchor--no-underline dnb-anchor--no-hover ) const params = { @@ -439,7 +439,7 @@ function Content({ key: 'button-icon-clone', className: classnames( icon.props?.className, - 'dnb-button__icon' + 'dnb-button__icon', ), }) ) : ( diff --git a/packages/dnb-eufemia/src/components/button/__tests__/Button.screenshot.test.ts b/packages/dnb-eufemia/src/components/button/__tests__/Button.screenshot.test.ts index 5662106185a..11313d4d2fa 100644 --- a/packages/dnb-eufemia/src/components/button/__tests__/Button.screenshot.test.ts +++ b/packages/dnb-eufemia/src/components/button/__tests__/Button.screenshot.test.ts @@ -279,7 +279,7 @@ describe.each(['ui', 'sbanken', 'eiendom'])( expect(screenshot).toMatchImageSnapshot() }) }) - } + }, ) describe.each(['sbanken'])('Button for %s', (themeName) => { diff --git a/packages/dnb-eufemia/src/components/button/__tests__/Button.test.tsx b/packages/dnb-eufemia/src/components/button/__tests__/Button.test.tsx index 2447bd4e470..3404b1e2cc2 100644 --- a/packages/dnb-eufemia/src/components/button/__tests__/Button.test.tsx +++ b/packages/dnb-eufemia/src/components/button/__tests__/Button.test.tsx @@ -66,7 +66,7 @@ describe('Button component', () => { it('has to have a bounding tag if property is set', () => { render(
    diff --git a/packages/dnb-eufemia/src/components/dialog/__tests__/Dialog.test.tsx b/packages/dnb-eufemia/src/components/dialog/__tests__/Dialog.test.tsx index 72d0bc306bd..e886ee350cd 100644 --- a/packages/dnb-eufemia/src/components/dialog/__tests__/Dialog.test.tsx +++ b/packages/dnb-eufemia/src/components/dialog/__tests__/Dialog.test.tsx @@ -29,7 +29,7 @@ describe('Dialog', () => { render( - + , ) expect(document.body.getAttribute('style')).toBe(null) @@ -37,7 +37,7 @@ describe('Dialog', () => { fireEvent.click(document.querySelector('button.dnb-modal__trigger')) expect(document.body.getAttribute('style')).toContain( - 'overflow: hidden;' + 'overflow: hidden;', ) }) @@ -45,13 +45,13 @@ describe('Dialog', () => { render( - + , ) fireEvent.click(document.querySelector('button.dnb-modal__trigger')) expect( - document.querySelector('button.dnb-modal__close-button') + document.querySelector('button.dnb-modal__close-button'), ).toBeInTheDocument() }) @@ -59,7 +59,7 @@ describe('Dialog', () => { render() expect( - document.querySelector('button.dnb-modal__trigger') + document.querySelector('button.dnb-modal__trigger'), ).not.toBeInTheDocument() }) @@ -76,7 +76,7 @@ describe('Dialog', () => { {({ close }) => ( + , ) fireEvent.click(document.querySelector('button')) expect(on_open).toHaveBeenCalledTimes(1) @@ -117,13 +117,13 @@ describe('Dialog', () => { }} > - + , ) fireEvent.click(document.querySelector('button')) expect(document.querySelector('.dnb-dialog__title').textContent).toBe( - contextTitle + contextTitle, ) }) @@ -131,7 +131,7 @@ describe('Dialog', () => { const { rerender } = render( - + , ) const elem = document.querySelector('.dnb-modal__content') expect(elem.getAttribute('role')).toBe('dialog') @@ -145,7 +145,7 @@ describe('Dialog', () => { rerender( - + , ) expect(elem.getAttribute('role')).toBe('region') @@ -164,7 +164,7 @@ describe('Dialog', () => { variant="confirmation" > - + , ) expect(elem.getAttribute('role')).toBe('alertdialog') @@ -196,7 +196,7 @@ describe('Dialog', () => { it('is closed by keyboardevent esc', () => { let testTriggeredBy = null const on_close = jest.fn( - ({ triggeredBy }) => (testTriggeredBy = triggeredBy) + ({ triggeredBy }) => (testTriggeredBy = triggeredBy), ) const props: DialogProps & DialogContentProps = { @@ -277,24 +277,24 @@ describe('Dialog', () => { getComponent({ directDomReturn: false, noAnimation: true, - }) + }), ) expect( - document.querySelector('#content-third') + document.querySelector('#content-third'), ).not.toBeInTheDocument() fireEvent.click(document.querySelector('button#modal-first')) expect( - document.documentElement.getAttribute('data-dnb-modal-active') + document.documentElement.getAttribute('data-dnb-modal-active'), ).toBe('modal-first') fireEvent.click(document.querySelector('button#modal-second')) expect( - document.documentElement.getAttribute('data-dnb-modal-active') + document.documentElement.getAttribute('data-dnb-modal-active'), ).toBe('modal-second') fireEvent.click(document.querySelector('button#modal-third')) expect( - document.documentElement.getAttribute('data-dnb-modal-active') + document.documentElement.getAttribute('data-dnb-modal-active'), ).toBe('modal-third') expect(on_open.first).toHaveBeenCalledTimes(1) @@ -302,25 +302,25 @@ describe('Dialog', () => { expect(on_open.third).toHaveBeenCalledTimes(1) expect( - document.querySelectorAll('button.dnb-modal__close-button').length + document.querySelectorAll('button.dnb-modal__close-button').length, ).toBe(3) expect(document.querySelector('#content-first')).toHaveAttribute( - 'aria-hidden' + 'aria-hidden', ) expect(document.querySelector('#content-second')).toHaveAttribute( - 'aria-hidden' + 'aria-hidden', ) expect(document.querySelector('#content-third')).not.toHaveAttribute( - 'aria-hidden' + 'aria-hidden', ) expect( - document.querySelector('button.dnb-modal__close-button') + document.querySelector('button.dnb-modal__close-button'), ).toHaveAttribute('aria-hidden') expect( - document.querySelectorAll('button.dnb-modal__close-button')[1] + document.querySelectorAll('button.dnb-modal__close-button')[1], ).toHaveAttribute('aria-hidden') expect( - document.querySelectorAll('button.dnb-modal__close-button')[2] + document.querySelectorAll('button.dnb-modal__close-button')[2], ).not.toHaveAttribute('aria-hidden') // Close the third one @@ -332,19 +332,19 @@ describe('Dialog', () => { }) expect( - document.documentElement.getAttribute('data-dnb-modal-active') + document.documentElement.getAttribute('data-dnb-modal-active'), ).toBe('modal-second') expect( - document.querySelector('#content-third') + document.querySelector('#content-third'), ).not.toBeInTheDocument() expect(document.querySelector('#content-second')).not.toHaveAttribute( - 'aria-hidden' + 'aria-hidden', ) expect( - document.querySelector('button.dnb-modal__close-button') + document.querySelector('button.dnb-modal__close-button'), ).toHaveAttribute('aria-hidden') expect( - document.querySelectorAll('button.dnb-modal__close-button')[1] + document.querySelectorAll('button.dnb-modal__close-button')[1], ).not.toHaveAttribute('aria-hidden') // Close the second one @@ -356,16 +356,16 @@ describe('Dialog', () => { }) expect( - document.documentElement.getAttribute('data-dnb-modal-active') + document.documentElement.getAttribute('data-dnb-modal-active'), ).toBe('modal-first') expect( - document.querySelector('#content-second') + document.querySelector('#content-second'), ).not.toBeInTheDocument() expect(document.querySelector('#content-first')).not.toHaveAttribute( - 'aria-hidden' + 'aria-hidden', ) expect( - document.querySelector('button.dnb-modal__close-button') + document.querySelector('button.dnb-modal__close-button'), ).not.toHaveAttribute('aria-hidden') // Close the first one @@ -376,10 +376,10 @@ describe('Dialog', () => { expect(on_close.third).toHaveBeenCalledTimes(1) expect( - document.querySelector('#content-first') + document.querySelector('#content-first'), ).not.toBeInTheDocument() expect(document.documentElement).not.toHaveAttribute( - 'data-dnb-modal-active' + 'data-dnb-modal-active', ) }) }) @@ -398,7 +398,7 @@ describe('Dialog', () => { {({ close }) => ( - + , ) const element = document.querySelector('.dnb-dialog__actions') diff --git a/packages/dnb-eufemia/src/components/dialog/parts/DialogAction.tsx b/packages/dnb-eufemia/src/components/dialog/parts/DialogAction.tsx index 3e0ccc4b79b..e64fa36bfac 100644 --- a/packages/dnb-eufemia/src/components/dialog/parts/DialogAction.tsx +++ b/packages/dnb-eufemia/src/components/dialog/parts/DialogAction.tsx @@ -85,7 +85,7 @@ const DialogAction = ({ }) }, }, - child.props.children + child.props.children, ) } else { return child diff --git a/packages/dnb-eufemia/src/components/drawer/DrawerContent.tsx b/packages/dnb-eufemia/src/components/drawer/DrawerContent.tsx index d647f0ef02b..ed904825d05 100644 --- a/packages/dnb-eufemia/src/components/drawer/DrawerContent.tsx +++ b/packages/dnb-eufemia/src/components/drawer/DrawerContent.tsx @@ -44,7 +44,7 @@ export default function DrawerContent({ getContent( typeof rest.children === 'function' ? Object.freeze({ ...rest, close: context?.close }) - : rest + : rest, ) const innerParams = { @@ -62,7 +62,7 @@ export default function DrawerContent({ isTrue(noAnimationOnMobile) && `dnb-drawer--no-animation-on-mobile`, `dnb-drawer--${containerPlacement || 'right'}`, - className + className, ), style: (minWidth || maxWidth) && { minWidth, maxWidth }, onClick: context?.preventClick, @@ -79,7 +79,7 @@ export default function DrawerContent({ const height = getOffsetTop(context?.contentRef.current) / 16 context?.contentRef.current.style.setProperty( '--header-height', - `${height}rem` + `${height}rem`, ) } catch (e) { warn(e) @@ -89,12 +89,12 @@ export default function DrawerContent({ const navigationElement = findElementInChildren( content, (cur: React.ReactElement) => - cur.type === DrawerNavigation || cur.type === ModalHeaderBar + cur.type === DrawerNavigation || cur.type === ModalHeaderBar, ) const headerElement = findElementInChildren( content, (cur: React.ReactElement) => - cur.type === DrawerHeader || cur.type === ModalHeader + cur.type === DrawerHeader || cur.type === ModalHeader, ) return ( diff --git a/packages/dnb-eufemia/src/components/drawer/__tests__/Drawer.test.tsx b/packages/dnb-eufemia/src/components/drawer/__tests__/Drawer.test.tsx index 4ad7323f361..bfa51d5970b 100644 --- a/packages/dnb-eufemia/src/components/drawer/__tests__/Drawer.test.tsx +++ b/packages/dnb-eufemia/src/components/drawer/__tests__/Drawer.test.tsx @@ -28,7 +28,7 @@ describe('Drawer', () => { render( - + , ) expect(document.body.getAttribute('style')).toBe(null) @@ -36,7 +36,7 @@ describe('Drawer', () => { fireEvent.click(document.querySelector('button.dnb-modal__trigger')) expect(document.body.getAttribute('style')).toContain( - 'overflow: hidden;' + 'overflow: hidden;', ) }) @@ -44,13 +44,13 @@ describe('Drawer', () => { render( - + , ) fireEvent.click(document.querySelector('button.dnb-modal__trigger')) expect( - document.querySelector('button.dnb-modal__close-button') + document.querySelector('button.dnb-modal__close-button'), ).toBeInTheDocument() }) @@ -58,7 +58,7 @@ describe('Drawer', () => { render() expect( - document.querySelector('button.dnb-modal__trigger') + document.querySelector('button.dnb-modal__trigger'), ).not.toBeInTheDocument() }) @@ -75,7 +75,7 @@ describe('Drawer', () => { {({ close }) => ( - + , ) expect( - document.querySelector('#content-third') + document.querySelector('#content-third'), ).not.toBeInTheDocument() fireEvent.click(document.querySelector('button#modal-first')) expect( - document.documentElement.getAttribute('data-dnb-modal-active') + document.documentElement.getAttribute('data-dnb-modal-active'), ).toBe('modal-first') fireEvent.click(document.querySelector('button#modal-second')) expect( - document.documentElement.getAttribute('data-dnb-modal-active') + document.documentElement.getAttribute('data-dnb-modal-active'), ).toBe('modal-second') fireEvent.click(document.querySelector('button#modal-third')) expect( - document.documentElement.getAttribute('data-dnb-modal-active') + document.documentElement.getAttribute('data-dnb-modal-active'), ).toBe('modal-third') expect(on_open.first).toHaveBeenCalledTimes(1) @@ -212,29 +212,29 @@ describe('Drawer', () => { expect(on_open.third).toHaveBeenCalledTimes(1) expect( - document.querySelectorAll('button.dnb-modal__close-button').length + document.querySelectorAll('button.dnb-modal__close-button').length, ).toBe(3) expect(document.querySelector('#content-first')).toHaveAttribute( - 'aria-hidden' + 'aria-hidden', ) expect(document.querySelector('#content-second')).toHaveAttribute( - 'aria-hidden' + 'aria-hidden', ) expect(document.querySelector('#content-third')).not.toHaveAttribute( - 'aria-hidden' + 'aria-hidden', ) expect( - document.querySelectorAll('button.dnb-modal__close-button')[0] + document.querySelectorAll('button.dnb-modal__close-button')[0], ).toHaveAttribute('aria-hidden') expect( - document.querySelectorAll('button.dnb-modal__close-button')[0] + document.querySelectorAll('button.dnb-modal__close-button')[0], ).toHaveAttribute('aria-hidden') expect( - document.querySelectorAll('button.dnb-modal__close-button')[1] + document.querySelectorAll('button.dnb-modal__close-button')[1], ).toHaveAttribute('aria-hidden') expect( - document.querySelectorAll('button.dnb-modal__close-button')[2] + document.querySelectorAll('button.dnb-modal__close-button')[2], ).not.toHaveAttribute('aria-hidden') // Close the third one @@ -246,19 +246,19 @@ describe('Drawer', () => { }) expect( - document.documentElement.getAttribute('data-dnb-modal-active') + document.documentElement.getAttribute('data-dnb-modal-active'), ).toBe('modal-second') expect( - document.querySelector('#content-third') + document.querySelector('#content-third'), ).not.toBeInTheDocument() expect(document.querySelector('#content-second')).not.toHaveAttribute( - 'aria-hidden' + 'aria-hidden', ) expect( - document.querySelectorAll('button.dnb-modal__close-button')[0] + document.querySelectorAll('button.dnb-modal__close-button')[0], ).toHaveAttribute('aria-hidden') expect( - document.querySelectorAll('button.dnb-modal__close-button')[1] + document.querySelectorAll('button.dnb-modal__close-button')[1], ).not.toHaveAttribute('aria-hidden') // Close the second one @@ -270,16 +270,16 @@ describe('Drawer', () => { }) expect( - document.documentElement.getAttribute('data-dnb-modal-active') + document.documentElement.getAttribute('data-dnb-modal-active'), ).toBe('modal-first') expect( - document.querySelector('#content-second') + document.querySelector('#content-second'), ).not.toBeInTheDocument() expect(document.querySelector('#content-first')).not.toHaveAttribute( - 'aria-hidden' + 'aria-hidden', ) expect( - document.querySelectorAll('button.dnb-modal__close-button')[0] + document.querySelectorAll('button.dnb-modal__close-button')[0], ).not.toHaveAttribute('aria-hidden') // Close the first one @@ -291,10 +291,10 @@ describe('Drawer', () => { }) expect( - document.querySelector('#content-first') + document.querySelector('#content-first'), ).not.toBeInTheDocument() expect(document.documentElement).not.toHaveAttribute( - 'data-dnb-modal-active' + 'data-dnb-modal-active', ) }) @@ -335,7 +335,7 @@ describe('Drawer', () => { {({ close }) => (
    - + , ) } diff --git a/packages/dnb-eufemia/src/components/dropdown/Dropdown.js b/packages/dnb-eufemia/src/components/dropdown/Dropdown.js index 2c1fd04ce51..048e1758b6b 100644 --- a/packages/dnb-eufemia/src/components/dropdown/Dropdown.js +++ b/packages/dnb-eufemia/src/components/dropdown/Dropdown.js @@ -129,7 +129,7 @@ export default class Dropdown extends React.PureComponent { PropTypes.arrayOf(PropTypes.string), ]), }), - ]) + ]), ), ]), default_value: PropTypes.oneOfType([ @@ -389,7 +389,7 @@ class DropdownInstance extends React.PureComponent { if (data && data.length > 0) { const currentOptionData = getCurrentData( this.context.drawerList.selected_item, - data + data, ) if (currentOptionData) { title = @@ -408,7 +408,7 @@ class DropdownInstance extends React.PureComponent { { skeleton: this.context?.skeleton }, this.context.getTranslation(this.props).Dropdown, includeValidProps(this.context.FormRow), - this.context.Dropdown + this.context.Dropdown, ) const { @@ -485,7 +485,7 @@ class DropdownInstance extends React.PureComponent { // make it possible to grab the rest attributes and return it with all events Object.assign( this.context.drawerList.attributes, - validateDOMAttributes(null, attributes) + validateDOMAttributes(null, attributes), ) const mainParams = { @@ -507,14 +507,14 @@ class DropdownInstance extends React.PureComponent { 'dnb-form-component', createSpacingClasses(props), _className, - className + className, ), } const triggerParams = { className: classnames( 'dnb-dropdown__trigger', - opened && 'dnb-button--active' + opened && 'dnb-button--active', ), id, disabled, @@ -536,7 +536,7 @@ class DropdownInstance extends React.PureComponent { triggerParams['aria-describedby'] = combineDescribedBy( triggerParams, showStatus ? id + '-status' : null, - suffix ? id + '-suffix' : null + suffix ? id + '-suffix' : null, ) } @@ -544,7 +544,7 @@ class DropdownInstance extends React.PureComponent { triggerParams['aria-labelledby'] = combineLabelledBy( triggerParams, id + '-label', - id // used to read the current value + id, // used to read the current value ) } @@ -610,7 +610,7 @@ class DropdownInstance extends React.PureComponent { className={classnames( 'dnb-dropdown__icon', parseFloat(selected_item) === 0 && - 'dnb-dropdown__icon--first' + 'dnb-dropdown__icon--first', )} > {icon !== false && ( diff --git a/packages/dnb-eufemia/src/components/dropdown/__tests__/Dropdown.test.tsx b/packages/dnb-eufemia/src/components/dropdown/__tests__/Dropdown.test.tsx index 2d3dbbc0801..ee5bb2792ae 100644 --- a/packages/dnb-eufemia/src/components/dropdown/__tests__/Dropdown.test.tsx +++ b/packages/dnb-eufemia/src/components/dropdown/__tests__/Dropdown.test.tsx @@ -66,7 +66,7 @@ describe('Dropdown component', () => { let elem expect( - document.querySelector('.dnb-dropdown__text__inner').textContent + document.querySelector('.dnb-dropdown__text__inner').textContent, ).toBe((mockData[props.value] as DrawerListDataObject).selected_value) keydown(32) // space @@ -89,10 +89,10 @@ describe('Dropdown component', () => { expect(elem.classList).toContain('dnb-drawer-list__option--selected') expect( - document.querySelector('.dnb-dropdown__text__inner').textContent + document.querySelector('.dnb-dropdown__text__inner').textContent, ).toBe( (mockData[(props.value as number) + 1] as DrawerListDataObject) - .selected_value + .selected_value, ) }) @@ -102,7 +102,7 @@ describe('Dropdown component', () => { keydown(32) // space expect( - document.querySelector('.dnb-drawer-list__option--focus') + document.querySelector('.dnb-drawer-list__option--focus'), ).toBeInTheDocument() keydown(83) // S @@ -111,7 +111,7 @@ describe('Dropdown component', () => { rerender() expect( - document.querySelectorAll('.dnb-drawer-list__option')[1].classList + document.querySelectorAll('.dnb-drawer-list__option')[1].classList, ).toContain('dnb-drawer-list__option--focus') keydown(70) // F @@ -120,22 +120,22 @@ describe('Dropdown component', () => { rerender() expect( - document.querySelectorAll('.dnb-drawer-list__option')[2].classList + document.querySelectorAll('.dnb-drawer-list__option')[2].classList, ).toContain('dnb-drawer-list__option--focus') }) it('has correct state when opened prop is given', () => { render( - + , ) expect( - document.querySelector('button').getAttribute('aria-expanded') + document.querySelector('button').getAttribute('aria-expanded'), ).toBe('true') expect( document .querySelector('.dnb-drawer-list__options') - .getAttribute('aria-expanded') + .getAttribute('aria-expanded'), ).toBe('true') }) @@ -146,12 +146,12 @@ describe('Dropdown component', () => { no_animation trigger_element={(props) => } data={mockData} - /> + />, ) expect(document.querySelector('button')).toBeInTheDocument() expect( - Array.from(document.querySelector('button').classList) + Array.from(document.querySelector('button').classList), ).toContain('dnb-dropdown__trigger') expect(document.querySelector('button').textContent).toBe('test') @@ -162,7 +162,7 @@ describe('Dropdown component', () => { document .querySelector('.dnb-drawer-list__options') - .getAttribute('aria-expanded') + .getAttribute('aria-expanded'), ).toBe('true') }) @@ -175,11 +175,11 @@ describe('Dropdown component', () => { status="status text" status_state="warn" status_props={{ stretch: true }} - /> + />, ) expect( - Array.from(document.querySelector('.dnb-form-status').classList) + Array.from(document.querySelector('.dnb-form-status').classList), ).toEqual([ 'dnb-form-status', 'dnb-form-status--warn', @@ -199,11 +199,11 @@ describe('Dropdown component', () => { keep_open={true} on_change={on_change} data={mockData} - /> + />, ) expect( - document.querySelector('.dnb-drawer-list__option--selected') + document.querySelector('.dnb-drawer-list__option--selected'), ).not.toBeInTheDocument() // then simulate changes @@ -213,17 +213,17 @@ describe('Dropdown component', () => { expect(on_change).toHaveBeenCalledTimes(1) expect( - document.querySelector('.dnb-drawer-list__option--selected') + document.querySelector('.dnb-drawer-list__option--selected'), ).toBeInTheDocument() expect(document.querySelector('.dnb-dropdown').classList).toContain( - 'dnb-dropdown--opened' + 'dnb-dropdown--opened', ) // close keydown(27) // esc expect( - document.querySelector('.dnb-dropdown').classList + document.querySelector('.dnb-dropdown').classList, ).not.toContain('dnb-dropdown--opened') }) @@ -238,11 +238,11 @@ describe('Dropdown component', () => { on_change={on_change} on_hide={on_hide} data={mockData} - /> + />, ) expect( - document.querySelector('.dnb-drawer-list__option--selected') + document.querySelector('.dnb-drawer-list__option--selected'), ).not.toBeInTheDocument() // then simulate changes @@ -252,17 +252,17 @@ describe('Dropdown component', () => { expect(on_change).toHaveBeenCalledTimes(1) expect( - document.querySelector('.dnb-drawer-list__option--selected') + document.querySelector('.dnb-drawer-list__option--selected'), ).toBeInTheDocument() expect(document.querySelector('.dnb-dropdown').classList).toContain( - 'dnb-dropdown--opened' + 'dnb-dropdown--opened', ) // try to close it keydown(27) // esc expect(document.querySelector('.dnb-dropdown').classList).toContain( - 'dnb-dropdown--opened' + 'dnb-dropdown--opened', ) expect(on_hide).toHaveBeenCalledTimes(0) @@ -279,7 +279,7 @@ describe('Dropdown component', () => { expect( document.querySelectorAll('.dnb-drawer-list__option--selected') - .length + .length, ).toBe(1) const notChangedItem = mockData[(props.value as number) + 1] @@ -303,14 +303,14 @@ describe('Dropdown component', () => { title={title} on_change={on_change} prevent_selection - /> + />, ) // open first open() expect( - document.querySelector('.dnb-drawer-list__option--selected') + document.querySelector('.dnb-drawer-list__option--selected'), ).not.toBeInTheDocument() // then simulate changes @@ -322,7 +322,7 @@ describe('Dropdown component', () => { open() expect( - document.querySelector('.dnb-drawer-list__option--selected') + document.querySelector('.dnb-drawer-list__option--selected'), ).not.toBeInTheDocument() rerender( @@ -333,7 +333,7 @@ describe('Dropdown component', () => { title={title} on_change={on_change} prevent_selection={false} - /> + />, ) // open again @@ -346,7 +346,7 @@ describe('Dropdown component', () => { open() expect( - document.querySelector('.dnb-drawer-list__option--selected') + document.querySelector('.dnb-drawer-list__option--selected'), ).toBeInTheDocument() rerender( @@ -358,7 +358,7 @@ describe('Dropdown component', () => { on_change={on_change} prevent_selection={false} action_menu={true} - /> + />, ) // open again @@ -371,7 +371,7 @@ describe('Dropdown component', () => { open() expect( - document.querySelector('.dnb-drawer-list__option--selected') + document.querySelector('.dnb-drawer-list__option--selected'), ).not.toBeInTheDocument() rerender( @@ -383,14 +383,14 @@ describe('Dropdown component', () => { on_change={on_change} prevent_selection={true} action_menu={false} - /> + />, ) expect( document .querySelector('.dnb-icon') - .getAttribute('data-testid') + .getAttribute('data-testid'), ).toBe('chevron down icon') const event = on_change.mock.calls[0][0] @@ -401,10 +401,10 @@ describe('Dropdown component', () => { expect(event.data).toStrictEqual(selectedItem) expect(document.querySelector('.dnb-dropdown__text').textContent).toBe( - title + title, ) expect( - document.querySelector('.dnb-dropdown--is-popup') + document.querySelector('.dnb-dropdown--is-popup'), ).not.toBeInTheDocument() rerender( @@ -416,51 +416,51 @@ describe('Dropdown component', () => { on_change={on_change} prevent_selection={true} action_menu={false} - /> + />, ) expect( - document.querySelector('.dnb-dropdown__text') + document.querySelector('.dnb-dropdown__text'), ).not.toBeInTheDocument() expect( - document.querySelector('.dnb-dropdown--is-popup') + document.querySelector('.dnb-dropdown--is-popup'), ).toBeInTheDocument() }) it('can be reset to null', () => { let value const { rerender } = render( - + , ) expect(document.querySelector('.dnb-dropdown__text').textContent).toBe( - 'Valgmeny' + 'Valgmeny', ) value = 2 rerender() expect(document.querySelector('.dnb-dropdown__text').textContent).toBe( - (mockData[value] as DrawerListDataObject).selected_value + (mockData[value] as DrawerListDataObject).selected_value, ) rerender() expect(document.querySelector('.dnb-dropdown__text').textContent).toBe( - 'Valgmeny' + 'Valgmeny', ) value = 3 rerender() expect(document.querySelector('.dnb-dropdown__text').textContent).toBe( - (mockData[value] as DrawerListDataObject).selected_value + (mockData[value] as DrawerListDataObject).selected_value, ) rerender() expect(document.querySelector('.dnb-dropdown__text').textContent).toBe( - 'Valgmeny' + 'Valgmeny', ) }) @@ -476,7 +476,7 @@ describe('Dropdown component', () => { const on_change = jest.fn() const { rerender } = render( - + , ) // open first @@ -493,7 +493,7 @@ describe('Dropdown component', () => { openAndSelectNext() expect(document.querySelector('.dnb-dropdown__text').textContent).toBe( - 'A value' + 'A value', ) expect(on_change.mock.calls[0][0].data.selected_key).toBe('a') @@ -503,17 +503,17 @@ describe('Dropdown component', () => { data={mockData} on_change={on_change} value="b" - /> + />, ) expect(document.querySelector('.dnb-dropdown__text').textContent).toBe( - 'B value' + 'B value', ) openAndSelectNext() expect(document.querySelector('.dnb-dropdown__text').textContent).toBe( - 'C value' + 'C value', ) expect(on_change.mock.calls[1][0].data.selected_key).toBe('c') @@ -523,17 +523,17 @@ describe('Dropdown component', () => { data={mockData} on_change={on_change} value="id-123" - /> + />, ) expect(document.querySelector('.dnb-dropdown__text').textContent).toBe( - '123 value' + '123 value', ) openAndSelectNext() expect(document.querySelector('.dnb-dropdown__text').textContent).toBe( - '456 value' + '456 value', ) expect(on_change.mock.calls[2][0].data.selected_key).toBe('id-456') @@ -543,11 +543,11 @@ describe('Dropdown component', () => { data={mockData} on_change={on_change} value={123} - /> + />, ) expect(document.querySelector('.dnb-dropdown__text').textContent).toBe( - 'Valgmeny' + 'Valgmeny', ) }) @@ -560,7 +560,7 @@ describe('Dropdown component', () => { data={mockData} title={title} more_menu - /> + />, ) // open first @@ -575,21 +575,21 @@ describe('Dropdown component', () => { open() expect( - document.querySelector('.dnb-drawer-list__option--selected') + document.querySelector('.dnb-drawer-list__option--selected'), ).not.toBeInTheDocument() expect( document .querySelector('.dnb-icon') - .getAttribute('data-testid') + .getAttribute('data-testid'), ).toBe('more icon') expect( - document.querySelector('.dnb-dropdown__text') + document.querySelector('.dnb-dropdown__text'), ).not.toBeInTheDocument() expect( - document.querySelector('.dnb-dropdown--is-popup') + document.querySelector('.dnb-dropdown--is-popup'), ).toBeInTheDocument() }) @@ -604,7 +604,7 @@ describe('Dropdown component', () => { data={mockData} on_change={on_change} on_select={on_select} - /> + />, ) // open first open() @@ -653,7 +653,7 @@ describe('Dropdown component', () => { {...props} data={{ 'en-GB': 'English', 'nb-NO': 'Norsk' }} on_change={on_change} - /> + />, ) open() @@ -704,7 +704,7 @@ describe('Dropdown component', () => { expect( elem .querySelector('button.dnb-dropdown__trigger') - .getAttribute('aria-expanded') + .getAttribute('aria-expanded'), ).toBe('true') expect(elem.getAttribute('class')).toContain('dnb-dropdown--opened') @@ -716,7 +716,7 @@ describe('Dropdown component', () => { open() expect( - document.querySelectorAll('li.dnb-drawer-list__option').length + document.querySelectorAll('li.dnb-drawer-list__option').length, ).toBe(mockData.length) }) @@ -731,7 +731,7 @@ describe('Dropdown component', () => { on_hide={on_hide} {...params} data={mockData} - /> + />, ) open() @@ -774,7 +774,7 @@ describe('Dropdown component', () => { on_show_focus={on_show_focus} on_hide_focus={on_hide_focus} data={mockData} - /> + />, ) // 1. open the dropdown @@ -789,7 +789,7 @@ describe('Dropdown component', () => { expect(on_show_focus).toBeCalledTimes(1) expect(on_show_focus.mock.calls[0][0].element).toBe( - document.activeElement + document.activeElement, ) // 2. close the dropdown with tab @@ -807,7 +807,7 @@ describe('Dropdown component', () => { }) expect(on_hide_focus).toBeCalledTimes(1) expect(on_hide_focus.mock.calls[0][0].element).toBe( - document.querySelector('.dnb-button') + document.querySelector('.dnb-button'), ) }) @@ -820,7 +820,7 @@ describe('Dropdown component', () => { open() expect(document.querySelector('.dnb-dropdown').classList).toContain( - 'dnb-dropdown--opened' + 'dnb-dropdown--opened', ) act(() => { @@ -831,14 +831,14 @@ describe('Dropdown component', () => { expect(on_hide.mock.calls.length).toBe(1) expect( - document.querySelector('.dnb-dropdown').classList + document.querySelector('.dnb-dropdown').classList, ).not.toContain('dnb-dropdown--opened') // reopen open() expect(document.querySelector('.dnb-dropdown').classList).toContain( - 'dnb-dropdown--opened' + 'dnb-dropdown--opened', ) preventClose = true @@ -852,24 +852,24 @@ describe('Dropdown component', () => { // we are still open expect(document.querySelector('.dnb-dropdown').classList).toContain( - 'dnb-dropdown--opened' + 'dnb-dropdown--opened', ) }) it('will set focus on options when key down/up is pressed on first item', async () => { const { rerender } = render( - + , ) // first open keydown(40) // down expect(document.querySelector('.dnb-dropdown').classList).toContain( - 'dnb-dropdown--opened' + 'dnb-dropdown--opened', ) expect(document.activeElement.classList).toContain( - 'dnb-drawer-list__options' + 'dnb-drawer-list__options', ) keydown(40) // down @@ -878,19 +878,19 @@ describe('Dropdown component', () => { await wait(1) expect(document.activeElement.classList).toContain( - 'dnb-drawer-list__option' + 'dnb-drawer-list__option', ) expect(document.activeElement.classList).toContain( - 'dnb-drawer-list__option--focus' + 'dnb-drawer-list__option--focus', ) expect( - document.querySelectorAll('li.dnb-drawer-list__option')[0].classList + document.querySelectorAll('li.dnb-drawer-list__option')[0].classList, ).toContain('dnb-drawer-list__option--focus') keydown(38) // up expect(document.activeElement.classList).toContain( - 'dnb-drawer-list__options' + 'dnb-drawer-list__options', ) // then simulate changes @@ -900,18 +900,18 @@ describe('Dropdown component', () => { await wait(1) expect(document.activeElement.classList).toContain( - 'dnb-drawer-list__option' + 'dnb-drawer-list__option', ) let options = document.querySelectorAll('li.dnb-drawer-list__option') expect(options[mockData.length - 1].classList).toContain( - 'dnb-drawer-list__option--focus' + 'dnb-drawer-list__option--focus', ) // then simulate changes keydown(40) // down expect( - document.querySelectorAll('li.dnb-drawer-list__option')[0].classList // the first item + document.querySelectorAll('li.dnb-drawer-list__option')[0].classList, // the first item ).toContain('dnb-drawer-list__option--focus') rerender( @@ -920,7 +920,7 @@ describe('Dropdown component', () => { no_animation data={mockData} direction="top" - /> + />, ) // then simulate changes @@ -928,7 +928,7 @@ describe('Dropdown component', () => { options = document.querySelectorAll('li.dnb-drawer-list__option') expect( - options[mockData.length - 1].classList // the last item + options[mockData.length - 1].classList, // the last item ).toContain('dnb-drawer-list__option--focus') // delay because we want to wait to have the DOM focus to be called @@ -938,7 +938,7 @@ describe('Dropdown component', () => { keydown(40) // down expect(document.activeElement.classList).toContain( - 'dnb-drawer-list__options' + 'dnb-drawer-list__options', ) // then simulate changes @@ -946,7 +946,7 @@ describe('Dropdown component', () => { options = document.querySelectorAll('li.dnb-drawer-list__option') expect( - options[mockData.length - 1].classList // the last item + options[mockData.length - 1].classList, // the last item ).toContain('dnb-drawer-list__option--focus') // then simulate changes @@ -954,14 +954,14 @@ describe('Dropdown component', () => { options = document.querySelectorAll('li.dnb-drawer-list__option') expect( - options[mockData.length - 2].classList // the second item + options[mockData.length - 2].classList, // the second item ).toContain('dnb-drawer-list__option--focus') // then simulate changes keydown(33) // pageUp expect( - document.querySelectorAll('li.dnb-drawer-list__option')[0].classList // the first item + document.querySelectorAll('li.dnb-drawer-list__option')[0].classList, // the first item ).toContain('dnb-drawer-list__option--focus') // then simulate changes @@ -969,7 +969,7 @@ describe('Dropdown component', () => { options = document.querySelectorAll('li.dnb-drawer-list__option') expect( - options[mockData.length - 1].classList // the last item + options[mockData.length - 1].classList, // the last item ).toContain('dnb-drawer-list__option--focus') }) @@ -977,7 +977,7 @@ describe('Dropdown component', () => { render( - + , ) // first open @@ -988,17 +988,17 @@ describe('Dropdown component', () => { keydown(13) // enter expect( - document.querySelector('.dnb-dropdown__text__inner').textContent + document.querySelector('.dnb-dropdown__text__inner').textContent, ).toBe( (mockData[(props.value as number) + 1] as DrawerListDataObject) - .selected_value + .selected_value, ) }) it('has correct selected value', () => { render() expect( - document.querySelector('.dnb-dropdown__text__inner').textContent + document.querySelector('.dnb-dropdown__text__inner').textContent, ).toBe((mockData[props.value] as DrawerListDataObject).selected_value) }) @@ -1010,7 +1010,7 @@ describe('Dropdown component', () => { keydown(40) // down expect( - document.querySelector('.dnb-dropdown__text__inner').textContent + document.querySelector('.dnb-dropdown__text__inner').textContent, ).toBe((mockData[props.value] as DrawerListDataObject).selected_value) }) @@ -1029,17 +1029,17 @@ describe('Dropdown component', () => { render() expect( - document.querySelector('.dnb-dropdown__text__inner').textContent + document.querySelector('.dnb-dropdown__text__inner').textContent, ).toBe((mockData[newValue] as DrawerListDataObject).selected_value) open() const options = document.querySelectorAll('li.dnb-drawer-list__option') expect(options[newValue].classList).toContain( - 'dnb-drawer-list__option--selected' + 'dnb-drawer-list__option--selected', ) expect(options[newValue].classList).toContain( - 'dnb-drawer-list__option--focus' + 'dnb-drawer-list__option--focus', ) }) @@ -1047,7 +1047,7 @@ describe('Dropdown component', () => { const title = 'Make a selection' render() expect( - document.querySelector('.dnb-dropdown__text__inner').innerHTML + document.querySelector('.dnb-dropdown__text__inner').innerHTML, ).toBe(title) }) @@ -1057,12 +1057,12 @@ describe('Dropdown component', () => { keydown(32) // space expect( - document.querySelector('button').getAttribute('aria-expanded') + document.querySelector('button').getAttribute('aria-expanded'), ).toBe('true') expect( document .querySelector('.dnb-drawer-list__option') - .querySelector('.dnb-drawer-list__option__inner').innerHTML + .querySelector('.dnb-drawer-list__option__inner').innerHTML, ).toBe('') }) @@ -1071,28 +1071,28 @@ describe('Dropdown component', () => { render() expect( - document.querySelector('.dnb-dropdown__text__inner').innerHTML + document.querySelector('.dnb-dropdown__text__inner').innerHTML, ).toBe(aStringOf) render() expect( - document.querySelector('.dnb-dropdown__text__inner').innerHTML + document.querySelector('.dnb-dropdown__text__inner').innerHTML, ).toBe(aStringOf) render() expect( - document.querySelector('.dnb-dropdown__text__inner').innerHTML + document.querySelector('.dnb-dropdown__text__inner').innerHTML, ).toBe(aStringOf) }) it('has a disabled attribute, once we set disabled to true', () => { const { rerender } = render( - + , ) rerender() expect( - document.querySelector('button.dnb-dropdown__trigger') + document.querySelector('button.dnb-dropdown__trigger'), ).toHaveAttribute('disabled') }) @@ -1161,7 +1161,7 @@ describe('Dropdown markup', () => { } const CheckComponent = render( - + , ) expect( @@ -1169,7 +1169,7 @@ describe('Dropdown markup', () => { rules: { 'aria-required-children': { enabled: false }, }, - }) + }), ).toHaveNoViolations() }) }) @@ -1182,7 +1182,7 @@ describe('Dropdown scss', () => { it('have to match default theme snapshot', () => { const css = loadScss( - require.resolve('../style/themes/dnb-dropdown-theme-ui.scss') + require.resolve('../style/themes/dnb-dropdown-theme-ui.scss'), ) expect(css).toMatchSnapshot() }) @@ -1193,7 +1193,7 @@ const keydown = (keyCode) => { document.querySelector('button.dnb-dropdown__trigger'), { keyCode, - } + }, ) } diff --git a/packages/dnb-eufemia/src/components/dropdown/stories/Dropdown.stories.tsx b/packages/dnb-eufemia/src/components/dropdown/stories/Dropdown.stories.tsx index 87e507a5010..4befb92d4e8 100644 --- a/packages/dnb-eufemia/src/components/dropdown/stories/Dropdown.stories.tsx +++ b/packages/dnb-eufemia/src/components/dropdown/stories/Dropdown.stories.tsx @@ -401,7 +401,7 @@ const DropdownStory = () => { console.log( 'on_change', // event.currentTarget.dataset, - attributes + attributes, ) }} data-attr={123} @@ -864,7 +864,7 @@ function UpdateDataExample() { size="small" on_click={() => { const updatedSelectedData = selectedData.filter( - (data) => item?.selected_value !== data?.selected_value + (data) => item?.selected_value !== data?.selected_value, ) setSelectedData(updatedSelectedData) setChoiceData( @@ -872,9 +872,9 @@ function UpdateDataExample() { (data) => updatedSelectedData.findIndex( ({ selected_value: updatedValue }) => - updatedValue === data?.selected_value - ) === -1 - ) + updatedValue === data?.selected_value, + ) === -1, + ), ) }} > @@ -897,12 +897,12 @@ function UpdateDataExample() { return ( data && item?.selected_value !== data?.selected_value ) - }) + }), ) if ( selectedData.findIndex( ({ selected_value }) => - selected_value === data.selected_value + selected_value === data.selected_value, ) === -1 ) { setSelectedData([...selectedData, data]) diff --git a/packages/dnb-eufemia/src/components/form-label/FormLabel.js b/packages/dnb-eufemia/src/components/form-label/FormLabel.js index 0e23c229545..70fbaea33e8 100644 --- a/packages/dnb-eufemia/src/components/form-label/FormLabel.js +++ b/packages/dnb-eufemia/src/components/form-label/FormLabel.js @@ -82,7 +82,7 @@ export default class FormLabel extends React.PureComponent { FormLabel.defaultProps, { skeleton: this.context?.skeleton }, includeValidProps(this.context.FormRow), - this.context.FormLabel + this.context.FormLabel, ) const { @@ -113,7 +113,7 @@ export default class FormLabel extends React.PureComponent { createSkeletonClass('font', skeleton, this.context), createSpacingClasses(props), className, - _className + _className, ), htmlFor: for_id, id, diff --git a/packages/dnb-eufemia/src/components/form-label/__tests__/FormLabel.test.tsx b/packages/dnb-eufemia/src/components/form-label/__tests__/FormLabel.test.tsx index b9ff7342b80..6f97d74ae33 100644 --- a/packages/dnb-eufemia/src/components/form-label/__tests__/FormLabel.test.tsx +++ b/packages/dnb-eufemia/src/components/form-label/__tests__/FormLabel.test.tsx @@ -18,10 +18,10 @@ describe('FormLabel component', () => { it('should forward unlisted attributes like "aria-hidden"', () => { render() expect( - document.querySelector('label[aria-hidden]') + document.querySelector('label[aria-hidden]'), ).toBeInTheDocument() expect(document.querySelector('label[aria-hidden]')).toHaveAttribute( - 'aria-hidden' + 'aria-hidden', ) }) @@ -51,12 +51,12 @@ describe('FormLabel component', () => { render( - + , ) const element = document.querySelector('.dnb-form-label') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['class', 'label']) @@ -86,7 +86,7 @@ describe('FormLabel scss', () => { it('have to match default theme snapshot', () => { const css = loadScss( - require.resolve('../style/themes/dnb-form-label-theme-ui.scss') + require.resolve('../style/themes/dnb-form-label-theme-ui.scss'), ) expect(css).toMatchSnapshot() }) diff --git a/packages/dnb-eufemia/src/components/form-row/FormRow.js b/packages/dnb-eufemia/src/components/form-row/FormRow.js index bd7de9663e6..7cad73c858a 100644 --- a/packages/dnb-eufemia/src/components/form-row/FormRow.js +++ b/packages/dnb-eufemia/src/components/form-row/FormRow.js @@ -137,7 +137,7 @@ export default class FormRow extends React.PureComponent { const props = extendPropsWithContextInClassComponent( this.props, FormRow.defaultProps, - this.context.FormRow // nested FormRow + this.context.FormRow, // nested FormRow ) const { @@ -197,7 +197,7 @@ export default class FormRow extends React.PureComponent { isNested && 'dnb-form-row--nested', createSpacingClasses(props), className, - _className + _className, ), ...attributes, } @@ -270,7 +270,7 @@ export default class FormRow extends React.PureComponent { 'dnb-form-row__content', isTrue(wrap) && 'dnb-form-row__content--wrap', label && !isTrue(vertical) && direction !== 'vertical', - responsive && 'dnb-responsive-component' + responsive && 'dnb-responsive-component', )} > {children} diff --git a/packages/dnb-eufemia/src/components/form-row/FormRowHelpers.tsx b/packages/dnb-eufemia/src/components/form-row/FormRowHelpers.tsx index 6bb52b54de1..61a6a8d2a9f 100644 --- a/packages/dnb-eufemia/src/components/form-row/FormRowHelpers.tsx +++ b/packages/dnb-eufemia/src/components/form-row/FormRowHelpers.tsx @@ -24,7 +24,7 @@ const validFormRowProps = { export const includeValidProps = ( props: FormRowProps, - excludeProps?: Record + excludeProps?: Record, ) => { return filterValidProps(props, validFormRowProps, excludeProps) } diff --git a/packages/dnb-eufemia/src/components/form-row/__tests__/FormRow.test.tsx b/packages/dnb-eufemia/src/components/form-row/__tests__/FormRow.test.tsx index 7f4a0d0cb67..040625b9e38 100644 --- a/packages/dnb-eufemia/src/components/form-row/__tests__/FormRow.test.tsx +++ b/packages/dnb-eufemia/src/components/form-row/__tests__/FormRow.test.tsx @@ -19,7 +19,7 @@ describe('FormRow component', () => { it('should have vertical direction class', () => { render() expect(document.querySelector('.dnb-form-row').classList).toContain( - 'dnb-form-row--vertical' + 'dnb-form-row--vertical', ) }) @@ -31,16 +31,16 @@ describe('FormRow component', () => { - + , ) expect( - document.querySelectorAll('span.dnb-input')[0].classList + document.querySelectorAll('span.dnb-input')[0].classList, ).toContain('dnb-input--vertical') expect( - document.querySelectorAll('span.dnb-input')[1].classList + document.querySelectorAll('span.dnb-input')[1].classList, ).toContain('dnb-input--horizontal') expect( - document.querySelectorAll('span.dnb-input')[2].classList + document.querySelectorAll('span.dnb-input')[2].classList, ).toContain('dnb-input--vertical') }) @@ -62,25 +62,25 @@ describe('FormRow component', () => { const { rerender } = render( 1234 - + , ) expect( document .querySelector('.dnb-number-format') - .querySelector('.dnb-number-format__visible').textContent + .querySelector('.dnb-number-format__visible').textContent, ).toBe('1Ā 234,00 kr') rerender( 1234 - + , ) expect( document .querySelector('.dnb-number-format') - .querySelector('.dnb-number-format__visible').textContent + .querySelector('.dnb-number-format__visible').textContent, ).toBe('NOKĀ 1Ā 234.00') }) @@ -90,13 +90,13 @@ describe('FormRow component', () => { 1234 - + , ) expect( document .querySelector('.dnb-number-format') - .querySelector('.dnb-number-format__visible').textContent + .querySelector('.dnb-number-format__visible').textContent, ).toBe('NOKĀ 1Ā 234.00') }) @@ -104,12 +104,12 @@ describe('FormRow component', () => { const { rerender } = render( - + , ) rerender( - + , ) expect(document.querySelector('input[disabled]')).toBeInTheDocument() }) @@ -128,7 +128,7 @@ describe('FormRow scss', () => { it('have to match default theme snapshot', () => { const css = loadScss( - require.resolve('../style/themes/dnb-form-row-theme-ui.scss') + require.resolve('../style/themes/dnb-form-row-theme-ui.scss'), ) expect(css).toMatchSnapshot() }) diff --git a/packages/dnb-eufemia/src/components/form-set/FormSet.js b/packages/dnb-eufemia/src/components/form-set/FormSet.js index 8bce576c6c7..839375ad8ec 100644 --- a/packages/dnb-eufemia/src/components/form-set/FormSet.js +++ b/packages/dnb-eufemia/src/components/form-set/FormSet.js @@ -69,7 +69,7 @@ export default class FormSet extends React.PureComponent { const props = extendPropsWithContextInClassComponent( this.props, FormSet.defaultProps, - this.context.FormSet + this.context.FormSet, ) const { @@ -107,7 +107,7 @@ export default class FormSet extends React.PureComponent { 'dnb-form-set', createSpacingClasses(this.props), className, - _className + _className, ), ...attributes, } diff --git a/packages/dnb-eufemia/src/components/form-set/__tests__/FormSet.test.tsx b/packages/dnb-eufemia/src/components/form-set/__tests__/FormSet.test.tsx index 6bfe221097d..8e8396e73f9 100644 --- a/packages/dnb-eufemia/src/components/form-set/__tests__/FormSet.test.tsx +++ b/packages/dnb-eufemia/src/components/form-set/__tests__/FormSet.test.tsx @@ -28,10 +28,10 @@ describe('FormSet component', () => { render( - + , ) expect(document.querySelector('.dnb-form-row').classList).toContain( - 'dnb-form-row--vertical' + 'dnb-form-row--vertical', ) }) @@ -41,10 +41,10 @@ describe('FormSet component', () => { - + , ) expect( - document.querySelector('input.dnb-input__input[disabled]') + document.querySelector('input.dnb-input__input[disabled]'), ).toBeInTheDocument() rerender( @@ -52,10 +52,10 @@ describe('FormSet component', () => { - + , ) expect( - document.querySelector('input.dnb-input__input[disabled]') + document.querySelector('input.dnb-input__input[disabled]'), ).not.toBeInTheDocument() rerender( @@ -63,10 +63,10 @@ describe('FormSet component', () => { - + , ) expect( - document.querySelector('input.dnb-input__input[disabled]') + document.querySelector('input.dnb-input__input[disabled]'), ).toBeInTheDocument() rerender( @@ -74,11 +74,11 @@ describe('FormSet component', () => { - + , ) expect( - document.querySelector('input.dnb-input__input[disabled]') + document.querySelector('input.dnb-input__input[disabled]'), ).not.toBeInTheDocument() }) @@ -86,25 +86,25 @@ describe('FormSet component', () => { const { rerender } = render( 1234 - + , ) expect( document .querySelector('.dnb-number-format') - .querySelector('.dnb-number-format__visible').textContent + .querySelector('.dnb-number-format__visible').textContent, ).toBe('1Ā 234,00 kr') rerender( 1234 - + , ) expect( document .querySelector('.dnb-number-format') - .querySelector('.dnb-number-format__visible').textContent + .querySelector('.dnb-number-format__visible').textContent, ).toBe('NOKĀ 1Ā 234.00') }) @@ -114,13 +114,13 @@ describe('FormSet component', () => { 1234 - + , ) expect( document .querySelector('.dnb-number-format') - .querySelector('.dnb-number-format__visible').textContent + .querySelector('.dnb-number-format__visible').textContent, ).toBe('NOKĀ 1Ā 234.00') }) @@ -138,7 +138,7 @@ describe('FormSet scss', () => { it('have to match default theme snapshot', () => { const css = loadScss( - require.resolve('../style/themes/dnb-form-set-theme-ui.scss') + require.resolve('../style/themes/dnb-form-set-theme-ui.scss'), ) expect(css).toMatchSnapshot() }) diff --git a/packages/dnb-eufemia/src/components/form-status/FormStatus.js b/packages/dnb-eufemia/src/components/form-status/FormStatus.js index da43f6e5993..9692d6a2ef8 100644 --- a/packages/dnb-eufemia/src/components/form-status/FormStatus.js +++ b/packages/dnb-eufemia/src/components/form-status/FormStatus.js @@ -195,7 +195,7 @@ export default class FormStatus extends React.PureComponent { }, }) } - } + }, ) this._ref = React.createRef() @@ -283,7 +283,7 @@ export default class FormStatus extends React.PureComponent { }, { preventRestack: true, // because of the internal "close" - } + }, ) } else if (!FormStatus.getContent(this.props)) { const status_id = this.getStatusId() @@ -336,7 +336,7 @@ export default class FormStatus extends React.PureComponent { FormStatus.defaultProps, { skeleton: this.context && this.context.skeleton }, includeValidProps(this.context.FormRow), - this.context.FormStatus + this.context.FormStatus, ) const { @@ -370,7 +370,7 @@ export default class FormStatus extends React.PureComponent { state, icon, icon_size, - theme: this.context?.theme?.name + theme: this.context?.theme?.name, }) const contentToRender = @@ -404,7 +404,7 @@ export default class FormStatus extends React.PureComponent { hasStringContent ? 'dnb-form-status--has-content' : null, createSpacingClasses(props), className, - _className + _className, ), id: !String(id).startsWith('null') ? this.state.id : null, title, @@ -425,7 +425,7 @@ export default class FormStatus extends React.PureComponent { const textParams = { className: classnames( 'dnb-form-status__text', - createSkeletonClass('font', skeleton, this.context) + createSkeletonClass('font', skeleton, this.context), ), id: !String(text_id).startsWith('null') ? text_id : null, } @@ -501,8 +501,8 @@ WarnIcon.defaultProps = { title: 'error', } -export const InfoIcon = props => { - const isSbankenTheme = props && props?.theme === 'sbanken'; +export const InfoIcon = (props) => { + const isSbankenTheme = props && props?.theme === 'sbanken' let fill = isSbankenTheme ? '#000' : '#007272' if (props && props?.state === 'success') { fill = isSbankenTheme ? '#02A56A' : '#28B482' @@ -536,7 +536,7 @@ InfoIcon.propTypes = { InfoIcon.defaultProps = { title: 'info', state: 'info', - theme: 'ui' + theme: 'ui', } export const MarketingIcon = (props) => ( diff --git a/packages/dnb-eufemia/src/components/form-status/__tests__/FormStatus.test.tsx b/packages/dnb-eufemia/src/components/form-status/__tests__/FormStatus.test.tsx index 474583aff57..d6f9e0509b7 100644 --- a/packages/dnb-eufemia/src/components/form-status/__tests__/FormStatus.test.tsx +++ b/packages/dnb-eufemia/src/components/form-status/__tests__/FormStatus.test.tsx @@ -19,24 +19,24 @@ describe('FormStatus component', () => { + />, ) expect( - document.querySelector('.dnb-input__input').getAttribute('style') + document.querySelector('.dnb-input__input').getAttribute('style'), ).toBe('width: 10rem;') expect( - document.querySelector('.dnb-form-status').getAttribute('style') + document.querySelector('.dnb-form-status').getAttribute('style'), ).toContain('max-width: 30rem;') }) it('should re-calculate max-width', () => { const { rerender } = render( - + , ) expect( - document.querySelector('.dnb-form-status').getAttribute('style') + document.querySelector('.dnb-form-status').getAttribute('style'), ).toBe('max-width: 30rem;') rerender( @@ -44,11 +44,11 @@ describe('FormStatus component', () => { status="status message" status_props={{ text: 'change width to 35rem' }} style={{ width: '35rem' }} - /> + />, ) expect( - document.querySelector('.dnb-form-status').getAttribute('style') + document.querySelector('.dnb-form-status').getAttribute('style'), ).toBe('max-width: 35rem; height: auto;') rerender( @@ -56,11 +56,11 @@ describe('FormStatus component', () => { status="status message" status_props={{ text: 'change width to 40rem' }} style={{ width: '40rem' }} - /> + />, ) expect( - document.querySelector('.dnb-form-status').getAttribute('style') + document.querySelector('.dnb-form-status').getAttribute('style'), ).toBe('max-width: 40rem; height: auto;') rerender( @@ -68,13 +68,13 @@ describe('FormStatus component', () => { status="status message" status_props={{ text: 'change width to 10rem' }} style={{ width: '10rem' }} - /> + />, ) window.dispatchEvent(new Event('resize')) expect( - document.querySelector('.dnb-form-status').getAttribute('style') + document.querySelector('.dnb-form-status').getAttribute('style'), ).toBe('max-width: 30rem; height: auto;') }) @@ -82,10 +82,10 @@ describe('FormStatus component', () => { render() expect( - document.querySelector('.dnb-form-status').getAttribute('id') + document.querySelector('.dnb-form-status').getAttribute('id'), ).toBe('custom-id-form-status') expect( - document.querySelector('.dnb-form-status__text').getAttribute('id') + document.querySelector('.dnb-form-status__text').getAttribute('id'), ).toBe('custom-id-status') }) @@ -96,10 +96,10 @@ describe('FormStatus component', () => { status_props={{ variant: 'outlined', }} - /> + />, ) expect(document.querySelector('.dnb-form-status').classList).toContain( - 'dnb-form-status__variant--outlined' + 'dnb-form-status__variant--outlined', ) }) @@ -109,26 +109,26 @@ describe('FormStatus component', () => { rerender(content-a) expect(document.querySelector('.dnb-form-status').textContent).toBe( - 'content-a' + 'content-a', ) rerender(content-b) expect(document.querySelector('.dnb-form-status').textContent).toBe( - 'content-b' + 'content-b', ) }) it('should have correct attributes once the "hidden" prop changes', async () => { const { rerender } = render(
    Row {i} Column 2 Row {i} Column 3 Row {i} Column 4
    -
    + , ) expect(Array.from(screen.queryByRole('table').classList)).toEqual([ @@ -49,7 +49,7 @@ describe('Table', () => { render( -
    + , ) expect(Array.from(screen.queryByRole('table').classList)).toEqual([ @@ -63,7 +63,7 @@ describe('Table', () => { render( -
    + , ) expect(Array.from(screen.queryByRole('table').classList)).toEqual([ @@ -77,7 +77,7 @@ describe('Table', () => { render( -
    + , ) expect(Array.from(screen.queryByRole('table').classList)).toEqual( @@ -86,7 +86,7 @@ describe('Table', () => { 'dnb-table__variant--generic', 'dnb-table__size--large', 'custom-class', - ]) + ]), ) }) @@ -94,11 +94,11 @@ describe('Table', () => { render( -
    + , ) expect(screen.queryByRole('table').getAttribute('aria-label')).toEqual( - 'custom-label' + 'custom-label', ) }) @@ -106,7 +106,7 @@ describe('Table', () => { render( -
    + , ) expect(Array.from(screen.queryByRole('table').classList)).toEqual( @@ -115,7 +115,7 @@ describe('Table', () => { 'dnb-table__variant--generic', 'dnb-table__size--large', 'dnb-table--fixed', - ]) + ]), ) }) @@ -123,11 +123,11 @@ describe('Table', () => { render( -
    + , ) expect(Array.from(screen.queryByRole('table').classList)).toContain( - 'dnb-table--border' + 'dnb-table--border', ) }) @@ -135,11 +135,11 @@ describe('Table', () => { render( -
    + , ) expect(Array.from(screen.queryByRole('table').classList)).toContain( - 'dnb-table--outline' + 'dnb-table--outline', ) }) @@ -147,12 +147,12 @@ describe('Table', () => { render( -
    + , ) const element = screen.queryByRole('table') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['class']) @@ -162,7 +162,7 @@ describe('Table', () => { 'dnb-table__variant--generic', 'dnb-table__size--large', 'dnb-space__top--large', - ]) + ]), ) }) @@ -170,12 +170,12 @@ describe('Table', () => { render( -
    + , ) const element = screen.queryByRole('table') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['class']) @@ -186,7 +186,7 @@ describe('Table', () => { 'dnb-table__size--large', 'dnb-skeleton', 'dnb-skeleton--font', - ]) + ]), ) }) }) @@ -196,7 +196,7 @@ describe('Table aria', () => { const Component = render( -
    + , ) expect(await axeComponent(Component)).toHaveNoViolations() }) @@ -210,7 +210,7 @@ describe('Table scss', () => { it('have to match default theme snapshot', () => { const css = loadScss( - require.resolve('../style/themes/dnb-table-theme-ui.scss') + require.resolve('../style/themes/dnb-table-theme-ui.scss'), ) expect(css).toMatchSnapshot() }) diff --git a/packages/dnb-eufemia/src/components/table/__tests__/TableAccordion.test.tsx b/packages/dnb-eufemia/src/components/table/__tests__/TableAccordion.test.tsx index 262f5dc85d9..2725f768b18 100644 --- a/packages/dnb-eufemia/src/components/table/__tests__/TableAccordion.test.tsx +++ b/packages/dnb-eufemia/src/components/table/__tests__/TableAccordion.test.tsx @@ -29,7 +29,7 @@ describe('TableAccordion', () => { content - + , ) const element = document.querySelector('table') @@ -46,13 +46,13 @@ describe('TableAccordion', () => { accordion content - + , ) const element = document.querySelector('tr') expect(Array.from(element.classList)).toContain( - 'dnb-table__tr--has-accordion-content' + 'dnb-table__tr--has-accordion-content', ) }) @@ -65,14 +65,14 @@ describe('TableAccordion', () => { accordion content - + , ) const element = document.querySelector('tr') .nextSibling as HTMLTableRowElement const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['aria-hidden', 'hidden', 'class']) @@ -92,14 +92,14 @@ describe('TableAccordion', () => { accordion content - + , ) const trElement = document.querySelector('tr') const accordionElem = trElement.nextSibling as HTMLTableRowElement const attributes = Array.from(accordionElem.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['aria-hidden', 'role', 'class']) @@ -122,7 +122,7 @@ describe('TableAccordion', () => { accordion content - + , ) const element = document.querySelector('tr') as HTMLTableRowElement @@ -144,7 +144,7 @@ describe('TableAccordion', () => { accordion content - + , ) const trElement = document.querySelector('tr') @@ -152,7 +152,7 @@ describe('TableAccordion', () => { const element = accordionElem.querySelector('td') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['colspan', 'class']) @@ -170,7 +170,7 @@ describe('TableAccordion', () => { accordion content - + , ) const trElement = document.querySelector('tr') @@ -178,7 +178,7 @@ describe('TableAccordion', () => { const element = accordionElem.querySelector('td') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['role', 'colspan', 'class', 'style']) @@ -197,7 +197,7 @@ describe('TableAccordion', () => { accordion content - + , ) const trElement = document.querySelector('tr') @@ -205,12 +205,12 @@ describe('TableAccordion', () => { const element = accordionElem.querySelector('td') expect( - element.querySelector('div.dnb-table__tr__accordion_content__inner') + element.querySelector('div.dnb-table__tr__accordion_content__inner'), ).toBeInTheDocument() expect( element.querySelector( - 'div.dnb-table__tr__accordion_content__inner__spacing' - ) + 'div.dnb-table__tr__accordion_content__inner__spacing', + ), ).toBeInTheDocument() }) @@ -224,7 +224,7 @@ describe('TableAccordion', () => { accordion content - + , ) const trElement = document.querySelector('tr') @@ -234,7 +234,7 @@ describe('TableAccordion', () => { expect(element.querySelector('span.dnb-sr-only')).toBeInTheDocument() expect(element.querySelector('span[aria-live]')).toBeInTheDocument() expect( - element.querySelector('span[aria-live]').getAttribute('aria-live') + element.querySelector('span[aria-live]').getAttribute('aria-live'), ).toBe('assertive') }) @@ -248,7 +248,7 @@ describe('TableAccordion', () => { accordion content - + , ) const trElement = document.querySelector('tr') @@ -270,7 +270,7 @@ describe('TableAccordion', () => { accordion content - + , ) expect(liveElement.textContent).toBe(en.accordionMoreContentSR) @@ -285,7 +285,7 @@ describe('TableAccordion', () => { accordion content - + , ) const trElement = document.querySelector('tr') @@ -298,10 +298,10 @@ describe('TableAccordion', () => { fireEvent.click(trElement) expect(Array.from(trElement.classList)).toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) expect(Array.from(accordionElem.classList)).toContain( - 'dnb-table__tr__accordion_content--expanded' + 'dnb-table__tr__accordion_content--expanded', ) }) @@ -317,7 +317,7 @@ describe('TableAccordion', () => { accordion content - + , ) const trElement = document.querySelector('tr') @@ -329,7 +329,7 @@ describe('TableAccordion', () => { fireEvent.click(inputElem) expect(Array.from(trElement.classList)).not.toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) jest @@ -339,7 +339,7 @@ describe('TableAccordion', () => { fireEvent.click(buttonElem) expect(Array.from(trElement.classList)).not.toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) jest.spyOn(document, 'activeElement', 'get').mockReturnValue(null) @@ -347,20 +347,20 @@ describe('TableAccordion', () => { fireEvent.click(inputElem) expect(Array.from(trElement.classList)).not.toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) fireEvent.click(buttonElem) expect(Array.from(trElement.classList)).toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) // Close again fireEvent.click(trElement) expect(Array.from(trElement.classList)).not.toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) const getSelection = jest.fn(() => ({ @@ -372,7 +372,7 @@ describe('TableAccordion', () => { fireEvent.click(trElement) expect(Array.from(trElement.classList)).not.toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) // Simulate keyboard usage @@ -381,13 +381,13 @@ describe('TableAccordion', () => { fireEvent.keyDown(inputElem, { keyCode: 13 }) // enter expect(Array.from(trElement.classList)).not.toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) fireEvent.keyDown(inputElem, { keyCode: 32 }) // space expect(Array.from(trElement.classList)).not.toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) jest.spyOn(document, 'activeElement', 'get').mockReturnValue(null) @@ -407,7 +407,7 @@ describe('TableAccordion', () => { accordion content - + , ) const select = (i: number, list: NodeListOf) => @@ -415,21 +415,21 @@ describe('TableAccordion', () => { const getTh = (i: number) => { return select( i, - document.querySelector('thead tr').querySelectorAll('th') + document.querySelector('thead tr').querySelectorAll('th'), ) } const getTd = (i: number) => { return select( i, - document.querySelector('tbody tr').querySelectorAll('td') + document.querySelector('tbody tr').querySelectorAll('td'), ) } expect(Array.from(getTh(0).classList)).toContain( - 'dnb-table__th__accordion-icon' + 'dnb-table__th__accordion-icon', ) expect(Array.from(getTd(0).classList)).toContain( - 'dnb-table__td__accordion-icon' + 'dnb-table__td__accordion-icon', ) rerender( @@ -445,14 +445,14 @@ describe('TableAccordion', () => { accordion content - + , ) expect(Array.from(getTh(-1).classList)).toContain( - 'dnb-table__th__accordion-icon' + 'dnb-table__th__accordion-icon', ) expect(Array.from(getTd(-1).classList)).toContain( - 'dnb-table__td__accordion-icon' + 'dnb-table__td__accordion-icon', ) }) @@ -464,12 +464,12 @@ describe('TableAccordion', () => { heading - + , ) const trElement = document.querySelector('thead tr th') expect(Array.from(trElement.classList)).toContain( - 'dnb-table__th__accordion-icon' + 'dnb-table__th__accordion-icon', ) const divElement = trElement.querySelector('div') @@ -484,12 +484,12 @@ describe('TableAccordion', () => { heading - + , ) const thElement = document.querySelector('thead tr th') expect(Array.from(thElement.classList)).toContain( - 'dnb-table__th__accordion-icon' + 'dnb-table__th__accordion-icon', ) expect(thElement.textContent).toBe(nb.accordionToggleButtonSR) @@ -507,12 +507,12 @@ describe('TableAccordion', () => { const { rerender } = render( {content}
    -
    + , ) const thElement = document.querySelector('thead tr th') expect(Array.from(thElement.classList)).toContain( - 'dnb-table__th__accordion-icon' + 'dnb-table__th__accordion-icon', ) expect(thElement.textContent).toBe(nb.accordionToggleButtonSR) @@ -522,7 +522,7 @@ describe('TableAccordion', () => { {content}
    - + , ) expect(thElement.textContent).toBe(en.accordionToggleButtonSR) @@ -530,7 +530,7 @@ describe('TableAccordion', () => { rerender( {content}
    -
    + , ) expect(thElement.textContent).toBe(nb.accordionToggleButtonSR) @@ -540,7 +540,7 @@ describe('TableAccordion', () => { {content}
    - + , ) expect(thElement.textContent).toBe(en.accordionToggleButtonSR) @@ -560,7 +560,7 @@ describe('TableAccordion', () => { accordion content - + , ) const trElement = document.querySelector('tbody tr') @@ -569,7 +569,7 @@ describe('TableAccordion', () => { jest.spyOn(document, 'activeElement', 'get').mockReturnValue(trElement) expect(Array.from(trElement.classList)).not.toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) // open @@ -581,10 +581,10 @@ describe('TableAccordion', () => { expect(enterKey.preventDefault).toHaveBeenCalledTimes(1) expect(Array.from(trElement.classList)).toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) expect(Array.from(accordionElem.classList)).toContain( - 'dnb-table__tr__accordion_content--expanded' + 'dnb-table__tr__accordion_content--expanded', ) // close @@ -596,10 +596,10 @@ describe('TableAccordion', () => { expect(spaceKey.preventDefault).toHaveBeenCalledTimes(1) expect(Array.from(trElement.classList)).not.toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) expect(Array.from(accordionElem.classList)).not.toContain( - 'dnb-table__tr__accordion_content--expanded' + 'dnb-table__tr__accordion_content--expanded', ) }) @@ -612,7 +612,7 @@ describe('TableAccordion', () => { accordion content - + , ) const trElement = document.querySelector('tr') @@ -626,20 +626,20 @@ describe('TableAccordion', () => { fireEvent.mouseEnter(trElement) expect(Array.from(trElement.classList)).not.toContain( - 'dnb-table__tr--hover' + 'dnb-table__tr--hover', ) fireEvent.click(trElement) fireEvent.mouseEnter(trElement) expect(Array.from(trElement.classList)).toContain( - 'dnb-table__tr--hover' + 'dnb-table__tr--hover', ) fireEvent.mouseLeave(trElement) expect(Array.from(trElement.classList)).not.toContain( - 'dnb-table__tr--hover' + 'dnb-table__tr--hover', ) }) @@ -667,27 +667,27 @@ describe('TableAccordion', () => { accordion content 2 - + , ) const trElement1 = document.querySelector('tr') expect(Array.from(trElement1.classList)).toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) const accordionElem1 = trElement1.nextSibling as HTMLTableRowElement expect(Array.from(accordionElem1.classList)).toContain( - 'dnb-table__tr__accordion_content--expanded' + 'dnb-table__tr__accordion_content--expanded', ) const trElement2 = document.querySelectorAll('tr')[1] expect(Array.from(trElement2.classList)).not.toContain( - 'dnb-table__tr--expanded' + 'dnb-table__tr--expanded', ) const accordionElem2 = trElement2.nextSibling as HTMLTableRowElement expect(Array.from(accordionElem2.classList)).not.toContain( - 'dnb-table__tr__accordion_content--expanded' + 'dnb-table__tr__accordion_content--expanded', ) }) @@ -707,7 +707,7 @@ describe('TableAccordion', () => { accordion content - + , ) const trElement = document.querySelector('tr') @@ -732,7 +732,7 @@ describe('TableAccordion', () => { accordion content - + , ) const trElement = document.querySelector('tr') @@ -742,8 +742,8 @@ describe('TableAccordion', () => { act(() => { simulateAnimationEnd( document.querySelector( - '.dnb-table__tr__accordion_content__inner' - ) + '.dnb-table__tr__accordion_content__inner', + ), ) expect(onOpened).toHaveBeenCalledTimes(1) @@ -764,7 +764,7 @@ describe('TableAccordion', () => { accordion content - + , ) const trElement = document.querySelector('tr') @@ -775,8 +775,8 @@ describe('TableAccordion', () => { act(() => { simulateAnimationEnd( document.querySelector( - '.dnb-table__tr__accordion_content__inner' - ) + '.dnb-table__tr__accordion_content__inner', + ), ) expect(onClosed).toHaveBeenCalledTimes(1) diff --git a/packages/dnb-eufemia/src/components/table/__tests__/TableContainer.test.tsx b/packages/dnb-eufemia/src/components/table/__tests__/TableContainer.test.tsx index 65130664234..e9cf73a7877 100644 --- a/packages/dnb-eufemia/src/components/table/__tests__/TableContainer.test.tsx +++ b/packages/dnb-eufemia/src/components/table/__tests__/TableContainer.test.tsx @@ -43,11 +43,11 @@ describe('TableContainer', () => { expect(element.textContent).toBe('HeaderTexttable 1table 2text') expect( - document.querySelector('.dnb-table__container__head--empty') + document.querySelector('.dnb-table__container__head--empty'), ).not.toBeInTheDocument() expect( - document.querySelector('.dnb-table__container__foot--empty') + document.querySelector('.dnb-table__container__foot--empty'), ).not.toBeInTheDocument() }) @@ -56,7 +56,7 @@ describe('TableContainer', () => { const element = document.querySelector('.dnb-table__container') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['class', 'aria-label']) @@ -81,7 +81,7 @@ describe('TableContainer', () => { render() expect( - document.querySelector('.dnb-table__container__head--empty') + document.querySelector('.dnb-table__container__head--empty'), ).toBeInTheDocument() }) @@ -89,7 +89,7 @@ describe('TableContainer', () => { render() expect( - document.querySelector('.dnb-table__container__foot--empty') + document.querySelector('.dnb-table__container__foot--empty'), ).toBeInTheDocument() }) @@ -105,15 +105,15 @@ describe('TableContainer', () => { - + , ) expect( - document.querySelector('.dnb-table__container__head--empty') + document.querySelector('.dnb-table__container__head--empty'), ).toBeInTheDocument() expect( - document.querySelector('.dnb-table__container__foot--empty') + document.querySelector('.dnb-table__container__foot--empty'), ).toBeInTheDocument() }) @@ -122,7 +122,7 @@ describe('TableContainer', () => { const element = document.querySelector('.dnb-scroll-view') expect(Array.from(element.classList)).toContain( - 'dnb-table__scroll-view' + 'dnb-table__scroll-view', ) }) @@ -131,7 +131,7 @@ describe('TableContainer', () => { const element = document.querySelector('.dnb-table__container') expect(Array.from(element.classList)).toContain( - 'dnb-space__top--large' + 'dnb-space__top--large', ) }) }) diff --git a/packages/dnb-eufemia/src/components/table/__tests__/TableScrollView.test.tsx b/packages/dnb-eufemia/src/components/table/__tests__/TableScrollView.test.tsx index 4ffa64c8243..a58a13071da 100644 --- a/packages/dnb-eufemia/src/components/table/__tests__/TableScrollView.test.tsx +++ b/packages/dnb-eufemia/src/components/table/__tests__/TableScrollView.test.tsx @@ -17,7 +17,7 @@ describe('Table.ScrollView', () => { render() expect( - document.querySelector('.dnb-table__scroll-view') + document.querySelector('.dnb-table__scroll-view'), ).toBeInTheDocument() }) @@ -27,7 +27,7 @@ describe('Table.ScrollView', () => {
    -
    + , ) const element = document.querySelector('.dnb-table__scroll-view') @@ -55,7 +55,7 @@ describe('Table.ScrollView', () => {
    - + , ) const element = document.querySelector('.dnb-table__scroll-view') diff --git a/packages/dnb-eufemia/src/components/table/__tests__/TableStickyHeader.test.tsx b/packages/dnb-eufemia/src/components/table/__tests__/TableStickyHeader.test.tsx index 515a45a92e0..c63c9097bc4 100644 --- a/packages/dnb-eufemia/src/components/table/__tests__/TableStickyHeader.test.tsx +++ b/packages/dnb-eufemia/src/components/table/__tests__/TableStickyHeader.test.tsx @@ -18,7 +18,7 @@ describe('useStickyHeader', () => { const simulateScroll = ( y: number, - scrollElement: HTMLElement = null + scrollElement: HTMLElement = null, ) => { if (scrollElement) { jest.spyOn(scrollElement, 'scrollTop', 'get').mockReturnValue(y) @@ -41,7 +41,7 @@ describe('useStickyHeader', () => { render( -
    + , ) expect(Array.from(screen.queryByRole('table').classList)).toEqual([ @@ -56,7 +56,7 @@ describe('useStickyHeader', () => { render( -
    + , ) expect(Array.from(screen.queryByRole('table').classList)).toEqual([ @@ -71,7 +71,7 @@ describe('useStickyHeader', () => { render( -
    + , ) setSizes() @@ -82,7 +82,7 @@ describe('useStickyHeader', () => { 'dnb-table__tr--odd', 'sticky', 'css-position', - ]) + ]), ) }) @@ -93,13 +93,13 @@ describe('useStickyHeader', () => { render( -
    + , ) setSizes() expect(Array.from(screen.queryByRole('table').classList)).toContain( - 'dnb-table--sticky' + 'dnb-table--sticky', ) simulateScroll(200) @@ -115,7 +115,7 @@ describe('useStickyHeader', () => { const { rerender } = render( -
    + , ) const thElement = document.querySelector('th') @@ -131,7 +131,7 @@ describe('useStickyHeader', () => { rerender( -
    + , ) setSizes() @@ -143,7 +143,7 @@ describe('useStickyHeader', () => { const { rerender } = render( -
    + , ) const tableElement = document.querySelector('table') @@ -159,7 +159,7 @@ describe('useStickyHeader', () => { // Should set correct value (320-(160-64)=224) simulateScroll(320) expect(trElem.style.getPropertyValue('--table-offset')).toEqual( - '224px' + '224px', ) simulateScroll(0) @@ -168,13 +168,13 @@ describe('useStickyHeader', () => { // Should set correct value (300-(160-64)=204) simulateScroll(300) expect(trElem.style.getPropertyValue('--table-offset')).toEqual( - '204px' + '204px', ) // Should keep the previous value (300-(160-64)=204) simulateScroll(3000) expect(trElem.style.getPropertyValue('--table-offset')).toEqual( - '204px' + '204px', ) // change the table offset @@ -184,13 +184,13 @@ describe('useStickyHeader', () => { // Should set correct value (320-(80-64)=304) simulateScroll(320) expect(trElem.style.getPropertyValue('--table-offset')).toEqual( - '304px' + '304px', ) rerender( -
    + , ) setSizes() @@ -198,7 +198,7 @@ describe('useStickyHeader', () => { // Should set correct value (320-160=160) simulateScroll(320) expect(trElem.style.getPropertyValue('--table-offset')).toEqual( - '160px' + '160px', ) }) @@ -208,7 +208,7 @@ describe('useStickyHeader', () => {
    -
    + , ) const trElem = document.querySelector('tr') @@ -237,7 +237,7 @@ describe('useStickyHeader', () => {
    - + , ) simulateScroll(46, scrollElem) @@ -255,13 +255,13 @@ describe('useStickyHeader', () => { - + , ) const tableElement = document.querySelector('table') const trElem = document.querySelector('tr') const barElem: HTMLElement = document.querySelector( - '.dnb-modal__header__bar' + '.dnb-modal__header__bar', ) const scrollElem: HTMLElement = document.querySelector('.dnb-scroll-view') @@ -278,7 +278,7 @@ describe('useStickyHeader', () => { // Should set correct value (320-(160-40)=200) simulateScroll(320, scrollElem) expect(trElem.style.getPropertyValue('--table-offset')).toEqual( - '200px' + '200px', ) simulateScroll(0, scrollElem) @@ -287,13 +287,13 @@ describe('useStickyHeader', () => { // Should set correct value (300-(160-40)=180) simulateScroll(300, scrollElem) expect(trElem.style.getPropertyValue('--table-offset')).toEqual( - '180px' + '180px', ) // Should keep the previous value (300-(160-40)=180) simulateScroll(3000, scrollElem) expect(trElem.style.getPropertyValue('--table-offset')).toEqual( - '180px' + '180px', ) // change the table offset @@ -303,7 +303,7 @@ describe('useStickyHeader', () => { // Should set correct value (320-(80-40)=280) simulateScroll(320, scrollElem) expect(trElem.style.getPropertyValue('--table-offset')).toEqual( - '280px' + '280px', ) rerender( @@ -314,7 +314,7 @@ describe('useStickyHeader', () => { - + , ) setSizes() @@ -322,7 +322,7 @@ describe('useStickyHeader', () => { // Should set correct value (320-(160-64)=224) simulateScroll(320, scrollElem) expect(trElem.style.getPropertyValue('--table-offset')).toEqual( - '224px' + '224px', ) rerender( @@ -333,7 +333,7 @@ describe('useStickyHeader', () => { - + , ) setSizes() @@ -341,7 +341,7 @@ describe('useStickyHeader', () => { // Should set correct value (320-(160-40)=200) simulateScroll(320, scrollElem) expect(trElem.style.getPropertyValue('--table-offset')).toEqual( - '200px' + '200px', ) }) }) @@ -351,7 +351,7 @@ describe('Table aria', () => { const Component = render( -
    + , ) expect(await axeComponent(Component)).toHaveNoViolations() }) diff --git a/packages/dnb-eufemia/src/components/table/__tests__/TableTd.test.tsx b/packages/dnb-eufemia/src/components/table/__tests__/TableTd.test.tsx index 56e8e3bf9c3..3e219d7484a 100644 --- a/packages/dnb-eufemia/src/components/table/__tests__/TableTd.test.tsx +++ b/packages/dnb-eufemia/src/components/table/__tests__/TableTd.test.tsx @@ -14,7 +14,7 @@ describe('TableTd', () => { - + , ) expect(document.querySelector('td')).toBeInTheDocument() }) @@ -27,7 +27,7 @@ describe('TableTd', () => { td content - + , ) const element = document.querySelector('td') @@ -43,12 +43,12 @@ describe('TableTd', () => { td content - + , ) const element = document.querySelector('td') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['role', 'class', 'aria-label']) @@ -62,7 +62,7 @@ describe('TableTd', () => { td content - + , ) const element = document.querySelector('td') @@ -78,7 +78,7 @@ describe('TableTd', () => { td content - + , ) const element = document.querySelector('td') @@ -96,12 +96,12 @@ describe('TableTd', () => { td content - + , ) const element = document.querySelector('td') expect(Array.from(element.classList)).toContain( - 'dnb-table__td--no-spacing' + 'dnb-table__td--no-spacing', ) }) @@ -113,12 +113,12 @@ describe('TableTd', () => { td content - + , ) const element = document.querySelector('td') expect(Array.from(element.classList)).toContain( - 'dnb-table__td--spacing-horizontal' + 'dnb-table__td--spacing-horizontal', ) }) diff --git a/packages/dnb-eufemia/src/components/table/__tests__/TableTh.test.tsx b/packages/dnb-eufemia/src/components/table/__tests__/TableTh.test.tsx index c3337162fcd..4ed6994812c 100644 --- a/packages/dnb-eufemia/src/components/table/__tests__/TableTh.test.tsx +++ b/packages/dnb-eufemia/src/components/table/__tests__/TableTh.test.tsx @@ -15,7 +15,7 @@ describe('TableTh', () => { - + , ) expect(document.querySelector('th')).toBeInTheDocument() }) @@ -28,7 +28,7 @@ describe('TableTh', () => { th content - + , ) const element = document.querySelector('th') @@ -44,12 +44,12 @@ describe('TableTh', () => { th content - + , ) const element = document.querySelector('th') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['role', 'scope', 'class', 'align']) @@ -63,7 +63,7 @@ describe('TableTh', () => { th content - + , ) const element = document.querySelector('th') @@ -79,7 +79,7 @@ describe('TableTh', () => { th content - + , ) const element = document.querySelector('th') @@ -96,7 +96,7 @@ describe('TableTh', () => { th content - + , ) const element = document.querySelector('th') @@ -113,7 +113,7 @@ describe('TableTh', () => { th content - + , ) const element = document.querySelector('th') @@ -130,7 +130,7 @@ describe('TableTh', () => { th content - + , ) const element = document.querySelector('th') @@ -148,7 +148,7 @@ describe('TableTh', () => { - + , ) const element = document.querySelector('th') @@ -166,7 +166,7 @@ describe('TableTh', () => { - + , ) const element = document.querySelector('th') @@ -182,7 +182,7 @@ describe('TableTh', () => { th content - + , ) const element = document.querySelector('th') @@ -197,7 +197,7 @@ describe('TableTh', () => { th content - + , ) const element = document.querySelector('th') diff --git a/packages/dnb-eufemia/src/components/table/__tests__/TableTr.test.tsx b/packages/dnb-eufemia/src/components/table/__tests__/TableTr.test.tsx index 22876e3be32..6abe4a839fa 100644 --- a/packages/dnb-eufemia/src/components/table/__tests__/TableTr.test.tsx +++ b/packages/dnb-eufemia/src/components/table/__tests__/TableTr.test.tsx @@ -12,7 +12,7 @@ describe('TableTr', () => { - + , ) expect(document.querySelector('tr')).toBeInTheDocument() }) @@ -25,7 +25,7 @@ describe('TableTr', () => { content - + , ) const element = document.querySelector('tr') @@ -41,7 +41,7 @@ describe('TableTr', () => { content - + , ) const element = document.querySelector('tr') @@ -57,7 +57,7 @@ describe('TableTr', () => { content - + , ) const element = document.querySelector('tr') @@ -73,12 +73,12 @@ describe('TableTr', () => { content - + , ) const element = document.querySelector('tr') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['role', 'class', 'aria-label']) @@ -92,7 +92,7 @@ describe('TableTr', () => { content - + , ) const element = document.querySelector('tr') @@ -108,7 +108,7 @@ describe('TableTr', () => { content - + , ) const element = document.querySelector('tr') @@ -123,7 +123,7 @@ describe('TableTr', () => { content - + , ) const element = document.querySelector('tr') @@ -139,7 +139,7 @@ describe('TableTr', () => { content - + , ) const element = document.querySelector('tr') @@ -163,21 +163,21 @@ describe('TableTr', () => { content - + , ) const elements = document.querySelectorAll('tbody tr') expect(Array.from(elements[0].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) expect(Array.from(elements[1].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) expect(Array.from(elements[2].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) expect(Array.from(elements[3].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) }) @@ -198,21 +198,21 @@ describe('TableTr', () => { content - + , ) const elements = document.querySelectorAll('tbody tr') expect(Array.from(elements[0].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) expect(Array.from(elements[1].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) expect(Array.from(elements[2].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) expect(Array.from(elements[3].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) }) @@ -269,22 +269,22 @@ describe('TableTr', () => { content - + , ) let elements = document.querySelectorAll('tbody tr') expect(elements).toHaveLength(4) expect(Array.from(elements[0].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) expect(Array.from(elements[1].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) expect(Array.from(elements[2].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) expect(Array.from(elements[3].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) rerender( @@ -300,19 +300,19 @@ describe('TableTr', () => { content - + , ) elements = document.querySelectorAll('tbody tr') expect(elements).toHaveLength(3) expect(Array.from(elements[0].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) expect(Array.from(elements[1].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) expect(Array.from(elements[2].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) rerender( @@ -331,23 +331,23 @@ describe('TableTr', () => { content - + , ) elements = document.querySelectorAll('tbody tr') expect(elements).toHaveLength(4) // console.log('document.body', document.body.innerHTML) expect(Array.from(elements[0].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) expect(Array.from(elements[1].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) expect(Array.from(elements[2].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) expect(Array.from(elements[3].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) }) @@ -358,15 +358,15 @@ describe('TableTr', () => { expect(elements).toHaveLength(3) expect(elements[0].textContent).toBe('content cab') expect(Array.from(elements[0].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) expect(elements[1].textContent).toBe('content abc') expect(Array.from(elements[1].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) expect(elements[2].textContent).toBe('content bac') expect(Array.from(elements[2].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) fireEvent.click(screen.queryByText('re-order')) @@ -375,15 +375,15 @@ describe('TableTr', () => { expect(elements).toHaveLength(3) expect(elements[0].textContent).toBe('content abc') expect(Array.from(elements[0].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) expect(elements[1].textContent).toBe('content bac') expect(Array.from(elements[1].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) expect(elements[2].textContent).toBe('content cab') expect(Array.from(elements[2].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) }) @@ -391,22 +391,22 @@ describe('TableTr', () => { render( - + , ) let elements = document.querySelectorAll('tbody tr') expect(elements).toHaveLength(3) expect(elements[0].textContent).toBe('content cab') expect(Array.from(elements[0].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) expect(elements[1].textContent).toBe('content abc') expect(Array.from(elements[1].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) expect(elements[2].textContent).toBe('content bac') expect(Array.from(elements[2].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) fireEvent.click(screen.queryByText('re-order')) @@ -415,15 +415,15 @@ describe('TableTr', () => { expect(elements).toHaveLength(3) expect(elements[0].textContent).toBe('content abc') expect(Array.from(elements[0].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) expect(elements[1].textContent).toBe('content bac') expect(Array.from(elements[1].classList)).toContain( - 'dnb-table__tr--odd' + 'dnb-table__tr--odd', ) expect(elements[2].textContent).toBe('content cab') expect(Array.from(elements[2].classList)).toContain( - 'dnb-table__tr--even' + 'dnb-table__tr--even', ) }) }) diff --git a/packages/dnb-eufemia/src/components/table/style/table-accordion.scss b/packages/dnb-eufemia/src/components/table/style/table-accordion.scss index a23f8d7a6ec..7faf1dd0a67 100644 --- a/packages/dnb-eufemia/src/components/table/style/table-accordion.scss +++ b/packages/dnb-eufemia/src/components/table/style/table-accordion.scss @@ -135,7 +135,9 @@ &--outline tbody - &__tr--has-accordion-content:not(#{&}__tr--expanded):not(:nth-last-child(2)) + &__tr--has-accordion-content:not(#{&}__tr--expanded):not( + :nth-last-child(2) + ) &__td::before { bottom: -0.0625rem; } @@ -145,7 +147,9 @@ background-color: var(--color-white); } - &__tr--has-accordion-content#{&}__tr:not(&__tr--disabled):not(:active):not(:hover):focus { + &__tr--has-accordion-content#{&}__tr:not(&__tr--disabled):not( + :active + ):not(:hover):focus { td::before { @include whatInput(keyboard) { top: 0; @@ -175,7 +179,9 @@ @include tableAccordionActiveColor(); } - &__tr--has-accordion-content#{&}__tr--expanded:not(&__tr--disabled)#{&}__tr--hover:not(:active):hover + &__tr--has-accordion-content#{&}__tr--expanded:not( + &__tr--disabled + )#{&}__tr--hover:not(:active):hover &__td { background-color: var(--accordion-background); @@ -185,7 +191,9 @@ } } - &__tr--has-accordion-content#{&}__tr#{&}__tr--expanded:not(&__tr--disabled):not(:active):not(:hover) { + &__tr--has-accordion-content#{&}__tr#{&}__tr--expanded:not( + &__tr--disabled + ):not(:active):not(:hover) { @include whatInputNot('keyboard') { background-color: var(--accordion-background); @@ -294,7 +302,9 @@ &--outline tbody - &__tr#{&}__tr--has-accordion-content:not(#{&}__tr--expanded):nth-last-child(2) + &__tr#{&}__tr--has-accordion-content:not( + #{&}__tr--expanded + ):nth-last-child(2) &__td:first-of-type { &, &::before, @@ -305,7 +315,9 @@ &--outline tbody &__tr:last-of-type &__td:last-of-type, &--outline tbody - &__tr#{&}__tr--has-accordion-content:not(#{&}__tr--expanded):nth-last-child(2) + &__tr#{&}__tr--has-accordion-content:not( + #{&}__tr--expanded + ):nth-last-child(2) &__td:last-of-type { &, &::before, diff --git a/packages/dnb-eufemia/src/components/table/style/table-header-buttons.scss b/packages/dnb-eufemia/src/components/table/style/table-header-buttons.scss index 6b7e125d314..a03dc98437d 100644 --- a/packages/dnb-eufemia/src/components/table/style/table-header-buttons.scss +++ b/packages/dnb-eufemia/src/components/table/style/table-header-buttons.scss @@ -20,7 +20,9 @@ .dnb-table__sort-button.dnb-button { > .dnb-icon { opacity: 0; - transition: opacity 200ms ease-out, transform 500ms ease-out; + transition: + opacity 200ms ease-out, + transform 500ms ease-out; html[data-visual-test] & { transition: none; diff --git a/packages/dnb-eufemia/src/components/table/style/table-tr.scss b/packages/dnb-eufemia/src/components/table/style/table-tr.scss index 8f4b3478a47..25a8d6daaeb 100644 --- a/packages/dnb-eufemia/src/components/table/style/table-tr.scss +++ b/packages/dnb-eufemia/src/components/table/style/table-tr.scss @@ -23,7 +23,9 @@ &--outline thead &__tr:first-of-type, &--outline tbody - &__tr#{&}__tr--has-accordion-content:not(#{&}__tr--expanded):nth-last-child(2) { + &__tr#{&}__tr--has-accordion-content:not( + #{&}__tr--expanded + ):nth-last-child(2) { // use clip-path, because border-radius does not clip on tr's // use "-1rem" to add room for sticky shadow clip-path: inset(0 0 -1rem 0 round 0.5rem 0.5rem 0 0); @@ -31,7 +33,9 @@ &--outline tbody &__tr:last-of-type, &--outline tbody - &__tr#{&}__tr--has-accordion-content:not(#{&}__tr--expanded):nth-last-child(2) { + &__tr#{&}__tr--has-accordion-content:not( + #{&}__tr--expanded + ):nth-last-child(2) { // use clip-path, because border-radius does not clip on tr's clip-path: inset(0 round 0 0 0.5rem 0.5rem); } diff --git a/packages/dnb-eufemia/src/components/table/style/themes/dnb-table-theme-ui.scss b/packages/dnb-eufemia/src/components/table/style/themes/dnb-table-theme-ui.scss index c996b00c47f..ddbdbb123da 100644 --- a/packages/dnb-eufemia/src/components/table/style/themes/dnb-table-theme-ui.scss +++ b/packages/dnb-eufemia/src/components/table/style/themes/dnb-table-theme-ui.scss @@ -101,7 +101,9 @@ &:not(&--outline) > tbody > &__tr:last-of-type > &__th::after, &:not(&--outline) > tbody - > &__tr#{&}__tr--has-accordion-content:not(#{&}__tr--expanded):nth-last-child(2) + > &__tr#{&}__tr--has-accordion-content:not( + #{&}__tr--expanded + ):nth-last-child(2) td::after { @include tableBorder(); diff --git a/packages/dnb-eufemia/src/components/table/useHandleSortState.tsx b/packages/dnb-eufemia/src/components/table/useHandleSortState.tsx index 93e06e2160f..c0be55377bf 100644 --- a/packages/dnb-eufemia/src/components/table/useHandleSortState.tsx +++ b/packages/dnb-eufemia/src/components/table/useHandleSortState.tsx @@ -60,7 +60,7 @@ export function useHandleSortState( defaults: useHandleSortStateOptions = { direction: 'off', modes: ['asc', 'desc', 'off'], - } + }, ) { const initialState = React.useMemo(() => { return Object.entries(config).reduce((acc, [name, opts]) => { @@ -127,7 +127,7 @@ export function useHandleSortState( return acc }, - {} + {}, ) return { sortState, sortHandler, activeSortName } diff --git a/packages/dnb-eufemia/src/components/tabs/Tabs.js b/packages/dnb-eufemia/src/components/tabs/Tabs.js index 51885f1ab3c..d82bfa78afe 100644 --- a/packages/dnb-eufemia/src/components/tabs/Tabs.js +++ b/packages/dnb-eufemia/src/components/tabs/Tabs.js @@ -51,14 +51,14 @@ export default class Tabs extends React.PureComponent { .isRequired, selected: PropTypes.bool, disabled: PropTypes.bool, - }) + }), ), PropTypes.objectOf( PropTypes.shape({ title: PropTypes.string.isRequired, selected: PropTypes.bool, disabled: PropTypes.bool, - }) + }), ), ]), content: PropTypes.oneOfType([ @@ -157,7 +157,7 @@ export default class Tabs extends React.PureComponent { useKey = data.reduce( (acc, { selected, key }) => (selected ? key : acc), - null + null, ) || (data[0] && data[0].key) } else { @@ -299,7 +299,7 @@ export default class Tabs extends React.PureComponent { let selected_key = Tabs.getSelectedKeyOrFallback( props.selected_key, - data + data, ) // check if we have to open a different tab @@ -415,7 +415,7 @@ export default class Tabs extends React.PureComponent { if (typeof window !== 'undefined') { try { const pos = parseFloat( - window.localStorage.getItem(`tabs-pos-${this._id}`) + window.localStorage.getItem(`tabs-pos-${this._id}`), ) window.localStorage.removeItem(`tabs-pos-${this._id}`) return isNaN(pos) ? -1 : pos @@ -445,7 +445,7 @@ export default class Tabs extends React.PureComponent { try { window.localStorage.setItem( `tabs-last-${this._id}`, - this.state.selected_key + this.state.selected_key, ) // gets removed right afterwards } catch (e) { warn(e) @@ -599,15 +599,15 @@ export default class Tabs extends React.PureComponent { try { if (this.state.hasScrollbar && this._tablistRef.current) { const first = this._tablistRef.current.querySelector( - '.dnb-tabs__button__snap:first-of-type' + '.dnb-tabs__button__snap:first-of-type', ) const isFirst = first.classList.contains(type) const last = this._tablistRef.current.querySelector( - '.dnb-tabs__button__snap:last-of-type' + '.dnb-tabs__button__snap:last-of-type', ) const isLast = last.classList.contains(type) const elem = this._tablistRef.current.querySelector( - `.dnb-tabs__button.${type}` + `.dnb-tabs__button.${type}`, ) const style = window.getComputedStyle(this._tabsRef.current) @@ -617,7 +617,7 @@ export default class Tabs extends React.PureComponent { // Add the extra padding when we go from 1 to 2 tab so the nav button if (!isFirst && !isLast && parseFloat(style.paddingLeft) < 16) { const navButton = this._tabsRef.current.querySelector( - '.dnb-tabs__scroll-nav-button:first-of-type' + '.dnb-tabs__scroll-nav-button:first-of-type', ) const additionalSpace = parseFloat(window.getComputedStyle(navButton).width) * 1.5 @@ -689,7 +689,7 @@ export default class Tabs extends React.PureComponent { dispatchCustomElementEvent( this, 'on_mouse_enter', - this.getEventArgs({ event, selected_key }) + this.getEventArgs({ event, selected_key }), ) } } @@ -700,7 +700,7 @@ export default class Tabs extends React.PureComponent { const ret = dispatchCustomElementEvent( this, 'on_click', - this.getEventArgs({ event, selected_key }) + this.getEventArgs({ event, selected_key }), ) if (ret !== false) { @@ -727,7 +727,7 @@ export default class Tabs extends React.PureComponent { getCurrentTitle = (selected_key = this.state.selected_key) => { const current = this.state.data.filter( - ({ key }) => key == selected_key + ({ key }) => key == selected_key, )[0] return (current && current.title) || null } @@ -736,7 +736,7 @@ export default class Tabs extends React.PureComponent { const currentData = this.state.data.filter(({ disabled }) => !disabled) const currentIndex = currentData.reduce( (acc, { key }, i) => (key == stateKey ? i : acc), - -1 + -1, ) let nextIndex = currentIndex + useKey if (nextIndex < 0) { @@ -747,7 +747,7 @@ export default class Tabs extends React.PureComponent { } return currentData.reduce( (acc, { key }, i) => (i === nextIndex ? key : acc), - null + null, ) } @@ -762,13 +762,13 @@ export default class Tabs extends React.PureComponent { focus_key, _listenForPropChanges: false, }, - this.setFocusOnTabButton + this.setFocusOnTabButton, ) dispatchCustomElementEvent( this, 'on_focus', - this.getEventArgs({ event, focus_key }) + this.getEventArgs({ event, focus_key }), ) this.setWhatInput() @@ -785,7 +785,7 @@ export default class Tabs extends React.PureComponent { setFocusOnTabButton = () => { try { const elem = this._tablistRef.current.querySelector( - '.dnb-tabs__button.focus' + '.dnb-tabs__button.focus', ) elem.focus({ preventScroll: true }) @@ -803,7 +803,7 @@ export default class Tabs extends React.PureComponent { warnAboutMissingContainer() { warn( - `Could not find the required that provides role="tabpanel"` + `Could not find the required that provides role="tabpanel"`, ) } @@ -825,14 +825,14 @@ export default class Tabs extends React.PureComponent { focus_key: selected_key, _listenForPropChanges: false, }, - this.handleVerticalScroll + this.handleVerticalScroll, ) } dispatchCustomElementEvent( this, 'on_change', - this.getEventArgs({ event, selected_key }) + this.getEventArgs({ event, selected_key }), ) if (this.props.use_hash && typeof window !== 'undefined') { @@ -840,7 +840,7 @@ export default class Tabs extends React.PureComponent { window.history.replaceState( undefined, undefined, - `#${selected_key}` + `#${selected_key}`, ) } catch (e) { warn('Tabs Error:', e) @@ -889,7 +889,7 @@ export default class Tabs extends React.PureComponent { } return acc }, - {} + {}, ) } else if (isTrue(prevent_rerender)) { this._cache = { @@ -907,13 +907,13 @@ export default class Tabs extends React.PureComponent { aria-hidden={hide ? true : undefined} className={classnames( 'dnb-tabs__cached', - hide && 'dnb-tabs__cached--hidden' + hide && 'dnb-tabs__cached--hidden', )} > {content} ) - } + }, ) return cachedContent @@ -988,7 +988,7 @@ export default class Tabs extends React.PureComponent { 'dnb-tabs', createSpacingClasses(this.props), className, - _className + _className, ), } @@ -1021,7 +1021,7 @@ export default class Tabs extends React.PureComponent { hasScrollbar && 'dnb-tabs--has-scrollbar', nav_button_edge && 'dnb-tabs--at-edge', no_border && 'dnb-tabs__tabs--no-border', - className + className, )} ref={this._tabsRef} {...rest} @@ -1034,7 +1034,7 @@ export default class Tabs extends React.PureComponent { (typeof this.state.isFirst !== 'undefined' || this.hasLastPosition()) && 'dnb-tabs__scroll-nav-button--visible', - this.state.isFirst && 'dnb-tabs__scroll-nav-button--hide' + this.state.isFirst && 'dnb-tabs__scroll-nav-button--hide', )} /> @@ -1048,7 +1048,7 @@ export default class Tabs extends React.PureComponent { (typeof this.state.isLast !== 'undefined' || this.hasLastPosition()) && 'dnb-tabs__scroll-nav-button--visible', - this.state.isLast && 'dnb-tabs__scroll-nav-button--hide' + this.state.isLast && 'dnb-tabs__scroll-nav-button--hide', )} /> @@ -1112,7 +1112,7 @@ Tip: Check out other solutions like Your content, outs className={classnames( 'dnb-tabs__button__snap', isFocus && 'focus', - isSelected && 'selected' + isSelected && 'selected', )} key={`tab-${key}`} > @@ -1124,7 +1124,7 @@ Tip: Check out other solutions like Your content, outs className={classnames( 'dnb-tabs__button', isFocus && 'focus', - isSelected && 'selected' + isSelected && 'selected', )} onMouseEnter={this.onMouseEnterHandler} onClick={this.onClickHandler} @@ -1136,7 +1136,7 @@ Tip: Check out other solutions like Your content, outs {title} @@ -1145,7 +1145,7 @@ Tip: Check out other solutions like Your content, outs ) - } + }, ) const params = {} @@ -1155,7 +1155,7 @@ Tip: Check out other solutions like Your content, outs if (selected_key) { params['aria-labelledby'] = combineLabelledBy( params, - `${this._id}-tab-${selected_key}` + `${this._id}-tab-${selected_key}`, ) } return ( @@ -1176,7 +1176,7 @@ Tip: Check out other solutions like Your content, outs const props = (this._props = extendPropsWithContextInClassComponent( this.props, Tabs.defaultProps, - { skeleton: this.context?.skeleton } + { skeleton: this.context?.skeleton }, )) const { render: customRenderer } = props @@ -1247,7 +1247,7 @@ const ScrollNavButton = (props) => { {...props} className={classnames( 'dnb-tabs__scroll-nav-button', - props.className + props.className, )} /> ) diff --git a/packages/dnb-eufemia/src/components/tabs/TabsContentWrapper.js b/packages/dnb-eufemia/src/components/tabs/TabsContentWrapper.js index 089be3f8ab8..8f3fcc0f1de 100644 --- a/packages/dnb-eufemia/src/components/tabs/TabsContentWrapper.js +++ b/packages/dnb-eufemia/src/components/tabs/TabsContentWrapper.js @@ -79,7 +79,7 @@ export default class ContentWrapper extends React.PureComponent { if (key) { params['aria-labelledby'] = combineLabelledBy( params, - `${id}-tab-${key}` + `${id}-tab-${key}`, ) } @@ -107,7 +107,7 @@ export default class ContentWrapper extends React.PureComponent { isTrue(content_spacing) ? 'large' : content_spacing }` : null, - createSpacingClasses(rest) + createSpacingClasses(rest), )} {...params} > diff --git a/packages/dnb-eufemia/src/components/tabs/TabsCustomContent.js b/packages/dnb-eufemia/src/components/tabs/TabsCustomContent.js index 208264726bd..02a188d2b5f 100644 --- a/packages/dnb-eufemia/src/components/tabs/TabsCustomContent.js +++ b/packages/dnb-eufemia/src/components/tabs/TabsCustomContent.js @@ -65,7 +65,7 @@ export default class CustomContent extends React.PureComponent { 'dnb-tabs__content__inner', createSpacingClasses(rest), className, - _className + _className, )} > {this.props.children} diff --git a/packages/dnb-eufemia/src/components/tabs/__tests__/Tabs.test.tsx b/packages/dnb-eufemia/src/components/tabs/__tests__/Tabs.test.tsx index 662e8fa329c..e60f01e5241 100644 --- a/packages/dnb-eufemia/src/components/tabs/__tests__/Tabs.test.tsx +++ b/packages/dnb-eufemia/src/components/tabs/__tests__/Tabs.test.tsx @@ -37,14 +37,14 @@ describe('Tabs component', () => { selected_key={startup_selected_key} > {contentWrapperData} - + , ) expect( document .querySelector('.dnb-tabs__button.selected') - .querySelectorAll('span')[0].textContent + .querySelectorAll('span')[0].textContent, ).toBe( - tablistData.find(({ key }) => key === startup_selected_key).title + tablistData.find(({ key }) => key === startup_selected_key).title, ) }) @@ -71,7 +71,7 @@ describe('Tabs component', () => { on_click={on_click} > {contentWrapperData} - + , ) fireEvent.click(document.querySelectorAll('.dnb-tabs__button')[1]) @@ -95,7 +95,7 @@ describe('Tabs component', () => { render( {contentWrapperData} - + , ) fireEvent.keyDown(document.querySelector('.dnb-tabs__tabs__tablist'), { @@ -123,15 +123,15 @@ describe('Tabs component', () => { render( {contentWrapperData} - + , ) expect( document .querySelector('.dnb-tabs__tabs__tablist') - .querySelectorAll('a')[1].outerHTML + .querySelectorAll('a')[1].outerHTML, ).toMatchInlineSnapshot( - `"Second"` + `"Second"`, ) }) @@ -139,7 +139,7 @@ describe('Tabs component', () => { render( {contentWrapperData} - + , ) const element = document.querySelector('.dnb-tabs__tabs') @@ -154,7 +154,7 @@ describe('Tabs component', () => { render( {contentWrapperData} - + , ) const element = document.querySelector('.dnb-tabs__tabs') @@ -170,7 +170,7 @@ describe('Tabs component', () => { render( {contentWrapperData} - + , ) const element = document.querySelector('.dnb-tabs__content') @@ -180,7 +180,7 @@ describe('Tabs component', () => { 'dnb-tabs__content', 'dnb-height-animation--is-in-dom', 'dnb-height-animation--show-overflow', - ]) + ]), ) }) @@ -188,7 +188,7 @@ describe('Tabs component', () => { render( {contentWrapperData} - + , ) const element = document.querySelector('.dnb-tabs__tabs') @@ -204,7 +204,7 @@ describe('Tabs component', () => { render( {contentWrapperData} - + , ) const element = document.querySelector('.dnb-tabs') @@ -219,7 +219,7 @@ describe('Tabs component', () => { render( {contentWrapperData} - + , ) const element = document.querySelector('.dnb-tabs__tabs') @@ -231,7 +231,7 @@ describe('Tabs component', () => { 'dnb-tabs__tabs--left', 'dnb-section', 'dnb-section--black-3', - ]) + ]), ) }) @@ -239,7 +239,7 @@ describe('Tabs component', () => { render( {contentWrapperData} - + , ) const element = document.querySelector('.dnb-tabs__content') @@ -257,7 +257,7 @@ describe('Tabs component', () => { 'dnb-height-animation--is-in-dom', 'dnb-height-animation--parallax', 'dnb-height-animation--show-overflow', - ]) + ]), ) }) }) @@ -271,14 +271,14 @@ describe('TabList component', () => { selected_key={startup_selected_key} > {contentWrapperData} - + , ) expect( - document.querySelectorAll('.dnb-tabs__button__snap').length + document.querySelectorAll('.dnb-tabs__button__snap').length, ).toBe(tablistData.length) expect(document.querySelectorAll('div[role="tabpanel"]').length).toBe( - 1 + 1, ) }) @@ -290,13 +290,13 @@ describe('TabList component', () => { selected_key={startup_selected_key} > {contentWrapperData} - + , ) fireEvent.click(document.querySelector('button[data-tab-key="third"]')) expect( - document.querySelector('button[data-tab-key="third"]').classList + document.querySelector('button[data-tab-key="third"]').classList, ).toContain('selected') const content = document.querySelector('div[role="tabpanel"]') @@ -314,16 +314,16 @@ describe('A single Tab component', () => { selected_key={startup_selected_key} > {contentWrapperData} - + , ) expect( document .querySelector('button[data-tab-key="second"]') - .getAttribute('role') + .getAttribute('role'), ).toBe('tab') expect( - document.querySelector('button[data-tab-key="second"]').classList + document.querySelector('button[data-tab-key="second"]').classList, ).toContain('selected') }) @@ -335,12 +335,12 @@ describe('A single Tab component', () => { selected_key={startup_selected_key} > {contentWrapperData} - + , ) // reset the state fireEvent.click( - document.querySelector('button[data-tab-key="second"]') + document.querySelector('button[data-tab-key="second"]'), ) fireEvent.keyDown(document.querySelector('div[role="tablist"]'), { @@ -359,17 +359,17 @@ describe('A single Tab component', () => { expect( document .querySelectorAll('.dnb-tabs__button__snap')[0] - .querySelector('button').classList + .querySelector('button').classList, ).toContain('selected') expect( - document.querySelector('div.dnb-tabs__content').textContent + document.querySelector('div.dnb-tabs__content').textContent, ).toBe('First') // then click on tab two // also test the ability of having a integer only as the key fireEvent.click(document.querySelector('button[data-tab-key="2"]')) expect( - document.querySelector('div.dnb-tabs__content').textContent + document.querySelector('div.dnb-tabs__content').textContent, ).toBe('Second') }) @@ -388,11 +388,11 @@ describe('A single Tab component', () => { }, { title: 'Two', key: 'two', content: 'Content two' }, ]} - /> + />, ) expect( - document.querySelector('div.dnb-tabs__cached') + document.querySelector('div.dnb-tabs__cached'), ).toBeInTheDocument() // also check a real live rerender scenario @@ -408,7 +408,7 @@ describe('A single Tab component', () => { expect( document .querySelectorAll('div.dnb-tabs__cached')[0] - .getAttribute('aria-hidden') + .getAttribute('aria-hidden'), ).toBe('true') // and on tab one again @@ -417,18 +417,18 @@ describe('A single Tab component', () => { // the entered value should still be the same expect( (document.querySelector('.dnb-input__input') as HTMLInputElement) - .value + .value, ).toBe(value) expect( document .querySelectorAll('div.dnb-tabs__cached')[0] - .getAttribute('aria-hidden') + .getAttribute('aria-hidden'), ).not.toBe('true') expect( document .querySelectorAll('div.dnb-tabs__cached')[1] - .getAttribute('aria-hidden') + .getAttribute('aria-hidden'), ).toBe('true') }) @@ -445,27 +445,27 @@ describe('A single Tab component', () => { }, { title: 'Two', key: 2, content: 'Content two' }, ]} - /> + />, ) expect( - document.querySelector('div.dnb-tabs__cached') + document.querySelector('div.dnb-tabs__cached'), ).toBeInTheDocument() expect( - document.querySelectorAll('div.dnb-tabs__cached')[0] + document.querySelectorAll('div.dnb-tabs__cached')[0], ).not.toHaveAttribute('aria-hidden') expect( document .querySelectorAll('div.dnb-tabs__cached')[1] - .getAttribute('aria-hidden') + .getAttribute('aria-hidden'), ).toBe('true') expect( - document.querySelectorAll('div.dnb-tabs__cached')[0].textContent + document.querySelectorAll('div.dnb-tabs__cached')[0].textContent, ).toBe('Content one') expect( - document.querySelectorAll('div.dnb-tabs__cached')[1].textContent + document.querySelectorAll('div.dnb-tabs__cached')[1].textContent, ).toBe('Content two') }) @@ -476,25 +476,25 @@ describe('A single Tab component', () => { second - + , ) expect( document .querySelector('button.selected') - .getAttribute('data-tab-key') + .getAttribute('data-tab-key'), ).toBe('second-title') expect( document .querySelectorAll('.dnb-tabs__button__snap button')[1] - .getAttribute('data-tab-key') + .getAttribute('data-tab-key'), ).toBe('second-title') expect( - document.querySelector('div.dnb-tabs__content').textContent + document.querySelector('div.dnb-tabs__content').textContent, ).toBe('second') expect( document.querySelector( - 'button[aria-selected=true] span.dnb-tabs__button__title' - ).textContent + 'button[aria-selected=true] span.dnb-tabs__button__title', + ).textContent, ).toBe('second title') }) @@ -522,7 +522,7 @@ describe('A single Tab component', () => { expect( document .querySelector('button.selected') - .getAttribute('data-tab-key') + .getAttribute('data-tab-key'), ).toBe('first') expect(testKey).toBe('first') expect(testTitle).toBe('First') @@ -532,7 +532,7 @@ describe('A single Tab component', () => { expect( document .querySelector('button.selected') - .getAttribute('data-tab-key') + .getAttribute('data-tab-key'), ).toBe('second') expect(testKey).toBe('second') @@ -541,7 +541,7 @@ describe('A single Tab component', () => { expect( document .querySelector('button.selected') - .getAttribute('data-tab-key') + .getAttribute('data-tab-key'), ).toBe('third') expect(testKey).toBe('third') }) @@ -552,15 +552,15 @@ describe('A single Tab component', () => {
    single
    - + , ) expect( - document.querySelector('div.dnb-tabs__content__inner').textContent + document.querySelector('div.dnb-tabs__content__inner').textContent, ).toBe('single') expect( document.querySelector('button span.dnb-tabs__button__title') - .textContent + .textContent, ).toBe('single title') }) @@ -570,15 +570,15 @@ describe('A single Tab component', () => { data={[ { title: 'single title', key: 1, content:
    single
    }, ]} - /> + />, ) expect( - document.querySelector('div.dnb-tabs__content').textContent + document.querySelector('div.dnb-tabs__content').textContent, ).toBe('single') expect( document.querySelector('button span.dnb-tabs__button__title') - .textContent + .textContent, ).toBe('single title') }) @@ -605,7 +605,7 @@ describe('A single Tab component', () => { }, ]} /> - + , ) expect(document.querySelector('.dnb-tabs')).toBeInTheDocument() @@ -620,7 +620,7 @@ describe('Tabs scss', () => { it('have to match default theme snapshot', () => { const css = loadScss( - require.resolve('../style/themes/dnb-tabs-theme-ui.scss') + require.resolve('../style/themes/dnb-tabs-theme-ui.scss'), ) expect(css).toMatchSnapshot() }) @@ -635,7 +635,7 @@ describe('Tabs ARIA', () => { selected_key={startup_selected_key} > {contentWrapperData} - + , ) expect(await axeComponent(Comp)).toHaveNoViolations() }) diff --git a/packages/dnb-eufemia/src/components/tag/Tag.tsx b/packages/dnb-eufemia/src/components/tag/Tag.tsx index 65f8d9153ac..a295d53f3ee 100644 --- a/packages/dnb-eufemia/src/components/tag/Tag.tsx +++ b/packages/dnb-eufemia/src/components/tag/Tag.tsx @@ -98,7 +98,7 @@ const Tag = (localProps: TagProps & SpacingProps) => { defaultProps, context?.translation?.Tag, context?.Tag, - tagGroupContext + tagGroupContext, ) const { @@ -124,7 +124,7 @@ const Tag = (localProps: TagProps & SpacingProps) => { className, spacingClasses, isInteractive && 'dnb-tag--interactive', - isRemovable && 'dnb-tag--removable' + isRemovable && 'dnb-tag--removable', ) const buttonAttr: typeof props & Pick = props @@ -152,7 +152,7 @@ const Tag = (localProps: TagProps & SpacingProps) => { if (!tagGroupContext && !hasLabel) { warn( - `Tag group required: A Tag requires a Tag.Group with label description as a parent component. This is to ensure correct semantic and accessibility.` + `Tag group required: A Tag requires a Tag.Group with label description as a parent component. This is to ensure correct semantic and accessibility.`, ) } diff --git a/packages/dnb-eufemia/src/components/tag/__tests__/Tag.test.tsx b/packages/dnb-eufemia/src/components/tag/__tests__/Tag.test.tsx index d818ee4cf88..4988e4ebad1 100644 --- a/packages/dnb-eufemia/src/components/tag/__tests__/Tag.test.tsx +++ b/packages/dnb-eufemia/src/components/tag/__tests__/Tag.test.tsx @@ -43,7 +43,7 @@ describe('Tag Group', () => { - + , ) expect(document.querySelectorAll('.dnb-tag')).toHaveLength(4) @@ -55,10 +55,10 @@ describe('Tag Group', () => { render( ClassName - + , ) expect(document.getElementsByClassName(customClassName)).toHaveLength( - 1 + 1, ) }) @@ -68,11 +68,11 @@ describe('Tag Group', () => { render( skeleton - + , ) expect( - document.getElementsByClassName(skeletonClassName) + document.getElementsByClassName(skeletonClassName), ).toHaveLength(1) }) @@ -80,12 +80,12 @@ describe('Tag Group', () => { render( Tag - + , ) const element = document.querySelector('.dnb-tag__group') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['class']) @@ -103,7 +103,7 @@ describe('Tag', () => { render( - + , ) expect(document.querySelector('.dnb-tag')).toBeInTheDocument() }) @@ -112,7 +112,7 @@ describe('Tag', () => { render( - + , ) expect(document.querySelector('.dnb-tag')).toBeInTheDocument() @@ -124,7 +124,7 @@ describe('Tag', () => { render( - + , ) expect(screen.queryByText(text)).toBeInTheDocument() @@ -136,7 +136,7 @@ describe('Tag', () => { render( {text} - + , ) expect(screen.queryByText(text)).toBeInTheDocument() @@ -148,7 +148,7 @@ describe('Tag', () => { render( {text} - + , ) expect(screen.queryByText(text)).toBeInTheDocument() @@ -160,11 +160,11 @@ describe('Tag', () => { render( skeleton - + , ) expect( - document.getElementsByClassName(skeletonClassName) + document.getElementsByClassName(skeletonClassName), ).toHaveLength(1) }) @@ -176,11 +176,11 @@ describe('Tag', () => { skeleton - + , ) expect( - document.getElementsByClassName(skeletonClassName) + document.getElementsByClassName(skeletonClassName), ).toHaveLength(1) }) @@ -190,7 +190,7 @@ describe('Tag', () => { render( - + , ) expect(screen.queryByRole('button')).not.toBeInTheDocument() @@ -201,7 +201,7 @@ describe('Tag', () => { render( - + , ) expect(document.querySelector('.dnb-icon')).toBeInTheDocument() @@ -211,12 +211,12 @@ describe('Tag', () => { render( Tag - + , ) const element = document.querySelector('.dnb-tag') const attributes = Array.from(element.attributes).map( - (attr) => attr.name + (attr) => attr.name, ) expect(attributes).toEqual(['class']) @@ -243,11 +243,11 @@ describe('Tag', () => { > Clickable - + , ) expect( - document.getElementsByClassName(clickableClassName) + document.getElementsByClassName(clickableClassName), ).toHaveLength(1) expect(screen.queryByRole('button')).toBeInTheDocument() }) @@ -257,7 +257,7 @@ describe('Tag', () => { render( onClick - + , ) fireEvent.click(screen.getByRole('button')) @@ -268,7 +268,7 @@ describe('Tag', () => { render( - + , ) expect(document.querySelector('.dnb-icon')).toBeInTheDocument() @@ -289,14 +289,14 @@ describe('Tag', () => { > Removable - + , ) expect( - document.getElementsByClassName(removableClassName) + document.getElementsByClassName(removableClassName), ).toHaveLength(1) expect( - document.getElementsByClassName(clickableClassName) + document.getElementsByClassName(clickableClassName), ).toHaveLength(1) expect(screen.queryByRole('button')).toBeInTheDocument() }) @@ -306,7 +306,7 @@ describe('Tag', () => { render( onDelete - + , ) fireEvent.click(screen.getByRole('button')) @@ -317,21 +317,21 @@ describe('Tag', () => { const { container, rerender } = render( Tag - + , ) expect( - container.querySelectorAll('.dnb-space__top--small').length + container.querySelectorAll('.dnb-space__top--small').length, ).toBe(1) rerender( Tag - + , ) expect( - container.querySelectorAll('.dnb-space__top--small').length + container.querySelectorAll('.dnb-space__top--small').length, ).toBe(2) }) @@ -339,7 +339,7 @@ describe('Tag', () => { render( - + , ) expect(document.querySelector('.dnb-icon')).toBeInTheDocument() @@ -349,7 +349,7 @@ describe('Tag', () => { render( - + , ) expect(document.querySelector('.dnb-icon')).toBeInTheDocument() @@ -360,7 +360,7 @@ describe('Tag', () => { render( - + , ) expect(screen.getByTitle(nb.removeIconTitle)).toBeInTheDocument() @@ -375,7 +375,7 @@ describe('Tag', () => { onClick - + , ) fireEvent.click(screen.getByRole('button')) @@ -389,7 +389,7 @@ describe('Tag', () => { render( Keyboard - + , ) fireEvent.keyUp(screen.getByRole('button'), { @@ -426,10 +426,10 @@ describe('Tag', () => { render( ClassName - + , ) expect(document.getElementsByClassName(customClassName)).toHaveLength( - 1 + 1, ) }) @@ -439,7 +439,7 @@ describe('Tag', () => { - + , ) expect(document.querySelector('.dnb-button__text')).toBeInTheDocument() @@ -451,7 +451,7 @@ describe('Tag aria', () => { const Component = render( - + , ) expect(await axeComponent(Component)).toHaveNoViolations() }) diff --git a/packages/dnb-eufemia/src/components/textarea/Textarea.js b/packages/dnb-eufemia/src/components/textarea/Textarea.js index c425f22f04e..3c381d93316 100644 --- a/packages/dnb-eufemia/src/components/textarea/Textarea.js +++ b/packages/dnb-eufemia/src/components/textarea/Textarea.js @@ -340,7 +340,7 @@ export default class Textarea extends React.PureComponent { { skeleton: this.context?.skeleton }, this.context.getTranslation(this.props).Textarea, includeValidProps(this.context.FormRow), - this.context.Textarea + this.context.Textarea, ) const { @@ -411,7 +411,7 @@ export default class Textarea extends React.PureComponent { textareaParams['aria-describedby'] = combineDescribedBy( textareaParams, showStatus ? id + '-status' : null, - suffix ? id + '-suffix' : null + suffix ? id + '-suffix' : null, ) } if (readOnly) { @@ -432,14 +432,14 @@ export default class Textarea extends React.PureComponent { createSkeletonClass(null, skeleton), createSpacingClasses(props), _className, - className + className, ), } const innerParams = { className: classnames( 'dnb-textarea__inner', - createSkeletonClass('shape', skeleton, this.context) + createSkeletonClass('shape', skeleton, this.context), ), } @@ -514,7 +514,7 @@ export default class Textarea extends React.PureComponent { aria-hidden className={classnames( 'dnb-textarea__placeholder', - align ? `dnb-textarea__align--${align}` : null + align ? `dnb-textarea__align--${align}` : null, )} style={placeholderStyle} > diff --git a/packages/dnb-eufemia/src/components/textarea/__tests__/Textarea.test.tsx b/packages/dnb-eufemia/src/components/textarea/__tests__/Textarea.test.tsx index 5d9b4f6e087..801559d99a4 100644 --- a/packages/dnb-eufemia/src/components/textarea/__tests__/Textarea.test.tsx +++ b/packages/dnb-eufemia/src/components/textarea/__tests__/Textarea.test.tsx @@ -23,12 +23,12 @@ describe('Textarea component', () => { render( + , ) fireEvent.focus(document.querySelector('textarea')) expect(document.querySelector('.dnb-textarea').classList).toContain( - 'dnb-textarea--focus' + 'dnb-textarea--focus', ) }) @@ -36,10 +36,10 @@ describe('Textarea component', () => { render( + , ) expect( - document.querySelector('.dnb-textarea').classList + document.querySelector('.dnb-textarea').classList, ).not.toContain('dnb-textarea--has-content') const value = 'new value' @@ -49,7 +49,7 @@ describe('Textarea component', () => { }) expect(document.querySelector('.dnb-textarea').classList).toContain( - 'dnb-textarea--has-content' + 'dnb-textarea--has-content', ) expect(document.querySelector('textarea').value).toBe(value) }) @@ -59,7 +59,7 @@ describe('Textarea component', () => { const { rerender } = render( + , ) const initValue = 'new prop value' const emptyValue = null @@ -67,14 +67,14 @@ describe('Textarea component', () => { rerender( + , ) expect(document.querySelector('textarea').value).toBe(initValue) rerender( + , ) expect(document.querySelector('textarea').value).toBe('') }) @@ -92,7 +92,7 @@ describe('Textarea component', () => { value={initValue} on_change={on_change} on_key_down={on_key_down} // additional native event test - /> + />, ) expect(document.querySelector('textarea').value).toBe(initValue) @@ -100,7 +100,7 @@ describe('Textarea component', () => { await waitFor(() => { expect(on_change.mock.calls.length).toBe(9) expect(document.querySelector('textarea').value).toBe( - initValue + newValue + initValue + newValue, ) }) @@ -136,7 +136,7 @@ describe('Textarea component', () => { rerender( + , ) const value = 'new value' rerender( + , ) expect(document.querySelector('textarea').value).toBe(value) }) @@ -175,7 +175,7 @@ describe('Textarea component', () => { it('has to to have a status value as defined in the prop', () => { render(