webcoreui 0.0.11 → 0.0.12
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 +33 -7
- package/astro.d.ts +4 -0
- package/astro.js +4 -0
- package/components/Accordion/Accordion.astro +10 -8
- package/components/Accordion/Accordion.svelte +8 -8
- package/components/Accordion/Accordion.tsx +7 -6
- package/components/Accordion/{accordion.scss → accordion.module.scss} +18 -10
- package/components/Alert/Alert.astro +11 -7
- package/components/Alert/Alert.svelte +9 -7
- package/components/Alert/Alert.tsx +11 -7
- package/components/Alert/alert.module.scss +54 -0
- package/components/Alert/alert.ts +3 -1
- package/components/Avatar/Avatar.astro +4 -4
- package/components/Avatar/Avatar.svelte +13 -7
- package/components/Avatar/Avatar.tsx +11 -9
- package/components/Avatar/{avatar.scss → avatar.module.scss} +2 -2
- package/components/Badge/Badge.astro +8 -8
- package/components/Badge/Badge.svelte +25 -13
- package/components/Badge/Badge.tsx +26 -8
- package/components/Badge/badge.module.scss +89 -0
- package/components/Badge/badge.ts +8 -1
- package/components/Button/Button.astro +10 -6
- package/components/Button/Button.svelte +15 -11
- package/components/Button/Button.tsx +11 -7
- package/components/Button/button.module.scss +94 -0
- package/components/Button/button.ts +6 -1
- package/components/Card/Card.astro +7 -15
- package/components/Card/Card.svelte +16 -13
- package/components/Card/Card.tsx +15 -11
- package/components/Card/card.module.scss +33 -0
- package/components/Checkbox/Checkbox.astro +10 -10
- package/components/Checkbox/Checkbox.svelte +19 -18
- package/components/Checkbox/Checkbox.tsx +12 -11
- package/components/Checkbox/{checkbox.scss → checkbox.module.scss} +16 -17
- package/components/Checkbox/checkbox.ts +5 -1
- package/components/ConditionalWrapper/ConditionalWrapper.svelte +1 -1
- package/components/Icon/Icon.svelte +1 -8
- package/components/Icon/Icon.tsx +1 -8
- package/components/Icon/map.ts +23 -0
- package/components/Input/Input.astro +50 -52
- package/components/Input/Input.svelte +52 -52
- package/components/Input/Input.tsx +59 -59
- package/components/Input/{input.scss → input.module.scss} +87 -83
- package/components/Input/input.ts +8 -2
- package/components/Menu/Menu.astro +107 -0
- package/components/Menu/Menu.svelte +88 -0
- package/components/Menu/Menu.tsx +107 -0
- package/components/Menu/menu.module.scss +144 -0
- package/components/Menu/menu.ts +21 -0
- package/components/Progress/Progress.astro +42 -40
- package/components/Progress/Progress.svelte +40 -38
- package/components/Progress/Progress.tsx +48 -47
- package/components/Progress/{progress.scss → progress.module.scss} +66 -66
- package/components/Radio/Radio.astro +57 -57
- package/components/Radio/Radio.svelte +58 -56
- package/components/Radio/Radio.tsx +69 -68
- package/components/Radio/{radio.scss → radio.module.scss} +92 -92
- package/components/Radio/radio.ts +4 -0
- package/components/Rating/Rating.astro +13 -10
- package/components/Rating/Rating.svelte +15 -15
- package/components/Rating/Rating.tsx +22 -11
- package/components/Rating/{rating.scss → rating.module.scss} +10 -9
- package/components/Rating/rating.ts +1 -1
- package/components/Spinner/Spinner.astro +44 -42
- package/components/Spinner/Spinner.svelte +40 -38
- package/components/Spinner/Spinner.tsx +45 -44
- package/components/Spinner/{spinner.scss → spinner.module.scss} +41 -41
- package/components/Switch/Switch.astro +13 -11
- package/components/Switch/Switch.svelte +26 -24
- package/components/Switch/Switch.tsx +14 -12
- package/components/Switch/{switch.scss → switch.module.scss} +4 -4
- package/components/Switch/switch.ts +8 -4
- package/components/Table/Table.astro +60 -60
- package/components/Table/Table.svelte +56 -54
- package/components/Table/Table.tsx +64 -63
- package/components/Table/{table.scss → table.module.scss} +64 -65
- package/components/Tabs/Tabs.astro +77 -76
- package/components/Tabs/Tabs.svelte +56 -54
- package/components/Tabs/Tabs.tsx +70 -69
- package/components/Tabs/{tabs.scss → tabs.module.scss} +30 -31
- package/components/ThemeSwitcher/ThemeSwitcher.astro +106 -0
- package/components/ThemeSwitcher/ThemeSwitcher.svelte +76 -0
- package/components/ThemeSwitcher/ThemeSwitcher.tsx +89 -0
- package/components/ThemeSwitcher/themeswitcher.module.scss +74 -0
- package/components/ThemeSwitcher/themeswitcher.ts +13 -0
- package/components/Timeline/Timeline.astro +36 -34
- package/components/Timeline/Timeline.svelte +32 -30
- package/components/Timeline/Timeline.tsx +38 -37
- package/components/Timeline/{timeline.scss → timeline.module.scss} +71 -71
- package/components/TimelineItem/TimelineItem.astro +27 -26
- package/components/TimelineItem/TimelineItem.svelte +24 -22
- package/components/TimelineItem/TimelineItem.tsx +33 -32
- package/components/TimelineItem/{timelineitem.scss → timelineitem.module.scss} +31 -31
- package/components/Toast/Toast.astro +41 -30
- package/components/Toast/Toast.svelte +32 -21
- package/components/Toast/Toast.tsx +38 -28
- package/components/Toast/{toast.scss → toast.module.scss} +44 -43
- package/components/Toast/toast.ts +3 -6
- package/icons/moon.svg +3 -0
- package/icons/sun.svg +3 -0
- package/index.js +3 -0
- package/package.json +3 -1
- package/react.d.ts +4 -0
- package/react.js +4 -0
- package/scss/global/elements.scss +1 -1
- package/scss/global/scrollbar.scss +21 -0
- package/scss/global/theme.scss +140 -0
- package/scss/global/tooltip.scss +8 -5
- package/scss/global/utility.scss +29 -0
- package/scss/global.scss +2 -0
- package/scss/resets.scss +5 -5
- package/scss/setup.scss +39 -18
- package/svelte.d.ts +16 -12
- package/svelte.js +4 -0
- package/utils/classNames.ts +4 -0
- package/utils/cookies.ts +28 -0
- package/utils/event.ts +17 -0
- package/utils/toast.ts +12 -9
- package/components/Alert/alert.scss +0 -53
- package/components/Badge/badge.scss +0 -85
- package/components/Button/button.scss +0 -91
- package/components/Card/card.scss +0 -37
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { SvelteCheckboxProps } from './checkbox'
|
|
3
3
|
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
|
|
4
4
|
|
|
5
5
|
import check from '../../icons/check.svg?raw'
|
|
6
6
|
|
|
7
|
-
import './checkbox.scss'
|
|
7
|
+
import styles from './checkbox.module.scss'
|
|
8
|
+
import { classNames } from '../../utils/classNames'
|
|
8
9
|
|
|
9
|
-
export let checked:
|
|
10
|
-
export let label:
|
|
11
|
-
export let subText:
|
|
12
|
-
export let disabled:
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
15
|
-
export let onClick:
|
|
10
|
+
export let checked: SvelteCheckboxProps['checked'] = false
|
|
11
|
+
export let label: SvelteCheckboxProps['label'] = ''
|
|
12
|
+
export let subText: SvelteCheckboxProps['subText'] = ''
|
|
13
|
+
export let disabled: SvelteCheckboxProps['disabled'] = false
|
|
14
|
+
export let color: SvelteCheckboxProps['color'] = ''
|
|
15
|
+
export let className: SvelteCheckboxProps['className'] = ''
|
|
16
|
+
export let onClick: SvelteCheckboxProps['onClick'] = () => {}
|
|
16
17
|
|
|
17
|
-
const classes = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
]
|
|
18
|
+
const classes = classNames([
|
|
19
|
+
styles.checkbox,
|
|
20
|
+
label && subText && styles.col,
|
|
21
|
+
className
|
|
22
|
+
])
|
|
22
23
|
|
|
23
24
|
const style = color
|
|
24
25
|
? `--w-checkbox-color: ${color};`
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
<ConditionalWrapper
|
|
30
31
|
condition={!!(label && subText)}
|
|
31
32
|
element="div"
|
|
32
|
-
class=
|
|
33
|
+
class={styles.wrapper}
|
|
33
34
|
>
|
|
34
35
|
<input
|
|
35
36
|
type="checkbox"
|
|
@@ -37,16 +38,16 @@
|
|
|
37
38
|
disabled={disabled}
|
|
38
39
|
on:click={onClick}
|
|
39
40
|
/>
|
|
40
|
-
<span class=
|
|
41
|
+
<span class={styles.check}>
|
|
41
42
|
{@html check}
|
|
42
43
|
</span>
|
|
43
44
|
{#if label}
|
|
44
|
-
<span class=
|
|
45
|
+
<span class={styles.label}>
|
|
45
46
|
{@html label}
|
|
46
47
|
</span>
|
|
47
48
|
{/if}
|
|
48
49
|
</ConditionalWrapper>
|
|
49
50
|
{#if label && subText}
|
|
50
|
-
<span class=
|
|
51
|
+
<span class={styles.text}>{@html subText}</span>
|
|
51
52
|
{/if}
|
|
52
53
|
</label>
|
|
@@ -4,22 +4,23 @@ import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
|
|
|
4
4
|
|
|
5
5
|
import check from '../../icons/check.svg?raw'
|
|
6
6
|
|
|
7
|
-
import './checkbox.scss'
|
|
7
|
+
import styles from './checkbox.module.scss'
|
|
8
|
+
import { classNames } from '../../utils/classNames'
|
|
8
9
|
|
|
9
10
|
const Checkbox = ({
|
|
10
11
|
checked,
|
|
11
12
|
label,
|
|
12
13
|
subText,
|
|
13
14
|
disabled,
|
|
14
|
-
boxed,
|
|
15
15
|
color,
|
|
16
|
+
className,
|
|
16
17
|
onClick
|
|
17
18
|
}: ReactCheckboxProps) => {
|
|
18
|
-
const classes = [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
]
|
|
19
|
+
const classes = classNames([
|
|
20
|
+
styles.checkbox,
|
|
21
|
+
label && subText && styles.col,
|
|
22
|
+
className
|
|
23
|
+
])
|
|
23
24
|
|
|
24
25
|
const style = color
|
|
25
26
|
? { '--w-checkbox-color': color } as React.CSSProperties
|
|
@@ -30,7 +31,7 @@ const Checkbox = ({
|
|
|
30
31
|
<ConditionalWrapper
|
|
31
32
|
condition={!!(label && subText)}
|
|
32
33
|
wrapper={children => (
|
|
33
|
-
<div className=
|
|
34
|
+
<div className={styles.wrapper}>
|
|
34
35
|
{children}
|
|
35
36
|
</div>
|
|
36
37
|
)}
|
|
@@ -42,19 +43,19 @@ const Checkbox = ({
|
|
|
42
43
|
onClick={onClick}
|
|
43
44
|
/>
|
|
44
45
|
<span
|
|
45
|
-
className=
|
|
46
|
+
className={styles.check}
|
|
46
47
|
dangerouslySetInnerHTML={{ __html: check }}
|
|
47
48
|
/>
|
|
48
49
|
{label && (
|
|
49
50
|
<span
|
|
50
|
-
className=
|
|
51
|
+
className={styles.label}
|
|
51
52
|
dangerouslySetInnerHTML={{ __html: label }}
|
|
52
53
|
/>
|
|
53
54
|
)}
|
|
54
55
|
</ConditionalWrapper>
|
|
55
56
|
{label && subText && (
|
|
56
57
|
<span
|
|
57
|
-
className=
|
|
58
|
+
className={styles.text}
|
|
58
59
|
dangerouslySetInnerHTML={{ __html: subText }}
|
|
59
60
|
/>
|
|
60
61
|
)}
|
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
@import '../../scss/config.scss';
|
|
2
2
|
|
|
3
|
-
.
|
|
3
|
+
.checkbox {
|
|
4
4
|
cursor: pointer;
|
|
5
5
|
display: inline-flex;
|
|
6
6
|
align-items: center;
|
|
7
7
|
gap: 10px;
|
|
8
8
|
font-size: 16px;
|
|
9
|
+
line-height: 1.5;
|
|
9
10
|
|
|
10
11
|
&.col {
|
|
11
12
|
flex-direction: column;
|
|
12
13
|
align-items: flex-start;
|
|
13
14
|
justify-content: flex-start;
|
|
14
|
-
gap:
|
|
15
|
+
gap: 0;
|
|
15
16
|
|
|
16
|
-
.
|
|
17
|
+
.wrapper {
|
|
17
18
|
display: flex;
|
|
18
|
-
align-items: center;
|
|
19
19
|
gap: 10px;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
.check {
|
|
22
|
+
margin-top: 5px;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
input {
|
|
@@ -38,15 +36,15 @@
|
|
|
38
36
|
left: 50%;
|
|
39
37
|
transform: translate(-50%, -50%);
|
|
40
38
|
display: block;
|
|
41
|
-
color:
|
|
39
|
+
color: var(--w-color-primary-50);
|
|
42
40
|
width: 10px;
|
|
43
41
|
height: 10px;
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
&:disabled + span {
|
|
48
|
-
background-color:
|
|
49
|
-
border-color:
|
|
46
|
+
background-color: var(--w-color-primary-40);
|
|
47
|
+
border-color: var(--w-color-primary-40);
|
|
50
48
|
cursor: no-drop;
|
|
51
49
|
}
|
|
52
50
|
}
|
|
@@ -59,6 +57,7 @@
|
|
|
59
57
|
display: inline-block;
|
|
60
58
|
width: 15px;
|
|
61
59
|
height: 15px;
|
|
60
|
+
min-width: 15px;
|
|
62
61
|
border: 1px solid var(--w-checkbox-color);
|
|
63
62
|
border-radius: 2px;
|
|
64
63
|
position: relative;
|
|
@@ -68,17 +67,17 @@
|
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
.
|
|
70
|
+
.text {
|
|
72
71
|
margin-left: 25px;
|
|
73
72
|
font-size: 14px;
|
|
74
|
-
color:
|
|
73
|
+
color: var(--w-color-primary-20);
|
|
75
74
|
|
|
76
75
|
a {
|
|
77
76
|
@include Transition(color);
|
|
78
|
-
color:
|
|
77
|
+
color: var(--w-color-primary-20);
|
|
79
78
|
|
|
80
79
|
&:hover {
|
|
81
|
-
color:
|
|
80
|
+
color: var(--w-color-primary);
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
83
|
}
|
|
@@ -3,10 +3,14 @@ export type CheckboxProps = {
|
|
|
3
3
|
label?: string
|
|
4
4
|
subText?: string
|
|
5
5
|
disabled?: boolean
|
|
6
|
-
boxed?: boolean
|
|
7
6
|
color?: string
|
|
7
|
+
className?: string
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export type SvelteCheckboxProps = {
|
|
11
|
+
onClick?: (key: any) => any
|
|
12
|
+
} & CheckboxProps
|
|
13
|
+
|
|
10
14
|
export type ReactCheckboxProps = {
|
|
11
15
|
onClick?: (key: any) => any
|
|
12
16
|
} & CheckboxProps
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { IconProps } from './icon'
|
|
3
|
-
|
|
4
|
-
import Github from '../../icons/github.svg?raw'
|
|
5
|
-
import ArrowDown from '../../icons/arrow-down.svg?raw'
|
|
3
|
+
import iconMap from './map'
|
|
6
4
|
|
|
7
5
|
export let type: IconProps['type'] = ''
|
|
8
6
|
export let size: IconProps['size'] = 24
|
|
9
7
|
export let color: IconProps['color'] = ''
|
|
10
8
|
|
|
11
|
-
const iconMap = {
|
|
12
|
-
'github': Github,
|
|
13
|
-
'arrow-down': ArrowDown
|
|
14
|
-
}
|
|
15
|
-
|
|
16
9
|
const icon = iconMap[type as keyof typeof iconMap]
|
|
17
10
|
.replace('width="24"', `width=${size}`)
|
|
18
11
|
.replace('height="24"', color
|
package/components/Icon/Icon.tsx
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import type { IconProps } from './icon'
|
|
3
|
-
|
|
4
|
-
import Github from '../../icons/github.svg?raw'
|
|
5
|
-
import ArrowDown from '../../icons/arrow-down.svg?raw'
|
|
6
|
-
|
|
7
|
-
const iconMap = {
|
|
8
|
-
'github': Github,
|
|
9
|
-
'arrow-down': ArrowDown
|
|
10
|
-
}
|
|
3
|
+
import iconMap from './map'
|
|
11
4
|
|
|
12
5
|
const Icon = ({
|
|
13
6
|
type,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Alert from '../../icons/alert.svg?raw'
|
|
2
|
+
import ArrowDown from '../../icons/arrow-down.svg?raw'
|
|
3
|
+
import Check from '../../icons/check.svg?raw'
|
|
4
|
+
import CircleCheck from '../../icons/circle-check.svg?raw'
|
|
5
|
+
import Github from '../../icons/github.svg?raw'
|
|
6
|
+
import Info from '../../icons/info.svg?raw'
|
|
7
|
+
import Moon from '../../icons/moon.svg?raw'
|
|
8
|
+
import Sun from '../../icons/sun.svg?raw'
|
|
9
|
+
import Warning from '../../icons/warning.svg?raw'
|
|
10
|
+
|
|
11
|
+
const iconMap = {
|
|
12
|
+
'alert': Alert,
|
|
13
|
+
'arrow-down': ArrowDown,
|
|
14
|
+
'check': Check,
|
|
15
|
+
'circle-check': CircleCheck,
|
|
16
|
+
'github': Github,
|
|
17
|
+
'info': Info,
|
|
18
|
+
'moon': Moon,
|
|
19
|
+
'sun': Sun,
|
|
20
|
+
'warning': Warning
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default iconMap
|
|
@@ -1,52 +1,50 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { InputProps } from './input'
|
|
3
|
-
import ConditionalWrapper from '
|
|
4
|
-
|
|
5
|
-
import './input.scss'
|
|
6
|
-
|
|
7
|
-
interface Props extends InputProps {}
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
type = 'text',
|
|
11
|
-
theme,
|
|
12
|
-
label,
|
|
13
|
-
subText,
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/>
|
|
52
|
-
</ConditionalWrapper>
|
|
1
|
+
---
|
|
2
|
+
import type { InputProps } from './input'
|
|
3
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.astro'
|
|
4
|
+
|
|
5
|
+
import styles from './input.module.scss'
|
|
6
|
+
|
|
7
|
+
interface Props extends InputProps {}
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
type = 'text',
|
|
11
|
+
theme,
|
|
12
|
+
label,
|
|
13
|
+
subText,
|
|
14
|
+
className,
|
|
15
|
+
...rest
|
|
16
|
+
} = Astro.props
|
|
17
|
+
|
|
18
|
+
const classes = [
|
|
19
|
+
styles.input,
|
|
20
|
+
theme && styles[theme],
|
|
21
|
+
className
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
const useLabel = !!(label || subText || Astro.slots.has('default'))
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<ConditionalWrapper condition={useLabel}>
|
|
28
|
+
<label slot="wrapper" class={styles['input-label']}>
|
|
29
|
+
{label && (
|
|
30
|
+
<div class={styles.label}>{label}</div>
|
|
31
|
+
)}
|
|
32
|
+
<ConditionalWrapper condition={Astro.slots.has('default')}>
|
|
33
|
+
<div class={styles.wrapper} slot="wrapper">
|
|
34
|
+
children
|
|
35
|
+
</div>
|
|
36
|
+
<slot />
|
|
37
|
+
children
|
|
38
|
+
</ConditionalWrapper>
|
|
39
|
+
{subText && (
|
|
40
|
+
<div class={styles.subtext}>
|
|
41
|
+
<Fragment set:html={subText} />
|
|
42
|
+
</div>
|
|
43
|
+
)}
|
|
44
|
+
</label>
|
|
45
|
+
<input
|
|
46
|
+
type={type}
|
|
47
|
+
class:list={classes}
|
|
48
|
+
{...rest}
|
|
49
|
+
/>
|
|
50
|
+
</ConditionalWrapper>
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type {
|
|
3
|
-
import ConditionalWrapper from '
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export let
|
|
9
|
-
export let
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
className
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
const useLabel = !!(label || subText || $$slots.
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<ConditionalWrapper
|
|
26
|
-
condition={useLabel}
|
|
27
|
-
element="label"
|
|
28
|
-
class=
|
|
29
|
-
>
|
|
30
|
-
{#if label}
|
|
31
|
-
<div class=
|
|
32
|
-
{/if}
|
|
33
|
-
<ConditionalWrapper
|
|
34
|
-
condition={$$slots.
|
|
35
|
-
element="div"
|
|
36
|
-
class=
|
|
37
|
-
>
|
|
38
|
-
<slot
|
|
39
|
-
<input
|
|
40
|
-
type={type}
|
|
41
|
-
class={classes}
|
|
42
|
-
on:change={onChange}
|
|
43
|
-
on:keyup={onKeyUp}
|
|
44
|
-
{...$$restProps}
|
|
45
|
-
/>
|
|
46
|
-
</ConditionalWrapper>
|
|
47
|
-
{#if label}
|
|
48
|
-
<div class=
|
|
49
|
-
{@html subText}
|
|
50
|
-
</div>
|
|
51
|
-
{/if}
|
|
52
|
-
</ConditionalWrapper>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SvelteInputProps } from './input'
|
|
3
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
|
|
4
|
+
|
|
5
|
+
import styles from './input.module.scss'
|
|
6
|
+
import { classNames } from '../../utils/classNames'
|
|
7
|
+
|
|
8
|
+
export let type: SvelteInputProps['type'] = 'text'
|
|
9
|
+
export let theme: SvelteInputProps['theme'] = null
|
|
10
|
+
export let label: SvelteInputProps['label'] = ''
|
|
11
|
+
export let subText: SvelteInputProps['subText'] = ''
|
|
12
|
+
export let className: SvelteInputProps['className'] = ''
|
|
13
|
+
export let onChange: SvelteInputProps['onChange'] = () => {}
|
|
14
|
+
export let onKeyUp: SvelteInputProps['onKeyUp'] = () => {}
|
|
15
|
+
|
|
16
|
+
const classes = classNames([
|
|
17
|
+
styles.input,
|
|
18
|
+
theme && styles[theme],
|
|
19
|
+
className
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
const useLabel = !!(label || subText || $$slots.default)
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<ConditionalWrapper
|
|
26
|
+
condition={useLabel}
|
|
27
|
+
element="label"
|
|
28
|
+
class={styles['input-label']}
|
|
29
|
+
>
|
|
30
|
+
{#if label}
|
|
31
|
+
<div class={styles.label}>{label}</div>
|
|
32
|
+
{/if}
|
|
33
|
+
<ConditionalWrapper
|
|
34
|
+
condition={$$slots.default}
|
|
35
|
+
element="div"
|
|
36
|
+
class={styles.wrapper}
|
|
37
|
+
>
|
|
38
|
+
<slot />
|
|
39
|
+
<input
|
|
40
|
+
type={type}
|
|
41
|
+
class={classes}
|
|
42
|
+
on:change={onChange}
|
|
43
|
+
on:keyup={onKeyUp}
|
|
44
|
+
{...$$restProps}
|
|
45
|
+
/>
|
|
46
|
+
</ConditionalWrapper>
|
|
47
|
+
{#if label}
|
|
48
|
+
<div class={styles.subtext}>
|
|
49
|
+
{@html subText}
|
|
50
|
+
</div>
|
|
51
|
+
{/if}
|
|
52
|
+
</ConditionalWrapper>
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import type { ReactInputProps } from './input'
|
|
3
|
-
import ConditionalWrapper from '
|
|
4
|
-
|
|
5
|
-
import './input.scss'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
icon,
|
|
14
|
-
value,
|
|
15
|
-
className,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
className
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
const useLabel = !!(label || subText ||
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<ConditionalWrapper condition={useLabel} wrapper={children => (
|
|
29
|
-
<label className=
|
|
30
|
-
{children}
|
|
31
|
-
</label>
|
|
32
|
-
)}>
|
|
33
|
-
{label && (
|
|
34
|
-
<div className=
|
|
35
|
-
)}
|
|
36
|
-
<ConditionalWrapper condition={!!
|
|
37
|
-
<div className=
|
|
38
|
-
{children}
|
|
39
|
-
</div>
|
|
40
|
-
)}>
|
|
41
|
-
{
|
|
42
|
-
<input
|
|
43
|
-
type={type}
|
|
44
|
-
className={classes}
|
|
45
|
-
defaultValue={value}
|
|
46
|
-
{...rest}
|
|
47
|
-
/>
|
|
48
|
-
</ConditionalWrapper>
|
|
49
|
-
{subText && (
|
|
50
|
-
<div
|
|
51
|
-
className=
|
|
52
|
-
dangerouslySetInnerHTML={{ __html: subText }}
|
|
53
|
-
/>
|
|
54
|
-
)}
|
|
55
|
-
</ConditionalWrapper>
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export default Input
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { ReactInputProps } from './input'
|
|
3
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
|
|
4
|
+
|
|
5
|
+
import styles from './input.module.scss'
|
|
6
|
+
import { classNames } from '../../utils/classNames'
|
|
7
|
+
|
|
8
|
+
const Input = ({
|
|
9
|
+
type = 'text',
|
|
10
|
+
theme,
|
|
11
|
+
label,
|
|
12
|
+
subText,
|
|
13
|
+
icon,
|
|
14
|
+
value,
|
|
15
|
+
className,
|
|
16
|
+
children,
|
|
17
|
+
...rest
|
|
18
|
+
}: ReactInputProps) => {
|
|
19
|
+
const classes = classNames([
|
|
20
|
+
styles.input,
|
|
21
|
+
theme && styles[theme],
|
|
22
|
+
className
|
|
23
|
+
])
|
|
24
|
+
|
|
25
|
+
const useLabel = !!(label || subText || children)
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<ConditionalWrapper condition={useLabel} wrapper={children => (
|
|
29
|
+
<label className={styles['input-label']}>
|
|
30
|
+
{children}
|
|
31
|
+
</label>
|
|
32
|
+
)}>
|
|
33
|
+
{label && (
|
|
34
|
+
<div className={styles.label}>{label}</div>
|
|
35
|
+
)}
|
|
36
|
+
<ConditionalWrapper condition={!!children} wrapper={children => (
|
|
37
|
+
<div className={styles.wrapper}>
|
|
38
|
+
{children}
|
|
39
|
+
</div>
|
|
40
|
+
)}>
|
|
41
|
+
{children}
|
|
42
|
+
<input
|
|
43
|
+
type={type}
|
|
44
|
+
className={classes}
|
|
45
|
+
defaultValue={value}
|
|
46
|
+
{...rest}
|
|
47
|
+
/>
|
|
48
|
+
</ConditionalWrapper>
|
|
49
|
+
{subText && (
|
|
50
|
+
<div
|
|
51
|
+
className={styles.subtext}
|
|
52
|
+
dangerouslySetInnerHTML={{ __html: subText }}
|
|
53
|
+
/>
|
|
54
|
+
)}
|
|
55
|
+
</ConditionalWrapper>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default Input
|