8000 MWPW-173962: refactor&simplify by 3ch023 · Pull Request #4352 · adobecom/milo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

MWPW-173962: refactor&simplify #4352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 23, 2025
Merged
4 changes: 1 addition & 3 deletions libs/blocks/merch/merch.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const GeoMap = {
};

/**
* Used when 3in1 modals are configured with ms=e or cs=t extra paramter, but 3in1 is disabled.
* Used when 3in1 modals are configured with ms=e or cs=t extra parameter, but 3in1 is disabled.
* Dexter modals should deeplink to plan=edu or plan=team tabs.
* @type {Record<string, string>}
*/
Expand Down Expand Up @@ -755,7 +755,6 @@ export async function getCheckoutContext(el, params) {
const { settings } = await initService();
const { checkoutClientId } = settings;
const checkoutMarketSegment = params.get('marketSegment');
const checkoutWorkflow = params.get('workflow') ?? settings.checkoutWorkflow;
const checkoutWorkflowStep = params?.get('workflowStep') ?? settings.checkoutWorkflowStep;
const entitlement = params?.get('entitlement');
const upgrade = params?.get('upgrade');
Expand All @@ -771,7 +770,6 @@ export async function getCheckoutContext(el, params) {
return {
...context,
checkoutClientId,
checkoutWorkflow,
checkoutWorkflowStep,
checkoutMarketSegment,
entitlement,
Expand Down
5 changes: 1 addition & 4 deletions libs/blocks/ost/ost.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ export const createLinkMarkup = (
if (offer.commitment === 'PERPETUAL') params.set('perp', true);

if (isCta) {
const { workflow, workflowStep } = options;
const { workflowStep } = options;
params.set('text', options.ctaText ?? DEFAULT_CTA_TEXT);
if (workflow && workflow !== defaults.checkoutWorkflow) {
params.set('workflow', workflow);
}
if (workflowStep && workflowStep !== defaults.checkoutWorkflowStep) {
params.set('workflowStep', workflowStep);
}
Expand Down
6 changes: 3 additions & 3 deletions libs/deps/mas/commerce.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Large diffs are n EDBE ot rendered by default.

28 changes: 14 additions & 14 deletions libs/deps/mas/merch-card-collection.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions libs/deps/mas/merch-card.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions libs/deps/mas/merch-offer-select.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var S=Object.defineProperty;var m=t=>{throw TypeError(t)};var g=(t,o,e)=>o in t?S(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e;var n=(t,o,e)=>g(t,typeof o!="symbol"?o+"":o,e),f=(t,o,e)=>o.has(t)||m("Cannot "+e);var E=(t,o,e)=>(f(t,o,"read from private field"),e?e.call(t):o.get(t)),_=(t,o,e)=>o.has(t)?m("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(t):o.set(t,e),b=(t,o,e,r)=>(f(t,o,"write to private field"),r?r.call(t,e):o.set(t,e),e);import{html as R,LitElement as M}from"../lit-all.min.js";import{css as C,html as N,LitElement as y}from"../lit-all.min.js";var D=Object.freeze({MONTH:"MONTH",YEAR:"YEAR",TWO_YEARS:"TWO_YEARS",THREE_YEARS:"THREE_YEARS",PERPETUAL:"PERPETUAL",TERM_LICENSE:"TERM_LICENSE",ACCESS_PASS:"ACCESS_PASS",THREE_MONTHS:"THREE_MONTHS",SIX_MONTHS:"SIX_MONTHS"}),I=Object.freeze({ANNUAL:"ANNUAL",MONTHLY:"MONTHLY",TWO_YEARS:"TWO_YEARS",THREE_YEARS:"THREE_YEARS",P1D:"P1D",P1Y:"P1Y",P3Y:"P3Y",P10Y:"P10Y",P15Y:"P15Y",P3D:"P3D",P7D:"P7D",P30D:"P30D",HALF_YEARLY:"HALF_YEARLY",QUARTERLY:"QUARTERLY"});var O='span[is="inline-price"][data-wcs-osi]',h='a[is="checkout-link"][data-wcs-osi],button[is="checkout-button"][data-wcs-osi]';var H=`${O},${h}`,c="merch-offer:ready",T="merch-offer-select:ready";var A="merch-offer:selected";var u="merch-quantity-selector:change";var w=Object.freeze({CHECKOUT:"checkout",CHECKOUT_EMAIL:"checkout/email",SEGMENTATION:"segmentation",BUNDLE:"bundle",COMMITMENT:"commitment",RECOMMENDATION:"recommendation",EMAIL:"email",PAYMENT:"payment",CHANGE_PLAN_TEAM_PLANS:"change-plan/team-upgrade/plans",CHANGE_PLAN_TEAM_PAYMENT:"change-plan/team-upgrade/payment"}),Y=Object.freeze({V2:"UCv2",V3:"UCv3"}),V=Object.freeze({STAGE:"STAGE",PRODUCTION:"PRODUCTION",LOCAL:"LOCAL"});var a,l=class extends y{constructor(){super();_(this,a);this.defaults={},this.variant="plans"}saveContainerDefaultValues(){let e=this.closest(this.getAttribute("container")),r=e?.querySelector('[slot="description"]:not(merch-offer > *)')?.cloneNode(!0),i=e?.badgeText;return{description:r,badgeText:i}}getSlottedElement(e,r){return(r||this.closest(this.getAttribute("container"))).querySelector(`[slot="${e}"]:not(merch-offer > *)`)}updateSlot(e,r){let i=this.getSlottedElement(e,r);if(!i)return;let s=this.selectedOffer.getOptionValue(e)?this.selectedOffer.getOptionValue(e):this.defaults[e];s&&i.replaceWith(s.cloneNode(!0))}handleOfferSelection(e){let r=e.detail;this.selectOffer(r)}handleOfferSelectionByQuantity(e){let r=e.detail.option,i=Number.parseInt(r),s=this.findAppropriateOffer(i);this.selectOffer(s),this.getSlottedElement("cta").setAttribute("data-quantity",i)}selectOffer(e){if(!e)return;let r=this.selectedOffer;r&&(r.selected=!1),e.selected=!0,this.selectedOffer=e,this.planType=e.planType,this.updateContainer(),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent(A,{detail:this,bubbles:!0}))})}findAppropriateOffer(e){let r=null;return this.offers.find(s=>{let d=Number.parseInt(s.getAttribute("value"));if(d===e)return!0;if(d>e)return!1;r=s})||r}updateBadgeText(e){this.selectedOffer.badgeText===""?e.badgeText=null:this.selectedOffer.badgeText?e.badgeText=this.selectedOffer.badgeText:e.badgeText=this.defaults.badgeText}updateContainer(){let e=this.closest(this.getAttribute("container"));!e||!this.selectedOffer||(this.updateSlot("cta",e),this.updateSlot("secondary-cta",e),this.updateSlot("price",e),!this.manageableMode&&(this.updateSlot("description",e),this.updateBadgeText(e)))}render(){return N`<fieldset><slot class="${this.variant}"></slot></fieldset>`}connectedCallback(){super.connectedCallback(),this.addEventListener("focusin",this.handleFocusin),this.addEventListener("click",this.handleFocusin),this.addEventListener(c,this.handleOfferSelectReady);let e=this.closest("merch-quantity-select");this.manageableMode=e,this.offers=[...this.querySelectorAll("merch-offer")],b(this,a,this.handleOfferSelectionByQuantity.bind(this)),this.manageableMode?e.addEventListener(u,E(this,a)):this.defaults=this.saveContainerDefaultValues(),this.selectedOffer=this.offers[0],this.planType&&this.updateContainer()}get miniCompareMobileCard(){return this.merchCard?.variant==="mini-compare-chart"&&this.isMobile}get merchCard(){return this.closest("merch-card")}get isMobile(){return window.matchMedia("(max-width: 767px)").matches}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(u,E(this,a)),this.removeEventListener(c,this.handleOfferSelectReady),this.removeEventListener("focusin",this.handleFocusin),this.removeEventListener("click",this.handleFocusin)}get price(){return this.querySelector('merch-offer[aria-selected] [is="inline-price"]')}get customerSegment(){return this.selectedOffer?.customerSegment}get marketSegment(){return this.selectedOffer?.marketSegment}handleFocusin(e){e.target?.nodeName==="MERCH-OFFER"&&(e.preventDefault(),e.stopImmediatePropagation(),this.selectOffer(e.target))}async handleOfferSelectReady(){this.planType||this.querySelector("merch-offer:not([plan-type])")||(this.planType=this.selectedOffer.planType,await this.updateComplete,this.selectOffer(this.selectedOffer??this.querySelector("merch-offer[aria-selected]")??this.querySelector("merch-offer")),this.dispatchEvent(new CustomEvent(T,{bubbles:!0})))}};a=new WeakMap,n(l,"styles",C`
var S=Object.defineProperty;var m=t=>{throw TypeError(t)};var g=(t,o,e)=>o in t?S(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e;var n=(t,o,e)=>g(t,typeof o!="symbol"?o+"":o,e),f=(t,o,e)=>o.has(t)||m("Cannot "+e);var E=(t,o,e)=>(f(t,o,"read from private field"),e?e.call(t):o.get(t)),_=(t,o,e)=>o.has(t)?m("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(t):o.set(t,e),b=(t,o,e,r)=>(f(t,o,"write to private field"),r?r.call(t,e):o.set(t,e),e);import{html as R,LitElement as M}from"../lit-all.min.js";import{css as C,html as N,LitElement as y}from"../lit-all.min.js";var D=Object.freeze({MONTH:"MONTH",YEAR:"YEAR",TWO_YEARS:"TWO_YEARS",THREE_YEARS:"THREE_YEARS",PERPETUAL:"PERPETUAL",TERM_LICENSE:"TERM_LICENSE",ACCESS_PASS:"ACCESS_PASS",THREE_MONTHS:"THREE_MONTHS",SIX_MONTHS:"SIX_MONTHS"}),I=Object.freeze({ANNUAL:"ANNUAL",MONTHLY:"MONTHLY",TWO_YEARS:"TWO_YEARS",THREE_YEARS:"THREE_YEARS",P1D:"P1D",P1Y:"P1Y",P3Y:"P3Y",P10Y:"P10Y",P15Y:"P15Y",P3D:"P3D",P7D:"P7D",P30D:"P30D",HALF_YEARLY:"HALF_YEARLY",QUARTERLY:"QUARTERLY"});var O='span[is="inline-price"][data-wcs-osi]',h='a[is="checkout-link"][data-wcs-osi],button[is="checkout-button"][data-wcs-osi]';var w=`${O},${h}`,c="merch-offer:ready",T="merch-offer-select:ready";var x="merch-offer:selected";var u="merch-quantity-selector:change";var H=Object.freeze({SEGMENTATION:"segmentation",BUNDLE:"bundle",COMMITMENT:"commitment",RECOMMENDATION:"recommendation",EMAIL:"email",PAYMENT:"payment",CHANGE_PLAN_TEAM_PLANS:"change-plan/team-upgrade/plans",CHANGE_PLAN_TEAM_PAYMENT:"change-plan/team-upgrade/payment"});var Y=Object.freeze({STAGE:"STAGE",PRODUCTION:"PRODUCTION",LOCAL:"LOCAL"});var a,l=class extends y{constructor(){super();_(this,a);this.defaults={},this.variant="plans"}saveContainerDefaultValues(){let e=this.closest(this.getAttribute("container")),r=e?.querySelector('[slot="description"]:not(merch-offer > *)')?.cloneNode(!0),i=e?.badgeText;return{description:r,badgeText:i}}getSlottedElement(e,r){return(r||this.closest(this.getAttribute("container"))).querySelector(`[slot="${e}"]:not(merch-offer > *)`)}updateSlot(e,r){let i=this.getSlottedElement(e,r);if(!i)return;let s=this.selectedOffer.getOptionValue(e)?this.selectedOffer.getOptionValue(e):this.defaults[e];s&&i.replaceWith(s.cloneNode(!0))}handleOfferSelection(e){let r=e.detail;this.selectOffer(r)}handleOfferSelectionByQuantity(e){let r=e.detail.option,i=Number.parseInt(r),s=this.findAppropriateOffer(i);this.selectOffer(s),this.getSlottedElement("cta").setAttribute("data-quantity",i)}selectOffer(e){if(!e)return;let r=this.selectedOffer;r&&(r.selected=!1),e.selected=!0,this.selectedOffer=e,this.planType=e.planType,this.updateContainer(),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent(x,{detail:this,bubbles:!0}))})}findAppropriateOffer(e){let r=null;return this.offers.find(s=>{let d=Number.parseInt(s.getAttribute("value"));if(d===e)return!0;if(d>e)return!1;r=s})||r}updateBadgeText(e){this.selectedOffer.badgeText===""?e.badgeText=null:this.selectedOffer.badgeText?e.badgeText=this.selectedOffer.badgeText:e.badgeText=this.defaults.badgeText}updateContainer(){let e=this.closest(this.getAttribute("container"));!e||!this.selectedOffer||(this.updateSlot("cta",e),this.updateSlot("secondary-cta",e),this.updateSlot("price",e),!this.manageableMode&&(this.updateSlot("description",e),this.updateBadgeText(e)))}render(){return N`<fieldset><slot class="${this.variant}"></slot></fieldset>`}connectedCallback(){super.connectedCallback(),this.addEventListener("focusin",this.handleFocusin),this.addEventListener("click",this.handleFocusin),this.addEventListener(c,this.handleOfferSelectReady);let e=this.closest("merch-quantity-select");this.manageableMode=e,this.offers=[...this.querySelectorAll("merch-offer")],b(this,a,this.handleOfferSelectionByQuantity.bind(this)),this.manageableMode?e.addEventListener(u,E(this,a)):this.defaults=this.saveContainerDefaultValues(),this.selectedOffer=this.offers[0],this.planType&&this.updateContainer()}get miniCompareMobileCard(){return this.merchCard?.variant==="mini-compare-chart"&&this.isMobile}get merchCard(){return this.closest("merch-card")}get isMobile(){return window.matchMedia("(max-width: 767px)").matches}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(u,E(this,a)),this.removeEventListener(c,this.handleOfferSelectReady),this.removeEventListener("focusin",this.handleFocusin),this.removeEventListener("click",this.handleFocusin)}get price(){return this.querySelector('merch-offer[aria-selected] [is="inline-price"]')}get customerSegment(){return this.selectedOffer?.customerSegment}get marketSegment(){return this.selectedOffer?.marketSegment}handleFocusin(e){e.target?.nodeName==="MERCH-OFFER"&&(e.preventDefault(),e.stopImmediatePropagation(),this.selectOffer(e.target))}async handleOfferSelectReady(){this.planType||this.querySelector("merch-offer:not([plan-type])")||(this.planType=this.selectedOffer.planType,await this.updateComplete,this.selectOffer(this.selectedOffer??this.querySelector("merch-offer[aria-selected]")??this.querySelector("merch-offer")),this.dispatchEvent(new CustomEvent(T,{bubbles:!0})))}};a=new WeakMap,n(l,"styles",C`
:host {
display: inline-block;
}
Expand All @@ -17,7 +17,7 @@ var S=Object.defineProperty;var m=t=>{throw TypeError(t)};var g=(t,o,e)=>o in t?
flex-direction: column;
gap: var(--consonant-merch-spacing-xs);
}
`),n(l,"properties",{offers:{type:Array},selectedOffer:{type:Object},defaults:{type:Object},variant:{type:String,attribute:"variant",reflect:!0},planType:{type:String,attribute:"plan-type",reflect:!0},stock:{type:Boolean,reflect:!0}});customElements.define("merch-offer-select",l);import{css as L}from"../lit-all.min.js";var x=L`
`),n(l,"properties",{offers:{type:Array},selectedOffer:{type:Object},defaults:{type:Object},variant:{type:String,attribute:"variant",reflect:!0},planType:{type:String,attribute:"plan-type",reflect:!0},stock:{type:Boolean,reflect:!0}});customElements.define("merch-offer-select",l);import{css as L}from"../lit-all.min.js";var A=L`
:host {
--merch-radio: rgba(82, 88, 228);
--merch-radio-hover: rgba(64, 70, 202);
Expand Down Expand Up @@ -245,4 +245,4 @@ var S=Object.defineProperty;var m=t=>{throw TypeError(t)};var g=(t,o,e)=>o in t?
><slot name="condition-tooltip"></slot
></sp-tooltip>
</sp-overlay>
</div>`}render(){return this.configuration||!this.price?"":this.type==="subscription-option"?this.asSubscriptionOption:this.asRadioOption}get price(){return this.querySelector('span[is="inline-price"]:not([data-template="strikethrough"])')}get cta(){return this.querySelector(h)}get prices(){return this.querySelectorAll('span[is="inline-price"]')}get customerSegment(){return this.price?.value?.[0].customerSegment}get marketSegment(){return this.price?.value?.[0].marketSegments[0]}async initOffer(){if(!this.price)return;this.prices.forEach(r=>r.setAttribute("slot","price")),await this.updateComplete,await Promise.all([...this.prices].map(r=>r.onceSettled()));let{value:[e]}=this.price;this.planType=e.planType,await this.updateComplete,this.dispatchEvent(new CustomEvent(c,{bubbles:!0}))}};n(p,"properties",{text:{type:String},selected:{type:Boolean,attribute:"aria-selected",reflect:!0},badgeText:{type:String,attribute:"badge-text"},type:{type:String,attribute:"type",reflect:!0},planType:{type:String,attribute:"plan-type",reflect:!0}}),n(p,"styles",[x]);customElements.define(v,p);
</div>`}render(){return this.configuration||!this.price?"":this.type==="subscription-option"?this.asSubscriptionOption:this.asRadioOption}get price(){return this.querySelector('span[is="inline-price"]:not([data-template="strikethrough"])')}get cta(){return this.querySelector(h)}get prices(){return this.querySelectorAll('span[is="inline-price"]')}get customerSegment(){return this.price?.value?.[0].customerSegment}get marketSegment(){return this.price?.value?.[0].marketSegments[0]}async initOffer(){if(!this.price)return;this.prices.forEach(r=>r.setAttribute("slot","price")),await this.updateComplete,await Promise.all([...this.prices].map(r=>r.onceSettled()));let{value:[e]}=this.price;this.planType=e.planType,await this.updateComplete,this.dispatchEvent(new CustomEvent(c,{bubbles:!0}))}};n(p,"properties",{text:{type:String},selected:{type:Boolean,attribute:"aria-selected",reflect:!0},badgeText:{type:String,attribute:"badge-text"},type:{type:String,attribute:"type",reflect:!0},planType:{type:String,attribute:"plan-type",reflect:!0}}),n(p,"styles",[A]);customElements.define(v,p);
Loading
Loading
0