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
+115
View File
@@ -0,0 +1,115 @@
// Styles
import "../../../src/components/VStepper/VStepper.sass"; // Mixins
import { provide as RegistrableProvide } from '../../mixins/registrable';
import Proxyable from '../../mixins/proxyable';
import Themeable from '../../mixins/themeable'; // Utilities
import mixins from '../../util/mixins';
import { breaking } from '../../util/console';
const baseMixins = mixins(RegistrableProvide('stepper'), Proxyable, Themeable);
/* @vue/component */
export default baseMixins.extend({
name: 'v-stepper',
provide() {
return {
stepClick: this.stepClick,
isVertical: this.vertical
};
},
props: {
altLabels: Boolean,
nonLinear: Boolean,
vertical: Boolean
},
data() {
const data = {
isBooted: false,
steps: [],
content: [],
isReverse: false
};
data.internalLazyValue = this.value != null ? this.value : (data[0] || {}).step || 1;
return data;
},
computed: {
classes() {
return {
'v-stepper--is-booted': this.isBooted,
'v-stepper--vertical': this.vertical,
'v-stepper--alt-labels': this.altLabels,
'v-stepper--non-linear': this.nonLinear,
...this.themeClasses
};
}
},
watch: {
internalValue(val, oldVal) {
this.isReverse = Number(val) < Number(oldVal);
oldVal && (this.isBooted = true);
this.updateView();
}
},
created() {
/* istanbul ignore next */
if (this.$listeners.input) {
breaking('@input', '@change', this);
}
},
mounted() {
this.updateView();
},
methods: {
register(item) {
if (item.$options.name === 'v-stepper-step') {
this.steps.push(item);
} else if (item.$options.name === 'v-stepper-content') {
item.isVertical = this.vertical;
this.content.push(item);
}
},
unregister(item) {
if (item.$options.name === 'v-stepper-step') {
this.steps = this.steps.filter(i => i !== item);
} else if (item.$options.name === 'v-stepper-content') {
item.isVertical = this.vertical;
this.content = this.content.filter(i => i !== item);
}
},
stepClick(step) {
this.$nextTick(() => this.internalValue = step);
},
updateView() {
for (let index = this.steps.length; --index >= 0;) {
this.steps[index].toggle(this.internalValue);
}
for (let index = this.content.length; --index >= 0;) {
this.content[index].toggle(this.internalValue, this.isReverse);
}
}
},
render(h) {
return h('div', {
staticClass: 'v-stepper',
class: this.classes
}, this.$slots.default);
}
});
//# sourceMappingURL=VStepper.js.map
File diff suppressed because one or more lines are too long
+131
View File
@@ -0,0 +1,131 @@
// Components
import { VTabTransition, VTabReverseTransition } from '../transitions'; // Mixins
import { inject as RegistrableInject } from '../../mixins/registrable'; // Helpers
import { convertToUnit } from '../../util/helpers'; // Utilities
import mixins from '../../util/mixins';
const baseMixins = mixins(RegistrableInject('stepper', 'v-stepper-content', 'v-stepper'));
/* @vue/component */
export default baseMixins.extend().extend({
name: 'v-stepper-content',
inject: {
isVerticalProvided: {
from: 'isVertical'
}
},
props: {
step: {
type: [Number, String],
required: true
}
},
data() {
return {
height: 0,
// Must be null to allow
// previous comparison
isActive: null,
isReverse: false,
isVertical: this.isVerticalProvided
};
},
computed: {
computedTransition() {
// Fix for #8978
const reverse = this.$vuetify.rtl ? !this.isReverse : this.isReverse;
return reverse ? VTabReverseTransition : VTabTransition;
},
styles() {
if (!this.isVertical) return {};
return {
height: convertToUnit(this.height)
};
}
},
watch: {
isActive(current, previous) {
// If active and the previous state
// was null, is just booting up
if (current && previous == null) {
this.height = 'auto';
return;
}
if (!this.isVertical) return;
if (this.isActive) this.enter();else this.leave();
}
},
mounted() {
this.$refs.wrapper.addEventListener('transitionend', this.onTransition, false);
this.stepper && this.stepper.register(this);
},
beforeDestroy() {
this.$refs.wrapper.removeEventListener('transitionend', this.onTransition, false);
this.stepper && this.stepper.unregister(this);
},
methods: {
onTransition(e) {
if (!this.isActive || e.propertyName !== 'height') return;
this.height = 'auto';
},
enter() {
let scrollHeight = 0; // Render bug with height
requestAnimationFrame(() => {
scrollHeight = this.$refs.wrapper.scrollHeight;
});
this.height = 0; // Give the collapsing element time to collapse
setTimeout(() => this.isActive && (this.height = scrollHeight || 'auto'), 450);
},
leave() {
this.height = this.$refs.wrapper.clientHeight;
setTimeout(() => this.height = 0, 10);
},
toggle(step, reverse) {
this.isActive = step.toString() === this.step.toString();
this.isReverse = reverse;
}
},
render(h) {
const contentData = {
staticClass: 'v-stepper__content'
};
const wrapperData = {
staticClass: 'v-stepper__wrapper',
style: this.styles,
ref: 'wrapper'
};
if (!this.isVertical) {
contentData.directives = [{
name: 'show',
value: this.isActive
}];
}
const wrapper = h('div', wrapperData, [this.$slots.default]);
const content = h('div', contentData, [wrapper]);
return h(this.computedTransition, {
on: this.$listeners
}, [content]);
}
});
//# sourceMappingURL=VStepperContent.js.map
File diff suppressed because one or more lines are too long
+144
View File
@@ -0,0 +1,144 @@
// Components
import VIcon from '../VIcon'; // Mixins
import Colorable from '../../mixins/colorable';
import { inject as RegistrableInject } from '../../mixins/registrable'; // Directives
import ripple from '../../directives/ripple'; // Utilities
import mixins from '../../util/mixins';
const baseMixins = mixins(Colorable, RegistrableInject('stepper', 'v-stepper-step', 'v-stepper'));
/* @vue/component */
export default baseMixins.extend().extend({
name: 'v-stepper-step',
directives: {
ripple
},
inject: ['stepClick'],
props: {
color: {
type: String,
default: 'primary'
},
complete: Boolean,
completeIcon: {
type: String,
default: '$complete'
},
editable: Boolean,
editIcon: {
type: String,
default: '$edit'
},
errorIcon: {
type: String,
default: '$error'
},
rules: {
type: Array,
default: () => []
},
step: [Number, String]
},
data() {
return {
isActive: false,
isInactive: true
};
},
computed: {
classes() {
return {
'v-stepper__step--active': this.isActive,
'v-stepper__step--editable': this.editable,
'v-stepper__step--inactive': this.isInactive,
'v-stepper__step--error error--text': this.hasError,
'v-stepper__step--complete': this.complete
};
},
hasError() {
return this.rules.some(validate => validate() !== true);
}
},
mounted() {
this.stepper && this.stepper.register(this);
},
beforeDestroy() {
this.stepper && this.stepper.unregister(this);
},
methods: {
click(e) {
e.stopPropagation();
this.$emit('click', e);
if (this.editable) {
this.stepClick(this.step);
}
},
genIcon(icon) {
return this.$createElement(VIcon, icon);
},
genLabel() {
return this.$createElement('div', {
staticClass: 'v-stepper__label'
}, this.$slots.default);
},
genStep() {
const color = !this.hasError && (this.complete || this.isActive) ? this.color : false;
return this.$createElement('span', this.setBackgroundColor(color, {
staticClass: 'v-stepper__step__step'
}), this.genStepContent());
},
genStepContent() {
const children = [];
if (this.hasError) {
children.push(this.genIcon(this.errorIcon));
} else if (this.complete) {
if (this.editable) {
children.push(this.genIcon(this.editIcon));
} else {
children.push(this.genIcon(this.completeIcon));
}
} else {
children.push(String(this.step));
}
return children;
},
toggle(step) {
this.isActive = step.toString() === this.step.toString();
this.isInactive = Number(step) < Number(this.step);
}
},
render(h) {
return h('div', {
staticClass: 'v-stepper__step',
class: this.classes,
directives: [{
name: 'ripple',
value: this.editable
}],
on: {
click: this.click
}
}, [this.genStep(), this.genLabel()]);
}
});
//# sourceMappingURL=VStepperStep.js.map
File diff suppressed because one or more lines are too long
+17
View File
@@ -0,0 +1,17 @@
import { createSimpleFunctional } from '../../util/helpers';
import VStepper from './VStepper';
import VStepperStep from './VStepperStep';
import VStepperContent from './VStepperContent';
const VStepperHeader = createSimpleFunctional('v-stepper__header');
const VStepperItems = createSimpleFunctional('v-stepper__items');
export { VStepper, VStepperContent, VStepperStep, VStepperHeader, VStepperItems };
export default {
$_vuetify_subcomponents: {
VStepper,
VStepperContent,
VStepperStep,
VStepperHeader,
VStepperItems
}
};
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/components/VStepper/index.ts"],"names":[],"mappings":"AAAA,SAAS,sBAAT,QAAuC,oBAAvC;AACA,OAAO,QAAP,MAAqB,YAArB;AACA,OAAO,YAAP,MAAyB,gBAAzB;AACA,OAAO,eAAP,MAA4B,mBAA5B;AAEA,MAAM,cAAc,GAAG,sBAAsB,CAAC,mBAAD,CAA7C;AACA,MAAM,aAAa,GAAG,sBAAsB,CAAC,kBAAD,CAA5C;AAEA,SACE,QADF,EAEE,eAFF,EAGE,YAHF,EAIE,cAJF,EAKE,aALF;AAQA,eAAe;AACb,EAAA,uBAAuB,EAAE;AACvB,IAAA,QADuB;AAEvB,IAAA,eAFuB;AAGvB,IAAA,YAHuB;AAIvB,IAAA,cAJuB;AAKvB,IAAA;AALuB;AADZ,CAAf","sourcesContent":["import { createSimpleFunctional } from '../../util/helpers'\nimport VStepper from './VStepper'\nimport VStepperStep from './VStepperStep'\nimport VStepperContent from './VStepperContent'\n\nconst VStepperHeader = createSimpleFunctional('v-stepper__header')\nconst VStepperItems = createSimpleFunctional('v-stepper__items')\n\nexport {\n VStepper,\n VStepperContent,\n VStepperStep,\n VStepperHeader,\n VStepperItems,\n}\n\nexport default {\n $_vuetify_subcomponents: {\n VStepper,\n VStepperContent,\n VStepperStep,\n VStepperHeader,\n VStepperItems,\n },\n}\n"],"sourceRoot":"","file":"index.js"}