@primer-io/primer-js 1.4.2 → 1.4.3
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/CHANGELOG.md +6 -0
- package/dist/custom-elements.json +26 -26
- package/dist/primer-loader.js +11 -45
- package/dist/web-types.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
{
|
|
52
52
|
"kind": "variable",
|
|
53
53
|
"name": "ye",
|
|
54
|
-
"default": "class extends v{constructor(){super();this.customStyles=\"\";this.clientToken=\"\";this.options={};this.disableLoader=!1;this._jsInitialized=!1;this.previousLoadingState=!0;this.hasAssignedContent=!1;this._loadingTimeoutId=null;this._eventListenerController=null;this._classObserver=null;this.locale=
|
|
54
|
+
"default": "class extends v{constructor(){super();this.customStyles=\"\";this.clientToken=\"\";this.options={};this.disableLoader=!1;this._jsInitialized=!1;this.previousLoadingState=!0;this.hasAssignedContent=!1;this._loadingTimeoutId=null;this._eventListenerController=null;this._classObserver=null;this.locale=tr(La());this.onSlotChange=e=>{let i=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=i.length>0,this.requestUpdate()};this.sdkContextController=new ya(this),this.primerEventsController=new Xt(this),this.styleProcessingController=new fa(this),this.vaultManagerController=new Er(this),this.headlessSdkController=new Ya(this)}set jsInitialized(e){this.requestUpdate(),this._jsInitialized=e}get jsInitialized(){return this._jsInitialized}get primerJS(){return this.headlessSdkController?.primerJSInstance??void 0}connectedCallback(){super.connectedCallback(),this.sdkContextController.setEventsController(this.primerEventsController),this._eventListenerController=new AbortController,document.addEventListener(\"primer:card-submit\",this.handleExternalCardSubmit.bind(this),{signal:this._eventListenerController.signal}),document.addEventListener(\"primer:vault-submit\",this.handleExternalVaultSubmit.bind(this),{signal:this._eventListenerController.signal}),document.addEventListener(\"primer:show-other-payments-toggle\",this.handleExternalShowOtherPaymentsToggle.bind(this),{signal:this._eventListenerController.signal}),this._classObserver=new MutationObserver(()=>{this.requestUpdate()}),this._classObserver.observe(this,{attributes:!0,attributeFilter:[\"class\"]})}attributeChangedCallback(e,r,i){e===th.CUSTOM_STYLES?this.styleProcessingController.processCustomStyles(i):super.attributeChangedCallback(e,r,i)}disconnectedCallback(){this._loadingTimeoutId&&(window.clearTimeout(this._loadingTimeoutId),this._loadingTimeoutId=null),this.sdkContextController.contextProvider.value.sdkState?.isLoading&&this.sdkContextController.setSdkState({isLoading:!1}),this._eventListenerController&&(this._eventListenerController.abort(),this._eventListenerController=null),this._classObserver&&(this._classObserver.disconnect(),this._classObserver=null),super.disconnectedCallback()}willUpdate(e){e.has(\"options\")&&(this.options?.locale&&(bn(this.options?.locale)?this.locale=tr(this.options?.locale):T.warn(\"\\u{1F30E}\\u2757 Unsupported locale provided:\",this.options?.locale,\"- Falling back to system locale\")),fn(this.locale))}updated(){let e=getComputedStyle(this);this.sdkContextController.setComputedStyles(e),this.checkLoadingStateChange()}handleExternalCardSubmit(e){this._eventListenerController?.signal.aborted||e.target!==this&&this.primerEventsController.dispatchEvent(\"primer:card-submit\",e.detail)}handleExternalVaultSubmit(e){this._eventListenerController?.signal.aborted||e.target!==this&&this.primerEventsController.dispatchEvent(\"primer:vault-submit\",e.detail)}handleExternalShowOtherPaymentsToggle(e){this._eventListenerController?.signal.aborted||e.target!==this&&this.primerEventsController.dispatchEvent(\"primer:show-other-payments-toggle\",e.detail)}checkLoadingStateChange(){let e=this.sdkContextController.contextProvider.value.sdkState.isLoading||!1;if(this.previousLoadingState&&!e){this.jsInitialized=!0,Q({eventName:\"CHECKOUT_FLOW_STARTED\"});let r=De.getSdkInitStartTime(),i=r?Date.now()-r:void 0;qn(i)}this.previousLoadingState=e,e&&!this._loadingTimeoutId?this._loadingTimeoutId=window.setTimeout(()=>{this.sdkContextController.contextProvider.value.sdkState.isLoading&&(T.warn(\"Loading timeout in component, forcing completion\"),this.sdkContextController.setSdkState({isLoading:!1}),this.jsInitialized=!0),this._loadingTimeoutId=null},1e4):!e&&this._loadingTimeoutId&&(window.clearTimeout(this._loadingTimeoutId),this._loadingTimeoutId=null)}render(){let e=this.sdkContextController.contextProvider.value.sdkState,r=e.isLoading,i=e.primerJsError,n=!r&&!i;return u` ${k(i,()=>u`<primer-checkout-error></primer-checkout-error>`)}<slot name=\"main\" @slotchange=${this.onSlotChange}></slot>${k(this.hasAssignedContent||!n,()=>y,()=>u`<primer-main></primer-main>`)} `}addEventListener(e,r,i){super.addEventListener(e,r,i)}removeEventListener(e,r,i){super.removeEventListener(e,r,i)}}"
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
"kind": "function",
|
|
@@ -63,16 +63,16 @@
|
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"kind": "function",
|
|
66
|
-
"name": "
|
|
66
|
+
"name": "oh"
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
"kind": "function",
|
|
70
|
-
"name": "
|
|
70
|
+
"name": "sh"
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
73
|
"kind": "variable",
|
|
74
74
|
"name": "Be",
|
|
75
|
-
"default": "class extends v{constructor(){super(...arguments);this.color=\"var(--primer-color-loader)\";this.size=\"medium\";this.compact=!1}getSize(){if(this.size in
|
|
75
|
+
"default": "class extends v{constructor(){super(...arguments);this.color=\"var(--primer-color-loader)\";this.size=\"medium\";this.compact=!1}getSize(){if(this.size in Ln)return Ln[this.size];let e=parseInt(this.size,10);return isNaN(e)?Ln.medium:e}render(){let e=this.getSize(),r=20,i=`0 0 ${r} ${r}`;return this.style.setProperty(\"--spinner-color\",this.color),this.style.setProperty(\"--spinner-size\",`${e}px`),u`<div class=\"spinner-container ${this.compact?\"compact\":\"\"}\"><svg class=\"spinner\" width=\"${e}\" height=\"${e}\" viewBox=\"${i}\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" role=\"status\" aria-label=\"Loading\" ><path d=\"M4.27827 10.002C4.27827 6.84166 6.84019 4.27973 10.0005 4.27973C10.7676 4.27973 11.3894 3.6579 11.3894 2.89084C11.3894 2.12378 10.7676 1.50195 10.0005 1.50195C5.30607 1.50195 1.50049 5.30753 1.50049 10.002C1.50049 14.6964 5.30607 18.502 10.0005 18.502C14.6949 18.502 18.5005 14.6964 18.5005 10.002C18.5005 9.23489 17.8787 8.61306 17.1116 8.61306C16.3445 8.61306 15.7227 9.23489 15.7227 10.002C15.7227 13.1622 13.1608 15.7242 10.0005 15.7242C6.84019 15.7242 4.27827 13.1622 4.27827 10.002Z\" fill=\"currentColor\" class=\"path\" /></svg></div>`}}"
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
"kind": "variable",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
{
|
|
113
113
|
"kind": "variable",
|
|
114
114
|
"name": "re",
|
|
115
|
-
"default": "class extends v{constructor(){super(...arguments);this.prefix=\"+351\";this.value=\"\";this.placeholder=\"\";this.inputId=\"primer-pt-phone-number-input\";this.maxLength=15;this.minLength=9;this.disabled=!1;this.hasErrors=!1;this.handleInput=e=>{e.stopPropagation();let r=e.target,n=r.value.replace(/\\D/g,\"\").slice(0,this.maxLocalDigits);r.value!==n&&(r.value=n),this.dispatchValueEvent(\"input\",n)};this.handleChange=e=>{e.stopPropagation();let i=e.target.value.replace(/\\D/g,\"\");this.dispatchValueEvent(\"change\",i)};this.handleHostClick=()=>{this.inputEl?.focus()}}get localDigits(){let r=(this.value==null?\"\":String(this.value)).replace(/[^\\d+]/g,\"\");return r.startsWith(this.prefix)?r.slice(this.prefix.length):r.replace(/^\\+/,\"\")}get maxLocalDigits(){return Math.max(this.maxLength-this.prefix.length,0)}updated(e){if(!e.has(\"value\")&&!e.has(\"prefix\"))return;let r=this.inputEl;if(!r)return;let i=this.localDigits;r.value!==i&&(r.value=i)}dispatchValueEvent(e,r){let i=r.length?`${this.prefix}${r}`:\"\";this.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,composed:!0}))}focus(){this.inputEl?.focus()}render(){return u`<div @click=${this.handleHostClick} style=\"display: contents;\"><span class=\"flag\" aria-hidden=\"true\">${
|
|
115
|
+
"default": "class extends v{constructor(){super(...arguments);this.prefix=\"+351\";this.value=\"\";this.placeholder=\"\";this.inputId=\"primer-pt-phone-number-input\";this.maxLength=15;this.minLength=9;this.disabled=!1;this.hasErrors=!1;this.handleInput=e=>{e.stopPropagation();let r=e.target,n=r.value.replace(/\\D/g,\"\").slice(0,this.maxLocalDigits);r.value!==n&&(r.value=n),this.dispatchValueEvent(\"input\",n)};this.handleChange=e=>{e.stopPropagation();let i=e.target.value.replace(/\\D/g,\"\");this.dispatchValueEvent(\"change\",i)};this.handleHostClick=()=>{this.inputEl?.focus()}}get localDigits(){let r=(this.value==null?\"\":String(this.value)).replace(/[^\\d+]/g,\"\");return r.startsWith(this.prefix)?r.slice(this.prefix.length):r.replace(/^\\+/,\"\")}get maxLocalDigits(){return Math.max(this.maxLength-this.prefix.length,0)}updated(e){if(!e.has(\"value\")&&!e.has(\"prefix\"))return;let r=this.inputEl;if(!r)return;let i=this.localDigits;r.value!==i&&(r.value=i)}dispatchValueEvent(e,r){let i=r.length?`${this.prefix}${r}`:\"\";this.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,composed:!0}))}focus(){this.inputEl?.focus()}render(){return u`<div @click=${this.handleHostClick} style=\"display: contents;\"><span class=\"flag\" aria-hidden=\"true\">${ch}</span><span class=\"prefix\">${this.prefix}</span><input id=${this.inputId} type=\"tel\" inputmode=\"numeric\" autocomplete=\"tel-national\" ?disabled=${this.disabled} placeholder=${this.placeholder} @input=${this.handleInput} @change=${this.handleChange} /></div>`}}"
|
|
116
116
|
},
|
|
117
117
|
{
|
|
118
118
|
"kind": "variable",
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
{
|
|
138
138
|
"kind": "variable",
|
|
139
139
|
"name": "ve",
|
|
140
|
-
"default": "class extends v{constructor(){super(...arguments);this.disabled=!1;this.selectedCategory=null;this.isExpanded=!1;this.categoryLoading=!1;this._setupTask=new $(this,{task:async([e,r])=>{let i=e?.find(n=>n.type===B.KLARNA);return!i||!r?Y:{manager:i.manager}},args:()=>[this.primerContext?.paymentMethods,this.primerContext?.headlessUtils]});this.handleExpandedChange=e=>{this.isExpanded=e.detail.expanded,this.isExpanded||(this.selectedCategory=null,this.categoryLoading=!1,this.klarnaContainer&&(this.klarnaContainer.innerHTML=\"\"))};this.klarnaPaymentInProgress=!1}async startKlarnaPayment(){if(!(!this._setupTask.value||!this.selectedCategory)){this.klarnaPaymentInProgress=!0;try{await this._setupTask.value.manager.start({paymentMethodCategoryId:this.selectedCategory})}catch(e){
|
|
140
|
+
"default": "class extends v{constructor(){super(...arguments);this.disabled=!1;this.selectedCategory=null;this.isExpanded=!1;this.categoryLoading=!1;this._setupTask=new $(this,{task:async([e,r])=>{let i=e?.find(n=>n.type===B.KLARNA);return!i||!r?Y:{manager:i.manager}},args:()=>[this.primerContext?.paymentMethods,this.primerContext?.headlessUtils]});this.handleExpandedChange=e=>{this.isExpanded=e.detail.expanded,this.isExpanded||(this.selectedCategory=null,this.categoryLoading=!1,this.klarnaContainer&&(this.klarnaContainer.innerHTML=\"\"))};this.klarnaPaymentInProgress=!1}async startKlarnaPayment(){if(!(!this._setupTask.value||!this.selectedCategory)){this.klarnaPaymentInProgress=!0;try{await this._setupTask.value.manager.start({paymentMethodCategoryId:this.selectedCategory})}catch(e){T.errorWithDatadog(\"Failed to start Klarna payment\",{error:e})}finally{this.klarnaPaymentInProgress=!1}}}async renderSelectedCategory(){if(!(!this._setupTask.value||!this.selectedCategory||!this.klarnaContainer))try{this.klarnaContainer.innerHTML=\"\",this.categoryLoading=!0,await this._setupTask.value.manager.renderCategory({containerId:this.klarnaContainer,paymentMethodCategoryId:this.selectedCategory,onHeightChange:()=>{}})}catch(e){T.errorWithDatadog(\"Failed to render Klarna category\",{error:e})}finally{this.categoryLoading=!1}}selectCategory(e){this.disabled||(this.selectedCategory=e)}updated(e){e.has(\"selectedCategory\")&&this.selectedCategory&&this.renderSelectedCategory()}renderCategorySelection(){let e=this.primerContext?.klarnaCategories?.categories||[];return this.primerContext?.klarnaCategories?.isLoading||!1?u`<div class=\"loading\"><primer-spinner size=\"small\"></primer-spinner></div>`:(e.length>0&&!this.selectedCategory&&this.selectCategory(e[0].id),e.length===1?y:u`<div class=\"category-selection\">${e.map(i=>u`<button class=${X({\"category-button\":!0,selected:i.id===this.selectedCategory,loading:this.categoryLoading&&i.id===this.selectedCategory})} @click=${()=>{this.selectCategory(i.id)}} ?disabled=${this.disabled} ><span class=${X({\"category-label\":!0,hidden:this.categoryLoading&&i.id===this.selectedCategory})} >${i.name}</span >${this.categoryLoading&&i.id===this.selectedCategory?u`<primer-spinner class=\"category-spinner\" size=\"small\" compact ></primer-spinner>`:y}</button>`)}</div>`)}renderExpandedContent(){return u` ${this.renderCategorySelection()}<div class=\"klarna-category-container ${!this.categoryLoading&&this.selectedCategory?\"visible\":\"\"}\" ><div id=\"klarna-category-container\" class=\"klarna-category-content\" ></div></div><primer-payment-method-accordion-confirm-button ?disabled=${!this.selectedCategory||this.disabled} ?loading=${!!this.primerContext?.sdkState?.isProcessing} @confirm=${()=>this.startKlarnaPayment()} ></primer-payment-method-accordion-confirm-button>`}render(){return this._setupTask.render({error:e=>{let r=e instanceof Error?e.message:\"Unknown error in Klarna\";return u`<div class=\"error\"> Error loading Klarna: ${r}</div>`},complete:({manager:e})=>e?u`<primer-payment-method-accordion .type=${B.KLARNA} ?disabled=${this.disabled} .expanded=${this.isExpanded} ?suppress-blur-collapse=${this.klarnaPaymentInProgress} @expanded-change=${this.handleExpandedChange} >${this.renderExpandedContent()}</primer-payment-method-accordion>`:y})}}"
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
"kind": "variable",
|
|
@@ -147,22 +147,22 @@
|
|
|
147
147
|
{
|
|
148
148
|
"kind": "variable",
|
|
149
149
|
"name": "Ve",
|
|
150
|
-
"default": "class extends v{constructor(){super();this.disabled=!1;this.buttonContainerRef=
|
|
150
|
+
"default": "class extends v{constructor(){super();this.disabled=!1;this.buttonContainerRef=Vt();this.renderButtonTask=new $(this,{args:()=>[this.paymentMethod],task:async([e])=>{if(!e)return Y;await this.updateComplete;let r=this.buttonContainerRef.value;if(!r)throw new Error(\"Button container not found\");let i=e.manager.createButton(),n=Wa(r);return await i.render(r,{style:{buttonHeight:n}}),this.disabled&&await i.setDisabled(this.disabled),this.disabled&&(await this.updateComplete,or(this.disabled,this.buttonContainerRef)),i}})}attributeChangedCallback(e,r,i){if(super.attributeChangedCallback(e,r,i),e===\"disabled\"&&r!==i){let n=i!==null,o=this.renderButtonTask.value;o&&o.setDisabled(n)}}updated(e){e.has(\"disabled\")&&or(this.disabled,this.buttonContainerRef)}render(){return u`<div class=\"native-button-container\" ${Et(this.buttonContainerRef)} ></div>`}}"
|
|
151
151
|
},
|
|
152
152
|
{
|
|
153
153
|
"kind": "variable",
|
|
154
154
|
"name": "He",
|
|
155
|
-
"default": "class extends v{constructor(){super();this.disabled=!1;this.buttonContainerRef=
|
|
155
|
+
"default": "class extends v{constructor(){super();this.disabled=!1;this.buttonContainerRef=Vt();this.renderButtonTask=new $(this,{args:()=>[this.paymentMethod],task:async([e])=>{if(!e)return Y;await this.updateComplete;let r=this.buttonContainerRef.value;if(!r)throw new Error(\"Button container not found\");let i=e.manager.createButton(),n=_l(Wa(this));return await i.render(r,{style:{buttonHeight:n}}),this.disabled&&await i.setDisabled(this.disabled),this.disabled&&(await this.updateComplete,or(this.disabled,this.buttonContainerRef)),i}})}attributeChangedCallback(e,r,i){if(super.attributeChangedCallback(e,r,i),e===\"disabled\"&&r!==i){let n=i!==null,o=this.renderButtonTask.value;o&&o.setDisabled(n)}}updated(e){e.has(\"disabled\")&&or(this.disabled,this.buttonContainerRef)}render(){return u`<div class=\"native-button-container\" ${Et(this.buttonContainerRef)} ></div>`}}"
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
158
|
"kind": "variable",
|
|
159
159
|
"name": "be",
|
|
160
|
-
"default": "class extends v{constructor(){super(...arguments);this.disabled=!1;this.currentState=\"collapsed\";this.blikCode=\"\";this.errorMessage=\"\";this.pollingDuration=0;this.pollingTimer=null;this.handleExpandedChange=async e=>{if(this.disabled)return;if(!e.detail.expanded){this.handleCollapse();return}if(this.currentState!==\"collapsed\")return;if(!this.paymentMethod?.manager){this.errorMessage=E(\"something_went_wrong_error\",{id:\"something_went_wrong_error\"}),this.currentState=\"error\",
|
|
160
|
+
"default": "class extends v{constructor(){super(...arguments);this.disabled=!1;this.currentState=\"collapsed\";this.blikCode=\"\";this.errorMessage=\"\";this.pollingDuration=0;this.pollingTimer=null;this.handleExpandedChange=async e=>{if(this.disabled)return;if(!e.detail.expanded){this.handleCollapse();return}if(this.currentState!==\"collapsed\")return;if(!this.paymentMethod?.manager){this.errorMessage=E(\"something_went_wrong_error\",{id:\"something_went_wrong_error\"}),this.currentState=\"error\",T.error(\"Manager not available when expanding BLIK form\");return}this.currentState=\"expanded-input\",await this.updateComplete,this.shadowRoot?.querySelector(\"#blik-code\")?.focus()};this.handleCollapse=()=>{this.currentState=\"collapsed\",this.blikCode=\"\",this.errorMessage=\"\",this.stopPollingTimer()};this.handleInput=e=>{let r=e.target,i=r.value,o=i.replace(/\\D/g,\"\").slice(0,6);i!==o&&(r.value=o),this.blikCode=o,this.currentState===\"error\"&&(this.currentState=\"expanded-input\",this.errorMessage=\"\"),o.length===6&&this.submitBlikCode()};this.handleRetry=async()=>{this.currentState=\"expanded-input\",this.errorMessage=\"\",this.blikCode=\"\",await this.updateComplete,this.shadowRoot?.querySelector(\"#blik-code\")?.focus()}}get isExpanded(){return this.currentState!==\"collapsed\"}startPollingTimer(){this.pollingDuration=0,this.pollingTimer=window.setInterval(()=>{this.pollingDuration+=1},1e3)}stopPollingTimer(){this.pollingTimer!==null&&(window.clearInterval(this.pollingTimer),this.pollingTimer=null),this.pollingDuration=0}async submitBlikCode(){if(this.blikCode.length!==6){this.errorMessage=E(\"sixDigitCodeErrorTooShort\",{id:\"sixDigitCodeErrorTooShort\"}),this.currentState=\"error\";return}let e=this.paymentMethod?.manager;if(!e){this.errorMessage=\"BLIK payment method not initialized\",this.currentState=\"error\",T.error(\"BLIK manager not available via loadManagerTask\");return}this.currentState=\"loading\",this.errorMessage=\"\",this.startPollingTimer();try{await e.start({blikCode:this.blikCode}),this.stopPollingTimer(),this.currentState=\"collapsed\",this.blikCode=\"\"}catch(r){this.stopPollingTimer(),this.currentState=\"error\",this.errorMessage=r instanceof Error?r.message:E(\"tokenizationError\",{id:\"tokenizationError\"}),T.errorWithDatadog(\"BLIK payment failed\",{error:r instanceof Error?{message:r.message,name:r.name}:\"Unknown error\"})}}renderExpandedInput(){return u`<div class=\"blik-input-wrapper\"><label for=\"blik-code\" class=\"blik-label\">${E(\"getCodeFromBankingApp\",{id:\"getCodeFromBankingApp\"})}</label><input id=\"blik-code\" type=\"text\" inputmode=\"numeric\" pattern=\"[0-9]*\" maxlength=\"6\" class=\"blik-input\" .value=\"${this.blikCode}\" @input=\"${this.handleInput}\" ?disabled=\"${this.disabled}\" placeholder=\"000000\" aria-label=\"${E(\"sixDigitCodeLabel\",{id:\"sixDigitCodeLabel\"})}\" autocomplete=\"off\" spellcheck=\"false\" /></div>`}renderLoading(){return u`<div class=\"blik-loading\"><primer-spinner size=\"medium\"></primer-spinner>${this.pollingDuration>30?u`<div class=\"blik-timeout-warning\"> This is taking longer than expected... </div>`:y}</div>`}renderError(){return u`<div class=\"blik-error\"><div class=\"blik-error-message\" role=\"alert\">${this.errorMessage||E(\"something_went_wrong_error\",{id:\"something_went_wrong_error\"})}</div><button class=\"blik-retry-button\" @click=\"${this.handleRetry}\" ?disabled=\"${this.disabled}\" >${E(\"retry_button\",{id:\"retry_button\"})}</button></div>`}renderExpandedState(){switch(this.currentState){case\"expanded-input\":return this.renderExpandedInput();case\"loading\":return this.renderLoading();case\"error\":return this.renderError();default:return y}}disconnectedCallback(){super.disconnectedCallback(),this.stopPollingTimer()}render(){return u`<primer-payment-method-accordion .type=${this.paymentMethod?.type} ?disabled=${this.disabled} .expanded=${this.isExpanded} @expanded-change=${this.handleExpandedChange} >${this.isExpanded?this.renderExpandedState():y}</primer-payment-method-accordion>`}}"
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
"kind": "variable",
|
|
164
|
-
"name": "
|
|
165
|
-
"default": "class extends v{constructor(){super(...arguments);this.disabled=!1;this.currentState=\"collapsed\";this.phoneNumber=\"\";this.errorMessage=\"\";this.handleExpandedChange=async e=>{if(!this.disabled){if(!e.detail.expanded){this.handleCollapse();return}if(this.currentState===\"collapsed\"){if(!this.paymentMethod?.manager){this.errorMessage=E(\"something_went_wrong_error\",{id:\"something_went_wrong_error\"}),this.currentState=\"error\",
|
|
164
|
+
"name": "Pe",
|
|
165
|
+
"default": "class extends v{constructor(){super(...arguments);this.disabled=!1;this.currentState=\"collapsed\";this.phoneNumber=\"\";this.errorMessage=\"\";this.handleExpandedChange=async e=>{if(!this.disabled){if(!e.detail.expanded){this.handleCollapse();return}if(this.currentState===\"collapsed\"){if(!this.paymentMethod?.manager){this.errorMessage=E(\"something_went_wrong_error\",{id:\"something_went_wrong_error\"}),this.currentState=\"error\",T.error(\"Manager not available when expanding MB WAY form\");return}this.currentState=\"expanded-input\",await this.updateComplete,this.shadowRoot?.querySelector(\"primer-pt-phone-number-input\")?.focus()}}};this.handleCollapse=()=>{this.currentState=\"collapsed\",this.phoneNumber=\"\",this.errorMessage=\"\"};this.handleInput=e=>{this.phoneNumber=e.detail,this.currentState===\"error\"&&(this.currentState=\"expanded-input\",this.errorMessage=\"\")};this.handleRetry=async()=>{this.currentState=\"expanded-input\",this.errorMessage=\"\",this.phoneNumber=\"\",await this.updateComplete,this.shadowRoot?.querySelector(\"primer-pt-phone-number-input\")?.focus()}}get isExpanded(){return this.currentState!==\"collapsed\"}get isPhoneValid(){return this.phoneNumber.length>=Kl&&this.phoneNumber.length<=Fl&&/^\\+\\d+$/.test(this.phoneNumber)}async submit(){if(!this.isPhoneValid){this.errorMessage=E(\"telephoneNumberErrorTooShort\",{id:\"telephoneNumberErrorTooShort\"}),this.currentState=\"error\";return}let e=this.paymentMethod?.manager;if(!e){this.errorMessage=\"MB WAY payment method not initialized\",this.currentState=\"error\",T.error(\"MB WAY manager not available\");return}this.currentState=\"loading\",this.errorMessage=\"\";try{await e.start({phoneNumber:this.phoneNumber}),this.currentState=\"collapsed\",this.phoneNumber=\"\"}catch(r){this.currentState=\"error\",this.errorMessage=r instanceof Error?r.message:E(\"tokenizationError\",{id:\"tokenizationError\"}),T.errorWithDatadog(\"MB WAY payment failed\",{error:r instanceof Error?{message:r.message,name:r.name}:\"Unknown error\"})}}renderExpandedInput(){return u`<div class=\"mbway-input-wrapper\"><label class=\"mbway-label\" for=\"primer-mbway-phone\">${E(\"telephoneNumberLabel\",{id:\"telephoneNumberLabel\"})}</label><primer-pt-phone-number-input input-id=\"primer-mbway-phone\" .value=${this.phoneNumber} .placeholder=${E(\"telephoneNumberPlaceholder\",{id:\"telephoneNumberPlaceholder\"})} .maxLength=${Fl} .minLength=${Kl} ?disabled=${this.disabled} ?has-errors=${!!this.errorMessage} @input=${this.handleInput} ></primer-pt-phone-number-input><button class=\"mbway-submit-button\" @click=${()=>void this.submit()} ?disabled=${this.disabled||!this.isPhoneValid} >${E(\"pay\",{id:\"pay\"})}</button></div>`}renderLoading(){let e=E(\"Complete your payment in {appName}\",{id:\"completeYourPaymentInTheApp\"}).replace(\"{appName}\",\"MB WAY\");return u`<div class=\"mbway-loading\"><primer-spinner size=\"medium\"></primer-spinner><div class=\"mbway-loading-message\">${e}</div></div>`}renderError(){return u`<div class=\"mbway-error\"><div class=\"mbway-error-message\" role=\"alert\">${this.errorMessage||E(\"something_went_wrong_error\",{id:\"something_went_wrong_error\"})}</div><button class=\"mbway-retry-button\" @click=${this.handleRetry} ?disabled=${this.disabled} >${E(\"retry_button\",{id:\"retry_button\"})}</button></div>`}renderExpandedState(){switch(this.currentState){case\"expanded-input\":return this.renderExpandedInput();case\"loading\":return this.renderLoading();case\"error\":return this.renderError();default:return y}}render(){return u`<primer-payment-method-accordion .type=${this.paymentMethod?.type} ?disabled=${this.disabled} .expanded=${this.isExpanded} @expanded-change=${this.handleExpandedChange} >${this.isExpanded?this.renderExpandedState():y}</primer-payment-method-accordion>`}}"
|
|
166
166
|
},
|
|
167
167
|
{
|
|
168
168
|
"kind": "variable",
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
{
|
|
178
178
|
"kind": "variable",
|
|
179
179
|
"name": "$e",
|
|
180
|
-
"default": "class extends v{constructor(){super(...arguments);this.disabled=!1;this._setupTask=new $(this,{task:([e,r])=>{if(!e||!r)return Y;let i=r.getPaymentMethodConfiguration(e);if(!i)return Y;let n=Hl(e)?this.primerContext?.clientOptions?.giftCard:void 0,o=i.displayMetadata.button,s=this._getBackgroundColor(e,o,n?.background),l=this._getTextColor(s);return{backgroundColor:s,textColor:l,name:i.name,alt:n?.logoAlt??i.name,displayName:this._getDisplayName(e,o.text,n?.text),iconUrl:this._getIconUrl(e,o,s,n?.logoSrc),iconPosition:this._getIconPosition(e,o)}},args:()=>[this.type,this.primerContext?.headlessUtils]})}_legacyGetButtonLabel(e){if(!e)return;let r=e?
|
|
180
|
+
"default": "class extends v{constructor(){super(...arguments);this.disabled=!1;this._setupTask=new $(this,{task:([e,r])=>{if(!e||!r)return Y;let i=r.getPaymentMethodConfiguration(e);if(!i)return Y;let n=Hl(e)?this.primerContext?.clientOptions?.giftCard:void 0,o=i.displayMetadata.button,s=this._getBackgroundColor(e,o,n?.background),l=this._getTextColor(s);return{backgroundColor:s,textColor:l,name:i.name,alt:n?.logoAlt??i.name,displayName:this._getDisplayName(e,o.text,n?.text),iconUrl:this._getIconUrl(e,o,s,n?.logoSrc),iconPosition:this._getIconPosition(e,o)}},args:()=>[this.type,this.primerContext?.headlessUtils]})}_legacyGetButtonLabel(e){if(!e)return;let r=e?xn(e):\"\";return r===\"payWith\"&&(r=\"pay_with\"),E(r,{id:r})}_getBackgroundColor(e,r,i){switch(e){case W.KLARNA:case W.ADYEN_KLARNA:return r.backgroundColor.light??r.backgroundColor.colored;default:return i??r.backgroundColor.colored??r.backgroundColor.light}}_getIconUrl(e,r,i,n){if(n)return n;switch(e){case W.KLARNA:case W.ADYEN_KLARNA:return bh;case W.PAY_NL_PAYCONIQ:return i===r.backgroundColor.light?yh:fh;case W.ADYEN_CASHAPP:return r.iconUrl.dark??r.iconUrl.colored??r.iconUrl.light;default:return e===\"TRIPLE_A\"?vh:r.iconUrl.colored??r.iconUrl.light}}_getIconPosition(e,r){switch(e){case W.KLARNA:case W.ADYEN_KLARNA:return\"END\";default:return r.iconPositionRelativeToText||\"START\"}}_getTextColor(e){let r=e.replace(\"#\",\"\");if(r.length<6)return;let i=parseInt(r.substring(0,2),16),n=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16);return isNaN(i)||isNaN(n)||isNaN(o)?void 0:(.2126*i+.7152*n+.0722*o)/255>.6?\"#000000\":\"#FFFFFF\"}_getDisplayName(e,r,i){switch(e){case W.KLARNA:return this.primerContext?.clientOptions?.klarna?.buttonOptions?.text??i??this._legacyGetButtonLabel(r)??this._legacyGetButtonLabel(\"Pay with\");case W.ADYEN_KLARNA:return this.primerContext?.clientOptions?.adyenKlarna?.buttonOptions?.text??i??this._legacyGetButtonLabel(r)??this._legacyGetButtonLabel(\"Pay with\");default:return i??this._legacyGetButtonLabel(r)}}_handleClick(){this.disabled||this.dispatchEvent(new Event(\"payment-method-click\",{bubbles:!0,composed:!0}))}render(){return this._setupTask.render({error:()=>y,complete:e=>{this.style.setProperty(\"--payment-method-button-bg-color\",e.backgroundColor),e.textColor&&this.style.setProperty(\"--payment-method-button-text-color\",e.textColor);let r={loading:!!this.primerContext?.sdkState?.isProcessing,\"icon-end\":e.iconPosition===\"END\",\"image-only\":!e.displayName};return u`<primer-button @click=\"${()=>this._handleClick()}\" class=${X(r)} title=\"${E(\"pay_with\",{id:\"pay_with\"})} ${e.name}\" ?disabled=${this.disabled} ><img src=\"${e.iconUrl}\" alt=\"${e.alt}\" />${k(e.displayName,()=>u`<span class=\"button-text\">${e.displayName}</span>`)}</primer-button>`}})}}"
|
|
181
181
|
},
|
|
182
182
|
{
|
|
183
183
|
"kind": "variable",
|
|
@@ -187,12 +187,12 @@
|
|
|
187
187
|
{
|
|
188
188
|
"kind": "variable",
|
|
189
189
|
"name": "ne",
|
|
190
|
-
"default": "class extends v{constructor(){super(...arguments);this.formData={};this.errors={};this.touchedFields=new Set;this.dirtyFields=new Set;this.focusedField=null;this.submitted=!1;this.countryOptions=[];this._initializationTask=new $(this,{task:async([e,r])=>{if(!e||!r)return Y;let i=this.extractFieldConfig(e);return await this.initializeCountryOptions(),i},args:()=>[this.primerContext?.configuration??null,this.primerContext?.headlessUtils]})}connectedCallback(){super.connectedCallback(),this._initializationTask.value}extractFieldConfig(e){if(e?.checkoutModules){let r=e.checkoutModules.find(i=>i.type===\"BILLING_ADDRESS\");if(r?.options){let i=r.options;return Object.keys(
|
|
190
|
+
"default": "class extends v{constructor(){super(...arguments);this.formData={};this.errors={};this.touchedFields=new Set;this.dirtyFields=new Set;this.focusedField=null;this.submitted=!1;this.countryOptions=[];this._initializationTask=new $(this,{task:async([e,r])=>{if(!e||!r)return Y;let i=this.extractFieldConfig(e);return await this.initializeCountryOptions(),i},args:()=>[this.primerContext?.configuration??null,this.primerContext?.headlessUtils]})}connectedCallback(){super.connectedCallback(),this._initializationTask.value}extractFieldConfig(e){if(e?.checkoutModules){let r=e.checkoutModules.find(i=>i.type===\"BILLING_ADDRESS\");if(r?.options){let i=r.options;return Object.keys(Bn).reduce((n,o)=>({...n,[o]:i[o]??!1}),{})}}return this.defaultFieldConfig}async initializeCountryOptions(){try{let e=Dn(\"en\");this.countryOptions=[...e.map(([n,o])=>({value:n,label:o}))],this.requestUpdate(\"countryOptions\");let r=vn();if(r===\"en\"||r===\"en-GB\"||r.startsWith(\"en-\"))return;if(await Nd(r)){let n=Dn(r);this.countryOptions=[...n.map(([o,s])=>({value:o,label:s}))],this.requestUpdate(\"countryOptions\")}}catch(e){T.errorWithDatadog(\"Failed to load country locale\",{error:e})}}get fieldConfig(){return this.extractFieldConfig(this.primerContext?.configuration)}get defaultFieldConfig(){return Object.keys(Bn).reduce((e,r)=>({...e,[r]:!1}),{})}get shouldShowForm(){return this.fieldConfig.postalCode}handleInput(e,r){this.formData={...this.formData,[e]:r},this.dirtyFields.add(e),(this.submitted||this.dirtyFields.has(e)&&this.touchedFields.has(e))&&this.validateField(e),this.dispatchEvent(new CustomEvent(\"primer-billing-address-change\",{detail:this.formData,bubbles:!0,composed:!0}))}handleFocus(e){this.focusedField=e}handleBlur(e){this.focusedField=null,this.touchedFields.add(e),this.validateField(e)}validateField(e){let r=this.formData[e],i=this.fieldConfig[e];if(!i){delete this.errors[e];return}if(i&&(!r||r.trim()===\"\")){let n=`${e}ErrorRequired`;this.errors={...this.errors,[e]:E(\"This field is required\",{id:n})}}else{let n={...this.errors};delete n[e],this.errors=n}}validateForm(){return Object.keys(Bn).forEach(e=>{let r=e;this.fieldConfig[r]&&this.validateField(r)}),Object.keys(this.errors).length===0}async validateForSubmission(){if(!this.shouldShowForm)return!0;this.submitted=!0,Object.keys(this.fieldConfig).forEach(r=>{this.fieldConfig[r]&&this.touchedFields.add(r)});let e=this.validateForm();return this.requestUpdate(),await this.updateComplete,e}async submitToSDK(){if(this.primerContext?.headlessUtils?.setBillingAddress)try{return await this.primerContext?.headlessUtils.setBillingAddress(this.formData),this.dispatchEvent(new CustomEvent(\"primer-billing-address-submit\",{detail:this.formData,bubbles:!0,composed:!0})),!0}catch(e){return T.errorWithDatadog(\"Failed to set billing address\",{error:e}),!1}return!0}shouldShowError(e){let r=!!this.errors[e],i=this.dirtyFields.has(e),n=this.touchedFields.has(e);return r&&(this.submitted||i&&n)}render(){return this._initializationTask.render({pending:()=>y,error:()=>y,complete:()=>this.shouldShowForm?(this.removeAttribute(\"hidden\"),u`<div class=\"billing-address-form\"><div class=\"billing-address-title\">${E(\"Billing address\",{id:\"billingAddressLabel\"})}</div>${k(this.fieldConfig.countryCode,()=>u`<primer-input-wrapper .focusWithin=${this.focusedField===\"countryCode\"} .hasError=${this.shouldShowError(\"countryCode\")} ><primer-input-label slot=\"label\">${E(\"Country code\",{id:\"countryCodeLabel\"})}</primer-input-label><primer-select slot=\"input\" id=\"countryCode\" name=\"countryCode\" .value=${this.formData.countryCode||\"\"} .options=${this.countryOptions} .hasError=${this.shouldShowError(\"countryCode\")} placeholder=${E(\"Select a country\",{id:\"countrySelectPlaceholder\"})} @input=${e=>this.handleInput(\"countryCode\",e.detail)} @focus=${()=>this.handleFocus(\"countryCode\")} @blur=${()=>this.handleBlur(\"countryCode\")} ></primer-select>${k(this.shouldShowError(\"countryCode\"),()=>u`<primer-input-error slot=\"error\">${this.errors.countryCode}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.firstName||this.fieldConfig.lastName,()=>u`<div class=\"billing-address-row\">${k(this.fieldConfig.firstName,()=>u`<primer-input-wrapper .focusWithin=${this.focusedField===\"firstName\"} .hasError=${this.shouldShowError(\"firstName\")} ><primer-input-label slot=\"label\">${E(\"First name\",{id:\"firstNameLabel\"})}</primer-input-label><primer-input slot=\"input\" id=\"firstName\" name=\"firstName\" type=\"text\" .value=${this.formData.firstName||\"\"} placeholder=${E(\"First name\",{id:\"firstNamePlaceholder\"})} @input=${e=>this.handleInput(\"firstName\",e.detail)} @focus=${()=>this.handleFocus(\"firstName\")} @blur=${()=>this.handleBlur(\"firstName\")} ></primer-input>${k(this.shouldShowError(\"firstName\"),()=>u`<primer-input-error slot=\"error\">${this.errors.firstName}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.lastName,()=>u`<primer-input-wrapper .focusWithin=${this.focusedField===\"lastName\"} .hasError=${this.shouldShowError(\"lastName\")} ><primer-input-label slot=\"label\">${E(\"Last name\",{id:\"lastNameLabel\"})}</primer-input-label><primer-input slot=\"input\" id=\"lastName\" name=\"lastName\" type=\"text\" .value=${this.formData.lastName||\"\"} placeholder=${E(\"Last name\",{id:\"lastNamePlaceholder\"})} @input=${e=>this.handleInput(\"lastName\",e.detail)} @focus=${()=>this.handleFocus(\"lastName\")} @blur=${()=>this.handleBlur(\"lastName\")} ></primer-input>${k(this.shouldShowError(\"lastName\"),()=>u`<primer-input-error slot=\"error\">${this.errors.lastName}</primer-input-error>`)}</primer-input-wrapper>`)}</div>`)} ${k(this.fieldConfig.addressLine1,()=>u`<primer-input-wrapper .focusWithin=${this.focusedField===\"addressLine1\"} .hasError=${this.shouldShowError(\"addressLine1\")} ><primer-input-label slot=\"label\">${E(\"Address line 1\",{id:\"addressLine1\"})}</primer-input-label><primer-input slot=\"input\" id=\"addressLine1\" name=\"addressLine1\" type=\"text\" .value=${this.formData.addressLine1||\"\"} placeholder=${E(\"Address line 1\",{id:\"addressLine1Placeholder\"})} @input=${e=>this.handleInput(\"addressLine1\",e.detail)} @focus=${()=>this.handleFocus(\"addressLine1\")} @blur=${()=>this.handleBlur(\"addressLine1\")} ></primer-input>${k(this.shouldShowError(\"addressLine1\"),()=>u`<primer-input-error slot=\"error\">${this.errors.addressLine1}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.addressLine2,()=>u`<primer-input-wrapper .focusWithin=${this.focusedField===\"addressLine2\"} .hasError=${this.shouldShowError(\"addressLine2\")} ><primer-input-label slot=\"label\">${E(\"Address line 2\",{id:\"addressLine2\"})}</primer-input-label><primer-input slot=\"input\" id=\"addressLine2\" name=\"addressLine2\" type=\"text\" .value=${this.formData.addressLine2||\"\"} placeholder=${E(\"Address line 2\",{id:\"addressLine2Placeholder\"})} @input=${e=>this.handleInput(\"addressLine2\",e.detail)} @focus=${()=>this.handleFocus(\"addressLine2\")} @blur=${()=>this.handleBlur(\"addressLine2\")} ></primer-input>${k(this.shouldShowError(\"addressLine2\"),()=>u`<primer-input-error slot=\"error\">${this.errors.addressLine2}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.postalCode||this.fieldConfig.city,()=>u`<div class=\"billing-address-row\">${k(this.fieldConfig.postalCode,()=>u`<primer-input-wrapper .focusWithin=${this.focusedField===\"postalCode\"} .hasError=${this.shouldShowError(\"postalCode\")} ><primer-input-label slot=\"label\">${E(\"Postal code\",{id:\"postalCodeLabel\"})}</primer-input-label><primer-input slot=\"input\" id=\"postalCode\" name=\"postalCode\" type=\"text\" .value=${this.formData.postalCode||\"\"} placeholder=${E(\"90210\",{id:\"postalCodePlaceholder\"})} @input=${e=>this.handleInput(\"postalCode\",e.detail)} @focus=${()=>this.handleFocus(\"postalCode\")} @blur=${()=>this.handleBlur(\"postalCode\")} ></primer-input>${k(this.shouldShowError(\"postalCode\"),()=>u`<primer-input-error slot=\"error\">${this.errors.postalCode}</primer-input-error>`)}</primer-input-wrapper>`)} ${k(this.fieldConfig.city,()=>u`<primer-input-wrapper .focusWithin=${this.focusedField===\"city\"} .hasError=${this.shouldShowError(\"city\")} ><primer-input-label slot=\"label\">${E(\"City\",{id:\"cityLabel\"})}</primer-input-label><primer-input slot=\"input\" id=\"city\" name=\"city\" type=\"text\" .value=${this.formData.city||\"\"} placeholder=${E(\"Cape Town\",{id:\"cityPlaceholder\"})} @input=${e=>this.handleInput(\"city\",e.detail)} @focus=${()=>this.handleFocus(\"city\")} @blur=${()=>this.handleBlur(\"city\")} ></primer-input>${k(this.shouldShowError(\"city\"),()=>u`<primer-input-error slot=\"error\">${this.errors.city}</primer-input-error>`)}</primer-input-wrapper>`)}</div>`)} ${k(this.fieldConfig.state,()=>u`<primer-input-wrapper .focusWithin=${this.focusedField===\"state\"} .hasError=${this.shouldShowError(\"state\")} ><primer-input-label slot=\"label\">${E(\"State / Region / County\",{id:\"stateLabel\"})}</primer-input-label><primer-input slot=\"input\" id=\"state\" name=\"state\" type=\"text\" .value=${this.formData.state||\"\"} placeholder=${E(\"State / Region / County\",{id:\"statePlaceholder\"})} @input=${e=>this.handleInput(\"state\",e.detail)} @focus=${()=>this.handleFocus(\"state\")} @blur=${()=>this.handleBlur(\"state\")} ></primer-input>${k(this.shouldShowError(\"state\"),()=>u`<primer-input-error slot=\"error\">${this.errors.state}</primer-input-error>`)}</primer-input-wrapper>`)}</div>`):(this.setAttribute(\"hidden\",\"\"),y)})}}"
|
|
191
191
|
},
|
|
192
192
|
{
|
|
193
193
|
"kind": "variable",
|
|
194
194
|
"name": "oe",
|
|
195
|
-
"default": "class extends v{constructor(){super();this.hasSlottedSubmit=!1;this.isEditMode=!1;this.deletePaymentMethodId=null;this.isDeleting=!1;this.errorMessage=\"\";this.animationDuration=300;this._isHandlingContextEvent=!1;this._contextVaultSubmitListener=null;this.deleteAssetConfig=null;this.handleSubmitSlotChange=e=>{let i=e.target.assignedNodes({flatten:!0});this.hasSlottedSubmit=i.length>0};this.handleToggleEditMode=e=>{this.isEditMode=e.detail,this.deletePaymentMethodId=null,this.isEditMode&&this.primerContext?.vaultItem&&this.primerContext?.vaultItem.setSelectedVaultedPaymentMethod(null)};this.handleDeletePaymentMethod=async e=>{if(this.deletePaymentMethodId=e.detail,this.deletePaymentMethodId&&this.primerContext?.vaultManager&&this.primerContext?.headlessUtils){let r=this.primerContext?.vaultManager.vaultedPaymentMethods.find(i=>i.id===this.deletePaymentMethodId);r&&(this.deleteAssetConfig=await Ja(r,this.primerContext?.headlessUtils,this.primerContext?.vaultManager))}};this.handleCancelDelete=()=>{this.deletePaymentMethodId=null,this.deleteAssetConfig=null};this.handleConfirmDelete=async()=>{if(!this.primerContext?.vaultManager?.deleteVaultedPaymentMethod||!this.deletePaymentMethodId){this.errorMessage=E(\"something_went_wrong_error\",{id:\"something_went_wrong_error\"});return}try{this.isDeleting=!0,await this.primerContext?.vaultManager.deleteVaultedPaymentMethod(this.deletePaymentMethodId),this.deletePaymentMethodId=null,this.deleteAssetConfig=null}catch(e){this.errorMessage=e instanceof Error?e.message:E(\"something_went_wrong_error\",{id:\"something_went_wrong_error\"})}finally{this.isDeleting=!1}};this.handlePaymentError=e=>{let r=e.detail?.error;this.errorMessage=r instanceof Error?r.message:E(\"payment_processing_error\",{id:\"payment_processing_error\"})};this.handleCloseError=()=>{this.errorMessage=\"\"};this.handleSlotButtonClick=e=>{let i=e.target.closest(\"button, primer-button\");if(!i)return;let n=i;this.isSubmitButton(n)&&(e.preventDefault(),this.submitVaultPayment())};this.handleDirectSubmit=()=>{this.submitVaultPayment()};this.handleContextVaultSubmit=e=>{if(!this._isHandlingContextEvent){this._isHandlingContextEvent=!0;try{e.target!==this&&(e.stopPropagation(),this.submitVaultPayment())}finally{this._isHandlingContextEvent=!1}}};new
|
|
195
|
+
"default": "class extends v{constructor(){super();this.hasSlottedSubmit=!1;this.isEditMode=!1;this.deletePaymentMethodId=null;this.isDeleting=!1;this.errorMessage=\"\";this.animationDuration=300;this._isHandlingContextEvent=!1;this._contextVaultSubmitListener=null;this.deleteAssetConfig=null;this.handleSubmitSlotChange=e=>{let i=e.target.assignedNodes({flatten:!0});this.hasSlottedSubmit=i.length>0};this.handleToggleEditMode=e=>{this.isEditMode=e.detail,this.deletePaymentMethodId=null,this.isEditMode&&this.primerContext?.vaultItem&&this.primerContext?.vaultItem.setSelectedVaultedPaymentMethod(null)};this.handleDeletePaymentMethod=async e=>{if(this.deletePaymentMethodId=e.detail,this.deletePaymentMethodId&&this.primerContext?.vaultManager&&this.primerContext?.headlessUtils){let r=this.primerContext?.vaultManager.vaultedPaymentMethods.find(i=>i.id===this.deletePaymentMethodId);r&&(this.deleteAssetConfig=await Ja(r,this.primerContext?.headlessUtils,this.primerContext?.vaultManager))}};this.handleCancelDelete=()=>{this.deletePaymentMethodId=null,this.deleteAssetConfig=null};this.handleConfirmDelete=async()=>{if(!this.primerContext?.vaultManager?.deleteVaultedPaymentMethod||!this.deletePaymentMethodId){this.errorMessage=E(\"something_went_wrong_error\",{id:\"something_went_wrong_error\"});return}try{this.isDeleting=!0,await this.primerContext?.vaultManager.deleteVaultedPaymentMethod(this.deletePaymentMethodId),this.deletePaymentMethodId=null,this.deleteAssetConfig=null}catch(e){this.errorMessage=e instanceof Error?e.message:E(\"something_went_wrong_error\",{id:\"something_went_wrong_error\"})}finally{this.isDeleting=!1}};this.handlePaymentError=e=>{let r=e.detail?.error;this.errorMessage=r instanceof Error?r.message:E(\"payment_processing_error\",{id:\"payment_processing_error\"})};this.handleCloseError=()=>{this.errorMessage=\"\"};this.handleSlotButtonClick=e=>{let i=e.target.closest(\"button, primer-button\");if(!i)return;let n=i;this.isSubmitButton(n)&&(e.preventDefault(),this.submitVaultPayment())};this.handleDirectSubmit=()=>{this.submitVaultPayment()};this.handleContextVaultSubmit=e=>{if(!this._isHandlingContextEvent){this._isHandlingContextEvent=!0;try{e.target!==this&&(e.stopPropagation(),this.submitVaultPayment())}finally{this._isHandlingContextEvent=!1}}};new sr(this,{defaultOptions:{keyframeOptions:{duration:Number(getComputedStyle(document.documentElement).getPropertyValue(\"--primer-animation-duration\").trim().replace(\"ms\",\"\")),easing:getComputedStyle(document.documentElement).getPropertyValue(\"--primer-animation-easing\").trim()}}})}getAnimationConfig(){return{keyframeOptions:{duration:this.animationDuration,easing:getComputedStyle(document.documentElement).getPropertyValue(\"--primer-animation-easing\").trim(),fill:\"both\"}}}isSubmitButton(e){let r=e.tagName.toLowerCase(),i=r===\"button\",n=r===\"primer-button\";return i&&(e.getAttribute(\"type\")===\"submit\"||e.hasAttribute(\"data-submit\"))||n&&(e.getAttribute(\"type\")===\"submit\"||e.hasAttribute(\"data-submit\"))}async submitVaultPayment(){if(this.primerContext?.vaultManager)try{await this.primerContext?.vaultManager.startVaultedPaymentFlow()}catch(e){this.dispatchEvent(new CustomEvent(\"primer-vault-payment-error\",{detail:{error:e},bubbles:!0,composed:!0}))}}getPaymentMethodName(e){if(!this.primerContext?.vaultManager)return\"\";let r=this.primerContext?.vaultManager.vaultedPaymentMethods.find(i=>i.id===e);if(!r)return\"\";try{return Kn(r).description||\"\"}catch{return\"\"}}setupContextEventListeners(){this.primerContext?.events?.host&&this._contextVaultSubmitListener&&this.primerContext?.events.host.addEventListener(\"primer:vault-submit\",this._contextVaultSubmitListener)}cleanupContextEventListeners(){this.primerContext?.events?.host&&this._contextVaultSubmitListener&&this.primerContext?.events.host.removeEventListener(\"primer:vault-submit\",this._contextVaultSubmitListener)}connectedCallback(){super.connectedCallback(),this.addEventListener(\"click\",this.handleSlotButtonClick),this.addEventListener(\"primer:vault-submit\",this.handleDirectSubmit),this._contextVaultSubmitListener=e=>{this.handleContextVaultSubmit(e)},this.setupContextEventListeners()}disconnectedCallback(){this.removeEventListener(\"click\",this.handleSlotButtonClick),this.removeEventListener(\"primer:vault-submit\",this.handleDirectSubmit),this.cleanupContextEventListeners(),super.disconnectedCallback()}renderLoadingOverlay(){return u`<div class=\"loading-overlay\" ${Mt({...this.getAnimationConfig(),properties:[\"opacity\"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ><primer-spinner size=\"medium\" color=\"var(--primer-color-loader)\" ></primer-spinner></div>`}renderDeleteConfirmation(){if(!this.deletePaymentMethodId||!this.deleteAssetConfig)return y;let e=this.getPaymentMethodName(this.deletePaymentMethodId);return u`<div class=\"delete-confirmation-container\"><primer-button disabled variant=\"secondary\"><primer-payment-method-content .assetConfig=${this.deleteAssetConfig} ></primer-payment-method-content></primer-button><primer-vault-delete-confirmation .isDeleting=${this.isDeleting} .paymentMethodId=${this.deletePaymentMethodId} .paymentMethodName=${e} @confirm-delete=${this.handleConfirmDelete} @cancel-delete=${this.handleCancelDelete} ${Mt({...this.getAnimationConfig(),properties:[\"opacity\"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-delete-confirmation></div>`}renderPaymentMethodItem(e){return this.deletePaymentMethodId===e.id?y:u`<primer-vault-payment-method-item .paymentMethod=${e} .isEditMode=${this.isEditMode} @delete-payment-method=${this.handleDeletePaymentMethod} ${Mt({...this.getAnimationConfig(),properties:[\"opacity\"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-payment-method-item>`}renderPaymentMethodList(){let e=this.primerContext?.vaultManager?.vaultedPaymentMethods||[],r=!this.isEditMode&&e.length>0&&!this.deletePaymentMethodId;return u`<div class=\"payment-methods-list\">${e.map(i=>this.renderPaymentMethodItem(i))} ${k(r,()=>u`<div class=\"submit-button-container\"><slot name=\"submit-button\" @slotchange=${this.handleSubmitSlotChange} ${Mt({...this.getAnimationConfig(),properties:[\"opacity\"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></slot>${k(!this.hasSlottedSubmit,()=>u`<primer-vault-payment-submit class=\"submit-button\" @primer-vault-payment-error=${this.handlePaymentError} ></primer-vault-payment-submit>`)}</div>`,()=>y)}</div>`}render(){if(!this.primerContext?.vaultManager?.enabled||this.primerContext?.vaultManager?.headless)return y;let e=this.primerContext?.vaultManager.vaultedPaymentMethods.length>0,r=this.primerContext?.vaultManager.isLoading,i=this.primerContext?.vaultManager.isUpdating;return u` ${k(!this.primerContext?.vaultManager?.showEmptyState&&!e,()=>y,()=>u`<slot name=\"vault-empty-state\"><div class=\"vault-manager ${i?\"is-updating\":\"\"}\"><primer-vault-manager-header .isEditMode=${this.isEditMode} .hasPaymentMethods=${e} @toggle-edit-mode=${this.handleToggleEditMode} ></primer-vault-manager-header>${k(this.errorMessage,()=>u`<primer-vault-error-message .errorMessage=${this.errorMessage} @close-error=${this.handleCloseError} ${Mt({...this.getAnimationConfig(),properties:[\"opacity\"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-error-message>`,()=>y)}<div class=\"vault-manager-content\">${k(!r&&!e,()=>u`<div class=\"content-container\"><primer-vault-empty-state ${Mt({...this.getAnimationConfig(),properties:[\"opacity\"],in:[{opacity:0},{opacity:1}],out:[{opacity:1},{opacity:0}]})} ></primer-vault-empty-state></div>`,()=>y)} ${k(!r&&e,()=>u`<div class=\"content-container\">${k(this.deletePaymentMethodId,()=>this.renderDeleteConfirmation(),()=>this.renderPaymentMethodList())}</div>`,()=>y)}</div>${k(i,()=>this.renderLoadingOverlay(),()=>y)}</div></slot>`)} `}}"
|
|
196
196
|
},
|
|
197
197
|
{
|
|
198
198
|
"kind": "variable",
|
|
@@ -227,7 +227,7 @@
|
|
|
227
227
|
{
|
|
228
228
|
"kind": "variable",
|
|
229
229
|
"name": "ae",
|
|
230
|
-
"default": "class extends v{constructor(){super();this.paymentMethod=null;this.cvvError=null;this.cvvInputIsDirty=!1;this.cvvInputIsBlurred=!1;this.cvvInput=null;this.isFocused=!1;this._setupCVVIframe=new $(this,{task:([e,r])=>!e||!r||e.paymentMethodType!==\"PAYMENT_CARD\"||!e.paymentInstrumentData?.network||r.createCvvInput===null?Y:{network:e.paymentInstrumentData.network,createCvvInput:r.createCvvInput},args:()=>[this.paymentMethod,this.primerContext?.vaultManager]});this.cvvContainerId=`cvv-container-${Math.random().toString(36).substring(2,9)}`,new $(this,{task:async([e])=>{if(!e)return Y;await this.updateComplete;let r=this.renderRoot.querySelector(`#${this.cvvContainerId}`);if(!r)return;let i=
|
|
230
|
+
"default": "class extends v{constructor(){super();this.paymentMethod=null;this.cvvError=null;this.cvvInputIsDirty=!1;this.cvvInputIsBlurred=!1;this.cvvInput=null;this.isFocused=!1;this._setupCVVIframe=new $(this,{task:([e,r])=>!e||!r||e.paymentMethodType!==\"PAYMENT_CARD\"||!e.paymentInstrumentData?.network||r.createCvvInput===null?Y:{network:e.paymentInstrumentData.network,createCvvInput:r.createCvvInput},args:()=>[this.paymentMethod,this.primerContext?.vaultManager]});this.cvvContainerId=`cvv-container-${Math.random().toString(36).substring(2,9)}`,new $(this,{task:async([e])=>{if(!e)return Y;await this.updateComplete;let r=this.renderRoot.querySelector(`#${this.cvvContainerId}`);if(!r)return;let i=Kr(this.primerContext?.computedStyles??null),n=i?{input:{base:i}}:void 0,o={cardNetwork:e.network,container:r,name:\"cvv\",placeholder:\"123\",style:n,ariaLabel:E(\"CVV\",{id:\"cardCVV\"})};this.cvvInput=await e.createCvvInput?.(o)??null,this.cvvInput&&(this.cvvInput.focus(),this.cvvError=this.cvvInput.metadata.errorCode||null,this.primerContext?.vaultItem?.setCvvInput(this.cvvInput),this.cvvInput.addListener(\"change\",()=>{this.onCvvInputChange()}),this.cvvInput.addListener(\"blur\",()=>{this.onBlur()}),this.cvvInput.addListener(\"focus\",()=>{this.onFocus()}))},args:()=>[this._setupCVVIframe.value]})}disconnectedCallback(){super.disconnectedCallback(),this.cvvInput&&(this.cvvInput.remove(),this.cvvInput=null,this.cvvError=null,this.primerContext?.vaultItem?.setCvvInput(null))}onCvvInputChange(){!this.cvvInput||!this.primerContext?.vaultItem||(this.cvvInputIsDirty=!0,this.cvvError=this.cvvInput.metadata.errorCode||null)}onBlur(){this.cvvInput&&(this.cvvInputIsBlurred=!0,this.cvvError=this.cvvInput.metadata.errorCode||null,this.isFocused=!1)}onFocus(){this.isFocused=!0}render(){return this._setupCVVIframe.render({error:()=>y,complete:()=>u`<div class=\"cvv-input-container\"><primer-input-wrapper .focusWithin=${this.isFocused} .hasError=${!!this.cvvError&&(this.primerContext?.vaultItem?.formIsDirty||this.cvvInputIsDirty&&this.cvvInputIsBlurred)} ><slot name=\"label\" slot=\"label\"><primer-input-label>CVV</primer-input-label></slot><div slot=\"input\" id=\"${this.cvvContainerId}\"></div>${k(this.cvvError&&(this.primerContext?.vaultItem?.formIsDirty||this.cvvInputIsDirty&&this.cvvInputIsBlurred),()=>u`<primer-input-error slot=\"error\">${E(this.cvvError,{id:this.cvvError})}</primer-input-error>`)}</primer-input-wrapper></div>`})}}"
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
233
|
"kind": "variable",
|
|
@@ -237,7 +237,7 @@
|
|
|
237
237
|
{
|
|
238
238
|
"kind": "variable",
|
|
239
239
|
"name": "Se",
|
|
240
|
-
"default": "class extends v{constructor(){super(...arguments);this.hideLabels=!1;this.disabled=!1;this.hasAssignedContent=!1;this.selectedCardNetwork=null;this.formErrorMessage=null;this.paymentMethodSelectionSent=!1;this.cardFormProvider=new yt(this,{context:
|
|
240
|
+
"default": "class extends v{constructor(){super(...arguments);this.hideLabels=!1;this.disabled=!1;this.hasAssignedContent=!1;this.selectedCardNetwork=null;this.formErrorMessage=null;this.paymentMethodSelectionSent=!1;this.cardFormProvider=new yt(this,{context:lr,initialValue:null});this.eventsController=new Xt(this);this._contextCardSubmitListener=null;this._isHandlingContextEvent=!1;this.inputControllers=new Map;this.setupCardFormTask=new $(this,{task:([e])=>{let r=e?.find(l=>l.type===W.PAYMENT_CARD)?.manager;if(!r)return Y;let i=r.createHostedInputs(),{cardNumberInput:n,expiryInput:o,cvvInput:s}=i;return this.cardFormProvider.setValue({cardholderNameInput:i.cardholderNameInput,cardNumberInput:n,expiryInput:o,cvvInput:s,setCardholderName:l=>{r.setCardholderName(l),this.shouldRequireCardholderName&&r.validate?.().then(c=>{let m=c?.validationErrors?.find(A=>A.name===qd.cardholderName),g=this.inputControllers.get(\"cardholderName\");g&&g.updateMetaFromValidation({valid:!1,error:m?.message||m?.error||null,errorCode:m?.message||m?.error||null})})},setCardNetwork:l=>{this.selectedCardNetwork=l},validate:()=>r.validate(),submit:l=>r.submit(l),hideLabels:this.hideLabels,disabled:this.disabled,setSubmissionState:l=>{this.inputControllers.forEach(c=>{c.setSubmitted(l)})},propagateValidationErrors:l=>{l&&l.forEach(c=>{let p=c.field||c.name,m=c.message||c.error,g=qd[p];if(g){let A=this.inputControllers.get(g);if(A){let M={valid:!1,error:m,errorCode:m};A.updateMetaFromValidation(M)}}})},registerInputController:(l,c)=>{this.inputControllers.set(l,c)},unregisterInputController:l=>{this.inputControllers.delete(l)},onUserInteraction:()=>{this.sendPaymentMethodSelectionEvent(),this.checkAndSendPaymentDetailsEnteredEvent()}}),!0},args:()=>[this.primerContext?.paymentMethods]});this.paymentDetailsEnteredSent=!1;this.handleSlotButtonClick=e=>{let i=e.target.closest(\"button, primer-button\");if(!i)return;let n=i;this.isSubmitButton(n)&&(e.preventDefault(),this.submitCardPayment())};this.handleDirectSubmit=e=>{e.stopPropagation(),this.submitCardPayment()};this.handleContextCardSubmit=e=>{if(!this._isHandlingContextEvent){this._isHandlingContextEvent=!0;try{e.target!==this&&(e.stopPropagation(),this.submitCardPayment())}finally{this._isHandlingContextEvent=!1}}};this.onSlotChange=e=>{let i=e.target.assignedNodes({flatten:!0});this.hasAssignedContent=i.length>0};this.handleFormSubmit=e=>{e.preventDefault(),e.stopPropagation(),this.submitCardPayment()}}updated(e){if(super.updated(e),(e.has(\"hideLabels\")||e.has(\"disabled\"))&&this.cardFormProvider.value&&this.cardFormProvider.setValue({...this.cardFormProvider.value,hideLabels:this.hideLabels,disabled:this.disabled}),e.has(\"context\")){let i=e.get(\"context\")?.events??null;i?.host&&this._contextCardSubmitListener&&i.host.removeEventListener(\"primer:card-submit\",this._contextCardSubmitListener),this.setupContextEventListeners()}}get shouldShowCardholderName(){let e=this.primerContext?.clientOptions?.card?.cardholderName;return typeof e?.visible==\"boolean\"?e.visible:!0}get shouldRequireCardholderName(){if(!this.shouldShowCardholderName)return!1;let e=this.primerContext?.clientOptions?.card?.cardholderName;return typeof e?.required==\"boolean\"?e.required:!0}sendPaymentMethodSelectionEvent(){this.paymentMethodSelectionSent||(this.paymentMethodSelectionSent=!0,Q({eventName:\"PAYMENT_METHOD_SELECTION\",paymentMethod:\"PAYMENT_CARD\"}))}checkAndSendPaymentDetailsEnteredEvent(){if(this.paymentDetailsEnteredSent)return;let e=this.inputControllers.get(\"cardNumber\"),r=this.inputControllers.get(\"expire\"),i=this.inputControllers.get(\"cvv\"),n=e?.meta?.dirty===!0,o=r?.meta?.dirty===!0,s=i?.meta?.dirty===!0,l=!0;this.shouldRequireCardholderName&&(l=this.inputControllers.get(\"cardholderName\")?.meta?.dirty===!0),n&&o&&s&&l&&(this.sendPaymentDetailsEnteredEvent(),this.paymentDetailsEnteredSent=!0)}sendPaymentDetailsEnteredEvent(){Q({eventName:\"PAYMENT_DETAILS_ENTERED\",paymentMethod:\"PAYMENT_CARD\"})}connectedCallback(){super.connectedCallback(),this.addEventListener(\"click\",this.handleSlotButtonClick),this.addEventListener(\"primer:card-submit\",this.handleDirectSubmit),this._contextCardSubmitListener=e=>{this.handleContextCardSubmit(e)},this.setupContextEventListeners()}disconnectedCallback(){this.removeEventListener(\"click\",this.handleSlotButtonClick),this.removeEventListener(\"primer:card-submit\",this.handleDirectSubmit),this.cleanupContextEventListeners(),super.disconnectedCallback()}setupContextEventListeners(){this.primerContext?.events?.host&&this._contextCardSubmitListener&&this.primerContext?.events.host.addEventListener(\"primer:card-submit\",this._contextCardSubmitListener)}cleanupContextEventListeners(){this.primerContext?.events?.host&&this._contextCardSubmitListener&&this.primerContext?.events.host.removeEventListener(\"primer:card-submit\",this._contextCardSubmitListener)}isSubmitButton(e){let r=e.tagName.toLowerCase(),i=r===\"button\",n=r===\"primer-button\";return i&&(e.getAttribute(\"type\")===\"submit\"||e.hasAttribute(\"data-submit\"))||n&&(e.getAttribute(\"type\")===\"submit\"||e.hasAttribute(\"data-submit\"))}async submitCardPayment(){let e=this.cardFormProvider.value,r=this.primerContext?.sdkState.isProcessing;if(!e||this.disabled||r)return;this.formErrorMessage=null,e.setSubmissionState?.(!0);let i=this.querySelector(\"primer-billing-address\")||this.renderRoot.querySelector(\"primer-billing-address\"),n=!0;i&&(n=await i.validateForSubmission());let o=await e.validate?.();if(o?.valid&&n){if(i&&!await i.submitToSDK()){let p=E(\"tokenizationError\",{id:\"tokenizationError\"});this.formErrorMessage=p,this.eventsController.dispatchFormSubmitErrors([{field:\"billingAddress\",name:\"billingAddress\",error:\"BILLING_ADDRESS_SUBMISSION_FAILED\",message:p}]);return}let s={success:!0};this.eventsController.dispatchFormSubmitSuccess(s);let l=this.selectedCardNetwork?{cardNetwork:this.selectedCardNetwork}:void 0;await e.submit?.(l)}else{let s=o?.validationErrors;e.propagateValidationErrors?.(s||[]),this.cardFormProvider.setValue({...e,errors:s}),this.eventsController.dispatchFormSubmitErrors(s)}}render(){return this.setupCardFormTask.status===bt.ERROR||this.setupCardFormTask.status===bt.INITIAL?y:u`<form @submit=${this.handleFormSubmit}><slot name=\"card-form-content\" @slotchange=${this.onSlotChange}></slot>${this.setupCardFormTask.render({complete:()=>k(this.hasAssignedContent,()=>y,()=>u`<div class=\"card-form\"><primer-input-card-number></primer-input-card-number><div class=\"card-form-row\"><primer-input-card-expiry></primer-input-card-expiry><primer-input-cvv></primer-input-cvv></div>${k(this.shouldShowCardholderName,()=>u`<primer-input-card-holder-name></primer-input-card-holder-name>`,()=>y)} ${k(this.primerContext?.clientOptions?.sdkCore!==!1,()=>u`<primer-billing-address></primer-billing-address>`,()=>y)}</div><primer-card-form-submit></primer-card-form-submit><primer-error-message message=\"${this.formErrorMessage||\"\"}\" ?visible=\"${!!this.formErrorMessage}\" ></primer-error-message>`)})}</form>`}}"
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
243
|
"kind": "variable",
|
|
@@ -267,7 +267,7 @@
|
|
|
267
267
|
{
|
|
268
268
|
"kind": "variable",
|
|
269
269
|
"name": "me",
|
|
270
|
-
"default": "class extends v{constructor(){super(...arguments);this.selectedCardNetwork=null;this.isDropdownOpen=!1;this.focusedNetworkIndex=0;this.isKeyboardNavigation=!1;this.buttonRef=
|
|
270
|
+
"default": "class extends v{constructor(){super(...arguments);this.selectedCardNetwork=null;this.isDropdownOpen=!1;this.focusedNetworkIndex=0;this.isKeyboardNavigation=!1;this.buttonRef=Vt();this.dropdownRef=Vt();this.networkOptionRefs=[];this.toggleDropdown=e=>{this.isKeyboardNavigation=!1,e.stopPropagation(),this.getSelectableNetworks().length>1&&(this.isDropdownOpen=!this.isDropdownOpen,this.isDropdownOpen&&(this.focusedNetworkIndex=this.getSelectedNetworkIndex()))};this.handleClickOutside=e=>{this.isDropdownOpen&&(this.contains(e.target)||(this.isDropdownOpen=!1,this.isKeyboardNavigation=!1))};this.handleMouseMove=()=>{this.isKeyboardNavigation&&(this.isKeyboardNavigation=!1)};this.handleKeyDown=e=>{if(!(!(this.getSelectableNetworks().length>1)||!(this.contains(e.target)||this===e.target||this.isDropdownOpen&&e.target===document.body)))switch(this.isKeyboardNavigation=!0,e.key){case\"ArrowDown\":e.preventDefault(),this.isDropdownOpen?(this.focusedNetworkIndex=(this.focusedNetworkIndex+1)%this.getSelectableNetworks().length,this.focusNetworkOption()):(this.isDropdownOpen=!0,this.focusedNetworkIndex=this.getSelectedNetworkIndex());break;case\"ArrowUp\":e.preventDefault(),this.isDropdownOpen?(this.focusedNetworkIndex=(this.focusedNetworkIndex-1+this.getSelectableNetworks().length)%this.getSelectableNetworks().length,this.focusNetworkOption()):(this.isDropdownOpen=!0,this.focusedNetworkIndex=this.getSelectedNetworkIndex());break;case\"Enter\":case\" \":this.isDropdownOpen&&this.focusedNetworkIndex>=0?(e.preventDefault(),this.selectNetwork(e,this.getSelectableNetworks()[this.focusedNetworkIndex])):!this.isDropdownOpen&&this.buttonRef.value===document.activeElement&&(e.preventDefault(),this.isDropdownOpen=!0,this.focusedNetworkIndex=this.getSelectedNetworkIndex());break;case\"Escape\":this.isDropdownOpen&&(e.preventDefault(),this.isDropdownOpen=!1,this.buttonRef.value?.focus());break;case\"Tab\":this.isDropdownOpen&&(this.isDropdownOpen=!1);break}};this.handleDocumentKeyDown=e=>{this.isDropdownOpen&&this.handleKeyDown(e)}}getNetworkIconUrl(e){return this.primerContext?.headlessUtils?.getCardNetworkAsset(e.network)?.cardUrl}renderDefaultCardIcon(){return u`<div class=\"network-icon\">${$a[\"payment-card\"]}</div>`}getSelectableNetworks(){return this.primerContext?.cardNetworks?.selectableCardNetworks||[]}getDetectedNetwork(){return this.selectedCardNetwork??(this.primerContext?.cardNetworks?.detectedCardNetwork||null)}getSelectedNetworkIndex(){let e=this.getDetectedNetwork();if(!e)return 0;let r=this.getSelectableNetworks().findIndex(i=>i.network===e.network);return r>=0?r:0}selectNetwork(e,r){e.stopPropagation(),this.selectedCardNetwork=r,this.isDropdownOpen=!1,this.buttonRef.value?.focus(),this.primerContext?.cardNetworks&&this.dispatchEvent(new CustomEvent(\"network-selected\",{detail:{network:r.network},bubbles:!0,composed:!0}))}focusNetworkOption(){requestAnimationFrame(()=>{this.networkOptionRefs[this.focusedNetworkIndex]&&this.networkOptionRefs[this.focusedNetworkIndex].focus()})}setNetworkOptionRef(e,r){this.networkOptionRefs[r]=e}connectedCallback(){super.connectedCallback(),setTimeout(()=>{document.addEventListener(\"click\",this.handleClickOutside),document.addEventListener(\"mousemove\",this.handleMouseMove),this.addEventListener(\"keydown\",this.handleKeyDown),document.addEventListener(\"keydown\",this.handleDocumentKeyDown)},0)}disconnectedCallback(){document.removeEventListener(\"click\",this.handleClickOutside),document.removeEventListener(\"keydown\",this.handleDocumentKeyDown),document.removeEventListener(\"mousemove\",this.handleMouseMove),this.removeEventListener(\"keydown\",this.handleKeyDown),super.disconnectedCallback()}render(){if(this.primerContext?.cardNetworks?.isLoading)return u`<primer-spinner size=\"small\" compact></primer-spinner>`;let e=this.getSelectableNetworks();if(!this.getDetectedNetwork()&&e.length===0)return this.renderDefaultCardIcon();let r=this.getDetectedNetwork()||(e.length>0?e[0]:null);if(!r)return this.renderDefaultCardIcon();let i=e.length>1;return i&&!Ic(e.map(o=>o.network))?u`<div class=\"network-selector-inline\">${e.map(o=>u`<div class=\"network-icon-container\"><img class=\"network-icon\" src=${this.getNetworkIconUrl(o)??\"\"} alt=${o.displayName} /></div>`)}</div>`:u`<button ${Et(this.buttonRef)} class=\"network-selector ${i?\"\":\"static\"}\" tabindex=${i?\"0\":\"-1\"} @click=${this.toggleDropdown} @keydown=${o=>{(o.key===\" \"||o.key===\"Enter\")&&i&&(o.preventDefault(),this.isDropdownOpen=!this.isDropdownOpen,this.isDropdownOpen&&(this.focusedNetworkIndex=this.getSelectedNetworkIndex()))}} aria-label=${i?`Selected card network: ${r.displayName}. Click to change.`:`Card network: ${r.displayName}`} aria-expanded=${i?this.isDropdownOpen:y} aria-haspopup=${i?\"true\":y} aria-controls=${i?\"network-dropdown\":y} ><img class=\"network-icon\" src=${this.getNetworkIconUrl(r)} alt=${r.displayName} />${k(i,()=>u`<primer-icon class=\"caret ${this.isDropdownOpen?\"open\":\"\"}\" size=\"sm\" name=\"chevron-down\" ></primer-icon>`,()=>y)}</button>${k(this.isDropdownOpen,()=>u`<div ${Et(this.dropdownRef)} id=\"network-dropdown\" class=\"dropdown open\" role=\"listbox\" aria-label=\"Select card network\" >${e.map((o,s)=>u`<div ${Et(l=>this.setNetworkOptionRef(l,s))} class=\"network-option ${this.isKeyboardNavigation&&s===this.focusedNetworkIndex?\"focused\":\"\"}\" @click=${l=>this.selectNetwork(l,o)} @keydown=${l=>{(l.key===\"Enter\"||l.key===\" \")&&this.selectNetwork(l,o)}} role=\"option\" aria-selected=${o.network===r.network} tabindex=\"${s===this.focusedNetworkIndex?\"0\":\"-1\"}\" ><img class=\"network-option-icon\" src=${this.getNetworkIconUrl(o)} alt=${o.displayName} /><span class=\"network-name\">${o.displayName}</span>${k(o.network===r.network,()=>u`<primer-icon class=\"checkmark\" name=\"checkmark\" size=\"sm\" ></primer-icon>`,()=>y)}</div>`)}</div>`,()=>y)} `}}"
|
|
271
271
|
},
|
|
272
272
|
{
|
|
273
273
|
"kind": "variable",
|
|
@@ -286,12 +286,12 @@
|
|
|
286
286
|
},
|
|
287
287
|
{
|
|
288
288
|
"kind": "variable",
|
|
289
|
-
"name": "
|
|
289
|
+
"name": "ur",
|
|
290
290
|
"default": "class extends v{render(){return u`<primer-checkout-state type=\"complete\"></primer-checkout-state>`}}"
|
|
291
291
|
},
|
|
292
292
|
{
|
|
293
293
|
"kind": "variable",
|
|
294
|
-
"name": "
|
|
294
|
+
"name": "$t",
|
|
295
295
|
"default": "class extends v{render(){return u`<primer-checkout-state type=\"failure\" description=${this.primerContext?.sdkState?.primerJsError?.message||\"\"} ></primer-checkout-state>`}}"
|
|
296
296
|
},
|
|
297
297
|
{
|
|
@@ -306,7 +306,7 @@
|
|
|
306
306
|
},
|
|
307
307
|
{
|
|
308
308
|
"kind": "function",
|
|
309
|
-
"name": "
|
|
309
|
+
"name": "tD"
|
|
310
310
|
}
|
|
311
311
|
],
|
|
312
312
|
"exports": [
|
|
@@ -330,7 +330,7 @@
|
|
|
330
330
|
"kind": "js",
|
|
331
331
|
"name": "AdyenMbway",
|
|
332
332
|
"declaration": {
|
|
333
|
-
"name": "
|
|
333
|
+
"name": "Pe",
|
|
334
334
|
"module": "dist/primer-loader.js"
|
|
335
335
|
}
|
|
336
336
|
},
|
|
@@ -562,7 +562,7 @@
|
|
|
562
562
|
"kind": "js",
|
|
563
563
|
"name": "PrimerCheckoutComplete",
|
|
564
564
|
"declaration": {
|
|
565
|
-
"name": "
|
|
565
|
+
"name": "ur",
|
|
566
566
|
"module": "dist/primer-loader.js"
|
|
567
567
|
}
|
|
568
568
|
},
|
|
@@ -578,7 +578,7 @@
|
|
|
578
578
|
"kind": "js",
|
|
579
579
|
"name": "PrimerCheckoutFailure",
|
|
580
580
|
"declaration": {
|
|
581
|
-
"name": "
|
|
581
|
+
"name": "$t",
|
|
582
582
|
"module": "dist/primer-loader.js"
|
|
583
583
|
}
|
|
584
584
|
},
|
|
@@ -722,7 +722,7 @@
|
|
|
722
722
|
"kind": "js",
|
|
723
723
|
"name": "injectDarkTheme",
|
|
724
724
|
"declaration": {
|
|
725
|
-
"name": "
|
|
725
|
+
"name": "sh",
|
|
726
726
|
"module": "dist/primer-loader.js"
|
|
727
727
|
}
|
|
728
728
|
},
|
|
@@ -730,7 +730,7 @@
|
|
|
730
730
|
"kind": "js",
|
|
731
731
|
"name": "injectLightTheme",
|
|
732
732
|
"declaration": {
|
|
733
|
-
"name": "
|
|
733
|
+
"name": "oh",
|
|
734
734
|
"module": "dist/primer-loader.js"
|
|
735
735
|
}
|
|
736
736
|
},
|
|
@@ -754,7 +754,7 @@
|
|
|
754
754
|
"kind": "js",
|
|
755
755
|
"name": "loadPrimer",
|
|
756
756
|
"declaration": {
|
|
757
|
-
"name": "
|
|
757
|
+
"name": "tD",
|
|
758
758
|
"module": "dist/primer-loader.js"
|
|
759
759
|
}
|
|
760
760
|
}
|