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.
Files changed (122) hide show
  1. package/README.md +33 -7
  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.scss → accordion.module.scss} +18 -10
  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 +54 -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} +2 -2
  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 +89 -0
  21. package/components/Badge/badge.ts +8 -1
  22. package/components/Button/Button.astro +10 -6
  23. package/components/Button/Button.svelte +15 -11
  24. package/components/Button/Button.tsx +11 -7
  25. package/components/Button/button.module.scss +94 -0
  26. package/components/Button/button.ts +6 -1
  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 +33 -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.scss → checkbox.module.scss} +16 -17
  35. package/components/Checkbox/checkbox.ts +5 -1
  36. package/components/ConditionalWrapper/ConditionalWrapper.svelte +1 -1
  37. package/components/Icon/Icon.svelte +1 -8
  38. package/components/Icon/Icon.tsx +1 -8
  39. package/components/Icon/map.ts +23 -0
  40. package/components/Input/Input.astro +50 -52
  41. package/components/Input/Input.svelte +52 -52
  42. package/components/Input/Input.tsx +59 -59
  43. package/components/Input/{input.scss → input.module.scss} +87 -83
  44. package/components/Input/input.ts +8 -2
  45. package/components/Menu/Menu.astro +107 -0
  46. package/components/Menu/Menu.svelte +88 -0
  47. package/components/Menu/Menu.tsx +107 -0
  48. package/components/Menu/menu.module.scss +144 -0
  49. package/components/Menu/menu.ts +21 -0
  50. package/components/Progress/Progress.astro +42 -40
  51. package/components/Progress/Progress.svelte +40 -38
  52. package/components/Progress/Progress.tsx +48 -47
  53. package/components/Progress/{progress.scss → progress.module.scss} +66 -66
  54. package/components/Radio/Radio.astro +57 -57
  55. package/components/Radio/Radio.svelte +58 -56
  56. package/components/Radio/Radio.tsx +69 -68
  57. package/components/Radio/{radio.scss → radio.module.scss} +92 -92
  58. package/components/Radio/radio.ts +4 -0
  59. package/components/Rating/Rating.astro +13 -10
  60. package/components/Rating/Rating.svelte +15 -15
  61. package/components/Rating/Rating.tsx +22 -11
  62. package/components/Rating/{rating.scss → rating.module.scss} +10 -9
  63. package/components/Rating/rating.ts +1 -1
  64. package/components/Spinner/Spinner.astro +44 -42
  65. package/components/Spinner/Spinner.svelte +40 -38
  66. package/components/Spinner/Spinner.tsx +45 -44
  67. package/components/Spinner/{spinner.scss → spinner.module.scss} +41 -41
  68. package/components/Switch/Switch.astro +13 -11
  69. package/components/Switch/Switch.svelte +26 -24
  70. package/components/Switch/Switch.tsx +14 -12
  71. package/components/Switch/{switch.scss → switch.module.scss} +4 -4
  72. package/components/Switch/switch.ts +8 -4
  73. package/components/Table/Table.astro +60 -60
  74. package/components/Table/Table.svelte +56 -54
  75. package/components/Table/Table.tsx +64 -63
  76. package/components/Table/{table.scss → table.module.scss} +64 -65
  77. package/components/Tabs/Tabs.astro +77 -76
  78. package/components/Tabs/Tabs.svelte +56 -54
  79. package/components/Tabs/Tabs.tsx +70 -69
  80. package/components/Tabs/{tabs.scss → tabs.module.scss} +30 -31
  81. package/components/ThemeSwitcher/ThemeSwitcher.astro +106 -0
  82. package/components/ThemeSwitcher/ThemeSwitcher.svelte +76 -0
  83. package/components/ThemeSwitcher/ThemeSwitcher.tsx +89 -0
  84. package/components/ThemeSwitcher/themeswitcher.module.scss +74 -0
  85. package/components/ThemeSwitcher/themeswitcher.ts +13 -0
  86. package/components/Timeline/Timeline.astro +36 -34
  87. package/components/Timeline/Timeline.svelte +32 -30
  88. package/components/Timeline/Timeline.tsx +38 -37
  89. package/components/Timeline/{timeline.scss → timeline.module.scss} +71 -71
  90. package/components/TimelineItem/TimelineItem.astro +27 -26
  91. package/components/TimelineItem/TimelineItem.svelte +24 -22
  92. package/components/TimelineItem/TimelineItem.tsx +33 -32
  93. package/components/TimelineItem/{timelineitem.scss → timelineitem.module.scss} +31 -31
  94. package/components/Toast/Toast.astro +41 -30
  95. package/components/Toast/Toast.svelte +32 -21
  96. package/components/Toast/Toast.tsx +38 -28
  97. package/components/Toast/{toast.scss → toast.module.scss} +44 -43
  98. package/components/Toast/toast.ts +3 -6
  99. package/icons/moon.svg +3 -0
  100. package/icons/sun.svg +3 -0
  101. package/index.js +3 -0
  102. package/package.json +3 -1
  103. package/react.d.ts +4 -0
  104. package/react.js +4 -0
  105. package/scss/global/elements.scss +1 -1
  106. package/scss/global/scrollbar.scss +21 -0
  107. package/scss/global/theme.scss +140 -0
  108. package/scss/global/tooltip.scss +8 -5
  109. package/scss/global/utility.scss +29 -0
  110. package/scss/global.scss +2 -0
  111. package/scss/resets.scss +5 -5
  112. package/scss/setup.scss +39 -18
  113. package/svelte.d.ts +16 -12
  114. package/svelte.js +4 -0
  115. package/utils/classNames.ts +4 -0
  116. package/utils/cookies.ts +28 -0
  117. package/utils/event.ts +17 -0
  118. package/utils/toast.ts +12 -9
  119. package/components/Alert/alert.scss +0 -53
  120. package/components/Badge/badge.scss +0 -85
  121. package/components/Button/button.scss +0 -91
  122. package/components/Card/card.scss +0 -37
