@carbon/react 1.61.0-rc.1 → 1.62.0-rc.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.
@@ -217,7 +217,8 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
217
217
  setHighlightedIndex(changes.selectedItem);
218
218
  if (onChange) {
219
219
  onChange({
220
- selectedItem: changes.selectedItem
220
+ selectedItem: changes.selectedItem,
221
+ inputValue
221
222
  });
222
223
  }
223
224
  return changes;
@@ -430,6 +431,16 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
430
431
  if (highlightedIndex !== -1) {
431
432
  selectItem(filterItems(items, itemToString, inputValue)[highlightedIndex]);
432
433
  }
434
+
435
+ // Since `onChange` does not normally fire when the menu is closed, we should
436
+ // manually fire it when `allowCustomValue` is provided, the menu is closing,
437
+ // and there is a value.
438
+ if (allowCustomValue && isOpen && inputValue) {
439
+ onChange({
440
+ selectedItem,
441
+ inputValue
442
+ });
443
+ }
433
444
  event.preventDownshiftDefault = true;
434
445
  event?.persist?.();
435
446
  }
@@ -21,6 +21,7 @@ import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsT
21
21
  import wrapFocus, { wrapFocusWithoutSentinels, elementOrParentIsFloatingMenu } from '../../internal/wrapFocus.js';
22
22
  import { usePrefix } from '../../internal/usePrefix.js';
23
23
  import { useFeatureFlag } from '../FeatureFlags/index.js';
24
+ import { composeEventHandlers } from '../../tools/events.js';
24
25
  import { match } from '../../internal/keyboard/match.js';
25
26
  import { Escape, Tab } from '../../internal/keyboard/keys.js';
26
27
 
@@ -148,7 +149,7 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
148
149
  }
149
150
  onKeyDown?.(event);
150
151
  }
