webcoreui 0.0.11 → 0.1.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.
Files changed (141) hide show
  1. package/README.md +42 -11
  2. package/astro.d.ts +4 -0
  3. package/astro.js +4 -0
  4. package/components/Accordion/Accordion.astro +10 -8
  5. package/components/Accordion/Accordion.svelte +8 -8
  6. package/components/Accordion/Accordion.tsx +7 -6
  7. package/components/Accordion/accordion.module.scss +65 -0
  8. package/components/Alert/Alert.astro +11 -7
  9. package/components/Alert/Alert.svelte +9 -7
  10. package/components/Alert/Alert.tsx +11 -7
  11. package/components/Alert/alert.module.scss +51 -0
  12. package/components/Alert/alert.ts +3 -1
  13. package/components/Avatar/Avatar.astro +4 -4
  14. package/components/Avatar/Avatar.svelte +13 -7
  15. package/components/Avatar/Avatar.tsx +11 -9
  16. package/components/Avatar/{avatar.scss → avatar.module.scss} +11 -8
  17. package/components/Badge/Badge.astro +8 -8
  18. package/components/Badge/Badge.svelte +25 -13
  19. package/components/Badge/Badge.tsx +26 -8
  20. package/components/Badge/badge.module.scss +86 -0
  21. package/components/Badge/badge.ts +8 -1
  22. package/components/Button/Button.astro +9 -7
  23. package/components/Button/Button.svelte +13 -11
  24. package/components/Button/Button.tsx +10 -8
  25. package/components/Button/button.module.scss +87 -0
  26. package/components/Button/button.ts +6 -2
  27. package/components/Card/Card.astro +7 -15
  28. package/components/Card/Card.svelte +16 -13
  29. package/components/Card/Card.tsx +15 -11
  30. package/components/Card/card.module.scss +38 -0
  31. package/components/Checkbox/Checkbox.astro +10 -10
  32. package/components/Checkbox/Checkbox.svelte +19 -18
  33. package/components/Checkbox/Checkbox.tsx +12 -11
  34. package/components/Checkbox/checkbox.module.scss +70 -0
  35. package/components/Checkbox/checkbox.ts +5 -1
  36. package/components/ConditionalWrapper/ConditionalWrapper.svelte +1 -1
  37. package/components/Icon/Icon.astro +2 -2
  38. package/components/Icon/Icon.svelte +1 -8
  39. package/components/Icon/Icon.tsx +1 -8
  40. package/components/Icon/map.ts +23 -0
  41. package/components/Input/Input.astro +50 -52
  42. package/components/Input/Input.svelte +52 -52
  43. package/components/Input/Input.tsx +59 -59
  44. package/components/Input/input.module.scss +79 -0
  45. package/components/Input/input.ts +8 -2
  46. package/components/Menu/Menu.astro +107 -0
  47. package/components/Menu/Menu.svelte +88 -0
  48. package/components/Menu/Menu.tsx +107 -0
  49. package/components/Menu/menu.module.scss +141 -0
  50. package/components/Menu/menu.ts +21 -0
  51. package/components/Progress/Progress.astro +42 -40
  52. package/components/Progress/Progress.svelte +40 -38
  53. package/components/Progress/Progress.tsx +48 -47
  54. package/components/Progress/progress.module.scss +70 -0
  55. package/components/Radio/Radio.astro +57 -57
  56. package/components/Radio/Radio.svelte +58 -56
  57. package/components/Radio/Radio.tsx +69 -68
  58. package/components/Radio/radio.module.scss +84 -0
  59. package/components/Radio/radio.ts +4 -0
  60. package/components/Rating/Rating.astro +13 -10
  61. package/components/Rating/Rating.svelte +15 -15
  62. package/components/Rating/Rating.tsx +22 -11
  63. package/components/Rating/rating.module.scss +45 -0
  64. package/components/Rating/rating.ts +1 -1
  65. package/components/Spinner/Spinner.astro +44 -42
  66. package/components/Spinner/Spinner.svelte +40 -38
  67. package/components/Spinner/Spinner.tsx +45 -44
  68. package/components/Spinner/{spinner.scss → spinner.module.scss} +50 -41
  69. package/components/Switch/Switch.astro +13 -11
  70. package/components/Switch/Switch.svelte +26 -24
  71. package/components/Switch/Switch.tsx +14 -12
  72. package/components/Switch/switch.module.scss +82 -0
  73. package/components/Switch/switch.ts +8 -4
  74. package/components/Table/Table.astro +60 -60
  75. package/components/Table/Table.svelte +56 -54
  76. package/components/Table/Table.tsx +64 -63
  77. package/components/Table/{table.scss → table.module.scss} +60 -65
  78. package/components/Tabs/Tabs.astro +76 -76
  79. package/components/Tabs/Tabs.svelte +56 -54
  80. package/components/Tabs/Tabs.tsx +70 -69
  81. package/components/Tabs/tabs.module.scss +125 -0
  82. package/components/ThemeSwitcher/ThemeSwitcher.astro +106 -0
  83. package/components/ThemeSwitcher/ThemeSwitcher.svelte +76 -0
  84. package/components/ThemeSwitcher/ThemeSwitcher.tsx +89 -0
  85. package/components/ThemeSwitcher/themeswitcher.module.scss +76 -0
  86. package/components/ThemeSwitcher/themeswitcher.ts +13 -0
  87. package/components/Timeline/Timeline.astro +36 -34
  88. package/components/Timeline/Timeline.svelte +32 -30
  89. package/components/Timeline/Timeline.tsx +38 -37
  90. package/components/Timeline/{timeline.scss → timeline.module.scss} +76 -71
  91. package/components/TimelineItem/TimelineItem.astro +27 -26
  92. package/components/TimelineItem/TimelineItem.svelte +24 -22
  93. package/components/TimelineItem/TimelineItem.tsx +33 -32
  94. package/components/TimelineItem/timelineitem.module.scss +29 -0
  95. package/components/Toast/Toast.astro +41 -30
  96. package/components/Toast/Toast.svelte +32 -21
  97. package/components/Toast/Toast.tsx +38 -28
  98. package/components/Toast/toast.module.scss +40 -0
  99. package/components/Toast/toast.ts +8 -6
  100. package/icons/moon.svg +3 -0
  101. package/icons/sun.svg +3 -0
  102. package/icons.d.ts +11 -0
  103. package/icons.js +9 -0
  104. package/index.js +3 -0
  105. package/package.json +5 -1
  106. package/react.d.ts +4 -0
  107. package/react.js +4 -0
  108. package/scss/config/color-palette.scss +23 -0
  109. package/scss/config/css-values.scss +44 -0
  110. package/scss/config/layout.scss +41 -0
  111. package/scss/config/mixins.scss +395 -9
  112. package/scss/config/typography.scss +66 -0
  113. package/scss/config.scss +6 -1
  114. package/scss/global/elements.scss +22 -2
  115. package/scss/global/scrollbar.scss +24 -0
  116. package/scss/global/theme.scss +140 -0
  117. package/scss/global/tooltip.scss +47 -39
  118. package/scss/global/utility.scss +33 -4
  119. package/scss/global.scss +2 -1
  120. package/scss/resets.scss +64 -11
  121. package/scss/setup.scss +25 -31
  122. package/svelte.d.ts +16 -12
  123. package/svelte.js +4 -0
  124. package/utils/classNames.ts +4 -0
  125. package/utils/cookies.ts +28 -0
  126. package/utils/event.ts +17 -0
  127. package/utils/toast.ts +15 -11
  128. package/components/Accordion/accordion.scss +0 -63
  129. package/components/Alert/alert.scss +0 -53
  130. package/components/Badge/badge.scss +0 -85
  131. package/components/Button/button.scss +0 -91
  132. package/components/Card/card.scss +0 -37
  133. package/components/Checkbox/checkbox.scss +0 -85
  134. package/components/Input/input.scss +0 -83
  135. package/components/Progress/progress.scss +0 -66
  136. package/components/Radio/radio.scss +0 -92
  137. package/components/Rating/rating.scss +0 -37
  138. package/components/Switch/switch.scss +0 -84
  139. package/components/Tabs/tabs.scss +0 -134
  140. package/components/TimelineItem/timelineitem.scss +0 -31
  141. package/components/Toast/toast.scss +0 -43
