@atlaskit/inline-edit 13.0.9 → 13.2.0
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 +1041 -717
- package/dist/cjs/inline-edit.js +11 -7
- package/dist/cjs/internal/buttons.js +6 -3
- package/dist/cjs/internal/read-view.js +23 -13
- package/dist/es2019/inline-edit.js +11 -7
- package/dist/es2019/internal/buttons.js +6 -3
- package/dist/es2019/internal/read-view.js +23 -14
- package/dist/esm/inline-edit.js +11 -7
- package/dist/esm/internal/buttons.js +6 -3
- package/dist/esm/internal/read-view.js +23 -14
- package/dist/types/inline-edit.d.ts +1 -1
- package/dist/types/internal/buttons.d.ts +2 -1
- package/dist/types/internal/read-view.d.ts +2 -1
- package/dist/types/types.d.ts +4 -0
- package/dist/types-ts4.5/inline-edit.d.ts +1 -1
- package/dist/types-ts4.5/internal/buttons.d.ts +2 -1
- package/dist/types-ts4.5/internal/read-view.d.ts +2 -1
- package/dist/types-ts4.5/types.d.ts +4 -0
- package/package.json +16 -14
package/dist/cjs/inline-edit.js
CHANGED
|
@@ -13,6 +13,8 @@ var _react2 = require("@emotion/react");
|
|
|
13
13
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
14
14
|
var _Field = _interopRequireDefault(require("@atlaskit/form/Field"));
|
|
15
15
|
var _Form = _interopRequireDefault(require("@atlaskit/form/Form"));
|
|
16
|
+
var _pressable = _interopRequireDefault(require("@atlaskit/primitives/pressable"));
|
|
17
|
+
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
16
18
|
var _buttons = _interopRequireDefault(require("./internal/buttons"));
|
|
17
19
|
var _useButtonFocusHook2 = _interopRequireDefault(require("./internal/hooks/use-button-focus-hook"));
|
|
18
20
|
var _readView = _interopRequireDefault(require("./internal/read-view"));
|
|
@@ -27,7 +29,7 @@ var fieldStyles = (0, _react2.css)({
|
|
|
27
29
|
var analyticsAttributes = {
|
|
28
30
|
componentName: 'inlineEdit',
|
|
29
31
|
packageName: "@atlaskit/inline-edit",
|
|
30
|
-
packageVersion: "13.0
|
|
32
|
+
packageVersion: "13.2.0"
|
|
31
33
|
};
|
|
32
34
|
var noop = function noop() {};
|
|
33
35
|
var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
@@ -58,7 +60,8 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
58
60
|
_props$onCancel = props.onCancel,
|
|
59
61
|
providedOnCancel = _props$onCancel === void 0 ? noop : _props$onCancel,
|
|
60
62
|
_props$onEdit = props.onEdit,
|
|
61
|
-
providedOnEdit = _props$onEdit === void 0 ? noop : _props$onEdit
|
|
63
|
+
providedOnEdit = _props$onEdit === void 0 ? noop : _props$onEdit,
|
|
64
|
+
testId = props.testId;
|
|
62
65
|
var wasFocusReceivedSinceLastBlurRef = (0, _react.useRef)(false);
|
|
63
66
|
var isControlled = typeof isEditing === 'undefined';
|
|
64
67
|
var _useState = (0, _react.useState)(startWithEditViewOpen),
|
|
@@ -149,7 +152,8 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
149
152
|
postReadViewClick: doNotFocusOnEditButton,
|
|
150
153
|
editButtonRef: editButtonRef,
|
|
151
154
|
readViewFitContainerWidth: readViewFitContainerWidth,
|
|
152
|
-
readView: readView
|
|
155
|
+
readView: readView,
|
|
156
|
+
testId: testId
|
|
153
157
|
});
|
|
154
158
|
};
|
|
155
159
|
return (0, _react2.jsx)(_Form.default, {
|
|
@@ -198,6 +202,7 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
198
202
|
}, editView(_objectSpread(_objectSpread({}, fieldProps), {}, {
|
|
199
203
|
errorMessage: error
|
|
200
204
|
}), editViewRef), !hideActionButtons ? (0, _react2.jsx)(_buttons.default, {
|
|
205
|
+
testId: testId,
|
|
201
206
|
cancelButtonLabel: cancelButtonLabel,
|
|
202
207
|
confirmButtonLabel: confirmButtonLabel,
|
|
203
208
|
onMouseDown: function onMouseDown() {
|
|
@@ -209,11 +214,10 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
209
214
|
_onCancelClick(e);
|
|
210
215
|
}
|
|
211
216
|
}) : /** This is to allow Ctrl + Enter to submit without action buttons */
|
|
212
|
-
(0, _react2.jsx)(
|
|
217
|
+
(0, _react2.jsx)(_pressable.default, {
|
|
213
218
|
hidden: true,
|
|
214
|
-
type: "submit"
|
|
215
|
-
|
|
216
|
-
}));
|
|
219
|
+
type: "submit"
|
|
220
|
+
}, (0, _react2.jsx)(_visuallyHidden.default, null, "Submit")));
|
|
217
221
|
}) : /** Field is used here only for the label and spacing */
|
|
218
222
|
(0, _react2.jsx)(_Field.default, {
|
|
219
223
|
name: "inlineEdit",
|
|
@@ -53,7 +53,8 @@ var Buttons = function Buttons(_ref) {
|
|
|
53
53
|
var confirmButtonLabel = _ref.confirmButtonLabel,
|
|
54
54
|
cancelButtonLabel = _ref.cancelButtonLabel,
|
|
55
55
|
onMouseDown = _ref.onMouseDown,
|
|
56
|
-
onCancelClick = _ref.onCancelClick
|
|
56
|
+
onCancelClick = _ref.onCancelClick,
|
|
57
|
+
testId = _ref.testId;
|
|
57
58
|
return (0, _react.jsx)("div", {
|
|
58
59
|
css: buttonsContainerStyles
|
|
59
60
|
}, (0, _react.jsx)("div", {
|
|
@@ -63,7 +64,8 @@ var Buttons = function Buttons(_ref) {
|
|
|
63
64
|
icon: _check.default,
|
|
64
65
|
UNSAFE_size: "small",
|
|
65
66
|
onMouseDown: onMouseDown,
|
|
66
|
-
label: confirmButtonLabel
|
|
67
|
+
label: confirmButtonLabel,
|
|
68
|
+
testId: testId && "".concat(testId, "--confirm")
|
|
67
69
|
})), (0, _react.jsx)("div", {
|
|
68
70
|
css: buttonWrapperBaseStyles
|
|
69
71
|
}, (0, _react.jsx)(_new.IconButton, {
|
|
@@ -71,7 +73,8 @@ var Buttons = function Buttons(_ref) {
|
|
|
71
73
|
UNSAFE_size: "small",
|
|
72
74
|
label: cancelButtonLabel,
|
|
73
75
|
onClick: onCancelClick,
|
|
74
|
-
onMouseDown: onMouseDown
|
|
76
|
+
onMouseDown: onMouseDown,
|
|
77
|
+
testId: testId && "".concat(testId, "--cancel")
|
|
75
78
|
})));
|
|
76
79
|
};
|
|
77
80
|
var _default = exports.default = Buttons;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
@@ -7,7 +8,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
8
|
exports.default = void 0;
|
|
8
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
10
|
var _react2 = require("@emotion/react");
|
|
11
|
+
var _primitives = require("@atlaskit/primitives");
|
|
10
12
|
var _colors = require("@atlaskit/theme/colors");
|
|
13
|
+
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
11
14
|
var _constants = require("./constants");
|
|
12
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -16,17 +19,24 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
16
19
|
var readViewContainerStyles = (0, _react2.css)({
|
|
17
20
|
lineHeight: 1
|
|
18
21
|
});
|
|
19
|
-
var editButtonStyles = (0,
|
|
22
|
+
var editButtonStyles = (0, _primitives.xcss)({
|
|
20
23
|
display: 'block',
|
|
21
|
-
margin:
|
|
22
|
-
padding:
|
|
24
|
+
margin: 'space.0',
|
|
25
|
+
padding: 'space.0',
|
|
23
26
|
appearance: 'none',
|
|
24
27
|
background: 'transparent',
|
|
25
28
|
border: 0,
|
|
26
29
|
lineHeight: 1,
|
|
27
|
-
outline:
|
|
28
|
-
'
|
|
29
|
-
|
|
30
|
+
outline: 0,
|
|
31
|
+
':focus-visible': {
|
|
32
|
+
outline: 0
|
|
33
|
+
},
|
|
34
|
+
// @ts-expect-error
|
|
35
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
36
|
+
':focus + div': {
|
|
37
|
+
borderColor: 'color.border.focused',
|
|
38
|
+
borderWidth: 'border.width.outline',
|
|
39
|
+
borderStyle: 'solid'
|
|
30
40
|
}
|
|
31
41
|
});
|
|
32
42
|
var readViewWrapperStyles = (0, _react2.css)({
|
|
@@ -51,7 +61,8 @@ var ReadView = function ReadView(_ref) {
|
|
|
51
61
|
postReadViewClick = _ref.postReadViewClick,
|
|
52
62
|
editButtonRef = _ref.editButtonRef,
|
|
53
63
|
readViewFitContainerWidth = _ref.readViewFitContainerWidth,
|
|
54
|
-
readView = _ref.readView
|
|
64
|
+
readView = _ref.readView,
|
|
65
|
+
testId = _ref.testId;
|
|
55
66
|
var startX = (0, _react.useRef)(0);
|
|
56
67
|
var startY = (0, _react.useRef)(0);
|
|
57
68
|
var mouseHasMovedAfterMouseDown = function mouseHasMovedAfterMouseDown(event) {
|
|
@@ -68,13 +79,12 @@ var ReadView = function ReadView(_ref) {
|
|
|
68
79
|
};
|
|
69
80
|
return (0, _react2.jsx)("div", {
|
|
70
81
|
css: readViewContainerStyles
|
|
71
|
-
}, (0, _react2.jsx)(
|
|
72
|
-
|
|
73
|
-
"aria-label": editButtonLabel,
|
|
74
|
-
type: "button",
|
|
82
|
+
}, (0, _react2.jsx)(_primitives.Pressable, {
|
|
83
|
+
xcss: editButtonStyles,
|
|
75
84
|
onClick: onEditRequested,
|
|
76
|
-
ref: editButtonRef
|
|
77
|
-
|
|
85
|
+
ref: editButtonRef,
|
|
86
|
+
testId: testId && "".concat(testId, "--edit-button")
|
|
87
|
+
}, (0, _react2.jsx)(_visuallyHidden.default, null, editButtonLabel)), (0, _react2.jsx)("div", {
|
|
78
88
|
css: [readViewWrapperStyles, readViewFitContainerWidth && readViewFitContainerWidthStyles]
|
|
79
89
|
/**
|
|
80
90
|
* It is not normally acceptable to add click handlers to non-interactive elements
|
|
@@ -4,6 +4,8 @@ import { css, jsx } from '@emotion/react';
|
|
|
4
4
|
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
5
5
|
import Field from '@atlaskit/form/Field';
|
|
6
6
|
import Form from '@atlaskit/form/Form';
|
|
7
|
+
import Pressable from '@atlaskit/primitives/pressable';
|
|
8
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
7
9
|
import Buttons from './internal/buttons';
|
|
8
10
|
import useButtonFocusHook from './internal/hooks/use-button-focus-hook';
|
|
9
11
|
import ReadView from './internal/read-view';
|
|
@@ -14,7 +16,7 @@ const fieldStyles = css({
|
|
|
14
16
|
const analyticsAttributes = {
|
|
15
17
|
componentName: 'inlineEdit',
|
|
16
18
|
packageName: "@atlaskit/inline-edit",
|
|
17
|
-
packageVersion: "13.0
|
|
19
|
+
packageVersion: "13.2.0"
|
|
18
20
|
};
|
|
19
21
|
const noop = () => {};
|
|
20
22
|
const InnerInlineEdit = props => {
|
|
@@ -36,7 +38,8 @@ const InnerInlineEdit = props => {
|
|
|
36
38
|
analyticsContext,
|
|
37
39
|
onConfirm: providedOnConfirm,
|
|
38
40
|
onCancel: providedOnCancel = noop,
|
|
39
|
-
onEdit: providedOnEdit = noop
|
|
41
|
+
onEdit: providedOnEdit = noop,
|
|
42
|
+
testId
|
|
40
43
|
} = props;
|
|
41
44
|
const wasFocusReceivedSinceLastBlurRef = useRef(false);
|
|
42
45
|
const isControlled = typeof isEditing === 'undefined';
|
|
@@ -125,7 +128,8 @@ const InnerInlineEdit = props => {
|
|
|
125
128
|
postReadViewClick: doNotFocusOnEditButton,
|
|
126
129
|
editButtonRef: editButtonRef,
|
|
127
130
|
readViewFitContainerWidth: readViewFitContainerWidth,
|
|
128
|
-
readView: readView
|
|
131
|
+
readView: readView,
|
|
132
|
+
testId: testId
|
|
129
133
|
});
|
|
130
134
|
};
|
|
131
135
|
return jsx(Form, {
|
|
@@ -174,6 +178,7 @@ const InnerInlineEdit = props => {
|
|
|
174
178
|
...fieldProps,
|
|
175
179
|
errorMessage: error
|
|
176
180
|
}, editViewRef), !hideActionButtons ? jsx(Buttons, {
|
|
181
|
+
testId: testId,
|
|
177
182
|
cancelButtonLabel: cancelButtonLabel,
|
|
178
183
|
confirmButtonLabel: confirmButtonLabel,
|
|
179
184
|
onMouseDown: () => {
|
|
@@ -185,11 +190,10 @@ const InnerInlineEdit = props => {
|
|
|
185
190
|
onCancelClick(e);
|
|
186
191
|
}
|
|
187
192
|
}) : /** This is to allow Ctrl + Enter to submit without action buttons */
|
|
188
|
-
jsx(
|
|
193
|
+
jsx(Pressable, {
|
|
189
194
|
hidden: true,
|
|
190
|
-
type: "submit"
|
|
191
|
-
|
|
192
|
-
}))) : /** Field is used here only for the label and spacing */
|
|
195
|
+
type: "submit"
|
|
196
|
+
}, jsx(VisuallyHidden, null, "Submit")))) : /** Field is used here only for the label and spacing */
|
|
193
197
|
jsx(Field, {
|
|
194
198
|
name: "inlineEdit",
|
|
195
199
|
label: label,
|
|
@@ -46,7 +46,8 @@ const Buttons = ({
|
|
|
46
46
|
confirmButtonLabel,
|
|
47
47
|
cancelButtonLabel,
|
|
48
48
|
onMouseDown,
|
|
49
|
-
onCancelClick
|
|
49
|
+
onCancelClick,
|
|
50
|
+
testId
|
|
50
51
|
}) => {
|
|
51
52
|
return jsx("div", {
|
|
52
53
|
css: buttonsContainerStyles
|
|
@@ -57,7 +58,8 @@ const Buttons = ({
|
|
|
57
58
|
icon: ConfirmIcon,
|
|
58
59
|
UNSAFE_size: "small",
|
|
59
60
|
onMouseDown: onMouseDown,
|
|
60
|
-
label: confirmButtonLabel
|
|
61
|
+
label: confirmButtonLabel,
|
|
62
|
+
testId: testId && `${testId}--confirm`
|
|
61
63
|
})), jsx("div", {
|
|
62
64
|
css: buttonWrapperBaseStyles
|
|
63
65
|
}, jsx(IconButton, {
|
|
@@ -65,7 +67,8 @@ const Buttons = ({
|
|
|
65
67
|
UNSAFE_size: "small",
|
|
66
68
|
label: cancelButtonLabel,
|
|
67
69
|
onClick: onCancelClick,
|
|
68
|
-
onMouseDown: onMouseDown
|
|
70
|
+
onMouseDown: onMouseDown,
|
|
71
|
+
testId: testId && `${testId}--cancel`
|
|
69
72
|
})));
|
|
70
73
|
};
|
|
71
74
|
export default Buttons;
|
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React, { useRef } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
|
-
import {
|
|
4
|
+
import { Pressable, xcss } from '@atlaskit/primitives';
|
|
5
|
+
import { N30 } from '@atlaskit/theme/colors';
|
|
6
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
5
7
|
import { borderRadius } from './constants';
|
|
6
8
|
const readViewContainerStyles = css({
|
|
7
9
|
lineHeight: 1
|
|
8
10
|
});
|
|
9
|
-
const editButtonStyles =
|
|
11
|
+
const editButtonStyles = xcss({
|
|
10
12
|
display: 'block',
|
|
11
|
-
margin:
|
|
12
|
-
padding:
|
|
13
|
+
margin: 'space.0',
|
|
14
|
+
padding: 'space.0',
|
|
13
15
|
appearance: 'none',
|
|
14
16
|
background: 'transparent',
|
|
15
17
|
border: 0,
|
|
16
18
|
lineHeight: 1,
|
|
17
|
-
outline:
|
|
18
|
-
'
|
|
19
|
-
|
|
19
|
+
outline: 0,
|
|
20
|
+
':focus-visible': {
|
|
21
|
+
outline: 0
|
|
22
|
+
},
|
|
23
|
+
// @ts-expect-error
|
|
24
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
25
|
+
':focus + div': {
|
|
26
|
+
borderColor: 'color.border.focused',
|
|
27
|
+
borderWidth: 'border.width.outline',
|
|
28
|
+
borderStyle: 'solid'
|
|
20
29
|
}
|
|
21
30
|
});
|
|
22
31
|
const readViewWrapperStyles = css({
|
|
@@ -41,7 +50,8 @@ const ReadView = ({
|
|
|
41
50
|
postReadViewClick,
|
|
42
51
|
editButtonRef,
|
|
43
52
|
readViewFitContainerWidth,
|
|
44
|
-
readView
|
|
53
|
+
readView,
|
|
54
|
+
testId
|
|
45
55
|
}) => {
|
|
46
56
|
const startX = useRef(0);
|
|
47
57
|
const startY = useRef(0);
|
|
@@ -59,13 +69,12 @@ const ReadView = ({
|
|
|
59
69
|
};
|
|
60
70
|
return jsx("div", {
|
|
61
71
|
css: readViewContainerStyles
|
|
62
|
-
}, jsx(
|
|
63
|
-
|
|
64
|
-
"aria-label": editButtonLabel,
|
|
65
|
-
type: "button",
|
|
72
|
+
}, jsx(Pressable, {
|
|
73
|
+
xcss: editButtonStyles,
|
|
66
74
|
onClick: onEditRequested,
|
|
67
|
-
ref: editButtonRef
|
|
68
|
-
|
|
75
|
+
ref: editButtonRef,
|
|
76
|
+
testId: testId && `${testId}--edit-button`
|
|
77
|
+
}, jsx(VisuallyHidden, null, editButtonLabel)), jsx("div", {
|
|
69
78
|
css: [readViewWrapperStyles, readViewFitContainerWidth && readViewFitContainerWidthStyles]
|
|
70
79
|
/**
|
|
71
80
|
* It is not normally acceptable to add click handlers to non-interactive elements
|
package/dist/esm/inline-edit.js
CHANGED
|
@@ -8,6 +8,8 @@ import { css, jsx } from '@emotion/react';
|
|
|
8
8
|
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
9
9
|
import Field from '@atlaskit/form/Field';
|
|
10
10
|
import Form from '@atlaskit/form/Form';
|
|
11
|
+
import Pressable from '@atlaskit/primitives/pressable';
|
|
12
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
11
13
|
import Buttons from './internal/buttons';
|
|
12
14
|
import useButtonFocusHook from './internal/hooks/use-button-focus-hook';
|
|
13
15
|
import ReadView from './internal/read-view';
|
|
@@ -18,7 +20,7 @@ var fieldStyles = css({
|
|
|
18
20
|
var analyticsAttributes = {
|
|
19
21
|
componentName: 'inlineEdit',
|
|
20
22
|
packageName: "@atlaskit/inline-edit",
|
|
21
|
-
packageVersion: "13.0
|
|
23
|
+
packageVersion: "13.2.0"
|
|
22
24
|
};
|
|
23
25
|
var noop = function noop() {};
|
|
24
26
|
var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
@@ -49,7 +51,8 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
49
51
|
_props$onCancel = props.onCancel,
|
|
50
52
|
providedOnCancel = _props$onCancel === void 0 ? noop : _props$onCancel,
|
|
51
53
|
_props$onEdit = props.onEdit,
|
|
52
|
-
providedOnEdit = _props$onEdit === void 0 ? noop : _props$onEdit
|
|
54
|
+
providedOnEdit = _props$onEdit === void 0 ? noop : _props$onEdit,
|
|
55
|
+
testId = props.testId;
|
|
53
56
|
var wasFocusReceivedSinceLastBlurRef = useRef(false);
|
|
54
57
|
var isControlled = typeof isEditing === 'undefined';
|
|
55
58
|
var _useState = useState(startWithEditViewOpen),
|
|
@@ -140,7 +143,8 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
140
143
|
postReadViewClick: doNotFocusOnEditButton,
|
|
141
144
|
editButtonRef: editButtonRef,
|
|
142
145
|
readViewFitContainerWidth: readViewFitContainerWidth,
|
|
143
|
-
readView: readView
|
|
146
|
+
readView: readView,
|
|
147
|
+
testId: testId
|
|
144
148
|
});
|
|
145
149
|
};
|
|
146
150
|
return jsx(Form, {
|
|
@@ -189,6 +193,7 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
189
193
|
}, editView(_objectSpread(_objectSpread({}, fieldProps), {}, {
|
|
190
194
|
errorMessage: error
|
|
191
195
|
}), editViewRef), !hideActionButtons ? jsx(Buttons, {
|
|
196
|
+
testId: testId,
|
|
192
197
|
cancelButtonLabel: cancelButtonLabel,
|
|
193
198
|
confirmButtonLabel: confirmButtonLabel,
|
|
194
199
|
onMouseDown: function onMouseDown() {
|
|
@@ -200,11 +205,10 @@ var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
|
200
205
|
_onCancelClick(e);
|
|
201
206
|
}
|
|
202
207
|
}) : /** This is to allow Ctrl + Enter to submit without action buttons */
|
|
203
|
-
jsx(
|
|
208
|
+
jsx(Pressable, {
|
|
204
209
|
hidden: true,
|
|
205
|
-
type: "submit"
|
|
206
|
-
|
|
207
|
-
}));
|
|
210
|
+
type: "submit"
|
|
211
|
+
}, jsx(VisuallyHidden, null, "Submit")));
|
|
208
212
|
}) : /** Field is used here only for the label and spacing */
|
|
209
213
|
jsx(Field, {
|
|
210
214
|
name: "inlineEdit",
|
|
@@ -46,7 +46,8 @@ var Buttons = function Buttons(_ref) {
|
|
|
46
46
|
var confirmButtonLabel = _ref.confirmButtonLabel,
|
|
47
47
|
cancelButtonLabel = _ref.cancelButtonLabel,
|
|
48
48
|
onMouseDown = _ref.onMouseDown,
|
|
49
|
-
onCancelClick = _ref.onCancelClick
|
|
49
|
+
onCancelClick = _ref.onCancelClick,
|
|
50
|
+
testId = _ref.testId;
|
|
50
51
|
return jsx("div", {
|
|
51
52
|
css: buttonsContainerStyles
|
|
52
53
|
}, jsx("div", {
|
|
@@ -56,7 +57,8 @@ var Buttons = function Buttons(_ref) {
|
|
|
56
57
|
icon: ConfirmIcon,
|
|
57
58
|
UNSAFE_size: "small",
|
|
58
59
|
onMouseDown: onMouseDown,
|
|
59
|
-
label: confirmButtonLabel
|
|
60
|
+
label: confirmButtonLabel,
|
|
61
|
+
testId: testId && "".concat(testId, "--confirm")
|
|
60
62
|
})), jsx("div", {
|
|
61
63
|
css: buttonWrapperBaseStyles
|
|
62
64
|
}, jsx(IconButton, {
|
|
@@ -64,7 +66,8 @@ var Buttons = function Buttons(_ref) {
|
|
|
64
66
|
UNSAFE_size: "small",
|
|
65
67
|
label: cancelButtonLabel,
|
|
66
68
|
onClick: onCancelClick,
|
|
67
|
-
onMouseDown: onMouseDown
|
|
69
|
+
onMouseDown: onMouseDown,
|
|
70
|
+
testId: testId && "".concat(testId, "--cancel")
|
|
68
71
|
})));
|
|
69
72
|
};
|
|
70
73
|
export default Buttons;
|
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React, { useRef } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
|
-
import {
|
|
4
|
+
import { Pressable, xcss } from '@atlaskit/primitives';
|
|
5
|
+
import { N30 } from '@atlaskit/theme/colors';
|
|
6
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
5
7
|
import { borderRadius } from './constants';
|
|
6
8
|
var readViewContainerStyles = css({
|
|
7
9
|
lineHeight: 1
|
|
8
10
|
});
|
|
9
|
-
var editButtonStyles =
|
|
11
|
+
var editButtonStyles = xcss({
|
|
10
12
|
display: 'block',
|
|
11
|
-
margin:
|
|
12
|
-
padding:
|
|
13
|
+
margin: 'space.0',
|
|
14
|
+
padding: 'space.0',
|
|
13
15
|
appearance: 'none',
|
|
14
16
|
background: 'transparent',
|
|
15
17
|
border: 0,
|
|
16
18
|
lineHeight: 1,
|
|
17
|
-
outline:
|
|
18
|
-
'
|
|
19
|
-
|
|
19
|
+
outline: 0,
|
|
20
|
+
':focus-visible': {
|
|
21
|
+
outline: 0
|
|
22
|
+
},
|
|
23
|
+
// @ts-expect-error
|
|
24
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
25
|
+
':focus + div': {
|
|
26
|
+
borderColor: 'color.border.focused',
|
|
27
|
+
borderWidth: 'border.width.outline',
|
|
28
|
+
borderStyle: 'solid'
|
|
20
29
|
}
|
|
21
30
|
});
|
|
22
31
|
var readViewWrapperStyles = css({
|
|
@@ -41,7 +50,8 @@ var ReadView = function ReadView(_ref) {
|
|
|
41
50
|
postReadViewClick = _ref.postReadViewClick,
|
|
42
51
|
editButtonRef = _ref.editButtonRef,
|
|
43
52
|
readViewFitContainerWidth = _ref.readViewFitContainerWidth,
|
|
44
|
-
readView = _ref.readView
|
|
53
|
+
readView = _ref.readView,
|
|
54
|
+
testId = _ref.testId;
|
|
45
55
|
var startX = useRef(0);
|
|
46
56
|
var startY = useRef(0);
|
|
47
57
|
var mouseHasMovedAfterMouseDown = function mouseHasMovedAfterMouseDown(event) {
|
|
@@ -58,13 +68,12 @@ var ReadView = function ReadView(_ref) {
|
|
|
58
68
|
};
|
|
59
69
|
return jsx("div", {
|
|
60
70
|
css: readViewContainerStyles
|
|
61
|
-
}, jsx(
|
|
62
|
-
|
|
63
|
-
"aria-label": editButtonLabel,
|
|
64
|
-
type: "button",
|
|
71
|
+
}, jsx(Pressable, {
|
|
72
|
+
xcss: editButtonStyles,
|
|
65
73
|
onClick: onEditRequested,
|
|
66
|
-
ref: editButtonRef
|
|
67
|
-
|
|
74
|
+
ref: editButtonRef,
|
|
75
|
+
testId: testId && "".concat(testId, "--edit-button")
|
|
76
|
+
}, jsx(VisuallyHidden, null, editButtonLabel)), jsx("div", {
|
|
68
77
|
css: [readViewWrapperStyles, readViewFitContainerWidth && readViewFitContainerWidthStyles]
|
|
69
78
|
/**
|
|
70
79
|
* It is not normally acceptable to add click handlers to non-interactive elements
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { jsx } from '@emotion/react';
|
|
2
|
-
import { InlineEditProps } from './types';
|
|
2
|
+
import { type InlineEditProps } from './types';
|
|
3
3
|
declare const InlineEdit: <FieldValue extends unknown = string>(props: InlineEditProps<FieldValue>) => jsx.JSX.Element;
|
|
4
4
|
export default InlineEdit;
|
|
@@ -6,6 +6,7 @@ interface ButtonsProp {
|
|
|
6
6
|
cancelButtonLabel: string;
|
|
7
7
|
onMouseDown: () => void;
|
|
8
8
|
onCancelClick: (event: React.MouseEvent<HTMLElement>) => void;
|
|
9
|
+
testId?: string;
|
|
9
10
|
}
|
|
10
|
-
declare const Buttons: ({ confirmButtonLabel, cancelButtonLabel, onMouseDown, onCancelClick, }: ButtonsProp) => jsx.JSX.Element;
|
|
11
|
+
declare const Buttons: ({ confirmButtonLabel, cancelButtonLabel, onMouseDown, onCancelClick, testId, }: ButtonsProp) => jsx.JSX.Element;
|
|
11
12
|
export default Buttons;
|
|
@@ -8,6 +8,7 @@ interface ReadViewProps {
|
|
|
8
8
|
editButtonRef: React.RefObject<HTMLButtonElement>;
|
|
9
9
|
readViewFitContainerWidth?: boolean;
|
|
10
10
|
readView: () => React.ReactNode;
|
|
11
|
+
testId?: string;
|
|
11
12
|
}
|
|
12
|
-
declare const ReadView: ({ editButtonLabel, onEditRequested, postReadViewClick, editButtonRef, readViewFitContainerWidth, readView, }: ReadViewProps) => jsx.JSX.Element;
|
|
13
|
+
declare const ReadView: ({ editButtonLabel, onEditRequested, postReadViewClick, editButtonRef, readViewFitContainerWidth, readView, testId, }: ReadViewProps) => jsx.JSX.Element;
|
|
13
14
|
export default ReadView;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -33,6 +33,10 @@ interface CommonProps {
|
|
|
33
33
|
* starts in `editView`.
|
|
34
34
|
*/
|
|
35
35
|
startWithEditViewOpen?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests
|
|
38
|
+
*/
|
|
39
|
+
testId?: string;
|
|
36
40
|
}
|
|
37
41
|
export interface ExtendedFieldProps<FieldValue> extends FieldProps<FieldValue> {
|
|
38
42
|
errorMessage?: string | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { jsx } from '@emotion/react';
|
|
2
|
-
import { InlineEditProps } from './types';
|
|
2
|
+
import { type InlineEditProps } from './types';
|
|
3
3
|
declare const InlineEdit: <FieldValue extends unknown = string>(props: InlineEditProps<FieldValue>) => jsx.JSX.Element;
|
|
4
4
|
export default InlineEdit;
|
|
@@ -6,6 +6,7 @@ interface ButtonsProp {
|
|
|
6
6
|
cancelButtonLabel: string;
|
|
7
7
|
onMouseDown: () => void;
|
|
8
8
|
onCancelClick: (event: React.MouseEvent<HTMLElement>) => void;
|
|
9
|
+
testId?: string;
|
|
9
10
|
}
|
|
10
|
-
declare const Buttons: ({ confirmButtonLabel, cancelButtonLabel, onMouseDown, onCancelClick, }: ButtonsProp) => jsx.JSX.Element;
|
|
11
|
+
declare const Buttons: ({ confirmButtonLabel, cancelButtonLabel, onMouseDown, onCancelClick, testId, }: ButtonsProp) => jsx.JSX.Element;
|
|
11
12
|
export default Buttons;
|
|
@@ -8,6 +8,7 @@ interface ReadViewProps {
|
|
|
8
8
|
editButtonRef: React.RefObject<HTMLButtonElement>;
|
|
9
9
|
readViewFitContainerWidth?: boolean;
|
|
10
10
|
readView: () => React.ReactNode;
|
|
11
|
+
testId?: string;
|
|
11
12
|
}
|
|
12
|
-
declare const ReadView: ({ editButtonLabel, onEditRequested, postReadViewClick, editButtonRef, readViewFitContainerWidth, readView, }: ReadViewProps) => jsx.JSX.Element;
|
|
13
|
+
declare const ReadView: ({ editButtonLabel, onEditRequested, postReadViewClick, editButtonRef, readViewFitContainerWidth, readView, testId, }: ReadViewProps) => jsx.JSX.Element;
|
|
13
14
|
export default ReadView;
|
|
@@ -33,6 +33,10 @@ interface CommonProps {
|
|
|
33
33
|
* starts in `editView`.
|
|
34
34
|
*/
|
|
35
35
|
startWithEditViewOpen?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests
|
|
38
|
+
*/
|
|
39
|
+
testId?: string;
|
|
36
40
|
}
|
|
37
41
|
export interface ExtendedFieldProps<FieldValue> extends FieldProps<FieldValue> {
|
|
38
42
|
errorMessage?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/inline-edit",
|
|
3
|
-
"version": "13.0
|
|
3
|
+
"version": "13.2.0",
|
|
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/"
|
|
@@ -35,15 +35,17 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@atlaskit/analytics-next": "^9.
|
|
39
|
-
"@atlaskit/button": "^17.
|
|
38
|
+
"@atlaskit/analytics-next": "^9.3.0",
|
|
39
|
+
"@atlaskit/button": "^17.14.0",
|
|
40
40
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
41
|
-
"@atlaskit/form": "^9.0
|
|
41
|
+
"@atlaskit/form": "^9.3.0",
|
|
42
42
|
"@atlaskit/icon": "^22.1.0",
|
|
43
43
|
"@atlaskit/inline-dialog": "^14.0.0",
|
|
44
|
-
"@atlaskit/
|
|
45
|
-
"@atlaskit/
|
|
46
|
-
"@atlaskit/
|
|
44
|
+
"@atlaskit/primitives": "^5.7.0",
|
|
45
|
+
"@atlaskit/textfield": "^6.3.0",
|
|
46
|
+
"@atlaskit/theme": "^12.7.0",
|
|
47
|
+
"@atlaskit/tokens": "^1.45.0",
|
|
48
|
+
"@atlaskit/visually-hidden": "^1.3.0",
|
|
47
49
|
"@babel/runtime": "^7.0.0",
|
|
48
50
|
"@emotion/react": "^11.7.1"
|
|
49
51
|
},
|
|
@@ -53,15 +55,15 @@
|
|
|
53
55
|
"devDependencies": {
|
|
54
56
|
"@af/accessibility-testing": "*",
|
|
55
57
|
"@af/integration-testing": "*",
|
|
56
|
-
"@atlaskit/datetime-picker": "^13.
|
|
58
|
+
"@atlaskit/datetime-picker": "^13.5.0",
|
|
57
59
|
"@atlaskit/docs": "*",
|
|
58
|
-
"@atlaskit/ds-lib": "^2.
|
|
59
|
-
"@atlaskit/section-message": "^6.
|
|
60
|
-
"@atlaskit/select": "^17.
|
|
60
|
+
"@atlaskit/ds-lib": "^2.3.0",
|
|
61
|
+
"@atlaskit/section-message": "^6.5.0",
|
|
62
|
+
"@atlaskit/select": "^17.8.0",
|
|
61
63
|
"@atlaskit/ssr": "*",
|
|
62
|
-
"@atlaskit/tag": "^12.
|
|
63
|
-
"@atlaskit/tag-group": "^10.
|
|
64
|
-
"@atlaskit/textarea": "^5.
|
|
64
|
+
"@atlaskit/tag": "^12.2.0",
|
|
65
|
+
"@atlaskit/tag-group": "^10.3.0",
|
|
66
|
+
"@atlaskit/textarea": "^5.4.0",
|
|
65
67
|
"@atlaskit/visual-regression": "*",
|
|
66
68
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
67
69
|
"@emotion/styled": "^11.0.0",
|