orc-shared 5.10.0-dev.2 → 5.10.0-dev.21
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/dist/actions/metadata.js +30 -11
- package/dist/actions/requestsApi.js +10 -1
- package/dist/components/AppFrame/About.js +136 -100
- package/dist/components/AppFrame/Anchor.js +45 -21
- package/dist/components/AppFrame/AppFrame.js +53 -31
- package/dist/components/AppFrame/Help.js +35 -15
- package/dist/components/AppFrame/MenuItem.js +148 -114
- package/dist/components/AppFrame/Preferences.js +136 -97
- package/dist/components/AppFrame/Sidebar.js +51 -28
- package/dist/components/AppFrame/Topbar.js +61 -36
- package/dist/components/ColumnWrapper.js +28 -5
- package/dist/components/Culture.js +33 -14
- package/dist/components/DropMenu/Menu.js +79 -45
- package/dist/components/DropMenu/index.js +34 -29
- package/dist/components/Form/Combination.js +45 -16
- package/dist/components/Form/Field.js +57 -38
- package/dist/components/Form/FieldElements.js +0 -11
- package/dist/components/Form/Fieldset.js +47 -19
- package/dist/components/Form/Form.js +22 -9
- package/dist/components/Form/FormElement.js +40 -7
- package/dist/components/Form/Inputs/Button.js +63 -18
- package/dist/components/Form/Inputs/ReadOnly.js +50 -27
- package/dist/components/{AppFrame/ApplicationSelector/Header.js → Form/Inputs/Selector.js} +30 -31
- package/dist/components/Form/Inputs/Text.js +20 -37
- package/dist/components/Form/Inputs/Toggles.js +39 -40
- package/dist/components/Form/Inputs/index.js +2 -13
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +31 -11
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +89 -0
- package/dist/components/MaterialUI/DataDisplay/Table.js +109 -18
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -1
- package/dist/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +198 -0
- package/dist/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +4 -1
- package/dist/components/MaterialUI/Inputs/DatePicker.js +14 -14
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
- package/dist/components/MaterialUI/Inputs/Select.js +2 -0
- package/dist/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/dist/components/MaterialUI/Inputs/Switch.js +17 -1
- package/dist/components/MaterialUI/Inputs/SwitchProps.js +2 -0
- package/dist/components/MaterialUI/Inputs/TimePicker.js +14 -21
- package/dist/components/MaterialUI/hocs/withDeferredTooltip.js +3 -1
- package/dist/components/MaterialUI/muiThemes.js +2 -1
- package/dist/components/Provision.js +1 -1
- package/dist/constants.js +2 -1
- package/dist/content/iconsSheet.svg +740 -116
- package/dist/hocs/withScrollBox.js +27 -12
- package/dist/hooks/useDaysAndMonthsLocalization.js +77 -0
- package/dist/hooks/useInMemoryPaging.js +135 -0
- package/dist/hooks/useMultipleFieldEditState.js +12 -3
- package/dist/reducers/metadata.js +6 -0
- package/dist/schemas/metadata.js +9 -1
- package/dist/selectors/locale.js +1 -0
- package/dist/selectors/metadata.js +14 -11
- package/dist/sharedMessages.js +184 -0
- package/dist/utils/ListHelper.js +271 -0
- package/dist/utils/comparisonHelper.js +185 -0
- package/dist/utils/propertyBagHelper.js +3 -1
- package/dist/utils/timezoneHelper.js +18 -31
- package/package.json +4 -3
- package/src/actions/metadata.js +11 -0
- package/src/actions/metadata.test.js +27 -0
- package/src/actions/requestsApi.js +6 -0
- package/src/components/AppFrame/About.js +97 -117
- package/src/components/AppFrame/About.test.js +128 -90
- package/src/components/AppFrame/Anchor.js +34 -36
- package/src/components/AppFrame/Anchor.test.js +5 -68
- package/src/components/AppFrame/AppFrame.js +31 -40
- package/src/components/AppFrame/AppFrame.test.js +424 -445
- package/src/components/AppFrame/Help.js +23 -20
- package/src/components/AppFrame/Help.test.js +3 -3
- package/src/components/AppFrame/MenuItem.js +106 -126
- package/src/components/AppFrame/MenuItem.test.js +78 -169
- package/src/components/AppFrame/Preferences.js +110 -98
- package/src/components/AppFrame/Preferences.test.js +115 -219
- package/src/components/AppFrame/Sidebar.js +39 -41
- package/src/components/AppFrame/Sidebar.test.js +88 -168
- package/src/components/AppFrame/Topbar.js +59 -52
- package/src/components/AppFrame/Topbar.test.js +31 -39
- package/src/components/ColumnWrapper.js +18 -9
- package/src/components/Culture.js +20 -10
- package/src/components/Culture.test.js +27 -16
- package/src/components/DropMenu/DropMenu.test.js +185 -224
- package/src/components/DropMenu/Menu.js +73 -80
- package/src/components/DropMenu/Menu.test.js +35 -86
- package/src/components/DropMenu/index.js +19 -15
- package/src/components/Form/Combination.js +35 -28
- package/src/components/Form/Combination.test.js +6 -19
- package/src/components/Form/Field.js +53 -66
- package/src/components/Form/Field.test.js +29 -51
- package/src/components/Form/FieldElements.js +0 -14
- package/src/components/Form/FieldElements.test.js +104 -111
- package/src/components/Form/Fieldset.js +42 -37
- package/src/components/Form/Fieldset.test.js +14 -7
- package/src/components/Form/Form.js +11 -7
- package/src/components/Form/Form.test.js +75 -56
- package/src/components/Form/FormElement.js +24 -16
- package/src/components/Form/InputField.test.js +24 -30
- package/src/components/Form/Inputs/Button.js +58 -14
- package/src/components/Form/Inputs/Button.test.js +32 -7
- package/src/components/Form/Inputs/Inputs.test.js +0 -7
- package/src/components/Form/Inputs/ReadOnly.js +34 -28
- package/src/components/Form/Inputs/ReadOnly.test.js +45 -7
- package/src/components/Form/Inputs/Selector.js +22 -0
- package/src/components/Form/Inputs/Selector.test.js +105 -0
- package/src/components/Form/Inputs/Text.js +15 -44
- package/src/components/Form/Inputs/Text.test.js +20 -29
- package/src/components/Form/Inputs/Toggles.js +27 -26
- package/src/components/Form/Inputs/Toggles.test.js +22 -28
- package/src/components/Form/Inputs/index.js +4 -15
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +1 -4
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +32 -6
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.test.js +3 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +39 -0
- package/src/components/MaterialUI/DataDisplay/Table.js +190 -114
- package/src/components/MaterialUI/DataDisplay/Table.test.js +246 -1
- package/src/components/MaterialUI/DataDisplay/TableProps.js +4 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +145 -0
- package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.test.js +457 -0
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +5 -1
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.test.js +7 -1
- package/src/components/MaterialUI/Inputs/DatePicker.js +19 -20
- package/src/components/MaterialUI/Inputs/DatePicker.test.js +11 -6
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
- package/src/components/MaterialUI/Inputs/Select.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
- package/src/components/MaterialUI/Inputs/Switch.js +22 -1
- package/src/components/MaterialUI/Inputs/Switch.test.js +23 -0
- package/src/components/MaterialUI/Inputs/SwitchProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SwitchProps.test.js +2 -0
- package/src/components/MaterialUI/Inputs/TimePicker.js +10 -19
- package/src/components/MaterialUI/Inputs/TimePicker.test.js +278 -117
- package/src/components/MaterialUI/hocs/withDeferredTooltip.js +4 -1
- package/src/components/MaterialUI/hocs/withDeferredTooltip.test.js +27 -0
- package/src/components/MaterialUI/muiThemes.js +1 -0
- package/src/components/Navigation/Bar.test.js +92 -87
- package/src/components/Provision.js +1 -1
- package/src/components/TaskDetailsModal.test.js +1 -3
- package/src/constants.js +1 -0
- package/src/content/iconsSheet.svg +740 -116
- package/src/hocs/withScrollBox.js +32 -19
- package/src/hocs/withScrollBox.test.js +15 -3
- package/src/hooks/useDaysAndMonthsLocalization.js +79 -0
- package/src/hooks/useDaysAndMonthsLocalization.test.js +107 -0
- package/src/hooks/useInMemoryPaging.js +78 -0
- package/src/hooks/useInMemoryPaging.test.js +515 -0
- package/src/hooks/useMultipleFieldEditState.js +11 -4
- package/src/hooks/useMultipleFieldEditState.test.js +49 -1
- package/src/reducers/metadata.js +6 -1
- package/src/reducers/metadata.test.js +31 -0
- package/src/requests +1 -0
- package/src/schemas/metadata.js +3 -0
- package/src/selectors/locale.js +1 -1
- package/src/selectors/metadata.js +12 -9
- package/src/selectors/metadata.test.js +92 -11
- package/src/sharedMessages.js +184 -0
- package/src/timezones.json +883 -0
- package/src/translations/en-US.json +46 -0
- package/src/translations/fr-CA.json +46 -0
- package/src/utils/ListHelper.js +203 -0
- package/src/utils/ListHelper.test.js +710 -0
- package/src/utils/comparisonHelper.js +135 -0
- package/src/utils/comparisonHelper.test.js +334 -0
- package/src/utils/propertyBagHelper.js +2 -0
- package/src/utils/propertyBagHelper.test.js +6 -0
- package/src/utils/timezoneHelper.js +10 -135
- package/src/utils/timezoneHelper.test.js +7 -7
- package/dist/components/Form/FieldList.js +0 -270
- package/dist/components/Form/Inputs/FieldButtons.js +0 -66
- package/dist/components/Form/Inputs/Number.js +0 -117
- package/dist/components/Form/Inputs/SmallButton.js +0 -91
- package/dist/components/Form/Inputs/Time.js +0 -86
- package/dist/components/Form/Inputs/Translation.js +0 -169
- package/src/components/AppFrame/ApplicationSelector/Header.js +0 -34
- package/src/components/AppFrame/ApplicationSelector/Header.test.js +0 -23
- package/src/components/Form/FieldList.js +0 -210
- package/src/components/Form/FieldList.test.js +0 -558
- package/src/components/Form/Inputs/FieldButtons.js +0 -90
- package/src/components/Form/Inputs/Number.js +0 -60
- package/src/components/Form/Inputs/Number.test.js +0 -435
- package/src/components/Form/Inputs/SmallButton.js +0 -37
- package/src/components/Form/Inputs/SmallButton.test.js +0 -65
- package/src/components/Form/Inputs/Time.js +0 -32
- package/src/components/Form/Inputs/Time.test.js +0 -41
- package/src/components/Form/Inputs/Translation.js +0 -93
- package/src/components/Form/Inputs/Translation.test.js +0 -204
|
@@ -269,7 +269,7 @@ describe("DatePicker", () => {
|
|
|
269
269
|
const expectedDate = "06/30/2020 12:00 AM";
|
|
270
270
|
expect(
|
|
271
271
|
<TestWrapper provider={{ store }} intlProvider stylesProvider muiThemeProvider={{ theme }}>
|
|
272
|
-
<DatePicker useTime={true} readOnly={true} onChange={updater} value={date} />
|
|
272
|
+
<DatePicker useTime={true} readOnly={true} onChange={updater} value={date} showTimeZone={true} />
|
|
273
273
|
</TestWrapper>,
|
|
274
274
|
"when mounted",
|
|
275
275
|
"to satisfy",
|
|
@@ -348,7 +348,7 @@ describe("DatePicker", () => {
|
|
|
348
348
|
useTime={true}
|
|
349
349
|
useDate={false}
|
|
350
350
|
showTimeSelectOnly={true}
|
|
351
|
-
|
|
351
|
+
timePickerWindowsTimeZone={requestTimeZone}
|
|
352
352
|
/>
|
|
353
353
|
</TestWrapper>
|
|
354
354
|
);
|
|
@@ -375,7 +375,7 @@ describe("DatePicker", () => {
|
|
|
375
375
|
useTime={true}
|
|
376
376
|
useDate={false}
|
|
377
377
|
showTimeSelectOnly={true}
|
|
378
|
-
|
|
378
|
+
timePickerWindowsTimeZone={null}
|
|
379
379
|
/>
|
|
380
380
|
</TestWrapper>
|
|
381
381
|
);
|
|
@@ -400,7 +400,7 @@ describe("DatePicker", () => {
|
|
|
400
400
|
useTime={true}
|
|
401
401
|
useDate={false}
|
|
402
402
|
showTimeSelectOnly={true}
|
|
403
|
-
|
|
403
|
+
timePickerWindowsTimeZone={requestTimeZone}
|
|
404
404
|
/>
|
|
405
405
|
</TestWrapper>
|
|
406
406
|
);
|
|
@@ -419,7 +419,12 @@ describe("DatePicker", () => {
|
|
|
419
419
|
const requestTimeZone = "Eastern Standard Time";
|
|
420
420
|
const component = (
|
|
421
421
|
<TestWrapper provider={{ store }} intlProvider>
|
|
422
|
-
<DatePicker
|
|
422
|
+
<DatePicker
|
|
423
|
+
value={date}
|
|
424
|
+
useDate={false}
|
|
425
|
+
showTimeSelectOnly={true}
|
|
426
|
+
timePickerWindowsTimeZone={requestTimeZone}
|
|
427
|
+
/>
|
|
423
428
|
</TestWrapper>
|
|
424
429
|
);
|
|
425
430
|
const mountedComponent = mount(component);
|
|
@@ -477,7 +482,7 @@ describe("DatePicker", () => {
|
|
|
477
482
|
useDate={false}
|
|
478
483
|
useTimeZone={true}
|
|
479
484
|
showTimeSelectOnly={true}
|
|
480
|
-
|
|
485
|
+
timePickerWindowsTimeZone={requestTimeZone}
|
|
481
486
|
/>
|
|
482
487
|
</TestWrapper>
|
|
483
488
|
);
|
|
@@ -167,6 +167,7 @@ const Select = ({ options, selectProps, children }) => {
|
|
|
167
167
|
const disabled = selectProps?.get(SelectProps.propNames.disabled) || false;
|
|
168
168
|
const error = selectProps?.get(SelectProps.propNames.error);
|
|
169
169
|
const native = selectProps?.get(SelectProps.propNames.native);
|
|
170
|
+
const onClose = selectProps?.get(SelectProps.propNames.onClose);
|
|
170
171
|
const inputProps = selectProps?.get(SelectProps.propNames.inputProps);
|
|
171
172
|
const hasError = !!error;
|
|
172
173
|
|
|
@@ -243,6 +244,7 @@ const Select = ({ options, selectProps, children }) => {
|
|
|
243
244
|
<SelectMUI
|
|
244
245
|
value={value}
|
|
245
246
|
onChange={handleChange}
|
|
247
|
+
onClose={onClose}
|
|
246
248
|
disableUnderline={true}
|
|
247
249
|
IconComponent={SelectIcon}
|
|
248
250
|
MenuProps={defaultMenuProps}
|
|
@@ -18,6 +18,7 @@ class SelectProps extends ComponentProps {
|
|
|
18
18
|
iconSelect: "iconSelect",
|
|
19
19
|
disabled: "disabled",
|
|
20
20
|
error: "error",
|
|
21
|
+
onClose: "onClose",
|
|
21
22
|
native: "native",
|
|
22
23
|
inputProps: "inputProps",
|
|
23
24
|
};
|
|
@@ -38,6 +39,7 @@ class SelectProps extends ComponentProps {
|
|
|
38
39
|
this.componentProps.set(this.constructor.propNames.iconSelect, null);
|
|
39
40
|
this.componentProps.set(this.constructor.propNames.disabled, null);
|
|
40
41
|
this.componentProps.set(this.constructor.propNames.error, null);
|
|
42
|
+
this.componentProps.set(this.constructor.propNames.onClose, null);
|
|
41
43
|
this.componentProps.set(this.constructor.propNames.native, null);
|
|
42
44
|
this.componentProps.set(this.constructor.propNames.inputProps, null);
|
|
43
45
|
|
|
@@ -12,6 +12,7 @@ describe("Select Props", () => {
|
|
|
12
12
|
"iconSelect",
|
|
13
13
|
"disabled",
|
|
14
14
|
"error",
|
|
15
|
+
"onClose",
|
|
15
16
|
"native",
|
|
16
17
|
"inputProps",
|
|
17
18
|
];
|
|
@@ -30,6 +31,7 @@ describe("Select Props", () => {
|
|
|
30
31
|
"iconSelect",
|
|
31
32
|
"disabled",
|
|
32
33
|
"error",
|
|
34
|
+
"onClose",
|
|
33
35
|
"native",
|
|
34
36
|
"inputProps",
|
|
35
37
|
];
|
|
@@ -87,6 +87,16 @@ export const useStyles = makeStyles(theme => ({
|
|
|
87
87
|
backgroundColor: `${theme.palette.grey.borders} !important`,
|
|
88
88
|
},
|
|
89
89
|
},
|
|
90
|
+
container: {
|
|
91
|
+
display: "flex",
|
|
92
|
+
flexDirection: "column",
|
|
93
|
+
},
|
|
94
|
+
errorText: {
|
|
95
|
+
marginTop: theme.spacing(0.5),
|
|
96
|
+
color: theme.palette.error.main,
|
|
97
|
+
fontSize: theme.typography.fieldLabelSize,
|
|
98
|
+
float: "left",
|
|
99
|
+
},
|
|
90
100
|
}));
|
|
91
101
|
|
|
92
102
|
const Switch = ({ switchProps }) => {
|
|
@@ -100,6 +110,7 @@ const Switch = ({ switchProps }) => {
|
|
|
100
110
|
const value = switchProps?.get(SwitchProps.propNames.value) || false;
|
|
101
111
|
const onCaption = switchProps?.get(SwitchProps.propNames.onCaption);
|
|
102
112
|
const offCaption = switchProps?.get(SwitchProps.propNames.offCaption);
|
|
113
|
+
const error = switchProps?.get(SwitchProps.propNames.error);
|
|
103
114
|
const disabled = switchProps?.get(SwitchProps.propNames.disabled) || false;
|
|
104
115
|
const readOnly = switchProps?.get(SwitchProps.propNames.readOnly);
|
|
105
116
|
const className = switchProps?.get(SwitchProps.propNames.className) || "";
|
|
@@ -120,7 +131,7 @@ const Switch = ({ switchProps }) => {
|
|
|
120
131
|
...className,
|
|
121
132
|
};
|
|
122
133
|
|
|
123
|
-
|
|
134
|
+
const switchComponent = (
|
|
124
135
|
<SwitchMui
|
|
125
136
|
disabled={disabled}
|
|
126
137
|
classes={switchClasses}
|
|
@@ -129,6 +140,16 @@ const Switch = ({ switchProps }) => {
|
|
|
129
140
|
color={"primary"}
|
|
130
141
|
/>
|
|
131
142
|
);
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
(error && (
|
|
146
|
+
<div className={classes.container}>
|
|
147
|
+
{switchComponent}
|
|
148
|
+
<div className={classNames(classes.errorText)}>{error}</div>
|
|
149
|
+
</div>
|
|
150
|
+
)) ||
|
|
151
|
+
switchComponent
|
|
152
|
+
);
|
|
132
153
|
};
|
|
133
154
|
|
|
134
155
|
export default Switch;
|
|
@@ -60,6 +60,29 @@ describe("Switch Component", () => {
|
|
|
60
60
|
expect(mountedComponent.containsMatchingElement(expected), "to be truthy");
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
it("Renders Switch component with an error", () => {
|
|
64
|
+
const switchProps = new SwitchProps();
|
|
65
|
+
|
|
66
|
+
switchProps.set(SwitchProps.propNames.update, update);
|
|
67
|
+
switchProps.set(SwitchProps.propNames.value, true);
|
|
68
|
+
switchProps.set(SwitchProps.propNames.error, "an error");
|
|
69
|
+
switchProps.set(SwitchProps.propNames.onCaption, { id: "captionOn" });
|
|
70
|
+
switchProps.set(SwitchProps.propNames.offCaption, { id: "captionOff" });
|
|
71
|
+
|
|
72
|
+
const component = (
|
|
73
|
+
<IntlProvider messages={messages} locale="en-US">
|
|
74
|
+
<Switch switchProps={switchProps} />
|
|
75
|
+
</IntlProvider>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const mountedComponent = mount(component);
|
|
79
|
+
const expectedSwitch = <SwitchMUI checked={true} />;
|
|
80
|
+
const expectedError = <div>an error</div>;
|
|
81
|
+
|
|
82
|
+
expect(mountedComponent.containsMatchingElement(expectedSwitch), "to be truthy");
|
|
83
|
+
expect(mountedComponent.containsMatchingElement(expectedError), "to be truthy");
|
|
84
|
+
});
|
|
85
|
+
|
|
63
86
|
it("Checkbox component handles check", () => {
|
|
64
87
|
const switchProps = new SwitchProps();
|
|
65
88
|
|
|
@@ -10,6 +10,7 @@ class SwitchProps extends ComponentProps {
|
|
|
10
10
|
readOnly: "readOnly",
|
|
11
11
|
className: "className",
|
|
12
12
|
id: "id",
|
|
13
|
+
error: "error",
|
|
13
14
|
metadata: "metadata",
|
|
14
15
|
};
|
|
15
16
|
|
|
@@ -23,6 +24,7 @@ class SwitchProps extends ComponentProps {
|
|
|
23
24
|
this.componentProps.set(this.constructor.propNames.readOnly, null);
|
|
24
25
|
this.componentProps.set(this.constructor.propNames.className, null);
|
|
25
26
|
this.componentProps.set(this.constructor.propNames.id, null);
|
|
27
|
+
this.componentProps.set(this.constructor.propNames.error, null);
|
|
26
28
|
this.componentProps.set(this.constructor.propNames.metadata, null);
|
|
27
29
|
|
|
28
30
|
this._isSwitchProps = true;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { useState, useEffect } from "react";
|
|
2
|
+
import { useIntl } from "react-intl";
|
|
2
3
|
import { makeStyles } from "@material-ui/core/styles";
|
|
3
4
|
import Select from "./Select";
|
|
4
5
|
import SelectProps from "./SelectProps";
|
|
5
|
-
import {
|
|
6
|
+
import { getWindowsTimeZone } from "../../../utils/timezoneHelper";
|
|
6
7
|
import { namedLookupLocalizedSelector } from "../../../selectors/metadata";
|
|
7
8
|
import { useSelector } from "react-redux";
|
|
8
9
|
|
|
@@ -65,8 +66,8 @@ const ampmOptions = [
|
|
|
65
66
|
{ value: "PM", label: "PM" },
|
|
66
67
|
];
|
|
67
68
|
|
|
68
|
-
const isBrowserUsingAMPM =
|
|
69
|
-
!!new Date(Date.UTC(2020, 7, 30, 3, 0, 0)).toLocaleTimeString().match(/am|a.m|pm|p.m/i);
|
|
69
|
+
const isBrowserUsingAMPM = locale =>
|
|
70
|
+
!!new Date(Date.UTC(2020, 7, 30, 3, 0, 0)).toLocaleTimeString(locale).match(/am|a.m|pm|p.m/i);
|
|
70
71
|
|
|
71
72
|
export const parseTime = timeStr => {
|
|
72
73
|
var time = timeStr.match(/(\d+)(?::(\d\d))?\s*(p?)/i);
|
|
@@ -184,17 +185,18 @@ export const MinsSelect = ({ updateTimeOptions, time, values = minOptions }) =>
|
|
|
184
185
|
);
|
|
185
186
|
};
|
|
186
187
|
|
|
187
|
-
const TimePicker = ({ value, onChange, showTimeZone,
|
|
188
|
+
const TimePicker = ({ value, onChange, showTimeZone, windowsTimeZone, timeOption }) => {
|
|
188
189
|
const classes = useStyles();
|
|
189
|
-
|
|
190
|
+
const { locale } = useIntl();
|
|
191
|
+
const showAMPM = isBrowserUsingAMPM(locale);
|
|
190
192
|
const [time, setTime] = useState(parseTime(value || "00:00"));
|
|
191
193
|
|
|
192
194
|
useEffect(() => {
|
|
193
195
|
setTime(parseTime(value || "00:00"));
|
|
194
196
|
}, [value, setTime]);
|
|
195
197
|
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
+
const timeZone = windowsTimeZone ?? getWindowsTimeZone();
|
|
199
|
+
const localizedTimeZone = useSelector(namedLookupLocalizedSelector("customer", "TimeZone", timeZone));
|
|
198
200
|
|
|
199
201
|
const onTimeChange = datetime => {
|
|
200
202
|
if (onChange) {
|
|
@@ -227,15 +229,6 @@ const TimePicker = ({ value, onChange, showTimeZone, showAMPM, requestedTimeZone
|
|
|
227
229
|
onTimeChange(time);
|
|
228
230
|
};
|
|
229
231
|
|
|
230
|
-
const getTimeZone = requestedTimeZone => {
|
|
231
|
-
if (requestedTimeZone) return requestedTimeZone;
|
|
232
|
-
if (!localizedTimeZoneName) {
|
|
233
|
-
var timezone = new Date().toString().match(/GMT(\S+) \(([^)]+)\)/i);
|
|
234
|
-
return `${timezone[2]} (GMT${timezone[1]})`;
|
|
235
|
-
}
|
|
236
|
-
return localizedTimeZoneName;
|
|
237
|
-
};
|
|
238
|
-
|
|
239
232
|
return (
|
|
240
233
|
<div className={classes.timeWrapper}>
|
|
241
234
|
<span className={classes.timePickerWrapper}>
|
|
@@ -244,9 +237,7 @@ const TimePicker = ({ value, onChange, showTimeZone, showAMPM, requestedTimeZone
|
|
|
244
237
|
<MinsSelect updateTimeOptions={updateTimeOptions} time={time} values={timeOption?.minutes} />
|
|
245
238
|
<AMPMSelect showAMPM={showAMPM} updateTimeOptions={updateTimeOptions} time={time} />
|
|
246
239
|
</span>
|
|
247
|
-
{showTimeZone &&
|
|
248
|
-
<label className={classes.timeZoneWrapper}>{showTimeZone && getTimeZone(requestedTimeZone)}</label>
|
|
249
|
-
)}
|
|
240
|
+
{showTimeZone && <label className={classes.timeZoneWrapper}>{localizedTimeZone}</label>}
|
|
250
241
|
</div>
|
|
251
242
|
);
|
|
252
243
|
};
|