@carbon/react 1.44.0 → 1.45.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.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +805 -805
- package/es/components/Checkbox/Checkbox.d.ts +1 -1
- package/es/components/Checkbox/Checkbox.js +1 -1
- package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/es/components/ComboBox/ComboBox.d.ts +1 -1
- package/es/components/ComboBox/ComboBox.js +1 -1
- package/es/components/ComboButton/index.js +1 -1
- package/es/components/ComposedModal/ModalFooter.d.ts +2 -1
- package/es/components/DataTable/DataTable.d.ts +2 -0
- package/es/components/DataTable/DataTable.js +3 -0
- package/es/components/DataTable/TableExpandRow.js +20 -3
- package/es/components/DataTable/TableHeader.d.ts +5 -0
- package/es/components/DataTable/TableHeader.js +30 -6
- package/es/components/DataTable/TableSlugRow.d.ts +31 -0
- package/es/components/DataTable/TableSlugRow.js +49 -0
- package/es/components/DataTable/index.d.ts +2 -1
- package/es/components/DataTable/index.js +3 -0
- package/es/components/DatePickerInput/DatePickerInput.d.ts +1 -1
- package/es/components/DatePickerInput/DatePickerInput.js +1 -1
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.js +1 -1
- package/es/components/InlineLoading/InlineLoading.d.ts +68 -0
- package/es/components/InlineLoading/InlineLoading.js +4 -4
- package/es/components/InlineLoading/index.d.ts +9 -0
- package/es/components/Layer/LayerContext.d.ts +8 -0
- package/es/components/Layer/LayerLevel.d.ts +5 -0
- package/es/components/Layer/LayerLevel.js +12 -0
- package/es/components/Layer/index.d.ts +38 -0
- package/es/components/Layer/index.js +9 -8
- package/es/components/Menu/MenuItem.js +2 -1
- package/es/components/MenuButton/index.js +1 -1
- package/es/components/Modal/Modal.d.ts +3 -2
- package/es/components/MultiSelect/FilterableMultiSelect.js +1 -1
- package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/MultiSelect.js +1 -1
- package/es/components/Notification/Notification.js +1 -0
- package/es/components/NumberInput/NumberInput.d.ts +1 -1
- package/es/components/NumberInput/NumberInput.js +1 -1
- package/es/components/RadioButton/RadioButton.d.ts +1 -1
- package/es/components/RadioButton/RadioButton.js +1 -1
- package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +1 -1
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/es/components/Select/Select.d.ts +1 -1
- package/es/components/Select/Select.js +1 -1
- package/es/components/Slider/Slider.Skeleton.js +17 -3
- package/es/components/Slider/Slider.js +132 -93
- package/es/components/Slider/SliderHandles.d.ts +4 -0
- package/es/components/Slider/SliderHandles.js +65 -0
- package/es/components/Tabs/Tabs.js +1 -1
- package/es/components/TextArea/TextArea.d.ts +7 -3
- package/es/components/TextArea/TextArea.js +84 -17
- package/es/components/TextInput/TextInput.d.ts +1 -1
- package/es/components/TextInput/TextInput.js +1 -1
- package/es/components/Tile/Tile.d.ts +8 -8
- package/es/components/Tile/Tile.js +9 -5
- package/es/components/Tooltip/Tooltip.js +48 -2
- package/es/components/UIShell/HeaderPanel.d.ts +36 -0
- package/es/components/UIShell/HeaderPanel.js +6 -6
- package/es/index.js +2 -1
- package/es/internal/useAnnouncer.js +2 -1
- package/es/internal/useNoInteractiveChildren.js +2 -6
- package/lib/components/Checkbox/Checkbox.d.ts +1 -1
- package/lib/components/Checkbox/Checkbox.js +1 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/lib/components/ComboBox/ComboBox.d.ts +1 -1
- package/lib/components/ComboBox/ComboBox.js +1 -1
- package/lib/components/ComboButton/index.js +1 -1
- package/lib/components/ComposedModal/ModalFooter.d.ts +2 -1
- package/lib/components/DataTable/DataTable.d.ts +2 -0
- package/lib/components/DataTable/DataTable.js +3 -0
- package/lib/components/DataTable/TableExpandRow.js +20 -3
- package/lib/components/DataTable/TableHeader.d.ts +5 -0
- package/lib/components/DataTable/TableHeader.js +29 -5
- package/lib/components/DataTable/TableSlugRow.d.ts +31 -0
- package/lib/components/DataTable/TableSlugRow.js +59 -0
- package/lib/components/DataTable/index.d.ts +2 -1
- package/lib/components/DataTable/index.js +3 -0
- package/lib/components/DatePickerInput/DatePickerInput.d.ts +1 -1
- package/lib/components/DatePickerInput/DatePickerInput.js +1 -1
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +1 -1
- package/lib/components/InlineLoading/InlineLoading.d.ts +68 -0
- package/lib/components/InlineLoading/InlineLoading.js +4 -4
- package/lib/components/InlineLoading/index.d.ts +9 -0
- package/lib/components/Layer/LayerContext.d.ts +8 -0
- package/lib/components/Layer/LayerLevel.d.ts +5 -0
- package/lib/components/Layer/LayerLevel.js +18 -0
- package/lib/components/Layer/index.d.ts +38 -0
- package/lib/components/Layer/index.js +10 -9
- package/lib/components/Menu/MenuItem.js +2 -1
- package/lib/components/MenuButton/index.js +1 -1
- package/lib/components/Modal/Modal.d.ts +3 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.js +1 -1
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/MultiSelect.js +1 -1
- package/lib/components/Notification/Notification.js +1 -0
- package/lib/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/components/NumberInput/NumberInput.js +1 -1
- package/lib/components/RadioButton/RadioButton.d.ts +1 -1
- package/lib/components/RadioButton/RadioButton.js +1 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +1 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/Select/Select.js +1 -1
- package/lib/components/Slider/Slider.Skeleton.js +17 -3
- package/lib/components/Slider/Slider.js +132 -93
- package/lib/components/Slider/SliderHandles.d.ts +4 -0
- package/lib/components/Slider/SliderHandles.js +76 -0
- package/lib/components/Tabs/Tabs.js +1 -1
- package/lib/components/TextArea/TextArea.d.ts +7 -3
- package/lib/components/TextArea/TextArea.js +83 -16
- package/lib/components/TextInput/TextInput.d.ts +1 -1
- package/lib/components/TextInput/TextInput.js +1 -1
- package/lib/components/Tile/Tile.d.ts +8 -8
- package/lib/components/Tile/Tile.js +9 -5
- package/lib/components/Tooltip/Tooltip.js +47 -1
- package/lib/components/UIShell/HeaderPanel.d.ts +36 -0
- package/lib/components/UIShell/HeaderPanel.js +7 -7
- package/lib/index.js +4 -2
- package/lib/internal/useAnnouncer.js +2 -1
- package/lib/internal/useNoInteractiveChildren.js +2 -6
- package/package.json +4 -7
|
@@ -49,6 +49,7 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
49
49
|
placeholder = '',
|
|
50
50
|
enableCounter = false,
|
|
51
51
|
maxCount = undefined,
|
|
52
|
+
counterMode = 'character',
|
|
52
53
|
warn = false,
|
|
53
54
|
warnText = '',
|
|
54
55
|
rows = 4,
|
|
@@ -63,15 +64,25 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
63
64
|
defaultValue,
|
|
64
65
|
value
|
|
65
66
|
} = other;
|
|
66
|
-
const [textCount, setTextCount] = React.useState(defaultValue?.toString()?.length || value?.toString()?.length || 0);
|
|
67
67
|
const {
|
|
68
68
|
current: textAreaInstanceId
|
|
69
69
|
} = React.useRef(getInstanceId());
|
|
70
70
|
const textareaRef = React.useRef(null);
|
|
71
71
|
const ref = useMergedRefs.useMergedRefs([forwardRef, textareaRef]);
|
|
72
|
+
function getInitialTextCount() {
|
|
73
|
+
const targetValue = defaultValue || value || textareaRef.current?.value || '';
|
|
74
|
+
const strValue = targetValue.toString();
|
|
75
|
+
if (counterMode === 'character') {
|
|
76
|
+
return strValue.length;
|
|
77
|
+
} else {
|
|
78
|
+
return strValue.match(/\w+/g)?.length || 0;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const [textCount, setTextCount] = React.useState(getInitialTextCount());
|
|
72
82
|
React.useEffect(() => {
|
|
73
|
-
setTextCount(
|
|
74
|
-
|
|
83
|
+
setTextCount(getInitialTextCount());
|
|
84
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
85
|
+
}, [value, defaultValue, counterMode]);
|
|
75
86
|
useIsomorphicEffect["default"](() => {
|
|
76
87
|
if (other.cols && textareaRef.current) {
|
|
77
88
|
textareaRef.current.style.width = '';
|
|
@@ -82,14 +93,63 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
82
93
|
}, [other.cols]);
|
|
83
94
|
const textareaProps = {
|
|
84
95
|
id,
|
|
96
|
+
onKeyDown: evt => {
|
|
97
|
+
if (!disabled && enableCounter && counterMode === 'word') {
|
|
98
|
+
const key = evt.which;
|
|
99
|
+
if (maxCount && textCount >= maxCount && key === 32) {
|
|
100
|
+
evt.preventDefault();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
onPaste: evt => {
|
|
105
|
+
if (!disabled) {
|
|
106
|
+
if (counterMode === 'word' && enableCounter && typeof maxCount !== 'undefined' && textareaRef.current !== null) {
|
|
107
|
+
const existingWords = textareaRef.current.value.match(/\w+/g) || [];
|
|
108
|
+
const pastedWords = evt.clipboardData.getData('Text').match(/\w+/g) || [];
|
|
109
|
+
const totalWords = existingWords.length + pastedWords.length;
|
|
110
|
+
if (totalWords > maxCount) {
|
|
111
|
+
evt.preventDefault();
|
|
112
|
+
const allowedWords = existingWords.concat(pastedWords).slice(0, maxCount);
|
|
113
|
+
setTimeout(() => {
|
|
114
|
+
setTextCount(maxCount);
|
|
115
|
+
}, 0);
|
|
116
|
+
textareaRef.current.value = allowedWords.join(' ');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
85
121
|
onChange: evt => {
|
|
86
|
-
if (!disabled
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
122
|
+
if (!disabled) {
|
|
123
|
+
if (counterMode == 'character') {
|
|
124
|
+
evt?.persist?.();
|
|
125
|
+
// delay textCount assignation to give the textarea element value time to catch up if is a controlled input
|
|
126
|
+
setTimeout(() => {
|
|
127
|
+
setTextCount(evt.target?.value?.length);
|
|
128
|
+
}, 0);
|
|
129
|
+
} else if (counterMode == 'word') {
|
|
130
|
+
if (!evt.target.value) {
|
|
131
|
+
setTimeout(() => {
|
|
132
|
+
setTextCount(0);
|
|
133
|
+
}, 0);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (enableCounter && typeof maxCount !== 'undefined' && textareaRef.current !== null) {
|
|
137
|
+
const matchedWords = evt.target?.value?.match(/\w+/g);
|
|
138
|
+
if (matchedWords && matchedWords.length <= maxCount) {
|
|
139
|
+
textareaRef.current.removeAttribute('maxLength');
|
|
140
|
+
setTimeout(() => {
|
|
141
|
+
setTextCount(matchedWords.length);
|
|
142
|
+
}, 0);
|
|
143
|
+
} else if (matchedWords && matchedWords.length > maxCount) {
|
|
144
|
+
setTimeout(() => {
|
|
145
|
+
setTextCount(matchedWords.length);
|
|
146
|
+
}, 0);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (onChange) {
|
|
151
|
+
onChange(evt);
|
|
152
|
+
}
|
|
93
153
|
}
|
|
94
154
|
},
|
|
95
155
|
onClick: evt => {
|
|
@@ -124,7 +184,7 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
124
184
|
htmlFor: id,
|
|
125
185
|
className: labelClasses
|
|
126
186
|
}, labelText) : null;
|
|
127
|
-
const counter = enableCounter && maxCount ? /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
187
|
+
const counter = enableCounter && maxCount && (counterMode === 'character' || counterMode === 'word') ? /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
128
188
|
as: "div",
|
|
129
189
|
className: counterClasses
|
|
130
190
|
}, `${textCount}/${maxCount}`) : null;
|
|
@@ -157,9 +217,12 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
157
217
|
ariaDescribedBy = helperId;
|
|
158
218
|
}
|
|
159
219
|
if (enableCounter) {
|
|
160
|
-
|
|
220
|
+
// handle different counter mode
|
|
221
|
+
if (counterMode == 'character') {
|
|
222
|
+
textareaProps.maxLength = maxCount;
|
|
223
|
+
}
|
|
161
224
|
}
|
|
162
|
-
const ariaAnnouncement = useAnnouncer.useAnnouncer(textCount, maxCount);
|
|
225
|
+
const ariaAnnouncement = useAnnouncer.useAnnouncer(textCount, maxCount, counterMode === 'word' ? 'words' : undefined);
|
|
163
226
|
const input = /*#__PURE__*/React__default["default"].createElement("textarea", _rollupPluginBabelHelpers["extends"]({}, other, textareaProps, {
|
|
164
227
|
placeholder: placeholder,
|
|
165
228
|
className: textareaClasses,
|
|
@@ -207,6 +270,10 @@ TextArea.propTypes = {
|
|
|
207
270
|
* Specify the `cols` attribute for the underlying `<textarea>` node
|
|
208
271
|
*/
|
|
209
272
|
cols: PropTypes__default["default"].number,
|
|
273
|
+
/**
|
|
274
|
+
* Specify the method used for calculating the counter number
|
|
275
|
+
*/
|
|
276
|
+
counterMode: PropTypes__default["default"].oneOf(['character', 'word']),
|
|
210
277
|
/**
|
|
211
278
|
* Optionally provide the default value of the `<textarea>`
|
|
212
279
|
*/
|
|
@@ -216,7 +283,7 @@ TextArea.propTypes = {
|
|
|
216
283
|
*/
|
|
217
284
|
disabled: PropTypes__default["default"].bool,
|
|
218
285
|
/**
|
|
219
|
-
* Specify whether to display the
|
|
286
|
+
* Specify whether to display the counter
|
|
220
287
|
*/
|
|
221
288
|
enableCounter: PropTypes__default["default"].bool,
|
|
222
289
|
/**
|
|
@@ -250,7 +317,7 @@ TextArea.propTypes = {
|
|
|
250
317
|
*/
|
|
251
318
|
light: deprecate["default"](PropTypes__default["default"].bool, 'The `light` prop for `TextArea` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
|
|
252
319
|
/**
|
|
253
|
-
* Max
|
|
320
|
+
* Max entity count allowed for the textarea. This is needed in order for enableCounter to display
|
|
254
321
|
*/
|
|
255
322
|
maxCount: PropTypes__default["default"].number,
|
|
256
323
|
/**
|
|
@@ -276,7 +343,7 @@ TextArea.propTypes = {
|
|
|
276
343
|
*/
|
|
277
344
|
rows: PropTypes__default["default"].number,
|
|
278
345
|
/**
|
|
279
|
-
* Provide a `Slug` component to be rendered inside the `TextArea` component
|
|
346
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `TextArea` component
|
|
280
347
|
*/
|
|
281
348
|
slug: PropTypes__default["default"].node,
|
|
282
349
|
/**
|
|
@@ -87,7 +87,7 @@ export interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInput
|
|
|
87
87
|
*/
|
|
88
88
|
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
89
89
|
/**
|
|
90
|
-
* Provide a `Slug` component to be rendered inside the `TextInput` component
|
|
90
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `TextInput` component
|
|
91
91
|
*/
|
|
92
92
|
slug?: ReactNodeLike;
|
|
93
93
|
/**
|
|
@@ -271,7 +271,7 @@ TextInput.propTypes = {
|
|
|
271
271
|
*/
|
|
272
272
|
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg']),
|
|
273
273
|
/**
|
|
274
|
-
* Provide a `Slug` component to be rendered inside the `TextInput` component
|
|
274
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `TextInput` component
|
|
275
275
|
*/
|
|
276
276
|
slug: PropTypes__default["default"].node,
|
|
277
277
|
/**
|
|
@@ -6,12 +6,12 @@ export interface TileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
6
6
|
/** @deprecated */
|
|
7
7
|
light?: boolean;
|
|
8
8
|
/**
|
|
9
|
-
* Specify if the `Tile` component should be rendered with rounded corners. Only valid
|
|
9
|
+
* **Experimental**: Specify if the `Tile` component should be rendered with rounded corners. Only valid
|
|
10
10
|
* when `slug` prop is present
|
|
11
11
|
*/
|
|
12
12
|
hasRoundedCorners?: boolean;
|
|
13
13
|
/**
|
|
14
|
-
* Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
14
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
15
15
|
*/
|
|
16
16
|
slug?: ReactNodeLike;
|
|
17
17
|
}
|
|
@@ -30,7 +30,7 @@ export interface ClickableTileProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
30
30
|
*/
|
|
31
31
|
disabled?: boolean;
|
|
32
32
|
/**
|
|
33
|
-
* Specify if the `ClickableTile` component should be rendered with rounded corners.
|
|
33
|
+
* **Experimental**: Specify if the `ClickableTile` component should be rendered with rounded corners.
|
|
34
34
|
* Only valid when `slug` prop is present
|
|
35
35
|
*/
|
|
36
36
|
hasRoundedCorners?: boolean;
|
|
@@ -57,7 +57,7 @@ export interface ClickableTileProps extends HTMLAttributes<HTMLAnchorElement> {
|
|
|
57
57
|
*/
|
|
58
58
|
rel?: string;
|
|
59
59
|
/**
|
|
60
|
-
* Specify if a `Slug` icon should be rendered inside the `ClickableTile`
|
|
60
|
+
* **Experimental**: Specify if a `Slug` icon should be rendered inside the `ClickableTile`
|
|
61
61
|
*/
|
|
62
62
|
slug?: boolean;
|
|
63
63
|
}
|
|
@@ -72,7 +72,7 @@ export interface SelectableTileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
72
72
|
*/
|
|
73
73
|
disabled?: boolean;
|
|
74
74
|
/**
|
|
75
|
-
* Specify if the `SelectableTile` component should be rendered with rounded corners.
|
|
75
|
+
* **Experimental**: Specify if the `SelectableTile` component should be rendered with rounded corners.
|
|
76
76
|
* Only valid when `slug` prop is present
|
|
77
77
|
*/
|
|
78
78
|
hasRoundedCorners?: boolean;
|
|
@@ -102,7 +102,7 @@ export interface SelectableTileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
102
102
|
*/
|
|
103
103
|
selected?: boolean;
|
|
104
104
|
/**
|
|
105
|
-
* Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
105
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
106
106
|
*/
|
|
107
107
|
slug?: ReactNodeLike;
|
|
108
108
|
/**
|
|
@@ -130,7 +130,7 @@ export interface ExpandableTileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
130
130
|
*/
|
|
131
131
|
expanded?: boolean;
|
|
132
132
|
/**
|
|
133
|
-
* Specify if the `ExpandableTile` component should be rendered with rounded corners.
|
|
133
|
+
* **Experimental**: Specify if the `ExpandableTile` component should be rendered with rounded corners.
|
|
134
134
|
* Only valid when `slug` prop is present
|
|
135
135
|
*/
|
|
136
136
|
hasRoundedCorners?: boolean;
|
|
@@ -147,7 +147,7 @@ export interface ExpandableTileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
147
147
|
*/
|
|
148
148
|
onKeyUp?(event: KeyboardEvent): void;
|
|
149
149
|
/**
|
|
150
|
-
* Provide a `Slug` component to be rendered inside the `ExpandableTile` component
|
|
150
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `ExpandableTile` component
|
|
151
151
|
*/
|
|
152
152
|
slug?: ReactNodeLike;
|
|
153
153
|
/**
|
|
@@ -66,7 +66,7 @@ Tile.propTypes = {
|
|
|
66
66
|
*/
|
|
67
67
|
className: PropTypes__default["default"].string,
|
|
68
68
|
/**
|
|
69
|
-
* Specify if the `Tile` component should be rendered with rounded corners. Only valid
|
|
69
|
+
* **Experimental**: Specify if the `Tile` component should be rendered with rounded corners. Only valid
|
|
70
70
|
* when `slug` prop is present
|
|
71
71
|
*/
|
|
72
72
|
hasRoundedCorners: PropTypes__default["default"].bool,
|
|
@@ -78,7 +78,7 @@ Tile.propTypes = {
|
|
|
78
78
|
*/
|
|
79
79
|
light: deprecate["default"](PropTypes__default["default"].bool, 'The `light` prop for `Tile` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.'),
|
|
80
80
|
/**
|
|
81
|
-
* Provide a `Slug` component to be rendered inside the `Tile` component
|
|
81
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `Tile` component
|
|
82
82
|
*/
|
|
83
83
|
slug: PropTypes__default["default"].node
|
|
84
84
|
};
|
|
@@ -183,7 +183,7 @@ ClickableTile.propTypes = {
|
|
|
183
183
|
*/
|
|
184
184
|
disabled: PropTypes__default["default"].bool,
|
|
185
185
|
/**
|
|
186
|
-
* Specify if the `ClickableTile` component should be rendered with rounded corners.
|
|
186
|
+
* **Experimental**: Specify if the `ClickableTile` component should be rendered with rounded corners.
|
|
187
187
|
* Only valid when `slug` prop is present
|
|
188
188
|
*/
|
|
189
189
|
hasRoundedCorners: PropTypes__default["default"].bool,
|
|
@@ -318,7 +318,7 @@ SelectableTile.propTypes = {
|
|
|
318
318
|
*/
|
|
319
319
|
disabled: PropTypes__default["default"].bool,
|
|
320
320
|
/**
|
|
321
|
-
* Specify if the `SelectableTile` component should be rendered with rounded corners.
|
|
321
|
+
* **Experimental**: Specify if the `SelectableTile` component should be rendered with rounded corners.
|
|
322
322
|
* Only valid when `slug` prop is present
|
|
323
323
|
*/
|
|
324
324
|
hasRoundedCorners: PropTypes__default["default"].bool,
|
|
@@ -353,7 +353,7 @@ SelectableTile.propTypes = {
|
|
|
353
353
|
*/
|
|
354
354
|
selected: PropTypes__default["default"].bool,
|
|
355
355
|
/**
|
|
356
|
-
* Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
356
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `SelectableTile` component
|
|
357
357
|
*/
|
|
358
358
|
slug: PropTypes__default["default"].node,
|
|
359
359
|
/**
|
|
@@ -583,6 +583,10 @@ ExpandableTile.propTypes = {
|
|
|
583
583
|
* optional handler to trigger a function when a key is pressed
|
|
584
584
|
*/
|
|
585
585
|
onKeyUp: PropTypes__default["default"].func,
|
|
586
|
+
/**
|
|
587
|
+
* **Experimental**: Provide a `Slug` component to be rendered inside the `ExpandableTile` component
|
|
588
|
+
*/
|
|
589
|
+
slug: PropTypes__default["default"].node,
|
|
586
590
|
/**
|
|
587
591
|
* The `tabindex` attribute.
|
|
588
592
|
*/
|
|
@@ -27,6 +27,10 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
27
27
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
28
28
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Event types that trigger a "drag" to stop.
|
|
32
|
+
*/
|
|
33
|
+
const DRAG_STOP_EVENT_TYPES = new Set(['mouseup', 'touchend', 'touchcancel']);
|
|
30
34
|
function Tooltip(_ref) {
|
|
31
35
|
let {
|
|
32
36
|
align = 'top',
|
|
@@ -43,6 +47,8 @@ function Tooltip(_ref) {
|
|
|
43
47
|
const containerRef = React.useRef(null);
|
|
44
48
|
const tooltipRef = React.useRef(null);
|
|
45
49
|
const [open, setOpen] = useDelayedState.useDelayedState(defaultOpen);
|
|
50
|
+
const [isDragging, setIsDragging] = React.useState(false);
|
|
51
|
+
const [isPointerIntersecting, setIsPointerIntersecting] = React.useState(false);
|
|
46
52
|
const id = useId.useId('tooltip');
|
|
47
53
|
const prefix = usePrefix.usePrefix();
|
|
48
54
|
const child = React__default["default"].Children.only(children);
|
|
@@ -51,7 +57,11 @@ function Tooltip(_ref) {
|
|
|
51
57
|
onBlur: () => setOpen(false),
|
|
52
58
|
onClick: () => closeOnActivation && setOpen(false),
|
|
53
59
|
// This should be placed on the trigger in case the element is disabled
|
|
54
|
-
onMouseEnter
|
|
60
|
+
onMouseEnter,
|
|
61
|
+
onMouseLeave,
|
|
62
|
+
onMouseDown: onDragStart,
|
|
63
|
+
onMouseMove: onMouseMove,
|
|
64
|
+
onTouchStart: onDragStart
|
|
55
65
|
};
|
|
56
66
|
function getChildEventHandlers(childProps) {
|
|
57
67
|
const eventHandlerFunctions = ['onFocus', 'onBlur', 'onClick', 'onMouseEnter'];
|
|
@@ -81,11 +91,34 @@ function Tooltip(_ref) {
|
|
|
81
91
|
}
|
|
82
92
|
}
|
|
83
93
|
function onMouseEnter() {
|
|
94
|
+
setIsPointerIntersecting(true);
|
|
84
95
|
setOpen(true, enterDelayMs);
|
|
85
96
|
}
|
|
86
97
|
function onMouseLeave() {
|
|
98
|
+
setIsPointerIntersecting(false);
|
|
99
|
+
if (isDragging) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
87
102
|
setOpen(false, leaveDelayMs);
|
|
88
103
|
}
|
|
104
|
+
function onMouseMove(evt) {
|
|
105
|
+
if (evt.buttons === 1) {
|
|
106
|
+
setIsDragging(true);
|
|
107
|
+
} else {
|
|
108
|
+
setIsDragging(false);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function onDragStart() {
|
|
112
|
+
setIsDragging(true);
|
|
113
|
+
}
|
|
114
|
+
const onDragStop = React.useCallback(() => {
|
|
115
|
+
setIsDragging(false);
|
|
116
|
+
// Close the tooltip, unless the mouse pointer is within the bounds of the
|
|
117
|
+
// trigger.
|
|
118
|
+
if (!isPointerIntersecting) {
|
|
119
|
+
setOpen(false, leaveDelayMs);
|
|
120
|
+
}
|
|
121
|
+
}, [isPointerIntersecting, leaveDelayMs, setOpen]);
|
|
89
122
|
useNoInteractiveChildren.useNoInteractiveChildren(tooltipRef, 'The Tooltip component must have no interactive content rendered by the' + '`label` or `description` prop');
|
|
90
123
|
React.useEffect(() => {
|
|
91
124
|
if (containerRef !== null && containerRef.current) {
|
|
@@ -95,6 +128,19 @@ function Tooltip(_ref) {
|
|
|
95
128
|
}
|
|
96
129
|
}
|
|
97
130
|
});
|
|
131
|
+
React.useEffect(() => {
|
|
132
|
+
if (isDragging) {
|
|
133
|
+
// Register drag stop handlers.
|
|
134
|
+
DRAG_STOP_EVENT_TYPES.forEach(eventType => {
|
|
135
|
+
document.addEventListener(eventType, onDragStop);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return () => {
|
|
139
|
+
DRAG_STOP_EVENT_TYPES.forEach(eventType => {
|
|
140
|
+
document.removeEventListener(eventType, onDragStop);
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
}, [isDragging, onDragStop]);
|
|
98
144
|
return /*#__PURE__*/React__default["default"].createElement(index.Popover, _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
99
145
|
align: align,
|
|
100
146
|
className: cx__default["default"](`${prefix}--tooltip`, customClassName),
|
|
@@ -0,0 +1,36 @@
|
|
|
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, { ReactNode } from 'react';
|
|
8
|
+
interface HeaderPanelProps {
|
|
9
|
+
/**
|
|
10
|
+
* Specify whether focus and blur listeners are added. They are by default.
|
|
11
|
+
*/
|
|
12
|
+
addFocusListeners?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The content that will render inside of the `HeaderPanel`
|
|
15
|
+
*/
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Optionally provide a custom class to apply to the underlying `<li>` node
|
|
19
|
+
*/
|
|
20
|
+
className?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Specify whether the panel is expanded
|
|
23
|
+
*/
|
|
24
|
+
expanded?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Provide the `href` to the id of the element on your package that could
|
|
27
|
+
* be target.
|
|
28
|
+
*/
|
|
29
|
+
href?: string;
|
|
30
|
+
/**
|
|
31
|
+
* An optional listener that is called a callback to collapse the HeaderPanel
|
|
32
|
+
*/
|
|
33
|
+
onHeaderPanelFocus?: () => void;
|
|
34
|
+
}
|
|
35
|
+
declare const HeaderPanel: React.FC<HeaderPanelProps>;
|
|
36
|
+
export default HeaderPanel;
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
12
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
-
var React = require('react');
|
|
14
13
|
var cx = require('classnames');
|
|
15
14
|
var PropTypes = require('prop-types');
|
|
15
|
+
var React = require('react');
|
|
16
16
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
17
17
|
var useEvent = require('../../internal/useEvent.js');
|
|
18
18
|
var useMergedRefs = require('../../internal/useMergedRefs.js');
|
|
@@ -21,9 +21,9 @@ var keys = require('../../internal/keyboard/keys.js');
|
|
|
21
21
|
|
|
22
22
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
23
|
|
|
24
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
25
24
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
26
25
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
26
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
27
27
|
|
|
28
28
|
const noopFn = () => {};
|
|
29
29
|
const HeaderPanel = /*#__PURE__*/React__default["default"].forwardRef(function HeaderPanel(_ref, ref) {
|
|
@@ -34,7 +34,7 @@ const HeaderPanel = /*#__PURE__*/React__default["default"].forwardRef(function H
|
|
|
34
34
|
addFocusListeners = true,
|
|
35
35
|
onHeaderPanelFocus = noopFn,
|
|
36
36
|
href,
|
|
37
|
-
...
|
|
37
|
+
...rest
|
|
38
38
|
} = _ref;
|
|
39
39
|
const prefix = usePrefix.usePrefix();
|
|
40
40
|
const headerPanelReference = React.useRef(null);
|
|
@@ -71,12 +71,13 @@ const HeaderPanel = /*#__PURE__*/React__default["default"].forwardRef(function H
|
|
|
71
71
|
useEvent.useWindowEvent('click', () => {
|
|
72
72
|
const focusedElement = document.activeElement;
|
|
73
73
|
setLastClickedElement(focusedElement);
|
|
74
|
-
|
|
74
|
+
const childJsxElement = children;
|
|
75
|
+
if (childJsxElement.type?.displayName === 'Switcher' && !focusedElement?.closest(`.${prefix}--header-panel--expanded`) && !focusedElement?.closest(`.${prefix}--header__action`) && !headerPanelReference?.current?.classList.contains(`${prefix}--switcher`) && expanded) {
|
|
75
76
|
setExpandedState(false);
|
|
76
77
|
onHeaderPanelFocus();
|
|
77
78
|
}
|
|
78
79
|
});
|
|
79
|
-
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({},
|
|
80
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
80
81
|
className: className,
|
|
81
82
|
ref: headerPanelRef
|
|
82
83
|
}, eventHandlers), children);
|
|
@@ -109,6 +110,5 @@ HeaderPanel.propTypes = {
|
|
|
109
110
|
onHeaderPanelFocus: PropTypes__default["default"].func
|
|
110
111
|
};
|
|
111
112
|
HeaderPanel.displayName = 'HeaderPanel';
|
|
112
|
-
var HeaderPanel$1 = HeaderPanel;
|
|
113
113
|
|
|
114
|
-
exports["default"] = HeaderPanel
|
|
114
|
+
exports["default"] = HeaderPanel;
|
package/lib/index.js
CHANGED
|
@@ -58,6 +58,7 @@ var ColumnHang = require('./components/Grid/ColumnHang.js');
|
|
|
58
58
|
var GridContext = require('./components/Grid/GridContext.js');
|
|
59
59
|
var Icon_Skeleton = require('./components/Icon/Icon.Skeleton.js');
|
|
60
60
|
var index$7 = require('./components/IdPrefix/index.js');
|
|
61
|
+
var InlineLoading = require('./components/InlineLoading/InlineLoading.js');
|
|
61
62
|
var Link = require('./components/Link/Link.js');
|
|
62
63
|
var ListItem = require('./components/ListItem/ListItem.js');
|
|
63
64
|
var Loading = require('./components/Loading/Loading.js');
|
|
@@ -161,7 +162,6 @@ var useContextMenu = require('./components/ContextMenu/useContextMenu.js');
|
|
|
161
162
|
var Copy = require('./components/Copy/Copy.js');
|
|
162
163
|
var CopyButton = require('./components/CopyButton/CopyButton.js');
|
|
163
164
|
var ErrorBoundary = require('./components/ErrorBoundary/ErrorBoundary.js');
|
|
164
|
-
var InlineLoading = require('./components/InlineLoading/InlineLoading.js');
|
|
165
165
|
var ModalWrapper = require('./components/ModalWrapper/ModalWrapper.js');
|
|
166
166
|
var ProgressIndicator_Skeleton = require('./components/ProgressIndicator/ProgressIndicator.Skeleton.js');
|
|
167
167
|
var TextInput_Skeleton = require('./components/TextInput/TextInput.Skeleton.js');
|
|
@@ -201,6 +201,7 @@ var TableHeader = require('./components/DataTable/TableHeader.js');
|
|
|
201
201
|
var TableRow = require('./components/DataTable/TableRow.js');
|
|
202
202
|
var TableSelectAll = require('./components/DataTable/TableSelectAll.js');
|
|
203
203
|
var TableSelectRow = require('./components/DataTable/TableSelectRow.js');
|
|
204
|
+
var TableSlugRow = require('./components/DataTable/TableSlugRow.js');
|
|
204
205
|
var TableToolbar = require('./components/DataTable/TableToolbar.js');
|
|
205
206
|
var TableToolbarAction = require('./components/DataTable/TableToolbarAction.js');
|
|
206
207
|
var TableToolbarContent = require('./components/DataTable/TableToolbarContent.js');
|
|
@@ -280,6 +281,7 @@ exports.ColumnHang = ColumnHang.ColumnHang;
|
|
|
280
281
|
exports.GridSettings = GridContext.GridSettings;
|
|
281
282
|
exports.IconSkeleton = Icon_Skeleton["default"];
|
|
282
283
|
exports.IdPrefix = index$7.IdPrefix;
|
|
284
|
+
exports.InlineLoading = InlineLoading["default"];
|
|
283
285
|
exports.Link = Link["default"];
|
|
284
286
|
exports.ListItem = ListItem["default"];
|
|
285
287
|
exports.Loading = Loading["default"];
|
|
@@ -417,7 +419,6 @@ exports.useContextMenu = useContextMenu["default"];
|
|
|
417
419
|
exports.Copy = Copy["default"];
|
|
418
420
|
exports.CopyButton = CopyButton["default"];
|
|
419
421
|
exports.ErrorBoundary = ErrorBoundary["default"];
|
|
420
|
-
exports.InlineLoading = InlineLoading["default"];
|
|
421
422
|
exports.ModalWrapper = ModalWrapper["default"];
|
|
422
423
|
exports.ProgressIndicatorSkeleton = ProgressIndicator_Skeleton["default"];
|
|
423
424
|
exports.TextInputSkeleton = TextInput_Skeleton["default"];
|
|
@@ -457,6 +458,7 @@ exports.TableHeader = TableHeader["default"];
|
|
|
457
458
|
exports.TableRow = TableRow["default"];
|
|
458
459
|
exports.TableSelectAll = TableSelectAll["default"];
|
|
459
460
|
exports.TableSelectRow = TableSelectRow["default"];
|
|
461
|
+
exports.TableSlugRow = TableSlugRow["default"];
|
|
460
462
|
exports.TableToolbar = TableToolbar["default"];
|
|
461
463
|
exports.TableToolbarAction = TableToolbarAction["default"];
|
|
462
464
|
exports.TableToolbarContent = TableToolbarContent["default"];
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
12
|
function useAnnouncer(textCount, maxCount) {
|
|
13
|
+
let entityName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'characters';
|
|
13
14
|
const lastTen = maxCount - 10;
|
|
14
15
|
if (textCount >= lastTen) {
|
|
15
|
-
return `${maxCount - textCount}
|
|
16
|
+
return `${maxCount - textCount} ${entityName} left.`;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -78,7 +78,7 @@ function getRoleContent(node) {
|
|
|
78
78
|
* @see https://github.com/w3c/aria-practices/blob/0553bb51588ffa517506e2a1b2ca1422ed438c5f/examples/js/utils.js#L68
|
|
79
79
|
*/
|
|
80
80
|
function isFocusable(element) {
|
|
81
|
-
if (element.tabIndex < 0) {
|
|
81
|
+
if (element.tabIndex === undefined || element.tabIndex < 0) {
|
|
82
82
|
return false;
|
|
83
83
|
}
|
|
84
84
|
if (element.disabled) {
|
|
@@ -89,12 +89,8 @@ function isFocusable(element) {
|
|
|
89
89
|
return !!element.href && element.rel !== 'ignore';
|
|
90
90
|
case 'INPUT':
|
|
91
91
|
return element.type !== 'hidden';
|
|
92
|
-
case 'BUTTON':
|
|
93
|
-
case 'SELECT':
|
|
94
|
-
case 'TEXTAREA':
|
|
95
|
-
return true;
|
|
96
92
|
default:
|
|
97
|
-
return
|
|
93
|
+
return true;
|
|
98
94
|
}
|
|
99
95
|
}
|
|
100
96
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.45.0-rc.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@babel/runtime": "^7.18.3",
|
|
50
50
|
"@carbon/feature-flags": "^0.16.0",
|
|
51
|
-
"@carbon/icons-react": "^11.
|
|
51
|
+
"@carbon/icons-react": "^11.32.0-rc.0",
|
|
52
52
|
"@carbon/layout": "^11.20.0",
|
|
53
|
-
"@carbon/styles": "^1.
|
|
53
|
+
"@carbon/styles": "^1.45.0-rc.0",
|
|
54
54
|
"@carbon/telemetry": "0.1.0",
|
|
55
55
|
"classnames": "2.3.2",
|
|
56
56
|
"copy-to-clipboard": "^3.3.1",
|
|
@@ -87,9 +87,7 @@
|
|
|
87
87
|
"@storybook/addon-actions": "^7.1.0",
|
|
88
88
|
"@storybook/addon-docs": "^7.1.0",
|
|
89
89
|
"@storybook/addon-essentials": "^7.1.0",
|
|
90
|
-
"@storybook/addon-knobs": "^7.0.2",
|
|
91
90
|
"@storybook/addon-links": "^7.4.5",
|
|
92
|
-
"@storybook/addon-notes": "^5.3.21",
|
|
93
91
|
"@storybook/addon-storysource": "^7.1.0",
|
|
94
92
|
"@storybook/react": "^7.1.0",
|
|
95
93
|
"@storybook/react-webpack5": "^7.1.0",
|
|
@@ -122,7 +120,6 @@
|
|
|
122
120
|
"sass": "^1.51.0",
|
|
123
121
|
"sass-loader": "^13.0.0",
|
|
124
122
|
"storybook": "^7.1.0",
|
|
125
|
-
"storybook-readme": "^5.0.9",
|
|
126
123
|
"stream-browserify": "^3.0.0",
|
|
127
124
|
"style-loader": "^3.3.1",
|
|
128
125
|
"typescript-config-carbon": "^0.2.0",
|
|
@@ -140,5 +137,5 @@
|
|
|
140
137
|
"**/*.scss",
|
|
141
138
|
"**/*.css"
|
|
142
139
|
],
|
|
143
|
-
"gitHead": "
|
|
140
|
+
"gitHead": "451ce652bb9e0fcd30fc28a41ddee1a1daedfd34"
|
|
144
141
|
}
|