carbon-addons-iot-react 2.98.2 → 2.100.1

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.
Files changed (44) hide show
  1. package/css/carbon-addons-iot-react.css +39 -33
  2. package/css/carbon-addons-iot-react.css.map +1 -1
  3. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBox.js +98 -0
  4. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBoxField.js +57 -0
  5. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBoxMenu.js +43 -0
  6. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBoxMenuIcon.js +55 -0
  7. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBoxMenuItem.js +58 -0
  8. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBoxPropTypes.js +12 -0
  9. package/es/node_modules/carbon-components-react/es/components/ListBox/ListBoxSelection.js +96 -0
  10. package/es/node_modules/carbon-components-react/es/components/ListBox/index.js +21 -0
  11. package/es/node_modules/carbon-components-react/es/prop-types/childrenOfType.js +36 -0
  12. package/es/node_modules/carbon-components-react/es/prop-types/tools/createChainableTypeChecker.js +38 -0
  13. package/es/node_modules/carbon-components-react/es/prop-types/tools/getDisplayName.js +37 -0
  14. package/es/src/components/ComboBox/CarbonComboBox.jsx +882 -0
  15. package/es/src/components/ComboBox/ComboBox.jsx +375 -0
  16. package/es/src/components/ComposedModal/ComposedModal.jsx +5 -1
  17. package/es/src/index.js +2 -1
  18. package/lib/css/carbon-addons-iot-react.css +39 -33
  19. package/lib/css/carbon-addons-iot-react.css.map +1 -1
  20. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBox.js +103 -0
  21. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBoxField.js +62 -0
  22. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBoxMenu.js +48 -0
  23. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBoxMenuIcon.js +60 -0
  24. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBoxMenuItem.js +63 -0
  25. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBoxPropTypes.js +17 -0
  26. package/lib/node_modules/carbon-components-react/es/components/ListBox/ListBoxSelection.js +101 -0
  27. package/lib/node_modules/carbon-components-react/es/components/ListBox/index.js +23 -0
  28. package/lib/node_modules/carbon-components-react/es/prop-types/childrenOfType.js +41 -0
  29. package/lib/node_modules/carbon-components-react/es/prop-types/tools/createChainableTypeChecker.js +40 -0
  30. package/lib/node_modules/carbon-components-react/es/prop-types/tools/getDisplayName.js +39 -0
  31. package/lib/scss/components/ComboBox/_combo-box.scss +43 -0
  32. package/lib/scss/components/ComposedModal/_composed-modal.scss +5 -0
  33. package/lib/scss/components/Tag/_tag.scss +11 -0
  34. package/lib/scss/styles.scss +1 -44
  35. package/lib/src/components/ComboBox/CarbonComboBox.jsx +889 -0
  36. package/lib/src/components/ComboBox/ComboBox.jsx +380 -0
  37. package/lib/src/components/ComposedModal/ComposedModal.jsx +5 -1
  38. package/lib/src/index.js +2 -1
  39. package/package.json +7 -5
  40. package/scss/components/ComboBox/_combo-box.scss +43 -0
  41. package/scss/components/ComposedModal/_composed-modal.scss +5 -0
  42. package/scss/components/Tag/_tag.scss +11 -0
  43. package/scss/styles.scss +1 -44
  44. package/umd/carbon-addons-iot-react.js +3327 -237
