@yakad/ui 1.2.79-beta → 1.2.81-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.
@@ -3,6 +3,7 @@ interface CodeFieldsProps extends React.HTMLAttributes<HTMLInputElement> {
3
3
  length?: number;
4
4
  name?: string;
5
5
  type?: string;
6
+ size?: "small" | "medium" | "large";
6
7
  }
7
- declare function CodeField(props: CodeFieldsProps): JSX.Element;
8
+ declare function CodeField(this: any, props: CodeFieldsProps): JSX.Element;
8
9
  export default CodeField;
@@ -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) {
5
- const joinedClassNames = joinClassNames(styles.input, props.className);
12
+ const length = props.length ? props.length : 6;
13
+ const joinedClassNames = joinClassNames(styles.input, props.size ? styles[props.size] : styles.medium, props.className);
6
14
  const joinedStyles = joinStyles({ width: "calc(1.5ch * " + props.length + ")" }, props.style);
7
- return (React.createElement("input", { ...props, name: props.name, type: props.type, minLength: props.length, maxLength: props.length, className: joinedClassNames, style: joinedStyles }));
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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,GAAW,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvD,MAAM,gBAAgB,GAAG,cAAc,CACnC,MAAM,CAAC,KAAK,EACZ,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAC/C,KAAK,CAAC,SAAU,CACnB,CAAC;IAEF,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"}
@@ -3,8 +3,7 @@
3
3
  display: block;
4
4
  border: none;
5
5
  padding: 0;
6
- margin: 0;
7
- margin-left: 0.5ch;
6
+ margin: auto;
8
7
  background: repeating-linear-gradient(
9
8
  90deg,
10
9
  #7d7d7d 0,
@@ -15,9 +14,22 @@
15
14
  0 100%/100% 0.2rem no-repeat;
16
15
  color: transparent;
17
16
  text-shadow: 0 0 0 rgb(var(--secondaryColor, 98 91 113));
18
- font: 5ch consolas, monospace;
19
17
  letter-spacing: 0.5ch;
20
18
  }
21
19
  .input:focus {
22
20
  outline: none;
23
21
  }
22
+ input::-webkit-outer-spin-button,
23
+ input::-webkit-inner-spin-button {
24
+ -webkit-appearance: none;
25
+ margin: 0;
26
+ }
27
+ .small {
28
+ font: 5ch consolas, monospace;
29
+ }
30
+ .medium {
31
+ font: 7ch consolas, monospace;
32
+ }
33
+ .large {
34
+ font: 11ch consolas, monospace;
35
+ }
@@ -6,10 +6,29 @@ interface CodeFieldsProps extends React.HTMLAttributes<HTMLInputElement> {
6
6
  length?: number;
7
7
  name?: string;
8
8
  type?: string;
9
+ size?: "small" | "medium" | "large";
9
10
  }
10
11
 
11
- function CodeField(props: CodeFieldsProps) {
12
- const joinedClassNames = joinClassNames(styles.input, props.className!);
12
+ function sliceOverLength(
13
+ event: React.FormEvent<HTMLInputElement>,
14
+ length: number
15
+ ) {
16
+ const targetInput = event.target as HTMLInputElement;
17
+ const targetLength = targetInput.value.length;
18
+ if (targetLength > length)
19
+ targetInput.value = targetInput.value.slice(0, targetLength - 1);
20
+
21
+ targetInput.value = targetInput.value.replace(/[^0-9]+/, "");
22
+ }
23
+
24
+ function CodeField(this: any, props: CodeFieldsProps) {
25
+ const length: number = props.length ? props.length : 6;
26
+
27
+ const joinedClassNames = joinClassNames(
28
+ styles.input,
29
+ props.size ? styles[props.size] : styles.medium,
30
+ props.className!
31
+ );
13
32
 
14
33
  const joinedStyles = joinStyles(
15
34
  { width: "calc(1.5ch * " + props.length + ")" },
@@ -18,13 +37,15 @@ function CodeField(props: CodeFieldsProps) {
18
37
 
19
38
  return (
20
39
  <input
21
- {...props}
22
40
  name={props.name}
23
- type={props.type}
24
- minLength={props.length}
25
- maxLength={props.length}
41
+ type="number"
42
+ minLength={length}
43
+ maxLength={length}
26
44
  className={joinedClassNames}
27
45
  style={joinedStyles}
46
+ onInput={(event) => sliceOverLength(event, length)}
47
+ autoComplete="off"
48
+ pattern="[0-9]"
28
49
  />
29
50
  );
30
51
  }
@@ -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,CACH,+BAAO,SAAS,EAAE,MAAM,CAAC,KAAK;QAC1B,kCACQ,KAAK,EACT,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,WAAW,EAAC,IAAI,EAChB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,SAAS,EAAE,gBAAgB,GAC7B;QACF,8BAAM,SAAS,EAAE,MAAM,CAAC,IAAI,IAAG,KAAK,CAAC,WAAW,CAAQ,CACpD,CACX,CAAC;AACN,CAAC;AAED,eAAe,UAAU,CAAC"}
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,CACH,+BAAO,SAAS,EAAE,MAAM,CAAC,KAAK;QAC1B,kCACQ,KAAK,EACT,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,WAAW,EAAC,IAAI,EAChB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,SAAS,EAAE,gBAAgB,EAC3B,SAAS,SACX;QACF,8BAAM,SAAS,EAAE,MAAM,CAAC,IAAI,IAAG,KAAK,CAAC,WAAW,CAAQ,CACpD,CACX,CAAC;AACN,CAAC;AAED,eAAe,UAAU,CAAC"}
@@ -29,6 +29,7 @@ function InputField(props: InputFieldProps) {
29
29
  type={props.type}
30
30
  value={props.value}
31
31
  className={joinedClassNames}
32
+ autoFocus
32
33
  />
33
34
  <span className={styles.span}>{props.placeholder}</span>
34
35
  </label>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yakad/ui",
3
- "version": "1.2.79-beta",
3
+ "version": "1.2.81-beta",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {