UNPKG

@zoff-tech/zt-bottom-drawer

Version:
20 lines 13.6 kB
import{printIonWarning as n}from"@utils/logging"; /*! * (C) Ionic http://ionicframework.com - MIT License */const e=(n,e)=>n.month===e.month&&n.day===e.day&&n.year===e.year;const t=(n,e)=>!!(n.year<e.year||n.year===e.year&&n.month<e.month||n.year===e.year&&n.month===e.month&&n.day!==null&&n.day<e.day);const o=(n,e)=>!!(n.year>e.year||n.year===e.year&&n.month>e.month||n.year===e.year&&n.month===e.month&&n.day!==null&&n.day>e.day);const r=(e,r,s)=>{const i=Array.isArray(e)?e:[e];for(const d of i){if(r!==undefined&&t(d,r)||s!==undefined&&o(d,s)){n("The value provided to ion-datetime is out of bounds.\n\n"+`Min: ${JSON.stringify(r)}\n`+`Max: ${JSON.stringify(s)}\n`+`Value: ${JSON.stringify(e)}`);break}}}; /*! * (C) Ionic http://ionicframework.com - MIT License */const s=n=>n%4===0&&n%100!==0||n%400===0;const i=(n,e)=>{if(e!==undefined){return e==="h23"}const t=new Intl.DateTimeFormat(n,{hour:"numeric"});const o=t.resolvedOptions();if(o.hourCycle!==undefined){return o.hourCycle==="h23"}const r=new Date("5/18/2021 00:00");const s=t.formatToParts(r);const i=s.find((n=>n.type==="hour"));if(!i){throw new Error("Hour value not found from DateTimeFormat")}return i.value==="00"};const d=(n,e)=>n===4||n===6||n===9||n===11?30:n===2?s(e)?29:28:31;const u=(n,e={month:"numeric",year:"numeric"})=>{const t=new Intl.DateTimeFormat(n,e).formatToParts(new Date);return t[0].type==="month"};const a=n=>{const e=new Intl.DateTimeFormat(n,{hour:"numeric"}).formatToParts(new Date);return e[0].type==="dayPeriod"}; /*! * (C) Ionic http://ionicframework.com - MIT License */const c=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/;const f=/^((\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/;const l=n=>{if(n===undefined){return}let e=n;if(typeof n==="string"){e=n.replace(/\[|\]|\s/g,"").split(",")}let t;if(Array.isArray(e)){t=e.map((n=>parseInt(n,10))).filter(isFinite)}else{t=[e]}return t};const m=n=>({month:parseInt(n.getAttribute("data-month"),10),day:parseInt(n.getAttribute("data-day"),10),year:parseInt(n.getAttribute("data-year"),10),dayOfWeek:parseInt(n.getAttribute("data-day-of-week"),10)});function y(n){if(Array.isArray(n)){return n.map((n=>y(n)))}let e=null;if(n!=null&&n!==""){e=f.exec(n);if(e){e.unshift(undefined,undefined);e[2]=e[3]=undefined}else{e=c.exec(n)}}if(e===null){return undefined}for(let n=1;n<8;n++){e[n]=e[n]!==undefined?parseInt(e[n],10):undefined}return{year:e[1],month:e[2],day:e[3],hour:e[4],minute:e[5],ampm:e[4]<12?"am":"pm"}}const h=(n,e,r)=>{if(e&&t(n,e)){return e}else if(r&&o(n,r)){return r}return n};const v=n=>n>=12?"pm":"am";const w=(n,e)=>{const{month:t,day:o,year:r,hour:s,minute:i}=y(n);const u=r!==null&&r!==void 0?r:e.year;const a=t!==null&&t!==void 0?t:12;return{month:a,day:o!==null&&o!==void 0?o:d(a,u),year:u,hour:s!==null&&s!==void 0?s:23,minute:i!==null&&i!==void 0?i:59}};const $=(n,e)=>{const{month:t,day:o,year:r,hour:s,minute:i}=y(n);return{month:t!==null&&t!==void 0?t:1,day:o!==null&&o!==void 0?o:1,year:r!==null&&r!==void 0?r:e.year,hour:s!==null&&s!==void 0?s:0,minute:i!==null&&i!==void 0?i:0}}; /*! * (C) Ionic http://ionicframework.com - MIT License */const p=n=>("0"+(n!==undefined?Math.abs(n):"0")).slice(-2);const T=n=>("000"+(n!==undefined?Math.abs(n):"0")).slice(-4);function O(n){if(Array.isArray(n)){return n.map((n=>O(n)))}let e="";if(n.year!==undefined){e=T(n.year);if(n.month!==undefined){e+="-"+p(n.month);if(n.day!==undefined){e+="-"+p(n.day);if(n.hour!==undefined){e+=`T${p(n.hour)}:${p(n.minute)}:00`}}}}else if(n.hour!==undefined){e=p(n.hour)+":"+p(n.minute)}return e}const I=(n,e)=>{if(e===undefined){return n}if(e==="am"){if(n===12){return 0}return n}if(n===12){return 12}return n+12};const D=n=>{const{dayOfWeek:e}=n;if(e===null||e===undefined){throw new Error("No day of week provided")}return Z(n,e)};const b=n=>{const{dayOfWeek:e}=n;if(e===null||e===undefined){throw new Error("No day of week provided")}return C(n,6-e)};const j=n=>C(n,1);const M=n=>Z(n,1);const k=n=>Z(n,7);const x=n=>C(n,7);const Z=(n,e)=>{const{month:t,day:o,year:r}=n;if(o===null){throw new Error("No day provided")}const s={month:t,day:o,year:r};s.day=o-e;if(s.day<1){s.month-=1}if(s.month<1){s.month=12;s.year-=1}if(s.day<1){const n=d(s.month,s.year);s.day=n+s.day}return s};const C=(n,e)=>{const{month:t,day:o,year:r}=n;if(o===null){throw new Error("No day provided")}const s={month:t,day:o,year:r};const i=d(t,r);s.day=o+e;if(s.day>i){s.day-=i;s.month+=1}if(s.month>12){s.month=1;s.year+=1}return s};const g=n=>{const e=n.month===1?12:n.month-1;const t=n.month===1?n.year-1:n.year;const o=d(e,t);const r=o<n.day?o:n.day;return{month:e,year:t,day:r}};const U=n=>{const e=n.month===12?1:n.month+1;const t=n.month===12?n.year+1:n.year;const o=d(e,t);const r=o<n.day?o:n.day;return{month:e,year:t,day:r}};const G=(n,e)=>{const t=n.month;const o=n.year+e;const r=d(t,o);const s=r<n.day?r:n.day;return{month:t,year:o,day:s}};const N=n=>G(n,-1);const A=n=>G(n,1);const E=(n,e,t)=>{if(e){return n}return I(n,t)};const W=(n,e)=>{const{ampm:t,hour:o}=n;let r=o;if(t==="am"&&e==="pm"){r=I(r,"pm")}else if(t==="pm"&&e==="am"){r=Math.abs(r-12)}return r};const F=(n,t,o)=>{const{month:r,day:s,year:i}=n;const u=h(Object.assign({},n),t,o);const a=d(r,i);if(s!==null&&a<s){u.day=a}if(t!==undefined&&e(u,t)){if(u.hour!==undefined&&t.hour!==undefined){if(u.hour<t.hour){u.hour=t.hour;u.minute=t.minute}else if(u.hour===t.hour&&u.minute!==undefined&&t.minute!==undefined&&u.minute<t.minute){u.minute=t.minute}}}if(o!==undefined&&e(n,o)){if(u.hour!==undefined&&o.hour!==undefined){if(u.hour>o.hour){u.hour=o.hour;u.minute=o.minute}else if(u.hour===o.hour&&u.minute!==undefined&&o.minute!==undefined&&u.minute>o.minute){u.minute=o.minute}}}return u};const J=(n,e,t,o,r,s)=>{const{hour:i,minute:d,day:u,month:a,year:c}=n;const f=Object.assign(Object.assign({},n),{dayOfWeek:undefined});if(e!==undefined){f.month=P(a,e)}if(u!==null&&t!==undefined){f.day=P(u,t)}if(o!==undefined){f.year=P(c,o)}if(i!==undefined&&r!==undefined){f.hour=P(i,r);f.ampm=v(f.hour)}if(d!==undefined&&s!==undefined){f.minute=P(d,s)}return f};const P=(n,e)=>{let t=e[0];let o=Math.abs(t-n);for(let r=1;r<e.length;r++){const s=e[r];const i=Math.abs(s-n);if(i<o){t=s;o=i}}return t}; /*! * (C) Ionic http://ionicframework.com - MIT License */const S=n=>{if(n===undefined){return""}return n.toUpperCase()};const H=(n,e,t)=>{const o={hour:e.hour,minute:e.minute};if(o.hour===undefined||o.minute===undefined){return"Invalid Time"}return new Intl.DateTimeFormat(n,{hour:"numeric",minute:"numeric",timeZone:"UTC",hourCycle:t?"h23":"h12"}).format(new Date(O(Object.assign({year:2023,day:1,month:1},o))+"Z"))};const R=n=>{const e=n.toString();if(e.length>1){return e}return`0${e}`};const q=(n,e)=>{if(e){return R(n)}if(n===0){return"12"}return n.toString()};const z=(n,e,t)=>{if(t.day===null){return null}const o=new Date(`${t.month}/${t.day}/${t.year} GMT+0000`);const r=new Intl.DateTimeFormat(n,{weekday:"long",month:"long",day:"numeric",timeZone:"UTC"}).format(o);return e?`Today, ${r}`:r};const B=(n,e)=>{const t=new Date(`${e.month}/${e.day}/${e.year} GMT+0000`);return new Intl.DateTimeFormat(n,{weekday:"short",month:"short",day:"numeric",timeZone:"UTC"}).format(t)};const K=(n,e)=>{const t=new Date(`${e.month}/${e.day}/${e.year} GMT+0000`);return new Intl.DateTimeFormat(n,{month:"long",year:"numeric",timeZone:"UTC"}).format(t)};const L=(n,e)=>Y(n,e,{month:"short",day:"numeric",year:"numeric"});const Q=(n,e)=>_(n,e,{day:"numeric"}).find((n=>n.type==="day")).value;const V=(n,e)=>Y(n,e,{year:"numeric"});const X=n=>{const e=n.hour!==undefined&&n.minute!==undefined?` ${n.hour}:${n.minute}`:"";return new Date(`${n.month}/${n.day}/${n.year}${e} GMT+0000`)};const Y=(n,e,t)=>{const o=X(e);return nn(n,t).format(o)};const _=(n,e,t)=>{const o=X(e);return nn(n,t).formatToParts(o)};const nn=(n,e)=>new Intl.DateTimeFormat(n,Object.assign(Object.assign({},e),{timeZone:"UTC"}));const en=n=>{if("RelativeTimeFormat"in Intl){const e=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(0,"day");return e.charAt(0).toUpperCase()+e.slice(1)}else{return"Today"}};const tn=n=>{const e=n.getTimezoneOffset();n.setMinutes(n.getMinutes()-e);return n};const on=tn(new Date("2022T01:00"));const rn=tn(new Date("2022T13:00"));const sn=(n,e)=>{const t=e==="am"?on:rn;const o=new Intl.DateTimeFormat(n,{hour:"numeric",timeZone:"UTC"}).formatToParts(t).find((n=>n.type==="dayPeriod"));if(o){return o.value}return S(e)};const dn=n=>Array.isArray(n)?n.join(","):n; /*! * (C) Ionic http://ionicframework.com - MIT License */const un=()=>tn(new Date).toISOString();const an=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59];const cn=[0,1,2,3,4,5,6,7,8,9,10,11];const fn=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23];const ln=(n,e,t=0)=>{const o=e==="ios"?"short":"narrow";const r=new Intl.DateTimeFormat(n,{weekday:o});const s=new Date("11/01/2020");const i=[];for(let n=t;n<t+7;n++){const e=new Date(s);e.setDate(e.getDate()+n);i.push(r.format(e))}return i};const mn=(n,e,t)=>{const o=d(n,e);const r=new Date(`${n}/1/${e}`).getDay();const s=r>=t?r-(t+1):6-(t-r);let i=[];for(let n=1;n<=o;n++){i.push({day:n,dayOfWeek:(s+n)%7})}for(let n=0;n<=s;n++){i=[{day:null,dayOfWeek:null},...i]}return i};const yn=(n,r="h12",s,i,d,u)=>{const a=r==="h23";let c=a?fn:cn;let f=an;let l=true;let m=true;if(d){c=c.filter((n=>d.includes(n)))}if(u){f=f.filter((n=>u.includes(n)))}if(s){if(e(n,s)){if(s.hour!==undefined){c=c.filter((e=>{const t=n.ampm==="pm"?(e+12)%24:e;return(a?e:t)>=s.hour}));l=s.hour<13}if(s.minute!==undefined){let e=false;if(s.hour!==undefined&&n.hour!==undefined){if(n.hour>s.hour){e=true}}f=f.filter((n=>{if(e){return true}return n>=s.minute}))}}else if(t(n,s)){c=[];f=[];l=m=false}}if(i){if(e(n,i)){if(i.hour!==undefined){c=c.filter((e=>{const t=n.ampm==="pm"?(e+12)%24:e;return(a?e:t)<=i.hour}));m=i.hour>=12}if(i.minute!==undefined&&n.hour===i.hour){f=f.filter((n=>n<=i.minute))}}else if(o(n,i)){c=[];f=[];l=m=false}}return{hours:c,minutes:f,am:l,pm:m}};const hn=n=>[g(n),{month:n.month,year:n.year,day:n.day},U(n)];const vn=(n,e,t,o,r,s={month:"long"})=>{const{year:i}=e;const d=[];if(r!==undefined){let e=r;if((o===null||o===void 0?void 0:o.month)!==undefined){e=e.filter((n=>n<=o.month))}if((t===null||t===void 0?void 0:t.month)!==undefined){e=e.filter((n=>n>=t.month))}e.forEach((e=>{const t=new Date(`${e}/1/${i} GMT+0000`);const o=new Intl.DateTimeFormat(n,Object.assign(Object.assign({},s),{timeZone:"UTC"})).format(t);d.push({text:o,value:e})}))}else{const e=o&&o.year===i?o.month:12;const r=t&&t.year===i?t.month:1;for(let t=r;t<=e;t++){const e=new Date(`${t}/1/${i} GMT+0000`);const o=new Intl.DateTimeFormat(n,Object.assign(Object.assign({},s),{timeZone:"UTC"})).format(e);d.push({text:o,value:t})}}return d};const wn=(n,e,t,o,r,s={day:"numeric"})=>{const{month:i,year:u}=e;const a=[];const c=d(i,u);const f=(o===null||o===void 0?void 0:o.day)!==null&&(o===null||o===void 0?void 0:o.day)!==undefined&&o.year===u&&o.month===i?o.day:c;const l=(t===null||t===void 0?void 0:t.day)!==null&&(t===null||t===void 0?void 0:t.day)!==undefined&&t.year===u&&t.month===i?t.day:1;if(r!==undefined){let e=r;e=e.filter((n=>n>=l&&n<=f));e.forEach((e=>{const t=new Date(`${i}/${e}/${u} GMT+0000`);const o=new Intl.DateTimeFormat(n,Object.assign(Object.assign({},s),{timeZone:"UTC"})).format(t);a.push({text:o,value:e})}))}else{for(let e=l;e<=f;e++){const t=new Date(`${i}/${e}/${u} GMT+0000`);const o=new Intl.DateTimeFormat(n,Object.assign(Object.assign({},s),{timeZone:"UTC"})).format(t);a.push({text:o,value:e})}}return a};const $n=(n,e,t,o,r)=>{var s,i;let d=[];if(r!==undefined){d=r;if((o===null||o===void 0?void 0:o.year)!==undefined){d=d.filter((n=>n<=o.year))}if((t===null||t===void 0?void 0:t.year)!==undefined){d=d.filter((n=>n>=t.year))}}else{const{year:n}=e;const r=(s=o===null||o===void 0?void 0:o.year)!==null&&s!==void 0?s:n;const u=(i=t===null||t===void 0?void 0:t.year)!==null&&i!==void 0?i:n-100;for(let n=u;n<=r;n++){d.push(n)}}return d.map((t=>({text:V(n,{year:t,month:e.month,day:e.day}),value:t})))};const pn=(n,e)=>{if(n.month===e.month&&n.year===e.year){return[n]}return[n,...pn(U(n),e)]};const Tn=(n,t,o,r,s,i)=>{let d=[];let u=[];let a=pn(o,r);if(i){a=a.filter((({month:n})=>i.includes(n)))}a.forEach((i=>{const a={month:i.month,day:null,year:i.year};const c=wn(n,a,o,r,s,{month:"short",day:"numeric",weekday:"short"});const f=[];const l=[];c.forEach((o=>{const r=e(Object.assign(Object.assign({},a),{day:o.value}),t);l.push({text:r?en(n):o.text,value:`${a.year}-${a.month}-${o.value}`});f.push({month:a.month,year:a.year,day:o.value})}));u=[...u,...f];d=[...d,...l]}));return{parts:u,items:d}};const On=(n,e,t,o,r,s,d)=>{const u=i(n,t);const{hours:a,minutes:c,am:f,pm:l}=yn(e,u?"h23":"h12",o,r,s,d);const m=a.map((n=>({text:q(n,u),value:E(n,u,e.ampm)})));const y=c.map((n=>({text:R(n),value:n})));const h=[];if(f&&!u){h.push({text:sn(n,"am"),value:"am"})}if(l&&!u){h.push({text:sn(n,"pm"),value:"pm"})}return{minutesData:y,hoursData:m,dayPeriodData:h}};export{wn as A,$n as B,u as C,On as D,a as E,ln as F,K as G,mn as H,hn as I,i as J,H as K,B as L,dn as M,A as N,N as O,h as P,v as Q,W as R,Y as S,L as T,Q as a,o as b,e as c,g as d,U as e,m as f,z as g,b as h,t as i,D as j,M as k,j as l,k as m,x as n,w as o,$ as p,y as q,l as r,O as s,un as t,J as u,F as v,r as w,d as x,Tn as y,vn as z}; //# sourceMappingURL=p-72283fec.js.map