@atlaskit/inline-edit 12.3.4 → 12.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/inline-edit.js +1 -1
- package/dist/cjs/inline-editable-textfield.js +25 -12
- package/dist/cjs/internal/buttons.js +6 -6
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/inline-edit.js +1 -1
- package/dist/es2019/inline-editable-textfield.js +13 -1
- package/dist/es2019/internal/buttons.js +6 -6
- package/dist/es2019/version.json +1 -1
- package/dist/esm/inline-edit.js +1 -1
- package/dist/esm/inline-editable-textfield.js +14 -1
- package/dist/esm/internal/buttons.js +6 -6
- package/dist/esm/version.json +1 -1
- package/dist/types/inline-editable-textfield.d.ts +0 -1
- package/dist/types-ts4.5/inline-editable-textfield.d.ts +0 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/inline-edit
|
|
2
2
|
|
|
3
|
+
## 12.3.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7257459df07`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7257459df07) - Fixed a regression: onCancel in InlinedEditableTextfield now resets the editable input to the defaultValue
|
|
8
|
+
|
|
3
9
|
## 12.3.4
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cjs/inline-edit.js
CHANGED
|
@@ -32,7 +32,7 @@ var buttonStyles = (0, _react2.css)({
|
|
|
32
32
|
var analyticsAttributes = {
|
|
33
33
|
componentName: 'inlineEdit',
|
|
34
34
|
packageName: "@atlaskit/inline-edit",
|
|
35
|
-
packageVersion: "12.3.
|
|
35
|
+
packageVersion: "12.3.5"
|
|
36
36
|
};
|
|
37
37
|
var noop = function noop() {};
|
|
38
38
|
var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
@@ -7,7 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
-
var _react = require("
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _react2 = require("@emotion/react");
|
|
11
12
|
var _error = _interopRequireDefault(require("@atlaskit/icon/glyph/error"));
|
|
12
13
|
var _inlineDialog = _interopRequireDefault(require("@atlaskit/inline-dialog"));
|
|
13
14
|
var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
|
|
@@ -16,11 +17,11 @@ var _inlineEdit = _interopRequireDefault(require("./inline-edit"));
|
|
|
16
17
|
var _constants = require("./internal/constants");
|
|
17
18
|
var _excluded = ["errorMessage", "isInvalid"];
|
|
18
19
|
/** @jsx jsx */
|
|
19
|
-
var errorIconContainerStyles = (0,
|
|
20
|
+
var errorIconContainerStyles = (0, _react2.css)({
|
|
20
21
|
paddingRight: "var(--ds-space-075, 6px)",
|
|
21
22
|
lineHeight: '100%'
|
|
22
23
|
});
|
|
23
|
-
var readViewForTextFieldStyles = (0,
|
|
24
|
+
var readViewForTextFieldStyles = (0, _react2.css)({
|
|
24
25
|
display: 'flex',
|
|
25
26
|
maxWidth: '100%',
|
|
26
27
|
minHeight: "".concat(8 * 2.5 / _constants.fontSize, "em"),
|
|
@@ -29,31 +30,43 @@ var readViewForTextFieldStyles = (0, _react.css)({
|
|
|
29
30
|
lineHeight: 8 * 2.5 / _constants.fontSize,
|
|
30
31
|
wordBreak: 'break-word'
|
|
31
32
|
});
|
|
32
|
-
var compactStyles = (0,
|
|
33
|
+
var compactStyles = (0, _react2.css)({
|
|
33
34
|
padding: "var(--ds-space-050, 4px)".concat(" ", "var(--ds-space-075, 6px)")
|
|
34
35
|
});
|
|
36
|
+
var noop = function noop() {};
|
|
35
37
|
var InlineEditableTextfield = function InlineEditableTextfield(props) {
|
|
36
38
|
var _props$isCompact = props.isCompact,
|
|
37
39
|
isCompact = _props$isCompact === void 0 ? false : _props$isCompact,
|
|
38
40
|
defaultValue = props.defaultValue,
|
|
39
41
|
placeholder = props.placeholder,
|
|
40
|
-
testId = props.testId
|
|
41
|
-
|
|
42
|
+
testId = props.testId,
|
|
43
|
+
_props$onCancel = props.onCancel,
|
|
44
|
+
providedOnCancel = _props$onCancel === void 0 ? noop : _props$onCancel;
|
|
45
|
+
var textFieldRef = (0, _react.useRef)();
|
|
46
|
+
var onCancel = (0, _react.useCallback)(function () {
|
|
47
|
+
if (textFieldRef.current) {
|
|
48
|
+
textFieldRef.current.value = defaultValue || '';
|
|
49
|
+
}
|
|
50
|
+
providedOnCancel();
|
|
51
|
+
}, [defaultValue, providedOnCancel]);
|
|
52
|
+
return (0, _react2.jsx)(_inlineEdit.default, (0, _extends2.default)({}, props, {
|
|
53
|
+
onCancel: onCancel,
|
|
42
54
|
defaultValue: defaultValue,
|
|
43
55
|
editView: function editView(_ref) {
|
|
44
56
|
var errorMessage = _ref.errorMessage,
|
|
45
57
|
isInvalid = _ref.isInvalid,
|
|
46
58
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
47
|
-
return (0,
|
|
59
|
+
return (0, _react2.jsx)(_inlineDialog.default, {
|
|
48
60
|
isOpen: isInvalid,
|
|
49
|
-
content: (0,
|
|
61
|
+
content: (0, _react2.jsx)("div", {
|
|
50
62
|
id: "error-message"
|
|
51
63
|
}, errorMessage),
|
|
52
64
|
placement: "right"
|
|
53
|
-
}, (0,
|
|
54
|
-
|
|
65
|
+
}, (0, _react2.jsx)(_textfield.default, (0, _extends2.default)({}, props, {
|
|
66
|
+
ref: textFieldRef,
|
|
67
|
+
elemAfterInput: isInvalid && (0, _react2.jsx)("div", {
|
|
55
68
|
css: errorIconContainerStyles
|
|
56
|
-
}, (0,
|
|
69
|
+
}, (0, _react2.jsx)(_error.default, {
|
|
57
70
|
label: "error",
|
|
58
71
|
primaryColor: "var(--ds-icon-danger, ".concat(_colors.R400, ")")
|
|
59
72
|
})),
|
|
@@ -63,7 +76,7 @@ var InlineEditableTextfield = function InlineEditableTextfield(props) {
|
|
|
63
76
|
})));
|
|
64
77
|
},
|
|
65
78
|
readView: function readView() {
|
|
66
|
-
return (0,
|
|
79
|
+
return (0, _react2.jsx)("div", {
|
|
67
80
|
css: [readViewForTextFieldStyles, isCompact && compactStyles],
|
|
68
81
|
"data-compact": isCompact,
|
|
69
82
|
"data-testid": testId && "read-view-".concat(testId)
|
|
@@ -26,15 +26,15 @@ var buttonsContainerStyles = (0, _react.css)({
|
|
|
26
26
|
var buttonWrapperElevationDarkStyles = (0, _react.css)({
|
|
27
27
|
boxShadow: "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.DN50A, ", 0 0 1px ").concat(_colors.DN60A), ")"),
|
|
28
28
|
// These buttons are floating, so they need an override to overlay interaction states
|
|
29
|
-
// eslint-disable-next-line @
|
|
29
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
30
30
|
'& > button': {
|
|
31
31
|
backgroundColor: "var(--ds-surface-overlay, ".concat(_colors.DN70, ")")
|
|
32
32
|
},
|
|
33
|
-
// eslint-disable-next-line @
|
|
33
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
34
34
|
'& > button:hover': {
|
|
35
35
|
backgroundColor: "var(--ds-surface-overlay-hovered, ".concat(_colors.DN60, ")")
|
|
36
36
|
},
|
|
37
|
-
// eslint-disable-next-line @
|
|
37
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
38
38
|
'& > button:active': {
|
|
39
39
|
backgroundColor: "var(--ds-surface-overlay-pressed, ".concat(_colors.B75, ")"),
|
|
40
40
|
color: "var(--ds-text, ".concat(_colors.B400, ")")
|
|
@@ -43,15 +43,15 @@ var buttonWrapperElevationDarkStyles = (0, _react.css)({
|
|
|
43
43
|
var buttonWrapperElevationLightStyles = (0, _react.css)({
|
|
44
44
|
boxShadow: "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N50A, ", 0 0 1px ").concat(_colors.N60A), ")"),
|
|
45
45
|
// These buttons are floating, so they need an override to overlay interaction states
|
|
46
|
-
// eslint-disable-next-line @
|
|
46
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
47
47
|
'& > button': {
|
|
48
48
|
backgroundColor: "var(--ds-surface-overlay, ".concat(_colors.N20A, ")")
|
|
49
49
|
},
|
|
50
|
-
// eslint-disable-next-line @
|
|
50
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
51
51
|
'& > button:hover': {
|
|
52
52
|
backgroundColor: "var(--ds-surface-overlay-hovered, ".concat(_colors.N30A, ")")
|
|
53
53
|
},
|
|
54
|
-
// eslint-disable-next-line @
|
|
54
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
55
55
|
'& > button:active': {
|
|
56
56
|
backgroundColor: "var(--ds-surface-overlay-pressed, rgba(179, 212, 255, 0.6))",
|
|
57
57
|
color: "var(--ds-text, ".concat(_colors.B400, ")")
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
+
import { useCallback, useRef } from 'react';
|
|
3
4
|
import { css, jsx } from '@emotion/react';
|
|
4
5
|
import ErrorIcon from '@atlaskit/icon/glyph/error';
|
|
5
6
|
import InlineDialog from '@atlaskit/inline-dialog';
|
|
@@ -23,14 +24,24 @@ const readViewForTextFieldStyles = css({
|
|
|
23
24
|
const compactStyles = css({
|
|
24
25
|
padding: `${"var(--ds-space-050, 4px)"} ${"var(--ds-space-075, 6px)"}`
|
|
25
26
|
});
|
|
27
|
+
const noop = () => {};
|
|
26
28
|
const InlineEditableTextfield = props => {
|
|
27
29
|
const {
|
|
28
30
|
isCompact = false,
|
|
29
31
|
defaultValue,
|
|
30
32
|
placeholder,
|
|
31
|
-
testId
|
|
33
|
+
testId,
|
|
34
|
+
onCancel: providedOnCancel = noop
|
|
32
35
|
} = props;
|
|
36
|
+
const textFieldRef = useRef();
|
|
37
|
+
const onCancel = useCallback(() => {
|
|
38
|
+
if (textFieldRef.current) {
|
|
39
|
+
textFieldRef.current.value = defaultValue || '';
|
|
40
|
+
}
|
|
41
|
+
providedOnCancel();
|
|
42
|
+
}, [defaultValue, providedOnCancel]);
|
|
33
43
|
return jsx(InlineEdit, _extends({}, props, {
|
|
44
|
+
onCancel: onCancel,
|
|
34
45
|
defaultValue: defaultValue,
|
|
35
46
|
editView: ({
|
|
36
47
|
errorMessage,
|
|
@@ -43,6 +54,7 @@ const InlineEditableTextfield = props => {
|
|
|
43
54
|
}, errorMessage),
|
|
44
55
|
placement: "right"
|
|
45
56
|
}, jsx(Textfield, _extends({}, props, {
|
|
57
|
+
ref: textFieldRef,
|
|
46
58
|
elemAfterInput: isInvalid && jsx("div", {
|
|
47
59
|
css: errorIconContainerStyles
|
|
48
60
|
}, jsx(ErrorIcon, {
|
|
@@ -19,15 +19,15 @@ const buttonsContainerStyles = css({
|
|
|
19
19
|
const buttonWrapperElevationDarkStyles = css({
|
|
20
20
|
boxShadow: `var(--ds-shadow-overlay, ${`0 4px 8px -2px ${DN50A}, 0 0 1px ${DN60A}`})`,
|
|
21
21
|
// These buttons are floating, so they need an override to overlay interaction states
|
|
22
|
-
// eslint-disable-next-line @
|
|
22
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
23
23
|
'& > button': {
|
|
24
24
|
backgroundColor: `var(--ds-surface-overlay, ${DN70})`
|
|
25
25
|
},
|
|
26
|
-
// eslint-disable-next-line @
|
|
26
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
27
27
|
'& > button:hover': {
|
|
28
28
|
backgroundColor: `var(--ds-surface-overlay-hovered, ${DN60})`
|
|
29
29
|
},
|
|
30
|
-
// eslint-disable-next-line @
|
|
30
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
31
31
|
'& > button:active': {
|
|
32
32
|
backgroundColor: `var(--ds-surface-overlay-pressed, ${B75})`,
|
|
33
33
|
color: `var(--ds-text, ${B400})`
|
|
@@ -36,15 +36,15 @@ const buttonWrapperElevationDarkStyles = css({
|
|
|
36
36
|
const buttonWrapperElevationLightStyles = css({
|
|
37
37
|
boxShadow: `var(--ds-shadow-overlay, ${`0 4px 8px -2px ${N50A}, 0 0 1px ${N60A}`})`,
|
|
38
38
|
// These buttons are floating, so they need an override to overlay interaction states
|
|
39
|
-
// eslint-disable-next-line @
|
|
39
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
40
40
|
'& > button': {
|
|
41
41
|
backgroundColor: `var(--ds-surface-overlay, ${N20A})`
|
|
42
42
|
},
|
|
43
|
-
// eslint-disable-next-line @
|
|
43
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
44
44
|
'& > button:hover': {
|
|
45
45
|
backgroundColor: `var(--ds-surface-overlay-hovered, ${N30A})`
|
|
46
46
|
},
|
|
47
|
-
// eslint-disable-next-line @
|
|
47
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
48
48
|
'& > button:active': {
|
|
49
49
|
backgroundColor: "var(--ds-surface-overlay-pressed, rgba(179, 212, 255, 0.6))",
|
|
50
50
|
color: `var(--ds-text, ${B400})`
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/inline-edit.js
CHANGED
|
@@ -23,7 +23,7 @@ var buttonStyles = css({
|
|
|
23
23
|
var analyticsAttributes = {
|
|
24
24
|
componentName: 'inlineEdit',
|
|
25
25
|
packageName: "@atlaskit/inline-edit",
|
|
26
|
-
packageVersion: "12.3.
|
|
26
|
+
packageVersion: "12.3.5"
|
|
27
27
|
};
|
|
28
28
|
var noop = function noop() {};
|
|
29
29
|
var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["errorMessage", "isInvalid"];
|
|
4
4
|
/** @jsx jsx */
|
|
5
|
+
import { useCallback, useRef } from 'react';
|
|
5
6
|
import { css, jsx } from '@emotion/react';
|
|
6
7
|
import ErrorIcon from '@atlaskit/icon/glyph/error';
|
|
7
8
|
import InlineDialog from '@atlaskit/inline-dialog';
|
|
@@ -25,13 +26,24 @@ var readViewForTextFieldStyles = css({
|
|
|
25
26
|
var compactStyles = css({
|
|
26
27
|
padding: "var(--ds-space-050, 4px)".concat(" ", "var(--ds-space-075, 6px)")
|
|
27
28
|
});
|
|
29
|
+
var noop = function noop() {};
|
|
28
30
|
var InlineEditableTextfield = function InlineEditableTextfield(props) {
|
|
29
31
|
var _props$isCompact = props.isCompact,
|
|
30
32
|
isCompact = _props$isCompact === void 0 ? false : _props$isCompact,
|
|
31
33
|
defaultValue = props.defaultValue,
|
|
32
34
|
placeholder = props.placeholder,
|
|
33
|
-
testId = props.testId
|
|
35
|
+
testId = props.testId,
|
|
36
|
+
_props$onCancel = props.onCancel,
|
|
37
|
+
providedOnCancel = _props$onCancel === void 0 ? noop : _props$onCancel;
|
|
38
|
+
var textFieldRef = useRef();
|
|
39
|
+
var onCancel = useCallback(function () {
|
|
40
|
+
if (textFieldRef.current) {
|
|
41
|
+
textFieldRef.current.value = defaultValue || '';
|
|
42
|
+
}
|
|
43
|
+
providedOnCancel();
|
|
44
|
+
}, [defaultValue, providedOnCancel]);
|
|
34
45
|
return jsx(InlineEdit, _extends({}, props, {
|
|
46
|
+
onCancel: onCancel,
|
|
35
47
|
defaultValue: defaultValue,
|
|
36
48
|
editView: function editView(_ref) {
|
|
37
49
|
var errorMessage = _ref.errorMessage,
|
|
@@ -44,6 +56,7 @@ var InlineEditableTextfield = function InlineEditableTextfield(props) {
|
|
|
44
56
|
}, errorMessage),
|
|
45
57
|
placement: "right"
|
|
46
58
|
}, jsx(Textfield, _extends({}, props, {
|
|
59
|
+
ref: textFieldRef,
|
|
47
60
|
elemAfterInput: isInvalid && jsx("div", {
|
|
48
61
|
css: errorIconContainerStyles
|
|
49
62
|
}, jsx(ErrorIcon, {
|
|
@@ -19,15 +19,15 @@ var buttonsContainerStyles = css({
|
|
|
19
19
|
var buttonWrapperElevationDarkStyles = css({
|
|
20
20
|
boxShadow: "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(DN50A, ", 0 0 1px ").concat(DN60A), ")"),
|
|
21
21
|
// These buttons are floating, so they need an override to overlay interaction states
|
|
22
|
-
// eslint-disable-next-line @
|
|
22
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
23
23
|
'& > button': {
|
|
24
24
|
backgroundColor: "var(--ds-surface-overlay, ".concat(DN70, ")")
|
|
25
25
|
},
|
|
26
|
-
// eslint-disable-next-line @
|
|
26
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
27
27
|
'& > button:hover': {
|
|
28
28
|
backgroundColor: "var(--ds-surface-overlay-hovered, ".concat(DN60, ")")
|
|
29
29
|
},
|
|
30
|
-
// eslint-disable-next-line @
|
|
30
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
31
31
|
'& > button:active': {
|
|
32
32
|
backgroundColor: "var(--ds-surface-overlay-pressed, ".concat(B75, ")"),
|
|
33
33
|
color: "var(--ds-text, ".concat(B400, ")")
|
|
@@ -36,15 +36,15 @@ var buttonWrapperElevationDarkStyles = css({
|
|
|
36
36
|
var buttonWrapperElevationLightStyles = css({
|
|
37
37
|
boxShadow: "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(N50A, ", 0 0 1px ").concat(N60A), ")"),
|
|
38
38
|
// These buttons are floating, so they need an override to overlay interaction states
|
|
39
|
-
// eslint-disable-next-line @
|
|
39
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
40
40
|
'& > button': {
|
|
41
41
|
backgroundColor: "var(--ds-surface-overlay, ".concat(N20A, ")")
|
|
42
42
|
},
|
|
43
|
-
// eslint-disable-next-line @
|
|
43
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
44
44
|
'& > button:hover': {
|
|
45
45
|
backgroundColor: "var(--ds-surface-overlay-hovered, ".concat(N30A, ")")
|
|
46
46
|
},
|
|
47
|
-
// eslint-disable-next-line @
|
|
47
|
+
// eslint-disable-next-line @atlaskit/design-system/no-nested-styles
|
|
48
48
|
'& > button:active': {
|
|
49
49
|
backgroundColor: "var(--ds-surface-overlay-pressed, rgba(179, 212, 255, 0.6))",
|
|
50
50
|
color: "var(--ds-text, ".concat(B400, ")")
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/inline-edit",
|
|
3
|
-
"version": "12.3.
|
|
3
|
+
"version": "12.3.5",
|
|
4
4
|
"description": "An inline edit displays a custom input component that switches between reading and editing on the same page.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"@atlaskit/form": "^8.11.0",
|
|
39
39
|
"@atlaskit/icon": "^21.12.0",
|
|
40
40
|
"@atlaskit/inline-dialog": "^13.6.0",
|
|
41
|
-
"@atlaskit/textfield": "^5.
|
|
41
|
+
"@atlaskit/textfield": "^5.6.0",
|
|
42
42
|
"@atlaskit/theme": "^12.5.0",
|
|
43
|
-
"@atlaskit/tokens": "^1.
|
|
43
|
+
"@atlaskit/tokens": "^1.13.0",
|
|
44
44
|
"@babel/runtime": "^7.0.0",
|
|
45
45
|
"@emotion/react": "^11.7.1"
|
|
46
46
|
},
|