@c2n/copy-button 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { LitElement, html, nothing, unsafeCSS } from "lit";
2
- import { customElement, property, state } from "lit/decorators.js";
2
+ import { property, state } from "lit/decorators.js";
3
+ import { customElement } from "@c2n/core/element-helper.js";
3
4
  import { classMap } from "lit/directives/class-map.js";
4
5
  //#region src/copy-button.scss?inline
5
6
  var copy_button_default = "/* ex : var((width: 24px), width, c2-checkbox) returns var(--c2-checkbox-width, 24px) */\n:host {\n display: inline-flex;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n:host([pin]) {\n position: absolute;\n top: var(--c2-copy-button__pin--offset-y,6px);\n right: var(--c2-copy-button__pin--offset-x,6px);\n transform: translate(var(--_c2-copy-button-scroll-x, 0px), var(--_c2-copy-button-scroll-y, 0px));\n}\n\n:host([pin=top-left]) {\n right: auto;\n left: var(--c2-copy-button__pin--offset-x,6px);\n}\n\n:host([pin=bottom-right]) {\n top: auto;\n bottom: var(--c2-copy-button__pin--offset-y,6px);\n}\n\n:host([pin=bottom-left]) {\n top: auto;\n bottom: var(--c2-copy-button__pin--offset-y,6px);\n right: auto;\n left: var(--c2-copy-button__pin--offset-x,6px);\n}\n\n:host([disabled]) {\n pointer-events: none;\n opacity: var(--c2-copy-button__container__disabled--opacity,0.38);\n}\n\n.c2-copy-button {\n appearance: none;\n box-sizing: border-box;\n margin: 0;\n font: inherit;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--c2-copy-button__container--gap,6px);\n height: var(--c2-copy-button__container--height,28px);\n min-width: var(--c2-copy-button__container--min-width,28px);\n padding: 0 var(--c2-copy-button__container--padding-right,6px) 0 var(--c2-copy-button__container--padding-left,6px);\n border: var(--c2-copy-button__container--border,none);\n border-radius: var(--c2-copy-button__container--border-radius,6px);\n background-color: var(--c2-copy-button__container--background-color);\n color: var(--c2-copy-button__container--color,rgb(34, 34, 34));\n font-size: var(--c2-copy-button__container--font-size,12px);\n font-weight: var(--c2-copy-button__container--font-weight,500);\n font-family: var(--c2-copy-button__container--font-family);\n cursor: pointer;\n user-select: none;\n transition: background-color 250ms cubic-bezier(0.2, 0, 0, 1), color 250ms cubic-bezier(0.2, 0, 0, 1);\n}\n.c2-copy-button:hover {\n background-color: var(--c2-copy-button__container__hover--background-color,rgb(230, 230, 230));\n color: var(--c2-copy-button__container__hover--color,var(--c2-copy-button__container--color,rgb(34, 34, 34)));\n border: var(--c2-copy-button__container__hover--border,var(--c2-copy-button__container--border,none));\n}\n.c2-copy-button:active {\n background-color: var(--c2-copy-button__container__active--background-color,var(--c2-copy-button__container__hover--background-color,rgb(213, 213, 213)));\n}\n.c2-copy-button:focus-visible {\n outline: var(--c2-copy-button__container__focus--outline,2px solid rgba(2, 101, 220, 0.4));\n outline-offset: var(--c2-copy-button__container__focus--outline-offset,2px);\n}\n.c2-copy-button:disabled {\n cursor: default;\n}\n.c2-copy-button.is-copied {\n color: var(--c2-copy-button__container__copied--color,rgb(0, 122, 77));\n background-color: var(--c2-copy-button__container__copied--background-color,var(--c2-copy-button__container--background-color));\n border: var(--c2-copy-button__container__copied--border,var(--c2-copy-button__container--border,none));\n}\n.c2-copy-button.is-failed {\n color: rgb(211, 21, 16);\n}\n\n:host(:not([reveal=always])) .c2-copy-button {\n opacity: 0;\n pointer-events: none;\n transition: opacity var(--c2-copy-button--transition-duration,150ms) cubic-bezier(0.2, 0, 0, 1);\n}\n\n:host(:not([reveal=always])) .c2-copy-button.is-visible {\n opacity: 1;\n pointer-events: auto;\n}\n\n@media (prefers-reduced-motion: reduce) {\n :host(:not([reveal=always])) .c2-copy-button {\n transition: none;\n }\n}\n.c2-copy-button-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: none;\n width: var(--c2-copy-button__icon--size,16px);\n height: var(--c2-copy-button__icon--size,16px);\n color: var(--c2-copy-button__icon--color);\n transition: color 250ms cubic-bezier(0.2, 0, 0, 1);\n}\n.c2-copy-button-icon svg,\n.c2-copy-button-icon ::slotted(*) {\n width: 100%;\n height: 100%;\n --c2-feather-icon--size: var(--c2-copy-button__icon--size,16px);\n --c2-mat-icon--font-size: var(--c2-copy-button__icon--size,16px);\n}\n\n.c2-copy-button.is-copied .c2-copy-button-icon {\n color: var(--c2-copy-button__icon__copied--color,var(--c2-copy-button__container__copied--color,rgb(0, 122, 77)));\n}\n\n.c2-copy-button-label {\n display: contents;\n white-space: nowrap;\n}\n\n.c2-copy-button-status {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n}";
