UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

143 lines (131 loc) 5.24 kB
'use strict'; function applyStateClassRenames(str) { let result = str; result = result.replaceAll('k-state-hover', 'k-hover'); result = result.replaceAll('k-state-focused', 'k-focus'); result = result.replaceAll('k-state-selected', 'k-selected'); result = result.replaceAll('k-state-disabled', 'k-disabled'); result = result.replaceAll('k-state-active', 'k-active'); result = result.replaceAll('k-state-alt', 'k-alt'); result = result.replaceAll('k-state-loading', 'k-loading'); result = result.replaceAll('k-state-invalid', 'k-invalid'); result = result.replaceAll('k-state-checked', 'k-checked'); result = result.replaceAll('k-state-expanded', 'k-expanded'); result = result.replaceAll('k-state-collapsed', 'k-collapsed'); result = result.replaceAll('k-state-empty', 'k-empty'); return result; } function applyGridCommandRenames(str) { let result = str; result = result.replaceAll('k-grid-update', 'k-grid-save-command'); result = result.replaceAll('k-grid-cancel', 'k-grid-cancel-command'); result = result.replaceAll('k-grid-delete', 'k-grid-remove-command'); return result; } function applyUploadClassRenames(str) { let result = str; result = result.replaceAll('k-file-group-wrapper', 'k-file-icon-wrapper'); result = result.replaceAll('k-file-invalid-group-wrapper', 'k-file-icon-wrapper'); result = result.replaceAll('k-multiple-files-invalid-group-wrapper', 'k-file-icon-wrapper'); result = result.replaceAll('k-file-group', 'k-file-icon'); result = result.replaceAll('k-file-name-size-wrap', 'k-file-info'); result = result.replaceAll('k-file-name-invalid', 'k-file-name'); result = result.replaceAll('k-file-information', 'k-file-summary'); result = result.replaceAll('k-dropzone-hover', 'k-hover'); result = result.replaceAll('k-dropzone-hovered', 'k-hover'); return result; } function applyCalendarNavRenames(str) { let result = str; result = result.replaceAll('k-nav-today', 'k-calendar-nav-today'); result = result.replaceAll('k-nav-fast', 'k-calendar-nav-today'); result = result.replaceAll('k-nav-prev', 'k-calendar-nav-prev'); result = result.replaceAll('k-prev-view', 'k-calendar-nav-prev'); result = result.replaceAll('k-nav-next', 'k-calendar-nav-next'); result = result.replaceAll('k-next-view', 'k-calendar-nav-next'); return result; } function applySortIconRenames(str) { let result = str; result = result.replace(/k-i-sort-asc-sm(?!all)/g, 'k-i-sort-asc-small'); result = result.replace(/k-i-sort-desc-sm(?!all)/g, 'k-i-sort-desc-small'); return result; } function applyToolbarOverflowAnchorRename(str) { return str.replaceAll('k-overflow-anchor', 'k-toolbar-overflow-button'); } function applyWindowDialogClassRenames(str) { let result = str; result = result.replaceAll('k-window-actions', 'k-window-titlebar-actions'); result = result.replaceAll('k-window-buttongroup', 'k-window-actions'); result = result.replaceAll('k-window-buttons', 'k-window-actions'); result = result.replace(/\.k-window-titleless(?=\.)/g, ''); result = result.replace(/(?<=[\w-])\.k-window-titleless/g, ''); result = result.replaceAll('k-dialog-actions', 'k-dialog-titlebar-actions'); result = result.replaceAll('k-dialog-buttongroup', 'k-dialog-actions'); result = result.replaceAll('k-dialog-buttons', 'k-dialog-actions'); return result; } function applyAll(str) { let result = str; result = applyStateClassRenames(result); result = applyGridCommandRenames(result); result = applyUploadClassRenames(result); result = applyCalendarNavRenames(result); result = applySortIconRenames(result); result = applyToolbarOverflowAnchorRename(result); result = applyWindowDialogClassRenames(result); 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; } module.exports = { applyStateClassRenames, applyGridCommandRenames, applyUploadClassRenames, applyCalendarNavRenames, applySortIconRenames, applyToolbarOverflowAnchorRename, applyWindowDialogClassRenames, applyAll, transformStringLiterals, transformTemplateLiterals, };