@harjs/react-ui 1.1.5 → 1.1.6
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/charts/gantt/styles.css +6 -6
- package/dist/assets/css/components/charts/pie/pie.css +7 -7
- package/dist/assets/css/components/data-display/calendar/styles.week-view.css +8 -6
- package/dist/assets/css/components/data-display/card/css.cjs +47 -0
- package/dist/assets/css/components/data-display/card/radius.css +41 -0
- package/dist/assets/css/components/data-display/card/status.css +929 -0
- package/dist/assets/css/components/data-display/card/styles.css +3 -6
- package/dist/assets/css/components/data-display/card/templates/radius.template.css +3 -0
- package/dist/assets/css/components/data-display/card/templates/status.template.css +47 -0
- package/dist/assets/css/components/data-display/diagram/styles.css +14 -10
- package/dist/assets/css/components/data-display/dnd/shadow.css +2 -2
- package/dist/assets/css/components/data-display/dnd/styles.css +3 -3
- package/dist/assets/css/components/data-display/grid-system/flex/styles.css +65 -0
- package/dist/assets/css/components/data-display/grid-system/styles.css +3 -0
- package/dist/assets/css/components/data-display/kanban-board/styles.css +16 -16
- package/dist/assets/css/components/data-display/paper/styles.css +3 -3
- package/dist/assets/css/components/data-display/syntax-highlighter/syntax-highlighter.css +3 -3
- package/dist/assets/css/components/data-display/table/filter-popup.css +6 -4
- package/dist/assets/css/components/data-display/table/properties-popup.css +3 -3
- package/dist/assets/css/components/data-display/table/scroll.css +1 -0
- package/dist/assets/css/components/data-display/table/styles.css +47 -46
- package/dist/assets/css/components/data-display/tabs/tabs.css +8 -8
- package/dist/assets/css/components/data-display/typography/paragraph/color.css +76 -50
- package/dist/assets/css/components/data-display/typography/paragraph/css.cjs +61 -0
- package/dist/assets/css/components/data-display/typography/paragraph/size.css +25 -7
- package/dist/assets/css/components/data-display/typography/paragraph/templates/color.template.css +3 -0
- package/dist/assets/css/components/data-display/typography/paragraph/templates/size.template.css +4 -0
- package/dist/assets/css/components/data-display/typography/title/core.css +0 -1
- package/dist/assets/css/components/feedback/alert/styles.css +8 -8
- package/dist/assets/css/components/feedback/drawer/content.css +9 -6
- package/dist/assets/css/components/feedback/drawer/css.cjs +38 -0
- package/dist/assets/css/components/feedback/drawer/header.css +68 -52
- package/dist/assets/css/components/feedback/drawer/radius.css +53 -0
- package/dist/assets/css/components/feedback/drawer/size.css +33 -0
- package/dist/assets/css/components/feedback/drawer/styles.css +68 -73
- package/dist/assets/css/components/feedback/drawer/templates/radius.template.css +4 -0
- package/dist/assets/css/components/feedback/drawer/templates/size.template.css +4 -0
- package/dist/assets/css/components/feedback/loading/loading.css +23 -11
- package/dist/assets/css/components/feedback/modal/content.css +15 -5
- package/dist/assets/css/components/feedback/modal/css.cjs +41 -0
- package/dist/assets/css/components/feedback/modal/footer.css +12 -8
- package/dist/assets/css/components/feedback/modal/header.css +66 -54
- package/dist/assets/css/components/feedback/modal/radius.css +43 -0
- package/dist/assets/css/components/feedback/modal/size.css +27 -0
- package/dist/assets/css/components/feedback/modal/styles.css +31 -40
- package/dist/assets/css/components/feedback/modal/templates/radius.template.css +3 -0
- package/dist/assets/css/components/feedback/modal/templates/size.template.css +3 -0
- package/dist/assets/css/components/feedback/notification/notification.css +6 -6
- package/dist/assets/css/components/feedback/popover/styles.css +6 -4
- package/dist/assets/css/components/feedback/popup-confirm/styles.css +5 -5
- package/dist/assets/css/components/feedback/progress/progress.css +6 -5
- package/dist/assets/css/components/feedback/tooltip/styles.css +3 -3
- package/dist/assets/css/components/form/button/color.css +1081 -0
- package/dist/assets/css/components/form/button/css.cjs +43 -0
- package/dist/assets/css/components/form/button/icon.css +47 -0
- package/dist/assets/css/components/form/button/position.css +21 -0
- package/dist/assets/css/components/form/button/radius.css +41 -0
- package/dist/assets/css/components/form/button/shape.css +8 -0
- package/dist/assets/css/components/form/button/size.css +67 -0
- package/dist/assets/css/components/form/button/styles.css +31 -17
- package/dist/assets/css/components/form/button/templates/color.template.css +107 -0
- package/dist/assets/css/components/form/button/templates/radius.template.css +3 -0
- package/dist/assets/css/components/form/button/templates/size.template.css +10 -0
- package/dist/assets/css/components/form/button-action/styles.css +18 -15
- package/dist/assets/css/components/form/button-group/styles.css +2 -23
- package/dist/assets/css/components/form/checkbox/checked.css +78 -0
- package/dist/assets/css/components/form/checkbox/color.checked.css +1031 -0
- package/dist/assets/css/components/form/checkbox/color.radio-checked.css +1161 -0
- package/dist/assets/css/components/form/checkbox/color.radio-unchecked.css +739 -0
- package/dist/assets/css/components/form/checkbox/color.unchecked.css +739 -0
- package/dist/assets/css/components/form/checkbox/css.cjs +61 -0
- package/dist/assets/css/components/form/checkbox/radius.css +41 -0
- package/dist/assets/css/components/form/checkbox/size.css +28 -0
- package/dist/assets/css/components/form/checkbox/styles.css +78 -0
- package/dist/assets/css/components/form/checkbox/templates/color.checked.template.css +101 -0
- package/dist/assets/css/components/form/checkbox/templates/color.radio-checked.template.css +114 -0
- package/dist/assets/css/components/form/checkbox/templates/color.radio-unchecked.template.css +72 -0
- package/dist/assets/css/components/form/checkbox/templates/color.unchecked.template.css +72 -0
- package/dist/assets/css/components/form/checkbox/templates/radius.template.css +3 -0
- package/dist/assets/css/components/form/checkbox/templates/size.template.css +8 -0
- package/dist/assets/css/components/form/checkbox-card/color.checked.css +755 -0
- package/dist/assets/css/components/form/checkbox-card/color.unchecked.css +753 -0
- package/dist/assets/css/components/form/checkbox-card/css.cjs +44 -0
- package/dist/assets/css/components/form/checkbox-card/radius.css +43 -0
- package/dist/assets/css/components/form/checkbox-card/styles.css +14 -0
- package/dist/assets/css/components/form/checkbox-card/templates/color.checked.template.css +74 -0
- package/dist/assets/css/components/form/checkbox-card/templates/color.unchecked.template.css +74 -0
- package/dist/assets/css/components/form/checkbox-card/templates/radius.template.css +3 -0
- package/dist/assets/css/components/form/checkbox-card/templates/size.template.css +8 -0
- package/dist/assets/css/components/form/date-picker/calendar/calendar.css +6 -4
- package/dist/assets/css/components/form/date-picker/calendar/content.css +12 -4
- package/dist/assets/css/components/form/date-picker/clock/clock.css +3 -3
- package/dist/assets/css/components/form/date-picker/clock/content.css +14 -5
- package/dist/assets/css/components/form/input/addon.css +131 -0
- package/dist/assets/css/components/form/input/color.css +1131 -0
- package/dist/assets/css/components/form/input/css.cjs +177 -0
- package/dist/assets/css/components/form/input/icon.css +52 -0
- package/dist/assets/css/components/form/input/radius.css +251 -0
- package/dist/assets/css/components/form/input/size.css +133 -0
- package/dist/assets/css/components/form/input/styles.css +37 -19
- package/dist/assets/css/components/form/input/templates/color.template.css +112 -0
- package/dist/assets/css/components/form/input/templates/radius.template.css +24 -0
- package/dist/assets/css/components/form/input/templates/size.template.css +21 -0
- package/dist/assets/css/components/form/select/options.css +12 -9
- package/dist/assets/css/components/form/select/styles.css +8 -14
- package/dist/assets/css/components/form/switch/styles.css +3 -3
- package/dist/assets/css/components/form/text-editor/styles.css +5 -11
- package/dist/assets/css/components/form/upload/dropzone.css +12 -12
- package/dist/assets/css/components/form/upload/list-and-gird.css +10 -10
- package/dist/assets/css/components/form/upload/styles.css +11 -11
- package/dist/assets/css/components/layout/layout.css +5 -5
- package/dist/assets/css/components/navigation/menu/styles.css +11 -11
- package/dist/assets/css/components/navigation/pagination/styles.css +20 -5
- package/dist/assets/css/components/navigation/steps/styles.css +9 -9
- package/dist/assets/css/components/navigation/wizard/styles.css +116 -0
- package/dist/assets/css/core/animation.css +1 -1
- package/dist/assets/css/core/color-palette.css +129 -95
- package/dist/assets/css/core/har-core.css +53 -0
- package/dist/assets/css/core/radius.css +12 -0
- package/dist/assets/css/core/space.css +27 -0
- package/dist/assets/css/core/stroke.css +10 -0
- package/dist/components/charts/gantt/index.js +19 -10
- package/dist/components/data-display/calendar/Header.js +3 -3
- package/dist/components/data-display/calendar/views/Week.js +1 -1
- package/dist/components/data-display/card/IProps.d.ts +4 -2
- package/dist/components/data-display/card/index.js +5 -3
- package/dist/components/data-display/chip/index.js +1 -1
- package/dist/components/data-display/diagram/index.js +2 -2
- package/dist/components/data-display/grid-system/flex/Flex.d.ts +4 -0
- package/dist/components/data-display/grid-system/flex/Flex.js +48 -0
- package/dist/components/data-display/grid-system/flex/IProps.d.ts +18 -0
- package/dist/components/data-display/grid-system/index.d.ts +1 -0
- package/dist/components/data-display/grid-system/index.js +2 -0
- package/dist/components/data-display/kanban-board/filter/DateFilters.js +1 -1
- package/dist/components/data-display/kanban-board/filter/SelectFilters.js +1 -1
- package/dist/components/data-display/table/THeadCell.js +1 -1
- package/dist/components/data-display/table/body/Editable.js +1 -1
- package/dist/components/data-display/table/body/TBody.js +1 -1
- package/dist/components/data-display/table/header/ActionButtons.js +13 -5
- package/dist/components/data-display/table/index.js +5 -3
- package/dist/components/data-display/typography/paragraph/IProps.d.ts +2 -2
- package/dist/components/data-display/typography/paragraph/Paragraph.js +2 -2
- package/dist/components/feedback/alert/index.js +1 -1
- package/dist/components/feedback/drawer/IProps.d.ts +5 -2
- package/dist/components/feedback/drawer/index.d.ts +1 -1
- package/dist/components/feedback/drawer/index.js +15 -12
- package/dist/components/feedback/modal/index.js +18 -23
- package/dist/components/feedback/popover/index.js +2 -2
- package/dist/components/feedback/popup-confirm/index.js +2 -2
- package/dist/components/feedback/progress/index.js +1 -1
- package/dist/components/form/button/index.js +12 -10
- package/dist/components/form/button-action/IProps.d.ts +10 -6
- package/dist/components/form/button-action/index.js +36 -17
- package/dist/components/form/button-group/Props.d.ts +6 -0
- package/dist/components/form/button-group/index.d.ts +3 -5
- package/dist/components/form/button-group/index.js +21 -7
- package/dist/components/form/checkbox/Props.d.ts +8 -0
- package/dist/components/form/checkbox/Props.js +1 -0
- package/dist/components/form/checkbox/index.d.ts +7 -3
- package/dist/components/form/checkbox/index.js +16 -7
- package/dist/components/form/checkbox-card/Props.d.ts +7 -0
- package/dist/components/form/checkbox-card/Props.js +1 -0
- package/dist/components/form/checkbox-card/index.d.ts +14 -0
- package/dist/components/form/checkbox-card/index.js +39 -0
- package/dist/components/form/checkbox-group/Props.d.ts +10 -0
- package/dist/components/form/checkbox-group/Props.js +1 -0
- package/dist/components/form/checkbox-group/index.d.ts +4 -0
- package/dist/components/form/checkbox-group/index.js +54 -0
- package/dist/components/form/date-picker/Props.d.ts +5 -4
- package/dist/components/form/date-picker/index.d.ts +2 -2
- package/dist/components/form/date-picker/index.js +33 -18
- package/dist/components/form/input/IProps.d.ts +4 -10
- package/dist/components/form/input/decimal/Decimal.js +21 -17
- package/dist/components/form/input/decimal/IProps.d.ts +3 -5
- package/dist/components/form/input/formatted-decimal/FormattedDecimal.js +16 -15
- package/dist/components/form/input/formatted-decimal/IProps.d.ts +3 -5
- package/dist/components/form/input/index.d.ts +9 -3
- package/dist/components/form/input/index.js +72 -40
- package/dist/components/form/input/phone/IProps.d.ts +3 -2
- package/dist/components/form/input/phone/Phone.js +15 -11
- package/dist/components/form/input/pin/IProps.d.ts +6 -0
- package/dist/components/form/input/pin/IProps.js +1 -0
- package/dist/components/form/input/pin/Pin.d.ts +7 -0
- package/dist/components/form/input/{otp/Otp.js → pin/Pin.js} +9 -9
- package/dist/components/form/radio/IProps.d.ts +3 -3
- package/dist/components/form/radio/index.d.ts +1 -2
- package/dist/components/form/radio/index.js +8 -22
- package/dist/components/form/radio-group/Props.d.ts +8 -0
- package/dist/components/form/radio-group/Props.js +1 -0
- package/dist/components/form/radio-group/index.d.ts +4 -0
- package/dist/components/form/radio-group/index.js +52 -0
- package/dist/components/form/select/Props.d.ts +3 -4
- package/dist/components/form/select/index.js +4 -4
- package/dist/components/form/switch/index.js +2 -2
- package/dist/components/form/text-editor/index.js +4 -4
- package/dist/components/form/upload/Dropzone.d.ts +1 -1
- package/dist/components/form/upload/Dropzone.js +6 -5
- package/dist/components/form/upload/List.js +3 -2
- package/dist/components/layout/LSider.js +1 -1
- package/dist/components/navigation/wizard/IProps.d.ts +34 -0
- package/dist/components/navigation/wizard/IProps.js +1 -0
- package/dist/components/navigation/wizard/index.d.ts +8 -0
- package/dist/components/navigation/wizard/index.js +138 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +7 -3
- package/dist/libs/core/application/locales/date-picker/IDatePickerLocale.d.ts +25 -0
- package/dist/libs/core/application/locales/date-picker/IDatePickerLocale.js +1 -0
- package/dist/libs/core/application/locales/date-picker/en.d.ts +3 -0
- package/dist/libs/core/application/locales/date-picker/en.js +25 -0
- package/dist/libs/core/application/locales/date-picker/tr.d.ts +3 -0
- package/dist/libs/core/application/locales/date-picker/tr.js +25 -0
- package/dist/libs/core/application/locales/wizard/IWizardLocale.d.ts +8 -0
- package/dist/libs/core/application/locales/wizard/IWizardLocale.js +1 -0
- package/dist/libs/core/application/locales/wizard/en.d.ts +3 -0
- package/dist/libs/core/application/locales/wizard/en.js +8 -0
- package/dist/libs/core/application/locales/wizard/tr.d.ts +3 -0
- package/dist/libs/core/application/locales/wizard/tr.js +8 -0
- package/dist/libs/infrastructure/shared/Utils.js +1 -1
- package/dist/libs/infrastructure/types/IGlobalProps.d.ts +10 -3
- package/dist/libs/infrastructure/types/index.d.ts +9 -6
- package/package.json +3 -1
- package/dist/assets/css/components/data-display/card/statuses.css +0 -377
- package/dist/assets/css/components/form/button/core/icon.css +0 -37
- package/dist/assets/css/components/form/button/core/position.css +0 -19
- package/dist/assets/css/components/form/button/core/shape.css +0 -13
- package/dist/assets/css/components/form/button/core/size.css +0 -14
- package/dist/assets/css/components/form/checkbox/checkbox.css +0 -53
- package/dist/assets/css/components/form/checkbox/core/border.css +0 -252
- package/dist/assets/css/components/form/input/core/addon.css +0 -11
- package/dist/assets/css/components/form/input/core/border.css +0 -114
- package/dist/assets/css/components/form/input/core/button.css +0 -34
- package/dist/assets/css/components/form/input/core/icon.css +0 -22
- package/dist/assets/css/components/form/input/otp/styles.css +0 -20
- package/dist/assets/css/components/form/input/phone/styles.css +0 -50
- package/dist/assets/css/components/form/radio/core/border.css +0 -252
- package/dist/assets/css/components/form/radio/radio.css +0 -69
- package/dist/assets/css/core/ar-core.css +0 -192
- package/dist/assets/css/core/variants/animation.css +0 -164
- package/dist/assets/css/core/variants/border.css +0 -18
- package/dist/assets/css/core/variants/borderless.css +0 -362
- package/dist/assets/css/core/variants/dashed.css +0 -362
- package/dist/assets/css/core/variants/filled.css +0 -428
- package/dist/assets/css/core/variants/outlined.css +0 -439
- package/dist/assets/css/core/variants/surface.css +0 -252
- package/dist/components/form/checkbox/IProps.d.ts +0 -5
- package/dist/components/form/input/otp/IProps.d.ts +0 -6
- package/dist/components/form/input/otp/Otp.d.ts +0 -7
- /package/dist/components/{form/checkbox → data-display/grid-system/flex}/IProps.js +0 -0
- /package/dist/components/form/{input/otp/IProps.js → button-group/Props.js} +0 -0
|
@@ -6,21 +6,9 @@ import Button from "../button";
|
|
|
6
6
|
import Alert from "../../feedback/alert";
|
|
7
7
|
import ReactDOM from "react-dom";
|
|
8
8
|
import DATE from "./DATE";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{ value: 1, text: "Şubat" },
|
|
13
|
-
{ value: 2, text: "Mart" },
|
|
14
|
-
{ value: 3, text: "Nisan" },
|
|
15
|
-
{ value: 4, text: "Mayıs" },
|
|
16
|
-
{ value: 5, text: "Haziran" },
|
|
17
|
-
{ value: 6, text: "Temmuz" },
|
|
18
|
-
{ value: 7, text: "Ağustos" },
|
|
19
|
-
{ value: 8, text: "Eylül" },
|
|
20
|
-
{ value: 9, text: "Ekim" },
|
|
21
|
-
{ value: 10, text: "Kasım" },
|
|
22
|
-
{ value: 11, text: "Aralık" },
|
|
23
|
-
];
|
|
9
|
+
import DatePickerTR from "../../../libs/core/application/locales/date-picker/tr";
|
|
10
|
+
import DatePickerEN from "../../../libs/core/application/locales/date-picker/en";
|
|
11
|
+
import { useTranslation } from "@harjs/translation";
|
|
24
12
|
const DatePicker = ({ variant, color, onChange, config, validation, ...attributes }) => {
|
|
25
13
|
// refs
|
|
26
14
|
const _arCalendar = useRef(null);
|
|
@@ -57,6 +45,33 @@ const DatePicker = ({ variant, color, onChange, config, validation, ...attribute
|
|
|
57
45
|
const [selectedDay, setSelectedDay] = useState(_currentDate.getDate());
|
|
58
46
|
const [selectedHours, setSelectedHours] = useState(_currentDate.getHours());
|
|
59
47
|
const [selectedMinutes, setSelectedMinutes] = useState(_currentDate.getMinutes());
|
|
48
|
+
const { t } = useTranslation(String(config?.locale ?? "tr"), {
|
|
49
|
+
tr: { ...DatePickerTR },
|
|
50
|
+
en: { ...DatePickerEN },
|
|
51
|
+
});
|
|
52
|
+
const weekdays = [
|
|
53
|
+
t("DatePicker.Mon"),
|
|
54
|
+
t("DatePicker.Tue"),
|
|
55
|
+
t("DatePicker.Wed"),
|
|
56
|
+
t("DatePicker.Thu"),
|
|
57
|
+
t("DatePicker.Fri"),
|
|
58
|
+
t("DatePicker.Sat"),
|
|
59
|
+
t("DatePicker.Sun"),
|
|
60
|
+
];
|
|
61
|
+
const months = [
|
|
62
|
+
{ value: 0, text: t("DatePicker.January") },
|
|
63
|
+
{ value: 1, text: t("DatePicker.February") },
|
|
64
|
+
{ value: 2, text: t("DatePicker.March") },
|
|
65
|
+
{ value: 3, text: t("DatePicker.April") },
|
|
66
|
+
{ value: 4, text: t("DatePicker.May") },
|
|
67
|
+
{ value: 5, text: t("DatePicker.June") },
|
|
68
|
+
{ value: 6, text: t("DatePicker.July") },
|
|
69
|
+
{ value: 7, text: t("DatePicker.August") },
|
|
70
|
+
{ value: 8, text: t("DatePicker.September") },
|
|
71
|
+
{ value: 9, text: t("DatePicker.October") },
|
|
72
|
+
{ value: 10, text: t("DatePicker.November") },
|
|
73
|
+
{ value: 11, text: t("DatePicker.December") },
|
|
74
|
+
];
|
|
60
75
|
// methods
|
|
61
76
|
const handleClickOutSide = (event) => {
|
|
62
77
|
const target = event.target;
|
|
@@ -134,7 +149,7 @@ const DatePicker = ({ variant, color, onChange, config, validation, ...attribute
|
|
|
134
149
|
onChange(inputDate.toISOString());
|
|
135
150
|
};
|
|
136
151
|
const okayButton = () => {
|
|
137
|
-
return (React.createElement(Button, { variant: "borderless", color: "green", onClick: () => handleOk() }, "
|
|
152
|
+
return (React.createElement(Button, { variant: "borderless", color: "green", onClick: () => handleOk() }, t("DatePicker.Button.Okay")));
|
|
138
153
|
};
|
|
139
154
|
const closeCalendar = () => {
|
|
140
155
|
const { year, month, day, hours, minutes } = DATE.Parse(String(attributes.value), config?.isClock);
|
|
@@ -346,10 +361,10 @@ const DatePicker = ({ variant, color, onChange, config, validation, ...attribute
|
|
|
346
361
|
} })))),
|
|
347
362
|
React.createElement("div", { className: "content" }, !isNaN(_month.current) && !isNaN(_year.current) ? (React.createElement("div", { className: "calendar" },
|
|
348
363
|
React.createElement("div", { className: "weekdays" }, weekdays.map((weekday, index) => (React.createElement("span", { key: index }, weekday)))),
|
|
349
|
-
React.createElement("div", { className: "days" }, calendarDays))) : (React.createElement(Alert, { status: "warning" }, "
|
|
364
|
+
React.createElement("div", { className: "days" }, calendarDays))) : (React.createElement(Alert, { status: "warning" }, t("DatePicker.Alert.1.Text")))),
|
|
350
365
|
config?.isFooterButton && (React.createElement("div", { ref: _calendarFooter, className: "footer" },
|
|
351
366
|
React.createElement("div", null,
|
|
352
|
-
React.createElement(Button, { variant: "borderless", onClick: () => setNowButton() }, "
|
|
367
|
+
React.createElement(Button, { variant: "borderless", onClick: () => setNowButton() }, t("DatePicker.Button.Now"))),
|
|
353
368
|
React.createElement("div", null, !config?.isClock && okayButton()))),
|
|
354
369
|
config?.isClock && (React.createElement("div", { ref: _arClock, className: "clock" },
|
|
355
370
|
React.createElement("div", { ref: _clockHeader, className: "header" },
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
button?: Omit<IButtonProps, "size" | "shape" | "position" | "fullWidth">;
|
|
6
|
-
addon?: {
|
|
7
|
-
variant?: Variants;
|
|
8
|
-
before?: string | number;
|
|
9
|
-
after?: string | number;
|
|
10
|
-
};
|
|
1
|
+
import { IBorderProps, IChildrenProps, IColorProps, ISizeProps, IUpperCaseProps, IValidationProps, IVariantProps } from "../../../libs/infrastructure/types/IGlobalProps";
|
|
2
|
+
interface IProps extends IChildrenProps, IVariantProps<{
|
|
3
|
+
component: "input";
|
|
4
|
+
}>, IColorProps, IBorderProps, ISizeProps, IUpperCaseProps, IValidationProps, Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "color" | "size"> {
|
|
11
5
|
}
|
|
12
6
|
export default IProps;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React, { useRef, useState, useEffect, useMemo } from "react";
|
|
3
3
|
import Input from "..";
|
|
4
|
-
|
|
4
|
+
import Utils from "../../../../libs/infrastructure/shared/Utils";
|
|
5
|
+
const Decimal = ({ variant, color, validation, locale = "tr-TR", ...attributes }) => {
|
|
6
|
+
// refs
|
|
5
7
|
const _input = useRef(null);
|
|
8
|
+
const _lastEmitted = useRef(null);
|
|
9
|
+
// states
|
|
6
10
|
const [_value, setValue] = useState("");
|
|
7
11
|
// methods
|
|
8
12
|
const decimalSeparator = useMemo(() => {
|
|
@@ -11,44 +15,44 @@ const Decimal = ({ variant, color, name, value, onChange, placeholder, validatio
|
|
|
11
15
|
}, [locale]);
|
|
12
16
|
const handleChange = (event) => {
|
|
13
17
|
let inputValue = event.target.value;
|
|
14
|
-
// Locale’a göre izin verilen karakterler. (rakam, decimal, -)
|
|
15
18
|
const regex = new RegExp(`[^0-9\\${decimalSeparator}-]`, "g");
|
|
16
19
|
inputValue = inputValue.replace(regex, "");
|
|
17
|
-
// Sadece başta negatif işarete izin ver.
|
|
18
20
|
if (inputValue.includes("-")) {
|
|
19
21
|
inputValue = (inputValue.startsWith("-") ? "-" : "") + inputValue.replace(/-/g, "");
|
|
20
22
|
}
|
|
21
|
-
// Tek decimal separator’a izin ver.
|
|
22
23
|
const parts = inputValue.split(decimalSeparator);
|
|
23
24
|
if (parts.length > 2) {
|
|
24
25
|
inputValue = parts[0] + decimalSeparator + parts.slice(1).join("");
|
|
25
26
|
}
|
|
26
27
|
setValue(inputValue);
|
|
27
|
-
// Parent’a normalize edilmiş "." decimal gönder.
|
|
28
28
|
const normalized = inputValue.replace(decimalSeparator, ".");
|
|
29
|
-
|
|
29
|
+
_lastEmitted.current = normalized; // <-- ekle
|
|
30
|
+
attributes.onChange?.({
|
|
30
31
|
...event,
|
|
31
|
-
target: {
|
|
32
|
-
...event.target,
|
|
33
|
-
name,
|
|
34
|
-
value: normalized,
|
|
35
|
-
},
|
|
32
|
+
target: { ...event.target, value: normalized },
|
|
36
33
|
});
|
|
37
34
|
};
|
|
38
35
|
// useEffects
|
|
39
36
|
useEffect(() => {
|
|
40
|
-
if (value
|
|
37
|
+
if (Utils.IsNullOrEmpty(attributes.value)) {
|
|
41
38
|
setValue("");
|
|
42
39
|
return;
|
|
43
40
|
}
|
|
44
|
-
const stringValue = String(value);
|
|
41
|
+
const stringValue = String(attributes.value);
|
|
42
|
+
// Parent, az önce gönderdiğimiz değeri (farklı formatta da olsa) aynen
|
|
43
|
+
// yansıtıyorsa, kullanıcının henüz yazmakta olduğu local state'i ezme.
|
|
44
|
+
if (_lastEmitted.current !== null &&
|
|
45
|
+
!Number.isNaN(Number(stringValue)) &&
|
|
46
|
+
Number(stringValue) === Number(_lastEmitted.current)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
45
49
|
const localized = stringValue.replace(".", decimalSeparator);
|
|
46
50
|
setValue(localized);
|
|
47
|
-
}, [value, decimalSeparator]);
|
|
48
|
-
return (React.createElement(Input, { ref: _input,
|
|
49
|
-
if (disabled)
|
|
51
|
+
}, [attributes.value, decimalSeparator]);
|
|
52
|
+
return (React.createElement(Input, { ref: _input, variant: variant, color: color, type: "text", inputMode: "decimal", ...attributes, value: _value, onChange: (e) => {
|
|
53
|
+
if (attributes.disabled)
|
|
50
54
|
return;
|
|
51
55
|
handleChange(e);
|
|
52
|
-
},
|
|
56
|
+
}, validation: validation }));
|
|
53
57
|
};
|
|
54
58
|
export default Decimal;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: string | number | readonly string[] | undefined;
|
|
5
|
-
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import Input from "..";
|
|
3
|
+
interface IProps extends ComponentProps<typeof Input> {
|
|
6
4
|
locale?: Intl.LocalesArgument;
|
|
7
5
|
}
|
|
8
6
|
export default IProps;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import Input from "..";
|
|
4
4
|
import NUMBER from "../../../../libs/infrastructure/shared/NUMBER";
|
|
5
|
-
|
|
5
|
+
import Utils from "../../../../libs/infrastructure/shared/Utils";
|
|
6
|
+
const FormattedDecimal = ({ variant, color, locale = "tr-TR", digits, validation, ...attributes }) => {
|
|
6
7
|
const _input = useRef(null);
|
|
7
8
|
const [_value, setValue] = useState("");
|
|
8
9
|
// methods
|
|
@@ -47,27 +48,27 @@ const FormattedDecimal = ({ variant, color, name, value, onChange, locale = "tr-
|
|
|
47
48
|
const numericValue = isNaN(parsed) ? 0 : parsed;
|
|
48
49
|
const formatted = value === "" ? "" : getFormatter.format(numericValue);
|
|
49
50
|
setValue(formatted);
|
|
50
|
-
onChange?.({
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
});
|
|
51
|
+
// attributes.onChange?.({
|
|
52
|
+
// ...event,
|
|
53
|
+
// target: {
|
|
54
|
+
// ...event.target,
|
|
55
|
+
// // ...attributes.onChange,
|
|
56
|
+
// value: normalized,
|
|
57
|
+
// },
|
|
58
|
+
// });
|
|
58
59
|
};
|
|
59
60
|
// useEffects
|
|
60
61
|
useEffect(() => {
|
|
61
|
-
if (value
|
|
62
|
+
if (Utils.IsNullOrEmpty(attributes.value)) {
|
|
62
63
|
setValue("");
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
|
-
setValue(getFormatter.format(Number(value)));
|
|
66
|
-
}, [value, getFormatter]);
|
|
67
|
-
return (React.createElement(Input, { ref: _input,
|
|
68
|
-
if (disabled)
|
|
66
|
+
setValue(getFormatter.format(Number(attributes.value)));
|
|
67
|
+
}, [attributes.value, getFormatter]);
|
|
68
|
+
return (React.createElement(Input, { ref: _input, variant: variant, color: color, ...attributes, value: _value, type: "text", inputMode: "decimal", onChange: (event) => {
|
|
69
|
+
if (attributes.disabled)
|
|
69
70
|
return;
|
|
70
71
|
handleChange(event);
|
|
71
|
-
}, onClick: handleClick, onKeyUp: handleKeyUp,
|
|
72
|
+
}, onClick: handleClick, onKeyUp: handleKeyUp, validation: validation }));
|
|
72
73
|
};
|
|
73
74
|
export default FormattedDecimal;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: string | number | readonly string[] | undefined;
|
|
5
|
-
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import Input from "..";
|
|
3
|
+
interface IProps extends ComponentProps<typeof Input> {
|
|
6
4
|
locale?: Intl.LocalesArgument;
|
|
7
5
|
digits?: {
|
|
8
6
|
minimum?: number;
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { ComponentProps } from "react";
|
|
2
2
|
import "../../../assets/css/components/form/input/styles.css";
|
|
3
3
|
import IProps from "./IProps";
|
|
4
|
-
import Otp from "./otp/Otp";
|
|
5
4
|
import FormattedDecimal from "./formatted-decimal/FormattedDecimal";
|
|
6
5
|
import Phone from "./phone/Phone";
|
|
7
6
|
import Decimal from "./decimal/Decimal";
|
|
7
|
+
import { IChildrenProps } from "../../../libs/infrastructure/types/IGlobalProps";
|
|
8
|
+
import Pin from "./pin/Pin";
|
|
8
9
|
interface InputCompound extends React.ForwardRefExoticComponent<IProps & React.RefAttributes<HTMLInputElement>> {
|
|
10
|
+
AddonBefore: ({ children }: IChildrenProps) => React.JSX.Element;
|
|
11
|
+
AddonAfter: ({ children }: IChildrenProps) => React.JSX.Element;
|
|
12
|
+
Icon: ({ children, position }: ComponentProps<typeof Input> & {
|
|
13
|
+
position: "start" | "end";
|
|
14
|
+
}) => React.JSX.Element;
|
|
9
15
|
Decimal: typeof Decimal;
|
|
10
16
|
FormattedDecimal: typeof FormattedDecimal;
|
|
17
|
+
Pin: typeof Pin;
|
|
11
18
|
Phone: typeof Phone;
|
|
12
|
-
Otp: typeof Otp;
|
|
13
19
|
}
|
|
14
20
|
declare const Input: InputCompound;
|
|
15
21
|
export default Input;
|
|
@@ -1,38 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
2
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState, } from "react";
|
|
3
3
|
import "../../../assets/css/components/form/input/styles.css";
|
|
4
|
-
import Button from "../button";
|
|
5
4
|
import Utils from "../../../libs/infrastructure/shared/Utils";
|
|
6
5
|
import { ARIcon } from "../../icons";
|
|
7
|
-
import Otp from "./otp/Otp";
|
|
8
6
|
import FormattedDecimal from "./formatted-decimal/FormattedDecimal";
|
|
9
7
|
import Phone from "./phone/Phone";
|
|
10
8
|
import Decimal from "./decimal/Decimal";
|
|
11
|
-
|
|
9
|
+
import Pin from "./pin/Pin";
|
|
10
|
+
const BaseInput = forwardRef(({ children, variant = "outlined", color = "gray", border = { radius: "4" }, size = "md", upperCase, validation, ...attributes }, ref) => {
|
|
12
11
|
// refs
|
|
13
12
|
const _innerRef = useRef(null);
|
|
14
13
|
const _label = useRef(null);
|
|
15
14
|
// states
|
|
16
15
|
const [value, setValue] = useState("");
|
|
16
|
+
const [labelWidth, setLabelWidth] = useState(0);
|
|
17
17
|
// hooks
|
|
18
18
|
// Dışarıdan gelen ref'i _innerRef'e bağla.
|
|
19
19
|
useImperativeHandle(ref, () => _innerRef.current);
|
|
20
20
|
// variables
|
|
21
|
-
const _wrapperClassName = ["
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
_inputClassName.push(...Utils.GetClassName(variant, undefined, !Utils.IsNullOrEmpty(validation?.text) ? "red" : color, border, undefined, icon, attributes.className));
|
|
26
|
-
// addon className
|
|
27
|
-
if (addon) {
|
|
28
|
-
_wrapperClassName.push("addon");
|
|
29
|
-
_addonBeforeClassName.push(`${addon.variant || "filled"}`);
|
|
30
|
-
_addonBeforeClassName.push(`${status}`);
|
|
31
|
-
_addonAfterClassName.push(`${addon.variant || "filled"}`);
|
|
32
|
-
_addonAfterClassName.push(`${status}`);
|
|
33
|
-
_addonBeforeClassName.push(`border-radius-${border.radius}`);
|
|
34
|
-
_addonAfterClassName.push(`border-radius-${border.radius}`);
|
|
35
|
-
}
|
|
21
|
+
const _wrapperClassName = ["har-input-wrapper"];
|
|
22
|
+
_wrapperClassName.push(...Utils.GetClassName(variant, undefined, !Utils.IsNullOrEmpty(validation?.text) ? "red" : color, border, size, undefined, attributes.className));
|
|
23
|
+
if (attributes.disabled)
|
|
24
|
+
_wrapperClassName.push("disabled");
|
|
36
25
|
// methods
|
|
37
26
|
const handleNumberChange = (delta) => {
|
|
38
27
|
const current = Number(value) || 0;
|
|
@@ -49,6 +38,40 @@ const BaseInput = forwardRef(({ variant = "outlined", color = "light", icon, bor
|
|
|
49
38
|
},
|
|
50
39
|
});
|
|
51
40
|
};
|
|
41
|
+
const renderIcon = () => {
|
|
42
|
+
const iconElements = React.Children.toArray(children).filter((child) => {
|
|
43
|
+
return React.isValidElement(child) && child.type === Input.Icon;
|
|
44
|
+
});
|
|
45
|
+
if (iconElements.length === 0)
|
|
46
|
+
return null;
|
|
47
|
+
return iconElements.map((child) => {
|
|
48
|
+
if (React.isValidElement(child))
|
|
49
|
+
return React.cloneElement(child);
|
|
50
|
+
return child;
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const renderAddon = (position) => {
|
|
54
|
+
const addons = React.Children.toArray(children).filter((child) => {
|
|
55
|
+
return (React.isValidElement(child) && child.type === (position === "before" ? Input.AddonBefore : Input.AddonAfter));
|
|
56
|
+
});
|
|
57
|
+
if (addons.length === 0)
|
|
58
|
+
return null;
|
|
59
|
+
return addons.map((child, index) => {
|
|
60
|
+
const isFirst = index === 0;
|
|
61
|
+
const isLast = index === addons.length - 1 && addons.length > 1;
|
|
62
|
+
const isMiddle = !isFirst && !isLast;
|
|
63
|
+
if (React.isValidElement(child))
|
|
64
|
+
return (React.createElement("div", { className: [
|
|
65
|
+
`addon-${position}`,
|
|
66
|
+
position === "after" && isFirst && addons.length > 1 ? "n-first" : "first",
|
|
67
|
+
isMiddle && "middle",
|
|
68
|
+
isLast && "last",
|
|
69
|
+
]
|
|
70
|
+
.filter(Boolean)
|
|
71
|
+
.join(" ") }, React.cloneElement(child)));
|
|
72
|
+
return child;
|
|
73
|
+
});
|
|
74
|
+
};
|
|
52
75
|
// Özel büyük harfe dönüştürme işlevi.
|
|
53
76
|
const convertToUpperCase = (str) => {
|
|
54
77
|
return str
|
|
@@ -71,15 +94,21 @@ const BaseInput = forwardRef(({ variant = "outlined", color = "light", icon, bor
|
|
|
71
94
|
if (attributes.value !== undefined)
|
|
72
95
|
setValue(attributes.value ?? "");
|
|
73
96
|
}, [attributes.value]);
|
|
97
|
+
useLayoutEffect(() => {
|
|
98
|
+
if (_label.current) {
|
|
99
|
+
const width = _label.current.getBoundingClientRect().width;
|
|
100
|
+
setLabelWidth(width);
|
|
101
|
+
}
|
|
102
|
+
}, [value, attributes.placeholder]);
|
|
74
103
|
return (React.createElement("div", { className: _wrapperClassName.map((c) => c).join(" ") },
|
|
75
|
-
|
|
76
|
-
React.createElement("div", { className: "
|
|
77
|
-
|
|
78
|
-
attributes.placeholder && (React.createElement("label", { ref: _label, className: value ? "visible" : "hidden", ...(value ? { style: { maxWidth:
|
|
104
|
+
renderAddon("before"),
|
|
105
|
+
React.createElement("div", { className: "har-input" },
|
|
106
|
+
renderIcon() && React.createElement("div", { className: "icon-element" }, renderIcon()),
|
|
107
|
+
attributes.placeholder && (React.createElement("label", { ref: _label, className: value ? "visible" : "hidden", ...(value ? { style: { maxWidth: labelWidth } } : {}) },
|
|
79
108
|
validation && "* ",
|
|
80
109
|
attributes.placeholder)),
|
|
81
|
-
React.createElement("div", { className: "input" },
|
|
82
|
-
React.createElement("input", { ref: _innerRef, ...attributes, type: attributes.type === "number" ? "text" : attributes.type, placeholder: `${validation ? "* " : ""}${attributes.placeholder ?? ""}`, value: value ?? attributes.value,
|
|
110
|
+
React.createElement("div", { className: "input", style: { width: attributes.width } },
|
|
111
|
+
React.createElement("input", { ref: _innerRef, ...attributes, type: attributes.type === "number" ? "text" : attributes.type, placeholder: `${validation ? "* " : ""}${attributes.placeholder ?? ""}`, value: value ?? attributes.value, ...(attributes.type === "number"
|
|
83
112
|
? {
|
|
84
113
|
onKeyDown: (event) => {
|
|
85
114
|
const allowedKeys = ["Backspace", "Tab", "ArrowLeft", "ArrowRight", "Delete"];
|
|
@@ -88,24 +117,23 @@ const BaseInput = forwardRef(({ variant = "outlined", color = "light", icon, bor
|
|
|
88
117
|
event.preventDefault();
|
|
89
118
|
},
|
|
90
119
|
}
|
|
91
|
-
: {}), ...(value
|
|
120
|
+
: {}), ...(value && labelWidth > 0 && attributes.placeholder
|
|
92
121
|
? {
|
|
93
122
|
style: {
|
|
94
123
|
...attributes.style,
|
|
95
124
|
clipPath: `polygon(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
125
|
+
-15px 0,
|
|
126
|
+
10px -5px,
|
|
127
|
+
10px 5px,
|
|
128
|
+
calc(${labelWidth}px + 7px) 5px,
|
|
129
|
+
calc(${labelWidth}px + 7px) -5px,
|
|
130
|
+
100% -70px,
|
|
131
|
+
calc(100% + 5px) calc(100% + 5px),
|
|
132
|
+
-5px calc(100% + 5px)
|
|
133
|
+
)`,
|
|
105
134
|
},
|
|
106
135
|
}
|
|
107
136
|
: { style: { ...attributes.style } }), onChange: (event) => {
|
|
108
|
-
// Disabled gelmesi durumunda işlem yapmasına izin verme...
|
|
109
137
|
if (attributes.disabled)
|
|
110
138
|
return;
|
|
111
139
|
(() => {
|
|
@@ -139,14 +167,18 @@ const BaseInput = forwardRef(({ variant = "outlined", color = "light", icon, bor
|
|
|
139
167
|
React.createElement(ARIcon, { icon: "ChevronUp", size: 12, fill: "var(--gray-500)" })),
|
|
140
168
|
React.createElement("span", { onClick: () => handleNumberChange(-1) },
|
|
141
169
|
React.createElement(ARIcon, { icon: "ChevronDown", size: 12, fill: "var(--gray-500)" }))))),
|
|
142
|
-
validation?.text && React.createElement("span", { className: "validation" }, validation.text)),
|
|
143
|
-
|
|
144
|
-
button && React.createElement(Button, { ...button, border: { radius: border.radius }, disabled: attributes.disabled })));
|
|
170
|
+
validation?.text && React.createElement("span", { className: "har-validation-text" }, validation.text)),
|
|
171
|
+
renderAddon("after")));
|
|
145
172
|
});
|
|
146
173
|
const Input = BaseInput;
|
|
174
|
+
Input.AddonBefore = ({ children }) => React.createElement(React.Fragment, null, children);
|
|
175
|
+
Input.AddonAfter = ({ children }) => React.createElement(React.Fragment, null, children);
|
|
176
|
+
Input.Icon = ({ children, position, ...attributes }) => {
|
|
177
|
+
return (React.createElement("span", { ...attributes, className: `icon ${position} ${attributes.className} ${attributes.onClick ? "cursor-pointer" : "cursor-text"}` }, children));
|
|
178
|
+
};
|
|
147
179
|
Input.Decimal = Decimal;
|
|
148
180
|
Input.FormattedDecimal = FormattedDecimal;
|
|
149
181
|
Input.Phone = Phone;
|
|
150
|
-
Input.
|
|
182
|
+
Input.Pin = Pin;
|
|
151
183
|
BaseInput.displayName = "Input";
|
|
152
184
|
export default Input;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IBorderProps, IColorProps, IValidationProps, IVariantProps } from "../../../../libs/infrastructure/types/IGlobalProps";
|
|
2
1
|
import { Option } from "../../../../libs/infrastructure/types";
|
|
3
|
-
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
import Input from "..";
|
|
4
|
+
interface IProps extends ComponentProps<typeof Input> {
|
|
4
5
|
options?: Option[];
|
|
5
6
|
values: {
|
|
6
7
|
option?: string;
|
|
@@ -26,16 +26,20 @@ const Phone = ({ variant, color, options, values, onSelected, validation, ...att
|
|
|
26
26
|
setSelected(options?.find((option) => option.value === values.option));
|
|
27
27
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
28
|
}, [values.value, values.option, optionsKey]);
|
|
29
|
-
return (React.createElement(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
return (React.createElement(Input, { ref: _input, ...attributes, ...(!options ? { style: { borderRadius: "var(--radius-4)" } } : {}), variant: variant, color: color, value: PHONE.FormatByMask(selected?.value, _value), type: "tel", inputMode: "decimal", onChange: (event) => {
|
|
30
|
+
if (attributes.disabled)
|
|
31
|
+
return;
|
|
32
|
+
setValue(event.target.value);
|
|
33
|
+
attributes.onChange?.(event);
|
|
34
|
+
}, onClick: handleClick, validation: validation },
|
|
35
|
+
React.createElement(Input.AddonBefore, null,
|
|
36
|
+
React.createElement(Select
|
|
37
|
+
// style={{ width: 130 }}
|
|
38
|
+
, {
|
|
39
|
+
// style={{ width: 130 }}
|
|
40
|
+
variant: "outlined", color: "gray", options: options ?? [], value: selected, onChange: (option) => {
|
|
41
|
+
onSelected?.(option);
|
|
42
|
+
setSelected(option);
|
|
43
|
+
}, validation: validation, config: { validation: { text: "hidden" } } }))));
|
|
40
44
|
};
|
|
41
45
|
export default Phone;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React, { useRef, useCallback, useState, useEffect } from "react";
|
|
3
3
|
import Input from "..";
|
|
4
|
-
|
|
4
|
+
import Flex from "../../../data-display/grid-system/flex/Flex";
|
|
5
|
+
const Pin = ({ character, ...attributes }) => {
|
|
5
6
|
// refs
|
|
6
7
|
const _inputs = useRef([]);
|
|
7
8
|
// states
|
|
@@ -10,7 +11,7 @@ const Otp = ({ character, onChange, ...attributes }) => {
|
|
|
10
11
|
const triggerChange = (newValues, event) => {
|
|
11
12
|
setOtpValues(newValues);
|
|
12
13
|
const combinedValue = newValues.join("");
|
|
13
|
-
onChange?.({
|
|
14
|
+
attributes.onChange?.({
|
|
14
15
|
...event,
|
|
15
16
|
target: {
|
|
16
17
|
...event.currentTarget,
|
|
@@ -84,7 +85,7 @@ const Otp = ({ character, onChange, ...attributes }) => {
|
|
|
84
85
|
setTimeout(() => currentInput?.select(), 0);
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
|
-
}, [character, otpValues, attributes.disabled, onChange, attributes.name]);
|
|
88
|
+
}, [character, otpValues, attributes.disabled, attributes.onChange, attributes.name]);
|
|
88
89
|
const handlePaste = useCallback((index) => (event) => {
|
|
89
90
|
event.preventDefault();
|
|
90
91
|
if (attributes.disabled)
|
|
@@ -113,10 +114,9 @@ const Otp = ({ character, onChange, ...attributes }) => {
|
|
|
113
114
|
useEffect(() => {
|
|
114
115
|
setOtpValues(Array(character).fill(""));
|
|
115
116
|
}, [character]);
|
|
116
|
-
return (React.createElement(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}, ...attributes, value: otpValues[index], onChange: () => { }, onKeyDown: handleKeyDown(index), onPaste: handlePaste(index), onFocus: (event) => event.target.select(), onClick: handleClick, size: 1, maxLength: 1, placeholder: undefined, autoFocus: index === 0, autoComplete: "off" }))))));
|
|
117
|
+
return (React.createElement(Flex, { gap: "var(--space-10)", alignItems: "center", justifyContent: "center" }, Array.from({ length: character }, (_, index) => (React.createElement(Input, { ref: (el) => {
|
|
118
|
+
_inputs.current[index] = el;
|
|
119
|
+
}, key: index, ...attributes, className: `pin-input ${attributes.className ?? ""}`, value: otpValues[index], onChange: () => { }, onKeyDown: handleKeyDown(index), onPaste: handlePaste(index), onFocus: (event) => event.target.select(), onClick: handleClick, maxLength: 1, ...(otpValues[index] === "" ? { placeholder: attributes.placeholder ?? "○" } : {}), ...(attributes.autoFocus === true ? { autoFocus: index === 0 } : {}), autoComplete: "off", inputMode: "numeric" })))));
|
|
120
120
|
};
|
|
121
|
-
|
|
122
|
-
export default
|
|
121
|
+
Pin.displayName = "Input.Otp";
|
|
122
|
+
export default Pin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import Checkbox from "../checkbox";
|
|
2
3
|
import { Color } from "../../../libs/infrastructure/types";
|
|
3
|
-
interface IProps extends
|
|
4
|
-
label?: string;
|
|
4
|
+
interface IProps extends Omit<ComponentProps<typeof Checkbox>, "border"> {
|
|
5
5
|
trace?: {
|
|
6
6
|
color: Color;
|
|
7
7
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import IProps from "./IProps";
|
|
3
|
-
|
|
4
|
-
declare const Radio: React.ForwardRefExoticComponent<IProps & React.RefAttributes<HTMLInputElement>>;
|
|
3
|
+
declare const Radio: React.ForwardRefExoticComponent<Omit<IProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
5
4
|
export default Radio;
|