@skeletonlabs/skeleton 1.8.0-dev.94c6548f → 1.8.0-dev.c238d061

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,5 @@
1
1
  declare namespace svelteHTML {
2
- interface HTMLAttributes<T> {
3
- 'on:copyComplete'?: (event: any) => any;
2
+ interface HTMLAttributes {
3
+ 'on:copyComplete'?: () => void;
4
4
  }
5
5
  }
@@ -1,4 +1,10 @@
1
- export declare function clipboard(node: HTMLElement, args: any): {
2
- update(newArgs: any): void;
1
+ type ClipboardArgs = string | {
2
+ element: string;
3
+ } | {
4
+ input: string;
5
+ };
6
+ export declare function clipboard(node: HTMLElement, args: ClipboardArgs): {
7
+ update(newArgs: ClipboardArgs): void;
3
8
  destroy(): void;
4
9
  };
10
+ export {};
@@ -1,4 +1,3 @@
1
- // Action: Clipboard
2
1
  export function clipboard(node, args) {
3
2
  const fireCopyCompleteEvent = () => {
4
3
  node.dispatchEvent(new CustomEvent('copyComplete'));
@@ -7,15 +6,19 @@ export function clipboard(node, args) {
7
6
  // Handle `data-clipboard` target based on object key
8
7
  if (typeof args === 'object') {
9
8
  // Element Inner HTML
10
- if (Object.prototype.hasOwnProperty.call(args, 'element')) {
9
+ if ('element' in args) {
11
10
  const element = document.querySelector(`[data-clipboard="${args.element}"]`);
12
- copyToClipboard(element?.innerHTML, 'text/html').then(fireCopyCompleteEvent);
11
+ if (!element)
12
+ throw new Error(`Missing HTMLElement with an attribute of [data-clipboard="${args.element}"]`);
13
+ copyToClipboard(element.innerHTML, 'text/html').then(fireCopyCompleteEvent);
13
14
  return;
14
15
  }
15
16
  // Form Input Value
16
- if (Object.prototype.hasOwnProperty.call(args, 'input')) {
17
+ if ('input' in args) {
17
18
  const input = document.querySelector(`[data-clipboard="${args.input}"]`);
18
- copyToClipboard(input?.value).then(fireCopyCompleteEvent);
19
+ if (!input)
20
+ throw new Error(`Missing HTMLInputElement with an attribute of [data-clipboard="${args.input}"]`);
21
+ copyToClipboard(input.value).then(fireCopyCompleteEvent);
19
22
  return;
20
23
  }
21
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skeletonlabs/skeleton",
3
- "version": "1.8.0-dev.94c6548f",
3
+ "version": "1.8.0-dev.c238d061",
4
4
  "description": "A SvelteKit component library.",
5
5
  "author": "endigo9740 <chris@skeletonlabs.dev>",
6
6
  "repository": {