@transferwise/components 45.4.0 → 45.5.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.
Files changed (80) hide show
  1. package/build/es/no-polyfill/actionButton/ActionButton.js +1 -1
  2. package/build/es/no-polyfill/actionButton/ActionButton.spec.js +1 -1
  3. package/build/es/no-polyfill/actionButton/ActionButton.story.js +1 -1
  4. package/build/es/no-polyfill/circularButton/CircularButton.js +1 -1
  5. package/build/es/no-polyfill/common/flowHeader/FlowHeader.js +1 -1
  6. package/build/es/no-polyfill/common/hooks/index.js +1 -1
  7. package/build/es/no-polyfill/common/hooks/useClientWidth/useClientWidth.js +1 -1
  8. package/build/es/no-polyfill/common/hooks/useLayout/useLayout.js +1 -1
  9. package/build/es/no-polyfill/dateLookup/dateTrigger/DateTrigger.js +1 -1
  10. package/build/es/no-polyfill/decision/Decision.js +2 -2
  11. package/build/es/no-polyfill/definitionList/DefinitionList.js +1 -1
  12. package/build/es/no-polyfill/flowNavigation/FlowNavigation.js +2 -2
  13. package/build/es/no-polyfill/flowNavigation/backButton/BackButton.js +1 -1
  14. package/build/es/no-polyfill/index.js +1 -1
  15. package/build/es/no-polyfill/overlayHeader/OverlayHeader.js +1 -1
  16. package/build/es/no-polyfill/phoneNumberInput/data/countries.js +1 -1
  17. package/build/es/no-polyfill/snackbar/Snackbar.js +1 -1
  18. package/build/es/no-polyfill/stepper/Stepper.js +1 -1
  19. package/build/es/no-polyfill/tile/Tile.js +1 -1
  20. package/build/es/polyfill/actionButton/ActionButton.js +1 -1
  21. package/build/es/polyfill/actionButton/ActionButton.spec.js +1 -1
  22. package/build/es/polyfill/actionButton/ActionButton.story.js +1 -1
  23. package/build/es/polyfill/circularButton/CircularButton.js +1 -1
  24. package/build/es/polyfill/common/flowHeader/FlowHeader.js +1 -1
  25. package/build/es/polyfill/common/hooks/index.js +1 -1
  26. package/build/es/polyfill/common/hooks/useClientWidth/useClientWidth.js +1 -1
  27. package/build/es/polyfill/common/hooks/useLayout/useLayout.js +1 -1
  28. package/build/es/polyfill/dateLookup/dateTrigger/DateTrigger.js +1 -1
  29. package/build/es/polyfill/decision/Decision.js +2 -2
  30. package/build/es/polyfill/definitionList/DefinitionList.js +1 -1
  31. package/build/es/polyfill/flowNavigation/FlowNavigation.js +2 -2
  32. package/build/es/polyfill/flowNavigation/backButton/BackButton.js +1 -1
  33. package/build/es/polyfill/index.js +1 -1
  34. package/build/es/polyfill/overlayHeader/OverlayHeader.js +1 -1
  35. package/build/es/polyfill/phoneNumberInput/data/countries.js +1 -1
  36. package/build/es/polyfill/snackbar/Snackbar.js +1 -1
  37. package/build/es/polyfill/stepper/Stepper.js +1 -1
  38. package/build/es/polyfill/tile/Tile.js +1 -1
  39. package/build/main.css +1 -1
  40. package/build/styles/actionButton/ActionButton.css +1 -1
  41. package/build/styles/main.css +1 -1
  42. package/build/styles/popover/Popover.css +1 -1
  43. package/build/styles/select/Select.css +1 -1
  44. package/build/styles/snackbar/Snackbar.css +1 -1
  45. package/build/styles/stepper/Stepper.css +1 -1
  46. package/build/types/actionButton/ActionButton.d.ts +3 -0
  47. package/build/types/actionButton/ActionButton.story.d.ts +1 -1
  48. package/build/types/button/Button.story.d.ts +24 -24
  49. package/build/types/circularButton/CircularButton.d.ts +1 -1
  50. package/build/types/common/flowHeader/FlowHeader.d.ts +10 -1
  51. package/build/types/common/hooks/index.d.ts +1 -1
  52. package/build/types/common/hooks/useClientWidth/useClientWidth.d.ts +9 -8
  53. package/build/types/decision/Decision.d.ts +1 -1
  54. package/build/types/definitionList/DefinitionList.d.ts +1 -1
  55. package/build/types/flowNavigation/FlowNavigation.d.ts +16 -34
  56. package/build/types/index.d.ts +2 -2
  57. package/build/types/listItem/ListItem.d.ts +1 -1
  58. package/build/types/listItem/ListItem.story.d.ts +1 -1
  59. package/build/types/snackbar/Snackbar.d.ts +1 -1
  60. package/build/types/stepper/Stepper.d.ts +13 -18
  61. package/build/umd/no-polyfill/main.js +1 -1
  62. package/build/umd/polyfill/main.js +1 -1
  63. package/package.json +5 -12
  64. package/scripts/generate-type-declarations.js +0 -2
  65. package/build/es/no-polyfill/common/flowHeader/index.js +0 -1
  66. package/build/es/no-polyfill/common/hooks/useClientWidth/index.js +0 -1
  67. package/build/es/no-polyfill/flowNavigation/index.js +0 -1
  68. package/build/es/no-polyfill/stepper/index.js +0 -1
  69. package/build/es/polyfill/common/flowHeader/index.js +0 -1
  70. package/build/es/polyfill/common/hooks/useClientWidth/index.js +0 -1
  71. package/build/es/polyfill/flowNavigation/index.js +0 -1
  72. package/build/es/polyfill/stepper/index.js +0 -1
  73. package/build/types/common/flowHeader/index.d.ts +0 -1
  74. package/build/types/common/hooks/useClientWidth/index.d.ts +0 -1
  75. package/build/types/flowNavigation/index.d.ts +0 -1
  76. package/build/types/stepper/index.d.ts +0 -2
  77. package/scripts/neptune-upgrader.js +0 -114
  78. package/upgrades/2021-02-v34-35.js +0 -193
  79. package/upgrades/2021-04-v35-36-typescript-support.js +0 -290
  80. package/upgrades/utils/index.js +0 -17
