@carbon/react 1.31.3 → 1.32.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/README.md +1 -1
- package/es/components/Accordion/Accordion.Skeleton.d.ts +64 -0
- package/es/components/Accordion/Accordion.Skeleton.js +3 -3
- package/es/components/Accordion/Accordion.d.ts +65 -0
- package/es/components/Accordion/Accordion.js +5 -6
- package/es/components/Accordion/AccordionItem.d.ts +105 -0
- package/es/components/Accordion/AccordionItem.js +12 -9
- package/es/components/Accordion/AccordionProvider.d.ts +20 -0
- package/es/components/Accordion/AccordionProvider.js +25 -0
- package/es/components/Accordion/index.d.ts +11 -0
- package/es/components/Button/Button.Skeleton.d.ts +28 -0
- package/es/components/Button/Button.Skeleton.js +5 -3
- package/es/components/Button/Button.d.ts +72 -0
- package/es/components/Button/Button.js +13 -10
- package/es/components/Button/index.d.ts +11 -0
- package/es/components/Button/index.js +2 -1
- package/es/components/ButtonSet/ButtonSet.d.ts +17 -0
- package/es/components/ButtonSet/ButtonSet.js +1 -2
- package/es/components/ButtonSet/index.d.ts +9 -0
- package/es/components/CodeSnippet/CodeSnippet.js +1 -0
- package/es/components/ComboButton/index.js +1 -0
- package/es/components/ComposedModal/ComposedModal.d.ts +70 -0
- package/es/components/ComposedModal/ComposedModal.js +58 -67
- package/es/components/ComposedModal/ModalFooter.d.ts +71 -0
- package/es/components/ComposedModal/ModalFooter.js +22 -19
- package/es/components/ComposedModal/ModalHeader.d.ts +58 -0
- package/es/components/ComposedModal/ModalHeader.js +8 -25
- package/es/components/ComposedModal/index.d.ts +9 -0
- package/es/components/ContainedList/ContainedList.js +12 -1
- package/es/components/ContentSwitcher/ContentSwitcher.d.ts +109 -0
- package/es/components/ContentSwitcher/ContentSwitcher.js +14 -6
- package/es/components/DangerButton/DangerButton.d.ts +9 -0
- package/es/components/DangerButton/DangerButton.js +2 -2
- package/es/components/DangerButton/index.d.ts +9 -0
- package/es/components/DataTable/TableBatchAction.js +1 -0
- package/es/components/DataTable/TableBatchActions.js +1 -0
- package/es/components/DataTable/TableBody.d.ts +29 -0
- package/es/components/DataTable/TableBody.js +2 -3
- package/es/components/DataTable/TableContainer.d.ts +51 -0
- package/es/components/DataTable/TableContainer.js +3 -4
- package/es/components/DataTable/TableExpandHeader.d.ts +86 -0
- package/es/components/DataTable/TableExpandHeader.js +4 -5
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +12 -16
- package/es/components/Dropdown/Dropdown.js +1 -0
- package/es/components/FluidTextInput/FluidTextInput.js +1 -0
- package/es/components/FormGroup/FormGroup.d.ts +80 -0
- package/es/components/IconButton/index.js +3 -2
- package/es/components/Layout/index.d.ts +74 -0
- package/es/components/Layout/index.js +14 -5
- package/es/components/Link/Link.d.ts +2 -2
- package/es/components/Link/Link.js +2 -1
- package/es/components/MenuButton/index.js +1 -0
- package/es/components/Modal/Modal.js +1 -0
- package/es/components/ModalWrapper/ModalWrapper.js +1 -0
- package/es/components/Notification/Notification.d.ts +531 -0
- package/es/components/Notification/Notification.js +40 -6
- package/es/components/Notification/index.d.ts +7 -0
- package/es/components/PrimaryButton/PrimaryButton.js +1 -0
- package/es/components/SecondaryButton/SecondaryButton.js +1 -0
- package/es/components/Select/Select.d.ts +1 -1
- package/es/components/SkeletonText/SkeletonText.d.ts +61 -0
- package/es/components/SkeletonText/SkeletonText.js +15 -17
- package/es/components/SkeletonText/index.d.ts +9 -0
- package/es/components/Switch/Switch.d.ts +56 -0
- package/es/components/Switch/Switch.js +4 -4
- package/es/components/Tab/index.d.ts +9 -0
- package/es/components/TabContent/TabContent.d.ts +40 -0
- package/es/components/TabContent/TabContent.js +6 -12
- package/es/components/TabContent/index.d.ts +10 -0
- package/es/components/Tabs/Tabs.Skeleton.d.ts +33 -0
- package/es/components/Tabs/Tabs.Skeleton.js +2 -2
- package/es/components/Tabs/Tabs.d.ts +311 -0
- package/es/components/Tabs/Tabs.js +151 -97
- package/es/components/Tabs/index.d.ts +10 -0
- package/es/components/Tabs/usePressable.js +11 -0
- package/es/components/TextInput/ControlledPasswordInput.d.ts +90 -0
- package/es/components/TextInput/ControlledPasswordInput.js +5 -6
- package/es/components/Tile/Tile.d.ts +153 -0
- package/es/components/Tile/Tile.js +62 -74
- package/es/components/Tile/index.d.ts +7 -0
- package/es/components/Toggle/Toggle.Skeleton.d.ts +3 -47
- package/es/components/Toggle/Toggle.Skeleton.js +24 -64
- package/es/components/Toggle/Toggle.js +1 -1
- package/es/components/UIShell/HeaderGlobalAction.js +1 -0
- package/es/components/UIShell/HeaderPanel.js +61 -5
- package/es/components/UIShell/SideNav.d.ts +1 -1
- package/es/components/UIShell/Switcher.js +45 -5
- package/es/components/UIShell/SwitcherItem.js +45 -6
- package/es/index.js +16 -16
- package/es/internal/keyboard/match.js +2 -2
- package/es/internal/useControllableState.js +2 -2
- package/es/internal/useMatchMedia.js +44 -0
- package/es/internal/wrapFocus.js +6 -6
- package/es/prop-types/requiredIfGivenPropIsTruthy.js +1 -1
- package/es/prop-types/types.js +3 -0
- package/lib/components/Accordion/Accordion.Skeleton.d.ts +64 -0
- package/lib/components/Accordion/Accordion.Skeleton.js +3 -3
- package/lib/components/Accordion/Accordion.d.ts +65 -0
- package/lib/components/Accordion/Accordion.js +5 -6
- package/lib/components/Accordion/AccordionItem.d.ts +105 -0
- package/lib/components/Accordion/AccordionItem.js +11 -8
- package/lib/components/Accordion/AccordionProvider.d.ts +20 -0
- package/lib/components/Accordion/AccordionProvider.js +34 -0
- package/lib/components/Accordion/index.d.ts +11 -0
- package/lib/components/Button/Button.Skeleton.d.ts +28 -0
- package/lib/components/Button/Button.Skeleton.js +5 -3
- package/lib/components/Button/Button.d.ts +72 -0
- package/lib/components/Button/Button.js +18 -11
- package/lib/components/Button/index.d.ts +11 -0
- package/lib/components/Button/index.js +6 -0
- package/lib/components/ButtonSet/ButtonSet.d.ts +17 -0
- package/lib/components/ButtonSet/ButtonSet.js +1 -2
- package/lib/components/ButtonSet/index.d.ts +9 -0
- package/lib/components/CodeSnippet/CodeSnippet.js +1 -0
- package/lib/components/ComboButton/index.js +1 -0
- package/lib/components/ComposedModal/ComposedModal.d.ts +70 -0
- package/lib/components/ComposedModal/ComposedModal.js +58 -67
- package/lib/components/ComposedModal/ModalFooter.d.ts +71 -0
- package/lib/components/ComposedModal/ModalFooter.js +22 -19
- package/lib/components/ComposedModal/ModalHeader.d.ts +58 -0
- package/lib/components/ComposedModal/ModalHeader.js +8 -25
- package/lib/components/ComposedModal/index.d.ts +9 -0
- package/lib/components/ContainedList/ContainedList.js +12 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +109 -0
- package/lib/components/ContentSwitcher/ContentSwitcher.js +14 -6
- package/lib/components/DangerButton/DangerButton.d.ts +9 -0
- package/lib/components/DangerButton/DangerButton.js +2 -2
- package/lib/components/DangerButton/index.d.ts +9 -0
- package/lib/components/DataTable/TableBatchAction.js +1 -0
- package/lib/components/DataTable/TableBatchActions.js +1 -0
- package/lib/components/DataTable/TableBody.d.ts +29 -0
- package/lib/components/DataTable/TableBody.js +3 -4
- package/lib/components/DataTable/TableContainer.d.ts +51 -0
- package/lib/components/DataTable/TableContainer.js +3 -4
- package/lib/components/DataTable/TableExpandHeader.d.ts +86 -0
- package/lib/components/DataTable/TableExpandHeader.js +4 -5
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +12 -16
- package/lib/components/Dropdown/Dropdown.js +1 -0
- package/lib/components/FluidTextInput/FluidTextInput.js +1 -0
- package/lib/components/FormGroup/FormGroup.d.ts +80 -0
- package/lib/components/IconButton/index.js +3 -2
- package/lib/components/Layout/index.d.ts +74 -0
- package/lib/components/Layout/index.js +14 -5
- package/lib/components/Link/Link.d.ts +2 -2
- package/lib/components/Link/Link.js +2 -1
- package/lib/components/MenuButton/index.js +1 -0
- package/lib/components/Modal/Modal.js +1 -0
- package/lib/components/ModalWrapper/ModalWrapper.js +1 -0
- package/lib/components/Notification/Notification.d.ts +531 -0
- package/lib/components/Notification/Notification.js +40 -6
- package/lib/components/Notification/index.d.ts +7 -0
- package/lib/components/PrimaryButton/PrimaryButton.js +1 -0
- package/lib/components/SecondaryButton/SecondaryButton.js +1 -0
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/SkeletonText/SkeletonText.d.ts +61 -0
- package/lib/components/SkeletonText/SkeletonText.js +15 -17
- package/lib/components/SkeletonText/index.d.ts +9 -0
- package/lib/components/Switch/Switch.d.ts +56 -0
- package/lib/components/Switch/Switch.js +4 -4
- package/lib/components/Tab/index.d.ts +9 -0
- package/lib/components/TabContent/TabContent.d.ts +40 -0
- package/lib/components/TabContent/TabContent.js +6 -12
- package/lib/components/TabContent/index.d.ts +10 -0
- package/lib/components/Tabs/Tabs.Skeleton.d.ts +33 -0
- package/lib/components/Tabs/Tabs.Skeleton.js +2 -2
- package/lib/components/Tabs/Tabs.d.ts +311 -0
- package/lib/components/Tabs/Tabs.js +150 -96
- package/lib/components/Tabs/index.d.ts +10 -0
- package/lib/components/Tabs/usePressable.js +11 -0
- package/lib/components/TextInput/ControlledPasswordInput.d.ts +90 -0
- package/lib/components/TextInput/ControlledPasswordInput.js +5 -6
- package/lib/components/Tile/Tile.d.ts +153 -0
- package/lib/components/Tile/Tile.js +62 -74
- package/lib/components/Tile/index.d.ts +7 -0
- package/lib/components/Toggle/Toggle.Skeleton.d.ts +3 -47
- package/lib/components/Toggle/Toggle.Skeleton.js +22 -62
- package/lib/components/Toggle/Toggle.js +1 -1
- package/lib/components/UIShell/HeaderGlobalAction.js +1 -0
- package/lib/components/UIShell/HeaderPanel.js +60 -4
- package/lib/components/UIShell/SideNav.d.ts +1 -1
- package/lib/components/UIShell/Switcher.js +44 -4
- package/lib/components/UIShell/SwitcherItem.js +45 -6
- package/lib/index.js +51 -47
- package/lib/internal/keyboard/match.js +2 -2
- package/lib/internal/useControllableState.js +2 -2
- package/lib/internal/useMatchMedia.js +48 -0
- package/lib/internal/wrapFocus.js +6 -6
- package/lib/prop-types/requiredIfGivenPropIsTruthy.js +1 -1
- package/lib/prop-types/types.js +3 -0
- package/package.json +4 -3
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import { ChevronLeft, ChevronRight, Close } from '@carbon/icons-react';
|
|
10
|
+
import { breakpoints } from '@carbon/layout';
|
|
10
11
|
import cx from 'classnames';
|
|
11
12
|
import debounce from 'lodash.debounce';
|
|
12
13
|
import PropTypes from 'prop-types';
|
|
13
|
-
import React__default, { useState, useRef, useCallback, useEffect } from 'react';
|
|
14
|
+
import React__default, { useState, useRef, useCallback, useEffect, forwardRef } from 'react';
|
|
15
|
+
import { isElement } from 'react-is';
|
|
14
16
|
import '../Tooltip/DefinitionTooltip.js';
|
|
15
17
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
16
18
|
import { useControllableState } from '../../internal/useControllableState.js';
|
|
@@ -23,19 +25,39 @@ import { usePrefix } from '../../internal/usePrefix.js';
|
|
|
23
25
|
import { usePressable } from './usePressable.js';
|
|
24
26
|
import deprecate from '../../prop-types/deprecate.js';
|
|
25
27
|
import { useEvent } from '../../internal/useEvent.js';
|
|
28
|
+
import { useMatchMedia } from '../../internal/useMatchMedia.js';
|
|
26
29
|
import { matches, match } from '../../internal/keyboard/match.js';
|
|
27
30
|
import { ArrowRight, ArrowLeft, Home, End, Delete } from '../../internal/keyboard/keys.js';
|
|
28
31
|
|
|
29
32
|
var _ChevronLeft, _ChevronRight, _Close;
|
|
30
33
|
|
|
31
34
|
// Used to manage the overall state of the Tabs
|
|
32
|
-
|
|
35
|
+
|
|
36
|
+
const TabsContext = /*#__PURE__*/React__default.createContext({
|
|
37
|
+
baseId: '',
|
|
38
|
+
activeIndex: 0,
|
|
39
|
+
defaultSelectedIndex: 0,
|
|
40
|
+
dismissable: false,
|
|
41
|
+
onTabCloseRequest() {},
|
|
42
|
+
setActiveIndex() {},
|
|
43
|
+
selectedIndex: 0,
|
|
44
|
+
setSelectedIndex() {}
|
|
45
|
+
});
|
|
33
46
|
|
|
34
47
|
// Used to keep track of position in a tablist
|
|
35
|
-
const TabContext = /*#__PURE__*/React__default.createContext(
|
|
48
|
+
const TabContext = /*#__PURE__*/React__default.createContext({
|
|
49
|
+
index: 0,
|
|
50
|
+
hasSecondaryLabel: false
|
|
51
|
+
});
|
|
52
|
+
const lgMediaQuery = `(min-width: ${breakpoints.lg.width})`;
|
|
36
53
|
|
|
37
54
|
// Used to keep track of position in a list of tab panels
|
|
38
|
-
const TabPanelContext = /*#__PURE__*/React__default.createContext();
|
|
55
|
+
const TabPanelContext = /*#__PURE__*/React__default.createContext(0);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Tabs
|
|
59
|
+
*/
|
|
60
|
+
|
|
39
61
|
function Tabs(_ref) {
|
|
40
62
|
let {
|
|
41
63
|
children,
|
|
@@ -52,13 +74,9 @@ function Tabs(_ref) {
|
|
|
52
74
|
const [selectedIndex, setSelectedIndex] = useControllableState({
|
|
53
75
|
value: controlledSelectedIndex,
|
|
54
76
|
defaultValue: defaultSelectedIndex,
|
|
55
|
-
onChange: value => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
selectedIndex: value
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
77
|
+
onChange: value => onChange?.({
|
|
78
|
+
selectedIndex: value
|
|
79
|
+
})
|
|
62
80
|
});
|
|
63
81
|
const value = {
|
|
64
82
|
baseId,
|
|
@@ -76,7 +94,7 @@ function Tabs(_ref) {
|
|
|
76
94
|
}
|
|
77
95
|
Tabs.propTypes = {
|
|
78
96
|
/**
|
|
79
|
-
* Provide child elements to be rendered inside
|
|
97
|
+
* Provide child elements to be rendered inside the `Tabs`.
|
|
80
98
|
* These elements should render either `TabsList` or `TabsPanels`
|
|
81
99
|
*/
|
|
82
100
|
children: PropTypes.node,
|
|
@@ -112,24 +130,28 @@ Tabs.propTypes = {
|
|
|
112
130
|
};
|
|
113
131
|
|
|
114
132
|
/**
|
|
115
|
-
* Get the next index for a given keyboard event
|
|
116
|
-
* items and the current index
|
|
117
|
-
* @param {Event} event
|
|
118
|
-
* @param {number} total
|
|
119
|
-
* @param {number} index
|
|
120
|
-
* @returns {number}
|
|
133
|
+
* Get the next index for a given keyboard event
|
|
134
|
+
* given a count of the total items and the current index
|
|
121
135
|
*/
|
|
122
136
|
function getNextIndex(event, total, index) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
137
|
+
switch (true) {
|
|
138
|
+
case match(event, ArrowRight):
|
|
139
|
+
return (index + 1) % total;
|
|
140
|
+
case match(event, ArrowLeft):
|
|
141
|
+
return (total + index - 1) % total;
|
|
142
|
+
case match(event, Home):
|
|
143
|
+
return 0;
|
|
144
|
+
case match(event, End):
|
|
145
|
+
return total - 1;
|
|
146
|
+
default:
|
|
147
|
+
return index;
|
|
131
148
|
}
|
|
132
149
|
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* TabList
|
|
153
|
+
*/
|
|
154
|
+
|
|
133
155
|
function TabList(_ref2) {
|
|
134
156
|
let {
|
|
135
157
|
activation = 'automatic',
|
|
@@ -137,6 +159,7 @@ function TabList(_ref2) {
|
|
|
137
159
|
children,
|
|
138
160
|
className: customClassName,
|
|
139
161
|
contained = false,
|
|
162
|
+
fullWidth = false,
|
|
140
163
|
iconSize,
|
|
141
164
|
leftOverflowButtonProps,
|
|
142
165
|
light,
|
|
@@ -157,7 +180,23 @@ function TabList(_ref2) {
|
|
|
157
180
|
const previousButton = useRef(null);
|
|
158
181
|
const nextButton = useRef(null);
|
|
159
182
|
const [isScrollable, setIsScrollable] = useState(false);
|
|
160
|
-
const [scrollLeft, setScrollLeft] = useState(
|
|
183
|
+
const [scrollLeft, setScrollLeft] = useState(0);
|
|
184
|
+
let hasSecondaryLabelTabs = false;
|
|
185
|
+
if (contained) {
|
|
186
|
+
hasSecondaryLabelTabs = React__default.Children.toArray(children).some(child => {
|
|
187
|
+
return isElement(child) && !!child.props.secondaryLabel;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
const isLg = useMatchMedia(lgMediaQuery);
|
|
191
|
+
const distributeWidth = fullWidth && contained && isLg && React__default.Children.toArray(children).length < 9;
|
|
192
|
+
const className = cx(`${prefix}--tabs`, {
|
|
193
|
+
[`${prefix}--tabs--contained`]: contained,
|
|
194
|
+
[`${prefix}--tabs--light`]: light,
|
|
195
|
+
[`${prefix}--tabs__icon--default`]: iconSize === 'default',
|
|
196
|
+
[`${prefix}--tabs__icon--lg`]: iconSize === 'lg',
|
|
197
|
+
[`${prefix}--tabs--tall`]: hasSecondaryLabelTabs,
|
|
198
|
+
[`${prefix}--tabs--full-width`]: distributeWidth
|
|
199
|
+
}, customClassName);
|
|
161
200
|
|
|
162
201
|
// Previous Button
|
|
163
202
|
// VISIBLE IF:
|
|
@@ -169,14 +208,6 @@ function TabList(_ref2) {
|
|
|
169
208
|
// SCROLLABLE
|
|
170
209
|
// AND SCROLL_LEFT + CLIENT_WIDTH < SCROLL_WIDTH
|
|
171
210
|
const [isNextButtonVisible, setIsNextButtonVisible] = useState(ref.current ? scrollLeft + buttonWidth + ref.current.clientWidth < ref.current.scrollWidth : false);
|
|
172
|
-
const hasSecondaryLabelTabs = contained && !!React__default.Children.toArray(children).filter(child => child.props.secondaryLabel).length;
|
|
173
|
-
const className = cx(`${prefix}--tabs`, customClassName, {
|
|
174
|
-
[`${prefix}--tabs--contained`]: contained,
|
|
175
|
-
[`${prefix}--tabs--light`]: light,
|
|
176
|
-
[`${prefix}--tabs__icon--default`]: iconSize === 'default',
|
|
177
|
-
[`${prefix}--tabs__icon--lg`]: iconSize === 'lg',
|
|
178
|
-
[`${prefix}--tabs--tall`]: hasSecondaryLabelTabs
|
|
179
|
-
});
|
|
180
211
|
const isPreviousButtonVisible = ref.current ? isScrollable && scrollLeft > 0 : false;
|
|
181
212
|
const previousButtonClasses = cx(`${prefix}--tab--overflow-nav-button`, `${prefix}--tab--overflow-nav-button--previous`, {
|
|
182
213
|
[`${prefix}--tab--overflow-nav-button--hidden`]: !isPreviousButtonVisible
|
|
@@ -193,9 +224,7 @@ function TabList(_ref2) {
|
|
|
193
224
|
function onKeyDown(event) {
|
|
194
225
|
if (matches(event, [ArrowRight, ArrowLeft, Home, End])) {
|
|
195
226
|
event.preventDefault();
|
|
196
|
-
const activeTabs = tabs.current.filter(tab =>
|
|
197
|
-
return !tab.disabled;
|
|
198
|
-
});
|
|
227
|
+
const activeTabs = tabs.current.filter(tab => !tab.disabled);
|
|
199
228
|
const currentIndex = activeTabs.indexOf(tabs.current[activation === 'automatic' ? selectedIndex : activeIndex]);
|
|
200
229
|
const nextIndex = tabs.current.indexOf(activeTabs[getNextIndex(event, activeTabs.length, currentIndex)]);
|
|
201
230
|
if (activation === 'automatic') {
|
|
@@ -203,7 +232,7 @@ function TabList(_ref2) {
|
|
|
203
232
|
} else if (activation === 'manual') {
|
|
204
233
|
setActiveIndex(nextIndex);
|
|
205
234
|
}
|
|
206
|
-
tabs.current[nextIndex]
|
|
235
|
+
tabs.current[nextIndex]?.focus();
|
|
207
236
|
}
|
|
208
237
|
}
|
|
209
238
|
useEffectOnce(() => {
|
|
@@ -253,12 +282,12 @@ function TabList(_ref2) {
|
|
|
253
282
|
|
|
254
283
|
// updates scroll location for all scroll behavior.
|
|
255
284
|
useIsomorphicEffect(() => {
|
|
256
|
-
if (scrollLeft !== null) {
|
|
285
|
+
if (scrollLeft !== null && ref.current) {
|
|
257
286
|
ref.current.scrollLeft = scrollLeft;
|
|
258
287
|
}
|
|
259
288
|
}, [scrollLeft]);
|
|
260
289
|
useIsomorphicEffect(() => {
|
|
261
|
-
if (!isScrollable) {
|
|
290
|
+
if (!isScrollable || !ref.current) {
|
|
262
291
|
return;
|
|
263
292
|
}
|
|
264
293
|
const tab = activation === 'manual' ? tabs.current[activeIndex] : tabs.current[selectedIndex];
|
|
@@ -292,7 +321,7 @@ function TabList(_ref2) {
|
|
|
292
321
|
let {
|
|
293
322
|
longPress
|
|
294
323
|
} = _ref3;
|
|
295
|
-
if (!longPress) {
|
|
324
|
+
if (!longPress && ref.current) {
|
|
296
325
|
setScrollLeft(Math.max(scrollLeft - ref.current.scrollWidth / tabs.current.length * 1.5, 0));
|
|
297
326
|
}
|
|
298
327
|
},
|
|
@@ -305,7 +334,7 @@ function TabList(_ref2) {
|
|
|
305
334
|
let {
|
|
306
335
|
longPress
|
|
307
336
|
} = _ref4;
|
|
308
|
-
if (!longPress) {
|
|
337
|
+
if (!longPress && ref.current) {
|
|
309
338
|
setScrollLeft(Math.min(scrollLeft + ref.current.scrollWidth / tabs.current.length * 1.5, ref.current.scrollWidth - ref.current.clientWidth));
|
|
310
339
|
}
|
|
311
340
|
},
|
|
@@ -317,7 +346,7 @@ function TabList(_ref2) {
|
|
|
317
346
|
className: className
|
|
318
347
|
}, /*#__PURE__*/React__default.createElement("button", _extends({
|
|
319
348
|
"aria-hidden": "true",
|
|
320
|
-
tabIndex:
|
|
349
|
+
tabIndex: -1,
|
|
321
350
|
"aria-label": "Scroll left",
|
|
322
351
|
ref: previousButton,
|
|
323
352
|
className: previousButtonClasses,
|
|
@@ -330,7 +359,7 @@ function TabList(_ref2) {
|
|
|
330
359
|
onScroll: debouncedOnScroll,
|
|
331
360
|
onKeyDown: onKeyDown
|
|
332
361
|
}), React__default.Children.map(children, (child, index) => {
|
|
333
|
-
return /*#__PURE__*/React__default.createElement(TabContext.Provider, {
|
|
362
|
+
return !isElement(child) ? null : /*#__PURE__*/React__default.createElement(TabContext.Provider, {
|
|
334
363
|
value: {
|
|
335
364
|
index,
|
|
336
365
|
hasSecondaryLabel: hasSecondaryLabelTabs,
|
|
@@ -343,7 +372,7 @@ function TabList(_ref2) {
|
|
|
343
372
|
}));
|
|
344
373
|
})), /*#__PURE__*/React__default.createElement("button", _extends({
|
|
345
374
|
"aria-hidden": "true",
|
|
346
|
-
tabIndex:
|
|
375
|
+
tabIndex: -1,
|
|
347
376
|
"aria-label": "Scroll right",
|
|
348
377
|
ref: nextButton,
|
|
349
378
|
className: nextButtonClasses,
|
|
@@ -362,7 +391,7 @@ TabList.propTypes = {
|
|
|
362
391
|
*/
|
|
363
392
|
'aria-label': PropTypes.string.isRequired,
|
|
364
393
|
/**
|
|
365
|
-
* Provide child elements to be rendered inside
|
|
394
|
+
* Provide child elements to be rendered inside `ContentTabs`.
|
|
366
395
|
* These elements should render a `ContentTab`
|
|
367
396
|
*/
|
|
368
397
|
children: PropTypes.node,
|
|
@@ -374,6 +403,10 @@ TabList.propTypes = {
|
|
|
374
403
|
* Specify whether component is contained type
|
|
375
404
|
*/
|
|
376
405
|
contained: PropTypes.bool,
|
|
406
|
+
/**
|
|
407
|
+
* Used for tabs within a grid, this makes it so tabs span the full container width and have the same width. Only available on contained tabs with <9 children
|
|
408
|
+
*/
|
|
409
|
+
fullWidth: PropTypes.bool,
|
|
377
410
|
/**
|
|
378
411
|
* If using `IconTab`, specify the size of the icon being used.
|
|
379
412
|
*/
|
|
@@ -383,7 +416,7 @@ TabList.propTypes = {
|
|
|
383
416
|
*/
|
|
384
417
|
leftOverflowButtonProps: PropTypes.object,
|
|
385
418
|
/**
|
|
386
|
-
* Specify whether
|
|
419
|
+
* Specify whether to use the light component variant
|
|
387
420
|
*/
|
|
388
421
|
light: deprecate(PropTypes.bool, 'The `light` prop for `TabList` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
|
|
389
422
|
/**
|
|
@@ -397,53 +430,60 @@ TabList.propTypes = {
|
|
|
397
430
|
*/
|
|
398
431
|
scrollDebounceWait: PropTypes.number,
|
|
399
432
|
/**
|
|
400
|
-
* Choose whether
|
|
401
|
-
* on component rerender
|
|
433
|
+
* Choose whether to automatically scroll
|
|
434
|
+
* to newly selected tabs on component rerender
|
|
402
435
|
*/
|
|
403
436
|
scrollIntoView: PropTypes.bool
|
|
404
437
|
};
|
|
405
438
|
|
|
406
439
|
/**
|
|
407
|
-
* Helper function to
|
|
408
|
-
* function will take a ref to the tablist, a direction, and a setter
|
|
409
|
-
* scrollLeft and will update the scroll position within a
|
|
410
|
-
* requestAnimationFrame.
|
|
411
|
-
*
|
|
412
|
-
* It returns a cleanup function to be run when the long press is
|
|
413
|
-
* deactivated
|
|
440
|
+
* Helper function to set up the behavior when a button is "long pressed".
|
|
441
|
+
* This function will take a ref to the tablist, a direction, and a setter
|
|
442
|
+
* for scrollLeft and will update the scroll position within a requestAnimationFrame.
|
|
414
443
|
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
* @param {Function} setScrollLeft
|
|
418
|
-
* @returns {Function}
|
|
444
|
+
* It returns a cleanup function to be run
|
|
445
|
+
* when the long press is deactivated
|
|
419
446
|
*/
|
|
420
447
|
function createLongPressBehavior(ref, direction, setScrollLeft) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
448
|
+
const node = ref.current;
|
|
449
|
+
if (!node) {
|
|
450
|
+
return () => {};
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// We manually override the scroll behavior to be "auto".
|
|
454
|
+
// If it is set as smooth, this animation does not update correctly
|
|
455
|
+
const defaultScrollBehavior = node?.style['scroll-behavior'];
|
|
456
|
+
node.style['scroll-behavior'] = 'auto';
|
|
425
457
|
const scrollDelta = direction === 'forward' ? 5 : -5;
|
|
426
458
|
let frameId = null;
|
|
427
459
|
function tick() {
|
|
428
|
-
|
|
460
|
+
if (!node) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
node.scrollLeft = node.scrollLeft + scrollDelta;
|
|
429
464
|
frameId = requestAnimationFrame(tick);
|
|
430
465
|
}
|
|
431
466
|
frameId = requestAnimationFrame(tick);
|
|
432
467
|
return () => {
|
|
433
468
|
// Restore the previous scroll behavior
|
|
434
|
-
|
|
469
|
+
node.style['scroll-behavior'] = defaultScrollBehavior;
|
|
435
470
|
|
|
436
471
|
// Make sure that our `scrollLeft` value is in sync with the existing
|
|
437
472
|
// `ref` after our requestAnimationFrame loop above
|
|
438
|
-
setScrollLeft(
|
|
473
|
+
setScrollLeft(node.scrollLeft);
|
|
439
474
|
if (frameId) {
|
|
440
475
|
cancelAnimationFrame(frameId);
|
|
441
476
|
}
|
|
442
477
|
};
|
|
443
478
|
}
|
|
444
|
-
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Tab
|
|
482
|
+
*/
|
|
483
|
+
|
|
484
|
+
const Tab = /*#__PURE__*/forwardRef(function Tab(_ref5, forwardRef) {
|
|
445
485
|
let {
|
|
446
|
-
as
|
|
486
|
+
as = 'button',
|
|
447
487
|
children,
|
|
448
488
|
className: customClassName,
|
|
449
489
|
disabled,
|
|
@@ -472,20 +512,21 @@ const Tab = /*#__PURE__*/React__default.forwardRef(function Tab(_ref5, forwardRe
|
|
|
472
512
|
const [ignoreHover, setIgnoreHover] = useState(false);
|
|
473
513
|
const id = `${baseId}-tab-${index}`;
|
|
474
514
|
const panelId = `${baseId}-tabpanel-${index}`;
|
|
475
|
-
const className = cx(`${prefix}--tabs__nav-item`, `${prefix}--tabs__nav-link`,
|
|
515
|
+
const className = cx(`${prefix}--tabs__nav-item`, `${prefix}--tabs__nav-link`, {
|
|
476
516
|
[`${prefix}--tabs__nav-item--selected`]: selectedIndex === index,
|
|
477
517
|
[`${prefix}--tabs__nav-item--disabled`]: disabled,
|
|
478
518
|
[`${prefix}--tabs__nav-item--hover-off`]: ignoreHover
|
|
479
|
-
});
|
|
519
|
+
}, customClassName);
|
|
520
|
+
const BaseComponent = as;
|
|
480
521
|
const onDismissIconMouseEnter = evt => {
|
|
481
|
-
if (contained) {
|
|
522
|
+
if (contained && tabRef.current) {
|
|
482
523
|
evt.stopPropagation();
|
|
483
524
|
setIgnoreHover(true);
|
|
484
525
|
tabRef.current.classList.add(`${prefix}--tabs__nav-item--hover-off`);
|
|
485
526
|
}
|
|
486
527
|
};
|
|
487
528
|
const onDismissIconMouseLeave = () => {
|
|
488
|
-
if (contained) {
|
|
529
|
+
if (contained && tabRef.current) {
|
|
489
530
|
tabRef.current.classList.remove(`${prefix}--tabs__nav-item--hover-off`);
|
|
490
531
|
setIgnoreHover(false);
|
|
491
532
|
}
|
|
@@ -517,7 +558,7 @@ const Tab = /*#__PURE__*/React__default.forwardRef(function Tab(_ref5, forwardRe
|
|
|
517
558
|
title: "Close tab",
|
|
518
559
|
ref: dismissIconRef
|
|
519
560
|
}, _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, null)));
|
|
520
|
-
const hasIcon = Icon
|
|
561
|
+
const hasIcon = Icon ?? dismissable;
|
|
521
562
|
return /*#__PURE__*/React__default.createElement(BaseComponent, _extends({}, rest, {
|
|
522
563
|
"aria-controls": panelId,
|
|
523
564
|
"aria-disabled": disabled,
|
|
@@ -532,9 +573,7 @@ const Tab = /*#__PURE__*/React__default.forwardRef(function Tab(_ref5, forwardRe
|
|
|
532
573
|
return;
|
|
533
574
|
}
|
|
534
575
|
setSelectedIndex(index);
|
|
535
|
-
|
|
536
|
-
onClick(evt);
|
|
537
|
-
}
|
|
576
|
+
onClick?.(evt);
|
|
538
577
|
},
|
|
539
578
|
onKeyDown: handleKeyDown,
|
|
540
579
|
tabIndex: selectedIndex === index ? '0' : '-1',
|
|
@@ -546,24 +585,27 @@ const Tab = /*#__PURE__*/React__default.forwardRef(function Tab(_ref5, forwardRe
|
|
|
546
585
|
}, /*#__PURE__*/React__default.createElement(Icon, {
|
|
547
586
|
size: 16
|
|
548
587
|
})), /*#__PURE__*/React__default.createElement("span", {
|
|
549
|
-
className: `${prefix}--tabs__nav-item-label
|
|
588
|
+
className: `${prefix}--tabs__nav-item-label`,
|
|
589
|
+
title: children
|
|
550
590
|
}, children), /*#__PURE__*/React__default.createElement("div", {
|
|
551
591
|
className: cx(`${prefix}--tabs__nav-item--icon`, {
|
|
552
592
|
[`${prefix}--visually-hidden`]: !hasIcon
|
|
553
593
|
})
|
|
554
|
-
}, DismissIcon, !dismissable &&
|
|
594
|
+
}, DismissIcon, !dismissable && Icon && /*#__PURE__*/React__default.createElement(Icon, {
|
|
555
595
|
size: 16
|
|
556
596
|
}))), hasSecondaryLabel && /*#__PURE__*/React__default.createElement("div", {
|
|
557
|
-
className: `${prefix}--tabs__nav-item-secondary-label
|
|
597
|
+
className: `${prefix}--tabs__nav-item-secondary-label`,
|
|
598
|
+
title: secondaryLabel
|
|
558
599
|
}, secondaryLabel));
|
|
559
600
|
});
|
|
560
601
|
Tab.propTypes = {
|
|
561
602
|
/**
|
|
562
603
|
* Provide a custom element to render instead of the default button
|
|
563
604
|
*/
|
|
605
|
+
// @ts-expect-error: Invalid prop type derivation
|
|
564
606
|
as: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
|
|
565
607
|
/**
|
|
566
|
-
* Provide child elements to be rendered inside
|
|
608
|
+
* Provide child elements to be rendered inside `Tab`.
|
|
567
609
|
*/
|
|
568
610
|
children: PropTypes.node,
|
|
569
611
|
/**
|
|
@@ -592,6 +634,7 @@ Tab.propTypes = {
|
|
|
592
634
|
* Optional prop to render an icon next to the label.
|
|
593
635
|
* Can be a React component class
|
|
594
636
|
*/
|
|
637
|
+
// @ts-expect-error: Invalid prop type derivation
|
|
595
638
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
596
639
|
/*
|
|
597
640
|
* An optional label to render under the primary tab label.
|
|
@@ -599,6 +642,11 @@ Tab.propTypes = {
|
|
|
599
642
|
**/
|
|
600
643
|
secondaryLabel: PropTypes.string
|
|
601
644
|
};
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* IconTab
|
|
648
|
+
*/
|
|
649
|
+
|
|
602
650
|
const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref6, ref) {
|
|
603
651
|
let {
|
|
604
652
|
children,
|
|
@@ -625,7 +673,7 @@ const IconTab = /*#__PURE__*/React__default.forwardRef(function IconTab(_ref6, r
|
|
|
625
673
|
});
|
|
626
674
|
IconTab.propTypes = {
|
|
627
675
|
/**
|
|
628
|
-
* Provide an icon to be rendered inside
|
|
676
|
+
* Provide an icon to be rendered inside `IconTab` as the visual label for Tab.
|
|
629
677
|
*/
|
|
630
678
|
children: PropTypes.node,
|
|
631
679
|
/**
|
|
@@ -641,7 +689,7 @@ IconTab.propTypes = {
|
|
|
641
689
|
*/
|
|
642
690
|
enterDelayMs: PropTypes.number,
|
|
643
691
|
/**
|
|
644
|
-
* Provide the label to be rendered inside
|
|
692
|
+
* Provide the label to be rendered inside the Tooltip. The label will use
|
|
645
693
|
* `aria-labelledby` and will fully describe the child node that is provided.
|
|
646
694
|
* This means that if you have text in the child node it will not be
|
|
647
695
|
* announced to the screen reader.
|
|
@@ -652,6 +700,11 @@ IconTab.propTypes = {
|
|
|
652
700
|
*/
|
|
653
701
|
leaveDelayMs: PropTypes.number
|
|
654
702
|
};
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* TabPanel
|
|
706
|
+
*/
|
|
707
|
+
|
|
655
708
|
const TabPanel = /*#__PURE__*/React__default.forwardRef(function TabPanel(_ref7, forwardRef) {
|
|
656
709
|
let {
|
|
657
710
|
children,
|
|
@@ -661,7 +714,7 @@ const TabPanel = /*#__PURE__*/React__default.forwardRef(function TabPanel(_ref7,
|
|
|
661
714
|
const prefix = usePrefix();
|
|
662
715
|
const panel = useRef(null);
|
|
663
716
|
const ref = useMergedRefs([forwardRef, panel]);
|
|
664
|
-
const [tabIndex, setTabIndex] = useState(
|
|
717
|
+
const [tabIndex, setTabIndex] = useState(0);
|
|
665
718
|
const [interactiveContent, setInteractiveContent] = useState(false);
|
|
666
719
|
const {
|
|
667
720
|
selectedIndex,
|
|
@@ -680,26 +733,24 @@ const TabPanel = /*#__PURE__*/React__default.forwardRef(function TabPanel(_ref7,
|
|
|
680
733
|
const content = getInteractiveContent(panel.current);
|
|
681
734
|
if (content) {
|
|
682
735
|
setInteractiveContent(true);
|
|
683
|
-
setTabIndex(
|
|
736
|
+
setTabIndex(-1);
|
|
684
737
|
}
|
|
685
738
|
});
|
|
686
739
|
|
|
687
740
|
// tabindex should only be 0 if no interactive content in children
|
|
688
741
|
useEffect(() => {
|
|
689
|
-
|
|
742
|
+
const node = panel.current;
|
|
743
|
+
if (!node) {
|
|
690
744
|
return;
|
|
691
745
|
}
|
|
692
|
-
const {
|
|
693
|
-
current: node
|
|
694
|
-
} = panel;
|
|
695
746
|
function callback() {
|
|
696
747
|
const content = getInteractiveContent(node);
|
|
697
748
|
if (content) {
|
|
698
749
|
setInteractiveContent(true);
|
|
699
|
-
setTabIndex(
|
|
750
|
+
setTabIndex(-1);
|
|
700
751
|
} else {
|
|
701
752
|
setInteractiveContent(false);
|
|
702
|
-
setTabIndex(
|
|
753
|
+
setTabIndex(0);
|
|
703
754
|
}
|
|
704
755
|
}
|
|
705
756
|
const observer = new MutationObserver(callback);
|
|
@@ -707,9 +758,7 @@ const TabPanel = /*#__PURE__*/React__default.forwardRef(function TabPanel(_ref7,
|
|
|
707
758
|
childList: true,
|
|
708
759
|
subtree: true
|
|
709
760
|
});
|
|
710
|
-
return () =>
|
|
711
|
-
observer.disconnect(node);
|
|
712
|
-
};
|
|
761
|
+
return () => observer.disconnect();
|
|
713
762
|
}, []);
|
|
714
763
|
return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
|
715
764
|
"aria-labelledby": tabId,
|
|
@@ -723,7 +772,7 @@ const TabPanel = /*#__PURE__*/React__default.forwardRef(function TabPanel(_ref7,
|
|
|
723
772
|
});
|
|
724
773
|
TabPanel.propTypes = {
|
|
725
774
|
/**
|
|
726
|
-
* Provide child elements to be rendered inside
|
|
775
|
+
* Provide child elements to be rendered inside `TabPanel`.
|
|
727
776
|
*/
|
|
728
777
|
children: PropTypes.node,
|
|
729
778
|
/**
|
|
@@ -731,6 +780,11 @@ TabPanel.propTypes = {
|
|
|
731
780
|
*/
|
|
732
781
|
className: PropTypes.string
|
|
733
782
|
};
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* TabPanels
|
|
786
|
+
*/
|
|
787
|
+
|
|
734
788
|
function TabPanels(_ref8) {
|
|
735
789
|
let {
|
|
736
790
|
children
|
|
@@ -743,7 +797,7 @@ function TabPanels(_ref8) {
|
|
|
743
797
|
}
|
|
744
798
|
TabPanels.propTypes = {
|
|
745
799
|
/**
|
|
746
|
-
* Provide child elements to be rendered inside
|
|
800
|
+
* Provide child elements to be rendered inside `TabPanels`.
|
|
747
801
|
*/
|
|
748
802
|
children: PropTypes.node
|
|
749
803
|
};
|
|
@@ -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 { Tabs } from './Tabs';
|
|
8
|
+
export default Tabs;
|
|
9
|
+
export { default as TabsSkeleton } from './Tabs.Skeleton';
|
|
10
|
+
export { TabPanels, type TabPanelsProps, TabPanel, type TabPanelProps, TabList, type TabListProps, IconTab, type IconTabProps, Tabs, type TabsProps, } from './Tabs';
|
|
@@ -7,6 +7,17 @@
|
|
|
7
7
|
|
|
8
8
|
import { useRef, useState, useEffect } from 'react';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @param {React.RefObject<HTMLElement>} ref
|
|
12
|
+
*
|
|
13
|
+
* @param {{
|
|
14
|
+
* onPress?(state: { longPress: boolean }): void,
|
|
15
|
+
* onPressIn?(): void,
|
|
16
|
+
* onPressOut?(): void,
|
|
17
|
+
* onLongPress?(): void,
|
|
18
|
+
* delayLongPressMs?: number,
|
|
19
|
+
* }} options
|
|
20
|
+
*/
|
|
10
21
|
function usePressable(ref) {
|
|
11
22
|
let {
|
|
12
23
|
onPress,
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ReactAttr } from '../../types/common';
|
|
3
|
+
export interface ControlledPasswordInputProps extends ReactAttr<HTMLInputElement> {
|
|
4
|
+
/**
|
|
5
|
+
* Provide a custom className that is applied directly to the underlying
|
|
6
|
+
* `<input>` node
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Optionally provide the default value of the `<input>`
|
|
11
|
+
*/
|
|
12
|
+
defaultValue?: string | number;
|
|
13
|
+
/**
|
|
14
|
+
* Specify whether the control is disabled
|
|
15
|
+
*/
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Provide text that is used alongside the control label for additional help
|
|
19
|
+
*/
|
|
20
|
+
helperText?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Specify whether or not the underlying label is visually hidden
|
|
23
|
+
*/
|
|
24
|
+
hideLabel?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* "Hide password" tooltip text on password visibility toggle
|
|
27
|
+
*/
|
|
28
|
+
hidePasswordLabel?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Provide a unique identifier for the input field
|
|
31
|
+
*/
|
|
32
|
+
id: string;
|
|
33
|
+
/**
|
|
34
|
+
* Specify whether the control is currently invalid
|
|
35
|
+
*/
|
|
36
|
+
invalid?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Provide the text that is displayed when the control is in an invalid state
|
|
39
|
+
*/
|
|
40
|
+
invalidText?: React.ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* Provide the text that will be read by a screen reader when visiting this
|
|
43
|
+
* control
|
|
44
|
+
*/
|
|
45
|
+
labelText: React.ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated The `light` prop for `ControlledPasswordInput` has been deprecated in favor of the new `Layer` component. It will be removed in the next major release.
|
|
48
|
+
*/
|
|
49
|
+
light?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Optionally provide an `onChange` handler that is called whenever `<input>`
|
|
52
|
+
* is updated
|
|
53
|
+
*/
|
|
54
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Optionally provide an `onClick` handler that is called whenever the
|
|
57
|
+
* `<input>` is clicked
|
|
58
|
+
*/
|
|
59
|
+
onClick?: (event: React.MouseEvent<HTMLInputElement>) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Specify the placeholder attribute for the `<input>`
|
|
62
|
+
*/
|
|
63
|
+
placeholder?: string;
|
|
64
|
+
/**
|
|
65
|
+
* "Show password" tooltip text on password visibility toggle
|
|
66
|
+
*/
|
|
67
|
+
showPasswordLabel?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Specify the size of the Text Input.
|
|
70
|
+
*/
|
|
71
|
+
size?: 'sm' | 'md' | 'lg';
|
|
72
|
+
/**
|
|
73
|
+
* Specify the alignment of the tooltip to the icon-only button.
|
|
74
|
+
* Can be one of?: start, center, or end.
|
|
75
|
+
*/
|
|
76
|
+
tooltipAlignment?: 'start' | 'center' | 'end';
|
|
77
|
+
/**
|
|
78
|
+
* Specify the direction of the tooltip for icon-only buttons.
|
|
79
|
+
* Can be either top, right, bottom, or left.
|
|
80
|
+
*/
|
|
81
|
+
tooltipPosition?: 'top' | 'right' | 'bottom' | 'left';
|
|
82
|
+
/**
|
|
83
|
+
* Provide the current value of the `<input>`
|
|
84
|
+
*/
|
|
85
|
+
value?: string | number;
|
|
86
|
+
togglePasswordVisibility?(event: React.MouseEvent<HTMLButtonElement>): void;
|
|
87
|
+
type?: string;
|
|
88
|
+
}
|
|
89
|
+
declare const ControlledPasswordInput: React.ForwardRefExoticComponent<ControlledPasswordInputProps & React.RefAttributes<unknown>>;
|
|
90
|
+
export default ControlledPasswordInput;
|