@useinsider/guido 3.28.1-beta.d3309a6 → 3.28.1-beta.ff58f9a

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 (46) hide show
  1. package/README.md +0 -10
  2. package/dist/@types/config/schemas.js +129 -142
  3. package/dist/@types/display-condition.js +21 -45
  4. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +19 -25
  5. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +55 -77
  6. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +1 -1
  7. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +43 -62
  8. package/dist/composables/useDisplayConditions.js +68 -83
  9. package/dist/enums/html-validator.js +1 -1
  10. package/dist/extensions/DisplayConditions/constants.js +10 -19
  11. package/dist/extensions/DisplayConditions/control.js +99 -120
  12. package/dist/extensions/DisplayConditions/display-conditions.css.js +6 -58
  13. package/dist/extensions/DisplayConditions/extension.js +14 -18
  14. package/dist/guido.css +1 -1
  15. package/dist/node_modules/valibot/dist/index.js +102 -118
  16. package/dist/package.json.js +1 -1
  17. package/dist/services/displayConditionApi.js +19 -18
  18. package/dist/src/@types/config/schemas.d.ts +0 -65
  19. package/dist/src/@types/display-condition.d.ts +0 -67
  20. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  21. package/dist/src/composables/useConfig.d.ts +2 -42
  22. package/dist/src/composables/useDisplayConditions.d.ts +1 -1
  23. package/dist/src/extensions/DisplayConditions/constants.d.ts +0 -2
  24. package/dist/src/extensions/DisplayConditions/control.d.ts +0 -1
  25. package/dist/src/stores/config.d.ts +21 -441
  26. package/package.json +2 -2
  27. package/dist/components/organisms/display-conditions/LogicBuilderConnector.vue.js +0 -18
  28. package/dist/components/organisms/display-conditions/LogicBuilderConnector.vue2.js +0 -25
  29. package/dist/components/organisms/display-conditions/LogicBuilderField.vue.js +0 -28
  30. package/dist/components/organisms/display-conditions/LogicBuilderField.vue2.js +0 -28
  31. package/dist/components/organisms/display-conditions/LogicBuilderGroup.vue.js +0 -30
  32. package/dist/components/organisms/display-conditions/LogicBuilderGroup.vue2.js +0 -32
  33. package/dist/components/organisms/display-conditions/LogicBuilderRow.vue.js +0 -28
  34. package/dist/components/organisms/display-conditions/LogicBuilderRow.vue2.js +0 -60
  35. package/dist/composables/useScrollToInvalid.js +0 -15
  36. package/dist/src/components/organisms/display-conditions/LogicBuilderConnector.vue.d.ts +0 -19
  37. package/dist/src/components/organisms/display-conditions/LogicBuilderField.vue.d.ts +0 -22
  38. package/dist/src/components/organisms/display-conditions/LogicBuilderGroup.vue.d.ts +0 -24
  39. package/dist/src/components/organisms/display-conditions/LogicBuilderRow.vue.d.ts +0 -25
  40. package/dist/src/composables/useScrollToInvalid.d.ts +0 -6
  41. package/dist/src/utils/displayConditionBuilder.d.ts +0 -29
  42. package/dist/src/utils/displayConditionRules.d.ts +0 -12
  43. package/dist/src/utils/displayConditionSummary.d.ts +0 -11
  44. package/dist/utils/displayConditionBuilder.js +0 -50
  45. package/dist/utils/displayConditionRules.js +0 -91
  46. package/dist/utils/displayConditionSummary.js +0 -28
