@carbon/react 1.53.1 → 1.54.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 +981 -1068
  2. package/es/components/Button/Button.d.ts +1 -1
  3. package/es/components/Button/Button.js +13 -89
  4. package/es/components/Button/ButtonBase.d.ts +10 -0
  5. package/es/components/Button/ButtonBase.js +110 -0
  6. package/es/components/CodeSnippet/CodeSnippet.js +1 -0
  7. package/es/components/ComboBox/ComboBox.js +13 -4
  8. package/es/components/ComboButton/index.js +1 -1
  9. package/es/components/ComposedModal/ComposedModal.js +19 -10
  10. package/es/components/DataTable/DataTable.js +1 -1
  11. package/es/components/DataTable/TableBatchAction.d.ts +1 -1
  12. package/es/components/DataTable/TableToolbarMenu.d.ts +5 -1
  13. package/es/components/DataTable/TableToolbarMenu.js +7 -0
  14. package/es/components/DatePicker/DatePicker.d.ts +4 -0
  15. package/es/components/DatePicker/DatePicker.js +37 -0
  16. package/es/components/IconButton/index.d.ts +1 -1
  17. package/es/components/IconButton/index.js +3 -4
  18. package/es/components/ListBox/ListBox.d.ts +8 -0
  19. package/es/components/ListBox/ListBox.js +15 -3
  20. package/es/components/Loading/Loading.d.ts +1 -1
  21. package/es/components/Menu/Menu.js +2 -0
  22. package/es/components/Modal/Modal.js +14 -5
  23. package/es/components/ModalWrapper/ModalWrapper.d.ts +1 -1
  24. package/es/components/Notification/Notification.js +18 -6
  25. package/es/components/Pagination/Pagination.Skeleton.d.ts +25 -0
  26. package/es/components/Pagination/Pagination.d.ts +102 -0
  27. package/es/components/Pagination/Pagination.js +13 -14
  28. package/es/components/Pagination/index.d.ts +10 -0
  29. package/es/components/Popover/index.d.ts +1 -1
  30. package/es/components/Popover/index.js +175 -108
  31. package/es/components/RadioTile/RadioTile.d.ts +55 -0
  32. package/es/components/RadioTile/RadioTile.js +17 -17
  33. package/es/components/RadioTile/index.d.ts +10 -0
  34. package/es/components/Slider/Slider.Skeleton.js +6 -2
  35. package/es/components/Slug/index.js +23 -2
  36. package/es/components/Stack/HStack.d.ts +10 -0
  37. package/es/components/Stack/HStack.js +23 -0
  38. package/es/components/Stack/Stack.d.ts +1 -1
  39. package/es/components/Stack/Stack.js +2 -2
  40. package/es/components/Stack/VStack.d.ts +10 -0
  41. package/es/components/Stack/{index.js → VStack.js} +1 -8
  42. package/es/components/Stack/index.d.ts +3 -6
  43. package/es/components/StructuredList/StructuredList.d.ts +8 -0
  44. package/es/components/StructuredList/StructuredList.js +28 -10
  45. package/es/components/TileGroup/TileGroup.js +30 -24
  46. package/es/components/Toggletip/index.d.ts +1 -18
  47. package/es/components/Toggletip/index.js +27 -4
  48. package/es/components/Tooltip/Tooltip.js +23 -5
  49. package/es/feature-flags.js +2 -1
  50. package/es/index.d.ts +1 -0
  51. package/es/index.js +5 -4
  52. package/es/internal/FloatingMenu.js +26 -5
  53. package/es/internal/environment.js +5 -1
  54. package/es/internal/keyboard/navigation.js +6 -2
  55. package/es/internal/useOutsideClick.js +31 -0
  56. package/es/internal/wrapFocus.js +51 -1
  57. package/es/tools/createPropAdapter.js +40 -0
  58. package/lib/components/Button/Button.d.ts +1 -1
  59. package/lib/components/Button/Button.js +13 -90
  60. package/lib/components/Button/ButtonBase.d.ts +10 -0
  61. package/lib/components/Button/ButtonBase.js +119 -0
  62. package/lib/components/CodeSnippet/CodeSnippet.js +1 -0
  63. package/lib/components/ComboBox/ComboBox.js +13 -4
  64. package/lib/components/ComboButton/index.js +1 -1
  65. package/lib/components/ComposedModal/ComposedModal.js +17 -8
  66. package/lib/components/DataTable/DataTable.js +1 -1
  67. package/lib/components/DataTable/TableBatchAction.d.ts +1 -1
  68. package/lib/components/DataTable/TableToolbarMenu.d.ts +5 -1
  69. package/lib/components/DataTable/TableToolbarMenu.js +7 -0
  70. package/lib/components/DatePicker/DatePicker.d.ts +4 -0
  71. package/lib/components/DatePicker/DatePicker.js +37 -0
  72. package/lib/components/IconButton/index.d.ts +1 -1
  73. package/lib/components/IconButton/index.js +3 -4
  74. package/lib/components/ListBox/ListBox.d.ts +8 -0
  75. package/lib/components/ListBox/ListBox.js +15 -3
  76. package/lib/components/Loading/Loading.d.ts +1 -1
  77. package/lib/components/Menu/Menu.js +2 -0
  78. package/lib/components/Modal/Modal.js +14 -5
  79. package/lib/components/ModalWrapper/ModalWrapper.d.ts +1 -1
  80. package/lib/components/Notification/Notification.js +15 -3
  81. package/lib/components/Pagination/Pagination.Skeleton.d.ts +25 -0
  82. package/lib/components/Pagination/Pagination.d.ts +102 -0
  83. package/lib/components/Pagination/Pagination.js +13 -14
  84. package/lib/components/Pagination/index.d.ts +10 -0
  85. package/lib/components/Popover/index.d.ts +1 -1
  86. package/lib/components/Popover/index.js +174 -107
  87. package/lib/components/RadioTile/RadioTile.d.ts +55 -0
  88. package/lib/components/RadioTile/RadioTile.js +17 -17
  89. package/lib/components/RadioTile/index.d.ts +10 -0
  90. package/lib/components/Slider/Slider.Skeleton.js +5 -1
  91. package/lib/components/Slug/index.js +23 -2
  92. package/lib/components/Stack/HStack.d.ts +10 -0
  93. package/lib/components/Stack/HStack.js +31 -0
  94. package/lib/components/Stack/Stack.d.ts +1 -1
  95. package/lib/components/Stack/Stack.js +3 -3
  96. package/lib/components/Stack/VStack.d.ts +10 -0
  97. package/lib/components/Stack/{index.js → VStack.js} +0 -8
  98. package/lib/components/Stack/index.d.ts +3 -6
  99. package/lib/components/StructuredList/StructuredList.d.ts +8 -0
  100. package/lib/components/StructuredList/StructuredList.js +27 -9
  101. package/lib/components/TileGroup/TileGroup.js +30 -24
  102. package/lib/components/Toggletip/index.d.ts +1 -18
  103. package/lib/components/Toggletip/index.js +27 -4
  104. package/lib/components/Tooltip/Tooltip.js +23 -5
  105. package/lib/feature-flags.js +2 -1
  106. package/lib/index.d.ts +1 -0
  107. package/lib/index.js +15 -14
  108. package/lib/internal/FloatingMenu.js +44 -4
  109. package/lib/internal/environment.js +5 -1
  110. package/lib/internal/keyboard/navigation.js +6 -2
  111. package/lib/internal/useOutsideClick.js +35 -0
  112. package/lib/internal/wrapFocus.js +51 -0
  113. package/lib/tools/createPropAdapter.js +44 -0
  114. package/package.json +9 -7
