@useinsider/guido 3.30.0-beta.23d415d → 3.30.0-beta.25ed52c

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 (35) hide show
  1. package/README.md +35 -0
  2. package/dist/@types/config/schemas.js +42 -37
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +129 -115
  5. package/dist/components/organisms/dynamic-content/DynamicContentAooRuleConfig.vue.js +34 -0
  6. package/dist/components/organisms/dynamic-content/DynamicContentAooRuleConfig.vue2.js +76 -0
  7. package/dist/components/organisms/dynamic-content/DynamicContentCustomFormat.vue.js +21 -0
  8. package/dist/components/organisms/dynamic-content/DynamicContentCustomFormat.vue2.js +33 -0
  9. package/dist/components/organisms/dynamic-content/DynamicContentPicker.vue.js +42 -0
  10. package/dist/components/organisms/dynamic-content/DynamicContentPicker.vue2.js +216 -0
  11. package/dist/composables/useDynamicContentFormat.js +10 -0
  12. package/dist/composables/useDynamicContentPicker.js +36 -0
  13. package/dist/composables/useInfoBoxPosition.js +16 -0
  14. package/dist/config/migrator/itemsBlockMigrator.js +164 -161
  15. package/dist/enums/dynamic-content.js +180 -2
  16. package/dist/guido.css +1 -1
  17. package/dist/package.json.js +2 -2
  18. package/dist/src/@types/config/schemas.d.ts +12 -0
  19. package/dist/src/@types/generic.d.ts +1 -0
  20. package/dist/src/components/organisms/dynamic-content/DynamicContentAooRuleConfig.vue.d.ts +48 -0
  21. package/dist/src/components/organisms/dynamic-content/DynamicContentCustomFormat.vue.d.ts +44 -0
  22. package/dist/src/components/organisms/dynamic-content/DynamicContentPicker.vue.d.ts +67 -0
  23. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  24. package/dist/src/composables/useConfig.d.ts +4 -0
  25. package/dist/src/composables/useDynamicContentFormat.d.ts +5 -0
  26. package/dist/src/composables/useDynamicContentPicker.d.ts +35 -0
  27. package/dist/src/composables/useInfoBoxPosition.d.ts +24 -0
  28. package/dist/src/enums/dynamic-content.d.ts +21 -0
  29. package/dist/src/stores/config.d.ts +42 -0
  30. package/dist/src/utils/dynamicContentPicker.d.ts +43 -0
  31. package/dist/src/utils/genericUtil.d.ts +1 -1
  32. package/dist/utils/dynamicContentPicker.js +88 -0
  33. package/dist/utils/genericUtil.js +21 -21
  34. package/dist/utils/pairProductVariables.js +98 -108
  35. package/package.json +1 -1
