@carbon/ibm-products 1.3.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. package/css/index-full-carbon.css +5102 -4711
  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 +189 -108
  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 +619 -236
  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 +950 -567
  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 +25 -29
  18. package/es/components/ActionBar/ActionBar.js +4 -1
  19. package/es/components/ActionSet/ActionSet.js +22 -10
  20. package/es/components/ActionSet/actions.js +25 -17
  21. package/es/components/AddSelect/AddSelect.js +141 -53
  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 +78 -0
  25. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +24 -17
  26. package/es/components/CancelableTextEdit/CancelableTextEdit.js +62 -24
  27. package/es/components/Card/Card.js +6 -4
  28. package/es/components/CreateFullPage/CreateFullPage.js +102 -258
  29. package/es/components/CreateFullPage/CreateFullPageStep.js +65 -13
  30. package/es/components/CreateFullPage/index.js +1 -2
  31. package/es/components/CreateInfluencer/CreateInfluencer.js +40 -220
  32. package/es/components/CreateTearsheet/CreateTearsheet.js +95 -146
  33. package/es/components/CreateTearsheet/CreateTearsheetStep.js +70 -20
  34. package/es/components/CreateTearsheet/index.js +0 -1
  35. package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +87 -28
  36. package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  37. package/es/components/EmptyStates/EmptyState.js +1 -1
  38. package/es/components/EmptyStates/EmptyStateContent.js +2 -2
  39. package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
  40. package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
  41. package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
  42. package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
  43. package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
  44. package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
  45. package/es/components/ExportModal/ExportModal.js +41 -12
  46. package/es/components/ImportModal/ImportModal.js +2 -1
  47. package/es/components/InlineEdit/InlineEdit.js +397 -0
  48. package/es/components/InlineEdit/index.js +7 -0
  49. package/es/components/MultiAddSelect/MultiAddSelect.js +16 -0
  50. package/es/components/MultiAddSelect/index.js +1 -0
  51. package/es/components/NotificationsPanel/NotificationsPanel.js +16 -3
  52. package/es/components/OptionsTile/OptionsTile.js +36 -15
  53. package/es/components/PageHeader/PageHeader.js +59 -35
  54. package/es/components/PageHeader/PageHeaderTitle.js +82 -7
  55. package/es/components/PageHeader/PageHeaderUtils.js +21 -2
  56. package/es/components/RemoveModal/RemoveModal.js +4 -2
  57. package/es/components/SidePanel/SidePanel.js +33 -16
  58. package/es/components/SingleAddSelect/SingleAddSelect.js +15 -0
  59. package/es/components/SingleAddSelect/index.js +1 -0
  60. package/es/components/TagSet/TagSet.js +4 -1
  61. package/es/components/Tearsheet/Tearsheet.js +1 -1
  62. package/es/components/Tearsheet/TearsheetNarrow.js +1 -1
  63. package/es/components/Tearsheet/TearsheetShell.js +1 -1
  64. package/es/components/Toolbar/Toolbar.js +69 -8
  65. package/es/components/WebTerminal/WebTerminal.js +1 -1
  66. package/es/components/index.js +4 -2
  67. package/es/global/js/hooks/index.js +1 -0
  68. package/es/global/js/hooks/useCreateComponentFocus.js +15 -19
  69. package/es/global/js/hooks/useCreateComponentStepChange.js +69 -79
  70. package/es/global/js/hooks/useResetCreateComponent.js +7 -4
  71. package/es/global/js/hooks/useRetrieveStepData.js +51 -0
  72. package/es/global/js/hooks/useValidCreateStepCount.js +4 -7
  73. package/es/global/js/package-settings.js +4 -2
  74. package/es/global/js/utils/lastIndexInArray.js +26 -0
  75. package/es/settings.js +0 -5
  76. package/lib/components/APIKeyModal/APIKeyModal.js +25 -29
  77. package/lib/components/ActionBar/ActionBar.js +4 -1
  78. package/lib/components/ActionSet/ActionSet.js +22 -10
  79. package/lib/components/ActionSet/actions.js +25 -17
  80. package/lib/components/AddSelect/AddSelect.js +141 -50
  81. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +71 -0
  82. package/lib/components/AddSelect/AddSelectList.js +112 -0
  83. package/lib/components/AddSelect/AddSelectSidebar.js +89 -0
  84. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +23 -16
  85. package/lib/components/CancelableTextEdit/CancelableTextEdit.js +62 -23
  86. package/lib/components/Card/Card.js +6 -4
  87. package/lib/components/CreateFullPage/CreateFullPage.js +102 -258
  88. package/lib/components/CreateFullPage/CreateFullPageStep.js +68 -13
  89. package/lib/components/CreateFullPage/index.js +1 -9
  90. package/lib/components/CreateInfluencer/CreateInfluencer.js +38 -231
  91. package/lib/components/CreateTearsheet/CreateTearsheet.js +97 -148
  92. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +72 -19
  93. package/lib/components/CreateTearsheet/index.js +0 -8
  94. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +86 -34
  95. package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  96. package/lib/components/EmptyStates/EmptyState.js +1 -1
  97. package/lib/components/EmptyStates/EmptyStateContent.js +2 -2
  98. package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
  99. package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
  100. package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
  101. package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
  102. package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
  103. package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
  104. package/lib/components/ExportModal/ExportModal.js +38 -11
  105. package/lib/components/ImportModal/ImportModal.js +2 -1
  106. package/lib/components/InlineEdit/InlineEdit.js +413 -0
  107. package/lib/components/InlineEdit/index.js +13 -0
  108. package/lib/components/MultiAddSelect/MultiAddSelect.js +37 -0
  109. package/lib/components/MultiAddSelect/index.js +13 -0
  110. package/lib/components/NotificationsPanel/NotificationsPanel.js +13 -1
  111. package/lib/components/OptionsTile/OptionsTile.js +36 -15
  112. package/lib/components/PageHeader/PageHeader.js +59 -35
  113. package/lib/components/PageHeader/PageHeaderTitle.js +91 -9
  114. package/lib/components/PageHeader/PageHeaderUtils.js +21 -2
  115. package/lib/components/RemoveModal/RemoveModal.js +4 -2
  116. package/lib/components/SidePanel/SidePanel.js +33 -16
  117. package/lib/components/SingleAddSelect/SingleAddSelect.js +36 -0
  118. package/lib/components/SingleAddSelect/index.js +13 -0
  119. package/lib/components/TagSet/TagSet.js +4 -1
  120. package/lib/components/Tearsheet/Tearsheet.js +1 -1
  121. package/lib/components/Tearsheet/TearsheetNarrow.js +1 -1
  122. package/lib/components/Tearsheet/TearsheetShell.js +1 -1
  123. package/lib/components/Toolbar/Toolbar.js +69 -6
  124. package/lib/components/WebTerminal/WebTerminal.js +1 -1
  125. package/lib/components/index.js +25 -9
  126. package/lib/global/js/hooks/index.js +8 -0
  127. package/lib/global/js/hooks/useCreateComponentFocus.js +15 -19
  128. package/lib/global/js/hooks/useCreateComponentStepChange.js +69 -79
  129. package/lib/global/js/hooks/useResetCreateComponent.js +7 -4
  130. package/lib/global/js/hooks/useRetrieveStepData.js +62 -0
  131. package/lib/global/js/hooks/useValidCreateStepCount.js +4 -7
  132. package/lib/global/js/package-settings.js +4 -2
  133. package/lib/global/js/utils/lastIndexInArray.js +35 -0
  134. package/lib/settings.js +0 -6
  135. package/package.json +24 -24
  136. package/scss/components/AddSelect/_add-select.scss +53 -8
  137. package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +19 -15
  138. package/scss/components/BreadcrumbWithOverflow/_index.scss +1 -1
  139. package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +142 -70
  140. package/scss/components/CancelableTextEdit/_storybook-styles.scss +0 -7
  141. package/scss/components/CreateFullPage/_create-full-page.scss +4 -11
  142. package/scss/components/CreateInfluencer/_create-influencer.scss +4 -4
  143. package/scss/components/CreateTearsheet/_create-tearsheet.scss +6 -10
  144. package/scss/components/CreateTearsheetNarrow/_storybook-styles.scss +0 -6
  145. package/scss/components/EditSidePanel/_storybook-styles.scss +0 -8
  146. package/scss/components/InlineEdit/_index.scss +8 -0
  147. package/scss/components/InlineEdit/_inline-edit.scss +320 -0
  148. package/scss/components/InlineEdit/_storybook-styles.scss +21 -0
  149. package/scss/components/LoadingBar/_storybook-styles.scss +0 -5
  150. package/scss/components/MultiAddSelect/_index.scss +1 -0
  151. package/scss/components/MultiAddSelect/_multi-add-select.scss +1 -0
  152. package/scss/components/MultiAddSelect/_storybook-styles.scss +6 -0
  153. package/scss/components/NotificationsPanel/_notifications-panel.scss +2 -2
  154. package/scss/components/OptionsTile/_storybook-styles.scss +0 -7
  155. package/scss/components/PageHeader/_index.scss +1 -1
  156. package/scss/components/PageHeader/_page-header.scss +18 -5
  157. package/scss/components/ProductiveCard/_productive-card.scss +0 -4
  158. package/scss/components/SidePanel/_side-panel.scss +15 -6
  159. package/scss/components/SingleAddSelect/_index.scss +1 -0
  160. package/scss/components/SingleAddSelect/_single-add-select.scss +1 -0
  161. package/scss/components/SingleAddSelect/_storybook-styles.scss +6 -0
  162. package/scss/components/StatusIcon/_index.scss +1 -1
  163. package/scss/components/StatusIcon/_status-icon.scss +6 -4
  164. package/scss/components/TagSet/_index.scss +1 -1
  165. package/scss/components/UserProfileImage/_index.scss +1 -1
  166. package/scss/components/UserProfileImage/_user-profile-image.scss +2 -2
  167. package/scss/components/WebTerminal/_web-terminal.scss +2 -2
  168. package/scss/components/_index.scss +3 -1
  169. package/scss/global/styles/_project-settings.scss +5 -1
  170. package/es/components/CreateFullPage/CreateFullPageSection.js +0 -53
  171. package/es/components/CreateFullPage/constants.js +0 -8
  172. package/es/components/CreateTearsheet/CreateTearsheetSection.js +0 -83
  173. package/es/components/CreateTearsheet/constants.js +0 -8
  174. package/es/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -327
  175. package/es/generated/feature-flags/feature-flags.js +0 -15
  176. package/es/global/js/utils/hasValidType.js +0 -94
  177. package/lib/components/CreateFullPage/CreateFullPageSection.js +0 -74
  178. package/lib/components/CreateFullPage/constants.js +0 -16
  179. package/lib/components/CreateTearsheet/CreateTearsheetSection.js +0 -105
  180. package/lib/components/CreateTearsheet/constants.js +0 -17
  181. package/lib/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -354
  182. package/lib/generated/feature-flags/feature-flags.js +0 -22
  183. package/lib/global/js/utils/hasValidType.js +0 -110
  184. package/scss/generated/feature-flags/_feature-flags.scss +0 -19
