@carbon/ibm-products 1.2.5 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. package/css/index-full-carbon.css +1028 -517
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -3
  4. package/css/index-without-carbon-released-only.css +187 -108
  5. package/css/index-without-carbon-released-only.css.map +1 -1
  6. package/css/index-without-carbon-released-only.min.css +3 -3
  7. package/css/index-without-carbon.css +580 -114
  8. package/css/index-without-carbon.css.map +1 -1
  9. package/css/index-without-carbon.min.css +3 -3
  10. package/css/index.css +804 -116
  11. package/css/index.css.map +1 -1
  12. package/css/index.min.css +3 -3
  13. package/es/components/APIKeyModal/APIKeyModal.js +25 -29
  14. package/es/components/ActionBar/ActionBar.js +4 -1
  15. package/es/components/ActionSet/ActionSet.js +22 -10
  16. package/es/components/ActionSet/actions.js +25 -17
  17. package/es/components/AddSelect/AddSelect.js +198 -0
  18. package/es/components/AddSelect/AddSelectBreadcrumbs.js +56 -0
  19. package/es/components/AddSelect/AddSelectList.js +94 -0
  20. package/es/components/AddSelect/AddSelectSidebar.js +46 -0
  21. package/es/components/AddSelect/index.js +7 -0
  22. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +24 -17
  23. package/es/components/CancelableTextEdit/CancelableTextEdit.js +245 -0
  24. package/es/components/{CreateTearsheet/constants.js → CancelableTextEdit/index.js} +1 -2
  25. package/es/components/Card/Card.js +6 -4
  26. package/es/components/CreateFullPage/CreateFullPage.js +102 -258
  27. package/es/components/CreateFullPage/CreateFullPageStep.js +65 -13
  28. package/es/components/CreateFullPage/index.js +1 -2
  29. package/es/components/CreateInfluencer/CreateInfluencer.js +40 -220
  30. package/es/components/CreateTearsheet/CreateTearsheet.js +95 -146
  31. package/es/components/CreateTearsheet/CreateTearsheetStep.js +70 -20
  32. package/es/components/CreateTearsheet/index.js +0 -1
  33. package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +87 -28
  34. package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  35. package/es/components/ExportModal/ExportModal.js +41 -12
  36. package/es/components/ImportModal/ImportModal.js +2 -1
  37. package/es/components/InlineEdit/InlineEdit.js +373 -0
  38. package/es/components/InlineEdit/index.js +7 -0
  39. package/es/components/MultiAddSelect/MultiAddSelect.js +16 -0
  40. package/es/components/MultiAddSelect/index.js +1 -0
  41. package/es/components/NotificationsPanel/NotificationsPanel.js +16 -3
  42. package/es/components/OptionsTile/OptionsTile.js +36 -15
  43. package/es/components/PageHeader/PageHeader.js +59 -35
  44. package/es/components/PageHeader/PageHeaderTitle.js +82 -7
  45. package/es/components/PageHeader/PageHeaderUtils.js +21 -2
  46. package/es/components/RemoveModal/RemoveModal.js +4 -2
  47. package/es/components/SidePanel/SidePanel.js +33 -16
  48. package/es/components/SingleAddSelect/SingleAddSelect.js +15 -0
  49. package/es/components/SingleAddSelect/index.js +1 -0
  50. package/es/components/TagSet/TagSet.js +4 -1
  51. package/es/components/Tearsheet/Tearsheet.js +1 -1
  52. package/es/components/Tearsheet/TearsheetNarrow.js +1 -1
  53. package/es/components/Tearsheet/TearsheetShell.js +1 -1
  54. package/es/components/Toolbar/Toolbar.js +69 -8
  55. package/es/components/WebTerminal/WebTerminal.js +1 -1
  56. package/es/components/index.js +5 -1
  57. package/es/global/js/hooks/index.js +1 -0
  58. package/es/global/js/hooks/useCreateComponentFocus.js +15 -19
  59. package/es/global/js/hooks/useCreateComponentStepChange.js +69 -79
  60. package/es/global/js/hooks/useResetCreateComponent.js +7 -4
  61. package/es/global/js/hooks/useRetrieveStepData.js +51 -0
  62. package/es/global/js/hooks/useValidCreateStepCount.js +4 -7
  63. package/es/global/js/package-settings.js +5 -1
  64. package/es/global/js/utils/lastIndexInArray.js +26 -0
  65. package/es/settings.js +0 -5
  66. package/lib/components/APIKeyModal/APIKeyModal.js +25 -29
  67. package/lib/components/ActionBar/ActionBar.js +4 -1
  68. package/lib/components/ActionSet/ActionSet.js +22 -10
  69. package/lib/components/ActionSet/actions.js +25 -17
  70. package/lib/components/AddSelect/AddSelect.js +223 -0
  71. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +71 -0
  72. package/lib/components/AddSelect/AddSelectList.js +112 -0
  73. package/lib/components/AddSelect/AddSelectSidebar.js +63 -0
  74. package/lib/components/AddSelect/index.js +13 -0
  75. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +23 -16
  76. package/lib/components/CancelableTextEdit/CancelableTextEdit.js +265 -0
  77. package/lib/components/CancelableTextEdit/index.js +13 -0
  78. package/lib/components/Card/Card.js +6 -4
  79. package/lib/components/CreateFullPage/CreateFullPage.js +102 -258
  80. package/lib/components/CreateFullPage/CreateFullPageStep.js +68 -13
  81. package/lib/components/CreateFullPage/index.js +1 -9
  82. package/lib/components/CreateInfluencer/CreateInfluencer.js +38 -231
  83. package/lib/components/CreateTearsheet/CreateTearsheet.js +97 -148
  84. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +72 -19
  85. package/lib/components/CreateTearsheet/index.js +0 -8
  86. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +86 -34
  87. package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +8 -6
  88. package/lib/components/ExportModal/ExportModal.js +38 -11
  89. package/lib/components/ImportModal/ImportModal.js +2 -1
  90. package/lib/components/InlineEdit/InlineEdit.js +389 -0
  91. package/lib/components/InlineEdit/index.js +13 -0
  92. package/lib/components/MultiAddSelect/MultiAddSelect.js +37 -0
  93. package/lib/components/MultiAddSelect/index.js +13 -0
  94. package/lib/components/NotificationsPanel/NotificationsPanel.js +13 -1
  95. package/lib/components/OptionsTile/OptionsTile.js +36 -15
  96. package/lib/components/PageHeader/PageHeader.js +59 -35
  97. package/lib/components/PageHeader/PageHeaderTitle.js +91 -9
  98. package/lib/components/PageHeader/PageHeaderUtils.js +21 -2
  99. package/lib/components/RemoveModal/RemoveModal.js +4 -2
  100. package/lib/components/SidePanel/SidePanel.js +33 -16
  101. package/lib/components/SingleAddSelect/SingleAddSelect.js +36 -0
  102. package/lib/components/SingleAddSelect/index.js +13 -0
  103. package/lib/components/TagSet/TagSet.js +4 -1
  104. package/lib/components/Tearsheet/Tearsheet.js +1 -1
  105. package/lib/components/Tearsheet/TearsheetNarrow.js +1 -1
  106. package/lib/components/Tearsheet/TearsheetShell.js +1 -1
  107. package/lib/components/Toolbar/Toolbar.js +69 -6
  108. package/lib/components/WebTerminal/WebTerminal.js +1 -1
  109. package/lib/components/index.js +33 -1
  110. package/lib/global/js/hooks/index.js +8 -0
  111. package/lib/global/js/hooks/useCreateComponentFocus.js +15 -19
  112. package/lib/global/js/hooks/useCreateComponentStepChange.js +69 -79
  113. package/lib/global/js/hooks/useResetCreateComponent.js +7 -4
  114. package/lib/global/js/hooks/useRetrieveStepData.js +62 -0
  115. package/lib/global/js/hooks/useValidCreateStepCount.js +4 -7
  116. package/lib/global/js/package-settings.js +5 -1
  117. package/lib/global/js/utils/lastIndexInArray.js +35 -0
  118. package/lib/settings.js +0 -6
  119. package/package.json +19 -19
  120. package/scss/components/AddSelect/_add-select.scss +108 -0
  121. package/scss/components/AddSelect/_index.scss +10 -0
  122. package/scss/components/AddSelect/_storybook-styles.scss +6 -0
  123. package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +19 -15
  124. package/scss/components/BreadcrumbWithOverflow/_index.scss +1 -1
  125. package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +212 -0
  126. package/{es/components/CreateFullPage/constants.js → scss/components/CancelableTextEdit/_index.scss} +2 -2
  127. package/scss/components/CancelableTextEdit/_storybook-styles.scss +15 -0
  128. package/scss/components/CreateFullPage/_create-full-page.scss +4 -11
  129. package/scss/components/CreateInfluencer/_create-influencer.scss +4 -4
  130. package/scss/components/CreateTearsheet/_create-tearsheet.scss +6 -10
  131. package/scss/components/InlineEdit/_index.scss +8 -0
  132. package/scss/components/InlineEdit/_inline-edit.scss +245 -0
  133. package/scss/components/InlineEdit/_storybook-styles.scss +28 -0
  134. package/scss/components/MultiAddSelect/_index.scss +1 -0
  135. package/scss/components/MultiAddSelect/_multi-add-select.scss +1 -0
  136. package/scss/components/MultiAddSelect/_storybook-styles.scss +6 -0
  137. package/scss/components/NotificationsPanel/_notifications-panel.scss +2 -2
  138. package/scss/components/PageHeader/_index.scss +1 -1
  139. package/scss/components/PageHeader/_page-header.scss +15 -5
  140. package/scss/components/ProductiveCard/_productive-card.scss +0 -4
  141. package/scss/components/SidePanel/_side-panel.scss +15 -6
  142. package/scss/components/SingleAddSelect/_index.scss +1 -0
  143. package/scss/components/SingleAddSelect/_single-add-select.scss +1 -0
  144. package/scss/components/SingleAddSelect/_storybook-styles.scss +6 -0
  145. package/scss/components/StatusIcon/_index.scss +1 -1
  146. package/scss/components/StatusIcon/_status-icon.scss +2 -0
  147. package/scss/components/TagSet/_index.scss +1 -1
  148. package/scss/components/UserProfileImage/_index.scss +1 -1
  149. package/scss/components/WebTerminal/_web-terminal.scss +2 -2
  150. package/scss/components/_index.scss +4 -0
  151. package/scss/global/styles/_project-settings.scss +5 -1
  152. package/es/components/CreateFullPage/CreateFullPageSection.js +0 -53
  153. package/es/components/CreateTearsheet/CreateTearsheetSection.js +0 -83
  154. package/es/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -327
  155. package/es/generated/feature-flags/feature-flags.js +0 -15
  156. package/es/global/js/utils/hasValidType.js +0 -94
  157. package/lib/components/CreateFullPage/CreateFullPageSection.js +0 -74
  158. package/lib/components/CreateFullPage/constants.js +0 -16
  159. package/lib/components/CreateTearsheet/CreateTearsheetSection.js +0 -105
  160. package/lib/components/CreateTearsheet/constants.js +0 -17
  161. package/lib/components/CreateTearsheet/preview-components/MultiStepWithSectionsTearsheet.js +0 -354
  162. package/lib/generated/feature-flags/feature-flags.js +0 -22
  163. package/lib/global/js/utils/hasValidType.js +0 -110
  164. package/scss/generated/feature-flags/_feature-flags.scss +0 -19
