vuetify-codemods 1.0.3 → 1.0.5
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 +48 -39
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -47982,15 +47982,15 @@ function requireBack() {
|
|
|
47982
47982
|
back.default = arr_back;
|
|
47983
47983
|
return back;
|
|
47984
47984
|
}
|
|
47985
|
-
var matcher = {};
|
|
47985
|
+
var matcher$1 = {};
|
|
47986
47986
|
var hasRequiredMatcher;
|
|
47987
47987
|
function requireMatcher() {
|
|
47988
|
-
if (hasRequiredMatcher) return matcher;
|
|
47988
|
+
if (hasRequiredMatcher) return matcher$1;
|
|
47989
47989
|
hasRequiredMatcher = 1;
|
|
47990
|
-
var __importDefault2 = matcher && matcher.__importDefault || function(mod) {
|
|
47990
|
+
var __importDefault2 = matcher$1 && matcher$1.__importDefault || function(mod) {
|
|
47991
47991
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
47992
47992
|
};
|
|
47993
|
-
Object.defineProperty(matcher, "__esModule", { value: true });
|
|
47993
|
+
Object.defineProperty(matcher$1, "__esModule", { value: true });
|
|
47994
47994
|
const type_12 = __importDefault2(/* @__PURE__ */ requireType$1());
|
|
47995
47995
|
function isTag(node2) {
|
|
47996
47996
|
return node2 && node2.nodeType === type_12.default.ELEMENT_NODE;
|
|
@@ -48073,7 +48073,7 @@ function requireMatcher() {
|
|
|
48073
48073
|
}
|
|
48074
48074
|
return result2;
|
|
48075
48075
|
}
|
|
48076
|
-
matcher.default = {
|
|
48076
|
+
matcher$1.default = {
|
|
48077
48077
|
isTag,
|
|
48078
48078
|
getAttributeValue,
|
|
48079
48079
|
getName,
|
|
@@ -48087,7 +48087,7 @@ function requireMatcher() {
|
|
|
48087
48087
|
findOne,
|
|
48088
48088
|
findAll: findAll2
|
|
48089
48089
|
};
|
|
48090
|
-
return matcher;
|
|
48090
|
+
return matcher$1;
|
|
48091
48091
|
}
|
|
48092
48092
|
var voidTag = {};
|
|
48093
48093
|
var hasRequiredVoidTag;
|
|
@@ -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, {
|
|
@@ -95800,7 +95800,7 @@ const classProps = /* @__PURE__ */ new Map([
|
|
|
95800
95800
|
["VWindowItem", "selectedClass"]
|
|
95801
95801
|
]);
|
|
95802
95802
|
function findClassNodes(ast, utils2, match2) {
|
|
95803
|
-
const
|
|
95803
|
+
const matchingRegexp = new RegExp(String.raw`(^|\s)(?:${match2.join("|")})(?=$|\s)`);
|
|
95804
95804
|
const results = [];
|
|
95805
95805
|
const attrs = ast_helpers_exports.findAll(ast, { type: "VAttribute" });
|
|
95806
95806
|
for (const node2 of attrs) {
|
|
@@ -95823,15 +95823,15 @@ function findClassNodes(ast, utils2, match2) {
|
|
|
95823
95823
|
if (!node2.value) continue;
|
|
95824
95824
|
utils2.traverseTemplateAST(node2.value, {
|
|
95825
95825
|
enterNode(node22) {
|
|
95826
|
-
if ((node22.type === "VLiteral" || node22.type === "Literal") && typeof node22.value === "string" &&
|
|
95826
|
+
if ((node22.type === "VLiteral" || node22.type === "Literal") && typeof node22.value === "string" && matchingRegexp.test(node22.value)) {
|
|
95827
95827
|
results.push(node22);
|
|
95828
|
-
} else if (node22.type === "Property" && (node22.key.type === "Literal" || node22.key.type === "Identifier" && !node22.computed)) {
|
|
95828
|
+
} else if (node22.type === "Property" && (node22.key.type === "Literal" && typeof node22.key.value === "string" && matchingRegexp.test(node22.key.value) || node22.key.type === "Identifier" && !node22.computed && matchingRegexp.test(node22.key.name))) {
|
|
95829
95829
|
results.push(node22.key);
|
|
95830
95830
|
}
|
|
95831
95831
|
}
|
|
95832
95832
|
});
|
|
95833
95833
|
}
|
|
95834
|
-
return results;
|
|
95834
|
+
return { results, matchingRegexp: new RegExp(matchingRegexp, "g") };
|
|
95835
95835
|
}
|
|
95836
95836
|
function removeDotMember(ref, name) {
|
|
95837
95837
|
let current = ref;
|
|
@@ -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",
|
|
@@ -95975,20 +95980,19 @@ const elevationComponents = /* @__PURE__ */ new Set([
|
|
|
95975
95980
|
]);
|
|
95976
95981
|
const mapping = [0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5];
|
|
95977
95982
|
const elevationMatch = String.raw`elevation-(\d{1,2})`;
|
|
95978
|
-
const elevationRegexp = new RegExp(String.raw`(^|\s)${elevationMatch}(?=$|\s)`, "g");
|
|
95979
95983
|
const v4ElevationPlugin = {
|
|
95980
95984
|
type: "codemod",
|
|
95981
95985
|
name: "vuetify-4-elevation",
|
|
95982
95986
|
transform({ sfcAST, utils: utils2 }) {
|
|
95983
95987
|
if (!sfcAST) return 0;
|
|
95984
95988
|
let count = 0;
|
|
95985
|
-
const
|
|
95986
|
-
for (const node2 of
|
|
95989
|
+
const { results, matchingRegexp } = findClassNodes(sfcAST, utils2, [elevationMatch]);
|
|
95990
|
+
for (const node2 of results) {
|
|
95987
95991
|
if (node2.type === "Identifier") {
|
|
95988
|
-
node2.name = node2.name.replaceAll(
|
|
95992
|
+
node2.name = node2.name.replaceAll(matchingRegexp, (_, s2, n2) => `${s2}elevation-${mapping[Number(n2)]}`);
|
|
95989
95993
|
count++;
|
|
95990
95994
|
} else if (typeof node2.value === "string") {
|
|
95991
|
-
node2.value = node2.value.replaceAll(
|
|
95995
|
+
node2.value = node2.value.replaceAll(matchingRegexp, (_, s2, n2) => `${s2}elevation-${mapping[Number(n2)]}`);
|
|
95992
95996
|
count++;
|
|
95993
95997
|
}
|
|
95994
95998
|
}
|
|
@@ -96029,7 +96033,7 @@ const v4FormSlotRefsPlugin = {
|
|
|
96029
96033
|
return count;
|
|
96030
96034
|
}
|
|
96031
96035
|
};
|
|
96032
|
-
const breakpoints = ["sm", "md", "lg", "xl", "xxl"];
|
|
96036
|
+
const breakpoints$1 = ["sm", "md", "lg", "xl", "xxl"];
|
|
96033
96037
|
const v4GridPlugin = {
|
|
96034
96038
|
type: "codemod",
|
|
96035
96039
|
name: "vuetify-4-grid",
|
|
@@ -96052,18 +96056,19 @@ const v4GridPlugin = {
|
|
|
96052
96056
|
builders2.vLiteral("compact")
|
|
96053
96057
|
)
|
|
96054
96058
|
);
|
|
96059
|
+
setParents(el.startTag, builders2);
|
|
96055
96060
|
count++;
|
|
96056
96061
|
}
|
|
96057
96062
|
for (const prop of ["align", "justify", "align-content"]) {
|
|
96058
96063
|
if (propToClass(el, prop, prop, builders2)) count++;
|
|
96059
|
-
for (const bp of breakpoints) {
|
|
96064
|
+
for (const bp of breakpoints$1) {
|
|
96060
96065
|
if (propToClass(el, `${prop}-${bp}`, `${prop}-${bp}`, builders2)) count++;
|
|
96061
96066
|
}
|
|
96062
96067
|
}
|
|
96063
96068
|
}
|
|
96064
96069
|
if (classify(tag) === "VCol") {
|
|
96065
96070
|
if (propToClass(el, "order", "order", builders2)) count++;
|
|
96066
|
-
for (const bp of breakpoints) {
|
|
96071
|
+
for (const bp of breakpoints$1) {
|
|
96067
96072
|
if (propToClass(el, `order-${bp}`, `order-${bp}`, builders2)) count++;
|
|
96068
96073
|
}
|
|
96069
96074
|
if (propToClass(el, "align-self", "align-self", builders2)) count++;
|
|
@@ -96096,6 +96101,7 @@ function appendStaticClass(el, cls, builders2) {
|
|
|
96096
96101
|
builders2.vLiteral(cls)
|
|
96097
96102
|
)
|
|
96098
96103
|
);
|
|
96104
|
+
setParents(el.startTag, builders2);
|
|
96099
96105
|
}
|
|
96100
96106
|
}
|
|
96101
96107
|
function propToClass(el, propName, classPrefix, builders2) {
|
|
@@ -96125,6 +96131,7 @@ const v4SnackbarMultilinePlugin = {
|
|
|
96125
96131
|
node2.startTag.attributes.push(
|
|
96126
96132
|
builders2.vAttribute(builders2.vIdentifier("min-height"), builders2.vLiteral("68"))
|
|
96127
96133
|
);
|
|
96134
|
+
setParents(node2.startTag, builders2);
|
|
96128
96135
|
}
|
|
96129
96136
|
count++;
|
|
96130
96137
|
break;
|
|
@@ -96147,6 +96154,7 @@ const v4SnackbarQueueSlotPlugin = {
|
|
|
96147
96154
|
if (!node2.key.argument) {
|
|
96148
96155
|
node2.key.name.rawName = "#";
|
|
96149
96156
|
node2.key.argument = builders2.vIdentifier("item");
|
|
96157
|
+
setParents(node2.key, builders2);
|
|
96150
96158
|
count++;
|
|
96151
96159
|
} else if (node2.key.argument.type === "VIdentifier") {
|
|
96152
96160
|
node2.key.argument.rawName = "item";
|
|
@@ -96157,35 +96165,36 @@ const v4SnackbarQueueSlotPlugin = {
|
|
|
96157
96165
|
return count;
|
|
96158
96166
|
}
|
|
96159
96167
|
};
|
|
96168
|
+
const breakpoints = ["sm", "md", "lg", "xl", "xxl"];
|
|
96160
96169
|
const replacements = {
|
|
96161
|
-
"
|
|
96162
|
-
"
|
|
96163
|
-
"
|
|
96164
|
-
"
|
|
96165
|
-
"
|
|
96166
|
-
"
|
|
96167
|
-
"
|
|
96168
|
-
"
|
|
96169
|
-
"
|
|
96170
|
-
"
|
|
96171
|
-
"
|
|
96172
|
-
"
|
|
96173
|
-
"
|
|
96170
|
+
"h1": "-display-large",
|
|
96171
|
+
"h2": "-display-medium",
|
|
96172
|
+
"h3": "-display-small",
|
|
96173
|
+
"h4": "-headline-large",
|
|
96174
|
+
"h5": "-headline-medium",
|
|
96175
|
+
"h6": "-headline-small",
|
|
96176
|
+
"subtitle-1": "-body-large",
|
|
96177
|
+
"subtitle-2": "-label-large",
|
|
96178
|
+
"body-1": "-body-large",
|
|
96179
|
+
"body-2": "-body-medium",
|
|
96180
|
+
"caption": "-body-small",
|
|
96181
|
+
"button": "-label-large",
|
|
96182
|
+
"overline": "-label-small"
|
|
96174
96183
|
};
|
|
96175
|
-
const
|
|
96184
|
+
const matcher = String.raw`text(-(?:${breakpoints.join("|")}))?-(${Object.keys(replacements).join("|")})`;
|
|
96176
96185
|
const v4TypographyPlugin = {
|
|
96177
96186
|
type: "codemod",
|
|
96178
96187
|
name: "vuetify-4-typography",
|
|
96179
96188
|
transform({ sfcAST, utils: utils2 }) {
|
|
96180
96189
|
if (!sfcAST) return 0;
|
|
96181
96190
|
let count = 0;
|
|
96182
|
-
const
|
|
96183
|
-
for (const node2 of
|
|
96191
|
+
const { results, matchingRegexp } = findClassNodes(sfcAST, utils2, [matcher]);
|
|
96192
|
+
for (const node2 of results) {
|
|
96184
96193
|
if (node2.type === "Identifier") {
|
|
96185
|
-
node2.name = node2.name.replaceAll(matchingRegexp, (_, s2, m) => `${s2}${replacements[m]}`);
|
|
96194
|
+
node2.name = node2.name.replaceAll(matchingRegexp, (_, s2, b, m) => `${s2}text${b || ""}${replacements[m]}`);
|
|
96186
96195
|
count++;
|
|
96187
96196
|
} else if (typeof node2.value === "string") {
|
|
96188
|
-
node2.value = node2.value.replaceAll(matchingRegexp, (_, s2, m) => `${s2}${replacements[m]}`);
|
|
96197
|
+
node2.value = node2.value.replaceAll(matchingRegexp, (_, s2, b, m) => `${s2}text${b || ""}${replacements[m]}`);
|
|
96189
96198
|
count++;
|
|
96190
96199
|
}
|
|
96191
96200
|
}
|