@mhmo91/schmancy 0.2.111 → 0.2.113
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.
- package/dist/{animated-text-CrZbI_E_.cjs → animated-text-B576YswO.cjs} +2 -2
- package/dist/{animated-text-CrZbI_E_.cjs.map → animated-text-B576YswO.cjs.map} +1 -1
- package/dist/{animated-text-CmvbdVJF.js → animated-text-BuRbVM-X.js} +3 -3
- package/dist/{animated-text-CmvbdVJF.js.map → animated-text-BuRbVM-X.js.map} +1 -1
- package/dist/animated-text.cjs +1 -1
- package/dist/animated-text.js +1 -1
- package/dist/area.cjs +1 -1
- package/dist/area.component-BFj0Dvfb.cjs +8 -0
- package/dist/area.component-BFj0Dvfb.cjs.map +1 -0
- package/dist/area.component-Bo5aB8BH.js +107 -0
- package/dist/area.component-Bo5aB8BH.js.map +1 -0
- package/dist/area.js +1 -1
- package/dist/{autocomplete-Bsx63fvs.cjs → autocomplete-Du2Jw0a2.cjs} +2 -2
- package/dist/{autocomplete-Bsx63fvs.cjs.map → autocomplete-Du2Jw0a2.cjs.map} +1 -1
- package/dist/{autocomplete-C7d1TghO.js → autocomplete-NL-c1Qp-.js} +3 -3
- package/dist/{autocomplete-C7d1TghO.js.map → autocomplete-NL-c1Qp-.js.map} +1 -1
- package/dist/autocomplete.cjs +1 -1
- package/dist/autocomplete.js +1 -1
- package/dist/busy.cjs +1 -1
- package/dist/busy.js +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/{checkbox-Ddc3Nogy.js → checkbox-DQYRlKod.js} +2 -2
- package/dist/{checkbox-Ddc3Nogy.js.map → checkbox-DQYRlKod.js.map} +1 -1
- package/dist/{checkbox-D5Zw8R82.cjs → checkbox-FM06WS9G.cjs} +2 -2
- package/dist/{checkbox-D5Zw8R82.cjs.map → checkbox-FM06WS9G.cjs.map} +1 -1
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/{chips-D5ADFFCU.cjs → chips-CJZbtp-O.cjs} +2 -2
- package/dist/{chips-D5ADFFCU.cjs.map → chips-CJZbtp-O.cjs.map} +1 -1
- package/dist/{chips-Bm_VYwr5.js → chips-Ctk7cxHI.js} +3 -3
- package/dist/{chips-Bm_VYwr5.js.map → chips-Ctk7cxHI.js.map} +1 -1
- package/dist/chips.cjs +1 -1
- package/dist/chips.js +1 -1
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/content-drawer.cjs +1 -1
- package/dist/content-drawer.js +1 -1
- package/dist/date-range-CZiZR3OZ.js +447 -0
- package/dist/date-range-CZiZR3OZ.js.map +1 -0
- package/dist/date-range-FxAO_oqk.cjs +79 -0
- package/dist/date-range-FxAO_oqk.cjs.map +1 -0
- package/dist/date-range.cjs +1 -1
- package/dist/date-range.js +1 -1
- package/dist/{delay-DSBPkKzK.cjs → delay-NkgyZVcO.cjs} +2 -2
- package/dist/{delay-DSBPkKzK.cjs.map → delay-NkgyZVcO.cjs.map} +1 -1
- package/dist/{delay-Nnqipc2p.js → delay-gZOjfjX_.js} +2 -2
- package/dist/{delay-Nnqipc2p.js.map → delay-gZOjfjX_.js.map} +1 -1
- package/dist/delay.cjs +1 -1
- package/dist/delay.js +1 -1
- package/dist/{divider-C7JP4sSG.js → divider-B-JF8gre.js} +3 -3
- package/dist/{divider-C7JP4sSG.js.map → divider-B-JF8gre.js.map} +1 -1
- package/dist/{divider-CcTSaeAl.cjs → divider-nNk0E_jZ.cjs} +2 -2
- package/dist/{divider-CcTSaeAl.cjs.map → divider-nNk0E_jZ.cjs.map} +1 -1
- package/dist/divider.cjs +1 -1
- package/dist/divider.js +1 -1
- package/dist/{flex-P9rZBgGQ.js → flex-CieqpOUS.js} +2 -2
- package/dist/{flex-P9rZBgGQ.js.map → flex-CieqpOUS.js.map} +1 -1
- package/dist/{flex-B_mVCq18.cjs → flex-INEcbqBe.cjs} +2 -2
- package/dist/{flex-B_mVCq18.cjs.map → flex-INEcbqBe.cjs.map} +1 -1
- package/dist/{form-cxzC6GVM.cjs → form-CKMp4UzU.cjs} +2 -2
- package/dist/{form-cxzC6GVM.cjs.map → form-CKMp4UzU.cjs.map} +1 -1
- package/dist/{form-DPcVlChy.js → form-lcamXnkd.js} +2 -2
- package/dist/{form-DPcVlChy.js.map → form-lcamXnkd.js.map} +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.js +1 -1
- package/dist/{icon-BEKKW3-2.cjs → icon-BZqH7sp7.cjs} +2 -2
- package/dist/{icon-BEKKW3-2.cjs.map → icon-BZqH7sp7.cjs.map} +1 -1
- package/dist/{icon-BGWDEYcH.js → icon-CJrmUGTm.js} +3 -3
- package/dist/{icon-BGWDEYcH.js.map → icon-CJrmUGTm.js.map} +1 -1
- package/dist/{icon-button-DlC2-vLK.js → icon-button-BNn0qRfC.js} +3 -3
- package/dist/{icon-button-DlC2-vLK.js.map → icon-button-BNn0qRfC.js.map} +1 -1
- package/dist/{icon-button-ChOGnclR.cjs → icon-button-nMHz4MDw.cjs} +2 -2
- package/dist/{icon-button-ChOGnclR.cjs.map → icon-button-nMHz4MDw.cjs.map} +1 -1
- package/dist/icons.cjs +1 -1
- package/dist/icons.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +33 -33
- package/dist/{input-C7C9t_rb.cjs → input-CszLZ81k.cjs} +2 -2
- package/dist/{input-C7C9t_rb.cjs.map → input-CszLZ81k.cjs.map} +1 -1
- package/dist/{input-CIRYUKIL.js → input-CwWLOBMF.js} +2 -2
- package/dist/{input-CIRYUKIL.js.map → input-CwWLOBMF.js.map} +1 -1
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.js +1 -1
- package/dist/{list-Bzx4a2RJ.js → list-CjrF4M5H.js} +2 -2
- package/dist/{list-Bzx4a2RJ.js.map → list-CjrF4M5H.js.map} +1 -1
- package/dist/{list-D1kS-XDO.cjs → list-D4y-Mkap.cjs} +2 -2
- package/dist/{list-D1kS-XDO.cjs.map → list-D4y-Mkap.cjs.map} +1 -1
- package/dist/list.cjs +1 -1
- package/dist/list.js +1 -1
- package/dist/{litElement.mixin-Dx9_p_nV.js → litElement.mixin-NzkxESus.js} +2 -2
- package/dist/{litElement.mixin-Dx9_p_nV.js.map → litElement.mixin-NzkxESus.js.map} +1 -1
- package/dist/{litElement.mixin-PVEJyATw.cjs → litElement.mixin-djlKJ0lX.cjs} +2 -2
- package/dist/{litElement.mixin-PVEJyATw.cjs.map → litElement.mixin-djlKJ0lX.cjs.map} +1 -1
- package/dist/{menu-CzcGpZXF.js → menu-Cb5kUAvU.js} +3 -3
- package/dist/{menu-CzcGpZXF.js.map → menu-Cb5kUAvU.js.map} +1 -1
- package/dist/{menu-D30w9YPg.cjs → menu-DAtFS31a.cjs} +2 -2
- package/dist/{menu-D30w9YPg.cjs.map → menu-DAtFS31a.cjs.map} +1 -1
- package/dist/menu.cjs +1 -1
- package/dist/menu.js +1 -1
- package/dist/nav-drawer.cjs +1 -1
- package/dist/nav-drawer.js +1 -1
- package/dist/notification.cjs +1 -1
- package/dist/notification.js +1 -1
- package/dist/{option-x_W6-_iT.cjs → option-0le6-QeS.cjs} +2 -2
- package/dist/{option-x_W6-_iT.cjs.map → option-0le6-QeS.cjs.map} +1 -1
- package/dist/{option-igpxXgTd.js → option-_1gW48HB.js} +2 -2
- package/dist/{option-igpxXgTd.js.map → option-_1gW48HB.js.map} +1 -1
- package/dist/option.cjs +1 -1
- package/dist/option.js +1 -1
- package/dist/{outlet-DzAi4iKo.js → outlet-6HZp4fo1.js} +3 -3
- package/dist/outlet-6HZp4fo1.js.map +1 -0
- package/dist/{outlet-DqRiezsh.cjs → outlet-DofHDlGH.cjs} +3 -3
- package/dist/outlet-DofHDlGH.cjs.map +1 -0
- package/dist/{payment-card-form-IamvKqiN.cjs → payment-card-form-Bi3yNg4b.cjs} +2 -2
- package/dist/{payment-card-form-IamvKqiN.cjs.map → payment-card-form-Bi3yNg4b.cjs.map} +1 -1
- package/dist/{payment-card-form-CwqKB8Tm.js → payment-card-form-C8FxRlh4.js} +3 -3
- package/dist/{payment-card-form-CwqKB8Tm.js.map → payment-card-form-C8FxRlh4.js.map} +1 -1
- package/dist/{radio-group-zGJIFNCR.cjs → radio-group-A5QxSGOr.cjs} +2 -2
- package/dist/{radio-group-zGJIFNCR.cjs.map → radio-group-A5QxSGOr.cjs.map} +1 -1
- package/dist/{radio-group-C9UaGgCL.js → radio-group-BapuNl8y.js} +2 -2
- package/dist/{radio-group-C9UaGgCL.js.map → radio-group-BapuNl8y.js.map} +1 -1
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.js +1 -1
- package/dist/{select-5ob4WHTf.js → select-8AjN6LbM.js} +3 -3
- package/dist/{select-5ob4WHTf.js.map → select-8AjN6LbM.js.map} +1 -1
- package/dist/{select-B194j_5a.cjs → select-BdU6KcPX.cjs} +2 -2
- package/dist/{select-B194j_5a.cjs.map → select-BdU6KcPX.cjs.map} +1 -1
- package/dist/select.cjs +1 -1
- package/dist/select.js +1 -1
- package/dist/{sheet-CHFHgh29.cjs → sheet-CQFdHSwJ.cjs} +6 -6
- package/dist/sheet-CQFdHSwJ.cjs.map +1 -0
- package/dist/{sheet-C2RxblaX.js → sheet-xR13xD2A.js} +11 -11
- package/dist/sheet-xR13xD2A.js.map +1 -0
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.js +1 -1
- package/dist/{slider-BgNoOOeQ.cjs → slider-B4OCBlQg.cjs} +2 -2
- package/dist/{slider-BgNoOOeQ.cjs.map → slider-B4OCBlQg.cjs.map} +1 -1
- package/dist/{slider-BOTY8Lhv.js → slider-BakU-Bdw.js} +3 -3
- package/dist/{slider-BOTY8Lhv.js.map → slider-BakU-Bdw.js.map} +1 -1
- package/dist/slider.cjs +1 -1
- package/dist/slider.js +1 -1
- package/dist/{spinner-Vwv-mKip.js → spinner-BDx3SZsl.js} +4 -4
- package/dist/spinner-BDx3SZsl.js.map +1 -0
- package/dist/{spinner-vBTOD2N0.cjs → spinner-C3VJtLgk.cjs} +3 -3
- package/dist/spinner-C3VJtLgk.cjs.map +1 -0
- package/dist/{surface-CryISDFd.js → surface-YiaJJQ5m.js} +2 -2
- package/dist/{surface-CryISDFd.js.map → surface-YiaJJQ5m.js.map} +1 -1
- package/dist/{surface-Csc8YLks.cjs → surface-kjOrb8TO.cjs} +2 -2
- package/dist/{surface-Csc8YLks.cjs.map → surface-kjOrb8TO.cjs.map} +1 -1
- package/dist/surface.cjs +1 -1
- package/dist/surface.js +1 -1
- package/dist/{table-DHHo5etf.cjs → table-BZV2dBD5.cjs} +2 -2
- package/dist/{table-DHHo5etf.cjs.map → table-BZV2dBD5.cjs.map} +1 -1
- package/dist/{table-DRL3oAjo.js → table-BguYeeBH.js} +2 -2
- package/dist/{table-DRL3oAjo.js.map → table-BguYeeBH.js.map} +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.js +1 -1
- package/dist/{tabs-group-BRVzKIRX.cjs → tabs-group-BZFBZ1_G.cjs} +2 -2
- package/dist/{tabs-group-BRVzKIRX.cjs.map → tabs-group-BZFBZ1_G.cjs.map} +1 -1
- package/dist/{tabs-group-BcXgpxUw.js → tabs-group-H3C6ZnQn.js} +2 -2
- package/dist/{tabs-group-BcXgpxUw.js.map → tabs-group-H3C6ZnQn.js.map} +1 -1
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/{tailwind.mixin-BM-bjRjT.cjs → tailwind.mixin-CBhPue3q.cjs} +2 -2
- package/dist/{tailwind.mixin-BM-bjRjT.cjs.map → tailwind.mixin-CBhPue3q.cjs.map} +1 -1
- package/dist/{tailwind.mixin-YEy_iITN.js → tailwind.mixin-DklgfhB4.js} +2 -2
- package/dist/{tailwind.mixin-YEy_iITN.js.map → tailwind.mixin-DklgfhB4.js.map} +1 -1
- package/dist/teleport.cjs +1 -1
- package/dist/{teleport.component-Bv5uSZu2.cjs → teleport.component-CF-USarR.cjs} +2 -2
- package/dist/{teleport.component-Bv5uSZu2.cjs.map → teleport.component-CF-USarR.cjs.map} +1 -1
- package/dist/{teleport.component-CNo2XXL6.js → teleport.component-D8DXijGl.js} +35 -35
- package/dist/{teleport.component-CNo2XXL6.js.map → teleport.component-D8DXijGl.js.map} +1 -1
- package/dist/teleport.js +1 -1
- package/dist/{textarea-CUi2u7J7.cjs → textarea-BCWPb0Sn.cjs} +2 -2
- package/dist/{textarea-CUi2u7J7.cjs.map → textarea-BCWPb0Sn.cjs.map} +1 -1
- package/dist/{textarea-BzI6HMKy.js → textarea-D7bTMerW.js} +2 -2
- package/dist/{textarea-BzI6HMKy.js.map → textarea-D7bTMerW.js.map} +1 -1
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +1 -1
- package/dist/{theme-button-DhD5GksO.js → theme-button-CP2_aq__.js} +2 -2
- package/dist/{theme-button-DhD5GksO.js.map → theme-button-CP2_aq__.js.map} +1 -1
- package/dist/{theme-button-BJe1x0Cs.cjs → theme-button-DHuXg7vh.cjs} +2 -2
- package/dist/{theme-button-BJe1x0Cs.cjs.map → theme-button-DHuXg7vh.cjs.map} +1 -1
- package/dist/theme-button.cjs +1 -1
- package/dist/theme-button.js +1 -1
- package/dist/theme.cjs +1 -1
- package/dist/{theme.component-D4WBav-_.js → theme.component-BtBosXb1.js} +2 -2
- package/dist/{theme.component-D4WBav-_.js.map → theme.component-BtBosXb1.js.map} +1 -1
- package/dist/{theme.component-BI2OGjYG.cjs → theme.component-Ly2C_fQ8.cjs} +2 -2
- package/dist/{theme.component-BI2OGjYG.cjs.map → theme.component-Ly2C_fQ8.cjs.map} +1 -1
- package/dist/theme.js +1 -1
- package/dist/{tree-8ORo7bDg.cjs → tree-CG9B3uQP.cjs} +2 -2
- package/dist/{tree-8ORo7bDg.cjs.map → tree-CG9B3uQP.cjs.map} +1 -1
- package/dist/{tree-D42tswgB.js → tree-Y2B7yK7L.js} +2 -2
- package/dist/{tree-D42tswgB.js.map → tree-Y2B7yK7L.js.map} +1 -1
- package/dist/tree.cjs +1 -1
- package/dist/tree.js +1 -1
- package/dist/{typewriter-JuHIja1a.cjs → typewriter-CzV1O28F.cjs} +2 -2
- package/dist/{typewriter-JuHIja1a.cjs.map → typewriter-CzV1O28F.cjs.map} +1 -1
- package/dist/{typewriter-BwNXbsZp.js → typewriter-bnkFoDFz.js} +4 -4
- package/dist/{typewriter-BwNXbsZp.js.map → typewriter-bnkFoDFz.js.map} +1 -1
- package/dist/typewriter.cjs +1 -1
- package/dist/typewriter.js +1 -1
- package/dist/{typography-CaOb3D3z.js → typography-CSQByhJF.js} +2 -2
- package/dist/{typography-CaOb3D3z.js.map → typography-CSQByhJF.js.map} +1 -1
- package/dist/{typography-BMkQ3cH-.cjs → typography-D-a-z23R.cjs} +2 -2
- package/dist/{typography-BMkQ3cH-.cjs.map → typography-D-a-z23R.cjs.map} +1 -1
- package/dist/typography.cjs +1 -1
- package/dist/typography.js +1 -1
- package/package.json +2 -2
- package/types/src/area/area.component.d.ts +5 -74
- package/types/src/date-range/date-range.d.ts +2 -2
- package/dist/area.component-BmSDlykT.cjs +0 -8
- package/dist/area.component-BmSDlykT.cjs.map +0 -1
- package/dist/area.component-D99_ptNx.js +0 -119
- package/dist/area.component-D99_ptNx.js.map +0 -1
- package/dist/date-range-CH-IKoMW.cjs +0 -72
- package/dist/date-range-CH-IKoMW.cjs.map +0 -1
- package/dist/date-range-LMnnBclq.js +0 -166
- package/dist/date-range-LMnnBclq.js.map +0 -1
- package/dist/outlet-DqRiezsh.cjs.map +0 -1
- package/dist/outlet-DzAi4iKo.js.map +0 -1
- package/dist/sheet-C2RxblaX.js.map +0 -1
- package/dist/sheet-CHFHgh29.cjs.map +0 -1
- package/dist/spinner-Vwv-mKip.js.map +0 -1
- package/dist/spinner-vBTOD2N0.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import SchmancyMenu from '@schmancy/menu/menu';
|
|
2
|
-
import
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
3
|
declare const SchmancyDateRange_base: CustomElementConstructor & import("@mixins/index").Constructor<import("lit").LitElement> & import("@mixins/index").Constructor<import("@mixins/index").IBaseMixin>;
|
|
4
4
|
/**
|
|
5
5
|
* A date range selector that supports presets and manual date input.
|
|
@@ -26,7 +26,7 @@ export default class SchmancyDateRange extends SchmancyDateRange_base {
|
|
|
26
26
|
dateFrom: string;
|
|
27
27
|
dateTo: string;
|
|
28
28
|
};
|
|
29
|
-
step:
|
|
29
|
+
step: dayjs.OpUnitType;
|
|
30
30
|
}>;
|
|
31
31
|
connectedCallback(): void;
|
|
32
32
|
/**
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("rxjs");require("lit/directives/class-map.js"),require("lit/directives/style-map.js");const y=require("./litElement.mixin-PVEJyATw.cjs");require("./tailwind.mixin-BM-bjRjT.cjs");const l=require("lit"),c=require("lit/decorators.js"),g=require("./index-DyJ0oDpR.cjs"),S=new e.Subject,d="FINDING_MORTIES",f="HERE_RICKY";class p{constructor(){this.prettyURL=!1,this.mode="HISTORY",this.request=new e.ReplaySubject(1),this.current=new Map,this.$current=new e.ReplaySubject(1),this.enableHistoryMode=!0,this.findingMortiesEvent=new CustomEvent(d),this.$current.next(this.current)}find(){return e.zip([e.fromEvent(window,f).pipe(e.map(t=>t.detail),e.bufferTime(0),e.tap(console.log)),e.of(1).pipe(e.tap(()=>window.dispatchEvent(this.findingMortiesEvent)))]).pipe(e.map(([t])=>t),e.timeout(1))}push(t){this.request.next(t)}pop(t){const o=JSON.parse(JSON.stringify(s.state));delete o[t],history.replaceState(null,"",encodeURIComponent(JSON.stringify(o)))}static getInstance(){return p.instance||(p.instance=new p),p.instance}get state(){const t=location.pathname.split("/").pop();let o={};try{o=t?JSON.parse(decodeURIComponent(t)):{}}catch{o={}}return o}}const s=p.getInstance();var h=(n=>(n.push="push",n.replace="replace",n.pop="pop",n.silent="silent",n))(h||{}),w=Object.defineProperty,E=Object.getOwnPropertyDescriptor,m=(n,t,o,r)=>{for(var i,a=r>1?void 0:r?E(t,o):t,u=n.length-1;u>=0;u--)(i=n[u])&&(a=(r?i(t,o,a):i(a))||a);return r&&a&&w(t,o,a),a};exports.SchmancyArea=class extends y.$LitElement(l.css`
|
|
2
|
-
:host {
|
|
3
|
-
position: relative;
|
|
4
|
-
display: block;
|
|
5
|
-
inset: 0;
|
|
6
|
-
}
|
|
7
|
-
`){constructor(){super(...arguments),this.mappings=[]}getComponentFromMappings(n,t){return e.of(location.pathname).pipe(e.map(o=>{const r=n.find(a=>a.pathname===o);if(!r)throw new Error(`No mapping found for pathname: ${o}`);const i=r.routes.find(a=>a.area===this.name);if(!i)throw new Error(`No route found for area: ${this.name} in pathname: ${o}`);return i}),e.map(o=>({area:this.name,component:o.component||this.default,state:o.state,historyStrategy:t})),e.catchError(()=>this.default?e.of({area:this.name,component:this.default,historyStrategy:t}):e.EMPTY))}getComponentFromPathname(n,t){return e.of(n).pipe(e.map(o=>o.split("/").pop()??""),e.map(o=>decodeURIComponent(o)),e.map(o=>JSON.parse(o)),e.map(o=>o[this.name]),e.map(o=>!o&&this.default?{component:this.default,state:void 0}:o),e.filter(o=>g.libExports.isPresent(o)),e.map(o=>({area:this.name,component:o.component??this.default,state:o.state,historyStrategy:t})),e.map(o=>o),e.catchError(()=>this.default?e.of({area:this.name,component:this.default,historyStrategy:t}):e.EMPTY))}firstUpdated(){if(!this.name)throw new Error("Area name or default component not set");e.merge(e.of(location.pathname).pipe(e.switchMap(n=>this.getComponentFromPathname(n,h.silent)),e.take(1)),s.request.pipe(e.filter(({area:n})=>n===this.name)),e.fromEvent(window,"popstate").pipe(e.map(n=>n.target.location.pathname),e.switchMap(n=>this.getComponentFromPathname(n,h.silent)))).pipe(e.filter(n=>!!n.component),e.takeUntil(this.disconnecting),e.distinctUntilChanged((n,t)=>{let o,r;return typeof n.component!="function"&&(typeof n.component=="string"&&(o=n.component),typeof t.component!="function"&&(typeof t.component=="string"&&(r=t.component),(r==null?void 0:r.replaceAll("-","").toLowerCase())===(o==null?void 0:o.replaceAll("-","").toLowerCase())))})).pipe(e.switchMap(n=>{const t=n.component;return t instanceof Promise?e.from(t).pipe(e.map(o=>({component:o.exports.default,route:n}))):e.of({component:t,route:n})}),e.map(({component:n,route:t})=>typeof n=="string"?{component:document.createElement(n),route:t}:n instanceof HTMLElement?{component:n,route:t}:typeof n=="function"?{component:new n,route:t}:void 0),e.distinctUntilChanged((n,t)=>n.component.tagName===t.component.tagName),e.map(({component:n,route:t})=>{var i,a;const o=(i=this.shadowRoot)==null?void 0:i.children[0],r=!!o;return o.remove(),n.classList.add("opacity-0"),(a=this.shadowRoot)==null||a.append(n),n.animate([{opacity:0},{opacity:1}],{duration:r?150:100,easing:"cubic-bezier(0.25, 0.8, 0.25, 1)",fill:"forwards"}),{component:n,route:t}}),e.tap(({component:n,route:t})=>{t.historyStrategy===void 0||t.historyStrategy==="push"?history.pushState(t.state,"",this.newPath(n.tagName,t)):t.historyStrategy&&["replace","pop"].includes(t.historyStrategy)&&history.replaceState(t.state,"",this.newPath(n.tagName,t)),s.current.set(this.name,{component:n.tagName,state:t.state,area:this.name}),s.$current.next(s.current)}),e.takeUntil(this.disconnecting)).subscribe()}newPath(n,t){const o=location.pathname.split("/").pop();let r={};try{r=o?JSON.parse(decodeURIComponent(o)):{}}catch{r={}}t.state=t.state??{};const i=t.clearQueryParams?this.queryParamClear(t.clearQueryParams):document.location.search;return encodeURIComponent(JSON.stringify({...r,[this.name]:{component:n.toLowerCase(),state:t.state}})).concat(`${i}`)}queryParamClear(n){if(!n)return"";const t=new URLSearchParams(location.search);return n.forEach(o=>t.delete(o)),t.toString()===""?"":`?${t.toString()}`}checkForTeleportationRequests(){return e.fromEvent(window,"FLIP_REQUEST").pipe(e.map(n=>n.detail),e.tap(()=>{this.dispatchEvent(new CustomEvent("FLIP_STARTED"))}),e.timeout(0),e.catchError(()=>e.of(null)),e.takeUntil(this.disconnecting))}disconnectedCallback(){super.disconnectedCallback(),this.disconnecting.next(!0)}render(){return l.html` <slot> </slot> `}},m([c.property()],exports.SchmancyArea.prototype,"name",2),m([c.property()],exports.SchmancyArea.prototype,"default",2),m([c.property({type:Array})],exports.SchmancyArea.prototype,"mappings",2),exports.SchmancyArea=m([c.customElement("schmancy-area")],exports.SchmancyArea),exports.FINDING_MORTIES=d,exports.HERE_RICKY=f,exports.HISTORY_STRATEGY=h,exports.area=s,exports.routerHistory=S;
|
|
8
|
-
//# sourceMappingURL=area.component-BmSDlykT.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"area.component-BmSDlykT.cjs","sources":["../src/area/area.service.ts","../src/area/router.types.ts","../src/area/area.component.ts"],"sourcesContent":["import { ReplaySubject, Subject, bufferTime, fromEvent, map, of, tap, timeout, zip } from 'rxjs'\nimport { SchmancyTeleportation } from '../teleport'\nimport { ActiveRoute, RouteAction } from './router.types'\n\nexport const routerHistory = new Subject<RouteAction>()\n\nexport const FINDING_MORTIES = 'FINDING_MORTIES'\nexport const HERE_RICKY = 'HERE_RICKY'\nexport type HERE_RICKY_EVENT = CustomEvent<{\n\tcomponent: SchmancyTeleportation\n}>\nexport type FINDING_MORTIES_EVENT = CustomEvent<{\n\tcomponent: SchmancyTeleportation\n}>\n\nclass AreaService {\n\tprivate static instance: AreaService\n\tpublic prettyURL = false\n\tpublic mode: 'SILENT' | 'HISTORY' = 'HISTORY'\n\tpublic request = new ReplaySubject<RouteAction>(1)\n\tpublic current = new Map<string, ActiveRoute>()\n\tpublic $current = new ReplaySubject<Map<string, ActiveRoute>>(1)\n\tpublic enableHistoryMode = true\n\tprivate findingMortiesEvent = new CustomEvent<FINDING_MORTIES_EVENT['detail']>(FINDING_MORTIES)\n\n\tconstructor() {\n\t\tthis.$current.next(this.current)\n\t}\n\n\tfind() {\n\t\treturn zip([\n\t\t\tfromEvent<HERE_RICKY_EVENT>(window, HERE_RICKY).pipe(\n\t\t\t\tmap(e => e.detail),\n\t\t\t\tbufferTime(0),\n\t\t\t\ttap(console.log),\n\t\t\t),\n\t\t\tof(1).pipe(tap(() => window.dispatchEvent(this.findingMortiesEvent))),\n\t\t]).pipe(\n\t\t\tmap(([component]) => component),\n\t\t\ttimeout(1),\n\t\t)\n\t}\n\n\tpush(r: RouteAction) {\n\t\tthis.request.next(r)\n\t}\n\n\tpop(name: string) {\n\t\tconst newState = JSON.parse(JSON.stringify(area.state))\n\t\tdelete newState[name]\n\t\tconsole.log(area.state, newState)\n\t\thistory.replaceState(null, '', encodeURIComponent(JSON.stringify(newState)))\n\t}\n\tstatic getInstance() {\n\t\tif (!AreaService.instance) {\n\t\t\tAreaService.instance = new AreaService()\n\t\t}\n\t\treturn AreaService.instance\n\t}\n\n\tget state() {\n\t\tconst pathname = location.pathname.split('/').pop()\n\t\tlet areaState = {}\n\t\ttry {\n\t\t\tareaState = pathname ? JSON.parse(decodeURIComponent(pathname)) : {}\n\t\t} catch {\n\t\t\tareaState = {}\n\t\t}\n\t\treturn areaState\n\t}\n}\n\nexport const area = AreaService.getInstance()\nexport default area\n","export type RouteAction = {\n\tcomponent: CustomElementConstructor | string | HTMLElement\n\tarea: string\n\tstate?: object\n\thistoryStrategy?: THistoryStrategy\n\tclearQueryParams?: string[] | null\n}\n\nexport type ActiveRoute = {\n\tcomponent: string\n\tarea: string\n\tstate?: object\n}\n\nexport type THistoryStrategy = 'push' | 'replace' | 'pop' | 'silent'\n\nexport enum HISTORY_STRATEGY {\n\tpush = 'push',\n\treplace = 'replace',\n\tpop = 'pop',\n\tsilent = 'silent',\n}\n","import { $LitElement } from '@mixins/index'\nimport { TemplateResult, css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport {\n\tEMPTY,\n\tcatchError,\n\tdistinctUntilChanged,\n\tfilter,\n\tfrom,\n\tfromEvent,\n\tmap,\n\tmerge,\n\tof,\n\tswitchMap,\n\ttake,\n\ttakeUntil,\n\ttap,\n\ttimeout,\n} from 'rxjs'\nimport { isPresent } from 'ts-is-present'\nimport area from './area.service'\nimport { HISTORY_STRATEGY, RouteAction } from './router.types'\n\n/**\n * Type describing the route for an area.\n */\ntype TRouteArea = {\n\tcomponent: string\n\tstate: object | undefined\n}\n\n/**\n * Type for a mapping entry. Each mapping specifies a pathname and an array of route definitions.\n * Each route definition contains an area name, a component (or promise/constructor/template),\n * and optionally, a state.\n */\nexport type AreaPathnames = {\n\tpathname: string\n\troutes: Array<{\n\t\tarea: string\n\t\tcomponent: string | Promise<NodeModule> | CustomElementConstructor | TemplateResult<1>\n\t\tstate?: object\n\t}>\n}\n\n@customElement('schmancy-area')\nexport class SchmancyArea extends $LitElement(css`\n\t:host {\n\t\tposition: relative;\n\t\tdisplay: block;\n\t\tinset: 0;\n\t}\n`) {\n\t/**\n\t * The name of the router outlet.\n\t * @attr\n\t * @type {string}\n\t * @public\n\t * @required\n\t */\n\t@property() name!: string\n\n\t/**\n\t * The default component to use if no matching route is found.\n\t */\n\t@property() default!: string | Promise<NodeModule> | CustomElementConstructor | TemplateResult<1>\n\n\t/**\n\t * (Optional) A mappings property that can be set on the element.\n\t * This property is only available for external use and does not alter\n\t * the component's built-in routing behavior.\n\t *\n\t * Example:\n\t * [\n\t * {\n\t * pathname: '/home',\n\t * routes: [\n\t * { area: 'main', component: 'home-view', state: { foo: 'bar' } },\n\t * { area: 'sidebar', component: 'menu-view' }\n\t * ]\n\t * },\n\t * {\n\t * pathname: '/about',\n\t * routes: [\n\t * { area: 'main', component: 'about-view' },\n\t * { area: 'sidebar', component: 'info-view' }\n\t * ]\n\t * }\n\t * ]\n\t */\n\t@property({ type: Array }) mappings: AreaPathnames[] = []\n\n\t/**\n\t * NEW PUBLIC API:\n\t * Accepts an array of route mappings and returns an observable emitting\n\t * the RouteAction for this area (if found) based on the current location's pathname.\n\t *\n\t * Note: This method does not affect the component's built-in logic.\n\t *\n\t * @param mappings - Array of route mapping objects.\n\t * @param historyStrategy - The history strategy to use (e.g. PUSH, REPLACE, SILENT).\n\t * @returns An RxJS Observable that emits a RouteAction.\n\t */\n\tpublic getComponentFromMappings(mappings: AreaPathnames[], historyStrategy: HISTORY_STRATEGY) {\n\t\treturn of(location.pathname).pipe(\n\t\t\tmap(currentPath => {\n\t\t\t\tconst mapping = mappings.find(m => m.pathname === currentPath)\n\t\t\t\tif (!mapping) {\n\t\t\t\t\tthrow new Error(`No mapping found for pathname: ${currentPath}`)\n\t\t\t\t}\n\t\t\t\tconst routeForArea = mapping.routes.find(route => route.area === this.name)\n\t\t\t\tif (!routeForArea) {\n\t\t\t\t\tthrow new Error(`No route found for area: ${this.name} in pathname: ${currentPath}`)\n\t\t\t\t}\n\t\t\t\treturn routeForArea\n\t\t\t}),\n\t\t\tmap(\n\t\t\t\troute =>\n\t\t\t\t\t({\n\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\tcomponent: route.component || this.default,\n\t\t\t\t\t\tstate: route.state,\n\t\t\t\t\t\thistoryStrategy,\n\t\t\t\t\t}) as RouteAction,\n\t\t\t),\n\t\t\tcatchError(() =>\n\t\t\t\tthis.default\n\t\t\t\t\t? of({\n\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\tcomponent: this.default,\n\t\t\t\t\t\t\thistoryStrategy,\n\t\t\t\t\t\t} as RouteAction)\n\t\t\t\t\t: EMPTY,\n\t\t\t),\n\t\t)\n\t}\n\n\t/**\n\t * ORIGINAL API:\n\t * Returns an observable that emits a RouteAction based on the provided pathname.\n\t *\n\t * This method retains the original logic that parses the URL.\n\t *\n\t * @param pathname - Pathname from the browser location API.\n\t * @param historyStrategy - The history strategy to use for the route (PUSH, REPLACE, SILENT).\n\t * @returns An observable emitting the RouteAction.\n\t */\n\tgetComponentFromPathname(pathname: string, historyStrategy: HISTORY_STRATEGY) {\n\t\treturn of(pathname).pipe(\n\t\t\tmap(path => path.split('/').pop() ?? ''),\n\t\t\tmap(path => decodeURIComponent(path)),\n\t\t\tmap(path => JSON.parse(path)),\n\t\t\tmap(routes => routes[this.name] as TRouteArea),\n\t\t\tmap(component =>\n\t\t\t\t!component && this.default\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tcomponent: this.default,\n\t\t\t\t\t\t\tstate: undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t: component,\n\t\t\t),\n\t\t\tfilter(x => isPresent(x)),\n\t\t\tmap((component: TRouteArea) => ({\n\t\t\t\tarea: this.name,\n\t\t\t\tcomponent: component.component ?? this.default,\n\t\t\t\tstate: component.state,\n\t\t\t\thistoryStrategy,\n\t\t\t})),\n\t\t\tmap(x => x as RouteAction),\n\t\t\tcatchError(() => {\n\t\t\t\treturn this.default\n\t\t\t\t\t? of({\n\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\tcomponent: this.default,\n\t\t\t\t\t\t\thistoryStrategy,\n\t\t\t\t\t\t} as RouteAction)\n\t\t\t\t\t: EMPTY\n\t\t\t}),\n\t\t)\n\t}\n\n\t/**\n\t * The original routing pipeline remains intact.\n\t * It uses getComponentFromPathname to resolve the route based on the URL.\n\t */\n\tprotected firstUpdated(): void {\n\t\tif (!this.name) {\n\t\t\t// TODO: maybe enforce this to be unique\n\t\t\tthrow new Error('Area name or default component not set')\n\t\t}\n\n\t\tmerge(\n\t\t\t// 1) Initial load from location.pathname.\n\t\t\tof(location.pathname).pipe(\n\t\t\t\tswitchMap(pathname => this.getComponentFromPathname(pathname, HISTORY_STRATEGY.silent)),\n\t\t\t\ttake(1),\n\t\t\t),\n\t\t\t// 2) Requests to change the route for this area.\n\t\t\tarea.request.pipe(filter(({ area }) => area === this.name)),\n\t\t\t// 3) Popstate events (back, forward).\n\t\t\tfromEvent<PopStateEvent>(window, 'popstate').pipe(\n\t\t\t\tmap(e => (e.target as Window).location.pathname),\n\t\t\t\tswitchMap(pathname => this.getComponentFromPathname(pathname, HISTORY_STRATEGY.silent)),\n\t\t\t),\n\t\t)\n\t\t\t.pipe(\n\t\t\t\tfilter(request => !!request.component),\n\t\t\t\ttakeUntil(this.disconnecting),\n\t\t\t\tdistinctUntilChanged((a, b) => {\n\t\t\t\t\tlet aComponent, bComponent\n\t\t\t\t\tif (typeof a.component === 'function') return false\n\t\t\t\t\telse if (typeof a.component === 'string') aComponent = a.component\n\n\t\t\t\t\tif (typeof b.component === 'function') return false\n\t\t\t\t\telse if (typeof b.component === 'string') bComponent = b.component\n\n\t\t\t\t\treturn bComponent?.replaceAll('-', '').toLowerCase() === aComponent?.replaceAll('-', '').toLowerCase()\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.pipe(\n\t\t\t\tswitchMap(route => {\n\t\t\t\t\tconst c = route.component\n\t\t\t\t\tif (c instanceof Promise) {\n\t\t\t\t\t\t// Dynamic import module.\n\t\t\t\t\t\treturn from(c).pipe(\n\t\t\t\t\t\t\tmap(x => ({\n\t\t\t\t\t\t\t\tcomponent: x.exports.default as CustomElementConstructor,\n\t\t\t\t\t\t\t\troute,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t)\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Already a string, function, or element.\n\t\t\t\t\t\treturn of({ component: c, route })\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tmap(({ component, route }) => {\n\t\t\t\t\tif (typeof component === 'string') {\n\t\t\t\t\t\t// Tag name.\n\t\t\t\t\t\treturn { component: document.createElement(component), route }\n\t\t\t\t\t} else if (component instanceof HTMLElement) {\n\t\t\t\t\t\t// Already an element instance.\n\t\t\t\t\t\treturn { component, route }\n\t\t\t\t\t} else if (typeof component === 'function') {\n\t\t\t\t\t\t// Custom element constructor.\n\t\t\t\t\t\treturn { component: new component(), route }\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tdistinctUntilChanged((prev, curr) => prev.component.tagName === curr.component.tagName),\n\t\t\t\t// Create the new view and add it to the DOM.\n\t\t\t\tmap(({ component, route }) => {\n\t\t\t\t\tconst oldView = this.shadowRoot?.children[0]\n\t\t\t\t\tconst oldViewExists = !!oldView\n\n\t\t\t\t\t// Remove the old view (if any).\n\t\t\t\t\toldView.remove()\n\t\t\t\t\t// Native Web Animations API - fade in.\n\t\t\t\t\tcomponent.classList.add('opacity-0')\n\t\t\t\t\tthis.shadowRoot?.append(component)\n\t\t\t\t\tcomponent.animate([{ opacity: 0 }, { opacity: 1 }], {\n\t\t\t\t\t\tduration: oldViewExists ? 150 : 100,\n\t\t\t\t\t\teasing: 'cubic-bezier(0.25, 0.8, 0.25, 1)',\n\t\t\t\t\t\tfill: 'forwards',\n\t\t\t\t\t})\n\n\t\t\t\t\treturn { component, route }\n\t\t\t\t}),\n\t\t\t\ttap(({ component, route }) => {\n\t\t\t\t\t// Handle history updates.\n\t\t\t\t\tif (typeof route.historyStrategy === 'undefined' || route.historyStrategy === 'push') {\n\t\t\t\t\t\thistory.pushState(route.state, '', this.newPath(component.tagName, route))\n\t\t\t\t\t} else if (route.historyStrategy && ['replace', 'pop'].includes(route.historyStrategy)) {\n\t\t\t\t\t\thistory.replaceState(route.state, '', this.newPath(component.tagName, route))\n\t\t\t\t\t}\n\t\t\t\t\tarea.current.set(this.name, {\n\t\t\t\t\t\tcomponent: component.tagName,\n\t\t\t\t\t\tstate: route.state,\n\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t})\n\n\t\t\t\t\tarea.$current.next(area.current)\n\t\t\t\t}),\n\t\t\t\ttakeUntil(this.disconnecting),\n\t\t\t)\n\t\t\t.subscribe()\n\t}\n\n\t/**\n\t * Computes the new URL path for the given component and route.\n\t */\n\tnewPath(tag: string, route: RouteAction) {\n\t\tconst oldPathname = location.pathname.split('/').pop()\n\t\tlet oldAreaState = {}\n\t\ttry {\n\t\t\toldAreaState = oldPathname ? JSON.parse(decodeURIComponent(oldPathname)) : {}\n\t\t} catch {\n\t\t\toldAreaState = {}\n\t\t}\n\t\troute.state = route.state ?? {}\n\t\tconst queryParams = route.clearQueryParams ? this.queryParamClear(route.clearQueryParams) : document.location.search\n\n\t\treturn encodeURIComponent(\n\t\t\tJSON.stringify({\n\t\t\t\t...oldAreaState,\n\t\t\t\t[this.name]: { component: tag.toLowerCase(), state: route.state },\n\t\t\t}),\n\t\t).concat(`${queryParams}`)\n\t}\n\n\t/**\n\t * Removes specified query parameters from the current URL.\n\t */\n\tqueryParamClear(params?: string[]) {\n\t\tif (!params) {\n\t\t\treturn ''\n\t\t}\n\t\t// Get query params from URL.\n\t\tconst urlParams = new URLSearchParams(location.search)\n\t\t// Remove query params.\n\t\tparams.forEach(param => urlParams.delete(param))\n\t\tif (urlParams.toString() === '') return ''\n\t\treturn `?${urlParams.toString()}`\n\t}\n\n\t/**\n\t * Checks for teleportation requests (FLIP_REQUEST events) and dispatches a FLIP_STARTED event.\n\t */\n\tcheckForTeleportationRequests() {\n\t\treturn fromEvent<CustomEvent>(window, 'FLIP_REQUEST').pipe(\n\t\t\tmap(e => e.detail),\n\t\t\ttap(() => {\n\t\t\t\tthis.dispatchEvent(new CustomEvent('FLIP_STARTED'))\n\t\t\t}),\n\t\t\ttimeout(0),\n\t\t\tcatchError(() => of(null)),\n\t\t\ttakeUntil(this.disconnecting),\n\t\t)\n\t}\n\n\tdisconnectedCallback(): void {\n\t\tsuper.disconnectedCallback()\n\t\tthis.disconnecting.next(true)\n\t}\n\n\trender() {\n\t\treturn html` <slot> </slot> `\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'schmancy-area': SchmancyArea\n\t}\n}\n"],"names":["routerHistory","Subject","FINDING_MORTIES","HERE_RICKY","AreaService","constructor","this","prettyURL","mode","request","ReplaySubject","current","Map","$current","enableHistoryMode","findingMortiesEvent","CustomEvent","next","zip","fromEvent","window","pipe","map","e","detail","bufferTime","tap","console","log","of","dispatchEvent","component","timeout","r","name","newState","JSON","parse","stringify","area","state","history","replaceState","encodeURIComponent","getInstance","instance","pathname","location","split","pop","areaState","decodeURIComponent","HISTORY_STRATEGY","SchmancyArea","$LitElement","css","super","arguments","mappings","historyStrategy","currentPath","mapping","find","m","Error","routeForArea","routes","route","default","catchError","EMPTY","path","filter","x","isPresent","libExports","merge","switchMap","getComponentFromPathname","silent","take","target","takeUntil","disconnecting","distinctUntilChanged","a","b","aComponent","bComponent","replaceAll","toLowerCase","c","Promise","from","exports","document","createElement","HTMLElement","prev","curr","tagName","oldView","shadowRoot","children","oldViewExists","remove","classList","add","append","animate","opacity","duration","easing","fill","pushState","newPath","includes","set","subscribe","tag","oldPathname","oldAreaState","queryParams","clearQueryParams","queryParamClear","search","concat","params","urlParams","URLSearchParams","forEach","param","delete","toString","disconnectedCallback","html","__decorateClass","property","prototype","type","Array","customElement"],"mappings":"qSAIaA,EAAAA,EAAgB,IAAIC,EAAqBA,QAEzCC,EAAkB,kBAClBC,EAAa,aAQ1B,MAAMC,CAAAA,CAUL,aAAAC,CARAC,KAAOC,UAAAA,GACPD,KAAOE,KAA6B,UAC7BF,KAAAG,QAAU,IAAIC,EAAAA,cAA2B,CACzCJ,EAAAA,KAAAK,YAAcC,IACdN,KAAAO,SAAW,IAAIH,EAAAA,cAAwC,CAAA,EAC9DJ,KAAOQ,kBAAAA,GACCR,KAAAS,oBAAsB,IAAIC,YAA6Cd,CAGzEI,EAAAA,KAAAO,SAASI,KAAKX,KAAKK,OAAAA,CAAO,CAGhC,MACC,CAAA,OAAOO,MAAI,CACVC,YAA4BC,OAAQjB,GAAYkB,KAC/CC,EAAAA,IAASC,GAAAA,EAAEC,MAAAA,EACXC,EAAAA,WAAW,CACXC,EAAAA,EAAAA,IAAIC,QAAQC,GAEbC,CAAAA,EAAAA,KAAG,CAAA,EAAGR,KAAKK,EAAAA,IAAI,IAAMN,OAAOU,cAAcxB,KAAKS,mBAC7CM,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,KACFC,EAAAA,IAAI,CAAES,CAAAA,CAAAA,IAAeA,CACrBC,EAAAA,EAAAA,QAAQ,CAAA,CAAA,CACT,CAGD,KAAKC,EACC3B,CAAAA,KAAAG,QAAQQ,KAAKgB,CAAC,CAAA,CAGpB,IAAIC,EAAAA,CACH,MAAMC,EAAWC,KAAKC,MAAM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B,QACQ,CAAA,OAAAsH,EAAAA,sBAAA,CA5RIC,EAAAA,EAAA,CAAXC,EAASA,YAdEpF,qBAcAqF,UAAA,OAAA,CAAA,EAKAF,EAAA,CAAXC,EAASA,SAnBEpF,CAAAA,EAAAA,qBAmBAqF,UAAA,UAAA,CAyBeF,EAAAA,EAAA,CAA1BC,WAAS,CAAEE,KAAMC,SA5CNvF,qBA4CeqF,UAAA,WAAA,CAAA,EA5CfrF,QAANA,aAAAmF,EAAA,CADNK,EAAAA,cAAc,eACFxF,CAAAA,EAAAA"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { Subject as v, ReplaySubject as C, zip as I, fromEvent as S, of as i, map as a, bufferTime as b, tap as l, timeout as N, catchError as d, EMPTY as P, filter as f, merge as O, switchMap as y, take as U, takeUntil as g, distinctUntilChanged as R, from as F } from "rxjs";
|
|
2
|
-
import "lit/directives/class-map.js";
|
|
3
|
-
import "lit/directives/style-map.js";
|
|
4
|
-
import { $ as T } from "./litElement.mixin-Dx9_p_nV.js";
|
|
5
|
-
import "./tailwind.mixin-YEy_iITN.js";
|
|
6
|
-
import { css as L, html as M } from "lit";
|
|
7
|
-
import { property as w, customElement as $ } from "lit/decorators.js";
|
|
8
|
-
import { l as J } from "./index-CuY8m6ta.js";
|
|
9
|
-
const B = new v(), x = "FINDING_MORTIES", k = "HERE_RICKY";
|
|
10
|
-
class p {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.prettyURL = !1, this.mode = "HISTORY", this.request = new C(1), this.current = /* @__PURE__ */ new Map(), this.$current = new C(1), this.enableHistoryMode = !0, this.findingMortiesEvent = new CustomEvent(x), this.$current.next(this.current);
|
|
13
|
-
}
|
|
14
|
-
find() {
|
|
15
|
-
return I([S(window, k).pipe(a((t) => t.detail), b(0), l(console.log)), i(1).pipe(l(() => window.dispatchEvent(this.findingMortiesEvent)))]).pipe(a(([t]) => t), N(1));
|
|
16
|
-
}
|
|
17
|
-
push(t) {
|
|
18
|
-
this.request.next(t);
|
|
19
|
-
}
|
|
20
|
-
pop(t) {
|
|
21
|
-
const n = JSON.parse(JSON.stringify(m.state));
|
|
22
|
-
delete n[t], history.replaceState(null, "", encodeURIComponent(JSON.stringify(n)));
|
|
23
|
-
}
|
|
24
|
-
static getInstance() {
|
|
25
|
-
return p.instance || (p.instance = new p()), p.instance;
|
|
26
|
-
}
|
|
27
|
-
get state() {
|
|
28
|
-
const t = location.pathname.split("/").pop();
|
|
29
|
-
let n = {};
|
|
30
|
-
try {
|
|
31
|
-
n = t ? JSON.parse(decodeURIComponent(t)) : {};
|
|
32
|
-
} catch {
|
|
33
|
-
n = {};
|
|
34
|
-
}
|
|
35
|
-
return n;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const m = p.getInstance();
|
|
39
|
-
var E = ((e) => (e.push = "push", e.replace = "replace", e.pop = "pop", e.silent = "silent", e))(E || {}), q = Object.defineProperty, A = Object.getOwnPropertyDescriptor, h = (e, t, n, o) => {
|
|
40
|
-
for (var s, r = o > 1 ? void 0 : o ? A(t, n) : t, u = e.length - 1; u >= 0; u--) (s = e[u]) && (r = (o ? s(t, n, r) : s(r)) || r);
|
|
41
|
-
return o && r && q(t, n, r), r;
|
|
42
|
-
};
|
|
43
|
-
let c = class extends T(L`
|
|
44
|
-
:host {
|
|
45
|
-
position: relative;
|
|
46
|
-
display: block;
|
|
47
|
-
inset: 0;
|
|
48
|
-
}
|
|
49
|
-
`) {
|
|
50
|
-
constructor() {
|
|
51
|
-
super(...arguments), this.mappings = [];
|
|
52
|
-
}
|
|
53
|
-
getComponentFromMappings(e, t) {
|
|
54
|
-
return i(location.pathname).pipe(a((n) => {
|
|
55
|
-
const o = e.find((r) => r.pathname === n);
|
|
56
|
-
if (!o) throw new Error(`No mapping found for pathname: ${n}`);
|
|
57
|
-
const s = o.routes.find((r) => r.area === this.name);
|
|
58
|
-
if (!s) throw new Error(`No route found for area: ${this.name} in pathname: ${n}`);
|
|
59
|
-
return s;
|
|
60
|
-
}), a((n) => ({ area: this.name, component: n.component || this.default, state: n.state, historyStrategy: t })), d(() => this.default ? i({ area: this.name, component: this.default, historyStrategy: t }) : P));
|
|
61
|
-
}
|
|
62
|
-
getComponentFromPathname(e, t) {
|
|
63
|
-
return i(e).pipe(a((n) => n.split("/").pop() ?? ""), a((n) => decodeURIComponent(n)), a((n) => JSON.parse(n)), a((n) => n[this.name]), a((n) => !n && this.default ? { component: this.default, state: void 0 } : n), f((n) => J.isPresent(n)), a((n) => ({ area: this.name, component: n.component ?? this.default, state: n.state, historyStrategy: t })), a((n) => n), d(() => this.default ? i({ area: this.name, component: this.default, historyStrategy: t }) : P));
|
|
64
|
-
}
|
|
65
|
-
firstUpdated() {
|
|
66
|
-
if (!this.name) throw new Error("Area name or default component not set");
|
|
67
|
-
O(i(location.pathname).pipe(y((e) => this.getComponentFromPathname(e, E.silent)), U(1)), m.request.pipe(f(({ area: e }) => e === this.name)), S(window, "popstate").pipe(a((e) => e.target.location.pathname), y((e) => this.getComponentFromPathname(e, E.silent)))).pipe(f((e) => !!e.component), g(this.disconnecting), R((e, t) => {
|
|
68
|
-
let n, o;
|
|
69
|
-
return typeof e.component != "function" && (typeof e.component == "string" && (n = e.component), typeof t.component != "function" && (typeof t.component == "string" && (o = t.component), (o == null ? void 0 : o.replaceAll("-", "").toLowerCase()) === (n == null ? void 0 : n.replaceAll("-", "").toLowerCase())));
|
|
70
|
-
})).pipe(y((e) => {
|
|
71
|
-
const t = e.component;
|
|
72
|
-
return t instanceof Promise ? F(t).pipe(a((n) => ({ component: n.exports.default, route: e }))) : i({ component: t, route: e });
|
|
73
|
-
}), a(({ component: e, route: t }) => typeof e == "string" ? { component: document.createElement(e), route: t } : e instanceof HTMLElement ? { component: e, route: t } : typeof e == "function" ? { component: new e(), route: t } : void 0), R((e, t) => e.component.tagName === t.component.tagName), a(({ component: e, route: t }) => {
|
|
74
|
-
var s, r;
|
|
75
|
-
const n = (s = this.shadowRoot) == null ? void 0 : s.children[0], o = !!n;
|
|
76
|
-
return n.remove(), e.classList.add("opacity-0"), (r = this.shadowRoot) == null || r.append(e), e.animate([{ opacity: 0 }, { opacity: 1 }], { duration: o ? 150 : 100, easing: "cubic-bezier(0.25, 0.8, 0.25, 1)", fill: "forwards" }), { component: e, route: t };
|
|
77
|
-
}), l(({ component: e, route: t }) => {
|
|
78
|
-
t.historyStrategy === void 0 || t.historyStrategy === "push" ? history.pushState(t.state, "", this.newPath(e.tagName, t)) : t.historyStrategy && ["replace", "pop"].includes(t.historyStrategy) && history.replaceState(t.state, "", this.newPath(e.tagName, t)), m.current.set(this.name, { component: e.tagName, state: t.state, area: this.name }), m.$current.next(m.current);
|
|
79
|
-
}), g(this.disconnecting)).subscribe();
|
|
80
|
-
}
|
|
81
|
-
newPath(e, t) {
|
|
82
|
-
const n = location.pathname.split("/").pop();
|
|
83
|
-
let o = {};
|
|
84
|
-
try {
|
|
85
|
-
o = n ? JSON.parse(decodeURIComponent(n)) : {};
|
|
86
|
-
} catch {
|
|
87
|
-
o = {};
|
|
88
|
-
}
|
|
89
|
-
t.state = t.state ?? {};
|
|
90
|
-
const s = t.clearQueryParams ? this.queryParamClear(t.clearQueryParams) : document.location.search;
|
|
91
|
-
return encodeURIComponent(JSON.stringify({ ...o, [this.name]: { component: e.toLowerCase(), state: t.state } })).concat(`${s}`);
|
|
92
|
-
}
|
|
93
|
-
queryParamClear(e) {
|
|
94
|
-
if (!e) return "";
|
|
95
|
-
const t = new URLSearchParams(location.search);
|
|
96
|
-
return e.forEach((n) => t.delete(n)), t.toString() === "" ? "" : `?${t.toString()}`;
|
|
97
|
-
}
|
|
98
|
-
checkForTeleportationRequests() {
|
|
99
|
-
return S(window, "FLIP_REQUEST").pipe(a((e) => e.detail), l(() => {
|
|
100
|
-
this.dispatchEvent(new CustomEvent("FLIP_STARTED"));
|
|
101
|
-
}), N(0), d(() => i(null)), g(this.disconnecting));
|
|
102
|
-
}
|
|
103
|
-
disconnectedCallback() {
|
|
104
|
-
super.disconnectedCallback(), this.disconnecting.next(!0);
|
|
105
|
-
}
|
|
106
|
-
render() {
|
|
107
|
-
return M` <slot> </slot> `;
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
h([w()], c.prototype, "name", 2), h([w()], c.prototype, "default", 2), h([w({ type: Array })], c.prototype, "mappings", 2), c = h([$("schmancy-area")], c);
|
|
111
|
-
export {
|
|
112
|
-
x as F,
|
|
113
|
-
k as H,
|
|
114
|
-
c as S,
|
|
115
|
-
m as a,
|
|
116
|
-
E as b,
|
|
117
|
-
B as r
|
|
118
|
-
};
|
|
119
|
-
//# sourceMappingURL=area.component-D99_ptNx.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"area.component-D99_ptNx.js","sources":["../src/area/area.service.ts","../src/area/router.types.ts","../src/area/area.component.ts"],"sourcesContent":["import { ReplaySubject, Subject, bufferTime, fromEvent, map, of, tap, timeout, zip } from 'rxjs'\nimport { SchmancyTeleportation } from '../teleport'\nimport { ActiveRoute, RouteAction } from './router.types'\n\nexport const routerHistory = new Subject<RouteAction>()\n\nexport const FINDING_MORTIES = 'FINDING_MORTIES'\nexport const HERE_RICKY = 'HERE_RICKY'\nexport type HERE_RICKY_EVENT = CustomEvent<{\n\tcomponent: SchmancyTeleportation\n}>\nexport type FINDING_MORTIES_EVENT = CustomEvent<{\n\tcomponent: SchmancyTeleportation\n}>\n\nclass AreaService {\n\tprivate static instance: AreaService\n\tpublic prettyURL = false\n\tpublic mode: 'SILENT' | 'HISTORY' = 'HISTORY'\n\tpublic request = new ReplaySubject<RouteAction>(1)\n\tpublic current = new Map<string, ActiveRoute>()\n\tpublic $current = new ReplaySubject<Map<string, ActiveRoute>>(1)\n\tpublic enableHistoryMode = true\n\tprivate findingMortiesEvent = new CustomEvent<FINDING_MORTIES_EVENT['detail']>(FINDING_MORTIES)\n\n\tconstructor() {\n\t\tthis.$current.next(this.current)\n\t}\n\n\tfind() {\n\t\treturn zip([\n\t\t\tfromEvent<HERE_RICKY_EVENT>(window, HERE_RICKY).pipe(\n\t\t\t\tmap(e => e.detail),\n\t\t\t\tbufferTime(0),\n\t\t\t\ttap(console.log),\n\t\t\t),\n\t\t\tof(1).pipe(tap(() => window.dispatchEvent(this.findingMortiesEvent))),\n\t\t]).pipe(\n\t\t\tmap(([component]) => component),\n\t\t\ttimeout(1),\n\t\t)\n\t}\n\n\tpush(r: RouteAction) {\n\t\tthis.request.next(r)\n\t}\n\n\tpop(name: string) {\n\t\tconst newState = JSON.parse(JSON.stringify(area.state))\n\t\tdelete newState[name]\n\t\tconsole.log(area.state, newState)\n\t\thistory.replaceState(null, '', encodeURIComponent(JSON.stringify(newState)))\n\t}\n\tstatic getInstance() {\n\t\tif (!AreaService.instance) {\n\t\t\tAreaService.instance = new AreaService()\n\t\t}\n\t\treturn AreaService.instance\n\t}\n\n\tget state() {\n\t\tconst pathname = location.pathname.split('/').pop()\n\t\tlet areaState = {}\n\t\ttry {\n\t\t\tareaState = pathname ? JSON.parse(decodeURIComponent(pathname)) : {}\n\t\t} catch {\n\t\t\tareaState = {}\n\t\t}\n\t\treturn areaState\n\t}\n}\n\nexport const area = AreaService.getInstance()\nexport default area\n","export type RouteAction = {\n\tcomponent: CustomElementConstructor | string | HTMLElement\n\tarea: string\n\tstate?: object\n\thistoryStrategy?: THistoryStrategy\n\tclearQueryParams?: string[] | null\n}\n\nexport type ActiveRoute = {\n\tcomponent: string\n\tarea: string\n\tstate?: object\n}\n\nexport type THistoryStrategy = 'push' | 'replace' | 'pop' | 'silent'\n\nexport enum HISTORY_STRATEGY {\n\tpush = 'push',\n\treplace = 'replace',\n\tpop = 'pop',\n\tsilent = 'silent',\n}\n","import { $LitElement } from '@mixins/index'\nimport { TemplateResult, css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport {\n\tEMPTY,\n\tcatchError,\n\tdistinctUntilChanged,\n\tfilter,\n\tfrom,\n\tfromEvent,\n\tmap,\n\tmerge,\n\tof,\n\tswitchMap,\n\ttake,\n\ttakeUntil,\n\ttap,\n\ttimeout,\n} from 'rxjs'\nimport { isPresent } from 'ts-is-present'\nimport area from './area.service'\nimport { HISTORY_STRATEGY, RouteAction } from './router.types'\n\n/**\n * Type describing the route for an area.\n */\ntype TRouteArea = {\n\tcomponent: string\n\tstate: object | undefined\n}\n\n/**\n * Type for a mapping entry. Each mapping specifies a pathname and an array of route definitions.\n * Each route definition contains an area name, a component (or promise/constructor/template),\n * and optionally, a state.\n */\nexport type AreaPathnames = {\n\tpathname: string\n\troutes: Array<{\n\t\tarea: string\n\t\tcomponent: string | Promise<NodeModule> | CustomElementConstructor | TemplateResult<1>\n\t\tstate?: object\n\t}>\n}\n\n@customElement('schmancy-area')\nexport class SchmancyArea extends $LitElement(css`\n\t:host {\n\t\tposition: relative;\n\t\tdisplay: block;\n\t\tinset: 0;\n\t}\n`) {\n\t/**\n\t * The name of the router outlet.\n\t * @attr\n\t * @type {string}\n\t * @public\n\t * @required\n\t */\n\t@property() name!: string\n\n\t/**\n\t * The default component to use if no matching route is found.\n\t */\n\t@property() default!: string | Promise<NodeModule> | CustomElementConstructor | TemplateResult<1>\n\n\t/**\n\t * (Optional) A mappings property that can be set on the element.\n\t * This property is only available for external use and does not alter\n\t * the component's built-in routing behavior.\n\t *\n\t * Example:\n\t * [\n\t * {\n\t * pathname: '/home',\n\t * routes: [\n\t * { area: 'main', component: 'home-view', state: { foo: 'bar' } },\n\t * { area: 'sidebar', component: 'menu-view' }\n\t * ]\n\t * },\n\t * {\n\t * pathname: '/about',\n\t * routes: [\n\t * { area: 'main', component: 'about-view' },\n\t * { area: 'sidebar', component: 'info-view' }\n\t * ]\n\t * }\n\t * ]\n\t */\n\t@property({ type: Array }) mappings: AreaPathnames[] = []\n\n\t/**\n\t * NEW PUBLIC API:\n\t * Accepts an array of route mappings and returns an observable emitting\n\t * the RouteAction for this area (if found) based on the current location's pathname.\n\t *\n\t * Note: This method does not affect the component's built-in logic.\n\t *\n\t * @param mappings - Array of route mapping objects.\n\t * @param historyStrategy - The history strategy to use (e.g. PUSH, REPLACE, SILENT).\n\t * @returns An RxJS Observable that emits a RouteAction.\n\t */\n\tpublic getComponentFromMappings(mappings: AreaPathnames[], historyStrategy: HISTORY_STRATEGY) {\n\t\treturn of(location.pathname).pipe(\n\t\t\tmap(currentPath => {\n\t\t\t\tconst mapping = mappings.find(m => m.pathname === currentPath)\n\t\t\t\tif (!mapping) {\n\t\t\t\t\tthrow new Error(`No mapping found for pathname: ${currentPath}`)\n\t\t\t\t}\n\t\t\t\tconst routeForArea = mapping.routes.find(route => route.area === this.name)\n\t\t\t\tif (!routeForArea) {\n\t\t\t\t\tthrow new Error(`No route found for area: ${this.name} in pathname: ${currentPath}`)\n\t\t\t\t}\n\t\t\t\treturn routeForArea\n\t\t\t}),\n\t\t\tmap(\n\t\t\t\troute =>\n\t\t\t\t\t({\n\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\tcomponent: route.component || this.default,\n\t\t\t\t\t\tstate: route.state,\n\t\t\t\t\t\thistoryStrategy,\n\t\t\t\t\t}) as RouteAction,\n\t\t\t),\n\t\t\tcatchError(() =>\n\t\t\t\tthis.default\n\t\t\t\t\t? of({\n\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\tcomponent: this.default,\n\t\t\t\t\t\t\thistoryStrategy,\n\t\t\t\t\t\t} as RouteAction)\n\t\t\t\t\t: EMPTY,\n\t\t\t),\n\t\t)\n\t}\n\n\t/**\n\t * ORIGINAL API:\n\t * Returns an observable that emits a RouteAction based on the provided pathname.\n\t *\n\t * This method retains the original logic that parses the URL.\n\t *\n\t * @param pathname - Pathname from the browser location API.\n\t * @param historyStrategy - The history strategy to use for the route (PUSH, REPLACE, SILENT).\n\t * @returns An observable emitting the RouteAction.\n\t */\n\tgetComponentFromPathname(pathname: string, historyStrategy: HISTORY_STRATEGY) {\n\t\treturn of(pathname).pipe(\n\t\t\tmap(path => path.split('/').pop() ?? ''),\n\t\t\tmap(path => decodeURIComponent(path)),\n\t\t\tmap(path => JSON.parse(path)),\n\t\t\tmap(routes => routes[this.name] as TRouteArea),\n\t\t\tmap(component =>\n\t\t\t\t!component && this.default\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tcomponent: this.default,\n\t\t\t\t\t\t\tstate: undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t: component,\n\t\t\t),\n\t\t\tfilter(x => isPresent(x)),\n\t\t\tmap((component: TRouteArea) => ({\n\t\t\t\tarea: this.name,\n\t\t\t\tcomponent: component.component ?? this.default,\n\t\t\t\tstate: component.state,\n\t\t\t\thistoryStrategy,\n\t\t\t})),\n\t\t\tmap(x => x as RouteAction),\n\t\t\tcatchError(() => {\n\t\t\t\treturn this.default\n\t\t\t\t\t? of({\n\t\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t\t\tcomponent: this.default,\n\t\t\t\t\t\t\thistoryStrategy,\n\t\t\t\t\t\t} as RouteAction)\n\t\t\t\t\t: EMPTY\n\t\t\t}),\n\t\t)\n\t}\n\n\t/**\n\t * The original routing pipeline remains intact.\n\t * It uses getComponentFromPathname to resolve the route based on the URL.\n\t */\n\tprotected firstUpdated(): void {\n\t\tif (!this.name) {\n\t\t\t// TODO: maybe enforce this to be unique\n\t\t\tthrow new Error('Area name or default component not set')\n\t\t}\n\n\t\tmerge(\n\t\t\t// 1) Initial load from location.pathname.\n\t\t\tof(location.pathname).pipe(\n\t\t\t\tswitchMap(pathname => this.getComponentFromPathname(pathname, HISTORY_STRATEGY.silent)),\n\t\t\t\ttake(1),\n\t\t\t),\n\t\t\t// 2) Requests to change the route for this area.\n\t\t\tarea.request.pipe(filter(({ area }) => area === this.name)),\n\t\t\t// 3) Popstate events (back, forward).\n\t\t\tfromEvent<PopStateEvent>(window, 'popstate').pipe(\n\t\t\t\tmap(e => (e.target as Window).location.pathname),\n\t\t\t\tswitchMap(pathname => this.getComponentFromPathname(pathname, HISTORY_STRATEGY.silent)),\n\t\t\t),\n\t\t)\n\t\t\t.pipe(\n\t\t\t\tfilter(request => !!request.component),\n\t\t\t\ttakeUntil(this.disconnecting),\n\t\t\t\tdistinctUntilChanged((a, b) => {\n\t\t\t\t\tlet aComponent, bComponent\n\t\t\t\t\tif (typeof a.component === 'function') return false\n\t\t\t\t\telse if (typeof a.component === 'string') aComponent = a.component\n\n\t\t\t\t\tif (typeof b.component === 'function') return false\n\t\t\t\t\telse if (typeof b.component === 'string') bComponent = b.component\n\n\t\t\t\t\treturn bComponent?.replaceAll('-', '').toLowerCase() === aComponent?.replaceAll('-', '').toLowerCase()\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.pipe(\n\t\t\t\tswitchMap(route => {\n\t\t\t\t\tconst c = route.component\n\t\t\t\t\tif (c instanceof Promise) {\n\t\t\t\t\t\t// Dynamic import module.\n\t\t\t\t\t\treturn from(c).pipe(\n\t\t\t\t\t\t\tmap(x => ({\n\t\t\t\t\t\t\t\tcomponent: x.exports.default as CustomElementConstructor,\n\t\t\t\t\t\t\t\troute,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t)\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Already a string, function, or element.\n\t\t\t\t\t\treturn of({ component: c, route })\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tmap(({ component, route }) => {\n\t\t\t\t\tif (typeof component === 'string') {\n\t\t\t\t\t\t// Tag name.\n\t\t\t\t\t\treturn { component: document.createElement(component), route }\n\t\t\t\t\t} else if (component instanceof HTMLElement) {\n\t\t\t\t\t\t// Already an element instance.\n\t\t\t\t\t\treturn { component, route }\n\t\t\t\t\t} else if (typeof component === 'function') {\n\t\t\t\t\t\t// Custom element constructor.\n\t\t\t\t\t\treturn { component: new component(), route }\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\tdistinctUntilChanged((prev, curr) => prev.component.tagName === curr.component.tagName),\n\t\t\t\t// Create the new view and add it to the DOM.\n\t\t\t\tmap(({ component, route }) => {\n\t\t\t\t\tconst oldView = this.shadowRoot?.children[0]\n\t\t\t\t\tconst oldViewExists = !!oldView\n\n\t\t\t\t\t// Remove the old view (if any).\n\t\t\t\t\toldView.remove()\n\t\t\t\t\t// Native Web Animations API - fade in.\n\t\t\t\t\tcomponent.classList.add('opacity-0')\n\t\t\t\t\tthis.shadowRoot?.append(component)\n\t\t\t\t\tcomponent.animate([{ opacity: 0 }, { opacity: 1 }], {\n\t\t\t\t\t\tduration: oldViewExists ? 150 : 100,\n\t\t\t\t\t\teasing: 'cubic-bezier(0.25, 0.8, 0.25, 1)',\n\t\t\t\t\t\tfill: 'forwards',\n\t\t\t\t\t})\n\n\t\t\t\t\treturn { component, route }\n\t\t\t\t}),\n\t\t\t\ttap(({ component, route }) => {\n\t\t\t\t\t// Handle history updates.\n\t\t\t\t\tif (typeof route.historyStrategy === 'undefined' || route.historyStrategy === 'push') {\n\t\t\t\t\t\thistory.pushState(route.state, '', this.newPath(component.tagName, route))\n\t\t\t\t\t} else if (route.historyStrategy && ['replace', 'pop'].includes(route.historyStrategy)) {\n\t\t\t\t\t\thistory.replaceState(route.state, '', this.newPath(component.tagName, route))\n\t\t\t\t\t}\n\t\t\t\t\tarea.current.set(this.name, {\n\t\t\t\t\t\tcomponent: component.tagName,\n\t\t\t\t\t\tstate: route.state,\n\t\t\t\t\t\tarea: this.name,\n\t\t\t\t\t})\n\n\t\t\t\t\tarea.$current.next(area.current)\n\t\t\t\t}),\n\t\t\t\ttakeUntil(this.disconnecting),\n\t\t\t)\n\t\t\t.subscribe()\n\t}\n\n\t/**\n\t * Computes the new URL path for the given component and route.\n\t */\n\tnewPath(tag: string, route: RouteAction) {\n\t\tconst oldPathname = location.pathname.split('/').pop()\n\t\tlet oldAreaState = {}\n\t\ttry {\n\t\t\toldAreaState = oldPathname ? JSON.parse(decodeURIComponent(oldPathname)) : {}\n\t\t} catch {\n\t\t\toldAreaState = {}\n\t\t}\n\t\troute.state = route.state ?? {}\n\t\tconst queryParams = route.clearQueryParams ? this.queryParamClear(route.clearQueryParams) : document.location.search\n\n\t\treturn encodeURIComponent(\n\t\t\tJSON.stringify({\n\t\t\t\t...oldAreaState,\n\t\t\t\t[this.name]: { component: tag.toLowerCase(), state: route.state },\n\t\t\t}),\n\t\t).concat(`${queryParams}`)\n\t}\n\n\t/**\n\t * Removes specified query parameters from the current URL.\n\t */\n\tqueryParamClear(params?: string[]) {\n\t\tif (!params) {\n\t\t\treturn ''\n\t\t}\n\t\t// Get query params from URL.\n\t\tconst urlParams = new URLSearchParams(location.search)\n\t\t// Remove query params.\n\t\tparams.forEach(param => urlParams.delete(param))\n\t\tif (urlParams.toString() === '') return ''\n\t\treturn `?${urlParams.toString()}`\n\t}\n\n\t/**\n\t * Checks for teleportation requests (FLIP_REQUEST events) and dispatches a FLIP_STARTED event.\n\t */\n\tcheckForTeleportationRequests() {\n\t\treturn fromEvent<CustomEvent>(window, 'FLIP_REQUEST').pipe(\n\t\t\tmap(e => e.detail),\n\t\t\ttap(() => {\n\t\t\t\tthis.dispatchEvent(new CustomEvent('FLIP_STARTED'))\n\t\t\t}),\n\t\t\ttimeout(0),\n\t\t\tcatchError(() => of(null)),\n\t\t\ttakeUntil(this.disconnecting),\n\t\t)\n\t}\n\n\tdisconnectedCallback(): void {\n\t\tsuper.disconnectedCallback()\n\t\tthis.disconnecting.next(true)\n\t}\n\n\trender() {\n\t\treturn html` <slot> </slot> `\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'schmancy-area': SchmancyArea\n\t}\n}\n"],"names":["routerHistory","Subject","FINDING_MORTIES","HERE_RICKY","AreaService","constructor","this","prettyURL","mode","request","ReplaySubject","current","Map","$current","enableHistoryMode","findingMortiesEvent","CustomEvent","next","find","zip","fromEvent","window","pipe","map","e","detail","bufferTime","tap","console","log","of","dispatchEvent","component","timeout","r","name","newState","JSON","parse","stringify","area","state","history","replaceState","encodeURIComponent","instance","pathname","location","split","pop","areaState","decodeURIComponent","getInstance","HISTORY_STRATEGY","SchmancyArea","$LitElement","css","super","arguments","mappings","historyStrategy","currentPath","mapping","m","Error","routeForArea","routes","route","default","catchError","EMPTY","path","filter","x","isPresent","merge","switchMap","getComponentFromPathname","silent","take","target","takeUntil","disconnecting","distinctUntilChanged","a","b","aComponent","bComponent","replaceAll","toLowerCase","c","Promise","from","exports","t","o","document","createElement","HTMLElement","prev","curr","tagName","oldView","shadowRoot","children","oldViewExists","remove","classList","add","append","animate","opacity","duration","easing","fill","pushState","newPath","includes","set","subscribe","tag","oldPathname","oldAreaState","queryParams","clearQueryParams","queryParamClear","search","concat","params","urlParams","URLSearchParams","forEach","param","delete","toString","disconnectedCallback","html","__decorateClass","property","prototype","type","Array","customElement"],"mappings":";;;;;;;;AAIa,MAAAA,IAAgB,IAAIC,KAEpBC,IAAkB,mBAClBC,IAAa;AAQ1B,MAAMC,EAAAA;AAAAA,EAUL,cAAAC;AARAC,SAAOC,YAAAA,IACPD,KAAOE,OAA6B,WAC7BF,KAAAG,UAAU,IAAIC,EAA2B,CAAA,GACzCJ,KAAAK,8BAAcC,OACdN,KAAAO,WAAW,IAAIH,EAAwC,IAC9DJ,KAAOQ,oBAAAA,IACCR,KAAAS,sBAAsB,IAAIC,YAA6Cd,CAAAA,GAGzEI,KAAAO,SAASI,KAAKX,KAAKK,OAAO;AAAA,EAAA;AAAA,EAGhC,OAAAO;AACC,WAAOC,EAAI,CACVC,EAA4BC,QAAQlB,CAAYmB,EAAAA,KAC/CC,EAASC,OAAAA,EAAEC,MAAAA,GACXC,EAAW,CAAA,GACXC,EAAIC,QAAQC,GAEbC,CAAAA,GAAAA,EAAG,GAAGR,KAAKK,EAAI,MAAMN,OAAOU,cAAczB,KAAKS,mBAC7CO,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,KACFC,EAAI,CAAA,CAAES,CAAeA,MAAAA,CAAAA,GACrBC,EAAQ,CAAA,CAAA;AAAA,EACT;AAAA,EAGD,KAAKC,GACC5B;AAAAA,SAAAG,QAAQQ,KAAKiB,CAAC;AAAA,EAAA;AAAA,EAGpB,IAAIC,GAC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AAA,IAAe,CAEnDiB,GAAAA,EAAQ,IACRoC,EAAW,MAAMvC,EAAG,IAAA,CAAA,GACpBmD,EAAU3E,KAAK4E,aAChB,CAAA;AAAA,EAAA;AAAA,EAGD,uBACCzB;AAAAA,UAAM8E,qBACDjI,GAAAA,KAAA4E,cAAcjE,KAAK,EAAA;AAAA,EAAI;AAAA,EAG7B;AACQ,WAAAuH;AAAAA,EAAA;AAAA;AA5RIC,EAAA,CAAXC,EAdWpF,CAAAA,GAAAA,EAcAqF,WAAA,QAAA,CAAA,GAKAF,EAAA,CAAXC,MAnBWpF,EAmBAqF,WAAA,WAAA,CAAA,GAyBeF,EAAA,CAA1BC,EAAS,EAAEE,MAAMC,MA5CNvF,CAAAA,CAAAA,GAAAA,EA4CeqF,WAAA,YAAA,IA5CfrF,IAANmF,EAAA,CADNK,EAAc,mBACFxF;"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";require("rxjs"),require("lit/directives/class-map.js"),require("lit/directives/style-map.js");const p=require("./litElement.mixin-PVEJyATw.cjs");require("./tailwind.mixin-BM-bjRjT.cjs");const h=require("lit"),d=require("lit/decorators.js"),m=require("lit/directives/if-defined.js"),s=require("moment");function u(e,t){if(!e)return null;const a=s(e);return a.isValid()?a.format(t):null}var y=Object.defineProperty,g=Object.getOwnPropertyDescriptor,c=(e,t,a,r)=>{for(var n,o=r>1?void 0:r?g(t,a):t,l=e.length-1;l>=0;l--)(n=e[l])&&(o=(r?n(t,a,o):n(o))||o);return r&&o&&y(t,a,o),o};let i=class extends p.$LitElement(){constructor(){super(...arguments),this.type="date",this.selectedDateRange="Today"}connectedCallback(){super.connectedCallback(),this.initPresetRanges();const e=this.getDateFormat(),t=function(a,r,n){const o=u(a,n),l=u(r,n);return{dateFrom:o,dateTo:l,isValid:o!==null&&l!==null}}(this.dateFrom.value,this.dateTo.value,e);if(t.isValid)this.dateFrom.value=t.dateFrom,this.dateTo.value=t.dateTo,this.updateSelectedDateRange();else{const a=s().format(e);this.dateFrom.value=a,this.dateTo.value=a}}setDateRange(e,t){this.dateFrom.value=e,this.dateTo.value=t,this.dispatchEvent(new CustomEvent("change",{detail:{dateFrom:e,dateTo:t},bubbles:!0,composed:!0})),this.requestUpdate()}updated(e){e.has("type")&&(this.initPresetRanges(),this.updateSelectedDateRange())}getDateFormat(){return this.type==="date"?"YYYY-MM-DD":"YYYY-MM-DDTHH:mm"}getDisplayFormat(){return this.type==="date"?"MMM DD, YYYY":"MMM DD, YYYY hh:mm A"}initPresetRanges(){const e=this.getDateFormat();this.presetRanges=[{label:"Yesterday",range:{dateFrom:s().subtract(1,"days").startOf("day").format(e),dateTo:s().subtract(1,"days").endOf("day").format(e)},step:"day"},{label:"Today",range:{dateFrom:s().startOf("day").format(e),dateTo:s().endOf("day").format(e)},step:"day"},{label:"Tomorrow",range:{dateFrom:s().add(1,"days").startOf("day").format(e),dateTo:s().add(1,"days").endOf("day").format(e)},step:"day"},{label:"This Week",range:{dateFrom:s().startOf("isoWeek").format(e),dateTo:s().endOf("isoWeek").format(e)},step:"week"},{label:"Last Week",range:{dateFrom:s().subtract(1,"weeks").startOf("isoWeek").format(e),dateTo:s().subtract(1,"weeks").endOf("isoWeek").format(e)},step:"week"},{label:"This Month",range:{dateFrom:s().startOf("month").format(e),dateTo:s().endOf("month").format(e)},step:"month"}]}updateSelectedDateRange(){const e=this.presetRanges.find(t=>t.range.dateFrom===this.dateFrom.value&&t.range.dateTo===this.dateTo.value);if(e)this.selectedDateRange=e.label;else{const t=s(this.dateFrom.value),a=s(this.dateTo.value);if(t.isSame(a,"day"))this.selectedDateRange=t.format("MMM DD, YYYY"),t.format("HH:mm")==="00:00"&&a.format("HH:mm")==="23:59"||(this.selectedDateRange+=` ${t.format("HH:mm")}:${a.format("HH:mm")}`);else{const r=t.format(this.getDisplayFormat()),n=a.format(this.getDisplayFormat());this.selectedDateRange=`${r} - ${n}`}}}handlePresetChange(e){const t=this.presetRanges.find(n=>n.label===e);if(!t)return;const{dateFrom:a,dateTo:r}=t.range;this.setDateRange(a,r),this.selectedDateRange=e}shiftDateRange(e,t){t.stopPropagation();const a=this.getDateFormat(),r=s(this.dateTo.value).diff(s(this.dateFrom.value),"days")||1,n=s(this.dateFrom.value).add(e*r,"days").format(a),o=s(this.dateTo.value).add(e*r,"days").format(a);this.setDateRange(n,o),this.updateSelectedDateRange()}handleDateRangeChange(e){e.stopPropagation(),this.setDateRange(this.dateFrom.value,this.dateTo.value),this.updateSelectedDateRange()}render(){return h.html`
|
|
2
|
-
<!-- schmancy-menu typically provides a slot="button" for the trigger,
|
|
3
|
-
and then projects the menu items inside. -->
|
|
4
|
-
<schmancy-menu class="z-100 w-max" role="menu" aria-label="Date range presets and custom input">
|
|
5
|
-
<!-- The toggle/trigger slot -->
|
|
6
|
-
<schmancy-grid slot="button" align="center" cols="auto 1fr auto">
|
|
7
|
-
<schmancy-icon-button
|
|
8
|
-
type="button"
|
|
9
|
-
aria-label="Shift date range backward"
|
|
10
|
-
@click=${e=>{this.shiftDateRange(-1,e)}}
|
|
11
|
-
>
|
|
12
|
-
arrow_left
|
|
13
|
-
</schmancy-icon-button>
|
|
14
|
-
|
|
15
|
-
<schmancy-button
|
|
16
|
-
class="w-max"
|
|
17
|
-
variant="outlined"
|
|
18
|
-
type="button"
|
|
19
|
-
aria-haspopup="menu"
|
|
20
|
-
.ariaExpanded=${String(!1)}
|
|
21
|
-
>
|
|
22
|
-
${this.selectedDateRange||"Date range"}
|
|
23
|
-
</schmancy-button>
|
|
24
|
-
|
|
25
|
-
<schmancy-icon-button
|
|
26
|
-
type="button"
|
|
27
|
-
aria-label="Shift date range forward"
|
|
28
|
-
@click=${e=>{this.shiftDateRange(1,e)}}
|
|
29
|
-
>
|
|
30
|
-
arrow_right
|
|
31
|
-
</schmancy-icon-button>
|
|
32
|
-
</schmancy-grid>
|
|
33
|
-
|
|
34
|
-
<!-- The menu surface: presets + manual date selection -->
|
|
35
|
-
${this.presetRanges.map(e=>h.html`
|
|
36
|
-
<schmancy-menu-item role="menuitem" class="w-full" @click=${()=>this.handlePresetChange(e.label)}>
|
|
37
|
-
<schmancy-grid class="w-full" align="center" cols="auto 1fr auto"> ${e.label} </schmancy-grid>
|
|
38
|
-
</schmancy-menu-item>
|
|
39
|
-
`)}
|
|
40
|
-
|
|
41
|
-
<!-- Manual date range inputs + "Apply" button -->
|
|
42
|
-
<schmancy-grid gap="sm" flow="row" class="p-4">
|
|
43
|
-
<schmancy-input
|
|
44
|
-
id="checkin"
|
|
45
|
-
.type=${this.type}
|
|
46
|
-
.label=${this.dateFrom.label}
|
|
47
|
-
.value=${this.dateFrom.value}
|
|
48
|
-
min=${m.ifDefined(this.minDate)}
|
|
49
|
-
@change=${e=>{e.preventDefault(),e.stopPropagation();const t=this.getDateFormat(),a=s(e.detail.value,t).format(t);this.dateFrom.value=a,this.checkOutInput.setAttribute("min",a)}}
|
|
50
|
-
></schmancy-input>
|
|
51
|
-
|
|
52
|
-
<schmancy-input
|
|
53
|
-
id="checkout"
|
|
54
|
-
.type=${this.type}
|
|
55
|
-
.label=${this.dateTo.label}
|
|
56
|
-
.value=${this.dateTo.value}
|
|
57
|
-
min=${m.ifDefined(this.dateFrom.value)}
|
|
58
|
-
max=${m.ifDefined(this.maxDate)}
|
|
59
|
-
@change=${e=>{e.preventDefault(),e.stopPropagation();const t=this.getDateFormat(),a=s(e.detail.value,t).format(t);this.dateTo.value=a}}
|
|
60
|
-
></schmancy-input>
|
|
61
|
-
|
|
62
|
-
<schmancy-button
|
|
63
|
-
type="button"
|
|
64
|
-
variant="outlined"
|
|
65
|
-
@click=${e=>{this.handleDateRangeChange(e)}}
|
|
66
|
-
>
|
|
67
|
-
Apply
|
|
68
|
-
</schmancy-button>
|
|
69
|
-
</schmancy-grid>
|
|
70
|
-
</schmancy-menu>
|
|
71
|
-
`}};c([d.property({type:String})],i.prototype,"type",2),c([d.property({type:Object})],i.prototype,"dateFrom",2),c([d.property({type:Object})],i.prototype,"dateTo",2),c([d.property({type:String})],i.prototype,"minDate",2),c([d.property({type:String})],i.prototype,"maxDate",2),c([d.query("#checkin")],i.prototype,"checkInInput",2),c([d.query("#checkout")],i.prototype,"checkOutInput",2),c([d.query("schmancy-menu")],i.prototype,"schmancyMenu",2),c([d.state()],i.prototype,"selectedDateRange",2),i=c([d.customElement("schmancy-date-range")],i);
|
|
72
|
-
//# sourceMappingURL=date-range-CH-IKoMW.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date-range-CH-IKoMW.cjs","sources":["../src/date-range/date-utils.ts","../src/date-range/date-range.ts"],"sourcesContent":["import moment from 'moment'\n\ntype DateFormat = 'YYYY-MM-DD' | 'YYYY-MM-DDTHH:mm'\n\n/**\n * Ensures that a date string conforms to a specific format.\n * If the date is already in the correct format, it returns the original string.\n * If the date is in a different format, it attempts to convert it to the specified format.\n * If the date is invalid or cannot be converted, it returns null.\n *\n * @param dateString The date string to validate and format.\n * @param expectedFormat The expected date format (e.g., 'YYYY-MM-DD', 'YYYY-MM-DDTHH:mm').\n * @returns The formatted date string, or null if the date is invalid.\n */\nfunction enforceDateFormat(dateString: string | undefined, expectedFormat: DateFormat): string | null {\n\tif (!dateString) {\n\t\treturn null // Or handle the undefined case differently if needed\n\t}\n\n\tconst parsedDate = moment(dateString)\n\n\tif (!parsedDate.isValid()) {\n\t\treturn null // Date is invalid\n\t}\n\n\treturn parsedDate.format(expectedFormat)\n}\n\n/**\n * Validates if the initial date range values are in the expected format.\n *\n * @param dateFrom The dateFrom value to validate.\n * @param dateTo The dateTo value to validate.\n * @param expectedFormat The expected date format.\n * @returns An object indicating whether each date is valid, and the formatted date or null if invalid.\n */\nfunction validateInitialDateRange(\n\tdateFrom: string | undefined,\n\tdateTo: string | undefined,\n\texpectedFormat: DateFormat,\n): {\n\tdateFrom: string | null\n\tdateTo: string | null\n\tisValid: boolean\n} {\n\tconst formattedDateFrom = enforceDateFormat(dateFrom, expectedFormat)\n\tconst formattedDateTo = enforceDateFormat(dateTo, expectedFormat)\n\n\tconst isValid = formattedDateFrom !== null && formattedDateTo !== null\n\n\treturn {\n\t\tdateFrom: formattedDateFrom,\n\t\tdateTo: formattedDateTo,\n\t\tisValid,\n\t}\n}\n\nexport { validateInitialDateRange }\n","import { $LitElement } from '@mixins/index'\nimport { SchmancyInputChangeEvent } from '@schmancy/input'\nimport SchmancyMenu from '@schmancy/menu/menu'\nimport { html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport moment from 'moment'\nimport { validateInitialDateRange } from './date-utils' // Import the utility\n\ntype DateFormat = 'YYYY-MM-DD' | 'YYYY-MM-DDTHH:mm'\n\n/**\n * A date range selector that supports presets and manual date input.\n */\n@customElement('schmancy-date-range')\nexport default class SchmancyDateRange extends $LitElement() {\n\t// Either \"date\" or \"datetime-local\"\n\t@property({ type: String }) type: 'date' | 'datetime-local' = 'date'\n\n\t@property({ type: Object }) dateFrom!: { label: string; value: string }\n\t@property({ type: Object }) dateTo!: { label: string; value: string }\n\n\t// Optional min/max constraints\n\t@property({ type: String }) minDate?: string\n\t@property({ type: String }) maxDate?: string\n\n\t@query('#checkin') checkInInput!: HTMLInputElement\n\t@query('#checkout') checkOutInput!: HTMLInputElement\n\n\t// The <schmancy-menu> that displays presets + manual date inputs\n\t@query('schmancy-menu') schmancyMenu!: SchmancyMenu\n\n\t// Display text in the trigger button\n\t@state() selectedDateRange: string = 'Today'\n\n\t// Preset date range definitions\n\tpresetRanges!: Array<{\n\t\tlabel: string\n\t\trange: { dateFrom: string; dateTo: string }\n\t\tstep: moment.unitOfTime.DurationConstructor\n\t}>\n\n\tconnectedCallback(): void {\n\t\tsuper.connectedCallback()\n\t\tthis.initPresetRanges()\n\n\t\t// Validate and format initial date range\n\t\tconst dateFormat = this.getDateFormat() as DateFormat\n\t\tconst validatedRange = validateInitialDateRange(this.dateFrom.value, this.dateTo.value, dateFormat)\n\n\t\tif (validatedRange.isValid) {\n\t\t\tthis.dateFrom.value = validatedRange.dateFrom!\n\t\t\tthis.dateTo.value = validatedRange.dateTo!\n\t\t\tthis.updateSelectedDateRange()\n\t\t} else {\n\t\t\tconsole.error('Invalid initial date range. Falling back to default.')\n\t\t\t// Handle invalid initial dates (e.g., set to default values, display an error)\n\t\t\tconst now = moment().format(dateFormat)\n\t\t\tthis.dateFrom.value = now\n\t\t\tthis.dateTo.value = now\n\t\t}\n\t}\n\t/**\n\t * Update the internal date range and fire a 'change' event to notify external code.\n\t */\n\tprivate setDateRange(fromDate: string, toDate: string) {\n\t\tthis.dateFrom.value = fromDate\n\t\tthis.dateTo.value = toDate\n\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent<TSchmancDateRangePayload>('change', {\n\t\t\t\tdetail: { dateFrom: fromDate, dateTo: toDate },\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true, // If you want it to pass shadow boundaries\n\t\t\t}),\n\t\t)\n\t\tthis.requestUpdate()\n\t}\n\tupdated(changedProps: Map<string, unknown>) {\n\t\tif (changedProps.has('type')) {\n\t\t\t// Re-init presets if \"type\" changes from date -> datetime\n\t\t\tthis.initPresetRanges()\n\t\t\tthis.updateSelectedDateRange()\n\t\t}\n\t}\n\n\t/**\n\t * Format strings for the internal <input> and for display text.\n\t */\n\tprivate getDateFormat(): string {\n\t\treturn this.type === 'date' ? 'YYYY-MM-DD' : 'YYYY-MM-DDTHH:mm'\n\t}\n\tprivate getDisplayFormat(): string {\n\t\treturn this.type === 'date' ? 'MMM DD, YYYY' : 'MMM DD, YYYY hh:mm A'\n\t}\n\n\t/**\n\t * Build up a list of preset ranges (yesterday, today, etc.).\n\t */\n\tprivate initPresetRanges() {\n\t\tconst format = this.getDateFormat()\n\t\tthis.presetRanges = [\n\t\t\t{\n\t\t\t\tlabel: 'Yesterday',\n\t\t\t\trange: {\n\t\t\t\t\tdateFrom: moment().subtract(1, 'days').startOf('day').format(format),\n\t\t\t\t\tdateTo: moment().subtract(1, 'days').endOf('day').format(format),\n\t\t\t\t},\n\t\t\t\tstep: 'day',\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: 'Today',\n\t\t\t\trange: {\n\t\t\t\t\tdateFrom: moment().startOf('day').format(format),\n\t\t\t\t\tdateTo: moment().endOf('day').format(format),\n\t\t\t\t},\n\t\t\t\tstep: 'day',\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: 'Tomorrow',\n\t\t\t\trange: {\n\t\t\t\t\tdateFrom: moment().add(1, 'days').startOf('day').format(format),\n\t\t\t\t\tdateTo: moment().add(1, 'days').endOf('day').format(format),\n\t\t\t\t},\n\t\t\t\tstep: 'day',\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: 'This Week',\n\t\t\t\trange: {\n\t\t\t\t\tdateFrom: moment().startOf('isoWeek').format(format),\n\t\t\t\t\tdateTo: moment().endOf('isoWeek').format(format),\n\t\t\t\t},\n\t\t\t\tstep: 'week',\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: 'Last Week',\n\t\t\t\trange: {\n\t\t\t\t\tdateFrom: moment().subtract(1, 'weeks').startOf('isoWeek').format(format),\n\t\t\t\t\tdateTo: moment().subtract(1, 'weeks').endOf('isoWeek').format(format),\n\t\t\t\t},\n\t\t\t\tstep: 'week',\n\t\t\t},\n\t\t\t{\n\t\t\t\tlabel: 'This Month',\n\t\t\t\trange: {\n\t\t\t\t\tdateFrom: moment().startOf('month').format(format),\n\t\t\t\t\tdateTo: moment().endOf('month').format(format),\n\t\t\t\t},\n\t\t\t\tstep: 'month',\n\t\t\t},\n\t\t\t// Add more if desired (e.g. \"Last Month,\" \"Custom,\" etc.)\n\t\t]\n\t}\n\n\t/**\n\t * Based on the current dateFrom/dateTo, see if it matches a preset.\n\t * Otherwise display a \"Custom\" range: \"Jan 01, 2023 - Jan 07, 2023\".\n\t */\n\tprivate updateSelectedDateRange() {\n\t\tconst preset = this.presetRanges.find(\n\t\t\tp => p.range.dateFrom === this.dateFrom.value && p.range.dateTo === this.dateTo.value,\n\t\t)\n\t\tif (preset) {\n\t\t\tthis.selectedDateRange = preset.label\n\t\t} else {\n\t\t\t// Construct a custom label\n\t\t\tconst fromMoment = moment(this.dateFrom.value)\n\t\t\tconst toMoment = moment(this.dateTo.value)\n\t\t\tconsole.log(fromMoment.format('HH:mm'), toMoment.format('HH:mm'), fromMoment.format('HH:mm'))\n\t\t\tif (fromMoment.isSame(toMoment, 'day')) {\n\t\t\t\tthis.selectedDateRange = fromMoment.format('MMM DD, YYYY')\n\t\t\t\t// append the time if fromMoment is not the start of the day and toMoment is not the end of the day\n\t\t\t\tif (fromMoment.format('HH:mm') !== '00:00' || toMoment.format('HH:mm') !== '23:59') {\n\t\t\t\t\tthis.selectedDateRange += ` ${fromMoment.format('HH:mm')}:${toMoment.format('HH:mm')}`\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst fromStr = fromMoment.format(this.getDisplayFormat())\n\t\t\t\tconst toStr = toMoment.format(this.getDisplayFormat())\n\t\t\t\tthis.selectedDateRange = `${fromStr} - ${toStr}`\n\t\t\t}\n\t\t}\n\t}\n\tprivate handlePresetChange(label: string) {\n\t\tconst preset = this.presetRanges.find(range => range.label === label)\n\t\tif (!preset) return\n\t\tconst { dateFrom, dateTo } = preset.range\n\t\tthis.setDateRange(dateFrom, dateTo)\n\t\tthis.selectedDateRange = label\n\t}\n\n\t/**\n\t * Shift the current date range forward or backward by the same number of days.\n\t * If the range is 7 days wide, shift 7 days, etc.\n\t */\n\tprivate shiftDateRange(factor: number, event: Event) {\n\t\tevent.stopPropagation() // Prevent click from bubbling to the schmancy-button\n\n\t\tconst format = this.getDateFormat()\n\t\tconst currentDiff = moment(this.dateTo.value).diff(moment(this.dateFrom.value), 'days') || 1\n\t\tconst newDateFrom = moment(this.dateFrom.value)\n\t\t\t.add(factor * currentDiff, 'days')\n\t\t\t.format(format)\n\t\tconst newDateTo = moment(this.dateTo.value)\n\t\t\t.add(factor * currentDiff, 'days')\n\t\t\t.format(format)\n\n\t\tthis.setDateRange(newDateFrom, newDateTo)\n\t\tthis.updateSelectedDateRange()\n\t}\n\n\t/**\n\t * Applies the date range from the inputs.\n\t * Closes the menu when done.\n\t */\n\tprivate handleDateRangeChange(event: Event) {\n\t\tevent.stopPropagation() // Prevent click from bubbling to the schmancy-button\n\t\tthis.setDateRange(this.dateFrom.value, this.dateTo.value)\n\t\tthis.updateSelectedDateRange()\n\t}\n\n\trender() {\n\t\treturn html`\n\t\t\t<!-- schmancy-menu typically provides a slot=\"button\" for the trigger,\n and then projects the menu items inside. -->\n\t\t\t<schmancy-menu class=\"z-100 w-max\" role=\"menu\" aria-label=\"Date range presets and custom input\">\n\t\t\t\t<!-- The toggle/trigger slot -->\n\t\t\t\t<schmancy-grid slot=\"button\" align=\"center\" cols=\"auto 1fr auto\">\n\t\t\t\t\t<schmancy-icon-button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\taria-label=\"Shift date range backward\"\n\t\t\t\t\t\t@click=${(e: Event) => {\n\t\t\t\t\t\t\tthis.shiftDateRange(-1, e) // Pass the event\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\tarrow_left\n\t\t\t\t\t</schmancy-icon-button>\n\n\t\t\t\t\t<schmancy-button\n\t\t\t\t\t\tclass=\"w-max\"\n\t\t\t\t\t\tvariant=\"outlined\"\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\taria-haspopup=\"menu\"\n\t\t\t\t\t\t.ariaExpanded=${String(false)}\n\t\t\t\t\t>\n\t\t\t\t\t\t${this.selectedDateRange || 'Date range'}\n\t\t\t\t\t</schmancy-button>\n\n\t\t\t\t\t<schmancy-icon-button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\taria-label=\"Shift date range forward\"\n\t\t\t\t\t\t@click=${(e: Event) => {\n\t\t\t\t\t\t\tthis.shiftDateRange(1, e) // Pass the event\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\tarrow_right\n\t\t\t\t\t</schmancy-icon-button>\n\t\t\t\t</schmancy-grid>\n\n\t\t\t\t<!-- The menu surface: presets + manual date selection -->\n\t\t\t\t${this.presetRanges.map(\n\t\t\t\t\tpreset => html`\n\t\t\t\t\t\t<schmancy-menu-item role=\"menuitem\" class=\"w-full\" @click=${() => this.handlePresetChange(preset.label)}>\n\t\t\t\t\t\t\t<schmancy-grid class=\"w-full\" align=\"center\" cols=\"auto 1fr auto\"> ${preset.label} </schmancy-grid>\n\t\t\t\t\t\t</schmancy-menu-item>\n\t\t\t\t\t`,\n\t\t\t\t)}\n\n\t\t\t\t<!-- Manual date range inputs + \"Apply\" button -->\n\t\t\t\t<schmancy-grid gap=\"sm\" flow=\"row\" class=\"p-4\">\n\t\t\t\t\t<schmancy-input\n\t\t\t\t\t\tid=\"checkin\"\n\t\t\t\t\t\t.type=${this.type}\n\t\t\t\t\t\t.label=${this.dateFrom.label}\n\t\t\t\t\t\t.value=${this.dateFrom.value}\n\t\t\t\t\t\tmin=${ifDefined(this.minDate)}\n\t\t\t\t\t\t@change=${(event: SchmancyInputChangeEvent) => {\n\t\t\t\t\t\t\tevent.preventDefault()\n\t\t\t\t\t\t\tevent.stopPropagation()\n\t\t\t\t\t\t\tconst fmt = this.getDateFormat()\n\t\t\t\t\t\t\tconst selectedDate = moment(event.detail.value, fmt).format(fmt)\n\t\t\t\t\t\t\tthis.dateFrom.value = selectedDate\n\t\t\t\t\t\t\t// Update the checkout input's min attribute:\n\t\t\t\t\t\t\tthis.checkOutInput.setAttribute('min', selectedDate)\n\t\t\t\t\t\t}}\n\t\t\t\t\t></schmancy-input>\n\n\t\t\t\t\t<schmancy-input\n\t\t\t\t\t\tid=\"checkout\"\n\t\t\t\t\t\t.type=${this.type}\n\t\t\t\t\t\t.label=${this.dateTo.label}\n\t\t\t\t\t\t.value=${this.dateTo.value}\n\t\t\t\t\t\tmin=${ifDefined(this.dateFrom.value)}\n\t\t\t\t\t\tmax=${ifDefined(this.maxDate)}\n\t\t\t\t\t\t@change=${(event: SchmancyInputChangeEvent) => {\n\t\t\t\t\t\t\tevent.preventDefault()\n\t\t\t\t\t\t\tevent.stopPropagation()\n\t\t\t\t\t\t\tconst fmt = this.getDateFormat()\n\t\t\t\t\t\t\tconst selectedDate = moment(event.detail.value, fmt).format(fmt)\n\t\t\t\t\t\t\tthis.dateTo.value = selectedDate\n\t\t\t\t\t\t}}\n\t\t\t\t\t></schmancy-input>\n\n\t\t\t\t\t<schmancy-button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tvariant=\"outlined\"\n\t\t\t\t\t\t@click=${(e: Event) => {\n\t\t\t\t\t\t\tthis.handleDateRangeChange(e)\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\tApply\n\t\t\t\t\t</schmancy-button>\n\t\t\t\t</schmancy-grid>\n\t\t\t</schmancy-menu>\n\t\t`\n\t}\n}\n\n/**\n * The payload for a date range change event.\n */\nexport type TSchmancDateRangePayload = {\n\tdateFrom?: string\n\tdateTo?: string\n}\n\n/**\n * A custom event fired when the date range is updated.\n */\nexport type SchmancyDateRangeChangeEvent = CustomEvent<TSchmancDateRangePayload>\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'schmancy-date-range': SchmancyDateRange\n\t}\n}\n"],"names":["enforceDateFormat","dateString","expectedFormat","parsedDate","moment","isValid","format","SchmancyDateRange","$LitElement","super","arguments","this","type","selectedDateRange","connectedCallback","initPresetRanges","dateFormat","getDateFormat","validatedRange","dateFrom","dateTo","formattedDateFrom","formattedDateTo","value","updateSelectedDateRange","now","fromDate","toDate","dispatchEvent","CustomEvent","detail","bubbles","composed","requestUpdate","changedProps","has","getDisplayFormat","presetRanges","label","range","subtract","startOf","endOf","step","add","preset","find","p","fromMoment","toMoment","isSame","fromStr","toStr","setDateRange","factor","event","stopPropagation","currentDiff","diff","newDateFrom","newDateTo","html","e","shiftDateRange","String","map","handlePresetChange","ifDefined","minDate","preventDefault","fmt","selectedDate","checkOutInput","setAttribute","maxDate","handleDateRangeChange","__decorateClass","property","prototype","Object","query","state","customElement"],"mappings":"2TAcA,SAASA,EAAkBC,EAAgCC,EAAAA,CAC1D,GAAKD,CAAAA,EACG,OAAA,KAGF,MAAAE,EAAaC,EAAOH,CAEtB,EAAA,OAACE,EAAWE,QAAAA,EAITF,EAAWG,OAAOJ,CAAAA,EAHjB,IAIT,iMCXA,IAAqBK,EAArB,cAA+CC,EAAAA,YAAAA,CAAAA,CAA/C,aAAAC,CAAAA,MAAAA,GAAAC,SAE+DC,EAAAA,KAAAC,KAAA,OAgBzBD,KAAAE,kBAAA,OAAA,CASrC,mBACCJ,CAAAA,MAAMK,kBACNH,EAAAA,KAAKI,iBAGC,EAAA,MAAAC,EAAaL,KAAKM,cAAAA,EAClBC,EDZR,SACCC,EACAC,EACAlB,EAMM,CAAA,MAAAmB,EAAoBrB,EAAkBmB,EAAUjB,CAChDoB,EAAAA,EAAkBtB,EAAkBoB,EAAQlB,CAAAA,EAI3C,MAAA,CACNiB,SAAUE,EACVD,OAAQE,EACRjB,QALegB,IAAsB,MAAQC,IAAoB,IAApBA,CAO/C,ECPkDX,KAAKQ,SAASI,MAAOZ,KAAKS,OAAOG,MAAOP,CAAAA,EAExF,GAAIE,EAAeb,QACbM,KAAAQ,SAASI,MAAQL,EAAeC,SAChCR,KAAAS,OAAOG,MAAQL,EAAeE,OACnCT,KAAKa,wBACC,MAAA,CAGN,MAAMC,EAAMrB,IAASE,OAAOU,CAAAA,EAC5BL,KAAKQ,SAASI,MAAQE,EACtBd,KAAKS,OAAOG,MAAQE,CAAA,CACrB,CAKO,aAAaC,EAAkBC,EACtChB,CAAAA,KAAKQ,SAASI,MAAQG,EACtBf,KAAKS,OAAOG,MAAQI,EAEfhB,KAAAiB,cACJ,IAAIC,YAAsC,SAAU,CACnDC,OAAQ,CAAEX,SAAUO,EAAUN,OAAQO,GACtCI,QAAS,GACTC,SAAU,EAAA,CAAA,CAAA,EAGZrB,KAAKsB,cAAAA,CAAc,CAEpB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CAAAA,CAAAA,EAAAA,EAIQuE,UAAA,WAAA,CAAA,EACAF,EAAA,CAA3BC,WAAS,CAAEjE,KAAMmE,UALExE,EAKQuE,UAAA,SAAA,CAGAF,EAAAA,EAAA,CAA3BC,WAAS,CAAEjE,KAAMoD,MAAAA,CAAAA,CAAAA,EAREzD,EAQQuE,UAAA,UAAA,CACAF,EAAAA,EAAA,CAA3BC,WAAS,CAAEjE,KAAMoD,UATEzD,EASQuE,UAAA,UAAA,CAETF,EAAAA,EAAA,CAAlBI,EAAAA,MAAM,aAXazE,EAWDuE,UAAA,eAAA,CACCF,EAAAA,EAAA,CAAnBI,EAAAA,MAAM,WAZazE,CAAAA,EAAAA,EAYAuE,UAAA,gBAAA,GAGIF,EAAA,CAAvBI,EAAAA,MAAM,eAAA,CAAA,EAfazE,EAeIuE,UAAA,eAAA,GAGfF,EAAA,CAARK,EAAMA,MAlBa1E,CAAAA,EAAAA,EAkBXuE,UAAA,oBAAA,CAAA,EAlBWvE,EAArBqE,EAAA,CADCM,EAAAA,cAAc,qBACM3E,CAAAA,EAAAA,CAAAA"}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import "rxjs";
|
|
2
|
-
import "lit/directives/class-map.js";
|
|
3
|
-
import "lit/directives/style-map.js";
|
|
4
|
-
import { $ as g } from "./litElement.mixin-Dx9_p_nV.js";
|
|
5
|
-
import "./tailwind.mixin-YEy_iITN.js";
|
|
6
|
-
import { html as u } from "lit";
|
|
7
|
-
import { property as l, query as c, state as y, customElement as f } from "lit/decorators.js";
|
|
8
|
-
import { ifDefined as h } from "lit/directives/if-defined.js";
|
|
9
|
-
import s from "moment";
|
|
10
|
-
function p(t, e) {
|
|
11
|
-
if (!t) return null;
|
|
12
|
-
const a = s(t);
|
|
13
|
-
return a.isValid() ? a.format(e) : null;
|
|
14
|
-
}
|
|
15
|
-
var D = Object.defineProperty, b = Object.getOwnPropertyDescriptor, d = (t, e, a, o) => {
|
|
16
|
-
for (var n, r = o > 1 ? void 0 : o ? b(e, a) : e, m = t.length - 1; m >= 0; m--) (n = t[m]) && (r = (o ? n(e, a, r) : n(r)) || r);
|
|
17
|
-
return o && r && D(e, a, r), r;
|
|
18
|
-
};
|
|
19
|
-
let i = class extends g() {
|
|
20
|
-
constructor() {
|
|
21
|
-
super(...arguments), this.type = "date", this.selectedDateRange = "Today";
|
|
22
|
-
}
|
|
23
|
-
connectedCallback() {
|
|
24
|
-
super.connectedCallback(), this.initPresetRanges();
|
|
25
|
-
const t = this.getDateFormat(), e = function(a, o, n) {
|
|
26
|
-
const r = p(a, n), m = p(o, n);
|
|
27
|
-
return { dateFrom: r, dateTo: m, isValid: r !== null && m !== null };
|
|
28
|
-
}(this.dateFrom.value, this.dateTo.value, t);
|
|
29
|
-
if (e.isValid) this.dateFrom.value = e.dateFrom, this.dateTo.value = e.dateTo, this.updateSelectedDateRange();
|
|
30
|
-
else {
|
|
31
|
-
const a = s().format(t);
|
|
32
|
-
this.dateFrom.value = a, this.dateTo.value = a;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
setDateRange(t, e) {
|
|
36
|
-
this.dateFrom.value = t, this.dateTo.value = e, this.dispatchEvent(new CustomEvent("change", { detail: { dateFrom: t, dateTo: e }, bubbles: !0, composed: !0 })), this.requestUpdate();
|
|
37
|
-
}
|
|
38
|
-
updated(t) {
|
|
39
|
-
t.has("type") && (this.initPresetRanges(), this.updateSelectedDateRange());
|
|
40
|
-
}
|
|
41
|
-
getDateFormat() {
|
|
42
|
-
return this.type === "date" ? "YYYY-MM-DD" : "YYYY-MM-DDTHH:mm";
|
|
43
|
-
}
|
|
44
|
-
getDisplayFormat() {
|
|
45
|
-
return this.type === "date" ? "MMM DD, YYYY" : "MMM DD, YYYY hh:mm A";
|
|
46
|
-
}
|
|
47
|
-
initPresetRanges() {
|
|
48
|
-
const t = this.getDateFormat();
|
|
49
|
-
this.presetRanges = [{ label: "Yesterday", range: { dateFrom: s().subtract(1, "days").startOf("day").format(t), dateTo: s().subtract(1, "days").endOf("day").format(t) }, step: "day" }, { label: "Today", range: { dateFrom: s().startOf("day").format(t), dateTo: s().endOf("day").format(t) }, step: "day" }, { label: "Tomorrow", range: { dateFrom: s().add(1, "days").startOf("day").format(t), dateTo: s().add(1, "days").endOf("day").format(t) }, step: "day" }, { label: "This Week", range: { dateFrom: s().startOf("isoWeek").format(t), dateTo: s().endOf("isoWeek").format(t) }, step: "week" }, { label: "Last Week", range: { dateFrom: s().subtract(1, "weeks").startOf("isoWeek").format(t), dateTo: s().subtract(1, "weeks").endOf("isoWeek").format(t) }, step: "week" }, { label: "This Month", range: { dateFrom: s().startOf("month").format(t), dateTo: s().endOf("month").format(t) }, step: "month" }];
|
|
50
|
-
}
|
|
51
|
-
updateSelectedDateRange() {
|
|
52
|
-
const t = this.presetRanges.find((e) => e.range.dateFrom === this.dateFrom.value && e.range.dateTo === this.dateTo.value);
|
|
53
|
-
if (t) this.selectedDateRange = t.label;
|
|
54
|
-
else {
|
|
55
|
-
const e = s(this.dateFrom.value), a = s(this.dateTo.value);
|
|
56
|
-
if (e.isSame(a, "day")) this.selectedDateRange = e.format("MMM DD, YYYY"), e.format("HH:mm") === "00:00" && a.format("HH:mm") === "23:59" || (this.selectedDateRange += ` ${e.format("HH:mm")}:${a.format("HH:mm")}`);
|
|
57
|
-
else {
|
|
58
|
-
const o = e.format(this.getDisplayFormat()), n = a.format(this.getDisplayFormat());
|
|
59
|
-
this.selectedDateRange = `${o} - ${n}`;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
handlePresetChange(t) {
|
|
64
|
-
const e = this.presetRanges.find((n) => n.label === t);
|
|
65
|
-
if (!e) return;
|
|
66
|
-
const { dateFrom: a, dateTo: o } = e.range;
|
|
67
|
-
this.setDateRange(a, o), this.selectedDateRange = t;
|
|
68
|
-
}
|
|
69
|
-
shiftDateRange(t, e) {
|
|
70
|
-
e.stopPropagation();
|
|
71
|
-
const a = this.getDateFormat(), o = s(this.dateTo.value).diff(s(this.dateFrom.value), "days") || 1, n = s(this.dateFrom.value).add(t * o, "days").format(a), r = s(this.dateTo.value).add(t * o, "days").format(a);
|
|
72
|
-
this.setDateRange(n, r), this.updateSelectedDateRange();
|
|
73
|
-
}
|
|
74
|
-
handleDateRangeChange(t) {
|
|
75
|
-
t.stopPropagation(), this.setDateRange(this.dateFrom.value, this.dateTo.value), this.updateSelectedDateRange();
|
|
76
|
-
}
|
|
77
|
-
render() {
|
|
78
|
-
return u`
|
|
79
|
-
<!-- schmancy-menu typically provides a slot="button" for the trigger,
|
|
80
|
-
and then projects the menu items inside. -->
|
|
81
|
-
<schmancy-menu class="z-100 w-max" role="menu" aria-label="Date range presets and custom input">
|
|
82
|
-
<!-- The toggle/trigger slot -->
|
|
83
|
-
<schmancy-grid slot="button" align="center" cols="auto 1fr auto">
|
|
84
|
-
<schmancy-icon-button
|
|
85
|
-
type="button"
|
|
86
|
-
aria-label="Shift date range backward"
|
|
87
|
-
@click=${(t) => {
|
|
88
|
-
this.shiftDateRange(-1, t);
|
|
89
|
-
}}
|
|
90
|
-
>
|
|
91
|
-
arrow_left
|
|
92
|
-
</schmancy-icon-button>
|
|
93
|
-
|
|
94
|
-
<schmancy-button
|
|
95
|
-
class="w-max"
|
|
96
|
-
variant="outlined"
|
|
97
|
-
type="button"
|
|
98
|
-
aria-haspopup="menu"
|
|
99
|
-
.ariaExpanded=${String(!1)}
|
|
100
|
-
>
|
|
101
|
-
${this.selectedDateRange || "Date range"}
|
|
102
|
-
</schmancy-button>
|
|
103
|
-
|
|
104
|
-
<schmancy-icon-button
|
|
105
|
-
type="button"
|
|
106
|
-
aria-label="Shift date range forward"
|
|
107
|
-
@click=${(t) => {
|
|
108
|
-
this.shiftDateRange(1, t);
|
|
109
|
-
}}
|
|
110
|
-
>
|
|
111
|
-
arrow_right
|
|
112
|
-
</schmancy-icon-button>
|
|
113
|
-
</schmancy-grid>
|
|
114
|
-
|
|
115
|
-
<!-- The menu surface: presets + manual date selection -->
|
|
116
|
-
${this.presetRanges.map((t) => u`
|
|
117
|
-
<schmancy-menu-item role="menuitem" class="w-full" @click=${() => this.handlePresetChange(t.label)}>
|
|
118
|
-
<schmancy-grid class="w-full" align="center" cols="auto 1fr auto"> ${t.label} </schmancy-grid>
|
|
119
|
-
</schmancy-menu-item>
|
|
120
|
-
`)}
|
|
121
|
-
|
|
122
|
-
<!-- Manual date range inputs + "Apply" button -->
|
|
123
|
-
<schmancy-grid gap="sm" flow="row" class="p-4">
|
|
124
|
-
<schmancy-input
|
|
125
|
-
id="checkin"
|
|
126
|
-
.type=${this.type}
|
|
127
|
-
.label=${this.dateFrom.label}
|
|
128
|
-
.value=${this.dateFrom.value}
|
|
129
|
-
min=${h(this.minDate)}
|
|
130
|
-
@change=${(t) => {
|
|
131
|
-
t.preventDefault(), t.stopPropagation();
|
|
132
|
-
const e = this.getDateFormat(), a = s(t.detail.value, e).format(e);
|
|
133
|
-
this.dateFrom.value = a, this.checkOutInput.setAttribute("min", a);
|
|
134
|
-
}}
|
|
135
|
-
></schmancy-input>
|
|
136
|
-
|
|
137
|
-
<schmancy-input
|
|
138
|
-
id="checkout"
|
|
139
|
-
.type=${this.type}
|
|
140
|
-
.label=${this.dateTo.label}
|
|
141
|
-
.value=${this.dateTo.value}
|
|
142
|
-
min=${h(this.dateFrom.value)}
|
|
143
|
-
max=${h(this.maxDate)}
|
|
144
|
-
@change=${(t) => {
|
|
145
|
-
t.preventDefault(), t.stopPropagation();
|
|
146
|
-
const e = this.getDateFormat(), a = s(t.detail.value, e).format(e);
|
|
147
|
-
this.dateTo.value = a;
|
|
148
|
-
}}
|
|
149
|
-
></schmancy-input>
|
|
150
|
-
|
|
151
|
-
<schmancy-button
|
|
152
|
-
type="button"
|
|
153
|
-
variant="outlined"
|
|
154
|
-
@click=${(t) => {
|
|
155
|
-
this.handleDateRangeChange(t);
|
|
156
|
-
}}
|
|
157
|
-
>
|
|
158
|
-
Apply
|
|
159
|
-
</schmancy-button>
|
|
160
|
-
</schmancy-grid>
|
|
161
|
-
</schmancy-menu>
|
|
162
|
-
`;
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
d([l({ type: String })], i.prototype, "type", 2), d([l({ type: Object })], i.prototype, "dateFrom", 2), d([l({ type: Object })], i.prototype, "dateTo", 2), d([l({ type: String })], i.prototype, "minDate", 2), d([l({ type: String })], i.prototype, "maxDate", 2), d([c("#checkin")], i.prototype, "checkInInput", 2), d([c("#checkout")], i.prototype, "checkOutInput", 2), d([c("schmancy-menu")], i.prototype, "schmancyMenu", 2), d([y()], i.prototype, "selectedDateRange", 2), i = d([f("schmancy-date-range")], i);
|
|
166
|
-
//# sourceMappingURL=date-range-LMnnBclq.js.map
|