From e99f7000b2bc0c8cb60435b9a2cf89b5935ca55a Mon Sep 17 00:00:00 2001 From: Damien Pellier Date: Fri, 18 Aug 2023 11:12:42 +0200 Subject: [PATCH] feat(arch): move && simplify component clipboard --- .../core/src/utils/clipboard/public-api.ts | 1 + .../src/utils/clipboard/write-on-clipboard.ts | 8 ++ .../common/core/src/utils/public-api.ts | 1 + packages-new/common/stencil/package.json | 1 + .../components/clipboard/.gitignore | 0 .../components/clipboard/.npmignore | 0 .../components/clipboard/CHANGELOG.md | 0 .../components/clipboard/THIRD-PARTY-LICENCES | 0 .../documentation/specifications/spec.md | 55 +++++++++ .../specifications-clipboard-contents.mdx | 0 .../specifications-clipboard-events.mdx | 0 .../specifications-clipboard-methods.mdx | 0 .../specifications-clipboard-properties.mdx | 0 .../specifications-clipboard-tests.mdx | 0 .../specifications-clipboard.mdx | 3 +- .../components/clipboard/jest.config.ts | 5 +- .../components/clipboard/package.json | 14 ++- .../components/clipboard/react/.gitignore | 0 .../components/clipboard/react/.npmignore | 0 .../components/clipboard/react/CHANGELOG.md | 0 .../components/clipboard/react/package.json | 12 +- .../clipboard/react/tsconfig.cjs.json | 0 .../components/clipboard/react/tsconfig.json | 0 .../constants/default-attributes.ts | 11 ++ .../osds-clipboard/core/controller.ts | 11 ++ .../osds-clipboard/interfaces/attributes.ts | 14 ++- .../osds-clipboard/interfaces/events.ts | 9 ++ .../osds-clipboard.e2e.screenshot.ts | 22 ++-- .../osds-clipboard/osds-clipboard.e2e.ts | 35 +++--- .../osds-clipboard/osds-clipboard.scss | 0 .../osds-clipboard/osds-clipboard.spec.ts | 102 +++++++++++++++++ .../osds-clipboard/osds-clipboard.tsx | 33 +++--- .../components/osds-clipboard/public-api.ts | 3 + .../src/docs/osds-clipboard/usage.mdx | 2 +- .../components/clipboard/src/global.dev.ts | 2 +- .../components/clipboard/src/global.prod.ts | 0 .../components/clipboard/src/global.test.ts | 0 .../components/clipboard/src/global.ts | 2 +- .../components/clipboard/src/index.html | 4 +- .../components/clipboard/src/index.ts | 0 .../components/clipboard/stencil.config.ts | 7 +- .../components/clipboard/tsconfig.dev.json | 0 .../components/clipboard/tsconfig.json | 0 .../components/clipboard/tsconfig.prod.json | 0 .../components/clipboard/tsconfig.test.json | 0 .../components/clipboard/typedoc.json | 2 +- .../components/clipboard/vue/.gitignore | 0 .../components/clipboard/vue/.npmignore | 0 .../components/clipboard/vue/CHANGELOG.md | 0 .../components/clipboard/vue/package.json | 8 +- .../clipboard/vue/tsconfig.cjs.json | 0 .../components/clipboard/vue/tsconfig.json | 0 packages-new/components/package.json | 1 + packages-new/components/skeleton/.gitignore | 2 + .../clipboard/ods-clipboard-controller.ts | 14 --- .../ods-clipboard-default-attributes.ts | 9 -- .../clipboard/ods-clipboard-events.ts | 5 - .../clipboard/ods-clipboard-methods.ts | 5 - .../src/components/clipboard/ods-clipboard.ts | 16 --- .../src/components/clipboard/public-api.ts | 6 - .../core/src/components/public-api.ts | 1 - .../osds-clipboard/osds-clipboard.spec.ts | 108 ------------------ .../components/osds-clipboard/public-api.ts | 1 - packages/stencil/components/stencil.config.ts | 6 +- .../clipboard.specifications.stories.mdx | 2 +- .../clipboard.web-component.stories.page.mdx | 5 +- .../clipboard.web-components.stories.ts | 21 ++-- scripts/testing-report/index.html | 2 +- yarn.lock | 81 +++++++------ 69 files changed, 335 insertions(+), 317 deletions(-) create mode 100644 packages-new/common/core/src/utils/clipboard/public-api.ts create mode 100644 packages-new/common/core/src/utils/clipboard/write-on-clipboard.ts rename {packages/stencil => packages-new}/components/clipboard/.gitignore (100%) rename {packages/stencil => packages-new}/components/clipboard/.npmignore (100%) rename {packages/stencil => packages-new}/components/clipboard/CHANGELOG.md (100%) rename {packages/stencil => packages-new}/components/clipboard/THIRD-PARTY-LICENCES (100%) create mode 100644 packages-new/components/clipboard/documentation/specifications/spec.md rename {packages/specifications/components/clipboard => packages-new/components/clipboard/documentation/specifications}/specifications-clipboard-contents.mdx (100%) rename {packages/specifications/components/clipboard => packages-new/components/clipboard/documentation/specifications}/specifications-clipboard-events.mdx (100%) rename {packages/specifications/components/clipboard => packages-new/components/clipboard/documentation/specifications}/specifications-clipboard-methods.mdx (100%) rename {packages/specifications/components/clipboard => packages-new/components/clipboard/documentation/specifications}/specifications-clipboard-properties.mdx (100%) rename {packages/specifications/components/clipboard => packages-new/components/clipboard/documentation/specifications}/specifications-clipboard-tests.mdx (100%) rename {packages/specifications/components/clipboard => packages-new/components/clipboard/documentation/specifications}/specifications-clipboard.mdx (79%) rename {packages/stencil => packages-new}/components/clipboard/jest.config.ts (68%) rename {packages/stencil => packages-new}/components/clipboard/package.json (85%) rename {packages/stencil => packages-new}/components/clipboard/react/.gitignore (100%) rename {packages/stencil => packages-new}/components/clipboard/react/.npmignore (100%) rename {packages/stencil => packages-new}/components/clipboard/react/CHANGELOG.md (100%) rename {packages/stencil => packages-new}/components/clipboard/react/package.json (70%) rename {packages/stencil => packages-new}/components/clipboard/react/tsconfig.cjs.json (100%) rename {packages/stencil => packages-new}/components/clipboard/react/tsconfig.json (100%) create mode 100644 packages-new/components/clipboard/src/components/osds-clipboard/constants/default-attributes.ts create mode 100644 packages-new/components/clipboard/src/components/osds-clipboard/core/controller.ts rename packages/libraries/core/src/components/clipboard/ods-clipboard-attributes.ts => packages-new/components/clipboard/src/components/osds-clipboard/interfaces/attributes.ts (56%) create mode 100644 packages-new/components/clipboard/src/components/osds-clipboard/interfaces/events.ts rename {packages/stencil => packages-new}/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.screenshot.ts (59%) rename {packages/stencil => packages-new}/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.ts (74%) rename {packages/stencil => packages-new}/components/clipboard/src/components/osds-clipboard/osds-clipboard.scss (100%) create mode 100644 packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.spec.ts rename {packages/stencil => packages-new}/components/clipboard/src/components/osds-clipboard/osds-clipboard.tsx (61%) create mode 100644 packages-new/components/clipboard/src/components/osds-clipboard/public-api.ts rename {packages/stencil => packages-new}/components/clipboard/src/docs/osds-clipboard/usage.mdx (64%) rename {packages/stencil => packages-new}/components/clipboard/src/global.dev.ts (90%) rename {packages/stencil => packages-new}/components/clipboard/src/global.prod.ts (100%) rename {packages/stencil => packages-new}/components/clipboard/src/global.test.ts (100%) rename {packages/stencil => packages-new}/components/clipboard/src/global.ts (81%) rename {packages/stencil => packages-new}/components/clipboard/src/index.html (90%) rename {packages/stencil => packages-new}/components/clipboard/src/index.ts (100%) rename {packages/stencil => packages-new}/components/clipboard/stencil.config.ts (67%) rename {packages/stencil => packages-new}/components/clipboard/tsconfig.dev.json (100%) rename {packages/stencil => packages-new}/components/clipboard/tsconfig.json (100%) rename {packages/stencil => packages-new}/components/clipboard/tsconfig.prod.json (100%) rename {packages/stencil => packages-new}/components/clipboard/tsconfig.test.json (100%) rename {packages/stencil => packages-new}/components/clipboard/typedoc.json (72%) rename {packages/stencil => packages-new}/components/clipboard/vue/.gitignore (100%) rename {packages/stencil => packages-new}/components/clipboard/vue/.npmignore (100%) rename {packages/stencil => packages-new}/components/clipboard/vue/CHANGELOG.md (100%) rename {packages/stencil => packages-new}/components/clipboard/vue/package.json (78%) rename {packages/stencil => packages-new}/components/clipboard/vue/tsconfig.cjs.json (100%) rename {packages/stencil => packages-new}/components/clipboard/vue/tsconfig.json (100%) delete mode 100644 packages/libraries/core/src/components/clipboard/ods-clipboard-controller.ts delete mode 100644 packages/libraries/core/src/components/clipboard/ods-clipboard-default-attributes.ts delete mode 100644 packages/libraries/core/src/components/clipboard/ods-clipboard-events.ts delete mode 100644 packages/libraries/core/src/components/clipboard/ods-clipboard-methods.ts delete mode 100644 packages/libraries/core/src/components/clipboard/ods-clipboard.ts delete mode 100644 packages/libraries/core/src/components/clipboard/public-api.ts delete mode 100644 packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.spec.ts delete mode 100644 packages/stencil/components/clipboard/src/components/osds-clipboard/public-api.ts diff --git a/packages-new/common/core/src/utils/clipboard/public-api.ts b/packages-new/common/core/src/utils/clipboard/public-api.ts new file mode 100644 index 0000000000..d5b28911d4 --- /dev/null +++ b/packages-new/common/core/src/utils/clipboard/public-api.ts @@ -0,0 +1 @@ +export { writeOnClipboard } from './write-on-clipboard'; diff --git a/packages-new/common/core/src/utils/clipboard/write-on-clipboard.ts b/packages-new/common/core/src/utils/clipboard/write-on-clipboard.ts new file mode 100644 index 0000000000..834ad61c3b --- /dev/null +++ b/packages-new/common/core/src/utils/clipboard/write-on-clipboard.ts @@ -0,0 +1,8 @@ +export function writeOnClipboard(textToWrite: string): Promise { + try { + return navigator.clipboard.writeText(textToWrite); + } catch (error) { + console.error(error); + return Promise.reject(error); + } +} \ No newline at end of file diff --git a/packages-new/common/core/src/utils/public-api.ts b/packages-new/common/core/src/utils/public-api.ts index 99e8604d2e..9a28bebfee 100644 --- a/packages-new/common/core/src/utils/public-api.ts +++ b/packages-new/common/core/src/utils/public-api.ts @@ -1,4 +1,5 @@ export * from './checkbox/public-api'; +export * from './clipboard/public-api'; export * from './debounce/public-api'; export * from './enum/public-api'; export * from './loading/public-api'; diff --git a/packages-new/common/stencil/package.json b/packages-new/common/stencil/package.json index a8396b69e1..513945d6c9 100644 --- a/packages-new/common/stencil/package.json +++ b/packages-new/common/stencil/package.json @@ -16,6 +16,7 @@ "doc:api": "typedoc --plugin none src/*" }, "dependencies": { + "@ovhcloud/ods-common-core": "^15.0.1", "@ovhcloud/ods-theme-blue-jeans": "^15.0.1", "@stencil/core": "~2.18.1" }, diff --git a/packages/stencil/components/clipboard/.gitignore b/packages-new/components/clipboard/.gitignore similarity index 100% rename from packages/stencil/components/clipboard/.gitignore rename to packages-new/components/clipboard/.gitignore diff --git a/packages/stencil/components/clipboard/.npmignore b/packages-new/components/clipboard/.npmignore similarity index 100% rename from packages/stencil/components/clipboard/.npmignore rename to packages-new/components/clipboard/.npmignore diff --git a/packages/stencil/components/clipboard/CHANGELOG.md b/packages-new/components/clipboard/CHANGELOG.md similarity index 100% rename from packages/stencil/components/clipboard/CHANGELOG.md rename to packages-new/components/clipboard/CHANGELOG.md diff --git a/packages/stencil/components/clipboard/THIRD-PARTY-LICENCES b/packages-new/components/clipboard/THIRD-PARTY-LICENCES similarity index 100% rename from packages/stencil/components/clipboard/THIRD-PARTY-LICENCES rename to packages-new/components/clipboard/THIRD-PARTY-LICENCES diff --git a/packages-new/components/clipboard/documentation/specifications/spec.md b/packages-new/components/clipboard/documentation/specifications/spec.md new file mode 100644 index 0000000000..45f933374a --- /dev/null +++ b/packages-new/components/clipboard/documentation/specifications/spec.md @@ -0,0 +1,55 @@ +* [**Interfaces**](#interfaces) +* [**Classes**](#classes) +* [**Type alias**](#type-alias) +* [**Variables**](#variables) + +## Interfaces + +### OdsClipboardAttributes +|name | Type | Required | Default | Description| +|---|---|:---:|---|---| +|**`disabled`** | _boolean_ | | | Disabled the input, the focus, and the tooltip| +|**`flex`** | _boolean_ | | | Indicates if the input is full width or not: see component principles| +|**`value`** | _string_ | ✴️ | | Input text value| + +### OdsClipboardEvents +|name | Type | Required | Default | Description| +|---|---|:---:|---|---| +|**`odsClipboardCopied`** | _string_ | ✴️ | | | + +## Classes + +### OdsClipboardController +#### Methods +> **handlerClick**() => _unknown_ + + + +## Type alias + +### OdsClipboard + +interface description of all implementation of `ods-clipboard`. +each implementation must have defined events, methods, attributes +and one controller for the common behavior logic + +> - `OdsComponentGenericMethods` + +> - `OdsComponentGenericEvents` + +### OdsClipboardAttributes + +> _Based on `OdsComponentAttributes`_ + +### OdsClipboardEvents + +> _Based on `OdsComponentEvents`_ + +### OdsClipboardMethods + +> _Based on `OdsComponentMethods`_ + +## Variables + +### odsClipboardDefaultAttributes +`OdsClipboardAttributes` \ No newline at end of file diff --git a/packages/specifications/components/clipboard/specifications-clipboard-contents.mdx b/packages-new/components/clipboard/documentation/specifications/specifications-clipboard-contents.mdx similarity index 100% rename from packages/specifications/components/clipboard/specifications-clipboard-contents.mdx rename to packages-new/components/clipboard/documentation/specifications/specifications-clipboard-contents.mdx diff --git a/packages/specifications/components/clipboard/specifications-clipboard-events.mdx b/packages-new/components/clipboard/documentation/specifications/specifications-clipboard-events.mdx similarity index 100% rename from packages/specifications/components/clipboard/specifications-clipboard-events.mdx rename to packages-new/components/clipboard/documentation/specifications/specifications-clipboard-events.mdx diff --git a/packages/specifications/components/clipboard/specifications-clipboard-methods.mdx b/packages-new/components/clipboard/documentation/specifications/specifications-clipboard-methods.mdx similarity index 100% rename from packages/specifications/components/clipboard/specifications-clipboard-methods.mdx rename to packages-new/components/clipboard/documentation/specifications/specifications-clipboard-methods.mdx diff --git a/packages/specifications/components/clipboard/specifications-clipboard-properties.mdx b/packages-new/components/clipboard/documentation/specifications/specifications-clipboard-properties.mdx similarity index 100% rename from packages/specifications/components/clipboard/specifications-clipboard-properties.mdx rename to packages-new/components/clipboard/documentation/specifications/specifications-clipboard-properties.mdx diff --git a/packages/specifications/components/clipboard/specifications-clipboard-tests.mdx b/packages-new/components/clipboard/documentation/specifications/specifications-clipboard-tests.mdx similarity index 100% rename from packages/specifications/components/clipboard/specifications-clipboard-tests.mdx rename to packages-new/components/clipboard/documentation/specifications/specifications-clipboard-tests.mdx diff --git a/packages/specifications/components/clipboard/specifications-clipboard.mdx b/packages-new/components/clipboard/documentation/specifications/specifications-clipboard.mdx similarity index 79% rename from packages/specifications/components/clipboard/specifications-clipboard.mdx rename to packages-new/components/clipboard/documentation/specifications/specifications-clipboard.mdx index 2979d81158..9498d9bc51 100644 --- a/packages/specifications/components/clipboard/specifications-clipboard.mdx +++ b/packages-new/components/clipboard/documentation/specifications/specifications-clipboard.mdx @@ -1,6 +1,5 @@ import {Description} from '@storybook/addon-docs'; - -import Specs from '@ovhcloud/ods-core/src/components/clipboard/docs/spec.md'; +import Specs from './spec.md'; import SpecsClipboardContents from './specifications-clipboard-contents.mdx'; import SpecsClipboardTests from './specifications-clipboard-tests.mdx'; diff --git a/packages/stencil/components/clipboard/jest.config.ts b/packages-new/components/clipboard/jest.config.ts similarity index 68% rename from packages/stencil/components/clipboard/jest.config.ts rename to packages-new/components/clipboard/jest.config.ts index 03c8f901bd..aa2c0e1fc3 100644 --- a/packages/stencil/components/clipboard/jest.config.ts +++ b/packages-new/components/clipboard/jest.config.ts @@ -1,5 +1,5 @@ import type { Config } from '@jest/types'; -import { OdsGetJestConfig } from '@ovhcloud/ods-testing'; +import { OdsGetJestConfig } from '@ovhcloud/ods-common-testing'; const args = process.argv.slice(2); @@ -15,8 +15,9 @@ const args = process.argv.slice(2); * }; * ``` */ +// @ts-ignore until dependencies are fixed to one unique version of @jest/types const config: Config.InitialOptions = OdsGetJestConfig({ - basePath: '/../../../..', + basePath: '/../../..', args }); export default config; diff --git a/packages/stencil/components/clipboard/package.json b/packages-new/components/clipboard/package.json similarity index 85% rename from packages/stencil/components/clipboard/package.json rename to packages-new/components/clipboard/package.json index 4bb8e74eb7..60feac73ef 100644 --- a/packages/stencil/components/clipboard/package.json +++ b/packages-new/components/clipboard/package.json @@ -1,15 +1,14 @@ { - "name": "@ovhcloud/ods-stencil-clipboard", + "name": "@ovhcloud/ods-component-clipboard", "version": "15.0.1", - "private": true, - "description": "Clipboard component", + "description": "ODS Clipboard component", "author": "OVH SAS", "license": "Apache-2.0", "main": "dist/index.cjs.js", "module": "dist/index.js", "es2015": "dist/esm/index.js", "es2017": "dist/esm/index.js", - "types": "dist/types/components.d.ts", + "types": "dist/types/index.d.ts", "collection": "dist/collection/collection-manifest.json", "collection:main": "dist/collection/index.js", "scripts": { @@ -35,12 +34,15 @@ "test:e2e:ci:screenshot:update": "stencil test --config stencil.config.ts --e2e --ci --screenshot --update-screenshot --passWithNoTests" }, "dependencies": { + "@ovhcloud/ods-common-core": "^15.0.1", + "@ovhcloud/ods-common-stencil": "^15.0.1", "@ovhcloud/ods-component-icon": "^15.0.1", "@ovhcloud/ods-component-input": "^15.0.1", - "@ovhcloud/ods-stencil-component": "^15.0.1" + "@ovhcloud/ods-theming": "^15.0.1" }, "devDependencies": { - "@ovhcloud/ods-stencil-component-dev": "^15.0.1" + "@ovhcloud/ods-common-testing": "^15.0.1", + "@ovhcloud/ods-stencil-dev": "^15.0.1" }, "publishConfig": { "registry": "" diff --git a/packages/stencil/components/clipboard/react/.gitignore b/packages-new/components/clipboard/react/.gitignore similarity index 100% rename from packages/stencil/components/clipboard/react/.gitignore rename to packages-new/components/clipboard/react/.gitignore diff --git a/packages/stencil/components/clipboard/react/.npmignore b/packages-new/components/clipboard/react/.npmignore similarity index 100% rename from packages/stencil/components/clipboard/react/.npmignore rename to packages-new/components/clipboard/react/.npmignore diff --git a/packages/stencil/components/clipboard/react/CHANGELOG.md b/packages-new/components/clipboard/react/CHANGELOG.md similarity index 100% rename from packages/stencil/components/clipboard/react/CHANGELOG.md rename to packages-new/components/clipboard/react/CHANGELOG.md diff --git a/packages/stencil/components/clipboard/react/package.json b/packages-new/components/clipboard/react/package.json similarity index 70% rename from packages/stencil/components/clipboard/react/package.json rename to packages-new/components/clipboard/react/package.json index 7e9dde7bf9..847b4e8bec 100644 --- a/packages/stencil/components/clipboard/react/package.json +++ b/packages-new/components/clipboard/react/package.json @@ -1,5 +1,5 @@ { - "name": "@ovhcloud/ods-stencil-clipboard-react", + "name": "@ovhcloud/ods-component-clipboard-react", "version": "15.0.1", "private": true, "description": "React specific wrapper for ods", @@ -20,19 +20,13 @@ "dist/" ], "dependencies": { - "@ovhcloud/ods-stencil-clipboard": "^15.0.1", - "tslib": "*" + "@ovhcloud/ods-component-clipboard": "^15.0.1" }, "peerDependencies": { "react": ">=16.8.6", "react-dom": ">=16.8.6" }, "devDependencies": { - "@types/react": "17.0.37", - "@types/react-dom": "17.0.11", - "react": "16.14.0", - "react-dom": "16.14.0", - "rimraf": "^3.0.2", - "typescript": "4.7.4" + "@ovhcloud/ods-react-dev": "^15.0.1" } } diff --git a/packages/stencil/components/clipboard/react/tsconfig.cjs.json b/packages-new/components/clipboard/react/tsconfig.cjs.json similarity index 100% rename from packages/stencil/components/clipboard/react/tsconfig.cjs.json rename to packages-new/components/clipboard/react/tsconfig.cjs.json diff --git a/packages/stencil/components/clipboard/react/tsconfig.json b/packages-new/components/clipboard/react/tsconfig.json similarity index 100% rename from packages/stencil/components/clipboard/react/tsconfig.json rename to packages-new/components/clipboard/react/tsconfig.json diff --git a/packages-new/components/clipboard/src/components/osds-clipboard/constants/default-attributes.ts b/packages-new/components/clipboard/src/components/osds-clipboard/constants/default-attributes.ts new file mode 100644 index 0000000000..9d04d593b4 --- /dev/null +++ b/packages-new/components/clipboard/src/components/osds-clipboard/constants/default-attributes.ts @@ -0,0 +1,11 @@ +import type { OdsClipboardAttribute } from '../interfaces/attributes'; + +const DEFAULT_ATTRIBUTE: OdsClipboardAttribute = Object.freeze({ + disabled: false, + inline: false, + value: '', +}); + +export { + DEFAULT_ATTRIBUTE, +}; diff --git a/packages-new/components/clipboard/src/components/osds-clipboard/core/controller.ts b/packages-new/components/clipboard/src/components/osds-clipboard/core/controller.ts new file mode 100644 index 0000000000..8d1e7017a7 --- /dev/null +++ b/packages-new/components/clipboard/src/components/osds-clipboard/core/controller.ts @@ -0,0 +1,11 @@ +import { writeOnClipboard } from '@ovhcloud/ods-common-core'; + +class OdsClipboardController { + async handlerClick(value: string): Promise { + await writeOnClipboard(value); + } +} + +export { + OdsClipboardController, +}; diff --git a/packages/libraries/core/src/components/clipboard/ods-clipboard-attributes.ts b/packages-new/components/clipboard/src/components/osds-clipboard/interfaces/attributes.ts similarity index 56% rename from packages/libraries/core/src/components/clipboard/ods-clipboard-attributes.ts rename to packages-new/components/clipboard/src/components/osds-clipboard/interfaces/attributes.ts index 2b2a6a526d..adc2206010 100644 --- a/packages/libraries/core/src/components/clipboard/ods-clipboard-attributes.ts +++ b/packages-new/components/clipboard/src/components/osds-clipboard/interfaces/attributes.ts @@ -1,12 +1,14 @@ -import { OdsComponentAttributes } from '../ods-component-attributes'; +interface OdsClipboardAttribute { + /** Disabled the input, the focus, and the tooltip */ + disabled?: boolean; -export interface OdsClipboardAttributes extends OdsComponentAttributes { /** Indicates if the input is full width or not: see component principles */ - flex?: boolean; + inline?: boolean; /** Input text value */ value: string; - - /** Disabled the input, the focus, and the tooltip */ - disabled?: boolean; } + +export { + OdsClipboardAttribute, +}; diff --git a/packages-new/components/clipboard/src/components/osds-clipboard/interfaces/events.ts b/packages-new/components/clipboard/src/components/osds-clipboard/interfaces/events.ts new file mode 100644 index 0000000000..33f03f03b4 --- /dev/null +++ b/packages-new/components/clipboard/src/components/osds-clipboard/interfaces/events.ts @@ -0,0 +1,9 @@ +import type { EventEmitter } from '@stencil/core'; + +interface OdsClipboardEvent { + odsClipboardCopied: EventEmitter; +} + +export { + OdsClipboardEvent, +}; diff --git a/packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.screenshot.ts b/packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.screenshot.ts similarity index 59% rename from packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.screenshot.ts rename to packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.screenshot.ts index b657f57a25..a931cd1175 100644 --- a/packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.screenshot.ts +++ b/packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.screenshot.ts @@ -1,27 +1,23 @@ -import { E2EElement, E2EPage, newE2EPage } from '@stencil/core/testing'; -import { - OdsClipboardAttributes, - OdsComponentAttributes2StringAttributes, - odsClipboardDefaultAttributes, -} from '@ovhcloud/ods-core'; -import { OdsCreateAttributes, OdsStringAttributes2Str } from '@ovhcloud/ods-testing'; +import type { E2EPage } from '@stencil/core/testing'; +import type { OdsClipboardAttribute } from './interfaces/attributes'; +import { newE2EPage } from '@stencil/core/testing'; +import { odsComponentAttributes2StringAttributes, odsStringAttributes2Str } from '@ovhcloud/ods-common-testing'; +import { DEFAULT_ATTRIBUTE } from './constants/default-attributes'; describe('e2e:osds-clipboard', () => { + const baseAttribute = { value: '' }; let page: E2EPage; - let el: E2EElement; - async function setup({ attributes = {}, html = `` }: { attributes?: Partial, html?: string } = {}) { - const minimalAttributes: OdsClipboardAttributes = OdsCreateAttributes(attributes, odsClipboardDefaultAttributes); - const stringAttributes = OdsComponentAttributes2StringAttributes(minimalAttributes, odsClipboardDefaultAttributes); + async function setup({ attributes = {}, html = '' }: { attributes?: Partial, html?: string } = {}) { + const stringAttributes = odsComponentAttributes2StringAttributes({ ...baseAttribute, ...attributes }, DEFAULT_ATTRIBUTE); page = await newE2EPage(); await page.setContent(` - + ${html} `); await page.evaluate(() => document.body.style.setProperty('margin', '0px')); - el = await page.find('osds-clipboard'); } describe('screenshots', () => { diff --git a/packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.ts b/packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.ts similarity index 74% rename from packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.ts rename to packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.ts index a272dc1133..32bf9c094a 100644 --- a/packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.ts +++ b/packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.e2e.ts @@ -1,8 +1,11 @@ -import { E2EElement, E2EPage, newE2EPage } from '@stencil/core/testing'; -import { OdsClipboardAttributes, OdsComponentAttributes2StringAttributes, odsClipboardDefaultAttributes } from '@ovhcloud/ods-core'; -import { OdsCreateAttributes, OdsStringAttributes2Str } from '@ovhcloud/ods-testing'; +import type { E2EElement, E2EPage } from '@stencil/core/testing'; +import type { OdsClipboardAttribute } from './interfaces/attributes'; +import { newE2EPage } from '@stencil/core/testing'; +import { odsComponentAttributes2StringAttributes, odsStringAttributes2Str } from '@ovhcloud/ods-common-testing'; +import { DEFAULT_ATTRIBUTE } from './constants/default-attributes'; describe('e2e:osds-clipboard', () => { + const baseAttribute = { value: '' }; let page: E2EPage; let el: E2EElement; let input: E2EElement; @@ -11,20 +14,19 @@ describe('e2e:osds-clipboard', () => { await page.evaluate(() => { let clipboardText = ''; const clipboard = { - writeText: text => new Promise(resolve => resolve(clipboardText = text)), + writeText: (text: string) => new Promise(resolve => resolve(clipboardText = text)), readText: () => new Promise(resolve => resolve(clipboardText)), - }; + }; (window["navigator"] as any)["clipboard"] = clipboard; Object.defineProperty(navigator, 'clipboard', { value: clipboard }); }); - } + } - async function setup({ attributes }: { attributes: Partial }) { - const minimalAttributes: OdsClipboardAttributes = OdsCreateAttributes(attributes, odsClipboardDefaultAttributes); - const stringAttributes = OdsComponentAttributes2StringAttributes(minimalAttributes, odsClipboardDefaultAttributes); + async function setup({ attributes = {} }: { attributes?: Partial } = {}) { + const stringAttributes = odsComponentAttributes2StringAttributes({ ...baseAttribute, ...attributes }, DEFAULT_ATTRIBUTE); page = await newE2EPage(); - await page.setContent(``); + await page.setContent(``); const origin = await page.evaluate(() => window.origin); const browserContext = page.browserContext(); @@ -32,7 +34,7 @@ describe('e2e:osds-clipboard', () => { await page.evaluate(() => document.body.style.setProperty('margin', '0px')); await mockClipboard(page); - + el = await page.find('osds-clipboard'); input = await page.find('osds-clipboard >>> osds-input'); await page.waitForChanges(); @@ -49,7 +51,7 @@ describe('e2e:osds-clipboard', () => { it('should copy the input value', async () => { const value = 'text to copy'; - + await setup({ attributes: { value } }); await input.click(); @@ -59,9 +61,9 @@ describe('e2e:osds-clipboard', () => { it('should copy the input value with keyboard', async () => { const value = 'text to copy'; - + await setup({ attributes: { value } }); - + await page.keyboard.press('Tab'); await page.keyboard.press('Enter'); @@ -80,13 +82,12 @@ describe('e2e:osds-clipboard', () => { it('should noy copy the input value with keyboard', async () => { const value = 'text to copy'; - + await setup({ attributes: { value, disabled: true } }); - + await page.keyboard.press('Tab'); await page.keyboard.press('Enter'); expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(''); }); - }); diff --git a/packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.scss b/packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.scss similarity index 100% rename from packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.scss rename to packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.scss diff --git a/packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.spec.ts b/packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.spec.ts new file mode 100644 index 0000000000..82d50d8e11 --- /dev/null +++ b/packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.spec.ts @@ -0,0 +1,102 @@ +jest.mock('./core/controller'); // keep jest.mock before any + +import type { SpecPage } from '@stencil/core/testing'; +import type { OdsClipboardAttribute } from './interfaces/attributes'; +import { newSpecPage } from '@stencil/core/testing'; +import { odsComponentAttributes2StringAttributes, odsStringAttributes2Str, odsUnitTestAttribute } from '@ovhcloud/ods-common-testing'; +import { DEFAULT_ATTRIBUTE } from './constants/default-attributes'; +import { OdsClipboardController } from './core/controller'; +import { OsdsClipboard } from './osds-clipboard'; + +describe('spec:osds-clipboard', () => { + const baseAttribute = { value: '' }; + let page: SpecPage; + let root: HTMLElement | undefined; + let instance: OsdsClipboard; + let controller: OdsClipboardController; + let input: HTMLElement | null | undefined; + + afterEach(() => { + jest.clearAllMocks(); + }); + + async function setup({ attributes = {} }: { attributes?: Partial } = {}) { + const stringAttributes = odsComponentAttributes2StringAttributes({ ...baseAttribute, ...attributes }, DEFAULT_ATTRIBUTE); + + page = await newSpecPage({ + components: [OsdsClipboard], + html: `My Clipboard`, + }); + + root = page.root; + instance = page.rootInstance; + controller = (OdsClipboardController as unknown as jest.SpyInstance).mock.instances[0]; + input = root?.shadowRoot?.querySelector('osds-input'); + } + + it('should render', async () => { + await setup({}); + expect(root?.shadowRoot).toBeTruthy(); + expect(instance).toBeTruthy(); + }); + + describe('attributes', () => { + const config = { + instance: () => instance, + page: () => page, + root: () => page.root, + wait: () => page.waitForChanges(), + }; + + describe('inline', () => { + odsUnitTestAttribute({ + name: 'inline', + defaultValue: DEFAULT_ATTRIBUTE.inline, + newValue: false, + value: true, + setup: (value) => setup({ attributes: { ['inline']: value } }), + ...config, + }); + }); + + describe('disabled', () => { + odsUnitTestAttribute({ + name: 'disabled', + defaultValue: DEFAULT_ATTRIBUTE.disabled, + newValue: false, + value: true, + setup: (value) => setup({ attributes: { ['disabled']: value } }), + ...config, + }); + }); + + describe('value', () => { + odsUnitTestAttribute({ + name: 'value', + defaultValue: DEFAULT_ATTRIBUTE.value, + newValue: 'value', + value: 'new value', + setup: (value) => setup({ attributes: { ['value']: value } }), + ...config, + }); + }); + }); + + describe('methods', () => { + it('should call handlerClick controller', async () => { + await setup({}); + instance.handlerClick(); + input?.click(); + + expect(controller.handlerClick).toHaveBeenCalledTimes(2); + }); + + it('should not call handlerClick controller because of disabled', async () => { + await setup({ attributes: { disabled: true } }); + instance.handlerClick(); + input?.click(); + + expect(controller.handlerClick).not.toHaveBeenCalled(); + }) + }); +}); diff --git a/packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.tsx b/packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.tsx similarity index 61% rename from packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.tsx rename to packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.tsx index 5551903717..f86208e120 100644 --- a/packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.tsx +++ b/packages-new/components/clipboard/src/components/osds-clipboard/osds-clipboard.tsx @@ -1,33 +1,29 @@ -import { Component, Element, Host, h, Prop, Event, EventEmitter } from '@stencil/core'; -import { - OdsClipboard, - OdsClipboardController, - odsClipboardDefaultAttributes, - OdsClipboardEvents, - OdsClipboardMethods, -} from '@ovhcloud/ods-core'; -import { OdsStencilEvents, OdsStencilMethods } from '@ovhcloud/ods-stencil/libraries/stencil-core'; +import type { EventEmitter } from '@stencil/core'; +import type { OdsClipboardAttribute } from './interfaces/attributes'; +import type { OdsClipboardEvent } from './interfaces/events'; +import { Component, Host, h, Prop, Event } from '@stencil/core'; import { OdsThemeColorIntent } from '@ovhcloud/ods-theming'; import { ODS_ICON_NAME } from '@ovhcloud/ods-component-icon'; import { ODS_INPUT_TYPE } from '@ovhcloud/ods-component-input'; +import { DEFAULT_ATTRIBUTE } from './constants/default-attributes'; +import { OdsClipboardController } from './core/controller'; @Component({ tag: 'osds-clipboard', styleUrl: 'osds-clipboard.scss', shadow: true }) -export class OsdsClipboard implements OdsClipboard, OdsStencilEvents> { - controller: OdsClipboardController = new OdsClipboardController(this); - @Element() el!: HTMLElement; +export class OsdsClipboard implements OdsClipboardAttribute, OdsClipboardEvent { + controller: OdsClipboardController = new OdsClipboardController(); - /** @see OdsClipboardAttributes.flex */ - @Prop({ reflect: true }) public flex?: boolean = odsClipboardDefaultAttributes.flex; + /** @see OdsClipboardAttributes.inline */ + @Prop({ reflect: true }) public inline?: boolean = DEFAULT_ATTRIBUTE.inline; /** @see OdsClipboardAttributes.value */ - @Prop({ reflect: true }) public value: string = odsClipboardDefaultAttributes.value; + @Prop({ reflect: true }) public value: string = DEFAULT_ATTRIBUTE.value; /** @see OdsClipboardAttributes.disabled */ - @Prop({ reflect: true }) public disabled?: boolean = odsClipboardDefaultAttributes.disabled; + @Prop({ reflect: true }) public disabled?: boolean = DEFAULT_ATTRIBUTE.disabled; /** @see OdsClipboardEvents.odsClipboardCopied */ @Event() odsClipboardCopied!: EventEmitter; @@ -50,22 +46,19 @@ export class OsdsClipboard implements OdsClipboard - this.handlerClick() } onKeyDown={ (event: KeyboardEvent) => this.handlerKeyDown(event) } > - ); } diff --git a/packages-new/components/clipboard/src/components/osds-clipboard/public-api.ts b/packages-new/components/clipboard/src/components/osds-clipboard/public-api.ts new file mode 100644 index 0000000000..c00cbbd47c --- /dev/null +++ b/packages-new/components/clipboard/src/components/osds-clipboard/public-api.ts @@ -0,0 +1,3 @@ +export type { OdsClipboardAttribute } from './interfaces/attributes'; +export type { OdsClipboardEvent } from './interfaces/events'; +export { OsdsClipboard } from './osds-clipboard'; diff --git a/packages/stencil/components/clipboard/src/docs/osds-clipboard/usage.mdx b/packages-new/components/clipboard/src/docs/osds-clipboard/usage.mdx similarity index 64% rename from packages/stencil/components/clipboard/src/docs/osds-clipboard/usage.mdx rename to packages-new/components/clipboard/src/docs/osds-clipboard/usage.mdx index 69f14ffa38..a24f0a85d7 100644 --- a/packages/stencil/components/clipboard/src/docs/osds-clipboard/usage.mdx +++ b/packages-new/components/clipboard/src/docs/osds-clipboard/usage.mdx @@ -1,4 +1,4 @@ -import GenericStyle from '@ovhcloud/ods-core/docs/generic-style.mdx'; +import GenericStyle from '@ovhcloud/ods-common-core/docs/generic-style.mdx'; diff --git a/packages/stencil/components/clipboard/src/global.dev.ts b/packages-new/components/clipboard/src/global.dev.ts similarity index 90% rename from packages/stencil/components/clipboard/src/global.dev.ts rename to packages-new/components/clipboard/src/global.dev.ts index a8506b3d44..5d6a09feae 100644 --- a/packages/stencil/components/clipboard/src/global.dev.ts +++ b/packages-new/components/clipboard/src/global.dev.ts @@ -5,7 +5,7 @@ import './components'; import './global'; -import { OdsLogger } from '@ovhcloud/ods-core'; +import { OdsLogger } from '@ovhcloud/ods-common-core'; import '@ovhcloud/ods-component-icon'; import '@ovhcloud/ods-component-input'; diff --git a/packages/stencil/components/clipboard/src/global.prod.ts b/packages-new/components/clipboard/src/global.prod.ts similarity index 100% rename from packages/stencil/components/clipboard/src/global.prod.ts rename to packages-new/components/clipboard/src/global.prod.ts diff --git a/packages/stencil/components/clipboard/src/global.test.ts b/packages-new/components/clipboard/src/global.test.ts similarity index 100% rename from packages/stencil/components/clipboard/src/global.test.ts rename to packages-new/components/clipboard/src/global.test.ts diff --git a/packages/stencil/components/clipboard/src/global.ts b/packages-new/components/clipboard/src/global.ts similarity index 81% rename from packages/stencil/components/clipboard/src/global.ts rename to packages-new/components/clipboard/src/global.ts index 801da40aa7..ea6288ae4d 100644 --- a/packages/stencil/components/clipboard/src/global.ts +++ b/packages-new/components/clipboard/src/global.ts @@ -3,7 +3,7 @@ // it allows to initialize some stuff of the library, after the component itself // ### -import { OdsLogger } from '@ovhcloud/ods-core'; +import { OdsLogger } from '@ovhcloud/ods-common-core'; const logger = new OdsLogger('clipboard.global'); logger.log('init'); diff --git a/packages/stencil/components/clipboard/src/index.html b/packages-new/components/clipboard/src/index.html similarity index 90% rename from packages/stencil/components/clipboard/src/index.html rename to packages-new/components/clipboard/src/index.html index 1cfc9f6f29..a7411b527b 100644 --- a/packages/stencil/components/clipboard/src/index.html +++ b/packages-new/components/clipboard/src/index.html @@ -18,8 +18,8 @@

Clipboard

Clipboard -

Clipboard flex

-Clipboard +

Clipboard inline

+Clipboard

Clipboard disabled

Clipboard diff --git a/packages/stencil/components/clipboard/src/index.ts b/packages-new/components/clipboard/src/index.ts similarity index 100% rename from packages/stencil/components/clipboard/src/index.ts rename to packages-new/components/clipboard/src/index.ts diff --git a/packages/stencil/components/clipboard/stencil.config.ts b/packages-new/components/clipboard/stencil.config.ts similarity index 67% rename from packages/stencil/components/clipboard/stencil.config.ts rename to packages-new/components/clipboard/stencil.config.ts index 5914b90445..e86a6f17b6 100644 --- a/packages/stencil/components/clipboard/stencil.config.ts +++ b/packages-new/components/clipboard/stencil.config.ts @@ -1,5 +1,5 @@ import { Config } from '@stencil/core'; -import { getStencilConfig } from '@ovhcloud/ods-stencil/libraries/stencil-core'; +import { getStencilConfig } from '@ovhcloud/ods-common-stencil'; import * as jestConfig from './jest.config'; const args = process.argv.slice(2); @@ -9,12 +9,11 @@ export const config: Config = getStencilConfig({ args, jestConfig: jestConfig.default, reactOutput: { - componentCorePackage: '@ovhcloud/ods-stencil/components/clipboard', - // exclude peer dependencies that corresponds to www usage + componentCorePackage: '@ovhcloud/ods-component-clipboard', excludeComponents: ['osds-input', 'osds-icon', 'osds-spinner'] }, vueOutput: { - componentCorePackage: '@ovhcloud/ods-stencil/components/clipboard', + componentCorePackage: '@ovhcloud/ods-component-clipboard', excludeComponents: ['osds-input', 'osds-icon', 'osds-spinner'] }, dev: { diff --git a/packages/stencil/components/clipboard/tsconfig.dev.json b/packages-new/components/clipboard/tsconfig.dev.json similarity index 100% rename from packages/stencil/components/clipboard/tsconfig.dev.json rename to packages-new/components/clipboard/tsconfig.dev.json diff --git a/packages/stencil/components/clipboard/tsconfig.json b/packages-new/components/clipboard/tsconfig.json similarity index 100% rename from packages/stencil/components/clipboard/tsconfig.json rename to packages-new/components/clipboard/tsconfig.json diff --git a/packages/stencil/components/clipboard/tsconfig.prod.json b/packages-new/components/clipboard/tsconfig.prod.json similarity index 100% rename from packages/stencil/components/clipboard/tsconfig.prod.json rename to packages-new/components/clipboard/tsconfig.prod.json diff --git a/packages/stencil/components/clipboard/tsconfig.test.json b/packages-new/components/clipboard/tsconfig.test.json similarity index 100% rename from packages/stencil/components/clipboard/tsconfig.test.json rename to packages-new/components/clipboard/tsconfig.test.json diff --git a/packages/stencil/components/clipboard/typedoc.json b/packages-new/components/clipboard/typedoc.json similarity index 72% rename from packages/stencil/components/clipboard/typedoc.json rename to packages-new/components/clipboard/typedoc.json index eadb408fed..937f440420 100644 --- a/packages/stencil/components/clipboard/typedoc.json +++ b/packages-new/components/clipboard/typedoc.json @@ -1,6 +1,6 @@ { "entryPoints": ["src"], - "out": "docs-api/stencil-components-clipboard", + "out": "docs-api/ods-component-clipboard", "tsconfig":"tsconfig.prod.json", "exclude": "**/*+(index|.spec|.e2e|.d).ts", "plugin": "none" diff --git a/packages/stencil/components/clipboard/vue/.gitignore b/packages-new/components/clipboard/vue/.gitignore similarity index 100% rename from packages/stencil/components/clipboard/vue/.gitignore rename to packages-new/components/clipboard/vue/.gitignore diff --git a/packages/stencil/components/clipboard/vue/.npmignore b/packages-new/components/clipboard/vue/.npmignore similarity index 100% rename from packages/stencil/components/clipboard/vue/.npmignore rename to packages-new/components/clipboard/vue/.npmignore diff --git a/packages/stencil/components/clipboard/vue/CHANGELOG.md b/packages-new/components/clipboard/vue/CHANGELOG.md similarity index 100% rename from packages/stencil/components/clipboard/vue/CHANGELOG.md rename to packages-new/components/clipboard/vue/CHANGELOG.md diff --git a/packages/stencil/components/clipboard/vue/package.json b/packages-new/components/clipboard/vue/package.json similarity index 78% rename from packages/stencil/components/clipboard/vue/package.json rename to packages-new/components/clipboard/vue/package.json index 816016eb59..6799493ee6 100644 --- a/packages/stencil/components/clipboard/vue/package.json +++ b/packages-new/components/clipboard/vue/package.json @@ -1,5 +1,5 @@ { - "name": "@ovhcloud/ods-stencil-clipboard-vue", + "name": "@ovhcloud/ods-component-clipboard-vue", "version": "15.0.1", "private": true, "description": "Vue specific wrapper for ods", @@ -20,14 +20,12 @@ "dist/" ], "dependencies": { - "@ovhcloud/ods-stencil-clipboard": "^15.0.1" + "@ovhcloud/ods-component-clipboard": "^15.0.1" }, "peerDependencies": { "vue": ">=3" }, "devDependencies": { - "rimraf": "^3.0.2", - "typescript": "4.7.4", - "vue": "^3.2.41" + "@ovhcloud/ods-vue-dev": "^15.0.1" } } diff --git a/packages/stencil/components/clipboard/vue/tsconfig.cjs.json b/packages-new/components/clipboard/vue/tsconfig.cjs.json similarity index 100% rename from packages/stencil/components/clipboard/vue/tsconfig.cjs.json rename to packages-new/components/clipboard/vue/tsconfig.cjs.json diff --git a/packages/stencil/components/clipboard/vue/tsconfig.json b/packages-new/components/clipboard/vue/tsconfig.json similarity index 100% rename from packages/stencil/components/clipboard/vue/tsconfig.json rename to packages-new/components/clipboard/vue/tsconfig.json diff --git a/packages-new/components/package.json b/packages-new/components/package.json index d6c58357ee..ef0bc32a35 100644 --- a/packages-new/components/package.json +++ b/packages-new/components/package.json @@ -11,6 +11,7 @@ "@ovhcloud/ods-component-checkbox": "^15.0.1", "@ovhcloud/ods-component-checkbox-button": "^15.0.1", "@ovhcloud/ods-component-chip": "^15.0.1", + "@ovhcloud/ods-component-clipboard": "^15.0.1", "@ovhcloud/ods-component-collapsible": "^15.0.1", "@ovhcloud/ods-component-content-addon": "^15.0.1", "@ovhcloud/ods-component-icon": "^15.0.1", diff --git a/packages-new/components/skeleton/.gitignore b/packages-new/components/skeleton/.gitignore index 9ca4e2da31..d9e1d2628b 100644 --- a/packages-new/components/skeleton/.gitignore +++ b/packages-new/components/skeleton/.gitignore @@ -1,4 +1,6 @@ dist/ +custom-elements/ +custom-elements-bundle/ www/ loader/ docs-api diff --git a/packages/libraries/core/src/components/clipboard/ods-clipboard-controller.ts b/packages/libraries/core/src/components/clipboard/ods-clipboard-controller.ts deleted file mode 100644 index e494bc5596..0000000000 --- a/packages/libraries/core/src/components/clipboard/ods-clipboard-controller.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { OdsClipboard } from './ods-clipboard'; -import { OdsComponentController } from '../ods-component-controller'; -import { writeOnClipboard } from '../../utils/clipboard/write-on-clipboard'; - -export class OdsClipboardController extends OdsComponentController { - - constructor(component: OdsClipboard) { - super(component); - } - - async handlerClick(value: string): Promise { - await writeOnClipboard(value); - } -} diff --git a/packages/libraries/core/src/components/clipboard/ods-clipboard-default-attributes.ts b/packages/libraries/core/src/components/clipboard/ods-clipboard-default-attributes.ts deleted file mode 100644 index 685b78d93d..0000000000 --- a/packages/libraries/core/src/components/clipboard/ods-clipboard-default-attributes.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { OdsClipboardAttributes } from './ods-clipboard-attributes'; - -export const odsClipboardDefaultAttributesDoc = { - flex: false, - value: '', - disabled: false, -} as const; - -export const odsClipboardDefaultAttributes = odsClipboardDefaultAttributesDoc as OdsClipboardAttributes; diff --git a/packages/libraries/core/src/components/clipboard/ods-clipboard-events.ts b/packages/libraries/core/src/components/clipboard/ods-clipboard-events.ts deleted file mode 100644 index 7efeb28f7c..0000000000 --- a/packages/libraries/core/src/components/clipboard/ods-clipboard-events.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { OdsComponentEvents } from '../ods-component-events'; - -export interface OdsClipboardEvents extends OdsComponentEvents { - odsClipboardCopied: string; -} diff --git a/packages/libraries/core/src/components/clipboard/ods-clipboard-methods.ts b/packages/libraries/core/src/components/clipboard/ods-clipboard-methods.ts deleted file mode 100644 index c61778fc36..0000000000 --- a/packages/libraries/core/src/components/clipboard/ods-clipboard-methods.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { OdsComponentMethods } from '../ods-component-methods'; - -export interface OdsClipboardMethods extends OdsComponentMethods { - // Methods -} diff --git a/packages/libraries/core/src/components/clipboard/ods-clipboard.ts b/packages/libraries/core/src/components/clipboard/ods-clipboard.ts deleted file mode 100644 index f6f93de5ca..0000000000 --- a/packages/libraries/core/src/components/clipboard/ods-clipboard.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { OdsClipboardAttributes } from './ods-clipboard-attributes'; -import { OdsClipboardController } from './ods-clipboard-controller'; -import { OdsClipboardEvents } from './ods-clipboard-events'; -import { OdsClipboardMethods } from './ods-clipboard-methods'; -import { OdsComponent } from '../ods-component'; -import { OdsComponentGenericEvents } from '../ods-component-generic-events'; -import { OdsComponentGenericMethods } from '../ods-component-generic-methods'; - -/** - * interface description of all implementation of `ods-clipboard`. - * each implementation must have defined events, methods, attributes - * and one controller for the common behavior logic - */ -export type OdsClipboard = OdsComponentGenericMethods, - ComponentEvents extends OdsComponentGenericEvents = OdsComponentGenericEvents> = - OdsComponent; diff --git a/packages/libraries/core/src/components/clipboard/public-api.ts b/packages/libraries/core/src/components/clipboard/public-api.ts deleted file mode 100644 index f35d9d9d3e..0000000000 --- a/packages/libraries/core/src/components/clipboard/public-api.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './ods-clipboard'; -export * from './ods-clipboard-attributes'; -export * from './ods-clipboard-controller'; -export * from './ods-clipboard-default-attributes'; -export * from './ods-clipboard-events'; -export * from './ods-clipboard-methods'; diff --git a/packages/libraries/core/src/components/public-api.ts b/packages/libraries/core/src/components/public-api.ts index 12a0dad74b..0073ab94f0 100644 --- a/packages/libraries/core/src/components/public-api.ts +++ b/packages/libraries/core/src/components/public-api.ts @@ -1,6 +1,5 @@ export * from './accordion/public-api'; export * from './accordion-group/public-api'; -export * from './clipboard/public-api'; export * from './code/public-api'; export * from './form-field/public-api'; export * from './location-tile/public-api'; diff --git a/packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.spec.ts b/packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.spec.ts deleted file mode 100644 index ba452fd973..0000000000 --- a/packages/stencil/components/clipboard/src/components/osds-clipboard/osds-clipboard.spec.ts +++ /dev/null @@ -1,108 +0,0 @@ -jest.mock('@ovhcloud/ods-core/src/components/clipboard/ods-clipboard-controller'); // keep jest.mock before any - -import { - OdsClipboardAttributes, - OdsClipboardController, - OdsComponentAttributes2StringAttributes, - odsClipboardDefaultAttributes, -} from '@ovhcloud/ods-core'; -import { - OdsCreateAttributes, - OdsStringAttributes2Str, - odsUnitTestAttribute -} from '@ovhcloud/ods-testing'; -import { SpecPage, newSpecPage } from '@stencil/core/testing'; -import { OsdsClipboard } from './osds-clipboard'; -import { getAttributeContextOptions } from '@ovhcloud/ods-stencil/libraries/stencil-testing'; - -describe('spec:osds-clipboard', () => { - let page: SpecPage; - let root: HTMLElement | undefined; - let instance: OsdsClipboard; - let controller: OdsClipboardController; - let input: HTMLElement; - - afterEach(() => { - jest.clearAllMocks(); - }); - - async function setup({ attributes = {} }: { attributes?: Partial } = {}) { - const minimalAttributes: OdsClipboardAttributes = OdsCreateAttributes(attributes, odsClipboardDefaultAttributes); - const stringAttributes = OdsComponentAttributes2StringAttributes(minimalAttributes, odsClipboardDefaultAttributes); - - page = await newSpecPage({ - components: [OsdsClipboard], - html: `My Clipboard`, - }); - - root = page.root; - instance = page.rootInstance; - controller = (OdsClipboardController as unknown as jest.SpyInstance).mock.instances[0]; - input = root.shadowRoot.querySelector('osds-input'); - } - - it('should render', async () => { - await setup({}); - expect(root?.shadowRoot).toBeTruthy(); - expect(instance).toBeTruthy(); - }); - - describe('attributes', () => { - const config = { - page: () => page, - instance: () => instance, - setup - }; - - describe('flex', () => { - odsUnitTestAttribute({ - ...getAttributeContextOptions({ - name: 'flex', - list: [true, false], - defaultValue: odsClipboardDefaultAttributes.flex, - ...config - }) - }); - }); - - describe('disabled', () => { - odsUnitTestAttribute({ - ...getAttributeContextOptions({ - name: 'disabled', - list: [true, false], - defaultValue: odsClipboardDefaultAttributes.disabled, - ...config - }) - }); - }); - - describe('value', () => { - odsUnitTestAttribute({ - ...getAttributeContextOptions({ - name: 'value', - list: ['', 'new value'], - defaultValue: odsClipboardDefaultAttributes.value, - ...config - }) - }); - }); - }); - - describe('methods', () => { - it('should call handlerClick controller', async () => { - await setup({}); - instance.handlerClick(); - input.click(); - - expect(controller.handlerClick).toHaveBeenCalledTimes(2); - }); - - it('should not call handlerClick controller because of disabled', async () => { - await setup({ attributes: { disabled: true } }); - instance.handlerClick(); - input.click(); - - expect(controller.handlerClick).not.toHaveBeenCalled(); - }) - }); -}); diff --git a/packages/stencil/components/clipboard/src/components/osds-clipboard/public-api.ts b/packages/stencil/components/clipboard/src/components/osds-clipboard/public-api.ts deleted file mode 100644 index 48fd6e0b12..0000000000 --- a/packages/stencil/components/clipboard/src/components/osds-clipboard/public-api.ts +++ /dev/null @@ -1 +0,0 @@ -export { OsdsClipboard } from './osds-clipboard' diff --git a/packages/stencil/components/stencil.config.ts b/packages/stencil/components/stencil.config.ts index 96aeadc792..b874f06d39 100644 --- a/packages/stencil/components/stencil.config.ts +++ b/packages/stencil/components/stencil.config.ts @@ -38,8 +38,9 @@ const config: Config = { 'osds-button', 'osds-cart', 'osds-checkbox', - 'osds-chip', 'osds-checkbox-button', + 'osds-chip', + 'osds-clipboard', 'osds-collapsible', 'osds-content-addon', 'osds-divider', @@ -65,9 +66,10 @@ const config: Config = { 'osds-button', 'osds-cart', 'osds-checkbox', + 'osds-checkbox-button', 'osds-chip', + 'osds-clipboard', 'osds-collapsible', - 'osds-checkbox-button', 'osds-content-addon', 'osds-divider', 'osds-flag', diff --git a/packages/tools/storybook/stories/components/clipboard/clipboard.specifications.stories.mdx b/packages/tools/storybook/stories/components/clipboard/clipboard.specifications.stories.mdx index 43d374723c..7c558396af 100644 --- a/packages/tools/storybook/stories/components/clipboard/clipboard.specifications.stories.mdx +++ b/packages/tools/storybook/stories/components/clipboard/clipboard.specifications.stories.mdx @@ -1,5 +1,5 @@ import { Meta } from '@storybook/addon-docs'; -import SpecificationsClipboard from '@ovhcloud/ods-specifications/components/clipboard/specifications-clipboard.mdx'; +import SpecificationsClipboard from '@ovhcloud/ods-component-clipboard/documentation/specifications/specifications-clipboard.mdx'; import Notes from '../notes.mdx'; diff --git a/packages/tools/storybook/stories/components/clipboard/clipboard.web-component.stories.page.mdx b/packages/tools/storybook/stories/components/clipboard/clipboard.web-component.stories.page.mdx index eaca2bf3bf..961d563b18 100644 --- a/packages/tools/storybook/stories/components/clipboard/clipboard.web-component.stories.page.mdx +++ b/packages/tools/storybook/stories/components/clipboard/clipboard.web-component.stories.page.mdx @@ -1,7 +1,6 @@ import { Canvas, Description, Meta, DocsContainer } from '@storybook/addon-docs'; - -import Usage from '@ovhcloud/ods-stencil-clipboard/src/docs/osds-clipboard/usage.mdx'; -import APITable from '@ovhcloud/ods-stencil-clipboard/dist/docs/components/osds-clipboard/readme.md'; +import APITable from '@ovhcloud/ods-component-clipboard/dist/docs/components/osds-clipboard/readme.md'; +import Usage from '@ovhcloud/ods-component-clipboard/src/docs/osds-clipboard/usage.mdx'; diff --git a/packages/tools/storybook/stories/components/clipboard/clipboard.web-components.stories.ts b/packages/tools/storybook/stories/components/clipboard/clipboard.web-components.stories.ts index c0a44b6ee2..1bfd49ec8b 100644 --- a/packages/tools/storybook/stories/components/clipboard/clipboard.web-components.stories.ts +++ b/packages/tools/storybook/stories/components/clipboard/clipboard.web-components.stories.ts @@ -1,25 +1,20 @@ import { html } from 'lit-html'; -import { iframe } from '../../../.storybook/iframe'; - -import { defineCustomElements } from '@ovhcloud/ods-stencil-clipboard/loader'; -import { - extractArgTypes, - extractStoryParams, - getTagAttributes, -} from '../../../core/componentHTMLUtils'; - -import changelog from '@ovhcloud/ods-stencil-clipboard/CHANGELOG.md'; +import { defineCustomElements } from '@ovhcloud/ods-component-clipboard/loader'; +import { extractArgTypes, extractStoryParams, getTagAttributes } from '../../../core/componentHTMLUtils'; +// @ts-ignore +import changelog from '@ovhcloud/ods-component-clipboard/CHANGELOG.md'; +// @ts-ignore import page from './clipboard.web-component.stories.page.mdx'; defineCustomElements(); /* Default story parameters */ const storyParams = { - flex: { + disabled: { category: 'General', defaultValue: false, }, - disabled: { + inline: { category: 'General', defaultValue: false, }, @@ -33,7 +28,6 @@ export default { title: 'UI Components/Clipboard [atom]/Web Component', parameters: { notes: { - API: iframe('/stencil-clipboard/modules/index.html'), changelog, }, docs: { page } @@ -50,6 +44,7 @@ const TemplateDefault = (args:any) => { `; } export const Default = TemplateDefault.bind({}); +// @ts-ignore Default.args = { ...extractStoryParams(storyParams), }; diff --git a/scripts/testing-report/index.html b/scripts/testing-report/index.html index 716a7d9a93..b3816efaf8 100644 --- a/scripts/testing-report/index.html +++ b/scripts/testing-report/index.html @@ -104,7 +104,7 @@ {name: 'osds-checkbox', id: 'checkbox', newArch: true}, {name: 'osds-checkbox-button', id: 'checkbox-button', newArch: true}, {name: 'osds-chip', id: 'chip', newArch: true}, - {name: 'osds-clipboard', id: 'clipboard'}, + {name: 'osds-clipboard', id: 'clipboard', newArch: true}, {name: 'osds-code', id: 'code'}, {name: 'osds-collapsible', id: 'collapsible', newArch: true}, {name: 'osds-content-addon', id: 'content-addon', newArch: true}, diff --git a/yarn.lock b/yarn.lock index 7b27a88a5d..e8e7f12f81 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5439,6 +5439,7 @@ __metadata: version: 0.0.0-use.local resolution: "@ovhcloud/ods-common-stencil@workspace:packages-new/common/stencil" dependencies: + "@ovhcloud/ods-common-core": ^15.0.1 "@ovhcloud/ods-common-testing": ^15.0.1 "@ovhcloud/ods-dev": ^15.0.1 "@ovhcloud/ods-theme-blue-jeans": ^15.0.1 @@ -5677,6 +5678,43 @@ __metadata: languageName: unknown linkType: soft +"@ovhcloud/ods-component-clipboard-react@workspace:packages-new/components/clipboard/react": + version: 0.0.0-use.local + resolution: "@ovhcloud/ods-component-clipboard-react@workspace:packages-new/components/clipboard/react" + dependencies: + "@ovhcloud/ods-component-clipboard": ^15.0.1 + "@ovhcloud/ods-react-dev": ^15.0.1 + peerDependencies: + react: ">=16.8.6" + react-dom: ">=16.8.6" + languageName: unknown + linkType: soft + +"@ovhcloud/ods-component-clipboard-vue@workspace:packages-new/components/clipboard/vue": + version: 0.0.0-use.local + resolution: "@ovhcloud/ods-component-clipboard-vue@workspace:packages-new/components/clipboard/vue" + dependencies: + "@ovhcloud/ods-component-clipboard": ^15.0.1 + "@ovhcloud/ods-vue-dev": ^15.0.1 + peerDependencies: + vue: ">=3" + languageName: unknown + linkType: soft + +"@ovhcloud/ods-component-clipboard@^15.0.1, @ovhcloud/ods-component-clipboard@workspace:packages-new/components/clipboard": + version: 0.0.0-use.local + resolution: "@ovhcloud/ods-component-clipboard@workspace:packages-new/components/clipboard" + dependencies: + "@ovhcloud/ods-common-core": ^15.0.1 + "@ovhcloud/ods-common-stencil": ^15.0.1 + "@ovhcloud/ods-common-testing": ^15.0.1 + "@ovhcloud/ods-component-icon": ^15.0.1 + "@ovhcloud/ods-component-input": ^15.0.1 + "@ovhcloud/ods-stencil-dev": ^15.0.1 + "@ovhcloud/ods-theming": ^15.0.1 + languageName: unknown + linkType: soft + "@ovhcloud/ods-component-collapsible-react@workspace:packages-new/components/collapsible/react": version: 0.0.0-use.local resolution: "@ovhcloud/ods-component-collapsible-react@workspace:packages-new/components/collapsible/react" @@ -6311,6 +6349,7 @@ __metadata: "@ovhcloud/ods-component-checkbox": ^15.0.1 "@ovhcloud/ods-component-checkbox-button": ^15.0.1 "@ovhcloud/ods-component-chip": ^15.0.1 + "@ovhcloud/ods-component-clipboard": ^15.0.1 "@ovhcloud/ods-component-collapsible": ^15.0.1 "@ovhcloud/ods-component-content-addon": ^15.0.1 "@ovhcloud/ods-component-icon": ^15.0.1 @@ -6516,48 +6555,6 @@ __metadata: languageName: unknown linkType: soft -"@ovhcloud/ods-stencil-clipboard-react@workspace:packages/stencil/components/clipboard/react": - version: 0.0.0-use.local - resolution: "@ovhcloud/ods-stencil-clipboard-react@workspace:packages/stencil/components/clipboard/react" - dependencies: - "@ovhcloud/ods-stencil-clipboard": ^15.0.1 - "@types/react": 17.0.37 - "@types/react-dom": 17.0.11 - react: 16.14.0 - react-dom: 16.14.0 - rimraf: ^3.0.2 - tslib: "*" - typescript: 4.7.4 - peerDependencies: - react: ">=16.8.6" - react-dom: ">=16.8.6" - languageName: unknown - linkType: soft - -"@ovhcloud/ods-stencil-clipboard-vue@workspace:packages/stencil/components/clipboard/vue": - version: 0.0.0-use.local - resolution: "@ovhcloud/ods-stencil-clipboard-vue@workspace:packages/stencil/components/clipboard/vue" - dependencies: - "@ovhcloud/ods-stencil-clipboard": ^15.0.1 - rimraf: ^3.0.2 - typescript: 4.7.4 - vue: ^3.2.41 - peerDependencies: - vue: ">=3" - languageName: unknown - linkType: soft - -"@ovhcloud/ods-stencil-clipboard@^15.0.1, @ovhcloud/ods-stencil-clipboard@workspace:packages/stencil/components/clipboard": - version: 0.0.0-use.local - resolution: "@ovhcloud/ods-stencil-clipboard@workspace:packages/stencil/components/clipboard" - dependencies: - "@ovhcloud/ods-component-icon": ^15.0.1 - "@ovhcloud/ods-component-input": ^15.0.1 - "@ovhcloud/ods-stencil-component": ^15.0.1 - "@ovhcloud/ods-stencil-component-dev": ^15.0.1 - languageName: unknown - linkType: soft - "@ovhcloud/ods-stencil-code-react@workspace:packages/stencil/components/code/react": version: 0.0.0-use.local resolution: "@ovhcloud/ods-stencil-code-react@workspace:packages/stencil/components/code/react"