svelora 3.0.0 → 3.0.2

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 (109) hide show
  1. package/dist/Accordion/Accordion.svelte +66 -97
  2. package/dist/Alert/Alert.svelte +39 -64
  3. package/dist/Alert/Alert.svelte.d.ts +1 -1
  4. package/dist/Avatar/Avatar.svelte +35 -75
  5. package/dist/AvatarGroup/AvatarGroup.svelte +38 -55
  6. package/dist/Badge/Badge.svelte +28 -50
  7. package/dist/Banner/Banner.svelte +46 -41
  8. package/dist/Banner/Banner.svelte.d.ts +1 -1
  9. package/dist/Breadcrumb/Breadcrumb.svelte +32 -26
  10. package/dist/Button/Button.svelte +70 -138
  11. package/dist/Calendar/Calendar.svelte +94 -157
  12. package/dist/Calendar/Calendar.svelte.d.ts +1 -1
  13. package/dist/Card/Card.svelte +18 -31
  14. package/dist/Carousel/Carousel.svelte +118 -173
  15. package/dist/Checkbox/Checkbox.svelte +52 -97
  16. package/dist/CheckboxGroup/CheckboxGroup.svelte +62 -107
  17. package/dist/CheckboxGroup/CheckboxGroup.svelte.d.ts +1 -1
  18. package/dist/Chip/Chip.svelte +22 -34
  19. package/dist/CodeBlock/CodeBlock.svelte +42 -59
  20. package/dist/Collapsible/Collapsible.svelte +22 -38
  21. package/dist/Collapsible/Collapsible.svelte.d.ts +1 -1
  22. package/dist/Collapsible/CollapsibleTestWrapper.svelte +2 -5
  23. package/dist/Collapsible/CollapsibleTestWrapper.svelte.d.ts +1 -1
  24. package/dist/Command/Command.svelte +40 -77
  25. package/dist/Command/Command.svelte.d.ts +1 -1
  26. package/dist/Command/CommandTestWrapper.svelte +2 -10
  27. package/dist/Command/CommandTestWrapper.svelte.d.ts +1 -1
  28. package/dist/Container/Container.svelte +11 -14
  29. package/dist/ContextMenu/ContextMenu.svelte +51 -114
  30. package/dist/ContextMenu/ContextMenu.svelte.d.ts +1 -1
  31. package/dist/Drawer/Drawer.svelte +72 -110
  32. package/dist/Drawer/DrawerTriggerTestWrapper.svelte +1 -2
  33. package/dist/DropdownMenu/DropdownMenu.svelte +63 -124
  34. package/dist/DropdownMenu/DropdownMenu.svelte.d.ts +1 -1
  35. package/dist/DropdownMenu/DropdownMenuTriggerTestWrapper.svelte +2 -5
  36. package/dist/Editor/Editor.svelte +441 -576
  37. package/dist/Editor/Editor.svelte.d.ts +1 -1
  38. package/dist/Editor/EditorUrlPrompt.svelte +40 -53
  39. package/dist/Editor/SlashPopup.svelte +12 -24
  40. package/dist/Empty/Empty.svelte +32 -63
  41. package/dist/FieldGroup/FieldGroup.svelte +23 -38
  42. package/dist/FileUpload/FileUpload.svelte +242 -320
  43. package/dist/FileUpload/FileUpload.svelte.d.ts +1 -1
  44. package/dist/Fonts/Fonts.svelte +15 -37
  45. package/dist/Form/Form.svelte +112 -170
  46. package/dist/FormField/FormField.svelte +102 -135
  47. package/dist/Icon/Icon.svelte +7 -32
  48. package/dist/Input/Input.svelte +71 -141
  49. package/dist/Input/Input.svelte.d.ts +2 -2
  50. package/dist/Kbd/Kbd.svelte +18 -34
  51. package/dist/Link/Link.svelte +129 -196
  52. package/dist/LocaleButton/LocaleButton.svelte +165 -0
  53. package/dist/LocaleButton/LocaleButton.svelte.d.ts +5 -0
  54. package/dist/LocaleButton/index.d.ts +2 -0
  55. package/dist/LocaleButton/index.js +1 -0
  56. package/dist/LocaleButton/locale-button.types.d.ts +182 -0
  57. package/dist/LocaleButton/locale-button.types.js +1 -0
  58. package/dist/LocaleButton/locale-button.variants.d.ts +61 -0
  59. package/dist/LocaleButton/locale-button.variants.js +34 -0
  60. package/dist/Modal/Modal.svelte +52 -106
  61. package/dist/Modal/ModalTriggerTestWrapper.svelte +1 -2
  62. package/dist/Pagination/Pagination.svelte +48 -92
  63. package/dist/Pagination/pagination.variants.d.ts +1 -1
  64. package/dist/PinInput/PinInput.svelte +57 -111
  65. package/dist/PinInput/PinInput.svelte.d.ts +1 -1
  66. package/dist/Popover/Popover.svelte +28 -61
  67. package/dist/Popover/Popover.svelte.d.ts +1 -1
  68. package/dist/Progress/Progress.svelte +75 -94
  69. package/dist/RadioGroup/RadioGroup.svelte +54 -99
  70. package/dist/RadioGroup/RadioGroup.svelte.d.ts +1 -1
  71. package/dist/Select/Select.svelte +112 -269
  72. package/dist/Select/Select.svelte.d.ts +1 -1
  73. package/dist/SelectMenu/SelectMenu.svelte +211 -409
  74. package/dist/SelectMenu/SelectMenu.svelte.d.ts +1 -1
  75. package/dist/SelectMenu/SelectMenuFormFieldTestWrapper.svelte +3 -6
  76. package/dist/Separator/Separator.svelte +29 -44
  77. package/dist/Skeleton/Skeleton.svelte +11 -23
  78. package/dist/Slideover/Slideover.svelte +52 -106
  79. package/dist/Slideover/SlideoverTriggerTestWrapper.svelte +1 -2
  80. package/dist/Slider/Slider.svelte +48 -84
  81. package/dist/Slider/Slider.svelte.d.ts +1 -1
  82. package/dist/Stepper/Stepper.svelte +139 -132
  83. package/dist/Stepper/Stepper.svelte.d.ts +1 -1
  84. package/dist/Switch/Switch.svelte +62 -98
  85. package/dist/Table/Table.svelte +232 -283
  86. package/dist/Table/table.variants.d.ts +1 -1
  87. package/dist/Tabs/Tabs.svelte +96 -129
  88. package/dist/Tabs/Tabs.svelte.d.ts +1 -1
  89. package/dist/Textarea/Textarea.svelte +90 -173
  90. package/dist/Textarea/Textarea.svelte.d.ts +1 -1
  91. package/dist/ThemeModeButton/ThemeModeButton.svelte +16 -38
  92. package/dist/Timeline/Timeline.svelte +75 -54
  93. package/dist/Toast/Toaster.svelte +8 -25
  94. package/dist/Tooltip/Tooltip.svelte +34 -66
  95. package/dist/Tooltip/Tooltip.svelte.d.ts +1 -1
  96. package/dist/Tooltip/TooltipTestWrapper.svelte +2 -5
  97. package/dist/User/User.svelte +33 -49
  98. package/dist/docs/navigation.d.ts +1 -1
  99. package/dist/docs/navigation.js +8 -1
  100. package/dist/hooks/HookContextProbe.svelte +2 -4
  101. package/dist/hooks/HookContextProvider.svelte +8 -6
  102. package/dist/hooks/HookEmitProbe.svelte +8 -11
  103. package/dist/i18n.d.ts +2 -0
  104. package/dist/i18n.js +19 -0
  105. package/dist/index.d.ts +1 -0
  106. package/dist/index.js +1 -0
  107. package/dist/mcp/svelora-docs.data.json +4 -2
  108. package/dist/theme.css +1 -1
  109. package/package.json +16 -8
