uisv 0.0.21 → 0.0.23
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.
- package/dist/components/accordion.svelte +22 -22
- package/dist/components/accordion.svelte.d.ts +10 -10
- package/dist/components/alert.svelte +22 -28
- package/dist/components/alert.svelte.d.ts +5 -5
- package/dist/components/app.svelte +63 -0
- package/dist/components/app.svelte.d.ts +8 -0
- package/dist/components/badge.svelte +18 -23
- package/dist/components/badge.svelte.d.ts +3 -3
- package/dist/components/banner.svelte +18 -24
- package/dist/components/banner.svelte.d.ts +5 -5
- package/dist/components/breadcrumb.svelte +7 -8
- package/dist/components/breadcrumb.svelte.d.ts +5 -26
- package/dist/components/button.svelte +36 -44
- package/dist/components/button.svelte.d.ts +12 -11
- package/dist/components/calendar.svelte +6 -7
- package/dist/components/calendar.svelte.d.ts +3 -3
- package/dist/components/card.svelte +11 -12
- package/dist/components/card.svelte.d.ts +5 -5
- package/dist/components/checkbox-group.svelte +12 -13
- package/dist/components/checkbox-group.svelte.d.ts +4 -4
- package/dist/components/checkbox.svelte +42 -40
- package/dist/components/checkbox.svelte.d.ts +6 -6
- package/dist/components/chip.svelte +7 -8
- package/dist/components/chip.svelte.d.ts +3 -3
- package/dist/components/collapsible.svelte +7 -6
- package/dist/components/collapsible.svelte.d.ts +4 -4
- package/dist/components/color-picker.svelte +1 -1
- package/dist/components/h1.svelte +8 -7
- package/dist/components/h2.svelte +12 -11
- package/dist/components/h3.svelte +9 -8
- package/dist/components/h4.svelte +12 -11
- package/dist/components/h5.svelte +12 -11
- package/dist/components/h6.svelte +12 -11
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.js +7 -0
- package/dist/components/input-number.svelte +8 -9
- package/dist/components/input-number.svelte.d.ts +5 -5
- package/dist/components/input-time.svelte +11 -12
- package/dist/components/input-time.svelte.d.ts +6 -6
- package/dist/components/input.svelte +19 -29
- package/dist/components/input.svelte.d.ts +6 -6
- package/dist/components/kbd.svelte +6 -7
- package/dist/components/kbd.svelte.d.ts +2 -2
- package/dist/components/modal.svelte +189 -0
- package/dist/components/modal.svelte.d.ts +33 -0
- package/dist/components/p.svelte +3 -1
- package/dist/components/pin-input.svelte +10 -11
- package/dist/components/pin-input.svelte.d.ts +3 -3
- package/dist/components/placeholder.svelte +4 -4
- package/dist/components/popover.svelte +33 -61
- package/dist/components/popover.svelte.d.ts +8 -30
- package/dist/components/progress.svelte +62 -26
- package/dist/components/progress.svelte.d.ts +8 -7
- package/dist/components/select.svelte +49 -53
- package/dist/components/select.svelte.d.ts +22 -29
- package/dist/components/seperator.svelte +7 -8
- package/dist/components/seperator.svelte.d.ts +6 -6
- package/dist/components/slider.svelte +13 -14
- package/dist/components/slider.svelte.d.ts +4 -4
- package/dist/components/switch.svelte +19 -23
- package/dist/components/switch.svelte.d.ts +6 -6
- package/dist/components/tabs.svelte +19 -20
- package/dist/components/tabs.svelte.d.ts +7 -7
- package/dist/components/toast.svelte +173 -0
- package/dist/components/toast.svelte.d.ts +8 -0
- package/dist/components/toast.svelte.js +11 -0
- package/dist/components/tooltip.svelte +94 -0
- package/dist/components/tooltip.svelte.d.ts +24 -0
- package/dist/contexts.d.ts +54 -0
- package/dist/contexts.js +46 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mode.d.ts +89 -0
- package/dist/mode.js +1 -0
- package/dist/utilities/index.d.ts +5 -0
- package/dist/utilities/index.js +5 -0
- package/dist/utilities/isComponent.d.ts +7 -0
- package/dist/utilities/isComponent.js +10 -0
- package/dist/utilities/isSnippet.d.ts +7 -0
- package/dist/utilities/isSnippet.js +8 -0
- package/dist/utilities/useElementRects.svelte.d.ts +11 -0
- package/dist/{utilities.svelte.js → utilities/useElementRects.svelte.js} +0 -38
- package/dist/utilities/useRafFn.svelte.d.ts +43 -0
- package/dist/utilities/useRafFn.svelte.js +56 -0
- package/dist/utilities/useStyle.svelte.d.ts +8 -0
- package/dist/utilities/useStyle.svelte.js +21 -0
- package/dist/vite.js +30 -35
- package/package.json +39 -27
- package/dist/utilities.svelte.d.ts +0 -31
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Icon,
|
|
5
|
+
Progress,
|
|
6
|
+
type ButtonProps,
|
|
7
|
+
type ProgressProps,
|
|
8
|
+
type ToastOptions,
|
|
9
|
+
useRafFn,
|
|
10
|
+
} from '../index.js';
|
|
11
|
+
import { boxWith } from 'svelte-toolbelt';
|
|
12
|
+
import { tv } from 'tailwind-variants';
|
|
13
|
+
import defu from 'defu';
|
|
14
|
+
import { onDestroy, onMount } from 'svelte';
|
|
15
|
+
import { getAppContext } from '../contexts.js';
|
|
16
|
+
|
|
17
|
+
export type ToastProps = ToastOptions & {
|
|
18
|
+
closeToast?: () => void;
|
|
19
|
+
expanded?: boolean;
|
|
20
|
+
};
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<script lang="ts">
|
|
24
|
+
let {
|
|
25
|
+
title,
|
|
26
|
+
description,
|
|
27
|
+
closeToast = () => {},
|
|
28
|
+
actions = [],
|
|
29
|
+
close = true,
|
|
30
|
+
color = 'primary',
|
|
31
|
+
duration = getAppContext().toaster.duration!,
|
|
32
|
+
icon,
|
|
33
|
+
progress = true,
|
|
34
|
+
orientation = 'vertical',
|
|
35
|
+
expanded = false,
|
|
36
|
+
ui = {},
|
|
37
|
+
}: ToastProps = $props();
|
|
38
|
+
|
|
39
|
+
let remaining = $state(boxWith(() => duration).current);
|
|
40
|
+
|
|
41
|
+
const { pause, resume } = useRafFn(({ delta }) => (remaining = remaining - delta));
|
|
42
|
+
|
|
43
|
+
const variants = $derived(
|
|
44
|
+
tv({
|
|
45
|
+
slots: {
|
|
46
|
+
base: 'overflow-hidden bg-surface-base shadow-lg rounded-lg border border-surface-accented space-y-4',
|
|
47
|
+
wrapper: 'm-4 flex gap-4',
|
|
48
|
+
title: 'text-sm font-medium text-labe-highlighted',
|
|
49
|
+
description: 'text-sm text-label-muted',
|
|
50
|
+
icon: 'shrink-0 size-5',
|
|
51
|
+
avatar: 'shrink-0',
|
|
52
|
+
avatarSize: '2xl',
|
|
53
|
+
actions: 'flex gap-1.5 shrink-0 m-4',
|
|
54
|
+
progress: '',
|
|
55
|
+
close: 'p-0',
|
|
56
|
+
},
|
|
57
|
+
variants: {
|
|
58
|
+
color: {
|
|
59
|
+
primary: {
|
|
60
|
+
base: 'focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary',
|
|
61
|
+
icon: 'text-primary',
|
|
62
|
+
},
|
|
63
|
+
surface: {
|
|
64
|
+
base: 'focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-inverted',
|
|
65
|
+
icon: 'text-highlighted',
|
|
66
|
+
},
|
|
67
|
+
success: {
|
|
68
|
+
base: 'focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-success',
|
|
69
|
+
icon: 'text-success',
|
|
70
|
+
},
|
|
71
|
+
info: {
|
|
72
|
+
base: 'focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-info',
|
|
73
|
+
icon: 'text-info',
|
|
74
|
+
},
|
|
75
|
+
warning: {
|
|
76
|
+
base: 'focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-warning',
|
|
77
|
+
icon: 'text-warning',
|
|
78
|
+
},
|
|
79
|
+
error: {
|
|
80
|
+
base: 'focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-error',
|
|
81
|
+
icon: 'text-error',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
orientation: {
|
|
85
|
+
horizontal: {
|
|
86
|
+
base: 'items-center',
|
|
87
|
+
actions: 'items-center',
|
|
88
|
+
},
|
|
89
|
+
vertical: {
|
|
90
|
+
base: 'items-start',
|
|
91
|
+
actions: 'items-start mt-2.5',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
title: {
|
|
95
|
+
true: {
|
|
96
|
+
description: 'mt-1',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
})({ color, title: !!title, orientation }),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
$effect(() => {
|
|
104
|
+
if (expanded) pause();
|
|
105
|
+
else resume();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
onMount(resume);
|
|
109
|
+
onDestroy(pause);
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
<div class={variants.base({ class: ui.base })}>
|
|
113
|
+
<div class={variants.wrapper({ class: ui.wrapper })}>
|
|
114
|
+
<Icon name={icon} class={variants.icon({ class: ui.icon })} />
|
|
115
|
+
|
|
116
|
+
<div>
|
|
117
|
+
<h1 class={variants.title({ class: ui.title })}>
|
|
118
|
+
{title}
|
|
119
|
+
</h1>
|
|
120
|
+
|
|
121
|
+
{#if description}
|
|
122
|
+
<p class={variants.description({ class: ui.description })}>
|
|
123
|
+
{description}
|
|
124
|
+
</p>
|
|
125
|
+
{/if}
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
{#if orientation === 'horizontal'}
|
|
129
|
+
{@render actions_snippet()}
|
|
130
|
+
{/if}
|
|
131
|
+
|
|
132
|
+
{#if close}
|
|
133
|
+
<Button
|
|
134
|
+
{...defu(typeof close === 'boolean' ? {} : close, <ButtonProps>{
|
|
135
|
+
icon: getAppContext().icons.close,
|
|
136
|
+
color: 'surface',
|
|
137
|
+
variant: 'link',
|
|
138
|
+
onclick: closeToast,
|
|
139
|
+
ui: { base: variants.icon({ class: ui.icon }) },
|
|
140
|
+
})}
|
|
141
|
+
/>
|
|
142
|
+
{/if}
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
{#if orientation === 'vertical'}
|
|
146
|
+
{@render actions_snippet()}
|
|
147
|
+
{/if}
|
|
148
|
+
|
|
149
|
+
{#if progress}
|
|
150
|
+
<Progress
|
|
151
|
+
max={duration}
|
|
152
|
+
value={remaining}
|
|
153
|
+
{...defu(typeof progress === 'object' ? progress : {}, <ProgressProps>{
|
|
154
|
+
size: 'sm',
|
|
155
|
+
ui: { base: variants.progress({ class: ui.progress }) },
|
|
156
|
+
})}
|
|
157
|
+
/>
|
|
158
|
+
{/if}
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
{#snippet actions_snippet()}
|
|
162
|
+
{#if actions.length > 0}
|
|
163
|
+
<div class={variants.actions({ class: ui.actions })}>
|
|
164
|
+
{#each actions as action, idx (idx)}
|
|
165
|
+
<Button
|
|
166
|
+
{...defu(action, <ButtonProps>{
|
|
167
|
+
size: 'xs',
|
|
168
|
+
})}
|
|
169
|
+
/>
|
|
170
|
+
{/each}
|
|
171
|
+
</div>
|
|
172
|
+
{/if}
|
|
173
|
+
{/snippet}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ToastOptions } from '../index.js';
|
|
2
|
+
export type ToastProps = ToastOptions & {
|
|
3
|
+
closeToast?: () => void;
|
|
4
|
+
expanded?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare const Toast: import("svelte").Component<any, {}, "">;
|
|
7
|
+
type Toast = ReturnType<typeof Toast>;
|
|
8
|
+
export default Toast;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { toast as _toast } from 'svelte-sonner';
|
|
2
|
+
import Toast from './toast.svelte';
|
|
3
|
+
import {} from 'svelte';
|
|
4
|
+
import {} from '../index.js';
|
|
5
|
+
export function toast(opts) {
|
|
6
|
+
return _toast.custom(Toast, {
|
|
7
|
+
componentProps: opts,
|
|
8
|
+
id: opts.id,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export const useToasts = _toast.getActiveToasts;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { TooltipContentProps, TooltipArrowProps, PortalProps } from 'bits-ui';
|
|
3
|
+
import { Tooltip } from 'bits-ui';
|
|
4
|
+
import { type KbdProps, type ButtonProps, isSnippet, Button, Kbd } from '../index.js';
|
|
5
|
+
import type { Snippet } from 'svelte';
|
|
6
|
+
import { fly } from 'svelte/transition';
|
|
7
|
+
import { tv, type ClassValue } from 'tailwind-variants';
|
|
8
|
+
|
|
9
|
+
export type TooltipProps = {
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
open?: boolean;
|
|
12
|
+
kbds?: KbdProps['value'][] | KbdProps[];
|
|
13
|
+
trigger?: ButtonProps | Snippet<[Record<string, unknown>]>;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
portal?: PortalProps;
|
|
16
|
+
content?: TooltipContentProps;
|
|
17
|
+
ui?: {
|
|
18
|
+
content?: ClassValue;
|
|
19
|
+
wrapper?: ClassValue;
|
|
20
|
+
kbds?: ClassValue;
|
|
21
|
+
arrow?: ClassValue;
|
|
22
|
+
};
|
|
23
|
+
arrow?: boolean | TooltipArrowProps;
|
|
24
|
+
};
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script lang="ts">
|
|
28
|
+
let {
|
|
29
|
+
children,
|
|
30
|
+
open = $bindable(false),
|
|
31
|
+
kbds,
|
|
32
|
+
trigger,
|
|
33
|
+
disabled,
|
|
34
|
+
portal,
|
|
35
|
+
content,
|
|
36
|
+
ui = {},
|
|
37
|
+
arrow,
|
|
38
|
+
...rest
|
|
39
|
+
}: TooltipProps = $props();
|
|
40
|
+
|
|
41
|
+
const variants = $derived(
|
|
42
|
+
tv({
|
|
43
|
+
slots: {
|
|
44
|
+
content: '',
|
|
45
|
+
wrapper: '',
|
|
46
|
+
kbds: '',
|
|
47
|
+
kbdsize: '',
|
|
48
|
+
arrow: '',
|
|
49
|
+
},
|
|
50
|
+
})(),
|
|
51
|
+
);
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<Tooltip.Root bind:open disabled={!(children || kbds?.length) || disabled}>
|
|
55
|
+
{#if !!trigger}
|
|
56
|
+
<Tooltip.Trigger {...rest}>
|
|
57
|
+
{#snippet child({ props })}
|
|
58
|
+
{#if isSnippet(trigger)}
|
|
59
|
+
{@render trigger(props)}
|
|
60
|
+
{:else}
|
|
61
|
+
<Button {...props} {...trigger} />
|
|
62
|
+
{/if}
|
|
63
|
+
{/snippet}
|
|
64
|
+
</Tooltip.Trigger>
|
|
65
|
+
{/if}
|
|
66
|
+
|
|
67
|
+
<Tooltip.Portal {...portal}>
|
|
68
|
+
<Tooltip.Content {...content} forceMount>
|
|
69
|
+
{#snippet child({ props, wrapperProps })}
|
|
70
|
+
<div {...wrapperProps} class={variants.wrapper({ class: [ui.wrapper] })}>
|
|
71
|
+
<div {...props} class={variants.content({ class: [ui.content] })} transition:fly>
|
|
72
|
+
{@render children?.()}
|
|
73
|
+
|
|
74
|
+
{#if kbds?.length}
|
|
75
|
+
<span class={variants.kbds({ class: ui.kbds })}>
|
|
76
|
+
{#each kbds as kbd, idx (idx)}
|
|
77
|
+
<Kbd {...typeof kbd === 'string' ? { value: kbd } : kbd} />
|
|
78
|
+
{/each}
|
|
79
|
+
</span>
|
|
80
|
+
{/if}
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
{/snippet}
|
|
84
|
+
children
|
|
85
|
+
|
|
86
|
+
{#if arrow}
|
|
87
|
+
<Tooltip.Arrow
|
|
88
|
+
{...typeof arrow === 'boolean' ? {} : arrow}
|
|
89
|
+
class={variants.arrow({ class: ui.arrow })}
|
|
90
|
+
/>
|
|
91
|
+
{/if}
|
|
92
|
+
</Tooltip.Content>
|
|
93
|
+
</Tooltip.Portal>
|
|
94
|
+
</Tooltip.Root>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TooltipContentProps, TooltipArrowProps, PortalProps } from 'bits-ui';
|
|
2
|
+
import { Tooltip } from 'bits-ui';
|
|
3
|
+
import { type KbdProps, type ButtonProps } from '../index.js';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import { type ClassValue } from 'tailwind-variants';
|
|
6
|
+
export type TooltipProps = {
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
open?: boolean;
|
|
9
|
+
kbds?: KbdProps['value'][] | KbdProps[];
|
|
10
|
+
trigger?: ButtonProps | Snippet<[Record<string, unknown>]>;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
portal?: PortalProps;
|
|
13
|
+
content?: TooltipContentProps;
|
|
14
|
+
ui?: {
|
|
15
|
+
content?: ClassValue;
|
|
16
|
+
wrapper?: ClassValue;
|
|
17
|
+
kbds?: ClassValue;
|
|
18
|
+
arrow?: ClassValue;
|
|
19
|
+
};
|
|
20
|
+
arrow?: boolean | TooltipArrowProps;
|
|
21
|
+
};
|
|
22
|
+
declare const Tooltip: import("svelte").Component<TooltipProps, {}, "open">;
|
|
23
|
+
type Tooltip = ReturnType<typeof Tooltip>;
|
|
24
|
+
export default Tooltip;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ToasterProps } from 'svelte-sonner';
|
|
2
|
+
import type { ModeWatcherProps } from './mode.js';
|
|
3
|
+
import type { TooltipProviderProps } from 'bits-ui';
|
|
4
|
+
export declare const DEFAULT_ICONS: {
|
|
5
|
+
arrowdown: string;
|
|
6
|
+
arrowleft: string;
|
|
7
|
+
arrowright: string;
|
|
8
|
+
arrowup: string;
|
|
9
|
+
caution: string;
|
|
10
|
+
check: string;
|
|
11
|
+
chevrondoubleleft: string;
|
|
12
|
+
chevrondoubleright: string;
|
|
13
|
+
chevrondown: string;
|
|
14
|
+
chevronleft: string;
|
|
15
|
+
chevronright: string;
|
|
16
|
+
chevronup: string;
|
|
17
|
+
close: string;
|
|
18
|
+
copy: string;
|
|
19
|
+
copycheck: string;
|
|
20
|
+
dark: string;
|
|
21
|
+
drag: string;
|
|
22
|
+
ellipsis: string;
|
|
23
|
+
error: string;
|
|
24
|
+
external: string;
|
|
25
|
+
eye: string;
|
|
26
|
+
eyeoff: string;
|
|
27
|
+
file: string;
|
|
28
|
+
folder: string;
|
|
29
|
+
folderopen: string;
|
|
30
|
+
hash: string;
|
|
31
|
+
info: string;
|
|
32
|
+
light: string;
|
|
33
|
+
loading: string;
|
|
34
|
+
menu: string;
|
|
35
|
+
minus: string;
|
|
36
|
+
panelclose: string;
|
|
37
|
+
panelopen: string;
|
|
38
|
+
plus: string;
|
|
39
|
+
reload: string;
|
|
40
|
+
search: string;
|
|
41
|
+
stop: string;
|
|
42
|
+
success: string;
|
|
43
|
+
system: string;
|
|
44
|
+
tip: string;
|
|
45
|
+
upload: string;
|
|
46
|
+
warning: string;
|
|
47
|
+
};
|
|
48
|
+
export type AppContext = {
|
|
49
|
+
icons: Partial<typeof DEFAULT_ICONS>;
|
|
50
|
+
toaster: Partial<ToasterProps>;
|
|
51
|
+
modewatcher: ModeWatcherProps;
|
|
52
|
+
tooltip: TooltipProviderProps;
|
|
53
|
+
};
|
|
54
|
+
export declare const getAppContext: () => AppContext, setAppContext: (context: AppContext) => AppContext;
|
package/dist/contexts.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createContext } from 'svelte';
|
|
2
|
+
export const DEFAULT_ICONS = {
|
|
3
|
+
arrowdown: 'i-lucide:arrow-down',
|
|
4
|
+
arrowleft: 'i-lucide:arrow-left',
|
|
5
|
+
arrowright: 'i-lucide:arrow-right',
|
|
6
|
+
arrowup: 'i-lucide:arrow-up',
|
|
7
|
+
caution: 'i-lucide:circle-alert',
|
|
8
|
+
check: 'i-lucide:check',
|
|
9
|
+
chevrondoubleleft: 'i-lucide:chevron-double-left',
|
|
10
|
+
chevrondoubleright: 'i-lucide:chevron-double-right',
|
|
11
|
+
chevrondown: 'i-lucide:chevron-down',
|
|
12
|
+
chevronleft: 'i-lucide:chevron-left',
|
|
13
|
+
chevronright: 'i-lucide:chevron-right',
|
|
14
|
+
chevronup: 'i-lucide:chevron-up',
|
|
15
|
+
close: 'i-lucide:x',
|
|
16
|
+
copy: 'i-lucide:copy',
|
|
17
|
+
copycheck: 'i-lucide:circle-check',
|
|
18
|
+
dark: 'i-lucide:moon',
|
|
19
|
+
drag: 'i-lucide:grip-vertical',
|
|
20
|
+
ellipsis: 'i-lucide:ellipsis',
|
|
21
|
+
error: 'i-lucide:circle-x',
|
|
22
|
+
external: 'i-lucide:arrow-up-right',
|
|
23
|
+
eye: 'i-lucide:eye',
|
|
24
|
+
eyeoff: 'i-lucide:eye-slash',
|
|
25
|
+
file: 'i-lucide:file',
|
|
26
|
+
folder: 'i-lucide:folder',
|
|
27
|
+
folderopen: 'i-lucide:folder-open',
|
|
28
|
+
hash: 'i-lucide:hash',
|
|
29
|
+
info: 'i-lucide:info',
|
|
30
|
+
light: 'i-lucide:sun',
|
|
31
|
+
loading: 'i-lucide:loader-circle',
|
|
32
|
+
menu: 'i-lucide:list',
|
|
33
|
+
minus: 'i-lucide:minus',
|
|
34
|
+
panelclose: 'i-lucide:caret-left',
|
|
35
|
+
panelopen: 'i-lucide:caret-right',
|
|
36
|
+
plus: 'i-lucide:plus',
|
|
37
|
+
reload: 'i-lucide:arrow-counter-clockwise',
|
|
38
|
+
search: 'i-lucide:magnifying-glass',
|
|
39
|
+
stop: 'i-lucide:square',
|
|
40
|
+
success: 'i-lucide:check-circle',
|
|
41
|
+
system: 'i-lucide:monitor',
|
|
42
|
+
tip: 'i-lucide:lightbulb',
|
|
43
|
+
upload: 'i-lucide:upload',
|
|
44
|
+
warning: 'i-lucide:warning',
|
|
45
|
+
};
|
|
46
|
+
export const [getAppContext, setAppContext] = createContext();
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/mode.d.ts
CHANGED
|
@@ -1 +1,90 @@
|
|
|
1
|
+
import { setMode } from 'mode-watcher';
|
|
2
|
+
export type Mode = Parameters<typeof setMode>['0'];
|
|
3
|
+
export type ThemeColors = {
|
|
4
|
+
dark: string;
|
|
5
|
+
light: string;
|
|
6
|
+
} | undefined;
|
|
7
|
+
export type ModeWatcherProps = {
|
|
8
|
+
/**
|
|
9
|
+
* Whether to automatically track operating system preferences
|
|
10
|
+
* and update the mode accordingly.
|
|
11
|
+
*
|
|
12
|
+
* @default `true`
|
|
13
|
+
*/
|
|
14
|
+
track?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The default mode to use instead of the user's preference.
|
|
17
|
+
*
|
|
18
|
+
* @default `"system"`
|
|
19
|
+
*/
|
|
20
|
+
defaultMode?: Mode;
|
|
21
|
+
/**
|
|
22
|
+
* The default theme to use, which will be applied to the root `html` element
|
|
23
|
+
* and can be managed with the `setTheme` function.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```html
|
|
27
|
+
* <html data-theme="your-custom-theme"></html>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @default `undefined`
|
|
31
|
+
*/
|
|
32
|
+
defaultTheme?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The theme colors to use for each mode.
|
|
35
|
+
*/
|
|
36
|
+
themeColors?: ThemeColors;
|
|
37
|
+
/**
|
|
38
|
+
* Whether to disable transitions when updating the mode.
|
|
39
|
+
*/
|
|
40
|
+
disableTransitions?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The classname to add to the root `html` element when the mode is dark.
|
|
43
|
+
*
|
|
44
|
+
* @default `["dark"]`
|
|
45
|
+
*/
|
|
46
|
+
darkClassNames?: string[];
|
|
47
|
+
/**
|
|
48
|
+
* The classname to add to the root `html` element when the mode is light.
|
|
49
|
+
*
|
|
50
|
+
* @default `[]`
|
|
51
|
+
*/
|
|
52
|
+
lightClassNames?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* Optionally provide a custom local storage key to use for storing the mode.
|
|
55
|
+
*
|
|
56
|
+
* @default `'mode-watcher-mode'`
|
|
57
|
+
*/
|
|
58
|
+
modeStorageKey?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Optionally provide a custom local storage key to use for storing the theme.
|
|
61
|
+
*
|
|
62
|
+
* @default `'mode-watcher-theme'`
|
|
63
|
+
*/
|
|
64
|
+
themeStorageKey?: string;
|
|
65
|
+
/**
|
|
66
|
+
* An optional nonce to use for the injected script tag to allow-list mode-watcher
|
|
67
|
+
* if you are using a Content Security Policy.
|
|
68
|
+
*
|
|
69
|
+
* @default `undefined`
|
|
70
|
+
*/
|
|
71
|
+
nonce?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Whether to disable the injected script tag that sets the initial mode.
|
|
74
|
+
* Set this if you are manually injecting the script using a hook.
|
|
75
|
+
*
|
|
76
|
+
* @default `false`
|
|
77
|
+
*/
|
|
78
|
+
disableHeadScriptInjection?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Whether to run the mode changes synchronously instead of using
|
|
81
|
+
* an animation frame. If true, will have an impact on blocking performance
|
|
82
|
+
* due to blocking the main thread.
|
|
83
|
+
*
|
|
84
|
+
* Only applicable if `disableTransitions` is set to `true`.
|
|
85
|
+
*
|
|
86
|
+
* @default `false`
|
|
87
|
+
*/
|
|
88
|
+
synchronousModeChanges?: boolean;
|
|
89
|
+
};
|
|
1
90
|
export * from 'mode-watcher';
|
package/dist/mode.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is a Svelte component
|
|
3
|
+
* @param v - The value to check
|
|
4
|
+
* @returns true if the value is a component, false otherwise
|
|
5
|
+
*/
|
|
6
|
+
export function isComponent(v) {
|
|
7
|
+
if (typeof document !== 'undefined')
|
|
8
|
+
return typeof v === 'function';
|
|
9
|
+
return typeof v === 'function' && 'render' in v;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ElementSizeOptions, type MaybeGetter } from 'runed';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a reactive value holding the dom rect of `node`s.
|
|
4
|
+
*
|
|
5
|
+
* Accepts an `options` object with the following properties:
|
|
6
|
+
* - `initialSize`: The initial size of the element. Defaults to `{ width: 0, height: 0 }`.
|
|
7
|
+
* - `box`: The box model to use. Can be either `"content-box"` or `"border-box"`. Defaults to `"border-box"`.
|
|
8
|
+
*
|
|
9
|
+
* @returns an array of dom rects.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useElementRects(nodes: MaybeGetter<HTMLElement[]>, options?: ElementSizeOptions): DOMRect[];
|
|
@@ -1,22 +1,4 @@
|
|
|
1
1
|
import { extract, useMutationObserver, useResizeObserver, } from 'runed';
|
|
2
|
-
/**
|
|
3
|
-
* Checks if a value is a Svelte component
|
|
4
|
-
* @param v - The value to check
|
|
5
|
-
* @returns true if the value is a component, false otherwise
|
|
6
|
-
*/
|
|
7
|
-
export function isComponent(v) {
|
|
8
|
-
if (typeof document !== 'undefined')
|
|
9
|
-
return typeof v === 'function';
|
|
10
|
-
return typeof v === 'function' && 'render' in v;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Checks if a value is a Svelte snippet
|
|
14
|
-
* @param v - The value to check
|
|
15
|
-
* @returns true if the value is a snippet, false otherwise
|
|
16
|
-
*/
|
|
17
|
-
export function isSnippet(v) {
|
|
18
|
-
return typeof v === 'function' && !('render' in v);
|
|
19
|
-
}
|
|
20
2
|
/**
|
|
21
3
|
* Returns a reactive value holding the dom rect of `node`s.
|
|
22
4
|
*
|
|
@@ -47,23 +29,3 @@ export function useElementRects(nodes, options = {}) {
|
|
|
47
29
|
});
|
|
48
30
|
return rects;
|
|
49
31
|
}
|
|
50
|
-
let uisv_usestyle_id = 0;
|
|
51
|
-
/**
|
|
52
|
-
* Inject reactive style element in head.
|
|
53
|
-
* @param css string
|
|
54
|
-
*/
|
|
55
|
-
export function useStyle(css) {
|
|
56
|
-
const id = `uisv_styletag_${++uisv_usestyle_id}`;
|
|
57
|
-
let el = $state();
|
|
58
|
-
$effect(() => {
|
|
59
|
-
if (!el) {
|
|
60
|
-
el = (document.getElementById(id) || document.createElement('style'));
|
|
61
|
-
if (!el.isConnected) {
|
|
62
|
-
el.id = id;
|
|
63
|
-
document.head.appendChild(el);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
el.textContent = extract(css);
|
|
67
|
-
});
|
|
68
|
-
return { id };
|
|
69
|
-
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface UseRafFnCallbackArguments {
|
|
2
|
+
/**
|
|
3
|
+
* Time elapsed between this and the last frame.
|
|
4
|
+
*/
|
|
5
|
+
delta: number;
|
|
6
|
+
/**
|
|
7
|
+
* Time elapsed since the creation of the web page. See {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp#the_time_origin Time origin}.
|
|
8
|
+
*/
|
|
9
|
+
timestamp: DOMHighResTimeStamp;
|
|
10
|
+
}
|
|
11
|
+
export interface UseRafFnOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Start the requestAnimationFrame loop immediately on creation
|
|
14
|
+
*
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
17
|
+
immediate?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The maximum frame per second to execute the function.
|
|
20
|
+
* Set to `-1` to disable the limit.
|
|
21
|
+
*
|
|
22
|
+
* @default -1
|
|
23
|
+
*/
|
|
24
|
+
fpslimit?: number;
|
|
25
|
+
/**
|
|
26
|
+
* After the requestAnimationFrame loop executed once, it will be automatically stopped.
|
|
27
|
+
*
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
once?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Call function on every `requestAnimationFrame`. With controls of pausing and resuming.
|
|
34
|
+
*
|
|
35
|
+
* @see https://vueuse.org/useRafFn
|
|
36
|
+
* @param fn
|
|
37
|
+
* @param options
|
|
38
|
+
*/
|
|
39
|
+
export declare function useRafFn(fn: (args: UseRafFnCallbackArguments) => void, options?: UseRafFnOptions): {
|
|
40
|
+
is_active: boolean;
|
|
41
|
+
pause: () => void;
|
|
42
|
+
resume: () => void;
|
|
43
|
+
};
|