@carbon/react 1.0.1 → 1.1.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/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://carbon-react-next.netlify.app/).
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://carbon-react-next.netlify.app/)
89
+ - [Storybook](https://react.carbondesignsystem.com/)
90
90
  - [Icon Library](https://www.carbondesignsystem.com/guidelines/icons/library/)
91
91
 
92
92
  ## 🙌 Contributing
@@ -277,7 +277,11 @@ function DatePicker(_ref) {
277
277
  }), carbonFlatpickrFixEventsPlugin({
278
278
  inputFrom: startInputField.current,
279
279
  inputTo: endInputField.current
280
- })]), _defineProperty(_flatpickr, "clickOpens", true), _defineProperty(_flatpickr, "nextArrow", rightArrowHTML), _defineProperty(_flatpickr, "prevArrow", leftArrowHTML), _defineProperty(_flatpickr, "onChange", savedOnChange), _defineProperty(_flatpickr, "onClose", savedOnClose), _defineProperty(_flatpickr, "onReady", onHook), _defineProperty(_flatpickr, "onMonthChange", onHook), _defineProperty(_flatpickr, "onYearChange", onHook), _defineProperty(_flatpickr, "onOpen", function onOpen() {
280
+ })]), _defineProperty(_flatpickr, "clickOpens", true), _defineProperty(_flatpickr, "nextArrow", rightArrowHTML), _defineProperty(_flatpickr, "prevArrow", leftArrowHTML), _defineProperty(_flatpickr, "onChange", function onChange() {
281
+ if (savedOnChange) {
282
+ savedOnChange.apply(void 0, arguments);
283
+ }
284
+ }), _defineProperty(_flatpickr, "onClose", savedOnClose), _defineProperty(_flatpickr, "onReady", onHook), _defineProperty(_flatpickr, "onMonthChange", onHook), _defineProperty(_flatpickr, "onYearChange", onHook), _defineProperty(_flatpickr, "onOpen", function onOpen() {
281
285
  onHook.apply(void 0, arguments);
282
286
  savedOnOpen.apply(void 0, arguments);
283
287
  }), _defineProperty(_flatpickr, "onValueUpdate", onHook), _flatpickr));
@@ -10,10 +10,11 @@ import PropTypes from 'prop-types';
10
10
  import React__default from 'react';
11
11
  import cx from 'classnames';
12
12
  import { usePrefix } from '../../internal/usePrefix.js';
13
+ import { CircleDash } from '@carbon/icons-react';
13
14
 
14
15
  var _excluded = ["className"];
15
16
 
16
- var _svg, _Step, _Step2, _Step3, _Step4;
17
+ var _CircleDash, _Step, _Step2, _Step3, _Step4;
17
18
 
