webcoreui 1.5.0-0 → 1.5.0-beta.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 (228) hide show
  1. package/astro.d.ts +62 -56
  2. package/astro.js +4 -0
  3. package/components/Accordion/Accordion.astro +1 -1
  4. package/components/Accordion/Accordion.svelte +60 -58
  5. package/components/Accordion/Accordion.tsx +4 -2
  6. package/components/Alert/Alert.astro +2 -1
  7. package/components/Alert/Alert.svelte +9 -2
  8. package/components/Alert/Alert.tsx +10 -3
  9. package/components/Alert/alert.ts +2 -18
  10. package/components/AspectRatio/AspectRatio.astro +1 -1
  11. package/components/AspectRatio/AspectRatio.svelte +7 -2
  12. package/components/AspectRatio/AspectRatio.tsx +6 -3
  13. package/components/AspectRatio/aspectratio.ts +0 -10
  14. package/components/Avatar/Avatar.astro +1 -1
  15. package/components/Avatar/Avatar.svelte +3 -1
  16. package/components/Avatar/Avatar.tsx +3 -2
  17. package/components/Badge/Badge.astro +2 -1
  18. package/components/Badge/Badge.svelte +9 -2
  19. package/components/Badge/Badge.tsx +8 -3
  20. package/components/Badge/badge.ts +11 -13
  21. package/components/Banner/Banner.astro +1 -1
  22. package/components/Banner/Banner.svelte +7 -2
  23. package/components/Banner/Banner.tsx +6 -2
  24. package/components/Banner/banner.ts +0 -10
  25. package/components/BottomNavigation/BottomNavigation.astro +1 -1
  26. package/components/BottomNavigation/BottomNavigation.svelte +3 -1
  27. package/components/BottomNavigation/BottomNavigation.tsx +3 -2
  28. package/components/Breadcrumb/Breadcrumb.astro +1 -1
  29. package/components/Breadcrumb/Breadcrumb.svelte +3 -1
  30. package/components/Breadcrumb/Breadcrumb.tsx +3 -1
  31. package/components/Button/Button.astro +2 -1
  32. package/components/Button/Button.svelte +9 -2
  33. package/components/Button/Button.tsx +7 -2
  34. package/components/Button/button.ts +23 -20
  35. package/components/Card/Card.astro +9 -2
  36. package/components/Card/Card.svelte +17 -4
  37. package/components/Card/Card.tsx +23 -6
  38. package/components/Card/card.module.scss +11 -4
  39. package/components/Card/card.ts +3 -16
  40. package/components/Carousel/Carousel.astro +1 -1
  41. package/components/Carousel/Carousel.svelte +8 -3
  42. package/components/Carousel/Carousel.tsx +7 -2
  43. package/components/Carousel/carousel.ts +0 -12
  44. package/components/CarouselItem/CarouselItem.astro +14 -0
  45. package/components/CarouselItem/CarouselItem.svelte +18 -0
  46. package/components/CarouselItem/CarouselItem.tsx +18 -0
  47. package/components/CarouselItem/carouselItem.ts +4 -0
  48. package/components/Checkbox/Checkbox.astro +3 -6
  49. package/components/Checkbox/Checkbox.svelte +9 -7
  50. package/components/Checkbox/Checkbox.tsx +8 -5
  51. package/components/Checkbox/checkbox.ts +2 -17
  52. package/components/Collapsible/Collapsible.astro +1 -1
  53. package/components/Collapsible/Collapsible.svelte +9 -2
  54. package/components/Collapsible/Collapsible.tsx +8 -2
  55. package/components/Collapsible/collapsible.ts +0 -15
  56. package/components/ConditionalWrapper/ConditionalWrapper.astro +1 -1
  57. package/components/ConditionalWrapper/ConditionalWrapper.svelte +8 -2
  58. package/components/ConditionalWrapper/ConditionalWrapper.tsx +7 -2
  59. package/components/ConditionalWrapper/conditionalwrapper.ts +2 -14
  60. package/components/ContextMenu/ContextMenu.astro +2 -1
  61. package/components/ContextMenu/ContextMenu.svelte +9 -3
  62. package/components/ContextMenu/ContextMenu.tsx +8 -2
  63. package/components/ContextMenu/contextmenu.ts +2 -17
  64. package/components/Copy/Copy.astro +2 -2
  65. package/components/Copy/Copy.svelte +8 -3
  66. package/components/Copy/Copy.tsx +7 -3
  67. package/components/Copy/copy.ts +2 -12
  68. package/components/Counter/Counter.astro +3 -2
  69. package/components/Counter/Counter.svelte +10 -5
  70. package/components/Counter/Counter.tsx +11 -7
  71. package/components/Counter/counter.ts +2 -11
  72. package/components/DataTable/DataTable.astro +1 -1
  73. package/components/DataTable/DataTable.svelte +8 -2
  74. package/components/DataTable/DataTable.tsx +7 -2
  75. package/components/DataTable/datatable.ts +0 -12
  76. package/components/Flex/Flex.astro +2 -1
  77. package/components/Flex/Flex.svelte +8 -2
  78. package/components/Flex/Flex.tsx +8 -3
  79. package/components/Flex/flex.ts +2 -15
  80. package/components/Footer/Footer.astro +1 -1
  81. package/components/Footer/Footer.svelte +7 -2
  82. package/components/Footer/Footer.tsx +6 -2
  83. package/components/Footer/footer.ts +0 -10
  84. package/components/Grid/Grid.astro +2 -1
  85. package/components/Grid/Grid.svelte +8 -2
  86. package/components/Grid/Grid.tsx +8 -3
  87. package/components/Grid/grid.ts +2 -15
  88. package/components/Group/Group.astro +1 -1
  89. package/components/Group/Group.svelte +7 -2
  90. package/components/Group/Group.tsx +6 -2
  91. package/components/Group/group.ts +0 -10
  92. package/components/Icon/Icon.astro +1 -1
  93. package/components/Icon/Icon.svelte +3 -1
  94. package/components/Icon/Icon.tsx +3 -2
  95. package/components/Image/Image.astro +2 -1
  96. package/components/Image/Image.svelte +4 -1
  97. package/components/Image/Image.tsx +3 -1
  98. package/components/Image/image.ts +2 -3
  99. package/components/ImageLoader/ImageLoader.astro +1 -1
  100. package/components/ImageLoader/ImageLoader.svelte +3 -1
  101. package/components/ImageLoader/ImageLoader.tsx +4 -2
  102. package/components/Input/Input.astro +3 -2
  103. package/components/Input/Input.svelte +14 -4
  104. package/components/Input/Input.tsx +11 -3
  105. package/components/Input/input.ts +26 -53
  106. package/components/Kbd/Kbd.astro +1 -1
  107. package/components/Kbd/Kbd.svelte +7 -2
  108. package/components/Kbd/Kbd.tsx +6 -2
  109. package/components/Kbd/kbd.ts +0 -10
  110. package/components/List/List.astro +1 -1
  111. package/components/List/List.svelte +6 -2
  112. package/components/List/List.tsx +8 -4
  113. package/components/List/list.ts +0 -8
  114. package/components/Masonry/Masonry.astro +1 -1
  115. package/components/Masonry/Masonry.svelte +7 -2
  116. package/components/Masonry/Masonry.tsx +7 -3
  117. package/components/Masonry/masonry.ts +2 -13
  118. package/components/Menu/Menu.astro +1 -1
  119. package/components/Menu/Menu.svelte +7 -2
  120. package/components/Menu/Menu.tsx +6 -2
  121. package/components/Menu/menu.ts +0 -10
  122. package/components/Modal/Modal.astro +2 -3
  123. package/components/Modal/Modal.svelte +8 -4
  124. package/components/Modal/Modal.tsx +6 -4
  125. package/components/Modal/modal.ts +2 -14
  126. package/components/OTPInput/OTPInput.astro +3 -5
  127. package/components/OTPInput/OTPInput.svelte +6 -6
  128. package/components/OTPInput/OTPInput.tsx +10 -8
  129. package/components/OTPInput/otpinput.ts +2 -4
  130. package/components/Pagination/Pagination.astro +1 -1
  131. package/components/Pagination/Pagination.svelte +6 -2
  132. package/components/Pagination/Pagination.tsx +6 -2
  133. package/components/Pagination/pagination.ts +0 -8
  134. package/components/Popover/Popover.astro +3 -7
  135. package/components/Popover/Popover.svelte +9 -8
  136. package/components/Popover/Popover.tsx +9 -12
  137. package/components/Popover/popover.ts +2 -15
  138. package/components/Progress/Progress.astro +1 -1
  139. package/components/Progress/Progress.svelte +3 -1
  140. package/components/Progress/Progress.tsx +3 -1
  141. package/components/Radio/Radio.astro +3 -4
  142. package/components/Radio/Radio.svelte +10 -5
  143. package/components/Radio/Radio.tsx +7 -5
  144. package/components/Radio/radio.ts +2 -14
  145. package/components/RangeSlider/RangeSlider.astro +1 -1
  146. package/components/RangeSlider/RangeSlider.svelte +6 -2
  147. package/components/RangeSlider/RangeSlider.tsx +7 -3
  148. package/components/RangeSlider/rangeslider.ts +0 -9
  149. package/components/Rating/Rating.astro +1 -1
  150. package/components/Rating/Rating.svelte +3 -1
  151. package/components/Rating/Rating.tsx +3 -1
  152. package/components/Ribbon/Ribbon.astro +1 -1
  153. package/components/Ribbon/Ribbon.svelte +7 -2
  154. package/components/Ribbon/Ribbon.tsx +6 -2
  155. package/components/Ribbon/ribbon.ts +0 -10
  156. package/components/Select/Select.astro +1 -1
  157. package/components/Select/Select.svelte +9 -4
  158. package/components/Select/Select.tsx +9 -4
  159. package/components/Select/select.ts +1 -12
  160. package/components/Sheet/Sheet.astro +2 -1
  161. package/components/Sheet/Sheet.svelte +5 -3
  162. package/components/Sheet/Sheet.tsx +5 -4
  163. package/components/Sheet/sheet.ts +3 -10
  164. package/components/Sidebar/Sidebar.astro +1 -1
  165. package/components/Sidebar/Sidebar.svelte +7 -2
  166. package/components/Sidebar/Sidebar.tsx +6 -2
  167. package/components/Sidebar/sidebar.ts +0 -10
  168. package/components/Skeleton/Skeleton.astro +1 -1
  169. package/components/Skeleton/Skeleton.svelte +3 -1
  170. package/components/Skeleton/Skeleton.tsx +3 -1
  171. package/components/Slider/Slider.astro +1 -1
  172. package/components/Slider/Slider.svelte +8 -2
  173. package/components/Slider/Slider.tsx +6 -2
  174. package/components/Slider/slider.ts +0 -10
  175. package/components/SpeedDial/SpeedDial.astro +1 -1
  176. package/components/SpeedDial/SpeedDial.svelte +3 -1
  177. package/components/SpeedDial/SpeedDial.tsx +4 -2
  178. package/components/Spinner/Spinner.astro +1 -1
  179. package/components/Spinner/Spinner.svelte +3 -1
  180. package/components/Spinner/Spinner.tsx +3 -1
  181. package/components/Spoiler/Spoiler.astro +1 -1
  182. package/components/Spoiler/Spoiler.svelte +7 -2
  183. package/components/Spoiler/Spoiler.tsx +6 -2
  184. package/components/Spoiler/spoiler.ts +0 -10
  185. package/components/Stepper/Stepper.astro +1 -1
  186. package/components/Stepper/Stepper.svelte +3 -1
  187. package/components/Stepper/Stepper.tsx +3 -1
  188. package/components/Switch/Switch.astro +7 -2
  189. package/components/Switch/Switch.svelte +13 -4
  190. package/components/Switch/Switch.tsx +8 -4
  191. package/components/Switch/switch.ts +2 -16
  192. package/components/Tab/Tab.astro +25 -0
  193. package/components/Tab/Tab.svelte +28 -0
  194. package/components/Tab/Tab.tsx +30 -0
  195. package/components/Tab/tab.ts +6 -0
  196. package/components/Table/Table.astro +1 -1
  197. package/components/Table/Table.svelte +3 -1
  198. package/components/Table/Table.tsx +3 -1
  199. package/components/Tabs/Tabs.astro +58 -25
  200. package/components/Tabs/Tabs.svelte +45 -12
  201. package/components/Tabs/Tabs.tsx +42 -11
  202. package/components/Tabs/tabs.module.scss +7 -6
  203. package/components/Tabs/tabs.ts +0 -10
  204. package/components/Textarea/Textarea.astro +3 -6
  205. package/components/Textarea/Textarea.svelte +10 -7
  206. package/components/Textarea/Textarea.tsx +9 -7
  207. package/components/Textarea/textarea.ts +2 -17
  208. package/components/ThemeSwitcher/ThemeSwitcher.astro +1 -1
  209. package/components/ThemeSwitcher/ThemeSwitcher.svelte +9 -3
  210. package/components/ThemeSwitcher/ThemeSwitcher.tsx +7 -2
  211. package/components/ThemeSwitcher/themeswitcher.ts +0 -13
  212. package/components/Timeline/Timeline.astro +1 -1
  213. package/components/Timeline/Timeline.svelte +7 -2
  214. package/components/Timeline/Timeline.tsx +6 -2
  215. package/components/Timeline/timeline.ts +0 -10
  216. package/components/TimelineItem/TimelineItem.astro +1 -1
  217. package/components/TimelineItem/TimelineItem.svelte +7 -2
  218. package/components/TimelineItem/TimelineItem.tsx +8 -3
  219. package/components/TimelineItem/timelineitem.ts +0 -12
  220. package/components/Toast/Toast.astro +2 -1
  221. package/components/Toast/Toast.svelte +5 -3
  222. package/components/Toast/Toast.tsx +5 -4
  223. package/components/Toast/toast.ts +3 -11
  224. package/package.json +19 -19
  225. package/react.d.ts +145 -138
  226. package/react.js +4 -0
  227. package/svelte.d.ts +145 -138
  228. package/svelte.js +4 -0
