zmp-vue
Version:
Build full featured iOS & Android apps using ZMP & Vue
100 lines (88 loc) • 3.01 kB
JavaScript
;
exports.__esModule = true;
exports.default = void 0;
var _vue = require("vue");
var _utils = require("../shared/utils");
var _mixins = require("../shared/mixins");
var _zmp = require("../shared/zmp");
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var _hoisted_1 = {
key: 0,
class: "resize-handler"
};
function render(_ctx, _cache) {
return (0, _vue.openBlock)(), (0, _vue.createBlock)((0, _vue.resolveDynamicComponent)(_ctx.tag), {
ref: "elRef",
class: _ctx.classes
}, {
default: (0, _vue.withCtx)(function () {
return [(0, _vue.renderSlot)(_ctx.$slots, "default"), _ctx.resizable && _ctx.resizableHandler ? ((0, _vue.openBlock)(), (0, _vue.createBlock)("span", _hoisted_1)) : (0, _vue.createCommentVNode)("", true)];
}),
_: 3
}, 8, ["class"]);
}
var _default = {
name: 'zmp-col',
render: render,
props: _extends({
tag: {
type: String,
default: 'div'
},
width: {
type: [Number, String],
default: 'auto'
},
xsmall: {
type: [Number, String]
},
small: {
type: [Number, String]
},
medium: {
type: [Number, String]
},
large: {
type: [Number, String]
},
xlarge: {
type: [Number, String]
},
resizable: Boolean,
resizableFixed: Boolean,
resizableAbsolute: Boolean,
resizableHandler: {
type: Boolean,
default: true
}
}, _mixins.colorProps),
emits: ['grid:resize'],
setup: function setup(props, _ref) {
var emit = _ref.emit;
var elRef = (0, _vue.ref)(null);
var onResize = function onResize(el) {
if (el === elRef.value) {
emit('grid:resize');
}
};
(0, _vue.onMounted)(function () {
(0, _zmp.zmpready)(function () {
_zmp.zmp.on('gridResize', onResize);
});
});
(0, _vue.onBeforeUnmount)(function () {
_zmp.zmp.off('gridResize', onResize);
});
var classes = (0, _vue.computed)(function () {
var _classNames;
return (0, _utils.classNames)((_classNames = {
col: props.width === 'auto'
}, _classNames["col-" + props.width] = props.width !== 'auto', _classNames["xsmall-" + props.xsmall] = props.xsmall, _classNames["small-" + props.small] = props.small, _classNames["medium-" + props.medium] = props.medium, _classNames["large-" + props.large] = props.large, _classNames["xlarge-" + props.xlarge] = props.xlarge, _classNames.resizable = props.resizable, _classNames['resizable-fixed'] = props.resizableFixed, _classNames['resizable-absolute'] = props.resizableAbsolute, _classNames), (0, _mixins.colorClasses)(props));
});
return {
classes: classes,
elRef: elRef
};
}
};
exports.default = _default;