@@ -8,21 +8,27 @@
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import cx from 'classnames';
10
10
  import PropTypes from 'prop-types';
11
- import React__default, { useRef, useMemo, useState } from 'react';
11
+ import React__default, { useRef, useMemo, useEffect } from 'react';
12
12
  import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
13
13
  import { useMergedRefs } from '../../internal/useMergedRefs.js';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
15
  import { useWindowEvent } from '../../internal/useEvent.js';
16
+ import { mapPopoverAlignProp } from '../../tools/createPropAdapter.js';
17
+ import { useFloating, offset, flip, arrow, autoUpdate } from '@floating-ui/react';
16
18
 
17
19
  const PopoverContext = /*#__PURE__*/React__default.createContext({
18
- floating: {
20
+ setFloating: {
19
21
  current: null
20
- }
22
+ },
23
+ caretRef: {
24
+ current: null
25
+ },
26
+ autoAlign: null
21
27
  });
22
28
  const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFunction(_ref, forwardRef) {
23
29
  let {
24
30
  isTabTip,
25
- align = isTabTip ? 'bottom-left' : 'bottom',
31
+ align: initialAlign = isTabTip ? 'bottom-start' : 'bottom',
26
32
  as: BaseComponent = 'span',
27
33
  autoAlign = false,
28
34
  caret = isTabTip ? false : true,
@@ -36,7 +42,9 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
36
42
  } = _ref;
37
43
  const prefix = usePrefix();
38
44
  const floating = useRef(null);
45
+ const caretRef = useRef(null);
39
46
  const popover = useRef(null);
47
+ let align = mapPopoverAlignProp(initialAlign);
40
48
 
41
49
  // If the `Popover` is the last focusable item in the tab order, it should also close when the browser window loses focus (#12922)
42
50
  useWindowEvent('blur', () => {
@@ -49,124 +57,150 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
49
57
  onRequestClose?.();
50
58
  }
51
59
  });
