carbon-react 111.8.0 → 111.8.2

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.
@@ -46,7 +46,7 @@ export const StyledDdDiv = styled.div`
46
46
  `;
47
47
  export const StyledDt = styled.dt`
48
48
  ${space}
49
- font-size: 14px;
49
+ font-size: var(--fontSizes100);
50
50
  font-weight: 700;
51
51
  color: var(--colorsUtilityYin090);
52
52
  `;
@@ -54,8 +54,8 @@ StyledDt.defaultProps = {
54
54
  theme: baseTheme
55
55
  };
56
56
  export const StyledDd = styled.dd`
57
- font-size: 14px;
58
- font-weight: 700;
57
+ font-size: var(--fontSizes100);
58
+ font-weight: var(--fontWeights400);
59
59
  color: var(--colorsUtilityYin065);
60
60
  margin-left: 0px;
61
61
 
@@ -415,7 +415,6 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
415
415
  isOpen: isOpen
416
416
  }, children);
417
417
  return /*#__PURE__*/React.createElement(StyledSelect, _extends({
418
- ref: containerRef,
419
418
  hasTextCursor: true,
420
419
  readOnly: readOnly,
421
420
  disabled: disabled,
@@ -1,12 +1,14 @@
1
1
  import styled from "styled-components";
2
+ import { baseTheme } from "../../../style/themes";
2
3
  const StyledSelectListContainer = styled.div`
3
4
  background-color: white;
4
5
  box-shadow: var(--boxShadow100);
5
- min-width: 100%;
6
- max-width: 870px;
7
- height: 100%;
8
6
  overflow: hidden;
9
7
  animation: fadeIn 250ms ease-out;
8
+ position: absolute;
9
+ z-index: ${({
10
+ theme
11
+ }) => theme.zIndex.popover};
10
12
 
11
13
  @keyframes fadeIn {
12
14
  0% {
@@ -17,4 +19,7 @@ const StyledSelectListContainer = styled.div`
17
19
  }
18
20
  }
19
21
  `;
22
+ StyledSelectListContainer.defaultProps = {
23
+ theme: baseTheme
24
+ };
20
25
  export default StyledSelectListContainer;
@@ -2,9 +2,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React, { useEffect, useState, useCallback, useLayoutEffect, useRef, useMemo } from "react";
4
4
  import PropTypes from "prop-types";
5
- import { flip, offset } from "@floating-ui/dom";
5
+ import { flip, offset, size } from "@floating-ui/dom";
6
6
  import useScrollBlock from "../../../hooks/__internal__/useScrollBlock";
7
- import { StyledSelectList, StyledSelectLoaderContainer, StyledPopoverContainer, StyledSelectListTable, StyledSelectListTableHeader, StyledSelectListTableBody } from "./select-list.style";
7
+ import { StyledSelectList, StyledSelectLoaderContainer, StyledSelectListTable, StyledSelectListTableHeader, StyledSelectListTableBody } from "./select-list.style";
8
8
  import Popover from "../../../__internal__/popover";
9
9
  import OptionRow from "../option-row/option-row.component";
10
10
  import updateListScrollTop from "./update-list-scroll";
@@ -42,8 +42,6 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
42
42
  ...listProps
43
43
  }, listContainerRef) => {
44
44
  const [currentOptionsListIndex, setCurrentOptionsListIndex] = useState(-1);
45
- const [listHeight, setListHeight] = useState(0);
46
- const [listWidth, setListWidth] = useState(null);
47
45
  const [scrollbarWidth, setScrollbarWidth] = useState(0);
48
46
  const lastFilter = useRef("");
49
47
  const listRef = useRef();
@@ -53,24 +51,6 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
53
51
  blockScroll,
54
52
  allowScroll
55
53
  } = useScrollBlock();
56
- const updateListHeight = useCallback(() => {
57
- if (isOpen) {
58
- let newHeight = listRef.current.clientHeight;
59
-
60
- if (listActionButtonRef.current) {
61
- newHeight += listActionButtonRef.current.parentElement.clientHeight;
62
- }
63
-
64
- setListHeight(`${newHeight}px`);
65
- }
66
- }, [isOpen]);
67
- const listCallbackRef = useCallback(element => {
68
- listRef.current = element;
69
-
70
- if (element) {
71
- setTimeout(updateListHeight, 0);
72
- }
73
- }, [updateListHeight]);
74
54
  useEffect(() => {
75
55
  if (isOpen) {
76
56
  blockScroll();
@@ -228,21 +208,6 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
228
208
  onListScrollBottom();
229
209
  }
230
210
  }, [onListScrollBottom]);
