@atlaskit/form 14.2.0 → 14.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/form
2
2
 
3
+ ## 14.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 14.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 14.2.0
4
16
 
5
17
  ### Minor Changes
@@ -978,7 +990,6 @@
978
990
  had no effect when used.
979
991
 
980
992
  The props which were removed from the typings are:
981
-
982
993
  - `error`
983
994
  - `fieldId`
984
995
  - `valid`
@@ -1575,7 +1586,6 @@
1575
1586
 
1576
1587
  Remove namespace imports from React, ReactDom, and PropTypes- Updated dependencies
1577
1588
  [6548261c9a](https://bitbucket.org/atlassian/atlassian-frontend/commits/6548261c9a):
1578
-
1579
1589
  - @atlaskit/docs@8.3.2
1580
1590
  - @atlaskit/visual-regression@0.1.9
1581
1591
  - @atlaskit/button@13.3.7
@@ -1893,7 +1903,6 @@
1893
1903
  ### Minor Changes
1894
1904
 
1895
1905
  - [minor][7bbf303d01](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/7bbf303d01):
1896
-
1897
1906
  - Improved form validation user experience when field validation and submission validation used
1898
1907
  together on the same field
1899
1908
  - Improved form validation docs
@@ -1982,13 +1991,11 @@
1982
1991
  ## 6.0.1
1983
1992
 
1984
1993
  - [patch][19bbcb44ed](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/19bbcb44ed):
1985
-
1986
1994
  - Upgrade final-form dependency. No behavioural or API changes.
1987
1995
 
1988
1996
  ## 6.0.0
1989
1997
 
1990
1998
  - [major][7c17b35107](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/7c17b35107):
1991
-
1992
1999
  - Updates react and react-dom peer dependencies to react@^16.8.0 and react-dom@^16.8.0. To use
1993
2000
  this package, please ensure you use at least this version of react and react-dom.
1994
2001
 
@@ -2011,7 +2018,6 @@
2011
2018
  ## 5.2.8
2012
2019
 
2013
2020
  - [patch][cb7ec50eca](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/cb7ec50eca):
2014
-
2015
2021
  - Internal changes only. Form is compatible with SSR.
2016
2022
 
2017
2023
  ## 5.2.7
@@ -2045,7 +2051,6 @@
2045
2051
  ## 5.2.6
2046
2052
 
2047
2053
  - [patch][9b0bdd73c2](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/9b0bdd73c2):
2048
-
2049
2054
  - Remove unused inline edit dependency from package
2050
2055
 
2051
2056
  ## 5.2.5
@@ -2093,7 +2098,6 @@
2093
2098
  ## 5.2.2
2094
2099
 
2095
2100
  - [patch][a1217df379](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/a1217df379):
2096
-
2097
2101
  - Internal changes only. Form is now compatible with ssr.
2098
2102
 
2099
2103
  ## 5.2.1
@@ -2128,13 +2132,11 @@
2128
2132
  ## 5.2.0
2129
2133
 
2130
2134
  - [minor][fe7683f9d6](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/fe7683f9d6):
2131
-
2132
2135
  - Feature: Submit form on Cmd + Enter on Mac and Ctrl + Enter on Mac and Windows
2133
2136
 
2134
2137
  ## 5.1.8
2135
2138
 
2136
2139
  - [patch][76299208e6](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/76299208e6):
2137
-
2138
2140
  - Drop ES5 from all the flow modules
2139
2141
 
2140
2142
  ### Dropping CJS support in all @atlaskit packages
@@ -2186,7 +2188,6 @@
2186
2188
  ## 5.1.6
2187
2189
 
2188
2190
  - [patch][887c85ffdc](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/887c85ffdc):
2189
-
2190
2191
  - Form now provides a `getValues` function to it's child render function. The `getValues` function
2191
2192
  returns an object containing the current value of all fields.
2192
2193
 
@@ -2201,13 +2202,11 @@
2201
2202
  ## 5.1.4
2202
2203
 
2203
2204
  - [patch][0c0f20c9cf](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/0c0f20c9cf):
2204
-
2205
2205
  - Fix typo in Field.js
2206
2206
 
2207
2207
  ## 5.1.3
2208
2208
 
2209
2209
  - [patch][a360a3d2b6](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/a360a3d2b6):
2210
-
2211
2210
  - Bugfix: field entry in form state gets deleted when Field is unmounted
2212
2211
  - Bugfix: Shallow equal check in Field works correctly across different types
2213
2212
 
@@ -2238,20 +2237,17 @@
2238
2237
  ## 5.1.1
2239
2238
 
2240
2239
  - [patch][58e7bc1](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/58e7bc1):
2241
-
2242
2240
  - Added example of Form use within a ModalDialog - no changes required
2243
2241
 
2244
2242
  ## 5.1.0
2245
2243
 
2246
2244
  - [minor][b36a82f](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/b36a82f):
2247
-
2248
2245
  - **feature:** Uses context to automatically assosiate a message to field. No upgrade changes
2249
2246
  required. Can remove fieldId prop on Message components if you are using that prop currently.
2250
2247
 
2251
2248
  ## 5.0.0
2252
2249
 
2253
2250
  - [major][647a46f](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/647a46f):
2254
-
2255
2251
  - **Breaking:** this version is a major overhaul of the package.
2256
2252
  - **Conceptual changes:** The `Form` component must be the source of truth for the form state.
2257
2253
  This means you keep track of far less state in your application.
@@ -2374,13 +2370,11 @@
2374
2370
  ## 4.0.15
2375
2371
 
2376
2372
  - [patch][e6d3f57](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/e6d3f57):
2377
-
2378
2373
  - Check that content children of FormSection are valid elements before cloning
2379
2374
 
2380
2375
  ## 4.0.14
2381
2376
 
2382
2377
  - [patch][c8d935f](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/c8d935f" d):
2383
-
2384
2378
  - Fixing form header styles
2385
2379
 
2386
2380
  ## 4.0.13
@@ -460,23 +460,23 @@ const formElement = (
460
460
  import Form from '@atlaskit/form';
461
461
 
462
462
  const FormComponent1 = () => (
463
- <Form onSubmit={() => {}} autocomplete="off" id="foo" name="bar" noValidate><input /></Form>
463
+ <Form onSubmit={() => {}} noValidate name="bar" id="foo" autocomplete="off"><input /></Form>
464
464
  );
465
465
 
466
466
  const FormComponent2 = () => (
467
467
  <>
468
- <Form onSubmit={() => {}} autocomplete="off" id="foo" name="bar" noValidate><input /></Form>
468
+ <Form onSubmit={() => {}} noValidate name="bar" id="foo" autocomplete="off"><input /></Form>
469
469
  </>
470
470
  );
471
471
 
472
472
  class FormComponent3 extends React.Component {
473
473
  render() {
474
- return (<Form onSubmit={() => {}} autocomplete="off" id="foo" name="bar" noValidate><input /></Form>);
474
+ return (<Form onSubmit={() => {}} noValidate name="bar" id="foo" autocomplete="off"><input /></Form>);
475
475
  }
476
476
  }
477
477
 
478
478
  const formElement = (
479
- <Form onSubmit={() => {}} autocomplete="off" id="foo" name="bar" noValidate><input /></Form>
479
+ <Form onSubmit={() => {}} noValidate name="bar" id="foo" autocomplete="off"><input /></Form>
480
480
  );
481
481
  `,
482
482
  'should migrate existing props on `form` into their respective props on `Form`',
@@ -540,23 +540,23 @@ const formElement = (
540
540
  import Form from '@atlaskit/form';
541
541
 
542
542
  const FormComponent1 = () => (
543
- <Form onSubmit={() => {}} label="foo" labelId="bar"><input /></Form>
543
+ <Form onSubmit={() => {}} labelId="bar" label="foo"><input /></Form>
544
544
  );
545
545
 
546
546
  const FormComponent2 = () => (
547
547
  <>
548
- <Form onSubmit={() => {}} label="foo" labelId="bar"><input /></Form>
548
+ <Form onSubmit={() => {}} labelId="bar" label="foo"><input /></Form>
549
549
  </>
550
550
  );
551
551
 
552
552
  class FormComponent3 extends React.Component {
553
553
  render() {
554
- return (<Form onSubmit={() => {}} label="foo" labelId="bar"><input /></Form>);
554
+ return (<Form onSubmit={() => {}} labelId="bar" label="foo"><input /></Form>);
555
555
  }
556
556
  }
557
557
 
558
558
  const formElement = (
559
- <Form onSubmit={() => {}} label="foo" labelId="bar"><input /></Form>
559
+ <Form onSubmit={() => {}} labelId="bar" label="foo"><input /></Form>
560
560
  );
561
561
  `,
562
562
  'should migrate existing props on `form` into different names',
@@ -622,26 +622,26 @@ const formElement = (
622
622
  const FormComponent1 = () => (
623
623
  <Form
624
624
  onSubmit={() => {}}
625
+ noValidate
626
+ name="bar"
627
+ id="foo"
628
+ autocomplete="off"
625
629
  formProps={{
626
630
  quu: "qux"
627
- }}
628
- autocomplete="off"
629
- id="foo"
630
- name="bar"
631
- noValidate><input /></Form>
631
+ }}><input /></Form>
632
632
  );
633
633
 
634
634
  const FormComponent2 = () => (
635
635
  <>
636
636
  <Form
637
637
  onSubmit={() => {}}
638
+ noValidate
639
+ name="bar"
640
+ id="foo"
641
+ autocomplete="off"
638
642
  formProps={{
639
643
  quu: "qux"
640
- }}
641
- autocomplete="off"
642
- id="foo"
643
- name="bar"
644
- noValidate><input /></Form>
644
+ }}><input /></Form>
645
645
  </>
646
646
  );
