-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(arch): move && simplify component clipboard
- Loading branch information
Showing
69 changed files
with
335 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { writeOnClipboard } from './write-on-clipboard'; |
8 changes: 8 additions & 0 deletions
8
packages-new/common/core/src/utils/clipboard/write-on-clipboard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export function writeOnClipboard(textToWrite: string): Promise<void> { | ||
try { | ||
return navigator.clipboard.writeText(textToWrite); | ||
} catch (error) { | ||
console.error(error); | ||
return Promise.reject(error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
55 changes: 55 additions & 0 deletions
55
packages-new/components/clipboard/documentation/specifications/spec.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions
3
...ts/clipboard/specifications-clipboard.mdx → ...ecifications/specifications-clipboard.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
...es-new/components/clipboard/src/components/osds-clipboard/constants/default-attributes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { OdsClipboardAttribute } from '../interfaces/attributes'; | ||
|
||
const DEFAULT_ATTRIBUTE: OdsClipboardAttribute = Object.freeze({ | ||
disabled: false, | ||
inline: false, | ||
value: '', | ||
}); | ||
|
||
export { | ||
DEFAULT_ATTRIBUTE, | ||
}; |
11 changes: 11 additions & 0 deletions
11
packages-new/components/clipboard/src/components/osds-clipboard/core/controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { writeOnClipboard } from '@ovhcloud/ods-common-core'; | ||
|
||
class OdsClipboardController { | ||
async handlerClick(value: string): Promise<void> { | ||
await writeOnClipboard(value); | ||
} | ||
} | ||
|
||
export { | ||
OdsClipboardController, | ||
}; |
14 changes: 8 additions & 6 deletions
14
...nts/clipboard/ods-clipboard-attributes.ts → ...s/osds-clipboard/interfaces/attributes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; |
9 changes: 9 additions & 0 deletions
9
packages-new/components/clipboard/src/components/osds-clipboard/interfaces/events.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { EventEmitter } from '@stencil/core'; | ||
|
||
interface OdsClipboardEvent { | ||
odsClipboardCopied: EventEmitter<string>; | ||
} | ||
|
||
export { | ||
OdsClipboardEvent, | ||
}; |
22 changes: 9 additions & 13 deletions
22
...lipboard/osds-clipboard.e2e.screenshot.ts → ...lipboard/osds-clipboard.e2e.screenshot.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.