@@ -1,290 +0,0 @@
1
- /* eslint-disable no-console */
2
- import { componentsPackageName, defaultPrintOptions, getLiteralType } from './utils';
3
-
4
- const Scroll = 'Scroll';
5
- const sizeCase = { old: 'Size', new: 'Size' };
6
- const priorityCase = { old: 'Priority', new: 'Priority' };
7
- const positionCase = { old: 'Position', new: 'Position' };
8
- const monthFormatCase = { old: 'MonthFormat', new: 'MonthFormat' };
9
- const layoutCase = { old: 'Layout', new: 'Layout' };
10
- const statusCase = { old: 'Status', new: 'Status' };
11
-
12
- const breakingChangesMap = [
13
- {
14
- component: 'Avatar',
15
- enums: [sizeCase, { old: 'Type', new: 'AvatarType' }, { old: 'Theme', new: 'Theme' }],
16
- },
17
- {
18
- component: 'Loader',
19
- enums: [sizeCase],
20
- },
21
- {
22
- component: 'Badge',
23
- enums: [sizeCase, { old: 'Border', new: 'Theme' }],
24
- },
25
- {
26
- component: 'Alert',
27
- enums: [
28
- { old: 'Type', new: 'Sentiment' },
29
- { old: 'ArrowPosition', new: 'AlertArrowPosition' },
30
- ],
31
- },
32
- {
33
- component: 'Button',
34
- enums: [priorityCase, sizeCase],
35
- },
36
- {
37
- component: 'Chevron',
38
- enums: [{ old: 'Orientation', new: 'Position' }, sizeCase],
39
- },
40
- {
41
- component: 'CircularButton',
42
- enums: [{ old: 'Type', new: 'ControlType' }, priorityCase],
43
- },
44
- {
45
- component: 'AvatarWrapper',
46
- enums: [{ old: 'ProfileType', new: 'ProfileType' }],
47
- },
48
- {
49
- component: 'DateInput',
50
- enums: [sizeCase, { old: 'DateMode', new: 'DateMode' }, monthFormatCase],
51
- },
52
- {
53
- component: 'DateLookup',
54
- enums: [sizeCase, monthFormatCase],
55
- },
56
- {
57
- component: 'Decision',
58
- enums: [
59
- { old: 'Presentation', new: 'DecisionPresentation' },
60
- { old: 'Type', new: 'DecisionType' },
61
- sizeCase,
62
- ],
63
- },
64
- {
65
- component: 'DefinitionList',
66
- enums: [layoutCase],
67
- },
68
- {
69
- component: 'Drawer',
70
- enums: [positionCase],
71
- },
72
- {
73
- component: 'DynamicFieldDefinitionList',
74
- enums: [layoutCase],
75
- },
76
- {
77
- component: 'Info',
78
- enums: [sizeCase, { old: 'Presentation', new: 'InfoPresentation' }],
79
- },
80
- {
81
- component: 'InlineAlert',
82
- enums: [{ old: 'Type', new: 'Sentiment' }],
83
- },
84
- {
85
- component: 'Modal',
86
- enums: [sizeCase, positionCase, { old: Scroll, new: Scroll }],
87
- },
88
- {
89
- component: 'PhoneNumberInput',
90
- enums: [sizeCase],
91
- },
92
- {
93
- component: 'Popover',
94
- enums: [{ old: 'Placement', new: 'Position' }],
95
- },
96
- {
97
- component: 'ProcessIndicator',
98
- enums: [statusCase, sizeCase],
99
- },
100
- {
101
- component: 'Summary',
102
- enums: [statusCase],
103
- },
104
- {
105
- component: 'Tabs',
106
- enums: [
107
- { old: 'SpacerSizes', new: 'Size' },
108
- { old: 'HeaderWidth', new: 'Width' },
109
- ],
110
- },
111
- {
112
- component: 'Tile',
113
- enums: [sizeCase],
114
- },
115
- {
116
- component: 'Tooltip',
117
- enums: [positionCase],
118
- },
119
- {
120
- component: 'Typeahead',
121
- enums: [sizeCase, { old: 'Type', new: 'Sentiment' }],
122
- },
123
- {
124
- component: 'Upload',
125
- enums: [{ old: 'UploadStep', new: 'UploadStep' }],
126
- },
127
- ];
128
-
129
- const ButtonTypeBreakingChange = {
130
- Type: ['PRIMARY', 'PAY', 'SECONDARY', 'DANGER', 'LINK'],
131
- ControlType: ['ACCENT', 'POSITIVE', 'NEGATIVE'],
132
- };
133
-
134
- export default function codemod(file, api, options) {
135
- const literalType = getLiteralType(options.parser);
136
- const j = api.jscodeshift;
137
- const fileTree = j(file.source);
138
-
139
- let hasModifications = false;
140
- breakingChangesMap.forEach(({ component, enums }) => {
141
- const componentImport = fileTree
142
- .find(j.ImportDeclaration, {
143
- source: {
144
- type: literalType,
145
- value: componentsPackageName,
146
- },
147
- })
148
- .find(j.Identifier, {
149
- name: component,
150
- });
151
-
152
- if (componentImport.size() > 0) {
153
- enums.forEach((enumItem) => {
154
- let newEnum = enumItem.new;
155
- fileTree
156
- .find(j.MemberExpression, {
157
- object: {
158
- type: 'Identifier',
159
- name: component,
160
- },
161
- property: {
162
- type: 'Identifier',
163
- name: enumItem.old,
164
- },
165
- })
166
- .replaceWith((node) => {
167
- hasModifications = true;
168
- // cover Button's edge case
169
- if (component === 'Button') {
170
- const enumItemValue = node.parentPath.node.property.name;
171
- if (
172
- enumItemValue === 'ACCENT' ||
173
- enumItemValue === 'POSITIVE' ||
174
- enumItemValue === 'NEGATIVE'
175
- ) {
176
- // use `ControlType` instead of `Type` in above cases
177
- newEnum = 'ControlType';
178
- }
179
- }
180
- return j.jsxIdentifier(newEnum);
181
- });
182
-
183
- if (hasModifications) {
184
- hasModifications = false;
185
- // check whether we already added this enum into import statement
186
- const enumImports = fileTree
187
- .find(j.ImportDeclaration, {
188
- source: {
189
- type: literalType,
190
- value: componentsPackageName,
191
- },
192
- })
193
- .find(j.Identifier, {
194
- name: newEnum,
195
- });
196
-
197
- if (enumImports.size() === 0) {
198
- // add import for `newEnum`
199
- fileTree
200
- .find(j.ImportDeclaration, {
201
- source: {
202
- type: literalType,
203
- value: componentsPackageName,
204
- },
205
- })
206
- .forEach((paths) => {
207
- paths.value.specifiers.push(j.importSpecifier(j.identifier(newEnum)));
208
- });
209
- }
210
-
211
- // do we still need import component?
212
- const isComponentNotUsedAtJsx =
213
- fileTree
214
- .find(j.JSXElement, {
215
- openingElement: {
216
- name: {
217
- type: 'JSXIdentifier',
218
- name: component,
219
- },
220
- },
221
- })
222
- .size() === 0;
223
-
224
- if (isComponentNotUsedAtJsx) {
225
- // delete component from import statement
226
- fileTree
227
- .find(j.ImportDeclaration, {
228
- source: {
229
- type: literalType,
230
- value: componentsPackageName,
231
- },
232
- })
233
- .find(j.Identifier, {
234
- name: component,
235
- })
236
- .remove();
237
- }
238
- }
239
- });
240
- }
241
- });
242
-
243
- [...ButtonTypeBreakingChange.Type, ...ButtonTypeBreakingChange.ControlType].forEach(
244
- (enumItemValue) => {
245
- fileTree
246
- .find(j.MemberExpression, {
247
- object: {
248
- property: {
249
- name: 'Type',
250
- },
251
- },
252
- property: {
253
- name: enumItemValue,
254
- },
255
- })
256
- .replaceWith(() => {
257
- // eslint-disable-next-line unicorn/prevent-abbreviations -- this is a useless rule, and useless application of it
258
- const newProp = ButtonTypeBreakingChange.Type.includes(enumItemValue)
259
- ? 'Type'
260
- : 'ControlType';
261
-
262
- const enumImports = fileTree
263
- .find(j.ImportDeclaration, {
264
- source: {
265
- type: literalType,
266
- value: componentsPackageName,
267
- },
268
- })
269
- .find(j.Identifier, {
270
- name: newProp,
271
- });
272
- if (enumImports.size() === 0) {
273
- fileTree
274
- .find(j.ImportDeclaration, {
275
- source: {
276
- type: literalType,
277
- value: componentsPackageName,
278
- },
279
- })
280
- .forEach((paths) => {
281
- paths.value.specifiers.push(j.importSpecifier(j.identifier(newProp)));
282
- });
283
- }
284
- return j.jsxIdentifier(`${newProp}.${enumItemValue}`);
285
- });
286
- },
287
- );
288
-
289
- return fileTree.toSource(defaultPrintOptions);
290
- }
@@ -1,17 +0,0 @@
1
- export const componentsPackageName = '@transferwise/components';
2
-
3
- export const defaultPrintOptions = {
4
- quote: 'single',
5
- trailingComma: true,
6
- };
7
-
8
- export function getLiteralType(parser) {
9
- return parser === 'tsx' ? 'StringLiteral' : 'Literal';
10
- }
11
-
12
- export const log = (verbose, message, level = 0) => {
13
- if (verbose >= level) {
14
- // eslint-disable-next-line no-undef
15
- api.report(`✨ ${message}`);
16
- }
17
- };