New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@digibib/deichman-admin-frontend-common

Package Overview
Dependencies
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@digibib/deichman-admin-frontend-common - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

28

CHANGELOG.md

@@ -6,6 +6,31 @@ # Changelog

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
an d this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
## 2.2.0
* `Added` Autocomplete - `placeholder` property to set placeholder text for the input.
* `Added` Autocomplete - `labelFunction` property - to be used to extract label from whatever object.
* `Added` Autocomplete - no hits (ingen treff) is not displayed if no items are supplied or all of them were removed.
* `Added` Autocomplete - suggestion list is not displayed if no items are supplied or all of them were removed.
* `Added` Autocomplete - open/close icon is not displayed if no items are supplied or all of them were removed.
* `Added` Autocomplete - text input is disabled if no items are supplied or all of them were removed.
* `Added` Autocomplete - increased test coverage for user interaction tests (Autocomplete.test.ts).
* `Added` Autocomplete - support for inputProps (props propagated to the input field).
* `Added` Autocomplete - support for openIcon/closeIcon slots.
* `Fixed` Autocomplete - better encapsulation in InternalItems - using private methods.
* `Fixed` Autocomplete - streamlined dropdown open event handling - using mouseDown all over the place to secure more
robust and concise functionality.
* `Fixed` Autocomplete - more consistent functionality if minCharsToSuggest is set to 0. The dropdown list can be closed
on all usual ways ([ESC], close icon, tabbing away/losing focus by any other means). Previously losing focus/close icon
was not working.
* `Fixed` Autocomplete - layout when not displaying label is fixed now. The component resizes itself correctly based on
its `wide`/`showNumberOfHits` properties. See dev app for playground.
* `Fixed` Autocomplete - in case of `closeOnSelect === true` and `minCharsToSuggest === 0` the suggestion list did not
close
## 2.1.0
* `Fixed` Suggestion list did not open on doubleClick

@@ -17,2 +42,3 @@ * `Added` Option to set tab index.

Bugfixes and build system improvements.
Note, that this release was unfortunately not following semantic versioning strictly.

@@ -19,0 +45,0 @@ * `Added` `wide` option to AutoComplete

2

