svelora 3.0.1 → 3.0.3
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.js +6 -0
- 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 +2 -0
- package/package.json +16 -8
package/dist/Tabs/Tabs.svelte
CHANGED
|
@@ -1,134 +1,101 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import type { TabsItem, TabsProps } from './tabs.types.js'
|
|
3
|
-
|
|
4
|
-
export type Props = TabsProps
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
} else {
|
|
103
|
-
indicatorStyle = `top: ${activeTrigger.offsetTop}px; height: ${activeTrigger.offsetHeight}px;`
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function scheduleIndicatorUpdate() {
|
|
108
|
-
cancelAnimationFrame(rafId)
|
|
109
|
-
rafId = requestAnimationFrame(updateIndicator)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Update indicator on mount and when dependencies change
|
|
113
|
-
$effect(() => {
|
|
114
|
-
void value
|
|
115
|
-
void orientation
|
|
116
|
-
void items
|
|
117
|
-
tick().then(updateIndicator)
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
// Handle resize with rAF debouncing
|
|
121
|
-
$effect(() => {
|
|
122
|
-
if (!listEl) return
|
|
123
|
-
|
|
124
|
-
const observer = new ResizeObserver(scheduleIndicatorUpdate)
|
|
125
|
-
observer.observe(listEl)
|
|
126
|
-
|
|
127
|
-
return () => {
|
|
128
|
-
observer.disconnect()
|
|
129
|
-
cancelAnimationFrame(rafId)
|
|
130
|
-
}
|
|
131
|
-
})
|
|
4
|
+
<script lang="ts">import { Tabs } from "bits-ui";
|
|
5
|
+
import { tick, untrack } from "svelte";
|
|
6
|
+
import { getComponentConfig } from "../config.js";
|
|
7
|
+
import Icon from "../Icon/Icon.svelte";
|
|
8
|
+
import { tabsDefaults, tabsVariants } from "./tabs.variants.js";
|
|
9
|
+
const config = getComponentConfig("tabs", tabsDefaults);
|
|
10
|
+
let { ref = $bindable(null), items = [], value = $bindable(), defaultValue, onValueChange, variant = config.defaultVariants.variant ?? "pill", color = config.defaultVariants.color ?? "primary", size = config.defaultVariants.size ?? "md", orientation = config.defaultVariants.orientation ?? "horizontal", activationMode = "automatic", disabled = false, loop = true, content: showContent = true, ui, class: className, leading, label: labelSlot, trailing, body: bodySlot, ...restProps } = $props();
|
|
11
|
+
// Initialize value if not provided (intentionally reads initial values only)
|
|
12
|
+
if (value === undefined) {
|
|
13
|
+
value = untrack(() => defaultValue ?? (items.length > 0 ? items[0].value ?? "0" : undefined));
|
|
14
|
+
}
|
|
15
|
+
let listEl = $state(null);
|
|
16
|
+
let indicatorStyle = $state("");
|
|
17
|
+
const variantSlots = $derived(tabsVariants({
|
|
18
|
+
variant,
|
|
19
|
+
color,
|
|
20
|
+
size,
|
|
21
|
+
orientation
|
|
22
|
+
}));
|
|
23
|
+
const classes = $derived({
|
|
24
|
+
root: variantSlots.root({ class: [
|
|
25
|
+
config.slots.root,
|
|
26
|
+
className,
|
|
27
|
+
ui?.root
|
|
28
|
+
] }),
|
|
29
|
+
list: variantSlots.list({ class: [config.slots.list, ui?.list] }),
|
|
30
|
+
indicator: variantSlots.indicator({ class: [config.slots.indicator, ui?.indicator] }),
|
|
31
|
+
trigger: variantSlots.trigger({ class: [config.slots.trigger, ui?.trigger] }),
|
|
32
|
+
leadingIcon: variantSlots.leadingIcon({ class: [config.slots.leadingIcon, ui?.leadingIcon] }),
|
|
33
|
+
label: variantSlots.label({ class: [config.slots.label, ui?.label] }),
|
|
34
|
+
content: variantSlots.content({ class: [config.slots.content, ui?.content] })
|
|
35
|
+
});
|
|
36
|
+
let rafId = 0;
|
|
37
|
+
function getItemValue(item, index) {
|
|
38
|
+
return item.value ?? String(index);
|
|
39
|
+
}
|
|
40
|
+
function getTriggerClass(item) {
|
|
41
|
+
if (!item.ui?.trigger && !item.class) return classes.trigger;
|
|
42
|
+
return variantSlots.trigger({ class: [
|
|
43
|
+
config.slots.trigger,
|
|
44
|
+
ui?.trigger,
|
|
45
|
+
item.ui?.trigger,
|
|
46
|
+
item.class
|
|
47
|
+
] });
|
|
48
|
+
}
|
|
49
|
+
function getIconClass(item) {
|
|
50
|
+
if (!item.ui?.leadingIcon) return classes.leadingIcon;
|
|
51
|
+
return variantSlots.leadingIcon({ class: [
|
|
52
|
+
config.slots.leadingIcon,
|
|
53
|
+
ui?.leadingIcon,
|
|
54
|
+
item.ui?.leadingIcon
|
|
55
|
+
] });
|
|
56
|
+
}
|
|
57
|
+
function getLabelClass(item) {
|
|
58
|
+
if (!item.ui?.label) return classes.label;
|
|
59
|
+
return variantSlots.label({ class: [
|
|
60
|
+
config.slots.label,
|
|
61
|
+
ui?.label,
|
|
62
|
+
item.ui?.label
|
|
63
|
+
] });
|
|
64
|
+
}
|
|
65
|
+
function updateIndicator() {
|
|
66
|
+
if (!listEl) return;
|
|
67
|
+
const activeTrigger = listEl.querySelector("[data-state=\"active\"]");
|
|
68
|
+
if (!activeTrigger) {
|
|
69
|
+
indicatorStyle = "opacity: 0;";
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (orientation === "horizontal") {
|
|
73
|
+
indicatorStyle = `left: ${activeTrigger.offsetLeft}px; width: ${activeTrigger.offsetWidth}px;`;
|
|
74
|
+
} else {
|
|
75
|
+
indicatorStyle = `top: ${activeTrigger.offsetTop}px; height: ${activeTrigger.offsetHeight}px;`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function scheduleIndicatorUpdate() {
|
|
79
|
+
cancelAnimationFrame(rafId);
|
|
80
|
+
rafId = requestAnimationFrame(updateIndicator);
|
|
81
|
+
}
|
|
82
|
+
// Update indicator on mount and when dependencies change
|
|
83
|
+
$effect(() => {
|
|
84
|
+
void value;
|
|
85
|
+
void orientation;
|
|
86
|
+
void items;
|
|
87
|
+
tick().then(updateIndicator);
|
|
88
|
+
});
|
|
89
|
+
// Handle resize with rAF debouncing
|
|
90
|
+
$effect(() => {
|
|
91
|
+
if (!listEl) return;
|
|
92
|
+
const observer = new ResizeObserver(scheduleIndicatorUpdate);
|
|
93
|
+
observer.observe(listEl);
|
|
94
|
+
return () => {
|
|
95
|
+
observer.disconnect();
|
|
96
|
+
cancelAnimationFrame(rafId);
|
|
97
|
+
};
|
|
98
|
+
});
|
|
132
99
|
</script>
|
|
133
100
|
|
|
134
101
|
<Tabs.Root
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TabsProps } from './tabs.types.js';
|
|
2
2
|
export type Props = TabsProps;
|
|
3
3
|
import { Tabs } from 'bits-ui';
|
|
4
|
-
declare const Tabs: import("svelte").Component<TabsProps, {}, "
|
|
4
|
+
declare const Tabs: import("svelte").Component<TabsProps, {}, "ref" | "value">;
|
|
5
5
|
type Tabs = ReturnType<typeof Tabs>;
|
|
6
6
|
export default Tabs;
|
|
@@ -1,178 +1,95 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import type { TextareaProps } from './textarea.types.js'
|
|
3
|
-
|
|
4
|
-
export type Props = TextareaProps
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const isLeading = $derived((!!icon && !trailing) || (loading && !trailing) || !!leadingIcon)
|
|
97
|
-
const isTrailing = $derived((!!icon && trailing) || (loading && trailing) || !!trailingIcon)
|
|
98
|
-
|
|
99
|
-
const leadingIconName = $derived(
|
|
100
|
-
loading && isLeading
|
|
101
|
-
? loadingIcon
|
|
102
|
-
: leadingIcon || (isLeading && !trailing ? icon : undefined)
|
|
103
|
-
)
|
|
104
|
-
const trailingIconName = $derived(
|
|
105
|
-
loading && isTrailing ? loadingIcon : trailingIcon || (trailing ? icon : undefined)
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
const ariaDescribedBy = $derived(
|
|
109
|
-
!formFieldContext
|
|
110
|
-
? undefined
|
|
111
|
-
: hasError
|
|
112
|
-
? `${formFieldContext.ariaId}-error`
|
|
113
|
-
: `${formFieldContext.ariaId}-description ${formFieldContext.ariaId}-help`
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
const variantSlots = $derived(
|
|
117
|
-
textareaVariants({
|
|
118
|
-
variant,
|
|
119
|
-
color: resolvedColor,
|
|
120
|
-
size: resolvedSize,
|
|
121
|
-
leading: isLeading,
|
|
122
|
-
trailing: isTrailing,
|
|
123
|
-
loading,
|
|
124
|
-
highlight: resolvedHighlight,
|
|
125
|
-
autoresize
|
|
126
|
-
})
|
|
127
|
-
)
|
|
128
|
-
const classes = $derived({
|
|
129
|
-
root: variantSlots.root({
|
|
130
|
-
class: [config.slots.root, fieldGroupClass?.root, className, ui?.root]
|
|
131
|
-
}),
|
|
132
|
-
base: variantSlots.base({
|
|
133
|
-
class: [config.slots.base, fieldGroupClass?.base, ui?.base]
|
|
134
|
-
}),
|
|
135
|
-
leading: variantSlots.leading({ class: [config.slots.leading, ui?.leading] }),
|
|
136
|
-
leadingIcon: variantSlots.leadingIcon({
|
|
137
|
-
class: [config.slots.leadingIcon, ui?.leadingIcon]
|
|
138
|
-
}),
|
|
139
|
-
trailing: variantSlots.trailing({ class: [config.slots.trailing, ui?.trailing] }),
|
|
140
|
-
trailingIcon: variantSlots.trailingIcon({
|
|
141
|
-
class: [config.slots.trailingIcon, ui?.trailingIcon]
|
|
142
|
-
})
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
let cachedMaxHeight = $state(0)
|
|
146
|
-
|
|
147
|
-
$effect(() => {
|
|
148
|
-
if (!autoresize || !ref || maxrows <= 0) {
|
|
149
|
-
cachedMaxHeight = 0
|
|
150
|
-
return
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const style = window.getComputedStyle(ref)
|
|
154
|
-
cachedMaxHeight =
|
|
155
|
-
parseFloat(style.lineHeight) * maxrows +
|
|
156
|
-
parseFloat(style.paddingTop) +
|
|
157
|
-
parseFloat(style.paddingBottom)
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
$effect(() => {
|
|
161
|
-
if (!autoresize || !ref) return
|
|
162
|
-
|
|
163
|
-
void value
|
|
164
|
-
|
|
165
|
-
ref.style.height = 'auto'
|
|
166
|
-
const scrollHeight = ref.scrollHeight
|
|
167
|
-
|
|
168
|
-
if (cachedMaxHeight > 0 && scrollHeight > cachedMaxHeight) {
|
|
169
|
-
ref.style.height = `${cachedMaxHeight}px`
|
|
170
|
-
ref.style.overflowY = 'auto'
|
|
171
|
-
} else {
|
|
172
|
-
ref.style.height = `${scrollHeight}px`
|
|
173
|
-
ref.style.overflowY = 'hidden'
|
|
174
|
-
}
|
|
175
|
-
})
|
|
4
|
+
<script lang="ts">import { getContext } from "svelte";
|
|
5
|
+
import { getComponentConfig, iconsDefaults } from "../config.js";
|
|
6
|
+
import { fieldGroupVariantWithRoot } from "../FieldGroup/field-group.variants.js";
|
|
7
|
+
import { useFormField, useFormFieldEmit } from "../hooks/useFormField.svelte.js";
|
|
8
|
+
import Icon from "../Icon/Icon.svelte";
|
|
9
|
+
import { textareaDefaults, textareaVariants } from "./textarea.variants.js";
|
|
10
|
+
const config = getComponentConfig("textarea", textareaDefaults);
|
|
11
|
+
const icons = getComponentConfig("icons", iconsDefaults);
|
|
12
|
+
let { ref = $bindable(null), value = $bindable(), ui, id, name, color = config.defaultVariants.color, variant = config.defaultVariants.variant, size, highlight, loading = false, loadingIcon = icons.loading, disabled = false, icon, leadingIcon, trailingIcon, trailing = false, leadingSlot, trailingSlot, autoresize = false, rows = 3, maxrows = 0, class: className, onblur, oninput, onchange, onfocus, ...restProps } = $props();
|
|
13
|
+
const formFieldContext = useFormField();
|
|
14
|
+
const emit = useFormFieldEmit();
|
|
15
|
+
function handleBlur(event) {
|
|
16
|
+
emit.onBlur();
|
|
17
|
+
onblur?.(event);
|
|
18
|
+
}
|
|
19
|
+
function handleInput(event) {
|
|
20
|
+
emit.onInput();
|
|
21
|
+
oninput?.(event);
|
|
22
|
+
}
|
|
23
|
+
function handleChange(event) {
|
|
24
|
+
emit.onChange();
|
|
25
|
+
onchange?.(event);
|
|
26
|
+
}
|
|
27
|
+
function handleFocus(event) {
|
|
28
|
+
emit.onFocus();
|
|
29
|
+
onfocus?.(event);
|
|
30
|
+
}
|
|
31
|
+
const fieldGroupContext = getContext("fieldGroup");
|
|
32
|
+
const hasError = $derived(formFieldContext?.error !== undefined && formFieldContext?.error !== false);
|
|
33
|
+
const resolvedSize = $derived(size ?? formFieldContext?.size ?? fieldGroupContext?.size ?? config.defaultVariants.size);
|
|
34
|
+
const resolvedColor = $derived(hasError ? "error" : color);
|
|
35
|
+
const resolvedHighlight = $derived(highlight ?? hasError);
|
|
36
|
+
const fieldGroupClass = $derived(fieldGroupContext ? fieldGroupVariantWithRoot.fieldGroup[fieldGroupContext.orientation ?? "horizontal"] : undefined);
|
|
37
|
+
const resolvedId = $derived(id ?? formFieldContext?.ariaId);
|
|
38
|
+
const resolvedName = $derived(name ?? formFieldContext?.name);
|
|
39
|
+
const isLeading = $derived(!!icon && !trailing || loading && !trailing || !!leadingIcon);
|
|
40
|
+
const isTrailing = $derived(!!icon && trailing || loading && trailing || !!trailingIcon);
|
|
41
|
+
const leadingIconName = $derived(loading && isLeading ? loadingIcon : leadingIcon || (isLeading && !trailing ? icon : undefined));
|
|
42
|
+
const trailingIconName = $derived(loading && isTrailing ? loadingIcon : trailingIcon || (trailing ? icon : undefined));
|
|
43
|
+
const ariaDescribedBy = $derived(!formFieldContext ? undefined : hasError ? `${formFieldContext.ariaId}-error` : `${formFieldContext.ariaId}-description ${formFieldContext.ariaId}-help`);
|
|
44
|
+
const variantSlots = $derived(textareaVariants({
|
|
45
|
+
variant,
|
|
46
|
+
color: resolvedColor,
|
|
47
|
+
size: resolvedSize,
|
|
48
|
+
leading: isLeading,
|
|
49
|
+
trailing: isTrailing,
|
|
50
|
+
loading,
|
|
51
|
+
highlight: resolvedHighlight,
|
|
52
|
+
autoresize
|
|
53
|
+
}));
|
|
54
|
+
const classes = $derived({
|
|
55
|
+
root: variantSlots.root({ class: [
|
|
56
|
+
config.slots.root,
|
|
57
|
+
fieldGroupClass?.root,
|
|
58
|
+
className,
|
|
59
|
+
ui?.root
|
|
60
|
+
] }),
|
|
61
|
+
base: variantSlots.base({ class: [
|
|
62
|
+
config.slots.base,
|
|
63
|
+
fieldGroupClass?.base,
|
|
64
|
+
ui?.base
|
|
65
|
+
] }),
|
|
66
|
+
leading: variantSlots.leading({ class: [config.slots.leading, ui?.leading] }),
|
|
67
|
+
leadingIcon: variantSlots.leadingIcon({ class: [config.slots.leadingIcon, ui?.leadingIcon] }),
|
|
68
|
+
trailing: variantSlots.trailing({ class: [config.slots.trailing, ui?.trailing] }),
|
|
69
|
+
trailingIcon: variantSlots.trailingIcon({ class: [config.slots.trailingIcon, ui?.trailingIcon] })
|
|
70
|
+
});
|
|
71
|
+
let cachedMaxHeight = $state(0);
|
|
72
|
+
$effect(() => {
|
|
73
|
+
if (!autoresize || !ref || maxrows <= 0) {
|
|
74
|
+
cachedMaxHeight = 0;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const style = window.getComputedStyle(ref);
|
|
78
|
+
cachedMaxHeight = parseFloat(style.lineHeight) * maxrows + parseFloat(style.paddingTop) + parseFloat(style.paddingBottom);
|
|
79
|
+
});
|
|
80
|
+
$effect(() => {
|
|
81
|
+
if (!autoresize || !ref) return;
|
|
82
|
+
void value;
|
|
83
|
+
ref.style.height = "auto";
|
|
84
|
+
const scrollHeight = ref.scrollHeight;
|
|
85
|
+
if (cachedMaxHeight > 0 && scrollHeight > cachedMaxHeight) {
|
|
86
|
+
ref.style.height = `${cachedMaxHeight}px`;
|
|
87
|
+
ref.style.overflowY = "auto";
|
|
88
|
+
} else {
|
|
89
|
+
ref.style.height = `${scrollHeight}px`;
|
|
90
|
+
ref.style.overflowY = "hidden";
|
|
91
|
+
}
|
|
92
|
+
});
|
|
176
93
|
</script>
|
|
177
94
|
|
|
178
95
|
<div class={classes.root}>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TextareaProps } from './textarea.types.js';
|
|
2
2
|
export type Props = TextareaProps;
|
|
3
|
-
declare const Textarea: import("svelte").Component<TextareaProps, {}, "
|
|
3
|
+
declare const Textarea: import("svelte").Component<TextareaProps, {}, "ref" | "value">;
|
|
4
4
|
type Textarea = ReturnType<typeof Textarea>;
|
|
5
5
|
export default Textarea;
|
|
@@ -1,43 +1,21 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import type { ThemeModeButtonProps } from './theme-mode-button.types.js'
|
|
3
|
-
|
|
4
|
-
export type Props = ThemeModeButtonProps
|
|
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
|
-
variant = config.defaultVariants.variant ?? 'ghost',
|
|
23
|
-
size,
|
|
24
|
-
lightIcon = icons.light,
|
|
25
|
-
darkIcon = icons.dark,
|
|
26
|
-
loading = false,
|
|
27
|
-
disabled = false,
|
|
28
|
-
square = true,
|
|
29
|
-
block = false,
|
|
30
|
-
children,
|
|
31
|
-
class: className,
|
|
32
|
-
...restProps
|
|
33
|
-
}: Props = $props()
|
|
34
|
-
|
|
35
|
-
const isDark = $derived(mode.current === 'dark')
|
|
36
|
-
|
|
37
|
-
const slots = themeModeButtonVariants()
|
|
38
|
-
const baseClass = $derived(slots.base({ class: [config.slots.base, className, ui?.base] }))
|
|
39
|
-
|
|
40
|
-
const iconName = $derived(isDark ? lightIcon : darkIcon)
|
|
4
|
+
<script lang="ts">import { mode, toggleMode } from "mode-watcher";
|
|
5
|
+
import Button from "../Button/Button.svelte";
|
|
6
|
+
import { getComponentConfig, iconsDefaults } from "../config.js";
|
|
7
|
+
import { themeModeButtonDefaults, themeModeButtonVariants } from "./theme-mode-button.variants.js";
|
|
8
|
+
const config = getComponentConfig("themeModeButton", themeModeButtonDefaults);
|
|
9
|
+
const icons = getComponentConfig("icons", iconsDefaults);
|
|
10
|
+
let { ui, color = config.defaultVariants.color ?? "surface", variant = config.defaultVariants.variant ?? "ghost", size, lightIcon = icons.light, darkIcon = icons.dark, loading = false, disabled = false, square = true, block = false, children, class: className, ...restProps } = $props();
|
|
11
|
+
const isDark = $derived(mode.current === "dark");
|
|
12
|
+
const slots = themeModeButtonVariants();
|
|
13
|
+
const baseClass = $derived(slots.base({ class: [
|
|
14
|
+
config.slots.base,
|
|
15
|
+
className,
|
|
16
|
+
ui?.base
|
|
17
|
+
] }));
|
|
18
|
+
const iconName = $derived(isDark ? lightIcon : darkIcon);
|
|
41
19
|
</script>
|
|
42
20
|
|
|
43
21
|
{#if children}
|