@atlaskit/inline-edit 14.3.0 → 15.0.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 +26 -0
- package/dist/cjs/inline-edit.js +1 -1
- package/dist/es2019/inline-edit.js +1 -1
- package/dist/esm/inline-edit.js +1 -1
- package/package.json +21 -23
- package/codemods/12.0.0-lite-mode.ts +0 -15
- package/codemods/__tests__/12.0.0-lite-mode.tsx +0 -405
- package/codemods/__tests__/add-comments-when-validate-found.ts +0 -118
- package/codemods/__tests__/lift-InlineEditStateless-to-default.ts +0 -129
- package/codemods/__tests__/lift-InlineEditableTextField-to-its-entry-point.tsx +0 -82
- package/codemods/__tests__/spread-errorMessage-out-of-fieldProps.tsx +0 -493
- package/codemods/migrates/add-comments-when-validate-found.ts +0 -44
- package/codemods/migrates/lift-InlineEditStateless-to-default.ts +0 -58
- package/codemods/migrates/lift-InlineEditableTextField-to-its-entry-point.ts +0 -41
- package/codemods/migrates/spread-errorMessage-out-of-fieldProps.ts +0 -56
- package/codemods/migrates/utils.ts +0 -94
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @atlaskit/inline-edit
|
|
2
2
|
|
|
3
|
+
## 15.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#117363](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/117363)
|
|
8
|
+
[`10a0f7f6c2027`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/10a0f7f6c2027) -
|
|
9
|
+
This package's `peerDependencies` have been adjusted for `react` and/or `react-dom` to reflect the
|
|
10
|
+
status of only supporting React 18 going forward. No explicit breaking change to React support has
|
|
11
|
+
been made in this release, but this is to signify going forward, breaking changes for React 16 or
|
|
12
|
+
React 17 may come via non-major semver releases.
|
|
13
|
+
|
|
14
|
+
Please refer this community post for more details:
|
|
15
|
+
https://community.developer.atlassian.com/t/rfc-78-dropping-support-for-react-16-and-rendering-in-a-react-18-concurrent-root-in-jira-and-confluence/87026
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
21
|
+
## 14.3.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#116462](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/116462)
|
|
26
|
+
[`6f296bda0bac5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6f296bda0bac5) -
|
|
27
|
+
Remove old codemods and update dependencies.
|
|
28
|
+
|
|
3
29
|
## 14.3.0
|
|
4
30
|
|
|
5
31
|
### Minor Changes
|
package/dist/cjs/inline-edit.js
CHANGED
|
@@ -29,7 +29,7 @@ var fieldStyles = null;
|
|
|
29
29
|
var analyticsAttributes = {
|
|
30
30
|
componentName: 'inlineEdit',
|
|
31
31
|
packageName: "@atlaskit/inline-edit",
|
|
32
|
-
packageVersion: "
|
|
32
|
+
packageVersion: "15.0.0"
|
|
33
33
|
};
|
|
34
34
|
var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
35
35
|
var _props$startWithEditV = props.startWithEditViewOpen,
|
package/dist/esm/inline-edit.js
CHANGED
|
@@ -19,7 +19,7 @@ var fieldStyles = null;
|
|
|
19
19
|
var analyticsAttributes = {
|
|
20
20
|
componentName: 'inlineEdit',
|
|
21
21
|
packageName: "@atlaskit/inline-edit",
|
|
22
|
-
packageVersion: "
|
|
22
|
+
packageVersion: "15.0.0"
|
|
23
23
|
};
|
|
24
24
|
var InnerInlineEdit = function InnerInlineEdit(props) {
|
|
25
25
|
var _props$startWithEditV = props.startWithEditViewOpen,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/inline-edit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.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/"
|
|
@@ -34,44 +34,42 @@
|
|
|
34
34
|
"runReact18": true
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@atlaskit/analytics-next": "^
|
|
38
|
-
"@atlaskit/button": "^
|
|
37
|
+
"@atlaskit/analytics-next": "^11.0.0",
|
|
38
|
+
"@atlaskit/button": "^21.0.0",
|
|
39
39
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
40
|
-
"@atlaskit/css": "^0.
|
|
41
|
-
"@atlaskit/form": "^
|
|
42
|
-
"@atlaskit/icon": "^
|
|
43
|
-
"@atlaskit/inline-dialog": "^
|
|
40
|
+
"@atlaskit/css": "^0.10.0",
|
|
41
|
+
"@atlaskit/form": "^12.0.0",
|
|
42
|
+
"@atlaskit/icon": "^24.0.0",
|
|
43
|
+
"@atlaskit/inline-dialog": "^17.0.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
|
-
"@atlaskit/primitives": "^
|
|
46
|
-
"@atlaskit/textfield": "^
|
|
47
|
-
"@atlaskit/theme": "^
|
|
48
|
-
"@atlaskit/tokens": "^
|
|
49
|
-
"@atlaskit/visually-hidden": "^
|
|
45
|
+
"@atlaskit/primitives": "^14.0.0",
|
|
46
|
+
"@atlaskit/textfield": "^8.0.0",
|
|
47
|
+
"@atlaskit/theme": "^17.0.0",
|
|
48
|
+
"@atlaskit/tokens": "^4.0.0",
|
|
49
|
+
"@atlaskit/visually-hidden": "^2.0.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
51
51
|
"@compiled/react": "^0.18.2"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"react": "^
|
|
54
|
+
"react": "^18.2.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@af/accessibility-testing": "*",
|
|
58
58
|
"@af/integration-testing": "*",
|
|
59
|
-
"@atlaskit/datetime-picker": "^
|
|
59
|
+
"@atlaskit/datetime-picker": "^16.0.0",
|
|
60
60
|
"@atlaskit/docs": "*",
|
|
61
|
-
"@atlaskit/ds-lib": "^
|
|
62
|
-
"@atlaskit/heading": "^
|
|
61
|
+
"@atlaskit/ds-lib": "^4.0.0",
|
|
62
|
+
"@atlaskit/heading": "^5.0.0",
|
|
63
63
|
"@atlaskit/link": "*",
|
|
64
|
-
"@atlaskit/section-message": "^
|
|
65
|
-
"@atlaskit/select": "^
|
|
64
|
+
"@atlaskit/section-message": "^8.0.0",
|
|
65
|
+
"@atlaskit/select": "^19.0.0",
|
|
66
66
|
"@atlaskit/ssr": "*",
|
|
67
|
-
"@atlaskit/tag": "^
|
|
68
|
-
"@atlaskit/tag-group": "^
|
|
69
|
-
"@atlaskit/textarea": "^
|
|
67
|
+
"@atlaskit/tag": "^14.0.0",
|
|
68
|
+
"@atlaskit/tag-group": "^12.0.0",
|
|
69
|
+
"@atlaskit/textarea": "^8.0.0",
|
|
70
70
|
"@atlaskit/visual-regression": "*",
|
|
71
71
|
"@atlassian/feature-flags-test-utils": "*",
|
|
72
72
|
"@testing-library/react": "^13.4.0",
|
|
73
|
-
"ast-types": "^0.13.3",
|
|
74
|
-
"jscodeshift": "^0.13.0",
|
|
75
73
|
"react-dom": "^18.2.0",
|
|
76
74
|
"react-select-event": "^5.5.0",
|
|
77
75
|
"typescript": "~5.4.2"
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
-
|
|
3
|
-
import addCommentsWhenValidateFound from './migrates/add-comments-when-validate-found';
|
|
4
|
-
import liftInlineEditableTextField from './migrates/lift-InlineEditableTextField-to-its-entry-point';
|
|
5
|
-
import elevateComponentToDefault from './migrates/lift-InlineEditStateless-to-default';
|
|
6
|
-
import spreadErrorMessage from './migrates/spread-errorMessage-out-of-fieldProps';
|
|
7
|
-
|
|
8
|
-
const transformer = createTransformer([
|
|
9
|
-
addCommentsWhenValidateFound,
|
|
10
|
-
liftInlineEditableTextField,
|
|
11
|
-
elevateComponentToDefault,
|
|
12
|
-
spreadErrorMessage,
|
|
13
|
-
]);
|
|
14
|
-
|
|
15
|
-
export default transformer;
|
|
@@ -1,405 +0,0 @@
|
|
|
1
|
-
import transformer from '../12.0.0-lite-mode';
|
|
2
|
-
|
|
3
|
-
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
4
|
-
|
|
5
|
-
describe('apply all transforms', () => {
|
|
6
|
-
defineInlineTest(
|
|
7
|
-
{ default: transformer, parser: 'tsx' },
|
|
8
|
-
{},
|
|
9
|
-
`
|
|
10
|
-
import React from "react";
|
|
11
|
-
import InlineEdit, {InlineEditableTextfield} from "@atlaskit/inline-edit";
|
|
12
|
-
|
|
13
|
-
export default () => (
|
|
14
|
-
<Container>
|
|
15
|
-
<InlineEdit
|
|
16
|
-
editView={fieldProps => <Textfield {...fieldProps} autoFocus />}
|
|
17
|
-
validate={() => {}}
|
|
18
|
-
/>
|
|
19
|
-
<InlineEditableTextfield />
|
|
20
|
-
</Container>
|
|
21
|
-
);
|
|
22
|
-
`,
|
|
23
|
-
`
|
|
24
|
-
/* TODO: (from codemod) We could not automatically convert this code to the new API.
|
|
25
|
-
|
|
26
|
-
This file uses \`inline-edit\`’s \`validate\` prop which previously would use \`react-loadable\` and the \`inline-dialog\` packages. Version 12.0.0 of \`inline-edit\` now no longer includes these dependencies out of the box and instead allows you to compose your own experience.
|
|
27
|
-
|
|
28
|
-
If you are using an editable textfield you can move over to the \`@atlaskit/inline-edit/inline-editable-textfield\` instead which comes with the previous error message behavior.
|
|
29
|
-
|
|
30
|
-
To migrate you can use the \`isInvalid\` and \`errorMessage\` props passed to \`editView\`, like so:
|
|
31
|
-
|
|
32
|
-
\`\`\`ts
|
|
33
|
-
import InlineDialog from '@atlaskit/inline-dialog';
|
|
34
|
-
import InlineEdit from '@atlaskit/inline-edit';
|
|
35
|
-
|
|
36
|
-
const MyEditView = (
|
|
37
|
-
<InlineEdit
|
|
38
|
-
editView={({ errorMessage, isInvalid, ...props }) => (
|
|
39
|
-
<InlineDialog content={errorMessage} isOpen={isInvalid}>
|
|
40
|
-
<Textfield {...props} />
|
|
41
|
-
</InlineDialog>
|
|
42
|
-
)}
|
|
43
|
-
/>
|
|
44
|
-
);
|
|
45
|
-
\`\`\`
|
|
46
|
-
*/
|
|
47
|
-
import React from "react";
|
|
48
|
-
import InlineEditableTextfield from "@atlaskit/inline-edit/inline-editable-textfield";
|
|
49
|
-
import InlineEdit from "@atlaskit/inline-edit";
|
|
50
|
-
|
|
51
|
-
export default () => (
|
|
52
|
-
<Container>
|
|
53
|
-
<InlineEdit
|
|
54
|
-
editView={(
|
|
55
|
-
{
|
|
56
|
-
errorMessage,
|
|
57
|
-
...fieldProps
|
|
58
|
-
}
|
|
59
|
-
) => <Textfield {...fieldProps} autoFocus />}
|
|
60
|
-
validate={() => {}}
|
|
61
|
-
/>
|
|
62
|
-
<InlineEditableTextfield />
|
|
63
|
-
</Container>
|
|
64
|
-
);
|
|
65
|
-
`,
|
|
66
|
-
'should switch InlineEditableTextfield to a new entrypoint with default import',
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
defineInlineTest(
|
|
70
|
-
{ default: transformer, parser: 'tsx' },
|
|
71
|
-
{},
|
|
72
|
-
`
|
|
73
|
-
import React, { PureComponent } from "react";
|
|
74
|
-
import InlineEdit from "@atlaskit/inline-edit";
|
|
75
|
-
import TextField from "@atlaskit/textfield";
|
|
76
|
-
|
|
77
|
-
export default class ColumnEditableTitle extends PureComponent {
|
|
78
|
-
handleChange = (event) => {
|
|
79
|
-
this.setState({ editValue: event.target.value });
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
handleEditChange = () => {
|
|
83
|
-
this.setState({ isEditing: true });
|
|
84
|
-
if (this.props.onEditChange) {
|
|
85
|
-
this.props.onEditChange(true);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
handleConfirm = () => {
|
|
90
|
-
const newValue = this.state.editValue.trim();
|
|
91
|
-
|
|
92
|
-
if (isBlank(newValue) || hasNotChange(newValue, this.props.text)) {
|
|
93
|
-
this.handleCancel();
|
|
94
|
-
} else {
|
|
95
|
-
this.setState({ isEditing: false });
|
|
96
|
-
this.props.onConfirm(this.props.columnId, newValue);
|
|
97
|
-
if (this.props.onEditChange) {
|
|
98
|
-
this.props.onEditChange(false);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
handleCancel = () => {
|
|
104
|
-
this.setState({
|
|
105
|
-
editValue: this.props.text,
|
|
106
|
-
isEditing: false,
|
|
107
|
-
});
|
|
108
|
-
this.props.onCancel(this.props.columnId);
|
|
109
|
-
if (isNotNewColumn(this.props) && this.props.onEditChange) {
|
|
110
|
-
this.props.onEditChange(false);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
handleKeyDown = (event) => {
|
|
115
|
-
if (isEscape(event)) {
|
|
116
|
-
this.handleCancel();
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
renderReading = () => (
|
|
121
|
-
<Reading>
|
|
122
|
-
<ColumnTitle {...this.props} text={this.state.editValue} />
|
|
123
|
-
</Reading>
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
renderEditing = (fieldProps) => (
|
|
127
|
-
<TextField
|
|
128
|
-
{...fieldProps}
|
|
129
|
-
autoFocus
|
|
130
|
-
value={this.state.editValue}
|
|
131
|
-
onChange={this.handleChange}
|
|
132
|
-
onMouseDown={(event) => event.stopPropagation()}
|
|
133
|
-
onKeyDown={this.handleKeyDown}
|
|
134
|
-
isCompact
|
|
135
|
-
/>
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
render() {
|
|
139
|
-
const { isDisabled } = this.props;
|
|
140
|
-
|
|
141
|
-
// if this component is disabled or in case this component belongs to a
|
|
142
|
-
// new column (id < 0) and is no longer being edited then <ColumnTitle/>
|
|
143
|
-
// should be rendered instead (not in editable mode).
|
|
144
|
-
const shouldRenderColumnTitle =
|
|
145
|
-
isDisabled || (isNewColumn(this.props) && !this.state.isEditing);
|
|
146
|
-
|
|
147
|
-
return shouldRenderColumnTitle ? (
|
|
148
|
-
<ColumnTitle {...this.props} text={this.state.editValue} />
|
|
149
|
-
) : (
|
|
150
|
-
<Container>
|
|
151
|
-
<InlineEdit
|
|
152
|
-
defaultValue={this.state.editValue}
|
|
153
|
-
startWithEditViewOpen
|
|
154
|
-
validate={() => {}}
|
|
155
|
-
editView={this.renderEditing}
|
|
156
|
-
readView={this.renderReading}
|
|
157
|
-
onConfirm={this.handleConfirm}
|
|
158
|
-
// OnCancel will be exposed back once https://product-fabric.atlassian.net/browse/DST-1865 is released
|
|
159
|
-
onCancel={this.handleCancel}
|
|
160
|
-
/>
|
|
161
|
-
</Container>
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
`,
|
|
166
|
-
`
|
|
167
|
-
/* TODO: (from codemod) We could not automatically convert this code to the new API.
|
|
168
|
-
|
|
169
|
-
This file uses \`inline-edit\`’s \`validate\` prop which previously would use \`react-loadable\` and the \`inline-dialog\` packages. Version 12.0.0 of \`inline-edit\` now no longer includes these dependencies out of the box and instead allows you to compose your own experience.
|
|
170
|
-
|
|
171
|
-
If you are using an editable textfield you can move over to the \`@atlaskit/inline-edit/inline-editable-textfield\` instead which comes with the previous error message behavior.
|
|
172
|
-
|
|
173
|
-
To migrate you can use the \`isInvalid\` and \`errorMessage\` props passed to \`editView\`, like so:
|
|
174
|
-
|
|
175
|
-
\`\`\`ts
|
|
176
|
-
import InlineDialog from '@atlaskit/inline-dialog';
|
|
177
|
-
import InlineEdit from '@atlaskit/inline-edit';
|
|
178
|
-
|
|
179
|
-
const MyEditView = (
|
|
180
|
-
<InlineEdit
|
|
181
|
-
editView={({ errorMessage, isInvalid, ...props }) => (
|
|
182
|
-
<InlineDialog content={errorMessage} isOpen={isInvalid}>
|
|
183
|
-
<Textfield {...props} />
|
|
184
|
-
</InlineDialog>
|
|
185
|
-
)}
|
|
186
|
-
/>
|
|
187
|
-
);
|
|
188
|
-
\`\`\`
|
|
189
|
-
*/
|
|
190
|
-
import React, { PureComponent } from "react";
|
|
191
|
-
import InlineEdit from "@atlaskit/inline-edit";
|
|
192
|
-
import TextField from "@atlaskit/textfield";
|
|
193
|
-
|
|
194
|
-
export default class ColumnEditableTitle extends PureComponent {
|
|
195
|
-
handleChange = (event) => {
|
|
196
|
-
this.setState({ editValue: event.target.value });
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
handleEditChange = () => {
|
|
200
|
-
this.setState({ isEditing: true });
|
|
201
|
-
if (this.props.onEditChange) {
|
|
202
|
-
this.props.onEditChange(true);
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
handleConfirm = () => {
|
|
207
|
-
const newValue = this.state.editValue.trim();
|
|
208
|
-
|
|
209
|
-
if (isBlank(newValue) || hasNotChange(newValue, this.props.text)) {
|
|
210
|
-
this.handleCancel();
|
|
211
|
-
} else {
|
|
212
|
-
this.setState({ isEditing: false });
|
|
213
|
-
this.props.onConfirm(this.props.columnId, newValue);
|
|
214
|
-
if (this.props.onEditChange) {
|
|
215
|
-
this.props.onEditChange(false);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
handleCancel = () => {
|
|
221
|
-
this.setState({
|
|
222
|
-
editValue: this.props.text,
|
|
223
|
-
isEditing: false,
|
|
224
|
-
});
|
|
225
|
-
this.props.onCancel(this.props.columnId);
|
|
226
|
-
if (isNotNewColumn(this.props) && this.props.onEditChange) {
|
|
227
|
-
this.props.onEditChange(false);
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
handleKeyDown = (event) => {
|
|
232
|
-
if (isEscape(event)) {
|
|
233
|
-
this.handleCancel();
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
renderReading = () => (
|
|
238
|
-
<Reading>
|
|
239
|
-
<ColumnTitle {...this.props} text={this.state.editValue} />
|
|
240
|
-
</Reading>
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
renderEditing = (fieldProps) => (
|
|
244
|
-
<TextField
|
|
245
|
-
{...fieldProps}
|
|
246
|
-
autoFocus
|
|
247
|
-
value={this.state.editValue}
|
|
248
|
-
onChange={this.handleChange}
|
|
249
|
-
onMouseDown={(event) => event.stopPropagation()}
|
|
250
|
-
onKeyDown={this.handleKeyDown}
|
|
251
|
-
isCompact
|
|
252
|
-
/>
|
|
253
|
-
);
|
|
254
|
-
|
|
255
|
-
render() {
|
|
256
|
-
const { isDisabled } = this.props;
|
|
257
|
-
|
|
258
|
-
// if this component is disabled or in case this component belongs to a
|
|
259
|
-
// new column (id < 0) and is no longer being edited then <ColumnTitle/>
|
|
260
|
-
// should be rendered instead (not in editable mode).
|
|
261
|
-
const shouldRenderColumnTitle =
|
|
262
|
-
isDisabled || (isNewColumn(this.props) && !this.state.isEditing);
|
|
263
|
-
|
|
264
|
-
return shouldRenderColumnTitle ? (
|
|
265
|
-
<ColumnTitle {...this.props} text={this.state.editValue} />
|
|
266
|
-
) : (
|
|
267
|
-
<Container>
|
|
268
|
-
<InlineEdit
|
|
269
|
-
defaultValue={this.state.editValue}
|
|
270
|
-
startWithEditViewOpen
|
|
271
|
-
validate={() => {}}
|
|
272
|
-
editView={this.renderEditing}
|
|
273
|
-
readView={this.renderReading}
|
|
274
|
-
onConfirm={this.handleConfirm}
|
|
275
|
-
// OnCancel will be exposed back once https://product-fabric.atlassian.net/browse/DST-1865 is released
|
|
276
|
-
onCancel={this.handleCancel}
|
|
277
|
-
/>
|
|
278
|
-
</Container>
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
`,
|
|
283
|
-
'ColumnEditableTitle - add comment when editView is not inline and validate is passed',
|
|
284
|
-
);
|
|
285
|
-
|
|
286
|
-
defineInlineTest(
|
|
287
|
-
{ default: transformer, parser: 'tsx' },
|
|
288
|
-
{},
|
|
289
|
-
`
|
|
290
|
-
import React from "react";
|
|
291
|
-
import InlineEdit from "@atlaskit/inline-edit";
|
|
292
|
-
|
|
293
|
-
export default () => (
|
|
294
|
-
<InlineEditOffsetContainer>
|
|
295
|
-
<InlineEdit
|
|
296
|
-
{...inlineEditProps}
|
|
297
|
-
label={label}
|
|
298
|
-
editButtonLabel={intl.formatMessage(
|
|
299
|
-
inlineEditableMessages.editButtonLabel,
|
|
300
|
-
i18nValues,
|
|
301
|
-
)}
|
|
302
|
-
confirmButtonLabel={intl.formatMessage(
|
|
303
|
-
inlineEditableMessages.confirmButtonLabel,
|
|
304
|
-
i18nValues,
|
|
305
|
-
)}
|
|
306
|
-
cancelButtonLabel={intl.formatMessage(
|
|
307
|
-
inlineEditableMessages.cancelButtonLabel,
|
|
308
|
-
i18nValues,
|
|
309
|
-
)}
|
|
310
|
-
isLabelHidden
|
|
311
|
-
isFitContainerWidthReadView
|
|
312
|
-
shouldConfirmOnEnter
|
|
313
|
-
isWaiting={isWaiting}
|
|
314
|
-
isInvalid={isInvalid}
|
|
315
|
-
invalidMessage={invalidMessage}
|
|
316
|
-
editView={
|
|
317
|
-
// We forward props from Title to SingleLineTextInput
|
|
318
|
-
// so the props InlineEdit injets are passed through.
|
|
319
|
-
<TitleThatForwardsProps>
|
|
320
|
-
<SingleLineTextInput
|
|
321
|
-
isEditing
|
|
322
|
-
isInitiallySelected
|
|
323
|
-
style={inheritStyles}
|
|
324
|
-
onChange={(e) =>
|
|
325
|
-
inlineEditProps.onChange(e.target.value)
|
|
326
|
-
}
|
|
327
|
-
value={inlineEditProps.value}
|
|
328
|
-
/>
|
|
329
|
-
</TitleThatForwardsProps>
|
|
330
|
-
}
|
|
331
|
-
readView={
|
|
332
|
-
// We forward props from Title to SingleLineTextInput
|
|
333
|
-
// so the props InlineEdit injets are passed through.
|
|
334
|
-
<TitleThatForwardsProps>
|
|
335
|
-
<SingleLineTextInput
|
|
336
|
-
style={inheritStyles}
|
|
337
|
-
isEditing={false}
|
|
338
|
-
value={children}
|
|
339
|
-
/>
|
|
340
|
-
</TitleThatForwardsProps>
|
|
341
|
-
}
|
|
342
|
-
/>
|
|
343
|
-
</InlineEditOffsetContainer>
|
|
344
|
-
);
|
|
345
|
-
`,
|
|
346
|
-
`
|
|
347
|
-
import React from "react";
|
|
348
|
-
import InlineEdit from "@atlaskit/inline-edit";
|
|
349
|
-
|
|
350
|
-
export default () => (
|
|
351
|
-
<InlineEditOffsetContainer>
|
|
352
|
-
<InlineEdit
|
|
353
|
-
{...inlineEditProps}
|
|
354
|
-
label={label}
|
|
355
|
-
editButtonLabel={intl.formatMessage(
|
|
356
|
-
inlineEditableMessages.editButtonLabel,
|
|
357
|
-
i18nValues,
|
|
358
|
-
)}
|
|
359
|
-
confirmButtonLabel={intl.formatMessage(
|
|
360
|
-
inlineEditableMessages.confirmButtonLabel,
|
|
361
|
-
i18nValues,
|
|
362
|
-
)}
|
|
363
|
-
cancelButtonLabel={intl.formatMessage(
|
|
364
|
-
inlineEditableMessages.cancelButtonLabel,
|
|
365
|
-
i18nValues,
|
|
366
|
-
)}
|
|
367
|
-
isLabelHidden
|
|
368
|
-
isFitContainerWidthReadView
|
|
369
|
-
shouldConfirmOnEnter
|
|
370
|
-
isWaiting={isWaiting}
|
|
371
|
-
isInvalid={isInvalid}
|
|
372
|
-
invalidMessage={invalidMessage}
|
|
373
|
-
editView={
|
|
374
|
-
// We forward props from Title to SingleLineTextInput
|
|
375
|
-
// so the props InlineEdit injets are passed through.
|
|
376
|
-
<TitleThatForwardsProps>
|
|
377
|
-
<SingleLineTextInput
|
|
378
|
-
isEditing
|
|
379
|
-
isInitiallySelected
|
|
380
|
-
style={inheritStyles}
|
|
381
|
-
onChange={(e) =>
|
|
382
|
-
inlineEditProps.onChange(e.target.value)
|
|
383
|
-
}
|
|
384
|
-
value={inlineEditProps.value}
|
|
385
|
-
/>
|
|
386
|
-
</TitleThatForwardsProps>
|
|
387
|
-
}
|
|
388
|
-
readView={
|
|
389
|
-
// We forward props from Title to SingleLineTextInput
|
|
390
|
-
// so the props InlineEdit injets are passed through.
|
|
391
|
-
<TitleThatForwardsProps>
|
|
392
|
-
<SingleLineTextInput
|
|
393
|
-
style={inheritStyles}
|
|
394
|
-
isEditing={false}
|
|
395
|
-
value={children}
|
|
396
|
-
/>
|
|
397
|
-
</TitleThatForwardsProps>
|
|
398
|
-
}
|
|
399
|
-
/>
|
|
400
|
-
</InlineEditOffsetContainer>
|
|
401
|
-
);
|
|
402
|
-
`,
|
|
403
|
-
'should do nothing for editView is something other than arrow function',
|
|
404
|
-
);
|
|
405
|
-
});
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { createTransformer } from '@atlaskit/codemod-utils';
|
|
2
|
-
|
|
3
|
-
import addCommentsWhenValidateFound from '../migrates/add-comments-when-validate-found';
|
|
4
|
-
|
|
5
|
-
const transformer = createTransformer([addCommentsWhenValidateFound]);
|
|
6
|
-
|
|
7
|
-
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
8
|
-
|
|
9
|
-
describe('wrapEditViewWithInlineDialog prop', () => {
|
|
10
|
-
defineInlineTest(
|
|
11
|
-
{ default: transformer, parser: 'tsx' },
|
|
12
|
-
{},
|
|
13
|
-
`
|
|
14
|
-
import React from "react";
|
|
15
|
-
import InlineEdit from "@atlaskit/inline-edit";
|
|
16
|
-
|
|
17
|
-
export default () => (
|
|
18
|
-
<InlineEdit
|
|
19
|
-
defaultValue={editValue}
|
|
20
|
-
label="Inline edit"
|
|
21
|
-
editView={fieldProps => <Textfield {...fieldProps} autoFocus />}
|
|
22
|
-
readView={() => (
|
|
23
|
-
<ReadViewContainer data-testid="read-view">
|
|
24
|
-
{editValue || 'Click to enter value'}
|
|
25
|
-
</ReadViewContainer>
|
|
26
|
-
)}
|
|
27
|
-
onConfirm={value => setEditValue(value)}
|
|
28
|
-
/>
|
|
29
|
-
);
|
|
30
|
-
`,
|
|
31
|
-
`
|
|
32
|
-
import React from "react";
|
|
33
|
-
import InlineEdit from "@atlaskit/inline-edit";
|
|
34
|
-
|
|
35
|
-
export default () => (
|
|
36
|
-
<InlineEdit
|
|
37
|
-
defaultValue={editValue}
|
|
38
|
-
label="Inline edit"
|
|
39
|
-
editView={fieldProps => <Textfield {...fieldProps} autoFocus />}
|
|
40
|
-
readView={() => (
|
|
41
|
-
<ReadViewContainer data-testid="read-view">
|
|
42
|
-
{editValue || 'Click to enter value'}
|
|
43
|
-
</ReadViewContainer>
|
|
44
|
-
)}
|
|
45
|
-
onConfirm={value => setEditValue(value)}
|
|
46
|
-
/>
|
|
47
|
-
);
|
|
48
|
-
`,
|
|
49
|
-
'should not do anything particular',
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
defineInlineTest(
|
|
53
|
-
{ default: transformer, parser: 'tsx' },
|
|
54
|
-
{},
|
|
55
|
-
`
|
|
56
|
-
import React from "react";
|
|
57
|
-
import InlineEdit from "@atlaskit/inline-edit";
|
|
58
|
-
|
|
59
|
-
export default () => (
|
|
60
|
-
<InlineEdit
|
|
61
|
-
defaultValue={editValue}
|
|
62
|
-
label="Inline edit"
|
|
63
|
-
editView={fieldProps => <Textfield {...fieldProps} autoFocus />}
|
|
64
|
-
readView={() => (
|
|
65
|
-
<ReadViewContainer data-testid="read-view">
|
|
66
|
-
{editValue || 'Click to enter value'}
|
|
67
|
-
</ReadViewContainer>
|
|
68
|
-
)}
|
|
69
|
-
onConfirm={value => setEditValue(value)}
|
|
70
|
-
validate={() => {}}
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
`,
|
|
74
|
-
`
|
|
75
|
-
/* TODO: (from codemod) We could not automatically convert this code to the new API.
|
|
76
|
-
|
|
77
|
-
This file uses \`inline-edit\`’s \`validate\` prop which previously would use \`react-loadable\` and the \`inline-dialog\` packages. Version 12.0.0 of \`inline-edit\` now no longer includes these dependencies out of the box and instead allows you to compose your own experience.
|
|
78
|
-
|
|
79
|
-
If you are using an editable textfield you can move over to the \`@atlaskit/inline-edit/inline-editable-textfield\` instead which comes with the previous error message behavior.
|
|
80
|
-
|
|
81
|
-
To migrate you can use the \`isInvalid\` and \`errorMessage\` props passed to \`editView\`, like so:
|
|
82
|
-
|
|
83
|
-
\`\`\`ts
|
|
84
|
-
import InlineDialog from '@atlaskit/inline-dialog';
|
|
85
|
-
import InlineEdit from '@atlaskit/inline-edit';
|
|
86
|
-
|
|
87
|
-
const MyEditView = (
|
|
88
|
-
<InlineEdit
|
|
89
|
-
editView={({ errorMessage, isInvalid, ...props }) => (
|
|
90
|
-
<InlineDialog content={errorMessage} isOpen={isInvalid}>
|
|
91
|
-
<Textfield {...props} />
|
|
92
|
-
</InlineDialog>
|
|
93
|
-
)}
|
|
94
|
-
/>
|
|
95
|
-
);
|
|
96
|
-
\`\`\`
|
|
97
|
-
*/
|
|
98
|
-
import React from "react";
|
|
99
|
-
import InlineEdit from "@atlaskit/inline-edit";
|
|
100
|
-
|
|
101
|
-
export default () => (
|
|
102
|
-
<InlineEdit
|
|
103
|
-
defaultValue={editValue}
|
|
104
|
-
label="Inline edit"
|
|
105
|
-
editView={fieldProps => <Textfield {...fieldProps} autoFocus />}
|
|
106
|
-
readView={() => (
|
|
107
|
-
<ReadViewContainer data-testid="read-view">
|
|
108
|
-
{editValue || 'Click to enter value'}
|
|
109
|
-
</ReadViewContainer>
|
|
110
|
-
)}
|
|
111
|
-
onConfirm={value => setEditValue(value)}
|
|
112
|
-
validate={() => {}}
|
|
113
|
-
/>
|
|
114
|
-
);
|
|
115
|
-
`,
|
|
116
|
-
'add comment when validate function is defined',
|
|
117
|
-
);
|
|
118
|
-
});
|