60
+
61
+ // Slug styling places a border around the popover content so the caret
62
+ // needs to be placed 1px further outside the popover content. To do so,
63
+ // we look to see if any of the children has a className containing "slug"
64
+ const initialCaretHeight = React__default.Children.toArray(children).some(x => {
65
+ return x?.props?.className?.includes('slug');
66
+ }) ? 7 : 6;
67
+ // These defaults match the defaults defined in packages/styles/scss/components/popover/_popover.scss
68
+ const popoverDimensions = useRef({
69
+ offset: 10,
70
+ caretHeight: initialCaretHeight
71
+ });
72
+ useIsomorphicEffect(() => {
73
+ // The popover is only offset when a caret is present. Technically, the custom properties
74
+ // accessed below can be set by a user even if caret=false, but doing so does not follow
75
+ // the design specification for Popover.
76
+ if (caret && popover.current) {
77
+ // Gather the dimensions of the caret and prefer the values set via custom properties.
78
+ // If a value is not set via a custom property, provide a default value that matches the
79
+ // default values defined in the sass style file
80
+ const getStyle = window.getComputedStyle(popover.current, null);
81
+ const offsetProperty = getStyle.getPropertyValue('--cds-popover-offset');
82
+ const caretProperty = getStyle.getPropertyValue('--cds-popover-caret-height');
83
+
84
+ // Handle if the property values are in px or rem.
85
+ // We want to store just the base number value without a unit suffix
86
+ if (offsetProperty) {
87
+ popoverDimensions.current.offset = offsetProperty.includes('px') ? Number(offsetProperty.split('px', 1)[0]) * 1 : Number(offsetProperty.split('rem', 1)[0]) * 16;
88
+ }
89
+ if (caretProperty) {
90
+ popoverDimensions.current.caretHeight = caretProperty.includes('px') ? Number(caretProperty.split('px', 1)[0]) * 1 : Number(caretProperty.split('rem', 1)[0]) * 16;
91
+ }
92
+ }
93
+ });
94
+ const {
95
+ refs,
96
+ floatingStyles,
97
+ placement,
98
+ middlewareData
99
+ } = useFloating(autoAlign ? {
100
+ placement: align,
101
+ // The floating element is positioned relative to its nearest
102
+ // containing block (usually the viewport). It will in many cases also
103
+ // “break” the floating element out of a clipping ancestor.
104
+ // https://floating-ui.com/docs/misc#clipping
105
+ strategy: 'fixed',
106
+ // Middleware order matters, arrow should be last
107
+ middleware: [offset(!isTabTip ? popoverDimensions?.current?.offset : 0), flip({
108
+ fallbackAxisSideDirection: 'start'
109
+ }), arrow({
110
+ element: caretRef
111
+ })],
112
+ whileElementsMounted: autoUpdate
113
+ } : {} // When autoAlign is turned off, floating-ui will not be used
114
+ );
115
+
52
116
  const value = useMemo(() => {
53
117
  return {
54
- floating
118
+ floating,
119
+ setFloating: refs.setFloating,
120
+ caretRef,
121
+ autoAlign: autoAlign
55
122
  };
56
- }, []);
123
+ }, [refs.setFloating, autoAlign]);
57
124
  if (isTabTip) {
58
- const tabTipAlignments = ['bottom-left', 'bottom-right'];
125
+ const tabTipAlignments = ['bottom-start', 'bottom-end'];
59
126
  if (!tabTipAlignments.includes(align)) {
60
- align = 'bottom-left';
127
+ align = 'bottom-start';
61
128
  }
62
129
  }