@@ -1,103 +1,81 @@
1
- import { defineComponent as j, reactive as P, ref as i, computed as l, watch as G } from "vue";
2
- import K from "../../wrappers/WpDrawer.vue.js";
3
- import { useDisplayConditions as M, DISPLAY_CONDITIONS_TRANS_KEY as c } from "../../../composables/useDisplayConditions.js";
4
- import { invalidFieldAttrs as W, useScrollToInvalid as q } from "../../../composables/useScrollToInvalid.js";
5
- import { useTranslations as z } from "../../../composables/useTranslations.js";
6
- import { DISPLAY_CONDITION_LIMITS as H } from "../../../enums/display-condition.js";
7
- import { useConfigStore as J } from "../../../stores/config.js";
8
- import { useDisplayConditionStore as Q } from "../../../stores/display-condition.js";
9
- import { emptyBuilder as x, builderFromTree as U, treeFromBuilder as V } from "../../../utils/displayConditionBuilder.js";
10
- import { readLogicBuilderRules as X } from "../../../utils/displayConditionRules.js";
11
- import { InRadioButton as Z, InBasicTextInput as ee } from "@useinsider/design-system-vue";
12
- import te from "./CodeEditorField.vue.js";
13
- import oe from "./LogicBuilderField.vue.js";
14
- const be = /* @__PURE__ */ j({
1
+ import { defineComponent as w, reactive as L, ref as c, computed as u, watch as N } from "vue";
2
+ import R from "../../wrappers/WpDrawer.vue.js";
3
+ import { useDisplayConditions as k, DISPLAY_CONDITIONS_TRANS_KEY as i } from "../../../composables/useDisplayConditions.js";
4
+ import { useTranslations as Y } from "../../../composables/useTranslations.js";
5
+ import { DISPLAY_CONDITION_LIMITS as j } from "../../../enums/display-condition.js";
6
+ import { useDisplayConditionStore as E } from "../../../stores/display-condition.js";
7
+ import { InRadioButton as P, InBasicTextInput as F } from "@useinsider/design-system-vue";
8
+ import G from "./CodeEditorField.vue.js";
9
+ const Z = /* @__PURE__ */ w({
15
10
  __name: "DisplayConditionCreateDrawer",
16
- setup(re) {
17
- const s = z(), p = Q(), S = J(), {
18
- validate: I,
19
- notifyInvalid: m,
20
- createInline: _,
21
- createAndSave: A,
22
- cancel: C,
23
- describeWithAcademyLink: T
24
- } = M(), v = () => ({
25
- name: "",
26
- description: "",
27
- method: "logicBuilder",
28
- codeBefore: "",
29
- codeAfter: "",
30
- rules: null
31
- }), e = P(v()), y = i(x()), B = i(!1), F = l(() => {
32
- var t;
33
- return ((t = S.template) == null ? void 0 : t.displayConditionAttributes) ?? { custom: [], default: [] };
34
- }), g = l(() => e.method === "logicBuilder"), r = i({}), a = i(!1), d = i(!1), u = l(() => a.value || d.value), h = i(), D = i(), O = i(), { scrollToFirstInvalid: b } = q(O);
35
- let f = 0;
36
- G(() => p.isCreateOpen, (t) => {
37
- if (f += 1, !t)
11
+ setup(K) {
12
+ const n = Y(), p = E(), {
13
+ validate: v,
14
+ notifyInvalid: f,
15
+ createInline: y,
16
+ createAndSave: _,
17
+ cancel: b,
18
+ describeWithAcademyLink: B
19
+ } = k(), m = () => ({ name: "", description: "", codeBefore: "", codeAfter: "" }), e = L(m()), o = c({}), r = c(!1), l = c(!1), s = u(() => r.value || l.value), g = c(), I = c();
20
+ let d = 0;
21
+ N(() => p.isCreateOpen, (a) => {
22
+ if (d += 1, !a)
38
23
  return;
39
- const { editing: o } = p, n = o ? X(o.extraData) : null;
40
- Object.assign(e, v(), o ? {
41
- name: o.name,
42
- description: o.description,
43
- method: n ? "logicBuilder" : "codeOnly",
44
- codeBefore: n ? "" : o.beforeScript,
45
- codeAfter: n ? "" : o.afterScript
46
- } : {}), y.value = n ? U(n) : x(), B.value = !1, r.value = {}, a.value = !1;
24
+ const { editing: t } = p;
25
+ Object.assign(e, t ? {
26
+ name: t.name,
27
+ description: t.description,
28
+ codeBefore: t.beforeScript,
29
+ codeAfter: t.afterScript
30
+ } : m()), o.value = {}, r.value = !1;
47
31
  }, { immediate: !0 });
48
- const $ = l(() => T("create-description")), N = l(() => ({
32
+ const C = u(() => B("create-description")), D = u(() => ({
49
33
  cancelOrBackButton: {
50
34
  styling: "ghost",
51
35
  type: "secondary",
52
- labelText: s(`${c}.cancel`),
53
- disabledStatus: u.value
36
+ labelText: n(`${i}.cancel`),
37
+ disabledStatus: s.value
54
38
  },
55
39
  secondaryButton: {
56
40
  styling: "solid",
57
41
  type: "subtle-primary",
58
- labelText: s(`${c}.create-and-save`),
59
- loadingStatus: a.value
42
+ labelText: n(`${i}.create-and-save`),
43
+ loadingStatus: r.value
60
44
  },
61
45
  primaryButton: {
62
46
  styling: "solid",
63
47
  type: "primary",
64
- labelText: s(`${c}.create`),
65
- disabledStatus: u.value
48
+ labelText: n(`${i}.create`),
49
+ disabledStatus: s.value
66
50
  }
67
- })), k = (t, o) => {
68
- o !== e[t] && (e[t] = o, r.value[t] && (r.value = { ...r.value, [t]: void 0 }));
69
- }, E = l(() => `${s(`${c}.condition-description`)} <span class="guido-display-condition-create__optional t-c-53">(${s(`${c}.optional`)})</span>`), Y = (t) => {
70
- a.value || (e.method = t);
71
- }, w = async () => {
72
- var L, R;
73
- const t = f;
74
- d.value = !0;
75
- const [o, n] = await Promise.all([(L = h.value) == null ? void 0 : L.read(), (R = D.value) == null ? void 0 : R.read()]);
76
- return d.value = !1, t !== f ? !1 : (e.codeBefore = o ?? e.codeBefore, e.codeAfter = n ?? e.codeAfter, !0);
77
- };
78
- return { __sfc: !0, trans: s, store: p, configStore: S, validate: I, notifyInvalid: m, createInline: _, createAndSave: A, cancel: C, describeWithAcademyLink: T, emptyDraft: v, draft: e, builder: y, showRuleErrors: B, attributes: F, isLogicBuilder: g, errors: r, isSaving: a, isReadingCode: d, isBusy: u, codeBeforeRef: h, codeAfterRef: D, contentRef: O, scrollToFirstInvalid: b, openGeneration: f, descriptionText: $, footerButtonGroupOptions: N, updateField: k, descriptionLabel: E, selectMethod: Y, readCode: w, submit: async (t) => {
79
- if (u.value)
51
+ })), O = (a, t) => {
52
+ t !== e[a] && (e[a] = t, o.value[a] && (o.value = { ...o.value, [a]: void 0 }));
53
+ }, T = u(() => `${n(`${i}.condition-description`)} <span class="guido-display-condition-create__optional t-c-53">(${n(`${i}.optional`)})</span>`);
54
+ return { __sfc: !0, trans: n, store: p, validate: v, notifyInvalid: f, createInline: y, createAndSave: _, cancel: b, describeWithAcademyLink: B, emptyDraft: m, draft: e, errors: o, isSaving: r, isReadingCode: l, isBusy: s, codeBeforeRef: g, codeAfterRef: I, openGeneration: d, descriptionText: C, footerButtonGroupOptions: D, updateField: O, descriptionLabel: T, submit: async (a) => {
55
+ var S, A;
56
+ if (s.value)
80
57
  return;
81
- if (g.value)
82
- e.rules = V(y.value), B.value = !e.rules;
83
- else if (!await w())
58
+ const t = d;
59
+ l.value = !0;
60
+ const [$, x] = await Promise.all([(S = g.value) == null ? void 0 : S.read(), (A = I.value) == null ? void 0 : A.read()]);
61
+ if (l.value = !1, t !== d)
84
62
  return;
85
- if (r.value = I(e), Object.keys(r.value).length || g.value && !e.rules) {
86
- m(), await b();
63
+ if (e.codeBefore = $ ?? e.codeBefore, e.codeAfter = x ?? e.codeAfter, o.value = v(e), Object.keys(o.value).length) {
64
+ f();
87
65
  return;
88
66
  }
89
- if (t === "inline") {
90
- _({ ...e });
67
+ if (a === "inline") {
68
+ y({ ...e });
91
69
  return;
92
70
  }
93
- a.value = !0;
94
- const o = await A({ ...e });
95
- a.value = !1, r.value = o ?? {}, Object.keys(r.value).length && (m(), await b());
71
+ r.value = !0;
72
+ const h = await _({ ...e });
73
+ r.value = !1, o.value = h ?? {}, Object.keys(o.value).length && f();
96
74
  }, close: () => {
97
- u.value || C();
98
- }, WpDrawer: K, KEY: c, invalidFieldAttrs: W, DISPLAY_CONDITION_LIMITS: H, InBasicTextInput: ee, InRadioButton: Z, CodeEditorField: te, LogicBuilderField: oe };
75
+ s.value || b();
76
+ }, WpDrawer: R, KEY: i, DISPLAY_CONDITION_LIMITS: j, InBasicTextInput: F, InRadioButton: P, CodeEditorField: G };
99
77
  }
100
78
  });
101
79
  export {
102
- be as default
80
+ Z as default
103
81
  };
@@ -28,7 +28,7 @@ var a = function() {
28
28
  l,
29
29
  !1,
30
30
  null,
31
- "6523e561"
31
+ "0d740001"
32
32
  );
33
33
  const f = c.exports;
34
34
  export {
@@ -1,82 +1,63 @@
1
- import { defineComponent as b, ref as d, watch as j, computed as a } from "vue";
2
- import K from "../../wrappers/WpDrawer.vue.js";
3
- import P from "../../wrappers/WpModal.vue.js";
4
- import { useDisplayConditions as W, DISPLAY_CONDITIONS_TRANS_KEY as n } from "../../../composables/useDisplayConditions.js";
5
- import { useTranslations as Y } from "../../../composables/useTranslations.js";
6
- import { useConfigStore as w } from "../../../stores/config.js";
7
- import { useDisplayConditionStore as F } from "../../../stores/display-condition.js";
8
- import { parseRuleTree as G } from "../../../utils/displayConditionRules.js";
9
- import { summarizeRuleTree as H, OPERATOR_TRANS_SUFFIX as q } from "../../../utils/displayConditionSummary.js";
10
- import { getTooltipOptions as z } from "../../../utils/tooltipUtils.js";
11
- import { InSkeleton as U, InDropdownMenu as V, InButtonV2 as X, InBasicTextInput as J } from "@useinsider/design-system-vue";
12
- import Q from "./DisplayConditionListState.vue.js";
13
- const me = /* @__PURE__ */ b({
1
+ import { defineComponent as T, ref as r, watch as I, computed as i } from "vue";
2
+ import O from "../../wrappers/WpDrawer.vue.js";
3
+ import B from "../../wrappers/WpModal.vue.js";
4
+ import { useDisplayConditions as L, DISPLAY_CONDITIONS_TRANS_KEY as s } from "../../../composables/useDisplayConditions.js";
5
+ import { useTranslations as M } from "../../../composables/useTranslations.js";
6
+ import { useDisplayConditionStore as h } from "../../../stores/display-condition.js";
7
+ import { getTooltipOptions as C } from "../../../utils/tooltipUtils.js";
8
+ import { InSkeleton as $, InDropdownMenu as E, InButtonV2 as b, InBasicTextInput as k } from "@useinsider/design-system-vue";
9
+ import w from "./DisplayConditionListState.vue.js";
10
+ const ee = /* @__PURE__ */ T({
14
11
  __name: "DisplayConditionSelectDrawer",
15
- setup(Z) {
16
- const T = [40, 76, 76, 76], o = Y(), t = F(), m = w(), { loadList: f, select: $, deleteSaved: g, cancel: O, describeWithAcademyLink: v } = W(), p = d(""), c = d(null), l = d(null), i = d(!1);
17
- j(() => t.isSelectOpen, (e) => {
18
- e && (p.value = "", c.value = null, l.value = null, f());
12
+ setup(A) {
13
+ const g = [40, 76, 76, 76], l = M(), t = h(), { loadList: c, select: v, deleteSaved: d, cancel: D, describeWithAcademyLink: p } = L(), u = r(""), a = r(null), n = r(null), o = r(!1);
14
+ I(() => t.isSelectOpen, (e) => {
15
+ e && (u.value = "", a.value = null, n.value = null, c());
19
16
  }, { immediate: !0 });
20
- const y = a(() => {
21
- const e = p.value.trim().toLocaleLowerCase();
22
- return e ? t.list.filter((s) => `${s.name} ${s.description}`.toLocaleLowerCase().includes(e)) : t.list;
23
- }), B = a(() => t.listStatus === "error" ? "error" : t.list.length ? y.value.length ? null : "no-result" : "empty"), I = a(() => v("select-description")), x = a(() => ({
17
+ const f = i(() => {
18
+ const e = u.value.trim().toLocaleLowerCase();
19
+ return e ? t.list.filter((m) => `${m.name} ${m.description}`.toLocaleLowerCase().includes(e)) : t.list;
20
+ }), y = i(() => t.listStatus === "error" ? "error" : t.list.length ? f.value.length ? null : "no-result" : "empty"), _ = i(() => p("select-description")), S = i(() => ({
24
21
  cancelOrBackButton: {
25
22
  styling: "ghost",
26
23
  type: "secondary",
27
- labelText: o(`${n}.back`),
24
+ labelText: l(`${s}.back`),
28
25
  leftIcon: "line-arrow-left"
29
26
  }
30
- })), C = a(() => ({
27
+ })), x = i(() => ({
31
28
  cancelOrBackButton: {
32
29
  type: "secondary",
33
30
  styling: "ghost",
34
- labelText: o(`${n}.cancel`),
35
- disabledStatus: i.value
31
+ labelText: l(`${s}.cancel`),
32
+ disabledStatus: o.value
36
33
  },
37
34
  primaryButton: {
38
35
  type: "danger",
39
- labelText: o(`${n}.delete`),
40
- loadingStatus: i.value
36
+ labelText: l(`${s}.delete`),
37
+ loadingStatus: o.value
41
38
  }
42
- })), L = (e) => {
43
- c.value = c.value === e.id ? null : e.id;
44
- }, h = (e) => {
45
- l.value = l.value === e.id ? null : e.id;
46
- }, A = (e) => {
47
- l.value === e.id && (l.value = null);
48
- }, E = (e) => z(
39
+ }));
40
+ return { __sfc: !0, SKELETON_HEIGHTS: g, trans: l, store: t, loadList: c, select: v, deleteSaved: d, cancel: D, describeWithAcademyLink: p, search: u, expandedId: a, menuId: n, isDeleting: o, filteredList: f, listState: y, descriptionText: _, footerButtonGroupOptions: S, deleteModalButtons: x, toggleExpanded: (e) => {
41
+ a.value = a.value === e.id ? null : e.id;
42
+ }, toggleMenu: (e) => {
43
+ n.value = n.value === e.id ? null : e.id;
44
+ }, closeMenu: (e) => {
45
+ n.value === e.id && (n.value = null);
46
+ }, expandTooltip: (e) => C(
49
47
  `guido__display-condition-expand-tooltip-${e.id}`,
50
48
  { staticPosition: "top right" }
51
- ), M = (e) => [
52
- { text: o(`${n}.delete`), value: `guido__display-condition-delete-${e.id}` }
53
- ], R = (e) => {
54
- l.value = null, t.pendingDelete = e;
55
- }, k = async () => {
56
- !t.pendingDelete || i.value || (i.value = !0, await g(t.pendingDelete), i.value = !1);
57
- }, N = () => {
58
- i.value || (t.pendingDelete = null);
59
- }, S = (e) => {
60
- var D;
61
- const s = G(e.codeBefore);
62
- if (!s)
63
- return null;
64
- const r = (D = m.template) == null ? void 0 : D.displayConditionAttributes, _ = H(
65
- s,
66
- [...(r == null ? void 0 : r.custom) ?? [], ...(r == null ? void 0 : r.default) ?? []],
67
- (u) => o(`${n}.operator-${q[u]}`)
68
- );
69
- return _.groups.map((u) => u.lines.join(`
70
- ${o(`${n}.${u.condition}`)} `)).join(`
71
-
72
- ${o(`${n}.${_.condition}`)}
73
-
74
- `);
75
- };
76
- return { __sfc: !0, SKELETON_HEIGHTS: T, trans: o, store: t, configStore: m, loadList: f, select: $, deleteSaved: g, cancel: O, describeWithAcademyLink: v, search: p, expandedId: c, menuId: l, isDeleting: i, filteredList: y, listState: B, descriptionText: I, footerButtonGroupOptions: x, deleteModalButtons: C, toggleExpanded: L, toggleMenu: h, closeMenu: A, expandTooltip: E, menuOptions: M, requestDelete: R, confirmDelete: k, closeDeleteModal: N, summaryOf: S, codeOf: (e) => (e.method === "logicBuilder" ? S(e) : null) ?? [e.codeBefore, e.codeAfter].filter(Boolean).join(`
77
- `), WpDrawer: K, WpModal: P, KEY: n, InBasicTextInput: J, InButtonV2: X, InDropdownMenu: V, InSkeleton: U, DisplayConditionListState: Q };
49
+ ), menuOptions: (e) => [
50
+ { text: l(`${s}.delete`), value: `guido__display-condition-delete-${e.id}` }
51
+ ], requestDelete: (e) => {
52
+ n.value = null, t.pendingDelete = e;
53
+ }, confirmDelete: async () => {
54
+ !t.pendingDelete || o.value || (o.value = !0, await d(t.pendingDelete), o.value = !1);
55
+ }, closeDeleteModal: () => {
56
+ o.value || (t.pendingDelete = null);
57
+ }, codeOf: (e) => [e.codeBefore, e.codeAfter].filter(Boolean).join(`
58
+ `), WpDrawer: O, WpModal: B, KEY: s, InBasicTextInput: k, InButtonV2: b, InDropdownMenu: E, InSkeleton: $, DisplayConditionListState: w };
78
59
  }
79
60
  });
80
61
  export {
81
- me as default
62
+ ee as default
82
63
  };
@@ -1,48 +1,34 @@
1
- import { useToaster as L } from "./useToaster.js";
2
- import { useTranslations as M } from "./useTranslations.js";
3
- import { ACADEMY_LINKS as O } from "../enums/academy.js";
4
- import { DisplayConditionSourceType as E, DISPLAY_CONDITION_LIMITS as a, DisplayConditionEvent as C } from "../enums/display-condition.js";
5
- import { ToasterTypeOptions as u } from "../enums/toaster.js";
6
- import { useDisplayConditionApi as B } from "../services/displayConditionApi.js";
1
+ import { useToaster as M } from "./useToaster.js";
2
+ import { useTranslations as x } from "./useTranslations.js";
3
+ import { ACADEMY_LINKS as L } from "../enums/academy.js";
4
+ import { DisplayConditionSourceType as y, DISPLAY_CONDITION_LIMITS as s, DisplayConditionEvent as I } from "../enums/display-condition.js";
5
+ import { ToasterTypeOptions as l } from "../enums/toaster.js";
6
+ import { useDisplayConditionApi as O } from "../services/displayConditionApi.js";
7
7
  import { useConfigStore as q } from "../stores/config.js";
8
- import { useDisplayConditionStore as R } from "../stores/display-condition.js";
9
- import { findInvalidCodeFields as P, nextConditionId as Y } from "../utils/displayCondition.js";
10
- import { parseRuleTree as b, compileRuleTree as k } from "../utils/displayConditionRules.js";
11
- import { escapeHtml as F } from "../utils/htmlEscape.js";
12
- import { computed as X } from "vue";
13
- const w = "email-editor.display-conditions", i = w, K = 409, I = (n) => {
14
- const l = n.method === "logicBuilder";
15
- return {
16
- name: n.name,
17
- description: n.description,
18
- method: n.method,
19
- codeBefore: l ? "" : n.codeBefore,
20
- codeAfter: l ? "" : n.codeAfter,
21
- rules: l ? b(n.codeBefore) : null
22
- };
23
- }, se = () => {
24
- const n = R(), l = q(), y = B(), o = M(), { showToaster: p } = L(), d = X(
25
- () => l.isFeatureEnabled("liquidSyntax") ? "liquid" : "pongo"
26
- ), h = (e) => {
8
+ import { useDisplayConditionStore as P } from "../stores/display-condition.js";
9
+ import { findInvalidCodeFields as Y, nextConditionId as w } from "../utils/displayCondition.js";
10
+ import { escapeHtml as R } from "../utils/htmlEscape.js";
11
+ import { computed as b } from "vue";
12
+ const B = "email-editor.display-conditions", i = B, F = 409, S = (n, m, r) => ({
13
+ id: w(),
14
+ name: n.name.trim(),
15
+ description: n.description.trim(),
16
+ beforeScript: n.codeBefore,
17
+ afterScript: n.codeAfter,
18
+ extraData: JSON.stringify(r === void 0 ? { source: m } : { source: m, savedId: r })
19
+ }), v = (n) => ({
20
+ name: n.name,
21
+ description: n.description,
22
+ codeBefore: n.codeBefore,
23
+ codeAfter: n.codeAfter
24
+ }), ne = () => {
25
+ const n = P(), m = q(), r = O(), o = x(), { showToaster: p } = M(), u = b(
26
+ () => m.isFeatureEnabled("liquidSyntax") ? "liquid" : "pongo"
27
+ ), f = (e) => {
27
28
  const t = { condition: e };
28
- return document.dispatchEvent(new CustomEvent(C.APPLY, { detail: t })), n.close(), t.applied === !0;
29
- }, D = (e, t, r) => {
30
- const c = Y(), f = r === void 0 ? { source: t } : { source: t, savedId: r }, s = { id: c, name: e.name.trim(), description: e.description.trim() };
31
- return e.method !== "logicBuilder" ? {
32
- ...s,
33
- beforeScript: e.codeBefore,
34
- afterScript: e.codeAfter,
35
- extraData: JSON.stringify(f)
36
- } : e.rules ? {
37
- ...s,
38
- ...k(e.rules, d.value, `dc${c}`),
39
- extraData: JSON.stringify({ ...f, method: "logicBuilder", rules: e.rules })
40
- } : null;
41
- }, A = (e, t, r) => {
42
- const c = D(e, t, r);
43
- return c ? h(c) : !1;
44
- }, g = () => {
45
- n.view !== "none" && (document.dispatchEvent(new CustomEvent(C.CANCEL)), n.close());
29
+ return document.dispatchEvent(new CustomEvent(I.APPLY, { detail: t })), n.close(), t.applied === !0;
30
+ }, D = () => {
31
+ n.view !== "none" && (document.dispatchEvent(new CustomEvent(I.CANCEL)), n.close());
46
32
  }, N = (e) => {
47
33
  if (e.mode === "select") {
48
34
  n.openSelect();
@@ -53,72 +39,71 @@ const w = "email-editor.display-conditions", i = w, K = 409, I = (n) => {
53
39
  const e = ++n.listRequest;
54
40
  n.listStatus = "loading";
55
41
  try {
56
- const t = await y.list(d.value);
42
+ const t = await r.list(u.value);
57
43
  e === n.listRequest && (n.list = t, n.listStatus = "loaded");
58
44
  } catch (t) {
59
45
  console.warn("Display conditions could not be loaded.", t), e === n.listRequest && (n.listStatus = "error");
60
46
  }
61
- }, T = (e) => {
62
- const t = {}, r = e.name.trim();
63
- r ? r.length < a.NAME_MIN ? t.name = o(`${i}.error-name-min`, { min: a.NAME_MIN }) : r.length > a.NAME_MAX && (t.name = o(`${i}.error-name-max`, { max: a.NAME_MAX })) : t.name = o(`${i}.error-name-required`);
64
- const { DESCRIPTION_MAX: c } = a;
65
- if (e.description.trim().length > c && (t.description = o(`${i}.error-description-max`, { max: c })), e.method === "logicBuilder")
66
- return t;
67
- const f = P(e.codeBefore, e.codeAfter, d.value);
68
- return ["codeBefore", "codeAfter"].forEach((s) => {
69
- e[s].trim() ? f.includes(s) ? t[s] = o(`${i}.error-code-invalid`) : e[s].length > a.CODE_MAX && (t[s] = o(`${i}.error-code-max`, { max: a.CODE_MAX })) : t[s] = o(`${i}.error-code-required`);
47
+ }, h = (e) => {
48
+ const t = {}, d = e.name.trim();
49
+ d ? d.length < s.NAME_MIN ? t.name = o(`${i}.error-name-min`, { min: s.NAME_MIN }) : d.length > s.NAME_MAX && (t.name = o(`${i}.error-name-max`, { max: s.NAME_MAX })) : t.name = o(`${i}.error-name-required`);
50
+ const { DESCRIPTION_MAX: C } = s;
51
+ e.description.trim().length > C && (t.description = o(`${i}.error-description-max`, { max: C }));
52
+ const g = Y(e.codeBefore, e.codeAfter, u.value);
53
+ return ["codeBefore", "codeAfter"].forEach((a) => {
54
+ e[a].trim() ? g.includes(a) ? t[a] = o(`${i}.error-code-invalid`) : e[a].length > s.CODE_MAX && (t[a] = o(`${i}.error-code-max`, { max: s.CODE_MAX })) : t[a] = o(`${i}.error-code-required`);
70
55
  }), t;
71
- }, S = (e, t) => {
72
- p(e ? { type: u.Success, message: t } : { type: u.Error, message: o("products.something-went-wrong") });
73
- }, _ = (e) => o(
56
+ }, A = (e, t) => {
57
+ p(e ? { type: l.Success, message: t } : { type: l.Error, message: o("products.something-went-wrong") });
58
+ }, T = (e) => o(
74
59
  `${i}.${e}`,
75
60
  {
76
- academyLink: `<a href="${O.EMAIL_DISPLAY_CONDITIONS}" target="_blank" style="color: #0A2ECC; text-decoration: underline;">${o(`${i}.academy`)}</a>`
61
+ academyLink: `<a href="${L.EMAIL_DISPLAY_CONDITIONS}" target="_blank" style="color: #0A2ECC; text-decoration: underline;">${o(`${i}.academy`)}</a>`
77
62
  }
78
- ), x = () => {
79
- p({ type: u.Error, message: o(`${i}.validation-failed`) });
80
- }, m = (e) => ({ name: F(e) }), v = (e, t) => {
81
- e != null && e.authReported || (console.warn(t, e), p({ type: u.Error, message: t }));
63
+ ), _ = () => {
64
+ p({ type: l.Error, message: o(`${i}.validation-failed`) });
65
+ }, c = (e) => ({ name: R(e) }), E = (e, t) => {
66
+ e != null && e.authReported || (console.warn(t, e), p({ type: l.Error, message: t }));
82
67
  };
83
68
  return {
84
- syntax: d,
69
+ syntax: u,
85
70
  handleOpen: N,
86
- cancel: g,
71
+ cancel: D,
87
72
  loadList: $,
88
- validate: T,
89
- notifyInvalid: x,
90
- describeWithAcademyLink: _,
73
+ validate: h,
74
+ notifyInvalid: _,
75
+ describeWithAcademyLink: T,
91
76
  createInline: (e) => {
92
- S(
93
- A(e, E.INLINE),
94
- o(`${i}.created`, m(e.name.trim()))
77
+ A(
78
+ f(S(e, y.INLINE)),
79
+ o(`${i}.created`, c(e.name.trim()))
95
80
  );
96
81
  },
97
82
  createAndSave: async (e) => {
98
83
  try {
99
- const t = await y.create(e, d.value);
100
- return n.list = [t, ...n.list.filter((r) => r.id !== t.id)], S(
101
- A(I(t), E.SAVED, t.id),
102
- o(`${i}.created-and-saved`, m(t.name))
84
+ const t = await r.create(e, u.value);
85
+ return n.list = [t, ...n.list.filter((d) => d.id !== t.id)], A(
86
+ f(S(v(t), y.SAVED, t.id)),
87
+ o(`${i}.created-and-saved`, c(t.name))
103
88
  ), {};
104
89
  } catch (t) {
105
- return (t == null ? void 0 : t.status) === K ? { name: o(`${i}.error-name-exists`) } : (v(t, o(`${i}.save-failed`, m(e.name.trim()))), null);
90
+ return (t == null ? void 0 : t.status) === F ? { name: o(`${i}.error-name-exists`) } : (E(t, o(`${i}.save-failed`, c(e.name.trim()))), null);
106
91
  }
107
92
  },
108
93
  select: (e) => {
109
- S(
110
- A(I(e), E.SAVED, e.id),
111
- o(`${i}.applied`, m(e.name))
94
+ A(
95
+ f(S(v(e), y.SAVED, e.id)),
96
+ o(`${i}.applied`, c(e.name))
112
97
  );
113
98
  },
114
99
  deleteSaved: async (e) => {
115
100
  try {
116
- await y.remove(e.id), n.list = n.list.filter((t) => t.id !== e.id), p({
117
- type: u.Success,
118
- message: o(`${i}.deleted`, m(e.name))
101
+ await r.remove(e.id), n.list = n.list.filter((t) => t.id !== e.id), p({
102
+ type: l.Success,
103
+ message: o(`${i}.deleted`, c(e.name))
119
104
  });
120
105
  } catch (t) {
121
- v(t, o(`${i}.delete-failed`));
106
+ E(t, o(`${i}.delete-failed`));
122
107
  } finally {
123
108
  n.pendingDelete = null;
124
109
  }
@@ -126,6 +111,6 @@ const w = "email-editor.display-conditions", i = w, K = 409, I = (n) => {
126
111
  };
127
112
  };
128
113
  export {
129
- w as DISPLAY_CONDITIONS_TRANS_KEY,
130
- se as useDisplayConditions
114
+ B as DISPLAY_CONDITIONS_TRANS_KEY,
115
+ ne as useDisplayConditions
131
116
  };
@@ -1,4 +1,4 @@
1
- const n = "newsletter.already-in-progress", s = "newsletter.campaign-could-not-be-saved", e = / (==|<=|>=|!=|>|<|in) | (if|elif|endif|else|and|or) |("[\S ]+")|('[\S ]+')|(\(|\))|([^”\s\n]+)|(({%)|( %}))/gm, E = /{%( )*now( )(".*")( )*%}/gm, o = /{%(?:(?!{%)[\s\S])*?%}/g, _ = /\{\{[^{}]+\}\}/g, t = /(\s)data-[\w-]+=(?:"[^"]*"|'[^']*')/g, i = /^[A-Za-z0-9_.]+$/, a = [
1
+ const n = "newsletter.already-in-progress", s = "newsletter.campaign-could-not-be-saved", e = / (==|<=|>=|!=|>|<|in) | (if|elif|endif|else|and|or) |("[\S ]+")|('[\S ]+')|([^”\s\n]+)|(({%)|( %}))/gm, E = /{%( )*now( )(".*")( )*%}/gm, o = /{%(?:(?!{%)[\s\S])*?%}/g, _ = /\{\{[^{}]+\}\}/g, t = /(\s)data-[\w-]+=(?:"[^"]*"|'[^']*')/g, i = /^[A-Za-z0-9_.]+$/, a = [
2
2
  "ins-unsubscribe-link",
3
3
  "ins-global-unsubscribe-link",
4
4
  "ins-preferences-unsubscribe-link",
@@ -1,10 +1,10 @@
1
1
  import { BlockType as o } from "../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- const n = "conditions", t = "guido-display-conditions-control", s = 10, d = [o.STRIPE, o.STRUCTURE, o.CONTAINER], e = {
2
+ const n = "conditions", t = "guido-display-conditions-control", d = 10, s = [o.STRIPE, o.STRUCTURE, o.CONTAINER], c = {
3
3
  PLUS: "guido-display-condition-plus",
4
4
  EDIT: "guido-display-condition-edit",
5
5
  TRASH: "guido-display-condition-trash",
6
6
  CHEVRON: "guido-display-condition-chevron"
7
- }, c = {
7
+ }, e = {
8
8
  ADD: "guidoDisplayConditionAdd",
9
9
  CREATE: "guidoDisplayConditionCreate",
10
10
  SELECT: "guidoDisplayConditionSelect",
@@ -12,24 +12,15 @@ const n = "conditions", t = "guido-display-conditions-control", s = 10, d = [o.S
12
12
  SHOW_LESS: "guidoDisplayConditionShowLess",
13
13
  EDIT: "guidoDisplayConditionEdit",
14
14
  REMOVE: "guidoDisplayConditionRemove"
15
- }, a = ["applyConditionSwitcher", "applyCondition", "displayConditions"], O = "You can add Display Condition by selecting an existing condition or creating a new one to show specific content.", C = "You can create or select a display condition to control content visibility based on your recipients' properties or events.", p = "Show this block if recipient meet the condition below", I = {
16
- is: "is",
17
- "is-not": "is not",
18
- contains: "contain",
19
- "not-contains": "doesn't contain",
20
- "is-one-of": "is one of",
21
- "is-not-one-of": "is not one of"
22
- };
15
+ }, C = ["applyConditionSwitcher", "applyCondition", "displayConditions"], a = "You can add Display Condition by selecting an existing condition or creating a new one to show specific content.", O = "You can create or select a display condition to control content visibility based on your recipients' properties or events.";
23
16
  export {
24
- C as APPLIED_DESCRIPTION,
25
- a as BUILT_IN_CONDITION_CONTROLS,
17
+ O as APPLIED_DESCRIPTION,
18
+ C as BUILT_IN_CONDITION_CONTROLS,
26
19
  t as CONDITIONS_CONTROL_ID,
27
20
  n as CONDITIONS_TAB_ID,
28
- d as CONDITION_BLOCK_TYPES,
29
- c as CONDITION_BUTTONS,
30
- e as CONDITION_ICONS,
31
- O as EMPTY_DESCRIPTION,
32
- s as MAX_COLLAPSED_LINES,
33
- I as OPERATOR_LABELS,
34
- p as RULES_INTRO
21
+ s as CONDITION_BLOCK_TYPES,
22
+ e as CONDITION_BUTTONS,
23
+ c as CONDITION_ICONS,
24
+ a as EMPTY_DESCRIPTION,
25
+ d as MAX_COLLAPSED_LINES
35
26
  };