@heycater/qualification-funnel 1.19.5 → 1.19.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -595,7 +595,7 @@
595
595
  margin-left: ${e=>e.theme.spacing(2)}px;
596
596
  `,VM=_p(BM)`
597
597
  margin-right: ${e=>e.theme.spacing(2)}px;
598
- `,UM={locales:["en","de"],defaultLocale:"de"},WM=e=>t=>{const n=t=>`${t}_${UM.locales.includes(e)?e:UM.defaultLocale}`;if(t.includes(".")){const[e,r]=t.split(".");return`${e}.${n(r)}`}return n(t)};function HM(){const e=_E();var t;return{localizedFieldAlgolia:WM(e.locale),localizedAttributeName:(t=e.locale,e=>UM.locales.includes(t)?`${e}${CS(t)}`:`${e}${CS(UM.defaultLocale)}`)}}function ZM({questionId:e,suggestions:t,onSelect:n}){const{localizedAttributeName:r}=HM(),o=g.useMemo(()=>t.map(e=>({value:e.value,label:e[r("label")]})),[r,t])||[];return C.jsx(KM,{flexWrap:"wrap",flexDirection:"row",alignItems:"center",justifyContent:"center",id:e,children:o.map((e,t)=>C.jsx(Fm,{onClick:()=>n(e.value),children:C.jsx(YM,{variant:"caption",children:e.label})},`${e.value}::${t}`))})}const KM=_p(Fm)`
598
+ `,UM={locales:["en","de"],defaultLocale:"de"},WM=e=>t=>{const n=t=>{let n;return n="string"==typeof e&&e.startsWith("en")?"en":UM.locales.includes(e)?e:UM.defaultLocale,`${t}_${n}`};if(t.includes(".")){const[e,r]=t.split(".");return`${e}.${n(r)}`}return n(t)};function HM(){const e=_E();var t;return{localizedFieldAlgolia:WM(e.locale),localizedAttributeName:(t=e.locale,e=>(null==t?void 0:t.startsWith("en"))?`${e}En`:UM.locales.includes(t)?`${e}${CS(t)}`:`${e}${CS(UM.defaultLocale)}`)}}function ZM({questionId:e,suggestions:t,onSelect:n}){const{localizedAttributeName:r}=HM(),o=g.useMemo(()=>t.map(e=>({value:e.value,label:e[r("label")]})),[r,t])||[];return C.jsx(KM,{flexWrap:"wrap",flexDirection:"row",alignItems:"center",justifyContent:"center",id:e,children:o.map((e,t)=>C.jsx(Fm,{onClick:()=>n(e.value),children:C.jsx(YM,{variant:"caption",children:e.label})},`${e.value}::${t}`))})}const KM=_p(Fm)`
599
599
  display: flex;
600
600
  gap: ${({theme:e})=>e.spacing(1.5)}px;
601
601
  justify-content: space-around;
@@ -877,7 +877,7 @@
877
877
  ${({theme:e})=>e.breakpoints.up("md")} {
878
878
  max-width: 320px;
879
879
  }
