@mailstep/design-system 0.13.0-beta.2 → 0.13.1-beta.2
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/package.json +1 -1
- package/ui/Blocks/Scheduler/components/DateChanger/index.d.ts +1 -1
- package/ui/Blocks/Scheduler/components/DateChanger/index.js +1 -1
- package/ui/Blocks/Scheduler/hooks/useChangeDate.d.ts +1 -1
- package/ui/{Elements → Forms}/DatePicker/DatePicker.d.ts +1 -1
- package/ui/{Elements → Forms}/DatePicker/DatePicker.js +7 -3
- package/ui/{Elements → Forms}/DatePicker/Datetime/DateTime.js +1 -1
- package/ui/{Elements → Forms}/DatePicker/Datetime/components/DateRepeater.js +5 -5
- package/ui/{Elements → Forms}/DatePicker/Datetime/components/FooterRow.js +1 -1
- package/ui/{Elements → Forms}/DatePicker/Datetime/components/FooterRowLabel.js +1 -1
- package/ui/{Elements → Forms}/DatePicker/Datetime/components/TimeInput.js +1 -1
- package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/Timepicker.js +19 -9
- package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/constants.d.ts +1 -0
- package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/constants.js +3 -2
- package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/styles.js +8 -2
- package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/utils/index.d.ts +1 -0
- package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/utils/index.js +2 -1
- package/ui/Forms/DatePicker/Datetime/components/Timepicker/utils/isTimeFieldComplete.d.ts +3 -0
- package/ui/Forms/DatePicker/Datetime/components/Timepicker/utils/isTimeFieldComplete.js +5 -0
- package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/utils/padTime.js +1 -1
- package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/utils/parseTimeField.js +1 -1
- package/ui/Forms/DatePicker/Datetime/components/Timepicker/utils/sanitizeTimeField.js +5 -0
- package/ui/{Elements → Forms}/DatePicker/Datetime/components/ViewNavigation.js +1 -1
- package/ui/{Elements → Forms}/DatePicker/Datetime/types.js +1 -1
- package/ui/{Elements → Forms}/DatePicker/Datetime/views/DaysView.js +1 -1
- package/ui/{Elements → Forms}/DatePicker/Datetime/views/MonthsView.js +1 -1
- package/ui/{Elements → Forms}/DatePicker/Datetime/views/YearsView.js +1 -1
- package/ui/{Elements → Forms}/DatePicker/components/DatePickerInput/DatePickerInput.d.ts +6 -2
- package/ui/Forms/DatePicker/components/DatePickerInput/DatePickerInput.js +62 -0
- package/ui/Forms/DatePicker/components/DatePickerInput/constants.d.ts +5 -0
- package/ui/Forms/DatePicker/components/DatePickerInput/constants.js +16 -0
- package/ui/Forms/DatePicker/components/DatePickerInput/utils/applyDateMask.d.ts +3 -0
- package/ui/Forms/DatePicker/components/DatePickerInput/utils/applyDateMask.js +19 -0
- package/ui/Forms/DatePicker/components/DatePickerInput/utils/countDigits.d.ts +3 -0
- package/ui/Forms/DatePicker/components/DatePickerInput/utils/countDigits.js +5 -0
- package/ui/Forms/DatePicker/components/DatePickerInput/utils/getMaskedCaretPosition.d.ts +3 -0
- package/ui/Forms/DatePicker/components/DatePickerInput/utils/getMaskedCaretPosition.js +14 -0
- package/ui/Forms/DatePicker/components/DatePickerInput/utils/index.d.ts +4 -0
- package/ui/Forms/DatePicker/components/DatePickerInput/utils/index.js +5 -0
- package/ui/Forms/DatePicker/components/DatePickerInput/utils/isMaskableFormat.d.ts +3 -0
- package/ui/Forms/DatePicker/components/DatePickerInput/utils/isMaskableFormat.js +9 -0
- package/ui/{Elements → Forms}/DatePicker/index.js +1 -1
- package/ui/Forms/DatePicker/stories/hooks/useOnChange.d.ts +5 -0
- package/ui/Forms/DatePicker/stories/hooks/useOnChange.js +13 -0
- package/ui/{Elements → Forms}/DatePicker/styles.js +10 -5
- package/ui/Forms/DatePicker/utils/constants.d.ts +3 -0
- package/ui/{Elements → Forms}/DatePicker/utils/constants.js +5 -5
- package/ui/Forms/DatePicker/utils/getInputFormat.d.ts +3 -0
- package/ui/Forms/DatePicker/utils/getInputFormat.js +10 -0
- package/ui/Forms/Input/styles.js +3 -9
- package/ui/Modules/CommonGrid/components/Filters/DatePickerRange/DatePickerRange.d.ts +1 -1
- package/ui/Modules/CommonGrid/components/Filters/DatePickerRange/DatePickerRange.js +1 -1
- package/ui/Modules/CommonGrid/components/Filters/DatePickerRange/utils/pickerRangeToString.d.ts +1 -1
- package/ui/Modules/CommonGrid/components/Filters/DatePickerRange/utils/pickerRangeToString.js +3 -3
- package/ui/index.d.ts +2 -2
- package/ui/index.js +2 -2
- package/ui/Elements/DatePicker/Datetime/components/Timepicker/utils/sanitizeTimeField.js +0 -4
- package/ui/Elements/DatePicker/components/DatePickerInput/DatePickerInput.js +0 -33
- package/ui/Elements/DatePicker/utils/constants.d.ts +0 -3
- /package/ui/{Elements → Forms}/DatePicker/Datetime/DateTime.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/components/DateRepeater.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/components/FooterRow.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/components/FooterRowLabel.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/components/TimeInput.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/Timepicker.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/index.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/index.js +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/styles.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/utils/padTime.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/utils/parseTimeField.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/utils/sanitizeTimeField.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/components/ViewNavigation.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/types.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/views/DaysView.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/views/MonthsView.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/Datetime/views/YearsView.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/components/DatePickerInput/index.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/components/DatePickerInput/index.js +0 -0
- /package/ui/{Elements → Forms}/DatePicker/index.d.ts +0 -0
- /package/ui/{Elements → Forms}/DatePicker/styles.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FC } from 'react';
|
|
2
|
-
import { type DatePickerType } from '../../../../
|
|
2
|
+
import { type DatePickerType } from '../../../../Forms/DatePicker/DatePicker';
|
|
3
3
|
type DateChangerProps = {
|
|
4
4
|
isLoading?: boolean;
|
|
5
5
|
isDatepickerOpen: boolean;
|
|
@@ -2,7 +2,7 @@ import { ArrowDown } from "../../../../Elements/Icon/icons/ArrowDown.js";
|
|
|
2
2
|
import "../../../../Elements/Icon/index.js";
|
|
3
3
|
import { Spinner } from "../../../../Elements/Spinner/Spinner.js";
|
|
4
4
|
import { LanguageContext } from "../../../../ThemeProvider/ThemeProvider.js";
|
|
5
|
-
import DatePicker_default from "../../../../
|
|
5
|
+
import DatePicker_default from "../../../../Forms/DatePicker/index.js";
|
|
6
6
|
import Popover from "../../../Popover/index.js";
|
|
7
7
|
import { formatDate } from "../../utils/formatDate.js";
|
|
8
8
|
import { ArrowContainer, DateChangerContainer } from "./styles.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { SpaceAround } from '
|
|
2
|
+
import type { SpaceAround } from '../../Elements/SpaceAround';
|
|
3
3
|
import type { DateTimeOthers, DatetimepickerProps } from './Datetime/types';
|
|
4
4
|
import 'moment/dist/locale/cs';
|
|
5
5
|
import 'moment/dist/locale/el';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { LanguageContext } from "../../ThemeProvider/ThemeProvider.js";
|
|
2
|
-
import SpaceAround_default from "
|
|
2
|
+
import SpaceAround_default from "../../Elements/SpaceAround/index.js";
|
|
3
3
|
import Datetime from "./Datetime/DateTime.js";
|
|
4
4
|
import { DatePickerInput } from "./components/DatePickerInput/DatePickerInput.js";
|
|
5
5
|
import "./components/DatePickerInput/index.js";
|
|
6
|
+
import { getInputFormat } from "./utils/getInputFormat.js";
|
|
6
7
|
import { DatePickerBase } from "./styles.js";
|
|
7
8
|
import React, { useCallback, useContext } from "react";
|
|
8
9
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -12,13 +13,15 @@ import "moment/dist/locale/el";
|
|
|
12
13
|
import "moment/dist/locale/it";
|
|
13
14
|
import "moment/dist/locale/ru";
|
|
14
15
|
import "moment/dist/locale/sk";
|
|
15
|
-
//#region packages/ui/
|
|
16
|
+
//#region packages/ui/Forms/DatePicker/DatePicker.tsx
|
|
16
17
|
const defaultDateFormat = "DD.MM.YYYY";
|
|
17
18
|
const DatePicker = ({ name, value, initialViewDate, error, label, disabled, isValidDate, onChange, dateFormat = defaultDateFormat, timeFormat = false, open, secondValue = null, input, icon = true, showInputLabel = false, showCalendarLabel = true, spaceAround = false, className, onClear, onInputChange, ...passProps }) => {
|
|
18
19
|
const locale = useContext(LanguageContext);
|
|
20
|
+
const inputFormat = getInputFormat(dateFormat, timeFormat);
|
|
19
21
|
const handleRenderInput = useCallback((inputProps, openCalendar) => /* @__PURE__ */ jsx(DatePickerInput, {
|
|
20
22
|
inputProps,
|
|
21
23
|
openCalendar,
|
|
24
|
+
format: inputFormat,
|
|
22
25
|
name,
|
|
23
26
|
label,
|
|
24
27
|
error,
|
|
@@ -35,7 +38,8 @@ const DatePicker = ({ name, value, initialViewDate, error, label, disabled, isVa
|
|
|
35
38
|
icon,
|
|
36
39
|
showInputLabel,
|
|
37
40
|
onClear,
|
|
38
|
-
onInputChange
|
|
41
|
+
onInputChange,
|
|
42
|
+
inputFormat
|
|
39
43
|
]);
|
|
40
44
|
const handleRenderView = useCallback((_, renderCalendar) => {
|
|
41
45
|
if (label && !showInputLabel) return /* @__PURE__ */ jsx(x.div, {
|
|
@@ -5,7 +5,7 @@ import React from "react";
|
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import moment from "moment";
|
|
7
7
|
import onClickOutside from "react-onclickoutside";
|
|
8
|
-
//#region packages/ui/
|
|
8
|
+
//#region packages/ui/Forms/DatePicker/Datetime/DateTime.tsx
|
|
9
9
|
const viewModes = {
|
|
10
10
|
YEARS: "years",
|
|
11
11
|
MONTHS: "months",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Icon_default from "
|
|
1
|
+
import Icon_default from "../../../../Elements/Icon/index.js";
|
|
2
2
|
import "../types.js";
|
|
3
3
|
import { DatePickerRepeatTrans } from "../../utils/constants.js";
|
|
4
4
|
import { FooterRow } from "./FooterRow.js";
|
|
@@ -7,7 +7,7 @@ import { useCallback } from "react";
|
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { x } from "@xstyled/styled-components";
|
|
9
9
|
import { i18n } from "@lingui/core";
|
|
10
|
-
//#region packages/ui/
|
|
10
|
+
//#region packages/ui/Forms/DatePicker/Datetime/components/DateRepeater.tsx
|
|
11
11
|
const DateRepeater = ({ onChangeOthers, others, reset }) => {
|
|
12
12
|
const handleChange = useCallback((e) => {
|
|
13
13
|
const dateTypeRepeater = e.target.value;
|
|
@@ -40,7 +40,7 @@ const DateRepeater = ({ onChangeOthers, others, reset }) => {
|
|
|
40
40
|
onChange: handleChange,
|
|
41
41
|
value: others?.dateTypeRepeater,
|
|
42
42
|
backgroundColor: "transparent",
|
|
43
|
-
color: "
|
|
43
|
+
color: "typoPrimary",
|
|
44
44
|
cursor: "pointer",
|
|
45
45
|
border: "none",
|
|
46
46
|
children: [
|
|
@@ -53,11 +53,11 @@ const DateRepeater = ({ onChangeOthers, others, reset }) => {
|
|
|
53
53
|
}),
|
|
54
54
|
/* @__PURE__ */ jsx("option", {
|
|
55
55
|
value: "every-today",
|
|
56
|
-
children: DatePickerRepeatTrans["every-today"]
|
|
56
|
+
children: DatePickerRepeatTrans()["every-today"]
|
|
57
57
|
}),
|
|
58
58
|
/* @__PURE__ */ jsx("option", {
|
|
59
59
|
value: "every-yesterday",
|
|
60
|
-
children: DatePickerRepeatTrans["every-yesterday"]
|
|
60
|
+
children: DatePickerRepeatTrans()["every-yesterday"]
|
|
61
61
|
})
|
|
62
62
|
]
|
|
63
63
|
})] })
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { styled } from "@xstyled/styled-components";
|
|
2
|
-
//#region packages/ui/
|
|
2
|
+
//#region packages/ui/Forms/DatePicker/Datetime/components/FooterRow.tsx
|
|
3
3
|
const FooterRow = styled.div`
|
|
4
4
|
display: flex;
|
|
5
5
|
justify-content: space-between;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled$1 from "@xstyled/styled-components";
|
|
2
|
-
//#region packages/ui/
|
|
2
|
+
//#region packages/ui/Forms/DatePicker/Datetime/components/FooterRowLabel.tsx
|
|
3
3
|
const FooterRowLabel = styled$1.span`
|
|
4
4
|
margin-left: 8px;
|
|
5
5
|
text-align: left;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled$1 from "@xstyled/styled-components";
|
|
2
|
-
//#region packages/ui/
|
|
2
|
+
//#region packages/ui/Forms/DatePicker/Datetime/components/TimeInput.tsx
|
|
3
3
|
const TimeInput = styled$1.input`
|
|
4
4
|
margin: 0;
|
|
5
5
|
margin-right: -1px;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Icon_default from "../../../../../Elements/Icon/index.js";
|
|
2
2
|
import { FooterRow } from "../FooterRow.js";
|
|
3
3
|
import { FooterRowLabel } from "../FooterRowLabel.js";
|
|
4
4
|
import "./constants.js";
|
|
5
5
|
import { TimeButton, TimeField, TimeWrapper } from "./styles.js";
|
|
6
6
|
import { padTime } from "./utils/padTime.js";
|
|
7
|
+
import { isTimeFieldComplete } from "./utils/isTimeFieldComplete.js";
|
|
7
8
|
import { parseTimeField } from "./utils/parseTimeField.js";
|
|
8
9
|
import { sanitizeTimeField } from "./utils/sanitizeTimeField.js";
|
|
10
|
+
import "./utils/index.js";
|
|
9
11
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
10
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
13
|
import { x } from "@xstyled/styled-components";
|
|
12
14
|
import { i18n } from "@lingui/core";
|
|
13
|
-
//#region packages/ui/
|
|
15
|
+
//#region packages/ui/Forms/DatePicker/Datetime/components/Timepicker/Timepicker.tsx
|
|
14
16
|
const Timepicker = ({ setTime, value, disabled }) => {
|
|
15
17
|
const hours = value?.getHours?.() ?? 0;
|
|
16
18
|
const minutes = value?.getMinutes?.() ?? 0;
|
|
@@ -18,6 +20,7 @@ const Timepicker = ({ setTime, value, disabled }) => {
|
|
|
18
20
|
const [minutesValue, setMinutesValue] = useState(padTime(minutes));
|
|
19
21
|
const isHoursEdited = useRef(false);
|
|
20
22
|
const isMinutesEdited = useRef(false);
|
|
23
|
+
const minutesRef = useRef(null);
|
|
21
24
|
useEffect(() => {
|
|
22
25
|
if (isHoursEdited.current) return;
|
|
23
26
|
setHoursValue(padTime(hours));
|
|
@@ -72,6 +75,8 @@ const Timepicker = ({ setTime, value, disabled }) => {
|
|
|
72
75
|
const parsed = parseTimeField(nextValue, NaN);
|
|
73
76
|
if (Number.isNaN(parsed) || parsed > 23) return;
|
|
74
77
|
commitTime("hours", parsed);
|
|
78
|
+
if (!isTimeFieldComplete(nextValue, parsed, 23)) return;
|
|
79
|
+
minutesRef.current?.focus();
|
|
75
80
|
}, [commitTime]);
|
|
76
81
|
const onMinutesChange = useCallback((e) => {
|
|
77
82
|
const nextValue = sanitizeTimeField(e.target.value);
|
|
@@ -93,17 +98,21 @@ const Timepicker = ({ setTime, value, disabled }) => {
|
|
|
93
98
|
}, []);
|
|
94
99
|
const onHoursBlur = useCallback(() => {
|
|
95
100
|
isHoursEdited.current = false;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
setHoursValue((prev) => {
|
|
102
|
+
const parsed = parseTimeField(prev, NaN);
|
|
103
|
+
return padTime(!Number.isNaN(parsed) && parsed <= 23 ? parsed : hours);
|
|
104
|
+
});
|
|
105
|
+
}, [hours]);
|
|
99
106
|
const onMinutesBlur = useCallback(() => {
|
|
100
107
|
isMinutesEdited.current = false;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
108
|
+
setMinutesValue((prev) => {
|
|
109
|
+
const parsed = parseTimeField(prev, NaN);
|
|
110
|
+
return padTime(!Number.isNaN(parsed) && parsed <= 59 ? parsed : minutes);
|
|
111
|
+
});
|
|
112
|
+
}, [minutes]);
|
|
104
113
|
return /* @__PURE__ */ jsxs(FooterRow, {
|
|
105
114
|
disabled,
|
|
106
|
-
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(
|
|
115
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Icon_default, { icon: "clock" }), /* @__PURE__ */ jsx(FooterRowLabel, { children: i18n._({
|
|
107
116
|
id: "dataGrid.filterCell.time",
|
|
108
117
|
message: "Time"
|
|
109
118
|
}) })] }), /* @__PURE__ */ jsx(x.div, {
|
|
@@ -147,6 +156,7 @@ const Timepicker = ({ setTime, value, disabled }) => {
|
|
|
147
156
|
children: ":"
|
|
148
157
|
}),
|
|
149
158
|
/* @__PURE__ */ jsx(TimeField, {
|
|
159
|
+
ref: minutesRef,
|
|
150
160
|
value: minutesValue,
|
|
151
161
|
disabled,
|
|
152
162
|
inputMode: "numeric",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
//#region packages/ui/
|
|
1
|
+
//#region packages/ui/Forms/DatePicker/Datetime/components/Timepicker/constants.ts
|
|
2
2
|
const HOURS_COUNT = 24;
|
|
3
3
|
const MINUTES_COUNT = 60;
|
|
4
4
|
const MINUTES_STEP = 5;
|
|
5
5
|
const MAX_HOURS = 23;
|
|
6
6
|
const MAX_MINUTES = 59;
|
|
7
|
+
const TIME_FIELD_LENGTH = 2;
|
|
7
8
|
//#endregion
|
|
8
|
-
export { HOURS_COUNT, MAX_HOURS, MAX_MINUTES, MINUTES_COUNT, MINUTES_STEP };
|
|
9
|
+
export { HOURS_COUNT, MAX_HOURS, MAX_MINUTES, MINUTES_COUNT, MINUTES_STEP, TIME_FIELD_LENGTH };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled$1 from "@xstyled/styled-components";
|
|
2
2
|
import { th as th$1 } from "@xstyled/system";
|
|
3
|
-
//#region packages/ui/
|
|
3
|
+
//#region packages/ui/Forms/DatePicker/Datetime/components/Timepicker/styles.ts
|
|
4
4
|
const TimeButton = styled$1.button`
|
|
5
5
|
transform: rotate(90deg);
|
|
6
6
|
font-size: 20px;
|
|
@@ -10,14 +10,20 @@ const TimeButton = styled$1.button`
|
|
|
10
10
|
background-color: transparent !important;
|
|
11
11
|
border: none;
|
|
12
12
|
color: ${th$1("colors.lightGray4")};
|
|
13
|
+
|
|
13
14
|
&:disabled:hover {
|
|
14
15
|
color: ${th$1("colors.lightGray4")};
|
|
15
16
|
cursor: default;
|
|
16
17
|
}
|
|
18
|
+
|
|
17
19
|
&:hover {
|
|
18
20
|
color: ${th$1("colors.red2")};
|
|
19
21
|
background-color: transparent !important;
|
|
20
22
|
}
|
|
23
|
+
|
|
24
|
+
&:focus {
|
|
25
|
+
outline: none;
|
|
26
|
+
}
|
|
21
27
|
`;
|
|
22
28
|
const TimeWrapper = styled$1.div`
|
|
23
29
|
display: flex;
|
|
@@ -39,7 +45,7 @@ const TimeField = styled$1.input`
|
|
|
39
45
|
border: none;
|
|
40
46
|
outline: none;
|
|
41
47
|
background-color: transparent;
|
|
42
|
-
color:
|
|
48
|
+
color: typoPrimary;
|
|
43
49
|
&:disabled {
|
|
44
50
|
opacity: 0.5;
|
|
45
51
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { padTime } from "./padTime.js";
|
|
2
|
+
import { isTimeFieldComplete } from "./isTimeFieldComplete.js";
|
|
2
3
|
import { parseTimeField } from "./parseTimeField.js";
|
|
3
4
|
import { sanitizeTimeField } from "./sanitizeTimeField.js";
|
|
4
|
-
export { padTime, parseTimeField, sanitizeTimeField };
|
|
5
|
+
export { isTimeFieldComplete, padTime, parseTimeField, sanitizeTimeField };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region packages/ui/
|
|
1
|
+
//#region packages/ui/Forms/DatePicker/Datetime/components/Timepicker/utils/padTime.ts
|
|
2
2
|
const padTime = (value) => String(value).padStart(2, "0");
|
|
3
3
|
//#endregion
|
|
4
4
|
export { padTime };
|
package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/utils/parseTimeField.js
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region packages/ui/
|
|
1
|
+
//#region packages/ui/Forms/DatePicker/Datetime/components/Timepicker/utils/parseTimeField.ts
|
|
2
2
|
const parseTimeField = (text, fallback) => {
|
|
3
3
|
if (text === "") return fallback;
|
|
4
4
|
const parsed = Number(text);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
//#region packages/ui/
|
|
3
|
+
//#region packages/ui/Forms/DatePicker/Datetime/components/ViewNavigation.tsx
|
|
4
4
|
function ViewNavigation({ onClickPrev, onClickSwitch, onClickNext, switchContent, switchColSpan, switchProps, label }) {
|
|
5
5
|
return /* @__PURE__ */ jsxs("tr", { children: [
|
|
6
6
|
/* @__PURE__ */ jsx("th", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region packages/ui/
|
|
1
|
+
//#region packages/ui/Forms/DatePicker/Datetime/types.ts
|
|
2
2
|
let DatePickerRepeat = /* @__PURE__ */ function(DatePickerRepeat) {
|
|
3
3
|
DatePickerRepeat["EVERY_TODAY"] = "every-today";
|
|
4
4
|
DatePickerRepeat["EVERY_YESTERDAY"] = "every-yesterday";
|
|
@@ -4,7 +4,7 @@ import "../components/Timepicker/index.js";
|
|
|
4
4
|
import ViewNavigation from "../components/ViewNavigation.js";
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
//#region packages/ui/
|
|
7
|
+
//#region packages/ui/Forms/DatePicker/Datetime/views/DaysView.tsx
|
|
8
8
|
var DaysView = class extends React.Component {
|
|
9
9
|
constructor(..._args) {
|
|
10
10
|
super(..._args);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ViewNavigation from "../components/ViewNavigation.js";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
//#region packages/ui/
|
|
4
|
+
//#region packages/ui/Forms/DatePicker/Datetime/views/MonthsView.tsx
|
|
5
5
|
var MonthsView = class extends React.Component {
|
|
6
6
|
constructor(..._args) {
|
|
7
7
|
super(..._args);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ViewNavigation from "../components/ViewNavigation.js";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
//#region packages/ui/
|
|
4
|
+
//#region packages/ui/Forms/DatePicker/Datetime/views/YearsView.tsx
|
|
5
5
|
var YearsView = class extends React.Component {
|
|
6
6
|
constructor(..._args) {
|
|
7
7
|
super(..._args);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { type FC, type InputHTMLAttributes } from 'react';
|
|
1
|
+
import { type ChangeEvent, type FC, type InputHTMLAttributes } from 'react';
|
|
2
|
+
type DatetimeInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> & {
|
|
3
|
+
onChange?: (event: ChangeEvent<HTMLInputElement> | string) => void;
|
|
4
|
+
};
|
|
2
5
|
type DatePickerInputProps = {
|
|
3
|
-
inputProps:
|
|
6
|
+
inputProps: DatetimeInputProps;
|
|
4
7
|
openCalendar: () => void;
|
|
8
|
+
format: string;
|
|
5
9
|
name?: string;
|
|
6
10
|
label?: string;
|
|
7
11
|
error?: string;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import Input_default from "../../../Input/index.js";
|
|
2
|
+
import { applyDateMask } from "./utils/applyDateMask.js";
|
|
3
|
+
import { countDigits } from "./utils/countDigits.js";
|
|
4
|
+
import { getMaskedCaretPosition } from "./utils/getMaskedCaretPosition.js";
|
|
5
|
+
import { isMaskableFormat } from "./utils/isMaskableFormat.js";
|
|
6
|
+
import { useCallback, useLayoutEffect, useRef, useState } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
//#region packages/ui/Forms/DatePicker/components/DatePickerInput/DatePickerInput.tsx
|
|
9
|
+
const DatePickerInput = ({ inputProps, openCalendar, format, name, label, error, disabled, icon, showInputLabel, onClear, onInputChange }) => {
|
|
10
|
+
const [typedValue, setTypedValue] = useState(null);
|
|
11
|
+
const inputRef = useRef(null);
|
|
12
|
+
const caretPosition = useRef(null);
|
|
13
|
+
const isMasked = isMaskableFormat(format);
|
|
14
|
+
useLayoutEffect(() => {
|
|
15
|
+
if (caretPosition.current === null) return;
|
|
16
|
+
const caret = caretPosition.current;
|
|
17
|
+
caretPosition.current = null;
|
|
18
|
+
inputRef.current?.setSelectionRange(caret, caret);
|
|
19
|
+
});
|
|
20
|
+
const handleChange = useCallback((e) => {
|
|
21
|
+
if (!isMasked) {
|
|
22
|
+
setTypedValue(e.target.value);
|
|
23
|
+
inputProps.onChange?.(e);
|
|
24
|
+
onInputChange?.(e.target.value);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const { value, selectionStart } = e.target;
|
|
28
|
+
const digitsBeforeCaret = countDigits(value.slice(0, selectionStart ?? value.length));
|
|
29
|
+
const maskedValue = applyDateMask(value, format);
|
|
30
|
+
caretPosition.current = getMaskedCaretPosition(maskedValue, digitsBeforeCaret);
|
|
31
|
+
setTypedValue(maskedValue);
|
|
32
|
+
inputProps.onChange?.(maskedValue);
|
|
33
|
+
onInputChange?.(maskedValue);
|
|
34
|
+
}, [
|
|
35
|
+
inputProps,
|
|
36
|
+
onInputChange,
|
|
37
|
+
isMasked,
|
|
38
|
+
format
|
|
39
|
+
]);
|
|
40
|
+
const handleBlur = useCallback(() => {
|
|
41
|
+
setTypedValue(null);
|
|
42
|
+
}, []);
|
|
43
|
+
return /* @__PURE__ */ jsx(Input_default, {
|
|
44
|
+
type: "text",
|
|
45
|
+
icon: icon ? "calendar" : void 0,
|
|
46
|
+
name,
|
|
47
|
+
error,
|
|
48
|
+
disabled,
|
|
49
|
+
isInvalid: !!error,
|
|
50
|
+
inputRef,
|
|
51
|
+
onChange: handleChange,
|
|
52
|
+
onBlur: handleBlur,
|
|
53
|
+
label: showInputLabel ? label : void 0,
|
|
54
|
+
value: typedValue ?? inputProps.value,
|
|
55
|
+
onFocus: openCalendar,
|
|
56
|
+
iconOnClick: openCalendar,
|
|
57
|
+
onClear,
|
|
58
|
+
autoComplete: "off"
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { DatePickerInput };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region packages/ui/Forms/DatePicker/components/DatePickerInput/constants.ts
|
|
2
|
+
const MASKABLE_TOKENS = [
|
|
3
|
+
"DD",
|
|
4
|
+
"MM",
|
|
5
|
+
"YY",
|
|
6
|
+
"YYYY",
|
|
7
|
+
"HH",
|
|
8
|
+
"mm",
|
|
9
|
+
"ss"
|
|
10
|
+
];
|
|
11
|
+
const DIGIT_PATTERN = /\d/;
|
|
12
|
+
const FORMAT_SLOT_PATTERN = /[A-Za-z]/;
|
|
13
|
+
const NON_DIGIT_PATTERN = /\D/g;
|
|
14
|
+
const FORMAT_TOKEN_PATTERN = /[A-Za-z]+/g;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { DIGIT_PATTERN, FORMAT_SLOT_PATTERN, FORMAT_TOKEN_PATTERN, MASKABLE_TOKENS, NON_DIGIT_PATTERN };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FORMAT_SLOT_PATTERN, NON_DIGIT_PATTERN } from "../constants.js";
|
|
2
|
+
//#region packages/ui/Forms/DatePicker/components/DatePickerInput/utils/applyDateMask.ts
|
|
3
|
+
const applyDateMask = (value, format) => {
|
|
4
|
+
const digits = value.replace(NON_DIGIT_PATTERN, "");
|
|
5
|
+
let masked = "";
|
|
6
|
+
let digitIndex = 0;
|
|
7
|
+
for (const char of format) {
|
|
8
|
+
if (digitIndex >= digits.length) break;
|
|
9
|
+
if (FORMAT_SLOT_PATTERN.test(char)) {
|
|
10
|
+
masked += digits[digitIndex];
|
|
11
|
+
digitIndex += 1;
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
masked += char;
|
|
15
|
+
}
|
|
16
|
+
return masked;
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { applyDateMask };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DIGIT_PATTERN } from "../constants.js";
|
|
2
|
+
//#region packages/ui/Forms/DatePicker/components/DatePickerInput/utils/getMaskedCaretPosition.ts
|
|
3
|
+
const getMaskedCaretPosition = (maskedValue, digitsBeforeCaret) => {
|
|
4
|
+
if (digitsBeforeCaret <= 0) return 0;
|
|
5
|
+
let digits = 0;
|
|
6
|
+
for (let index = 0; index < maskedValue.length; index += 1) {
|
|
7
|
+
if (!DIGIT_PATTERN.test(maskedValue[index])) continue;
|
|
8
|
+
digits += 1;
|
|
9
|
+
if (digits === digitsBeforeCaret) return index + 1;
|
|
10
|
+
}
|
|
11
|
+
return maskedValue.length;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getMaskedCaretPosition };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { applyDateMask } from "./applyDateMask.js";
|
|
2
|
+
import { countDigits } from "./countDigits.js";
|
|
3
|
+
import { getMaskedCaretPosition } from "./getMaskedCaretPosition.js";
|
|
4
|
+
import { isMaskableFormat } from "./isMaskableFormat.js";
|
|
5
|
+
export { applyDateMask, countDigits, getMaskedCaretPosition, isMaskableFormat };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FORMAT_TOKEN_PATTERN, MASKABLE_TOKENS } from "../constants.js";
|
|
2
|
+
//#region packages/ui/Forms/DatePicker/components/DatePickerInput/utils/isMaskableFormat.ts
|
|
3
|
+
const isMaskableFormat = (format) => {
|
|
4
|
+
const tokens = format.match(FORMAT_TOKEN_PATTERN);
|
|
5
|
+
if (!tokens?.length) return false;
|
|
6
|
+
return tokens.every((token) => MASKABLE_TOKENS.includes(token));
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { isMaskableFormat };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DatePickerRepeat, TimePickerRepeat } from "./Datetime/types.js";
|
|
2
2
|
import DatePicker_default$1 from "./DatePicker.js";
|
|
3
|
-
//#region packages/ui/
|
|
3
|
+
//#region packages/ui/Forms/DatePicker/index.ts
|
|
4
4
|
var DatePicker_default = DatePicker_default$1;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { DatePickerRepeat, TimePickerRepeat, DatePicker_default as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
//#region packages/ui/Forms/DatePicker/stories/hooks/useOnChange.ts
|
|
3
|
+
const useOnChange = () => {
|
|
4
|
+
const [value, setValue] = useState("");
|
|
5
|
+
return {
|
|
6
|
+
value,
|
|
7
|
+
handleChange: useCallback((next) => {
|
|
8
|
+
setValue(next);
|
|
9
|
+
}, [])
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { useOnChange };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled$1, { x } from "@xstyled/styled-components";
|
|
2
2
|
import { th as th$1 } from "@xstyled/system";
|
|
3
|
-
//#region packages/ui/
|
|
3
|
+
//#region packages/ui/Forms/DatePicker/styles.ts
|
|
4
4
|
const DatePickerBase = styled$1(x.div)`
|
|
5
5
|
.rdt {
|
|
6
6
|
position: relative;
|
|
@@ -10,8 +10,8 @@ const DatePickerBase = styled$1(x.div)`
|
|
|
10
10
|
position: absolute;
|
|
11
11
|
z-index: 1;
|
|
12
12
|
min-width: 250px;
|
|
13
|
-
color:
|
|
14
|
-
background:
|
|
13
|
+
color: typoPrimary;
|
|
14
|
+
background-color: white;
|
|
15
15
|
border: 1px solid rgba(0, 0, 0, 0.15);
|
|
16
16
|
border-radius: 10px;
|
|
17
17
|
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
|
|
@@ -44,6 +44,10 @@ const DatePickerBase = styled$1(x.div)`
|
|
|
44
44
|
.rdtPicker td {
|
|
45
45
|
padding: 0 0.8rem;
|
|
46
46
|
}
|
|
47
|
+
.rdtDay:not(.rdtActiveRange):hover {
|
|
48
|
+
border-radius: 0.5rem;
|
|
49
|
+
}
|
|
50
|
+
|
|
47
51
|
.rdtPicker .rdtCounter .rdtBtn:hover,
|
|
48
52
|
.rdtPicker .rdtYear:hover,
|
|
49
53
|
.rdtPicker .rdtMonth:hover,
|
|
@@ -54,11 +58,12 @@ const DatePickerBase = styled$1(x.div)`
|
|
|
54
58
|
.rdtPicker .rdtTimeToggle:hover,
|
|
55
59
|
.rdtPicker .rdtSwitch:hover {
|
|
56
60
|
background: #f8f9fa;
|
|
61
|
+
color: gray4;
|
|
57
62
|
cursor: pointer;
|
|
58
63
|
}
|
|
59
64
|
.rdtPicker .rdtOld,
|
|
60
65
|
.rdtPicker .rdtNew {
|
|
61
|
-
color:
|
|
66
|
+
color: lightGray4;
|
|
62
67
|
}
|
|
63
68
|
.rdtPicker .rdtToday {
|
|
64
69
|
position: relative;
|
|
@@ -191,7 +196,7 @@ const DatePickerBase = styled$1(x.div)`
|
|
|
191
196
|
}
|
|
192
197
|
|
|
193
198
|
.rdtPicker .rdtActiveRange {
|
|
194
|
-
background:
|
|
199
|
+
background-color: lightGray6;
|
|
195
200
|
}
|
|
196
201
|
|
|
197
202
|
.rdtPicker .rdtCounters > div :first-child {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../Datetime/types.js";
|
|
2
2
|
import { i18n } from "@lingui/core";
|
|
3
|
-
//#region packages/ui/
|
|
4
|
-
const DatePickerRepeatTrans = {
|
|
3
|
+
//#region packages/ui/Forms/DatePicker/utils/constants.ts
|
|
4
|
+
const DatePickerRepeatTrans = () => ({
|
|
5
5
|
["every-today"]: i18n._({
|
|
6
6
|
id: "dataGrid.everyToday",
|
|
7
7
|
message: "Every today"
|
|
@@ -10,8 +10,8 @@ const DatePickerRepeatTrans = {
|
|
|
10
10
|
id: "dataGrid.everyYesterday",
|
|
11
11
|
message: "Every yesterday"
|
|
12
12
|
})
|
|
13
|
-
};
|
|
14
|
-
const TimePickerRepeatTrans = {
|
|
13
|
+
});
|
|
14
|
+
const TimePickerRepeatTrans = () => ({
|
|
15
15
|
["from"]: i18n._({
|
|
16
16
|
id: "dataGrid.timepicker.from",
|
|
17
17
|
message: "from"
|
|
@@ -24,6 +24,6 @@ const TimePickerRepeatTrans = {
|
|
|
24
24
|
id: "dataGrid.timepicker.at",
|
|
25
25
|
message: "at"
|
|
26
26
|
})
|
|
27
|
-
};
|
|
27
|
+
});
|
|
28
28
|
//#endregion
|
|
29
29
|
export { DatePickerRepeatTrans, TimePickerRepeatTrans };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region packages/ui/Forms/DatePicker/utils/getInputFormat.ts
|
|
2
|
+
const getInputFormat = (dateFormat, timeFormat) => {
|
|
3
|
+
const date = typeof dateFormat === "string" ? dateFormat : "";
|
|
4
|
+
const time = typeof timeFormat === "string" ? timeFormat : "";
|
|
5
|
+
if (!date) return time;
|
|
6
|
+
if (!time) return date;
|
|
7
|
+
return `${date} ${time}`;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { getInputFormat };
|
package/ui/Forms/Input/styles.js
CHANGED
|
@@ -19,7 +19,7 @@ const InputIcon = styled$1.div`
|
|
|
19
19
|
svg {
|
|
20
20
|
stroke: lightGray3;
|
|
21
21
|
cursor: pointer;
|
|
22
|
-
color: ${({ $isInvalid, hasValue, disabled }) => $isInvalid ? th.color("inputErrorColor") : disabled || !hasValue ? th.color("lightGray6") : th.color("
|
|
22
|
+
color: ${({ $isInvalid, hasValue, disabled }) => $isInvalid ? th.color("inputErrorColor") : disabled || !hasValue ? th.color("lightGray6") : th.color("typoPrimary")};
|
|
23
23
|
}
|
|
24
24
|
`;
|
|
25
25
|
const ClearableInputIcon = styled$1(InputIcon)`
|
|
@@ -60,12 +60,6 @@ const StyledInput = styled$1.input.attrs((props) => ({ as: props.$asTextArea ? "
|
|
|
60
60
|
resize: none;
|
|
61
61
|
overflow: hidden;
|
|
62
62
|
|
|
63
|
-
~ ${InputIcon} {
|
|
64
|
-
svg {
|
|
65
|
-
stroke: lightGray3;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
63
|
::placeholder {
|
|
70
64
|
color: gray1;
|
|
71
65
|
opacity: 1;
|
|
@@ -79,8 +73,8 @@ const StyledInput = styled$1.input.attrs((props) => ({ as: props.$asTextArea ? "
|
|
|
79
73
|
|
|
80
74
|
~ ${InputIcon} {
|
|
81
75
|
svg {
|
|
82
|
-
stroke:
|
|
83
|
-
color:
|
|
76
|
+
stroke: typoPrimary;
|
|
77
|
+
color: typoPrimary;
|
|
84
78
|
}
|
|
85
79
|
}
|
|
86
80
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FC } from 'react';
|
|
2
|
-
import type { DateTimeOthers } from '../../../../../
|
|
2
|
+
import type { DateTimeOthers } from '../../../../../Forms/DatePicker/Datetime/types';
|
|
3
3
|
import type { FilterComponentProps } from '../../../types';
|
|
4
4
|
type InitialView = 'past' | 'future';
|
|
5
5
|
type DatePickerRangeProps = FilterComponentProps<Date[]> & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useClickOutside } from "../../../../../Blocks/Modal/hooks/useClickOutside.js";
|
|
2
2
|
import Input_default from "../../../../../Forms/Input/index.js";
|
|
3
|
-
import DatePicker_default from "../../../../../
|
|
3
|
+
import DatePicker_default from "../../../../../Forms/DatePicker/index.js";
|
|
4
4
|
import { getCleanValues } from "./utils/getCleanValues.js";
|
|
5
5
|
import { pickerRangeToString } from "./utils/pickerRangeToString.js";
|
|
6
6
|
import React, { useCallback, useMemo, useState } from "react";
|
package/ui/Modules/CommonGrid/components/Filters/DatePickerRange/utils/pickerRangeToString.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { DateTimeOthers } from '../../../../../../
|
|
1
|
+
import type { DateTimeOthers } from '../../../../../../Forms/DatePicker/Datetime/types';
|
|
2
2
|
export declare const pickerRangeToString: (values?: Date[], others?: DateTimeOthers[]) => string;
|
package/ui/Modules/CommonGrid/components/Filters/DatePickerRange/utils/pickerRangeToString.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { DatePickerRepeatTrans, TimePickerRepeatTrans } from "../../../../../../
|
|
1
|
+
import { DatePickerRepeatTrans, TimePickerRepeatTrans } from "../../../../../../Forms/DatePicker/utils/constants.js";
|
|
2
2
|
import { sameDate } from "./sameDate.js";
|
|
3
3
|
import { DateTime } from "luxon";
|
|
4
4
|
//#region packages/ui/Modules/CommonGrid/components/Filters/DatePickerRange/utils/pickerRangeToString.ts
|
|
5
5
|
const pickerRangeToString = (values = [], others) => {
|
|
6
6
|
if (others?.[0]?.dateTypeRepeater || others?.[1]?.dateTypeRepeater) return others.map((other, i) => {
|
|
7
7
|
if (!other?.dateTypeRepeater) return values[i] && DateTime.fromJSDate(values[i]).toFormat("dd.LL.yyyy HH:mm");
|
|
8
|
-
const repeaterDate = DatePickerRepeatTrans[other?.dateTypeRepeater];
|
|
9
|
-
return `${i === 0 ? TimePickerRepeatTrans.from : TimePickerRepeatTrans.to} ${repeaterDate} ${other?.time ? `${String(other?.time.h).padStart(2, "0")}:${String(other?.time.m).padStart(2, "0")}` : ""}`.trim();
|
|
8
|
+
const repeaterDate = DatePickerRepeatTrans()[other?.dateTypeRepeater];
|
|
9
|
+
return `${i === 0 ? TimePickerRepeatTrans().from : TimePickerRepeatTrans().to} ${repeaterDate} ${other?.time ? `${String(other?.time.h).padStart(2, "0")}:${String(other?.time.m).padStart(2, "0")}` : ""}`.trim();
|
|
10
10
|
}).filter(Boolean).join(" - ");
|
|
11
11
|
if (!values[0] && !values[1]) return "";
|
|
12
12
|
if (values[0] && !values[1] || sameDate(values[0], values[1])) return DateTime.fromJSDate(values[0]).toFormat("dd.LL.yyyy");
|
package/ui/index.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ import Badge from './Elements/Badge';
|
|
|
17
17
|
import BorderedBox from './Elements/BorderedBox';
|
|
18
18
|
import Button from './Elements/Button';
|
|
19
19
|
import Card from './Elements/Card';
|
|
20
|
-
import DatePicker from './Elements/DatePicker';
|
|
21
20
|
import Dropdown from './Elements/Dropdown';
|
|
22
21
|
import DropdownSelect from './Elements/DropdownSelect';
|
|
23
22
|
import ErrorMessage from './Elements/ErrorMessage';
|
|
@@ -39,6 +38,7 @@ import Tag from './Elements/Tag';
|
|
|
39
38
|
import Toast from './Elements/Toast';
|
|
40
39
|
import Toggle from './Elements/Toggle';
|
|
41
40
|
import Typography from './Elements/Typography';
|
|
41
|
+
import DatePicker from './Forms/DatePicker';
|
|
42
42
|
import Checkbox from './Forms/Checkbox';
|
|
43
43
|
import Input from './Forms/Input';
|
|
44
44
|
import RadioButton from './Forms/RadioButton';
|
|
@@ -81,7 +81,7 @@ export * from './Forms/Input';
|
|
|
81
81
|
export * from './Forms/RadioButton';
|
|
82
82
|
export * from './ThemeProvider';
|
|
83
83
|
export * from './utils';
|
|
84
|
-
export * from './
|
|
84
|
+
export * from './Forms/DatePicker';
|
|
85
85
|
export * from './Modules/CommonGrid';
|
|
86
86
|
export * from './Blocks/Popover';
|
|
87
87
|
export * from './Elements/SingleSelect';
|
package/ui/index.js
CHANGED
|
@@ -133,9 +133,9 @@ import SpaceAroundWrap from "./Elements/SpaceAround/SpaceAround.js";
|
|
|
133
133
|
import SpaceAround_default from "./Elements/SpaceAround/index.js";
|
|
134
134
|
import Select_default from "./Elements/Select/index.js";
|
|
135
135
|
import SingleSelect_default from "./Elements/SingleSelect/index.js";
|
|
136
|
-
import { DatePickerRepeat, TimePickerRepeat } from "./
|
|
136
|
+
import { DatePickerRepeat, TimePickerRepeat } from "./Forms/DatePicker/Datetime/types.js";
|
|
137
137
|
import Input_default from "./Forms/Input/index.js";
|
|
138
|
-
import DatePicker_default from "./
|
|
138
|
+
import DatePicker_default from "./Forms/DatePicker/index.js";
|
|
139
139
|
import { useEvent } from "./Modules/CommonGrid/hooks/useEvent.js";
|
|
140
140
|
import { useAddFilter } from "./Modules/CommonGrid/hooks/useAddFilter.js";
|
|
141
141
|
import { types_exports } from "./Modules/CommonGrid/types.js";
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import Input_default from "../../../../Forms/Input/index.js";
|
|
2
|
-
import { useCallback, useState } from "react";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
//#region packages/ui/Elements/DatePicker/components/DatePickerInput/DatePickerInput.tsx
|
|
5
|
-
const DatePickerInput = ({ inputProps, openCalendar, name, label, error, disabled, icon, showInputLabel, onClear, onInputChange }) => {
|
|
6
|
-
const [typedValue, setTypedValue] = useState(null);
|
|
7
|
-
const handleChange = useCallback((e) => {
|
|
8
|
-
setTypedValue(e.target.value);
|
|
9
|
-
inputProps.onChange?.(e);
|
|
10
|
-
onInputChange?.(e.target.value);
|
|
11
|
-
}, [inputProps, onInputChange]);
|
|
12
|
-
const handleBlur = useCallback(() => {
|
|
13
|
-
setTypedValue(null);
|
|
14
|
-
}, []);
|
|
15
|
-
return /* @__PURE__ */ jsx(Input_default, {
|
|
16
|
-
type: "text",
|
|
17
|
-
icon: icon ? "calendar" : void 0,
|
|
18
|
-
name,
|
|
19
|
-
error,
|
|
20
|
-
disabled,
|
|
21
|
-
isInvalid: !!error,
|
|
22
|
-
onChange: handleChange,
|
|
23
|
-
onBlur: handleBlur,
|
|
24
|
-
label: showInputLabel ? label : void 0,
|
|
25
|
-
value: typedValue ?? inputProps.value,
|
|
26
|
-
onFocus: openCalendar,
|
|
27
|
-
iconOnClick: openCalendar,
|
|
28
|
-
onClear,
|
|
29
|
-
autoComplete: "off"
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
33
|
-
export { DatePickerInput };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/ui/{Elements → Forms}/DatePicker/Datetime/components/Timepicker/utils/parseTimeField.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|