@jenesei-software/jenesei-kit-react 1.3.29 → 1.3.31

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 (145) hide show
  1. package/build/area-preview.cjs.js +1 -1
  2. package/build/area-preview.es.js +1 -1
  3. package/build/area-skeleton.cjs.js +1 -1
  4. package/build/area-skeleton.es.js +1 -1
  5. package/build/build-info.txt +3 -3
  6. package/build/{component-BaGCJM5V.js → component-BEkYgajE.js} +2 -2
  7. package/build/{component-BaGCJM5V.js.map → component-BEkYgajE.js.map} +1 -1
  8. package/build/{component-DJcrW4KX.js → component-BFDCc96N.js} +2 -2
  9. package/build/{component-DJcrW4KX.js.map → component-BFDCc96N.js.map} +1 -1
  10. package/build/{component-BgFRZSbi.cjs → component-BFLPbIpv.cjs} +2 -2
  11. package/build/{component-BgFRZSbi.cjs.map → component-BFLPbIpv.cjs.map} +1 -1
  12. package/build/{component-yTziSQZ7.js → component-BV20JUqs.js} +3 -3
  13. package/build/{component-yTziSQZ7.js.map → component-BV20JUqs.js.map} +1 -1
  14. package/build/{component-BT3dejQO.js → component-BpgbR-JI.js} +2 -2
  15. package/build/{component-BT3dejQO.js.map → component-BpgbR-JI.js.map} +1 -1
  16. package/build/{component-Br2H7F-p.js → component-BqSYYCb3.js} +2 -2
  17. package/build/{component-Br2H7F-p.js.map → component-BqSYYCb3.js.map} +1 -1
  18. package/build/{component-Cp433cAv.js → component-BsjFCBxJ.js} +3 -3
  19. package/build/{component-Cp433cAv.js.map → component-BsjFCBxJ.js.map} +1 -1
  20. package/build/{component-Dwf2HFot.cjs → component-ByU2po_i.cjs} +2 -2
  21. package/build/{component-Dwf2HFot.cjs.map → component-ByU2po_i.cjs.map} +1 -1
  22. package/build/{component-BpwTWRxp.js → component-C-oN9gXq.js} +2 -2
  23. package/build/{component-BpwTWRxp.js.map → component-C-oN9gXq.js.map} +1 -1
  24. package/build/{component-D2Y1Ky9N.js → component-CJWnWh-4.js} +4 -4
  25. package/build/{component-D2Y1Ky9N.js.map → component-CJWnWh-4.js.map} +1 -1
  26. package/build/{component-BzFd5DyJ.js → component-CMUWN8YO.js} +3 -3
  27. package/build/{component-BzFd5DyJ.js.map → component-CMUWN8YO.js.map} +1 -1
  28. package/build/{component-ClQrDMsC.cjs → component-CSY_QAf5.cjs} +2 -2
  29. package/build/{component-ClQrDMsC.cjs.map → component-CSY_QAf5.cjs.map} +1 -1
  30. package/build/{component-OxaRuSX5.cjs → component-D8qNfh_3.cjs} +2 -2
  31. package/build/{component-OxaRuSX5.cjs.map → component-D8qNfh_3.cjs.map} +1 -1
  32. package/build/{component-TMPesaZf.cjs → component-DE1S-lZ5.cjs} +2 -2
  33. package/build/{component-TMPesaZf.cjs.map → component-DE1S-lZ5.cjs.map} +1 -1
  34. package/build/{component-BABozkX6.cjs → component-DfZKriX4.cjs} +2 -2
  35. package/build/{component-BABozkX6.cjs.map → component-DfZKriX4.cjs.map} +1 -1
  36. package/build/{component-CsIx8Dgr.cjs → component-Dl6zU2mb.cjs} +2 -2
  37. package/build/{component-CsIx8Dgr.cjs.map → component-Dl6zU2mb.cjs.map} +1 -1
  38. package/build/{component-CjiOOMn9.cjs → component-Dmn44ouM.cjs} +2 -2
  39. package/build/{component-CjiOOMn9.cjs.map → component-Dmn44ouM.cjs.map} +1 -1
  40. package/build/{component-BHfH9Gw4.js → component-Tjc4KXtU.js} +2 -2
  41. package/build/{component-BHfH9Gw4.js.map → component-Tjc4KXtU.js.map} +1 -1
  42. package/build/{component-DYX1oGKH.js → component-UAARmvBH.js} +2 -2
  43. package/build/{component-DYX1oGKH.js.map → component-UAARmvBH.js.map} +1 -1
  44. package/build/component-accordion.cjs.js +1 -1
  45. package/build/component-accordion.es.js +2 -2
  46. package/build/component-button-group.cjs.js +1 -1
  47. package/build/component-button-group.es.js +2 -2
  48. package/build/component-button.cjs.js +1 -1
  49. package/build/component-button.es.js +1 -1
  50. package/build/component-checkbox-group.cjs.js +1 -1
  51. package/build/component-checkbox-group.es.js +2 -2
  52. package/build/component-checkbox.cjs.js +1 -1
  53. package/build/component-checkbox.es.js +2 -2
  54. package/build/component-date-picker.cjs.js +1 -1
  55. package/build/component-date-picker.d.ts +8 -0
  56. package/build/component-date-picker.es.js +4 -2
  57. package/build/component-icon.cjs.js +1 -1
  58. package/build/component-icon.es.js +6 -6
  59. package/build/component-image-button.cjs.js +1 -1
  60. package/build/component-image-button.es.js +1 -1
  61. package/build/component-image-select.cjs.js +1 -1
  62. package/build/component-image-select.es.js +8 -8
  63. package/build/component-image-slider.cjs.js +1 -1
  64. package/build/component-image-slider.es.js +4 -4
  65. package/build/component-image.cjs.js +1 -1
  66. package/build/component-image.es.js +3 -3
  67. package/build/component-input-otp.cjs.js +1 -1
  68. package/build/component-input-otp.es.js +5 -5
  69. package/build/component-input.cjs.js +1 -1
  70. package/build/component-input.es.js +15 -15
  71. package/build/{component-B97JZKUB.cjs → component-jeO6CsTP.cjs} +2 -2
  72. package/build/{component-B97JZKUB.cjs.map → component-jeO6CsTP.cjs.map} +1 -1
  73. package/build/component-map.cjs.js +1 -1
  74. package/build/component-map.es.js +8 -8
  75. package/build/component-pagination.cjs.js +1 -1
  76. package/build/component-pagination.es.js +1 -1
  77. package/build/component-range.cjs.js +1 -1
  78. package/build/component-range.es.js +5 -5
  79. package/build/component-select.cjs.js +1 -1
  80. package/build/component-select.es.js +18 -18
  81. package/build/{component-DcAF7Isg.cjs → component-ssaD7jJ-.cjs} +2 -2
  82. package/build/{component-DcAF7Isg.cjs.map → component-ssaD7jJ-.cjs.map} +1 -1
  83. package/build/component-textarea.cjs.js +1 -1
  84. package/build/component-textarea.d.ts +3 -0
  85. package/build/component-textarea.es.js +5 -5
  86. package/build/component-toggle.cjs.js +1 -1
  87. package/build/component-toggle.es.js +4 -4
  88. package/build/component-tooltip.cjs.js +1 -1
  89. package/build/component-tooltip.d.ts +107 -0
  90. package/build/component-tooltip.es.js +9 -9
  91. package/build/component-typography.cjs.js +1 -1
  92. package/build/component-typography.d.ts +107 -0
  93. package/build/component-typography.es.js +6 -6
  94. package/build/{component-DFMjWiWi.cjs → component-zyoew755.cjs} +2 -2
  95. package/build/{component-DFMjWiWi.cjs.map → component-zyoew755.cjs.map} +1 -1
  96. package/build/{component.components-KcVM2DN2.js → component.components-CFsHZ-xd.js} +2 -2
  97. package/build/{component.components-KcVM2DN2.js.map → component.components-CFsHZ-xd.js.map} +1 -1
  98. package/build/{component.components-CsWG1Rwi.cjs → component.components-DnPZVXuo.cjs} +2 -2
  99. package/build/{component.components-CsWG1Rwi.cjs.map → component.components-DnPZVXuo.cjs.map} +1 -1
  100. package/build/{component.constants-B-csc6ih.cjs → component.constants-4oL81SFS.cjs} +2 -2
  101. package/build/{component.constants-B-csc6ih.cjs.map → component.constants-4oL81SFS.cjs.map} +1 -1
  102. package/build/{component.constants-BkbucsSA.js → component.constants-B3aCG9Aq.js} +3 -3
  103. package/build/{component.constants-BkbucsSA.js.map → component.constants-B3aCG9Aq.js.map} +1 -1
  104. package/build/{component.constants-ECVKYlcl.cjs → component.constants-DIRNAI_M.cjs} +2 -2
  105. package/build/{component.constants-ECVKYlcl.cjs.map → component.constants-DIRNAI_M.cjs.map} +1 -1
  106. package/build/{component.constants-BmRV80H6.js → component.constants-DWE902Cf.js} +2 -2
  107. package/build/{component.constants-BmRV80H6.js.map → component.constants-DWE902Cf.js.map} +1 -1
  108. package/build/component.types-D7_uJxuD.cjs +2 -0
  109. package/build/component.types-D7_uJxuD.cjs.map +1 -0
  110. package/build/{component.types-Cc_Ly48_.js → component.types-DhrhPsES.js} +187 -154
  111. package/build/component.types-DhrhPsES.js.map +1 -0
  112. package/build/consts.cjs.js +1 -1
  113. package/build/consts.es.js +1 -1
  114. package/build/context-app.cjs.js +1 -1
  115. package/build/context-app.es.js +17 -17
  116. package/build/context-sonner.cjs.js +1 -1
  117. package/build/context-sonner.es.js +18 -18
  118. package/build/{context.constants-CHzb-q9a.cjs → context.constants-CPdsUeiQ.cjs} +215 -206
  119. package/build/context.constants-CPdsUeiQ.cjs.map +1 -0
  120. package/build/{context.constants-ByIVCRij.js → context.constants-D8UVM6GL.js} +247 -134
  121. package/build/{context.constants-ByIVCRij.js.map → context.constants-D8UVM6GL.js.map} +1 -1
  122. package/build/{context.hooks-BDsIAUYd.js → context.hooks-1u3F7jId.js} +2 -2
  123. package/build/{context.hooks-BDsIAUYd.js.map → context.hooks-1u3F7jId.js.map} +1 -1
  124. package/build/{context.hooks-Bjivw-Im.cjs → context.hooks-Bi7-SukA.cjs} +2 -2
  125. package/build/{context.hooks-Bjivw-Im.cjs.map → context.hooks-Bi7-SukA.cjs.map} +1 -1
  126. package/build/{context.hooks-BHOQU6q9.cjs → context.hooks-CEM899ZV.cjs} +2 -2
  127. package/build/{context.hooks-BHOQU6q9.cjs.map → context.hooks-CEM899ZV.cjs.map} +1 -1
  128. package/build/{context.hooks-BGRydtLx.js → context.hooks-Ds6nn4po.js} +2 -2
  129. package/build/{context.hooks-BGRydtLx.js.map → context.hooks-Ds6nn4po.js.map} +1 -1
  130. package/build/index.cjs.js +1 -1
  131. package/build/index.d.ts +118 -0
  132. package/build/index.es.js +141 -139
  133. package/build/style-error.cjs.js +1 -1
  134. package/build/style-error.es.js +4 -4
  135. package/build/style-theme.cjs.js +1 -1
  136. package/build/style-theme.es.js +13 -13
  137. package/build/{use-2JigT9W0.cjs → use-BwhyveId.cjs} +2 -2
  138. package/build/{use-2JigT9W0.cjs.map → use-BwhyveId.cjs.map} +1 -1
  139. package/build/{use-DQXYSmcn.js → use-CjnNUWWw.js} +3 -3
  140. package/build/{use-DQXYSmcn.js.map → use-CjnNUWWw.js.map} +1 -1
  141. package/package.json +2 -2
  142. package/build/component.types-Cc_Ly48_.js.map +0 -1
  143. package/build/component.types-DqOJPJfu.cjs +0 -2
  144. package/build/component.types-DqOJPJfu.cjs.map +0 -1
  145. package/build/context.constants-CHzb-q9a.cjs.map +0 -1
