webcoreui 1.4.0 → 1.5.0-beta.1

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 (262) hide show
  1. package/README.md +15 -1
  2. package/astro.d.ts +62 -56
  3. package/astro.js +4 -0
  4. package/components/Accordion/Accordion.astro +1 -1
  5. package/components/Accordion/Accordion.svelte +60 -58
  6. package/components/Accordion/Accordion.tsx +3 -1
  7. package/components/Alert/Alert.astro +2 -1
  8. package/components/Alert/Alert.svelte +12 -5
  9. package/components/Alert/Alert.tsx +10 -3
  10. package/components/Alert/alert.ts +2 -18
  11. package/components/AspectRatio/AspectRatio.astro +1 -1
  12. package/components/AspectRatio/AspectRatio.svelte +27 -22
  13. package/components/AspectRatio/AspectRatio.tsx +6 -3
  14. package/components/AspectRatio/aspectratio.ts +0 -10
  15. package/components/Avatar/Avatar.astro +1 -1
  16. package/components/Avatar/Avatar.svelte +7 -5
  17. package/components/Avatar/Avatar.tsx +3 -2
  18. package/components/Avatar/avatar.module.scss +3 -5
  19. package/components/Badge/Badge.astro +2 -1
  20. package/components/Badge/Badge.svelte +11 -4
  21. package/components/Badge/Badge.tsx +8 -3
  22. package/components/Badge/badge.module.scss +5 -6
  23. package/components/Badge/badge.ts +11 -13
  24. package/components/Banner/Banner.astro +1 -1
  25. package/components/Banner/Banner.svelte +11 -5
  26. package/components/Banner/Banner.tsx +6 -2
  27. package/components/Banner/banner.module.scss +4 -6
  28. package/components/Banner/banner.ts +0 -10
  29. package/components/BottomNavigation/BottomNavigation.astro +1 -1
  30. package/components/BottomNavigation/BottomNavigation.svelte +7 -4
  31. package/components/BottomNavigation/BottomNavigation.tsx +3 -2
  32. package/components/BottomNavigation/bottomnavigation.module.scss +68 -70
  33. package/components/Breadcrumb/Breadcrumb.astro +1 -1
  34. package/components/Breadcrumb/Breadcrumb.svelte +5 -3
  35. package/components/Breadcrumb/Breadcrumb.tsx +3 -1
  36. package/components/Button/Button.astro +2 -1
  37. package/components/Button/Button.svelte +11 -4
  38. package/components/Button/Button.tsx +7 -2
  39. package/components/Button/button.module.scss +9 -12
  40. package/components/Button/button.ts +23 -20
  41. package/components/Card/Card.astro +9 -2
  42. package/components/Card/Card.svelte +21 -8
  43. package/components/Card/Card.tsx +23 -6
  44. package/components/Card/card.module.scss +12 -9
  45. package/components/Card/card.ts +3 -16
  46. package/components/Carousel/Carousel.astro +3 -3
  47. package/components/Carousel/Carousel.svelte +24 -19
  48. package/components/Carousel/Carousel.tsx +9 -4
  49. package/components/Carousel/carousel.module.scss +3 -5
  50. package/components/Carousel/carousel.ts +0 -12
  51. package/components/CarouselItem/CarouselItem.astro +14 -0
  52. package/components/CarouselItem/CarouselItem.svelte +18 -0
  53. package/components/CarouselItem/CarouselItem.tsx +18 -0
  54. package/components/CarouselItem/carouselItem.ts +4 -0
  55. package/components/Checkbox/Checkbox.astro +3 -6
  56. package/components/Checkbox/Checkbox.svelte +13 -10
  57. package/components/Checkbox/Checkbox.tsx +8 -5
  58. package/components/Checkbox/checkbox.module.scss +4 -6
  59. package/components/Checkbox/checkbox.ts +2 -17
  60. package/components/Collapsible/Collapsible.astro +1 -1
  61. package/components/Collapsible/Collapsible.svelte +13 -6
  62. package/components/Collapsible/Collapsible.tsx +8 -2
  63. package/components/Collapsible/collapsible.module.scss +5 -5
  64. package/components/Collapsible/collapsible.ts +0 -15
  65. package/components/ConditionalWrapper/ConditionalWrapper.astro +1 -1
  66. package/components/ConditionalWrapper/ConditionalWrapper.svelte +8 -2
  67. package/components/ConditionalWrapper/ConditionalWrapper.tsx +7 -2
  68. package/components/ConditionalWrapper/conditionalwrapper.ts +2 -14
  69. package/components/ContextMenu/ContextMenu.astro +2 -1
  70. package/components/ContextMenu/ContextMenu.svelte +17 -9
  71. package/components/ContextMenu/ContextMenu.tsx +8 -2
  72. package/components/ContextMenu/contextmenu.ts +2 -17
  73. package/components/Copy/Copy.astro +2 -2
  74. package/components/Copy/Copy.svelte +10 -5
  75. package/components/Copy/Copy.tsx +7 -3
  76. package/components/Copy/copy.ts +2 -12
  77. package/components/Counter/Counter.astro +3 -2
  78. package/components/Counter/Counter.svelte +16 -10
  79. package/components/Counter/Counter.tsx +11 -7
  80. package/components/Counter/counter.module.scss +3 -5
  81. package/components/Counter/counter.ts +2 -11
  82. package/components/DataTable/DataTable.astro +1 -1
  83. package/components/DataTable/DataTable.svelte +23 -15
  84. package/components/DataTable/DataTable.tsx +7 -2
  85. package/components/DataTable/datatable.ts +0 -12
  86. package/components/Flex/Flex.astro +2 -1
  87. package/components/Flex/Flex.svelte +12 -6
  88. package/components/Flex/Flex.tsx +8 -3
  89. package/components/Flex/flex.ts +2 -15
  90. package/components/Footer/Footer.astro +1 -1
  91. package/components/Footer/Footer.svelte +13 -8
  92. package/components/Footer/Footer.tsx +6 -2
  93. package/components/Footer/footer.ts +0 -10
  94. package/components/Grid/Grid.astro +2 -1
  95. package/components/Grid/Grid.svelte +12 -6
  96. package/components/Grid/Grid.tsx +8 -3
  97. package/components/Grid/grid.ts +2 -15
  98. package/components/Group/Group.astro +1 -1
  99. package/components/Group/Group.svelte +9 -4
  100. package/components/Group/Group.tsx +6 -2
  101. package/components/Group/group.ts +0 -10
  102. package/components/Icon/Icon.astro +1 -1
  103. package/components/Icon/Icon.svelte +16 -9
  104. package/components/Icon/Icon.tsx +3 -2
  105. package/components/Image/Image.astro +2 -1
  106. package/components/Image/Image.svelte +54 -51
  107. package/components/Image/Image.tsx +3 -1
  108. package/components/Image/image.ts +2 -3
  109. package/components/ImageLoader/ImageLoader.astro +1 -1
  110. package/components/ImageLoader/ImageLoader.svelte +5 -3
  111. package/components/ImageLoader/ImageLoader.tsx +3 -1
  112. package/components/Input/Input.astro +3 -2
  113. package/components/Input/Input.svelte +19 -9
  114. package/components/Input/Input.tsx +11 -3
  115. package/components/Input/input.ts +26 -53
  116. package/components/Kbd/Kbd.astro +1 -1
  117. package/components/Kbd/Kbd.svelte +9 -4
  118. package/components/Kbd/Kbd.tsx +6 -2
  119. package/components/Kbd/kbd.ts +0 -10
  120. package/components/List/List.astro +1 -1
  121. package/components/List/List.svelte +13 -9
  122. package/components/List/List.tsx +10 -6
  123. package/components/List/list.ts +0 -8
  124. package/components/Masonry/Masonry.astro +1 -1
  125. package/components/Masonry/Masonry.svelte +14 -9
  126. package/components/Masonry/Masonry.tsx +7 -3
  127. package/components/Masonry/masonry.module.scss +4 -6
  128. package/components/Masonry/masonry.ts +2 -13
  129. package/components/Menu/Menu.astro +1 -1
  130. package/components/Menu/Menu.svelte +13 -7
  131. package/components/Menu/Menu.tsx +6 -2
  132. package/components/Menu/menu.ts +0 -10
  133. package/components/Modal/Modal.astro +2 -3
  134. package/components/Modal/Modal.svelte +12 -8
  135. package/components/Modal/Modal.tsx +6 -4
  136. package/components/Modal/modal.module.scss +5 -5
  137. package/components/Modal/modal.ts +2 -14
  138. package/components/OTPInput/OTPInput.astro +3 -5
  139. package/components/OTPInput/OTPInput.svelte +10 -10
  140. package/components/OTPInput/OTPInput.tsx +10 -8
  141. package/components/OTPInput/otpinput.module.scss +0 -12
  142. package/components/OTPInput/otpinput.ts +2 -4
  143. package/components/Pagination/Pagination.astro +1 -1
  144. package/components/Pagination/Pagination.svelte +8 -4
  145. package/components/Pagination/Pagination.tsx +6 -2
  146. package/components/Pagination/pagination.ts +0 -8
  147. package/components/Popover/Popover.astro +3 -7
  148. package/components/Popover/Popover.svelte +11 -10
  149. package/components/Popover/Popover.tsx +9 -12
  150. package/components/Popover/popover.ts +2 -15
  151. package/components/Progress/Progress.astro +1 -1
  152. package/components/Progress/Progress.svelte +8 -6
  153. package/components/Progress/Progress.tsx +3 -1
  154. package/components/Progress/progress.module.scss +15 -17
  155. package/components/Radio/Radio.astro +4 -4
  156. package/components/Radio/Radio.svelte +15 -8
  157. package/components/Radio/Radio.tsx +8 -5
  158. package/components/Radio/radio.module.scss +4 -6
  159. package/components/Radio/radio.ts +3 -14
  160. package/components/RangeSlider/RangeSlider.astro +5 -2
  161. package/components/RangeSlider/RangeSlider.svelte +20 -35
  162. package/components/RangeSlider/RangeSlider.tsx +11 -4
  163. package/components/RangeSlider/rangeslider.module.scss +14 -16
  164. package/components/RangeSlider/rangeslider.ts +1 -9
  165. package/components/Rating/Rating.astro +1 -1
  166. package/components/Rating/Rating.svelte +10 -7
  167. package/components/Rating/Rating.tsx +3 -1
  168. package/components/Rating/rating.module.scss +13 -15
  169. package/components/Ribbon/Ribbon.astro +1 -1
  170. package/components/Ribbon/Ribbon.svelte +9 -4
  171. package/components/Ribbon/Ribbon.tsx +6 -2
  172. package/components/Ribbon/ribbon.module.scss +9 -11
  173. package/components/Ribbon/ribbon.ts +0 -10
  174. package/components/Select/Select.astro +3 -1
  175. package/components/Select/Select.svelte +179 -171
  176. package/components/Select/Select.tsx +11 -4
  177. package/components/Select/select.ts +2 -12
  178. package/components/Sheet/Sheet.astro +2 -1
  179. package/components/Sheet/Sheet.svelte +7 -5
  180. package/components/Sheet/Sheet.tsx +5 -4
  181. package/components/Sheet/sheet.ts +3 -10
  182. package/components/Sidebar/Sidebar.astro +1 -1
  183. package/components/Sidebar/Sidebar.svelte +9 -4
  184. package/components/Sidebar/Sidebar.tsx +6 -2
  185. package/components/Sidebar/sidebar.ts +0 -10
  186. package/components/Skeleton/Skeleton.astro +1 -1
  187. package/components/Skeleton/Skeleton.svelte +7 -5
  188. package/components/Skeleton/Skeleton.tsx +3 -1
  189. package/components/Skeleton/skeleton.module.scss +6 -9
  190. package/components/Slider/Slider.astro +7 -5
  191. package/components/Slider/Slider.svelte +18 -10
  192. package/components/Slider/Slider.tsx +12 -6
  193. package/components/Slider/slider.module.scss +12 -14
  194. package/components/Slider/slider.ts +3 -12
  195. package/components/SpeedDial/SpeedDial.astro +1 -1
  196. package/components/SpeedDial/SpeedDial.svelte +6 -4
  197. package/components/SpeedDial/SpeedDial.tsx +4 -2
  198. package/components/SpeedDial/speeddial.module.scss +4 -6
  199. package/components/Spinner/Spinner.astro +1 -1
  200. package/components/Spinner/Spinner.svelte +7 -5
  201. package/components/Spinner/Spinner.tsx +3 -1
  202. package/components/Spinner/spinner.module.scss +13 -14
  203. package/components/Spoiler/Spoiler.astro +1 -1
  204. package/components/Spoiler/Spoiler.svelte +11 -5
  205. package/components/Spoiler/Spoiler.tsx +6 -2
  206. package/components/Spoiler/spoiler.module.scss +3 -5
  207. package/components/Spoiler/spoiler.ts +0 -10
  208. package/components/Stepper/Stepper.astro +1 -1
  209. package/components/Stepper/Stepper.svelte +7 -5
  210. package/components/Stepper/Stepper.tsx +3 -1
  211. package/components/Stepper/stepper.defaults.scss +5 -0
  212. package/components/Stepper/stepper.module.scss +11 -13
  213. package/components/Switch/Switch.astro +7 -2
  214. package/components/Switch/Switch.svelte +17 -8
  215. package/components/Switch/Switch.tsx +8 -4
  216. package/components/Switch/switch.module.scss +5 -7
  217. package/components/Switch/switch.ts +2 -16
  218. package/components/Tab/Tab.astro +25 -0
  219. package/components/Tab/Tab.svelte +28 -0
  220. package/components/Tab/Tab.tsx +30 -0
  221. package/components/Tab/tab.ts +6 -0
  222. package/components/Table/Table.astro +1 -1
  223. package/components/Table/Table.svelte +5 -3
  224. package/components/Table/Table.tsx +3 -1
  225. package/components/Tabs/Tabs.astro +58 -25
  226. package/components/Tabs/Tabs.svelte +47 -14
  227. package/components/Tabs/Tabs.tsx +42 -11
  228. package/components/Tabs/tabs.module.scss +7 -6
  229. package/components/Tabs/tabs.ts +0 -10
  230. package/components/Textarea/Textarea.astro +3 -6
  231. package/components/Textarea/Textarea.svelte +13 -10
  232. package/components/Textarea/Textarea.tsx +9 -7
  233. package/components/Textarea/textarea.ts +2 -17
  234. package/components/ThemeSwitcher/ThemeSwitcher.astro +1 -1
  235. package/components/ThemeSwitcher/ThemeSwitcher.svelte +14 -8
  236. package/components/ThemeSwitcher/ThemeSwitcher.tsx +7 -2
  237. package/components/ThemeSwitcher/themeswitcher.module.scss +10 -12
  238. package/components/ThemeSwitcher/themeswitcher.ts +0 -13
  239. package/components/Timeline/Timeline.astro +1 -1
  240. package/components/Timeline/Timeline.svelte +11 -6
  241. package/components/Timeline/Timeline.tsx +6 -2
  242. package/components/Timeline/timeline.module.scss +6 -8
  243. package/components/Timeline/timeline.ts +0 -10
  244. package/components/TimelineItem/TimelineItem.astro +1 -1
  245. package/components/TimelineItem/TimelineItem.svelte +9 -4
  246. package/components/TimelineItem/TimelineItem.tsx +8 -3
  247. package/components/TimelineItem/timelineitem.module.scss +4 -4
  248. package/components/TimelineItem/timelineitem.ts +0 -12
  249. package/components/Toast/Toast.astro +2 -1
  250. package/components/Toast/Toast.svelte +9 -7
  251. package/components/Toast/Toast.tsx +5 -4
  252. package/components/Toast/toast.ts +3 -11
  253. package/package.json +19 -19
  254. package/react.d.ts +145 -138
  255. package/react.js +4 -0
  256. package/scss/config/functions.scss +41 -0
  257. package/scss/config/mixins.scss +65 -0
  258. package/scss/config.scss +1 -0
  259. package/scss/global/theme.scss +209 -194
  260. package/scss/setup.scss +6 -3
  261. package/svelte.d.ts +145 -138
  262. package/svelte.js +4 -0
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
- import type { SvelteCheckboxProps } from './checkbox'
2
+ import type { ChangeEventHandler, HTMLInputAttributes, MouseEventHandler } from 'svelte/elements'
3
+ import type { CheckboxProps } from './checkbox'
3
4
 
