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.
Files changed (77) hide show
  1. package/README.md +10 -10
  2. package/astro.d.ts +30 -16
  3. package/astro.js +17 -1
  4. package/components/Alert/Alert.tsx +1 -8
  5. package/components/Alert/alert.scss +1 -0
  6. package/components/Alert/alert.ts +6 -0
  7. package/components/Avatar/Avatar.tsx +1 -0
  8. package/components/Badge/Badge.astro +3 -2
  9. package/components/Badge/Badge.svelte +1 -1
  10. package/components/Badge/Badge.tsx +3 -7
  11. package/components/Badge/badge.ts +4 -0
  12. package/components/Button/Button.tsx +1 -5
  13. package/components/Button/button.scss +0 -1
  14. package/components/Button/button.ts +5 -1
  15. package/components/Card/Card.tsx +1 -7
  16. package/components/Card/card.scss +1 -0
  17. package/components/Card/card.ts +6 -0
  18. package/components/Checkbox/Checkbox.tsx +2 -6
  19. package/components/Checkbox/checkbox.ts +4 -0
  20. package/components/ConditionalWrapper/ConditionalWrapper.tsx +2 -8
  21. package/components/ConditionalWrapper/conditionalwrapper.ts +5 -0
  22. package/components/Input/Input.astro +52 -0
  23. package/components/Input/Input.svelte +52 -0
  24. package/components/Input/Input.tsx +59 -0
  25. package/components/Input/input.scss +83 -0
  26. package/components/Input/input.ts +44 -0
  27. package/components/Progress/Progress.astro +40 -0
  28. package/components/Progress/Progress.svelte +38 -0
  29. package/components/Progress/Progress.tsx +47 -0
  30. package/components/Progress/progress.scss +66 -0
  31. package/components/Progress/progress.ts +12 -0
  32. package/components/Radio/Radio.tsx +2 -6
  33. package/components/Radio/radio.ts +4 -0
  34. package/components/Spinner/Spinner.astro +42 -0
  35. package/components/Spinner/Spinner.svelte +38 -0
  36. package/components/Spinner/Spinner.tsx +44 -0
  37. package/components/Spinner/spinner.scss +41 -0
  38. package/components/Spinner/spinner.ts +7 -0
  39. package/components/Switch/Switch.tsx +2 -6
  40. package/components/Switch/switch.ts +4 -0
  41. package/components/Table/Table.astro +60 -0
  42. package/components/Table/Table.svelte +54 -0
  43. package/components/Table/Table.tsx +63 -0
  44. package/components/Table/table.scss +65 -0
  45. package/components/Table/table.ts +10 -0
  46. package/components/Tabs/Tabs.astro +76 -0
  47. package/components/Tabs/Tabs.svelte +54 -0
  48. package/components/Tabs/Tabs.tsx +69 -0
  49. package/components/Tabs/tabs.scss +134 -0
  50. package/components/Tabs/tabs.ts +16 -0
  51. package/components/Timeline/Timeline.astro +34 -0
  52. package/components/Timeline/Timeline.svelte +30 -0
  53. package/components/Timeline/Timeline.tsx +37 -0
  54. package/components/Timeline/timeline.scss +71 -0
  55. package/components/Timeline/timeline.ts +61 -0
  56. package/components/TimelineItem/TimelineItem.astro +26 -0
  57. package/components/TimelineItem/TimelineItem.svelte +22 -0
  58. package/components/TimelineItem/TimelineItem.tsx +32 -0
  59. package/components/TimelineItem/timelineitem.scss +31 -0
  60. package/components/TimelineItem/timelineitem.ts +5 -0
  61. package/components/Toast/Toast.astro +30 -0
  62. package/components/Toast/Toast.svelte +21 -0
  63. package/components/Toast/Toast.tsx +28 -0
  64. package/components/Toast/toast.scss +43 -0
  65. package/components/Toast/toast.ts +11 -0
  66. package/index.js +1 -0
  67. package/package.json +3 -1
  68. package/react.d.ts +42 -27
  69. package/react.js +17 -1
  70. package/scss/global/tooltip.scss +133 -0
  71. package/scss/global/utility.scss +17 -0
  72. package/scss/global.scss +1 -0
  73. package/scss/resets.scss +4 -0
  74. package/scss/setup.scss +20 -1
  75. package/svelte.d.ts +30 -16
  76. package/svelte.js +17 -1
  77. package/utils/toast.ts +65 -0
