@carbon/react 1.63.1 → 1.64.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.
Files changed (114) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1558 -1265
  2. package/es/components/{Slug → AILabel}/index.js +47 -35
  3. package/es/components/{AiSkeleton/AiSkeletonIcon.d.ts → AISkeleton/AISkeletonIcon.d.ts} +4 -4
  4. package/es/components/{AiSkeleton/AiSkeletonIcon.js → AISkeleton/AISkeletonIcon.js} +5 -5
  5. package/es/components/{AiSkeleton/AiSkeletonPlaceholder.d.ts → AISkeleton/AISkeletonPlaceholder.d.ts} +4 -4
  6. package/es/components/{AiSkeleton/AiSkeletonPlaceholder.js → AISkeleton/AISkeletonPlaceholder.js} +5 -5
  7. package/es/components/{AiSkeleton/AiSkeletonText.d.ts → AISkeleton/AISkeletonText.d.ts} +4 -4
  8. package/es/components/{AiSkeleton/AiSkeletonText.js → AISkeleton/AISkeletonText.js} +3 -3
  9. package/es/components/AISkeleton/index.d.ts +10 -0
  10. package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
  11. package/es/components/ComboBox/ComboBox.d.ts +21 -6
  12. package/es/components/ComboBox/ComboBox.js +52 -14
  13. package/es/components/ComposedModal/ComposedModal.js +1 -1
  14. package/es/components/DataTable/DataTable.js +1 -1
  15. package/es/components/DataTable/TableSelectRow.js +2 -1
  16. package/es/components/DataTable/TableToolbarSearch.js +2 -2
  17. package/es/components/DatePicker/DatePicker.js +65 -14
  18. package/es/components/DatePicker/plugins/fixEventsPlugin.js +11 -0
  19. package/es/components/DatePickerInput/DatePickerInput.js +1 -1
  20. package/es/components/Dropdown/Dropdown.d.ts +6 -4
  21. package/es/components/Dropdown/Dropdown.js +18 -10
  22. package/es/components/FluidMultiSelect/FluidMultiSelect.js +10 -6
  23. package/es/components/Menu/MenuItem.js +45 -63
  24. package/es/components/Modal/Modal.js +1 -1
  25. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +6 -4
  26. package/es/components/MultiSelect/FilterableMultiSelect.js +50 -27
  27. package/es/components/MultiSelect/MultiSelect.d.ts +6 -4
  28. package/es/components/MultiSelect/MultiSelect.js +12 -8
  29. package/es/components/NumberInput/NumberInput.js +2 -2
  30. package/es/components/OverflowMenu/OverflowMenu.js +2 -1
  31. package/es/components/OverflowMenu/next/index.js +2 -1
  32. package/es/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  33. package/es/components/RadioTile/RadioTile.js +1 -1
  34. package/es/components/Select/Select.js +1 -1
  35. package/es/components/Tabs/Tabs.js +3 -3
  36. package/es/components/Tag/DismissibleTag.js +1 -1
  37. package/es/components/Tag/OperationalTag.js +1 -1
  38. package/es/components/Tag/SelectableTag.js +3 -1
  39. package/es/components/Tag/Tag.js +1 -1
  40. package/es/components/TextArea/TextArea.js +1 -1
  41. package/es/components/TextInput/PasswordInput.js +5 -0
  42. package/es/components/TextInput/TextInput.js +1 -1
  43. package/es/components/Tile/Tile.js +2 -2
  44. package/es/components/TreeView/TreeNode.d.ts +150 -0
  45. package/es/components/TreeView/TreeNode.js +22 -15
  46. package/es/components/TreeView/TreeView.d.ts +59 -0
  47. package/es/components/TreeView/TreeView.js +37 -23
  48. package/es/components/TreeView/index.d.ts +11 -0
  49. package/es/components/UIShell/SwitcherItem.d.ts +4 -0
  50. package/es/components/UIShell/SwitcherItem.js +7 -1
  51. package/es/index.d.ts +4 -2
  52. package/es/index.js +6 -6
  53. package/es/node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js +143 -0
  54. package/es/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs.js +39 -0
  55. package/lib/components/{Slug → AILabel}/index.js +49 -37
  56. package/lib/components/{AiSkeleton/AiSkeletonIcon.d.ts → AISkeleton/AISkeletonIcon.d.ts} +4 -4
  57. package/lib/components/{AiSkeleton/AiSkeletonIcon.js → AISkeleton/AISkeletonIcon.js} +5 -5
  58. package/lib/components/{AiSkeleton/AiSkeletonPlaceholder.d.ts → AISkeleton/AISkeletonPlaceholder.d.ts} +4 -4
  59. package/lib/components/{AiSkeleton/AiSkeletonPlaceholder.js → AISkeleton/AISkeletonPlaceholder.js} +5 -5
  60. package/lib/components/{AiSkeleton/AiSkeletonText.d.ts → AISkeleton/AISkeletonText.d.ts} +4 -4
  61. package/lib/components/{AiSkeleton/AiSkeletonText.js → AISkeleton/AISkeletonText.js} +3 -3
  62. package/lib/components/AISkeleton/index.d.ts +10 -0
  63. package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
  64. package/lib/components/ComboBox/ComboBox.d.ts +21 -6
  65. package/lib/components/ComboBox/ComboBox.js +52 -14
  66. package/lib/components/ComposedModal/ComposedModal.js +1 -1
  67. package/lib/components/DataTable/DataTable.js +2 -2
  68. package/lib/components/DataTable/TableSelectRow.js +2 -1
  69. package/lib/components/DataTable/TableToolbarSearch.js +2 -2
  70. package/lib/components/DatePicker/DatePicker.js +65 -14
  71. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +11 -0
  72. package/lib/components/DatePickerInput/DatePickerInput.js +1 -1
  73. package/lib/components/Dropdown/Dropdown.d.ts +6 -4
  74. package/lib/components/Dropdown/Dropdown.js +18 -10
  75. package/lib/components/FluidMultiSelect/FluidMultiSelect.js +10 -6
  76. package/lib/components/Menu/MenuItem.js +44 -62
  77. package/lib/components/Modal/Modal.js +1 -1
  78. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +6 -4
  79. package/lib/components/MultiSelect/FilterableMultiSelect.js +49 -26
  80. package/lib/components/MultiSelect/MultiSelect.d.ts +6 -4
  81. package/lib/components/MultiSelect/MultiSelect.js +12 -8
  82. package/lib/components/NumberInput/NumberInput.js +2 -2
  83. package/lib/components/OverflowMenu/OverflowMenu.js +2 -1
  84. package/lib/components/OverflowMenu/next/index.js +2 -1
  85. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  86. package/lib/components/RadioTile/RadioTile.js +1 -1
  87. package/lib/components/Select/Select.js +1 -1
  88. package/lib/components/Tabs/Tabs.js +2 -2
  89. package/lib/components/Tag/DismissibleTag.js +1 -1
  90. package/lib/components/Tag/OperationalTag.js +1 -1
  91. package/lib/components/Tag/SelectableTag.js +3 -1
  92. package/lib/components/Tag/Tag.js +1 -1
  93. package/lib/components/TextArea/TextArea.js +1 -1
  94. package/lib/components/TextInput/PasswordInput.js +5 -0
  95. package/lib/components/TextInput/TextInput.js +1 -1
  96. package/lib/components/Tile/Tile.js +2 -2
  97. package/lib/components/TreeView/TreeNode.d.ts +150 -0
  98. package/lib/components/TreeView/TreeNode.js +24 -17
  99. package/lib/components/TreeView/TreeView.d.ts +59 -0
  100. package/lib/components/TreeView/TreeView.js +39 -25
  101. package/lib/components/TreeView/index.d.ts +11 -0
  102. package/lib/components/UIShell/SwitcherItem.d.ts +4 -0
  103. package/lib/components/UIShell/SwitcherItem.js +7 -1
  104. package/lib/index.d.ts +4 -2
  105. package/lib/index.js +20 -14
  106. package/lib/node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js +148 -0
  107. package/lib/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs.js +47 -0
  108. package/package.json +4 -4
  109. package/scss/components/ai-label/_ai-label.scss +9 -0
  110. package/scss/components/ai-label/_index.scss +9 -0
  111. package/es/components/AiSkeleton/index.d.ts +0 -10
  112. package/es/components/DataTable/tools/instanceId.js +0 -20
  113. package/lib/components/AiSkeleton/index.d.ts +0 -10
  114. package/lib/components/DataTable/tools/instanceId.js +0 -24