@@ -4,7 +4,7 @@ import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.astro'
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
8
 
9
9
  interface Props extends CheckboxProps {}
10
10
 
@@ -13,14 +13,14 @@ const {
13
13
  label,
14
14
  subText,
15
15
  disabled,
16
- boxed,
17
- color
16
+ color,
17
+ className
18
18
  } = Astro.props
19
19
 
20
20
  const classes = [
21
- 'w-checkbox',
22
- boxed && 'boxed',
23
- label && subText && 'col'
21
+ styles.checkbox,
22
+ label && subText && styles.col,
23
+ className
24
24
  ]
25
25
 
26
26
  const style = color
@@ -30,21 +30,21 @@ const style = color
30
30
 
31
31
  <label class:list={classes} style={style}>
32
32
  <ConditionalWrapper condition={!!(label && subText)}>
33
- <div class="checkbox-wrapper" slot="wrapper">
33
+ <div class={styles.wrapper} slot="wrapper">
34
34
  children
35
35
  </div>
36
36
  <input type="checkbox" checked={checked} disabled={disabled} />
37
- <span class="check">
37
+ <span class={styles.check}>
38
38
  <Fragment set:html={check} />
39
39
  </span>
40
40
  {label && (
41
- <span class="label">
41
+ <span class={styles.label}>
42
42
  <Fragment set:html={label} />
43
43
  </span>
44
44
  )}