@@ -1,97 +1,53 @@
1
- <script lang="ts" module>
2
- import type { PaginationProps } from './pagination.types.js'
3
-
4
- export type Props = PaginationProps
1
+ <script lang="ts" module>export {};
5
2
  </script>
6
3
 
7
- <script lang="ts">
8
- import { Pagination } from 'bits-ui'
9
- import { untrack } from 'svelte'
10
- import ButtonComponent from '../Button/Button.svelte'
11
- import { getComponentConfig, iconsDefaults } from '../config.js'
12
- import Icon from '../Icon/Icon.svelte'
13
- import {
14
- activeVariantColorClasses,
15
- paginationDefaults,
16
- paginationVariants
17
- } from './pagination.variants.js'
18
-
19
- const config = getComponentConfig('pagination', paginationDefaults)
20
- const icons = getComponentConfig('icons', iconsDefaults)
21
-
22
- let {
23
- ref = $bindable(null),
24
- page = $bindable(),
25
- defaultPage = 1,
26
- total = 0,
27
- itemsPerPage = 10,
28
- siblingCount = 1,
29
- showEdges = false,
30
- showControls = true,
31
- disabled = false,
32
- onPageChange,
33
- size = config.defaultVariants.size ?? 'md',
34
- variant = config.defaultVariants.variant ?? 'ghost',
35
- color = config.defaultVariants.color ?? 'surface',
36
- activeColor = config.defaultVariants.activeColor ?? 'primary',
37
- activeVariant = config.defaultVariants.activeVariant ?? 'solid',
38
- firstIcon = icons.chevronsLeft,
39
- prevIcon = icons.chevronLeft,
40
- nextIcon = icons.chevronRight,
41
- lastIcon = icons.chevronsRight,
42
- ellipsisIcon = icons.ellipsis,
43
- ui,
44
- class: className,
45
- firstSlot,
46
- prevSlot,
47
- nextSlot,
48
- lastSlot,
49
- ellipsisSlot,
50
- itemSlot,
51
- ...restProps
52
- }: Props = $props()
53
-
54
- if (page === undefined) {
55
- page = untrack(() => defaultPage)
56
- }
57
-
58
- const totalPages = $derived(Math.max(1, Math.ceil(total / itemsPerPage)))
59
- const isFirstPage = $derived(page === 1)
60
- const isLastPage = $derived(page === totalPages)
61
- const prevDisabled = $derived(disabled || isFirstPage)
62
- const nextDisabled = $derived(disabled || isLastPage)
63
-
64
- const variantSlots = $derived(paginationVariants({ size, disabled }))
65
- const activeCls = $derived(
66
- activeVariantColorClasses[activeVariant]?.[activeColor] ??
67
- activeVariantColorClasses.solid.primary
68
- )
69
- const classes = $derived({
70
- root: variantSlots.root({ class: [config.slots.root, className] }),
71
- list: variantSlots.list({ class: [config.slots.list, ui?.list] }),
72
- item: variantSlots.item({ class: [config.slots.item, activeCls, ui?.item] }),
73
- ellipsis: variantSlots.ellipsis({ class: [config.slots.ellipsis, ui?.ellipsis] }),
74
- ellipsisIcon: variantSlots.ellipsisIcon({
75
- class: [config.slots.ellipsisIcon, ui?.ellipsisIcon]
76
- }),
77
- first: variantSlots.first({ class: [config.slots.first, ui?.first] }),
78
- prev: variantSlots.prev({ class: [config.slots.prev, ui?.prev] }),
79
- next: variantSlots.next({ class: [config.slots.next, ui?.next] }),
80
- last: variantSlots.last({ class: [config.slots.last, ui?.last] })
81
- })
82
-
83
- function handlePageChange(newPage: number) {
84
- page = newPage
85
- onPageChange?.(newPage)
86
- }
87
-
88
- function goToFirst() {
89
- if (!isFirstPage) handlePageChange(1)
90
- }
91
-
92
- function goToLast() {
93
- if (!isLastPage) handlePageChange(totalPages)
94
- }
4
+ <script lang="ts">import { Pagination } from "bits-ui";
5
+ import { untrack } from "svelte";
6
+ import ButtonComponent from "../Button/Button.svelte";
7
+ import { getComponentConfig, iconsDefaults } from "../config.js";
8
+ import Icon from "../Icon/Icon.svelte";
9
+ import { activeVariantColorClasses, paginationDefaults, paginationVariants } from "./pagination.variants.js";
10
+ const config = getComponentConfig("pagination", paginationDefaults);
11
+ const icons = getComponentConfig("icons", iconsDefaults);
12
+ let { ref = $bindable(null), page = $bindable(), defaultPage = 1, total = 0, itemsPerPage = 10, siblingCount = 1, showEdges = false, showControls = true, disabled = false, onPageChange, size = config.defaultVariants.size ?? "md", variant = config.defaultVariants.variant ?? "ghost", color = config.defaultVariants.color ?? "surface", activeColor = config.defaultVariants.activeColor ?? "primary", activeVariant = config.defaultVariants.activeVariant ?? "solid", firstIcon = icons.chevronsLeft, prevIcon = icons.chevronLeft, nextIcon = icons.chevronRight, lastIcon = icons.chevronsRight, ellipsisIcon = icons.ellipsis, ui, class: className, firstSlot, prevSlot, nextSlot, lastSlot, ellipsisSlot, itemSlot, ...restProps } = $props();
13
+ if (page === undefined) {
14
+ page = untrack(() => defaultPage);
15
+ }
16
+ const totalPages = $derived(Math.max(1, Math.ceil(total / itemsPerPage)));
17
+ const isFirstPage = $derived(page === 1);
18
+ const isLastPage = $derived(page === totalPages);
19
+ const prevDisabled = $derived(disabled || isFirstPage);
20
+ const nextDisabled = $derived(disabled || isLastPage);
21
+ const variantSlots = $derived(paginationVariants({
22
+ size,
23
+ disabled
24
+ }));
25
+ const activeCls = $derived(activeVariantColorClasses[activeVariant]?.[activeColor] ?? activeVariantColorClasses.solid.primary);
26
+ const classes = $derived({
27
+ root: variantSlots.root({ class: [config.slots.root, className] }),
28
+ list: variantSlots.list({ class: [config.slots.list, ui?.list] }),
29
+ item: variantSlots.item({ class: [
30
+ config.slots.item,
31
+ activeCls,
32
+ ui?.item
33
+ ] }),
34
+ ellipsis: variantSlots.ellipsis({ class: [config.slots.ellipsis, ui?.ellipsis] }),
35
+ ellipsisIcon: variantSlots.ellipsisIcon({ class: [config.slots.ellipsisIcon, ui?.ellipsisIcon] }),
36
+ first: variantSlots.first({ class: [config.slots.first, ui?.first] }),
37
+ prev: variantSlots.prev({ class: [config.slots.prev, ui?.prev] }),
38
+ next: variantSlots.next({ class: [config.slots.next, ui?.next] }),
39
+ last: variantSlots.last({ class: [config.slots.last, ui?.last] })
40
+ });
41
+ function handlePageChange(newPage) {
42
+ page = newPage;
43
+ onPageChange?.(newPage);
44
+ }
45
+ function goToFirst() {
46
+ if (!isFirstPage) handlePageChange(1);
47
+ }
48
+ function goToLast() {
49
+ if (!isLastPage) handlePageChange(totalPages);
50
+ }
95
51
  </script>
