@atlaskit/form 15.5.1 → 15.5.3

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 (43) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/codemods/migrate-data-testid-to-testid-prop.tsx +5 -7
  3. package/codemods/utils/add-jsx-attribute-to-jsx-element.tsx +21 -0
  4. package/codemods/utils/create-remove-func-for.tsx +30 -0
  5. package/codemods/utils/get-dynamic-import-collection.tsx +40 -0
  6. package/codemods/utils/get-import-declaration-collection.tsx +12 -0
  7. package/codemods/utils/get-import-default-specifier-collection.tsx +9 -0
  8. package/codemods/utils/get-import-default-specifier-name.tsx +12 -0
  9. package/codemods/utils/get-import-specifier-collection.tsx +12 -0
  10. package/codemods/utils/get-import-specifier-name.tsx +12 -0
  11. package/codemods/utils/get-jsx-attribute-by-name.tsx +15 -0
  12. package/codemods/utils/get-jsx-attributes-by-name.tsx +17 -0
  13. package/codemods/utils/get-jsx-attributes.tsx +5 -0
  14. package/codemods/utils/get-jsx-spread-identifier-attributes-by-name.tsx +37 -0
  15. package/codemods/utils/get-jsx-spread-object-expression-attributes-by-name.tsx +19 -0
  16. package/codemods/utils/has-dynamic-import.tsx +12 -0
  17. package/codemods/utils/has-import-declaration.tsx +12 -0
  18. package/codemods/utils/is-class-declaration-identifier-present.tsx +14 -0
  19. package/codemods/utils/is-function-declaration-identifier-present.tsx +14 -0
  20. package/codemods/utils/is-import-declaration-identifier-present.tsx +13 -0
  21. package/codemods/utils/is-variable-declarator-identifier-present.tsx +17 -0
  22. package/codemods/utils/remove-jsx-attribute-by-name.tsx +16 -0
  23. package/codemods/utils/remove-jsx-attribute-object-property-by-name.tsx +58 -0
  24. package/dist/cjs/character-counter.compiled.css +1 -1
  25. package/dist/cjs/character-counter.js +1 -1
  26. package/dist/cjs/messages.compiled.css +3 -3
  27. package/dist/cjs/messages.js +3 -3
  28. package/dist/cjs/required-asterisk.compiled.css +1 -1
  29. package/dist/cjs/required-asterisk.js +1 -1
  30. package/dist/es2019/character-counter.compiled.css +1 -1
  31. package/dist/es2019/character-counter.js +1 -1
  32. package/dist/es2019/messages.compiled.css +3 -3
  33. package/dist/es2019/messages.js +3 -3
  34. package/dist/es2019/required-asterisk.compiled.css +1 -1
  35. package/dist/es2019/required-asterisk.js +1 -1
  36. package/dist/esm/character-counter.compiled.css +1 -1
  37. package/dist/esm/character-counter.js +1 -1
  38. package/dist/esm/messages.compiled.css +3 -3
  39. package/dist/esm/messages.js +3 -3
  40. package/dist/esm/required-asterisk.compiled.css +1 -1
  41. package/dist/esm/required-asterisk.js +1 -1
  42. package/package.json +10 -2
  43. package/codemods/utils/helpers.tsx +0 -353
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/form
2
2
 
3
+ ## 15.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`02483200273ec`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/02483200273ec) -
8
+ Enrol all Design System UI packages into the React Compiler with platform gating via
9
+ isReactCompilerActivePlatform.
10
+ - Updated dependencies
11
+
12
+ ## 15.5.2
13
+
14
+ ### Patch Changes
15
+
16
+ - [`22bf79dbdcdca`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/22bf79dbdcdca) -
17
+ Internal changes to remove unnecessary token fallbacks and imports from `@atlaskit/theme`
18
+ - Updated dependencies
19
+
3
20
  ## 15.5.1
4
21
 
5
22
  ### Patch Changes
@@ -7,13 +7,11 @@ import {
7
7
  } from 'jscodeshift';
8
8
  import { type Collection } from 'jscodeshift/src/Collection';
9
9
 
10
- import {
11
- addJSXAttributeToJSXElement,
12
- getImportDeclarationCollection,
13
- getImportDefaultSpecifierCollection,
14
- getImportDefaultSpecifierName,
15
- hasImportDeclaration,
16
- } from './utils/helpers';
10
+ import { addJSXAttributeToJSXElement } from './utils/add-jsx-attribute-to-jsx-element';
11
+ import { getImportDeclarationCollection } from './utils/get-import-declaration-collection';
12
+ import { getImportDefaultSpecifierCollection } from './utils/get-import-default-specifier-collection';
13
+ import { getImportDefaultSpecifierName } from './utils/get-import-default-specifier-name';
14
+ import { hasImportDeclaration } from './utils/has-import-declaration';
17
15
 
18
16
  const importPath = '@atlaskit/form';
19
17
 