231
- const assignListWidth = useCallback(() => {
232
- if (anchorElement) {
233
- const inputBoundingRect = anchorElement.getBoundingClientRect();
234
- const width = `${inputBoundingRect.width}px`;
235
- setListWidth(width);
236
- }
237
- }, [anchorElement]);
238
- useLayoutEffect(() => {
239
- assignListWidth();
240
- window.addEventListener("resize", assignListWidth);
241
- return () => {
242
- window.removeEventListener("resize", assignListWidth);
243
- };
244
- }, [assignListWidth]);
245
- useLayoutEffect(updateListHeight, [children, updateListHeight]);
246
211
  useEffect(() => {
247
212
  const keyboardEvent = "keydown";
248
213
  const listElement = listRef.current;
@@ -286,7 +251,17 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
286
251
  listRef.current.scrollTop = listRef.current.scrollHeight;
287
252
  }
288
253
  }, [children, currentOptionsListIndex, isLoading, lastOptionIndex]);
289
- const popoverMiddleware = useMemo(() => [offset(3), ...(flipEnabled ? [flip({
254
+ const popoverMiddleware = useMemo(() => [offset(3), size({
255
+ apply({
256
+ rects,
257
+ elements
258
+ }) {
259
+ Object.assign(elements.floating.style, {
260
+ width: `${rects.reference.width}px`
261
+ });
262
+ }
263
+
264
+ }), ...(flipEnabled ? [flip({
290
265
  fallbackStrategy: "initialPlacement"
291
266
  })] : [])], [flipEnabled]);
292
267
 
@@ -307,7 +282,12 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
307
282
  }, childrenWithListProps));
308
283
  }
309
284
 
310
- return /*#__PURE__*/React.createElement(Popover, {
285
+ return /*#__PURE__*/React.createElement(SelectListContext.Provider, {
286
+ value: {
287
+ currentOptionsListIndex,
288
+ multiselectValues
289
+ }
290
+ }, /*#__PURE__*/React.createElement(Popover, {
311
291
  placement: listPlacement,
312
292
  disablePortal: disablePortal,
313
293
  reference: anchorRef,
@@ -315,17 +295,9 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
315
295
  isOpen: isOpen,
316
296
  disableBackgroundUI: true,
317
297
  animationFrame: true
318
- }, /*#__PURE__*/React.createElement(StyledPopoverContainer, {
319
- height: listHeight,
320
- width: listWidth,
321
- ref: listContainerRef
322
- }, /*#__PURE__*/React.createElement(SelectListContext.Provider, {
323
- value: {
324
- currentOptionsListIndex,
325
- multiselectValues
326
- }
327
298
  }, /*#__PURE__*/React.createElement(StyledSelectListContainer, _extends({
328
- "data-element": "select-list-wrapper"
299
+ "data-element": "select-list-wrapper",
300
+ ref: listContainerRef
329
301
  }, listProps), /*#__PURE__*/React.createElement(StyledSelectList, {
330
302
  id: id,
331
303
  as: multiColumn ? "div" : "ul",
@@ -333,7 +305,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
333
305
  "data-element": "select-list",
334
306
  role: "listbox",
335
307
  "aria-multiselectable": multiselectValues ? true : undefined,
336
- ref: listCallbackRef,
308
+ ref: listRef,
337
309
  tabIndex: "-1",
338
310
  isLoading: isLoading,
339
311
  multiColumn: multiColumn,
@@ -342,7 +314,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
342
314
  ref: listActionButtonRef,
343
315
  listActionButton: listActionButton,
344
316
  onListAction: onListAction
345
- })))));
317
+ }))));
346
318
  });