45
45
  </ConditionalWrapper>
46
46
  {label && subText && (
47
- <span class="sub-text">
47
+ <span class={styles.text}>
48
48
  <Fragment set:html={subText} />
49
49
  </span>
50
50
  )}
@@ -1,24 +1,25 @@
1
1
  <script lang="ts">
2
- import type { CheckboxProps } from './checkbox'
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: CheckboxProps['checked'] = false
10
- export let label: CheckboxProps['label'] = ''
11
- export let subText: CheckboxProps['subText'] = ''
12
- export let disabled: CheckboxProps['disabled'] = false
13
- export let boxed: CheckboxProps['boxed'] = false
14
- export let color: CheckboxProps['color'] = ''
15
- export let onClick: () => any = () => {}
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
- 'w-checkbox',
19
- boxed && 'boxed',
20
- label && subText && 'col'
21
- ].filter(Boolean).join(' ')
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="checkbox-wrapper"
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="check">
41
+ <span class={styles.check}>
41
42
  {@html check}
42
43
  </span>
43
44
  {#if label}
44
- <span class="label">
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="sub-text">{@html subText}</span>
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
- 'w-checkbox',
20
- boxed && 'boxed',
21
- label && subText && 'col'
22
- ].filter(Boolean).join(' ')
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="checkbox-wrapper">
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="check"
46
+ className={styles.check}
46
47
  dangerouslySetInnerHTML={{ __html: check }}
47
48
  />
48
49
  {label && (
49
50
  <span
50
- className="label"
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="sub-text"
58
+ className={styles.text}
58
59
  dangerouslySetInnerHTML={{ __html: subText }}
59
60
  />
60
61
  )}
@@ -0,0 +1,70 @@
1
+ @use '../../scss/config.scss' as *;
2
+
3
+ body {
4
+ --w-checkbox-color: var(--w-color-primary);
5
+ }
6
+
7
+ .checkbox {
8
+ @include layout(inline-flex, sm);
9
+ @include typography(md, hmd);
10
+
11
+ cursor: pointer;
12
+
13
+ &.col {
14
+ @include layout(column, h-start, v-start, none);
15
+
16
+ .wrapper {
17
+ @include layout(flex, sm);
18
+ }
19
+ }
20
+
21
+ input {
22
+ display: none;
23
+
24
+ &:checked + span {
25
+ @include background(var(--w-checkbox-color));
26
+
27
+ svg {
28
+ @include position(absolute, center);
29
+ @include typography(primary-50);
30
+ @include size(10px);
31
+
32
+ display: block;
33
+ }
34
+ }
35
+
36
+ &:disabled + span {
37
+ @include background(primary-40);
38
+ @include border(primary-40);
39
+ cursor: no-drop;
40
+ }
41
+ }
42
+
43
+ .check {
44
+ @include size(15px);
45
+ @include position(relative);
46
+ @include border-radius(sm);
47
+ @include spacing(mt-xs);
48
+
49
+ display: inline-block;
50
+ min-width: 15px;
51
+ border: 1px solid var(--w-checkbox-color);
52
+
53
+ svg {
54
+ @include visibility(none);
55
+ }
56
+ }
57
+
58
+ .text {
59
+ @include spacing(ml-lg);
60
+ @include typography(sm, primary-20);
61
+
62
+ a {
63
+ @include typography(primary-20);
64
+
65
+ &:hover {
66
+ @include typography(primary);
67
+ }
68
+ }
69
+ }
70
+ }
@@ -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
@@ -2,7 +2,7 @@
2
2
  import type { ConditionalWrapperProps } from './conditionalwrapper'
