@gomusdev/web-components 1.8.1 → 1.8.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.
@@ -11167,10 +11167,13 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
11167
11167
  */
11168
11168
  fetchAndCache(endpoint, dataKey, responseKey, options) {
11169
11169
  var _a2;
11170
- __privateGet(this, _ensureApi).call(this);
11171
11170
  options ?? (options = {});
11172
11171
  options.query ?? (options.query = {});
11173
11172
  options.cache ?? (options.cache = 1e3);
11173
+ if (!__privateGet(this, _canFetch).call(this)) {
11174
+ console.warn("(fetchAndCache) Shop not loaded!");
11175
+ return get(__privateGet(this, _data2))[dataKey];
11176
+ }
11174
11177
  const query = assign(options.query, { per_page: 1e3 });
11175
11178
  const fetchId = endpoint + JSON.stringify(query);
11176
11179
  const isNotFetchedYet = !__privateGet(this, _fetchStatus)[fetchId];
@@ -11494,8 +11497,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
11494
11497
  window.go = go;
11495
11498
  const _Forms = class _Forms {
11496
11499
  static defineForm(options) {
11497
- debugger;
11498
- console.log({ fields: options.fields });
11499
11500
  go.defineConfig({ forms: { [options.id]: { fields: options.fields } } });
11500
11501
  __privateGet(_Forms, _requiredApiKeysMap)[options.id] = options.requiredApiKeys || [];
11501
11502
  }
@@ -11550,6 +11551,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
11550
11551
  return function(host, details) {
11551
11552
  if (host) {
11552
11553
  host.addEventListener(KEY2, (e) => {
11554
+ e.stopPropagation();
11553
11555
  e.detail.data = details;
11554
11556
  });
11555
11557
  }
@@ -11571,7 +11573,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
11571
11573
  constructor(formId, form) {
11572
11574
  __privateAdd(this, _fields, /* @__PURE__ */ state(proxy([])));
11573
11575
  __privateAdd(this, _apiErrors, /* @__PURE__ */ state(proxy([])));
11574
- __privateAdd(this, _isValid, /* @__PURE__ */ user_derived(() => errors(this.fields) == 0));
11576
+ __privateAdd(this, _isValid, /* @__PURE__ */ user_derived(() => errors(get(__privateGet(this, _fields))) == 0));
11575
11577
  this.formId = formId;
11576
11578
  this.form = form;
11577
11579
  }
@@ -11688,7 +11690,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
11688
11690
  }
11689
11691
  }
11690
11692
  onMount(() => {
11691
- const form = wrapInElement($$props.$$host, "form", { id: "login-form", novalidate: true });
11693
+ const form = wrapInElement($$props.$$host, "form", { novalidate: true });
11692
11694
  form.addEventListener("submit", handleSubmit);
11693
11695
  details.form = form;
11694
11696
  });
@@ -13789,11 +13791,10 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
13789
13791
  let when = prop($$props, "when", 7), then = prop($$props, "then", 7, "show");
13790
13792
  const data = /* @__PURE__ */ state(proxy({}));
13791
13793
  get(data).ticketSelection = getTicketSelectionDetails($$props.$$host);
13794
+ let formDetails = /* @__PURE__ */ state(void 0);
13792
13795
  user_effect(() => {
13793
- var _a2;
13794
- const formDetails = getDetails($$props.$$host);
13795
- if (!formDetails) return;
13796
- get(data).formData = (_a2 = getDetails($$props.$$host)) == null ? void 0 : _a2.formData;
13796
+ if (!get(formDetails)) return;
13797
+ get(data).formData = get(formDetails).formData;
13797
13798
  });
13798
13799
  let evaluatedWhen = /* @__PURE__ */ user_derived(() => evaluateExpression(when(), get(data)));
13799
13800
  let content = null;
@@ -13813,6 +13814,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
13813
13814
  }
13814
13815
  }
13815
13816
  });
13817
+ onMount(async () => {
13818
+ set(formDetails, await pollUntilTruthy(() => getDetails($$props.$$host)), true);
13819
+ });
13816
13820
  return pop({
13817
13821
  get data() {
13818
13822
  return get(data);
@@ -13836,7 +13840,16 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
13836
13840
  }
13837
13841
  });
13838
13842
  }
