@combeenation/custom-code-sdk 0.0.1-alpha12 → 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/index.d.ts CHANGED
@@ -8,6 +8,13 @@ export declare class Button {
8
8
  #private;
9
9
  readonly id: CtrlId;
10
10
  constructor(id: CtrlId);
11
+ /**
12
+ * See {@link CustomControl.onRendered} for detailed information on what you can do with this listener and what it is
13
+ * not meant for.
14
+ *
15
+ * Also see {@link OnRenderedCallback} for important information regarding the `element` which is passed to the
16
+ * callback.
17
+ */
11
18
  onRendered(callback: OnRenderedCallback<HTMLButtonElement>): CallbackUnsubscribeOption;
12
19
  onClick(callback: OnClickCallback): CallbackUnsubscribeOption;
13
20
  setVisible(visible: boolean): Promise<void>;
@@ -25,6 +32,7 @@ export declare namespace CbnSdk {
25
32
  fireAnalyticsEvent,
26
33
  getAssetPaths,
27
34
  getParentPageUrl,
35
+ onParentPageEvent,
28
36
  navigateToLogin,
29
37
  onAnyCmpValueChanged,
30
38
  redirectParentPage,
@@ -54,6 +62,13 @@ export declare class Checkbox {
54
62
  #private;
55
63
  readonly id: CtrlId;
56
64
  constructor(id: CtrlId);
65
+ /**
66
+ * See {@link CustomControl.onRendered} for detailed information on what you can do with this listener and what it is
67
+ * not meant for.
68
+ *
69
+ * Also see {@link OnRenderedCallback} for important information regarding the `element` which is passed to the
70
+ * callback.
71
+ */
57
72
  onRendered(callback: OnRenderedCallback<HTMLLabelElement>): CallbackUnsubscribeOption;
58
73
  setVisible(visible: boolean): Promise<void>;
59
74
  }
@@ -98,8 +113,126 @@ export declare class Collapsible {
98
113
  #private;
99
114
  readonly id: CtrlId;
100
115
  constructor(id: CtrlId);
116
+ /**
117
+ * See {@link CustomControl.onRendered} for detailed information on what you can do with this listener and what it is
118
+ * not meant for.
119
+ *
120
+ * Also see {@link OnRenderedCallback} for important information regarding the `element` which is passed to the
121
+ * callback.
122
+ */
123
+ onRendered(callback: OnRenderedCallback<HTMLDivElement>): CallbackUnsubscribeOption;
124
+ setVisible(visible: boolean): Promise<void>;
125
+ }
126
+
127
+ export declare class Combobox<TValue extends NonNullable<DataListValue>> {
128
+ #private;
129
+ readonly id: CtrlId;
130
+ constructor(id: CtrlId);
131
+ /**
132
+ * See {@link CustomControlV1.onRendered} for detailed information on what you can do with this listener and what it
133
+ * is not meant for.
134
+ *
135
+ * Also see {@link OnRenderedCallback} for important information regarding the `element` which is passed to the
136
+ * callback.
137
+ */
101
138
  onRendered(callback: OnRenderedCallback<HTMLDivElement>): CallbackUnsubscribeOption;
139
+ /**
140
+ * See {@link CustomControlV1.onRendered} for detailed information on what you can do with this listener and what it
141
+ * is not meant for. Most of the information there also applies to `onItemRendered`.
142
+ *
143
+ * Also see {@link OnRenderedCallback} for important information regarding the `element` which is passed to the
144
+ * callback which also applies here.
145
+ *
146
+ * @param callback Callback function which is given the rendered HTML element and the corresponding item data.
147
+ *
148
+ * Typical usage for type safe access to the item data where `IProductsTable` is the auto generated
149
+ * type of the table component from which the combobox entries are populated:
150
+ *
151
+ * ```ts
152
+ * combobox.onItemRendered<IProductsTable[number]>((el, itemData) => { ... })
153
+ * ```
154
+ */
155
+ onItemRendered<TItemData>(callback: (element: HTMLDivElement, itemData: TItemData) => void): CallbackUnsubscribeOption;
156
+ /**
157
+ * See {@link CustomControlV1.onRendered} for detailed information on what you can do with this listener and what it
158
+ * is not meant for. Most of the information there also applies to `onValueItemRendered`.
159
+ *
160
+ * Also see {@link OnRenderedCallback} for important information regarding the `element` which is passed to the
161
+ * callback which also applies here.
162
+ *
163
+ * @param callback Callback function which is given the rendered HTML element and the corresponding item data of the
164
+ * currently selected value item shown in the trigger.
165
+ *
166
+ * Typical usage for type safe access to the item data where `IProductsTable` is the auto generated
167
+ * type of the table component from which the combobox entries are populated:
168
+ *
169
+ * ```ts
170
+ * combobox.onValueItemRendered<IProductsTable[number]>((el, itemData) => { ... })
171
+ * ```
172
+ */
173
+ onValueItemRendered<TItemData>(callback: (element: HTMLDivElement, itemData: TItemData) => void): CallbackUnsubscribeOption;
174
+ /**
175
+ * See {@link CustomControlV1.onRendered} for detailed information on what you can do with this listener and what it
176
+ * is not meant for. Most of the information there also applies to `onGroupHeaderRendered`.
177
+ *
178
+ * Also see {@link OnRenderedCallback} for important information regarding the `element` which is passed to the
179
+ * callback which also applies here.
180
+ *
181
+ * @param callback Callback function which is given the rendered HTML element and the corresponding group data.
182
+ *
183
+ * Typical usage for type safe access to the group data where `IProductGroupsTable` is the auto
184
+ * generated type of the table component from which the combobox groups are populated:
185
+ *
186
+ * ```ts
187
+ * combobox.onGroupHeaderRendered<IProductGroupsTable[number]>((el, groupData) => { ... })
188
+ * ```
189
+ */
190
+ onGroupHeaderRendered<TGroupData>(callback: (element: HTMLDivElement, groupData: TGroupData) => void): CallbackUnsubscribeOption;
191
+ /**
192
+ * Fires when the selection is committed which is:
193
+ * - in single select mode: when the popup closes (or when an option is clicked).
194
+ * - in multi select mode: immediately on every selection change.
195
+ *
196
+ * @param callback Callback function which is given the raw selection value/keys and the corresponding item data of
197
+ * all the selected items.
198
+ *
199
+ * Typical usage for type safe access to the item data where `IProductsTable` is the auto generated
200
+ * type of the table component from which the combobox entries are populated:
201
+ *
202
+ * ```ts
203
+ * // Single selection:
204
+ * combobox.onValueChange<IProductsTable[number]>((value, valueItemData) => { ... })
205
+ *
206
+ * // Multi selection:
207
+ * combobox.onValueChange<IProductsTable>((value, valueItemData) => { ... })
208
+ * ```
209
+ */
210
+ onValueChange<TItemData extends TValue extends any[] ? any[] : any>(callback: (value: TValue | undefined, valueItemData: TItemData | undefined) => void): CallbackUnsubscribeOption;
211
+ /**
212
+ * Registers a callback that fires when a combobox item is clicked.
213
+ *
214
+ * - Fires **before** `onValueChange`.
215
+ * - Fires even when the clicked item is already selected.
216
+ *
217
+ * @param callback Callback function which is given the item data of the clicked item and the raw mouse event.
218
+ *
219
+ * Typical usage for type safe access to the item data where `IProductsTable` is the auto generated
220
+ * type of the table component from which the combobox entries are populated:
221
+ *
222
+ * ```ts
223
+ * combobox.onItemClicked<IProductsTable[number]>((itemData, event) => { ... })
224
+ * ```
225
+ */
226
+ onItemClicked<TItemData>(callback: (itemData: TItemData, event: MouseEvent) => void): CallbackUnsubscribeOption;
102
227
  setVisible(visible: boolean): Promise<void>;
228
+ /**
229
+ * Sets the entries (data items) displayed by the combobox. Existing entries are overwritten.
230
+ */
231
+ setEntries(entries: TemplateData[]): void;
232
+ /**
233
+ * Sets the group data used to render the group headers of the combobox. Existing group data is overwritten.
234
+ */
235
+ setGroupData(groupData: TemplateData[]): void;
103
236
  }
104
237
 
105
238
  /**
@@ -317,6 +450,10 @@ export declare class CustomControl {
317
450
  *
318
451
  * !!! Important !!!
319
452
  *
453
+ * See {@link OnRenderedCallback} for important information regarding the `element` which is passed to the callback.
454
+ *
455
+ * !!! Important !!!
456
+ *
320
457
  * This is **not** meant to be used for manipulating the rendered content of the control besides simple,
321
458
  * non-structural/-behavioral changes like adding CSS classes or data attributes etc.
322
459
  *
@@ -335,12 +472,99 @@ export declare class CustomControl {
335
472
  */
336
473
  declare type CustomCtrlRenderFn = (element: HTMLDivElement, rawHtml: string | undefined) => void | Promise<void>;
337
474
 
338
- export declare class Dataview {
475
+ /**
476
+ * The actual value which comes from the entries data and which is converted to `DataListHtmlValue` before being passed
477
+ * to the DOM elements.
478
+ */
479
+ declare type DataListValue = string | string[] | number | number[] | undefined;
480
+
481
+ export declare class Dataview<TValue extends NonNullable<DataListValue>> {
339
482
  #private;
340
483
  readonly id: CtrlId;
341
484
  constructor(id: CtrlId);
485
+ /**
486
+ * See {@link CustomControl.onRendered} for detailed information on what you can do with this listener and what it is
487
+ * not meant for.
488
+ *
489
+ * Also see {@link OnRenderedCallback} for important information regarding the `element` which is passed to the
490
+ * callback.
491
+ */
342
492
  onRendered(callback: OnRenderedCallback<HTMLDivElement>): CallbackUnsubscribeOption;
493
+ /**
494
+ * See {@link CustomControl.onRendered} for detailed information on what you can do with this listener and what it is
495
+ * not meant for. Most of the information there also applies to `onItemRendered`.
496
+ *
497
+ * Also see {@link OnRenderedCallback} for important information regarding the `element` which is passed to the
498
+ * callback which also applies here.
499
+ *
500
+ * @param callback Callback function which is given the rendered HTML element and the corresponding item data.
501
+ *
502
+ * Typical usage for type safe access to the item data where `IProductsTable` is the auto generated
503
+ * type of the table component from which the dataview entries are populated:
504
+ *
505
+ * ```ts
506
+ * dataview.onItemRendered<IProductsTable[number]>(el, itemData) => { ... }
507
+ * ```
508
+ */
509
+ onItemRendered<TItemData>(callback: (element: HTMLDivElement, itemData: TItemData) => void): CallbackUnsubscribeOption;
510
+ /**
511
+ * See {@link CustomControl.onRendered} for detailed information on what you can do with this listener and what it is
512
+ * not meant for. Most of the information there also applies to `onGroupHeaderRendered`.
513
+ *
514
+ * Also see {@link OnRenderedCallback} for important information regarding the `element` which is passed to the
515
+ * callback which also applies here.
516
+ *
517
+ * @param callback Callback function which is given the rendered HTML element and the corresponding group data.
518
+ *
519
+ * Typical usage for type safe access to the group data where `IProductGroupsTable` is the auto
520
+ * generated type of the table component from which the dataview groups are populated:
521
+ *
522
+ * ```ts
523
+ * dataview.onGroupHeaderRendered<IProductGroupsTable[number]>((el, groupData) => { ... })
524
+ * ```
525
+ */
526
+ onGroupHeaderRendered<TGroupData>(callback: (element: HTMLDivElement, groupData: TGroupData) => void): CallbackUnsubscribeOption;
527
+ /**
528
+ * @param callback Callback function which is given the raw selection value/keys and the corresponding item data of
529
+ * all the selected items.
530
+ *
531
+ * Typical usage for type safe access to the item data where `IProductsTable` is the auto generated
532
+ * type of the table component from which the dataview entries are populated:
533
+ *
534
+ * ```ts
535
+ * // Single selection list:
536
+ * dataview.onValueChange<IProductsTable[number]>(value, valueItemData) => { ... }
537
+ *
538
+ * // Multi selection list:
539
+ * dataview.onValueChange<IProductsTable>(value, valueItemData) => { ... }
540
+ * ```
541
+ */
542
+ onValueChange<TItemData extends TValue extends any[] ? any[] : any>(callback: (value: TValue | undefined, valueItemData: TItemData | undefined) => void): CallbackUnsubscribeOption;
543
+ /**
544
+ * Registers a callback that fires when a datalist item is clicked.
545
+ *
546
+ * - Fires **before** `onValueChange`.
547
+ * - Fires even when the clicked item is already selected.
548
+ *
549
+ * @param callback Callback function which is given the item data of rendered item and the raw mouse event.
550
+ *
551
+ * Typical usage for type safe access to the item data where `IProductsTable` is the auto generated
552
+ * type of the table component from which the dataview entries are populated:
553
+ *
554
+ * ```ts
555
+ * dataview.onItemClicked<IProductsTable[number]>(itemData, event) => { ... }
556
+ * ```
557
+ */
558
+ onItemClicked<TItemData>(callback: (itemData: TItemData, event: MouseEvent) => void): CallbackUnsubscribeOption;
343
559
  setVisible(visible: boolean): Promise<void>;
560
+ /**
561
+ * Sets the entries (data items) displayed by the dataview. Existing entries are overwritten.
562
+ */
563
+ setEntries(entries: TemplateData[]): void;
564
+ /**
565
+ * Sets the group data used to render the group headers of the dataview. Existing group data is overwritten.
566
+ */
567
+ setGroupData(groupData: TemplateData[]): void;
344
568
  }
345
569
 
346
570
  export declare type DocumentConvertTask = {
@@ -476,6 +700,13 @@ export declare class Input {
476
700
  #private;
477
701
  readonly id: CtrlId;
478
702
  constructor(id: CtrlId);
703
+ /**
704
+ * See {@link CustomControl.onRendered} for detailed information on what you can do with this listener and what it is
705
+ * not meant for.
706
+ *
707
+ * Also see {@link OnRenderedCallback} for important information regarding the `element` which is passed to the
708
+ * callback.
709
+ */
479
710
  onRendered(callback: OnRenderedCallback<HTMLDivElement>): CallbackUnsubscribeOption;
480
711
  setVisible(visible: boolean): Promise<void>;
481
712
  }
@@ -541,12 +772,54 @@ export declare const onAnyCmpValueChanged: <TInput extends ValueComponent>(liste
541
772
 
542
773
  declare type OnClickCallback = () => void;
543
774
 
775
+ /**
776
+ * Registers a callback for events from the parent page.\
777
+ * The parent page can send those events by calling `Combeenation.sendEventToConfigurator`.
778
+ */
779
+ export declare const onParentPageEvent: (callback: (type: "success" | "error", data: unknown) => void) => CallbackUnsubscribeOption;
780
+
781
+ /**
782
+ * @param element The rendered DOM element.
783
+ *
784
+ * !!! Important !!!
785
+ *
786
+ * This can either be a newly created element or the same, reused element which was already passed to a
787
+ * previous `onRendered` callback invocation.
788
+ *
789
+ * What does this mean?
790
+ * - When registering event listener, avoid `element.addEventListener` but use the form
791
+ * `element.onclick = ...` instead.
792
+ * - Be careful when using API like `MutationObserver` on the element and ensure to not register multiple
793
+ * observer on the same element over time.
794
+ * - Be careful when binding/using the element in external libraries which might use `addEventListener`
795
+ * or things like `MutationObserver` internally (e.g. DnD libraries etc.).
796
+ * - If you **need to** use `addEventListener` etc. e.g. because you have to use a library which uses it
797
+ * internally, make sure to manually check whether the element was already processed/initialized in a
798
+ * previous `onRendered` invocation or not.
799
+ *
800
+ * E.g. something like this:
801
+ *
802
+ * ```ts
803
+ * dataview.onRendered((element) => {
804
+ * if (element.dataset.wasVisited) return;
805
+ * element.dataset.wasVisited = 'true';
806
+ *
807
+ * // -> Safely use `element.addEventListener` or `dndManager.init(element)` etc.
808
+ * });
809
+ */
544
810
  declare type OnRenderedCallback<T extends HTMLElement = HTMLElement> = (element: T) => void;
545
811
 
546
812
  export declare class Panel {
547
813
  #private;
548
814
  readonly id: CtrlId;
549
815
  constructor(id: CtrlId);
816
+ /**
817
+ * See {@link CustomControl.onRendered} for detailed information on what you can do with this listener and what it is
818
+ * not meant for.
819
+ *
820
+ * Also see {@link OnRenderedCallback} for important information regarding the `element` which is passed to the
821
+ * callback.
822
+ */
550
823
  onRendered(callback: OnRenderedCallback<HTMLDivElement>): CallbackUnsubscribeOption;
551
824
  setVisible(visible: boolean): Promise<void>;
552
825
  }
@@ -829,10 +1102,23 @@ declare type SyncCmpValuesStore<TCmps extends Record<CmpName, ValueComponent>> =
829
1102
  [K in keyof TCmps & CmpName]: TCmps[K] extends ValueComponent<any, infer TValue, any> ? TValue | undefined : never;
830
1103
  };
831
1104
 
1105
+ /**
1106
+ * The raw data passed to the corresponding liquid template (e.g. to a datalist item template or a group header
1107
+ * template etc.)
1108
+ */
1109
+ declare type TemplateData = Record<string, unknown>;
1110
+
832
1111
  declare class Text_2 {
833
1112
  #private;
834
1113
  readonly id: CtrlId;
835
1114
  constructor(id: CtrlId);
1115
+ /**
1116
+ * See {@link CustomControl.onRendered} for detailed information on what you can do with this listener and what it is
1117
+ * not meant for.
1118
+ *
1119
+ * Also see {@link OnRenderedCallback} for important information regarding the `element` which is passed to the
1120
+ * callback.
1121
+ */
836
1122
  onRendered(callback: OnRenderedCallback<HTMLSpanElement>): CallbackUnsubscribeOption;
837
1123
  setVisible(visible: boolean): Promise<void>;
838
1124
  setText(text: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combeenation/custom-code-sdk",
3
- "version": "0.0.1-alpha12",
3
+ "version": "0.0.1-alpha13",
4
4
  "description": "Combeenation custom code SDK package",
5
5
  "keywords": [],
6
6
  "homepage": "",
@@ -20,7 +20,7 @@
20
20
  "pack": "npm run build:clean && npm pack",
21
21
  "pub:alpha": "npm run build:clean && npm publish --tag alpha",
22
22
  "pub:beta": "npm run build:clean && npm publish --tag beta",
23
- "pub:final": "npm run build:clean && npm publish --tag latest",
23
+ "pub:final": "npm run build:clean && npm publish",
24
24
  "pub:rc": "npm run build:clean && npm publish --tag rc",
25
25
  "ts:check": "tsc --noEmit --incremental --preserveWatchOutput --pretty",
26
26
  "ts:watch": "npm run ts:check -- --watch"
@@ -30,14 +30,15 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@combeenation/configurator-client": "*",
33
+ "@microsoft/api-extractor": "7.58.7",
33
34
  "@repo/std-configs": "*",
34
35
  "@repo/std-lib": "*",
35
- "typescript": "5.8.2",
36
- "vite": "6.2.1",
37
- "vite-plugin-dts": "4.5.4"
36
+ "typescript": "6.0.3",
37
+ "unplugin-dts": "1.0.1",
38
+ "vite": "8.0.14"
38
39
  },
39
40
  "@comment dependencies": [
40
- "All our external (!) sub dependencies shall be included in `vite.config.ts:rollupOptions.external`.",
41
+ "All our external (!) sub dependencies shall be included in `vite.config.ts:rolldownOptions.external`.",
41
42
  "See comment there for more details on why."
42
43
  ],
43
44
  "@comment devDependencies": {
@@ -48,7 +49,7 @@
48
49
  "",
49
50
  "Listing it as `devDependencies` prevents the package from showing up in the builts package's `package.json` and",
50
51
  "Vite embeds the required code from the dependency directly into our built package as long as it is not listed",
51
- "in Vite's `rollupOptions.external`.",
52
+ "in Vite's `rolldownOptions.external`.",
52
53
  "",
53
54
  "In theory, we could list it as a normal dependency and pin it to a published version but that makes dev life",
54
55
  "much harder e.g. when locally testing changes to the `custom-code-sdk` in a consuming project.",