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.
- package/dist/Accordion/Accordion.svelte +66 -97
- package/dist/Alert/Alert.svelte +39 -64
- package/dist/Alert/Alert.svelte.d.ts +1 -1
- package/dist/Avatar/Avatar.svelte +35 -75
- package/dist/AvatarGroup/AvatarGroup.svelte +38 -55
- package/dist/Badge/Badge.svelte +28 -50
- package/dist/Banner/Banner.svelte +46 -41
- package/dist/Banner/Banner.svelte.d.ts +1 -1
- package/dist/Breadcrumb/Breadcrumb.svelte +32 -26
- package/dist/Button/Button.svelte +70 -138
- package/dist/Calendar/Calendar.svelte +94 -157
- package/dist/Calendar/Calendar.svelte.d.ts +1 -1
- package/dist/Card/Card.svelte +18 -31
- package/dist/Carousel/Carousel.svelte +118 -173
- package/dist/Checkbox/Checkbox.svelte +52 -97
- package/dist/CheckboxGroup/CheckboxGroup.svelte +62 -107
- package/dist/CheckboxGroup/CheckboxGroup.svelte.d.ts +1 -1
- package/dist/Chip/Chip.svelte +22 -34
- package/dist/CodeBlock/CodeBlock.svelte +42 -59
- package/dist/Collapsible/Collapsible.svelte +22 -38
- package/dist/Collapsible/Collapsible.svelte.d.ts +1 -1
- package/dist/Collapsible/CollapsibleTestWrapper.svelte +2 -5
- package/dist/Collapsible/CollapsibleTestWrapper.svelte.d.ts +1 -1
- package/dist/Command/Command.svelte +40 -77
- package/dist/Command/Command.svelte.d.ts +1 -1
- package/dist/Command/CommandTestWrapper.svelte +2 -10
- package/dist/Command/CommandTestWrapper.svelte.d.ts +1 -1
- package/dist/Container/Container.svelte +11 -14
- package/dist/ContextMenu/ContextMenu.svelte +51 -114
- package/dist/ContextMenu/ContextMenu.svelte.d.ts +1 -1
- package/dist/Drawer/Drawer.svelte +72 -110
- package/dist/Drawer/DrawerTriggerTestWrapper.svelte +1 -2
- package/dist/DropdownMenu/DropdownMenu.svelte +63 -124
- package/dist/DropdownMenu/DropdownMenu.svelte.d.ts +1 -1
- package/dist/DropdownMenu/DropdownMenuTriggerTestWrapper.svelte +2 -5
- package/dist/Editor/Editor.svelte +441 -576
- package/dist/Editor/Editor.svelte.d.ts +1 -1
- package/dist/Editor/EditorUrlPrompt.svelte +40 -53
- package/dist/Editor/SlashPopup.svelte +12 -24
- package/dist/Empty/Empty.svelte +32 -63
- package/dist/FieldGroup/FieldGroup.svelte +23 -38
- package/dist/FileUpload/FileUpload.svelte +242 -320
- package/dist/FileUpload/FileUpload.svelte.d.ts +1 -1
- package/dist/Fonts/Fonts.svelte +15 -37
- package/dist/Form/Form.svelte +112 -170
- package/dist/FormField/FormField.svelte +102 -135
- package/dist/Icon/Icon.svelte +7 -32
- package/dist/Input/Input.svelte +71 -141
- package/dist/Input/Input.svelte.d.ts +2 -2
- package/dist/Kbd/Kbd.svelte +18 -34
- package/dist/Link/Link.svelte +129 -196
- package/dist/LocaleButton/LocaleButton.svelte +165 -0
- package/dist/LocaleButton/LocaleButton.svelte.d.ts +5 -0
- package/dist/LocaleButton/index.d.ts +2 -0
- package/dist/LocaleButton/index.js +1 -0
- package/dist/LocaleButton/locale-button.types.d.ts +182 -0
- package/dist/LocaleButton/locale-button.types.js +1 -0
- package/dist/LocaleButton/locale-button.variants.d.ts +61 -0
- package/dist/LocaleButton/locale-button.variants.js +34 -0
- package/dist/Modal/Modal.svelte +52 -106
- package/dist/Modal/ModalTriggerTestWrapper.svelte +1 -2
- package/dist/Pagination/Pagination.svelte +48 -92
- package/dist/Pagination/pagination.variants.d.ts +1 -1
- package/dist/PinInput/PinInput.svelte +57 -111
- package/dist/PinInput/PinInput.svelte.d.ts +1 -1
- package/dist/Popover/Popover.svelte +28 -61
- package/dist/Popover/Popover.svelte.d.ts +1 -1
- package/dist/Progress/Progress.svelte +75 -94
- package/dist/RadioGroup/RadioGroup.svelte +54 -99
- package/dist/RadioGroup/RadioGroup.svelte.d.ts +1 -1
- package/dist/Select/Select.svelte +112 -269
- package/dist/Select/Select.svelte.d.ts +1 -1
- package/dist/SelectMenu/SelectMenu.svelte +211 -409
- package/dist/SelectMenu/SelectMenu.svelte.d.ts +1 -1
- package/dist/SelectMenu/SelectMenuFormFieldTestWrapper.svelte +3 -6
- package/dist/Separator/Separator.svelte +29 -44
- package/dist/Skeleton/Skeleton.svelte +11 -23
- package/dist/Slideover/Slideover.svelte +52 -106
- package/dist/Slideover/SlideoverTriggerTestWrapper.svelte +1 -2
- package/dist/Slider/Slider.svelte +48 -84
- package/dist/Slider/Slider.svelte.d.ts +1 -1
- package/dist/Stepper/Stepper.svelte +139 -132
- package/dist/Stepper/Stepper.svelte.d.ts +1 -1
- package/dist/Switch/Switch.svelte +62 -98
- package/dist/Table/Table.svelte +232 -283
- package/dist/Table/table.variants.d.ts +1 -1
- package/dist/Tabs/Tabs.svelte +96 -129
- package/dist/Tabs/Tabs.svelte.d.ts +1 -1
- package/dist/Textarea/Textarea.svelte +90 -173
- package/dist/Textarea/Textarea.svelte.d.ts +1 -1
- package/dist/ThemeModeButton/ThemeModeButton.svelte +16 -38
- package/dist/Timeline/Timeline.svelte +75 -54
- package/dist/Toast/Toaster.svelte +8 -25
- package/dist/Tooltip/Tooltip.svelte +34 -66
- package/dist/Tooltip/Tooltip.svelte.d.ts +1 -1
- package/dist/Tooltip/TooltipTestWrapper.svelte +2 -5
- package/dist/User/User.svelte +33 -49
- package/dist/docs/navigation.d.ts +1 -1
- package/dist/docs/navigation.js +8 -1
- package/dist/hooks/HookContextProbe.svelte +2 -4
- package/dist/hooks/HookContextProvider.svelte +8 -6
- package/dist/hooks/HookEmitProbe.svelte +8 -11
- package/dist/i18n.d.ts +2 -0
- package/dist/i18n.js +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mcp/svelora-docs.data.json +4 -2
- package/dist/theme.css +1 -1
- 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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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, {}, "
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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, {}, "
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|