dist/index.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("svelte/internal"),require("svelte")):"function"==typeof define&&define.amd?define(["exports","svelte/internal","svelte"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Autocomplete={},e["svelte/internal"],e.svelte)}(this,(function(e,t,i){"use strict";class n{constructor({originalItem:e,displayLabel:t,originalLabel:i,highlighted:n}){this._originalItem=e,this._displayLabel=t,this._originalLabel=i,this._highlighted=n,this.key=Symbol(),this._index=0}get originalItem(){return this._originalItem}get originalLabel(){return this._originalLabel}get index(){return this._index}set index(e){this._index=e}get displayLabel(){return this._displayLabel}set displayLabel(e){this._displayLabel=e}get highlighted(){return this._highlighted}set highlighted(e){this._highlighted=e}}class l{constructor(e,t){const i={simple:e=>new n({originalItem:e,displayLabel:e,originalLabel:e,highlighted:!1}),complex:e=>new n({originalItem:e,displayLabel:e[t],originalLabel:e[t],highlighted:!1})},l="object"==typeof(e&&e[0]);if(l&&null==t)throw new Error("labelFieldName should be set for complex objects");this.itemConverter=null!=t&&l?i.complex:i.simple,this.items=e.map(this.itemConverter),this.sortItems()}sortItems(){this.items.sort((e,t)=>e.originalLabel.localeCompare(t.originalLabel))}filter(e,t=!1){const i=new RegExp(this.escapeRegExp(e),t?"":"i");return this.items.filter(t=>""===e||t.originalLabel.match(i)).map((e,t)=>(e.index=t,e.displayLabel=e.originalLabel.replace(i,(function(e){return""!=e?`<B>${e}</B>`:""})),e))}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}addItem(e){this.items=[...this.items,this.itemConverter(e)],this.sortItems()}remove(e){this.items=this.items.filter(t=>t.key!==e.key)}}class s{constructor(e=!1){this._opened=!1,this.userOpened=!1,this._highlightedItem=null,this.filterText="",this._filteredItems=[],this.internalItems=null,this.filterCaseSensitive=e}get highlightedItem(){return this._highlightedItem}get filteredItems(){return this._filteredItems}highlight(e){return null!=this._highlightedItem&&(this._highlightedItem.highlighted=!1,this._highlightedItem=null),null!=e?(e.highlighted=!0,this._highlightedItem=e):this._highlightedItem=null,this}highlightNext(){if(null!=this._highlightedItem){const e=this._highlightedItem.index+1<this._filteredItems.length?this._highlightedItem.index+1:0;this.highlight(this._filteredItems[e])}return this}highlightPrev(){if(null!=this._highlightedItem){const e=0===this._highlightedItem.index?this._filteredItems.length-1:this._highlightedItem.index-1;this.highlight(this._filteredItems[e])}return this}shiftHighlightBy(e){if(null!=this._highlightedItem){const t=this._highlightedItem.index,i=Math.min(Math.max(0,t+e),this._filteredItems.length-1);this.highlight(this._filteredItems[i])}return this}setOpened(e){return this._opened=e,e||(this.userOpened=!1),this}get opened(){return this._opened}setUserOpened(e){return this.userOpened=e,this}setItems(e,t){return this.internalItems=new l(e,t),this.filter(this.filterText),this.highlight(null),this}addItem(e){var t;return null===(t=this.internalItems)||void 0===t||t.addItem(e),this.filter(this.filterText),this}filter(e){var t,i;return this.filterText=e,this._filteredItems=null!==(i=null===(t=this.internalItems)||void 0===t?void 0:t.filter(this.filterText,this.filterCaseSensitive))&&void 0!==i?i:[],null!=this._highlightedItem&&this._filteredItems.some(e=>e.key===this._highlightedItem.key)||this.highlight(this._filteredItems[0]),this}isHighlighted(e){return this._highlightedItem.key===e.key}removeHighlighted(){if(null!=this._highlightedItem){const e=Math.max(this._highlightedItem.index-1,0);this.internalItems.remove(this._highlightedItem),this.filter(this.filterText),this._filteredItems.length>0?this.highlight(this._filteredItems[e]):this.highlight(null)}return this}}var o;!function(e){e.AC_LIST="ac-list",e.AC_LIST_ITEM="ac-list-item",e.OPEN_LIST="open-list",e.CLOSE_LIST="close-list"}(o||(o={}));var r=o;const{window:h}=t.globals;function a(e){t.append_styles(e,"svelte-1icczi","div.dropdown.svelte-1icczi.svelte-1icczi{background:#fff;position:absolute;max-width:100%;min-width:200px;overflow-y:auto;z-index:99;padding:0 0;top:0;border:1px solid #999;max-height:calc(10 * (1rem + 10px) + 15px);user-select:none}div.dropdown.hidden.svelte-1icczi.svelte-1icczi{visibility:hidden}div.dropdown.svelte-1icczi .list-item.highlighted.svelte-1icczi{background-color:#bbbb}div.autocomplete.svelte-1icczi.svelte-1icczi{position:relative}div.autocomplete.svelte-1icczi .input-label.svelte-1icczi{text-align:right;color:#aaaaaa;white-space:nowrap;min-width:6rem}div.autocomplete.svelte-1icczi input.svelte-1icczi{display:inline-block;width:auto;min-width:10rem}div.autocomplete.svelte-1icczi input.wide.svelte-1icczi{width:calc(100% - 7rem)}div.autocomplete.svelte-1icczi .openClose.svelte-1icczi{display:inline-block;position:relative;left:-1.2rem;font-size:0.7rem;user-select:none;width:1.5rem}div.autocomplete.svelte-1icczi .openClose.arrow.svelte-1icczi{transform:scale(1.5, 1)}div.autocomplete.svelte-1icczi .openClose.circle.svelte-1icczi{transform:scale(1.5, 1.5)}.openClose.svelte-1icczi.svelte-1icczi:hover{cursor:pointer}")}function c(e,t,i){const n=e.slice();return n[54]=t[i],n}const d=e=>({item:1024&e[0],displayLabel:1024&e[0]}),u=e=>({item:e[54].originalItem,displayLabel:e[54].displayLabel});function p(e){let i,n,l,s;return{c(){i=t.element("div"),n=t.text("ᐯ"),t.attr(i,"class","openClose arrow svelte-1icczi"),t.attr(i,"data-testid",r.OPEN_LIST)},m(o,r){t.insert(o,i,r),t.append(i,n),l||(s=t.listen(i,"click",e[38]),l=!0)},p:t.noop,d(e){e&&t.detach(i),l=!1,s()}}}function g(e){let i,n,l,s;return{c(){i=t.element("div"),n=t.text("Ⓧ"),t.attr(i,"class","openClose circle svelte-1icczi"),t.attr(i,"data-testid",r.CLOSE_LIST)},m(o,r){t.insert(o,i,r),t.append(i,n),l||(s=t.listen(i,"click",e[17]),l=!0)},p:t.noop,d(e){e&&t.detach(i),l=!1,s()}}}function m(e){let i,n,l=`${e[10].filteredItems.length} ${e[10].filteredItems.length>1?e[4].hits:e[4].hit}`;return{c(){i=t.element("label"),n=t.text(l),t.attr(i,"class","input-label svelte-1icczi"),t.attr(i,"for",e[13])},m(e,l){t.insert(e,i,l),t.append(i,n)},p(e,i){1040&i[0]&&l!==(l=`${e[10].filteredItems.length} ${e[10].filteredItems.length>1?e[4].hits:e[4].hit}`)&&t.set_data(n,l)},d(e){e&&t.detach(i)}}}function f(e){let i,n,l=e[4].noHit+"";return{c(){i=t.element("div"),n=t.text(l),t.attr(i,"class","list-item")},m(e,l){t.insert(e,i,l),t.append(i,n)},p(e,i){16&i[0]&&l!==(l=e[4].noHit+"")&&t.set_data(n,l)},i:t.noop,o:t.noop,d(e){e&&t.detach(i)}}}function v(e){let i,n,l=e[10].filteredItems,s=[];for(let t=0;t<l.length;t+=1)s[t]=_(c(e,l,t));const o=e=>t.transition_out(s[e],1,1,()=>{s[e]=null});return{c(){for(let e=0;e<s.length;e+=1)s[e].c();i=t.empty()},m(e,l){for(let t=0;t<s.length;t+=1)s[t].m(e,l);t.insert(e,i,l),n=!0},p(e,n){if(5252096&n[0]|4&n[1]){let r;for(l=e[10].filteredItems,r=0;r<l.length;r+=1){const o=c(e,l,r);s[r]?(s[r].p(o,n),t.transition_in(s[r],1)):(s[r]=_(o),s[r].c(),t.transition_in(s[r],1),s[r].m(i.parentNode,i))}for(t.group_outros(),r=l.length;r<s.length;r+=1)o(r);t.check_outros()}},i(e){if(!n){for(let e=0;e<l.length;e+=1)t.transition_in(s[e]);n=!0}},o(e){s=s.filter(Boolean);for(let e=0;e<s.length;e+=1)t.transition_out(s[e]);n=!1},d(e){t.destroy_each(s,e),e&&t.detach(i)}}}function _(e){let i,n,l,s,o;const h=e[34].listItem,a=t.create_slot(h,e,e[33],u),c=a||function(e){let i,n,l=e[54].displayLabel+"";return{c(){i=new t.HtmlTag(!1),n=t.empty(),i.a=n},m(e,s){i.m(l,e,s),t.insert(e,n,s)},p(e,t){1024&t[0]&&l!==(l=e[54].displayLabel+"")&&i.p(l)},d(e){e&&t.detach(n),e&&i.d()}}}(e);function p(){return e[39](e[54])}return{c(){i=t.element("div"),c&&c.c(),n=t.space(),t.attr(i,"data-testid",r.AC_LIST_ITEM),t.attr(i,"class",t.null_to_empty("list-item "+e[13])+" svelte-1icczi"),t.toggle_class(i,"highlighted",e[10].isHighlighted(e[54]))},m(r,h){t.insert(r,i,h),c&&c.m(i,null),t.append(i,n),l=!0,s||(o=[t.listen(i,"pointerenter",p),t.listen(i,"mousedown",e[40])],s=!0)},p(n,s){e=n,a?a.p&&(!l||1024&s[0]|4&s[1])&&t.update_slot_base(a,h,e,e[33],l?t.get_slot_changes(h,e[33],s,d):t.get_all_dirty_from_scope(e[33]),u):c&&c.p&&(!l||1024&s[0])&&c.p(e,l?s:[-1,-1]),1024&s[0]&&t.toggle_class(i,"highlighted",e[10].isHighlighted(e[54]))},i(e){l||(t.transition_in(c,e),l=!0)},o(e){t.transition_out(c,e),l=!1},d(e){e&&t.detach(i),c&&c.d(e),s=!1,t.run_all(o)}}}function I(e){let i,n,l,s,o,a,c,d,u,_,I,y,w,S;function z(e,t){return e[10].opened?g:p}let L=z(e),C=L(e),O=e[6]&&m(e);const $=[v,f],k=[];function T(e,t){return e[10].filteredItems.length>0?0:1}return d=T(e),u=k[d]=$[d](e),{c(){i=t.element("div"),n=t.element("input"),s=t.space(),C.c(),o=t.space(),O&&O.c(),a=t.space(),c=t.element("div"),u.c(),t.attr(n,"class",l=t.null_to_empty(e[3].join(" "))+" svelte-1icczi"),t.attr(n,"id",e[13]),t.attr(n,"style",e[2]),t.attr(n,"tabindex",e[8]),t.attr(n,"type","text"),t.toggle_class(n,"wide",e[7]),t.attr(c,"data-testid",r.AC_LIST),t.attr(c,"class","dropdown svelte-1icczi"),t.attr(c,"style",_="z-index: "+(e[5]+1)),t.attr(c,"tabindex","-1"),t.toggle_class(c,"hidden",!e[10].opened),t.attr(i,"class",I=t.null_to_empty(`autocomplete ${e[13]} ${e[0].join(" ")}`)+" svelte-1icczi"),t.attr(i,"style",e[1])},m(l,r){t.insert(l,i,r),t.append(i,n),e[36](n),t.set_input_value(n,e[9]),t.append(i,s),C.m(i,null),t.append(i,o),O&&O.m(i,null),t.append(i,a),t.append(i,c),k[d].m(c,null),e[41](c),y=!0,w||(S=[t.listen(h,"mousedown",e[21]),t.listen(h,"scroll",e[35]),t.listen(n,"input",e[37]),t.listen(n,"blur",e[15]),t.listen(n,"dblclick",e[19]),t.listen(n,"focus",e[14]),t.listen(n,"keydown",e[18]),t.listen(c,"keydown",t.prevent_default(b)),t.listen(c,"scroll",t.stop_propagation(t.prevent_default(x)))],w=!0)},p(e,s){(!y||8&s[0]&&l!==(l=t.null_to_empty(e[3].join(" "))+" svelte-1icczi"))&&t.attr(n,"class",l),(!y||4&s[0])&&t.attr(n,"style",e[2]),(!y||256&s[0])&&t.attr(n,"tabindex",e[8]),512&s[0]&&n.value!==e[9]&&t.set_input_value(n,e[9]),136&s[0]&&t.toggle_class(n,"wide",e[7]),L===(L=z(e))&&C?C.p(e,s):(C.d(1),C=L(e),C&&(C.c(),C.m(i,o))),e[6]?O?O.p(e,s):(O=m(e),O.c(),O.m(i,a)):O&&(O.d(1),O=null);let r=d;d=T(e),d===r?k[d].p(e,s):(t.group_outros(),t.transition_out(k[r],1,1,()=>{k[r]=null}),t.check_outros(),u=k[d],u?u.p(e,s):(u=k[d]=$[d](e),u.c()),t.transition_in(u,1),u.m(c,null)),(!y||32&s[0]&&_!==(_="z-index: "+(e[5]+1)))&&t.attr(c,"style",_),1024&s[0]&&t.toggle_class(c,"hidden",!e[10].opened),(!y||1&s[0]&&I!==(I=t.null_to_empty(`autocomplete ${e[13]} ${e[0].join(" ")}`)+" svelte-1icczi"))&&t.attr(i,"class",I),(!y||2&s[0])&&t.attr(i,"style",e[1])},i(e){y||(t.transition_in(u),y=!0)},o(e){t.transition_out(u),y=!1},d(n){n&&t.detach(i),e[36](null),C.d(),O&&O.d(),k[d].d(),e[41](null),w=!1,t.run_all(S)}}}let y=0;const b=()=>!1,x=()=>!1;function w(e,n,l){let o,{$$slots:r={},$$scope:h}=n;const a=i.createEventDispatcher();let{items:c=[]}=n,{labelFieldName:d=""}=n,{containerClassNames:u=[]}=n,{containerStyle:p=""}=n,{inputStyle:g=""}=n,{inputClassNames:m=[]}=n,{i18n:f={hit:" treff",hits:" treff",noHit:"Ingen treff"}}=n,{minCharsToSuggest:v=3}=n,{removeOnSelect:_=!1}=n,{closeOnSelect:I=!0}=n,{zIndexOffset:b=0}=n,{preferOpenUpwards:x=!1}=n,{showNumberOfHits:w=!0}=n,{caseSensitive:S=!1}=n,{wide:z=!1}=n,{tabIndex:L=null}=n;const C="autocomplete-"+y++;let O,$,k=!1,T=!1,N="",E=[];function H(e=!1){l(10,o=o.setOpened(!0).setUserOpened(e)),M()}function A(){l(10,o=o.setOpened(!1))}i.afterUpdate(()=>{E.forEach(e=>e()),E=[]});const P={Escape:function(){l(9,N=""),A()},ArrowDown:U,ArrowUp:U,Enter:B,Backspace:function(){N.length<=1&&A()},Tab:function(){T=!0},PageDown:j,PageUp:j};function U(e){e.stopPropagation(),e.preventDefault(),o.opened?("ArrowDown"===(null==e?void 0:e.key)&&l(10,o=o.highlightNext()),"ArrowUp"===(null==e?void 0:e.key)&&l(10,o=o.highlightPrev()),q()):H(!0)}function B(e){o.opened&&(null!==o.highlightedItem&&(a("select",{selected:o.highlightedItem.originalItem}),_&&(l(10,o=o.removeHighlighted()),M())),I?A():e&&_&&E.push(()=>{const e=Array.from(document.querySelectorAll(":hover")).find(e=>{var t,i;return(null===(t=e.classList)||void 0===t?void 0:t.contains(C))&&(null===(i=e.classList)||void 0===i?void 0:i.contains("list-item"))});null==e||e.dispatchEvent(new PointerEvent("pointerenter"))}))}function j(e){if(e.stopPropagation(),e.preventDefault(),o.opened){const t="PageDown"===e.key?1:-1,i=O.scrollHeight/o.filteredItems.length,n=Math.floor(O.getBoundingClientRect().height/i)-1;l(10,o=o.shiftHighlightBy(t*n)),q()}else H(!0)}function D(e){o.isHighlighted(e)||l(10,o=o.highlight(e))}function M(){E.push(()=>R()),q()}function q(){E.push(()=>{var e;o.opened&&(null===(e=O.querySelector(".highlighted"))||void 0===e||e.scrollIntoView({behavior:"auto",block:"nearest",inline:"start"}))})}function R(){const{height:e,pageLeft:t}=window.visualViewport,{bottom:i,height:n,top:s}=$.getBoundingClientRect(),{height:o}=O.getBoundingClientRect();l(11,O.style.top=i+o>e||x&&s-o>t?`-${o}px`:n+"px",O)}return e.$$set=e=>{"items"in e&&l(24,c=e.items),"labelFieldName"in e&&l(25,d=e.labelFieldName),"containerClassNames"in e&&l(0,u=e.containerClassNames),"containerStyle"in e&&l(1,p=e.containerStyle),"inputStyle"in e&&l(2,g=e.inputStyle),"inputClassNames"in e&&l(3,m=e.inputClassNames),"i18n"in e&&l(4,f=e.i18n),"minCharsToSuggest"in e&&l(26,v=e.minCharsToSuggest),"removeOnSelect"in e&&l(27,_=e.removeOnSelect),"closeOnSelect"in e&&l(28,I=e.closeOnSelect),"zIndexOffset"in e&&l(5,b=e.zIndexOffset),"preferOpenUpwards"in e&&l(29,x=e.preferOpenUpwards),"showNumberOfHits"in e&&l(6,w=e.showNumberOfHits),"caseSensitive"in e&&l(30,S=e.caseSensitive),"wide"in e&&l(7,z=e.wide),"tabIndex"in e&&l(8,L=e.tabIndex),"$$scope"in e&&l(33,h=e.$$scope)},e.$$.update=()=>{1124073472&e.$$.dirty[0]&&l(10,o=new s(S).setItems(c||[],d)),1536&e.$$.dirty[0]&&(!function(e){l(10,o=o.filter(e)),q()}(N),o.opened&&M()),67110400&e.$$.dirty[0]|2&e.$$.dirty[1]&&(N.length>=v&&!o.opened&&k?H(!1):(o.opened&&!o.userOpened&&N.length<v||!k)&&A())},[u,p,g,m,f,b,w,z,L,N,o,O,$,C,function(){l(32,k=!0)},function(){const e=Array.from(document.querySelectorAll(":hover")).some(e=>{var t;return null===(t=e.classList)||void 0===t?void 0:t.contains(C)});l(32,k=!T&&e),E.push(()=>T=!1)},H,A,function(e){return P[e.key]&&P[e.key](e)},function(){!o.opened&&H(!0)},B,function(e){e.composedPath().some(e=>{var t,i;return null!==(i=null===(t=e.classList)||void 0===t?void 0:t.contains(C))&&void 0!==i&&i})?(!o.opened&&document.activeElement===$&&N.length>=v&&H(!1),window.setTimeout((function(){$.focus()}),1)):A()},D,R,c,d,v,_,I,x,S,function(e){l(10,o=o.addItem(e))},k,h,r,()=>{o.opened&&R()},function(e){t.binding_callbacks[e?"unshift":"push"](()=>{$=e,l(12,$)})},function(){N=this.value,l(9,N)},()=>H(!0),e=>D(e),()=>B(!0),function(e){t.binding_callbacks[e?"unshift":"push"](()=>{O=e,l(11,O)})}]}class S extends t.SvelteComponent{constructor(e){super(),t.init(this,e,w,I,t.safe_not_equal,{items:24,labelFieldName:25,containerClassNames:0,containerStyle:1,inputStyle:2,inputClassNames:3,i18n:4,minCharsToSuggest:26,removeOnSelect:27,closeOnSelect:28,zIndexOffset:5,preferOpenUpwards:29,showNumberOfHits:6,caseSensitive:30,wide:7,tabIndex:8,addItem:31},a,[-1,-1])}get addItem(){return this.$$.ctx[31]}}e.Autocomplete=S,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("svelte/internal"),require("svelte")):"function"==typeof define&&define.amd?define(["exports","svelte/internal","svelte"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Autocomplete={},e["svelte/internal"],e.svelte)}(this,(function(e,t,i){"use strict";class n{constructor({originalItem:e,displayLabel:t,originalLabel:i,highlighted:n}){this._originalItem=e,this._displayLabel=t,this._originalLabel=i,this._highlighted=n,this.key=Symbol(),this._index=0}get originalItem(){return this._originalItem}get originalLabel(){return this._originalLabel}get index(){return this._index}set index(e){this._index=e}get displayLabel(){return this._displayLabel}set displayLabel(e){this._displayLabel=e}get highlighted(){return this._highlighted}set highlighted(e){this._highlighted=e}}class s{constructor(e,t){this.labelFunction=t,this.items=e.map(this.convertItem.bind(this)),this.sortItems()}filter(e,t=!1){const i=new RegExp(s.escapeRegExp(e),t?"":"i");return this.items.filter(t=>""===e||t.originalLabel.match(i)).map((e,t)=>(e.index=t,e.displayLabel=e.originalLabel.replace(i,(function(e){return""!=e?`<B>${e}</B>`:""})),e))}addItem(e){this.items=[...this.items,this.convertItem(e)],this.sortItems()}remove(e){this.items=this.items.filter(t=>t.key!==e.key)}hasItems(){return 0!==this.items.length}static escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}sortItems(){this.items.sort((e,t)=>e.originalLabel.localeCompare(t.originalLabel))}convertItem(e){return new n({originalItem:e,displayLabel:this.labelFunction(e),originalLabel:this.labelFunction(e),highlighted:!1})}}class l{constructor(e=!1){this._opened=!1,this._userOpened=!1,this._highlightedItem=null,this.filterText="",this._filteredItems=[],this.internalItems=null,this.filterCaseSensitive=e}highlight(e){return null!=this._highlightedItem&&(this._highlightedItem.highlighted=!1,this._highlightedItem=null),null!=e?(e.highlighted=!0,this._highlightedItem=e):this._highlightedItem=null,this}highlightNext(){if(null!=this._highlightedItem){const e=this._highlightedItem.index+1<this._filteredItems.length?this._highlightedItem.index+1:0;this.highlight(this._filteredItems[e])}return this}highlightPrev(){if(null!=this._highlightedItem){const e=0===this._highlightedItem.index?this._filteredItems.length-1:this._highlightedItem.index-1;this.highlight(this._filteredItems[e])}return this}shiftHighlightBy(e){if(null!=this._highlightedItem){const t=this._highlightedItem.index,i=Math.min(Math.max(0,t+e),this._filteredItems.length-1);this.highlight(this._filteredItems[i])}return this}setOpened(e){return this._opened=e,e?this._userClosed=!1:this._userOpened=!1,this}get opened(){return this._opened}setUserOpened(e){return this._userOpened=e,this}setItems(e,t){return this.internalItems=new s(e,t),this.filter(this.filterText),this.highlight(null),this}hasItems(){return this.internalItems.hasItems()}addItem(e){var t;return null===(t=this.internalItems)||void 0===t||t.addItem(e),this.filter(this.filterText),this}filter(e){var t,i;return this.filterText=e,this._filteredItems=null!==(i=null===(t=this.internalItems)||void 0===t?void 0:t.filter(this.filterText,this.filterCaseSensitive))&&void 0!==i?i:[],null!=this._highlightedItem&&this._filteredItems.some(e=>e.key===this._highlightedItem.key)||this.highlight(this._filteredItems[0]),this}isHighlighted(e){return this._highlightedItem.key===e.key}removeHighlighted(){if(null!=this._highlightedItem){const e=Math.max(this._highlightedItem.index-1,0);this.internalItems.remove(this._highlightedItem),this.filter(this.filterText),this._filteredItems.length>0?this.highlight(this._filteredItems[e]):this.highlight(null)}return this}get userClosed(){return this._userClosed}set userClosed(e){this._userClosed=e}get userOpened(){return this._userOpened}set userOpened(e){this._userOpened=e}get highlightedItem(){return this._highlightedItem}get filteredItems(){return this._filteredItems}}var o;!function(e){e.AC_LIST="ac-list",e.AC_LIST_ITEM="ac-list-item",e.CLOSE_LIST="close-list",e.OPEN_LIST="open-list",e.ROOT="root"}(o||(o={}));var a=o;const{window:r}=t.globals;function h(e){t.append_styles(e,"svelte-aniw8a","div.autocomplete.svelte-aniw8a{position:relative;display:flex;align-content:center;justify-content:start}label.input-label.svelte-aniw8a{text-align:right;color:#aaaaaa;white-space:nowrap;min-width:6rem;margin:auto 0}input.svelte-aniw8a{display:inline-block;width:auto;min-width:10rem}input.wide.svelte-aniw8a{width:100%}div.input-and-icons.svelte-aniw8a{position:relative;display:flex;align-items:center;justify-content:stretch}div.input-and-icons.wide.svelte-aniw8a{width:100%}div.dropdown.svelte-aniw8a{background:#fff;position:absolute;max-width:100%;min-width:200px;overflow-y:auto;z-index:99;padding:0 0;top:0;border:1px solid #999;max-height:calc(10 * (1rem + 10px) + 15px);user-select:none}div.dropdown.hidden.svelte-aniw8a{visibility:hidden}div.list-item.highlighted.svelte-aniw8a{background-color:#bbbb}div.openClose.svelte-aniw8a{display:inline-block;position:relative;left:-1.2rem;font-size:0.7rem;user-select:none;width:1.5rem}div.openClose.wide.svelte-aniw8a{position:absolute;left:calc(100% - 1.2rem)}div.openClose.arrow.svelte-aniw8a{transform:scale(1.5, 1)}div.openClose.circle.svelte-aniw8a{transform:scale(1.5, 1.5)}div.openClose.svelte-aniw8a:hover{cursor:pointer}")}function d(e,t,i){const n=e.slice();return n[60]=t[i],n}const u=e=>({item:4096&e[0],displayLabel:4096&e[0]}),c=e=>({item:e[60].originalItem,displayLabel:e[60].displayLabel}),g=e=>({}),p=e=>({}),m=e=>({}),f=e=>({});function _(e){let i,n,s,l;const o=[I,v],a=[];function r(e,t){return e[12].opened?0:1}return i=r(e),n=a[i]=o[i](e),{c(){n.c(),s=t.empty()},m(e,n){a[i].m(e,n),t.insert(e,s,n),l=!0},p(e,l){let h=i;i=r(e),i===h?a[i].p(e,l):(t.group_outros(),t.transition_out(a[h],1,1,()=>{a[h]=null}),t.check_outros(),n=a[i],n?n.p(e,l):(n=a[i]=o[i](e),n.c()),t.transition_in(n,1),n.m(s.parentNode,s))},i(e){l||(t.transition_in(n),l=!0)},o(e){t.transition_out(n),l=!1},d(e){a[i].d(e),e&&t.detach(s)}}}function v(e){let i,n,s,l;const o=e[38].openIcon,r=t.create_slot(o,e,e[37],p),h=r||function(e){let i;return{c(){i=t.text("ᐯ")},m(e,n){t.insert(e,i,n)},d(e){e&&t.detach(i)}}}();return{c(){i=t.element("div"),h&&h.c(),t.attr(i,"class","openClose arrow svelte-aniw8a"),t.attr(i,"data-testid",a.OPEN_LIST),t.toggle_class(i,"wide",e[7])},m(o,a){t.insert(o,i,a),h&&h.m(i,null),n=!0,s||(l=t.listen(i,"mousedown",e[43]),s=!0)},p(e,s){r&&r.p&&(!n||64&s[1])&&t.update_slot_base(r,o,e,e[37],n?t.get_slot_changes(o,e[37],s,g):t.get_all_dirty_from_scope(e[37]),p),128&s[0]&&t.toggle_class(i,"wide",e[7])},i(e){n||(t.transition_in(h,e),n=!0)},o(e){t.transition_out(h,e),n=!1},d(e){e&&t.detach(i),h&&h.d(e),s=!1,l()}}}function I(e){let i,n,s,l;const o=e[38].closeIcon,r=t.create_slot(o,e,e[37],f),h=r||function(e){let i;return{c(){i=t.text("Ⓧ")},m(e,n){t.insert(e,i,n)},d(e){e&&t.detach(i)}}}();return{c(){i=t.element("div"),h&&h.c(),t.attr(i,"class","openClose circle svelte-aniw8a"),t.attr(i,"data-testid",a.CLOSE_LIST),t.toggle_class(i,"wide",e[7])},m(o,a){t.insert(o,i,a),h&&h.m(i,null),n=!0,s||(l=t.listen(i,"mousedown",e[42]),s=!0)},p(e,s){r&&r.p&&(!n||64&s[1])&&t.update_slot_base(r,o,e,e[37],n?t.get_slot_changes(o,e[37],s,m):t.get_all_dirty_from_scope(e[37]),f),128&s[0]&&t.toggle_class(i,"wide",e[7])},i(e){n||(t.transition_in(h,e),n=!0)},o(e){t.transition_out(h,e),n=!1},d(e){e&&t.detach(i),h&&h.d(e),s=!1,l()}}}function w(e){let i,n,s=`${e[12].filteredItems.length} ${e[12].filteredItems.length>1?e[4].hits:e[4].hit}`;return{c(){i=t.element("label"),n=t.text(s),t.attr(i,"class","input-label svelte-aniw8a"),t.attr(i,"for",e[15])},m(e,s){t.insert(e,i,s),t.append(i,n)},p(e,i){4112&i[0]&&s!==(s=`${e[12].filteredItems.length} ${e[12].filteredItems.length>1?e[4].hits:e[4].hit}`)&&t.set_data(n,s)},d(e){e&&t.detach(i)}}}function b(e){let i,n,s=e[4].noHit+"";return{c(){i=t.element("div"),n=t.text(s),t.attr(i,"class","list-item")},m(e,s){t.insert(e,i,s),t.append(i,n)},p(e,i){16&i[0]&&s!==(s=e[4].noHit+"")&&t.set_data(n,s)},i:t.noop,o:t.noop,d(e){e&&t.detach(i)}}}function y(e){let i,n,s=e[12].filteredItems,l=[];for(let t=0;t<s.length;t+=1)l[t]=x(d(e,s,t));const o=e=>t.transition_out(l[e],1,1,()=>{l[e]=null});return{c(){for(let e=0;e<l.length;e+=1)l[e].c();i=t.empty()},m(e,s){for(let t=0;t<l.length;t+=1)l[t].m(e,s);t.insert(e,i,s),n=!0},p(e,n){if(21008384&n[0]|64&n[1]){let a;for(s=e[12].filteredItems,a=0;a<s.length;a+=1){const o=d(e,s,a);l[a]?(l[a].p(o,n),t.transition_in(l[a],1)):(l[a]=x(o),l[a].c(),t.transition_in(l[a],1),l[a].m(i.parentNode,i))}for(t.group_outros(),a=s.length;a<l.length;a+=1)o(a);t.check_outros()}},i(e){if(!n){for(let e=0;e<s.length;e+=1)t.transition_in(l[e]);n=!0}},o(e){l=l.filter(Boolean);for(let e=0;e<l.length;e+=1)t.transition_out(l[e]);n=!1},d(e){t.destroy_each(l,e),e&&t.detach(i)}}}function x(e){let i,n,s,l,o;const r=e[38].listItem,h=t.create_slot(r,e,e[37],c),d=h||function(e){let i,n,s=e[60].displayLabel+"";return{c(){i=new t.HtmlTag(!1),n=t.empty(),i.a=n},m(e,l){i.m(s,e,l),t.insert(e,n,l)},p(e,t){4096&t[0]&&s!==(s=e[60].displayLabel+"")&&i.p(s)},d(e){e&&t.detach(n),e&&i.d()}}}(e);function g(){return e[44](e[60])}return{c(){i=t.element("div"),d&&d.c(),n=t.space(),t.attr(i,"data-testid",a.AC_LIST_ITEM),t.attr(i,"class",t.null_to_empty("list-item "+e[15])+" svelte-aniw8a"),t.toggle_class(i,"highlighted",e[12].isHighlighted(e[60]))},m(a,r){t.insert(a,i,r),d&&d.m(i,null),t.append(i,n),s=!0,l||(o=[t.listen(i,"pointerenter",g),t.listen(i,"mousedown",e[45])],l=!0)},p(n,l){e=n,h?h.p&&(!s||4096&l[0]|64&l[1])&&t.update_slot_base(h,r,e,e[37],s?t.get_slot_changes(r,e[37],l,u):t.get_all_dirty_from_scope(e[37]),c):d&&d.p&&(!s||4096&l[0])&&d.p(e,s?l:[-1,-1,-1]),4096&l[0]&&t.toggle_class(i,"highlighted",e[12].isHighlighted(e[60]))},i(e){s||(t.transition_in(d,e),s=!0)},o(e){t.transition_out(d,e),s=!1},d(e){e&&t.detach(i),d&&d.d(e),l=!1,t.run_all(o)}}}function O(e){let i,n,s,l,o,h,d,u,c,g,p,m,f,v,I,x,O,S=e[12].hasItems(),L=[{autocomplete:"off"},{class:l=e[3].join(" ")},{id:e[15]},{style:e[2]},{tabindex:e[8]},{placeholder:o=e[12].hasItems()?e[9]:void 0},{disabled:h=!e[12].hasItems()},{type:"text"},e[10]],k={};for(let e=0;e<L.length;e+=1)k=t.assign(k,L[e]);let T=S&&_(e),N=e[6]&&w(e);const H=[y,b],E=[];function P(e,t){return e[12].filteredItems.length>0?0:1}return p=P(e),m=E[p]=H[p](e),{c(){i=t.element("div"),n=t.element("div"),s=t.element("input"),d=t.space(),T&&T.c(),u=t.space(),N&&N.c(),c=t.space(),g=t.element("div"),m.c(),t.set_attributes(s,k),t.toggle_class(s,"wide",e[7]),t.toggle_class(s,"svelte-aniw8a",!0),t.attr(n,"class","input-and-icons svelte-aniw8a"),t.toggle_class(n,"wide",e[7]),t.attr(g,"data-testid",a.AC_LIST),t.attr(g,"class","dropdown svelte-aniw8a"),t.attr(g,"style",f="z-index: "+(e[5]+1)),t.toggle_class(g,"hidden",!(e[12].opened&&e[12].hasItems())),t.attr(i,"class",v=t.null_to_empty(`autocomplete ${e[15]} ${e[0].join(" ")}`)+" svelte-aniw8a"),t.attr(i,"style",e[1]),t.attr(i,"data-testid",a.ROOT)},m(l,o){t.insert(l,i,o),t.append(i,n),t.append(n,s),s.autofocus&&s.focus(),e[40](s),t.set_input_value(s,e[11]),t.append(n,d),T&&T.m(n,null),t.append(i,u),N&&N.m(i,null),t.append(i,c),t.append(i,g),E[p].m(g,null),e[46](g),I=!0,x||(O=[t.listen(r,"mousedown",e[23]),t.listen(r,"scroll",e[39]),t.listen(s,"input",e[41]),t.listen(s,"blur",e[17]),t.listen(s,"dblclick",e[21]),t.listen(s,"focus",e[16]),t.listen(s,"keydown",e[20]),t.listen(g,"keydown",t.prevent_default(C)),t.listen(g,"scroll",t.stop_propagation(t.prevent_default($))),t.listen(i,"mousedown",t.stop_propagation(t.prevent_default(e[47])))],x=!0)},p(e,a){t.set_attributes(s,k=t.get_spread_update(L,[{autocomplete:"off"},(!I||8&a[0]&&l!==(l=e[3].join(" ")))&&{class:l},{id:e[15]},(!I||4&a[0])&&{style:e[2]},(!I||256&a[0])&&{tabindex:e[8]},(!I||4608&a[0]&&o!==(o=e[12].hasItems()?e[9]:void 0))&&{placeholder:o},(!I||4096&a[0]&&h!==(h=!e[12].hasItems()))&&{disabled:h},{type:"text"},1024&a[0]&&e[10]])),2048&a[0]&&s.value!==e[11]&&t.set_input_value(s,e[11]),t.toggle_class(s,"wide",e[7]),t.toggle_class(s,"svelte-aniw8a",!0),4096&a[0]&&(S=e[12].hasItems()),S?T?(T.p(e,a),4096&a[0]&&t.transition_in(T,1)):(T=_(e),T.c(),t.transition_in(T,1),T.m(n,null)):T&&(t.group_outros(),t.transition_out(T,1,1,()=>{T=null}),t.check_outros()),128&a[0]&&t.toggle_class(n,"wide",e[7]),e[6]?N?N.p(e,a):(N=w(e),N.c(),N.m(i,c)):N&&(N.d(1),N=null);let r=p;p=P(e),p===r?E[p].p(e,a):(t.group_outros(),t.transition_out(E[r],1,1,()=>{E[r]=null}),t.check_outros(),m=E[p],m?m.p(e,a):(m=E[p]=H[p](e),m.c()),t.transition_in(m,1),m.m(g,null)),(!I||32&a[0]&&f!==(f="z-index: "+(e[5]+1)))&&t.attr(g,"style",f),4096&a[0]&&t.toggle_class(g,"hidden",!(e[12].opened&&e[12].hasItems())),(!I||1&a[0]&&v!==(v=t.null_to_empty(`autocomplete ${e[15]} ${e[0].join(" ")}`)+" svelte-aniw8a"))&&t.attr(i,"class",v),(!I||2&a[0])&&t.attr(i,"style",e[1])},i(e){I||(t.transition_in(T),t.transition_in(m),I=!0)},o(e){t.transition_out(T),t.transition_out(m),I=!1},d(n){n&&t.detach(i),e[40](null),T&&T.d(),N&&N.d(),E[p].d(),e[46](null),x=!1,t.run_all(O)}}}let S=0;const C=()=>!1,$=()=>!1;function L(e,n,s){let o,a,{$$slots:r={},$$scope:h}=n;const d=i.createEventDispatcher();let{items:u=[]}=n,{labelFieldName:c=null}=n,{labelFunction:g=null}=n,{containerClassNames:p=[]}=n,{containerStyle:m=""}=n,{inputStyle:f=""}=n,{inputClassNames:_=[]}=n,{i18n:v={hit:" treff",hits:" treff",noHit:"Ingen treff"}}=n,{minCharsToSuggest:I=3}=n,{removeOnSelect:w=!1}=n,{closeOnSelect:b=!0}=n,{zIndexOffset:y=0}=n,{preferOpenUpwards:x=!1}=n,{showNumberOfHits:O=!0}=n,{caseSensitive:C=!1}=n,{wide:$=!1}=n,{tabIndex:L=null}=n,{placeholder:k=null}=n,{inputProps:T={}}=n;const N="autocomplete-"+S++;let H,E,P=!1,A=!1,F="",U=[];function B(e=!1){s(12,a=a.setOpened(!0).setUserOpened(e)),V()}function j(e=!1){s(12,a.userClosed=e,a),s(12,a=a.setOpened(!1))}i.afterUpdate(()=>{U.forEach(e=>e()),U=[]});const z={Escape:function(){s(11,F=""),E.blur(),s(35,P=!1),j(!0)},ArrowDown:R,ArrowUp:R,Enter:D,Backspace:function(){F.length<=1&&j()},Tab:function(){A=!0},PageDown:M,PageUp:M};function R(e){e.stopPropagation(),e.preventDefault(),a.opened?("ArrowDown"===(null==e?void 0:e.key)&&s(12,a=a.highlightNext()),"ArrowUp"===(null==e?void 0:e.key)&&s(12,a=a.highlightPrev()),G()):B(!0)}function D(e){a.opened&&(null!==a.highlightedItem&&(d("select",{selected:a.highlightedItem.originalItem}),w&&(s(12,a=a.removeHighlighted()),a.hasItems()||s(11,F=""),V())),b?j(!0):e&&w&&U.push(()=>{const e=Array.from(document.querySelectorAll(":hover")).find(e=>{var t,i;return(null===(t=e.classList)||void 0===t?void 0:t.contains(N))&&(null===(i=e.classList)||void 0===i?void 0:i.contains("list-item"))});null==e||e.dispatchEvent(new PointerEvent("pointerenter"))}))}function M(e){if(e.stopPropagation(),e.preventDefault(),a.opened){const t="PageDown"===e.key?1:-1,i=H.scrollHeight/a.filteredItems.length,n=Math.floor(H.getBoundingClientRect().height/i)-1;s(12,a=a.shiftHighlightBy(t*n)),G()}else B(!0)}function q(e){a.isHighlighted(e)||s(12,a=a.highlight(e))}function V(){U.push(()=>J()),G()}function G(){U.push(()=>{var e;a.opened&&(null===(e=H.querySelector(".highlighted"))||void 0===e||e.scrollIntoView({behavior:"auto",block:"nearest",inline:"start"}))})}function J(){const{height:e,pageLeft:t}=window.visualViewport,{bottom:i,height:n,top:l}=E.getBoundingClientRect(),{height:o}=H.getBoundingClientRect();s(13,H.style.top=i+o>e||x&&l-o>t?`-${o}px`:n+"px",H)}return e.$$set=e=>{"items"in e&&s(26,u=e.items),"labelFieldName"in e&&s(27,c=e.labelFieldName),"labelFunction"in e&&s(28,g=e.labelFunction),"containerClassNames"in e&&s(0,p=e.containerClassNames),"containerStyle"in e&&s(1,m=e.containerStyle),"inputStyle"in e&&s(2,f=e.inputStyle),"inputClassNames"in e&&s(3,_=e.inputClassNames),"i18n"in e&&s(4,v=e.i18n),"minCharsToSuggest"in e&&s(29,I=e.minCharsToSuggest),"removeOnSelect"in e&&s(30,w=e.removeOnSelect),"closeOnSelect"in e&&s(31,b=e.closeOnSelect),"zIndexOffset"in e&&s(5,y=e.zIndexOffset),"preferOpenUpwards"in e&&s(32,x=e.preferOpenUpwards),"showNumberOfHits"in e&&s(6,O=e.showNumberOfHits),"caseSensitive"in e&&s(33,C=e.caseSensitive),"wide"in e&&s(7,$=e.wide),"tabIndex"in e&&s(8,L=e.tabIndex),"placeholder"in e&&s(9,k=e.placeholder),"inputProps"in e&&s(10,T=e.inputProps),"$$scope"in e&&s(37,h=e.$$scope)},e.$$.update=()=>{402653184&e.$$.dirty[0]&&s(36,o=null!=g?g:null!=c?e=>e[c]:e=>e),67108864&e.$$.dirty[0]|36&e.$$.dirty[1]&&s(12,a=new l(C).setItems(u||[],o)),6144&e.$$.dirty[0]&&(!function(e){s(12,a=a.filter(e)),G()}(F),a.opened&&V()),536877056&e.$$.dirty[0]|16&e.$$.dirty[1]&&(F.length>=I&&!a.opened&&P&&!a.userClosed?B(!1):(a.opened&&!a.userOpened&&F.length<I||!P||a.userClosed)&&j())},[p,m,f,_,v,y,O,$,L,k,T,F,a,H,E,N,function(){s(35,P=!0)},function(){const e=Array.from(document.querySelectorAll(":hover")).some(e=>{var t;return null===(t=e.classList)||void 0===t?void 0:t.contains(N)});s(35,P=!A&&e),U.push(()=>A=!1)},B,j,function(e){return z[e.key]&&z[e.key](e)},function(){!a.opened&&B(!0)},D,function(){s(35,P=!1),j()},q,J,u,c,g,I,w,b,x,C,function(e){s(12,a=a.addItem(e))},P,o,h,r,()=>{a.opened&&J()},function(e){t.binding_callbacks[e?"unshift":"push"](()=>{E=e,s(14,E)})},function(){F=this.value,s(11,F)},()=>j(!0),()=>B(!0),e=>q(e),()=>D(!0),function(e){t.binding_callbacks[e?"unshift":"push"](()=>{H=e,s(13,H)})},()=>E.focus()]}class k extends t.SvelteComponent{constructor(e){super(),t.init(this,e,L,O,t.safe_not_equal,{items:26,labelFieldName:27,labelFunction:28,containerClassNames:0,containerStyle:1,inputStyle:2,inputClassNames:3,i18n:4,minCharsToSuggest:29,removeOnSelect:30,closeOnSelect:31,zIndexOffset:5,preferOpenUpwards:32,showNumberOfHits:6,caseSensitive:33,wide:7,tabIndex:8,placeholder:9,inputProps:10,addItem:34},h,[-1,-1,-1])}get addItem(){return this.$$.ctx[34]}}e.Autocomplete=k,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.js.map
{
"name": "@digibib/deichman-admin-frontend-common",
"version": "2.1.0",
"version": "2.2.0",
"description": "Set of common Deichman Svelte components",

@@ -5,0 +5,0 @@ "svelte": "src/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc