@yourdash/uikit 1.0.15 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,6 +8,8 @@
8
8
  .component {
9
9
  display: inline-block;
10
10
  text-align: center;
11
+ margin: 0;
12
+ line-height: 1;
11
13
  }
12
14
 
13
15
  .h1component {
@@ -8,7 +8,6 @@
8
8
  .component {
9
9
  display: flex;
10
10
  border: var(#{$theme}#{$border});
11
- border-bottom: none;
12
11
  border-radius: var(#{$theme}#{$radius});
13
12
  }
14
13
 
@@ -16,6 +15,7 @@
16
15
  width: 0;
17
16
  height: calc(100% - calc(var(#{$theme}#{$gap})) * 2);
18
17
  margin: var(#{$theme}#{$gap});
18
+ border-left: none;
19
19
 
20
20
  &.disableMargin {
21
21
  height: 100%;
@@ -28,6 +28,7 @@
28
28
  width: calc(100% - calc(var(#{$theme}#{$gap})) * 2);
29
29
  height: 0;
30
30
  margin: var(#{$theme}#{$gap});
31
+ border-bottom: none;
31
32
 
32
33
  &.disableMargin {
33
34
  width: 100%;
@@ -1,64 +1,78 @@
1
- /*
2
- * Copyright ©2024 Ewsgit<https://ewsgit.uk> and YourDash<https://yourdash.ewsgit.uk> contributors.
3
- * YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
4
- */
5
-
6
- import clippy from "@yourdash/shared/web/helpers/clippy.ts";
7
- import Icon from "../icon/icon.tsx";
8
- import { UKIconType } from "../icon/iconDictionary.ts";
9
- import styles from "./textInput.module.scss";
10
- import React, { useEffect, useRef, useState } from "react";
11
-
12
- const TextInputComponent: React.FC<{
13
- getValue?: React.Dispatch<React.SetStateAction<string>>;
14
- onSubmit?: (value: string) => void;
15
- placeholder: string;
16
- icon?: UKIconType;
17
- defaultValue?: string;
18
- value?: string;
19
- accessibleName: string;
20
- className?: string;
21
- type?: string;
22
- }> = (props) => {
23
- const ref = useRef<HTMLInputElement>(null);
24
-
25
- useEffect(() => {
26
- if (!ref.current) return;
27
-
28
- if (props.value) ref.current.value = props.value;
29
- }, [props.value]);
30
-
31
- useEffect(() => {
32
- if (!ref.current) return;
33
-
34
- ref.current.onchange = () => {
35
- if (!ref.current) return;
36
- if (!props.getValue) return;
37
-
38
- props.getValue(ref.current.value);
39
- };
40
- }, []);
41
-
42
- return (
43
- <div className={clippy(styles.component, props.className)}>
44
- {props.icon && (
45
- <Icon
46
- className={styles.icon}
47
- icon={props.icon}
48
- />
49
- )}
50
- <input
51
- ref={ref}
52
- type={props.type || "text"}
53
- aria-label={props.accessibleName}
54
- defaultValue={props.defaultValue}
55
- className={clippy(styles.input, !props.icon && styles.noIcon)}
56
- placeholder={props.placeholder}
57
- />
58
- </div>
59
- );
60
- };
61
-
62
- const TextInput = TextInputComponent;
63
-
64
- export default TextInput;
1
+ /*
2
+ * Copyright ©2024 Ewsgit<https://ewsgit.uk> and YourDash<https://yourdash.ewsgit.uk> contributors.
3
+ * YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
4
+ */
5
+
6
+ import clippy from "@yourdash/shared/web/helpers/clippy.ts";
7
+ import Icon from "../icon/icon.tsx";
8
+ import { UKIconType } from "../icon/iconDictionary.ts";
9
+ import styles from "./textInput.module.scss";
10
+ import React, { useEffect, useRef, useState } from "react";
11
+
12
+ const TextInputComponent: React.FC<{
13
+ getValue?: React.Dispatch<React.SetStateAction<string>>;
14
+ getLiveValue?: React.Dispatch<React.SetStateAction<string>>;
15
+ onSubmit?: (value: string) => void;
16
+ placeholder: string;
17
+ icon?: UKIconType;
18
+ defaultValue?: string;
19
+ value?: string;
20
+ accessibleName: string;
21
+ className?: string;
22
+ type?: string;
23
+ }> = (props) => {
24
+ const ref = useRef<HTMLInputElement>(null);
25
+
26
+ useEffect(() => {
27
+ if (!ref.current) return;
28
+
29
+ if (props.value) ref.current.value = props.value;
30
+ }, [props.value]);
31
+
32
+ useEffect(() => {
33
+ if (!ref.current) return;
34
+
35
+ ref.current.onchange = () => {
36
+ if (!ref.current) return;
37
+ if (!props.getValue) return;
38
+
39
+ props.getValue(ref.current.value);
40
+ };
41
+
42
+ ref.current.onkeyup = (event) => {
43
+ if (!ref.current) return;
44
+ if (!props.onSubmit) return;
45
+
46
+ if (props.getLiveValue) {
47
+ props.getLiveValue(ref.current.value);
48
+ }
49
+
50
+ if (event.key === "Enter") {
51
+ props.onSubmit(ref.current.value);
52
+ }
53
+ };
54
+ }, []);
55
+
56
+ return (
57
+ <div className={clippy(styles.component, props.className)}>
58
+ {props.icon && (
59
+ <Icon
60
+ className={styles.icon}
61
+ icon={props.icon}
62
+ />
63
+ )}
64
+ <input
65
+ ref={ref}
66
+ type={props.type || "text"}
67
+ aria-label={props.accessibleName}
68
+ defaultValue={props.defaultValue}
69
+ className={clippy(styles.input, !props.icon && styles.noIcon)}
70
+ placeholder={props.placeholder}
71
+ />
72
+ </div>
73
+ );
74
+ };
75
+
76
+ const TextInput = TextInputComponent;
77
+
78
+ export default TextInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yourdash/uikit",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {