Skip to content

Commit 5e6134f

Browse files
committed
Renaming files & folders was bein a PITA and things not working 🤬
So had to stub it out again with npm run new-package
1 parent fbe484f commit 5e6134f

File tree

13 files changed

+138
-123
lines changed

13 files changed

+138
-123
lines changed

‎package-lock.json‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/uui-text-copy-button/README.md‎

Lines changed: 0 additions & 32 deletions
This file was deleted.

‎packages/uui-text-copy-button/lib/index.ts‎

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# uui-text-copy
2+
3+
![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-text-copy?logoColor=%231B264F)
4+
5+
Umbraco style text-copy component.
6+
7+
## Installation
8+
9+
### ES imports
10+
11+
```zsh
12+
npm i @umbraco-ui/uui-text-copy
13+
```
14+
15+
Import the registration of `<uui-text-copy>` via:
16+
17+
```javascript
18+
import '@umbraco-ui/uui-text-copy';
19+
```
20+
21+
When looking to leverage the `UUITextCopyElement` base class as a type and/or for extension purposes, do so via:
22+
23+
```javascript
24+
import { UUITextCopyElement } from '@umbraco-ui/uui-text-copy';
25+
```
26+
27+
## Usage
28+
29+
```html
30+
<uui-text-copy></uui-text-copy>
31+
```

packages/uui-text-copy-button/lib/UUITextCopyButtonEvent.ts renamed to packages/uui-text-copy/lib/UUITextCopyEvent.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
2-
import { UUITextCopyButtonElement } from './uui-text-copy-button.element';
2+
import { UUITextCopyElement } from './uui-text-copy.element';
33

4-
interface UUITextCopyButtonEventInit extends EventInit {
4+
interface UUITextCopyEventInit extends EventInit {
55
detail?: { text: string };
66
}
77

8-
export class UUITextCopyButtonEvent extends UUIEvent<
8+
export class UUITextCopyEvent extends UUIEvent<
99
{ text: string },
10-
UUITextCopyButtonElement
10+
UUITextCopyElement
1111
> {
1212
public static readonly COPIED: string = 'copied';
1313
public static readonly COPYING: string = 'copying';
1414

15-
constructor(evName: string, eventInit: UUITextCopyButtonEventInit = {}) {
15+
constructor(evName: string, eventInit: UUITextCopyEventInit = {}) {
1616
super(evName, {
1717
...{ bubbles: true },
1818
...eventInit,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './uui-text-copy.element';
2+
export * from './UUITextCopyEvent';

packages/uui-text-copy-button/lib/uui-text-copy-button.element.ts renamed to packages/uui-text-copy/lib/uui-text-copy.element.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
21
import { css, html, LitElement } from 'lit';
32
import { property } from 'lit/decorators.js';
4-
import { UUIButtonElement } from '@umbraco-ui/uui-button/lib';
5-
import { UUITextCopyButtonEvent } from './UUITextCopyButtonEvent';
3+
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
64
import { demandCustomElement } from '@umbraco-ui/uui-base/lib/utils';
7-
import { LabelMixin } from '@umbraco-ui/uui-base/lib/mixins';
5+
import { UUIButtonElement } from '@umbraco-ui/uui-button/lib';
6+
import {
7+
LabelMixin,
8+
UUIInterfaceColor,
9+
UUIInterfaceLook,
10+
} from '@umbraco-ui/uui-base';
11+
import { UUITextCopyEvent } from './UUITextCopyEvent';
812

913
/**
1014
* @summary A button to trigger text content to be copied to the clipboard
11-
* @element uui-text-copy-button
15+
* @element uui-text-copy
1216
* @dependency uui-button
1317
* @dependency uui-icon
14-
* @fires {UUICopyEvent} copying - Fires before the content is about to copied to the clipboard and can be used to transform or modify the data before its added to the clipboard
15-
* @fires {UUICopyEvent} copied - Fires when the content is copied to the clipboard
18+
* @fires {UUITextCopyEvent} copying - Fires before the content is about to copied to the clipboard and can be used to transform or modify the data before its added to the clipboard
19+
* @fires {UUITextCopyEvent} copied - Fires when the content is copied to the clipboard
1620
* @slot - Use to replace the default content of 'Copy' and the copy icon
1721
*/
18-
@defineElement('uui-text-copy-button')
19-
export class UUITextCopyButtonElement extends LabelMixin('', LitElement) {
22+
@defineElement('uui-text-copy')
23+
export class UUITextCopyElement extends LabelMixin('', LitElement) {
2024
/**
2125
* Set a string you wish to copy to the clipboard
2226
* @type {string}
@@ -53,17 +57,16 @@ export class UUITextCopyButtonElement extends LabelMixin('', LitElement) {
5357
* @default "default"
5458
*/
5559
@property()
56-
look: 'default' | 'primary' | 'secondary' | 'outline' | 'placeholder' =
57-
'default';
60+
look: UUIInterfaceLook = 'default';
5861

5962
/**
60-
* Changes the color of the button to one of the predefined, symbolic colors.
63+
* Changes the look of the button to one of the predefined, symbolic looks. For example - set this to positive if you want nice, green "confirm" button.
6164
* @type {"default" | "positive" | "warning" | "danger"}
6265
* @attr
6366
* @default "default"
6467
*/
65-
@property()
66-
color: 'default' | 'positive' | 'warning' | 'danger' = 'default';
68+
@property({ reflect: true })
69+
color: UUIInterfaceColor = 'default';
6770

6871
/**
6972
* Makes the left and right padding of the button narrower.
@@ -120,12 +123,9 @@ export class UUITextCopyButtonElement extends LabelMixin('', LitElement) {
120123
}
121124
}
122125

123-
const beforeCopyEv = new UUITextCopyButtonEvent(
124-
UUITextCopyButtonEvent.COPYING,
125-
{
126-
detail: { text: this.#valueToCopy },
127-
},
128-
);
126+
const beforeCopyEv = new UUITextCopyEvent(UUITextCopyEvent.COPYING, {
127+
detail: { text: this.#valueToCopy },
128+
});
129129
this.dispatchEvent(beforeCopyEv);
130130

131131
if (beforeCopyEv.detail.text != null) {
@@ -136,7 +136,7 @@ export class UUITextCopyButtonElement extends LabelMixin('', LitElement) {
136136
.writeText(this.#valueToCopy)
137137
.then(() => {
138138
this.dispatchEvent(
139-
new UUITextCopyButtonEvent(UUITextCopyButtonEvent.COPIED, {
139+
new UUITextCopyEvent(UUITextCopyEvent.COPIED, {
140140
detail: { text: this.#valueToCopy },
141141
}),
142142
);
@@ -173,6 +173,6 @@ export class UUITextCopyButtonElement extends LabelMixin('', LitElement) {
173173

174174
declare global {
175175
interface HTMLElementTagNameMap {
176-
'uui-text-copy-button': UUITextCopyButtonElement;
176+
'uui-text-copy': UUITextCopyElement;
177177
}
178178
}

0 commit comments

Comments
 (0)