880
- `;function sP(){var e,t;const n=_E(),{answerOf:r,actions:o,state:i}=KO(),{trackAnswer:a}=dj(),s=r("event_date"),l=s?new Date(s):void 0,u=function(e,t){if(h_(2,arguments),!t||"object"!==he(t))return new Date(NaN);var n=t.years?p_(t.years):0,r=t.months?p_(t.months):0,o=t.weeks?p_(t.weeks):0,i=t.days?p_(t.days):0,a=t.hours?p_(t.hours):0,s=t.minutes?p_(t.minutes):0,l=t.seconds?p_(t.seconds):0,u=m_(e),c=r||n?v_(u,r+12*n):u,d=i||o?g_(c,i+7*o):c,f=1e3*(l+60*(s+60*a));return new Date(d.getTime()+f)}(new Date,{days:2}),c="qualification"in i?UL.getAttributes({answers:i.qualification.answers,selectedCaterer:i.qualification.selectedCaterer}):null,d="en"===n.locale?null==(e=null==c?void 0:c.minDate)?void 0:e.messageEn:null==(t=null==c?void 0:c.minDate)?void 0:t.messageDe,[f]=g.useState(!!r(VL.id));g.useEffect(()=>{s&&o.answerQuestion("has_recurring_need",f)},[f]);const[p,h]=g.useState(l||u);return C.jsx(nP,{dateSelector:C.jsxs(pP,{children:[C.jsx(hP,{children:C.jsx(tP,{components:{Caption:uP,Row:cP,Day:lP},formatters:{formatWeekdayName:(e,t)=>TL(e,"EEEEE",{locale:null==t?void 0:t.locale})},month:p,onDayClick:e=>{o.answerQuestion("event_date",e),a("event_date",TL(e,"yyyy-MM-dd"))},selected:l,fromDate:u,onMonthChange:h,captionLayout:"buttons",locale:n.locale?hM[n.locale]:void 0,showOutsideDays:!0,mode:"single"})}),d&&C.jsx(Fm,{textAlign:"center",mt:2,children:C.jsxs(fP,{children:["*",d]})})]}),sideContent:C.jsx(oP,{})})}function lP(e){const{outside:t}=DT(e.date,e.displayMonth),n=$j();return t&&function(e){return h_(1,arguments),1===m_(e).getDate()}(e.date)?C.jsxs(Fm,{position:"relative",children:[C.jsx(Fm,{position:"absolute",top:"-3px",left:"-3px",children:C.jsx(Qm,{fontSize:9,children:TL(e.date,"MMM",{locale:n.locale})})}),C.jsx(qT,{...e})]}):C.jsx(qT,{...e})}function uP(e){const{goToMonth:t,nextMonth:n,previousMonth:r}=Yj(),o=$j();return C.jsxs(Fm,{display:"flex",justifyContent:"space-between",alignItems:"center",py:1.5,children:[C.jsx(dP,{id:"datepicker__prev-month",type:"button",disabled:!r,onClick:()=>r&&t(r),children:C.jsx(Qj,{})}),C.jsx(Qm,{fontSize:15,fontWeight:600,children:TL(e.displayMonth,"MMMM yyyy",{locale:o.locale})}),C.jsx(dP,{id:"datepicker__next-month",type:"button",disabled:!n,onClick:()=>n&&t(n),children:C.jsx(Jj,{})})]})}function cP(e){const t=new Date;if(FL(t,e.displayMonth)){const n=RL(e.displayMonth),r=RL(t)-n,o=e.dates.map(e=>__(e,r));return o.some(t=>FL(t,e.displayMonth))?C.jsx(UT,{...e,weekNumber:e.weekNumber+r,dates:o}):C.jsx(C.Fragment,{})}return C.jsx(UT,{...e})}const dP=_p.button`
880
+ `;function sP(){var e,t,n;const r=_E(),{answerOf:o,actions:i,state:a}=KO(),{trackAnswer:s}=dj(),l=o("event_date"),u=l?new Date(l):void 0,c=function(e,t){if(h_(2,arguments),!t||"object"!==he(t))return new Date(NaN);var n=t.years?p_(t.years):0,r=t.months?p_(t.months):0,o=t.weeks?p_(t.weeks):0,i=t.days?p_(t.days):0,a=t.hours?p_(t.hours):0,s=t.minutes?p_(t.minutes):0,l=t.seconds?p_(t.seconds):0,u=m_(e),c=r||n?v_(u,r+12*n):u,d=i||o?g_(c,i+7*o):c,f=1e3*(l+60*(s+60*a));return new Date(d.getTime()+f)}(new Date,{days:2}),d="qualification"in a?UL.getAttributes({answers:a.qualification.answers,selectedCaterer:a.qualification.selectedCaterer}):null,f=(null==(e=r.locale)?void 0:e.startsWith("en"))?null==(t=null==d?void 0:d.minDate)?void 0:t.messageEn:null==(n=null==d?void 0:d.minDate)?void 0:n.messageDe,[p]=g.useState(!!o(VL.id));g.useEffect(()=>{l&&i.answerQuestion("has_recurring_need",p)},[p]);const[h,m]=g.useState(u||c);return C.jsx(nP,{dateSelector:C.jsxs(pP,{children:[C.jsx(hP,{children:C.jsx(tP,{components:{Caption:uP,Row:cP,Day:lP},formatters:{formatWeekdayName:(e,t)=>TL(e,"EEEEE",{locale:null==t?void 0:t.locale})},month:h,onDayClick:e=>{i.answerQuestion("event_date",e),s("event_date",TL(e,"yyyy-MM-dd"))},selected:u,fromDate:c,onMonthChange:m,captionLayout:"buttons",locale:r.locale?hM[r.locale]:void 0,showOutsideDays:!0,mode:"single"})}),f&&C.jsx(Fm,{textAlign:"center",mt:2,children:C.jsxs(fP,{children:["*",f]})})]}),sideContent:C.jsx(oP,{})})}function lP(e){const{outside:t}=DT(e.date,e.displayMonth),n=$j();return t&&function(e){return h_(1,arguments),1===m_(e).getDate()}(e.date)?C.jsxs(Fm,{position:"relative",children:[C.jsx(Fm,{position:"absolute",top:"-3px",left:"-3px",children:C.jsx(Qm,{fontSize:9,children:TL(e.date,"MMM",{locale:n.locale})})}),C.jsx(qT,{...e})]}):C.jsx(qT,{...e})}function uP(e){const{goToMonth:t,nextMonth:n,previousMonth:r}=Yj(),o=$j();return C.jsxs(Fm,{display:"flex",justifyContent:"space-between",alignItems:"center",py:1.5,children:[C.jsx(dP,{id:"datepicker__prev-month",type:"button",disabled:!r,onClick:()=>r&&t(r),children:C.jsx(Qj,{})}),C.jsx(Qm,{fontSize:15,fontWeight:600,children:TL(e.displayMonth,"MMMM yyyy",{locale:o.locale})}),C.jsx(dP,{id:"datepicker__next-month",type:"button",disabled:!n,onClick:()=>n&&t(n),children:C.jsx(Jj,{})})]})}function cP(e){const t=new Date;if(FL(t,e.displayMonth)){const n=RL(e.displayMonth),r=RL(t)-n,o=e.dates.map(e=>__(e,r));return o.some(t=>FL(t,e.displayMonth))?C.jsx(UT,{...e,weekNumber:e.weekNumber+r,dates:o}):C.jsx(C.Fragment,{})}return C.jsx(UT,{...e})}const dP=_p.button`
881
881
  background-color: transparent;