@@ -0,0 +1,21 @@
1
+ import { type ASTPath, type JSCodeshift, type JSXAttribute, type JSXElement } from 'jscodeshift';
2
+
3
+ export const addJSXAttributeToJSXElement: (
4
+ j: JSCodeshift,
5
+ jsxElementPath: ASTPath<JSXElement>,
6
+ jsxAttribute: JSXAttribute,
7
+ limit?: number,
8
+ ) => void = (
9
+ j: JSCodeshift,
10
+ jsxElementPath: ASTPath<JSXElement>,
11
+ jsxAttribute: JSXAttribute,
12
+ limit?: number,
13
+ ) => {
14
+ j(jsxElementPath)
15
+ .find(j.JSXOpeningElement)
16
+ .forEach((openingElement, i) => {
17
+ if (!limit || i < limit) {
18
+ openingElement.node.attributes?.push(jsxAttribute);
19
+ }
20
+ });
21
+ };
@@ -0,0 +1,30 @@
1
+ import { type JSCodeshift } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ import { addCommentToStartOfFile, getNamedSpecifier } from '@atlaskit/codemod-utils';
5
+
6
+ import { getJSXAttributesByName } from './get-jsx-attributes-by-name';
7
+
8
+ export const createRemoveFuncFor: (
9
+ component: string,
10
+ importName: string,
11
+ prop: string,
12
+ comment?: string,
13
+ ) => (j: JSCodeshift, source: Collection<Node>) => void =
14
+ (component: string, importName: string, prop: string, comment?: string) =>
15
+ (j: JSCodeshift, source: Collection<Node>) => {
16
+ const specifier = getNamedSpecifier(j, source, component, importName);
17
+
18
+ if (!specifier) {
19
+ return;
20
+ }
21
+
22
+ source.findJSXElements(specifier).forEach((element) => {
23
+ getJSXAttributesByName(j, element, prop).forEach((attribute: any) => {
24
+ j(attribute).remove();
25
+ if (comment) {
26
+ addCommentToStartOfFile({ j, base: source, message: comment });
27
+ }
28
+ });
29
+ });
30
+ };
@@ -0,0 +1,40 @@
1
+ import { type CallExpression, type JSCodeshift } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ function isCallExpressionCalleeImportType(callee: CallExpression['callee']) {
5
+ return callee && callee.type === 'Import';
6
+ }
7
+
8
+ function isCallExpressionArgumentStringLiteralType(
9
+ callExpressionArguments: CallExpression['arguments'],
10
+ ) {
11
+ return (
12
+ callExpressionArguments &&
13
+ callExpressionArguments.length &&
14
+ callExpressionArguments[0].type === 'StringLiteral'
15
+ );
16
+ }
17
+
18
+ function isCallExpressionArgumentValueMatches(
19
+ callExpressionArgument: CallExpression['arguments'][0],
20
+ j: JSCodeshift,
21
+ value: string,
22
+ ) {
23
+ return j(callExpressionArgument).some((path) => path.node.value === value);
24
+ }
25
+
26
+ export function getDynamicImportCollection(
27
+ j: JSCodeshift,
28
+ collection: Collection<any>,
29
+ importPath: string,
30
+ ): Collection<CallExpression> {
31
+ return collection.find(j.CallExpression).filter((callExpressionPath) => {
32
+ const { callee, arguments: callExpressionArguments } = callExpressionPath.node;
33
+
34
+ return !!(
35
+ isCallExpressionCalleeImportType(callee) &&
36
+ isCallExpressionArgumentStringLiteralType(callExpressionArguments) &&
37
+ isCallExpressionArgumentValueMatches(callExpressionArguments[0], j, importPath)
38
+ );
39
+ });
40
+ }
@@ -0,0 +1,12 @@
1
+ import { type ImportDeclaration, type JSCodeshift } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ export function getImportDeclarationCollection(
5
+ j: JSCodeshift,
6
+ collection: Collection<any>,
7
+ importPath: string,
8
+ ): Collection<ImportDeclaration> {
9
+ return collection
10
+ .find(j.ImportDeclaration)
11
+ .filter((importDeclarationPath) => importDeclarationPath.node.source.value === importPath);
12
+ }
@@ -0,0 +1,9 @@
1
+ import { type ImportDeclaration, type ImportDefaultSpecifier, type JSCodeshift } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ export function getImportDefaultSpecifierCollection(
5
+ j: JSCodeshift,
6
+ importDeclarationCollection: Collection<ImportDeclaration>,
7
+ ): Collection<ImportDefaultSpecifier> {
8
+ return importDeclarationCollection.find(j.ImportDefaultSpecifier);
9
+ }
@@ -0,0 +1,12 @@
1
+ import { type ImportDefaultSpecifier } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ export function getImportDefaultSpecifierName(
5
+ importSpecifierCollection: Collection<ImportDefaultSpecifier>,
6
+ ): string | null {
7
+ if (importSpecifierCollection.length === 0) {
8
+ return null;
9
+ }
10
+
11
+ return importSpecifierCollection.nodes()[0]!.local!.name;
12
+ }
@@ -0,0 +1,12 @@
1
+ import { type ImportDeclaration, type ImportSpecifier, type JSCodeshift } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ export function getImportSpecifierCollection(
5
+ j: JSCodeshift,
6
+ importDeclarationCollection: Collection<ImportDeclaration>,
7
+ importName: string,
8
+ ): Collection<ImportSpecifier> {
9
+ return importDeclarationCollection
10
+ .find(j.ImportSpecifier)
11
+ .filter((importSpecifierPath) => importSpecifierPath.node.imported.name === importName);
12
+ }
@@ -0,0 +1,12 @@
1
+ import { type ImportSpecifier } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ export function getImportSpecifierName(
5
+ importSpecifierCollection: Collection<ImportSpecifier>,
6
+ ): string | null {
7
+ if (importSpecifierCollection.length === 0) {
8
+ return null;
9
+ }
10
+
11
+ return importSpecifierCollection.nodes()[0]!.local!.name;
12
+ }
@@ -0,0 +1,15 @@
1
+ import { type ASTPath, type JSCodeshift, type JSXAttribute, type JSXElement } from 'jscodeshift';
2
+
3
+ export const getJSXAttributeByName: (
4
+ j: JSCodeshift,
5
+ jsxElementPath: ASTPath<JSXElement>,
6
+ attributeName: string,
7
+ ) => JSXAttribute | undefined = (
8
+ j: JSCodeshift,
9
+ jsxElementPath: ASTPath<JSXElement>,
10
+ attributeName: string,
11
+ ): JSXAttribute | undefined => {
12
+ const attributes: JSXAttribute[] = j(jsxElementPath).find(j.JSXAttribute).nodes();
13
+
14
+ return attributes?.find((attr) => attr.name && attr.name.name === attributeName);
15
+ };
@@ -0,0 +1,17 @@
1
+ import { type ASTPath, type JSCodeshift, type JSXAttribute, type JSXElement } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ export function getJSXAttributesByName(
5
+ j: JSCodeshift,
6
+ jsxElementPath: ASTPath<JSXElement>,
7
+ attributeName: string,
8
+ ): Collection<JSXAttribute> {
9
+ return j(jsxElementPath)
10
+ .find(j.JSXOpeningElement)
11
+ .find(j.JSXAttribute)
12
+ .filter((jsxAttributePath) =>
13
+ j(jsxAttributePath)
14
+ .find(j.JSXIdentifier)
15
+ .some((jsxIdentifierPath) => jsxIdentifierPath.node.name === attributeName),
16
+ );
17
+ }
@@ -0,0 +1,5 @@
1
+ import { type ASTPath, type JSXAttribute, type JSXElement } from 'jscodeshift';
2
+
3
+ export const getJSXAttributes: (jsxElementPath: ASTPath<JSXElement>) => JSXAttribute[] = (
4
+ jsxElementPath: ASTPath<JSXElement>,
5
+ ) => jsxElementPath.node.openingElement.attributes as JSXAttribute[];
@@ -0,0 +1,37 @@
1
+ import { type ASTPath, type JSCodeshift, type JSXElement, type ObjectProperty } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ export function getJSXSpreadIdentifierAttributesByName(
5
+ j: JSCodeshift,
6
+ collection: Collection<any>,
7
+ jsxElementPath: ASTPath<JSXElement>,
8
+ attributeName: string,
9
+ ): Collection<ObjectProperty> | null {
10
+ const identifierCollection = j(jsxElementPath)
11
+ .find(j.JSXOpeningElement)
12
+ .find(j.JSXSpreadAttribute)
13
+ .filter((jsxSpreadAttributePath) => jsxSpreadAttributePath.node.argument.type === 'Identifier')
14
+ .find(j.Identifier);
15
+
16
+ if (identifierCollection.length === 0) {
17
+ return null;
18
+ }
19
+
20
+ return collection
21
+ .find(j.VariableDeclarator)
22
+ .filter((variableDeclaratorPath) => {
23
+ const { id } = variableDeclaratorPath.node;
24
+
25
+ return (
26
+ id.type === 'Identifier' &&
27
+ identifierCollection.some((identifierPath) => identifierPath.node.name === id.name)
28
+ );
29
+ })
30
+ .find(j.ObjectExpression)
31
+ .find(j.ObjectProperty)
32
+ .filter((objectPropertyPath) =>
33
+ j(objectPropertyPath)
34
+ .find(j.Identifier)
35
+ .some((identifierPath) => identifierPath.node.name === attributeName),
36
+ );
37
+ }
@@ -0,0 +1,19 @@
1
+ import { type ASTPath, type JSCodeshift, type JSXElement, type ObjectProperty } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ export function getJSXSpreadObjectExpressionAttributesByName(
5
+ j: JSCodeshift,
6
+ jsxElementPath: ASTPath<JSXElement>,
7
+ attributeName: string,
8
+ ): Collection<ObjectProperty> {
9
+ return j(jsxElementPath)
10
+ .find(j.JSXOpeningElement)
11
+ .find(j.JSXSpreadAttribute)
12
+ .find(j.ObjectExpression)
13
+ .find(j.ObjectProperty)
14
+ .filter((objectPropertyPath) =>
15
+ j(objectPropertyPath)
16
+ .find(j.Identifier)
17
+ .some((identifierPath) => identifierPath.node.name === attributeName),
18
+ );
19
+ }
@@ -0,0 +1,12 @@
1
+ import { type JSCodeshift } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ import { getDynamicImportCollection } from './get-dynamic-import-collection';
5
+
6
+ export function hasDynamicImport(
7
+ j: JSCodeshift,
8
+ collection: Collection<any>,
9
+ importPath: string,
10
+ ): boolean {
11
+ return getDynamicImportCollection(j, collection, importPath).length > 0;
12
+ }
@@ -0,0 +1,12 @@
1
+ import { type JSCodeshift } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ import { getImportDeclarationCollection } from './get-import-declaration-collection';
5
+
6
+ export function hasImportDeclaration(
7
+ j: JSCodeshift,
8
+ collection: Collection<any>,
9
+ importPath: string,
10
+ ): boolean {
11
+ return getImportDeclarationCollection(j, collection, importPath).length > 0;
12
+ }
@@ -0,0 +1,14 @@
1
+ import { type Identifier, type JSCodeshift } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ export function isClassDeclarationIdentifierPresent(
5
+ j: JSCodeshift,
6
+ collection: Collection<any>,
7
+ variableName: string,
8
+ ): boolean {
9
+ return collection.find(j.ClassDeclaration).some((classDeclarationPath) => {
10
+ const { id } = classDeclarationPath.node;
11
+
12
+ return !!(id && id.type === 'Identifier' && (id as Identifier).name === variableName);
13
+ });
14
+ }
@@ -0,0 +1,14 @@
1
+ import { type Identifier, type JSCodeshift } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ export function isFunctionDeclarationIdentifierPresent(
5
+ j: JSCodeshift,
6
+ collection: Collection<any>,
7
+ variableName: string,
8
+ ): boolean {
9
+ return collection.find(j.FunctionDeclaration).some((functionDeclarationPath) => {
10
+ const { id } = functionDeclarationPath.node;
11
+
12
+ return !!(id && id.type === 'Identifier' && (id as Identifier).name === variableName);
13
+ });
14
+ }
@@ -0,0 +1,13 @@
1
+ import { type JSCodeshift } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ export function isImportDeclarationIdentifierPresent(
5
+ j: JSCodeshift,
6
+ collection: Collection<any>,
7
+ variableName: string,
8
+ ): boolean {
9
+ return collection
10
+ .find(j.ImportDeclaration)
11
+ .find(j.Identifier)
12
+ .some((identifierPath) => identifierPath.node.name === variableName);
13
+ }
@@ -0,0 +1,17 @@
1
+ import { type Identifier, type JSCodeshift } from 'jscodeshift';
2
+ import { type Collection } from 'jscodeshift/src/Collection';
3
+
4
+ export function isVariableDeclaratorIdentifierPresent(
5
+ j: JSCodeshift,
6
+ collection: Collection<any>,
7
+ variableName: string,
8
+ ): boolean {
9
+ return collection
10
+ .find(j.VariableDeclaration)
11
+ .find(j.VariableDeclarator)
12
+ .some((variableDeclaratorPath) => {
13
+ const { id } = variableDeclaratorPath.node;
14
+
15
+ return !!(id && id.type === 'Identifier' && (id as Identifier).name === variableName);
16
+ });
17
+ }
@@ -0,0 +1,16 @@
1
+ import { type ASTPath, type JSCodeshift, type JSXElement } from 'jscodeshift';
2
+
3
+ import { getJSXAttributeByName } from './get-jsx-attribute-by-name';
4
+ import { getJSXAttributes } from './get-jsx-attributes';
5
+
6
+ export const removeJSXAttributeByName: (
7
+ j: JSCodeshift,
8
+ jsxElementPath: ASTPath<JSXElement>,
9
+ attrName: string,
10
+ ) => void = (j: JSCodeshift, jsxElementPath: ASTPath<JSXElement>, attrName: string) => {
11
+ const attributes = getJSXAttributes(jsxElementPath);
12
+ const attr = getJSXAttributeByName(j, jsxElementPath, attrName);
13
+ if (attr) {
14
+ attributes?.splice(attributes.indexOf(attr), 1);
15
+ }
16
+ };
@@ -0,0 +1,58 @@
1
+ import {
2
+ type ASTPath,
3
+ type Identifier,
4
+ type JSCodeshift,
5
+ type JSXElement,
6
+ type StringLiteral,
7
+ } from 'jscodeshift';
8
+
9
+ import { getJSXAttributeByName } from './get-jsx-attribute-by-name';
10
+ import { getJSXAttributesByName } from './get-jsx-attributes-by-name';
11
+ import { removeJSXAttributeByName } from './remove-jsx-attribute-by-name';
12
+
13
+ export const removeJSXAttributeObjectPropertyByName: (
14
+ j: JSCodeshift,
15
+ jsxElementPath: ASTPath<JSXElement>,
16
+ attrName: string,
17
+ propertyToRemove: string,
18
+ ) => void = (
19
+ j: JSCodeshift,
20
+ jsxElementPath: ASTPath<JSXElement>,
21
+ attrName: string,
22
+ propertyToRemove: string,
23
+ ) => {
24
+ const attr = getJSXAttributeByName(j, jsxElementPath, attrName);
25
+
26
+ if (!attr) {
27
+ return;
28
+ }
29
+
30
+ const attrCollection = getJSXAttributesByName(j, jsxElementPath, attrName);
31
+
32
+ const removeMatchingNodes = (p: ASTPath<Identifier | StringLiteral>) => {
33
+ const name = p.node.type === 'Identifier' ? p.node?.name : p.node?.value;
34
+ // Need to account for quoted properties
35
+ const nameMatches = propertyToRemove.match(new RegExp(`['"]?${name}['"]?`));
36
+ // This will otherwise try to remove values of properties since they are literals
37
+ const isKey = p.parent.value?.type === 'ObjectProperty';
38
+ // Sorry about all the parents. This is the easiest way to get the name
39
+ // of the attribute name. And I always know the depth of the object
40
+ // property here.
41
+ const parentNameMatches = attrName === p.parent.parent.parent.parent.node?.name?.name;
42
+ if (isKey && nameMatches && parentNameMatches) {
43
+ j(p.parent).remove();
44
+ }
45
+ };
46
+
47
+ // Remove all the now migrated object properties
48
+ const objectProperties = attrCollection.find(j.ObjectProperty);
49
+ objectProperties.find(j.Identifier).forEach(removeMatchingNodes);
50
+ objectProperties.find(j.StringLiteral).forEach(removeMatchingNodes);
51
+
52
+ // @ts-ignore -- Property 'expression' does not exist on type 'LiteralKind | JSXElement | JSXExpressionContainer | JSXFragment'. Property 'expression' does not exist on type 'Literal'.
53
+ const attrProperties = attr.value?.expression.properties;
54
+
55
+ if (attrProperties && attrProperties?.length === 0) {
56
+ removeJSXAttributeByName(j, jsxElementPath, attrName);
57
+ }
58
+ };
@@ -3,4 +3,4 @@
3
3
  ._1pfh1b66{margin-block-start:var(--ds-space-050,4px)}
