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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { ProgressProps } from './progress'
|
|
3
|
+
import './progress.scss'
|
|
4
|
+
|
|
5
|
+
interface Props extends ProgressProps {}
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
value,
|
|
9
|
+
size,
|
|
10
|
+
label,
|
|
11
|
+
color,
|
|
12
|
+
background,
|
|
13
|
+
square,
|
|
14
|
+
striped,
|
|
15
|
+
stripeLight,
|
|
16
|
+
stripeDark,
|
|
17
|
+
className
|
|
18
|
+
} = Astro.props
|
|
19
|
+
|
|
20
|
+
const classes = [
|
|
21
|
+
'w-progress',
|
|
22
|
+
size,
|
|
23
|
+
striped && 'striped',
|
|
24
|
+
square && 'square',
|
|
25
|
+
className
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
const styles = [
|
|
29
|
+
color && `--w-progress-color: ${color};`,
|
|
30
|
+
background && `--w-progress-background: ${background};`,
|
|
31
|
+
stripeLight && `--w-progress-stripe-light: ${stripeLight};`,
|
|
32
|
+
stripeDark && `--w-progress-stripe-dark: ${stripeDark};`
|
|
33
|
+
].filter(Boolean).join('')
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
<div class:list={classes} style={styles}>
|
|
37
|
+
<div class="progress" style={`--w-progress-width: ${value}%;`}>
|
|
38
|
+
{label && `${value}%`}
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ProgressProps } from './progress'
|
|
3
|
+
import './progress.scss'
|
|
4
|
+
|
|
5
|
+
export let value: ProgressProps['value'] = 0
|
|
6
|
+
export let size: ProgressProps['size'] = null
|
|
7
|
+
export let label: ProgressProps['label'] = false
|
|
8
|
+
export let color: ProgressProps['color'] = ''
|
|
9
|
+
export let background: ProgressProps['background'] = ''
|
|
10
|
+
export let square: ProgressProps['square'] = false
|
|
11
|
+
export let striped: ProgressProps['striped'] = false
|
|
12
|
+
export let stripeLight: ProgressProps['stripeLight'] = ''
|
|
13
|
+
export let stripeDark: ProgressProps['stripeDark'] = ''
|
|
14
|
+
export let className: ProgressProps['className'] = ''
|
|
15
|
+
|
|
16
|
+
const classes = [
|
|
17
|
+
'w-progress',
|
|
18
|
+
size,
|
|
19
|
+
striped && 'striped',
|
|
20
|
+
square && 'square',
|
|
21
|
+
className
|
|
22
|
+
].filter(Boolean).join(' ')
|
|
23
|
+
|
|
24
|
+
const styles = [
|
|
25
|
+
color && `--w-progress-color: ${color};`,
|
|
26
|
+
background && `--w-progress-background: ${background};`,
|
|
27
|
+
stripeLight && `--w-progress-stripe-light: ${stripeLight};`,
|
|
28
|
+
stripeDark && `--w-progress-stripe-dark: ${stripeDark};`
|
|
29
|
+
].filter(Boolean).join('')
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<div class={classes} style={styles}>
|
|
33
|
+
<div class="progress" style={`--w-progress-width: ${value}%;`}>
|
|
34
|
+
{#if label}
|
|
35
|
+
{`${value}%`}
|
|
36
|
+
{/if}
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { ProgressProps } from './progress'
|
|
3
|
+
|
|
4
|
+
import './progress.scss'
|
|
5
|
+
|
|
6
|
+
const Progress = ({
|
|
7
|
+
value,
|
|
8
|
+
size,
|
|
9
|
+
label,
|
|
10
|
+
color,
|
|
11
|
+
background,
|
|
12
|
+
square,
|
|
13
|
+
striped,
|
|
14
|
+
stripeLight,
|
|
15
|
+
stripeDark,
|
|
16
|
+
className
|
|
17
|
+
}: ProgressProps) => {
|
|
18
|
+
const classes = [
|
|
19
|
+
'w-progress',
|
|
20
|
+
size,
|
|
21
|
+
striped && 'striped',
|
|
22
|
+
square && 'square',
|
|
23
|
+
className
|
|
24
|
+
].filter(Boolean).join(' ')
|
|
25
|
+
|
|
26
|
+
const styles = {
|
|
27
|
+
...(color && { '--w-progress-color': color }),
|
|
28
|
+
...(background && { '--w-progress-background': background }),
|
|
29
|
+
...(stripeLight && { '--w-progress-stripe-light': stripeLight }),
|
|
30
|
+
...(stripeDark && { '--w-progress-stripe-dark': stripeDark }),
|
|
31
|
+
} as React.CSSProperties
|
|
32
|
+
|
|
33
|
+
const percent = {
|
|
34
|
+
'--w-progress-width': `${value}%`
|
|
35
|
+
} as React.CSSProperties
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className={classes} style={styles}>
|
|
39
|
+
<div className="progress" style={percent}>
|
|
40
|
+
{label && `${value}%`}
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default Progress
|
|
47
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
@import '../../scss/config.scss';
|
|
2
|
+
|
|
3
|
+
.w-progress {
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 10px;
|
|
6
|
+
background: var(--w-progress-background);
|
|
7
|
+
border-radius: 20px;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
color: var(--w-progress-background);
|
|
10
|
+
font-family: Bold;
|
|
11
|
+
font-size: 10px;
|
|
12
|
+
|
|
13
|
+
&.medium {
|
|
14
|
+
height: 15px;
|
|
15
|
+
font-size: 12px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&.large {
|
|
19
|
+
height: 20px;
|
|
20
|
+
font-size: 14px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.square {
|
|
24
|
+
border-radius: 2px;
|
|
25
|
+
|
|
26
|
+
.progress {
|
|
27
|
+
border-radius: 2px;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&.striped {
|
|
32
|
+
|
|
33
|
+
.progress {
|
|
34
|
+
background-size: 10px 10px;
|
|
35
|
+
background-image: linear-gradient(
|
|
36
|
+
-45deg,
|
|
37
|
+
var(--w-progress-stripe-light) 25%,
|
|
38
|
+
var(--w-progress-stripe-dark) 25%,
|
|
39
|
+
var(--w-progress-stripe-dark) 50%,
|
|
40
|
+
var(--w-progress-stripe-light) 50%,
|
|
41
|
+
var(--w-progress-stripe-light) 75%,
|
|
42
|
+
var(--w-progress-stripe-dark) 75%,
|
|
43
|
+
var(--w-progress-stripe-dark)
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.medium .progress {
|
|
48
|
+
background-size: 15px 15px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&.large .progress {
|
|
52
|
+
background-size: 20px 20px;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.progress {
|
|
57
|
+
@include Transition(width);
|
|
58
|
+
width: var(--w-progress-width);
|
|
59
|
+
height: 100%;
|
|
60
|
+
background: var(--w-progress-color);
|
|
61
|
+
border-radius: 20px;
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { ReactRadioProps } from './radio'
|
|
3
3
|
|
|
4
4
|
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
|
|
5
5
|
|
|
6
6
|
import './radio.scss'
|
|
7
7
|
|
|
8
|
-
type ReactRadioProps = {
|
|
9
|
-
onChange?: () => any
|
|
10
|
-
} & RadioProps
|
|
11
|
-
|
|
12
8
|
const Radio = ({
|
|
13
9
|
name,
|
|
14
10
|
items,
|
|
@@ -46,7 +42,7 @@ const Radio = ({
|
|
|
46
42
|
type="radio"
|
|
47
43
|
name={name}
|
|
48
44
|
value={item.value}
|
|
49
|
-
|
|
45
|
+
defaultChecked={item.selected}
|
|
50
46
|
disabled={item.disabled}
|
|
51
47
|
onChange={onChange}
|
|
52
48
|
/>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { SpinnerProps } from './spinner'
|
|
3
|
+
import './spinner.scss'
|
|
4
|
+
|
|
5
|
+
interface Props extends SpinnerProps {}
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
color,
|
|
9
|
+
width,
|
|
10
|
+
speed,
|
|
11
|
+
size,
|
|
12
|
+
dashArray,
|
|
13
|
+
} = Astro.props
|
|
14
|
+
|
|
15
|
+
const classes = [
|
|
16
|
+
'w-spinner',
|
|
17
|
+
dashArray && 'dashed'
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
const styles = [
|
|
21
|
+
color && `--w-spinner-color: ${color};`,
|
|
22
|
+
width && `--w-spinner-width: ${width}px;`,
|
|
23
|
+
speed && `--w-spinner-speed: ${speed}s;`,
|
|
24
|
+
size && `--w-spinner-size: ${size}px;`,
|
|
25
|
+
dashArray && `--w-spinner-dash: ${dashArray}`,
|
|
26
|
+
].filter(Boolean).join(' ')
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
<svg
|
|
30
|
+
class:list={classes}
|
|
31
|
+
viewBox="25 25 50 50"
|
|
32
|
+
role="status"
|
|
33
|
+
style={styles}
|
|
34
|
+
>
|
|
35
|
+
<circle
|
|
36
|
+
class="spinner-path"
|
|
37
|
+
cx="50"
|
|
38
|
+
cy="50"
|
|
39
|
+
r="20"
|
|
40
|
+
fill="none"
|
|
41
|
+
/>
|
|
42
|
+
</svg>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SpinnerProps } from './spinner'
|
|
3
|
+
import './spinner.scss'
|
|
4
|
+
|
|
5
|
+
export let color: SpinnerProps['color'] = ''
|
|
6
|
+
export let width: SpinnerProps['width'] = 0
|
|
7
|
+
export let speed: SpinnerProps['speed'] = 0
|
|
8
|
+
export let size: SpinnerProps['size'] = 0
|
|
9
|
+
export let dashArray: SpinnerProps['dashArray'] = 0
|
|
10
|
+
|
|
11
|
+
const classes = [
|
|
12
|
+
'w-spinner',
|
|
13
|
+
dashArray && 'dashed'
|
|
14
|
+
].filter(Boolean).join(' ')
|
|
15
|
+
|
|
16
|
+
const styles = [
|
|
17
|
+
color && `--w-spinner-color: ${color};`,
|
|
18
|
+
width && `--w-spinner-width: ${width}px;`,
|
|
19
|
+
speed && `--w-spinner-speed: ${speed}s;`,
|
|
20
|
+
size && `--w-spinner-size: ${size}px;`,
|
|
21
|
+
dashArray && `--w-spinner-dash: ${dashArray}`,
|
|
22
|
+
].filter(Boolean).join(' ')
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<svg
|
|
26
|
+
class={classes}
|
|
27
|
+
viewBox="25 25 50 50"
|
|
28
|
+
role="status"
|
|
29
|
+
style={styles}
|
|
30
|
+
>
|
|
31
|
+
<circle
|
|
32
|
+
class="spinner-path"
|
|
33
|
+
cx="50"
|
|
34
|
+
cy="50"
|
|
35
|
+
r="20"
|
|
36
|
+
fill="none"
|
|
37
|
+
/>
|
|
38
|
+
</svg>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { SpinnerProps } from './spinner'
|
|
3
|
+
|
|
4
|
+
import './spinner.scss'
|
|
5
|
+
|
|
6
|
+
const Spinner = ({
|
|
7
|
+
color,
|
|
8
|
+
width,
|
|
9
|
+
speed,
|
|
10
|
+
size,
|
|
11
|
+
dashArray
|
|
12
|
+
}: SpinnerProps) => {
|
|
13
|
+
const classes = [
|
|
14
|
+
'w-spinner',
|
|
15
|
+
dashArray && 'dashed'
|
|
16
|
+
].filter(Boolean).join(' ')
|
|
17
|
+
|
|
18
|
+
const styles = {
|
|
19
|
+
...(color && { '--w-spinner-color': color }),
|
|
20
|
+
...(width && { '--w-spinner-width': `${width}px;` }),
|
|
21
|
+
...(speed && { '--w-spinner-speed': `${speed}s;` }),
|
|
22
|
+
...(size && { '--w-spinner-size': `${size}px;` }),
|
|
23
|
+
...(dashArray && { '--w-spinner-dash': dashArray }),
|
|
24
|
+
} as React.CSSProperties
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<svg
|
|
28
|
+
className={classes}
|
|
29
|
+
viewBox="25 25 50 50"
|
|
30
|
+
role="status"
|
|
31
|
+
style={styles}
|
|
32
|
+
>
|
|
33
|
+
<circle
|
|
34
|
+
className="spinner-path"
|
|
35
|
+
cx="50"
|
|
36
|
+
cy="50"
|
|
37
|
+
r="20"
|
|
38
|
+
fill="none"
|
|
39
|
+
/>
|
|
40
|
+
</svg>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default Spinner
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
@import '../../scss/config.scss';
|
|
2
|
+
|
|
3
|
+
.w-spinner {
|
|
4
|
+
margin: 0px auto;
|
|
5
|
+
width: var(--w-spinner-size);
|
|
6
|
+
height: var(--w-spinner-size);
|
|
7
|
+
animation: rotate var(--w-spinner-speed) linear infinite;
|
|
8
|
+
|
|
9
|
+
&.dashed .spinner-path {
|
|
10
|
+
stroke-dasharray: var(--w-spinner-dash);
|
|
11
|
+
animation: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.spinner-path {
|
|
15
|
+
stroke: var(--w-spinner-color);
|
|
16
|
+
stroke-width: var(--w-spinner-width);
|
|
17
|
+
animation: dash 1.5s ease-in-out infinite;
|
|
18
|
+
stroke-linecap: round;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@keyframes rotate {
|
|
23
|
+
100% {
|
|
24
|
+
transform: rotate(360deg);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@keyframes dash {
|
|
29
|
+
0% {
|
|
30
|
+
stroke-dasharray: 1, 200;
|
|
31
|
+
stroke-dashoffset: 0;
|
|
32
|
+
}
|
|
33
|
+
50% {
|
|
34
|
+
stroke-dasharray: 89, 200;
|
|
35
|
+
stroke-dashoffset: -35;
|
|
36
|
+
}
|
|
37
|
+
100% {
|
|
38
|
+
stroke-dasharray: 89, 200;
|
|
39
|
+
stroke-dashoffset: -124;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { ReactSwitchProps } from './switch'
|
|
3
3
|
import './switch.scss'
|
|
4
4
|
|
|
5
|
-
type ReactSwitchProps = {
|
|
6
|
-
onClick?: () => any
|
|
7
|
-
} & SwitchProps
|
|
8
|
-
|
|
9
5
|
const Switch = ({
|
|
10
6
|
label,
|
|
11
7
|
toggled,
|
|
@@ -36,7 +32,7 @@ const Switch = ({
|
|
|
36
32
|
<label className={classes} style={styles || null}>
|
|
37
33
|
<input
|
|
38
34
|
type="checkbox"
|
|
39
|
-
|
|
35
|
+
defaultChecked={toggled}
|
|
40
36
|
disabled={disabled}
|
|
41
37
|
onClick={onClick}
|
|
42
38
|
/>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { TableProps } from './table'
|
|
3
|
+
import './table.scss'
|
|
4
|
+
|
|
5
|
+
interface Props extends TableProps {}
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
headings,
|
|
9
|
+
footer,
|
|
10
|
+
data,
|
|
11
|
+
hover,
|
|
12
|
+
striped,
|
|
13
|
+
offsetStripe,
|
|
14
|
+
compact,
|
|
15
|
+
className
|
|
16
|
+
} = Astro.props
|
|
17
|
+
|
|
18
|
+
const classes = [
|
|
19
|
+
'w-table',
|
|
20
|
+
hover && 'hover',
|
|
21
|
+
striped && `striped-${striped}s`,
|
|
22
|
+
offsetStripe && 'offset',
|
|
23
|
+
compact && 'compact',
|
|
24
|
+
className
|
|
25
|
+
]
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
<div class:list={classes}>
|
|
29
|
+
<table>
|
|
30
|
+
{headings?.length && (
|
|
31
|
+
<thead>
|
|
32
|
+
<tr>
|
|
33
|
+
{headings.map(heading => (
|
|
34
|
+
<th>{heading}</th>
|
|
35
|
+
))}
|
|
36
|
+
</tr>
|
|
37
|
+
</thead>
|
|
38
|
+
)}
|
|
39
|
+
<tbody>
|
|
40
|
+
{data.map(row => (
|
|
41
|
+
<tr>
|
|
42
|
+
{row.map(column => (
|
|
43
|
+
<td>
|
|
44
|
+
<Fragment set:html={column} />
|
|
45
|
+
</td>
|
|
46
|
+
))}
|
|
47
|
+
</tr>
|
|
48
|
+
))}
|
|
49
|
+
</tbody>
|
|
50
|
+
{footer?.length && (
|
|
51
|
+
<tfoot>
|
|
52
|
+
<tr>
|
|
53
|
+
{footer.map(data => (
|
|
54
|
+
<td>{data}</td>
|
|
55
|
+
))}
|
|
56
|
+
</tr>
|
|
57
|
+
</tfoot>
|
|
58
|
+
)}
|
|
59
|
+
</table>
|
|
60
|
+
</div>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { TableProps } from './table'
|
|
3
|
+
import './table.scss'
|
|
4
|
+
|
|
5
|
+
export let headings: TableProps['headings'] = []
|
|
6
|
+
export let footer: TableProps['footer'] = []
|
|
7
|
+
export let data: TableProps['data'] = []
|
|
8
|
+
export let hover: TableProps['hover'] = false
|
|
9
|
+
export let striped: TableProps['striped'] = null
|
|
10
|
+
export let offsetStripe: TableProps['offsetStripe'] = false
|
|
11
|
+
export let compact: TableProps['compact'] = false
|
|
12
|
+
export let className: TableProps['className'] = ''
|
|
13
|
+
|
|
14
|
+
const classes = [
|
|
15
|
+
'w-table',
|
|
16
|
+
hover && 'hover',
|
|
17
|
+
striped && `striped-${striped}s`,
|
|
18
|
+
offsetStripe && 'offset',
|
|
19
|
+
compact && 'compact',
|
|
20
|
+
className
|
|
21
|
+
].filter(Boolean).join(' ')
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<div class={classes}>
|
|
25
|
+
<table>
|
|
26
|
+
{#if headings?.length}
|
|
27
|
+
<thead>
|
|
28
|
+
<tr>
|
|
29
|
+
{#each headings as heading}
|
|
30
|
+
<th>{heading}</th>
|
|
31
|
+
{/each}
|
|
32
|
+
</tr>
|
|
33
|
+
</thead>
|
|
34
|
+
{/if}
|
|
35
|
+
<tbody>
|
|
36
|
+
{#each data as row}
|
|
37
|
+
<tr>
|
|
38
|
+
{#each row as column}
|
|
39
|
+
<td>{@html column}</td>
|
|
40
|
+
{/each}
|
|
41
|
+
</tr>
|
|
42
|
+
{/each}
|
|
43
|
+
</tbody>
|
|
44
|
+
{#if footer?.length}
|
|
45
|
+
<tfoot>
|
|
46
|
+
<tr>
|
|
47
|
+
{#each footer as data}
|
|
48
|
+
<td>{data}</td>
|
|
49
|
+
{/each}
|
|
50
|
+
</tr>
|
|
51
|
+
</tfoot>
|
|
52
|
+
{/if}
|
|
53
|
+
</table>
|
|
54
|
+
</div>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { TableProps } from './table'
|
|
3
|
+
|
|
4
|
+
import './table.scss'
|
|
5
|
+
|
|
6
|
+
const Table = ({
|
|
7
|
+
headings,
|
|
8
|
+
footer,
|
|
9
|
+
data,
|
|
10
|
+
hover,
|
|
11
|
+
striped,
|
|
12
|
+
offsetStripe,
|
|
13
|
+
compact,
|
|
14
|
+
className
|
|
15
|
+
}: TableProps) => {
|
|
16
|
+
const classes = [
|
|
17
|
+
'w-table',
|
|
18
|
+
hover && 'hover',
|
|
19
|
+
striped && `striped-${striped}s`,
|
|
20
|
+
offsetStripe && 'offset',
|
|
21
|
+
compact && 'compact',
|
|
22
|
+
className
|
|
23
|
+
].filter(Boolean).join(' ')
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className={classes}>
|
|
27
|
+
<table>
|
|
28
|
+
{headings?.length && (
|
|
29
|
+
<thead>
|
|
30
|
+
<tr>
|
|
31
|
+
{headings.map((heading, index) => (
|
|
32
|
+
<th key={index}>{heading}</th>
|
|
33
|
+
))}
|
|
34
|
+
</tr>
|
|
35
|
+
</thead>
|
|
36
|
+
)}
|
|
37
|
+
<tbody>
|
|
38
|
+
{data.map((row, rowIndex) => (
|
|
39
|
+
<tr key={rowIndex}>
|
|
40
|
+
{row.map((column, columnIndex) => (
|
|
41
|
+
<td
|
|
42
|
+
key={columnIndex}
|
|
43
|
+
dangerouslySetInnerHTML={{ __html: column }}
|
|
44
|
+
/>
|
|
45
|
+
))}
|
|
46
|
+
</tr>
|
|
47
|
+
))}
|
|
48
|
+
</tbody>
|
|
49
|
+
{footer?.length && (
|
|
50
|
+
<tfoot>
|
|
51
|
+
<tr>
|
|
52
|
+
{footer.map((data, index) => (
|
|
53
|
+
<td key={index}>{data}</td>
|
|
54
|
+
))}
|
|
55
|
+
</tr>
|
|
56
|
+
</tfoot>
|
|
57
|
+
)}
|
|
58
|
+
</table>
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default Table
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
@import '../../scss/config.scss';
|
|
2
|
+
|
|
3
|
+
.w-table {
|
|
4
|
+
overflow-x: auto;
|
|
5
|
+
|
|
6
|
+
table {
|
|
7
|
+
width: 100%;
|
|
8
|
+
border-collapse: collapse;
|
|
9
|
+
text-align: left;
|
|
10
|
+
font-size: 16px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
thead,
|
|
14
|
+
tfoot {
|
|
15
|
+
font-family: Bold;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
th,
|
|
19
|
+
td {
|
|
20
|
+
padding: 5px 10px;
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
thead,
|
|
25
|
+
tr {
|
|
26
|
+
border-bottom: 1px solid #252525;
|
|
27
|
+
|
|
28
|
+
&:last-child {
|
|
29
|
+
border-bottom: 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
a {
|
|
34
|
+
text-decoration: underline;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
tfoot,
|
|
38
|
+
&.hover tr:hover,
|
|
39
|
+
&.striped-rows tbody tr:nth-child(odd),
|
|
40
|
+
&.striped-rows.offset tbody tr:nth-child(even),
|
|
41
|
+
&.striped-columns td:nth-child(odd),
|
|
42
|
+
&.striped-columns.offset td:nth-child(even) {
|
|
43
|
+
background: #111;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&.striped-rows tr,
|
|
47
|
+
&.striped-rows thead,
|
|
48
|
+
&.striped-columns tr,
|
|
49
|
+
&.striped-columns thead {
|
|
50
|
+
border-bottom: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&.striped-rows.offset tbody tr:nth-child(odd),
|
|
54
|
+
&.striped-rows.offset tfoot,
|
|
55
|
+
&.striped-columns.offset td:nth-child(odd),
|
|
56
|
+
&.striped-columns tfoot {
|
|
57
|
+
background: transparent;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&.compact {
|
|
61
|
+
th, td {
|
|
62
|
+
padding: 3px 10px;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|