@alfalab/core-components-calendar-range 9.0.14 → 9.1.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.
- package/Component.d.ts +4 -0
- package/Component.js.map +1 -1
- package/components/divider/index.css +8 -8
- package/components/divider/index.module.css.js +1 -1
- package/components/divider/index.module.css.js.map +1 -1
- package/cssm/Component.d.ts +4 -0
- package/cssm/Component.js.map +1 -1
- package/cssm/components/divider/index.module.css +1 -1
- package/cssm/hooks.d.ts +31 -0
- package/cssm/hooks.js +84 -0
- package/cssm/hooks.js.map +1 -1
- package/cssm/views/index.module.css +12 -0
- package/cssm/views/static.d.ts +13 -2
- package/cssm/views/static.js +93 -50
- package/cssm/views/static.js.map +1 -1
- package/esm/Component.d.ts +4 -0
- package/esm/Component.js.map +1 -1
- package/esm/components/divider/index.css +8 -8
- package/esm/components/divider/index.module.css.js +1 -1
- package/esm/components/divider/index.module.css.js.map +1 -1
- package/esm/hooks.d.ts +31 -0
- package/esm/hooks.js +84 -2
- package/esm/hooks.js.map +1 -1
- package/esm/views/index.css +19 -7
- package/esm/views/index.module.css.js +1 -1
- package/esm/views/index.module.css.js.map +1 -1
- package/esm/views/static.d.ts +13 -2
- package/esm/views/static.js +93 -50
- package/esm/views/static.js.map +1 -1
- package/hooks.d.ts +31 -0
- package/hooks.js +84 -0
- package/hooks.js.map +1 -1
- package/modern/Component.d.ts +4 -0
- package/modern/Component.js.map +1 -1
- package/modern/components/divider/index.css +8 -8
- package/modern/components/divider/index.module.css.js +1 -1
- package/modern/components/divider/index.module.css.js.map +1 -1
- package/modern/hooks.d.ts +31 -0
- package/modern/hooks.js +79 -2
- package/modern/hooks.js.map +1 -1
- package/modern/views/index.css +19 -7
- package/modern/views/index.module.css.js +1 -1
- package/modern/views/index.module.css.js.map +1 -1
- package/modern/views/static.d.ts +13 -2
- package/modern/views/static.js +88 -45
- package/modern/views/static.js.map +1 -1
- package/moderncssm/Component.d.ts +4 -0
- package/moderncssm/Component.js.map +1 -1
- package/moderncssm/components/divider/index.module.css +1 -1
- package/moderncssm/hooks.d.ts +31 -0
- package/moderncssm/hooks.js +79 -2
- package/moderncssm/hooks.js.map +1 -1
- package/moderncssm/views/index.module.css +13 -0
- package/moderncssm/views/static.d.ts +13 -2
- package/moderncssm/views/static.js +88 -45
- package/moderncssm/views/static.js.map +1 -1
- package/package.json +2 -1
- package/src/Component.tsx +5 -0
- package/src/components/divider/index.module.css +1 -1
- package/src/hooks.ts +150 -1
- package/src/views/index.module.css +11 -0
- package/src/views/static.tsx +188 -92
- package/views/index.css +19 -7
- package/views/index.module.css.js +1 -1
- package/views/index.module.css.js.map +1 -1
- package/views/static.d.ts +13 -2
- package/views/static.js +90 -47
- package/views/static.js.map +1 -1
package/src/views/static.tsx
CHANGED
|
@@ -1,35 +1,51 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
|
-
import React, { type FC, type MouseEvent, useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import React, { type FC, type MouseEvent, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import cn from 'classnames';
|
|
4
4
|
import { addMonths, endOfMonth, isSameMonth, max, startOfMonth, subMonths } from 'date-fns';
|
|
5
5
|
|
|
6
6
|
import { CalendarDesktop } from '@alfalab/core-components-calendar/desktop';
|
|
7
7
|
import { usePeriodWithReset } from '@alfalab/core-components-calendar/shared';
|
|
8
|
+
import { type CalendarInputProps } from '@alfalab/core-components-calendar-input';
|
|
8
9
|
import {
|
|
9
10
|
formatDate,
|
|
10
11
|
isValidInputValue,
|
|
11
12
|
parseDateString,
|
|
12
13
|
} from '@alfalab/core-components-calendar-input/shared';
|
|
13
|
-
import {
|
|
14
|
-
DateInput,
|
|
15
|
-
type DateInputProps,
|
|
16
|
-
isCompleteDateInput,
|
|
17
|
-
} from '@alfalab/core-components-date-input';
|
|
14
|
+
import { isCompleteDateInput } from '@alfalab/core-components-date-input';
|
|
18
15
|
import { getDataTestId } from '@alfalab/core-components-shared';
|
|
16
|
+
import {
|
|
17
|
+
UniversalDateInput,
|
|
18
|
+
type UniversalDateInputProps,
|
|
19
|
+
} from '@alfalab/core-components-universal-date-input';
|
|
19
20
|
|
|
20
21
|
import { type CalendarRangeProps } from '../Component';
|
|
21
22
|
import { Divider } from '../components/divider';
|
|
22
|
-
import { useSelectionProps, useStaticViewMonthes } from '../hooks';
|
|
23
|
+
import { useSelectionProps, useStaticRangeAutoSwap, useStaticViewMonthes } from '../hooks';
|
|
23
24
|
import { isDayButton } from '../utils';
|
|
24
25
|
|
|
25
26
|
import styles from './index.module.css';
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
type DateInputProps = Omit<CalendarInputProps, 'onCalendarOpen' | 'onCalendarClose' | 'onChange'>;
|
|
29
|
+
|
|
30
|
+
interface CalendarRangeStaticProps
|
|
31
|
+
extends Omit<CalendarRangeProps, 'calendarPosition' | 'inputFromProps' | 'inputToProps'> {
|
|
28
32
|
/**
|
|
29
33
|
* Отображать начальный месяц слева или справа (влияет только на начальный рендер)
|
|
30
34
|
*/
|
|
31
35
|
defaultMonthPosition?: 'left' | 'right';
|
|
32
|
-
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Пропсы для инпута начальной даты диапазона
|
|
39
|
+
*/
|
|
40
|
+
inputFromProps?: DateInputProps;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Пропсы для инпута конечной даты диапазона
|
|
44
|
+
*/
|
|
45
|
+
inputToProps?: DateInputProps;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type CorrectionToggleRef = { handleCorrection: () => void };
|
|
33
49
|
|
|
34
50
|
export const CalendarRangeStatic: FC<CalendarRangeStaticProps> = ({
|
|
35
51
|
className,
|
|
@@ -42,7 +58,6 @@ export const CalendarRangeStatic: FC<CalendarRangeStaticProps> = ({
|
|
|
42
58
|
onDateFromChange = () => null,
|
|
43
59
|
onDateToChange = () => null,
|
|
44
60
|
onChange = () => null,
|
|
45
|
-
onError,
|
|
46
61
|
inputFromProps = {},
|
|
47
62
|
inputToProps = {},
|
|
48
63
|
offDays,
|
|
@@ -50,10 +65,33 @@ export const CalendarRangeStatic: FC<CalendarRangeStaticProps> = ({
|
|
|
50
65
|
returnInvalidDates = false,
|
|
51
66
|
dataTestId,
|
|
52
67
|
calendarContainerClassName,
|
|
68
|
+
autoSwap = false,
|
|
69
|
+
onError,
|
|
53
70
|
}) => {
|
|
54
71
|
const [inputFromValue, setInputFromValue] = useState<string>(valueFrom);
|
|
55
72
|
const [inputToValue, setInputToValue] = useState<string>(valueTo);
|
|
56
73
|
|
|
74
|
+
const [inputFromError, setInputFromError] = useState(false);
|
|
75
|
+
const [inputToError, setInputToError] = useState(false);
|
|
76
|
+
|
|
77
|
+
const toggleCorrectionFromRef = useRef<CorrectionToggleRef>(null);
|
|
78
|
+
const toggleCorrectionToRef = useRef<CorrectionToggleRef>(null);
|
|
79
|
+
|
|
80
|
+
const inputToRef = useRef<HTMLInputElement>(null);
|
|
81
|
+
const inputFromRef = useRef<HTMLInputElement>(null);
|
|
82
|
+
|
|
83
|
+
const { swapDates, isInternalUpdate } = useStaticRangeAutoSwap({
|
|
84
|
+
autoSwap,
|
|
85
|
+
setInputFromValue,
|
|
86
|
+
setInputToValue,
|
|
87
|
+
toggleCorrectionFromRef,
|
|
88
|
+
toggleCorrectionToRef,
|
|
89
|
+
inputFromRef,
|
|
90
|
+
inputToRef,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const [rangeValidationError, setRangeValidationError] = useState(false);
|
|
94
|
+
|
|
57
95
|
let dateFrom = isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
58
96
|
? parseDateString(inputFromValue).getTime()
|
|
59
97
|
: null;
|
|
@@ -66,11 +104,6 @@ export const CalendarRangeStatic: FC<CalendarRangeStaticProps> = ({
|
|
|
66
104
|
dateFrom = null;
|
|
67
105
|
}
|
|
68
106
|
|
|
69
|
-
const bothInvalid =
|
|
70
|
-
isCompleteDateInput(inputFromValue) &&
|
|
71
|
-
isCompleteDateInput(inputToValue) &&
|
|
72
|
-
parseDateString(inputFromValue).getTime() > parseDateString(inputToValue).getTime();
|
|
73
|
-
|
|
74
107
|
const [highlightedDate, setHighlightedDate] = useState<number | undefined>(undefined);
|
|
75
108
|
|
|
76
109
|
const period = usePeriodWithReset({
|
|
@@ -78,26 +111,6 @@ export const CalendarRangeStatic: FC<CalendarRangeStaticProps> = ({
|
|
|
78
111
|
initialSelectedTo: dateTo ? parseDateString(inputToValue).getTime() : undefined,
|
|
79
112
|
});
|
|
80
113
|
|
|
81
|
-
const validateInputFromValue = useCallback(
|
|
82
|
-
(value: string) => isValidInputValue(value, minDate, dateFrom || maxDate, offDays),
|
|
83
|
-
[dateFrom, maxDate, minDate, offDays],
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
const validateInputToValue = useCallback(
|
|
87
|
-
(value: string) => isValidInputValue(value, dateFrom || minDate, maxDate, offDays),
|
|
88
|
-
|
|
89
|
-
[dateFrom, minDate, maxDate, offDays],
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const [inputFromInvalid, setInputFromInvalid] = useState<boolean>(
|
|
93
|
-
isCompleteDateInput(inputFromValue) && dateFrom === null,
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const [inputToInvalid, setInputToInvalid] = useState<boolean>(
|
|
97
|
-
isCompleteDateInput(inputToValue) && dateTo === null,
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
const hasValidateError = bothInvalid || inputFromInvalid || inputToInvalid;
|
|
101
114
|
const {
|
|
102
115
|
calendarProps: calendarFromProps,
|
|
103
116
|
onInputChange: onInputChangeFrom,
|
|
@@ -118,22 +131,48 @@ export const CalendarRangeStatic: FC<CalendarRangeStaticProps> = ({
|
|
|
118
131
|
},
|
|
119
132
|
);
|
|
120
133
|
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
134
|
+
const handleInputFromChange: Required<UniversalDateInputProps>['onInputChange'] = (
|
|
135
|
+
event,
|
|
136
|
+
payload,
|
|
137
|
+
) => {
|
|
138
|
+
const newValue = payload.value;
|
|
139
|
+
|
|
140
|
+
setInputFromValue(newValue);
|
|
124
141
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
142
|
+
if (isValidInputValue(newValue, minDate, maxDate, offDays)) {
|
|
143
|
+
swapDates(newValue, inputFromValue, inputToValue);
|
|
144
|
+
}
|
|
128
145
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
onInputChangeFrom
|
|
146
|
+
const payloadWithDate = { date: parseDateString(payload.value), value: payload.value };
|
|
147
|
+
|
|
148
|
+
if (onInputChangeFrom) {
|
|
149
|
+
onInputChangeFrom(
|
|
150
|
+
event === null ? ({} as React.ChangeEvent<HTMLInputElement>) : event,
|
|
151
|
+
payloadWithDate,
|
|
152
|
+
);
|
|
153
|
+
}
|
|
132
154
|
};
|
|
133
155
|
|
|
134
|
-
const handleInputToChange: Required<
|
|
135
|
-
|
|
136
|
-
|
|
156
|
+
const handleInputToChange: Required<UniversalDateInputProps>['onInputChange'] = (
|
|
157
|
+
event,
|
|
158
|
+
payload,
|
|
159
|
+
) => {
|
|
160
|
+
const newValue = payload.value;
|
|
161
|
+
|
|
162
|
+
setInputToValue(newValue);
|
|
163
|
+
|
|
164
|
+
if (isValidInputValue(newValue, minDate, maxDate, offDays)) {
|
|
165
|
+
swapDates(newValue, inputFromValue, inputToValue);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const payloadWithDate = { date: parseDateString(payload.value), value: payload.value };
|
|
169
|
+
|
|
170
|
+
if (onInputChangeTo) {
|
|
171
|
+
onInputChangeTo(
|
|
172
|
+
event === null ? ({} as React.ChangeEvent<HTMLInputElement>) : event,
|
|
173
|
+
payloadWithDate,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
137
176
|
};
|
|
138
177
|
|
|
139
178
|
const handleMouseOver = useCallback((event: MouseEvent<HTMLDivElement>) => {
|
|
@@ -180,22 +219,24 @@ export const CalendarRangeStatic: FC<CalendarRangeStaticProps> = ({
|
|
|
180
219
|
}, [valueTo]);
|
|
181
220
|
|
|
182
221
|
useEffect(() => {
|
|
183
|
-
if (!inputFromValue || isCompleteDateInput(inputFromValue)) {
|
|
184
|
-
handleValidInputFrom();
|
|
185
|
-
}
|
|
186
|
-
|
|
187
222
|
period.setStart(dateFrom || undefined);
|
|
188
223
|
if (dateTo) {
|
|
189
224
|
period.setEnd(dateTo);
|
|
190
225
|
}
|
|
191
226
|
|
|
227
|
+
if (isInternalUpdate.current) {
|
|
228
|
+
isInternalUpdate.current = false;
|
|
229
|
+
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
192
233
|
if (inputFromValue !== valueFrom) {
|
|
193
|
-
onDateFromChange({
|
|
234
|
+
onDateFromChange?.({
|
|
194
235
|
value: inputFromValue,
|
|
195
236
|
date: dateFrom,
|
|
196
237
|
});
|
|
197
238
|
|
|
198
|
-
onChange({
|
|
239
|
+
onChange?.({
|
|
199
240
|
valueFrom: inputFromValue,
|
|
200
241
|
valueTo: inputToValue,
|
|
201
242
|
dateFrom,
|
|
@@ -206,15 +247,17 @@ export const CalendarRangeStatic: FC<CalendarRangeStaticProps> = ({
|
|
|
206
247
|
}, [inputFromValue]);
|
|
207
248
|
|
|
208
249
|
useEffect(() => {
|
|
209
|
-
if (!inputToValue || isCompleteDateInput(inputToValue)) {
|
|
210
|
-
handleValidInputTo();
|
|
211
|
-
}
|
|
212
|
-
|
|
213
250
|
period.setEnd(dateTo || undefined);
|
|
214
251
|
if (dateFrom) {
|
|
215
252
|
period.setStart(dateFrom);
|
|
216
253
|
}
|
|
217
254
|
|
|
255
|
+
if (isInternalUpdate.current) {
|
|
256
|
+
isInternalUpdate.current = false;
|
|
257
|
+
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
218
261
|
if (inputToValue !== valueTo) {
|
|
219
262
|
// eslint-disable-next-line no-nested-ternary
|
|
220
263
|
const inputDateTo = returnInvalidDates
|
|
@@ -223,12 +266,12 @@ export const CalendarRangeStatic: FC<CalendarRangeStaticProps> = ({
|
|
|
223
266
|
: null
|
|
224
267
|
: dateTo;
|
|
225
268
|
|
|
226
|
-
onDateToChange({
|
|
269
|
+
onDateToChange?.({
|
|
227
270
|
value: inputToValue,
|
|
228
271
|
date: inputDateTo,
|
|
229
272
|
});
|
|
230
273
|
|
|
231
|
-
onChange({
|
|
274
|
+
onChange?.({
|
|
232
275
|
valueFrom: inputFromValue,
|
|
233
276
|
valueTo: inputToValue,
|
|
234
277
|
dateFrom,
|
|
@@ -238,12 +281,53 @@ export const CalendarRangeStatic: FC<CalendarRangeStaticProps> = ({
|
|
|
238
281
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
239
282
|
}, [inputToValue]);
|
|
240
283
|
|
|
284
|
+
useEffect(() => {
|
|
285
|
+
const isInputFromValueComplete = isCompleteDateInput(inputFromValue);
|
|
286
|
+
const isInputToValueComplete = isCompleteDateInput(inputToValue);
|
|
287
|
+
|
|
288
|
+
let individualInputFromError = false;
|
|
289
|
+
let individualInputToError = false;
|
|
290
|
+
|
|
291
|
+
if (isInputFromValueComplete) {
|
|
292
|
+
individualInputFromError = !isValidInputValue(
|
|
293
|
+
inputFromValue,
|
|
294
|
+
minDate,
|
|
295
|
+
maxDate,
|
|
296
|
+
offDays,
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (isInputToValueComplete) {
|
|
301
|
+
individualInputToError = !isValidInputValue(inputToValue, minDate, maxDate, offDays);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
let isRangeError = false;
|
|
305
|
+
|
|
306
|
+
const isValidInputFromValueStandalone =
|
|
307
|
+
isInputFromValueComplete && individualInputFromError === false;
|
|
308
|
+
const isValidInputToValueStandalone =
|
|
309
|
+
isInputToValueComplete && individualInputToError === false;
|
|
310
|
+
|
|
311
|
+
if (isValidInputFromValueStandalone && isValidInputToValueStandalone) {
|
|
312
|
+
const parsedDateFrom = parseDateString(inputFromValue).getTime();
|
|
313
|
+
const parsedDateTo = parseDateString(inputToValue).getTime();
|
|
314
|
+
|
|
315
|
+
if (parsedDateFrom > parsedDateTo) {
|
|
316
|
+
isRangeError = true;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
setInputFromError(individualInputFromError || isRangeError);
|
|
321
|
+
setInputToError(individualInputToError || isRangeError);
|
|
322
|
+
|
|
323
|
+
setRangeValidationError(isRangeError);
|
|
324
|
+
}, [inputFromValue, inputToValue, minDate, maxDate, offDays]);
|
|
325
|
+
|
|
241
326
|
useEffect(() => {
|
|
242
327
|
if (onError) {
|
|
243
|
-
onError(
|
|
328
|
+
onError(rangeValidationError);
|
|
244
329
|
}
|
|
245
|
-
|
|
246
|
-
}, [hasValidateError]);
|
|
330
|
+
}, [onError, rangeValidationError]);
|
|
247
331
|
|
|
248
332
|
const rangeProps = useSelectionProps(period.selectedFrom, period.selectedTo, highlightedDate);
|
|
249
333
|
|
|
@@ -260,22 +344,54 @@ export const CalendarRangeStatic: FC<CalendarRangeStaticProps> = ({
|
|
|
260
344
|
onMouseOver={handleMouseOver}
|
|
261
345
|
data-test-id={dataTestId}
|
|
262
346
|
>
|
|
263
|
-
<div>
|
|
264
|
-
<
|
|
347
|
+
<div className={cn(styles.inputsContainer)}>
|
|
348
|
+
<UniversalDateInput
|
|
265
349
|
{...dateInputFromProps}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
: dateInputFromProps.mobileMode
|
|
270
|
-
}
|
|
350
|
+
Calendar={undefined}
|
|
351
|
+
view='date'
|
|
352
|
+
picker={false}
|
|
271
353
|
value={inputFromValue}
|
|
272
|
-
|
|
354
|
+
onInputChange={handleInputFromChange}
|
|
273
355
|
onClear={handleClearFrom}
|
|
274
|
-
|
|
275
|
-
error={
|
|
356
|
+
correctionRef={toggleCorrectionFromRef}
|
|
357
|
+
error={inputFromError ? 'Укажите корректную дату' : dateInputFromProps.error}
|
|
276
358
|
clear={true}
|
|
277
359
|
block={true}
|
|
360
|
+
minDate={minDate}
|
|
361
|
+
autoCorrection={false}
|
|
362
|
+
maxDate={
|
|
363
|
+
minMaxInSameMonth
|
|
364
|
+
? maxDate
|
|
365
|
+
: maxDate && max([maxDate, endOfMonth(subMonths(maxDate, 1))]).getTime()
|
|
366
|
+
}
|
|
367
|
+
ref={inputFromRef}
|
|
278
368
|
/>
|
|
369
|
+
|
|
370
|
+
<Divider inputFromProps={inputFromProps} inputToProps={inputToProps} />
|
|
371
|
+
|
|
372
|
+
<UniversalDateInput
|
|
373
|
+
{...dateInputToProps}
|
|
374
|
+
Calendar={undefined}
|
|
375
|
+
view='date'
|
|
376
|
+
picker={false}
|
|
377
|
+
value={inputToValue}
|
|
378
|
+
onInputChange={handleInputToChange}
|
|
379
|
+
onClear={handleClearTo}
|
|
380
|
+
error={inputToError ? 'Укажите корректную дату' : dateInputToProps.error}
|
|
381
|
+
correctionRef={toggleCorrectionToRef}
|
|
382
|
+
clear={true}
|
|
383
|
+
block={true}
|
|
384
|
+
autoCorrection={false}
|
|
385
|
+
minDate={
|
|
386
|
+
minMaxInSameMonth
|
|
387
|
+
? minDate
|
|
388
|
+
: minDate && startOfMonth(addMonths(minDate, 1)).getTime()
|
|
389
|
+
}
|
|
390
|
+
maxDate={maxDate}
|
|
391
|
+
ref={inputToRef}
|
|
392
|
+
/>
|
|
393
|
+
</div>
|
|
394
|
+
<div className={cn(styles.calendarContainers)}>
|
|
279
395
|
<div
|
|
280
396
|
className={cn(styles.calendarContainer, calendarContainerClassName)}
|
|
281
397
|
data-test-id={getDataTestId(dataTestId, 'container-from')}
|
|
@@ -299,26 +415,6 @@ export const CalendarRangeStatic: FC<CalendarRangeStaticProps> = ({
|
|
|
299
415
|
{...rangeProps}
|
|
300
416
|
/>
|
|
301
417
|
</div>
|
|
302
|
-
</div>
|
|
303
|
-
|
|
304
|
-
<Divider inputFromProps={inputFromProps} inputToProps={inputToProps} />
|
|
305
|
-
|
|
306
|
-
<div>
|
|
307
|
-
<DateInput
|
|
308
|
-
{...dateInputToProps}
|
|
309
|
-
mobileMode={
|
|
310
|
-
dateInputToProps.mobileMode === 'popover'
|
|
311
|
-
? 'input'
|
|
312
|
-
: dateInputToProps.mobileMode
|
|
313
|
-
}
|
|
314
|
-
value={inputToValue}
|
|
315
|
-
onChange={handleInputToChange}
|
|
316
|
-
onClear={handleClearTo}
|
|
317
|
-
onBlur={handleValidInputTo}
|
|
318
|
-
error={bothInvalid || inputToInvalid || dateInputToProps.error}
|
|
319
|
-
clear={true}
|
|
320
|
-
block={true}
|
|
321
|
-
/>
|
|
322
418
|
<div data-test-id={getDataTestId(dataTestId, 'container-to')}>
|
|
323
419
|
<CalendarToComponent
|
|
324
420
|
{...calendarToProps}
|
package/views/index.css
CHANGED
|
@@ -1,32 +1,44 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--gap-s: 12px;
|
|
3
3
|
--gap-m: 16px;
|
|
4
|
+
--gap-2xl: 32px;
|
|
4
5
|
--gap-0: 0px;
|
|
5
6
|
--gap-12: var(--gap-s);
|
|
6
7
|
--gap-16: var(--gap-m);
|
|
8
|
+
--gap-32: var(--gap-2xl);
|
|
7
9
|
}
|
|
8
10
|
:root {
|
|
9
11
|
--calendar-inner-width: 280px;
|
|
10
12
|
}
|
|
11
|
-
.calendar-
|
|
13
|
+
.calendar-range__component_q8vzh {
|
|
12
14
|
display: flex;
|
|
13
15
|
}
|
|
14
|
-
.calendar-
|
|
16
|
+
.calendar-range__component_q8vzh button[aria-selected='true'] {
|
|
15
17
|
cursor: pointer;
|
|
16
18
|
}
|
|
17
|
-
.calendar-
|
|
19
|
+
.calendar-range__component_q8vzh *[class*='errorIcon_'] {
|
|
18
20
|
display: none;
|
|
19
21
|
}
|
|
20
|
-
.calendar-
|
|
22
|
+
.calendar-range__component_q8vzh *[class*='calendarIcon_'] {
|
|
21
23
|
margin-right: var(--gap-0);
|
|
22
24
|
}
|
|
23
|
-
.calendar-
|
|
25
|
+
.calendar-range__static_q8vzh {
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
}
|
|
28
|
+
.calendar-range__static_q8vzh .calendar-range__calendar_q8vzh {
|
|
24
29
|
width: var(--calendar-inner-width);
|
|
25
30
|
}
|
|
26
|
-
.calendar-
|
|
31
|
+
.calendar-range__static_q8vzh .calendar-range__calendar_q8vzh > div:first-child {
|
|
27
32
|
padding: var(--gap-16) var(--gap-0) var(--gap-12);
|
|
28
33
|
}
|
|
29
|
-
.calendar-
|
|
34
|
+
.calendar-range__inputsContainer_q8vzh {
|
|
35
|
+
display: flex;
|
|
36
|
+
}
|
|
37
|
+
.calendar-range__calendarContainers_q8vzh {
|
|
38
|
+
display: flex;
|
|
39
|
+
gap: var(--gap-32);
|
|
40
|
+
}
|
|
41
|
+
.calendar-range__calendarContainer_q8vzh {
|
|
30
42
|
width: var(--calendar-inner-width);
|
|
31
43
|
display: flex;
|
|
32
44
|
justify-content: center;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require('./index.css');
|
|
4
4
|
|
|
5
|
-
var styles = {"component":"calendar-
|
|
5
|
+
var styles = {"component":"calendar-range__component_q8vzh","static":"calendar-range__static_q8vzh","calendar":"calendar-range__calendar_q8vzh","inputsContainer":"calendar-range__inputsContainer_q8vzh","calendarContainers":"calendar-range__calendarContainers_q8vzh","calendarContainer":"calendar-range__calendarContainer_q8vzh"};
|
|
6
6
|
|
|
7
7
|
module.exports = styles;
|
|
8
8
|
//# sourceMappingURL=index.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.css.js","sources":["../src/views/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n@import '../../../calendar/src/vars.css';\n\n.component {\n display: flex;\n\n & button[aria-selected='true'] {\n cursor: pointer;\n }\n\n & *[class*='errorIcon_'] {\n display: none;\n }\n\n & *[class*='calendarIcon_'] {\n margin-right: var(--gap-0);\n }\n}\n\n.static {\n & .calendar {\n width: var(--calendar-inner-width);\n\n & > div:first-child {\n padding: var(--gap-16) var(--gap-0) var(--gap-12);\n }\n }\n}\n\n.calendarContainer {\n width: var(--calendar-inner-width);\n display: flex;\n justify-content: center;\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,WAAW,CAAC,iCAAiC,CAAC,QAAQ,CAAC,8BAA8B,CAAC,UAAU,CAAC,gCAAgC,CAAC,mBAAmB,CAAC,yCAAyC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":["../src/views/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n@import '../../../calendar/src/vars.css';\n\n.component {\n display: flex;\n\n & button[aria-selected='true'] {\n cursor: pointer;\n }\n\n & *[class*='errorIcon_'] {\n display: none;\n }\n\n & *[class*='calendarIcon_'] {\n margin-right: var(--gap-0);\n }\n}\n\n.static {\n flex-direction: column;\n\n & .calendar {\n width: var(--calendar-inner-width);\n\n & > div:first-child {\n padding: var(--gap-16) var(--gap-0) var(--gap-12);\n }\n }\n}\n\n.inputsContainer {\n display: flex;\n}\n\n.calendarContainers {\n display: flex;\n gap: var(--gap-32);\n}\n\n.calendarContainer {\n width: var(--calendar-inner-width);\n display: flex;\n justify-content: center;\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,WAAW,CAAC,iCAAiC,CAAC,QAAQ,CAAC,8BAA8B,CAAC,UAAU,CAAC,gCAAgC,CAAC,iBAAiB,CAAC,uCAAuC,CAAC,oBAAoB,CAAC,0CAA0C,CAAC,mBAAmB,CAAC,yCAAyC,CAAC;;;;"}
|
package/views/static.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { type FC } from 'react';
|
|
2
|
+
import { type CalendarInputProps } from '@alfalab/core-components-calendar-input';
|
|
2
3
|
import { type CalendarRangeProps } from '../Component';
|
|
3
|
-
|
|
4
|
+
type DateInputProps = Omit<CalendarInputProps, 'onCalendarOpen' | 'onCalendarClose' | 'onChange'>;
|
|
5
|
+
interface CalendarRangeStaticProps extends Omit<CalendarRangeProps, 'calendarPosition' | 'inputFromProps' | 'inputToProps'> {
|
|
4
6
|
/**
|
|
5
7
|
* Отображать начальный месяц слева или справа (влияет только на начальный рендер)
|
|
6
8
|
*/
|
|
7
9
|
defaultMonthPosition?: 'left' | 'right';
|
|
8
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Пропсы для инпута начальной даты диапазона
|
|
12
|
+
*/
|
|
13
|
+
inputFromProps?: DateInputProps;
|
|
14
|
+
/**
|
|
15
|
+
* Пропсы для инпута конечной даты диапазона
|
|
16
|
+
*/
|
|
17
|
+
inputToProps?: DateInputProps;
|
|
18
|
+
}
|
|
9
19
|
export declare const CalendarRangeStatic: FC<CalendarRangeStaticProps>;
|
|
20
|
+
export {};
|