882
882
  border: none;
883
883
  cursor: pointer;
package/dist/index.cjs.js CHANGED
@@ -444,7 +444,7 @@
444
444
  margin-left: ${e=>e.theme.spacing(2)}px;
445
445
  `,gp=o(hp)`
446
446
  margin-right: ${e=>e.theme.spacing(2)}px;
447
- `,yp={locales:["en","de"],defaultLocale:"de"},vp=e=>t=>{const n=t=>`${t}_${yp.locales.includes(e)?e:yp.defaultLocale}`;if(t.includes(".")){const[e,r]=t.split(".");return`${e}.${n(r)}`}return n(t)};function bp(){const e=du();var t;return{localizedFieldAlgolia:vp(e.locale),localizedAttributeName:(t=e.locale,e=>yp.locales.includes(t)?`${e}${Rl(t)}`:`${e}${Rl(yp.defaultLocale)}`)}}function Cp({questionId:e,suggestions:r,onSelect:i}){const{localizedAttributeName:o}=bp(),a=n.useMemo(()=>r.map(e=>({value:e.value,label:e[o("label")]})),[o,r])||[];return t.jsx(xp,{flexWrap:"wrap",flexDirection:"row",alignItems:"center",justifyContent:"center",id:e,children:a.map((e,n)=>t.jsx(v,{onClick:()=>i(e.value),children:t.jsx(wp,{variant:"caption",children:e.label})},`${e.value}::${n}`))})}const xp=o(v)`
447
+ `,yp={locales:["en","de"],defaultLocale:"de"},vp=e=>t=>{const n=t=>{let n;return n="string"==typeof e&&e.startsWith("en")?"en":yp.locales.includes(e)?e:yp.defaultLocale,`${t}_${n}`};if(t.includes(".")){const[e,r]=t.split(".");return`${e}.${n(r)}`}return n(t)};function bp(){const e=du();var t;return{localizedFieldAlgolia:vp(e.locale),localizedAttributeName:(t=e.locale,e=>(null==t?void 0:t.startsWith("en"))?`${e}En`:yp.locales.includes(t)?`${e}${Rl(t)}`:`${e}${Rl(yp.defaultLocale)}`)}}function Cp({questionId:e,suggestions:r,onSelect:i}){const{localizedAttributeName:o}=bp(),a=n.useMemo(()=>r.map(e=>({value:e.value,label:e[o("label")]})),[o,r])||[];return t.jsx(xp,{flexWrap:"wrap",flexDirection:"row",alignItems:"center",justifyContent:"center",id:e,children:a.map((e,n)=>t.jsx(v,{onClick:()=>i(e.value),children:t.jsx(wp,{variant:"caption",children:e.label})},`${e.value}::${n}`))})}const xp=o(v)`
448
448
  display: flex;