@@ -0,0 +1,397 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
+ var _excluded = ["cancelDescription", "className", "disabled", "editDescription", "editVisibleOnHoverOnly", "id", "invalid", "invalidText", "labelText", "light", "onCancel", "onSave", "onChange", "placeholder", "saveDescription", "saveDisabled", "size", "value", "warn", "warnText"];
6
+
7
+ /**
8
+ * Copyright IBM Corp. 2022, 2022
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
+ // Import portions of React that are needed.
14
+ import React, { useRef, useState } from 'react'; // Other standard imports.
15
+
16
+ import PropTypes from 'prop-types';
17
+ import cx from 'classnames';
18
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
19
+ import { pkg, carbon } from '../../settings'; // Carbon and package components we use.
20
+
21
+ /* TODO: @import(s) of carbon components and other package components. */
22
+
23
+ import { Button } from 'carbon-components-react';
24
+ import { Close16, Edit16, EditOff16, Checkmark16, WarningFilled16, WarningAltFilled16 } from '@carbon/icons-react'; // The block part of our conventional BEM class names (blockClass__E--M).
25
+
26
+ var blockClass = "".concat(pkg.prefix, "--inline-edit");
27
+ var componentName = 'InlineEdit'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
28
+
29
+ /**
30
+ * TODO: A description of the component.
31
+ */
32
+
33
+ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
34
+ var _cx, _cx3;
35
+
36
+ var cancelDescription = _ref.cancelDescription,
37
+ className = _ref.className,
38
+ disabled = _ref.disabled,
39
+ editDescription = _ref.editDescription,
40
+ editVisibleOnHoverOnly = _ref.editVisibleOnHoverOnly,
41
+ id = _ref.id,
42
+ invalid = _ref.invalid,
43
+ invalidText = _ref.invalidText,
44
+ labelText = _ref.labelText,
45
+ light = _ref.light,
46
+ onCancel = _ref.onCancel,
47
+ onSave = _ref.onSave,
48
+ onChange = _ref.onChange,
49
+ placeholder = _ref.placeholder,
50
+ saveDescription = _ref.saveDescription,
51
+ saveDisabled = _ref.saveDisabled,
52
+ size = _ref.size,
53
+ value = _ref.value,
54
+ warn = _ref.warn,
55
+ warnText = _ref.warnText,
56
+ rest = _objectWithoutProperties(_ref, _excluded);
57
+
58
+ var refInput = useRef(null);
59
+ var localRef = useRef(null);
60
+ var ref = refIn || localRef;
61
+
62
+ var _useState = useState(false),
63
+ _useState2 = _slicedToArray(_useState, 2),
64
+ editing = _useState2[0],
65
+ setEditing = _useState2[1];
66
+
67
+ var _useState3 = useState(value),
68
+ _useState4 = _slicedToArray(_useState3, 2),
69
+ internalValue = _useState4[0],
70
+ setInternalValue = _useState4[1];
71
+
72
+ var showValidationText = invalid || warn;
73
+ var validationText = invalidText || warnText;
74
+ var validationIcon = showValidationText ? invalid ? /*#__PURE__*/React.createElement(WarningFilled16, null) : /*#__PURE__*/React.createElement(WarningAltFilled16, null) : null;
75
+
76
+ var doSetEditing = function doSetEditing(value) {
77
+ if (value === false) {
78
+ // move scroll to start
79
+ refInput.current.scrollLeft = 0;
80
+ }
81
+
82
+ setEditing(!disabled && value);
83
+ };
84
+
85
+ var handleEdit = function handleEdit(ev) {
86
+ if (!disabled) {
87
+ var rightOfInput = ev.currentTarget.classList.contains("".concat(blockClass, "__edit")) || ev.target.classList.contains("".concat(blockClass, "__after-input-elements"));
88
+ var leftOfInput = ev.currentTarget = ev.target.classList.contains("".concat(blockClass)); // clicking on the content editable element should not set either of these to true
89
+
90
+ if (rightOfInput || leftOfInput) {
91
+ doSetEditing(true);
92
+ setTimeout(function () {
93
+ refInput.current.focus(); // select all the content
94
+
95
+ document.getSelection().selectAllChildren(refInput.current);
96
+
97
+ if (rightOfInput) {
98
+ document.getSelection().collapseToEnd();
99
+ refInput.current.scrollLeft = 9999; // never going to get there but ensures at end.
100
+ } else {
101
+ document.getSelection().collapseToStart();
102
+ refInput.current.scrollLeft = 0; // scroll to start
103
+ }
104
+ }, 0);
105
+ }
106
+ }
107
+ };
108
+
109
+ var handleFocus = function handleFocus(ev) {
110
+ ev.preventDefault();
111
+
112
+ if (!editing && ev.target.classList.contains("".concat(blockClass, "__input"))) {
113
+ doSetEditing(true);
114
+ }
115
+ };
116
+
117
+ var handleSave = function handleSave() {
118
+ doSetEditing(false);
119
+ document.getSelection().removeAllRanges();
120
+
121
+ if (onSave) {
122
+ onSave(refInput.current.innerText);
123
+ }
124
+ };
125
+
126
+ var handlePaste = function handlePaste(ev) {
127
+ ev.preventDefault(); // Get clipboard as plain text
128
+
129
+ var text = (ev.clipboardData || window.clipboardData).getData('text/plain'); // remove \n
130
+
131
+ var sanitizedText = text.replaceAll(/\n/g, '') // remove carriage returns
132
+ .replaceAll(/\t/g, ' '); // replace tab with two spaces
133
+
134
+ if (document.queryCommandSupported('insertText')) {
135
+ document.execCommand('insertText', false, sanitizedText);
136
+ } else {
137
+ // Insert text at the current position of caret
138
+ var range = document.getSelection().getRangeAt(0);
139
+ range.deleteContents();
140
+ var textNode = document.createTextNode(sanitizedText);
141
+ range.insertNode(textNode); // move selection end of textNode
142
+
143
+ range.selectNodeContents(textNode);
144
+ range.collapse(false); // remove existing range
145
+
146
+ var selection = document.getSelection();
147
+ selection.removeAllRanges(); // set the new range
148
+
149
+ selection.addRange(range);
150
+ }
151
+ };
152
+
153
+ var handleInput = function handleInput() {
154
+ setInternalValue(refInput.current.innerText);
155
+
156
+ if (onChange) {
157
+ onChange(refInput.current.innerText);
158
+ }
159
+ };
160
+
161
+ var handleCancel = function handleCancel() {
162
+ refInput.current.innerText = value;
163
+ handleInput(value);
164
+ doSetEditing(false);
165
+ document.getSelection().removeAllRanges();
166
+
167
+ if (onCancel) {
168
+ onCancel(value);
169
+ }
170
+ };
171
+
172
+ var handleBlur = function handleBlur(ev) {
173
+ if (!ref.current.contains(ev.relatedTarget)) {
174
+ doSetEditing(false);
175
+ handleSave();
176
+ }
177
+ };
178
+
179
+ var handleKeyDown = function handleKeyDown(ev) {
180
+ if (ev.key === 'Enter') {
181
+ ev.preventDefault();
182
+ refInput.current.blur(); // will cause save
183
+ }
184
+ };
185
+ /*
186
+ The HTML is structured as follows:
187
+ <container>
188
+ <!-- margin left of input to match Carbon -->
189
+ <content-editable>
190
+ <-- margin right of input space for after-input-elements -->
191
+ <after-input-elements>
192
+ </container>
193
+ NOTE:
194
+ - An input is not used as this would not permit a heading tag e.g. <h2>.
195
+ - Some padding is added to the left 16px standard for a Carbon text input
196
+ - The after-input-elements are position absolute with a margin to on the input to reserve space. Using inline-flex
197
+ - does not measure space properly for the input otherwise.
198
+ - The content editable is not expected to change size when buttons are added, to ensure the text does not move space
199
+ is reserved up front for buttons and invalid icon. Mostly this is only noticed if the width of the component is not 100%.
200
+ which can be shown by setting inlineEditFullWidth to false in storybook.
201
+ In making content-editable behave like an input of type text we have to account for.
202
+ - Enforcing a single line
203
+ - Pasting of non-text e.g. html or text with carriage returns
204
+ - The padding and border not hiding typed in text.
205
+ - Placing the cursor at the start or end depending on area clicked (before for left-padding)
206
+ */
207
+
208
+
209
+ var toolbarAnimation = true;
210
+ return (
211
+ /*#__PURE__*/
212
+ // eslint-disable-next-line
213
+ React.createElement("div", {
214
+ className: cx(blockClass, // Apply the block class to the main HTML element
215
+ className, // Apply any supplied class names to the main HTML element.
216
+ "".concat(blockClass, "--").concat(size), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--disabled"), disabled), _defineProperty(_cx, "".concat(blockClass, "--editing"), editing), _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _defineProperty(_cx, "".concat(blockClass, "--warn"), warn), _defineProperty(_cx, "".concat(blockClass, "--light"), light), _defineProperty(_cx, "".concat(blockClass, "--overflows"), refInput.current && refInput.current.scrollWidth > refInput.current.offsetWidth), _cx)),
217
+ onClick: handleEdit // disabled eslint for click handler
218
+ ,
219
+ onBlur: handleBlur,
220
+ ref: ref
221
+ }, /*#__PURE__*/React.createElement("div", _extends({}, rest, getDevtoolsProps(componentName), {
222
+ id: id,
223
+ size: size,
224
+ className: cx("".concat(blockClass, "__input"), _defineProperty({}, "".concat(blockClass, "__input--empty"), refInput.current && refInput.current.innerText.length === 0)),
225
+ contentEditable: true,
226
+ "aria-label": labelText,
227
+ role: "textbox",
228
+ tabIndex: disabled ? -1 : 0,
229
+ onFocus: handleFocus,
230
+ onInput: handleInput,
231
+ onKeyDown: handleKeyDown,
232
+ onPaste: handlePaste,
233
+ suppressContentEditableWarning: true,
234
+ ref: refInput,
235
+ "data-placeholder": placeholder !== null && placeholder !== void 0 ? placeholder : labelText
236
+ }), value), /*#__PURE__*/React.createElement("div", {
237
+ className: cx("".concat(blockClass, "__after-input-elements")) // tabindex -1 fixes blur target test when clicking on after-input-elements background
238
+ ,
239
+ tabIndex: "-1"
240
+ }, /*#__PURE__*/React.createElement("div", {
241
+ className: "".concat(blockClass, "__ellipsis"),
242
+ "aria-hidden": !editing
243
+ }, "\u2026"), /*#__PURE__*/React.createElement("div", {
244
+ className: cx("".concat(blockClass, "__toolbar"), (_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__toolbar--animation"), toolbarAnimation), _defineProperty(_cx3, "".concat(blockClass, "__toolbar--saveable"), refInput.current && value !== internalValue), _cx3))
245
+ }, showValidationText && validationText.length > 0 && /*#__PURE__*/React.createElement("div", {
246
+ className: "".concat(blockClass, "__validation-icon")
247
+ }, validationIcon), editing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
248
+ className: "".concat(blockClass, "__cancel"),
249
+ kind: "ghost",
250
+ hasIconOnly: true,
251
+ iconDescription: cancelDescription,
252
+ onClick: handleCancel,
253
+ renderIcon: Close16
254
+ }), /*#__PURE__*/React.createElement(Button, {
255
+ className: "".concat(blockClass, "__save"),
256
+ kind: "ghost",
257
+ hasIconOnly: true,
258
+ iconDescription: saveDescription,
259
+ onClick: handleSave,
260
+ renderIcon: Checkmark16,
261
+ disabled: invalid || saveDisabled || value === internalValue
262
+ })) : /*#__PURE__*/React.createElement(Button, {
263
+ "aria-hidden": "true",
264
+ className: cx("".concat(blockClass, "__edit"), _defineProperty({}, "".concat(blockClass, "__edit--hover-visible"), editVisibleOnHoverOnly)),
265
+ kind: "ghost",
266
+ hasIconOnly: true,
267
+ iconDescription: editDescription,
268
+ onClick: handleEdit,
269
+ renderIcon: disabled ? EditOff16 : Edit16,
270
+ disabled: disabled,
271
+ tabIndex: -1
272
+ }))), /*#__PURE__*/React.createElement("div", {
273
+ className: cx("".concat(blockClass, "__disabled-cover"))
274
+ }), showValidationText && validationText.length > 0 && /*#__PURE__*/React.createElement("div", {
275
+ className: "".concat(blockClass, "__validation-text ").concat(carbon.prefix, "--form-requirement")
276
+ }, validationText))
277
+ );
278
+ }); // Return a placeholder if not released and not enabled by feature flag
279
+
280
+ InlineEdit = pkg.checkComponentEnabled(InlineEdit, componentName); // The display name of the component, used by React. Note that displayName
281
+ // is used in preference to relying on function.name.
282
+
283
+ InlineEdit.displayName = componentName; // The types and DocGen commentary for the component props,
284
+ // in alphabetical order (for consistency).
285
+ // See https://www.npmjs.com/package/prop-types#usage.
286
+
287
+ InlineEdit.propTypes = {
288
+ /**
289
+ * label for cancel button
290
+ */
291
+ cancelDescription: PropTypes.string.isRequired,
292
+
293
+ /**
294
+ * Provide an optional class to be applied to the containing node.
295
+ */
296
+ className: PropTypes.string,
297
+
298
+ /**
299
+ * disable edit
300
+ */
301
+ disabled: PropTypes.bool,
302
+
303
+ /**
304
+ * Label for the edit button
305
+ */
306
+ editDescription: PropTypes.string.isRequired,
307
+
308
+ /**
309
+ * In some scenarios the edit icon only needs to be shown on hover. These cases are where continual visibility of
310
+ * the edit icon is redundant. E.g. a spreadsheet a property panel.
311
+ */
312
+ editVisibleOnHoverOnly: PropTypes.bool,
313
+
314
+ /**
315
+ * ID for inline edit
316
+ */
317
+ id: PropTypes.string,
318
+
319
+ /**
320
+ * set invalid state for input
321
+ */
322
+ invalid: PropTypes.bool,
323
+
324
+ /**
325
+ * text shown when invalid is true
326
+ */
327
+ invalidText: PropTypes.string,
328
+
329
+ /**
330
+ * label for text input
331
+ */
332
+ labelText: PropTypes.string,
333
+
334
+ /**
335
+ * change background to light version (mimic React TextInput)
336
+ */
337
+ light: PropTypes.bool,
338
+
339
+ /**
340
+ * method called on cancel event
341
+ */
342
+ onCancel: PropTypes.func,
343
+
344
+ /**
345
+ * method called on input event (it's a React thing onChange behaves like on input)
346
+ */
347
+ onChange: PropTypes.func,
348
+
349
+ /**
350
+ * method called on change event
351
+ */
352
+ onSave: PropTypes.func,
353
+
354
+ /**
355
+ * placeholder for text input
356
+ */
357
+ placeholder: PropTypes.string,
358
+
359
+ /**
360
+ * label for save button
361
+ */
362
+ saveDescription: PropTypes.string.isRequired,
363
+
364
+ /**
365
+ * disabled state of the save button
366
+ */
367
+ saveDisabled: PropTypes.bool,
368
+
369
+ /**
370
+ * vertical size of control
371
+ */
372
+ size: PropTypes.oneOf(['sm', 'md', 'lg']),
373
+
374
+ /**
375
+ * initial/unedited value
376
+ */
377
+ value: PropTypes.string,
378
+
379
+ /**
380
+ * set warn state for input
381
+ */
382
+ warn: PropTypes.bool,
383
+
384
+ /**
385
+ * text shown when warn true
386
+ */
387
+ warnText: PropTypes.string
388
+ }; // Default values for component props. Default values are not required for
389
+ // props that are required, nor for props where the component can apply
390
+ // 'undefined' values reasonably. Default values should be provided when the
391
+ // component needs to make a choice or assumption when a prop is not supplied.
392
+
393
+ InlineEdit.defaultProps = {
394
+ light: true,
395
+ // defaults to true to reflect design
396
+ size: 'md'
397
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2022
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
+ export { InlineEdit } from './InlineEdit';
@@ -0,0 +1,16 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { forwardRef } from 'react'; // import PropTypes from 'prop-types';
3
+
4
+ import { AddSelect } from '../AddSelect';
5
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
6
+ import { pkg } from '../../settings';
7
+ var componentName = 'MultiAddSelect';
8
+ export var MultiAddSelect = /*#__PURE__*/forwardRef(function (props, ref) {
9
+ return /*#__PURE__*/React.createElement(AddSelect, _extends({}, props, {
10
+ multi: true,
11
+ ref: ref
12
+ }, getDevtoolsProps(componentName)));
13
+ });
14
+ MultiAddSelect = pkg.checkComponentEnabled(MultiAddSelect, componentName);
15
+ MultiAddSelect.propTypes = {};
16
+ MultiAddSelect.displayName = componentName;
@@ -0,0 +1 @@
1
+ export { MultiAddSelect } from './MultiAddSelect';
@@ -5,7 +5,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
5
5
  var _excluded = ["className", "data", "daysAgoText", "dismissAllLabel", "dismissSingleNotificationIconDescription", "doNotDisturbDefaultToggled", "doNotDisturbLabel", "emptyStateLabel", "hoursAgoText", "hourAgoText", "minuteAgoText", "minutesAgoText", "monthsAgoText", "monthAgoText", "nowText", "onClickOutside", "onDismissAllNotifications", "onDismissSingleNotification", "onDoNotDisturbChange", "onSettingsClick", "onViewAllClick", "open", "previousLabel", "readLessLabel", "readMoreLabel", "secondsAgoText", "settingsIconDescription", "title", "todayLabel", "viewAllLabel", "yearsAgoText", "yearAgoText", "yesterdayAtText", "yesterdayLabel"];
6
6
 
7
7
  /**
8
- * Copyright IBM Corp. 2020, 2021
8
+ * Copyright IBM Corp. 2020, 2022
9
9
  *
10
10
  * This source code is licensed under the Apache-2.0 license found in the
11
11
  * LICENSE file in the root directory of this source tree.
@@ -22,7 +22,8 @@ import { timeAgo } from './utils';
22
22
  import { NotificationsEmptyState } from '../EmptyStates/NotificationsEmptyState'; // Carbon and package components we use.
23
23
 
24
24
  import { Button, Link, Toggle } from 'carbon-components-react';
25
- import { ErrorFilled16, WarningAltFilled16, CheckmarkFilled16, InformationSquareFilled16, ChevronDown16, Close16, Settings16 } from '@carbon/icons-react'; // The block part of our conventional BEM class names (blockClass__E--M).
25
+ import { ErrorFilled16, WarningAltFilled16, CheckmarkFilled16, InformationSquareFilled16, ChevronDown16, Close16, Settings16 } from '@carbon/icons-react';
26
+ import { usePreviousValue } from '../../global/js/hooks'; // The block part of our conventional BEM class names (blockClass__E--M).
26
27
 
27
28
  var componentName = 'NotificationsPanel';
28
29
  var blockClass = "".concat(pkg.prefix, "--notifications-panel");
@@ -75,6 +76,12 @@ export var NotificationsPanel = /*#__PURE__*/React.forwardRef(function (_ref, re
75
76
  allNotifications = _useState4[0],
76
77
  setAllNotifications = _useState4[1];
77
78
 
79
+ var previousState = usePreviousValue({
80
+ open: open
81
+ });
82
+ var reducedMotion = window && window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {
83
+ matches: true
84
+ };
78
85
  useEffect(function () {
79
86
  // Set the notifications passed to the state within this component
80
87
  setAllNotifications(data);
@@ -94,6 +101,12 @@ export var NotificationsPanel = /*#__PURE__*/React.forwardRef(function (_ref, re
94
101
  !open && setRender(false);
95
102
  };
96
103
 
104
+ useEffect(function () {
105
+ if (!open && previousState !== null && previousState !== void 0 && previousState.open && reducedMotion.matches) {
106
+ setRender(false);
107
+ }
108
+ }, [open, reducedMotion.matches, previousState === null || previousState === void 0 ? void 0 : previousState.open]);
109
+
97
110
  var sortChronologically = function sortChronologically(arr) {
98
111
  if (!arr || arr && !arr.length) {
99
112
  return;
@@ -233,7 +246,7 @@ export var NotificationsPanel = /*#__PURE__*/React.forwardRef(function (_ref, re
233
246
  id: blockClass,
234
247
  className: cx(blockClass, className, "".concat(blockClass, "__container")),
235
248
  style: {
236
- animation: "".concat(open ? 'fadeIn 250ms' : 'fadeOut 250ms')
249
+ animation: !reducedMotion.matches ? "".concat(open ? 'fade-in 250ms' : 'fade-out 250ms') : null
237
250
  },
238
251
  onAnimationEnd: onAnimationEnd,
239
252
  ref: ref || notificationPanelRef
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["children", "className", "enabled", "heading", "headingId", "invalid", "invalidText", "locked", "lockedText", "onToggle", "size", "summary", "warn", "warnText"];
5
+ var _excluded = ["children", "className", "enabled", "heading", "headingId", "invalid", "invalidText", "locked", "lockedText", "onToggle", "open", "size", "summary", "warn", "warnText"];
6
6
 
7
7
  /**
8
8
  * Copyright IBM Corp. 2021, 2021
@@ -41,22 +41,27 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
41
41
  locked = _ref.locked,
42
42
  lockedText = _ref.lockedText,
43
43
  onToggle = _ref.onToggle,
44
- _ref$size = _ref.size,
45
- size = _ref$size === void 0 ? 'xl' : _ref$size,
44
+ open = _ref.open,
45
+ size = _ref.size,
46
46
  summary = _ref.summary,
47
47
  warn = _ref.warn,
48
48
  warnText = _ref.warnText,
49
49
  rest = _objectWithoutProperties(_ref, _excluded);
50
50
 
51
- var _useState = useState(false),
51
+ var _useState = useState(open),
52
52
  _useState2 = _slicedToArray(_useState, 2),
53
- open = _useState2[0],
54
- setOpen = _useState2[1];
53
+ isOpen = _useState2[0],
54
+ setIsOpen = _useState2[1];
55
55
 
56
- var _useState3 = useState(false),
56
+ var _useState3 = useState(open),
57
57
  _useState4 = _slicedToArray(_useState3, 2),
58
- closing = _useState4[0],
59
- setClosing = _useState4[1];
58
+ prevIsOpen = _useState4[0],
59
+ setPrevIsOpen = _useState4[1];
60
+
61
+ var _useState5 = useState(false),
62
+ _useState6 = _slicedToArray(_useState5, 2),
63
+ closing = _useState6[0],
64
+ setClosing = _useState6[1];
60
65
 
61
66
  var detailsRef = useRef(null);
62
67
  var contentRef = useRef(null);
@@ -70,9 +75,19 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
70
75
  matches: true
71
76
  };
72
77
 
78
+ if (open !== prevIsOpen) {
79
+ if (isOpen && !open) {
80
+ collapse();
81
+ } else if (!isOpen && open) {
82
+ expand();
83
+ }
84
+
85
+ setPrevIsOpen(open);
86
+ }
87
+
73
88
  function expand() {
74
89
  if (detailsRef.current && contentRef.current && !reducedMotion.matches) {
75
- setOpen(true);
90
+ setIsOpen(true);
76
91
  detailsRef.current.open = true;
77
92
 
78
93
  var _getComputedStyle = getComputedStyle(contentRef.current),
@@ -98,7 +113,7 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
98
113
  });
99
114
  } else {
100
115
  // in case the refs are not set or the user prefers reduced motion, skip the animation
101
- setOpen(true);
116
+ setIsOpen(true);
102
117
  }
103
118
  }
104
119
 
@@ -127,7 +142,7 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
127
142
  });
128
143
 
129
144
  var callback = function callback() {
130
- setOpen(false);
145
+ setIsOpen(false);
131
146
  setClosing(false);
132
147
  };
133
148
 
@@ -135,14 +150,14 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
135
150
  animation.oncancel = callback;
136
151
  } else {
137
152
  // in case the ref is not set or the user prefers reduced motion, skip the animation
138
- setOpen(false);
153
+ setIsOpen(false);
139
154
  }
140
155
  }
141
156
 
142
157
  function toggle(e) {
143
158
  e.preventDefault();
144
159
 
145
- if (open) {
160
+ if (isOpen) {
146
161
  collapse();
147
162
  } else {
148
163
  expand();
@@ -199,7 +214,7 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
199
214
  size: "sm",
200
215
  disabled: isLocked
201
216
  })), isExpandable ? /*#__PURE__*/React.createElement("details", {
202
- open: open,
217
+ open: isOpen,
203
218
  ref: detailsRef
204
219
  }, /*#__PURE__*/React.createElement("summary", {
205
220
  className: "".concat(blockClass, "__header"),
@@ -277,6 +292,11 @@ OptionsTile.propTypes = {
277
292
  */
278
293
  onToggle: PropTypes.func,
279
294
 
295
+ /**
296
+ * Whether the OptionsTile is in open state.
297
+ */
298
+ open: PropTypes.bool,
299
+
280
300
  /**
281
301
  * Define the size of the OptionsTile.
282
302
  */
@@ -302,5 +322,6 @@ OptionsTile.propTypes = {
302
322
  // component needs to make a choice or assumption when a prop is not supplied.
303
323
 
304
324
  OptionsTile.defaultProps = {
325
+ open: false,
305
326
  size: 'xl'
306
327
  };