@skeletonlabs/skeleton 2.0.0-rc.3 → 2.1.0-dev.0b27cf4c

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.
@@ -6,5 +6,5 @@ type ClipboardArgs = string | {
6
6
  export declare function clipboard(node: HTMLElement, args: ClipboardArgs): {
7
7
  update(newArgs: ClipboardArgs): void;
8
8
  destroy(): void;
9
- };
9
+ } | undefined;
10
10
  export {};
@@ -1,4 +1,8 @@
1
1
  export function clipboard(node, args) {
2
+ if (!window.isSecureContext) {
3
+ console.error('Clipboard action failed: app not running in secure context, see: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard');
4
+ return;
5
+ }
2
6
  const fireCopyCompleteEvent = () => {
3
7
  node.dispatchEvent(new CustomEvent('copyComplete'));
4
8
  };
@@ -1,4 +1,5 @@
1
- <script>export let regionPage = "";
1
+ <script>export let scrollbarGutter = "auto";
2
+ export let regionPage = "";
2
3
  export let slotHeader = "z-10";
3
4
  export let slotSidebarLeft = "w-auto";
4
5
  export let slotSidebarRight = "w-auto";
@@ -43,7 +44,7 @@ $:
43
44
  {/if}
44
45
 
45
46
  <!-- Page -->
46
- <div id="page" class="{regionPage} {cPage}" on:scroll>
47
+ <div id="page" class="{regionPage} {cPage}" style:scrollbar-gutter={scrollbarGutter} on:scroll>
47
48
  <!-- Slot: Page Header -->
48
49
  {#if $$slots.pageHeader}
49
50
  <header id="page-header" class="flex-none {classesPageHeader}"><slot name="pageHeader">(slot:header)</slot></header>
@@ -10,6 +10,8 @@ import type { SvelteEvent } from '../../index.js';
10
10
  declare const __propDef: {
11
11
  props: {
12
12
  [x: string]: any;
13
+ /** Set `scrollbar-gutter` style.*/
14
+ scrollbarGutter?: string | undefined;
13
15
  /** Apply arbitrary classes to the entire `#page` region.*/
14
16
  regionPage?: string | undefined;
15
17
  /** Apply arbitrary classes to the `header` slot container element*/
@@ -3,7 +3,11 @@ import { prefersReducedMotionStore } from "../../index.js";
3
3
  import { dynamicTransition } from "../../internal/transitions.js";
4
4
  </script>
5
5
 
6
- <script generics="TransitionIn extends Transition = SlideTransition, TransitionOut extends Transition = SlideTransition">import { createEventDispatcher } from "svelte";
6
+ <script
7
+
8
+ generics="Value = unknown, Meta = unknown,
9
+ TransitionIn extends Transition = SlideTransition, TransitionOut extends Transition = SlideTransition"
10
+ >import { createEventDispatcher } from "svelte";
7
11
  const dispatch = createEventDispatcher();
8
12
  export let input = void 0;
9
13
  export let options = [];
@@ -54,7 +58,7 @@ $:
54
58
  $:
55
59
  optionsFiltered = input ? filterOptions() : listedOptions;
56
60
  $:
57
- sliceLimit = limit !== void 0 ? limit : optionsFiltered.length;
61
+ sliceLimit = limit ?? optionsFiltered.length;
58
62
  $:
59
63
  classesBase = `${$$props.class ?? ""}`;
60
64
  $:
@@ -3,14 +3,14 @@ import { slide } from 'svelte/transition';
3
3
  import { type Transition, type TransitionParams } from '../../index.js';
4
4
  type SlideTransition = typeof slide;
5
5
  import type { AutocompleteOption } from './types.js';
6
- declare class __sveltets_Render<TransitionIn extends Transition = SlideTransition, TransitionOut extends Transition = SlideTransition> {
6
+ declare class __sveltets_Render<Value = unknown, Meta = unknown, TransitionIn extends Transition = SlideTransition, TransitionOut extends Transition = SlideTransition> {
7
7
  props(): {
8
8
  [x: string]: any;
9
- input?: unknown;
10
- options?: AutocompleteOption[] | undefined;
9
+ input?: Value | undefined;
10
+ options?: AutocompleteOption<Value, Meta>[] | undefined;
11
11
  limit?: number | undefined;
12
- allowlist?: unknown[] | undefined;
13
- denylist?: unknown[] | undefined;
12
+ allowlist?: Value[] | undefined;
13
+ denylist?: Value[] | undefined;
14
14
  emptyState?: string | undefined;
15
15
  regionNav?: string | undefined;
16
16
  regionList?: string | undefined;
@@ -26,15 +26,15 @@ declare class __sveltets_Render<TransitionIn extends Transition = SlideTransitio
26
26
  events(): {
27
27
  click: MouseEvent;
28
28
  keypress: KeyboardEvent;
29
- selection: CustomEvent<AutocompleteOption>;
29
+ selection: CustomEvent<AutocompleteOption<Value, Meta>>;
30
30
  } & {
31
31
  [evt: string]: CustomEvent<any>;
32
32
  };
33
33
  slots(): {};
34
34
  }
35
- export type AutocompleteProps<TransitionIn extends Transition = SlideTransition, TransitionOut extends Transition = SlideTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['props']>;
36
- export type AutocompleteEvents<TransitionIn extends Transition = SlideTransition, TransitionOut extends Transition = SlideTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['events']>;
37
- export type AutocompleteSlots<TransitionIn extends Transition = SlideTransition, TransitionOut extends Transition = SlideTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['slots']>;
38
- export default class Autocomplete<TransitionIn extends Transition = SlideTransition, TransitionOut extends Transition = SlideTransition> extends SvelteComponentTyped<AutocompleteProps<TransitionIn, TransitionOut>, AutocompleteEvents<TransitionIn, TransitionOut>, AutocompleteSlots<TransitionIn, TransitionOut>> {
35
+ export type AutocompleteProps<Value = unknown, Meta = unknown, TransitionIn extends Transition = SlideTransition, TransitionOut extends Transition = SlideTransition> = ReturnType<__sveltets_Render<Value, Meta, TransitionIn, TransitionOut>['props']>;
36
+ export type AutocompleteEvents<Value = unknown, Meta = unknown, TransitionIn extends Transition = SlideTransition, TransitionOut extends Transition = SlideTransition> = ReturnType<__sveltets_Render<Value, Meta, TransitionIn, TransitionOut>['events']>;
37
+ export type AutocompleteSlots<Value = unknown, Meta = unknown, TransitionIn extends Transition = SlideTransition, TransitionOut extends Transition = SlideTransition> = ReturnType<__sveltets_Render<Value, Meta, TransitionIn, TransitionOut>['slots']>;
38
+ export default class Autocomplete<Value = unknown, Meta = unknown, TransitionIn extends Transition = SlideTransition, TransitionOut extends Transition = SlideTransition> extends SvelteComponentTyped<AutocompleteProps<Value, Meta, TransitionIn, TransitionOut>, AutocompleteEvents<Value, Meta, TransitionIn, TransitionOut>, AutocompleteSlots<Value, Meta, TransitionIn, TransitionOut>> {
39
39
  }
40
40
  export {};
@@ -1,10 +1,10 @@
1
- export interface AutocompleteOption {
2
- /** provide a unique display label per option. Supports HTML. */
1
+ export interface AutocompleteOption<Value = unknown, Meta = unknown> {
2
+ /** Provide a unique display label per option. Supports HTML. */
3
3
  label: string;
4
4
  /** Provide a unique option value. */
5
- value: unknown;
5
+ value: Value;
6
6
  /** Provide a comma separated list of keywords. */
7
- keywords?: any;
7
+ keywords?: string;
8
8
  /** Pass arbitrary data per option. */
9
- meta?: any;
9
+ meta?: Meta;
10
10
  }
@@ -110,6 +110,12 @@ $:
110
110
  classesChipList = `${cChipList}`;
111
111
  $:
112
112
  classesInputField = `${cInputField}`;
113
+ $:
114
+ chipValues = value?.map((val, i) => {
115
+ if (chipValues[i]?.val === val)
116
+ return chipValues[i];
117
+ return { id: Math.random(), val };
118
+ }) || [];
113
119
  </script>
114
120
 
115
121
  <div class="input-chip {classesBase}" class:opacity-50={$$restProps.disabled}>
@@ -91,7 +91,7 @@ onDestroy(() => {
91
91
  <!-- Button: Next -->
92
92
  <button type={buttonNextType} class="btn {buttonNext}" on:click={onNext} disabled={locked}>
93
93
  {#if locked}
94
- <svg class="w-3 aspect-square" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
94
+ <svg class="w-3 aspect-square fill-current" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
95
95
  <path
96
96
  d="M144 144v48H304V144c0-44.2-35.8-80-80-80s-80 35.8-80 80zM80 192V144C80 64.5 144.5 0 224 0s144 64.5 144 144v48h16c35.3 0 64 28.7 64 64V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V256c0-35.3 28.7-64 64-64H80z"
97
97
  />
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export type { AutocompleteOption } from './components/Autocomplete/types.js';
2
2
  export type { ConicStop } from './components/ConicGradient/types.js';
3
- export type { DrawerSettings } from './utilities/Drawer/types.js';
4
- export type { ModalSettings, ModalComponent } from './utilities/Modal/types.js';
5
- export type { ToastSettings } from './utilities/Toast/types.js';
3
+ export type { DrawerSettings, DrawerStore } from './utilities/Drawer/types.js';
4
+ export type { ModalSettings, ModalComponent, ModalStore } from './utilities/Modal/types.js';
5
+ export type { ToastSettings, ToastStore } from './utilities/Toast/types.js';
6
6
  export type { TableSource } from './components/Table/types.js';
7
7
  export type { PaginationSettings } from './components/Paginator/types.js';
8
8
  export type { PopupSettings } from './utilities/Popup/types.js';
@@ -3,13 +3,17 @@ import type { DrawerSettings } from './types.js';
3
3
  /**
4
4
  * Retrieves the `drawerStore`.
5
5
  *
6
+ * This can *ONLY* be called from the **top level** of components!
7
+ *
6
8
  * @example
7
- * ```ts
8
- * import { getDrawerStore } from "@skeletonlabs/skeleton";
9
+ * ```svelte
10
+ * <script>
11
+ * import { getDrawerStore } from "@skeletonlabs/skeleton";
9
12
  *
10
- * const drawerStore = getDrawerStore();
13
+ * const drawerStore = getDrawerStore();
11
14
  *
12
- * drawerStore.open();
15
+ * drawerStore.open();
16
+ * </script>
13
17
  * ```
14
18
  */
15
19
  export declare function getDrawerStore(): DrawerStore;
@@ -17,7 +21,7 @@ export declare function getDrawerStore(): DrawerStore;
17
21
  * Initializes the `drawerStore`.
18
22
  */
19
23
  export declare function initializeDrawerStore(): DrawerStore;
20
- type DrawerStore = ReturnType<typeof drawerService>;
24
+ export type DrawerStore = ReturnType<typeof drawerService>;
21
25
  declare function drawerService(): {
22
26
  subscribe: (this: void, run: import("svelte/store").Subscriber<DrawerSettings>, invalidate?: import("svelte/store").Invalidator<DrawerSettings> | undefined) => import("svelte/store").Unsubscriber;
23
27
  set: (this: void, value: DrawerSettings) => void;
@@ -5,13 +5,17 @@ const DRAWER_STORE_KEY = 'drawerStore';
5
5
  /**
6
6
  * Retrieves the `drawerStore`.
7
7
  *
8
+ * This can *ONLY* be called from the **top level** of components!
9
+ *
8
10
  * @example
9
- * ```ts
10
- * import { getDrawerStore } from "@skeletonlabs/skeleton";
11
+ * ```svelte
12
+ * <script>
13
+ * import { getDrawerStore } from "@skeletonlabs/skeleton";
11
14
  *
12
- * const drawerStore = getDrawerStore();
15
+ * const drawerStore = getDrawerStore();
13
16
  *
14
- * drawerStore.open();
17
+ * drawerStore.open();
18
+ * </script>
15
19
  * ```
16
20
  */
17
21
  export function getDrawerStore() {
@@ -1,3 +1,4 @@
1
+ export type { DrawerStore } from './stores.js';
1
2
  export interface DrawerSettings {
2
3
  open?: boolean;
3
4
  /** A unique identifier, useful for setting contents. */
@@ -202,11 +202,13 @@ $:
202
202
  aria-modal="true"
203
203
  aria-label={$modalStore[0].title ?? ''}
204
204
  >
205
- <svelte:component this={currentComponent?.ref} {...currentComponent?.props} {parent}>
206
- {#if currentComponent?.slot}
205
+ {#if currentComponent?.slot}
206
+ <svelte:component this={currentComponent?.ref} {...currentComponent?.props} {parent}>
207
207
  {@html currentComponent?.slot}
208
- {/if}
209
- </svelte:component>
208
+ </svelte:component>
209
+ {:else}
210
+ <svelte:component this={currentComponent?.ref} {...currentComponent?.props} {parent} />
211
+ {/if}
210
212
  </div>
211
213
  {/if}
212
214
  </div>
@@ -0,0 +1,8 @@
1
+ <script>import { initializeModalStore, getModalStore } from "./stores.js";
2
+ import Modal from "./Modal.svelte";
3
+ export let modalSetting;
4
+ initializeModalStore();
5
+ getModalStore().trigger(modalSetting);
6
+ </script>
7
+
8
+ <Modal />
@@ -0,0 +1,17 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { ModalSettings } from './types.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ modalSetting: ModalSettings;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type ModalTestProps = typeof __propDef.props;
13
+ export type ModalTestEvents = typeof __propDef.events;
14
+ export type ModalTestSlots = typeof __propDef.slots;
15
+ export default class ModalTest extends SvelteComponentTyped<ModalTestProps, ModalTestEvents, ModalTestSlots> {
16
+ }
17
+ export {};
@@ -3,13 +3,17 @@ import type { ModalSettings } from './types.js';
3
3
  /**
4
4
  * Retrieves the `modalStore`.
5
5
  *
6
+ * This can *ONLY* be called from the **top level** of components!
7
+ *
6
8
  * @example
7
- * ```ts
8
- * import { getmodalStore } from "@skeletonlabs/skeleton";
9
+ * ```svelte
10
+ * <script>
11
+ * import { getmodalStore } from "@skeletonlabs/skeleton";
9
12
  *
10
- * const modalStore = getModalStore();
13
+ * const modalStore = getModalStore();
11
14
  *
12
- * modalStore.trigger({ type: "alert", title: "Welcome!" });
15
+ * modalStore.trigger({ type: "alert", title: "Welcome!" });
16
+ * </script>
13
17
  * ```
14
18
  */
15
19
  export declare function getModalStore(): ModalStore;
@@ -17,7 +21,7 @@ export declare function getModalStore(): ModalStore;
17
21
  * Initializes the `modalStore`.
18
22
  */
19
23
  export declare function initializeModalStore(): ModalStore;
20
- type ModalStore = ReturnType<typeof modalService>;
24
+ export type ModalStore = ReturnType<typeof modalService>;
21
25
  declare function modalService(): {
22
26
  subscribe: (this: void, run: import("svelte/store").Subscriber<ModalSettings[]>, invalidate?: import("svelte/store").Invalidator<ModalSettings[]> | undefined) => import("svelte/store").Unsubscriber;
23
27
  set: (this: void, value: ModalSettings[]) => void;
@@ -5,13 +5,17 @@ const MODAL_STORE_KEY = 'modalStore';
5
5
  /**
6
6
  * Retrieves the `modalStore`.
7
7
  *
8
+ * This can *ONLY* be called from the **top level** of components!
9
+ *
8
10
  * @example
9
- * ```ts
10
- * import { getmodalStore } from "@skeletonlabs/skeleton";
11
+ * ```svelte
12
+ * <script>
13
+ * import { getmodalStore } from "@skeletonlabs/skeleton";
11
14
  *
12
- * const modalStore = getModalStore();
15
+ * const modalStore = getModalStore();
13
16
  *
14
- * modalStore.trigger({ type: "alert", title: "Welcome!" });
17
+ * modalStore.trigger({ type: "alert", title: "Welcome!" });
18
+ * </script>
15
19
  * ```
16
20
  */
17
21
  export function getModalStore() {
@@ -1,3 +1,4 @@
1
+ export type { ModalStore } from './stores.js';
1
2
  export interface ModalComponent {
2
3
  /** Import and provide your component reference. */
3
4
  ref: any;
@@ -6,6 +6,8 @@ interface TOCCrawlerArgs {
6
6
  scrollTarget?: string;
7
7
  /** Reload the action when this key value changes. */
8
8
  key?: unknown;
9
+ prefix?: string;
10
+ suffix?: string;
9
11
  }
10
12
  export declare function tocCrawler(node: HTMLElement, args?: TOCCrawlerArgs): {
11
13
  update(newArgs: TOCCrawlerArgs): void;
@@ -6,16 +6,16 @@ export function tocCrawler(node, args) {
6
6
  let headings;
7
7
  let permalinks = [];
8
8
  function init() {
9
- // Reset headings
10
- headings = node.querySelectorAll(queryElements);
11
- // Reset the permalinks array:
12
- permalinks = [];
13
9
  // Set accepted list of query elements
10
+ // (IMPORTANT: must proceed resetting `headings` below)
14
11
  if (args?.queryElements)
15
12
  queryElements = args.queryElements;
16
13
  // Set the desired scroll target to monitor
17
14
  if (args?.scrollTarget)
18
15
  scrollTarget = args.scrollTarget;
16
+ // Reset local values
17
+ headings = node.querySelectorAll(queryElements);
18
+ permalinks = [];
19
19
  // Query and process the headings
20
20
  queryHeadings();
21
21
  }
@@ -31,7 +31,9 @@ export function tocCrawler(node, args) {
31
31
  .replaceAll(/[^a-zA-Z0-9 ]/g, '')
32
32
  .replaceAll(' ', '-')
33
33
  .toLowerCase();
34
- elemHeading.id = `toc-${newHeadingId}`;
34
+ const prefix = args.prefix ? `${args.prefix}-` : '';
35
+ const suffix = args.suffix ? `-${args.suffix}` : '';
36
+ elemHeading.id = prefix + newHeadingId + suffix;
35
37
  }
36
38
  // Push heading data to the permalink array
37
39
  permalinks.push({
@@ -0,0 +1,12 @@
1
+ <script>import { initializeToastStore, getToastStore } from "./stores.js";
2
+ import Toast from "./Toast.svelte";
3
+ export let toastSettings = [];
4
+ export let max = void 0;
5
+ initializeToastStore();
6
+ const toastStore = getToastStore();
7
+ toastSettings.forEach((element) => {
8
+ toastStore.trigger(element);
9
+ });
10
+ </script>
11
+
12
+ <Toast {max} />
@@ -0,0 +1,18 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { ToastSettings } from './types.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ toastSettings?: ToastSettings[] | undefined;
6
+ max?: number | undefined;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {};
12
+ };
13
+ export type ToastTestProps = typeof __propDef.props;
14
+ export type ToastTestEvents = typeof __propDef.events;
15
+ export type ToastTestSlots = typeof __propDef.slots;
16
+ export default class ToastTest extends SvelteComponentTyped<ToastTestProps, ToastTestEvents, ToastTestSlots> {
17
+ }
18
+ export {};
@@ -3,13 +3,17 @@ import type { ToastSettings, Toast } from './types.js';
3
3
  /**
4
4
  * Retrieves the `toastStore`.
5
5
  *
6
+ * This can *ONLY* be called from the **top level** of components!
7
+ *
6
8
  * @example
7
- * ```ts
8
- * import { getToastStore } from "@skeletonlabs/skeleton";
9
+ * ```svelte
10
+ * <script>
11
+ * import { getToastStore } from "@skeletonlabs/skeleton";
9
12
  *
10
- * const toastStore = getToastStore();
13
+ * const toastStore = getToastStore();
11
14
  *
12
- * toastStore.open({ message: "Welcome!" });
15
+ * toastStore.open({ message: "Welcome!" });
16
+ * </script>
13
17
  * ```
14
18
  */
15
19
  export declare function getToastStore(): ToastStore;
@@ -17,7 +21,7 @@ export declare function getToastStore(): ToastStore;
17
21
  * Initializes the `toastStore`.
18
22
  */
19
23
  export declare function initializeToastStore(): ToastStore;
20
- type ToastStore = ReturnType<typeof toastService>;
24
+ export type ToastStore = ReturnType<typeof toastService>;
21
25
  declare function toastService(): {
22
26
  subscribe: (this: void, run: import("svelte/store").Subscriber<Toast[]>, invalidate?: import("svelte/store").Invalidator<Toast[]> | undefined) => import("svelte/store").Unsubscriber;
23
27
  close: (id: string) => void;
@@ -6,13 +6,17 @@ const TOAST_STORE_KEY = 'toastStore';
6
6
  /**
7
7
  * Retrieves the `toastStore`.
8
8
  *
9
+ * This can *ONLY* be called from the **top level** of components!
10
+ *
9
11
  * @example
10
- * ```ts
11
- * import { getToastStore } from "@skeletonlabs/skeleton";
12
+ * ```svelte
13
+ * <script>
14
+ * import { getToastStore } from "@skeletonlabs/skeleton";
12
15
  *
13
- * const toastStore = getToastStore();
16
+ * const toastStore = getToastStore();
14
17
  *
15
- * toastStore.open({ message: "Welcome!" });
18
+ * toastStore.open({ message: "Welcome!" });
19
+ * </script>
16
20
  * ```
17
21
  */
18
22
  export function getToastStore() {
@@ -1,3 +1,4 @@
1
+ export type { ToastStore } from './stores.js';
1
2
  export interface ToastSettings {
2
3
  /** Provide the toast message. Supports HTML. */
3
4
  message: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skeletonlabs/skeleton",
3
- "version": "2.0.0-rc.3",
3
+ "version": "2.1.0-dev.0b27cf4c",
4
4
  "description": "A SvelteKit component library.",
5
5
  "author": "endigo9740 <chris@skeletonlabs.dev>",
6
6
  "repository": {