@carbon/react 1.0.0 → 1.0.3
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 +2 -2
- package/es/components/Toggletip/index.js +252 -0
- package/es/index.js +2 -4
- package/es/internal/ComponentToggle.js +0 -1
- package/es/internal/useEvent.js +29 -0
- package/icons/package.json +2 -1
- package/lib/components/Toggletip/index.js +266 -0
- package/lib/index.js +34 -38
- package/lib/internal/ComponentToggle.js +0 -1
- package/lib/internal/useEvent.js +33 -0
- package/package.json +5 -5
- package/es/components/ToggleSmall/ToggleSmall.js +0 -104
- package/es/components/Toolbar/Toolbar.js +0 -121
- package/es/components/ToolbarSearch/ToolbarSearch.js +0 -168
- package/lib/components/ToggleSmall/ToggleSmall.js +0 -114
- package/lib/components/Toolbar/Toolbar.js +0 -135
- package/lib/components/ToolbarSearch/ToolbarSearch.js +0 -178
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ styles from the project or include the styles for a specific component:
|
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
For a full list of components available, checkout our
|
|
66
|
-
[Storybook](https://
|
|
66
|
+
[Storybook](https://react.carbondesignsystem.com/).
|
|
67
67
|
|
|
68
68
|
### Icons
|
|
69
69
|
|
|
@@ -86,7 +86,7 @@ For a full list of icons available, checkout our
|
|
|
86
86
|
|
|
87
87
|
If you're looking for `@carbon/react` API documentation, check out:
|
|
88
88
|
|
|
89
|
-
- [Storybook](https://
|
|
89
|
+
- [Storybook](https://react.carbondesignsystem.com/)
|
|
90
90
|
- [Icon Library](https://www.carbondesignsystem.com/guidelines/icons/library/)
|
|
91
91
|
|
|
92
92
|
## 🙌 Contributing
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2021
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import cx from 'classnames';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
import React__default, { useRef, useState, useContext } from 'react';
|
|
12
|
+
import { Popover, PopoverContent } from '../Popover/index.js';
|
|
13
|
+
import { useWindowEvent } from '../../internal/useEvent.js';
|
|
14
|
+
import { useId } from '../../internal/useId.js';
|
|
15
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
17
|
+
import { Escape } from '../../internal/keyboard/keys.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Used to render the label for a Toggletip
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
function ToggletipLabel(_ref) {
|
|
24
|
+
var _ref$as = _ref.as,
|
|
25
|
+
BaseComponent = _ref$as === void 0 ? 'span' : _ref$as,
|
|
26
|
+
children = _ref.children,
|
|
27
|
+
customClassName = _ref.className;
|
|
28
|
+
var prefix = usePrefix();
|
|
29
|
+
var className = cx("".concat(prefix, "--toggletip-label"), customClassName);
|
|
30
|
+
return /*#__PURE__*/React__default.createElement(BaseComponent, {
|
|
31
|
+
className: className
|
|
32
|
+
}, children);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
ToggletipLabel.propTypes = {
|
|
36
|
+
/**
|
|
37
|
+
* Provide a custom element or component to render the top-level node for the
|
|
38
|
+
* component.
|
|
39
|
+
*/
|
|
40
|
+
as: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Custom children to be rendered as the content of the label
|
|
44
|
+
*/
|
|
45
|
+
children: PropTypes.node,
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Provide a custom class name to be added to the outermost node in the
|
|
49
|
+
* component
|
|
50
|
+
*/
|
|
51
|
+
className: PropTypes.string
|
|
52
|
+
}; // Used to coordinate accessibility props between button and content along with
|
|
53
|
+
// the actions to open and close the toggletip
|
|
54
|
+
|
|
55
|
+
var ToggletipContext = /*#__PURE__*/React__default.createContext();
|
|
56
|
+
|
|
57
|
+
function useToggletip() {
|
|
58
|
+
return useContext(ToggletipContext);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Used as a container for the button and content of a toggletip. This component
|
|
62
|
+
* is responsible for coordinating between interactions with the button and the
|
|
63
|
+
* visibility of the content
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
function Toggletip(_ref2) {
|
|
68
|
+
var align = _ref2.align,
|
|
69
|
+
as = _ref2.as,
|
|
70
|
+
customClassName = _ref2.className,
|
|
71
|
+
children = _ref2.children,
|
|
72
|
+
_ref2$defaultOpen = _ref2.defaultOpen,
|
|
73
|
+
defaultOpen = _ref2$defaultOpen === void 0 ? false : _ref2$defaultOpen;
|
|
74
|
+
var ref = useRef();
|
|
75
|
+
|
|
76
|
+
var _useState = useState(defaultOpen),
|
|
77
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
78
|
+
open = _useState2[0],
|
|
79
|
+
setOpen = _useState2[1];
|
|
80
|
+
|
|
81
|
+
var prefix = usePrefix();
|
|
82
|
+
var id = useId();
|
|
83
|
+
var className = cx("".concat(prefix, "--toggletip"), customClassName, _defineProperty({}, "".concat(prefix, "--toggletip--open"), open));
|
|
84
|
+
var actions = {
|
|
85
|
+
toggle: function toggle() {
|
|
86
|
+
setOpen(!open);
|
|
87
|
+
},
|
|
88
|
+
close: function close() {
|
|
89
|
+
setOpen(false);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var value = {
|
|
93
|
+
buttonProps: {
|
|
94
|
+
'aria-expanded': open,
|
|
95
|
+
'aria-controls': id,
|
|
96
|
+
onClick: actions.toggle
|
|
97
|
+
},
|
|
98
|
+
contentProps: {
|
|
99
|
+
id: id
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
function onKeyDown(event) {
|
|
104
|
+
if (open && match(event, Escape)) {
|
|
105
|
+
actions.close();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
useWindowEvent('click', function (event) {
|
|
110
|
+
if (open && !ref.current.contains(event.target)) {
|
|
111
|
+
actions.close();
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return /*#__PURE__*/React__default.createElement(ToggletipContext.Provider, {
|
|
115
|
+
value: value
|
|
116
|
+
}, /*#__PURE__*/React__default.createElement(Popover, {
|
|
117
|
+
align: align,
|
|
118
|
+
as: as,
|
|
119
|
+
caret: true,
|
|
120
|
+
className: className,
|
|
121
|
+
dropShadow: false,
|
|
122
|
+
highContrast: true,
|
|
123
|
+
open: open,
|
|
124
|
+
onKeyDown: onKeyDown,
|
|
125
|
+
ref: ref
|
|
126
|
+
}, children));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
Toggletip.propTypes = {
|
|
130
|
+
/**
|
|
131
|
+
* Specify how the toggletip should align with the button
|
|
132
|
+
*/
|
|
133
|
+
align: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Provide a custom element or component to render the top-level node for the
|
|
137
|
+
* component.
|
|
138
|
+
*/
|
|
139
|
+
as: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Custom children to be rendered as the content of the label
|
|
143
|
+
*/
|
|
144
|
+
children: PropTypes.node,
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Provide a custom class name to be added to the outermost node in the
|
|
148
|
+
* component
|
|
149
|
+
*/
|
|
150
|
+
className: PropTypes.string,
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Specify if the toggletip should be open by default
|
|
154
|
+
*/
|
|
155
|
+
defaultOpen: PropTypes.bool
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* `ToggletipButton` controls the visibility of the Toggletip through mouse
|
|
159
|
+
* clicks and keyboard interactions.
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
function ToggletipButton(_ref3) {
|
|
163
|
+
var children = _ref3.children,
|
|
164
|
+
customClassName = _ref3.className,
|
|
165
|
+
_ref3$label = _ref3.label,
|
|
166
|
+
label = _ref3$label === void 0 ? 'Show information' : _ref3$label;
|
|
167
|
+
var toggletip = useToggletip();
|
|
168
|
+
var prefix = usePrefix();
|
|
169
|
+
var className = cx("".concat(prefix, "--toggletip-button"), customClassName);
|
|
170
|
+
return /*#__PURE__*/React__default.createElement("button", _extends({}, toggletip.buttonProps, {
|
|
171
|
+
"aria-label": label,
|
|
172
|
+
type: "button",
|
|
173
|
+
className: className
|
|
174
|
+
}), children);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
ToggletipButton.propTypes = {
|
|
178
|
+
/**
|
|
179
|
+
* Custom children to be rendered as the content of the label
|
|
180
|
+
*/
|
|
181
|
+
children: PropTypes.node,
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Provide a custom class name to be added to the outermost node in the
|
|
185
|
+
* component
|
|
186
|
+
*/
|
|
187
|
+
className: PropTypes.string,
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Provide an accessible label for this button
|
|
191
|
+
*/
|
|
192
|
+
label: PropTypes.string
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* `ToggletipContent` is a wrapper around `PopoverContent`. It places the
|
|
196
|
+
* `children` passed in as a prop inside of `PopoverContent` so that they will
|
|
197
|
+
* be rendered inside of the popover for this component.
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
function ToggletipContent(_ref4) {
|
|
201
|
+
var children = _ref4.children,
|
|
202
|
+
customClassName = _ref4.className;
|
|
203
|
+
var toggletip = useToggletip();
|
|
204
|
+
var prefix = usePrefix();
|
|
205
|
+
return /*#__PURE__*/React__default.createElement(PopoverContent, _extends({
|
|
206
|
+
className: customClassName
|
|
207
|
+
}, toggletip.contentProps), /*#__PURE__*/React__default.createElement("div", {
|
|
208
|
+
className: "".concat(prefix, "--toggletip-content")
|
|
209
|
+
}, children));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
ToggletipContent.propTypes = {
|
|
213
|
+
/**
|
|
214
|
+
* Custom children to be rendered as the content of the label
|
|
215
|
+
*/
|
|
216
|
+
children: PropTypes.node,
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Provide a custom class name to be added to the outermost node in the
|
|
220
|
+
* component
|
|
221
|
+
*/
|
|
222
|
+
className: PropTypes.string
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* `ToggletipActions` is a container for one or two actions present at the base
|
|
226
|
+
* of a toggletip. It is used for layout of these items.
|
|
227
|
+
*/
|
|
228
|
+
|
|
229
|
+
function ToggletipActions(_ref5) {
|
|
230
|
+
var children = _ref5.children,
|
|
231
|
+
customClassName = _ref5.className;
|
|
232
|
+
var prefix = usePrefix();
|
|
233
|
+
var className = cx("".concat(prefix, "--toggletip-actions"), customClassName);
|
|
234
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
235
|
+
className: className
|
|
236
|
+
}, children);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
ToggletipActions.propTypes = {
|
|
240
|
+
/**
|
|
241
|
+
* Custom children to be rendered as the content of the label
|
|
242
|
+
*/
|
|
243
|
+
children: PropTypes.node,
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Provide a custom class name to be added to the outermost node in the
|
|
247
|
+
* component
|
|
248
|
+
*/
|
|
249
|
+
className: PropTypes.string
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
export { Toggletip, ToggletipActions, ToggletipButton, ToggletipContent, ToggletipLabel };
|
package/es/index.js
CHANGED
|
@@ -78,10 +78,7 @@ export { default as TileGroup } from './components/TileGroup/index.js';
|
|
|
78
78
|
export { default as TimePicker } from './components/TimePicker/index.js';
|
|
79
79
|
export { default as TimePickerSelect } from './components/TimePickerSelect/index.js';
|
|
80
80
|
export { default as Toggle } from './components/Toggle/index.js';
|
|
81
|
-
export {
|
|
82
|
-
export { default as ToggleSmall } from './components/ToggleSmall/ToggleSmall.js';
|
|
83
|
-
export { default as Toolbar, ToolbarDivider, ToolbarItem, ToolbarOption, ToolbarTitle } from './components/Toolbar/Toolbar.js';
|
|
84
|
-
export { default as ToolbarSearch } from './components/ToolbarSearch/ToolbarSearch.js';
|
|
81
|
+
export { Toggletip, ToggletipActions, ToggletipButton, ToggletipContent, ToggletipLabel } from './components/Toggletip/index.js';
|
|
85
82
|
export { default as UnorderedList } from './components/UnorderedList/UnorderedList.js';
|
|
86
83
|
export { default as SkeletonText } from './components/SkeletonText/SkeletonText.js';
|
|
87
84
|
export { default as SkeletonPlaceholder } from './components/SkeletonPlaceholder/SkeletonPlaceholder.js';
|
|
@@ -97,6 +94,7 @@ export { default as SliderSkeleton } from './components/Slider/Slider.Skeleton.j
|
|
|
97
94
|
export { default as TabsSkeleton } from './components/Tabs/Tabs.Skeleton.js';
|
|
98
95
|
export { default as TextInputSkeleton } from './components/TextInput/TextInput.Skeleton.js';
|
|
99
96
|
export { default as ToggleSkeleton } from './components/Toggle/Toggle.Skeleton.js';
|
|
97
|
+
export { default as ToggleSmallSkeleton } from './components/ToggleSmall/ToggleSmall.Skeleton.js';
|
|
100
98
|
export { default as IconSkeleton } from './components/Icon/Icon.Skeleton.js';
|
|
101
99
|
export { default as DatePickerSkeleton } from './components/DatePicker/DatePicker.Skeleton.js';
|
|
102
100
|
export { HeaderNavigation, SideNavMenu } from './components/UIShell/index.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2021
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useRef, useEffect } from 'react';
|
|
9
|
+
|
|
10
|
+
function useWindowEvent(eventName, callback) {
|
|
11
|
+
var savedCallback = useRef(null);
|
|
12
|
+
useEffect(function () {
|
|
13
|
+
savedCallback.current = callback;
|
|
14
|
+
});
|
|
15
|
+
useEffect(function () {
|
|
16
|
+
function handler(event) {
|
|
17
|
+
if (savedCallback.current) {
|
|
18
|
+
savedCallback.current(event);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
window.addEventListener(eventName, handler);
|
|
23
|
+
return function () {
|
|
24
|
+
window.removeEventListener(eventName, handler);
|
|
25
|
+
};
|
|
26
|
+
}, [eventName]);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { useWindowEvent };
|
package/icons/package.json
CHANGED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2021
|
|
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 index = require('../Popover/index.js');
|
|
17
|
+
var useEvent = require('../../internal/useEvent.js');
|
|
18
|
+
var useId = require('../../internal/useId.js');
|
|
19
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
20
|
+
var match = require('../../internal/keyboard/match.js');
|
|
21
|
+
var keys = require('../../internal/keyboard/keys.js');
|
|
22
|
+
|
|
23
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
|
+
|
|
25
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
26
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
27
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Used to render the label for a Toggletip
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
function ToggletipLabel(_ref) {
|
|
34
|
+
var _ref$as = _ref.as,
|
|
35
|
+
BaseComponent = _ref$as === void 0 ? 'span' : _ref$as,
|
|
36
|
+
children = _ref.children,
|
|
37
|
+
customClassName = _ref.className;
|
|
38
|
+
var prefix = usePrefix.usePrefix();
|
|
39
|
+
var className = cx__default["default"]("".concat(prefix, "--toggletip-label"), customClassName);
|
|
40
|
+
return /*#__PURE__*/React__default["default"].createElement(BaseComponent, {
|
|
41
|
+
className: className
|
|
42
|
+
}, children);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
ToggletipLabel.propTypes = {
|
|
46
|
+
/**
|
|
47
|
+
* Provide a custom element or component to render the top-level node for the
|
|
48
|
+
* component.
|
|
49
|
+
*/
|
|
50
|
+
as: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].elementType]),
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Custom children to be rendered as the content of the label
|
|
54
|
+
*/
|
|
55
|
+
children: PropTypes__default["default"].node,
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Provide a custom class name to be added to the outermost node in the
|
|
59
|
+
* component
|
|
60
|
+
*/
|
|
61
|
+
className: PropTypes__default["default"].string
|
|
62
|
+
}; // Used to coordinate accessibility props between button and content along with
|
|
63
|
+
// the actions to open and close the toggletip
|
|
64
|
+
|
|
65
|
+
var ToggletipContext = /*#__PURE__*/React__default["default"].createContext();
|
|
66
|
+
|
|
67
|
+
function useToggletip() {
|
|
68
|
+
return React.useContext(ToggletipContext);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Used as a container for the button and content of a toggletip. This component
|
|
72
|
+
* is responsible for coordinating between interactions with the button and the
|
|
73
|
+
* visibility of the content
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
function Toggletip(_ref2) {
|
|
78
|
+
var align = _ref2.align,
|
|
79
|
+
as = _ref2.as,
|
|
80
|
+
customClassName = _ref2.className,
|
|
81
|
+
children = _ref2.children,
|
|
82
|
+
_ref2$defaultOpen = _ref2.defaultOpen,
|
|
83
|
+
defaultOpen = _ref2$defaultOpen === void 0 ? false : _ref2$defaultOpen;
|
|
84
|
+
var ref = React.useRef();
|
|
85
|
+
|
|
86
|
+
var _useState = React.useState(defaultOpen),
|
|
87
|
+
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
|
88
|
+
open = _useState2[0],
|
|
89
|
+
setOpen = _useState2[1];
|
|
90
|
+
|
|
91
|
+
var prefix = usePrefix.usePrefix();
|
|
92
|
+
var id = useId.useId();
|
|
93
|
+
var className = cx__default["default"]("".concat(prefix, "--toggletip"), customClassName, _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--toggletip--open"), open));
|
|
94
|
+
var actions = {
|
|
95
|
+
toggle: function toggle() {
|
|
96
|
+
setOpen(!open);
|
|
97
|
+
},
|
|
98
|
+
close: function close() {
|
|
99
|
+
setOpen(false);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var value = {
|
|
103
|
+
buttonProps: {
|
|
104
|
+
'aria-expanded': open,
|
|
105
|
+
'aria-controls': id,
|
|
106
|
+
onClick: actions.toggle
|
|
107
|
+
},
|
|
108
|
+
contentProps: {
|
|
109
|
+
id: id
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
function onKeyDown(event) {
|
|
114
|
+
if (open && match.match(event, keys.Escape)) {
|
|
115
|
+
actions.close();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
useEvent.useWindowEvent('click', function (event) {
|
|
120
|
+
if (open && !ref.current.contains(event.target)) {
|
|
121
|
+
actions.close();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return /*#__PURE__*/React__default["default"].createElement(ToggletipContext.Provider, {
|
|
125
|
+
value: value
|
|
126
|
+
}, /*#__PURE__*/React__default["default"].createElement(index.Popover, {
|
|
127
|
+
align: align,
|
|
128
|
+
as: as,
|
|
129
|
+
caret: true,
|
|
130
|
+
className: className,
|
|
131
|
+
dropShadow: false,
|
|
132
|
+
highContrast: true,
|
|
133
|
+
open: open,
|
|
134
|
+
onKeyDown: onKeyDown,
|
|
135
|
+
ref: ref
|
|
136
|
+
}, children));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
Toggletip.propTypes = {
|
|
140
|
+
/**
|
|
141
|
+
* Specify how the toggletip should align with the button
|
|
142
|
+
*/
|
|
143
|
+
align: PropTypes__default["default"].oneOf(['top', 'bottom', 'left', 'right']),
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Provide a custom element or component to render the top-level node for the
|
|
147
|
+
* component.
|
|
148
|
+
*/
|
|
149
|
+
as: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].elementType]),
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Custom children to be rendered as the content of the label
|
|
153
|
+
*/
|
|
154
|
+
children: PropTypes__default["default"].node,
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Provide a custom class name to be added to the outermost node in the
|
|
158
|
+
* component
|
|
159
|
+
*/
|
|
160
|
+
className: PropTypes__default["default"].string,
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Specify if the toggletip should be open by default
|
|
164
|
+
*/
|
|
165
|
+
defaultOpen: PropTypes__default["default"].bool
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* `ToggletipButton` controls the visibility of the Toggletip through mouse
|
|
169
|
+
* clicks and keyboard interactions.
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
function ToggletipButton(_ref3) {
|
|
173
|
+
var children = _ref3.children,
|
|
174
|
+
customClassName = _ref3.className,
|
|
175
|
+
_ref3$label = _ref3.label,
|
|
176
|
+
label = _ref3$label === void 0 ? 'Show information' : _ref3$label;
|
|
177
|
+
var toggletip = useToggletip();
|
|
178
|
+
var prefix = usePrefix.usePrefix();
|
|
179
|
+
var className = cx__default["default"]("".concat(prefix, "--toggletip-button"), customClassName);
|
|
180
|
+
return /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({}, toggletip.buttonProps, {
|
|
181
|
+
"aria-label": label,
|
|
182
|
+
type: "button",
|
|
183
|
+
className: className
|
|
184
|
+
}), children);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
ToggletipButton.propTypes = {
|
|
188
|
+
/**
|
|
189
|
+
* Custom children to be rendered as the content of the label
|
|
190
|
+
*/
|
|
191
|
+
children: PropTypes__default["default"].node,
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Provide a custom class name to be added to the outermost node in the
|
|
195
|
+
* component
|
|
196
|
+
*/
|
|
197
|
+
className: PropTypes__default["default"].string,
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Provide an accessible label for this button
|
|
201
|
+
*/
|
|
202
|
+
label: PropTypes__default["default"].string
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* `ToggletipContent` is a wrapper around `PopoverContent`. It places the
|
|
206
|
+
* `children` passed in as a prop inside of `PopoverContent` so that they will
|
|
207
|
+
* be rendered inside of the popover for this component.
|
|
208
|
+
*/
|
|
209
|
+
|
|
210
|
+
function ToggletipContent(_ref4) {
|
|
211
|
+
var children = _ref4.children,
|
|
212
|
+
customClassName = _ref4.className;
|
|
213
|
+
var toggletip = useToggletip();
|
|
214
|
+
var prefix = usePrefix.usePrefix();
|
|
215
|
+
return /*#__PURE__*/React__default["default"].createElement(index.PopoverContent, _rollupPluginBabelHelpers["extends"]({
|
|
216
|
+
className: customClassName
|
|
217
|
+
}, toggletip.contentProps), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
218
|
+
className: "".concat(prefix, "--toggletip-content")
|
|
219
|
+
}, children));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
ToggletipContent.propTypes = {
|
|
223
|
+
/**
|
|
224
|
+
* Custom children to be rendered as the content of the label
|
|
225
|
+
*/
|
|
226
|
+
children: PropTypes__default["default"].node,
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Provide a custom class name to be added to the outermost node in the
|
|
230
|
+
* component
|
|
231
|
+
*/
|
|
232
|
+
className: PropTypes__default["default"].string
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* `ToggletipActions` is a container for one or two actions present at the base
|
|
236
|
+
* of a toggletip. It is used for layout of these items.
|
|
237
|
+
*/
|
|
238
|
+
|
|
239
|
+
function ToggletipActions(_ref5) {
|
|
240
|
+
var children = _ref5.children,
|
|
241
|
+
customClassName = _ref5.className;
|
|
242
|
+
var prefix = usePrefix.usePrefix();
|
|
243
|
+
var className = cx__default["default"]("".concat(prefix, "--toggletip-actions"), customClassName);
|
|
244
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
245
|
+
className: className
|
|
246
|
+
}, children);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
ToggletipActions.propTypes = {
|
|
250
|
+
/**
|
|
251
|
+
* Custom children to be rendered as the content of the label
|
|
252
|
+
*/
|
|
253
|
+
children: PropTypes__default["default"].node,
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Provide a custom class name to be added to the outermost node in the
|
|
257
|
+
* component
|
|
258
|
+
*/
|
|
259
|
+
className: PropTypes__default["default"].string
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
exports.Toggletip = Toggletip;
|
|
263
|
+
exports.ToggletipActions = ToggletipActions;
|
|
264
|
+
exports.ToggletipButton = ToggletipButton;
|
|
265
|
+
exports.ToggletipContent = ToggletipContent;
|
|
266
|
+
exports.ToggletipLabel = ToggletipLabel;
|