vuetify-codemods 1.0.2 → 1.0.4
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/main.js +109 -3
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -94402,7 +94402,7 @@ var __export = (target, all) => {
|
|
|
94402
94402
|
var builders_exports = {};
|
|
94403
94403
|
__export(builders_exports, {
|
|
94404
94404
|
htmlComment: () => htmlComment,
|
|
94405
|
-
setParents: () => setParents,
|
|
94405
|
+
setParents: () => setParents$1,
|
|
94406
94406
|
vAttribute: () => vAttribute,
|
|
94407
94407
|
vDirective: () => vDirective,
|
|
94408
94408
|
vDirectiveKey: () => vDirectiveKey,
|
|
@@ -94641,7 +94641,7 @@ var traverseNodes = (node2, visitor2) => {
|
|
|
94641
94641
|
leaveNode: visitor2.leaveNode ?? noop
|
|
94642
94642
|
});
|
|
94643
94643
|
};
|
|
94644
|
-
function setParents(node2) {
|
|
94644
|
+
function setParents$1(node2) {
|
|
94645
94645
|
traverseNodes(node2, {
|
|
94646
94646
|
enterNode(innerNode, parent) {
|
|
94647
94647
|
innerNode.parent = parent;
|
|
@@ -95218,7 +95218,7 @@ function transformVueFile(code2, filename, codemods, opts) {
|
|
|
95218
95218
|
stats.push([codemod.name, count]);
|
|
95219
95219
|
}
|
|
95220
95220
|
if (templateAst && originalTemplate) {
|
|
95221
|
-
setParents(templateAst);
|
|
95221
|
+
setParents$1(templateAst);
|
|
95222
95222
|
let scriptIndex = 0;
|
|
95223
95223
|
let styleIndex = 0;
|
|
95224
95224
|
traverseNodes(templateAst, {
|
|
@@ -95858,6 +95858,11 @@ function replaceChildNode(parent, oldChild, newChild) {
|
|
|
95858
95858
|
}
|
|
95859
95859
|
return false;
|
|
95860
95860
|
}
|
|
95861
|
+
function setParents(node2, builders2) {
|
|
95862
|
+
const parent = node2.parent;
|
|
95863
|
+
builders2.setParents(node2);
|
|
95864
|
+
node2.parent = parent;
|
|
95865
|
+
}
|
|
95861
95866
|
const v4ComboboxItemSlotPlugin = {
|
|
95862
95867
|
type: "codemod",
|
|
95863
95868
|
name: "vuetify-4-combobox-item-slot",
|
|
@@ -96010,6 +96015,103 @@ const v4ElevationPlugin = {
|
|
|
96010
96015
|
return count;
|
|
96011
96016
|
}
|
|
96012
96017
|
};
|
|
96018
|
+
const v4FormSlotRefsPlugin = {
|
|
96019
|
+
type: "codemod",
|
|
96020
|
+
name: "vuetify-4-form-slot-refs",
|
|
96021
|
+
transform({ sfcAST }) {
|
|
96022
|
+
if (!sfcAST) return 0;
|
|
96023
|
+
let count = 0;
|
|
96024
|
+
const slotNodes = findSlotNodes(sfcAST, ["VForm"], ["default"]);
|
|
96025
|
+
for (const node2 of slotNodes) {
|
|
96026
|
+
const refs = findSlotPropReferences(
|
|
96027
|
+
node2,
|
|
96028
|
+
["errors", "isDisabled", "isReadonly", "isValidating", "isValid", "items"]
|
|
96029
|
+
);
|
|
96030
|
+
for (const ref of refs) {
|
|
96031
|
+
count += removeDotMember(ref.reference, "value");
|
|
96032
|
+
}
|
|
96033
|
+
}
|
|
96034
|
+
return count;
|
|
96035
|
+
}
|
|
96036
|
+
};
|
|
96037
|
+
const breakpoints = ["sm", "md", "lg", "xl", "xxl"];
|
|
96038
|
+
const v4GridPlugin = {
|
|
96039
|
+
type: "codemod",
|
|
96040
|
+
name: "vuetify-4-grid",
|
|
96041
|
+
transform({ sfcAST, utils: utils2 }) {
|
|
96042
|
+
if (!sfcAST) return 0;
|
|
96043
|
+
let count = 0;
|
|
96044
|
+
const { builders: builders2 } = utils2;
|
|
96045
|
+
const elements = ast_helpers_exports.findAll(sfcAST, { type: "VElement" });
|
|
96046
|
+
for (const el of elements) {
|
|
96047
|
+
const tag = el.rawName;
|
|
96048
|
+
if (classify(tag) === "VRow") {
|
|
96049
|
+
const denseAttr = getStaticAttr(el, "dense");
|
|
96050
|
+
if (denseAttr) {
|
|
96051
|
+
const idx = el.startTag.attributes.indexOf(denseAttr);
|
|
96052
|
+
el.startTag.attributes.splice(
|
|
96053
|
+
idx,
|
|
96054
|
+
1,
|
|
96055
|
+
builders2.vAttribute(
|
|
96056
|
+
builders2.vIdentifier("density"),
|
|
96057
|
+
builders2.vLiteral("compact")
|
|
96058
|
+
)
|
|
96059
|
+
);
|
|
96060
|
+
setParents(el.startTag, builders2);
|
|
96061
|
+
count++;
|
|
96062
|
+
}
|
|
96063
|
+
for (const prop of ["align", "justify", "align-content"]) {
|
|
96064
|
+
if (propToClass(el, prop, prop, builders2)) count++;
|
|
96065
|
+
for (const bp of breakpoints) {
|
|
96066
|
+
if (propToClass(el, `${prop}-${bp}`, `${prop}-${bp}`, builders2)) count++;
|
|
96067
|
+
}
|
|
96068
|
+
}
|
|
96069
|
+
}
|
|
96070
|
+
if (classify(tag) === "VCol") {
|
|
96071
|
+
if (propToClass(el, "order", "order", builders2)) count++;
|
|
96072
|
+
for (const bp of breakpoints) {
|
|
96073
|
+
if (propToClass(el, `order-${bp}`, `order-${bp}`, builders2)) count++;
|
|
96074
|
+
}
|
|
96075
|
+
if (propToClass(el, "align-self", "align-self", builders2)) count++;
|
|
96076
|
+
}
|
|
96077
|
+
}
|
|
96078
|
+
return count;
|
|
96079
|
+
}
|
|
96080
|
+
};
|
|
96081
|
+
function getStaticAttr(el, name) {
|
|
96082
|
+
return el.startTag.attributes.find(
|
|
96083
|
+
(a3) => !a3.directive && a3.key.name === name
|
|
96084
|
+
);
|
|
96085
|
+
}
|
|
96086
|
+
function removeAttr(el, name) {
|
|
96087
|
+
const idx = el.startTag.attributes.findIndex(
|
|
96088
|
+
(a3) => !a3.directive && a3.key.name === name
|
|
96089
|
+
);
|
|
96090
|
+
if (~idx) el.startTag.attributes.splice(idx, 1);
|
|
96091
|
+
}
|
|
96092
|
+
function appendStaticClass(el, cls, builders2) {
|
|
96093
|
+
const attr = getStaticAttr(el, "class");
|
|
96094
|
+
if (attr?.value) {
|
|
96095
|
+
if (attr.value.type === "VLiteral") {
|
|
96096
|
+
attr.value.value = attr.value.value ? `${attr.value.value} ${cls}` : cls;
|
|
96097
|
+
}
|
|
96098
|
+
} else {
|
|
96099
|
+
el.startTag.attributes.unshift(
|
|
96100
|
+
builders2.vAttribute(
|
|
96101
|
+
builders2.vIdentifier("class"),
|
|
96102
|
+
builders2.vLiteral(cls)
|
|
96103
|
+
)
|
|
96104
|
+
);
|
|
96105
|
+
setParents(el.startTag, builders2);
|
|
96106
|
+
}
|
|
96107
|
+
}
|
|
96108
|
+
function propToClass(el, propName, classPrefix, builders2) {
|
|
96109
|
+
const attr = getStaticAttr(el, propName);
|
|
96110
|
+
if (attr?.value?.type !== "VLiteral" || !attr.value.value) return false;
|
|
96111
|
+
appendStaticClass(el, `${classPrefix}-${attr.value.value}`, builders2);
|
|
96112
|
+
removeAttr(el, propName);
|
|
96113
|
+
return true;
|
|
96114
|
+
}
|
|
96013
96115
|
const v4SnackbarMultilinePlugin = {
|
|
96014
96116
|
type: "codemod",
|
|
96015
96117
|
name: "vuetify-4-snackbar-multiline",
|
|
@@ -96030,6 +96132,7 @@ const v4SnackbarMultilinePlugin = {
|
|
|
96030
96132
|
node2.startTag.attributes.push(
|
|
96031
96133
|
builders2.vAttribute(builders2.vIdentifier("min-height"), builders2.vLiteral("68"))
|
|
96032
96134
|
);
|
|
96135
|
+
setParents(node2.startTag, builders2);
|
|
96033
96136
|
}
|
|
96034
96137
|
count++;
|
|
96035
96138
|
break;
|
|
@@ -96052,6 +96155,7 @@ const v4SnackbarQueueSlotPlugin = {
|
|
|
96052
96155
|
if (!node2.key.argument) {
|
|
96053
96156
|
node2.key.name.rawName = "#";
|
|
96054
96157
|
node2.key.argument = builders2.vIdentifier("item");
|
|
96158
|
+
setParents(node2.key, builders2);
|
|
96055
96159
|
count++;
|
|
96056
96160
|
} else if (node2.key.argument.type === "VIdentifier") {
|
|
96057
96161
|
node2.key.argument.rawName = "item";
|
|
@@ -96101,6 +96205,8 @@ function vuetify4() {
|
|
|
96101
96205
|
return [
|
|
96102
96206
|
v4ComboboxItemSlotPlugin,
|
|
96103
96207
|
v4ElevationPlugin,
|
|
96208
|
+
v4FormSlotRefsPlugin,
|
|
96209
|
+
v4GridPlugin,
|
|
96104
96210
|
v4SnackbarMultilinePlugin,
|
|
96105
96211
|
v4SnackbarQueueSlotPlugin,
|
|
96106
96212
|
v4TypographyPlugin
|