@useinsider/guido 3.20.1-beta.49b58ed → 3.20.1-beta.55d63aa

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 (135) hide show
  1. package/README.md +1 -1
  2. package/dist/@types/config/schemas.js +38 -37
  3. package/dist/@types/display-condition.js +25 -0
  4. package/dist/components/Guido.vue.js +6 -6
  5. package/dist/components/Guido.vue2.js +101 -112
  6. package/dist/components/organisms/AutoSaveController.vue2.js +9 -19
  7. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +20 -0
  8. package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +30 -0
  9. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
  10. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +71 -0
  11. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +34 -0
  12. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +57 -0
  13. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
  14. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
  15. package/dist/components/organisms/header/AutoSaveToggle.vue.js +22 -0
  16. package/dist/components/organisms/header/AutoSaveToggle.vue2.js +19 -0
  17. package/dist/components/organisms/header/EditorActions.vue.js +13 -13
  18. package/dist/components/organisms/header/EditorActions.vue2.js +72 -57
  19. package/dist/components/organisms/header/HeaderWrapper.vue.js +6 -6
  20. package/dist/components/organisms/header/HeaderWrapper.vue2.js +17 -9
  21. package/dist/components/organisms/header/LeftSlot.vue.js +1 -1
  22. package/dist/components/organisms/header/LeftSlot.vue2.js +23 -28
  23. package/dist/components/organisms/header/MiddleSlot.vue.js +4 -4
  24. package/dist/components/organisms/header/MiddleSlot.vue2.js +7 -8
  25. package/dist/components/organisms/header/RightSlot.vue.js +8 -9
  26. package/dist/components/organisms/header/RightSlot.vue2.js +18 -13
  27. package/dist/components/organisms/onboarding/OnboardingWrapper.vue.js +12 -12
  28. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +35 -60
  29. package/dist/composables/useBlocksConfig.js +32 -24
  30. package/dist/composables/useCustomInterfaceAppearance.js +41 -42
  31. package/dist/composables/useDisplayConditions.js +111 -0
  32. package/dist/composables/useLegacyStrategyConversion.js +16 -16
  33. package/dist/composables/useStripo.js +4 -3
  34. package/dist/config/i18n/en/labels.json.js +4 -36
  35. package/dist/config/i18n/en/tooltips.json.js +1 -2
  36. package/dist/enums/academy.js +1 -0
  37. package/dist/enums/display-condition.js +12 -0
  38. package/dist/extensions/Blocks/Items/block.js +43 -42
  39. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +296 -223
  40. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +219 -205
  41. package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +19 -0
  42. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +51 -36
  43. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +31 -35
  44. package/dist/extensions/DisplayConditions/bridge.js +17 -0
  45. package/dist/extensions/DisplayConditions/constants.js +17 -0
  46. package/dist/extensions/DisplayConditions/control.js +169 -0
  47. package/dist/extensions/DisplayConditions/display-conditions.css.js +201 -0
  48. package/dist/extensions/DisplayConditions/extension.js +28 -0
  49. package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
  50. package/dist/extensions/DisplayConditions/library.js +25 -0
  51. package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
  52. package/dist/guido.css +1 -1
  53. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +272 -192
  54. package/dist/node_modules/valibot/dist/index.js +297 -261
  55. package/dist/package.json.js +1 -1
  56. package/dist/services/displayConditionApi.js +39 -0
  57. package/dist/sprite.svg +0 -10
  58. package/dist/src/@types/config/schemas.d.ts +4 -2
  59. package/dist/src/@types/display-condition.d.ts +59 -0
  60. package/dist/src/components/organisms/AutoSaveController.vue.d.ts +1 -19
  61. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
  62. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +19 -1
  63. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +19 -1
  64. package/dist/src/composables/useActionsApi.d.ts +2 -2
  65. package/dist/src/composables/useConfig.d.ts +2 -2
  66. package/dist/src/composables/useDisplayConditions.d.ts +16 -0
  67. package/dist/src/enums/academy.d.ts +1 -0
  68. package/dist/src/enums/display-condition.d.ts +15 -0
  69. package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +1 -0
  70. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +8 -0
  71. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +40 -0
  72. package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +1 -0
  73. package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +1 -0
  74. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +11 -0
  75. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +7 -0
  76. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +2 -0
  77. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +18 -3
  78. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +7 -0
  79. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +7 -0
  80. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +7 -0
  81. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +7 -0
  82. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +7 -0
  83. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +7 -0
  84. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +8 -1
  85. package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +17 -0
  86. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +7 -0
  87. package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +1 -0
  88. package/dist/src/extensions/Blocks/controlFactories.d.ts +22 -0
  89. package/dist/src/extensions/DisplayConditions/bridge.d.ts +6 -0
  90. package/dist/src/extensions/DisplayConditions/constants.d.ts +14 -0
  91. package/dist/src/extensions/DisplayConditions/control.d.ts +21 -0
  92. package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
  93. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
  94. package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
  95. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
  96. package/dist/src/mock/api/display-conditions.d.ts +2 -0
  97. package/dist/src/services/displayConditionApi.d.ts +9 -0
  98. package/dist/src/stores/autosave.d.ts +1 -73
  99. package/dist/src/stores/config.d.ts +20 -20
  100. package/dist/src/stores/display-condition.d.ts +81 -0
  101. package/dist/src/stores/editor.d.ts +0 -109
  102. package/dist/src/stores/onboarding.d.ts +21 -953
  103. package/dist/src/stores/version-history.d.ts +1 -1
  104. package/dist/src/utils/displayCondition.d.ts +4 -0
  105. package/dist/src/utils/protectTableText.d.ts +2 -0
  106. package/dist/src/utils/timeUtil.d.ts +0 -5
  107. package/dist/static/styles/components/button.css.js +5 -0
  108. package/dist/static/styles/variables.css.js +0 -2
  109. package/dist/stores/autosave.js +7 -12
  110. package/dist/stores/display-condition.js +28 -0
  111. package/dist/stores/editor.js +4 -7
  112. package/dist/stores/onboarding.js +21 -48
  113. package/dist/utils/displayCondition.js +21 -0
  114. package/dist/utils/pairProductVariables.js +15 -14
  115. package/dist/utils/protectTableText.js +22 -0
  116. package/dist/utils/timeUtil.js +17 -6
  117. package/package.json +3 -3
  118. package/dist/components/organisms/header/AutoSaveStatus.vue.js +0 -17
  119. package/dist/components/organisms/header/AutoSaveStatus.vue2.js +0 -25
  120. package/dist/components/organisms/header/EditorActionsMenu.vue.js +0 -20
  121. package/dist/components/organisms/header/EditorActionsMenu.vue2.js +0 -98
  122. package/dist/components/organisms/header/accessibility/AccessibilityToolbar.vue.js +0 -18
  123. package/dist/components/organisms/header/accessibility/AccessibilityToolbar.vue2.js +0 -37
  124. package/dist/components/organisms/header/accessibility/ColorVisionSelect.vue.js +0 -22
  125. package/dist/components/organisms/header/accessibility/ColorVisionSelect.vue2.js +0 -48
  126. package/dist/components/organisms/onboarding/EditorTabBarOnboarding.vue.js +0 -19
  127. package/dist/components/organisms/onboarding/EditorTabBarOnboarding.vue2.js +0 -90
  128. package/dist/composables/useAccessibilityApi.js +0 -45
  129. package/dist/src/components/organisms/onboarding/EditorTabBarOnboarding.vue.d.ts +0 -2
  130. package/dist/src/composables/useAccessibilityApi.d.ts +0 -13
  131. package/dist/static/styles/components/accessibility.css.js +0 -234
  132. /package/dist/src/components/organisms/{header/AutoSaveStatus.vue.d.ts → display-conditions/DisplayConditionCreateDrawer.vue.d.ts} +0 -0
  133. /package/dist/src/components/organisms/{header/EditorActionsMenu.vue.d.ts → display-conditions/DisplayConditionSelectDrawer.vue.d.ts} +0 -0
  134. /package/dist/src/components/organisms/{header/accessibility/AccessibilityToolbar.vue.d.ts → display-conditions/DisplayConditionsHost.vue.d.ts} +0 -0
  135. /package/dist/src/components/organisms/header/{accessibility/ColorVisionSelect.vue.d.ts → AutoSaveToggle.vue.d.ts} +0 -0
