@shival99/z-ui-svelte 0.1.8 → 0.1.10
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/z-command/ZCommand.svelte +11 -2
- package/dist/components/z-drawer/ZDrawer.svelte +7 -0
- package/dist/components/z-drawer/ZDrawer.svelte.d.ts +3 -0
- package/dist/components/z-shimmer-text/ZShimmerText.svelte +70 -61
- package/dist/components/z-shimmer-text/ZShimmerText.svelte.d.ts +4 -0
- package/dist/components/z-toast/ZToastPillText.svelte +77 -77
- package/package.json +1 -1
|
@@ -154,7 +154,12 @@
|
|
|
154
154
|
// would otherwise become the reference, leaving the highlight offset once it stops.
|
|
155
155
|
const box = row && content ? { row: row.getBoundingClientRect(), list: content.getBoundingClientRect() } : null;
|
|
156
156
|
indicator = box
|
|
157
|
-
? {
|
|
157
|
+
? {
|
|
158
|
+
top: box.row.top - box.list.top,
|
|
159
|
+
left: box.row.left - box.list.left,
|
|
160
|
+
width: box.row.width,
|
|
161
|
+
height: box.row.height,
|
|
162
|
+
}
|
|
158
163
|
: null;
|
|
159
164
|
});
|
|
160
165
|
|
|
@@ -355,7 +360,11 @@
|
|
|
355
360
|
></div>
|
|
356
361
|
{/if}
|
|
357
362
|
{#key path.length}
|
|
358
|
-
<div
|
|
363
|
+
<div
|
|
364
|
+
class="space-y-1"
|
|
365
|
+
in:fly={{ x: direction * 16, duration: ms(Z_COMMAND_PAGE_MS), opacity: 0 }}
|
|
366
|
+
onintroend={() => settled++}
|
|
367
|
+
>
|
|
359
368
|
{#if flat.length === 0}
|
|
360
369
|
<div class="text-muted-foreground py-6 text-center text-sm" role="presentation">
|
|
361
370
|
{#if empty}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import ZPortal from '../../overlay/ZPortal.svelte';
|
|
8
8
|
import { zMergeClasses } from '../../utils/merge-classes';
|
|
9
9
|
import ZDrawerPanel from './ZDrawerPanel.svelte';
|
|
10
|
+
import type { ZIcon } from '../z-icon/z-icon.types';
|
|
10
11
|
import { Z_DRAWER_FLOATING_INSET } from './z-drawer.define';
|
|
11
12
|
import { ZDrawerResizeController } from './z-drawer-resize.svelte';
|
|
12
13
|
import { ZDrawerSheetController } from './z-drawer-sheet.svelte';
|
|
@@ -40,6 +41,8 @@
|
|
|
40
41
|
zHideHeader?: boolean;
|
|
41
42
|
zOkText?: string | null;
|
|
42
43
|
zCancelText?: string | null;
|
|
44
|
+
zOkIcon?: ZIcon;
|
|
45
|
+
zCancelIcon?: ZIcon;
|
|
43
46
|
zOkDestructive?: boolean;
|
|
44
47
|
zOkDisabled?: boolean;
|
|
45
48
|
zLoading?: boolean;
|
|
@@ -86,6 +89,8 @@
|
|
|
86
89
|
zHideHeader = false,
|
|
87
90
|
zOkText = null,
|
|
88
91
|
zCancelText = null,
|
|
92
|
+
zOkIcon,
|
|
93
|
+
zCancelIcon,
|
|
89
94
|
zOkDestructive = false,
|
|
90
95
|
zOkDisabled = false,
|
|
91
96
|
zLoading = false,
|
|
@@ -223,6 +228,8 @@
|
|
|
223
228
|
bodyClass={zBodyClass}
|
|
224
229
|
okText={zOkText}
|
|
225
230
|
cancelText={zCancelText}
|
|
231
|
+
okIcon={zOkIcon}
|
|
232
|
+
cancelIcon={zCancelIcon}
|
|
226
233
|
okDestructive={zOkDestructive}
|
|
227
234
|
okDisabled={zOkDisabled}
|
|
228
235
|
loading={zLoading}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { ClassValue } from 'clsx';
|
|
3
|
+
import type { ZIcon } from '../z-icon/z-icon.types';
|
|
3
4
|
import type { ZDrawerOverlayType, ZDrawerPlacement, ZDrawerScrollMode, ZDrawerType } from './z-drawer.types';
|
|
4
5
|
import type { ZDrawerShape } from './z-drawer.types';
|
|
5
6
|
interface Props {
|
|
@@ -27,6 +28,8 @@ interface Props {
|
|
|
27
28
|
zHideHeader?: boolean;
|
|
28
29
|
zOkText?: string | null;
|
|
29
30
|
zCancelText?: string | null;
|
|
31
|
+
zOkIcon?: ZIcon;
|
|
32
|
+
zCancelIcon?: ZIcon;
|
|
30
33
|
zOkDestructive?: boolean;
|
|
31
34
|
zOkDisabled?: boolean;
|
|
32
35
|
zLoading?: boolean;
|
|
@@ -1,61 +1,70 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
import type { ClassValue } from 'clsx';
|
|
4
|
-
import { zTranslate } from '../../i18n/translate.svelte';
|
|
5
|
-
import { zMergeClasses } from '../../utils/merge-classes';
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
class?: ClassValue;
|
|
9
|
-
/** Text or i18n key. The `children` snippet replaces it. */
|
|
10
|
-
zText?: string;
|
|
11
|
-
/** Seconds for one sweep (default 2). */
|
|
12
|
-
zDuration?: number;
|
|
13
|
-
/** Hold the sweep: the text stays in its resting colour. */
|
|
14
|
-
zPaused?: boolean;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
background-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ClassValue } from 'clsx';
|
|
4
|
+
import { zTranslate } from '../../i18n/translate.svelte';
|
|
5
|
+
import { zMergeClasses } from '../../utils/merge-classes';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
class?: ClassValue;
|
|
9
|
+
/** Text or i18n key. The `children` snippet replaces it. */
|
|
10
|
+
zText?: string;
|
|
11
|
+
/** Seconds for one sweep (default 2). */
|
|
12
|
+
zDuration?: number;
|
|
13
|
+
/** Hold the sweep: the text stays in its resting colour. */
|
|
14
|
+
zPaused?: boolean;
|
|
15
|
+
/** Resting colour of the text (any CSS colour; default the muted foreground). */
|
|
16
|
+
zBase?: string;
|
|
17
|
+
/** Colour of the sweeping highlight (default the foreground). */
|
|
18
|
+
zPeak?: string;
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let { class: className, zText = '', zDuration = 2, zPaused = false, zBase, zPeak, children }: Props = $props();
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<!-- A highlight sweeps across the text — "thinking…", "loading…" — without moving any layout. -->
|
|
26
|
+
<span
|
|
27
|
+
class={zMergeClasses('z-shimmer-text inline-block', zPaused && 'z-shimmer-text-paused', className)}
|
|
28
|
+
style:--z-shimmer-duration={`${zDuration}s`}
|
|
29
|
+
style:--z-shimmer-base={zBase}
|
|
30
|
+
style:--z-shimmer-peak={zPeak}
|
|
31
|
+
>
|
|
32
|
+
{#if children}{@render children()}{:else}{zTranslate(zText)}{/if}
|
|
33
|
+
</span>
|
|
34
|
+
|
|
35
|
+
<style>
|
|
36
|
+
.z-shimmer-text {
|
|
37
|
+
/* The gradient is 3x the text and never repeats: the highlight enters and leaves in the resting colour, so the
|
|
38
|
+
loop has no jump (a repeating gradient showed the previous tile's highlight when the sweep restarted). */
|
|
39
|
+
background-image: linear-gradient(
|
|
40
|
+
105deg,
|
|
41
|
+
var(--z-shimmer-base, var(--muted-foreground)) 40%,
|
|
42
|
+
var(--z-shimmer-peak, var(--foreground)) 50%,
|
|
43
|
+
var(--z-shimmer-base, var(--muted-foreground)) 60%
|
|
44
|
+
);
|
|
45
|
+
background-size: 300% 100%;
|
|
46
|
+
background-repeat: no-repeat;
|
|
47
|
+
background-clip: text;
|
|
48
|
+
-webkit-background-clip: text;
|
|
49
|
+
color: transparent;
|
|
50
|
+
animation: z-shimmer-sweep var(--z-shimmer-duration, 2s) linear infinite;
|
|
51
|
+
}
|
|
52
|
+
.z-shimmer-text-paused {
|
|
53
|
+
animation-play-state: paused;
|
|
54
|
+
}
|
|
55
|
+
@keyframes z-shimmer-sweep {
|
|
56
|
+
from {
|
|
57
|
+
background-position: 100% 0;
|
|
58
|
+
}
|
|
59
|
+
to {
|
|
60
|
+
background-position: 0% 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
@media (prefers-reduced-motion: reduce) {
|
|
64
|
+
.z-shimmer-text {
|
|
65
|
+
animation: none;
|
|
66
|
+
background-image: none;
|
|
67
|
+
color: var(--z-shimmer-base, var(--muted-foreground));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
</style>
|
|
@@ -8,6 +8,10 @@ interface Props {
|
|
|
8
8
|
zDuration?: number;
|
|
9
9
|
/** Hold the sweep: the text stays in its resting colour. */
|
|
10
10
|
zPaused?: boolean;
|
|
11
|
+
/** Resting colour of the text (any CSS colour; default the muted foreground). */
|
|
12
|
+
zBase?: string;
|
|
13
|
+
/** Colour of the sweeping highlight (default the foreground). */
|
|
14
|
+
zPeak?: string;
|
|
11
15
|
children?: Snippet;
|
|
12
16
|
}
|
|
13
17
|
declare const ZShimmerText: import("svelte").Component<Props, {}, "">;
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Z_TOAST_PILL_EASE, Z_TOAST_PILL_MORPH_MS, zPillFadeBlur } from './z-toast.pill.motion';
|
|
3
|
-
import ZToastPillReveal from './ZToastPillReveal.svelte';
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
text: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
let { text }: Props = $props();
|
|
10
|
-
|
|
11
|
-
let box = $state<HTMLElement | null>(null);
|
|
12
|
-
let measure = $state<HTMLElement | null>(null);
|
|
13
|
-
// Pinned (px) only while the line glides from the old text's width to the new one's.
|
|
14
|
-
let width = $state<number | null>(null);
|
|
15
|
-
let mounted = false;
|
|
16
|
-
// The first text is shown as is; every later one is revealed letter by letter. Read when a text block
|
|
17
|
-
// is created (never re-rendered from), so it is a plain object rather than state.
|
|
18
|
-
const shown = { value: false };
|
|
19
|
-
|
|
20
|
-
$effect(() => {
|
|
21
|
-
shown.value = true;
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// Before the text swaps, pin the width the line has now...
|
|
25
|
-
$effect.pre(() => {
|
|
26
|
-
void text;
|
|
27
|
-
if (mounted && box) {
|
|
28
|
-
width = box.offsetWidth;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// ...then let it glide to the new text's natural width.
|
|
33
|
-
$effect(() => {
|
|
34
|
-
void text;
|
|
35
|
-
if (!measure) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (!mounted) {
|
|
39
|
-
mounted = true;
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const next = measure.offsetWidth;
|
|
44
|
-
const frame = requestAnimationFrame(() => {
|
|
45
|
-
width = width === next ? null : next;
|
|
46
|
-
});
|
|
47
|
-
return () => cancelAnimationFrame(frame);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
function release(event: TransitionEvent): void {
|
|
51
|
-
if (event.propertyName === 'width') {
|
|
52
|
-
width = null;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
</script>
|
|
56
|
-
|
|
57
|
-
<!-- The invisible copy sizes the line; the old text fades out over the new one in the same cell. -->
|
|
58
|
-
<span
|
|
59
|
-
bind:this={box}
|
|
60
|
-
class="relative inline-grid max-w-
|
|
61
|
-
style:width={width === null ? undefined : `${width}px`}
|
|
62
|
-
style:transition="width {Z_TOAST_PILL_MORPH_MS}ms {Z_TOAST_PILL_EASE}"
|
|
63
|
-
ontransitionend={release}
|
|
64
|
-
>
|
|
65
|
-
<span bind:this={measure} class="invisible col-start-1 row-start-1 w-max whitespace-pre" aria-hidden="true">
|
|
66
|
-
{text}
|
|
67
|
-
</span>
|
|
68
|
-
{#key text}
|
|
69
|
-
<span class="col-start-1 row-start-1 w-
|
|
70
|
-
{#if shown.value}
|
|
71
|
-
<ZToastPillReveal {text} />
|
|
72
|
-
{:else}
|
|
73
|
-
{text}
|
|
74
|
-
{/if}
|
|
75
|
-
</span>
|
|
76
|
-
{/key}
|
|
77
|
-
</span>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Z_TOAST_PILL_EASE, Z_TOAST_PILL_MORPH_MS, zPillFadeBlur } from './z-toast.pill.motion';
|
|
3
|
+
import ZToastPillReveal from './ZToastPillReveal.svelte';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let { text }: Props = $props();
|
|
10
|
+
|
|
11
|
+
let box = $state<HTMLElement | null>(null);
|
|
12
|
+
let measure = $state<HTMLElement | null>(null);
|
|
13
|
+
// Pinned (px) only while the line glides from the old text's width to the new one's.
|
|
14
|
+
let width = $state<number | null>(null);
|
|
15
|
+
let mounted = false;
|
|
16
|
+
// The first text is shown as is; every later one is revealed letter by letter. Read when a text block
|
|
17
|
+
// is created (never re-rendered from), so it is a plain object rather than state.
|
|
18
|
+
const shown = { value: false };
|
|
19
|
+
|
|
20
|
+
$effect(() => {
|
|
21
|
+
shown.value = true;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Before the text swaps, pin the width the line has now...
|
|
25
|
+
$effect.pre(() => {
|
|
26
|
+
void text;
|
|
27
|
+
if (mounted && box) {
|
|
28
|
+
width = box.offsetWidth;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// ...then let it glide to the new text's natural width.
|
|
33
|
+
$effect(() => {
|
|
34
|
+
void text;
|
|
35
|
+
if (!measure) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!mounted) {
|
|
39
|
+
mounted = true;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const next = measure.offsetWidth;
|
|
44
|
+
const frame = requestAnimationFrame(() => {
|
|
45
|
+
width = width === next ? null : next;
|
|
46
|
+
});
|
|
47
|
+
return () => cancelAnimationFrame(frame);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
function release(event: TransitionEvent): void {
|
|
51
|
+
if (event.propertyName === 'width') {
|
|
52
|
+
width = null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<!-- The invisible copy sizes the line; the old text fades out over the new one in the same cell. -->
|
|
58
|
+
<span
|
|
59
|
+
bind:this={box}
|
|
60
|
+
class="relative inline-grid max-w-96 grid-cols-[minmax(0,1fr)] items-center overflow-hidden whitespace-nowrap motion-reduce:transition-none"
|
|
61
|
+
style:width={width === null ? undefined : `${width}px`}
|
|
62
|
+
style:transition="width {Z_TOAST_PILL_MORPH_MS}ms {Z_TOAST_PILL_EASE}"
|
|
63
|
+
ontransitionend={release}
|
|
64
|
+
>
|
|
65
|
+
<span bind:this={measure} class="invisible col-start-1 row-start-1 w-max whitespace-pre" aria-hidden="true">
|
|
66
|
+
{text}
|
|
67
|
+
</span>
|
|
68
|
+
{#key text}
|
|
69
|
+
<span class="col-start-1 row-start-1 min-w-0 truncate" out:zPillFadeBlur>
|
|
70
|
+
{#if shown.value}
|
|
71
|
+
<ZToastPillReveal {text} />
|
|
72
|
+
{:else}
|
|
73
|
+
{text}
|
|
74
|
+
{/if}
|
|
75
|
+
</span>
|
|
76
|
+
{/key}
|
|
77
|
+
</span>
|