mirror of
https://github.com/tabler/tabler.git
synced 2026-08-20 18:04:24 +04:00
Release 1.0.0-beta10
This commit is contained in:
+3
-3
File diff suppressed because one or more lines are too long
+34
-3
@@ -13,10 +13,9 @@ var __assign = (this && this.__assign) || function () {
|
||||
var CountUp = /** @class */ (function () {
|
||||
function CountUp(target, endVal, options) {
|
||||
var _this = this;
|
||||
this.target = target;
|
||||
this.endVal = endVal;
|
||||
this.options = options;
|
||||
this.version = '2.0.8';
|
||||
this.version = '2.1.0';
|
||||
this.defaults = {
|
||||
startVal: 0,
|
||||
decimalPlaces: 0,
|
||||
@@ -28,7 +27,9 @@ var CountUp = /** @class */ (function () {
|
||||
separator: ',',
|
||||
decimal: '.',
|
||||
prefix: '',
|
||||
suffix: ''
|
||||
suffix: '',
|
||||
enableScrollSpy: false,
|
||||
scrollSpyDelay: 200,
|
||||
};
|
||||
this.finalEndVal = null; // for smart easing
|
||||
this.useEasing = true;
|
||||
@@ -135,7 +136,37 @@ var CountUp = /** @class */ (function () {
|
||||
else {
|
||||
this.error = '[CountUp] target is null or undefined';
|
||||
}
|
||||
// scroll spy
|
||||
if (window !== undefined && this.options.enableScrollSpy) {
|
||||
if (!this.error) {
|
||||
// set up global array of onscroll functions
|
||||
window['onScrollFns'] = window['onScrollFns'] || [];
|
||||
window['onScrollFns'].push(function () { return _this.handleScroll(_this); });
|
||||
window.onscroll = function () {
|
||||
window['onScrollFns'].forEach(function (fn) { return fn(); });
|
||||
};
|
||||
this.handleScroll(this);
|
||||
}
|
||||
else {
|
||||
console.error(this.error, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
CountUp.prototype.handleScroll = function (self) {
|
||||
if (!self || !window)
|
||||
return;
|
||||
var bottomOfScroll = window.innerHeight + window.scrollY;
|
||||
var bottomOfEl = self.el.offsetTop + self.el.offsetHeight;
|
||||
if (bottomOfEl < bottomOfScroll && bottomOfEl > window.scrollY && self.paused) {
|
||||
// in view
|
||||
self.paused = false;
|
||||
setTimeout(function () { return self.start(); }, self.options.scrollSpyDelay);
|
||||
}
|
||||
else if (window.scrollY > bottomOfEl && !self.paused) {
|
||||
// scrolled past
|
||||
self.reset();
|
||||
}
|
||||
};
|
||||
// determines where easing starts and whether to count down or up
|
||||
CountUp.prototype.determineDirectionAndSmartEasing = function () {
|
||||
var end = (this.finalEndVal) ? this.finalEndVal : this.endVal;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+2
File diff suppressed because one or more lines are too long
+14
-13
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* Tom Select v2.0.0
|
||||
* Tom Select v2.0.1
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
*/
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TomSelect=t()}(this,(function(){"use strict"
|
||||
function e(e,t){e.split(/\s+/).forEach((e=>{t(e)}))}class t{constructor(){this._events={}}on(t,i){e(t,(e=>{this._events[e]=this._events[e]||[],this._events[e].push(i)}))}off(t,i){var s=arguments.length
|
||||
function e(e,t){e.split(/\s+/).forEach((e=>{t(e)}))}class t{constructor(){this._events=void 0,this._events={}}on(t,i){e(t,(e=>{this._events[e]=this._events[e]||[],this._events[e].push(i)}))}off(t,i){var s=arguments.length
|
||||
0!==s?e(t,(e=>{if(1===s)return delete this._events[e]
|
||||
e in this._events!=!1&&this._events[e].splice(this._events[e].indexOf(i),1)})):this._events={}}trigger(t,...i){var s=this
|
||||
e(t,(e=>{if(e in s._events!=!1)for(let t of s._events[e])t.apply(s,i)}))}}var i
|
||||
@@ -33,7 +33,7 @@ return e?-1===(n=(e+="").search(t.regex))?0:(s=t.string.length/e.length,0===n&&(
|
||||
if("function"==typeof i)return i
|
||||
i&&!Array.isArray(i)&&(e[t]=[i])},y=(e,t)=>{if(Array.isArray(e))e.forEach(t)
|
||||
else for(var i in e)e.hasOwnProperty(i)&&t(e[i],i)},O=(e,t)=>"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=c(e+"").toLowerCase())>(t=c(t+"").toLowerCase())?1:t>e?-1:0
|
||||
class w{constructor(e,t){this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t,i){if(!e||!e.length)return[]
|
||||
class w{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t,i){if(!e||!e.length)return[]
|
||||
const s=[],n=e.split(/\s+/)
|
||||
var o
|
||||
return i&&(o=new RegExp("^("+Object.keys(i).map(f).join("|")+"):(.*)$")),n.forEach((e=>{let i,n=null,r=null
|
||||
@@ -122,7 +122,7 @@ if(!e.plugins.hasOwnProperty(t))throw new Error('Unable to find "'+t+'" plugin')
|
||||
s.requested[t]=!0,s.loaded[t]=n.fn.apply(i,[i.plugins.settings[t]||{}]),s.names.push(t)}require(e){var t=this,i=t.plugins
|
||||
if(!t.plugins.loaded.hasOwnProperty(e)){if(i.requested[e])throw new Error('Plugin has circular dependency ("'+e+'")')
|
||||
t.loadPlugin(e)}return i.loaded[e]}}}(t)){constructor(e,t){var i
|
||||
super(),this.order=0,this.isOpen=!1,this.isDisabled=!1,this.isInvalid=!1,this.isValid=!0,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.hasOptions=!1,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],U++
|
||||
super(),this.control_input=void 0,this.wrapper=void 0,this.dropdown=void 0,this.control=void 0,this.dropdown_content=void 0,this.focus_node=void 0,this.order=0,this.settings=void 0,this.input=void 0,this.tabIndex=void 0,this.is_select_tag=void 0,this.rtl=void 0,this.inputId=void 0,this._destroy=void 0,this.sifter=void 0,this.isOpen=!1,this.isDisabled=!1,this.isRequired=void 0,this.isInvalid=!1,this.isValid=!0,this.isLocked=!1,this.isFocused=!1,this.isInputHidden=!1,this.isSetup=!1,this.ignoreFocus=!1,this.hasOptions=!1,this.currentResults=void 0,this.lastValue="",this.caretPos=0,this.loading=0,this.loadedSearches={},this.activeOption=null,this.activeItems=[],this.optgroups={},this.options={},this.userOptions={},this.items=[],U++
|
||||
var s=b(e)
|
||||
if(s.tomselect)throw new Error("Tom Select already initialized on this element")
|
||||
s.tomselect=this,i=(window.getComputedStyle&&window.getComputedStyle(s,null)).getPropertyValue("direction")
|
||||
@@ -197,9 +197,10 @@ i&&C(i,"last-active"),A(e,"active last-active"),t.trigger("item_select",e),-1==t
|
||||
this.activeItems.splice(t,1),C(e,"active")}clearActiveItems(){C(this.activeItems,"active"),this.activeItems=[]}setActiveOption(e){e!==this.activeOption&&(this.clearActiveOption(),e&&(this.activeOption=e,E(this.focus_node,{"aria-activedescendant":e.getAttribute("id")}),E(e,{"aria-selected":"true"}),A(e,"active"),this.scrollToOption(e)))}scrollToOption(e,t){if(!e)return
|
||||
const i=this.dropdown_content,s=i.clientHeight,n=i.scrollTop||0,o=e.offsetHeight,r=e.getBoundingClientRect().top-i.getBoundingClientRect().top+n
|
||||
r+o>s+n?this.scroll(r-s+o,t):r<n&&this.scroll(r,t)}scroll(e,t){const i=this.dropdown_content
|
||||
t&&(i.style.scrollBehavior=t),i.scrollTop=e,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(C(this.activeOption,"active"),E(this.activeOption,{"aria-selected":null})),this.activeOption=null,E(this.focus_node,{"aria-activedescendant":null})}selectAll(){if("single"===this.settings.mode)return
|
||||
const e=this.controlChildren()
|
||||
e.length&&(this.hideInput(),this.close(),this.activeItems=e,A(e,"active"))}inputState(){var e=this
|
||||
t&&(i.style.scrollBehavior=t),i.scrollTop=e,i.style.scrollBehavior=""}clearActiveOption(){this.activeOption&&(C(this.activeOption,"active"),E(this.activeOption,{"aria-selected":null})),this.activeOption=null,E(this.focus_node,{"aria-activedescendant":null})}selectAll(){const e=this
|
||||
if("single"===e.settings.mode)return
|
||||
const t=e.controlChildren()
|
||||
t.length&&(e.hideInput(),e.close(),e.activeItems=t,y(t,(t=>{e.setActiveItemClass(t)})))}inputState(){var e=this
|
||||
e.control.contains(e.control_input)&&(E(e.control_input,{placeholder:e.settings.placeholder}),e.activeItems.length>0||!e.isFocused&&e.settings.hidePlaceholder&&e.items.length>0?(e.setTextboxValue(),e.isInputHidden=!0):(e.settings.hidePlaceholder&&e.items.length>0&&E(e.control_input,{placeholder:""}),e.isInputHidden=!1),e.wrapper.classList.toggle("input-hidden",e.isInputHidden))}hideInput(){this.inputState()}showInput(){this.inputState()}inputValue(){return this.control_input.value.trim()}focus(){var e=this
|
||||
e.isDisabled||(e.ignoreFocus=!0,e.control_input.offsetWidth?e.control_input.focus():e.focus_node.focus(),setTimeout((()=>{e.ignoreFocus=!1,e.onFocus()}),0))}blur(){this.focus_node.blur(),this.onBlur()}getScoreFunction(e){return this.sifter.getScoreFunction(e,this.getSearchOptions())}getSearchOptions(){var e=this.settings,t=e.sortField
|
||||
return"string"==typeof e.sortField&&(t=[{field:e.sortField}]),{fields:e.searchField,conjunction:e.searchConjunction,sort:t,nesting:e.nesting}}search(e){var t,i,s,n=this,o=this.getSearchOptions()
|
||||
@@ -207,16 +208,16 @@ if(n.settings.score&&"function"!=typeof(s=n.settings.score.call(n,e)))throw new
|
||||
if(e!==n.lastQuery?(n.lastQuery=e,i=n.sifter.search(e,Object.assign(o,{score:s})),n.currentResults=i):i=Object.assign({},n.currentResults),n.settings.hideSelected)for(t=i.items.length-1;t>=0;t--){let e=q(i.items[t].id)
|
||||
e&&-1!==n.items.indexOf(e)&&i.items.splice(t,1)}return i}refreshOptions(e=!0){var t,i,s,n,o,r,l,a,c,d,p
|
||||
const u={},h=[]
|
||||
var g,v=this,f=v.inputValue(),m=v.search(f),O=v.activeOption,w=v.settings.shouldOpen||!1,b=v.dropdown_content
|
||||
for(O&&(c=O.dataset.value,d=O.closest("[data-group]")),n=m.items.length,"number"==typeof v.settings.maxOptions&&(n=Math.min(n,v.settings.maxOptions)),n>0&&(w=!0),t=0;t<n;t++){let e=m.items[t].id,n=v.options[e],l=v.getOption(e,!0)
|
||||
for(v.settings.hideSelected||l.classList.toggle("selected",v.items.includes(e)),o=n[v.settings.optgroupField]||"",i=0,s=(r=Array.isArray(o)?o:[o])&&r.length;i<s;i++)o=r[i],v.optgroups.hasOwnProperty(o)||(o=""),u.hasOwnProperty(o)||(u[o]=document.createDocumentFragment(),h.push(o)),i>0&&(l=l.cloneNode(!0),E(l,{id:n.$id+"-clone-"+i,"aria-selected":null}),l.classList.add("ts-cloned"),C(l,"active")),c==e&&d&&d.dataset.group===o&&(O=l),u[o].appendChild(l)}this.settings.lockOptgroupOrder&&h.sort(((e,t)=>(v.optgroups[e]&&v.optgroups[e].$order||0)-(v.optgroups[t]&&v.optgroups[t].$order||0))),l=document.createDocumentFragment(),y(h,(e=>{if(v.optgroups.hasOwnProperty(e)&&u[e].children.length){let t=document.createDocumentFragment(),i=v.render("optgroup_header",v.optgroups[e])
|
||||
var g,v=this,f=v.inputValue(),m=v.search(f),O=null,w=v.settings.shouldOpen||!1,b=v.dropdown_content
|
||||
for(v.activeOption&&(c=v.activeOption.dataset.value,d=v.activeOption.closest("[data-group]")),n=m.items.length,"number"==typeof v.settings.maxOptions&&(n=Math.min(n,v.settings.maxOptions)),n>0&&(w=!0),t=0;t<n;t++){let e=m.items[t].id,n=v.options[e],l=v.getOption(e,!0)
|
||||
for(v.settings.hideSelected||l.classList.toggle("selected",v.items.includes(e)),o=n[v.settings.optgroupField]||"",i=0,s=(r=Array.isArray(o)?o:[o])&&r.length;i<s;i++)o=r[i],v.optgroups.hasOwnProperty(o)||(o=""),u.hasOwnProperty(o)||(u[o]=document.createDocumentFragment(),h.push(o)),i>0&&(l=l.cloneNode(!0),E(l,{id:n.$id+"-clone-"+i,"aria-selected":null}),l.classList.add("ts-cloned"),C(l,"active")),O||c!=e||(d?d.dataset.group===o&&(O=l):O=l),u[o].appendChild(l)}this.settings.lockOptgroupOrder&&h.sort(((e,t)=>(v.optgroups[e]&&v.optgroups[e].$order||0)-(v.optgroups[t]&&v.optgroups[t].$order||0))),l=document.createDocumentFragment(),y(h,(e=>{if(v.optgroups.hasOwnProperty(e)&&u[e].children.length){let t=document.createDocumentFragment(),i=v.render("optgroup_header",v.optgroups[e])
|
||||
G(t,i),G(t,u[e])
|
||||
let s=v.render("optgroup",{group:v.optgroups[e],options:t})
|
||||
G(l,s)}else G(l,u[e])})),b.innerHTML="",G(b,l),v.settings.highlight&&(g=b.querySelectorAll("span.highlight"),Array.prototype.forEach.call(g,(function(e){var t=e.parentNode
|
||||
t.replaceChild(e.firstChild,e),t.normalize()})),m.query.length&&m.tokens.length&&y(m.tokens,(e=>{V(b,e.regex)})))
|
||||
var I=e=>{let t=v.render(e,{input:f})
|
||||
return t&&(w=!0,b.insertBefore(t,b.firstChild)),t}
|
||||
if(v.loading?I("loading"):v.settings.shouldLoad.call(v,f)?0===m.items.length&&I("no_results"):I("not_loading"),(a=v.canCreate(f))&&(p=I("option_create")),v.hasOptions=m.items.length>0||a,w){if(m.items.length>0){if(!b.contains(O)&&"single"===v.settings.mode&&v.items.length&&(O=v.getOption(v.items[0])),!b.contains(O)){let e=0
|
||||
if(v.loading?I("loading"):v.settings.shouldLoad.call(v,f)?0===m.items.length&&I("no_results"):I("not_loading"),(a=v.canCreate(f))&&(p=I("option_create")),v.hasOptions=m.items.length>0||a,w){if(m.items.length>0){if(!O&&"single"===v.settings.mode&&v.items.length&&(O=v.getOption(v.items[0])),!b.contains(O)){let e=0
|
||||
p&&!v.settings.addPrecedence&&(e=1),O=v.selectable()[e]}}else p&&(O=p)
|
||||
e&&!v.isOpen&&(v.open(),v.scrollToOption(O,"auto")),v.setActiveOption(O)}else v.clearActiveOption(),e&&v.isOpen&&v.close(!1)}selectable(){return this.dropdown_content.querySelectorAll("[data-selectable]")}addOption(e,t=!1){const i=this
|
||||
if(Array.isArray(e))return i.addOptions(e,t),!1
|
||||
@@ -269,8 +270,8 @@ s.toggle("focus",e.isFocused),s.toggle("disabled",e.isDisabled),s.toggle("requir
|
||||
e.input.checkValidity&&(e.isValid=e.input.checkValidity(),e.isInvalid=!e.isValid)}isFull(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems}updateOriginalInput(e={}){const t=this
|
||||
var i,s
|
||||
const n=t.input.querySelector('option[value=""]')
|
||||
if(t.is_select_tag){const e=[]
|
||||
function o(i,s,o){return i||(i=b('<option value="'+N(s)+'">'+N(o)+"</option>")),i!=n&&t.input.append(i),e.push(i),i.selected=!0,i}t.input.querySelectorAll("option:checked").forEach((e=>{e.selected=!1})),0==t.items.length&&"single"==t.settings.mode?o(n,"",""):t.items.forEach((n=>{if(i=t.options[n],s=i[t.settings.labelField]||"",e.includes(i.$option)){o(t.input.querySelector(`option[value="${Q(n)}"]:not(:checked)`),n,s)}else i.$option=o(i.$option,n,s)}))}else t.input.value=t.getValue()
|
||||
if(t.is_select_tag){const e=[],r=t.input.querySelectorAll("option:checked").length
|
||||
function o(i,s,o){return i||(i=b('<option value="'+N(s)+'">'+N(o)+"</option>")),i!=n&&t.input.append(i),e.push(i),(i!=n||r>0)&&(i.selected=!0),i}t.input.querySelectorAll("option:checked").forEach((e=>{e.selected=!1})),0==t.items.length&&"single"==t.settings.mode?o(n,"",""):t.items.forEach((n=>{if(i=t.options[n],s=i[t.settings.labelField]||"",e.includes(i.$option)){o(t.input.querySelector(`option[value="${Q(n)}"]:not(:checked)`),n,s)}else i.$option=o(i.$option,n,s)}))}else t.input.value=t.getValue()
|
||||
t.isSetup&&(e.silent||t.trigger("change",t.getValue()))}open(){var e=this
|
||||
e.isLocked||e.isOpen||"multi"===e.settings.mode&&e.isFull()||(e.isOpen=!0,E(e.focus_node,{"aria-expanded":"true"}),e.refreshState(),S(e.dropdown,{visibility:"hidden",display:"block"}),e.positionDropdown(),S(e.dropdown,{visibility:"visible",display:"block"}),e.focus(),e.trigger("dropdown_open",e.dropdown))}close(e=!0){var t=this,i=t.isOpen
|
||||
e&&(t.setTextboxValue(),"single"===t.settings.mode&&t.items.length&&t.hideInput()),t.isOpen=!1,E(t.focus_node,{"aria-expanded":"false"}),S(t.dropdown,{display:"none"}),t.settings.hideSelected&&t.clearActiveOption(),t.refreshState(),i&&t.trigger("dropdown_close",t.dropdown)}positionDropdown(){if("body"===this.settings.dropdownParent){var e=this.control,t=e.getBoundingClientRect(),i=e.offsetHeight+t.top+window.scrollY,s=t.left+window.scrollX
|
||||
|
||||
Reference in New Issue
Block a user