@atlaskit/datetime-picker 17.6.1 → 17.6.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.
- package/CHANGELOG.md +17 -0
- package/codemods/14.0.0-remove-duplicate-and-unused-props.tsx +18 -61
- package/codemods/__tests__/next-remove-duplicate-and-unused-props.tsx +6 -6
- package/codemods/utils/add-jsx-attribute-to-jsx-element.tsx +13 -0
- package/codemods/utils/create-remove-func-for.tsx +30 -0
- package/codemods/utils/dtp-props-to-move-into-picker-props.tsx +23 -0
- package/codemods/utils/get-dynamic-import-collection.tsx +40 -0
- package/codemods/utils/get-import-declaration-collection.tsx +12 -0
- package/codemods/utils/get-import-specifier-collection.tsx +12 -0
- package/codemods/utils/get-import-specifier-name.tsx +12 -0
- package/codemods/utils/get-jsx-attribute-by-name.tsx +15 -0
- package/codemods/utils/get-jsx-attributes-by-name.tsx +17 -0
- package/codemods/utils/get-jsx-attributes.tsx +5 -0
- package/codemods/utils/get-jsx-spread-identifier-attributes-by-name.tsx +37 -0
- package/codemods/utils/get-jsx-spread-object-expression-attributes-by-name.tsx +19 -0
- package/codemods/utils/has-dynamic-import.tsx +12 -0
- package/codemods/utils/has-import-declaration.tsx +12 -0
- package/codemods/utils/is-class-declaration-identifier-present.tsx +14 -0
- package/codemods/utils/is-function-declaration-identifier-present.tsx +14 -0
- package/codemods/utils/is-import-declaration-identifier-present.tsx +13 -0
- package/codemods/utils/is-variable-declarator-identifier-present.tsx +17 -0
- package/codemods/utils/remove-jsx-attribute-by-name.tsx +16 -0
- package/codemods/utils/remove-jsx-attribute-object-property-by-name.tsx +58 -0
- package/codemods/utils/select-props-to-move-into-props.tsx +23 -0
- package/dist/cjs/components/date-picker.js +2 -2
- package/dist/cjs/components/date-time-picker-class.js +1 -1
- package/dist/cjs/components/date-time-picker-fc-new.js +1 -1
- package/dist/cjs/components/date-time-picker-fc-old.js +1 -1
- package/dist/cjs/components/time-picker.js +1 -1
- package/dist/cjs/internal/date-time-picker-container.compiled.css +0 -1
- package/dist/cjs/internal/date-time-picker-container.js +1 -1
- package/dist/es2019/components/date-picker.js +2 -2
- package/dist/es2019/components/date-time-picker-class.js +1 -1
- package/dist/es2019/components/date-time-picker-fc-new.js +1 -1
- package/dist/es2019/components/date-time-picker-fc-old.js +1 -1
- package/dist/es2019/components/time-picker.js +1 -1
- package/dist/es2019/internal/date-time-picker-container.compiled.css +0 -1
- package/dist/es2019/internal/date-time-picker-container.js +1 -1
- package/dist/esm/components/date-picker.js +2 -2
- package/dist/esm/components/date-time-picker-class.js +1 -1
- package/dist/esm/components/date-time-picker-fc-new.js +1 -1
- package/dist/esm/components/date-time-picker-fc-old.js +1 -1
- package/dist/esm/components/time-picker.js +1 -1
- package/dist/esm/internal/date-time-picker-container.compiled.css +0 -1
- package/dist/esm/internal/date-time-picker-container.js +1 -1
- package/package.json +9 -1
- package/codemods/utils/helpers.tsx +0 -327
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/datetime-picker
|
|
2
2
|
|
|
3
|
+
## 17.6.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
|
+
## 17.6.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
|
## 17.6.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -1,78 +1,35 @@
|
|
|
1
1
|
import { type API, type FileInfo, type JSCodeshift, type Options } from 'jscodeshift';
|
|
2
2
|
import { type Collection } from 'jscodeshift/src/Collection';
|
|
3
3
|
|
|
4
|
+
import { addJSXAttributeToJSXElement } from './utils/add-jsx-attribute-to-jsx-element';
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from './utils/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type FromPickerFormula = {
|
|
22
|
-
source: string[];
|
|
23
|
-
newPropName: string;
|
|
24
|
-
};
|
|
6
|
+
dtpPropsToMoveIntoPickerProps,
|
|
7
|
+
type ToPickerFormula,
|
|
8
|
+
} from './utils/dtp-props-to-move-into-picker-props';
|
|
9
|
+
import { getImportDeclarationCollection } from './utils/get-import-declaration-collection';
|
|
10
|
+
import { getImportSpecifierCollection } from './utils/get-import-specifier-collection';
|
|
11
|
+
import { getImportSpecifierName } from './utils/get-import-specifier-name';
|
|
12
|
+
import { getJSXAttributeByName } from './utils/get-jsx-attribute-by-name';
|
|
13
|
+
import { getJSXAttributesByName } from './utils/get-jsx-attributes-by-name';
|
|
14
|
+
import { hasImportDeclaration } from './utils/has-import-declaration';
|
|
15
|
+
import { removeJSXAttributeByName } from './utils/remove-jsx-attribute-by-name';
|
|
16
|
+
import { removeJSXAttributeObjectPropertyByName } from './utils/remove-jsx-attribute-object-property-by-name';
|
|
17
|
+
import {
|
|
18
|
+
type FromPickerFormula,
|
|
19
|
+
selectPropsToMoveIntoProps,
|
|
20
|
+
} from './utils/select-props-to-move-into-props';
|
|
25
21
|
|
|
26
22
|
const importPath = '@atlaskit/datetime-picker';
|
|
27
23
|
|
|
28
24
|
const dateTimePickerImportName = 'DateTimePicker';
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
const datePickerImportName = 'DatePicker';
|
|
26
|
+
const timePickerImportName = 'TimePicker';
|
|
31
27
|
|
|
32
28
|
const pickerAndSelectPropNames = [
|
|
33
29
|
['datePickerSelectProps', 'datePickerProps'],
|
|
34
30
|
['timePickerSelectProps', 'timePickerProps'],
|
|
35
31
|
];
|
|
36
32
|
|
|
37
|
-
export const dtpPropsToMoveIntoPickerProps: ToPickerFormula[] = [
|
|
38
|
-
{
|
|
39
|
-
oldPropName: 'dateFormat',
|
|
40
|
-
destination: ['datePickerProps', 'dateFormat'],
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
oldPropName: 'times',
|
|
44
|
-
destination: ['timePickerProps', 'times'],
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
oldPropName: 'timeFormat',
|
|
48
|
-
destination: ['timePickerProps', 'timeFormat'],
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
oldPropName: 'timeIsEditable',
|
|
52
|
-
destination: ['timePickerProps', 'timeIsEditable'],
|
|
53
|
-
},
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
// For the pickers, not for DTP
|
|
57
|
-
export const selectPropsToMoveIntoProps: FromPickerFormula[] = [
|
|
58
|
-
{
|
|
59
|
-
source: ['selectProps', 'aria-describedby'],
|
|
60
|
-
newPropName: 'aria-describedby',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
source: ['selectProps', 'aria-label'],
|
|
64
|
-
newPropName: 'label',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
source: ['selectProps', 'inputId'],
|
|
68
|
-
newPropName: 'id',
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
source: ['selectProps', 'placeholder'],
|
|
72
|
-
newPropName: 'placeholder',
|
|
73
|
-
},
|
|
74
|
-
];
|
|
75
|
-
|
|
76
33
|
/**
|
|
77
34
|
* Move *pickerSelectProps into their respectice *pickerProps as a property
|
|
78
35
|
* named `selectProps`.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
jest.autoMockOff();
|
|
2
2
|
|
|
3
|
-
import transformer
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
selectPropsToMoveIntoProps,
|
|
7
|
-
timePickerImportName,
|
|
8
|
-
} from '../14.0.0-remove-duplicate-and-unused-props';
|
|
3
|
+
import transformer from '../14.0.0-remove-duplicate-and-unused-props';
|
|
4
|
+
import { dtpPropsToMoveIntoPickerProps } from '../utils/dtp-props-to-move-into-picker-props';
|
|
5
|
+
import { selectPropsToMoveIntoProps } from '../utils/select-props-to-move-into-props';
|
|
9
6
|
|
|
10
7
|
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
11
8
|
|
|
9
|
+
const datePickerImportName = 'DatePicker';
|
|
10
|
+
const timePickerImportName = 'TimePicker';
|
|
11
|
+
|
|
12
12
|
defineInlineTest(
|
|
13
13
|
{ default: transformer, parser: 'tsx' },
|
|
14
14
|
{},
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
) => void = (j: JSCodeshift, jsxElementPath: ASTPath<JSXElement>, jsxAttribute: JSXAttribute) => {
|
|
8
|
+
j(jsxElementPath)
|
|
9
|
+
.find(j.JSXOpeningElement)
|
|
10
|
+
.forEach((openingElement) => {
|
|
11
|
+
openingElement.node.attributes?.push(jsxAttribute);
|
|
12
|
+
});
|
|
13
|
+
};
|
|
@@ -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,23 @@
|
|
|
1
|
+
export type ToPickerFormula = {
|
|
2
|
+
oldPropName: string;
|
|
3
|
+
destination: string[];
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export const dtpPropsToMoveIntoPickerProps: ToPickerFormula[] = [
|
|
7
|
+
{
|
|
8
|
+
oldPropName: 'dateFormat',
|
|
9
|
+
destination: ['datePickerProps', 'dateFormat'],
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
oldPropName: 'times',
|
|
13
|
+
destination: ['timePickerProps', 'times'],
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
oldPropName: 'timeFormat',
|
|
17
|
+
destination: ['timePickerProps', 'timeFormat'],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
oldPropName: 'timeIsEditable',
|
|
21
|
+
destination: ['timePickerProps', 'timeIsEditable'],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
@@ -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,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
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type FromPickerFormula = {
|
|
2
|
+
source: string[];
|
|
3
|
+
newPropName: string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export const selectPropsToMoveIntoProps: FromPickerFormula[] = [
|
|
7
|
+
{
|
|
8
|
+
source: ['selectProps', 'aria-describedby'],
|
|
9
|
+
newPropName: 'aria-describedby',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
source: ['selectProps', 'aria-label'],
|
|
13
|
+
newPropName: 'label',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
source: ['selectProps', 'inputId'],
|
|
17
|
+
newPropName: 'id',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
source: ['selectProps', 'placeholder'],
|
|
21
|
+
newPropName: 'placeholder',
|
|
22
|
+
},
|
|
23
|
+
];
|
|
@@ -37,7 +37,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
37
37
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
38
38
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
39
39
|
var packageName = "@atlaskit/datetime-picker";
|
|
40
|
-
var packageVersion = "
|
|
40
|
+
var packageVersion = "0.0.0-development";
|
|
41
41
|
var styles = {
|
|
42
42
|
pickerContainerStyle: "_kqswh2mm",
|
|
43
43
|
dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o",
|
|
@@ -477,7 +477,7 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, _forwarded
|
|
|
477
477
|
selectStyles = _selectProps$styles === void 0 ? {} : _selectProps$styles;
|
|
478
478
|
var disabledStyle = isDisabled ? {
|
|
479
479
|
pointerEvents: 'none',
|
|
480
|
-
color: "var(--ds-icon-disabled,
|
|
480
|
+
color: "var(--ds-icon-disabled, #080F214A)"
|
|
481
481
|
} : {};
|
|
482
482
|
var calendarProps = {
|
|
483
483
|
calendarContainerRef: containerRef.current,
|
|
@@ -30,7 +30,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
30
30
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /// <reference types="node" />
|
|
31
31
|
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
32
32
|
var packageName = "@atlaskit/datetime-picker";
|
|
33
|
-
var packageVersion = "
|
|
33
|
+
var packageVersion = "0.0.0-development";
|
|
34
34
|
var compiledStyles = {
|
|
35
35
|
datePickerContainerStyles: "_i0dl1ssb _16jlkb7n _1o9zidpf",
|
|
36
36
|
timePickerContainerStyles: "_i0dl1ssb _16jlkb7n",
|
|
@@ -33,7 +33,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
33
33
|
// for typing `process`
|
|
34
34
|
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
35
35
|
var packageName = "@atlaskit/datetime-picker";
|
|
36
|
-
var packageVersion = "
|
|
36
|
+
var packageVersion = "0.0.0-development";
|
|
37
37
|
var analyticsAttributes = {
|
|
38
38
|
componentName: 'dateTimePicker',
|
|
39
39
|
packageName: packageName,
|
|
@@ -33,7 +33,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
33
33
|
// for typing `process`
|
|
34
34
|
// oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
35
35
|
var packageName = "@atlaskit/datetime-picker";
|
|
36
|
-
var packageVersion = "
|
|
36
|
+
var packageVersion = "0.0.0-development";
|
|
37
37
|
var analyticsAttributes = {
|
|
38
38
|
componentName: 'dateTimePicker',
|
|
39
39
|
packageName: packageName,
|
|
@@ -26,7 +26,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
26
26
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
27
27
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // oxlint-disable-next-line @atlassian/no-restricted-imports
|
|
28
28
|
var packageName = "@atlaskit/datetime-picker";
|
|
29
|
-
var packageVersion = "
|
|
29
|
+
var packageVersion = "0.0.0-development";
|
|
30
30
|
var menuStyles = {
|
|
31
31
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
32
32
|
position: 'static',
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
._1e0c1txw{display:flex}
|
|
11
11
|
._bfhk1j28{background-color:transparent}
|
|
12
12
|
._bfhk1j9a{background-color:var(--ds-background-input,#fff)}
|
|
13
|
-
._bfhk1y3p{background-color:var(--ds-background-input-pressed,transparent)}
|
|
14
13
|
._bfhkby5v{background-color:var(--ds-background-disabled,#17171708)}
|
|
15
14
|
._bfhkr01l{background-color:var(--ds-background-input-pressed,#fff)}
|
|
16
15
|
._4cvx1bqt:hover{border-color:var(--ds-border-danger,#e2483d)}
|
|
@@ -44,6 +44,6 @@ var DateTimePickerContainer = exports.DateTimePickerContainer = /*#__PURE__*/(0,
|
|
|
44
44
|
return /*#__PURE__*/React.createElement("div", (0, _extends2.default)({}, innerProps, {
|
|
45
45
|
"data-testid": testId,
|
|
46
46
|
ref: ref,
|
|
47
|
-
className: (0, _runtime.ax)(["_2rko12b0 _v564r5cv _1e0c1txw _bfhk1j9a _d0altlke", (0, _platformFeatureFlags.fg)('platform-dst-shape-theme-default') && "_2rko1qi0", "_19itno8c", isDisabled && "_1h6dbk0g _bfhkby5v _d0al73ad", isFocused && "_bfhkr01l", appearance === 'subtle' && isFocused && "_1h6d1j28
|
|
47
|
+
className: (0, _runtime.ax)(["_2rko12b0 _v564r5cv _1e0c1txw _bfhk1j9a _d0altlke", (0, _platformFeatureFlags.fg)('platform-dst-shape-theme-default') && "_2rko1qi0", "_19itno8c", isDisabled && "_1h6dbk0g _bfhkby5v _d0al73ad", isFocused && "_bfhkr01l", appearance === 'subtle' && isFocused && "_1h6d1j28 _bfhkr01l", appearance === 'subtle' && !isFocused && "_1h6d1j28 _bfhk1j28", isFocused && "_1h6d1v1w _16qsvyy1", isInvalid && "_1h6d1bqt", notFocusedOrIsDisabled && isInvalid && "_4cvx1bqt _irr3l4ek", notFocusedOrIsDisabled && !isInvalid && "_4cvxrsbi _irr3l4ek", appearance === 'none' && "_1h6d1j28 _bfhk1j28 _4cvx1j28 _irr31j28"])
|
|
48
48
|
}), children);
|
|
49
49
|
});
|
|
@@ -24,7 +24,7 @@ import { Menu } from '../internal/menu';
|
|
|
24
24
|
import { getSafeCalendarValue, getShortISOString } from '../internal/parse-date';
|
|
25
25
|
import { makeSingleValue } from '../internal/single-value';
|
|
26
26
|
const packageName = "@atlaskit/datetime-picker";
|
|
27
|
-
const packageVersion = "
|
|
27
|
+
const packageVersion = "0.0.0-development";
|
|
28
28
|
const styles = {
|
|
29
29
|
pickerContainerStyle: "_kqswh2mm",
|
|
30
30
|
dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o",
|
|
@@ -405,7 +405,7 @@ const DatePicker = /*#__PURE__*/forwardRef((props, _forwardedRef) => {
|
|
|
405
405
|
} = selectProps;
|
|
406
406
|
const disabledStyle = isDisabled ? {
|
|
407
407
|
pointerEvents: 'none',
|
|
408
|
-
color: "var(--ds-icon-disabled,
|
|
408
|
+
color: "var(--ds-icon-disabled, #080F214A)"
|
|
409
409
|
} : {};
|
|
410
410
|
const calendarProps = {
|
|
411
411
|
calendarContainerRef: containerRef.current,
|
|
@@ -16,7 +16,7 @@ import { convertTokens } from '../internal/parse-tokens';
|
|
|
16
16
|
import DatePicker from './date-picker';
|
|
17
17
|
import TimePicker from './time-picker';
|
|
18
18
|
const packageName = "@atlaskit/datetime-picker";
|
|
19
|
-
const packageVersion = "
|
|
19
|
+
const packageVersion = "0.0.0-development";
|
|
20
20
|
const compiledStyles = {
|
|
21
21
|
datePickerContainerStyles: "_i0dl1ssb _16jlkb7n _1o9zidpf",
|
|
22
22
|
timePickerContainerStyles: "_i0dl1ssb _16jlkb7n",
|
|
@@ -20,7 +20,7 @@ import { convertTokens } from '../internal/parse-tokens';
|
|
|
20
20
|
import DatePicker from './date-picker';
|
|
21
21
|
import TimePicker from './time-picker';
|
|
22
22
|
const packageName = "@atlaskit/datetime-picker";
|
|
23
|
-
const packageVersion = "
|
|
23
|
+
const packageVersion = "0.0.0-development";
|
|
24
24
|
const analyticsAttributes = {
|
|
25
25
|
componentName: 'dateTimePicker',
|
|
26
26
|
packageName,
|
|
@@ -20,7 +20,7 @@ import { convertTokens } from '../internal/parse-tokens';
|
|
|
20
20
|
import DatePicker from './date-picker';
|
|
21
21
|
import TimePicker from './time-picker';
|
|
22
22
|
const packageName = "@atlaskit/datetime-picker";
|
|
23
|
-
const packageVersion = "
|
|
23
|
+
const packageVersion = "0.0.0-development";
|
|
24
24
|
const analyticsAttributes = {
|
|
25
25
|
componentName: 'dateTimePicker',
|
|
26
26
|
packageName,
|
|
@@ -13,7 +13,7 @@ import parseTime from '../internal/parse-time';
|
|
|
13
13
|
import { convertTokens } from '../internal/parse-tokens';
|
|
14
14
|
import { makeSingleValue } from '../internal/single-value';
|
|
15
15
|
const packageName = "@atlaskit/datetime-picker";
|
|
16
|
-
const packageVersion = "
|
|
16
|
+
const packageVersion = "0.0.0-development";
|
|
17
17
|
const menuStyles = {
|
|
18
18
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
19
19
|
position: 'static',
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
._1e0c1txw{display:flex}
|
|
11
11
|
._bfhk1j28{background-color:transparent}
|
|
12
12
|
._bfhk1j9a{background-color:var(--ds-background-input,#fff)}
|
|
13
|
-
._bfhk1y3p{background-color:var(--ds-background-input-pressed,transparent)}
|
|
14
13
|
._bfhkby5v{background-color:var(--ds-background-disabled,#17171708)}
|
|
15
14
|
._bfhkr01l{background-color:var(--ds-background-input-pressed,#fff)}
|
|
16
15
|
._4cvx1bqt:hover{border-color:var(--ds-border-danger,#e2483d)}
|
|
@@ -36,6 +36,6 @@ export const DateTimePickerContainer = /*#__PURE__*/forwardRef(({
|
|
|
36
36
|
return /*#__PURE__*/React.createElement("div", _extends({}, innerProps, {
|
|
37
37
|
"data-testid": testId,
|
|
38
38
|
ref: ref,
|
|
39
|
-
className: ax(["_2rko12b0 _v564r5cv _1e0c1txw _bfhk1j9a _d0altlke", fg('platform-dst-shape-theme-default') && "_2rko1qi0", "_19itno8c", isDisabled && "_1h6dbk0g _bfhkby5v _d0al73ad", isFocused && "_bfhkr01l", appearance === 'subtle' && isFocused && "_1h6d1j28
|
|
39
|
+
className: ax(["_2rko12b0 _v564r5cv _1e0c1txw _bfhk1j9a _d0altlke", fg('platform-dst-shape-theme-default') && "_2rko1qi0", "_19itno8c", isDisabled && "_1h6dbk0g _bfhkby5v _d0al73ad", isFocused && "_bfhkr01l", appearance === 'subtle' && isFocused && "_1h6d1j28 _bfhkr01l", appearance === 'subtle' && !isFocused && "_1h6d1j28 _bfhk1j28", isFocused && "_1h6d1v1w _16qsvyy1", isInvalid && "_1h6d1bqt", notFocusedOrIsDisabled && isInvalid && "_4cvx1bqt _irr3l4ek", notFocusedOrIsDisabled && !isInvalid && "_4cvxrsbi _irr3l4ek", appearance === 'none' && "_1h6d1j28 _bfhk1j28 _4cvx1j28 _irr31j28"])
|
|
40
40
|
}), children);
|
|
41
41
|
});
|
|
@@ -30,7 +30,7 @@ import { Menu } from '../internal/menu';
|
|
|
30
30
|
import { getSafeCalendarValue, getShortISOString } from '../internal/parse-date';
|
|
31
31
|
import { makeSingleValue } from '../internal/single-value';
|
|
32
32
|
var packageName = "@atlaskit/datetime-picker";
|
|
33
|
-
var packageVersion = "
|
|
33
|
+
var packageVersion = "0.0.0-development";
|
|
34
34
|
var styles = {
|
|
35
35
|
pickerContainerStyle: "_kqswh2mm",
|
|
36
36
|
dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o",
|
|
@@ -470,7 +470,7 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, _forwardedRef) {
|
|
|
470
470
|
selectStyles = _selectProps$styles === void 0 ? {} : _selectProps$styles;
|
|
471
471
|
var disabledStyle = isDisabled ? {
|
|
472
472
|
pointerEvents: 'none',
|
|
473
|
-
color: "var(--ds-icon-disabled,
|
|
473
|
+
color: "var(--ds-icon-disabled, #080F214A)"
|
|
474
474
|
} : {};
|
|
475
475
|
var calendarProps = {
|
|
476
476
|
calendarContainerRef: containerRef.current,
|
|
@@ -25,7 +25,7 @@ import { convertTokens } from '../internal/parse-tokens';
|
|
|
25
25
|
import DatePicker from './date-picker';
|
|
26
26
|
import TimePicker from './time-picker';
|
|
27
27
|
var packageName = "@atlaskit/datetime-picker";
|
|
28
|
-
var packageVersion = "
|
|
28
|
+
var packageVersion = "0.0.0-development";
|
|
29
29
|
var compiledStyles = {
|
|
30
30
|
datePickerContainerStyles: "_i0dl1ssb _16jlkb7n _1o9zidpf",
|
|
31
31
|
timePickerContainerStyles: "_i0dl1ssb _16jlkb7n",
|
|
@@ -27,7 +27,7 @@ import { convertTokens } from '../internal/parse-tokens';
|
|
|
27
27
|
import DatePicker from './date-picker';
|
|
28
28
|
import TimePicker from './time-picker';
|
|
29
29
|
var packageName = "@atlaskit/datetime-picker";
|
|
30
|
-
var packageVersion = "
|
|
30
|
+
var packageVersion = "0.0.0-development";
|
|
31
31
|
var analyticsAttributes = {
|
|
32
32
|
componentName: 'dateTimePicker',
|
|
33
33
|
packageName: packageName,
|
|
@@ -27,7 +27,7 @@ import { convertTokens } from '../internal/parse-tokens';
|
|
|
27
27
|
import DatePicker from './date-picker';
|
|
28
28
|
import TimePicker from './time-picker';
|
|
29
29
|
var packageName = "@atlaskit/datetime-picker";
|
|
30
|
-
var packageVersion = "
|
|
30
|
+
var packageVersion = "0.0.0-development";
|
|
31
31
|
var analyticsAttributes = {
|
|
32
32
|
componentName: 'dateTimePicker',
|
|
33
33
|
packageName: packageName,
|
|
@@ -19,7 +19,7 @@ import parseTime from '../internal/parse-time';
|
|
|
19
19
|
import { convertTokens } from '../internal/parse-tokens';
|
|
20
20
|
import { makeSingleValue } from '../internal/single-value';
|
|
21
21
|
var packageName = "@atlaskit/datetime-picker";
|
|
22
|
-
var packageVersion = "
|
|
22
|
+
var packageVersion = "0.0.0-development";
|
|
23
23
|
var menuStyles = {
|
|
24
24
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
25
25
|
position: 'static',
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
._1e0c1txw{display:flex}
|
|
11
11
|
._bfhk1j28{background-color:transparent}
|
|
12
12
|
._bfhk1j9a{background-color:var(--ds-background-input,#fff)}
|
|
13
|
-
._bfhk1y3p{background-color:var(--ds-background-input-pressed,transparent)}
|
|
14
13
|
._bfhkby5v{background-color:var(--ds-background-disabled,#17171708)}
|
|
15
14
|
._bfhkr01l{background-color:var(--ds-background-input-pressed,#fff)}
|
|
16
15
|
._4cvx1bqt:hover{border-color:var(--ds-border-danger,#e2483d)}
|
|
@@ -35,6 +35,6 @@ export var DateTimePickerContainer = /*#__PURE__*/forwardRef(function (_ref, ref
|
|
|
35
35
|
return /*#__PURE__*/React.createElement("div", _extends({}, innerProps, {
|
|
36
36
|
"data-testid": testId,
|
|
37
37
|
ref: ref,
|
|
38
|
-
className: ax(["_2rko12b0 _v564r5cv _1e0c1txw _bfhk1j9a _d0altlke", fg('platform-dst-shape-theme-default') && "_2rko1qi0", "_19itno8c", isDisabled && "_1h6dbk0g _bfhkby5v _d0al73ad", isFocused && "_bfhkr01l", appearance === 'subtle' && isFocused && "_1h6d1j28
|
|
38
|
+
className: ax(["_2rko12b0 _v564r5cv _1e0c1txw _bfhk1j9a _d0altlke", fg('platform-dst-shape-theme-default') && "_2rko1qi0", "_19itno8c", isDisabled && "_1h6dbk0g _bfhkby5v _d0al73ad", isFocused && "_bfhkr01l", appearance === 'subtle' && isFocused && "_1h6d1j28 _bfhkr01l", appearance === 'subtle' && !isFocused && "_1h6d1j28 _bfhk1j28", isFocused && "_1h6d1v1w _16qsvyy1", isInvalid && "_1h6d1bqt", notFocusedOrIsDisabled && isInvalid && "_4cvx1bqt _irr3l4ek", notFocusedOrIsDisabled && !isInvalid && "_4cvxrsbi _irr3l4ek", appearance === 'none' && "_1h6d1j28 _bfhk1j28 _4cvx1j28 _irr31j28"])
|
|
39
39
|
}), children);
|
|
40
40
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/datetime-picker",
|
|
3
|
-
"version": "17.6.
|
|
3
|
+
"version": "17.6.3",
|
|
4
4
|
"description": "A date time picker allows the user to select an associated date and time.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -25,6 +25,13 @@
|
|
|
25
25
|
],
|
|
26
26
|
"atlaskit:src": "src/index.tsx",
|
|
27
27
|
"atlassian": {
|
|
28
|
+
"react-compiler": {
|
|
29
|
+
"enabled": true,
|
|
30
|
+
"gating": {
|
|
31
|
+
"source": "@atlassian/react-compiler-gating",
|
|
32
|
+
"importSpecifierName": "isReactCompilerActivePlatform"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
28
35
|
"team": "Design System Team",
|
|
29
36
|
"website": {
|
|
30
37
|
"name": "Date time picker",
|
|
@@ -69,6 +76,7 @@
|
|
|
69
76
|
"@atlaskit/textfield": "^8.2.0",
|
|
70
77
|
"@atlaskit/toggle": "^15.2.0",
|
|
71
78
|
"@atlassian/feature-flags-test-utils": "^1.0.0",
|
|
79
|
+
"@atlassian/react-compiler-gating": "workspace:^",
|
|
72
80
|
"@atlassian/ssr-tests": "workspace:^",
|
|
73
81
|
"@atlassian/structured-docs-types": "workspace:^",
|
|
74
82
|
"@testing-library/react": "^16.3.0",
|
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ASTPath,
|
|
3
|
-
CallExpression,
|
|
4
|
-
default as core,
|
|
5
|
-
Identifier,
|
|
6
|
-
ImportDeclaration,
|
|
7
|
-
ImportSpecifier,
|
|
8
|
-
JSCodeshift,
|
|
9
|
-
JSXAttribute,
|
|
10
|
-
JSXElement,
|
|
11
|
-
ObjectProperty,
|
|
12
|
-
StringLiteral,
|
|
13
|
-
} from 'jscodeshift';
|
|
14
|
-
import { type Collection } from 'jscodeshift/src/Collection';
|
|
15
|
-
|
|
16
|
-
import { addCommentToStartOfFile, getNamedSpecifier } from '@atlaskit/codemod-utils';
|
|
17
|
-
|
|
18
|
-
export function hasImportDeclaration(
|
|
19
|
-
j: JSCodeshift,
|
|
20
|
-
collection: Collection<any>,
|
|
21
|
-
importPath: string,
|
|
22
|
-
): boolean {
|
|
23
|
-
return getImportDeclarationCollection(j, collection, importPath).length > 0;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function getImportDeclarationCollection(
|
|
27
|
-
j: JSCodeshift,
|
|
28
|
-
collection: Collection<any>,
|
|
29
|
-
importPath: string,
|
|
30
|
-
): Collection<ImportDeclaration> {
|
|
31
|
-
return collection
|
|
32
|
-
.find(j.ImportDeclaration)
|
|
33
|
-
.filter((importDeclarationPath) => importDeclarationPath.node.source.value === importPath);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function hasDynamicImport(
|
|
37
|
-
j: JSCodeshift,
|
|
38
|
-
collection: Collection<any>,
|
|
39
|
-
importPath: string,
|
|
40
|
-
): boolean {
|
|
41
|
-
return getDynamicImportCollection(j, collection, importPath).length > 0;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getDynamicImportCollection(
|
|
45
|
-
j: JSCodeshift,
|
|
46
|
-
collection: Collection<any>,
|
|
47
|
-
importPath: string,
|
|
48
|
-
): Collection<CallExpression> {
|
|
49
|
-
return collection.find(j.CallExpression).filter((callExpressionPath) => {
|
|
50
|
-
const { callee, arguments: callExpressionArguments } = callExpressionPath.node;
|
|
51
|
-
|
|
52
|
-
return !!(
|
|
53
|
-
isCallExpressionCalleeImportType(callee) &&
|
|
54
|
-
isCallExpressionArgumentStringLiteralType(callExpressionArguments) &&
|
|
55
|
-
isCallExpressionArgumentValueMatches(callExpressionArguments[0], j, importPath)
|
|
56
|
-
);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function isCallExpressionCalleeImportType(callee: CallExpression['callee']) {
|
|
60
|
-
return callee && callee.type === 'Import';
|
|
61
|
-
}
|
|
62
|
-
function isCallExpressionArgumentStringLiteralType(
|
|
63
|
-
callExpressionArguments: CallExpression['arguments'],
|
|
64
|
-
) {
|
|
65
|
-
return (
|
|
66
|
-
callExpressionArguments &&
|
|
67
|
-
callExpressionArguments.length &&
|
|
68
|
-
callExpressionArguments[0].type === 'StringLiteral'
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
function isCallExpressionArgumentValueMatches(
|
|
72
|
-
callExpressionArgument: CallExpression['arguments'][0],
|
|
73
|
-
j: JSCodeshift,
|
|
74
|
-
value: string,
|
|
75
|
-
) {
|
|
76
|
-
return j(callExpressionArgument).some((path) => path.node.value === value);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function getImportSpecifierCollection(
|
|
80
|
-
j: JSCodeshift,
|
|
81
|
-
importDeclarationCollection: Collection<ImportDeclaration>,
|
|
82
|
-
importName: string,
|
|
83
|
-
): Collection<ImportSpecifier> {
|
|
84
|
-
return importDeclarationCollection
|
|
85
|
-
.find(j.ImportSpecifier)
|
|
86
|
-
.filter((importSpecifierPath) => importSpecifierPath.node.imported.name === importName);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function getImportSpecifierName(
|
|
90
|
-
importSpecifierCollection: Collection<ImportSpecifier>,
|
|
91
|
-
): string | null {
|
|
92
|
-
if (importSpecifierCollection.length === 0) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return importSpecifierCollection.nodes()[0]!.local!.name;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function isVariableDeclaratorIdentifierPresent(
|
|
100
|
-
j: JSCodeshift,
|
|
101
|
-
collection: Collection<any>,
|
|
102
|
-
variableName: string,
|
|
103
|
-
): boolean {
|
|
104
|
-
return collection
|
|
105
|
-
.find(j.VariableDeclaration)
|
|
106
|
-
.find(j.VariableDeclarator)
|
|
107
|
-
.some((variableDeclaratorPath) => {
|
|
108
|
-
const { id } = variableDeclaratorPath.node;
|
|
109
|
-
|
|
110
|
-
return !!(id && id.type === 'Identifier' && (id as Identifier).name === variableName);
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function isFunctionDeclarationIdentifierPresent(
|
|
115
|
-
j: JSCodeshift,
|
|
116
|
-
collection: Collection<any>,
|
|
117
|
-
variableName: string,
|
|
118
|
-
): boolean {
|
|
119
|
-
return collection.find(j.FunctionDeclaration).some((functionDeclarationPath) => {
|
|
120
|
-
const { id } = functionDeclarationPath.node;
|
|
121
|
-
|
|
122
|
-
return !!(id && id.type === 'Identifier' && (id as Identifier).name === variableName);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function isClassDeclarationIdentifierPresent(
|
|
127
|
-
j: JSCodeshift,
|
|
128
|
-
collection: Collection<any>,
|
|
129
|
-
variableName: string,
|
|
130
|
-
): boolean {
|
|
131
|
-
return collection.find(j.ClassDeclaration).some((classDeclarationPath) => {
|
|
132
|
-
const { id } = classDeclarationPath.node;
|
|
133
|
-
|
|
134
|
-
return !!(id && id.type === 'Identifier' && (id as Identifier).name === variableName);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function isImportDeclarationIdentifierPresent(
|
|
139
|
-
j: JSCodeshift,
|
|
140
|
-
collection: Collection<any>,
|
|
141
|
-
variableName: string,
|
|
142
|
-
): boolean {
|
|
143
|
-
return collection
|
|
144
|
-
.find(j.ImportDeclaration)
|
|
145
|
-
.find(j.Identifier)
|
|
146
|
-
.some((identifierPath) => identifierPath.node.name === variableName);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export function getJSXAttributesByName(
|
|
150
|
-
j: JSCodeshift,
|
|
151
|
-
jsxElementPath: ASTPath<JSXElement>,
|
|
152
|
-
attributeName: string,
|
|
153
|
-
): Collection<JSXAttribute> {
|
|
154
|
-
return j(jsxElementPath)
|
|
155
|
-
.find(j.JSXOpeningElement)
|
|
156
|
-
.find(j.JSXAttribute)
|
|
157
|
-
.filter((jsxAttributePath) =>
|
|
158
|
-
j(jsxAttributePath)
|
|
159
|
-
.find(j.JSXIdentifier)
|
|
160
|
-
.some((jsxIdentifierPath) => jsxIdentifierPath.node.name === attributeName),
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export function getJSXSpreadIdentifierAttributesByName(
|
|
165
|
-
j: JSCodeshift,
|
|
166
|
-
collection: Collection<any>,
|
|
167
|
-
jsxElementPath: ASTPath<JSXElement>,
|
|
168
|
-
attributeName: string,
|
|
169
|
-
): Collection<ObjectProperty> | null {
|
|
170
|
-
const identifierCollection = j(jsxElementPath)
|
|
171
|
-
.find(j.JSXOpeningElement)
|
|
172
|
-
.find(j.JSXSpreadAttribute)
|
|
173
|
-
.filter((jsxSpreadAttributePath) => jsxSpreadAttributePath.node.argument.type === 'Identifier')
|
|
174
|
-
.find(j.Identifier);
|
|
175
|
-
|
|
176
|
-
if (identifierCollection.length === 0) {
|
|
177
|
-
return null;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return collection
|
|
181
|
-
.find(j.VariableDeclarator)
|
|
182
|
-
.filter((variableDeclaratorPath) => {
|
|
183
|
-
const { id } = variableDeclaratorPath.node;
|
|
184
|
-
|
|
185
|
-
return (
|
|
186
|
-
id.type === 'Identifier' &&
|
|
187
|
-
identifierCollection.some((identifierPath) => identifierPath.node.name === id.name)
|
|
188
|
-
);
|
|
189
|
-
})
|
|
190
|
-
.find(j.ObjectExpression)
|
|
191
|
-
.find(j.ObjectProperty)
|
|
192
|
-
.filter((objectPropertyPath) =>
|
|
193
|
-
j(objectPropertyPath)
|
|
194
|
-
.find(j.Identifier)
|
|
195
|
-
.some((identifierPath) => identifierPath.node.name === attributeName),
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export function getJSXSpreadObjectExpressionAttributesByName(
|
|
200
|
-
j: JSCodeshift,
|
|
201
|
-
jsxElementPath: ASTPath<JSXElement>,
|
|
202
|
-
attributeName: string,
|
|
203
|
-
): Collection<ObjectProperty> {
|
|
204
|
-
return j(jsxElementPath)
|
|
205
|
-
.find(j.JSXOpeningElement)
|
|
206
|
-
.find(j.JSXSpreadAttribute)
|
|
207
|
-
.find(j.ObjectExpression)
|
|
208
|
-
.find(j.ObjectProperty)
|
|
209
|
-
.filter((objectPropertyPath) =>
|
|
210
|
-
j(objectPropertyPath)
|
|
211
|
-
.find(j.Identifier)
|
|
212
|
-
.some((identifierPath) => identifierPath.node.name === attributeName),
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export const createRemoveFuncFor: (
|
|
217
|
-
component: string,
|
|
218
|
-
importName: string,
|
|
219
|
-
prop: string,
|
|
220
|
-
comment?: string,
|
|
221
|
-
) => (j: core.JSCodeshift, source: Collection<Node>) => void =
|
|
222
|
-
(component: string, importName: string, prop: string, comment?: string) =>
|
|
223
|
-
(j: core.JSCodeshift, source: Collection<Node>) => {
|
|
224
|
-
const specifier = getNamedSpecifier(j, source, component, importName);
|
|
225
|
-
|
|
226
|
-
if (!specifier) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
source.findJSXElements(specifier).forEach((element) => {
|
|
231
|
-
getJSXAttributesByName(j, element, prop).forEach((attribute: any) => {
|
|
232
|
-
j(attribute).remove();
|
|
233
|
-
if (comment) {
|
|
234
|
-
addCommentToStartOfFile({ j, base: source, message: comment });
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
export const getJSXAttributeByName: (
|
|
241
|
-
j: JSCodeshift,
|
|
242
|
-
jsxElementPath: ASTPath<JSXElement>,
|
|
243
|
-
attributeName: string,
|
|
244
|
-
) => JSXAttribute | undefined = (
|
|
245
|
-
j: JSCodeshift,
|
|
246
|
-
jsxElementPath: ASTPath<JSXElement>,
|
|
247
|
-
attributeName: string,
|
|
248
|
-
): JSXAttribute | undefined => {
|
|
249
|
-
const attributes: JSXAttribute[] = j(jsxElementPath).find(j.JSXAttribute).nodes();
|
|
250
|
-
|
|
251
|
-
return attributes?.find((attr) => attr.name && attr.name.name === attributeName);
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
export const addJSXAttributeToJSXElement: (
|
|
255
|
-
j: JSCodeshift,
|
|
256
|
-
jsxElementPath: ASTPath<JSXElement>,
|
|
257
|
-
jsxAttribute: JSXAttribute,
|
|
258
|
-
) => void = (j: JSCodeshift, jsxElementPath: ASTPath<JSXElement>, jsxAttribute: JSXAttribute) => {
|
|
259
|
-
j(jsxElementPath)
|
|
260
|
-
.find(j.JSXOpeningElement)
|
|
261
|
-
.forEach((openingElement) => {
|
|
262
|
-
openingElement.node.attributes?.push(jsxAttribute);
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
export const removeJSXAttributeByName: (
|
|
267
|
-
j: JSCodeshift,
|
|
268
|
-
jsxElementPath: ASTPath<JSXElement>,
|
|
269
|
-
attrName: string,
|
|
270
|
-
) => void = (j: JSCodeshift, jsxElementPath: ASTPath<JSXElement>, attrName: string) => {
|
|
271
|
-
const attributes = getJSXAttributes(jsxElementPath);
|
|
272
|
-
const attr = getJSXAttributeByName(j, jsxElementPath, attrName);
|
|
273
|
-
if (attr) {
|
|
274
|
-
attributes?.splice(attributes.indexOf(attr), 1);
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
export const getJSXAttributes: (jsxElementPath: ASTPath<JSXElement>) => JSXAttribute[] = (
|
|
279
|
-
jsxElementPath: ASTPath<JSXElement>,
|
|
280
|
-
) => jsxElementPath.node.openingElement.attributes as JSXAttribute[];
|
|
281
|
-
|
|
282
|
-
export const removeJSXAttributeObjectPropertyByName: (
|
|
283
|
-
j: JSCodeshift,
|
|
284
|
-
jsxElementPath: ASTPath<JSXElement>,
|
|
285
|
-
attrName: string,
|
|
286
|
-
propertyToRemove: string,
|
|
287
|
-
) => void = (
|
|
288
|
-
j: JSCodeshift,
|
|
289
|
-
jsxElementPath: ASTPath<JSXElement>,
|
|
290
|
-
attrName: string,
|
|
291
|
-
propertyToRemove: string,
|
|
292
|
-
) => {
|
|
293
|
-
const attr = getJSXAttributeByName(j, jsxElementPath, attrName);
|
|
294
|
-
|
|
295
|
-
if (!attr) {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
const attrCollection = getJSXAttributesByName(j, jsxElementPath, attrName);
|
|
300
|
-
|
|
301
|
-
const removeMatchingNodes = (p: ASTPath<Identifier | StringLiteral>) => {
|
|
302
|
-
const name = p.node.type === 'Identifier' ? p.node?.name : p.node?.value;
|
|
303
|
-
// Need to account for quoted properties
|
|
304
|
-
const nameMatches = propertyToRemove.match(new RegExp(`['"]?${name}['"]?`));
|
|
305
|
-
// This will otherwise try to remove values of properties since they are literals
|
|
306
|
-
const isKey = p.parent.value?.type === 'ObjectProperty';
|
|
307
|
-
// Sorry about all the parents. This is the easiest way to get the name
|
|
308
|
-
// of the attribute name. And I always know the depth of the object
|
|
309
|
-
// property here.
|
|
310
|
-
const parentNameMatches = attrName === p.parent.parent.parent.parent.node?.name?.name;
|
|
311
|
-
if (isKey && nameMatches && parentNameMatches) {
|
|
312
|
-
j(p.parent).remove();
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
// Remove all the now migrated object properties
|
|
317
|
-
const objectProperties = attrCollection.find(j.ObjectProperty);
|
|
318
|
-
objectProperties.find(j.Identifier).forEach(removeMatchingNodes);
|
|
319
|
-
objectProperties.find(j.StringLiteral).forEach(removeMatchingNodes);
|
|
320
|
-
|
|
321
|
-
// @ts-ignore -- Property 'expression' does not exist on type 'LiteralKind | JSXElement | JSXExpressionContainer | JSXFragment'. Property 'expression' does not exist on type 'Literal'.
|
|
322
|
-
const attrProperties = attr.value?.expression.properties;
|
|
323
|
-
|
|
324
|
-
if (attrProperties && attrProperties?.length === 0) {
|
|
325
|
-
removeJSXAttributeByName(j, jsxElementPath, attrName);
|
|
326
|
-
}
|
|
327
|
-
};
|