@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
102 lines (91 loc) • 3.48 kB
JavaScript
;
function applyExpansionPanelHiddenClass(str) {
let result = str;
result = result.replaceAll('k-expander-content-wrapper.k-d-none', 'k-expander-content-wrapper.k-hidden');
result = result.replaceAll('k-d-none.k-expander-content-wrapper', 'k-hidden.k-expander-content-wrapper');
return result;
}
function transformStringLiterals(root, j, fn) {
let changed = false;
const visit = path => {
if (typeof path.node.value !== 'string') {
return;
}
const updated = fn(path.node.value);
if (updated === path.node.value) {
return;
}
path.node.value = updated;
if (path.node.extra) {
path.node.extra.rawValue = updated;
if (path.node.extra.raw) {
path.node.extra.raw = fn(path.node.extra.raw);
}
}
changed = true;
};
root.find(j.StringLiteral).forEach(visit);
root.find(j.Literal, n => typeof n.value === 'string').forEach(visit);
return changed;
}
function transformTemplateLiterals(root, j, fn) {
let changed = false;
root.find(j.TemplateLiteral).forEach(path => {
path.node.quasis.forEach(quasi => {
const updatedRaw = fn(quasi.value.raw);
const updatedCooked = quasi.value.cooked != null ? fn(quasi.value.cooked) : null;
if (updatedRaw !== quasi.value.raw || updatedCooked !== quasi.value.cooked) {
quasi.value.raw = updatedRaw;
if (quasi.value.cooked != null) {
quasi.value.cooked = updatedCooked;
}
changed = true;
}
});
});
return changed;
}
function applyRenderingClassRemovals(str) {
let result = str;
result = result.replaceAll('.k-table-alt-row.k-alt', '.k-table-alt-row');
result = result.replaceAll('.k-alt.k-table-alt-row', '.k-table-alt-row');
result = result.replaceAll('.k-dockmanager .k-tabstrip.k-header', '.k-dockmanager .k-tabstrip');
result = result.replaceAll('.k-window-content.k-popup-edit-form', '.k-popup-edit-form');
result = result.replaceAll('.k-popup-edit-form.k-window-content', '.k-popup-edit-form');
result = result.replaceAll('.k-aiprompt .k-card-body.k-white-space-pre-line', '.k-aiprompt .k-card-body');
result = result.replaceAll('.k-treelist .k-treelist-group', '.k-treelist .k-table-group-row');
return result;
}
function transformNumbersSelectLabel(root, j) {
let changed = false;
const removeIfMatch = path => {
const key = path.node.key;
const keyName =
key.type === 'Identifier' ? key.name :
(key.type === 'StringLiteral' || key.type === 'Literal') ? key.value :
null;
if (keyName === 'numbersSelectLabel') {
path.prune();
changed = true;
}
};
root.find(j.ObjectProperty).forEach(removeIfMatch);
root.find(j.Property, n => !n.computed && !n.method && !n.shorthand).forEach(removeIfMatch);
return changed;
}
function applyGridDragStrips(str) {
let result = str;
result = result.replace(/\.k-table-th\.k-drag-cell(?=[\s{,>+~:.#\[)]|$)/g, '.k-table-th');
result = result.replace(/\.k-drag-cell\.k-table-th(?=[\s{,>+~:.#\[)]|$)/g, '.k-table-th');
result = result.replace(/\.k-table-th\.k-touch-action-none(?=[\s{,>+~:.#\[)]|$)/g, '.k-table-th');
result = result.replace(/\.k-touch-action-none\.k-table-th(?=[\s{,>+~:.#\[)]|$)/g, '.k-table-th');
return result;
}
module.exports = {
applyExpansionPanelHiddenClass,
applyRenderingClassRemovals,
applyGridDragStrips,
transformNumbersSelectLabel,
transformStringLiterals,
transformTemplateLiterals,
};