130
+ useEffect(() => {
131
+ if (autoAlign) {
132
+ Object.keys(floatingStyles).forEach(style => {
133
+ if (refs.floating.current) {
134
+ refs.floating.current.style[style] = floatingStyles[style];
135
+ }
136
+ });
137
+ if (caret && middlewareData && middlewareData.arrow && caretRef?.current) {
138
+ const {
139
+ x,
140
+ y
141
+ } = middlewareData.arrow;
142
+ const staticSide = {
143
+ top: 'bottom',
144
+ right: 'left',
145
+ bottom: 'top',
146
+ left: 'right'
147
+ }[placement.split('-')[0]];
148
+ caretRef.current.style.left = x != null ? `${x}px` : '';
149
+ caretRef.current.style.top = y != null ? `${y}px` : '';
150
+
151
+ // Ensure the static side gets unset when flipping to other placements' axes.
152
+ caretRef.current.style.right = '';
153
+ caretRef.current.style.bottom = '';
154
+ if (staticSide) {
155
+ caretRef.current.style[staticSide] = `${-popoverDimensions?.current?.caretHeight}px`;
156
+ }
157
+ }
158
+ }
159
+ }, [floatingStyles, refs.floating, autoAlign, middlewareData, placement, caret]);
63
160
  const ref = useMergedRefs([forwardRef, popover]);
64
- const [autoAligned, setAutoAligned] = useState(false);
65
- const [autoAlignment, setAutoAlignment] = useState(align);
161
+ const currentAlignment = autoAlign && placement !== align ? placement : align;
66
162
  const className = cx({
67
163
  [`${prefix}--popover-container`]: true,
68
164
  [`${prefix}--popover--caret`]: caret,
69
165
  [`${prefix}--popover--drop-shadow`]: dropShadow,
70
166
  [`${prefix}--popover--high-contrast`]: highContrast,
71
167
  [`${prefix}--popover--open`]: open,
72
- [`${prefix}--popover--${autoAlignment}`]: autoAligned && !isTabTip,
73
- [`${prefix}--popover--${align}`]: !autoAligned,
168
+ [`${prefix}--popover--auto-align`]: autoAlign,
169
+ [`${prefix}--popover--${currentAlignment}`]: true,
74
170
  [`${prefix}--popover--tab-tip`]: isTabTip
75
171
  }, customClassName);
