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,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
- import { Tabs } from 'bits-ui'
9
- import { tick, untrack } from 'svelte'
10
- import { getComponentConfig } from '../config.js'
11
- import Icon from '../Icon/Icon.svelte'
12
- import { tabsDefaults, tabsVariants } from './tabs.variants.js'
13
-
14
- const config = getComponentConfig('tabs', tabsDefaults)
15
-
16
- let {
17
- ref = $bindable(null),
18
- items = [],
19
- value = $bindable(),
20
- defaultValue,
21
- onValueChange,
22
- variant = config.defaultVariants.variant ?? 'pill',
23
- color = config.defaultVariants.color ?? 'primary',
24
- size = config.defaultVariants.size ?? 'md',
25
- orientation = config.defaultVariants.orientation ?? 'horizontal',
26
- activationMode = 'automatic',
27
- disabled = false,
28
- loop = true,
29
- content: showContent = true,
30
- ui,
31
- class: className,
32
- leading,
33
- label: labelSlot,
34
- trailing,
35
- body: bodySlot,
36
- ...restProps
37
- }: Props = $props()
38
-
39
- // Initialize value if not provided (intentionally reads initial values only)
40
- if (value === undefined) {
41
- value = untrack(
42
- () => defaultValue ?? (items.length > 0 ? (items[0].value ?? '0') : undefined)
43
- )
44
- }
45
-
46
- let listEl: HTMLElement | null = $state(null)
47
- let indicatorStyle = $state('')
48
-
49
- const variantSlots = $derived(tabsVariants({ variant, color, size, orientation }))
50
-
51
- const classes = $derived({
52
- root: variantSlots.root({ class: [config.slots.root, className, ui?.root] }),
53
- list: variantSlots.list({ class: [config.slots.list, ui?.list] }),
54
- indicator: variantSlots.indicator({
55
- class: [config.slots.indicator, ui?.indicator]
56
- }),
57
- trigger: variantSlots.trigger({ class: [config.slots.trigger, ui?.trigger] }),
58
- leadingIcon: variantSlots.leadingIcon({
59
- class: [config.slots.leadingIcon, ui?.leadingIcon]
60
- }),
61
- label: variantSlots.label({ class: [config.slots.label, ui?.label] }),
62
- content: variantSlots.content({ class: [config.slots.content, ui?.content] })
63
- })
64
-
65
- let rafId = 0
66
-
67
- function getItemValue(item: TabsItem, index: number): string {
68
- return item.value ?? String(index)
69
- }
70
-
71
- function getTriggerClass(item: TabsItem) {
72
- if (!item.ui?.trigger && !item.class) return classes.trigger
73
- return variantSlots.trigger({
74
- class: [config.slots.trigger, ui?.trigger, item.ui?.trigger, item.class]
75
- })
76
- }
77
-
78
- function getIconClass(item: TabsItem) {
79
- if (!item.ui?.leadingIcon) return classes.leadingIcon
80
- return variantSlots.leadingIcon({
81
- class: [config.slots.leadingIcon, ui?.leadingIcon, item.ui?.leadingIcon]
82
- })
83
- }
84
-
85
- function getLabelClass(item: TabsItem) {
86
- if (!item.ui?.label) return classes.label
87
- return variantSlots.label({
88
- class: [config.slots.label, ui?.label, item.ui?.label]
89
- })
90
- }
91
-
92
- function updateIndicator() {
93
- if (!listEl) return
94
- const activeTrigger = listEl.querySelector('[data-state="active"]') as HTMLElement
95
- if (!activeTrigger) {
96
- indicatorStyle = 'opacity: 0;'
97
- return
98
- }
99
-
100
- if (orientation === 'horizontal') {
101
- indicatorStyle = `left: ${activeTrigger.offsetLeft}px; width: ${activeTrigger.offsetWidth}px;`
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, {}, "value" | "ref">;
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
- import { getContext } from 'svelte'
9
- import { getComponentConfig, iconsDefaults } from '../config.js'
10
- import {
11
- type FieldGroupVariantProps,
12
- fieldGroupVariantWithRoot
13
- } from '../FieldGroup/field-group.variants.js'
14
- import { useFormField, useFormFieldEmit } from '../hooks/useFormField.svelte.js'
15
- import Icon from '../Icon/Icon.svelte'
16
- import { textareaDefaults, textareaVariants } from './textarea.variants.js'
17
-
18
- const config = getComponentConfig('textarea', textareaDefaults)
19
- const icons = getComponentConfig('icons', iconsDefaults)
20
-
21
- let {
22
- ref = $bindable(null),
23
- value = $bindable(),
24
- ui,
25
- id,
26
- name,
27
- color = config.defaultVariants.color,
28
- variant = config.defaultVariants.variant,
29
- size,
30
- highlight,
31
- loading = false,
32
- loadingIcon = icons.loading,
33
- disabled = false,
34
- icon,
35
- leadingIcon,
36
- trailingIcon,
37
- trailing = false,
38
- leadingSlot,
39
- trailingSlot,
40
- autoresize = false,
41
- rows = 3,
42
- maxrows = 0,
43
- class: className,
44
- onblur,
45
- oninput,
46
- onchange,
47
- onfocus,
48
- ...restProps
49
- }: Props = $props()
50
-
51
- const formFieldContext = useFormField()
52
- const emit = useFormFieldEmit()
53
-
54
- function handleBlur(event: FocusEvent & { currentTarget: HTMLTextAreaElement }) {
55
- emit.onBlur()
56
- onblur?.(event)
57
- }
58
- function handleInput(event: Event & { currentTarget: HTMLTextAreaElement }) {
59
- emit.onInput()
60
- oninput?.(event)
61
- }
62
- function handleChange(event: Event & { currentTarget: HTMLTextAreaElement }) {
63
- emit.onChange()
64
- onchange?.(event)
65
- }
66
- function handleFocus(event: FocusEvent & { currentTarget: HTMLTextAreaElement }) {
67
- emit.onFocus()
68
- onfocus?.(event)
69
- }
70
-
71
- const fieldGroupContext = getContext<
72
- | {
73
- orientation: NonNullable<FieldGroupVariantProps['orientation']>
74
- size: NonNullable<FieldGroupVariantProps['size']>
75
- }
76
- | undefined
77
- >('fieldGroup')
78
-
79
- const hasError = $derived(
80
- formFieldContext?.error !== undefined && formFieldContext?.error !== false
81
- )
82
- const resolvedSize = $derived(
83
- size ?? formFieldContext?.size ?? fieldGroupContext?.size ?? config.defaultVariants.size
84
- )
85
- const resolvedColor = $derived(hasError ? 'error' : color)
86
- const resolvedHighlight = $derived(highlight ?? hasError)
87
- const fieldGroupClass = $derived(
88
- fieldGroupContext
89
- ? fieldGroupVariantWithRoot.fieldGroup[fieldGroupContext.orientation ?? 'horizontal']
90
- : undefined
91
- )
92
-
93
- const resolvedId = $derived(id ?? formFieldContext?.ariaId)
94
- const resolvedName = $derived(name ?? formFieldContext?.name)
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, {}, "value" | "ref">;
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
- import { mode, toggleMode } from 'mode-watcher'
9
- import Button from '../Button/Button.svelte'
10
- import { getComponentConfig, iconsDefaults } from '../config.js'
11
- import {
12
- themeModeButtonDefaults,
13
- themeModeButtonVariants
14
- } from './theme-mode-button.variants.js'
15
-
16
- const config = getComponentConfig('themeModeButton', themeModeButtonDefaults)
17
- const icons = getComponentConfig('icons', iconsDefaults)
18
-
19
- let {
20
- ui,
21
- color = config.defaultVariants.color ?? 'surface',
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}