@sanity/ui-codemod 1.0.0-alpha.7 → 1.0.0-alpha.8
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/_chunks-es/grid.mods.js +48 -48
- package/dist/_chunks-es/grid.mods.js.map +1 -1
- package/dist/transforms/latest/stack/stack.js +1 -1
- package/dist/transforms/latest/stack/stack.js.map +1 -1
- package/package.json +1 -1
- package/src/transforms/latest/grid/grid.mods.ts +48 -48
- package/src/transforms/latest/grid/grid.test.ts +4 -4
- package/src/transforms/latest/stack/stack.test.ts +6 -6
- package/src/transforms/latest/stack/stack.ts +5 -1
|
@@ -30,54 +30,54 @@ const GRID_MODS = {
|
|
|
30
30
|
name: "gridTemplateColumns",
|
|
31
31
|
mapping: {
|
|
32
32
|
0: "0px",
|
|
33
|
-
1: "repeat(1, 1fr)",
|
|
34
|
-
2: "repeat(2, 1fr)",
|
|
35
|
-
3: "repeat(3, 1fr)",
|
|
36
|
-
4: "repeat(4, 1fr)",
|
|
37
|
-
5: "repeat(5, 1fr)",
|
|
38
|
-
6: "repeat(6, 1fr)",
|
|
39
|
-
7: "repeat(7, 1fr)",
|
|
40
|
-
8: "repeat(8, 1fr)",
|
|
41
|
-
9: "repeat(9, 1fr)",
|
|
42
|
-
10: "repeat(10, 1fr)",
|
|
43
|
-
11: "repeat(11, 1fr)",
|
|
44
|
-
12: "repeat(12, 1fr)"
|
|
33
|
+
1: "repeat(1, minmax(0, 1fr))",
|
|
34
|
+
2: "repeat(2, minmax(0, 1fr))",
|
|
35
|
+
3: "repeat(3, minmax(0, 1fr))",
|
|
36
|
+
4: "repeat(4, minmax(0, 1fr))",
|
|
37
|
+
5: "repeat(5, minmax(0, 1fr))",
|
|
38
|
+
6: "repeat(6, minmax(0, 1fr))",
|
|
39
|
+
7: "repeat(7, minmax(0, 1fr))",
|
|
40
|
+
8: "repeat(8, minmax(0, 1fr))",
|
|
41
|
+
9: "repeat(9, minmax(0, 1fr))",
|
|
42
|
+
10: "repeat(10, minmax(0, 1fr))",
|
|
43
|
+
11: "repeat(11, minmax(0, 1fr))",
|
|
44
|
+
12: "repeat(12, minmax(0, 1fr))"
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
gridTemplateColumns: {
|
|
48
48
|
type: "mapped-only",
|
|
49
49
|
mapping: {
|
|
50
50
|
0: "0px",
|
|
51
|
-
1: "repeat(1, 1fr)",
|
|
52
|
-
2: "repeat(2, 1fr)",
|
|
53
|
-
3: "repeat(3, 1fr)",
|
|
54
|
-
4: "repeat(4, 1fr)",
|
|
55
|
-
5: "repeat(5, 1fr)",
|
|
56
|
-
6: "repeat(6, 1fr)",
|
|
57
|
-
7: "repeat(7, 1fr)",
|
|
58
|
-
8: "repeat(8, 1fr)",
|
|
59
|
-
9: "repeat(9, 1fr)",
|
|
60
|
-
10: "repeat(10, 1fr)",
|
|
61
|
-
11: "repeat(11, 1fr)",
|
|
62
|
-
12: "repeat(12, 1fr)"
|
|
51
|
+
1: "repeat(1, minmax(0, 1fr))",
|
|
52
|
+
2: "repeat(2, minmax(0, 1fr))",
|
|
53
|
+
3: "repeat(3, minmax(0, 1fr))",
|
|
54
|
+
4: "repeat(4, minmax(0, 1fr))",
|
|
55
|
+
5: "repeat(5, minmax(0, 1fr))",
|
|
56
|
+
6: "repeat(6, minmax(0, 1fr))",
|
|
57
|
+
7: "repeat(7, minmax(0, 1fr))",
|
|
58
|
+
8: "repeat(8, minmax(0, 1fr))",
|
|
59
|
+
9: "repeat(9, minmax(0, 1fr))",
|
|
60
|
+
10: "repeat(10, minmax(0, 1fr))",
|
|
61
|
+
11: "repeat(11, minmax(0, 1fr))",
|
|
62
|
+
12: "repeat(12, minmax(0, 1fr))"
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
gridTemplateRows: {
|
|
66
66
|
type: "mapped-only",
|
|
67
67
|
mapping: {
|
|
68
68
|
0: "0px",
|
|
69
|
-
1: "repeat(1, 1fr)",
|
|
70
|
-
2: "repeat(2, 1fr)",
|
|
71
|
-
3: "repeat(3, 1fr)",
|
|
72
|
-
4: "repeat(4, 1fr)",
|
|
73
|
-
5: "repeat(5, 1fr)",
|
|
74
|
-
6: "repeat(6, 1fr)",
|
|
75
|
-
7: "repeat(7, 1fr)",
|
|
76
|
-
8: "repeat(8, 1fr)",
|
|
77
|
-
9: "repeat(9, 1fr)",
|
|
78
|
-
10: "repeat(10, 1fr)",
|
|
79
|
-
11: "repeat(11, 1fr)",
|
|
80
|
-
12: "repeat(12, 1fr)"
|
|
69
|
+
1: "repeat(1, minmax(0, 1fr))",
|
|
70
|
+
2: "repeat(2, minmax(0, 1fr))",
|
|
71
|
+
3: "repeat(3, minmax(0, 1fr))",
|
|
72
|
+
4: "repeat(4, minmax(0, 1fr))",
|
|
73
|
+
5: "repeat(5, minmax(0, 1fr))",
|
|
74
|
+
6: "repeat(6, minmax(0, 1fr))",
|
|
75
|
+
7: "repeat(7, minmax(0, 1fr))",
|
|
76
|
+
8: "repeat(8, minmax(0, 1fr))",
|
|
77
|
+
9: "repeat(9, minmax(0, 1fr))",
|
|
78
|
+
10: "repeat(10, minmax(0, 1fr))",
|
|
79
|
+
11: "repeat(11, minmax(0, 1fr))",
|
|
80
|
+
12: "repeat(12, minmax(0, 1fr))"
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
justifyContent: {
|
|
@@ -89,18 +89,18 @@ const GRID_MODS = {
|
|
|
89
89
|
name: "gridTemplateRows",
|
|
90
90
|
mapping: {
|
|
91
91
|
0: "0px",
|
|
92
|
-
1: "repeat(1, 1fr)",
|
|
93
|
-
2: "repeat(2, 1fr)",
|
|
94
|
-
3: "repeat(3, 1fr)",
|
|
95
|
-
4: "repeat(4, 1fr)",
|
|
96
|
-
5: "repeat(5, 1fr)",
|
|
97
|
-
6: "repeat(6, 1fr)",
|
|
98
|
-
7: "repeat(7, 1fr)",
|
|
99
|
-
8: "repeat(8, 1fr)",
|
|
100
|
-
9: "repeat(9, 1fr)",
|
|
101
|
-
10: "repeat(10, 1fr)",
|
|
102
|
-
11: "repeat(11, 1fr)",
|
|
103
|
-
12: "repeat(12, 1fr)"
|
|
92
|
+
1: "repeat(1, minmax(0, 1fr))",
|
|
93
|
+
2: "repeat(2, minmax(0, 1fr))",
|
|
94
|
+
3: "repeat(3, minmax(0, 1fr))",
|
|
95
|
+
4: "repeat(4, minmax(0, 1fr))",
|
|
96
|
+
5: "repeat(5, minmax(0, 1fr))",
|
|
97
|
+
6: "repeat(6, minmax(0, 1fr))",
|
|
98
|
+
7: "repeat(7, minmax(0, 1fr))",
|
|
99
|
+
8: "repeat(8, minmax(0, 1fr))",
|
|
100
|
+
9: "repeat(9, minmax(0, 1fr))",
|
|
101
|
+
10: "repeat(10, minmax(0, 1fr))",
|
|
102
|
+
11: "repeat(11, minmax(0, 1fr))",
|
|
103
|
+
12: "repeat(12, minmax(0, 1fr))"
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.mods.js","sources":["../../src/transforms/latest/grid/grid.mods.ts"],"sourcesContent":["import {LAYOUT_MODS} from '../../../constants/latest/layout-mods'\nimport type {AttributeMods} from '../../../types/AttributeMods'\n\n/** @internal */\nexport const GRID_MODS: AttributeMods = {\n ...LAYOUT_MODS,\n alignItems: {\n type: 'style-only',\n style: 'alignItems',\n },\n autoCols: {\n type: 'rename-only',\n name: 'gridAutoColumns',\n },\n autoFlow: {\n type: 'rename-only',\n name: 'gridAutoFlow',\n },\n autoRows: {\n type: 'rename-only',\n name: 'gridAutoRows',\n },\n flexDirection: {\n type: 'style-only',\n style: 'flexDirection',\n },\n flexWrap: {\n type: 'style-only',\n style: 'flexWrap',\n },\n columns: {\n type: 'rename-mapped',\n name: 'gridTemplateColumns',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, 1fr)',\n 2: 'repeat(2, 1fr)',\n 3: 'repeat(3, 1fr)',\n 4: 'repeat(4, 1fr)',\n 5: 'repeat(5, 1fr)',\n 6: 'repeat(6, 1fr)',\n 7: 'repeat(7, 1fr)',\n 8: 'repeat(8, 1fr)',\n 9: 'repeat(9, 1fr)',\n 10: 'repeat(10, 1fr)',\n 11: 'repeat(11, 1fr)',\n 12: 'repeat(12, 1fr)',\n },\n },\n gridTemplateColumns: {\n type: 'mapped-only',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, 1fr)',\n 2: 'repeat(2, 1fr)',\n 3: 'repeat(3, 1fr)',\n 4: 'repeat(4, 1fr)',\n 5: 'repeat(5, 1fr)',\n 6: 'repeat(6, 1fr)',\n 7: 'repeat(7, 1fr)',\n 8: 'repeat(8, 1fr)',\n 9: 'repeat(9, 1fr)',\n 10: 'repeat(10, 1fr)',\n 11: 'repeat(11, 1fr)',\n 12: 'repeat(12, 1fr)',\n },\n },\n gridTemplateRows: {\n type: 'mapped-only',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, 1fr)',\n 2: 'repeat(2, 1fr)',\n 3: 'repeat(3, 1fr)',\n 4: 'repeat(4, 1fr)',\n 5: 'repeat(5, 1fr)',\n 6: 'repeat(6, 1fr)',\n 7: 'repeat(7, 1fr)',\n 8: 'repeat(8, 1fr)',\n 9: 'repeat(9, 1fr)',\n 10: 'repeat(10, 1fr)',\n 11: 'repeat(11, 1fr)',\n 12: 'repeat(12, 1fr)',\n },\n },\n justifyContent: {\n type: 'style-only',\n style: 'justifyContent',\n },\n rows: {\n type: 'rename-mapped',\n name: 'gridTemplateRows',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, 1fr)',\n 2: 'repeat(2, 1fr)',\n 3: 'repeat(3, 1fr)',\n 4: 'repeat(4, 1fr)',\n 5: 'repeat(5, 1fr)',\n 6: 'repeat(6, 1fr)',\n 7: 'repeat(7, 1fr)',\n 8: 'repeat(8, 1fr)',\n 9: 'repeat(9, 1fr)',\n 10: 'repeat(10, 1fr)',\n 11: 'repeat(11, 1fr)',\n 12: 'repeat(12, 1fr)',\n },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,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,gBAAgB;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA,EAAA;AAAA,EAET,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"grid.mods.js","sources":["../../src/transforms/latest/grid/grid.mods.ts"],"sourcesContent":["import {LAYOUT_MODS} from '../../../constants/latest/layout-mods'\nimport type {AttributeMods} from '../../../types/AttributeMods'\n\n/** @internal */\nexport const GRID_MODS: AttributeMods = {\n ...LAYOUT_MODS,\n alignItems: {\n type: 'style-only',\n style: 'alignItems',\n },\n autoCols: {\n type: 'rename-only',\n name: 'gridAutoColumns',\n },\n autoFlow: {\n type: 'rename-only',\n name: 'gridAutoFlow',\n },\n autoRows: {\n type: 'rename-only',\n name: 'gridAutoRows',\n },\n flexDirection: {\n type: 'style-only',\n style: 'flexDirection',\n },\n flexWrap: {\n type: 'style-only',\n style: 'flexWrap',\n },\n columns: {\n type: 'rename-mapped',\n name: 'gridTemplateColumns',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, minmax(0, 1fr))',\n 2: 'repeat(2, minmax(0, 1fr))',\n 3: 'repeat(3, minmax(0, 1fr))',\n 4: 'repeat(4, minmax(0, 1fr))',\n 5: 'repeat(5, minmax(0, 1fr))',\n 6: 'repeat(6, minmax(0, 1fr))',\n 7: 'repeat(7, minmax(0, 1fr))',\n 8: 'repeat(8, minmax(0, 1fr))',\n 9: 'repeat(9, minmax(0, 1fr))',\n 10: 'repeat(10, minmax(0, 1fr))',\n 11: 'repeat(11, minmax(0, 1fr))',\n 12: 'repeat(12, minmax(0, 1fr))',\n },\n },\n gridTemplateColumns: {\n type: 'mapped-only',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, minmax(0, 1fr))',\n 2: 'repeat(2, minmax(0, 1fr))',\n 3: 'repeat(3, minmax(0, 1fr))',\n 4: 'repeat(4, minmax(0, 1fr))',\n 5: 'repeat(5, minmax(0, 1fr))',\n 6: 'repeat(6, minmax(0, 1fr))',\n 7: 'repeat(7, minmax(0, 1fr))',\n 8: 'repeat(8, minmax(0, 1fr))',\n 9: 'repeat(9, minmax(0, 1fr))',\n 10: 'repeat(10, minmax(0, 1fr))',\n 11: 'repeat(11, minmax(0, 1fr))',\n 12: 'repeat(12, minmax(0, 1fr))',\n },\n },\n gridTemplateRows: {\n type: 'mapped-only',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, minmax(0, 1fr))',\n 2: 'repeat(2, minmax(0, 1fr))',\n 3: 'repeat(3, minmax(0, 1fr))',\n 4: 'repeat(4, minmax(0, 1fr))',\n 5: 'repeat(5, minmax(0, 1fr))',\n 6: 'repeat(6, minmax(0, 1fr))',\n 7: 'repeat(7, minmax(0, 1fr))',\n 8: 'repeat(8, minmax(0, 1fr))',\n 9: 'repeat(9, minmax(0, 1fr))',\n 10: 'repeat(10, minmax(0, 1fr))',\n 11: 'repeat(11, minmax(0, 1fr))',\n 12: 'repeat(12, minmax(0, 1fr))',\n },\n },\n justifyContent: {\n type: 'style-only',\n style: 'justifyContent',\n },\n rows: {\n type: 'rename-mapped',\n name: 'gridTemplateRows',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, minmax(0, 1fr))',\n 2: 'repeat(2, minmax(0, 1fr))',\n 3: 'repeat(3, minmax(0, 1fr))',\n 4: 'repeat(4, minmax(0, 1fr))',\n 5: 'repeat(5, minmax(0, 1fr))',\n 6: 'repeat(6, minmax(0, 1fr))',\n 7: 'repeat(7, minmax(0, 1fr))',\n 8: 'repeat(8, minmax(0, 1fr))',\n 9: 'repeat(9, minmax(0, 1fr))',\n 10: 'repeat(10, minmax(0, 1fr))',\n 11: 'repeat(11, minmax(0, 1fr))',\n 12: 'repeat(12, minmax(0, 1fr))',\n },\n },\n}\n"],"names":[],"mappings":";AAIO,MAAM,YAA2B;AAAA,EACtC,GAAG;AAAA,EACH,YAAY;AAAA,IACV,MAAM;AAAA,IACN,OAAO;AAAA,EAAA;AAAA,EAET,UAAU;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,EAAA;AAAA,EAER,eAAe;AAAA,IACb,MAAM;AAAA,IACN,OAAO;AAAA,EAAA;AAAA,EAET,UAAU;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,EAAA;AAAA,EAET,SAAS;AAAA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,qBAAqB;AAAA,IACnB,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,kBAAkB;AAAA,IAChB,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,gBAAgB;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA,EAAA;AAAA,EAET,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAEJ;"}
|
|
@@ -40,7 +40,7 @@ function transform(fileInfo, api, options) {
|
|
|
40
40
|
element: "Flex",
|
|
41
41
|
callback: (path) => {
|
|
42
42
|
let changed = !1;
|
|
43
|
-
return addAttribute(j, path.node, "flexDirection", "column") && (changed = !0),
|
|
43
|
+
return transformAttributes(j, path, FLEX_MODS, FLEX_TODO_WARNING) && (changed = !0), addAttribute(j, path.node, "flexDirection", "column") && (changed = !0), addAttribute(j, path.node, "flexShrink", 0) && (changed = !0), changed;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
) && markChanged(), replaceElement(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.js","sources":["../../../../src/transforms/latest/stack/stack.mods.ts","../../../../src/transforms/latest/stack/stack.ts"],"sourcesContent":["import type {AttributeMods} from '../../../types/AttributeMods'\n\n/** @internal */\nexport const STACK_MODS: AttributeMods = {\n sizing: {\n type: 'remove',\n },\n space: {\n type: 'rename-only',\n name: 'gap',\n },\n}\n","import {type API, type FileInfo, type JSXElement} from 'jscodeshift'\n\nimport type {BaseOptions} from '../../../types/BaseOptions'\nimport {addAttribute} from '../../../utils/addAttribute'\nimport {getComponentLocalNames} from '../../../utils/getComponentLocalNames'\nimport {getStyledComponentAliases} from '../../../utils/getStyledComponentAliases'\nimport {replaceElement} from '../../../utils/replaceElement'\nimport {shouldTransformComponent} from '../../../utils/shouldTransformComponent'\nimport {transformAttributes} from '../../../utils/transformAttributes'\nimport {transformComponent} from '../../../utils/transformComponent'\nimport {transformImport} from '../../../utils/transformImport'\nimport {transformStyledComponents} from '../../../utils/transformStyledComponents'\nimport {FLEX_MODS} from '../flex/flex.mods'\nimport {STACK_MODS} from './stack.mods'\n\nconst STACK_TODO_WARNING = 'Please double check the Stack migration below'\nconst FLEX_TODO_WARNING = 'Please double check the Flex migration below'\nconst STYLED_TODO_WARNING = 'Please double check styled(Stack) migration below'\n\nfunction replaceWithFlex(attrs: JSXElement['openingElement']['attributes']) {\n if (!attrs) {\n return false\n }\n\n return attrs.some(\n (attr) =>\n attr.type === 'JSXAttribute' &&\n attr.name.type === 'JSXIdentifier' &&\n (attr.name.name.startsWith('padding') ||\n attr.name.name.startsWith('margin') ||\n attr.name.name.startsWith('overflow') ||\n attr.name.name.startsWith('flex') ||\n attr.name.name.endsWith('height') ||\n attr.name.name.endsWith('width')),\n )\n}\n\n/** @internal */\nexport default function transform(\n fileInfo: FileInfo,\n api: API,\n options?: BaseOptions,\n): string | undefined {\n const {fromPackage, toPackage} = options || {}\n\n return transformComponent(fileInfo, api, ({j, root, markChanged}) => {\n const localNames = getComponentLocalNames(j, root, 'Stack', options)\n const styledAliases = getStyledComponentAliases(\n j,\n root,\n 'Stack',\n fileInfo.path,\n localNames,\n options,\n )\n\n if (!shouldTransformComponent(j, root, 'Stack', localNames, options, styledAliases)) {\n return\n }\n\n if (transformImport(j, root, 'Stack', fromPackage, toPackage)) {\n markChanged()\n }\n\n if (\n replaceElement(\n j,\n root,\n (attrs) => replaceWithFlex(attrs),\n {\n element: 'Stack',\n localNames,\n },\n {\n element: 'Flex',\n callback: (path) => {\n let changed = false\n\n if (addAttribute(j, path.node, 'flexDirection', 'column')) {\n changed = true\n }\n\n if (
|
|
1
|
+
{"version":3,"file":"stack.js","sources":["../../../../src/transforms/latest/stack/stack.mods.ts","../../../../src/transforms/latest/stack/stack.ts"],"sourcesContent":["import type {AttributeMods} from '../../../types/AttributeMods'\n\n/** @internal */\nexport const STACK_MODS: AttributeMods = {\n sizing: {\n type: 'remove',\n },\n space: {\n type: 'rename-only',\n name: 'gap',\n },\n}\n","import {type API, type FileInfo, type JSXElement} from 'jscodeshift'\n\nimport type {BaseOptions} from '../../../types/BaseOptions'\nimport {addAttribute} from '../../../utils/addAttribute'\nimport {getComponentLocalNames} from '../../../utils/getComponentLocalNames'\nimport {getStyledComponentAliases} from '../../../utils/getStyledComponentAliases'\nimport {replaceElement} from '../../../utils/replaceElement'\nimport {shouldTransformComponent} from '../../../utils/shouldTransformComponent'\nimport {transformAttributes} from '../../../utils/transformAttributes'\nimport {transformComponent} from '../../../utils/transformComponent'\nimport {transformImport} from '../../../utils/transformImport'\nimport {transformStyledComponents} from '../../../utils/transformStyledComponents'\nimport {FLEX_MODS} from '../flex/flex.mods'\nimport {STACK_MODS} from './stack.mods'\n\nconst STACK_TODO_WARNING = 'Please double check the Stack migration below'\nconst FLEX_TODO_WARNING = 'Please double check the Flex migration below'\nconst STYLED_TODO_WARNING = 'Please double check styled(Stack) migration below'\n\nfunction replaceWithFlex(attrs: JSXElement['openingElement']['attributes']) {\n if (!attrs) {\n return false\n }\n\n return attrs.some(\n (attr) =>\n attr.type === 'JSXAttribute' &&\n attr.name.type === 'JSXIdentifier' &&\n (attr.name.name.startsWith('padding') ||\n attr.name.name.startsWith('margin') ||\n attr.name.name.startsWith('overflow') ||\n attr.name.name.startsWith('flex') ||\n attr.name.name.endsWith('height') ||\n attr.name.name.endsWith('width')),\n )\n}\n\n/** @internal */\nexport default function transform(\n fileInfo: FileInfo,\n api: API,\n options?: BaseOptions,\n): string | undefined {\n const {fromPackage, toPackage} = options || {}\n\n return transformComponent(fileInfo, api, ({j, root, markChanged}) => {\n const localNames = getComponentLocalNames(j, root, 'Stack', options)\n const styledAliases = getStyledComponentAliases(\n j,\n root,\n 'Stack',\n fileInfo.path,\n localNames,\n options,\n )\n\n if (!shouldTransformComponent(j, root, 'Stack', localNames, options, styledAliases)) {\n return\n }\n\n if (transformImport(j, root, 'Stack', fromPackage, toPackage)) {\n markChanged()\n }\n\n if (\n replaceElement(\n j,\n root,\n (attrs) => replaceWithFlex(attrs),\n {\n element: 'Stack',\n localNames,\n },\n {\n element: 'Flex',\n callback: (path) => {\n let changed = false\n\n if (transformAttributes(j, path, FLEX_MODS, FLEX_TODO_WARNING)) {\n changed = true\n }\n\n if (addAttribute(j, path.node, 'flexDirection', 'column')) {\n changed = true\n }\n\n if (addAttribute(j, path.node, 'flexShrink', 0)) {\n changed = true\n }\n\n return changed\n },\n },\n )\n ) {\n markChanged()\n }\n\n if (\n replaceElement(\n j,\n root,\n (attrs) => {\n return !replaceWithFlex(attrs)\n },\n {\n element: 'Stack',\n localNames,\n },\n {\n element: 'VStack',\n callback: (path) => transformAttributes(j, path, STACK_MODS, STACK_TODO_WARNING),\n },\n )\n ) {\n markChanged()\n }\n\n if (\n transformStyledComponents(j, root, styledAliases, (attrs) => !replaceWithFlex(attrs), {\n warning: STYLED_TODO_WARNING,\n callback: (path) => transformAttributes(j, path, STACK_MODS, STACK_TODO_WARNING),\n })\n ) {\n markChanged()\n }\n })\n}\n"],"names":[],"mappings":";;;;;AAGO,MAAM,aAA4B;AAAA,EACvC,QAAQ;AAAA,IACN,MAAM;AAAA,EAAA;AAAA,EAER,OAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,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eAIA;AAAA,MACE;AAAA,MACA;AAAA,MACA,CAAC,UACQ,CAAC,gBAAgB,KAAK;AAAA,MAE/B;AAAA,QACE,SAAS;AAAA,QACT;AAAA,MAAA;AAAA,MAEF;AAAA,QACE,SAAS;AAAA,QACT,UAAU,CAAC,SAAS,oBAAoB,GAAG,MAAM,YAAY,kBAAkB;AAAA,MAAA;AAAA,IACjF,KAGF,YAAA,GAIA,0BAA0B,GAAG,MAAM,eAAe,CAAC,UAAU,CAAC,gBAAgB,KAAK,GAAG;AAAA,MACpF,SAAS;AAAA,MACT,UAAU,CAAC,SAAS,oBAAoB,GAAG,MAAM,YAAY,kBAAkB;AAAA,IAAA,CAChF,KAED,YAAA;AAAA,EAEJ,CAAC;AACH;"}
|
package/package.json
CHANGED
|
@@ -33,54 +33,54 @@ export const GRID_MODS: AttributeMods = {
|
|
|
33
33
|
name: 'gridTemplateColumns',
|
|
34
34
|
mapping: {
|
|
35
35
|
0: '0px',
|
|
36
|
-
1: 'repeat(1, 1fr)',
|
|
37
|
-
2: 'repeat(2, 1fr)',
|
|
38
|
-
3: 'repeat(3, 1fr)',
|
|
39
|
-
4: 'repeat(4, 1fr)',
|
|
40
|
-
5: 'repeat(5, 1fr)',
|
|
41
|
-
6: 'repeat(6, 1fr)',
|
|
42
|
-
7: 'repeat(7, 1fr)',
|
|
43
|
-
8: 'repeat(8, 1fr)',
|
|
44
|
-
9: 'repeat(9, 1fr)',
|
|
45
|
-
10: 'repeat(10, 1fr)',
|
|
46
|
-
11: 'repeat(11, 1fr)',
|
|
47
|
-
12: 'repeat(12, 1fr)',
|
|
36
|
+
1: 'repeat(1, minmax(0, 1fr))',
|
|
37
|
+
2: 'repeat(2, minmax(0, 1fr))',
|
|
38
|
+
3: 'repeat(3, minmax(0, 1fr))',
|
|
39
|
+
4: 'repeat(4, minmax(0, 1fr))',
|
|
40
|
+
5: 'repeat(5, minmax(0, 1fr))',
|
|
41
|
+
6: 'repeat(6, minmax(0, 1fr))',
|
|
42
|
+
7: 'repeat(7, minmax(0, 1fr))',
|
|
43
|
+
8: 'repeat(8, minmax(0, 1fr))',
|
|
44
|
+
9: 'repeat(9, minmax(0, 1fr))',
|
|
45
|
+
10: 'repeat(10, minmax(0, 1fr))',
|
|
46
|
+
11: 'repeat(11, minmax(0, 1fr))',
|
|
47
|
+
12: 'repeat(12, minmax(0, 1fr))',
|
|
48
48
|
},
|
|
49
49
|
},
|
|
50
50
|
gridTemplateColumns: {
|
|
51
51
|
type: 'mapped-only',
|
|
52
52
|
mapping: {
|
|
53
53
|
0: '0px',
|
|
54
|
-
1: 'repeat(1, 1fr)',
|
|
55
|
-
2: 'repeat(2, 1fr)',
|
|
56
|
-
3: 'repeat(3, 1fr)',
|
|
57
|
-
4: 'repeat(4, 1fr)',
|
|
58
|
-
5: 'repeat(5, 1fr)',
|
|
59
|
-
6: 'repeat(6, 1fr)',
|
|
60
|
-
7: 'repeat(7, 1fr)',
|
|
61
|
-
8: 'repeat(8, 1fr)',
|
|
62
|
-
9: 'repeat(9, 1fr)',
|
|
63
|
-
10: 'repeat(10, 1fr)',
|
|
64
|
-
11: 'repeat(11, 1fr)',
|
|
65
|
-
12: 'repeat(12, 1fr)',
|
|
54
|
+
1: 'repeat(1, minmax(0, 1fr))',
|
|
55
|
+
2: 'repeat(2, minmax(0, 1fr))',
|
|
56
|
+
3: 'repeat(3, minmax(0, 1fr))',
|
|
57
|
+
4: 'repeat(4, minmax(0, 1fr))',
|
|
58
|
+
5: 'repeat(5, minmax(0, 1fr))',
|
|
59
|
+
6: 'repeat(6, minmax(0, 1fr))',
|
|
60
|
+
7: 'repeat(7, minmax(0, 1fr))',
|
|
61
|
+
8: 'repeat(8, minmax(0, 1fr))',
|
|
62
|
+
9: 'repeat(9, minmax(0, 1fr))',
|
|
63
|
+
10: 'repeat(10, minmax(0, 1fr))',
|
|
64
|
+
11: 'repeat(11, minmax(0, 1fr))',
|
|
65
|
+
12: 'repeat(12, minmax(0, 1fr))',
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
68
|
gridTemplateRows: {
|
|
69
69
|
type: 'mapped-only',
|
|
70
70
|
mapping: {
|
|
71
71
|
0: '0px',
|
|
72
|
-
1: 'repeat(1, 1fr)',
|
|
73
|
-
2: 'repeat(2, 1fr)',
|
|
74
|
-
3: 'repeat(3, 1fr)',
|
|
75
|
-
4: 'repeat(4, 1fr)',
|
|
76
|
-
5: 'repeat(5, 1fr)',
|
|
77
|
-
6: 'repeat(6, 1fr)',
|
|
78
|
-
7: 'repeat(7, 1fr)',
|
|
79
|
-
8: 'repeat(8, 1fr)',
|
|
80
|
-
9: 'repeat(9, 1fr)',
|
|
81
|
-
10: 'repeat(10, 1fr)',
|
|
82
|
-
11: 'repeat(11, 1fr)',
|
|
83
|
-
12: 'repeat(12, 1fr)',
|
|
72
|
+
1: 'repeat(1, minmax(0, 1fr))',
|
|
73
|
+
2: 'repeat(2, minmax(0, 1fr))',
|
|
74
|
+
3: 'repeat(3, minmax(0, 1fr))',
|
|
75
|
+
4: 'repeat(4, minmax(0, 1fr))',
|
|
76
|
+
5: 'repeat(5, minmax(0, 1fr))',
|
|
77
|
+
6: 'repeat(6, minmax(0, 1fr))',
|
|
78
|
+
7: 'repeat(7, minmax(0, 1fr))',
|
|
79
|
+
8: 'repeat(8, minmax(0, 1fr))',
|
|
80
|
+
9: 'repeat(9, minmax(0, 1fr))',
|
|
81
|
+
10: 'repeat(10, minmax(0, 1fr))',
|
|
82
|
+
11: 'repeat(11, minmax(0, 1fr))',
|
|
83
|
+
12: 'repeat(12, minmax(0, 1fr))',
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
86
|
justifyContent: {
|
|
@@ -92,18 +92,18 @@ export const GRID_MODS: AttributeMods = {
|
|
|
92
92
|
name: 'gridTemplateRows',
|
|
93
93
|
mapping: {
|
|
94
94
|
0: '0px',
|
|
95
|
-
1: 'repeat(1, 1fr)',
|
|
96
|
-
2: 'repeat(2, 1fr)',
|
|
97
|
-
3: 'repeat(3, 1fr)',
|
|
98
|
-
4: 'repeat(4, 1fr)',
|
|
99
|
-
5: 'repeat(5, 1fr)',
|
|
100
|
-
6: 'repeat(6, 1fr)',
|
|
101
|
-
7: 'repeat(7, 1fr)',
|
|
102
|
-
8: 'repeat(8, 1fr)',
|
|
103
|
-
9: 'repeat(9, 1fr)',
|
|
104
|
-
10: 'repeat(10, 1fr)',
|
|
105
|
-
11: 'repeat(11, 1fr)',
|
|
106
|
-
12: 'repeat(12, 1fr)',
|
|
95
|
+
1: 'repeat(1, minmax(0, 1fr))',
|
|
96
|
+
2: 'repeat(2, minmax(0, 1fr))',
|
|
97
|
+
3: 'repeat(3, minmax(0, 1fr))',
|
|
98
|
+
4: 'repeat(4, minmax(0, 1fr))',
|
|
99
|
+
5: 'repeat(5, minmax(0, 1fr))',
|
|
100
|
+
6: 'repeat(6, minmax(0, 1fr))',
|
|
101
|
+
7: 'repeat(7, minmax(0, 1fr))',
|
|
102
|
+
8: 'repeat(8, minmax(0, 1fr))',
|
|
103
|
+
9: 'repeat(9, minmax(0, 1fr))',
|
|
104
|
+
10: 'repeat(10, minmax(0, 1fr))',
|
|
105
|
+
11: 'repeat(11, minmax(0, 1fr))',
|
|
106
|
+
12: 'repeat(12, minmax(0, 1fr))',
|
|
107
107
|
},
|
|
108
108
|
},
|
|
109
109
|
}
|
|
@@ -53,8 +53,8 @@ defineInlineTest(
|
|
|
53
53
|
`,
|
|
54
54
|
`
|
|
55
55
|
<Grid
|
|
56
|
-
gridTemplateColumns="repeat(1, 1fr)"
|
|
57
|
-
gridTemplateRows="repeat(2, 1fr)"
|
|
56
|
+
gridTemplateColumns="repeat(1, minmax(0, 1fr))"
|
|
57
|
+
gridTemplateRows="repeat(2, minmax(0, 1fr))"
|
|
58
58
|
/>
|
|
59
59
|
`,
|
|
60
60
|
'updates grid props mapped values',
|
|
@@ -91,8 +91,8 @@ defineInlineTest(
|
|
|
91
91
|
`,
|
|
92
92
|
`
|
|
93
93
|
<Grid
|
|
94
|
-
gridTemplateColumns="repeat(1, 1fr)"
|
|
95
|
-
gridTemplateRows="repeat(2, 1fr)"
|
|
94
|
+
gridTemplateColumns="repeat(1, minmax(0, 1fr))"
|
|
95
|
+
gridTemplateRows="repeat(2, minmax(0, 1fr))"
|
|
96
96
|
/>
|
|
97
97
|
`,
|
|
98
98
|
'updates v3 grid props mapped values',
|
|
@@ -30,7 +30,7 @@ defineInlineTest(
|
|
|
30
30
|
`
|
|
31
31
|
import {Flex} from "@sanity/ui"
|
|
32
32
|
|
|
33
|
-
<Flex padding={2} flexDirection="column" />
|
|
33
|
+
<Flex padding={2} flexDirection="column" flexShrink={0} />
|
|
34
34
|
`,
|
|
35
35
|
'replaces Stack with Flex and updates import path based on fromPackage and toPackage',
|
|
36
36
|
)
|
|
@@ -66,7 +66,7 @@ defineInlineTest(
|
|
|
66
66
|
|
|
67
67
|
import { Flex } from "@sanity/ui";
|
|
68
68
|
|
|
69
|
-
<Flex margin={2} flexDirection="column" />
|
|
69
|
+
<Flex margin={2} flexDirection="column" flexShrink={0} />
|
|
70
70
|
`,
|
|
71
71
|
'replaces Stack and updates import path with multiple specifiers',
|
|
72
72
|
)
|
|
@@ -111,7 +111,7 @@ defineInlineTest(
|
|
|
111
111
|
|
|
112
112
|
<>
|
|
113
113
|
<VStack />
|
|
114
|
-
<Flex overflow="auto" flexDirection="column" />
|
|
114
|
+
<Flex overflow="auto" flexDirection="column" flexShrink={0} />
|
|
115
115
|
</>
|
|
116
116
|
`,
|
|
117
117
|
'replaces Stack with Flex and adds Flex import',
|
|
@@ -128,7 +128,7 @@ defineInlineTest(
|
|
|
128
128
|
`
|
|
129
129
|
import {Flex} from '@sanity/ui'
|
|
130
130
|
|
|
131
|
-
<Flex padding={1} flexDirection="column" />
|
|
131
|
+
<Flex padding={1} flexDirection="column" flexShrink={0} />
|
|
132
132
|
`,
|
|
133
133
|
'replaces Stack with Flex and removes Stack import',
|
|
134
134
|
)
|
|
@@ -142,7 +142,7 @@ defineInlineTest(
|
|
|
142
142
|
</Stack>
|
|
143
143
|
`,
|
|
144
144
|
`
|
|
145
|
-
<Flex padding={1} flexDirection="column">
|
|
145
|
+
<Flex padding={1} flexDirection="column" flexShrink={0}>
|
|
146
146
|
<span />
|
|
147
147
|
</Flex>
|
|
148
148
|
`,
|
|
@@ -156,7 +156,7 @@ defineInlineTest(
|
|
|
156
156
|
<Stack padding={1} width="fill" />
|
|
157
157
|
`,
|
|
158
158
|
`
|
|
159
|
-
<Flex padding={1} width="100%" flexDirection="column" />
|
|
159
|
+
<Flex padding={1} width="100%" flexDirection="column" flexShrink={0} />
|
|
160
160
|
`,
|
|
161
161
|
'replaces Stack with Flex and transforms attributes',
|
|
162
162
|
)
|
|
@@ -76,11 +76,15 @@ export default function transform(
|
|
|
76
76
|
callback: (path) => {
|
|
77
77
|
let changed = false
|
|
78
78
|
|
|
79
|
+
if (transformAttributes(j, path, FLEX_MODS, FLEX_TODO_WARNING)) {
|
|
80
|
+
changed = true
|
|
81
|
+
}
|
|
82
|
+
|
|
79
83
|
if (addAttribute(j, path.node, 'flexDirection', 'column')) {
|
|
80
84
|
changed = true
|
|
81
85
|
}
|
|
82
86
|
|
|
83
|
-
if (
|
|
87
|
+
if (addAttribute(j, path.node, 'flexShrink', 0)) {
|
|
84
88
|
changed = true
|
|
85
89
|
}
|
|
86
90
|
|