@carbon/react 1.56.0-rc.1 → 1.56.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.
@@ -6,9 +6,5 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import { type SearchProps } from '../Search';
9
- declare function ExpandableSearch({ onBlur, onChange, onExpand, onKeyDown, defaultValue, isExpanded, ...props }: SearchProps): import("react/jsx-runtime").JSX.Element;
10
- declare namespace ExpandableSearch {
11
- var propTypes: React.WeakValidationMap<SearchProps & React.RefAttributes<HTMLInputElement>> | undefined;
12
- var displayName: string;
13
- }
9
+ declare const ExpandableSearch: React.ForwardRefExoticComponent<SearchProps & React.RefAttributes<HTMLInputElement>>;
14
10
  export default ExpandableSearch;
@@ -12,10 +12,11 @@ import Search from '../Search/Search.js';
12
12
  import '../Search/Search.Skeleton.js';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
14
14
  import { composeEventHandlers } from '../../tools/events.js';
15
+ import mergeRefs from '../../tools/mergeRefs.js';
15
16
  import { match } from '../../internal/keyboard/match.js';
16
17
  import { Escape } from '../../internal/keyboard/keys.js';
17
18
 
18
- function ExpandableSearch(_ref) {
19
+ const ExpandableSearch = /*#__PURE__*/React__default.forwardRef(function ExpandableSearch(_ref, forwardedRef) {
19
20
  let {
20
21
  onBlur,
21
22
  onChange,
@@ -61,14 +62,14 @@ function ExpandableSearch(_ref) {
61
62
  return /*#__PURE__*/React__default.createElement(Search, _extends({}, props, {
62
63
  defaultValue: defaultValue,
63
64
  isExpanded: expanded,
64
- ref: searchRef,
65
+ ref: mergeRefs(searchRef, forwardedRef),
65
66
  className: classes,
66
67
  onBlur: composeEventHandlers([onBlur, handleBlur]),
67
68
  onChange: composeEventHandlers([onChange, handleChange]),
68
69
  onExpand: composeEventHandlers([onExpand, handleExpand]),
69
70
  onKeyDown: composeEventHandlers([onKeyDown, handleKeyDown])
70
71
  }));
71
- }
72
+ });
72
73
  ExpandableSearch.propTypes = Search.propTypes;
73
74
  ExpandableSearch.displayName = 'ExpandableSearch';
74
75
 
@@ -427,6 +427,10 @@ class Slider extends PureComponent {
427
427
  }
428
428
  });
