Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@entur/dropdown

Package Overview
Dependencies
Maintainers
0
Versions
245
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@entur/dropdown - npm Package Compare versions

Comparing version 6.0.3-RC.1 to 6.0.3-RC.2

4

dist/components/DropdownList.d.ts

@@ -16,3 +16,3 @@ import React from 'react';

} | undefined;
listRef?: React.Ref<HTMLUListElement>;
setListRef: (node: HTMLElement | null) => void;
loading?: boolean;

@@ -26,3 +26,3 @@ loadingText?: string;

};
export declare const DropdownList: <ValueType extends unknown>({ ariaLabelChosenSingular, ariaLabelSelectedItem, getItemProps, getMenuProps, inputValue, isOpen, highlightedIndex, listItems, listStyle, listRef, loading, loadingText, noMatchesText, selectAllCheckboxState, selectAllItem, selectedItems, showSelectAllInList, ...rest }: DropdownListProps<ValueType>) => React.JSX.Element;
export declare const DropdownList: <ValueType extends unknown>({ ariaLabelChosenSingular, ariaLabelSelectedItem, getItemProps, getMenuProps, inputValue, isOpen, highlightedIndex, listItems, listStyle, setListRef, loading, loadingText, noMatchesText, selectAllCheckboxState, selectAllItem, selectedItems, showSelectAllInList, ...rest }: DropdownListProps<ValueType>) => React.JSX.Element;
export {};

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),t=require("react"),n=require("downshift"),l=require("classnames"),a=require("@entur/form"),r=require("@entur/icons"),o=require("@entur/a11y"),i=require("@entur/loader"),s=require("@entur/tokens"),d=require("@floating-ui/react-dom"),u=require("@entur/button"),c=require("@entur/chip"),m=require("@entur/tooltip");function p(){p=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,l=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},r=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",i=a.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function d(e,t,n,a){var r=Object.create((t&&t.prototype instanceof m?t:m).prototype),o=new S(a||[]);return l(r,"_invoke",{value:w(e,n,o)}),r}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=d;var c={};function m(){}function g(){}function b(){}var f={};s(f,r,(function(){return this}));var h=Object.getPrototypeOf,v=h&&h(h(L([])));v&&v!==t&&n.call(v,r)&&(f=v);var y=b.prototype=m.prototype=Object.create(f);function I(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){function a(l,r,o,i){var s=u(e[l],e,r);if("throw"!==s.type){var d=s.arg,c=d.value;return c&&"object"==typeof c&&n.call(c,"__await")?t.resolve(c.__await).then((function(e){a("next",e,o,i)}),(function(e){a("throw",e,o,i)})):t.resolve(c).then((function(e){d.value=e,o(d)}),(function(e){return a("throw",e,o,i)}))}i(s.arg)}var r;l(this,"_invoke",{value:function(e,n){function l(){return new t((function(t,l){a(e,n,t,l)}))}return r=r?r.then(l,l):l()}})}function w(e,t,n){var l="suspendedStart";return function(a,r){if("executing"===l)throw new Error("Generator is already running");if("completed"===l){if("throw"===a)throw r;return{value:void 0,done:!0}}for(n.method=a,n.arg=r;;){var o=n.delegate;if(o){var i=x(o,n);if(i){if(i===c)continue;return i}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===l)throw l="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);l="executing";var s=u(e,t,n);if("normal"===s.type){if(l=n.done?"completed":"suspendedYield",s.arg===c)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(l="completed",n.method="throw",n.arg=s.arg)}}}function x(e,t){var n=t.method,l=e.iterator[n];if(void 0===l)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),c;var a=u(l,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,c;var r=a.arg;return r?r.done?(t[e.resultName]=r.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):r:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function L(e){if(e){var t=e[r];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var l=-1,a=function t(){for(;++l<e.length;)if(n.call(e,l))return t.value=e[l],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:T}}function T(){return{value:void 0,done:!0}}return g.prototype=b,l(y,"constructor",{value:b,configurable:!0}),l(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,s(e,i,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},I(_.prototype),s(_.prototype,o,(function(){return this})),e.AsyncIterator=_,e.async=function(t,n,l,a,r){void 0===r&&(r=Promise);var o=new _(d(t,n,l,a),r);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},I(y),s(y,i,"Generator"),s(y,r,(function(){return this})),s(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var l in t)n.push(l);return n.reverse(),function e(){for(;n.length;){var l=n.pop();if(l in t)return e.value=l,e.done=!1,e}return e.done=!0,e}},e.values=L,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function l(n,l){return o.type="throw",o.arg=e,t.next=n,l&&(t.method="next",t.arg=void 0),!!l}for(var a=this.tryEntries.length-1;a>=0;--a){var r=this.tryEntries[a],o=r.completion;if("root"===r.tryLoc)return l("end");if(r.tryLoc<=this.prev){var i=n.call(r,"catchLoc"),s=n.call(r,"finallyLoc");if(i&&s){if(this.prev<r.catchLoc)return l(r.catchLoc,!0);if(this.prev<r.finallyLoc)return l(r.finallyLoc)}else if(i){if(this.prev<r.catchLoc)return l(r.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return l(r.finallyLoc)}}}},abrupt:function(e,t){for(var l=this.tryEntries.length-1;l>=0;--l){var a=this.tryEntries[l];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var r=a;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=e,o.arg=t,r?(this.method="next",this.next=r.finallyLoc,c):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),E(n),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var l=n.completion;if("throw"===l.type){var a=l.arg;E(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:L(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},e}function g(e,t,n,l,a,r,o){try{var i=e[r](o),s=i.value}catch(e){return void n(e)}i.done?t(s):Promise.resolve(s).then(l,a)}function b(){return b=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(e[l]=n[l])}return e},b.apply(this,arguments)}function f(e){if(null==e)throw new TypeError("Cannot destructure "+e)}function h(e,t){if(null==e)return{};var n,l,a={},r=Object.keys(e);for(l=0;l<r.length;l++)t.indexOf(n=r[l])>=0||(a[n]=e[n]);return a}var v=["children","onChange","onInputValueChange","highlightFirstItemOnOpen","className","style","searchable"],y=t.createContext(null),I=function(e){var a=e.children,r=e.onChange,o=void 0===r?function(){}:r,i=e.onInputValueChange,s=void 0===i?function(){}:i,d=e.highlightFirstItemOnOpen,u=void 0!==d&&d,c=e.className,m=e.style,p=e.searchable,g=void 0!==p&&p,f=h(e,v);return t.createElement(n,b({itemToString:function(e){return e?e.label:""},onStateChange:function(e,t){e.type!==n.stateChangeTypes.controlledPropUpdatedSelectedItem&&("selectedItem"in e?o(e.selectedItem,t):"inputValue"in e&&s(e.inputValue))},stateReducer:function(e,t){var n=u&&"isOpen"in t&&t.isOpen?{highlightedIndex:0}:{};if(!g)return b({},t,n);switch(t.type){case"__autocomplete_change_input__":default:return b({},t,n);case"__autocomplete_click_item__":case"__autocomplete_keydown_enter__":case"__autocomplete_blur_input__":case"__autocomplete_mouseup__":return b({},t,{inputValue:""},n)}}},f),(function(e){return t.createElement("div",{className:l("eds-input-group",c),style:m},t.createElement(y.Provider,{value:e},a))}))},_=function(){var e=t.useContext(y);if(!e)throw new Error("You need to wrap your component in a DownshiftProvider");return e},w=["items"],x=function(e){var n=e.items,a=h(e,w),o=_(),i=o.highlightedIndex,s=o.isOpen,d=o.selectedItem,u=o.getItemProps,c=o.getMenuProps;return t.createElement("ul",b({className:l("eds-dropdown-list",{"eds-dropdown-list--open":s})},c(),a),s?n.map((function(e,n){return t.createElement("li",b({className:l("eds-dropdown-list__item",{"eds-dropdown-list__item--highlighted":i===n,"eds-dropdown-list__item--selected":d===e})},u({key:""+n+e.value,item:e,index:n})),t.createElement("span",null,e.label),e.icons&&t.createElement("span",null,e.icons.map((function(e,n){return t.createElement(e,{key:n,inline:!0,className:"eds-dropdown-list__item-icon"})}))),d===e&&t.createElement(r.CheckIcon,null))})):null)},C=function(){var e=_();return t.createElement("button",b({},(0,e.getToggleButtonProps)({className:l("eds-dropdown__toggle-button",{"eds-dropdown__toggle-button--open":e.isOpen})}),{tabIndex:-1,type:"button"}),t.createElement(r.DownArrowIcon,null))},E=["className","children"],S=function(e){var n=e.className,a=e.children,r=h(e,E);return t.createElement("div",b({className:l("eds-inline-spinner",n)},r),t.createElement(i.LoadingDots,null),t.createElement(o.VisuallyHidden,null,a))},L=["children","className","items","loading","loadingText","placeholder","style","listStyle","clearable","label","isFilled","disableLabelAnimation"],T=function(e){var n=e.children,l=e.className,r=e.items,o=e.loading,i=void 0!==o&&o,d=e.loadingText,u=void 0===d?"Loading...":d,c=e.style,m=e.listStyle,p=e.clearable,g=e.label,f=e.isFilled,v=void 0!==f&&f,y=e.disableLabelAnimation,I=h(e,L),w=_().getLabelProps;return t.createElement("div",{className:"eds-dropdown-wrapper",style:c},t.createElement(a.BaseFormControl,b({append:t.createElement(O,{clearable:p,loading:i,loadingText:u,readOnly:I.readOnly}),className:l,label:g,isFilled:v,labelProps:w(),disableLabelAnimation:y},I),n),t.createElement(x,b({items:r,style:b({position:"absolute",top:s.space.extraLarge3+s.space.extraSmall+"px"},m)},I)))},k=function(e){var n=b({},(f(e),e)),l=_(),a=l.clearSelection,o=l.selectedItem;return t.createElement(t.Fragment,null,o&&t.createElement("button",b({className:"eds-dropdown__clear-button",type:"button",tabIndex:-1,onClick:function(){return a()},"aria-label":"Trykk for å fjerne valg"},n),t.createElement(r.CloseSmallIcon,null)),o&&t.createElement("div",{className:"eds-dropdown__divider"}))},O=function(e){var n=e.clearable,l=e.readOnly;return e.loading?t.createElement(S,null,e.loadingText):l?null:n?t.createElement(t.Fragment,null,t.createElement(k,null)," ",t.createElement(C,null)):t.createElement(C,null)},N=["disabled","placeholder","selectOnTab","openOnFocus","listStyle","items","label","disableLabelAnimation","loading","loadingText","className","clearable"],P=t.forwardRef((function(e,n){var l=e.disabled,a=e.placeholder,r=void 0===a?"Vennligst velg":a,o=e.selectOnTab,i=void 0!==o&&o,s=e.openOnFocus,d=void 0!==s&&s,u=e.listStyle,c=e.items,m=e.label,p=e.disableLabelAnimation,g=e.loading,f=e.loadingText,v=e.className,y=e.clearable,I=h(e,N),w=_(),x=w.getToggleButtonProps,C=w.selectedItem,E=w.selectHighlightedItem,S=w.openMenu,L=w.isOpen,k=w.highlightedIndex,O=w.setHighlightedIndex;return t.createElement(T,b({disabled:l,listStyle:u,items:c,label:m,isFilled:!!C||0!==r.length,disableLabelAnimation:p,loading:g,loadingText:f,className:v,clearable:y},I),t.createElement("button",b({},x(b({className:"eds-form-control eds-dropdown__selected-item",style:{textAlign:"left"},disabled:l,type:"button",onKeyDown:function(e){if(i&&"Tab"===e.key&&E(),L){var t=e.key,n=c.map((function(e,t){return b({},e,{index:t})})).filter((function(e){return e.label.trim().charAt(0).toLowerCase()===t})),l=n.find((function(e){return e.index>(null!=k?k:0)}));l?O(l.index):n.length>0&&O(n[0].index)}},onFocus:function(){d&&!L&&S()}},I)),{ref:n}),C?C.label:r))})),A=["disabled","className","items","loading","loadingText","readOnly","prepend","selectOnTab","openOnFocus","listStyle","clearable","itemFilter","label","disableLabelAnimation","placeholder"],F=t.forwardRef((function(n,l){var a=n.disabled,r=void 0!==a&&a,o=n.className,i=n.items,s=n.loading,d=n.loadingText,u=n.readOnly,c=void 0!==u&&u,m=n.prepend,p=n.selectOnTab,g=void 0!==p&&p,f=n.openOnFocus,v=void 0!==f&&f,y=n.listStyle,I=n.clearable,w=n.itemFilter,x=void 0===w?function(e,t){return function(e,t){if(!t)return!0;var n=t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return new RegExp(n,"i").test(e.label)}(e,t)}:w,C=n.label,E=n.disableLabelAnimation,S=n.placeholder,L=h(n,A),k=_(),O=k.getInputProps,N=k.inputValue,P=k.selectHighlightedItem,F=k.isOpen,B=k.openMenu,V=k.closeMenu,M=k.selectedItem,D=t.useState(!1),R=D[0],j=D[1],K=t.useRef(null),q=t.useMemo((function(){return i.filter((function(e){return x(e,N)}))}),[N,i,x]);return t.createElement(T,{items:q,disabled:r,readOnly:c,className:o,loading:s,loadingText:d,prepend:m,listStyle:y,clearable:I,label:C,isFilled:!!M,disableLabelAnimation:E},!R&&M&&!N&&t.createElement("span",{className:"eds-dropdown__searchable-selected-item__wrapper"},t.createElement("span",{className:"eds-dropdown__searchable-selected-item",onClick:function(){var e;return null==(e=K.current)?void 0:e.focus()}},M.label)),t.createElement("input",b({},O(b({disabled:r,readOnly:c,className:"eds-form-control eds-dropdown__input",onKeyDown:function(e){g&&"Tab"===e.key&&P()},onFocus:function(){!F&&v&&B(),j(!0)},placeholder:M?M.label:S},L)),{onBlur:function(){j(!1),V()},ref:e.mergeRefs(l,K)})))})),B=function(e){var n=e.feedback,l=e.variant;return t.createElement(a.VariantProvider,{variant:l},t.createElement("div",{className:e.className,style:e.style},e.children,n&&l&&t.createElement(a.FeedbackText,{variant:l},n)))},V=function(n,l){void 0===l&&(l=250);var a="function"==typeof n,r=t.useState(a?[]:n),o=r[0],i=r[1],s=t.useState(!1),d=s[0],u=s[1],c=t.useRef(new AbortController),m=t.useMemo((function(){return a?n:function(){return Promise.resolve(n)}}),[n,a]),f=function(){var e,t=(e=p().mark((function e(t){var n,l,a,r,o;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null!=c&&c.current&&(null==c||null==(n=c.current)||n.abort()),l=new AbortController,c.current=l,u(!0),e.prev=4,e.next=7,m(null!=t?t:"",c);case 7:if(o=e.sent,null==c||null==(a=c.current)||null==(r=a.signal)||!r.aborted){e.next=11;break}return console.warn("Avbryt den asynkrone funksjonen din med signalet fra AbortController-en for å for å unngå minnelekkasje.",'Funksjonen bør kaste en DOMException med navnet "AbortError" når den avbrytes.',"","\n\nSe eksempel her: https://design.entur.no/komponenter/skjemaelementer/dropdown#s%C3%B8kbar-dropdown-med-valg-fra-nettverkskall-bassert-p%C3%A5-tekstinput","\nLes mer om AbortController her: https://developer.mozilla.org/en-US/docs/Web/API/AbortController"),e.abrupt("return");case 11:u(!1),i(o),e.next=21;break;case 15:if(e.prev=15,e.t0=e.catch(4),!e.t0||"object"!=typeof e.t0||!("name"in e.t0)||"AbortError"!==e.t0.name){e.next=19;break}return e.abrupt("return");case 19:throw console.warn("The following error was received but not handled inside Entur Designsystems useResolvedItems hook:"),e.t0;case 21:case"end":return e.stop()}}),e,null,[[4,15]])})),function(){var t=this,n=arguments;return new Promise((function(l,a){var r=e.apply(t,n);function o(e){g(r,l,a,o,i,"next",e)}function i(e){g(r,l,a,o,i,"throw",e)}o(void 0)}))});return function(e){return t.apply(this,arguments)}}(),h=e.useDebounce(f,l),v=function(e){return t.useMemo((function(){return e.map((function(e){return"string"==typeof e?{value:e,label:e}:b({},e,void 0===(null==e?void 0:e.value)?{value:e.label}:{value:e.value})}))}),[e])}(o);return t.useEffect((function(){return function(){var e;return null==c||null==(e=c.current)?void 0:e.abort("Component unmounted")}}),[]),t.useEffect((function(){a&&h("")}),[a,m]),{items:v,loading:!!a&&d,fetchItems:h}},M=["highlightFirstItemOnOpen","debounceTimeout","disabled","feedback","items","label","loadingText","onChange","placeholder","prepend","readOnly","searchable","selectOnTab","openOnFocus","variant","value","clearable","className","style","listStyle","itemFilter","disableLabelAnimation"],D=t.forwardRef((function(e,n){var l=e.highlightFirstItemOnOpen,a=e.debounceTimeout,r=e.disabled,o=e.feedback,i=e.items,s=e.label,d=e.loadingText,u=e.onChange,c=void 0===u?function(){}:u,m=e.placeholder,p=e.prepend,g=e.readOnly,f=e.searchable,v=e.selectOnTab,y=e.openOnFocus,_=e.variant,w=e.value,x=e.clearable,C=void 0!==x&&x,E=e.className,S=e.style,L=e.listStyle,T=e.itemFilter,k=e.disableLabelAnimation,O=h(e,M),N=V(i,a),A=N.items,D=N.loading,R=N.fetchItems,j=void 0===w?void 0:A.find((function(e){return w===e.value}))||null,K=f?F:P,q=f?{itemFilter:T,name:O.name,"data-cy":O["data-cy"]}:{name:O.name,"data-cy":O["data-cy"]};return t.createElement(I,b({selectedItem:j,onInputValueChange:R,onChange:c,value:w,highlightFirstItemOnOpen:l,className:E,style:S,searchable:f},O),t.createElement(B,{feedback:o,variant:_},t.createElement(K,b({label:s,items:A,loading:D,loadingText:d,disabled:r,readOnly:g,placeholder:m,prepend:p,selectOnTab:v,openOnFocus:y,listStyle:L,clearable:C,disableLabelAnimation:k,ref:n},q))))})),R=["className","clearable","debounceTimeout","disabled","feedback","initialSelectedItems","items","itemsSelectedLabel","label","listStyle","loading","loadingText","onChange","openOnFocus","readOnly","style","variant"],j=t.createContext(null),K=function(){var e=t.useContext(j);if(!e)throw new Error("You need to wrap your component in a DownshiftProvider");return e};function q(e,t){var l=t.changes;switch(t.type){case n.useSelect.stateChangeTypes.ToggleButtonKeyDownEnter:case n.useSelect.stateChangeTypes.ToggleButtonKeyDownSpaceButton:case n.useSelect.stateChangeTypes.ItemClick:return b({},l,{isOpen:!0,highlightedIndex:e.highlightedIndex});default:return l}}var H=function(e){var n=b({},(f(e),e)),l=K().reset;return t.createElement(t.Fragment,null,t.createElement("button",b({className:"eds-dropdown__clear-button",type:"button",tabIndex:-1,onClick:function(){return l()}},n),t.createElement(r.CloseIcon,null)),t.createElement("div",{className:"eds-dropdown__divider"}))},G=function(e){var n=e.readOnly,l=e.hasSelected;return e.loading?t.createElement(S,null,e.loadingText):n?null:l?t.createElement(t.Fragment,null,t.createElement(H,null),t.createElement(U,null)):t.createElement(U,null)},U=function(){var e=K(),n=e.openMenu,a=e.openOnFocus;return t.createElement("button",b({},(0,e.getToggleButtonProps)({className:l("eds-dropdown__toggle-button",{"eds-dropdown__toggle-button--open":e.isOpen}),onFocus:function(){a&&n()}}),{type:"button"}),t.createElement(r.DownArrowIcon,null))},Y=function(){return t.createElement("svg",{className:"eds-checkbox-icon",width:"11px",height:"9px",viewBox:"6 11 37 33"},t.createElement("path",{className:"eds-checkbox-icon__path",d:"M14.1 27.2l7.1 7.2 14.6-14.8",fill:"none"}))},$=["ariaLabelChosenSingular","ariaLabelSelectedItem","getItemProps","getMenuProps","inputValue","isOpen","highlightedIndex","listItems","listStyle","listRef","loading","loadingText","noMatchesText","selectAllCheckboxState","selectAllItem","selectedItems","showSelectAllInList"],z=function(n){var r,i=n.ariaLabelChosenSingular,s=void 0===i?"valgt":i,d=n.ariaLabelSelectedItem,u=void 0===d?", valgt element, trykk for å fjerne":d,c=n.getItemProps,m=n.getMenuProps,p=n.isOpen,g=n.highlightedIndex,f=n.listItems,v=n.listStyle,y=n.listRef,I=n.loading,_=void 0!==I&&I,w=n.loadingText,x=void 0===w?"Laster inn …":w,C=n.noMatchesText,E=void 0===C?"Ingen treff for søket":C,S=n.selectAllCheckboxState,L=n.selectAllItem,T=n.selectedItems,k=h(n,$),O=void 0!==L,N=!_&&(0===f.length||1===(null==f?void 0:f.length)&&(null==f||null==(r=f[0])?void 0:r.value)===(null==L?void 0:L.value)),P=function(e){return T.some((function(t){return(null==t?void 0:t.value)===(null==e?void 0:e.value)&&(null==t?void 0:t.label)===(null==e?void 0:e.label)}))},A=function(){switch(null==S?void 0:S()){case"indeterminate":return{label:(null==L?void 0:L.label)+", delvis valgt",selected:!1};case!0:return{label:(null==L?void 0:L.label)+", "+s,selected:!0};default:return{label:""+(null==L?void 0:L.label),selected:!1}}};return t.createElement("ul",b({},m({"aria-multiselectable":O},{suppressRefError:!0}),{ref:e.mergeRefs(y,m().ref),className:"eds-dropdown__list",style:b({display:p?"inline-block":"none"},k.style,v)}),!_&&f.length>0&&f.map((function(e,n){var r=e.value===(null==L?void 0:L.value);return r&&f.length<=2?null:t.createElement("li",b({className:l("eds-dropdown__list__item",{"eds-dropdown__list__item--select-all":r,"eds-dropdown__list__item--highlighted":g===n,"eds-dropdown__list__item--selected":!O&&P(e)}),key:(null==e?void 0:e.label)+(null==e?void 0:e.value)},c({item:e,index:n,"aria-selected":r?A().selected:P(e)})),r?t.createElement(t.Fragment,null,t.createElement(a.Checkbox,{"aria-hidden":"true",checked:null==S?void 0:S(),className:"eds-dropdown__list__item__checkbox",onChange:function(){},tabIndex:-1}),t.createElement("span",{className:"eds-dropdown__list__item__text","aria-label":A().label},null==L?void 0:L.label)):function(e){return t.createElement(t.Fragment,null,t.createElement(a.Checkbox,{"aria-hidden":"true",checked:P(e),className:"eds-dropdown__list__item__checkbox",onChange:function(){},style:O?{}:{display:"none"},tabIndex:-1}),t.createElement("span",{className:"eds-dropdown__list__item__text"},e.label,t.createElement(o.VisuallyHidden,null,P(e)?u:"")),e.icons&&t.createElement("span",null,e.icons.map((function(n){var l;return t.createElement(n,{key:(null==e?void 0:e.label)+(null==e?void 0:e.value)+(null!=(l=null==n?void 0:n.displayName)?l:null==n?void 0:n.name),inline:!0,className:"eds-dropdown__list__item__icon"})}))))}(e))})),N&&t.createElement("li",{key:"dropdown-list-no-match",className:"eds-dropdown__list__item"},E),_&&t.createElement("li",{key:"dropdown-list-loading",className:"eds-dropdown__list__item"},x))},J=["tabIndex"],W=function(e){var n,a=e.ariaLabelRemoveSelected,r=e.ariaLabelChosen,o=void 0===r?"valgt":r,i=e.disabled,s=e.getSelectedItemProps,d=e.readOnly,u=e.removeSelectedItem,m=e.selectedItem,p=h(null!=(n=null==s?void 0:s({selectedItem:m,index:e.index}))?n:{},J);return t.createElement(c.TagChip,b({size:"small",className:l("eds-dropdown__selected-item-tag",{"eds-dropdown__selected-item-tag--readonly":d,"eds-dropdown__selected-item-tag--disabled":i})},p,{onClose:function(e){e.stopPropagation(),u(m)},closeButtonAriaLabel:m.label+" "+o+", "+a+" ",key:m.value,"aria-live":"polite"}),t.createElement("span",{"aria-hidden":"true",className:"eds-dropdown__selected-item-tag__text"},m.label))},Q=function(e){var n=e.ariaHiddenToggleButton,l=void 0!==n&&n,a=e.ariaLabelCloseList,r=e.ariaLabelOpenList,o=e.clearable,s=e.disabled,d=e.focusable,u=void 0!==d&&d,c=e.getToggleButtonProps,m=e.isOpen,p=e.loading,g=void 0!==p&&p,b=e.loadingText,f=void 0===b?"Laster resultater …":b,h=e.selectedItems;return void 0!==s&&s?null:t.createElement("div",{className:"eds-dropdown__appendix"},void 0!==o&&o&&(null==h?void 0:h.length)>0&&null!==h[0]&&t.createElement(t.Fragment,null,t.createElement(X,{onClear:e.onClear,focusable:!0,labelClearSelectedItems:e.labelClearSelectedItems}),t.createElement("div",{className:"eds-dropdown__appendix__divider"})),g?t.createElement("div",{className:"eds-dropdown__appendix__toggle-button--loading-dots"},t.createElement(i.LoadingDots,{"aria-label":f})):t.createElement(Z,{"aria-hidden":l,ariaLabelCloseList:a,ariaLabelOpenList:r,getToggleButtonProps:c,isOpen:m,focusable:u}))},X=function(e){var n=e.labelClearSelectedItems,l=void 0===n?"Fjern valgte":n,a=e.focusable;return t.createElement(m.Tooltip,{"aria-hidden":"true",placement:"top",content:l,className:"eds-dropdown__appendix__clear-button__tooltip"},t.createElement(u.IconButton,{className:"eds-dropdown__appendix__clear-button",type:"button",tabIndex:void 0!==a&&a?0:1,onClick:e.onClear,"aria-label":l},t.createElement(r.CloseSmallIcon,{"aria-hidden":"true"})))},Z=function(e){var n=e.isOpen,a=e["aria-hidden"],o=void 0!==a&&a,i=e.ariaLabelCloseList,s=void 0===i?"Lukk liste med valg":i,d=e.ariaLabelOpenList,c=void 0===d?"Åpne liste med valg":d,m=e.focusable,p=void 0!==m&&m;return t.createElement(u.IconButton,b({},(0,e.getToggleButtonProps)({className:l("eds-dropdown__appendix__toggle-button",{"eds-dropdown__appendix__toggle-button--open":n}),"aria-labelledby":void 0}),{"aria-hidden":o,"aria-label":o?void 0:n?s:c,tabIndex:p?0:-1,type:"button"}),t.createElement(r.DownArrowIcon,{"aria-hidden":"true"}))},ee="";function te(e,t){if(!t)return!0;var n=t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return new RegExp(n,"i").test(e.label)}function ne(e,t){return!0}var le=function(e){return e?e.label:""},ae=function(e){return(null==e?void 0:e.label)+(null==e?void 0:e.value)},re=function(e){return"function"==typeof e&&e.length>0};function oe(e){var t=e.selectAllItemIncluded,n=e.resultCount;if(!e.isOpen)return"";var l=void 0!==t&&t?n-1:n;return 0===l?"Ingen resultater":l+" resultat"+(1===l?"":"er")+" tilgjengelig, naviger med pil opp eller ned, velg elementer med Enter."}var ie=["ariaLabelChosenSingular","ariaLabelCloseList","ariaLabelOpenList","ariaLabelSelectedItem","className","clearable","debounceTimeout","disabled","disableLabelAnimation","feedback","items","itemFilter","label","labelClearSelectedItem","labelTooltip","listStyle","loadingText","noMatchesText","onChange","placeholder","prepend","readOnly","selectedItem","selectOnBlur","selectOnTab","style","variant"],se=["className","clearable","clearInputOnSelect","debounceTimeout","disabled","feedback","hideSelectAll","items","itemFilter","label","labelAllItemsSelected","labelClearAllItems","labelSelectAll","labelTooltip","listStyle","loadingText","maxChips","noMatchesText","onChange","placeholder","readOnly","selectedItems","selectOnBlur","selectOnTab","style","variant","ariaLabelChosenSingular","ariaLabelChosenPlural","ariaLabelCloseList","ariaLabelJumpToInput","ariaLabelOpenList","ariaLabelRemoveSelected","ariaLabelSelectedItem"],de=["ariaLabelChosenSingular","ariaLabelCloseList","ariaLabelOpenList","ariaLabelSelectedItem","className","clearable","disabled","disableLabelAnimation","feedback","items","label","labelClearSelectedItem","labelTooltip","listStyle","loadingText","onChange","placeholder","prepend","readOnly","selectedItem","selectOnBlur","selectOnTab","style","variant"],ue=["className","disabled","disableLabelAnimation","feedback","items","label","loadingText","onChange","prepend","readOnly","selectedItem","style","value","variant"],ce=function(e){var n=e.hidden;return e.loading?t.createElement("div",{className:"eds-dropdown-native__loading-dots"},t.createElement(i.LoadingDots,{"aria-label":e.loadingText})):n?t.createElement(t.Fragment,null):t.createElement(r.DownArrowIcon,{inline:!0})};e.warnAboutMissingStyles("dropdown","form","a11y","chip"),exports.Dropdown=function(e){var r,o,i=e.ariaLabelChosenSingular,u=e.ariaLabelCloseList,c=e.ariaLabelOpenList,m=e.ariaLabelSelectedItem,p=e.className,g=e.clearable,f=void 0!==g&&g,v=e.disabled,y=void 0!==v&&v,I=e.disableLabelAnimation,_=e.feedback,w=e.items,x=e.label,C=e.labelClearSelectedItem,E=void 0===C?"fjern valgt":C,S=e.labelTooltip,L=e.listStyle,T=e.loadingText,k=e.onChange,O=e.placeholder,N=e.prepend,P=e.readOnly,A=void 0!==P&&P,F=e.selectedItem,B=e.selectOnBlur,M=void 0!==B&&B,D=e.selectOnTab,R=void 0!==D&&D,j=e.style,K=e.variant,q=void 0===K?"information":K,H=h(e,de),G=V(w),U=G.items,Y=G.loading,$=t.useRef(null),J=null!==F||void 0!==O,W=n.useSelect({items:U,defaultHighlightedIndex:F?void 0:0,selectedItem:F,onStateChange:function(e){var t=e.selectedItem;switch(e.type){case n.useSelect.stateChangeTypes.ToggleButtonBlur:if(!M)break;case n.useSelect.stateChangeTypes.ToggleButtonKeyDownEnter:case n.useSelect.stateChangeTypes.ToggleButtonKeyDownSpaceButton:case n.useSelect.stateChangeTypes.ItemClick:if(void 0===t)return;null==k||k(null!=t?t:null)}},itemToString:le}),X=W.isOpen,Z=W.openMenu,ee=W.getItemProps,te=W.getLabelProps,ne=W.getMenuProps,ae=W.getToggleButtonProps,re=W.highlightedIndex,oe=d.useFloating({whileElementsMounted:function(e,t,n){return d.autoUpdate(e,t,n)},placement:"bottom-start",open:X,middleware:[d.offset(s.space.extraSmall2),d.flip()]}),ie=oe.refs,se=oe.floatingStyles;return t.createElement(a.BaseFormControl,b({append:t.createElement(Q,{ariaHiddenToggleButton:!0,ariaLabelCloseList:u,ariaLabelOpenList:c,clearable:f,labelClearSelectedItems:E,focusable:!1,getToggleButtonProps:ae,isOpen:X,loading:Y,loadingText:T,onClear:function(){var e;null==k||k(null),null==(e=$.current)||e.focus()},disabled:A||y,selectedItems:[F]}),className:l("eds-dropdown",p,{"eds-dropdown--has-tooltip":void 0!==S}),disabled:y,disableLabelAnimation:I,feedback:_,isFilled:J,label:x,labelId:te().id,labelProps:te(),labelTooltip:S,onClick:function(e){e.target===e.currentTarget&&Z()},prepend:N,readOnly:A,ref:ie.setReference,style:j,variant:q},H),t.createElement("div",b({className:"eds-dropdown__selected-item"},ae({id:void 0,onKeyDown:function(e){if(R&&X&&"Tab"===e.key){var t=U[re];t&&(null==k||k(t))}},ref:$})),null!=(r=null!=(o=null==F?void 0:F.label)?o:t.createElement("div",{className:l("eds-dropdown__selected-item__placeholder",{"eds-dropdown__selected-item__placeholder--readonly":A})},O))?r:""),t.createElement(z,{ariaLabelChosenSingular:i,ariaLabelSelectedItem:m,getItemProps:ee,getMenuProps:ne,highlightedIndex:re,isOpen:X,listItems:U,listStyle:b({},se,L),listRef:ie.setFloating,loading:Y,loadingText:T,selectedItems:null!==F?[F]:[]}))},exports.DropdownDeprecated=D,exports.MultiSelect=function(r){var i=r.className,u=r.clearable,c=void 0===u||u,m=r.clearInputOnSelect,p=void 0!==m&&m,g=r.debounceTimeout,f=r.disabled,v=void 0!==f&&f,y=r.feedback,I=r.hideSelectAll,_=void 0!==I&&I,w=r.items,x=r.itemFilter,C=void 0===x?re(w)?ne:te:x,E=r.label,S=r.labelAllItemsSelected,L=void 0===S?"Alle valgt":S,T=r.labelClearAllItems,k=void 0===T?"Fjern valgte":T,O=r.labelSelectAll,N=void 0===O?"Velg alle":O,P=r.labelTooltip,A=r.listStyle,F=r.loadingText,B=r.maxChips,M=void 0===B?10:B,D=r.noMatchesText,R=r.onChange,j=void 0===R?function(){}:R,K=r.placeholder,q=r.readOnly,H=void 0!==q&&q,G=r.selectedItems,U=void 0===G?[]:G,Y=r.selectOnBlur,$=void 0!==Y&&Y,J=r.selectOnTab,X=void 0!==J&&J,Z=r.style,ie=r.variant,de=void 0===ie?"information":ie,ue=r.ariaLabelChosenSingular,ce=r.ariaLabelChosenPlural,me=void 0===ce?"valgte":ce,pe=r.ariaLabelCloseList,ge=r.ariaLabelJumpToInput,be=void 0===ge?U.length+" valgte elementer, trykk for å hoppe til tekstfeltet":ge,fe=r.ariaLabelOpenList,he=r.ariaLabelRemoveSelected,ve=void 0===he?"trykk for å fjerne valg":he,ye=r.ariaLabelSelectedItem,Ie=h(r,se),_e=t.useState(0),we=_e[0],xe=_e[1],Ce=t.useRef(null);t.useEffect((function(){void 0!==Ie.selectedItem&&console.warn("Incorrect 'selectedItem' prop found, did you mean to use 'selectedItems?")}),[Ie.selectedItem]);var Ee=V(w,g),Se=Ee.items,Le=Ee.loading,Te=Ee.fetchItems,ke="function"!=typeof w&&U.length===Se.length,Oe={value:e.useRandomId("select-all"),label:N},Ne=t.useMemo((function(){return{value:ee,label:ke?L:U.length+" "+me}}),[ke,U,L,me]),Pe=t.useState([].concat(_?[]:[Oe],Se)),Ae=Pe[0],Fe=Pe[1],Be=function(e){var t=e.inputValue;return Fe([].concat(_?[]:[Oe],Se.filter((function(e){return C(e,t)}))))},Ve=function(e){var t=e.inputValue;re(w)&&Te(null!=t?t:ee),Be({inputValue:null!=t?t:ee})};t.useEffect((function(){Be({inputValue:Xe})}),[Se]);var Me=function(e){var t=e.selectedItems,n=e.selectAll,l=t.length>0,a=e.listItems.filter((function(e){return e.value!==n.value})),r=a.filter((function(e){return!t.some((function(t){return t.value===e.value}))})),o=!a.some((function(e){return!t.some((function(t){return t.value===e.value}))})),i=a.some((function(e){return t.some((function(t){return t.value===e.value}))})),s=function(e,n){return n([].concat(t,[e]))},d=function(e){return t.some((function(t){return t.value===e.value}))},u=function(e){return e.value===n.value},c=function(e,n){return n(t.filter((function(t){return t.value!==e.value})))},m=function(e){e([].concat(t,r))},p=function(e){e(t.filter((function(e){return!a.some((function(t){return t.value===e.value}))})))};return{addClickedItemToSelectedItems:s,allListItemsAreSelected:o,clickedItemIsInSelectedItems:d,clickedItemIsSelectAll:u,handleListItemClicked:function(e){var t=e.clickedItem,n=e.onChange;return u(t)?o?p(n):m(n):d(t)?c(t,n):void s(t,n)},hasSelectedItems:l,listItemsWithoutSelectAll:a,removeClickedItemFromSelectedItems:c,selectAllCheckboxState:function(){return!!o||!!i&&"indeterminate"},selectAllUnselectedItemsInListItems:m,someListItemsAreSelected:i,unselectAllListItems:p}}({listItems:Ae,selectAll:Oe,selectedItems:U}),De=Me.hasSelectedItems,Re=Me.handleListItemClicked,je=Me.selectAllCheckboxState,Ke=n.useMultipleSelection({selectedItems:U,itemToString:le,itemToKey:ae,onStateChange:function(e){var t=e.selectedItems;switch(e.type){case n.useMultipleSelection.stateChangeTypes.SelectedItemKeyDownBackspace:case n.useMultipleSelection.stateChangeTypes.SelectedItemKeyDownDelete:case n.useMultipleSelection.stateChangeTypes.DropdownKeyDownBackspace:case n.useMultipleSelection.stateChangeTypes.FunctionRemoveSelectedItem:void 0!==t&&j(t)}}}),qe=Ke.getSelectedItemProps,He=Ke.getDropdownProps,Ge=t.useCallback((function(e,t){var l=t.changes,a=t.type;switch(void 0!==l.highlightedIndex&&(null==l?void 0:l.highlightedIndex)>=0&&xe(null==l?void 0:l.highlightedIndex),a){case n.useCombobox.stateChangeTypes.InputKeyDownEnter:case n.useCombobox.stateChangeTypes.ItemClick:var r,o;return p&&Ve({inputValue:ee}),b({},l,{isOpen:!0,inputValue:p?ee:null!=(r=null==Ce||null==(o=Ce.current)?void 0:o.value)?r:ee});case n.useCombobox.stateChangeTypes.ControlledPropUpdatedSelectedItem:var i,s;return b({},l,{inputValue:null!=(i=null==Ce||null==(s=Ce.current)?void 0:s.value)?i:ee});case n.useCombobox.stateChangeTypes.InputChange:var d,u=/^\s+/g,c=" "===l.inputValue;return null!=(d=l.inputValue)&&d.match(u)?(tt(l.inputValue.replace(u,ee)),c&&(et(),Ze&&void 0!==l.highlightedIndex&&Re({clickedItem:Ae[l.highlightedIndex],onChange:j})),l):(Ve({inputValue:l.inputValue}),xe(_?0:1),b({},l,{highlightedIndex:_?0:1}));case n.useCombobox.stateChangeTypes.InputBlur:return Ve({inputValue:ee}),b({},l,{inputValue:ee});default:return l}}),[_,Se,Be,w]),Ue=n.useCombobox(b({defaultHighlightedIndex:we,items:Ae,itemToString:le,selectedItem:null,stateReducer:Ge,onStateChange:function(e){var t=e.selectedItem;if(t)switch(e.type){case n.useCombobox.stateChangeTypes.InputBlur:if(!$)break;case n.useCombobox.stateChangeTypes.InputKeyDownEnter:case n.useCombobox.stateChangeTypes.ItemClick:Re({clickedItem:t,onChange:j})}},getA11yStatusMessage:function(e){return oe(b({},e,{selectAllItemIncluded:!_,resultCount:Ae.length}))}},Ie)),Ye=Ue.getInputProps,$e=Ue.getItemProps,ze=Ue.getLabelProps,Je=Ue.getMenuProps,We=Ue.getToggleButtonProps,Qe=Ue.highlightedIndex,Xe=Ue.inputValue,Ze=Ue.isOpen,et=Ue.openMenu,tt=Ue.setInputValue,nt=d.useFloating({whileElementsMounted:function(e,t,n){return d.autoUpdate(e,t,n)},placement:"bottom-start",open:Ze,middleware:[d.offset(s.space.extraSmall2),d.flip()]}),lt=nt.refs,at=nt.floatingStyles,rt=function(){var e;j([]),tt(ee),null==(e=Ce.current)||e.focus(),Ve({inputValue:Xe})};return t.createElement(a.BaseFormControl,b({append:t.createElement(Q,{ariaLabelCloseList:pe,ariaLabelOpenList:fe,selectedItems:U,isOpen:Ze,clearable:c,labelClearSelectedItems:k,focusable:!1,loading:Le,loadingText:F,disabled:H||v,onClear:rt,getToggleButtonProps:We}),className:l("eds-dropdown","eds-dropdown--multiselect",i,{"eds-dropdown--has-tooltip":void 0!==P}),disabled:v,feedback:y,isFilled:De||Xe!==ee,label:E,labelId:ze().id,labelProps:ze(),labelTooltip:P,onClick:function(e){var t;e.target===e.currentTarget&&(null==(t=Ce.current)||t.focus())},readOnly:H,ref:lt.setReference,style:Z,variant:de},Ie),t.createElement("div",{className:l("eds-dropdown--multiselect__selected-items-and-input",{"eds-dropdown--multiselect__selected-items-and-input--filled":De}),onClick:function(e){e.target===e.currentTarget&&et()}},U.length<=M?t.createElement(t.Fragment,null,U.length>1?t.createElement(o.VisuallyHidden,{onClick:function(){var e;return null==(e=Ce.current)?void 0:e.focus()}},be):t.createElement(t.Fragment,null),U.map((function(e,n){return t.createElement(W,{ariaLabelChosen:ue,ariaLabelRemoveSelected:ve,disabled:v,getSelectedItemProps:qe,index:n,key:(null==e?void 0:e.label)+("string"==typeof(null==e?void 0:e.value)?e.value:""),readOnly:H,removeSelectedItem:function(){var t;Re({clickedItem:e,onChange:j}),null==Ce||null==(t=Ce.current)||t.focus()},selectedItem:e})}))):t.createElement(W,{ariaLabelRemoveSelected:k,ariaLabelChosen:"",disabled:v,readOnly:H,removeSelectedItem:rt,selectedItem:Ne}),t.createElement("input",b({placeholder:K,className:"eds-dropdown__input eds-form-control",disabled:H||v},Ye(b({onKeyDown:function(e){if(X&&Ze&&"Tab"===e.key){var t=Ae[Qe];t&&Re({clickedItem:t,onChange:j})}}},He({preventKeyAction:Ze,value:null!=Xe?Xe:ee,ref:Ce})))))),t.createElement(z,{ariaLabelChosenSingular:ue,ariaLabelSelectedItem:ye,getItemProps:$e,getMenuProps:Je,highlightedIndex:Qe,inputValue:Xe,isOpen:Ze,listItems:Ae,listStyle:b({},at,A),listRef:lt.setFloating,loading:Le,loadingText:F,noMatchesText:D,selectAllCheckboxState:je,selectAllItem:Oe,selectedItems:U}))},exports.MultiSelectDeprecated=function(r){var o=r.className,i=r.clearable,d=void 0!==i&&i,u=r.debounceTimeout,c=r.disabled,m=r.feedback,p=r.initialSelectedItems,g=void 0===p?[]:p,f=r.items,v=r.itemsSelectedLabel,y=void 0===v?function(e){return function(e){return e.length<3?e.map((function(e){return e.label})).toString():e.length+" elementer valgt"}(e)}:v,I=r.label,_=r.listStyle,w=r.loading,x=void 0!==w&&w,C=r.loadingText,E=void 0===C?"":C,S=r.onChange,L=void 0===S?function(){}:S,T=r.openOnFocus,k=void 0!==T&&T,O=r.readOnly,N=void 0!==O&&O,P=r.style,A=r.variant,F=h(r,R),B=V(f,u).items,M=t.useState(g),D=M[0],K=M[1],H=t.useCallback((function(){K([])}),[]);function U(e){return D.some((function(t){return t.value===e.value}))}var $=n.useSelect(b({items:B,stateReducer:q,selectedItem:null,onSelectedItemChange:function(e){var t=e.selectedItem;if(t)if(U(t)){var n=D.filter((function(e){return e.value!==t.value}));K(n),L(n)}else{var l=[].concat(D,[t]);K(l),L(l)}}},F)),z=$.isOpen,J=$.getToggleButtonProps,W=$.getLabelProps,Q=$.getMenuProps,X=$.highlightedIndex,Z=$.getItemProps,ee=$.openMenu,te=D.length?y(D):"",ne=e.useRandomId("eds-multiselect");return t.createElement(j.Provider,{value:{isOpen:z,reset:H,getToggleButtonProps:J,openMenu:ee,openOnFocus:k}},t.createElement("div",{className:l("eds-multiselect","eds-dropdown-wrapper",o),style:P},t.createElement(a.BaseFormControl,{label:I,labelId:ne,labelProps:W,feedback:m,variant:A,isFilled:D.length>0||z,disabled:c,readOnly:N,append:t.createElement(G,{hasSelected:d&&D.length>0,loading:x,loadingText:E,readOnly:N})},t.createElement("button",b({},J({style:{textAlign:"left"},type:"button",className:"eds-form-control eds-multiselect__button"})),te)),t.createElement("ul",b({className:l("eds-dropdown-list",{"eds-dropdown-list--open":z})},Q({style:b({position:"absolute",top:s.space.extraLarge3+s.space.extraSmall+"px"},_)})),z&&B.map((function(e,n){return t.createElement("li",b({className:l("eds-dropdown-list__item",{"eds-dropdown-list__item--highlighted":X===n,"eds-dropdown-list__item--selected":U(e)}),key:""+e.value+n},Z({item:e,index:n}),{style:{display:"flex"}}),t.createElement("span",{style:{display:"flex"}},t.createElement("span",{className:l("eds-multiselect-checkbox",{"eds-multiselect-checkbox--checked":U(e)})},t.createElement(Y,null)),t.createElement("span",{className:"eds-multiselect__item-label"},e.label)),e.icons&&t.createElement("span",null,e.icons.map((function(e,n){return t.createElement(e,{key:n,inline:!0,className:"eds-dropdown-list__item-icon"})}))))})))))},exports.NativeDropdown=function(n){var l,r=n.className,o=n.disabled,i=void 0!==o&&o,s=n.disableLabelAnimation,d=n.feedback,u=n.items,c=n.label,m=n.loadingText,p=n.onChange,g=n.prepend,f=n.readOnly,v=void 0!==f&&f,y=n.selectedItem,I=n.style,_=n.value,w=n.variant,x=h(n,ue),C=V(u),E=C.items,S=C.loading,L=e.useRandomId("eds-dropdown-native");return t.createElement(a.BaseFormControl,{disabled:i,readOnly:v,prepend:g,append:t.createElement(ce,{hidden:i||v,loading:S,loadingText:m}),className:r,style:I,label:c,labelId:L,variant:w,feedback:d,disableLabelAnimation:s,isFilled:!0},t.createElement("select",b({"aria-invalid":"negative"===w||"error"===w,"aria-labelledby":L,"aria-busy":S,className:"eds-form-control eds-dropdown--native",disabled:i||v,onChange:function(e){var t;null==p||p({value:e.target.value,selectedItem:null!=(t=E.find((function(t){return t.value===e.target.value})))?t:null,target:e.target})},value:null!=(l=null!=_?_:null==y?void 0:y.value)?l:void 0},x),E.map((function(e){return t.createElement("option",{key:e.value,value:e.value},e.label)}))))},exports.SearchableDropdown=function(e){var r,o,i=e.ariaLabelChosenSingular,u=e.ariaLabelCloseList,c=e.ariaLabelOpenList,m=e.ariaLabelSelectedItem,p=e.className,g=e.clearable,f=void 0===g||g,v=e.debounceTimeout,y=e.disabled,I=void 0!==y&&y,_=e.disableLabelAnimation,w=void 0!==_&&_,x=e.feedback,C=e.items,E=e.itemFilter,S=void 0===E?re(C)?ne:te:E,L=e.label,T=e.labelClearSelectedItem,k=void 0===T?"fjern valgt":T,O=e.labelTooltip,N=e.listStyle,P=e.loadingText,A=e.noMatchesText,F=e.onChange,B=void 0===F?function(){}:F,M=e.placeholder,D=e.prepend,R=e.readOnly,j=void 0!==R&&R,K=e.selectedItem,q=e.selectOnBlur,H=void 0!==q&&q,G=e.selectOnTab,U=void 0!==G&&G,Y=e.style,$=e.variant,J=void 0===$?"info":$,W=h(e,ie),X=t.useState(null!==K),Z=X[0],ae=X[1],se=t.useState(0),de=se[0],ue=se[1],ce=t.useRef(null),me=V(C,v),pe=me.items,ge=me.loading,be=me.fetchItems,fe=t.useState(pe),he=fe[0],ve=fe[1],ye=function(e){var t=e.inputValue;return ve(pe.filter((function(e){return S(e,t)})))},Ie=function(e){var t=e.inputValue;re(C)&&be(null!=t?t:ee),ye({inputValue:null!=t?t:ee})},_e="undefined"!=typeof document&&(null==ce?void 0:ce.current)===(null==(r=document)?void 0:r.activeElement);t.useEffect((function(){ye({inputValue:Fe})}),[pe]),t.useEffect((function(){null===Ae||_e||(ae(!0),Ie({inputValue:ee}),Be(ee))}),[]);var we=t.useCallback((function(e,t){var l=t.type,a=t.changes;switch(void 0!==a.highlightedIndex&&(null==a?void 0:a.highlightedIndex)>=0&&ue(null==a?void 0:a.highlightedIndex),l){case n.useCombobox.stateChangeTypes.ItemClick:case n.useCombobox.stateChangeTypes.InputKeyDownEnter:case n.useCombobox.stateChangeTypes.InputBlur:return Ie({inputValue:ee}),b({},a,{inputValue:ee});case n.useCombobox.stateChangeTypes.ControlledPropUpdatedSelectedItem:return null===a.selectedItem||_e||ae(!0),Ie({inputValue:ee}),b({},a,{inputValue:ee});case n.useCombobox.stateChangeTypes.InputChange:var r,o=/^\s+/g,i=" "===a.inputValue;return null!=(r=a.inputValue)&&r.match(o)?(Be(a.inputValue.replace(o,ee)),i&&(Ee(),Ce&&void 0!==a.highlightedIndex&&B(he[a.highlightedIndex]))):(Ie({inputValue:a.inputValue}),Ne(0),ue(0)),a;default:return a}}),[be,ye]),xe=n.useCombobox(b({defaultHighlightedIndex:de,items:he,itemToString:le,selectedItem:K,stateReducer:we,onStateChange:function(e){var t=e.selectedItem;switch(e.type){case n.useCombobox.stateChangeTypes.InputBlur:if(!H)break;case n.useCombobox.stateChangeTypes.InputKeyDownEnter:case n.useCombobox.stateChangeTypes.ItemClick:if(void 0===t)return;B(null!=t?t:null)}},getA11yStatusMessage:function(e){return oe(b({},e,{resultCount:he.length}))}},W)),Ce=xe.isOpen,Ee=xe.openMenu,Se=xe.getToggleButtonProps,Le=xe.getLabelProps,Te=xe.getMenuProps,ke=xe.getInputProps,Oe=xe.highlightedIndex,Ne=xe.setHighlightedIndex,Pe=xe.getItemProps,Ae=xe.selectedItem,Fe=xe.inputValue,Be=xe.setInputValue,Ve=d.useFloating({whileElementsMounted:function(e,t,n){return d.autoUpdate(e,t,n)},placement:"bottom-start",open:Ce,middleware:[d.offset(s.space.extraSmall2),d.flip()]}),Me=Ve.refs,De=Ve.floatingStyles;return t.createElement(a.BaseFormControl,b({append:t.createElement(Q,{ariaLabelCloseList:u,ariaLabelOpenList:c,clearable:f,labelClearSelectedItems:k,disabled:j||I,focusable:!1,getToggleButtonProps:Se,isOpen:Ce,loading:ge,loadingText:P,onClear:function(){var e;B(null),Be(ee),null==(e=ce.current)||e.focus(),Ie({inputValue:Fe}),ae(!1)},selectedItems:[Ae]}),className:l("eds-dropdown","eds-dropdown--searchable",p,{"eds-dropdown--has-tooltip":void 0!==O}),disabled:I,disableLabelAnimation:w,feedback:x,isFilled:null!==Ae||Fe!==ee,label:L,labelId:Le().id,labelProps:Le(),labelTooltip:O,onClick:function(e){var t;e.target===e.currentTarget&&(null==(t=ce.current)||t.focus())},prepend:D,readOnly:j,ref:Me.setReference,style:Y,variant:J},W),t.createElement("span",{className:l("eds-dropdown--searchable__selected-item",{"eds-dropdown--searchable__selected-item--hidden":!Z}),"aria-hidden":"true",onClick:function(){var e;null==(e=ce.current)||e.focus(),Ee()}},Z?null==Ae?void 0:Ae.label:""),t.createElement("input",b({className:l("eds-dropdown__input eds-form-control",{"eds-dropdown__input--hidden":Z}),disabled:j||I,placeholder:null!=(o=null==Ae?void 0:Ae.label)?o:M},ke({onBlur:function(){null!==Ae&&ae(!0)},onFocus:function(){ae(!1)},onKeyDown:function(e){U&&Ce&&"Tab"===e.key&&(null==B||B(he[Oe]))},ref:ce}))),t.createElement(z,{ariaLabelChosenSingular:i,ariaLabelSelectedItem:m,getItemProps:Pe,getMenuProps:Te,highlightedIndex:Oe,isOpen:Ce,listItems:he,listStyle:b({},De,N),listRef:Me.setFloating,loading:ge,loadingText:P,noMatchesText:A,selectedItems:null!==Ae?[Ae]:[]}))};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),t=require("react"),n=require("downshift"),l=require("classnames"),a=require("@entur/form"),r=require("@entur/icons"),o=require("@entur/a11y"),i=require("@entur/loader"),s=require("@entur/tokens"),d=require("@floating-ui/react-dom"),u=require("@entur/button"),c=require("@entur/chip"),m=require("@entur/tooltip");function p(){p=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,l=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},r=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",i=a.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function d(e,t,n,a){var r=Object.create((t&&t.prototype instanceof m?t:m).prototype),o=new S(a||[]);return l(r,"_invoke",{value:w(e,n,o)}),r}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=d;var c={};function m(){}function g(){}function b(){}var h={};s(h,r,(function(){return this}));var f=Object.getPrototypeOf,v=f&&f(f(L([])));v&&v!==t&&n.call(v,r)&&(h=v);var y=b.prototype=m.prototype=Object.create(h);function I(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){function a(l,r,o,i){var s=u(e[l],e,r);if("throw"!==s.type){var d=s.arg,c=d.value;return c&&"object"==typeof c&&n.call(c,"__await")?t.resolve(c.__await).then((function(e){a("next",e,o,i)}),(function(e){a("throw",e,o,i)})):t.resolve(c).then((function(e){d.value=e,o(d)}),(function(e){return a("throw",e,o,i)}))}i(s.arg)}var r;l(this,"_invoke",{value:function(e,n){function l(){return new t((function(t,l){a(e,n,t,l)}))}return r=r?r.then(l,l):l()}})}function w(e,t,n){var l="suspendedStart";return function(a,r){if("executing"===l)throw new Error("Generator is already running");if("completed"===l){if("throw"===a)throw r;return{value:void 0,done:!0}}for(n.method=a,n.arg=r;;){var o=n.delegate;if(o){var i=x(o,n);if(i){if(i===c)continue;return i}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===l)throw l="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);l="executing";var s=u(e,t,n);if("normal"===s.type){if(l=n.done?"completed":"suspendedYield",s.arg===c)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(l="completed",n.method="throw",n.arg=s.arg)}}}function x(e,t){var n=t.method,l=e.iterator[n];if(void 0===l)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),c;var a=u(l,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,c;var r=a.arg;return r?r.done?(t[e.resultName]=r.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):r:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function L(e){if(e){var t=e[r];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var l=-1,a=function t(){for(;++l<e.length;)if(n.call(e,l))return t.value=e[l],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:T}}function T(){return{value:void 0,done:!0}}return g.prototype=b,l(y,"constructor",{value:b,configurable:!0}),l(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,s(e,i,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},I(_.prototype),s(_.prototype,o,(function(){return this})),e.AsyncIterator=_,e.async=function(t,n,l,a,r){void 0===r&&(r=Promise);var o=new _(d(t,n,l,a),r);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},I(y),s(y,i,"Generator"),s(y,r,(function(){return this})),s(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var l in t)n.push(l);return n.reverse(),function e(){for(;n.length;){var l=n.pop();if(l in t)return e.value=l,e.done=!1,e}return e.done=!0,e}},e.values=L,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function l(n,l){return o.type="throw",o.arg=e,t.next=n,l&&(t.method="next",t.arg=void 0),!!l}for(var a=this.tryEntries.length-1;a>=0;--a){var r=this.tryEntries[a],o=r.completion;if("root"===r.tryLoc)return l("end");if(r.tryLoc<=this.prev){var i=n.call(r,"catchLoc"),s=n.call(r,"finallyLoc");if(i&&s){if(this.prev<r.catchLoc)return l(r.catchLoc,!0);if(this.prev<r.finallyLoc)return l(r.finallyLoc)}else if(i){if(this.prev<r.catchLoc)return l(r.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return l(r.finallyLoc)}}}},abrupt:function(e,t){for(var l=this.tryEntries.length-1;l>=0;--l){var a=this.tryEntries[l];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var r=a;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=e,o.arg=t,r?(this.method="next",this.next=r.finallyLoc,c):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),E(n),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var l=n.completion;if("throw"===l.type){var a=l.arg;E(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:L(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},e}function g(e,t,n,l,a,r,o){try{var i=e[r](o),s=i.value}catch(e){return void n(e)}i.done?t(s):Promise.resolve(s).then(l,a)}function b(){return b=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var l in n)Object.prototype.hasOwnProperty.call(n,l)&&(e[l]=n[l])}return e},b.apply(this,arguments)}function h(e){if(null==e)throw new TypeError("Cannot destructure "+e)}function f(e,t){if(null==e)return{};var n,l,a={},r=Object.keys(e);for(l=0;l<r.length;l++)t.indexOf(n=r[l])>=0||(a[n]=e[n]);return a}var v=["children","onChange","onInputValueChange","highlightFirstItemOnOpen","className","style","searchable"],y=t.createContext(null),I=function(e){var a=e.children,r=e.onChange,o=void 0===r?function(){}:r,i=e.onInputValueChange,s=void 0===i?function(){}:i,d=e.highlightFirstItemOnOpen,u=void 0!==d&&d,c=e.className,m=e.style,p=e.searchable,g=void 0!==p&&p,h=f(e,v);return t.createElement(n,b({itemToString:function(e){return e?e.label:""},onStateChange:function(e,t){e.type!==n.stateChangeTypes.controlledPropUpdatedSelectedItem&&("selectedItem"in e?o(e.selectedItem,t):"inputValue"in e&&s(e.inputValue))},stateReducer:function(e,t){var n=u&&"isOpen"in t&&t.isOpen?{highlightedIndex:0}:{};if(!g)return b({},t,n);switch(t.type){case"__autocomplete_change_input__":default:return b({},t,n);case"__autocomplete_click_item__":case"__autocomplete_keydown_enter__":case"__autocomplete_blur_input__":case"__autocomplete_mouseup__":return b({},t,{inputValue:""},n)}}},h),(function(e){return t.createElement("div",{className:l("eds-input-group",c),style:m},t.createElement(y.Provider,{value:e},a))}))},_=function(){var e=t.useContext(y);if(!e)throw new Error("You need to wrap your component in a DownshiftProvider");return e},w=["items"],x=function(e){var n=e.items,a=f(e,w),o=_(),i=o.highlightedIndex,s=o.isOpen,d=o.selectedItem,u=o.getItemProps,c=o.getMenuProps;return t.createElement("ul",b({className:l("eds-dropdown-list",{"eds-dropdown-list--open":s})},c(),a),s?n.map((function(e,n){return t.createElement("li",b({className:l("eds-dropdown-list__item",{"eds-dropdown-list__item--highlighted":i===n,"eds-dropdown-list__item--selected":d===e})},u({key:""+n+e.value,item:e,index:n})),t.createElement("span",null,e.label),e.icons&&t.createElement("span",null,e.icons.map((function(e,n){return t.createElement(e,{key:n,inline:!0,className:"eds-dropdown-list__item-icon"})}))),d===e&&t.createElement(r.CheckIcon,null))})):null)},C=function(){var e=_();return t.createElement("button",b({},(0,e.getToggleButtonProps)({className:l("eds-dropdown__toggle-button",{"eds-dropdown__toggle-button--open":e.isOpen})}),{tabIndex:-1,type:"button"}),t.createElement(r.DownArrowIcon,null))},E=["className","children"],S=function(e){var n=e.className,a=e.children,r=f(e,E);return t.createElement("div",b({className:l("eds-inline-spinner",n)},r),t.createElement(i.LoadingDots,null),t.createElement(o.VisuallyHidden,null,a))},L=["children","className","items","loading","loadingText","placeholder","style","listStyle","clearable","label","isFilled","disableLabelAnimation"],T=function(e){var n=e.children,l=e.className,r=e.items,o=e.loading,i=void 0!==o&&o,d=e.loadingText,u=void 0===d?"Loading...":d,c=e.style,m=e.listStyle,p=e.clearable,g=e.label,h=e.isFilled,v=void 0!==h&&h,y=e.disableLabelAnimation,I=f(e,L),w=_().getLabelProps;return t.createElement("div",{className:"eds-dropdown-wrapper",style:c},t.createElement(a.BaseFormControl,b({append:t.createElement(O,{clearable:p,loading:i,loadingText:u,readOnly:I.readOnly}),className:l,label:g,isFilled:v,labelProps:w(),disableLabelAnimation:y},I),n),t.createElement(x,b({items:r,style:b({position:"absolute",top:s.space.extraLarge3+s.space.extraSmall+"px"},m)},I)))},k=function(e){var n=b({},(h(e),e)),l=_(),a=l.clearSelection,o=l.selectedItem;return t.createElement(t.Fragment,null,o&&t.createElement("button",b({className:"eds-dropdown__clear-button",type:"button",tabIndex:-1,onClick:function(){return a()},"aria-label":"Trykk for å fjerne valg"},n),t.createElement(r.CloseSmallIcon,null)),o&&t.createElement("div",{className:"eds-dropdown__divider"}))},O=function(e){var n=e.clearable,l=e.readOnly;return e.loading?t.createElement(S,null,e.loadingText):l?null:n?t.createElement(t.Fragment,null,t.createElement(k,null)," ",t.createElement(C,null)):t.createElement(C,null)},N=["disabled","placeholder","selectOnTab","openOnFocus","listStyle","items","label","disableLabelAnimation","loading","loadingText","className","clearable"],P=t.forwardRef((function(e,n){var l=e.disabled,a=e.placeholder,r=void 0===a?"Vennligst velg":a,o=e.selectOnTab,i=void 0!==o&&o,s=e.openOnFocus,d=void 0!==s&&s,u=e.listStyle,c=e.items,m=e.label,p=e.disableLabelAnimation,g=e.loading,h=e.loadingText,v=e.className,y=e.clearable,I=f(e,N),w=_(),x=w.getToggleButtonProps,C=w.selectedItem,E=w.selectHighlightedItem,S=w.openMenu,L=w.isOpen,k=w.highlightedIndex,O=w.setHighlightedIndex;return t.createElement(T,b({disabled:l,listStyle:u,items:c,label:m,isFilled:!!C||0!==r.length,disableLabelAnimation:p,loading:g,loadingText:h,className:v,clearable:y},I),t.createElement("button",b({},x(b({className:"eds-form-control eds-dropdown__selected-item",style:{textAlign:"left"},disabled:l,type:"button",onKeyDown:function(e){if(i&&"Tab"===e.key&&E(),L){var t=e.key,n=c.map((function(e,t){return b({},e,{index:t})})).filter((function(e){return e.label.trim().charAt(0).toLowerCase()===t})),l=n.find((function(e){return e.index>(null!=k?k:0)}));l?O(l.index):n.length>0&&O(n[0].index)}},onFocus:function(){d&&!L&&S()}},I)),{ref:n}),C?C.label:r))})),A=["disabled","className","items","loading","loadingText","readOnly","prepend","selectOnTab","openOnFocus","listStyle","clearable","itemFilter","label","disableLabelAnimation","placeholder"],F=t.forwardRef((function(n,l){var a=n.disabled,r=void 0!==a&&a,o=n.className,i=n.items,s=n.loading,d=n.loadingText,u=n.readOnly,c=void 0!==u&&u,m=n.prepend,p=n.selectOnTab,g=void 0!==p&&p,h=n.openOnFocus,v=void 0!==h&&h,y=n.listStyle,I=n.clearable,w=n.itemFilter,x=void 0===w?function(e,t){return function(e,t){if(!t)return!0;var n=t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return new RegExp(n,"i").test(e.label)}(e,t)}:w,C=n.label,E=n.disableLabelAnimation,S=n.placeholder,L=f(n,A),k=_(),O=k.getInputProps,N=k.inputValue,P=k.selectHighlightedItem,F=k.isOpen,B=k.openMenu,V=k.closeMenu,M=k.selectedItem,D=t.useState(!1),R=D[0],j=D[1],K=t.useRef(null),q=t.useMemo((function(){return i.filter((function(e){return x(e,N)}))}),[N,i,x]);return t.createElement(T,{items:q,disabled:r,readOnly:c,className:o,loading:s,loadingText:d,prepend:m,listStyle:y,clearable:I,label:C,isFilled:!!M,disableLabelAnimation:E},!R&&M&&!N&&t.createElement("span",{className:"eds-dropdown__searchable-selected-item__wrapper"},t.createElement("span",{className:"eds-dropdown__searchable-selected-item",onClick:function(){var e;return null==(e=K.current)?void 0:e.focus()}},M.label)),t.createElement("input",b({},O(b({disabled:r,readOnly:c,className:"eds-form-control eds-dropdown__input",onKeyDown:function(e){g&&"Tab"===e.key&&P()},onFocus:function(){!F&&v&&B(),j(!0)},placeholder:M?M.label:S},L)),{onBlur:function(){j(!1),V()},ref:e.mergeRefs(l,K)})))})),B=function(e){var n=e.feedback,l=e.variant;return t.createElement(a.VariantProvider,{variant:l},t.createElement("div",{className:e.className,style:e.style},e.children,n&&l&&t.createElement(a.FeedbackText,{variant:l},n)))},V=function(n,l){void 0===l&&(l=250);var a="function"==typeof n,r=t.useState(a?[]:n),o=r[0],i=r[1],s=t.useState(!1),d=s[0],u=s[1],c=t.useRef(new AbortController),m=t.useMemo((function(){return a?n:function(){return Promise.resolve(n)}}),[n,a]),h=function(){var e,t=(e=p().mark((function e(t){var n,l,a,r,o;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null!=c&&c.current&&(null==c||null==(n=c.current)||n.abort()),l=new AbortController,c.current=l,u(!0),e.prev=4,e.next=7,m(null!=t?t:"",c);case 7:if(o=e.sent,null==c||null==(a=c.current)||null==(r=a.signal)||!r.aborted){e.next=11;break}return console.warn("Avbryt den asynkrone funksjonen din med signalet fra AbortController-en for å for å unngå minnelekkasje.",'Funksjonen bør kaste en DOMException med navnet "AbortError" når den avbrytes.',"","\n\nSe eksempel her: https://design.entur.no/komponenter/skjemaelementer/dropdown#s%C3%B8kbar-dropdown-med-valg-fra-nettverkskall-bassert-p%C3%A5-tekstinput","\nLes mer om AbortController her: https://developer.mozilla.org/en-US/docs/Web/API/AbortController"),e.abrupt("return");case 11:u(!1),i(o),e.next=21;break;case 15:if(e.prev=15,e.t0=e.catch(4),!e.t0||"object"!=typeof e.t0||!("name"in e.t0)||"AbortError"!==e.t0.name){e.next=19;break}return e.abrupt("return");case 19:throw console.warn("The following error was received but not handled inside Entur Designsystems useResolvedItems hook:"),e.t0;case 21:case"end":return e.stop()}}),e,null,[[4,15]])})),function(){var t=this,n=arguments;return new Promise((function(l,a){var r=e.apply(t,n);function o(e){g(r,l,a,o,i,"next",e)}function i(e){g(r,l,a,o,i,"throw",e)}o(void 0)}))});return function(e){return t.apply(this,arguments)}}(),f=e.useDebounce(h,l),v=function(e){return t.useMemo((function(){return e.map((function(e){return"string"==typeof e?{value:e,label:e}:b({},e,void 0===(null==e?void 0:e.value)?{value:e.label}:{value:e.value})}))}),[e])}(o);return t.useEffect((function(){return function(){var e;return null==c||null==(e=c.current)?void 0:e.abort("Component unmounted")}}),[]),t.useEffect((function(){a&&f("")}),[a,m]),{items:v,loading:!!a&&d,fetchItems:f}},M=["highlightFirstItemOnOpen","debounceTimeout","disabled","feedback","items","label","loadingText","onChange","placeholder","prepend","readOnly","searchable","selectOnTab","openOnFocus","variant","value","clearable","className","style","listStyle","itemFilter","disableLabelAnimation"],D=t.forwardRef((function(e,n){var l=e.highlightFirstItemOnOpen,a=e.debounceTimeout,r=e.disabled,o=e.feedback,i=e.items,s=e.label,d=e.loadingText,u=e.onChange,c=void 0===u?function(){}:u,m=e.placeholder,p=e.prepend,g=e.readOnly,h=e.searchable,v=e.selectOnTab,y=e.openOnFocus,_=e.variant,w=e.value,x=e.clearable,C=void 0!==x&&x,E=e.className,S=e.style,L=e.listStyle,T=e.itemFilter,k=e.disableLabelAnimation,O=f(e,M),N=V(i,a),A=N.items,D=N.loading,R=N.fetchItems,j=void 0===w?void 0:A.find((function(e){return w===e.value}))||null,K=h?F:P,q=h?{itemFilter:T,name:O.name,"data-cy":O["data-cy"]}:{name:O.name,"data-cy":O["data-cy"]};return t.createElement(I,b({selectedItem:j,onInputValueChange:R,onChange:c,value:w,highlightFirstItemOnOpen:l,className:E,style:S,searchable:h},O),t.createElement(B,{feedback:o,variant:_},t.createElement(K,b({label:s,items:A,loading:D,loadingText:d,disabled:r,readOnly:g,placeholder:m,prepend:p,selectOnTab:v,openOnFocus:y,listStyle:L,clearable:C,disableLabelAnimation:k,ref:n},q))))})),R=["className","clearable","debounceTimeout","disabled","feedback","initialSelectedItems","items","itemsSelectedLabel","label","listStyle","loading","loadingText","onChange","openOnFocus","readOnly","style","variant"],j=t.createContext(null),K=function(){var e=t.useContext(j);if(!e)throw new Error("You need to wrap your component in a DownshiftProvider");return e};function q(e,t){var l=t.changes;switch(t.type){case n.useSelect.stateChangeTypes.ToggleButtonKeyDownEnter:case n.useSelect.stateChangeTypes.ToggleButtonKeyDownSpaceButton:case n.useSelect.stateChangeTypes.ItemClick:return b({},l,{isOpen:!0,highlightedIndex:e.highlightedIndex});default:return l}}var H=function(e){var n=b({},(h(e),e)),l=K().reset;return t.createElement(t.Fragment,null,t.createElement("button",b({className:"eds-dropdown__clear-button",type:"button",tabIndex:-1,onClick:function(){return l()}},n),t.createElement(r.CloseIcon,null)),t.createElement("div",{className:"eds-dropdown__divider"}))},G=function(e){var n=e.readOnly,l=e.hasSelected;return e.loading?t.createElement(S,null,e.loadingText):n?null:l?t.createElement(t.Fragment,null,t.createElement(H,null),t.createElement(U,null)):t.createElement(U,null)},U=function(){var e=K(),n=e.openMenu,a=e.openOnFocus;return t.createElement("button",b({},(0,e.getToggleButtonProps)({className:l("eds-dropdown__toggle-button",{"eds-dropdown__toggle-button--open":e.isOpen}),onFocus:function(){a&&n()}}),{type:"button"}),t.createElement(r.DownArrowIcon,null))},Y=function(){return t.createElement("svg",{className:"eds-checkbox-icon",width:"11px",height:"9px",viewBox:"6 11 37 33"},t.createElement("path",{className:"eds-checkbox-icon__path",d:"M14.1 27.2l7.1 7.2 14.6-14.8",fill:"none"}))},$=["ariaLabelChosenSingular","ariaLabelSelectedItem","getItemProps","getMenuProps","inputValue","isOpen","highlightedIndex","listItems","listStyle","setListRef","loading","loadingText","noMatchesText","selectAllCheckboxState","selectAllItem","selectedItems","showSelectAllInList"],z=function(e){var n,r=e.ariaLabelChosenSingular,i=void 0===r?"valgt":r,s=e.ariaLabelSelectedItem,d=void 0===s?", valgt element, trykk for å fjerne":s,u=e.getItemProps,c=e.getMenuProps,m=e.isOpen,p=e.highlightedIndex,g=e.listItems,h=e.listStyle,v=e.setListRef,y=e.loading,I=void 0!==y&&y,_=e.loadingText,w=void 0===_?"Laster inn …":_,x=e.noMatchesText,C=void 0===x?"Ingen treff for søket":x,E=e.selectAllCheckboxState,S=e.selectAllItem,L=e.selectedItems,T=f(e,$),k=void 0!==S,O=!I&&(0===g.length||1===(null==g?void 0:g.length)&&(null==g||null==(n=g[0])?void 0:n.value)===(null==S?void 0:S.value)),N=function(e){return L.some((function(t){return(null==t?void 0:t.value)===(null==e?void 0:e.value)&&(null==t?void 0:t.label)===(null==e?void 0:e.label)}))},P=function(){switch(null==E?void 0:E()){case"indeterminate":return{label:(null==S?void 0:S.label)+", delvis valgt",selected:!1};case!0:return{label:(null==S?void 0:S.label)+", "+i,selected:!0};default:return{label:""+(null==S?void 0:S.label),selected:!1}}};return t.createElement("ul",b({},c({"aria-multiselectable":k},{suppressRefError:!0}),{ref:v,className:"eds-dropdown__list",style:b({display:m?"inline-block":"none"},T.style,h)}),!I&&g.length>0&&g.map((function(e,n){var r=e.value===(null==S?void 0:S.value);return r&&g.length<=2?null:t.createElement("li",b({className:l("eds-dropdown__list__item",{"eds-dropdown__list__item--select-all":r,"eds-dropdown__list__item--highlighted":p===n,"eds-dropdown__list__item--selected":!k&&N(e)}),key:(null==e?void 0:e.label)+(null==e?void 0:e.value)},u({item:e,index:n,"aria-selected":r?P().selected:N(e)})),r?t.createElement(t.Fragment,null,t.createElement(a.Checkbox,{"aria-hidden":"true",checked:null==E?void 0:E(),className:"eds-dropdown__list__item__checkbox",onChange:function(){},tabIndex:-1}),t.createElement("span",{className:"eds-dropdown__list__item__text","aria-label":P().label},null==S?void 0:S.label)):function(e){return t.createElement(t.Fragment,null,t.createElement(a.Checkbox,{"aria-hidden":"true",checked:N(e),className:"eds-dropdown__list__item__checkbox",onChange:function(){},style:k?{}:{display:"none"},tabIndex:-1}),t.createElement("span",{className:"eds-dropdown__list__item__text"},e.label,t.createElement(o.VisuallyHidden,null,N(e)?d:"")),e.icons&&t.createElement("span",null,e.icons.map((function(n){var l;return t.createElement(n,{key:(null==e?void 0:e.label)+(null==e?void 0:e.value)+(null!=(l=null==n?void 0:n.displayName)?l:null==n?void 0:n.name),inline:!0,className:"eds-dropdown__list__item__icon"})}))))}(e))})),O&&t.createElement("li",{key:"dropdown-list-no-match",className:"eds-dropdown__list__item"},C),I&&t.createElement("li",{key:"dropdown-list-loading",className:"eds-dropdown__list__item"},w))},J=["tabIndex"],W=function(e){var n,a=e.ariaLabelRemoveSelected,r=e.ariaLabelChosen,o=void 0===r?"valgt":r,i=e.disabled,s=e.getSelectedItemProps,d=e.readOnly,u=e.removeSelectedItem,m=e.selectedItem,p=f(null!=(n=null==s?void 0:s({selectedItem:m,index:e.index}))?n:{},J);return t.createElement(c.TagChip,b({size:"small",className:l("eds-dropdown__selected-item-tag",{"eds-dropdown__selected-item-tag--readonly":d,"eds-dropdown__selected-item-tag--disabled":i})},p,{onClose:function(e){e.stopPropagation(),u(m)},closeButtonAriaLabel:m.label+" "+o+", "+a+" ",key:m.value,"aria-live":"polite"}),t.createElement("span",{"aria-hidden":"true",className:"eds-dropdown__selected-item-tag__text"},m.label))},Q=function(e){var n=e.ariaHiddenToggleButton,l=void 0!==n&&n,a=e.ariaLabelCloseList,r=e.ariaLabelOpenList,o=e.clearable,s=e.disabled,d=e.focusable,u=void 0!==d&&d,c=e.getToggleButtonProps,m=e.isOpen,p=e.loading,g=void 0!==p&&p,b=e.loadingText,h=void 0===b?"Laster resultater …":b,f=e.selectedItems;return void 0!==s&&s?null:t.createElement("div",{className:"eds-dropdown__appendix"},void 0!==o&&o&&(null==f?void 0:f.length)>0&&null!==f[0]&&t.createElement(t.Fragment,null,t.createElement(X,{onClear:e.onClear,focusable:!0,labelClearSelectedItems:e.labelClearSelectedItems}),t.createElement("div",{className:"eds-dropdown__appendix__divider"})),g?t.createElement("div",{className:"eds-dropdown__appendix__toggle-button--loading-dots"},t.createElement(i.LoadingDots,{"aria-label":h})):t.createElement(Z,{"aria-hidden":l,ariaLabelCloseList:a,ariaLabelOpenList:r,getToggleButtonProps:c,isOpen:m,focusable:u}))},X=function(e){var n=e.labelClearSelectedItems,l=void 0===n?"Fjern valgte":n,a=e.focusable;return t.createElement(m.Tooltip,{"aria-hidden":"true",placement:"top",content:l,className:"eds-dropdown__appendix__clear-button__tooltip"},t.createElement(u.IconButton,{className:"eds-dropdown__appendix__clear-button",type:"button",tabIndex:void 0!==a&&a?0:1,onClick:e.onClear,"aria-label":l},t.createElement(r.CloseSmallIcon,{"aria-hidden":"true"})))},Z=function(e){var n=e.isOpen,a=e["aria-hidden"],o=void 0!==a&&a,i=e.ariaLabelCloseList,s=void 0===i?"Lukk liste med valg":i,d=e.ariaLabelOpenList,c=void 0===d?"Åpne liste med valg":d,m=e.focusable,p=void 0!==m&&m;return t.createElement(u.IconButton,b({},(0,e.getToggleButtonProps)({className:l("eds-dropdown__appendix__toggle-button",{"eds-dropdown__appendix__toggle-button--open":n}),"aria-labelledby":void 0}),{"aria-hidden":o,"aria-label":o?void 0:n?s:c,tabIndex:p?0:-1,type:"button"}),t.createElement(r.DownArrowIcon,{"aria-hidden":"true"}))},ee="";function te(e,t){if(!t)return!0;var n=t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return new RegExp(n,"i").test(e.label)}function ne(e,t){return!0}var le=function(e){return e?e.label:""},ae=function(e){return(null==e?void 0:e.label)+(null==e?void 0:e.value)},re=function(e){return"function"==typeof e&&e.length>0};function oe(e){var t=e.selectAllItemIncluded,n=e.resultCount;if(!e.isOpen)return"";var l=void 0!==t&&t?n-1:n;return 0===l?"Ingen resultater":l+" resultat"+(1===l?"":"er")+" tilgjengelig, naviger med pil opp eller ned, velg elementer med Enter."}var ie=["ariaLabelChosenSingular","ariaLabelCloseList","ariaLabelOpenList","ariaLabelSelectedItem","className","clearable","debounceTimeout","disabled","disableLabelAnimation","feedback","items","itemFilter","label","labelClearSelectedItem","labelTooltip","listStyle","loadingText","noMatchesText","onChange","placeholder","prepend","readOnly","selectedItem","selectOnBlur","selectOnTab","style","variant"],se=["className","clearable","clearInputOnSelect","debounceTimeout","disabled","feedback","hideSelectAll","items","itemFilter","label","labelAllItemsSelected","labelClearAllItems","labelSelectAll","labelTooltip","listStyle","loadingText","maxChips","noMatchesText","onChange","placeholder","readOnly","selectedItems","selectOnBlur","selectOnTab","style","variant","ariaLabelChosenSingular","ariaLabelChosenPlural","ariaLabelCloseList","ariaLabelJumpToInput","ariaLabelOpenList","ariaLabelRemoveSelected","ariaLabelSelectedItem"],de=["ariaLabelChosenSingular","ariaLabelCloseList","ariaLabelOpenList","ariaLabelSelectedItem","className","clearable","disabled","disableLabelAnimation","feedback","items","label","labelClearSelectedItem","labelTooltip","listStyle","loadingText","onChange","placeholder","prepend","readOnly","selectedItem","selectOnBlur","selectOnTab","style","variant"],ue=["className","disabled","disableLabelAnimation","feedback","items","label","loadingText","onChange","prepend","readOnly","selectedItem","style","value","variant"],ce=function(e){var n=e.hidden;return e.loading?t.createElement("div",{className:"eds-dropdown-native__loading-dots"},t.createElement(i.LoadingDots,{"aria-label":e.loadingText})):n?t.createElement(t.Fragment,null):t.createElement(r.DownArrowIcon,{inline:!0})};e.warnAboutMissingStyles("dropdown","form","a11y","chip"),exports.Dropdown=function(e){var r,o,i=e.ariaLabelChosenSingular,u=e.ariaLabelCloseList,c=e.ariaLabelOpenList,m=e.ariaLabelSelectedItem,p=e.className,g=e.clearable,h=void 0!==g&&g,v=e.disabled,y=void 0!==v&&v,I=e.disableLabelAnimation,_=e.feedback,w=e.items,x=e.label,C=e.labelClearSelectedItem,E=void 0===C?"fjern valgt":C,S=e.labelTooltip,L=e.listStyle,T=e.loadingText,k=e.onChange,O=e.placeholder,N=e.prepend,P=e.readOnly,A=void 0!==P&&P,F=e.selectedItem,B=e.selectOnBlur,M=void 0!==B&&B,D=e.selectOnTab,R=void 0!==D&&D,j=e.style,K=e.variant,q=void 0===K?"information":K,H=f(e,de),G=V(w),U=G.items,Y=G.loading,$=t.useRef(null),J=null!==F||void 0!==O,W=n.useSelect({items:U,defaultHighlightedIndex:F?void 0:0,selectedItem:F,onStateChange:function(e){var t=e.selectedItem;switch(e.type){case n.useSelect.stateChangeTypes.ToggleButtonBlur:if(!M)break;case n.useSelect.stateChangeTypes.ToggleButtonKeyDownEnter:case n.useSelect.stateChangeTypes.ToggleButtonKeyDownSpaceButton:case n.useSelect.stateChangeTypes.ItemClick:if(void 0===t)return;null==k||k(null!=t?t:null)}},itemToString:le}),X=W.isOpen,Z=W.openMenu,ee=W.getItemProps,te=W.getLabelProps,ne=W.getMenuProps,ae=W.getToggleButtonProps,re=W.highlightedIndex,oe=d.useFloating({whileElementsMounted:function(e,t,n){return d.autoUpdate(e,t,n)},placement:"bottom-start",open:X,middleware:[d.offset(s.space.extraSmall2),d.flip()]}),ie=oe.refs,se=oe.floatingStyles;return t.createElement(a.BaseFormControl,b({append:t.createElement(Q,{ariaHiddenToggleButton:!0,ariaLabelCloseList:u,ariaLabelOpenList:c,clearable:h,labelClearSelectedItems:E,focusable:!1,getToggleButtonProps:ae,isOpen:X,loading:Y,loadingText:T,onClear:function(){var e;null==k||k(null),null==(e=$.current)||e.focus()},disabled:A||y,selectedItems:[F]}),className:l("eds-dropdown",p,{"eds-dropdown--has-tooltip":void 0!==S}),disabled:y,disableLabelAnimation:I,feedback:_,isFilled:J,label:x,labelId:te().id,labelProps:te(),labelTooltip:S,onClick:function(e){e.target===e.currentTarget&&Z()},prepend:N,readOnly:A,ref:ie.setReference,style:j,variant:q},H),t.createElement("div",b({className:"eds-dropdown__selected-item"},ae({id:void 0,onKeyDown:function(e){if(R&&X&&"Tab"===e.key){var t=U[re];t&&(null==k||k(t))}},ref:$})),null!=(r=null!=(o=null==F?void 0:F.label)?o:t.createElement("div",{className:l("eds-dropdown__selected-item__placeholder",{"eds-dropdown__selected-item__placeholder--readonly":A})},O))?r:""),t.createElement(z,{ariaLabelChosenSingular:i,ariaLabelSelectedItem:m,getItemProps:ee,getMenuProps:ne,highlightedIndex:re,isOpen:X,listItems:U,listStyle:b({},se,L),setListRef:ie.setFloating,loading:Y,loadingText:T,selectedItems:null!==F?[F]:[]}))},exports.DropdownDeprecated=D,exports.MultiSelect=function(r){var i=r.className,u=r.clearable,c=void 0===u||u,m=r.clearInputOnSelect,p=void 0!==m&&m,g=r.debounceTimeout,h=r.disabled,v=void 0!==h&&h,y=r.feedback,I=r.hideSelectAll,_=void 0!==I&&I,w=r.items,x=r.itemFilter,C=void 0===x?re(w)?ne:te:x,E=r.label,S=r.labelAllItemsSelected,L=void 0===S?"Alle valgt":S,T=r.labelClearAllItems,k=void 0===T?"Fjern valgte":T,O=r.labelSelectAll,N=void 0===O?"Velg alle":O,P=r.labelTooltip,A=r.listStyle,F=r.loadingText,B=r.maxChips,M=void 0===B?10:B,D=r.noMatchesText,R=r.onChange,j=void 0===R?function(){}:R,K=r.placeholder,q=r.readOnly,H=void 0!==q&&q,G=r.selectedItems,U=void 0===G?[]:G,Y=r.selectOnBlur,$=void 0!==Y&&Y,J=r.selectOnTab,X=void 0!==J&&J,Z=r.style,ie=r.variant,de=void 0===ie?"information":ie,ue=r.ariaLabelChosenSingular,ce=r.ariaLabelChosenPlural,me=void 0===ce?"valgte":ce,pe=r.ariaLabelCloseList,ge=r.ariaLabelJumpToInput,be=void 0===ge?U.length+" valgte elementer, trykk for å hoppe til tekstfeltet":ge,he=r.ariaLabelOpenList,fe=r.ariaLabelRemoveSelected,ve=void 0===fe?"trykk for å fjerne valg":fe,ye=r.ariaLabelSelectedItem,Ie=f(r,se),_e=t.useState(0),we=_e[0],xe=_e[1],Ce=t.useRef(null);t.useEffect((function(){void 0!==Ie.selectedItem&&console.warn("Incorrect 'selectedItem' prop found, did you mean to use 'selectedItems?")}),[Ie.selectedItem]);var Ee=V(w,g),Se=Ee.items,Le=Ee.loading,Te=Ee.fetchItems,ke="function"!=typeof w&&U.length===Se.length,Oe={value:e.useRandomId("select-all"),label:N},Ne=t.useMemo((function(){return{value:ee,label:ke?L:U.length+" "+me}}),[ke,U,L,me]),Pe=t.useState([].concat(_?[]:[Oe],Se)),Ae=Pe[0],Fe=Pe[1],Be=function(e){var t=e.inputValue;return Fe([].concat(_?[]:[Oe],Se.filter((function(e){return C(e,t)}))))},Ve=function(e){var t=e.inputValue;re(w)&&Te(null!=t?t:ee),Be({inputValue:null!=t?t:ee})};t.useEffect((function(){Be({inputValue:Xe})}),[Se]);var Me=function(e){var t=e.selectedItems,n=e.selectAll,l=t.length>0,a=e.listItems.filter((function(e){return e.value!==n.value})),r=a.filter((function(e){return!t.some((function(t){return t.value===e.value}))})),o=!a.some((function(e){return!t.some((function(t){return t.value===e.value}))})),i=a.some((function(e){return t.some((function(t){return t.value===e.value}))})),s=function(e,n){return n([].concat(t,[e]))},d=function(e){return t.some((function(t){return t.value===e.value}))},u=function(e){return e.value===n.value},c=function(e,n){return n(t.filter((function(t){return t.value!==e.value})))},m=function(e){e([].concat(t,r))},p=function(e){e(t.filter((function(e){return!a.some((function(t){return t.value===e.value}))})))};return{addClickedItemToSelectedItems:s,allListItemsAreSelected:o,clickedItemIsInSelectedItems:d,clickedItemIsSelectAll:u,handleListItemClicked:function(e){var t=e.clickedItem,n=e.onChange;return u(t)?o?p(n):m(n):d(t)?c(t,n):void s(t,n)},hasSelectedItems:l,listItemsWithoutSelectAll:a,removeClickedItemFromSelectedItems:c,selectAllCheckboxState:function(){return!!o||!!i&&"indeterminate"},selectAllUnselectedItemsInListItems:m,someListItemsAreSelected:i,unselectAllListItems:p}}({listItems:Ae,selectAll:Oe,selectedItems:U}),De=Me.hasSelectedItems,Re=Me.handleListItemClicked,je=Me.selectAllCheckboxState,Ke=n.useMultipleSelection({selectedItems:U,itemToString:le,itemToKey:ae,onStateChange:function(e){var t=e.selectedItems;switch(e.type){case n.useMultipleSelection.stateChangeTypes.SelectedItemKeyDownBackspace:case n.useMultipleSelection.stateChangeTypes.SelectedItemKeyDownDelete:case n.useMultipleSelection.stateChangeTypes.DropdownKeyDownBackspace:case n.useMultipleSelection.stateChangeTypes.FunctionRemoveSelectedItem:void 0!==t&&j(t)}}}),qe=Ke.getSelectedItemProps,He=Ke.getDropdownProps,Ge=t.useCallback((function(e,t){var l=t.changes,a=t.type;switch(void 0!==l.highlightedIndex&&(null==l?void 0:l.highlightedIndex)>=0&&xe(null==l?void 0:l.highlightedIndex),a){case n.useCombobox.stateChangeTypes.InputKeyDownEnter:case n.useCombobox.stateChangeTypes.ItemClick:var r,o;return p&&Ve({inputValue:ee}),b({},l,{isOpen:!0,inputValue:p?ee:null!=(r=null==Ce||null==(o=Ce.current)?void 0:o.value)?r:ee});case n.useCombobox.stateChangeTypes.ControlledPropUpdatedSelectedItem:var i,s;return b({},l,{inputValue:null!=(i=null==Ce||null==(s=Ce.current)?void 0:s.value)?i:ee});case n.useCombobox.stateChangeTypes.InputChange:var d,u=/^\s+/g,c=" "===l.inputValue;return null!=(d=l.inputValue)&&d.match(u)?(tt(l.inputValue.replace(u,ee)),c&&(et(),Ze&&void 0!==l.highlightedIndex&&Re({clickedItem:Ae[l.highlightedIndex],onChange:j})),l):(Ve({inputValue:l.inputValue}),xe(_?0:1),b({},l,{highlightedIndex:_?0:1}));case n.useCombobox.stateChangeTypes.InputBlur:return Ve({inputValue:ee}),b({},l,{inputValue:ee});default:return l}}),[_,Se,Be,w]),Ue=n.useCombobox(b({defaultHighlightedIndex:we,items:Ae,itemToString:le,selectedItem:null,stateReducer:Ge,onStateChange:function(e){var t=e.selectedItem;if(t)switch(e.type){case n.useCombobox.stateChangeTypes.InputBlur:if(!$)break;case n.useCombobox.stateChangeTypes.InputKeyDownEnter:case n.useCombobox.stateChangeTypes.ItemClick:Re({clickedItem:t,onChange:j})}},getA11yStatusMessage:function(e){return oe(b({},e,{selectAllItemIncluded:!_,resultCount:Ae.length}))}},Ie)),Ye=Ue.getInputProps,$e=Ue.getItemProps,ze=Ue.getLabelProps,Je=Ue.getMenuProps,We=Ue.getToggleButtonProps,Qe=Ue.highlightedIndex,Xe=Ue.inputValue,Ze=Ue.isOpen,et=Ue.openMenu,tt=Ue.setInputValue,nt=d.useFloating({whileElementsMounted:function(e,t,n){return d.autoUpdate(e,t,n)},placement:"bottom-start",open:Ze,middleware:[d.offset(s.space.extraSmall2),d.flip()]}),lt=nt.refs,at=nt.floatingStyles,rt=function(){var e;j([]),tt(ee),null==(e=Ce.current)||e.focus(),Ve({inputValue:Xe})};return t.createElement(a.BaseFormControl,b({append:t.createElement(Q,{ariaLabelCloseList:pe,ariaLabelOpenList:he,selectedItems:U,isOpen:Ze,clearable:c,labelClearSelectedItems:k,focusable:!1,loading:Le,loadingText:F,disabled:H||v,onClear:rt,getToggleButtonProps:We}),className:l("eds-dropdown","eds-dropdown--multiselect",i,{"eds-dropdown--has-tooltip":void 0!==P}),disabled:v,feedback:y,isFilled:De||Xe!==ee,label:E,labelId:ze().id,labelProps:ze(),labelTooltip:P,onClick:function(e){var t;e.target===e.currentTarget&&(null==(t=Ce.current)||t.focus())},readOnly:H,ref:lt.setReference,style:Z,variant:de},Ie),t.createElement("div",{className:l("eds-dropdown--multiselect__selected-items-and-input",{"eds-dropdown--multiselect__selected-items-and-input--filled":De}),onClick:function(e){e.target===e.currentTarget&&et()}},U.length<=M?t.createElement(t.Fragment,null,U.length>1?t.createElement(o.VisuallyHidden,{onClick:function(){var e;return null==(e=Ce.current)?void 0:e.focus()}},be):t.createElement(t.Fragment,null),U.map((function(e,n){return t.createElement(W,{ariaLabelChosen:ue,ariaLabelRemoveSelected:ve,disabled:v,getSelectedItemProps:qe,index:n,key:(null==e?void 0:e.label)+("string"==typeof(null==e?void 0:e.value)?e.value:""),readOnly:H,removeSelectedItem:function(){var t;Re({clickedItem:e,onChange:j}),null==Ce||null==(t=Ce.current)||t.focus()},selectedItem:e})}))):t.createElement(W,{ariaLabelRemoveSelected:k,ariaLabelChosen:"",disabled:v,readOnly:H,removeSelectedItem:rt,selectedItem:Ne}),t.createElement("input",b({placeholder:K,className:"eds-dropdown__input eds-form-control",disabled:H||v},Ye(b({onKeyDown:function(e){if(X&&Ze&&"Tab"===e.key){var t=Ae[Qe];t&&Re({clickedItem:t,onChange:j})}}},He({preventKeyAction:Ze,value:null!=Xe?Xe:ee,ref:Ce})))))),t.createElement(z,{ariaLabelChosenSingular:ue,ariaLabelSelectedItem:ye,getItemProps:$e,getMenuProps:Je,highlightedIndex:Qe,inputValue:Xe,isOpen:Ze,listItems:Ae,listStyle:b({},at,A),setListRef:lt.setFloating,loading:Le,loadingText:F,noMatchesText:D,selectAllCheckboxState:je,selectAllItem:Oe,selectedItems:U}))},exports.MultiSelectDeprecated=function(r){var o=r.className,i=r.clearable,d=void 0!==i&&i,u=r.debounceTimeout,c=r.disabled,m=r.feedback,p=r.initialSelectedItems,g=void 0===p?[]:p,h=r.items,v=r.itemsSelectedLabel,y=void 0===v?function(e){return function(e){return e.length<3?e.map((function(e){return e.label})).toString():e.length+" elementer valgt"}(e)}:v,I=r.label,_=r.listStyle,w=r.loading,x=void 0!==w&&w,C=r.loadingText,E=void 0===C?"":C,S=r.onChange,L=void 0===S?function(){}:S,T=r.openOnFocus,k=void 0!==T&&T,O=r.readOnly,N=void 0!==O&&O,P=r.style,A=r.variant,F=f(r,R),B=V(h,u).items,M=t.useState(g),D=M[0],K=M[1],H=t.useCallback((function(){K([])}),[]);function U(e){return D.some((function(t){return t.value===e.value}))}var $=n.useSelect(b({items:B,stateReducer:q,selectedItem:null,onSelectedItemChange:function(e){var t=e.selectedItem;if(t)if(U(t)){var n=D.filter((function(e){return e.value!==t.value}));K(n),L(n)}else{var l=[].concat(D,[t]);K(l),L(l)}}},F)),z=$.isOpen,J=$.getToggleButtonProps,W=$.getLabelProps,Q=$.getMenuProps,X=$.highlightedIndex,Z=$.getItemProps,ee=$.openMenu,te=D.length?y(D):"",ne=e.useRandomId("eds-multiselect");return t.createElement(j.Provider,{value:{isOpen:z,reset:H,getToggleButtonProps:J,openMenu:ee,openOnFocus:k}},t.createElement("div",{className:l("eds-multiselect","eds-dropdown-wrapper",o),style:P},t.createElement(a.BaseFormControl,{label:I,labelId:ne,labelProps:W,feedback:m,variant:A,isFilled:D.length>0||z,disabled:c,readOnly:N,append:t.createElement(G,{hasSelected:d&&D.length>0,loading:x,loadingText:E,readOnly:N})},t.createElement("button",b({},J({style:{textAlign:"left"},type:"button",className:"eds-form-control eds-multiselect__button"})),te)),t.createElement("ul",b({className:l("eds-dropdown-list",{"eds-dropdown-list--open":z})},Q({style:b({position:"absolute",top:s.space.extraLarge3+s.space.extraSmall+"px"},_)})),z&&B.map((function(e,n){return t.createElement("li",b({className:l("eds-dropdown-list__item",{"eds-dropdown-list__item--highlighted":X===n,"eds-dropdown-list__item--selected":U(e)}),key:""+e.value+n},Z({item:e,index:n}),{style:{display:"flex"}}),t.createElement("span",{style:{display:"flex"}},t.createElement("span",{className:l("eds-multiselect-checkbox",{"eds-multiselect-checkbox--checked":U(e)})},t.createElement(Y,null)),t.createElement("span",{className:"eds-multiselect__item-label"},e.label)),e.icons&&t.createElement("span",null,e.icons.map((function(e,n){return t.createElement(e,{key:n,inline:!0,className:"eds-dropdown-list__item-icon"})}))))})))))},exports.NativeDropdown=function(n){var l,r=n.className,o=n.disabled,i=void 0!==o&&o,s=n.disableLabelAnimation,d=n.feedback,u=n.items,c=n.label,m=n.loadingText,p=n.onChange,g=n.prepend,h=n.readOnly,v=void 0!==h&&h,y=n.selectedItem,I=n.style,_=n.value,w=n.variant,x=f(n,ue),C=V(u),E=C.items,S=C.loading,L=e.useRandomId("eds-dropdown-native");return t.createElement(a.BaseFormControl,{disabled:i,readOnly:v,prepend:g,append:t.createElement(ce,{hidden:i||v,loading:S,loadingText:m}),className:r,style:I,label:c,labelId:L,variant:w,feedback:d,disableLabelAnimation:s,isFilled:!0},t.createElement("select",b({"aria-invalid":"negative"===w||"error"===w,"aria-labelledby":L,"aria-busy":S,className:"eds-form-control eds-dropdown--native",disabled:i||v,onChange:function(e){var t;null==p||p({value:e.target.value,selectedItem:null!=(t=E.find((function(t){return t.value===e.target.value})))?t:null,target:e.target})},value:null!=(l=null!=_?_:null==y?void 0:y.value)?l:void 0},x),E.map((function(e){return t.createElement("option",{key:e.value,value:e.value},e.label)}))))},exports.SearchableDropdown=function(e){var r,o,i=e.ariaLabelChosenSingular,u=e.ariaLabelCloseList,c=e.ariaLabelOpenList,m=e.ariaLabelSelectedItem,p=e.className,g=e.clearable,h=void 0===g||g,v=e.debounceTimeout,y=e.disabled,I=void 0!==y&&y,_=e.disableLabelAnimation,w=void 0!==_&&_,x=e.feedback,C=e.items,E=e.itemFilter,S=void 0===E?re(C)?ne:te:E,L=e.label,T=e.labelClearSelectedItem,k=void 0===T?"fjern valgt":T,O=e.labelTooltip,N=e.listStyle,P=e.loadingText,A=e.noMatchesText,F=e.onChange,B=void 0===F?function(){}:F,M=e.placeholder,D=e.prepend,R=e.readOnly,j=void 0!==R&&R,K=e.selectedItem,q=e.selectOnBlur,H=void 0!==q&&q,G=e.selectOnTab,U=void 0!==G&&G,Y=e.style,$=e.variant,J=void 0===$?"info":$,W=f(e,ie),X=t.useState(null!==K),Z=X[0],ae=X[1],se=t.useState(0),de=se[0],ue=se[1],ce=t.useRef(null),me=V(C,v),pe=me.items,ge=me.loading,be=me.fetchItems,he=t.useState(pe),fe=he[0],ve=he[1],ye=function(e){var t=e.inputValue;return ve(pe.filter((function(e){return S(e,t)})))},Ie=function(e){var t=e.inputValue;re(C)&&be(null!=t?t:ee),ye({inputValue:null!=t?t:ee})},_e="undefined"!=typeof document&&(null==ce?void 0:ce.current)===(null==(r=document)?void 0:r.activeElement);t.useEffect((function(){ye({inputValue:Fe})}),[pe]),t.useEffect((function(){null===Ae||_e||(ae(!0),Ie({inputValue:ee}),Be(ee))}),[]);var we=t.useCallback((function(e,t){var l=t.type,a=t.changes;switch(void 0!==a.highlightedIndex&&(null==a?void 0:a.highlightedIndex)>=0&&ue(null==a?void 0:a.highlightedIndex),l){case n.useCombobox.stateChangeTypes.ItemClick:case n.useCombobox.stateChangeTypes.InputKeyDownEnter:case n.useCombobox.stateChangeTypes.InputBlur:return Ie({inputValue:ee}),b({},a,{inputValue:ee});case n.useCombobox.stateChangeTypes.ControlledPropUpdatedSelectedItem:return null===a.selectedItem||_e||ae(!0),Ie({inputValue:ee}),b({},a,{inputValue:ee});case n.useCombobox.stateChangeTypes.InputChange:var r,o=/^\s+/g,i=" "===a.inputValue;return null!=(r=a.inputValue)&&r.match(o)?(Be(a.inputValue.replace(o,ee)),i&&(Ee(),Ce&&void 0!==a.highlightedIndex&&B(fe[a.highlightedIndex]))):(Ie({inputValue:a.inputValue}),Ne(0),ue(0)),a;default:return a}}),[be,ye]),xe=n.useCombobox(b({defaultHighlightedIndex:de,items:fe,itemToString:le,selectedItem:K,stateReducer:we,onStateChange:function(e){var t=e.selectedItem;switch(e.type){case n.useCombobox.stateChangeTypes.InputBlur:if(!H)break;case n.useCombobox.stateChangeTypes.InputKeyDownEnter:case n.useCombobox.stateChangeTypes.ItemClick:if(void 0===t)return;B(null!=t?t:null)}},getA11yStatusMessage:function(e){return oe(b({},e,{resultCount:fe.length}))}},W)),Ce=xe.isOpen,Ee=xe.openMenu,Se=xe.getToggleButtonProps,Le=xe.getLabelProps,Te=xe.getMenuProps,ke=xe.getInputProps,Oe=xe.highlightedIndex,Ne=xe.setHighlightedIndex,Pe=xe.getItemProps,Ae=xe.selectedItem,Fe=xe.inputValue,Be=xe.setInputValue,Ve=d.useFloating({whileElementsMounted:function(e,t,n){return d.autoUpdate(e,t,n)},placement:"bottom-start",open:Ce,middleware:[d.offset(s.space.extraSmall2),d.flip()]}),Me=Ve.refs,De=Ve.floatingStyles;return t.createElement(a.BaseFormControl,b({append:t.createElement(Q,{ariaLabelCloseList:u,ariaLabelOpenList:c,clearable:h,labelClearSelectedItems:k,disabled:j||I,focusable:!1,getToggleButtonProps:Se,isOpen:Ce,loading:ge,loadingText:P,onClear:function(){var e;B(null),Be(ee),null==(e=ce.current)||e.focus(),Ie({inputValue:Fe}),ae(!1)},selectedItems:[Ae]}),className:l("eds-dropdown","eds-dropdown--searchable",p,{"eds-dropdown--has-tooltip":void 0!==O}),disabled:I,disableLabelAnimation:w,feedback:x,isFilled:null!==Ae||Fe!==ee,label:L,labelId:Le().id,labelProps:Le(),labelTooltip:O,onClick:function(e){var t;e.target===e.currentTarget&&(null==(t=ce.current)||t.focus())},prepend:D,readOnly:j,ref:Me.setReference,style:Y,variant:J},W),t.createElement("span",{className:l("eds-dropdown--searchable__selected-item",{"eds-dropdown--searchable__selected-item--hidden":!Z}),"aria-hidden":"true",onClick:function(){var e;null==(e=ce.current)||e.focus(),Ee()}},Z?null==Ae?void 0:Ae.label:""),t.createElement("input",b({className:l("eds-dropdown__input eds-form-control",{"eds-dropdown__input--hidden":Z}),disabled:j||I,placeholder:null!=(o=null==Ae?void 0:Ae.label)?o:M},ke({onBlur:function(){null!==Ae&&ae(!0)},onFocus:function(){ae(!1)},onKeyDown:function(e){U&&Ce&&"Tab"===e.key&&(null==B||B(fe[Oe]))},ref:ce}))),t.createElement(z,{ariaLabelChosenSingular:i,ariaLabelSelectedItem:m,getItemProps:Pe,getMenuProps:Te,highlightedIndex:Oe,isOpen:Ce,listItems:fe,listStyle:b({},De,N),setListRef:Me.setFloating,loading:ge,loadingText:P,noMatchesText:A,selectedItems:null!==Ae?[Ae]:[]}))};
//# sourceMappingURL=dropdown.cjs.production.min.js.map
{
"name": "@entur/dropdown",
"version": "6.0.3-RC.1",
"version": "6.0.3-RC.2",
"license": "EUPL-1.2",

@@ -43,3 +43,3 @@ "main": "dist/index.js",

},
"gitHead": "d7b4d04bcbef5d3861b802b0a6af3f36a91a4118"
"gitHead": "cae8c3d33759ad14480e6c3f42f864d7969edf3a"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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