@carbon/react 1.102.0 → 1.103.0
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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1011 -1011
- package/es/components/Breadcrumb/BreadcrumbItem.js +1 -1
- package/es/components/Button/Button.Skeleton.js +2 -1
- package/es/components/Button/Button.d.ts +4 -4
- package/es/components/Button/Button.js +4 -4
- package/es/components/Button/index.js +1 -1
- package/es/components/ButtonSet/ButtonSet.js +1 -1
- package/es/components/Checkbox/index.js +1 -1
- package/es/components/ComboBox/ComboBox.js +2 -2
- package/es/components/ComposedModal/ComposedModal.js +0 -3
- package/es/components/ComposedModal/ComposedModalPresence.d.ts +9 -1
- package/es/components/ComposedModal/ComposedModalPresence.js +14 -1
- package/es/components/ComposedModal/index.d.ts +1 -1
- package/es/components/ContainedList/index.js +1 -1
- package/es/components/DataTable/TableHeader.js +1 -1
- package/es/components/DataTable/TableRow.js +1 -1
- package/es/components/DataTable/TableToolbarMenu.js +1 -1
- package/es/components/DatePicker/DatePicker.Skeleton.d.ts +8 -5
- package/es/components/DatePicker/DatePicker.Skeleton.js +2 -2
- package/es/components/DatePicker/DatePicker.d.ts +4 -2
- package/es/components/DatePicker/DatePicker.js +9 -6
- package/es/components/DatePicker/index.js +1 -1
- package/es/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
- package/es/components/DatePicker/plugins/rangePlugin.js +2 -1
- package/es/components/{UIShell/_utils.d.ts → DatePicker/utils.d.ts} +2 -2
- package/es/components/{UIShell/_utils.js → DatePicker/utils.js} +2 -2
- package/es/components/DatePickerInput/DatePickerInput.js +1 -1
- package/es/components/Dialog/Dialog.js +1 -1
- package/es/components/Dropdown/index.js +1 -1
- package/es/components/ExpandableSearch/ExpandableSearch.js +1 -1
- package/es/components/FeatureFlags/index.d.ts +8 -18
- package/es/components/FeatureFlags/index.js +23 -103
- package/es/components/FileUploader/FileUploader.Skeleton.js +1 -1
- package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderButton.js +3 -7
- package/es/components/Icon/Icon.Skeleton.js +1 -1
- package/es/components/IconIndicator/index.js +1 -1
- package/es/components/Menu/MenuItem.js +1 -1
- package/es/components/Modal/ModalPresence.d.ts +9 -1
- package/es/components/Modal/ModalPresence.js +14 -1
- package/es/components/Modal/index.d.ts +2 -2
- package/es/components/MultiSelect/MultiSelect.js +9 -10
- package/es/components/Notification/Notification.js +1 -1
- package/es/components/NumberInput/NumberInput.js +15 -13
- package/es/components/OverflowMenu/OverflowMenu.d.ts +1 -1
- package/es/components/OverflowMenu/OverflowMenu.js +3 -5
- package/es/components/OverflowMenuV2/index.js +1 -1
- package/es/components/PageHeader/PageHeader.js +2 -23
- package/es/components/Pagination/Pagination.Skeleton.js +1 -1
- package/es/components/Pagination/Pagination.d.ts +4 -0
- package/es/components/Pagination/Pagination.js +6 -1
- package/es/components/Pagination/experimental/Pagination.js +12 -1
- package/es/components/Popover/index.js +1 -1
- package/es/components/RadioButton/RadioButton.Skeleton.js +1 -1
- package/es/components/Search/index.js +1 -1
- package/es/components/Select/index.js +1 -1
- package/es/components/ShapeIndicator/index.js +1 -1
- package/es/components/Slider/Slider.js +230 -249
- package/es/components/Slider/SliderHandles.js +65 -53
- package/es/components/Switch/IconSwitch.js +1 -1
- package/es/components/Tabs/Tabs.js +10 -12
- package/es/components/Tag/Tag.Skeleton.js +1 -1
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/TextArea/index.js +1 -1
- package/es/components/TextInput/index.js +1 -1
- package/es/components/Tile/Tile.d.ts +2 -2
- package/es/components/Tile/Tile.js +7 -2
- package/es/components/Toggle/Toggle.Skeleton.js +1 -1
- package/es/components/Toggletip/index.js +1 -1
- package/es/components/UIShell/HeaderMenu.js +1 -1
- package/es/components/UIShell/SideNav.d.ts +1 -4
- package/es/components/UIShell/SideNav.js +10 -25
- package/es/components/UIShell/SideNavContext.d.ts +17 -0
- package/es/components/UIShell/SideNavContext.js +24 -0
- package/es/components/UIShell/SideNavItems.d.ts +1 -1
- package/es/components/UIShell/SideNavItems.js +12 -16
- package/es/components/UIShell/SideNavLink.js +8 -4
- package/es/components/UIShell/SideNavMenu.js +7 -5
- package/es/index.js +30 -30
- package/es/internal/useNoInteractiveChildren.js +25 -30
- package/es/internal/usePresence.d.ts +1 -1
- package/es/internal/usePresence.js +14 -17
- package/lib/components/Button/Button.Skeleton.js +2 -1
- package/lib/components/Button/Button.d.ts +4 -4
- package/lib/components/Button/Button.js +4 -4
- package/lib/components/Button/index.js +1 -1
- package/lib/components/ButtonSet/ButtonSet.js +1 -1
- package/lib/components/Checkbox/index.js +1 -1
- package/lib/components/ComboBox/ComboBox.js +2 -2
- package/lib/components/ComposedModal/ComposedModal.js +0 -3
- package/lib/components/ComposedModal/ComposedModalPresence.d.ts +9 -1
- package/lib/components/ComposedModal/ComposedModalPresence.js +14 -0
- package/lib/components/ComposedModal/index.d.ts +1 -1
- package/lib/components/ContainedList/index.js +0 -3
- package/lib/components/DataTable/TableToolbarMenu.js +1 -1
- package/lib/components/DatePicker/DatePicker.Skeleton.d.ts +8 -5
- package/lib/components/DatePicker/DatePicker.Skeleton.js +2 -2
- package/lib/components/DatePicker/DatePicker.d.ts +4 -2
- package/lib/components/DatePicker/DatePicker.js +9 -6
- package/lib/components/DatePicker/index.js +1 -1
- package/lib/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
- package/lib/components/DatePicker/plugins/rangePlugin.js +2 -1
- package/lib/components/{UIShell/_utils.d.ts → DatePicker/utils.d.ts} +2 -2
- package/lib/components/{UIShell/_utils.js → DatePicker/utils.js} +2 -2
- package/lib/components/Dropdown/index.js +1 -1
- package/lib/components/FeatureFlags/index.d.ts +8 -18
- package/lib/components/FeatureFlags/index.js +21 -102
- package/lib/components/FileUploader/FileUploader.Skeleton.js +1 -1
- package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderButton.js +2 -6
- package/lib/components/Icon/Icon.Skeleton.js +0 -3
- package/lib/components/IconIndicator/index.js +0 -3
- package/lib/components/Modal/ModalPresence.d.ts +9 -1
- package/lib/components/Modal/ModalPresence.js +14 -0
- package/lib/components/Modal/index.d.ts +2 -2
- package/lib/components/MultiSelect/MultiSelect.js +8 -9
- package/lib/components/NumberInput/NumberInput.js +14 -12
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +1 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +2 -7
- package/lib/components/OverflowMenuV2/index.js +1 -1
- package/lib/components/PageHeader/PageHeader.js +2 -23
- package/lib/components/Pagination/Pagination.Skeleton.js +0 -3
- package/lib/components/Pagination/Pagination.d.ts +4 -0
- package/lib/components/Pagination/Pagination.js +6 -1
- package/lib/components/Pagination/experimental/Pagination.js +12 -1
- package/lib/components/RadioButton/RadioButton.Skeleton.js +0 -3
- package/lib/components/Search/index.js +1 -1
- package/lib/components/Select/index.js +1 -1
- package/lib/components/ShapeIndicator/index.js +0 -3
- package/lib/components/Slider/Slider.js +229 -248
- package/lib/components/Slider/SliderHandles.js +64 -52
- package/lib/components/Tabs/Tabs.js +9 -11
- package/lib/components/Tag/Tag.Skeleton.js +0 -3
- package/lib/components/TextArea/index.js +1 -1
- package/lib/components/TextInput/index.js +1 -1
- package/lib/components/Tile/Tile.d.ts +2 -2
- package/lib/components/Tile/Tile.js +6 -1
- package/lib/components/Toggle/Toggle.Skeleton.js +0 -3
- package/lib/components/Toggletip/index.js +0 -3
- package/lib/components/UIShell/SideNav.d.ts +1 -4
- package/lib/components/UIShell/SideNav.js +8 -24
- package/lib/components/UIShell/SideNavContext.d.ts +17 -0
- package/lib/components/UIShell/SideNavContext.js +27 -0
- package/lib/components/UIShell/SideNavItems.d.ts +1 -1
- package/lib/components/UIShell/SideNavItems.js +11 -15
- package/lib/components/UIShell/SideNavLink.js +7 -3
- package/lib/components/UIShell/SideNavMenu.js +8 -6
- package/lib/index.js +102 -100
- package/lib/internal/useNoInteractiveChildren.js +25 -30
- package/lib/internal/usePresence.d.ts +1 -1
- package/lib/internal/usePresence.js +13 -16
- package/package.json +5 -5
- package/telemetry.yml +2 -1
|
@@ -30,6 +30,7 @@ var FormContext = require('../FluidForm/FormContext.js');
|
|
|
30
30
|
var iconsReact = require('@carbon/icons-react');
|
|
31
31
|
var utilities = require('@carbon/utilities');
|
|
32
32
|
var DatePickerLocales = require('./DatePickerLocales.js');
|
|
33
|
+
var utils$1 = require('./utils.js');
|
|
33
34
|
|
|
34
35
|
// Weekdays shorthand for English locale
|
|
35
36
|
// Ensure localization exists before trying to access it
|
|
@@ -595,9 +596,9 @@ const DatePicker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
595
596
|
React.useEffect(() => {
|
|
596
597
|
// when value prop is manually reset, this clears the flatpickr calendar instance and text input
|
|
597
598
|
// run if both:
|
|
598
|
-
// 1. value prop is set to
|
|
599
|
+
// 1. value prop is set to an empty value (`""`, `undefined`, `null`, etc) OR an array of all empty values
|
|
599
600
|
// 2. flatpickr instance contains values in its `selectedDates` property so it hasn't already been cleared
|
|
600
|
-
if ((
|
|
601
|
+
if ((utils$1.isEmptyDateValue(value) || Array.isArray(value) && value.every(utils$1.isEmptyDateValue)) && calendarRef.current?.selectedDates.length) {
|
|
601
602
|
calendarRef.current?.clear();
|
|
602
603
|
if (startInputField.current) {
|
|
603
604
|
startInputField.current.value = '';
|
|
@@ -611,7 +612,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
611
612
|
if (calendarRef.current?.set) {
|
|
612
613
|
if (value !== undefined) {
|
|
613
614
|
// To make up for calendarRef.current.setDate not making provision for an empty string or array
|
|
614
|
-
if (value === '' || value === null || Array.isArray(value) && (value.length === 0 || value.every(
|
|
615
|
+
if (value === '' || value === null || Array.isArray(value) && (value.length === 0 || value.every(utils$1.isEmptyDateValue))) {
|
|
615
616
|
// only clear if there are selected dates to avoid unnecessary operations
|
|
616
617
|
if (calendarRef.current.selectedDates.length > 0) {
|
|
617
618
|
calendarRef.current.clear();
|
|
@@ -622,7 +623,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
622
623
|
}
|
|
623
624
|
updateClassNames(calendarRef.current, prefix);
|
|
624
625
|
//for simple date picker w/o calendar; initial mount may not have value
|
|
625
|
-
} else if (!calendarRef.current && value) {
|
|
626
|
+
} else if (!calendarRef.current && typeof value !== 'undefined' && value !== null) {
|
|
626
627
|
startInputField.current.value = value;
|
|
627
628
|
}
|
|
628
629
|
}, [value, prefix, startInputField]);
|
|
@@ -656,8 +657,10 @@ const DatePicker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
656
657
|
});
|
|
657
658
|
DatePicker.propTypes = {
|
|
658
659
|
/**
|
|
659
|
-
* Flatpickr prop passthrough enables direct date input, and when set to
|
|
660
|
-
* we must clear dates manually by resetting the value prop to
|
|
660
|
+
* Flatpickr prop passthrough enables direct date input, and when set to
|
|
661
|
+
* false, we must clear dates manually by resetting the value prop to an empty
|
|
662
|
+
* value (such as `""`, `null`, or `undefined`) or an array of all empty
|
|
663
|
+
* values, making it a controlled input.
|
|
661
664
|
*/
|
|
662
665
|
allowInput: PropTypes.bool,
|
|
663
666
|
/**
|
|
@@ -16,4 +16,4 @@ var DatePicker_Skeleton = require('./DatePicker.Skeleton.js');
|
|
|
16
16
|
|
|
17
17
|
exports.DatePicker = DatePicker.default;
|
|
18
18
|
exports.default = DatePicker.default;
|
|
19
|
-
exports.DatePickerSkeleton = DatePicker_Skeleton.
|
|
19
|
+
exports.DatePickerSkeleton = DatePicker_Skeleton.DatePickerSkeleton;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
10
|
var baseRangePlugin = require('flatpickr/dist/plugins/rangePlugin');
|
|
11
|
+
var utils = require('../utils.js');
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* @param config Plugin configuration.
|
|
@@ -40,7 +41,7 @@ const rangePlugin = (config = {}) => {
|
|
|
40
41
|
const inputToElement = typeof inputTo === 'string' ? document.querySelector(inputTo) : inputTo;
|
|
41
42
|
[inputFrom, inputToElement].forEach((input, i) => {
|
|
42
43
|
if (input && input instanceof HTMLInputElement) {
|
|
43
|
-
input.value =
|
|
44
|
+
input.value = utils.isEmptyDateValue(dates[i]) ? '' : formatDate(new Date(dates[i]), fp.config.dateFormat);
|
|
44
45
|
}
|
|
45
46
|
});
|
|
46
47
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp.
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
export const
|
|
7
|
+
export declare const isEmptyDateValue: (date: unknown) => date is "" | null | undefined;
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const isEmptyDateValue = date => date === '' || date === null || typeof date === 'undefined';
|
|
11
11
|
|
|
12
|
-
exports.
|
|
12
|
+
exports.isEmptyDateValue = isEmptyDateValue;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2015,
|
|
2
|
+
* Copyright IBM Corp. 2015, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import
|
|
8
|
+
import { type ReactNode } from 'react';
|
|
9
9
|
export interface FeatureFlagsProps {
|
|
10
10
|
children?: ReactNode;
|
|
11
11
|
flags?: Record<string, boolean>;
|
|
@@ -20,19 +20,14 @@ export interface FeatureFlagsProps {
|
|
|
20
20
|
enableEnhancedFileUploader?: boolean;
|
|
21
21
|
enablePresence?: boolean;
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Our FeatureFlagContext is used alongside the FeatureFlags component to enable
|
|
25
|
-
* or disable feature flags in a given React tree
|
|
26
|
-
*/
|
|
27
|
-
declare const FeatureFlagContext: React.Context<any>;
|
|
28
23
|
/**
|
|
29
24
|
* Supports an object of feature flag values with the `flags` prop, merging them
|
|
30
25
|
* along with the current `FeatureFlagContext` to provide consumers to check if
|
|
31
26
|
* a feature flag is enabled or disabled in a given React tree
|
|
32
27
|
*/
|
|
33
|
-
declare
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
export declare const FeatureFlags: {
|
|
29
|
+
({ children, flags, enableV12TileDefaultIcons, enableV12TileRadioIcons, enableV12Overflowmenu, enableTreeviewControllable, enableExperimentalFocusWrapWithoutSentinels, enableFocusWrapWithoutSentinels, enableDialogElement, enableV12DynamicFloatingStyles, enableEnhancedFileUploader, enablePresence, }: FeatureFlagsProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
propTypes: {
|
|
36
31
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
37
32
|
/**
|
|
38
33
|
* Provide the feature flags to enabled or disabled in the current Rea,ct tree
|
|
@@ -49,18 +44,13 @@ declare namespace FeatureFlags {
|
|
|
49
44
|
enableEnhancedFileUploader: PropTypes.Requireable<boolean>;
|
|
50
45
|
enablePresence: PropTypes.Requireable<boolean>;
|
|
51
46
|
};
|
|
52
|
-
}
|
|
47
|
+
};
|
|
53
48
|
/**
|
|
54
49
|
* Access whether a given flag is enabled or disabled in a given
|
|
55
50
|
* FeatureFlagContext
|
|
56
|
-
*
|
|
57
|
-
* @returns {boolean}
|
|
58
51
|
*/
|
|
59
|
-
declare
|
|
52
|
+
export declare const useFeatureFlag: (flag: string) => boolean;
|
|
60
53
|
/**
|
|
61
54
|
* Access all feature flag information for the given FeatureFlagContext
|
|
62
|
-
*
|
|
63
|
-
* @returns {FeatureFlagScope}
|
|
64
55
|
*/
|
|
65
|
-
declare
|
|
66
|
-
export { FeatureFlags, FeatureFlagContext, useFeatureFlags, useFeatureFlag };
|
|
56
|
+
export declare const useFeatureFlags: () => import("@carbon/feature-flags/types/FeatureFlagScope").FeatureFlagScope;
|
|
@@ -12,7 +12,6 @@ var PropTypes = require('prop-types');
|
|
|
12
12
|
var React = require('react');
|
|
13
13
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
14
14
|
|
|
15
|
-
// TODO: Can this variable be deleted now? It isn't used anywhere.
|
|
16
15
|
/**
|
|
17
16
|
* Our FeatureFlagContext is used alongside the FeatureFlags component to enable
|
|
18
17
|
* or disable feature flags in a given React tree
|
|
@@ -24,7 +23,7 @@ const FeatureFlagContext = /*#__PURE__*/React.createContext(featureFlags.Feature
|
|
|
24
23
|
* along with the current `FeatureFlagContext` to provide consumers to check if
|
|
25
24
|
* a feature flag is enabled or disabled in a given React tree
|
|
26
25
|
*/
|
|
27
|
-
|
|
26
|
+
const FeatureFlags = ({
|
|
28
27
|
children,
|
|
29
28
|
flags = {},
|
|
30
29
|
enableV12TileDefaultIcons = false,
|
|
@@ -37,46 +36,30 @@ function FeatureFlags({
|
|
|
37
36
|
enableV12DynamicFloatingStyles = false,
|
|
38
37
|
enableEnhancedFileUploader = false,
|
|
39
38
|
enablePresence = false
|
|
40
|
-
}) {
|
|
39
|
+
}) => {
|
|
41
40
|
const parentScope = React.useContext(FeatureFlagContext);
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const [scope, updateScope] = React.useState(() => {
|
|
41
|
+
const scope = React.useMemo(() => {
|
|
42
|
+
const combinedFlags = {
|
|
43
|
+
'enable-v12-tile-default-icons': enableV12TileDefaultIcons,
|
|
44
|
+
'enable-v12-tile-radio-icons': enableV12TileRadioIcons,
|
|
45
|
+
'enable-v12-overflowmenu': enableV12Overflowmenu,
|
|
46
|
+
'enable-treeview-controllable': enableTreeviewControllable,
|
|
47
|
+
'enable-experimental-focus-wrap-without-sentinels': enableExperimentalFocusWrapWithoutSentinels,
|
|
48
|
+
'enable-focus-wrap-without-sentinels': enableFocusWrapWithoutSentinels,
|
|
49
|
+
'enable-dialog-element': enableDialogElement,
|
|
50
|
+
'enable-v12-dynamic-floating-styles': enableV12DynamicFloatingStyles,
|
|
51
|
+
'enable-enhanced-file-uploader': enableEnhancedFileUploader,
|
|
52
|
+
'enable-presence': enablePresence,
|
|
53
|
+
...flags
|
|
54
|
+
};
|
|
57
55
|
const scope = featureFlags.createScope(combinedFlags);
|
|
58
56
|
scope.mergeWithScope(parentScope);
|
|
59
57
|
return scope;
|
|
60
|
-
});
|
|
61
|
-
if (parentScope !== prevParentScope) {
|
|
62
|
-
const scope = featureFlags.createScope(combinedFlags);
|
|
63
|
-
scope.mergeWithScope(parentScope);
|
|
64
|
-
updateScope(scope);
|
|
65
|
-
setPrevParentScope(parentScope);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// We use a custom hook to detect if any of the keys or their values change
|
|
69
|
-
// for flags that are passed in. If they have changed, then we re-create the
|
|
70
|
-
// FeatureFlagScope using the new flags
|
|
71
|
-
useChangedValue(combinedFlags, isEqual, changedFlags => {
|
|
72
|
-
const scope = featureFlags.createScope(changedFlags);
|
|
73
|
-
scope.mergeWithScope(parentScope);
|
|
74
|
-
updateScope(scope);
|
|
75
|
-
});
|
|
58
|
+
}, [enableV12TileDefaultIcons, enableV12TileRadioIcons, enableV12Overflowmenu, enableTreeviewControllable, enableExperimentalFocusWrapWithoutSentinels, enableFocusWrapWithoutSentinels, enableDialogElement, enableV12DynamicFloatingStyles, enableEnhancedFileUploader, enablePresence, flags, parentScope]);
|
|
76
59
|
return /*#__PURE__*/React.createElement(FeatureFlagContext.Provider, {
|
|
77
60
|
value: scope
|
|
78
61
|
}, children);
|
|
79
|
-
}
|
|
62
|
+
};
|
|
80
63
|
FeatureFlags.propTypes = {
|
|
81
64
|
children: PropTypes.node,
|
|
82
65
|
/**
|
|
@@ -95,84 +78,20 @@ FeatureFlags.propTypes = {
|
|
|
95
78
|
enablePresence: PropTypes.bool
|
|
96
79
|
};
|
|
97
80
|
|
|
98
|
-
/**
|
|
99
|
-
* This hook will store previous versions of the given `value` and compare the
|
|
100
|
-
* current value to the previous one using the `compare` function. If the
|
|
101
|
-
* compare function returns true, then the given `callback` is invoked in an
|
|
102
|
-
* effect.
|
|
103
|
-
*
|
|
104
|
-
* @param {any} value
|
|
105
|
-
* @param {Function} compare
|
|
106
|
-
* @param {Function} callback
|
|
107
|
-
*/
|
|
108
|
-
function useChangedValue(value, compare, callback) {
|
|
109
|
-
const initialRender = React.useRef(false);
|
|
110
|
-
const savedCallback = React.useRef(callback);
|
|
111
|
-
const [prevValue, setPrevValue] = React.useState(value);
|
|
112
|
-
if (!compare(prevValue, value)) {
|
|
113
|
-
setPrevValue(value);
|
|
114
|
-
}
|
|
115
|
-
React.useEffect(() => {
|
|
116
|
-
savedCallback.current = callback;
|
|
117
|
-
});
|
|
118
|
-
React.useEffect(() => {
|
|
119
|
-
// We only want the callback triggered after the first render
|
|
120
|
-
if (initialRender.current) {
|
|
121
|
-
savedCallback.current(prevValue);
|
|
122
|
-
}
|
|
123
|
-
}, [prevValue]);
|
|
124
|
-
React.useEffect(() => {
|
|
125
|
-
initialRender.current = true;
|
|
126
|
-
}, []);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
81
|
/**
|
|
130
82
|
* Access whether a given flag is enabled or disabled in a given
|
|
131
83
|
* FeatureFlagContext
|
|
132
|
-
*
|
|
133
|
-
* @returns {boolean}
|
|
134
84
|
*/
|
|
135
|
-
|
|
85
|
+
const useFeatureFlag = flag => {
|
|
136
86
|
const scope = React.useContext(FeatureFlagContext);
|
|
137
87
|
return scope.enabled(flag);
|
|
138
|
-
}
|
|
88
|
+
};
|
|
139
89
|
|
|
140
90
|
/**
|
|
141
91
|
* Access all feature flag information for the given FeatureFlagContext
|
|
142
|
-
*
|
|
143
|
-
* @returns {FeatureFlagScope}
|
|
144
|
-
*/
|
|
145
|
-
function useFeatureFlags() {
|
|
146
|
-
return React.useContext(FeatureFlagContext);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Compare two objects and determine if they are equal. This is a shallow
|
|
151
|
-
* comparison since the objects we are comparing are objects with boolean flags
|
|
152
|
-
* from the flags prop in the `FeatureFlags` component
|
|
153
|
-
*
|
|
154
|
-
* @param {object} a
|
|
155
|
-
* @param {object} b
|
|
156
|
-
* @returns {boolean}
|
|
157
92
|
*/
|
|
158
|
-
|
|
159
|
-
if (a === b) {
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
for (const key of Object.keys(a)) {
|
|
163
|
-
if (a[key] !== b[key]) {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
for (const key of Object.keys(b)) {
|
|
168
|
-
if (b[key] !== a[key]) {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
93
|
+
const useFeatureFlags = () => React.useContext(FeatureFlagContext);
|
|
174
94
|
|
|
175
|
-
exports.FeatureFlagContext = FeatureFlagContext;
|
|
176
95
|
exports.FeatureFlags = FeatureFlags;
|
|
177
96
|
exports.useFeatureFlag = useFeatureFlag;
|
|
178
97
|
exports.useFeatureFlags = useFeatureFlags;
|
|
@@ -31,7 +31,7 @@ function FileUploaderSkeleton({
|
|
|
31
31
|
})), /*#__PURE__*/React.createElement(SkeletonText.default, {
|
|
32
32
|
width: "225px",
|
|
33
33
|
className: `${prefix}--label-description`
|
|
34
|
-
}), _ButtonSkeleton || (_ButtonSkeleton = /*#__PURE__*/React.createElement(Button_Skeleton.
|
|
34
|
+
}), _ButtonSkeleton || (_ButtonSkeleton = /*#__PURE__*/React.createElement(Button_Skeleton.ButtonSkeleton, null)));
|
|
35
35
|
}
|
|
36
36
|
FileUploaderSkeleton.propTypes = {
|
|
37
37
|
/**
|
|
@@ -39,7 +39,6 @@ function FileUploaderButton({
|
|
|
39
39
|
}) {
|
|
40
40
|
const prefix = usePrefix.usePrefix();
|
|
41
41
|
const [labelText, setLabelText] = React.useState(ownerLabelText);
|
|
42
|
-
const [prevOwnerLabelText, setPrevOwnerLabelText] = React.useState(ownerLabelText);
|
|
43
42
|
const generatedId = useId.useId();
|
|
44
43
|
const {
|
|
45
44
|
current: inputId
|
|
@@ -53,12 +52,9 @@ function FileUploaderButton({
|
|
|
53
52
|
[`${prefix}--btn--sm`]: size === 'small' || size === 'sm',
|
|
54
53
|
[`${prefix}--layout--size-${size}`]: size
|
|
55
54
|
});
|
|
56
|
-
|
|
57
|
-
// Adjust label text state based on changes to the labelText prop
|
|
58
|
-
if (ownerLabelText !== prevOwnerLabelText) {
|
|
55
|
+
React.useEffect(() => {
|
|
59
56
|
setLabelText(ownerLabelText);
|
|
60
|
-
|
|
61
|
-
}
|
|
57
|
+
}, [ownerLabelText]);
|
|
62
58
|
function onClick(event) {
|
|
63
59
|
event.target.value = null;
|
|
64
60
|
if (inputNode.current) {
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
-
|
|
12
10
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
11
|
var PropTypes = require('prop-types');
|
|
14
12
|
var React = require('react');
|
|
@@ -32,4 +30,3 @@ IconSkeleton.propTypes = {
|
|
|
32
30
|
};
|
|
33
31
|
|
|
34
32
|
exports.IconSkeleton = IconSkeleton;
|
|
35
|
-
exports.default = IconSkeleton;
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
-
|
|
12
10
|
var PropTypes = require('prop-types');
|
|
13
11
|
var React = require('react');
|
|
14
12
|
var cx = require('classnames');
|
|
@@ -76,4 +74,3 @@ IconIndicator.propTypes = {
|
|
|
76
74
|
|
|
77
75
|
exports.IconIndicator = IconIndicator;
|
|
78
76
|
exports.IconIndicatorKinds = IconIndicatorKinds;
|
|
79
|
-
exports.default = IconIndicator;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { type PropsWithChildren } from 'react';
|
|
7
|
+
import React, { type ComponentType, type PropsWithChildren } from 'react';
|
|
8
8
|
import { type PresenceContext } from '../../internal/usePresenceContext';
|
|
9
9
|
export interface ModalPresenceProps {
|
|
10
10
|
/**
|
|
@@ -29,4 +29,12 @@ export declare const ModalPresenceContext: React.Context<ModalPresenceContextPro
|
|
|
29
29
|
* Handles occurrences where only a single modal must consume a context.
|
|
30
30
|
*/
|
|
31
31
|
export declare const useExclusiveModalPresenceContext: (id: string) => ModalPresenceContextProps | undefined;
|
|
32
|
+
type WithModalPresenceProps = Pick<ModalPresenceProps, 'open'>;
|
|
33
|
+
/**
|
|
34
|
+
* Higher-order function that wraps a component with ModalPresence
|
|
35
|
+
*/
|
|
36
|
+
export declare const withModalPresence: <TProps extends object>(Component: ComponentType<TProps>) => {
|
|
37
|
+
({ open, ...componentProps }: TProps & WithModalPresenceProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
displayName: string;
|
|
39
|
+
};
|
|
32
40
|
export {};
|
|
@@ -35,7 +35,21 @@ const useExclusiveModalPresenceContext = id => {
|
|
|
35
35
|
const ctx = React.useContext(ModalPresenceContext);
|
|
36
36
|
return ctx?.isPresenceExclusive(id) ? ctx : undefined;
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Higher-order function that wraps a component with ModalPresence
|
|
40
|
+
*/
|
|
41
|
+
const withModalPresence = Component => {
|
|
42
|
+
const WithModalPresence = ({
|
|
43
|
+
open,
|
|
44
|
+
...componentProps
|
|
45
|
+
}) => /*#__PURE__*/React.createElement(ModalPresence, {
|
|
46
|
+
open: open
|
|
47
|
+
}, /*#__PURE__*/React.createElement(Component, componentProps));
|
|
48
|
+
WithModalPresence.displayName = `withModalPresence(${Component.displayName || Component.name || 'Component'})`;
|
|
49
|
+
return WithModalPresence;
|
|
50
|
+
};
|
|
38
51
|
|
|
39
52
|
exports.ModalPresence = ModalPresence;
|
|
40
53
|
exports.ModalPresenceContext = ModalPresenceContext;
|
|
41
54
|
exports.useExclusiveModalPresenceContext = useExclusiveModalPresenceContext;
|
|
55
|
+
exports.withModalPresence = withModalPresence;
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import Modal, { type ModalProps } from './Modal';
|
|
8
|
-
import { ModalPresence, type ModalPresenceProps } from './ModalPresence';
|
|
8
|
+
import { ModalPresence, withModalPresence, type ModalPresenceProps } from './ModalPresence';
|
|
9
9
|
export default Modal;
|
|
10
|
-
export { Modal, ModalPresence, type ModalProps, type ModalPresenceProps };
|
|
10
|
+
export { Modal, ModalPresence, withModalPresence, type ModalProps, type ModalPresenceProps, };
|
|
@@ -112,11 +112,11 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
112
112
|
isFluid
|
|
113
113
|
} = React.useContext(FormContext.FormContext);
|
|
114
114
|
const multiSelectInstanceId = useId.useId();
|
|
115
|
+
const prevOpenPropRef = React.useRef(open);
|
|
115
116
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
116
117
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
117
118
|
const [inputFocused, setInputFocused] = React.useState(false);
|
|
118
119
|
const [isOpen, setIsOpen] = React.useState(open || false);
|
|
119
|
-
const [prevOpenProp, setPrevOpenProp] = React.useState(open);
|
|
120
120
|
const [topItems, setTopItems] = React.useState([]);
|
|
121
121
|
const [itemsCleared, setItemsCleared] = React.useState(false);
|
|
122
122
|
const enableFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
|
|
@@ -250,14 +250,13 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
250
250
|
onMenuChange(open);
|
|
251
251
|
}
|
|
252
252
|
};
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
253
|
+
React.useEffect(() => {
|
|
254
|
+
if (prevOpenPropRef.current !== open) {
|
|
255
|
+
setIsOpen(open);
|
|
256
|
+
onMenuChange?.(open);
|
|
257
|
+
prevOpenPropRef.current = open;
|
|
258
|
+
}
|
|
259
|
+
}, [open, onMenuChange]);
|
|
261
260
|
const normalizedProps = useNormalizedInputProps.useNormalizedInputProps({
|
|
262
261
|
id,
|
|
263
262
|
disabled,
|
|
@@ -343,7 +343,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
343
343
|
* The number value that was previously "committed" to the input on blur
|
|
344
344
|
* Only used when type="text"
|
|
345
345
|
*/
|
|
346
|
-
const
|
|
346
|
+
const previousNumberValue = React.useRef(numberValue);
|
|
347
347
|
/**
|
|
348
348
|
* The current text value of the input.
|
|
349
349
|
* Only used when type=text
|
|
@@ -356,10 +356,12 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
356
356
|
numberingSystem
|
|
357
357
|
}), [locale, formatOptions, numberingSystem]);
|
|
358
358
|
const format = React.useCallback(value => isNaN(value) || value === null ? '' : numberFormatter.format(value), [numberFormatter]);
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
359
|
+
React.useEffect(() => {
|
|
360
|
+
if (isControlled && !(isNaN(previousNumberValue.current) && isNaN(numberValue)) && previousNumberValue.current !== numberValue) {
|
|
361
|
+
setInputValue(format(numberValue));
|
|
362
|
+
previousNumberValue.current = numberValue;
|
|
363
|
+
}
|
|
364
|
+
}, [isControlled, numberValue, format]);
|
|
363
365
|
const inputRef = React.useRef(null);
|
|
364
366
|
const ref = useMergedRefs.useMergedRefs([forwardRef, inputRef]);
|
|
365
367
|
const numberInputClasses = cx({
|
|
@@ -506,7 +508,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
506
508
|
// numberValue in useControllableState.
|
|
507
509
|
setNumberValue(parsedFormattedNewValue);
|
|
508
510
|
setInputValue(formattedNewValue);
|
|
509
|
-
|
|
511
|
+
previousNumberValue.current = parsedFormattedNewValue;
|
|
510
512
|
}
|
|
511
513
|
if (onChange) {
|
|
512
514
|
onChange(event, state);
|
|
@@ -608,22 +610,22 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
608
610
|
if (onChange && isValid) {
|
|
609
611
|
const state = {
|
|
610
612
|
value: parsedFormattedNewValue,
|
|
611
|
-
direction: previousNumberValue < parsedFormattedNewValue ? 'up' : 'down'
|
|
613
|
+
direction: previousNumberValue.current < parsedFormattedNewValue ? 'up' : 'down'
|
|
612
614
|
};
|
|
613
615
|
|
|
614
616
|
// If the old and new values are NaN, don't call onChange
|
|
615
|
-
// to avoid an
|
|
617
|
+
// to avoid an unnecessary re-render and potential infinite
|
|
616
618
|
// loop when isControlled.
|
|
617
|
-
if (!(isNaN(previousNumberValue) && isNaN(parsedFormattedNewValue))) {
|
|
619
|
+
if (!(isNaN(previousNumberValue.current) && isNaN(parsedFormattedNewValue))) {
|
|
618
620
|
onChange(e, state);
|
|
619
621
|
}
|
|
620
622
|
}
|
|
621
623
|
|
|
622
624
|
// If the old and new values are NaN, don't set state to avoid
|
|
623
|
-
// an
|
|
625
|
+
// an unnecessary re-render and potential infinite loop when
|
|
624
626
|
// isControlled.
|
|
625
|
-
if (!(isNaN(previousNumberValue) && isNaN(numberValue))) {
|
|
626
|
-
|
|
627
|
+
if (!(isNaN(previousNumberValue.current) && isNaN(numberValue))) {
|
|
628
|
+
previousNumberValue.current = numberValue;
|
|
627
629
|
}
|
|
628
630
|
if (!(isNaN(numberValue) && isNaN(parsedFormattedNewValue))) {
|
|
629
631
|
setNumberValue(parsedFormattedNewValue);
|
|
@@ -70,7 +70,7 @@ export interface OverflowMenuProps extends Omit<IconButtonProps, 'type' | 'aria-
|
|
|
70
70
|
*/
|
|
71
71
|
menuOffset?: MenuOffset;
|
|
72
72
|
/**
|
|
73
|
-
* The adjustment in position applied to the floating menu.
|
|
73
|
+
* The adjustment in position applied to the floating menu when flipped.
|
|
74
74
|
*/
|
|
75
75
|
menuOffsetFlip?: MenuOffset;
|
|
76
76
|
/**
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
-
|
|
12
10
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
11
|
var React = require('react');
|
|
14
12
|
var iconsReact = require('@carbon/icons-react');
|
|
@@ -70,10 +68,8 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
|
70
68
|
if (process.env.NODE_ENV !== 'production') {
|
|
71
69
|
!(triggerButtonPositionProp && triggerButtonPositionFactor) ? process.env.NODE_ENV !== "production" ? invariant(false, '[OverflowMenu] wrong floating menu direction: `%s`', direction) : invariant(false) : void 0;
|
|
72
70
|
}
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
74
71
|
const {
|
|
75
|
-
offsetWidth: menuWidth
|
|
76
|
-
offsetHeight: menuHeight
|
|
72
|
+
offsetWidth: menuWidth
|
|
77
73
|
} = menuBody;
|
|
78
74
|
switch (triggerButtonPositionProp) {
|
|
79
75
|
case 'top':
|
|
@@ -427,7 +423,7 @@ OverflowMenu.propTypes = {
|
|
|
427
423
|
left: PropTypes.number.isRequired
|
|
428
424
|
}), PropTypes.func]),
|
|
429
425
|
/**
|
|
430
|
-
* The adjustment in position applied to the floating menu.
|
|
426
|
+
* The adjustment in position applied to the floating menu when flipped.
|
|
431
427
|
*/
|
|
432
428
|
menuOffsetFlip: PropTypes.oneOfType([PropTypes.shape({
|
|
433
429
|
top: PropTypes.number.isRequired,
|
|
@@ -477,5 +473,4 @@ OverflowMenu.propTypes = {
|
|
|
477
473
|
};
|
|
478
474
|
|
|
479
475
|
exports.OverflowMenu = OverflowMenu;
|
|
480
|
-
exports.default = OverflowMenu;
|
|
481
476
|
exports.getMenuOffset = getMenuOffset;
|
|
@@ -20,7 +20,7 @@ function OverflowMenuV2(props) {
|
|
|
20
20
|
}
|
|
21
21
|
return /*#__PURE__*/React.createElement(index.FeatureFlags, {
|
|
22
22
|
enableV12Overflowmenu: true
|
|
23
|
-
}, /*#__PURE__*/React.createElement(index$1.
|
|
23
|
+
}, /*#__PURE__*/React.createElement(index$1.OverflowMenu, props));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
exports.OverflowMenuV2 = OverflowMenuV2;
|