@carbon/ibm-products 1.5.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. package/css/index-full-carbon.css +389 -139
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +9 -3
  4. package/css/index-full-carbon.min.css.map +1 -0
  5. package/css/index-without-carbon-released-only.css +33 -27
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +3 -3
  8. package/css/index-without-carbon-released-only.min.css.map +1 -0
  9. package/css/index-without-carbon.css +330 -133
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +9 -3
  12. package/css/index-without-carbon.min.css.map +1 -0
  13. package/css/index.css +332 -135
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +9 -3
  16. package/css/index.min.css.map +1 -0
  17. package/es/components/APIKeyModal/APIKeyModal.js +10 -13
  18. package/es/components/ActionBar/ActionBar.js +0 -3
  19. package/es/components/ActionBar/ActionBarItem.js +2 -6
  20. package/es/components/ActionSet/ActionSet.js +11 -13
  21. package/es/components/AddSelect/AddSelect.js +122 -72
  22. package/es/components/AddSelect/AddSelectBreadcrumbs.js +56 -0
  23. package/es/components/AddSelect/AddSelectList.js +94 -0
  24. package/es/components/AddSelect/AddSelectSidebar.js +110 -0
  25. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +5 -5
  26. package/es/components/ButtonMenu/ButtonMenu.js +6 -4
  27. package/es/components/ButtonMenu/ButtonMenuItem.js +1 -2
  28. package/es/components/Card/Card.js +37 -25
  29. package/es/components/Card/CardFooter.js +14 -10
  30. package/es/components/Card/CardHeader.js +8 -6
  31. package/es/components/Cascade/Cascade.js +5 -4
  32. package/es/components/ComboButton/ComboButton.js +0 -4
  33. package/es/components/ComboButton/ComboButtonItem/index.js +0 -5
  34. package/es/components/CreateFullPage/CreateFullPageStep.js +15 -8
  35. package/es/components/CreateModal/CreateModal.js +1 -4
  36. package/es/components/CreateTearsheet/CreateTearsheet.js +10 -11
  37. package/es/components/CreateTearsheet/CreateTearsheetStep.js +18 -14
  38. package/es/components/DataSpreadsheet/DataSpreadsheet.js +414 -0
  39. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +138 -0
  40. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +64 -0
  41. package/es/components/DataSpreadsheet/createActiveCellFn.js +45 -0
  42. package/es/components/DataSpreadsheet/generateData.js +47 -0
  43. package/es/components/DataSpreadsheet/getCellSize.js +30 -0
  44. package/es/components/{CancelableTextEdit → DataSpreadsheet}/index.js +2 -2
  45. package/es/components/EditSidePanel/EditSidePanel.js +9 -10
  46. package/es/components/EmptyStates/EmptyState.js +8 -7
  47. package/es/components/EmptyStates/EmptyStateContent.js +2 -2
  48. package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +5 -9
  49. package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +5 -9
  50. package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +5 -9
  51. package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +5 -9
  52. package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +5 -9
  53. package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +5 -9
  54. package/es/components/ExampleComponent/ExampleComponent.js +12 -13
  55. package/es/components/ExportModal/ExportModal.js +13 -9
  56. package/es/components/ExpressiveCard/ExpressiveCard.js +0 -8
  57. package/es/components/ImportModal/ImportModal.js +7 -5
  58. package/es/components/InlineEdit/InlineEdit.js +256 -88
  59. package/es/components/LoadingBar/LoadingBar.js +13 -17
  60. package/es/components/ModifiedTabs/ModifiedTabLabelNew.js +0 -4
  61. package/es/components/ModifiedTabs/ModifiedTabLabelWithClose.js +0 -5
  62. package/es/components/ModifiedTabs/ModifiedTabs.js +24 -18
  63. package/es/components/NotificationsPanel/NotificationsPanel.js +125 -89
  64. package/es/components/OptionsTile/OptionsTile.js +6 -9
  65. package/es/components/PageHeader/PageHeader.js +19 -13
  66. package/es/components/PageHeader/PageHeaderTitle.js +10 -6
  67. package/es/components/ProductiveCard/ProductiveCard.js +23 -12
  68. package/es/components/RemoveModal/RemoveModal.js +0 -3
  69. package/es/components/SidePanel/SidePanel.js +54 -32
  70. package/es/components/TagSet/TagSet.js +13 -9
  71. package/es/components/TagSet/TagSetModal.js +16 -12
  72. package/es/components/TagSet/TagSetOverflow.js +21 -13
  73. package/es/components/Tearsheet/Tearsheet.js +27 -18
  74. package/es/components/Tearsheet/TearsheetNarrow.js +18 -15
  75. package/es/components/Tearsheet/TearsheetShell.js +3 -4
  76. package/es/components/Toolbar/ToolbarButton.js +0 -3
  77. package/es/components/WebTerminal/WebTerminal.js +18 -19
  78. package/es/components/index.js +2 -2
  79. package/es/global/js/hooks/index.js +1 -0
  80. package/es/global/js/hooks/useActiveElement.js +27 -0
  81. package/es/global/js/package-settings.js +2 -1
  82. package/es/global/js/utils/Wrap.js +7 -5
  83. package/es/global/js/utils/getScrollbarWidth.js +14 -0
  84. package/es/settings.js +0 -5
  85. package/lib/components/APIKeyModal/APIKeyModal.js +10 -13
  86. package/lib/components/ActionBar/ActionBar.js +0 -3
  87. package/lib/components/ActionBar/ActionBarItem.js +2 -6
  88. package/lib/components/ActionSet/ActionSet.js +11 -13
  89. package/lib/components/AddSelect/AddSelect.js +126 -72
  90. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +71 -0
  91. package/lib/components/AddSelect/AddSelectList.js +112 -0
  92. package/lib/components/AddSelect/AddSelectSidebar.js +122 -0
  93. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +5 -5
  94. package/lib/components/ButtonMenu/ButtonMenu.js +6 -4
  95. package/lib/components/ButtonMenu/ButtonMenuItem.js +1 -2
  96. package/lib/components/Card/Card.js +37 -25
  97. package/lib/components/Card/CardFooter.js +14 -10
  98. package/lib/components/Card/CardHeader.js +8 -6
  99. package/lib/components/Cascade/Cascade.js +5 -4
  100. package/lib/components/ComboButton/ComboButton.js +0 -4
  101. package/lib/components/ComboButton/ComboButtonItem/index.js +0 -5
  102. package/lib/components/CreateFullPage/CreateFullPageStep.js +17 -14
  103. package/lib/components/CreateModal/CreateModal.js +1 -4
  104. package/lib/components/CreateTearsheet/CreateTearsheet.js +10 -11
  105. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +20 -20
  106. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +438 -0
  107. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +161 -0
  108. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +80 -0
  109. package/lib/components/DataSpreadsheet/createActiveCellFn.js +56 -0
  110. package/lib/components/DataSpreadsheet/generateData.js +58 -0
  111. package/lib/components/DataSpreadsheet/getCellSize.js +39 -0
  112. package/lib/components/DataSpreadsheet/index.js +13 -0
  113. package/lib/components/EditSidePanel/EditSidePanel.js +9 -10
  114. package/lib/components/EmptyStates/EmptyState.js +10 -9
  115. package/lib/components/EmptyStates/EmptyStateContent.js +2 -2
  116. package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +4 -8
  117. package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +4 -8
  118. package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +4 -8
  119. package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +4 -8
  120. package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +4 -8
  121. package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +4 -8
  122. package/lib/components/ExampleComponent/ExampleComponent.js +12 -13
  123. package/lib/components/ExportModal/ExportModal.js +13 -9
  124. package/lib/components/ExpressiveCard/ExpressiveCard.js +0 -8
  125. package/lib/components/ImportModal/ImportModal.js +7 -5
  126. package/lib/components/InlineEdit/InlineEdit.js +253 -87
  127. package/lib/components/LoadingBar/LoadingBar.js +13 -17
  128. package/lib/components/ModifiedTabs/ModifiedTabLabelNew.js +0 -4
  129. package/lib/components/ModifiedTabs/ModifiedTabLabelWithClose.js +0 -5
  130. package/lib/components/ModifiedTabs/ModifiedTabs.js +24 -18
  131. package/lib/components/NotificationsPanel/NotificationsPanel.js +122 -87
  132. package/lib/components/OptionsTile/OptionsTile.js +6 -9
  133. package/lib/components/PageHeader/PageHeader.js +18 -12
  134. package/lib/components/PageHeader/PageHeaderTitle.js +10 -6
  135. package/lib/components/ProductiveCard/ProductiveCard.js +24 -18
  136. package/lib/components/RemoveModal/RemoveModal.js +0 -3
  137. package/lib/components/SidePanel/SidePanel.js +54 -32
  138. package/lib/components/TagSet/TagSet.js +13 -9
  139. package/lib/components/TagSet/TagSetModal.js +17 -13
  140. package/lib/components/TagSet/TagSetOverflow.js +24 -19
  141. package/lib/components/Tearsheet/Tearsheet.js +26 -17
  142. package/lib/components/Tearsheet/TearsheetNarrow.js +18 -15
  143. package/lib/components/Tearsheet/TearsheetShell.js +2 -3
  144. package/lib/components/Toolbar/ToolbarButton.js +0 -3
  145. package/lib/components/WebTerminal/WebTerminal.js +18 -19
  146. package/lib/components/index.js +8 -8
  147. package/lib/global/js/hooks/index.js +8 -0
  148. package/lib/global/js/hooks/useActiveElement.js +39 -0
  149. package/lib/global/js/package-settings.js +2 -1
  150. package/lib/global/js/utils/Wrap.js +7 -5
  151. package/lib/global/js/utils/getScrollbarWidth.js +23 -0
  152. package/lib/settings.js +0 -6
  153. package/package.json +25 -23
  154. package/scss/components/AddSelect/_add-select.scss +59 -5
  155. package/scss/components/BreadcrumbWithOverflow/_index.scss +1 -1
  156. package/scss/components/CreateInfluencer/_create-influencer.scss +4 -4
  157. package/scss/components/CreateTearsheet/_create-tearsheet.scss +2 -2
  158. package/scss/components/CreateTearsheetNarrow/_storybook-styles.scss +0 -6
  159. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +102 -0
  160. package/scss/components/{CancelableTextEdit → DataSpreadsheet}/_index.scss +2 -2
  161. package/scss/components/DataSpreadsheet/_storybook-styles.scss +6 -0
  162. package/scss/components/EditSidePanel/_storybook-styles.scss +0 -8
  163. package/scss/components/InlineEdit/_inline-edit.scss +293 -10
  164. package/scss/components/InlineEdit/_storybook-styles.scss +12 -6
  165. package/scss/components/LoadingBar/_storybook-styles.scss +0 -5
  166. package/scss/components/NotificationsPanel/_notifications-panel.scss +2 -2
  167. package/scss/components/OptionsTile/_storybook-styles.scss +0 -7
  168. package/scss/components/PageHeader/_index.scss +1 -1
  169. package/scss/components/PageHeader/_page-header.scss +4 -1
  170. package/scss/components/ProductiveCard/_productive-card.scss +0 -4
  171. package/scss/components/SidePanel/_side-panel.scss +15 -6
  172. package/scss/components/StatusIcon/_index.scss +1 -1
  173. package/scss/components/StatusIcon/_status-icon.scss +4 -4
  174. package/scss/components/TagSet/_index.scss +1 -1
  175. package/scss/components/UserProfileImage/_index.scss +1 -1
  176. package/scss/components/UserProfileImage/_user-profile-image.scss +2 -2
  177. package/scss/components/WebTerminal/_web-terminal.scss +2 -2
  178. package/scss/components/_index.scss +1 -1
  179. package/scss/global/styles/_project-settings.scss +5 -1
  180. package/es/components/CancelableTextEdit/CancelableTextEdit.js +0 -245
  181. package/es/generated/feature-flags/feature-flags.js +0 -15
  182. package/lib/components/CancelableTextEdit/CancelableTextEdit.js +0 -265
  183. package/lib/components/CancelableTextEdit/index.js +0 -13
  184. package/lib/generated/feature-flags/feature-flags.js +0 -22
  185. package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +0 -211
  186. package/scss/components/CancelableTextEdit/_storybook-styles.scss +0 -15
  187. package/scss/generated/feature-flags/_feature-flags.scss +0 -19
