UNPKG

@visitscotland/component-library

Version:
1 lines 6.83 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VsGuestSelector=t():e.VsGuestSelector=t()}(self,(function(){return(self.webpackChunk_visitscotland_component_library=self.webpackChunk_visitscotland_component_library||[]).push([[3741],{21726:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return o.a}});var l=n(38300),o=n.n(l),a={};for(var u in l)"default"!==u&&(a[u]=function(e){return l[e]}.bind(0,u));n.d(t,a)},31440:function(e,t,n){"use strict";n(44596)},34900:function(e,t,n){"use strict";n.r(t);var l=n(21726),o={};for(var a in l)"default"!==a&&(o[a]=function(e){return l[e]}.bind(0,a));n.d(t,o),n(31440);const u=l.default;t.default=u},38300:function(e,t,n){"use strict";var l=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(17527),a=n(17527),u={class:"form-group vs-guest-selector","data-test":"vs-guest-selector"},s={class:"vs-guest-selector__label"},r=["disabled"],i={class:"vs-guest-selector__button-row mb-075"},c={class:"d-flex justify-content-between"},d=["value","disabled"],m=["value","disabled"],v=n(17527),f=n(378),g=l(n(26216)),p=l(n(48836));t.default=(0,o.defineComponent)({__name:"GuestSelector",props:{availability:{type:Boolean}},setup:function(e){var t=(0,v.getCurrentInstance)(),n=(0,f.getLabelText)("add_room_label","Add a Room","guests_rooms"),l=(0,f.getLabelText)("save_changes","Save","guests_rooms"),o=(0,v.ref)(2),b=(0,f.getLabelText)("guest","Guest","guests_rooms"),_=(0,f.getLabelText)("guests","Guests","guests_rooms"),h=(0,v.ref)(!1),x=(0,v.ref)(0),y=(0,v.ref)([{id:"".concat(t.uid),showRemoveBtn:!1,numberGroups:{adults:{minCount:1,maxCount:30,count:2,name:"r1a",unitLabel:(0,f.getLabelText)("adults","Adults","guests_rooms")},children:{minCount:0,maxCount:30,count:0,name:"r1children",unitLabel:(0,f.getLabelText)("children","Children","guests_rooms")},infants:{minCount:0,maxCount:30,count:0,name:"r1infants",unitLabel:(0,f.getLabelText)("infants","Infants","guests_rooms")}}}]),C=(0,v.ref)(1),k=(0,f.getLabelText)("room","Room","guests_rooms"),L=(0,f.getLabelText)("rooms","Rooms","guests_rooms"),T=(0,v.ref)(!1),V=(0,v.ref)(!1),N=function(){V.value=!1},B=function(){V.value=!V.value},w=function(){if(y.value.length<5){var e={id:"".concat(t.uid),showRemoveBtn:!0,numberGroups:{adults:{minCount:1,maxCount:30,count:1,name:"r"+(y.value.length+1)+"a",unitLabel:(0,f.getLabelText)("adults","Adults","guests_rooms")},children:{minCount:0,maxCount:30,count:0,name:"r"+(y.value.length+1)+"children",unitLabel:(0,f.getLabelText)("children","Children","guests_rooms")},infants:{minCount:0,maxCount:30,count:0,name:"r"+(y.value.length+1)+"infants",unitLabel:(0,f.getLabelText)("infants","Infants","guests_rooms")}}},n=y.value.slice();n.push(e),y.value=n,C.value=n.length,h.value=!0,o.value=o.value+1}},E=function(e,t,n){var l=y.value.findIndex((function(e){return e.id===n}));y.value.splice(l,1),C.value=y.value.length,T.value=!0,o.value=o.value-e,x.value=x.value-t,1===y.value.length&&(h.value=!1)},S=function(e,t,n){o.value="increase"===e?o.value+1:o.value-1,"adults"!==t&&(x.value="increase"===e?x.value+1:x.value-1);var l=y.value.findIndex((function(e){return e.id===n}));y.value[l].numberGroups[t].count="increase"===e?y.value[l].numberGroups[t].count+1:y.value[l].numberGroups[t].count-1};return function(e,t){return(0,a.openBlock)(),(0,a.createElementBlock)("div",u,[(0,a.createElementVNode)("span",s,(0,a.toDisplayString)((0,a.unref)(_)),1),(0,a.createElementVNode)("button",{tabIndex:"availability ? '0' : ''",class:"vs-guest-selector__trigger form-control vs-input",onClick:(0,a.withModifiers)(B,["prevent"]),disabled:!e.availability},[(0,a.createElementVNode)("span",null,(0,a.toDisplayString)(C.value)+" ",1),(0,a.createElementVNode)("span",null,(0,a.toDisplayString)(C.value>1?(0,a.unref)(L):(0,a.unref)(k)),1),t[0]||(t[0]=(0,a.createTextVNode)(",  ")),(0,a.createElementVNode)("span",null,(0,a.toDisplayString)(o.value)+" ",1),(0,a.createElementVNode)("span",null,(0,a.toDisplayString)(o.value>1?(0,a.unref)(_):(0,a.unref)(b)),1)],8,r),(0,a.createElementVNode)("div",{class:(0,a.normalizeClass)(["vs-guest-selector__modal",V.value?"vs-guest-selector__modal--visible":""])},[(0,a.createVNode)(p.default,{class:"align-self-end","data-test":"vs-guest-selector__close-btn",variant:"subtle",icon:"vs-icon-control-dismiss",size:"md","icon-only":"",onClick:(0,a.withModifiers)(N,["prevent"])},{default:(0,a.withCtx)((function(){return[(0,a.createTextVNode)((0,a.toDisplayString)((0,a.unref)(f.getLabelText)("close","Close","guests_rooms")),1)]})),_:1}),(0,a.createElementVNode)("div",i,[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(y.value,(function(e,t){return(0,a.openBlock)(),(0,a.createBlock)(g.default,{key:e.id,name:"r"+(t+1),"show-remove-btn":h.value,"unit-label":(0,a.unref)(f.getLabelText)("room","Room","guests_rooms")+" "+(t+1),"unit-options":e,"unit-removed":T.value,onNumberChange:S,onOnRemove:E},null,8,["name","show-remove-btn","unit-label","unit-options","unit-removed"])})),128))]),(0,a.createElementVNode)("div",c,[y.value.length<5?((0,a.openBlock)(),(0,a.createBlock)(p.default,{key:0,variant:"secondary",class:"c-search__popup__btn-link me-050 align-self-start",onClick:(0,a.withModifiers)(w,["prevent"])},{default:(0,a.withCtx)((function(){return[(0,a.createTextVNode)((0,a.toDisplayString)((0,a.unref)(n)),1)]})),_:1})):(0,a.createCommentVNode)("",!0),y.value.length<5?((0,a.openBlock)(),(0,a.createBlock)(p.default,{key:1,class:"c-search__popup__btn-link c-search__popup__btn-link--pull-right align-self-end",onClick:(0,a.withModifiers)(N,["prevent"])},{default:(0,a.withCtx)((function(){return[(0,a.createTextVNode)((0,a.toDisplayString)((0,a.unref)(l)),1)]})),_:1})):(0,a.createCommentVNode)("",!0)])],2),y.value?((0,a.openBlock)(),(0,a.createElementBlock)("input",{key:0,type:"hidden",name:"rooms",id:"room-count",value:C.value,disabled:!e.availability},null,8,d)):(0,a.createCommentVNode)("",!0),y.value?((0,a.openBlock)(),(0,a.createElementBlock)("input",{key:1,type:"hidden",name:"guests",id:"guest-count",value:o.value,disabled:!e.availability},null,8,m)):(0,a.createCommentVNode)("",!0)])}}})},44596:function(e,t,n){"use strict";var l=n(85072),o=n.n(l),a=n(97825),u=n.n(a),s=n(77659),r=n.n(s),i=n(55056),c=n.n(i),d=n(10540),m=n.n(d),v=n(41113),f=n.n(v),g=n(51590),p=n.n(g),b={};b.styleTagTransform=f(),b.setAttributes=c(),b.insert=r().bind(null,"head"),b.domAPI=u(),b.insertStyleElement=m(),o()(p(),b),p()&&p().locals&&p().locals},51590:function(){}},function(e){return e.O(0,[641,6262,7510,3751,4352,7527,4467,8086,810,4982,6422,8745,8836,378,8896,6216],(function(){return e(e.s=34900)})),e.O()}])}));