@skeletonlabs/skeleton 1.2.5 → 1.5.1

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.
Files changed (45) hide show
  1. package/dist/components/Accordion/Accordion.svelte +2 -1
  2. package/dist/components/Accordion/Accordion.svelte.d.ts +2 -0
  3. package/dist/components/AppRail/AppRail.svelte +1 -1
  4. package/dist/components/AppRail/AppRail.svelte.d.ts +3 -3
  5. package/dist/components/AppRail/AppRailTile.svelte +9 -2
  6. package/dist/components/AppRail/AppRailTile.svelte.d.ts +5 -5
  7. package/dist/components/Autocomplete/Autocomplete.svelte +4 -1
  8. package/dist/components/Autocomplete/Autocomplete.svelte.d.ts +5 -3
  9. package/dist/components/Avatar/Avatar.svelte +10 -1
  10. package/dist/components/Avatar/Avatar.svelte.d.ts +2 -0
  11. package/dist/components/ListBox/ListBoxItem.svelte +1 -1
  12. package/dist/components/Tab/Tab.svelte +33 -1
  13. package/dist/components/Tab/TabGroup.svelte +3 -1
  14. package/dist/utilities/CodeBlock/CodeBlock.svelte +12 -5
  15. package/dist/utilities/CodeBlock/CodeBlock.svelte.d.ts +2 -0
  16. package/dist/utilities/Drawer/Drawer.svelte +3 -2
  17. package/dist/utilities/Drawer/Drawer.svelte.d.ts +1 -1
  18. package/dist/utilities/LightSwitch/LightSwitch.svelte +8 -2
  19. package/dist/utilities/LocalStorageStore/LocalStorageStore.js +4 -4
  20. package/dist/utilities/Popup/popup.d.ts +2 -2
  21. package/dist/utilities/Popup/popup.js +163 -212
  22. package/dist/utilities/Popup/types.d.ts +20 -12
  23. package/dist/utilities/Popup/types.js +0 -1
  24. package/dist/utilities/Toast/Toast.svelte +2 -2
  25. package/dist/utilities/Toast/Toast.svelte.d.ts +1 -1
  26. package/package.json +4 -1
  27. package/src/lib/styles/all.css +21 -9
  28. package/src/lib/styles/elements/breadcrumbs.css +10 -0
  29. package/src/lib/styles/elements/codeblocks.css +16 -0
  30. package/src/lib/styles/elements/forms.css +15 -0
  31. package/src/lib/styles/elements/lists.css +2 -3
  32. package/src/lib/styles/elements/popups.css +2 -2
  33. package/src/lib/styles/partials/elements.css +20 -0
  34. package/src/lib/styles/{typography.css → partials/typography-next.css} +33 -35
  35. package/src/lib/styles/partials/typography-prose.css +51 -0
  36. package/src/lib/styles/partials/typography.css +99 -0
  37. package/src/lib/styles/{variants.css → partials/variants.css} +53 -5
  38. package/src/lib/styles/skeleton-minimal.css +30 -0
  39. package/src/lib/styles/skeleton.css +30 -0
  40. package/src/lib/tailwind/generated/intellisense-classes.cjs +1 -1
  41. package/src/lib/tailwind/intellisense.cjs +2 -2
  42. package/src/lib/styles/elements.css +0 -19
  43. package/src/lib/styles/highlight-js.css +0 -116
  44. /package/src/lib/styles/{core.css → partials/core.css} +0 -0
  45. /package/src/lib/styles/{tailwind.css → partials/tailwind.css} +0 -0
@@ -2,6 +2,7 @@
2
2
  import { setContext } from "svelte";
3
3
  export let autocollapse = false;
4
4
  export let duration = 200;
5
+ export let width = "w-full";
5
6
  export let spacing = "space-y-1";
6
7
  export let disabled = false;
7
8
  export let padding = "py-2 px-4";
@@ -26,7 +27,7 @@ setContext("regionControl", regionControl);
26
27
  setContext("regionPanel", regionPanel);
27
28
  setContext("regionCaret", regionCaret);
28
29
  $:
29
- classesBase = `${spacing} ${$$props.class ?? ""}`;
30
+ classesBase = `${width} ${spacing} ${$$props.class ?? ""}`;
30
31
  </script>
31
32
 
32
33
  <!-- @component The Accordion parent element. -->
