@boomerang-io/carbon-addons-boomerang-react 4.6.11-beta.9 → 4.6.11
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/README.md +162 -162
- package/dist/cjs/components/AboutPlatform/AboutPlatform.js +50 -50
- package/dist/cjs/components/AdvantageSideNav/AdvantageSideNav.js +218 -230
- package/dist/cjs/components/AutoSuggest/AutoSuggest.js +101 -101
- package/dist/cjs/components/Avatar/Avatar.js +18 -18
- package/dist/cjs/components/CheckboxList/CheckboxList.js +34 -34
- package/dist/cjs/components/ComboBox/ComboBox.js +103 -103
- package/dist/cjs/components/ComboBoxMultiSelect/ComboBoxMultiSelect.js +32 -32
- package/dist/cjs/components/ComboBoxMultiSelect/MultiSelect.js +208 -208
- package/dist/cjs/components/ComposedModal/ComposedModal.js +80 -80
- package/dist/cjs/components/ConfirmModal/ConfirmModal.js +43 -43
- package/dist/cjs/components/Creatable/Creatable.js +137 -137
- package/dist/cjs/components/DataDrivenInput/DataDrivenInput.js +226 -226
- package/dist/cjs/components/DateInput/DateInput.js +35 -35
- package/dist/cjs/components/DecisionButtons/DecisionButtons.js +61 -61
- package/dist/cjs/components/DelayedRender/DelayedRender.js +17 -17
- package/dist/cjs/components/DynamicFormik/DynamicFormik.js +578 -578
- package/dist/cjs/components/Error403/Error403.js +13 -13
- package/dist/cjs/components/Error403/ForbiddenErrorBackground.js +113 -113
- package/dist/cjs/components/Error403/GraphicWrangler/GraphicWrangler.js +62 -62
- package/dist/cjs/components/Error404/Error404.js +13 -13
- package/dist/cjs/components/Error404/GraphicLoch/GraphicLoch.js +17 -17
- package/dist/cjs/components/Error404/NotFoundErrorBackground.js +129 -129
- package/dist/cjs/components/ErrorBoundary/ErrorBoundary.js +32 -32
- package/dist/cjs/components/ErrorDragon/ErrorDragon.js +13 -13
- package/dist/cjs/components/ErrorDragon/assets/ErrorGraphic.js +35 -35
- package/dist/cjs/components/ErrorFullPage/ErrorFullPage.js +10 -10
- package/dist/cjs/components/ErrorMessage/ErrorMessage.js +22 -22
- package/dist/cjs/components/ErrorPage/ErrorPage.js +11 -11
- package/dist/cjs/components/ErrorPageCore/ErrorPageCore.js +15 -15
- package/dist/cjs/components/ErrorPageCore/GenericErrorBackground.js +124 -124
- package/dist/cjs/components/FeatureHeader/FeatureHeader.js +29 -29
- package/dist/cjs/components/FeatureNavTab/FeatureNavTab.js +12 -12
- package/dist/cjs/components/FeatureNavTabs/FeatureNavTabs.js +12 -12
- package/dist/cjs/components/FeatureSideNav/FeatureSideNav.js +12 -12
- package/dist/cjs/components/FeatureSideNav/FeatureSideNavFooter.js +8 -8
- package/dist/cjs/components/FeatureSideNav/FeatureSideNavHeader.js +8 -8
- package/dist/cjs/components/FeatureSideNav/FeatureSideNavLinks.js +14 -14
- package/dist/cjs/components/FeatureSideNavLink/FeatureSideNavLink.js +12 -12
- package/dist/cjs/components/Feedback/Feedback.js +37 -40
- package/dist/cjs/components/FlowModal/FlowModal.js +141 -141
- package/dist/cjs/components/FlowModal/FlowModalForm.js +12 -12
- package/dist/cjs/components/Header/Header.js +187 -179
- package/dist/cjs/components/Header/HeaderAppSwitcher.js +94 -94
- package/dist/cjs/components/Header/HeaderMenu.js +7 -7
- package/dist/cjs/components/Header/HeaderMenuItem.js +51 -52
- package/dist/cjs/components/Header/HeaderTeamSwitcher.js +306 -303
- package/dist/cjs/components/Header/UserRequests.js +29 -29
- package/dist/cjs/components/ImageModal/ImageModal.js +17 -17
- package/dist/cjs/components/Loading/Loading.js +8 -8
- package/dist/cjs/components/MemberBar/MemberBar.js +20 -20
- package/dist/cjs/components/Modal/Modal.js +20 -20
- package/dist/cjs/components/ModalConfirmEdit/ModalConfirmArray.js +14 -14
- package/dist/cjs/components/ModalConfirmEdit/ModalConfirmDetails.js +11 -11
- package/dist/cjs/components/ModalConfirmEdit/ModalConfirmEdit.js +17 -17
- package/dist/cjs/components/ModalForm/ModalForm.js +9 -9
- package/dist/cjs/components/Notifications/NotificationsContainer.js +22 -22
- package/dist/cjs/components/Notifications/ToastNotification.js +21 -21
- package/dist/cjs/components/Notifications/notify.js +17 -17
- package/dist/cjs/components/PlatformBanner/PlatformBanner.js +8 -8
- package/dist/cjs/components/PlatformNotifications/PlatformNotification.js +17 -17
- package/dist/cjs/components/PlatformNotifications/PlatformNotificationsContainer.js +136 -136
- package/dist/cjs/components/Portal/Portal.js +14 -14
- package/dist/cjs/components/PrivacyRedirect/PrivacyRedirect.js +30 -30
- package/dist/cjs/components/PrivacyStatement/PrivacyStatement.js +90 -90
- package/dist/cjs/components/ProfileSettings/ProfileSettings.js +124 -124
- package/dist/cjs/components/ProtectedRoute/ProtectedRoute.js +13 -13
- package/dist/cjs/components/RadioGroup/RadioGroup.js +33 -33
- package/dist/cjs/components/RichTextArea/RichTextArea.js +142 -142
- package/dist/cjs/components/SignOut/SignOut.js +27 -27
- package/dist/cjs/components/SupportCenter/SupportCenter.js +65 -65
- package/dist/cjs/components/TextArea/TextArea.js +16 -16
- package/dist/cjs/components/TextInput/TextInput.js +13 -13
- package/dist/cjs/components/Toggle/Toggle.js +22 -22
- package/dist/cjs/components/TooltipHover/TooltipHover.js +39 -39
- package/dist/cjs/components/UIShell/UIShell.js +95 -94
- package/dist/cjs/config/servicesConfig.js +22 -21
- package/dist/cjs/constants/DataDrivenInputTypes.js +74 -74
- package/dist/cjs/constants/UserType.js +13 -13
- package/dist/cjs/hooks/useHeaderMenu.js +49 -49
- package/dist/cjs/hooks/usePortal.js +74 -74
- package/dist/cjs/hooks/useWindowSize.js +33 -33
- package/dist/cjs/internal/ListBox/ListBox.js +41 -41
- package/dist/cjs/internal/ListBox/ListBoxField.js +19 -19
- package/dist/cjs/internal/ListBox/ListBoxMenu.js +19 -19
- package/dist/cjs/internal/ListBox/ListBoxMenuIcon.js +31 -31
- package/dist/cjs/internal/ListBox/ListBoxMenuItem.js +38 -38
- package/dist/cjs/internal/ListBox/ListBoxSelection.js +64 -64
- package/dist/cjs/internal/ListBox/index.js +10 -10
- package/dist/cjs/internal/keyboard/keys.js +16 -16
- package/dist/cjs/internal/keyboard/match.js +67 -67
- package/dist/cjs/internal/settings.js +5 -5
- package/dist/cjs/tools/accessibility.js +13 -13
- package/dist/cjs/tools/createPropAdapter.js +44 -44
- package/dist/cjs/tools/isUrl.js +39 -39
- package/dist/cjs/tools/setupGetInstanceId.js +20 -20
- package/dist/cjs/tools/useSetState.js +12 -12
- package/dist/cjs/tools/yupAst/astGenerator.js +212 -212
- package/dist/cjs/tools/yupAst/customValidators.js +17 -17
- package/dist/esm/components/AboutPlatform/AboutPlatform.js +50 -50
- package/dist/esm/components/AdvantageSideNav/AdvantageSideNav.js +219 -231
- package/dist/esm/components/AutoSuggest/AutoSuggest.js +101 -101
- package/dist/esm/components/Avatar/Avatar.js +18 -18
- package/dist/esm/components/CheckboxList/CheckboxList.js +34 -34
- package/dist/esm/components/ComboBox/ComboBox.js +103 -103
- package/dist/esm/components/ComboBoxMultiSelect/ComboBoxMultiSelect.js +32 -32
- package/dist/esm/components/ComboBoxMultiSelect/MultiSelect.js +208 -208
- package/dist/esm/components/ComposedModal/ComposedModal.js +80 -80
- package/dist/esm/components/ConfirmModal/ConfirmModal.js +43 -43
- package/dist/esm/components/Creatable/Creatable.js +137 -137
- package/dist/esm/components/DataDrivenInput/DataDrivenInput.js +226 -226
- package/dist/esm/components/DateInput/DateInput.js +35 -35
- package/dist/esm/components/DecisionButtons/DecisionButtons.js +61 -61
- package/dist/esm/components/DelayedRender/DelayedRender.js +17 -17
- package/dist/esm/components/DynamicFormik/DynamicFormik.js +578 -578
- package/dist/esm/components/Error403/Error403.js +13 -13
- package/dist/esm/components/Error403/ForbiddenErrorBackground.js +113 -113
- package/dist/esm/components/Error403/GraphicWrangler/GraphicWrangler.js +62 -62
- package/dist/esm/components/Error404/Error404.js +13 -13
- package/dist/esm/components/Error404/GraphicLoch/GraphicLoch.js +17 -17
- package/dist/esm/components/Error404/NotFoundErrorBackground.js +129 -129
- package/dist/esm/components/ErrorBoundary/ErrorBoundary.js +32 -32
- package/dist/esm/components/ErrorDragon/ErrorDragon.js +13 -13
- package/dist/esm/components/ErrorDragon/assets/ErrorGraphic.js +35 -35
- package/dist/esm/components/ErrorFullPage/ErrorFullPage.js +10 -10
- package/dist/esm/components/ErrorMessage/ErrorMessage.js +22 -22
- package/dist/esm/components/ErrorPage/ErrorPage.js +11 -11
- package/dist/esm/components/ErrorPageCore/ErrorPageCore.js +15 -15
- package/dist/esm/components/ErrorPageCore/GenericErrorBackground.js +124 -124
- package/dist/esm/components/FeatureHeader/FeatureHeader.js +29 -29
- package/dist/esm/components/FeatureNavTab/FeatureNavTab.js +12 -12
- package/dist/esm/components/FeatureNavTabs/FeatureNavTabs.js +12 -12
- package/dist/esm/components/FeatureSideNav/FeatureSideNav.js +12 -12
- package/dist/esm/components/FeatureSideNav/FeatureSideNavFooter.js +8 -8
- package/dist/esm/components/FeatureSideNav/FeatureSideNavHeader.js +8 -8
- package/dist/esm/components/FeatureSideNav/FeatureSideNavLinks.js +14 -14
- package/dist/esm/components/FeatureSideNavLink/FeatureSideNavLink.js +12 -12
- package/dist/esm/components/Feedback/Feedback.js +37 -40
- package/dist/esm/components/FlowModal/FlowModal.js +141 -141
- package/dist/esm/components/FlowModal/FlowModalForm.js +12 -12
- package/dist/esm/components/Header/Header.js +187 -179
- package/dist/esm/components/Header/HeaderAppSwitcher.js +94 -94
- package/dist/esm/components/Header/HeaderMenu.js +7 -7
- package/dist/esm/components/Header/HeaderMenuItem.js +52 -53
- package/dist/esm/components/Header/HeaderTeamSwitcher.js +308 -305
- package/dist/esm/components/Header/UserRequests.js +29 -29
- package/dist/esm/components/ImageModal/ImageModal.js +17 -17
- package/dist/esm/components/Loading/Loading.js +8 -8
- package/dist/esm/components/MemberBar/MemberBar.js +20 -20
- package/dist/esm/components/Modal/Modal.js +20 -20
- package/dist/esm/components/ModalConfirmEdit/ModalConfirmArray.js +14 -14
- package/dist/esm/components/ModalConfirmEdit/ModalConfirmDetails.js +11 -11
- package/dist/esm/components/ModalConfirmEdit/ModalConfirmEdit.js +17 -17
- package/dist/esm/components/ModalForm/ModalForm.js +9 -9
- package/dist/esm/components/Notifications/NotificationsContainer.js +22 -22
- package/dist/esm/components/Notifications/ToastNotification.js +21 -21
- package/dist/esm/components/Notifications/notify.js +17 -17
- package/dist/esm/components/PlatformBanner/PlatformBanner.js +8 -8
- package/dist/esm/components/PlatformNotifications/PlatformNotification.js +17 -17
- package/dist/esm/components/PlatformNotifications/PlatformNotificationsContainer.js +136 -136
- package/dist/esm/components/Portal/Portal.js +14 -14
- package/dist/esm/components/PrivacyRedirect/PrivacyRedirect.js +30 -30
- package/dist/esm/components/PrivacyStatement/PrivacyStatement.js +90 -90
- package/dist/esm/components/ProfileSettings/ProfileSettings.js +124 -124
- package/dist/esm/components/ProtectedRoute/ProtectedRoute.js +13 -13
- package/dist/esm/components/RadioGroup/RadioGroup.js +33 -33
- package/dist/esm/components/RichTextArea/RichTextArea.js +142 -142
- package/dist/esm/components/SignOut/SignOut.js +27 -27
- package/dist/esm/components/SupportCenter/SupportCenter.js +65 -65
- package/dist/esm/components/TextArea/TextArea.js +16 -16
- package/dist/esm/components/TextInput/TextInput.js +13 -13
- package/dist/esm/components/Toggle/Toggle.js +22 -22
- package/dist/esm/components/TooltipHover/TooltipHover.js +39 -39
- package/dist/esm/components/UIShell/UIShell.js +95 -94
- package/dist/esm/config/servicesConfig.js +22 -21
- package/dist/esm/constants/DataDrivenInputTypes.js +74 -74
- package/dist/esm/constants/UserType.js +13 -13
- package/dist/esm/hooks/useHeaderMenu.js +49 -49
- package/dist/esm/hooks/usePortal.js +74 -74
- package/dist/esm/hooks/useWindowSize.js +33 -33
- package/dist/esm/internal/ListBox/ListBox.js +41 -41
- package/dist/esm/internal/ListBox/ListBoxField.js +19 -19
- package/dist/esm/internal/ListBox/ListBoxMenu.js +19 -19
- package/dist/esm/internal/ListBox/ListBoxMenuIcon.js +31 -31
- package/dist/esm/internal/ListBox/ListBoxMenuItem.js +38 -38
- package/dist/esm/internal/ListBox/ListBoxSelection.js +64 -64
- package/dist/esm/internal/ListBox/index.js +10 -10
- package/dist/esm/internal/keyboard/keys.js +16 -16
- package/dist/esm/internal/keyboard/match.js +67 -67
- package/dist/esm/internal/settings.js +5 -5
- package/dist/esm/tools/accessibility.js +13 -13
- package/dist/esm/tools/createPropAdapter.js +44 -44
- package/dist/esm/tools/isUrl.js +39 -39
- package/dist/esm/tools/setupGetInstanceId.js +20 -20
- package/dist/esm/tools/useSetState.js +12 -12
- package/dist/esm/tools/yupAst/astGenerator.js +212 -212
- package/dist/esm/tools/yupAst/customValidators.js +17 -17
- package/dist/types/index.d.ts +1359 -1410
- package/package.json +167 -167
- package/scss/components/AboutPlatform/_aboutPlatform.scss +139 -139
- package/scss/components/AdvantageSideNav/_advantageSideNav.scss +261 -261
- package/scss/components/AutoSuggest/_autoSuggest.scss +62 -62
- package/scss/components/Avatar/_avatar.scss +32 -32
- package/scss/components/CheckboxList/_checkboxList.scss +26 -26
- package/scss/components/ComboBox/_combobox.scss +23 -23
- package/scss/components/ComboBoxMultiSelect/_comboBoxMultiSelect.scss +53 -53
- package/scss/components/ConfirmModal/_confirmModal.scss +12 -12
- package/scss/components/Creatable/_creatable.scss +48 -48
- package/scss/components/DateInput/_dateInput.scss +36 -36
- package/scss/components/DecisionButtons/_decisionButtons.scss +132 -132
- package/scss/components/DynamicFormik/_dynamicFormik.scss +17 -17
- package/scss/components/ErrorBoundary/_errorBoundary.scss +12 -12
- package/scss/components/ErrorDragon/_errorDragon.scss +55 -55
- package/scss/components/ErrorMessage/_errorMessage.scss +43 -43
- package/scss/components/ErrorPage/_errorPage.scss +66 -66
- package/scss/components/ErrorPageCore/_errorPageCore.scss +73 -73
- package/scss/components/FeatureHeader/_featureHeader.scss +67 -67
- package/scss/components/FeatureNavTab/_featureNavTab.scss +27 -27
- package/scss/components/FeatureSideNav/_featureSideNav.scss +76 -76
- package/scss/components/FeatureSideNavLink/_featureSideNavLink.scss +49 -49
- package/scss/components/Feedback/_feedback.scss +46 -46
- package/scss/components/Header/_header.scss +179 -179
- package/scss/components/Header/_headerAppSwitcher.scss +117 -117
- package/scss/components/Header/_headerMenu.scss +30 -30
- package/scss/components/Header/_headerMenuItem.scss +65 -65
- package/scss/components/Header/_headerTeamSwitcher.scss +195 -195
- package/scss/components/Header/_userRequests.scss +36 -36
- package/scss/components/ImageModal/_imageModal.scss +51 -51
- package/scss/components/MemberBar/_memberBar.scss +99 -99
- package/scss/components/Modal/_modal.scss +163 -163
- package/scss/components/ModalConfirmEdit/_modalConfirmEdit.scss +113 -113
- package/scss/components/Notifications/_notifications.scss +57 -57
- package/scss/components/PlatformBanner/_platformBanner.scss +30 -30
- package/scss/components/PlatformNotifications/_platformNotifications.scss +230 -230
- package/scss/components/PrivacyRedirect/_privacyRedirect.scss +43 -43
- package/scss/components/PrivacyStatement/_privacyStatement.scss +137 -137
- package/scss/components/ProfileSettings/_profileSettings.scss +117 -117
- package/scss/components/ProtectedRoute/_protectedRoute.scss +32 -32
- package/scss/components/RadioGroup/_radioGroup.scss +46 -46
- package/scss/components/RichTextArea/_richTextArea.scss +82 -82
- package/scss/components/SignOut/_signOut.scss +51 -51
- package/scss/components/SupportCenter/_supportCenter.scss +16 -16
- package/scss/components/TextArea/_textArea.scss +19 -19
- package/scss/components/TextInput/_textInput.scss +26 -26
- package/scss/components/Toggle/_toggle.scss +80 -80
- package/scss/components/TooltipHover/_tooltip.scss +48 -48
- package/scss/global/_config.scss +14 -14
- package/scss/global/_tippy.scss +49 -49
- package/scss/global/index.scss +401 -401
- package/scss/global/themes/_boomerang.scss +184 -184
- package/scss/global/themes/_default.scss +79 -79
- package/scss/global/themes/_shell-tokens.scss +42 -42
- package/scss/global/utils/_animations.scss +15 -15
- package/scss/global/utils/_mixins.scss +67 -67
- package/scss/global/utils/index.scss +10 -10
|
@@ -10,232 +10,232 @@ import TextInputComponent from '../TextInput/TextInput.js';
|
|
|
10
10
|
import ToggleComponent from '../Toggle/Toggle.js';
|
|
11
11
|
import { CHECKBOX_TYPES, CREATABLE_TYPES, DATE_TYPES, MULTI_SELECT_TYPES, RADIO_TYPES, SELECT_TYPES, TEXT_AREA_TYPES, TEXT_EDITOR_TYPES, TEXT_INPUT_TYPES, BOOLEAN_TYPES } from '../../constants/DataDrivenInputTypes.js';
|
|
12
12
|
|
|
13
|
-
/*
|
|
14
|
-
IBM Confidential
|
|
15
|
-
694970X, 69497O0
|
|
16
|
-
© Copyright IBM Corp. 2022, 2024
|
|
17
|
-
*/
|
|
18
|
-
function formatSelectOptions(options = []) {
|
|
19
|
-
return options.map((option) => ({ label: option.value, value: option.key }));
|
|
20
|
-
}
|
|
21
|
-
function formatCheckBoxListOptions(options = []) {
|
|
22
|
-
return options.map((option) => ({ labelText: option.value, id: option.key }));
|
|
23
|
-
}
|
|
24
|
-
function formatRadioGroupOptions(options = []) {
|
|
25
|
-
return options.map((option) => ({
|
|
26
|
-
labelText: option.value,
|
|
27
|
-
value: option.key,
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
function validateRegex(pattern, value) {
|
|
31
|
-
const regexTester = new RegExp(pattern);
|
|
32
|
-
let hasError = false;
|
|
33
|
-
if (Array.isArray(value))
|
|
34
|
-
hasError = !value.every((val) => regexTester.test(val));
|
|
35
|
-
else
|
|
36
|
-
hasError = !regexTester.test(value);
|
|
37
|
-
return hasError;
|
|
38
|
-
}
|
|
39
|
-
const determineInitialValues = (input) => {
|
|
40
|
-
let value = "";
|
|
41
|
-
const valueToCheck = input.value || input.defaultValue || input.values || input.defaultValues;
|
|
42
|
-
if (valueToCheck) {
|
|
43
|
-
switch (valueToCheck) {
|
|
44
|
-
case "false": {
|
|
45
|
-
value = false;
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
case "true": {
|
|
49
|
-
value = true;
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
default: {
|
|
53
|
-
value = valueToCheck;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return value;
|
|
58
|
-
};
|
|
59
|
-
function DataDrivenInput(props) {
|
|
60
|
-
const { CheckboxList = CheckboxListComponent, Creatable = CreatableComponent, DateInput = DateInputComponent, MultiSelect = ComboBoxMultiSelect, RadioGroup = RadioGroupComponent, Select = ComboBoxComponent, TextArea = TextAreaComponent, TextEditor = TextAreaComponent, TextInput = TextInputComponent, Toggle = ToggleComponent, formikProps, ...inputProps } = props;
|
|
61
|
-
const {
|
|
62
|
-
// eslint-disable-next-line no-unused-vars
|
|
63
|
-
conditionallyRender, customComponent, disabled, description = "", defaultValue, defaultValues, label, helperText = "", pattern, patternInvalidText, invalid, invalidText,
|
|
64
|
-
// eslint-disable-next-line no-unused-vars
|
|
65
|
-
invalidValues, key, governingOptions, governingDisabled, minValueLength, maxValueLength, onBlur, onChange, options, placeholder, readOnly, required,
|
|
66
|
-
// eslint-disable-next-line no-unused-vars
|
|
67
|
-
requiredForKey,
|
|
68
|
-
// eslint-disable-next-line no-unused-vars
|
|
69
|
-
requiredValueOf, type, value, values, ...restInputProps } = inputProps;
|
|
70
|
-
let Component;
|
|
71
|
-
let componentProps = {};
|
|
72
|
-
let inputValue = value || values;
|
|
73
|
-
let regexError = inputValue && Boolean(pattern) && validateRegex(pattern, inputValue);
|
|
74
|
-
let invalidInput = regexError || invalid;
|
|
75
|
-
let invalidTextMessage = regexError && patternInvalidText ? patternInvalidText : invalidText;
|
|
76
|
-
React.useEffect(() => {
|
|
77
|
-
// eslint-disable-next-line
|
|
78
|
-
inputValue = determineInitialValues({
|
|
79
|
-
value,
|
|
80
|
-
values,
|
|
81
|
-
defaultValue,
|
|
82
|
-
defaultValues,
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
const allInputProps = {
|
|
86
|
-
id: key,
|
|
87
|
-
name: key,
|
|
88
|
-
key,
|
|
89
|
-
disabled,
|
|
90
|
-
helperText,
|
|
91
|
-
label,
|
|
92
|
-
onBlur,
|
|
93
|
-
onChange,
|
|
94
|
-
readOnly,
|
|
95
|
-
required,
|
|
96
|
-
tooltipContent: description,
|
|
97
|
-
};
|
|
98
|
-
if (Object.values(CHECKBOX_TYPES).includes(type)) {
|
|
99
|
-
const checkboxOptions = formatCheckBoxListOptions(options);
|
|
100
|
-
Component = CheckboxList;
|
|
101
|
-
componentProps = {
|
|
102
|
-
...allInputProps,
|
|
103
|
-
initialSelectedItems: inputValue,
|
|
104
|
-
options: checkboxOptions,
|
|
105
|
-
...restInputProps,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
else if (Object.values(CREATABLE_TYPES).includes(type)) {
|
|
109
|
-
Component = Creatable;
|
|
110
|
-
componentProps = {
|
|
111
|
-
...allInputProps,
|
|
112
|
-
createKeyValuePair: type === CREATABLE_TYPES.CREATABLE_PAIR || type === CREATABLE_TYPES.CREATABLE_PAIR_NON_DELETABLE,
|
|
113
|
-
nonDeletable: type === CREATABLE_TYPES.CREATABLE_SINGLE_NON_DELETABLE ||
|
|
114
|
-
type === CREATABLE_TYPES.CREATABLE_PAIR_NON_DELETABLE,
|
|
115
|
-
invalid: invalidInput,
|
|
116
|
-
invalidText: invalidTextMessage,
|
|
117
|
-
placeholder,
|
|
118
|
-
value: inputValue,
|
|
119
|
-
...restInputProps,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
else if (Object.values(DATE_TYPES).includes(type)) {
|
|
123
|
-
Component = DateInput;
|
|
124
|
-
componentProps = {
|
|
125
|
-
...allInputProps,
|
|
126
|
-
invalid,
|
|
127
|
-
invalidText,
|
|
128
|
-
placeholder,
|
|
129
|
-
type,
|
|
130
|
-
value: inputValue,
|
|
131
|
-
...restInputProps,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
else if (Object.values(MULTI_SELECT_TYPES).includes(type)) {
|
|
135
|
-
const items = formatSelectOptions(options);
|
|
136
|
-
Component = MultiSelect;
|
|
137
|
-
componentProps = {
|
|
138
|
-
...allInputProps,
|
|
139
|
-
items,
|
|
140
|
-
initialSelectedItems: Array.isArray(inputValue)
|
|
141
|
-
? items.filter((item) => inputValue.includes(item.value))
|
|
142
|
-
: typeof inputValue === "string"
|
|
143
|
-
? inputValue
|
|
144
|
-
: [],
|
|
145
|
-
itemToString: (input) => input && input.label,
|
|
146
|
-
invalid,
|
|
147
|
-
invalidText,
|
|
148
|
-
placeholder,
|
|
149
|
-
...restInputProps,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
else if (Object.values(RADIO_TYPES).includes(type)) {
|
|
153
|
-
const radioOptions = formatRadioGroupOptions(options);
|
|
154
|
-
Component = RadioGroup;
|
|
155
|
-
componentProps = {
|
|
156
|
-
...allInputProps,
|
|
157
|
-
options: radioOptions,
|
|
158
|
-
valueSelected: inputValue,
|
|
159
|
-
...restInputProps,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
else if (Object.values(SELECT_TYPES).includes(type)) {
|
|
163
|
-
const items = governingOptions || formatSelectOptions(options);
|
|
164
|
-
const selectedItem = items.find((item) => item.value === value) ?? { label: "", value: "" };
|
|
165
|
-
Component = Select;
|
|
166
|
-
componentProps = {
|
|
167
|
-
...allInputProps,
|
|
168
|
-
disabled: governingDisabled || disabled,
|
|
169
|
-
invalid,
|
|
170
|
-
invalidText,
|
|
171
|
-
initialSelectedItem: selectedItem,
|
|
172
|
-
selectedItem,
|
|
173
|
-
itemToString: (input) => input && input.label,
|
|
174
|
-
items,
|
|
175
|
-
placeholder,
|
|
176
|
-
...restInputProps,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
else if (Object.values(TEXT_AREA_TYPES).includes(type)) {
|
|
180
|
-
Component = TextArea;
|
|
181
|
-
componentProps = {
|
|
182
|
-
...allInputProps,
|
|
183
|
-
invalid: invalidInput,
|
|
184
|
-
invalidText: invalidTextMessage,
|
|
185
|
-
placeholder,
|
|
186
|
-
value: inputValue,
|
|
187
|
-
...restInputProps,
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
else if (type.startsWith(TEXT_EDITOR_TYPES.TEXT_EDITOR)) {
|
|
191
|
-
Component = TextEditor;
|
|
192
|
-
componentProps = {
|
|
193
|
-
...allInputProps,
|
|
194
|
-
invalid: invalidInput,
|
|
195
|
-
invalidText: invalidTextMessage,
|
|
196
|
-
placeholder,
|
|
197
|
-
value: inputValue,
|
|
198
|
-
...restInputProps,
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
else if (Object.values(TEXT_INPUT_TYPES).includes(type)) {
|
|
202
|
-
Component = TextInput;
|
|
203
|
-
componentProps = {
|
|
204
|
-
...allInputProps,
|
|
205
|
-
maxLength: maxValueLength,
|
|
206
|
-
minLength: minValueLength,
|
|
207
|
-
max: maxValueLength,
|
|
208
|
-
min: minValueLength,
|
|
209
|
-
invalid: invalidInput,
|
|
210
|
-
invalidText: invalidTextMessage,
|
|
211
|
-
placeholder,
|
|
212
|
-
type: type === TEXT_INPUT_TYPES.SECURED ? TEXT_INPUT_TYPES.PASSWORD : type,
|
|
213
|
-
value: inputValue,
|
|
214
|
-
...restInputProps,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
else if (Object.values(BOOLEAN_TYPES).includes(type)) {
|
|
218
|
-
Component = Toggle;
|
|
219
|
-
componentProps = {
|
|
220
|
-
...allInputProps,
|
|
221
|
-
invalid,
|
|
222
|
-
invalidText,
|
|
223
|
-
onChange: undefined,
|
|
224
|
-
onToggle: onChange,
|
|
225
|
-
toggled: value === true || value === "true",
|
|
226
|
-
...restInputProps,
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
if (customComponent) {
|
|
230
|
-
Component = customComponent;
|
|
231
|
-
return (React.createElement(Component, { ...allInputProps, ...componentProps, value: inputValue, ...restInputProps, formikProps: formikProps }));
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
if (Component) {
|
|
235
|
-
return React.createElement(Component, { ...componentProps });
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
return null;
|
|
13
|
+
/*
|
|
14
|
+
IBM Confidential
|
|
15
|
+
694970X, 69497O0
|
|
16
|
+
© Copyright IBM Corp. 2022, 2024
|
|
17
|
+
*/
|
|
18
|
+
function formatSelectOptions(options = []) {
|
|
19
|
+
return options.map((option) => ({ label: option.value, value: option.key }));
|
|
20
|
+
}
|
|
21
|
+
function formatCheckBoxListOptions(options = []) {
|
|
22
|
+
return options.map((option) => ({ labelText: option.value, id: option.key }));
|
|
23
|
+
}
|
|
24
|
+
function formatRadioGroupOptions(options = []) {
|
|
25
|
+
return options.map((option) => ({
|
|
26
|
+
labelText: option.value,
|
|
27
|
+
value: option.key,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
function validateRegex(pattern, value) {
|
|
31
|
+
const regexTester = new RegExp(pattern);
|
|
32
|
+
let hasError = false;
|
|
33
|
+
if (Array.isArray(value))
|
|
34
|
+
hasError = !value.every((val) => regexTester.test(val));
|
|
35
|
+
else
|
|
36
|
+
hasError = !regexTester.test(value);
|
|
37
|
+
return hasError;
|
|
38
|
+
}
|
|
39
|
+
const determineInitialValues = (input) => {
|
|
40
|
+
let value = "";
|
|
41
|
+
const valueToCheck = input.value || input.defaultValue || input.values || input.defaultValues;
|
|
42
|
+
if (valueToCheck) {
|
|
43
|
+
switch (valueToCheck) {
|
|
44
|
+
case "false": {
|
|
45
|
+
value = false;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case "true": {
|
|
49
|
+
value = true;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
default: {
|
|
53
|
+
value = valueToCheck;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
};
|
|
59
|
+
function DataDrivenInput(props) {
|
|
60
|
+
const { CheckboxList = CheckboxListComponent, Creatable = CreatableComponent, DateInput = DateInputComponent, MultiSelect = ComboBoxMultiSelect, RadioGroup = RadioGroupComponent, Select = ComboBoxComponent, TextArea = TextAreaComponent, TextEditor = TextAreaComponent, TextInput = TextInputComponent, Toggle = ToggleComponent, formikProps, ...inputProps } = props;
|
|
61
|
+
const {
|
|
62
|
+
// eslint-disable-next-line no-unused-vars
|
|
63
|
+
conditionallyRender, customComponent, disabled, description = "", defaultValue, defaultValues, label, helperText = "", pattern, patternInvalidText, invalid, invalidText,
|
|
64
|
+
// eslint-disable-next-line no-unused-vars
|
|
65
|
+
invalidValues, key, governingOptions, governingDisabled, minValueLength, maxValueLength, onBlur, onChange, options, placeholder, readOnly, required,
|
|
66
|
+
// eslint-disable-next-line no-unused-vars
|
|
67
|
+
requiredForKey,
|
|
68
|
+
// eslint-disable-next-line no-unused-vars
|
|
69
|
+
requiredValueOf, type, value, values, ...restInputProps } = inputProps;
|
|
70
|
+
let Component;
|
|
71
|
+
let componentProps = {};
|
|
72
|
+
let inputValue = value || values;
|
|
73
|
+
let regexError = inputValue && Boolean(pattern) && validateRegex(pattern, inputValue);
|
|
74
|
+
let invalidInput = regexError || invalid;
|
|
75
|
+
let invalidTextMessage = regexError && patternInvalidText ? patternInvalidText : invalidText;
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
// eslint-disable-next-line
|
|
78
|
+
inputValue = determineInitialValues({
|
|
79
|
+
value,
|
|
80
|
+
values,
|
|
81
|
+
defaultValue,
|
|
82
|
+
defaultValues,
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
const allInputProps = {
|
|
86
|
+
id: key,
|
|
87
|
+
name: key,
|
|
88
|
+
key,
|
|
89
|
+
disabled,
|
|
90
|
+
helperText,
|
|
91
|
+
label,
|
|
92
|
+
onBlur,
|
|
93
|
+
onChange,
|
|
94
|
+
readOnly,
|
|
95
|
+
required,
|
|
96
|
+
tooltipContent: description,
|
|
97
|
+
};
|
|
98
|
+
if (Object.values(CHECKBOX_TYPES).includes(type)) {
|
|
99
|
+
const checkboxOptions = formatCheckBoxListOptions(options);
|
|
100
|
+
Component = CheckboxList;
|
|
101
|
+
componentProps = {
|
|
102
|
+
...allInputProps,
|
|
103
|
+
initialSelectedItems: inputValue,
|
|
104
|
+
options: checkboxOptions,
|
|
105
|
+
...restInputProps,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
else if (Object.values(CREATABLE_TYPES).includes(type)) {
|
|
109
|
+
Component = Creatable;
|
|
110
|
+
componentProps = {
|
|
111
|
+
...allInputProps,
|
|
112
|
+
createKeyValuePair: type === CREATABLE_TYPES.CREATABLE_PAIR || type === CREATABLE_TYPES.CREATABLE_PAIR_NON_DELETABLE,
|
|
113
|
+
nonDeletable: type === CREATABLE_TYPES.CREATABLE_SINGLE_NON_DELETABLE ||
|
|
114
|
+
type === CREATABLE_TYPES.CREATABLE_PAIR_NON_DELETABLE,
|
|
115
|
+
invalid: invalidInput,
|
|
116
|
+
invalidText: invalidTextMessage,
|
|
117
|
+
placeholder,
|
|
118
|
+
value: inputValue,
|
|
119
|
+
...restInputProps,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
else if (Object.values(DATE_TYPES).includes(type)) {
|
|
123
|
+
Component = DateInput;
|
|
124
|
+
componentProps = {
|
|
125
|
+
...allInputProps,
|
|
126
|
+
invalid,
|
|
127
|
+
invalidText,
|
|
128
|
+
placeholder,
|
|
129
|
+
type,
|
|
130
|
+
value: inputValue,
|
|
131
|
+
...restInputProps,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
else if (Object.values(MULTI_SELECT_TYPES).includes(type)) {
|
|
135
|
+
const items = formatSelectOptions(options);
|
|
136
|
+
Component = MultiSelect;
|
|
137
|
+
componentProps = {
|
|
138
|
+
...allInputProps,
|
|
139
|
+
items,
|
|
140
|
+
initialSelectedItems: Array.isArray(inputValue)
|
|
141
|
+
? items.filter((item) => inputValue.includes(item.value))
|
|
142
|
+
: typeof inputValue === "string"
|
|
143
|
+
? inputValue
|
|
144
|
+
: [],
|
|
145
|
+
itemToString: (input) => input && input.label,
|
|
146
|
+
invalid,
|
|
147
|
+
invalidText,
|
|
148
|
+
placeholder,
|
|
149
|
+
...restInputProps,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
else if (Object.values(RADIO_TYPES).includes(type)) {
|
|
153
|
+
const radioOptions = formatRadioGroupOptions(options);
|
|
154
|
+
Component = RadioGroup;
|
|
155
|
+
componentProps = {
|
|
156
|
+
...allInputProps,
|
|
157
|
+
options: radioOptions,
|
|
158
|
+
valueSelected: inputValue,
|
|
159
|
+
...restInputProps,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
else if (Object.values(SELECT_TYPES).includes(type)) {
|
|
163
|
+
const items = governingOptions || formatSelectOptions(options);
|
|
164
|
+
const selectedItem = items.find((item) => item.value === value) ?? { label: "", value: "" };
|
|
165
|
+
Component = Select;
|
|
166
|
+
componentProps = {
|
|
167
|
+
...allInputProps,
|
|
168
|
+
disabled: governingDisabled || disabled,
|
|
169
|
+
invalid,
|
|
170
|
+
invalidText,
|
|
171
|
+
initialSelectedItem: selectedItem,
|
|
172
|
+
selectedItem,
|
|
173
|
+
itemToString: (input) => input && input.label,
|
|
174
|
+
items,
|
|
175
|
+
placeholder,
|
|
176
|
+
...restInputProps,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
else if (Object.values(TEXT_AREA_TYPES).includes(type)) {
|
|
180
|
+
Component = TextArea;
|
|
181
|
+
componentProps = {
|
|
182
|
+
...allInputProps,
|
|
183
|
+
invalid: invalidInput,
|
|
184
|
+
invalidText: invalidTextMessage,
|
|
185
|
+
placeholder,
|
|
186
|
+
value: inputValue,
|
|
187
|
+
...restInputProps,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
else if (type.startsWith(TEXT_EDITOR_TYPES.TEXT_EDITOR)) {
|
|
191
|
+
Component = TextEditor;
|
|
192
|
+
componentProps = {
|
|
193
|
+
...allInputProps,
|
|
194
|
+
invalid: invalidInput,
|
|
195
|
+
invalidText: invalidTextMessage,
|
|
196
|
+
placeholder,
|
|
197
|
+
value: inputValue,
|
|
198
|
+
...restInputProps,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
else if (Object.values(TEXT_INPUT_TYPES).includes(type)) {
|
|
202
|
+
Component = TextInput;
|
|
203
|
+
componentProps = {
|
|
204
|
+
...allInputProps,
|
|
205
|
+
maxLength: maxValueLength,
|
|
206
|
+
minLength: minValueLength,
|
|
207
|
+
max: maxValueLength,
|
|
208
|
+
min: minValueLength,
|
|
209
|
+
invalid: invalidInput,
|
|
210
|
+
invalidText: invalidTextMessage,
|
|
211
|
+
placeholder,
|
|
212
|
+
type: type === TEXT_INPUT_TYPES.SECURED ? TEXT_INPUT_TYPES.PASSWORD : type,
|
|
213
|
+
value: inputValue,
|
|
214
|
+
...restInputProps,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
else if (Object.values(BOOLEAN_TYPES).includes(type)) {
|
|
218
|
+
Component = Toggle;
|
|
219
|
+
componentProps = {
|
|
220
|
+
...allInputProps,
|
|
221
|
+
invalid,
|
|
222
|
+
invalidText,
|
|
223
|
+
onChange: undefined,
|
|
224
|
+
onToggle: onChange,
|
|
225
|
+
toggled: value === true || value === "true",
|
|
226
|
+
...restInputProps,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
if (customComponent) {
|
|
230
|
+
Component = customComponent;
|
|
231
|
+
return (React.createElement(Component, { ...allInputProps, ...componentProps, value: inputValue, ...restInputProps, formikProps: formikProps }));
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
if (Component) {
|
|
235
|
+
return React.createElement(Component, { ...componentProps });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return null;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
export { DataDrivenInput as default };
|
|
@@ -6,41 +6,41 @@ import TooltipHover from '../TooltipHover/TooltipHover.js';
|
|
|
6
6
|
import { DATE_TYPES } from '../../constants/DataDrivenInputTypes.js';
|
|
7
7
|
import { prefix } from '../../internal/settings.js';
|
|
8
8
|
|
|
9
|
-
/*
|
|
10
|
-
IBM Confidential
|
|
11
|
-
694970X, 69497O0
|
|
12
|
-
© Copyright IBM Corp. 2022, 2024
|
|
13
|
-
*/
|
|
14
|
-
const DateInputComponent = React.forwardRef(function DateInputComponent({ id, dateFormat, datePickerProps = {}, disabled, helperText, invalid, label, labelText, max, min, onCalendarChange, onChange, readOnly, tooltipClassName = `${prefix}--bmrg-date-input__tooltip`, tooltipContent, tooltipProps = { direction: "top" }, type = DATE_TYPES.DATE, value, ...dateInputProps }, ref) {
|
|
15
|
-
const labelValue = label || labelText;
|
|
16
|
-
const dateInputHelperId = !helperText ? undefined : `date-input-helper-text-${id}`;
|
|
17
|
-
const helperClasses = cx(`${prefix}--form__helper-text`, {
|
|
18
|
-
[`${prefix}--form__helper-text--disabled`]: disabled,
|
|
19
|
-
});
|
|
20
|
-
if (type === DATE_TYPES.DATE_RANGE) {
|
|
21
|
-
/** Add support for csv strings */
|
|
22
|
-
const finalValue = typeof value === "string" ? value.split(",") : value;
|
|
23
|
-
return (React.createElement("div", { className: `${prefix}--bmrg-date-input` },
|
|
24
|
-
labelValue && (React.createElement("div", { className: `${prefix}--label ${prefix}--bmrg-date-input__label` },
|
|
25
|
-
React.createElement("div", null, labelValue),
|
|
26
|
-
tooltipContent && (React.createElement("div", { className: tooltipClassName },
|
|
27
|
-
React.createElement(TooltipHover, { tooltipContent: tooltipContent, ...tooltipProps },
|
|
28
|
-
React.createElement(Information, { size: 16, fill: "currentColor" })))))),
|
|
29
|
-
React.createElement(DatePicker, { key: id, allowInput: !readOnly, className: `${prefix}--bmrg-date-picker`, dateFormat: dateFormat, datePickerType: "range", maxDate: max, minDate: min, onChange: typeof onCalendarChange === "function" ? onCalendarChange : onChange, value: finalValue, ...datePickerProps },
|
|
30
|
-
React.createElement(DatePickerInput, { id: `${id}-start`, autoComplete: "off", disabled: disabled || readOnly, invalid: invalid, labelText: "", readOnly: readOnly, ref: ref, style: { width: "100%" }, pattern: ".*", ...dateInputProps }),
|
|
31
|
-
React.createElement(DatePickerInput, { id: `${id}-end`, autoComplete: "off", disabled: disabled || readOnly, invalid: invalid, labelText: "", readOnly: readOnly, ref: ref, style: { width: "100%" }, pattern: ".*", ...dateInputProps })),
|
|
32
|
-
helperText && !invalid && (React.createElement("div", { id: dateInputHelperId, className: helperClasses }, helperText))));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return (React.createElement("div", { className: `${prefix}--bmrg-date-input` },
|
|
36
|
-
React.createElement(DatePicker, { key: id, allowInput: !readOnly, className: `${prefix}--bmrg-date-picker`, dateFormat: dateFormat, datePickerType: "single", maxDate: max, minDate: min, onChange: onCalendarChange, value: value, ...datePickerProps },
|
|
37
|
-
React.createElement(DatePickerInput, { id: id, disabled: disabled || readOnly, invalid: invalid, onChange: onChange, labelText: labelValue && (React.createElement("div", { className: `${prefix}--bmrg-date-input__label` },
|
|
38
|
-
React.createElement("div", null, labelValue),
|
|
39
|
-
tooltipContent && (React.createElement("div", { className: tooltipClassName },
|
|
40
|
-
React.createElement(TooltipHover, { tooltipContent: tooltipContent, ...tooltipProps },
|
|
41
|
-
React.createElement(Information, { size: 16, fill: "currentColor" })))))), readOnly: readOnly, ref: ref, style: { width: "100%" }, pattern: ".*", ...dateInputProps })),
|
|
42
|
-
helperText && !invalid && (React.createElement("div", { id: dateInputHelperId, className: helperClasses }, helperText))));
|
|
43
|
-
}
|
|
9
|
+
/*
|
|
10
|
+
IBM Confidential
|
|
11
|
+
694970X, 69497O0
|
|
12
|
+
© Copyright IBM Corp. 2022, 2024
|
|
13
|
+
*/
|
|
14
|
+
const DateInputComponent = React.forwardRef(function DateInputComponent({ id, dateFormat, datePickerProps = {}, disabled, helperText, invalid, label, labelText, max, min, onCalendarChange, onChange, readOnly, tooltipClassName = `${prefix}--bmrg-date-input__tooltip`, tooltipContent, tooltipProps = { direction: "top" }, type = DATE_TYPES.DATE, value, ...dateInputProps }, ref) {
|
|
15
|
+
const labelValue = label || labelText;
|
|
16
|
+
const dateInputHelperId = !helperText ? undefined : `date-input-helper-text-${id}`;
|
|
17
|
+
const helperClasses = cx(`${prefix}--form__helper-text`, {
|
|
18
|
+
[`${prefix}--form__helper-text--disabled`]: disabled,
|
|
19
|
+
});
|
|
20
|
+
if (type === DATE_TYPES.DATE_RANGE) {
|
|
21
|
+
/** Add support for csv strings */
|
|
22
|
+
const finalValue = typeof value === "string" ? value.split(",") : value;
|
|
23
|
+
return (React.createElement("div", { className: `${prefix}--bmrg-date-input` },
|
|
24
|
+
labelValue && (React.createElement("div", { className: `${prefix}--label ${prefix}--bmrg-date-input__label` },
|
|
25
|
+
React.createElement("div", null, labelValue),
|
|
26
|
+
tooltipContent && (React.createElement("div", { className: tooltipClassName },
|
|
27
|
+
React.createElement(TooltipHover, { tooltipContent: tooltipContent, ...tooltipProps },
|
|
28
|
+
React.createElement(Information, { size: 16, fill: "currentColor" })))))),
|
|
29
|
+
React.createElement(DatePicker, { key: id, allowInput: !readOnly, className: `${prefix}--bmrg-date-picker`, dateFormat: dateFormat, datePickerType: "range", maxDate: max, minDate: min, onChange: typeof onCalendarChange === "function" ? onCalendarChange : onChange, value: finalValue, ...datePickerProps },
|
|
30
|
+
React.createElement(DatePickerInput, { id: `${id}-start`, autoComplete: "off", disabled: disabled || readOnly, invalid: invalid, labelText: "", readOnly: readOnly, ref: ref, style: { width: "100%" }, pattern: ".*", ...dateInputProps }),
|
|
31
|
+
React.createElement(DatePickerInput, { id: `${id}-end`, autoComplete: "off", disabled: disabled || readOnly, invalid: invalid, labelText: "", readOnly: readOnly, ref: ref, style: { width: "100%" }, pattern: ".*", ...dateInputProps })),
|
|
32
|
+
helperText && !invalid && (React.createElement("div", { id: dateInputHelperId, className: helperClasses }, helperText))));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return (React.createElement("div", { className: `${prefix}--bmrg-date-input` },
|
|
36
|
+
React.createElement(DatePicker, { key: id, allowInput: !readOnly, className: `${prefix}--bmrg-date-picker`, dateFormat: dateFormat, datePickerType: "single", maxDate: max, minDate: min, onChange: onCalendarChange, value: value, ...datePickerProps },
|
|
37
|
+
React.createElement(DatePickerInput, { id: id, disabled: disabled || readOnly, invalid: invalid, onChange: onChange, labelText: labelValue && (React.createElement("div", { className: `${prefix}--bmrg-date-input__label` },
|
|
38
|
+
React.createElement("div", null, labelValue),
|
|
39
|
+
tooltipContent && (React.createElement("div", { className: tooltipClassName },
|
|
40
|
+
React.createElement(TooltipHover, { tooltipContent: tooltipContent, ...tooltipProps },
|
|
41
|
+
React.createElement(Information, { size: 16, fill: "currentColor" })))))), readOnly: readOnly, ref: ref, style: { width: "100%" }, pattern: ".*", ...dateInputProps })),
|
|
42
|
+
helperText && !invalid && (React.createElement("div", { id: dateInputHelperId, className: helperClasses }, helperText))));
|
|
43
|
+
}
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
export { DateInputComponent as default };
|