@gomusdev/web-components 1.44.0 → 1.45.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.
@@ -12816,19 +12816,28 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
12816
12816
  this.update();
12817
12817
  }
12818
12818
  update() {
12819
- this.options = assign(this.defaultConfig, this.override);
12819
+ const merged = assign(this.defaultConfig, this.override);
12820
+ merged.forms = Object.keys({ ...this.defaultConfig.forms, ...this.override.forms }).reduce(
12821
+ (acc, key) => {
12822
+ acc[key] = {
12823
+ ...this.defaultConfig.forms[key],
12824
+ ...this.override.forms[key]
12825
+ };
12826
+ return acc;
12827
+ },
12828
+ {}
12829
+ );
12830
+ this.options = merged;
12820
12831
  }
12821
12832
  get config() {
12822
12833
  return this.options;
12823
12834
  }
12824
12835
  define(options) {
12825
- console.log("ConfigStore.define", options);
12826
12836
  this.override = assign(this.override, options);
12827
12837
  this.update();
12828
12838
  return this;
12829
12839
  }
12830
12840
  default(options) {
12831
- console.log("ConfigStore.default", options);
12832
12841
  this.defaultConfig = assign(this.defaultConfig, options);
12833
12842
  this.update();
12834
12843
  return this;
@@ -16475,14 +16484,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16475
16484
  fill(data) {
16476
16485
  const fs = this.fields;
16477
16486
  Object.entries(data).forEach(([key, val]) => {
16478
- console.log(key, val);
16479
16487
  const f = fs.find((f2) => f2.apiKey === key);
16480
16488
  if (!f) {
16481
16489
  console.warn(`(FormDetails.fill) Field with API key ${key} not found.`);
16482
16490
  return;
16483
16491
  }
16484
16492
  if (f.type === "select") {
16485
- console.log(f.options());
16486
16493
  if (!f.options?.().find((o) => o.value === val)) {
16487
16494
  throw new Error(`(FormDetails.fill) Field ${key} has invalid value: ${val}`);
16488
16495
  }
@@ -16590,7 +16597,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16590
16597
  [],
16591
16598
  ["details"]
16592
16599
  ));
16593
- var root$c = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
16600
+ var root$a = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
16594
16601
  function PasswordReset($$anchor, $$props) {
16595
16602
  push($$props, true);
16596
16603
  let custom2 = prop($$props, "custom", 7, false);
@@ -16620,7 +16627,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16620
16627
  flushSync();
16621
16628
  }
16622
16629
  };
16623
- var go_form = root$c();
16630
+ var go_form = root$a();
16624
16631
  set_custom_element_data(go_form, "formId", "passwordReset");
16625
16632
  template_effect(() => set_custom_element_data(go_form, "custom", custom2()));
16626
16633
  event("submit", go_form, passwordReset);
@@ -16628,7 +16635,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16628
16635
  return pop($$exports);
16629
16636
  }
16630
16637
  customElements.define("go-password-reset", create_custom_element(PasswordReset, { custom: {} }, [], []));
16631
- var root$b = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
16632
16638
  function SignIn($$anchor, $$props) {
16633
16639
  push($$props, true);
16634
16640
  Forms.defineForm({
@@ -16639,6 +16645,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16639
16645
  { key: "password", required: true }
16640
16646
  ]
16641
16647
  });
16648
+ let custom2 = prop($$props, "custom", 7, false);
16642
16649
  async function signIn(event2) {
16643
16650
  const form = event2.target;
16644
16651
  const details = form.details;
@@ -16649,11 +16656,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16649
16656
  details.apiErrors = result.error.errors;
16650
16657
  }
16651
16658
  }
16652
- var go_form = root$b();
16653
- set_custom_element_data(go_form, "formId", "signIn");
16654
- event("submit", go_form, signIn);
16655
- append($$anchor, go_form);
16656
- pop();
16659
+ wrapInElement($$props.$$host, "go-form", { "form-id": "signIn", custom: custom2() });
16660
+ $$props.$$host.addEventListener("submit", signIn);
16661
+ var $$exports = {
16662
+ get custom() {
16663
+ return custom2();
16664
+ },
16665
+ set custom($$value = false) {
16666
+ custom2($$value);
16667
+ flushSync();
16668
+ }
16669
+ };
16670
+ return pop($$exports);
16657
16671
  }