@@ -0,0 +1,19 @@
1
+ import { useRecommendationExtensionStore as u } from "../store/recommendation.js";
2
+ import { commitBlockChangeOutsidePanel as d } from "./nodeConfigWriter.js";
3
+ async function l(e, { pickUpdates: n, description: i, fetch: s = !0 }) {
4
+ const t = u(), r = t.blockStates[e];
5
+ if (!r)
6
+ return !1;
7
+ const { configVersion: c, adoptedSizeVersion: a } = r, f = n(r.recommendationConfigs);
8
+ if (s)
9
+ try {
10
+ await t.fetchRecommendationProductsForBlock(e);
11
+ } catch (m) {
12
+ console.error("[recommendation] product refetch outside the panel failed", m);
13
+ }
14
+ const o = t.blockStates[e];
15
+ return o ? o.configVersion !== c || o.adoptedSizeVersion !== a ? l(e, { pickUpdates: n, description: i }) : d(e, f, o.recommendationProducts, i) : !1;
16
+ }
17
+ export {
18
+ l as refreshBlockOutsidePanel
19
+ };
@@ -1,53 +1,68 @@
1
- import { ModificationDescription as s } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { RECOMMENDATION_ID_ATTR as a } from "../constants/selectors.js";
3
- import { isPartnerManagedBlock as C, updateProductContentInPlace as p, regenerateProductRowsWithStyles as y } from "../controls/main/utils.js";
4
- import { RecommendationConfigService as m } from "../services/configService.js";
5
- import { useRecommendationExtensionStore as N } from "../store/recommendation.js";
6
- let n = null;
7
- function B(e) {
8
- n = e;
9
- }
10
- function S(e, t) {
11
- const o = N(), i = o.currentRecommendationId;
12
- if (i === e || !o.blockStates[e]) {
13
- t();
1
+ import { ModificationDescription as g } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { RECOMMENDATION_ID_ATTR as l } from "../constants/selectors.js";
3
+ import { isPartnerManagedBlock as m, updateProductContentInPlace as d, regenerateProductRowsWithStyles as C } from "../controls/main/utils.js";
4
+ import { RecommendationConfigService as c } from "../services/configService.js";
5
+ import { useRecommendationExtensionStore as y } from "../store/recommendation.js";
6
+ let r = null;
7
+ function M(n) {
8
+ r = n;
9
+ }
10
+ function a(n) {
11
+ const e = r == null ? void 0 : r.getDocumentRootHtmlNode();
12
+ return !e || !("querySelector" in e) ? null : e.querySelector(`[${l}="${n}"]`) ?? null;
13
+ }
14
+ function N(n, e) {
15
+ const o = c.getConfig(n);
16
+ return Object.keys(e).some((t) => JSON.stringify(o[t]) !== JSON.stringify(e[t]));
17
+ }
18
+ function S(n, e) {
19
+ const o = c.getConfig(n);
20
+ return ["filters", "strategy", "strategyId", "size"].some((t) => t in e && JSON.stringify(o[t]) !== JSON.stringify(e[t]));
21
+ }
22
+ function P(n, e, o) {
23
+ const t = a(n);
24
+ return !r || !t ? !1 : (S(t, e) && c.updateConfig(r, t, e, o), !0);
25
+ }
26
+ function p(n, e) {
27
+ const o = y(), t = o.currentRecommendationId;
28
+ if (t === n || !o.blockStates[n]) {
29
+ e();
14
30
  return;
15
31
  }
16
- o.setCurrentBlock(e);
32
+ o.setCurrentBlock(n);
17
33
  try {
18
- t();
34
+ e();
19
35
  } finally {
20
- o.$patch({ currentRecommendationId: i });
36
+ o.$patch({ currentRecommendationId: t });
21
37
  }
22
38
  }
23
- function P(e) {
24
- const t = n == null ? void 0 : n.getDocumentRootHtmlNode();
25
- return !t || !("querySelectorAll" in t) ? [] : t.querySelectorAll(`[${a}="${e}"]`).map((o) => m.getConfig(o));
39
+ function I(n) {
40
+ const e = r == null ? void 0 : r.getDocumentRootHtmlNode();
41
+ return !e || !("querySelectorAll" in e) ? [] : e.querySelectorAll(`[${l}="${n}"]`).map((o) => c.getConfig(o));
26
42
  }
27
- function $(e, t, o, i) {
28
- const f = n == null ? void 0 : n.getDocumentRootHtmlNode();
29
- if (!n || !f || !("querySelector" in f))
30
- return !1;
31
- const r = f.querySelector(`[${a}="${e}"]`);
32
- if (!r)
43
+ function $(n, e, o, t) {
44
+ const i = a(n);
45
+ if (!r || !i)
33
46
  return !1;
34
- const c = n.getDocumentModifier(), d = m.getConfig(r), g = Object.keys(t).some((l) => JSON.stringify(d[l]) !== JSON.stringify(t[l]));
35
- if (m.stageConfig(c, r, t), C(r))
36
- return c.apply(new s(i)), !0;
47
+ const f = r.getDocumentModifier(), s = N(i, e);
48
+ if (c.stageConfig(f, i, e), m(i))
49
+ return s && f.apply(new g(t)), !0;
37
50
  let u = !1;
38
- return S(e, () => {
39
- p({
40
- currentNode: r,
41
- documentModifier: c,
51
+ return p(n, () => {
52
+ d({
53
+ currentNode: i,
54
+ documentModifier: f,
42
55
  products: o,
43
56
  onApplied: () => {
44
57
  u = !0;
45
58
  }
46
- }) || (u = y({ currentNode: r, documentModifier: c, products: o }));
47
- }), !u && g && c.apply(new s(i)), !0;
59
+ }) || (u = C({ currentNode: i, documentModifier: f, products: o }));
60
+ }), !u && s && f.apply(new g(t)), !0;
48
61
  }
49
62
  export {
50
63
  $ as commitBlockChangeOutsidePanel,
51
- P as readBlockNodeConfigs,
52
- B as registerNodeConfigWriter
64
+ S as hasEditedConfigChange,
65
+ I as readBlockNodeConfigs,
66
+ M as registerNodeConfigWriter,
67
+ P as writeBlockConfigOutsidePanel
53
68
  };
@@ -1,47 +1,43 @@
1
1
  import { useRecommendationExtensionStore as g } from "../store/recommendation.js";
2
- import { toBlockUrlConfig as m } from "./blockUrlConfig.js";
3
- import { commitBlockChangeOutsidePanel as d, readBlockNodeConfigs as y } from "./nodeConfigWriter.js";
4
- function l(t, o) {
5
- const r = JSON.stringify(m(o));
6
- return y(t).find((e) => JSON.stringify(m(e)) !== r) ?? o;
2
+ import { refreshBlockOutsidePanel as y } from "./blockRefresh.js";
3
+ import { toBlockUrlConfig as a } from "./blockUrlConfig.js";
4
+ import { commitBlockChangeOutsidePanel as l, readBlockNodeConfigs as S } from "./nodeConfigWriter.js";
5
+ function d(e, t) {
6
+ const r = JSON.stringify(a(t));
7
+ return S(e).find((o) => JSON.stringify(a(o)) !== r) ?? t;
7
8
  }
8
- async function C(t, o, r) {
9
- const e = g(), c = [t, o];
10
- (/* @__PURE__ */ new Map([[t, l(t, r)], [o, r]])).forEach((n, s) => {
11
- var a;
12
- (!!n.strategyId || s === o) && ((a = e.blockStates[s]) == null ? void 0 : a.recommendationConfigs.strategyId) !== n.strategyId && e.seedBlockUrlConfig(s, m(n));
13
- }), e.resetArrivedBlock(o), await Promise.all(c.map(async (n) => {
14
- if (!await e.refreshStrategyBlock(n))
9
+ async function p(e, t, r) {
10
+ const o = g(), s = [e, t];
11
+ (/* @__PURE__ */ new Map([[e, d(e, r)], [t, r]])).forEach((n, i) => {
12
+ var m;
13
+ (!!n.strategyId || i === t) && ((m = o.blockStates[i]) == null ? void 0 : m.recommendationConfigs.strategyId) !== n.strategyId && o.seedBlockUrlConfig(i, a(n));
14
+ }), o.resetArrivedBlock(t), await Promise.all(s.map(async (n) => {
15
+ if (!await o.refreshStrategyBlock(n))
15
16
  return;
16
- const { recommendationConfigs: s, recommendationProducts: i } = e.blockStates[n];
17
- d(
17
+ const { recommendationConfigs: i, recommendationProducts: f } = o.blockStates[n];
18
+ l(
18
19
  n,
19
- { size: s.size },
20
- i,
20
+ { size: i.size },
21
+ f,
21
22
  "Refresh duplicated recommendation strategy"
22
23
  );
23
24
  }));
24
25
  }
25
- async function B(t, o) {
26
- const r = g(), e = r.blockStates[t];
27
- if (!e)
26
+ async function k(e, t) {
27
+ if (!g().blockStates[e])
28
28
  return !1;
29
- const { strategyId: c, strategy: f, size: n, nodeConfigVersion: s } = e.recommendationConfigs;
30
- if (r.currentRecommendationId === t)
31
- try {
32
- await r.fetchRecommendationProducts();
33
- } catch (a) {
34
- console.error("[recommendation] product refetch after a strategy change failed", a);
35
- }
36
- const i = d(
37
- t,
38
- { strategyId: c, strategy: f, size: n, configVersion: s },
39
- e.recommendationProducts,
40
- o
41
- );
42
- return i || console.error("[recommendation] strategy change did not reach a node", { blockId: t }), i;
29
+ const r = await y(e, {
30
+ pickUpdates: ({ strategyId: o, strategy: s, size: c, nodeConfigVersion: n }) => ({
31
+ strategyId: o,
32
+ strategy: s,
33
+ size: c,
34
+ configVersion: n
35
+ }),
36
+ description: t
37
+ });
38
+ return r || console.error("[recommendation] strategy change did not reach a node", { blockId: e }), r;
43
39
  }
44
40
  export {
45
- B as commitStrategyChange,
46
- C as refreshDuplicatedStrategyBlocks
41
+ k as commitStrategyChange,
42
+ p as refreshDuplicatedStrategyBlocks
47
43
  };
@@ -0,0 +1,17 @@
1
+ import { DisplayConditionEvent as e } from "../../enums/display-condition.js";
2
+ let n = null;
3
+ const p = (E, t) => {
4
+ n == null || n();
5
+ const i = (o) => {
6
+ n == null || n(), t.onApply(o.detail.condition);
7
+ }, m = () => {
8
+ var o;
9
+ n == null || n(), (o = t.onCancel) == null || o.call(t);
10
+ };
11
+ document.addEventListener(e.APPLY, i), document.addEventListener(e.CANCEL, m), n = () => {
12
+ document.removeEventListener(e.APPLY, i), document.removeEventListener(e.CANCEL, m), n = null;
13
+ }, document.dispatchEvent(new CustomEvent(e.OPEN, { detail: E }));
14
+ };
15
+ export {
16
+ p as requestDisplayCondition
17
+ };
@@ -0,0 +1,17 @@
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", c = 10, s = [o.STRIPE, o.STRUCTURE, o.CONTAINER], d = {
3
+ PLUS: "guido-display-condition-plus",
4
+ EDIT: "guido-display-condition-edit",
5
+ TRASH: "guido-display-condition-trash",
6
+ CHEVRON: "guido-display-condition-chevron"
7
+ }, e = ["applyConditionSwitcher", "applyCondition", "displayConditions"], I = "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.";
8
+ export {
9
+ O as APPLIED_DESCRIPTION,
10
+ e as BUILT_IN_CONDITION_CONTROLS,
11
+ t as CONDITIONS_CONTROL_ID,
12
+ n as CONDITIONS_TAB_ID,
13
+ s as CONDITION_BLOCK_TYPES,
14
+ d as CONDITION_ICONS,
15
+ I as EMPTY_DESCRIPTION,
16
+ c as MAX_COLLAPSED_LINES
17
+ };
@@ -0,0 +1,169 @@
1
+ var $ = Object.defineProperty;
2
+ var S = (d, s, t) => s in d ? $(d, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[s] = t;
3
+ var h = (d, s, t) => S(d, typeof s != "symbol" ? s + "" : s, t);
4
+ import { CommonControl as O } from "../Blocks/common-control.js";
5
+ import { parseSource as N } from "../../utils/displayCondition.js";
6
+ import { escapeHtml as C } from "../../utils/htmlEscape.js";
7
+ import { ModificationDescription as D, UIElementType as b, UEAttr as w } from "../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
8
+ import { requestDisplayCondition as I } from "./bridge.js";
9
+ import { CONDITIONS_CONTROL_ID as x, APPLIED_DESCRIPTION as E, EMPTY_DESCRIPTION as T, MAX_COLLAPSED_LINES as v, CONDITION_ICONS as g } from "./constants.js";
10
+ const p = ".guido-display-conditions", M = { id: 0, name: "", description: "", beforeScript: "", afterScript: "" }, _ = (d) => `<${b.ICON} ${w.ICON.src}="${d}"></${b.ICON}>`, l = (d, s, t, i = !1) => `<button type="button" class="${s}" id="${d}"${i ? " hidden" : ""}>${t}</button>`;
11
+ class B extends O {
12
+ constructor() {
13
+ super(...arguments);
14
+ h(this, "expanded", !1);
15
+ h(this, "listeners", []);
16
+ h(this, "resizeObserver", null);
17
+ }
18
+ getId() {
19
+ return x;
20
+ }
21
+ getTemplate() {
22
+ return `
23
+ <div class="guido-display-conditions">
24
+ <div class="guido-display-conditions__header">
25
+ <p class="guido-display-conditions__title">${this.api.translate("Display Conditions")}</p>
26
+ <p class="guido-display-conditions__description" data-dc-description></p>
27
+ </div>
28
+ <div class="guido-display-conditions__empty" data-dc-empty>
29
+ ${l(
30
+ "guido__btn-add-display-condition",
31
+ "guido-display-conditions__add",
32
+ `${_(g.PLUS)}<span>${this.api.translate("Add Display Condition")}</span>`
33
+ )}
34
+ <div class="guido-display-conditions__menu" data-dc-menu hidden>
35
+ ${l(
36
+ "guido__btn-display-condition-create",
37
+ "guido-display-conditions__menu-item",
38
+ this.api.translate("Create New Condition")
39
+ )}
40
+ ${l(
41
+ "guido__btn-display-condition-select",
42
+ "guido-display-conditions__menu-item",
43
+ this.api.translate("Select Saved Condition")
44
+ )}
45
+ </div>
46
+ </div>
47
+ <div class="guido-display-conditions__applied" data-dc-applied hidden>
48
+ <div class="guido-display-conditions__code-box">
49
+ <p class="guido-display-conditions__name" data-dc-name></p>
50
+ <div class="guido-display-conditions__sections" data-dc-sections>
51
+ <p class="guido-display-conditions__section-label">
52
+ ${this.api.translate("Code Before Module")}
53
+ </p>
54
+ <pre class="guido-display-conditions__code" data-dc-before></pre>
55
+ <p class="guido-display-conditions__section-label" data-dc-after-label>
56
+ ${this.api.translate("Code After Module")}
57
+ </p>
58
+ <pre class="guido-display-conditions__code" data-dc-after></pre>
59
+ </div>
60
+ ${l(
61
+ "guido__btn-display-condition-toggle",
62
+ "guido-display-conditions__toggle",
63
+ `${_(g.CHEVRON)}<span data-dc-toggle-label></span>`,
64
+ !0
65
+ )}
66
+ </div>
67
+ <div class="guido-display-conditions__actions">
68
+ ${l(
69
+ "guido__btn-edit-display-condition",
70
+ "guido-display-conditions__action guido-display-conditions__action--edit",
71
+ `${_(g.EDIT)}<span>${this.api.translate("Edit")}</span>`
72
+ )}
73
+ ${l(
74
+ "guido__btn-remove-display-condition",
75
+ "guido-display-conditions__action guido-display-conditions__action--remove",
76
+ `${_(g.TRASH)}<span>${this.api.translate("Remove")}</span>`
77
+ )}
78
+ </div>
79
+ </div>
80
+ </div>
81
+ `;
82
+ }
83
+ onRender() {
84
+ this.teardown(), this.wire("#guido__btn-add-display-condition", () => this.toggleMenu()), this.wire("#guido__btn-display-condition-create", () => this.openDrawer("create")), this.wire("#guido__btn-display-condition-select", () => this.openDrawer("select")), this.wire("#guido__btn-edit-display-condition", () => this.openDrawer("edit")), this.wire("#guido__btn-remove-display-condition", () => this.applyCondition(null)), this.wire("#guido__btn-display-condition-toggle", () => {
85
+ this.expanded = !this.expanded, this.paint();
86
+ }), this.observeCodeSize(), this.paint();
87
+ }
88
+ onTemplateNodeUpdated(t) {
89
+ const i = t !== this.currentNode;
90
+ super.onTemplateNodeUpdated(t), i && (this.expanded = !1), this.paint();
91
+ }
92
+ onDestroy() {
93
+ super.onDestroy(), this.teardown();
94
+ }
95
+ getCondition() {
96
+ var e;
97
+ const t = this.currentNode, i = (e = t == null ? void 0 : t.getDisplayCondition) == null ? void 0 : e.call(t);
98
+ return !i || !(i.name || i.beforeScript || i.afterScript) ? null : { ...i, description: i.description ?? "" };
99
+ }
100
+ toggleMenu(t) {
101
+ var n, o;
102
+ const i = (n = this.getContainer()) == null ? void 0 : n.querySelector(`${p} [data-dc-menu]`);
103
+ if (!i)
104
+ return;
105
+ i.hidden = t === void 0 ? !i.hidden : !t;
106
+ const e = (o = this.getContainer()) == null ? void 0 : o.querySelector(`${p} #guido__btn-add-display-condition`);
107
+ i.style.width = !i.hidden && e ? `${e.getBoundingClientRect().width}px` : "";
108
+ }
109
+ openDrawer(t) {
110
+ this.toggleMenu(!1), I(
111
+ { mode: t, current: t === "edit" ? this.getCondition() : null },
112
+ { onApply: (i) => this.applyCondition(i) }
113
+ );
114
+ }
115
+ applyCondition(t) {
116
+ if (!this.currentNode)
117
+ return;
118
+ const i = this.api.getDocumentModifier().modifyHtml(this.currentNode);
119
+ t ? i.setDisplayCondition(t) : i.setDisplayCondition(M), i.apply(new D(
120
+ t ? `Set display condition ${t.name}` : "Remove display condition"
121
+ ));
122
+ }
123
+ wire(t, i) {
124
+ var n;
125
+ const e = (n = this.getContainer()) == null ? void 0 : n.querySelector(`${p} ${t}`);
126
+ e && (e.addEventListener("click", i), this.listeners.push({ element: e, handler: i }));
127
+ }
128
+ teardown() {
129
+ var t;
130
+ this.listeners.forEach(({ element: i, handler: e }) => i.removeEventListener("click", e)), this.listeners = [], (t = this.resizeObserver) == null || t.disconnect(), this.resizeObserver = null;
131
+ }
132
+ // Line counts depend on layout: the panel font loads late and the panel can be resized.
133
+ observeCodeSize() {
134
+ var i;
135
+ const t = (i = this.getContainer()) == null ? void 0 : i.querySelectorAll(`${p} .guido-display-conditions__code`);
136
+ !(t != null && t.length) || typeof ResizeObserver > "u" || (this.resizeObserver = new ResizeObserver(() => this.paint()), t.forEach((e) => {
137
+ var n;
138
+ return (n = this.resizeObserver) == null ? void 0 : n.observe(e);
139
+ }));
140
+ }
141
+ paint() {
142
+ var f;
143
+ const t = (f = this.getContainer()) == null ? void 0 : f.querySelector(p);
144
+ if (!t)
145
+ return;
146
+ const i = this.getCondition(), e = (u) => t.querySelector(u);
147
+ if (e("[data-dc-empty]").hidden = !!i, e("[data-dc-applied]").hidden = !i, e("[data-dc-description]").textContent = this.api.translate(i ? E : T), !i)
148
+ return;
149
+ e("[data-dc-name]").textContent = i.name, e("#guido__btn-edit-display-condition").hidden = N(i) !== "inline";
150
+ const n = e("[data-dc-sections]"), o = e("[data-dc-before]"), a = e("[data-dc-after]");
151
+ o.innerHTML = C(i.beforeScript), a.innerHTML = C(i.afterScript), a.hidden = !i.afterScript, e("[data-dc-after-label]").hidden = !i.afterScript, n.style.maxHeight = "";
152
+ const r = parseFloat(getComputedStyle(o).lineHeight) || 24, c = (u) => u.hidden ? 0 : Math.round(u.scrollHeight / r), y = c(o) + c(a) > v, m = e("#guido__btn-display-condition-toggle");
153
+ m.hidden = !y, m.classList.toggle("is-expanded", this.expanded), e("[data-dc-toggle-label]").textContent = this.api.translate(this.expanded ? "Show Less" : "Show More"), y && !this.expanded && (n.style.maxHeight = `${this.collapsedHeight(n, [o, a], r)}px`);
154
+ }
155
+ // Labels do not count toward the line limit, so the cut lands after the 10th rendered code line.
156
+ collapsedHeight(t, i, e) {
157
+ const { top: n } = t.getBoundingClientRect();
158
+ let o = v, a = 0;
159
+ return i.filter((r) => !r.hidden).forEach((r) => {
160
+ if (o <= 0)
161
+ return;
162
+ const c = Math.min(o, Math.round(r.scrollHeight / e));
163
+ a = r.getBoundingClientRect().top - n + c * e, o -= c;
164
+ }), a;
165
+ }
166
+ }
167
+ export {
168
+ B as DisplayConditionsControl
169
+ };
@@ -0,0 +1,201 @@
1
+ const n = `.guido-display-conditions {
2
+ display: flex;
3
+ flex-direction: column;
4
+ font-family: inherit;
5
+ }
6
+
7
+ .guido-display-conditions__header {
8
+ padding: 16px;
9
+ }
10
+
11
+ .guido-display-conditions__title {
12
+ margin: 0 0 8px;
13
+ color: var(--guido-color-gray-800);
14
+ font-size: 16px;
15
+ font-weight: 600;
16
+ line-height: 24px;
17
+ }
18
+
19
+ .guido-display-conditions__description {
20
+ margin: 0;
21
+ color: var(--guido-color-gray-600);
22
+ font-size: 13px;
23
+ line-height: 16px;
24
+ }
25
+
26
+ .guido-display-conditions__empty {
27
+ padding: 8px 16px 16px;
28
+ }
29
+
30
+ .guido-display-conditions__add {
31
+ display: flex;
32
+ gap: 8px;
33
+ align-items: center;
34
+ justify-content: center;
35
+ width: 100%;
36
+ height: 40px;
37
+ padding: 0 16px;
38
+ border: none;
39
+ border-radius: 4px;
40
+ background: var(--guido-color-primary-100);
41
+ color: var(--guido-color-primary-500);
42
+ font: inherit;
43
+ font-size: 15px;
44
+ line-height: 24px;
45
+ cursor: pointer;
46
+ }
47
+
48
+ /* Stripo draws registered icons at 100% of ue-icon-component (Figma: 20px glyph in a 24px box). */
49
+ .guido-display-conditions ue-icon-component {
50
+ display: inline-flex;
51
+ flex-shrink: 0;
52
+ align-items: center;
53
+ justify-content: center;
54
+ width: 24px;
55
+ height: 24px;
56
+ }
57
+
58
+ .guido-display-conditions ue-icon-component svg {
59
+ width: 20px;
60
+ height: 20px;
61
+ }
62
+
63
+ .guido-display-conditions__add:hover {
64
+ background: var(--guido-color-primary-200);
65
+ }
66
+
67
+ .guido-display-conditions__add:focus-visible,
68
+ .guido-display-conditions__action:focus-visible,
69
+ .guido-display-conditions__toggle:focus-visible {
70
+ outline: 2px solid var(--guido-color-primary-500);
71
+ outline-offset: 2px;
72
+ }
73
+
74
+ .guido-display-conditions__code-box {
75
+ display: flex;
76
+ flex-direction: column;
77
+ gap: 8px;
78
+ padding: 16px;
79
+ background: var(--guido-color-gray-0);
80
+ }
81
+
82
+ .guido-display-conditions__sections {
83
+ display: flex;
84
+ flex-direction: column;
85
+ gap: 8px;
86
+ overflow: hidden;
87
+ }
88
+
89
+ .guido-display-conditions__name,
90
+ .guido-display-conditions__section-label {
91
+ margin: 0;
92
+ color: var(--guido-color-gray-800);
93
+ font-size: 15px;
94
+ font-weight: 600;
95
+ line-height: 24px;
96
+ word-break: break-word;
97
+ }
98
+
99
+ .guido-display-conditions__code {
100
+ margin: 0;
101
+ color: #101727;
102
+ font-family: inherit;
103
+ font-size: 15px;
104
+ line-height: 24px;
105
+ white-space: pre-wrap;
106
+ word-break: break-word;
107
+ }
108
+
109
+ .guido-display-conditions__toggle {
110
+ display: inline-flex;
111
+ align-items: center;
112
+ align-self: flex-start;
113
+ padding: 8px 0;
114
+ border: none;
115
+ background: none;
116
+ color: var(--guido-color-primary-500);
117
+ font: inherit;
118
+ font-size: 15px;
119
+ line-height: 24px;
120
+ cursor: pointer;
121
+ }
122
+
123
+ .guido-display-conditions__toggle span {
124
+ padding: 0 8px;
125
+ }
126
+
127
+ .guido-display-conditions__toggle.is-expanded ue-icon-component {
128
+ transform: rotate(180deg);
129
+ }
130
+
131
+ .guido-display-conditions__actions {
132
+ display: flex;
133
+ gap: 16px;
134
+ align-items: center;
135
+ height: 48px;
136
+ padding: 0 8px;
137
+ background: var(--guido-color-white);
138
+ }
139
+
140
+ .guido-display-conditions__action {
141
+ display: inline-flex;
142
+ align-items: center;
143
+ padding: 8px;
144
+ border: none;
145
+ background: none;
146
+ font: inherit;
147
+ font-size: 15px;
148
+ line-height: 24px;
149
+ cursor: pointer;
150
+ }
151
+
152
+ .guido-display-conditions__action span {
153
+ padding: 0 8px;
154
+ }
155
+
156
+ .guido-display-conditions__action--edit {
157
+ color: var(--guido-color-primary-500);
158
+ }
159
+
160
+ .guido-display-conditions__action--remove {
161
+ color: var(--guido-color-danger-500);
162
+ }
163
+
164
+ .guido-display-conditions [hidden] {
165
+ display: none !important;
166
+ }
167
+
168
+ /* No positioned ancestor inside Stripo's clipping scroller: the menu keeps its static spot but escapes the clip. */
169
+ .guido-display-conditions__menu {
170
+ position: absolute;
171
+ z-index: 2;
172
+ margin-top: 4px;
173
+ padding: 4px 0;
174
+ border-radius: 4px;
175
+ background-color: #FFFFFF;
176
+ box-shadow: 0 4px 16px rgba(34, 41, 56, 0.16);
177
+ }
178
+
179
+ .guido-display-conditions__menu-item {
180
+ display: block;
181
+ width: 100%;
182
+ padding: 8px 16px;
183
+ border: 0;
184
+ background: none;
185
+ color: var(--guido-color-neutral-800);
186
+ cursor: pointer;
187
+ font: inherit;
188
+ font-size: 14px;
189
+ line-height: 24px;
190
+ text-align: left;
191
+ }
192
+
193
+ .guido-display-conditions__menu-item:hover,
194
+ .guido-display-conditions__menu-item:focus-visible {
195
+ background-color: var(--guido-color-neutral-100);
196
+ outline: none;
197
+ }
198
+ `;
199
+ export {
200
+ n as default
201
+ };
@@ -0,0 +1,28 @@
1
+ import { ExtensionBuilder as t } from "../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { APPLIED_DESCRIPTION as o, EMPTY_DESCRIPTION as i } from "./constants.js";
3
+ import { DisplayConditionsControl as e } from "./control.js";
4
+ import n from "./display-conditions.css.js";
5
+ import { DisplayConditionsIconsRegistry as s } from "./iconsRegistry.js";
6
+ import { DisplayConditionsLibrary as d } from "./library.js";
7
+ import { DisplayConditionsSettingsPanel as r } from "./settingsPanel.js";
8
+ const S = new t().addControl(e).withIconsRegistry(s).withSettingsPanelRegistry(r).withExternalDisplayCondition(d).withStyles(n).withLocalization({
9
+ en: {
10
+ Conditions: "Conditions",
11
+ "Display Conditions": "Display Conditions",
12
+ "Add Display Condition": "Add Display Condition",
13
+ "Create New Condition": "Create New Condition",
14
+ "Select Saved Condition": "Select Saved Condition",
15
+ [i]: i,
16
+ [o]: o,
17
+ Edit: "Edit",
18
+ Remove: "Remove",
19
+ "Show More": "Show More",
20
+ "Show Less": "Show Less",
21
+ "Code Before Module": "Code Before Module",
22
+ "Code After Module": "Code After Module",
23
+ "Insider Display Conditions": "Insider Display Conditions"
24
+ }
25
+ }).build();
26
+ export {
27
+ S as default
28
+ };
@@ -0,0 +1,20 @@
1
+ import { IconsRegistry as n } from "../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CONDITION_ICONS as r } from "./constants.js";
3
+ const h = 'fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"', s = (t, o, e = 1.3) => `
4
+ <svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 ${t} ${t}">
5
+ <path d="${o}" ${h} stroke-width="${e}"/>
6
+ </svg>`;
7
+ class g extends n {
8
+ registerIconsSvg(o) {
9
+ o[r.PLUS] = s(20, "M10 4v12M4 10h12", 1.5), o[r.EDIT] = s(
10
+ 20,
11
+ "M3.5 16.5h13M5 12.6 13.1 4.5a1.4 1.4 0 0 1 2 0l.4.4a1.4 1.4 0 0 1 0 2L7.4 15H5v-2.4Z"
12
+ ), o[r.TRASH] = s(
13
+ 20,
14
+ "M3.5 5.5h13M8 5.5V4h4v1.5M5 5.5l.8 11h8.4l.8-11M8.5 8.5v5M11.5 8.5v5"
15
+ ), o[r.CHEVRON] = s(20, "m5 7.5 5 5 5-5", 1.5);
16
+ }
17
+ }
18
+ export {
19
+ g as DisplayConditionsIconsRegistry
20
+ };