@gomusdev/web-components 4.1.0 → 4.2.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.
package/README.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.2.0 (2026-07-09)
4
+
5
+ ### Features
6
+
7
+ * **membership:** add <go-membership-activation> form web component
8
+
9
+ ## 4.1.1 (2026-07-09)
10
+
11
+ ### Bug Fixes
12
+
13
+ * **forms:** pass required type argument to HTMLAttributes
14
+ * **forms:** resolve remaining typescript-eslint errors in InputAndLabel
15
+ * **forms:** set field.value when a single payment mode is auto-selected, closes [#135](https://gitlab.giantmonkey.de/gomus/frontend/issues/135)
16
+ * **forms:** type the field snippet map as Record<FieldType, Snippet>
17
+
3
18
  ## 4.1.0 (2026-07-09)
4
19
 
5
20
  ### Features
@@ -0,0 +1 @@
1
+ export { SvelteComponent as default } from 'svelte';
@@ -13545,6 +13545,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13545
13545
  var SIGN_IN_ENDPOINT = "/api/v4/auth/sign_in";
13546
13546
  var SIGN_UP_ENDPOINT = "/api/v4/auth";
13547
13547
  var WITHDRAWAL_ENDPOINT = "/api/v4/orders/withdrawals";
13548
+ var MEMBERSHIP_ACTIVATION_ENDPOINT = "/api/v4/customer/memberships/activate";
13548
13549
  var ORDERS_ENDPOINT = "/api/v4/orders";
13549
13550
  //#endregion
13550
13551
  //#region ../../packages/gomus-api/lib/customerLevels.ts
@@ -13763,6 +13764,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13763
13764
  requiredFields: ["email"]
13764
13765
  });
13765
13766
  }
