@gem-sdk/components 2.0.0-staging.927 → 2.0.0-staging.928
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var TextInline=require("../../text/components/TextInline.js"),helpers=require("../../helpers.js"),system=require("@gem-sdk/system"),styles=require("./styles.js");const getDayEst=e=>{let t=new Date(Date.now()),a=e?.typeFormat==="Custom"?e?.customFormat:e?.typeFormat;if(!
|
|
1
|
+
"use strict";var TextInline=require("../../text/components/TextInline.js"),helpers=require("../../helpers.js"),system=require("@gem-sdk/system"),styles=require("./styles.js");const getEstimateValue=e=>e?"number"==typeof e?e:Number(e.split("days")[0]):0,getDayEst=e=>{let t=new Date(Date.now()),a=getEstimateValue(e?.estimateTime),r=getEstimateValue(e?.minEstimate),s=getEstimateValue(e?.maxEstimate),l=e?.typeFormat==="Custom"?e?.customFormat:e?.typeFormat;if(!l)return"";if(e?.typeEstimate===ESTIMATE_DAYS.SPECIFIC){let e=`${getDayFormat(getFutureDay(a),l)}`;return e}getDayFormat(t);let u=`${getDayFormat(getFutureDay(r),l)} - ${getDayFormat(getFutureDay(s),l)}`;return u},EstimateDateLevel=e=>{switch(e?.htmlTag){case 1:return"h1";case 2:return"h2";case 3:return"h3";case 4:return"h4";case 5:return"h5";case 6:return"h6";default:return"div"}},getNewSetting=({type:e,styles:t,setting:a,builderProps:r,pageContext:s})=>{let l="React"===e,u=getTextContent({type:e,styles:t,setting:a,builderProps:r,pageContext:s});return{text:u,htmlTag:EstimateDateLevel(a),globalSize:a?.globalSize,background:a?.background,...!l&&{translate:a?.translate,isForceValue:!0}}},getTextContent=({type:e,styles:t,setting:a,builderProps:r,pageContext:s})=>{let l="React"===e,u=system.createClass({"estimate-date-main":!0}),n=l||s?.isPreviewing?a?.customText:helpers.getDynamicSourceLocales({val:a?.customText,uid:r?.uid,settingId:a?.translate||"",pageContext:s,isCapitalize:t?.typo?.attrs?.transform==="capitalize",translate:a?.translate}).toString(),i={pageContext:s,setting:a,isReact:l,builderProps:r,textWithTranslate:n};return`${a?.enableCustomText===!1?"":TextInline.default({styles:styles.getStyleEstimateDate(t,"typoCustom"),setting:{text:n},elementAttrs:{debugText:JSON.stringify(i).replaceAll("'","'")}})} ${TextInline.default({styles:styles.getStyleEstimateDate(t,"typoDate"),setting:{text:getDayEst(a)},className:u})}`},OUT_OF_STOCK={SHOW:"show",HIDE:"hide"},ESTIMATE_DAYS={SPECIFIC:"specific",RANGE:"range"},getDayFormat=(e,t="%B %d, %Y")=>{let a=e.getMonth()+1,r=e.getDate(),s=e.getFullYear();function l(e){let t=Math.floor(e/10)%10,a=e%10;return 1===a&&1!==t?"st":2===a&&1!==t?"nd":3===a&&1!==t?"rd":"th"}let u=[{type:"%a",value:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][e.getDay()]},{type:"%A",value:["Sunday","Monday","Tueday","Wednesday","Thursday","Friday","Saturday"][e.getDay()]},{type:"%d",value:r.toString().padStart(2,"0")},{type:"%b",value:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][a-1]},{type:"%B",value:["January","February","March","April","May","June","July","August","September","October","November","December"][a-1]},{type:"%m",value:a.toString().padStart(2,"0")},{type:"%y",value:s.toString().slice(-2)},{type:"%Y",value:s},{type:"%sf",value:l(r)}];return u.forEach(e=>{t=t.replaceAll(e?.type,e?.value?.toString()||"")}),t},getFutureDay=e=>{let t=new Date,a=new Date(t);return a.setDate(t.getDate()+Number(e)),a},listFormatDate=()=>{let e=new Date(Date.now());return{FORMAT_1:{Label:getDayFormat(e,"%b %d"),value:"%b %d"},FORMAT_2:{Label:getDayFormat(e,"%b %d, %Y"),value:"%b %d, %Y"},FORMAT_3:{Label:getDayFormat(e,"%a, %b %d"),value:"%a, %b %d"},FORMAT_4:{Label:getDayFormat(e,"%d/%m/%Y"),value:"%d/%m/%Y"},FORMAT_5:{Label:getDayFormat(e,"%Y/%m/%d"),value:"%Y/%m/%d"},FORMAT_6:{Label:"Custom"}}};exports.ESTIMATE_DAYS=ESTIMATE_DAYS,exports.OUT_OF_STOCK=OUT_OF_STOCK,exports.getDayFormat=getDayFormat,exports.getFutureDay=getFutureDay,exports.getNewSetting=getNewSetting,exports.listFormatDate=listFormatDate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"../../text/components/TextInline.js";import{getDynamicSourceLocales as e}from"../../helpers.js";import{createClass as a}from"@gem-sdk/system";import{getStyleEstimateDate as r}from"./styles.js";let getDayEst=t=>{let e=new Date(Date.now()),a=t?.typeFormat==="Custom"?t?.customFormat:t?.typeFormat;if(!
|
|
1
|
+
import t from"../../text/components/TextInline.js";import{getDynamicSourceLocales as e}from"../../helpers.js";import{createClass as a}from"@gem-sdk/system";import{getStyleEstimateDate as r}from"./styles.js";let getEstimateValue=t=>t?"number"==typeof t?t:Number(t.split("days")[0]):0,getDayEst=t=>{let e=new Date(Date.now()),a=getEstimateValue(t?.estimateTime),r=getEstimateValue(t?.minEstimate),u=getEstimateValue(t?.maxEstimate),l=t?.typeFormat==="Custom"?t?.customFormat:t?.typeFormat;if(!l)return"";if(t?.typeEstimate===ESTIMATE_DAYS.SPECIFIC){let t=`${getDayFormat(getFutureDay(a),l)}`;return t}getDayFormat(e);let s=`${getDayFormat(getFutureDay(r),l)} - ${getDayFormat(getFutureDay(u),l)}`;return s},EstimateDateLevel=t=>{switch(t?.htmlTag){case 1:return"h1";case 2:return"h2";case 3:return"h3";case 4:return"h4";case 5:return"h5";case 6:return"h6";default:return"div"}},getNewSetting=({type:t,styles:e,setting:a,builderProps:r,pageContext:u})=>{let l="React"===t,s=getTextContent({type:t,styles:e,setting:a,builderProps:r,pageContext:u});return{text:s,htmlTag:EstimateDateLevel(a),globalSize:a?.globalSize,background:a?.background,...!l&&{translate:a?.translate,isForceValue:!0}}},getTextContent=({type:u,styles:l,setting:s,builderProps:n,pageContext:m})=>{let o="React"===u,i=a({"estimate-date-main":!0}),y=o||m?.isPreviewing?s?.customText:e({val:s?.customText,uid:n?.uid,settingId:s?.translate||"",pageContext:m,isCapitalize:l?.typo?.attrs?.transform==="capitalize",translate:s?.translate}).toString(),g={pageContext:m,setting:s,isReact:o,builderProps:n,textWithTranslate:y};return`${s?.enableCustomText===!1?"":t({styles:r(l,"typoCustom"),setting:{text:y},elementAttrs:{debugText:JSON.stringify(g).replaceAll("'","'")}})} ${t({styles:r(l,"typoDate"),setting:{text:getDayEst(s)},className:i})}`},OUT_OF_STOCK={SHOW:"show",HIDE:"hide"},ESTIMATE_DAYS={SPECIFIC:"specific",RANGE:"range"},getDayFormat=(t,e="%B %d, %Y")=>{let a=t.getMonth()+1,r=t.getDate(),u=t.getFullYear();function l(t){let e=Math.floor(t/10)%10,a=t%10;return 1===a&&1!==e?"st":2===a&&1!==e?"nd":3===a&&1!==e?"rd":"th"}let s=[{type:"%a",value:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t.getDay()]},{type:"%A",value:["Sunday","Monday","Tueday","Wednesday","Thursday","Friday","Saturday"][t.getDay()]},{type:"%d",value:r.toString().padStart(2,"0")},{type:"%b",value:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][a-1]},{type:"%B",value:["January","February","March","April","May","June","July","August","September","October","November","December"][a-1]},{type:"%m",value:a.toString().padStart(2,"0")},{type:"%y",value:u.toString().slice(-2)},{type:"%Y",value:u},{type:"%sf",value:l(r)}];return s.forEach(t=>{e=e.replaceAll(t?.type,t?.value?.toString()||"")}),e},getFutureDay=t=>{let e=new Date,a=new Date(e);return a.setDate(e.getDate()+Number(t)),a},listFormatDate=()=>{let t=new Date(Date.now());return{FORMAT_1:{Label:getDayFormat(t,"%b %d"),value:"%b %d"},FORMAT_2:{Label:getDayFormat(t,"%b %d, %Y"),value:"%b %d, %Y"},FORMAT_3:{Label:getDayFormat(t,"%a, %b %d"),value:"%a, %b %d"},FORMAT_4:{Label:getDayFormat(t,"%d/%m/%Y"),value:"%d/%m/%Y"},FORMAT_5:{Label:getDayFormat(t,"%Y/%m/%d"),value:"%Y/%m/%d"},FORMAT_6:{Label:"Custom"}}};export{ESTIMATE_DAYS,OUT_OF_STOCK,getDayFormat,getFutureDay,getNewSetting,listFormatDate};
|