76
- useIsomorphicEffect(() => {
77
- if (!open) {
78
- return;
79
- }
80
- if (!autoAlign || isTabTip) {
81
- setAutoAligned(false);
82
- return;
83
- }
84
- if (!floating.current) {
85
- return;
86
- }
87
- if (autoAligned === true) {
88
- return;
89
- }
90
- const rect = floating.current.getBoundingClientRect();
91
-
92
- // The conditions, per side, of when the popover is not visible, excluding the popover's internal padding(16)
93
- const conditions = {
94
- left: rect.x < -16,
95
- top: rect.y < -16,
96
- right: rect.x + (rect.width - 16) > document.documentElement.clientWidth,
97
- bottom: rect.y + (rect.height - 16) > document.documentElement.clientHeight
98
- };
99
- if (!conditions.left && !conditions.top && !conditions.right && !conditions.bottom) {
100
- setAutoAligned(false);
101
- return;
102
- }
103
- const alignments = ['top', 'top-left', 'right-bottom', 'right', 'right-top', 'bottom-left', 'bottom', 'bottom-right', 'left-top', 'left', 'left-bottom', 'top-right'];
104
-
105
- // Creates the prioritized list of options depending on ideal alignment coming from `align`
106
- const options = [align];
107
- let option = alignments[(alignments.indexOf(align) + 1) % alignments.length];
108
- while (option) {
109
- if (options.includes(option)) {
110
- break;
111
- }
112
- options.push(option);
113
- option = alignments[(alignments.indexOf(option) + 1) % alignments.length];
114
- }
115
- function isVisible(alignment) {
116
- if (!popover.current || !floating.current) {
117
- return false;
118
- }
119
- popover.current.classList.add(`${prefix}--popover--${alignment}`);
120
- const rect = floating.current.getBoundingClientRect();
121
-
122
- // Check if popover is not visible to the left of the screen
123
- if (rect.x < -16) {
124
- popover.current.classList.remove(`${prefix}--popover--${alignment}`);
125
- return false;
126
- }
127
-
128
- // Check if popover is not visible at the top of the screen
129
- if (rect.y < -16) {
130
- popover.current.classList.remove(`${prefix}--popover--${alignment}`);
131
- return false;
132
- }
133
-
134
- // Check if popover is not visible to right of screen
135
- if (rect.x + (rect.width - 16) > document.documentElement.clientWidth) {
136
- popover.current.classList.remove(`${prefix}--popover--${alignment}`);
137
- return false;
138
- }
139
-
140
- // Check if popover is not visible to bottom of screen
141
- if (rect.y + (rect.height - 16) > document.documentElement.clientHeight) {
142
- popover.current.classList.remove(`${prefix}--popover--${alignment}`);
143
- return false;
144
- }
145
- popover.current.classList.remove(`${prefix}--popover--${alignment}`);
146
- return true;
147
- }
148
- let alignment = null;
149
- for (let i = 0; i < options.length; i++) {
150
- const option = options[i];
151
- if (isVisible(option)) {
152
- alignment = option;
153
- break;
154
- }
155
- }
156
- if (alignment) {
157
- setAutoAligned(true);
158
- setAutoAlignment(alignment);
159
- }
160
- }, [autoAligned, align, autoAlign, prefix, open, isTabTip]);
161
172
  const mappedChildren = React__default.Children.map(children, child => {
162
173
  const item = child;
163
- if (item?.type === 'button') {
164
- const {
165
- className
166
- } = item.props;
174
+ if ((item?.type === 'button' || autoAlign && item?.type?.displayName !== 'PopoverContent' || autoAlign && item?.type?.displayName === 'ToggletipButton') && /*#__PURE__*/React__default.isValidElement(item)) {
175
+ const className = item?.props?.className;
176
+ const ref = (item?.props).ref;
167
177
  const tabTipClasses = cx(`${prefix}--popover--tab-tip__button`, className);
168
178
  return /*#__PURE__*/React__default.cloneElement(item, {
169
- className: tabTipClasses
179
+ className: isTabTip && item?.type === 'button' ? tabTipClasses : className || '',
180
+ // With cloneElement, if you pass a `ref`, it overrides the original ref.
181
+ // https://react.dev/reference/react/cloneElement#parameters
182
+ // The block below works around this and ensures that the original ref is still
183
+ // called while allowing the floating-ui reference element to be set as well.
184
+ // `useMergedRefs` can't be used here because hooks can't be called from within a callback.
185
+ // More here: https://github.com/facebook/react/issues/8873#issuecomment-489579878
186
+ ref: node => {
187
+ // For a popover, there isn't an explicit trigger component, it's just the first child that's
188
+ // passed in which should *not* be PopoverContent.
189
+ // For a toggletip there is a specific trigger component, ToggletipButton.
190
+ // In either of these caes we want to set this as the reference node for floating-ui autoAlign
191
+ // positioning.
192
+ if (autoAlign && item?.type?.displayName !== 'PopoverContent' || autoAlign && item?.type?.displayName === 'ToggletipButton') {
193
+ // Set the reference element for floating-ui
194
+ refs.setReference(node);
195
+ }
196
+
197
+ // Call the original ref, if any
198
+ if (typeof ref === 'function') {
199
+ ref(node);
200
+ } else if (ref !== null && ref !== undefined) {
201
+ ref.current = node;
202
+ }
203
+ }
170
204
  });
171
205
  } else {
172
206
  return item;
@@ -178,7 +212,7 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
178
212
  }, /*#__PURE__*/React__default.createElement(BaseComponentAsAny, _extends({}, rest, {
179
213
  className: className,
180
214
  ref: ref
181
- }), isTabTip ? mappedChildren : children));
215
+ }), autoAlign || isTabTip ? mappedChildren : children));
182
216
  });
183
217
 
184
218
  // Note: this displayName is temporarily set so that Storybook ArgTable