647
647
 
@@ -650,13 +650,13 @@ const formElement = (
650
650
  return (
651
651
  <Form
652
652
  onSubmit={() => {}}
653
+ noValidate
654
+ name="bar"
655
+ id="foo"
656
+ autocomplete="off"
653
657
  formProps={{
654
658
  quu: "qux"
655
- }}
656
- autocomplete="off"
657
- id="foo"
658
- name="bar"
659
- noValidate><input /></Form>
659
+ }}><input /></Form>
660
660
  );
661
661
  }
662
662
  }
@@ -664,13 +664,13 @@ const formElement = (
664
664
  const formElement = (
665
665
  <Form
666
666
  onSubmit={() => {}}
667
+ noValidate
668
+ name="bar"
669
+ id="foo"
670
+ autocomplete="off"
667
671
  formProps={{
668
672
  quu: "qux"
669
- }}
670
- autocomplete="off"
671
- id="foo"
672
- name="bar"
673
- noValidate><input /></Form>
673
+ }}><input /></Form>
674
674
  );
675
675
  `,
676
676
  'should migrate existing props on `form` into their respective props on `Form` and also use `formProps` if needed',
@@ -1,20 +1,12 @@
1
1
  import {
2
2
  type API,
3
+ type Collection,
3
4
  type FileInfo,
4
5
  type JSCodeshift,
5
6
  type JSXAttribute,
6
7
  type JSXElement,
7
8
  type Options,
8
9
  } from 'jscodeshift';
9
- import { type Collection } from 'jscodeshift/src/Collection';
10
-
11
- import {
12
- addJSXAttributeToJSXElement,
13
- getImportDeclarationCollection,
14
- getImportDefaultSpecifierCollection,
15
- getImportDefaultSpecifierName,
16
- hasImportDeclaration,
17
- } from './utils/helpers';
18
10
 
19
11
  const importPath = '@atlaskit/form';
20
12
  const EXISTING_FORM_ATTRIBUTES: Record<string, any> = {
@@ -26,6 +18,56 @@ const EXISTING_FORM_ATTRIBUTES: Record<string, any> = {
26
18
  noValidate: 'noValidate',
27
19
  };
28
20
 
21
+ const shouldSkipFile = (filePath: string): boolean =>
22
+ filePath.includes('__tests__') || filePath.includes('test');
23
+
24
+ /**
25
+ * Helper functions for JSX manipulation
26
+ */
27
+ function getImportDeclarationCollection(
28
+ j: JSCodeshift,
29
+ collection: Collection<any>,
30
+ importPath: string,
31
+ ): Collection<any> {
32
+ return collection.find(j.ImportDeclaration, {
33
+ source: { value: importPath },
34
+ });
35
+ }
36
+
37
+ function getImportDefaultSpecifierCollection(
38
+ j: JSCodeshift,
39
+ importDeclarationCollection: Collection<any>,
40
+ ): Collection<any> {
41
+ return importDeclarationCollection.find(j.ImportDefaultSpecifier);
42
+ }
43
+
44
+ function getImportDefaultSpecifierName(defaultImport: Collection<any>): string | null {
45
+ if (defaultImport.length === 0) {
46
+ return null;
47
+ }
48
+ return defaultImport.get(0).node.local.name;
49
+ }
50
+
51
+ function hasImportDeclaration(
52
+ j: JSCodeshift,
53
+ collection: Collection<any>,
54
+ importPath: string,
55
+ ): boolean {
56
+ return getImportDeclarationCollection(j, collection, importPath).length > 0;
57
+ }
58
+
59
+ function addJSXAttributeToJSXElement(
60
+ j: JSCodeshift,
61
+ jsxElementPath: any,
62
+ attribute: JSXAttribute,
63
+ position: number = 0,
64
+ ): void {
65
+ if (!jsxElementPath.node.openingElement.attributes) {
66
+ jsxElementPath.node.openingElement.attributes = [];
67
+ }
68
+ jsxElementPath.node.openingElement.attributes.splice(position, 0, attribute);
69
+ }
70
+
29
71
  const convertToSimpleForm = (j: JSCodeshift, collection: Collection<any>) => {
30
72
  const importDeclarationCollection = getImportDeclarationCollection(j, collection, importPath);
31
73
  const defaultImport = getImportDefaultSpecifierCollection(j, importDeclarationCollection);
@@ -58,7 +100,7 @@ const convertToSimpleForm = (j: JSCodeshift, collection: Collection<any>) => {
58
100
  return;
59
101
  }
60
102
 
61
- // if function child but more than just `fieldProps`, exit early
103
+ // if function child but more than just `formProps`, exit early
62
104
  const args = childFunction.expression.params
63
105
  .filter((arg) => arg.type === 'ObjectPattern' && 'properties' in arg)
64
106
  .flatMap((arg) => arg.properties)
@@ -188,7 +230,13 @@ const convertToSimpleForm = (j: JSCodeshift, collection: Collection<any>) => {
188
230
  };
189
231
 
190
232
  export default function transformer(fileInfo: FileInfo, { jscodeshift: j }: API, options: Options) {
191
- const { source } = fileInfo;
233
+ const { source, path } = fileInfo;
234
+
235
+ // Skip test files
236
+ if (path && shouldSkipFile(path)) {
237
+ return source;
238
+ }
239
+
192
240
  const collection = j(source);
193
241
 
194
242
  // If our component is not here, skip the file
@@ -13,7 +13,7 @@ type GetCurrentValue = <FormValues>(name: string) => FormValues[keyof FormValues
13
13
  export declare const FormContext: React.Context<{
14
14
  registerField: RegisterField;
15
15
  getCurrentValue: GetCurrentValue;
16
- subscribe: FormApi["subscribe"];
16
+ subscribe: FormApi['subscribe'];
17
17
  }>;
18
18
  /**
19
19
  * __Is disabled context__
@@ -116,5 +116,5 @@ export interface FormProps<FormValues> {
116
116
  * - [Code](https://atlassian.design/components/form/code)
117
117
  * - [Usage](https://atlassian.design/components/form/usage)
118
118
  */
119
- declare const Form: <FormValues extends Record<string, any> = {}>(props: FormProps<FormValues> & React.RefAttributes<HTMLFormElement>) => React.ReactElement | null;
119
+ declare const Form: <FormValues extends Record<string, any>>(props: FormProps<FormValues> & React.RefAttributes<HTMLFormElement>) => React.ReactElement | null;
120
120
  export default Form;
@@ -13,7 +13,7 @@ type GetCurrentValue = <FormValues>(name: string) => FormValues[keyof FormValues
13
13
  export declare const FormContext: React.Context<{
14
14
  registerField: RegisterField;
15
15
  getCurrentValue: GetCurrentValue;
16
- subscribe: FormApi["subscribe"];
16
+ subscribe: FormApi['subscribe'];
17
17
  }>;
18
18
  /**
19
19
  * __Is disabled context__
@@ -116,5 +116,5 @@ export interface FormProps<FormValues> {
116
116
  * - [Code](https://atlassian.design/components/form/code)
117
117
  * - [Usage](https://atlassian.design/components/form/usage)
118
118
  */
119
- declare const Form: <FormValues extends Record<string, any> = {}>(props: FormProps<FormValues> & React.RefAttributes<HTMLFormElement>) => React.ReactElement | null;
119
+ declare const Form: <FormValues extends Record<string, any>>(props: FormProps<FormValues> & React.RefAttributes<HTMLFormElement>) => React.ReactElement | null;
120
120
  export default Form;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/form",
3
- "version": "14.2.0",
3
+ "version": "14.2.2",
4
4
  "description": "A form allows users to input information.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -16,7 +16,7 @@
16
16
  "**/*.compiled.css"
17
17
  ],
18
18
  "atlaskit:src": "src/index.tsx",
19
- "atlaskit:designLink": "https://atlassian.design/guidelines/product/patterns/forms",
19
+ "atlaskit:designLink": "https://atlassian.design/patterns/forms",
20
20
  "atlassian": {
21
21
  "team": "Design System Team",
22
22
  "website": {
@@ -25,13 +25,13 @@
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "@atlaskit/css": "^0.14.0",
28
+ "@atlaskit/css": "^0.15.0",
29
29
  "@atlaskit/ds-lib": "^5.1.0",
30
30
  "@atlaskit/heading": "^5.2.0",
31
- "@atlaskit/icon": "^28.3.0",
31
+ "@atlaskit/icon": "^28.5.0",
32
32
  "@atlaskit/platform-feature-flags": "^1.1.0",
33
- "@atlaskit/primitives": "^14.15.0",
34
- "@atlaskit/tokens": "^6.3.0",
33
+ "@atlaskit/primitives": "^15.0.0",
34
+ "@atlaskit/tokens": "^7.0.0",
35
35
  "@babel/runtime": "^7.0.0",
36
36
  "final-form": "^4.20.3",
37
37
  "final-form-focus": "^1.1.2",
@@ -45,14 +45,14 @@
45
45
  "@af/integration-testing": "workspace:^",
46
46
  "@af/visual-regression": "workspace:^",
47
47
  "@atlaskit/banner": "^14.0.0",
48
- "@atlaskit/button": "^23.4.0",
48
+ "@atlaskit/button": "^23.5.0",
49
49
  "@atlaskit/checkbox": "^17.1.0",
50
50
  "@atlaskit/codemod-utils": "^4.2.0",
51
- "@atlaskit/datetime-picker": "^17.0.0",
52
- "@atlaskit/docs": "^11.1.0",
51
+ "@atlaskit/datetime-picker": "^17.1.0",
52
+ "@atlaskit/docs": "^11.2.0",
53
53
  "@atlaskit/link": "^3.2.0",
54
54
  "@atlaskit/lozenge": "^13.0.0",
55
- "@atlaskit/modal-dialog": "^14.4.0",
55
+ "@atlaskit/modal-dialog": "^14.5.0",
56
56
  "@atlaskit/radio": "^8.3.0",
57
57
  "@atlaskit/range": "^9.2.0",
58
58
  "@atlaskit/section-message": "^8.7.0",