@hazelcast/ui 1.3.2-next.23 → 1.3.2-next.24
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.
|
@@ -4,6 +4,7 @@ import { Button } from '../../Button';
|
|
|
4
4
|
import { timePoints } from '../helpers/consts';
|
|
5
5
|
import { TimeField } from '../../TimeField';
|
|
6
6
|
import styles from './CalendarTime.module.scss';
|
|
7
|
+
import { useRefValue } from '../../hooks';
|
|
7
8
|
// Note: AM/PM 1-12 hours time
|
|
8
9
|
const DATE_FORMAT = 'hh:mm a';
|
|
9
10
|
// Note: 0-23 hours time
|
|
@@ -11,6 +12,7 @@ const DATE_FORMAT_NO_MERIDIEM = 'HH:mm';
|
|
|
11
12
|
export const CalendarTimeInternal = ({ date, value, onChange }) => {
|
|
12
13
|
const [time, setTime] = useState(value);
|
|
13
14
|
const [timeInputError, setTimeInputError] = useState();
|
|
15
|
+
const getValue = useRefValue(value);
|
|
14
16
|
/*
|
|
15
17
|
* Note:
|
|
16
18
|
* We cannot override how react-datepicker handles time values.
|
|
@@ -22,7 +24,7 @@ export const CalendarTimeInternal = ({ date, value, onChange }) => {
|
|
|
22
24
|
* Furthermore, the package even does not handle potential thrown error by date-fns' parse.
|
|
23
25
|
* Even the live demos do crash on an input like "10:10q" (See source 1. link below).
|
|
24
26
|
*
|
|
25
|
-
* For
|
|
27
|
+
* For these reasons we need to provide our own wrapper around the functionality to achieve 2 things:
|
|
26
28
|
* - Provide IE11 with a proper fallback
|
|
27
29
|
* - Prevent the invalid input value crash
|
|
28
30
|
* - Provide the user with an input error in case the value is invalid
|
|
@@ -50,11 +52,17 @@ export const CalendarTimeInternal = ({ date, value, onChange }) => {
|
|
|
50
52
|
// Note: Output time, that we feed back to 'react-datetime' is in 'DATE_FORMAT_NO_MERIDIEM' format
|
|
51
53
|
const timeStringWithoutAm = format(parsedDate, DATE_FORMAT_NO_MERIDIEM);
|
|
52
54
|
onChange(timeStringWithoutAm);
|
|
53
|
-
|
|
55
|
+
// remove error because time from the list can not be invalid
|
|
56
|
+
setTimeInputError(undefined);
|
|
57
|
+
// restores input field value when we select the same time from the list
|
|
58
|
+
if (getValue() === timeStringWithoutAm) {
|
|
59
|
+
setTime(timeStringWithoutAm);
|
|
60
|
+
}
|
|
61
|
+
}, [onChange, getValue, date]);
|
|
54
62
|
return (React.createElement("div", { "data-test": "calendar-time", className: styles.container },
|
|
55
63
|
React.createElement("div", { "data-test": "calendar-time-header", className: styles.header },
|
|
56
64
|
React.createElement(TimeField, { showAriaLabel: true, label: "Time Input", error: timeInputError, name: "time", value: time.toString(), onChange: handleTimeInputChange })),
|
|
57
|
-
React.createElement("div", { "data-test": "calendar-time-timePoints", className: styles.timePoints }, timePoints.map((tP) => (React.createElement(Button, { className: styles.timePoint, bodyClassName: styles.timePointBody, key: tP,
|
|
65
|
+
React.createElement("div", { "data-test": "calendar-time-timePoints", className: styles.timePoints }, timePoints.map((tP) => (React.createElement(Button, { className: styles.timePoint, bodyClassName: styles.timePointBody, key: tP, variant: "text", onClick: handleDateClick(tP) }, tP))))));
|
|
58
66
|
};
|
|
59
67
|
export const CalendarTime = (props) => {
|
|
60
68
|
// Note: Cast the "unknown" props to the actual type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarTime.js","sourceRoot":"","sources":["../../../src/Calendar/components/CalendarTime.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAmB,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,MAAM,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":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AAM,IAAC,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,eAAe,CAAC,EAAE,CAAC,IAC3H,EAAE,CACI,CACV,CAAC,CACE,CACF,CACP,CAAA;AACH,CAAC,CAAA;AAUD,MAAM,CAAC,MAAM,YAAY,GAA0B,CAAC,KAAK,EAAE,EAAE;IAC3D,oDAAoD;IACpD,MAAM,UAAU,GAAG,KAAkC,CAAA;IAErD,OAAO,oBAAC,oBAAoB,OAAK,UAAU,GAAI,CAAA;AACjD,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hazelcast/ui",
|
|
3
|
-
"version": "1.3.2-next.
|
|
3
|
+
"version": "1.3.2-next.24+5dd3dec",
|
|
4
4
|
"description": "Hazelcast design system components",
|
|
5
5
|
"author": "",
|
|
6
6
|
"homepage": "https://github.com/hazelcast/frontend-shared#readme",
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"webpack": "^5.65.0",
|
|
110
110
|
"yup": "^0.32.11"
|
|
111
111
|
},
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "5dd3dec76869d90c8a812d0e166a6f7af0e84e23"
|
|
113
113
|
}
|