@@ -1,17 +1,12 @@
1
1
  import { j as jsxRuntimeExports } from "./jsx-runtime-BrDlu8eK.js";
2
- import { bt as KEY_SIZE_DATA, bC as usePopover, D as DateWrapper, z as DateInputWrapper, aR as Typography, x as DateInput, F as DateInputButton, bD as Popover, s as DateDropdownList, B as Button, ao as SelectMonth, aq as SelectYear, t as DateDropdownDays, w as DateDropdownDayOfWeek, v as DateDropdownDay, bp as ErrorMessage } from "./context.constants-ByIVCRij.js";
2
+ import { bv as KEY_SIZE_DATA, bE as usePopover, D as DateWrapper, z as DateInputWrapper, aT as Typography, x as DateInput, F as DateInputButton, H as DateInputButtonClear, bF as Popover, s as DateDropdownList, B as Button, aq as SelectMonth, as as SelectYear, t as DateDropdownDays, w as DateDropdownDayOfWeek, v as DateDropdownDay, br as ErrorMessage } from "./context.constants-D8UVM6GL.js";
3
3
  import "./component.styles-B0L4jbOO.js";
4
4
  import { R as Ripple } from "./component-DHM9pbab.js";
5
5
  import { b as Stack } from "./component-DEZX8aBs.js";
