webcoreui 0.2.0 → 0.4.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.
- package/README.md +12 -1
- package/astro.d.ts +15 -1
- package/astro.js +14 -0
- package/components/Accordion/Accordion.astro +2 -0
- package/components/Accordion/Accordion.svelte +2 -0
- package/components/Accordion/Accordion.tsx +2 -0
- package/components/Alert/Alert.astro +3 -2
- package/components/Alert/Alert.svelte +4 -3
- package/components/Alert/Alert.tsx +7 -3
- package/components/Avatar/Avatar.astro +2 -1
- package/components/Avatar/Avatar.svelte +2 -1
- package/components/Avatar/Avatar.tsx +3 -3
- package/components/Avatar/avatar.module.scss +2 -0
- package/components/Badge/Badge.astro +1 -0
- package/components/Badge/Badge.svelte +3 -2
- package/components/Badge/Badge.tsx +2 -1
- package/components/Button/Button.astro +4 -5
- package/components/Button/Button.svelte +2 -1
- package/components/Button/Button.tsx +2 -1
- package/components/Button/button.ts +1 -1
- package/components/Card/Card.astro +11 -3
- package/components/Card/Card.svelte +5 -2
- package/components/Card/Card.tsx +5 -2
- package/components/Card/card.ts +1 -0
- package/components/Checkbox/Checkbox.astro +1 -0
- package/components/Checkbox/Checkbox.svelte +7 -5
- package/components/Checkbox/Checkbox.tsx +4 -2
- package/components/Collapsible/Collapsible.astro +64 -0
- package/components/Collapsible/Collapsible.svelte +49 -0
- package/components/Collapsible/Collapsible.tsx +55 -0
- package/components/Collapsible/collapsible.module.scss +29 -0
- package/components/Collapsible/collapsible.ts +14 -0
- package/components/ConditionalWrapper/ConditionalWrapper.astro +2 -1
- package/components/ConditionalWrapper/ConditionalWrapper.tsx +1 -2
- package/components/Group/Group.astro +22 -0
- package/components/Group/Group.svelte +20 -0
- package/components/Group/Group.tsx +22 -0
- package/components/Group/group.module.scss +43 -0
- package/components/Group/group.ts +8 -0
- package/components/Icon/map.ts +2 -0
- package/components/Input/Input.astro +8 -1
- package/components/Input/Input.svelte +15 -3
- package/components/Input/Input.tsx +10 -3
- package/components/Input/input.module.scss +4 -1
- package/components/Input/input.ts +9 -4
- package/components/List/List.astro +169 -0
- package/components/List/List.svelte +147 -0
- package/components/List/List.tsx +168 -0
- package/components/List/list.module.scss +91 -0
- package/components/List/list.ts +37 -0
- package/components/Menu/Menu.astro +2 -1
- package/components/Menu/Menu.svelte +7 -5
- package/components/Menu/Menu.tsx +116 -113
- package/components/Modal/Modal.astro +6 -4
- package/components/Modal/Modal.svelte +8 -6
- package/components/Modal/Modal.tsx +79 -76
- package/components/Modal/modal.module.scss +1 -1
- package/components/Modal/modal.ts +1 -0
- package/components/Popover/Popover.astro +26 -0
- package/components/Popover/Popover.svelte +23 -0
- package/components/Popover/Popover.tsx +55 -0
- package/components/Popover/popover.module.scss +52 -0
- package/components/Popover/popover.ts +10 -0
- package/components/Progress/Progress.astro +2 -1
- package/components/Progress/Progress.svelte +2 -1
- package/components/Progress/Progress.tsx +3 -2
- package/components/Radio/Radio.astro +1 -0
- package/components/Radio/Radio.svelte +4 -2
- package/components/Radio/Radio.tsx +3 -2
- package/components/Rating/Rating.astro +3 -1
- package/components/Rating/Rating.svelte +9 -7
- package/components/Rating/Rating.tsx +4 -2
- package/components/Select/Select.astro +135 -0
- package/components/Select/Select.svelte +122 -0
- package/components/Select/Select.tsx +142 -0
- package/components/Select/select.module.scss +25 -0
- package/components/Select/select.ts +21 -0
- package/components/Sheet/Sheet.astro +30 -0
- package/components/Sheet/Sheet.svelte +25 -0
- package/components/Sheet/Sheet.tsx +33 -0
- package/components/Sheet/sheet.module.scss +68 -0
- package/components/Sheet/sheet.ts +10 -0
- package/components/Slider/Slider.astro +2 -1
- package/components/Slider/Slider.svelte +2 -1
- package/components/Slider/Slider.tsx +49 -48
- package/components/Spinner/Spinner.astro +4 -3
- package/components/Spinner/Spinner.svelte +3 -2
- package/components/Spinner/Spinner.tsx +4 -3
- package/components/Switch/Switch.astro +2 -1
- package/components/Switch/Switch.svelte +5 -4
- package/components/Switch/Switch.tsx +2 -2
- package/components/Switch/switch.module.scss +1 -1
- package/components/Table/Table.astro +1 -0
- package/components/Table/Table.svelte +2 -1
- package/components/Table/Table.tsx +2 -1
- package/components/Tabs/Tabs.astro +2 -1
- package/components/Tabs/Tabs.svelte +2 -1
- package/components/Tabs/Tabs.tsx +4 -3
- package/components/Textarea/Textarea.astro +45 -0
- package/components/Textarea/Textarea.svelte +47 -0
- package/components/Textarea/Textarea.tsx +52 -0
- package/components/Textarea/textarea.module.scss +36 -0
- package/components/Textarea/textarea.ts +18 -0
- package/components/ThemeSwitcher/ThemeSwitcher.astro +108 -107
- package/components/ThemeSwitcher/ThemeSwitcher.svelte +5 -4
- package/components/ThemeSwitcher/ThemeSwitcher.tsx +91 -90
- package/components/Timeline/Timeline.astro +3 -2
- package/components/Timeline/Timeline.svelte +3 -2
- package/components/Timeline/Timeline.tsx +3 -2
- package/components/TimelineItem/TimelineItem.svelte +2 -1
- package/components/TimelineItem/TimelineItem.tsx +2 -1
- package/components/Toast/Toast.astro +3 -1
- package/components/Toast/Toast.svelte +14 -7
- package/components/Toast/Toast.tsx +3 -1
- package/icons/moon.svg +1 -1
- package/icons/search.svg +3 -0
- package/icons.d.ts +1 -0
- package/icons.js +1 -0
- package/index.d.ts +99 -0
- package/index.js +2 -0
- package/package.json +23 -4
- package/react.d.ts +14 -0
- package/react.js +14 -0
- package/scss/config/mixins.scss +12 -10
- package/scss/config/variables.scss +1 -0
- package/scss/config.scss +1 -0
- package/scss/global/utility.scss +2 -0
- package/svelte.d.ts +15 -1
- package/svelte.js +14 -0
- package/utils/cookies.ts +4 -4
- package/utils/debounce.ts +24 -0
- package/utils/event.ts +2 -2
- package/utils/interpolate.ts +5 -5
- package/utils/modal.ts +90 -27
- package/utils/popover.ts +223 -0
- package/utils/toast.ts +6 -8
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
@import '../../scss/config.scss';
|
|
2
|
+
|
|
3
|
+
.sheet {
|
|
4
|
+
@include position(t0, 'r-100%', lauto);
|
|
5
|
+
@include visibility(1);
|
|
6
|
+
@include border-radius(none);
|
|
7
|
+
@include size(100%);
|
|
8
|
+
@include border(0);
|
|
9
|
+
@include border(left, primary-50);
|
|
10
|
+
|
|
11
|
+
transform: none;
|
|
12
|
+
|
|
13
|
+
&[data-show="true"] {
|
|
14
|
+
@include position(r0);
|
|
15
|
+
|
|
16
|
+
transform: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.left {
|
|
20
|
+
@include position('l-100%', rauto);
|
|
21
|
+
@include border(0);
|
|
22
|
+
@include border(right, primary-50);
|
|
23
|
+
|
|
24
|
+
&[data-show="true"] {
|
|
25
|
+
@include position(l0);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.top {
|
|
30
|
+
@include position(t0, l0);
|
|
31
|
+
@include size(hauto);
|
|
32
|
+
@include border(0);
|
|
33
|
+
@include border(bottom, primary-50);
|
|
34
|
+
|
|
35
|
+
transform: translateY(-100%);
|
|
36
|
+
min-width: 100%;
|
|
37
|
+
|
|
38
|
+
&[data-show="true"] {
|
|
39
|
+
transform: translateY(0);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&.bottom {
|
|
44
|
+
@include position(b0, l0);
|
|
45
|
+
@include size(hauto);
|
|
46
|
+
@include border(0);
|
|
47
|
+
@include border(top, primary-50);
|
|
48
|
+
|
|
49
|
+
transform: translateY(100%);
|
|
50
|
+
top: auto;
|
|
51
|
+
min-width: 100%;
|
|
52
|
+
|
|
53
|
+
&[data-show="true"] {
|
|
54
|
+
transform: translateY(0);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@include media(xs) {
|
|
60
|
+
.sheet {
|
|
61
|
+
@include position(r-500px);
|
|
62
|
+
@include size(w500px);
|
|
63
|
+
|
|
64
|
+
&.left {
|
|
65
|
+
@include position(l-500px);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { SvelteSliderProps } from './slider'
|
|
3
3
|
|
|
4
|
-
import styles from './slider.module.scss'
|
|
5
4
|
import { classNames } from '../../utils/classNames'
|
|
6
5
|
|
|
6
|
+
import styles from './slider.module.scss'
|
|
7
|
+
|
|
7
8
|
export let min: SvelteSliderProps['min'] = 0
|
|
8
9
|
export let max: SvelteSliderProps['max'] = 100
|
|
9
10
|
export let value: SvelteSliderProps['value'] = 0
|
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import type { ReactSliderProps } from './slider'
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
...(
|
|
28
|
-
...(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { ReactSliderProps } from './slider'
|
|
3
|
+
|
|
4
|
+
import { classNames } from '../../utils/classNames'
|
|
5
|
+
|
|
6
|
+
import styles from './slider.module.scss'
|
|
7
|
+
|
|
8
|
+
const Slider = ({
|
|
9
|
+
min,
|
|
10
|
+
max,
|
|
11
|
+
value,
|
|
12
|
+
step,
|
|
13
|
+
disabled,
|
|
14
|
+
color,
|
|
15
|
+
background,
|
|
16
|
+
thumb,
|
|
17
|
+
id,
|
|
18
|
+
className,
|
|
19
|
+
onChange
|
|
20
|
+
}: ReactSliderProps) => {
|
|
21
|
+
const classes = classNames([
|
|
22
|
+
styles.slider,
|
|
23
|
+
className
|
|
24
|
+
])
|
|
25
|
+
|
|
26
|
+
const styleVariables = {
|
|
27
|
+
...(color && { '--w-slider-color': color }),
|
|
28
|
+
...(background && { '--w-slider-background': background }),
|
|
29
|
+
...(thumb && { '--w-slider-thumb': thumb })
|
|
30
|
+
} as React.CSSProperties
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<input
|
|
34
|
+
type="range"
|
|
35
|
+
min={min}
|
|
36
|
+
max={max}
|
|
37
|
+
defaultValue={value || min}
|
|
38
|
+
step={step}
|
|
39
|
+
disabled={disabled}
|
|
40
|
+
className={classes}
|
|
41
|
+
id={id}
|
|
42
|
+
style={styleVariables}
|
|
43
|
+
onChange={onChange}
|
|
44
|
+
/>
|
|
45
|
+
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default Slider
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { SpinnerProps } from './spinner'
|
|
3
3
|
|
|
4
|
-
import styles from './spinner.module.scss'
|
|
5
4
|
import { classNames } from '../../utils/classNames'
|
|
6
5
|
|
|
6
|
+
import styles from './spinner.module.scss'
|
|
7
|
+
|
|
7
8
|
interface Props extends SpinnerProps {}
|
|
8
9
|
|
|
9
10
|
const {
|
|
@@ -11,7 +12,7 @@ const {
|
|
|
11
12
|
width,
|
|
12
13
|
speed,
|
|
13
14
|
size,
|
|
14
|
-
dashArray
|
|
15
|
+
dashArray
|
|
15
16
|
} = Astro.props
|
|
16
17
|
|
|
17
18
|
const classes = [
|
|
@@ -24,7 +25,7 @@ const styleVariables = classNames([
|
|
|
24
25
|
width && `--w-spinner-width: ${width}px;`,
|
|
25
26
|
speed && `--w-spinner-speed: ${speed}s;`,
|
|
26
27
|
size && `--w-spinner-size: ${size}px;`,
|
|
27
|
-
dashArray && `--w-spinner-dash: ${dashArray}
|
|
28
|
+
dashArray && `--w-spinner-dash: ${dashArray}`
|
|
28
29
|
])
|
|
29
30
|
---
|
|
30
31
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { SpinnerProps } from './spinner'
|
|
3
3
|
|
|
4
|
-
import styles from './spinner.module.scss'
|
|
5
4
|
import { classNames } from '../../utils/classNames'
|
|
6
5
|
|
|
6
|
+
import styles from './spinner.module.scss'
|
|
7
|
+
|
|
7
8
|
export let color: SpinnerProps['color'] = ''
|
|
8
9
|
export let width: SpinnerProps['width'] = 0
|
|
9
10
|
export let speed: SpinnerProps['speed'] = 0
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
width && `--w-spinner-width: ${width}px;`,
|
|
21
22
|
speed && `--w-spinner-speed: ${speed}s;`,
|
|
22
23
|
size && `--w-spinner-size: ${size}px;`,
|
|
23
|
-
dashArray && `--w-spinner-dash: ${dashArray}
|
|
24
|
+
dashArray && `--w-spinner-dash: ${dashArray}`
|
|
24
25
|
])
|
|
25
26
|
</script>
|
|
26
27
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import type { SpinnerProps } from './spinner'
|
|
3
3
|
|
|
4
|
-
import styles from './spinner.module.scss'
|
|
5
4
|
import { classNames } from '../../utils/classNames'
|
|
6
5
|
|
|
6
|
+
import styles from './spinner.module.scss'
|
|
7
|
+
|
|
7
8
|
const Spinner = ({
|
|
8
9
|
color,
|
|
9
10
|
width,
|
|
@@ -15,13 +16,13 @@ const Spinner = ({
|
|
|
15
16
|
styles.spinner,
|
|
16
17
|
dashArray && styles.dashed
|
|
17
18
|
])
|
|
18
|
-
|
|
19
|
+
|
|
19
20
|
const stylesVariable = {
|
|
20
21
|
...(color && { '--w-spinner-color': color }),
|
|
21
22
|
...(width && { '--w-spinner-width': `${width}px;` }),
|
|
22
23
|
...(speed && { '--w-spinner-speed': `${speed}s;` }),
|
|
23
24
|
...(size && { '--w-spinner-size': `${size}px;` }),
|
|
24
|
-
...(dashArray && { '--w-spinner-dash': dashArray })
|
|
25
|
+
...(dashArray && { '--w-spinner-dash': dashArray })
|
|
25
26
|
} as React.CSSProperties
|
|
26
27
|
|
|
27
28
|
return (
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { SvelteSwitchProps } from './switch'
|
|
3
3
|
|
|
4
|
-
import styles from './switch.module.scss'
|
|
5
4
|
import { classNames } from '../../utils/classNames'
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
import styles from './switch.module.scss'
|
|
7
|
+
|
|
7
8
|
export let label: SvelteSwitchProps['label'] = ''
|
|
8
9
|
export let toggled: SvelteSwitchProps['toggled'] = false
|
|
9
10
|
export let offColor: SvelteSwitchProps['offColor'] = ''
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
export let disabled: SvelteSwitchProps['disabled'] = false
|
|
15
16
|
export let className: SvelteSwitchProps['className'] = ''
|
|
16
17
|
export let onClick: SvelteSwitchProps['onClick'] = () => {}
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
const classes = classNames([
|
|
19
20
|
styles.switch,
|
|
20
21
|
reverse && styles.reverse,
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
disabled && styles.disabled,
|
|
24
25
|
className
|
|
25
26
|
])
|
|
26
|
-
|
|
27
|
+
|
|
27
28
|
const styleVariables = classNames([
|
|
28
29
|
offColor && `--w-switch-off-color: ${offColor};`,
|
|
29
30
|
onColor && `--w-switch-on-color: ${onColor};`
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import type { ReactSwitchProps } from './switch'
|
|
3
3
|
|
|
4
|
-
import styles from './switch.module.scss'
|
|
5
4
|
import { classNames } from '../../utils/classNames'
|
|
6
5
|
|
|
6
|
+
import styles from './switch.module.scss'
|
|
7
|
+
|
|
7
8
|
const Switch = ({
|
|
8
9
|
label,
|
|
9
10
|
toggled,
|
|
@@ -42,7 +43,6 @@ const Switch = ({
|
|
|
42
43
|
{label && <span className={styles.label}>{label}</span>}
|
|
43
44
|
</label>
|
|
44
45
|
)
|
|
45
|
-
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export default Switch
|
|
@@ -68,13 +68,13 @@ body {
|
|
|
68
68
|
@include background(var(--w-switch-off-color));
|
|
69
69
|
|
|
70
70
|
&::before {
|
|
71
|
+
@include transition(transform);
|
|
71
72
|
@include position(absolute, l3px, b3px);
|
|
72
73
|
@include size(24px);
|
|
73
74
|
@include border-radius(max);
|
|
74
75
|
@include background(primary-70);
|
|
75
76
|
|
|
76
77
|
content: '';
|
|
77
|
-
transition: 0.3s;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { TableProps } from './table'
|
|
3
3
|
|
|
4
|
-
import styles from './table.module.scss'
|
|
5
4
|
import { classNames } from '../../utils/classNames'
|
|
6
5
|
|
|
6
|
+
import styles from './table.module.scss'
|
|
7
|
+
|
|
7
8
|
export let headings: TableProps['headings'] = []
|
|
8
9
|
export let footer: TableProps['footer'] = []
|
|
9
10
|
export let data: TableProps['data'] = []
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { TabsProps } from './tabs'
|
|
3
|
+
|
|
3
4
|
import styles from './tabs.module.scss'
|
|
4
5
|
|
|
5
6
|
interface Props extends TabsProps {}
|
|
@@ -59,7 +60,7 @@ const classes = [
|
|
|
59
60
|
} else {
|
|
60
61
|
element.dataset.active = false
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
+
})
|
|
63
64
|
|
|
64
65
|
const tabs = target.parentElement?.querySelectorAll('button') as NodeListOf<HTMLButtonElement>
|
|
65
66
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { TabsProps } from './tabs'
|
|
3
3
|
|
|
4
|
-
import styles from './tabs.module.scss'
|
|
5
4
|
import { classNames } from '../../utils/classNames'
|
|
6
5
|
|
|
6
|
+
import styles from './tabs.module.scss'
|
|
7
|
+
|
|
7
8
|
export let items: TabsProps['items'] = []
|
|
8
9
|
export let theme: TabsProps['theme'] = null
|
|
9
10
|
export let vertical: TabsProps['vertical'] = false
|
package/components/Tabs/Tabs.tsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React, { useState
|
|
1
|
+
import React, { useRef,useState } from 'react'
|
|
2
2
|
import type { ReactTabsProps } from './tabs'
|
|
3
3
|
|
|
4
|
-
import styles from './tabs.module.scss'
|
|
5
4
|
import { classNames } from '../../utils/classNames'
|
|
6
5
|
|
|
6
|
+
import styles from './tabs.module.scss'
|
|
7
|
+
|
|
7
8
|
const Tabs = ({
|
|
8
9
|
items,
|
|
9
10
|
theme,
|
|
@@ -33,7 +34,7 @@ const Tabs = ({
|
|
|
33
34
|
item.dataset.active = true
|
|
34
35
|
}
|
|
35
36
|
})
|
|
36
|
-
|
|
37
|
+
|
|
37
38
|
setActive(tab)
|
|
38
39
|
}
|
|
39
40
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { TextareaProps } from './textarea'
|
|
3
|
+
|
|
4
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.astro'
|
|
5
|
+
|
|
6
|
+
import styles from './textarea.module.scss'
|
|
7
|
+
|
|
8
|
+
interface Props extends TextareaProps {}
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
label,
|
|
12
|
+
placeholder,
|
|
13
|
+
subText,
|
|
14
|
+
value = '',
|
|
15
|
+
disabled,
|
|
16
|
+
className
|
|
17
|
+
} = Astro.props
|
|
18
|
+
|
|
19
|
+
const classes = [
|
|
20
|
+
styles.textarea,
|
|
21
|
+
className
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
const useLabel = !!(label || subText)
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<ConditionalWrapper condition={useLabel}>
|
|
28
|
+
<label slot="wrapper" class={styles['label-wrapper']}>
|
|
29
|
+
{label && (
|
|
30
|
+
<div class={styles.label}>{label}</div>
|
|
31
|
+
)}
|
|
32
|
+
children
|
|
33
|
+
{subText && (
|
|
34
|
+
<div class={styles.subtext}>
|
|
35
|
+
<Fragment set:html={subText} />
|
|
36
|
+
</div>
|
|
37
|
+
)}
|
|
38
|
+
</label>
|
|
39
|
+
|
|
40
|
+
<textarea
|
|
41
|
+
placeholder={placeholder}
|
|
42
|
+
disabled={disabled}
|
|
43
|
+
class:list={classes}
|
|
44
|
+
>{value}</textarea>
|
|
45
|
+
</ConditionalWrapper>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SvelteTextareaProps } from './textarea'
|
|
3
|
+
|
|
4
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
|
|
5
|
+
|
|
6
|
+
import { classNames } from '../../utils/classNames'
|
|
7
|
+
|
|
8
|
+
import styles from './textarea.module.scss'
|
|
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'] = () => {}
|
|
18
|
+
|
|
19
|
+
const classes = classNames([
|
|
20
|
+
styles.textarea,
|
|
21
|
+
className
|
|
22
|
+
])
|
|
23
|
+
|
|
24
|
+
const useLabel = !!(label || subText)
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<ConditionalWrapper
|
|
28
|
+
condition={useLabel}
|
|
29
|
+
element="label"
|
|
30
|
+
class={styles['label-wrapper']}
|
|
31
|
+
>
|
|
32
|
+
{#if label}
|
|
33
|
+
<div class={styles.label}>{label}</div>
|
|
34
|
+
{/if}
|
|
35
|
+
<textarea
|
|
36
|
+
placeholder={placeholder}
|
|
37
|
+
disabled={disabled}
|
|
38
|
+
class={classes}
|
|
39
|
+
on:change={onChange}
|
|
40
|
+
on:keyup={onKeyUp}
|
|
41
|
+
>{value}</textarea>
|
|
42
|
+
{#if subText}
|
|
43
|
+
<div class={styles.subtext}>
|
|
44
|
+
{@html subText}
|
|
45
|
+
</div>
|
|
46
|
+
{/if}
|
|
47
|
+
</ConditionalWrapper>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { ReactTextareaProps } from './textarea'
|
|
3
|
+
|
|
4
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
|
|
5
|
+
|
|
6
|
+
import { classNames } from '../../utils/classNames'
|
|
7
|
+
|
|
8
|
+
import styles from './textarea.module.scss'
|
|
9
|
+
|
|
10
|
+
const Textarea = ({
|
|
11
|
+
label,
|
|
12
|
+
placeholder,
|
|
13
|
+
subText,
|
|
14
|
+
value = '',
|
|
15
|
+
disabled,
|
|
16
|
+
className,
|
|
17
|
+
...rest
|
|
18
|
+
}: ReactTextareaProps) => {
|
|
19
|
+
const classes = classNames([
|
|
20
|
+
styles.textarea,
|
|
21
|
+
className
|
|
22
|
+
])
|
|
23
|
+
|
|
24
|
+
const useLabel = !!(label || subText)
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<ConditionalWrapper condition={useLabel} wrapper={children => (
|
|
28
|
+
<label className={styles['label-wrapper']}>
|
|
29
|
+
{label && (
|
|
30
|
+
<div className={styles.label}>{label}</div>
|
|
31
|
+
)}
|
|
32
|
+
{children}
|
|
33
|
+
{subText && (
|
|
34
|
+
<div
|
|
35
|
+
className={styles.subtext}
|
|
36
|
+
dangerouslySetInnerHTML={{ __html: subText }}
|
|
37
|
+
/>
|
|
38
|
+
)}
|
|
39
|
+
</label>
|
|
40
|
+
)}>
|
|
41
|
+
<textarea
|
|
42
|
+
placeholder={placeholder}
|
|
43
|
+
disabled={disabled}
|
|
44
|
+
className={classes}
|
|
45
|
+
defaultValue={value}
|
|
46
|
+
{...rest}
|
|
47
|
+
/>
|
|
48
|
+
</ConditionalWrapper>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default Textarea
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@import '../../scss/config.scss';
|
|
2
|
+
|
|
3
|
+
.textarea {
|
|
4
|
+
@include size('w100%');
|
|
5
|
+
@include background(transparent);
|
|
6
|
+
@include border-radius(sm);
|
|
7
|
+
@include border(primary-50);
|
|
8
|
+
@include spacing(p-sm);
|
|
9
|
+
@include typography(regular, primary, hlg);
|
|
10
|
+
|
|
11
|
+
min-height: 50px;
|
|
12
|
+
resize: vertical;
|
|
13
|
+
|
|
14
|
+
&[disabled] {
|
|
15
|
+
@include typography(primary-30);
|
|
16
|
+
cursor: no-drop;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&::placeholder {
|
|
20
|
+
@include typography(primary-30);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.label-wrapper {
|
|
25
|
+
@include layout(flex, column);
|
|
26
|
+
|
|
27
|
+
.label {
|
|
28
|
+
@include typography(primary-20);
|
|
29
|
+
@include spacing(mb-xs);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.subtext {
|
|
33
|
+
@include typography(md, primary-30);
|
|
34
|
+
@include spacing(mt-xs);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type TextareaProps = {
|
|
2
|
+
label?: string
|
|
3
|
+
placeholder?: string
|
|
4
|
+
subText?: string
|
|
5
|
+
value?: string
|
|
6
|
+
disabled?: boolean
|
|
7
|
+
className?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type SvelteTextareaProps = {
|
|
11
|
+
onChange?: (e: any) => any
|
|
12
|
+
onKeyUp?: (e: any) => any
|
|
13
|
+
} & TextareaProps
|
|
14
|
+
|
|
15
|
+
export type ReactTextareaProps = {
|
|
16
|
+
onChange?: (e: any) => any
|
|
17
|
+
onKeyUp?: (e: any) => any
|
|
18
|
+
} & TextareaProps
|