449
449
  gap: ${({theme:e})=>e.spacing(1.5)}px;
450
450
  justify-content: space-around;
@@ -726,7 +726,7 @@
726
726
  ${({theme:e})=>e.breakpoints.up("md")} {
727
727
  max-width: 320px;
728
728
  }
729
- `;function lh(){var e,r;const i=du(),{answerOf:o,actions:a,state:s}=xf(),{trackAnswer:l}=$p(),c=o("event_date"),d=c?new Date(c):void 0,f=rc(new Date,{days:2}),p="qualification"in s?gd.getAttributes({answers:s.qualification.answers,selectedCaterer:s.qualification.selectedCaterer}):null,h="en"===i.locale?null==(e=null==p?void 0:p.minDate)?void 0:e.messageEn:null==(r=null==p?void 0:p.minDate)?void 0:r.messageDe,[m]=n.useState(!!o(md.id));n.useEffect(()=>{c&&a.answerQuestion("has_recurring_need",m)},[m]);const[g,y]=n.useState(d||f);return t.jsx(rh,{dateSelector:t.jsxs(hh,{children:[t.jsx(mh,{children:t.jsx(u.DayPicker,{components:{Caption:ch,Row:dh,Day:uh},formatters:{formatWeekdayName:(e,t)=>rd(e,"EEEEE",{locale:null==t?void 0:t.locale})},month:g,onDayClick:e=>{a.answerQuestion("event_date",e),l("event_date",rd(e,"yyyy-MM-dd"))},selected:d,fromDate:f,onMonthChange:y,captionLayout:"buttons",locale:i.locale?qf[i.locale]:void 0,showOutsideDays:!0,mode:"single"})}),h&&t.jsx(v,{textAlign:"center",mt:2,children:t.jsxs(ph,{children:["*",h]})})]}),sideContent:t.jsx(oh,{})})}function uh(e){const{outside:n}=u.useActiveModifiers(e.date,e.displayMonth),r=u.useDayPicker();return n&&function(e){return ec(1,arguments),1===tc(e).getDate()}(e.date)?t.jsxs(v,{position:"relative",children:[t.jsx(v,{position:"absolute",top:"-3px",left:"-3px",children:t.jsx(D,{fontSize:9,children:rd(e.date,"MMM",{locale:r.locale})})}),t.jsx(u.Day,{...e})]}):t.jsx(u.Day,{...e})}function ch(e){const{goToMonth:n,nextMonth:r,previousMonth:i}=u.useNavigation(),o=u.useDayPicker();return t.jsxs(v,{display:"flex",justifyContent:"space-between",alignItems:"center",py:1.5,children:[t.jsx(fh,{id:"datepicker__prev-month",type:"button",disabled:!i,onClick:()=>i&&n(i),children:t.jsx(u.IconLeft,{})}),t.jsx(D,{fontSize:15,fontWeight:600,children:rd(e.displayMonth,"MMMM yyyy",{locale:o.locale})}),t.jsx(fh,{id:"datepicker__next-month",type:"button",disabled:!r,onClick:()=>r&&n(r),children:t.jsx(u.IconRight,{})})]})}function dh(e){const n=new Date;if(pd(n,e.displayMonth)){const r=od(e.displayMonth),i=od(n)-r,o=e.dates.map(e=>function(e,t){return ec(2,arguments),nc(e,7*Xu(t))}(e,i));return o.some(t=>pd(t,e.displayMonth))?t.jsx(u.Row,{...e,weekNumber:e.weekNumber+i,dates:o}):t.jsx(t.Fragment,{})}return t.jsx(u.Row,{...e})}const fh=o.button`
729
+ `;function lh(){var e,r,i;const o=du(),{answerOf:a,actions:s,state:l}=xf(),{trackAnswer:c}=$p(),d=a("event_date"),f=d?new Date(d):void 0,p=rc(new Date,{days:2}),h="qualification"in l?gd.getAttributes({answers:l.qualification.answers,selectedCaterer:l.qualification.selectedCaterer}):null,m=(null==(e=o.locale)?void 0:e.startsWith("en"))?null==(r=null==h?void 0:h.minDate)?void 0:r.messageEn:null==(i=null==h?void 0:h.minDate)?void 0:i.messageDe,[g]=n.useState(!!a(md.id));n.useEffect(()=>{d&&s.answerQuestion("has_recurring_need",g)},[g]);const[y,b]=n.useState(f||p);return t.jsx(rh,{dateSelector:t.jsxs(hh,{children:[t.jsx(mh,{children:t.jsx(u.DayPicker,{components:{Caption:ch,Row:dh,Day:uh},formatters:{formatWeekdayName:(e,t)=>rd(e,"EEEEE",{locale:null==t?void 0:t.locale})},month:y,onDayClick:e=>{s.answerQuestion("event_date",e),c("event_date",rd(e,"yyyy-MM-dd"))},selected:f,fromDate:p,onMonthChange:b,captionLayout:"buttons",locale:o.locale?qf[o.locale]:void 0,showOutsideDays:!0,mode:"single"})}),m&&t.jsx(v,{textAlign:"center",mt:2,children:t.jsxs(ph,{children:["*",m]})})]}),sideContent:t.jsx(oh,{})})}function uh(e){const{outside:n}=u.useActiveModifiers(e.date,e.displayMonth),r=u.useDayPicker();return n&&function(e){return ec(1,arguments),1===tc(e).getDate()}(e.date)?t.jsxs(v,{position:"relative",children:[t.jsx(v,{position:"absolute",top:"-3px",left:"-3px",children:t.jsx(D,{fontSize:9,children:rd(e.date,"MMM",{locale:r.locale})})}),t.jsx(u.Day,{...e})]}):t.jsx(u.Day,{...e})}function ch(e){const{goToMonth:n,nextMonth:r,previousMonth:i}=u.useNavigation(),o=u.useDayPicker();return t.jsxs(v,{display:"flex",justifyContent:"space-between",alignItems:"center",py:1.5,children:[t.jsx(fh,{id:"datepicker__prev-month",type:"button",disabled:!i,onClick:()=>i&&n(i),children:t.jsx(u.IconLeft,{})}),t.jsx(D,{fontSize:15,fontWeight:600,children:rd(e.displayMonth,"MMMM yyyy",{locale:o.locale})}),t.jsx(fh,{id:"datepicker__next-month",type:"button",disabled:!r,onClick:()=>r&&n(r),children:t.jsx(u.IconRight,{})})]})}function dh(e){const n=new Date;if(pd(n,e.displayMonth)){const r=od(e.displayMonth),i=od(n)-r,o=e.dates.map(e=>function(e,t){return ec(2,arguments),nc(e,7*Xu(t))}(e,i));return o.some(t=>pd(t,e.displayMonth))?t.jsx(u.Row,{...e,weekNumber:e.weekNumber+i,dates:o}):t.jsx(t.Fragment,{})}return t.jsx(u.Row,{...e})}const fh=o.button`
730
730
  background-color: transparent;