6
6
  import moment from "moment";
7
- import { useState, useRef, useEffect, useMemo, useCallback, Fragment } from "react";
7
+ import { useState, useEffect, useRef, useMemo, useCallback, Fragment } from "react";
8
8
  import { useTheme } from "styled-components";
9
- function countSevens(number) {
10
- const divisor = 7;
11
- const count = Math.floor(number / divisor);
12
- const remainder = number % divisor;
13
- return remainder > 0 ? count + 1 : count;
14
- }
9
+ const weekOrder = ["mo", "tu", "we", "th", "fr", "sa", "su"];
15
10
  const DatePicker = (props) => {
16
11
  var _a, _b, _c, _d;
17
12
  const { onChange } = props;
@@ -23,13 +18,13 @@ const DatePicker = (props) => {
23
18
  [DatePickerVariant.MM]: "",
24
19
  [DatePickerVariant.YYYY]: ""
25
20
  });
26
- const refInputValue = useRef(input);
27
21
  useEffect(() => {
28
22
  refInputValue.current = input;
29
23
  }, [input]);
30
- const isHasInput = useMemo(() => {
31
- return input[DatePickerVariant.DD] !== "" || input[DatePickerVariant.MM] !== "" || input[DatePickerVariant.YYYY] !== "";
32
- }, [input]);
24
+ const isHasInput = useMemo(
25
+ () => input[DatePickerVariant.DD] !== "" || input[DatePickerVariant.MM] !== "" || input[DatePickerVariant.YYYY] !== "",
26
+ [input]
27
+ );
33
28
  const onClearInput = useCallback(() => {
34
29
  setInput({
35
30
  [DatePickerVariant.DD]: "",
@@ -49,42 +44,12 @@ const DatePicker = (props) => {
49
44
  }
50
45
  return props.mode;
51
46
  }, [props.mode]);
52
- const getNextSegment = useCallback(
53
- (currentSegment) => {
54
- const currentIndex = mode.indexOf(currentSegment);
55
- return currentIndex < mode.length - 1 ? mode[currentIndex + 1] : mode[0];
56
- },
57
- [mode]
58
- );
59
- const getPrevSegment = useCallback(
60
- (currentSegment) => {
61
- const currentIndex = mode.indexOf(currentSegment);
62
- return currentIndex > 0 ? mode[currentIndex - 1] : mode[mode.length - 1];
63
- },
64
- [mode]
65
- );
66
- const getValidateInput = useCallback(
67
- (input2, onSuccess, onFailure, onNan) => {
68
- const dayStr = input2.DD;
69
- const monthStr = input2.MM;
70
- const yearStr = input2.YYYY;
71
- const day = dayStr === "" ? NaN : Number(dayStr);
72
- const month = monthStr === "" ? NaN : Number(monthStr);
73
- const year = yearStr === "" ? NaN : Number(yearStr);
74
- const isHasInput2 = dayStr !== "" || monthStr !== "" || yearStr !== "";
75
- if (!Number.isNaN(day) && !Number.isNaN(month) && !Number.isNaN(year)) {
76
- const m = moment.utc(`${day}.${month}.${year}`, "D.M.YYYY", true).startOf("day");
77
- if (m.isValid()) {
78
- onSuccess == null ? void 0 : onSuccess(m.valueOf());
79
- } else {
80
- onFailure == null ? void 0 : onFailure();
81
- }
82
- } else {
83
- onNan == null ? void 0 : onNan(isHasInput2);
84
- }
85
- },
86
- []
87
- );
47
+ const type = useMemo(() => {
48
+ if (!props.type) {
49
+ return "manualAndSelect";
50
+ }
51
+ return props.type;
52
+ }, [props.type]);
88
53
  const dataDate = useMemo(() => {
89
54
  const segments = [DatePickerVariant.DD, DatePickerVariant.MM, DatePickerVariant.YYYY];
90
55
  const result = Object.fromEntries(
@@ -96,10 +61,10 @@ const DatePicker = (props) => {
96
61
  placeholder: props.locale.inputs[segment === DatePickerVariant.DD ? "day" : segment === DatePickerVariant.MM ? "month" : "year"],
97
62
  isFirst: mode[0] === segment,
98
63
  isLast: mode[mode.length - 1] === segment,
99
- segmentNext: getNextSegment(segment),
100
- segmentPrev: getPrevSegment(segment),
101
- onNextSegment: () => setActiveSegment(getNextSegment(segment)),
102
- onPrevSegment: () => setActiveSegment(getPrevSegment(segment)),
64
+ segmentNext: getNextSegment(segment, mode),
65
+ segmentPrev: getPrevSegment(segment, mode),
66
+ onNextSegment: () => setActiveSegment(getNextSegment(segment, mode)),
67
+ onPrevSegment: () => setActiveSegment(getPrevSegment(segment, mode)),
103
68
  setValue: (value) => setInput((prev) => ({ ...prev, [segment]: value })),
104
69
  setActive: () => setActiveSegment(segment)
105
70
  }
@@ -107,9 +72,8 @@ const DatePicker = (props) => {
107
72
  );
108
73
  const resultSort = mode.map((segment) => result[segment]).filter(Boolean);
109
74
  return { sort: resultSort, default: result };
110
- }, [props, getNextSegment, getPrevSegment, mode, input]);
75
+ }, [props, mode, input]);
111
76
  const daysInWeek = useMemo(() => {
112
- const weekOrder = ["mo", "tu", "we", "th", "fr", "sa", "su"];
113
77
  return weekOrder.map((key, index) => {
114
78
  const found = props.locale.weeks.find((w) => w.value === key);
115
79
  return {
@@ -119,47 +83,38 @@ const DatePicker = (props) => {
119
83
  });
120
84
  }, [props.locale.weeks]);
121
85
  const daysInMonth = useMemo(() => {
122
- const today = moment.utc();
123
- const baseMoment = valueMoment ?? dateDefaultMoment;
124
- const startOfMonth = baseMoment.clone().startOf("month");
125
- const endOfMonth = baseMoment.clone().endOf("month");
86
+ const dateToday = moment.utc();
87
+ const dateValue = valueMoment ?? dateDefaultMoment;
88
+ const dateStartOfMonth = dateValue.clone().startOf("month");
89
+ const dateEndOfMonth = dateValue.clone().endOf("month");
126
90
  const dateMin = props.dateMin ? moment.utc(props.dateMin) : null;
127
91
  const dateMax = props.dateMax ? moment.utc(props.dateMax) : null;
128
- const firstVisibleDay = startOfMonth.clone().subtract(startOfMonth.isoWeekday() - 1, "days");
129
- const lastVisibleDay = endOfMonth.clone().add(7 - endOfMonth.isoWeekday(), "days");
130
- const days = [];
131
- const currentDate = firstVisibleDay.clone();
132
- while (currentDate <= lastVisibleDay) {
133
- const isCurrentMonth = currentDate.isBetween(startOfMonth, endOfMonth, "day", "[]");
134
- days.push({
135
- value: currentDate.valueOf(),
136
- labelString: currentDate.format("dd"),
137
- labelNumber: currentDate.date(),
138
- dayOfWeek: currentDate.isoWeekday(),
139
- isWeekend: [6, 7].includes(currentDate.isoWeekday()),
140
- weekOfMonth: Math.ceil((days.length + 1) / 7),
141
- isToday: currentDate.isSame(today, "day"),
92
+ const dateVisibleDayFirst = dateStartOfMonth.clone().subtract(dateStartOfMonth.isoWeekday() - 1, "days");
93
+ const dateVisibleDayLast = dateEndOfMonth.clone().add(7 - dateEndOfMonth.isoWeekday(), "days");
94
+ const result = [];
95
+ const dateCurrent = dateVisibleDayFirst.clone();
96
+ while (dateCurrent <= dateVisibleDayLast) {
97
+ const isCurrentMonth = dateCurrent.isBetween(dateStartOfMonth, dateEndOfMonth, "day", "[]");
98
+ result.push({
99
+ value: dateCurrent.valueOf(),
100
+ labelString: dateCurrent.format("dd"),
101
+ labelNumber: dateCurrent.date(),
102
+ dayOfWeek: dateCurrent.isoWeekday(),
103
+ isWeekend: [6, 7].includes(dateCurrent.isoWeekday()),
104
+ weekOfMonth: Math.ceil((result.length + 1) / 7),
105
+ isToday: dateCurrent.isSame(dateToday, "day"),
142
106
  isCurrentMonth,
143
- isDisabled: !!(dateMin && currentDate.isBefore(dateMin, "day") || dateMax && currentDate.isAfter(dateMax, "day"))
107
+ isDisabled: !!(dateMin && dateCurrent.isBefore(dateMin, "day") || dateMax && dateCurrent.isAfter(dateMax, "day"))
144
108
  });
145
- currentDate.add(1, "day");
109
+ dateCurrent.add(1, "day");
146
110
  }
147
- return days;
111
+ return result;
148
112
  }, [valueMoment, dateDefaultMoment, props.dateMax, props.dateMin]);
149
- const rows = useMemo(() => countSevens(daysInMonth.length) + 1, [daysInMonth]);
150
- const height = useMemo(
151
- () => 40 + rows * 28 + (rows - 1) * 6 + KEY_SIZE_DATA[props.size].padding * 2,
152
- [props.size, rows]
153
- );
113
+ const rows = useMemo(() => getCountSevens(daysInMonth.length) + 1, [daysInMonth]);
154
114
  const sizeRadius = useMemo(() => KEY_SIZE_DATA[props.size].radius, [props.size]);
155
115
  const sizePadding = useMemo(() => KEY_SIZE_DATA[props.size].padding, [props.size]);
156
- const isHasValue = useMemo(() => {
157
- return valueMoment !== null;
158
- }, [valueMoment]);
159
- const refIsHasValueOnce = useRef(false);
160
- useEffect(() => {
161
- if (isHasValue && !refIsHasValueOnce.current) refIsHasValueOnce.current = true;
162
- }, [isHasValue]);
116
+ const height = useMemo(() => 40 + rows * 28 + (rows - 1) * 6 + sizePadding * 2, [sizePadding, rows]);
117
+ const isHasValue = useMemo(() => valueMoment !== null, [valueMoment]);
163
118
  const isBlockNextMonth = useMemo(() => {
164
119
  const nextMonth = (valueMoment ?? dateDefaultMoment).clone().add(1, "month").startOf("month");
165
120
  const isBeforeEndDate = props.dateMax ? nextMonth.isAfter(moment.utc(props.dateMax), "month") : false;
@@ -171,6 +126,8 @@ const DatePicker = (props) => {
171
126
  return isAfterStartDate;
172
127
  }, [valueMoment, props.dateMin, dateDefaultMoment]);
173
128
  const [isInputFocused, setIsInputFocused] = useState(false);
129
+ const refInputValue = useRef(input);
130
+ const refIsHasValueOnce = useRef(false);
174
131
  const refPrevValue = useRef("");
175
132
  const refSelectMonth = useRef(null);
176
133
  const refSelectYear = useRef(null);
@@ -198,8 +155,8 @@ const DatePicker = (props) => {
198
155
  onBlurReference
199
156
  });
200
157
  const isShowPlaceholder = useMemo(() => {
201
- return !!(!isInputFocused && !isHasValue && props.labelPlaceholder && !isOpen && !isHasInput && !activeSegment);
202
- }, [isInputFocused, isHasValue, isOpen, props.labelPlaceholder, isHasInput, activeSegment]);
158
+ return !!(!isInputFocused && !isHasValue && props.labelPlaceholder && (type !== "select" ? !isOpen : true) && !isHasInput && !activeSegment);
159
+ }, [isInputFocused, isHasValue, isOpen, props.labelPlaceholder, isHasInput, activeSegment, type]);
203
160
  const onChangeDate = useCallback(
204
161
  (timestamp, isAddLeadingZeros, input2) => {
205
162
  const momentNewDate = moment(timestamp).utc();
@@ -241,7 +198,7 @@ const DatePicker = (props) => {
241
198
  if (activeSegment && dataDate.default[activeSegment]) {
242
199
  if (isDigit) {
243
200
  const digit = key;
244
- handleDigitKey(digit, activeSegment, input, dataDate);
201
+ getDigitKey(digit, activeSegment, input, dataDate);
245
202
  e.preventDefault();
246
203
  e.stopPropagation();
247
204
  }
@@ -318,6 +275,59 @@ const DatePicker = (props) => {
318
275
  const newDate = (valueMoment ?? dateDefaultMoment).clone().subtract(1, "month");
319
276
  onChangeDate(newDate.valueOf(), true);
320
277
  }, [valueMoment, onChangeDate, dateDefaultMoment]);
278
+ const onFocusInput = useCallback(() => {
279
+ if (type === "select") return;
280
+ setIsInputFocused(true);
281
+ if (!activeSegment) setActiveSegment(DatePickerVariant.DD);
282
+ }, [activeSegment, type]);
283
+ const onBlurInput = useCallback(() => {
284
+ var _a2;
285
+ setIsInputFocused(false);
286
+ if (!isOpen) {
287
+ (_a2 = props.onBlur) == null ? void 0 : _a2.call(props);
288
+ }
289
+ }, [isOpen, props.onBlur]);
290
+ const onChangeInput = useCallback(
291
+ (e) => {
292
+ const value = e.target.value;
293
+ const result = getParseDateString(value);
294
+ if (result) {
295
+ setInput({
296
+ DD: String(result.day).padStart(2, "0"),
297
+ MM: String(result.month).padStart(2, "0"),
298
+ YYYY: String(result.year)
299
+ });
300
+ if (refHiddenInput.current) refHiddenInput.current.value = "";
301
+ return;
302
+ }
303
+ const prevValue = refPrevValue.current;
304
+ const newChar = value.length > prevValue.length ? value.slice(-1) : null;
305
+ refPrevValue.current = value;
306
+ if (newChar && /^\d$/.test(newChar)) {
307
+ onKeyDown({
308
+ key: newChar,
309
+ preventDefault: () => {
310
+ },
311
+ stopPropagation: () => {
312
+ }
313
+ });
314
+ }
315
+ if (value.length < prevValue.length) {
316
+ onKeyDown({
317
+ key: "Backspace",
318
+ preventDefault: () => {
319
+ },
320
+ stopPropagation: () => {
321
+ }
322
+ });
323
+ }
324
+ if (refHiddenInput.current) refHiddenInput.current.value = "";
325
+ },
326
+ [onKeyDown]
327
+ );
328
+ useEffect(() => {
329
+ if (isHasValue && !refIsHasValueOnce.current) refIsHasValueOnce.current = true;
330
+ }, [isHasValue]);
321
331
  useEffect(() => {
322
332
  setDateDefaultMoment(moment(props.dateDefault).utc());
323
333
  }, [props.dateDefault]);
@@ -354,7 +364,7 @@ const DatePicker = (props) => {
354
364
  }
355
365
  }
356
366
  );
357
- }, [getValidateInput, onChangeDate, onChange, input, activeSegment]);
367
+ }, [onChangeDate, onChange, input, activeSegment]);
358
368
  useEffect(() => {
359
369
  if (!isOpen && !isInputFocused && isHasInput && !activeSegment)
360
370
  getValidateInput(
@@ -372,7 +382,7 @@ const DatePicker = (props) => {
372
382
  setIsError(false);
373
383
  }
374
384
  );
375
- }, [getValidateInput, onClearInput, input, isOpen, isInputFocused, onChange, isHasInput, activeSegment]);
385
+ }, [onClearInput, input, isOpen, isInputFocused, onChange, isHasInput, activeSegment]);
376
386
  useEffect(() => {
377
387
  if (!activeSegment) return;
378
388
  getValidateInput(
@@ -390,7 +400,7 @@ const DatePicker = (props) => {
390
400
  }
391
401
  }
392
402
  );
393
- }, [onChangeDate, getValidateInput, activeSegment]);
403
+ }, [onChangeDate, activeSegment]);
394
404
  useEffect(() => {
395
405
  var _a2;
396
406
  if (activeSegment) {
@@ -429,10 +439,14 @@ const DatePicker = (props) => {
429
439
  } : props.error,
430
440
  $isOpen: isOpen || !!activeSegment,
431
441
  onClick: () => {
442
+ if (type === "select") {
443
+ toggle();
444
+ return;
445
+ }
432
446
  if (!activeSegment && !(props == null ? void 0 : props.isReadOnly)) setActiveSegment(DatePickerVariant.DD);
433
447
  },
434
448
  children: [
435
- /* @__PURE__ */ jsxRuntimeExports.jsx(
449
+ type !== "select" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
436
450
  "input",
437
451
  {
438
452
  name: props.name,
@@ -455,55 +469,11 @@ const DatePicker = (props) => {
455
469
  background: "transparent"
456
470
  },
457
471
  onKeyDown,
458
- onChange: (e) => {
459
- const value = e.target.value;
460
- console.log("value", value);
461
- const result = parseDateString(value);
462
- if (result) {
463
- setInput({
464
- DD: String(result.day).padStart(2, "0"),
465
- MM: String(result.month).padStart(2, "0"),
466
- YYYY: String(result.year)
467
- });
468
- if (refHiddenInput.current) refHiddenInput.current.value = "";
469
- return;
470
- }
471
- const prevValue = refPrevValue.current;
472
- const newChar = value.length > prevValue.length ? value.slice(-1) : null;
473
- refPrevValue.current = value;
474
- if (newChar && /^\d$/.test(newChar)) {
475
- onKeyDown({
476
- key: newChar,
477
- preventDefault: () => {
478
- },
479
- stopPropagation: () => {
480
- }
481
- });
482
- }
483
- if (value.length < prevValue.length) {
484
- onKeyDown({
485
- key: "Backspace",
486
- preventDefault: () => {
487
- },
488
- stopPropagation: () => {
489
- }
490
- });
491
- }
492
- if (refHiddenInput.current) refHiddenInput.current.value = "";
493
- },
494
- onFocus: () => {
495
- setIsInputFocused(true);
496
- if (!activeSegment) setActiveSegment(DatePickerVariant.DD);
497
- },
498
- onBlur: () => {
499
- var _a2;
500
- setIsInputFocused(false);
501
- if (!isOpen) {
502
- (_a2 = props.onBlur) == null ? void 0 : _a2.call(props);
503
- }
504
- }
472
+ onChange: onChangeInput,
473
+ onFocus: onFocusInput,
474
+ onBlur: onBlurInput
505
475
  }
506
- ),
476
+ ) : null,
507
477
  isShowPlaceholder ? /* @__PURE__ */ jsxRuntimeExports.jsx(
508
478
  Typography,
509
479
  {
@@ -531,6 +501,7 @@ const DatePicker = (props) => {
531
501
  weight: ((_b2 = props.font) == null ? void 0 : _b2.weight) ?? (props.isBold ? 500 : 400)
532
502
  },
533
503
  onClick: (e) => {
504
+ if (type === "select") return;
534
505
  e.preventDefault();
535
506
  e.stopPropagation();
536
507
  if ((props == null ? void 0 : props.isDisabled) || (props == null ? void 0 : props.isReadOnly)) return;
@@ -542,7 +513,7 @@ const DatePicker = (props) => {
542
513
  index !== dataDate.sort.length - 1 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { width: "4px", pointerEvents: "none", textAlign: "center" }, children: "." })
543
514
  ] }, date.type);
544
515
  }),