@@ -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
  )}
@@ -1,29 +1,27 @@
1
1
  @import '../../scss/config.scss';
2
2
 
3
- .w-checkbox {
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: 5px;
15
+ gap: 0;
15
16
 
16
- .checkbox-wrapper {
17
+ .wrapper {
17
18
  display: flex;
18
- align-items: center;
19
19
  gap: 10px;
20
- }
21
- }
22
20
 
23
- &.boxed {
24
- border: 1px solid #252525;
25
- border-radius: 5px;
26
- padding: 20px;
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: #252525;
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: #333;
49
- border-color: #333;
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
- .sub-text {
70
+ .text {
72
71
  margin-left: 25px;
73
72
  font-size: 14px;
74
- color: #BBB;
73
+ color: var(--w-color-primary-20);
75
74
 
76
75
  a {
77
76
  @include Transition(color);
78
- color: #BBB;
77
+ color: var(--w-color-primary-20);
79
78
 
80
79
  &:hover {
81
- color: #FFF;
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
@@ -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,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>
@@ -1,59 +1,59 @@
1
- import React from 'react'
2
- import type { ReactInputProps } from './input'
3
- import ConditionalWrapper from '@components/ConditionalWrapper/ConditionalWrapper.tsx'
4
-
5
- import './input.scss'
6
-
7
- const Input = ({
8
- type = 'text',
9
- theme,
10
- label,
11
- subText,
12
- fill,
13
- icon,
14
- value,
15
- className,
16
- ...rest
17
- }: ReactInputProps) => {
18
- const classes = [
19
- 'w-input',
20
- theme,
21
- fill && 'fill',
22
- className
23
- ].filter(Boolean).join(' ')
24
-
25
- const useLabel = !!(label || subText || icon)
26
-
27
- return (
28
- <ConditionalWrapper condition={useLabel} wrapper={children => (
29
- <label className="w-input-label">
30
- {children}
31
- </label>
32
- )}>
33
- {label && (
34
- <div className="label">{label}</div>
35
- )}
36
- <ConditionalWrapper condition={!!icon} wrapper={children => (
37
- <div className="input-wrapper">
38
- {children}
39
- </div>
40
- )}>
41
- {icon && icon}
42
- <input
43
- type={type}
44
- className={classes}
45
- defaultValue={value}
46
- {...rest}
47
- />
48
- </ConditionalWrapper>
49
- {subText && (
50
- <div
51
- className="subtext"
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