uisv 0.0.22 → 0.0.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.
Files changed (57) hide show
  1. package/dist/components/accordion.svelte +6 -19
  2. package/dist/components/alert.svelte +58 -55
  3. package/dist/components/alert.svelte.d.ts +2 -2
  4. package/dist/components/app.svelte +28 -22
  5. package/dist/components/app.svelte.d.ts +2 -9
  6. package/dist/components/badge.svelte +16 -16
  7. package/dist/components/badge.svelte.d.ts +4 -2
  8. package/dist/components/banner.svelte +11 -15
  9. package/dist/components/banner.svelte.d.ts +2 -2
  10. package/dist/components/breadcrumb.svelte +3 -4
  11. package/dist/components/breadcrumb.svelte.d.ts +1 -1
  12. package/dist/components/button.svelte +10 -8
  13. package/dist/components/card.svelte +1 -1
  14. package/dist/components/checkbox-group.svelte +3 -5
  15. package/dist/components/checkbox-group.svelte.d.ts +3 -3
  16. package/dist/components/checkbox.svelte +12 -22
  17. package/dist/components/checkbox.svelte.d.ts +4 -5
  18. package/dist/components/collapsible.svelte +3 -1
  19. package/dist/components/index.d.ts +5 -0
  20. package/dist/components/index.js +5 -0
  21. package/dist/components/input-number.svelte +3 -2
  22. package/dist/components/input.svelte +9 -18
  23. package/dist/components/kbd.svelte +8 -8
  24. package/dist/components/modal.svelte +2 -2
  25. package/dist/components/navigation-menu.svelte +416 -0
  26. package/dist/components/navigation-menu.svelte.d.ts +20 -0
  27. package/dist/components/progress.svelte +42 -7
  28. package/dist/components/progress.svelte.d.ts +3 -2
  29. package/dist/components/radio-group.svelte +102 -0
  30. package/dist/components/radio-group.svelte.d.ts +27 -0
  31. package/dist/components/select.svelte +19 -11
  32. package/dist/components/select.svelte.d.ts +5 -6
  33. package/dist/components/seperator.svelte +1 -1
  34. package/dist/components/switch.svelte +2 -1
  35. package/dist/components/tabs.svelte +3 -13
  36. package/dist/components/tabs.svelte.d.ts +1 -1
  37. package/dist/components/toast.svelte +173 -0
  38. package/dist/components/toast.svelte.d.ts +8 -0
  39. package/dist/components/toast.svelte.js +11 -0
  40. package/dist/contexts.d.ts +10 -3
  41. package/dist/contexts.js +2 -2
  42. package/dist/index.d.ts +1 -2
  43. package/dist/index.js +1 -2
  44. package/dist/utilities/index.d.ts +5 -0
  45. package/dist/utilities/index.js +5 -0
  46. package/dist/utilities/isComponent.d.ts +7 -0
  47. package/dist/utilities/isComponent.js +10 -0
  48. package/dist/utilities/isSnippet.d.ts +7 -0
  49. package/dist/utilities/isSnippet.js +8 -0
  50. package/dist/utilities/useElementRects.svelte.d.ts +11 -0
  51. package/dist/{utilities.svelte.js → utilities/useElementRects.svelte.js} +0 -38
  52. package/dist/utilities/useRafFn.svelte.d.ts +43 -0
  53. package/dist/utilities/useRafFn.svelte.js +56 -0
  54. package/dist/utilities/useStyle.svelte.d.ts +8 -0
  55. package/dist/utilities/useStyle.svelte.js +21 -0
  56. package/package.json +37 -27
  57. package/dist/utilities.svelte.d.ts +0 -31
@@ -4,7 +4,7 @@
4
4
  // import { FORM_LOADING_CONTEXT_KEY } from '../utils/keys.js';
5
5
  import type { SvelteHTMLElements } from 'svelte/elements';
6
6
  import { tv, type ClassValue } from 'tailwind-variants';
7
- import { app_icons } from '../contexts.js';
7
+ import { getAppContext } from '../contexts.js';
8
8
 