@@ -6,17 +6,18 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { useRef, useState, useEffect } from 'react';
10
- import PropTypes from 'prop-types';
11
9
  import cx from 'classnames';
12
- import uniqueId from '../../tools/uniqueId.js';
13
- import { usePrefix } from '../../internal/usePrefix.js';
10
+ import PropTypes from 'prop-types';
11
+ import React__default, { useRef, useState, useEffect } from 'react';
14
12
  import { useControllableState } from '../../internal/useControllableState.js';
13
+ import { usePrefix } from '../../internal/usePrefix.js';
14
+ import uniqueId from '../../tools/uniqueId.js';
15
15
  import { useFeatureFlag } from '../FeatureFlags/index.js';
16
+ import TreeNode from './TreeNode.js';
16
17
  import { matches, match } from '../../internal/keyboard/match.js';
17
18
  import { ArrowUp, ArrowDown, Home, End } from '../../internal/keyboard/keys.js';
18
19
 
19
- function TreeView(_ref) {
20
+ const TreeView = _ref => {
20
21
  let {
21
22
  active: prespecifiedActive,
22
23
  children,
@@ -36,6 +37,7 @@ function TreeView(_ref) {
36
37
  } = useRef(rest.id || uniqueId());
37
38
  const prefix = usePrefix();
38
39
  const treeClasses = cx(className, `${prefix}--tree`, {
40
+ // @ts-ignore - will always be false according to prop types
39
41
  [`${prefix}--tree--${size}`]: size !== 'default'
40
42
  });
41
43
  const treeRootRef = useRef(null);
@@ -61,9 +63,7 @@ function TreeView(_ref) {
61
63
  }
62
64
  function handleTreeSelect(event) {
63
65
  let node = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
64
- const {
65
- id: nodeId
66
- } = node;
66
+ const nodeId = node.id;
67
67
  if (multiselect && (event.metaKey || event.ctrlKey)) {
68
68
  if (!selected.includes(nodeId)) {
69
69
  setSelected(selected.concat(nodeId));
@@ -107,14 +107,15 @@ function TreeView(_ref) {
107
107
  }
108
108
  }
109
109
  let focusTarget = false;
110
- const nodesWithProps = React__default.Children.map(children, node => {
110
+ const nodesWithProps = React__default.Children.map(children, _node => {
111
+ const node = _node;
111
112
  const sharedNodeProps = {
112
113
  active,
113
114
  depth: 0,
114
115
  onNodeFocusEvent: handleFocusEvent,
115
116
  onTreeSelect: handleTreeSelect,
116
117
  selected,
117
- tabIndex: !node.props.disabled && -1 || null
118
+ tabIndex: !node.props.disabled && -1 || undefined
118
119
  };
119
120
  if (!focusTarget && !node.props.disabled) {
120
121
  sharedNodeProps.tabIndex = 0;
@@ -126,40 +127,47 @@ function TreeView(_ref) {
126
127
  });
127
128
  function handleKeyDown(event) {
128
129
  event.stopPropagation();
129
- if (matches(event, [ArrowUp, ArrowDown, Home, End, {
130
+ if (matches(event, [ArrowUp, ArrowDown, Home, End,
131
+ // @ts-ignore - `matches` doesn't like the object syntax without missing properties
132
+ {
130
133
  code: 'KeyA'
131
134
  }])) {
132
135
  event.preventDefault();
133
136
  }
137
+ if (!treeWalker.current) {
138
+ return;
139
+ }
134
140
  treeWalker.current.currentNode = event.target;
135
- let nextFocusNode;
141
+ let nextFocusNode = null;
136
142
  if (match(event, ArrowUp)) {
137
143
  nextFocusNode = treeWalker.current.previousNode();
138
144
  }
139
145
  if (match(event, ArrowDown)) {
140
146
  nextFocusNode = treeWalker.current.nextNode();
141
147
  }
148
+ // @ts-ignore - `matches` doesn't like the object syntax without missing properties
142
149
  if (matches(event, [Home, End, {
143
150
  code: 'KeyA'
144
151
  }])) {
145
152
  const nodeIds = [];
146
153
  if (matches(event, [Home, End])) {
147
- if (multiselect && event.shiftKey && event.ctrlKey && !treeWalker.current.currentNode.getAttribute('aria-disabled')) {
154
+ if (multiselect && event.shiftKey && event.ctrlKey && treeWalker.current.currentNode instanceof Element && !treeWalker.current.currentNode.getAttribute('aria-disabled')) {
148
155
  nodeIds.push(treeWalker.current.currentNode?.id);
149
156
  }
150
157
  while (match(event, Home) ? treeWalker.current.previousNode() : treeWalker.current.nextNode()) {
151
158
  nextFocusNode = treeWalker.current.currentNode;
152
- if (multiselect && event.shiftKey && event.ctrlKey && !nextFocusNode.getAttribute('aria-disabled')) {
159
+ if (multiselect && event.shiftKey && event.ctrlKey && nextFocusNode instanceof Element && !nextFocusNode.getAttribute('aria-disabled')) {
153
160
  nodeIds.push(nextFocusNode?.id);
154
161
  }
155
162
  }
156
163
  }
164
+ // @ts-ignore - `matches` doesn't like the object syntax without missing properties
157
165
  if (match(event, {
158
166
  code: 'KeyA'
159
167
  }) && event.ctrlKey) {
160
168
  treeWalker.current.currentNode = treeWalker.current.root;
161
169
  while (treeWalker.current.nextNode()) {
162
- if (!treeWalker.current.currentNode.getAttribute('aria-disabled')) {
170
+ if (treeWalker.current.currentNode instanceof Element && !treeWalker.current.currentNode.getAttribute('aria-disabled')) {
163
171
  nodeIds.push(treeWalker.current.currentNode?.id);
164
172
  }
165
173
  }
@@ -168,14 +176,19 @@ function TreeView(_ref) {
168
176
  }
169
177
  if (nextFocusNode && nextFocusNode !== event.target) {
170
178
  resetNodeTabIndices();
171
- nextFocusNode.tabIndex = 0;
172
- nextFocusNode.focus();
179
+ if (nextFocusNode instanceof HTMLElement) {
180
+ nextFocusNode.tabIndex = 0;
181
+ nextFocusNode.focus();
182
+ }
173
183
  }
174
184
  rest?.onKeyDown?.(event);
175
185
  }
176
186
  useEffect(() => {
177
187
  treeWalker.current = treeWalker.current ?? document.createTreeWalker(treeRootRef?.current, NodeFilter.SHOW_ELEMENT, {
178
188
  acceptNode: function (node) {
189
+ if (!(node instanceof Element)) {
190
+ return NodeFilter.FILTER_SKIP;
191
+ }
179
192
  if (node.classList.contains(`${prefix}--tree-node--disabled`)) {
180
193
  return NodeFilter.FILTER_REJECT;
181
194
  }
@@ -198,20 +211,20 @@ function TreeView(_ref) {
198
211
  }, []);
199
212
  useActiveAndSelectedOnMount();
200
213
  const labelId = `${treeId}__label`;
201
- const TreeLabel = () => !hideLabel && /*#__PURE__*/React__default.createElement("label", {
214
+ const TreeLabel = () => !hideLabel ? /*#__PURE__*/React__default.createElement("label", {
202
215
  id: labelId,
203
216
  className: `${prefix}--label`
204
- }, label);
217
+ }, label) : null;
205
218
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TreeLabel, null), /*#__PURE__*/React__default.createElement("ul", _extends({}, rest, {
206
- "aria-label": hideLabel ? label : null,
207
- "aria-labelledby": !hideLabel ? labelId : null,
208
- "aria-multiselectable": multiselect || null,
219
+ "aria-label": hideLabel ? label : undefined,
220
+ "aria-labelledby": !hideLabel ? labelId : undefined,
221
+ "aria-multiselectable": multiselect || undefined,
209
222
  className: treeClasses,
210
223
  onKeyDown: handleKeyDown,
211
224
  ref: treeRootRef,
212
225
  role: "tree"
213
226
  }), nodesWithProps));
214
- }
227
+ };
215
228
  TreeView.propTypes = {
216
229
  /**
217
230
  * Mark the active node in the tree, represented by its ID
@@ -256,5 +269,6 @@ TreeView.propTypes = {
256
269
  */
257
270
  size: PropTypes.oneOf(['xs', 'sm'])
258
271
  };
272
+ TreeView.TreeNode = TreeNode;
259
273
 
260
274
  export { TreeView as default };
@@ -0,0 +1,11 @@
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
+ import TreeNode, { TreeNodeProps } from './TreeNode';
8
+ import TreeView, { TreeViewProps } from './TreeView';
9
+ export { TreeNode, TreeView };
10
+ export type { TreeViewProps, TreeNodeProps };
11
+ export default TreeView;
@@ -47,6 +47,10 @@ interface BaseSwitcherItemProps {
47
47
  * Specify where to open the link.
48
48
  */
49
49
  target?: HTMLAttributeAnchorTarget;
50
+ /**
51
+ * The rel property for the link.
52
+ */
53
+ rel?: string;
50
54
  }
51
55
  interface SwitcherItemWithAriaLabel extends BaseSwitcherItemProps {
52
56
  'aria-label': string;
@@ -29,6 +29,7 @@ const SwitcherItem = /*#__PURE__*/forwardRef(function SwitcherItem(props, forwar
29
29
  onKeyDown = () => {},
30
30
  href,
31
31
  target,
32
+ rel,
32
33
  ...rest
33
34
  } = props;
34
35
  const prefix = usePrefix();
@@ -67,6 +68,7 @@ const SwitcherItem = /*#__PURE__*/forwardRef(function SwitcherItem(props, forwar
67
68
  },
68
69
  href: href,
69
70
  target: target,
71
+ rel: rel,
70
72
  ref: forwardRef
71
73
  }, rest, {
72
74
  className: linkClassName,
@@ -111,7 +113,11 @@ SwitcherItem.propTypes = {
111
113
  /**
112
114
  * Specify where to open the link.
113
115
  */
114
- target: PropTypes.string
116
+ target: PropTypes.string,
117
+ /**
118
+ * The rel property for the link.
119
+ */
120
+ rel: PropTypes.string
115
121
  };
116
122
 
117
123
  export { SwitcherItem as default };
package/es/index.d.ts CHANGED
@@ -116,9 +116,11 @@ export { OverflowMenuV2 as unstable_OverflowMenuV2 } from './components/Overflow
116
116
  export { PageSelector as unstable_PageSelector, Pagination as unstable_Pagination, } from './components/Pagination/experimental';
117
117
  export * from './components/Popover';
118
118
  export * from './components/ProgressBar';
119
- export { Slug as unstable__Slug, SlugContent as unstable__SlugContent, SlugActions as unstable__SlugActions, } from './components/Slug';
119
+ export { AILabel, AILabelContent, AILabelActions } from './components/AILabel';
120
+ export { AILabel as unstable__Slug, AILabelContent as unstable__SlugContent, AILabelActions as unstable__SlugActions, } from './components/AILabel';
120
121
  export { ChatButton as unstable__ChatButton, ChatButtonSkeleton as unstable__ChatButtonSkeleton, } from './components/ChatButton';
121
- export { AiSkeletonText as unstable__AiSkeletonText, AiSkeletonIcon as unstable__AiSkeletonIcon, AiSkeletonPlaceholder as unstable__AiSkeletonPlaceholder, } from './components/AiSkeleton';
122
+ export { AISkeletonText, AISkeletonIcon, AISkeletonPlaceholder, } from './components/AISkeleton';
123
+ export { AISkeletonText as unstable__AiSkeletonText, AISkeletonIcon as unstable__AiSkeletonIcon, AISkeletonPlaceholder as unstable__AiSkeletonPlaceholder, } from './components/AISkeleton';
122
124
  export * from './components/Stack';
123
125
  export * from './components/Tooltip';
124
126
  export { Text as unstable_Text, TextDirection as unstable_TextDirection, } from './components/Text';
package/es/index.js CHANGED
@@ -126,6 +126,8 @@ export { Toggle } from './components/Toggle/Toggle.js';
126
126
  export { default as ToggleSkeleton } from './components/Toggle/Toggle.Skeleton.js';
127
127
  export { default as ToggleSmallSkeleton } from './components/ToggleSmall/ToggleSmall.Skeleton.js';
128
128
  export { Toggletip, ToggletipActions, ToggletipButton, ToggletipContent, ToggletipLabel } from './components/Toggletip/index.js';
129
+ export { default as TreeNode } from './components/TreeView/TreeNode.js';
130
+ export { default as TreeView } from './components/TreeView/TreeView.js';
129
131
  export { default as Content } from './components/UIShell/Content.js';
130
132
  export { default as Header } from './components/UIShell/Header.js';
131
133
  export { default as HeaderContainer } from './components/UIShell/HeaderContainer.js';
@@ -164,10 +166,10 @@ export { Layout as unstable_Layout } from './components/Layout/index.js';
164
166
  export { OverflowMenuV2 as unstable_OverflowMenuV2 } from './components/OverflowMenuV2/index.js';
165
167
  export { Popover, PopoverContent } from './components/Popover/index.js';
166
168
  export { default as ProgressBar } from './components/ProgressBar/ProgressBar.js';
167
- export { Slug as unstable__Slug, SlugActions as unstable__SlugActions, SlugContent as unstable__SlugContent } from './components/Slug/index.js';
168
- export { default as unstable__AiSkeletonPlaceholder } from './components/AiSkeleton/AiSkeletonPlaceholder.js';
169
- export { default as unstable__AiSkeletonIcon } from './components/AiSkeleton/AiSkeletonIcon.js';
170
- export { default as unstable__AiSkeletonText } from './components/AiSkeleton/AiSkeletonText.js';
169
+ export { AILabel, AILabelActions, AILabelContent, AILabel as unstable__Slug, AILabelActions as unstable__SlugActions, AILabelContent as unstable__SlugContent } from './components/AILabel/index.js';
170
+ export { default as AISkeletonPlaceholder, default as unstable__AiSkeletonPlaceholder } from './components/AISkeleton/AISkeletonPlaceholder.js';
171
+ export { default as AISkeletonIcon, default as unstable__AiSkeletonIcon } from './components/AISkeleton/AISkeletonIcon.js';
172
+ export { default as AISkeletonText, default as unstable__AiSkeletonText } from './components/AISkeleton/AISkeletonText.js';
171
173
  export { DefinitionTooltip } from './components/Tooltip/DefinitionTooltip.js';
172
174
  export { Tooltip } from './components/Tooltip/Tooltip.js';
173
175
  import './components/Text/index.js';
@@ -188,7 +190,6 @@ export { default as useContextMenu } from './components/ContextMenu/useContextMe
188
190
  export { default as SliderSkeleton } from './components/Slider/Slider.Skeleton.js';
189
191
  export { default as TextInputSkeleton } from './components/TextInput/TextInput.Skeleton.js';
190
192
  export { default as TextInput } from './components/TextInput/TextInput.js';
191
- export { default as TreeView } from './components/TreeView/TreeView.js';
192
193
  export { default as unstable__FluidComboBox } from './components/FluidComboBox/FluidComboBox.js';
193
194
  export { default as unstable__FluidComboBoxSkeleton } from './components/FluidComboBox/FluidComboBox.Skeleton.js';
194
195
  export { default as unstable__FluidDatePicker } from './components/FluidDatePicker/FluidDatePicker.js';
@@ -234,4 +235,3 @@ export { default as TableToolbarSearch } from './components/DataTable/TableToolb
234
235
  export { default as TableToolbarMenu } from './components/DataTable/TableToolbarMenu.js';
235
236
  export { default as FilterableMultiSelect } from './components/MultiSelect/FilterableMultiSelect.js';
236
237
  export { default as MultiSelect } from './components/MultiSelect/MultiSelect.js';
237
- export { default as TreeNode } from './components/TreeView/TreeNode.js';
@@ -0,0 +1,143 @@
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
+ import { evaluate, getPaddingObject, rectToClientRect, sides } from '../../utils/dist/floating-ui.utils.mjs.js';
9
+ export { rectToClientRect } from '../../utils/dist/floating-ui.utils.mjs.js';
10
+
11
+ /**
12
+ * Resolves with an object of overflow side offsets that determine how much the
13
+ * element is overflowing a given clipping boundary on each side.
14
+ * - positive = overflowing the boundary by that number of pixels
15
+ * - negative = how many pixels left before it will overflow
16
+ * - 0 = lies flush with the boundary
17
+ * @see https://floating-ui.com/docs/detectOverflow
18
+ */
19
+ async function detectOverflow(state, options) {
20
+ var _await$platform$isEle;
21
+ if (options === void 0) {
22
+ options = {};
23
+ }
24
+ const {
25
+ x,
26
+ y,
27
+ platform,
28
+ rects,
29
+ elements,
30
+ strategy
31
+ } = state;
32
+ const {
33
+ boundary = 'clippingAncestors',
34
+ rootBoundary = 'viewport',
35
+ elementContext = 'floating',
36
+ altBoundary = false,
37
+ padding = 0
38
+ } = evaluate(options, state);
39
+ const paddingObject = getPaddingObject(padding);
40
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
41
+ const element = elements[altBoundary ? altContext : elementContext];
42
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
43
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
44
+ boundary,
45
+ rootBoundary,
46
+ strategy
47
+ }));
48
+ const rect = elementContext === 'floating' ? {
49
+ ...rects.floating,
50
+ x,
51
+ y
52
+ } : rects.reference;
53
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
54
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
55
+ x: 1,
56
+ y: 1
57
+ } : {
58
+ x: 1,
59
+ y: 1
60
+ };
61
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
62
+ rect,
63
+ offsetParent,
64
+ strategy
65
+ }) : rect);
66
+ return {
67
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
68
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
69
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
70
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
71
+ };
72
+ }
73
+
74
+ function getSideOffsets(overflow, rect) {
75
+ return {
76
+ top: overflow.top - rect.height,
77
+ right: overflow.right - rect.width,
78
+ bottom: overflow.bottom - rect.height,
79
+ left: overflow.left - rect.width
80
+ };
81
+ }
82
+ function isAnySideFullyClipped(overflow) {
83
+ return sides.some(side => overflow[side] >= 0);
84
+ }
85
+ /**
86
+ * Provides data to hide the floating element in applicable situations, such as
87
+ * when it is not in the same clipping context as the reference element.
88
+ * @see https://floating-ui.com/docs/hide
89
+ */
90
+ const hide = function (options) {
91
+ if (options === void 0) {
92
+ options = {};
93
+ }
94
+ return {
95
+ name: 'hide',
96
+ options,
97
+ async fn(state) {
98
+ const {
99
+ rects
100
+ } = state;
101
+ const {
102
+ strategy = 'referenceHidden',
103
+ ...detectOverflowOptions
104
+ } = evaluate(options, state);
105
+ switch (strategy) {
106
+ case 'referenceHidden':
107
+ {
108
+ const overflow = await detectOverflow(state, {
109
+ ...detectOverflowOptions,
110
+ elementContext: 'reference'
111
+ });
112
+ const offsets = getSideOffsets(overflow, rects.reference);
113
+ return {
114
+ data: {
115
+ referenceHiddenOffsets: offsets,
116
+ referenceHidden: isAnySideFullyClipped(offsets)
117
+ }
118
+ };
119
+ }
120
+ case 'escaped':
121
+ {
122
+ const overflow = await detectOverflow(state, {
123
+ ...detectOverflowOptions,
124
+ altBoundary: true
125
+ });
126
+ const offsets = getSideOffsets(overflow, rects.floating);
127
+ return {
128
+ data: {
129
+ escapedOffsets: offsets,
130
+ escaped: isAnySideFullyClipped(offsets)
131
+ }
132
+ };
133
+ }
134
+ default:
135
+ {
136
+ return {};
137
+ }
138
+ }
139
+ }
140
+ };
141
+ };
142
+
143
+ export { detectOverflow, hide };
@@ -0,0 +1,39 @@
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
+ const sides = ['top', 'right', 'bottom', 'left'];
9
+ function evaluate(value, param) {
10
+ return typeof value === 'function' ? value(param) : value;
11
+ }
12
+ function expandPaddingObject(padding) {
13
+ return {
14
+ top: 0,
15
+ right: 0,
16
+ bottom: 0,
17
+ left: 0,
18
+ ...padding
19
+ };
20
+ }
21
+ function getPaddingObject(padding) {
22
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
23
+ top: padding,
24
+ right: padding,
25
+ bottom: padding,
26
+ left: padding
27
+ };
28
+ }
29
+ function rectToClientRect(rect) {
30
+ return {
31
+ ...rect,
32
+ top: rect.y,
33
+ left: rect.x,
34
+ right: rect.x + rect.width,
35
+ bottom: rect.y + rect.height
36
+ };
37
+ }
38
+
39
+ export { evaluate, expandPaddingObject, getPaddingObject, rectToClientRect, sides };
@@ -18,6 +18,7 @@ var index = require('../Toggletip/index.js');
18
18
  var index$1 = require('../IconButton/index.js');
19
19
  var iconsReact = require('@carbon/icons-react');
20
20
  var useId = require('../../internal/useId.js');
21
+ var deprecate = require('../../prop-types/deprecate.js');
21
22
 
22
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
23
24
 
@@ -26,24 +27,23 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
26
27
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
27
28
 
28
29
  var _Undo;
29
- const SlugContent = /*#__PURE__*/React__default["default"].forwardRef(function SlugContent(_ref, ref) {
30
+ const AILabelContent = /*#__PURE__*/React__default["default"].forwardRef(function AILabelContent(_ref, ref) {
30
31
  let {
31
32
  children,
32
33
  className
33
34
  } = _ref;
34
35
  const prefix = usePrefix.usePrefix();
35
- const hasSlugActions = React__default["default"].Children.toArray(children).some(child => child.type?.displayName === 'SlugActions');
36
- const slugContentClasses = cx__default["default"](className, {
36
+ const hasAILabelActions = React__default["default"].Children.toArray(children).some(child => child.type?.displayName === 'AILabelActions');
37
+ const aiLabelContentClasses = cx__default["default"](className, {
37
38
  [`${prefix}--slug-content`]: true,
38
- [`${prefix}--slug-content--with-actions`]: hasSlugActions
39
+ [`${prefix}--slug-content--with-actions`]: hasAILabelActions
39
40
  });
40
41
  return /*#__PURE__*/React__default["default"].createElement(index.ToggletipContent, {
41
- className: slugContentClasses,
42
- ref: ref
42
+ className: aiLabelContentClasses
43
43
  }, children);
44
44
  });
45
- SlugContent.displayName = 'SlugContent';
46
- SlugContent.propTypes = {
45
+ AILabelContent.displayName = 'AILabelContent';
46
+ AILabelContent.propTypes = {
47
47
  /**
48
48
  * Specify the content you want rendered inside the slug ToggleTip
49
49
  */
@@ -53,22 +53,22 @@ SlugContent.propTypes = {
53
53
  */
54
54
  className: PropTypes__default["default"].string
55
55
  };
56
- const SlugActions = /*#__PURE__*/React__default["default"].forwardRef(function SlugActions(_ref2, ref) {
56
+ const AILabelActions = /*#__PURE__*/React__default["default"].forwardRef(function AILabelActions(_ref2, ref) {
57
57
  let {
58
58
  children,
59
59
  className
60
60
  } = _ref2;
61
61
  const prefix = usePrefix.usePrefix();
62
- const slugActionBarClasses = cx__default["default"](className, {
62
+ const aiLabelActionsClasses = cx__default["default"](className, {
63
63
  [`${prefix}--slug-actions`]: true
64
64
  });
65
65
  return /*#__PURE__*/React__default["default"].createElement(index.ToggletipActions, {
66
- className: slugActionBarClasses,
66
+ className: aiLabelActionsClasses,
67
67
  ref: ref
68
68
  }, children);
69
69
  });
70
- SlugActions.displayName = 'SlugActions';
71
- SlugActions.propTypes = {
70
+ AILabelActions.displayName = 'AILabelActions';
71
+ AILabelActions.propTypes = {
72
72
  /**
73
73
  * Specify the content you want rendered inside the slug callout toolbar
74
74
  */
@@ -78,10 +78,11 @@ SlugActions.propTypes = {
78
78
  */
79
79
  className: PropTypes__default["default"].string
80
80
  };
81
- const Slug = /*#__PURE__*/React__default["default"].forwardRef(function Slug(_ref3, ref) {
81
+ const AILabel = /*#__PURE__*/React__default["default"].forwardRef(function AILabel(_ref3, ref) {
82
82
  let {
83
83
  aiText = 'AI',
84
84
  aiTextLabel,
85
+ textLabel,
85
86
  align,
86
87
  autoAlign = true,
87
88
  children,
@@ -91,29 +92,30 @@ const Slug = /*#__PURE__*/React__default["default"].forwardRef(function Slug(_re
91
92
  revertActive,
92
93
  revertLabel = 'Revert to AI input',
93
94
  slugLabel = 'Show information',
95
+ ['aria-label']: ariaLabel = 'Show information',
94
96
  size = 'xs',
95
97
  ...rest
96
98
  } = _ref3;
97
99
  const prefix = usePrefix.usePrefix();
98
- const id = useId.useId('slug');
99
- const slugClasses = cx__default["default"](className, {
100
+ const id = useId.useId('AILabel');
101
+ const aiLabelClasses = cx__default["default"](className, {
100
102
  [`${prefix}--slug`]: true,
101
103
  [`${prefix}--slug--revert`]: revertActive
102
104
  });
103
- const slugButtonClasses = cx__default["default"]({
105
+ const aiLabelButtonClasses = cx__default["default"]({
104
106
  [`${prefix}--slug__button`]: true,
105
107
  [`${prefix}--slug__button--${size}`]: size,
106
108
  [`${prefix}--slug__button--${kind}`]: kind,
107
- [`${prefix}--slug__button--inline-with-content`]: kind === 'inline' && aiTextLabel
109
+ [`${prefix}--slug__button--inline-with-content`]: kind === 'inline' && (aiTextLabel || textLabel)
108
110
  });
109
111
  const handleOnRevertClick = evt => {
110
112
  if (onRevertClick) {
111
113
  onRevertClick(evt);
112
114
  }
113
115
  };
114
- const ariaLabel = !aiTextLabel ? `${aiText} - ${slugLabel}` : `${aiText} - ${aiTextLabel}`;
116
+ const ariaLabelText = !aiTextLabel && !textLabel ? `${aiText} - ${slugLabel || ariaLabel}` : `${aiText} - ${aiTextLabel || textLabel}`;
115
117
  return /*#__PURE__*/React__default["default"].createElement("div", {
116
- className: slugClasses,
118
+ className: aiLabelClasses,
117
119
  ref: ref,
118
120
  id: id
119
121
  }, revertActive ? /*#__PURE__*/React__default["default"].createElement(index$1.IconButton, _rollupPluginBabelHelpers["extends"]({
@@ -125,24 +127,29 @@ const Slug = /*#__PURE__*/React__default["default"].forwardRef(function Slug(_re
125
127
  align: align,
126
128
  autoAlign: autoAlign
127
129
  }, rest), /*#__PURE__*/React__default["default"].createElement(index.ToggletipButton, {
128
- className: slugButtonClasses,
129
- label: ariaLabel
130
+ className: aiLabelButtonClasses,
131
+ label: ariaLabelText
130
132
  }, /*#__PURE__*/React__default["default"].createElement("span", {
131
133
  className: `${prefix}--slug__text`
132
- }, aiText), aiTextLabel && /*#__PURE__*/React__default["default"].createElement("span", {
134
+ }, aiText), kind === 'inline' && (aiTextLabel || textLabel) && /*#__PURE__*/React__default["default"].createElement("span", {
133
135
  className: `${prefix}--slug__additional-text`
134
- }, aiTextLabel)), children));
136
+ }, aiTextLabel || textLabel)), children));
135
137
  });
136
- Slug.displayName = 'Slug';
137
- Slug.propTypes = {
138
+ AILabel.displayName = 'AILabel';
139
+ AILabel.propTypes = {
140
+ /**
141
+ * Specify the content you want rendered inside the `AILabel` ToggleTip
142
+ */
143
+ AILabelContent: PropTypes__default["default"].node,
138
144
  /**
139
145
  * Specify the correct translation of the AI text
140
146
  */
141
147
  aiText: PropTypes__default["default"].string,
142
148
  /**
149
+ * @deprecated
143
150
  * Specify additional text to be rendered next to the AI label in the inline variant
144
151
  */
145
- aiTextLabel: PropTypes__default["default"].string,
152
+ aiTextLabel: deprecate["default"](PropTypes__default["default"].string, '`aiTextLabel` on `AILabel` has been deprecated - Please use the `textLabel` prop instead'),
146
153
  /**
147
154
  * Specify how the popover should align with the button
148
155
  */
@@ -163,20 +170,24 @@ Slug.propTypes = {
163
170
  'right-end', 'right-top',
164
171
  // deprecated use right-start instead
165
172
  'right-start']),
173
+ /**
174
+ * Specify the text that will be provided to the aria-label of the `AILabel` button
175
+ */
176
+ 'aria-label': PropTypes__default["default"].string,
166
177
  /**
167
178
  * Will auto-align the popover. This prop is currently experimental and is subject to future changes.
168
179
  */
169
180
  autoAlign: PropTypes__default["default"].bool,
170
181
  /**
171
- * Specify the content you want rendered inside the slug ToggleTip
182
+ * Specify the content you want rendered inside the `AILabel` ToggleTip
172
183
  */
173
184
  children: PropTypes__default["default"].node,
174
185
  /**
175
- * Specify an optional className to be added to the AI slug
186
+ * Specify an optional className to be added to the `AILabel`
176
187
  */
177
188
  className: PropTypes__default["default"].string,
178
189
  /**
179
- * Specify the type of Slug, from the following list of types:
190
+ * Specify the type of `AILabel`, from the following list of types:
180
191
  */
181
192
  kind: PropTypes__default["default"].oneOf(['default', 'inline']),
182
193
  /**
@@ -196,15 +207,16 @@ Slug.propTypes = {
196
207
  */
197
208
  size: PropTypes__default["default"].oneOf(['mini', '2xs', 'xs', 'sm', 'md', 'lg', 'xl']),
198
209
  /**
199
- * Specify the content you want rendered inside the slug ToggleTip
210
+ * @deprecated
211
+ * Specify the text that will be provided to the aria-label of the `AILabel` button
200
212
  */
201
- slugContent: PropTypes__default["default"].node,
213
+ slugLabel: deprecate["default"](PropTypes__default["default"].string, '`slugLabel` on `AILabel` has been deprecated - Please use the `ariaLabel` prop instead'),
202
214
  /**
203
- * Specify the text that will be provided to the aria-label of the `Slug` button
215
+ * Specify additional text to be rendered next to the AI label in the inline variant
204
216
  */
205
- slugLabel: PropTypes__default["default"].string
217
+ textLabel: PropTypes__default["default"].string
206
218
  };
207
219
 
208
- exports.Slug = Slug;
209
- exports.SlugActions = SlugActions;
210
- exports.SlugContent = SlugContent;
220
+ exports.AILabel = AILabel;
221
+ exports.AILabelActions = AILabelActions;
222
+ exports.AILabelContent = AILabelContent;