vuetify eingebunden + erster Versuch Combobox
This commit is contained in:
+169
@@ -0,0 +1,169 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
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; }; // Styles
|
||||
|
||||
// Components
|
||||
|
||||
// Mixins
|
||||
|
||||
|
||||
require('../../../src/stylus/components/_radios.styl');
|
||||
|
||||
var _VIcon = require('../VIcon');
|
||||
|
||||
var _VIcon2 = _interopRequireDefault(_VIcon);
|
||||
|
||||
var _VLabel = require('../VLabel');
|
||||
|
||||
var _VLabel2 = _interopRequireDefault(_VLabel);
|
||||
|
||||
var _colorable = require('../../mixins/colorable');
|
||||
|
||||
var _colorable2 = _interopRequireDefault(_colorable);
|
||||
|
||||
var _rippleable = require('../../mixins/rippleable');
|
||||
|
||||
var _rippleable2 = _interopRequireDefault(_rippleable);
|
||||
|
||||
var _themeable = require('../../mixins/themeable');
|
||||
|
||||
var _themeable2 = _interopRequireDefault(_themeable);
|
||||
|
||||
var _selectable = require('../../mixins/selectable');
|
||||
|
||||
var _selectable2 = _interopRequireDefault(_selectable);
|
||||
|
||||
var _registrable = require('../../mixins/registrable');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
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); } }
|
||||
|
||||
/* @vue/component */
|
||||
exports.default = {
|
||||
name: 'v-radio',
|
||||
mixins: [_colorable2.default, _rippleable2.default, (0, _registrable.inject)('radio', 'v-radio', 'v-radio-group'), _themeable2.default],
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
color: {
|
||||
type: String,
|
||||
default: 'accent'
|
||||
},
|
||||
disabled: Boolean,
|
||||
label: String,
|
||||
onIcon: {
|
||||
type: String,
|
||||
default: '$vuetify.icons.radioOn'
|
||||
},
|
||||
offIcon: {
|
||||
type: String,
|
||||
default: '$vuetify.icons.radioOff'
|
||||
},
|
||||
readonly: Boolean,
|
||||
value: null
|
||||
},
|
||||
data: function data() {
|
||||
return {
|
||||
isActive: false,
|
||||
isFocused: false,
|
||||
parentError: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
computedData: function computedData() {
|
||||
return this.setTextColor(!this.parentError && this.isActive && this.color, {
|
||||
staticClass: 'v-radio',
|
||||
'class': _extends({
|
||||
'v-radio--is-disabled': this.isDisabled,
|
||||
'v-radio--is-focused': this.isFocused
|
||||
}, this.themeClasses)
|
||||
});
|
||||
},
|
||||
computedColor: function computedColor() {
|
||||
return this.isActive ? this.color : this.radio.validationState || false;
|
||||
},
|
||||
computedIcon: function computedIcon() {
|
||||
return this.isActive ? this.onIcon : this.offIcon;
|
||||
},
|
||||
hasState: function hasState() {
|
||||
return this.isActive || !!this.radio.validationState;
|
||||
},
|
||||
isDisabled: function isDisabled() {
|
||||
return this.disabled || !!this.radio.disabled;
|
||||
},
|
||||
isReadonly: function isReadonly() {
|
||||
return this.readonly || !!this.radio.readonly;
|
||||
}
|
||||
},
|
||||
mounted: function mounted() {
|
||||
this.radio.register(this);
|
||||
},
|
||||
beforeDestroy: function beforeDestroy() {
|
||||
this.radio.unregister(this);
|
||||
},
|
||||
|
||||
methods: {
|
||||
genInput: function genInput() {
|
||||
var _Selectable$options$m;
|
||||
|
||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
// We can't actually use the mixin directly because
|
||||
// it's made for standalone components, but its
|
||||
// genInput method is exactly what we need
|
||||
return (_Selectable$options$m = _selectable2.default.options.methods.genInput).call.apply(_Selectable$options$m, [this].concat(_toConsumableArray(args)));
|
||||
},
|
||||
genLabel: function genLabel() {
|
||||
return this.$createElement(_VLabel2.default, {
|
||||
on: { click: this.onChange },
|
||||
attrs: {
|
||||
for: this.id
|
||||
},
|
||||
props: {
|
||||
color: this.radio.validationState || '',
|
||||
dark: this.dark,
|
||||
focused: this.hasState,
|
||||
light: this.light
|
||||
}
|
||||
}, this.$slots.label || this.label);
|
||||
},
|
||||
genRadio: function genRadio() {
|
||||
return this.$createElement('div', {
|
||||
staticClass: 'v-input--selection-controls__input'
|
||||
}, [this.genInput('radio', _extends({
|
||||
name: this.radio.name || (this.radio._uid ? 'v-radio-' + this.radio._uid : false),
|
||||
value: this.value
|
||||
}, this.$attrs)), this.genRipple(this.setTextColor(this.computedColor)), this.$createElement(_VIcon2.default, this.setTextColor(this.computedColor, {
|
||||
props: {
|
||||
dark: this.dark,
|
||||
light: this.light
|
||||
}
|
||||
}), this.computedIcon)]);
|
||||
},
|
||||
onFocus: function onFocus(e) {
|
||||
this.isFocused = true;
|
||||
this.$emit('focus', e);
|
||||
},
|
||||
onBlur: function onBlur(e) {
|
||||
this.isFocused = false;
|
||||
this.$emit('blur', e);
|
||||
},
|
||||
onChange: function onChange() {
|
||||
if (this.isDisabled || this.isReadonly) return;
|
||||
if (!this.isDisabled && (!this.isActive || !this.radio.mandatory)) {
|
||||
this.$emit('change', this.value);
|
||||
}
|
||||
},
|
||||
onKeydown: function onKeydown() {}
|
||||
},
|
||||
render: function render(h) {
|
||||
return h('div', this.computedData, [this.genRadio(), this.genLabel()]);
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=VRadio.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+137
@@ -0,0 +1,137 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
require('../../../src/stylus/components/_selection-controls.styl');
|
||||
|
||||
require('../../../src/stylus/components/_radio-group.styl');
|
||||
|
||||
var _VInput = require('../VInput');
|
||||
|
||||
var _VInput2 = _interopRequireDefault(_VInput);
|
||||
|
||||
var _comparable = require('../../mixins/comparable');
|
||||
|
||||
var _comparable2 = _interopRequireDefault(_comparable);
|
||||
|
||||
var _registrable = require('../../mixins/registrable');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/* @vue/component */
|
||||
|
||||
// Mixins
|
||||
exports.default = _VInput2.default.extend({
|
||||
name: 'v-radio-group',
|
||||
mixins: [_comparable2.default, (0, _registrable.provide)('radio')],
|
||||
model: {
|
||||
prop: 'value',
|
||||
event: 'change'
|
||||
},
|
||||
provide: function provide() {
|
||||
return {
|
||||
radio: this
|
||||
};
|
||||
},
|
||||
|
||||
props: {
|
||||
column: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
height: {
|
||||
type: [Number, String],
|
||||
default: 'auto'
|
||||
},
|
||||
mandatory: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
name: String,
|
||||
row: Boolean,
|
||||
// If no value set on VRadio
|
||||
// will match valueComparator
|
||||
// force default to null
|
||||
value: {
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data: function data() {
|
||||
return {
|
||||
internalTabIndex: -1,
|
||||
radios: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
classes: function classes() {
|
||||
return {
|
||||
'v-input--selection-controls v-input--radio-group': true,
|
||||
'v-input--radio-group--column': this.column && !this.row,
|
||||
'v-input--radio-group--row': this.row
|
||||
};
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
hasError: 'setErrorState',
|
||||
internalValue: 'setActiveRadio'
|
||||
},
|
||||
mounted: function mounted() {
|
||||
this.setErrorState(this.hasError);
|
||||
this.setActiveRadio();
|
||||
},
|
||||
|
||||
methods: {
|
||||
genDefaultSlot: function genDefaultSlot() {
|
||||
return this.$createElement('div', {
|
||||
staticClass: 'v-input--radio-group__input',
|
||||
attrs: {
|
||||
role: 'radiogroup'
|
||||
}
|
||||
}, _VInput2.default.options.methods.genDefaultSlot.call(this));
|
||||
},
|
||||
onRadioChange: function onRadioChange(value) {
|
||||
if (this.disabled) return;
|
||||
this.hasInput = true;
|
||||
this.internalValue = value;
|
||||
this.setActiveRadio();
|
||||
this.$nextTick(this.validate);
|
||||
},
|
||||
onRadioBlur: function onRadioBlur(e) {
|
||||
if (!e.relatedTarget || !e.relatedTarget.classList.contains('v-radio')) {
|
||||
this.hasInput = true;
|
||||
this.$emit('blur', e);
|
||||
}
|
||||
},
|
||||
register: function register(radio) {
|
||||
radio.isActive = this.valueComparator(this.internalValue, radio.value);
|
||||
radio.$on('change', this.onRadioChange);
|
||||
radio.$on('blur', this.onRadioBlur);
|
||||
this.radios.push(radio);
|
||||
},
|
||||
setErrorState: function setErrorState(val) {
|
||||
for (var index = this.radios.length; --index >= 0;) {
|
||||
this.radios[index].parentError = val;
|
||||
}
|
||||
},
|
||||
setActiveRadio: function setActiveRadio() {
|
||||
for (var index = this.radios.length; --index >= 0;) {
|
||||
var radio = this.radios[index];
|
||||
radio.isActive = this.valueComparator(this.internalValue, radio.value);
|
||||
}
|
||||
},
|
||||
unregister: function unregister(radio) {
|
||||
radio.$off('change', this.onRadioChange);
|
||||
radio.$off('blur', this.onRadioBlur);
|
||||
var index = this.radios.findIndex(function (r) {
|
||||
return r === radio;
|
||||
});
|
||||
/* istanbul ignore else */
|
||||
if (index > -1) this.radios.splice(index, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
// Components
|
||||
// Styles
|
||||
//# sourceMappingURL=VRadioGroup.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+26
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.VRadio = exports.VRadioGroup = undefined;
|
||||
|
||||
var _VRadioGroup = require('./VRadioGroup');
|
||||
|
||||
var _VRadioGroup2 = _interopRequireDefault(_VRadioGroup);
|
||||
|
||||
var _VRadio = require('./VRadio');
|
||||
|
||||
var _VRadio2 = _interopRequireDefault(_VRadio);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.VRadioGroup = _VRadioGroup2.default;
|
||||
exports.VRadio = _VRadio2.default;
|
||||
exports.default = {
|
||||
$_vuetify_subcomponents: {
|
||||
VRadioGroup: _VRadioGroup2.default,
|
||||
VRadio: _VRadio2.default
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/components/VRadioGroup/index.js"],"names":[],"mappings":";;;;;;;;;;;AACA;;;;;;QAES,W,GAAA,qB;QAAa,M,GAAA,gB;kBAEP;AACb,6BAAyB;AACvB,0CADuB;AAEvB;AAFuB;AADZ,C","sourcesContent":["import VRadioGroup from './VRadioGroup'\nimport VRadio from './VRadio'\n\nexport { VRadioGroup, VRadio }\n\nexport default {\n $_vuetify_subcomponents: {\n VRadioGroup,\n VRadio\n }\n}\n"],"sourceRoot":""}
|
||||
Reference in New Issue
Block a user