@taiga-ui/cdk
Version:
Base library for creating Angular components and applications using Taiga UI principles regarding of actual visual appearance
32 lines • 1.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.migrateOverscroll = void 0;
const elements_1 = require("../../../../utils/templates/elements");
const inputs_1 = require("../../../../utils/templates/inputs");
const template_resource_1 = require("../../../../utils/templates/template-resource");
const remove_attrs_1 = require("../utils/remove-attrs");
const overscrollAttrName = 'tuiOverscroll';
function migrateOverscroll({ resource, recorder, fileSystem, }) {
var _a;
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
const elements = (0, elements_1.findElementsWithDirective)(template, overscrollAttrName).filter(({ sourceCodeLocation }) => !!sourceCodeLocation);
if (!elements.length) {
return;
}
elements.forEach(({ attrs, sourceCodeLocation }) => {
const attrToRemove = (0, inputs_1.findAttr)(attrs, overscrollAttrName);
attrToRemove &&
(0, remove_attrs_1.removeAttrs)([attrToRemove], sourceCodeLocation, recorder, templateOffset);
});
const element = (_a = elements[0]) === null || _a === void 0 ? void 0 : _a.sourceCodeLocation;
if (element) {
addTodo(recorder, element, templateOffset);
}
}
exports.migrateOverscroll = migrateOverscroll;
function addTodo(recorder, sourceCodeLocation, templateOffset) {
var _a, _b;
recorder.insertRight(templateOffset + ((_b = (_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.startTag) === null || _a === void 0 ? void 0 : _a.startOffset) !== null && _b !== void 0 ? _b : 0), '<!-- TODO: (Taiga UI migration) use "overscroll-behavior" ccs property instead of "tuiOverscroll" directive -->\n');
}
//# sourceMappingURL=migrate-overscroll.js.map