151
- function handleMousedown(evt) {
152
+ function handleOnClick(evt) {
152
153
  const target = evt.target;
153
154
  evt.stopPropagation();
154
155
  if (!preventCloseOnClickOutside && !elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target)) {
@@ -256,7 +257,7 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
256
257
  ref: ref,
257
258
  "aria-hidden": !open,
258
259
  onBlur: !focusTrapWithoutSentinels ? handleBlur : () => {},
259
- onMouseDown: handleMousedown,
260
+ onClick: composeEventHandlers([rest?.onClick, handleOnClick]),
260
261
  onKeyDown: handleKeyDown,
261
262
  className: modalClass
262
263
  }), /*#__PURE__*/React__default.createElement("div", {
@@ -25,14 +25,16 @@ var carbonFlatpickrRangePlugin = (config => {
25
25
  origSetDate.call(this, dates, triggerChange, format);
26
26
  // If `triggerChange` is `true`, `onValueUpdate` Flatpickr event is fired
27
27
  // where Flatpickr's range plugin takes care of fixing the first `<input>`
28
- if (!triggerChange) {
28
+ if (!triggerChange && dates.length === 2) {
29
29
  const {
30
- _input: inputDates
30
+ _input: inputFrom
31
31
  } = fp;
32
- const inputDatesArray = inputDates.value.split(' ');
33
- [inputDatesArray[0], inputDatesArray[2]].forEach((input, i) => {
32
+ const {
33
+ input: inputTo
34
+ } = config;
35
+ [inputFrom, inputTo].forEach((input, i) => {
34
36
  if (input) {
35
- input = !dates[i] ? '' : fp.formatDate(new Date(dates[i]), fp.config.dateFormat);
37
+ input.value = !dates[i] ? '' : fp.formatDate(new Date(dates[i]), fp.config.dateFormat);
36
38
  }
37
39
  });
38
40
  }
@@ -4,7 +4,6 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import 'wicg-inert';
8
7
  import React from 'react';
9
8
  import { ReactAttr } from '../../types/common';
10
9
  export interface DialogProps extends ReactAttr<HTMLDialogElement> {
@@ -26,6 +25,6 @@ export interface DialogProps extends ReactAttr<HTMLDialogElement> {
26
25
  */
27
26
  open?: boolean;
28
27
  }
29
- declare const Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<unknown>>;
30
- export { Dialog };
31
- export default Dialog;
28
+ declare const unstable__Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<unknown>>;
29
+ export { unstable__Dialog };
30
+ export default unstable__Dialog;
@@ -26,6 +26,7 @@ import { IconButton } from '../IconButton/index.js';
26
26
  import { noopFn } from '../../internal/noopFn.js';
27
27
  import '../Text/index.js';
28
28
  import { useFeatureFlag } from '../FeatureFlags/index.js';
29
+ import { composeEventHandlers } from '../../tools/events.js';
29
30
  import { Text } from '../Text/Text.js';
30
31
  import { match } from '../../internal/keyboard/match.js';
31
32
  import { Escape, Enter, Tab } from '../../internal/keyboard/keys.js';
@@ -106,7 +107,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
106
107
  }
107
108
  }
108
109
  }
109
- function handleMousedown(evt) {
110
+ function handleOnClick(evt) {
110
111
  const target = evt.target;
111
112
  evt.stopPropagation();
112
113
  if (!preventCloseOnClickOutside && !elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target)) {
@@ -305,7 +306,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
305
306
  return /*#__PURE__*/React__default.createElement(Layer, _extends({}, rest, {
306
307
  level: 0,
307
308
  onKeyDown: handleKeyDown,
308
- onMouseDown: handleMousedown,
309
+ onClick: composeEventHandlers([rest?.onClick, handleOnClick]),
309
310
  onBlur: !focusTrapWithoutSentinels ? handleBlur : () => {},
310
311
  className: modalClasses,
311
312
  role: "presentation",
@@ -120,15 +120,15 @@ const Search = /*#__PURE__*/React__default.forwardRef(function Search(_ref, forw
120
120
  "aria-label": placeholder,
121
121
  className: searchClasses
122
122
  }, /*#__PURE__*/React__default.createElement("div", {
123
- "aria-label": "button",
123
+ "aria-label": onExpand ? 'button' : undefined,
124
124
  "aria-labelledby": onExpand ? uniqueId : undefined,
125
- role: "button",
125
+ role: onExpand ? 'button' : undefined,
126
126
  className: `${prefix}--search-magnifier`,
127
127
  onClick: onExpand,
128
128
  onKeyDown: handleExpandButtonKeyDown,
129
129
  tabIndex: onExpand && !isExpanded ? 0 : -1,
130
130
  ref: expandButtonRef,
131
- "aria-expanded": onExpand && isExpanded ? true : false,
131
+ "aria-expanded": onExpand && isExpanded ? true : onExpand && !isExpanded ? false : undefined,
132
132
  "aria-controls": onExpand ? uniqueId : undefined
133
133
  }, /*#__PURE__*/React__default.createElement(CustomSearchIcon, {
134
134
  icon: renderIcon
@@ -36,7 +36,7 @@ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
36
36
  */
37
37
  disabled?: boolean;
38
38
  /**
39
- * The callback to format the label associated with the minimum/maximum value.
39
+ * The callback to format the label associated with the minimum/maximum value and the value tooltip when hideTextInput is true.
40
40
  */
41
41
  formatLabel?: (value: number, label: string | undefined) => string;
42
42
  /**
@@ -1092,13 +1092,14 @@ class Slider extends PureComponent {
1092
1092
  }, other), /*#__PURE__*/React__default.createElement(ThumbWrapper, _extends({
1093
1093
  hasTooltip: hideTextInput,
1094
1094
  className: lowerThumbWrapperClasses,
1095
- label: `${value}`,
1095
+ label: `${formatLabel(value, '')}`,
1096
1096
  align: "top"
1097
1097
  }, lowerThumbWrapperProps), /*#__PURE__*/React__default.createElement("div", {
1098
1098
  className: lowerThumbClasses,
1099
1099
  role: "slider",
1100
1100
  id: twoHandles ? undefined : id,
1101
1101
  tabIndex: !readOnly ? 0 : -1,
1102
+ "aria-valuetext": `${formatLabel(value, '')}`,
1102
1103
  "aria-valuemax": twoHandles ? valueUpper : max,
1103
1104
  "aria-valuemin": min,
1104
1105
  "aria-valuenow": value,
@@ -1111,7 +1112,7 @@ class Slider extends PureComponent {
1111
1112
  }, twoHandles && !isRtl ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, _LowerHandle || (_LowerHandle = /*#__PURE__*/React__default.createElement(LowerHandle, null)), _LowerHandleFocus || (_LowerHandleFocus = /*#__PURE__*/React__default.createElement(LowerHandleFocus, null))) : twoHandles && isRtl ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, _UpperHandle || (_UpperHandle = /*#__PURE__*/React__default.createElement(UpperHandle, null)), _UpperHandleFocus || (_UpperHandleFocus = /*#__PURE__*/React__default.createElement(UpperHandleFocus, null))) : undefined)), twoHandles ? /*#__PURE__*/React__default.createElement(ThumbWrapper, _extends({
1112
1113
  hasTooltip: hideTextInput,
1113
1114
  className: upperThumbWrapperClasses,
1114
- label: `${valueUpper}`,
1115
+ label: `${formatLabel(valueUpper || 0, '')}`,
1115
1116
  align: "top"
1116
1117
  }, upperThumbWrapperProps), /*#__PURE__*/React__default.createElement("div", {
1117
1118
  className: upperThumbClasses,
@@ -77,6 +77,63 @@ declare namespace Tabs {
77
77
  selectedIndex: PropTypes.Requireable<number>;
78
78
  };
79
79
  }
80
+ export interface TabsVerticalProps {
81
+ /**
82
+ * Provide child elements to be rendered inside the `TabsVertical`.
83
+ * These elements should render either `TabsListVertical` or `TabsPanels`
84
+ */
85
+ children?: ReactNode;
86
+ /**
87
+ * Specify which content tab should be initially selected when the component
88
+ * is first rendered
89
+ */
90
+ defaultSelectedIndex?: number;
91
+ /**
92
+ * Option to set a height style only if using vertical variation
93
+ */
94
+ height?: string;
95
+ /**
96
+ * Provide an optional function which is called
97
+ * whenever the state of the `Tabs` changes
98
+ */
99
+ onChange?(state: {
100
+ selectedIndex: number;
101
+ }): void;
102
+ /**
103
+ * Control which content panel is currently selected. This puts the component
104
+ * in a controlled mode and should be used along with `onChange`
105
+ */
106
+ selectedIndex?: number;
107
+ }
108
+ declare function TabsVertical({ children, height, defaultSelectedIndex, onChange, selectedIndex: controlledSelectedIndex, ...rest }: TabsVerticalProps): import("react/jsx-runtime").JSX.Element;
109
+ declare namespace TabsVertical {
110
+ var propTypes: {
111
+ /**
112
+ * Provide child elements to be rendered inside the `TabsVertical`.
113
+ * These elements should render either `TabsListVertical` or `TabsPanels`
114
+ */
115
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
116
+ /**
117
+ * Specify which content tab should be initially selected when the component
118
+ * is first rendered
119
+ */
120
+ defaultSelectedIndex: PropTypes.Requireable<number>;
121
+ /**
122
+ * Option to set a height style only if using vertical variation
123
+ */
124
+ height: PropTypes.Requireable<string>;
125
+ /**
126
+ * Provide an optional function which is called whenever the state of the
127
+ * `Tabs` changes
128
+ */
129
+ onChange: PropTypes.Requireable<(...args: any[]) => any>;
130
+ /**
131
+ * Control which content panel is currently selected. This puts the component
132
+ * in a controlled mode and should be used along with `onChange`
133
+ */
134
+ selectedIndex: PropTypes.Requireable<number>;
135
+ };
136
+ }
80
137
  /**
81
138
  * TabList
82
139
  */
@@ -195,6 +252,59 @@ declare namespace TabList {
195
252
  scrollIntoView: PropTypes.Requireable<boolean>;
196
253
  };
197
254
  }
255
+ /**
256
+ * TabListVertical
257
+ */
258
+ export interface TabListVerticalProps extends DivAttributes {
259
+ /**
260
+ * Specify whether the content tab should be activated automatically or
261
+ * manually
262
+ */
263
+ activation?: 'automatic' | 'manual';
264
+ /**
265
+ * Provide an accessible label to be read when a user interacts with this
266
+ * component
267
+ */
268
+ 'aria-label': string;
269
+ /**
270
+ * Provide child elements to be rendered inside `ContentTabs`.
271
+ * These elements should render a `ContentTab`
272
+ */
273
+ children?: ReactNode;
274
+ /**
275
+ * Specify an optional className to be added to the container node
276
+ */
277
+ className?: string;
278
+ /**
279
+ * Choose whether to automatically scroll to newly selected tabs
280
+ * on component rerender
281
+ */
282
+ scrollIntoView?: boolean;
283
+ }
284
+ declare function TabListVertical({ activation, 'aria-label': label, children, className: customClassName, scrollIntoView, ...rest }: TabListVerticalProps): import("react/jsx-runtime").JSX.Element;
285
+ declare namespace TabListVertical {
286
+ var propTypes: {
287
+ /**
288
+ * Specify whether the content tab should be activated automatically or
289
+ * manually
290
+ */
291
+ activation: PropTypes.Requireable<string>;
292
+ /**
293
+ * Provide an accessible label to be read when a user interacts with this
294
+ * component
295
+ */
296
+ 'aria-label': PropTypes.Validator<string>;
297
+ /**
298
+ * Provide child elements to be rendered inside `ContentTabs`.
299
+ * These elements should render a `ContentTab`
300
+ */
301
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
302
+ /**
303
+ * Specify an optional className to be added to the container node
304
+ */
305
+ className: PropTypes.Requireable<string>;
306
+ };
307
+ }
198
308
  /**
199
309
  * Tab
200
310
  */
@@ -308,4 +418,4 @@ declare namespace TabPanels {
308
418
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
309
419
  };
310
420
  }
311
- export { Tabs, Tab, IconTab, TabPanel, TabPanels, TabList };
421
+ export { Tabs, TabsVertical, Tab, IconTab, TabPanel, TabPanels, TabList, TabListVertical, };