@@ -46,7 +46,8 @@ var NotificationsEmptyState = /*#__PURE__*/_react.default.forwardRef(function (_
46
46
  className = _ref.className,
47
47
  illustrationTheme = _ref.illustrationTheme,
48
48
  link = _ref.link,
49
- size = _ref.size,
49
+ _ref$size = _ref.size,
50
+ size = _ref$size === void 0 ? _EmptyState.defaults.size : _ref$size,
50
51
  subtitle = _ref.subtitle,
51
52
  title = _ref.title,
52
53
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
@@ -114,15 +115,10 @@ NotificationsEmptyState.propTypes = {
114
115
  /**
115
116
  * Empty state subtitle
116
117
  */
117
- subtitle: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]).isRequired,
118
+ subtitle: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]),
118
119
 
119
120
  /**
120
121
  * Empty state title
121
122
  */
122
123
  title: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]).isRequired
123
- }; // Default values for component props. Default values are not required for
124
- // props that are required, nor for props where the component can apply
125
- // 'undefined' values reasonably. Default values should be provided when the
126
- // component needs to make a choice or assumption when a prop is not supplied.
127
-
128
- NotificationsEmptyState.defaultProps = _EmptyState.EmptyStateDefaultProps;
124
+ };
@@ -46,7 +46,8 @@ var UnauthorizedEmptyState = /*#__PURE__*/_react.default.forwardRef(function (_r
46
46
  className = _ref.className,
47
47
  illustrationTheme = _ref.illustrationTheme,
48
48
  link = _ref.link,
49
- size = _ref.size,
49
+ _ref$size = _ref.size,
50
+ size = _ref$size === void 0 ? _EmptyState.defaults.size : _ref$size,
50
51
  subtitle = _ref.subtitle,
51
52
  title = _ref.title,
52
53
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
@@ -114,15 +115,10 @@ UnauthorizedEmptyState.propTypes = {
114
115
  /**
115
116
  * Empty state subtitle
116
117
  */
117
- subtitle: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]).isRequired,
118
+ subtitle: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]),
118
119
 
