@boomerang-io/carbon-addons-boomerang-react 4.6.11-beta.8 → 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 -241
- 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 +190 -168
- package/dist/cjs/components/Header/HeaderAppSwitcher.js +94 -102
- 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 +327 -0
- 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 -89
- 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 +220 -243
- 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 +190 -168
- package/dist/esm/components/Header/HeaderAppSwitcher.js +94 -102
- 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 +318 -0
- 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 +96 -90
- 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 -1309
- 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 -0
- 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 -402
- 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
|
@@ -2,44 +2,44 @@ import React, { useRef, useState, useEffect } from 'react';
|
|
|
2
2
|
import cx from 'classnames';
|
|
3
3
|
import { prefix } from '../settings.js';
|
|
4
4
|
|
|
5
|
-
/*
|
|
6
|
-
IBM Confidential
|
|
7
|
-
694970X, 69497O0
|
|
8
|
-
© Copyright IBM Corp. 2022, 2024
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Copyright IBM Corp. 2016, 2018
|
|
12
|
-
*
|
|
13
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
-
* LICENSE file in the root directory of this source tree.
|
|
15
|
-
*/
|
|
16
|
-
function useIsTruncated(ref) {
|
|
17
|
-
const [isTruncated, setIsTruncated] = useState(false);
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
const { offsetWidth, scrollWidth } = ref.current;
|
|
20
|
-
setIsTruncated(offsetWidth < scrollWidth);
|
|
21
|
-
}, [ref, setIsTruncated]);
|
|
22
|
-
return isTruncated;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* `ListBoxMenuItem` is a helper component for managing the container class
|
|
26
|
-
* name, alongside any classes for any corresponding states, for a generic list
|
|
27
|
-
* box menu item.
|
|
28
|
-
*/
|
|
29
|
-
const ListBoxMenuItem = React.forwardRef(function ListBoxMenuItem({ children, isActive, isHighlighted, title, ...rest }, forwardedRef) {
|
|
30
|
-
const ref = useRef(null);
|
|
31
|
-
const isTruncated = useIsTruncated(forwardedRef?.menuItemOptionRef || ref);
|
|
32
|
-
const className = cx(`${prefix}--list-box__menu-item`, {
|
|
33
|
-
[`${prefix}--list-box__menu-item--active`]: isActive,
|
|
34
|
-
[`${prefix}--list-box__menu-item--highlighted`]: isHighlighted,
|
|
35
|
-
});
|
|
36
|
-
return (React.createElement("div", { ...rest, className: className, title: isTruncated ? title : undefined },
|
|
37
|
-
React.createElement("div", { className: `${prefix}--list-box__menu-item__option`, ref: forwardedRef?.menuItemOptionRef || ref }, children)));
|
|
38
|
-
});
|
|
39
|
-
ListBoxMenuItem.displayName = "ListBoxMenuItem";
|
|
40
|
-
ListBoxMenuItem.defaultProps = {
|
|
41
|
-
isActive: false,
|
|
42
|
-
isHighlighted: false,
|
|
5
|
+
/*
|
|
6
|
+
IBM Confidential
|
|
7
|
+
694970X, 69497O0
|
|
8
|
+
© Copyright IBM Corp. 2022, 2024
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Copyright IBM Corp. 2016, 2018
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
function useIsTruncated(ref) {
|
|
17
|
+
const [isTruncated, setIsTruncated] = useState(false);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const { offsetWidth, scrollWidth } = ref.current;
|
|
20
|
+
setIsTruncated(offsetWidth < scrollWidth);
|
|
21
|
+
}, [ref, setIsTruncated]);
|
|
22
|
+
return isTruncated;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* `ListBoxMenuItem` is a helper component for managing the container class
|
|
26
|
+
* name, alongside any classes for any corresponding states, for a generic list
|
|
27
|
+
* box menu item.
|
|
28
|
+
*/
|
|
29
|
+
const ListBoxMenuItem = React.forwardRef(function ListBoxMenuItem({ children, isActive, isHighlighted, title, ...rest }, forwardedRef) {
|
|
30
|
+
const ref = useRef(null);
|
|
31
|
+
const isTruncated = useIsTruncated(forwardedRef?.menuItemOptionRef || ref);
|
|
32
|
+
const className = cx(`${prefix}--list-box__menu-item`, {
|
|
33
|
+
[`${prefix}--list-box__menu-item--active`]: isActive,
|
|
34
|
+
[`${prefix}--list-box__menu-item--highlighted`]: isHighlighted,
|
|
35
|
+
});
|
|
36
|
+
return (React.createElement("div", { ...rest, className: className, title: isTruncated ? title : undefined },
|
|
37
|
+
React.createElement("div", { className: `${prefix}--list-box__menu-item__option`, ref: forwardedRef?.menuItemOptionRef || ref }, children)));
|
|
38
|
+
});
|
|
39
|
+
ListBoxMenuItem.displayName = "ListBoxMenuItem";
|
|
40
|
+
ListBoxMenuItem.defaultProps = {
|
|
41
|
+
isActive: false,
|
|
42
|
+
isHighlighted: false,
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
export { ListBoxMenuItem as default };
|
|
@@ -5,70 +5,70 @@ import { Enter } from '../keyboard/keys.js';
|
|
|
5
5
|
import { match } from '../keyboard/match.js';
|
|
6
6
|
import { prefix } from '../settings.js';
|
|
7
7
|
|
|
8
|
-
/*
|
|
9
|
-
IBM Confidential
|
|
10
|
-
694970X, 69497O0
|
|
11
|
-
© Copyright IBM Corp. 2022, 2024
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Copyright IBM Corp. 2016, 2018
|
|
15
|
-
*
|
|
16
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
17
|
-
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* `ListBoxSelection` is used to provide controls for clearing a selection, in
|
|
21
|
-
* addition to conditionally rendering a badge if the control has more than one
|
|
22
|
-
* selection.
|
|
23
|
-
*/
|
|
24
|
-
function ListBoxSelection({ clearSelection, selectionCount, translateWithId: t = (id) => defaultTranslations[id], disabled, onClearSelection, }) {
|
|
25
|
-
const className = cx(`${prefix}--list-box__selection`, {
|
|
26
|
-
[`${prefix}--tag--filter`]: selectionCount,
|
|
27
|
-
[`${prefix}--list-box__selection--multi`]: selectionCount,
|
|
28
|
-
});
|
|
29
|
-
const handleOnClick = (event) => {
|
|
30
|
-
event.stopPropagation();
|
|
31
|
-
if (disabled) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
clearSelection(event);
|
|
35
|
-
if (onClearSelection) {
|
|
36
|
-
onClearSelection(event);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const handleOnKeyDown = (event) => {
|
|
40
|
-
event.stopPropagation();
|
|
41
|
-
if (disabled) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
// When a user hits ENTER, we'll clear the selection
|
|
45
|
-
if (match(event, Enter)) {
|
|
46
|
-
clearSelection(event);
|
|
47
|
-
if (onClearSelection) {
|
|
48
|
-
onClearSelection(event);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const description = selectionCount ? t("clear.all") : t("clear.selection");
|
|
53
|
-
const tagClasses = cx(`${prefix}--tag`, `${prefix}--tag--filter`, `${prefix}--tag--high-contrast`, {
|
|
54
|
-
[`${prefix}--tag--disabled`]: disabled,
|
|
55
|
-
});
|
|
56
|
-
return selectionCount ? (React.createElement("div", { className: tagClasses },
|
|
57
|
-
React.createElement("span", { className: `${prefix}--tag__label`, title: String(selectionCount) }, selectionCount),
|
|
58
|
-
React.createElement("div", { role: "button", tabIndex: disabled ? -1 : 0, className: `${prefix}--tag__close-icon`, onClick: handleOnClick, onKeyDown: handleOnKeyDown,
|
|
59
|
-
// @ts-expect-error TS(2322)
|
|
60
|
-
disabled: disabled, "aria-label": t("clear.all"), title: description },
|
|
61
|
-
React.createElement(Close, null)))) : (React.createElement("div", { role: "button", className: className, tabIndex: disabled ? -1 : 0, onClick: handleOnClick, onKeyDown: handleOnKeyDown, "aria-label": description, title: description },
|
|
62
|
-
selectionCount,
|
|
63
|
-
React.createElement(Close, null)));
|
|
64
|
-
}
|
|
65
|
-
const translationIds = {
|
|
66
|
-
"clear.all": "clear.all",
|
|
67
|
-
"clear.selection": "clear.selection",
|
|
68
|
-
};
|
|
69
|
-
const defaultTranslations = {
|
|
70
|
-
[translationIds["clear.all"]]: "Clear all selected items",
|
|
71
|
-
[translationIds["clear.selection"]]: "Clear selected item",
|
|
8
|
+
/*
|
|
9
|
+
IBM Confidential
|
|
10
|
+
694970X, 69497O0
|
|
11
|
+
© Copyright IBM Corp. 2022, 2024
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Copyright IBM Corp. 2016, 2018
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* `ListBoxSelection` is used to provide controls for clearing a selection, in
|
|
21
|
+
* addition to conditionally rendering a badge if the control has more than one
|
|
22
|
+
* selection.
|
|
23
|
+
*/
|
|
24
|
+
function ListBoxSelection({ clearSelection, selectionCount, translateWithId: t = (id) => defaultTranslations[id], disabled, onClearSelection, }) {
|
|
25
|
+
const className = cx(`${prefix}--list-box__selection`, {
|
|
26
|
+
[`${prefix}--tag--filter`]: selectionCount,
|
|
27
|
+
[`${prefix}--list-box__selection--multi`]: selectionCount,
|
|
28
|
+
});
|
|
29
|
+
const handleOnClick = (event) => {
|
|
30
|
+
event.stopPropagation();
|
|
31
|
+
if (disabled) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
clearSelection(event);
|
|
35
|
+
if (onClearSelection) {
|
|
36
|
+
onClearSelection(event);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const handleOnKeyDown = (event) => {
|
|
40
|
+
event.stopPropagation();
|
|
41
|
+
if (disabled) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// When a user hits ENTER, we'll clear the selection
|
|
45
|
+
if (match(event, Enter)) {
|
|
46
|
+
clearSelection(event);
|
|
47
|
+
if (onClearSelection) {
|
|
48
|
+
onClearSelection(event);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const description = selectionCount ? t("clear.all") : t("clear.selection");
|
|
53
|
+
const tagClasses = cx(`${prefix}--tag`, `${prefix}--tag--filter`, `${prefix}--tag--high-contrast`, {
|
|
54
|
+
[`${prefix}--tag--disabled`]: disabled,
|
|
55
|
+
});
|
|
56
|
+
return selectionCount ? (React.createElement("div", { className: tagClasses },
|
|
57
|
+
React.createElement("span", { className: `${prefix}--tag__label`, title: String(selectionCount) }, selectionCount),
|
|
58
|
+
React.createElement("div", { role: "button", tabIndex: disabled ? -1 : 0, className: `${prefix}--tag__close-icon`, onClick: handleOnClick, onKeyDown: handleOnKeyDown,
|
|
59
|
+
// @ts-expect-error TS(2322)
|
|
60
|
+
disabled: disabled, "aria-label": t("clear.all"), title: description },
|
|
61
|
+
React.createElement(Close, null)))) : (React.createElement("div", { role: "button", className: className, tabIndex: disabled ? -1 : 0, onClick: handleOnClick, onKeyDown: handleOnKeyDown, "aria-label": description, title: description },
|
|
62
|
+
selectionCount,
|
|
63
|
+
React.createElement(Close, null)));
|
|
64
|
+
}
|
|
65
|
+
const translationIds = {
|
|
66
|
+
"clear.all": "clear.all",
|
|
67
|
+
"clear.selection": "clear.selection",
|
|
68
|
+
};
|
|
69
|
+
const defaultTranslations = {
|
|
70
|
+
[translationIds["clear.all"]]: "Clear all selected items",
|
|
71
|
+
[translationIds["clear.selection"]]: "Clear selected item",
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
export { ListBoxSelection as default, translationIds };
|
|
@@ -5,14 +5,14 @@ export { default as ListBoxMenuIcon } from './ListBoxMenuIcon.js';
|
|
|
5
5
|
export { default as ListBoxMenuItem } from './ListBoxMenuItem.js';
|
|
6
6
|
export { default as ListBoxSelection } from './ListBoxSelection.js';
|
|
7
7
|
|
|
8
|
-
/*
|
|
9
|
-
IBM Confidential
|
|
10
|
-
694970X, 69497O0
|
|
11
|
-
© Copyright IBM Corp. 2022, 2024
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Copyright IBM Corp. 2016, 2018
|
|
15
|
-
*
|
|
16
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
17
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
/*
|
|
9
|
+
IBM Confidential
|
|
10
|
+
694970X, 69497O0
|
|
11
|
+
© Copyright IBM Corp. 2022, 2024
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Copyright IBM Corp. 2016, 2018
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
18
|
*/
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/*
|
|
2
|
-
IBM Confidential
|
|
3
|
-
694970X, 69497O0
|
|
4
|
-
© Copyright IBM Corp. 2022, 2024
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Copyright IBM Corp. 2016, 2018
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
10
|
-
* LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/
|
|
12
|
-
const Enter = {
|
|
13
|
-
key: "Enter",
|
|
14
|
-
which: 13,
|
|
15
|
-
keyCode: 13,
|
|
16
|
-
code: "Enter",
|
|
1
|
+
/*
|
|
2
|
+
IBM Confidential
|
|
3
|
+
694970X, 69497O0
|
|
4
|
+
© Copyright IBM Corp. 2022, 2024
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Copyright IBM Corp. 2016, 2018
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
const Enter = {
|
|
13
|
+
key: "Enter",
|
|
14
|
+
which: 13,
|
|
15
|
+
keyCode: 13,
|
|
16
|
+
code: "Enter",
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export { Enter };
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
/*
|
|
2
|
-
IBM Confidential
|
|
3
|
-
694970X, 69497O0
|
|
4
|
-
© Copyright IBM Corp. 2022, 2024
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Copyright IBM Corp. 2016, 2018
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
10
|
-
* LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* @typedef Key
|
|
14
|
-
* @property key {Array<string>|string}
|
|
15
|
-
* @property which {number}
|
|
16
|
-
* @property keyCode {number}
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* Check to see if at least one key code matches the key code of the
|
|
20
|
-
* given event.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* import * as keys from '../keys';
|
|
24
|
-
* import { matches } from '../match';
|
|
25
|
-
*
|
|
26
|
-
* function handleOnKeyDown(event) {
|
|
27
|
-
* if (matches(event, [keys.Enter, keys.Space]) {
|
|
28
|
-
* // ...
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
*
|
|
32
|
-
* @param {Event} event
|
|
33
|
-
* @param {Array<Key>} keysToMatch
|
|
34
|
-
* @returns {boolean}
|
|
35
|
-
*/
|
|
36
|
-
/**
|
|
37
|
-
* Check to see if the given key matches the corresponding keyboard event. Also
|
|
38
|
-
* supports passing in the value directly if you can't used the given event.
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* import * as keys from '../keys';
|
|
42
|
-
* import { matches } from '../match';
|
|
43
|
-
*
|
|
44
|
-
* function handleOnKeyDown(event) {
|
|
45
|
-
* if (match(event, keys.Enter) {
|
|
46
|
-
* // ...
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
*
|
|
50
|
-
* @param {Event|number|string} eventOrCode
|
|
51
|
-
* @param {Key} key
|
|
52
|
-
* @returns {boolean}
|
|
53
|
-
*/
|
|
54
|
-
function match(eventOrCode, { key, which, keyCode, code } = {}) {
|
|
55
|
-
if (typeof eventOrCode === "string") {
|
|
56
|
-
return eventOrCode === key;
|
|
57
|
-
}
|
|
58
|
-
if (typeof eventOrCode === "number") {
|
|
59
|
-
return eventOrCode === which || eventOrCode === keyCode;
|
|
60
|
-
}
|
|
61
|
-
if (eventOrCode.key && Array.isArray(key)) {
|
|
62
|
-
return key.indexOf(eventOrCode.key) !== -1;
|
|
63
|
-
}
|
|
64
|
-
return (eventOrCode.key === key ||
|
|
65
|
-
eventOrCode.which === which ||
|
|
66
|
-
eventOrCode.keyCode === keyCode ||
|
|
67
|
-
eventOrCode.code === code);
|
|
1
|
+
/*
|
|
2
|
+
IBM Confidential
|
|
3
|
+
694970X, 69497O0
|
|
4
|
+
© Copyright IBM Corp. 2022, 2024
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Copyright IBM Corp. 2016, 2018
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @typedef Key
|
|
14
|
+
* @property key {Array<string>|string}
|
|
15
|
+
* @property which {number}
|
|
16
|
+
* @property keyCode {number}
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Check to see if at least one key code matches the key code of the
|
|
20
|
+
* given event.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import * as keys from '../keys';
|
|
24
|
+
* import { matches } from '../match';
|
|
25
|
+
*
|
|
26
|
+
* function handleOnKeyDown(event) {
|
|
27
|
+
* if (matches(event, [keys.Enter, keys.Space]) {
|
|
28
|
+
* // ...
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* @param {Event} event
|
|
33
|
+
* @param {Array<Key>} keysToMatch
|
|
34
|
+
* @returns {boolean}
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Check to see if the given key matches the corresponding keyboard event. Also
|
|
38
|
+
* supports passing in the value directly if you can't used the given event.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* import * as keys from '../keys';
|
|
42
|
+
* import { matches } from '../match';
|
|
43
|
+
*
|
|
44
|
+
* function handleOnKeyDown(event) {
|
|
45
|
+
* if (match(event, keys.Enter) {
|
|
46
|
+
* // ...
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* @param {Event|number|string} eventOrCode
|
|
51
|
+
* @param {Key} key
|
|
52
|
+
* @returns {boolean}
|
|
53
|
+
*/
|
|
54
|
+
function match(eventOrCode, { key, which, keyCode, code } = {}) {
|
|
55
|
+
if (typeof eventOrCode === "string") {
|
|
56
|
+
return eventOrCode === key;
|
|
57
|
+
}
|
|
58
|
+
if (typeof eventOrCode === "number") {
|
|
59
|
+
return eventOrCode === which || eventOrCode === keyCode;
|
|
60
|
+
}
|
|
61
|
+
if (eventOrCode.key && Array.isArray(key)) {
|
|
62
|
+
return key.indexOf(eventOrCode.key) !== -1;
|
|
63
|
+
}
|
|
64
|
+
return (eventOrCode.key === key ||
|
|
65
|
+
eventOrCode.which === which ||
|
|
66
|
+
eventOrCode.keyCode === keyCode ||
|
|
67
|
+
eventOrCode.code === code);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export { match };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/*
|
|
2
|
-
IBM Confidential
|
|
3
|
-
694970X, 69497O0
|
|
4
|
-
© Copyright IBM Corp. 2022, 2024
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Determine if keydown event is accessible
|
|
8
|
-
* @param {Object} event the first array
|
|
9
|
-
* @param {Array} arr2 the second array
|
|
10
|
-
* @returns {boolean} true if both arrays have the same contents, otherwise false
|
|
11
|
-
*/
|
|
12
|
-
const isAccessibleKeyDownEvent = (evt) => {
|
|
13
|
-
return evt.which === 13 || evt.which === 32 || evt.type === "click";
|
|
1
|
+
/*
|
|
2
|
+
IBM Confidential
|
|
3
|
+
694970X, 69497O0
|
|
4
|
+
© Copyright IBM Corp. 2022, 2024
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Determine if keydown event is accessible
|
|
8
|
+
* @param {Object} event the first array
|
|
9
|
+
* @param {Array} arr2 the second array
|
|
10
|
+
* @returns {boolean} true if both arrays have the same contents, otherwise false
|
|
11
|
+
*/
|
|
12
|
+
const isAccessibleKeyDownEvent = (evt) => {
|
|
13
|
+
return evt.which === 13 || evt.which === 32 || evt.type === "click";
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export { isAccessibleKeyDownEvent };
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
/*
|
|
2
|
-
IBM Confidential
|
|
3
|
-
694970X, 69497O0
|
|
4
|
-
© Copyright IBM Corp. 2022, 2024
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Copyright IBM Corp. 2016, 2018
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
10
|
-
* LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Create an adapter that converts an object of props with potentially deprecated
|
|
14
|
-
* prop names to the replacement prop names in a newer version. Useful for guarding
|
|
15
|
-
* against breaking changes when a prop has been renamed
|
|
16
|
-
*
|
|
17
|
-
* @param {Array} spec - an array of options which specify a text or regex
|
|
18
|
-
* matcher alongside a replacement if there is a match
|
|
19
|
-
* @returns {Function}
|
|
20
|
-
*/
|
|
21
|
-
function createPropAdapter(spec) {
|
|
22
|
-
// if props aren't passed in we should default the prop to empty object
|
|
23
|
-
return (input = {}) => {
|
|
24
|
-
const output = {};
|
|
25
|
-
Object.keys(input).forEach((key) => {
|
|
26
|
-
const match = spec.find(([regex]) => {
|
|
27
|
-
return key.match(regex);
|
|
28
|
-
});
|
|
29
|
-
if (match) {
|
|
30
|
-
const [regex, replacer] = match;
|
|
31
|
-
output[key.replace(regex, replacer)] = input[key];
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
output[key] = input[key];
|
|
35
|
-
});
|
|
36
|
-
return output;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* TODO: REMOVE IN v11
|
|
41
|
-
* props staring with "default..." were changed to "initial..." in Downshift v3
|
|
42
|
-
*
|
|
43
|
-
* @see https://github.com/downshift-js/downshift/releases/tag/v3.0.0
|
|
44
|
-
*/
|
|
1
|
+
/*
|
|
2
|
+
IBM Confidential
|
|
3
|
+
694970X, 69497O0
|
|
4
|
+
© Copyright IBM Corp. 2022, 2024
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Copyright IBM Corp. 2016, 2018
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Create an adapter that converts an object of props with potentially deprecated
|
|
14
|
+
* prop names to the replacement prop names in a newer version. Useful for guarding
|
|
15
|
+
* against breaking changes when a prop has been renamed
|
|
16
|
+
*
|
|
17
|
+
* @param {Array} spec - an array of options which specify a text or regex
|
|
18
|
+
* matcher alongside a replacement if there is a match
|
|
19
|
+
* @returns {Function}
|
|
20
|
+
*/
|
|
21
|
+
function createPropAdapter(spec) {
|
|
22
|
+
// if props aren't passed in we should default the prop to empty object
|
|
23
|
+
return (input = {}) => {
|
|
24
|
+
const output = {};
|
|
25
|
+
Object.keys(input).forEach((key) => {
|
|
26
|
+
const match = spec.find(([regex]) => {
|
|
27
|
+
return key.match(regex);
|
|
28
|
+
});
|
|
29
|
+
if (match) {
|
|
30
|
+
const [regex, replacer] = match;
|
|
31
|
+
output[key.replace(regex, replacer)] = input[key];
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
output[key] = input[key];
|
|
35
|
+
});
|
|
36
|
+
return output;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* TODO: REMOVE IN v11
|
|
41
|
+
* props staring with "default..." were changed to "initial..." in Downshift v3
|
|
42
|
+
*
|
|
43
|
+
* @see https://github.com/downshift-js/downshift/releases/tag/v3.0.0
|
|
44
|
+
*/
|
|
45
45
|
const mapDownshiftProps = createPropAdapter([[/^default/g, "initial"]]);
|
|
46
46
|
|
|
47
47
|
export { mapDownshiftProps };
|
package/dist/esm/tools/isUrl.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
/*
|
|
2
|
-
IBM Confidential
|
|
3
|
-
694970X, 69497O0
|
|
4
|
-
© Copyright IBM Corp. 2022, 2024
|
|
5
|
-
*/
|
|
6
|
-
/* eslint-disable */
|
|
7
|
-
/**
|
|
8
|
-
* https://github.com/segmentio/is-url
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* RegExps.
|
|
12
|
-
* A URL must match #1 and then at least one of #2/#3.
|
|
13
|
-
* Use two levels of REs to avoid REDOS.
|
|
14
|
-
*/
|
|
15
|
-
const protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
|
|
16
|
-
const localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/;
|
|
17
|
-
const nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/;
|
|
18
|
-
/**
|
|
19
|
-
* Loosely validate a URL `string`.
|
|
20
|
-
*
|
|
21
|
-
* @param {String} string
|
|
22
|
-
* @return {Boolean}
|
|
23
|
-
*/
|
|
24
|
-
function isUrl(string) {
|
|
25
|
-
if (typeof string !== "string") {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
const match = string.match(protocolAndDomainRE);
|
|
29
|
-
if (!match) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
const everythingAfterProtocol = match[1];
|
|
33
|
-
if (!everythingAfterProtocol) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
if (localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol)) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
1
|
+
/*
|
|
2
|
+
IBM Confidential
|
|
3
|
+
694970X, 69497O0
|
|
4
|
+
© Copyright IBM Corp. 2022, 2024
|
|
5
|
+
*/
|
|
6
|
+
/* eslint-disable */
|
|
7
|
+
/**
|
|
8
|
+
* https://github.com/segmentio/is-url
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* RegExps.
|
|
12
|
+
* A URL must match #1 and then at least one of #2/#3.
|
|
13
|
+
* Use two levels of REs to avoid REDOS.
|
|
14
|
+
*/
|
|
15
|
+
const protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
|
|
16
|
+
const localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/;
|
|
17
|
+
const nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/;
|
|
18
|
+
/**
|
|
19
|
+
* Loosely validate a URL `string`.
|
|
20
|
+
*
|
|
21
|
+
* @param {String} string
|
|
22
|
+
* @return {Boolean}
|
|
23
|
+
*/
|
|
24
|
+
function isUrl(string) {
|
|
25
|
+
if (typeof string !== "string") {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const match = string.match(protocolAndDomainRE);
|
|
29
|
+
if (!match) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const everythingAfterProtocol = match[1];
|
|
33
|
+
if (!everythingAfterProtocol) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol)) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export { isUrl as default };
|