347
319
  SelectList.propTypes = {
348
320
  /** The ID for the parent <div> */
@@ -1,25 +1,4 @@
1
1
  import styled, { css } from "styled-components";
2
- import { baseTheme } from "../../../style/themes";
3
- const overhang = 4; // TODO (design-tokens): no elovation/zindex tokens yet
4
-
5
- const StyledPopoverContainer = styled.div`
6
- position: absolute;
7
- z-index: ${({
8
- theme
9
- }) => theme.zIndex.popover};
10
- height: ${({
11
- height
12
- }) => height};
13
- width: calc(100% + ${2 * overhang}px);
14
- ${({
15
- width
16
- }) => css`
17
- width: ${width};
18
- `};
19
- `;
20
- StyledPopoverContainer.defaultProps = {
21
- theme: baseTheme
22
- };
23
2
  const StyledSelectList = styled.ul`
24
3
  ${({
25
4
  isLoading,
@@ -115,4 +94,4 @@ const StyledSelectListTableBody = styled.tbody`
115
94
  table-layout: fixed;
116
95
  max-height: 132px;
117
96
  `;
118
- export { StyledPopoverContainer, StyledSelectList, StyledSelectLoaderContainer, StyledSelectListTable, StyledSelectListTableHeader, StyledSelectListTableBody };
97
+ export { StyledSelectList, StyledSelectLoaderContainer, StyledSelectListTable, StyledSelectListTableHeader, StyledSelectListTableBody };
@@ -66,7 +66,7 @@ const StyledDdDiv = _styledComponents.default.div`
66
66
  exports.StyledDdDiv = StyledDdDiv;
67
67
  const StyledDt = _styledComponents.default.dt`
68
68
  ${_styledSystem.space}
69
- font-size: 14px;
69
+ font-size: var(--fontSizes100);
70
70
  font-weight: 700;
71
71
  color: var(--colorsUtilityYin090);
72
72
  `;
@@ -75,8 +75,8 @@ StyledDt.defaultProps = {
75
75
  theme: _themes.baseTheme
76
76
  };
77
77
  const StyledDd = _styledComponents.default.dd`
78
- font-size: 14px;
79
- font-weight: 700;
78
+ font-size: var(--fontSizes100);
79
+ font-weight: var(--fontWeights400);
80
80
  color: var(--colorsUtilityYin065);
81
81
  margin-left: 0px;
82
82
 
@@ -441,7 +441,6 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
441
441
  }, children);
442
442
 
443
443
  return /*#__PURE__*/_react.default.createElement(_select.default, _extends({
444
- ref: containerRef,
445
444
  hasTextCursor: true,
446
445
  readOnly: readOnly,
447
446
  disabled: disabled,
@@ -7,16 +7,19 @@ exports.default = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
 
10
+ var _themes = require("../../../style/themes");
11
+
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
13
 
12
14
  const StyledSelectListContainer = _styledComponents.default.div`
13
15
  background-color: white;
14
16
  box-shadow: var(--boxShadow100);
15
- min-width: 100%;
16
- max-width: 870px;
17
- height: 100%;
18
17
  overflow: hidden;
19
18
  animation: fadeIn 250ms ease-out;
19
+ position: absolute;
20
+ z-index: ${({
21
+ theme
22
+ }) => theme.zIndex.popover};
20
23
 
21
24
  @keyframes fadeIn {
22
25
  0% {
@@ -27,5 +30,8 @@ const StyledSelectListContainer = _styledComponents.default.div`
27
30
  }
28
31
  }
29
32
  `;
33
+ StyledSelectListContainer.defaultProps = {
34
+ theme: _themes.baseTheme
35
+ };
30
36
  var _default = StyledSelectListContainer;
31
37
  exports.default = _default;
@@ -72,8 +72,6 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
72
72
  ...listProps
73
73
  }, listContainerRef) => {
74
74
  const [currentOptionsListIndex, setCurrentOptionsListIndex] = (0, _react.useState)(-1);
75
- const [listHeight, setListHeight] = (0, _react.useState)(0);
76
- const [listWidth, setListWidth] = (0, _react.useState)(null);
77
75
  const [scrollbarWidth, setScrollbarWidth] = (0, _react.useState)(0);
78
76
  const lastFilter = (0, _react.useRef)("");
79
77
  const listRef = (0, _react.useRef)();
@@ -83,24 +81,6 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
83
81
  blockScroll,
84
82
  allowScroll
85
83
  } = (0, _useScrollBlock.default)();
86
- const updateListHeight = (0, _react.useCallback)(() => {
87
- if (isOpen) {
88
- let newHeight = listRef.current.clientHeight;
89
-
90
- if (listActionButtonRef.current) {
91
- newHeight += listActionButtonRef.current.parentElement.clientHeight;
92
- }
93
-
94
- setListHeight(`${newHeight}px`);
95
- }
96
- }, [isOpen]);
97
- const listCallbackRef = (0, _react.useCallback)(element => {
98
- listRef.current = element;
99
-
100
- if (element) {
101
- setTimeout(updateListHeight, 0);
102
- }
103
- }, [updateListHeight]);
104
84
  (0, _react.useEffect)(() => {
105
85
  if (isOpen) {
106
86
  blockScroll();
@@ -258,21 +238,6 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
258
238
  onListScrollBottom();
259
239
  }
260
240
  }, [onListScrollBottom]);
261
- const assignListWidth = (0, _react.useCallback)(() => {
262
- if (anchorElement) {
263
- const inputBoundingRect = anchorElement.getBoundingClientRect();
264
- const width = `${inputBoundingRect.width}px`;
265
- setListWidth(width);
266
- }
267
- }, [anchorElement]);
268
- (0, _react.useLayoutEffect)(() => {
269
- assignListWidth();
270
- window.addEventListener("resize", assignListWidth);
271
- return () => {
272
- window.removeEventListener("resize", assignListWidth);
273
- };
274
- }, [assignListWidth]);
275
- (0, _react.useLayoutEffect)(updateListHeight, [children, updateListHeight]);
276
241
  (0, _react.useEffect)(() => {
277
242
  const keyboardEvent = "keydown";
278
243
  const listElement = listRef.current;
@@ -316,7 +281,17 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
316
281
  listRef.current.scrollTop = listRef.current.scrollHeight;
317
282
  }
318
283
  }, [children, currentOptionsListIndex, isLoading, lastOptionIndex]);
