UNPKG

ivue-material-plus

Version:

A high quality UI components Library with Vue.js

84 lines (79 loc) 2.24 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); var shared = require('@vue/shared'); var utils = require('../utils.js'); function getAllAliases(props, aliases) { return props.reduce((prev, cur) => { prev[cur] = cur; return prev; }, aliases); } function useWatcher(parentDom, _props) { const vm = vue.getCurrentInstance(); const registerComplexWatchers = () => { const props = ["fixed"]; const aliases = { columnWidth: "width", columnMinWidth: "minWidth" }; const allAliases = getAllAliases(props, aliases); Object.keys(allAliases).forEach((key) => { const columnKey = aliases[key]; if (shared.hasOwn(_props, columnKey)) { vue.watch( () => _props[columnKey], (newVal) => { let value = newVal; if (columnKey === "width" && key === "columnWidth") { value = utils.parseWidth(newVal); } if (columnKey === "minWidth" && key === "columnMinWidth") { value = utils.parseMinWidth(newVal); } vm.columnConfig.value[columnKey] = value; vm.columnConfig.value[key] = value; const updateColumns = columnKey === "fixed"; parentDom.value.store.scheduleLayout(updateColumns); } ); } }); }; const registerNormalWatchers = () => { const props = [ "label", "filters", "filterMultiple", "sortable", "index", "formatter", "className", "labelClassName", "showOverflowTooltip" ]; const aliases = { property: "prop", align: "align", headerAlign: "headerAlign" }; const allAliases = getAllAliases(props, aliases); Object.keys(allAliases).forEach((key) => { const columnKey = aliases[key]; if (shared.hasOwn(_props, columnKey)) { vue.watch( () => _props[columnKey], (newVal) => { vm.columnConfig.value[key] = newVal; } ); } }); }; return { registerNormalWatchers, registerComplexWatchers }; } exports["default"] = useWatcher; //# sourceMappingURL=watcher.js.map