@@ -0,0 +1,10 @@
1
+ export type TableProps = {
2
+ headings?: string[]
3
+ footer?: string[]
4
+ data: string[][]
5
+ hover?: boolean
6
+ striped?: 'column' | 'row' | null
7
+ offsetStripe?: boolean
8
+ compact?: boolean
9
+ className?: string
10
+ }
@@ -0,0 +1,76 @@
1
+ ---
2
+ import type { TabsProps } from './tabs'
3
+ import './tabs.scss'
4
+
5
+ interface Props extends TabsProps {}
6
+
7
+ const {
8
+ items,
9
+ theme,
10
+ vertical,
11
+ even,
12
+ className
13
+ } = Astro.props
14
+
15
+ const classes = [
16
+ 'w-tabs',
17
+ theme && theme,
18
+ vertical && 'vertical',
19
+ even && 'even',
20
+ className
21
+ ]
22
+ ---
23
+
24
+ <section class:list={classes} data-id="w-tabs">
25
+ <div class="tabs-wrapper">
26
+ <div class="tabs">
27
+ {items.map(item => (
28
+ <button
29
+ data-value={item.value}
30
+ class:list={[item.active && 'active']}
31
+ disabled={item.disabled}
32
+ >
33
+ <Fragment set:html={item.label} />
34
+ </button>
35
+ ))}
36
+ </div>
37
+ </div>
38
+ <div class="tab-content">
39
+ <slot />
40
+ </div>
41
+ </section>
42
+
43
+ <script>
44
+ const tabs = document.querySelectorAll('[data-id="w-tabs"]')
45
+
46
+ Array.from(tabs).forEach(element => {
47
+ element.addEventListener('click', event => {
48
+ const target = event.target as HTMLDivElement
49
+
50
+ if (target.dataset.value) {
51
+ const tabContent = target.parentElement
52
+ ?.parentElement
53
+ ?.nextElementSibling as HTMLDivElement
54
+
55
+ Array.from(tabContent.children)
56
+ .forEach((element: any) => {
57
+ if (element.dataset.tab === target.dataset.value) {
58
+ element.dataset.active = true
59
+ } else {
60
+ element.dataset.active = false
61
+ }
62
+ })
63
+
64
+ const tabs = target.parentElement?.querySelectorAll('button') as NodeListOf<HTMLButtonElement>
65
+
66
+ Array.from(tabs).forEach((tab: any) => {
67
+ tab.classList.remove('active')
68
+
69
+ if (tab.dataset.value === target.dataset.value) {
70
+ tab.classList.add('active')
71
+ }
72
+ })
73
+ }
74
+ })
75
+ })
76
+ </script>
@@ -0,0 +1,54 @@
1
+ <script lang="ts">
2
+ import type { TabsProps } from './tabs'
3
+ import './tabs.scss'
4
+
5
+ export let items: TabsProps['items'] = []
6
+ export let theme: TabsProps['theme'] = null
7
+ export let vertical: TabsProps['vertical'] = false
8
+ export let even: TabsProps['even'] = false
9
+ export let className: TabsProps['className'] = ''
10
+
11
+ let active = ''
12
+ let tabContainer: HTMLDivElement
13
+
14
+ const classes = [
15
+ 'w-tabs',
16
+ theme && theme,
17
+ vertical && 'vertical',
18
+ even && 'even',
19
+ className
20
+ ].filter(Boolean).join(' ')
21
+
22
+ const setTab = (tab: string) => {
23
+ const tabs = tabContainer.querySelectorAll('[data-tab]')
24
+
25
+ active = tab
26
+
27
+ Array.from(tabs).forEach((item: any) => {
28
+ item.dataset.active = false
29
+
30
+ if (item.dataset.tab === active) {
31
+ item.dataset.active = true
32
+ }
33
+ })
34
+ }
35
+ </script>
36
+
37
+ <section class={classes}>
38
+ <div class="tabs-wrapper">
39
+ <div class="tabs">
40
+ {#each items as item}
41
+ <button
42
+ class:active={active ? active === item.value : item.active}
43
+ disabled={item.disabled}
44
+ on:click={() => setTab(item.value)}
45
+ >
46
+ {@html item.label}
47
+ </button>
48
+ {/each}
49
+ </div>
50
+ </div>
51
+ <div class="tab-content" bind:this={tabContainer}>
52
+ <slot />
53
+ </div>
54
+ </section>
@@ -0,0 +1,69 @@
1
+ import React, { useState, useRef } from 'react'
2
+ import type { ReactTabsProps } from './tabs'
3
+
4
+ import './tabs.scss'
5
+
6
+ const Tabs = ({
7
+ items,
8
+ theme,
9
+ vertical,
10
+ even,
11
+ className,
12
+ children
13
+ }: ReactTabsProps) => {
14
+ const tabContainer = useRef<HTMLDivElement>(null)
15
+ const [active, setActive] = useState('')
16
+
17
+ const classes = [
18
+ 'w-tabs',
19
+ theme && theme,
20
+ vertical && 'vertical',
21
+ even && 'even',
22
+ className
23
+ ].filter(Boolean).join(' ')
24
+
25
+ const setTab = (tab: string) => {
26
+ const tabs = tabContainer.current!.querySelectorAll('[data-tab]')
27
+
28
+ Array.from(tabs).forEach((item: any) => {
29
+ item.dataset.active = false
30
+
31
+ if (item.dataset.tab === tab) {
32
+ item.dataset.active = true
33
+ }
34
+ })
35
+
36
+ setActive(tab)
37
+ }
38
+
39
+ const isActive = (item: ReactTabsProps['items'][0]) => {
40
+ if (!active) {
41
+ return item.active ? 'active' : undefined
42
+ }
43
+
44
+ return active === item.value ? 'active' : undefined
45
+ }
46
+
47
+ return (
48
+ <section className={classes}>
49
+ <div className="tabs-wrapper">
50
+ <div className="tabs">
51
+ {items.map((item, index) => (
52
+ <button
53
+ key={index}
54
+ disabled={item.disabled}
55
+ dangerouslySetInnerHTML={{ __html: item.label }}
56
+ onClick={() => setTab(item.value)}
57
+ className={isActive(item)}
58
+ />
59
+ ))}
60
+ </div>
61
+ </div>
62
+ <div className="tab-content" ref={tabContainer}>
63
+ {children}
64
+ </div>
65
+ </section>
66
+ )
67
+ }
68
+
69
+ export default Tabs
@@ -0,0 +1,134 @@
1
+ @import '../../scss/config.scss';
2
+
3
+ .w-tabs {
4
+
5
+ &.boxed .tabs,
6
+ &.outline .tabs {
7
+ background: #252525;
8
+ border-radius: 5px;
9
+ padding: 5px;
10
+ width: fit-content;
11
+
12
+ button {
13
+ @include Transition();
14
+ border-radius: 5px;
15
+ padding: 10px;
16
+
17
+ &.active {
18
+ border: 0;
19
+ background: #000;
20
+ padding-bottom: 10px;
21
+ }
22
+ }
23
+ }
24
+
25
+ &.outline .tabs {
26
+ background: transparent;
27
+ border: 1px solid #252525;
28
+
29
+ button {
30
+ margin-bottom: 0;
31
+
32
+ &.active {
33
+ background: #252525;
34
+ }
35
+ }
36
+ }
37
+
38
+ &.even .tabs button {
39
+ flex: 1;
40
+ justify-content: center;
41
+ }
42
+
43
+ &.vertical {
44
+ display: flex;
45
+ gap: 20px;
46
+
47
+ &.boxed .tabs button,
48
+ &.outline .tabs button {
49
+ border-bottom: 0;
50
+ }
51
+
52
+ .tabs {
53
+ flex-direction: column;
54
+ gap: 5px;
55
+
56
+ button {
57
+ padding: 10px;
58
+ border-bottom: 2px solid #252525;
59
+
60
+ &.active {
61
+ padding-bottom: 10px;
62
+ }
63
+ }
64
+ }
65
+
66
+ .tab-content {
67
+ margin-top: 0;
68
+ }
69
+ }
70
+
71
+ .tabs-wrapper {
72
+ overflow: auto;
73
+ }
74
+
75
+ .tabs {
76
+ border-bottom: 2px solid #252525;
77
+ display: flex;
78
+ gap: 10px;
79
+
80
+ button {
81
+ @include Transition(color);
82
+ background: transparent;
83
+ cursor: pointer;
84
+ color: #FFF;
85
+ border: 0;
86
+ font-size: 16px;
87
+ padding: 0;
88
+ margin-bottom: -2px;
89
+ padding: 15px 15px;
90
+ color: #BBB;
91
+ display: flex;
92
+ align-items: center;
93
+ gap: 10px;
94
+ flex-shrink: 0;
95
+
96
+ svg {
97
+ pointer-events: none;
98
+ width: 20px;
99
+ height: 20px;
100
+ }
101
+
102
+ &[disabled] {
103
+ color: #555;
104
+ cursor: no-drop;
105
+ }
106
+
107
+ &.active {
108
+ color: #FFF;
109
+ border-bottom: 2px solid #FFF;
110
+ padding-bottom: 13px;
111
+ }
112
+ }
113
+ }
114
+
115
+ .tab-content {
116
+ margin-top: 20px;
117
+ }
118
+
119
+ [data-tab] {
120
+ display: none;
121
+
122
+ &[data-active="true"] {
123
+ display: block;
124
+ }
125
+ }
126
+ }
127
+
128
+ @include Media('xs') {
129
+ .w-tabs {
130
+ &.even .tabs {
131
+ width: auto;
132
+ }
133
+ }
134
+ }
@@ -0,0 +1,16 @@
1
+ export type TabsProps = {
2
+ items: {
3
+ label: string
4
+ value: string
5
+ active?: boolean
6
+ disabled?: boolean
7
+ }[]
8
+ theme?: 'boxed' | 'outline' | null
9
+ vertical?: boolean
10
+ even?: boolean
11
+ className?: string
12
+ }
13
+
14
+ export type ReactTabsProps = {
15
+ children: React.ReactNode
16
+ } & TabsProps
@@ -0,0 +1,34 @@
1
+ ---
2
+ import type { TimelineProps } from './timeline'
3
+ import './timeline.scss'
4
+
5
+ interface Props extends TimelineProps {}
6
+
7
+ const {
8
+ theme,
9
+ counter,
10
+ alternate,
11
+ centered,
12
+ color,
13
+ textColor,
14
+ className
15
+ } = Astro.props
16
+
17
+ const classes = [
18
+ 'w-timeline',
19
+ theme,
20
+ alternate && 'alternate',
21
+ centered && 'centered',
22
+ className
23
+ ]
24
+
25
+ const styles = [
26
+ color && `--w-timeline-color: ${color};`,
27
+ textColor && `--w-timeline-text-color: ${textColor};`,
28
+ counter && `--w-timeline-counter: ${counter};`,
29
+ ].join('')
30
+ ---
31
+
32
+ <ul class:list={classes} style={styles}>
33
+ <slot />
34
+ </ul>
@@ -0,0 +1,30 @@
1
+ <script lang="ts">
2
+ import type { TimelineProps } from './timeline'
3
+ import './timeline.scss'
4
+
5
+ export let theme: TimelineProps['theme'] = null
6
+ export let counter: TimelineProps['counter'] = null
7
+ export let alternate: TimelineProps['alternate'] = false
8
+ export let centered: TimelineProps['centered'] = false
9
+ export let color: TimelineProps['color'] = ''
10
+ export let textColor: TimelineProps['textColor'] = ''
11
+ export let className: TimelineProps['className'] = ''
12
+
13
+ const classes = [
14
+ 'w-timeline',
15
+ theme,
16
+ alternate && 'alternate',
17
+ centered && 'centered',
18
+ className
19
+ ].filter(Boolean).join(' ')
20
+
21
+ const styles = [
22
+ color && `--w-timeline-color: ${color};`,
23
+ textColor && `--w-timeline-text-color: ${textColor};`,
24
+ counter && `--w-timeline-counter: ${counter};`,
25
+ ].join('')
26
+ </script>
27
+
28
+ <ul class={classes} style={styles}>
29
+ <slot />
30
+ </ul>
@@ -0,0 +1,37 @@
1
+ import React from 'react'
2
+ import type { ReactTimelineProps } from './timeline'
3
+
4
+ import './timeline.scss'
5
+
6
+ const Timeline = ({
7
+ theme,
8
+ counter,
9
+ alternate,
10
+ centered,
11
+ color,
12
+ textColor,
13
+ className,
14
+ children
15
+ }: ReactTimelineProps) => {
16
+ const classes = [
17
+ 'w-timeline',
18
+ theme,
19
+ alternate && 'alternate',
20
+ centered && 'centered',
21
+ className
22
+ ].filter(Boolean).join(' ')
23
+
24
+ const styles = {
25
+ ...(color && { '--w-timeline-color': color }),
26
+ ...(textColor && { '--w-timeline-text-color': textColor }),
27
+ ...(counter && { '--w-timeline-counter': counter }),
28
+ } as React.CSSProperties
29
+
30
+ return (
31
+ <ul className={classes} style={styles}>
32
+ {children}
33
+ </ul>
34
+ )
35
+ }
36
+
37
+ export default Timeline
@@ -0,0 +1,71 @@
1
+ @import '../../scss/config.scss';
2
+
3
+ // (circle width + border * 2) / 2 - line width
4
+ $leftOffset: calc(((25px + 4px) / 2) - 1px);
5
+ $rightOffset: calc((((25px + 4px) / 2) - 1px) * -1);
6
+
7
+ .w-timeline {
8
+ display: flex;
9
+ gap: 20px;
10
+ flex-direction: column;
11
+ padding: 0 0 0 40px;
12
+ margin: 0;
13
+ list-style-type: none;
14
+ counter-reset: item;
15
+ position: relative;
16
+
17
+ &::before {
18
+ position: absolute;
19
+ content: '';
20
+ width: 1px;
21
+ background: var(--w-timeline-color);
22
+ height: 100%;
23
+ left: $leftOffset
24
+ }
25
+
26
+ &.fill li::before {
27
+ content: '';
28
+ }
29
+
30
+ &.stroke li::before {
31
+ background: #000;
32
+ border: 2px solid var(--w-timeline-color);
33
+ }
34
+ }
35
+
36
+ @include Media('xs') {
37
+ .w-timeline {
38
+ &.alternate {
39
+ padding: 0;
40
+
41
+ &::before {
42
+ left: calc(50% - 1px);
43
+ }
44
+
45
+ li {
46
+ width: 50%;
47
+
48
+ &:nth-child(odd) {
49
+ padding-right: 40px;
50
+ }
51
+
52
+ &:nth-child(even) {
53
+ align-self: flex-end;
54
+ padding-left: 40px;
55
+
56
+ &::before {
57
+ left: 25px;
58
+ }
59
+ }
60
+
61
+ &::before {
62
+ right: $rightOffset;
63
+ }
64
+ }
65
+ }
66
+
67
+ &.centered li:nth-child(odd) {
68
+ text-align: right;
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,61 @@
1
+ export type TimelineProps = {
2
+ theme?: 'fill' | 'stroke' | 'stroke fill' | null
3
+ alternate?: boolean
4
+ centered?: boolean
5
+ color?: string
6
+ textColor?: string
7
+ className?: string
8
+ counter?: 'arabic-indic'
9
+ | 'armenian'
10
+ | 'bengali'
11
+ | 'cambodian'
12
+ | 'circle'
13
+ | 'cjk-decimal'
14
+ | 'cjk-earthly-branch'
15
+ | 'cjk-heavenly-stem'
16
+ | 'decimal-leading-zero'
17
+ | 'devanagari'
18
+ | 'disc'
19
+ | 'disclosure-closed'
20
+ | 'disclosure-open'
21
+ | 'ethiopic-numeric'
22
+ | 'georgian'
23
+ | 'gujarati'
24
+ | 'gurmukhi'
25
+ | 'hebrew'
26
+ | 'hiragana'
27
+ | 'hiragana-iroha'
28
+ | 'japanese-formal'
29
+ | 'kannada'
30
+ | 'katakana'
31
+ | 'katakana-iroha'
32
+ | 'khmer'
33
+ | 'korean-hangul-formal'
34
+ | 'korean-hanja-formal'
35
+ | 'lao'
36
+ | 'lower-alpha'
37
+ | 'lower-alpha'
38
+ | 'lower-armenian'
39
+ | 'lower-greek'
40
+ | 'lower-roman'
41
+ | 'malayalam'
42
+ | 'mongolian'
43
+ | 'myanmar'
44
+ | 'oriya'
45
+ | 'persian'
46
+ | 'simp-chinese-formal'
47
+ | 'square'
48
+ | 'tamil'
49
+ | 'telugu'
50
+ | 'thai'
51
+ | 'tibetan'
52
+ | 'trad-chinese-formal'
53
+ | 'upper-alpha'
54
+ | 'upper-armenian'
55
+ | 'upper-roman'
56
+ | null
57
+ }
58
+
59
+ export type ReactTimelineProps = {
60
+ children: React.ReactNode
61
+ } & TimelineProps
@@ -0,0 +1,26 @@
1
+ ---
2
+ import type { TimelineItemProps } from './timelineitem'
3
+ import './timelineitem.scss'
4
+
5
+ interface Props extends TimelineItemProps {}
6
+
7
+ const {
8
+ title,
9
+ titleTag = 'span',
10
+ className
11
+ } = Astro.props
12
+
13
+ const classes = [
14
+ 'w-timeline-item',
15
+ className
16
+ ]
17
+
18
+ const Title = titleTag
19
+ ---
20
+
21
+ <li class:list={classes}>
22
+ {title && (
23
+ <Title class:list="timeline-title">{title}</Title>
24
+ )}
25
+ <slot />
26
+ </li>
@@ -0,0 +1,22 @@
1
+ <script lang="ts">
2
+ import type { TimelineItemProps } from './timelineitem'
3
+ import './timelineitem.scss'
4
+
5
+ export let title: TimelineItemProps['title'] = ''
6
+ export let titleTag: TimelineItemProps['titleTag'] = 'span'
7
+ export let className: TimelineItemProps['className'] = ''
8
+
9
+ const classes = [
10
+ 'w-timeline-item',
11
+ className
12
+ ].filter(Boolean).join(' ')
13
+ </script>
14
+
15
+ <li class={classes}>
16
+ {#if title}
17
+ <svelte:element this={titleTag} class="timeline-title">
18
+ {title}
19
+ </svelte:element>
20
+ {/if}
21
+ <slot />
22
+ </li>
@@ -0,0 +1,32 @@
1
+ import React from 'react'
2
+ import type { TimelineItemProps } from './timelineitem'
3
+
4
+ import './timelineitem.scss'
5
+
6
+ type ReactTimelineItemProps = {
7
+ TitleTag?: keyof JSX.IntrinsicElements
8
+ children: React.ReactNode
9
+ } & Omit<TimelineItemProps, 'titleTag'>
10
+
11
+ const TimelineItem = ({
12
+ title,
13
+ TitleTag = 'span',
14
+ className,
15
+ children
16
+ }: ReactTimelineItemProps) => {
17
+ const classes = [
18
+ 'w-timeline-item',
19
+ className
20
+ ].filter(Boolean).join(' ')
21
+
22
+ return (
23
+ <li className={classes}>
24
+ {title && (
25
+ <TitleTag className="timeline-title">{title}</TitleTag>
26
+ )}
27
+ {children}
28
+ </li>
29
+ )
30
+ }
31
+
32
+ export default TimelineItem