package/package.json CHANGED
@@ -1,18 +1,30 @@
1
1
  {
2
2
  "name": "@c2n/copy-button",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "main": "dist/copy-button.js",
6
6
  "exports": {
7
7
  ".": {
8
- "default": "./dist/copy-button.js",
9
- "types": "./types/src/copy-button.d.ts"
8
+ "types": "./types/src/copy-button.d.ts",
9
+ "default": "./dist/copy-button.js"
10
+ },
11
+ "./react": {
12
+ "types": "./react.d.ts",
13
+ "default": "./react.js"
14
+ },
15
+ "./vue": {
16
+ "types": "./vue.d.ts",
17
+ "default": "./vue.js"
10
18
  },
11
19
  "./custom-elements.json": "./custom-elements.json"
12
20
  },
13
21
  "files": [
14
22
  "dist",
15
- "types"
23
+ "types",
24
+ "react.d.ts",
25
+ "react.js",
26
+ "vue.d.ts",
27
+ "vue.js"
16
28
  ],
17
29
  "keywords": [
18
30
  "copy-button",
@@ -50,12 +62,12 @@
50
62
  }
51
63
  },
52
64
  "dependencies": {
53
- "@c2n/core": "0.0.6",
65
+ "@c2n/core": "0.0.8",
54
66
  "lit": "3.3.3"
55
67
  },
56
68
  "devDependencies": {
57
69
  "@c2n/config": "*"
58
70
  },
59
71
  "customElements": "custom-elements.json",
60
- "gitHead": "2921054bc75299da66dad11c1e374246ff88a51e"
72
+ "gitHead": "be59cbccee1d33ca248e39f69b05c0b595ec6c6d"
61
73
  }
package/react.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ //
3
+ // JSX types for the custom elements of @c2n/copy-button. Import once, anywhere in the program:
4
+ //
5
+ // import '@c2n/copy-button/react'
6
+ //
7
+ // Register the elements at module scope before React renders, or React writes an object prop as an
8
+ // attribute and it stringifies.
9
+
10
+ import type { DetailedHTMLProps, HTMLAttributes } from 'react'
11
+ import type { CopyButton } from '@c2n/copy-button'
12
+
13
+ /** Standard React host-element attributes plus the element's own public properties. */
14
+ type C2Props<T> = DetailedHTMLProps<HTMLAttributes<T>, T> & Partial<Omit<T, keyof HTMLElement>>
15
+
16
+ declare module 'react' {
17
+ namespace JSX {
18
+ interface IntrinsicElements {
19
+ 'c2-copy-button': C2Props<CopyButton>
20
+ }
21
+ }
22
+ }
23
+
24
+ export {}
package/react.js ADDED
@@ -0,0 +1,3 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ // Types only — see the matching .d.ts.
3
+ export {}
@@ -1,6 +1,20 @@
1
1
  import { LitElement, type PropertyValues } from 'lit';
2
+ import type { TypedAddEventListener, TypedRemoveEventListener } from '@c2n/core/event-helper.js';
2
3
  /** Corners `pin` can anchor to. The bare `pin` attribute means `top-right`. */
3
4
  export type CopyButtonPin = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
5
+ /** Events fired by {@link CopyButton}, keyed for `addEventListener`. */
6
+ export interface CopyButtonEventMap {
7
+ copied: CustomEvent<{
8
+ text: string;
9
+ }>;
10
+ 'copy-error': CustomEvent<{
11
+ error: unknown;
12
+ }>;
13
+ }
14
+ export interface CopyButton {
15
+ addEventListener: TypedAddEventListener<CopyButton, CopyButtonEventMap>;
16
+ removeEventListener: TypedRemoveEventListener<CopyButton, CopyButtonEventMap>;
17
+ }
4
18
  /**
5
19
  * Copies text to the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/framework-types. Do not edit by hand.
2
+ //
3
+ // Vue template types for the custom elements of @c2n/copy-button. Import once, anywhere in the program:
4
+ //
5
+ // import '@c2n/copy-button/vue'
6
+ //
7
+ // Tell the compiler about the tags as well, or every c2-* tag is resolved as a Vue component and renders
8
+ // nothing: template.compilerOptions.isCustomElement = (tag) => tag.startsWith('c2-') in vite.config.ts.
9
+
10
+ import type { DefineComponent, HTMLAttributes } from 'vue'
11
+ import type { CopyButton, CopyButtonEventMap } from '@c2n/copy-button'
12
+
13
+ /** The element's own public properties, plus every attribute Vue understands on a host element. */
14
+ type C2Props<T> = Partial<Omit<T, keyof HTMLElement>> & HTMLAttributes
15
+
16
+ declare module 'vue' {
17
+ interface GlobalComponents {
18
+ 'c2-copy-button': DefineComponent<
19
+ C2Props<CopyButton> & {
20
+ 'copied-duration'?: unknown
21
+ 'copied-label'?: unknown
22
+ onCopyError?: (event: CopyButtonEventMap['copy-error']) => void
23
+ onCopied?: (event: CopyButtonEventMap['copied']) => void
24
+ }
25
+ >
26
+ }
27
+ }
28
+
29
+ declare module '@vue/runtime-dom' {
30
+ interface HTMLAttributes {
31
+ /** Vue's own definition omits it, and slotting a plain element into a component needs it. */
32
+ slot?: string
33
+ }
34
+ }
35
+
36
+ export {}
package/vue.js ADDED
@@ -0,0 +1,3 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ // Types only — see the matching .d.ts.
3
+ export {}