@@ -190,7 +224,28 @@ Popover.propTypes = {
190
224
  /**
191
225
  * Specify how the popover should align with the trigger element
192
226
  */
193
- align: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-bottom', 'left-top', 'right', 'right-bottom', 'right-top']),
227
+ align: PropTypes.oneOf(['top', 'top-left',
228
+ // deprecated use top-start instead
229
+ 'top-right',
230
+ // deprecated use top-end instead
231
+
232
+ 'bottom', 'bottom-left',
233
+ // deprecated use bottom-start instead
234
+ 'bottom-right',
235
+ // deprecated use bottom-end instead
236
+
237
+ 'left', 'left-bottom',
238
+ // deprecated use left-end instead
239
+ 'left-top',
240
+ // deprecated use left-start instead
241
+
242
+ 'right', 'right-bottom',
243
+ // deprecated use right-end instead
244
+ 'right-top',
245
+ // deprecated use right-start instead
246
+
247
+ // new values to match floating-ui
248
+ 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
194
249
  /**
195
250
  * Provide a custom element or component to render the top-level node for the
196
251
  * component.
@@ -244,19 +299,31 @@ _ref2, forwardRef) {
244
299
  } = _ref2;
245
300
  const prefix = usePrefix();
246
301
  const {
247
- floating
302
+ setFloating,
303
+ caretRef,
304
+ autoAlign
248
305
  } = React__default.useContext(PopoverContext);
249
- const ref = useMergedRefs([floating, forwardRef]);
306
+ const ref = useMergedRefs([setFloating, forwardRef]);
250
307
  return /*#__PURE__*/React__default.createElement("span", _extends({}, rest, {
251
308
  className: `${prefix}--popover`
252
309
  }), /*#__PURE__*/React__default.createElement("span", {
253
310
  className: cx(`${prefix}--popover-content`, className),
254
311
  ref: ref
255
- }, children), /*#__PURE__*/React__default.createElement("span", {
256
- className: `${prefix}--popover-caret`
312
+ }, children, autoAlign && /*#__PURE__*/React__default.createElement("span", {
313
+ className: cx({
314
+ [`${prefix}--popover-caret`]: true,
315
+ [`${prefix}--popover--auto-align`]: true
316
+ }),
317
+ ref: caretRef
318
+ })), !autoAlign && /*#__PURE__*/React__default.createElement("span", {
319
+ className: cx({
320
+ [`${prefix}--popover-caret`]: true
321
+ }),
322
+ ref: caretRef
257
323
  }));
258
324
  }
259
325
  const PopoverContent = /*#__PURE__*/React__default.forwardRef(PopoverContentRenderFunction);
326
+ PopoverContent.displayName = 'PopoverContent';
260
327
  PopoverContent.propTypes = {
261
328
  /**
262
329
  * Provide elements to be rendered inside of the component
@@ -0,0 +1,55 @@
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 React from 'react';
8
+ export interface RadioTileProps {
9
+ /**
10
+ * Specify whether the `RadioTile` should be checked.
11
+ */
12
+ checked?: boolean;
13
+ /**
14
+ * The `RadioTile` content.
15
+ */
16
+ children?: React.ReactNode;
17
+ /**
18
+ * Provide an optional `className` to be applied to the underlying `<label>`.
19
+ */
20
+ className?: string;
21
+ /**
22
+ * Specify whether the `RadioTile` should be disabled.
23
+ */
24
+ disabled?: boolean;
25
+ /**
26
+ * Provide a unique id for the underlying `<input>`.
27
+ */
28
+ id?: string;
29
+ /**
30
+ * `true` to use the light version. For use on `$layer-01` backgrounds only.
31
+ * Don't use this to make tile background color the same as the container background color.
32
+ *
33
+ * @deprecated This prop is no longer needed and has been deprecated in v11 in favor of the new Layer component. It will be removed in the next major release.
34
+ */
35
+ light?: boolean;
36
+ /**
37
+ * Provide a `name` for the underlying `<input>`.
38
+ */
39
+ name?: string;
40
+ /**
41
+ * Provide an optional `onChange` hook that is called each time the value of
42
+ * the underlying `<input>` changes.
43
+ */
44
+ onChange?: (value: string | number, name: string | undefined, event: React.ChangeEvent<HTMLInputElement> | React.KeyboardEvent<HTMLInputElement>) => void;
45
+ /**
46
+ * Specify the tab index of the underlying `<input>`.
47
+ */
48
+ tabIndex?: number;
49
+ /**
50
+ * Specify the value of the underlying `<input>`.
51
+ */
52
+ value: string | number;
53
+ }
54
+ declare const RadioTile: React.ForwardRefExoticComponent<RadioTileProps & React.RefAttributes<HTMLInputElement>>;
55
+ export default RadioTile;
@@ -26,7 +26,6 @@ const RadioTile = /*#__PURE__*/React__default.forwardRef(function RadioTile(_ref
26
26
  children,
27
27
  className: customClassName,
28
28
  disabled,
29
- // eslint-disable-next-line no-unused-vars
30
29
  light,
31
30
  checked,
32
31
  name,
@@ -70,9 +69,9 @@ const RadioTile = /*#__PURE__*/React__default.forwardRef(function RadioTile(_ref
70
69
  disabled: disabled,
71
70
  id: inputId,
72
71
  name: name,
73
- onChange: !disabled ? handleOnChange : null,
74
- onKeyDown: !disabled ? handleOnKeyDown : null,
75
- tabIndex: !disabled ? tabIndex : null,
72
+ onChange: !disabled ? handleOnChange : undefined,
73
+ onKeyDown: !disabled ? handleOnKeyDown : undefined,
74
+ tabIndex: !disabled ? tabIndex : undefined,
76
75
  type: "radio",
77
76
  value: value,
78
77
  ref: ref
@@ -85,49 +84,50 @@ const RadioTile = /*#__PURE__*/React__default.forwardRef(function RadioTile(_ref
85
84
  className: `${prefix}--tile-content`
86
85
  }, children)));
87
86
  });
87
+ RadioTile.displayName = 'RadioTile';
88
88
  RadioTile.propTypes = {
89
89
  /**
90
- * `true` if this tile should be selected.
90
+ * Specify whether the `RadioTile` should be checked.
91
91
  */
92
92
  checked: PropTypes.bool,
93
93
  /**
94
- * The tile content.
94
+ * The `RadioTile` content.
95
95
  */
96
96
  children: PropTypes.node,
97
97
  /**
98
- * The CSS class names.
98
+ * Provide an optional `className` to be applied to the underlying `<label>`.
99
99
  */
100
100
  className: PropTypes.string,
101
101
  /**
102
- * Specify whether the RadioTile should be disabled
102
+ * Specify whether the `RadioTile` should be disabled.
103
103
  */
104
104
  disabled: PropTypes.bool,
105
105
  /**
106
- * The ID of the `<input>`.
106
+ * Provide a unique id for the underlying `<input>`.
107
107
  */
108
108
  id: PropTypes.string,
109
109
  /**
110
- * `true` to use the light version. For use on $ui-01 backgrounds only.
110
+ * `true` to use the light version. For use on `$layer-01` backgrounds only.
111
111
  * Don't use this to make tile background color same as container background color.
112
112
  */
113
- light: deprecate(PropTypes.bool, 'The `light` prop for `RadioTile` is no longer needed and has ' + 'been deprecated in v11 in favor of the new `Layer` component. It will be moved in the next major release.'),
113
+ light: deprecate(PropTypes.bool, 'The `light` prop for `RadioTile` is no longer needed and has ' + 'been deprecated in v11 in favor of the new `Layer` component. It will be removed in the next major release.'),
114
114
  /**
115
- * The `name` of the `<input>`.
115
+ * Provide a `name` for the underlying `<input>`.
116
116
  */
117
117
  name: PropTypes.string,
118
118
  /**
119
- * The handler of the massaged `change` event on the `<input>`.
119
+ * Provide an optional `onChange` hook that is called each time the value of
120
+ * the underlying `<input>` changes.
120
121
  */
121
122
  onChange: PropTypes.func,
122
123
  /**
123
- * Specify the tab index of the wrapper element
124
+ * Specify the tab index of the underlying `<input>`.
124
125
  */
125
126
  tabIndex: PropTypes.number,
126
127
  /**
127
- * The `value` of the `<input>`.
128
+ * Specify the value of the underlying `<input>`.
128
129
  */
129
130
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
130
131
  };
131
- var RadioTile$1 = RadioTile;
132
132
 
133
- export { RadioTile$1 as default };
133
+ export { RadioTile as default };
@@ -0,0 +1,10 @@
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 RadioTile, { RadioTileProps } from './RadioTile';
8
+ export default RadioTile;
9
+ export { RadioTile };
10
+ export type { RadioTileProps };
@@ -7,9 +7,10 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
- import React__default from 'react';
10
+ import React__default, { useState } from 'react';
11
11
  import cx from 'classnames';
12
12
  import { usePrefix } from '../../internal/usePrefix.js';
13
+ import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
13
14
  import { LowerHandle, UpperHandle } from './SliderHandles.js';
14
15
 
15
16
  var _LowerHandle, _UpperHandle, _UpperHandle2, _LowerHandle2;
@@ -21,7 +22,10 @@ const SliderSkeleton = _ref => {
21
22
  ...rest
22
23
  } = _ref;
23
24
  const prefix = usePrefix();
24
- const isRtl = document?.dir === 'rtl';
25
+ const [isRtl, setIsRtl] = useState(false);
26
+ useIsomorphicEffect(() => {
27
+ setIsRtl(document ? document.dir === 'rtl' : false);
28
+ }, []);
25
29
  const containerClasses = cx(`${prefix}--slider-container`, `${prefix}--skeleton`, {
26
30
  [`${prefix}--slider-container--two-handles`]: twoHandles,
27
31
  [`${prefix}--slider-container--rtl`]: isRtl
@@ -136,9 +136,30 @@ Slug.propTypes = {
136
136
  /**
137
137
  * Specify how the popover should align with the button
138
138
  */
139
- align: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-bottom', 'left-top', 'right', 'right-bottom', 'right-top']),
139
+ align: PropTypes.oneOf(['top', 'top-left',
140
+ // deprecated use top-start instead
141
+ 'top-right',
142
+ // deprecated use top-end instead
143
+
144
+ 'bottom', 'bottom-left',
145
+ // deprecated use bottom-start instead
146
+ 'bottom-right',
147
+ // deprecated use bottom-end instead
148
+
149
+ 'left', 'left-bottom',
150
+ // deprecated use left-end instead
151
+ 'left-top',
152
+ // deprecated use left-start instead
153
+
154
+ 'right', 'right-bottom',
155
+ // deprecated use right-end instead
156
+ 'right-top',
157
+ // deprecated use right-start instead
158
+
159
+ // new values to match floating-ui
160
+ 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
140
161
  /**
141
- * Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to future changes.
162
+ * Will auto-align the popover. This prop is currently experimental and is subject to future changes.
142
163
  */
143
164
  autoAlign: PropTypes.bool,
144
165
  /**
@@ -0,0 +1,10 @@
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 React from 'react';
8
+ import { StackProps } from './Stack';
9
+ declare const HStack: React.ForwardRefExoticComponent<StackProps & React.RefAttributes<React.ReactNode>>;
10
+ export { HStack };
@@ -0,0 +1,23 @@
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 { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React__default from 'react';
10
+ import { Stack } from './Stack.js';
11
+
12
+ const HStack = /*#__PURE__*/React__default.forwardRef(function HStack(_ref, ref) {
13
+ let {
14
+ children,
15
+ ...props
16
+ } = _ref;
17
+ return /*#__PURE__*/React__default.createElement(Stack, _extends({}, props, {
18
+ ref: ref,
19
+ orientation: "horizontal"
20
+ }), children);
21
+ });
22
+
23
+ export { HStack };
@@ -10,7 +10,7 @@ import React from 'react';
10
10
  * @type {Array<number>}
11
11
  */
12
12
  declare const SPACING_STEPS: number[];
13
- interface StackProps extends React.HTMLAttributes<HTMLElement> {
13
+ export interface StackProps extends React.HTMLAttributes<HTMLElement> {
14
14
  /**
15
15
  * Provide a custom element type to render as the outermost element in
16
16
  * the Stack component. By default, this component will render a `div`.
@@ -6,10 +6,10 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import { spacing } from '@carbon/layout';
9
+ import React__default from 'react';
10
10
  import cx from 'classnames';
11
11
  import PropTypes from 'prop-types';
12
- import React__default from 'react';
12
+ import { spacing } from '@carbon/layout';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
14
14
 
15
15
  /**
@@ -0,0 +1,10 @@
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 React from 'react';
8
+ import { StackProps } from './Stack';
9
+ declare const VStack: React.ForwardRefExoticComponent<StackProps & React.RefAttributes<React.ReactNode>>;
10
+ export { VStack };
@@ -8,14 +8,7 @@
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default from 'react';
10
10
  import { Stack } from './Stack.js';
11
- export { Stack } from './Stack.js';
12
11
 
13
- const HStack = /*#__PURE__*/React__default.forwardRef(function HStack(props, ref) {
14
- return /*#__PURE__*/React__default.createElement(Stack, _extends({}, props, {
15
- ref: ref,
16
- orientation: "horizontal"
17
- }));
18
- });
19
12
  const VStack = /*#__PURE__*/React__default.forwardRef(function VStack(props, ref) {
20
13
  return /*#__PURE__*/React__default.createElement(Stack, _extends({}, props, {
21
14
  ref: ref,
@@ -23,4 +16,4 @@ const VStack = /*#__PURE__*/React__default.forwardRef(function VStack(props, ref
23
16
  }));
24
17
  });
25
18
 
26
- export { HStack, VStack };
19
+ export { VStack };