96
52
 
97
53
  <Pagination.Root
@@ -153,8 +153,8 @@ export declare const paginationDefaults: {
153
153
  color: "surface";
154
154
  activeColor: "primary";
155
155
  activeVariant: "solid";
156
+ size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
156
157
  disabled?: boolean | undefined;
157
- size?: "md" | "xs" | "sm" | "lg" | "xl" | undefined;
158
158
  };
159
159
  slots: Partial<Record<PaginationSlots, string>>;
160
160
  };
@@ -1,116 +1,62 @@
1
- <script lang="ts" module>
2
- import type { PinInputProps } from './pin-input.types.js'
3
-
4
- export type Props = PinInputProps
1
+ <script lang="ts" module>export {};
5
2
  </script>
6
3
 
7
- <script lang="ts">
8
- import { PinInput, useId } from 'bits-ui'
9
- import { getComponentConfig, iconsDefaults } from '../config.js'
10
- import { useFormField, useFormFieldEmit } from '../hooks/useFormField.svelte.js'
11
- import Icon from '../Icon/Icon.svelte'
12
- import { pinInputDefaults, pinInputVariants } from './pin-input.variants.js'
13
-
14
- const config = getComponentConfig('pinInput', pinInputDefaults)
15
- const icons = getComponentConfig('icons', iconsDefaults)
16
-
17
- let {
18
- ref = $bindable(null),
19
- defaultValue = '',
20
- value = $bindable(defaultValue),
21
- onValueChange,
22
- onComplete,
23
- length = 5,
24
- type = 'text',
25
- mask = false,
26
- otp = false,
27
- disabled = false,
28
- required,
29
- textalign,
30
- pasteTransformer,
31
- pushPasswordManagerStrategy,
32
- inputId,
33
- name,
34
- placeholder = '○',
35
- autofocus = false,
36
- autofocusDelay = 0,
37
- highlight = false,
38
- loading = false,
39
- loadingIcon = icons.loading,
40
- fixed = false,
41
- color = config.defaultVariants.color,
42
- size,
43
- variant = config.defaultVariants.variant,
44
- class: className,
45
- ui,
46
- ...restProps
47
- }: Props = $props()
48
-
49
- const formFieldContext = useFormField()
50
- const emit = useFormFieldEmit()
51
-
52
- const isDisabled = $derived(disabled || loading)
53
-
54
- const autoInputId = useId()
55
- const hasError = $derived(
56
- formFieldContext?.error !== undefined && formFieldContext?.error !== false
57
- )
58
- const resolvedInputId = $derived(inputId ?? formFieldContext?.ariaId ?? autoInputId)
59
- const resolvedName = $derived(name ?? formFieldContext?.name)
60
- const resolvedSize = $derived(size ?? formFieldContext?.size ?? config.defaultVariants.size)
61
- const resolvedColor = $derived(hasError ? 'error' : color)
62
- const resolvedHighlight = $derived(hasError || highlight)
63
- const ariaDescribedBy = $derived(
64
- !formFieldContext
65
- ? undefined
66
- : hasError
67
- ? `${formFieldContext.ariaId}-error`
68
- : `${formFieldContext.ariaId}-description ${formFieldContext.ariaId}-help`
69
- )
70
-
71
- const resolvedPasteTransformer = $derived(
72
- pasteTransformer ??
73
- (type === 'number' ? (text: string) => text.replace(/\D/g, '') : undefined)
74
- )
75
-
76
- function handleValueChange(v: string) {
77
- const filtered = type === 'number' ? v.replace(/\D/g, '') : v
78
- value = filtered
79
- emit.onInput()
80
- onValueChange?.(filtered)
81
- }
82
-
83
- function handleComplete(v: string) {
84
- emit.onChange()
85
- onComplete?.(v)
86
- }
87
-
88
- const slots = $derived(
89
- pinInputVariants({
90
- variant,
91
- color: resolvedColor,
92
- size: resolvedSize,
93
- highlight: resolvedHighlight,
94
- fixed,
95
- disabled: isDisabled
96
- })
97
- )
98
-
99
- const classes = $derived.by(() => {
100
- const u = ui ?? {}
101
- return {
102
- root: slots.root({ class: [config.slots.root, className, u.root] }),
103
- base: slots.base({ class: [config.slots.base, u.base] })
104
- }
105
- })
106
-
107
- $effect(() => {
108
- if (!autofocus) return
109
- const input = ref?.querySelector('[data-pin-input-input]') as HTMLInputElement | null
110
- if (!input) return
111
- const timer = setTimeout(() => input.focus(), autofocusDelay)
112
- return () => clearTimeout(timer)
113
- })
4
+ <script lang="ts">import { PinInput, useId } from "bits-ui";
5
+ import { getComponentConfig, iconsDefaults } from "../config.js";
6
+ import { useFormField, useFormFieldEmit } from "../hooks/useFormField.svelte.js";
7
+ import Icon from "../Icon/Icon.svelte";
8
+ import { pinInputDefaults, pinInputVariants } from "./pin-input.variants.js";
9
+ const config = getComponentConfig("pinInput", pinInputDefaults);
10
+ const icons = getComponentConfig("icons", iconsDefaults);
11
+ let { ref = $bindable(null), defaultValue = "", value = $bindable(defaultValue), onValueChange, onComplete, length = 5, type = "text", mask = false, otp = false, disabled = false, required, textalign, pasteTransformer, pushPasswordManagerStrategy, inputId, name, placeholder = "○", autofocus = false, autofocusDelay = 0, highlight = false, loading = false, loadingIcon = icons.loading, fixed = false, color = config.defaultVariants.color, size, variant = config.defaultVariants.variant, class: className, ui, ...restProps } = $props();
12
+ const formFieldContext = useFormField();
13
+ const emit = useFormFieldEmit();
14
+ const isDisabled = $derived(disabled || loading);
15
+ const autoInputId = useId();
16
+ const hasError = $derived(formFieldContext?.error !== undefined && formFieldContext?.error !== false);
17
+ const resolvedInputId = $derived(inputId ?? formFieldContext?.ariaId ?? autoInputId);
18
+ const resolvedName = $derived(name ?? formFieldContext?.name);
19
+ const resolvedSize = $derived(size ?? formFieldContext?.size ?? config.defaultVariants.size);
20
+ const resolvedColor = $derived(hasError ? "error" : color);
21
+ const resolvedHighlight = $derived(hasError || highlight);
22
+ const ariaDescribedBy = $derived(!formFieldContext ? undefined : hasError ? `${formFieldContext.ariaId}-error` : `${formFieldContext.ariaId}-description ${formFieldContext.ariaId}-help`);
23
+ const resolvedPasteTransformer = $derived(pasteTransformer ?? (type === "number" ? (text) => text.replace(/\D/g, "") : undefined));
24
+ function handleValueChange(v) {
25
+ const filtered = type === "number" ? v.replace(/\D/g, "") : v;
26
+ value = filtered;
27
+ emit.onInput();
28
+ onValueChange?.(filtered);
29
+ }
30
+ function handleComplete(v) {
31
+ emit.onChange();
32
+ onComplete?.(v);
33
+ }
34
+ const slots = $derived(pinInputVariants({
35
+ variant,
36
+ color: resolvedColor,
37
+ size: resolvedSize,
38
+ highlight: resolvedHighlight,
39
+ fixed,
40
+ disabled: isDisabled
41
+ }));
42
+ const classes = $derived.by(() => {
43
+ const u = ui ?? {};
44
+ return {
45
+ root: slots.root({ class: [
46
+ config.slots.root,
47
+ className,
48
+ u.root
49
+ ] }),
50
+ base: slots.base({ class: [config.slots.base, u.base] })
51
+ };
52
+ });
53
+ $effect(() => {
54
+ if (!autofocus) return;
55
+ const input = ref?.querySelector("[data-pin-input-input]");
56
+ if (!input) return;
57
+ const timer = setTimeout(() => input.focus(), autofocusDelay);
58
+ return () => clearTimeout(timer);
59
+ });
114
60
  </script>
