wishthis/node_modules/fomantic-ui/dist/components/dropdown.min.js

11 lines
60 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*
* # Fomantic UI - 2.9.3
2022-01-13 13:00:31 +00:00
* https://github.com/fomantic/Fomantic-UI
2023-08-17 09:47:40 +00:00
* https://fomantic-ui.com/
2022-01-13 13:00:31 +00:00
*
2023-08-17 09:47:40 +00:00
* Copyright 2023 Contributors
2022-01-13 13:00:31 +00:00
* Released under the MIT license
2023-08-17 09:47:40 +00:00
* https://opensource.org/licenses/MIT
2022-01-13 13:00:31 +00:00
*
*/
!function(ee,te,ne){"use strict";function ie(e){return"function"==typeof e&&"number"!=typeof e.nodeType}te=void 0!==te&&te.Math===Math?te:globalThis,ee.fn.dropdown=function(B){var W,Q=ee(this),Y=ee(ne),$=Date.now(),_=[],X=B,G="string"==typeof X,J=[].slice.call(arguments,1),Z=function(e,t){var n;return 0<=[te,ne].indexOf(e)?n=ee(e):0===(n=ee(t.document).find(e)).length&&(n=t.frameElement?Z(e,t.parent):te),n};return Q.each(function(z){var v,P,t,n,i,e,a,o,s,m=ee.isPlainObject(B)?ee.extend(!0,{},ee.fn.dropdown.settings,B):ee.extend({},ee.fn.dropdown.settings),h=m.className,f=m.message,l=m.fields,g=m.keys,p=m.metadata,F=m.namespace,r=m.regExp,b=m.selector,c=m.error,N=m.templates,d="."+F,u="module-"+F,w=ee(this),y=Z(m.context,te),C=w.find(b.text),x=w.find(b.search),S=w.find(b.sizer),A=w.find(b.input),H=w.find(b.icon),j=w.find(b.clearIcon),T=0<w.prev().find(b.text).length?w.prev().find(b.text):w.prev(),k=w.children(b.menu),L=k.find(b.item),I=m.hideDividers?L.parent().children(b.divider):ee(),D=!1,U=!1,K=!1,O=!1,q=this,E=!1,R=w.data(u),V=!1,M={initialize:function(){M.debug("Initializing dropdown",m),M.is.alreadySetup()?M.setup.reference():(m.ignoreDiacritics&&!String.prototype.normalize&&(m.ignoreDiacritics=!1,M.error(c.noNormalize,q)),M.create.id(),M.setup.layout(),m.values&&(M.set.initialLoad(),M.change.values(m.values),M.remove.initialLoad()),M.refreshData(),M.save.defaults(),M.restore.selected(),M.bind.events(),M.observeChanges(),M.instantiate())},instantiate:function(){M.verbose("Storing instance of dropdown",M),R=M,w.data(u,M)},destroy:function(){M.verbose("Destroying previous dropdown",w),M.remove.tabbable(),M.remove.active(),k.transition("stop all"),k.removeClass(h.visible).addClass(h.hidden),w.off(d).removeData(u),k.off(d),Y.off(i),M.disconnect.menuObserver(),M.disconnect.selectObserver(),M.disconnect.classObserver()},observeChanges:function(){"MutationObserver"in te&&(a=new MutationObserver(M.event.select.mutation),o=new MutationObserver(M.event.menu.mutation),s=new MutationObserver(M.event.class.mutation),M.debug("Setting up mutation observer",a,o,s),M.observe.select(),M.observe.menu(),M.observe.class())},disconnect:{menuObserver:function(){o&&o.disconnect()},selectObserver:function(){a&&a.disconnect()},classObserver:function(){s&&s.disconnect()}},observe:{select:function(){M.has.input()&&a&&a.observe(w[0],{attributes:!0,childList:!0,subtree:!0})},menu:function(){M.has.menu()&&o&&o.observe(k[0],{childList:!0,subtree:!0})},class:function(){M.has.search()&&s&&s.observe(w[0],{attributes:!0})}},create:{id:function(){e=(Math.random().toString(16)+"000000000").slice(2,10),i="."+e,M.verbose("Creating unique id for element",e)},userChoice:function(e){var n,i;return!!(e=e||M.get.userValues())&&(e=Array.isArray(e)?e:[e],ee.each(e,function(e,t){!1===M.get.item(t)&&(i=m.templates.addition(M.add.variables(f.addResult,t)),i=ee("<div />").html(i).attr("data-"+p.value,t).attr("data-"+p.text,t).addClass(h.addition).addClass(h.item),m.hideAdditions&&i.addClass(h.hidden),n=void 0===n?i:n.add(i),M.verbose("Creating user choices for value",t,i))}),n)},userLabels:function(e){var t=M.get.userValues();t&&(M.debug("Adding user labels",t),ee.each(t,function(e,t){M.verbose("Adding custom user value"),M.add.label(t,t)}))},menu:function(){k=ee("<div />").addClass(h.menu).appendTo(w)},sizer:function(){S=ee("<span />").addClass(h.sizer).insertAfter(x)}},search:function(e){e=void 0!==e?e:M.get.query(),M.verbose("Searching for query",e),!1===m.fireOnInit&&M.is.initialLoad()?M.verbose("Skipping callback on initial load",m.onSearch):M.has.minCharacters(e)&&!1!==m.onSearch.call(q,e)?M.filter(e):M.hide(null,!0)},select:{firstUnfiltered:function(){M.verbose("Selecting first non-filtered element"),M.remove.selectedItem(),L.not(b.unselectable).not(b.addition+b.hidden).eq(0).addClass(h.selected)},nextAvailable:function(e){var t=(e=e.eq(0)).nextAll(b.item).not(b.unselectable).eq(0),e=e.prevAll(b.item).not(b.unselectable).eq(0);0<t.length?(M.verbose("Moving selection to",t),t.addClass(h.selected)):(M.verbose("Moving selection to",e),e.addClass(h.selected))}},