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yC,MAKH,OAHAxD,EAAAC,EAAA,CAAE,oBAAoBwD,YACpB,gDAEK3D","sources":["scripts/src/actionlist/index.ts"],"sourcesContent":["import Choices from \"choices.js\";\r\nimport $ from \"jquery\";\r\n\r\nexport const actionlist = (\r\n target: string | HTMLElement = \"select.js-choices\"\r\n) => {\r\n const $target = target instanceof HTMLElement ? $(target) : $(target); // workaround for jquery typescript quirk\r\n const instances = $target\r\n .map(function () {\r\n const $this = $(this);\r\n const list = ($this as unknown) as HTMLSelectElement;\r\n const choices = JSON.parse($(this).attr(\"data-options\") || \"[]\");\r\n const initialSelections = JSON.parse(\r\n $(this).attr(\"data-initial-values\") || \"[]\"\r\n );\r\n const className = $(this).attr(\"class\") || \"\";\r\n const isProductActionList = $this.hasClass(\"js-choices-product\");\r\n const disableDefaultSorting = $this.hasClass(\"js-choices--disable-sort\")\r\n ? false\r\n : true;\r\n // tslint:disable-next-line\r\n const instance = new Choices($(list)[0], {\r\n choices,\r\n items: initialSelections,\r\n classNames: {\r\n containerOuter: className,\r\n containerInner: isProductActionList\r\n ? \"choices__inner choices__inner--product\"\r\n : \"choices__inner\",\r\n input: \"choices__input\",\r\n inputCloned: \"choices__input--cloned\",\r\n list: \"choices__list\",\r\n listItems: \"choices__list--multiple\",\r\n listSingle: \"choices__list--single\",\r\n listDropdown: \"choices__list--dropdown\",\r\n item: \"choices__item \" + ($this.hasClass(\"js-choices-dark\") ? \"choices__item--dark\" : \"\"),\r\n itemSelectable: \"choices__item--selectable\",\r\n itemDisabled: \"choices__item--disabled\",\r\n itemChoice: \"choices__item--choice\",\r\n placeholder: \"choices__placeholder\",\r\n group: \"choices__group\",\r\n groupHeading: \"choices__heading\",\r\n button: \"choices__button\",\r\n activeState: \"is-active\",\r\n focusState: \"is-focused\",\r\n openState: \"is-open\",\r\n disabledState: \"is-disabled\",\r\n highlightedState: \"is-highlighted\",\r\n selectedState: \"is-selected\",\r\n flippedState: \"is-flipped\",\r\n loadingState: \"is-loading\",\r\n noResults: \"has-no-results\",\r\n noChoices: \"has-no-choices\"\r\n },\r\n shouldSort: disableDefaultSorting,\r\n searchEnabled: false,\r\n callbackOnInit: function () {\r\n if (!initialSelections || !initialSelections[0]) {\r\n return;\r\n }\r\n\r\n // tslint:disable-next-line\r\n this._highlightPosition = this.config.choices.findIndex(\r\n o => o.value === initialSelections[0]\r\n );\r\n }\r\n });\r\n $this.on(\"change\", function () {\r\n if (!$this.hasClass(\"js-not-link\")) {\r\n window.location.href = \"\" + $this.val();\r\n }\r\n });\r\n return instance;\r\n })\r\n .get();\r\n // used to insert product color or image in the action list\r\n $(\".js-product-icon\").insertAfter(\r\n \".js-product-list-icon .choices--product-list\"\r\n );\r\n return instances;\r\n};\r\nexport const changeProductColour = (backgroundColor: string) => {\r\n $(\".js-product-bg-colour\").css({ \"background-color\": backgroundColor });\r\n};\r\n"],"names":["$h6y48","parcelRequire","$7cf7e0aa20254005$export$368f3681dc02d125","target","instances","HTMLElement","$parcel$interopDefault","$4sYka","map","$this","this","list","choices","JSON","parse","attr","initialSelections","className","isProductActionList","hasClass","disableDefaultSorting","instance","items","classNames","containerOuter","containerInner","input","inputCloned","listItems","listSingle","listDropdown","item","itemSelectable","itemDisabled","itemChoice","placeholder","group","groupHeading","button","activeState","focusState","openState","disabledState","highlightedState","selectedState","flippedState","loadingState","noResults","noChoices","shouldSort","searchEnabled","callbackOnInit","_highlightPosition","config","findIndex","o","value","on","window","location","href","val","get","insertAfter"],"version":3,"file":"actionlist.ddc19fc1.js.map"}