16658
16672
  customElements.define("go-sign-in", create_custom_element(
16659
16673
  SignIn,
@@ -16663,9 +16677,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16663
16677
  [],
16664
16678
  []
16665
16679
  ));
16666
- var root$a = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
16667
16680
  function SignUp($$anchor, $$props) {
16668
16681
  push($$props, true);
16682
+ let custom2 = prop($$props, "custom", 7, false);
16669
16683
  Forms.defineForm({
16670
16684
  id: "signUp",
16671
16685
  submitLabel: "common.actions.register",
@@ -16696,11 +16710,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16696
16710
  details.apiErrors = result.error.errors;
16697
16711
  }
16698
16712
  }
16699
- var go_form = root$a();
16700
- set_custom_element_data(go_form, "formId", "signUp");
16701
- event("submit", go_form, signUp);
16702
- append($$anchor, go_form);
16703
- pop();
16713
+ wrapInElement($$props.$$host, "go-form", { "form-id": "signUp", custom: custom2() });
16714
+ $$props.$$host.addEventListener("submit", signUp);
16715
+ var $$exports = {
16716
+ get custom() {
16717
+ return custom2();
16718
+ },
16719
+ set custom($$value = false) {
16720
+ custom2($$value);
16721
+ flushSync();
16722
+ }
16723
+ };
16724
+ return pop($$exports);
16704
16725
  }
16705
16726
  customElements.define("go-sign-up", create_custom_element(
16706
16727
  SignUp,
@@ -17140,26 +17161,24 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17140
17161
  ]
17141
17162
  });
17142
17163
  wrapInElement($$props.$$host, "go-form", { "form-id": "checkoutGuest", custom: custom2() });