115
61
 
116
62
  <div class="relative inline-flex" {...restProps}>
@@ -1,6 +1,6 @@
1
1
  import type { PinInputProps } from './pin-input.types.js';
2
2
  export type Props = PinInputProps;
3
3
  import { PinInput } from 'bits-ui';
4
- declare const PinInput: import("svelte").Component<PinInputProps, {}, "value" | "ref">;
4
+ declare const PinInput: import("svelte").Component<PinInputProps, {}, "ref" | "value">;
5
5
  type PinInput = ReturnType<typeof PinInput>;
6
6
  export default PinInput;
@@ -1,66 +1,33 @@
1
- <script lang="ts" module>
2
- import type { PopoverProps } from './popover.types.js'
3
-
4
- export type Props = PopoverProps
1
+ <script lang="ts" module>export {};
5
2
  </script>
6
3
 
7
- <script lang="ts">
8
- import { Popover } from 'bits-ui'
9
- import { getComponentConfig } from '../config.js'
10
- import { popoverDefaults, popoverVariants } from './popover.variants.js'
11
-
12
- const config = getComponentConfig('popover', popoverDefaults)
13
-
14
- let {
15
- ref = $bindable(null),
16
- open = $bindable(false),
17
- onOpenChange,
18
- onOpenChangeComplete,
19
- side = 'bottom',
20
- sideOffset = 8,
21
- align = 'center',
22
- alignOffset = 0,
23
- avoidCollisions = true,
24
- collisionBoundary,
25
- collisionPadding = 8,
26
- sticky = 'partial',
27
- hideWhenDetached = false,
28
- trapFocus = true,
29
- preventScroll = false,
30
- onOpenAutoFocus,
31
- onCloseAutoFocus,
32
- onEscapeKeydown,
33
- onInteractOutside,
34
- forceMount,
35
- arrow = false,
36
- transition = config.defaultVariants.transition ?? true,
37
- portal = true,
38
- dismissible = true,
39
- ui,
40
- class: className,
41
- children,
42
- content: contentSlot,
43
- ...restProps
44
- }: Props = $props()
45
-
46
- const variantSlots = $derived(popoverVariants({ transition }))
47
- const classes = $derived({
48
- content: variantSlots.content({ class: [config.slots.content, ui?.content] }),
49
- arrow: variantSlots.arrow({ class: [config.slots.arrow, ui?.arrow] })
50
- })
51
-
52
- const arrowProps = $derived.by(() => {
53
- if (typeof arrow === 'object') {
54
- return { width: 12, height: 6, ...arrow }
55
- }
56
- return { width: 12, height: 6 }
57
- })
58
-
59
- const dismissBehavior = $derived(dismissible ? ('close' as const) : ('ignore' as const))
60
-
61
- function close() {
62
- open = false
63
- }
4
+ <script lang="ts">import { Popover } from "bits-ui";
5
+ import { getComponentConfig } from "../config.js";
6
+ import { popoverDefaults, popoverVariants } from "./popover.variants.js";
7
+ const config = getComponentConfig("popover", popoverDefaults);
8
+ let { ref = $bindable(null), open = $bindable(false), onOpenChange, onOpenChangeComplete, side = "bottom", sideOffset = 8, align = "center", alignOffset = 0, avoidCollisions = true, collisionBoundary, collisionPadding = 8, sticky = "partial", hideWhenDetached = false, trapFocus = true, preventScroll = false, onOpenAutoFocus, onCloseAutoFocus, onEscapeKeydown, onInteractOutside, forceMount, arrow = false, transition = config.defaultVariants.transition ?? true, portal = true, dismissible = true, ui, class: className, children, content: contentSlot, ...restProps } = $props();
9
+ const variantSlots = $derived(popoverVariants({ transition }));
10
+ const classes = $derived({
11
+ content: variantSlots.content({ class: [config.slots.content, ui?.content] }),
12
+ arrow: variantSlots.arrow({ class: [config.slots.arrow, ui?.arrow] })
13
+ });
14
+ const arrowProps = $derived.by(() => {
15
+ if (typeof arrow === "object") {
16
+ return {
17
+ width: 12,
18
+ height: 6,
19
+ ...arrow
20
+ };
21
+ }
22
+ return {
23
+ width: 12,
24
+ height: 6
25
+ };
26
+ });
27
+ const dismissBehavior = $derived(dismissible ? "close" : "ignore");
28
+ function close() {
29
+ open = false;
30
+ }
64
31
  </script>