@@ -1,7 +1,4 @@
1
- import type { Snippet } from 'svelte'
2
- import type { MouseEventHandler } from 'svelte/elements'
3
-
4
- export type BadgeProps = {
1
+ type BadgeBase = {
5
2
  theme?: 'secondary'
6
3
  | 'outline'
7
4
  | 'flat'
@@ -14,15 +11,16 @@ export type BadgeProps = {
14
11
  rounded?: boolean
15
12
  transparent?: boolean
16
13
  className?: string
17
- [key: string]: any
18
14
  }
19
15
 
20
- export type SvelteBadgeProps = {
21
- onClick?: MouseEventHandler<HTMLButtonElement> | null
22
- children?: Snippet
23
- } & BadgeProps
16
+ type AsSpan<T extends object = object> = BadgeBase & {
17
+ onClick?: never
18
+ } & T
19
+
20
+ type AsButton<T extends object = object> = BadgeBase & {
21
+ onClick: any
22
+ } & T
24
23
 
25
- export type ReactBadgeProps = {
26
- onClick?: React.MouseEventHandler<HTMLButtonElement>
27
- children?: React.ReactNode
28
- } & BadgeProps
24
+ export type BadgeProps<T extends object = object> =
25
+ | AsSpan<T>
26
+ | AsButton<T>
@@ -7,7 +7,7 @@ import closeIcon from '../../icons/close.svg?raw'
7
7
 
8
8
  import styles from './banner.module.scss'
9
9
 
10
- interface Props extends BannerProps {}
10
+ export type Props = BannerProps
11
11
 
12
12
  const {
13
13
  top,
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
- import type { SvelteBannerProps } from './banner'
2
+ import type { Snippet } from 'svelte'
3
+ import type { BannerProps } from './banner'
3
4
 
4
5
  import Button from '../Button/Button.svelte'
5
6
 
@@ -9,6 +10,10 @@
9
10
 
10
11
  import styles from './banner.module.scss'
11
12
 
13
+ export type Props = BannerProps & {
14
+ children: Snippet
15
+ }
16
+
12
17
  const {
13
18
  top,
14
19
  bottom,
@@ -17,7 +22,7 @@
17
22
  sticky = true,
18
23
  className,
19
24
  children
20
- }: SvelteBannerProps = $props()
25
+ }: Props = $props()
21
26
 
22
27
  const classes = $derived(classNames([
23
28
  styles.banner,
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from 'react'
2
- import type { ReactBannerProps } from './banner'
2
+ import type { BannerProps } from './banner'
3
3
 
4
4
  import Button from '../Button/Button.tsx'
5
5
 
@@ -9,6 +9,10 @@ import closeIcon from '../../icons/close.svg?raw'
9
9
 
10
10
  import styles from './banner.module.scss'
11
11
 
12
+ export type Props = BannerProps & {
13
+ children: React.ReactNode
14
+ }
15
+
12
16
  const Banner = ({
13
17
  top,
14
18
  bottom,
@@ -17,7 +21,7 @@ const Banner = ({
17
21
  sticky = true,
18
22
  className,
19
23
  children
20
- }: ReactBannerProps) => {
24
+ }: Props) => {
21
25
  const [visible, setVisible] = useState(true)
22
26
 
23
27
  const classes = classNames([
@@ -1,5 +1,3 @@
1
- import type { Snippet } from 'svelte'
2
-
3
1
  export type BannerProps = {
4
2
  top?: number
5
3
  bottom?: boolean
@@ -8,11 +6,3 @@ export type BannerProps = {
8
6
  sticky?: boolean
9
7
  className?: string
10
8
  }
11
-
12
- export type SvelteBannerProps = {
13
- children: Snippet
14
- } & BannerProps
15
-
16
- export type ReactBannerProps = {
17
- children: React.ReactNode
18
- } & BannerProps
@@ -5,7 +5,7 @@ import Icon from '../Icon/Icon.astro'
5
5
 
6
6
  import styles from './bottomnavigation.module.scss'
7
7
 
8
- interface Props extends BottomNavigationProps {}
8
+ export type Props = BottomNavigationProps
9
9
 
10
10
  const {
11
11
  items,
@@ -5,13 +5,15 @@
5
5
 
6
6
  import styles from './bottomnavigation.module.scss'
7
7
 
8
+ export type Props = BottomNavigationProps
9
+
8
10
  const {
9
11
  items,
10
12
  separated,
11
13
  floating,
12
14
  maxWidth,
13
15
  className
14
- }: BottomNavigationProps = $props()
16
+ }: Props = $props()
15
17
 
16
18
  const classes = $derived(classNames([
17
19
  styles.nav,
@@ -1,10 +1,11 @@
1
- import React from 'react'
2
1
  import type { BottomNavigationProps } from './bottomnavigation'
3
2
 
4
3
  import { classNames } from '../../utils/classNames'
5
4
 
6
5
  import styles from './bottomnavigation.module.scss'
7
6
 
7
+ export type Props = BottomNavigationProps
8
+
8
9
  type ElementType = BottomNavigationProps['items'][0] & {
9
10
  className: string
10
11
  dangerouslySetInnerHTML: {
@@ -18,7 +19,7 @@ const BottomNavigation = ({
18
19
  floating,
19
20
  maxWidth,
20
21
  className
21
- }: BottomNavigationProps) => {
22
+ }: Props) => {
22
23
  const classes = classNames([
23
24
  styles.nav,
24
25
  separated && styles.separated,
@@ -6,7 +6,7 @@ import Icon from '../Icon/Icon.astro'
6
6
 
7
7
  import styles from './breadcrumb.module.scss'
8
8
 
9
- interface Props extends BreadcrumbProps {}
9
+ export type Props = BreadcrumbProps
10
10
 
11
11
  const {
12
12
  items,
@@ -9,11 +9,13 @@
9
9
 
10
10
  import styles from './breadcrumb.module.scss'
11
11
 
12
+ export type Props = BreadcrumbProps
13
+
12
14
  const {
13
15
  items,
14
16
  separator,
15
17
  className
16
- }: BreadcrumbProps = $props()
18
+ }: Props = $props()
17
19
 
18
20
  const classes = $derived(classNames([
19
21
  styles.breadcrumb,
@@ -9,11 +9,13 @@ import ChevronRight from '../../icons/chevron-right.svg?raw'
9
9
 
10
10
  import styles from './breadcrumb.module.scss'
11
11
 
12
+ export type Props = BreadcrumbProps
13
+
12
14
  const Breadcrumb = ({
13
15
  items,
14
16
  separator,
15
17
  className
16
- }: BreadcrumbProps) => {
18
+ }: Props) => {
17
19
  const classes = classNames([
18
20
  styles.breadcrumb,
19
21
  className
@@ -1,9 +1,10 @@
1
1
  ---
2
+ import type { HTMLAttributes } from 'astro/types'
2
3
  import type { ButtonProps } from './button'
3
4
 
4
5
  import styles from './button.module.scss'
5
6
 
6
- interface Props extends ButtonProps {}
7
+ export type Props = ButtonProps<HTMLAttributes<'button'>>
7
8
 
8
9
  const {
9
10
  theme,
@@ -1,10 +1,17 @@
1
1
  <script lang="ts">
2
- import type { SvelteButtonProps } from './button'
2
+ import type { Snippet } from 'svelte'
3
+ import type { HTMLAttributes, MouseEventHandler } from 'svelte/elements'
4
+ import type { ButtonProps } from './button'
3
5
 
4
6
  import { classNames } from '../../utils/classNames'
5
7
 
6
8
  import styles from './button.module.scss'
7
9
 
10
+ export type Props = ButtonProps<HTMLAttributes<HTMLElement>> & {
11
+ onClick?: MouseEventHandler<HTMLButtonElement>
12
+ children: Snippet
13
+ }
14
+
8
15
  const {
9
16
  theme,
10
17
  href,
@@ -12,7 +19,7 @@
12
19
  onClick,
13
20
  children,
14
21
  ...rest
15
- }: SvelteButtonProps = $props()
22
+ }: Props = $props()
16
23
 
17
24
  const classes = $derived(classNames([
18
25
  styles.button,
@@ -1,10 +1,15 @@
1
1
  import React from 'react'
2
- import type { ReactButtonProps } from './button'
2
+ import type { ButtonProps } from './button'
3
3
 
4
4
  import { classNames } from '../../utils/classNames'
5
5
 
6
6
  import styles from './button.module.scss'
7
7
 
8
+ export type Props = ButtonProps<Record<string, unknown>> & {
9
+ onClick?: React.MouseEventHandler<HTMLButtonElement>
10
+ children?: React.ReactNode
11
+ }
12
+
8
13
  const Button = ({
9
14
  theme,
10
15
  href,
@@ -12,7 +17,7 @@ const Button = ({
12
17
  onClick,
13
18
  children,
14
19
  ...rest
15
- }: ReactButtonProps) => {
20
+ }: Props) => {
16
21
  const classes = classNames([
17
22
  styles.button,
18
23
  theme && styles[theme],
@@ -1,7 +1,4 @@
1
- import type { Snippet } from 'svelte'
2
- import type { MouseEventHandler } from 'svelte/elements'
3
-
4
- export type ButtonProps = {
1
+ export type ButtonBase = {
5
2
  theme?: 'secondary'
6
3
  | 'outline'
7
4
  | 'flat'
@@ -9,23 +6,29 @@ export type ButtonProps = {
9
6
  | 'success'
10
7
  | 'warning'
11
8
  | 'alert'
12
- target?: '_self'
13
- | '_blank'
14
- | '_parent'
15
- | '_top'
16
- | '_unfencedTop'
17
- | ''
18
- href?: string
19
9
  className?: string
20
- [key: string]: any
21
10
  }
22
11
 
23
- export type SvelteButtonProps = {
24
- onClick?: MouseEventHandler<HTMLButtonElement>
25
- children: Snippet
26
- } & ButtonProps
12
+ type AsButton<T extends object = object> = ButtonBase & {
13
+ href?: never
14
+ target?: never
15
+ rel?: never
16
+ download?: never
17
+ hreflang?: never
18
+ ping?: never
19
+ referrerpolicy?: never
20
+ } & T
21
+
22
+ type AsAnchor<T extends object = object> = ButtonBase & {
23
+ href?: string
24
+ target?: '_self' | '_blank' | '_parent' | '_top' | '_unfencedTop' | ''
25
+ rel?: string
26
+ download?: string | boolean
27
+ hreflang?: string
28
+ ping?: string
29
+ referrerpolicy?: ReferrerPolicy
30
+ } & T
27
31
 
28
- export type ReactButtonProps = {
29
- onClick?: React.MouseEventHandler<HTMLButtonElement>
30
- children?: React.ReactNode
31
- } & ButtonProps
32
+ export type ButtonProps<T extends object = object> =
33
+ | AsButton<T>
34
+ | AsAnchor<T>
@@ -3,7 +3,7 @@ import type { CardProps } from './card'
3
3
 
4
4
  import styles from './card.module.scss'
5
5
 
6
- interface Props extends CardProps {}
6
+ export type Props = CardProps
7
7
 
8
8
  const {
9
9
  element = 'section',
@@ -13,12 +13,14 @@ const {
13
13
  className,
14
14
  bodyClassName,
15
15
  secondary,
16
+ flat,
16
17
  ...rest
17
18
  } = Astro.props
18
19
 
19
20
  const classes = [
20
21
  styles.card,
21
22
  secondary && styles.secondary,
23
+ (flat && (compact || secondary)) && styles.flat,
22
24
  className
23
25
  ]
24
26
 
@@ -28,13 +30,18 @@ const bodyClasses = [
28
30
  bodyClassName
29
31
  ]
30
32
 
33
+ const titleClasses = [
34
+ styles.title,
35
+ flat && styles.flat
36
+ ]
37
+
31
38
  const Component = element
32
39
  const Title = titleTag
33
40
  ---
34
41
 
35
42
  <Component class:list={classes} {...rest}>
36
43
  {title && (
37
- <Title class:list={styles.title}>{title}</Title>
44
+ <Title class:list={titleClasses} set:html={title} />
38
45
  )}
39
46
  <div class:list={bodyClasses}>
40
47
  <slot />
@@ -1,10 +1,15 @@
1
1
  <script lang="ts">
2
- import type { SvelteCardProps } from './card'
2
+ import type { Snippet } from 'svelte'
3
+ import type { CardProps } from './card'
3
4
 
4
5
  import { classNames } from '../../utils/classNames'
5
6
 
6
7
  import styles from './card.module.scss'
7
8
 
9
+ export type Props = CardProps & {
10
+ children: Snippet
11
+ }
12
+
8
13
  const {
9
14
  element = 'section',
10
15
  title,
@@ -13,13 +18,15 @@
13
18
  className,
14
19
  bodyClassName,
15
20
  secondary,
21
+ flat,
16
22
  children,
17
23
  ...rest
18
- }: SvelteCardProps = $props()
24
+ }: Props = $props()
19
25
 
20
26
  const classes = $derived(classNames([
21
27
  styles.card,
22
28
  secondary && styles.secondary,
29
+ (flat && (compact || secondary)) && styles.flat,
23
30
  className
24
31
  ]))
25
32
 
@@ -28,12 +35,18 @@
28
35
  compact && styles.compact,
29
36
  bodyClassName
30
37
  ]))
38
+
39
+ const titleClasses = $derived(classNames([
40
+ styles.title,
41
+ flat && styles.flat,
42
+ (flat && compact) && styles.compact
43
+ ]))
31
44
  </script>
32
45
 
33
46
  <svelte:element this={element} class={classes} {...rest}>
34
47
  {#if title}
35
- <svelte:element this={titleTag} class={styles.title}>
36
- {title}
48
+ <svelte:element this={titleTag} class={titleClasses}>
49
+ {@html title}
37
50
  </svelte:element>
38
51
  {/if}
39
52
  <div class={bodyClasses}>
@@ -1,10 +1,16 @@
1
- import React from 'react'
2
- import type { ReactCardProps } from './card'
1
+ import React, { type JSX } from 'react'
2
+ import type { CardProps } from './card'
3
3
 
4
4
  import { classNames } from '../../utils/classNames'
5
5
 
6
6
  import styles from './card.module.scss'
7
7
 
8
+ export type Props = Omit<CardProps<any>, 'titleTag' | 'element'> & {
9
+ Element?: keyof JSX.IntrinsicElements
10
+ TitleTag?: keyof JSX.IntrinsicElements
11
+ children: React.ReactNode
12
+ }
13
+
8
14
  const Card = ({
9
15
  Element = 'section',
10
16
  title,
@@ -13,13 +19,15 @@ const Card = ({
13
19
  className,
14
20
  bodyClassName,
15
21
  secondary,
22
+ flat,
16
23
  children,
17
24
  ...rest
18
- }: ReactCardProps) => {
25
+ }: Props) => {
19
26
  const classes = classNames([
20
27
  styles.card,
21
- className,
22
- secondary && styles.secondary
28
+ secondary && styles.secondary,
29
+ (flat && (compact || secondary)) && styles.flat,
30
+ className
23
31
  ])
24
32
 
25
33
  const bodyClasses = classNames([
@@ -28,10 +36,19 @@ const Card = ({
28
36
  bodyClassName
29
37
  ])
30
38
 
39
+ const titleClasses = classNames([
40
+ styles.title,
41
+ flat && styles.flat,
42
+ (flat && compact) && styles.compact
43
+ ])
44
+
31
45
  return (
32
46
  <Element className={classes} {...rest}>
33
47
  {title && (
34
- <TitleTag className={styles.title}>{title}</TitleTag>
48
+ <TitleTag
49
+ className={titleClasses}
50
+ dangerouslySetInnerHTML={{ __html: title }}
51
+ />
35
52
  )}
36
53
  <div className={bodyClasses}>
37
54
  {children}
@@ -1,20 +1,27 @@
1
1
  @use '../../scss/config.scss' as *;
2
2
 
3
3
  .card {
4
- @include border(primary-50);
5
4
  @include border-radius(md);
6
5
  @include layout(flex, column);
7
6
  @include background(primary-70);
8
7
  @include visibility(hidden);
8
+
9
+ &:not(.flat) {
10
+ @include border(primary-50);
11
+ }
9
12
 
10
- &.secondary .body {
13
+ &.secondary .body,
14
+ &.flat .title {
11
15
  @include background(primary-60);
12
16
  }
13
17
 
14
18
  .title {
15
- @include spacing(p-default);
16
- @include border(primary-50, bottom);
17
19
  @include visibility(block);
20
+ @include spacing(p-default);
21
+
22
+ &:not(.flat) {
23
+ @include border(primary-50, bottom);
24
+ }
18
25
  }
19
26
 
20
27
  .body {
@@ -1,7 +1,4 @@
1
- import type { JSX } from 'react'
2
- import type { Snippet } from 'svelte'
3
-
4
- export type CardProps = {
1
+ export type CardProps<T extends object = Record<string, unknown>> = {
5
2
  element?: string
6
3
  title?: string
7
4
  titleTag?: string
@@ -9,15 +6,5 @@ export type CardProps = {
9
6
  className?: string
10
7
  bodyClassName?: string
11
8
  secondary?: boolean
12
- [key: string]: any
13
- }
14
-
15
- export type SvelteCardProps = {
16
- children: Snippet
17
- } & CardProps
18
-
19
- export type ReactCardProps = {
20
- Element?: keyof JSX.IntrinsicElements
21
- TitleTag?: keyof JSX.IntrinsicElements
22
- children: React.ReactNode
23
- } & Omit<CardProps, 'titleTag' | 'element'>
9
+ flat?: boolean
10
+ } & T
@@ -9,7 +9,7 @@ import { classNames } from '../../utils/classNames'
9
9
 
10
10
  import styles from './carousel.module.scss'
11
11
 
12
- interface Props extends CarouselProps {}
12
+ export type Props = CarouselProps
13
13
 
14
14
  const {
15
15
  items,
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
- import { onMount } from 'svelte'
3
- import type { SvelteCarouselProps } from './carousel'
2
+ import { onMount, type Snippet } from 'svelte'
3
+ import type { CarouselProps } from './carousel'
4
4
 
5
5
  import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
6
6
  import Pagination from '../Pagination/Pagination.svelte'
@@ -14,6 +14,11 @@
14
14
 
15
15
  import type { PaginationEventType } from '../Pagination/pagination'
16
16
 
17
+ export type Props = CarouselProps & {
18
+ onScroll?: (event: number) => void
19
+ children: Snippet
20
+ }
21
+
17
22
  let {
18
23
  items = 0,
19
24
  itemsPerSlide = 1,
@@ -28,7 +33,7 @@
28
33
  paginationClassName,
29
34
  children,
30
35
  onScroll
31
- }: SvelteCarouselProps = $props()
36
+ }: Props = $props()
32
37
 
33
38
  const getItemsPerSlide = () => {
34
39
  if (carousel) {
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useRef, useState } from 'react'
2
- import type { ReactCarouselProps } from './carousel'
2
+ import type { CarouselProps } from './carousel'
3
3
 
4
4
  import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
5
5
  import Pagination from '../Pagination/Pagination.tsx'
@@ -13,6 +13,11 @@ import styles from './carousel.module.scss'
13
13
 
14
14
  import type { PaginationEventType } from '../Pagination/pagination'
15
15
 
16
+ export type Props = CarouselProps & {
17
+ onScroll?: (event: number) => void
18
+ children?: React.ReactNode
19
+ }
20
+
16
21
  const Carousel = ({
17
22
  items,
18
23
  itemsPerSlide = 1,
@@ -27,7 +32,7 @@ const Carousel = ({
27
32
  paginationClassName,
28
33
  onScroll,
29
34
  children
30
- }: ReactCarouselProps) => {
35
+ }: Props) => {
31
36
  const getItemsPerSlide = () => {
32
37
  if (carousel.current) {
33
38
  return typeof itemsPerSlide === 'number'
@@ -1,5 +1,3 @@
1
- import type { Snippet } from 'svelte'
2
-
3
1
  import type { Responsive } from '../../utils/getLayoutClasses'
4
2
 
5
3
  import type { PaginationProps } from '../Pagination/pagination'
@@ -19,13 +17,3 @@ export type CarouselProps = {
19
17
  wrapperClassName?: string
20
18
  paginationClassName?: string
21
19
  }
22
-
23
- export type SvelteCarouselProps = {
24
- onScroll?: (event: number) => void
25
- children: Snippet
26
- } & CarouselProps
27
-
28
- export type ReactCarouselProps = {
29
- onScroll?: (event: number) => void
30
- children?: React.ReactNode
31
- } & CarouselProps
@@ -0,0 +1,14 @@
1
+ ---
2
+ import type { CarouselItemProps } from './carouselItem'
3
+
4
+ export type Props = CarouselItemProps
5
+
6
+ const {
7
+ active,
8
+ className
9
+ } = Astro.props
10
+ ---
11
+
12
+ <li class={className} data-active={active}>
13
+ <slot />
14
+ </li>
@@ -0,0 +1,18 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+ import type { CarouselItemProps } from './carouselItem'
4
+
5
+ export type Props = CarouselItemProps & {
6
+ children: Snippet
7
+ }
8
+
9
+ const {
10
+ active,
11
+ className,
12
+ children
13
+ }: Props = $props()
14
+ </script>
15
+
16
+ <li class={className} data-active={active}>
17
+ {@render children?.()}
18
+ </li>