@combeenation/custom-code-sdk 0.0.1-alpha11 → 0.0.1-alpha13

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/dist/bundle.es.js CHANGED
@@ -1,517 +1,408 @@
1
- var te = Object.defineProperty;
2
- var K = (e) => {
3
- throw TypeError(e);
4
- };
5
- var ne = (e, n, t) => n in e ? te(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
6
- var d = (e, n, t) => ne(e, typeof n != "symbol" ? n + "" : n, t), D = (e, n, t) => n.has(e) || K("Cannot " + t);
7
- var i = (e, n, t) => (D(e, n, "read from private field"), t ? t.call(e) : n.get(e)), a = (e, n, t) => n.has(e) ? K("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t), u = (e, n, t, s) => (D(e, n, "write to private field"), s ? s.call(e, t) : n.set(e, t), t);
8
- import { z as r } from "zod";
9
- const Y = "0.0.1-alpha11";
10
- var O, C;
11
- class Me {
12
- constructor(n) {
13
- d(this, "id");
14
- a(this, O, "v1");
15
- a(this, C);
16
- var s, o;
17
- this.id = n;
18
- const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, O));
19
- if (u(this, C, t == null ? void 0 : t.getButtonSdkBridge(this.id)), !i(this, C))
20
- throw new Error(`Cannot access API for Button "${this.id}".`);
21
- }
22
- onRendered(n) {
23
- var t;
24
- return ((t = i(this, C)) == null ? void 0 : t.addOnRenderedCallback(n)) ?? { unsubscribe: () => {
25
- } };
26
- }
27
- onClick(n) {
28
- var t;
29
- return ((t = i(this, C)) == null ? void 0 : t.addOnClickCallback(n)) ?? { unsubscribe: () => {
30
- } };
31
- }
32
- async setVisible(n) {
33
- var t;
34
- await ((t = i(this, C)) == null ? void 0 : t.setVisible(n));
35
- }
36
- setText(n) {
37
- var t;
38
- (t = i(this, C)) == null || t.setText(n);
39
- }
40
- }
41
- O = new WeakMap(), C = new WeakMap();
42
- var T, p;
43
- class _e {
44
- constructor(n) {
45
- d(this, "id");
46
- a(this, T, "v1");
47
- a(this, p);
48
- var s, o;
49
- this.id = n;
50
- const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, T));
51
- if (u(this, p, t == null ? void 0 : t.getCheckboxSdkBridge(this.id)), !i(this, p))
52
- throw new Error(`Cannot access API for Checkbox "${this.id}".`);
53
- }
54
- onRendered(n) {
55
- var t;
56
- return ((t = i(this, p)) == null ? void 0 : t.addOnRenderedCallback(n)) ?? { unsubscribe: () => {
57
- } };
58
- }
59
- async setVisible(n) {
60
- var t;
61
- await ((t = i(this, p)) == null ? void 0 : t.setVisible(n));
62
- }
63
- }
64
- T = new WeakMap(), p = new WeakMap();
65
- var $, b;
66
- class Le {
67
- constructor(n) {
68
- d(this, "id");
69
- a(this, $, "v1");
70
- a(this, b);
71
- var s, o;
72
- this.id = n;
73
- const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, $));
74
- if (u(this, b, t == null ? void 0 : t.getCollapsibleSdkBridge(this.id)), !i(this, b))
75
- throw new Error(`Cannot access API for Collapsible "${this.id}".`);
76
- }
77
- onRendered(n) {
78
- var t;
79
- return ((t = i(this, b)) == null ? void 0 : t.addOnRenderedCallback(n)) ?? { unsubscribe: () => {
80
- } };
81
- }
82
- async setVisible(n) {
83
- var t;
84
- await ((t = i(this, b)) == null ? void 0 : t.setVisible(n));
85
- }
86
- }
87
- $ = new WeakMap(), b = new WeakMap();
88
- var x, c;
89
- class Ue {
90
- constructor(n) {
91
- d(this, "id");
92
- a(this, x, "v1");
93
- a(this, c);
94
- var s, o;
95
- this.id = n;
96
- const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, x));
97
- if (u(this, c, t == null ? void 0 : t.getCustomCtrlSdkBridge(this.id)), !i(this, c))
98
- throw new Error(`Cannot access API for Custom Control "${this.id}".`);
99
- }
100
- /**
101
- * This gives custom code full control over what is rendered inside the control. When setting this function, custom
102
- * code is responsible to actively render/set the content/innerHTML of the given `element` inside the
103
- * {@link renderFn}.
104
- *
105
- * The configurator will not render any content inside the control when a {@link renderFn} is set.
106
- *
107
- * For the {@link renderFn} to work, the property `Custom code controlled` needs to be enabled on the control.
108
- * The {@link renderFn} will be ignored when `Custom code controlled` is not enabled.
109
- *
110
- * Good to know:
111
- * - Setting a new {@link renderFn} does not trigger a re-render.\
112
- * Use {@link render} if you want to trigger a re-render after setting a new {@link renderFn}.
113
- * - There can only be one {@link renderFn} per control. Setting a new one will override the existing one.
114
- * - The {@link renderFn} will be called in the following scenarios:
115
- * - Everytime the control is being shown. This is on initial show as well as when toggling its visibility.
116
- * - When forcing a render via the {@link render} method.
117
- * - Difference to {@link onRendered}:
118
- * - The {@link renderFn} is meant to control the rendered content whilst {@link onRendered} is a classic event
119
- * listener which allows you to perform certain actions like installing event listener on DOM nodes etc.
120
- * **after** the content has been rendered.
121
- * - You can install multiple {@link onRendered} callbacks.
122
- * - The {@link renderFn} and {@link onRendered} callbacks can be used side by side.
123
- * - The {@link renderFn} should always be used instead of manually manipulating the DOM via vanilla JS.\
124
- * When manipulating the DOM outside of the {@link renderFn}, your changes can always be overridden by the
125
- * configurator.\
126
- * Using the {@link renderFn} ensures that your changes are applied in a stable and predictable way.
127
- */
128
- set renderFn(n) {
129
- var t;
130
- (t = i(this, c)) == null || t.setRenderFn(n);
131
- }
132
- /**
133
- * Forces a re-render of the control.
134
- *
135
- * @param renderFn Convenience param which allows setting the {@link renderFn} and triggering a render in one call.
136
- * The given `renderFn` will be permanently installed and will override any previously set
137
- * {@link renderFn}.
138
- */
139
- async render(n) {
140
- var t;
141
- typeof n == "function" && (this.renderFn = n), await ((t = i(this, c)) == null ? void 0 : t.render());
142
- }
143
- /**
144
- * This allows custom code to register callbacks in which it can perform certain actions like installing event
145
- * listeners on DOM nodes or adding CSS classes etc. **after** the control has been rendered.
146
- *
147
- * The control can be rendered in the following scenarios:
148
- * - Everytime the control is being shown. This is on initial show as well as when toggling its visibility.
149
- * - When forcing a render via the {@link render} method.
150
- * - When the value of the control's `HTML` property changes e.g. via Hive in controls.
151
- *
152
- * !!! Important !!!
153
- *
154
- * This is **not** meant to be used for manipulating the rendered content of the control besides simple,
155
- * non-structural/-behavioral changes like adding CSS classes or data attributes etc.
156
- *
157
- * For manipulating/controlling the rendered content, use the {@link renderFn} instead.
158
- *
159
- * See {@link renderFn} for more differences between the two.
160
- */
161
- onRendered(n) {
162
- var t;
163
- return ((t = i(this, c)) == null ? void 0 : t.addOnRenderedCallback(n)) ?? { unsubscribe: () => {
164
- } };
165
- }
166
- getElement() {
167
- var t;
168
- return (t = i(this, c)) == null ? void 0 : t.getElement();
169
- }
170
- async setVisible(n) {
171
- var t;
172
- await ((t = i(this, c)) == null ? void 0 : t.setVisible(n));
173
- }
174
- }
175
- x = new WeakMap(), c = new WeakMap();
176
- var M, m;
177
- class Ne {
178
- constructor(n) {
179
- d(this, "id");
180
- a(this, M, "v1");
181
- a(this, m);
182
- var s, o;
183
- this.id = n;
184
- const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, M));
185
- if (u(this, m, t == null ? void 0 : t.getDataviewSdkBridge(this.id)), !i(this, m))
186
- throw new Error(`Cannot access API for Dataview "${this.id}".`);
187
- }
188
- onRendered(n) {
189
- var t;
190
- return ((t = i(this, m)) == null ? void 0 : t.addOnRenderedCallback(n)) ?? { unsubscribe: () => {
191
- } };
192
- }
193
- async setVisible(n) {
194
- var t;
195
- await ((t = i(this, m)) == null ? void 0 : t.setVisible(n));
196
- }
197
- }
198
- M = new WeakMap(), m = new WeakMap();
199
- var _, f;
200
- class Ze {
201
- constructor(n) {
202
- d(this, "id");
203
- a(this, _, "v1");
204
- a(this, f);
205
- var s, o;
206
- this.id = n;
207
- const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, _));
208
- if (u(this, f, t == null ? void 0 : t.getInputSdkBridge(this.id)), !i(this, f))
209
- throw new Error(`Cannot access API for Input "${this.id}".`);
210
- }
211
- onRendered(n) {
212
- var t;
213
- return ((t = i(this, f)) == null ? void 0 : t.addOnRenderedCallback(n)) ?? { unsubscribe: () => {
214
- } };
215
- }
216
- async setVisible(n) {
217
- var t;
218
- await ((t = i(this, f)) == null ? void 0 : t.setVisible(n));
219
- }
220
- }
221
- _ = new WeakMap(), f = new WeakMap();
222
- var L, w;
223
- class je {
224
- constructor(n) {
225
- d(this, "id");
226
- a(this, L, "v1");
227
- a(this, w);
228
- var s, o;
229
- this.id = n;
230
- const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, L));
231
- if (u(this, w, t == null ? void 0 : t.getPanelSdkBridge(this.id)), !i(this, w))
232
- throw new Error(`Cannot access API for Panel "${this.id}".`);
233
- }
234
- onRendered(n) {
235
- var t;
236
- return ((t = i(this, w)) == null ? void 0 : t.addOnRenderedCallback(n)) ?? { unsubscribe: () => {
237
- } };
238
- }
239
- async setVisible(n) {
240
- var t;
241
- await ((t = i(this, w)) == null ? void 0 : t.setVisible(n));
242
- }
243
- }
244
- L = new WeakMap(), w = new WeakMap();
245
- var U, l;
246
- class Ke {
247
- constructor(n) {
248
- d(this, "id");
249
- a(this, U, "v1");
250
- a(this, l);
251
- var s, o;
252
- this.id = n;
253
- const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, U));
254
- if (u(this, l, t == null ? void 0 : t.getTextSdkBridge(this.id)), !i(this, l))
255
- throw new Error(`Cannot access API for Text "${this.id}".`);
256
- }
257
- onRendered(n) {
258
- var t;
259
- return ((t = i(this, l)) == null ? void 0 : t.addOnRenderedCallback(n)) ?? { unsubscribe: () => {
260
- } };
261
- }
262
- async setVisible(n) {
263
- var t;
264
- await ((t = i(this, l)) == null ? void 0 : t.setVisible(n));
265
- }
266
- setText(n) {
267
- var t;
268
- (t = i(this, l)) == null || t.setText(n);
269
- }
1
+ import { z as e } from "zod";
2
+ //#region \0rolldown/runtime.js
3
+ var t = Object.defineProperty, n = (e, n) => {
4
+ let r = {};
5
+ for (var i in e) t(r, i, {
6
+ get: e[i],
7
+ enumerable: !0
8
+ });
9
+ return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
10
+ }, r = "0.0.1-alpha13", i = class {
11
+ id;
12
+ #e = "v1";
13
+ #t = void 0;
14
+ constructor(e) {
15
+ this.id = e;
16
+ let t = window.Cbn?.getCustomCodeSdkBridge?.(this.#e);
17
+ if (this.#t = t?.getButtonSdkBridge(this.id), !this.#t) throw Error(`Cannot access API for Button "${this.id}".`);
18
+ }
19
+ onRendered(e) {
20
+ return this.#t?.addOnRenderedCallback(e) ?? { unsubscribe: () => {} };
21
+ }
22
+ onClick(e) {
23
+ return this.#t?.addOnClickCallback(e) ?? { unsubscribe: () => {} };
24
+ }
25
+ async setVisible(e) {
26
+ await this.#t?.setVisible(e);
27
+ }
28
+ setText(e) {
29
+ this.#t?.setText(e);
30
+ }
31
+ }, a = class {
32
+ id;
33
+ #e = "v1";
34
+ #t = void 0;
35
+ constructor(e) {
36
+ this.id = e;
37
+ let t = window.Cbn?.getCustomCodeSdkBridge?.(this.#e);
38
+ if (this.#t = t?.getCheckboxSdkBridge(this.id), !this.#t) throw Error(`Cannot access API for Checkbox "${this.id}".`);
39
+ }
40
+ onRendered(e) {
41
+ return this.#t?.addOnRenderedCallback(e) ?? { unsubscribe: () => {} };
42
+ }
43
+ async setVisible(e) {
44
+ await this.#t?.setVisible(e);
45
+ }
46
+ }, o = class {
47
+ id;
48
+ #e = "v1";
49
+ #t = void 0;
50
+ constructor(e) {
51
+ this.id = e;
52
+ let t = window.Cbn?.getCustomCodeSdkBridge?.(this.#e);
53
+ if (this.#t = t?.getCollapsibleSdkBridge(this.id), !this.#t) throw Error(`Cannot access API for Collapsible "${this.id}".`);
54
+ }
55
+ onRendered(e) {
56
+ return this.#t?.addOnRenderedCallback(e) ?? { unsubscribe: () => {} };
57
+ }
58
+ async setVisible(e) {
59
+ await this.#t?.setVisible(e);
60
+ }
61
+ }, s = class {
62
+ id;
63
+ #e = "v1";
64
+ #t = void 0;
65
+ constructor(e) {
66
+ this.id = e;
67
+ let t = window.Cbn?.getCustomCodeSdkBridge?.(this.#e);
68
+ if (this.#t = t?.getComboboxSdkBridge(this.id), !this.#t) throw Error(`Cannot access API for Combobox "${this.id}".`);
69
+ }
70
+ onRendered(e) {
71
+ return this.#t?.addOnRenderedCallback(e) ?? { unsubscribe: () => {} };
72
+ }
73
+ onItemRendered(e) {
74
+ return this.#t?.addOnItemRenderedCallback(e) ?? { unsubscribe: () => {} };
75
+ }
76
+ onValueItemRendered(e) {
77
+ return this.#t?.addOnValueItemRenderedCallback(e) ?? { unsubscribe: () => {} };
78
+ }
79
+ onGroupHeaderRendered(e) {
80
+ return this.#t?.addOnGroupHeaderRenderedCallback(e) ?? { unsubscribe: () => {} };
81
+ }
82
+ onValueChange(e) {
83
+ return this.#t?.addOnValueChangeCallback(e) ?? { unsubscribe: () => {} };
84
+ }
85
+ onItemClicked(e) {
86
+ return this.#t?.addOnItemClickedCallback(e) ?? { unsubscribe: () => {} };
87
+ }
88
+ async setVisible(e) {
89
+ await this.#t?.setVisible(e);
90
+ }
91
+ setEntries(e) {
92
+ this.#t?.setEntries(e);
93
+ }
94
+ setGroupData(e) {
95
+ this.#t?.setGroupData(e);
96
+ }
97
+ }, c = class {
98
+ id;
99
+ #e = "v1";
100
+ #t = void 0;
101
+ constructor(e) {
102
+ this.id = e;
103
+ let t = window.Cbn?.getCustomCodeSdkBridge?.(this.#e);
104
+ if (this.#t = t?.getCustomCtrlSdkBridge(this.id), !this.#t) throw Error(`Cannot access API for Custom Control "${this.id}".`);
105
+ }
106
+ set renderFn(e) {
107
+ this.#t?.setRenderFn(e);
108
+ }
109
+ async render(e) {
110
+ typeof e == "function" && (this.renderFn = e), await this.#t?.render();
111
+ }
112
+ onRendered(e) {
113
+ return this.#t?.addOnRenderedCallback(e) ?? { unsubscribe: () => {} };
114
+ }
115
+ getElement() {
116
+ return this.#t?.getElement();
117
+ }
118
+ async setVisible(e) {
119
+ await this.#t?.setVisible(e);
120
+ }
121
+ }, l = class {
122
+ id;
123
+ #e = "v1";
124
+ #t = void 0;
125
+ constructor(e) {
126
+ this.id = e;
127
+ let t = window.Cbn?.getCustomCodeSdkBridge?.(this.#e);
128
+ if (this.#t = t?.getDataviewSdkBridge(this.id), !this.#t) throw Error(`Cannot access API for Dataview "${this.id}".`);
129
+ }
130
+ onRendered(e) {
131
+ return this.#t?.addOnRenderedCallback(e) ?? { unsubscribe: () => {} };
132
+ }
133
+ onItemRendered(e) {
134
+ return this.#t?.addOnItemRenderedCallback(e) ?? { unsubscribe: () => {} };
135
+ }
136
+ onGroupHeaderRendered(e) {
137
+ return this.#t?.addOnGroupHeaderRenderedCallback(e) ?? { unsubscribe: () => {} };
138
+ }
139
+ onValueChange(e) {
140
+ return this.#t?.addOnValueChangeCallback(e) ?? { unsubscribe: () => {} };
141
+ }
142
+ onItemClicked(e) {
143
+ return this.#t?.addOnItemClickedCallback(e) ?? { unsubscribe: () => {} };
144
+ }
145
+ async setVisible(e) {
146
+ await this.#t?.setVisible(e);
147
+ }
148
+ setEntries(e) {
149
+ this.#t?.setEntries(e);
150
+ }
151
+ setGroupData(e) {
152
+ this.#t?.setGroupData(e);
153
+ }
154
+ }, ee = class {
155
+ id;
156
+ #e = "v1";
157
+ #t = void 0;
158
+ constructor(e) {
159
+ this.id = e;
160
+ let t = window.Cbn?.getCustomCodeSdkBridge?.(this.#e);
161
+ if (this.#t = t?.getInputSdkBridge(this.id), !this.#t) throw Error(`Cannot access API for Input "${this.id}".`);
162
+ }
163
+ onRendered(e) {
164
+ return this.#t?.addOnRenderedCallback(e) ?? { unsubscribe: () => {} };
165
+ }
166
+ async setVisible(e) {
167
+ await this.#t?.setVisible(e);
168
+ }
169
+ }, u = class {
170
+ id;
171
+ #e = "v1";
172
+ #t = void 0;
173
+ constructor(e) {
174
+ this.id = e;
175
+ let t = window.Cbn?.getCustomCodeSdkBridge?.(this.#e);
176
+ if (this.#t = t?.getPanelSdkBridge(this.id), !this.#t) throw Error(`Cannot access API for Panel "${this.id}".`);
177
+ }
178
+ onRendered(e) {
179
+ return this.#t?.addOnRenderedCallback(e) ?? { unsubscribe: () => {} };
180
+ }
181
+ async setVisible(e) {
182
+ await this.#t?.setVisible(e);
183
+ }
184
+ }, te = class {
185
+ id;
186
+ #e = "v1";
187
+ #t = void 0;
188
+ constructor(e) {
189
+ this.id = e;
190
+ let t = window.Cbn?.getCustomCodeSdkBridge?.(this.#e);
191
+ if (this.#t = t?.getTextSdkBridge(this.id), !this.#t) throw Error(`Cannot access API for Text "${this.id}".`);
192
+ }
193
+ onRendered(e) {
194
+ return this.#t?.addOnRenderedCallback(e) ?? { unsubscribe: () => {} };
195
+ }
196
+ async setVisible(e) {
197
+ await this.#t?.setVisible(e);
198
+ }
199
+ setText(e) {
200
+ this.#t?.setText(e);
201
+ }
202
+ }, d = 1, f = [];
203
+ function ne(e, t) {
204
+ if (f.length >= d) throw Error(`Only ${d} \`ConfiguratorClient\` can be created at a time.`);
205
+ f.push({
206
+ client: e,
207
+ internals: t
208
+ });
270
209
  }
271
- U = new WeakMap(), l = new WeakMap();
272
- const G = 1, v = [];
273
- function se(e, n) {
274
- if (v.length >= G)
275
- throw new Error(`Only ${G} \`ConfiguratorClient\` can be created at a time.`);
276
- v.push({ client: e, internals: n });
210
+ function p() {
211
+ let e = f[0];
212
+ if (!e) throw Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");
213
+ return e.client;
277
214
  }
278
- function X() {
279
- const e = v[0];
280
- if (!e)
281
- throw new Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");
282
- return e.client;
215
+ function m() {
216
+ let e = f[0];
217
+ if (!e) throw Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");
218
+ return e.internals;
283
219
  }
284
- function ie() {
285
- const e = v[0];
286
- if (!e)
287
- throw new Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");
288
- return e.internals;
220
+ //#endregion
221
+ //#region src/utils/sdk-bridge.provider.ts
222
+ var h = window.Cbn?.getCustomCodeSdkBridge?.("v1");
223
+ if (!h) throw Error("Cannot access Configurator SDK bridge. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator.");
224
+ var g = h.createCfgrClient("v1", ne);
225
+ if (!g) throw Error("Cannot create Configurator Client. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator.");
226
+ var _ = h.getParentPageUtilsSdkBridge(), v = h.getCfgrUtilsSdkBridge(), re = h.getViewer3dSdkBridge(), y = g, b = /* @__PURE__ */ function(e) {
227
+ return e[e.Any = 1] = "Any", e[e.Image = 2] = "Image", e;
228
+ }({}), x = /* @__PURE__ */ function(e) {
229
+ return e[e.PdfAsset = 0] = "PdfAsset", e[e.Asset = 1] = "Asset", e[e.Merge = 2] = "Merge", e[e.OutputToCfgnFile = 4] = "OutputToCfgnFile", e;
230
+ }({}), S = /* @__PURE__ */ function(e) {
231
+ return e[e.PdfAsset = x.PdfAsset] = "PdfAsset", e[e.Asset = x.Asset] = "Asset", e;
232
+ }({}), C = (e) => v.uploadCfgnFiles(e, b.Image), w = (e) => v.uploadCfgnFiles(e, b.Any), T = (e) => v.uploadTempCfgnFiles(e, b.Image), E = (e) => v.uploadTempCfgnFiles(e, b.Any), D = (e) => v.convertDocument(e);
233
+ async function O(e, t, n, r) {
234
+ let i = t.length > 1, a = "MergeTask", o = "Task_", s = t.map((t, n) => t.type === S.PdfAsset ? {
235
+ type: x.PdfAsset,
236
+ name: `${o}${n}`,
237
+ bundleAliasName: e,
238
+ assetPath: t.assetPath,
239
+ context: t.context
240
+ } : {
241
+ type: x.Asset,
242
+ name: `${o}${n}`,
243
+ bundleAliasName: e,
244
+ assetPath: t.assetPath
245
+ });
246
+ return i && s.push({
247
+ type: x.Merge,
248
+ name: a,
249
+ inputTaskNames: s.map((e) => e.name)
250
+ }), s.push({
251
+ type: x.OutputToCfgnFile,
252
+ inputTaskName: i ? a : s[0].name,
253
+ name: "OutputPdfTask",
254
+ cfgnFileExtension: "pdf",
255
+ cfgnFileName: n,
256
+ cfgnFileDisplayName: r
257
+ }), v.convertDocument(s);
289
258
  }
290
- const oe = "v1";
291
- var S, q;
292
- const y = (q = (S = window.Cbn) == null ? void 0 : S.getCustomCodeSdkBridge) == null ? void 0 : q.call(S, "v1");
293
- if (!y)
294
- throw new Error(
295
- "Cannot access Configurator SDK bridge. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator."
296
- );
297
- const J = y.createCfgrClient(oe, se);
298
- if (!J)
299
- throw new Error(
300
- "Cannot create Configurator Client. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator."
301
- );
302
- const A = y.getParentPageUtilsSdkBridge(), V = y.getCfgrUtilsSdkBridge(), re = y.getViewer3dSdkBridge(), F = J;
303
- var Z = /* @__PURE__ */ ((e) => (e[e.Any = 1] = "Any", e[e.Image = 2] = "Image", e))(Z || {}), h = /* @__PURE__ */ ((e) => (e[e.PdfAsset = 0] = "PdfAsset", e[e.Asset = 1] = "Asset", e[e.Merge = 2] = "Merge", e[e.Watermark = 3] = "Watermark", e[e.OutputToCfgnFile = 4] = "OutputToCfgnFile", e))(h || {}), ae = /* @__PURE__ */ ((e) => (e[e.Left = 0] = "Left", e[e.Center = 1] = "Center", e[e.Right = 2] = "Right", e))(ae || {}), de = /* @__PURE__ */ ((e) => (e[e.Top = 0] = "Top", e[e.Center = 1] = "Center", e[e.Bottom = 2] = "Bottom", e))(de || {}), H = ((e) => (e[e.PdfAsset = h.PdfAsset] = "PdfAsset", e[e.Asset = h.Asset] = "Asset", e))(H || {});
304
- const ce = (e) => V.uploadCfgnFiles(e, Z.Image), ue = (e) => V.uploadCfgnFiles(e, Z.Any), Ce = (e) => V.convertDocument(e);
305
- async function ge(e, n, t, s) {
306
- const o = n.length > 1, k = "MergeTask", B = "Task_", E = n.map(
307
- (g, j) => g.type === H.PdfAsset ? {
308
- type: h.PdfAsset,
309
- name: `${B}${j}`,
310
- bundleAliasName: e,
311
- assetPath: g.assetPath,
312
- context: g.context
313
- } : {
314
- type: h.Asset,
315
- name: `${B}${j}`,
316
- bundleAliasName: e,
317
- assetPath: g.assetPath
318
- }
319
- );
320
- return o && E.push({
321
- type: h.Merge,
322
- name: k,
323
- inputTaskNames: E.map((g) => g.name)
324
- }), E.push({
325
- type: h.OutputToCfgnFile,
326
- inputTaskName: o ? k : E[0].name,
327
- name: "OutputPdfTask",
328
- cfgnFileExtension: "pdf",
329
- cfgnFileName: t,
330
- cfgnFileDisplayName: s
331
- }), V.convertDocument(E);
332
- }
333
- const N = {
334
- Text: "Text",
335
- Number: "Number",
336
- Logic: "Logic"
337
- }, I = {
338
- ValueComponent: "ValueComponent",
339
- TableComponent: "TableComponent",
340
- // TODO WTT: We're not actively supporting the following cmp types (yet). Neither in editor v2, nor in the headless
341
- // cfgr client. However, they're still sent w/ our cspd updates, which is why we still list them in our cspd
342
- // update Zod typings to not fail at parsing etc.
343
- //
344
- // If we decide to not support them at all, neither in editor v2, nor in the headless cfgr client, remove
345
- // them from here and update our cspd update data to not include them anymore.
346
- //
347
- // Also see & update `IgnoredCmpBaseTypes` accordingly.
348
- RecordComponent: "RecordComponent",
349
- ResourceComponent: "ResourceComponent",
350
- GraphicComponent: "GraphicComponent",
351
- CheckoutComponent: "CheckoutComponent"
352
- }, R = {
353
- ValueEditor: "ValueEditor",
354
- TableEditor: "TableEditor",
355
- Fiber: "Fiber",
356
- FiberEditor: "FiberEditor",
357
- CfgrField: "CfgrField"
259
+ //#endregion
260
+ //#region ../../packages/be-lib/src/lib/hive-enums.ts
261
+ var k = {
262
+ Text: "Text",
263
+ Number: "Number",
264
+ Logic: "Logic",
265
+ Image: "Image",
266
+ FileUrl: "FileUrl",
267
+ TextAsset: "TextAsset",
268
+ Table: "Table"
269
+ };
270
+ `${k.Text}`, `${k.Number}`;
271
+ var A = {
272
+ ValueComponent: "ValueComponent",
273
+ TableComponent: "TableComponent",
274
+ RecordComponent: "RecordComponent",
275
+ ResourceComponent: "ResourceComponent",
276
+ GraphicComponent: "GraphicComponent",
277
+ CheckoutComponent: "CheckoutComponent"
358
278
  };
359
- r.enum([
360
- R.ValueEditor,
361
- R.TableEditor,
362
- R.Fiber,
363
- R.FiberEditor,
364
- R.CfgrField
279
+ A.GraphicComponent, A.CheckoutComponent, A.ResourceComponent, A.RecordComponent;
280
+ var j = {
281
+ ValueEditor: "ValueEditor",
282
+ TableEditor: "TableEditor",
283
+ Fiber: "Fiber",
284
+ FiberEditor: "FiberEditor",
285
+ CfgrField: "CfgrField"
286
+ };
287
+ e.enum([
288
+ j.ValueEditor,
289
+ j.TableEditor,
290
+ j.Fiber,
291
+ j.FiberEditor,
292
+ j.CfgrField
293
+ ]), e.union([
294
+ e.string(),
295
+ e.number(),
296
+ e.boolean()
365
297
  ]);
366
- r.union([r.string(), r.number(), r.boolean()]);
367
- const P = (e) => typeof e == "string";
368
- r.string();
369
- r.enum([N.Text, N.Number, N.Logic]);
370
- r.string();
371
- r.custom((e) => P(e) && e.toLowerCase() === e);
372
- const W = (e) => (e == null ? void 0 : e.toLowerCase()) ?? "";
373
- r.string();
374
- const le = r.custom(
375
- (e) => P(e) ? new RegExp(`^${I.ValueComponent}<.*>$`).test(e) : !1
376
- ), he = r.custom(
377
- (e) => P(e) ? new RegExp(`^${I.RecordComponent}<.*>$`).test(e) : !1
378
- ), pe = r.custom(
379
- (e) => P(e) ? new RegExp(`^${I.ResourceComponent}<.*>$`).test(e) : !1
380
- ), be = r.custom(
381
- (e) => P(e) ? new RegExp(`^${I.TableComponent}<.*>$`).test(e) : !1
382
- );
383
- r.union([
384
- le,
385
- be,
386
- he,
387
- pe,
388
- r.literal(I.GraphicComponent),
389
- r.literal(I.CheckoutComponent)
298
+ var M = (e) => typeof e == "string";
299
+ e.string(), e.enum([
300
+ k.Text,
301
+ k.Number,
302
+ k.Logic
303
+ ]), e.string(), e.custom((e) => M(e) && e.toLowerCase() === e);
304
+ var N = (e) => e?.toLowerCase() ?? "";
305
+ e.string();
306
+ var P = e.custom((e) => M(e) ? RegExp(`^${A.ValueComponent}<.*>$`).test(e) : !1), F = e.custom((e) => M(e) ? RegExp(`^${A.RecordComponent}<.*>$`).test(e) : !1), I = e.custom((e) => M(e) ? RegExp(`^${A.ResourceComponent}<.*>$`).test(e) : !1), ie = e.custom((e) => M(e) ? RegExp(`^${A.TableComponent}<.*>$`).test(e) : !1);
307
+ e.union([
308
+ P,
309
+ ie,
310
+ F,
311
+ I,
312
+ e.literal(A.GraphicComponent),
313
+ e.literal(A.CheckoutComponent)
390
314
  ]);
391
- const z = r.union([r.string(), r.number(), r.boolean()]), me = r.union([z, r.array(z), r.object({}), r.unknown()]), fe = r.object({
392
- $typ: r.literal("Error"),
393
- // TODO WTT: Introduce more specific typing here for known error IDs etc.? Maybe in combination w/ some server
394
- // generated enum?
395
- Id: r.string(),
396
- Message: r.string(),
397
- /**
398
- * Just adding this here for completeness. Not sure if always there and what data it actually holds etc.
399
- * I guess this could be used for adding squiggly lines to the Hive rule etc.
400
- *
401
- * TODO WTT: Clarify what this is + refine the Zod type etc.
402
- */
403
- route: r.unknown().optional()
404
- });
405
- fe.or(me);
406
- const Q = /* @__PURE__ */ new Map();
407
- function we(e) {
408
- const n = W(e.name);
409
- Q.has(n) || Q.set(n, e);
410
- }
411
- class De {
412
- constructor(n, t) {
413
- d(this, "name");
414
- d(this, "zodType");
415
- this.name = n, this.zodType = t, we(this);
416
- }
417
- /**
418
- * Function for receiving the value of a component.
419
- */
420
- async getValue() {
421
- return await X().getCmpValue(this.name);
422
- }
423
- /**
424
- * Sends the ChangeConfigurationValue request to the server
425
- */
426
- async setInput(n) {
427
- const t = W(this.name);
428
- await ie().setCmpInput(t, n, this.zodType);
429
- }
430
- /**
431
- * @param listener Called whenever the value of the given cmp has changed
432
- * @param callImmediately `True:` The listener is immediately called with the current value of the cmp at the
433
- * time, the listener is added\
434
- * `False:` The listener will be called for the first time when the value of the cmp
435
- * actually changes
436
- * @param condition A predicate function which is given the new cmp value.\
437
- * The function can decide on whether the listener is called or not by returning true or false.
438
- */
439
- onValueChanged(n, t = !1, s) {
440
- X().onCmpValueChanged(this.name, n, s, t);
441
- }
315
+ var L = e.union([
316
+ e.string(),
317
+ e.number(),
318
+ e.boolean()
319
+ ]), ae = e.union([
320
+ L,
321
+ e.array(L),
322
+ e.object({}),
323
+ e.unknown()
324
+ ]);
325
+ e.object({
326
+ $typ: e.literal("Error"),
327
+ Id: e.string(),
328
+ Message: e.string(),
329
+ route: e.unknown().optional()
330
+ }).or(ae);
331
+ //#endregion
332
+ //#region ../configurator-client/src/cmps-registry.ts
333
+ var R = /* @__PURE__ */ new Map();
334
+ function oe(e) {
335
+ let t = N(e.name);
336
+ R.has(t) || R.set(t, e);
442
337
  }
443
- const Ae = () => V.getAssetPaths();
444
- var ee = /* @__PURE__ */ ((e) => (e[e.Facebook = 0] = "Facebook", e[e.Pinterest = 1] = "Pinterest", e[e.Twitter = 2] = "Twitter", e[e.LinkedIn = 3] = "LinkedIn", e[e.WhatsApp = 4] = "WhatsApp", e[e.Custom = 5] = "Custom", e[e.NativeShare = 6] = "NativeShare", e))(ee || {});
445
- const Ve = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+X2ZkAAAAASUVORK5CYII=", ke = F.onAnyCmpValueChanged.bind(F), Be = async (e) => {
446
- if (await F.finishConfiguration(e == null ? void 0 : e.input), e.sendDataToParentPage) {
447
- const n = e.transformParentPageData();
448
- await A.sendConfigurationFinished(n);
449
- }
450
- }, Ee = async (e) => {
451
- const n = ee[e.platform], t = e.imageUrl ?? Ve, s = { ...e, platform: n, imageUrl: t }, o = await F.shareConfiguration(s);
452
- await V.openShareWindow(e.platform, o);
453
- const { shareUrl: k, shareConfigurationId: B } = o;
454
- return { shareUrl: k, shareConfigurationId: B };
455
- }, Ie = () => A.isInIFrame(), Re = (e) => A.setIFrameSize(e), ye = (e) => V.navigateToLogin(e), Pe = async (e) => {
456
- const { promise: n, resolve: t } = Promise.withResolvers(), s = {};
457
- for (const [o, k] of Object.entries(e))
458
- k.onValueChanged((B) => {
459
- s[o] = B, Object.keys(e).every((g) => g in s) && t(s);
460
- }, !0);
461
- return n;
462
- }, Se = (e, n) => A.sendCustomMsg(e, n), ve = (e) => A.redirectParentPage(e), Fe = () => A.getParentPageUrl(), Oe = (e, n) => A.fireAnalyticsEvent(e, n), Te = async (e, n) => re.createArPage(e, n), Ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
463
- __proto__: null,
464
- configuratorIsInIFrame: Ie,
465
- convertDocument: Ce,
466
- createArPage: Te,
467
- createPdfFromAssets: ge,
468
- createSyncCmpValuesStore: Pe,
469
- finishConfiguration: Be,
470
- fireAnalyticsEvent: Oe,
471
- getAssetPaths: Ae,
472
- getParentPageUrl: Fe,
473
- navigateToLogin: ye,
474
- onAnyCmpValueChanged: ke,
475
- redirectParentPage: ve,
476
- sendCustomMsgToParentPage: Se,
477
- setConfiguratorIFrameSize: Re,
478
- shareConfiguration: Ee,
479
- uploadFiles: ue,
480
- uploadImages: ce,
481
- version: Y
482
- }, Symbol.toStringTag, { value: "Module" }));
483
- console.log(`Loading custom code SDK v${Y}`);
484
- export {
485
- Me as Button,
486
- Ge as CbnSdk,
487
- _e as Checkbox,
488
- Le as Collapsible,
489
- H as CreatePdfTaskTypes,
490
- Ue as CustomControl,
491
- Ne as Dataview,
492
- h as DocumentConvertTaskTypes,
493
- Ze as Input,
494
- je as Panel,
495
- Ke as Text,
496
- De as ValueComponent,
497
- ae as WatermarkHorizontalAlignment,
498
- de as WatermarkVerticalAlignment,
499
- Ie as configuratorIsInIFrame,
500
- Ce as convertDocument,
501
- Te as createArPage,
502
- ge as createPdfFromAssets,
503
- Pe as createSyncCmpValuesStore,
504
- Be as finishConfiguration,
505
- Oe as fireAnalyticsEvent,
506
- Ae as getAssetPaths,
507
- Fe as getParentPageUrl,
508
- ye as navigateToLogin,
509
- ke as onAnyCmpValueChanged,
510
- ve as redirectParentPage,
511
- Se as sendCustomMsgToParentPage,
512
- Re as setConfiguratorIFrameSize,
513
- Ee as shareConfiguration,
514
- ue as uploadFiles,
515
- ce as uploadImages,
516
- Y as version
517
- };
338
+ //#endregion
339
+ //#region ../configurator-client/src/cmps/value-component.ts
340
+ var se = class {
341
+ name;
342
+ zodType;
343
+ constructor(e, t) {
344
+ this.name = e, this.zodType = t, oe(this);
345
+ }
346
+ async getValue() {
347
+ return await p().getCmpValue(this.name);
348
+ }
349
+ async setInput(e) {
350
+ let t = N(this.name);
351
+ await m().setCmpInput(t, e, this.zodType);
352
+ }
353
+ onValueChanged(e, t = !1, n) {
354
+ p().onCmpValueChanged(this.name, e, n, t);
355
+ }
356
+ }, z = () => v.getAssetPaths(), B = /* @__PURE__ */ function(e) {
357
+ return e[e.Facebook = 0] = "Facebook", e[e.Pinterest = 1] = "Pinterest", e[e.Twitter = 2] = "Twitter", e[e.LinkedIn = 3] = "LinkedIn", e[e.WhatsApp = 4] = "WhatsApp", e[e.Custom = 5] = "Custom", e[e.NativeShare = 6] = "NativeShare", e;
358
+ }({}), V = y.onAnyCmpValueChanged.bind(y), H = async (e) => {
359
+ if (await y.finishConfiguration(e?.input), e.sendDataToParentPage) {
360
+ let t = e.transformParentPageData();
361
+ await _.sendConfigurationFinished(t);
362
+ }
363
+ }, U = async (e) => {
364
+ let t = B[e.platform], n = e.imageUrl ?? "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+X2ZkAAAAASUVORK5CYII=", r = {
365
+ ...e,
366
+ platform: t,
367
+ imageUrl: n
368
+ }, i = await y.shareConfiguration(r);
369
+ await v.openShareWindow(e.platform, i);
370
+ let { shareUrl: a, shareConfigurationId: o } = i;
371
+ return {
372
+ shareUrl: a,
373
+ shareConfigurationId: o
374
+ };
375
+ }, W = () => _.isInIFrame(), G = (e) => _.setIFrameSize(e), K = (e) => v.navigateToLogin(e), q = async (e) => {
376
+ let { promise: t, resolve: n } = Promise.withResolvers(), r = {};
377
+ for (let [t, i] of Object.entries(e)) i.onValueChanged((i) => {
378
+ r[t] = i, Object.keys(e).every((e) => e in r) && n(r);
379
+ }, !0);
380
+ return t;
381
+ }, J = (e, t) => _.sendCustomMsg(e, t), Y = (e) => _.redirectParentPage(e), X = () => _.getParentPageUrl(), Z = (e, t) => _.fireAnalyticsEvent(e, t), Q = (e) => _.onParentPageEvent(e), $ = async (e, t) => re.createArPage(e, t), ce = /* @__PURE__ */ n({
382
+ configuratorIsInIFrame: () => W,
383
+ convertDocument: () => D,
384
+ createArPage: () => $,
385
+ createPdfFromAssets: () => O,
386
+ createSyncCmpValuesStore: () => q,
387
+ finishConfiguration: () => H,
388
+ fireAnalyticsEvent: () => Z,
389
+ getAssetPaths: () => z,
390
+ getParentPageUrl: () => X,
391
+ navigateToLogin: () => K,
392
+ onAnyCmpValueChanged: () => V,
393
+ onParentPageEvent: () => Q,
394
+ redirectParentPage: () => Y,
395
+ sendCustomMsgToParentPage: () => J,
396
+ setConfiguratorIFrameSize: () => G,
397
+ shareConfiguration: () => U,
398
+ uploadFiles: () => w,
399
+ uploadImages: () => C,
400
+ uploadTempFiles: () => E,
401
+ uploadTempImages: () => T,
402
+ version: () => r
403
+ });
404
+ //#endregion
405
+ //#region src/index.ts
406
+ console.log(`Loading custom code SDK v${r}`);
407
+ //#endregion
408
+ export { i as Button, ce as CbnSdk, a as Checkbox, o as Collapsible, s as Combobox, S as CreatePdfTaskTypes, c as CustomControl, l as Dataview, x as DocumentConvertTaskTypes, ee as Input, u as Panel, te as Text, se as ValueComponent, W as configuratorIsInIFrame, D as convertDocument, $ as createArPage, O as createPdfFromAssets, q as createSyncCmpValuesStore, H as finishConfiguration, Z as fireAnalyticsEvent, z as getAssetPaths, X as getParentPageUrl, K as navigateToLogin, V as onAnyCmpValueChanged, Q as onParentPageEvent, Y as redirectParentPage, J as sendCustomMsgToParentPage, G as setConfiguratorIFrameSize, U as shareConfiguration, w as uploadFiles, C as uploadImages, E as uploadTempFiles, T as uploadTempImages, r as version };