731
731
  border: none;
732
732
  cursor: pointer;
package/dist/index.esm.js CHANGED
@@ -9886,9 +9886,14 @@ const localeConfig = {
9886
9886
  };
9887
9887
  const algoliaAttributeNameForLocale = (locale2) => (name) => {
9888
9888
  const toLocalizedAlgoliaKey = (name2) => {
9889
- const parsedLocale = localeConfig.locales.includes(
9890
- locale2
9891
- ) ? locale2 : localeConfig.defaultLocale;
9889
+ let parsedLocale;
9890
+ if (typeof locale2 === "string" && locale2.startsWith("en")) {
9891
+ parsedLocale = "en";
9892
+ } else if (localeConfig.locales.includes(locale2)) {
9893
+ parsedLocale = locale2;
9894
+ } else {
9895
+ parsedLocale = localeConfig.defaultLocale;
9896
+ }
9892
9897
  return `${name2}_${parsedLocale}`;
9893
9898
  };
9894
9899
  if (name.includes(".")) {
@@ -9898,6 +9903,9 @@ const algoliaAttributeNameForLocale = (locale2) => (name) => {
9898
9903
  return toLocalizedAlgoliaKey(name);
9899
9904
  };
9900
9905
  const attributeNameForLocale = (locale2) => (name) => {
9906
+ if (locale2 == null ? void 0 : locale2.startsWith("en")) {
9907
+ return `${name}En`;
9908
+ }
9901
9909
  if (!localeConfig.locales.includes(locale2))
9902
9910
  return `${name}${capitalize$3(localeConfig.defaultLocale)}`;
9903
9911
  return `${name}${capitalize$3(locale2)}`;
@@ -10849,7 +10857,7 @@ const SwitchesWrapper = styled.div`
10849
10857
  `;
10850
10858
  const defaultLeadTimeInDays = DEFAULT_LEAD_DAYS;
10851
10859
  function DatePickerEmbedded() {
10852
- var _a2, _b;
10860
+ var _a2, _b, _c;
10853
10861
  const router = useRouter();
10854
10862
  const { answerOf, actions, state } = useQualification();
10855
10863
  const { trackAnswer } = useTracking();
@@ -10863,7 +10871,7 @@ function DatePickerEmbedded() {
10863
10871
  answers: state.qualification.answers,
10864
10872
  selectedCaterer: state.qualification.selectedCaterer
10865
10873
  }) : null;
10866
- const minDateMessage = router.locale === "en" ? (_a2 = attributes == null ? void 0 : attributes.minDate) == null ? void 0 : _a2.messageEn : (_b = attributes == null ? void 0 : attributes.minDate) == null ? void 0 : _b.messageDe;
10874
+ const minDateMessage = ((_a2 = router.locale) == null ? void 0 : _a2.startsWith("en")) ? (_b = attributes == null ? void 0 : attributes.minDate) == null ? void 0 : _b.messageEn : (_c = attributes == null ? void 0 : attributes.minDate) == null ? void 0 : _c.messageDe;
10867
10875
  const [isRecurringNeedSelected] = useState(
10868
10876
  !!answerOf(isRecurringQuestion.id)
10869
10877
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycater/qualification-funnel",
3
- "version": "1.19.5",
3
+ "version": "1.19.7",
4
4
  "type": "module",
5
5
  "description": "Heycater embedded qualification funnel widget",
6
6
  "main": "dist/index.cjs.js",