119
120
  /**
120
121
  * Empty state title
121
122
  */
122
123
  title: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]).isRequired
123
- }; // Default values for component props. Default values are not required for
124
- // props that are required, nor for props where the component can apply
125
- // 'undefined' values reasonably. Default values should be provided when the
126
- // component needs to make a choice or assumption when a prop is not supplied.
127
-
128
- UnauthorizedEmptyState.defaultProps = _EmptyState.EmptyStateDefaultProps;
124
+ };
@@ -32,7 +32,13 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
32
32
  // The block part of our conventional BEM class names (blockClass__E--M).
33
33
  var blockClass = "".concat(_settings.pkg.prefix, "--example-component");
34
34
  var componentName = 'ExampleComponent'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
35
+ // Default values for props
35
36
 
37
+ var defaults = {
38
+ primaryKind: 'primary',
39
+ secondaryKind: 'secondary',
40
+ size: 'default'
41
+ };
36
42
  /**
37
43
  * This is an example component to show relevant conventions and usage.
38
44
  */
@@ -45,10 +51,13 @@ var ExampleComponent = /*#__PURE__*/_react.default.forwardRef(function (_ref, re
45
51
  onPrimaryClick = _ref.onPrimaryClick,
46
52
  onSecondaryClick = _ref.onSecondaryClick,
47
53
  primaryButtonLabel = _ref.primaryButtonLabel,
48
- primaryKind = _ref.primaryKind,
54
+ _ref$primaryKind = _ref.primaryKind,
55
+ primaryKind = _ref$primaryKind === void 0 ? defaults.primaryKind : _ref$primaryKind,
49
56
  secondaryButtonLabel = _ref.secondaryButtonLabel,
50
- secondaryKind = _ref.secondaryKind,
51
- size = _ref.size,
57
+ _ref$secondaryKind = _ref.secondaryKind,
58
+ secondaryKind = _ref$secondaryKind === void 0 ? defaults.secondaryKind : _ref$secondaryKind,
59
+ _ref$size = _ref.size,
60
+ size = _ref$size === void 0 ? defaults.size : _ref$size,
52
61
  style = _ref.style,
53
62
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
54
63
  var modeClass = boxedBorder ? "".concat(blockClass, "--boxed-set") : "".concat(blockClass, "--shadow-set");
@@ -156,14 +165,4 @@ ExampleComponent.propTypes = {
156
165
  * Optional style settings for the containing node.
157
166
  */
158
167
  style: _propTypes.default.object
159
- }; // Default values for component props. Default values are not required for
160
- // props that are required, nor for props where the component can apply
161
- // 'undefined' values reasonably. Default values should be provided when the
162
- // component needs to make a choice or assumption when a prop is not supplied.
163
-
164
- ExampleComponent.defaultProps = {
165
- boxedBorder: false,
166
- primaryKind: 'primary',
167
- secondaryKind: 'secondary',
168
- size: 'default'
169
168
  };
@@ -43,7 +43,13 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
43
43
 
44
44
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
45
45
 
46
- var componentName = 'ExportModal';
46
+ var componentName = 'ExportModal'; // Default values for props
47
+
48
+ var defaults = {
49
+ inputType: 'text',
50
+ preformattedExtensions: Object.freeze([]),
51
+ validExtensions: Object.freeze([])
52
+ };
47
53
  var ExportModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
48
54
  var _preformattedExtensio;
49
55
 
@@ -54,14 +60,16 @@ var ExportModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
54
60
  filename = _ref.filename,
55
61
  hidePasswordLabel = _ref.hidePasswordLabel,
56
62
  inputLabel = _ref.inputLabel,
57
- inputType = _ref.inputType,
63
+ _ref$inputType = _ref.inputType,
64
+ inputType = _ref$inputType === void 0 ? defaults.inputType : _ref$inputType,
58
65
  invalidInputText = _ref.invalidInputText,
59
66
  loading = _ref.loading,
60
67
  loadingMessage = _ref.loadingMessage,
61
68
  onClose = _ref.onClose,
62
69
  onRequestSubmit = _ref.onRequestSubmit,
63
70
  open = _ref.open,
64
- preformattedExtensions = _ref.preformattedExtensions,
71
+ _ref$preformattedExte = _ref.preformattedExtensions,
72
+ preformattedExtensions = _ref$preformattedExte === void 0 ? defaults.preformattedExtensions : _ref$preformattedExte,
65
73
  preformattedExtensionsLabel = _ref.preformattedExtensionsLabel,
66
74
  primaryButtonText = _ref.primaryButtonText,
67
75
  secondaryButtonText = _ref.secondaryButtonText,
@@ -69,7 +77,8 @@ var ExportModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
69
77
  successMessage = _ref.successMessage,
70
78
  successful = _ref.successful,
71
79
  title = _ref.title,
72
- validExtensions = _ref.validExtensions,
80
+ _ref$validExtensions = _ref.validExtensions,
81
+ validExtensions = _ref$validExtensions === void 0 ? defaults.validExtensions : _ref$validExtensions,
73
82
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
74
83
 
75
84
  var _useState = (0, _react.useState)(filename),
@@ -317,9 +326,4 @@ ExportModal.propTypes = {
317
326
  */
318
327
  validExtensions: _propTypes.default.array
319
328
  };
320
- ExportModal.defaultProps = {
321
- inputType: 'text',
322
- preformattedExtensions: [],
323
- validExtensions: []
324
- };
325
329
  ExportModal.displayName = componentName;
@@ -151,12 +151,4 @@ ExpressiveCard.propTypes = {
151
151
  */
152
152
  title: _propTypes.default.string
153
153
  };
154
- ExpressiveCard.defaultProps = {
155
- actionIcons: [],
156
- actionIconsPosition: 'bottom',
157
- mediaPosition: 'top',
158
- overflowActions: [],
159
- primaryButtonKind: 'primary',
160
- secondaryButtonKind: 'secondary'
161
- };
162
154
  ExpressiveCard.displayName = componentName;
@@ -47,9 +47,14 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
47
47
 
48
48
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
49
49
 
50
- var componentName = 'ImportModal';
50
+ var componentName = 'ImportModal'; // Default values for props
51
+
52
+ var defaults = {
53
+ accept: Object.freeze([])
54
+ };
51
55
  var ImportModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
52
- var accept = _ref.accept,
56
+ var _ref$accept = _ref.accept,
57
+ accept = _ref$accept === void 0 ? defaults.accept : _ref$accept,
53
58
  className = _ref.className,
54
59
  defaultErrorBody = _ref.defaultErrorBody,
55
60
  defaultErrorHeader = _ref.defaultErrorHeader,
@@ -438,7 +443,4 @@ ImportModal.propTypes = {
438
443
  */
439
444
  title: _propTypes.default.string.isRequired
440
445
  };
441
- ImportModal.defaultProps = {
442
- accept: []
443
- };
444
446
  ImportModal.displayName = componentName;
@@ -27,107 +27,273 @@ var _devtools = require("../../global/js/utils/devtools");
27
27
 
28
28
  var _settings = require("../../settings");
29
29
 
30
- var _ = require("../");
31
-
32
30
  var _carbonComponentsReact = require("carbon-components-react");
33
31
 
34
32
  var _iconsReact = require("@carbon/icons-react");
35
33
 
36
- var _excluded = ["className", "disabled", "editDescription", "id", "inline", "invalid", "invalidText", "labelText", "onChange", "onInput", "onRevert", "revertDescription", "saveDescription", "saveDisabled", "size", "value", "warn", "warnText"];
34
+ var _excluded = ["cancelDescription", "className", "disabled", "editDescription", "editVisibleOnHoverOnly", "id", "invalid", "invalidText", "labelText", "light", "onCancel", "onSave", "onChange", "placeholder", "saveDescription", "size", "value", "warn", "warnText"];
37
35
 
38
36
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
39
37
 
40
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
41
39
 
42
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
43
-
44
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
45
-
46
40
  // The block part of our conventional BEM class names (blockClass__E--M).
47
41
  var blockClass = "".concat(_settings.pkg.prefix, "--inline-edit");
48
42
  var componentName = 'InlineEdit'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
49
43
 
44
+ var defaults = {
45
+ light: true,
46
+ // defaults to true to reflect design
47
+ size: 'md'
48
+ };
50
49
  /**
51
50
  * TODO: A description of the component.
52
51
  */
53
52
 
54
- var InlineEdit = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
55
- var className = _ref.className,
53
+ var InlineEdit = /*#__PURE__*/_react.default.forwardRef(function (_ref, refIn) {
54
+ var _cx, _refInput$current, _refInput$current$inn, _cx3;
55
+
56
+ var cancelDescription = _ref.cancelDescription,
57
+ className = _ref.className,
56
58
  disabled = _ref.disabled,
57
59
  editDescription = _ref.editDescription,
60
+ editVisibleOnHoverOnly = _ref.editVisibleOnHoverOnly,
58
61
  id = _ref.id,
59
- inline = _ref.inline,
60
62
  invalid = _ref.invalid,
61
63
  invalidText = _ref.invalidText,
62
64
  labelText = _ref.labelText,
65
+ _ref$light = _ref.light,
66
+ light = _ref$light === void 0 ? defaults.light : _ref$light,
67
+ onCancel = _ref.onCancel,
68
+ onSave = _ref.onSave,
63
69
  onChange = _ref.onChange,
64
- onInput = _ref.onInput,
65
- onRevert = _ref.onRevert,
66
- revertDescription = _ref.revertDescription,
70
+ placeholder = _ref.placeholder,
67
71
  saveDescription = _ref.saveDescription,
68
- saveDisabled = _ref.saveDisabled,
69
- size = _ref.size,
72
+ _ref$size = _ref.size,
73
+ size = _ref$size === void 0 ? defaults.size : _ref$size,
70
74
  value = _ref.value,
71
75
  warn = _ref.warn,
72
76
  warnText = _ref.warnText,
73
77
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
78
+ var refInput = (0, _react.useRef)(null);
79
+ var localRef = (0, _react.useRef)(null);
80
+ var ref = refIn || localRef;
74
81
 
75
82
  var _useState = (0, _react.useState)(false),
76
83
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
77
84
  editing = _useState2[0],
78
85
  setEditing = _useState2[1];
79
86
 
80
- var handleEdit = function handleEdit() {
81
- return setEditing(function (prev) {
82
- return !prev;
83
- });
87
+ var _useState3 = (0, _react.useState)(value),
88
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
89
+ internalValue = _useState4[0],
90
+ setInternalValue = _useState4[1];
91
+
92
+ var showValidation = invalid || warn;
93
+ var validationText = invalidText || warnText;
94
+ var validationIcon = showValidation ? invalid ? /*#__PURE__*/_react.default.createElement(_iconsReact.WarningFilled16, null) : /*#__PURE__*/_react.default.createElement(_iconsReact.WarningAltFilled16, null) : null;
95
+
96
+ var doSetEditing = function doSetEditing(value) {
97
+ if (value === false) {
98
+ // move scroll to start
99
+ refInput.current.scrollLeft = 0;
100
+ }
101
+
102
+ setEditing(!disabled && value);
103
+ };
104
+
105
+ var handleEdit = function handleEdit(ev) {
106
+ if (!disabled) {
107
+ var rightOfInput = ev.currentTarget.classList.contains("".concat(blockClass, "__edit")) || ev.target.classList.contains("".concat(blockClass, "__after-input-elements"));
108
+ var leftOfInput = ev.currentTarget = ev.target.classList.contains("".concat(blockClass)); // clicking on the content editable element should not set either of these to true
109
+
110
+ if (rightOfInput || leftOfInput) {
111
+ doSetEditing(true);
112
+ setTimeout(function () {
113
+ refInput.current.focus(); // select all the content
114
+
115
+ document.getSelection().selectAllChildren(refInput.current);
116
+
117
+ if (rightOfInput) {
118
+ document.getSelection().collapseToEnd();
119
+ refInput.current.scrollLeft = 9999; // never going to get there but ensures at end.
120
+ } else {
121
+ document.getSelection().collapseToStart();
122
+ refInput.current.scrollLeft = 0; // scroll to start
123
+ }
124
+ }, 0);
125
+ }
126
+ }
127
+ };
128
+
129
+ var handleFocus = function handleFocus(ev) {
130
+ ev.preventDefault();
131
+
132
+ if (!editing && ev.target.classList.contains("".concat(blockClass, "__input"))) {
133
+ doSetEditing(true);
134
+ }
135
+ };
136
+
137
+ var handleSave = function handleSave() {
138
+ doSetEditing(false);
139
+ document.getSelection().removeAllRanges();
140
+
141
+ if (onSave) {
142
+ onSave(refInput.current.innerText);
143
+ }
144
+ };
145
+
146
+ var handleInput = function handleInput() {
147
+ setInternalValue(refInput.current.innerText);
148
+
149
+ if (onChange) {
150
+ onChange(refInput.current.innerText);
151
+ }
152
+ };
153
+
154
+ var handlePaste = function handlePaste(ev) {
155
+ ev.preventDefault(); // Get clipboard as plain text
156
+
157
+ var text = (ev.clipboardData || window.clipboardData).getData('text/plain'); // remove \n
158
+
159
+ var sanitizedText = text.replaceAll(/\n/g, '') // remove carriage returns
160
+ .replaceAll(/\t/g, ' '); // replace tab with two spaces
161
+
162
+ if (document.queryCommandSupported('insertText')) {
163
+ document.execCommand('insertText', false, sanitizedText);
164
+ } else {
165
+ // Insert text at the current position of caret
166
+ var range = document.getSelection().getRangeAt(0);
167
+ range.deleteContents();
168
+ var textNode = document.createTextNode(sanitizedText);
169
+ range.insertNode(textNode); // move selection end of textNode
170
+
171
+ range.selectNodeContents(textNode);
172
+ range.collapse(false); // remove existing range
173
+
174
+ var selection = document.getSelection();
175
+ selection.removeAllRanges(); // set the new range
176
+
177
+ selection.addRange(range);
178
+ }
84
179
  };
85
180
 
86
- var handleChange = function handleChange(val) {
87
- setEditing(false);
88
- onChange(val);
181
+ var handleCancel = function handleCancel() {
182
+ refInput.current.innerText = value;
183
+ handleInput(value);
184
+ doSetEditing(false);
185
+ document.getSelection().removeAllRanges();
186
+
187
+ if (onCancel) {
188
+ onCancel(value);
189
+ }
89
190
  };
90
191
 
91
- var handleRevert = function handleRevert() {
92
- setEditing(false);
93
- onRevert(value);
192
+ var handleBlur = function handleBlur(ev) {
193
+ if (!ref.current.contains(ev.relatedTarget)) {
194
+ handleSave();
195
+ }
94
196
  };
95
197
 
96
- var stdProps = _objectSpread(_objectSpread({}, rest), {}, {
97
- className: (0, _classnames.default)(blockClass, // Apply the block class to the main HTML element
98
- className, // Apply any supplied class names to the main HTML element.
99
- (0, _defineProperty2.default)({}, "".concat(blockClass, "--editing"), editing)),
100
- id: id,
101
- size: size,
102
- ref: ref
103
- }, (0, _devtools.getDevtoolsProps)(componentName));
104
-
105
- return editing ? /*#__PURE__*/_react.default.createElement(_.CancelableTextEdit, (0, _extends2.default)({}, stdProps, {
106
- hideLabel: true,
107
- inline: inline,
108
- invalid: invalid,
109
- invalidText: invalidText,
110
- labelText: labelText,
111
- onChange: handleChange,
112
- onInput: onInput,
113
- onRevert: handleRevert,
114
- revertDescription: revertDescription,
115
- saveDescription: saveDescription,
116
- saveDisabled: saveDisabled,
117
- value: value,
118
- warn: warn,
119
- warnText: warnText
120
- })) : /*#__PURE__*/_react.default.createElement("div", stdProps, /*#__PURE__*/_react.default.createElement("div", {
121
- className: "".concat(blockClass, "__value")
122
- }, value), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
123
- className: "".concat(blockClass, "__button ").concat(_settings.carbon.prefix, "--btn--md"),
124
- kind: "ghost",
125
- hasIconOnly: true,
126
- iconDescription: editDescription,
127
- onClick: handleEdit,
128
- renderIcon: disabled ? _iconsReact.EditOff16 : _iconsReact.Edit16,
129
- disabled: disabled
130
- }));
198
+ var handleKeyDown = function handleKeyDown(ev) {
199
+ if (ev.key === 'Enter') {
200
+ ev.preventDefault();
201
+ refInput.current.blur(); // will cause save
202
+ }
203
+ };
204
+ /*
205
+ The HTML is structured as follows:
206
+ <container>
207
+ <!-- margin left of input to match Carbon -->
208
+ <content-editable>
209
+ <-- margin right of input space for after-input-elements -->
210
+ <after-input-elements>
211
+ </container>
212
+ NOTE:
213
+ - An input is not used as this would not permit a heading tag e.g. <h2>.
214
+ - Some padding is added to the left 16px standard for a Carbon text input
215
+ - The after-input-elements are position absolute with a margin to on the input to reserve space. Using inline-flex
216
+ - does not measure space properly for the input otherwise.
217
+ - The content editable is not expected to change size when buttons are added, to ensure the text does not move space
218
+ is reserved up front for buttons and invalid icon. Mostly this is only noticed if the width of the component is not 100%.
219
+ which can be shown by setting inlineEditFullWidth to false in storybook.
220
+ In making content-editable behave like an input of type text we have to account for.
221
+ - Enforcing a single line
222
+ - Pasting of non-text e.g. html or text with carriage returns
223
+ - The padding and border not hiding typed in text.
224
+ - Placing the cursor at the start or end depending on area clicked (before for left-padding)
225
+ */
226
+
227
+
228
+ var toolbarAnimation = true;
229
+ return (
230
+ /*#__PURE__*/
231
+ // eslint-disable-next-line
232
+ _react.default.createElement("div", {
233
+ className: (0, _classnames.default)(blockClass, // Apply the block class to the main HTML element
234
+ className, // Apply any supplied class names to the main HTML element.
235
+ "".concat(blockClass, "--").concat(size), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--disabled"), disabled), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--editing"), editing), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--invalid"), invalid), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--warn"), warn), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--light"), light), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--overflows"), refInput.current && refInput.current.scrollWidth > refInput.current.offsetWidth), _cx)),
236
+ onClick: handleEdit // disabled eslint for click handler
237
+ ,
238
+ onBlur: handleBlur,
239
+ ref: ref
240
+ }, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, (0, _devtools.getDevtoolsProps)(componentName), {
241
+ id: id,
242
+ size: size,
243
+ className: (0, _classnames.default)("".concat(blockClass, "__input"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__input--empty"), ((_refInput$current = refInput.current) === null || _refInput$current === void 0 ? void 0 : (_refInput$current$inn = _refInput$current.innerText) === null || _refInput$current$inn === void 0 ? void 0 : _refInput$current$inn.length) === 0)),
244
+ contentEditable: true,
245
+ "aria-label": labelText,
246
+ role: "textbox",
247
+ tabIndex: disabled ? -1 : 0,
248
+ onFocus: handleFocus,
249
+ onInput: handleInput,
250
+ onKeyDown: handleKeyDown,
251
+ onPaste: handlePaste,
252
+ suppressContentEditableWarning: true,
253
+ ref: refInput,
254
+ "data-placeholder": placeholder !== null && placeholder !== void 0 ? placeholder : labelText
255
+ }), value), /*#__PURE__*/_react.default.createElement("div", {
256
+ className: (0, _classnames.default)("".concat(blockClass, "__after-input-elements")) // tabindex -1 fixes blur target test when clicking on after-input-elements background
257
+ ,
258
+ tabIndex: "-1"
259
+ }, /*#__PURE__*/_react.default.createElement("div", {
260
+ className: "".concat(blockClass, "__ellipsis"),
261
+ "aria-hidden": !editing
262
+ }, "\u2026"), /*#__PURE__*/_react.default.createElement("div", {
263
+ className: (0, _classnames.default)("".concat(blockClass, "__toolbar"), (_cx3 = {}, (0, _defineProperty2.default)(_cx3, "".concat(blockClass, "__toolbar--animation"), toolbarAnimation), (0, _defineProperty2.default)(_cx3, "".concat(blockClass, "__toolbar--saveable"), refInput.current && value !== internalValue), _cx3))
264
+ }, showValidation && /*#__PURE__*/_react.default.createElement("div", {
265
+ className: "".concat(blockClass, "__validation-icon")
266
+ }, validationIcon), editing ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
267
+ className: "".concat(blockClass, "__cancel"),
268
+ kind: "ghost",
269
+ hasIconOnly: true,
270
+ iconDescription: cancelDescription,
271
+ onClick: handleCancel,
272
+ renderIcon: _iconsReact.Close16
273
+ }), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
274
+ className: "".concat(blockClass, "__save"),
275
+ kind: "ghost",
276
+ hasIconOnly: true,
277
+ iconDescription: saveDescription,
278
+ onClick: handleSave,
279
+ renderIcon: _iconsReact.Checkmark16,
280
+ disabled: value === internalValue
281
+ })) : /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
282
+ "aria-hidden": "true",
283
+ className: (0, _classnames.default)("".concat(blockClass, "__edit"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__edit--hover-visible"), editVisibleOnHoverOnly)),
284
+ kind: "ghost",
285
+ hasIconOnly: true,
286
+ iconDescription: editDescription,
287
+ onClick: handleEdit,
288
+ renderIcon: disabled ? _iconsReact.EditOff16 : _iconsReact.Edit16,
289
+ disabled: disabled,
290
+ tabIndex: -1
291
+ }))), /*#__PURE__*/_react.default.createElement("div", {
292
+ className: (0, _classnames.default)("".concat(blockClass, "__disabled-cover"))
293
+ }), showValidation && validationText && validationText.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
294
+ className: "".concat(blockClass, "__validation-text ").concat(_settings.carbon.prefix, "--form-requirement")
295
+ }, validationText))
296
+ );
131
297
  }); // Return a placeholder if not released and not enabled by feature flag
