ui-svelte 0.2.24 → 0.2.26

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.
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte';
3
3
  import type { IconData } from '../display/Icon.svelte';
4
- import { IconButton } from '../index.js';
4
+ import { Avatar, IconButton } from '../index.js';
5
5
  import { cn } from '../utils/class-names.js';
6
6
  import { Add24RegularIcon } from '../icons/index.js';
7
7
  import { slide } from 'svelte/transition';
@@ -21,7 +21,7 @@
21
21
  icon?: IconData;
22
22
  color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'danger' | 'warning';
23
23
  variant?: 'solid' | 'soft';
24
- size?: 'sm' | 'md' | 'lg' | 'xl';
24
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
25
25
  actions?: FabAction[];
26
26
  isBlock?: boolean;
27
27
  offsetX?: string;
@@ -29,6 +29,11 @@
29
29
  onclick?: () => void;
30
30
  children?: Snippet;
31
31
  ariaLabel?: string;
32
+ src?: string;
33
+ name?: string;
34
+ alt?: string;
35
+ status?: 'online' | 'offline' | 'busy' | 'away';
36
+ isBordered?: boolean;
32
37
  };
33
38
 
34
39
  const {
@@ -44,7 +49,12 @@
44
49
  offsetY,
45
50
  onclick,
46
51
  children,
47
- ariaLabel
52
+ ariaLabel,
53
+ src,
54
+ name,
55
+ alt,
56
+ status,
57
+ isBordered
48
58
  }: Props = $props();
49
59
 
50
60
  let isOpen = $state(false);