18
19
  function Step() {
19
20
  var prefix = usePrefix();
@@ -21,9 +22,7 @@ function Step() {
21
22
  className: "".concat(prefix, "--progress-step ").concat(prefix, "--progress-step--incomplete")
22
23
  }, /*#__PURE__*/React__default.createElement("div", {
23
24
  className: "".concat(prefix, "--progress-step-button ").concat(prefix, "--progress-step-button--unclickable")
24
- }, _svg || (_svg = /*#__PURE__*/React__default.createElement("svg", null, /*#__PURE__*/React__default.createElement("path", {
25
- d: "M 7, 7 m -7, 0 a 7,7 0 1,0 14,0 a 7,7 0 1,0 -14,0"
26
- }))), /*#__PURE__*/React__default.createElement("p", {
25
+ }, _CircleDash || (_CircleDash = /*#__PURE__*/React__default.createElement(CircleDash, null)), /*#__PURE__*/React__default.createElement("p", {
27
26
  className: "".concat(prefix, "--progress-label")
28
27
  }), /*#__PURE__*/React__default.createElement("span", {
29
28
  className: "".concat(prefix, "--progress-line")
@@ -49,7 +49,8 @@ var RadioButton = /*#__PURE__*/React__default.forwardRef(function RadioButton(_r
49
49
  onChange: handleOnChange,
50
50
  id: uniqueId,
51
51
  ref: ref,
52
- disabled: disabled
52
+ disabled: disabled,
53
+ value: value
53
54
  })), /*#__PURE__*/React__default.createElement("label", {
54
55
  htmlFor: uniqueId,
55
56
  className: "".concat(prefix, "--radio-button__label")
@@ -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 { default as ToggleSmallSkeleton } from './components/ToggleSmall/ToggleSmall.Skeleton.js';
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 };
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "main": "lib/index.js",
3
- "module": "es/index.js"
3
+ "module": "es/index.js",
4
+ "sideEffects": false
4
5
  }
@@ -288,7 +288,11 @@ function DatePicker(_ref) {
288
288
  }), fixEventsPlugin["default"]({
289
289
  inputFrom: startInputField.current,
290
290
  inputTo: endInputField.current
291
- })]), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "clickOpens", true), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "nextArrow", rightArrowHTML), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "prevArrow", leftArrowHTML), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onChange", savedOnChange), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onClose", savedOnClose), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onReady", onHook), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onMonthChange", onHook), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onYearChange", onHook), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onOpen", function onOpen() {
291
+ })]), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "clickOpens", true), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "nextArrow", rightArrowHTML), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "prevArrow", leftArrowHTML), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onChange", function onChange() {
292
+ if (savedOnChange) {
293
+ savedOnChange.apply(void 0, arguments);
294
+ }
295
+ }), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onClose", savedOnClose), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onReady", onHook), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onMonthChange", onHook), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onYearChange", onHook), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onOpen", function onOpen() {
292
296
  onHook.apply(void 0, arguments);
293
297
  savedOnOpen.apply(void 0, arguments);
294
298
  }), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onValueUpdate", onHook), _flatpickr));
@@ -14,6 +14,7 @@ var PropTypes = require('prop-types');
14
14
  var React = require('react');
15
15
  var cx = require('classnames');
16
16
  var usePrefix = require('../../internal/usePrefix.js');
17
+ var iconsReact = require('@carbon/icons-react');
17
18
 
18
19
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
20
 
@@ -23,7 +24,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
23
24
 
24
25
  var _excluded = ["className"];
25
26
 
26
- var _svg, _Step, _Step2, _Step3, _Step4;
27
+ var _CircleDash, _Step, _Step2, _Step3, _Step4;
27
28
 
28
29
  function Step() {
29
30
  var prefix = usePrefix.usePrefix();
@@ -31,9 +32,7 @@ function Step() {
31
32
  className: "".concat(prefix, "--progress-step ").concat(prefix, "--progress-step--incomplete")
32
33
  }, /*#__PURE__*/React__default["default"].createElement("div", {
33
34
  className: "".concat(prefix, "--progress-step-button ").concat(prefix, "--progress-step-button--unclickable")
34
- }, _svg || (_svg = /*#__PURE__*/React__default["default"].createElement("svg", null, /*#__PURE__*/React__default["default"].createElement("path", {
35
- d: "M 7, 7 m -7, 0 a 7,7 0 1,0 14,0 a 7,7 0 1,0 -14,0"
36
- }))), /*#__PURE__*/React__default["default"].createElement("p", {
35
+ }, _CircleDash || (_CircleDash = /*#__PURE__*/React__default["default"].createElement(iconsReact.CircleDash, null)), /*#__PURE__*/React__default["default"].createElement("p", {
37
36
  className: "".concat(prefix, "--progress-label")
38
37
  }), /*#__PURE__*/React__default["default"].createElement("span", {
39
38
  className: "".concat(prefix, "--progress-line")
@@ -59,7 +59,8 @@ var RadioButton = /*#__PURE__*/React__default["default"].forwardRef(function Rad
59
59
  onChange: handleOnChange,
60
60
  id: uniqueId,
61
61
  ref: ref,
62
- disabled: disabled
62
+ disabled: disabled,
63
+ value: value
63
64
  })), /*#__PURE__*/React__default["default"].createElement("label", {
64
65
  htmlFor: uniqueId,
65
66
  className: "".concat(prefix, "--radio-button__label")