@useinsider/guido 3.28.1-beta.c5eeeb7 → 3.28.1-beta.d3309a6
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 +10 -0
- package/dist/@types/config/schemas.js +142 -129
- package/dist/@types/display-condition.js +45 -21
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +25 -19
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +77 -55
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +1 -1
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +62 -43
- package/dist/components/organisms/display-conditions/LogicBuilderConnector.vue.js +18 -0
- package/dist/components/organisms/display-conditions/LogicBuilderConnector.vue2.js +25 -0
- package/dist/components/organisms/display-conditions/LogicBuilderField.vue.js +28 -0
- package/dist/components/organisms/display-conditions/LogicBuilderField.vue2.js +28 -0
- package/dist/components/organisms/display-conditions/LogicBuilderGroup.vue.js +30 -0
- package/dist/components/organisms/display-conditions/LogicBuilderGroup.vue2.js +32 -0
- package/dist/components/organisms/display-conditions/LogicBuilderRow.vue.js +28 -0
- package/dist/components/organisms/display-conditions/LogicBuilderRow.vue2.js +60 -0
- package/dist/composables/useDisplayConditions.js +83 -68
- package/dist/composables/useScrollToInvalid.js +15 -0
- package/dist/config/migrator/itemsBlockMigrator.js +187 -186
- package/dist/enums/html-validator.js +1 -1
- package/dist/extensions/DisplayConditions/constants.js +19 -10
- package/dist/extensions/DisplayConditions/control.js +120 -99
- package/dist/extensions/DisplayConditions/display-conditions.css.js +58 -6
- package/dist/extensions/DisplayConditions/extension.js +18 -14
- package/dist/guido.css +1 -1
- package/dist/node_modules/valibot/dist/index.js +118 -102
- package/dist/package.json.js +6 -6
- package/dist/services/displayConditionApi.js +18 -19
- package/dist/src/@types/config/schemas.d.ts +65 -0
- package/dist/src/@types/display-condition.d.ts +67 -0
- package/dist/src/components/organisms/display-conditions/LogicBuilderConnector.vue.d.ts +19 -0
- package/dist/src/components/organisms/display-conditions/LogicBuilderField.vue.d.ts +22 -0
- package/dist/src/components/organisms/display-conditions/LogicBuilderGroup.vue.d.ts +24 -0
- package/dist/src/components/organisms/display-conditions/LogicBuilderRow.vue.d.ts +25 -0
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +42 -2
- package/dist/src/composables/useDisplayConditions.d.ts +1 -1
- package/dist/src/composables/useScrollToInvalid.d.ts +6 -0
- package/dist/src/extensions/DisplayConditions/constants.d.ts +2 -0
- package/dist/src/extensions/DisplayConditions/control.d.ts +1 -0
- package/dist/src/stores/config.d.ts +441 -21
- package/dist/src/utils/displayConditionBuilder.d.ts +29 -0
- package/dist/src/utils/displayConditionRules.d.ts +12 -0
- package/dist/src/utils/displayConditionSummary.d.ts +11 -0
- package/dist/utils/displayConditionBuilder.js +50 -0
- package/dist/utils/displayConditionRules.js +91 -0
- package/dist/utils/displayConditionSummary.js +28 -0
- package/package.json +1 -1
|
@@ -1,34 +1,48 @@
|
|
|
1
|
-
import { useToaster as
|
|
2
|
-
import { useTranslations as
|
|
3
|
-
import { ACADEMY_LINKS as
|
|
4
|
-
import { DisplayConditionSourceType as
|
|
5
|
-
import { ToasterTypeOptions as
|
|
6
|
-
import { useDisplayConditionApi as
|
|
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";
|
|
7
7
|
import { useConfigStore as q } from "../stores/config.js";
|
|
8
|
-
import { useDisplayConditionStore as
|
|
9
|
-
import { findInvalidCodeFields as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
), f = (e) => {
|
|
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) => {
|
|
28
27
|
const t = { condition: e };
|
|
29
|
-
return document.dispatchEvent(new CustomEvent(
|
|
30
|
-
}, D = () => {
|
|
31
|
-
|
|
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());
|
|
32
46
|
}, N = (e) => {
|
|
33
47
|
if (e.mode === "select") {
|
|
34
48
|
n.openSelect();
|
|
@@ -39,71 +53,72 @@ const B = "email-editor.display-conditions", i = B, F = 409, S = (n, m, r) => ({
|
|
|
39
53
|
const e = ++n.listRequest;
|
|
40
54
|
n.listStatus = "loading";
|
|
41
55
|
try {
|
|
42
|
-
const t = await
|
|
56
|
+
const t = await y.list(d.value);
|
|
43
57
|
e === n.listRequest && (n.list = t, n.listStatus = "loaded");
|
|
44
58
|
} catch (t) {
|
|
45
59
|
console.warn("Display conditions could not be loaded.", t), e === n.listRequest && (n.listStatus = "error");
|
|
46
60
|
}
|
|
47
|
-
},
|
|
48
|
-
const t = {},
|
|
49
|
-
|
|
50
|
-
const { DESCRIPTION_MAX:
|
|
51
|
-
e.description.trim().length >
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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`);
|
|
55
70
|
}), t;
|
|
56
|
-
},
|
|
57
|
-
p(e ? { type:
|
|
58
|
-
},
|
|
71
|
+
}, S = (e, t) => {
|
|
72
|
+
p(e ? { type: u.Success, message: t } : { type: u.Error, message: o("products.something-went-wrong") });
|
|
73
|
+
}, _ = (e) => o(
|
|
59
74
|
`${i}.${e}`,
|
|
60
75
|
{
|
|
61
|
-
academyLink: `<a href="${
|
|
76
|
+
academyLink: `<a href="${O.EMAIL_DISPLAY_CONDITIONS}" target="_blank" style="color: #0A2ECC; text-decoration: underline;">${o(`${i}.academy`)}</a>`
|
|
62
77
|
}
|
|
63
|
-
),
|
|
64
|
-
p({ type:
|
|
65
|
-
},
|
|
66
|
-
e != null && e.authReported || (console.warn(t, e), p({ type:
|
|
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 }));
|
|
67
82
|
};
|
|
68
83
|
return {
|
|
69
|
-
syntax:
|
|
84
|
+
syntax: d,
|
|
70
85
|
handleOpen: N,
|
|
71
|
-
cancel:
|
|
86
|
+
cancel: g,
|
|
72
87
|
loadList: $,
|
|
73
|
-
validate:
|
|
74
|
-
notifyInvalid:
|
|
75
|
-
describeWithAcademyLink:
|
|
88
|
+
validate: T,
|
|
89
|
+
notifyInvalid: x,
|
|
90
|
+
describeWithAcademyLink: _,
|
|
76
91
|
createInline: (e) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
o(`${i}.created`,
|
|
92
|
+
S(
|
|
93
|
+
A(e, E.INLINE),
|
|
94
|
+
o(`${i}.created`, m(e.name.trim()))
|
|
80
95
|
);
|
|
81
96
|
},
|
|
82
97
|
createAndSave: async (e) => {
|
|
83
98
|
try {
|
|
84
|
-
const t = await
|
|
85
|
-
return n.list = [t, ...n.list.filter((
|
|
86
|
-
|
|
87
|
-
o(`${i}.created-and-saved`,
|
|
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))
|
|
88
103
|
), {};
|
|
89
104
|
} catch (t) {
|
|
90
|
-
return (t == null ? void 0 : t.status) ===
|
|
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);
|
|
91
106
|
}
|
|
92
107
|
},
|
|
93
108
|
select: (e) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
o(`${i}.applied`,
|
|
109
|
+
S(
|
|
110
|
+
A(I(e), E.SAVED, e.id),
|
|
111
|
+
o(`${i}.applied`, m(e.name))
|
|
97
112
|
);
|
|
98
113
|
},
|
|
99
114
|
deleteSaved: async (e) => {
|
|
100
115
|
try {
|
|
101
|
-
await
|
|
102
|
-
type:
|
|
103
|
-
message: o(`${i}.deleted`,
|
|
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))
|
|
104
119
|
});
|
|
105
120
|
} catch (t) {
|
|
106
|
-
|
|
121
|
+
v(t, o(`${i}.delete-failed`));
|
|
107
122
|
} finally {
|
|
108
123
|
n.pendingDelete = null;
|
|
109
124
|
}
|
|
@@ -111,6 +126,6 @@ const B = "email-editor.display-conditions", i = B, F = 409, S = (n, m, r) => ({
|
|
|
111
126
|
};
|
|
112
127
|
};
|
|
113
128
|
export {
|
|
114
|
-
|
|
115
|
-
|
|
129
|
+
w as DISPLAY_CONDITIONS_TRANS_KEY,
|
|
130
|
+
se as useDisplayConditions
|
|
116
131
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { nextTick as i } from "vue";
|
|
2
|
+
const r = "data-guido-invalid", a = (e) => e ? { [r]: "true" } : {}, n = () => {
|
|
3
|
+
var e;
|
|
4
|
+
return ((e = window.matchMedia) == null ? void 0 : e.call(window, "(prefers-reduced-motion: reduce)").matches) ?? !1;
|
|
5
|
+
}, l = (e) => ({ scrollToFirstInvalid: async () => {
|
|
6
|
+
var o;
|
|
7
|
+
await i();
|
|
8
|
+
const t = (o = e.value) == null ? void 0 : o.querySelector(`[${r}]`);
|
|
9
|
+
return t ? (t.scrollIntoView({ behavior: n() ? "auto" : "smooth", block: "center" }), !0) : !1;
|
|
10
|
+
} });
|
|
11
|
+
export {
|
|
12
|
+
r as INVALID_FIELD_ATTR,
|
|
13
|
+
a as invalidFieldAttrs,
|
|
14
|
+
l as useScrollToInvalid
|
|
15
|
+
};
|