13839
- customElements.define("go-if", create_custom_element(If, { when: {}, then: {} }, [], ["data"], false));
13843
+ customElements.define("go-if", create_custom_element(
13844
+ If,
13845
+ {
13846
+ when: { attribute: "when", reflect: true, type: "String" },
13847
+ then: { attribute: "then", reflect: true, type: "String" }
13848
+ },
13849
+ [],
13850
+ ["data"],
13851
+ false
13852
+ ));
13840
13853
  function GomusInit($$anchor, $$props) {
13841
13854
  push($$props, true);
13842
13855
  let apiUrl = prop($$props, "apiUrl", 7), shopDomain = prop($$props, "shopDomain", 7), locale = prop($$props, "locale", 7);
@@ -11167,10 +11167,13 @@ class Shop {
11167
11167
  */
11168
11168
  fetchAndCache(endpoint, dataKey, responseKey, options) {
11169
11169
  var _a2;
11170
- __privateGet(this, _ensureApi).call(this);
11171
11170
  options ?? (options = {});
11172
11171
  options.query ?? (options.query = {});
11173
11172
  options.cache ?? (options.cache = 1e3);
11173
+ if (!__privateGet(this, _canFetch).call(this)) {
11174
+ console.warn("(fetchAndCache) Shop not loaded!");
11175
+ return get(__privateGet(this, _data2))[dataKey];
11176
+ }
11174
11177
  const query = assign(options.query, { per_page: 1e3 });
11175
11178
  const fetchId = endpoint + JSON.stringify(query);
11176
11179
  const isNotFetchedYet = !__privateGet(this, _fetchStatus)[fetchId];
@@ -11494,8 +11497,6 @@ const go = new Config();
11494
11497
  window.go = go;
11495
11498
  const _Forms = class _Forms {
11496
11499
  static defineForm(options) {
11497
- debugger;
11498
- console.log({ fields: options.fields });
11499
11500
  go.defineConfig({ forms: { [options.id]: { fields: options.fields } } });
11500
11501
  __privateGet(_Forms, _requiredApiKeysMap)[options.id] = options.requiredApiKeys || [];
11501
11502
  }
@@ -11550,6 +11551,7 @@ function createSetDetails(KEY2) {
11550
11551
  return function(host, details) {
11551
11552
  if (host) {
11552
11553
  host.addEventListener(KEY2, (e) => {
11554
+ e.stopPropagation();
11553
11555
  e.detail.data = details;
11554
11556
  });
11555
11557
  }
@@ -11571,7 +11573,7 @@ class FormDetails {
11571
11573
  constructor(formId, form) {
11572
11574
  __privateAdd(this, _fields, /* @__PURE__ */ state(proxy([])));
11573
11575
  __privateAdd(this, _apiErrors, /* @__PURE__ */ state(proxy([])));
11574
- __privateAdd(this, _isValid, /* @__PURE__ */ user_derived(() => errors(this.fields) == 0));
11576
+ __privateAdd(this, _isValid, /* @__PURE__ */ user_derived(() => errors(get(__privateGet(this, _fields))) == 0));
11575
11577
  this.formId = formId;
11576
11578
  this.form = form;
11577
11579
  }
@@ -11688,7 +11690,7 @@ function Form($$anchor, $$props) {
11688
11690
  }
11689
11691
  }
11690
11692
  onMount(() => {
11691
- const form = wrapInElement($$props.$$host, "form", { id: "login-form", novalidate: true });
11693
+ const form = wrapInElement($$props.$$host, "form", { novalidate: true });
11692
11694
  form.addEventListener("submit", handleSubmit);
11693
11695
  details.form = form;
11694
11696
  });
@@ -13789,11 +13791,10 @@ function If($$anchor, $$props) {
13789
13791
  let when = prop($$props, "when", 7), then = prop($$props, "then", 7, "show");
13790
13792
  const data = /* @__PURE__ */ state(proxy({}));
13791
13793
  get(data).ticketSelection = getTicketSelectionDetails($$props.$$host);
13794
+ let formDetails = /* @__PURE__ */ state(void 0);
13792
13795
  user_effect(() => {
13793
- var _a2;
13794
- const formDetails = getDetails($$props.$$host);
13795
- if (!formDetails) return;
13796
- get(data).formData = (_a2 = getDetails($$props.$$host)) == null ? void 0 : _a2.formData;
13796
+ if (!get(formDetails)) return;
13797
+ get(data).formData = get(formDetails).formData;
13797
13798
  });
13798
13799
  let evaluatedWhen = /* @__PURE__ */ user_derived(() => evaluateExpression(when(), get(data)));
13799
13800
  let content = null;
@@ -13813,6 +13814,9 @@ function If($$anchor, $$props) {
13813
13814
  }
13814
13815
  }
13815
13816
  });
13817
+ onMount(async () => {
13818
+ set(formDetails, await pollUntilTruthy(() => getDetails($$props.$$host)), true);
13819
+ });
13816
13820
  return pop({
13817
13821
  get data() {
13818
13822
  return get(data);
@@ -13836,7 +13840,16 @@ function If($$anchor, $$props) {
13836
13840
  }
13837
13841
  });
13838
13842
  }
13839
- customElements.define("go-if", create_custom_element(If, { when: {}, then: {} }, [], ["data"], false));
13843
+ customElements.define("go-if", create_custom_element(
13844
+ If,
13845
+ {
13846
+ when: { attribute: "when", reflect: true, type: "String" },
13847
+ then: { attribute: "then", reflect: true, type: "String" }
13848
+ },
13849
+ [],
13850
+ ["data"],
13851
+ false
13852
+ ));
13840
13853
  function GomusInit($$anchor, $$props) {
13841
13854
  push($$props, true);
13842
13855
  let apiUrl = prop($$props, "apiUrl", 7), shopDomain = prop($$props, "shopDomain", 7), locale = prop($$props, "locale", 7);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "Giantmonkey GmbH"
5
5
  },
6
6
  "license": "MIT",
7
- "version": "1.8.1",
7
+ "version": "1.8.3",
8
8
  "type": "module",
9
9
  "main": "./dist-js/gomus-webcomponents.iife.js",
10
10
  "module": "./dist-js/gomus-webcomponents.iife.js",