webcoreui 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/astro.d.ts +30 -16
- package/astro.js +17 -1
- package/components/Alert/Alert.tsx +1 -8
- package/components/Alert/alert.scss +1 -0
- package/components/Alert/alert.ts +6 -0
- package/components/Avatar/Avatar.tsx +1 -0
- package/components/Badge/Badge.astro +3 -2
- package/components/Badge/Badge.svelte +1 -1
- package/components/Badge/Badge.tsx +3 -7
- package/components/Badge/badge.ts +4 -0
- package/components/Button/Button.tsx +1 -5
- package/components/Button/button.scss +0 -1
- package/components/Button/button.ts +5 -1
- package/components/Card/Card.tsx +1 -7
- package/components/Card/card.scss +1 -0
- package/components/Card/card.ts +6 -0
- package/components/Checkbox/Checkbox.tsx +2 -6
- package/components/Checkbox/checkbox.ts +4 -0
- package/components/ConditionalWrapper/ConditionalWrapper.tsx +2 -8
- package/components/ConditionalWrapper/conditionalwrapper.ts +5 -0
- package/components/Input/Input.astro +52 -0
- package/components/Input/Input.svelte +52 -0
- package/components/Input/Input.tsx +59 -0
- package/components/Input/input.scss +83 -0
- package/components/Input/input.ts +44 -0
- package/components/Progress/Progress.astro +40 -0
- package/components/Progress/Progress.svelte +38 -0
- package/components/Progress/Progress.tsx +47 -0
- package/components/Progress/progress.scss +66 -0
- package/components/Progress/progress.ts +12 -0
- package/components/Radio/Radio.tsx +2 -6
- package/components/Radio/radio.ts +4 -0
- package/components/Spinner/Spinner.astro +42 -0
- package/components/Spinner/Spinner.svelte +38 -0
- package/components/Spinner/Spinner.tsx +44 -0
- package/components/Spinner/spinner.scss +41 -0
- package/components/Spinner/spinner.ts +7 -0
- package/components/Switch/Switch.tsx +2 -6
- package/components/Switch/switch.ts +4 -0
- package/components/Table/Table.astro +60 -0
- package/components/Table/Table.svelte +54 -0
- package/components/Table/Table.tsx +63 -0
- package/components/Table/table.scss +65 -0
- package/components/Table/table.ts +10 -0
- package/components/Tabs/Tabs.astro +76 -0
- package/components/Tabs/Tabs.svelte +54 -0
- package/components/Tabs/Tabs.tsx +69 -0
- package/components/Tabs/tabs.scss +134 -0
- package/components/Tabs/tabs.ts +16 -0
- package/components/Timeline/Timeline.astro +34 -0
- package/components/Timeline/Timeline.svelte +30 -0
- package/components/Timeline/Timeline.tsx +37 -0
- package/components/Timeline/timeline.scss +71 -0
- package/components/Timeline/timeline.ts +61 -0
- package/components/TimelineItem/TimelineItem.astro +26 -0
- package/components/TimelineItem/TimelineItem.svelte +22 -0
- package/components/TimelineItem/TimelineItem.tsx +32 -0
- package/components/TimelineItem/timelineitem.scss +31 -0
- package/components/TimelineItem/timelineitem.ts +5 -0
- package/components/Toast/Toast.astro +30 -0
- package/components/Toast/Toast.svelte +21 -0
- package/components/Toast/Toast.tsx +28 -0
- package/components/Toast/toast.scss +43 -0
- package/components/Toast/toast.ts +11 -0
- package/index.js +1 -0
- package/package.json +3 -1
- package/react.d.ts +42 -27
- package/react.js +17 -1
- package/scss/global/tooltip.scss +133 -0
- package/scss/global/utility.scss +17 -0
- package/scss/global.scss +1 -0
- package/scss/resets.scss +4 -0
- package/scss/setup.scss +20 -1
- package/svelte.d.ts +30 -16
- package/svelte.js +17 -1
- package/utils/toast.ts +65 -0
package/utils/toast.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { AlertProps } from '../components/Alert/alert'
|
|
2
|
+
|
|
3
|
+
type Toast = {
|
|
4
|
+
element: string
|
|
5
|
+
timeout?: number
|
|
6
|
+
title?: AlertProps['title']
|
|
7
|
+
content?: string
|
|
8
|
+
theme?: AlertProps['theme']
|
|
9
|
+
position?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let defaultTimeout = 5000
|
|
13
|
+
|
|
14
|
+
export let setDefaultTimeout = (time: number) => defaultTimeout = time
|
|
15
|
+
|
|
16
|
+
export const toast = (config: Toast | string) => {
|
|
17
|
+
const element = typeof config === 'string'
|
|
18
|
+
? config
|
|
19
|
+
: config.element
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
timeout,
|
|
23
|
+
title,
|
|
24
|
+
content,
|
|
25
|
+
theme,
|
|
26
|
+
position
|
|
27
|
+
} = (typeof config === 'string' ? {} : config) as Toast
|
|
28
|
+
|
|
29
|
+
const htmlElement = document.querySelector(element)
|
|
30
|
+
|
|
31
|
+
if (htmlElement) {
|
|
32
|
+
if (theme) {
|
|
33
|
+
htmlElement.classList.add(theme)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (position) {
|
|
37
|
+
htmlElement.classList.add(position, 'no-anim')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (title) {
|
|
41
|
+
const titleElement = htmlElement.querySelector('.alert-title')
|
|
42
|
+
|
|
43
|
+
titleElement ? titleElement.innerHTML = title : null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (content) {
|
|
47
|
+
const contentElement = htmlElement.querySelector('.alert-body')
|
|
48
|
+
|
|
49
|
+
contentElement ? contentElement.innerHTML = content : null
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
htmlElement.classList.remove('no-anim')
|
|
54
|
+
htmlElement.classList.add('show')
|
|
55
|
+
}, 0)
|
|
56
|
+
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
htmlElement.classList.remove('show')
|
|
59
|
+
}, timeout || defaultTimeout)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const hideToast = (element: string) => {
|
|
64
|
+
document.querySelector(element)?.classList.remove('show')
|
|
65
|
+
}
|