4
5
  import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
5
6
 
@@ -9,27 +10,31 @@
9
10
 
10
11
  import styles from './checkbox.module.scss'
11
12
 
13
+ export type Props = CheckboxProps<HTMLInputAttributes> & {
14
+ onChange?: ChangeEventHandler<HTMLInputElement>
15
+ onClick?: MouseEventHandler<HTMLInputElement>
16
+ }
17
+
12
18
  const {
13
- checked,
14
19
  label,
15
20
  subText,
16
- disabled,
17
21
  color,
18
22
  className,
19
23
  onClick,
20
24
  onChange,
21
25
  ...rest
22
- }: SvelteCheckboxProps = $props()
26
+ }: Props = $props()
23
27
 
24
- const classes = classNames([
28
+ const classes = $derived(classNames([
25
29
  styles.checkbox,
26
30
  label && subText && styles.col,
27
31
  className
28
- ])
32
+ ]))
29
33
 
30
- const style = color
34
+ const style = $derived(color
31
35
  ? `--w-checkbox-color: ${color};`
32
36
  : null
37
+ )
33
38
  </script>
34
39
 
35
40
  <label class={classes} style={style}>
@@ -39,12 +44,10 @@
39
44
  class={styles.wrapper}
40
45
  >
41
46
  <input
