@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
@@ -1,245 +0,0 @@
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 = ["className", "hideLabel", "inline", "invalid", "invalidText", "labelText", "onChange", "onInput", "onRevert", "revertDescription", "saveDescription", "saveDisabled", "size", "value", "warn", "warnText"];
6
-
7
- 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; }
8
-
9
- 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) { _defineProperty(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; }
10
-
11
- /**
12
- * Copyright IBM Corp. 2021, 2021
13
- *
14
- * This source code is licensed under the Apache-2.0 license found in the
15
- * LICENSE file in the root directory of this source tree.
16
- */
17
- // Import portions of React that are needed.
18
- import React, { useEffect, useState } from 'react'; // Other standard imports.
19
-
20
- import PropTypes from 'prop-types';
21
- import cx from 'classnames';
22
- import { Button, TextInput } from 'carbon-components-react';
23
- import { prepareProps } from '../../global/js/utils/props-helper';
24
- import { pkg, carbon } from '../../settings';
25
- import { getDevtoolsProps } from '../../global/js/utils/devtools';
26
- import { Checkmark16, Reset16 } from '@carbon/icons-react'; // Carbon and package components we use.
27
-
28
- /* TODO: @import(s) of carbon components and other package components. */
29
- // The block part of our conventional BEM class names (blockClass__E--M).
30
-
31
- var blockClass = "".concat(pkg.prefix, "--cancelable-text-edit");
32
- var componentName = 'CancelableTextEdit'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
33
-
34
- /**
35
- * TODO: A description of the component.
36
- */
37
-
38
- export var CancelableTextEdit = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
39
- var _cx;
40
-
41
- var className = _ref.className,
42
- hideLabel = _ref.hideLabel,
43
- inline = _ref.inline,
44
- invalid = _ref.invalid,
45
- invalidText = _ref.invalidText,
46
- labelText = _ref.labelText,
47
- onChange = _ref.onChange,
48
- onInput = _ref.onInput,
49
- onRevert = _ref.onRevert,
50
- revertDescription = _ref.revertDescription,
51
- saveDescription = _ref.saveDescription,
52
- saveDisabled = _ref.saveDisabled,
53
- size = _ref.size,
54
- value = _ref.value,
55
- warn = _ref.warn,
56
- warnText = _ref.warnText,
57
- rest = _objectWithoutProperties(_ref, _excluded);
58
-
59
- // remove these props later
60
- var removeProps = ['children', 'onInput', 'onChange', 'value'];
61
- var showWarn = inline && warn && !invalid;
62
- var showInvalid = inline && invalid;
63
-
64
- var _useState = useState(value !== null && value !== void 0 ? value : ''),
65
- _useState2 = _slicedToArray(_useState, 2),
66
- liveValue = _useState2[0],
67
- setLiveValue = _useState2[1];
68
-
69
- useEffect(function () {
70
- if (value !== liveValue) {
71
- setLiveValue(value);
72
- } // Do not care if liveValue changes here
73
- // eslint-disable-next-line react-hooks/exhaustive-deps
74
-
75
- }, [value]);
76
-
77
- var doInput = function doInput(newValue) {
78
- setLiveValue(newValue);
79
-
80
- if (onInput) {
81
- onInput(newValue);
82
- }
83
- };
84
-
85
- var handleInput = function handleInput(ev) {
86
- doInput(ev.target.value);
87
- };
88
-
89
- var handleRevert = function handleRevert() {
90
- doInput(value);
91
-
92
- if (onRevert) {
93
- onRevert(value);
94
- }
95
- };
96
-
97
- var handleSave = function handleSave() {
98
- if (onChange && !invalid) {
99
- onChange(liveValue);
100
- }
101
- };
102
-
103
- return /*#__PURE__*/React.createElement("div", _extends({
104
- className: cx(className, "".concat(blockClass), "".concat(blockClass, "--").concat(size), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _defineProperty(_cx, "".concat(blockClass, "--warn"), warn), _defineProperty(_cx, "".concat(blockClass, "--inline"), inline), _cx))
105
- }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("div", {
106
- className: "".concat(blockClass, "__main")
107
- }, /*#__PURE__*/React.createElement(TextInput, _extends({}, prepareProps(rest, removeProps), {
108
- // it is not permitted to pass children down to TextInput guard against this
109
- className: "".concat(blockClass, "__input"),
110
- ref: ref,
111
- onInput: handleInput,
112
- size: size,
113
- value: liveValue !== null && liveValue !== void 0 ? liveValue : '' // ?? '' prevents controlled components test failure https://reactjs.org/docs/forms.html#controlled-components
114
- ,
115
- hideLabel: hideLabel,
116
- inline: inline,
117
- invalid: invalid,
118
- invalidText: invalidText,
119
- labelText: labelText,
120
- warn: warn,
121
- warnText: warnText
122
- })), /*#__PURE__*/React.createElement("div", {
123
- className: "".concat(blockClass, "__buttons")
124
- }, !inline && !hideLabel && labelText && /*#__PURE__*/React.createElement("div", {
125
- className: "".concat(blockClass, "__label-spacer ").concat(carbon.prefix, "--label")
126
- }, "\xA0"), /*#__PURE__*/React.createElement("div", {
127
- className: "".concat(blockClass, "__buttons-inner")
128
- }, /*#__PURE__*/React.createElement(Button, {
129
- className: "".concat(blockClass, "__revert"),
130
- kind: "ghost",
131
- hasIconOnly: true,
132
- iconDescription: revertDescription,
133
- onClick: handleRevert,
134
- renderIcon: Reset16
135
- }), /*#__PURE__*/React.createElement(Button, {
136
- className: "".concat(blockClass, "__save"),
137
- kind: "ghost",
138
- hasIconOnly: true,
139
- iconDescription: saveDescription,
140
- onClick: handleSave,
141
- renderIcon: Checkmark16,
142
- disabled: invalid || saveDisabled || value === liveValue,
143
- "data-v": value,
144
- "data-lv": liveValue
145
- })))), inline && (showInvalid || showWarn) && /*#__PURE__*/React.createElement("div", {
146
- className: "".concat(blockClass, "__problem ").concat(carbon.prefix, "--form-requirement")
147
- }, showInvalid ? invalidText : warnText));
148
- }); // Return a placeholder if not released and not enabled by feature flag
149
-
150
- CancelableTextEdit = pkg.checkComponentEnabled(CancelableTextEdit, componentName); // The display name of the component, used by React. Note that displayName
151
- // is used in preference to relying on function.name.
152
-
153
- CancelableTextEdit.displayName = componentName; // The types and DocGen commentary for the component props,
154
- // in alphabetical order (for consistency).
155
- // See https://www.npmjs.com/package/prop-types#usage.
156
-
157
- CancelableTextEdit.propTypes = _objectSpread(_objectSpread({}, prepareProps(TextInput.propTypes, ['inline', 'invalid', 'invalidText', 'labelText', 'onChange', 'onInput', 'value', 'warn', 'warnText'])), {}, {
158
- /**
159
- * Provide an optional class to be applied to the containing node.
160
- */
161
- className: PropTypes.string,
162
-
163
- /**
164
- * hide the label
165
- */
166
- hideLabel: PropTypes.bool,
167
-
168
- /**
169
- * inline variant
170
- */
171
- inline: PropTypes.bool,
172
-
173
- /**
174
- * set invalid state for input
175
- */
176
- invalid: PropTypes.bool,
177
-
178
- /**
179
- * text shown when invalid is true
180
- */
181
- invalidText: PropTypes.string,
182
-
183
- /**
184
- * label for text input
185
- */
186
- labelText: PropTypes.string,
187
-
188
- /**
189
- * method called on change event
190
- */
191
- onChange: PropTypes.func,
192
-
193
- /**
194
- * method called on input event
195
- */
196
- onInput: PropTypes.func,
197
-
198
- /**
199
- * method called on revert event
200
- */
201
- onRevert: PropTypes.func,
202
-
203
- /**
204
- * label for revert button
205
- */
206
- revertDescription: PropTypes.string.isRequired,
207
-
208
- /**
209
- * label for save button
210
- */
211
- saveDescription: PropTypes.string.isRequired,
212
-
213
- /**
214
- * disabled state of the save button
215
- */
216
- saveDisabled: PropTypes.bool,
217
-
218
- /**
219
- * vertical size of control
220
- */
221
- size: PropTypes.oneOf(['sm', 'md', 'lg']),
222
-
223
- /**
224
- * initial/unedited value
225
- */
226
- value: PropTypes.string,
227
-
228
- /**
229
- * set warn state for input
230
- */
231
- warn: PropTypes.bool,
232
-
233
- /**
234
- * text shown when warn true
235
- */
236
- warnText: PropTypes.string
237
- }); // Default values for component props. Default values are not required for
238
- // props that are required, nor for props where the component can apply
239
- // 'undefined' values reasonably. Default values should be provided when the
240
- // component needs to make a choice or assumption when a prop is not supplied.
241
-
242
- CancelableTextEdit.defaultProps = {
243
- /* TODO: add defaults for relevant props. */
244
- size: 'md'
245
- };
@@ -1,15 +0,0 @@
1
- //
2
- // Copyright IBM Corp. 2020, 2020
3
- //
4
- // This source code is licensed under the Apache-2.0 license found in the
5
- // LICENSE file in the root directory of this source tree.
6
- //
7
- // ******************************
8
- // *
9
- // * ONLY EDIT IN /common-files/feature-flags files elsewhere are copies
10
- // * created by a pre-commit step
11
- // *
12
- // ******************************
13
- export default {
14
- 'enable-css-custom-properties': false
15
- };
@@ -1,265 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.CancelableTextEdit = void 0;
11
-
12
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
-
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
-
16
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
-
18
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
19
-
20
- var _react = _interopRequireWildcard(require("react"));
21
-
22
- var _propTypes = _interopRequireDefault(require("prop-types"));
23
-
24
- var _classnames = _interopRequireDefault(require("classnames"));
25
-
26
- var _carbonComponentsReact = require("carbon-components-react");
27
-
28
- var _propsHelper = require("../../global/js/utils/props-helper");
29
-
30
- var _settings = require("../../settings");
31
-
32
- var _devtools = require("../../global/js/utils/devtools");
33
-
34
- var _iconsReact = require("@carbon/icons-react");
35
-
36
- var _excluded = ["className", "hideLabel", "inline", "invalid", "invalidText", "labelText", "onChange", "onInput", "onRevert", "revertDescription", "saveDescription", "saveDisabled", "size", "value", "warn", "warnText"];
37
-
38
- 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
-
40
- 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
-
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
- // Carbon and package components we use.
47
-
48
- /* TODO: @import(s) of carbon components and other package components. */
49
- // The block part of our conventional BEM class names (blockClass__E--M).
50
- var blockClass = "".concat(_settings.pkg.prefix, "--cancelable-text-edit");
51
- var componentName = 'CancelableTextEdit'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
52
-
53
- /**
54
- * TODO: A description of the component.
55
- */
56
-
57
- var CancelableTextEdit = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
58
- var _cx;
59
-
60
- var className = _ref.className,
61
- hideLabel = _ref.hideLabel,
62
- inline = _ref.inline,
63
- invalid = _ref.invalid,
64
- invalidText = _ref.invalidText,
65
- labelText = _ref.labelText,
66
- onChange = _ref.onChange,
67
- onInput = _ref.onInput,
68
- onRevert = _ref.onRevert,
69
- revertDescription = _ref.revertDescription,
70
- saveDescription = _ref.saveDescription,
71
- saveDisabled = _ref.saveDisabled,
72
- size = _ref.size,
73
- value = _ref.value,
74
- warn = _ref.warn,
75
- warnText = _ref.warnText,
76
- rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
77
- // remove these props later
78
- var removeProps = ['children', 'onInput', 'onChange', 'value'];
79
- var showWarn = inline && warn && !invalid;
80
- var showInvalid = inline && invalid;
81
-
82
- var _useState = (0, _react.useState)(value !== null && value !== void 0 ? value : ''),
83
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
84
- liveValue = _useState2[0],
85
- setLiveValue = _useState2[1];
86
-
87
- (0, _react.useEffect)(function () {
88
- if (value !== liveValue) {
89
- setLiveValue(value);
90
- } // Do not care if liveValue changes here
91
- // eslint-disable-next-line react-hooks/exhaustive-deps
92
-
93
- }, [value]);
94
-
95
- var doInput = function doInput(newValue) {
96
- setLiveValue(newValue);
97
-
98
- if (onInput) {
99
- onInput(newValue);
100
- }
101
- };
102
-
103
- var handleInput = function handleInput(ev) {
104
- doInput(ev.target.value);
105
- };
106
-
107
- var handleRevert = function handleRevert() {
108
- doInput(value);
109
-
110
- if (onRevert) {
111
- onRevert(value);
112
- }
113
- };
114
-
115
- var handleSave = function handleSave() {
116
- if (onChange && !invalid) {
117
- onChange(liveValue);
118
- }
119
- };
120
-
121
- return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
122
- className: (0, _classnames.default)(className, "".concat(blockClass), "".concat(blockClass, "--").concat(size), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--invalid"), invalid), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--warn"), warn), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "--inline"), inline), _cx))
123
- }, (0, _devtools.getDevtoolsProps)(componentName)), /*#__PURE__*/_react.default.createElement("div", {
124
- className: "".concat(blockClass, "__main")
125
- }, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TextInput, (0, _extends2.default)({}, (0, _propsHelper.prepareProps)(rest, removeProps), {
126
- // it is not permitted to pass children down to TextInput guard against this
127
- className: "".concat(blockClass, "__input"),
128
- ref: ref,
129
- onInput: handleInput,
130
- size: size,
131
- value: liveValue !== null && liveValue !== void 0 ? liveValue : '' // ?? '' prevents controlled components test failure https://reactjs.org/docs/forms.html#controlled-components
132
- ,
133
- hideLabel: hideLabel,
134
- inline: inline,
135
- invalid: invalid,
136
- invalidText: invalidText,
137
- labelText: labelText,
138
- warn: warn,
139
- warnText: warnText
140
- })), /*#__PURE__*/_react.default.createElement("div", {
141
- className: "".concat(blockClass, "__buttons")
142
- }, !inline && !hideLabel && labelText && /*#__PURE__*/_react.default.createElement("div", {
143
- className: "".concat(blockClass, "__label-spacer ").concat(_settings.carbon.prefix, "--label")
144
- }, "\xA0"), /*#__PURE__*/_react.default.createElement("div", {
145
- className: "".concat(blockClass, "__buttons-inner")
146
- }, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
147
- className: "".concat(blockClass, "__revert"),
148
- kind: "ghost",
149
- hasIconOnly: true,
150
- iconDescription: revertDescription,
151
- onClick: handleRevert,
152
- renderIcon: _iconsReact.Reset16
153
- }), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
154
- className: "".concat(blockClass, "__save"),
155
- kind: "ghost",
156
- hasIconOnly: true,
157
- iconDescription: saveDescription,
158
- onClick: handleSave,
159
- renderIcon: _iconsReact.Checkmark16,
160
- disabled: invalid || saveDisabled || value === liveValue,
161
- "data-v": value,
162
- "data-lv": liveValue
163
- })))), inline && (showInvalid || showWarn) && /*#__PURE__*/_react.default.createElement("div", {
164
- className: "".concat(blockClass, "__problem ").concat(_settings.carbon.prefix, "--form-requirement")
165
- }, showInvalid ? invalidText : warnText));
166
- }); // Return a placeholder if not released and not enabled by feature flag
167
-
168
-
169
- exports.CancelableTextEdit = CancelableTextEdit;
170
- exports.CancelableTextEdit = CancelableTextEdit = _settings.pkg.checkComponentEnabled(CancelableTextEdit, componentName); // The display name of the component, used by React. Note that displayName
171
- // is used in preference to relying on function.name.
172
-
173
- CancelableTextEdit.displayName = componentName; // The types and DocGen commentary for the component props,
174
- // in alphabetical order (for consistency).
175
- // See https://www.npmjs.com/package/prop-types#usage.
176
-
177
- CancelableTextEdit.propTypes = _objectSpread(_objectSpread({}, (0, _propsHelper.prepareProps)(_carbonComponentsReact.TextInput.propTypes, ['inline', 'invalid', 'invalidText', 'labelText', 'onChange', 'onInput', 'value', 'warn', 'warnText'])), {}, {
178
- /**
179
- * Provide an optional class to be applied to the containing node.
180
- */
181
- className: _propTypes.default.string,
182
-
183
- /**
184
- * hide the label
185
- */
186
- hideLabel: _propTypes.default.bool,
187
-
188
- /**
189
- * inline variant
190
- */
191
- inline: _propTypes.default.bool,
192
-
193
- /**
194
- * set invalid state for input
195
- */
196
- invalid: _propTypes.default.bool,
197
-
198
- /**
199
- * text shown when invalid is true
200
- */
201
- invalidText: _propTypes.default.string,
202
-
203
- /**
204
- * label for text input
205
- */
206
- labelText: _propTypes.default.string,
207
-
208
- /**
209
- * method called on change event
210
- */
211
- onChange: _propTypes.default.func,
212
-
213
- /**
214
- * method called on input event
215
- */
216
- onInput: _propTypes.default.func,
217
-
218
- /**
219
- * method called on revert event
220
- */
221
- onRevert: _propTypes.default.func,
222
-
223
- /**
224
- * label for revert button
225
- */
226
- revertDescription: _propTypes.default.string.isRequired,
227
-
228
- /**
229
- * label for save button
230
- */
231
- saveDescription: _propTypes.default.string.isRequired,
232
-
233
- /**
234
- * disabled state of the save button
235
- */
236
- saveDisabled: _propTypes.default.bool,
237
-
238
- /**
239
- * vertical size of control
240
- */
241
- size: _propTypes.default.oneOf(['sm', 'md', 'lg']),
242
-
243
- /**
244
- * initial/unedited value
245
- */
246
- value: _propTypes.default.string,
247
-
248
- /**
249
- * set warn state for input
250
- */
251
- warn: _propTypes.default.bool,
252
-
253
- /**
254
- * text shown when warn true
255
- */
256
- warnText: _propTypes.default.string
257
- }); // Default values for component props. Default values are not required for
258
- // props that are required, nor for props where the component can apply
259
- // 'undefined' values reasonably. Default values should be provided when the
260
- // component needs to make a choice or assumption when a prop is not supplied.
261
-
262
- CancelableTextEdit.defaultProps = {
263
- /* TODO: add defaults for relevant props. */
264
- size: 'md'
265
- };
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "CancelableTextEdit", {
7
- enumerable: true,
8
- get: function get() {
9
- return _CancelableTextEdit.CancelableTextEdit;
10
- }
11
- });
12
-
13
- var _CancelableTextEdit = require("./CancelableTextEdit");
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- //
8
- // Copyright IBM Corp. 2020, 2020
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
- // ******************************
14
- // *
15
- // * ONLY EDIT IN /common-files/feature-flags files elsewhere are copies
16
- // * created by a pre-commit step
17
- // *
18
- // ******************************
19
- var _default = {
20
- 'enable-css-custom-properties': false
21
- };
22
- exports.default = _default;