@carbon/react 1.77.0-rc.0 → 1.77.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 +775 -775
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +11 -3
- package/es/components/Pagination/Pagination.js +2 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +10 -2
- package/lib/components/Pagination/Pagination.js +3 -2
- package/package.json +7 -7
- package/es/tools/array.js +0 -29
- package/lib/tools/array.js +0 -33
|
@@ -11,7 +11,7 @@ import cx from 'classnames';
|
|
|
11
11
|
import Downshift, { useCombobox, useMultipleSelection } from 'downshift';
|
|
12
12
|
import isEqual from 'react-fast-compare';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
|
-
import React__default, { useContext, useState, useLayoutEffect,
|
|
14
|
+
import React__default, { useContext, useRef, useState, useLayoutEffect, useMemo, useEffect } from 'react';
|
|
15
15
|
import { defaultFilterItems } from '../ComboBox/tools/filter.js';
|
|
16
16
|
import { sortingPropTypes } from './MultiSelectPropTypes.js';
|
|
17
17
|
import ListBox from '../ListBox/index.js';
|
|
@@ -106,6 +106,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
106
106
|
const {
|
|
107
107
|
isFluid
|
|
108
108
|
} = useContext(FormContext);
|
|
109
|
+
const isFirstRender = useRef(true);
|
|
109
110
|
const [isFocused, setIsFocused] = useState(false);
|
|
110
111
|
const [isOpen, setIsOpen] = useState(!!open);
|
|
111
112
|
const [prevOpen, setPrevOpen] = useState(!!open);
|
|
@@ -240,8 +241,15 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
243
|
useEffect(() => {
|
|
243
|
-
|
|
244
|
-
|
|
244
|
+
if (isFirstRender.current) {
|
|
245
|
+
isFirstRender.current = false;
|
|
246
|
+
if (open) {
|
|
247
|
+
onMenuChange?.(isOpen);
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
onMenuChange?.(isOpen);
|
|
251
|
+
}
|
|
252
|
+
}, [isOpen, onMenuChange, open]);
|
|
245
253
|
const {
|
|
246
254
|
getToggleButtonProps,
|
|
247
255
|
getLabelProps,
|
|
@@ -13,10 +13,10 @@ import React__default, { useRef, useState } from 'react';
|
|
|
13
13
|
import Select from '../Select/Select.js';
|
|
14
14
|
import '../Select/Select.Skeleton.js';
|
|
15
15
|
import SelectItem from '../SelectItem/SelectItem.js';
|
|
16
|
-
import { equals } from '../../tools/array.js';
|
|
17
16
|
import { useFallbackId } from '../../internal/useId.js';
|
|
18
17
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
19
18
|
import { IconButton } from '../IconButton/index.js';
|
|
19
|
+
import isEqual from 'react-fast-compare';
|
|
20
20
|
|
|
21
21
|
var _CaretLeft, _CaretRight;
|
|
22
22
|
function mapPageSizesToObject(sizes) {
|
|
@@ -117,7 +117,7 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
|
|
|
117
117
|
setPageSize(getPageSize(pageSizes, controlledPageSize));
|
|
118
118
|
setPrevControlledPageSize(controlledPageSize);
|
|
119
119
|
}
|
|
120
|
-
if (!
|
|
120
|
+
if (!isEqual(controlledPageSizes, prevPageSizes)) {
|
|
121
121
|
const pageSizes = mapPageSizesToObject(controlledPageSizes);
|
|
122
122
|
const hasPageSize = pageSizes.find(size => {
|
|
123
123
|
return size.value === pageSize;
|
|
@@ -118,6 +118,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
118
118
|
const {
|
|
119
119
|
isFluid
|
|
120
120
|
} = React.useContext(FormContext.FormContext);
|
|
121
|
+
const isFirstRender = React.useRef(true);
|
|
121
122
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
122
123
|
const [isOpen, setIsOpen] = React.useState(!!open);
|
|
123
124
|
const [prevOpen, setPrevOpen] = React.useState(!!open);
|
|
@@ -252,8 +253,15 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
252
253
|
}
|
|
253
254
|
}
|
|
254
255
|
React.useEffect(() => {
|
|
255
|
-
|
|
256
|
-
|
|
256
|
+
if (isFirstRender.current) {
|
|
257
|
+
isFirstRender.current = false;
|
|
258
|
+
if (open) {
|
|
259
|
+
onMenuChange?.(isOpen);
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
onMenuChange?.(isOpen);
|
|
263
|
+
}
|
|
264
|
+
}, [isOpen, onMenuChange, open]);
|
|
257
265
|
const {
|
|
258
266
|
getToggleButtonProps,
|
|
259
267
|
getLabelProps,
|
|
@@ -17,16 +17,17 @@ var React = require('react');
|
|
|
17
17
|
var Select = require('../Select/Select.js');
|
|
18
18
|
require('../Select/Select.Skeleton.js');
|
|
19
19
|
var SelectItem = require('../SelectItem/SelectItem.js');
|
|
20
|
-
var array = require('../../tools/array.js');
|
|
21
20
|
var useId = require('../../internal/useId.js');
|
|
22
21
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
23
22
|
var index = require('../IconButton/index.js');
|
|
23
|
+
var isEqual = require('react-fast-compare');
|
|
24
24
|
|
|
25
25
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
26
26
|
|
|
27
27
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
28
28
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
29
29
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
30
|
+
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
30
31
|
|
|
31
32
|
var _CaretLeft, _CaretRight;
|
|
32
33
|
function mapPageSizesToObject(sizes) {
|
|
@@ -127,7 +128,7 @@ const Pagination = /*#__PURE__*/React__default["default"].forwardRef(function Pa
|
|
|
127
128
|
setPageSize(getPageSize(pageSizes, controlledPageSize));
|
|
128
129
|
setPrevControlledPageSize(controlledPageSize);
|
|
129
130
|
}
|
|
130
|
-
if (!
|
|
131
|
+
if (!isEqual__default["default"](controlledPageSizes, prevPageSizes)) {
|
|
131
132
|
const pageSizes = mapPageSizesToObject(controlledPageSizes);
|
|
132
133
|
const hasPageSize = pageSizes.find(size => {
|
|
133
134
|
return size.value === pageSize;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.77.0
|
|
4
|
+
"version": "1.77.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@babel/runtime": "^7.24.7",
|
|
54
54
|
"@carbon/feature-flags": "^0.24.0",
|
|
55
|
-
"@carbon/icons-react": "^11.56.0
|
|
56
|
-
"@carbon/layout": "^11.30.0
|
|
57
|
-
"@carbon/styles": "^1.76.0
|
|
55
|
+
"@carbon/icons-react": "^11.56.0",
|
|
56
|
+
"@carbon/layout": "^11.30.0",
|
|
57
|
+
"@carbon/styles": "^1.76.0",
|
|
58
58
|
"@floating-ui/react": "^0.27.4",
|
|
59
59
|
"@ibm/telemetry-js": "^1.5.0",
|
|
60
60
|
"classnames": "2.5.1",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@babel/preset-react": "^7.24.7",
|
|
80
80
|
"@babel/preset-typescript": "^7.24.7",
|
|
81
81
|
"@carbon/test-utils": "^10.35.0",
|
|
82
|
-
"@carbon/themes": "^11.47.0
|
|
82
|
+
"@carbon/themes": "^11.47.0",
|
|
83
83
|
"@figma/code-connect": "^1.2.4",
|
|
84
84
|
"@rollup/plugin-babel": "^6.0.0",
|
|
85
85
|
"@rollup/plugin-commonjs": "^28.0.0",
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
"storybook-addon-accessibility-checker": "^3.1.61-rc.3",
|
|
132
132
|
"stream-browserify": "^3.0.0",
|
|
133
133
|
"style-loader": "^4.0.0",
|
|
134
|
-
"typescript-config-carbon": "^0.5.0
|
|
134
|
+
"typescript-config-carbon": "^0.5.0",
|
|
135
135
|
"webpack": "^5.65.0",
|
|
136
136
|
"webpack-dev-server": "^5.0.0"
|
|
137
137
|
},
|
|
@@ -146,5 +146,5 @@
|
|
|
146
146
|
"**/*.scss",
|
|
147
147
|
"**/*.css"
|
|
148
148
|
],
|
|
149
|
-
"gitHead": "
|
|
149
|
+
"gitHead": "2a32901cb1c74c149164122f0742305440716d35"
|
|
150
150
|
}
|
package/es/tools/array.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2023
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Shallow compare two arrays for equality
|
|
10
|
-
* @param {Array} arr1 the first array
|
|
11
|
-
* @param {Array} arr2 the second array
|
|
12
|
-
* @returns {boolean} true if both arrays have the same contents, otherwise false
|
|
13
|
-
*/
|
|
14
|
-
function equals(arr1, arr2) {
|
|
15
|
-
if (!Array.isArray(arr1) || !Array.isArray(arr2) || arr1.length !== arr2.length) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
if (arr1 === arr2) {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
for (let i = 0; i < arr1.length; i++) {
|
|
22
|
-
if (arr1[i] !== arr2[i]) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { equals };
|
package/lib/tools/array.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2023
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Shallow compare two arrays for equality
|
|
14
|
-
* @param {Array} arr1 the first array
|
|
15
|
-
* @param {Array} arr2 the second array
|
|
16
|
-
* @returns {boolean} true if both arrays have the same contents, otherwise false
|
|
17
|
-
*/
|
|
18
|
-
function equals(arr1, arr2) {
|
|
19
|
-
if (!Array.isArray(arr1) || !Array.isArray(arr2) || arr1.length !== arr2.length) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
if (arr1 === arr2) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
for (let i = 0; i < arr1.length; i++) {
|
|
26
|
-
if (arr1[i] !== arr2[i]) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
exports.equals = equals;
|