@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.
Files changed (47) hide show
  1. package/README.md +10 -0
  2. package/dist/@types/config/schemas.js +142 -129
  3. package/dist/@types/display-condition.js +45 -21
  4. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +25 -19
  5. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +77 -55
  6. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +1 -1
  7. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +62 -43
  8. package/dist/components/organisms/display-conditions/LogicBuilderConnector.vue.js +18 -0
  9. package/dist/components/organisms/display-conditions/LogicBuilderConnector.vue2.js +25 -0
  10. package/dist/components/organisms/display-conditions/LogicBuilderField.vue.js +28 -0
  11. package/dist/components/organisms/display-conditions/LogicBuilderField.vue2.js +28 -0
  12. package/dist/components/organisms/display-conditions/LogicBuilderGroup.vue.js +30 -0
  13. package/dist/components/organisms/display-conditions/LogicBuilderGroup.vue2.js +32 -0
  14. package/dist/components/organisms/display-conditions/LogicBuilderRow.vue.js +28 -0
  15. package/dist/components/organisms/display-conditions/LogicBuilderRow.vue2.js +60 -0
  16. package/dist/composables/useDisplayConditions.js +83 -68
  17. package/dist/composables/useScrollToInvalid.js +15 -0
  18. package/dist/config/migrator/itemsBlockMigrator.js +187 -186
  19. package/dist/enums/html-validator.js +1 -1
  20. package/dist/extensions/DisplayConditions/constants.js +19 -10
  21. package/dist/extensions/DisplayConditions/control.js +120 -99
  22. package/dist/extensions/DisplayConditions/display-conditions.css.js +58 -6
  23. package/dist/extensions/DisplayConditions/extension.js +18 -14
  24. package/dist/guido.css +1 -1
  25. package/dist/node_modules/valibot/dist/index.js +118 -102
  26. package/dist/package.json.js +6 -6
  27. package/dist/services/displayConditionApi.js +18 -19
  28. package/dist/src/@types/config/schemas.d.ts +65 -0
  29. package/dist/src/@types/display-condition.d.ts +67 -0
  30. package/dist/src/components/organisms/display-conditions/LogicBuilderConnector.vue.d.ts +19 -0
  31. package/dist/src/components/organisms/display-conditions/LogicBuilderField.vue.d.ts +22 -0
  32. package/dist/src/components/organisms/display-conditions/LogicBuilderGroup.vue.d.ts +24 -0
  33. package/dist/src/components/organisms/display-conditions/LogicBuilderRow.vue.d.ts +25 -0
  34. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  35. package/dist/src/composables/useConfig.d.ts +42 -2
  36. package/dist/src/composables/useDisplayConditions.d.ts +1 -1
  37. package/dist/src/composables/useScrollToInvalid.d.ts +6 -0
  38. package/dist/src/extensions/DisplayConditions/constants.d.ts +2 -0
  39. package/dist/src/extensions/DisplayConditions/control.d.ts +1 -0
  40. package/dist/src/stores/config.d.ts +441 -21
  41. package/dist/src/utils/displayConditionBuilder.d.ts +29 -0
  42. package/dist/src/utils/displayConditionRules.d.ts +12 -0
  43. package/dist/src/utils/displayConditionSummary.d.ts +11 -0
  44. package/dist/utils/displayConditionBuilder.js +50 -0
  45. package/dist/utils/displayConditionRules.js +91 -0
  46. package/dist/utils/displayConditionSummary.js +28 -0
  47. package/package.json +1 -1
@@ -1,81 +1,103 @@
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({
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({
10
15
  __name: "DisplayConditionCreateDrawer",
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)
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)
23
38
  return;
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;
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;
31
47
  }, { immediate: !0 });
