@carbon/ibm-products 1.66.0 → 1.67.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.
@@ -1,19 +1,19 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- // @flow
4
3
  /**
5
- * Copyright IBM Corp. 2022, 2023
4
+ * Copyright IBM Corp. 2022, 2024
6
5
  *
7
6
  * This source code is licensed under the Apache-2.0 license found in the
8
7
  * LICENSE file in the root directory of this source tree.
9
8
  */
10
9
 
11
- import { Filter16 } from '@carbon/icons-react';
10
+ import React, { useRef, useState, useEffect } from 'react';
12
11
  import { Button } from 'carbon-components-react';
12
+ import { Filter16 } from '@carbon/icons-react';
13
+ import { px, breakpoints } from '@carbon/layout';
13
14
  import cx from 'classnames';
14
15
  import PropTypes from 'prop-types';
15
- import React, { useRef, useState, useEffect } from 'react';
16
- import { useClickOutside } from '../../../../../global/js/hooks';
16
+ import { useClickOutside, useWindowResize } from '../../../../../global/js/hooks';
17
17
  import { pkg } from '../../../../../settings';
18
18
  import { ActionSet } from '../../../../ActionSet';
19
19
  import { BATCH, CLEAR_FILTERS, FLYOUT, INSTANT } from './constants';
@@ -53,6 +53,10 @@ var FilterFlyout = function FilterFlyout(_ref) {
53
53
  _useState2 = _slicedToArray(_useState, 2),
54
54
  open = _useState2[0],
55
55
  setOpen = _useState2[1];
56
+ var _useState3 = useState(false),
57
+ _useState4 = _slicedToArray(_useState3, 2),
58
+ stackedLayout = _useState4[0],
59
+ setStackedLayout = _useState4[1];
56
60
  var _useFilters = useFilters({
57
61
  updateMethod: updateMethod,
58
62
  filters: filters,
@@ -69,9 +73,13 @@ var FilterFlyout = function FilterFlyout(_ref) {
69
73
  renderFilter = _useFilters.renderFilter,
70
74
  filtersObjectArray = _useFilters.filtersObjectArray,
71
75
  lastAppliedFilters = _useFilters.lastAppliedFilters;
76
+ var width = breakpoints.md.width;
77
+ var mdPxWidth = parseInt(width) * 16;
72
78
 
73
79
  /** Refs */
74
80
  var filterFlyoutRef = useRef(null);
81
+ var flyoutInnerRef = useRef(null);
82
+ var flyoutFiltersContainerRef = useRef(null);
75
83
  var _useShouldDisableButt = useShouldDisableButtons({
76
84
  initialValue: true,
77
85
  filtersState: filtersState,
@@ -80,6 +88,33 @@ var FilterFlyout = function FilterFlyout(_ref) {
80
88
  _useShouldDisableButt2 = _slicedToArray(_useShouldDisableButt, 2),
81
89
  shouldDisableButtons = _useShouldDisableButt2[0],
82
90
  setShouldDisableButtons = _useShouldDisableButt2[1];
91
+ var handleResize = function handleResize(current) {
92
+ var filterFlyoutRefPosition = flyoutInnerRef === null || flyoutInnerRef === void 0 ? void 0 : flyoutInnerRef.current.getBoundingClientRect();
93
+ var originalFlyoutWidth = parseInt(window.getComputedStyle(flyoutInnerRef === null || flyoutInnerRef === void 0 ? void 0 : flyoutInnerRef.current).getPropertyValue('width'));
94
+ // Check to see if left value from flyout getBoundingClientRect is a negative number
95
+ // If it is, that is the amount we need to subtract from the flyout width
96
+ if (Math.sign(filterFlyoutRefPosition.left) === -1) {
97
+ var newFlyoutWidth = originalFlyoutWidth - Math.abs(filterFlyoutRefPosition.left);
98
+ flyoutInnerRef.current.style.width = px(newFlyoutWidth);
99
+ }
100
+ // Check to see if left value from flyout getBoundingClientRect is a positive number or 0
101
+ // If it is, that is the amount we need to add to the flyout width until we reach the
102
+ // max-width of the flyout (642)
103
+ if (originalFlyoutWidth < 642 && Math.sign(filterFlyoutRefPosition.left) === 1 || Math.sign(filterFlyoutRefPosition.left).toString() === '0') {
104
+ var _newFlyoutWidth = originalFlyoutWidth + Math.abs(filterFlyoutRefPosition.left);
105
+ flyoutInnerRef.current.style.width = px(_newFlyoutWidth);
106
+ }
107
+ // Begin stacking filters at this specific point
108
+ if ((current === null || current === void 0 ? void 0 : current.innerWidth) <= mdPxWidth + 254) {
109
+ setStackedLayout(true);
110
+ } else {
111
+ setStackedLayout(false);
112
+ }
113
+ };
114
+ useWindowResize(function (_ref2) {
115
+ var current = _ref2.current;
116
+ handleResize(current);
117
+ });
83
118
 
84
119
  /** Memos */
85
120
  var showActionSet = updateMethod === BATCH;
@@ -92,7 +127,12 @@ var FilterFlyout = function FilterFlyout(_ref) {
92
127
  var closeFlyout = function closeFlyout() {
93
128
  setOpen(false);
94
129
  onFlyoutClose();
130
+ flyoutInnerRef.current.style.width = px(642);
95
131
  };
132
+ useEffect(function () {
133
+ // Initialize flyout width
134
+ flyoutInnerRef.current.style.width = px(642);
135
+ }, []);
96
136
  var apply = function apply() {
97
137
  setAllFilters(filtersObjectArray);
98
138
  closeFlyout();
@@ -151,7 +191,8 @@ var FilterFlyout = function FilterFlyout(_ref) {
151
191
  lastAppliedFilters.current = JSON.stringify(reactTableFiltersState);
152
192
  }, [reactTableFiltersState, lastAppliedFilters]);
153
193
  return /*#__PURE__*/React.createElement("div", {
154
- className: "".concat(componentClass, "__container")
194
+ className: "".concat(componentClass, "__container"),
195
+ ref: filterFlyoutRef
155
196
  }, /*#__PURE__*/React.createElement(Button, {
156
197
  kind: "ghost",
157
198
  hasIconOnly: true,
@@ -162,14 +203,15 @@ var FilterFlyout = function FilterFlyout(_ref) {
162
203
  className: cx("".concat(componentClass, "__trigger"), _defineProperty({}, "".concat(componentClass, "__trigger--open"), open)),
163
204
  disabled: data.length === 0
164
205
  }), /*#__PURE__*/React.createElement("div", {
165
- ref: filterFlyoutRef,
206
+ ref: flyoutInnerRef,
166
207
  className: cx(componentClass, (_cx2 = {}, _defineProperty(_cx2, "".concat(componentClass, "--open"), open), _defineProperty(_cx2, "".concat(componentClass, "--batch"), showActionSet), _defineProperty(_cx2, "".concat(componentClass, "--instant"), !showActionSet), _cx2))
167
208
  }, /*#__PURE__*/React.createElement("div", {
168
209
  className: "".concat(componentClass, "__inner-container")
169
210
  }, /*#__PURE__*/React.createElement("span", {
170
211
  className: "".concat(componentClass, "__title")
171
212
  }, title), /*#__PURE__*/React.createElement("div", {
172
- className: "".concat(componentClass, "__filters")
213
+ className: cx("".concat(componentClass, "__filters"), _defineProperty({}, "".concat(componentClass, "__stacked"), stackedLayout)),
214
+ ref: flyoutFiltersContainerRef
173
215
  }, renderFilters())), renderActionSet()));
174
216
  };
175
217
  FilterFlyout.propTypes = {
@@ -36,7 +36,7 @@ export var innerContainerVariants = {
36
36
  return {
37
37
  opacity: 0,
38
38
  transition: {
39
- duration: shouldReduceMotion ? 0 : DURATIONS.fast01,
39
+ duration: shouldReduceMotion ? DURATIONS.moderate01 : DURATIONS.fast01,
40
40
  ease: shouldReduceMotion ? 0 : EASINGS.productive.exit
41
41
  }
42
42
  };
@@ -45,9 +45,9 @@ export var innerContainerVariants = {
45
45
  return {
46
46
  opacity: 1,
47
47
  transition: {
48
- duration: shouldReduceMotion ? 0 : DURATIONS.fast02,
48
+ duration: shouldReduceMotion ? DURATIONS.moderate01 : DURATIONS.fast02,
49
49
  ease: shouldReduceMotion ? 0 : EASINGS.productive.entrance,
50
- when: 'beforeChildren'
50
+ when: shouldReduceMotion ? null : 'beforeChildren'
51
51
  }
52
52
  };
53
53
  }
@@ -55,9 +55,10 @@ export var innerContainerVariants = {
55
55
  export var actionSetVariants = {
56
56
  hidden: function hidden(shouldReduceMotion) {
57
57
  return {
58
- y: ACTION_SET_HEIGHT,
58
+ y: shouldReduceMotion ? 0 : ACTION_SET_HEIGHT,
59
+ opacity: shouldReduceMotion ? 0 : 1,
59
60
  transition: {
60
- duration: shouldReduceMotion ? 0 : DURATIONS.fast01,
61
+ duration: shouldReduceMotion ? DURATIONS.moderate01 : DURATIONS.fast01,
61
62
  ease: shouldReduceMotion ? 0 : EASINGS.productive.exit
62
63
  }
63
64
  };
@@ -65,9 +66,11 @@ export var actionSetVariants = {
65
66
  visible: function visible(shouldReduceMotion) {
66
67
  return {
67
68
  y: 0,
69
+ opacity: 1,
68
70
  transition: {
69
- duration: shouldReduceMotion ? 0 : DURATIONS.fast02,
70
- ease: shouldReduceMotion ? 0 : EASINGS.productive.entrance
71
+ duration: shouldReduceMotion ? DURATIONS.moderate01 : DURATIONS.fast02,
72
+ ease: shouldReduceMotion ? 0 : EASINGS.productive.entrance,
73
+ delay: shouldReduceMotion ? 0.075 : 0
71
74
  }
72
75
  };
73
76
  }
@@ -8,11 +8,12 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.default = void 0;
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
- var _iconsReact = require("@carbon/icons-react");
11
+ var _react = _interopRequireWildcard(require("react"));
12
12
  var _carbonComponentsReact = require("carbon-components-react");
13
+ var _iconsReact = require("@carbon/icons-react");
14
+ var _layout = require("@carbon/layout");
13
15
  var _classnames = _interopRequireDefault(require("classnames"));
14
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
15
- var _react = _interopRequireWildcard(require("react"));
16
17
  var _hooks = require("../../../../../global/js/hooks");
17
18
  var _settings = require("../../../../../settings");
18
19
  var _ActionSet = require("../../../../ActionSet");
@@ -20,9 +21,8 @@ var _constants = require("./constants");
20
21
  var _hooks2 = require("./hooks");
21
22
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
22
23
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
23
- // @flow
24
24
  /**
25
- * Copyright IBM Corp. 2022, 2023
25
+ * Copyright IBM Corp. 2022, 2024
26
26
  *
27
27
  * This source code is licensed under the Apache-2.0 license found in the
28
28
  * LICENSE file in the root directory of this source tree.
@@ -62,6 +62,10 @@ var FilterFlyout = function FilterFlyout(_ref) {
62
62
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
63
63
  open = _useState2[0],
64
64
  setOpen = _useState2[1];
65
+ var _useState3 = (0, _react.useState)(false),
66
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
67
+ stackedLayout = _useState4[0],
68
+ setStackedLayout = _useState4[1];
65
69
  var _useFilters = (0, _hooks2.useFilters)({
66
70
  updateMethod: updateMethod,
67
71
  filters: filters,
@@ -78,9 +82,13 @@ var FilterFlyout = function FilterFlyout(_ref) {
78
82
  renderFilter = _useFilters.renderFilter,
79
83
  filtersObjectArray = _useFilters.filtersObjectArray,
80
84
  lastAppliedFilters = _useFilters.lastAppliedFilters;
85
+ var width = _layout.breakpoints.md.width;
86
+ var mdPxWidth = parseInt(width) * 16;
81
87
 
82
88
  /** Refs */
83
89
  var filterFlyoutRef = (0, _react.useRef)(null);
90
+ var flyoutInnerRef = (0, _react.useRef)(null);
91
+ var flyoutFiltersContainerRef = (0, _react.useRef)(null);
84
92
  var _useShouldDisableButt = (0, _hooks2.useShouldDisableButtons)({
85
93
  initialValue: true,
86
94
  filtersState: filtersState,
@@ -89,6 +97,33 @@ var FilterFlyout = function FilterFlyout(_ref) {
89
97
  _useShouldDisableButt2 = (0, _slicedToArray2.default)(_useShouldDisableButt, 2),
90
98
  shouldDisableButtons = _useShouldDisableButt2[0],
91
99
  setShouldDisableButtons = _useShouldDisableButt2[1];
100
+ var handleResize = function handleResize(current) {
101
+ var filterFlyoutRefPosition = flyoutInnerRef === null || flyoutInnerRef === void 0 ? void 0 : flyoutInnerRef.current.getBoundingClientRect();
102
+ var originalFlyoutWidth = parseInt(window.getComputedStyle(flyoutInnerRef === null || flyoutInnerRef === void 0 ? void 0 : flyoutInnerRef.current).getPropertyValue('width'));
103
+ // Check to see if left value from flyout getBoundingClientRect is a negative number
104
+ // If it is, that is the amount we need to subtract from the flyout width
105
+ if (Math.sign(filterFlyoutRefPosition.left) === -1) {
106
+ var newFlyoutWidth = originalFlyoutWidth - Math.abs(filterFlyoutRefPosition.left);
107
+ flyoutInnerRef.current.style.width = (0, _layout.px)(newFlyoutWidth);
108
+ }
109
+ // Check to see if left value from flyout getBoundingClientRect is a positive number or 0
110
+ // If it is, that is the amount we need to add to the flyout width until we reach the
111
+ // max-width of the flyout (642)
112
+ if (originalFlyoutWidth < 642 && Math.sign(filterFlyoutRefPosition.left) === 1 || Math.sign(filterFlyoutRefPosition.left).toString() === '0') {
113
+ var _newFlyoutWidth = originalFlyoutWidth + Math.abs(filterFlyoutRefPosition.left);
114
+ flyoutInnerRef.current.style.width = (0, _layout.px)(_newFlyoutWidth);
115
+ }
116
+ // Begin stacking filters at this specific point
117
+ if ((current === null || current === void 0 ? void 0 : current.innerWidth) <= mdPxWidth + 254) {
118
+ setStackedLayout(true);
119
+ } else {
120
+ setStackedLayout(false);
121
+ }
122
+ };
123
+ (0, _hooks.useWindowResize)(function (_ref2) {
124
+ var current = _ref2.current;
125
+ handleResize(current);
126
+ });
92
127
 
93
128
  /** Memos */
94
129
  var showActionSet = updateMethod === _constants.BATCH;
@@ -101,7 +136,12 @@ var FilterFlyout = function FilterFlyout(_ref) {
101
136
  var closeFlyout = function closeFlyout() {
102
137
  setOpen(false);
103
138
  onFlyoutClose();
139
+ flyoutInnerRef.current.style.width = (0, _layout.px)(642);
104
140
  };
141
+ (0, _react.useEffect)(function () {
142
+ // Initialize flyout width
143
+ flyoutInnerRef.current.style.width = (0, _layout.px)(642);
144
+ }, []);
105
145
  var apply = function apply() {
106
146
  setAllFilters(filtersObjectArray);
107
147
  closeFlyout();
@@ -160,7 +200,8 @@ var FilterFlyout = function FilterFlyout(_ref) {
160
200
  lastAppliedFilters.current = JSON.stringify(reactTableFiltersState);
161
201
  }, [reactTableFiltersState, lastAppliedFilters]);
162
202
  return /*#__PURE__*/_react.default.createElement("div", {
163
- className: "".concat(componentClass, "__container")
203
+ className: "".concat(componentClass, "__container"),
204
+ ref: filterFlyoutRef
164
205
  }, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
165
206
  kind: "ghost",
166
207
  hasIconOnly: true,
@@ -171,14 +212,15 @@ var FilterFlyout = function FilterFlyout(_ref) {
171
212
  className: (0, _classnames.default)("".concat(componentClass, "__trigger"), (0, _defineProperty2.default)({}, "".concat(componentClass, "__trigger--open"), open)),
172
213
  disabled: data.length === 0
173
214
  }), /*#__PURE__*/_react.default.createElement("div", {
174
- ref: filterFlyoutRef,
215
+ ref: flyoutInnerRef,
175
216
  className: (0, _classnames.default)(componentClass, (_cx2 = {}, (0, _defineProperty2.default)(_cx2, "".concat(componentClass, "--open"), open), (0, _defineProperty2.default)(_cx2, "".concat(componentClass, "--batch"), showActionSet), (0, _defineProperty2.default)(_cx2, "".concat(componentClass, "--instant"), !showActionSet), _cx2))
176
217
  }, /*#__PURE__*/_react.default.createElement("div", {
177
218
  className: "".concat(componentClass, "__inner-container")
178
219
  }, /*#__PURE__*/_react.default.createElement("span", {
179
220
  className: "".concat(componentClass, "__title")
180
221
  }, title), /*#__PURE__*/_react.default.createElement("div", {
181
- className: "".concat(componentClass, "__filters")
222
+ className: (0, _classnames.default)("".concat(componentClass, "__filters"), (0, _defineProperty2.default)({}, "".concat(componentClass, "__stacked"), stackedLayout)),
223
+ ref: flyoutFiltersContainerRef
182
224
  }, renderFilters())), renderActionSet()));
183
225
  };
184
226
  FilterFlyout.propTypes = {
@@ -43,7 +43,7 @@ var innerContainerVariants = {
43
43
  return {
44
44
  opacity: 0,
45
45
  transition: {
46
- duration: shouldReduceMotion ? 0 : _motionConstants.DURATIONS.fast01,
46
+ duration: shouldReduceMotion ? _motionConstants.DURATIONS.moderate01 : _motionConstants.DURATIONS.fast01,
47
47
  ease: shouldReduceMotion ? 0 : _motionConstants.EASINGS.productive.exit
48
48
  }
49
49
  };
@@ -52,9 +52,9 @@ var innerContainerVariants = {
52
52
  return {
53
53
  opacity: 1,
54
54
  transition: {
55
- duration: shouldReduceMotion ? 0 : _motionConstants.DURATIONS.fast02,
55
+ duration: shouldReduceMotion ? _motionConstants.DURATIONS.moderate01 : _motionConstants.DURATIONS.fast02,
56
56
  ease: shouldReduceMotion ? 0 : _motionConstants.EASINGS.productive.entrance,
57
- when: 'beforeChildren'
57
+ when: shouldReduceMotion ? null : 'beforeChildren'
58
58
  }
59
59
  };
60
60
  }
@@ -63,9 +63,10 @@ exports.innerContainerVariants = innerContainerVariants;
63
63
  var actionSetVariants = {
64
64
  hidden: function hidden(shouldReduceMotion) {
65
65
  return {
66
- y: _constants.ACTION_SET_HEIGHT,
66
+ y: shouldReduceMotion ? 0 : _constants.ACTION_SET_HEIGHT,
67
+ opacity: shouldReduceMotion ? 0 : 1,
67
68
  transition: {
68
- duration: shouldReduceMotion ? 0 : _motionConstants.DURATIONS.fast01,
69
+ duration: shouldReduceMotion ? _motionConstants.DURATIONS.moderate01 : _motionConstants.DURATIONS.fast01,
69
70
  ease: shouldReduceMotion ? 0 : _motionConstants.EASINGS.productive.exit
70
71
  }
71
72
  };
@@ -73,9 +74,11 @@ var actionSetVariants = {
73
74
  visible: function visible(shouldReduceMotion) {
74
75
  return {
75
76
  y: 0,
77
+ opacity: 1,
76
78
  transition: {
77
- duration: shouldReduceMotion ? 0 : _motionConstants.DURATIONS.fast02,
78
- ease: shouldReduceMotion ? 0 : _motionConstants.EASINGS.productive.entrance
79
+ duration: shouldReduceMotion ? _motionConstants.DURATIONS.moderate01 : _motionConstants.DURATIONS.fast02,
80
+ ease: shouldReduceMotion ? 0 : _motionConstants.EASINGS.productive.entrance,
81
+ delay: shouldReduceMotion ? 0.075 : 0
79
82
  }
80
83
  };
81
84
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/ibm-products",
3
3
  "description": "Carbon for IBM Products",
4
- "version": "1.66.0",
4
+ "version": "1.67.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -97,5 +97,5 @@
97
97
  "react": "^16.8.6 || ^17.0.1",
98
98
  "react-dom": "^16.8.6 || ^17.0.1"
99
99
  },
100
- "gitHead": "7af504361db8089815fc8527da02eaad1871362e"
100
+ "gitHead": "9d38cf405fc58bb75d8bab999816bf18c8d63167"
101
101
  }
@@ -1,10 +1,9 @@
1
- /*
2
- * Licensed Materials - Property of IBM
3
- * 5724-Q36
4
- * (c) Copyright IBM Corp. 2022
5
- * US Government Users Restricted Rights - Use, duplication or disclosure
6
- * restricted by GSA ADP Schedule Contract with IBM Corp.
7
- */
1
+ //
2
+ // Copyright IBM Corp. 2022, 2024
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
+ //
8
7
 
9
8
  // stylelint-disable carbon/layout-token-use
10
9
 
@@ -65,7 +64,7 @@ $action-set-height: rem(64px);
65
64
  .#{$block-class}-filter-flyout__filters {
66
65
  display: grid;
67
66
  gap: rem(16px) rem(32px);
68
- grid-template-columns: 1fr 1fr;
67
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
69
68
  }
70
69
 
71
70
  // Carbon overrides
@@ -78,3 +77,7 @@ $action-set-height: rem(64px);
78
77
  .#{$block-class}-filter-flyout .#{$carbon-prefix}--fieldset {
79
78
  margin-bottom: 0;
80
79
  }
80
+
81
+ .#{$block-class}-filter-flyout__stacked {
82
+ grid-template-columns: 1fr;
83
+ }