mimir-ui-kit 1.21.3 → 1.22.0

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.
Files changed (32) hide show
  1. package/dist/assets/ListFiles.css +1 -0
  2. package/dist/assets/styles.css +1 -0
  3. package/dist/components/DatePicker/DatePicker.d.ts +12 -0
  4. package/dist/components/DatePicker/DatePicker.js +87 -18
  5. package/dist/components/DatePicker/DatePickerModal.d.ts +2 -1
  6. package/dist/components/DatePicker/DatePickerModal.js +182 -7
  7. package/dist/components/DatePicker/MonthPickerModal.d.ts +9 -0
  8. package/dist/components/DatePicker/MonthPickerModal.js +123 -0
  9. package/dist/components/DatePicker/YearPickerModal.d.ts +9 -0
  10. package/dist/components/DatePicker/YearPickerModal.js +120 -0
  11. package/dist/components/DatePicker/constants.d.ts +1 -0
  12. package/dist/components/DatePicker/constants.js +15 -0
  13. package/dist/components/ListFiles/ListFiles.d.ts +26 -0
  14. package/dist/components/ListFiles/ListFiles.js +42 -0
  15. package/dist/components/ListFiles/constants.d.ts +3 -0
  16. package/dist/components/ListFiles/constants.js +33 -0
  17. package/dist/components/ListFiles/index.d.ts +2 -0
  18. package/dist/components/ListFiles/index.js +4 -0
  19. package/dist/components/Uploader/Uploader.js +1 -1
  20. package/dist/components/UploaderFiles/UploaderFiles.d.ts +38 -0
  21. package/dist/components/UploaderFiles/UploaderFiles.js +68 -0
  22. package/dist/components/UploaderFiles/index.d.ts +2 -0
  23. package/dist/components/UploaderFiles/index.js +4 -0
  24. package/dist/components/UploaderPhotos/UploaderPhotos.js +1 -0
  25. package/dist/styles.module-BZXDqssF.js +36 -0
  26. package/dist/utils/formating/FileSize.d.ts +1 -0
  27. package/dist/utils/formating/FileSize.js +13 -0
  28. package/dist/utils/index.d.ts +2 -0
  29. package/dist/utils/index.js +3 -1
  30. package/package.json +1 -1
  31. package/dist/DatePickerModal-BM0BgzTb.js +0 -204
  32. package/dist/assets/DatePickerModal.css +0 -1
