@dreamcommerce/aurora 3.1.52-1 → 3.1.52
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/build/cjs/packages/aurora/src/components/calendar/styled_day_picker/styled_day_picker.js +1 -1
- package/build/cjs/packages/aurora/src/components/color_picker/components/pure_color_picker.js +1 -0
- package/build/cjs/packages/aurora/src/components/color_picker/components/pure_color_picker.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/controls/values_syncer_control/values_syncer_control.js +3 -5
- package/build/cjs/packages/aurora/src/components/controls/values_syncer_control/values_syncer_control.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/date_and_time_picker/date_time_picker.js +27 -16
- package/build/cjs/packages/aurora/src/components/date_and_time_picker/date_time_picker.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/date_picker/components/date_picker_input.js +11 -43
- package/build/cjs/packages/aurora/src/components/date_picker/components/date_picker_input.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/date_picker/date_picker.js +13 -83
- package/build/cjs/packages/aurora/src/components/date_picker/date_picker.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/date_picker/date_picker_utils.js +4 -203
- package/build/cjs/packages/aurora/src/components/date_picker/date_picker_utils.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/time_picker/components/time_picker_input.js +10 -30
- package/build/cjs/packages/aurora/src/components/time_picker/components/time_picker_input.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/time_picker/time_picker.js +50 -85
- package/build/cjs/packages/aurora/src/components/time_picker/time_picker.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/time_picker/time_picker_utils.js +1 -62
- package/build/cjs/packages/aurora/src/components/time_picker/time_picker_utils.js.map +1 -1
- package/build/cjs/packages/aurora/src/index.js +0 -2
- package/build/cjs/packages/aurora/src/index.js.map +1 -1
- package/build/cjs/packages/aurora/src/translations/en.json.js +1 -4
- package/build/cjs/packages/aurora/src/translations/en.json.js.map +1 -1
- package/build/cjs/packages/aurora/src/translations/pl.json.js +1 -4
- package/build/cjs/packages/aurora/src/translations/pl.json.js.map +1 -1
- package/build/esm/packages/aurora/src/components/calendar/styled_day_picker/styled_day_picker.js +1 -1
- package/build/esm/packages/aurora/src/components/color_picker/components/pure_color_picker.js +1 -0
- package/build/esm/packages/aurora/src/components/color_picker/components/pure_color_picker.js.map +1 -1
- package/build/esm/packages/aurora/src/components/controls/values_syncer_control/values_syncer_control.js +3 -5
- package/build/esm/packages/aurora/src/components/controls/values_syncer_control/values_syncer_control.js.map +1 -1
- package/build/esm/packages/aurora/src/components/date_and_time_picker/date_time_picker.js +27 -16
- package/build/esm/packages/aurora/src/components/date_and_time_picker/date_time_picker.js.map +1 -1
- package/build/esm/packages/aurora/src/components/date_picker/components/date_picker_input.d.ts +1 -4
- package/build/esm/packages/aurora/src/components/date_picker/components/date_picker_input.js +11 -43
- package/build/esm/packages/aurora/src/components/date_picker/components/date_picker_input.js.map +1 -1
- package/build/esm/packages/aurora/src/components/date_picker/date_picker.d.ts +1 -1
- package/build/esm/packages/aurora/src/components/date_picker/date_picker.js +14 -84
- package/build/esm/packages/aurora/src/components/date_picker/date_picker.js.map +1 -1
- package/build/esm/packages/aurora/src/components/date_picker/date_picker_types.d.ts +1 -1
- package/build/esm/packages/aurora/src/components/date_picker/date_picker_utils.d.ts +1 -18
- package/build/esm/packages/aurora/src/components/date_picker/date_picker_utils.js +4 -203
- package/build/esm/packages/aurora/src/components/date_picker/date_picker_utils.js.map +1 -1
- package/build/esm/packages/aurora/src/components/time_picker/components/time_picker_input.d.ts +1 -2
- package/build/esm/packages/aurora/src/components/time_picker/components/time_picker_input.js +10 -30
- package/build/esm/packages/aurora/src/components/time_picker/components/time_picker_input.js.map +1 -1
- package/build/esm/packages/aurora/src/components/time_picker/time_picker.js +52 -87
- package/build/esm/packages/aurora/src/components/time_picker/time_picker.js.map +1 -1
- package/build/esm/packages/aurora/src/components/time_picker/time_picker_utils.d.ts +0 -11
- package/build/esm/packages/aurora/src/components/time_picker/time_picker_utils.js +1 -62
- package/build/esm/packages/aurora/src/components/time_picker/time_picker_utils.js.map +1 -1
- package/build/esm/packages/aurora/src/index.d.ts +0 -2
- package/build/esm/packages/aurora/src/index.js +0 -1
- package/build/esm/packages/aurora/src/index.js.map +1 -1
- package/build/esm/packages/aurora/src/translations/en.json +1 -4
- package/build/esm/packages/aurora/src/translations/en.json.js +1 -4
- package/build/esm/packages/aurora/src/translations/en.json.js.map +1 -1
- package/build/esm/packages/aurora/src/translations/pl.json +1 -4
- package/build/esm/packages/aurora/src/translations/pl.json.js +1 -4
- package/build/esm/packages/aurora/src/translations/pl.json.js.map +1 -1
- package/package.json +1 -1
- package/build/cjs/packages/aurora/src/components/input_mask/hooks/hooks.js +0 -196
- package/build/cjs/packages/aurora/src/components/input_mask/hooks/hooks.js.map +0 -1
- package/build/cjs/packages/aurora/src/components/input_mask/input-mask-constants.js +0 -14
- package/build/cjs/packages/aurora/src/components/input_mask/input-mask-constants.js.map +0 -1
- package/build/cjs/packages/aurora/src/components/input_mask/input_mask.js +0 -360
- package/build/cjs/packages/aurora/src/components/input_mask/input_mask.js.map +0 -1
- package/build/cjs/packages/aurora/src/components/input_mask/utils/defer.js +0 -16
- package/build/cjs/packages/aurora/src/components/input_mask/utils/defer.js.map +0 -1
- package/build/cjs/packages/aurora/src/components/input_mask/utils/helpers.js +0 -50
- package/build/cjs/packages/aurora/src/components/input_mask/utils/helpers.js.map +0 -1
- package/build/cjs/packages/aurora/src/components/input_mask/utils/input.js +0 -33
- package/build/cjs/packages/aurora/src/components/input_mask/utils/input.js.map +0 -1
- package/build/cjs/packages/aurora/src/components/input_mask/utils/mask.js +0 -371
- package/build/cjs/packages/aurora/src/components/input_mask/utils/mask.js.map +0 -1
- package/build/cjs/packages/aurora/src/components/input_mask/utils/parse-mask.js +0 -94
- package/build/cjs/packages/aurora/src/components/input_mask/utils/parse-mask.js.map +0 -1
- package/build/cjs/packages/aurora/src/components/input_mask/utils/validate-props.js +0 -37
- package/build/cjs/packages/aurora/src/components/input_mask/utils/validate-props.js.map +0 -1
- package/build/esm/packages/aurora/src/components/input_mask/hooks/hooks.d.ts +0 -10
- package/build/esm/packages/aurora/src/components/input_mask/hooks/hooks.js +0 -190
- package/build/esm/packages/aurora/src/components/input_mask/hooks/hooks.js.map +0 -1
- package/build/esm/packages/aurora/src/components/input_mask/input-mask-constants.d.ts +0 -6
- package/build/esm/packages/aurora/src/components/input_mask/input-mask-constants.js +0 -9
- package/build/esm/packages/aurora/src/components/input_mask/input-mask-constants.js.map +0 -1
- package/build/esm/packages/aurora/src/components/input_mask/input_mask.d.ts +0 -4
- package/build/esm/packages/aurora/src/components/input_mask/input_mask.js +0 -352
- package/build/esm/packages/aurora/src/components/input_mask/input_mask.js.map +0 -1
- package/build/esm/packages/aurora/src/components/input_mask/input_mask_types.d.ts +0 -39
- package/build/esm/packages/aurora/src/components/input_mask/input_mask_types.js +0 -2
- package/build/esm/packages/aurora/src/components/input_mask/input_mask_types.js.map +0 -1
- package/build/esm/packages/aurora/src/components/input_mask/utils/defer.d.ts +0 -2
- package/build/esm/packages/aurora/src/components/input_mask/utils/defer.js +0 -11
- package/build/esm/packages/aurora/src/components/input_mask/utils/defer.js.map +0 -1
- package/build/esm/packages/aurora/src/components/input_mask/utils/helpers.d.ts +0 -7
- package/build/esm/packages/aurora/src/components/input_mask/utils/helpers.js +0 -40
- package/build/esm/packages/aurora/src/components/input_mask/utils/helpers.js.map +0 -1
- package/build/esm/packages/aurora/src/components/input_mask/utils/input.d.ts +0 -9
- package/build/esm/packages/aurora/src/components/input_mask/utils/input.js +0 -29
- package/build/esm/packages/aurora/src/components/input_mask/utils/input.js.map +0 -1
- package/build/esm/packages/aurora/src/components/input_mask/utils/mask.d.ts +0 -63
- package/build/esm/packages/aurora/src/components/input_mask/utils/mask.js +0 -367
- package/build/esm/packages/aurora/src/components/input_mask/utils/mask.js.map +0 -1
- package/build/esm/packages/aurora/src/components/input_mask/utils/parse-mask.d.ts +0 -7
- package/build/esm/packages/aurora/src/components/input_mask/utils/parse-mask.js +0 -90
- package/build/esm/packages/aurora/src/components/input_mask/utils/parse-mask.js.map +0 -1
- package/build/esm/packages/aurora/src/components/input_mask/utils/validate-props.d.ts +0 -4
- package/build/esm/packages/aurora/src/components/input_mask/utils/validate-props.js +0 -31
- package/build/esm/packages/aurora/src/components/input_mask/utils/validate-props.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React__default, { useState, useMemo } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ErrorList } from '../error_list/error_list.js';
|
|
2
|
+
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2 } from '../../../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
3
|
+
import { cn } from '../../utilities/cn.js';
|
|
5
4
|
import { Popover } from '../popover/popover.js';
|
|
6
|
-
import {
|
|
5
|
+
import { PopoverTrigger } from '../popover/components/popover_trigger.js';
|
|
7
6
|
import { DatePickerInput } from './components/date_picker_input.js';
|
|
8
7
|
import { DatePickerContent } from './components/date_picker_content.js';
|
|
8
|
+
import { DatePickerUtils } from './date_picker_utils.js';
|
|
9
9
|
|
|
10
|
-
var _excluded = ["id", "mode", "placeholder", "disabled", "errors", "value", "onChange", "disabledDays"
|
|
10
|
+
var _excluded = ["id", "mode", "placeholder", "disabled", "errors", "value", "onChange", "disabledDays"];
|
|
11
11
|
var DatePicker = function DatePicker(_ref) {
|
|
12
12
|
var id = _ref.id,
|
|
13
13
|
_ref$mode = _ref.mode,
|
|
@@ -18,112 +18,42 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
18
18
|
value = _ref.value,
|
|
19
19
|
onChange = _ref.onChange,
|
|
20
20
|
disabledDays = _ref.disabledDays,
|
|
21
|
-
startMonth = _ref.startMonth,
|
|
22
|
-
endMonth = _ref.endMonth,
|
|
23
21
|
dayPickerProps = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
-
var _useTranslation = useTranslation(),
|
|
25
|
-
_useTranslation2 = _slicedToArray(_useTranslation, 1),
|
|
26
|
-
t = _useTranslation2[0];
|
|
27
22
|
var _useState = useState(false),
|
|
28
23
|
_useState2 = _slicedToArray(_useState, 2),
|
|
29
24
|
open = _useState2[0],
|
|
30
25
|
setOpen = _useState2[1];
|
|
31
|
-
var _useState3 = useState(''),
|
|
32
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
|
-
inputValue = _useState4[0],
|
|
34
|
-
setInputValue = _useState4[1];
|
|
35
|
-
var _useState5 = useState(undefined),
|
|
36
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
37
|
-
internalValidationErrors = _useState6[0],
|
|
38
|
-
setInternalValidationErrors = _useState6[1];
|
|
39
26
|
var selectedDates = useMemo(function () {
|
|
40
27
|
return value;
|
|
41
28
|
}, [value]);
|
|
42
29
|
var displayValue = useMemo(function () {
|
|
43
|
-
if (!selectedDates) return
|
|
30
|
+
if (!selectedDates) return '';
|
|
44
31
|
return DatePickerUtils.inputFormatValue(selectedDates, mode);
|
|
45
|
-
}, [selectedDates, mode, inputValue]);
|
|
46
|
-
var defaultMonth = useMemo(function () {
|
|
47
|
-
if (!selectedDates) return undefined;
|
|
48
|
-
if (mode === 'single' && selectedDates instanceof Date) {
|
|
49
|
-
return selectedDates;
|
|
50
|
-
}
|
|
51
|
-
if (mode === 'range' && selectedDates && _typeof(selectedDates) === 'object' && 'from' in selectedDates) {
|
|
52
|
-
return selectedDates.from;
|
|
53
|
-
}
|
|
54
|
-
return undefined;
|
|
55
32
|
}, [selectedDates, mode]);
|
|
56
|
-
var inputErrors = useMemo(function () {
|
|
57
|
-
if (internalValidationErrors && errors) {
|
|
58
|
-
return Array.isArray(errors) ? [].concat(_toConsumableArray(errors), [internalValidationErrors]) : [errors, internalValidationErrors];
|
|
59
|
-
}
|
|
60
|
-
if (internalValidationErrors) return internalValidationErrors;
|
|
61
|
-
return errors;
|
|
62
|
-
}, [internalValidationErrors, errors]);
|
|
63
33
|
var handleDateSelect = function handleDateSelect(selected) {
|
|
64
34
|
onChange === null || onChange === void 0 ? void 0 : onChange(selected);
|
|
65
|
-
setInputValue('');
|
|
66
|
-
setInternalValidationErrors(undefined);
|
|
67
35
|
if (mode === 'single' && selected) {
|
|
68
36
|
setOpen(false);
|
|
69
37
|
}
|
|
70
38
|
};
|
|
71
|
-
|
|
72
|
-
var typedValue = event.target.value;
|
|
73
|
-
setInputValue(typedValue);
|
|
74
|
-
if (typedValue.includes('_') || !typedValue) {
|
|
75
|
-
setInternalValidationErrors(undefined);
|
|
76
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (mode === 'single') {
|
|
80
|
-
var parsedDate = DatePickerUtils.parseStringToDate(typedValue);
|
|
81
|
-
if (!parsedDate) {
|
|
82
|
-
setInternalValidationErrors(undefined);
|
|
83
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
var isInRange = DatePickerUtils.isDateInRange(parsedDate, startMonth, endMonth);
|
|
87
|
-
var isDisabled = DatePickerUtils.isDateDisabled(parsedDate, disabledDays);
|
|
88
|
-
if (!isInRange || isDisabled) {
|
|
89
|
-
setInternalValidationErrors(t("This date isn't available. Choose another one."));
|
|
90
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
|
|
91
|
-
} else {
|
|
92
|
-
setInternalValidationErrors(undefined);
|
|
93
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(parsedDate);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (mode === 'range') {
|
|
97
|
-
var parsedRange = DatePickerUtils.parseStringToDateRange(typedValue);
|
|
98
|
-
if (parsedRange) {
|
|
99
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(parsedRange);
|
|
100
|
-
} else {
|
|
101
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Popover, {
|
|
39
|
+
return /*#__PURE__*/React__default.createElement(Popover, {
|
|
106
40
|
open: open,
|
|
107
41
|
onOpenChange: setOpen
|
|
42
|
+
}, /*#__PURE__*/React__default.createElement(PopoverTrigger, {
|
|
43
|
+
className: cn('aurora-w-full', disabled && 'aurora-cursor-not-allowed'),
|
|
44
|
+
disabled: disabled
|
|
108
45
|
}, /*#__PURE__*/React__default.createElement(DatePickerInput, {
|
|
109
46
|
id: id,
|
|
110
|
-
mode: mode,
|
|
111
47
|
value: displayValue,
|
|
112
48
|
placeholder: placeholder,
|
|
113
49
|
disabled: disabled,
|
|
114
|
-
errors:
|
|
115
|
-
|
|
116
|
-
}), /*#__PURE__*/React__default.createElement(DatePickerContent, _objectSpread2({
|
|
50
|
+
errors: errors
|
|
51
|
+
})), /*#__PURE__*/React__default.createElement(DatePickerContent, _objectSpread2({
|
|
117
52
|
mode: mode,
|
|
118
53
|
selected: selectedDates,
|
|
119
54
|
onSelect: handleDateSelect,
|
|
120
|
-
disabled: disabledDays
|
|
121
|
-
|
|
122
|
-
startMonth: startMonth,
|
|
123
|
-
endMonth: endMonth
|
|
124
|
-
}, dayPickerProps))), internalValidationErrors ? /*#__PURE__*/React__default.createElement(ErrorList, {
|
|
125
|
-
errors: internalValidationErrors
|
|
126
|
-
}) : null);
|
|
55
|
+
disabled: disabledDays
|
|
56
|
+
}, dayPickerProps)));
|
|
127
57
|
};
|
|
128
58
|
|
|
129
59
|
export { DatePicker };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DateRange, DayPickerProps } from 'react-day-picker';
|
|
2
|
-
export declare type DatePickerCalendarValue = Date | DateRange | undefined;
|
|
2
|
+
export declare type DatePickerCalendarValue = Date | Date[] | DateRange | undefined;
|
|
3
3
|
export interface DatePickerProps extends Omit<DayPickerProps, 'selected' | 'onSelect' | 'disabled'> {
|
|
4
4
|
id: string;
|
|
5
5
|
placeholder?: string;
|
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Mode } from 'react-day-picker';
|
|
2
2
|
import type { DatePickerCalendarValue } from './date_picker_types';
|
|
3
|
-
import type { InputState } from '../input_mask/input_mask_types';
|
|
4
|
-
declare type ValidationResult = {
|
|
5
|
-
valid: boolean;
|
|
6
|
-
keepFirst: boolean;
|
|
7
|
-
};
|
|
8
3
|
export declare class DatePickerUtils {
|
|
9
4
|
private static readonly formatter;
|
|
10
5
|
private static formatDate;
|
|
11
6
|
static inputFormatValue: (selected: DatePickerCalendarValue, mode: Mode) => string;
|
|
12
|
-
static parseStringToDate: (dateString: string) => Date | null;
|
|
13
|
-
static parseStringToDateRange: (rangeString: string) => DateRange | null;
|
|
14
|
-
private static replaceCharWithPlaceholder;
|
|
15
|
-
private static validateTwoDigitValue;
|
|
16
|
-
static validateDayAtPosition: (value: string, dayStartPos: number) => ValidationResult;
|
|
17
|
-
static validateMonthAtPosition: (value: string, monthStartPos: number) => ValidationResult;
|
|
18
|
-
static validateYearAtPosition: (value: string, yearStartPos: number) => ValidationResult;
|
|
19
|
-
private static handleInvalidInput;
|
|
20
|
-
static validateDateMask: (nextState: InputState, currentState?: InputState, mode?: Mode) => InputState;
|
|
21
|
-
static isDateInRange: (date: Date, startMonth?: Date, endMonth?: Date) => boolean;
|
|
22
|
-
static isDateDisabled: (date: Date, disabledDays?: DayPickerProps['disabled']) => boolean;
|
|
23
7
|
}
|
|
24
|
-
export {};
|
|
@@ -2,21 +2,6 @@ import { createClass as _createClass, classCallCheck as _classCallCheck, defineP
|
|
|
2
2
|
import 'react-day-picker';
|
|
3
3
|
|
|
4
4
|
var _DatePickerUtils;
|
|
5
|
-
var MASK_POSITIONS = {
|
|
6
|
-
SINGLE: {
|
|
7
|
-
DAY: 0,
|
|
8
|
-
MONTH: 3,
|
|
9
|
-
YEAR: 6
|
|
10
|
-
},
|
|
11
|
-
RANGE: {
|
|
12
|
-
DAY_START: 0,
|
|
13
|
-
MONTH_START: 3,
|
|
14
|
-
YEAR_START: 6,
|
|
15
|
-
DAY_END: 13,
|
|
16
|
-
MONTH_END: 16,
|
|
17
|
-
YEAR_END: 19
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
5
|
var DatePickerUtils = /*#__PURE__*/_createClass(function DatePickerUtils() {
|
|
21
6
|
_classCallCheck(this, DatePickerUtils);
|
|
22
7
|
});
|
|
@@ -34,6 +19,10 @@ _defineProperty(DatePickerUtils, "inputFormatValue", function (selected, mode) {
|
|
|
34
19
|
if (mode === 'single') {
|
|
35
20
|
return _DatePickerUtils.formatDate(selected);
|
|
36
21
|
}
|
|
22
|
+
if (mode === 'multiple') {
|
|
23
|
+
var dates = selected;
|
|
24
|
+
return dates.length > 0 ? dates.map(_DatePickerUtils.formatDate).join(', ') : '';
|
|
25
|
+
}
|
|
37
26
|
if (mode === 'range') {
|
|
38
27
|
var range = selected;
|
|
39
28
|
if (range.from && range.to) {
|
|
@@ -45,194 +34,6 @@ _defineProperty(DatePickerUtils, "inputFormatValue", function (selected, mode) {
|
|
|
45
34
|
}
|
|
46
35
|
return '';
|
|
47
36
|
});
|
|
48
|
-
_defineProperty(DatePickerUtils, "parseStringToDate", function (dateString) {
|
|
49
|
-
if (!dateString || dateString.includes('_')) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
var parts = dateString.split('.');
|
|
53
|
-
if (parts.length !== 3) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
var day = parseInt(parts[0], 10);
|
|
57
|
-
var month = parseInt(parts[1], 10);
|
|
58
|
-
var year = parseInt(parts[2], 10);
|
|
59
|
-
if (isNaN(day) || isNaN(month) || isNaN(year)) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
if (month < 1 || month > 12 || day < 1 || day > 31 || year < 1000) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
var date = new Date(year, month - 1, day);
|
|
66
|
-
if (date.getDate() !== day || date.getMonth() !== month - 1 || date.getFullYear() !== year) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return date;
|
|
70
|
-
});
|
|
71
|
-
_defineProperty(DatePickerUtils, "parseStringToDateRange", function (rangeString) {
|
|
72
|
-
if (!rangeString || rangeString.includes('_')) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
var parts = rangeString.split(' - ');
|
|
76
|
-
if (parts.length !== 2) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
var fromDate = _DatePickerUtils.parseStringToDate(parts[0].trim());
|
|
80
|
-
var toDate = _DatePickerUtils.parseStringToDate(parts[1].trim());
|
|
81
|
-
if (!fromDate || !toDate) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
if (fromDate > toDate) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
from: fromDate,
|
|
89
|
-
to: toDate
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
_defineProperty(DatePickerUtils, "replaceCharWithPlaceholder", function (value, position) {
|
|
93
|
-
return value.substring(0, position) + '_' + value.substring(position + 1);
|
|
94
|
-
});
|
|
95
|
-
_defineProperty(DatePickerUtils, "validateTwoDigitValue", function (value, startPos, firstDigit, maxSecondDigit) {
|
|
96
|
-
if (value.length < startPos + 2) return {
|
|
97
|
-
valid: true,
|
|
98
|
-
keepFirst: false
|
|
99
|
-
};
|
|
100
|
-
var first = value[startPos];
|
|
101
|
-
var second = value[startPos + 1];
|
|
102
|
-
if (second === '_') return {
|
|
103
|
-
valid: true,
|
|
104
|
-
keepFirst: false
|
|
105
|
-
};
|
|
106
|
-
if (first === '0' && second === '0') {
|
|
107
|
-
return {
|
|
108
|
-
valid: false,
|
|
109
|
-
keepFirst: false
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
if (first === firstDigit && parseInt(second) > maxSecondDigit) {
|
|
113
|
-
return {
|
|
114
|
-
valid: false,
|
|
115
|
-
keepFirst: true
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
return {
|
|
119
|
-
valid: true,
|
|
120
|
-
keepFirst: false
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
_defineProperty(DatePickerUtils, "validateDayAtPosition", function (value, dayStartPos) {
|
|
124
|
-
return _DatePickerUtils.validateTwoDigitValue(value, dayStartPos, '3', 1);
|
|
125
|
-
});
|
|
126
|
-
_defineProperty(DatePickerUtils, "validateMonthAtPosition", function (value, monthStartPos) {
|
|
127
|
-
return _DatePickerUtils.validateTwoDigitValue(value, monthStartPos, '1', 2);
|
|
128
|
-
});
|
|
129
|
-
_defineProperty(DatePickerUtils, "validateYearAtPosition", function (value, yearStartPos) {
|
|
130
|
-
if (value.length < yearStartPos + 2) return {
|
|
131
|
-
valid: true,
|
|
132
|
-
keepFirst: false
|
|
133
|
-
};
|
|
134
|
-
var first = value[yearStartPos];
|
|
135
|
-
var second = value[yearStartPos + 1];
|
|
136
|
-
if (second === '_') return {
|
|
137
|
-
valid: true,
|
|
138
|
-
keepFirst: false
|
|
139
|
-
};
|
|
140
|
-
if (first === '1' && second !== '9') {
|
|
141
|
-
return {
|
|
142
|
-
valid: false,
|
|
143
|
-
keepFirst: true
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
if (first === '2' && second !== '0') {
|
|
147
|
-
return {
|
|
148
|
-
valid: false,
|
|
149
|
-
keepFirst: true
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
return {
|
|
153
|
-
valid: true,
|
|
154
|
-
keepFirst: false
|
|
155
|
-
};
|
|
156
|
-
});
|
|
157
|
-
_defineProperty(DatePickerUtils, "handleInvalidInput", function (validation, value, currentValue, position, currentSelection, fallbackSelection) {
|
|
158
|
-
if (validation.keepFirst) {
|
|
159
|
-
var newValue = _DatePickerUtils.replaceCharWithPlaceholder(value, position + 1);
|
|
160
|
-
return {
|
|
161
|
-
value: newValue,
|
|
162
|
-
selection: {
|
|
163
|
-
start: position + 1,
|
|
164
|
-
end: position + 1
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
value: currentValue,
|
|
170
|
-
selection: currentSelection || fallbackSelection || {
|
|
171
|
-
start: null,
|
|
172
|
-
end: null
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
});
|
|
176
|
-
_defineProperty(DatePickerUtils, "validateDateMask", function (nextState, currentState) {
|
|
177
|
-
var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'single';
|
|
178
|
-
var value = nextState.value,
|
|
179
|
-
selection = nextState.selection;
|
|
180
|
-
var currentValue = (currentState === null || currentState === void 0 ? void 0 : currentState.value) || '';
|
|
181
|
-
var dayValidation = _DatePickerUtils.validateDayAtPosition(value, MASK_POSITIONS.SINGLE.DAY);
|
|
182
|
-
if (!dayValidation.valid) {
|
|
183
|
-
return _DatePickerUtils.handleInvalidInput(dayValidation, value, currentValue, MASK_POSITIONS.SINGLE.DAY, currentState === null || currentState === void 0 ? void 0 : currentState.selection, selection);
|
|
184
|
-
}
|
|
185
|
-
var monthValidation = _DatePickerUtils.validateMonthAtPosition(value, MASK_POSITIONS.SINGLE.MONTH);
|
|
186
|
-
if (!monthValidation.valid) {
|
|
187
|
-
return _DatePickerUtils.handleInvalidInput(monthValidation, value, currentValue, MASK_POSITIONS.SINGLE.MONTH, currentState === null || currentState === void 0 ? void 0 : currentState.selection, selection);
|
|
188
|
-
}
|
|
189
|
-
var yearValidation = _DatePickerUtils.validateYearAtPosition(value, MASK_POSITIONS.SINGLE.YEAR);
|
|
190
|
-
if (!yearValidation.valid) {
|
|
191
|
-
return _DatePickerUtils.handleInvalidInput(yearValidation, value, currentValue, MASK_POSITIONS.SINGLE.YEAR, currentState === null || currentState === void 0 ? void 0 : currentState.selection, selection);
|
|
192
|
-
}
|
|
193
|
-
if (mode === 'range') {
|
|
194
|
-
var dayValidation2 = _DatePickerUtils.validateDayAtPosition(value, MASK_POSITIONS.RANGE.DAY_END);
|
|
195
|
-
if (!dayValidation2.valid) {
|
|
196
|
-
return _DatePickerUtils.handleInvalidInput(dayValidation2, value, currentValue, MASK_POSITIONS.RANGE.DAY_END, currentState === null || currentState === void 0 ? void 0 : currentState.selection, selection);
|
|
197
|
-
}
|
|
198
|
-
var monthValidation2 = _DatePickerUtils.validateMonthAtPosition(value, MASK_POSITIONS.RANGE.MONTH_END);
|
|
199
|
-
if (!monthValidation2.valid) {
|
|
200
|
-
return _DatePickerUtils.handleInvalidInput(monthValidation2, value, currentValue, MASK_POSITIONS.RANGE.MONTH_END, currentState === null || currentState === void 0 ? void 0 : currentState.selection, selection);
|
|
201
|
-
}
|
|
202
|
-
var yearValidation2 = _DatePickerUtils.validateYearAtPosition(value, MASK_POSITIONS.RANGE.YEAR_END);
|
|
203
|
-
if (!yearValidation2.valid) {
|
|
204
|
-
return _DatePickerUtils.handleInvalidInput(yearValidation2, value, currentValue, MASK_POSITIONS.RANGE.YEAR_END, currentState === null || currentState === void 0 ? void 0 : currentState.selection, selection);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return nextState;
|
|
208
|
-
});
|
|
209
|
-
_defineProperty(DatePickerUtils, "isDateInRange", function (date, startMonth, endMonth) {
|
|
210
|
-
if (!startMonth && !endMonth) return true;
|
|
211
|
-
if (startMonth) {
|
|
212
|
-
var minDate = new Date(startMonth.getFullYear(), startMonth.getMonth(), 1);
|
|
213
|
-
if (date < minDate) return false;
|
|
214
|
-
}
|
|
215
|
-
if (endMonth) {
|
|
216
|
-
var maxDate = new Date(endMonth.getFullYear(), endMonth.getMonth() + 1, 0);
|
|
217
|
-
if (date > maxDate) return false;
|
|
218
|
-
}
|
|
219
|
-
return true;
|
|
220
|
-
});
|
|
221
|
-
_defineProperty(DatePickerUtils, "isDateDisabled", function (date, disabledDays) {
|
|
222
|
-
if (!disabledDays) return false;
|
|
223
|
-
if (Array.isArray(disabledDays)) {
|
|
224
|
-
return disabledDays.some(function (disabledDate) {
|
|
225
|
-
if (disabledDate instanceof Date) {
|
|
226
|
-
return disabledDate.getFullYear() === date.getFullYear() && disabledDate.getMonth() === date.getMonth() && disabledDate.getDate() === date.getDate();
|
|
227
|
-
}
|
|
228
|
-
return false;
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
if (typeof disabledDays === 'function') {
|
|
232
|
-
return disabledDays(date);
|
|
233
|
-
}
|
|
234
|
-
return false;
|
|
235
|
-
});
|
|
236
37
|
|
|
237
38
|
export { DatePickerUtils };
|
|
238
39
|
//# sourceMappingURL=date_picker_utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/build/esm/packages/aurora/src/components/time_picker/components/time_picker_input.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TInputProps } from "../../input/input_types";
|
|
3
3
|
export interface TimePickerInputProps extends TInputProps {
|
|
4
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
5
4
|
}
|
|
6
|
-
export declare const TimePickerInput: ({ id, value, placeholder, disabled, errors
|
|
5
|
+
export declare const TimePickerInput: ({ id, value, placeholder, disabled, errors }: TimePickerInputProps) => React.JSX.Element;
|
package/build/esm/packages/aurora/src/components/time_picker/components/time_picker_input.js
CHANGED
|
@@ -1,48 +1,28 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import { PopoverTrigger } from '../../popover/components/popover_trigger.js';
|
|
3
2
|
import { Input } from '../../input/input.js';
|
|
4
|
-
import { InputMask } from '../../input_mask/input_mask.js';
|
|
5
3
|
import { TimeLineIcon } from '../../../assets/icons/time_line_icon.js';
|
|
6
|
-
import { TimePickerUtils } from '../time_picker_utils.js';
|
|
7
4
|
|
|
8
5
|
var TimePickerInput = function TimePickerInput(_ref) {
|
|
9
6
|
var id = _ref.id,
|
|
10
7
|
value = _ref.value,
|
|
11
8
|
placeholder = _ref.placeholder,
|
|
12
9
|
disabled = _ref.disabled,
|
|
13
|
-
errors = _ref.errors
|
|
14
|
-
|
|
15
|
-
var mask = 'h9:m9';
|
|
16
|
-
var formatChars = {
|
|
17
|
-
h: /[0-2]/,
|
|
18
|
-
m: /[0-5]/
|
|
19
|
-
};
|
|
20
|
-
var handleBeforeMaskedStateChange = function handleBeforeMaskedStateChange(_ref2) {
|
|
21
|
-
var currentState = _ref2.currentState,
|
|
22
|
-
nextState = _ref2.nextState;
|
|
23
|
-
return TimePickerUtils.validateTimeMask(nextState, currentState);
|
|
24
|
-
};
|
|
25
|
-
return /*#__PURE__*/React__default.createElement(InputMask, {
|
|
26
|
-
mask: mask,
|
|
27
|
-
maskPlaceholder: "_",
|
|
28
|
-
formatChars: formatChars,
|
|
29
|
-
value: value || '',
|
|
30
|
-
onChange: onChange,
|
|
31
|
-
disabled: disabled,
|
|
32
|
-
beforeMaskedStateChange: handleBeforeMaskedStateChange
|
|
33
|
-
}, /*#__PURE__*/React__default.createElement(Input, {
|
|
10
|
+
errors = _ref.errors;
|
|
11
|
+
return /*#__PURE__*/React__default.createElement(Input, {
|
|
34
12
|
id: id,
|
|
13
|
+
value: value,
|
|
35
14
|
errors: errors,
|
|
15
|
+
readOnly: true,
|
|
16
|
+
disabled: disabled,
|
|
36
17
|
placeholder: placeholder,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
className: "aurora-flex aurora-h-full aurora-items-center aurora-cursor-pointer aurora-border-0 aurora-bg-transparent aurora-px-1 aurora-py-2 aurora-rounded-4 focus:aurora-outline-primary-hover"
|
|
18
|
+
hasCursorPointer: true,
|
|
19
|
+
postElement: /*#__PURE__*/React__default.createElement("div", {
|
|
20
|
+
className: "aurora-flex aurora-h-full aurora-items-center aurora-cursor-pointer aurora-border-0 aurora-bg-transparent aurora-p-1 aurora-rounded-4 focus:aurora-outline-primary-hover"
|
|
41
21
|
}, /*#__PURE__*/React__default.createElement(TimeLineIcon, {
|
|
42
22
|
size: 14,
|
|
43
23
|
className: "aurora-text"
|
|
44
|
-
}))
|
|
45
|
-
})
|
|
24
|
+
}))
|
|
25
|
+
});
|
|
46
26
|
};
|
|
47
27
|
|
|
48
28
|
export { TimePickerInput };
|
package/build/esm/packages/aurora/src/components/time_picker/components/time_picker_input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|