@carbon/ibm-products 2.43.2-canary.138 → 2.43.2-canary.143
Sign up to get free protection for your applications and to get access to all the features.
- package/es/components/EditInPlace/EditInPlace.d.ts +4 -0
- package/es/components/EditInPlace/EditInPlace.js +7 -1
- package/es/components/Tearsheet/TearsheetShell.js +9 -4
- package/es/global/js/hooks/useFocus.js +3 -2
- package/lib/components/EditInPlace/EditInPlace.d.ts +4 -0
- package/lib/components/EditInPlace/EditInPlace.js +7 -1
- package/lib/components/Tearsheet/TearsheetShell.js +9 -4
- package/lib/global/js/hooks/useFocus.js +3 -2
- package/package.json +4 -4
@@ -90,6 +90,10 @@ export interface EditInplaceProps extends PropsWithChildren {
|
|
90
90
|
* current value of the input
|
91
91
|
*/
|
92
92
|
value: string;
|
93
|
+
/**
|
94
|
+
* placeholder for the input
|
95
|
+
*/
|
96
|
+
placeholder?: string;
|
93
97
|
}
|
94
98
|
export declare let EditInPlace: React.ForwardRefExoticComponent<EditInplaceProps & React.RefAttributes<HTMLDivElement>>;
|
95
99
|
export declare const deprecatedProps: {
|
@@ -15,7 +15,7 @@ import cx from 'classnames';
|
|
15
15
|
import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
|
16
16
|
|
17
17
|
var _Close, _Checkmark, _Edit;
|
18
|
-
var _excluded = ["cancelLabel", "editAlwaysVisible", "editLabel", "id", "inheritTypography", "invalid", "invalidLabel", "invalidText", "labelText", "onCancel", "onChange", "onSave", "onBlur", "saveLabel", "size", "tooltipAlignment", "value"];
|
18
|
+
var _excluded = ["cancelLabel", "editAlwaysVisible", "editLabel", "id", "inheritTypography", "invalid", "invalidLabel", "invalidText", "labelText", "onCancel", "onChange", "onSave", "onBlur", "saveLabel", "size", "tooltipAlignment", "value", "placeholder"];
|
19
19
|
var componentName = 'EditInPlace';
|
20
20
|
var blockClass = "".concat(pkg.prefix, "--edit-in-place");
|
21
21
|
var defaults = {
|
@@ -42,6 +42,7 @@ var EditInPlace = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
42
42
|
size = _ref$size === void 0 ? 'sm' : _ref$size,
|
43
43
|
tooltipAlignment = _ref.tooltipAlignment,
|
44
44
|
value = _ref.value,
|
45
|
+
placeholder = _ref.placeholder,
|
45
46
|
rest = _objectWithoutProperties(_ref, _excluded);
|
46
47
|
var _useState = useState(false),
|
47
48
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -156,6 +157,7 @@ var EditInPlace = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
156
157
|
id: id,
|
157
158
|
className: cx("".concat(blockClass, "__text-input"), "".concat(carbon.prefix, "--text-input"), "".concat(carbon.prefix, "--text-input--").concat(size)),
|
158
159
|
type: "text",
|
160
|
+
placeholder: placeholder,
|
159
161
|
value: value,
|
160
162
|
onChange: onChangeHandler,
|
161
163
|
ref: inputRef
|
@@ -274,6 +276,10 @@ EditInPlace.propTypes = _objectSpread2({
|
|
274
276
|
* handler that is called when the save button is pressed or when the user removes focus from the input if it has a new value
|
275
277
|
*/
|
276
278
|
onSave: PropTypes.func.isRequired,
|
279
|
+
/**
|
280
|
+
* Placeholder for text input
|
281
|
+
*/
|
282
|
+
placeholder: PropTypes.string,
|
277
283
|
/**
|
278
284
|
* determines if the input is in readOnly mode
|
279
285
|
*/
|
@@ -139,11 +139,16 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
|
|
139
139
|
|
140
140
|
// Callback to give the tearsheet the opportunity to claim focus
|
141
141
|
handleStackChange.claimFocus = function () {
|
142
|
-
if (selectorPrimaryFocus) {
|
143
|
-
var
|
144
|
-
|
142
|
+
if (selectorPrimaryFocus && getSpecificElement(modalRef === null || modalRef === void 0 ? void 0 : modalRef.current, selectorPrimaryFocus)) {
|
143
|
+
var _window;
|
144
|
+
var specifiedEl = getSpecificElement(modalRef === null || modalRef === void 0 ? void 0 : modalRef.current, selectorPrimaryFocus);
|
145
|
+
if (specifiedEl && ((_window = window) === null || _window === void 0 || (_window = _window.getComputedStyle(specifiedEl)) === null || _window === void 0 ? void 0 : _window.display) !== 'none') {
|
146
|
+
return specifiedEl.focus();
|
147
|
+
}
|
145
148
|
}
|
146
|
-
|
149
|
+
setTimeout(function () {
|
150
|
+
return firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus();
|
151
|
+
}, 0);
|
147
152
|
};
|
148
153
|
useEffect(function () {
|
149
154
|
if (open) {
|
@@ -10,7 +10,8 @@ import { pkg } from '../../../settings.js';
|
|
10
10
|
import { useCallback, useEffect } from 'react';
|
11
11
|
|
12
12
|
var getSpecificElement = function getSpecificElement(parentEl, elementId) {
|
13
|
-
|
13
|
+
var element = parentEl === null || parentEl === void 0 ? void 0 : parentEl.querySelector(elementId);
|
14
|
+
return elementId && !(element !== null && element !== void 0 && element.disabled) ? element : null;
|
14
15
|
};
|
15
16
|
var useFocus = function useFocus(modalRef, selectorPrimaryFocus) {
|
16
17
|
var carbonPrefix = usePrefix();
|
@@ -18,7 +19,7 @@ var useFocus = function useFocus(modalRef, selectorPrimaryFocus) {
|
|
18
19
|
// Querying focusable element in the modal
|
19
20
|
// Query to exclude hidden elements in the modal from querySelectorAll() method
|
20
21
|
// feel free to include more if needed :)
|
21
|
-
var notQuery = ":not(.".concat(carbonPrefix, "--visually-hidden,.").concat(tearsheetBaseClass, "__header--no-close-icon,.").concat(carbonPrefix, "--btn--disabled,[aria-hidden=\"true\"],[tabindex=\"-1\"])");
|
22
|
+
var notQuery = ":not(.".concat(carbonPrefix, "--visually-hidden,.").concat(tearsheetBaseClass, "__header--no-close-icon,.").concat(carbonPrefix, "--btn--disabled,[aria-hidden=\"true\"],[tabindex=\"-1\"],[disabled])");
|
22
23
|
// Queries to include element types button, input, select, textarea
|
23
24
|
var queryButton = "button".concat(notQuery);
|
24
25
|
var queryInput = "input".concat(notQuery);
|
@@ -90,6 +90,10 @@ export interface EditInplaceProps extends PropsWithChildren {
|
|
90
90
|
* current value of the input
|
91
91
|
*/
|
92
92
|
value: string;
|
93
|
+
/**
|
94
|
+
* placeholder for the input
|
95
|
+
*/
|
96
|
+
placeholder?: string;
|
93
97
|
}
|
94
98
|
export declare let EditInPlace: React.ForwardRefExoticComponent<EditInplaceProps & React.RefAttributes<HTMLDivElement>>;
|
95
99
|
export declare const deprecatedProps: {
|
@@ -24,7 +24,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
24
24
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
25
25
|
|
26
26
|
var _Close, _Checkmark, _Edit;
|
27
|
-
var _excluded = ["cancelLabel", "editAlwaysVisible", "editLabel", "id", "inheritTypography", "invalid", "invalidLabel", "invalidText", "labelText", "onCancel", "onChange", "onSave", "onBlur", "saveLabel", "size", "tooltipAlignment", "value"];
|
27
|
+
var _excluded = ["cancelLabel", "editAlwaysVisible", "editLabel", "id", "inheritTypography", "invalid", "invalidLabel", "invalidText", "labelText", "onCancel", "onChange", "onSave", "onBlur", "saveLabel", "size", "tooltipAlignment", "value", "placeholder"];
|
28
28
|
var componentName = 'EditInPlace';
|
29
29
|
var blockClass = "".concat(settings.pkg.prefix, "--edit-in-place");
|
30
30
|
var defaults = {
|
@@ -51,6 +51,7 @@ exports.EditInPlace = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
51
51
|
size = _ref$size === void 0 ? 'sm' : _ref$size,
|
52
52
|
tooltipAlignment = _ref.tooltipAlignment,
|
53
53
|
value = _ref.value,
|
54
|
+
placeholder = _ref.placeholder,
|
54
55
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
55
56
|
var _useState = React.useState(false),
|
56
57
|
_useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
|
@@ -165,6 +166,7 @@ exports.EditInPlace = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
165
166
|
id: id,
|
166
167
|
className: cx__default["default"]("".concat(blockClass, "__text-input"), "".concat(settings.carbon.prefix, "--text-input"), "".concat(settings.carbon.prefix, "--text-input--").concat(size)),
|
167
168
|
type: "text",
|
169
|
+
placeholder: placeholder,
|
168
170
|
value: value,
|
169
171
|
onChange: onChangeHandler,
|
170
172
|
ref: inputRef
|
@@ -283,6 +285,10 @@ exports.EditInPlace.propTypes = _rollupPluginBabelHelpers.objectSpread2({
|
|
283
285
|
* handler that is called when the save button is pressed or when the user removes focus from the input if it has a new value
|
284
286
|
*/
|
285
287
|
onSave: index["default"].func.isRequired,
|
288
|
+
/**
|
289
|
+
* Placeholder for text input
|
290
|
+
*/
|
291
|
+
placeholder: index["default"].string,
|
286
292
|
/**
|
287
293
|
* determines if the input is in readOnly mode
|
288
294
|
*/
|
@@ -148,11 +148,16 @@ var TearsheetShell = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
148
148
|
|
149
149
|
// Callback to give the tearsheet the opportunity to claim focus
|
150
150
|
handleStackChange.claimFocus = function () {
|
151
|
-
if (selectorPrimaryFocus) {
|
152
|
-
var
|
153
|
-
|
151
|
+
if (selectorPrimaryFocus && useFocus.getSpecificElement(modalRef === null || modalRef === void 0 ? void 0 : modalRef.current, selectorPrimaryFocus)) {
|
152
|
+
var _window;
|
153
|
+
var specifiedEl = useFocus.getSpecificElement(modalRef === null || modalRef === void 0 ? void 0 : modalRef.current, selectorPrimaryFocus);
|
154
|
+
if (specifiedEl && ((_window = window) === null || _window === void 0 || (_window = _window.getComputedStyle(specifiedEl)) === null || _window === void 0 ? void 0 : _window.display) !== 'none') {
|
155
|
+
return specifiedEl.focus();
|
156
|
+
}
|
154
157
|
}
|
155
|
-
|
158
|
+
setTimeout(function () {
|
159
|
+
return firstElement === null || firstElement === void 0 ? void 0 : firstElement.focus();
|
160
|
+
}, 0);
|
156
161
|
};
|
157
162
|
React.useEffect(function () {
|
158
163
|
if (open) {
|
@@ -14,7 +14,8 @@ var settings = require('../../../settings.js');
|
|
14
14
|
var React = require('react');
|
15
15
|
|
16
16
|
var getSpecificElement = function getSpecificElement(parentEl, elementId) {
|
17
|
-
|
17
|
+
var element = parentEl === null || parentEl === void 0 ? void 0 : parentEl.querySelector(elementId);
|
18
|
+
return elementId && !(element !== null && element !== void 0 && element.disabled) ? element : null;
|
18
19
|
};
|
19
20
|
var useFocus = function useFocus(modalRef, selectorPrimaryFocus) {
|
20
21
|
var carbonPrefix = react.usePrefix();
|
@@ -22,7 +23,7 @@ var useFocus = function useFocus(modalRef, selectorPrimaryFocus) {
|
|
22
23
|
// Querying focusable element in the modal
|
23
24
|
// Query to exclude hidden elements in the modal from querySelectorAll() method
|
24
25
|
// feel free to include more if needed :)
|
25
|
-
var notQuery = ":not(.".concat(carbonPrefix, "--visually-hidden,.").concat(tearsheetBaseClass, "__header--no-close-icon,.").concat(carbonPrefix, "--btn--disabled,[aria-hidden=\"true\"],[tabindex=\"-1\"])");
|
26
|
+
var notQuery = ":not(.".concat(carbonPrefix, "--visually-hidden,.").concat(tearsheetBaseClass, "__header--no-close-icon,.").concat(carbonPrefix, "--btn--disabled,[aria-hidden=\"true\"],[tabindex=\"-1\"],[disabled])");
|
26
27
|
// Queries to include element types button, input, select, textarea
|
27
28
|
var queryButton = "button".concat(notQuery);
|
28
29
|
var queryInput = "input".concat(notQuery);
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@carbon/ibm-products",
|
3
3
|
"description": "Carbon for IBM Products",
|
4
|
-
"version": "2.43.2-canary.
|
4
|
+
"version": "2.43.2-canary.143+1d8640f5d",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -81,7 +81,7 @@
|
|
81
81
|
"fs-extra": "^11.2.0",
|
82
82
|
"glob": "^10.3.10",
|
83
83
|
"jest": "^29.7.0",
|
84
|
-
"jest-config-ibm-cloud-cognitive": "^1.6.0
|
84
|
+
"jest-config-ibm-cloud-cognitive": "^1.6.0",
|
85
85
|
"jest-environment-jsdom": "^29.7.0",
|
86
86
|
"namor": "^1.1.2",
|
87
87
|
"npm-check-updates": "^16.14.12",
|
@@ -96,7 +96,7 @@
|
|
96
96
|
"dependencies": {
|
97
97
|
"@babel/runtime": "^7.23.9",
|
98
98
|
"@carbon/feature-flags": "^0.20.0",
|
99
|
-
"@carbon/ibm-products-styles": "^2.43.0
|
99
|
+
"@carbon/ibm-products-styles": "^2.43.0",
|
100
100
|
"@carbon/telemetry": "^0.1.0",
|
101
101
|
"@dnd-kit/core": "^6.0.8",
|
102
102
|
"@dnd-kit/modifiers": "^7.0.0",
|
@@ -120,5 +120,5 @@
|
|
120
120
|
"react": "^16.8.6 || ^17.0.1 || ^18.2.0",
|
121
121
|
"react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
|
122
122
|
},
|
123
|
-
"gitHead": "
|
123
|
+
"gitHead": "1d8640f5d0481f820424dd565c64b409d4ad2010"
|
124
124
|
}
|