@combeenation/custom-code-sdk 0.0.1-alpha8 → 0.0.1-rc1

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