@useinsider/guido 2.1.0-beta.a67f307 → 2.1.0-beta.a873eb7

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.
Files changed (21) hide show
  1. package/dist/@types/config/schemas.js +1 -1
  2. package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +11 -13
  3. package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +54 -23
  4. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +3 -3
  5. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +34 -21
  6. package/dist/components/organisms/extensions/recommendation/Filters.vue.js +11 -11
  7. package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +44 -34
  8. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +58 -39
  9. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +93 -57
  10. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +8 -8
  11. package/dist/extensions/Blocks/Recommendation/validation/filterSchema.js +29 -0
  12. package/dist/guido.css +1 -1
  13. package/dist/services/stripoApi.js +20 -17
  14. package/dist/src/components/organisms/extensions/recommendation/FilterItem.vue.d.ts +1 -0
  15. package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +15 -1
  16. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -0
  17. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +18 -2
  18. package/dist/src/extensions/Blocks/Recommendation/validation/filterSchema.d.ts +15 -0
  19. package/dist/static/templates/empty/index.html.js +74 -0
  20. package/dist/static/templates/empty/style.css.js +779 -0
  21. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  import { ModuleFolderDefaults as b } from "../../enums/defaults.js";
2
- import { object as o, number as p, optional as e, string as t, pipe as u, picklist as n, custom as S, boolean as a, array as c, minLength as d, literal as r, variant as k } from "../../node_modules/valibot/dist/index.js";
2
+ import { object as o, number as p, optional as e, string as t, pipe as u, picklist as n, minLength as d, custom as S, boolean as a, array as c, literal as r, variant as k } from "../../node_modules/valibot/dist/index.js";
3
3
  const m = {
4
4
  /** Promotional/marketing emails */
5
5
  PROMOTIONAL: 1,
@@ -1,28 +1,26 @@
1
1
  import r from "./FilterItem.vue2.js";
2
2
  /* empty css */
3
- import i from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
- var l = function() {
3
+ import l from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var i = function() {
5
5
  var a = this, e = a._self._c, t = a._self._setupProxy;
6
- return e("div", { staticClass: "d-f f-d-c w-1 gap-16" }, [e("div", { staticClass: "d-f a-i-c j-c-s-b pt-4", class: { "bor-t-s-s bor-t-w-1 bor-t-c-50": a.index === 0 } }, [e("p", [a._v(" " + a._s(t.trans("newsletter.filter")) + " " + a._s(a.index + 1) + " ")]), e(t.InButtonV2, { attrs: { id: "guido__delete-filter-group-button", "left-icon": "line-delete", styling: "text", type: "danger", "label-text-status": !1 }, on: { click: function(s) {
6
+ return e("div", { staticClass: "d-f f-d-c w-1 gap-16", attrs: { "data-filter-group": a.filter.filterGroup, "data-filter-number": a.filter.filterNumber } }, [e("div", { staticClass: "d-f a-i-c j-c-s-b pt-4", class: { "bor-t-s-s bor-t-w-1 bor-t-c-50": a.index === 0 } }, [e("p", [a._v(" " + a._s(t.trans("newsletter.filter")) + " " + a._s(a.index + 1) + " ")]), e(t.InButtonV2, { attrs: { id: "guido__delete-filter-group-button", "left-icon": "line-delete", styling: "text", type: "danger", "label-text-status": !1 }, on: { click: function(s) {
7
7
  return t.emit("delete-filter", t.props.filter);
8
- } } })], 1), e("div", { staticClass: "w-1 d-f a-i-s j-c-s-b gap-16" }, [e(t.InSelect, { staticClass: "w-2", attrs: { "disabled-status": "", "search-status": "", "button-status": !1, "label-text": t.trans("action-builder.filter-type"), options: t.filterTypeOptions, value: [t.filterTypeOptions[0]] } }), e(t.InSelect, { staticClass: "w-2", attrs: { id: "filter-item-input--attribute-type", "search-status": "", "static-position": "bottom right", "button-status": !1, "label-text": t.trans("condition.attribute"), options: t.store.getFilterList, value: [t.selectedAttributeType] }, on: { select: function(s) {
9
- return t.updateFilter({ text: "attribute", value: s.value });
10
- } } })], 1), e("div", { staticClass: "w-1 d-f a-i-s j-c-s-b gap-16" }, [e(t.InSelect, { staticClass: "w-2", attrs: { "button-status": !1, "label-text": t.trans("condition.operator"), options: t.getOperatorOptions(t.selectedAttributeType.type), value: [t.selectedOperatorType] }, on: { select: function(s) {
8
+ } } })], 1), e("div", { staticClass: "w-1 d-f a-i-s j-c-s-b gap-16" }, [e(t.InSelect, { staticClass: "w-2", attrs: { "disabled-status": "", "search-status": "", "button-status": !1, "label-text": t.trans("action-builder.filter-type"), options: t.filterTypeOptions, value: [t.filterTypeOptions[0]] } }), e(t.InSelect, { staticClass: "w-2", attrs: { id: "filter-item-input--attribute-type", "search-status": "", "static-position": "bottom right", "button-status": !1, "label-text": t.trans("condition.attribute"), options: t.store.getFilterList, state: t.getFieldState("attribute"), value: [t.selectedAttributeType] }, on: { select: t.handleAttributeChange } })], 1), e("div", { staticClass: "w-1 d-f a-i-s j-c-s-b gap-16" }, [t.isBooleanAttribute ? e(t.InSelect, { staticClass: "w-2", attrs: { "button-status": !1, "label-text": t.trans("condition.operator"), options: t.booleanValueOptions, state: t.getFieldState("value"), value: [t.selectedBooleanValue] }, on: { select: t.handleBooleanValueChange } }) : [e(t.InSelect, { staticClass: "w-2", attrs: { "button-status": !1, "label-text": t.trans("condition.operator"), options: t.getOperatorOptions(t.selectedAttributeType.type), state: t.getFieldState("operator"), value: [t.selectedOperatorType] }, on: { select: function(s) {
11
9
  return t.updateFilter({ text: "operator", value: s.value });
12
- } } }), e(t.InBasicTextInput, { staticClass: "w-2", attrs: { id: "filter-item-input--value", name: "imageUrl", type: "text", "character-counter-status": !1, "label-text": t.trans("condition.value"), "max-character-length": 25, "placeholder-text": t.trans("condition.enter-value-placeholder"), "tooltip-status": !1, value: decodeURIComponent(t.props.filter.value) }, on: { input: function(s) {
10
+ } } }), e(t.InBasicTextInput, { staticClass: "w-2", attrs: { id: "filter-item-input--value", name: "imageUrl", "character-counter-status": !1, "label-text": t.trans("condition.value"), "max-character-length": 25, "placeholder-text": t.trans("condition.enter-value-placeholder"), "state-message": t.valueErrorMessage, states: t.getFieldState("value"), "tooltip-status": !1, type: t.valueInputType, value: decodeURIComponent(t.props.filter.value) }, on: { input: function(s) {
13
11
  t.updateFilter({ text: "value", value: encodeURIComponent(s) });
14
- } } })], 1), t.props.hasLogicAdapter ? e("div", { staticClass: "w-1 d-f a-i-c j-c-c p-r bor-b-s-s bor-b-w-1 bor-b-c-50 mt-4" }, [e(t.LogicAdapter, { staticClass: "p-a", attrs: { logic: t.props.filter.innerGroupOperator }, on: { change: function(s) {
12
+ } } })]], 2), t.props.hasLogicAdapter ? e("div", { staticClass: "w-1 d-f a-i-c j-c-c p-r bor-b-s-s bor-b-w-1 bor-b-c-50 mt-4" }, [e(t.LogicAdapter, { staticClass: "p-a", attrs: { logic: t.props.filter.innerGroupOperator }, on: { change: function(s) {
15
13
  return t.updateFilter({ text: "innerGroupOperator", value: s });
16
14
  } } })], 1) : a._e()]);
17
- }, n = [], o = /* @__PURE__ */ i(
15
+ }, o = [], n = /* @__PURE__ */ l(
18
16
  r,
19
- l,
20
- n,
17
+ i,
18
+ o,
21
19
  !1,
22
20
  null,
23
- "6562e38c"
21
+ "3b53a736"
24
22
  );
25
- const f = o.exports;
23
+ const f = n.exports;
26
24
  export {
27
25
  f as default
28
26
  };
@@ -1,38 +1,69 @@
1
- import { defineComponent as f, computed as i } from "vue";
2
- import { useTranslations as v } from "../../../../composables/useTranslations.js";
3
- import { getOperatorOptions as a } from "../../../../enums/extensions/recommendationBlock.js";
4
- import { useRecommendationExtensionStore as x } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { InButtonV2 as y, InSelect as F, InBasicTextInput as T } from "@useinsider/design-system-vue";
6
- import _ from "./LogicAdapter.vue.js";
7
- import { useDebounceFn as b } from "../../../../node_modules/@vueuse/shared/index.js";
8
- const h = /* @__PURE__ */ f({
1
+ import { defineComponent as _, computed as l } from "vue";
2
+ import { useTranslations as C } from "../../../../composables/useTranslations.js";
3
+ import { getOperatorOptions as p } from "../../../../enums/extensions/recommendationBlock.js";
4
+ import { useRecommendationExtensionStore as V } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { getInvalidFilterFields as A } from "../../../../extensions/Blocks/Recommendation/validation/filterSchema.js";
6
+ import { InButtonV2 as L, InSelect as O, InBasicTextInput as S } from "@useinsider/design-system-vue";
7
+ import E from "./LogicAdapter.vue.js";
8
+ import { useDebounceFn as N } from "../../../../node_modules/@vueuse/shared/index.js";
9
+ const K = /* @__PURE__ */ _({
9
10
  __name: "FilterItem",
10
11
  props: {
11
12
  filter: null,
12
13
  index: null,
13
- hasLogicAdapter: { type: Boolean }
14
+ hasLogicAdapter: { type: Boolean },
15
+ submitted: { type: Boolean }
14
16
  },
15
17
  emits: ["delete-filter"],
16
- setup(p, { emit: u }) {
17
- const e = p, n = v(), r = x(), m = [
18
+ setup(f, { emit: v }) {
19
+ const t = f, n = C(), a = V(), y = [
18
20
  {
19
21
  text: n("email-editor.standard-filter"),
20
22
  value: "standardFilter"
21
23
  }
22
- ], s = i(() => e.filter.attribute || ""), l = i(() => r.getFilterList.find((t) => t.value === s.value) || { text: "", value: "", type: "" }), c = i(() => {
23
- var t;
24
- return a((t = l.value) == null ? void 0 : t.type).find((o) => o.value === e.filter.operator);
25
- }), d = b((t) => {
26
- console.debug("updateFilter: ", t);
27
- const o = {
28
- ...e.filter,
29
- [t.text]: t.value
30
- };
31
- r.updateFilter(o);
24
+ ], i = [
25
+ { text: "True", value: "true" },
26
+ { text: "False", value: "false" }
27
+ ], d = l(() => t.filter.attribute || ""), r = l(() => a.getFilterList.find((e) => e.value === d.value) || { text: "", value: "", type: "" }), F = l(
28
+ () => {
29
+ var e;
30
+ return ((e = r.value) == null ? void 0 : e.type) === "Boolean";
31
+ }
32
+ ), b = l(() => {
33
+ var e;
34
+ return p((e = r.value) == null ? void 0 : e.type).find((o) => o.value === t.filter.operator);
35
+ }), g = l(
36
+ () => i.find((e) => e.value === t.filter.value) || i[0]
37
+ ), u = l(() => t.submitted ? A(t.filter) : /* @__PURE__ */ new Set()), h = (e) => u.value.has(e) ? "error" : "default", B = l(
38
+ () => u.value.has("value") ? n("action-builder.filter-empty-value-error") : ""
39
+ ), c = l(
40
+ () => {
41
+ var e;
42
+ return ((e = r.value) == null ? void 0 : e.type) === "Number";
43
+ }
44
+ ), x = l(() => c.value ? "number" : "text"), T = N((e) => {
45
+ a.updateFilter({
46
+ ...t.filter,
47
+ [e.text]: e.value
48
+ });
32
49
  }, 500);
33
- return { __sfc: !0, trans: n, store: r, props: e, filterTypeOptions: m, attributeType: s, selectedAttributeType: l, selectedOperatorType: c, emit: u, updateFilter: d, getOperatorOptions: a, InBasicTextInput: T, InSelect: F, InButtonV2: y, LogicAdapter: _ };
50
+ return { __sfc: !0, trans: n, store: a, props: t, filterTypeOptions: y, booleanValueOptions: i, attributeType: d, selectedAttributeType: r, isBooleanAttribute: F, selectedOperatorType: b, selectedBooleanValue: g, emit: v, invalidFields: u, getFieldState: h, valueErrorMessage: B, isNumericAttribute: c, valueInputType: x, updateFilter: T, handleAttributeChange: (e) => {
51
+ const o = a.getFilterList.find((I) => I.value === e.value), m = (o == null ? void 0 : o.type) === "Boolean", [s] = p(o == null ? void 0 : o.type);
52
+ a.updateFilter({
53
+ ...t.filter,
54
+ attribute: e.value,
55
+ operator: m ? "=" : (s == null ? void 0 : s.value) ?? "",
56
+ value: m ? "true" : ""
57
+ });
58
+ }, handleBooleanValueChange: (e) => {
59
+ a.updateFilter({
60
+ ...t.filter,
61
+ operator: "=",
62
+ value: e.value
63
+ });
64
+ }, getOperatorOptions: p, InBasicTextInput: S, InSelect: O, InButtonV2: L, LogicAdapter: E };
34
65
  }
35
66
  });
36
67
  export {
37
- h as default
68
+ K as default
38
69
  };
@@ -1,11 +1,11 @@
1
1
  import o from "./FilterSelectionDrawer.vue2.js";
2
2
  import n from "../../../../_virtual/_plugin-vue2_normalizer.js";
3
- var l = function() {
3
+ var i = function() {
4
4
  var e = this, r = e._self._c, t = e._self._setupProxy;
5
- return r(t.WpDrawer, { attrs: { id: "recommendation-filter-drawer", "title-text": "Filter Selection", "footer-button-group-options": t.footerButtonGroupOptions, status: t.store.filterSelectionDrawerStatus }, on: { cancelOrBackButtonEvent: t.closeModal, onCloseEvent: t.closeModal, primaryButtonEvent: t.applyFilter } }, [r(t.Filters)], 1);
5
+ return r(t.WpDrawer, { attrs: { id: "recommendation-filter-drawer", "description-status": "", "description-text": t.trans("email-editor.filter-description"), "footer-button-group-options": t.footerButtonGroupOptions, status: t.store.filterSelectionDrawerStatus, "title-text": t.trans("email-editor.add-filters") }, on: { cancelOrBackButtonEvent: t.cancelModal, onCloseEvent: t.cancelModal, primaryButtonEvent: t.applyFilter } }, [t.store.filterSelectionDrawerStatus ? r(t.Filters, { ref: "filtersRef", attrs: { submitted: t.submitted } }) : e._e()], 1);
6
6
  }, s = [], a = /* @__PURE__ */ n(
7
7
  o,
8
- l,
8
+ i,
9
9
  s,
10
10
  !1,
11
11
  null,
@@ -1,38 +1,51 @@
1
- import { defineComponent as n, ref as a, computed as l } from "vue";
2
- import i from "../../../wrappers/WpDrawer.vue.js";
3
- import { useTranslations as c } from "../../../../composables/useTranslations.js";
4
- import { useRecommendationExtensionStore as p } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import u from "./Filters.vue.js";
6
- const v = /* @__PURE__ */ n({
1
+ import { defineComponent as d, ref as a, watch as y, computed as g, nextTick as v } from "vue";
2
+ import b from "../../../wrappers/WpDrawer.vue.js";
3
+ import { useTranslations as w } from "../../../../composables/useTranslations.js";
4
+ import { useRecommendationExtensionStore as F } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { isFilterValid as _ } from "../../../../extensions/Blocks/Recommendation/validation/filterSchema.js";
6
+ import h from "./Filters.vue.js";
7
+ const I = /* @__PURE__ */ d({
7
8
  __name: "FilterSelectionDrawer",
8
- setup(f) {
9
- const r = c(), t = p(), e = a(!1), s = l(() => ({
9
+ setup(S) {
10
+ const r = w(), e = F(), t = a(!1), o = a(!1), c = a();
11
+ y(() => e.filterSelectionDrawerStatus, (n) => {
12
+ n && (o.value = !1);
13
+ });
14
+ const f = g(() => ({
10
15
  primaryButton: {
11
16
  styling: "solid",
12
17
  type: "primary",
13
18
  labelText: r(
14
- e.value ? "unsubscription-preference.selecting-type" : "products.select-and-continue"
19
+ t.value ? "unsubscription-preference.selecting-type" : "products.select-and-continue"
15
20
  ),
16
- loadingStatus: e.value,
17
- disabledStatus: !1
21
+ loadingStatus: t.value
18
22
  },
19
23
  cancelOrBackButton: {
20
24
  styling: "ghost",
21
25
  type: "secondary",
22
26
  labelText: r("products.cancel"),
23
- disabledStatus: e.value
27
+ disabledStatus: t.value
24
28
  }
25
- })), o = () => {
26
- t.closeFilterDrawer();
27
- };
28
- return { __sfc: !0, trans: r, store: t, isApplying: e, footerButtonGroupOptions: s, closeModal: o, applyFilter: () => {
29
- e.value = !0, t.patchCurrentBlockConfig(
30
- { filters: t.recommendationConfigs.filters },
29
+ }));
30
+ return { __sfc: !0, trans: r, store: e, isApplying: t, submitted: o, filtersRef: c, footerButtonGroupOptions: f, cancelModal: () => {
31
+ e.cancelFilterDrawer();
32
+ }, applyFilter: async () => {
33
+ var u;
34
+ o.value = !0;
35
+ const { filters: n } = e.recommendationConfigs, i = n.find((l) => !_(l));
36
+ if (i) {
37
+ (u = c.value) == null || u.switchToGroup(i.filterGroup), await v();
38
+ const { filterGroup: l, filterNumber: p } = i, m = `[data-filter-group="${l}"][data-filter-number="${p}"]`, s = document.querySelector(m);
39
+ s == null || s.scrollIntoView({ behavior: "smooth", block: "center" });
40
+ return;
41
+ }
42
+ t.value = !0, e.patchCurrentBlockConfig(
43
+ { filters: e.recommendationConfigs.filters },
31
44
  { triggerRefetch: !0 }
32
- ), o(), e.value = !1;
33
- }, WpDrawer: i, Filters: u };
45
+ ), e.closeFilterDrawer(), t.value = !1;
46
+ }, WpDrawer: b, Filters: h };
34
47
  }
35
48
  });
36
49
  export {
37
- v as default
50
+ I as default
38
51
  };
@@ -1,20 +1,20 @@
1
1
  import s from "./Filters.vue2.js";
2
2
  /* empty css */
3
- import a from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
- var o = function() {
5
- var i = this, e = i._self._c, t = i._self._setupProxy;
6
- return e("div", { staticClass: "d-f f-d-c gap-16" }, [e("div", { staticClass: "d-f a-i-c j-c-s-b gap-16" }, [e(t.InSegments, { staticClass: "f-g-1 w-1", attrs: { id: "guido__filter-group-segments", "segment-list": t.filterGroupList, selected: t.selectedFilterGroup, "with-icon": !1 }, on: { click: t.changeFilterGroup } }), e(t.InButtonV2, { staticClass: "w-20-s f-g-1", attrs: { id: "guido__add-filter-group-button", "left-icon": "line-plus-netural", type: "secondary", "disabled-status": t.isMaxFilterGroupCount, "label-text": t.trans("smart-recommender.add-filter-group"), "tooltip-text": t.isMaxFilterGroupCount ? t.trans("email-editor.add-filter-tooltip") : "" }, on: { click: t.handleAddFilterGroup } })], 1), e("div", { staticClass: "d-f a-i-c j-c-s-b gap-16" }, [e("div", { staticClass: "d-f a-i-c" }, [t.selectedFilterGroup > 1 ? e(t.LogicAdapter, { staticClass: "mr-2" }) : i._e(), e("p", [i._v(" " + i._s(t.trans("email-editor.filter-group")) + " " + i._s(t.selectedFilterGroup) + " ")])], 1), t.hasRemoveFilterButton ? e(t.InButtonV2, { attrs: { id: "guido__delete-filter-group-button", "left-icon": "line-delete", styling: "text", type: "danger", "label-text-status": !1 }, on: { click: t.handleDeleteFilterGroup } }) : i._e()], 1), e("div", { staticClass: "d-f a-i-c j-c-s-b f-d-c" }, i._l(t.selectedFilterGroupFilters, function(l, r) {
7
- return e(t.FilterItem, { key: r, attrs: { filter: l, "has-logic-adapter": t.hasLogicAdapter && r !== t.selectedFilterGroupFilters.length - 1, index: r }, on: { "delete-filter": t.handleDeleteFilter } });
8
- }), 1), e("div", { staticClass: "d-f a-i-c j-c-c mt-3" }, [e(t.InButtonV2, { staticClass: "w-11-s", attrs: { id: "filter-group--add-filter-button", "left-icon": "line-plus-netural", type: "subtle-primary", "label-text": t.trans("smart-recommender.add-filter-condition") }, on: { click: t.handleAddFilter } })], 1)]);
9
- }, d = [], n = /* @__PURE__ */ a(
3
+ import o from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var a = function() {
5
+ var r = this, e = r._self._c, t = r._self._setupProxy;
6
+ return e("div", { staticClass: "d-f f-d-c gap-16" }, [e("div", { staticClass: "d-f a-i-c j-c-s-b gap-16" }, [e(t.InSegments, { staticClass: "f-g-1 w-1", attrs: { id: "guido__filter-group-segments", "segment-list": t.filterGroupList, selected: t.selectedFilterGroup, "with-icon": !1 }, on: { click: t.switchToGroup } }), e(t.InButtonV2, { staticClass: "w-20-s f-g-1", attrs: { id: "guido__add-filter-group-button", "left-icon": "line-plus-netural", type: "secondary", "disabled-status": t.isMaxFilterGroupCount, "label-text": t.trans("smart-recommender.add-filter-group"), "tooltip-options": t.getTooltipOptions("add-filter-group-tooltip"), "tooltip-text": t.isMaxFilterGroupCount ? t.trans("email-editor.add-filter-group-tooltip") : "" }, on: { click: t.handleAddFilterGroup } })], 1), e("div", { staticClass: "d-f a-i-c j-c-s-b gap-16" }, [e("div", { staticClass: "d-f a-i-c" }, [t.selectedFilterGroup > 1 ? e(t.LogicAdapter, { staticClass: "mr-2", attrs: { logic: t.outerGroupOperator }, on: { change: t.handleOuterGroupOperatorChange } }) : r._e(), e("p", [r._v(" " + r._s(t.trans("email-editor.filter-group")) + " " + r._s(t.selectedFilterGroup) + " ")])], 1), t.hasRemoveFilterButton ? e(t.InButtonV2, { attrs: { id: "guido__delete-filter-group-button", "left-icon": "line-delete", styling: "text", type: "danger", "label-text-status": !1 }, on: { click: t.handleDeleteFilterGroup } }) : r._e()], 1), e("div", { staticClass: "d-f a-i-c j-c-s-b f-d-c" }, r._l(t.selectedFilterGroupFilters, function(l, i) {
7
+ return e(t.FilterItem, { key: i, attrs: { filter: l, "has-logic-adapter": t.hasLogicAdapter && i !== t.selectedFilterGroupFilters.length - 1, index: i, submitted: r.submitted }, on: { "delete-filter": t.handleDeleteFilter } });
8
+ }), 1), e("div", { staticClass: "d-f a-i-c j-c-c mt-3" }, [e(t.InButtonV2, { staticClass: "w-11-s", attrs: { id: "filter-group--add-filter-button", "left-icon": "line-plus-netural", type: "subtle-primary", "disabled-status": t.isMaxFilterPerGroupCount, "label-text": t.trans("smart-recommender.add-filter-condition"), "tooltip-text": t.isMaxFilterPerGroupCount ? t.trans("email-editor.add-filter-tooltip") : "" }, on: { click: t.handleAddFilter } })], 1)]);
9
+ }, d = [], n = /* @__PURE__ */ o(
10
10
  s,
11
- o,
11
+ a,
12
12
  d,
13
13
  !1,
14
14
  null,
15
- "1ccb6d4a"
15
+ "c5dee797"
16
16
  );
17
- const _ = n.exports;
17
+ const g = n.exports;
18
18
  export {
19
- _ as default
19
+ g as default
20
20
  };
@@ -1,44 +1,54 @@
1
- import { defineComponent as m, computed as o, ref as h } from "vue";
2
- import { useTranslations as G } from "../../../../composables/useTranslations.js";
1
+ import { defineComponent as h, computed as l, ref as O, watch as v } from "vue";
2
+ import { useTranslations as f } from "../../../../composables/useTranslations.js";
3
3
  import { useRecommendationExtensionStore as g } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
4
- import { InButtonV2 as v, InSegments as f } from "@useinsider/design-system-vue";
5
- import _ from "./FilterItem.vue.js";
4
+ import { getTooltipOptions as R } from "../../../../utils/tooltipUtils.js";
5
+ import { InButtonV2 as T, InSegments as U } from "@useinsider/design-system-vue";
6
+ import E from "./FilterItem.vue.js";
6
7
  import A from "./LogicAdapter.vue.js";
7
- const E = /* @__PURE__ */ m({
8
+ const y = /* @__PURE__ */ h({
8
9
  __name: "Filters",
9
- setup(R) {
10
- const i = G(), l = g(), u = o(() => l.getFilterGroupCount), t = o(() => Array.from({ length: u.value }, (e, a) => ({
11
- text: (a + 1).toString(),
12
- value: a + 1
13
- }))), r = h(1), s = (e) => {
10
+ props: {
11
+ submitted: { type: Boolean }
12
+ },
13
+ setup(C, { expose: a }) {
14
+ const i = f(), t = g(), u = l(() => t.getUniqueFilterGroups.map((e) => ({
15
+ text: e.toString(),
16
+ value: e
17
+ }))), r = O(1);
18
+ v(u, (e) => {
19
+ if (!e.length)
20
+ return;
21
+ e.some((G) => G.value === r.value) || (r.value = e[0].value);
22
+ });
23
+ const s = (e) => {
14
24
  r.value = e;
15
- }, d = () => {
16
- const e = t.value.length + 1;
17
- console.debug("handleAddFilterGroup", e), t.value.push({
18
- text: e.toString(),
19
- value: e
20
- }), l.addFilterGroup(e);
21
- }, p = o(() => t.value.length >= 3), n = o(() => l.getSelectedFilterGroup(r.value)), c = o(() => n.value.length > 1), F = o(() => t.value.length > 1);
22
- return { __sfc: !0, MAX_FILTER_GROUP_COUNT: 3, trans: i, store: l, filterGroupCount: u, filterGroupList: t, selectedFilterGroup: r, changeFilterGroup: s, handleAddFilterGroup: d, isMaxFilterGroupCount: p, selectedFilterGroupFilters: n, hasLogicAdapter: c, hasRemoveFilterButton: F, handleAddFilter: () => {
23
- l.addFilter({
24
- type: "standardFilter",
25
- attribute: "",
26
- operatorReplace: "",
27
- operator: "",
28
- innerGroupOperator: "*",
29
- outerGroupOperator: "*",
30
- filterNumber: n.value.length + 1,
31
- filterGroup: r.value,
32
- isValid: !1,
33
- value: ""
34
- }), console.debug("handleAddFilter");
25
+ };
26
+ a({ switchToGroup: s });
27
+ const p = () => {
28
+ const e = t.getUniqueFilterGroups, o = e.length > 0 ? Math.max(...e) + 1 : 1;
29
+ t.addFilterGroup(o), r.value = o;
30
+ }, c = l(() => u.value.length >= 3), n = l(() => t.getSelectedFilterGroup(r.value)), d = l(() => n.value.length >= 10), F = l(() => n.value.length > 1), _ = l(() => u.value.length > 1), m = l(() => {
31
+ var o;
32
+ return ((o = n.value[0]) == null ? void 0 : o.outerGroupOperator) || "*";
33
+ });
34
+ return { __sfc: !0, MAX_FILTER_GROUP_COUNT: 3, MAX_FILTER_PER_GROUP_COUNT: 10, trans: i, store: t, filterGroupList: u, selectedFilterGroup: r, switchToGroup: s, handleAddFilterGroup: p, isMaxFilterGroupCount: c, selectedFilterGroupFilters: n, isMaxFilterPerGroupCount: d, hasLogicAdapter: F, hasRemoveFilterButton: _, outerGroupOperator: m, handleOuterGroupOperatorChange: (e) => {
35
+ n.value.forEach((o) => {
36
+ t.updateFilter({ ...o, outerGroupOperator: e });
37
+ });
38
+ }, handleAddFilter: () => {
39
+ t.addFilter(
40
+ t.createDefaultFilter(
41
+ r.value,
42
+ n.value.length + 1
43
+ )
44
+ );
35
45
  }, handleDeleteFilter: (e) => {
36
- console.debug("handleDeleteFilter: ", e), l.deleteFilter(e);
46
+ t.deleteFilter(e);
37
47
  }, handleDeleteFilterGroup: () => {
38
- t.value.length !== 1 && (console.debug("handleDeleteFilterGroup"), t.value.splice(r.value - 1, 1), r.value > 1 && r.value--);
39
- }, InSegments: f, InButtonV2: v, FilterItem: _, LogicAdapter: A };
48
+ u.value.length <= 1 || t.deleteFilterGroup(r.value);
49
+ }, getTooltipOptions: R, InSegments: U, InButtonV2: T, FilterItem: E, LogicAdapter: A };
40
50
  }
41
51
  });
42
52
  export {
43
- E as default
53
+ y as default
44
54
  };
@@ -1,8 +1,8 @@
1
- var d = Object.defineProperty;
2
- var m = (c, s, t) => s in c ? d(c, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[s] = t;
3
- var n = (c, s, t) => m(c, typeof s != "symbol" ? s + "" : s, t);
4
- import { CommonControl as h } from "../../../common-control.js";
5
- import { RecommendationConfigService as f } from "../../services/configService.js";
1
+ var m = Object.defineProperty;
2
+ var h = (c, s, t) => s in c ? m(c, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[s] = t;
3
+ var n = (c, s, t) => h(c, typeof s != "symbol" ? s + "" : s, t);
4
+ import { CommonControl as f } from "../../../common-control.js";
5
+ import { RecommendationConfigService as l } from "../../services/configService.js";
6
6
  import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
7
7
  import { AlgorithmControl as p } from "./algorithm.js";
8
8
  import { ALGORITHM_CONTROL_ID as W } from "./algorithm.js";
@@ -10,17 +10,17 @@ import { CurrencyControl as g } from "./currency.js";
10
10
  import { CURRENCY_CONTROL_ID as H } from "./currency.js";
11
11
  import { FiltersControl as R } from "./filters.js";
12
12
  import { FILTERS_CONTROL_ID as j } from "./filters.js";
13
- import { LocaleControl as y } from "./locale.js";
13
+ import { LocaleControl as N } from "./locale.js";
14
14
  import { LOCALE_CONTROL_ID as K } from "./locale.js";
15
- import { ProductLayoutControl as _ } from "./productLayout.js";
15
+ import { ProductLayoutControl as y } from "./productLayout.js";
16
16
  import { PRODUCT_LAYOUT_CONTROL_ID as J } from "./productLayout.js";
17
- import { ShuffleControl as N } from "./shuffle.js";
17
+ import { ShuffleControl as _ } from "./shuffle.js";
18
18
  import { SHUFFLE_CONTROL_ID as X } from "./shuffle.js";
19
- import { regenerateProductRowsWithStyles as b, getBlockElement as P, updateProductContentInPlace as I } from "./utils.js";
20
- import { formatProductPrice as tt, getCardComposition as et, getCurrentLayout as ot, reapplySpacing as rt, regenerateMobileProductRows as nt, regenerateProductRows as it, setCurrencyAttributes as st, updatePricesInPlace as ct, updateSingleProductContent as at } from "./utils.js";
21
- import { useDebounceFn as l } from "../../../../../node_modules/@vueuse/shared/index.js";
19
+ import { regenerateProductRowsWithStyles as b, getBlockElement as I, updateProductContentInPlace as P } from "./utils.js";
20
+ import { formatProductPrice as tt, getCardComposition as et, getCurrentLayout as ot, reapplySpacing as rt, regenerateMobileProductRows as it, regenerateProductRows as nt, setCurrencyAttributes as st, updatePricesInPlace as ct, updateSingleProductContent as at } from "./utils.js";
21
+ import { useDebounceFn as u } from "../../../../../node_modules/@vueuse/shared/index.js";
22
22
  const T = "recommendation-id", S = "ui-elements-recommendation-block";
23
- class $ extends h {
23
+ class z extends f {
24
24
  constructor() {
25
25
  super(...arguments);
26
26
  n(this, "store", C());
@@ -36,19 +36,19 @@ class $ extends h {
36
36
  /**
37
37
  * Debounced product fetch to prevent rapid API calls during config changes
38
38
  */
39
- n(this, "_debouncedFetchProducts", l(() => {
39
+ n(this, "_debouncedFetchProducts", u(() => {
40
40
  this.store.fetchRecommendationProducts();
41
41
  }, 500));
42
42
  /**
43
43
  * Debounced regeneration when products arrive from API
44
44
  * Tries in-place update first to preserve styles, falls back to full regeneration
45
45
  */
46
- n(this, "_debouncedRegenerateWithProducts", l(() => {
46
+ n(this, "_debouncedRegenerateWithProducts", u(() => {
47
47
  const t = this.store.recommendationProducts;
48
48
  if (!this.currentNode || !this.api)
49
49
  return;
50
50
  const e = this.api.getDocumentModifier();
51
- I({
51
+ P({
52
52
  currentNode: this.currentNode,
53
53
  documentModifier: e,
54
54
  products: t
@@ -59,7 +59,7 @@ class $ extends h {
59
59
  return S;
60
60
  }
61
61
  getTemplate() {
62
- return this.algorithmControl = new p(), this.localeControl = new y(), this.currencyControl = new g(), this.productLayoutControl = new _(), this.filtersControl = new R(), this.shuffleControl = new N(), `
62
+ return this.algorithmControl = new p(), this.localeControl = new N(), this.currencyControl = new g(), this.productLayoutControl = new y(), this.filtersControl = new R(), this.shuffleControl = new _(), `
63
63
  <div class="recommendation-controls-container">
64
64
  ${this.algorithmControl.getTemplate()}
65
65
  ${this.localeControl.getTemplate()}
@@ -95,19 +95,19 @@ class $ extends h {
95
95
  });
96
96
  }
97
97
  onTemplateNodeUpdated(t) {
98
- var i;
98
+ var r;
99
99
  super.onTemplateNodeUpdated(t);
100
100
  const e = this._getRecommendationIdFromNode(t);
101
- e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((i = this.store.blockStates[e]) != null && i.isInitialized) && this._fetchBlockData(e), [
101
+ e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((r = this.store.blockStates[e]) != null && r.isInitialized) && this._fetchBlockData(e), [
102
102
  this.algorithmControl,
103
103
  this.localeControl,
104
104
  this.currencyControl,
105
105
  this.productLayoutControl,
106
106
  this.filtersControl,
107
107
  this.shuffleControl
108
- ].forEach((r) => {
108
+ ].forEach((i) => {
109
109
  var a;
110
- r != null && r.api && (r.currentNode = t, (a = r.onTemplateNodeUpdated) == null || a.call(r, t));
110
+ i != null && i.api && (i.currentNode = t, (a = i.onTemplateNodeUpdated) == null || a.call(i, t));
111
111
  });
112
112
  }
113
113
  onDestroy() {
@@ -152,13 +152,17 @@ class $ extends h {
152
152
  * values are being prepared for the upcoming initial fetch.
153
153
  */
154
154
  _syncNodeConfigToStore() {
155
- const t = f.getConfig(this.currentNode);
155
+ var r;
156
+ const t = l.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
156
157
  this.store.patchCurrentBlockConfig({
157
158
  strategy: t.strategy,
158
159
  language: t.language,
159
160
  size: t.size,
160
161
  productIds: t.productIds,
161
- filters: t.filters,
162
+ // Only sync filters from node config during initial load.
163
+ // After initialization, the Pinia store is the source of truth
164
+ // for filters (edited via the filter drawer).
165
+ ...o ? {} : { filters: t.filters },
162
166
  shuffleProducts: t.shuffleProducts,
163
167
  currencySettings: {
164
168
  name: t.currency.code,
@@ -181,26 +185,26 @@ class $ extends h {
181
185
  this.store.fetchRecommendationFilters(),
182
186
  this.store.fetchRecommendationCreateData(),
183
187
  this.store.fetchRecommendationProducts()
184
- ])).forEach((o, i) => {
188
+ ])).forEach((o, r) => {
185
189
  o.status === "rejected" && console.warn(`Recommendation block: ${[
186
190
  "fetchRecommendationFilters",
187
191
  "fetchRecommendationCreateData",
188
192
  "fetchRecommendationProducts"
189
- ][i]} failed`, o.reason);
193
+ ][r]} failed`, o.reason);
190
194
  });
191
195
  }
192
196
  /**
193
197
  * Reads the recommendation-id attribute from the block element within the node
194
198
  */
195
199
  _getRecommendationIdFromNode(t) {
196
- const e = P(t);
200
+ const e = I(t);
197
201
  if (!e || !("getAttribute" in e))
198
202
  return null;
199
203
  const o = e.getAttribute(T);
200
204
  if (!o)
201
205
  return null;
202
- const i = parseInt(o);
203
- return Number.isNaN(i) ? null : i;
206
+ const r = parseInt(o);
207
+ return Number.isNaN(r) ? null : r;
204
208
  }
205
209
  /**
206
210
  * Listen to store changes that require product refresh or regeneration.
@@ -213,12 +217,27 @@ class $ extends h {
213
217
  const { store: t } = this;
214
218
  let e = t.recommendationProducts, o = t.$state.configVersion;
215
219
  this.storeUnsubscription = t.$subscribe(() => {
216
- const i = t.$state.configVersion;
217
- i !== o && (o = i, this._debouncedFetchProducts());
218
- const r = t.recommendationProducts, a = r !== e, u = Array.isArray(r) && r.length > 0;
219
- a && u && (e = r, this._debouncedRegenerateWithProducts());
220
+ const r = t.$state.configVersion;
221
+ r !== o && (o = r, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
222
+ const i = t.recommendationProducts, a = i !== e, d = Array.isArray(i) && i.length > 0;
223
+ a && d && (e = i, this._debouncedRegenerateWithProducts());
220
224
  });
221
225
  }
226
+ /**
227
+ * Persists the current filter state from Pinia store to the Stripo node config.
228
+ * This ensures filters survive template save/reload cycles.
229
+ */
230
+ _persistFiltersToNodeConfig() {
231
+ if (!this.currentNode || !this.api)
232
+ return;
233
+ const { filters: t } = this.store.recommendationConfigs;
234
+ l.updateConfig(
235
+ this.api,
236
+ this.currentNode,
237
+ { filters: t },
238
+ "Update recommendation filters"
239
+ );
240
+ }
222
241
  }
223
242
  export {
224
243
  W as ALGORITHM_CONTROL_ID,
@@ -229,22 +248,22 @@ export {
229
248
  j as FILTERS_CONTROL_ID,
230
249
  R as FiltersControl,
231
250
  K as LOCALE_CONTROL_ID,
232
- y as LocaleControl,
251
+ N as LocaleControl,
233
252
  J as PRODUCT_LAYOUT_CONTROL_ID,
234
- _ as ProductLayoutControl,
235
- $ as RecommendationBlockControl,
253
+ y as ProductLayoutControl,
254
+ z as RecommendationBlockControl,
236
255
  X as SHUFFLE_CONTROL_ID,
237
- N as ShuffleControl,
256
+ _ as ShuffleControl,
238
257
  tt as formatProductPrice,
239
- P as getBlockElement,
258
+ I as getBlockElement,
240
259
  et as getCardComposition,
241
260
  ot as getCurrentLayout,
242
261
  rt as reapplySpacing,
243
- nt as regenerateMobileProductRows,
244
- it as regenerateProductRows,
262
+ it as regenerateMobileProductRows,
263
+ nt as regenerateProductRows,
245
264
  b as regenerateProductRowsWithStyles,
246
265
  st as setCurrencyAttributes,
247
266
  ct as updatePricesInPlace,
248
- I as updateProductContentInPlace,
267
+ P as updateProductContentInPlace,
249
268
  at as updateSingleProductContent
250
269
  };