ui-svelte 0.2.23 → 0.2.24

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.
@@ -10,6 +10,8 @@
10
10
  icon: IconData;
11
11
  label?: string;
12
12
  color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'danger' | 'warning';
13
+ href?: string;
14
+ target?: '_blank' | '_self' | '_parent' | '_top';
13
15
  onclick?: () => void;
14
16
  };
15
17
 
@@ -80,16 +82,30 @@
80
82
  style="--fab-action-index: {index}; --fab-action-delay: {index * 50}ms"
81
83
  transition:slide={{ duration: 150, delay: index * 50 }}
82
84
  >
83
- {#if action.label}
84
- <span class="fab-action-label">{action.label}</span>
85
+ {#if action.href}
86
+ <a
87
+ href={action.href}
88
+ target={action.target}
89
+ class="fab-action-link"
90
+ onclick={() => handleActionClick(action)}
91
+ >
92
+ {#if action.label}
93
+ <span class="fab-action-label">{action.label}</span>
94
+ {/if}
95
+ <IconButton icon={action.icon} color={action.color ?? 'muted'} {variant} size="md" />
96
+ </a>
97
+ {:else}
98
+ {#if action.label}
99
+ <span class="fab-action-label">{action.label}</span>
100
+ {/if}
101
+ <IconButton
102
+ icon={action.icon}
103
+ color={action.color ?? 'muted'}
104
+ {variant}
105
+ size="md"
106
+ onclick={() => handleActionClick(action)}
107
+ />
85
108
  {/if}
86
- <IconButton
87
- icon={action.icon}
88
- color={action.color ?? 'muted'}
89
- {variant}
90
- size="md"
91
- onclick={() => handleActionClick(action)}
92
- />
93
109
  </div>
94
110
  {/each}
95
111
  </div>
@@ -4,6 +4,8 @@ export type FabAction = {
4
4
  icon: IconData;
5
5
  label?: string;
6
6
  color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'danger' | 'warning';
7
+ href?: string;
8
+ target?: '_blank' | '_self' | '_parent' | '_top';
7
9
  onclick?: () => void;
8
10
  };
9
11
  type Props = {
@@ -81,4 +81,8 @@
81
81
  @apply ml-3 px-3 py-1.5 text-sm font-medium whitespace-nowrap;
82
82
  @apply bg-surface text-on-surface rounded-ui shadow-md;
83
83
  }
84
+
85
+ .fab-action-link {
86
+ @apply flex items-center no-underline;
87
+ }
84
88
  }
@@ -0,0 +1,8 @@
1
+ type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
2
+ export declare const useBreakpoint: (breakpoint: Breakpoint) => {
3
+ readonly isBelow: boolean;
4
+ readonly isAbove: boolean;
5
+ readonly width: number;
6
+ readonly breakpointValue: number;
7
+ };
8
+ export {};
@@ -0,0 +1,40 @@
1
+ const breakpoints = {
2
+ xs: 0,
3
+ sm: 640,
4
+ md: 768,
5
+ lg: 1024,
6
+ xl: 1280,
7
+ '2xl': 1536
8
+ };
9
+ export const useBreakpoint = (breakpoint) => {
10
+ let isBelow = $state(false);
11
+ let isAbove = $state(false);
12
+ let currentWidth = $state(0);
13
+ const updateBreakpoint = () => {
14
+ currentWidth = window.innerWidth;
15
+ const breakpointValue = breakpoints[breakpoint];
16
+ isBelow = currentWidth < breakpointValue;
17
+ isAbove = currentWidth >= breakpointValue;
18
+ };
19
+ $effect(() => {
20
+ updateBreakpoint();
21
+ window.addEventListener('resize', updateBreakpoint);
22
+ return () => {
23
+ window.removeEventListener('resize', updateBreakpoint);
24
+ };
25
+ });
26
+ return {
27
+ get isBelow() {
28
+ return isBelow;
29
+ },
30
+ get isAbove() {
31
+ return isAbove;
32
+ },
33
+ get width() {
34
+ return currentWidth;
35
+ },
36
+ get breakpointValue() {
37
+ return breakpoints[breakpoint];
38
+ }
39
+ };
40
+ };
package/dist/index.d.ts CHANGED
@@ -86,5 +86,6 @@ import { useAuth } from './hooks/use-auth.svelte.js';
86
86
  import { theme } from './stores/theme.svelte.js';
87
87
  import { useSearch } from './hooks/use-search.svelte.js';
88
88
  import { useChat } from './hooks/use-chat.svelte.js';
89
- export { AreaChart, ArcChart, BarChart, Candlestick, LineChart, PieChart, Alert, AlertDialog, AppBar, Accordion, Avatar, AvatarGroup, Audio, Badge, Button, BottomNav, Carousel, Card, ChatBox, Checkbox, Chip, Code, Countdown, ColorField, Collapsible, Command, ComboBox, CsvField, DateField, DateRange, Drawer, Dropzone, Divider, DragDrop, Dropdown, Editor, Empty, Fab, Footer, FooterNav, FooterGroup, formatCurrency, formatDate, formatNumber, getWeekdays, i18n, Icon, IconButton, Image, ImageCropper, Item, initLanguage, Modal, Map, Marquee, NavMenu, Pagination, PasswordField, PhoneField, PinField, plural, PopoverStack, Provider, RadioGroup, Record, Scaffold, Section, Skeleton, Select, setLanguage, Sidebar, SideNav, Slider, t, Table, Tabs, TextField, Textarea, theme, Toast, toast, Toggle, ToggleGroup, ToggleTheme, Tooltip, useAuth, useChat, useClipboard, useFetch, useForm, useLocalStorage, useScroll, useSearch, useTable, useWebSocket, Video };
89
+ import { useBreakpoint } from './hooks/use-breakpoint.svelte.js';
90
+ export { AreaChart, ArcChart, BarChart, Candlestick, LineChart, PieChart, Alert, AlertDialog, AppBar, Accordion, Avatar, AvatarGroup, Audio, Badge, Button, BottomNav, Carousel, Card, ChatBox, Checkbox, Chip, Code, Countdown, ColorField, Collapsible, Command, ComboBox, CsvField, DateField, DateRange, Drawer, Dropzone, Divider, DragDrop, Dropdown, Editor, Empty, Fab, Footer, FooterNav, FooterGroup, formatCurrency, formatDate, formatNumber, getWeekdays, i18n, Icon, IconButton, Image, ImageCropper, Item, initLanguage, Modal, Map, Marquee, NavMenu, Pagination, PasswordField, PhoneField, PinField, plural, PopoverStack, Provider, RadioGroup, Record, Scaffold, Section, Skeleton, Select, setLanguage, Sidebar, SideNav, Slider, t, Table, Tabs, TextField, Textarea, theme, Toast, toast, Toggle, ToggleGroup, ToggleTheme, Tooltip, useAuth, useBreakpoint, useChat, useClipboard, useFetch, useForm, useLocalStorage, useScroll, useSearch, useTable, useWebSocket, Video };
90
91
  export type { IconData, SideNavItem, SideNavSubItem, DragDropItem, DragDropGroup, PromptMessage, PromptState, LatLng, MapMarker, RouteInfo, FabAction };
package/dist/index.js CHANGED
@@ -86,4 +86,5 @@ import { useAuth } from './hooks/use-auth.svelte.js';
86
86
  import { theme } from './stores/theme.svelte.js';
87
87
  import { useSearch } from './hooks/use-search.svelte.js';
88
88
  import { useChat } from './hooks/use-chat.svelte.js';
89
- export { AreaChart, ArcChart, BarChart, Candlestick, LineChart, PieChart, Alert, AlertDialog, AppBar, Accordion, Avatar, AvatarGroup, Audio, Badge, Button, BottomNav, Carousel, Card, ChatBox, Checkbox, Chip, Code, Countdown, ColorField, Collapsible, Command, ComboBox, CsvField, DateField, DateRange, Drawer, Dropzone, Divider, DragDrop, Dropdown, Editor, Empty, Fab, Footer, FooterNav, FooterGroup, formatCurrency, formatDate, formatNumber, getWeekdays, i18n, Icon, IconButton, Image, ImageCropper, Item, initLanguage, Modal, Map, Marquee, NavMenu, Pagination, PasswordField, PhoneField, PinField, plural, PopoverStack, Provider, RadioGroup, Record, Scaffold, Section, Skeleton, Select, setLanguage, Sidebar, SideNav, Slider, t, Table, Tabs, TextField, Textarea, theme, Toast, toast, Toggle, ToggleGroup, ToggleTheme, Tooltip, useAuth, useChat, useClipboard, useFetch, useForm, useLocalStorage, useScroll, useSearch, useTable, useWebSocket, Video };
89
+ import { useBreakpoint } from './hooks/use-breakpoint.svelte.js';
90
+ export { AreaChart, ArcChart, BarChart, Candlestick, LineChart, PieChart, Alert, AlertDialog, AppBar, Accordion, Avatar, AvatarGroup, Audio, Badge, Button, BottomNav, Carousel, Card, ChatBox, Checkbox, Chip, Code, Countdown, ColorField, Collapsible, Command, ComboBox, CsvField, DateField, DateRange, Drawer, Dropzone, Divider, DragDrop, Dropdown, Editor, Empty, Fab, Footer, FooterNav, FooterGroup, formatCurrency, formatDate, formatNumber, getWeekdays, i18n, Icon, IconButton, Image, ImageCropper, Item, initLanguage, Modal, Map, Marquee, NavMenu, Pagination, PasswordField, PhoneField, PinField, plural, PopoverStack, Provider, RadioGroup, Record, Scaffold, Section, Skeleton, Select, setLanguage, Sidebar, SideNav, Slider, t, Table, Tabs, TextField, Textarea, theme, Toast, toast, Toggle, ToggleGroup, ToggleTheme, Tooltip, useAuth, useBreakpoint, useChat, useClipboard, useFetch, useForm, useLocalStorage, useScroll, useSearch, useTable, useWebSocket, Video };
@@ -2,11 +2,15 @@
2
2
  import { cn } from '../utils/class-names.js';
3
3
  import { useScroll } from '../hooks/use-scroll.svelte.js';
4
4
  import type { Snippet } from 'svelte';
5
+ import { afterNavigate } from '$app/navigation';
5
6
 
6
7
  type Props = {
7
8
  start?: Snippet;
8
9
  center?: Snippet;
9
10
  end?: Snippet;
11
+ popoverContent?: Snippet;
12
+ popoverOpen?: boolean;
13
+ popoverClass?: string;
10
14
  rootClass?: string;
11
15
  contentClass?: string;
12
16
  startClass?: string;
@@ -33,10 +37,13 @@
33
37
  isBoxed?: boolean;
34
38
  };
35
39
 
36
- const {
40
+ let {
37
41
  start,
38
42
  center,
39
43
  end,
44
+ popoverContent,
45
+ popoverOpen = $bindable(false),
46
+ popoverClass,
40
47
  rootClass,
41
48
  contentClass,
42
49
  startClass,
@@ -78,6 +85,14 @@
78
85
  soft: 'is-soft'
79
86
  };
80
87
 
88
+ $effect(() => {
89
+ afterNavigate(() => {
90
+ if (popoverOpen) {
91
+ popoverOpen = false;
92
+ }
93
+ });
94
+ });
95
+
81
96
  $effect(() => {
82
97
  if (headerElement) {
83
98
  headerHeight = headerElement.offsetHeight;
@@ -124,6 +139,7 @@
124
139
  isSticky && 'is-sticky',
125
140
  isFloating && 'is-floating-enabled',
126
141
  isFloatingActive && 'is-floating',
142
+ popoverContent && 'has-popover',
127
143
  rootClass
128
144
  )}
129
145
  >
@@ -144,4 +160,10 @@
144
160
  </div>
145
161
  {/if}
146
162
  </div>
163
+
164
+ {#if popoverContent}
165
+ <div class={cn('appbar-popover', popoverOpen && 'is-open', popoverClass)}>
166
+ {@render popoverContent()}
167
+ </div>
168
+ {/if}
147
169
  </header>
@@ -3,6 +3,9 @@ type Props = {
3
3
  start?: Snippet;
4
4
  center?: Snippet;
5
5
  end?: Snippet;
6
+ popoverContent?: Snippet;
7
+ popoverOpen?: boolean;
8
+ popoverClass?: string;
6
9
  rootClass?: string;
7
10
  contentClass?: string;
8
11
  startClass?: string;
@@ -19,6 +22,6 @@ type Props = {
19
22
  isFloating?: boolean;
20
23
  isBoxed?: boolean;
21
24
  };
22
- declare const AppBar: import("svelte").Component<Props, {}, "">;
25
+ declare const AppBar: import("svelte").Component<Props, {}, "popoverOpen">;
23
26
  type AppBar = ReturnType<typeof AppBar>;
24
27
  export default AppBar;
@@ -21,7 +21,7 @@
21
21
  | 'warning'
22
22
  | 'danger'
23
23
  | 'surface'
24
- | 'default';
24
+ | 'background';
25
25
  variant?: 'solid' | 'soft';
26
26
  isBlurred?: boolean;
27
27
  isBordered?: boolean;
@@ -38,8 +38,8 @@
38
38
  startClass,
39
39
  centerClass,
40
40
  endClass,
41
- color = 'default',
42
- variant = 'soft',
41
+ color = 'surface',
42
+ variant = 'solid',
43
43
  isBordered,
44
44
  isBlurred,
45
45
  isBoxed,
@@ -62,7 +62,7 @@
62
62
  warning: 'is-warning',
63
63
  danger: 'is-danger',
64
64
  surface: 'is-surface',
65
- default: 'is-default'
65
+ background: 'is-background'
66
66
  };
67
67
 
68
68
  const variants = {
@@ -8,7 +8,7 @@ type Props = {
8
8
  startClass?: string;
9
9
  centerClass?: string;
10
10
  endClass?: string;
11
- color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'warning' | 'danger' | 'surface' | 'default';
11
+ color?: 'primary' | 'secondary' | 'muted' | 'success' | 'info' | 'warning' | 'danger' | 'surface' | 'background';
12
12
  variant?: 'solid' | 'soft';
13
13
  isBlurred?: boolean;
14
14
  isBordered?: boolean;
@@ -1,6 +1,6 @@
1
1
  @layer components {
2
2
  .appbar {
3
- @apply w-full z-30 transition-all duration-300;
3
+ @apply w-full z-30 transition-all duration-300 relative;
4
4
  padding-top: env(safe-area-inset-top, 0px);
5
5
 
6
6
  &.is-sticky {
@@ -112,5 +112,25 @@
112
112
  @apply flex flex-nowrap justify-end items-center p-3 gap-3 relative;
113
113
  }
114
114
  }
115
+
116
+ .appbar-popover {
117
+ @apply absolute left-0 right-0 w-full;
118
+ @apply transition-all duration-300 ease-in-out;
119
+ @apply flex flex-col gap-2 p-3;
120
+ @apply bg-inherit;
121
+ @apply shadow-lg shadow-muted/20;
122
+ @apply rounded-b-box;
123
+ top: 100%;
124
+ z-index: 9999;
125
+ opacity: 0;
126
+ visibility: hidden;
127
+ transform: translateY(-0.5rem);
128
+
129
+ &.is-open {
130
+ opacity: 1;
131
+ visibility: visible;
132
+ transform: translateY(0);
133
+ }
134
+ }
115
135
  }
116
136
  }
@@ -67,7 +67,7 @@
67
67
  &.is-danger {
68
68
  @apply bg-danger text-on-danger;
69
69
  }
70
- &.is-default {
70
+ &.is-background {
71
71
  @apply bg-background text-on-background;
72
72
  }
73
73
  &.is-surface {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui-svelte",
3
- "version": "0.2.23",
3
+ "version": "0.2.24",
4
4
  "author": {
5
5
  "name": "SappsDev",
6
6
  "email": "info@sappsdev.com"
@@ -67,4 +67,4 @@
67
67
  "svelte": "./dist/index.js",
68
68
  "type": "module",
69
69
  "types": "./dist/index.d.ts"
70
- }
70
+ }