9
9
  export type ButtonBaseProps = {
10
10
  /** The underlying DOM element being rendered. You can bind to this to get a reference to the element. */
@@ -80,7 +80,7 @@
80
80
  href,
81
81
  icon,
82
82
  loading,
83
- loadingicon = app_icons.get().loading,
83
+ loadingicon = getAppContext().icons.loading,
84
84
  type,
85
85
  trailingicon,
86
86
  leadingicon,
@@ -94,7 +94,7 @@
94
94
  return false;
95
95
  });
96
96
 
97
- const classnames = $derived(
97
+ const variants = $derived(
98
98
  tv({
99
99
  slots: {
100
100
  icon: '',
@@ -124,7 +124,7 @@
124
124
  },
125
125
  sm: { base: 'font-medium text-xs px-2 h-7 rounded gap-1', icon: 'size-4' },
126
126
  md: { base: 'font-medium text-sm rounded-md px-2 h-8 gap-2', icon: 'size-5' },
127
- lg: { base: 'font-medium text-sm px-3 h-9 rounded-md gap-2', icon: 'size-6' },
127
+ lg: { base: 'font-medium text-sm px-3 h-9 rounded-md gap-2', icon: 'size-5' },
128
128
  xl: { base: 'font-medium px-3 h-10 rounded-md gap-2', icon: 'size-6' },
129
129
  },
130
130
  block: {
@@ -353,14 +353,14 @@
353
353
 
354
354
  <svelte:element
355
355
  this={href ? 'a' : 'button'}
356
+ bind:this={ref}
356
357
  type={href ? undefined : type}
357
358
  href={href && !disabled ? href : undefined}
358
359
  disabled={disabled || is_loading}
359
360
  aria-disabled={href ? disabled : undefined}
360
361
  role={href && disabled ? 'link' : undefined}
361
362
  tabindex={href && disabled ? -1 : 0}
362
- bind:this={ref}
363
- class={classnames.base({
363
+ class={variants.base({
364
364
  class: [only_icon && 'px-0 aspect-square justify-center', href && 'cursor-pointer', ui.base],
365
365
  })}
366
366
  onclick={onClickWrapper}
@@ -369,7 +369,9 @@
369
369
  {#if iconposition === 'leading' || leadingicon || loading}
370
370
  <Icon
371
371
  name={is_loading ? loadingicon : leadingicon || icon}
372
- class={[ui.leadingicon, loading && 'animate-spin', iconposition === 'leading' && ui.icon]}
372
+ class={variants.icon({
373
+ class: [ui.leadingicon, loading && 'animate-spin', iconposition === 'leading' && ui.icon],
374
+ })}
373
375
  />
374
376
  {/if}
375
377
 
@@ -382,7 +384,7 @@
382
384
  {#if iconposition === 'trailing' || trailingicon}
383
385
  <Icon
384
386
  name={trailingicon || icon}
385
- class={[ui.trailingicon, iconposition === 'trailing' && ui.icon]}
387
+ class={variants.icon({ class: [ui.trailingicon, iconposition === 'trailing' && ui.icon] })}
386
388
  />
387
389
  {/if}
388
390
  </svelte:element>
@@ -63,7 +63,7 @@
63
63
  </div>
64
64
 
65
65
  {#if footer}
66
- <div class={variants.header({ class: [ui.header] })}>
66
+ <div class={variants.footer({ class: [ui.footer] })}>
67
67
  {@render footer()}
68
68
  </div>
69
69
  {/if}
@@ -3,18 +3,16 @@
3
3
  import type { Component, Snippet } from 'svelte';
4
4
  import { type PropColor, isComponent, isSnippet, Checkbox } from '../index.js';
5
5
 
6
- /* eslint @typescript-eslint/no-explicit-any: 0 */
7
-
8
6
  export type CheckboxGroupProps = {
9
7
  color?: PropColor;
10
8
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
11
- icon?: string | Snippet | Component;
9
+ icon?: string | Component;
12
10
  required?: boolean;
13
11
  indicator?: 'start' | 'end' | 'hidden';
14
- value?: any[];
12
+ value?: string[];
15
13
  valuekey?: string;
16
14
  variant?: 'list' | 'card' | 'table';
17
- items: Array<any>;
15
+ items: Array<string>;
18
16
  labelkey?: string;
19
17
  descriptionkey?: string;
20
18
  legend?: string | Snippet | Component;
@@ -4,13 +4,13 @@ import { type PropColor } from '../index.js';
4
4
  export type CheckboxGroupProps = {
5
5
  color?: PropColor;
6
6
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
7
- icon?: string | Snippet | Component;
7
+ icon?: string | Component;
8
8
  required?: boolean;
9
9
  indicator?: 'start' | 'end' | 'hidden';
10
- value?: any[];
10
+ value?: string[];
11
11
  valuekey?: string;
12
12
  variant?: 'list' | 'card' | 'table';
13
- items: Array<any>;
13
+ items: Array<string>;
14
14
  labelkey?: string;
15
15
  descriptionkey?: string;
16
16
  legend?: string | Snippet | Component;
@@ -1,16 +1,17 @@
1
1
  <script module lang="ts">
2
- import { type PropColor, isComponent, isSnippet } from '../index.js';
3
- import type { Snippet } from 'svelte';
2
+ import { getAppContext } from '../contexts.js';
3
+ import { type PropColor } from '../index.js';
4
+ import type { Snippet, Component } from 'svelte';
4
5
  import { tv, type ClassValue } from 'tailwind-variants';
5
- import type { Component } from 'vitest-browser-svelte';
6
+ import Icon from './icon.svelte';
6
7
 
7
8
  export type CheckboxProps = {
8
9
  value?: boolean | 'intermediate';
9
10
  color?: PropColor;
10
11
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
11
12
  disabled?: boolean;
12
- icon?: string | Snippet | Component;
13
- intermediateicon?: string | Snippet | Component;
13
+ icon?: string | Component;
14
+ intermediateicon?: string | Component;
14
15
  label?: string | Snippet;
15
16
  description?: string | Snippet;
16
17
  required?: boolean;
@@ -32,8 +33,8 @@
32
33
  color = 'primary',
33
34
  size = 'md',
34
35
  disabled,
35
- icon = 'i-lucide-check',
36
- intermediateicon = 'i-lucide-minus',
36
+ icon = getAppContext().icons.check,
37
+ intermediateicon = getAppContext().icons.minus,
37
38
  label,
38
39
  description,
39
40
  required,
@@ -130,8 +131,10 @@
130
131
  value = !value;
131
132
  }}
132
133
  >
133
- {@render Icon(icon, [value !== true && 'opacity-0'])}
134
- {@render Icon(intermediateicon, [value !== 'intermediate' && 'opacity-0'])}
134
+ <Icon
135
+ name={value === 'intermediate' ? intermediateicon : value !== true ? icon : undefined}
136
+ class={variants.icon({ class: [ui.icon] })}
137
+ />
135
138
  </button>
136
139
 
137
140
  {#if label}
@@ -161,16 +164,3 @@
161
164
  </div>
162
165
  {/if}
163
166
  </svelte:element>
164
-
165
- {#snippet Icon(ico?: CheckboxProps['icon'], icon_class?: ClassValue)}
166
- <div class={['absolute', icon_class]}>
167
- {#if typeof ico === 'string'}
168
- <div class={variants.icon({ class: [ico, ui.icon] })}></div>
169
- {:else if isSnippet(ico)}
170
- {@render ico()}
171
- {:else if isComponent(ico)}
172
- {@const Iconn = ico}
173
- <Iconn />
174
- {/if}
175
- </div>
176
- {/snippet}
@@ -1,14 +1,13 @@
1
1
  import { type PropColor } from '../index.js';
2
- import type { Snippet } from 'svelte';
2
+ import type { Snippet, Component } from 'svelte';
3
3
  import { type ClassValue } from 'tailwind-variants';
4
- import type { Component } from 'vitest-browser-svelte';
5
4
  export type CheckboxProps = {
6
5
  value?: boolean | 'intermediate';
7
6
  color?: PropColor;
8
7
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
9
8
  disabled?: boolean;
10
- icon?: string | Snippet | Component;
11
- intermediateicon?: string | Snippet | Component;
9
+ icon?: string | Component;
10
+ intermediateicon?: string | Component;
12
11
  label?: string | Snippet;
13
12
  description?: string | Snippet;
14
13
  required?: boolean;
@@ -22,6 +21,6 @@ export type CheckboxProps = {
22
21
  description?: ClassValue;
23
22
  };
24
23
  };
25
- declare const Checkbox: import("svelte").Component<CheckboxProps, {}, "value">;
24
+ declare const Checkbox: Component<CheckboxProps, {}, "value">;
26
25
  type Checkbox = ReturnType<typeof Checkbox>;
27
26
  export default Checkbox;
@@ -16,6 +16,8 @@
16
16
  </script>
17
17
 
18
18
  <script lang="ts">
19
+ import { getAppContext } from '../contexts.js';
20
+
19
21
  let {
20
22
  open = $bindable(false),
21
23
  children,
@@ -40,7 +42,7 @@
40
42
  {#snippet child({ props })}
41
43
  <Button
42
44
  {...props}
43
- trailingicon="i-lucide-chevron-down"
45
+ trailingicon={getAppContext().icons.chevrondown}
44
46
  {...rest}
45
47
  block
46
48
  ui={defu(ui, { trailingicon: 'ms-auto' })}
@@ -61,3 +61,8 @@ export * from './tooltip.svelte';
61
61
  export { default as Tooltip } from './tooltip.svelte';
62
62
  export * from './app.svelte';
63
63
  export { default as App } from './app.svelte';
64
+ export * from './toast.svelte.js';
65
+ export * from './popover.svelte';
66
+ export { default as Popover } from './popover.svelte';
67
+ export * from './radio-group.svelte';
68
+ export { default as RadioGroup } from './radio-group.svelte';
@@ -61,3 +61,8 @@ export * from './tooltip.svelte';
61
61
  export { default as Tooltip } from './tooltip.svelte';
62
62
  export * from './app.svelte';
63
63
  export { default as App } from './app.svelte';
64
+ export * from './toast.svelte.js';
65
+ export * from './popover.svelte';
66
+ export { default as Popover } from './popover.svelte';
67
+ export * from './radio-group.svelte';
68
+ export { default as RadioGroup } from './radio-group.svelte';
@@ -9,6 +9,7 @@
9
9
  import type { SvelteHTMLElements } from 'svelte/elements';
10
10
  import { tv, type ClassValue } from 'tailwind-variants';
11
11
  import { useId } from 'bits-ui';
12
+ import { getAppContext } from '../contexts.js';
12
13
 
13
14
  export type InputNumberProps = Omit<SvelteHTMLElements['input'], 'size' | 'value'> & {
14
15
  value?: number;
@@ -154,7 +155,7 @@
154
155
  {#if increment}
155
156
  <Button
156
157
  variant="link"
157
- icon="i-lucide:minus"
158
+ icon={getAppContext().icons.minus}
158
159
  onclick={() => {
159
160
  value = value === undefined ? 0 : value - 1;
160
161
  }}
@@ -164,7 +165,7 @@
164
165
  {#if increment}
165
166
  <Button
166
167
  variant="link"
167
- icon="i-lucide:plus"
168
+ icon={getAppContext().icons.plus}
168
169
  onclick={() => {
169
170
  value = value === undefined ? 0 : value + 1;
170
171
  }}
@@ -1,10 +1,11 @@
1
1
  <script module lang="ts">
2
- import { type PropColor, type PropVariant, isComponent, isSnippet } from '../index.js';
2
+ import { type PropColor, type PropVariant, isComponent, isSnippet, Icon } from '../index.js';
3
3
  import type { Component, Snippet } from 'svelte';
4
4
  import type { SvelteHTMLElements } from 'svelte/elements';
5
5
  import { maska } from 'maska/svelte';
6
6
  import { type MaskInputOptions } from 'maska';
7
7
  import { tv, type ClassValue } from 'tailwind-variants';
8
+ import { getAppContext } from '../contexts.js';
8
9
 
9
10
  export type InputProps = Omit<SvelteHTMLElements['input'], 'size'> & {
10
11
  name?: string;
@@ -56,8 +57,6 @@
56
57
  </script>
57
58
 
58
59
  <script lang="ts">
59
- import Icon from './icon.svelte';
60
-
61
60
  let {
62
61
  type,
63
62
  value = $bindable(),
@@ -70,7 +69,7 @@
70
69
  highlight,
71
70
  leading,
72
71
  loading,
73
- loadingicon = 'i-lucide-loader-circle',
72
+ loadingicon = getAppContext().icons.loading,
74
73
  required,
75
74
  trailing,
76
75
  mask,
@@ -132,7 +131,7 @@
132
131
  },
133
132
  },
134
133
  variant: {
135
- outline: { root: 'ring ring-dimmed' },
134
+ outline: { root: 'ring ring-surface-accented' },
136
135
  soft: {
137
136
  root: 'bg-surface-muted hover:bg-surface-elevated focus-within:bg-surface-elevated',
138
137
  },
@@ -223,7 +222,7 @@
223
222
 
224
223
  <div class={variants.root({ class: ui.root })}>
225
224
  {#if leading || (icon && iconposition === 'leading') || loading}
226
- {@const TrailingIcon = loading ? loadingicon : icon}
225
+ {@const leadingicon = loading ? loadingicon : icon}
227
226
 
228
227
  <span class={variants.leading({ class: ui.leading })}>
229
228
  {#if !!leading && !loading}
@@ -237,7 +236,7 @@
237
236
  {/if}
238
237
  {:else}
239
238
  <Icon
240
- name={TrailingIcon}
239
+ name={leadingicon}
241
240
  class={variants.icon({ class: [loading ? 'animate-spin' : ''] })}
242
241
  />
243
242
  {/if}
@@ -251,6 +250,7 @@
251
250
  class={variants.base({ class: [ui.base] })}
252
251
  {...rest}
253
252
  use:maska={mask}
253
+ bind:value
254
254
  />
255
255
 
256
256
  {#if trailing || (icon && iconposition === 'trailing')}
@@ -264,17 +264,8 @@
264
264
  {:else if isSnippet(trailing)}
265
265
  {@render trailing()}
266
266
  {/if}
267
- {:else if typeof icon === 'string'}
268
- <div
269
- class={variants.icon({
270
- class: [icon, ui.icon],
271
- })}
272
- ></div>
273
- {:else if isSnippet(icon)}
274
- {@render icon()}
275
- {:else if isComponent(icon)}
276
- {@const Icon = icon}
277
- <Icon class={variants.icon({ class: [ui.icon] })} />
267
+ {:else}
268
+ <Icon name={icon} class={variants.icon({ class: [ui.icon] })} />
278
269
  {/if}
279
270
  </span>
280
271
  {/if}
@@ -57,16 +57,16 @@
57
57
  return navigator.userAgent.match(/Macintosh;/);
58
58
  });
59
59
 
60
- const kbdKeysSpecificMap = $derived({
61
- meta: macOS ? KBD_KEYS.command : 'Ctrl',
62
- alt: macOS ? KBD_KEYS.command : 'Ctrl',
63
- ctrl: macOS ? KBD_KEYS.option : 'Alt',
60
+ const kbdKeysSpecificMap = $derived.by(() => {
61
+ return {
62
+ meta: macOS?.length ? KBD_KEYS.command : 'Ctrl',
63
+ alt: macOS?.length ? KBD_KEYS.command : 'Ctrl',
64
+ ctrl: macOS?.length ? KBD_KEYS.option : 'Alt',
65
+ };
64
66
  });
65
67
 
66
- function getKey(value?: KbdKey | string) {
67
- if (!value) {
68
- return;
69
- }
68
+ function getKey(value: KbdKey | string | undefined) {
69
+ if (!value) return;
70
70
 
71
71
  if (['meta', 'alt', 'ctrl'].includes(value)) {
72
72
  return kbdKeysSpecificMap[value as KbdSpecificKey];
@@ -6,7 +6,7 @@
6
6
  import defu from 'defu';
7
7
  import { fade, scale } from 'svelte/transition';
8
8
  import { cubicIn } from 'svelte/easing';
9
- import { app_icons } from '../contexts.js';
9
+ import { getAppContext } from '../contexts.js';
10
10
 
11
11
  export type ModalProps = {
12
12
  open?: boolean;
@@ -160,7 +160,7 @@
160
160
  {...defu(typeof close === 'boolean' ? {} : close, <ButtonProps>{
161
161
  variant: 'ghost',
162
162
  color: 'surface',
163
- icon: app_icons.get().close,
163
+ icon: getAppContext().icons.close,
164
164
  onclick() {
165
165
  open = false;
166
166
  },