@@ -0,0 +1,216 @@
1
+ import { defineComponent as Tt, ref as d, computed as o, toRef as _t, reactive as Dt, watch as at, onBeforeUnmount as Bt, nextTick as lt } from "vue";
2
+ import { useDynamicContentFormat as wt } from "../../../composables/useDynamicContentFormat.js";
3
+ import { useInfoBoxPosition as Rt } from "../../../composables/useInfoBoxPosition.js";
4
+ import { useTranslations as Ht } from "../../../composables/useTranslations.js";
5
+ import { ARRAY_OF_OBJECTS_CATEGORY_VALUE as it, ARRAY_OF_OBJECTS_LABEL_BASE as ut, DynamicContentAttributeType as st, DynamicContentCustomFormat as ct } from "../../../enums/dynamic-content.js";
6
+ import Pt from "./DynamicContentAooRuleConfig.vue.js";
7
+ import Nt from "./DynamicContentCustomFormat.vue.js";
8
+ import { isLookupBinding as $t, isAooTokenForArrays as rt, removeAooTokenOnce as Vt, extractUsedAooPatterns as zt, buildLookupColumnOptions as Ut, getIndefiniteArticle as Yt, findDynamicContentSelection as Mt } from "../../../utils/dynamicContentPicker.js";
9
+ import { escapeHtml as z } from "../../../utils/htmlEscape.js";
10
+ import { InSelect as jt, InInfoBox as Jt, InBasicTextInput as Kt } from "@useinsider/design-system-vue";
11
+ const ae = /* @__PURE__ */ Tt({
12
+ __name: "DynamicContentPicker",
13
+ props: {
14
+ visible: { type: Boolean },
15
+ dynamicContentOptions: { default: () => [] },
16
+ aooOptions: { default: () => [] },
17
+ aooScanContent: { default: "" },
18
+ initialData: { default: null },
19
+ position: { default: () => ({}) }
20
+ },
21
+ emits: ["close", "addDynamicContent"],
22
+ setup(mt, { emit: _ }) {
23
+ const a = mt, p = Object.freeze({ attribute: "attribute", settings: "settings" }), D = "dynamic-content-modal__save-button", U = "dynamic-content-modal__cancel-button", l = Ht(), { getFormatOptions: B, isNumberFormatSupported: Y } = wt(), M = d(), I = d(), c = d(), k = d(p.attribute), w = d({ width: 0, height: 0 }), F = d(!1), h = o(() => {
24
+ var t;
25
+ return !!((t = a.initialData) != null && t.value);
26
+ }), { positionStyle: dt } = Rt({
27
+ anchor: _t(a, "position"),
28
+ size: w,
29
+ isAbove: o(() => !h.value)
30
+ });
31
+ let r = null, u = null;
32
+ const f = /* @__PURE__ */ new Set();
33
+ let g = !1, R = !1;
34
+ const e = Dt({
35
+ dynamicContentInput: [],
36
+ lookupColumnInput: [],
37
+ aooLeafInput: [],
38
+ dynamicContentFallbackInput: "",
39
+ isCustomFormatEnabled: !1,
40
+ customFormat: {}
41
+ }), L = o(() => a.aooOptions.map((t) => t.value).filter(Boolean)), v = o(() => a.aooOptions.length ? { text: l(`${ut}-text`), value: it, description: "" } : null), j = o(() => v.value ? [...a.dynamicContentOptions, v.value] : a.dynamicContentOptions), C = o(() => $t(e.dynamicContentInput[0])), y = o(() => {
42
+ var t;
43
+ return ((t = e.dynamicContentInput[0]) == null ? void 0 : t.value) === it;
44
+ }), pt = o(() => {
45
+ var n, i;
46
+ const t = rt((n = a.initialData) == null ? void 0 : n.value, L.value) ? Vt(a.aooScanContent, (i = a.initialData) == null ? void 0 : i.value) : a.aooScanContent;
47
+ return zt(t).filter(
48
+ (s) => L.value.includes(s.slice(s.indexOf(".") + 1))
49
+ );
50
+ }), J = o(() => Ut(e.dynamicContentInput[0])), S = o(
51
+ () => {
52
+ var t, n;
53
+ return String(((t = e.dynamicContentInput[0]) == null ? void 0 : t.bindingLabel) || ((n = e.dynamicContentInput[0]) == null ? void 0 : n.text) || "");
54
+ }
55
+ ), ft = o(() => z(S.value)), vt = o(
56
+ () => l("products.dropdown-placeholder", { label: S.value })
57
+ ), H = o(
58
+ () => {
59
+ var t;
60
+ return ((t = e.dynamicContentInput[0]) == null ? void 0 : t.type) === st.Datetime;
61
+ }
62
+ ), K = o(
63
+ () => {
64
+ var t;
65
+ return ((t = e.dynamicContentInput[0]) == null ? void 0 : t.type) === st.Number && Y.value;
66
+ }
67
+ ), P = o(() => H.value || K.value), m = o(() => H.value ? ct.Time : ct.Number), Ct = o(() => ({
68
+ type: m.value,
69
+ options: B(m.value),
70
+ checkboxLabel: l(`dynamic-content.custom-${m.value}-checkbox-text`),
71
+ selectLabel: l(`dynamic-content.custom-${m.value}-label-text`),
72
+ selectPlaceholder: l(`dynamic-content.custom-${m.value}-placeholder-text`)
73
+ })), q = (t) => l("validations.select-a-field-to-continue", {
74
+ article: Yt(t),
75
+ field: t
76
+ }), G = o(() => {
77
+ const t = (n, i, s) => F.value && n && !i.length ? q(s) : "";
78
+ return {
79
+ dynamicContentInput: t(
80
+ !0,
81
+ e.dynamicContentInput,
82
+ l("dynamic-content.dynamic-contents-label")
83
+ ),
84
+ lookupColumnInput: t(C.value, e.lookupColumnInput, S.value),
85
+ aooLeafInput: t(
86
+ y.value,
87
+ e.aooLeafInput,
88
+ l(`${ut}-text`)
89
+ )
90
+ };
91
+ }), yt = o(() => e.dynamicContentInput.length ? y.value ? !!e.aooLeafInput.length : C.value ? !!e.lookupColumnInput.length : !0 : !1), x = o(() => k.value === p.settings), A = o(() => y.value ? e.aooLeafInput[0] : C.value ? e.lookupColumnInput[0] : e.dynamicContentInput[0]), N = o(() => !y.value && !C.value && e.isCustomFormatEnabled && P.value), bt = o(() => {
92
+ var t;
93
+ return x.value ? z(String(((t = A.value) == null ? void 0 : t.text) ?? "")) : l(h.value ? "integration-hub.webhook.replace-dynamic-content" : "dynamic-content.modal-title");
94
+ }), It = o(() => {
95
+ var t;
96
+ return z(`{{${((t = A.value) == null ? void 0 : t.value) ?? ""}}}`);
97
+ }), kt = o(() => [
98
+ {
99
+ id: D,
100
+ text: l("products.save"),
101
+ type: "text",
102
+ icon: "line-check-netural",
103
+ status: "default"
104
+ },
105
+ {
106
+ id: U,
107
+ text: l("products.cancel"),
108
+ type: "text",
109
+ icon: "line-error-netural",
110
+ status: "secondary"
111
+ }
112
+ ]), Ft = (t) => {
113
+ var n;
114
+ (n = c.value) == null || n.resetState(), e.dynamicContentInput = [t], e.lookupColumnInput = [], e.aooLeafInput = [], e.dynamicContentFallbackInput = "", e.isCustomFormatEnabled = !1, e.customFormat = {};
115
+ }, ht = (t) => {
116
+ e.lookupColumnInput = [t], e.dynamicContentFallbackInput = "";
117
+ }, gt = ({ leaf: t }) => {
118
+ e.aooLeafInput = [t];
119
+ }, Lt = () => {
120
+ e.aooLeafInput = [];
121
+ }, O = () => {
122
+ _("close");
123
+ }, W = () => {
124
+ var i;
125
+ const t = (i = a.initialData) == null ? void 0 : i.format;
126
+ if (!t || !P.value || !c.value)
127
+ return;
128
+ const n = B(m.value).find((s) => s.value === t.value);
129
+ n ? (e.customFormat = t, c.value.setFormat(n)) : (e.customFormat = {}, e.isCustomFormatEnabled = !1, c.value.resetState());
130
+ }, Q = () => {
131
+ _("addDynamicContent", {
132
+ ...A.value,
133
+ ...N.value ? { format: e.customFormat } : { fallback: e.dynamicContentFallbackInput }
134
+ });
135
+ }, X = () => {
136
+ var n;
137
+ return F.value = !0, (((n = c.value) == null ? void 0 : n.validate()) ?? !0) && !Object.values(G.value).some(Boolean);
138
+ }, Z = () => {
139
+ if (X()) {
140
+ if (x.value || N.value) {
141
+ Q();
142
+ return;
143
+ }
144
+ k.value = p.settings;
145
+ }
146
+ }, St = ({ id: t }) => {
147
+ if (t !== D) {
148
+ O();
149
+ return;
150
+ }
151
+ R || Z();
152
+ }, xt = ({ detail: t }) => {
153
+ R = t > 1;
154
+ }, At = (t, n) => {
155
+ n ? f.add(t) : f.delete(t);
156
+ }, Ot = ({ target: t, currentTarget: n }) => {
157
+ g = t === n;
158
+ }, Et = () => {
159
+ g && O();
160
+ }, b = ({ key: t, isComposing: n }) => {
161
+ t === "Escape" && !n && !f.size && O();
162
+ }, $ = () => {
163
+ const { offsetWidth: t = 0, offsetHeight: n = 0 } = I.value || {};
164
+ w.value = { width: t, height: n };
165
+ }, tt = () => {
166
+ var n;
167
+ let t = document.activeElement;
168
+ for (; (n = t == null ? void 0 : t.shadowRoot) != null && n.activeElement; )
169
+ t = t.shadowRoot.activeElement;
170
+ return (t == null ? void 0 : t.contentDocument) || null;
171
+ }, E = () => {
172
+ document.removeEventListener("keydown", b, !0), u == null || u.removeEventListener("keydown", b, !0), u = null, r == null || r.disconnect(), r = null;
173
+ }, et = async () => {
174
+ var t;
175
+ E(), document.addEventListener("keydown", b, !0), await lt(), !(!a.visible || !I.value) && (u = h.value ? tt() : null, u ? u.addEventListener("keydown", b, !0) : (t = M.value) == null || t.focus({ preventScroll: !0 }), $(), typeof ResizeObserver < "u" && (r = new ResizeObserver($), r.observe(I.value)));
176
+ }, V = async () => {
177
+ const { initialData: t } = a;
178
+ if (rt(t == null ? void 0 : t.value, L.value) && v.value) {
179
+ e.dynamicContentInput = [v.value], t != null && t.fallback && (e.dynamicContentFallbackInput = t.fallback);
180
+ return;
181
+ }
182
+ const n = Mt(t, j.value);
183
+ if (n && (e.dynamicContentInput = [n.binding]), await lt(), n != null && n.column) {
184
+ const i = J.value.find((s) => {
185
+ var ot;
186
+ return s.value === ((ot = n.column) == null ? void 0 : ot.value);
187
+ });
188
+ i && (e.lookupColumnInput = [i]);
189
+ }
190
+ t != null && t.fallback && (e.dynamicContentFallbackInput = t.fallback), n && W();
191
+ }, nt = () => {
192
+ var t;
193
+ E(), f.clear(), g = !1, k.value = p.attribute, F.value = !1, e.dynamicContentInput = [], e.lookupColumnInput = [], e.aooLeafInput = [], e.dynamicContentFallbackInput = "", e.isCustomFormatEnabled = !1, e.customFormat = {}, (t = c.value) == null || t.resetState();
194
+ }, T = (t) => console.error("[DYNAMIC_CONTENT_PICKER] open failed", t);
195
+ return at(
196
+ () => a.visible,
197
+ (t) => {
198
+ if (!t) {
199
+ nt();
200
+ return;
201
+ }
202
+ V().catch(T), et().catch(T);
203
+ },
204
+ { immediate: !0 }
205
+ ), at(
206
+ [() => a.initialData, () => a.dynamicContentOptions],
207
+ () => {
208
+ a.visible && !x.value && a.initialData && a.dynamicContentOptions.length && V().catch(T);
209
+ },
210
+ { deep: !0 }
211
+ ), Bt(E), { __sfc: !0, STEPS: p, SAVE_BUTTON_ID: D, CANCEL_BUTTON_ID: U, props: a, emit: _, trans: l, getFormatOptions: B, isNumberFormatSupported: Y, layerRef: M, boxRef: I, customFormatRef: c, currentStep: k, boxSize: w, isSubmitted: F, isEditing: h, positionStyle: dt, resizeObserver: r, frameDocument: u, openLists: f, isPressedOnLayer: g, isRepeatedClick: R, state: e, aooArrayKeys: L, aooEntry: v, formattedDynamicContentOptions: j, isLookupSelected: C, isAooSelected: y, usedAooPatterns: pt, lookupColumnOptions: J, lookupBindingText: S, lookupBindingLabel: ft, lookupColumnPlaceholder: vt, isCustomDateTimeFormatVisible: H, isCustomNumberFormatVisible: K, hasCustomFormat: P, customFormatType: m, customFormatConfig: Ct, requiredMessage: q, errors: G, hasSelectedDynamicContent: yt, isSettingsStep: x, selectedContent: A, hasAppliedFormat: N, titleText: bt, descriptionText: It, buttonOptions: kt, selectDynamicContentHandler: Ft, selectLookupColumnHandler: ht, selectAooLeafHandler: gt, clearAooLeafHandler: Lt, closeHandler: O, restoreInitialFormat: W, insertDynamicContent: Q, validate: X, primaryButtonClickHandler: Z, buttonClickHandler: St, clickCaptureHandler: xt, openListHandler: At, layerMousedownHandler: Ot, layerClickHandler: Et, keydownHandler: b, measureBox: $, getFocusedFrameDocument: tt, stopTracking: E, startTracking: et, populateInitialData: V, resetPicker: nt, reportFailure: T, DynamicContentAooRuleConfig: Pt, DynamicContentCustomFormat: Nt, InBasicTextInput: Kt, InInfoBox: Jt, InSelect: jt };
212
+ }
213
+ });
214
+ export {
215
+ ae as default
216
+ };
@@ -0,0 +1,10 @@
1
+ import { useConfig as e } from "./useConfig.js";
2
+ import { DynamicContentCustomFormat as i, NumberFormats as n, LiquidTimeFormats as u, PongoTimeFormats as a } from "../enums/dynamic-content.js";
3
+ import { computed as o } from "vue";
4
+ const f = () => {
5
+ const { isFeatureEnabled: r } = e(), t = o(() => r("liquidSyntax"));
6
+ return { isNumberFormatSupported: o(() => !t.value), getFormatOptions: (m) => m !== i.Time ? n : t.value ? u : a };
7
+ };
8
+ export {
9
+ f as useDynamicContentFormat
10
+ };
@@ -0,0 +1,36 @@
1
+ import { useConfigStore as f } from "../stores/config.js";
2
+ import { useGuidoEmailEditorStore as b } from "../stores/guido-email-editor.js";
3
+ import { buildPickerOptions as v, buildAooScanContent as S } from "../utils/dynamicContentPicker.js";
4
+ import { computed as o, ref as C } from "vue";
5
+ const A = ({ onInsert: c, onClose: s }) => {
6
+ const t = f(), p = o(() => t.isFeatureEnabled("dynamicContentPicker")), i = C({ visible: !1, initialData: null }), m = o(() => {
7
+ var e;
8
+ return v((e = t.template) == null ? void 0 : e.dynamicContentList);
9
+ }), u = o(() => {
10
+ var a, l;
11
+ if (!i.value.visible)
12
+ return "";
13
+ const e = b(), n = e.hasSnapshot ? e.html : (a = t.template) == null ? void 0 : a.html, { subject: d = "", preheader: k = "" } = ((l = t.editor) == null ? void 0 : l.emailHeader) ?? {};
14
+ return S([d, k, n ?? ""]);
15
+ }), r = () => {
16
+ i.value = { visible: !1, initialData: null };
17
+ };
18
+ return {
19
+ isPickerEnabled: p,
20
+ picker: i,
21
+ pickerOptions: m,
22
+ pickerAooScanContent: u,
23
+ openPicker: (e, n) => {
24
+ i.value = { visible: !0, initialData: e ?? null, position: n };
25
+ },
26
+ pickerSaveHandler: (e) => {
27
+ r(), c(e);
28
+ },
29
+ pickerCloseHandler: () => {
30
+ r(), s();
31
+ }
32
+ };
33
+ };
34
+ export {
35
+ A as useDynamicContentPicker
36
+ };
@@ -0,0 +1,16 @@
1
+ import { ref as g, computed as x, onMounted as a, onBeforeUnmount as f } from "vue";
2
+ const u = 8, h = (t, e) => Math.max(u, Math.min(t, e)), b = (t) => ["x", "y", "width", "height"].every((e) => Number.isFinite(t == null ? void 0 : t[e])) && Number(t == null ? void 0 : t.width) > 0 && Number(t == null ? void 0 : t.height) > 0, c = ({ anchor: t, size: e, isAbove: l }) => {
3
+ const i = g({ width: window.innerWidth, height: window.innerHeight }), d = () => {
4
+ i.value = { width: window.innerWidth, height: window.innerHeight };
5
+ }, v = x(() => {
6
+ const w = i.value.height - e.value.height - u, r = i.value.width - e.value.width - u, n = t.value, o = b(n), m = o ? n.x : (i.value.width - e.value.width) / 2, s = { left: `${h(m, r)}px` };
7
+ if (o && l.value)
8
+ return { bottom: `${h(i.value.height - n.y, w)}px`, ...s };
9
+ const p = o ? n.y + n.height : (i.value.height - e.value.height) / 2;
10
+ return { top: `${h(p, w)}px`, ...s };
11
+ });
12
+ return a(() => window.addEventListener("resize", d)), f(() => window.removeEventListener("resize", d)), { positionStyle: v };
13
+ };
14
+ export {
15
+ c as useInfoBoxPosition
16
+ };