65
32
 
66
33
  {#snippet popoverContentEl()}
@@ -1,6 +1,6 @@
1
1
  import type { PopoverProps } from './popover.types.js';
2
2
  export type Props = PopoverProps;
3
3
  import { Popover } from 'bits-ui';
4
- declare const Popover: import("svelte").Component<PopoverProps, {}, "ref" | "open">;
4
+ declare const Popover: import("svelte").Component<PopoverProps, {}, "open" | "ref">;
5
5
  type Popover = ReturnType<typeof Popover>;
6
6
  export default Popover;
@@ -1,99 +1,80 @@
1
- <script lang="ts" module>
2
- import type { ProgressProps } from './progress.types.js'
3
-
4
- export type Props = ProgressProps
1
+ <script lang="ts" module>export {};
5
2
  </script>
6
3
 
7
- <script lang="ts">
8
- import { Progress } from 'bits-ui'
9
- import { getComponentConfig } from '../config.js'
10
- import { progressDefaults, progressVariants } from './progress.variants.js'
11
-
12
- const config = getComponentConfig('progress', progressDefaults)
13
-
14
- let {
15
- ref = $bindable(null),
16
- value = null,
17
- max = 100,
18
- status = false,
19
- color = config.defaultVariants.color,
20
- size = config.defaultVariants.size,
21
- orientation = config.defaultVariants.orientation,
22
- inverted = false,
23
- animation = config.defaultVariants.animation,
24
- ui,
25
- class: className,
26
- statusSlot,
27
- stepSlot,
28
- ...restProps
29
- }: Props = $props()
30
-
31
- const isIndeterminate = $derived(value === null)
32
- const hasSteps = $derived(Array.isArray(max))
33
-
34
- const realMax = $derived.by(() => {
35
- if (isIndeterminate || !max) return undefined
36
- if (Array.isArray(max)) return max.length - 1
37
- return Number(max)
38
- })
39
-
40
- const percent = $derived.by(() => {
41
- if (isIndeterminate) return undefined
42
- if (value! < 0) return 0
43
- if (value! > (realMax ?? 100)) return 100
44
- return Math.round((value! / (realMax ?? 100)) * 100)
45
- })
46
-
47
- const indicatorStyle = $derived.by(() => {
48
- if (percent === undefined) return ''
49
- const offset = 100 - percent
50
- if (orientation === 'vertical') {
51
- return `transform: translateY(${inverted ? '' : '-'}${offset}%);`
52
- }
53
- return `transform: translateX(${inverted ? '' : '-'}${offset}%);`
54
- })
55
-
56
- const statusStyle = $derived.by(() => {
57
- const val = `${Math.max(percent ?? 0, 0)}%`
58
- return orientation === 'vertical' ? `height: ${val};` : `width: ${val};`
59
- })
60
-
61
- function stepVariant(index: number): 'active' | 'first' | 'last' | 'other' {
62
- const isActive = index === Number(value)
63
- const isFirst = index === 0
64
- const isLast = index === realMax
65
-
66
- if (isActive && !isFirst) return 'active'
67
- if (isFirst && isActive) return 'first'
68
- if (isLast && isActive) return 'last'
69
- return 'other'
70
- }
71
-
72
- const classes = $derived.by(() => {
73
- const slots = progressVariants({ animation, color, size, orientation, inverted })
74
- return {
75
- root: slots.root({ class: [config.slots.root, className, ui?.root] }),
76
- base: slots.base({ class: [config.slots.base, ui?.base] }),
77
- indicator: slots.indicator({ class: [config.slots.indicator, ui?.indicator] }),
78
- status: slots.status({ class: [config.slots.status, ui?.status] }),
79
- steps: slots.steps({ class: [config.slots.steps, ui?.steps] })
80
- }
81
- })
82
-
83
- const stepClasses = $derived.by(() => {
84
- const make = (step: 'active' | 'first' | 'last' | 'other') =>
85
- progressVariants({ size, orientation, inverted, step }).step({
86
- class: [config.slots.step, ui?.step]
87
- })
88
- return {
89
- active: make('active'),
90
- first: make('first'),
91
- last: make('last'),
92
- other: make('other')
93
- }
94
- })
95
-
96
- const state = $derived(isIndeterminate ? 'indeterminate' : 'determinate')
4
+ <script lang="ts">import { Progress } from "bits-ui";
5
+ import { getComponentConfig } from "../config.js";
6
+ import { progressDefaults, progressVariants } from "./progress.variants.js";
7
+ const config = getComponentConfig("progress", progressDefaults);
8
+ let { ref = $bindable(null), value = null, max = 100, status = false, color = config.defaultVariants.color, size = config.defaultVariants.size, orientation = config.defaultVariants.orientation, inverted = false, animation = config.defaultVariants.animation, ui, class: className, statusSlot, stepSlot, ...restProps } = $props();
9
+ const isIndeterminate = $derived(value === null);
10
+ const hasSteps = $derived(Array.isArray(max));
11
+ const realMax = $derived.by(() => {
12
+ if (isIndeterminate || !max) return undefined;
13
+ if (Array.isArray(max)) return max.length - 1;
14
+ return Number(max);
15
+ });
16
+ const percent = $derived.by(() => {
17
+ if (isIndeterminate) return undefined;
18
+ if (value < 0) return 0;
19
+ if (value > (realMax ?? 100)) return 100;
20
+ return Math.round(value / (realMax ?? 100) * 100);
21
+ });
22
+ const indicatorStyle = $derived.by(() => {
23
+ if (percent === undefined) return "";
24
+ const offset = 100 - percent;
25
+ if (orientation === "vertical") {
26
+ return `transform: translateY(${inverted ? "" : "-"}${offset}%);`;
27
+ }
28
+ return `transform: translateX(${inverted ? "" : "-"}${offset}%);`;
29
+ });
30
+ const statusStyle = $derived.by(() => {
31
+ const val = `${Math.max(percent ?? 0, 0)}%`;
32
+ return orientation === "vertical" ? `height: ${val};` : `width: ${val};`;
33
+ });
34
+ function stepVariant(index) {
35
+ const isActive = index === Number(value);
36
+ const isFirst = index === 0;
37
+ const isLast = index === realMax;
38
+ if (isActive && !isFirst) return "active";
39
+ if (isFirst && isActive) return "first";
40
+ if (isLast && isActive) return "last";
41
+ return "other";
42
+ }
43
+ const classes = $derived.by(() => {
44
+ const slots = progressVariants({
45
+ animation,
46
+ color,
47
+ size,
48
+ orientation,
49
+ inverted
50
+ });
51
+ return {
52
+ root: slots.root({ class: [
53
+ config.slots.root,
54
+ className,
55
+ ui?.root
56
+ ] }),
57
+ base: slots.base({ class: [config.slots.base, ui?.base] }),
58
+ indicator: slots.indicator({ class: [config.slots.indicator, ui?.indicator] }),
59
+ status: slots.status({ class: [config.slots.status, ui?.status] }),
60
+ steps: slots.steps({ class: [config.slots.steps, ui?.steps] })
61
+ };
62
+ });
63
+ const stepClasses = $derived.by(() => {
64
+ const make = (step) => progressVariants({
65
+ size,
66
+ orientation,
67
+ inverted,
68
+ step
69
+ }).step({ class: [config.slots.step, ui?.step] });
70
+ return {
71
+ active: make("active"),
72
+ first: make("first"),
73
+ last: make("last"),
74
+ other: make("other")
75
+ };
76
+ });
77
+ const state = $derived(isIndeterminate ? "indeterminate" : "determinate");
97
78
  </script>
98
79
 
99
80
  <Progress.Root