@@ -6,6 +6,8 @@ declare const __propDef: {
6
6
  autocollapse?: boolean | undefined;
7
7
  /** Set the drawer animation duration in milliseconds.*/
8
8
  duration?: number | undefined;
9
+ /** Provide classes to set the accordion width.*/
10
+ width?: string | undefined;
9
11
  /** Provide classes to set the vertical spacing between items.*/
10
12
  spacing?: string | undefined;
11
13
  /** Set the accordion disabled state for all items.*/
@@ -21,7 +21,7 @@ $:
21
21
 
22
22
  <!-- @component A vertical navigation rail component. -->
23
23
 
24
- <div class="app-rail {classesBase}">
24
+ <div class="app-rail {classesBase}" data-testid="app-rail">
25
25
  <!-- Slot: lead -->
26
26
  <div class="app-bar-lead {regionLead}"><slot name="lead" /></div>
27
27
  <!-- Slot: Default -->
@@ -1,10 +1,10 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import { type Writable } from 'svelte/store';
2
+ import { type Readable, type Writable } from 'svelte/store';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  [x: string]: any;
6
- /** Provide a writable store to maintain navigation selection.*/
7
- selected?: Writable<any> | undefined;
6
+ /** Provide a writable or readable store to maintain navigation selection.*/
7
+ selected?: Writable<any> | Readable<any> | undefined;
8
8
  /** Provide classes to set the background color.*/
9
9
  background?: string | undefined;
10
10
  /** Provide classes to set the background color.*/
@@ -8,12 +8,19 @@ export let regionLabel = "";
8
8
  export let selected = getContext("selected");
9
9
  export let active = getContext("active");
10
10
  export let hover = getContext("hover");
11
+ if ($$props.href) {
12
+ tag = "a";
13
+ if (value === void 0)
14
+ value = $$props.href;
15
+ }
11
16
  const cBase = "unstyled grid place-content-center place-items-center w-full aspect-square space-y-1.5 cursor-pointer";
12
17
  const cLabel = "font-bold text-xs text-center";
13
18
  function onClickHandler(event) {
14
19
  if (!String($selected) || !String(value))
15
20
  return;
16
- $selected = value;
21
+ if (selected && "set" in selected) {
22
+ selected.set(value);
23
+ }
17
24
  dispatch("click", event);
18
25
  }
19
26
  $:
@@ -30,7 +37,7 @@ function prunedRestProps() {
30
37
 
31
38
  <!-- @component A navigation tile for the App Rail component. -->
32
39
 
33
- <div on:click={onClickHandler} on:keydown on:keyup on:keypress>
40
+ <div on:click={onClickHandler} on:keydown on:keyup on:keypress data-testid="app-rail-tile">
34
41
  <!-- IMPORTANT: avoid forwarding events on <svelte:element> tags per: -->
35
42
  <!-- https://github.com/skeletonlabs/skeleton/issues/727#issuecomment-1356859261 -->
36
43
  <svelte:element this={tag} {...prunedRestProps()} class="app-rail-tile {classesBase}">
@@ -1,9 +1,9 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { Writable } from 'svelte/store';
2
+ import type { Readable, Writable } from 'svelte/store';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  [x: string]: any;
6
- /** Provide a unique value, active tiles will be highlighted.*/
6
+ /** Provide a unique value, active tiles will be highlighted. href will be used if no value is provided.*/
7
7
  value?: any | undefined;
8
8
  /** Provide the element tag. Button or Anchor recommended.*/
9
9
  tag?: string | undefined;
@@ -13,9 +13,9 @@ declare const __propDef: {
13
13
  regionIcon?: string | undefined;
14
14
  /** Provide arbitrary classes to style the label region.*/
15
15
  regionLabel?: string | undefined;
16
- selected?: Writable<string> | undefined;
17
- active?: Writable<string> | undefined;
18
- hover?: Writable<string> | undefined;
16
+ selected?: Writable<string> | Readable<string> | undefined;
17
+ active?: string | undefined;
18
+ hover?: string | undefined;
19
19
  };
20
20
  events: {
21
21
  keydown: KeyboardEvent;
@@ -2,6 +2,7 @@
2
2
  const dispatch = createEventDispatcher();
3
3
  export let input = void 0;
4
4
  export let options = [];
5
+ export let limit = void 0;
5
6
  export let allowlist = [];
6
7
  export let denylist = [];
7
8
  export let emptyState = "No Results Found.";
@@ -51,6 +52,8 @@ $:
51
52
  filterByDenied();
52
53
  $:
53
54
  optionsFiltered = input ? filterOptions() : listedOptions;
55
+ $:
56
+ sliceLimit = limit !== void 0 ? limit : optionsFiltered.length;
54
57
  $:
55
58
  classesBase = `${$$props.class ?? ""}`;
56
59
  $:
@@ -70,7 +73,7 @@ $:
70
73
  {#if optionsFiltered.length > 0}
71
74
  <nav class="autocomplete-nav {classesNav}">
72
75
  <ul class="autocomplete-list {classesList}">
73
- {#each optionsFiltered as option, i (option)}
76
+ {#each optionsFiltered.slice(0, sliceLimit) as option, i (option)}
74
77
  <li class="autocomplete-item {classesItem}">
75
78
  <button class="autocomplete-button {classesButton}" type="button" on:click={() => onSelection(option)} on:click on:keypress>
76
79
  {@html option.label}
@@ -5,11 +5,13 @@ declare const __propDef: {
5
5
  [x: string]: any;
6
6
  /** Bind the input value.*/
7
7
  input?: unknown;
8
- /** Define values for the list*/
8
+ /** Define values for the list.*/
9
9
  options?: AutocompleteOption[] | undefined;
10
- /** Provide allowlist values*/
10
+ /** Limit the total number of suggestions.*/
11
+ limit?: number | undefined;
12
+ /** Provide allowlist values.*/
11
13
  allowlist?: unknown[] | undefined;
12
- /** Provide denylist values*/
14
+ /** Provide denylist values.*/
13
15
  denylist?: unknown[] | undefined;
14
16
  /** Provide a HTML markup to display when no match is found.*/
15
17
  emptyState?: string | undefined;
@@ -1,6 +1,7 @@
1
1
  <script>export let initials = "AB";
2
2
  export let fill = "fill-token";
3
3
  export let src = "";
4
+ export let fallback = "";
4
5
  export let action = () => {
5
6
  };
6
7
  export let actionParams = "";
@@ -22,7 +23,15 @@ function prunedRestProps() {
22
23
 
23
24
  <figure class="avatar {classesBase}" data-testid="avatar" on:click on:keydown on:keyup on:keypress>
24
25
  {#if src}
25
- <img class="avatar-image {cImage}" style={$$props.style ?? ''} {src} alt={$$props.alt || ''} use:action={actionParams} {...prunedRestProps()} />
26
+ <img
27
+ class="avatar-image {cImage}"
28
+ style={$$props.style ?? ''}
29
+ {src}
30
+ alt={$$props.alt || ''}
31
+ use:action={actionParams}
32
+ on:error={() => (src = fallback)}
33
+ {...prunedRestProps()}
34
+ />
26
35
  {:else}
27
36
  <svg class="avatar-initials w-full h-full" viewBox="0 0 512 512">
28
37
  <text x="50%" y="50%" dominant-baseline="central" text-anchor="middle" font-weight="bold" font-size={150} class="avatar-text {fill}">
@@ -8,6 +8,8 @@ declare const __propDef: {
8
8
  fill?: string | undefined;
9
9
  /** Provide the avatar image element source.*/
10
10
  src?: string | undefined;
11
+ /** Provide the fallback image element source.*/
12
+ fallback?: string | undefined;
11
13
  /** Image only. Provide an Svelte action reference, such as `filter`.*/
12
14
  action?: any;
13
15
  /** Image only. Provide Svelte action params, such as Apollo.*/
@@ -8,7 +8,7 @@ export let active = getContext("active");
8
8
  export let hover = getContext("hover");
9
9
  export let padding = getContext("padding");
10
10
  const cBase = "cursor-pointer -outline-offset-[3px]";
11
- const cLabel = "flex space-x-4";
11
+ const cLabel = "flex items-center space-x-4";
12
12
  let checked;
13
13
  let elemInput;
14
14
  $:
@@ -16,6 +16,38 @@ function onKeyDown(event) {
16
16
  if (["Enter", "Space"].includes(event.code)) {
17
17
  event.preventDefault();
18
18
  elemInput.click();
19
+ } else if (event.code === "ArrowRight") {
20
+ const tabList = elemInput.closest(".tab-list");
21
+ if (!tabList)
22
+ return;
23
+ const tabs = Array.from(tabList.querySelectorAll(".tab"));
24
+ const currTab = elemInput.closest(".tab");
25
+ if (!currTab)
26
+ return;
27
+ const currIndex = tabs.indexOf(currTab);
28
+ const nextIndex = currIndex + 1 >= tabs.length ? 0 : currIndex + 1;
29
+ const nextTab = tabs[nextIndex];
30
+ const nextTabInput = nextTab?.querySelector("input");
31
+ if (nextTab && nextTabInput) {
32
+ nextTabInput.click();
33
+ nextTab.focus();
34
+ }
35
+ } else if (event.code === "ArrowLeft") {
36
+ const tabList = elemInput.closest(".tab-list");
37
+ if (!tabList)
38
+ return;
39
+ const tabs = Array.from(tabList.querySelectorAll(".tab"));
40
+ const currTab = elemInput.closest(".tab");
41
+ if (!currTab)
42
+ return;
43
+ const currIndex = tabs.indexOf(currTab);
44
+ const nextIndex = currIndex - 1 < 0 ? tabs.length - 1 : currIndex - 1;
45
+ const nextTab = tabs[nextIndex];
46
+ const nextTabInput = nextTab?.querySelector("input");
47
+ if (nextTab && nextTabInput) {
48
+ nextTabInput.click();
49
+ nextTab.focus();
50
+ }
19
51
  }
20
52
  }
21
53
  $:
@@ -40,7 +72,7 @@ function prunedRestProps() {
40
72
  role="tab"
41
73
  aria-controls={controls}
42
74
  aria-selected={selected}
43
- tabindex="0"
75
+ tabindex={selected ? 0 : -1}
44
76
  on:keydown={onKeyDown}
45
77
  on:keydown
46
78
  on:keyup
@@ -35,6 +35,8 @@ $:
35
35
  </div>
36
36
  <!-- Tab Panel -->
37
37
  {#if $$slots.panel}
38
- <div class="tab-panel {classesPanel}" role="tabpanel" aria-labelledby={panel}><slot name="panel" /></div>
38
+ <div class="tab-panel {classesPanel}" role="tabpanel" aria-labelledby={panel} tabindex="0">
39
+ <slot name="panel" />
40
+ </div>
39
41
  {/if}
40
42
  </div>
@@ -4,6 +4,7 @@ import { storeHighlightJs } from "./stores";
4
4
  import { clipboard } from "../../actions/Clipboard/clipboard";
5
5
  export let language = "plaintext";
6
6
  export let code = "";
7
+ export let lineNumbers = false;
7
8
  export let background = "bg-neutral-900/90";
8
9
  export let blur = "";
9
10
  export let text = "text-sm";
@@ -38,23 +39,29 @@ $:
38
39
  displayCode = $storeHighlightJs.highlight(code, { language }).value.trim();
39
40
  formatted = true;
40
41
  }
42
+ $:
43
+ if (lineNumbers) {
44
+ displayCode = displayCode.replace(/^/gm, () => {
45
+ return '<span class="line"></span> ';
46
+ });
47
+ }
41
48
  $:
42
49
  classesBase = `${cBase} ${background} ${blur} ${text} ${color} ${rounded} ${shadow} ${$$props.class ?? ""}`;
43
50
  </script>
44
51
 
45
52
  <!-- prettier-ignore -->
46
53
  {#if language && code}
47
- <div class="code-block {classesBase}" data-testid="code-block">
54
+ <div class="codeblock {classesBase}" data-testid="codeblock">
48
55
  <!-- Header -->
49
- <header class="code-block-header {cHeader}">
56
+ <header class="codeblock-header {cHeader}">
50
57
  <!-- Language -->
51
- <span class="code-block-language">{languageFormatter(language)}</span>
58
+ <span class="codeblock-language">{languageFormatter(language)}</span>
52
59
  <!-- Copy Button -->
53
- <button class="code-block-btn {button}" on:click={onCopyClick} use:clipboard={code}>
60
+ <button class="codeblock-btn {button}" on:click={onCopyClick} use:clipboard={code}>
54
61
  {!copyState ? buttonLabel : buttonCopied}
55
62
  </button>
56
63
  </header>
57
64
  <!-- Pre/Code -->
58
- <pre class="code-block-pre {cPre}"><code class="code-block-code language-{language}">{#if formatted}{@html displayCode}{:else}{code.trim()}{/if}</code></pre>
65
+ <pre class="codeblock-pre {cPre}"><code class="codeblock-code language-{language} lineNumbers">{#if formatted}{@html displayCode}{:else}{code.trim()}{/if}</code></pre>
59
66
  </div>
60
67
  {/if}
@@ -6,6 +6,8 @@ declare const __propDef: {
6
6
  language?: string | undefined;
7
7
  /** Provide the code snippet to render. Be mindful to escape as needed!*/
8
8
  code?: string | undefined;
9
+ /** Specify if line numbers should be added to the code block*/
10
+ lineNumbers?: boolean | undefined;
9
11
  /** Provide classes to set the background color.*/
10
12
  background?: string | undefined;
11
13
  /** Provided classes to set the backdrop blur.*/
@@ -1,5 +1,6 @@
1
1
  <script>import { fade, fly } from "svelte/transition";
2
- import { createEventDispatcher, onMount } from "svelte";
2
+ import { createEventDispatcher } from "svelte";
3
+ import { BROWSER } from "esm-env";
3
4
  const dispatch = createEventDispatcher();
4
5
  import { focusTrap } from "../../actions/FocusTrap/focusTrap";
5
6
  import { drawerStore } from "./stores";
@@ -65,7 +66,7 @@ function applyPropSettings(settings) {
65
66
  describedby = settings.describedby || propDefaults.describedby;
66
67
  }
67
68
  function applyAnimationSettings() {
68
- if (window === void 0)
69
+ if (!BROWSER)
69
70
  return;
70
71
  switch (position) {
71
72
  case "top":
@@ -10,7 +10,7 @@ declare const __propDef: {
10
10
  bgBackdrop?: string | undefined;
11
11
  /** Backdrop - Provide classes to set the blur style.*/
12
12
  blur?: string | undefined;
13
- /** Drawer - Provide classes to set padding.*/
13
+ /** Backdrop - Provide classes to set padding.*/
14
14
  padding?: string | undefined;
15
15
  /** Drawer - Provide classes to set the drawer background color.*/
16
16
  bgDrawer?: string | undefined;
@@ -1,4 +1,5 @@
1
- <script>import { modeCurrent, setModeUserPrefers, setModeCurrent, setInitialClassState } from "./lightswitch";
1
+ <script>import { onMount } from "svelte";
2
+ import { modeCurrent, setModeUserPrefers, setModeCurrent, setInitialClassState, getModeOsPrefers } from "./lightswitch";
2
3
  export let bgLight = "bg-surface-50";
3
4
  export let bgDark = "bg-surface-900";
4
5
  export let fillLight = "fill-surface-50";
@@ -26,6 +27,11 @@ function onKeyDown(event) {
26
27
  event.currentTarget.click();
27
28
  }
28
29
  }
30
+ onMount(() => {
31
+ if (!("modeCurrent" in localStorage)) {
32
+ setModeCurrent(getModeOsPrefers());
33
+ }
34
+ });
29
35
  $:
30
36
  trackBg = $modeCurrent === true ? bgLight : bgDark;
31
37
  $:
@@ -43,7 +49,7 @@ $:
43
49
  </script>
44
50
 
45
51
  <svelte:head>
46
- {@html `<script>(${setInitialClassState.toString()})();</script>`}
52
+ {@html `<script nonce="%sveltekit.nonce%">(${setInitialClassState.toString()})();</script>`}
47
53
  </svelte:head>
48
54
 
49
55
  <div
@@ -1,6 +1,7 @@
1
1
  // Source: https://github.com/joshnuss/svelte-local-storage-store
2
2
  // https://github.com/joshnuss/svelte-local-storage-store/blob/master/index.ts
3
3
  // Represents version v0.4.0 (2023-01-18)
4
+ import { BROWSER } from 'esm-env';
4
5
  import { writable as internal, get } from 'svelte/store';
5
6
  /* eslint-disable @typescript-eslint/no-explicit-any */
6
7
  const stores = {};
@@ -10,19 +11,18 @@ function getStorage(type) {
10
11
  export function localStorageStore(key, initialValue, options) {
11
12
  const serializer = options?.serializer ?? JSON;
12
13
  const storageType = options?.storage ?? 'local';
13
- const browser = typeof window !== 'undefined' && typeof document !== 'undefined';
14
14
  function updateStorage(key, value) {
15
- if (!browser)
15
+ if (!BROWSER)
16
16
  return;
17
17
  getStorage(storageType).setItem(key, serializer.stringify(value));
18
18
  }
19
19
  if (!stores[key]) {
20
20
  const store = internal(initialValue, (set) => {
21
- const json = browser ? getStorage(storageType).getItem(key) : null;
21
+ const json = BROWSER ? getStorage(storageType).getItem(key) : null;
22
22
  if (json) {
23
23
  set(serializer.parse(json));
24
24
  }
25
- if (browser) {
25
+ if (BROWSER) {
26
26
  const handleStorage = (event) => {
27
27
  if (event.key === key)
28
28
  set(event.newValue ? serializer.parse(event.newValue) : null);
@@ -1,7 +1,7 @@
1
1
  import { type Writable } from 'svelte/store';
2
2
  import type { PopupSettings } from './types';
3
3
  export declare const storePopup: Writable<any>;
4
- export declare function popup(node: HTMLElement, args: PopupSettings): {
4
+ export declare function popup(triggerNode: HTMLElement, args: PopupSettings): {
5
5
  update(newArgs: PopupSettings): void;
6
6
  destroy(): void;
7
- } | undefined;
7
+ };