@@ -115,13 +125,17 @@
115
125
  {#if children}
116
126
  {@render children()}
117
127
  {:else}
118
- <IconButton
119
- {icon}
128
+ <Avatar
129
+ {src}
130
+ {name}
131
+ {alt}
120
132
  {color}
121
133
  {variant}
122
134
  {size}
135
+ {status}
136
+ {isBordered}
137
+ {icon}
123
138
  onclick={handleTriggerClick}
124
- ariaLabel={ariaLabel || (actions.length > 0 ? 'Open actions menu' : undefined)}
125
139
  />
126
140
  {/if}
127
141
  </div>
@@ -14,7 +14,7 @@ type Props = {
14
14
  icon?: IconData;
15
15
  color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'danger' | 'warning';
16
16
  variant?: 'solid' | 'soft';
17
- size?: 'sm' | 'md' | 'lg' | 'xl';
17
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
18
18
  actions?: FabAction[];
19
19
  isBlock?: boolean;
20
20
  offsetX?: string;
@@ -22,6 +22,11 @@ type Props = {
22
22
  onclick?: () => void;
23
23
  children?: Snippet;
24
24
  ariaLabel?: string;
25
+ src?: string;
26
+ name?: string;
27
+ alt?: string;
28
+ status?: 'online' | 'offline' | 'busy' | 'away';
29
+ isBordered?: boolean;
25
30
  };
26
31
  declare const Fab: import("svelte").Component<Props, {}, "">;
27
32
  type Fab = ReturnType<typeof Fab>;
@@ -358,11 +358,11 @@
358
358
  transition:
359
359
  opacity 0.6s ease-out,
360
360
  transform 0.6s ease-out;
361
- }
362
361
 
363
- @utility reveal.is-visible {
364
- opacity: 1;
365
- transform: translateY(0);
362
+ &.is-visible {
363
+ opacity: 1;
364
+ transform: translateY(0);
365
+ }
366
366
  }
367
367
 
368
368
  @utility reveal-left {
@@ -371,11 +371,11 @@
371
371
  transition:
372
372
  opacity 0.6s ease-out,
373
373
  transform 0.6s ease-out;
374
- }
375
374
 
376
- @utility reveal-left.is-visible {
377
- opacity: 1;
378
- transform: translateX(0);
375
+ &.is-visible {
376
+ opacity: 1;
377
+ transform: translateX(0);
378
+ }
379
379
  }
380
380
 
381
381
  @utility reveal-right {
@@ -384,11 +384,11 @@
384
384
  transition:
385
385
  opacity 0.6s ease-out,
386
386
  transform 0.6s ease-out;
387
- }
388
387
 
389
- @utility reveal-right.is-visible {
390
- opacity: 1;
391
- transform: translateX(0);
388
+ &.is-visible {
389
+ opacity: 1;
390
+ transform: translateX(0);
391
+ }
392
392
  }
393
393
 
394
394
  @utility reveal-zoom {
@@ -397,11 +397,11 @@
397
397
  transition:
398
398
  opacity 0.6s ease-out,
399
399
  transform 0.6s ease-out;
400
- }
401
400
 
402
- @utility reveal-zoom.is-visible {
403
- opacity: 1;
404
- transform: scale(1);
401
+ &.is-visible {
402
+ opacity: 1;
403
+ transform: scale(1);
404
+ }
405
405
  }
406
406
 
407
407
  @utility shake {
@@ -266,6 +266,7 @@
266
266
 
267
267
  .truncate-lines-2 {
268
268
  display: -webkit-box;
269
+ line-clamp: 2;
269
270
  -webkit-line-clamp: 2;
270
271
  -webkit-box-orient: vertical;
271
272
  overflow: hidden;
@@ -273,6 +274,7 @@
273
274
 
274
275
  .truncate-lines-3 {
275
276
  display: -webkit-box;
277
+ line-clamp: 3;
276
278
  -webkit-line-clamp: 3;
277
279
  -webkit-box-orient: vertical;
278
280
  overflow: hidden;
@@ -280,6 +282,7 @@
280
282
 
281
283
  .truncate-lines-4 {
282
284
  display: -webkit-box;
285
+ line-clamp: 4;
283
286
  -webkit-line-clamp: 4;
284
287
  -webkit-box-orient: vertical;
285
288
  overflow: hidden;
@@ -288,4 +291,4 @@
288
291
  .prose-narrow { max-width: 45ch; }
289
292
  .prose-normal { max-width: 65ch; }
290
293
  .prose-wide { max-width: 80ch; }
291
- }
294
+ }
@@ -5,7 +5,7 @@
5
5
  Info24RegularIcon,
6
6
  Warning24RegularIcon
7
7
  } from '../icons/index.js';
8
- import { Icon } from '../index.js';
8
+ import { Avatar } from '../index.js';
9
9
  import { cn } from '../utils/class-names.js';
10
10
  import type { Snippet } from 'svelte';
11
11
  import type { IconData } from './Icon.svelte';
@@ -18,6 +18,12 @@
18
18
  icon?: IconData;
19
19
  color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'danger' | 'warning';
20
20
  variant?: 'solid' | 'soft';
21
+ src?: string;
22
+ name?: string;
23
+ alt?: string;
24
+ avatarSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
25
+ status?: 'online' | 'offline' | 'busy' | 'away';
26
+ isBordered?: boolean;
21
27
  };
22
28
 
23
29
  let {
@@ -27,7 +33,13 @@
27
33
  showIcon,
28
34
  icon,
29
35
  color = 'info',
30
- variant = 'soft'
36
+ variant = 'soft',
37
+ src,
38
+ name,
39
+ alt,
40
+ avatarSize = 'md',
41
+ status,
42
+ isBordered
31
43
  }: Props = $props();
32
44
 
33
45
  const colors = {
@@ -63,9 +75,20 @@
63
75
  </script>
64
76
 
65
77
  <div class={cn('alert', colors[color], variants[variant])}>
66
- {#if showIcon}
78
+ {#if showIcon || src || name}
67
79
  <div class="alert-start">
68
- <Icon icon={currentIcon} class="alert-icon" />
80
+ <Avatar
81
+ {src}
82
+ {name}
83
+ {alt}
84
+ icon={currentIcon}
85
+ size={avatarSize}
86
+ {status}
87
+ {isBordered}
88
+ {color}
89
+ {variant}
90
+ class="alert-icon"
91
+ />
69
92
  </div>
70
93
  {/if}
71
94
 
@@ -8,6 +8,12 @@ type Props = {
8
8
  icon?: IconData;
9
9
  color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'danger' | 'warning';
10
10
  variant?: 'solid' | 'soft';
11
+ src?: string;
12
+ name?: string;
13
+ alt?: string;
14
+ avatarSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
15
+ status?: 'online' | 'offline' | 'busy' | 'away';
16
+ isBordered?: boolean;
11
17
  };
12
18
  declare const Alert: import("svelte").Component<Props, {}, "">;
13
19
  type Alert = ReturnType<typeof Alert>;
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { slide } from 'svelte/transition';
3
3
 
4
- import { Icon, IconButton, toast } from '../index.js';
4
+ import { Avatar, IconButton, toast, type IconData } from '../index.js';
5
5
  import { cn } from '../utils/class-names.js';
6
6
  import { popover } from '../utils/popover.js';
7
7
  import {
@@ -12,6 +12,19 @@
12
12
  Warning24RegularIcon
13
13
  } from '../icons/index.js';
14
14
 
15
+ const DEFAULT_ICONS: Record<
16
+ 'primary' | 'secondary' | 'muted' | 'info' | 'success' | 'warning' | 'danger',
17
+ IconData
18
+ > = {
19
+ primary: Info24RegularIcon,
20
+ secondary: Info24RegularIcon,
21
+ muted: Info24RegularIcon,
22
+ info: Info24RegularIcon,
23
+ success: CheckmarkCircle24RegularIcon,
24
+ warning: Warning24RegularIcon,
25
+ danger: DismissCircle24RegularIcon
26
+ };
27
+
15
28
  type Props = {
16
29
  class?: string;
17
30
  position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
@@ -75,16 +88,19 @@
75
88
  )}
76
89
  style="--toast-index: {index}; --toast-total: {toast.messages.length}"
77
90
  >
78
- {#if showIcon}
79
- {#if message.color === 'info'}
80
- <Icon icon={Info24RegularIcon} class="toast-icon" />
81
- {:else if message.color === 'success'}
82
- <Icon icon={CheckmarkCircle24RegularIcon} class="toast-icon" />
83
- {:else if message.color === 'warning'}
84
- <Icon icon={Warning24RegularIcon} class="toast-icon" />
85
- {:else if message.color === 'danger'}
86
- <Icon icon={DismissCircle24RegularIcon} class="toast-icon" />
87
- {/if}
91
+ {#if showIcon || message.src || message.name}
92
+ <Avatar
93
+ src={message.src}
94
+ name={message.name}
95
+ alt={message.alt}
96
+ icon={message.icon ?? DEFAULT_ICONS[message.color as keyof typeof DEFAULT_ICONS]}
97
+ size={message.avatarSize || 'md'}
98
+ status={message.status}
99
+ isBordered={message.isBordered}
100
+ color={message.color}
101
+ variant={message.variant || variant}
102
+ class="toast-icon"
103
+ />
88
104
  {/if}
89
105
  <div class="toast-content">
90
106
  {#if message.title}
@@ -1,4 +1,4 @@
1
- import type { IconData } from "../index.js";
1
+ import type { IconData } from '../index.js';
2
2
  export interface ToastMessage {
3
3
  id: string;
4
4
  icon?: IconData;
@@ -8,6 +8,12 @@ export interface ToastMessage {
8
8
  position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
9
9
  variant?: 'solid' | 'soft';
10
10
  color: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'danger' | 'warning';
11
+ src?: string;
12
+ name?: string;
13
+ alt?: string;
14
+ avatarSize?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
15
+ status?: 'online' | 'offline' | 'busy' | 'away';
16
+ isBordered?: boolean;
11
17
  }
12
18
  export declare const toast: {
13
19
  readonly messages: ToastMessage[];
@@ -12,7 +12,13 @@ const toastShow = (message) => {
12
12
  duration: message.duration || 0,
13
13
  icon: message.icon,
14
14
  position: message.position,
15
- variant: message.variant || 'soft'
15
+ variant: message.variant || 'soft',
16
+ src: message.src,
17
+ name: message.name,
18
+ alt: message.alt,
19
+ avatarSize: message.avatarSize || 'md',
20
+ status: message.status,
21
+ isBordered: message.isBordered
16
22
  };
17
23
  toastMessages = [...toastMessages, newMessage];
18
24
  if (newMessage.duration && newMessage.duration > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui-svelte",
3
- "version": "0.2.24",
3
+ "version": "0.2.26",
4
4
  "author": {
5
5
  "name": "SappsDev",
6
6
  "email": "info@sappsdev.com"