{"version":3,"file":"price_dropdown-BXxh9n9e.js","sources":["../../../app/assets/javascripts/components/dropdown_menu/desktop/price_dropdown.ts"],"sourcesContent":["\nimport numeral from \"numeral\"\nimport isBlankStr from \"underscore.string/isBlank\"\nimport {\n MinMaxSelectWithChosen,\n InputSelector as BaseInputSelector,\n DEFAULT_SELECTOR as BASE_DEFAULT_SELECTOR,\n} from \"components/dropdown_menu/with_chosen\"\n\nexport type InputSelector = BaseInputSelector & {\n scope?: string | Element | JQuery\n main?: string | Element | JQuery\n min_select?: string | Element | JQuery\n max_select?: string | Element | JQuery\n toggle?: string | Element | JQuery\n dropdown?: string | Element | JQuery\n min_wrapper?: string | Element | JQuery\n max_wrapper?: string | Element | JQuery\n}\nconst DEFAULT_SELECTOR = Object.assign({}, BASE_DEFAULT_SELECTOR, {\n scope: \".cell-listing-filter\",\n main: \".cell-listing-filter__price-dropdown-container\",\n min_select: \".cell-listing-filter__minimum-price-input\",\n max_select: \".cell-listing-filter__maximum-price-input\",\n toggle: \".dropdown-with-input-toggle\",\n dropdown: \".dropdown-menu-with-input\",\n max_wrapper: \".filter-option--price-max\",\n min_wrapper: \".filter-option--price-min\",\n})\n\n\nclass PriceDropdown extends MinMaxSelectWithChosen {\n protected name: string\n\n constructor(selector?: InputSelector){\n const merged_selector = Object.assign({}, DEFAULT_SELECTOR, selector)\n super(merged_selector)\n\n this.name = \"price_dropdown_blueprint\"\n }\n\n protected onChange(e: Event): void {\n super.onChange(e)\n\n this.emit(\"val_change\")\n }\n protected convertValueToLabel(): string {\n const min_value = this.$min_select.val()\n const max_value = this.$max_select.val()\n\n if (!isBlankStr(min_value) && !isBlankStr(max_value)){\n return `${this.convert(min_value)} - ${this.convert(max_value)}`\n }\n else if (!isBlankStr(min_value)){\n return `> ${this.convert(min_value)}`\n }\n else if ( !isBlankStr(max_value) ){\n return `< ${this.convert(max_value)}`\n }\n else{\n return this.$selected_text.data(\"original-text\")\n }\n }\n protected onClick(): void {\n this.toggle()\n\n setTimeout(() => {\n // set Timeout here\n // hypothesis: As button is not a part of the chosen jquery\n // so we handle onClick event here\n // but later chosen treat this as an clickout event of chosen\n // click our btn -> clickout of chosen -> hiding\n // so we Have to use settimeout to activate the chosen afterward\n // click our btn (onclick handle)-> clickout of chosen -> hiding -> chosen:open\n // |------------------------------------------------^\n // we open max_select instead as We guess user are more often to choose max price selector rather then min\n this.$max_select.trigger(\"chosen:open\")\n })\n }\n\n public hide(): void {\n this.reset()\n this.$el.hide()\n }\n\n public show(): void {\n this.$el.show()\n }\n\n protected convert(val: number): string {\n return `$${numeral(val).format(\"0[.]0a\")}`\n }\n}\n\n\nexport {\n PriceDropdown,\n DEFAULT_SELECTOR,\n}\n"],"names":["DEFAULT_SELECTOR","BASE_DEFAULT_SELECTOR","PriceDropdown","MinMaxSelectWithChosen","selector","merged_selector","min_value","max_value","isBlankStr","val","numeral"],"mappings":"+HAmBA,MAAMA,EAAmB,OAAO,OAAO,CAAA,EAAIC,EAAuB,CAChE,MAAc,uBACd,KAAc,iDACd,WAAc,4CACd,WAAc,4CACd,OAAc,8BACd,SAAc,4BACd,YAAc,4BACd,YAAc,2BAChB,CAAC,EAGD,MAAMC,UAAsBC,CAAuB,CAGjD,YAAYC,EAAyB,CACnC,MAAMC,EAAkB,OAAO,OAAO,CAAA,EAAIL,EAAkBI,CAAQ,EACpE,MAAMC,CAAe,EAErB,KAAK,KAAO,0BAAA,CAGJ,SAAS,EAAgB,CACjC,MAAM,SAAS,CAAC,EAEhB,KAAK,KAAK,YAAY,CAAA,CAEd,qBAA8B,CAChC,MAAAC,EAAY,KAAK,YAAY,IAAI,EACjCC,EAAY,KAAK,YAAY,IAAI,EAEvC,MAAI,CAACC,EAAWF,CAAS,GAAK,CAACE,EAAWD,CAAS,EAC1C,GAAG,YAAK,QAAQD,CAAS,EAAC,OAAM,YAAK,QAAQC,CAAS,GAErDC,EAAWF,CAAS,EAGnBE,EAAWD,CAAS,EAItB,KAAK,eAAe,KAAK,eAAe,EAHxC,KAAK,YAAK,QAAQA,CAAS,GAH3B,KAAK,YAAK,QAAQD,CAAS,EAOpC,CAEQ,SAAgB,CACxB,KAAK,OAAO,EAEZ,WAAW,IAAM,CAUV,KAAA,YAAY,QAAQ,aAAa,CAAA,CACvC,CAAA,CAGI,MAAa,CAClB,KAAK,MAAM,EACX,KAAK,IAAI,KAAK,CAAA,CAGT,MAAa,CAClB,KAAK,IAAI,KAAK,CAAA,CAGN,QAAQG,EAAqB,CACrC,MAAO,IAAI,OAAAC,EAAQD,CAAG,EAAE,OAAO,QAAQ,EAAC,CAE5C"}