545
- /* @__PURE__ */ jsxRuntimeExports.jsx(
516
+ type !== "manual" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
546
517
  DateInputButton,
547
518
  {
548
519
  genre: props.genre,
@@ -555,6 +526,7 @@ const DatePicker = (props) => {
555
526
  isDisabledRipple: true,
556
527
  icons: [{ name: "Calendar", type: "id" }],
557
528
  isDisabled: (props == null ? void 0 : props.isDisabled) || (props == null ? void 0 : props.isReadOnly),
529
+ tabIndex: 0,
558
530
  onFocus: (e) => {
559
531
  e.preventDefault();
560
532
  e.stopPropagation();
@@ -566,7 +538,35 @@ const DatePicker = (props) => {
566
538
  toggle();
567
539
  }
568
540
  }
569
- )
541
+ ) : null,
542
+ props.isShowClearButton && (isHasValue || isHasInput) && !(props == null ? void 0 : props.isDisabled) && !(props == null ? void 0 : props.isReadOnly) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
543
+ DateInputButtonClear,
544
+ {
545
+ genre: props.genre,
546
+ size: "small",
547
+ isWidthAsHeight: true,
548
+ isFullSize: true,
549
+ isRadius: true,
550
+ isWhileTapEffect: true,
551
+ isOnlyIcon: true,
552
+ isDisabledRipple: true,
553
+ tabIndex: 0,
554
+ icons: [{ name: "Close", type: "id" }],
555
+ isDisabled: (props == null ? void 0 : props.isDisabled) || (props == null ? void 0 : props.isReadOnly),
556
+ onFocus: (e) => {
557
+ e.preventDefault();
558
+ e.stopPropagation();
559
+ setActiveSegment(null);
560
+ },
561
+ onClick: (e) => {
562
+ e.preventDefault();
563
+ e.stopPropagation();
564
+ onChange(null);
565
+ onClearInput();
566
+ setIsError(false);
567
+ }
568
+ }
569
+ ) : null
570
570
  ]
