@yakad/ui 1.2.79-beta → 1.2.80-beta
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/codeField/codeField.d.ts +1 -1
- package/codeField/codeField.js +9 -1
- package/codeField/codeField.js.map +1 -1
- package/codeField/codeField.module.css +5 -0
- package/codeField/codeField.tsx +21 -5
- package/inputField/inputField.js +1 -1
- package/inputField/inputField.js.map +1 -1
- package/inputField/inputField.tsx +1 -0
- package/package.json +1 -1
package/codeField/codeField.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ interface CodeFieldsProps extends React.HTMLAttributes<HTMLInputElement> {
|
|
|
4
4
|
name?: string;
|
|
5
5
|
type?: string;
|
|
6
6
|
}
|
|
7
|
-
declare function CodeField(props: CodeFieldsProps): JSX.Element;
|
|
7
|
+
declare function CodeField(this: any, props: CodeFieldsProps): JSX.Element;
|
|
8
8
|
export default CodeField;
|
package/codeField/codeField.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { joinClassNames, joinStyles } from "@yakad/lib";
|
|
3
3
|
import styles from "./codeField.module.css";
|
|
4
|
+
function sliceOverLength(event, length) {
|
|
5
|
+
const targetInput = event.target;
|
|
6
|
+
const targetLength = targetInput.value.length;
|
|
7
|
+
if (targetLength > length)
|
|
8
|
+
targetInput.value = targetInput.value.slice(0, targetLength - 1);
|
|
9
|
+
targetInput.value = targetInput.value.replace(/[^0-9]+/, "");
|
|
10
|
+
}
|
|
4
11
|
function CodeField(props) {
|
|
12
|
+
const length = props.length ? props.length : 6;
|
|
5
13
|
const joinedClassNames = joinClassNames(styles.input, props.className);
|
|
6
14
|
const joinedStyles = joinStyles({ width: "calc(1.5ch * " + props.length + ")" }, props.style);
|
|
7
|
-
return (React.createElement("input", {
|
|
15
|
+
return (React.createElement("input", { name: props.name, type: "number", minLength: length, maxLength: length, className: joinedClassNames, style: joinedStyles, onInput: (event) => sliceOverLength(event, length), autoComplete: "off", pattern: "[0-9]" }));
|
|
8
16
|
}
|
|
9
17
|
export default CodeField;
|
|
10
18
|
//# sourceMappingURL=codeField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeField.js","sourceRoot":"","sources":["codeField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAQ5C,SAAS,SAAS,CAAC,KAAsB;
|
|
1
|
+
{"version":3,"file":"codeField.js","sourceRoot":"","sources":["codeField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAQ5C,SAAS,eAAe,CACpB,KAAwC,EACxC,MAAc;IAEd,MAAM,WAAW,GAAG,KAAK,CAAC,MAA0B,CAAC;IACrD,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC;IAC9C,IAAI,YAAY,GAAG,MAAM;QACrB,WAAW,CAAC,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;IAErE,WAAW,CAAC,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,SAAS,CAAY,KAAsB;IAChD,MAAM,MAAM,GAAW,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvD,MAAM,gBAAgB,GAAG,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,SAAU,CAAC,CAAC;IAExE,MAAM,YAAY,GAAG,UAAU,CAC3B,EAAE,KAAK,EAAE,eAAe,GAAG,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE,EAC/C,KAAK,CAAC,KAAM,CACf,CAAC;IAEF,OAAO,CACH,+BACI,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,gBAAgB,EAC3B,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,EAClD,YAAY,EAAC,KAAK,EAClB,OAAO,EAAC,OAAO,GACjB,CACL,CAAC;AACN,CAAC;AAED,eAAe,SAAS,CAAC"}
|
package/codeField/codeField.tsx
CHANGED
|
@@ -8,7 +8,21 @@ interface CodeFieldsProps extends React.HTMLAttributes<HTMLInputElement> {
|
|
|
8
8
|
type?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function
|
|
11
|
+
function sliceOverLength(
|
|
12
|
+
event: React.FormEvent<HTMLInputElement>,
|
|
13
|
+
length: number
|
|
14
|
+
) {
|
|
15
|
+
const targetInput = event.target as HTMLInputElement;
|
|
16
|
+
const targetLength = targetInput.value.length;
|
|
17
|
+
if (targetLength > length)
|
|
18
|
+
targetInput.value = targetInput.value.slice(0, targetLength - 1);
|
|
19
|
+
|
|
20
|
+
targetInput.value = targetInput.value.replace(/[^0-9]+/, "");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function CodeField(this: any, props: CodeFieldsProps) {
|
|
24
|
+
const length: number = props.length ? props.length : 6;
|
|
25
|
+
|
|
12
26
|
const joinedClassNames = joinClassNames(styles.input, props.className!);
|
|
13
27
|
|
|
14
28
|
const joinedStyles = joinStyles(
|
|
@@ -18,13 +32,15 @@ function CodeField(props: CodeFieldsProps) {
|
|
|
18
32
|
|
|
19
33
|
return (
|
|
20
34
|
<input
|
|
21
|
-
{...props}
|
|
22
35
|
name={props.name}
|
|
23
|
-
type=
|
|
24
|
-
minLength={
|
|
25
|
-
maxLength={
|
|
36
|
+
type="number"
|
|
37
|
+
minLength={length}
|
|
38
|
+
maxLength={length}
|
|
26
39
|
className={joinedClassNames}
|
|
27
40
|
style={joinedStyles}
|
|
41
|
+
onInput={(event) => sliceOverLength(event, length)}
|
|
42
|
+
autoComplete="off"
|
|
43
|
+
pattern="[0-9]"
|
|
28
44
|
/>
|
|
29
45
|
);
|
|
30
46
|
}
|
package/inputField/inputField.js
CHANGED
|
@@ -4,7 +4,7 @@ import styles from "./inputField.module.css";
|
|
|
4
4
|
function InputField(props) {
|
|
5
5
|
const joinedClassNames = joinClassNames(styles.input, props.variant ? styles[props.variant] : styles.standard, props.className);
|
|
6
6
|
return (React.createElement("label", { className: styles.label },
|
|
7
|
-
React.createElement("input", { ...props, name: props.name, disabled: props.disabled, placeholder: " ", type: props.type, value: props.value, className: joinedClassNames }),
|
|
7
|
+
React.createElement("input", { ...props, name: props.name, disabled: props.disabled, placeholder: " ", type: props.type, value: props.value, className: joinedClassNames, autoFocus: true }),
|
|
8
8
|
React.createElement("span", { className: styles.span }, props.placeholder)));
|
|
9
9
|
}
|
|
10
10
|
export default InputField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputField.js","sourceRoot":"","sources":["inputField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAY7C,SAAS,UAAU,CAAC,KAAsB;IACtC,MAAM,gBAAgB,GAAG,cAAc,CACnC,MAAM,CAAC,KAAK,EACZ,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EACvD,KAAK,CAAC,SAAU,CACnB,CAAC;IAEF,OAAO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