@via-profit/ui-kit 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -99,20 +99,38 @@ const computeView = (inputParams) => {
99
99
  const computeCalendarDate = (params) => {
100
100
  const { inputValue, defaultValue } = params;
101
101
  const today = new Date();
102
- if (inputValue) {
103
- if (isRangeValue(inputValue) && inputValue[1]) {
104
- return inputValue[1];
102
+ // Проверяем inputValue
103
+ if (inputValue !== null && inputValue !== undefined) {
104
+ if (Array.isArray(inputValue) && inputValue.length > 0) {
105
+ // Для range режима - берем первый элемент, если он есть
106
+ if (inputValue[0] instanceof Date) {
107
+ return inputValue[0];
108
+ }
109
+ // Если первый элемент null, пробуем второй
110
+ if (inputValue[1] instanceof Date) {
111
+ return inputValue[1];
112
+ }
105
113
  }
106
- if (isRangeValue(inputValue) && inputValue[0]) {
107
- return inputValue[0];
114
+ else if (inputValue instanceof Date) {
115
+ // Для non-range режима
116
+ return inputValue;
108
117
  }
109
118
  }
110
- if (isRangeValue(defaultValue) && defaultValue && defaultValue[1]) {
111
- return defaultValue[1];
112
- }
113
- if (isRangeValue(defaultValue) && defaultValue && defaultValue[0]) {
114
- return defaultValue[0];
119
+ // Проверяем defaultValue
120
+ if (defaultValue !== null && defaultValue !== undefined) {
121
+ if (Array.isArray(defaultValue) && defaultValue.length > 0) {
122
+ if (defaultValue[0] instanceof Date) {
123
+ return defaultValue[0];
124
+ }
125
+ if (defaultValue[1] instanceof Date) {
126
+ return defaultValue[1];
127
+ }
128
+ }
129
+ else if (defaultValue instanceof Date) {
130
+ return defaultValue;
131
+ }
115
132
  }
133
+ // Возвращаем сегодняшнюю дату, если ничего не подошло
116
134
  return today;
117
135
  };
118
136
  const CalendarComponent = react_1.default.forwardRef((props, ref) => {
@@ -252,11 +270,13 @@ const CalendarComponent = react_1.default.forwardRef((props, ref) => {
252
270
  if (JSON.stringify(inputValue) !== JSON.stringify(inputValueRef.current)) {
253
271
  inputValueRef.current = inputValue;
254
272
  setValue(inputValue);
255
- if (isRangeValue(inputValue) && inputValue && inputValue[0] instanceof Date) {
256
- setCalendarDate(inputValue[0]);
257
- }
258
- else {
259
- setCalendarDate(inputValue);
273
+ if (inputValue !== null && inputValue !== undefined) {
274
+ if (Array.isArray(inputValue) && inputValue[0] instanceof Date) {
275
+ setCalendarDate(inputValue[0]);
276
+ }
277
+ else if (inputValue instanceof Date) {
278
+ setCalendarDate(inputValue);
279
+ }
260
280
  }
261
281
  }
262
282
  }, [inputValue]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@via-profit/ui-kit",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "UI Kit",
5
5
  "repository": {
6
6
  "type": "git",