webcoreui 0.9.0 → 0.10.0

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 (138) hide show
  1. package/README.md +20 -6
  2. package/components/Accordion/Accordion.astro +15 -10
  3. package/components/Accordion/Accordion.svelte +14 -12
  4. package/components/Accordion/Accordion.tsx +2 -2
  5. package/components/Alert/Alert.svelte +17 -12
  6. package/components/Alert/Alert.tsx +1 -1
  7. package/components/Alert/alert.ts +10 -3
  8. package/components/AspectRatio/AspectRatio.svelte +7 -4
  9. package/components/AspectRatio/aspectratio.ts +6 -0
  10. package/components/Avatar/Avatar.svelte +11 -9
  11. package/components/Badge/Badge.svelte +14 -10
  12. package/components/Badge/badge.ts +2 -1
  13. package/components/Banner/Banner.astro +10 -4
  14. package/components/Banner/Banner.svelte +14 -10
  15. package/components/Banner/Banner.tsx +1 -0
  16. package/components/Banner/banner.ts +6 -0
  17. package/components/BottomNavigation/BottomNavigation.svelte +7 -5
  18. package/components/Breadcrumb/Breadcrumb.astro +1 -1
  19. package/components/Breadcrumb/Breadcrumb.svelte +8 -6
  20. package/components/Breadcrumb/Breadcrumb.tsx +2 -2
  21. package/components/Button/Button.svelte +12 -8
  22. package/components/Button/Button.tsx +2 -2
  23. package/components/Button/button.ts +2 -3
  24. package/components/Card/Card.svelte +14 -10
  25. package/components/Card/card.ts +6 -0
  26. package/components/Carousel/Carousel.astro +46 -41
  27. package/components/Carousel/carousel.ts +3 -0
  28. package/components/Checkbox/Checkbox.svelte +12 -9
  29. package/components/Checkbox/checkbox.module.scss +4 -0
  30. package/components/Collapsible/Collapsible.astro +8 -5
  31. package/components/Collapsible/Collapsible.svelte +54 -49
  32. package/components/Collapsible/collapsible.ts +8 -0
  33. package/components/ConditionalWrapper/ConditionalWrapper.svelte +10 -6
  34. package/components/ConditionalWrapper/conditionalwrapper.ts +6 -0
  35. package/components/Copy/Copy.astro +17 -11
  36. package/components/Copy/Copy.svelte +68 -61
  37. package/components/Copy/Copy.tsx +1 -0
  38. package/components/Copy/copy.ts +8 -2
  39. package/components/DataTable/DataTable.astro +103 -93
  40. package/components/DataTable/DataTable.svelte +276 -272
  41. package/components/DataTable/datatable.ts +5 -2
  42. package/components/Flex/Flex.svelte +14 -10
  43. package/components/Flex/flex.ts +6 -0
  44. package/components/Footer/Footer.svelte +12 -9
  45. package/components/Footer/footer.ts +6 -0
  46. package/components/Grid/Grid.svelte +12 -8
  47. package/components/Grid/grid.ts +6 -0
  48. package/components/Group/Group.svelte +7 -4
  49. package/components/Group/group.ts +6 -0
  50. package/components/Icon/Icon.astro +19 -5
  51. package/components/Icon/Icon.svelte +23 -7
  52. package/components/Icon/Icon.tsx +19 -5
  53. package/components/Icon/icon.ts +9 -3
  54. package/components/Icon/map.ts +8 -10
  55. package/components/Input/Input.svelte +24 -20
  56. package/components/Input/input.ts +10 -3
  57. package/components/Kbd/Kbd.svelte +7 -4
  58. package/components/Kbd/kbd.ts +6 -0
  59. package/components/List/List.astro +65 -60
  60. package/components/List/List.svelte +149 -147
  61. package/components/List/List.tsx +1 -1
  62. package/components/Masonry/Masonry.svelte +12 -10
  63. package/components/Menu/Menu.astro +8 -3
  64. package/components/Menu/Menu.svelte +15 -10
  65. package/components/Menu/Menu.tsx +3 -1
  66. package/components/Menu/menu.ts +6 -0
  67. package/components/Modal/Modal.astro +1 -0
  68. package/components/Modal/Modal.svelte +18 -13
  69. package/components/Modal/Modal.tsx +2 -1
  70. package/components/Modal/modal.ts +6 -1
  71. package/components/Pagination/Pagination.astro +75 -69
  72. package/components/Pagination/Pagination.svelte +29 -26
  73. package/components/Pagination/Pagination.tsx +5 -4
  74. package/components/Pagination/pagination.module.scss +4 -0
  75. package/components/Popover/Popover.svelte +10 -6
  76. package/components/Popover/popover.ts +6 -0
  77. package/components/Progress/Progress.svelte +12 -10
  78. package/components/Progress/progress.ts +1 -1
  79. package/components/Radio/Radio.svelte +12 -9
  80. package/components/Radio/radio.ts +4 -2
  81. package/components/Rating/Rating.svelte +16 -14
  82. package/components/Ribbon/Ribbon.svelte +9 -6
  83. package/components/Ribbon/ribbon.ts +6 -0
  84. package/components/Select/Select.astro +73 -63
  85. package/components/Select/Select.svelte +27 -22
  86. package/components/Select/Select.tsx +8 -6
  87. package/components/Sheet/Sheet.svelte +9 -5
  88. package/components/Sheet/sheet.ts +6 -2
  89. package/components/Sidebar/Sidebar.svelte +7 -4
  90. package/components/Sidebar/sidebar.ts +6 -0
  91. package/components/Skeleton/Skeleton.svelte +9 -7
  92. package/components/Slider/Slider.svelte +15 -13
  93. package/components/Slider/slider.module.scss +4 -0
  94. package/components/Slider/slider.ts +4 -2
  95. package/components/Spinner/Spinner.svelte +7 -5
  96. package/components/Spoiler/Spoiler.astro +13 -8
  97. package/components/Spoiler/Spoiler.svelte +13 -10
  98. package/components/Spoiler/spoiler.ts +6 -0
  99. package/components/Stepper/Stepper.svelte +9 -7
  100. package/components/Switch/Switch.svelte +15 -12
  101. package/components/Table/Table.svelte +11 -9
  102. package/components/Table/table.ts +1 -1
  103. package/components/Tabs/Tabs.astro +8 -5
  104. package/components/Tabs/Tabs.svelte +14 -11
  105. package/components/Tabs/tabs.ts +7 -1
  106. package/components/Textarea/Textarea.svelte +14 -11
  107. package/components/Textarea/textarea.ts +9 -4
  108. package/components/ThemeSwitcher/ThemeSwitcher.astro +43 -37
  109. package/components/ThemeSwitcher/ThemeSwitcher.svelte +14 -10
  110. package/components/ThemeSwitcher/themeswitcher.ts +7 -0
  111. package/components/Timeline/Timeline.svelte +12 -9
  112. package/components/Timeline/timeline.ts +7 -2
  113. package/components/TimelineItem/TimelineItem.svelte +8 -5
  114. package/components/TimelineItem/timelineitem.ts +6 -0
  115. package/components/Toast/Toast.svelte +18 -10
  116. package/components/Toast/toast.ts +6 -1
  117. package/icons/alert.svg +2 -2
  118. package/icons/check.svg +2 -2
  119. package/icons/chevron-down.svg +3 -0
  120. package/icons/chevron-left.svg +3 -0
  121. package/icons/chevron-right.svg +3 -0
  122. package/icons/chevron-up.svg +3 -0
  123. package/icons/circle-check.svg +3 -3
  124. package/icons/info.svg +3 -3
  125. package/icons.d.ts +4 -5
  126. package/icons.js +4 -5
  127. package/index.d.ts +1 -0
  128. package/index.js +1 -0
  129. package/package.json +20 -20
  130. package/react.d.ts +3 -3
  131. package/svelte.d.ts +98 -98
  132. package/utils/bodyFreeze.ts +13 -0
  133. package/utils/modal.ts +12 -0
  134. package/icons/arrow-down.svg +0 -3
  135. package/icons/arrow-left.svg +0 -3
  136. package/icons/arrow-right.svg +0 -3
  137. package/icons/components.svg +0 -3
  138. package/icons/file.svg +0 -3
