@pega/custom-dx-components 0.0.1 → 0.23.1
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/.vscode/extensions.json +1 -1
- package/README.md +6 -189
- package/package.json +34 -32
- package/src/auth.js +608 -0
- package/src/cli.js +42 -0
- package/src/constants.js +122 -8
- package/src/tasks/authenticate/helper.js +91 -8
- package/src/tasks/authenticate/index.js +169 -49
- package/src/tasks/build/helper.js +122 -0
- package/src/tasks/build/index.js +54 -0
- package/src/tasks/build-all/helper.js +70 -0
- package/src/tasks/build-all/index.js +79 -0
- package/src/tasks/{publish/bundle → bundle}/builder/index.js +49 -5
- package/src/tasks/{publish/bundle → bundle}/builder/webpack.config.js +5 -3
- package/src/tasks/{publish/bundle → bundle}/index.js +2 -2
- package/src/tasks/create/index.js +87 -64
- package/src/tasks/create/templates/Constellation/Field/Boolean/Boolean.js.mustache +38 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/boolean-format.js.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/config.json.mustache +145 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/demo.stories.jsx.mustache +61 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/index.jsx.mustache +170 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Boolean/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +61 -0
- package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +41 -0
- package/src/tasks/create/templates/Constellation/Field/Date/config.json.mustache +195 -0
- package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +439 -0
- package/src/tasks/create/templates/Constellation/Field/Date/demo.stories.jsx.mustache +73 -0
- package/src/tasks/create/templates/Constellation/Field/Date/index.jsx.mustache +256 -0
- package/src/tasks/create/templates/Constellation/Field/Date/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Date/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Date/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/config.json.mustache +256 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +92 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js.mustache +287 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +328 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/demo.stories.jsx.mustache +73 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/index.jsx.mustache +254 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/DateTime/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/config.json.mustache +278 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/demo.stories.jsx.mustache +49 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/index.jsx.mustache +273 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/config.json.mustache +291 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/demo.stories.jsx.mustache +53 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/index.jsx.mustache +299 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Currency/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/config.json.mustache +93 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/demo.stories.jsx.mustache +49 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/index.jsx.mustache +281 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Decimal-Percentage/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/config.json.mustache +347 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/demo.stories.jsx.mustache +49 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/index.jsx.mustache +336 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Integer/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/config.json.mustache +114 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/demo.stories.jsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/index.jsx.mustache +351 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/mock.stories.js.mustache +67 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Picklist/suggestions-handler.js +10 -0
- package/src/tasks/create/{template → templates/Constellation/Field/Text}/config.json.mustache +14 -5
- package/src/tasks/create/templates/Constellation/Field/Text/demo.stories.jsx.mustache +51 -0
- package/src/tasks/create/{template → templates/Constellation/Field/Text}/index.jsx.mustache +5 -0
- package/src/tasks/create/templates/Constellation/Field/Text/mock.stories.js.mustache +13 -0
- package/src/tasks/create/templates/Constellation/Field/Text/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/config.json.mustache +111 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/demo.stories.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/index.jsx.mustache +231 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Email/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/StatusWork.jsx +26 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/config.json.mustache +111 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/demo.stories.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/index.jsx.mustache +239 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/mock.stories.js.mustache +21 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Input/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/config.json.mustache +111 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/demo.stories.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/index.jsx.mustache +231 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Paragraph/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/config.json.mustache +123 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/demo.stories.jsx.mustache +46 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/index.jsx.mustache +267 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/mock.stories.js.mustache +37 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-Phone/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/config.json.mustache +237 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/demo.stories.jsx.mustache +46 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/event-utils.js.mustache +18 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/index.jsx.mustache +232 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/mock.stories.js.mustache +22 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.jsx.mustache +173 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/config.json.mustache +185 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/demo.stories.jsx.mustache +57 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/index.jsx.mustache +213 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/mock.stories.js.mustache +20 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/suggestions-handler.js +10 -0
- package/src/tasks/create/templates/Constellation/Field/TimeOfDay/time-of-day.js.mustache +287 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/OneColumnDetails.svg +22 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/config.json.mustache +35 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.jsx.mustache +132 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.jsx.mustache +86 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.stories.js.mustache +189 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +152 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/StatusWork.jsx.mustache +26 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/TwoColumnDetails.svg +28 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/config.json.mustache +42 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.jsx.mustache +136 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.jsx.mustache +86 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.stories.js.mustache +230 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +155 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/DefaultForm.svg +29 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/config.json.mustache +45 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/demo.stories.jsx.mustache +169 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/index.jsx.mustache +45 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/mock.stories.js.mustache +137 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/TwoColumn.svg +38 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/config.json.mustache +27 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/demo.stories.jsx.mustache +178 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/mock.stories.js.mustache +143 -0
- package/src/tasks/create/templates/Constellation/Template/FORM-region/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/GetNextWork.jsx.mustache +35 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/OneColumnPage.svg +36 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/config.json.mustache +32 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/demo.stories.jsx.mustache +102 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/index.jsx.mustache +70 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/localizations.json.mustache +4 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/mock.stories.js.mustache +94 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +229 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/OneColumnPage.svg +36 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/config.json.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/demo.stories.jsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/index.jsx.mustache +76 -0
- package/src/tasks/create/templates/Constellation/Widget/CASE/mock.stories.js.mustache +390 -0
- package/src/tasks/create/{template → templates/Constellation/Widget/CASE}/styles.js.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Widget/PAGE/OneColumnPage.svg +36 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/config.json.mustache +59 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/demo.stories.jsx.mustache +30 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/index.jsx.mustache +48 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/mock.stories.js.mustache +23 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE/styles.js.mustache +7 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Avatar.jsx.mustache +75 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/OneColumnPage.svg +36 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Operator.jsx.mustache +240 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/config.json.mustache +66 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/demo.stories.jsx.mustache +68 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/index.jsx.mustache +110 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/mock.stories.js.mustache +51 -0
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/styles.js.mustache +7 -0
- package/src/tasks/create-all/index.js +398 -0
- package/src/tasks/delete/helper.js +6 -4
- package/src/tasks/delete/index.js +4 -0
- package/src/tasks/delete-all/helper.js +153 -0
- package/src/tasks/delete-all/index.js +49 -0
- package/src/tasks/generate-ai/aiPrompt.txt.mustache +121 -0
- package/src/tasks/generate-ai/helper.js +184 -0
- package/src/tasks/generate-ai/index.js +33 -0
- package/src/tasks/index.js +7 -0
- package/src/tasks/init/index.js +9 -3
- package/src/tasks/init/template/.eslintignore +8 -0
- package/src/tasks/init/template/.eslintrc.json +186 -5
- package/src/tasks/init/template/.vscode/extensions.json +1 -1
- package/src/tasks/init/template/README.md +80 -61
- package/src/tasks/init/template/keys/DX-ComponentDev.zip +0 -0
- package/src/tasks/init/template/keys/dxcb.crt +32 -0
- package/src/tasks/init/template/keys/dxcb.key +51 -0
- package/src/tasks/init/template/package.json.mustache +44 -21
- package/src/tasks/init/template/tasks.config.json +19 -5
- package/src/tasks/init/template/templateNPMRC.txt +8 -0
- package/src/tasks/linter/index.js +46 -0
- package/src/tasks/list/helper.js +19 -6
- package/src/tasks/list/index.js +4 -0
- package/src/tasks/publish/helper.js +13 -4
- package/src/tasks/publish/index.js +14 -1
- package/src/tasks/publish-all/helper.js +154 -0
- package/src/tasks/publish-all/index.js +95 -0
- package/src/tasks/rename/index.js +314 -0
- package/src/tasks/validator/index.js +291 -18
- package/src/util.js +247 -6
- package/src/tasks/create/template/demo.stories.jsx.mustache +0 -44
- package/src/tasks/init/template/src/components/MBTAList/MBTAList.stories.tsx +0 -10
- package/src/tasks/init/template/src/components/MBTAList/MBTAList.tsx +0 -122
- package/src/tasks/init/template/src/components/MBTAList/icons/accessible.icon.tsx +0 -14
- package/src/tasks/init/template/src/components/MBTAList/icons/bus.icon.tsx +0 -13
- package/src/tasks/init/template/src/components/MBTAList/icons/mbta.icon.tsx +0 -10
- package/src/tasks/init/template/src/components/MBTAList/icons/subway.icon.tsx +0 -14
- package/src/tasks/init/template/src/components/MBTAList/index.ts +0 -2
- /package/src/tasks/{publish/bundle → bundle}/builder/modules.js +0 -0
- /package/src/tasks/{publish/bundle → bundle}/builder/paths.js +0 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { DateInput, FieldValueList, DateTimeDisplay, Text, } from '@pega/cosmos-react-core';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import FormattedText from "./FormattedText.jsx";
|
|
6
|
+
|
|
7
|
+
import Styled{{COMPONENT_CLASS_NAME}}Wrapper from './styles';
|
|
8
|
+
|
|
9
|
+
// includes in bundle
|
|
10
|
+
import {
|
|
11
|
+
datetimedisplayformatter,
|
|
12
|
+
formatExists,
|
|
13
|
+
getFullYear,
|
|
14
|
+
getMaxDate,
|
|
15
|
+
getMinDate,
|
|
16
|
+
datetimeFireChangeBlurEvents,
|
|
17
|
+
getDateFormat
|
|
18
|
+
} from "./date.js";
|
|
19
|
+
import { suggestionsHandler } from './suggestions-handler';
|
|
20
|
+
|
|
21
|
+
// Duplicated runtime code from Constellation Design System Component
|
|
22
|
+
|
|
23
|
+
// props passed in combination of props from property panel (config.json) and run time props from Constellation
|
|
24
|
+
// any default values in config.pros should be set in defaultProps at bottom of this file
|
|
25
|
+
const {{COMPONENT_CLASS_NAME}} = props => {
|
|
26
|
+
const {
|
|
27
|
+
getPConnect,
|
|
28
|
+
value,
|
|
29
|
+
validatemessage,
|
|
30
|
+
label,
|
|
31
|
+
hideLabel,
|
|
32
|
+
helperText,
|
|
33
|
+
nextYearRange,
|
|
34
|
+
previousYearRange,
|
|
35
|
+
showWeekNumber,
|
|
36
|
+
testId,
|
|
37
|
+
showAsFormattedText,
|
|
38
|
+
additionalProps,
|
|
39
|
+
displayMode,
|
|
40
|
+
variant,
|
|
41
|
+
hasSuggestions
|
|
42
|
+
} = props;
|
|
43
|
+
|
|
44
|
+
let {formatter} = props;
|
|
45
|
+
const pConn = getPConnect();
|
|
46
|
+
const actions = pConn.getActionsApi();
|
|
47
|
+
const propName = pConn?.getStateProps()?.value;
|
|
48
|
+
|
|
49
|
+
let { readOnly, required, disabled } = props;
|
|
50
|
+
[readOnly, required, disabled] = [readOnly, required, disabled].map(
|
|
51
|
+
(prop) => prop === true || (typeof prop === "string" && prop === "true")
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const [status, setStatus] = useState(hasSuggestions ? 'pending' : '');
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (validatemessage !== '') {
|
|
58
|
+
setStatus('error');
|
|
59
|
+
}
|
|
60
|
+
if (hasSuggestions) {
|
|
61
|
+
setStatus('pending');
|
|
62
|
+
} else if (!hasSuggestions && status !== 'success') {
|
|
63
|
+
setStatus(validatemessage !== '' ? 'error' : undefined);
|
|
64
|
+
}
|
|
65
|
+
}, [validatemessage, hasSuggestions]);
|
|
66
|
+
|
|
67
|
+
// calculate min and max range of calendar
|
|
68
|
+
const currentYear = getFullYear();
|
|
69
|
+
const yearFromValue = getFullYear(value);
|
|
70
|
+
const maxDate = getMaxDate(
|
|
71
|
+
parseInt(nextYearRange, 10),
|
|
72
|
+
currentYear,
|
|
73
|
+
yearFromValue
|
|
74
|
+
);
|
|
75
|
+
const minDate = getMinDate(
|
|
76
|
+
parseInt(previousYearRange, 10),
|
|
77
|
+
currentYear,
|
|
78
|
+
yearFromValue
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const onResolveSuggestionHandler = (accepted) => {
|
|
82
|
+
suggestionsHandler(accepted, pConn, setStatus);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
function handleBlur(onBlurValue) {
|
|
88
|
+
const { valueAsISOString: date, state: errorState } = onBlurValue;
|
|
89
|
+
const trimmedDate = date ? date.substring(0, date.indexOf('T')) : date;
|
|
90
|
+
datetimeFireChangeBlurEvents(errorState, value, trimmedDate, actions, propName, pConn);
|
|
91
|
+
const isValueChanged = !(value === undefined && trimmedDate === '') && value !== trimmedDate;
|
|
92
|
+
if (hasSuggestions && isValueChanged) {
|
|
93
|
+
pConn.ignoreSuggestion();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function handleChange(onChangeValue) {
|
|
98
|
+
const { valueAsISOString: date } = onChangeValue;
|
|
99
|
+
const trimmedDate = date ? date.substring(0, date.indexOf('T')) : date;
|
|
100
|
+
if (hasSuggestions && value !== trimmedDate) {
|
|
101
|
+
setStatus(undefined);
|
|
102
|
+
}
|
|
103
|
+
pConn.clearErrorMessages({
|
|
104
|
+
property: propName
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (displayMode === 'LABELS_LEFT' || displayMode === 'STACKED_LARGE_VAL' || displayMode === 'DISPLAY_ONLY') {
|
|
109
|
+
let variantValue = "date";
|
|
110
|
+
let formatValue = "long";
|
|
111
|
+
if(pConn && pConn.getConfigProps()){
|
|
112
|
+
const runtimeformatter = pConn.getConfigProps()?.formatter;
|
|
113
|
+
if(formatter !== runtimeformatter){
|
|
114
|
+
formatter = runtimeformatter;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if(formatter !== "" && formatExists(formatter)){
|
|
118
|
+
const {variantVal,formatVal} = datetimedisplayformatter(formatter);
|
|
119
|
+
variantValue = variantVal;
|
|
120
|
+
formatValue = formatVal;
|
|
121
|
+
}
|
|
122
|
+
const displayComp = (
|
|
123
|
+
<DateTimeDisplay
|
|
124
|
+
variant={variantValue}
|
|
125
|
+
format={formatValue}
|
|
126
|
+
value={value}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
switch(displayMode){
|
|
130
|
+
case 'DISPLAY_ONLY': {
|
|
131
|
+
return ( <Styled{{COMPONENT_CLASS_NAME}}Wrapper> displayComp </Styled{{COMPONENT_CLASS_NAME}}Wrapper>);
|
|
132
|
+
}
|
|
133
|
+
case "LABELS_LEFT" : {
|
|
134
|
+
return (
|
|
135
|
+
<Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
136
|
+
<FieldValueList
|
|
137
|
+
variant={hideLabel ? "stacked" : variant}
|
|
138
|
+
data-testid={testId}
|
|
139
|
+
fields={[{ id: '1', name: hideLabel ? "" :label, value: displayComp }]}
|
|
140
|
+
/>
|
|
141
|
+
</Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
142
|
+
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
case "STACKED_LARGE_VAL" : {
|
|
146
|
+
return (
|
|
147
|
+
<Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
148
|
+
<FieldValueList
|
|
149
|
+
variant='stacked'
|
|
150
|
+
data-testid={testId}
|
|
151
|
+
fields={[{ id: '2', name: hideLabel ? "" :label, value: <Text variant='h1' as='span'>{displayComp}</Text> }]}
|
|
152
|
+
/>
|
|
153
|
+
</Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
154
|
+
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
// no default
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
let dateComponent;
|
|
163
|
+
|
|
164
|
+
if (readOnly && showAsFormattedText) {
|
|
165
|
+
const environmentInfo = PCore.getEnvironmentInfo();
|
|
166
|
+
const locale = environmentInfo && environmentInfo.getLocale();
|
|
167
|
+
const textAdditionalProps = {
|
|
168
|
+
format: getDateFormat(locale),
|
|
169
|
+
fieldType: 'Date'
|
|
170
|
+
};
|
|
171
|
+
dateComponent = (
|
|
172
|
+
<Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
173
|
+
<FormattedText
|
|
174
|
+
formatType='date'
|
|
175
|
+
value={value}
|
|
176
|
+
label={label}
|
|
177
|
+
hideLabel={hideLabel}
|
|
178
|
+
testId={testId}
|
|
179
|
+
additionalProps={textAdditionalProps}
|
|
180
|
+
customFormat={getDateFormat(locale)}
|
|
181
|
+
/>
|
|
182
|
+
</Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
183
|
+
);
|
|
184
|
+
} else {
|
|
185
|
+
dateComponent = (
|
|
186
|
+
<Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
187
|
+
<DateInput
|
|
188
|
+
{...additionalProps}
|
|
189
|
+
label={label}
|
|
190
|
+
labelHidden={hideLabel}
|
|
191
|
+
info={validatemessage || helperText}
|
|
192
|
+
status={status}
|
|
193
|
+
value={value || undefined}
|
|
194
|
+
disabled={disabled}
|
|
195
|
+
readOnly={readOnly}
|
|
196
|
+
required={required}
|
|
197
|
+
showWeekNumber={showWeekNumber}
|
|
198
|
+
min={minDate}
|
|
199
|
+
max={maxDate}
|
|
200
|
+
data-testid={testId}
|
|
201
|
+
onFocus={actions.onFocus}
|
|
202
|
+
onChange={handleChange}
|
|
203
|
+
onBlur={handleBlur}
|
|
204
|
+
onResolveSuggestion={onResolveSuggestionHandler}
|
|
205
|
+
/>
|
|
206
|
+
</Styled{{COMPONENT_CLASS_NAME}}Wrapper>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
return dateComponent;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
{{COMPONENT_CLASS_NAME}}.defaultProps = {
|
|
215
|
+
value: undefined,
|
|
216
|
+
validatemessage: "",
|
|
217
|
+
helperText: "",
|
|
218
|
+
hideLabel: false,
|
|
219
|
+
disabled: false,
|
|
220
|
+
readOnly: false,
|
|
221
|
+
required: false,
|
|
222
|
+
showWeekNumber: false,
|
|
223
|
+
nextYearRange: "",
|
|
224
|
+
previousYearRange: "",
|
|
225
|
+
testId: null,
|
|
226
|
+
showAsFormattedText: false,
|
|
227
|
+
additionalProps: {},
|
|
228
|
+
displayMode: null,
|
|
229
|
+
variant: "inline",
|
|
230
|
+
formatter: "defaultDate",
|
|
231
|
+
hasSuggestions: false
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
{{COMPONENT_CLASS_NAME}}.propTypes = {
|
|
235
|
+
value: PropTypes.string,
|
|
236
|
+
label: PropTypes.string.isRequired,
|
|
237
|
+
hideLabel: PropTypes.bool,
|
|
238
|
+
getPConnect: PropTypes.func.isRequired,
|
|
239
|
+
validatemessage: PropTypes.string,
|
|
240
|
+
helperText: PropTypes.string,
|
|
241
|
+
disabled: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
242
|
+
readOnly: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
243
|
+
required: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
244
|
+
showWeekNumber: PropTypes.bool,
|
|
245
|
+
nextYearRange: PropTypes.string,
|
|
246
|
+
previousYearRange: PropTypes.string,
|
|
247
|
+
testId: PropTypes.string,
|
|
248
|
+
showAsFormattedText: PropTypes.bool,
|
|
249
|
+
additionalProps: PropTypes.objectOf(PropTypes.any),
|
|
250
|
+
displayMode: PropTypes.string,
|
|
251
|
+
variant: PropTypes.string,
|
|
252
|
+
formatter: PropTypes.string,
|
|
253
|
+
hasSuggestions: PropTypes.bool
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
export default {{COMPONENT_CLASS_NAME}};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const configProps = {
|
|
2
|
+
value: '2023-01-31T12:23:00.000Z',
|
|
3
|
+
validatemessage: '',
|
|
4
|
+
label: 'Date Label',
|
|
5
|
+
hideLabel: false,
|
|
6
|
+
helperText: 'Date helper text',
|
|
7
|
+
nextYearRange: '10',
|
|
8
|
+
previousYearRange: '10',
|
|
9
|
+
showWeekNumber: true,
|
|
10
|
+
testId: '12345678',
|
|
11
|
+
showAsFormattedText: true,
|
|
12
|
+
additionalProps: {},
|
|
13
|
+
displayMode: '',
|
|
14
|
+
variant: '',
|
|
15
|
+
hasSuggestions: false,
|
|
16
|
+
readOnly: false,
|
|
17
|
+
required: false,
|
|
18
|
+
disabled: false
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const stateProps = {
|
|
22
|
+
value: '.DateLabel'
|
|
23
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable import/prefer-default-export */
|
|
2
|
+
export const suggestionsHandler = (accepted, pConn, setStatus) => {
|
|
3
|
+
if (accepted) {
|
|
4
|
+
pConn.acceptSuggestion();
|
|
5
|
+
setStatus('success');
|
|
6
|
+
} else {
|
|
7
|
+
pConn.ignoreSuggestion();
|
|
8
|
+
setStatus(undefined);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{COMPONENT_KEY}}",
|
|
3
|
+
"label": "{{COMPONENT_LABEL}}",
|
|
4
|
+
"description": "{{DESCRIPTION}}",
|
|
5
|
+
"organization": "{{ORGANIZATION}}",
|
|
6
|
+
"version": "{{VERSION}}",
|
|
7
|
+
"library": "{{LIBRARY}}",
|
|
8
|
+
"allowedApplications": {{{ALLOWEDAPPS}}},
|
|
9
|
+
"componentKey": "{{COMPONENT_KEY}}",
|
|
10
|
+
"type": "{{TYPE}}",
|
|
11
|
+
"subtype": {{{SUB_TYPE}}},
|
|
12
|
+
"icon": "images/pz-text-input-active.svg",
|
|
13
|
+
"properties": [
|
|
14
|
+
{
|
|
15
|
+
"name": "label",
|
|
16
|
+
"label": "Field label",
|
|
17
|
+
"format": "TEXT",
|
|
18
|
+
"required": true
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "readOnly",
|
|
22
|
+
"label": "Edit mode",
|
|
23
|
+
"format": "READONLY"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"format": "SELECT",
|
|
27
|
+
"name": "clockFormat",
|
|
28
|
+
"label": "Clock",
|
|
29
|
+
"defaultValue": "0",
|
|
30
|
+
"source": [
|
|
31
|
+
{
|
|
32
|
+
"key": "0",
|
|
33
|
+
"value": "use locale"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"key": "12",
|
|
37
|
+
"value": "12 hours"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"key": "24",
|
|
41
|
+
"value": "24 hours"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "withSeconds",
|
|
47
|
+
"label": "Display seconds",
|
|
48
|
+
"format": "BOOLEAN"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"label": "Column settings",
|
|
52
|
+
"format": "GROUP",
|
|
53
|
+
"visibility": "@VIEWTYPE == 'MultiRecordDisplayAsTable'",
|
|
54
|
+
"properties": [
|
|
55
|
+
{
|
|
56
|
+
"name": "columnWidth",
|
|
57
|
+
"label": "Column width",
|
|
58
|
+
"format": "SELECT",
|
|
59
|
+
"source": [
|
|
60
|
+
{
|
|
61
|
+
"key": "auto",
|
|
62
|
+
"value": "Auto"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"key": "custom",
|
|
66
|
+
"value": "Custom"
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "width",
|
|
72
|
+
"label": "Width (px)",
|
|
73
|
+
"format": "NUMBER",
|
|
74
|
+
"visibility": "$this.columnWidth == 'custom'"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"label": "Input settings",
|
|
80
|
+
"format": "GROUP",
|
|
81
|
+
"visibility": "(!readOnly = true)",
|
|
82
|
+
"properties": [
|
|
83
|
+
{
|
|
84
|
+
"format": "LABEL",
|
|
85
|
+
"label": "Year range",
|
|
86
|
+
"variant": "secondary"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"format": "INLINE",
|
|
90
|
+
"elements": [
|
|
91
|
+
{
|
|
92
|
+
"key": "next",
|
|
93
|
+
"format": "LABEL",
|
|
94
|
+
"label": "Next",
|
|
95
|
+
"variant": "secondary"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"key": "nextYears",
|
|
99
|
+
"format": "NUMBER",
|
|
100
|
+
"label": "",
|
|
101
|
+
"name": "nextYearRange",
|
|
102
|
+
"min": 0
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"key": "year",
|
|
106
|
+
"format": "LABEL",
|
|
107
|
+
"label": "years",
|
|
108
|
+
"variant": "secondary"
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"format": "INLINE",
|
|
114
|
+
"elements": [
|
|
115
|
+
{
|
|
116
|
+
"key": "previous",
|
|
117
|
+
"format": "LABEL",
|
|
118
|
+
"label": "Previous",
|
|
119
|
+
"variant": "secondary"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"key": "previousYears",
|
|
123
|
+
"format": "NUMBER",
|
|
124
|
+
"label": "",
|
|
125
|
+
"name": "previousYearRange",
|
|
126
|
+
"min": 0
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"key": "year",
|
|
130
|
+
"format": "LABEL",
|
|
131
|
+
"label": "years",
|
|
132
|
+
"variant": "secondary"
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"name": "showWeekNumber",
|
|
138
|
+
"label": "Display week numbers on calendar",
|
|
139
|
+
"format": "BOOLEAN"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"format": "SELECT",
|
|
143
|
+
"name": "pickerInterval",
|
|
144
|
+
"label": "Time picker",
|
|
145
|
+
"defaultValue": "30",
|
|
146
|
+
"source": [
|
|
147
|
+
{
|
|
148
|
+
"key": "5",
|
|
149
|
+
"value": "5 min"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"key": "10",
|
|
153
|
+
"value": "10 min"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"key": "15",
|
|
157
|
+
"value": "15 min"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"key": "20",
|
|
161
|
+
"value": "20 min"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"key": "30",
|
|
165
|
+
"value": "30 min"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"key": "60",
|
|
169
|
+
"value": "1 hr"
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "helperText",
|
|
175
|
+
"label": "Helper text",
|
|
176
|
+
"format": "TEXT"
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"label": "Read-only settings",
|
|
182
|
+
"format": "GROUP",
|
|
183
|
+
"properties": [
|
|
184
|
+
{
|
|
185
|
+
"name": "showAsFormattedText",
|
|
186
|
+
"label": "Show as formatted text",
|
|
187
|
+
"format": "BOOLEAN"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"format": "SELECT",
|
|
191
|
+
"name": "formatter",
|
|
192
|
+
"label": "Format",
|
|
193
|
+
"defaultValue": "defaultDateTime",
|
|
194
|
+
"source": [
|
|
195
|
+
{
|
|
196
|
+
"key": "defaultDateTime",
|
|
197
|
+
"value": "Default"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"key": "DateTime-Short",
|
|
201
|
+
"value": "Date"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"key": "DateTime-Since",
|
|
205
|
+
"value": "Since"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"key": "Time-Only",
|
|
209
|
+
"value": "Time only"
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"label": "Conditions",
|
|
217
|
+
"format": "GROUP",
|
|
218
|
+
"properties": [
|
|
219
|
+
{
|
|
220
|
+
"name": "required",
|
|
221
|
+
"label": "Required",
|
|
222
|
+
"format": "REQUIRED",
|
|
223
|
+
"visibility": "(!readOnly = true)"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"name": "disabled",
|
|
227
|
+
"label": "Disabled",
|
|
228
|
+
"format": "DISABLED",
|
|
229
|
+
"visibility": "(!readOnly = true)"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "visibility",
|
|
233
|
+
"label": "Visibility",
|
|
234
|
+
"format": "VISIBILITY"
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"label": "Advanced",
|
|
240
|
+
"format": "GROUP",
|
|
241
|
+
"collapsible": true,
|
|
242
|
+
"properties": [
|
|
243
|
+
{
|
|
244
|
+
"name": "testId",
|
|
245
|
+
"label": "Test ID",
|
|
246
|
+
"format": "TEXT",
|
|
247
|
+
"ignorePattern": "[^-_\\p{N}\\p{L}]",
|
|
248
|
+
"includeAnnotations": false
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
],
|
|
253
|
+
"defaultConfig": {
|
|
254
|
+
"label": "@L $this.label"
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import relativeTime from "dayjs/plugin/relativeTime";
|
|
3
|
+
import localizedFormat from "dayjs/plugin/localizedFormat";
|
|
4
|
+
import utc from "dayjs/plugin/utc";
|
|
5
|
+
import tzone from "dayjs/plugin/timezone";
|
|
6
|
+
|
|
7
|
+
dayjs.extend(relativeTime);
|
|
8
|
+
dayjs.extend(localizedFormat);
|
|
9
|
+
dayjs.extend(utc);
|
|
10
|
+
dayjs.extend(tzone);
|
|
11
|
+
|
|
12
|
+
const types = ["fromNow", "customFormat"];
|
|
13
|
+
|
|
14
|
+
// value should be in ISO 8601 format.
|
|
15
|
+
function DateFormatter(
|
|
16
|
+
value,
|
|
17
|
+
{ type = types[1], format = "DD/MM/YYYY", timezone, fieldType } = {}
|
|
18
|
+
) {
|
|
19
|
+
if (!value) return value;
|
|
20
|
+
switch (type) {
|
|
21
|
+
case types[1]:
|
|
22
|
+
if (timezone && fieldType !== 'Date') return dayjs(value).tz(timezone).format(format); // Date only value should be formatted without timezone
|
|
23
|
+
return dayjs(value).format(format);
|
|
24
|
+
case types[0]:
|
|
25
|
+
return dayjs(value).from(dayjs());
|
|
26
|
+
default:
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// value should be in hh:mm:ss format (00:00:00 - 23:59:59).
|
|
31
|
+
function TimeFormatter(value, options) {
|
|
32
|
+
if (!value) return value;
|
|
33
|
+
const { locale = "en-US" } = options;
|
|
34
|
+
const timeOnlyRegex = /^(?:[01]\d|2[0123]):(?:[012345]\d):(?:[012345]\d)$/;
|
|
35
|
+
if (value.length === 8 && timeOnlyRegex.test(value)) {
|
|
36
|
+
const { timeOptions = {} } = options;
|
|
37
|
+
const tempDate = new Date();
|
|
38
|
+
const hours = parseInt(value.substr(0, 2), 10);
|
|
39
|
+
const minutes = parseInt(value.substr(3, 2), 10);
|
|
40
|
+
const seconds = parseInt(value.substr(6, 2), 10);
|
|
41
|
+
tempDate.setHours(hours);
|
|
42
|
+
tempDate.setMinutes(minutes);
|
|
43
|
+
tempDate.setSeconds(seconds);
|
|
44
|
+
return tempDate.toLocaleTimeString(locale, timeOptions);
|
|
45
|
+
}
|
|
46
|
+
return DateFormatter(value, options);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const DateTimeShortFormatter = (value, options) => {
|
|
50
|
+
return DateFormatter(value, {
|
|
51
|
+
...options,
|
|
52
|
+
type: "customFormat",
|
|
53
|
+
format: "MMM DD, YYYY"
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default {
|
|
58
|
+
"DateTime-Long": (value, options) =>
|
|
59
|
+
DateFormatter(value, { ...options, type: "customFormat", format: "LLL" }),
|
|
60
|
+
"DateTime-Short": DateTimeShortFormatter,
|
|
61
|
+
"DateTime-Since": (value) => DateFormatter(value, { type: "fromNow" }),
|
|
62
|
+
"Time-Only": (value, options) =>
|
|
63
|
+
TimeFormatter(value, {
|
|
64
|
+
...options,
|
|
65
|
+
type: "customFormat",
|
|
66
|
+
format: "hh:mm:ss A"
|
|
67
|
+
}),
|
|
68
|
+
convertToTimezone: (value, options) => {
|
|
69
|
+
return value && options && options.timezone
|
|
70
|
+
? DateFormatter(value, {
|
|
71
|
+
...options,
|
|
72
|
+
type: "customFormat",
|
|
73
|
+
format: "YYYY-MM-DDTHH:mm:ss"
|
|
74
|
+
})
|
|
75
|
+
: value;
|
|
76
|
+
},
|
|
77
|
+
convertFromTimezone: (value, timezone) =>
|
|
78
|
+
value && timezone
|
|
79
|
+
? dayjs.tz(value, timezone).utc().format("YYYY-MM-DDTHH:mm:ss[Z]")
|
|
80
|
+
: value,
|
|
81
|
+
Date: (value, options) =>
|
|
82
|
+
DateFormatter(value, { type: "customFormat", ...options }),
|
|
83
|
+
"Date-Default": DateTimeShortFormatter,
|
|
84
|
+
"Date-Time-Default": (value, options) =>
|
|
85
|
+
DateFormatter(value, { ...options, type: "customFormat", format: "lll" }),
|
|
86
|
+
"Time-Default": (value, options) =>
|
|
87
|
+
TimeFormatter(value, {
|
|
88
|
+
...options,
|
|
89
|
+
type: "customFormat",
|
|
90
|
+
format: "hh:mm A"
|
|
91
|
+
})
|
|
92
|
+
};
|