@atlaskit/textfield 5.1.2

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +673 -0
  2. package/LICENSE +13 -0
  3. package/README.md +13 -0
  4. package/__perf__/default.tsx +5 -0
  5. package/__perf__/examples.tsx +58 -0
  6. package/codemods/5.0.0-lite-mode.tsx +16 -0
  7. package/codemods/__tests__/5.0.0-lite-mode.tsx +87 -0
  8. package/codemods/__tests__/remove-imports.tsx +64 -0
  9. package/codemods/__tests__/remove-prop.tsx +142 -0
  10. package/codemods/__tests__/rename-imports.tsx +85 -0
  11. package/codemods/migrations/remove-imports.tsx +8 -0
  12. package/codemods/migrations/remove-props.tsx +10 -0
  13. package/codemods/migrations/rename-imports.tsx +15 -0
  14. package/codemods/migrations/utils.tsx +375 -0
  15. package/dist/cjs/component-tokens.js +66 -0
  16. package/dist/cjs/index.js +23 -0
  17. package/dist/cjs/styles.js +231 -0
  18. package/dist/cjs/text-field.js +169 -0
  19. package/dist/cjs/types.js +5 -0
  20. package/dist/cjs/version.json +5 -0
  21. package/dist/es2019/component-tokens.js +46 -0
  22. package/dist/es2019/index.js +2 -0
  23. package/dist/es2019/styles.js +192 -0
  24. package/dist/es2019/text-field.js +129 -0
  25. package/dist/es2019/types.js +1 -0
  26. package/dist/es2019/version.json +5 -0
  27. package/dist/esm/component-tokens.js +46 -0
  28. package/dist/esm/index.js +2 -0
  29. package/dist/esm/styles.js +206 -0
  30. package/dist/esm/text-field.js +145 -0
  31. package/dist/esm/types.js +1 -0
  32. package/dist/esm/version.json +5 -0
  33. package/dist/types/component-tokens.d.ts +44 -0
  34. package/dist/types/index.d.ts +3 -0
  35. package/dist/types/styles.d.ts +208 -0
  36. package/dist/types/text-field.d.ts +14 -0
  37. package/dist/types/types.d.ts +71 -0
  38. package/package.json +79 -0
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2019 Atlassian Pty Ltd
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Textfield
2
+
3
+ A text field is an input that allows a user to write or edit text.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ yarn add @atlaskit/textfield
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Detailed docs and example usage can be found [here](https://atlassian.design/components/textfield/).
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+
3
+ import Textfield from '../src';
4
+
5
+ export default () => <Textfield name="basic" />;
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+
3
+ import { fireEvent } from '@testing-library/dom';
4
+ import {
5
+ InteractionTaskArgs,
6
+ PublicInteractionTask,
7
+ } from 'storybook-addon-performance';
8
+
9
+ import Texfield from '../src';
10
+
11
+ const testId = 'text-field-test-id';
12
+
13
+ const getLastTexfield = (container: HTMLElement) => {
14
+ const textField = container.querySelectorAll(`[data-testId="${testId}"]`);
15
+ return textField[textField.length - 1];
16
+ };
17
+
18
+ const textField = () => {
19
+ return <Texfield placeholder="new texfield" testId={testId} width="large" />;
20
+ };
21
+
22
+ const interactionTasks: PublicInteractionTask[] = [
23
+ {
24
+ name: 'Focus',
25
+ description: 'Render texfield and make input focus',
26
+ run: async ({ container }: InteractionTaskArgs): Promise<void> => {
27
+ const texfield = getLastTexfield(container);
28
+ fireEvent.focus(texfield);
29
+ },
30
+ },
31
+ {
32
+ name: 'Blur',
33
+ description: 'Render texfield and make input blur',
34
+ run: async ({ container }: InteractionTaskArgs): Promise<void> => {
35
+ const texfield = getLastTexfield(container);
36
+ fireEvent.blur(texfield);
37
+ },
38
+ },
39
+ {
40
+ name: 'OnChange',
41
+ description: 'Render texfield and make input change',
42
+ run: async ({ container }: InteractionTaskArgs): Promise<void> => {
43
+ const texfield = getLastTexfield(container);
44
+ fireEvent.change(texfield, { target: { value: 'foo' } });
45
+ },
46
+ },
47
+ ];
48
+
49
+ textField.story = {
50
+ name: 'texfield',
51
+ parameters: {
52
+ performance: {
53
+ interactions: interactionTasks,
54
+ },
55
+ },
56
+ };
57
+
58
+ export default textField;
@@ -0,0 +1,16 @@
1
+ import { removeThemeImports } from './migrations/remove-imports';
2
+ import { removeThemeProp } from './migrations/remove-props';
3
+ import {
4
+ renameThemeAppearanceImport,
5
+ renamethemeTokensImport,
6
+ } from './migrations/rename-imports';
7
+ import { createTransformer } from './migrations/utils';
8
+
9
+ const transformer = createTransformer('@atlaskit/textfield', [
10
+ removeThemeProp,
11
+ removeThemeImports,
12
+ renamethemeTokensImport,
13
+ renameThemeAppearanceImport,
14
+ ]);
15
+
16
+ export default transformer;
@@ -0,0 +1,87 @@
1
+ jest.autoMockOff();
2
+
3
+ import transformer from '../5.0.0-lite-mode';
4
+
5
+ const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
6
+
7
+ describe('TextField code-mods', () => {
8
+ defineInlineTest(
9
+ { default: transformer, parser: 'tsx' },
10
+ {},
11
+ `
12
+ import Textfield, { ThemeProps, ThemeAppearance , themeTokens as ColorTokens, ThemeTokens } from '@atlaskit/textfield';
13
+ import customeTheme from './theme';
14
+ import React from 'react';
15
+
16
+ const SimpleTextfield = () => {
17
+ return (
18
+ <Textfield
19
+ theme={customTheme}
20
+ />
21
+ );
22
+ }
23
+ `,
24
+ `
25
+ /* TODO: (from codemod) This file uses the @atlaskit/textfield \`theme\` prop which
26
+ has now been removed due to its poor performance characteristics. We have not replaced
27
+ theme with an equivalent API due to minimal usage of the \`theme\` prop.
28
+ The appearance of TextField will have likely changed. */
29
+ /* TODO: (from codemod) This file uses exports used to help theme @atlaskit/textfield which
30
+ has now been removed due to its poor performance characteristics. */
31
+ import Textfield, { Appearance, TextFieldColors as ColorTokens } from '@atlaskit/textfield';
32
+ import customeTheme from './theme';
33
+ import React from 'react';
34
+
35
+ const SimpleTextfield = () => {
36
+ return <Textfield />;
37
+ }
38
+ `,
39
+ 'should remove theme & its imports from Textfield and leave a comment',
40
+ );
41
+ defineInlineTest(
42
+ { default: transformer, parser: 'tsx' },
43
+ {},
44
+ `
45
+ import Textfield, { ThemeProps, ThemeTokens } from '@atlaskit/textfield';
46
+ import React from 'react';
47
+
48
+ const SimpleTextfield = () => {
49
+ return (
50
+ <Textfield
51
+ theme={(theme, props: ThemeProps) => {
52
+ const { container, input, ...rest } = theme(props);
53
+ return {
54
+ ...rest,
55
+ container: {
56
+ ...container,
57
+ padding: 5,
58
+ border: '2px solid orange',
59
+ },
60
+ input: {
61
+ ...input,
62
+ fontSize: 20,
63
+ border: '2px solid green',
64
+ },
65
+ };
66
+ }}
67
+ />
68
+ );
69
+ }
70
+ `,
71
+ `
72
+ /* TODO: (from codemod) This file uses the @atlaskit/textfield \`theme\` prop which
73
+ has now been removed due to its poor performance characteristics. We have not replaced
74
+ theme with an equivalent API due to minimal usage of the \`theme\` prop.
75
+ The appearance of TextField will have likely changed. */
76
+ /* TODO: (from codemod) This file uses exports used to help theme @atlaskit/textfield which
77
+ has now been removed due to its poor performance characteristics. */
78
+ import Textfield from '@atlaskit/textfield';
79
+ import React from 'react';
80
+
81
+ const SimpleTextfield = () => {
82
+ return <Textfield />;
83
+ }
84
+ `,
85
+ 'should remove theme prop & its imports from Textfield and leave a comment',
86
+ );
87
+ });
@@ -0,0 +1,64 @@
1
+ jest.autoMockOff();
2
+
3
+ import { removeThemeImports } from '../migrations/remove-imports';
4
+ import { createTransformer } from '../migrations/utils';
5
+
6
+ const transformer = createTransformer('@atlaskit/textfield', [
7
+ removeThemeImports,
8
+ ]);
9
+
10
+ const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
11
+
12
+ const importToDoComment = `
13
+ /* TODO: (from codemod) This file uses exports used to help theme @atlaskit/textfield which
14
+ has now been removed due to its poor performance characteristics. */`;
15
+
16
+ describe('Remove imports', () => {
17
+ defineInlineTest(
18
+ { default: transformer, parser: 'tsx' },
19
+ {},
20
+ `
21
+ import Textfield, { Theme, ThemeProps, ThemeTokens } from '@atlaskit/textfield';
22
+ `,
23
+ `
24
+ ${importToDoComment}
25
+ import Textfield from '@atlaskit/textfield';
26
+ `,
27
+ 'should remove theme imports from Textfield and leave a comment',
28
+ );
29
+ defineInlineTest(
30
+ { default: transformer, parser: 'tsx' },
31
+ {},
32
+ `
33
+ import Textfield, { ThemeProps as TextfieldThemeProp, Theme as TextFieldTheme, ThemeTokens as TextfieldThemeTokens} from '@atlaskit/textfield';
34
+ `,
35
+ `
36
+ ${importToDoComment}
37
+ import Textfield from '@atlaskit/textfield';
38
+ `,
39
+ 'should remove theme imports with alias name from Textfield and leave a comment',
40
+ );
41
+ defineInlineTest(
42
+ { default: transformer, parser: 'tsx' },
43
+ {},
44
+ `
45
+ import { TextFieldProps, ThemeProps, Theme, ThemeTokens } from '@atlaskit/textfield';
46
+ `,
47
+ `
48
+ ${importToDoComment}
49
+ import { TextFieldProps } from '@atlaskit/textfield';
50
+ `,
51
+ 'should remove theme imports & leave other imports from Textfield and leave a comment',
52
+ );
53
+ defineInlineTest(
54
+ { default: transformer, parser: 'tsx' },
55
+ {},
56
+ `
57
+ import { ThemeProps, ThemeTokens, Theme } from '@atlaskit/textfield';
58
+ `,
59
+ `
60
+ ${importToDoComment}
61
+ `,
62
+ 'should remove theme imports & remove whole line if no default import from Textfield and leave a comment',
63
+ );
64
+ });
@@ -0,0 +1,142 @@
1
+ jest.autoMockOff();
2
+
3
+ import { removeThemeProp } from '../migrations/remove-props';
4
+ import { createTransformer } from '../migrations/utils';
5
+
6
+ const transformer = createTransformer('@atlaskit/textfield', [removeThemeProp]);
7
+
8
+ const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
9
+
10
+ const themeToDoComment = `
11
+ /* TODO: (from codemod) This file uses the @atlaskit/textfield \`theme\` prop which
12
+ has now been removed due to its poor performance characteristics. We have not replaced
13
+ theme with an equivalent API due to minimal usage of the \`theme\` prop.
14
+ The appearance of TextField will have likely changed. */`;
15
+
16
+ describe('Remove prop', () => {
17
+ defineInlineTest(
18
+ { default: transformer, parser: 'tsx' },
19
+ {},
20
+ `
21
+ import React from 'react';
22
+ import Textfield from '@atlaskit/textfield';
23
+ import customeTheme from './theme';
24
+
25
+ const SimpleTextfield = () => {
26
+ return (
27
+ <Textfield
28
+ theme={customTheme}
29
+ />
30
+ );
31
+ }
32
+ `,
33
+ `
34
+ ${themeToDoComment}
35
+ import React from 'react';
36
+ import Textfield from '@atlaskit/textfield';
37
+ import customeTheme from './theme';
38
+
39
+ const SimpleTextfield = () => {
40
+ return <Textfield />;
41
+ }
42
+ `,
43
+ 'should remove theme from Textfield and leave a comment',
44
+ );
45
+
46
+ defineInlineTest(
47
+ { default: transformer, parser: 'tsx' },
48
+ {},
49
+ `
50
+ import React from 'react';
51
+ import TextField from '@atlaskit/textfield';
52
+ import customeTheme from './theme';
53
+
54
+ const SimpleTextfield = () => {
55
+ return (
56
+ <TextField
57
+ theme={customTheme}
58
+ />
59
+ );
60
+ }
61
+ `,
62
+ `
63
+ ${themeToDoComment}
64
+ import React from 'react';
65
+ import TextField from '@atlaskit/textfield';
66
+ import customeTheme from './theme';
67
+
68
+ const SimpleTextfield = () => {
69
+ return <TextField />;
70
+ }
71
+ `,
72
+ 'should remove theme from TextField and leave a comment',
73
+ );
74
+
75
+ defineInlineTest(
76
+ { default: transformer, parser: 'tsx' },
77
+ {},
78
+ `
79
+ import React from 'react';
80
+ import Textfield from '@atlaskit/textfield';
81
+ import customeTheme from './theme';
82
+
83
+ const SimpleTextfield = () => {
84
+ return (
85
+ <div>
86
+ <Textfield
87
+ theme={customTheme}
88
+ />
89
+ <Textfield
90
+ theme={customTheme}
91
+ />
92
+ </div>
93
+ );
94
+ }
95
+ `,
96
+ `
97
+ ${themeToDoComment}
98
+ import React from 'react';
99
+ import Textfield from '@atlaskit/textfield';
100
+ import customeTheme from './theme';
101
+
102
+ const SimpleTextfield = () => {
103
+ return (
104
+ <div>
105
+ <Textfield />
106
+ <Textfield />
107
+ </div>
108
+ );
109
+ }
110
+ `,
111
+ 'should remove 2 usages of theme and add 1 comment',
112
+ );
113
+
114
+ defineInlineTest(
115
+ { default: transformer, parser: 'tsx' },
116
+ {},
117
+ `
118
+ import React from 'react';
119
+ import Foo from '@atlaskit/textfield';
120
+ import customeTheme from './theme';
121
+
122
+ const SimpleTextfield = () => {
123
+ return (
124
+ <Foo
125
+ theme={customeTheme}
126
+ />
127
+ );
128
+ }
129
+ `,
130
+ `
131
+ ${themeToDoComment}
132
+ import React from 'react';
133
+ import Foo from '@atlaskit/textfield';
134
+ import customeTheme from './theme';
135
+
136
+ const SimpleTextfield = () => {
137
+ return <Foo />;
138
+ }
139
+ `,
140
+ 'should remove theme prop when using an aliased name',
141
+ );
142
+ });
@@ -0,0 +1,85 @@
1
+ jest.autoMockOff();
2
+
3
+ import {
4
+ renameThemeAppearanceImport,
5
+ renamethemeTokensImport,
6
+ } from '../migrations/rename-imports';
7
+ import { createTransformer } from '../migrations/utils';
8
+
9
+ const transformer = createTransformer('@atlaskit/textfield', [
10
+ renamethemeTokensImport,
11
+ renameThemeAppearanceImport,
12
+ ]);
13
+
14
+ const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
15
+
16
+ describe('Rename imports', () => {
17
+ defineInlineTest(
18
+ { default: transformer, parser: 'tsx' },
19
+ {},
20
+ `
21
+ import { themeTokens, ThemeAppearance } from '@atlaskit/textfield';
22
+ `,
23
+ `
24
+ import { TextFieldColors, Appearance } from '@atlaskit/textfield';
25
+ `,
26
+ 'should rename themeTokens & ThemeAppearance to TextFieldColors & Appearance',
27
+ );
28
+ defineInlineTest(
29
+ { default: transformer, parser: 'tsx' },
30
+ {},
31
+ `
32
+ import Textfield, { ThemeAppearance, themeTokens } from '@atlaskit/textfield';
33
+ `,
34
+ `
35
+ import Textfield, { Appearance, TextFieldColors } from '@atlaskit/textfield';
36
+ `,
37
+ 'should rename themeTokens & Appearance to TextFieldColors & Appearance and keep Textfield default import as is',
38
+ );
39
+ defineInlineTest(
40
+ { default: transformer, parser: 'tsx' },
41
+ {},
42
+ `
43
+ import Textfield, { TextFieldProps, themeTokens } from '@atlaskit/textfield';
44
+ `,
45
+ `
46
+ import Textfield, { TextFieldProps, TextFieldColors } from '@atlaskit/textfield';
47
+ `,
48
+ 'should rename themeTokens to TextFieldColors and keep TextFieldProps as is',
49
+ );
50
+ defineInlineTest(
51
+ { default: transformer, parser: 'tsx' },
52
+ {},
53
+ `
54
+ import Textfield, { TextFieldProps, themeTokens as MyLifeMyColors } from '@atlaskit/textfield';
55
+ `,
56
+ `
57
+ import Textfield, { TextFieldProps, TextFieldColors as MyLifeMyColors } from '@atlaskit/textfield';
58
+ `,
59
+ 'should rename themeTokens to TextFieldColors and keep its alias name as is',
60
+ );
61
+ defineInlineTest(
62
+ { default: transformer, parser: 'tsx' },
63
+ {},
64
+ `
65
+ import Textfield, { ThemeProps as TextfieldThemeProp,
66
+ ThemeAppearance as TextFieldAppearance, Theme as TextFieldTheme, themeTokens as MyLifeMyColors, ThemeTokens as TextfieldThemeTokens} from '@atlaskit/textfield';
67
+ `,
68
+ `
69
+ import Textfield, { ThemeProps as TextfieldThemeProp,
70
+ Appearance as TextFieldAppearance, Theme as TextFieldTheme, TextFieldColors as MyLifeMyColors, ThemeTokens as TextfieldThemeTokens} from '@atlaskit/textfield';
71
+ `,
72
+ 'should rename themeTokens to TextFieldColors, ThemeAppearance to Appearance and keep its alias name as is even when there are multiple name exports with alias',
73
+ );
74
+ defineInlineTest(
75
+ { default: transformer, parser: 'tsx' },
76
+ {},
77
+ `
78
+ import { themeTokens, TextFieldProps } from '@atlaskit/textfield';
79
+ `,
80
+ `
81
+ import { TextFieldColors, TextFieldProps } from '@atlaskit/textfield';
82
+ `,
83
+ 'should rename themeTokens to TextFieldColors and keep TextFieldProps named import as is',
84
+ );
85
+ });