4
4
  ._4cvr1h6o{align-items:center}
5
5
  ._4t3i7vkz{height:1pc}
6
- ._syaze6sf{color:var(--ds-text-danger,#ae2a19)}
6
+ ._syaz1tmw{color:var(--ds-text-danger,#ae2e24)}
@@ -19,7 +19,7 @@ var _fieldIdContext = require("./field-id-context");
19
19
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
20
20
  // Extracted styles for character counter message container
21
21
  var messageContainerStyles = {
22
- root: "_11c8wadc _syaze6sf _1pfh1b66"
22
+ root: "_11c8wadc _syaz1tmw _1pfh1b66"
23
23
  };
24
24
 
25
25
  // Extracted styles for error icon wrapper, need to use css to override the default height
@@ -5,6 +5,6 @@
5
5
  ._1pfh1b66{margin-block-start:var(--ds-space-050,4px)}
6
6
  ._4cvr1h6o{align-items:center}
7
7
  ._4t3i7vkz{height:1pc}
8
- ._syaz1wmz{color:var(--ds-text-subtlest,#6b778c)}
9
- ._syaze6sf{color:var(--ds-text-danger,#ae2a19)}
10
- ._syazy73q{color:var(--ds-text-success,#216e4e)}
8
+ ._syaz1rpy{color:var(--ds-text-subtlest,#6b6e76)}
9
+ ._syaz1tmw{color:var(--ds-text-danger,#ae2e24)}
10
+ ._syazgsak{color:var(--ds-text-success,#4c6b1f)}
@@ -26,9 +26,9 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
26
26
 
27
27
  var messageStyles = null;
28
28
  var messageAppearanceStyles = {
29
- default: "_syaz1wmz",
30
- error: "_syaze6sf",
31
- valid: "_syazy73q"
29
+ default: "_syaz1rpy",
30
+ error: "_syaz1tmw",
31
+ valid: "_syazgsak"
32
32
  };
33
33
  var iconWrapperStyles = {
34
34
  root: "_1e0c1txw _4t3i7vkz _4cvr1h6o"
@@ -1,3 +1,3 @@
1
1
  ._bozgv77o{padding-inline-start:var(--ds-space-025,2px)}
2
2
  ._ect4ttxp{font-family:var(--ds-font-family-body,"Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
3
- ._syaz1ick{color:var(--ds-text-danger,#de350b)}
3
+ ._syaz1tmw{color:var(--ds-text-danger,#ae2e24)}
@@ -15,6 +15,6 @@ function RequiredAsterisk() {
15
15
  return /*#__PURE__*/React.createElement("span", {
16
16
  "aria-hidden": "true",
17
17
  title: "required",
18
- className: (0, _runtime.ax)(["_syaz1ick _ect4ttxp _bozgv77o"])
18
+ className: (0, _runtime.ax)(["_syaz1tmw _ect4ttxp _bozgv77o"])
19
19
  }, "*");
20
20
  }
@@ -3,4 +3,4 @@
3
3
  ._1pfh1b66{margin-block-start:var(--ds-space-050,4px)}
4
4
  ._4cvr1h6o{align-items:center}
5
5
  ._4t3i7vkz{height:1pc}
6
- ._syaze6sf{color:var(--ds-text-danger,#ae2a19)}
6
+ ._syaz1tmw{color:var(--ds-text-danger,#ae2e24)}
@@ -10,7 +10,7 @@ import { FieldId } from './field-id-context';
10
10
 
11
11
  // Extracted styles for character counter message container
12
12
  const messageContainerStyles = {
13
- root: "_11c8wadc _syaze6sf _1pfh1b66"
13
+ root: "_11c8wadc _syaz1tmw _1pfh1b66"
14
14
  };
15
15
 
16
16
  // Extracted styles for error icon wrapper, need to use css to override the default height
@@ -5,6 +5,6 @@
5
5
  ._1pfh1b66{margin-block-start:var(--ds-space-050,4px)}
6
6
  ._4cvr1h6o{align-items:center}
7
7
  ._4t3i7vkz{height:1pc}
8
- ._syaz1wmz{color:var(--ds-text-subtlest,#6b778c)}
9
- ._syaze6sf{color:var(--ds-text-danger,#ae2a19)}
10
- ._syazy73q{color:var(--ds-text-success,#216e4e)}
8
+ ._syaz1rpy{color:var(--ds-text-subtlest,#6b6e76)}
9
+ ._syaz1tmw{color:var(--ds-text-danger,#ae2e24)}
10
+ ._syazgsak{color:var(--ds-text-success,#4c6b1f)}
@@ -17,9 +17,9 @@ import { FieldId } from './field-id-context';
17
17
 
18
18
  const messageStyles = null;
19
19
  const messageAppearanceStyles = {
20
- default: "_syaz1wmz",
21
- error: "_syaze6sf",
22
- valid: "_syazy73q"
20
+ default: "_syaz1rpy",
21
+ error: "_syaz1tmw",
22
+ valid: "_syazgsak"
23
23
  };
24
24
  const iconWrapperStyles = {
25
25
  root: "_1e0c1txw _4t3i7vkz _4cvr1h6o"
@@ -1,3 +1,3 @@
1
1
  ._bozgv77o{padding-inline-start:var(--ds-space-025,2px)}
2
2
  ._ect4ttxp{font-family:var(--ds-font-family-body,"Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
3
- ._syaz1ick{color:var(--ds-text-danger,#de350b)}
3
+ ._syaz1tmw{color:var(--ds-text-danger,#ae2e24)}
@@ -7,6 +7,6 @@ export default function RequiredAsterisk() {
7
7
  return /*#__PURE__*/React.createElement("span", {
8
8
  "aria-hidden": "true",
9
9
  title: "required",
10
- className: ax(["_syaz1ick _ect4ttxp _bozgv77o"])
10
+ className: ax(["_syaz1tmw _ect4ttxp _bozgv77o"])
11
11
  }, "*");
12
12
  }
@@ -3,4 +3,4 @@
3
3
  ._1pfh1b66{margin-block-start:var(--ds-space-050,4px)}
4
4
  ._4cvr1h6o{align-items:center}
5
5
  ._4t3i7vkz{height:1pc}
6
- ._syaze6sf{color:var(--ds-text-danger,#ae2a19)}
6
+ ._syaz1tmw{color:var(--ds-text-danger,#ae2e24)}
@@ -11,7 +11,7 @@ import { FieldId } from './field-id-context';
11
11
 
12
12
  // Extracted styles for character counter message container
13
13
  var messageContainerStyles = {
14
- root: "_11c8wadc _syaze6sf _1pfh1b66"
14
+ root: "_11c8wadc _syaz1tmw _1pfh1b66"
15
15
  };
16
16
 
17
17
  // Extracted styles for error icon wrapper, need to use css to override the default height
@@ -5,6 +5,6 @@
5
5
  ._1pfh1b66{margin-block-start:var(--ds-space-050,4px)}
6
6
  ._4cvr1h6o{align-items:center}
7
7
  ._4t3i7vkz{height:1pc}
8
- ._syaz1wmz{color:var(--ds-text-subtlest,#6b778c)}
9
- ._syaze6sf{color:var(--ds-text-danger,#ae2a19)}
10
- ._syazy73q{color:var(--ds-text-success,#216e4e)}
8
+ ._syaz1rpy{color:var(--ds-text-subtlest,#6b6e76)}
9
+ ._syaz1tmw{color:var(--ds-text-danger,#ae2e24)}
10
+ ._syazgsak{color:var(--ds-text-success,#4c6b1f)}
@@ -18,9 +18,9 @@ import { FieldId } from './field-id-context';
18
18
 
19
19
  var messageStyles = null;
20
20
  var messageAppearanceStyles = {
21
- default: "_syaz1wmz",
22
- error: "_syaze6sf",
23
- valid: "_syazy73q"
21
+ default: "_syaz1rpy",
22
+ error: "_syaz1tmw",
23
+ valid: "_syazgsak"
24
24
  };
25
25
  var iconWrapperStyles = {
26
26
  root: "_1e0c1txw _4t3i7vkz _4cvr1h6o"
@@ -1,3 +1,3 @@
1
1
  ._bozgv77o{padding-inline-start:var(--ds-space-025,2px)}
2
2
  ._ect4ttxp{font-family:var(--ds-font-family-body,"Atlassian Sans",ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}
3
- ._syaz1ick{color:var(--ds-text-danger,#de350b)}
3
+ ._syaz1tmw{color:var(--ds-text-danger,#ae2e24)}
@@ -7,6 +7,6 @@ export default function RequiredAsterisk() {
7
7
  return /*#__PURE__*/React.createElement("span", {
8
8
  "aria-hidden": "true",
9
9
  title: "required",
10
- className: ax(["_syaz1ick _ect4ttxp _bozgv77o"])
10
+ className: ax(["_syaz1tmw _ect4ttxp _bozgv77o"])
11
11
  }, "*");
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/form",
3
- "version": "15.5.1",
3
+ "version": "15.5.3",
4
4
  "description": "A form allows people to input information.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -18,6 +18,13 @@
18
18
  "atlaskit:src": "src/index.tsx",
19
19
  "atlaskit:designLink": "https://atlassian.design/patterns/forms",
20
20
  "atlassian": {
21
+ "react-compiler": {
22
+ "enabled": true,
23
+ "gating": {
24
+ "source": "@atlassian/react-compiler-gating",
25
+ "importSpecifierName": "isReactCompilerActivePlatform"
26
+ }
27
+ },
21
28
  "team": "Design System Team",
22
29
  "website": {
23
30
  "name": "Form",
@@ -56,7 +63,7 @@
56
63
  "@atlaskit/link": "^3.3.0",
57
64
  "@atlaskit/lozenge": "^13.5.0",
58
65
  "@atlaskit/modal-dialog": "^14.14.0",
59
- "@atlaskit/radio": "^8.4.0",
66
+ "@atlaskit/radio": "^8.5.0",
60
67
  "@atlaskit/range": "^10.0.0",
61
68
  "@atlaskit/section-message": "^8.12.0",
62
69
  "@atlaskit/select": "^21.10.0",
@@ -64,6 +71,7 @@
64
71
  "@atlaskit/textfield": "^8.2.0",
65
72
  "@atlaskit/toggle": "^15.2.0",
66
73
  "@atlassian/feature-flags-test-utils": "^1.0.0",
74
+ "@atlassian/react-compiler-gating": "workspace:^",
67
75
  "@atlassian/ssr-tests": "workspace:^",
68
76
  "@atlassian/structured-docs-types": "workspace:^",
69
77
  "@atlassian/testing-library": "^0.5.0",
@@ -1,353 +0,0 @@
1
- import type {
2
- ASTPath,
3
- CallExpression,
4
- default as core,
5
- Identifier,
6
- ImportDeclaration,
7
- ImportDefaultSpecifier,
8
- ImportSpecifier,
9
- JSCodeshift,
10
- JSXAttribute,
11
- JSXElement,
12
- ObjectProperty,
13
- StringLiteral,
14
- } from 'jscodeshift';
15
- import { type Collection } from 'jscodeshift/src/Collection';
16
-
17
- import { addCommentToStartOfFile, getNamedSpecifier } from '@atlaskit/codemod-utils';
18
-
19
- export function hasImportDeclaration(
20
- j: JSCodeshift,
21
- collection: Collection<any>,
22
- importPath: string,
23
- ): boolean {
24
- return getImportDeclarationCollection(j, collection, importPath).length > 0;
25
- }
26
-
27
- export function getImportDeclarationCollection(
28
- j: JSCodeshift,
29
- collection: Collection<any>,
30
- importPath: string,
31
- ): Collection<ImportDeclaration> {
32
- return collection
33
- .find(j.ImportDeclaration)
34
- .filter((importDeclarationPath) => importDeclarationPath.node.source.value === importPath);
35
- }
36
-
37
- export function hasDynamicImport(
38
- j: JSCodeshift,
39
- collection: Collection<any>,
40
- importPath: string,
41
- ): boolean {
42
- return getDynamicImportCollection(j, collection, importPath).length > 0;
43
- }
44
-
45
- export function getDynamicImportCollection(
46
- j: JSCodeshift,
47
- collection: Collection<any>,
48
- importPath: string,
49
- ): Collection<CallExpression> {
50
- return collection.find(j.CallExpression).filter((callExpressionPath) => {
51
- const { callee, arguments: callExpressionArguments } = callExpressionPath.node;
52
-
53
- return !!(
54
- isCallExpressionCalleeImportType(callee) &&
55
- isCallExpressionArgumentStringLiteralType(callExpressionArguments) &&
56
- isCallExpressionArgumentValueMatches(callExpressionArguments[0], j, importPath)
57
- );
58
- });
59
- }
60
- function isCallExpressionCalleeImportType(callee: CallExpression['callee']) {
61
- return callee && callee.type === 'Import';
62
- }
63
- function isCallExpressionArgumentStringLiteralType(
64
- callExpressionArguments: CallExpression['arguments'],
65
- ) {
66
- return (
67
- callExpressionArguments &&
68
- callExpressionArguments.length &&
69
- callExpressionArguments[0].type === 'StringLiteral'
70
- );
71
- }
72
- function isCallExpressionArgumentValueMatches(
73
- callExpressionArgument: CallExpression['arguments'][0],
74
- j: JSCodeshift,
75
- value: string,
76
- ) {
77
- return j(callExpressionArgument).some((path) => path.node.value === value);
78
- }
79
-
80
- export function getImportDefaultSpecifierCollection(
81
- j: JSCodeshift,
82
- importDeclarationCollection: Collection<ImportDeclaration>,
83
- ): Collection<ImportDefaultSpecifier> {
84
- return importDeclarationCollection.find(j.ImportDefaultSpecifier);
85
- }
86
-
87
- export function getImportSpecifierCollection(
88
- j: JSCodeshift,
89
- importDeclarationCollection: Collection<ImportDeclaration>,
90
- importName: string,
91
- ): Collection<ImportSpecifier> {
92
- return importDeclarationCollection
93
- .find(j.ImportSpecifier)
94
- .filter((importSpecifierPath) => importSpecifierPath.node.imported.name === importName);
95
- }
96
-
97
- export function getImportDefaultSpecifierName(
98
- importSpecifierCollection: Collection<ImportDefaultSpecifier>,
99
- ): string | null {
100
- if (importSpecifierCollection.length === 0) {
101
- return null;
102
- }
103
-
104
- return importSpecifierCollection.nodes()[0]!.local!.name;
105
- }
106
-
107
- export function getImportSpecifierName(
108
- importSpecifierCollection: Collection<ImportSpecifier>,
109
- ): string | null {
110
- if (importSpecifierCollection.length === 0) {
111
- return null;
112
- }
113
-
114
- return importSpecifierCollection.nodes()[0]!.local!.name;
115
- }
116
-
117
- export function isVariableDeclaratorIdentifierPresent(
118
- j: JSCodeshift,
119
- collection: Collection<any>,
120
- variableName: string,
121
- ): boolean {
122
- return collection
123
- .find(j.VariableDeclaration)
124
- .find(j.VariableDeclarator)
125
- .some((variableDeclaratorPath) => {
126
- const { id } = variableDeclaratorPath.node;
127
-
128
- return !!(id && id.type === 'Identifier' && (id as Identifier).name === variableName);
129
- });
130
- }
131
-
132
- export function isFunctionDeclarationIdentifierPresent(
133
- j: JSCodeshift,
134
- collection: Collection<any>,
135
- variableName: string,
136
- ): boolean {
137
- return collection.find(j.FunctionDeclaration).some((functionDeclarationPath) => {
138
- const { id } = functionDeclarationPath.node;
139
-
140
- return !!(id && id.type === 'Identifier' && (id as Identifier).name === variableName);
141
- });
142
- }
143
-
144
- export function isClassDeclarationIdentifierPresent(
145
- j: JSCodeshift,
146
- collection: Collection<any>,
147
- variableName: string,
148
- ): boolean {
149
- return collection.find(j.ClassDeclaration).some((classDeclarationPath) => {
150
- const { id } = classDeclarationPath.node;
151
-
152
- return !!(id && id.type === 'Identifier' && (id as Identifier).name === variableName);
153
- });
154
- }
155
-
156
- export function isImportDeclarationIdentifierPresent(
157
- j: JSCodeshift,
158
- collection: Collection<any>,
159
- variableName: string,
160
- ): boolean {
161
- return collection
162
- .find(j.ImportDeclaration)
163
- .find(j.Identifier)
164
- .some((identifierPath) => identifierPath.node.name === variableName);
165
- }
166
-
167
- export function getJSXAttributesByName(
168
- j: JSCodeshift,
169
- jsxElementPath: ASTPath<JSXElement>,
170
- attributeName: string,
171
- ): Collection<JSXAttribute> {
172
- return j(jsxElementPath)
173
- .find(j.JSXOpeningElement)
174
- .find(j.JSXAttribute)
175
- .filter((jsxAttributePath) =>
176
- j(jsxAttributePath)
177
- .find(j.JSXIdentifier)
178
- .some((jsxIdentifierPath) => jsxIdentifierPath.node.name === attributeName),
179
- );
180
- }
181
-
182
- export function getJSXSpreadIdentifierAttributesByName(
183
- j: JSCodeshift,
184
- collection: Collection<any>,
185
- jsxElementPath: ASTPath<JSXElement>,
186
- attributeName: string,
187
- ): Collection<ObjectProperty> | null {
188
- const identifierCollection = j(jsxElementPath)
189
- .find(j.JSXOpeningElement)
190
- .find(j.JSXSpreadAttribute)
191
- .filter((jsxSpreadAttributePath) => jsxSpreadAttributePath.node.argument.type === 'Identifier')
192
- .find(j.Identifier);
193
-
194
- if (identifierCollection.length === 0) {
195
- return null;
196
- }
197
-
198
- return collection
199
- .find(j.VariableDeclarator)
200
- .filter((variableDeclaratorPath) => {
201
- const { id } = variableDeclaratorPath.node;
202
-
203
- return (
204
- id.type === 'Identifier' &&
205
- identifierCollection.some((identifierPath) => identifierPath.node.name === id.name)
206
- );
207
- })
208
- .find(j.ObjectExpression)
209
- .find(j.ObjectProperty)
210
- .filter((objectPropertyPath) =>
211
- j(objectPropertyPath)
212
- .find(j.Identifier)
213
- .some((identifierPath) => identifierPath.node.name === attributeName),
214
- );
215
- }
216
-
217
- export function getJSXSpreadObjectExpressionAttributesByName(
218
- j: JSCodeshift,
219
- jsxElementPath: ASTPath<JSXElement>,
220
- attributeName: string,
221
- ): Collection<ObjectProperty> {
222
- return j(jsxElementPath)
223
- .find(j.JSXOpeningElement)
224
- .find(j.JSXSpreadAttribute)
225
- .find(j.ObjectExpression)
226
- .find(j.ObjectProperty)
227
- .filter((objectPropertyPath) =>
228
- j(objectPropertyPath)
229
- .find(j.Identifier)
230
- .some((identifierPath) => identifierPath.node.name === attributeName),
231
- );
232
- }
233
-
234
- export const createRemoveFuncFor: (
235
- component: string,
236
- importName: string,
237
- prop: string,
238
- comment?: string,
239
- ) => (j: core.JSCodeshift, source: Collection<Node>) => void =
240
- (component: string, importName: string, prop: string, comment?: string) =>
241
- (j: core.JSCodeshift, source: Collection<Node>) => {
242
- const specifier = getNamedSpecifier(j, source, component, importName);
243
-
244
- if (!specifier) {
245
- return;
246
- }
247
-
248
- source.findJSXElements(specifier).forEach((element) => {
249
- getJSXAttributesByName(j, element, prop).forEach((attribute: any) => {
250
- j(attribute).remove();
251
- if (comment) {
252
- addCommentToStartOfFile({ j, base: source, message: comment });
253
- }
254
- });
255
- });
256
- };
257
-
258
- export const getJSXAttributeByName: (
259
- j: JSCodeshift,
260
- jsxElementPath: ASTPath<JSXElement>,
261
- attributeName: string,
262
- ) => JSXAttribute | undefined = (
263
- j: JSCodeshift,
264
- jsxElementPath: ASTPath<JSXElement>,
265
- attributeName: string,
266
- ): JSXAttribute | undefined => {
267
- const attributes: JSXAttribute[] = j(jsxElementPath).find(j.JSXAttribute).nodes();
268
-
269
- return attributes?.find((attr) => attr.name && attr.name.name === attributeName);
270
- };
271
-
272
- export const addJSXAttributeToJSXElement: (
273
- j: JSCodeshift,
274
- jsxElementPath: ASTPath<JSXElement>,
275
- jsxAttribute: JSXAttribute,
276
- limit?: number,
277
- ) => void = (
278
- j: JSCodeshift,
279
- jsxElementPath: ASTPath<JSXElement>,
280
- jsxAttribute: JSXAttribute,
281
- limit?: number,
282
- ) => {
283
- j(jsxElementPath)
284
- .find(j.JSXOpeningElement)
285
- .forEach((openingElement, i) => {
286
- if (!limit || i < limit) {
287
- openingElement.node.attributes?.push(jsxAttribute);
288
- }
289
- });
290
- };
291
-
292
- export const removeJSXAttributeByName: (
293
- j: JSCodeshift,
294
- jsxElementPath: ASTPath<JSXElement>,
295
- attrName: string,
296
- ) => void = (j: JSCodeshift, jsxElementPath: ASTPath<JSXElement>, attrName: string) => {
297
- const attributes = getJSXAttributes(jsxElementPath);
298
- const attr = getJSXAttributeByName(j, jsxElementPath, attrName);
299
- if (attr) {
300
- attributes?.splice(attributes.indexOf(attr), 1);
301
- }
302
- };
303
-
304
- export const getJSXAttributes: (jsxElementPath: ASTPath<JSXElement>) => JSXAttribute[] = (
305
- jsxElementPath: ASTPath<JSXElement>,
306
- ) => jsxElementPath.node.openingElement.attributes as JSXAttribute[];
307
-
308
- export const removeJSXAttributeObjectPropertyByName: (
309
- j: JSCodeshift,
310
- jsxElementPath: ASTPath<JSXElement>,
311
- attrName: string,
312
- propertyToRemove: string,
313
- ) => void = (
314
- j: JSCodeshift,
315
- jsxElementPath: ASTPath<JSXElement>,
316
- attrName: string,
317
- propertyToRemove: string,
318
- ) => {
319
- const attr = getJSXAttributeByName(j, jsxElementPath, attrName);
320
-
321
- if (!attr) {
322
- return;
323
- }
324
-
325
- const attrCollection = getJSXAttributesByName(j, jsxElementPath, attrName);
326
-
327
- const removeMatchingNodes = (p: ASTPath<Identifier | StringLiteral>) => {
328
- const name = p.node.type === 'Identifier' ? p.node?.name : p.node?.value;
329
- // Need to account for quoted properties
330
- const nameMatches = propertyToRemove.match(new RegExp(`['"]?${name}['"]?`));
331
- // This will otherwise try to remove values of properties since they are literals
332
- const isKey = p.parent.value?.type === 'ObjectProperty';
333
- // Sorry about all the parents. This is the easiest way to get the name
334
- // of the attribute name. And I always know the depth of the object
335
- // property here.
336
- const parentNameMatches = attrName === p.parent.parent.parent.parent.node?.name?.name;
337
- if (isKey && nameMatches && parentNameMatches) {
338
- j(p.parent).remove();
339
- }
340
- };
341
-
342
- // Remove all the now migrated object properties
343
- const objectProperties = attrCollection.find(j.ObjectProperty);
344
- objectProperties.find(j.Identifier).forEach(removeMatchingNodes);
345
- objectProperties.find(j.StringLiteral).forEach(removeMatchingNodes);
346
-
347
- // @ts-ignore -- Property 'expression' does not exist on type 'LiteralKind | JSXElement | JSXExpressionContainer | JSXFragment'. Property 'expression' does not exist on type 'Literal'.
348
- const attrProperties = attr.value?.expression.properties;
349
-
350
- if (attrProperties && attrProperties?.length === 0) {
351
- removeJSXAttributeByName(j, jsxElementPath, attrName);
352
- }
353
- };