@carbon/ibm-products 1.6.1 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +224 -143
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -3
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +1 -2
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +178 -142
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +3 -3
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +178 -142
- package/css/index.css.map +1 -1
- package/css/index.min.css +3 -3
- package/css/index.min.css.map +1 -1
- package/es/components/APIKeyModal/APIKeyModal.js +10 -13
- package/es/components/ActionBar/ActionBar.js +0 -3
- package/es/components/ActionBar/ActionBarItem.js +2 -6
- package/es/components/ActionSet/ActionSet.js +11 -13
- package/es/components/AddSelect/AddSelect.js +121 -25
- package/es/components/AddSelect/AddSelectBreadcrumbs.js +5 -5
- package/es/components/AddSelect/AddSelectColumn.js +21 -0
- package/es/components/AddSelect/AddSelectList.js +68 -9
- package/es/components/AddSelect/AddSelectSidebar.js +43 -5
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +0 -3
- package/es/components/ButtonMenu/ButtonMenu.js +6 -4
- package/es/components/ButtonMenu/ButtonMenuItem.js +1 -2
- package/es/components/Card/Card.js +31 -21
- package/es/components/Card/CardFooter.js +14 -10
- package/es/components/Card/CardHeader.js +8 -6
- package/es/components/Cascade/Cascade.js +5 -4
- package/es/components/ComboButton/ComboButton.js +0 -4
- package/es/components/ComboButton/ComboButtonItem/index.js +0 -5
- package/es/components/CreateFullPage/CreateFullPageStep.js +15 -8
- package/es/components/CreateModal/CreateModal.js +1 -4
- package/es/components/CreateTearsheet/CreateTearsheet.js +10 -11
- package/es/components/CreateTearsheet/CreateTearsheetStep.js +18 -14
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +454 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +322 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +64 -0
- package/es/components/DataSpreadsheet/createActiveCellFn.js +45 -0
- package/es/components/DataSpreadsheet/createCellSelectionArea.js +45 -0
- package/es/components/DataSpreadsheet/generateData.js +47 -0
- package/es/components/DataSpreadsheet/getCellSize.js +30 -0
- package/es/components/{CancelableTextEdit → DataSpreadsheet}/index.js +2 -2
- package/es/components/EditSidePanel/EditSidePanel.js +9 -10
- package/es/components/EmptyStates/EmptyState.js +7 -6
- package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +4 -8
- package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +4 -8
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +4 -8
- package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +4 -8
- package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +4 -8
- package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +4 -8
- package/es/components/ExampleComponent/ExampleComponent.js +12 -13
- package/es/components/ExportModal/ExportModal.js +13 -9
- package/es/components/ExpressiveCard/ExpressiveCard.js +0 -8
- package/es/components/ImportModal/ImportModal.js +7 -5
- package/es/components/InlineEdit/InlineEdit.js +51 -46
- package/es/components/LoadingBar/LoadingBar.js +13 -17
- package/es/components/ModifiedTabs/ModifiedTabLabelNew.js +0 -4
- package/es/components/ModifiedTabs/ModifiedTabLabelWithClose.js +0 -5
- package/es/components/ModifiedTabs/ModifiedTabs.js +24 -18
- package/es/components/NotificationsPanel/NotificationsPanel.js +109 -86
- package/es/components/OptionsTile/OptionsTile.js +6 -9
- package/es/components/PageHeader/PageHeader.js +10 -7
- package/es/components/ProductiveCard/ProductiveCard.js +23 -12
- package/es/components/RemoveModal/RemoveModal.js +0 -3
- package/es/components/SidePanel/SidePanel.js +22 -17
- package/es/components/TagSet/TagSet.js +13 -9
- package/es/components/TagSet/TagSetModal.js +16 -12
- package/es/components/TagSet/TagSetOverflow.js +21 -13
- package/es/components/Tearsheet/Tearsheet.js +27 -18
- package/es/components/Tearsheet/TearsheetNarrow.js +18 -15
- package/es/components/Tearsheet/TearsheetShell.js +3 -4
- package/es/components/Toolbar/ToolbarButton.js +0 -3
- package/es/components/WebTerminal/WebTerminal.js +17 -18
- package/es/components/index.js +2 -2
- package/es/global/js/hooks/index.js +1 -0
- package/es/global/js/hooks/useActiveElement.js +27 -0
- package/es/global/js/package-settings.js +2 -1
- package/es/global/js/utils/DisplayBox.js +31 -0
- package/es/global/js/utils/Wrap.js +7 -5
- package/es/global/js/utils/deepCloneObject.js +26 -0
- package/es/global/js/utils/getScrollbarWidth.js +14 -0
- package/lib/components/APIKeyModal/APIKeyModal.js +10 -13
- package/lib/components/ActionBar/ActionBar.js +0 -3
- package/lib/components/ActionBar/ActionBarItem.js +2 -6
- package/lib/components/ActionSet/ActionSet.js +11 -13
- package/lib/components/AddSelect/AddSelect.js +119 -24
- package/lib/components/AddSelect/AddSelectBreadcrumbs.js +3 -4
- package/lib/components/AddSelect/AddSelectColumn.js +37 -0
- package/lib/components/AddSelect/AddSelectList.js +66 -9
- package/lib/components/AddSelect/AddSelectSidebar.js +43 -4
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +0 -3
- package/lib/components/ButtonMenu/ButtonMenu.js +6 -4
- package/lib/components/ButtonMenu/ButtonMenuItem.js +1 -2
- package/lib/components/Card/Card.js +31 -21
- package/lib/components/Card/CardFooter.js +14 -10
- package/lib/components/Card/CardHeader.js +8 -6
- package/lib/components/Cascade/Cascade.js +5 -4
- package/lib/components/ComboButton/ComboButton.js +0 -4
- package/lib/components/ComboButton/ComboButtonItem/index.js +0 -5
- package/lib/components/CreateFullPage/CreateFullPageStep.js +17 -14
- package/lib/components/CreateModal/CreateModal.js +1 -4
- package/lib/components/CreateTearsheet/CreateTearsheet.js +10 -11
- package/lib/components/CreateTearsheet/CreateTearsheetStep.js +20 -20
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +478 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +349 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +80 -0
- package/lib/components/DataSpreadsheet/createActiveCellFn.js +56 -0
- package/lib/components/DataSpreadsheet/createCellSelectionArea.js +56 -0
- package/lib/components/DataSpreadsheet/generateData.js +58 -0
- package/lib/components/DataSpreadsheet/getCellSize.js +39 -0
- package/lib/components/DataSpreadsheet/index.js +13 -0
- package/lib/components/EditSidePanel/EditSidePanel.js +9 -10
- package/lib/components/EmptyStates/EmptyState.js +9 -8
- package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +3 -7
- package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +3 -7
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +3 -7
- package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +3 -7
- package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +3 -7
- package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +3 -7
- package/lib/components/ExampleComponent/ExampleComponent.js +12 -13
- package/lib/components/ExportModal/ExportModal.js +13 -9
- package/lib/components/ExpressiveCard/ExpressiveCard.js +0 -8
- package/lib/components/ImportModal/ImportModal.js +7 -5
- package/lib/components/InlineEdit/InlineEdit.js +51 -46
- package/lib/components/LoadingBar/LoadingBar.js +13 -17
- package/lib/components/ModifiedTabs/ModifiedTabLabelNew.js +0 -4
- package/lib/components/ModifiedTabs/ModifiedTabLabelWithClose.js +0 -5
- package/lib/components/ModifiedTabs/ModifiedTabs.js +24 -18
- package/lib/components/NotificationsPanel/NotificationsPanel.js +109 -86
- package/lib/components/OptionsTile/OptionsTile.js +6 -9
- package/lib/components/PageHeader/PageHeader.js +9 -6
- package/lib/components/ProductiveCard/ProductiveCard.js +24 -18
- package/lib/components/RemoveModal/RemoveModal.js +0 -3
- package/lib/components/SidePanel/SidePanel.js +22 -17
- package/lib/components/TagSet/TagSet.js +13 -9
- package/lib/components/TagSet/TagSetModal.js +17 -13
- package/lib/components/TagSet/TagSetOverflow.js +24 -19
- package/lib/components/Tearsheet/Tearsheet.js +26 -17
- package/lib/components/Tearsheet/TearsheetNarrow.js +18 -15
- package/lib/components/Tearsheet/TearsheetShell.js +2 -3
- package/lib/components/Toolbar/ToolbarButton.js +0 -3
- package/lib/components/WebTerminal/WebTerminal.js +17 -18
- package/lib/components/index.js +8 -8
- package/lib/global/js/hooks/index.js +8 -0
- package/lib/global/js/hooks/useActiveElement.js +39 -0
- package/lib/global/js/package-settings.js +2 -1
- package/lib/global/js/utils/DisplayBox.js +46 -0
- package/lib/global/js/utils/Wrap.js +7 -5
- package/lib/global/js/utils/deepCloneObject.js +37 -0
- package/lib/global/js/utils/getScrollbarWidth.js +23 -0
- package/package.json +18 -16
- package/scss/components/{CancelableTextEdit → ActionBar}/_storybook-styles.scss +2 -2
- package/scss/components/ActionSet/_storybook-styles.scss +1 -3
- package/scss/components/AddSelect/_add-select.scss +77 -1
- package/scss/components/BreadcrumbWithOverflow/_storybook-styles.scss +8 -0
- package/scss/components/ButtonSetWithOverflow/_storybook-styles.scss +8 -0
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +120 -0
- package/scss/components/{CancelableTextEdit → DataSpreadsheet}/_index.scss +2 -2
- package/scss/components/DataSpreadsheet/_storybook-styles.scss +6 -0
- package/scss/components/InlineEdit/_inline-edit.scss +22 -8
- package/scss/components/InlineEdit/_storybook-styles.scss +1 -0
- package/scss/components/TagSet/_storybook-styles.scss +8 -0
- package/scss/components/Tearsheet/_tearsheet.scss +1 -2
- package/scss/components/_index.scss +1 -1
- package/scss/global/styles/_display-box.scss +62 -0
- package/es/components/CancelableTextEdit/CancelableTextEdit.js +0 -245
- package/lib/components/CancelableTextEdit/CancelableTextEdit.js +0 -265
- package/lib/components/CancelableTextEdit/index.js +0 -13
- package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +0 -212
@@ -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, Close16 } 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: Close16
|
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,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.Close16
|
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");
|