47
+ {...rest}
42
48
  type="checkbox"
43
- checked={checked}
44
- disabled={disabled}
45
49
  onclick={onClick}
46
50
  onchange={onChange}
47
- {...rest}
48
51
  />
49
52
  <span class={styles.check}>
50
53
  {@html check}
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import type { ReactCheckboxProps } from './checkbox'
2
+ import type { CheckboxProps } from './checkbox'
3
3
 
4
4
  import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
5
5
 
@@ -9,15 +9,19 @@ import check from '../../icons/check.svg?raw'
9
9
 
10
10
  import styles from './checkbox.module.scss'
11
11
 
12
+ export type Props = CheckboxProps<React.InputHTMLAttributes<HTMLInputElement>> & {
13
+ onChange?: React.ChangeEventHandler<HTMLInputElement>
14
+ onClick?: React.MouseEventHandler<HTMLInputElement>
15
+ }
16
+
12
17
  const Checkbox = ({
13
18
  checked,
14
19
  label,
15
20
  subText,
16
- disabled,
17
21
  color,
18
22
  className,
19
23
  ...rest
20
- }: ReactCheckboxProps) => {
24
+ }: Props) => {
21
25
  const classes = classNames([
22
26
  styles.checkbox,
23
27
  label && subText && styles.col,
@@ -39,10 +43,9 @@ const Checkbox = ({
39
43
  )}
40
44
  >
41
45
  <input
46
+ {...rest}
42
47
  type="checkbox"
43
48
  defaultChecked={checked}
44
- disabled={disabled}
45
- {...rest}
46
49
  />
47
50
  <span
48
51
  className={styles.check}
@@ -1,10 +1,8 @@
1
1
  @use '../../scss/config.scss' as *;
2
2
 
3
- body {
4
- --w-checkbox-color: var(--w-color-primary);
5
- }
6
-
7
3
  .checkbox {
4
+ --color: var(--w-checkbox-color, var(--w-color-primary));
5
+
8
6
  @include layout(inline-flex, sm);
9
7
  @include typography(hmd);
10
8
 
@@ -22,7 +20,7 @@ body {
22
20
  display: none;
23
21
 
24
22
  &:checked + span {
25
- @include background(var(--w-checkbox-color));
23
+ @include background(var(--color));
26
24
 
27
25
  svg {
28
26
  @include position(absolute, center);
@@ -48,7 +46,7 @@ body {
48
46
 
49
47
  display: inline-block;
50
48
  min-width: 15px;
51
- border: 1px solid var(--w-checkbox-color);
49
+ border: 1px solid var(--color);
52
50
 
53
51
  svg {
54
52
  @include visibility(none);
@@ -1,21 +1,6 @@
1
- import type { ChangeEventHandler, MouseEventHandler } from 'svelte/elements'
2
-
3
- export type CheckboxProps = {
4
- checked?: boolean
1
+ export type CheckboxProps<T extends object = object> = {
5
2
  label?: string
6
3
  subText?: string
7
- disabled?: boolean
8
4
  color?: string
9
5
  className?: string
10
- [key: string]: any
11
- }
12
-
13
- export type SvelteCheckboxProps = {
14
- onChange?: ChangeEventHandler<HTMLInputElement>
15
- onClick?: MouseEventHandler<HTMLInputElement>
16
- } & CheckboxProps
17
-
18
- export type ReactCheckboxProps = {
19
- onChange?: React.ChangeEventHandler<HTMLInputElement>
20
- onClick?: React.MouseEventHandler<HTMLInputElement>
21
- } & CheckboxProps
6
+ } & T
@@ -5,7 +5,7 @@ import { classNames } from '../../utils/classNames'
5
5
 
6
6
  import styles from './collapsible.module.scss'
7
7
 
8
- interface Props extends CollapsibleProps {}
8
+ export type Props = CollapsibleProps
9
9
 
10
10
  const {
11
11
  initialHeight,
@@ -1,10 +1,17 @@
1
1
  <script lang="ts">
2
- import type { SvelteCollapsibleProps } from './collapsible'
2
+ import type { Snippet } from 'svelte'
3
+ import type { CollapsibleProps } from './collapsible'
3
4
 
4
5
  import { classNames } from '../../utils/classNames'
5
6
 
6
7
  import styles from './collapsible.module.scss'
7
8
 
9
+ export type Props = CollapsibleProps & {
10
+ on: Snippet
11
+ off: Snippet
12
+ children: Snippet
13
+ }
14
+
8
15
  let {
9
16
  initialHeight,
10
17
  maxHeight,
@@ -14,18 +21,18 @@
14
21
  children,
15
22
  off,
16
23
  on
17
- }: SvelteCollapsibleProps = $props()
24
+ }: Props = $props()
18
25
 
19
- const classes = classNames([
26
+ const classes = $derived(classNames([
20
27
  styles.collapsible,
21
28
  maxHeight && styles.animated,
22
29
  className
23
- ])
30
+ ]))
24
31
 
25
- const styleVariables = classNames([
32
+ const styleVariables = $derived(classNames([
26
33
  initialHeight && `--w-collapsible-initial-height: ${initialHeight};`,
27
34
  maxHeight && `--w-collapsible-max-height: ${maxHeight};`
28
- ])
35
+ ]))
29
36
  </script>
30
37
 
31
38
  <div
@@ -1,10 +1,16 @@
1
1
  import React, { useState } from 'react'
2
- import type { ReactCollapsibleProps } from './collapsible'
2
+ import type { CollapsibleProps } from './collapsible'
3
3
 
4
4
  import { classNames } from '../../utils/classNames'
5
5
 
6
6
  import styles from './collapsible.module.scss'
7
7
 
8
+ export type Props = CollapsibleProps & {
9
+ on: React.ReactNode
10
+ off: React.ReactNode
11
+ children: React.ReactNode
12
+ }
13
+
8
14
  const Collapsible = ({
9
15
  initialHeight,
10
16
  maxHeight,
@@ -14,7 +20,7 @@ const Collapsible = ({
14
20
  children,
15
21
  className,
16
22
  togglesClassName
17
- }: ReactCollapsibleProps) => {
23
+ }: Props) => {
18
24
  const [toggle, setToggled] = useState(toggled)
19
25
 
20
26
  const classes = classNames([
@@ -1,8 +1,8 @@
1
1
  @use '../../scss/config.scss' as *;
2
2
 
3
- body {
4
- --w-collapsible-initial-height: 0;
5
- --w-collapsible-max-height: 100%;
3
+ .wrapper {
4
+ --initial-height: var(--w-collapsible-initial-height, 0);
5
+ --max-height: var(--w-collapsible-max-height, 100%);
6
6
  }
7
7
 
8
8
  .collapsible {
@@ -14,7 +14,7 @@ body {
14
14
  }
15
15
 
16
16
  &[data-toggled="true"] .wrapper {
17
- max-height: var(--w-collapsible-max-height);
17
+ max-height: var(--max-height);
18
18
  }
19
19
 
20
20
  &.animated .wrapper {
@@ -24,6 +24,6 @@ body {
24
24
  .wrapper {
25
25
  @include visibility(hidden);
26
26
 
27
- max-height: var(--w-collapsible-initial-height);
27
+ max-height: var(--initial-height);
28
28
  }
29
29
  }
@@ -1,5 +1,3 @@
1
- import type { Snippet } from 'svelte'
2
-
3
1
  export type CollapsibleProps = {
4
2
  initialHeight?: string
5
3
  maxHeight?: string
@@ -7,16 +5,3 @@ export type CollapsibleProps = {
7
5
  className?: string
8
6
  togglesClassName?: string
9
7
  }
10
-
11
- export type SvelteCollapsibleProps = {
12
- on: Snippet
13
- off: Snippet
14
- children: Snippet
15
- } & CollapsibleProps
16
-
17
- export type ReactCollapsibleProps = {
18
- on: React.ReactNode
19
- off: React.ReactNode
20
- children: React.ReactNode
21
- } & CollapsibleProps
22
-
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { ConditionalWrapperProps } from './conditionalwrapper'
3
3
 
4
- interface Props extends ConditionalWrapperProps {}
4
+ export type Props = ConditionalWrapperProps
5
5
 
6
6
  const { condition } = Astro.props
7
7
 
@@ -1,12 +1,18 @@
1
1
  <script lang="ts">
2
- import type { SvelteConditionalWrapperProps } from './conditionalwrapper'
2
+ import type { Snippet } from 'svelte'
3
+ import type { ConditionalWrapperProps } from './conditionalwrapper'
4
+
5
+ export type Props = ConditionalWrapperProps & {
6
+ children: Snippet
7
+ element?: string
8
+ }
3
9
 
4
10
  const {
5
11
  condition,
6
12
  element = 'div',
7
13
  children,
8
14
  ...rest
9
- }: SvelteConditionalWrapperProps = $props()
15
+ }: Props = $props()
10
16
  </script>
11
17
 
12
18
  {#if condition}
@@ -1,6 +1,11 @@
1
- import type { ReactConditionalWrapperProps } from './conditionalwrapper'
1
+ import type { ConditionalWrapperProps } from './conditionalwrapper'
2
2
 
3
- const ConditionalWrapper = ({ condition, wrapper, children }: ReactConditionalWrapperProps) =>
3
+ export type Props = ConditionalWrapperProps & {
4
+ wrapper: (_: React.ReactNode) => any
5
+ children: React.ReactNode
6
+ }
7
+
8
+ const ConditionalWrapper = ({ condition, wrapper, children }: Props) =>
4
9
  condition ? wrapper(children) : children
5
10
 
6
11
  export default ConditionalWrapper
@@ -1,15 +1,3 @@
1
- import type { Snippet } from 'svelte'
2
-
3
- export type ConditionalWrapperProps = {
1
+ export type ConditionalWrapperProps<T extends object = Record<string, unknown>> = {
4
2
  condition: boolean
5
- [key: string]: any
6
- }
7
-
8
- export type SvelteConditionalWrapperProps = {
9
- children: Snippet
10
- } & ConditionalWrapperProps
11
-
12
- export type ReactConditionalWrapperProps = {
13
- wrapper: (_: React.ReactNode) => any
14
- children: React.ReactNode
15
- } & ConditionalWrapperProps
3
+ } & T
@@ -1,11 +1,12 @@
1
1
  ---
2
+ import type { HTMLAttributes } from 'astro/types'
2
3
  import type { ContextMenuProps } from './contextmenu'
3
4
 
4
5
  import { classNames } from '../../utils/classNames'
5
6
 
6
7
  import styles from './contextmenu.module.scss'
7
8
 
8
- interface Props extends ContextMenuProps {}
9
+ export type Props = ContextMenuProps<HTMLAttributes<'div'>>
9
10
 
10
11
  const {
11
12
  element = 'div',
@@ -1,24 +1,30 @@
1
1
  <script lang="ts">
2
- import { onMount } from 'svelte'
3
- import type { SvelteContextMenuProps } from './contextmenu'
2
+ import { onMount, type Snippet } from 'svelte'
3
+ import type { HTMLAttributes } from 'svelte/elements'
4
+ import type { ContextMenuProps } from './contextmenu'
4
5
 
5
6
  import { classNames } from '../../utils/classNames'
6
7
  import { on } from '../../utils/DOMUtils'
7
8
 
8
9
  import styles from './contextmenu.module.scss'
9
10
 
11
+ export type Props = ContextMenuProps<HTMLAttributes<HTMLElement>> & {
12
+ children: Snippet
13
+ context: Snippet
14
+ }
15
+
10
16
  const {
11
17
  element = 'div',
12
18
  className,
13
19
  children,
14
20
  context,
15
21
  ...rest
16
- }: SvelteContextMenuProps = $props()
22
+ }: Props = $props()
17
23
 
18
- const classes = classNames([
24
+ const classes = $derived(classNames([
19
25
  styles.ctx,
20
26
  className
21
- ])
27
+ ]))
22
28
 
23
29
  const showContext = (event: MouseEvent) => {
24
30
  event.preventDefault()
@@ -67,10 +73,12 @@
67
73
  }
68
74
  })
69
75
 
70
- if (!context) {
71
- // eslint-disable-next-line no-console, max-len
72
- console.error('Missing "context" slot. Attach slot="context" to one of the children of your <ContextMenu> component.')
73
- }
76
+ $effect(() => {
77
+ if (!context) {
78
+ // eslint-disable-next-line no-console, max-len
79
+ console.error('Missing "context" slot. Attach slot="context" to one of the children of your <ContextMenu> component.')
80
+ }
81
+ })
74
82
  </script>
75
83
 
76
84
  <svelte:element {...rest} this={element} class={classes} bind:this={ctx}>
@@ -1,18 +1,24 @@
1
1
  import React, { useEffect, useRef } from 'react'
2
- import type { ReactContextMenuProps } from './contextmenu'
2
+ import type { ContextMenuProps } from './contextmenu'
3
3
 
4
4
  import { classNames } from '../../utils/classNames'
5
5
  import { on } from '../../utils/DOMUtils'
6
6
 
7
7
  import styles from './contextmenu.module.scss'
8
8
 
9
+ export type Props = Omit<ContextMenuProps, 'element'> & {
10
+ Element?: React.ElementType
11
+ children: React.ReactNode
12
+ context: React.ReactNode
13
+ }
14
+
9
15
  const ContextMenu = ({
10
16
  Element = 'div',
11
17
  className,
12
18
  children,
13
19
  context,
14
20
  ...rest
15
- }: ReactContextMenuProps) => {
21
+ }: Props) => {
16
22
  const ctx = useRef<HTMLElement>(null)
17
23
  const content = useRef<HTMLDivElement>(null)
18
24
  const classes = classNames([
@@ -1,19 +1,4 @@
1
- import type React from 'react'
2
- import type { Snippet } from 'svelte'
3
-
4
- export type ContextMenuProps = {
1
+ export type ContextMenuProps<T extends object = object> = {
5
2
  element?: string
6
3
  className?: string
7
- [key: string]: any
8
- }
9
-
10
- export type SvelteContextMenuProps = {
11
- children: Snippet
12
- context: Snippet
13
- } & ContextMenuProps
14
-
15
- export type ReactContextMenuProps = {
16
- Element?: React.ElementType
17
- children: React.ReactNode
18
- context: React.ReactNode
19
- } & Omit<ContextMenuProps, 'element'>
4
+ } & T
@@ -1,14 +1,14 @@
1
1
  ---
2
2
  import type { CopyProps } from './copy'
3
3
 
4
- import Badge from '../Badge/Badge.astro'
4
+ import Badge, { type Props as BadgeProps } from '../Badge/Badge.astro'
5
5
  import Icon from '../Icon/Icon.astro'
6
6
 
7
7
  import { classNames } from '../../utils/classNames'
8
8
 
9
9
  import styles from './copy.module.scss'
10
10
 
11
- interface Props extends CopyProps {}
11
+ export type Props = CopyProps<BadgeProps>
12
12
 
13
13
  const {
14
14
  tooltip,
@@ -1,7 +1,8 @@
1
1
  <script lang="ts">
2
- import type { SvelteCopyProps } from './copy'
2
+ import type { Snippet } from 'svelte'
3
+ import type { CopyProps } from './copy'
3
4
 
4
- import Badge from '../Badge/Badge.svelte'
5
+ import Badge, { type Props as BadgeProps } from '../Badge/Badge.svelte'
5
6
 
6
7
  import { classNames } from '../../utils/classNames'
7
8
 
@@ -10,6 +11,10 @@
10
11
 
11
12
  import styles from './copy.module.scss'
12
13
 
14
+ export type Props = CopyProps<BadgeProps> & {
15
+ children: Snippet
16
+ }
17
+
13
18
  let {
14
19
  tooltip = $bindable(''),
15
20
  tooltipPosition,
@@ -18,12 +23,12 @@
18
23
  className,
19
24
  children,
20
25
  ...rest
21
- }: SvelteCopyProps = $props()
26
+ }: Props = $props()
22
27
 
23
- const classes = classNames([
28
+ const classes = $derived(classNames([
24
29
  styles.copy,
25
30
  className
26
- ])
31
+ ]))
27
32
 
28
33
  let copyButton: HTMLButtonElement | undefined = $state()
29
34
  let copiedButton: HTMLSpanElement | undefined = $state()
@@ -1,7 +1,7 @@
1
1
  import React, { useRef, useState } from 'react'
2
- import type { ReactCopyProps } from './copy'
2
+ import type { CopyProps } from './copy'
3
3
 
4
- import Badge from '../Badge/Badge.tsx'
4
+ import Badge, { type Props as BadgeProps } from '../Badge/Badge.tsx'
5
5
 
6
6
  import { classNames } from '../../utils/classNames'
7
7
 
@@ -10,6 +10,10 @@ import copy from '../../icons/copy.svg?raw'
10
10
 
11
11
  import styles from './copy.module.scss'
12
12
 
13
+ export type Props = CopyProps<BadgeProps> & {
14
+ children: React.ReactNode
15
+ }
16
+
13
17
  const Copy = ({
14
18
  tooltip,
15
19
  tooltipPosition,
@@ -18,7 +22,7 @@ const Copy = ({
18
22
  className,
19
23
  children,
20
24
  ...rest
21
- }: ReactCopyProps) => {
25
+ }: Props) => {
22
26
  const copyButton = useRef<HTMLButtonElement>(null)
23
27
  const copiedButton = useRef<HTMLSpanElement>(null)
24
28
  const [tooltipText, setTooltipText] = useState(tooltip)
@@ -1,20 +1,10 @@
1
- import type { Snippet } from 'svelte'
2
-
3
1
  import type { BadgeProps } from '../Badge/badge'
4
2
  import type { IconProps } from '../Icon/icon'
5
3
 
6
- export type CopyProps = {
4
+ export type CopyProps<T extends object = object> = {
7
5
  tooltip?: string
8
6
  tooltipPosition?: 'left' | 'right' | 'bottom' | null
9
7
  copyIcon?: IconProps['type'] | string
10
8
  copiedIcon?: IconProps['type'] | string
11
9
  className?: string
12
- } & BadgeProps
13
-
14
- export type SvelteCopyProps = {
15
- children: Snippet
16
- } & CopyProps
17
-
18
- export type ReactCopyProps = {
19
- children: React.ReactNode
20
- } & CopyProps
10
+ } & BadgeProps<T>
@@ -1,4 +1,5 @@
1
1
  ---
2
+ import type { HTMLAttributes } from 'astro/types'
2
3
  import type { CounterProps } from './counter'
3
4
 
4
5
  import Icon from '../Icon/Icon.astro'
@@ -8,7 +9,7 @@ import plusIcon from '../../icons/plus.svg?raw'
8
9
 
9
10
  import styles from './counter.module.scss'
10
11
 
11
- interface Props extends CounterProps {}
12
+ export type Props = CounterProps<HTMLAttributes<'input'>>
12
13
 
13
14
  const {
14
15
  type = 'compact',
@@ -49,10 +50,10 @@ const styleVariable = width
49
50
  </Fragment>
50
51
  </button>
51
52
  <input
53
+ {...rest}
52
54
  type="number"
53
55
  value={value}
54
56
  disabled={disabled}
55
- {...rest}
56
57
  />
57
58
  <button data-id="w-counter-max" disabled={disabled}>
58
59
  <Fragment>