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