This commit is contained in:
darenhsu
2022-07-17 13:16:16 +08:00
parent 84759556ff
commit befd344ab0
28070 changed files with 4008428 additions and 1 deletions
+204
View File
@@ -0,0 +1,204 @@
// Styles
import "../../../src/components/VCarousel/VCarousel.sass"; // Extensions
import VWindow from '../VWindow/VWindow'; // Components
import VBtn from '../VBtn';
import VIcon from '../VIcon';
import VProgressLinear from '../VProgressLinear'; // Mixins
// TODO: Move this into core components v2.0
import ButtonGroup from '../../mixins/button-group'; // Utilities
import { convertToUnit } from '../../util/helpers';
import { breaking } from '../../util/console';
export default VWindow.extend({
name: 'v-carousel',
props: {
continuous: {
type: Boolean,
default: true
},
cycle: Boolean,
delimiterIcon: {
type: String,
default: '$delimiter'
},
height: {
type: [Number, String],
default: 500
},
hideDelimiters: Boolean,
hideDelimiterBackground: Boolean,
interval: {
type: [Number, String],
default: 6000,
validator: value => value > 0
},
mandatory: {
type: Boolean,
default: true
},
progress: Boolean,
progressColor: String,
showArrows: {
type: Boolean,
default: true
},
verticalDelimiters: {
type: String,
default: undefined
}
},
data() {
return {
internalHeight: this.height,
slideTimeout: undefined
};
},
computed: {
classes() {
return { ...VWindow.options.computed.classes.call(this),
'v-carousel': true,
'v-carousel--hide-delimiter-background': this.hideDelimiterBackground,
'v-carousel--vertical-delimiters': this.isVertical
};
},
isDark() {
return this.dark || !this.light;
},
isVertical() {
return this.verticalDelimiters != null;
}
},
watch: {
internalValue: 'restartTimeout',
interval: 'restartTimeout',
height(val, oldVal) {
if (val === oldVal || !val) return;
this.internalHeight = val;
},
cycle(val) {
if (val) {
this.restartTimeout();
} else {
clearTimeout(this.slideTimeout);
this.slideTimeout = undefined;
}
}
},
created() {
/* istanbul ignore next */
if (this.$attrs.hasOwnProperty('hide-controls')) {
breaking('hide-controls', ':show-arrows="false"', this);
}
},
mounted() {
this.startTimeout();
},
methods: {
genControlIcons() {
if (this.isVertical) return null;
return VWindow.options.methods.genControlIcons.call(this);
},
genDelimiters() {
return this.$createElement('div', {
staticClass: 'v-carousel__controls',
style: {
left: this.verticalDelimiters === 'left' && this.isVertical ? 0 : 'auto',
right: this.verticalDelimiters === 'right' ? 0 : 'auto'
}
}, [this.genItems()]);
},
genItems() {
const length = this.items.length;
const children = [];
for (let i = 0; i < length; i++) {
const child = this.$createElement(VBtn, {
staticClass: 'v-carousel__controls__item',
attrs: {
'aria-label': this.$vuetify.lang.t('$vuetify.carousel.ariaLabel.delimiter', i + 1, length)
},
props: {
icon: true,
small: true,
value: this.getValue(this.items[i], i)
}
}, [this.$createElement(VIcon, {
props: {
size: 18
}
}, this.delimiterIcon)]);
children.push(child);
}
return this.$createElement(ButtonGroup, {
props: {
value: this.internalValue,
mandatory: this.mandatory
},
on: {
change: val => {
this.internalValue = val;
}
}
}, children);
},
genProgress() {
return this.$createElement(VProgressLinear, {
staticClass: 'v-carousel__progress',
props: {
color: this.progressColor,
value: (this.internalIndex + 1) / this.items.length * 100
}
});
},
restartTimeout() {
this.slideTimeout && clearTimeout(this.slideTimeout);
this.slideTimeout = undefined;
window.requestAnimationFrame(this.startTimeout);
},
startTimeout() {
if (!this.cycle) return;
this.slideTimeout = window.setTimeout(this.next, +this.interval > 0 ? +this.interval : 6000);
}
},
render(h) {
const render = VWindow.options.render.call(this, h);
render.data.style = `height: ${convertToUnit(this.height)};`;
/* istanbul ignore else */
if (!this.hideDelimiters) {
render.children.push(this.genDelimiters());
}
/* istanbul ignore else */
if (this.progress || this.progressColor) {
render.children.push(this.genProgress());
}
return render;
}
});
//# sourceMappingURL=VCarousel.js.map
File diff suppressed because one or more lines are too long
+45
View File
@@ -0,0 +1,45 @@
// Extensions
import VWindowItem from '../VWindow/VWindowItem'; // Components
import { VImg } from '../VImg'; // Utilities
import mixins from '../../util/mixins';
import { getSlot } from '../../util/helpers';
import Routable from '../../mixins/routable'; // Types
const baseMixins = mixins(VWindowItem, Routable);
/* @vue/component */
export default baseMixins.extend({
name: 'v-carousel-item',
inheritAttrs: false,
methods: {
genDefaultSlot() {
return [this.$createElement(VImg, {
staticClass: 'v-carousel__item',
props: { ...this.$attrs,
height: this.windowGroup.internalHeight
},
on: this.$listeners,
scopedSlots: {
placeholder: this.$scopedSlots.placeholder
}
}, getSlot(this))];
},
genWindowItem() {
const {
tag,
data
} = this.generateRouteLink();
data.staticClass = 'v-window-item';
data.directives.push({
name: 'show',
value: this.isActive
});
return this.$createElement(tag, data, this.genDefaultSlot());
}
}
});
//# sourceMappingURL=VCarouselItem.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/components/VCarousel/VCarouselItem.ts"],"names":[],"mappings":"AAAA;AACA,OAAO,WAAP,MAAwB,wBAAxB,C,CAEA;;AACA,SAAS,IAAT,QAAqB,SAArB,C,CAEA;;AACA,OAAO,MAAP,MAAmB,mBAAnB;AACA,SAAS,OAAT,QAAwB,oBAAxB;AACA,OAAO,QAAP,MAAqB,uBAArB,C,CAEA;;AACA,MAAM,UAAU,GAAG,MAAM,CACvB,WADuB,EAEvB,QAFuB,CAAzB;AAKA;;AACA,eAAe,UAAU,CAAC,MAAX,CAAkB;AAC/B,EAAA,IAAI,EAAE,iBADyB;AAG/B,EAAA,YAAY,EAAE,KAHiB;AAK/B,EAAA,OAAO,EAAE;AACP,IAAA,cAAc,GAAA;AACZ,aAAO,CACL,KAAK,cAAL,CAAoB,IAApB,EAA0B;AACxB,QAAA,WAAW,EAAE,kBADW;AAExB,QAAA,KAAK,EAAE,EACL,GAAG,KAAK,MADH;AAEL,UAAA,MAAM,EAAE,KAAK,WAAL,CAAiB;AAFpB,SAFiB;AAMxB,QAAA,EAAE,EAAE,KAAK,UANe;AAOxB,QAAA,WAAW,EAAE;AACX,UAAA,WAAW,EAAE,KAAK,YAAL,CAAkB;AADpB;AAPW,OAA1B,EAUG,OAAO,CAAC,IAAD,CAVV,CADK,CAAP;AAaD,KAfM;;AAgBP,IAAA,aAAa,GAAA;AACX,YAAM;AAAE,QAAA,GAAF;AAAO,QAAA;AAAP,UAAgB,KAAK,iBAAL,EAAtB;AAEA,MAAA,IAAI,CAAC,WAAL,GAAmB,eAAnB;AACA,MAAA,IAAI,CAAC,UAAL,CAAiB,IAAjB,CAAsB;AACpB,QAAA,IAAI,EAAE,MADc;AAEpB,QAAA,KAAK,EAAE,KAAK;AAFQ,OAAtB;AAKA,aAAO,KAAK,cAAL,CAAoB,GAApB,EAAyB,IAAzB,EAA+B,KAAK,cAAL,EAA/B,CAAP;AACD;;AA1BM;AALsB,CAAlB,CAAf","sourcesContent":["// Extensions\nimport VWindowItem from '../VWindow/VWindowItem'\n\n// Components\nimport { VImg } from '../VImg'\n\n// Utilities\nimport mixins from '../../util/mixins'\nimport { getSlot } from '../../util/helpers'\nimport Routable from '../../mixins/routable'\n\n// Types\nconst baseMixins = mixins(\n VWindowItem,\n Routable\n)\n\n/* @vue/component */\nexport default baseMixins.extend({\n name: 'v-carousel-item',\n\n inheritAttrs: false,\n\n methods: {\n genDefaultSlot () {\n return [\n this.$createElement(VImg, {\n staticClass: 'v-carousel__item',\n props: {\n ...this.$attrs,\n height: this.windowGroup.internalHeight,\n },\n on: this.$listeners,\n scopedSlots: {\n placeholder: this.$scopedSlots.placeholder,\n },\n }, getSlot(this)),\n ]\n },\n genWindowItem () {\n const { tag, data } = this.generateRouteLink()\n\n data.staticClass = 'v-window-item'\n data.directives!.push({\n name: 'show',\n value: this.isActive,\n })\n\n return this.$createElement(tag, data, this.genDefaultSlot())\n },\n },\n})\n"],"sourceRoot":"","file":"VCarouselItem.js"}
+10
View File
@@ -0,0 +1,10 @@
import VCarousel from './VCarousel';
import VCarouselItem from './VCarouselItem';
export { VCarousel, VCarouselItem };
export default {
$_vuetify_subcomponents: {
VCarousel,
VCarouselItem
}
};
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/components/VCarousel/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAP,MAAsB,aAAtB;AACA,OAAO,aAAP,MAA0B,iBAA1B;AAEA,SAAS,SAAT,EAAoB,aAApB;AAEA,eAAe;AACb,EAAA,uBAAuB,EAAE;AACvB,IAAA,SADuB;AAEvB,IAAA;AAFuB;AADZ,CAAf","sourcesContent":["import VCarousel from './VCarousel'\nimport VCarouselItem from './VCarouselItem'\n\nexport { VCarousel, VCarouselItem }\n\nexport default {\n $_vuetify_subcomponents: {\n VCarousel,\n VCarouselItem,\n },\n}\n"],"sourceRoot":"","file":"index.js"}