429
429
  _defineProperty(this, "processNewInputValue", input => {
430
+ this.setState({
431
+ correctedValue: null,
432
+ correctedPosition: null
433
+ });
430
434
  const targetValue = Number.parseFloat(input.value);
431
435
  const validity = !isNaN(targetValue);
432
436
 
@@ -978,8 +982,8 @@ class Slider extends PureComponent {
978
982
  correctedPosition,
979
983
  isRtl
980
984
  } = this.state;
981
- const showWarning = !readOnly && warn && isValid || typeof correctedValue !== null && correctedPosition === HandlePosition.LOWER;
982
- const showWarningUpper = !readOnly && warn && (twoHandles ? isValidUpper : isValid) || typeof correctedValue !== null && correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER);
985
+ const showWarning = !readOnly && warn || typeof correctedValue !== null && correctedPosition === HandlePosition.LOWER && isValid;
986
+ const showWarningUpper = !readOnly && warn || typeof correctedValue !== null && correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER) && (twoHandles ? isValidUpper : isValid);
983
987
  return /*#__PURE__*/React__default.createElement(PrefixContext.Consumer, null, prefix => {
984
988
  const labelId = `${id}-label`;
985
989
  const labelClasses = cx(`${prefix}--label`, {
@@ -14,6 +14,8 @@ import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.
14
14
  import { textInputProps } from './util.js';
15
15
  import '../FluidForm/FluidForm.js';
16
16
  import { FormContext } from '../FluidForm/FormContext.js';
17
+ import '../Tooltip/DefinitionTooltip.js';
18
+ import { Tooltip } from '../Tooltip/Tooltip.js';
17
19
  import deprecate from '../../prop-types/deprecate.js';
18
20
  import { usePrefix } from '../../internal/usePrefix.js';
19
21
 
@@ -38,7 +40,7 @@ const PasswordInput = /*#__PURE__*/React__default.forwardRef(function PasswordIn
38
40
  size = 'md',
39
41
  showPasswordLabel = 'Show password',
40
42
  tooltipPosition = 'bottom',
41
- tooltipAlignment = 'center',
43
+ tooltipAlignment = 'end',
42
44
  type = 'password',
43
45
  warn = false,
44
46
  warnText,
@@ -127,11 +129,25 @@ const PasswordInput = /*#__PURE__*/React__default.forwardRef(function PasswordIn
127
129
  }) : /*#__PURE__*/React__default.createElement(View, {
128
130
  className: `${prefix}--icon-visibility-on`
129
131
  });
130
- const passwordVisibilityToggleClasses = cx(`${prefix}--text-input--password__visibility__toggle`, `${prefix}--btn`, `${prefix}--btn--icon-only`, `${prefix}--tooltip__trigger`, `${prefix}--tooltip--a11y`, {
131
- [`${prefix}--btn--disabled`]: disabled,
132
+ const passwordVisibilityToggleClasses = cx(`${prefix}--text-input--password__visibility__toggle`, `${prefix}--btn`, `${prefix}--tooltip__trigger`, `${prefix}--tooltip--a11y`, {
132
133
  [`${prefix}--tooltip--${tooltipPosition}`]: tooltipPosition,
133
134
  [`${prefix}--tooltip--align-${tooltipAlignment}`]: tooltipAlignment
134
135
  });
136
+ let align = undefined;
137
+ if (tooltipPosition === 'top' || tooltipPosition === 'bottom') {
138
+ if (tooltipAlignment === 'center') {
139
+ align = tooltipPosition;
140
+ }
141
+ if (tooltipAlignment === 'end') {
142
+ align = `${tooltipPosition}-right`;
143
+ }
144
+ if (tooltipAlignment === 'start') {
145
+ align = `${tooltipPosition}-left`;
146
+ }
147
+ }
148
+ if (tooltipPosition === 'right' || tooltipPosition === 'left') {
149
+ align = tooltipPosition;
150
+ }
135
151
  const input = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("input", _extends({}, textInputProps({
136
152
  sharedTextInputProps,
137
153
  invalid: normalizedProps.invalid,
@@ -145,14 +161,16 @@ const PasswordInput = /*#__PURE__*/React__default.forwardRef(function PasswordIn
145
161
  "data-toggle-password-visibility": inputType === 'password'
146
162
  })), isFluid && /*#__PURE__*/React__default.createElement("hr", {
147
163
  className: `${prefix}--text-input__divider`
148
- }), /*#__PURE__*/React__default.createElement("button", {
164
+ }), /*#__PURE__*/React__default.createElement(Tooltip, {
165
+ align: align,
166
+ className: `${prefix}--toggle-password-tooltip`,
167
+ label: passwordIsVisible ? hidePasswordLabel : showPasswordLabel
168
+ }, /*#__PURE__*/React__default.createElement("button", {
149
169
  type: "button",
150
170
  className: passwordVisibilityToggleClasses,
151
171
  disabled: disabled,
152
172
  onClick: handleTogglePasswordVisibility
153
- }, !disabled && /*#__PURE__*/React__default.createElement("span", {
154
- className: `${prefix}--assistive-text`
155
- }, passwordIsVisible ? hidePasswordLabel : showPasswordLabel), passwordVisibilityIcon));
173
+ }, passwordVisibilityIcon)));
156
174
  useEffect(() => {
157
175
  setInputType(type);
158
176
  }, [type]);
@@ -6,9 +6,5 @@
6
6
  */
7
7
  import React from 'react';
8
8
  import { type SearchProps } from '../Search';
9
- declare function ExpandableSearch({ onBlur, onChange, onExpand, onKeyDown, defaultValue, isExpanded, ...props }: SearchProps): import("react/jsx-runtime").JSX.Element;
10
- declare namespace ExpandableSearch {
11
- var propTypes: React.WeakValidationMap<SearchProps & React.RefAttributes<HTMLInputElement>> | undefined;
12
- var displayName: string;
13
- }
9
+ declare const ExpandableSearch: React.ForwardRefExoticComponent<SearchProps & React.RefAttributes<HTMLInputElement>>;
14
10
  export default ExpandableSearch;
@@ -16,6 +16,7 @@ var Search = require('../Search/Search.js');
16
16
  require('../Search/Search.Skeleton.js');
17
17
  var usePrefix = require('../../internal/usePrefix.js');
18
18
  var events = require('../../tools/events.js');
19
+ var mergeRefs = require('../../tools/mergeRefs.js');
19
20
  var match = require('../../internal/keyboard/match.js');
20
21
  var keys = require('../../internal/keyboard/keys.js');
21
22
 
@@ -24,7 +25,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
24
25
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
25
26
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
26
27
 
27
- function ExpandableSearch(_ref) {
28
+ const ExpandableSearch = /*#__PURE__*/React__default["default"].forwardRef(function ExpandableSearch(_ref, forwardedRef) {
28
29
  let {
29
30
  onBlur,
30
31
  onChange,
@@ -70,14 +71,14 @@ function ExpandableSearch(_ref) {
70
71
  return /*#__PURE__*/React__default["default"].createElement(Search["default"], _rollupPluginBabelHelpers["extends"]({}, props, {
71
72
  defaultValue: defaultValue,
72
73
  isExpanded: expanded,
73
- ref: searchRef,
74
+ ref: mergeRefs["default"](searchRef, forwardedRef),
74
75
  className: classes,
75
76
  onBlur: events.composeEventHandlers([onBlur, handleBlur]),
76
77
  onChange: events.composeEventHandlers([onChange, handleChange]),
77
78
  onExpand: events.composeEventHandlers([onExpand, handleExpand]),
78
79
  onKeyDown: events.composeEventHandlers([onKeyDown, handleKeyDown])
79
80
  }));
80
- }
81
+ });
81
82
  ExpandableSearch.propTypes = Search["default"].propTypes;
82
83
  ExpandableSearch.displayName = 'ExpandableSearch';
83
84
 
@@ -438,6 +438,10 @@ class Slider extends React.PureComponent {
438
438
  }
439
439
  });
440
440
  _rollupPluginBabelHelpers.defineProperty(this, "processNewInputValue", input => {
441
+ this.setState({
442
+ correctedValue: null,
443
+ correctedPosition: null
444
+ });
441
445
  const targetValue = Number.parseFloat(input.value);
442
446
  const validity = !isNaN(targetValue);
443
447
 
@@ -989,8 +993,8 @@ class Slider extends React.PureComponent {
989
993
  correctedPosition,
990
994
  isRtl
991
995
  } = this.state;
992
- const showWarning = !readOnly && warn && isValid || typeof correctedValue !== null && correctedPosition === HandlePosition.LOWER;
993
- const showWarningUpper = !readOnly && warn && (twoHandles ? isValidUpper : isValid) || typeof correctedValue !== null && correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER);
996
+ const showWarning = !readOnly && warn || typeof correctedValue !== null && correctedPosition === HandlePosition.LOWER && isValid;
997
+ const showWarningUpper = !readOnly && warn || typeof correctedValue !== null && correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER) && (twoHandles ? isValidUpper : isValid);
994
998
  return /*#__PURE__*/React__default["default"].createElement(usePrefix.PrefixContext.Consumer, null, prefix => {
995
999
  const labelId = `${id}-label`;
996
1000
  const labelClasses = cx__default["default"](`${prefix}--label`, {
@@ -18,6 +18,8 @@ var useNormalizedInputProps = require('../../internal/useNormalizedInputProps.js
18
18
  var util = require('./util.js');
19
19
  require('../FluidForm/FluidForm.js');
20
20
  var FormContext = require('../FluidForm/FormContext.js');
21
+ require('../Tooltip/DefinitionTooltip.js');
22
+ var Tooltip = require('../Tooltip/Tooltip.js');
21
23
  var deprecate = require('../../prop-types/deprecate.js');
22
24
  var usePrefix = require('../../internal/usePrefix.js');
23
25
 
@@ -48,7 +50,7 @@ const PasswordInput = /*#__PURE__*/React__default["default"].forwardRef(function
48
50
  size = 'md',
49
51
  showPasswordLabel = 'Show password',
50
52
  tooltipPosition = 'bottom',
51
- tooltipAlignment = 'center',
53
+ tooltipAlignment = 'end',
52
54
  type = 'password',
53
55
  warn = false,
54
56
  warnText,
@@ -137,11 +139,25 @@ const PasswordInput = /*#__PURE__*/React__default["default"].forwardRef(function
137
139
  }) : /*#__PURE__*/React__default["default"].createElement(iconsReact.View, {
138
140
  className: `${prefix}--icon-visibility-on`
139
141
  });
140
- const passwordVisibilityToggleClasses = cx__default["default"](`${prefix}--text-input--password__visibility__toggle`, `${prefix}--btn`, `${prefix}--btn--icon-only`, `${prefix}--tooltip__trigger`, `${prefix}--tooltip--a11y`, {
141
- [`${prefix}--btn--disabled`]: disabled,
142
+ const passwordVisibilityToggleClasses = cx__default["default"](`${prefix}--text-input--password__visibility__toggle`, `${prefix}--btn`, `${prefix}--tooltip__trigger`, `${prefix}--tooltip--a11y`, {
142
143
  [`${prefix}--tooltip--${tooltipPosition}`]: tooltipPosition,
143
144
  [`${prefix}--tooltip--align-${tooltipAlignment}`]: tooltipAlignment
144
145
  });
146
+ let align = undefined;
147
+ if (tooltipPosition === 'top' || tooltipPosition === 'bottom') {
148
+ if (tooltipAlignment === 'center') {
149
+ align = tooltipPosition;
150
+ }
151
+ if (tooltipAlignment === 'end') {
152
+ align = `${tooltipPosition}-right`;
153
+ }
154
+ if (tooltipAlignment === 'start') {
155
+ align = `${tooltipPosition}-left`;
156
+ }
157
+ }
158
+ if (tooltipPosition === 'right' || tooltipPosition === 'left') {
159
+ align = tooltipPosition;
160
+ }
145
161
  const input = /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("input", _rollupPluginBabelHelpers["extends"]({}, util.textInputProps({
146
162
  sharedTextInputProps,
147
163
  invalid: normalizedProps.invalid,
@@ -155,14 +171,16 @@ const PasswordInput = /*#__PURE__*/React__default["default"].forwardRef(function
155
171
  "data-toggle-password-visibility": inputType === 'password'
156
172
  })), isFluid && /*#__PURE__*/React__default["default"].createElement("hr", {
157
173
  className: `${prefix}--text-input__divider`
158
- }), /*#__PURE__*/React__default["default"].createElement("button", {
174
+ }), /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
175
+ align: align,
176
+ className: `${prefix}--toggle-password-tooltip`,
177
+ label: passwordIsVisible ? hidePasswordLabel : showPasswordLabel
178
+ }, /*#__PURE__*/React__default["default"].createElement("button", {
159
179
  type: "button",
160
180
  className: passwordVisibilityToggleClasses,
161
181
  disabled: disabled,
162
182
  onClick: handleTogglePasswordVisibility
163
- }, !disabled && /*#__PURE__*/React__default["default"].createElement("span", {
164
- className: `${prefix}--assistive-text`
165
- }, passwordIsVisible ? hidePasswordLabel : showPasswordLabel), passwordVisibilityIcon));
183
+ }, passwordVisibilityIcon)));
166
184
  React.useEffect(() => {
167
185
  setInputType(type);
168
186
  }, [type]);
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.56.0-rc.1",
4
+ "version": "1.56.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -49,9 +49,9 @@
49
49
  "dependencies": {
50
50
  "@babel/runtime": "^7.18.3",
51
51
  "@carbon/feature-flags": "^0.19.0",
52
- "@carbon/icons-react": "^11.40.0-rc.1",
52
+ "@carbon/icons-react": "^11.40.0",
53
53
  "@carbon/layout": "^11.21.0",
54
- "@carbon/styles": "^1.55.1-rc.0",
54
+ "@carbon/styles": "^1.56.0",
55
55
  "@floating-ui/react": "^0.26.0",
56
56
  "@ibm/telemetry-js": "^1.4.0",
57
57
  "classnames": "2.5.1",
@@ -141,5 +141,5 @@
141
141
  "**/*.scss",
142
142
  "**/*.css"
143
143
  ],
144
- "gitHead": "c6ef02eb0fa5b2dcaccbbe60d45f26884a167948"
144
+ "gitHead": "7d883c90790c14c76ce131a62121a533ffe6af6f"
145
145
  }