@@ -0,0 +1,103 @@
1
+ 'use strict';
2
+
3
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
+
5
+ var PropTypes = _interopDefault(require('prop-types'));
6
+ var React = require('react');
7
+ var React__default = _interopDefault(React);
8
+ var classnames = _interopDefault(require('classnames'));
9
+ var carbonComponents = require('carbon-components');
10
+ var __chunk_187 = require('./ListBoxPropTypes.js');
11
+
12
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
13
+
14
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+
16
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
17
+
18
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
19
+ var prefix = carbonComponents.settings.prefix;
20
+
21
+ var handleOnKeyDown = function handleOnKeyDown(event) {
22
+ if (event.keyCode === 27) {
23
+ event.stopPropagation();
24
+ }
25
+ };
26
+
27
+ var handleClick = function handleClick(event) {
28
+ event.preventDefault();
29
+ event.stopPropagation();
30
+ };
31
+ /**
32
+ * `ListBox` is a generic container component that handles creating the
33
+ * container class name in response to certain props.
34
+ */
35
+
36
+
37
+ var ListBox = function ListBox(_ref) {
38
+ var _cx;
39
+
40
+ var children = _ref.children,
41
+ containerClassName = _ref.className,
42
+ disabled = _ref.disabled,
43
+ innerRef = _ref.innerRef,
44
+ type = _ref.type,
45
+ size = _ref.size,
46
+ invalid = _ref.invalid,
47
+ invalidText = _ref.invalidText,
48
+ light = _ref.light,
49
+ isOpen = _ref.isOpen,
50
+ rest = _objectWithoutProperties(_ref, ["children", "className", "disabled", "innerRef", "type", "size", "invalid", "invalidText", "light", "isOpen"]);
51
+
52
+ var className = classnames((_cx = {}, _defineProperty(_cx, containerClassName, !!containerClassName), _defineProperty(_cx, "".concat(prefix, "--list-box"), true), _defineProperty(_cx, "".concat(prefix, "--list-box--").concat(size), size), _defineProperty(_cx, "".concat(prefix, "--list-box--inline"), type === 'inline'), _defineProperty(_cx, "".concat(prefix, "--list-box--disabled"), disabled), _defineProperty(_cx, "".concat(prefix, "--list-box--light"), light), _defineProperty(_cx, "".concat(prefix, "--list-box--expanded"), isOpen), _cx));
53
+ return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", _extends({}, rest, {
54
+ className: className,
55
+ ref: innerRef,
56
+ onKeyDown: handleOnKeyDown,
57
+ onClick: handleClick,
58
+ "data-invalid": invalid || undefined
59
+ }), children), invalid ? React__default.createElement("div", {
60
+ className: "".concat(prefix, "--form-requirement")
61
+ }, invalidText) : null);
62
+ };
63
+
64
+ ListBox.propTypes = {
65
+ /**
66
+ * Provide the contents of your ListBox
67
+ */
68
+ children: PropTypes.node,
69
+
70
+ /**
71
+ * Specify a class name to be applied on the containing list box node
72
+ */
73
+ className: PropTypes.string,
74
+
75
+ /**
76
+ * `innerRef` hook used for libraries like Downshift that require a reference
77
+ * on a container node when it is not a native element
78
+ */
79
+ innerRef: PropTypes.func.isRequired,
80
+
81
+ /**
82
+ * Specify whether the ListBox is currently disabled
83
+ */
84
+ disabled: PropTypes.bool.isRequired,
85
+
86
+ /**
87
+ * Specify the "type" of the ListBox. Currently supports either `default` or
88
+ * `inline` as an option.
89
+ */
90
+ type: __chunk_187.ListBoxType.isRequired,
91
+
92
+ /**
93
+ * Specify the size of the ListBox. Currently supports either `sm` or `xl` as an option.
94
+ */
95
+ size: __chunk_187.ListBoxSize
96
+ };
97
+ ListBox.defaultProps = {
98
+ innerRef: function innerRef() {},
99
+ disabled: false,
100
+ type: 'default'
101
+ };
102
+
103
+ exports.default = ListBox;
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
+
5
+ var PropTypes = _interopDefault(require('prop-types'));
6
+ var React = require('react');
7
+ var React__default = _interopDefault(React);
8
+ var carbonComponents = require('carbon-components');
9
+
10
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
11
+
12
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
13
+
14
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
15
+ var prefix = carbonComponents.settings.prefix;
16
+
17
+ /**
18
+ * `ListBoxField` is responsible for creating the containing node for valid
19
+ * elements inside of a field. It also provides a11y-related attributes like
20
+ * `role` to make sure a user can focus the given field.
21
+ */
22
+
23
+ var ListBoxField = function ListBoxField(_ref) {
24
+ var children = _ref.children,
25
+ id = _ref.id,
26
+ disabled = _ref.disabled,
27
+ tabIndex = _ref.tabIndex,
28
+ rest = _objectWithoutProperties(_ref, ["children", "id", "disabled", "tabIndex"]);
29
+
30
+ return React__default.createElement("div", _extends({
31
+ role: rest['aria-expanded'] ? 'combobox' : rest.role || 'combobox',
32
+ "aria-owns": rest['aria-expanded'] && "".concat(id, "__menu") || null,
33
+ "aria-controls": rest['aria-expanded'] && "".concat(id, "__menu") || null,
34
+ "aria-haspopup": "listbox",
35
+ className: "".concat(prefix, "--list-box__field"),
36
+ tabIndex: !disabled && tabIndex || -1
37
+ }, rest), children);
38
+ };
39
+
40
+ ListBoxField.propTypes = {
41
+ /**
42
+ * Provide the contents of your ListBoxField
43
+ */
44
+ children: PropTypes.node,
45
+
46
+ /**
47
+ * Specify a custom `id`
48
+ */
49
+ id: PropTypes.string.isRequired,
50
+
51
+ /**
52
+ * Specify if the parent <ListBox> is disabled
53
+ */
54
+ disabled: PropTypes.bool,
55
+
56
+ /**
57
+ * Optional prop to specify the tabIndex of the <ListBox> trigger button
58
+ */
59
+ tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
60
+ };
61
+
62
+ exports.default = ListBoxField;
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
+
5
+ var PropTypes = _interopDefault(require('prop-types'));
6
+ var React = require('react');
7
+ var React__default = _interopDefault(React);
8
+ var carbonComponents = require('carbon-components');
9
+ var __chunk_190 = require('./ListBoxMenuItem.js');
10
+ var __chunk_193 = require('../../prop-types/childrenOfType.js');
11
+
12
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
13
+
14
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
15
+
16
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
17
+ var prefix = carbonComponents.settings.prefix;
18
+ /**
19
+ * `ListBoxMenu` is a simple container node that isolates the `list-box__menu`
20
+ * class into a single component. It is also being used to validate given
21
+ * `children` components.
22
+ */
23
+
24
+ var ListBoxMenu = function ListBoxMenu(_ref) {
25
+ var children = _ref.children,
26
+ id = _ref.id,
27
+ rest = _objectWithoutProperties(_ref, ["children", "id"]);
28
+
29
+ return React__default.createElement("div", _extends({
30
+ id: "".concat(id, "__menu"),
31
+ className: "".concat(prefix, "--list-box__menu"),
32
+ role: "listbox"
33
+ }, rest), children);
34
+ };
35
+
36
+ ListBoxMenu.propTypes = {
37
+ /**
38
+ * Provide the contents of your ListBoxMenu
39
+ */
40
+ children: __chunk_193.default(__chunk_190.default),
41
+
42
+ /**
43
+ * Specify a custom `id`
44
+ */
45
+ id: PropTypes.string.isRequired
46
+ };
47
+
48
+ exports.default = ListBoxMenu;
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
+
5
+ var PropTypes = _interopDefault(require('prop-types'));
6
+ var React = require('react');
7
+ var React__default = _interopDefault(React);
8
+ var classnames = _interopDefault(require('classnames'));
9
+ var iconsReact = require('@carbon/icons-react');
10
+ var carbonComponents = require('carbon-components');
11
+
12
+ var _defaultTranslations;
13
+
14
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+ var prefix = carbonComponents.settings.prefix;
16
+ var translationIds = {
17
+ 'close.menu': 'close.menu',
18
+ 'open.menu': 'open.menu'
19
+ };
20
+ var defaultTranslations = (_defaultTranslations = {}, _defineProperty(_defaultTranslations, translationIds['close.menu'], 'Close menu'), _defineProperty(_defaultTranslations, translationIds['open.menu'], 'Open menu'), _defaultTranslations);
21
+ /**
22
+ * `ListBoxMenuIcon` is used to orient the icon up or down depending on the
23
+ * state of the menu for a given `ListBox`
24
+ */
25
+
26
+ var ListBoxMenuIcon = function ListBoxMenuIcon(_ref) {
27
+ var isOpen = _ref.isOpen,
28
+ t = _ref.translateWithId;
29
+ var className = classnames("".concat(prefix, "--list-box__menu-icon"), _defineProperty({}, "".concat(prefix, "--list-box__menu-icon--open"), isOpen));
30
+ var description = isOpen ? t('close.menu') : t('open.menu');
31
+ return React__default.createElement("div", {
32
+ className: className
33
+ }, React__default.createElement(iconsReact.ChevronDown16, {
34
+ name: "chevron--down",
35
+ "aria-label": description
36
+ }, React__default.createElement("title", null, description)));
37
+ };
38
+
39
+ ListBoxMenuIcon.propTypes = {
40
+ /**
41
+ * Specify whether the menu is currently open, which will influence the
42
+ * direction of the menu icon
43
+ */
44
+ isOpen: PropTypes.bool.isRequired,
45
+
46
+ /**
47
+ * i18n hook used to provide the appropriate description for the given menu
48
+ * icon. This function takes in an id defined in `translationIds` and should
49
+ * return a string message for that given message id.
50
+ */
51
+ translateWithId: PropTypes.func.isRequired
52
+ };
53
+ ListBoxMenuIcon.defaultProps = {
54
+ translateWithId: function translateWithId(id) {
55
+ return defaultTranslations[id];
56
+ }
57
+ };
58
+
59
+ exports.translationIds = translationIds;
60
+ exports.default = ListBoxMenuIcon;
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+
3
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
+
5
+ var PropTypes = _interopDefault(require('prop-types'));
6
+ var React = require('react');
7
+ var React__default = _interopDefault(React);
8
+ var classnames = _interopDefault(require('classnames'));
9
+ var carbonComponents = require('carbon-components');
10
+
11
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
12
+
13
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+
15
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
16
+
17
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
18
+ var prefix = carbonComponents.settings.prefix;
19
+ /**
20
+ * `ListBoxMenuItem` is a helper component for managing the container class
21
+ * name, alongside any classes for any corresponding states, for a generic list
22
+ * box menu item.
23
+ */
24
+
25
+ var ListBoxMenuItem = function ListBoxMenuItem(_ref) {
26
+ var _cx;
27
+
28
+ var children = _ref.children,
29
+ isActive = _ref.isActive,
30
+ isHighlighted = _ref.isHighlighted,
31
+ rest = _objectWithoutProperties(_ref, ["children", "isActive", "isHighlighted"]);
32
+
33
+ var className = classnames((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--list-box__menu-item"), true), _defineProperty(_cx, "".concat(prefix, "--list-box__menu-item--active"), isActive), _defineProperty(_cx, "".concat(prefix, "--list-box__menu-item--highlighted"), isHighlighted), _cx));
34
+ return React__default.createElement("div", _extends({
35
+ className: className
36
+ }, rest), React__default.createElement("div", {
37
+ className: "".concat(prefix, "--list-box__menu-item__option")
38
+ }, children));
39
+ };
40
+
41
+ ListBoxMenuItem.propTypes = {
42
+ /**
43
+ * Specify any children nodes that hsould be rendered inside of the ListBox
44
+ * Menu Item
45
+ */
46
+ children: PropTypes.node,
47
+
48
+ /**
49
+ * Specify whether the current menu item is "active".
50
+ */
51
+ isActive: PropTypes.bool.isRequired,
52
+
53
+ /**
54
+ * Specify whether the current menu item is "highlighed".
55
+ */
56
+ isHighlighted: PropTypes.bool.isRequired
57
+ };
58
+ ListBoxMenuItem.defaultProps = {
59
+ isActive: false,
60
+ isHighlighted: false
61
+ };
62
+
63
+ exports.default = ListBoxMenuItem;
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
+
5
+ var PropTypes = _interopDefault(require('prop-types'));
6
+
7
+ /**
8
+ * Copyright IBM Corp. 2016, 2018
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
+ var ListBoxType = PropTypes.oneOf(['default', 'inline']);
14
+ var ListBoxSize = PropTypes.oneOf(['sm', 'xl']);
15
+
16
+ exports.ListBoxType = ListBoxType;
17
+ exports.ListBoxSize = ListBoxSize;
@@ -0,0 +1,101 @@
1
+ 'use strict';
2
+
3
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
+
5
+ var PropTypes = _interopDefault(require('prop-types'));
6
+ var React = require('react');
7
+ var React__default = _interopDefault(React);
8
+ var classnames = _interopDefault(require('classnames'));
9
+ var iconsReact = require('@carbon/icons-react');
10
+ var carbonComponents = require('carbon-components');
11
+ var __chunk_110 = require('../../internal/keyboard/keys.js');
12
+ var __chunk_111 = require('../../internal/keyboard/match.js');
13
+ require('../../internal/keyboard/navigation.js');
14
+
15
+ var _defaultTranslations;
16
+
17
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+ var prefix = carbonComponents.settings.prefix;
19
+ /**
20
+ * `ListBoxSelection` is used to provide controls for clearing a selection, in
21
+ * addition to conditionally rendering a badge if the control has more than one
22
+ * selection.
23
+ */
24
+
25
+ var ListBoxSelection = function ListBoxSelection(_ref) {
26
+ var _cx;
27
+
28
+ var clearSelection = _ref.clearSelection,
29
+ selectionCount = _ref.selectionCount,
30
+ t = _ref.translateWithId,
31
+ disabled = _ref.disabled;
32
+ var className = classnames("".concat(prefix, "--list-box__selection"), (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--tag--filter"), selectionCount), _defineProperty(_cx, "".concat(prefix, "--list-box__selection--multi"), selectionCount), _cx));
33
+
34
+ var handleOnClick = function handleOnClick(event) {
35
+ event.stopPropagation();
36
+
37
+ if (disabled) {
38
+ return;
39
+ }
40
+
41
+ clearSelection(event);
42
+ };
43
+
44
+ var handleOnKeyDown = function handleOnKeyDown(event) {
45
+ event.stopPropagation();
46
+
47
+ if (disabled) {
48
+ return;
49
+ } // When a user hits ENTER, we'll clear the selection
50
+
51
+
52
+ if (__chunk_111.match(event, __chunk_110.Enter)) {
53
+ clearSelection(event);
54
+ }
55
+ };
56
+
57
+ var description = selectionCount ? t('clear.all') : t('clear.selection');
58
+ return React__default.createElement("div", {
59
+ role: "button",
60
+ className: className,
61
+ tabIndex: disabled ? -1 : 0,
62
+ onClick: handleOnClick,
63
+ onKeyDown: handleOnKeyDown,
64
+ "aria-label": "Clear Selection",
65
+ title: description
66
+ }, selectionCount, React__default.createElement(iconsReact.Close16, null));
67
+ };
68
+
69
+ var translationIds = {
70
+ 'clear.all': 'clear.all',
71
+ 'clear.selection': 'clear.selection'
72
+ };
73
+ var defaultTranslations = (_defaultTranslations = {}, _defineProperty(_defaultTranslations, translationIds['clear.all'], 'Clear all selected items'), _defineProperty(_defaultTranslations, translationIds['clear.selection'], 'Clear selected item'), _defaultTranslations);
74
+ ListBoxSelection.propTypes = {
75
+ /**
76
+ * Specify a function to be invoked when a user interacts with the clear
77
+ * selection element.
78
+ */
79
+ clearSelection: PropTypes.func.isRequired,
80
+
81
+ /**
82
+ * Specify an optional `selectionCount` value that will be used to determine
83
+ * whether the selection should display a badge or a single clear icon.
84
+ */
85
+ selectionCount: PropTypes.number,
86
+
87
+ /**
88
+ * i18n hook used to provide the appropriate description for the given menu
89
+ * icon. This function takes in an id defined in `translationIds` and should
90
+ * return a string message for that given message id.
91
+ */
92
+ translateWithId: PropTypes.func.isRequired
93
+ };
94
+ ListBoxSelection.defaultProps = {
95
+ translateWithId: function translateWithId(id) {
96
+ return defaultTranslations[id];
97
+ }
98
+ };
99
+
100
+ exports.translationIds = translationIds;
101
+ exports.default = ListBoxSelection;
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ require('./ListBoxPropTypes.js');
4
+ var __chunk_188 = require('./ListBox.js');
5
+ var __chunk_189 = require('./ListBoxField.js');
6
+ var __chunk_190 = require('./ListBoxMenuItem.js');
7
+ var __chunk_194 = require('./ListBoxMenu.js');
8
+ var __chunk_195 = require('./ListBoxMenuIcon.js');
9
+ var __chunk_196 = require('./ListBoxSelection.js');
10
+
11
+ /**
12
+ * Copyright IBM Corp. 2016, 2018
13
+ *
14
+ * This source code is licensed under the Apache-2.0 license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ */
17
+ __chunk_188.default.Field = __chunk_189.default;
18
+ __chunk_188.default.Menu = __chunk_194.default;
19
+ __chunk_188.default.MenuIcon = __chunk_195.default;
20
+ __chunk_188.default.MenuItem = __chunk_190.default;
21
+ __chunk_188.default.Selection = __chunk_196.default;
22
+
23
+ exports.default = __chunk_188.default;
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
+
5
+ var React = require('react');
6
+ var React__default = _interopDefault(React);
7
+ var __chunk_191 = require('./tools/createChainableTypeChecker.js');
8
+ var __chunk_192 = require('./tools/getDisplayName.js');
9
+
10
+ /**
11
+ * Copyright IBM Corp. 2016, 2018
12
+ *
13
+ * This source code is licensed under the Apache-2.0 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+ /**
17
+ * `childrenOfType` is used for asserting that children of a given React
18
+ * component are only of a given type. Currently, this supports React elements,
19
+ * Stateless Functional Components, and Class-based components.
20
+ *
21
+ * This prop validator also supports chaining through `isRequired`
22
+ */
23
+
24
+ var childrenOfType = function childrenOfType(expectedChildType) {
25
+ var expectedDisplayName = __chunk_192.default( // Support both React elements and components by using `type` if it exists
26
+ expectedChildType.type || expectedChildType);
27
+
28
+ var validate = function validate(props, propName, componentName) {
29
+ React.Children.forEach(props[propName], function (child) {
30
+ var childDisplayName = __chunk_192.default(child.type);
31
+
32
+ if (child.type !== expectedChildType.type && child.type !== expectedChildType) {
33
+ throw new Error("Invalid prop `children` of type `".concat(childDisplayName, "` ") + "supplied to `".concat(componentName, "`, expected each child to be a ") + "`".concat(expectedDisplayName, "` component."));
34
+ }
35
+ });
36
+ };
37
+
38
+ return __chunk_191.default(validate);
39
+ };
40
+
41
+ exports.default = childrenOfType;
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Copyright IBM Corp. 2016, 2018
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ /**
11
+ * `createChainableTypeChecker` is used inside of our custom prop validators to
12
+ * add in chaining `isRequired` on a given prop validator.
13
+ */
14
+ var createChainableTypeChecker = function createChainableTypeChecker(validate) {
15
+ // `checkType` is borrowed heavily from the `prop-types` package
16
+ var checkType = function checkType(isRequired, props, propName, componentName, location) {
17
+ if (props[propName] == null) {
18
+ if (isRequired) {
19
+ if (props[propName] === null) {
20
+ return new Error("The ".concat(location, " `").concat(propName, "` is marked as required in ") + "".concat(componentName, ", but its value is `null`."));
21
+ }
22
+
23
+ return new Error("The ".concat(location, " `").concat(propName, "` is marked as required in ") + "".concat(componentName, ", but its value is `undefined`."));
24
+ }
25
+
26
+ return null;
27
+ } else {
28
+ return validate(props, propName, componentName, location);
29
+ }
30
+ }; // By default, the validator will have `isRequired` set to false. However, we
31
+ // also define the `isRequired` property on the validtor so that consumers can
32
+ // chain their prop validator and assert that the property is required.
33
+
34
+
35
+ var chainedCheckType = checkType.bind(null, false);
36
+ chainedCheckType.isRequired = checkType.bind(null, true);
37
+ return chainedCheckType;
38
+ };
39
+
40
+ exports.default = createChainableTypeChecker;
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Copyright IBM Corp. 2016, 2018
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ var cachedDisplayNames = new WeakMap();
10
+ /**
11
+ * `getDisplayName` is a utility function for getting a name from a given
12
+ * component type. It supports names from React elements, Stateless Functional
13
+ * Components, and Class-based Components
14
+ */
15
+
16
+ var getDisplayName = function getDisplayName(type) {
17
+ if (typeof type === 'string') {
18
+ return type;
19
+ }
20
+
21
+ if (cachedDisplayNames.has(type)) {
22
+ return cachedDisplayNames.get(type);
23
+ }
24
+
25
+ var displayName;
26
+
27
+ if (typeof type.displayName === 'string') {
28
+ displayName = type.displayName;
29
+ }
30
+
31
+ if (!displayName) {
32
+ displayName = type.name || 'Unknown';
33
+ }
34
+
35
+ cachedDisplayNames.set(type, displayName);
36
+ return displayName;
37
+ };
38
+
39
+ exports.default = getDisplayName;
@@ -1 +1,44 @@
1
1
  @import '~carbon-components/scss/components/combo-box/combo-box';
2
+
3
+ .#{$iot-prefix}--combobox {
4
+ display: flex;
5
+ flex-flow: column-reverse;
6
+ position: relative;
7
+ padding-top: $spacing-08;
8
+
9
+ .#{$prefix}--form__helper-text,
10
+ .#{$prefix}--label {
11
+ bottom: 100%;
12
+ position: absolute;
13
+ }
14
+
15
+ .#{$prefix}--label {
16
+ transform: translateY(25px);
17
+ }
18
+
19
+ .#{$prefix}--form__helper-text {
20
+ transform: translateY(40px);
21
+ }
22
+
23
+ &-tags {
24
+ margin-bottom: $spacing-03;
25
+
26
+ li {
27
+ display: inline-block;
28
+ max-width: 100%;
29
+ }
30
+ }
31
+
32
+ &.#{$iot-prefix}--combobox-add {
33
+ .#{$prefix}--list-box__menu-item:first-child {
34
+ &::after {
35
+ content: attr(data-text);
36
+ color: $text-03;
37
+ position: absolute;
38
+ right: $spacing-03;
39
+ top: 50%;
40
+ transform: translateY(-50%);
41
+ }
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,5 @@
1
+ @import '../../globals/vars';
2
+
3
+ .#{$iot-prefix}--composed-modal__body--small-margin-bottom {
4
+ margin-bottom: $spacing-05;
5
+ }
@@ -1 +1,12 @@
1
1
  @import '~carbon-components/scss/components/tag/tag';
2
+
3
+ html[dir='rtl'] {
4
+ .#{$prefix}--tag--filter {
5
+ padding-right: $spacing-03;
6
+ padding-left: $spacing-01;
7
+ }
8
+
9
+ .#{$prefix}--tag__close-icon {
10
+ margin: 0 $spacing-02 0 0;
11
+ }
12
+ }