@@ -0,0 +1 @@
1
+ ._file-info_d2me4_2{display:flex;flex-direction:column;gap:8px;overflow:hidden}._file-info_d2me4_2 span{font-family:Inter,sans-serif;font-size:14px;font-weight:400;line-height:18px;text-align:left;color:#b2b2b2}._file-info_d2me4_2 ._file-info__name-wrapper_d2me4_16{display:table;table-layout:fixed;width:100%}._file-info_d2me4_2 ._file-info__name-wrapper_d2me4_16 div{font-family:Inter,sans-serif;font-size:18px;font-weight:400;line-height:24px;text-align:left;color:#000;display:table-cell;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}._file-upload-container_d2me4_34{display:flex;flex-direction:column;width:100%;padding-left:0;margin-bottom:0;gap:8px}._file-upload-container_d2me4_34 li{display:flex;justify-content:space-between;align-items:center;background:#fff;position:relative;padding:8px 16px;border-radius:6px}._file-upload-container_d2me4_34 li button{background:#f2f2f2;position:absolute;right:4px;top:4px}._file-upload-container_d2me4_34 li span{display:flex}
@@ -0,0 +1 @@
1
+ ._input_3fxwe_2{padding-right:var(--space-3xl)}._input-wrapper_3fxwe_6{flex:1}._date-wrapper_3fxwe_10{position:relative;width:100%}._date-wrapper_3fxwe_10:hover ._input-wrapper_3fxwe_6{background-color:var(--input-bg-color-hover)}._date-wrapper_3fxwe_10:before{position:absolute;top:0;right:60px;bottom:0;left:0;z-index:3;cursor:pointer;content:""}[data-disabled=true] ._date-wrapper_3fxwe_10:before{cursor:auto}[data-disabled=true] ._date-wrapper_3fxwe_10 ._input-wrapper_3fxwe_6{background:var(--black-20)}[data-disabled=true] ._date-wrapper_3fxwe_10 ._input-wrapper_3fxwe_6 label,[data-disabled=true] ._date-wrapper_3fxwe_10 ._input-wrapper_3fxwe_6 input{color:var(--white)}[data-disabled=true] ._button-wrapper_3fxwe_35 svg{color:var(--white);fill:var(--white);cursor:default}._wrapper_3fxwe_41{position:relative;display:flex;align-items:center;border-radius:var(--control-radius-s)}._wrapper_3fxwe_41._active_3fxwe_47{border-bottom:1px solid var(--citrine-100)}._button-wrapper_3fxwe_35{position:absolute;top:0;right:0;z-index:2;display:flex;width:44px;height:100%;max-height:var(--button-height-xxl)}._button_3fxwe_35{align-self:center;background-color:transparent;border-radius:var(--control-radius-s)}._field-overlow_3fxwe_68{position:fixed;top:0;right:0;bottom:0;left:0;z-index:3}._calendar-block_3fxwe_74{position:absolute;z-index:3;display:flex;flex-direction:column;width:368px;max-height:none;padding:16px;font-weight:var(--font-weight-text-regular);font-size:var(--size-text-l);font-family:var(--font-inter);font-style:normal;line-height:var(--line-height-text-2xs);text-align:center;text-overflow:ellipsis;background:var(--white);border-radius:var(--control-radius-s);box-shadow:0 0 #16172705,0 2px 4px #16172705,0 6px 6px #16172705,0 15px 9px #16172703;opacity:0;transition:height .5s ease-in;font-feature-settings:"zero";font-variant-numeric:slashed-zero}._calendar-block_3fxwe_74 ._h_3fxwe_97{display:flex;width:100%;color:var(--black-100)}._calendar-block_3fxwe_74 ._b_3fxwe_35{display:grid;grid-template-columns:repeat(7,1fr)}._calendar-block_3fxwe_74 ._d_3fxwe_10{display:flex;flex:1;align-items:center;justify-content:center;color:var(--black-100);cursor:pointer;gap:4px}._calendar-block_3fxwe_74 ._m_3fxwe_118,._calendar-block_3fxwe_74 ._a_3fxwe_47,._calendar-block_3fxwe_74 ._prev_3fxwe_120{width:auto;height:48px;overflow:hidden}._calendar-block_3fxwe_74 ._m_3fxwe_118{display:flex;align-items:center;justify-content:center;color:var(--disabled)}._calendar-block_3fxwe_74 ._m_3fxwe_118 b{font-weight:var(--font-weight-text-regular)}._calendar-block_3fxwe_74 ._orange_3fxwe_136{color:var(--citrine-100)}._calendar-block_3fxwe_74 ._a_3fxwe_47{color:var(--black-100);border-radius:var(--control-radius-s)}._calendar-block_3fxwe_74 ._a_3fxwe_47 b{display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-weight:var(--font-weight-text-regular);cursor:pointer}._calendar-block_3fxwe_74 ._a_3fxwe_47 b:hover{background:var(--black-10)}._calendar-block_3fxwe_74 ._a_3fxwe_47 b:active{color:var(--white);background:var(--sapphire-100)}._calendar-block_3fxwe_74 ._current_3fxwe_161{background:var(--sapphire-10);border-radius:var(--control-radius-s)}._calendar-block_3fxwe_74 ._monthGrid_3fxwe_166{display:grid;grid-template-columns:repeat(3,1fr)}
@@ -14,6 +14,12 @@ export type DatePicker = {
14
14
  * значение из стейта (data)
15
15
  */
16
16
  value?: string;
17
+ /**
18
+ * значение типа модально окна календаря
19
+ */
20
+ type?: 'days' | 'months' | 'years';
21
+ disabled?: boolean;
22
+ error?: boolean;
17
23
  } & TInputProps;
18
24
  export type TDatePickerValue = {
19
25
  value?: Date;
@@ -33,4 +39,10 @@ export declare const DatePicker: import('react').MemoExoticComponent<import('rea
33
39
  * значение из стейта (data)
34
40
  */
35
41
  value?: string;
42
+ /**
43
+ * значение типа модально окна календаря
44
+ */
45
+ type?: "days" | "months" | "years";
46
+ disabled?: boolean;
47
+ error?: boolean;
36
48
  } & import('../Input/types').TInputProps & import('../Input').TAdditionalProps & import('react').RefAttributes<HTMLInputElement>>>;
@@ -1,44 +1,92 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { c as classNames } from "../../index-CweZ_OcN.js";
3
- import { memo, forwardRef, useState } from "react";
4
- import { c as cls, D as DatePickerModal } from "../../DatePickerModal-BM0BgzTb.js";
3
+ import { memo, forwardRef, useState, useEffect } from "react";
4
+ import { DatePickerModal } from "./DatePickerModal.js";
5
+ import { MonthPickerModal } from "./MonthPickerModal.js";
6
+ import { c as cls } from "../../styles.module-BZXDqssF.js";
7
+ import { YearPickerModal } from "./YearPickerModal.js";
5
8
  import { useClickOutside } from "../../hooks/useClickOutside/useClickOutside.js";
6
9
  import { formating } from "../../utils/index.js";
7
10
  import { Button } from "../Button/Button.js";
8
11
  import { I as Input } from "../../Input-6mudFqTb.js";
12
+ import { EInputVariant } from "../Input/constants.js";
9
13
  const DatePicker = memo(
10
14
  forwardRef(
11
- ({ size, value, onChangeValue, name, before, ...props }, ref) => {
15
+ ({
16
+ size,
17
+ value,
18
+ onChangeValue,
19
+ name,
20
+ before,
21
+ type = "days",
22
+ error,
23
+ variant,
24
+ disabled = false,
25
+ ...props
26
+ }, ref) => {
12
27
  const [isActive, setActive] = useState(false);
28
+ const [pickerType, setType] = useState(type);
13
29
  const [date, setDate] = useState(
14
30
  value ? new Date(value) : /* @__PURE__ */ new Date()
15
31
  );
32
+ const [isError, setError] = useState(error);
33
+ useEffect(() => {
34
+ setError(error);
35
+ }, [error]);
16
36
  useClickOutside({
17
37
  isActive,
18
- setActive,
38
+ setActive: (e) => {
39
+ setActive(e);
40
+ setType(type);
41
+ },
19
42
  className: cls["calendar-block"]
20
43
  });
21
44
  const onOpen = () => {
22
- setActive(true);
45
+ if (!disabled) setActive(true);
23
46
  };
24
47
  const onDate = (d) => {
48
+ if (pickerType === "years") {
49
+ if (type === "years") {
50
+ setActive(false);
51
+ setType(type);
52
+ } else {
53
+ setType("months");
54
+ }
55
+ }
56
+ if (pickerType === "months") {
57
+ if (type === "months") {
58
+ setActive(false);
59
+ setType(type);
60
+ } else {
61
+ setType("days");
62
+ }
63
+ }
25
64
  setDate(d);
26
65
  onChangeValue == null ? void 0 : onChangeValue({ value: d, name });
27
66
  };
28
67
  const wrapperClassNames = classNames(cls.wrapper, isActive && cls.active);
29
- return /* @__PURE__ */ jsxs("div", { className: wrapperClassNames, children: [
30
- /* @__PURE__ */ jsx("div", { className: cls["date-wrapper"], onClick: onOpen, children: /* @__PURE__ */ jsx(
31
- Input,
68
+ return /* @__PURE__ */ jsxs("div", { className: wrapperClassNames, "data-disabled": disabled, children: [
69
+ /* @__PURE__ */ jsx(
70
+ "div",
32
71
  {
33
- ref,
34
- className: cls.input,
35
- wrapperClassName: cls["input-wrapper"],
36
- size,
37
- type: "text",
38
- value: formating.Date(date, "dd.mm.yy"),
39
- ...props
72
+ "data-error": isError,
73
+ className: cls["date-wrapper"],
74
+ onClick: onOpen,
75
+ children: /* @__PURE__ */ jsx(
76
+ Input,
77
+ {
78
+ ref,
79
+ className: cls.input,
80
+ wrapperClassName: cls["input-wrapper"],
81
+ size,
82
+ type: "text",
83
+ variant: isError ? EInputVariant.Error : variant,
84
+ value: formating.Date(date, "dd.mm.yy"),
85
+ ...props
86
+ }
87
+ )
40
88
  }
41
- ) }),
89
+ ),
42
90
  /* @__PURE__ */ jsx("div", { className: cls["button-wrapper"], children: /* @__PURE__ */ jsx(
43
91
  Button,
44
92
  {
@@ -50,13 +98,34 @@ const DatePicker = memo(
50
98
  iconName: isActive ? "DropdownArrowUp16px" : "DropdownArrowBottom16px"
51
99
  }
52
100
  ) }),
53
- isActive && /* @__PURE__ */ jsx(
101
+ pickerType === "days" && isActive && /* @__PURE__ */ jsx(
54
102
  DatePickerModal,
55
103
  {
56
104
  onChangeValue: onDate,
57
105
  date,
58
106
  setActive,
59
- before: typeof before === "string" ? new Date(before) : before
107
+ before: typeof before === "string" ? new Date(before) : before,
108
+ onType: setType
109
+ }
110
+ ),
111
+ pickerType === "months" && isActive && /* @__PURE__ */ jsx(
112
+ MonthPickerModal,
113
+ {
114
+ onChangeValue: onDate,
115
+ date,
116
+ setActive,
117
+ before: typeof before === "string" ? new Date(before) : before,
118
+ onType: setType
119
+ }
120
+ ),
121
+ pickerType === "years" && isActive && /* @__PURE__ */ jsx(
122
+ YearPickerModal,
123
+ {
124
+ onChangeValue: onDate,
125
+ date,
126
+ setActive,
127
+ before: typeof before === "string" ? new Date(before) : before,
128
+ onType: setType
60
129
  }
61
130
  )
62
131
  ] });
@@ -3,6 +3,7 @@ type DatePickerModal = {
3
3
  onChangeValue: (d: Date) => void;
4
4
  setActive: (s: boolean) => void;
5
5
  before?: Date;
6
+ onType?: (s: 'days' | 'months' | 'years') => void;
6
7
  };
7
- export declare function DatePickerModal({ date, onChangeValue, setActive, before }: DatePickerModal): import("react/jsx-runtime").JSX.Element;
8
+ export declare function DatePickerModal({ date, onChangeValue, setActive, before, onType }: DatePickerModal): import("react/jsx-runtime").JSX.Element;
8
9
  export {};
@@ -1,9 +1,184 @@
1
- import "react/jsx-runtime";
2
- import "react";
3
- import "./constants.js";
4
- import { D } from "../../DatePickerModal-BM0BgzTb.js";
5
- import "../../utils/index.js";
6
- import "../Button/Button.js";
1
+ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
+ import { useRef, useState, useEffect } from "react";
3
+ import { week } from "./constants.js";
4
+ import { c as cls } from "../../styles.module-BZXDqssF.js";
5
+ import { Icon } from "../../icons/Icon.js";
6
+ import { formating } from "../../utils/index.js";
7
+ import { Button } from "../Button/Button.js";
8
+ function DatePickerModal({
9
+ date,
10
+ onChangeValue,
11
+ setActive,
12
+ before,
13
+ onType
14
+ }) {
15
+ const field = useRef(null);
16
+ const _current = new Date(date);
17
+ const _selecte = new Date(date);
18
+ const current = {
19
+ y: _current.getFullYear(),
20
+ d: _current.getDate(),
21
+ m: _current.getMonth() + 1
22
+ };
23
+ const selecte = {
24
+ y: _selecte.getFullYear(),
25
+ d: _selecte.getDate(),
26
+ m: _selecte.getMonth() + 1
27
+ };
28
+ const countWorkDays = 4;
29
+ const [month, setMonth] = useState({ y: selecte.y, m: selecte.m });
30
+ const blockWidth = 368;
31
+ useEffect(() => {
32
+ var _a, _b, _c, _d;
33
+ const windowHeight = window.innerHeight;
34
+ const windowWidth = window.innerWidth;
35
+ if (field.current !== null) {
36
+ const inputWidth = ((_b = (_a = field == null ? void 0 : field.current) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.offsetWidth) || 0;
37
+ const inputHeight = (_d = (_c = field == null ? void 0 : field.current) == null ? void 0 : _c.parentElement) == null ? void 0 : _d.offsetHeight;
38
+ const inputPosition = field.current.getBoundingClientRect();
39
+ const calendarSize = field.current.offsetHeight;
40
+ if (windowHeight < inputPosition.y + calendarSize) {
41
+ field.current.style.top = -calendarSize + "px";
42
+ } else {
43
+ field.current.style.top = inputHeight + "px";
44
+ }
45
+ if (windowWidth < inputPosition.x + blockWidth) {
46
+ field.current.style.left = inputWidth - blockWidth + "px";
47
+ }
48
+ field.current.style.opacity = "1";
49
+ }
50
+ }, [month]);
51
+ const countPrevDays = (e) => {
52
+ let dayOfWeek = e.getDay();
53
+ if (dayOfWeek === 0) dayOfWeek = 7;
54
+ return dayOfWeek - 1;
55
+ };
56
+ const currentMonthIndex = month.m - 1;
57
+ const currentMonthFull = new Date(month.y, currentMonthIndex);
58
+ const days = [];
59
+ const prevDays = () => {
60
+ const prevMonth = new Date(currentMonthFull);
61
+ prevMonth.setDate(prevMonth.getDate() - 1);
62
+ const lastDayPrevMohth = prevMonth.getDate();
63
+ const prevList = [];
64
+ for (let i = 0; i < countPrevDays(currentMonthFull); i++) {
65
+ prevList.push(lastDayPrevMohth - i);
66
+ }
67
+ prevList.reverse();
68
+ return prevList;
69
+ };
70
+ const prevDaysArray = prevDays();
71
+ while (currentMonthFull.getMonth() === currentMonthIndex) {
72
+ days.push(currentMonthFull.getDate());
73
+ currentMonthFull.setDate(currentMonthFull.getDate() + 1);
74
+ }
75
+ const nextDays = () => {
76
+ const totalViewDays = 42;
77
+ const daysCount = totalViewDays - (prevDaysArray.length + days.length);
78
+ const nextList = [];
79
+ for (let i = 1; i <= daysCount; i++) {
80
+ nextList.push(i);
81
+ }
82
+ return nextList;
83
+ };
84
+ const nextDaysArray = nextDays();
85
+ const update = (m, y) => {
86
+ y = m > 12 ? y + 1 : m < 1 ? y - 1 : y;
87
+ m = m > 12 ? 1 : m < 1 ? 12 : m;
88
+ return { y, m };
89
+ };
90
+ const onExit = () => {
91
+ setActive(false);
92
+ };
93
+ const next = () => {
94
+ setMonth(update(month.m + 1, month.y));
95
+ };
96
+ const prev = () => {
97
+ setMonth(update(month.m - 1, month.y));
98
+ };
99
+ const isBefore = (activeDate) => {
100
+ if (before) {
101
+ const beforeDate = before.getTime();
102
+ if (beforeDate > activeDate) return true;
103
+ }
104
+ return false;
105
+ };
106
+ const send = (searchDate) => {
107
+ if (isBefore(
108
+ (/* @__PURE__ */ new Date(
109
+ `${month.y}-${formating.Number(2, month.m)}-${formating.Number(2, searchDate)}`
110
+ )).getTime()
111
+ ))
112
+ return;
113
+ onChangeValue(
114
+ /* @__PURE__ */ new Date(
115
+ `${month.y}-${formating.Number(2, month.m)}-${formating.Number(2, searchDate)}`
116
+ )
117
+ );
118
+ onExit();
119
+ };
120
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: [cls["calendar-block"]].join(" "), ref: field, children: [
121
+ /* @__PURE__ */ jsxs("div", { className: cls["h"], children: [
122
+ /* @__PURE__ */ jsx(
123
+ Button,
124
+ {
125
+ isIconButton: true,
126
+ iconName: "DropdownArrowLeft16px",
127
+ onClick: prev,
128
+ variant: "secondary-gray",
129
+ size: "l"
130
+ }
131
+ ),
132
+ /* @__PURE__ */ jsxs("div", { className: cls["d"], onClick: () => onType == null ? void 0 : onType("months"), children: [
133
+ formating.Month(month.m).name,
134
+ "’",
135
+ month.y.toString().slice(-2),
136
+ /* @__PURE__ */ jsx(Icon, { iconName: "DropdownArrowBottom16px" })
137
+ ] }),
138
+ /* @__PURE__ */ jsx(
139
+ Button,
140
+ {
141
+ isIconButton: true,
142
+ iconName: "DropdownArrowRight16px",
143
+ onClick: next,
144
+ variant: "secondary-gray",
145
+ size: "l"
146
+ }
147
+ )
148
+ ] }),
149
+ /* @__PURE__ */ jsxs("div", { className: cls["b"], children: [
150
+ week.map((i, s) => /* @__PURE__ */ jsx(
151
+ "div",
152
+ {
153
+ className: `${s > countWorkDays ? [cls["m"], cls["orange"]].join(" ") : cls["m"]}`,
154
+ children: i
155
+ },
156
+ `v${s}`
157
+ )),
158
+ prevDaysArray.map((el, key) => /* @__PURE__ */ jsx("div", { className: cls["m"], children: el }, key)),
159
+ days.map((i, s) => /* @__PURE__ */ jsx(
160
+ "div",
161
+ {
162
+ className: isBefore(
163
+ (/* @__PURE__ */ new Date(
164
+ `${month.y}-${formating.Number(2, month.m)}-${formating.Number(2, i)}`
165
+ )).getTime()
166
+ ) ? cls["m"] : cls["a"],
167
+ children: i !== 0 ? /* @__PURE__ */ jsx(
168
+ "b",
169
+ {
170
+ className: current.y === month.y && current.m === month.m && current.d === i ? cls["current"] : "",
171
+ onClick: () => send(i),
172
+ children: i
173
+ }
174
+ ) : /* @__PURE__ */ jsx("p", {})
175
+ },
176
+ s
177
+ )),
178
+ nextDaysArray.map((el, key) => /* @__PURE__ */ jsx("div", { className: cls["m"], children: el }, key))
179
+ ] })
180
+ ] }) });
181
+ }
7
182
  export {
8
- D as DatePickerModal
183
+ DatePickerModal
9
184
  };
@@ -0,0 +1,9 @@
1
+ type MonthPickerModal = {
2
+ date: Date;
3
+ onChangeValue: (d: Date) => void;
4
+ setActive: (s: boolean) => void;
5
+ before?: Date;
6
+ onType?: (s: 'years') => void;
7
+ };
8
+ export declare function MonthPickerModal({ date, onChangeValue, before, onType }: MonthPickerModal): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,123 @@
1
+ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
+ import { useRef, useState, useEffect } from "react";
3
+ import { months } from "./constants.js";
4
+ import { c as cls } from "../../styles.module-BZXDqssF.js";
5
+ import { Icon } from "../../icons/Icon.js";
6
+ import { formating } from "../../utils/index.js";
7
+ import { Button } from "../Button/Button.js";
8
+ function MonthPickerModal({
9
+ date,
10
+ onChangeValue,
11
+ before,
12
+ onType
13
+ }) {
14
+ const field = useRef(null);
15
+ const _current = new Date(date);
16
+ const _selecte = new Date(date);
17
+ const current = {
18
+ y: _current.getFullYear(),
19
+ d: _current.getDate(),
20
+ m: _current.getMonth() + 1
21
+ };
22
+ const selecte = {
23
+ y: _selecte.getFullYear(),
24
+ d: _selecte.getDate(),
25
+ m: _selecte.getMonth() + 1
26
+ };
27
+ const [year, setYear] = useState(selecte.y);
28
+ const blockWidth = 368;
29
+ useEffect(() => {
30
+ var _a, _b, _c, _d;
31
+ const windowHeight = window.innerHeight;
32
+ const windowWidth = window.innerWidth;
33
+ if (field.current !== null) {
34
+ const inputWidth = ((_b = (_a = field == null ? void 0 : field.current) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.offsetWidth) || 0;
35
+ const inputHeight = (_d = (_c = field == null ? void 0 : field.current) == null ? void 0 : _c.parentElement) == null ? void 0 : _d.offsetHeight;
36
+ const inputPosition = field.current.getBoundingClientRect();
37
+ const calendarSize = field.current.offsetHeight;
38
+ if (windowHeight < inputPosition.y + calendarSize) {
39
+ field.current.style.top = -calendarSize + "px";
40
+ } else {
41
+ field.current.style.top = inputHeight + "px";
42
+ }
43
+ if (windowWidth < inputPosition.x + blockWidth) {
44
+ field.current.style.left = inputWidth - blockWidth + "px";
45
+ }
46
+ field.current.style.opacity = "1";
47
+ }
48
+ }, []);
49
+ const next = () => {
50
+ setYear(year + 1);
51
+ };
52
+ const prev = () => {
53
+ setYear(year - 1);
54
+ };
55
+ const isBefore = (activeDate) => {
56
+ if (before) {
57
+ const beforeDate = before.getTime();
58
+ if (beforeDate > activeDate) return true;
59
+ }
60
+ return false;
61
+ };
62
+ const send = (searchDate) => {
63
+ if (isBefore(
64
+ (/* @__PURE__ */ new Date(
65
+ `${year}-${formating.Number(2, searchDate)}-${formating.Number(2, selecte.d)}`
66
+ )).getTime()
67
+ ))
68
+ return;
69
+ onChangeValue(
70
+ /* @__PURE__ */ new Date(
71
+ `${year}-${formating.Number(2, searchDate)}-${formating.Number(2, selecte.d)}`
72
+ )
73
+ );
74
+ };
75
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: [cls["calendar-block"]].join(" "), ref: field, children: [
76
+ /* @__PURE__ */ jsxs("div", { className: cls["h"], children: [
77
+ /* @__PURE__ */ jsx(
78
+ Button,
79
+ {
80
+ isIconButton: true,
81
+ iconName: "DropdownArrowLeft16px",
82
+ onClick: prev,
83
+ variant: "secondary-gray",
84
+ size: "l"
85
+ }
86
+ ),
87
+ /* @__PURE__ */ jsxs("div", { onClick: () => onType == null ? void 0 : onType("years"), className: cls["d"], children: [
88
+ year.toString(),
89
+ /* @__PURE__ */ jsx(Icon, { iconName: "DropdownArrowBottom16px" })
90
+ ] }),
91
+ /* @__PURE__ */ jsx(
92
+ Button,
93
+ {
94
+ isIconButton: true,
95
+ iconName: "DropdownArrowRight16px",
96
+ onClick: next,
97
+ variant: "secondary-gray",
98
+ size: "l"
99
+ }
100
+ )
101
+ ] }),
102
+ /* @__PURE__ */ jsx("div", { className: cls["monthGrid"], children: months.map((i, s) => /* @__PURE__ */ jsx(
103
+ "div",
104
+ {
105
+ className: isBefore(
106
+ (/* @__PURE__ */ new Date(`${year}-${formating.Number(2, s + 1)}`)).getTime()
107
+ ) ? cls["m"] : cls["a"],
108
+ children: /* @__PURE__ */ jsx(
109
+ "b",
110
+ {
111
+ className: current.y === year && current.m === s + 1 ? cls["current"] : "",
112
+ onClick: () => send(s + 1),
113
+ children: i
114
+ }
115
+ )
116
+ },
117
+ s
118
+ )) })
119
+ ] }) });
120
+ }
121
+ export {
122
+ MonthPickerModal
123
+ };
@@ -0,0 +1,9 @@
1
+ type YearPickerModal = {
2
+ date: Date;
3
+ onChangeValue: (d: Date) => void;
4
+ setActive: (s: boolean) => void;
5
+ before?: Date;
6
+ onType?: (s: 'years') => void;
7
+ };
8
+ export declare function YearPickerModal({ date, onChangeValue, before, onType }: YearPickerModal): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,120 @@
1
+ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
+ import { useRef, useState, useEffect } from "react";
3
+ import { c as cls } from "../../styles.module-BZXDqssF.js";
4
+ import { formating } from "../../utils/index.js";
5
+ import { Button } from "../Button/Button.js";
6
+ function YearPickerModal({
7
+ date,
8
+ onChangeValue,
9
+ before,
10
+ onType
11
+ }) {
12
+ const field = useRef(null);
13
+ const _current = new Date(date);
14
+ const _selecte = new Date(date);
15
+ const current = {
16
+ y: _current.getFullYear(),
17
+ d: _current.getDate(),
18
+ m: _current.getMonth() + 1
19
+ };
20
+ const selecte = {
21
+ y: _selecte.getFullYear(),
22
+ d: _selecte.getDate(),
23
+ m: _selecte.getMonth() + 1
24
+ };
25
+ const [year, setYear] = useState(selecte.y);
26
+ const blockWidth = 368;
27
+ const firstYears = year - 7;
28
+ const years = Array.from(Array(15).keys()).map((i) => i + firstYears);
29
+ useEffect(() => {
30
+ var _a, _b, _c, _d;
31
+ const windowHeight = window.innerHeight;
32
+ const windowWidth = window.innerWidth;
33
+ if (field.current !== null) {
34
+ const inputWidth = ((_b = (_a = field == null ? void 0 : field.current) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.offsetWidth) || 0;
35
+ const inputHeight = (_d = (_c = field == null ? void 0 : field.current) == null ? void 0 : _c.parentElement) == null ? void 0 : _d.offsetHeight;
36
+ const inputPosition = field.current.getBoundingClientRect();
37
+ const calendarSize = field.current.offsetHeight;
38
+ if (windowHeight < inputPosition.y + calendarSize) {
39
+ field.current.style.top = -calendarSize + "px";
40
+ } else {
41
+ field.current.style.top = inputHeight + "px";
42
+ }
43
+ if (windowWidth < inputPosition.x + blockWidth) {
44
+ field.current.style.left = inputWidth - blockWidth + "px";
45
+ }
46
+ field.current.style.opacity = "1";
47
+ }
48
+ }, []);
49
+ const next = () => {
50
+ setYear(year + 15);
51
+ };
52
+ const prev = () => {
53
+ setYear(year - 15);
54
+ };
55
+ const isBefore = (activeDate) => {
56
+ if (before) {
57
+ const beforeDate = before.getTime();
58
+ if (beforeDate > activeDate) return true;
59
+ }
60
+ return false;
61
+ };
62
+ const send = (searchDate) => {
63
+ if (isBefore(
64
+ (/* @__PURE__ */ new Date(
65
+ `${searchDate}-${formating.Number(2, selecte.m)}-${formating.Number(2, selecte.d)}`
66
+ )).getTime()
67
+ ))
68
+ return;
69
+ onChangeValue(
70
+ /* @__PURE__ */ new Date(
71
+ `${searchDate}-${formating.Number(2, selecte.m)}-${formating.Number(2, selecte.d)}`
72
+ )
73
+ );
74
+ };
75
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: [cls["calendar-block"]].join(" "), ref: field, children: [
76
+ /* @__PURE__ */ jsxs("div", { className: cls["h"], children: [
77
+ /* @__PURE__ */ jsx(
78
+ Button,
79
+ {
80
+ isIconButton: true,
81
+ iconName: "DropdownArrowLeft16px",
82
+ onClick: prev,
83
+ variant: "secondary-gray",
84
+ size: "l"
85
+ }
86
+ ),
87
+ /* @__PURE__ */ jsx("div", { onClick: () => onType == null ? void 0 : onType("years"), className: cls["d"] }),
88
+ /* @__PURE__ */ jsx(
89
+ Button,
90
+ {
91
+ isIconButton: true,
92
+ iconName: "DropdownArrowRight16px",
93
+ onClick: next,
94
+ variant: "secondary-gray",
95
+ size: "l"
96
+ }
97
+ )
98
+ ] }),
99
+ /* @__PURE__ */ jsx("div", { className: cls["monthGrid"], children: years.map((i, s) => /* @__PURE__ */ jsx(
100
+ "div",
101
+ {
102
+ className: isBefore(
103
+ (/* @__PURE__ */ new Date(`${i}-${formating.Number(2, current.m)}`)).getTime()
104
+ ) ? cls["m"] : cls["a"],
105
+ children: /* @__PURE__ */ jsx(
106
+ "b",
107
+ {
108
+ className: current.y === i ? cls["current"] : "",
109
+ onClick: () => send(i),
110
+ children: i
111
+ }
112
+ )
113
+ },
114
+ s
115
+ )) })
116
+ ] }) });
117
+ }
118
+ export {
119
+ YearPickerModal
120
+ };
@@ -4,3 +4,4 @@ export declare enum EDatePickerBeforeDate {
4
4
  CurrentDate3 = "2024-07-11"
5
5
  }
6
6
  export declare const week: string[];
7
+ export declare const months: string[];
@@ -5,7 +5,22 @@ var EDatePickerBeforeDate = /* @__PURE__ */ ((EDatePickerBeforeDate2) => {
5
5
  return EDatePickerBeforeDate2;
6
6
  })(EDatePickerBeforeDate || {});
7
7
  const week = ["пн", "вт", "ср", "чт", "пт", "сб", "вс"];
8
+ const months = [
9
+ "Январь",
10
+ "Февраль",
11
+ "Март",
12
+ "Апрель",
13
+ "Май",
14
+ "Июнь",
15
+ "Июль",
16
+ "Август",
17
+ "Сентябрь",
18
+ "Октябрь",
19
+ "Ноябрь",
20
+ "Декабрь"
21
+ ];
8
22
  export {
9
23
  EDatePickerBeforeDate,
24
+ months,
10
25
  week
11
26
  };
@@ -0,0 +1,26 @@
1
+ export type TListFiles = {
2
+ /**
3
+ * Массив фото
4
+ */
5
+ value: TFilesDetail[];
6
+ /**
7
+ * функция -callback, которая вызывается при изменении списка и передает обновленный список и deleteId,
8
+ */
9
+ onChange?: (e: TFileValue) => void;
10
+ };
11
+ export type TFileItem = {
12
+ id: number;
13
+ url: string;
14
+ };
15
+ export type TFileValue = {
16
+ deleteId?: number;
17
+ list: TFilesDetail[];
18
+ };
19
+ export type TFilesDetail = {
20
+ id: number;
21
+ url: string;
22
+ name: string;
23
+ size?: number;
24
+ type?: string;
25
+ };
26
+ export declare function ListFiles({ value, onChange }: TListFiles): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,42 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
3
+ import { formating } from "../../utils/index.js";
4
+ import { Button } from "../Button/Button.js";
5
+ import '../../assets/ListFiles.css';const cls = {
6
+ "file-info": "_file-info_d2me4_2",
7
+ "file-info__name-wrapper": "_file-info__name-wrapper_d2me4_16",
8
+ "file-upload-container": "_file-upload-container_d2me4_34"
9
+ };
10
+ function ListFiles({ value, onChange }) {
11
+ const [list, setList] = useState(value);
12
+ useEffect(() => {
13
+ setList(value);
14
+ }, [value]);
15
+ const onDelete = async (id) => {
16
+ const newList = [...list.filter((el) => el.id !== id)];
17
+ setList(newList);
18
+ onChange == null ? void 0 : onChange({ deleteId: id, list: newList });
19
+ };
20
+ return /* @__PURE__ */ jsx("ul", { className: cls["file-upload-container"], children: list.map((el, key) => /* @__PURE__ */ jsxs("li", { children: [
21
+ /* @__PURE__ */ jsxs("div", { className: cls["file-info"], children: [
22
+ (el == null ? void 0 : el.size) && /* @__PURE__ */ jsxs("span", { children: [
23
+ " ",
24
+ formating.Size(el == null ? void 0 : el.size)
25
+ ] }),
26
+ /* @__PURE__ */ jsx("div", { className: cls["file-info__name-wrapper"], children: /* @__PURE__ */ jsx("div", { children: el.name }) })
27
+ ] }),
28
+ /* @__PURE__ */ jsx(
29
+ Button,
30
+ {
31
+ isIconButton: true,
32
+ iconName: "Close12px",
33
+ size: "m-s",
34
+ variant: "secondary-gray",
35
+ onClick: () => onDelete(el.id)
36
+ }
37
+ )
38
+ ] }, key)) });
39
+ }
40
+ export {
41
+ ListFiles
42
+ };
@@ -0,0 +1,3 @@
1
+ import { TFilesDetail } from './ListFiles';
2
+
3
+ export declare const photos: TFilesDetail[];
@@ -0,0 +1,33 @@
1
+ const photos = [
2
+ {
3
+ id: 111,
4
+ name: "ООО “КИЗ-СТРОЙ” - Свидетельство о регистрации (06.12.2003).xls",
5
+ url: "https://i.pinimg.com/736x/5a/e6/12/5ae612a7ecf50870c8f41961fefc332f.jpg",
6
+ size: 1024,
7
+ type: "image/png"
8
+ },
9
+ {
10
+ id: 112,
11
+ name: "ООО “КИЗ-СТРОЙ” - Доверенность (20.10.2005).xls",
12
+ url: "https://i1.sndcdn.com/artworks-rQAPPfrs44UvRwIz-WJkvyQ-t500x500.jpg",
13
+ size: 1024,
14
+ type: "image/png"
15
+ },
16
+ {
17
+ id: 113,
18
+ name: "Скан паспорта.pdf",
19
+ url: "https://i1.sndcdn.com/avatars-000095020320-0pmjnu-t500x500.jpg",
20
+ size: 2064,
21
+ type: "image/png"
22
+ },
23
+ {
24
+ id: 114,
25
+ name: "Прочие документы.xls",
26
+ url: "https://i1.sndcdn.com/avatars-000151937348-27m28p-t500x500.jpg",
27
+ size: 1024,
28
+ type: "image/png"
29
+ }
30
+ ];
31
+ export {
32
+ photos
33
+ };
@@ -0,0 +1,2 @@
1
+ export { ListFiles } from './ListFiles';
2
+ export type { ListFiles as TListFiles } from './ListFiles';
@@ -0,0 +1,4 @@
1
+ import { ListFiles } from "./ListFiles.js";
2
+ export {
3
+ ListFiles
4
+ };
@@ -23,7 +23,7 @@ const MIME = {
23
23
  };
24
24
  const filesTyps = ["jpeg", "jpg", "png", "tiff", "gif"];
25
25
  const generateId = (min, max) => {
26
- return Math.random() * (max - min) + min;
26
+ return Math.round(Math.random() * (max - min) + min);
27
27
  };
28
28
  const Uploader = forwardRef(
29
29
  (props, ref) => {
@@ -0,0 +1,38 @@
1
+ import { TFilesDetail } from '../ListFiles/ListFiles';
2
+ import { imageTypesArr } from '../Uploader/constants';
3
+ import { TFileItem } from '../Uploader/Uploader';
4
+
5
+ export type TUploaderFiles = {
6
+ /**
7
+ * Массив разрешенных типов файлов для настройки валидации
8
+ * 'jpeg' | 'jpg' | 'png' | 'tiff' | 'gif' | 'doc' | 'xls' | 'pdf' |'docx' | 'txt'
9
+ */
10
+ filesType: imageTypesArr[];
11
+ /**
12
+ * Наименование передаваемого массива файлов
13
+ */
14
+ arrayName: string;
15
+ /**
16
+ * Максимальный размер файлов.
17
+ */
18
+ maxSize: number;
19
+ /**
20
+ * Функция обратного вызова, передает параметры type и data,
21
+ * type 'add' в data передает массив файлов,
22
+ * type:'delete' в data передает id удаленного файла
23
+ */
24
+ onChange: (j: TOnChangeFilesUpdate) => void;
25
+ /**
26
+ * Передаваемые файлы.
27
+ */
28
+ value?: TFilesDetail[];
29
+ /**
30
+ * Максимальное количество файлов.
31
+ */
32
+ maxFiles: number;
33
+ };
34
+ export type TOnChangeFilesUpdate = {
35
+ type: string;
36
+ data: TFileItem[] | number;
37
+ };
38
+ export declare const UploaderFiles: import('react').ForwardRefExoticComponent<TUploaderFiles & import('react').RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,68 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { c as classNames } from "../../index-CweZ_OcN.js";
3
+ import { forwardRef, useState, useEffect } from "react";
4
+ import { ListFiles } from "../ListFiles/ListFiles.js";
5
+ import { Uploader } from "../Uploader/Uploader.js";
6
+ import '../../assets/UploaderPhotos.css';const cls = {
7
+ "upload-file__wrapper": "_upload-file__wrapper_17bcu_2"
8
+ };
9
+ const UploaderFiles = forwardRef(
10
+ (props, ref) => {
11
+ const { filesType, arrayName, maxSize, onChange, value, maxFiles } = props;
12
+ const [files, setFiles] = useState(value || []);
13
+ const isMaxFilesReached = files.length >= maxFiles;
14
+ useEffect(() => {
15
+ if (value) {
16
+ setFiles(value);
17
+ }
18
+ }, [value]);
19
+ const onChangeValue = (e) => {
20
+ const newFiles = [
21
+ ...files,
22
+ ...e.value.map((el) => {
23
+ var _a, _b, _c;
24
+ return {
25
+ id: el.id,
26
+ url: "",
27
+ size: (_a = el == null ? void 0 : el.file) == null ? void 0 : _a.size,
28
+ name: (_b = el == null ? void 0 : el.file) == null ? void 0 : _b.name,
29
+ type: (_c = el == null ? void 0 : el.file) == null ? void 0 : _c.type
30
+ };
31
+ })
32
+ ];
33
+ setFiles(newFiles);
34
+ onChange == null ? void 0 : onChange({ type: "add", data: e.value });
35
+ };
36
+ const onDelete = (j) => {
37
+ setFiles(j.list);
38
+ if (j.deleteId) onChange == null ? void 0 : onChange({ type: "delete", data: j.deleteId });
39
+ };
40
+ return /* @__PURE__ */ jsxs(
41
+ "div",
42
+ {
43
+ className: classNames(
44
+ cls["upload-file__wrapper"],
45
+ isMaxFilesReached && cls.disabled
46
+ ),
47
+ children: [
48
+ /* @__PURE__ */ jsx(
49
+ Uploader,
50
+ {
51
+ filesType,
52
+ arrayName,
53
+ maxSize,
54
+ onChangeValue,
55
+ ref,
56
+ maxFiles,
57
+ isDisabled: isMaxFilesReached
58
+ }
59
+ ),
60
+ /* @__PURE__ */ jsx(ListFiles, { value: files, onChange: onDelete })
61
+ ]
62
+ }
63
+ );
64
+ }
65
+ );
66
+ export {
67
+ UploaderFiles
68
+ };
@@ -0,0 +1,2 @@
1
+ export { UploaderFiles } from './UploaderFiles';
2
+ export type { TUploaderFiles, TOnChangeFilesUpdate } from './UploaderFiles';
@@ -0,0 +1,4 @@
1
+ import { UploaderFiles } from "./UploaderFiles.js";
2
+ export {
3
+ UploaderFiles
4
+ };
@@ -31,6 +31,7 @@ const UploaderPhotos = forwardRef(
31
31
  setPhotos(j.list);
32
32
  if (j.deleteId) onChange == null ? void 0 : onChange({ type: "delete", data: j.deleteId });
33
33
  };
34
+ console.log(photos);
34
35
  return /* @__PURE__ */ jsxs(
35
36
  "div",
36
37
  {
@@ -0,0 +1,36 @@
1
+ import './assets/styles.css';const input = "_input_3fxwe_2";
2
+ const wrapper = "_wrapper_3fxwe_41";
3
+ const active = "_active_3fxwe_47";
4
+ const button = "_button_3fxwe_35";
5
+ const h = "_h_3fxwe_97";
6
+ const b = "_b_3fxwe_35";
7
+ const d = "_d_3fxwe_10";
8
+ const m = "_m_3fxwe_118";
9
+ const a = "_a_3fxwe_47";
10
+ const prev = "_prev_3fxwe_120";
11
+ const orange = "_orange_3fxwe_136";
12
+ const current = "_current_3fxwe_161";
13
+ const monthGrid = "_monthGrid_3fxwe_166";
14
+ const cls = {
15
+ input,
16
+ "input-wrapper": "_input-wrapper_3fxwe_6",
17
+ "date-wrapper": "_date-wrapper_3fxwe_10",
18
+ "button-wrapper": "_button-wrapper_3fxwe_35",
19
+ wrapper,
20
+ active,
21
+ button,
22
+ "field-overlow": "_field-overlow_3fxwe_68",
23
+ "calendar-block": "_calendar-block_3fxwe_74",
24
+ h,
25
+ b,
26
+ d,
27
+ m,
28
+ a,
29
+ prev,
30
+ orange,
31
+ current,
32
+ monthGrid
33
+ };
34
+ export {
35
+ cls as c
36
+ };
@@ -0,0 +1 @@
1
+ export default function Size(size: number): string;
@@ -0,0 +1,13 @@
1
+ function Size(size) {
2
+ if (!size) return "";
3
+ let i = -1;
4
+ const b = [" Kb", " Mb", " Gb", " Tb", "Pb", "Eb", "Zb", "Yb"];
5
+ do {
6
+ size /= 1024;
7
+ i += 1;
8
+ } while (size > 1024);
9
+ return Math.max(size, 0.1).toFixed(1) + b[i];
10
+ }
11
+ export {
12
+ Size as default
13
+ };
@@ -1,4 +1,5 @@
1
1
  import { default as Date } from './formating/Date';
2
+ import { default as Size } from './formating/FileSize';
2
3
  import { default as Month } from './formating/Month';
3
4
  import { default as Number } from './formating/Numbers';
4
5
  import { default as UUIDv4 } from './UUID4';
@@ -8,4 +9,5 @@ export declare const formating: {
8
9
  Month: typeof Month;
9
10
  Date: typeof Date;
10
11
  UUIDv4: typeof UUIDv4;
12
+ Size: typeof Size;
11
13
  };
@@ -1,4 +1,5 @@
1
1
  import _Date from "./formating/Date.js";
2
+ import Size from "./formating/FileSize.js";
2
3
  import Month from "./formating/Month.js";
3
4
  import Numbers from "./formating/Numbers.js";
4
5
  import UUIDv4 from "./UUID4.js";
@@ -6,7 +7,8 @@ const formating = {
6
7
  Number: Numbers,
7
8
  Month,
8
9
  Date: _Date,
9
- UUIDv4
10
+ UUIDv4,
11
+ Size
10
12
  };
11
13
  export {
12
14
  formating
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mimir-ui-kit",
3
3
  "private": false,
4
- "version": "1.21.3",
4
+ "version": "1.22.0",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
@@ -1,204 +0,0 @@
1
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import { useRef, useState, useEffect } from "react";
3
- import { week } from "./components/DatePicker/constants.js";
4
- import { formating } from "./utils/index.js";
5
- import { Button } from "./components/Button/Button.js";
6
- import './assets/DatePickerModal.css';const input = "_input_1ndkx_2";
7
- const wrapper = "_wrapper_1ndkx_21";
8
- const active = "_active_1ndkx_27";
9
- const button = "_button_1ndkx_35";
10
- const h = "_h_1ndkx_81";
11
- const b = "_b_1ndkx_35";
12
- const d = "_d_1ndkx_6";
13
- const m = "_m_1ndkx_100";
14
- const a = "_a_1ndkx_27";
15
- const prev = "_prev_1ndkx_102";
16
- const orange = "_orange_1ndkx_118";
17
- const current = "_current_1ndkx_143";
18
- const cls = {
19
- input,
20
- "date-wrapper": "_date-wrapper_1ndkx_6",
21
- wrapper,
22
- active,
23
- "input-wrapper": "_input-wrapper_1ndkx_31",
24
- "button-wrapper": "_button-wrapper_1ndkx_35",
25
- button,
26
- "field-overlow": "_field-overlow_1ndkx_52",
27
- "calendar-block": "_calendar-block_1ndkx_58",
28
- h,
29
- b,
30
- d,
31
- m,
32
- a,
33
- prev,
34
- orange,
35
- current
36
- };
37
- function DatePickerModal({
38
- date,
39
- onChangeValue,
40
- setActive,
41
- before
42
- }) {
43
- const field = useRef(null);
44
- const _current = new Date(date);
45
- const _selecte = new Date(date);
46
- const current2 = {
47
- y: _current.getFullYear(),
48
- d: _current.getDate(),
49
- m: _current.getMonth() + 1
50
- };
51
- const selecte = {
52
- y: _selecte.getFullYear(),
53
- d: _selecte.getDate(),
54
- m: _selecte.getMonth() + 1
55
- };
56
- const countWorkDays = 4;
57
- const [month, setMonth] = useState({ y: selecte.y, m: selecte.m });
58
- useEffect(() => {
59
- const windowHeight = window.innerHeight;
60
- if (field.current !== null) {
61
- const inputPosition = field.current.getBoundingClientRect();
62
- const calendarSize = field.current.offsetHeight;
63
- if (windowHeight < inputPosition.y + calendarSize) {
64
- field.current.style.top = -calendarSize + "px";
65
- } else {
66
- field.current.style.top = "65px";
67
- }
68
- field.current.style.opacity = "1";
69
- }
70
- }, [month]);
71
- const countPrevDays = (e) => {
72
- let dayOfWeek = e.getDay();
73
- if (dayOfWeek === 0) dayOfWeek = 7;
74
- return dayOfWeek - 1;
75
- };
76
- const currentMonthIndex = month.m - 1;
77
- const currentMonthFull = new Date(month.y, currentMonthIndex);
78
- const days = [];
79
- const prevDays = () => {
80
- const prevMonth = new Date(currentMonthFull);
81
- prevMonth.setDate(prevMonth.getDate() - 1);
82
- const lastDayPrevMohth = prevMonth.getDate();
83
- const prevList = [];
84
- for (let i = 0; i < countPrevDays(currentMonthFull); i++) {
85
- prevList.push(lastDayPrevMohth - i);
86
- }
87
- prevList.reverse();
88
- return prevList;
89
- };
90
- const prevDaysArray = prevDays();
91
- while (currentMonthFull.getMonth() === currentMonthIndex) {
92
- days.push(currentMonthFull.getDate());
93
- currentMonthFull.setDate(currentMonthFull.getDate() + 1);
94
- }
95
- const nextDays = () => {
96
- const totalViewDays = 42;
97
- const daysCount = totalViewDays - (prevDaysArray.length + days.length);
98
- const nextList = [];
99
- for (let i = 1; i <= daysCount; i++) {
100
- nextList.push(i);
101
- }
102
- return nextList;
103
- };
104
- const nextDaysArray = nextDays();
105
- const update = (m2, y) => {
106
- y = m2 > 12 ? y + 1 : m2 < 1 ? y - 1 : y;
107
- m2 = m2 > 12 ? 1 : m2 < 1 ? 12 : m2;
108
- return { y, m: m2 };
109
- };
110
- const onExit = () => {
111
- setActive(false);
112
- };
113
- const next = () => {
114
- setMonth(update(month.m + 1, month.y));
115
- };
116
- const prev2 = () => {
117
- setMonth(update(month.m - 1, month.y));
118
- };
119
- const isBefore = (activeDate) => {
120
- if (before) {
121
- const beforeDate = before.getTime();
122
- if (beforeDate > activeDate) return true;
123
- }
124
- return false;
125
- };
126
- const send = (searchDate) => {
127
- if (isBefore(
128
- (/* @__PURE__ */ new Date(
129
- `${month.y}-${formating.Number(2, month.m)}-${formating.Number(2, searchDate)}`
130
- )).getTime()
131
- ))
132
- return;
133
- onChangeValue(
134
- /* @__PURE__ */ new Date(
135
- `${month.y}-${formating.Number(2, month.m)}-${formating.Number(2, searchDate)}`
136
- )
137
- );
138
- onExit();
139
- };
140
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: [cls["calendar-block"]].join(" "), ref: field, children: [
141
- /* @__PURE__ */ jsxs("div", { className: cls["h"], children: [
142
- /* @__PURE__ */ jsx(
143
- Button,
144
- {
145
- isIconButton: true,
146
- iconName: "DropdownArrowLeft16px",
147
- onClick: prev2,
148
- variant: "secondary-gray",
149
- size: "l"
150
- }
151
- ),
152
- /* @__PURE__ */ jsxs("div", { className: cls["d"], children: [
153
- formating.Month(month.m).name,
154
- "’",
155
- month.y.toString().slice(-2)
156
- ] }),
157
- /* @__PURE__ */ jsx(
158
- Button,
159
- {
160
- isIconButton: true,
161
- iconName: "DropdownArrowRight16px",
162
- onClick: next,
163
- variant: "secondary-gray",
164
- size: "l"
165
- }
166
- )
167
- ] }),
168
- /* @__PURE__ */ jsxs("div", { className: cls["b"], children: [
169
- week.map((i, s) => /* @__PURE__ */ jsx(
170
- "div",
171
- {
172
- className: `${s > countWorkDays ? [cls["m"], cls["orange"]].join(" ") : cls["m"]}`,
173
- children: i
174
- },
175
- `v${s}`
176
- )),
177
- prevDaysArray.map((el, key) => /* @__PURE__ */ jsx("div", { className: cls["m"], children: el }, key)),
178
- days.map((i, s) => /* @__PURE__ */ jsx(
179
- "div",
180
- {
181
- className: isBefore(
182
- (/* @__PURE__ */ new Date(
183
- `${month.y}-${formating.Number(2, month.m)}-${formating.Number(2, i)}`
184
- )).getTime()
185
- ) ? cls["m"] : cls["a"],
186
- children: i !== 0 ? /* @__PURE__ */ jsx(
187
- "b",
188
- {
189
- className: current2.y === month.y && current2.m === month.m && current2.d === i ? cls["current"] : "",
190
- onClick: () => send(i),
191
- children: i
192
- }
193
- ) : /* @__PURE__ */ jsx("p", {})
194
- },
195
- s
196
- )),
197
- nextDaysArray.map((el, key) => /* @__PURE__ */ jsx("div", { className: cls["m"], children: el }, key))
198
- ] })
199
- ] }) });
200
- }
201
- export {
202
- DatePickerModal as D,
203
- cls as c
204
- };
@@ -1 +0,0 @@
1
- ._input_1ndkx_2{padding-right:var(--space-3xl)}._date-wrapper_1ndkx_6{position:relative;width:100%}._date-wrapper_1ndkx_6:hover input{background:var(--input-bg-color-hover)}._date-wrapper_1ndkx_6:before{position:absolute;top:0;right:60px;bottom:0;left:0;z-index:3;cursor:pointer;content:""}._wrapper_1ndkx_21{position:relative;display:flex;align-items:center;border-radius:var(--control-radius-s)}._wrapper_1ndkx_21._active_1ndkx_27{border-bottom:1px solid var(--citrine-100)}._input-wrapper_1ndkx_31{flex:1}._button-wrapper_1ndkx_35{position:absolute;top:0;right:0;z-index:2;display:flex;width:44px;height:100%;max-height:var(--button-height-xxl)}._button_1ndkx_35{align-self:center;background-color:transparent;border-radius:var(--control-radius-s)}._field-overlow_1ndkx_52{position:fixed;top:0;right:0;bottom:0;left:0;z-index:3}._calendar-block_1ndkx_58{position:absolute;z-index:3;display:flex;flex-direction:column;width:368px;max-height:none;padding:16px;font-weight:var(--font-weight-text-regular);font-size:var(--size-text-l);font-family:var(--font-inter);font-style:normal;line-height:var(--line-height-text-2xs);text-align:center;text-overflow:ellipsis;background:#fff;border-radius:var(--control-radius-s);box-shadow:0 0 #16172705,0 2px 4px #16172705,0 6px 6px #16172705,0 15px 9px #16172703;opacity:0;transition:height .5s ease-in;font-feature-settings:"zero";font-variant-numeric:slashed-zero}._calendar-block_1ndkx_58 ._h_1ndkx_81{display:flex;width:100%;color:var(--black-100)}._calendar-block_1ndkx_58 ._b_1ndkx_35{display:grid;grid-template-columns:repeat(7,1fr)}._calendar-block_1ndkx_58 ._d_1ndkx_6{display:flex;flex:1;align-items:center;justify-content:center;color:var(--black-100)}._calendar-block_1ndkx_58 ._m_1ndkx_100,._calendar-block_1ndkx_58 ._a_1ndkx_27,._calendar-block_1ndkx_58 ._prev_1ndkx_102{width:48px;height:48px;overflow:hidden}._calendar-block_1ndkx_58 ._m_1ndkx_100{display:flex;align-items:center;justify-content:center;color:var(--disabled)}._calendar-block_1ndkx_58 ._m_1ndkx_100 b{font-weight:var(--font-weight-text-regular)}._calendar-block_1ndkx_58 ._orange_1ndkx_118{color:var(--citrine-100)}._calendar-block_1ndkx_58 ._a_1ndkx_27{color:var(--black-100);border-radius:var(--control-radius-s)}._calendar-block_1ndkx_58 ._a_1ndkx_27 b{display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-weight:var(--font-weight-text-regular);cursor:pointer}._calendar-block_1ndkx_58 ._a_1ndkx_27 b:hover{background:var(--black-10)}._calendar-block_1ndkx_58 ._a_1ndkx_27 b:active{color:var(--white);background:var(--sapphire-100)}._calendar-block_1ndkx_58 ._current_1ndkx_143{background:var(--sapphire-10);border-radius:var(--control-radius-s)}