@@ -0,0 +1,373 @@
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", "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 } 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, _cx2;
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
+ saveDescription = _ref.saveDescription,
50
+ saveDisabled = _ref.saveDisabled,
51
+ size = _ref.size,
52
+ value = _ref.value,
53
+ warn = _ref.warn,
54
+ warnText = _ref.warnText,
55
+ rest = _objectWithoutProperties(_ref, _excluded);
56
+
57
+ var refInput = useRef(null);
58
+ var localRef = useRef(null);
59
+ var ref = refIn || localRef;
60
+
61
+ var _useState = useState(false),
62
+ _useState2 = _slicedToArray(_useState, 2),
63
+ editing = _useState2[0],
64
+ setEditing = _useState2[1];
65
+
66
+ var _useState3 = useState(value),
67
+ _useState4 = _slicedToArray(_useState3, 2),
68
+ internalValue = _useState4[0],
69
+ setInternalValue = _useState4[1];
70
+
71
+ var showValidationText = invalid || warn;
72
+ var validationText = invalidText || warnText;
73
+ var validationIcon = showValidationText ? invalid ? /*#__PURE__*/React.createElement(WarningFilled16, null) : /*#__PURE__*/React.createElement(WarningAltFilled16, null) : null;
74
+
75
+ var handleEdit = function handleEdit(ev) {
76
+ if (!disabled) {
77
+ var rightOfInput = ev.currentTarget.classList.contains("".concat(blockClass, "__edit")) || ev.target.classList.contains("".concat(blockClass, "__controls"));
78
+ var leftOfInput = ev.currentTarget = ev.target.classList.contains("".concat(blockClass)); // clicking on the content editable element should not set either of these to true
79
+
80
+ if (rightOfInput || leftOfInput) {
81
+ setEditing(true);
82
+ setTimeout(function () {
83
+ refInput.current.focus(); // select all the content
84
+
85
+ document.getSelection().selectAllChildren(refInput.current);
86
+
87
+ if (rightOfInput) {
88
+ document.getSelection().collapseToEnd();
89
+ refInput.current.scrollLeft = 9999; // never going to get there but ensures at end.
90
+ } else {
91
+ document.getSelection().collapseToStart();
92
+ refInput.current.scrollLeft = 0; // scroll to start
93
+ }
94
+ }, 0);
95
+ }
96
+ }
97
+ };
98
+
99
+ var handleFocus = function handleFocus(ev) {
100
+ if (!editing && ev.target.classList.contains("".concat(blockClass, "__input"))) {
101
+ // console.log(editing);
102
+ setEditing(true);
103
+ }
104
+ };
105
+
106
+ var handleSave = function handleSave() {
107
+ setEditing(false);
108
+ document.getSelection().removeAllRanges();
109
+
110
+ if (onSave) {
111
+ onSave(refInput.current.innerText);
112
+ }
113
+ };
114
+
115
+ var handlePaste = function handlePaste(ev) {
116
+ ev.preventDefault(); // Get clipboard as plain text
117
+
118
+ var text = (ev.clipboardData || window.clipboardData).getData('text/plain'); // remove \n
119
+
120
+ var sanitizedText = text.replaceAll(/\n/g, '') // remove carriage returns
121
+ .replaceAll(/\t/g, ' '); // replace tab with two spaces
122
+
123
+ if (document.queryCommandSupported('insertText')) {
124
+ document.execCommand('insertText', false, sanitizedText);
125
+ } else {
126
+ // Insert text at the current position of caret
127
+ var range = document.getSelection().getRangeAt(0);
128
+ range.deleteContents();
129
+ var textNode = document.createTextNode(sanitizedText);
130
+ range.insertNode(textNode); // move selection end of textNode
131
+
132
+ range.selectNodeContents(textNode);
133
+ range.collapse(false); // remove existing range
134
+
135
+ var selection = document.getSelection();
136
+ selection.removeAllRanges(); // set the new range
137
+
138
+ selection.addRange(range);
139
+ }
140
+ };
141
+
142
+ var handleInput = function handleInput() {
143
+ setInternalValue(refInput.current.innerText);
144
+
145
+ if (onChange) {
146
+ onChange(refInput.current.innerText);
147
+ }
148
+ };
149
+
150
+ var handleCancel = function handleCancel() {
151
+ refInput.current.innerText = value;
152
+ handleInput(value);
153
+ setEditing(false);
154
+ document.getSelection().removeAllRanges();
155
+
156
+ if (onCancel) {
157
+ onCancel(value);
158
+ }
159
+ };
160
+
161
+ var handleBlur = function handleBlur(ev) {
162
+ if (!ref.current.contains(ev.relatedTarget)) {
163
+ setEditing(false);
164
+ handleSave();
165
+ }
166
+ };
167
+
168
+ var handleKeyDown = function handleKeyDown(ev) {
169
+ if (ev.key === 'Enter') {
170
+ ev.preventDefault();
171
+ refInput.current.blur(); // will cause save
172
+ }
173
+ };
174
+ /*
175
+ The HTML is structured as follows:
176
+ <container>
177
+ <!-- margin left of input to match Carbon -->
178
+ <content-editable>
179
+ <-- margin right of input space for controls -->
180
+ <controls>
181
+ </container>
182
+ NOTE:
183
+ - An input is not used as this would not permit a heading tag e.g. <h2>.
184
+ - Some padding is added to the left 16px standard for a Carbon text input
185
+ - The controls are position absolute with a margin to on the input to reserve space. Using inline-flex
186
+ - does not measure space properly for the input otherwise.
187
+ - The content editable is not expected to change size when buttons are added, to ensure the text does not move space
188
+ is reserved up front for buttons and invalid icon. Mostly this is only noticed if the width of the component is not 100%.
189
+ which can be shown by setting inlineEditFullWidth to false in storybook.
190
+ In making content-editable behave like an input of type text we have to account for.
191
+ - Enforcing a single line
192
+ - Pasting of non-text e.g. html or text with carriage returns
193
+ - The padding and border not hiding typed in text.
194
+ - Placing the cursor at the start or end depending on area clicked (before for left-padding)
195
+ */
196
+
197
+
198
+ var controlsAnimation = true;
199
+ return (
200
+ /*#__PURE__*/
201
+ // eslint-disable-next-line
202
+ React.createElement("div", {
203
+ className: cx(blockClass, // Apply the block class to the main HTML element
204
+ className, // Apply any supplied class names to the main HTML element.
205
+ "".concat(blockClass, "--").concat(size), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--editing"), editing), _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _defineProperty(_cx, "".concat(blockClass, "--light"), light), _cx)),
206
+ onClick: handleEdit // disabled eslint for click handler
207
+ ,
208
+ onBlur: handleBlur,
209
+ ref: ref
210
+ }, /*#__PURE__*/React.createElement("div", _extends({}, rest, getDevtoolsProps(componentName), {
211
+ id: id,
212
+ size: size,
213
+ className: "".concat(blockClass, "__input"),
214
+ contentEditable: true,
215
+ "aria-label": labelText,
216
+ role: "textbox",
217
+ tabIndex: "0",
218
+ onFocus: handleFocus,
219
+ onInput: handleInput,
220
+ onKeyDown: handleKeyDown,
221
+ onPaste: handlePaste,
222
+ suppressContentEditableWarning: true,
223
+ ref: refInput
224
+ }), value), refInput.current && refInput.current.innerText.length === 0 && /*#__PURE__*/React.createElement("div", {
225
+ className: "".concat(blockClass, "__placeholder")
226
+ }, labelText), showValidationText && validationText.length > 0 && /*#__PURE__*/React.createElement("div", {
227
+ className: "".concat(blockClass, "__validation-text")
228
+ }, validationText), /*#__PURE__*/React.createElement("div", {
229
+ className: "".concat(blockClass, "__validation-icon")
230
+ }, validationIcon), /*#__PURE__*/React.createElement("div", {
231
+ className: cx("".concat(blockClass, "__controls"), (_cx2 = {}, _defineProperty(_cx2, "".concat(blockClass, "__controls--animation"), controlsAnimation), _defineProperty(_cx2, "".concat(blockClass, "__controls--saveable"), invalid || saveDisabled || refInput.current && value !== internalValue), _cx2))
232
+ }, editing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
233
+ className: "".concat(blockClass, "__cancel"),
234
+ kind: "ghost",
235
+ hasIconOnly: true,
236
+ iconDescription: cancelDescription,
237
+ onClick: handleCancel,
238
+ renderIcon: Close16
239
+ }), /*#__PURE__*/React.createElement(Button, {
240
+ className: "".concat(blockClass, "__save"),
241
+ kind: "ghost",
242
+ hasIconOnly: true,
243
+ iconDescription: saveDescription,
244
+ onClick: handleSave,
245
+ renderIcon: Checkmark16,
246
+ disabled: invalid || saveDisabled || value === internalValue
247
+ })) : /*#__PURE__*/React.createElement(Button, {
248
+ "aria-hidden": "true",
249
+ className: cx("".concat(blockClass, "__edit"), _defineProperty({}, "".concat(blockClass, "__edit--hover-visible"), editVisibleOnHoverOnly)),
250
+ kind: "ghost",
251
+ hasIconOnly: true,
252
+ iconDescription: editDescription,
253
+ onClick: handleEdit,
254
+ renderIcon: disabled ? EditOff16 : Edit16,
255
+ disabled: disabled,
256
+ tabIndex: -1
257
+ })))
258
+ );
259
+ }); // Return a placeholder if not released and not enabled by feature flag
260
+
261
+ InlineEdit = pkg.checkComponentEnabled(InlineEdit, componentName); // The display name of the component, used by React. Note that displayName
262
+ // is used in preference to relying on function.name.
263
+
264
+ InlineEdit.displayName = componentName; // The types and DocGen commentary for the component props,
265
+ // in alphabetical order (for consistency).
266
+ // See https://www.npmjs.com/package/prop-types#usage.
267
+
268
+ InlineEdit.propTypes = {
269
+ /**
270
+ * label for cancel button
271
+ */
272
+ cancelDescription: PropTypes.string.isRequired,
273
+
274
+ /**
275
+ * Provide an optional class to be applied to the containing node.
276
+ */
277
+ className: PropTypes.string,
278
+
279
+ /**
280
+ * disable edit
281
+ */
282
+ disabled: PropTypes.bool,
283
+
284
+ /**
285
+ * Label for the edit button
286
+ */
287
+ editDescription: PropTypes.string.isRequired,
288
+
289
+ /**
290
+ * In some scenarios the edit icon only needs to be shown on hover. These cases are where continual visibility of
291
+ * the edit icon is redundant. E.g. a spreadsheet a property panel.
292
+ */
293
+ editVisibleOnHoverOnly: PropTypes.bool,
294
+
295
+ /**
296
+ * ID for inline edit
297
+ */
298
+ id: PropTypes.string,
299
+
300
+ /**
301
+ * set invalid state for input
302
+ */
303
+ invalid: PropTypes.bool,
304
+
305
+ /**
306
+ * text shown when invalid is true
307
+ */
308
+ invalidText: PropTypes.string,
309
+
310
+ /**
311
+ * label for text input
312
+ */
313
+ labelText: PropTypes.string,
314
+
315
+ /**
316
+ * change background to light version (mimic React TextInput)
317
+ */
318
+ light: PropTypes.bool,
319
+
320
+ /**
321
+ * method called on cancel event
322
+ */
323
+ onCancel: PropTypes.func,
324
+
325
+ /**
326
+ * method called on input event (it's a React thing onChange behaves like on input)
327
+ */
328
+ onChange: PropTypes.func,
329
+
330
+ /**
331
+ * method called on change event
332
+ */
333
+ onSave: PropTypes.func,
334
+
335
+ /**
336
+ * label for save button
337
+ */
338
+ saveDescription: PropTypes.string.isRequired,
339
+
340
+ /**
341
+ * disabled state of the save button
342
+ */
343
+ saveDisabled: PropTypes.bool,
344
+
345
+ /**
346
+ * vertical size of control
347
+ */
348
+ size: PropTypes.oneOf(['sm', 'md', 'lg']),
349
+
350
+ /**
351
+ * initial/unedited value
352
+ */
353
+ value: PropTypes.string,
354
+
355
+ /**
356
+ * set warn state for input
357
+ */
358
+ warn: PropTypes.bool,
359
+
360
+ /**
361
+ * text shown when warn true
362
+ */
363
+ warnText: PropTypes.string
364
+ }; // Default values for component props. Default values are not required for
365
+ // props that are required, nor for props where the component can apply
366
+ // 'undefined' values reasonably. Default values should be provided when the
367
+ // component needs to make a choice or assumption when a prop is not supplied.
368
+
369
+ InlineEdit.defaultProps = {
370
+ light: true,
371
+ // defaults to true to reflect design
372
+ size: 'md'
373
+ };
@@ -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
  };