@workday/canvas-kit-codemod 14.0.0-alpha.1239-next.0 → 14.0.0-alpha.1251-next.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/dist/es6/v13.2/mapping/index.d.ts +2 -2
- package/dist/es6/v13.2/mapping/index.js +2 -2
- package/dist/es6/v14-tokens/baseMapping.d.ts +160 -0
- package/dist/es6/v14-tokens/baseMapping.d.ts.map +1 -0
- package/dist/es6/v14-tokens/baseMapping.js +159 -0
- package/dist/es6/v14-tokens/index.d.ts +4 -0
- package/dist/es6/v14-tokens/index.d.ts.map +1 -0
- package/dist/es6/v14-tokens/index.js +9 -0
- package/dist/es6/v14-tokens/migrateColorTokens.d.ts +4 -0
- package/dist/es6/v14-tokens/migrateColorTokens.d.ts.map +1 -0
- package/dist/es6/v14-tokens/migrateColorTokens.js +101 -0
- package/dist/es6/v14-tokens/utils/transformObjectPropertyRecursively.d.ts +4 -0
- package/dist/es6/v14-tokens/utils/transformObjectPropertyRecursively.d.ts.map +1 -0
- package/dist/es6/v14-tokens/utils/transformObjectPropertyRecursively.js +141 -0
- package/index.js +7 -0
- package/package.json +2 -2
|
@@ -201,7 +201,7 @@ export declare const systemColors: {
|
|
|
201
201
|
soap400: string;
|
|
202
202
|
soap500: string;
|
|
203
203
|
};
|
|
204
|
-
'color,fill,colorFocus,colorHover,colorActive,icon,iconColor': {
|
|
204
|
+
'color,fill,colorFocus,colorHover,colorActive,icon,iconColor,textShadow': {
|
|
205
205
|
blackPepper300: string;
|
|
206
206
|
blackPepper400: string;
|
|
207
207
|
blackPepper500: string;
|
|
@@ -215,7 +215,7 @@ export declare const systemColors: {
|
|
|
215
215
|
licorice400: string;
|
|
216
216
|
licorice500: string;
|
|
217
217
|
};
|
|
218
|
-
'border,borderColor,borderTopColor,borderRightColor,borderBottomColor,borderLeftColor,borderInlineColor,borderBlockColor,borderInlineStartColor,borderInlineEndColor,borderBlockStartColor,borderBlockEndColor,borderColorFocus,borderColorHover,borderColorActive': {
|
|
218
|
+
'border,borderColor,borderTopColor,borderRightColor,borderBottomColor,borderLeftColor,borderInline,borderInlineStart,borderInlineEnd,borderBlock,borderBlockStart,borderBlockEnd,borderInlineColor,borderBlockColor,borderInlineStartColor,borderInlineEndColor,borderBlockStartColor,borderBlockEndColor,borderColorFocus,borderColorHover,borderColorActive': {
|
|
219
219
|
blackPepper400: string;
|
|
220
220
|
blackPepper500: string;
|
|
221
221
|
blueberry400: string;
|
|
@@ -134,7 +134,7 @@ export const systemColors = {
|
|
|
134
134
|
soap400: 'system.color.bg.alt.strong',
|
|
135
135
|
soap500: 'system.color.bg.alt.stronger',
|
|
136
136
|
},
|
|
137
|
-
'color,fill,colorFocus,colorHover,colorActive,icon,iconColor': {
|
|
137
|
+
'color,fill,colorFocus,colorHover,colorActive,icon,iconColor,textShadow': {
|
|
138
138
|
blackPepper300: 'system.color.fg.default',
|
|
139
139
|
blackPepper400: 'system.color.fg.strong',
|
|
140
140
|
blackPepper500: 'system.color.fg.stronger',
|
|
@@ -148,7 +148,7 @@ export const systemColors = {
|
|
|
148
148
|
licorice400: 'system.color.fg.muted.strong',
|
|
149
149
|
licorice500: 'system.color.fg.muted.stronger',
|
|
150
150
|
},
|
|
151
|
-
'border,borderColor,borderTopColor,borderRightColor,borderBottomColor,borderLeftColor,borderInlineColor,borderBlockColor,borderInlineStartColor,borderInlineEndColor,borderBlockStartColor,borderBlockEndColor,borderColorFocus,borderColorHover,borderColorActive': {
|
|
151
|
+
'border,borderColor,borderTopColor,borderRightColor,borderBottomColor,borderLeftColor,borderInline,borderInlineStart,borderInlineEnd,borderBlock,borderBlockStart,borderBlockEnd,borderInlineColor,borderBlockColor,borderInlineStartColor,borderInlineEndColor,borderBlockStartColor,borderBlockEndColor,borderColorFocus,borderColorHover,borderColorActive': {
|
|
152
152
|
blackPepper400: 'system.color.border.contrast.default',
|
|
153
153
|
blackPepper500: 'system.color.border.contrast.strong',
|
|
154
154
|
blueberry400: 'system.color.border.primary.default',
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
declare const baseMapping: {
|
|
2
|
+
cinnamon100: string;
|
|
3
|
+
cinnamon200: string;
|
|
4
|
+
cinnamon300: string;
|
|
5
|
+
cinnamon400: string;
|
|
6
|
+
cinnamon500: string;
|
|
7
|
+
cinnamon600: string;
|
|
8
|
+
peach100: string;
|
|
9
|
+
peach200: string;
|
|
10
|
+
peach300: string;
|
|
11
|
+
peach400: string;
|
|
12
|
+
peach500: string;
|
|
13
|
+
peach600: string;
|
|
14
|
+
chiliMango100: string;
|
|
15
|
+
chiliMango200: string;
|
|
16
|
+
chiliMango300: string;
|
|
17
|
+
chiliMango400: string;
|
|
18
|
+
chiliMango500: string;
|
|
19
|
+
chiliMango600: string;
|
|
20
|
+
cantaloupe100: string;
|
|
21
|
+
cantaloupe200: string;
|
|
22
|
+
cantaloupe300: string;
|
|
23
|
+
cantaloupe400: string;
|
|
24
|
+
cantaloupe500: string;
|
|
25
|
+
cantaloupe600: string;
|
|
26
|
+
sourLemon100: string;
|
|
27
|
+
sourLemon200: string;
|
|
28
|
+
sourLemon300: string;
|
|
29
|
+
sourLemon400: string;
|
|
30
|
+
sourLemon500: string;
|
|
31
|
+
sourLemon600: string;
|
|
32
|
+
juicyPear100: string;
|
|
33
|
+
juicyPear200: string;
|
|
34
|
+
juicyPear300: string;
|
|
35
|
+
juicyPear400: string;
|
|
36
|
+
juicyPear500: string;
|
|
37
|
+
juicyPear600: string;
|
|
38
|
+
kiwi100: string;
|
|
39
|
+
kiwi200: string;
|
|
40
|
+
kiwi300: string;
|
|
41
|
+
kiwi400: string;
|
|
42
|
+
kiwi500: string;
|
|
43
|
+
kiwi600: string;
|
|
44
|
+
greenApple100: string;
|
|
45
|
+
greenApple200: string;
|
|
46
|
+
greenApple300: string;
|
|
47
|
+
greenApple400: string;
|
|
48
|
+
greenApple500: string;
|
|
49
|
+
greenApple600: string;
|
|
50
|
+
watermelon100: string;
|
|
51
|
+
watermelon200: string;
|
|
52
|
+
watermelon300: string;
|
|
53
|
+
watermelon400: string;
|
|
54
|
+
watermelon500: string;
|
|
55
|
+
watermelon600: string;
|
|
56
|
+
jewel100: string;
|
|
57
|
+
jewel200: string;
|
|
58
|
+
jewel300: string;
|
|
59
|
+
jewel400: string;
|
|
60
|
+
jewel500: string;
|
|
61
|
+
jewel600: string;
|
|
62
|
+
toothpaste100: string;
|
|
63
|
+
toothpaste200: string;
|
|
64
|
+
toothpaste300: string;
|
|
65
|
+
toothpaste400: string;
|
|
66
|
+
toothpaste500: string;
|
|
67
|
+
toothpaste600: string;
|
|
68
|
+
blueberry100: string;
|
|
69
|
+
blueberry200: string;
|
|
70
|
+
blueberry300: string;
|
|
71
|
+
blueberry400: string;
|
|
72
|
+
blueberry500: string;
|
|
73
|
+
blueberry600: string;
|
|
74
|
+
plum100: string;
|
|
75
|
+
plum200: string;
|
|
76
|
+
plum300: string;
|
|
77
|
+
plum400: string;
|
|
78
|
+
plum500: string;
|
|
79
|
+
plum600: string;
|
|
80
|
+
berrySmoothie100: string;
|
|
81
|
+
berrySmoothie200: string;
|
|
82
|
+
berrySmoothie300: string;
|
|
83
|
+
berrySmoothie400: string;
|
|
84
|
+
berrySmoothie500: string;
|
|
85
|
+
berrySmoothie600: string;
|
|
86
|
+
blackberry100: string;
|
|
87
|
+
blackberry200: string;
|
|
88
|
+
blackberry300: string;
|
|
89
|
+
blackberry400: string;
|
|
90
|
+
blackberry500: string;
|
|
91
|
+
blackberry600: string;
|
|
92
|
+
islandPunch100: string;
|
|
93
|
+
islandPunch200: string;
|
|
94
|
+
islandPunch300: string;
|
|
95
|
+
islandPunch400: string;
|
|
96
|
+
islandPunch500: string;
|
|
97
|
+
islandPunch600: string;
|
|
98
|
+
grapeSoda100: string;
|
|
99
|
+
grapeSoda200: string;
|
|
100
|
+
grapeSoda300: string;
|
|
101
|
+
grapeSoda400: string;
|
|
102
|
+
grapeSoda500: string;
|
|
103
|
+
grapeSoda600: string;
|
|
104
|
+
pomegranate100: string;
|
|
105
|
+
pomegranate200: string;
|
|
106
|
+
pomegranate300: string;
|
|
107
|
+
pomegranate400: string;
|
|
108
|
+
pomegranate500: string;
|
|
109
|
+
pomegranate600: string;
|
|
110
|
+
fruitPunch100: string;
|
|
111
|
+
fruitPunch200: string;
|
|
112
|
+
fruitPunch300: string;
|
|
113
|
+
fruitPunch400: string;
|
|
114
|
+
fruitPunch500: string;
|
|
115
|
+
fruitPunch600: string;
|
|
116
|
+
rootBeer100: string;
|
|
117
|
+
rootBeer200: string;
|
|
118
|
+
rootBeer300: string;
|
|
119
|
+
rootBeer400: string;
|
|
120
|
+
rootBeer500: string;
|
|
121
|
+
rootBeer600: string;
|
|
122
|
+
toastedMarshmallow100: string;
|
|
123
|
+
toastedMarshmallow200: string;
|
|
124
|
+
toastedMarshmallow300: string;
|
|
125
|
+
toastedMarshmallow400: string;
|
|
126
|
+
toastedMarshmallow500: string;
|
|
127
|
+
toastedMarshmallow600: string;
|
|
128
|
+
licorice100: string;
|
|
129
|
+
licorice200: string;
|
|
130
|
+
licorice300: string;
|
|
131
|
+
licorice400: string;
|
|
132
|
+
licorice500: string;
|
|
133
|
+
licorice600: string;
|
|
134
|
+
soap100: string;
|
|
135
|
+
soap200: string;
|
|
136
|
+
soap300: string;
|
|
137
|
+
soap400: string;
|
|
138
|
+
soap500: string;
|
|
139
|
+
soap600: string;
|
|
140
|
+
frenchVanilla100: string;
|
|
141
|
+
frenchVanilla200: string;
|
|
142
|
+
frenchVanilla300: string;
|
|
143
|
+
frenchVanilla400: string;
|
|
144
|
+
frenchVanilla500: string;
|
|
145
|
+
frenchVanilla600: string;
|
|
146
|
+
blackPepper100: string;
|
|
147
|
+
blackPepper200: string;
|
|
148
|
+
blackPepper300: string;
|
|
149
|
+
blackPepper400: string;
|
|
150
|
+
blackPepper500: string;
|
|
151
|
+
blackPepper600: string;
|
|
152
|
+
dragonFruit100: string;
|
|
153
|
+
dragonFruit200: string;
|
|
154
|
+
dragonFruit300: string;
|
|
155
|
+
dragonFruit400: string;
|
|
156
|
+
dragonFruit500: string;
|
|
157
|
+
dragonFruit600: string;
|
|
158
|
+
};
|
|
159
|
+
export default baseMapping;
|
|
160
|
+
//# sourceMappingURL=baseMapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseMapping.d.ts","sourceRoot":"","sources":["../../../lib/v14-tokens/baseMapping.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsLhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
const baseMapping = {
|
|
2
|
+
cinnamon100: 'red50',
|
|
3
|
+
cinnamon200: 'red100',
|
|
4
|
+
cinnamon300: 'red300',
|
|
5
|
+
cinnamon400: 'red400',
|
|
6
|
+
cinnamon500: 'red600',
|
|
7
|
+
cinnamon600: 'red700',
|
|
8
|
+
peach100: 'coral50',
|
|
9
|
+
peach200: 'coral200',
|
|
10
|
+
peach300: 'coral300',
|
|
11
|
+
peach400: 'red400',
|
|
12
|
+
peach500: 'coral600',
|
|
13
|
+
peach600: 'coral700',
|
|
14
|
+
chiliMango100: 'coral100',
|
|
15
|
+
chiliMango200: 'coral200',
|
|
16
|
+
chiliMango300: 'coral300',
|
|
17
|
+
chiliMango400: 'orange500',
|
|
18
|
+
chiliMango500: 'orange500',
|
|
19
|
+
chiliMango600: 'orange700',
|
|
20
|
+
cantaloupe100: 'amber50',
|
|
21
|
+
cantaloupe200: 'amber200',
|
|
22
|
+
cantaloupe300: 'amber300',
|
|
23
|
+
cantaloupe400: 'amber400',
|
|
24
|
+
cantaloupe500: 'amber500',
|
|
25
|
+
cantaloupe600: 'amber600',
|
|
26
|
+
sourLemon100: 'amber25',
|
|
27
|
+
sourLemon200: 'amber100',
|
|
28
|
+
sourLemon300: 'amber200',
|
|
29
|
+
sourLemon400: 'amber300',
|
|
30
|
+
sourLemon500: 'amber300',
|
|
31
|
+
sourLemon600: 'amber500',
|
|
32
|
+
juicyPear100: 'amber25',
|
|
33
|
+
juicyPear200: 'amber100',
|
|
34
|
+
juicyPear300: 'amber200',
|
|
35
|
+
juicyPear400: 'amber200',
|
|
36
|
+
juicyPear500: 'green500',
|
|
37
|
+
juicyPear600: 'green700',
|
|
38
|
+
kiwi100: 'green50',
|
|
39
|
+
kiwi200: 'green100',
|
|
40
|
+
kiwi300: 'green200',
|
|
41
|
+
kiwi400: 'green500',
|
|
42
|
+
kiwi500: 'green500',
|
|
43
|
+
kiwi600: 'green700',
|
|
44
|
+
greenApple100: 'green50',
|
|
45
|
+
greenApple200: 'green100',
|
|
46
|
+
greenApple300: 'green200',
|
|
47
|
+
greenApple400: 'green600',
|
|
48
|
+
greenApple500: 'green700',
|
|
49
|
+
greenApple600: 'green800',
|
|
50
|
+
watermelon100: 'teal25',
|
|
51
|
+
watermelon200: 'teal100',
|
|
52
|
+
watermelon300: 'green100',
|
|
53
|
+
watermelon400: 'green600',
|
|
54
|
+
watermelon500: 'green700',
|
|
55
|
+
watermelon600: 'green900',
|
|
56
|
+
jewel100: 'teal25',
|
|
57
|
+
jewel200: 'teal200',
|
|
58
|
+
jewel300: 'teal400',
|
|
59
|
+
jewel400: 'teal500',
|
|
60
|
+
jewel500: 'teal600',
|
|
61
|
+
jewel600: 'teal700',
|
|
62
|
+
toothpaste100: 'azure50',
|
|
63
|
+
toothpaste200: 'azure200',
|
|
64
|
+
toothpaste300: 'azure300',
|
|
65
|
+
toothpaste400: 'azure500',
|
|
66
|
+
toothpaste500: 'azure700',
|
|
67
|
+
toothpaste600: 'azure800',
|
|
68
|
+
blueberry100: 'blue100',
|
|
69
|
+
blueberry200: 'blue100',
|
|
70
|
+
blueberry300: 'blue400',
|
|
71
|
+
blueberry400: 'blue600',
|
|
72
|
+
blueberry500: 'blue700',
|
|
73
|
+
blueberry600: 'blue900',
|
|
74
|
+
plum100: 'blue100',
|
|
75
|
+
plum200: 'blue200',
|
|
76
|
+
plum300: 'blue400',
|
|
77
|
+
plum400: 'blue600',
|
|
78
|
+
plum500: 'blue700',
|
|
79
|
+
plum600: 'blue800',
|
|
80
|
+
berrySmoothie100: 'indigo50',
|
|
81
|
+
berrySmoothie200: 'indigo200',
|
|
82
|
+
berrySmoothie300: 'indigo400',
|
|
83
|
+
berrySmoothie400: 'indigo500',
|
|
84
|
+
berrySmoothie500: 'indigo700',
|
|
85
|
+
berrySmoothie600: 'indigo800',
|
|
86
|
+
blackberry100: 'indigo25',
|
|
87
|
+
blackberry200: 'indigo200',
|
|
88
|
+
blackberry300: 'indigo400',
|
|
89
|
+
blackberry400: 'indigo500',
|
|
90
|
+
blackberry500: 'indigo700',
|
|
91
|
+
blackberry600: 'indigo900',
|
|
92
|
+
islandPunch100: 'purple25',
|
|
93
|
+
islandPunch200: 'purple200',
|
|
94
|
+
islandPunch300: 'purple500',
|
|
95
|
+
islandPunch400: 'purple500',
|
|
96
|
+
islandPunch500: 'purple700',
|
|
97
|
+
islandPunch600: 'purple800',
|
|
98
|
+
grapeSoda100: 'magenta50',
|
|
99
|
+
grapeSoda200: 'magenta200',
|
|
100
|
+
grapeSoda300: 'purple400',
|
|
101
|
+
grapeSoda400: 'purple500',
|
|
102
|
+
grapeSoda500: 'purple600',
|
|
103
|
+
grapeSoda600: 'purple800',
|
|
104
|
+
pomegranate100: 'magenta50',
|
|
105
|
+
pomegranate200: 'magenta100',
|
|
106
|
+
pomegranate300: 'magenta500',
|
|
107
|
+
pomegranate400: 'magenta500',
|
|
108
|
+
pomegranate500: 'red700',
|
|
109
|
+
pomegranate600: 'red800',
|
|
110
|
+
fruitPunch100: 'red25',
|
|
111
|
+
fruitPunch200: 'red200',
|
|
112
|
+
fruitPunch300: 'red300',
|
|
113
|
+
fruitPunch400: 'red400',
|
|
114
|
+
fruitPunch500: 'red500',
|
|
115
|
+
fruitPunch600: 'red700',
|
|
116
|
+
rootBeer100: 'coral25',
|
|
117
|
+
rootBeer200: 'coral100',
|
|
118
|
+
rootBeer300: 'coral200',
|
|
119
|
+
rootBeer400: 'coral200',
|
|
120
|
+
rootBeer500: 'amber900',
|
|
121
|
+
rootBeer600: 'amber950',
|
|
122
|
+
toastedMarshmallow100: 'amber25',
|
|
123
|
+
toastedMarshmallow200: 'orange100',
|
|
124
|
+
toastedMarshmallow300: 'orange200',
|
|
125
|
+
toastedMarshmallow400: 'orange300',
|
|
126
|
+
toastedMarshmallow500: 'amber500',
|
|
127
|
+
toastedMarshmallow600: 'amber600',
|
|
128
|
+
licorice100: 'slate400',
|
|
129
|
+
licorice200: 'slate500',
|
|
130
|
+
licorice300: 'slate600',
|
|
131
|
+
licorice400: 'slate700',
|
|
132
|
+
licorice500: 'slate800',
|
|
133
|
+
licorice600: 'slate900',
|
|
134
|
+
soap100: 'slate25',
|
|
135
|
+
soap200: 'slate50',
|
|
136
|
+
soap300: 'slate100',
|
|
137
|
+
soap400: 'slate200',
|
|
138
|
+
soap500: 'slate300',
|
|
139
|
+
soap600: 'slate300',
|
|
140
|
+
frenchVanilla100: 'neutral0',
|
|
141
|
+
frenchVanilla200: 'neutral100',
|
|
142
|
+
frenchVanilla300: 'neutral200',
|
|
143
|
+
frenchVanilla400: 'neutral300',
|
|
144
|
+
frenchVanilla500: 'neutral400',
|
|
145
|
+
frenchVanilla600: 'neutral500',
|
|
146
|
+
blackPepper100: 'neutral500',
|
|
147
|
+
blackPepper200: 'neutral700',
|
|
148
|
+
blackPepper300: 'neutral900',
|
|
149
|
+
blackPepper400: 'neutral950',
|
|
150
|
+
blackPepper500: 'neutral975',
|
|
151
|
+
blackPepper600: 'neutral1000',
|
|
152
|
+
dragonFruit100: 'purple25',
|
|
153
|
+
dragonFruit200: 'purple100',
|
|
154
|
+
dragonFruit300: 'indigo500',
|
|
155
|
+
dragonFruit400: 'indigo600',
|
|
156
|
+
dragonFruit500: 'indigo700',
|
|
157
|
+
dragonFruit600: 'indigo800',
|
|
158
|
+
};
|
|
159
|
+
export default baseMapping;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/v14-tokens/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAMtC,QAAA,MAAM,SAAS,EAAE,SAGhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import migrateColorTokens from './migrateColorTokens';
|
|
2
|
+
import migrateDepthTokens from '../v13.2/migrateDepthTokens';
|
|
3
|
+
import migrateOtherTokens from '../v13.2/migrateOtherTokens';
|
|
4
|
+
import migrateTypeTokens from '../v13.2/migrateTypeTokens';
|
|
5
|
+
const transform = (file, api, options) => {
|
|
6
|
+
const fixes = [migrateColorTokens, migrateDepthTokens, migrateTypeTokens, migrateOtherTokens];
|
|
7
|
+
return fixes.reduce((source, fix) => fix({ ...file, source }, api, options), file.source);
|
|
8
|
+
};
|
|
9
|
+
export default transform;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrateColorTokens.d.ts","sourceRoot":"","sources":["../../../lib/v14-tokens/migrateColorTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAC,MAAM,aAAa,CAAC;AAclD,QAAA,MAAM,SAAS,EAAE,SAsIhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { addMissingImports, filterOutImports } from '../v13.2/utils';
|
|
2
|
+
import { transformObjectPropertyRecursively } from './utils/transformObjectPropertyRecursively';
|
|
3
|
+
import { mapping } from '../v13.2/mapping';
|
|
4
|
+
import baseMapping from './baseMapping';
|
|
5
|
+
const canvasImportSources = [
|
|
6
|
+
'@workday/canvas-kit-styling',
|
|
7
|
+
'@workday/canvas-kit-react/tokens',
|
|
8
|
+
'@workday/canvas-tokens-web',
|
|
9
|
+
];
|
|
10
|
+
const transform = (file, api) => {
|
|
11
|
+
const j = api.jscodeshift;
|
|
12
|
+
const root = j(file.source);
|
|
13
|
+
let importDeclaration = {};
|
|
14
|
+
const checkImport = (value) => Object.keys(importDeclaration).includes(value);
|
|
15
|
+
root
|
|
16
|
+
.find(j.ImportDeclaration, {
|
|
17
|
+
source: { value: (value) => canvasImportSources.includes(value) },
|
|
18
|
+
})
|
|
19
|
+
.forEach(nodePath => {
|
|
20
|
+
importDeclaration = { ...importDeclaration, ...filterOutImports(nodePath) };
|
|
21
|
+
});
|
|
22
|
+
if (!Object.values(importDeclaration).some(importedValue => importedValue === 'colors' || importedValue === 'base')) {
|
|
23
|
+
return root.toSource();
|
|
24
|
+
}
|
|
25
|
+
root
|
|
26
|
+
.find(j.CallExpression, {
|
|
27
|
+
callee: {
|
|
28
|
+
type: 'Identifier',
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
.forEach(nodePath => {
|
|
32
|
+
const name = nodePath.value.callee.name;
|
|
33
|
+
const stylesDeclaration = nodePath.value.arguments[0];
|
|
34
|
+
const isCanvasKitStyling = importDeclaration[name] === 'createStyles' || importDeclaration[name] === 'createStencil';
|
|
35
|
+
if (stylesDeclaration.type === 'ObjectExpression') {
|
|
36
|
+
stylesDeclaration.properties = stylesDeclaration.properties.map((prop) => transformObjectPropertyRecursively({ j, root }, prop, importDeclaration, isCanvasKitStyling));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
root.find(j.ObjectExpression).forEach(nodePath => {
|
|
40
|
+
nodePath.value.properties = nodePath.value.properties.map((prop) => transformObjectPropertyRecursively({ j, root }, prop, importDeclaration));
|
|
41
|
+
});
|
|
42
|
+
root
|
|
43
|
+
.find(j.MemberExpression, (value) => {
|
|
44
|
+
return (value.type === 'MemberExpression' &&
|
|
45
|
+
checkImport(value.object.name) &&
|
|
46
|
+
Object.keys(baseMapping).includes(value.property.name));
|
|
47
|
+
})
|
|
48
|
+
.replaceWith(nodePath => {
|
|
49
|
+
const mainWrapper = nodePath.value.object;
|
|
50
|
+
if (mainWrapper.type === 'Identifier' && importDeclaration[mainWrapper.name] !== 'type') {
|
|
51
|
+
const mainObject = mainWrapper;
|
|
52
|
+
const mainName = mainObject.name;
|
|
53
|
+
const lowestProperty = nodePath.value.property;
|
|
54
|
+
const importedName = importDeclaration[mainName];
|
|
55
|
+
const map = importedName === 'base' ? { type: 'base' } : mapping[importedName];
|
|
56
|
+
if (map.type === 'base' && lowestProperty.type === 'Identifier') {
|
|
57
|
+
const colorName = baseMapping[lowestProperty.name];
|
|
58
|
+
if (mainName === 'colors') {
|
|
59
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['base'] });
|
|
60
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-kit-styling', specifiers: ['cssVar'] });
|
|
61
|
+
return j.callExpression(j.identifier('cssVar'), [
|
|
62
|
+
j.memberExpression(j.identifier(map.type), j.identifier(colorName || lowestProperty.name)),
|
|
63
|
+
]);
|
|
64
|
+
}
|
|
65
|
+
if (mainName === 'base') {
|
|
66
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['base'] });
|
|
67
|
+
return j.memberExpression(j.identifier(map.type), j.identifier(colorName));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return nodePath;
|
|
72
|
+
});
|
|
73
|
+
// Filter out base imports if no base tokens are used
|
|
74
|
+
root
|
|
75
|
+
.find(j.ImportDeclaration, {
|
|
76
|
+
source: { value: (value) => canvasImportSources.includes(value) },
|
|
77
|
+
})
|
|
78
|
+
.forEach(nodePath => {
|
|
79
|
+
var _a;
|
|
80
|
+
nodePath.value.specifiers = (_a = nodePath.value.specifiers) === null || _a === void 0 ? void 0 : _a.filter(specifier => {
|
|
81
|
+
if (specifier.type === 'ImportSpecifier' && specifier.local) {
|
|
82
|
+
const localName = specifier.local.name.toString();
|
|
83
|
+
const importedName = specifier.imported.name.toString();
|
|
84
|
+
if (importedName === 'base') {
|
|
85
|
+
const nodes = root
|
|
86
|
+
.find(j.MemberExpression, {
|
|
87
|
+
object: {
|
|
88
|
+
type: 'Identifier',
|
|
89
|
+
name: localName,
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
.nodes();
|
|
93
|
+
return nodes.length;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
return root.toSource();
|
|
100
|
+
};
|
|
101
|
+
export default transform;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformObjectPropertyRecursively.d.ts","sourceRoot":"","sources":["../../../../lib/v14-tokens/utils/transformObjectPropertyRecursively.ts"],"names":[],"mappings":"AAiDA,eAAO,MAAM,kCAAkC,gBAClC,GAAG,YACJ,GAAG;;wBAEQ,OAAO,KAC3B,GAuNF,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { systemColors } from '../../v13.2/mapping';
|
|
2
|
+
import { addMissingImports } from '../../v13.2/utils/addMissingImports';
|
|
3
|
+
import { varToMemberExpression } from '../../v13.2/utils/varToMemberExpression';
|
|
4
|
+
import baseMapping from '../baseMapping';
|
|
5
|
+
const checkSystemColors = (property) => {
|
|
6
|
+
var _a;
|
|
7
|
+
return (_a = Object.entries(systemColors).find(([blockKey]) => blockKey
|
|
8
|
+
.split(',')
|
|
9
|
+
.some(prop => property.key.type === 'Identifier' && prop === property.key.name))) === null || _a === void 0 ? void 0 : _a[1];
|
|
10
|
+
};
|
|
11
|
+
const updateArguments = ({ j, root }, expr, property, importDeclaration) => {
|
|
12
|
+
return expr.arguments.map((arg) => {
|
|
13
|
+
var _a;
|
|
14
|
+
if (arg.type === 'MemberExpression' &&
|
|
15
|
+
arg.object.type === 'Identifier' &&
|
|
16
|
+
arg.property.type === 'Identifier') {
|
|
17
|
+
const tokens = (_a = Object.entries(systemColors).find(([blockKey]) => blockKey
|
|
18
|
+
.split(',')
|
|
19
|
+
.some(prop => property.key.type === 'Identifier' && prop === property.key.name))) === null || _a === void 0 ? void 0 : _a[1];
|
|
20
|
+
const colorToken = tokens === null || tokens === void 0 ? void 0 : tokens[arg.property.name];
|
|
21
|
+
if (colorToken &&
|
|
22
|
+
(importDeclaration[arg.object.name] === 'colors' ||
|
|
23
|
+
importDeclaration[arg.object.name] === 'base')) {
|
|
24
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['system'] });
|
|
25
|
+
return varToMemberExpression(j, colorToken);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return arg;
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
export const transformObjectPropertyRecursively = ({ j, root }, property, importDeclaration, isCanvasKitStyling) => {
|
|
32
|
+
var _a;
|
|
33
|
+
if (property.type === 'ObjectProperty' &&
|
|
34
|
+
property.key.type === 'Identifier' &&
|
|
35
|
+
property.value.type === 'MemberExpression' &&
|
|
36
|
+
property.value.object.type === 'Identifier' &&
|
|
37
|
+
property.value.property.type === 'Identifier') {
|
|
38
|
+
const cssProperty = property.key.name;
|
|
39
|
+
const tokens = (_a = Object.entries(systemColors).find(([blockKey]) => blockKey.split(',').some(prop => prop === cssProperty))) === null || _a === void 0 ? void 0 : _a[1];
|
|
40
|
+
const { property: value, object: { name }, } = property.value;
|
|
41
|
+
const colorToken = tokens === null || tokens === void 0 ? void 0 : tokens[value.name];
|
|
42
|
+
if (colorToken) {
|
|
43
|
+
if (importDeclaration[name] === 'colors') {
|
|
44
|
+
if (!isCanvasKitStyling) {
|
|
45
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-kit-styling', specifiers: ['cssVar'] });
|
|
46
|
+
}
|
|
47
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['system'] });
|
|
48
|
+
return j.objectProperty(j.identifier(cssProperty), isCanvasKitStyling
|
|
49
|
+
? varToMemberExpression(j, colorToken)
|
|
50
|
+
: j.callExpression(j.identifier('cssVar'), [varToMemberExpression(j, colorToken)]));
|
|
51
|
+
}
|
|
52
|
+
if (importDeclaration[property.value.object.name] === 'base') {
|
|
53
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['system'] });
|
|
54
|
+
return j.objectProperty(j.identifier(cssProperty), varToMemberExpression(j, colorToken));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const baseToken = baseMapping[property.value.property.name];
|
|
59
|
+
if (baseToken) {
|
|
60
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['base'] });
|
|
61
|
+
return j.objectProperty(j.identifier(cssProperty), j.memberExpression(j.identifier('base'), j.identifier(baseToken)));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return property;
|
|
65
|
+
}
|
|
66
|
+
if (property.value.type === 'CallExpression') {
|
|
67
|
+
property.value.arguments = updateArguments({ j, root }, property.value, property, importDeclaration);
|
|
68
|
+
}
|
|
69
|
+
if (property.type === 'ObjectProperty' && property.value.type === 'TemplateLiteral') {
|
|
70
|
+
const templateLiteral = property.value;
|
|
71
|
+
const transformedQuasis = templateLiteral.quasis.map((quasi) => quasi);
|
|
72
|
+
const transformedExpressions = templateLiteral.expressions.map((expr) => {
|
|
73
|
+
var _a;
|
|
74
|
+
if (expr.type === 'MemberExpression' &&
|
|
75
|
+
expr.object.type === 'Identifier' &&
|
|
76
|
+
expr.property.type === 'Identifier') {
|
|
77
|
+
const tokens = (_a = Object.entries(systemColors).find(([blockKey]) => blockKey.split(',').some(prop => prop === property.key.name))) === null || _a === void 0 ? void 0 : _a[1];
|
|
78
|
+
const colorToken = tokens === null || tokens === void 0 ? void 0 : tokens[expr.property.name];
|
|
79
|
+
if (colorToken) {
|
|
80
|
+
if (importDeclaration[expr.object.name] === 'colors') {
|
|
81
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-kit-styling', specifiers: ['cssVar'] });
|
|
82
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['system'] });
|
|
83
|
+
return j.callExpression(j.identifier('cssVar'), [
|
|
84
|
+
varToMemberExpression(j, colorToken),
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
87
|
+
if (importDeclaration[expr.object.name] === 'base') {
|
|
88
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['system'] });
|
|
89
|
+
return j.memberExpression(j.identifier('base'), j.identifier(colorToken));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (expr.type === 'CallExpression') {
|
|
94
|
+
expr.arguments = updateArguments({ j, root }, expr, property, importDeclaration);
|
|
95
|
+
}
|
|
96
|
+
return expr;
|
|
97
|
+
});
|
|
98
|
+
return j.objectProperty(property.key, j.templateLiteral(transformedQuasis, transformedExpressions));
|
|
99
|
+
}
|
|
100
|
+
if (property.type === 'ObjectProperty' && property.value.type === 'ConditionalExpression') {
|
|
101
|
+
const { test, consequent, alternate } = property.value;
|
|
102
|
+
const tokens = checkSystemColors(property);
|
|
103
|
+
let consequentNode = consequent;
|
|
104
|
+
let alternateNode = alternate;
|
|
105
|
+
if (consequent.type === 'MemberExpression' &&
|
|
106
|
+
consequent.object.type === 'Identifier' &&
|
|
107
|
+
consequent.property.type === 'Identifier') {
|
|
108
|
+
const consequentColorToken = tokens === null || tokens === void 0 ? void 0 : tokens[consequent.property.name];
|
|
109
|
+
if (consequentColorToken) {
|
|
110
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-kit-styling', specifiers: ['cssVar'] });
|
|
111
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['system'] });
|
|
112
|
+
consequentNode = j.callExpression(j.identifier('cssVar'), [
|
|
113
|
+
varToMemberExpression(j, consequentColorToken),
|
|
114
|
+
]);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (consequent.type === 'CallExpression') {
|
|
118
|
+
consequent.arguments = updateArguments({ j, root }, consequent, property, importDeclaration);
|
|
119
|
+
}
|
|
120
|
+
if (alternate.type === 'MemberExpression' &&
|
|
121
|
+
alternate.object.type === 'Identifier' &&
|
|
122
|
+
alternate.property.type === 'Identifier') {
|
|
123
|
+
const alternateColorToken = tokens === null || tokens === void 0 ? void 0 : tokens[alternate.property.name];
|
|
124
|
+
if (alternateColorToken) {
|
|
125
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-kit-styling', specifiers: ['cssVar'] });
|
|
126
|
+
addMissingImports({ j, root }, { importPath: '@workday/canvas-tokens-web', specifiers: ['system'] });
|
|
127
|
+
alternateNode = j.callExpression(j.identifier('cssVar'), [
|
|
128
|
+
varToMemberExpression(j, alternateColorToken),
|
|
129
|
+
]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (alternate.type === 'CallExpression') {
|
|
133
|
+
alternate.arguments = updateArguments({ j, root }, alternate, property, importDeclaration);
|
|
134
|
+
}
|
|
135
|
+
return j.objectProperty(property.key, j.conditionalExpression(test, consequentNode, alternateNode));
|
|
136
|
+
}
|
|
137
|
+
if (property.type === 'ObjectProperty' && property.value.type === 'ObjectExpression') {
|
|
138
|
+
return j.objectProperty(property.key, j.objectExpression(property.value.properties.map((prop) => transformObjectPropertyRecursively({ j, root }, prop, importDeclaration, isCanvasKitStyling))));
|
|
139
|
+
}
|
|
140
|
+
return property;
|
|
141
|
+
};
|
package/index.js
CHANGED
|
@@ -102,6 +102,13 @@ const {
|
|
|
102
102
|
describe: chalk.gray('The path to execute the transform in (recursively).'),
|
|
103
103
|
});
|
|
104
104
|
})
|
|
105
|
+
.command('v14-tokens [path]', chalk.gray('Canvas Kit v13 > v14 upgrade transform'), yargs => {
|
|
106
|
+
yargs.positional('path', {
|
|
107
|
+
type: 'string',
|
|
108
|
+
default: '.',
|
|
109
|
+
describe: chalk.gray('The path to execute the transform in (recursively).'),
|
|
110
|
+
});
|
|
111
|
+
})
|
|
105
112
|
.demandCommand(1, chalk.red.bold('You must provide a transform to apply.'))
|
|
106
113
|
.strictCommands()
|
|
107
114
|
.fail((msg, err, yargs) => {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@workday/canvas-kit-codemod",
|
|
3
3
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "14.0.0-alpha.
|
|
5
|
+
"version": "14.0.0-alpha.1251-next.0",
|
|
6
6
|
"description": "A collection of codemods for use on Workday Canvas Kit packages.",
|
|
7
7
|
"main": "dist/es6/index.js",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"resolutions": {
|
|
47
47
|
"recast": "0.20.4"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "74f6a6aa07c8b1689b37208aed829b22b162acf0"
|
|
50
50
|
}
|