@gomusdev/web-components 1.35.0 → 1.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { default as UIForm } from '../forms/ui/generic/Form.svelte';
|
|
2
|
-
export declare function redeem(form: UIForm
|
|
2
|
+
export declare function redeem(form: UIForm): Promise<void>;
|
|
@@ -7,12 +7,14 @@ type defineFormOptions = {
|
|
|
7
7
|
id: string;
|
|
8
8
|
fields: FormField[];
|
|
9
9
|
requiredApiKeys?: string[];
|
|
10
|
+
submitLabel?: string;
|
|
10
11
|
};
|
|
11
12
|
export declare class Forms {
|
|
12
13
|
#private;
|
|
13
14
|
static defineForm(options: defineFormOptions): void;
|
|
14
15
|
static defineFields(fields: Record<string, FieldInit>): void;
|
|
15
16
|
static setRequiredApiKeys(formId: string, requiredApiKeys: string[]): void;
|
|
17
|
+
static getFormOptions(formId: string): any;
|
|
16
18
|
static createField(key: string, required: boolean): Field;
|
|
17
19
|
static getFormFields(formId: string): any;
|
|
18
20
|
static getFieldInit(key: string): any;
|
|
@@ -15420,7 +15420,11 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15420
15420
|
}
|
|
15421
15421
|
const _Forms = class _Forms {
|
|
15422
15422
|
static defineForm(options) {
|
|
15423
|
-
go.defineConfig({
|
|
15423
|
+
go.defineConfig({
|
|
15424
|
+
forms: {
|
|
15425
|
+
[options.id]: { fields: options.fields, submitLabel: options.submitLabel }
|
|
15426
|
+
}
|
|
15427
|
+
});
|
|
15424
15428
|
}
|
|
15425
15429
|
static defineFields(fields) {
|
|
15426
15430
|
go.defineConfig({ fields });
|
|
@@ -15428,6 +15432,9 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15428
15432
|
static setRequiredApiKeys(formId, requiredApiKeys) {
|
|
15429
15433
|
__privateGet(_Forms, _requiredApiKeysMap)[formId] = requiredApiKeys;
|
|
15430
15434
|
}
|
|
15435
|
+
static getFormOptions(formId) {
|
|
15436
|
+
return go.config.forms[formId];
|
|
15437
|
+
}
|
|
15431
15438
|
static createField(key, required) {
|
|
15432
15439
|
const init2 = _Forms.getFieldInit(key);
|
|
15433
15440
|
if (!init2) {
|
|
@@ -15764,7 +15771,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15764
15771
|
host.replaceChildren(element);
|
|
15765
15772
|
return element;
|
|
15766
15773
|
}
|
|
15767
|
-
var root_1$i = /* @__PURE__ */ from_html(`<go-all-fields></go-all-fields> <go-form-feedback><go-errors-feedback></go-errors-feedback> <go-success-feedback></go-success-feedback></go-form-feedback> <go-submit>
|
|
15774
|
+
var root_1$i = /* @__PURE__ */ from_html(`<go-all-fields></go-all-fields> <go-form-feedback><go-errors-feedback></go-errors-feedback> <go-success-feedback></go-success-feedback></go-form-feedback> <go-submit> </go-submit>`, 3);
|
|
15768
15775
|
function Form($$anchor, $$props) {
|
|
15769
15776
|
push($$props, true);
|
|
15770
15777
|
let formId = prop($$props, "formId", 7), custom2 = prop($$props, "custom", 7);
|
|
@@ -15810,7 +15817,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15810
15817
|
var fragment_1 = root_1$i();
|
|
15811
15818
|
var go_all_fields = first_child(fragment_1);
|
|
15812
15819
|
var go_form_feedback = sibling(go_all_fields, 2);
|
|
15813
|
-
sibling(go_form_feedback, 2);
|
|
15820
|
+
var go_submit = sibling(go_form_feedback, 2);
|
|
15821
|
+
var text2 = child(go_submit, true);
|
|
15822
|
+
reset(go_submit);
|
|
15823
|
+
template_effect(($0) => set_text(text2, $0), [
|
|
15824
|
+
() => shop.t(Forms.getFormOptions(formId())?.submitLabel || "Submit")
|
|
15825
|
+
]);
|
|
15814
15826
|
append($$anchor2, fragment_1);
|
|
15815
15827
|
};
|
|
15816
15828
|
if_block(node, ($$render) => {
|
|
@@ -15836,6 +15848,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15836
15848
|
let custom2 = prop($$props, "custom", 7, false);
|
|
15837
15849
|
Forms.defineForm({
|
|
15838
15850
|
id: "passwordReset",
|
|
15851
|
+
submitLabel: "user.passwordReset.actions.requestPasswordReset",
|
|
15839
15852
|
fields: [{ key: "email", required: true }]
|
|
15840
15853
|
});
|
|
15841
15854
|
async function passwordReset(event2) {
|
|
@@ -15872,6 +15885,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15872
15885
|
push($$props, true);
|
|
15873
15886
|
Forms.defineForm({
|
|
15874
15887
|
id: "signIn",
|
|
15888
|
+
submitLabel: "common.actions.login",
|
|
15875
15889
|
fields: [
|
|
15876
15890
|
{ key: "email", required: true },
|
|
15877
15891
|
{ key: "password", required: true }
|
|
@@ -15907,6 +15921,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
15907
15921
|
push($$props, true);
|
|
15908
15922
|
Forms.defineForm({
|
|
15909
15923
|
id: "signUp",
|
|
15924
|
+
submitLabel: "common.actions.register",
|
|
15910
15925
|
fields: [
|
|
15911
15926
|
// { id: 'salutation', required: false },
|
|
15912
15927
|
{ key: "firstName", required: true },
|
|
@@ -16251,6 +16266,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16251
16266
|
let cart = /* @__PURE__ */ user_derived(() => shop.cart);
|
|
16252
16267
|
Forms.defineForm({
|
|
16253
16268
|
id: "checkoutGuest",
|
|
16269
|
+
submitLabel: "cart.detail.actions.checkout",
|
|
16254
16270
|
fields: [
|
|
16255
16271
|
{ key: "firstName", required: true },
|
|
16256
16272
|
{ key: "lastName", required: true },
|
|
@@ -16293,7 +16309,8 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16293
16309
|
return pop($$exports);
|
|
16294
16310
|
}
|
|
16295
16311
|
customElements.define("go-checkout-form", create_custom_element(CheckoutForm, { custom: {} }, [], [], false));
|
|
16296
|
-
|
|
16312
|
+
enable_legacy_mode_flag();
|
|
16313
|
+
async function redeem(form) {
|
|
16297
16314
|
if (!form) {
|
|
16298
16315
|
throw new Error("(go-coupon-redemption): form not found");
|
|
16299
16316
|
}
|
|
@@ -16319,36 +16336,29 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
16319
16336
|
const token = form.details.formData.id;
|
|
16320
16337
|
shop.cart.addCoupon(token);
|
|
16321
16338
|
const tokenField = form.details.fields.find((f) => f.key === "token");
|
|
16322
|
-
if (tokenField)
|
|
16323
|
-
|
|
16339
|
+
if (tokenField) {
|
|
16340
|
+
tokenField.value = "";
|
|
16341
|
+
form.dispatchEvent(new Event("go-success", { bubbles: true, composed: true }));
|
|
16342
|
+
}
|
|
16324
16343
|
} else {
|
|
16325
16344
|
form.details.apiErrors ??= [];
|
|
16326
16345
|
form.details.apiErrors = [shop.t("cart.coupon.form.errors.notValid")];
|
|
16327
16346
|
}
|
|
16328
16347
|
}
|
|
16329
|
-
var root$7 = /* @__PURE__ */ from_html(`<go-form
|
|
16348
|
+
var root$7 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
|
|
16330
16349
|
function CouponRedemption($$anchor, $$props) {
|
|
16331
|
-
push($$props,
|
|
16332
|
-
let form;
|
|
16350
|
+
push($$props, false);
|
|
16333
16351
|
Forms.defineForm({
|
|
16334
16352
|
id: "couponRedemption",
|
|
16353
|
+
submitLabel: "cart.coupon.form.submit",
|
|
16335
16354
|
fields: [{ key: "token", required: true }]
|
|
16336
16355
|
});
|
|
16337
|
-
async function redeem$1() {
|
|
16338
|
-
await redeem(
|
|
16356
|
+
async function redeem$1(e) {
|
|
16357
|
+
await redeem(e.target);
|
|
16339
16358
|
}
|
|
16359
|
+
init();
|
|
16340
16360
|
var go_form = root$7();
|
|
16341
16361
|
set_custom_element_data(go_form, "formId", "couponRedemption");
|
|
16342
|
-
set_custom_element_data(go_form, "custom", true);
|
|
16343
|
-
var go_field = child(go_form);
|
|
16344
|
-
set_custom_element_data(go_field, "key", "token");
|
|
16345
|
-
var go_errors_feedback = sibling(go_field, 2);
|
|
16346
|
-
var go_submit = sibling(go_errors_feedback, 2);
|
|
16347
|
-
var text2 = child(go_submit, true);
|
|
16348
|
-
reset(go_submit);
|
|
16349
|
-
reset(go_form);
|
|
16350
|
-
bind_this(go_form, ($$value) => form = $$value, () => form);
|
|
16351
|
-
template_effect(($0) => set_text(text2, $0), [() => shop.t("cart.coupon.form.submit")]);
|
|
16352
16362
|
event("submit", go_form, redeem$1);
|
|
16353
16363
|
append($$anchor, go_form);
|
|
16354
16364
|
pop();
|
|
@@ -22480,7 +22490,6 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
22480
22490
|
return pop($$exports);
|
|
22481
22491
|
}
|
|
22482
22492
|
create_custom_element(Calendar_prev_button, { children: {}, child: {}, id: {}, ref: {}, tabindex: {} }, [], [], true);
|
|
22483
|
-
enable_legacy_mode_flag();
|
|
22484
22493
|
var root_1$e = /* @__PURE__ */ from_html(`<input/>`);
|
|
22485
22494
|
var root_2$c = /* @__PURE__ */ from_html(`<input/>`);
|
|
22486
22495
|
function Hidden_input($$anchor, $$props) {
|
|
@@ -15420,7 +15420,11 @@ function validateField(field) {
|
|
|
15420
15420
|
}
|
|
15421
15421
|
const _Forms = class _Forms {
|
|
15422
15422
|
static defineForm(options) {
|
|
15423
|
-
go.defineConfig({
|
|
15423
|
+
go.defineConfig({
|
|
15424
|
+
forms: {
|
|
15425
|
+
[options.id]: { fields: options.fields, submitLabel: options.submitLabel }
|
|
15426
|
+
}
|
|
15427
|
+
});
|
|
15424
15428
|
}
|
|
15425
15429
|
static defineFields(fields) {
|
|
15426
15430
|
go.defineConfig({ fields });
|
|
@@ -15428,6 +15432,9 @@ const _Forms = class _Forms {
|
|
|
15428
15432
|
static setRequiredApiKeys(formId, requiredApiKeys) {
|
|
15429
15433
|
__privateGet(_Forms, _requiredApiKeysMap)[formId] = requiredApiKeys;
|
|
15430
15434
|
}
|
|
15435
|
+
static getFormOptions(formId) {
|
|
15436
|
+
return go.config.forms[formId];
|
|
15437
|
+
}
|
|
15431
15438
|
static createField(key, required) {
|
|
15432
15439
|
const init2 = _Forms.getFieldInit(key);
|
|
15433
15440
|
if (!init2) {
|
|
@@ -15764,7 +15771,7 @@ function wrapInElement(host, tag, props) {
|
|
|
15764
15771
|
host.replaceChildren(element);
|
|
15765
15772
|
return element;
|
|
15766
15773
|
}
|
|
15767
|
-
var root_1$i = /* @__PURE__ */ from_html(`<go-all-fields></go-all-fields> <go-form-feedback><go-errors-feedback></go-errors-feedback> <go-success-feedback></go-success-feedback></go-form-feedback> <go-submit>
|
|
15774
|
+
var root_1$i = /* @__PURE__ */ from_html(`<go-all-fields></go-all-fields> <go-form-feedback><go-errors-feedback></go-errors-feedback> <go-success-feedback></go-success-feedback></go-form-feedback> <go-submit> </go-submit>`, 3);
|
|
15768
15775
|
function Form($$anchor, $$props) {
|
|
15769
15776
|
push($$props, true);
|
|
15770
15777
|
let formId = prop($$props, "formId", 7), custom2 = prop($$props, "custom", 7);
|
|
@@ -15810,7 +15817,12 @@ function Form($$anchor, $$props) {
|
|
|
15810
15817
|
var fragment_1 = root_1$i();
|
|
15811
15818
|
var go_all_fields = first_child(fragment_1);
|
|
15812
15819
|
var go_form_feedback = sibling(go_all_fields, 2);
|
|
15813
|
-
sibling(go_form_feedback, 2);
|
|
15820
|
+
var go_submit = sibling(go_form_feedback, 2);
|
|
15821
|
+
var text2 = child(go_submit, true);
|
|
15822
|
+
reset(go_submit);
|
|
15823
|
+
template_effect(($0) => set_text(text2, $0), [
|
|
15824
|
+
() => shop.t(Forms.getFormOptions(formId())?.submitLabel || "Submit")
|
|
15825
|
+
]);
|
|
15814
15826
|
append($$anchor2, fragment_1);
|
|
15815
15827
|
};
|
|
15816
15828
|
if_block(node, ($$render) => {
|
|
@@ -15836,6 +15848,7 @@ function PasswordReset($$anchor, $$props) {
|
|
|
15836
15848
|
let custom2 = prop($$props, "custom", 7, false);
|
|
15837
15849
|
Forms.defineForm({
|
|
15838
15850
|
id: "passwordReset",
|
|
15851
|
+
submitLabel: "user.passwordReset.actions.requestPasswordReset",
|
|
15839
15852
|
fields: [{ key: "email", required: true }]
|
|
15840
15853
|
});
|
|
15841
15854
|
async function passwordReset(event2) {
|
|
@@ -15872,6 +15885,7 @@ function SignIn($$anchor, $$props) {
|
|
|
15872
15885
|
push($$props, true);
|
|
15873
15886
|
Forms.defineForm({
|
|
15874
15887
|
id: "signIn",
|
|
15888
|
+
submitLabel: "common.actions.login",
|
|
15875
15889
|
fields: [
|
|
15876
15890
|
{ key: "email", required: true },
|
|
15877
15891
|
{ key: "password", required: true }
|
|
@@ -15907,6 +15921,7 @@ function SignUp($$anchor, $$props) {
|
|
|
15907
15921
|
push($$props, true);
|
|
15908
15922
|
Forms.defineForm({
|
|
15909
15923
|
id: "signUp",
|
|
15924
|
+
submitLabel: "common.actions.register",
|
|
15910
15925
|
fields: [
|
|
15911
15926
|
// { id: 'salutation', required: false },
|
|
15912
15927
|
{ key: "firstName", required: true },
|
|
@@ -16251,6 +16266,7 @@ function CheckoutForm($$anchor, $$props) {
|
|
|
16251
16266
|
let cart = /* @__PURE__ */ user_derived(() => shop.cart);
|
|
16252
16267
|
Forms.defineForm({
|
|
16253
16268
|
id: "checkoutGuest",
|
|
16269
|
+
submitLabel: "cart.detail.actions.checkout",
|
|
16254
16270
|
fields: [
|
|
16255
16271
|
{ key: "firstName", required: true },
|
|
16256
16272
|
{ key: "lastName", required: true },
|
|
@@ -16293,7 +16309,8 @@ function CheckoutForm($$anchor, $$props) {
|
|
|
16293
16309
|
return pop($$exports);
|
|
16294
16310
|
}
|
|
16295
16311
|
customElements.define("go-checkout-form", create_custom_element(CheckoutForm, { custom: {} }, [], [], false));
|
|
16296
|
-
|
|
16312
|
+
enable_legacy_mode_flag();
|
|
16313
|
+
async function redeem(form) {
|
|
16297
16314
|
if (!form) {
|
|
16298
16315
|
throw new Error("(go-coupon-redemption): form not found");
|
|
16299
16316
|
}
|
|
@@ -16319,36 +16336,29 @@ async function redeem(form, host) {
|
|
|
16319
16336
|
const token = form.details.formData.id;
|
|
16320
16337
|
shop.cart.addCoupon(token);
|
|
16321
16338
|
const tokenField = form.details.fields.find((f) => f.key === "token");
|
|
16322
|
-
if (tokenField)
|
|
16323
|
-
|
|
16339
|
+
if (tokenField) {
|
|
16340
|
+
tokenField.value = "";
|
|
16341
|
+
form.dispatchEvent(new Event("go-success", { bubbles: true, composed: true }));
|
|
16342
|
+
}
|
|
16324
16343
|
} else {
|
|
16325
16344
|
form.details.apiErrors ??= [];
|
|
16326
16345
|
form.details.apiErrors = [shop.t("cart.coupon.form.errors.notValid")];
|
|
16327
16346
|
}
|
|
16328
16347
|
}
|
|
16329
|
-
var root$7 = /* @__PURE__ */ from_html(`<go-form
|
|
16348
|
+
var root$7 = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
|
|
16330
16349
|
function CouponRedemption($$anchor, $$props) {
|
|
16331
|
-
push($$props,
|
|
16332
|
-
let form;
|
|
16350
|
+
push($$props, false);
|
|
16333
16351
|
Forms.defineForm({
|
|
16334
16352
|
id: "couponRedemption",
|
|
16353
|
+
submitLabel: "cart.coupon.form.submit",
|
|
16335
16354
|
fields: [{ key: "token", required: true }]
|
|
16336
16355
|
});
|
|
16337
|
-
async function redeem$1() {
|
|
16338
|
-
await redeem(
|
|
16356
|
+
async function redeem$1(e) {
|
|
16357
|
+
await redeem(e.target);
|
|
16339
16358
|
}
|
|
16359
|
+
init();
|
|
16340
16360
|
var go_form = root$7();
|
|
16341
16361
|
set_custom_element_data(go_form, "formId", "couponRedemption");
|
|
16342
|
-
set_custom_element_data(go_form, "custom", true);
|
|
16343
|
-
var go_field = child(go_form);
|
|
16344
|
-
set_custom_element_data(go_field, "key", "token");
|
|
16345
|
-
var go_errors_feedback = sibling(go_field, 2);
|
|
16346
|
-
var go_submit = sibling(go_errors_feedback, 2);
|
|
16347
|
-
var text2 = child(go_submit, true);
|
|
16348
|
-
reset(go_submit);
|
|
16349
|
-
reset(go_form);
|
|
16350
|
-
bind_this(go_form, ($$value) => form = $$value, () => form);
|
|
16351
|
-
template_effect(($0) => set_text(text2, $0), [() => shop.t("cart.coupon.form.submit")]);
|
|
16352
16362
|
event("submit", go_form, redeem$1);
|
|
16353
16363
|
append($$anchor, go_form);
|
|
16354
16364
|
pop();
|
|
@@ -22480,7 +22490,6 @@ function Calendar_prev_button($$anchor, $$props) {
|
|
|
22480
22490
|
return pop($$exports);
|
|
22481
22491
|
}
|
|
22482
22492
|
create_custom_element(Calendar_prev_button, { children: {}, child: {}, id: {}, ref: {}, tabindex: {} }, [], [], true);
|
|
22483
|
-
enable_legacy_mode_flag();
|
|
22484
22493
|
var root_1$e = /* @__PURE__ */ from_html(`<input/>`);
|
|
22485
22494
|
var root_2$c = /* @__PURE__ */ from_html(`<input/>`);
|
|
22486
22495
|
function Hidden_input($$anchor, $$props) {
|