32
- const C = u(() => B("create-description")), D = u(() => ({
48
+ const $ = l(() => T("create-description")), N = l(() => ({
33
49
  cancelOrBackButton: {
34
50
  styling: "ghost",
35
51
  type: "secondary",
36
- labelText: n(`${i}.cancel`),
37
- disabledStatus: s.value
52
+ labelText: s(`${c}.cancel`),
53
+ disabledStatus: u.value
38
54
  },
39
55
  secondaryButton: {
40
56
  styling: "solid",
41
57
  type: "subtle-primary",
42
- labelText: n(`${i}.create-and-save`),
43
- loadingStatus: r.value
58
+ labelText: s(`${c}.create-and-save`),
59
+ loadingStatus: a.value
44
60
  },
45
61
  primaryButton: {
46
62
  styling: "solid",
47
63
  type: "primary",
48
- labelText: n(`${i}.create`),
49
- disabledStatus: s.value
64
+ labelText: s(`${c}.create`),
65
+ disabledStatus: u.value
50
66
  }
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)
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)
57
80
  return;
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)
81
+ if (g.value)
82
+ e.rules = V(y.value), B.value = !e.rules;
83
+ else if (!await w())
62
84
  return;
63
- if (e.codeBefore = $ ?? e.codeBefore, e.codeAfter = x ?? e.codeAfter, o.value = v(e), Object.keys(o.value).length) {
64
- f();
85
+ if (r.value = I(e), Object.keys(r.value).length || g.value && !e.rules) {
86
+ m(), await b();
65
87
  return;
66
88
  }
67
- if (a === "inline") {
68
- y({ ...e });
89
+ if (t === "inline") {
90
+ _({ ...e });
69
91
  return;
70
92
  }
71
- r.value = !0;
72
- const h = await _({ ...e });
73
- r.value = !1, o.value = h ?? {}, Object.keys(o.value).length && f();
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());
74
96
  }, close: () => {
75
- s.value || b();
76
- }, WpDrawer: R, KEY: i, DISPLAY_CONDITION_LIMITS: j, InBasicTextInput: F, InRadioButton: P, CodeEditorField: G };
97
+ u.value || C();
98
+ }, WpDrawer: K, KEY: c, invalidFieldAttrs: W, DISPLAY_CONDITION_LIMITS: H, InBasicTextInput: ee, InRadioButton: Z, CodeEditorField: te, LogicBuilderField: oe };
77
99
  }
78
100
  });
79
101
  export {
80
- Z as default
102
+ be as default
81
103
  };
@@ -28,7 +28,7 @@ var a = function() {
28
28
  l,
29
29
  !1,
30
30
  null,
31
- "0d740001"
31
+ "6523e561"
32
32
  );
33
33
  const f = c.exports;