132
298
 
133
299
 
@@ -140,6 +306,11 @@ InlineEdit.displayName = componentName; // The types and DocGen commentary for t
140
306
  // See https://www.npmjs.com/package/prop-types#usage.
141
307
 
142
308
  InlineEdit.propTypes = {
309
+ /**
310
+ * label for cancel button
311
+ */
312
+ cancelDescription: _propTypes.default.string.isRequired,
313
+
143
314
  /**
144
315
  * Provide an optional class to be applied to the containing node.
145
316
  */
@@ -156,16 +327,15 @@ InlineEdit.propTypes = {
156
327
  editDescription: _propTypes.default.string.isRequired,
157
328
 
158
329
  /**
159
- * ID for inline edit
330
+ * In some scenarios the edit icon only needs to be shown on hover. These cases are where continual visibility of
331
+ * the edit icon is redundant. E.g. a spreadsheet a property panel.
160
332
  */
161
- id: _propTypes.default.string,
162
-
163
- /* TODO: add types and DocGen for all props. */
333
+ editVisibleOnHoverOnly: _propTypes.default.bool,
164
334
 
165
335
  /**
166
- * inline variant
167
- */
168
- inline: _propTypes.default.bool,
336
+ * ID for inline edit
337
+ */
338
+ id: _propTypes.default.string,
169
339
 
170
340
  /**
171
341
  * set invalid state for input
@@ -183,34 +353,38 @@ InlineEdit.propTypes = {
183
353
  labelText: _propTypes.default.string,
184
354
 
185
355
  /**
186
- * method called on change event
356
+ * change background to light version (mimic React TextInput)
187
357
  */
188
- onChange: _propTypes.default.func,
358
+ light: _propTypes.default.bool,
189
359
 
190
360
  /**
191
- * method called on input event
361
+ * method called on cancel event
192
362
  */
193
- onInput: _propTypes.default.func,
363
+ onCancel: _propTypes.default.func,
194
364
 
195
365
  /**
196
- * method called on revert event
366
+ * method called on input event (it's a React thing onChange behaves like on input).
367
+ *
368
+ * NOTE: caller to handle invalid/warn states and associated text
197
369
  */
198
- onRevert: _propTypes.default.func,
370
+ onChange: _propTypes.default.func,
199
371
 
200
372
  /**
201
- * label for revert button
373
+ * method called on change event
374
+ *
375
+ * NOTE: caller to handle invalid/warn states and associated text
202
376
  */
203
- revertDescription: _propTypes.default.string.isRequired,
377
+ onSave: _propTypes.default.func,
204
378
 
205
379
  /**
206
- * label for save button
380
+ * placeholder for text input
207
381
  */
208
- saveDescription: _propTypes.default.string.isRequired,
382
+ placeholder: _propTypes.default.string,
209
383
 
210
384
  /**
211
- * disabled state of the save button
385
+ * label for save button
212
386
  */
213
- saveDisabled: _propTypes.default.bool,
387
+ saveDescription: _propTypes.default.string.isRequired,
214
388
 
215
389
  /**
216
390
  * vertical size of control
@@ -231,12 +405,4 @@ InlineEdit.propTypes = {
231
405
  * text shown when warn true
232
406
  */
233
407
  warnText: _propTypes.default.string
234
- }; // Default values for component props. Default values are not required for
235
- // props that are required, nor for props where the component can apply
236
- // 'undefined' values reasonably. Default values should be provided when the
237
- // component needs to make a choice or assumption when a prop is not supplied.
238
-
239
- InlineEdit.defaultProps = {
240
- /* TODO: add defaults for relevant props. */
241
- size: 'md'
242
408
  };