ar-design 0.3.70 → 0.3.72

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.
@@ -18,12 +18,16 @@ const Popover = ({ children, title, message, content, onConfirm, windowBlur, ful
18
18
  // methods
19
19
  const handleClickOutSide = (event) => {
20
20
  const target = event.target;
21
- if (_arPopover.current && !_arPopover.current.contains(target))
21
+ const isArSelectOptions = document.getElementsByClassName("ar-select-options").length === 0;
22
+ const isArCalendar = document.getElementsByClassName("ar-date-calendar").length === 0;
23
+ if (_arPopover.current && !_arPopover.current.contains(target) && isArCalendar && isArSelectOptions)
22
24
  setOpen(false);
23
25
  };
24
26
  const handleKeys = (event) => {
25
27
  const key = event.key;
26
- if (key === "Escape")
28
+ const isArSelectOptions = document.getElementsByClassName("ar-select-options").length === 0;
29
+ const isArCalendar = document.getElementsByClassName("ar-date-calendar").length === 0;
30
+ if (key === "Escape" && isArCalendar && isArSelectOptions)
27
31
  setOpen(false);
28
32
  };
29
33
  const handlePosition = () => {
@@ -1,7 +1,10 @@
1
1
  import { IBorder, IColors, IStatus, IValidation, IVariant } from "../../../libs/types/IGlobalProps";
2
2
  type Props = {
3
3
  label?: string;
4
- isClock?: boolean;
5
4
  onChange: (value: string) => void;
5
+ config?: {
6
+ isClock?: boolean;
7
+ isFooterButton?: boolean;
8
+ };
6
9
  } & IVariant & IColors & IStatus & IBorder & IValidation & Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "onChange" | "color">;
7
10
  export default Props;
@@ -21,7 +21,7 @@ const months = [
21
21
  { value: 10, text: "Kasım" },
22
22
  { value: 11, text: "Aralık" },
23
23
  ];
24
- const DatePicker = ({ variant, color, onChange, isClock, validation, ...attributes }) => {
24
+ const DatePicker = ({ variant, color, onChange, config, validation, ...attributes }) => {
25
25
  // refs
26
26
  const _arCalendar = useRef(null);
27
27
  const _arClock = useRef(null);
@@ -80,7 +80,7 @@ const DatePicker = ({ variant, color, onChange, isClock, validation, ...attribut
80
80
  const screenCenterY = window.innerHeight / 2;
81
81
  const sx = window.scrollX || document.documentElement.scrollLeft || document.body.scrollLeft;
82
82
  const sy = window.scrollY || document.documentElement.scrollTop || document.body.scrollTop;
83
- const _isClock = InpuRect.left > screenCenterX ? -Math.abs(isClock ? 7.5 * 16.75 : 0) : 0;
83
+ const _isClock = InpuRect.left > screenCenterX ? -Math.abs(config?.isClock ? 7.5 * 16.75 : 0) : 0;
84
84
  _arCalendar.current.style.visibility = "visible";
85
85
  _arCalendar.current.style.opacity = "1";
86
86
  _arCalendar.current.style.top = `${(InpuRect.top > screenCenterY ? InpuRect.top - arCalendarRect.height : InpuRect.top + InpuRect.height) + sy}px`;
@@ -109,7 +109,7 @@ const DatePicker = ({ variant, color, onChange, isClock, validation, ...attribut
109
109
  setSelectedDay(_day.current);
110
110
  setSelectedHours(_hours.current);
111
111
  setSelectedMinutes(_minutes.current);
112
- const inputDate = new Date(Date.UTC(_year.current, _month.current, _day.current, !isClock ? 0 : _hours.current, !isClock ? 0 : _minutes.current, 0));
112
+ const inputDate = new Date(Date.UTC(_year.current, _month.current, _day.current, !config?.isClock ? 0 : _hours.current, !config?.isClock ? 0 : _minutes.current, 0));
113
113
  onChange(inputDate.toISOString());
114
114
  isShutdownOn && setCalendarIsOpen(false);
115
115
  };
@@ -129,14 +129,14 @@ const DatePicker = ({ variant, color, onChange, isClock, validation, ...attribut
129
129
  // Takvim kapatılıyor...
130
130
  setCalendarIsOpen(false);
131
131
  // Değer gönderiliyor...
132
- const inputDate = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), !isClock ? 0 : now.getHours(), !isClock ? 0 : now.getMinutes(), 0));
132
+ const inputDate = new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), !config?.isClock ? 0 : now.getHours(), !config?.isClock ? 0 : now.getMinutes(), 0));
133
133
  onChange(inputDate.toISOString());
134
134
  };
135
135
  const okayButton = () => {
136
136
  return (React.createElement(Button, { variant: "borderless", color: "green", onClick: () => handleOk() }, "Tamam"));
137
137
  };
138
138
  const closeCalendar = () => {
139
- const { year, month, day, hours, minutes } = DATE.Parse(String(attributes.value), isClock);
139
+ const { year, month, day, hours, minutes } = DATE.Parse(String(attributes.value), config?.isClock);
140
140
  _year.current = attributes.value ? year : selectedYear;
141
141
  _month.current = attributes.value ? month - 1 : selectedMonth;
142
142
  _day.current = attributes.value ? day : selectedDay;
@@ -212,7 +212,7 @@ const DatePicker = ({ variant, color, onChange, isClock, validation, ...attribut
212
212
  // Listeler oluşturuyor...
213
213
  generateList(24, _hours.current, setHours);
214
214
  generateList(60, _minutes.current, setMinutes);
215
- if (!isClock)
215
+ if (!config?.isClock)
216
216
  return;
217
217
  if (calendarIsOpen)
218
218
  handleHeight();
@@ -231,7 +231,7 @@ const DatePicker = ({ variant, color, onChange, isClock, validation, ...attribut
231
231
  behavior: "smooth",
232
232
  });
233
233
  }
234
- }, [timeChanged, calendarIsOpen, isClock]);
234
+ }, [timeChanged, calendarIsOpen, config?.isClock]);
235
235
  useEffect(() => {
236
236
  if (isNaN(_year.current))
237
237
  return;
@@ -250,7 +250,7 @@ const DatePicker = ({ variant, color, onChange, isClock, validation, ...attribut
250
250
  attributes.placeholder && attributes.placeholder.length > 0 && (React.createElement("label", null,
251
251
  validation ? "* " : "",
252
252
  attributes.placeholder)),
253
- React.createElement(Input, { ref: _beginDate, variant: variant, color: color, ...attributes, value: DATE.ParseValue(String(attributes.value), isClock), type: isClock ? "datetime-local" : "date", onKeyDown: (event) => {
253
+ React.createElement(Input, { ref: _beginDate, variant: variant, color: color, ...attributes, value: DATE.ParseValue(String(attributes.value), config?.isClock), type: config?.isClock ? "datetime-local" : "date", onKeyDown: (event) => {
254
254
  if (event.code === "Space")
255
255
  event.preventDefault();
256
256
  else if (event.code === "Enter")
@@ -330,11 +330,11 @@ const DatePicker = ({ variant, color, onChange, isClock, validation, ...attribut
330
330
  React.createElement("div", { className: "content" }, !isNaN(_month.current) && !isNaN(_year.current) ? (React.createElement("div", { className: "calendar" },
331
331
  React.createElement("div", { className: "weekdays" }, weekdays.map((weekday, index) => (React.createElement("span", { key: index }, weekday)))),
332
332
  React.createElement("div", { className: "days" }, calendarDays))) : (React.createElement(Alert, { status: "warning" }, "Ay veya y\u0131l se\u00E7imi yapman\u0131z gerekmektedir."))),
333
- React.createElement("div", { ref: _calendarFooter, className: "footer" },
333
+ config?.isFooterButton && (React.createElement("div", { ref: _calendarFooter, className: "footer" },
334
334
  React.createElement("div", null,
335
335
  React.createElement(Button, { variant: "borderless", onClick: () => setNowButton() }, "\u015Eimdi")),
336
- React.createElement("div", null, !isClock && okayButton())),
337
- isClock && (React.createElement("div", { ref: _arClock, className: "clock" },
336
+ React.createElement("div", null, !config?.isClock && okayButton()))),
337
+ config?.isClock && (React.createElement("div", { ref: _arClock, className: "clock" },
338
338
  React.createElement("div", { ref: _clockHeader, className: "header" },
339
339
  _hours.current.toString().padStart(2, "0"),
340
340
  " : ",
@@ -2,7 +2,7 @@ import React from "react";
2
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";
5
+ import Num from "./num/Num";
6
6
  interface InputCompound extends React.ForwardRefExoticComponent<IProps & React.RefAttributes<HTMLInputElement>> {
7
7
  Number: typeof Num;
8
8
  Otp: typeof Otp;
@@ -5,7 +5,7 @@ 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";
8
+ import Num from "./num/Num";
9
9
  const BaseInput = forwardRef(({ variant = "outlined", color = "light", icon, border = { radius: "sm" }, button, addon, upperCase, validation, ...attributes }, ref) => {
10
10
  // refs
11
11
  const _innerRef = useRef(null);
@@ -18,9 +18,10 @@ const Otp = ({ character, onChange, ...attributes }) => {
18
18
  if (!_inputs.current[index + 1]) {
19
19
  _inputs.current[character - 1]?.focus();
20
20
  _inputs.current[character - 1]?.select();
21
- return;
22
21
  }
23
- _inputs.current[index + 1]?.focus();
22
+ else {
23
+ _inputs.current[index + 1]?.focus();
24
+ }
24
25
  }
25
26
  onChange?.({
26
27
  ...event,
@@ -47,6 +48,18 @@ const Otp = ({ character, onChange, ...attributes }) => {
47
48
  const input = _inputs.current[i];
48
49
  if (input) {
49
50
  input.value = chars[i];
51
+ _value.current = { ..._value.current, [i]: chars[i] };
52
+ onChange?.({
53
+ ...event,
54
+ target: {
55
+ ...event.currentTarget,
56
+ name: attributes.name ?? "",
57
+ value: Object.keys(_value.current)
58
+ .sort((a, b) => Number(a) - Number(b))
59
+ .map((key) => _value.current[Number(key)])
60
+ .join(""),
61
+ },
62
+ });
50
63
  input.focus();
51
64
  }
52
65
  i++;
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 InputTag from "./components/form/input-tag";
9
8
  import Radio from "./components/form/radio";
10
9
  import Select from "./components/form/select";
11
10
  import Switch from "./components/form/switch";
@@ -34,4 +33,4 @@ import Pagination from "./components/navigation/pagination";
34
33
  import Steps from "./components/navigation/steps";
35
34
  import Grid from "./components/data-display/grid-system";
36
35
  import Layout from "./components/layout";
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, };
36
+ export { Button, ButtonAction, ButtonGroup, Checkbox, DatePicker, Input, 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 InputTag from "./components/form/input-tag";
10
9
  import Radio from "./components/form/radio";
11
10
  import Select from "./components/form/select";
12
11
  import Switch from "./components/form/switch";
@@ -41,7 +40,7 @@ import Grid from "./components/data-display/grid-system";
41
40
  import Layout from "./components/layout";
42
41
  export {
43
42
  // Form Elements
44
- Button, ButtonAction, ButtonGroup, Checkbox, DatePicker, Input, InputTag, Radio, Select, Switch, TextEditor, Upload,
43
+ Button, ButtonAction, ButtonGroup, Checkbox, DatePicker, Input, Radio, Select, Switch, TextEditor, Upload,
45
44
  // Data Display
46
45
  Card, Chip, Diagram, Divider, DnD, KanbanBoard, Paper, SyntaxHighlighter, Table, Tabs, Typography,
47
46
  // Feedback
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.3.70",
3
+ "version": "0.3.72",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,4 +0,0 @@
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
- }
4
- export default IProps;
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- import IProps from "./IProps";
3
- declare const InputTag: React.FC<IProps>;
4
- export default InputTag;
@@ -1,6 +0,0 @@
1
- import React from "react";
2
- import Input from "../input";
3
- const InputTag = ({ ...attributes }) => {
4
- return React.createElement(Input, { ...attributes });
5
- };
6
- export default InputTag;