This commit is contained in:
2022-07-21 03:28:35 +00:00
parent d7c883d6df
commit 51b34b0e1d
30103 changed files with 4152204 additions and 23 deletions
+167
View File
@@ -0,0 +1,167 @@
// Styles
import "../../../src/components/VRadioGroup/VRadio.sass";
import VLabel from '../VLabel';
import VIcon from '../VIcon';
import VInput from '../VInput'; // Mixins
import BindsAttrs from '../../mixins/binds-attrs';
import Colorable from '../../mixins/colorable';
import { factory as GroupableFactory } from '../../mixins/groupable';
import Rippleable from '../../mixins/rippleable';
import Themeable from '../../mixins/themeable';
import Selectable from '../../mixins/selectable'; // Utilities
import { getSlot } from '../../util/helpers';
import mixins from '../../util/mixins';
const baseMixins = mixins(BindsAttrs, Colorable, Rippleable, GroupableFactory('radioGroup'), Themeable);
/* @vue/component */
export default baseMixins.extend().extend({
name: 'v-radio',
inheritAttrs: false,
props: {
disabled: Boolean,
id: String,
label: String,
name: String,
offIcon: {
type: String,
default: '$radioOff'
},
onIcon: {
type: String,
default: '$radioOn'
},
readonly: Boolean,
value: {
default: null
}
},
data: () => ({
isFocused: false
}),
computed: {
classes() {
return {
'v-radio--is-disabled': this.isDisabled,
'v-radio--is-focused': this.isFocused,
...this.themeClasses,
...this.groupClasses
};
},
computedColor() {
return Selectable.options.computed.computedColor.call(this);
},
computedIcon() {
return this.isActive ? this.onIcon : this.offIcon;
},
computedId() {
return VInput.options.computed.computedId.call(this);
},
hasLabel: VInput.options.computed.hasLabel,
hasState() {
return (this.radioGroup || {}).hasState;
},
isDisabled() {
return this.disabled || !!this.radioGroup && this.radioGroup.isDisabled;
},
isReadonly() {
return this.readonly || !!this.radioGroup && this.radioGroup.isReadonly;
},
computedName() {
if (this.name || !this.radioGroup) {
return this.name;
}
return this.radioGroup.name || `radio-${this.radioGroup._uid}`;
},
rippleState() {
return Selectable.options.computed.rippleState.call(this);
},
validationState() {
return (this.radioGroup || {}).validationState || this.computedColor;
}
},
methods: {
genInput(args) {
// 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.methods.genInput.call(this, 'radio', args);
},
genLabel() {
if (!this.hasLabel) return null;
return this.$createElement(VLabel, {
on: {
click: e => {
// Prevent label from
// causing the input
// to focus
e.preventDefault();
this.onChange();
}
},
attrs: {
for: this.computedId
},
props: {
color: this.validationState,
focused: this.hasState
}
}, getSlot(this, 'label') || this.label);
},
genRadio() {
return this.$createElement('div', {
staticClass: 'v-input--selection-controls__input'
}, [this.$createElement(VIcon, this.setTextColor(this.validationState, {
props: {
dense: this.radioGroup && this.radioGroup.dense
}
}), this.computedIcon), this.genInput({
name: this.computedName,
value: this.value,
...this.attrs$
}), this.genRipple(this.setTextColor(this.rippleState))]);
},
onFocus(e) {
this.isFocused = true;
this.$emit('focus', e);
},
onBlur(e) {
this.isFocused = false;
this.$emit('blur', e);
},
onChange() {
if (this.isDisabled || this.isReadonly || this.isActive) return;
this.toggle();
},
onKeydown: () => {}
},
render(h) {
const data = {
staticClass: 'v-radio',
class: this.classes
};
return h('div', data, [this.genRadio(), this.genLabel()]);
}
});
//# sourceMappingURL=VRadio.js.map
File diff suppressed because one or more lines are too long
+80
View File
@@ -0,0 +1,80 @@
// Styles
import "../../../src/styles/components/_selection-controls.sass";
import "../../../src/components/VRadioGroup/VRadioGroup.sass"; // Extensions
import VInput from '../VInput';
import { BaseItemGroup } from '../VItemGroup/VItemGroup'; // Mixins
import Comparable from '../../mixins/comparable'; // Types
import mixins from '../../util/mixins';
const baseMixins = mixins(Comparable, BaseItemGroup, VInput);
/* @vue/component */
export default baseMixins.extend({
name: 'v-radio-group',
provide() {
return {
radioGroup: this
};
},
props: {
column: {
type: Boolean,
default: true
},
height: {
type: [Number, String],
default: 'auto'
},
name: String,
row: Boolean,
// If no value set on VRadio
// will match valueComparator
// force default to null
value: null
},
computed: {
classes() {
return { ...VInput.options.computed.classes.call(this),
'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
};
}
},
methods: {
genDefaultSlot() {
return this.$createElement('div', {
staticClass: 'v-input--radio-group__input',
attrs: {
id: this.id,
role: 'radiogroup',
'aria-labelledby': this.computedId
}
}, VInput.options.methods.genDefaultSlot.call(this));
},
genInputSlot() {
const render = VInput.options.methods.genInputSlot.call(this);
delete render.data.on.click;
return render;
},
genLabel() {
const label = VInput.options.methods.genLabel.call(this);
if (!label) return null;
label.data.attrs.id = this.computedId; // WAI considers this an orphaned label
delete label.data.attrs.for;
label.tag = 'legend';
return label;
},
onClick: BaseItemGroup.options.methods.onClick
}
});
//# sourceMappingURL=VRadioGroup.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/components/VRadioGroup/VRadioGroup.ts"],"names":[],"mappings":"AAAA;AACA,OAAO,yDAAP;AACA,OAAO,sDAAP,C,CAEA;;AACA,OAAO,MAAP,MAAmB,WAAnB;AACA,SAAS,aAAT,QAA8B,0BAA9B,C,CAEA;;AACA,OAAO,UAAP,MAAuB,yBAAvB,C,CAEA;;AACA,OAAO,MAAP,MAAmB,mBAAnB;AAGA,MAAM,UAAU,GAAG,MAAM,CACvB,UADuB,EAEvB,aAFuB,EAGvB,MAHuB,CAAzB;AAMA;;AACA,eAAe,UAAU,CAAC,MAAX,CAAkB;AAC/B,EAAA,IAAI,EAAE,eADyB;;AAG/B,EAAA,OAAO,GAAA;AACL,WAAO;AACL,MAAA,UAAU,EAAE;AADP,KAAP;AAGD,GAP8B;;AAS/B,EAAA,KAAK,EAAE;AACL,IAAA,MAAM,EAAE;AACN,MAAA,IAAI,EAAE,OADA;AAEN,MAAA,OAAO,EAAE;AAFH,KADH;AAKL,IAAA,MAAM,EAAE;AACN,MAAA,IAAI,EAAE,CAAC,MAAD,EAAS,MAAT,CADA;AAEN,MAAA,OAAO,EAAE;AAFH,KALH;AASL,IAAA,IAAI,EAAE,MATD;AAUL,IAAA,GAAG,EAAE,OAVA;AAWL;AACA;AACA;AACA,IAAA,KAAK,EAAE;AAdF,GATwB;AA0B/B,EAAA,QAAQ,EAAE;A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AO,EAAE,aAAa,CAAC,OAAd,CAAsB,OAAtB,CAA8B;AA9BhC;AArCsB,CAAlB,CAAf","sourcesContent":["// Styles\nimport '../../styles/components/_selection-controls.sass'\nimport './VRadioGroup.sass'\n\n// Extensions\nimport VInput from '../VInput'\nimport { BaseItemGroup } from '../VItemGroup/VItemGroup'\n\n// Mixins\nimport Comparable from '../../mixins/comparable'\n\n// Types\nimport mixins from '../../util/mixins'\nimport { PropType } from 'vue'\n\nconst baseMixins = mixins(\n Comparable,\n BaseItemGroup,\n VInput\n)\n\n/* @vue/component */\nexport default baseMixins.extend({\n name: 'v-radio-group',\n\n provide () {\n return {\n radioGroup: this,\n }\n },\n\n props: {\n column: {\n type: Boolean,\n default: true,\n },\n height: {\n type: [Number, String],\n default: 'auto',\n },\n name: String,\n row: Boolean,\n // If no value set on VRadio\n // will match valueComparator\n // force default to null\n value: null as unknown as PropType<any>,\n },\n\n computed: {\n classes (): object {\n return {\n ...VInput.options.computed.classes.call(this),\n 'v-input--selection-controls v-input--radio-group': true,\n 'v-input--radio-group--column': this.column && !this.row,\n 'v-input--radio-group--row': this.row,\n }\n },\n },\n\n methods: {\n genDefaultSlot () {\n return this.$createElement('div', {\n staticClass: 'v-input--radio-group__input',\n attrs: {\n id: this.id,\n role: 'radiogroup',\n 'aria-labelledby': this.computedId,\n },\n }, VInput.options.methods.genDefaultSlot.call(this))\n },\n genInputSlot () {\n const render = VInput.options.methods.genInputSlot.call(this)\n\n delete render.data!.on!.click\n\n return render\n },\n genLabel () {\n const label = VInput.options.methods.genLabel.call(this)\n\n if (!label) return null\n\n label.data!.attrs!.id = this.computedId\n // WAI considers this an orphaned label\n delete label.data!.attrs!.for\n label.tag = 'legend'\n\n return label\n },\n onClick: BaseItemGroup.options.methods.onClick,\n },\n})\n"],"sourceRoot":"","file":"VRadioGroup.js"}
+10
View File
@@ -0,0 +1,10 @@
import VRadioGroup from './VRadioGroup';
import VRadio from './VRadio';
export { VRadioGroup, VRadio };
export default {
$_vuetify_subcomponents: {
VRadioGroup,
VRadio
}
};
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/components/VRadioGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAP,MAAwB,eAAxB;AACA,OAAO,MAAP,MAAmB,UAAnB;AAEA,SAAS,WAAT,EAAsB,MAAtB;AAEA,eAAe;AACb,EAAA,uBAAuB,EAAE;AACvB,IAAA,WADuB;AAEvB,IAAA;AAFuB;AADZ,CAAf","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":"","file":"index.js"}