13767
+ activateMembership(params) {
13768
+ return this.apiPost(MEMBERSHIP_ACTIVATION_ENDPOINT, {
13769
+ body: params,
13770
+ requiredFields: ["email"],
13771
+ parseAs: "text"
13772
+ });
13773
+ }
13766
13774
  checkout(params) {
13767
13775
  return this.apiPost(`/api/v4/orders`, {
13768
13776
  body: params,
@@ -32813,10 +32821,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
32813
32821
  var root_9$1 = /* @__PURE__ */ from_html(`<label><!></label> <select><!></select>`, 1);
32814
32822
  var root_10$1 = /* @__PURE__ */ from_html(`<img style="width: 60px" aria-hidden="true"/>`);
32815
32823
  var root_11 = /* @__PURE__ */ from_html(`<span class="go-payment-mode-icons"></span>`);
32816
- var root_12 = /* @__PURE__ */ from_html(`<label><input type="radio"/> <!></label>`);
32817
- var root_13 = /* @__PURE__ */ from_html(`<fieldset role="radiogroup"><legend><!></legend> <!></fieldset>`);
32818
- var root_14 = /* @__PURE__ */ from_html(`<label> <input/></label>`);
32819
- var root_15 = /* @__PURE__ */ from_html(`<fieldset><legend><!></legend> <!></fieldset>`);
32824
+ var root_12 = /* @__PURE__ */ from_html(`<span class="go-payment-mode-name"> </span>`);
32825
+ var root_13 = /* @__PURE__ */ from_html(`<label><input type="radio"/> <!></label>`);
32826
+ var root_14 = /* @__PURE__ */ from_html(`<fieldset role="radiogroup"><legend><!></legend> <!></fieldset>`);
32827
+ var root_15 = /* @__PURE__ */ from_html(`<label> <input/></label>`);
32828
+ var root_16 = /* @__PURE__ */ from_html(`<fieldset><legend><!></legend> <!></fieldset>`);
32820
32829
  function InputAndLabel($$anchor, $$props) {
32821
32830
  push($$props, true);
32822
32831
  const labelText = ($$anchor) => {
@@ -33016,12 +33025,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
33016
33025
  };
33017
33026
  const paymentMode = ($$anchor) => {
33018
33027
  const modes = /* @__PURE__ */ user_derived(() => shop.payment_modes ? Object.values(shop.payment_modes) : []);
33019
- var fieldset = root_13();
33028
+ var fieldset = root_14();
33020
33029
  var legend = child(fieldset);
33021
33030
  labelText(child(legend));
33022
33031
  reset(legend);
33023
33032
  each(sibling(legend, 2), 17, () => get$2(modes), (mode) => mode.id, ($$anchor, mode) => {
33024
- var label_6 = root_12();
33033
+ var label_6 = root_13();
33025
33034
  var input_4 = child(label_6);
33026
33035
  remove_input_defaults(input_4);
33027
33036
  var node_11 = sibling(input_4, 2);
@@ -33040,8 +33049,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
33040
33049
  reset(span_2);
33041
33050
  append($$anchor, span_2);
33042
33051
  };
33052
+ var alternate = ($$anchor) => {
33053
+ var span_3 = root_12();
33054
+ var text_4 = child(span_3, true);
33055
+ reset(span_3);
33056
+ template_effect(() => set_text(text_4, get$2(mode).name));
33057
+ append($$anchor, span_3);
33058
+ };
33043
33059
  if_block(node_11, ($$render) => {
33044
33060
  if (get$2(mode).icons.length > 0) $$render(consequent_3);
33061
+ else $$render(alternate, -1);
33045
33062
  });
33046
33063
  reset(label_6);
33047
33064
  template_effect(($0, $1, $2) => {
@@ -33052,7 +33069,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
33052
33069
  set_attribute(input_4, "aria-label", $2);
33053
33070
  }, [
33054
33071
  () => String(get$2(mode).id),
33055
- () => get$2(modes).length === 1 || String(get$2(mode).id) === String(field().value),
33072
+ () => field().value === String(get$2(mode).id),
33056
33073
  () => shop.t(`cart.paymentMode.ariaLabel.${get$2(mode).name.toLowerCase()}`)
33057
33074
  ]);
33058
33075
  delegated("change", input_4, () => {
@@ -33068,17 +33085,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
33068
33085
  append($$anchor, fieldset);
33069
33086
  };
33070
33087
  const radio = ($$anchor) => {
33071
- var fieldset_1 = root_15();
33088
+ var fieldset_1 = root_16();
33072
33089
  var legend_1 = child(fieldset_1);
33073
33090
  labelText(child(legend_1));
33074
33091
  reset(legend_1);
33075
33092
  var node_13 = sibling(legend_1, 2);
33076
33093
  var consequent_4 = ($$anchor) => {
33077
33094
  var fragment_9 = comment();
33078
- each(first_child(fragment_9), 17, () => field().options, index$1, ($$anchor, option) => {
33079
- var label_7 = root_14();
33080
- var text_4 = child(label_7);
33081
- var input_5 = sibling(text_4);
33095
+ each(first_child(fragment_9), 17, () => field().options(), (option) => option.value, ($$anchor, option) => {
33096
+ var label_7 = root_15();
33097
+ var text_5 = child(label_7);
33098
+ var input_5 = sibling(text_5);
33082
33099
  attribute_effect(input_5, () => ({
33083
33100
  ...get$2(fieldAttributes),
33084
33101
  ...restProps,
@@ -33088,8 +33105,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
33088
33105
  reset(label_7);
33089
33106
  template_effect(() => {
33090
33107
  set_class(label_7, 1, clsx(labelClass()));
33091
- set_attribute(label_7, "for", get$2(inputId) + get$2(option));
33092
- set_text(text_4, `${get$2(option) ?? ""} `);
33108
+ set_attribute(label_7, "for", get$2(inputId) + get$2(option).value);
33109
+ set_text(text_5, `${get$2(option).label ?? ""} `);
33093
33110
  });
33094
33111
  bind_value(input_5, () => field().value, ($$value) => field(field().value = $$value, true));
33095
33112
  append($$anchor, label_7);
@@ -33139,6 +33156,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
33139
33156
  }));
33140
33157
  let label = /* @__PURE__ */ user_derived(() => shop.t(field().label) || field().label);
33141
33158
  const CDN_PATH = `https://cdn.shop.platform.gomus.de/`;
33159
+ user_effect(() => {
33160
+ if (field().type !== "paymentMode") return;
33161
+ const modes = shop.payment_modes ? Object.values(shop.payment_modes) : [];
33162
+ if (modes.length === 1 && field().value === "") field(field().value = String(modes[0].id), true);
33163
+ });
33142
33164
  let filePreviewUrl = /* @__PURE__ */ state(null);
33143
33165
  user_effect(() => {
33144
33166
  const value = field().value;
@@ -35758,6 +35780,47 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
35758
35780
  type: "String"
35759
35781
  } }, [], []));
35760
35782
  //#endregion
35783
+ //#region src/components/membershipActivation/MembershipActivation.svelte
35784
+ function MembershipActivation($$anchor, $$props) {
35785
+ push($$props, true);
35786
+ let custom = prop($$props, "custom", 7, false);
35787
+ Forms.defineForm({
35788
+ id: "membershipActivation",
35789
+ submitLabel: "membership.activation.actions.submit",
35790
+ fields: [{
35791
+ key: "email",
35792
+ required: true
35793
+ }]
35794
+ });
35795
+ async function onSubmit(event) {
35796
+ const details = event.target.details;
35797
+ if ((await shop.activateMembership(details.formData)).response?.ok) $$props.$$host.dispatchEvent(new Event("go-success", {
35798
+ bubbles: true,
35799
+ composed: true
35800
+ }));
35801
+ else details.apiErrors = [shop.t("membership.activation.form.errors.requestFailed")];
35802
+ }
35803
+ wrapInElement($$props.$$host, "go-form", {
35804
+ "form-id": "membershipActivation",
35805
+ custom: custom()
35806
+ });
35807
+ $$props.$$host.addEventListener("submit", onSubmit);
35808
+ return pop({
35809
+ get custom() {
35810
+ return custom();
35811
+ },
35812
+ set custom($$value = false) {
35813
+ custom($$value);
35814
+ flushSync();
35815
+ }
35816
+ });
35817
+ }
35818
+ customElements.define("go-membership-activation", create_custom_element(MembershipActivation, { custom: {
35819
+ attribute: "custom",
35820
+ reflect: true,
35821
+ type: "Boolean"
35822
+ } }, [], []));
35823
+ //#endregion
35761
35824
  //#region src/components/order/lib/OrderDetails.svelte.ts
35762
35825
  var OrderDetails = class {
35763
35826
  #token = /* @__PURE__ */ state();
@@ -13544,6 +13544,7 @@ var TICKETS_ENDPOINT = "/api/v4/tickets";
13544
13544
  var SIGN_IN_ENDPOINT = "/api/v4/auth/sign_in";
13545
13545
  var SIGN_UP_ENDPOINT = "/api/v4/auth";
13546
13546
  var WITHDRAWAL_ENDPOINT = "/api/v4/orders/withdrawals";
13547
+ var MEMBERSHIP_ACTIVATION_ENDPOINT = "/api/v4/customer/memberships/activate";
13547
13548
  var ORDERS_ENDPOINT = "/api/v4/orders";
13548
13549
  //#endregion
13549
13550
  //#region ../../packages/gomus-api/lib/customerLevels.ts
@@ -13762,6 +13763,13 @@ var Shop = class {
13762
13763
  requiredFields: ["email"]
13763
13764
  });
13764
13765
  }
13766
+ activateMembership(params) {
13767
+ return this.apiPost(MEMBERSHIP_ACTIVATION_ENDPOINT, {
13768
+ body: params,
13769
+ requiredFields: ["email"],
13770
+ parseAs: "text"
13771
+ });
13772
+ }
13765
13773
  checkout(params) {
13766
13774
  return this.apiPost(`/api/v4/orders`, {
13767
13775
  body: params,
@@ -32812,10 +32820,11 @@ var select_content = /* @__PURE__ */ from_html(`<!>`, 1);
32812
32820
  var root_9$1 = /* @__PURE__ */ from_html(`<label><!></label> <select><!></select>`, 1);
32813
32821
  var root_10$1 = /* @__PURE__ */ from_html(`<img style="width: 60px" aria-hidden="true"/>`);
32814
32822
  var root_11 = /* @__PURE__ */ from_html(`<span class="go-payment-mode-icons"></span>`);
32815
- var root_12 = /* @__PURE__ */ from_html(`<label><input type="radio"/> <!></label>`);
32816
- var root_13 = /* @__PURE__ */ from_html(`<fieldset role="radiogroup"><legend><!></legend> <!></fieldset>`);
32817
- var root_14 = /* @__PURE__ */ from_html(`<label> <input/></label>`);
32818
- var root_15 = /* @__PURE__ */ from_html(`<fieldset><legend><!></legend> <!></fieldset>`);
32823
+ var root_12 = /* @__PURE__ */ from_html(`<span class="go-payment-mode-name"> </span>`);
32824
+ var root_13 = /* @__PURE__ */ from_html(`<label><input type="radio"/> <!></label>`);
32825
+ var root_14 = /* @__PURE__ */ from_html(`<fieldset role="radiogroup"><legend><!></legend> <!></fieldset>`);
32826
+ var root_15 = /* @__PURE__ */ from_html(`<label> <input/></label>`);
32827
+ var root_16 = /* @__PURE__ */ from_html(`<fieldset><legend><!></legend> <!></fieldset>`);
32819
32828
  function InputAndLabel($$anchor, $$props) {
32820
32829
  push($$props, true);
32821
32830
  const labelText = ($$anchor) => {
@@ -33015,12 +33024,12 @@ function InputAndLabel($$anchor, $$props) {
33015
33024
  };
33016
33025
  const paymentMode = ($$anchor) => {
33017
33026
  const modes = /* @__PURE__ */ user_derived(() => shop.payment_modes ? Object.values(shop.payment_modes) : []);
33018
- var fieldset = root_13();
33027
+ var fieldset = root_14();
33019
33028
  var legend = child(fieldset);
33020
33029
  labelText(child(legend));
33021
33030
  reset(legend);
33022
33031
  each(sibling(legend, 2), 17, () => get$2(modes), (mode) => mode.id, ($$anchor, mode) => {
33023
- var label_6 = root_12();
33032
+ var label_6 = root_13();
33024
33033
  var input_4 = child(label_6);
33025
33034
  remove_input_defaults(input_4);
33026
33035
  var node_11 = sibling(input_4, 2);
@@ -33039,8 +33048,16 @@ function InputAndLabel($$anchor, $$props) {
33039
33048
  reset(span_2);
33040
33049
  append($$anchor, span_2);
33041
33050
  };
33051
+ var alternate = ($$anchor) => {
33052
+ var span_3 = root_12();
33053
+ var text_4 = child(span_3, true);
33054
+ reset(span_3);
33055
+ template_effect(() => set_text(text_4, get$2(mode).name));
33056
+ append($$anchor, span_3);
33057
+ };
33042
33058
  if_block(node_11, ($$render) => {
33043
33059
  if (get$2(mode).icons.length > 0) $$render(consequent_3);
33060
+ else $$render(alternate, -1);
33044
33061
  });
33045
33062
  reset(label_6);
33046
33063
  template_effect(($0, $1, $2) => {
@@ -33051,7 +33068,7 @@ function InputAndLabel($$anchor, $$props) {
33051
33068
  set_attribute(input_4, "aria-label", $2);
33052
33069
  }, [
33053
33070
  () => String(get$2(mode).id),
33054
- () => get$2(modes).length === 1 || String(get$2(mode).id) === String(field().value),
33071
+ () => field().value === String(get$2(mode).id),
33055
33072
  () => shop.t(`cart.paymentMode.ariaLabel.${get$2(mode).name.toLowerCase()}`)
33056
33073
  ]);
33057
33074
  delegated("change", input_4, () => {
@@ -33067,17 +33084,17 @@ function InputAndLabel($$anchor, $$props) {
33067
33084
  append($$anchor, fieldset);
33068
33085
  };
33069
33086
  const radio = ($$anchor) => {
33070
- var fieldset_1 = root_15();
33087
+ var fieldset_1 = root_16();
33071
33088
  var legend_1 = child(fieldset_1);
33072
33089
  labelText(child(legend_1));
33073
33090
  reset(legend_1);
33074
33091
  var node_13 = sibling(legend_1, 2);
33075
33092
  var consequent_4 = ($$anchor) => {
33076
33093
  var fragment_9 = comment();
33077
- each(first_child(fragment_9), 17, () => field().options, index$1, ($$anchor, option) => {
33078
- var label_7 = root_14();
33079
- var text_4 = child(label_7);
33080
- var input_5 = sibling(text_4);
33094
+ each(first_child(fragment_9), 17, () => field().options(), (option) => option.value, ($$anchor, option) => {
33095
+ var label_7 = root_15();
33096
+ var text_5 = child(label_7);
33097
+ var input_5 = sibling(text_5);
33081
33098
  attribute_effect(input_5, () => ({
33082
33099
  ...get$2(fieldAttributes),
33083
33100
  ...restProps,
@@ -33087,8 +33104,8 @@ function InputAndLabel($$anchor, $$props) {
33087
33104
  reset(label_7);
33088
33105
  template_effect(() => {
33089
33106
  set_class(label_7, 1, clsx(labelClass()));
33090
- set_attribute(label_7, "for", get$2(inputId) + get$2(option));
33091
- set_text(text_4, `${get$2(option) ?? ""} `);
33107
+ set_attribute(label_7, "for", get$2(inputId) + get$2(option).value);
33108
+ set_text(text_5, `${get$2(option).label ?? ""} `);
33092
33109
  });
33093
33110
  bind_value(input_5, () => field().value, ($$value) => field(field().value = $$value, true));
33094
33111
  append($$anchor, label_7);
@@ -33138,6 +33155,11 @@ function InputAndLabel($$anchor, $$props) {
33138
33155
  }));
33139
33156
  let label = /* @__PURE__ */ user_derived(() => shop.t(field().label) || field().label);
33140
33157
  const CDN_PATH = `https://cdn.shop.platform.gomus.de/`;
33158
+ user_effect(() => {
33159
+ if (field().type !== "paymentMode") return;
33160
+ const modes = shop.payment_modes ? Object.values(shop.payment_modes) : [];
33161
+ if (modes.length === 1 && field().value === "") field(field().value = String(modes[0].id), true);
33162
+ });
33141
33163
  let filePreviewUrl = /* @__PURE__ */ state(null);
33142
33164
  user_effect(() => {
33143
33165
  const value = field().value;
@@ -35757,6 +35779,47 @@ customElements.define("go-link", create_custom_element(Link, { to: {
35757
35779
  type: "String"
35758
35780
  } }, [], []));
35759
35781
  //#endregion
35782
+ //#region src/components/membershipActivation/MembershipActivation.svelte
35783
+ function MembershipActivation($$anchor, $$props) {
35784
+ push($$props, true);
35785
+ let custom = prop($$props, "custom", 7, false);
35786
+ Forms.defineForm({
35787
+ id: "membershipActivation",
35788
+ submitLabel: "membership.activation.actions.submit",
35789
+ fields: [{
35790
+ key: "email",
35791
+ required: true
35792
+ }]
35793
+ });
35794
+ async function onSubmit(event) {
35795
+ const details = event.target.details;
35796
+ if ((await shop.activateMembership(details.formData)).response?.ok) $$props.$$host.dispatchEvent(new Event("go-success", {
35797
+ bubbles: true,
35798
+ composed: true
35799
+ }));
35800
+ else details.apiErrors = [shop.t("membership.activation.form.errors.requestFailed")];
35801
+ }
35802
+ wrapInElement($$props.$$host, "go-form", {
35803
+ "form-id": "membershipActivation",
35804
+ custom: custom()
35805
+ });
35806
+ $$props.$$host.addEventListener("submit", onSubmit);
35807
+ return pop({
35808
+ get custom() {
35809
+ return custom();
35810
+ },
35811
+ set custom($$value = false) {
35812
+ custom($$value);
35813
+ flushSync();
35814
+ }
35815
+ });
35816
+ }
35817
+ customElements.define("go-membership-activation", create_custom_element(MembershipActivation, { custom: {
35818
+ attribute: "custom",
35819
+ reflect: true,
35820
+ type: "Boolean"
35821
+ } }, [], []));
35822
+ //#endregion
35760
35823
  //#region src/components/order/lib/OrderDetails.svelte.ts
35761
35824
  var OrderDetails = class {
35762
35825
  #token = /* @__PURE__ */ state();