ar-design 0.3.67 → 0.3.69
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/dist/assets/css/components/form/input/otp/styles.css +20 -0
- package/dist/assets/css/components/form/input/{input.css → styles.css} +3 -0
- package/dist/components/data-display/table/Editable.js +1 -2
- package/dist/components/form/date-picker/Props.d.ts +2 -2
- package/dist/components/form/input/IProps.d.ts +2 -2
- package/dist/components/form/input/index.d.ts +8 -2
- package/dist/components/form/input/index.js +10 -5
- package/dist/components/form/{input-number → input/num}/IProps.d.ts +1 -1
- package/dist/components/form/input/num/index.d.ts +4 -0
- package/dist/components/form/{input-number → input/num}/index.js +5 -5
- package/dist/components/form/input/otp/IProps.d.ts +6 -0
- package/dist/components/form/input/otp/IProps.js +1 -0
- package/dist/components/form/input/otp/Otp.d.ts +7 -0
- package/dist/components/form/input/otp/Otp.js +67 -0
- package/dist/components/form/input-tag/IProps.d.ts +2 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/package.json +1 -1
- package/dist/components/form/input-number/index.d.ts +0 -4
- /package/dist/components/form/{input-number → input/num}/IProps.js +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.ar-input-otp-wrapper {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row;
|
|
4
|
+
flex-wrap: nowrap;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: 0.5rem;
|
|
8
|
+
|
|
9
|
+
> span {
|
|
10
|
+
> .ar-input-wrapper {
|
|
11
|
+
> .ar-input {
|
|
12
|
+
> .input {
|
|
13
|
+
> input {
|
|
14
|
+
text-align: center !important;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -3,7 +3,6 @@ import React, { useState } from "react";
|
|
|
3
3
|
import Input from "../../form/input";
|
|
4
4
|
import DatePicker from "../../form/date-picker";
|
|
5
5
|
import Select from "../../form/select";
|
|
6
|
-
import InputNumber from "../../form/input-number";
|
|
7
6
|
const Editable = function ({ c, item, index, onEditable, validation }) {
|
|
8
7
|
const key = c.key;
|
|
9
8
|
const itemValue = item[c.key];
|
|
@@ -23,7 +22,7 @@ const Editable = function ({ c, item, index, onEditable, validation }) {
|
|
|
23
22
|
onEditable({ ...item, [key]: c.editable?.type === "number" ? Number(value) : value }, index);
|
|
24
23
|
}, validation: { text: _vText } }));
|
|
25
24
|
case "input-number":
|
|
26
|
-
return (React.createElement(
|
|
25
|
+
return (React.createElement(Input.Number, { variant: "borderless", name: c.key, value: value, onChange: (event) => {
|
|
27
26
|
const { value } = event.target;
|
|
28
27
|
setValue(value);
|
|
29
28
|
onEditable({ ...item, [key]: c.editable?.type === "number" ? Number(value) : value }, index);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IBorder, IColors,
|
|
1
|
+
import { IBorder, IColors, IStatus, IValidation, IVariant } from "../../../libs/types/IGlobalProps";
|
|
2
2
|
type Props = {
|
|
3
3
|
label?: string;
|
|
4
4
|
isClock?: boolean;
|
|
5
5
|
onChange: (value: string) => void;
|
|
6
|
-
} & IVariant & IColors & IStatus & IBorder &
|
|
6
|
+
} & IVariant & IColors & IStatus & IBorder & IValidation & Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "onChange" | "color">;
|
|
7
7
|
export default Props;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import IButtonProps from "../button/IProps";
|
|
2
2
|
import { Variants } from "../../../libs/types";
|
|
3
|
-
import { IBorder, IColors, IIcon,
|
|
4
|
-
interface IProps extends IVariant, IColors, IBorder, IIcon,
|
|
3
|
+
import { IBorder, IColors, IIcon, IUpperCase, IValidation, IVariant } from "../../../libs/types/IGlobalProps";
|
|
4
|
+
interface IProps extends IVariant, IColors, IBorder, IIcon, IUpperCase, IValidation, Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "color"> {
|
|
5
5
|
button?: Omit<IButtonProps, "size" | "shape" | "position" | "fullWidth">;
|
|
6
6
|
addon?: {
|
|
7
7
|
variant?: Variants;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import "../../../assets/css/components/form/input/
|
|
2
|
+
import "../../../assets/css/components/form/input/styles.css";
|
|
3
3
|
import IProps from "./IProps";
|
|
4
|
-
|
|
4
|
+
import Otp from "./otp/Otp";
|
|
5
|
+
import Num from "./num";
|
|
6
|
+
interface InputCompound extends React.ForwardRefExoticComponent<IProps & React.RefAttributes<HTMLInputElement>> {
|
|
7
|
+
Number: typeof Num;
|
|
8
|
+
Otp: typeof Otp;
|
|
9
|
+
}
|
|
10
|
+
declare const Input: InputCompound;
|
|
5
11
|
export default Input;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
3
|
-
import "../../../assets/css/components/form/input/
|
|
3
|
+
import "../../../assets/css/components/form/input/styles.css";
|
|
4
4
|
import Button from "../button";
|
|
5
5
|
import Utils from "../../../libs/infrastructure/shared/Utils";
|
|
6
6
|
import { ARIcon } from "../../icons";
|
|
7
|
-
|
|
7
|
+
import Otp from "./otp/Otp";
|
|
8
|
+
import Num from "./num";
|
|
9
|
+
const BaseInput = forwardRef(({ variant = "outlined", color = "light", icon, border = { radius: "sm" }, button, addon, upperCase, validation, ...attributes }, ref) => {
|
|
8
10
|
// refs
|
|
9
11
|
const _innerRef = useRef(null);
|
|
10
12
|
const _label = useRef(null);
|
|
@@ -18,7 +20,7 @@ const Input = forwardRef(({ variant = "outlined", color = "light", size = "norma
|
|
|
18
20
|
const _inputClassName = [];
|
|
19
21
|
const _addonBeforeClassName = ["addon-before"];
|
|
20
22
|
const _addonAfterClassName = ["addon-after"];
|
|
21
|
-
_inputClassName.push(...Utils.GetClassName(variant, undefined, !Utils.IsNullOrEmpty(validation?.text) ? "red" : color, border,
|
|
23
|
+
_inputClassName.push(...Utils.GetClassName(variant, undefined, !Utils.IsNullOrEmpty(validation?.text) ? "red" : color, border, undefined, icon, attributes.className));
|
|
22
24
|
// addon className
|
|
23
25
|
if (addon) {
|
|
24
26
|
_wrapperClassName.push("addon");
|
|
@@ -75,7 +77,7 @@ const Input = forwardRef(({ variant = "outlined", color = "light", size = "norma
|
|
|
75
77
|
validation && "* ",
|
|
76
78
|
attributes.placeholder)),
|
|
77
79
|
React.createElement("div", { className: "input" },
|
|
78
|
-
React.createElement("input", { ref: _innerRef, ...attributes, type: attributes.type === "number" ? "text" : attributes.type, placeholder: `${validation ? "* " : ""}${attributes.placeholder ?? ""}`, value: value ?? attributes.value, size: 20, className: _inputClassName.map((c) => c).join(" "), ...(attributes.type === "number"
|
|
80
|
+
React.createElement("input", { ref: _innerRef, ...attributes, type: attributes.type === "number" ? "text" : attributes.type, placeholder: `${validation ? "* " : ""}${attributes.placeholder ?? ""}`, value: value ?? attributes.value, size: attributes.size || 20, className: _inputClassName.map((c) => c).join(" "), ...(attributes.type === "number"
|
|
79
81
|
? {
|
|
80
82
|
onKeyDown: (event) => {
|
|
81
83
|
const allowedKeys = ["Backspace", "Tab", "ArrowLeft", "ArrowRight", "Delete"];
|
|
@@ -138,5 +140,8 @@ const Input = forwardRef(({ variant = "outlined", color = "light", size = "norma
|
|
|
138
140
|
addon?.after && React.createElement("span", { className: _addonAfterClassName.map((c) => c).join(" ") }, addon?.after),
|
|
139
141
|
button && React.createElement(Button, { ...button, border: { radius: border.radius }, disabled: attributes.disabled })));
|
|
140
142
|
});
|
|
141
|
-
Input
|
|
143
|
+
const Input = BaseInput;
|
|
144
|
+
Input.Otp = Otp;
|
|
145
|
+
Input.Number = Num;
|
|
146
|
+
BaseInput.displayName = "Input";
|
|
142
147
|
export default Input;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBorder, IColors, IDisabled, IPlaceholder, IUpperCase, IValidation, IVariant } from "
|
|
1
|
+
import { IBorder, IColors, IDisabled, IPlaceholder, IUpperCase, IValidation, IVariant } from "../../../../libs/types/IGlobalProps";
|
|
2
2
|
interface IProps extends IVariant, IColors, IBorder, IUpperCase, IValidation, IPlaceholder, IDisabled {
|
|
3
3
|
name: string;
|
|
4
4
|
value: string | number | readonly string[] | undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import Input from "
|
|
4
|
-
import { NUMBER } from "
|
|
5
|
-
const
|
|
3
|
+
import Input from "..";
|
|
4
|
+
import { NUMBER } from "../../../../libs/infrastructure/shared";
|
|
5
|
+
const Num = ({ variant, color, name, value, onChange, locale = "tr-TR", digits, placeholder, validation, disabled, }) => {
|
|
6
6
|
// refs
|
|
7
7
|
// const _firstLoad = useRef<boolean>(false);
|
|
8
8
|
const _input = useRef(null);
|
|
@@ -71,7 +71,7 @@ const InputNumber = ({ variant, color, name, value, onChange, locale = "tr-TR",
|
|
|
71
71
|
// setValue(getFormatter.format(Number(value)));
|
|
72
72
|
// _firstLoad.current = true;
|
|
73
73
|
// }
|
|
74
|
-
setValue(getFormatter.format(Number(value)));
|
|
74
|
+
setValue(getFormatter.format(window.Number(value)));
|
|
75
75
|
}, [value]);
|
|
76
76
|
return (React.createElement(Input, { ref: _input, name: name, variant: variant, color: color, value: _value ?? "", type: "text", inputMode: "decimal", onChange: (event) => {
|
|
77
77
|
// Disabled gelmesi durumunda işlem yapmasına izin verme...
|
|
@@ -80,4 +80,4 @@ const InputNumber = ({ variant, color, name, value, onChange, locale = "tr-TR",
|
|
|
80
80
|
handleChange(event);
|
|
81
81
|
}, onClick: handleClick, onKeyUp: handleKeyUp, placeholder: placeholder, validation: validation, disabled: disabled }));
|
|
82
82
|
};
|
|
83
|
-
export default
|
|
83
|
+
export default Num;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IColors, IVariant } from "../../../../libs/types/IGlobalProps";
|
|
2
|
+
interface IProps extends IVariant, IColors, Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "color"> {
|
|
3
|
+
character: number;
|
|
4
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
5
|
+
}
|
|
6
|
+
export default IProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { useRef, useCallback } from "react";
|
|
3
|
+
import Input from "..";
|
|
4
|
+
const Otp = ({ character, onChange, ...attributes }) => {
|
|
5
|
+
// refs
|
|
6
|
+
const _inputs = useRef([]);
|
|
7
|
+
const _value = useRef({});
|
|
8
|
+
// methods
|
|
9
|
+
const handleInput = useCallback((index) => (event) => {
|
|
10
|
+
if (attributes.disabled)
|
|
11
|
+
return;
|
|
12
|
+
let { value } = event.currentTarget;
|
|
13
|
+
_value.current = { ..._value.current, [index]: value };
|
|
14
|
+
if (value.length >= 1) {
|
|
15
|
+
_inputs.current[index + 1]?.focus();
|
|
16
|
+
_inputs.current[index + 1]?.select();
|
|
17
|
+
}
|
|
18
|
+
onChange?.({
|
|
19
|
+
...event,
|
|
20
|
+
target: {
|
|
21
|
+
...event.currentTarget,
|
|
22
|
+
name: attributes.name ?? "",
|
|
23
|
+
value: Object.keys(_value.current)
|
|
24
|
+
.sort((a, b) => Number(a) - Number(b))
|
|
25
|
+
.map((key) => _value.current[Number(key)])
|
|
26
|
+
.join(""),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}, [onChange, attributes.name, attributes.disabled]);
|
|
30
|
+
const handleKeyUp = useCallback((index) => (event) => {
|
|
31
|
+
const input = event.currentTarget;
|
|
32
|
+
const { value } = input;
|
|
33
|
+
const lastChar = value.slice(-1);
|
|
34
|
+
event.currentTarget.value = lastChar;
|
|
35
|
+
if (event.key === "Backspace" && value.length === 0) {
|
|
36
|
+
_inputs.current[index - 1]?.focus();
|
|
37
|
+
_inputs.current[index - 1]?.select();
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
40
|
+
const handleKeyDown = (index) => (event) => {
|
|
41
|
+
if (index === 0 && (event.key === "ArrowDown" || event.key === "ArrowLeft"))
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
if (index + 1 >= character && (event.key === "ArrowUp" || event.key === "ArrowRight"))
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
if (!/[0-9]/.test(event.key) && event.key.length === 1)
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
if (event.key === "ArrowDown" || event.key === "ArrowLeft") {
|
|
48
|
+
_inputs.current[index - 1]?.focus();
|
|
49
|
+
setTimeout(() => _inputs.current[index - 1]?.select(), 0);
|
|
50
|
+
}
|
|
51
|
+
else if (event.key === "ArrowUp" || event.key === "ArrowRight") {
|
|
52
|
+
_inputs.current[index + 1]?.focus();
|
|
53
|
+
setTimeout(() => _inputs.current[index + 1]?.select(), 0);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const handleClick = useCallback((event) => {
|
|
57
|
+
const input = event.currentTarget;
|
|
58
|
+
if (document.activeElement === input)
|
|
59
|
+
input.select();
|
|
60
|
+
}, []);
|
|
61
|
+
return (React.createElement("div", { className: "ar-input-otp-wrapper" }, Array.from({ length: character }, (_, index) => (React.createElement("span", { key: index },
|
|
62
|
+
React.createElement(Input, { ref: (el) => {
|
|
63
|
+
_inputs.current[index] = el;
|
|
64
|
+
}, ...attributes, value: _value.current[index] ?? "", onInput: handleInput(index), onKeyUp: handleKeyUp(index), onKeyDown: handleKeyDown(index), onFocus: (event) => event.target.select(), onClick: handleClick, size: 1, placeholder: undefined, autoFocus: index === 0, autoComplete: "off" }))))));
|
|
65
|
+
};
|
|
66
|
+
Otp.displayName = "Input.Otp";
|
|
67
|
+
export default Otp;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBorder, IIcon,
|
|
2
|
-
interface IProps extends IVariant, IStatus, IBorder, IIcon,
|
|
1
|
+
import { IBorder, IIcon, IStatus, IUpperCase, IValidation, IVariant } from "../../../libs/types/IGlobalProps";
|
|
2
|
+
interface IProps extends IVariant, IStatus, IBorder, IIcon, IUpperCase, IValidation, Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "color"> {
|
|
3
3
|
}
|
|
4
4
|
export default IProps;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import ButtonGroup from "./components/form/button-group";
|
|
|
5
5
|
import Checkbox from "./components/form/checkbox";
|
|
6
6
|
import DatePicker from "./components/form/date-picker";
|
|
7
7
|
import Input from "./components/form/input";
|
|
8
|
-
import InputNumber from "./components/form/input-number";
|
|
9
8
|
import InputTag from "./components/form/input-tag";
|
|
10
9
|
import Radio from "./components/form/radio";
|
|
11
10
|
import Select from "./components/form/select";
|
|
@@ -35,4 +34,4 @@ import Pagination from "./components/navigation/pagination";
|
|
|
35
34
|
import Steps from "./components/navigation/steps";
|
|
36
35
|
import Grid from "./components/data-display/grid-system";
|
|
37
36
|
import Layout from "./components/layout";
|
|
38
|
-
export { Button, ButtonAction, ButtonGroup, Checkbox, DatePicker, Input,
|
|
37
|
+
export { Button, ButtonAction, ButtonGroup, Checkbox, DatePicker, Input, InputTag, Radio, Select, Switch, TextEditor, Upload, Card, Chip, Diagram, Divider, DnD, KanbanBoard, Paper, SyntaxHighlighter, Table, Tabs, Typography, Alert, Drawer, Modal, Popover, Progress, Tooltip, Breadcrumb, Menu, Pagination, Steps, Grid, Layout, };
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,6 @@ import ButtonGroup from "./components/form/button-group";
|
|
|
6
6
|
import Checkbox from "./components/form/checkbox";
|
|
7
7
|
import DatePicker from "./components/form/date-picker";
|
|
8
8
|
import Input from "./components/form/input";
|
|
9
|
-
import InputNumber from "./components/form/input-number";
|
|
10
9
|
import InputTag from "./components/form/input-tag";
|
|
11
10
|
import Radio from "./components/form/radio";
|
|
12
11
|
import Select from "./components/form/select";
|
|
@@ -42,7 +41,7 @@ import Grid from "./components/data-display/grid-system";
|
|
|
42
41
|
import Layout from "./components/layout";
|
|
43
42
|
export {
|
|
44
43
|
// Form Elements
|
|
45
|
-
Button, ButtonAction, ButtonGroup, Checkbox, DatePicker, Input,
|
|
44
|
+
Button, ButtonAction, ButtonGroup, Checkbox, DatePicker, Input, InputTag, Radio, Select, Switch, TextEditor, Upload,
|
|
46
45
|
// Data Display
|
|
47
46
|
Card, Chip, Diagram, Divider, DnD, KanbanBoard, Paper, SyntaxHighlighter, Table, Tabs, Typography,
|
|
48
47
|
// Feedback
|
package/package.json
CHANGED
|
File without changes
|