319
- const popoverMiddleware = (0, _react.useMemo)(() => [(0, _dom.offset)(3), ...(flipEnabled ? [(0, _dom.flip)({
284
+ const popoverMiddleware = (0, _react.useMemo)(() => [(0, _dom.offset)(3), (0, _dom.size)({
285
+ apply({
286
+ rects,
287
+ elements
288
+ }) {
289
+ Object.assign(elements.floating.style, {
290
+ width: `${rects.reference.width}px`
291
+ });
292
+ }
293
+
294
+ }), ...(flipEnabled ? [(0, _dom.flip)({
320
295
  fallbackStrategy: "initialPlacement"
321
296
  })] : [])], [flipEnabled]);
322
297
 
@@ -337,7 +312,12 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
337
312
  }, childrenWithListProps));
338
313
  }
339
314
 
340
- return /*#__PURE__*/_react.default.createElement(_popover.default, {
315
+ return /*#__PURE__*/_react.default.createElement(_selectListContext.default.Provider, {
316
+ value: {
317
+ currentOptionsListIndex,
318
+ multiselectValues
319
+ }
320
+ }, /*#__PURE__*/_react.default.createElement(_popover.default, {
341
321
  placement: listPlacement,
342
322
  disablePortal: disablePortal,
343
323
  reference: anchorRef,
@@ -345,17 +325,9 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
345
325
  isOpen: isOpen,
346
326
  disableBackgroundUI: true,
347
327
  animationFrame: true
348
- }, /*#__PURE__*/_react.default.createElement(_selectList.StyledPopoverContainer, {
349
- height: listHeight,
350
- width: listWidth,
351
- ref: listContainerRef
352
- }, /*#__PURE__*/_react.default.createElement(_selectListContext.default.Provider, {
353
- value: {
354
- currentOptionsListIndex,
355
- multiselectValues
356
- }
357
328
  }, /*#__PURE__*/_react.default.createElement(_selectListContainer.default, _extends({
358
- "data-element": "select-list-wrapper"
329
+ "data-element": "select-list-wrapper",
330
+ ref: listContainerRef
359
331
  }, listProps), /*#__PURE__*/_react.default.createElement(_selectList.StyledSelectList, {
360
332
  id: id,
361
333
  as: multiColumn ? "div" : "ul",
@@ -363,7 +335,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
363
335
  "data-element": "select-list",
364
336
  role: "listbox",
365
337
  "aria-multiselectable": multiselectValues ? true : undefined,
366
- ref: listCallbackRef,
338
+ ref: listRef,
367
339
  tabIndex: "-1",
368
340
  isLoading: isLoading,
369
341
  multiColumn: multiColumn,
@@ -372,7 +344,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
372
344
  ref: listActionButtonRef,
373
345
  listActionButton: listActionButton,
374
346
  onListAction: onListAction
375
- })))));
347
+ }))));
376
348
  });
377
349
 
378
350
  SelectList.propTypes = {
@@ -3,37 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.StyledSelectListTableBody = exports.StyledSelectListTableHeader = exports.StyledSelectListTable = exports.StyledSelectLoaderContainer = exports.StyledSelectList = exports.StyledPopoverContainer = void 0;
6
+ exports.StyledSelectListTableBody = exports.StyledSelectListTableHeader = exports.StyledSelectListTable = exports.StyledSelectLoaderContainer = exports.StyledSelectList = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
 
10
- var _themes = require("../../../style/themes");
11
-
12
10
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
13
11
 
14
12
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
13
 
16
- const overhang = 4; // TODO (design-tokens): no elovation/zindex tokens yet
17
-
18
- const StyledPopoverContainer = _styledComponents.default.div`
19
- position: absolute;
20
- z-index: ${({
21
- theme
22
- }) => theme.zIndex.popover};
23
- height: ${({
24
- height
25
- }) => height};
26
- width: calc(100% + ${2 * overhang}px);
27
- ${({
28
- width
29
- }) => (0, _styledComponents.css)`
30
- width: ${width};
31
- `};
32
- `;
33
- exports.StyledPopoverContainer = StyledPopoverContainer;
34
- StyledPopoverContainer.defaultProps = {
35
- theme: _themes.baseTheme
36
- };
37
14
  const StyledSelectList = _styledComponents.default.ul`
38
15
  ${({
39
16
  isLoading,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "111.8.0",
3
+ "version": "111.8.2",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",