Админка

This commit is contained in:
iriska-gri committed 2023-09-18 16:45:39 +03:00
1 parent 6d3adbb54c
commit 0e64eede38
301 files changed
+296588 -14

No files matched your search

+207
View File
@@ -0,0 +1,207 @@
import { defineComponent, openBlock, createBlock, toDisplayString } from 'vue';
var script = defineComponent({
name: "Vue3Autocounter",
interval: null,
props: {
startAmount: {
type: Number,
default: 0
},
endAmount: {
type: Number,
default: 0,
required: true
},
duration: {
type: Number,
default: 3,
validator(duration) {
return duration >= 1;
}
},
autoinit: {
type: Boolean,
default: true
},
prefix: {
type: String,
default: ''
},
suffix: {
type: String,
default: ''
},
separator: {
type: String,
default: ','
},
decimalSeparator: {
type: String,
default: '.'
},
decimals: {
type: Number,
default: 0,
validator(decimals) {
return decimals >= 0;
}
}
},
data() {
return {
timestamp: 0,
startTimestamp: 0,
currentAmount: 0,
currentStartAmount: 0,
currentDuration: 0,
paused: false,
remaining: 0,
animationFrame: 0
};
},
mounted() {
this.currentAmount = this.startAmount;
this.currentStartAmount = this.startAmount;
this.currentDuration = this.duration * 1000;
this.remaining = this.duration * 1000;
if (this.autoinit) this.start();else this.paused = true;
this.$emit('mounted');
},
unmounted() {
this.cancelAnimation();
},
watch: {
startAmount() {
this.reset();
},
endAmount() {
this.reset();
},
duration() {
this.reset();
}
},
computed: {
isCountingUp() {
return this.endAmount > this.startAmount;
},
displayedAmount() {
return `${this.prefix}${this.formatedAmount}${this.suffix}`;
},
formatedAmount() {
const regex = /(\d+)(\d{3})/;
let numberString = this.currentAmount.toFixed(this.decimals);
numberString += '';
let numberArray = numberString.split('.');
let numbers = numberArray[0];
let decimals = numberArray.length > 1 ? this.decimalSeparator + numberArray[1] : '';
let isNumber = !isNaN(parseFloat(this.separator));
if (this.separator && !isNumber) {
while (regex.test(numbers)) numbers = numbers.replace(regex, '$1' + this.separator + '$2');
}
return numbers + decimals;
}
},
methods: {
start() {
this.cancelAnimation();
this.currentStartAmount = this.startAmount;
this.startTimestamp = null;
this.currentDuration = this.duration * 1000;
this.paused = false;
this.animationFrame = window.requestAnimationFrame(this.counting);
},
pause() {
if (this.paused) return;
this.cancelAnimation();
this.paused = true;
},
resume() {
if (!this.paused) return;
this.startTimestamp = null;
this.currentDuration = +this.remaining;
this.currentStartAmount = +this.currentAmount;
this.animationFrame = window.requestAnimationFrame(this.counting);
this.paused = false;
},
reset() {
this.paused = false;
this.startTimestamp = null;
this.cancelAnimation();
this.currentAmount = this.startAmount;
if (this.autoinit) this.start();else this.paused = true;
},
counting(timestamp) {
this.timestamp = timestamp;
if (!this.startTimestamp) this.startTimestamp = timestamp;
let progress = timestamp - this.startTimestamp;
this.remaining = this.currentDuration - progress;
if (!this.isCountingUp) {
this.currentAmount = this.currentStartAmount - (this.currentStartAmount - this.endAmount) * (progress / this.currentDuration);
this.currentAmount = this.currentAmount < this.endAmount ? this.endAmount : this.currentAmount;
} else {
this.currentAmount = this.currentStartAmount + (this.endAmount - this.currentStartAmount) * (progress / this.currentDuration);
this.currentAmount = this.currentAmount > this.endAmount ? this.endAmount : this.currentAmount;
}
if (progress < this.currentDuration) this.animationFrame = window.requestAnimationFrame(this.counting);else {
setTimeout(() => {
this.$emit('finished');
}, 1000);
}
},
cancelAnimation() {
if (this.animationFrame) window.cancelAnimationFrame(this.animationFrame);
}
}
});
function render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createBlock("span", null, toDisplayString(_ctx.displayedAmount), 1);
}
script.render = render;
// Import vue component
// Default export is installable instance of component.
// IIFE injects install function into component, allowing component
// to be registered via Vue.use() as well as Vue.component(),
var entry_esm = /*#__PURE__*/(() => {
// Assign InstallableComponent type
const installable = script; // Attach install function executed by Vue.use()
installable.install = app => {
app.component('Vue3Autocounter', installable);
};
return installable;
})(); // It's possible to expose named exports when writing components that can
// also be used as directives, etc. - eg. import { RollupDemoDirective } from 'rollup-demo';
// export const RollupDemoDirective = directive;
export default entry_esm;
+1
View File
@@ -0,0 +1 @@
var Vue3Autocounter=function(t){"use strict";function n(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],i=!0,e=!1,u=void 0;try{for(var a,o=t[Symbol.iterator]();!(i=(a=o.next()).done)&&(r.push(a.value),!n||r.length!==n);i=!0);}catch(t){e=!0,u=t}finally{try{i||null==o.return||o.return()}finally{if(e)throw u}}return r}(t,n)||function(t,n){if(!t)return;if("string"==typeof t)return r(t,n);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return r(t,n)}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,i=new Array(n);r<n;r++)i[r]=t[r];return i}var i=t.defineComponent({name:"Vue3Autocounter",interval:null,props:{startAmount:{type:Number,default:0},endAmount:{type:Number,default:0,required:!0},duration:{type:Number,default:3,validator:function(t){return t>=1}},autoinit:{type:Boolean,default:!0},prefix:{type:String,default:""},suffix:{type:String,default:""},separator:{type:String,default:","},decimalSeparator:{type:String,default:"."},decimals:{type:Number,default:0,validator:function(t){return t>=0}}},data:function(){return{timestamp:0,startTimestamp:0,currentAmount:0,currentStartAmount:0,currentDuration:0,paused:!1,remaining:0,animationFrame:0}},mounted:function(){this.currentAmount=this.startAmount,this.currentStartAmount=this.startAmount,this.currentDuration=1e3*this.duration,this.remaining=1e3*this.duration,this.autoinit?this.start():this.paused=!0,this.$emit("mounted")},unmounted:function(){this.cancelAnimation()},watch:{startAmount:function(){this.reset()},endAmount:function(){this.reset()},duration:function(){this.reset()}},computed:{isCountingUp:function(){return this.endAmount>this.startAmount},displayedAmount:function(){return"".concat(this.prefix).concat(this.formatedAmount).concat(this.suffix)},formatedAmount:function(){var t=/(\d+)(\d{3})/,n=this.currentAmount.toFixed(this.decimals),r=(n+="").split("."),i=r[0],e=r.length>1?this.decimalSeparator+r[1]:"",u=!isNaN(parseFloat(this.separator));if(this.separator&&!u)for(;t.test(i);)i=i.replace(t,"$1"+this.separator+"$2");return i+e}},methods:{start:function(){this.cancelAnimation(),this.currentStartAmount=this.startAmount,this.startTimestamp=null,this.currentDuration=1e3*this.duration,this.paused=!1,this.animationFrame=window.requestAnimationFrame(this.counting)},pause:function(){this.paused||(this.cancelAnimation(),this.paused=!0)},resume:function(){this.paused&&(this.startTimestamp=null,this.currentDuration=+this.remaining,this.currentStartAmount=+this.currentAmount,this.animationFrame=window.requestAnimationFrame(this.counting),this.paused=!1)},reset:function(){this.paused=!1,this.startTimestamp=null,this.cancelAnimation(),this.currentAmount=this.startAmount,this.autoinit?this.start():this.paused=!0},counting:function(t){var n=this;this.timestamp=t,this.startTimestamp||(this.startTimestamp=t);var r=t-this.startTimestamp;this.remaining=this.currentDuration-r,this.isCountingUp?(this.currentAmount=this.currentStartAmount+(this.endAmount-this.currentStartAmount)*(r/this.currentDuration),this.currentAmount=this.currentAmount>this.endAmount?this.endAmount:this.currentAmount):(this.currentAmount=this.currentStartAmount-(this.currentStartAmount-this.endAmount)*(r/this.currentDuration),this.currentAmount=this.currentAmount<this.endAmount?this.endAmount:this.currentAmount),r<this.currentDuration?this.animationFrame=window.requestAnimationFrame(this.counting):setTimeout((function(){n.$emit("finished")}),1e3)},cancelAnimation:function(){this.animationFrame&&window.cancelAnimationFrame(this.animationFrame)}}});i.render=function(n,r,i,e,u,a){return t.openBlock(),t.createBlock("span",null,t.toDisplayString(n.displayedAmount),1)};var e=function(){var t=i;return t.install=function(n){n.component("Vue3Autocounter",t)},t}(),u=Object.freeze({__proto__:null,default:e});return Object.entries(u).forEach((function(t){var r=n(t,2),i=r[0],u=r[1];"default"!==i&&(e[i]=u)})),e}(Vue);
+245
View File
@@ -0,0 +1,245 @@
'use strict';var vue=require('vue');function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}var script = vue.defineComponent({
name: "Vue3Autocounter",
interval: null,
props: {
startAmount: {
type: Number,
default: 0
},
endAmount: {
type: Number,
default: 0,
required: true
},
duration: {
type: Number,
default: 3,
validator: function validator(duration) {
return duration >= 1;
}
},
autoinit: {
type: Boolean,
default: true
},
prefix: {
type: String,
default: ''
},
suffix: {
type: String,
default: ''
},
separator: {
type: String,
default: ','
},
decimalSeparator: {
type: String,
default: '.'
},
decimals: {
type: Number,
default: 0,
validator: function validator(decimals) {
return decimals >= 0;
}
}
},
data: function data() {
return {
timestamp: 0,
startTimestamp: 0,
currentAmount: 0,
currentStartAmount: 0,
currentDuration: 0,
paused: false,
remaining: 0,
animationFrame: 0
};
},
mounted: function mounted() {
this.currentAmount = this.startAmount;
this.currentStartAmount = this.startAmount;
this.currentDuration = this.duration * 1000;
this.remaining = this.duration * 1000;
if (this.autoinit) this.start();else this.paused = true;
this.$emit('mounted');
},
unmounted: function unmounted() {
this.cancelAnimation();
},
watch: {
startAmount: function startAmount() {
this.reset();
},
endAmount: function endAmount() {
this.reset();
},
duration: function duration() {
this.reset();
}
},
computed: {
isCountingUp: function isCountingUp() {
return this.endAmount > this.startAmount;
},
displayedAmount: function displayedAmount() {
return "".concat(this.prefix).concat(this.formatedAmount).concat(this.suffix);
},
formatedAmount: function formatedAmount() {
var regex = /(\d+)(\d{3})/;
var numberString = this.currentAmount.toFixed(this.decimals);
numberString += '';
var numberArray = numberString.split('.');
var numbers = numberArray[0];
var decimals = numberArray.length > 1 ? this.decimalSeparator + numberArray[1] : '';
var isNumber = !isNaN(parseFloat(this.separator));
if (this.separator && !isNumber) {
while (regex.test(numbers)) {
numbers = numbers.replace(regex, '$1' + this.separator + '$2');
}
}
return numbers + decimals;
}
},
methods: {
start: function start() {
this.cancelAnimation();
this.currentStartAmount = this.startAmount;
this.startTimestamp = null;
this.currentDuration = this.duration * 1000;
this.paused = false;
this.animationFrame = window.requestAnimationFrame(this.counting);
},
pause: function pause() {
if (this.paused) return;
this.cancelAnimation();
this.paused = true;
},
resume: function resume() {
if (!this.paused) return;
this.startTimestamp = null;
this.currentDuration = +this.remaining;
this.currentStartAmount = +this.currentAmount;
this.animationFrame = window.requestAnimationFrame(this.counting);
this.paused = false;
},
reset: function reset() {
this.paused = false;
this.startTimestamp = null;
this.cancelAnimation();
this.currentAmount = this.startAmount;
if (this.autoinit) this.start();else this.paused = true;
},
counting: function counting(timestamp) {
var _this = this;
this.timestamp = timestamp;
if (!this.startTimestamp) this.startTimestamp = timestamp;
var progress = timestamp - this.startTimestamp;
this.remaining = this.currentDuration - progress;
if (!this.isCountingUp) {
this.currentAmount = this.currentStartAmount - (this.currentStartAmount - this.endAmount) * (progress / this.currentDuration);
this.currentAmount = this.currentAmount < this.endAmount ? this.endAmount : this.currentAmount;
} else {
this.currentAmount = this.currentStartAmount + (this.endAmount - this.currentStartAmount) * (progress / this.currentDuration);
this.currentAmount = this.currentAmount > this.endAmount ? this.endAmount : this.currentAmount;
}
if (progress < this.currentDuration) this.animationFrame = window.requestAnimationFrame(this.counting);else {
setTimeout(function () {
_this.$emit('finished');
}, 1000);
}
},
cancelAnimation: function cancelAnimation() {
if (this.animationFrame) window.cancelAnimationFrame(this.animationFrame);
}
}
});function render(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createBlock("span", null, vue.toDisplayString(_ctx.displayedAmount), 1);
}script.render = render;// Import vue component
// Default export is installable instance of component.
// IIFE injects install function into component, allowing component
// to be registered via Vue.use() as well as Vue.component(),
var component = /*#__PURE__*/(function () {
// Assign InstallableComponent type
var installable = script; // Attach install function executed by Vue.use()
installable.install = function (app) {
app.component('Vue3Autocounter', installable);
};
return installable;
})(); // It's possible to expose named exports when writing components that can
// also be used as directives, etc. - eg. import { RollupDemoDirective } from 'rollup-demo';
// export const RollupDemoDirective = directive;
var namedExports=/*#__PURE__*/Object.freeze({__proto__:null,'default': component});// only expose one global var, with named exports exposed as properties of
// that global var (eg. plugin.namedExport)
Object.entries(namedExports).forEach(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
exportName = _ref2[0],
exported = _ref2[1];
if (exportName !== 'default') component[exportName] = exported;
});module.exports=component;