@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.
- package/css/index-full-carbon.css +389 -139
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +9 -3
- package/css/index-full-carbon.min.css.map +1 -0
- package/css/index-without-carbon-released-only.css +33 -27
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +3 -3
- package/css/index-without-carbon-released-only.min.css.map +1 -0
- package/css/index-without-carbon.css +330 -133
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +9 -3
- package/css/index-without-carbon.min.css.map +1 -0
- package/css/index.css +332 -135
- package/css/index.css.map +1 -1
- package/css/index.min.css +9 -3
- package/css/index.min.css.map +1 -0
- 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 +122 -72
- package/es/components/AddSelect/AddSelectBreadcrumbs.js +56 -0
- package/es/components/AddSelect/AddSelectList.js +94 -0
- package/es/components/AddSelect/AddSelectSidebar.js +110 -0
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +5 -5
- package/es/components/ButtonMenu/ButtonMenu.js +6 -4
- package/es/components/ButtonMenu/ButtonMenuItem.js +1 -2
- package/es/components/Card/Card.js +37 -25
- 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 +414 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +138 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +64 -0
- package/es/components/DataSpreadsheet/createActiveCellFn.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 +8 -7
- package/es/components/EmptyStates/EmptyStateContent.js +2 -2
- package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +5 -9
- package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +5 -9
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +5 -9
- package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +5 -9
- package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +5 -9
- package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +5 -9
- 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 +256 -88
- 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 +125 -89
- package/es/components/OptionsTile/OptionsTile.js +6 -9
- package/es/components/PageHeader/PageHeader.js +19 -13
- package/es/components/PageHeader/PageHeaderTitle.js +10 -6
- package/es/components/ProductiveCard/ProductiveCard.js +23 -12
- package/es/components/RemoveModal/RemoveModal.js +0 -3
- package/es/components/SidePanel/SidePanel.js +54 -32
- 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 +18 -19
- 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/Wrap.js +7 -5
- package/es/global/js/utils/getScrollbarWidth.js +14 -0
- package/es/settings.js +0 -5
- 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 +126 -72
- package/lib/components/AddSelect/AddSelectBreadcrumbs.js +71 -0
- package/lib/components/AddSelect/AddSelectList.js +112 -0
- package/lib/components/AddSelect/AddSelectSidebar.js +122 -0
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +5 -5
- package/lib/components/ButtonMenu/ButtonMenu.js +6 -4
- package/lib/components/ButtonMenu/ButtonMenuItem.js +1 -2
- package/lib/components/Card/Card.js +37 -25
- 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 +438 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +161 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +80 -0
- package/lib/components/DataSpreadsheet/createActiveCellFn.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 +10 -9
- package/lib/components/EmptyStates/EmptyStateContent.js +2 -2
- package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +4 -8
- package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +4 -8
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +4 -8
- package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +4 -8
- package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +4 -8
- package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +4 -8
- 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 +253 -87
- 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 +122 -87
- package/lib/components/OptionsTile/OptionsTile.js +6 -9
- package/lib/components/PageHeader/PageHeader.js +18 -12
- package/lib/components/PageHeader/PageHeaderTitle.js +10 -6
- package/lib/components/ProductiveCard/ProductiveCard.js +24 -18
- package/lib/components/RemoveModal/RemoveModal.js +0 -3
- package/lib/components/SidePanel/SidePanel.js +54 -32
- 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 +18 -19
- 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/Wrap.js +7 -5
- package/lib/global/js/utils/getScrollbarWidth.js +23 -0
- package/lib/settings.js +0 -6
- package/package.json +25 -23
- package/scss/components/AddSelect/_add-select.scss +59 -5
- package/scss/components/BreadcrumbWithOverflow/_index.scss +1 -1
- package/scss/components/CreateInfluencer/_create-influencer.scss +4 -4
- package/scss/components/CreateTearsheet/_create-tearsheet.scss +2 -2
- package/scss/components/CreateTearsheetNarrow/_storybook-styles.scss +0 -6
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +102 -0
- package/scss/components/{CancelableTextEdit → DataSpreadsheet}/_index.scss +2 -2
- package/scss/components/DataSpreadsheet/_storybook-styles.scss +6 -0
- package/scss/components/EditSidePanel/_storybook-styles.scss +0 -8
- package/scss/components/InlineEdit/_inline-edit.scss +293 -10
- package/scss/components/InlineEdit/_storybook-styles.scss +12 -6
- package/scss/components/LoadingBar/_storybook-styles.scss +0 -5
- package/scss/components/NotificationsPanel/_notifications-panel.scss +2 -2
- package/scss/components/OptionsTile/_storybook-styles.scss +0 -7
- package/scss/components/PageHeader/_index.scss +1 -1
- package/scss/components/PageHeader/_page-header.scss +4 -1
- package/scss/components/ProductiveCard/_productive-card.scss +0 -4
- package/scss/components/SidePanel/_side-panel.scss +15 -6
- package/scss/components/StatusIcon/_index.scss +1 -1
- package/scss/components/StatusIcon/_status-icon.scss +4 -4
- package/scss/components/TagSet/_index.scss +1 -1
- package/scss/components/UserProfileImage/_index.scss +1 -1
- package/scss/components/UserProfileImage/_user-profile-image.scss +2 -2
- package/scss/components/WebTerminal/_web-terminal.scss +2 -2
- package/scss/components/_index.scss +1 -1
- package/scss/global/styles/_project-settings.scss +5 -1
- package/es/components/CancelableTextEdit/CancelableTextEdit.js +0 -245
- package/es/generated/feature-flags/feature-flags.js +0 -15
- package/lib/components/CancelableTextEdit/CancelableTextEdit.js +0 -265
- package/lib/components/CancelableTextEdit/index.js +0 -13
- package/lib/generated/feature-flags/feature-flags.js +0 -22
- package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +0 -211
- package/scss/components/CancelableTextEdit/_storybook-styles.scss +0 -15
- package/scss/generated/feature-flags/_feature-flags.scss +0 -19
@@ -24,9 +24,14 @@ import PropTypes from 'prop-types';
|
|
24
24
|
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
25
25
|
import uuidv4 from '../../global/js/utils/uuidv4';
|
26
26
|
import { pkg } from '../../settings';
|
27
|
-
var componentName = 'ImportModal';
|
27
|
+
var componentName = 'ImportModal'; // Default values for props
|
28
|
+
|
29
|
+
var defaults = {
|
30
|
+
accept: Object.freeze([])
|
31
|
+
};
|
28
32
|
export var ImportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
29
|
-
var accept = _ref.accept,
|
33
|
+
var _ref$accept = _ref.accept,
|
34
|
+
accept = _ref$accept === void 0 ? defaults.accept : _ref$accept,
|
30
35
|
className = _ref.className,
|
31
36
|
defaultErrorBody = _ref.defaultErrorBody,
|
32
37
|
defaultErrorHeader = _ref.defaultErrorHeader,
|
@@ -416,7 +421,4 @@ ImportModal.propTypes = {
|
|
416
421
|
*/
|
417
422
|
title: PropTypes.string.isRequired
|
418
423
|
};
|
419
|
-
ImportModal.defaultProps = {
|
420
|
-
accept: []
|
421
|
-
};
|
422
424
|
ImportModal.displayName = componentName;
|
@@ -2,11 +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 = ["className", "disabled", "editDescription", "
|
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; }
|
5
|
+
var _excluded = ["cancelDescription", "className", "disabled", "editDescription", "editVisibleOnHoverOnly", "id", "invalid", "invalidText", "labelText", "light", "onCancel", "onSave", "onChange", "placeholder", "saveDescription", "size", "value", "warn", "warnText"];
|
10
6
|
|
11
7
|
/**
|
12
8
|
* Copyright IBM Corp. 2022, 2022
|
@@ -15,7 +11,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
15
11
|
* LICENSE file in the root directory of this source tree.
|
16
12
|
*/
|
17
13
|
// Import portions of React that are needed.
|
18
|
-
import React, { useState } from 'react'; // Other standard imports.
|
14
|
+
import React, { useRef, useState } from 'react'; // Other standard imports.
|
19
15
|
|
20
16
|
import PropTypes from 'prop-types';
|
21
17
|
import cx from 'classnames';
|
@@ -24,94 +20,266 @@ import { pkg, carbon } from '../../settings'; // Carbon and package components w
|
|
24
20
|
|
25
21
|
/* TODO: @import(s) of carbon components and other package components. */
|
26
22
|
|
27
|
-
import { CancelableTextEdit } from '../';
|
28
23
|
import { Button } from 'carbon-components-react';
|
29
|
-
import { Edit16, EditOff16 } from '@carbon/icons-react'; // The block part of our conventional BEM class names (blockClass__E--M).
|
24
|
+
import { Close16, Edit16, EditOff16, Checkmark16, WarningFilled16, WarningAltFilled16 } from '@carbon/icons-react'; // The block part of our conventional BEM class names (blockClass__E--M).
|
30
25
|
|
31
26
|
var blockClass = "".concat(pkg.prefix, "--inline-edit");
|
32
27
|
var componentName = 'InlineEdit'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
|
33
28
|
|
29
|
+
var defaults = {
|
30
|
+
light: true,
|
31
|
+
// defaults to true to reflect design
|
32
|
+
size: 'md'
|
33
|
+
};
|
34
34
|
/**
|
35
35
|
* TODO: A description of the component.
|
36
36
|
*/
|
37
37
|
|
38
|
-
export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref,
|
39
|
-
var
|
38
|
+
export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
|
39
|
+
var _cx, _refInput$current, _refInput$current$inn, _cx3;
|
40
|
+
|
41
|
+
var cancelDescription = _ref.cancelDescription,
|
42
|
+
className = _ref.className,
|
40
43
|
disabled = _ref.disabled,
|
41
44
|
editDescription = _ref.editDescription,
|
45
|
+
editVisibleOnHoverOnly = _ref.editVisibleOnHoverOnly,
|
42
46
|
id = _ref.id,
|
43
|
-
inline = _ref.inline,
|
44
47
|
invalid = _ref.invalid,
|
45
48
|
invalidText = _ref.invalidText,
|
46
49
|
labelText = _ref.labelText,
|
50
|
+
_ref$light = _ref.light,
|
51
|
+
light = _ref$light === void 0 ? defaults.light : _ref$light,
|
52
|
+
onCancel = _ref.onCancel,
|
53
|
+
onSave = _ref.onSave,
|
47
54
|
onChange = _ref.onChange,
|
48
|
-
|
49
|
-
onRevert = _ref.onRevert,
|
50
|
-
revertDescription = _ref.revertDescription,
|
55
|
+
placeholder = _ref.placeholder,
|
51
56
|
saveDescription = _ref.saveDescription,
|
52
|
-
|
53
|
-
size = _ref.size,
|
57
|
+
_ref$size = _ref.size,
|
58
|
+
size = _ref$size === void 0 ? defaults.size : _ref$size,
|
54
59
|
value = _ref.value,
|
55
60
|
warn = _ref.warn,
|
56
61
|
warnText = _ref.warnText,
|
57
62
|
rest = _objectWithoutProperties(_ref, _excluded);
|
58
63
|
|
64
|
+
var refInput = useRef(null);
|
65
|
+
var localRef = useRef(null);
|
66
|
+
var ref = refIn || localRef;
|
67
|
+
|
59
68
|
var _useState = useState(false),
|
60
69
|
_useState2 = _slicedToArray(_useState, 2),
|
61
70
|
editing = _useState2[0],
|
62
71
|
setEditing = _useState2[1];
|
63
72
|
|
64
|
-
var
|
65
|
-
|
66
|
-
|
67
|
-
|
73
|
+
var _useState3 = useState(value),
|
74
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
75
|
+
internalValue = _useState4[0],
|
76
|
+
setInternalValue = _useState4[1];
|
77
|
+
|
78
|
+
var showValidation = invalid || warn;
|
79
|
+
var validationText = invalidText || warnText;
|
80
|
+
var validationIcon = showValidation ? invalid ? /*#__PURE__*/React.createElement(WarningFilled16, null) : /*#__PURE__*/React.createElement(WarningAltFilled16, null) : null;
|
81
|
+
|
82
|
+
var doSetEditing = function doSetEditing(value) {
|
83
|
+
if (value === false) {
|
84
|
+
// move scroll to start
|
85
|
+
refInput.current.scrollLeft = 0;
|
86
|
+
}
|
87
|
+
|
88
|
+
setEditing(!disabled && value);
|
89
|
+
};
|
90
|
+
|
91
|
+
var handleEdit = function handleEdit(ev) {
|
92
|
+
if (!disabled) {
|
93
|
+
var rightOfInput = ev.currentTarget.classList.contains("".concat(blockClass, "__edit")) || ev.target.classList.contains("".concat(blockClass, "__after-input-elements"));
|
94
|
+
var leftOfInput = ev.currentTarget = ev.target.classList.contains("".concat(blockClass)); // clicking on the content editable element should not set either of these to true
|
95
|
+
|
96
|
+
if (rightOfInput || leftOfInput) {
|
97
|
+
doSetEditing(true);
|
98
|
+
setTimeout(function () {
|
99
|
+
refInput.current.focus(); // select all the content
|
100
|
+
|
101
|
+
document.getSelection().selectAllChildren(refInput.current);
|
102
|
+
|
103
|
+
if (rightOfInput) {
|
104
|
+
document.getSelection().collapseToEnd();
|
105
|
+
refInput.current.scrollLeft = 9999; // never going to get there but ensures at end.
|
106
|
+
} else {
|
107
|
+
document.getSelection().collapseToStart();
|
108
|
+
refInput.current.scrollLeft = 0; // scroll to start
|
109
|
+
}
|
110
|
+
}, 0);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
};
|
114
|
+
|
115
|
+
var handleFocus = function handleFocus(ev) {
|
116
|
+
ev.preventDefault();
|
117
|
+
|
118
|
+
if (!editing && ev.target.classList.contains("".concat(blockClass, "__input"))) {
|
119
|
+
doSetEditing(true);
|
120
|
+
}
|
121
|
+
};
|
122
|
+
|
123
|
+
var handleSave = function handleSave() {
|
124
|
+
doSetEditing(false);
|
125
|
+
document.getSelection().removeAllRanges();
|
126
|
+
|
127
|
+
if (onSave) {
|
128
|
+
onSave(refInput.current.innerText);
|
129
|
+
}
|
130
|
+
};
|
131
|
+
|
132
|
+
var handleInput = function handleInput() {
|
133
|
+
setInternalValue(refInput.current.innerText);
|
134
|
+
|
135
|
+
if (onChange) {
|
136
|
+
onChange(refInput.current.innerText);
|
137
|
+
}
|
138
|
+
};
|
139
|
+
|
140
|
+
var handlePaste = function handlePaste(ev) {
|
141
|
+
ev.preventDefault(); // Get clipboard as plain text
|
142
|
+
|
143
|
+
var text = (ev.clipboardData || window.clipboardData).getData('text/plain'); // remove \n
|
144
|
+
|
145
|
+
var sanitizedText = text.replaceAll(/\n/g, '') // remove carriage returns
|
146
|
+
.replaceAll(/\t/g, ' '); // replace tab with two spaces
|
147
|
+
|
148
|
+
if (document.queryCommandSupported('insertText')) {
|
149
|
+
document.execCommand('insertText', false, sanitizedText);
|
150
|
+
} else {
|
151
|
+
// Insert text at the current position of caret
|
152
|
+
var range = document.getSelection().getRangeAt(0);
|
153
|
+
range.deleteContents();
|
154
|
+
var textNode = document.createTextNode(sanitizedText);
|
155
|
+
range.insertNode(textNode); // move selection end of textNode
|
156
|
+
|
157
|
+
range.selectNodeContents(textNode);
|
158
|
+
range.collapse(false); // remove existing range
|
159
|
+
|
160
|
+
var selection = document.getSelection();
|
161
|
+
selection.removeAllRanges(); // set the new range
|
162
|
+
|
163
|
+
selection.addRange(range);
|
164
|
+
}
|
68
165
|
};
|
69
166
|
|
70
|
-
var
|
71
|
-
|
72
|
-
|
167
|
+
var handleCancel = function handleCancel() {
|
168
|
+
refInput.current.innerText = value;
|
169
|
+
handleInput(value);
|
170
|
+
doSetEditing(false);
|
171
|
+
document.getSelection().removeAllRanges();
|
172
|
+
|
173
|
+
if (onCancel) {
|
174
|
+
onCancel(value);
|
175
|
+
}
|
73
176
|
};
|
74
177
|
|
75
|
-
var
|
76
|
-
|
77
|
-
|
178
|
+
var handleBlur = function handleBlur(ev) {
|
179
|
+
if (!ref.current.contains(ev.relatedTarget)) {
|
180
|
+
handleSave();
|
181
|
+
}
|
78
182
|
};
|
79
183
|
|
80
|
-
var
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
184
|
+
var handleKeyDown = function handleKeyDown(ev) {
|
185
|
+
if (ev.key === 'Enter') {
|
186
|
+
ev.preventDefault();
|
187
|
+
refInput.current.blur(); // will cause save
|
188
|
+
}
|
189
|
+
};
|
190
|
+
/*
|
191
|
+
The HTML is structured as follows:
|
192
|
+
<container>
|
193
|
+
<!-- margin left of input to match Carbon -->
|
194
|
+
<content-editable>
|
195
|
+
<-- margin right of input space for after-input-elements -->
|
196
|
+
<after-input-elements>
|
197
|
+
</container>
|
198
|
+
NOTE:
|
199
|
+
- An input is not used as this would not permit a heading tag e.g. <h2>.
|
200
|
+
- Some padding is added to the left 16px standard for a Carbon text input
|
201
|
+
- The after-input-elements are position absolute with a margin to on the input to reserve space. Using inline-flex
|
202
|
+
- does not measure space properly for the input otherwise.
|
203
|
+
- The content editable is not expected to change size when buttons are added, to ensure the text does not move space
|
204
|
+
is reserved up front for buttons and invalid icon. Mostly this is only noticed if the width of the component is not 100%.
|
205
|
+
which can be shown by setting inlineEditFullWidth to false in storybook.
|
206
|
+
In making content-editable behave like an input of type text we have to account for.
|
207
|
+
- Enforcing a single line
|
208
|
+
- Pasting of non-text e.g. html or text with carriage returns
|
209
|
+
- The padding and border not hiding typed in text.
|
210
|
+
- Placing the cursor at the start or end depending on area clicked (before for left-padding)
|
211
|
+
*/
|
212
|
+
|
213
|
+
|
214
|
+
var toolbarAnimation = true;
|
215
|
+
return (
|
216
|
+
/*#__PURE__*/
|
217
|
+
// eslint-disable-next-line
|
218
|
+
React.createElement("div", {
|
219
|
+
className: cx(blockClass, // Apply the block class to the main HTML element
|
220
|
+
className, // Apply any supplied class names to the main HTML element.
|
221
|
+
"".concat(blockClass, "--").concat(size), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--disabled"), disabled), _defineProperty(_cx, "".concat(blockClass, "--editing"), editing), _defineProperty(_cx, "".concat(blockClass, "--invalid"), invalid), _defineProperty(_cx, "".concat(blockClass, "--warn"), warn), _defineProperty(_cx, "".concat(blockClass, "--light"), light), _defineProperty(_cx, "".concat(blockClass, "--overflows"), refInput.current && refInput.current.scrollWidth > refInput.current.offsetWidth), _cx)),
|
222
|
+
onClick: handleEdit // disabled eslint for click handler
|
223
|
+
,
|
224
|
+
onBlur: handleBlur,
|
225
|
+
ref: ref
|
226
|
+
}, /*#__PURE__*/React.createElement("div", _extends({}, rest, getDevtoolsProps(componentName), {
|
227
|
+
id: id,
|
228
|
+
size: size,
|
229
|
+
className: cx("".concat(blockClass, "__input"), _defineProperty({}, "".concat(blockClass, "__input--empty"), ((_refInput$current = refInput.current) === null || _refInput$current === void 0 ? void 0 : (_refInput$current$inn = _refInput$current.innerText) === null || _refInput$current$inn === void 0 ? void 0 : _refInput$current$inn.length) === 0)),
|
230
|
+
contentEditable: true,
|
231
|
+
"aria-label": labelText,
|
232
|
+
role: "textbox",
|
233
|
+
tabIndex: disabled ? -1 : 0,
|
234
|
+
onFocus: handleFocus,
|
235
|
+
onInput: handleInput,
|
236
|
+
onKeyDown: handleKeyDown,
|
237
|
+
onPaste: handlePaste,
|
238
|
+
suppressContentEditableWarning: true,
|
239
|
+
ref: refInput,
|
240
|
+
"data-placeholder": placeholder !== null && placeholder !== void 0 ? placeholder : labelText
|
241
|
+
}), value), /*#__PURE__*/React.createElement("div", {
|
242
|
+
className: cx("".concat(blockClass, "__after-input-elements")) // tabindex -1 fixes blur target test when clicking on after-input-elements background
|
243
|
+
,
|
244
|
+
tabIndex: "-1"
|
245
|
+
}, /*#__PURE__*/React.createElement("div", {
|
246
|
+
className: "".concat(blockClass, "__ellipsis"),
|
247
|
+
"aria-hidden": !editing
|
248
|
+
}, "\u2026"), /*#__PURE__*/React.createElement("div", {
|
249
|
+
className: cx("".concat(blockClass, "__toolbar"), (_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__toolbar--animation"), toolbarAnimation), _defineProperty(_cx3, "".concat(blockClass, "__toolbar--saveable"), refInput.current && value !== internalValue), _cx3))
|
250
|
+
}, showValidation && /*#__PURE__*/React.createElement("div", {
|
251
|
+
className: "".concat(blockClass, "__validation-icon")
|
252
|
+
}, validationIcon), editing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
253
|
+
className: "".concat(blockClass, "__cancel"),
|
254
|
+
kind: "ghost",
|
255
|
+
hasIconOnly: true,
|
256
|
+
iconDescription: cancelDescription,
|
257
|
+
onClick: handleCancel,
|
258
|
+
renderIcon: Close16
|
259
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
260
|
+
className: "".concat(blockClass, "__save"),
|
261
|
+
kind: "ghost",
|
262
|
+
hasIconOnly: true,
|
263
|
+
iconDescription: saveDescription,
|
264
|
+
onClick: handleSave,
|
265
|
+
renderIcon: Checkmark16,
|
266
|
+
disabled: value === internalValue
|
267
|
+
})) : /*#__PURE__*/React.createElement(Button, {
|
268
|
+
"aria-hidden": "true",
|
269
|
+
className: cx("".concat(blockClass, "__edit"), _defineProperty({}, "".concat(blockClass, "__edit--hover-visible"), editVisibleOnHoverOnly)),
|
270
|
+
kind: "ghost",
|
271
|
+
hasIconOnly: true,
|
272
|
+
iconDescription: editDescription,
|
273
|
+
onClick: handleEdit,
|
274
|
+
renderIcon: disabled ? EditOff16 : Edit16,
|
275
|
+
disabled: disabled,
|
276
|
+
tabIndex: -1
|
277
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
278
|
+
className: cx("".concat(blockClass, "__disabled-cover"))
|
279
|
+
}), showValidation && validationText && validationText.length > 0 && /*#__PURE__*/React.createElement("div", {
|
280
|
+
className: "".concat(blockClass, "__validation-text ").concat(carbon.prefix, "--form-requirement")
|
281
|
+
}, validationText))
|
282
|
+
);
|
115
283
|
}); // Return a placeholder if not released and not enabled by feature flag
|
116
284
|
|
117
285
|
InlineEdit = pkg.checkComponentEnabled(InlineEdit, componentName); // The display name of the component, used by React. Note that displayName
|
@@ -122,6 +290,11 @@ InlineEdit.displayName = componentName; // The types and DocGen commentary for t
|
|
122
290
|
// See https://www.npmjs.com/package/prop-types#usage.
|
123
291
|
|
124
292
|
InlineEdit.propTypes = {
|
293
|
+
/**
|
294
|
+
* label for cancel button
|
295
|
+
*/
|
296
|
+
cancelDescription: PropTypes.string.isRequired,
|
297
|
+
|
125
298
|
/**
|
126
299
|
* Provide an optional class to be applied to the containing node.
|
127
300
|
*/
|
@@ -138,16 +311,15 @@ InlineEdit.propTypes = {
|
|
138
311
|
editDescription: PropTypes.string.isRequired,
|
139
312
|
|
140
313
|
/**
|
141
|
-
*
|
314
|
+
* In some scenarios the edit icon only needs to be shown on hover. These cases are where continual visibility of
|
315
|
+
* the edit icon is redundant. E.g. a spreadsheet a property panel.
|
142
316
|
*/
|
143
|
-
|
144
|
-
|
145
|
-
/* TODO: add types and DocGen for all props. */
|
317
|
+
editVisibleOnHoverOnly: PropTypes.bool,
|
146
318
|
|
147
319
|
/**
|
148
|
-
|
149
|
-
|
150
|
-
|
320
|
+
* ID for inline edit
|
321
|
+
*/
|
322
|
+
id: PropTypes.string,
|
151
323
|
|
152
324
|
/**
|
153
325
|
* set invalid state for input
|
@@ -165,34 +337,38 @@ InlineEdit.propTypes = {
|
|
165
337
|
labelText: PropTypes.string,
|
166
338
|
|
167
339
|
/**
|
168
|
-
*
|
340
|
+
* change background to light version (mimic React TextInput)
|
169
341
|
*/
|
170
|
-
|
342
|
+
light: PropTypes.bool,
|
171
343
|
|
172
344
|
/**
|
173
|
-
* method called on
|
345
|
+
* method called on cancel event
|
174
346
|
*/
|
175
|
-
|
347
|
+
onCancel: PropTypes.func,
|
176
348
|
|
177
349
|
/**
|
178
|
-
* method called on
|
350
|
+
* method called on input event (it's a React thing onChange behaves like on input).
|
351
|
+
*
|
352
|
+
* NOTE: caller to handle invalid/warn states and associated text
|
179
353
|
*/
|
180
|
-
|
354
|
+
onChange: PropTypes.func,
|
181
355
|
|
182
356
|
/**
|
183
|
-
*
|
357
|
+
* method called on change event
|
358
|
+
*
|
359
|
+
* NOTE: caller to handle invalid/warn states and associated text
|
184
360
|
*/
|
185
|
-
|
361
|
+
onSave: PropTypes.func,
|
186
362
|
|
187
363
|
/**
|
188
|
-
*
|
364
|
+
* placeholder for text input
|
189
365
|
*/
|
190
|
-
|
366
|
+
placeholder: PropTypes.string,
|
191
367
|
|
192
368
|
/**
|
193
|
-
*
|
369
|
+
* label for save button
|
194
370
|
*/
|
195
|
-
|
371
|
+
saveDescription: PropTypes.string.isRequired,
|
196
372
|
|
197
373
|
/**
|
198
374
|
* vertical size of control
|
@@ -213,12 +389,4 @@ InlineEdit.propTypes = {
|
|
213
389
|
* text shown when warn true
|
214
390
|
*/
|
215
391
|
warnText: PropTypes.string
|
216
|
-
}; // Default values for component props. Default values are not required for
|
217
|
-
// props that are required, nor for props where the component can apply
|
218
|
-
// 'undefined' values reasonably. Default values should be provided when the
|
219
|
-
// component needs to make a choice or assumption when a prop is not supplied.
|
220
|
-
|
221
|
-
InlineEdit.defaultProps = {
|
222
|
-
/* TODO: add defaults for relevant props. */
|
223
|
-
size: 'md'
|
224
392
|
};
|
@@ -23,7 +23,13 @@ import { pkg
|
|
23
23
|
|
24
24
|
var blockClass = "".concat(pkg.prefix, "--loading-bar");
|
25
25
|
var componentName = 'LoadingBar'; // NOTE: the component SCSS is not imported here: it is rolled up separately.
|
26
|
+
// Default values for props
|
26
27
|
|
28
|
+
var defaults = {
|
29
|
+
active: true,
|
30
|
+
percentage: undefined,
|
31
|
+
ariaLabel: 'Active loading indicator'
|
32
|
+
};
|
27
33
|
/**
|
28
34
|
* The LoadingBar component provides a way to communicate the loading state to users.
|
29
35
|
* It is intended to fill the space of where it's used, and should persist until the
|
@@ -40,11 +46,14 @@ var componentName = 'LoadingBar'; // NOTE: the component SCSS is not imported he
|
|
40
46
|
export var LoadingBar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
41
47
|
var _cx2, _cx3;
|
42
48
|
|
43
|
-
var active = _ref.active,
|
44
|
-
|
49
|
+
var _ref$active = _ref.active,
|
50
|
+
active = _ref$active === void 0 ? defaults.active : _ref$active,
|
51
|
+
_ref$ariaLabel = _ref.ariaLabel,
|
52
|
+
ariaLabel = _ref$ariaLabel === void 0 ? defaults.ariaLabel : _ref$ariaLabel,
|
45
53
|
className = _ref.className,
|
46
54
|
id = _ref.id,
|
47
|
-
percentage = _ref.percentage,
|
55
|
+
_ref$percentage = _ref.percentage,
|
56
|
+
percentage = _ref$percentage === void 0 ? defaults.percentage : _ref$percentage,
|
48
57
|
percentageIndicatorText = _ref.percentageIndicatorText,
|
49
58
|
showPercentageIndicator = _ref.showPercentageIndicator,
|
50
59
|
small = _ref.small,
|
@@ -108,7 +117,7 @@ LoadingBar.propTypes = {
|
|
108
117
|
/**
|
109
118
|
* Specify whether you want the loading bar indicator to be active or not
|
110
119
|
*/
|
111
|
-
active: PropTypes.bool
|
120
|
+
active: PropTypes.bool,
|
112
121
|
|
113
122
|
/**
|
114
123
|
* Specify a ariaLabel that would be used to best describe the active loading state
|
@@ -144,17 +153,4 @@ LoadingBar.propTypes = {
|
|
144
153
|
* Specify whether you would like the small variant of this component
|
145
154
|
*/
|
146
155
|
small: PropTypes.bool
|
147
|
-
}; // Default values for component props. Default values are not required for
|
148
|
-
// props that are required, nor for props where the component can apply
|
149
|
-
// 'undefined' values reasonably. Default values should be provided when the
|
150
|
-
// component needs to make a choice or assumption when a prop is not supplied.
|
151
|
-
|
152
|
-
LoadingBar.defaultProps = {
|
153
|
-
/* add defaults for relevant props. */
|
154
|
-
active: true,
|
155
|
-
small: false,
|
156
|
-
percentage: undefined,
|
157
|
-
showPercentageIndicator: false,
|
158
|
-
percentageIndicatorText: undefined,
|
159
|
-
ariaLabel: 'Active loading indicator'
|
160
156
|
};
|
@@ -46,9 +46,4 @@ ModifiedTabLabelWithClose.propTypes = {
|
|
46
46
|
* unsavedContent indicates tab contents have not been saved
|
47
47
|
*/
|
48
48
|
unsavedContent: PropTypes.bool
|
49
|
-
};
|
50
|
-
ModifiedTabLabelWithClose.defaultProps = {
|
51
|
-
unsavedContent: false,
|
52
|
-
label: '',
|
53
|
-
onClose: undefined
|
54
49
|
};
|
@@ -10,13 +10,31 @@ import { Tabs, Tab } from 'carbon-components-react';
|
|
10
10
|
import { ModifiedTabLabelWithClose } from './ModifiedTabLabelWithClose';
|
11
11
|
import { ModifiedTabLabelNew } from './ModifiedTabLabelNew';
|
12
12
|
import { pkg } from '../../settings';
|
13
|
-
var componentName = 'ModifiedTabs';
|
13
|
+
var componentName = 'ModifiedTabs'; // Default values for props
|
14
|
+
|
15
|
+
var defaults = {
|
16
|
+
tabs: [{
|
17
|
+
id: 'tab-1',
|
18
|
+
label: 'Tab 1',
|
19
|
+
content: /*#__PURE__*/React.createElement("div", null, "Iam am the content of tab 1."),
|
20
|
+
unsavedContent: false
|
21
|
+
}],
|
22
|
+
newTabLabel: 'New tab',
|
23
|
+
newTabContent: 'Your new tab will be here soon',
|
24
|
+
onNewTab: undefined,
|
25
|
+
onCloseTab: undefined
|
26
|
+
};
|
14
27
|
export var ModifiedTabs = function ModifiedTabs(_ref) {
|
15
|
-
var tabs = _ref.tabs,
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
28
|
+
var _ref$tabs = _ref.tabs,
|
29
|
+
tabs = _ref$tabs === void 0 ? defaults.tabs : _ref$tabs,
|
30
|
+
_ref$newTabLabel = _ref.newTabLabel,
|
31
|
+
newTabLabel = _ref$newTabLabel === void 0 ? defaults.newTabLabel : _ref$newTabLabel,
|
32
|
+
_ref$newTabContent = _ref.newTabContent,
|
33
|
+
newTabContent = _ref$newTabContent === void 0 ? defaults.newTabContent : _ref$newTabContent,
|
34
|
+
_ref$onNewTab = _ref.onNewTab,
|
35
|
+
onNewTab = _ref$onNewTab === void 0 ? defaults.onNewTab : _ref$onNewTab,
|
36
|
+
_ref$onCloseTab = _ref.onCloseTab,
|
37
|
+
onCloseTab = _ref$onCloseTab === void 0 ? defaults.onCloseTab : _ref$onCloseTab;
|
20
38
|
|
21
39
|
var handleNewTab = function handleNewTab() {
|
22
40
|
if (onNewTab) {
|
@@ -98,16 +116,4 @@ ModifiedTabs.propTypes = {
|
|
98
116
|
*/
|
99
117
|
tabs: PropTypes.array
|
100
118
|
};
|
101
|
-
ModifiedTabs.defaultProps = {
|
102
|
-
tabs: [{
|
103
|
-
id: 'tab-1',
|
104
|
-
label: 'Tab 1',
|
105
|
-
content: /*#__PURE__*/React.createElement("div", null, "Iam am the content of tab 1."),
|
106
|
-
unsavedContent: false
|
107
|
-
}],
|
108
|
-
newTabLabel: 'New tab',
|
109
|
-
newTabContent: 'Your new tab will be here soon',
|
110
|
-
onNewTab: undefined,
|
111
|
-
onCloseTab: undefined
|
112
|
-
};
|
113
119
|
ModifiedTabs.displayName = componentName;
|