@shival99/z-ui-svelte 0.1.7 → 0.1.9

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.
@@ -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
- ? { top: box.row.top - box.list.top, left: box.row.left - box.list.left, width: box.row.width, height: box.row.height }
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 class="space-y-1" in:fly={{ x: direction * 16, duration: ms(Z_COMMAND_PAGE_MS), opacity: 0 }} onintroend={() => settled++}>
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;
@@ -7,12 +7,12 @@
7
7
  import ZIconAnimated from './ZIconAnimated.svelte';
8
8
  import ZIconCustom from './ZIconCustom.svelte';
9
9
  import { zGetIcon, zLoadIcon } from './z-icon.loader.svelte';
10
- import type { ZIcon, ZIconAnimationTrigger, ZIconSize } from './z-icon.types';
10
+ import type { ZIcon as ZIconName, ZIconAnimationTrigger, ZIconSize } from './z-icon.types';
11
11
 
12
12
  interface Props extends Omit<HTMLAttributes<HTMLSpanElement>, 'class'> {
13
13
  class?: ClassValue;
14
14
  /** Named icon from any supported family (`lucideX`, `saxHomeBold`, `tablerHeart`, …). */
15
- zType?: ZIcon;
15
+ zType?: ZIconName;
16
16
  /** Animated icon (kebab-case, e.g. `bell`). Takes precedence over `zType`. */
17
17
  zAnimatedType?: ZAnimatedIcon;
18
18
  /** Keep the animated icon looping. */
@@ -1,11 +1,11 @@
1
1
  import type { HTMLAttributes } from 'svelte/elements';
2
2
  import type { ClassValue } from 'clsx';
3
3
  import type { ZAnimatedIcon } from './animated';
4
- import type { ZIcon, ZIconAnimationTrigger, ZIconSize } from './z-icon.types';
4
+ import type { ZIcon as ZIconName, ZIconAnimationTrigger, ZIconSize } from './z-icon.types';
5
5
  interface Props extends Omit<HTMLAttributes<HTMLSpanElement>, 'class'> {
6
6
  class?: ClassValue;
7
7
  /** Named icon from any supported family (`lucideX`, `saxHomeBold`, `tablerHeart`, …). */
8
- zType?: ZIcon;
8
+ zType?: ZIconName;
9
9
  /** Animated icon (kebab-case, e.g. `bell`). Takes precedence over `zType`. */
10
10
  zAnimatedType?: ZAnimatedIcon;
11
11
  /** Keep the animated icon looping. */
@@ -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-lg 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 w-max truncate" out:zPillFadeBlur>
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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shival99/z-ui-svelte",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Z-UI component library for Svelte 5 (runes, no CDK).",
5
5
  "license": "MIT",
6
6
  "type": "module",