17143
- const form = $$props.$$host.querySelector("go-form");
17144
- onMount(async () => {
17145
- $$props.$$host.addEventListener("go-submit", async (e) => {
17146
- const auth = await shop.signUp(form.details.formData, true);
17147
- if (auth.error) {
17148
- form.details.apiErrors = auth.error.errors;
17149
- return;
17150
- }
17151
- const checkout = await shop.checkout(get$2(cart).orderData());
17152
- if (checkout.error) {
17153
- form.details.apiErrors = checkout.error;
17154
- return;
17155
- }
17156
- const beforeSubmit = configStore.config.forms.checkoutGuest?.beforeSubmit;
17157
- if (beforeSubmit) {
17158
- await beforeSubmit(form.details.formData);
17159
- }
17160
- const paymentUrl = checkout.data.meta.payment_url;
17161
- configStore.config.navigateTo?.(paymentUrl);
17162
- });
17164
+ $$props.$$host.addEventListener("submit", async (e) => {
17165
+ const form = e.target;
17166
+ const auth = await shop.signUp(form.details.formData, true);
17167
+ if (auth.error) {
17168
+ form.details.apiErrors = auth.error.errors;
17169
+ return;
17170
+ }
17171
+ const checkout = await shop.checkout(get$2(cart).orderData());
17172
+ if (checkout.error) {
17173
+ form.details.apiErrors = checkout.error;
17174
+ return;
17175
+ }
17176
+ const beforeSubmit = configStore.config.forms.checkoutGuest?.beforeSubmit;
17177
+ if (beforeSubmit) {
17178
+ await beforeSubmit(form.details.formData);
17179
+ }
17180
+ const paymentUrl = checkout.data.meta.payment_url;
17181
+ configStore.config.navigateTo?.(paymentUrl);
17163
17182
  });
17164
17183
  var $$exports = {
17165
17184
  get custom() {
@@ -12816,19 +12816,28 @@ class ConfigStoreSvelte {
12816
12816
  this.update();
12817
12817
  }
12818
12818
  update() {
12819
- this.options = assign(this.defaultConfig, this.override);
12819
+ const merged = assign(this.defaultConfig, this.override);
12820
+ merged.forms = Object.keys({ ...this.defaultConfig.forms, ...this.override.forms }).reduce(
12821
+ (acc, key) => {
12822
+ acc[key] = {
12823
+ ...this.defaultConfig.forms[key],
12824
+ ...this.override.forms[key]
12825
+ };
12826
+ return acc;
12827
+ },
12828
+ {}
12829
+ );
12830
+ this.options = merged;
12820
12831
  }
12821
12832
  get config() {
12822
12833
  return this.options;
12823
12834
  }
12824
12835
  define(options) {
12825
- console.log("ConfigStore.define", options);
12826
12836
  this.override = assign(this.override, options);
12827
12837
  this.update();
12828
12838
  return this;
12829
12839
  }
12830
12840
  default(options) {
12831
- console.log("ConfigStore.default", options);
12832
12841
  this.defaultConfig = assign(this.defaultConfig, options);
12833
12842
  this.update();
12834
12843
  return this;
@@ -16475,14 +16484,12 @@ class FormDetails {
16475
16484
  fill(data) {
16476
16485
  const fs = this.fields;
16477
16486
  Object.entries(data).forEach(([key, val]) => {
16478
- console.log(key, val);
16479
16487
  const f = fs.find((f2) => f2.apiKey === key);
16480
16488
  if (!f) {
16481
16489
  console.warn(`(FormDetails.fill) Field with API key ${key} not found.`);
16482
16490
  return;
16483
16491
  }
16484
16492
  if (f.type === "select") {
16485
- console.log(f.options());
16486
16493
  if (!f.options?.().find((o) => o.value === val)) {
16487
16494
  throw new Error(`(FormDetails.fill) Field ${key} has invalid value: ${val}`);
16488
16495
  }
@@ -16590,7 +16597,7 @@ customElements.define("go-form", create_custom_element(
16590
16597
  [],
16591
16598
  ["details"]
16592
16599
  ));
16593
- var root$c = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
16600
+ var root$a = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
16594
16601
  function PasswordReset($$anchor, $$props) {
16595
16602
  push($$props, true);
16596
16603
  let custom2 = prop($$props, "custom", 7, false);
@@ -16620,7 +16627,7 @@ function PasswordReset($$anchor, $$props) {
16620
16627
  flushSync();
16621
16628
  }
16622
16629
  };
16623
- var go_form = root$c();
16630
+ var go_form = root$a();
16624
16631
  set_custom_element_data(go_form, "formId", "passwordReset");
16625
16632
  template_effect(() => set_custom_element_data(go_form, "custom", custom2()));
16626
16633
  event("submit", go_form, passwordReset);
@@ -16628,7 +16635,6 @@ function PasswordReset($$anchor, $$props) {
16628
16635
  return pop($$exports);
16629
16636
  }
16630
16637
  customElements.define("go-password-reset", create_custom_element(PasswordReset, { custom: {} }, [], []));
16631
- var root$b = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
16632
16638
  function SignIn($$anchor, $$props) {
16633
16639
  push($$props, true);
16634
16640
  Forms.defineForm({
@@ -16639,6 +16645,7 @@ function SignIn($$anchor, $$props) {
16639
16645
  { key: "password", required: true }
16640
16646
  ]
16641
16647
  });
16648
+ let custom2 = prop($$props, "custom", 7, false);
16642
16649
  async function signIn(event2) {
16643
16650
  const form = event2.target;
16644
16651
  const details = form.details;
@@ -16649,11 +16656,18 @@ function SignIn($$anchor, $$props) {
16649
16656
  details.apiErrors = result.error.errors;
16650
16657
  }
16651
16658
  }
16652
- var go_form = root$b();
16653
- set_custom_element_data(go_form, "formId", "signIn");
16654
- event("submit", go_form, signIn);
16655
- append($$anchor, go_form);
16656
- pop();
16659
+ wrapInElement($$props.$$host, "go-form", { "form-id": "signIn", custom: custom2() });
16660
+ $$props.$$host.addEventListener("submit", signIn);
16661
+ var $$exports = {
16662
+ get custom() {
16663
+ return custom2();
16664
+ },
16665
+ set custom($$value = false) {
16666
+ custom2($$value);
16667
+ flushSync();
16668
+ }
16669
+ };
16670
+ return pop($$exports);
16657
16671
  }
16658
16672
  customElements.define("go-sign-in", create_custom_element(
16659
16673
  SignIn,
@@ -16663,9 +16677,9 @@ customElements.define("go-sign-in", create_custom_element(
16663
16677
  [],
16664
16678
  []
16665
16679
  ));
16666
- var root$a = /* @__PURE__ */ from_html(`<go-form></go-form>`, 2);
16667
16680
  function SignUp($$anchor, $$props) {
16668
16681
  push($$props, true);
16682
+ let custom2 = prop($$props, "custom", 7, false);
16669
16683
  Forms.defineForm({
16670
16684
  id: "signUp",
16671
16685
  submitLabel: "common.actions.register",
@@ -16696,11 +16710,18 @@ function SignUp($$anchor, $$props) {
16696
16710
  details.apiErrors = result.error.errors;
16697
16711
  }
16698
16712
  }
16699
- var go_form = root$a();
16700
- set_custom_element_data(go_form, "formId", "signUp");
16701
- event("submit", go_form, signUp);
16702
- append($$anchor, go_form);
16703
- pop();
16713
+ wrapInElement($$props.$$host, "go-form", { "form-id": "signUp", custom: custom2() });
16714
+ $$props.$$host.addEventListener("submit", signUp);
16715
+ var $$exports = {
16716
+ get custom() {
16717
+ return custom2();
16718
+ },
16719
+ set custom($$value = false) {
16720
+ custom2($$value);
16721
+ flushSync();
16722
+ }
16723
+ };
16724
+ return pop($$exports);
16704
16725
  }
16705
16726
  customElements.define("go-sign-up", create_custom_element(
16706
16727
  SignUp,
@@ -17140,26 +17161,24 @@ function CheckoutForm($$anchor, $$props) {
17140
17161
  ]
17141
17162
  });
17142
17163
  wrapInElement($$props.$$host, "go-form", { "form-id": "checkoutGuest", custom: custom2() });
17143
- const form = $$props.$$host.querySelector("go-form");
17144
- onMount(async () => {
17145
- $$props.$$host.addEventListener("go-submit", async (e) => {
17146
- const auth = await shop.signUp(form.details.formData, true);
17147
- if (auth.error) {
17148
- form.details.apiErrors = auth.error.errors;
17149
- return;
17150
- }
17151
- const checkout = await shop.checkout(get$2(cart).orderData());
17152
- if (checkout.error) {
17153
- form.details.apiErrors = checkout.error;
17154
- return;
17155
- }
17156
- const beforeSubmit = configStore.config.forms.checkoutGuest?.beforeSubmit;
17157
- if (beforeSubmit) {
17158
- await beforeSubmit(form.details.formData);
17159
- }
17160
- const paymentUrl = checkout.data.meta.payment_url;
17161
- configStore.config.navigateTo?.(paymentUrl);
17162
- });
17164
+ $$props.$$host.addEventListener("submit", async (e) => {
17165
+ const form = e.target;
17166
+ const auth = await shop.signUp(form.details.formData, true);
17167
+ if (auth.error) {
17168
+ form.details.apiErrors = auth.error.errors;
17169
+ return;
17170
+ }
17171
+ const checkout = await shop.checkout(get$2(cart).orderData());
17172
+ if (checkout.error) {
17173
+ form.details.apiErrors = checkout.error;
17174
+ return;
17175
+ }
17176
+ const beforeSubmit = configStore.config.forms.checkoutGuest?.beforeSubmit;
17177
+ if (beforeSubmit) {
17178
+ await beforeSubmit(form.details.formData);
17179
+ }
17180
+ const paymentUrl = checkout.data.meta.payment_url;
17181
+ configStore.config.navigateTo?.(paymentUrl);
17163
17182
  });
17164
17183
  var $$exports = {
17165
17184
  get custom() {
@@ -1 +1 @@
1
- export declare function wrapInElement(host: HTMLElement, tag: string, props?: Record<string, string | boolean>): HTMLElement;
1
+ export declare function wrapInElement(host: HTMLElement, tag: string, props?: Record<string, unknown | boolean>): HTMLElement;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "Giantmonkey GmbH"
5
5
  },
6
6
  "license": "MIT",
7
- "version": "1.44.0",
7
+ "version": "1.45.0",
8
8
  "type": "module",
9
9
  "main": "./dist-js/gomus-webcomponents.iife.js",
10
10
  "module": "./dist-js/gomus-webcomponents.iife.js",