@carbon/react 1.58.0 → 1.58.1

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.
@@ -20,6 +20,8 @@ require('../Text/index.js');
20
20
  var deprecate = require('../../prop-types/deprecate.js');
21
21
  var DefinitionTooltip = require('../Tooltip/DefinitionTooltip.js');
22
22
  require('../Tooltip/Tooltip.js');
23
+ var isEllipsisActive = require('./isEllipsisActive.js');
24
+ var react = require('@floating-ui/react');
23
25
  var Text = require('../Text/Text.js');
24
26
 
25
27
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -49,7 +51,7 @@ const SIZES = {
49
51
  md: 'md',
50
52
  lg: 'lg'
51
53
  };
52
- const Tag = _ref => {
54
+ const Tag = /*#__PURE__*/React__default["default"].forwardRef(function Tag(_ref, forwardRef) {
53
55
  let {
54
56
  children,
55
57
  className,
@@ -69,17 +71,14 @@ const Tag = _ref => {
69
71
  ...other
70
72
  } = _ref;
71
73
  const prefix = usePrefix.usePrefix();
74
+ const tagRef = React.useRef();
75
+ const ref = react.useMergeRefs([forwardRef, tagRef]);
72
76
  const tagId = id || `tag-${getInstanceId()}`;
73
77
  const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
74
- const isEllipsisActive = element => {
75
- setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
76
- return element.offsetWidth < element.scrollWidth;
77
- };
78
78
  React.useLayoutEffect(() => {
79
- const elementTagId = document.querySelector(`#${tagId}`);
80
- const newElement = elementTagId?.getElementsByClassName(`${prefix}--tag__label`)[0];
81
- isEllipsisActive(newElement);
82
- }, [prefix, tagId]);
79
+ const newElement = tagRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
80
+ setIsEllipsisApplied(isEllipsisActive.isEllipsisActive(newElement));
81
+ }, [prefix, tagRef]);
83
82
  const conditions = [`${prefix}--tag--selectable`, `${prefix}--tag--filter`, `${prefix}--tag--operational`];
84
83
  const isInteractiveTag = conditions.some(el => className?.includes(el));
85
84
  const tagClasses = cx__default["default"](`${prefix}--tag`, className, {
@@ -132,6 +131,7 @@ const Tag = _ref => {
132
131
  [`${prefix}--tag--${type}`]: type && !isInteractiveTag
133
132
  });
134
133
  return /*#__PURE__*/React__default["default"].createElement(ComponentTag, _rollupPluginBabelHelpers["extends"]({
134
+ ref: ref,
135
135
  disabled: disabled,
136
136
  className: tagClasses,
137
137
  id: tagId
@@ -148,7 +148,7 @@ const Tag = _ref => {
148
148
  title: children !== null && children !== undefined ? children : typeText,
149
149
  className: labelClasses
150
150
  }, children !== null && children !== undefined ? children : typeText), normalizedSlug);
151
- };
151
+ });
152
152
  Tag.propTypes = {
153
153
  /**
154
154
  * Provide an alternative tag or component to use instead of the default
@@ -170,7 +170,7 @@ Tag.propTypes = {
170
170
  /**
171
171
  * Determine if `Tag` is a filter/chip
172
172
  */
173
- filter: deprecate["default"](PropTypes__default["default"].bool, 'This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
173
+ filter: deprecate["default"](PropTypes__default["default"].bool, 'The `filter` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
174
174
  /**
175
175
  * Specify the id for the tag.
176
176
  */
@@ -178,7 +178,7 @@ Tag.propTypes = {
178
178
  /**
179
179
  * Click handler for filter tag close button.
180
180
  */
181
- onClose: deprecate["default"](PropTypes__default["default"].func, 'This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
181
+ onClose: deprecate["default"](PropTypes__default["default"].func, 'The `onClose` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
182
182
  /**
183
183
  * Optional prop to render a custom icon.
184
184
  * Can be a React component class
@@ -196,7 +196,7 @@ Tag.propTypes = {
196
196
  /**
197
197
  * Text to show on clear filters
198
198
  */
199
- title: deprecate["default"](PropTypes__default["default"].string, 'This property is deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
199
+ title: deprecate["default"](PropTypes__default["default"].string, 'The `title` prop has been deprecated and will be removed in the next major version. Use DismissibleTag instead.'),
200
200
  /**
201
201
  * Specify the type of the `Tag`
202
202
  */
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 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
+ */
7
+ export declare const isEllipsisActive: (element: any) => boolean;
@@ -0,0 +1,19 @@
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
+ const isEllipsisActive = element => {
13
+ if (element) {
14
+ return element?.offsetWidth < element?.scrollWidth;
15
+ }
16
+ return false;
17
+ };
18
+
19
+ exports.isEllipsisActive = isEllipsisActive;
@@ -95,7 +95,7 @@ function Tooltip(_ref) {
95
95
  }
96
96
  function onMouseEnter() {
97
97
  // Interactive Tags should not support onMouseEnter
98
- if (!rest?.onMouseEnter?.()) {
98
+ if (!rest?.onMouseEnter) {
99
99
  setIsPointerIntersecting(true);
100
100
  setOpen(true, enterDelayMs);
101
101
  }
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.58.0",
4
+ "version": "1.58.1",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -141,5 +141,5 @@
141
141
  "**/*.scss",
142
142
  "**/*.css"
143
143
  ],
144
- "gitHead": "574070ef9eef05d6e1e5899354bbadc77ba5f3ee"
144
+ "gitHead": "08968165fe61174317b023555b812528d21bab39"
145
145
  }