571
571
  }
572
572
  )
@@ -614,7 +614,7 @@ const DatePicker = (props) => {
614
614
  isWidthAsHeight: true,
615
615
  genre: props.genre,
616
616
  size: "small",
617
- onClick: () => !isBlockPrevMonth && onPrevMonth(),
617
+ onClick: () => onPrevMonth(),
618
618
  isDisabledRipple: true,
619
619
  isHidden: isBlockPrevMonth,
620
620
  isDisabled: isBlockPrevMonth
@@ -667,7 +667,7 @@ const DatePicker = (props) => {
667
667
  {
668
668
  type: "button",
669
669
  isWhileTapEffect: true,
670
- onClick: () => !isBlockNextMonth && onNextMonth(),
670
+ onClick: () => onNextMonth(),
671
671
  isWidthAsHeight: true,
672
672
  isRadius: true,
673
673
  icons: [
@@ -770,7 +770,9 @@ const DatePicker = (props) => {
770
770
  ) : null
771
771
  ] });
772
772
  };
773
- function handleDigitKey(key, activeSegment, input, dataDate) {
773
+ const ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
774
+ const SLASH_DATE_REGEX = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
775
+ function getDigitKey(key, activeSegment, input, dataDate) {
774
776
  const digit = key;
775
777
  const seg = activeSegment;
776
778
  const current = input[seg] ?? "";
@@ -827,12 +829,10 @@ function handleDigitKey(key, activeSegment, input, dataDate) {
827
829
  dataDate.default[seg].setValue(nextValue);
828
830
  }
829
831
  }
830
- const ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
831
- const SLASH_DATE_REGEX = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
832
- function parseDateString(value) {
832
+ function getParseDateString(value) {
833
833
  if (ISO_DATE_REGEX.test(value)) {
834
834
  const [year, month, day] = value.split("-").map(Number);
835
- return validateDate(year, month, day);
835
+ return getValidateDate(year, month, day);
836
836
  }
837
837
  const match = SLASH_DATE_REGEX.exec(value);
838
838
  if (match) {
@@ -849,17 +849,50 @@ function parseDateString(value) {
849
849
  month = num1;
850
850
  day = num2;
851
851
  }
852
- return validateDate(year, month, day);
852
+ return getValidateDate(year, month, day);
853
853
  }
854
854
  return null;
855
855
  }
856
- function validateDate(year, month, day) {
856
+ function getValidateDate(year, month, day) {
857
857
  const date = new Date(year, month - 1, day);
858
858
  if (date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day) {
859
859
  return { year, month, day };
860
860
  }
861
861
  return null;
862
862
  }
863
+ function getCountSevens(number) {
864
+ const divisor = 7;
865
+ const count = Math.floor(number / divisor);
866
+ const remainder = number % divisor;
867
+ return remainder > 0 ? count + 1 : count;
868
+ }
869
+ function getNextSegment(currentSegment, mode) {
870
+ const currentIndex = mode.indexOf(currentSegment);
871
+ return currentIndex < mode.length - 1 ? mode[currentIndex + 1] : mode[0];
872
+ }
873
+ function getPrevSegment(currentSegment, mode) {
874
+ const currentIndex = mode.indexOf(currentSegment);
875
+ return currentIndex > 0 ? mode[currentIndex - 1] : mode[mode.length - 1];
876
+ }
877
+ function getValidateInput(input, onSuccess, onFailure, onNan) {
878
+ const dayStr = input.DD;
879
+ const monthStr = input.MM;
880
+ const yearStr = input.YYYY;
881
+ const day = dayStr === "" ? NaN : Number(dayStr);
882
+ const month = monthStr === "" ? NaN : Number(monthStr);
883
+ const year = yearStr === "" ? NaN : Number(yearStr);
884
+ const isHasInput = dayStr !== "" || monthStr !== "" || yearStr !== "";
885
+ if (!Number.isNaN(day) && !Number.isNaN(month) && !Number.isNaN(year)) {
886
+ const m = moment.utc(`${day}.${month}.${year}`, "D.M.YYYY", true).startOf("day");
887
+ if (m.isValid()) {
888
+ onSuccess == null ? void 0 : onSuccess(m.valueOf());
889
+ } else {
890
+ onFailure == null ? void 0 : onFailure();
891
+ }
892
+ } else {
893
+ onNan == null ? void 0 : onNan(isHasInput);
894
+ }
895
+ }
863
896
  var DatePickerVariant = /* @__PURE__ */ ((DatePickerVariant2) => {
864
897
  DatePickerVariant2["DD"] = "DD";
865
898
  DatePickerVariant2["MM"] = "MM";
@@ -870,4 +903,4 @@ export {
870
903
  DatePicker as D,
871
904
  DatePickerVariant as a
872
905
  };
873
- //# sourceMappingURL=component.types-Cc_Ly48_.js.map
906
+ //# sourceMappingURL=component.types-DhrhPsES.js.map