@loidolt/theme-svelte 0.2.0

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 (85) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/Alert.svelte +36 -0
  3. package/dist/components/Alert.svelte.d.ts +15 -0
  4. package/dist/components/AppShell.svelte +31 -0
  5. package/dist/components/AppShell.svelte.d.ts +14 -0
  6. package/dist/components/Badge.svelte +27 -0
  7. package/dist/components/Badge.svelte.d.ts +12 -0
  8. package/dist/components/Brand.svelte +35 -0
  9. package/dist/components/Brand.svelte.d.ts +15 -0
  10. package/dist/components/Button.svelte +85 -0
  11. package/dist/components/Button.svelte.d.ts +21 -0
  12. package/dist/components/Card.svelte +43 -0
  13. package/dist/components/Card.svelte.d.ts +18 -0
  14. package/dist/components/Checkbox.svelte +54 -0
  15. package/dist/components/Checkbox.svelte.d.ts +21 -0
  16. package/dist/components/ContextBar.svelte +33 -0
  17. package/dist/components/ContextBar.svelte.d.ts +13 -0
  18. package/dist/components/Dialog.svelte +84 -0
  19. package/dist/components/Dialog.svelte.d.ts +28 -0
  20. package/dist/components/DropdownMenu.svelte +99 -0
  21. package/dist/components/DropdownMenu.svelte.d.ts +47 -0
  22. package/dist/components/Field.svelte +52 -0
  23. package/dist/components/Field.svelte.d.ts +24 -0
  24. package/dist/components/IconButton.svelte +43 -0
  25. package/dist/components/IconButton.svelte.d.ts +16 -0
  26. package/dist/components/Input.svelte +27 -0
  27. package/dist/components/Input.svelte.d.ts +11 -0
  28. package/dist/components/Label.svelte +24 -0
  29. package/dist/components/Label.svelte.d.ts +11 -0
  30. package/dist/components/NavMenu.svelte +62 -0
  31. package/dist/components/NavMenu.svelte.d.ts +43 -0
  32. package/dist/components/NumberField.svelte +78 -0
  33. package/dist/components/NumberField.svelte.d.ts +21 -0
  34. package/dist/components/PageHeader.svelte +37 -0
  35. package/dist/components/PageHeader.svelte.d.ts +15 -0
  36. package/dist/components/Panel.svelte +38 -0
  37. package/dist/components/Panel.svelte.d.ts +15 -0
  38. package/dist/components/Popover.svelte +58 -0
  39. package/dist/components/Popover.svelte.d.ts +21 -0
  40. package/dist/components/Progress.svelte +43 -0
  41. package/dist/components/Progress.svelte.d.ts +12 -0
  42. package/dist/components/RadioGroup.svelte +49 -0
  43. package/dist/components/RadioGroup.svelte.d.ts +37 -0
  44. package/dist/components/Section.svelte +39 -0
  45. package/dist/components/Section.svelte.d.ts +15 -0
  46. package/dist/components/Select.svelte +57 -0
  47. package/dist/components/Select.svelte.d.ts +41 -0
  48. package/dist/components/Separator.svelte +29 -0
  49. package/dist/components/Separator.svelte.d.ts +10 -0
  50. package/dist/components/Sidebar.svelte +35 -0
  51. package/dist/components/Sidebar.svelte.d.ts +16 -0
  52. package/dist/components/Skeleton.svelte +26 -0
  53. package/dist/components/Skeleton.svelte.d.ts +11 -0
  54. package/dist/components/Spinner.svelte +22 -0
  55. package/dist/components/Spinner.svelte.d.ts +10 -0
  56. package/dist/components/Switch.svelte +62 -0
  57. package/dist/components/Switch.svelte.d.ts +17 -0
  58. package/dist/components/Table.svelte +43 -0
  59. package/dist/components/Table.svelte.d.ts +17 -0
  60. package/dist/components/Tabs.svelte +63 -0
  61. package/dist/components/Tabs.svelte.d.ts +41 -0
  62. package/dist/components/Textarea.svelte +27 -0
  63. package/dist/components/Textarea.svelte.d.ts +11 -0
  64. package/dist/components/Toast.svelte +53 -0
  65. package/dist/components/Toast.svelte.d.ts +16 -0
  66. package/dist/components/ToastViewport.svelte +38 -0
  67. package/dist/components/ToastViewport.svelte.d.ts +13 -0
  68. package/dist/components/Tooltip.svelte +76 -0
  69. package/dist/components/Tooltip.svelte.d.ts +28 -0
  70. package/dist/components/TooltipProvider.svelte +33 -0
  71. package/dist/components/TooltipProvider.svelte.d.ts +14 -0
  72. package/dist/components/Topbar.svelte +32 -0
  73. package/dist/components/Topbar.svelte.d.ts +14 -0
  74. package/dist/components/Workspace.svelte +38 -0
  75. package/dist/components/Workspace.svelte.d.ts +12 -0
  76. package/dist/index.d.ts +46 -0
  77. package/dist/index.js +44 -0
  78. package/dist/styles.css +1 -0
  79. package/dist/toaster.svelte.d.ts +43 -0
  80. package/dist/toaster.svelte.js +82 -0
  81. package/dist/types.d.ts +39 -0
  82. package/dist/types.js +1 -0
  83. package/dist/utils.d.ts +5 -0
  84. package/dist/utils.js +7 -0
  85. package/package.json +66 -0
