This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/vuetify/es5/components/VDatePicker/mixins/date-picker-table.js

222 lines
7.9 KiB
JavaScript
Raw Permalink Normal View History

2019-08-11 18:48:02 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
require("../../../../src/components/VDatePicker/VDatePickerTable.sass");
var _touch = _interopRequireDefault(require("../../../directives/touch"));
var _colorable = _interopRequireDefault(require("../../../mixins/colorable"));
var _localable = _interopRequireDefault(require("../../../mixins/localable"));
var _themeable = _interopRequireDefault(require("../../../mixins/themeable"));
var _isDateAllowed = _interopRequireDefault(require("../util/isDateAllowed"));
var _mixins = _interopRequireDefault(require("../../../util/mixins"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _default2 = (0, _mixins.default)(_colorable.default, _localable.default, _themeable.default
/* @vue/component */
).extend({
directives: {
Touch: _touch.default
},
props: {
allowedDates: Function,
current: String,
disabled: Boolean,
format: Function,
events: {
type: [Array, Function, Object],
default: function _default() {
return null;
}
},
eventColor: {
type: [Array, Function, Object, String],
default: function _default() {
return 'warning';
}
},
min: String,
max: String,
readonly: Boolean,
scrollable: Boolean,
tableDate: {
type: String,
required: true
},
value: [String, Array]
},
data: function data() {
return {
isReversing: false
};
},
computed: {
computedTransition: function computedTransition() {
return this.isReversing === !this.$vuetify.rtl ? 'tab-reverse-transition' : 'tab-transition';
},
displayedMonth: function displayedMonth() {
return Number(this.tableDate.split('-')[1]) - 1;
},
displayedYear: function displayedYear() {
return Number(this.tableDate.split('-')[0]);
}
},
watch: {
tableDate: function tableDate(newVal, oldVal) {
this.isReversing = newVal < oldVal;
}
},
methods: {
genButtonClasses: function genButtonClasses(isAllowed, isFloating, isSelected, isCurrent) {
return _objectSpread({
'v-size--default': !isFloating,
'v-btn--active': isSelected,
'v-btn--flat': !isAllowed || this.disabled,
'v-btn--text': isSelected === isCurrent,
'v-btn--rounded': isFloating,
'v-btn--disabled': !isAllowed || this.disabled,
'v-btn--outlined': isCurrent && !isSelected
}, this.themeClasses);
},
genButtonEvents: function genButtonEvents(value, isAllowed, mouseEventType) {
var _this = this;
if (this.disabled) return undefined;
return {
click: function click() {
isAllowed && !_this.readonly && _this.$emit('input', value);
_this.$emit("click:".concat(mouseEventType), value);
},
dblclick: function dblclick() {
return _this.$emit("dblclick:".concat(mouseEventType), value);
}
};
},
genButton: function genButton(value, isFloating, mouseEventType, formatter) {
var isAllowed = (0, _isDateAllowed.default)(value, this.min, this.max, this.allowedDates);
var isSelected = value === this.value || Array.isArray(this.value) && this.value.indexOf(value) !== -1;
var isCurrent = value === this.current;
var setColor = isSelected ? this.setBackgroundColor : this.setTextColor;
var color = (isSelected || isCurrent) && (this.color || 'accent');
return this.$createElement('button', setColor(color, {
staticClass: 'v-btn',
class: this.genButtonClasses(isAllowed, isFloating, isSelected, isCurrent),
attrs: {
type: 'button'
},
domProps: {
disabled: this.disabled || !isAllowed
},
on: this.genButtonEvents(value, isAllowed, mouseEventType)
}), [this.$createElement('div', {
staticClass: 'v-btn__content'
}, [formatter(value)]), this.genEvents(value)]);
},
getEventColors: function getEventColors(date) {
var arrayize = function arrayize(v) {
return Array.isArray(v) ? v : [v];
};
var eventData;
var eventColors = [];
if (Array.isArray(this.events)) {
eventData = this.events.includes(date);
} else if (this.events instanceof Function) {
eventData = this.events(date) || false;
} else if (this.events) {
eventData = this.events[date] || false;
} else {
eventData = false;
}
if (!eventData) {
return [];
} else if (eventData !== true) {
eventColors = arrayize(eventData);
} else if (typeof this.eventColor === 'string') {
eventColors = [this.eventColor];
} else if (typeof this.eventColor === 'function') {
eventColors = arrayize(this.eventColor(date));
} else if (Array.isArray(this.eventColor)) {
eventColors = this.eventColor;
} else {
eventColors = arrayize(this.eventColor[date]);
}
return eventColors.filter(function (v) {
return v;
});
},
genEvents: function genEvents(date) {
var _this2 = this;
var eventColors = this.getEventColors(date);
return eventColors.length ? this.$createElement('div', {
staticClass: 'v-date-picker-table__events'
}, eventColors.map(function (color) {
return _this2.$createElement('div', _this2.setBackgroundColor(color));
})) : null;
},
wheel: function wheel(e, calculateTableDate) {
e.preventDefault();
this.$emit('update:table-date', calculateTableDate(e.deltaY));
},
touch: function touch(value, calculateTableDate) {
this.$emit('update:table-date', calculateTableDate(value));
},
genTable: function genTable(staticClass, children, calculateTableDate) {
var _this3 = this;
var transition = this.$createElement('transition', {
props: {
name: this.computedTransition
}
}, [this.$createElement('table', {
key: this.tableDate
}, children)]);
var touchDirective = {
name: 'touch',
value: {
left: function left(e) {
return e.offsetX < -15 && _this3.touch(1, calculateTableDate);
},
right: function right(e) {
return e.offsetX > 15 && _this3.touch(-1, calculateTableDate);
}
}
};
return this.$createElement('div', {
staticClass: staticClass,
class: _objectSpread({
'v-date-picker-table--disabled': this.disabled
}, this.themeClasses),
on: !this.disabled && this.scrollable ? {
wheel: function wheel(e) {
return _this3.wheel(e, calculateTableDate);
}
} : undefined,
directives: [touchDirective]
}, [transition]);
}
}
});
exports.default = _default2;
//# sourceMappingURL=date-picker-table.js.map