@carbon/react 1.42.1 → 1.44.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 +2843 -1416
- package/es/components/Breadcrumb/BreadcrumbItem.js +1 -2
- package/es/components/ComboBox/ComboBox.d.ts +5 -0
- package/es/components/ComboBox/ComboBox.js +28 -2
- package/es/components/ComboButton/index.js +2 -1
- package/es/components/ComposedModal/ComposedModal.d.ts +3 -3
- package/es/components/ComposedModal/ComposedModal.js +3 -3
- package/es/components/ComposedModal/ModalFooter.d.ts +18 -0
- package/es/components/ComposedModal/ModalFooter.js +48 -16
- package/es/components/ContextMenu/useContextMenu.js +2 -1
- package/es/components/DataTableSkeleton/DataTableSkeleton.js +1 -1
- package/es/components/DatePickerInput/DatePickerInput.d.ts +4 -0
- package/es/components/DatePickerInput/DatePickerInput.js +16 -2
- package/es/components/Dropdown/Dropdown.d.ts +5 -0
- package/es/components/Dropdown/Dropdown.js +20 -3
- package/es/components/InlineLoading/index.js +9 -0
- package/es/components/Link/Link.d.ts +5 -0
- package/es/components/Link/Link.js +9 -2
- package/es/components/Menu/Menu.js +14 -0
- package/es/components/Menu/MenuContext.js +1 -0
- package/es/components/Menu/MenuItem.js +19 -4
- package/es/components/MenuButton/index.js +3 -1
- package/es/components/Modal/Modal.d.ts +17 -0
- package/es/components/Modal/Modal.js +38 -3
- package/es/components/MultiSelect/FilterableMultiSelect.js +17 -3
- package/es/components/MultiSelect/MultiSelect.d.ts +5 -0
- package/es/components/MultiSelect/MultiSelect.js +17 -3
- package/es/components/NumberInput/NumberInput.d.ts +5 -0
- package/es/components/NumberInput/NumberInput.js +29 -4
- package/es/components/Select/Select.d.ts +6 -1
- package/es/components/Select/Select.js +16 -2
- package/es/components/Slug/index.js +187 -0
- package/es/components/TextArea/TextArea.d.ts +4 -0
- package/es/components/TextArea/TextArea.js +47 -31
- package/es/components/TextInput/TextInput.d.ts +5 -0
- package/es/components/TextInput/TextInput.js +16 -2
- package/es/components/UIShell/SideNav.js +1 -1
- package/es/components/UIShell/SideNavHeader.d.ts +29 -0
- package/es/components/UIShell/SideNavHeader.js +3 -3
- package/es/components/UIShell/Switcher.d.ts +38 -0
- package/es/components/UIShell/Switcher.js +14 -13
- package/es/components/UIShell/SwitcherDivider.d.ts +9 -0
- package/es/components/UIShell/SwitcherDivider.js +4 -5
- package/es/components/UIShell/SwitcherItem.d.ts +49 -0
- package/es/components/UIShell/SwitcherItem.js +13 -17
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/prop-types/tools/getDisplayName.js +34 -0
- package/lib/components/Breadcrumb/BreadcrumbItem.js +1 -2
- package/lib/components/ComboBox/ComboBox.d.ts +5 -0
- package/lib/components/ComboBox/ComboBox.js +28 -2
- package/lib/components/ComboButton/index.js +2 -1
- package/lib/components/ComposedModal/ComposedModal.d.ts +3 -3
- package/lib/components/ComposedModal/ComposedModal.js +3 -3
- package/lib/components/ComposedModal/ModalFooter.d.ts +18 -0
- package/lib/components/ComposedModal/ModalFooter.js +48 -16
- package/lib/components/ContextMenu/useContextMenu.js +2 -1
- package/lib/components/DataTableSkeleton/DataTableSkeleton.js +1 -1
- package/lib/components/DatePickerInput/DatePickerInput.d.ts +4 -0
- package/lib/components/DatePickerInput/DatePickerInput.js +16 -2
- package/lib/components/Dropdown/Dropdown.d.ts +5 -0
- package/lib/components/Dropdown/Dropdown.js +20 -3
- package/lib/components/InlineLoading/index.js +17 -0
- package/lib/components/Link/Link.d.ts +5 -0
- package/lib/components/Link/Link.js +9 -2
- package/lib/components/Menu/Menu.js +14 -0
- package/lib/components/Menu/MenuContext.js +1 -0
- package/lib/components/Menu/MenuItem.js +19 -4
- package/lib/components/MenuButton/index.js +3 -1
- package/lib/components/Modal/Modal.d.ts +17 -0
- package/lib/components/Modal/Modal.js +38 -3
- package/lib/components/MultiSelect/FilterableMultiSelect.js +17 -3
- package/lib/components/MultiSelect/MultiSelect.d.ts +5 -0
- package/lib/components/MultiSelect/MultiSelect.js +17 -3
- package/lib/components/NumberInput/NumberInput.d.ts +5 -0
- package/lib/components/NumberInput/NumberInput.js +28 -3
- package/lib/components/Select/Select.d.ts +6 -1
- package/lib/components/Select/Select.js +16 -2
- package/lib/components/Slug/index.js +199 -0
- package/lib/components/TextArea/TextArea.d.ts +4 -0
- package/lib/components/TextArea/TextArea.js +47 -31
- package/lib/components/TextInput/TextInput.d.ts +5 -0
- package/lib/components/TextInput/TextInput.js +16 -2
- package/lib/components/UIShell/SideNav.js +1 -1
- package/lib/components/UIShell/SideNavHeader.d.ts +29 -0
- package/lib/components/UIShell/SideNavHeader.js +3 -3
- package/lib/components/UIShell/Switcher.d.ts +38 -0
- package/lib/components/UIShell/Switcher.js +13 -12
- package/lib/components/UIShell/SwitcherDivider.d.ts +9 -0
- package/lib/components/UIShell/SwitcherDivider.js +4 -5
- package/lib/components/UIShell/SwitcherItem.d.ts +49 -0
- package/lib/components/UIShell/SwitcherItem.js +12 -16
- package/lib/index.d.ts +1 -0
- package/lib/index.js +45 -41
- package/lib/prop-types/tools/getDisplayName.js +38 -0
- package/package.json +6 -6
- package/scss/utilities/_ai-gradient.scss +9 -0
|
@@ -0,0 +1,199 @@
|
|
|
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 cx = require('classnames');
|
|
14
|
+
var PropTypes = require('prop-types');
|
|
15
|
+
var React = require('react');
|
|
16
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
17
|
+
var index = require('../Toggletip/index.js');
|
|
18
|
+
var index$1 = require('../IconButton/index.js');
|
|
19
|
+
var iconsReact = require('@carbon/icons-react');
|
|
20
|
+
var useId = require('../../internal/useId.js');
|
|
21
|
+
|
|
22
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
|
+
|
|
24
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
25
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
26
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
27
|
+
|
|
28
|
+
var _Undo;
|
|
29
|
+
const SlugContent = /*#__PURE__*/React__default["default"].forwardRef(function SlugContent(_ref, ref) {
|
|
30
|
+
let {
|
|
31
|
+
children,
|
|
32
|
+
className
|
|
33
|
+
} = _ref;
|
|
34
|
+
const prefix = usePrefix.usePrefix();
|
|
35
|
+
const slugContentClasses = cx__default["default"](className, {
|
|
36
|
+
[`${prefix}--slug-content`]: true
|
|
37
|
+
});
|
|
38
|
+
return /*#__PURE__*/React__default["default"].createElement(index.ToggletipContent, {
|
|
39
|
+
className: slugContentClasses,
|
|
40
|
+
ref: ref
|
|
41
|
+
}, children);
|
|
42
|
+
});
|
|
43
|
+
SlugContent.propTypes = {
|
|
44
|
+
/**
|
|
45
|
+
* Specify the content you want rendered inside the slug ToggleTip
|
|
46
|
+
*/
|
|
47
|
+
children: PropTypes__default["default"].node,
|
|
48
|
+
/**
|
|
49
|
+
* Specify an optional className to be added to the AI slug callout
|
|
50
|
+
*/
|
|
51
|
+
className: PropTypes__default["default"].string
|
|
52
|
+
};
|
|
53
|
+
const SlugActions = /*#__PURE__*/React__default["default"].forwardRef(function SlugActions(_ref2, ref) {
|
|
54
|
+
let {
|
|
55
|
+
children,
|
|
56
|
+
className
|
|
57
|
+
} = _ref2;
|
|
58
|
+
const prefix = usePrefix.usePrefix();
|
|
59
|
+
const slugActionBarClasses = cx__default["default"](className, {
|
|
60
|
+
[`${prefix}--slug-actions`]: true
|
|
61
|
+
});
|
|
62
|
+
return /*#__PURE__*/React__default["default"].createElement(index.ToggletipActions, {
|
|
63
|
+
className: slugActionBarClasses,
|
|
64
|
+
ref: ref
|
|
65
|
+
}, children);
|
|
66
|
+
});
|
|
67
|
+
SlugActions.propTypes = {
|
|
68
|
+
/**
|
|
69
|
+
* Specify the content you want rendered inside the slug callout toolbar
|
|
70
|
+
*/
|
|
71
|
+
children: PropTypes__default["default"].node,
|
|
72
|
+
/**
|
|
73
|
+
* Specify an optional className to be added to the AI slug toolbar
|
|
74
|
+
*/
|
|
75
|
+
className: PropTypes__default["default"].string
|
|
76
|
+
};
|
|
77
|
+
const Slug = /*#__PURE__*/React__default["default"].forwardRef(function Slug(_ref3, ref) {
|
|
78
|
+
let {
|
|
79
|
+
aiText = 'AI',
|
|
80
|
+
aiTextLabel,
|
|
81
|
+
align,
|
|
82
|
+
autoAlign = true,
|
|
83
|
+
children,
|
|
84
|
+
className,
|
|
85
|
+
dotType,
|
|
86
|
+
kind,
|
|
87
|
+
onRevertClick,
|
|
88
|
+
revertActive,
|
|
89
|
+
revertLabel = 'Revert to AI input',
|
|
90
|
+
slugLabel = 'Show information',
|
|
91
|
+
size = 'xs',
|
|
92
|
+
...rest
|
|
93
|
+
} = _ref3;
|
|
94
|
+
const prefix = usePrefix.usePrefix();
|
|
95
|
+
const id = useId.useId('slug');
|
|
96
|
+
const slugClasses = cx__default["default"](className, {
|
|
97
|
+
[`${prefix}--slug`]: true,
|
|
98
|
+
[`${prefix}--slug--hollow`]: kind === 'hollow' || dotType === 'hollow',
|
|
99
|
+
// Need to come up with a better name; explainable?
|
|
100
|
+
// Need to be able to target the non-hollow variant another way
|
|
101
|
+
// other than using `:not` all over the styles
|
|
102
|
+
[`${prefix}--slug--enabled`]: kind !== 'hollow' && dotType !== 'hollow',
|
|
103
|
+
[`${prefix}--slug--revert`]: revertActive
|
|
104
|
+
});
|
|
105
|
+
const slugButtonClasses = cx__default["default"]({
|
|
106
|
+
[`${prefix}--slug__button`]: true,
|
|
107
|
+
[`${prefix}--slug__button--${size}`]: size,
|
|
108
|
+
[`${prefix}--slug__button--${kind}`]: kind,
|
|
109
|
+
[`${prefix}--slug__button--inline-with-content`]: kind === 'inline' && aiTextLabel
|
|
110
|
+
});
|
|
111
|
+
const handleOnRevertClick = evt => {
|
|
112
|
+
if (onRevertClick) {
|
|
113
|
+
onRevertClick(evt);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const ariaLabel = !aiTextLabel ? `${aiText} - ${slugLabel}` : `${aiText} - ${aiTextLabel}`;
|
|
117
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
118
|
+
className: slugClasses,
|
|
119
|
+
ref: ref,
|
|
120
|
+
id: id
|
|
121
|
+
}, revertActive ? /*#__PURE__*/React__default["default"].createElement(index$1.IconButton, _rollupPluginBabelHelpers["extends"]({
|
|
122
|
+
onClick: handleOnRevertClick,
|
|
123
|
+
kind: "ghost",
|
|
124
|
+
size: "sm",
|
|
125
|
+
label: revertLabel
|
|
126
|
+
}, rest), _Undo || (_Undo = /*#__PURE__*/React__default["default"].createElement(iconsReact.Undo, null))) : /*#__PURE__*/React__default["default"].createElement(index.Toggletip, _rollupPluginBabelHelpers["extends"]({
|
|
127
|
+
align: align,
|
|
128
|
+
autoAlign: autoAlign
|
|
129
|
+
}, rest), /*#__PURE__*/React__default["default"].createElement(index.ToggletipButton, {
|
|
130
|
+
className: slugButtonClasses,
|
|
131
|
+
label: ariaLabel
|
|
132
|
+
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
133
|
+
className: `${prefix}--slug__text`
|
|
134
|
+
}, aiText), aiTextLabel && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
135
|
+
className: `${prefix}--slug__additional-text`
|
|
136
|
+
}, aiTextLabel)), children));
|
|
137
|
+
});
|
|
138
|
+
Slug.propTypes = {
|
|
139
|
+
/**
|
|
140
|
+
* Specify the correct translation of the AI text
|
|
141
|
+
*/
|
|
142
|
+
aiText: PropTypes__default["default"].string,
|
|
143
|
+
/**
|
|
144
|
+
* Specify additional text to be rendered next to the AI label in the inline variant
|
|
145
|
+
*/
|
|
146
|
+
aiTextLabel: PropTypes__default["default"].string,
|
|
147
|
+
/**
|
|
148
|
+
* Specify how the popover should align with the button
|
|
149
|
+
*/
|
|
150
|
+
align: PropTypes__default["default"].oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-bottom', 'left-top', 'right', 'right-bottom', 'right-top']),
|
|
151
|
+
/**
|
|
152
|
+
* Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to future changes.
|
|
153
|
+
*/
|
|
154
|
+
autoAlign: PropTypes__default["default"].bool,
|
|
155
|
+
/**
|
|
156
|
+
* Specify the content you want rendered inside the slug ToggleTip
|
|
157
|
+
*/
|
|
158
|
+
children: PropTypes__default["default"].node,
|
|
159
|
+
/**
|
|
160
|
+
* Specify an optional className to be added to the AI slug
|
|
161
|
+
*/
|
|
162
|
+
className: PropTypes__default["default"].string,
|
|
163
|
+
/**
|
|
164
|
+
* Specify the type of dot that should be rendered in front of the inline variant
|
|
165
|
+
*/
|
|
166
|
+
dotType: PropTypes__default["default"].oneOf(['default', 'hollow']),
|
|
167
|
+
/**
|
|
168
|
+
* Specify the type of Slug, from the following list of types:
|
|
169
|
+
*/
|
|
170
|
+
kind: PropTypes__default["default"].oneOf(['default', 'hollow', 'inline']),
|
|
171
|
+
/**
|
|
172
|
+
* Callback function that fires when the revert button is clicked
|
|
173
|
+
*/
|
|
174
|
+
onRevertClick: PropTypes__default["default"].func,
|
|
175
|
+
/**
|
|
176
|
+
* Specify whether the revert button should be visible
|
|
177
|
+
*/
|
|
178
|
+
revertActive: PropTypes__default["default"].bool,
|
|
179
|
+
/**
|
|
180
|
+
* Specify the text that should be shown when the revert button is hovered
|
|
181
|
+
*/
|
|
182
|
+
revertLabel: PropTypes__default["default"].string,
|
|
183
|
+
/**
|
|
184
|
+
* Specify the size of the button, from the following list of sizes:
|
|
185
|
+
*/
|
|
186
|
+
size: PropTypes__default["default"].oneOf(['mini', '2xs', 'xs', 'sm', 'md', 'lg', 'xl']),
|
|
187
|
+
/**
|
|
188
|
+
* Specify the content you want rendered inside the slug ToggleTip
|
|
189
|
+
*/
|
|
190
|
+
slugContent: PropTypes__default["default"].node,
|
|
191
|
+
/**
|
|
192
|
+
* Specify the text that will be provided to the aria-label of the `Slug` button
|
|
193
|
+
*/
|
|
194
|
+
slugLabel: PropTypes__default["default"].string
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
exports.Slug = Slug;
|
|
198
|
+
exports.SlugActions = SlugActions;
|
|
199
|
+
exports.SlugContent = SlugContent;
|
|
@@ -85,6 +85,10 @@ export interface TextAreaProps extends React.InputHTMLAttributes<HTMLTextAreaEle
|
|
|
85
85
|
* Specify the rows attribute for the `<textarea>`
|
|
86
86
|
*/
|
|
87
87
|
rows?: number;
|
|
88
|
+
/**
|
|
89
|
+
* Provide a `Slug` component to be rendered inside the `TextArea` component
|
|
90
|
+
*/
|
|
91
|
+
slug?: ReactNodeLike;
|
|
88
92
|
/**
|
|
89
93
|
* Provide the current value of the `<textarea>`
|
|
90
94
|
*/
|
|
@@ -52,6 +52,7 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
52
52
|
warn = false,
|
|
53
53
|
warnText = '',
|
|
54
54
|
rows = 4,
|
|
55
|
+
slug,
|
|
55
56
|
...other
|
|
56
57
|
} = props;
|
|
57
58
|
const prefix = usePrefix.usePrefix();
|
|
@@ -66,9 +67,19 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
66
67
|
const {
|
|
67
68
|
current: textAreaInstanceId
|
|
68
69
|
} = React.useRef(getInstanceId());
|
|
70
|
+
const textareaRef = React.useRef(null);
|
|
71
|
+
const ref = useMergedRefs.useMergedRefs([forwardRef, textareaRef]);
|
|
69
72
|
React.useEffect(() => {
|
|
70
73
|
setTextCount(defaultValue?.toString()?.length || value?.toString()?.length || 0);
|
|
71
74
|
}, [value, defaultValue]);
|
|
75
|
+
useIsomorphicEffect["default"](() => {
|
|
76
|
+
if (other.cols && textareaRef.current) {
|
|
77
|
+
textareaRef.current.style.width = '';
|
|
78
|
+
textareaRef.current.style.resize = 'none';
|
|
79
|
+
} else if (textareaRef.current) {
|
|
80
|
+
textareaRef.current.style.width = `100%`;
|
|
81
|
+
}
|
|
82
|
+
}, [other.cols]);
|
|
72
83
|
const textareaProps = {
|
|
73
84
|
id,
|
|
74
85
|
onChange: evt => {
|
|
@@ -87,29 +98,36 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
87
98
|
}
|
|
88
99
|
}
|
|
89
100
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
101
|
+
const formItemClasses = cx__default["default"](`${prefix}--form-item`, className);
|
|
102
|
+
const textAreaWrapperClasses = cx__default["default"](`${prefix}--text-area__wrapper`, {
|
|
103
|
+
[`${prefix}--text-area__wrapper--readonly`]: other.readOnly,
|
|
104
|
+
[`${prefix}--text-area__wrapper--warn`]: warn,
|
|
105
|
+
[`${prefix}--text-area__wrapper--slug`]: slug
|
|
106
|
+
});
|
|
94
107
|
const labelClasses = cx__default["default"](`${prefix}--label`, {
|
|
95
108
|
[`${prefix}--visually-hidden`]: hideLabel && !isFluid,
|
|
96
109
|
[`${prefix}--label--disabled`]: disabled
|
|
97
110
|
});
|
|
111
|
+
const textareaClasses = cx__default["default"](`${prefix}--text-area`, {
|
|
112
|
+
[`${prefix}--text-area--light`]: light,
|
|
113
|
+
[`${prefix}--text-area--invalid`]: invalid,
|
|
114
|
+
[`${prefix}--text-area--warn`]: warn
|
|
115
|
+
});
|
|
116
|
+
const counterClasses = cx__default["default"](`${prefix}--label`, {
|
|
117
|
+
[`${prefix}--label--disabled`]: disabled
|
|
118
|
+
});
|
|
119
|
+
const helperTextClasses = cx__default["default"](`${prefix}--form__helper-text`, {
|
|
120
|
+
[`${prefix}--form__helper-text--disabled`]: disabled
|
|
121
|
+
});
|
|
98
122
|
const label = labelText ? /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
99
123
|
as: "label",
|
|
100
124
|
htmlFor: id,
|
|
101
125
|
className: labelClasses
|
|
102
126
|
}, labelText) : null;
|
|
103
|
-
const counterClasses = cx__default["default"](`${prefix}--label`, {
|
|
104
|
-
[`${prefix}--label--disabled`]: disabled
|
|
105
|
-
});
|
|
106
127
|
const counter = enableCounter && maxCount ? /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
107
128
|
as: "div",
|
|
108
129
|
className: counterClasses
|
|
109
130
|
}, `${textCount}/${maxCount}`) : null;
|
|
110
|
-
const helperTextClasses = cx__default["default"](`${prefix}--form__helper-text`, {
|
|
111
|
-
[`${prefix}--form__helper-text--disabled`]: disabled
|
|
112
|
-
});
|
|
113
131
|
const helperId = !helperText ? undefined : `text-area-helper-text-${textAreaInstanceId}`;
|
|
114
132
|
const helper = helperText ? /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
115
133
|
as: "div",
|
|
@@ -132,27 +150,16 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
132
150
|
}, warnText, isFluid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
|
|
133
151
|
className: `${prefix}--text-area__invalid-icon ${prefix}--text-area__invalid-icon--warning`
|
|
134
152
|
})) : null;
|
|
135
|
-
const textareaClasses = cx__default["default"](`${prefix}--text-area`, {
|
|
136
|
-
[`${prefix}--text-area--light`]: light,
|
|
137
|
-
[`${prefix}--text-area--invalid`]: invalid,
|
|
138
|
-
[`${prefix}--text-area--warn`]: warn
|
|
139
|
-
});
|
|
140
|
-
const textareaRef = React.useRef(null);
|
|
141
|
-
const ref = useMergedRefs.useMergedRefs([forwardRef, textareaRef]);
|
|
142
|
-
useIsomorphicEffect["default"](() => {
|
|
143
|
-
if (other.cols && textareaRef.current) {
|
|
144
|
-
textareaRef.current.style.width = '';
|
|
145
|
-
textareaRef.current.style.resize = 'none';
|
|
146
|
-
} else if (textareaRef.current) {
|
|
147
|
-
textareaRef.current.style.width = `100%`;
|
|
148
|
-
}
|
|
149
|
-
}, [other.cols]);
|
|
150
153
|
let ariaDescribedBy;
|
|
151
154
|
if (invalid) {
|
|
152
155
|
ariaDescribedBy = errorId;
|
|
153
156
|
} else if (!invalid && !warn && !isFluid && helperText) {
|
|
154
157
|
ariaDescribedBy = helperId;
|
|
155
158
|
}
|
|
159
|
+
if (enableCounter) {
|
|
160
|
+
textareaProps.maxLength = maxCount;
|
|
161
|
+
}
|
|
162
|
+
const ariaAnnouncement = useAnnouncer.useAnnouncer(textCount, maxCount);
|
|
156
163
|
const input = /*#__PURE__*/React__default["default"].createElement("textarea", _rollupPluginBabelHelpers["extends"]({}, other, textareaProps, {
|
|
157
164
|
placeholder: placeholder,
|
|
158
165
|
className: textareaClasses,
|
|
@@ -163,21 +170,26 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
163
170
|
readOnly: other.readOnly,
|
|
164
171
|
ref: ref
|
|
165
172
|
}));
|
|
173
|
+
|
|
174
|
+
// Slug is always size `mini`
|
|
175
|
+
let normalizedSlug;
|
|
176
|
+
if (slug) {
|
|
177
|
+
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
178
|
+
size: 'mini'
|
|
179
|
+
});
|
|
180
|
+
}
|
|
166
181
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
167
|
-
className:
|
|
182
|
+
className: formItemClasses
|
|
168
183
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
169
184
|
className: `${prefix}--text-area__label-wrapper`
|
|
170
185
|
}, label, counter), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
171
|
-
className:
|
|
172
|
-
[`${prefix}--text-area__wrapper--readonly`]: other.readOnly,
|
|
173
|
-
[`${prefix}--text-area__wrapper--warn`]: warn
|
|
174
|
-
}),
|
|
186
|
+
className: textAreaWrapperClasses,
|
|
175
187
|
"data-invalid": invalid || null
|
|
176
188
|
}, invalid && !isFluid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
|
|
177
189
|
className: `${prefix}--text-area__invalid-icon`
|
|
178
190
|
}), warn && !invalid && !isFluid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
|
|
179
191
|
className: `${prefix}--text-area__invalid-icon ${prefix}--text-area__invalid-icon--warning`
|
|
180
|
-
}), input, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
192
|
+
}), input, normalizedSlug, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
181
193
|
className: `${prefix}--text-area__counter-alert`,
|
|
182
194
|
role: "alert"
|
|
183
195
|
}, ariaAnnouncement), isFluid && /*#__PURE__*/React__default["default"].createElement("hr", {
|
|
@@ -263,6 +275,10 @@ TextArea.propTypes = {
|
|
|
263
275
|
* Specify the rows attribute for the `<textarea>`
|
|
264
276
|
*/
|
|
265
277
|
rows: PropTypes__default["default"].number,
|
|
278
|
+
/**
|
|
279
|
+
* Provide a `Slug` component to be rendered inside the `TextArea` component
|
|
280
|
+
*/
|
|
281
|
+
slug: PropTypes__default["default"].node,
|
|
266
282
|
/**
|
|
267
283
|
* Provide the current value of the `<textarea>`
|
|
268
284
|
*/
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
+
import { ReactNodeLike } from 'prop-types';
|
|
7
8
|
import React, { ReactNode } from 'react';
|
|
8
9
|
type ExcludedAttributes = 'defaultValue' | 'id' | 'size' | 'value';
|
|
9
10
|
export interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
|
|
@@ -85,6 +86,10 @@ export interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInput
|
|
|
85
86
|
* Specify the size of the Text Input. Currently supports the following:
|
|
86
87
|
*/
|
|
87
88
|
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
89
|
+
/**
|
|
90
|
+
* Provide a `Slug` component to be rendered inside the `TextInput` component
|
|
91
|
+
*/
|
|
92
|
+
slug?: ReactNodeLike;
|
|
88
93
|
/**
|
|
89
94
|
* Specify the type of the `<input>`
|
|
90
95
|
*/
|
|
@@ -52,6 +52,7 @@ const TextInput = /*#__PURE__*/React__default["default"].forwardRef(function Tex
|
|
|
52
52
|
warnText,
|
|
53
53
|
enableCounter = false,
|
|
54
54
|
maxCount,
|
|
55
|
+
slug,
|
|
55
56
|
...rest
|
|
56
57
|
} = _ref;
|
|
57
58
|
const prefix = usePrefix.usePrefix();
|
|
@@ -123,7 +124,8 @@ const TextInput = /*#__PURE__*/React__default["default"].forwardRef(function Tex
|
|
|
123
124
|
[`${prefix}--text-input__field-outer-wrapper--inline`]: inline
|
|
124
125
|
});
|
|
125
126
|
const fieldWrapperClasses = cx__default["default"](`${prefix}--text-input__field-wrapper`, {
|
|
126
|
-
[`${prefix}--text-input__field-wrapper--warning`]: normalizedProps.warn
|
|
127
|
+
[`${prefix}--text-input__field-wrapper--warning`]: normalizedProps.warn,
|
|
128
|
+
[`${prefix}--text-input__field-wrapper--slug`]: slug
|
|
127
129
|
});
|
|
128
130
|
const iconClasses = cx__default["default"]({
|
|
129
131
|
[`${prefix}--text-input__invalid-icon`]: normalizedProps.invalid || normalizedProps.warn,
|
|
@@ -162,6 +164,14 @@ const TextInput = /*#__PURE__*/React__default["default"].forwardRef(function Tex
|
|
|
162
164
|
} = React.useContext(FormContext.FormContext);
|
|
163
165
|
const ariaAnnouncement = useAnnouncer.useAnnouncer(textCount, maxCount);
|
|
164
166
|
const Icon = normalizedProps.icon;
|
|
167
|
+
|
|
168
|
+
// Slug is always size `mini`
|
|
169
|
+
let normalizedSlug;
|
|
170
|
+
if (slug) {
|
|
171
|
+
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
172
|
+
size: 'mini'
|
|
173
|
+
});
|
|
174
|
+
}
|
|
165
175
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
166
176
|
className: inputWrapperClasses
|
|
167
177
|
}, !inline ? labelWrapper : /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -173,7 +183,7 @@ const TextInput = /*#__PURE__*/React__default["default"].forwardRef(function Tex
|
|
|
173
183
|
"data-invalid": normalizedProps.invalid || null
|
|
174
184
|
}, Icon && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
175
185
|
className: iconClasses
|
|
176
|
-
}), input, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
186
|
+
}), input, normalizedSlug, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
177
187
|
className: `${prefix}--text-input__counter-alert`,
|
|
178
188
|
role: "alert"
|
|
179
189
|
}, ariaAnnouncement), isFluid && /*#__PURE__*/React__default["default"].createElement("hr", {
|
|
@@ -260,6 +270,10 @@ TextInput.propTypes = {
|
|
|
260
270
|
* Specify the size of the Text Input. Currently supports the following:
|
|
261
271
|
*/
|
|
262
272
|
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg']),
|
|
273
|
+
/**
|
|
274
|
+
* Provide a `Slug` component to be rendered inside the `TextInput` component
|
|
275
|
+
*/
|
|
276
|
+
slug: PropTypes__default["default"].node,
|
|
263
277
|
/**
|
|
264
278
|
* Specify the type of the `<input>`
|
|
265
279
|
*/
|
|
@@ -180,7 +180,7 @@ function SideNavRenderFunction(_ref, ref) {
|
|
|
180
180
|
tabIndex: -1,
|
|
181
181
|
ref: navRef,
|
|
182
182
|
className: `${prefix}--side-nav__navigation ${className}`,
|
|
183
|
-
inert: !isRail
|
|
183
|
+
inert: !isRail ? expanded || isLg ? undefined : -1 : undefined
|
|
184
184
|
}, accessibilityLabel, eventHandlers, other), childrenToRender));
|
|
185
185
|
}
|
|
186
186
|
const SideNav = /*#__PURE__*/React__default["default"].forwardRef(SideNavRenderFunction);
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
interface SideNavHeaderProps {
|
|
9
|
+
/**
|
|
10
|
+
* The child nodes to be rendered
|
|
11
|
+
*/
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Provide an optional class to be applied to the containing node
|
|
15
|
+
*/
|
|
16
|
+
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Property to indicate if the side nav container is open (or not). Use to
|
|
19
|
+
* keep local state and styling in step with the SideNav expansion state.
|
|
20
|
+
*/
|
|
21
|
+
isSideNavExpanded?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Provide an icon to render in the header of the side navigation. Should be
|
|
24
|
+
* a React class.
|
|
25
|
+
*/
|
|
26
|
+
renderIcon: React.ComponentType;
|
|
27
|
+
}
|
|
28
|
+
declare const SideNavHeader: React.FC<SideNavHeaderProps>;
|
|
29
|
+
export default SideNavHeader;
|
|
@@ -23,8 +23,8 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
23
23
|
|
|
24
24
|
const SideNavHeader = _ref => {
|
|
25
25
|
let {
|
|
26
|
-
className: customClassName,
|
|
27
26
|
children,
|
|
27
|
+
className: customClassName,
|
|
28
28
|
renderIcon: IconElement
|
|
29
29
|
} = _ref;
|
|
30
30
|
const prefix = usePrefix.usePrefix();
|
|
@@ -52,8 +52,8 @@ SideNavHeader.propTypes = {
|
|
|
52
52
|
* Provide an icon to render in the header of the side navigation. Should be
|
|
53
53
|
* a React class.
|
|
54
54
|
*/
|
|
55
|
+
// @ts-expect-error - PropTypes are unable to cover this case.
|
|
55
56
|
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]).isRequired
|
|
56
57
|
};
|
|
57
|
-
var SideNavHeader$1 = SideNavHeader;
|
|
58
58
|
|
|
59
|
-
exports["default"] = SideNavHeader
|
|
59
|
+
exports["default"] = SideNavHeader;
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
* Copyright IBM Corp. 2016, 2023
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/
|
|
13
|
+
import React, { ReactNode } from 'react';
|
|
14
|
+
interface BaseSwitcherProps {
|
|
15
|
+
/**
|
|
16
|
+
* expects to receive <SwitcherItem />
|
|
17
|
+
*/
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Optionally provide a custom class to apply to the underlying `<ul>` node
|
|
21
|
+
*/
|
|
22
|
+
className?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Specify whether the panel is expanded
|
|
25
|
+
*/
|
|
26
|
+
expanded?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface SwitcherWithAriaLabel extends BaseSwitcherProps {
|
|
29
|
+
'aria-label': string;
|
|
30
|
+
'aria-labelledby'?: never;
|
|
31
|
+
}
|
|
32
|
+
interface SwitcherWithAriaLabelledBy extends BaseSwitcherProps {
|
|
33
|
+
'aria-label'?: never;
|
|
34
|
+
'aria-labelledby': string;
|
|
35
|
+
}
|
|
36
|
+
type SwitcherProps = SwitcherWithAriaLabel | SwitcherWithAriaLabelledBy;
|
|
37
|
+
declare const Switcher: React.ForwardRefExoticComponent<SwitcherProps & React.RefAttributes<HTMLUListElement>>;
|
|
38
|
+
export default Switcher;
|
|
@@ -12,10 +12,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
12
12
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
13
|
var React = require('react');
|
|
14
14
|
var cx = require('classnames');
|
|
15
|
-
var PropTypes = require('prop-types');
|
|
16
|
-
var AriaPropTypes = require('../../prop-types/AriaPropTypes.js');
|
|
17
15
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
18
16
|
var useMergedRefs = require('../../internal/useMergedRefs.js');
|
|
17
|
+
var PropTypes = require('prop-types');
|
|
18
|
+
var AriaPropTypes = require('../../prop-types/AriaPropTypes.js');
|
|
19
|
+
var getDisplayName = require('../../prop-types/tools/getDisplayName.js');
|
|
19
20
|
|
|
20
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
22
|
|
|
@@ -23,7 +24,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
23
24
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
24
25
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
25
26
|
|
|
26
|
-
const Switcher = /*#__PURE__*/
|
|
27
|
+
const Switcher = /*#__PURE__*/React.forwardRef(function Switcher(props, forwardRef) {
|
|
27
28
|
const switcherRef = React.useRef(null);
|
|
28
29
|
const ref = useMergedRefs.useMergedRefs([switcherRef, forwardRef]);
|
|
29
30
|
const prefix = usePrefix.usePrefix();
|
|
@@ -39,7 +40,7 @@ const Switcher = /*#__PURE__*/React__default["default"].forwardRef(function Swit
|
|
|
39
40
|
'aria-labelledby': ariaLabelledBy
|
|
40
41
|
};
|
|
41
42
|
const className = cx__default["default"](`${prefix}--switcher`, {
|
|
42
|
-
[customClassName]: !!customClassName
|
|
43
|
+
[customClassName || '']: !!customClassName
|
|
43
44
|
});
|
|
44
45
|
const handleSwitcherItemFocus = _ref => {
|
|
45
46
|
let {
|
|
@@ -64,13 +65,14 @@ const Switcher = /*#__PURE__*/React__default["default"].forwardRef(function Swit
|
|
|
64
65
|
return enabledIndices[nextIndex];
|
|
65
66
|
}
|
|
66
67
|
})();
|
|
67
|
-
const switcherItem = switcherRef.current
|
|
68
|
-
switcherItem
|
|
68
|
+
const switcherItem = switcherRef.current?.children[nextValidIndex]?.children[0];
|
|
69
|
+
if (switcherItem) {
|
|
70
|
+
switcherItem.focus();
|
|
71
|
+
}
|
|
69
72
|
};
|
|
70
|
-
const childrenWithProps = React__default["default"].Children.
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
if (child.type?.displayName === 'SwitcherItem') {
|
|
73
|
+
const childrenWithProps = React__default["default"].Children.map(children, (child, index) => {
|
|
74
|
+
// only setup click handlers if onChange event is passed
|
|
75
|
+
if ( /*#__PURE__*/React__default["default"].isValidElement(child) && child.type && getDisplayName["default"](child.type) === 'Switcher') {
|
|
74
76
|
return /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
75
77
|
handleSwitcherItemFocus,
|
|
76
78
|
index,
|
|
@@ -108,6 +110,5 @@ Switcher.propTypes = {
|
|
|
108
110
|
*/
|
|
109
111
|
expanded: PropTypes__default["default"].bool
|
|
110
112
|
};
|
|
111
|
-
var Switcher$1 = Switcher;
|
|
112
113
|
|
|
113
|
-
exports["default"] = Switcher
|
|
114
|
+
exports["default"] = Switcher;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface SwitcherDividerProps {
|
|
3
|
+
/**
|
|
4
|
+
* Optionally provide a custom class to apply to the underlying `<li>` node
|
|
5
|
+
*/
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const SwitcherDivider: React.FC<SwitcherDividerProps>;
|
|
9
|
+
export default SwitcherDivider;
|
|
@@ -27,11 +27,11 @@ const SwitcherDivider = _ref => {
|
|
|
27
27
|
...other
|
|
28
28
|
} = _ref;
|
|
29
29
|
const prefix = usePrefix.usePrefix();
|
|
30
|
-
const
|
|
31
|
-
[customClassName]: !!customClassName
|
|
30
|
+
const classNames = cx__default["default"](`${prefix}--switcher__item--divider`, {
|
|
31
|
+
[customClassName || '']: !!customClassName
|
|
32
32
|
});
|
|
33
33
|
return /*#__PURE__*/React__default["default"].createElement("hr", _rollupPluginBabelHelpers["extends"]({}, other, {
|
|
34
|
-
className:
|
|
34
|
+
className: classNames
|
|
35
35
|
}));
|
|
36
36
|
};
|
|
37
37
|
SwitcherDivider.propTypes = {
|
|
@@ -40,6 +40,5 @@ SwitcherDivider.propTypes = {
|
|
|
40
40
|
*/
|
|
41
41
|
className: PropTypes__default["default"].string
|
|
42
42
|
};
|
|
43
|
-
var SwitcherDivider$1 = SwitcherDivider;
|
|
44
43
|
|
|
45
|
-
exports["default"] = SwitcherDivider
|
|
44
|
+
exports["default"] = SwitcherDivider;
|