@kaizen/components 1.69.1 → 1.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/codemods/migrateBrandMomentMoodToVariant/index.ts +5 -3
- package/codemods/migrateBrandMomentMoodToVariant/transformBrandMomentMoodToVariant.spec.ts +16 -5
- package/codemods/migrateCardVariantToColor/index.ts +5 -3
- package/codemods/migrateCardVariantToColor/transformCardVariantToColor.spec.ts +16 -5
- package/codemods/migrateConfirmationModalMoodsToVariant/index.ts +3 -1
- package/codemods/migrateConfirmationModalMoodsToVariant/transformConfirmationModalMoodsToVariant.spec.ts +27 -44
- package/codemods/migrateEmptyStateIllustrationTypeToVariant/index.ts +5 -3
- package/codemods/migrateEmptyStateIllustrationTypeToVariant/transformEmptyStateIllustrationTypeToVariant.spec.ts +16 -5
- package/codemods/migrateGlobalNotificationTypeToVariant/index.ts +5 -3
- package/codemods/migrateInformationTileMoodToVariant/index.ts +5 -3
- package/codemods/migrateInformationTileMoodToVariant/transformInformationTileMoodToVariant.spec.ts +16 -7
- package/codemods/migrateInlineNotificationTypeToVariant/index.ts +5 -3
- package/codemods/migrateMultiActionTileMoodToVariant/index.ts +5 -3
- package/codemods/migrateMultiActionTileMoodToVariant/transformMultiActionTileMoodToVariant.spec.ts +16 -7
- package/codemods/migrateNotificationTypeToVariant/migrateNotificationTypeToVariant.spec.ts +42 -43
- package/codemods/migrateProgressBarMoodToColor/index.ts +5 -3
- package/codemods/migrateProgressBarMoodToColor/transformProgressBarMoodToColor.spec.ts +16 -5
- package/codemods/migrateToastNotificationTypeToVariant/index.ts +6 -4
- package/codemods/migrateWellVariantToColor/index.ts +5 -3
- package/codemods/migrateWellVariantToColor/transformWellVariantToColor.spec.ts +26 -68
- package/codemods/migrateWellVariantToColor/transformWellVariantToColor.ts +10 -4
- package/codemods/removeInputEditModalMood/index.ts +3 -1
- package/codemods/removeInputEditModalMood/removeInputEditModalMood.spec.ts +23 -20
- package/codemods/removePopoverVariant/index.ts +1 -1
- package/codemods/removePopoverVariant/removePopoverVariant.spec.ts +23 -25
- package/codemods/upgradeIconV1/index.ts +2 -17
- package/codemods/upgradeIconV1/upgradeIconV1.spec.ts +18 -120
- package/codemods/upgradeIconV1/upgradeIconV1.ts +21 -28
- package/codemods/utils/__snapshots__/transformSource.spec.ts.snap +0 -10
- package/codemods/utils/getKaioTagName.spec.ts +167 -23
- package/codemods/utils/getKaioTagName.ts +71 -35
- package/codemods/utils/migrateStringProp.spec.ts +16 -5
- package/codemods/utils/migrateStringProp.ts +10 -3
- package/codemods/utils/removeProps.spec.ts +26 -25
- package/codemods/utils/removeProps.ts +10 -3
- package/codemods/utils/transformComponentsInDir.ts +40 -13
- package/codemods/utils/transformSource.spec.ts +1 -27
- package/codemods/utils/transformSource.ts +0 -26
- package/codemods/utils/updateKaioImports.ts +2 -0
- package/dist/cjs/LinkButton/LinkButton.cjs +59 -0
- package/dist/cjs/LinkButton/LinkButton.module.css.cjs +6 -0
- package/dist/cjs/__rc__/Button/Button.module.css.cjs +1 -1
- package/dist/cjs/index.cjs +2 -0
- package/dist/esm/LinkButton/LinkButton.mjs +53 -0
- package/dist/esm/LinkButton/LinkButton.module.css.mjs +4 -0
- package/dist/esm/__rc__/Button/Button.module.css.mjs +1 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/styles.css +3259 -3229
- package/dist/types/LinkButton/LinkButton.d.ts +11 -0
- package/dist/types/LinkButton/index.d.ts +1 -0
- package/dist/types/__rc__/Button/Button.d.ts +6 -5
- package/dist/types/index.d.ts +1 -2
- package/package.json +1 -1
- package/src/LinkButton/LinkButton.module.css +4 -0
- package/src/LinkButton/LinkButton.tsx +71 -0
- package/src/LinkButton/_docs/LinkButton--api-specification.mdx +281 -0
- package/src/LinkButton/_docs/LinkButton--usage-guidelines.mdx +29 -0
- package/src/LinkButton/_docs/LinkButton.doc.stories.tsx +136 -0
- package/src/LinkButton/_docs/LinkButton.spec.stories.tsx +80 -0
- package/src/LinkButton/_docs/LinkButton.stickersheet.stories.tsx +130 -0
- package/src/LinkButton/index.ts +1 -0
- package/src/__rc__/Button/Button.module.css +44 -19
- package/src/__rc__/Button/Button.tsx +8 -4
- package/src/__rc__/Button/_docs/Button--api-specification.mdx +5 -5
- package/src/__rc__/Button/_docs/Button--usage-guidelines.mdx +2 -5
- package/src/index.ts +1 -2
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { transformComponentsInDir } from '../utils'
|
|
2
2
|
import { transformBrandMomentMoodToVariant } from './transformBrandMomentMoodToVariant'
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const run = (): void => {
|
|
5
5
|
console.log('~(-_- ~) Running BrandMoment mood to variant transformer (~ -_-)~')
|
|
6
6
|
const targetDir = process.argv[2]
|
|
7
7
|
if (!targetDir) {
|
|
8
8
|
process.exit(1)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
transformComponentsInDir(targetDir,
|
|
11
|
+
transformComponentsInDir(targetDir, ['BrandMoment'], (tagNames) => [
|
|
12
|
+
transformBrandMomentMoodToVariant(tagNames),
|
|
13
|
+
])
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
run()
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { parseJsx } from '../__tests__/utils'
|
|
2
|
-
import { printAst,
|
|
2
|
+
import { printAst, transformSource, type TransformSourceArgs } from '../utils'
|
|
3
3
|
import { transformBrandMomentMoodToVariant } from './transformBrandMomentMoodToVariant'
|
|
4
4
|
|
|
5
|
-
const transformBrandMoment = (sourceFile:
|
|
6
|
-
|
|
5
|
+
const transformBrandMoment = (sourceFile: TransformSourceArgs['sourceFile']): string => {
|
|
6
|
+
const tagsMap = new Map([
|
|
7
|
+
[
|
|
8
|
+
'BrandMoment',
|
|
9
|
+
{
|
|
10
|
+
importModuleName: '@kaizen/components',
|
|
11
|
+
tagName: 'BrandMoment',
|
|
12
|
+
originalName: 'BrandMoment',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
])
|
|
16
|
+
|
|
17
|
+
return transformSource({
|
|
7
18
|
sourceFile,
|
|
8
|
-
|
|
9
|
-
tagName: 'BrandMoment',
|
|
19
|
+
transformers: [transformBrandMomentMoodToVariant(tagsMap)],
|
|
10
20
|
})
|
|
21
|
+
}
|
|
11
22
|
|
|
12
23
|
describe('transformBrandMomentMoodToVariant()', () => {
|
|
13
24
|
it('replaces mood="informative" with variant="informative"', () => {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { transformComponentsInDir } from '../utils'
|
|
2
2
|
import { transformCardVariantToColor } from './transformCardVariantToColor'
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const run = (): void => {
|
|
5
5
|
console.log('~(-_- ~) Running Card variant to color transformer (~ -_-)~')
|
|
6
6
|
const targetDir = process.argv[2]
|
|
7
7
|
if (!targetDir) {
|
|
8
8
|
process.exit(1)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
transformComponentsInDir(targetDir,
|
|
11
|
+
transformComponentsInDir(targetDir, ['Card'], (tagNames) => [
|
|
12
|
+
transformCardVariantToColor(tagNames),
|
|
13
|
+
])
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
run()
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { parseJsx } from '../__tests__/utils'
|
|
2
|
-
import { printAst,
|
|
2
|
+
import { printAst, transformSource, type TransformSourceArgs } from '../utils'
|
|
3
3
|
import { transformCardVariantToColor } from './transformCardVariantToColor'
|
|
4
4
|
|
|
5
|
-
const transformCard = (sourceFile:
|
|
6
|
-
|
|
5
|
+
const transformCard = (sourceFile: TransformSourceArgs['sourceFile']): string => {
|
|
6
|
+
const tagsMap = new Map([
|
|
7
|
+
[
|
|
8
|
+
'Card',
|
|
9
|
+
{
|
|
10
|
+
importModuleName: '@kaizen/components',
|
|
11
|
+
tagName: 'Card',
|
|
12
|
+
originalName: 'Card',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
])
|
|
16
|
+
|
|
17
|
+
return transformSource({
|
|
7
18
|
sourceFile,
|
|
8
|
-
|
|
9
|
-
tagName: 'Card',
|
|
19
|
+
transformers: [transformCardVariantToColor(tagsMap)],
|
|
10
20
|
})
|
|
21
|
+
}
|
|
11
22
|
|
|
12
23
|
describe('transformCardVariantToColor()', () => {
|
|
13
24
|
it('replaces variant="assertive" with color="orange"', () => {
|
|
@@ -8,7 +8,9 @@ const run = (): void => {
|
|
|
8
8
|
process.exit(1)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
transformComponentsInDir(targetDir,
|
|
11
|
+
transformComponentsInDir(targetDir, ['ConfirmationModal'], (tagNames) => [
|
|
12
|
+
transformConfirmationModalMoodsToVariant(tagNames),
|
|
13
|
+
])
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
run()
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import { parseJsx } from '../__tests__/utils'
|
|
2
|
-
import { printAst,
|
|
2
|
+
import { printAst, transformSource, type TransformSourceArgs } from '../utils'
|
|
3
3
|
import { transformConfirmationModalMoodsToVariant } from './transformConfirmationModalMoodsToVariant'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const transformConfirmationModal = (sourceFile: TransformSourceArgs['sourceFile']): string => {
|
|
6
|
+
const tagsMap = new Map([
|
|
7
|
+
[
|
|
8
|
+
'ConfirmationModal',
|
|
9
|
+
{
|
|
10
|
+
importModuleName: '@kaizen/components',
|
|
11
|
+
tagName: 'ConfirmationModal',
|
|
12
|
+
originalName: 'ConfirmationModal',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
])
|
|
16
|
+
|
|
17
|
+
return transformSource({
|
|
18
|
+
sourceFile,
|
|
19
|
+
transformers: [transformConfirmationModalMoodsToVariant(tagsMap)],
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
describe('transformConfirmationModalMoodsToVariant()', () => {
|
|
6
24
|
it('replaces mood="positive" with variant="success"', () => {
|
|
7
25
|
const inputAst = parseJsx(`
|
|
8
26
|
export const TestComponent = () => <ConfirmationModal mood="positive"/>
|
|
@@ -10,12 +28,7 @@ describe('transformConfirmationModalMoodsToVariant', () => {
|
|
|
10
28
|
const outputAst = parseJsx(`
|
|
11
29
|
export const TestComponent = () => <ConfirmationModal variant="success"/>
|
|
12
30
|
`)
|
|
13
|
-
|
|
14
|
-
sourceFile: inputAst,
|
|
15
|
-
astTransformer: transformConfirmationModalMoodsToVariant,
|
|
16
|
-
tagName: 'ConfirmationModal',
|
|
17
|
-
})
|
|
18
|
-
expect(transformed).toEqual(printAst(outputAst))
|
|
31
|
+
expect(transformConfirmationModal(inputAst)).toEqual(printAst(outputAst))
|
|
19
32
|
})
|
|
20
33
|
|
|
21
34
|
it('replaces mood="negative" with variant="warning"', () => {
|
|
@@ -25,12 +38,7 @@ describe('transformConfirmationModalMoodsToVariant', () => {
|
|
|
25
38
|
const outputAst = parseJsx(`
|
|
26
39
|
export const TestComponent = () => <ConfirmationModal variant="warning"/>
|
|
27
40
|
`)
|
|
28
|
-
|
|
29
|
-
sourceFile: inputAst,
|
|
30
|
-
astTransformer: transformConfirmationModalMoodsToVariant,
|
|
31
|
-
tagName: 'ConfirmationModal',
|
|
32
|
-
})
|
|
33
|
-
expect(transformed).toEqual(printAst(outputAst))
|
|
41
|
+
expect(transformConfirmationModal(inputAst)).toEqual(printAst(outputAst))
|
|
34
42
|
})
|
|
35
43
|
|
|
36
44
|
it('handles multiple attributes and replace only variant', () => {
|
|
@@ -40,12 +48,7 @@ describe('transformConfirmationModalMoodsToVariant', () => {
|
|
|
40
48
|
const outputAst = parseJsx(`
|
|
41
49
|
export const TestComponent = () => <ConfirmationModal variant="warning" id="123"/>
|
|
42
50
|
`)
|
|
43
|
-
|
|
44
|
-
sourceFile: inputAst,
|
|
45
|
-
astTransformer: transformConfirmationModalMoodsToVariant,
|
|
46
|
-
tagName: 'ConfirmationModal',
|
|
47
|
-
})
|
|
48
|
-
expect(transformed).toBe(printAst(outputAst))
|
|
51
|
+
expect(transformConfirmationModal(inputAst)).toBe(printAst(outputAst))
|
|
49
52
|
})
|
|
50
53
|
|
|
51
54
|
it('transforms multiple ConfirmationModals', () => {
|
|
@@ -55,12 +58,7 @@ describe('transformConfirmationModalMoodsToVariant', () => {
|
|
|
55
58
|
const outputAst = parseJsx(`
|
|
56
59
|
export const TestComponent = () => <div><ConfirmationModal variant="success"/><ConfirmationModal variant="warning"/></div>
|
|
57
60
|
`)
|
|
58
|
-
|
|
59
|
-
sourceFile: inputAst,
|
|
60
|
-
astTransformer: transformConfirmationModalMoodsToVariant,
|
|
61
|
-
tagName: 'ConfirmationModal',
|
|
62
|
-
})
|
|
63
|
-
expect(transformed).toBe(printAst(outputAst))
|
|
61
|
+
expect(transformConfirmationModal(inputAst)).toBe(printAst(outputAst))
|
|
64
62
|
})
|
|
65
63
|
|
|
66
64
|
it('transforms ConfirmationModal with arbitrary braces', () => {
|
|
@@ -70,12 +68,7 @@ describe('transformConfirmationModalMoodsToVariant', () => {
|
|
|
70
68
|
const outputAst = parseJsx(`
|
|
71
69
|
export const TestComponent = () => <div><ConfirmationModal variant="success"/><ConfirmationModal variant="cautionary"/><ConfirmationModal variant="success"/></div>
|
|
72
70
|
`)
|
|
73
|
-
|
|
74
|
-
sourceFile: inputAst,
|
|
75
|
-
astTransformer: transformConfirmationModalMoodsToVariant,
|
|
76
|
-
tagName: 'ConfirmationModal',
|
|
77
|
-
})
|
|
78
|
-
expect(transformed).toBe(printAst(outputAst))
|
|
71
|
+
expect(transformConfirmationModal(inputAst)).toBe(printAst(outputAst))
|
|
79
72
|
})
|
|
80
73
|
|
|
81
74
|
it("won't add variant if variant already exists", () => {
|
|
@@ -85,12 +78,7 @@ describe('transformConfirmationModalMoodsToVariant', () => {
|
|
|
85
78
|
const outputAst = parseJsx(`
|
|
86
79
|
export const TestComponent = () => <div><ConfirmationModal variant="success"/></div>
|
|
87
80
|
`)
|
|
88
|
-
|
|
89
|
-
sourceFile: inputAst,
|
|
90
|
-
astTransformer: transformConfirmationModalMoodsToVariant,
|
|
91
|
-
tagName: 'ConfirmationModal',
|
|
92
|
-
})
|
|
93
|
-
expect(transformed).toBe(printAst(outputAst))
|
|
81
|
+
expect(transformConfirmationModal(inputAst)).toBe(printAst(outputAst))
|
|
94
82
|
})
|
|
95
83
|
|
|
96
84
|
it("won't modify variants usings variables", () => {
|
|
@@ -100,11 +88,6 @@ describe('transformConfirmationModalMoodsToVariant', () => {
|
|
|
100
88
|
const outputAst = parseJsx(`
|
|
101
89
|
export const TestComponent = () => <div><ConfirmationModal variant={confirmationModalVariable}/></div>
|
|
102
90
|
`)
|
|
103
|
-
|
|
104
|
-
sourceFile: inputAst,
|
|
105
|
-
astTransformer: transformConfirmationModalMoodsToVariant,
|
|
106
|
-
tagName: 'ConfirmationModal',
|
|
107
|
-
})
|
|
108
|
-
expect(transformed).toBe(printAst(outputAst))
|
|
91
|
+
expect(transformConfirmationModal(inputAst)).toBe(printAst(outputAst))
|
|
109
92
|
})
|
|
110
93
|
})
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { transformComponentsInDir } from '../utils'
|
|
2
2
|
import { transformEmptyStateIllustrationTypeToVariant } from './transformEmptyStateIllustrationTypeToVariant'
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const run = (): void => {
|
|
5
5
|
console.log('~(-_- ~) Running EmptyState illustrationType to variant transformer (~ -_-)~')
|
|
6
6
|
const targetDir = process.argv[2]
|
|
7
7
|
if (!targetDir) {
|
|
8
8
|
process.exit(1)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
transformComponentsInDir(targetDir,
|
|
11
|
+
transformComponentsInDir(targetDir, ['EmptyState'], (tagNames) => [
|
|
12
|
+
transformEmptyStateIllustrationTypeToVariant(tagNames),
|
|
13
|
+
])
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
run()
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { parseJsx } from '../__tests__/utils'
|
|
2
|
-
import { printAst,
|
|
2
|
+
import { printAst, transformSource, type TransformSourceArgs } from '../utils'
|
|
3
3
|
import { transformEmptyStateIllustrationTypeToVariant } from './transformEmptyStateIllustrationTypeToVariant'
|
|
4
4
|
|
|
5
|
-
const transformEmptyState = (sourceFile:
|
|
6
|
-
|
|
5
|
+
const transformEmptyState = (sourceFile: TransformSourceArgs['sourceFile']): string => {
|
|
6
|
+
const tagsMap = new Map([
|
|
7
|
+
[
|
|
8
|
+
'EmptyState',
|
|
9
|
+
{
|
|
10
|
+
importModuleName: '@kaizen/components',
|
|
11
|
+
tagName: 'EmptyState',
|
|
12
|
+
originalName: 'EmptyState',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
])
|
|
16
|
+
|
|
17
|
+
return transformSource({
|
|
7
18
|
sourceFile,
|
|
8
|
-
|
|
9
|
-
tagName: 'EmptyState',
|
|
19
|
+
transformers: [transformEmptyStateIllustrationTypeToVariant(tagsMap)],
|
|
10
20
|
})
|
|
21
|
+
}
|
|
11
22
|
|
|
12
23
|
describe('transformEmptyStateIllustrationTypeToVariant()', () => {
|
|
13
24
|
it('replaces illustrationType="positive" with variant="success"', () => {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { transformNotificationTypeToVariant } from '../migrateNotificationTypeToVariant'
|
|
2
2
|
import { transformComponentsInDir } from '../utils'
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const run = (): void => {
|
|
5
5
|
console.log('~(-_- ~) Running GlobalNotification transformer (~ -_-)~')
|
|
6
6
|
const targetDir = process.argv[2]
|
|
7
7
|
if (!targetDir) {
|
|
8
8
|
process.exit(1)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
transformComponentsInDir(targetDir,
|
|
11
|
+
transformComponentsInDir(targetDir, ['GlobalNotification'], (tagNames) => [
|
|
12
|
+
transformNotificationTypeToVariant(tagNames),
|
|
13
|
+
])
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
run()
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { transformComponentsInDir } from '../utils'
|
|
2
2
|
import { transformInformationTileMoodToVariant } from './transformInformationTileMoodToVariant'
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const run = (): void => {
|
|
5
5
|
console.log('~(-_- ~) Running InformationTile mood to variant transformer (~ -_-)~')
|
|
6
6
|
const targetDir = process.argv[2]
|
|
7
7
|
if (!targetDir) {
|
|
8
8
|
process.exit(1)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
transformComponentsInDir(targetDir,
|
|
11
|
+
transformComponentsInDir(targetDir, ['InformationTile'], (tagNames) => [
|
|
12
|
+
transformInformationTileMoodToVariant(tagNames),
|
|
13
|
+
])
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
run()
|
package/codemods/migrateInformationTileMoodToVariant/transformInformationTileMoodToVariant.spec.ts
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { parseJsx } from '../__tests__/utils'
|
|
2
|
-
import { printAst,
|
|
2
|
+
import { printAst, transformSource, type TransformSourceArgs } from '../utils'
|
|
3
3
|
import { transformInformationTileMoodToVariant } from './transformInformationTileMoodToVariant'
|
|
4
4
|
|
|
5
|
-
const transformInformationTile = (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const transformInformationTile = (sourceFile: TransformSourceArgs['sourceFile']): string => {
|
|
6
|
+
const tagsMap = new Map([
|
|
7
|
+
[
|
|
8
|
+
'InformationTile',
|
|
9
|
+
{
|
|
10
|
+
importModuleName: '@kaizen/components',
|
|
11
|
+
tagName: 'InformationTile',
|
|
12
|
+
originalName: 'InformationTile',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
])
|
|
16
|
+
|
|
17
|
+
return transformSource({
|
|
9
18
|
sourceFile,
|
|
10
|
-
|
|
11
|
-
tagName: 'InformationTile',
|
|
19
|
+
transformers: [transformInformationTileMoodToVariant(tagsMap)],
|
|
12
20
|
})
|
|
21
|
+
}
|
|
13
22
|
|
|
14
23
|
describe('transformInformationTileMoodToVariant()', () => {
|
|
15
24
|
it('replaces mood="positive" with variant="default"', () => {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { transformNotificationTypeToVariant } from '../migrateNotificationTypeToVariant'
|
|
2
2
|
import { transformComponentsInDir } from '../utils'
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const run = (): void => {
|
|
5
5
|
console.log('~(-_- ~) Running InlineNotification transformer (~ -_-)~')
|
|
6
6
|
const targetDir = process.argv[2]
|
|
7
7
|
if (!targetDir) {
|
|
8
8
|
process.exit(1)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
transformComponentsInDir(targetDir,
|
|
11
|
+
transformComponentsInDir(targetDir, ['InlineNotification'], (tagNames) => [
|
|
12
|
+
transformNotificationTypeToVariant(tagNames),
|
|
13
|
+
])
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
run()
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { transformComponentsInDir } from '../utils'
|
|
2
2
|
import { transformMultiActionTileMoodToVariant } from './transformMultiActionTileMoodToVariant'
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const run = (): void => {
|
|
5
5
|
console.log(' ~(-_- ~) Running MultiActionTile mood to variant transformer (~ -_-)~')
|
|
6
6
|
const targetDir = process.argv[2]
|
|
7
7
|
if (!targetDir) {
|
|
8
8
|
process.exit(1)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
transformComponentsInDir(targetDir,
|
|
11
|
+
transformComponentsInDir(targetDir, ['MultiActionTile'], (tagNames) => [
|
|
12
|
+
transformMultiActionTileMoodToVariant(tagNames),
|
|
13
|
+
])
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
run()
|
package/codemods/migrateMultiActionTileMoodToVariant/transformMultiActionTileMoodToVariant.spec.ts
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { parseJsx } from '../__tests__/utils'
|
|
2
|
-
import { printAst,
|
|
2
|
+
import { printAst, transformSource, type TransformSourceArgs } from '../utils'
|
|
3
3
|
import { transformMultiActionTileMoodToVariant } from './transformMultiActionTileMoodToVariant'
|
|
4
4
|
|
|
5
|
-
const transformMultiActionTile = (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const transformMultiActionTile = (sourceFile: TransformSourceArgs['sourceFile']): string => {
|
|
6
|
+
const tagsMap = new Map([
|
|
7
|
+
[
|
|
8
|
+
'MultiActionTile',
|
|
9
|
+
{
|
|
10
|
+
importModuleName: '@kaizen/components',
|
|
11
|
+
tagName: 'MultiActionTile',
|
|
12
|
+
originalName: 'MultiActionTile',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
])
|
|
16
|
+
|
|
17
|
+
return transformSource({
|
|
9
18
|
sourceFile,
|
|
10
|
-
|
|
11
|
-
tagName: 'MultiActionTile',
|
|
19
|
+
transformers: [transformMultiActionTileMoodToVariant(tagsMap)],
|
|
12
20
|
})
|
|
21
|
+
}
|
|
13
22
|
|
|
14
23
|
describe('transformMultiActionTileMoodToVariant()', () => {
|
|
15
24
|
it('replaces mood="positive" with variant="default"', () => {
|
|
@@ -1,7 +1,41 @@
|
|
|
1
1
|
import { parseJsx } from '../__tests__/utils'
|
|
2
|
-
import { printAst,
|
|
2
|
+
import { printAst, transformSource, type TransformSourceArgs } from '../utils'
|
|
3
3
|
import { transformNotificationTypeToVariant } from './migrateNotificationTypeToVariant'
|
|
4
4
|
|
|
5
|
+
const transformNotifications = (sourceFile: TransformSourceArgs['sourceFile']): string => {
|
|
6
|
+
const tagsMap = new Map([
|
|
7
|
+
[
|
|
8
|
+
'GlobalNotification',
|
|
9
|
+
{
|
|
10
|
+
importModuleName: '@kaizen/components',
|
|
11
|
+
tagName: 'GlobalNotification',
|
|
12
|
+
originalName: 'GlobalNotification',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
[
|
|
16
|
+
'InlineNotification',
|
|
17
|
+
{
|
|
18
|
+
importModuleName: '@kaizen/components',
|
|
19
|
+
tagName: 'InlineNotification',
|
|
20
|
+
originalName: 'InlineNotification',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
'ToastNotification',
|
|
25
|
+
{
|
|
26
|
+
importModuleName: '@kaizen/components',
|
|
27
|
+
tagName: 'ToastNotification',
|
|
28
|
+
originalName: 'ToastNotification',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
])
|
|
32
|
+
|
|
33
|
+
return transformSource({
|
|
34
|
+
sourceFile,
|
|
35
|
+
transformers: [transformNotificationTypeToVariant(tagsMap)],
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
5
39
|
describe('transformNotificationTypeToVariant', () => {
|
|
6
40
|
it('replaces InlineNotifications type="positive" with variant="success"', () => {
|
|
7
41
|
const inputAst = parseJsx(`
|
|
@@ -10,12 +44,7 @@ describe('transformNotificationTypeToVariant', () => {
|
|
|
10
44
|
const outputAst = parseJsx(`
|
|
11
45
|
export const TestComponent = () => <InlineNotification variant="success">Test</InlineNotification>
|
|
12
46
|
`)
|
|
13
|
-
|
|
14
|
-
sourceFile: inputAst,
|
|
15
|
-
astTransformer: transformNotificationTypeToVariant,
|
|
16
|
-
tagName: 'InlineNotification',
|
|
17
|
-
})
|
|
18
|
-
expect(transformed).toEqual(printAst(outputAst))
|
|
47
|
+
expect(transformNotifications(inputAst)).toEqual(printAst(outputAst))
|
|
19
48
|
})
|
|
20
49
|
|
|
21
50
|
it('replaces GlobalNotification type="positive" with variant="success"', () => {
|
|
@@ -25,12 +54,7 @@ describe('transformNotificationTypeToVariant', () => {
|
|
|
25
54
|
const outputAst = parseJsx(`
|
|
26
55
|
export const TestComponent = () => <GlobalNotification variant="success">Test</GlobalNotification>
|
|
27
56
|
`)
|
|
28
|
-
|
|
29
|
-
sourceFile: inputAst,
|
|
30
|
-
astTransformer: transformNotificationTypeToVariant,
|
|
31
|
-
tagName: 'GlobalNotification',
|
|
32
|
-
})
|
|
33
|
-
expect(transformed).toEqual(printAst(outputAst))
|
|
57
|
+
expect(transformNotifications(inputAst)).toEqual(printAst(outputAst))
|
|
34
58
|
})
|
|
35
59
|
|
|
36
60
|
it('replaces ToastNotification type="positive" with variant="success"', () => {
|
|
@@ -40,12 +64,7 @@ describe('transformNotificationTypeToVariant', () => {
|
|
|
40
64
|
const outputAst = parseJsx(`
|
|
41
65
|
export const TestComponent = () => <ToastNotification variant="success">Test</ToastNotification>
|
|
42
66
|
`)
|
|
43
|
-
|
|
44
|
-
sourceFile: inputAst,
|
|
45
|
-
astTransformer: transformNotificationTypeToVariant,
|
|
46
|
-
tagName: 'ToastNotification',
|
|
47
|
-
})
|
|
48
|
-
expect(transformed).toEqual(printAst(outputAst))
|
|
67
|
+
expect(transformNotifications(inputAst)).toEqual(printAst(outputAst))
|
|
49
68
|
})
|
|
50
69
|
|
|
51
70
|
it('replaces type="informative" with variant="informative"', () => {
|
|
@@ -55,12 +74,7 @@ describe('transformNotificationTypeToVariant', () => {
|
|
|
55
74
|
const outputAst = parseJsx(`
|
|
56
75
|
export const TestComponent = () => <InlineNotification variant="informative">Test</InlineNotification>
|
|
57
76
|
`)
|
|
58
|
-
|
|
59
|
-
sourceFile: inputAst,
|
|
60
|
-
astTransformer: transformNotificationTypeToVariant,
|
|
61
|
-
tagName: 'InlineNotification',
|
|
62
|
-
})
|
|
63
|
-
expect(transformed).toBe(printAst(outputAst))
|
|
77
|
+
expect(transformNotifications(inputAst)).toBe(printAst(outputAst))
|
|
64
78
|
})
|
|
65
79
|
it('replaces type="cautionary" with variant="cautionary"', () => {
|
|
66
80
|
const inputAst = parseJsx(`
|
|
@@ -69,12 +83,7 @@ describe('transformNotificationTypeToVariant', () => {
|
|
|
69
83
|
const outputAst = parseJsx(`
|
|
70
84
|
export const TestComponent = () => <InlineNotification variant="cautionary">Test</InlineNotification>
|
|
71
85
|
`)
|
|
72
|
-
|
|
73
|
-
sourceFile: inputAst,
|
|
74
|
-
astTransformer: transformNotificationTypeToVariant,
|
|
75
|
-
tagName: 'InlineNotification',
|
|
76
|
-
})
|
|
77
|
-
expect(transformed).toBe(printAst(outputAst))
|
|
86
|
+
expect(transformNotifications(inputAst)).toBe(printAst(outputAst))
|
|
78
87
|
})
|
|
79
88
|
it('replaces type="security" with variant="security"', () => {
|
|
80
89
|
const inputAst = parseJsx(`
|
|
@@ -83,12 +92,7 @@ describe('transformNotificationTypeToVariant', () => {
|
|
|
83
92
|
const outputAst = parseJsx(`
|
|
84
93
|
export const TestComponent = () => <InlineNotification variant="security">Test</InlineNotification>
|
|
85
94
|
`)
|
|
86
|
-
|
|
87
|
-
sourceFile: inputAst,
|
|
88
|
-
astTransformer: transformNotificationTypeToVariant,
|
|
89
|
-
tagName: 'InlineNotification',
|
|
90
|
-
})
|
|
91
|
-
expect(transformed).toBe(printAst(outputAst))
|
|
95
|
+
expect(transformNotifications(inputAst)).toBe(printAst(outputAst))
|
|
92
96
|
})
|
|
93
97
|
it('replaces type="negative" with variant="warning"', () => {
|
|
94
98
|
const inputAst = parseJsx(`
|
|
@@ -97,11 +101,6 @@ describe('transformNotificationTypeToVariant', () => {
|
|
|
97
101
|
const outputAst = parseJsx(`
|
|
98
102
|
export const TestComponent = () => <InlineNotification variant="warning">Test</InlineNotification>
|
|
99
103
|
`)
|
|
100
|
-
|
|
101
|
-
sourceFile: inputAst,
|
|
102
|
-
astTransformer: transformNotificationTypeToVariant,
|
|
103
|
-
tagName: 'InlineNotification',
|
|
104
|
-
})
|
|
105
|
-
expect(transformed).toBe(printAst(outputAst))
|
|
104
|
+
expect(transformNotifications(inputAst)).toBe(printAst(outputAst))
|
|
106
105
|
})
|
|
107
106
|
})
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { transformComponentsInDir } from '../utils'
|
|
2
2
|
import { transformProgressBarMoodToColor } from './transformProgressBarMoodToColor'
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const run = (): void => {
|
|
5
5
|
console.log(' ~(-_- ~) Running ProgressBar mood to color transformer (~ -_-)~')
|
|
6
6
|
const targetDir = process.argv[2]
|
|
7
7
|
if (!targetDir) {
|
|
8
8
|
process.exit(1)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
transformComponentsInDir(targetDir,
|
|
11
|
+
transformComponentsInDir(targetDir, ['ProgressBar'], (tagNames) => [
|
|
12
|
+
transformProgressBarMoodToColor(tagNames),
|
|
13
|
+
])
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
run()
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { parseJsx } from '../__tests__/utils'
|
|
2
|
-
import { printAst,
|
|
2
|
+
import { printAst, transformSource, type TransformSourceArgs } from '../utils'
|
|
3
3
|
import { transformProgressBarMoodToColor } from './transformProgressBarMoodToColor'
|
|
4
4
|
|
|
5
|
-
const transformProgressBar = (sourceFile:
|
|
6
|
-
|
|
5
|
+
const transformProgressBar = (sourceFile: TransformSourceArgs['sourceFile']): string => {
|
|
6
|
+
const tagsMap = new Map([
|
|
7
|
+
[
|
|
8
|
+
'ProgressBar',
|
|
9
|
+
{
|
|
10
|
+
importModuleName: '@kaizen/components',
|
|
11
|
+
tagName: 'ProgressBar',
|
|
12
|
+
originalName: 'ProgressBar',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
])
|
|
16
|
+
|
|
17
|
+
return transformSource({
|
|
7
18
|
sourceFile,
|
|
8
|
-
|
|
9
|
-
tagName: 'ProgressBar',
|
|
19
|
+
transformers: [transformProgressBarMoodToColor(tagsMap)],
|
|
10
20
|
})
|
|
21
|
+
}
|
|
11
22
|
|
|
12
23
|
describe('transformProgressBarMoodToColor()', () => {
|
|
13
24
|
it('replaces mood="cautionary" with color="yellow"', () => {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { transformNotificationTypeToVariant } from '../migrateNotificationTypeToVariant'
|
|
2
2
|
import { transformComponentsInDir } from '../utils'
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
console.log('
|
|
4
|
+
const run = (): void => {
|
|
5
|
+
console.log('~(-_- ~) Running ToastNotification transformer (~ -_-)~')
|
|
6
6
|
const targetDir = process.argv[2]
|
|
7
7
|
if (!targetDir) {
|
|
8
8
|
process.exit(1)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
transformComponentsInDir(targetDir,
|
|
11
|
+
transformComponentsInDir(targetDir, ['ToastNotification'], (tagNames) => [
|
|
12
|
+
transformNotificationTypeToVariant(tagNames),
|
|
13
|
+
])
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
run()
|