@skeletonlabs/skeleton 1.8.0-dev.a448a023 → 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
  }
@@ -1,3 +1,6 @@
1
- export declare function filter(node: HTMLElement, filterName: string): {
2
- update(newArgs: any): void;
1
+ type Filters = ['Apollo', 'BlueNight', 'Emerald', 'GreenFall', 'Noir', 'NoirLight', 'Rustic', 'Summer84', 'XPro'];
2
+ type FilterName = `#${Filters[number]}` | (string & {});
3
+ export declare function filter(node: HTMLElement, filterName: FilterName): {
4
+ update(newArgs: FilterName): void;
3
5
  } | undefined;
6
+ export {};
@@ -1,6 +1,7 @@
1
1
  <script>import { createEventDispatcher } from "svelte/internal";
2
2
  export let value = 0;
3
3
  export let max = 5;
4
+ export let interactive = false;
4
5
  export let text = "text-token";
5
6
  export let fill = "fill-token";
6
7
  export let justify = "justify-center";
@@ -13,6 +14,10 @@ function iconClick(index) {
13
14
  });
14
15
  }
15
16
  const cBase = "w-full flex";
17
+ $:
18
+ elemInteractive = interactive ? "button" : "span";
19
+ $:
20
+ attrInteractive = interactive ? { type: "button" } : {};
16
21
  $:
17
22
  classesBase = `${cBase} ${text} ${fill} ${justify} ${spacing} ${$$props.class ?? ""}`;
18
23
  </script>
@@ -21,11 +26,17 @@ $:
21
26
  <!-- eslint-disable-next-line @typescript-eslint/no-unused-vars -->
22
27
  {#each Array(max) as _, i}
23
28
  {#if Math.floor(value) >= i + 1}
24
- <button type="button" class="rating-icon {regionIcon}" on:click={() => iconClick(i)}><slot name="full" /></button>
29
+ <svelte:element this={elemInteractive} {...attrInteractive} class="rating-icon {regionIcon}" on:click={() => iconClick(i)}>
30
+ <slot name="full" />
31
+ </svelte:element>
25
32
  {:else if value === i + 0.5}
26
- <button type="button" class="rating-icon {regionIcon}" on:click={() => iconClick(i)}><slot name="half" /></button>
33
+ <svelte:element this={elemInteractive} {...attrInteractive} class="rating-icon {regionIcon}" on:click={() => iconClick(i)}>
34
+ <slot name="half" />
35
+ </svelte:element>
27
36
  {:else}
28
- <button type="button" class="rating-icon {regionIcon}" on:click={() => iconClick(i)}><slot name="empty" /></button>
37
+ <svelte:element this={elemInteractive} {...attrInteractive} class="rating-icon {regionIcon}" on:click={() => iconClick(i)}>
38
+ <slot name="empty" />
39
+ </svelte:element>
29
40
  {/if}
30
41
  {/each}
31
42
  </div>
@@ -6,6 +6,8 @@ declare const __propDef: {
6
6
  value?: number | undefined;
7
7
  /** Maximum rating value.*/
8
8
  max?: number | undefined;
9
+ /** Enables interactive mode for each rating icon.*/
10
+ interactive?: boolean | undefined;
9
11
  /** Provide classes to set the text color.*/
10
12
  text?: string | undefined;
11
13
  /** Provide classes to set the SVG fill color.*/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skeletonlabs/skeleton",
3
- "version": "1.8.0-dev.a448a023",
3
+ "version": "1.8.0-dev.c238d061",
4
4
  "description": "A SvelteKit component library.",
5
5
  "author": "endigo9740 <chris@skeletonlabs.dev>",
6
6
  "repository": {