@@ -0,0 +1,15 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { HeadingLevel } from '../types.js';
4
+ interface Props extends HTMLAttributes<HTMLElement> {
5
+ title?: string;
6
+ header?: Snippet;
7
+ children: Snippet;
8
+ footer?: Snippet;
9
+ headingLevel?: HeadingLevel;
10
+ class?: string;
11
+ ref?: HTMLElement | null;
12
+ }
13
+ declare const Panel: import("svelte").Component<Props, {}, "ref">;
14
+ type Panel = ReturnType<typeof Panel>;
15
+ export default Panel;
@@ -0,0 +1,58 @@
1
+ <script lang="ts">
2
+ import { Popover as PopoverPrimitive } from 'bits-ui';
3
+ import type { Snippet } from 'svelte';
4
+ import type { PopoverContentProps } from 'bits-ui';
5
+ import type { Alignment, Placement, TriggerChildProps } from '../types.js';
6
+ import { cx } from '../utils.js';
7
+
8
+ type Props = Omit<PopoverContentProps, 'children' | 'class' | 'child'> & {
9
+ open?: boolean;
10
+ trigger?: Snippet;
11
+ /** Full control of the trigger element — receives the props Bits needs on it. */
12
+ triggerChild?: Snippet<[TriggerChildProps]>;
13
+ triggerClass?: string;
14
+ children: Snippet;
15
+ side?: Placement;
16
+ align?: Alignment;
17
+ sideOffset?: number;
18
+ /** `class` lands on the portaled Content element. */
19
+ class?: string;
20
+ onOpenChange?: (open: boolean) => void;
21
+ ref?: HTMLElement | null;
22
+ };
23
+
24
+ let {
25
+ open = $bindable(false),
26
+ trigger,
27
+ triggerChild,
28
+ triggerClass = 'ldt-button ldt-button--quiet',
29
+ children,
30
+ side = 'bottom',
31
+ align = 'start',
32
+ sideOffset = 6,
33
+ class: className,
34
+ onOpenChange,
35
+ ref = $bindable(null),
36
+ ...rest
37
+ }: Props = $props();
38
+ </script>
39
+
40
+ <PopoverPrimitive.Root bind:open {onOpenChange}>
41
+ {#if triggerChild}<PopoverPrimitive.Trigger
42
+ >{#snippet child(childProps)}{@render triggerChild(
43
+ childProps
44
+ )}{/snippet}</PopoverPrimitive.Trigger
45
+ >{:else if trigger}<PopoverPrimitive.Trigger class={triggerClass}
46
+ >{@render trigger()}</PopoverPrimitive.Trigger
47
+ >{/if}
48
+ <PopoverPrimitive.Portal
49
+ ><PopoverPrimitive.Content
50
+ bind:ref
51
+ {side}
52
+ {align}
53
+ {sideOffset}
54
+ class={cx('ldt-popover', className)}
55
+ {...rest}>{@render children()}</PopoverPrimitive.Content
56
+ ></PopoverPrimitive.Portal
57
+ >
58
+ </PopoverPrimitive.Root>
@@ -0,0 +1,21 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { PopoverContentProps } from 'bits-ui';
3
+ import type { Alignment, Placement, TriggerChildProps } from '../types.js';
4
+ type Props = Omit<PopoverContentProps, 'children' | 'class' | 'child'> & {
5
+ open?: boolean;
6
+ trigger?: Snippet;
7
+ /** Full control of the trigger element — receives the props Bits needs on it. */
8
+ triggerChild?: Snippet<[TriggerChildProps]>;
9
+ triggerClass?: string;
10
+ children: Snippet;
11
+ side?: Placement;
12
+ align?: Alignment;
13
+ sideOffset?: number;
14
+ /** `class` lands on the portaled Content element. */
15
+ class?: string;
16
+ onOpenChange?: (open: boolean) => void;
17
+ ref?: HTMLElement | null;
18
+ };
19
+ declare const Popover: import("svelte").Component<Props, {}, "ref" | "open">;
20
+ type Popover = ReturnType<typeof Popover>;
21
+ export default Popover;
@@ -0,0 +1,43 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { cx } from '../utils.js';
4
+
5
+ interface Props extends HTMLAttributes<HTMLDivElement> {
6
+ /** Omit (or pass `undefined`) for an indeterminate bar. */
7
+ value?: number;
8
+ max?: number;
9
+ label?: string;
10
+ class?: string;
11
+ ref?: HTMLDivElement | null;
12
+ }
13
+
14
+ let {
15
+ value,
16
+ max = 100,
17
+ label = 'Progress',
18
+ class: className,
19
+ ref = $bindable(null),
20
+ ...rest
21
+ }: Props = $props();
22
+
23
+ const indeterminate = $derived(value === undefined || !Number.isFinite(value));
24
+ // A non-positive `max` would make every ratio Infinity or NaN.
25
+ const safeMax = $derived(Number.isFinite(max) && max > 0 ? max : 100);
26
+ const clamped = $derived(Math.max(0, Math.min(safeMax, value ?? 0)));
27
+ </script>
28
+
29
+ <div
30
+ bind:this={ref}
31
+ class={cx('ldt-progress', indeterminate && 'ldt-progress--indeterminate', className)}
32
+ role="progressbar"
33
+ aria-label={label}
34
+ aria-valuenow={indeterminate ? undefined : clamped}
35
+ aria-valuemin="0"
36
+ aria-valuemax={safeMax}
37
+ {...rest}
38
+ >
39
+ <div
40
+ class="ldt-progress__bar"
41
+ style:--ldt-progress-value={indeterminate ? undefined : clamped / safeMax}
42
+ ></div>
43
+ </div>
@@ -0,0 +1,12 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ interface Props extends HTMLAttributes<HTMLDivElement> {
3
+ /** Omit (or pass `undefined`) for an indeterminate bar. */
4
+ value?: number;
5
+ max?: number;
6
+ label?: string;
7
+ class?: string;
8
+ ref?: HTMLDivElement | null;
9
+ }
10
+ declare const Progress: import("svelte").Component<Props, {}, "ref">;
11
+ type Progress = ReturnType<typeof Progress>;
12
+ export default Progress;
@@ -0,0 +1,49 @@
1
+ <script lang="ts" generics="T extends string = string">
2
+ import type { HTMLFieldsetAttributes } from 'svelte/elements';
3
+ import type { Option, Orientation } from '../types.js';
4
+ import { cx } from '../utils.js';
5
+
6
+ interface Props extends HTMLFieldsetAttributes {
7
+ value?: T;
8
+ options: Option<T>[];
9
+ /** Shared `name` for the inputs. Defaults to an SSR-stable generated id. */
10
+ name?: string;
11
+ /** Visible group label, rendered as a `<legend>`. */
12
+ label?: string;
13
+ orientation?: Orientation;
14
+ onValueChange?: (value: T) => void;
15
+ class?: string;
16
+ ref?: HTMLFieldSetElement | null;
17
+ }
18
+
19
+ // `$props.id()` matches between SSR and hydration; `Math.random()` split radio groups in two.
20
+ const generatedName = $props.id();
21
+
22
+ let {
23
+ value = $bindable(),
24
+ options,
25
+ name = generatedName,
26
+ label,
27
+ orientation = 'horizontal',
28
+ onValueChange,
29
+ class: className,
30
+ ref = $bindable(null),
31
+ ...rest
32
+ }: Props = $props();
33
+ </script>
34
+
35
+ <fieldset bind:this={ref} class={cx('ldt-fieldset', className)} {...rest}>
36
+ {#if label}<legend class="ldt-legend">{label}</legend>{/if}
37
+ <div class={cx('ldt-radio-group', orientation === 'vertical' && 'ldt-radio-group--vertical')}>
38
+ {#each options as option (option.value)}<label class="ldt-choice"
39
+ ><input
40
+ type="radio"
41
+ {name}
42
+ value={option.value}
43
+ bind:group={value}
44
+ disabled={option.disabled}
45
+ onchange={() => onValueChange?.(option.value)}
46
+ />{option.label}</label
47
+ >{/each}
48
+ </div>
49
+ </fieldset>
@@ -0,0 +1,37 @@
1
+ import type { HTMLFieldsetAttributes } from 'svelte/elements';
2
+ import type { Option, Orientation } from '../types.js';
3
+ declare function $$render<T extends string = string>(): {
4
+ props: HTMLFieldsetAttributes & {
5
+ value?: T;
6
+ options: Option<T>[];
7
+ /** Shared `name` for the inputs. Defaults to an SSR-stable generated id. */
8
+ name?: string;
9
+ /** Visible group label, rendered as a `<legend>`. */
10
+ label?: string;
11
+ orientation?: Orientation;
12
+ onValueChange?: (value: T) => void;
13
+ class?: string;
14
+ ref?: HTMLFieldSetElement | null;
15
+ };
16
+ exports: {};
17
+ bindings: "ref" | "value";
18
+ slots: {};
19
+ events: {};
20
+ };
21
+ declare class __sveltets_Render<T extends string = string> {
22
+ props(): ReturnType<typeof $$render<T>>['props'];
23
+ events(): ReturnType<typeof $$render<T>>['events'];
24
+ slots(): ReturnType<typeof $$render<T>>['slots'];
25
+ bindings(): "ref" | "value";
26
+ exports(): {};
27
+ }
28
+ interface $$IsomorphicComponent {
29
+ new <T extends string = string>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
30
+ $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
31
+ } & ReturnType<__sveltets_Render<T>['exports']>;
32
+ <T extends string = string>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
33
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
34
+ }
35
+ declare const RadioGroup: $$IsomorphicComponent;
36
+ type RadioGroup<T extends string = string> = InstanceType<typeof RadioGroup<T>>;
37
+ export default RadioGroup;
@@ -0,0 +1,39 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ import type { HeadingLevel } from '../types.js';
5
+ import { cx } from '../utils.js';
6
+
7
+ interface Props extends HTMLAttributes<HTMLElement> {
8
+ title?: string;
9
+ eyebrow?: string;
10
+ actions?: Snippet;
11
+ headingLevel?: HeadingLevel;
12
+ class?: string;
13
+ children: Snippet;
14
+ ref?: HTMLElement | null;
15
+ }
16
+
17
+ let {
18
+ title,
19
+ eyebrow,
20
+ actions,
21
+ headingLevel = 2,
22
+ class: className,
23
+ children,
24
+ ref = $bindable(null),
25
+ ...rest
26
+ }: Props = $props();
27
+ </script>
28
+
29
+ <section bind:this={ref} class={cx('ldt-section', className)} {...rest}>
30
+ {#if title || eyebrow || actions}<header class="ldt-section__heading">
31
+ <div>
32
+ {#if eyebrow}<p class="ldt-eyebrow">{eyebrow}</p>{/if}{#if title}<svelte:element
33
+ this={`h${headingLevel}`}
34
+ class="ldt-section__title">{title}</svelte:element
35
+ >{/if}
36
+ </div>
37
+ {#if actions}<div class="ldt-cluster">{@render actions()}</div>{/if}
38
+ </header>{/if}{@render children()}
39
+ </section>
@@ -0,0 +1,15 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { HeadingLevel } from '../types.js';
4
+ interface Props extends HTMLAttributes<HTMLElement> {
5
+ title?: string;
6
+ eyebrow?: string;
7
+ actions?: Snippet;
8
+ headingLevel?: HeadingLevel;
9
+ class?: string;
10
+ children: Snippet;
11
+ ref?: HTMLElement | null;
12
+ }
13
+ declare const Section: import("svelte").Component<Props, {}, "ref">;
14
+ type Section = ReturnType<typeof Section>;
15
+ export default Section;
@@ -0,0 +1,57 @@
1
+ <script lang="ts" generics="T extends string = string">
2
+ import type { HTMLSelectAttributes } from 'svelte/elements';
3
+ import type { Option } from '../types.js';
4
+ import { cx } from '../utils.js';
5
+
6
+ interface Props extends Omit<HTMLSelectAttributes, 'value'> {
7
+ value?: T | '';
8
+ options: Option<T>[];
9
+ /**
10
+ * Empty-choice text. Selectable again after a real choice unless the field is `required`,
11
+ * so a user can undo their selection.
12
+ */
13
+ placeholder?: string;
14
+ /** Accessible name when the select is not wrapped in a `Field` or `<label>`. */
15
+ label?: string;
16
+ /** Draws the full box instead of the default underline. */
17
+ boxed?: boolean;
18
+ onValueChange?: (value: T | '') => void;
19
+ class?: string;
20
+ ref?: HTMLSelectElement | null;
21
+ }
22
+
23
+ let {
24
+ value = $bindable(''),
25
+ options,
26
+ placeholder,
27
+ label,
28
+ boxed = false,
29
+ required = false,
30
+ onValueChange,
31
+ onchange,
32
+ class: className,
33
+ ref = $bindable(null),
34
+ ...rest
35
+ }: Props = $props();
36
+
37
+ function handleChange(event: Event & { currentTarget: EventTarget & HTMLSelectElement }) {
38
+ onValueChange?.(event.currentTarget.value as T | '');
39
+ onchange?.(event);
40
+ }
41
+ </script>
42
+
43
+ <select
44
+ bind:this={ref}
45
+ bind:value
46
+ {required}
47
+ aria-label={label}
48
+ class={cx('ldt-select', boxed && 'ldt-select--boxed', className)}
49
+ {...rest}
50
+ onchange={handleChange}
51
+ >
52
+ {#if placeholder}<option value="" disabled={required} hidden={required}>{placeholder}</option
53
+ >{/if}
54
+ {#each options as option (option.value)}<option value={option.value} disabled={option.disabled}
55
+ >{option.label}</option
56
+ >{/each}
57
+ </select>
@@ -0,0 +1,41 @@
1
+ import type { HTMLSelectAttributes } from 'svelte/elements';
2
+ import type { Option } from '../types.js';
3
+ declare function $$render<T extends string = string>(): {
4
+ props: Omit<HTMLSelectAttributes, "value"> & {
5
+ value?: T | "";
6
+ options: Option<T>[];
7
+ /**
8
+ * Empty-choice text. Selectable again after a real choice unless the field is `required`,
9
+ * so a user can undo their selection.
10
+ */
11
+ placeholder?: string;
12
+ /** Accessible name when the select is not wrapped in a `Field` or `<label>`. */
13
+ label?: string;
14
+ /** Draws the full box instead of the default underline. */
15
+ boxed?: boolean;
16
+ onValueChange?: (value: T | "") => void;
17
+ class?: string;
18
+ ref?: HTMLSelectElement | null;
19
+ };
20
+ exports: {};
21
+ bindings: "ref" | "value";
22
+ slots: {};
23
+ events: {};
24
+ };
25
+ declare class __sveltets_Render<T extends string = string> {
26
+ props(): ReturnType<typeof $$render<T>>['props'];
27
+ events(): ReturnType<typeof $$render<T>>['events'];
28
+ slots(): ReturnType<typeof $$render<T>>['slots'];
29
+ bindings(): "ref" | "value";
30
+ exports(): {};
31
+ }
32
+ interface $$IsomorphicComponent {
33
+ new <T extends string = string>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
34
+ $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
35
+ } & ReturnType<__sveltets_Render<T>['exports']>;
36
+ <T extends string = string>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
37
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
38
+ }
39
+ declare const Select: $$IsomorphicComponent;
40
+ type Select<T extends string = string> = InstanceType<typeof Select<T>>;
41
+ export default Select;
@@ -0,0 +1,29 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { Orientation } from '../types.js';
4
+ import { cx } from '../utils.js';
5
+
6
+ type Props = HTMLAttributes<HTMLHRElement> &
7
+ HTMLAttributes<HTMLDivElement> & {
8
+ orientation?: Orientation;
9
+ class?: string;
10
+ ref?: HTMLElement | null;
11
+ };
12
+
13
+ let {
14
+ orientation = 'horizontal',
15
+ class: className,
16
+ ref = $bindable(null),
17
+ ...rest
18
+ }: Props = $props();
19
+
20
+ const classes = $derived(
21
+ cx('ldt-separator', orientation === 'vertical' && 'ldt-separator--vertical', className)
22
+ );
23
+ </script>
24
+
25
+ {#if orientation === 'vertical'}
26
+ <div bind:this={ref} class={classes} role="separator" aria-orientation="vertical" {...rest}></div>
27
+ {:else}
28
+ <hr bind:this={ref} class={classes} {...rest} />
29
+ {/if}
@@ -0,0 +1,10 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ import type { Orientation } from '../types.js';
3
+ type Props = HTMLAttributes<HTMLHRElement> & HTMLAttributes<HTMLDivElement> & {
4
+ orientation?: Orientation;
5
+ class?: string;
6
+ ref?: HTMLElement | null;
7
+ };
8
+ declare const Separator: import("svelte").Component<Props, {}, "ref">;
9
+ type Separator = ReturnType<typeof Separator>;
10
+ export default Separator;
@@ -0,0 +1,35 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ import { cx } from '../utils.js';
5
+
6
+ interface Props extends HTMLAttributes<HTMLElement> {
7
+ side?: 'left' | 'right';
8
+ /**
9
+ * Accessible name. Only needed to tell several complementary regions apart — leave unset
10
+ * for a single sidebar, since "Sidebar" only repeats the role.
11
+ */
12
+ label?: string;
13
+ class?: string;
14
+ children: Snippet;
15
+ ref?: HTMLElement | null;
16
+ }
17
+
18
+ let {
19
+ side = 'left',
20
+ label,
21
+ class: className,
22
+ children,
23
+ ref = $bindable(null),
24
+ ...rest
25
+ }: Props = $props();
26
+ </script>
27
+
28
+ <aside
29
+ bind:this={ref}
30
+ class={cx('ldt-sidebar ldt-scrollbar', side === 'right' && 'ldt-sidebar--right', className)}
31
+ aria-label={label}
32
+ {...rest}
33
+ >
34
+ {@render children()}
35
+ </aside>
@@ -0,0 +1,16 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ interface Props extends HTMLAttributes<HTMLElement> {
4
+ side?: 'left' | 'right';
5
+ /**
6
+ * Accessible name. Only needed to tell several complementary regions apart — leave unset
7
+ * for a single sidebar, since "Sidebar" only repeats the role.
8
+ */
9
+ label?: string;
10
+ class?: string;
11
+ children: Snippet;
12
+ ref?: HTMLElement | null;
13
+ }
14
+ declare const Sidebar: import("svelte").Component<Props, {}, "ref">;
15
+ type Sidebar = ReturnType<typeof Sidebar>;
16
+ export default Sidebar;
@@ -0,0 +1,26 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { cx } from '../utils.js';
4
+
5
+ interface Props extends HTMLAttributes<HTMLSpanElement> {
6
+ /** Number is treated as pixels; strings pass through as CSS. */
7
+ width?: string | number;
8
+ height?: string | number;
9
+ class?: string;
10
+ ref?: HTMLSpanElement | null;
11
+ }
12
+
13
+ let { width, height, class: className, ref = $bindable(null), ...rest }: Props = $props();
14
+
15
+ const size = (value: string | number | undefined) =>
16
+ typeof value === 'number' ? `${value}px` : value;
17
+ </script>
18
+
19
+ <span
20
+ bind:this={ref}
21
+ class={cx('ldt-skeleton', className)}
22
+ style:width={size(width)}
23
+ style:height={size(height)}
24
+ aria-hidden="true"
25
+ {...rest}
26
+ ></span>
@@ -0,0 +1,11 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ interface Props extends HTMLAttributes<HTMLSpanElement> {
3
+ /** Number is treated as pixels; strings pass through as CSS. */
4
+ width?: string | number;
5
+ height?: string | number;
6
+ class?: string;
7
+ ref?: HTMLSpanElement | null;
8
+ }
9
+ declare const Skeleton: import("svelte").Component<Props, {}, "ref">;
10
+ type Skeleton = ReturnType<typeof Skeleton>;
11
+ export default Skeleton;
@@ -0,0 +1,22 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { cx } from '../utils.js';
4
+
5
+ interface Props extends HTMLAttributes<HTMLSpanElement> {
6
+ /** Accessible name. Pass `undefined` when an adjacent label already announces the wait. */
7
+ label?: string;
8
+ class?: string;
9
+ ref?: HTMLSpanElement | null;
10
+ }
11
+
12
+ let { label = 'Loading', class: className, ref = $bindable(null), ...rest }: Props = $props();
13
+ </script>
14
+
15
+ <span
16
+ bind:this={ref}
17
+ class={cx('ldt-spinner', className)}
18
+ role={label ? 'status' : undefined}
19
+ aria-label={label}
20
+ aria-hidden={label ? undefined : 'true'}
21
+ {...rest}
22
+ ></span>
@@ -0,0 +1,10 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ interface Props extends HTMLAttributes<HTMLSpanElement> {
3
+ /** Accessible name. Pass `undefined` when an adjacent label already announces the wait. */
4
+ label?: string;
5
+ class?: string;
6
+ ref?: HTMLSpanElement | null;
7
+ }
8
+ declare const Spinner: import("svelte").Component<Props, {}, "ref">;
9
+ type Spinner = ReturnType<typeof Spinner>;
10
+ export default Spinner;
@@ -0,0 +1,62 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLButtonAttributes } from 'svelte/elements';
4
+ import { cx } from '../utils.js';
5
+
6
+ interface Props extends HTMLButtonAttributes {
7
+ checked?: boolean;
8
+ disabled?: boolean;
9
+ /** Set to submit the state with a form; renders a hidden checkbox alongside the switch. */
10
+ name?: string;
11
+ /** Submitted value when checked. */
12
+ value?: string;
13
+ onCheckedChange?: (checked: boolean) => void;
14
+ class?: string;
15
+ children?: Snippet;
16
+ ref?: HTMLButtonElement | null;
17
+ }
18
+
19
+ let {
20
+ checked = $bindable(false),
21
+ disabled = false,
22
+ name,
23
+ value = 'on',
24
+ onCheckedChange,
25
+ onclick,
26
+ class: className,
27
+ children,
28
+ ref = $bindable(null),
29
+ ...rest
30
+ }: Props = $props();
31
+
32
+ function handleClick(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }) {
33
+ if (disabled) return;
34
+ checked = !checked;
35
+ onCheckedChange?.(checked);
36
+ onclick?.(event);
37
+ }
38
+ </script>
39
+
40
+ <button
41
+ bind:this={ref}
42
+ type="button"
43
+ role="switch"
44
+ aria-checked={checked}
45
+ {disabled}
46
+ class={cx('ldt-switch', className)}
47
+ {...rest}
48
+ onclick={handleClick}
49
+ >
50
+ <span class="ldt-switch__track" aria-hidden="true"><span class="ldt-switch__thumb"></span></span>
51
+ {#if children}<span>{@render children()}</span>{/if}
52
+ </button>
53
+ {#if name}<input
54
+ type="checkbox"
55
+ class="ldt-sr-only"
56
+ tabindex="-1"
57
+ aria-hidden="true"
58
+ {name}
59
+ {value}
60
+ {checked}
61
+ {disabled}
62
+ />{/if}
@@ -0,0 +1,17 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLButtonAttributes } from 'svelte/elements';
3
+ interface Props extends HTMLButtonAttributes {
4
+ checked?: boolean;
5
+ disabled?: boolean;
6
+ /** Set to submit the state with a form; renders a hidden checkbox alongside the switch. */
7
+ name?: string;
8
+ /** Submitted value when checked. */
9
+ value?: string;
10
+ onCheckedChange?: (checked: boolean) => void;
11
+ class?: string;
12
+ children?: Snippet;
13
+ ref?: HTMLButtonElement | null;
14
+ }
15
+ declare const Switch: import("svelte").Component<Props, {}, "ref" | "checked">;
16
+ type Switch = ReturnType<typeof Switch>;
17
+ export default Switch;