3
3
 
4
4
  export let condition: ConditionalWrapperProps['condition']
5
- export let element: string
5
+ export let element: string = 'div'
6
6
  </script>
7
7
 
8
8
  {#if condition}
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import type { IconProps } from './icon'
3
+ import iconMap from './map'
3
4
 
4
5
  interface Props extends IconProps {}
5
6
 
@@ -9,8 +10,7 @@ const {
9
10
  color
10
11
  } = Astro.props
11
12
 
12
- const { default: markup } = await import(`../../icons/${type}.svg?raw`)
13
- const icon = markup
13
+ const icon = iconMap[type as keyof typeof iconMap]
14
14
  .replace('width="24"', `width=${size}`)
15
15
  .replace('height="24"', color
16
16
  ? `height=${size} color=${color}`
@@ -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
@@ -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 '@components/ConditionalWrapper/ConditionalWrapper.astro'
4
-
5
- import './input.scss'
6
-
7
- interface Props extends InputProps {}
8
-
9
- const {
10
- type = 'text',
11
- theme,
12
- label,
13
- subText,
14
- fill,
15
- className,
16
- ...rest
17
- } = Astro.props
18
-
19
- const classes = [
20
- 'w-input',
21
- theme,
22
- fill && 'fill',
23
- className
24
- ]
25
-
26
- const useLabel = !!(label || subText || Astro.slots.has('icon'))
27
- ---
28
-
29
- <ConditionalWrapper condition={useLabel}>
30
- <label slot="wrapper" class="w-input-label">
31
- {label && (
32
- <div class="label">{label}</div>
33
- )}
34
- <ConditionalWrapper condition={Astro.slots.has('icon')}>
35
- <div class="input-wrapper" slot="wrapper">
36
- children
37
- </div>
38
- <slot name="icon" />
39
- children
40
- </ConditionalWrapper>
41
- {subText && (
42
- <div class="subtext">
43
- <Fragment set:html={subText} />
44
- </div>
45
- )}
46
- </label>
47
- <input
48
- type={type}
49
- class:list={classes}
50
- {...rest}
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 { InputProps } from './input'
3
- import ConditionalWrapper from '@components/ConditionalWrapper/ConditionalWrapper.svelte'
4
- import './input.scss'
5
-
6
- export let type: InputProps['type'] = 'text'
7
- export let theme: InputProps['theme'] = null
8
- export let label: InputProps['label'] = ''
9
- export let subText: InputProps['subText'] = ''
10
- export let fill: InputProps['fill'] = false
11
- export let className: InputProps['className'] = ''
12
- export let onChange: (e: any) => any = () => {}
13
- export let onKeyUp: (e: any) => any = () => {}
14
-
15
- const classes = [
16
- 'w-input',
17
- theme,
18
- fill && 'fill',
19
- className
20
- ].filter(Boolean).join(' ')
21
-
22
- const useLabel = !!(label || subText || $$slots.icon)
23
- </script>
24
-
25
- <ConditionalWrapper
26
- condition={useLabel}
27
- element="label"
28
- class="w-input-label"
29
- >
30
- {#if label}
31
- <div class="label">{label}</div>
32
- {/if}
33
- <ConditionalWrapper
34
- condition={$$slots.icon}
35
- element="div"
36
- class="input-wrapper"
37
- >
38
- <slot name="icon" />
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="subtext">
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>