vuetify eingebunden + erster Versuch Combobox
This commit is contained in:
+120
@@ -0,0 +1,120 @@
|
||||
var _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; };
|
||||
|
||||
import '../../../src/stylus/components/_expansion-panel.styl';
|
||||
import Themeable from '../../mixins/themeable';
|
||||
import { provide as RegistrableProvide } from '../../mixins/registrable';
|
||||
import mixins from '../../util/mixins';
|
||||
/* @vue/component */
|
||||
export default mixins(Themeable, RegistrableProvide('expansionPanel')).extend({
|
||||
name: 'v-expansion-panel',
|
||||
provide: function provide() {
|
||||
return {
|
||||
expansionPanel: this
|
||||
};
|
||||
},
|
||||
|
||||
props: {
|
||||
disabled: Boolean,
|
||||
readonly: Boolean,
|
||||
expand: Boolean,
|
||||
focusable: Boolean,
|
||||
inset: Boolean,
|
||||
popout: Boolean,
|
||||
value: {
|
||||
type: [Number, Array],
|
||||
default: function _default() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
data: function data() {
|
||||
return {
|
||||
items: [],
|
||||
open: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
classes: function classes() {
|
||||
return _extends({
|
||||
'v-expansion-panel--focusable': this.focusable,
|
||||
'v-expansion-panel--popout': this.popout,
|
||||
'v-expansion-panel--inset': this.inset
|
||||
}, this.themeClasses);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
expand: function expand(v) {
|
||||
var openIndex = -1;
|
||||
if (!v) {
|
||||
// Close all panels unless only one is open
|
||||
var openCount = this.open.reduce(function (acc, val) {
|
||||
return val ? acc + 1 : acc;
|
||||
}, 0);
|
||||
var open = Array(this.items.length).fill(false);
|
||||
if (openCount === 1) {
|
||||
openIndex = this.open.indexOf(true);
|
||||
}
|
||||
if (openIndex > -1) {
|
||||
open[openIndex] = true;
|
||||
}
|
||||
this.open = open;
|
||||
}
|
||||
this.$emit('input', v ? this.open : openIndex > -1 ? openIndex : null);
|
||||
},
|
||||
value: function value(v) {
|
||||
this.updateFromValue(v);
|
||||
}
|
||||
},
|
||||
mounted: function mounted() {
|
||||
this.value !== null && this.updateFromValue(this.value);
|
||||
},
|
||||
|
||||
methods: {
|
||||
updateFromValue: function updateFromValue(v) {
|
||||
if (Array.isArray(v) && !this.expand) return;
|
||||
var open = Array(this.items.length).fill(false);
|
||||
if (typeof v === 'number') {
|
||||
open[v] = true;
|
||||
} else if (v !== null) {
|
||||
open = v;
|
||||
}
|
||||
this.updatePanels(open);
|
||||
},
|
||||
updatePanels: function updatePanels(open) {
|
||||
this.open = open;
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
this.items[i].toggle(open && open[i]);
|
||||
}
|
||||
},
|
||||
panelClick: function panelClick(uid) {
|
||||
var open = this.expand ? this.open.slice() : Array(this.items.length).fill(false);
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
if (this.items[i]._uid === uid) {
|
||||
open[i] = !this.open[i];
|
||||
!this.expand && this.$emit('input', open[i] ? i : null);
|
||||
}
|
||||
}
|
||||
this.updatePanels(open);
|
||||
if (this.expand) this.$emit('input', open);
|
||||
},
|
||||
register: function register(content) {
|
||||
var i = this.items.push(content) - 1;
|
||||
this.value !== null && this.updateFromValue(this.value);
|
||||
content.toggle(!!this.open[i]);
|
||||
},
|
||||
unregister: function unregister(content) {
|
||||
var index = this.items.findIndex(function (i) {
|
||||
return i._uid === content._uid;
|
||||
});
|
||||
this.items.splice(index, 1);
|
||||
this.open.splice(index, 1);
|
||||
}
|
||||
},
|
||||
render: function render(h) {
|
||||
return h('ul', {
|
||||
staticClass: 'v-expansion-panel',
|
||||
class: this.classes
|
||||
}, this.$slots.default);
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=VExpansionPanel.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+123
@@ -0,0 +1,123 @@
|
||||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||
|
||||
import { VExpandTransition } from '../transitions';
|
||||
import Bootable from '../../mixins/bootable';
|
||||
import Toggleable from '../../mixins/toggleable';
|
||||
import Rippleable from '../../mixins/rippleable';
|
||||
import { inject as RegistrableInject } from '../../mixins/registrable';
|
||||
import VIcon from '../VIcon';
|
||||
import mixins from '../../util/mixins';
|
||||
import { consoleWarn } from '../../util/console';
|
||||
export default mixins(Bootable, Toggleable, Rippleable, RegistrableInject('expansionPanel', 'v-expansion-panel-content', 'v-expansion-panel')
|
||||
/* @vue/component */
|
||||
).extend({
|
||||
name: 'v-expansion-panel-content',
|
||||
props: {
|
||||
disabled: Boolean,
|
||||
readonly: Boolean,
|
||||
expandIcon: {
|
||||
type: String,
|
||||
default: '$vuetify.icons.expand'
|
||||
},
|
||||
hideActions: Boolean,
|
||||
ripple: {
|
||||
type: [Boolean, Object],
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data: function data() {
|
||||
return {
|
||||
height: 'auto'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
containerClasses: function containerClasses() {
|
||||
return {
|
||||
'v-expansion-panel__container--active': this.isActive,
|
||||
'v-expansion-panel__container--disabled': this.isDisabled
|
||||
};
|
||||
},
|
||||
isDisabled: function isDisabled() {
|
||||
return this.expansionPanel.disabled || this.disabled;
|
||||
},
|
||||
isReadonly: function isReadonly() {
|
||||
return this.expansionPanel.readonly || this.readonly;
|
||||
}
|
||||
},
|
||||
beforeMount: function beforeMount() {
|
||||
this.expansionPanel.register(this);
|
||||
// Can be removed once fully deprecated
|
||||
if (typeof this.value !== 'undefined') consoleWarn('v-model has been deprecated', this);
|
||||
},
|
||||
beforeDestroy: function beforeDestroy() {
|
||||
this.expansionPanel.unregister(this);
|
||||
},
|
||||
|
||||
methods: {
|
||||
onKeydown: function onKeydown(e) {
|
||||
// Ensure element is the activeElement
|
||||
if (e.keyCode === 13 && this.$el === document.activeElement) this.expansionPanel.panelClick(this._uid);
|
||||
},
|
||||
onHeaderClick: function onHeaderClick() {
|
||||
this.isReadonly || this.expansionPanel.panelClick(this._uid);
|
||||
},
|
||||
genBody: function genBody() {
|
||||
return this.$createElement('div', {
|
||||
ref: 'body',
|
||||
class: 'v-expansion-panel__body',
|
||||
directives: [{
|
||||
name: 'show',
|
||||
value: this.isActive
|
||||
}]
|
||||
}, this.showLazyContent(this.$slots.default));
|
||||
},
|
||||
genHeader: function genHeader() {
|
||||
var children = [].concat(_toConsumableArray(this.$slots.header || []));
|
||||
if (!this.hideActions) children.push(this.genIcon());
|
||||
return this.$createElement('div', {
|
||||
staticClass: 'v-expansion-panel__header',
|
||||
directives: [{
|
||||
name: 'ripple',
|
||||
value: this.ripple
|
||||
}],
|
||||
on: {
|
||||
click: this.onHeaderClick
|
||||
}
|
||||
}, children);
|
||||
},
|
||||
genIcon: function genIcon() {
|
||||
var icon = this.$slots.actions || [this.$createElement(VIcon, this.expandIcon)];
|
||||
return this.$createElement('transition', {
|
||||
attrs: { name: 'fade-transition' }
|
||||
}, [this.$createElement('div', {
|
||||
staticClass: 'v-expansion-panel__header__icon',
|
||||
directives: [{
|
||||
name: 'show',
|
||||
value: !this.isDisabled
|
||||
}]
|
||||
}, icon)]);
|
||||
},
|
||||
toggle: function toggle(active) {
|
||||
var _this = this;
|
||||
|
||||
if (active) this.isBooted = true;
|
||||
this.$nextTick(function () {
|
||||
return _this.isActive = active;
|
||||
});
|
||||
}
|
||||
},
|
||||
render: function render(h) {
|
||||
return h('li', {
|
||||
staticClass: 'v-expansion-panel__container',
|
||||
class: this.containerClasses,
|
||||
attrs: {
|
||||
tabindex: this.isReadonly || this.isDisabled ? null : 0,
|
||||
'aria-expanded': Boolean(this.isActive)
|
||||
},
|
||||
on: {
|
||||
keydown: this.onKeydown
|
||||
}
|
||||
}, [this.$slots.header && this.genHeader(), h(VExpandTransition, [this.genBody()])]);
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=VExpansionPanelContent.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
+10
@@ -0,0 +1,10 @@
|
||||
import VExpansionPanel from './VExpansionPanel';
|
||||
import VExpansionPanelContent from './VExpansionPanelContent';
|
||||
export { VExpansionPanel, VExpansionPanelContent };
|
||||
export default {
|
||||
$_vuetify_subcomponents: {
|
||||
VExpansionPanel: VExpansionPanel,
|
||||
VExpansionPanelContent: VExpansionPanelContent
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/components/VExpansionPanel/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAP,MAA4B,mBAA5B;AACA,OAAO,sBAAP,MAAmC,0BAAnC;AAEA,SAAS,eAAT,EAA0B,sBAA1B;AAEA,eAAe;AACb,6BAAyB;AACvB,wCADuB;AAEvB;AAFuB;AADZ,CAAf","sourcesContent":["import VExpansionPanel from './VExpansionPanel'\nimport VExpansionPanelContent from './VExpansionPanelContent'\n\nexport { VExpansionPanel, VExpansionPanelContent }\n\nexport default {\n $_vuetify_subcomponents: {\n VExpansionPanel,\n VExpansionPanelContent\n }\n}\n"],"sourceRoot":""}
|
||||
Reference in New Issue
Block a user