rebill-web-components-sdk 1.8.22 → 1.8.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/apm-checkout_19.cjs.entry.js +10 -4
- package/dist/cjs/index-C-VTnc0I.js.map +1 -1
- package/dist/collection/components/checkout/address/address.js +10 -4
- package/dist/collection/components/checkout/address/address.js.map +1 -1
- package/dist/components/p-8BpuJ_V5.js.map +1 -1
- package/dist/components/{p-s8WhwKwq.js → p-DgIW2T8E.js} +12 -6
- package/dist/components/p-DgIW2T8E.js.map +1 -0
- package/dist/components/rebill-address.js +1 -1
- package/dist/components/rebill-checkout.js +1 -1
- package/dist/components/rebill-renewal.js +1 -1
- package/dist/esm/apm-checkout_19.entry.js +10 -4
- package/dist/esm/index-D8cwEAmw.js.map +1 -1
- package/dist/rebill-web-components-sdk/p-7d0e00c6.entry.js +2 -0
- package/dist/rebill-web-components-sdk/p-7d0e00c6.entry.js.map +1 -0
- package/dist/rebill-web-components-sdk/p-D8cwEAmw.js.map +1 -1
- package/dist/rebill-web-components-sdk/rebill-web-components-sdk.esm.js +1 -1
- package/package.json +1 -1
- package/dist/components/p-s8WhwKwq.js.map +0 -1
- package/dist/rebill-web-components-sdk/p-6bcff3c5.entry.js +0 -2
- package/dist/rebill-web-components-sdk/p-6bcff3c5.entry.js.map +0 -1
|
@@ -63,9 +63,10 @@ const Address = /*@__PURE__*/ proxyCustomElement(class Address extends H {
|
|
|
63
63
|
.toLowerCase()
|
|
64
64
|
.normalize('NFD')
|
|
65
65
|
.replace(/[\u0300-\u036f]/g, '') // Remove accents
|
|
66
|
+
.replace(/\./g, '') // Remove dots
|
|
67
|
+
.replace(/\s+/g, ' ') // Normalize spaces
|
|
66
68
|
.trim();
|
|
67
69
|
};
|
|
68
|
-
SessionStore.setBillingAddress(address);
|
|
69
70
|
this.billingView = 'form';
|
|
70
71
|
if (address.country) {
|
|
71
72
|
await this.loadStatesForCountry(address.country);
|
|
@@ -95,15 +96,20 @@ const Address = /*@__PURE__*/ proxyCustomElement(class Address extends H {
|
|
|
95
96
|
else if (normalizedMatch) {
|
|
96
97
|
address.state = normalizedMatch.value;
|
|
97
98
|
}
|
|
98
|
-
else
|
|
99
|
+
else if (partialMatch) {
|
|
99
100
|
address.state = partialMatch.value;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
address.state = undefined;
|
|
104
|
+
}
|
|
100
105
|
}
|
|
101
106
|
}
|
|
107
|
+
SessionStore.setBillingAddress(address);
|
|
102
108
|
this.addressUpdated.emit({
|
|
103
109
|
country: address.country || '',
|
|
104
110
|
address: address.address || '',
|
|
105
111
|
city: address.city || '',
|
|
106
|
-
state: address.state ||
|
|
112
|
+
state: address.state || undefined,
|
|
107
113
|
zip: address.zip || '',
|
|
108
114
|
});
|
|
109
115
|
// Use requestAnimationFrame to ensure the form is rendered with the new state options
|
|
@@ -191,7 +197,7 @@ const Address = /*@__PURE__*/ proxyCustomElement(class Address extends H {
|
|
|
191
197
|
return (h("div", null, this.renderAddressHeader(), h("rebill-address-form", { countryOptions: this.countryOptions, stateOptions: this.currentBillingStateOptions, errors: errorsToShow, disabled: this.disabled, onFieldChanged: e => this.handleInput(e.detail.field, e.detail.value), onSearchRequested: () => this.handleSearchEntry() })));
|
|
192
198
|
}
|
|
193
199
|
render() {
|
|
194
|
-
return (h("div", { key: '
|
|
200
|
+
return (h("div", { key: 'f8078c9118473f6316e43558237a489de8e7e8bf' }, this.renderAddressForm()));
|
|
195
201
|
}
|
|
196
202
|
static get style() { return addressCss; }
|
|
197
203
|
}, [256, "rebill-address", {
|
|
@@ -248,6 +254,6 @@ function defineCustomElement() {
|
|
|
248
254
|
defineCustomElement();
|
|
249
255
|
|
|
250
256
|
export { Address as A, defineCustomElement as d };
|
|
251
|
-
//# sourceMappingURL=p-
|
|
257
|
+
//# sourceMappingURL=p-DgIW2T8E.js.map
|
|
252
258
|
|
|
253
|
-
//# sourceMappingURL=p-
|
|
259
|
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Ac,EAAE,IAAI,CAAC,cAAc,EACnC,YAAY,EAAE,IAAI,CAAC,0BAA0B,EAC7C,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,cAAc,EAAE,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACrE,iBAAiB,EAAE,MAAM,IAAI,CAAC,iBAAiB,EAAE,EAAA,CACjD,CACE;;IAIV,MAAM,GAAA;AACJ,QAAA,QACE,8DAEG,IAAI,CAAC,iBAAiB,EAAE,CACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["__stencil_proxyCustomElement","HTMLElement","sessionState"],"sources":["src/components/checkout/address/address.css?tag=rebill-address","src/components/checkout/address/address.tsx"],"sourcesContent":["@import '../../../styles/variables.css';\n\n:host {\n display: block;\n}\n\n.billing-header-row {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 16px;\n}\n\n.address-container {\n display: flex;\n flex-direction: column;\n gap: 16px;\n width: 100%;\n}\n\n.state-zip-row {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 16px;\n}\n\n.state-zip-row rebill-input-select,\n.state-zip-row rebill-input-text {\n flex: 1;\n}\n\n.search-input-container {\n margin-top: 8px;\n}\n\n.manual-entry-link-wrapper {\n margin-top: 8px;\n text-align: left;\n}\n\n.manual-entry-link {\n background: none;\n border: none;\n color: var(--rebill-color-primary);\n cursor: pointer;\n text-decoration: underline;\n font-size: 14px;\n padding: 4px 8px;\n transition: color 0.2s ease;\n text-decoration: none;\n}\n\n.manual-entry-link:hover {\n text-decoration: underline;\n text-decoration-color: var(--rebill-color-text-secondary);\n}\n\n.same-as-shipping-section {\n margin: 24px 0;\n padding: 16px 0;\n}\n\n.shipping-address-section {\n margin-top: 24px;\n padding-top: 24px;\n}\n","import { Component, Element, Event, EventEmitter, h, Prop, State } from '@stencil/core';\nimport { api } from '../../../api';\nimport { I18nService } from '../../../i18n/i18n.service';\nimport { onChange, sessionState, SessionStore } from '../../../store/session.store';\nimport { AddressComponents } from '../../../utils';\n\n@Component({\n tag: 'rebill-address',\n styleUrl: 'address.css',\n shadow: false,\n})\nexport class Address {\n @Element() el: HTMLElement;\n @Prop({ mutable: true, reflect: true }) billingView: 'search' | 'form' = 'search';\n @State() currentBillingStateOptions: { label: string; value: string }[] = [];\n @State() isLoadingAddress: boolean = false;\n @Prop() disabled: boolean = false;\n\n @Prop() countryOptions: { label: string; value: string }[] = [];\n\n @Prop() errors?: {\n 'billing-country': string;\n 'billing-state': string;\n 'billing-address': string;\n 'billing-city': string;\n 'billing-zip': string;\n } | null = null;\n\n private unsubscribeAddressStore?: () => void;\n\n private translateError(errorKey: string | undefined): string {\n if (!errorKey) return '';\n if (errorKey.includes('validation.') || errorKey.includes('paymentErrors.')) {\n return I18nService.translate(errorKey);\n }\n return errorKey;\n }\n\n @Event() addressUpdated: EventEmitter<{\n country: string;\n state: string;\n address: string;\n city: string;\n zip: string;\n }>;\n\n componentDidLoad() {\n this.unsubscribeAddressStore = onChange('data', () => {\n const billingAddress = sessionState.data.userInformation.address?.billingAddress;\n\n if (billingAddress) {\n const addressData: AddressComponents = {\n country: billingAddress.country || '',\n state: billingAddress.state || '',\n address: billingAddress.address || '',\n city: billingAddress.city || '',\n zip: billingAddress.zip || '',\n };\n\n this.emitInputEventsForAddress(addressData);\n }\n });\n }\n\n disconnectedCallback() {\n if (this.unsubscribeAddressStore) {\n this.unsubscribeAddressStore();\n }\n }\n\n private async handleAddressSelected(address: AddressComponents) {\n this.isLoadingAddress = true;\n\n // Normalize text function for handling accents and special characters\n const normalizeText = (text: string) => {\n return text\n .toLowerCase()\n .normalize('NFD')\n .replace(/[\\u0300-\\u036f]/g, '') // Remove accents\n .replace(/\\./g, '') // Remove dots\n .replace(/\\s+/g, ' ') // Normalize spaces\n .trim();\n };\n this.billingView = 'form';\n\n if (address.country) {\n await this.loadStatesForCountry(address.country);\n\n // Compare Google state with API states\n if (address.state && this.currentBillingStateOptions.length > 0) {\n const exactMatch = this.currentBillingStateOptions.find(\n option => option.value.toLowerCase() === address.state.toLowerCase(),\n );\n\n const partialMatch = this.currentBillingStateOptions.find(\n option =>\n option.value.toLowerCase().includes(address.state.toLowerCase()) ||\n address.state.toLowerCase().includes(option.value.toLowerCase()),\n );\n\n // Try to find matches with common variations\n const normalizedGoogleState = normalizeText(address.state)\n .replace('ciudad de ', '')\n .replace('estado de ', '')\n .replace('provincia de ', '');\n\n const normalizedMatch = this.currentBillingStateOptions.find(option => {\n const normalizedOption = normalizeText(option.value)\n .replace('ciudad de ', '')\n .replace('estado de ', '')\n .replace('provincia de ', '');\n\n const matches =\n normalizedOption === normalizedGoogleState ||\n normalizedOption.startsWith(normalizedGoogleState + ' ') ||\n normalizedGoogleState.startsWith(normalizedOption + ' ');\n return matches;\n });\n\n if (exactMatch) {\n address.state = exactMatch.value;\n } else if (normalizedMatch) {\n address.state = normalizedMatch.value;\n } else if (partialMatch) {\n address.state = partialMatch.value;\n } else {\n address.state = undefined;\n }\n }\n }\n SessionStore.setBillingAddress(address);\n\n this.addressUpdated.emit({\n country: address.country || '',\n address: address.address || '',\n city: address.city || '',\n state: address.state || undefined,\n zip: address.zip || '',\n });\n\n // Use requestAnimationFrame to ensure the form is rendered with the new state options\n // before emitting events. This ensures the state field can be properly populated.\n requestAnimationFrame(() => {\n this.emitInputEventsForAddress(address);\n setTimeout(() => {\n this.isLoadingAddress = false;\n }, 500);\n });\n }\n\n private emitInputEventsForAddress(address: AddressComponents) {\n // Emit input events for each address field that has a value\n // This mimics user input to properly clear validation errors\n const fields = [\n { id: `billing-country`, value: address.country },\n { id: `billing-address`, value: address.address },\n { id: `billing-city`, value: address.city },\n { id: `billing-state`, value: address.state },\n { id: `billing-zip`, value: address.zip },\n ];\n\n fields.forEach(field => {\n if (field.value) {\n this.emitInputEvent(field.id, field.value);\n }\n });\n }\n\n private emitInputEvent(id: string, value: string) {\n if (value) {\n // Create and dispatch a custom input event that the form component can listen to\n const inputEvent = new CustomEvent('input', {\n detail: { id, value },\n bubbles: true,\n composed: true,\n });\n this.el.dispatchEvent(inputEvent);\n }\n }\n\n private async loadStatesForCountry(countryCode: string) {\n try {\n const response = await api.data.getStates(countryCode);\n const statesResponse = response.data;\n const stateOptions =\n statesResponse && statesResponse.states\n ? statesResponse.states.map(state => ({ label: state, value: state }))\n : [];\n\n this.currentBillingStateOptions = stateOptions;\n } catch (error) {\n this.currentBillingStateOptions = [];\n }\n }\n\n private handleManualEntry = () => {\n this.billingView = 'form';\n };\n\n private handleSearchEntry = () => {\n this.billingView = 'search';\n };\n\n private async handleInput(field: string, value: string) {\n if (value === undefined) return;\n SessionStore.setBillingAddress({ [field]: value } as any);\n // Emit input event to form to sync with form data\n this.emitInputEvent(`billing-${field}`, value);\n\n // If country changes, load states for the new country\n if (field === 'country') {\n await this.loadStatesForCountry(value);\n // Clear the current state selection since the country changed\n SessionStore.setBillingAddress({ state: '' } as any);\n }\n }\n\n private renderAddressHeader() {\n return (\n <div class=\"billing-header-row\">\n <rebill-typography variant=\"body2\">\n {I18nService.translate('billingAddress.title')}\n </rebill-typography>\n </div>\n );\n }\n\n private renderAddressForm() {\n if (this.billingView === 'search') {\n const addressError =\n this.translateError(this.errors?.['billing-address']) ||\n this.translateError(this.errors?.['billing-country']) ||\n this.translateError(this.errors?.['billing-state']) ||\n this.translateError(this.errors?.['billing-city']) ||\n this.translateError(this.errors?.['billing-zip']) ||\n '';\n return (\n <div>\n {this.renderAddressHeader()}\n <rebill-address-search\n onAddressSelected={e => this.handleAddressSelected(e.detail)}\n onManualEntryRequested={() => this.handleManualEntry()}\n error={addressError}\n disabled={this.disabled}\n />\n </div>\n );\n }\n\n const errorsToShow = this.isLoadingAddress ? null : this.errors;\n\n return (\n <div>\n {this.renderAddressHeader()}\n <rebill-address-form\n countryOptions={this.countryOptions}\n stateOptions={this.currentBillingStateOptions}\n errors={errorsToShow}\n disabled={this.disabled}\n onFieldChanged={e => this.handleInput(e.detail.field, e.detail.value)}\n onSearchRequested={() => this.handleSearchEntry()}\n />\n </div>\n );\n }\n\n render() {\n return (\n <div>\n {/* Billing Address */}\n {this.renderAddressForm()}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -24,7 +24,7 @@ import { d as defineCustomElement$G } from './p-b3y0ldGK.js';
|
|
|
24
24
|
import { d as defineCustomElement$E } from './p-2hFT3wni.js';
|
|
25
25
|
import { d as defineCustomElement$C } from './p-B8GIr65u.js';
|
|
26
26
|
import { d as defineCustomElement$B } from './p-qmr2qRdk.js';
|
|
27
|
-
import { d as defineCustomElement$A } from './p-
|
|
27
|
+
import { d as defineCustomElement$A } from './p-DgIW2T8E.js';
|
|
28
28
|
import { d as defineCustomElement$z } from './p-y5rBN7LS.js';
|
|
29
29
|
import { d as defineCustomElement$x } from './p-DaYZxslj.js';
|
|
30
30
|
import { d as defineCustomElement$w } from './p-c9SkZ__E.js';
|
|
@@ -20,7 +20,7 @@ import { d as defineCustomElement$w } from './p-B48kVXFC.js';
|
|
|
20
20
|
import { d as defineCustomElement$v } from './p-DZKiNnX2.js';
|
|
21
21
|
import { d as defineCustomElement$u } from './p-B8GIr65u.js';
|
|
22
22
|
import { d as defineCustomElement$t } from './p-qmr2qRdk.js';
|
|
23
|
-
import { d as defineCustomElement$s } from './p-
|
|
23
|
+
import { d as defineCustomElement$s } from './p-DgIW2T8E.js';
|
|
24
24
|
import { d as defineCustomElement$r } from './p-y5rBN7LS.js';
|
|
25
25
|
import { d as defineCustomElement$p } from './p-DaYZxslj.js';
|
|
26
26
|
import { d as defineCustomElement$o } from './p-c9SkZ__E.js';
|
|
@@ -815,9 +815,10 @@ const Address = class {
|
|
|
815
815
|
.toLowerCase()
|
|
816
816
|
.normalize('NFD')
|
|
817
817
|
.replace(/[\u0300-\u036f]/g, '') // Remove accents
|
|
818
|
+
.replace(/\./g, '') // Remove dots
|
|
819
|
+
.replace(/\s+/g, ' ') // Normalize spaces
|
|
818
820
|
.trim();
|
|
819
821
|
};
|
|
820
|
-
SessionStore.setBillingAddress(address);
|
|
821
822
|
this.billingView = 'form';
|
|
822
823
|
if (address.country) {
|
|
823
824
|
await this.loadStatesForCountry(address.country);
|
|
@@ -847,15 +848,20 @@ const Address = class {
|
|
|
847
848
|
else if (normalizedMatch) {
|
|
848
849
|
address.state = normalizedMatch.value;
|
|
849
850
|
}
|
|
850
|
-
else
|
|
851
|
+
else if (partialMatch) {
|
|
851
852
|
address.state = partialMatch.value;
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
address.state = undefined;
|
|
856
|
+
}
|
|
852
857
|
}
|
|
853
858
|
}
|
|
859
|
+
SessionStore.setBillingAddress(address);
|
|
854
860
|
this.addressUpdated.emit({
|
|
855
861
|
country: address.country || '',
|
|
856
862
|
address: address.address || '',
|
|
857
863
|
city: address.city || '',
|
|
858
|
-
state: address.state ||
|
|
864
|
+
state: address.state || undefined,
|
|
859
865
|
zip: address.zip || '',
|
|
860
866
|
});
|
|
861
867
|
// Use requestAnimationFrame to ensure the form is rendered with the new state options
|
|
@@ -943,7 +949,7 @@ const Address = class {
|
|
|
943
949
|
return (h("div", null, this.renderAddressHeader(), h("rebill-address-form", { countryOptions: this.countryOptions, stateOptions: this.currentBillingStateOptions, errors: errorsToShow, disabled: this.disabled, onFieldChanged: e => this.handleInput(e.detail.field, e.detail.value), onSearchRequested: () => this.handleSearchEntry() })));
|
|
944
950
|
}
|
|
945
951
|
render() {
|
|
946
|
-
return (h("div", { key: '
|
|
952
|
+
return (h("div", { key: 'f8078c9118473f6316e43558237a489de8e7e8bf' }, this.renderAddressForm()));
|
|
947
953
|
}
|
|
948
954
|
};
|
|
949
955
|
Address.style = addressCss;
|