34
34
  export {
@@ -1,63 +1,82 @@
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({
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({
11
14
  __name: "DisplayConditionSelectDrawer",
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());
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());
16
19
  }, { immediate: !0 });
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(() => ({
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(() => ({
21
24
  cancelOrBackButton: {
22
25
  styling: "ghost",
23
26
  type: "secondary",
24
- labelText: l(`${s}.back`),
27
+ labelText: o(`${n}.back`),
25
28
  leftIcon: "line-arrow-left"
26
29
  }
27
- })), x = i(() => ({
30
+ })), C = a(() => ({
28
31
  cancelOrBackButton: {
29
32
  type: "secondary",
30
33
  styling: "ghost",
31
- labelText: l(`${s}.cancel`),
32
- disabledStatus: o.value
34
+ labelText: o(`${n}.cancel`),
35
+ disabledStatus: i.value
33
36
  },
34
37
  primaryButton: {
35
38
  type: "danger",
36
- labelText: l(`${s}.delete`),
37
- loadingStatus: o.value
39
+ labelText: o(`${n}.delete`),
40
+ loadingStatus: i.value
38
41
  }
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(
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(
47
49
  `guido__display-condition-expand-tooltip-${e.id}`,
48
50
  { staticPosition: "top right" }
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 };
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 };
59
78
  }
60
79
  });
61
80
  export {
62
- ee as default
81
+ me as default
63
82
  };
@@ -0,0 +1,18 @@
1
+ import r from "./LogicBuilderConnector.vue2.js";
2
+ /* empty css */
3
+ import n from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var o = function() {
5
+ var e = this, s = e._self._c, t = e._self._setupProxy;
6
+ return s("div", { staticClass: "guido-logic-builder-connector", attrs: { "data-logic": e.value } }, [s(t.InSegments, { attrs: { id: e.id, disable: e.disabled, "segment-list": t.segments, selected: e.value, "with-icon": !1 }, on: { click: t.select } })], 1);
7
+ }, c = [], i = /* @__PURE__ */ n(
8
+ r,
9
+ o,
10
+ c,
11
+ !1,
12
+ null,
13
+ "6c88ce0c"
14
+ );
15
+ const m = i.exports;
16
+ export {
17
+ m as default
18
+ };
@@ -0,0 +1,25 @@
1
+ import { defineComponent as i, computed as l } from "vue";
2
+ import { DISPLAY_CONDITIONS_TRANS_KEY as s } from "../../../composables/useDisplayConditions.js";
3
+ import { useTranslations as p } from "../../../composables/useTranslations.js";
4
+ import { InSegments as m } from "@useinsider/design-system-vue";
5
+ const I = /* @__PURE__ */ i({
6
+ __name: "LogicBuilderConnector",
7
+ props: {
8
+ id: null,
9
+ value: null,
10
+ disabled: { type: Boolean }
11
+ },
12
+ emits: ["input"],
13
+ setup(r, { emit: o }) {
14
+ const e = r, t = p(), a = l(() => [
15
+ { text: t(`${s}.and`), value: "and" },
16
+ { text: t(`${s}.or`), value: "or" }
17
+ ]);
18
+ return { __sfc: !0, props: e, emit: o, trans: t, segments: a, select: (n) => {
19
+ !e.disabled && n !== e.value && o("input", n);
20
+ }, InSegments: m };
21
+ }
22
+ });
23
+ export {
24
+ I as default
25
+ };
@@ -0,0 +1,28 @@
1
+ import n from "./LogicBuilderField.vue2.js";
2
+ /* empty css */
3
+ import s from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var d = function() {
5
+ var t = this, i = t._self._c, o = t._self._setupProxy;
6
+ return i("div", { staticClass: "guido-logic-builder", attrs: { id: "guido__display-condition-logic-builder" } }, [t._l(t.value.groups, function(e, u) {
7
+ return i("div", { key: e.id }, [u > 0 ? i(o.LogicBuilderConnector, { staticClass: "guido-logic-builder__group-connector", attrs: { id: `guido__display-condition-group-logic-${e.id}`, disabled: t.disabled, value: t.value.condition }, on: { input: function(r) {
8
+ return o.emit("input", { ...t.value, condition: r });
9
+ } } }) : t._e(), i(o.LogicBuilderGroup, { attrs: { "custom-attributes": t.customAttributes, "default-attributes": t.defaultAttributes, disabled: t.disabled, group: e, "show-errors": t.showErrors, "sole-group": t.value.groups.length === 1 }, on: { remove: function(r) {
10
+ return o.removeGroup(u);
11
+ }, update: function(r) {
12
+ return o.updateGroup(u, r);
13
+ } } })], 1);
14
+ }), i("div", { staticClass: "guido-logic-builder__footer" }, [i(o.InButtonV2, { attrs: { id: "guido__display-condition-add-group", "left-icon": "line-plus-netural", type: "subtle-primary", "disabled-status": t.disabled, "label-text": o.trans(`${o.KEY}.add-condition-group`) }, on: { click: function(e) {
15
+ o.setGroups([...t.value.groups, o.emptyGroup()]);
16
+ } } })], 1)], 2);
17
+ }, l = [], a = /* @__PURE__ */ s(
18
+ n,
19
+ d,
20
+ l,
21
+ !1,
22
+ null,
23
+ "111861b4"
24
+ );
25
+ const f = a.exports;
26
+ export {
27
+ f as default
28
+ };
@@ -0,0 +1,28 @@
1
+ import { defineComponent as m } from "vue";
2
+ import { DISPLAY_CONDITIONS_TRANS_KEY as a } from "../../../composables/useDisplayConditions.js";
3
+ import { useTranslations as c } from "../../../composables/useTranslations.js";
4
+ import { emptyGroup as n } from "../../../utils/displayConditionBuilder.js";
5
+ import { InButtonV2 as f } from "@useinsider/design-system-vue";
6
+ import d from "./LogicBuilderConnector.vue.js";
7
+ import _ from "./LogicBuilderGroup.vue.js";
8
+ const C = /* @__PURE__ */ m({
9
+ __name: "LogicBuilderField",
10
+ props: {
11
+ value: null,
12
+ showErrors: { type: Boolean },
13
+ customAttributes: null,
14
+ defaultAttributes: null,
15
+ disabled: { type: Boolean }
16
+ },
17
+ emits: ["input"],
18
+ setup(s, { emit: u }) {
19
+ const r = s, i = c(), t = (o) => u("input", {
20
+ ...r.value,
21
+ groups: o.length ? o : [n()]
22
+ });
23
+ return { __sfc: !0, props: r, emit: u, trans: i, setGroups: t, updateGroup: (o, p) => t(r.value.groups.map((e, l) => l === o ? p : e)), removeGroup: (o) => t(r.value.groups.filter((p, e) => e !== o)), KEY: a, emptyGroup: n, InButtonV2: f, LogicBuilderConnector: d, LogicBuilderGroup: _ };
24
+ }
25
+ });
26
+ export {
27
+ C as default
28
+ };
@@ -0,0 +1,30 @@
1
+ import n from "./LogicBuilderGroup.vue2.js";
2
+ /* empty css */
3
+ import d from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var s = function() {
5
+ var t = this, r = t._self._c, o = t._self._setupProxy;
6
+ return r("div", { staticClass: "guido-logic-builder-group", attrs: { "data-group-id": t.group.id } }, [t._l(t.group.rows, function(e, u) {
7
+ return r("div", { key: e.id }, [u > 0 ? r(o.LogicBuilderConnector, { attrs: { id: `guido__display-condition-row-logic-${e.id}`, disabled: t.disabled, value: t.group.condition }, on: { input: function(i) {
8
+ return o.emit("update", { ...t.group, condition: i });
9
+ } } }) : t._e(), r(o.LogicBuilderRow, { attrs: { "custom-attributes": t.customAttributes, "default-attributes": t.defaultAttributes, disabled: t.disabled, errors: t.showErrors ? o.findRowErrors(e) : {}, "remove-disabled": t.soleGroup && t.group.rows.length === 1, row: e }, on: { duplicate: function(i) {
10
+ return o.duplicateRow(u);
11
+ }, remove: function(i) {
12
+ return o.removeRow(u);
13
+ }, update: function(i) {
14
+ return o.updateRow(u, i);
15
+ } } })], 1);
16
+ }), r("div", { staticClass: "guido-logic-builder-group__footer" }, [r(o.InButtonV2, { attrs: { id: `guido__display-condition-add-rule-${t.group.id}`, "left-icon": "line-plus-netural", type: "subtle-primary", "disabled-status": t.disabled, "label-text": o.trans(`${o.KEY}.add-condition`) }, on: { click: function(e) {
17
+ o.setRows([...t.group.rows, o.emptyRow()]);
18
+ } } })], 1)], 2);
19
+ }, a = [], l = /* @__PURE__ */ d(
20
+ n,
21
+ s,
22
+ a,
23
+ !1,
24
+ null,
25
+ "3de36f36"
26
+ );
27
+ const g = l.exports;
28
+ export {
29
+ g as default
30
+ };
@@ -0,0 +1,32 @@
1
+ import { defineComponent as i } from "vue";
2
+ import { DISPLAY_CONDITIONS_TRANS_KEY as m } from "../../../composables/useDisplayConditions.js";
3
+ import { useTranslations as a } from "../../../composables/useTranslations.js";
4
+ import { findRowErrors as c, emptyRow as w, copyRow as f } from "../../../utils/displayConditionBuilder.js";
5
+ import { InButtonV2 as d } from "@useinsider/design-system-vue";
6
+ import R from "./LogicBuilderConnector.vue.js";
7
+ import g from "./LogicBuilderRow.vue.js";
8
+ const N = /* @__PURE__ */ i({
9
+ __name: "LogicBuilderGroup",
10
+ props: {
11
+ group: null,
12
+ showErrors: { type: Boolean },
13
+ customAttributes: null,
14
+ defaultAttributes: null,
15
+ disabled: { type: Boolean },
16
+ soleGroup: { type: Boolean }
17
+ },
18
+ emits: ["update", "remove"],
19
+ setup(u, { emit: e }) {
20
+ const r = u, n = a(), t = (o) => {
21
+ o.length ? e("update", { ...r.group, rows: o }) : e("remove");
22
+ };
23
+ return { __sfc: !0, props: r, emit: e, trans: n, setRows: t, updateRow: (o, s) => t(r.group.rows.map((p, l) => l === o ? s : p)), duplicateRow: (o) => t([
24
+ ...r.group.rows.slice(0, o + 1),
25
+ f(r.group.rows[o]),
26
+ ...r.group.rows.slice(o + 1)
27
+ ]), removeRow: (o) => t(r.group.rows.filter((s, p) => p !== o)), KEY: m, emptyRow: w, findRowErrors: c, InButtonV2: d, LogicBuilderConnector: R, LogicBuilderRow: g };
28
+ }
29
+ });
30
+ export {
31
+ N as default
32
+ };
@@ -0,0 +1,28 @@
1
+ import l from "./LogicBuilderRow.vue2.js";
2
+ /* empty css */
3
+ import r from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var i = function() {
5
+ var t = this, a = t._self._c, e = t._self._setupProxy;
6
+ return a("div", { staticClass: "guido-logic-builder-row", attrs: { "data-rule-attribute": t.row.attribute } }, [a(e.InSelect, t._b({ staticClass: "guido-logic-builder-row__field", attrs: { id: e.fieldId("property"), "search-status": "", "button-status": !1, "disabled-status": t.disabled, "label-status": !1, options: e.propertyOptions, "placeholder-text": e.trans(`${e.KEY}.select-property`), state: e.fieldState(t.errors.attribute), "state-message": t.errors.attribute ? e.trans(`${e.KEY}.error-property-required`) : "", value: e.selectedProperty }, on: { select: e.selectProperty } }, "InSelect", e.invalidFieldAttrs(t.errors.attribute), !1)), a(e.InSelect, t._b({ staticClass: "guido-logic-builder-row__field", attrs: { id: e.fieldId("operator"), "search-status": "", "button-status": !1, "disabled-status": t.disabled, "label-status": !1, options: e.operatorOptions, "placeholder-text": e.trans(`${e.KEY}.select-operator`), state: e.fieldState(t.errors.operator), "state-message": t.errors.operator ? e.trans(`${e.KEY}.error-operator-required`) : "", value: e.selectedOperator }, on: { select: e.selectOperator } }, "InSelect", e.invalidFieldAttrs(t.errors.operator), !1)), e.valueKind === "multi-select" ? a(e.InMultiSelect, t._b({ staticClass: "guido-logic-builder-row__field", attrs: { id: e.fieldId("value"), "button-status": !1, "disabled-status": t.disabled, "label-status": !1, options: e.valueOptions, "placeholder-text": e.trans(`${e.KEY}.enter-value`), "select-all-option-status": !1, state: e.fieldState(t.errors.value), "state-message": e.valueError, value: e.selectedValues }, on: { change: e.selectValues } }, "InMultiSelect", e.invalidFieldAttrs(t.errors.value), !1)) : e.valueKind === "tags" ? a("div", { staticClass: "guido-logic-builder-row__field", on: { paste: e.pasteTags } }, [a(e.InTags, t._b({ attrs: { id: e.fieldId("value"), "allow-duplicates": !1, disable: t.disabled, invalid: !!t.errors.value, "invalid-message": e.valueError, placeholder: e.trans(`${e.KEY}.enter-value`), validate: e.validateTag, value: t.row.values }, on: { input: e.updateTags } }, "InTags", e.invalidFieldAttrs(t.errors.value), !1))], 1) : e.valueKind === "select" ? a(e.InSelect, t._b({ staticClass: "guido-logic-builder-row__field", attrs: { id: e.fieldId("value"), "button-status": !1, "disabled-status": t.disabled, "label-status": !1, options: e.valueOptions, "placeholder-text": e.trans(`${e.KEY}.enter-value`), state: e.fieldState(t.errors.value), "state-message": e.valueError, value: e.selectedValues }, on: { select: function(s) {
7
+ return e.update({ values: [s.value] });
8
+ } } }, "InSelect", e.invalidFieldAttrs(t.errors.value), !1)) : e.valueKind === "date" ? a(e.InDatePickerV2, t._b({ staticClass: "guido-logic-builder-row__field", attrs: { id: e.fieldId("value"), "single-date-picker-status": "", "disabled-status": t.disabled, "label-status": !1, locale: e.datePickerLocale, name: e.fieldId("value"), "placeholder-text": e.trans(`${e.KEY}.enter-value`), state: e.fieldState(t.errors.value), "state-message": e.valueError, value: e.isoToPickerDate(t.row.values[0] ?? "") }, on: { apply: function(s) {
9
+ e.update({ values: [e.pickerDateToIso(s)] });
10
+ } } }, "InDatePickerV2", e.invalidFieldAttrs(t.errors.value), !1)) : a(e.InBasicTextInput, t._b({ staticClass: "guido-logic-builder-row__field", attrs: { id: e.fieldId("value"), type: "text", "character-counter-status": !1, "disabled-status": t.disabled, "label-status": !1, name: e.fieldId("value"), "placeholder-text": e.trans(`${e.KEY}.enter-value`), "state-message": e.valueError, states: e.fieldState(t.errors.value), "tooltip-status": !1, value: t.row.values[0] ?? "" }, on: { input: function(s) {
11
+ return e.update({ values: [s] });
12
+ } } }, "InBasicTextInput", e.invalidFieldAttrs(t.errors.value), !1)), a("div", { staticClass: "guido-logic-builder-row__actions" }, [a(e.InButtonV2, { attrs: { id: e.fieldId("duplicate"), "left-icon": "line-copy", styling: "ghost", type: "primary", "disabled-status": t.disabled, "label-text-status": !1 }, on: { click: function(s) {
13
+ return e.emit("duplicate");
14
+ } } }), a(e.InButtonV2, { attrs: { id: e.fieldId("remove"), "left-icon": "line-delete", styling: "ghost", type: "danger", "disabled-status": t.disabled || t.removeDisabled, "label-text-status": !1 }, on: { click: function(s) {
15
+ return e.emit("remove");
16
+ } } })], 1)], 1);
17
+ }, o = [], d = /* @__PURE__ */ r(
18
+ l,
19
+ i,
20
+ o,
21
+ !1,
22
+ null,
23
+ "8a2effc2"
24
+ );
25
+ const p = d.exports;
26
+ export {
27
+ p as default
28
+ };
@@ -0,0 +1,60 @@
1
+ import { defineComponent as V, computed as a } from "vue";
2
+ import { DISPLAY_CONDITIONS_TRANS_KEY as u } from "../../../composables/useDisplayConditions.js";
3
+ import { invalidFieldAttrs as B } from "../../../composables/useScrollToInvalid.js";
4
+ import { useTranslations as E } from "../../../composables/useTranslations.js";
5
+ import { locale as F } from "../../../utils/dateUtil.js";
6
+ import { isMultiValue as M, withAttribute as N, withOperator as K } from "../../../utils/displayConditionBuilder.js";
7
+ import { operatorsFor as L, isValidRuleValue as Y } from "../../../utils/displayConditionRules.js";
8
+ import { OPERATOR_TRANS_SUFFIX as C } from "../../../utils/displayConditionSummary.js";
9
+ import { InTags as q, InSelect as G, InMultiSelect as U, InDatePickerV2 as X, InButtonV2 as j, InBasicTextInput as z } from "@useinsider/design-system-vue";
10
+ const lt = /* @__PURE__ */ V({
11
+ __name: "LogicBuilderRow",
12
+ props: {
13
+ row: null,
14
+ errors: null,
15
+ customAttributes: null,
16
+ defaultAttributes: null,
17
+ disabled: { type: Boolean },
18
+ removeDisabled: { type: Boolean }
19
+ },
20
+ emits: ["update", "duplicate", "remove"],
21
+ setup(y, { emit: i }) {
22
+ const e = y, l = E(), A = F(), $ = (t) => `guido__display-condition-rule-${t}-${e.row.id}`, m = (t) => ({ text: t.label, value: t.key }), T = a(() => [
23
+ { text: l(`${u}.custom-attributes`), value: "guido-custom-attributes", list: e.customAttributes },
24
+ { text: l(`${u}.default-attributes`), value: "guido-default-attributes", list: e.defaultAttributes }
25
+ ].filter(({ list: t }) => t.length).map(({ text: t, value: r, list: o }) => ({ text: t, value: r, children: o.map(m) }))), p = a(() => [...e.customAttributes, ...e.defaultAttributes].find((t) => t.key === e.row.attribute)), g = a(() => {
26
+ var t;
27
+ return e.row.attribute ? [{ text: ((t = p.value) == null ? void 0 : t.label) ?? e.row.attribute, value: e.row.attribute }] : [];
28
+ }), v = a(() => L(e.row.type).map((t) => ({
29
+ text: l(`${u}.operator-${C[t]}`),
30
+ value: t
31
+ }))), _ = a(() => v.value.filter((t) => t.value === e.row.operator)), n = a(() => {
32
+ var t;
33
+ return e.row.type === "boolean" ? [
34
+ { text: l(`${u}.value-true`), value: "true" },
35
+ { text: l(`${u}.value-false`), value: "false" }
36
+ ] : (((t = p.value) == null ? void 0 : t.options) ?? []).map((r) => ({ text: r.label, value: r.value }));
37
+ }), f = a(() => M(e.row.operator)), x = a(() => n.value.filter((t) => e.row.values.includes(t.value))), I = a(() => f.value ? n.value.length ? "multi-select" : "tags" : n.value.length ? "select" : e.row.type === "date" ? "date" : "text"), O = a(() => e.errors.value ? e.row.values.some((t) => t.trim()) ? l(`${u}.error-value-invalid`) : l(`${u}.error-value-required`) : ""), S = (t) => t ? "error" : "default", c = (t) => i("update", { ...e.row, ...t }), k = (t) => {
38
+ const r = [...e.customAttributes, ...e.defaultAttributes].find((o) => o.key === t.value);
39
+ r && r.key !== e.row.attribute && i("update", N(e.row, r));
40
+ }, D = (t) => c({ values: t.map((r) => r.value) }), h = (t) => {
41
+ t.value !== e.row.operator && i("update", K(e.row, t.value));
42
+ }, P = (t) => {
43
+ const [r, o, s] = t.split("-");
44
+ return r && o && s ? `${o}/${s}/${r}` : "";
45
+ }, R = (t) => {
46
+ const [r, o, s] = t.split("/");
47
+ return s && r && o ? `${s}-${r.padStart(2, "0")}-${o.padStart(2, "0")}` : "";
48
+ }, d = /[,\r\n]/, b = (t) => Y(e.row.type, t), w = (t) => c({
49
+ values: [...new Set(t.flatMap((r) => r.split(d)).map((r) => r.trim()).filter(b))]
50
+ });
51
+ return { __sfc: !0, props: e, emit: i, trans: l, datePickerLocale: A, fieldId: $, toOption: m, propertyOptions: T, attribute: p, selectedProperty: g, operatorOptions: v, selectedOperator: _, valueOptions: n, isMulti: f, selectedValues: x, valueKind: I, valueError: O, fieldState: S, update: c, selectProperty: k, selectValues: D, selectOperator: h, isoToPickerDate: P, pickerDateToIso: R, TAG_SEPARATOR: d, validateTag: b, updateTags: w, pasteTags: (t) => {
52
+ var o;
53
+ const r = ((o = t.clipboardData) == null ? void 0 : o.getData("text")) ?? "";
54
+ d.test(r) && (t.preventDefault(), w([...e.row.values, r]));
55
+ }, KEY: u, invalidFieldAttrs: B, InBasicTextInput: z, InButtonV2: j, InDatePickerV2: X, InMultiSelect: U, InSelect: G, InTags: q };
56
+ }
57
+ });
58
+ export {
59
+ lt as default
60
+ };