@@ -5,16 +5,19 @@
5
5
 
6
6
  import styles from './switch.module.scss'
7
7
 
8
- export let label: SvelteSwitchProps['label'] = ''
9
- export let toggled: SvelteSwitchProps['toggled'] = false
10
- export let offColor: SvelteSwitchProps['offColor'] = ''
11
- export let onColor: SvelteSwitchProps['onColor'] = ''
12
- export let reverse: SvelteSwitchProps['reverse'] = false
13
- export let small: SvelteSwitchProps['small'] = false
14
- export let square: SvelteSwitchProps['square'] = false
15
- export let disabled: SvelteSwitchProps['disabled'] = false
16
- export let className: SvelteSwitchProps['className'] = ''
17
- export let onClick: SvelteSwitchProps['onClick'] = () => {}
8
+ const {
9
+ label,
10
+ toggled,
11
+ offColor,
12
+ onColor,
13
+ reverse,
14
+ small,
15
+ square,
16
+ disabled,
17
+ className,
18
+ onClick,
19
+ ...rest
20
+ }: SvelteSwitchProps = $props()
18
21
 
19
22
  const classes = classNames([
20
23
  styles.switch,
@@ -36,8 +39,8 @@
36
39
  type="checkbox"
37
40
  checked={toggled}
38
41
  disabled={disabled}
39
- on:click={onClick}
40
- {...$$restProps}
42
+ onclick={onClick}
43
+ {...rest}
41
44
  />
42
45
  <span class={styles.toggle}></span>
43
46
  {#if label}
@@ -5,15 +5,17 @@
5
5
 
6
6
  import styles from './table.module.scss'
7
7
 
8
- export let headings: TableProps['headings'] = []
9
- export let footer: TableProps['footer'] = []
10
- export let data: TableProps['data'] = []
11
- export let hover: TableProps['hover'] = false
12
- export let striped: TableProps['striped'] = null
13
- export let offsetStripe: TableProps['offsetStripe'] = false
14
- export let compact: TableProps['compact'] = false
15
- export let maxHeight: TableProps['maxHeight'] = ''
16
- export let className: TableProps['className'] = ''
8
+ const {
9
+ headings,
10
+ footer,
11
+ data,
12
+ hover,
13
+ striped,
14
+ offsetStripe,
15
+ compact,
16
+ maxHeight,
17
+ className
18
+ }: TableProps = $props()
17
19
 
18
20
  const classes = classNames([
19
21
  styles.table,
@@ -3,7 +3,7 @@ export type TableProps = {
3
3
  footer?: string[]
4
4
  data: string[][]
5
5
  hover?: boolean
6
- striped?: 'column' | 'row' | null
6
+ striped?: 'column' | 'row'
7
7
  offsetStripe?: boolean
8
8
  compact?: boolean
9
9
  maxHeight?: string
@@ -42,10 +42,10 @@ const classes = [
42
42
  </section>
43
43
 
44
44
  <script>
45
- const tabs = document.querySelectorAll('[data-id="w-tabs"]')
45
+ import { on } from '../../utils/DOMUtils'
46
46
 
47
- Array.from(tabs).forEach(element => {
48
- element.addEventListener('click', event => {
47
+ const addEventListeners = () => {
48
+ on('[data-id="w-tabs"]', 'click', (event: Event) => {
49
49
  const target = event.target as HTMLDivElement
50
50
 
51
51
  if (target.dataset.value) {
@@ -72,6 +72,9 @@ const classes = [
72
72
  }
73
73
  })
74
74
  }
75
- })
76
- })
75
+ }, true)
76
+ }
77
+
78
+ on(document, 'astro:after-swap', addEventListeners)
79
+ addEventListeners()
77
80
  </script>
@@ -1,18 +1,21 @@
1
1
  <script lang="ts">
2
- import type { TabsProps } from './tabs'
2
+ import type { SvelteTabsProps } from './tabs'
3
3
 
4
4
  import { classNames } from '../../utils/classNames'
5
5
 
6
6
  import styles from './tabs.module.scss'
7
7
 
8
- export let items: TabsProps['items'] = []
9
- export let theme: TabsProps['theme'] = null
10
- export let vertical: TabsProps['vertical'] = false
11
- export let even: TabsProps['even'] = false
12
- export let className: TabsProps['className'] = ''
8
+ const {
9
+ items,
10
+ theme,
11
+ vertical,
12
+ even,
13
+ className,
14
+ children
15
+ }: SvelteTabsProps = $props()
13
16
 
14
- let active = ''
15
- let tabContainer: HTMLDivElement
17
+ let active = $state('')
18
+ let tabContainer: HTMLDivElement | undefined = $state()
16
19
 
17
20
  const classes = classNames([
18
21
  styles.tabs,
@@ -23,7 +26,7 @@
23
26
  ])
24
27
 
25
28
  const setTab = (tab: string) => {
26
- const tabs = tabContainer.querySelectorAll('[data-tab]')
29
+ const tabs = tabContainer!.querySelectorAll('[data-tab]')
27
30
 
28
31
  active = tab
29
32
 
@@ -44,7 +47,7 @@
44
47
  <button
45
48
  data-active={active ? active === item.value : item.active}
46
49
  disabled={item.disabled}
47
- on:click={() => setTab(item.value)}
50
+ onclick={() => setTab(item.value)}
48
51
  >
49
52
  {@html item.label}
50
53
  </button>
@@ -52,6 +55,6 @@
52
55
  </div>
53
56
  </div>
54
57
  <div class={styles.content} bind:this={tabContainer}>
55
- <slot />
58
+ {@render children?.()}
56
59
  </div>
57
60
  </section>
@@ -1,3 +1,5 @@
1
+ import type { Snippet } from 'svelte'
2
+
1
3
  export type TabsProps = {
2
4
  items: {
3
5
  label: string
@@ -5,12 +7,16 @@ export type TabsProps = {
5
7
  active?: boolean
6
8
  disabled?: boolean
7
9
  }[]
8
- theme?: 'boxed' | 'outline' | null
10
+ theme?: 'boxed' | 'outline'
9
11
  vertical?: boolean
10
12
  even?: boolean
11
13
  className?: string
12
14
  }
13
15
 
16
+ export type SvelteTabsProps = {
17
+ children: Snippet
18
+ } & TabsProps
19
+
14
20
  export type ReactTabsProps = {
15
21
  children: React.ReactNode
16
22
  } & TabsProps
@@ -7,14 +7,17 @@
7
7
 
8
8
  import styles from './textarea.module.scss'
9
9
 
10
- export let label: SvelteTextareaProps['label'] = ''
11
- export let placeholder: SvelteTextareaProps['placeholder'] = ''
12
- export let subText: SvelteTextareaProps['subText'] = ''
13
- export let value: SvelteTextareaProps['value'] = ''
14
- export let disabled: SvelteTextareaProps['disabled'] = false
15
- export let className: SvelteTextareaProps['className'] = ''
16
- export let onChange: SvelteTextareaProps['onChange'] = () => {}
17
- export let onKeyUp: SvelteTextareaProps['onKeyUp'] = () => {}
10
+ const {
11
+ label,
12
+ placeholder,
13
+ subText,
14
+ value = '',
15
+ disabled,
16
+ className,
17
+ onChange,
18
+ onKeyUp,
19
+ ...rest
20
+ }: SvelteTextareaProps = $props()
18
21
 
19
22
  const classes = classNames([
20
23
  styles.textarea,
@@ -36,9 +39,9 @@
36
39
  placeholder={placeholder}
37
40
  disabled={disabled}
38
41
  class={classes}
39
- on:change={onChange}
40
- on:keyup={onKeyUp}
41
- {...$$restProps}
42
+ onchange={onChange}
43
+ onkeyup={onKeyUp}
44
+ {...rest}
42
45
  >{value}</textarea>
43
46
  {#if subText}
44
47
  <div class={styles.subtext}>
@@ -1,3 +1,8 @@
1
+ type Target = {
2
+ target: HTMLTextAreaElement
3
+ currentTarget: HTMLTextAreaElement
4
+ }
5
+
1
6
  export type TextareaProps = {
2
7
  label?: string
3
8
  placeholder?: string
@@ -9,11 +14,11 @@ export type TextareaProps = {
9
14
  }
10
15
 
11
16
  export type SvelteTextareaProps = {
12
- onChange?: (e: any) => any
13
- onKeyUp?: (e: any) => any
17
+ onChange?: (event: Event & Target) => void
18
+ onKeyUp?: (event: KeyboardEvent & Target) => void
14
19
  } & TextareaProps
15
20
 
16
21
  export type ReactTextareaProps = {
17
- onChange?: (e: any) => any
18
- onKeyUp?: (e: any) => any
22
+ onChange?: (event: React.ChangeEvent<HTMLTextAreaElement> & Target) => void
23
+ onKeyUp?: (event: React.KeyboardEvent<HTMLTextAreaElement> & Target) => void
19
24
  } & TextareaProps
@@ -50,59 +50,65 @@ const buttonClasses = [
50
50
 
51
51
  <script>
52
52
  import { getCookie, setCookie } from '../../utils/cookies'
53
+ import { on } from '../../utils/DOMUtils'
53
54
  import { dispatch, listen } from '../../utils/event'
54
55
 
55
- const switchers = document.querySelectorAll('[data-id="w-theme-switcher"]')
56
+ const addEventListeners = () => {
57
+ const switchers = document.querySelectorAll('[data-id="w-theme-switcher"]')
56
58
 
57
- let currentTheme = localStorage.getItem('w-theme')
58
- || getCookie('w-theme')
59
- || (switchers[0] as HTMLDivElement).dataset.primaryTheme
60
- || ''
59
+ let currentTheme = localStorage.getItem('w-theme')
60
+ || getCookie('w-theme')
61
+ || (switchers[0] as HTMLDivElement).dataset.primaryTheme
62
+ || ''
61
63
 
62
- const setActiveButton = (buttons: HTMLButtonElement[]) => {
63
- buttons.forEach(button => button.dataset.active = 'false')
64
+ const setActiveButton = (buttons: HTMLButtonElement[]) => {
65
+ buttons.forEach(button => button.dataset.active = 'false')
64
66
 
65
- buttons.forEach(button => {
66
- if (button.dataset.theme === currentTheme) {
67
- button.dataset.active = 'true'
68
- }
69
- })
70
- }
67
+ buttons.forEach(button => {
68
+ if (button.dataset.theme === currentTheme) {
69
+ button.dataset.active = 'true'
70
+ }
71
+ })
72
+ }
71
73
 
72
- Array.from(switchers).forEach(switcher => {
73
- const buttons = Array.from(switcher.querySelectorAll('button'))
74
+ Array.from(switchers).forEach(switcher => {
75
+ const buttons = Array.from(switcher.querySelectorAll('button'))
74
76
 
75
- setActiveButton(buttons)
77
+ setActiveButton(buttons)
76
78
 
77
- listen('theme-switched', theme => {
78
- currentTheme = theme
79
+ listen('theme-switched', theme => {
80
+ currentTheme = theme
79
81
 
80
- setActiveButton(buttons)
81
- })
82
+ setActiveButton(buttons)
83
+ })
82
84
 
83
- switcher.addEventListener('click', event => {
84
- const target = event.target as HTMLButtonElement
85
+ switcher.addEventListener('click', event => {
86
+ const target = event.target as HTMLButtonElement
85
87
 
86
- if (target.nodeName === 'BUTTON') {
87
- const toggleTheme = (switcher as HTMLDivElement).dataset.secondaryTheme
88
+ if (target.nodeName === 'BUTTON') {
89
+ const toggleTheme = (switcher as HTMLDivElement).dataset.secondaryTheme
88
90
 
89
- const theme = toggleTheme
90
- ? toggleTheme === target.dataset.theme
91
- ? (target.previousElementSibling as HTMLButtonElement).dataset.theme as string
92
- : (target.nextElementSibling as HTMLButtonElement).dataset.theme as string
93
- : target.dataset.theme as string
91
+ const theme = toggleTheme
92
+ ? toggleTheme === target.dataset.theme
93
+ ? (target.previousElementSibling as HTMLButtonElement).dataset.theme as string
94
+ : (target.nextElementSibling as HTMLButtonElement).dataset.theme as string
95
+ : target.dataset.theme as string
94
96
 
95
- document.body.classList.replace(currentTheme, theme)
97
+ document.body.classList.replace(currentTheme, theme)
96
98
 
97
- currentTheme = theme
99
+ currentTheme = theme
98
100
 
99
- setActiveButton(buttons)
100
- setCookie('w-theme', currentTheme, 30)
101
- localStorage.setItem('w-theme', currentTheme)
101
+ setActiveButton(buttons)
102
+ setCookie('w-theme', currentTheme, 30)
103
+ localStorage.setItem('w-theme', currentTheme)
102
104
 
103
- dispatch('theme-switched', currentTheme)
104
- }
105
+ dispatch('theme-switched', currentTheme)
106
+ }
107
+ })
105
108
  })
106
- })
109
+ }
110
+
111
+ on(document, 'astro:after-swap', addEventListeners)
112
+ addEventListeners()
107
113
  </script>
108
114
 
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { onMount } from 'svelte'
3
- import type { ThemeSwitcherProps } from './themeswitcher'
3
+ import type { SvelteThemeSwitcherProps } from './themeswitcher'
4
4
 
5
5
  import { classNames } from '../../utils/classNames'
6
6
  import { getCookie, setCookie } from '../../utils/cookies'
@@ -8,12 +8,16 @@
8
8
 
9
9
  import styles from './themeswitcher.module.scss'
10
10
 
11
- export let themes: ThemeSwitcherProps['themes'] = {}
12
- export let toggle: ThemeSwitcherProps['toggle'] = false
13
- export let size: ThemeSwitcherProps['size'] = 20
14
- export let className: ThemeSwitcherProps['className'] = ''
11
+ const {
12
+ themes,
13
+ toggle,
14
+ size,
15
+ primaryIcon,
16
+ secondaryIcon,
17
+ className
18
+ }: SvelteThemeSwitcherProps = $props()
15
19
 
16
- let currentTheme = ''
20
+ let currentTheme = $state('')
17
21
  let toggled = false
18
22
 
19
23
  const classes = classNames([
@@ -24,7 +28,7 @@
24
28
 
25
29
  const primaryTheme = themes[Object.keys(themes)[0]]
26
30
  const secondaryTheme = themes[Object.keys(themes)[1]]
27
- const useIcons = $$slots.primaryIcon && $$slots.secondaryIcon
31
+ const useIcons = primaryIcon && secondaryIcon
28
32
 
29
33
  const setTheme = (theme: string | number) => {
30
34
  if (typeof theme === 'number') {
@@ -62,7 +66,7 @@
62
66
  >
63
67
  {#each Object.keys(themes) as theme, index}
64
68
  <button
65
- on:click={() => setTheme(toggle ? index : themes[theme])}
69
+ onclick={() => setTheme(toggle ? index : themes[theme])}
66
70
  style={!useIcons ? `background:${theme};` : undefined}
67
71
  data-active={currentTheme === themes[theme]}
68
72
  aria-label={themes[theme]}
@@ -71,8 +75,8 @@
71
75
  useIcons && styles.icons
72
76
  ])}
73
77
  >
74
- {#if index === 0}<slot name="primaryIcon" />{/if}
75
- {#if index !== 0}<slot name="secondaryIcon" />{/if}
78
+ {#if index === 0}{@render primaryIcon?.()}{/if}
79
+ {#if index !== 0}{@render secondaryIcon?.()}{/if}
76
80
  </button>
77
81
  {/each}
78
82
  </div>
@@ -1,3 +1,5 @@
1
+ import type { Snippet } from 'svelte'
2
+
1
3
  export type ThemeSwitcherProps = {
2
4
  themes: {
3
5
  [key: string]: string
@@ -7,6 +9,11 @@ export type ThemeSwitcherProps = {
7
9
  className?: string
8
10
  }
9
11
 
12
+ export type SvelteThemeSwitcherProps = {
13
+ primaryIcon?: Snippet
14
+ secondaryIcon?: Snippet
15
+ } & ThemeSwitcherProps
16
+
10
17
  export type ReactThemeSwitcherProps = {
11
18
  primaryIcon?: React.ReactNode
12
19
  secondaryIcon?: React.ReactNode
@@ -1,17 +1,20 @@
1
1
  <script lang="ts">
2
- import type { TimelineProps } from './timeline'
2
+ import type { SvelteTimelineProps } from './timeline'
3
3
 
4
4
  import { classNames } from '../../utils/classNames'
5
5
 
6
6
  import styles from './timeline.module.scss'
7
7
 
8
- export let theme: TimelineProps['theme'] = null
9
- export let counter: TimelineProps['counter'] = null
10
- export let alternate: TimelineProps['alternate'] = false
11
- export let centered: TimelineProps['centered'] = false
12
- export let color: TimelineProps['color'] = ''
13
- export let textColor: TimelineProps['textColor'] = ''
14
- export let className: TimelineProps['className'] = ''
8
+ const {
9
+ theme,
10
+ counter,
11
+ alternate,
12
+ centered,
13
+ color,
14
+ textColor,
15
+ className,
16
+ children
17
+ }: SvelteTimelineProps = $props()
15
18
 
16
19
  const classes = classNames([
17
20
  styles.timeline,
@@ -29,5 +32,5 @@
29
32
  </script>
30
33
 
31
34
  <ul class={classes} style={styleVariables || null}>
32
- <slot />
35
+ {@render children?.()}
33
36
  </ul>
@@ -1,5 +1,7 @@
1
+ import type { Snippet } from 'svelte'
2
+
1
3
  export type TimelineProps = {
2
- theme?: 'fill' | 'stroke' | 'stroke fill' | null
4
+ theme?: 'fill' | 'stroke' | 'stroke fill'
3
5
  alternate?: boolean
4
6
  centered?: boolean
5
7
  color?: string
@@ -53,9 +55,12 @@ export type TimelineProps = {
53
55
  | 'upper-alpha'
54
56
  | 'upper-armenian'
55
57
  | 'upper-roman'
56
- | null
57
58
  }
58
59
 
60
+ export type SvelteTimelineProps = {
61
+ children: Snippet
62
+ } & TimelineProps
63
+
59
64
  export type ReactTimelineProps = {
60
65
  children: React.ReactNode
61
66
  } & TimelineProps
@@ -1,13 +1,16 @@
1
1
  <script lang="ts">
2
- import type { TimelineItemProps } from './timelineitem'
2
+ import type { SvelteTimelineItemProps } from './timelineitem'
3
3
 
4
4
  import { classNames } from '../../utils/classNames'
5
5
 
6
6
  import styles from './timelineitem.module.scss'
7
7
 
8
- export let title: TimelineItemProps['title'] = ''
9
- export let titleTag: TimelineItemProps['titleTag'] = 'span'
10
- export let className: TimelineItemProps['className'] = ''
8
+ const {
9
+ title,
10
+ titleTag = 'span',
11
+ className,
12
+ children
13
+ }: SvelteTimelineItemProps = $props()
11
14
 
12
15
  const classes = classNames([
13
16
  styles.item,
@@ -21,5 +24,5 @@
21
24
  {title}
22
25
  </svelte:element>
23
26
  {/if}
24
- <slot />
27
+ {@render children?.()}
25
28
  </li>
@@ -1,9 +1,15 @@
1
+ import type { Snippet } from 'svelte'
2
+
1
3
  export type TimelineItemProps = {
2
4
  title?: string
3
5
  titleTag?: string
4
6
  className?: string
5
7
  }
6
8
 
9
+ export type SvelteTimelineItemProps = {
10
+ children: Snippet
11
+ } & TimelineItemProps
12
+
7
13
  export type ReactTimelineItemProps = {
8
14
  TitleTag?: keyof JSX.IntrinsicElements
9
15
  children: React.ReactNode
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import type { ToastProps } from './toast'
2
+ import type { SvelteToastProps } from './toast'
3
3
 
4
4
  import Alert from '../Alert/Alert.svelte'
5
5
 
@@ -7,8 +7,13 @@
7
7
 
8
8
  import styles from './toast.module.scss'
9
9
 
10
- export let position: ToastProps['position'] = null
11
- export let className: ToastProps['className'] = ''
10
+ const {
11
+ position,
12
+ className,
13
+ icon,
14
+ children,
15
+ ...rest
16
+ }: SvelteToastProps = $props()
12
17
 
13
18
  const classes = classNames([
14
19
  styles.toast,
@@ -24,16 +29,19 @@
24
29
  'data-id': 'body'
25
30
  }
26
31
  }
32
+
33
+ const iconRender = $derived(icon)
27
34
  </script>
28
35
 
29
- {#if $$slots.icon}
30
- <Alert {...$$restProps} className={classes} {...additionalProps}>
31
- <slot slot="icon" name="icon" />
32
- <slot />
36
+ {#if icon}
37
+ <Alert {...rest} className={classes} {...additionalProps}>
38
+ {#snippet icon()}
39
+ {@render iconRender?.()}
40
+ {/snippet}
41
+ {@render children?.()}
33
42
  </Alert>
34
43
  {:else}
35
- <Alert {...$$restProps} className={classes} {...additionalProps}>
36
- <slot />
44
+ <Alert {...rest} className={classes} {...additionalProps}>
45
+ {@render children?.()}
37
46
  </Alert>
38
47
  {/if}
39
-
@@ -1,4 +1,8 @@
1
- import type { AlertProps, ReactAlertProps } from '../Alert/alert'
1
+ import type {
2
+ AlertProps,
3
+ ReactAlertProps,
4
+ SvelteAlertProps
5
+ } from '../Alert/alert'
2
6
 
3
7
  export type ToastProps = {
4
8
  position?: 'bottom-left'
@@ -10,4 +14,5 @@ export type ToastProps = {
10
14
  [key: string]: any
11
15
  } & AlertProps
12
16
 
17
+ export type SvelteToastProps = ToastProps & SvelteAlertProps
13
18
  export type ReactToastProps = ToastProps & ReactAlertProps
package/icons/alert.svg CHANGED
@@ -1,3 +1,3 @@
1
- <svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2
- <path fill-rule="evenodd" clip-rule="evenodd" d="M7.48872 2.15394C7.48856 2.1541 7.48888 2.15378 7.48872 2.15394L2.15302 7.48964C1.99269 7.64997 1.93416 7.74684 1.9045 7.81776C1.87504 7.88818 1.84615 7.99973 1.84615 8.23015V15.7698C1.84615 15.9963 1.8732 16.1054 1.90221 16.1759C1.93113 16.2463 1.9898 16.3459 2.15425 16.5104L7.48964 21.847C7.48966 21.847 7.48961 21.847 7.48964 21.847C7.64992 22.0073 7.74685 22.0658 7.81776 22.0955C7.88818 22.125 7.99973 22.1538 8.23015 22.1538H15.7698C15.9964 22.1538 16.1061 22.1268 16.1771 22.0976C16.2477 22.0687 16.3471 22.0102 16.5104 21.847L21.847 16.5104C22.0073 16.35 22.0658 16.2532 22.0955 16.1822C22.125 16.1118 22.1538 16.0003 22.1538 15.7698V8.23015C22.1538 8.00362 22.1268 7.89393 22.0976 7.82287C22.0687 7.75228 22.0102 7.65286 21.847 7.48964L16.5104 2.15302C16.3471 1.9898 16.2477 1.9313 16.1771 1.90235C16.1061 1.87321 15.9964 1.84615 15.7698 1.84615H8.23015C8.0037 1.84615 7.89439 1.87319 7.82354 1.90227C7.75298 1.93123 7.65289 1.99031 7.48872 2.15394ZM7.12261 0.194349C7.48962 0.0437307 7.85846 0 8.23015 0H15.7698C16.1415 0 16.5105 0.0437121 16.8776 0.194263C17.2452 0.345007 17.5433 0.575125 17.8158 0.847594L23.1524 6.18421C23.4249 6.45668 23.655 6.75479 23.8057 7.12236C23.9563 7.48946 24 7.85853 24 8.23015V15.7698C24 16.1548 23.952 16.5282 23.7987 16.8947C23.6455 17.2607 23.4155 17.5527 23.1524 17.8158L17.8158 23.1524C17.5433 23.4249 17.2452 23.655 16.8776 23.8057C16.5105 23.9563 16.1415 24 15.7698 24H8.23015C7.84519 24 7.47182 23.952 7.10532 23.7987C6.73932 23.6455 6.44726 23.4155 6.18421 23.1524L0.848825 17.8158C0.8488 17.8158 0.84885 17.8158 0.848825 17.8158C0.576388 17.5433 0.345783 17.2454 0.194714 16.8779C0.0437194 16.5106 0 16.1415 0 15.7698V8.23015C0 7.84519 0.0480391 7.47182 0.20135 7.10532C0.354452 6.73932 0.58454 6.44726 0.847594 6.18421L6.18513 0.846674C6.45759 0.574982 6.7554 0.345054 7.12261 0.194349ZM12 5.69477C12.5098 5.69477 12.9231 6.10804 12.9231 6.61785V13.3871C12.9231 13.8969 12.5098 14.3102 12 14.3102C11.4902 14.3102 11.0769 13.8969 11.0769 13.3871V6.61785C11.0769 6.10804 11.4902 5.69477 12 5.69477ZM12 15.8437C12.5098 15.8437 12.9231 16.257 12.9231 16.7668V17.3822C12.9231 17.892 12.5098 18.3052 12 18.3052C11.4902 18.3052 11.0769 17.892 11.0769 17.3822V16.7668C11.0769 16.257 11.4902 15.8437 12 15.8437Z" fill="currentColor"/>
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M12 6.65522V13.3774M12 17.3448V16.7337M6.87278 1.57322C7.30667 1.14056 7.66233 1 8.25633 1H15.7437C16.3377 1 16.6946 1.14056 17.1272 1.57322L22.4268 6.87278C22.8594 7.30544 23 7.66233 23 8.25633V15.7437C23 16.3548 22.8472 16.7068 22.4268 17.1272L17.1272 22.4268C16.6946 22.8594 16.3377 23 15.7437 23H8.25633C7.64522 23 7.29322 22.8472 6.87278 22.4268L1.57444 17.1272C1.14056 16.6933 1 16.3377 1 15.7437V8.25633C1 7.64522 1.15278 7.29322 1.57322 6.87278L6.87278 1.57322Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
3
  </svg>
package/icons/check.svg CHANGED
@@ -1,3 +1,3 @@
1
- <svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2
- <path fill-rule="evenodd" clip-rule="evenodd" d="M23.086 2.4174C24.073 3.13011 24.2953 4.50795 23.5827 5.49488L13.0118 20.1331C13.012 20.1328 13.0116 20.1333 13.0118 20.1331C12.559 20.7606 11.9697 21.2786 11.2894 21.647C10.6088 22.0155 9.85351 22.2256 9.0803 22.2619C8.30708 22.298 7.53554 22.159 6.82355 21.8555C6.11169 21.552 5.4775 21.0918 4.9682 20.5092C4.96837 20.5094 4.96803 20.5089 4.9682 20.5092L0.544999 15.451C-0.256393 14.5348 -0.163144 13.1422 0.753251 12.3408C1.66965 11.5394 3.06219 11.6327 3.86356 12.549L8.28678 17.6071C8.35962 17.6905 8.4506 17.7566 8.55232 17.8001C8.65405 17.8435 8.76437 17.8633 8.8747 17.8581C8.98526 17.8528 9.09319 17.823 9.19038 17.7702C9.28757 17.7177 9.37163 17.6437 9.43634 17.5541L20.0087 2.91393C20.7212 1.92699 22.0991 1.7047 23.086 2.4174Z" fill="currentColor"/>
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M1 14.927L3.94433 18.0266C5.56867 19.7367 6.38083 20.5899 7.29017 20.8599C8.0895 21.0957 8.94017 21.0327 9.701 20.6799C10.5682 20.2767 11.263 19.3101 12.6563 17.375L23 3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
3
  </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M1 6L12 17L23 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M17 1L6 12L17 23" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M6 23L17 12L6 1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M23 17L12 6L1 17" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>