@pcg/dynamic-components 1.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/index.d.ts +1816 -0
  3. package/dist/index.js +1564 -0
  4. package/dist/index.js.map +1 -0
  5. package/eslint.config.cjs +14 -0
  6. package/package.json +30 -0
  7. package/src/assertions/basic.ts +58 -0
  8. package/src/assertions/containers.ts +76 -0
  9. package/src/assertions/index.ts +6 -0
  10. package/src/assertions/paths.ts +12 -0
  11. package/src/assertions/rich-text.ts +16 -0
  12. package/src/assertions/yjs.ts +25 -0
  13. package/src/data-objects/data-object.ts +34 -0
  14. package/src/data-objects/index.ts +3 -0
  15. package/src/data-objects/rich-text.ts +38 -0
  16. package/src/dynamic-components/fractional-indexing.ts +321 -0
  17. package/src/dynamic-components/index.ts +6 -0
  18. package/src/dynamic-components/paths.ts +194 -0
  19. package/src/dynamic-components/registry/chats.ts +24 -0
  20. package/src/dynamic-components/registry/content.ts +118 -0
  21. package/src/dynamic-components/registry/forms.ts +525 -0
  22. package/src/dynamic-components/registry/index.ts +6 -0
  23. package/src/dynamic-components/registry/layout.ts +86 -0
  24. package/src/dynamic-components/registry/uikit-dynamic-component.ts +84 -0
  25. package/src/dynamic-components/tools.ts +195 -0
  26. package/src/dynamic-components/types.ts +237 -0
  27. package/src/index.ts +7 -0
  28. package/src/paths/array-keys.ts +164 -0
  29. package/src/paths/array-ops.ts +124 -0
  30. package/src/paths/basic-ops.ts +181 -0
  31. package/src/paths/constants.ts +1 -0
  32. package/src/paths/index.ts +7 -0
  33. package/src/paths/tools.ts +42 -0
  34. package/src/paths/types.ts +133 -0
  35. package/src/y-components/index.ts +3 -0
  36. package/src/y-components/tools.ts +234 -0
  37. package/src/y-components/types.ts +19 -0
  38. package/src/y-tools/array-path-ops.ts +240 -0
  39. package/src/y-tools/basic-path-ops.ts +189 -0
  40. package/src/y-tools/index.ts +6 -0
  41. package/src/y-tools/tools.ts +122 -0
  42. package/src/y-tools/types.ts +32 -0
  43. package/src/y-tools/y-array-keys.ts +47 -0
  44. package/tests/assertions/basic-types.test.ts +78 -0
  45. package/tests/assertions/containers.test.ts +72 -0
  46. package/tests/assertions/paths.test.ts +23 -0
  47. package/tests/assertions/yjs.test.ts +33 -0
  48. package/tests/dynamic-components/paths.test.ts +171 -0
  49. package/tests/dynamic-components/tools.test.ts +121 -0
  50. package/tests/paths/array-keys.test.ts +182 -0
  51. package/tests/paths/array-ops.test.ts +164 -0
  52. package/tests/paths/basic-ops.test.ts +263 -0
  53. package/tests/paths/tools.test.ts +55 -0
  54. package/tests/y-components/tools.test.ts +198 -0
  55. package/tests/y-tools/array-base-ops.test.ts +55 -0
  56. package/tests/y-tools/array-path-ops.test.ts +95 -0
  57. package/tsconfig.json +13 -0
  58. package/tsconfig.lib.json +13 -0
  59. package/tsdown.config.ts +18 -0
  60. package/vitest.config.ts +19 -0
@@ -0,0 +1,1816 @@
1
+ import * as Y from "yjs";
2
+ import { Entries } from "type-fest";
3
+ import { JSONContent } from "@tiptap/core";
4
+
5
+ //#region src/assertions/basic.d.ts
6
+
7
+ /**
8
+ * Checks if the given parameter is callable (a function).
9
+ * @param {unknown} fn - The function to check.
10
+ * @returns {boolean} Returns true if `fn` is a function, false otherwise.
11
+ * @example
12
+ * isCallable(() => {}); // Returns true
13
+ * isCallable('Hello'); // Returns false
14
+ */
15
+ declare const isCallable: (fn: unknown) => fn is (...args: any[]) => any;
16
+ /**
17
+ * Checks if the given value is a string.
18
+ * @param {unknown} val - The value to check.
19
+ * @returns {boolean} Returns true if `val` is a string, false otherwise.
20
+ * @example
21
+ * isString('Hello'); // Returns true
22
+ * isString(123); // Returns false
23
+ */
24
+ declare const isString: (val: unknown) => val is string;
25
+ /**
26
+ * Checks if the given value is a number.
27
+ * @param {unknown} val - The value to check.
28
+ * @returns {boolean} Returns true if `val` is a number, false otherwise.
29
+ * @example
30
+ * isNumber(123); // Returns true
31
+ * isNumber('Hello'); // Returns false
32
+ */
33
+ declare const isNumber: (val: unknown) => val is number;
34
+ /**
35
+ * Checks if a given value can be used as an index (a non-negative integer).
36
+ * @param {unknown} value - The value to check.
37
+ * @returns {boolean} Returns true if `value` can be used as an index, false otherwise.
38
+ * @example
39
+ * isIndex(2); // Returns true
40
+ * isIndex('2'); // Returns true
41
+ * isIndex(-1); // Returns false
42
+ */
43
+ declare const isIndex: (value: unknown) => value is number;
44
+ /**
45
+ * Checks if the given value is null or undefined.
46
+ * @param {unknown} value - The value to check.
47
+ * @returns {boolean} Returns true if `value` is null or undefined, false otherwise.
48
+ * @example
49
+ * isNullOrUndefined(null); // Returns true
50
+ * isNullOrUndefined(undefined); // Returns true
51
+ * isNullOrUndefined('Hello'); // Returns false
52
+ */
53
+ declare const isNullOrUndefined: (value: unknown) => value is undefined | null;
54
+ //#endregion
55
+ //#region src/assertions/containers.d.ts
56
+ /**
57
+ * Checks if the given value is an empty array.
58
+ * @param {unknown} arr - The array to check.
59
+ * @returns {boolean} Returns true if `arr` is an empty array, false otherwise.
60
+ * @example
61
+ * isEmptyArray([]); // Returns true
62
+ * isEmptyArray([1, 2, 3]); // Returns false
63
+ */
64
+ declare const isEmptyArray: (arr: unknown) => boolean;
65
+ /**
66
+ * Gets the keys of the given object.
67
+ * @param {T} arr - The object to get the keys from.
68
+ * @returns {Array<keyof T>} Returns an array of keys of the given object.
69
+ * @example
70
+ * keysOf({ a: 1, b: 2 }); // Returns ['a', 'b']
71
+ */
72
+ declare const keysOf: <T>(arr: T) => (keyof T)[];
73
+ /**
74
+ * Gets the entries of the given object.
75
+ * @param {T} arr - The object to get the entries from.
76
+ * @returns {Entries<T>} Returns an array of entries of the given object.
77
+ * @example
78
+ * entriesOf({ a: 1, b: 2 }); // Returns [['a', 1], ['b', 2]]
79
+ */
80
+ declare const entriesOf: <T>(arr: T) => Entries<T>;
81
+ /**
82
+ * Checks if the given value is an object (not an array).
83
+ * @param {unknown} obj - The value to check.
84
+ * @returns {boolean} Returns true if `obj` is an object, false otherwise.
85
+ * @example
86
+ * isObject({ a: 1 }); // Returns true
87
+ * isObject([1, 2, 3]); // Returns false
88
+ */
89
+ declare const isObject: (obj: unknown) => obj is Record<string, unknown>;
90
+ /**
91
+ * Checks if the given value is a container (an object or an array).
92
+ * @param {unknown} value - The value to check.
93
+ * @returns {boolean} Returns true if `value` is a container, false otherwise.
94
+ * @example
95
+ * isContainerValue({ a: 1 }); // Returns true
96
+ * isContainerValue([1, 2, 3]); // Returns true
97
+ * isContainerValue('Hello'); // Returns false
98
+ */
99
+ declare const isContainerValue: (value: unknown) => value is Record<string, unknown>;
100
+ /**
101
+ * Checks if the given value is an empty container (an empty object or array).
102
+ * @param {unknown} value - The value to check.
103
+ * @returns {boolean} Returns true if `value` is an empty container, false otherwise.
104
+ * @example
105
+ * isEmptyContainer({}); // Returns true
106
+ * isEmptyContainer([]); // Returns true
107
+ * isEmptyContainer({ a: 1 }); // Returns false
108
+ * isEmptyContainer([1, 2, 3]); // Returns false
109
+ */
110
+ declare const isEmptyContainer: (value: unknown) => boolean;
111
+ //#endregion
112
+ //#region src/assertions/paths.d.ts
113
+ /**
114
+ * Checks if two paths are equal.
115
+ * @param {(string | number)[]} path - The first path to compare.
116
+ * @param {(string | number)[]} toPath - The second path to compare.
117
+ * @returns {boolean} Returns true if both paths are of the same length and all corresponding elements are equal, false otherwise.
118
+ * @example
119
+ * isEqualPath(['items', 'id:xxx', 'name'], ['items', 'id:xxx', 'name']); // Returns true
120
+ * isEqualPath(['items', 'id:yyy', 'name'], ['items', 'id:xxx', 'name']); // Returns false
121
+ */
122
+ declare const isEqualPath: (path: (string | number)[], toPath: (string | number)[]) => boolean;
123
+ //#endregion
124
+ //#region src/data-objects/data-object.d.ts
125
+ /**
126
+ * The BaseDataObject interface represents a basic structure of a data object.
127
+ * It includes an `id` and a `type` string.
128
+ *
129
+ * @interface
130
+ * @example
131
+ * {
132
+ * id: 'xxx',
133
+ * tiptap: { ... },
134
+ * type: 'RichText'
135
+ * }
136
+ */
137
+ interface BaseDataObject {
138
+ /**
139
+ * The unique identifier for the data object.
140
+ */
141
+ id: string;
142
+ /**
143
+ * The type of the data object. It's used for differentiating different types of data objects.
144
+ */
145
+ type: string;
146
+ }
147
+ /**
148
+ * Gets the key of the data object. The key is a string combining `type` and `id` of the data object, separated by a colon.
149
+ * @param {BaseDataObject} dataObject - The data object to get the key from.
150
+ * @returns {string} Returns the key of the data object.
151
+ * @example
152
+ * getDataObjectKey({ id: 'xxx', type: 'RichText' }); // Returns 'RichText:xxx'
153
+ */
154
+ declare const getDataObjectKey: (dataObject: BaseDataObject) => string;
155
+ //#endregion
156
+ //#region src/data-objects/rich-text.d.ts
157
+ /**
158
+ * The RichText interface represents a rich text data object.
159
+ *
160
+ * @interface
161
+ * @example
162
+ * {
163
+ * id: 'xx',
164
+ * tiptap: { ... },
165
+ * html: '<p>...</p>',
166
+ * plaintext: '...',
167
+ * type: 'RichText'
168
+ * }
169
+ */
170
+ interface RichText extends BaseDataObject {
171
+ /**
172
+ * The TipTap JSON content of the rich text data object.
173
+ */
174
+ tiptap?: JSONContent;
175
+ /**
176
+ * The HTML representation of the rich text data object.
177
+ */
178
+ html?: string;
179
+ /**
180
+ * The plaintext representation of the rich text data object.
181
+ */
182
+ plaintext?: string;
183
+ /**
184
+ * The type of the rich text data object, set to 'RichText'.
185
+ */
186
+ type: 'RichText';
187
+ }
188
+ //#endregion
189
+ //#region src/assertions/rich-text.d.ts
190
+ /**
191
+ * Checks if the given value is a RichText object.
192
+ * @param {unknown} value - The value to check.
193
+ * @returns {boolean} Returns true if `value` is a RichText object, false otherwise.
194
+ * @example
195
+ * isRichText({ id: 'xx', ... type: 'RichText' }); // Returns true
196
+ */
197
+ declare const isRichText: (value: unknown) => value is RichText;
198
+ //#endregion
199
+ //#region src/assertions/yjs.d.ts
200
+ /**
201
+ * Checks if the given value is a Yjs Map.
202
+ * @param {unknown} yMap - The value to check.
203
+ * @returns {boolean} Returns true if `yMap` is a Yjs Map, false otherwise.
204
+ * @example
205
+ * const yMap = new Y.Map();
206
+ * isYMap(yMap); // Returns true
207
+ */
208
+ declare const isYMap: <T = unknown>(yMap: unknown) => yMap is Y.Map<T>;
209
+ /**
210
+ * Checks if the given value is a Yjs Array.
211
+ * @param {unknown} yArray - The value to check.
212
+ * @returns {boolean} Returns true if `yArray` is a Yjs Array, false otherwise.
213
+ * @example
214
+ * const yArray = new Y.Array();
215
+ * isYArray(yArray); // Returns true
216
+ */
217
+ declare const isYArray: <T = unknown>(yArray: unknown) => yArray is Y.Array<T>;
218
+ //#endregion
219
+ //#region src/dynamic-components/fractional-indexing.d.ts
220
+ /**
221
+ * @param {string | null} a
222
+ * @param {string | null} b
223
+ * @param {string=} digits
224
+ * @return {string}
225
+ */
226
+ declare const generateKeyBetween: (a: string | null, b: string | null, digits?: string) => string;
227
+ //#endregion
228
+ //#region src/dynamic-components/types.d.ts
229
+ type Point = [number, number];
230
+ interface DynamicComponentIO {
231
+ id: string;
232
+ name: string;
233
+ }
234
+ /**
235
+ * Represents a link between two dynamic components.
236
+ */
237
+ interface DynamicComponentLink {
238
+ /** The unique identifier of the link. */
239
+ id: string;
240
+ /** The input of the link. */
241
+ input: string;
242
+ /** The output of the link. */
243
+ output: string;
244
+ }
245
+ /**
246
+
247
+ /**
248
+ * ValidationRules interface is used for defining the set of
249
+ * validation constraints for a field in a form or component.
250
+ *
251
+ * @example
252
+ * let rules: ValidationRules = {
253
+ * required: true,
254
+ * min: 1,
255
+ * max: 100,
256
+ * pattern: 'email'
257
+ * };
258
+ */
259
+ interface ValidationRules {
260
+ /**
261
+ * Indicates whether the field is required or not.
262
+ */
263
+ required?: boolean;
264
+ /**
265
+ * Specifies the minimum value for the field.
266
+ */
267
+ min?: number;
268
+ /**
269
+ * Specifies the maximum value for the field.
270
+ */
271
+ max?: number;
272
+ /**
273
+ * Specifies a pattern that the field value should match.
274
+ */
275
+ pattern?: 'email' | 'url' | 'hh:mm:ss' | 'phone';
276
+ /**
277
+ *Specifies whether to trim spaces.
278
+ */
279
+ trim?: boolean;
280
+ }
281
+ interface ComponentStyles {
282
+ /**
283
+ * Specifies the top padding of the component.
284
+ */
285
+ paddingTop?: string;
286
+ /**
287
+ * Specifies the bottom padding of the component.
288
+ */
289
+ paddingBottom?: string;
290
+ }
291
+ /**
292
+ * DynamicComponent is a key feature of the component designer.
293
+ * It is a data structure used to describe dynamic components,
294
+ * which can be added to the content by the component designer and their properties can be edited on the fly.
295
+ * The output of the designer is a tree of dynamic components.
296
+ *
297
+ * For example, a text input component can be described as follows:
298
+ * ```typescript
299
+ * export interface DTextInput extends DynamicComponent {
300
+ * component: 'text-input';
301
+ * props: {
302
+ * name?: string;
303
+ * label?: string;
304
+ * placeholder?: string;
305
+ * maska?: string;
306
+ * disabled?: boolean;
307
+ * readonly?: boolean;
308
+ * rules?: ValidationRules;
309
+ * visible?: string;
310
+ * };
311
+ * }
312
+ * ```
313
+ */
314
+ interface DynamicComponent {
315
+ /**
316
+ * The unique identifier of the component.
317
+ */
318
+ id: string;
319
+ /**
320
+ * The type of the component.
321
+ */
322
+ component: string;
323
+ /**
324
+ * The variant of the component.
325
+ * For example, a button component can have variants like 'primary', 'secondary', etc.
326
+ */
327
+ variant?: string;
328
+ /**
329
+ * The position of the component.
330
+ */
331
+ position?: string;
332
+ /**
333
+ * A flag indicating whether the component is enabled or not.
334
+ */
335
+ enabled?: boolean;
336
+ /**
337
+ * The coordinated of the component in the canvas.
338
+ */
339
+ coordinates?: Point;
340
+ /**
341
+ * The inputs of the component.
342
+ * Input ports are used to connect the component to other components.
343
+ */
344
+ inputs?: DynamicComponentIO[];
345
+ /**
346
+ * The outputs of the component.
347
+ * Output ports are used to connect the component to other components.
348
+ */
349
+ outputs?: DynamicComponentIO[];
350
+ /**
351
+ * The properties of the component.
352
+ */
353
+ props: {
354
+ /**
355
+ * The name of the component.
356
+ */
357
+ name?: string;
358
+ /**
359
+ * The visibility of the component.
360
+ */
361
+ visible?: string;
362
+ /**
363
+ * The readonly status of the component.
364
+ */
365
+ readonly?: boolean;
366
+ /**
367
+ * The child components of the component.
368
+ */
369
+ components?: DynamicComponent[];
370
+ /**
371
+ * The validation rules for the component.
372
+ */
373
+ rules?: ValidationRules;
374
+ /**
375
+ * The styles for the component.
376
+ */
377
+ styles?: ComponentStyles;
378
+ /**
379
+ * Any other properties of the component.
380
+ */
381
+ [key: string]: unknown;
382
+ };
383
+ }
384
+ /**
385
+ * DynamicComponent is a key feature of the component designer.
386
+ * It is a data structure used to describe dynamic components ,
387
+ * which can be added to the content by the component designer and their properties can be edited on the fly.
388
+ * The output of the designer is a tree of dynamic components.
389
+ *
390
+ * DynamicComponentWithPosition is a DynamicComponent with defind fractional-indexed position.
391
+ *
392
+ * For example, a text input component can be described as follows:
393
+ * ```typescript
394
+ * {
395
+ * component: 'text-input';
396
+ * props: {
397
+ * name: 'email';
398
+ * label:: string;
399
+ * placeholder?: string;
400
+ * maska?: string;
401
+ * disabled?: boolean;
402
+ * readonly?: boolean;
403
+ * rules?: ValidationRules;
404
+ * visible?: string;
405
+ * };
406
+ * }
407
+ * ```
408
+ */
409
+ interface DynamicComponentWithPosition extends DynamicComponent {
410
+ /**
411
+ * The position of the component. This is required for DynamicComponentWithPosition.
412
+ */
413
+ position: string;
414
+ /**
415
+ * The properties of the component.
416
+ */
417
+ props: DynamicComponent['props'] & {
418
+ /**
419
+ * The child components of the component.
420
+ */
421
+ components?: DynamicComponentWithPosition[];
422
+ };
423
+ }
424
+ /**
425
+ * Defines a DynamicComponent.
426
+ * @param {T} component - The component to define.
427
+ * @returns {T} Returns the defined component.
428
+ */
429
+ declare const defineDynamicComponent: <T extends DynamicComponent>(component: T) => T;
430
+ /**
431
+ * Defines an array of DynamicComponents.
432
+ * @param {T[]} components - The components to define.
433
+ * @returns {T[]} Returns the defined components.
434
+ */
435
+ declare const defineDynamicComponents: <T extends DynamicComponent>(components: T[]) => T[];
436
+ //#endregion
437
+ //#region src/dynamic-components/paths.d.ts
438
+ /**
439
+ * Get array with components founded by rpath
440
+ *
441
+ * @example
442
+ * const components = [
443
+ * {
444
+ * id: "xxx",
445
+ * component: "collection",
446
+ * props: {
447
+ * components: [
448
+ * {
449
+ * id: "yyy",
450
+ * component: "text-input",
451
+ * props: {
452
+ * label: "Title"
453
+ * }
454
+ * }
455
+ * ]
456
+ * }
457
+ * }
458
+ * ]
459
+ *
460
+ * const { pathWithComponents } = getComponentsSubtreeByRPath(components, ['xxx', 'yyy']);
461
+ *
462
+ * // pathWithComponents
463
+ * // [
464
+ * // {
465
+ * // id: "xxx",
466
+ * // component: "collection",
467
+ * // ...
468
+ * // },
469
+ * // {
470
+ * // id: "yyy",
471
+ * // component: "text-input",
472
+ * // ...
473
+ * // }
474
+ * // ]
475
+ *
476
+ */
477
+ declare const getComponentsSubtreeByRPath: (components: DynamicComponent[], rpath: string[]) => {
478
+ pathWithComponents: DynamicComponent[];
479
+ complete: boolean;
480
+ };
481
+ /**
482
+ * Get array with components founded by values path.
483
+ *
484
+ * @example
485
+ * const components = [
486
+ * {
487
+ * id: "xxx",
488
+ * component: "collection",
489
+ * props: {
490
+ * name: "seo",
491
+ * components: [
492
+ * {
493
+ * id: "yyy",
494
+ * component: "text-input",
495
+ * props: {
496
+ * label: "Title",
497
+ * name: "title",
498
+ * }
499
+ * }
500
+ * ]
501
+ * }
502
+ * }
503
+ * ]
504
+ *
505
+ * const { pathWithComponents } = getComponentsSubtreeByPath(components, ['seo', 'title']);
506
+ *
507
+ * // pathWithComponents
508
+ * // [
509
+ * // {
510
+ * // id: "xxx",
511
+ * // component: "collection",
512
+ * // ...
513
+ * // },
514
+ * // {
515
+ * // id: "yyy",
516
+ * // component: "text-input",
517
+ * // ...
518
+ * // }
519
+ * // ]
520
+ *
521
+ */
522
+ declare const getComponentsSubtreeByPath: (components: DynamicComponent[], path: (string | number)[]) => {
523
+ pathWithComponents: DynamicComponent[];
524
+ complete: boolean;
525
+ };
526
+ //#endregion
527
+ //#region src/dynamic-components/registry/chats.d.ts
528
+ interface DChatTextMessage extends DynamicComponent {
529
+ component: 'chat-text-message';
530
+ props: {
531
+ content: RichText;
532
+ };
533
+ }
534
+ declare const isChatTextMessageComponent: (component: DynamicComponent) => component is DChatTextMessage;
535
+ interface DChatMessageDelay extends DynamicComponent {
536
+ component: 'chat-message-delay';
537
+ props: {
538
+ delay: number;
539
+ typing: boolean;
540
+ };
541
+ }
542
+ declare const isChatMessageDelayComponent: (component: DynamicComponent) => component is DChatMessageDelay;
543
+ //#endregion
544
+ //#region src/dynamic-components/registry/content.d.ts
545
+ interface DRichText extends DynamicComponent {
546
+ component: 'rich-text';
547
+ props: {
548
+ content: RichText;
549
+ };
550
+ }
551
+ declare const isRichTextComponent: (component: DynamicComponent) => component is DRichText;
552
+ interface DEmbedCode extends DynamicComponent {
553
+ component: 'embed-code';
554
+ props: {
555
+ js?: string;
556
+ css?: string;
557
+ html?: string;
558
+ visible?: string;
559
+ };
560
+ }
561
+ declare const isEmbedCodeComponent: (component: DynamicComponent) => component is DEmbedCode;
562
+ interface DImage extends DynamicComponent {
563
+ component: 'embed-code';
564
+ props: {
565
+ imageId: string;
566
+ };
567
+ }
568
+ declare const isImageComponent: (component: DynamicComponent) => component is DImage;
569
+ interface DLegacyContent extends DynamicComponent {
570
+ component: 'legacy-content';
571
+ props: {
572
+ html: string;
573
+ };
574
+ }
575
+ declare const isLegacyContentComponent: (component: DynamicComponent) => component is DLegacyContent;
576
+ interface DBibleQuote extends DynamicComponent {
577
+ component: 'bible-quote';
578
+ props: {
579
+ verseId: string;
580
+ };
581
+ }
582
+ declare const isBibleQuoteComponent: (component: DynamicComponent) => component is DBibleQuote;
583
+ interface DBiblePassage extends DynamicComponent {
584
+ component: 'bible-passage';
585
+ props: {
586
+ passage: string;
587
+ };
588
+ }
589
+ declare const isBiblePassageComponent: (component: DynamicComponent) => component is DBiblePassage;
590
+ interface TestItemVariant {
591
+ id: string;
592
+ content: RichText;
593
+ feedback?: RichText;
594
+ correct?: boolean;
595
+ }
596
+ interface TestItem {
597
+ id: string;
598
+ content: RichText;
599
+ variants: TestItemVariant[];
600
+ }
601
+ interface DTest extends DynamicComponent {
602
+ component: 'test';
603
+ props: {
604
+ title?: string;
605
+ items: TestItem[];
606
+ milestone?: string;
607
+ };
608
+ }
609
+ declare const isTestComponent: (component: DynamicComponent) => component is DTest;
610
+ interface DStatement extends DynamicComponent {
611
+ component: 'statement';
612
+ props: {
613
+ content: RichText;
614
+ };
615
+ }
616
+ declare const isStatementComponent: (component: DynamicComponent) => component is DStatement;
617
+ interface DPractice extends DynamicComponent {
618
+ component: 'practice';
619
+ props: {
620
+ title?: string;
621
+ content: RichText;
622
+ /**
623
+ * Date when the practice should be checked in ISO 8601 format
624
+ * @example '2023-10-01T00:08:00Z'
625
+ */
626
+ checkAt?: string;
627
+ };
628
+ }
629
+ declare const isPracticeComponent: (component: DynamicComponent) => component is DPractice;
630
+ //#endregion
631
+ //#region src/dynamic-components/registry/forms.d.ts
632
+ type ISizeType = 'middle' | 'large';
633
+ declare enum IImageRenditionType {
634
+ ORIGINAL = "ORIGINAL",
635
+ MAIN_2X = "MAIN_2X",
636
+ MAIN = "MAIN",
637
+ SMALL = "SMALL",
638
+ MAIN_LEGACY = "MAIN_LEGACY",
639
+ }
640
+ interface IRenditionOptions {
641
+ width: number;
642
+ height: number;
643
+ type: IImageRenditionType;
644
+ mimeType?: string;
645
+ quality?: number;
646
+ }
647
+ interface DHiddenInput extends DynamicComponent {
648
+ component: 'hidden-input';
649
+ props: {
650
+ name?: string;
651
+ rules?: ValidationRules;
652
+ testId?: string;
653
+ };
654
+ }
655
+ interface DComputedValue extends DynamicComponent {
656
+ component: 'computed-value';
657
+ props: {
658
+ name?: string;
659
+ label?: string;
660
+ placeholder?: string;
661
+ type: 'string' | 'number';
662
+ expression: string;
663
+ rules?: ValidationRules;
664
+ visible?: string;
665
+ testId?: string;
666
+ };
667
+ }
668
+ declare const isComputedValueComponent: (component: DynamicComponent) => component is DComputedValue;
669
+ interface DTextInput extends DynamicComponent {
670
+ component: 'text-input';
671
+ props: {
672
+ name?: string;
673
+ label?: string;
674
+ placeholder?: string;
675
+ hint?: string;
676
+ clearable?: boolean;
677
+ maska?: string;
678
+ disabled?: boolean;
679
+ readonly?: boolean;
680
+ rules?: ValidationRules;
681
+ visible?: string;
682
+ testId?: string;
683
+ };
684
+ }
685
+ declare const isTextInputComponent: (component: DynamicComponent) => component is DTextInput;
686
+ interface DConfirmDeletionInput extends DynamicComponent {
687
+ component: 'confirm-deletion-input';
688
+ props: {
689
+ title?: string;
690
+ text?: string;
691
+ keyWord: string;
692
+ testId?: string;
693
+ };
694
+ }
695
+ declare const isConfirmDeletionInputComponent: (component: DynamicComponent) => component is DConfirmDeletionInput;
696
+ interface DTextarea extends DynamicComponent {
697
+ component: 'textarea';
698
+ props: {
699
+ name?: string;
700
+ label?: string;
701
+ placeholder?: string;
702
+ hint?: string;
703
+ rows?: number;
704
+ autosize?: boolean;
705
+ lineBreak?: boolean;
706
+ disabled?: boolean;
707
+ readonly?: boolean;
708
+ rules?: ValidationRules;
709
+ visible?: string;
710
+ testId?: string;
711
+ };
712
+ }
713
+ declare const isTextareaComponent: (component: DynamicComponent) => component is DTextarea;
714
+ interface DHeading extends DynamicComponent {
715
+ component: 'heading';
716
+ props: {
717
+ text: string;
718
+ visible?: string;
719
+ testId?: string;
720
+ };
721
+ }
722
+ declare const isHeadingComponent: (component: DynamicComponent) => component is DHeading;
723
+ interface DRichTextEditor extends DynamicComponent {
724
+ component: 'rich-text-editor';
725
+ props: {
726
+ name?: string;
727
+ label?: string;
728
+ placeholder?: string;
729
+ minHeight?: number;
730
+ maxLength?: number;
731
+ rules?: ValidationRules;
732
+ visible?: string;
733
+ testId?: string;
734
+ };
735
+ }
736
+ declare const isRichTextEditorComponent: (component: DynamicComponent) => component is DRichTextEditor;
737
+ interface DDateTimePicker extends DynamicComponent {
738
+ component: 'date-time-picker';
739
+ props: {
740
+ name?: string;
741
+ label?: string;
742
+ placeholder?: string;
743
+ hint?: string;
744
+ type?: 'year' | 'month' | 'date' | 'dates' | 'week' | 'datetime' | 'datetimerange' | 'daterange' | 'monthrange';
745
+ readonly?: boolean;
746
+ format?: string;
747
+ clearable?: boolean;
748
+ rules?: {
749
+ required?: boolean;
750
+ };
751
+ visible?: string;
752
+ testId?: string;
753
+ };
754
+ }
755
+ declare const isDateTimePickerComponent: (component: DynamicComponent) => component is DDateTimePicker;
756
+ interface DNumberInput extends DynamicComponent {
757
+ component: 'number-input';
758
+ props: {
759
+ name?: string;
760
+ label?: string;
761
+ placeholder?: string;
762
+ hint?: string;
763
+ autosize?: boolean;
764
+ readonly?: boolean;
765
+ rules?: ValidationRules;
766
+ visible?: string;
767
+ testId?: string;
768
+ };
769
+ }
770
+ declare const isNumberInputComponent: (component: DynamicComponent) => component is DNumberInput;
771
+ interface DSlug extends DynamicComponent {
772
+ component: 'slug';
773
+ props: {
774
+ name?: string;
775
+ source?: string;
776
+ maxLength?: number;
777
+ readonly?: boolean;
778
+ rules?: {
779
+ required?: boolean;
780
+ };
781
+ visible?: string;
782
+ testId?: string;
783
+ };
784
+ }
785
+ declare const isSlugComponent: (component: DynamicComponent) => component is DSlug;
786
+ interface DImageUploader extends DynamicComponent {
787
+ component: 'image-uploader';
788
+ props: {
789
+ name?: string;
790
+ label?: string;
791
+ renditions: {
792
+ id: string;
793
+ position: string;
794
+ width: number;
795
+ height: number;
796
+ type: IImageRenditionType;
797
+ }[];
798
+ btnText?: string;
799
+ size?: ISizeType;
800
+ rounded?: ISizeType;
801
+ zoomable?: boolean;
802
+ downloadable?: boolean;
803
+ height?: number;
804
+ width?: number;
805
+ tooltipContent?: string;
806
+ hideTooltip?: boolean;
807
+ maxFileSize?: number;
808
+ readonly?: boolean;
809
+ visible?: string;
810
+ rules?: {
811
+ required?: boolean;
812
+ };
813
+ testId?: string;
814
+ };
815
+ }
816
+ declare const isImageUploaderComponent: (component: DynamicComponent) => component is DImageUploader;
817
+ interface DRawImageUploader extends DynamicComponent {
818
+ component: 'raw-image-uploader';
819
+ props: {
820
+ name?: string;
821
+ label?: string;
822
+ btnText?: string;
823
+ size?: ISizeType;
824
+ rounded?: boolean;
825
+ zoomable?: boolean;
826
+ downloadable?: boolean;
827
+ height?: number;
828
+ width?: number;
829
+ hideTooltip?: boolean;
830
+ tooltipContent?: string;
831
+ maxFileSize?: number;
832
+ visible?: string;
833
+ readonly?: boolean;
834
+ rules?: {
835
+ required?: boolean;
836
+ };
837
+ testId?: string;
838
+ };
839
+ }
840
+ declare const isRawImageUploaderComponent: (component: DynamicComponent) => component is DRawImageUploader;
841
+ interface DRawImagesUploader extends DynamicComponent {
842
+ component: 'raw-images-uploader';
843
+ props: {
844
+ name?: string;
845
+ label?: string;
846
+ btnText?: string;
847
+ size?: ISizeType;
848
+ rounded?: boolean;
849
+ zoomable?: boolean;
850
+ downloadable?: boolean;
851
+ height?: number;
852
+ width?: number;
853
+ tooltipContent?: string;
854
+ hideTooltip?: boolean;
855
+ maxFileSize?: number;
856
+ visible?: string;
857
+ readonly?: boolean;
858
+ rules?: {
859
+ required?: boolean;
860
+ max?: number;
861
+ };
862
+ testId?: string;
863
+ };
864
+ }
865
+ declare const isRawImagesUploaderComponent: (component: DynamicComponent) => component is DRawImagesUploader;
866
+ interface DSimpleImageUploader extends DynamicComponent {
867
+ component: 'simple-image-uploader';
868
+ props: {
869
+ name?: string;
870
+ label?: string;
871
+ rendition: {
872
+ width: number;
873
+ height: number;
874
+ type: IImageRenditionType;
875
+ };
876
+ btnText?: string;
877
+ size?: ISizeType;
878
+ rounded?: boolean;
879
+ zoomable?: boolean;
880
+ downloadable?: boolean;
881
+ width: number;
882
+ height: number;
883
+ hideTooltip?: boolean;
884
+ tooltipContent?: string;
885
+ maxFileSize?: number;
886
+ readonly?: boolean;
887
+ visible?: string;
888
+ rules?: {
889
+ required?: boolean;
890
+ };
891
+ testId?: string;
892
+ };
893
+ }
894
+ declare const isSimpleImageUploaderComponent: (component: DynamicComponent) => component is DSimpleImageUploader;
895
+ interface DRadioGroup extends DynamicComponent {
896
+ component: 'radio-group';
897
+ props: {
898
+ name?: string;
899
+ label?: string;
900
+ cols?: number;
901
+ direction?: 'col' | 'row';
902
+ items: {
903
+ id: string;
904
+ position: string;
905
+ value: unknown;
906
+ label: string;
907
+ }[];
908
+ readonly?: boolean;
909
+ rules?: {
910
+ required?: boolean;
911
+ };
912
+ visible?: string;
913
+ testId?: string;
914
+ };
915
+ }
916
+ declare const isRadioGroupComponent: (component: DynamicComponent) => component is DRadioGroup;
917
+ interface DSelect extends DynamicComponent {
918
+ component: 'select';
919
+ props: {
920
+ name?: string;
921
+ label?: string;
922
+ placeholder?: string;
923
+ hint?: string;
924
+ clearable?: boolean;
925
+ options: {
926
+ id: string;
927
+ position: string;
928
+ value: unknown;
929
+ label: string;
930
+ imageUrl?: string;
931
+ disabled?: boolean;
932
+ }[];
933
+ readonly?: boolean;
934
+ multiple?: boolean;
935
+ rules?: {
936
+ required?: boolean;
937
+ max?: number;
938
+ };
939
+ visible?: string;
940
+ testId?: string;
941
+ };
942
+ }
943
+ declare const isSelectComponent: (cmp: DynamicComponent) => cmp is DSelect;
944
+ interface DEntitySelect extends DynamicComponent {
945
+ component: 'entity-select';
946
+ props: {
947
+ name?: string;
948
+ label?: string;
949
+ placeholder?: string;
950
+ hint?: string;
951
+ entityType: string;
952
+ labelKey?: string;
953
+ idKey?: string;
954
+ filter?: Record<string, unknown>;
955
+ limit?: number;
956
+ multiple?: boolean;
957
+ visible?: string;
958
+ clearable?: boolean;
959
+ rules?: {
960
+ required?: boolean;
961
+ };
962
+ readonly?: boolean;
963
+ excludeIds?: string[];
964
+ imageUrlKey?: string;
965
+ defaultImageUrl?: string;
966
+ testId?: string;
967
+ };
968
+ }
969
+ declare const isEntitySelectComponent: (cmp: DynamicComponent) => cmp is DEntitySelect;
970
+ interface DCheckbox extends DynamicComponent {
971
+ component: 'checkbox';
972
+ props: {
973
+ name?: string;
974
+ label?: string;
975
+ readonly?: boolean;
976
+ rules?: {
977
+ required?: boolean;
978
+ };
979
+ visible?: string;
980
+ testId?: string;
981
+ };
982
+ }
983
+ declare const isCheckboxComponent: (component: DynamicComponent) => component is DCheckbox;
984
+ interface DCheckboxGroup extends DynamicComponent {
985
+ component: 'checkbox-group';
986
+ props: {
987
+ name?: string;
988
+ label?: string;
989
+ orientation?: 'horizontal' | 'vertical';
990
+ items: {
991
+ id: string;
992
+ position: string;
993
+ value: unknown;
994
+ label: string;
995
+ }[];
996
+ readonly?: boolean;
997
+ visible?: string;
998
+ rules?: {
999
+ required?: boolean;
1000
+ };
1001
+ testId?: string;
1002
+ };
1003
+ }
1004
+ declare const isCheckboxGroupComponent: (component: DynamicComponent) => component is DCheckboxGroup;
1005
+ interface DSwitch extends DynamicComponent {
1006
+ component: 'switch';
1007
+ props: {
1008
+ name?: string;
1009
+ label?: string;
1010
+ readonly?: boolean;
1011
+ visible?: string;
1012
+ rules?: {
1013
+ required?: boolean;
1014
+ };
1015
+ testId?: string;
1016
+ };
1017
+ }
1018
+ declare const isSwitchComponent: (component: DynamicComponent) => component is DSwitch;
1019
+ interface DFileUploader extends DynamicComponent {
1020
+ component: 'file-uploader';
1021
+ props: {
1022
+ name?: string;
1023
+ label?: string;
1024
+ accept?: string;
1025
+ placeholder?: string;
1026
+ maxFileSize?: number;
1027
+ downloadable?: boolean;
1028
+ readonly?: boolean;
1029
+ visible?: string;
1030
+ rules?: {
1031
+ required?: boolean;
1032
+ };
1033
+ testId?: string;
1034
+ };
1035
+ }
1036
+ declare const isFileUploaderComponent: (component: DynamicComponent) => component is DFileUploader;
1037
+ //#endregion
1038
+ //#region src/dynamic-components/registry/layout.d.ts
1039
+ interface DColumn extends DynamicComponent {
1040
+ component: 'column';
1041
+ props: {
1042
+ size: number;
1043
+ visible?: string;
1044
+ justifySelf?: 'start' | 'center' | 'end' | 'stretch';
1045
+ placeSelf?: 'start' | 'center' | 'end' | 'stretch';
1046
+ components: DynamicComponent[];
1047
+ };
1048
+ }
1049
+ declare const isColumnComponent: (component: DynamicComponent) => component is DColumn;
1050
+ interface DRow extends DynamicComponent {
1051
+ component: 'row';
1052
+ props: {
1053
+ components: DColumn[];
1054
+ visible?: string;
1055
+ placeItems?: 'start' | 'center' | 'end' | 'stretch';
1056
+ justifyItems?: 'start' | 'center' | 'end' | 'stretch';
1057
+ };
1058
+ }
1059
+ declare const isRowComponent: (component: DynamicComponent) => component is DRow;
1060
+ interface DCollection extends DynamicComponent {
1061
+ component: 'collection';
1062
+ props: {
1063
+ name?: string;
1064
+ heading: string;
1065
+ components: DynamicComponent[];
1066
+ rules?: ValidationRules;
1067
+ readonly?: boolean;
1068
+ visible?: string;
1069
+ };
1070
+ }
1071
+ declare const isCollectionComponent: (component: DynamicComponent) => component is DCollection;
1072
+ interface DRepeatableCollection extends DynamicComponent {
1073
+ component: 'repeatable-collection';
1074
+ props: {
1075
+ name?: string;
1076
+ heading: string;
1077
+ collectionTitle?: string;
1078
+ useTabs?: boolean;
1079
+ cols?: number;
1080
+ tabName?: string;
1081
+ confirmDeletion?: boolean;
1082
+ addButtonText?: string;
1083
+ readonly?: boolean;
1084
+ components: DynamicComponent[];
1085
+ visible?: string;
1086
+ rules?: {
1087
+ required?: boolean;
1088
+ };
1089
+ };
1090
+ }
1091
+ declare const isRepeatableCollectionComponent: (component: DynamicComponent) => component is DRepeatableCollection;
1092
+ interface DRowSettings extends DynamicComponent {
1093
+ component: 'row-settings';
1094
+ props: {
1095
+ label?: string;
1096
+ };
1097
+ }
1098
+ declare const isRowSettingsComponent: (component: DynamicComponent) => component is DRowSettings;
1099
+ //#endregion
1100
+ //#region src/dynamic-components/registry/uikit-dynamic-component.d.ts
1101
+ type FormDynamicComponent = DTextInput | DCheckbox | DTextarea | DSelect | DEntitySelect | DRadioGroup | DCheckboxGroup | DFileUploader | DImageUploader | DSimpleImageUploader | DRawImageUploader | DSlug | DEmbedCode | DRichTextEditor | DNumberInput | DSwitch | DHeading | DRawImagesUploader | DDateTimePicker | DComputedValue | DHiddenInput | DConfirmDeletionInput;
1102
+ type UiKitContentDynamicComponent = DRichText | DEmbedCode | DImage | DBibleQuote | DBiblePassage;
1103
+ type UiKitLayoutDynamicComponent = DRow | DColumn | DRowSettings | DCollection | DRepeatableCollection;
1104
+ type UiKitChatDynamicComponent = DChatTextMessage;
1105
+ type UiKitDynamicComponent = FormDynamicComponent | UiKitContentDynamicComponent | UiKitLayoutDynamicComponent | UiKitChatDynamicComponent;
1106
+ //#endregion
1107
+ //#region src/dynamic-components/tools.d.ts
1108
+ declare const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1109
+ declare const customAlphabet: (alphabet: string, defaultSize?: number) => (size?: number) => string;
1110
+ declare const uid: (size?: number) => string;
1111
+ /**
1112
+ * Gets the path to a property in a component.
1113
+ * @param {(string | number)[]} componentPath - The path to the component.
1114
+ * @param {string} name - The name of the property.
1115
+ * @returns {(string | number)[]} Returns the path to the property.
1116
+ * @example
1117
+ * getComponentPropertyPath(['components', 0], 'name'); // Returns ['components', 0, 'props', 'name']
1118
+ */
1119
+ declare const getComponentPropertyPath: (componentPath: (string | number)[], name: string) => (string | number)[];
1120
+ /**
1121
+ * Creates a copy of a dynamic component.
1122
+ * @param {DynamicComponent} component - The component to copy.
1123
+ * @param {Y.Doc} yDoc - The Yjs document to update with the copied component.
1124
+ * @returns {DynamicComponent} Returns the copied component.
1125
+ */
1126
+ declare const copyDynamicComponent: (component: DynamicComponent, yDoc?: Y.Doc) => DynamicComponent;
1127
+ /**
1128
+ * Sorts an array of dynamic components and generates a position for each one.
1129
+ * @param {DynamicComponent[]} components - The components to sort.
1130
+ * @returns {DynamicComponentWithPosition[]} Returns the sorted components with positions.
1131
+ */
1132
+ declare const sortDynamicComponents: (components: DynamicComponent[]) => DynamicComponentWithPosition[];
1133
+ /**
1134
+ * Searches for a dynamic component in a tree that matches a condition.
1135
+ * @param {DynamicComponent[]} components - The tree of components to search.
1136
+ * @param {(cmp: DynamicComponent) => boolean} isMatches - The condition to match.
1137
+ * @returns {DynamicComponent | null} Returns the matching component, or null if no match was found.
1138
+ */
1139
+ declare const searchDynamicComponentInTree: (components: DynamicComponent[], isMatches: (cmp: DynamicComponent) => boolean) => DynamicComponent | null;
1140
+ declare const getRelativePoint: (point: Point, relative: Point) => Point;
1141
+ /**
1142
+ * Creates a copy of a dynamic component and set its position (fractional-index) rely on the index of the component.
1143
+ * @param components - The components without positions.
1144
+ */
1145
+ declare const makeDynamicComponentsWithPosition: (components: DynamicComponent[]) => DynamicComponentWithPosition[];
1146
+ //#endregion
1147
+ //#region src/paths/array-keys.d.ts
1148
+ /**
1149
+ * In the system you are using, two types of keys are used to identify elements in an array: ID keys and position keys.
1150
+ * These keys provide a flexible and robust way to refer to specific elements in an array, particularly when dealing with arrays of objects.
1151
+ *
1152
+ * 1. **ID Keys:**
1153
+ * These keys have a prefix of 'id:' and are followed by the unique identifier of an object in the array.
1154
+ * For example, in your array `items: [{ id: 'xxx', name: 'John' }]`, you can refer to the object with `id: 'xxx'` using the ID key 'id:xxx'.
1155
+ * This is particularly useful when you have a unique identifier for each object in your array.
1156
+ * With this, even if objects move around in the array, you can always accurately refer to a specific object using its unique ID.
1157
+ *
1158
+ * 2. **Position Keys:**
1159
+ * These keys have a prefix of 'pos:' and are followed by a position indicator.
1160
+ * Position keys provide a way to refer to an object in an array based on its position rather than its content.
1161
+ * This can be useful when the position of an object in an array is significant and you want to refer to an object based on where it is in the array.
1162
+ *
1163
+ * In your path system, you can use either type of key as part of the path to refer to specific elements in an array.
1164
+ * For example, if you have an object like `{ items: [{ id: 'xxx', name: 'John' }] }`,
1165
+ * you can refer to the name of the first item in the array using either an ID key or a position key in the path:
1166
+ *
1167
+ * - Using an ID key: `['items', 'id:xxx', 'name']`
1168
+ * - Using a position key: `['items', 'pos:0', 'name']`
1169
+ *
1170
+ * This system of using ID and position keys in paths gives you a powerful and flexible way to refer to specific elements in complex, nested objects.
1171
+ */
1172
+ declare const POSITION_ARRAY_KEY_PREFIX = "pos:";
1173
+ /**
1174
+ * Checks if the given key is a position array key.
1175
+ * @param {unknown} key - The key to check.
1176
+ * @returns {boolean} Returns true if `key` is a position array key, false otherwise.
1177
+ * @example
1178
+ * isPositionArrayKey('pos:0'); // Returns true
1179
+ * isPositionArrayKey('id:0'); // Returns false
1180
+ */
1181
+ declare const isPositionArrayKey: (key: unknown) => key is string;
1182
+ /**
1183
+ * Creates a position array key.
1184
+ * @param {string} position - The position to create the key for.
1185
+ * @returns {string} Returns the created position array key.
1186
+ * @example
1187
+ * createPositionArrayKey('0'); // Returns 'pos:0'
1188
+ */
1189
+ declare const createPositionArrayKey: (position: string) => string;
1190
+ /**
1191
+ * Extracts the position from a position array key.
1192
+ * @param {string} key - The position array key to extract the position from.
1193
+ * @returns {string} Returns the extracted position.
1194
+ * @example
1195
+ * extractPositionFromArrayKey('pos:0'); // Returns '0'
1196
+ */
1197
+ declare const extractPositionFromArrayKey: (key: string) => string;
1198
+ declare const ID_PATH_KEY_PREFIX = "id:";
1199
+ /**
1200
+ * Checks if the given key is an ID array key.
1201
+ * @param {unknown} key - The key to check.
1202
+ * @returns {boolean} Returns true if `key` is an ID array key, false otherwise.
1203
+ * @example
1204
+ * isIdArrayKey('id:123'); // Returns true
1205
+ * isIdArrayKey('pos:0'); // Returns false
1206
+ */
1207
+ declare const isIdArrayKey: (key: unknown) => key is string;
1208
+ /**
1209
+ * Creates an ID array key.
1210
+ * @param {string} id - The ID to create the key for.
1211
+ * @returns {string} Returns the created ID array key.
1212
+ * @example
1213
+ * createIdArrayKey('123'); // Returns 'id:123'
1214
+ */
1215
+ declare const createIdArrayKey: (id: string) => string;
1216
+ /**
1217
+ * Extracts the ID from an ID array key.
1218
+ * @param {string} key - The ID array key to extract the ID from.
1219
+ * @returns {string} Returns the extracted ID.
1220
+ * @example
1221
+ * extractIdFromArrayKey('id:123'); // Returns '123'
1222
+ */
1223
+ declare const extractIdFromArrayKey: (key: string) => string;
1224
+ /**
1225
+ * Checks if the given key is an array key (either a position array key or an ID array key).
1226
+ * @param {unknown} key - The key to check.
1227
+ * @returns {boolean} Returns true if `key` is an array key, false otherwise.
1228
+ * @example
1229
+ * isArrayKey('id:123'); // Returns true
1230
+ * isArrayKey('pos:0'); // Returns true
1231
+ * isArrayKey('abc'); // Returns false
1232
+ */
1233
+ declare const isArrayKey: (key: unknown) => key is string;
1234
+ /**
1235
+ * Extracts the index from an array key in a given array.
1236
+ * @param {unknown} array - The array to extract the index from.
1237
+ * @param {string} key - The array key to extract the index from.
1238
+ * @returns {number} Returns the extracted index.
1239
+ * @example
1240
+ * getIndexByArrayKey(['a', 'b', 'c'], 'pos:1'); // Returns 1
1241
+ */
1242
+ declare const getIndexByArrayKey: (array: unknown, key: string) => number;
1243
+ //#endregion
1244
+ //#region src/paths/types.d.ts
1245
+ /**
1246
+ * The NestedRecord type represents a deeply nested object structure. It can be one of the following:
1247
+ * - A Record with string keys and unknown values
1248
+ * - An object with string keys and NestedRecord values
1249
+ * - An array of NestedRecords
1250
+ * - An array of unknown values
1251
+ *
1252
+ * This type is useful when working with deeply nested data structures where the shape of the data is not known beforehand.
1253
+ *
1254
+ * @example
1255
+ * let record: NestedRecord = {
1256
+ * key: "value",
1257
+ * nested: {
1258
+ * innerKey: "innerValue",
1259
+ * array: [
1260
+ * {
1261
+ * deepKey: "deepValue"
1262
+ * }
1263
+ * ]
1264
+ * },
1265
+ * };
1266
+ */
1267
+ type NestedRecord = Record<string, unknown> | {
1268
+ [k: string]: NestedRecord;
1269
+ } | NestedRecord[] | unknown[];
1270
+ /**
1271
+ * Represents the payload for a set operation in a NestedRecord.
1272
+ */
1273
+ interface SetPayload<T> {
1274
+ /**
1275
+ * The path to the field in the NestedRecord.
1276
+ */
1277
+ path: (string | number)[];
1278
+ /**
1279
+ * The real path to the field in the NestedRecord, represented as an array of component (editor) IDs.
1280
+ */
1281
+ rpath: string[];
1282
+ /**
1283
+ * The change like input letter in text input
1284
+ */
1285
+ atomic?: boolean;
1286
+ /**
1287
+ * The new value for the field.
1288
+ */
1289
+ value: T;
1290
+ }
1291
+ /**
1292
+ * Represents the payload for an unset operation in a NestedRecord.
1293
+ */
1294
+ interface UnsetPayload {
1295
+ /**
1296
+ * The path to the field in the NestedRecord.
1297
+ */
1298
+ path: (string | number)[];
1299
+ /**
1300
+ * The real path to the field in the NestedRecord, represented as an array of component (editor) IDs.
1301
+ */
1302
+ rpath: string[];
1303
+ }
1304
+ /**
1305
+ * Represents the payload for a push operation in a NestedRecord.
1306
+ */
1307
+ interface PushPayload<T> {
1308
+ /**
1309
+ * The path to the field in the NestedRecord.
1310
+ */
1311
+ path: (string | number)[];
1312
+ /**
1313
+ * The real path to the field in the NestedRecord, represented as an array of component (editor) IDs.
1314
+ */
1315
+ rpath: string[];
1316
+ /**
1317
+ * The value to push into the field.
1318
+ */
1319
+ value: T;
1320
+ }
1321
+ /**
1322
+ * Represents the payload for a pull operation in a NestedRecord.
1323
+ */
1324
+ interface PullPayload {
1325
+ /**
1326
+ * The path to the field in the NestedRecord.
1327
+ */
1328
+ path: (string | number)[];
1329
+ /**
1330
+ * The real path to the field in the NestedRecord, represented as an array of component (editor) IDs.
1331
+ */
1332
+ rpath: string[];
1333
+ /**
1334
+ * The key of the value to pull from the field.
1335
+ */
1336
+ key: string | number;
1337
+ }
1338
+ /**
1339
+ * Represents the payload for a move operation in a NestedRecord.
1340
+ */
1341
+ interface MovePayload {
1342
+ /**
1343
+ * The path to the field in the NestedRecord.
1344
+ */
1345
+ path: (string | number)[];
1346
+ /**
1347
+ * The real path to the field in the NestedRecord, represented as an array of component (editor) IDs.
1348
+ */
1349
+ rpath: string[];
1350
+ /**
1351
+ * The old fractional position of the field
1352
+ */
1353
+ oldPosition: string;
1354
+ /**
1355
+ * The fractional position of the related field, rely on which the field should be moved.
1356
+ */
1357
+ relativePosition: string;
1358
+ /**
1359
+ * Indicates whether the field should be inserted before or after the relative position.
1360
+ */
1361
+ insert: 'before' | 'after';
1362
+ }
1363
+ //#endregion
1364
+ //#region src/paths/array-ops.d.ts
1365
+ /**
1366
+ * Pushes a value into a nested array in an object using a path.
1367
+ * @param {NestedRecord} object - The object to push the value into.
1368
+ * @param {(string | number)[]} path - The path to the array in the object.
1369
+ * @param {unknown} value - The value to push.
1370
+ * @example
1371
+ * let obj = { items: ['John'] };
1372
+ * pushInPath(obj, ['items'], 'Jane'); // obj is now { items: ['John', 'Jane'] }
1373
+ */
1374
+ declare const pushInPath: (object: NestedRecord, path: (string | number)[], value: unknown) => void;
1375
+ /**
1376
+ * Inserts values into a nested array in an object at a specified index or key using a path.
1377
+ * @param {NestedRecord} object - The object to insert the values into.
1378
+ * @param {(string | number)[]} path - The path to the array in the object.
1379
+ * @param {string | number} keyOrIndex - The index or key at which to insert the values.
1380
+ * @param {unknown[]} values - The values to insert.
1381
+ * @example
1382
+ * let obj = { items: ['John', 'Jane'] };
1383
+ * insertInPath(obj, ['items'], 1, ['Joe']); // obj is now { items: ['John', 'Joe', 'Jane'] }
1384
+ */
1385
+ declare const insertInPath: (object: NestedRecord, path: (string | number)[], keyOrIndex: string | number, values: unknown[]) => void;
1386
+ /**
1387
+ * Removes a value from a nested array in an object at a specified index or array key using a path.
1388
+ * @param {NestedRecord} object - The object to remove the value from.
1389
+ * @param {(string | number)[]} path - The path to the array in the object.
1390
+ * @param {string | number} key - The index or key at which to remove the value.
1391
+ * @example
1392
+ * let obj = { items: ['John', 'Joe', 'Jane'] };
1393
+ * pullFromPath(obj, ['items'], 1); // obj is now { items: ['John', 'Jane'] }
1394
+ */
1395
+ declare const pullFromPath: (object: NestedRecord, path: (string | number)[], key: string | number) => void;
1396
+ /**
1397
+ * Moves an item to a new position relative to another item in the array or object at the specified path.
1398
+ *
1399
+ * @example
1400
+ * moveInYPath(values, ['components'], 'a0', 'b1', 'after');
1401
+ */
1402
+ declare const moveInPath: (object: NestedRecord, path: (string | number)[], oldPosition: string, relativePosition: string, insert: "before" | "after") => string;
1403
+ //#endregion
1404
+ //#region src/paths/basic-ops.d.ts
1405
+ /**
1406
+ * Gets a nested property value from an object using a path.
1407
+ * @param {NestedRecord | undefined} object - The object to get the value from.
1408
+ * @param {(string | number)[]} path - The path to the value in the object.
1409
+ * @returns {TValue | undefined} Returns the value at the specified path in the object.
1410
+ * @example
1411
+ * getFromPath({ items: [{ name: 'John' }] }, ['items', 0, 'name']); // Returns 'John'
1412
+ */
1413
+ declare const getFromPath: <TValue = unknown>(object: NestedRecord | undefined, path: (string | number)[]) => TValue | undefined;
1414
+ /**
1415
+ * Sets a nested property value in a path, creates the path properties if they don't exist.
1416
+ * @param {NestedRecord} object - The object to set the value in.
1417
+ * @param {(string | number)[]} path - The path to the value in the object.
1418
+ * @param {unknown} value - The value to set.
1419
+ * @example
1420
+ * let obj = { items: [{ name: 'John' }] };
1421
+ * setInPath(obj, ['items', 0, 'name'], 'Jane'); // obj is now { items: [{ name: 'Jane' }] }
1422
+ */
1423
+ declare const setInPath: (object: NestedRecord, path: (string | number)[], value: unknown) => void;
1424
+ /**
1425
+ * Removes a nested property from an object using a path.
1426
+ * @param {NestedRecord} object - The object to remove the value from.
1427
+ * @param {(string | number)[]} path - The path to the value in the object.
1428
+ * @example
1429
+ * let obj = { items: [{ name: 'John' }] };
1430
+ * unsetPath(obj, ['items', 0, 'name']); // obj is now { items: [{}] }
1431
+ */
1432
+ declare const unsetPath: (object: NestedRecord, path: (string | number)[]) => void;
1433
+ /** Checks if a nested property exists in an object using a path.
1434
+ * @param {NestedRecord | undefined} object - The object to check the value in.
1435
+ * @param {(string | number)[]} path - The path to the value in the object.
1436
+ * @returns {boolean} Returns true if the value exists at the specified path, false otherwise.
1437
+ * @example
1438
+ * existsInPath({ items: [{ name: 'John' }] }, ['items', 0, 'name']); // Returns true
1439
+ * existsInPath({ items: [{ name: 'John' }] }, ['items', 1, 'name']); // Returns false
1440
+ */
1441
+ declare const existsInPath: (object: NestedRecord | undefined, path: (string | number)[]) => boolean;
1442
+ /** * Compares two paths for equality.
1443
+ * @param {(string | number)[]} pathA - The first path to compare.
1444
+ * @param {(string | number)[]} pathB - The second path to compare.
1445
+ * @returns {boolean} Returns true if the paths are equal, false otherwise.
1446
+ * @example
1447
+ * isSamePath(['items', 0, 'name'], ['items', 0, 'name']); // Returns true
1448
+ * isSamePath(['items', 0, 'name'], ['items', 1, 'name']); // Returns false
1449
+ */
1450
+ declare const isSamePath: (pathA: (string | number)[], pathB: (string | number)[]) => boolean;
1451
+ //#endregion
1452
+ //#region src/paths/constants.d.ts
1453
+ declare const PATH_REGEXP: RegExp;
1454
+ //#endregion
1455
+ //#region src/paths/tools.d.ts
1456
+ /**
1457
+ * Joins a path with additional items.
1458
+ * @param {(string | number)[]} path - The initial path.
1459
+ * @param {...(string | number)[]} items - The items to add to the path.
1460
+ * @returns {(string | number)[]} Returns the joined path.
1461
+ * @throws {Error} If `path` is not an array or if any of `items` are not a string or an integer.
1462
+ * @example
1463
+ * joinPath(['items', 'id:xxx'], 'name'); // Returns ['items', 'id:xxx', 'name']
1464
+ */
1465
+ declare const joinPath: (path: (string | number)[], ...items: (string | number)[]) => (string | number)[];
1466
+ /**
1467
+ * Compares two fractional-based position strings for sorting.
1468
+ * @param {string} aPosition - The first fractional-based position string.
1469
+ * @param {string} bPosition - The second fractional-based position string.
1470
+ * @returns {number} Returns -1 if `aPosition` comes before `bPosition`, 1 if `aPosition` comes after `bPosition`, or 0 if they are equal.
1471
+ * @example
1472
+ * sortByPosition('a1', 'a2'); // Returns -1
1473
+ */
1474
+ declare const sortByPosition: (aPosition: string, bPosition: string) => 0 | 1 | -1;
1475
+ //#endregion
1476
+ //#region src/y-components/types.d.ts
1477
+ /**
1478
+ * Represents a dynamic component in Y.js.
1479
+ * Each component is represented as a Y.Map object where each key-value pair corresponds to a property of the component.
1480
+ */
1481
+ type YComponent = Y.Map<unknown>;
1482
+ /**
1483
+ * Represents an array of dynamic components in Y.js.
1484
+ * Each component in the array is represented as a YComponent.
1485
+ */
1486
+ type YComponentsArray = Y.Array<YComponent>;
1487
+ /**
1488
+ * Represents the properties of a dynamic component in Y.js.
1489
+ * Each property is represented as a key-value pair in a Y.Map object.
1490
+ */
1491
+ type YComponentProps = Y.Map<unknown>;
1492
+ //#endregion
1493
+ //#region src/y-components/tools.d.ts
1494
+ /**
1495
+ * This function converts dynamic component properties to Y.Map representation.
1496
+ */
1497
+ declare const dynamicComponentPropsToYComponentProps: (props: Record<string, unknown>) => Y.Map<unknown>;
1498
+ /**
1499
+ * This function converts a dynamic component to Y.Map representation.
1500
+ */
1501
+ declare const dynamicComponentToYMap: (component: DynamicComponent, yMap?: Y.Map<unknown>) => YComponent;
1502
+ /**
1503
+ * This function converts an array of dynamic components to Y.Array representation.
1504
+ */
1505
+ declare const dynamicComponentsToYArray: (components: DynamicComponent[], yArray?: Y.Array<unknown>) => Y.Array<unknown>;
1506
+ /**
1507
+ * This function checks if a given Y.Map object is a YComponent.
1508
+ */
1509
+ declare const isYComponent: (yComponent: unknown) => yComponent is YComponent;
1510
+ /**
1511
+ * This function converts a YComponent to a dynamic component.
1512
+ */
1513
+ declare const yComponentToDynamicComponent: (yComponent: YComponent, extractContent?: boolean) => DynamicComponentWithPosition;
1514
+ /**
1515
+ * This function converts a dynamic component to YComponent.
1516
+ */
1517
+ declare const dynamicComponentToYComponent: (component: DynamicComponent) => YComponent;
1518
+ /**
1519
+ * This function retrieves the properties of a YComponent.
1520
+ */
1521
+ declare const getYComponentProps: (yComponent: YComponent) => Y.Map<unknown>;
1522
+ /**
1523
+ * This function retrieves the array of components of a YComponent.
1524
+ */
1525
+ declare const getYComponentComponentsArray: (yComponent: YComponent) => Y.Array<YComponent>;
1526
+ /**
1527
+ * This function checks if a YComponent has a components array.
1528
+ * @example
1529
+ * // component
1530
+ * {
1531
+ * id: "column",
1532
+ * component: "column",
1533
+ * props: {
1534
+ * components: [...] <= has components array
1535
+ * }
1536
+ * }
1537
+ */
1538
+ declare const yComponentHasComponentsYArray: (yComponent: YComponent) => boolean;
1539
+ /**
1540
+ * This function retrieves the parent component of a YArray of YComponents.
1541
+ * @example
1542
+ * // parent component
1543
+ * {
1544
+ * id: "column",
1545
+ * component: "column",
1546
+ * props: {
1547
+ * components: [...] <= components array
1548
+ * }
1549
+ * }
1550
+ */
1551
+ declare const getYComponentsArrayParentComponent: (yArray: Y.Array<YComponent>) => YComponent | null;
1552
+ /**
1553
+ * This function finds a Y.Component in a Y.Array by its ID.
1554
+ */
1555
+ declare const findYComponentInArray: (yArray: Y.Array<YComponent>, componentId: string) => YComponent;
1556
+ //#endregion
1557
+ //#region src/y-tools/array-path-ops.d.ts
1558
+ /**
1559
+ * Pushes a value to the end of the Y.Array at the specified path.
1560
+ *
1561
+ * @example
1562
+ * let yMap = new Y.Map();
1563
+ * yMap.set('names', new Y.Array());
1564
+ * pushInYPath(yMap, ['names'], 'John');
1565
+ * // yMap now looks like: { names: ['John'] }
1566
+ */
1567
+ declare const pushInYPath: (entry: Y.Array<any> | Y.Map<any>, path: (string | number)[], value: any) => void;
1568
+ /**
1569
+ * Moves an item to a new position relative to another item in the Y.Array or Y.Map at the specified path.
1570
+ *
1571
+ * @example
1572
+ * moveInYPath(yMap, ['components'], 'a0', 'b1', 'after');
1573
+ */
1574
+ declare const moveInYPath: (entry: Y.Array<any> | Y.Map<any>, path: (string | number)[], oldPosition: string, relativePosition: string, insert: "before" | "after") => string;
1575
+ /**
1576
+ * Removes an item from the Y.Array or Y.Map at the specified path.
1577
+ *
1578
+ * @example
1579
+ * let yArray = new Y.Array();
1580
+ * yArray.push(['item1', 'item2', 'item3']);
1581
+ * pullFromYPath(yArray, [1]);
1582
+ * // yArray now looks like: ['item1', 'item3']
1583
+ */
1584
+ declare const pullFromYPath: (entry: Y.Array<any> | Y.Map<any>, path: (string | number)[], key: string | number) => void;
1585
+ interface MoveYMapToStartOptions {
1586
+ yArray: Y.Array<Y.Map<unknown>>;
1587
+ yMap: Y.Map<unknown>;
1588
+ }
1589
+ /**
1590
+ * Moves a Y.Map to the start of a Y.Array.
1591
+ * */
1592
+ declare const moveYMapToStart: ({
1593
+ yArray,
1594
+ yMap
1595
+ }: MoveYMapToEndOptions) => void;
1596
+ interface MoveYMapToEndOptions {
1597
+ yArray: Y.Array<Y.Map<unknown>>;
1598
+ yMap: Y.Map<unknown>;
1599
+ }
1600
+ /**
1601
+ * Moves a Y.Map to the end of a Y.Array.
1602
+ * */
1603
+ declare const moveYMapToEnd: ({
1604
+ yArray,
1605
+ yMap
1606
+ }: MoveYMapToEndOptions) => void;
1607
+ interface MoveYMapBeforeOptions {
1608
+ yArray: Y.Array<Y.Map<unknown>>;
1609
+ yMap: Y.Map<unknown>;
1610
+ relativePosition: string;
1611
+ }
1612
+ /**
1613
+ * Moves a Y.Map before another Y.Map in a Y.Array.
1614
+ * */
1615
+ declare const moveYMapBefore: ({
1616
+ yArray,
1617
+ yMap,
1618
+ relativePosition
1619
+ }: MoveYMapBeforeOptions) => void;
1620
+ interface MoveYMapAfterOptions {
1621
+ yArray: Y.Array<Y.Map<unknown>>;
1622
+ yMap: Y.Map<unknown>;
1623
+ relativePosition: string;
1624
+ }
1625
+ /**
1626
+ * Moves a Y.Map after another Y.Map in a Y.Array.
1627
+ * */
1628
+ declare const moveYMapAfter: ({
1629
+ yArray,
1630
+ yMap,
1631
+ relativePosition
1632
+ }: MoveYMapAfterOptions) => void;
1633
+ interface InsertYMapToEndOptions {
1634
+ yArray: Y.Array<Y.Map<unknown>>;
1635
+ yMap: Y.Map<unknown>;
1636
+ }
1637
+ /**
1638
+ * Inserts a Y.Map to the end of a Y.Array.
1639
+ * */
1640
+ declare const insertYMapToEnd: (opts: InsertYMapToEndOptions) => void;
1641
+ interface InsertYMapBeforeOptions {
1642
+ yArray: Y.Array<Y.Map<unknown>>;
1643
+ yMap: Y.Map<unknown>;
1644
+ relativePosition: string;
1645
+ }
1646
+ /**
1647
+ * Inserts a Y.Map before another Y.Map in a Y.Array.
1648
+ * */
1649
+ declare const insertYMapBefore: (opts: InsertYMapBeforeOptions) => void;
1650
+ interface InsertYMapAfterOptions {
1651
+ yArray: Y.Array<Y.Map<unknown>>;
1652
+ yMap: Y.Map<unknown>;
1653
+ relativePosition: string;
1654
+ }
1655
+ /**
1656
+ * Inserts a Y.Map before another Y.Map in a Y.Array.
1657
+ * */
1658
+ declare const insertYMapAfter: (opts: InsertYMapAfterOptions) => void;
1659
+ //#endregion
1660
+ //#region src/y-tools/basic-path-ops.d.ts
1661
+ /**
1662
+ * Sets a value at a given path within a Y.Map or Y.Array.
1663
+ *
1664
+ * @example
1665
+ * let ymap = new Y.Map();
1666
+ * setInYPath(ymap, ['key'], 'value');
1667
+ * // ymap now looks like: { key: 'value' }
1668
+ */
1669
+ declare const setInYPath: (ymap: Y.Map<unknown> | Y.Array<unknown>, path: (string | number)[], value: unknown) => void;
1670
+ /**
1671
+ * Removes a nested property from a Y.Map or Y.Array.
1672
+ *
1673
+ * @example
1674
+ * let ymap = new Y.Map();
1675
+ * ymap.set('key', 'value');
1676
+ * unsetYPath(ymap, ['key']);
1677
+ * // ymap now looks like: {}
1678
+ */
1679
+ declare const unsetYPath: (yType: Y.Map<unknown> | Y.Array<unknown>, path: (string | number)[]) => void;
1680
+ /**
1681
+ * Retrieves a nested property value from a Y.Map or Y.Array.
1682
+ *
1683
+ * @example
1684
+ * let ymap = new Y.Map();
1685
+ * ymap.set('key', 'value');
1686
+ * const value = getFromYPath(ymap, ['key']);
1687
+ * // value is now: 'value'
1688
+ */
1689
+ declare const getFromYPath: (entry: Y.Array<any> | Y.Map<any>, path: (string | number)[]) => unknown | null;
1690
+ //#endregion
1691
+ //#region src/y-tools/tools.d.ts
1692
+ /**
1693
+ * Returns the index of the first item in a Y.Array that matches a condition.
1694
+ *
1695
+ * @example
1696
+ * let yArray = new Y.Array();
1697
+ * yArray.push(['item1', 'item2', 'item3']);
1698
+ * const index = findIndexInYArray(yArray, (item) => item === 'item2');
1699
+ * // index is now: 1
1700
+ */
1701
+ declare const findIndexInYArray: <T = unknown>(yArray: Y.Array<T>, isMatches: (item: T) => boolean) => number;
1702
+ /**
1703
+ * Returns the first item in a Y.Array that matches a condition.
1704
+ *
1705
+ * @example
1706
+ * let yArray = new Y.Array();
1707
+ * yArray.push(['item1', 'item2', 'item3']);
1708
+ * const item = findInYArray(yArray, (item) => item === 'item2');
1709
+ * // item is now: 'item2'
1710
+ */
1711
+ declare const findInYArray: <T = unknown>(yArray: Y.Array<T>, isMatches: (item: T) => boolean) => T | null;
1712
+ /**
1713
+ * Converts an object to a Y.Map.
1714
+ *
1715
+ * @example
1716
+ * const object = { key: 'value' };
1717
+ * const yMap = objectToYMap(object);
1718
+ * // yMap now looks like: { key: 'value' }
1719
+ */
1720
+ declare const objectToYMap: (values: object) => Y.Map<unknown>;
1721
+ /**
1722
+ * Converts an array to a Y.Array.
1723
+ *
1724
+ * @example
1725
+ * const array = ['item1', 'item2', 'item3'];
1726
+ * const yArray = arrayToYArray(array);
1727
+ * // yArray now looks like: ['item1', 'item2', 'item3']
1728
+ */
1729
+ declare const arrayToYArray: (array: unknown[], yArray?: Y.Array<unknown>) => Y.Array<unknown>;
1730
+ /**
1731
+ * Returns a sorted Y.Array based on the position of each Y.Map in it.
1732
+ *
1733
+ * @example
1734
+ * let yArray = new Y.Array();
1735
+ * let yMap1 = new Y.Map();
1736
+ * let yMap2 = new Y.Map();
1737
+ * yMap1.set('position', 'a0');
1738
+ * yMap2.set('position', 'b0');
1739
+ * yArray.push([yMap2, yMap1]);
1740
+ * const sortedYArray = getSortedYArray(yArray);
1741
+ * // sortedYArray now looks like: [ yMap1, yMap2 ]
1742
+ */
1743
+ declare const getSortedYArray: <T extends Y.Map<any>>(yArray: Y.Array<T>) => T[];
1744
+ /**
1745
+ * Returns references to a Y.Map and its neighbors in a Y.Array based on its position.
1746
+ *
1747
+ * @example
1748
+ * let yArray = new Y.Array();
1749
+ * let yMap1 = new Y.Map();
1750
+ * let yMap2 = new Y.Map();
1751
+ * yMap1.set('position', 'a0');
1752
+ * yMap2.set('position', 'b0');
1753
+ * yArray.push([yMap2, yMap1]);
1754
+ * const refs = getYArrayRefsByPosition(yArray, 'a0');
1755
+ * // refs now looks like: { index: 0, ref: yMap1, right: yMap2, left: undefined, sortedArray: [yMap1, yMap2] }
1756
+ */
1757
+ declare const getYArrayRefsByPosition: <T extends Y.Map<unknown>>(yArray: Y.Array<T>, position: string) => {
1758
+ index: number;
1759
+ ref: T;
1760
+ right: T;
1761
+ left: T;
1762
+ sortedArray: T[];
1763
+ };
1764
+ //#endregion
1765
+ //#region src/y-tools/types.d.ts
1766
+ /**
1767
+ * Represents changes in Y.js awareness state. Contains arrays of added, removed, and updated items.
1768
+ */
1769
+ interface AwarenessStateChange {
1770
+ added: number[];
1771
+ removed: number[];
1772
+ updated: number[];
1773
+ }
1774
+ /**
1775
+ * Represents the awareness state. This includes a cursor, user information (id, name, avatarUrl), and a color.
1776
+ *
1777
+ * @example
1778
+ * const awarenessState: AwarenessState = {
1779
+ * cursor: ['xxx', 'yyy'], // rpath
1780
+ * user: {
1781
+ * id: 'abc123',
1782
+ * name: 'John Doe',
1783
+ * avatarUrl: 'https://example.com/avatar.jpg'
1784
+ * },
1785
+ * color: '#ff0000'
1786
+ * };
1787
+ */
1788
+ interface AwarenessState {
1789
+ cursor: string[];
1790
+ user: {
1791
+ id: string;
1792
+ name: string;
1793
+ avatarUrl?: string;
1794
+ };
1795
+ color: string;
1796
+ }
1797
+ //#endregion
1798
+ //#region src/y-tools/y-array-keys.d.ts
1799
+ /**
1800
+ * Returns the index of an item in a Y.Array based on its key.
1801
+ * The key can represent either the id or the position of the item in the array.
1802
+ *
1803
+ * @example
1804
+ * let yArray = new Y.Array();
1805
+ * let yMap = new Y.Map();
1806
+ * yMap.set('id', '123');
1807
+ * yMap.set('position', 'a0');
1808
+ * yArray.push([yMap]);
1809
+ * const index = getYArrayIndexByArrayKey(yArray, 'id:123');
1810
+ * const index = getYArrayIndexByArrayKey(yArray, 'pos:a0');
1811
+ * // index is now: 0
1812
+ */
1813
+ declare const getYArrayIndexByArrayKey: (yArray: unknown, key: string) => number;
1814
+ //#endregion
1815
+ export { AwarenessState, AwarenessStateChange, BaseDataObject, ComponentStyles, DBiblePassage, DBibleQuote, DChatMessageDelay, DChatTextMessage, DCheckbox, DCheckboxGroup, DCollection, DColumn, DComputedValue, DConfirmDeletionInput, DDateTimePicker, DEmbedCode, DEntitySelect, DFileUploader, DHeading, DHiddenInput, DImage, DImageUploader, DLegacyContent, DNumberInput, DPractice, DRadioGroup, DRawImageUploader, DRawImagesUploader, DRepeatableCollection, DRichText, DRichTextEditor, DRow, DRowSettings, DSelect, DSimpleImageUploader, DSlug, DStatement, DSwitch, DTest, DTextInput, DTextarea, DynamicComponent, DynamicComponentIO, DynamicComponentLink, DynamicComponentWithPosition, FormDynamicComponent, ID_PATH_KEY_PREFIX, IImageRenditionType, IRenditionOptions, ISizeType, InsertYMapAfterOptions, InsertYMapBeforeOptions, InsertYMapToEndOptions, MovePayload, MoveYMapAfterOptions, MoveYMapBeforeOptions, MoveYMapToEndOptions, MoveYMapToStartOptions, NestedRecord, PATH_REGEXP, POSITION_ARRAY_KEY_PREFIX, Point, PullPayload, PushPayload, RichText, SetPayload, TestItem, TestItemVariant, UiKitChatDynamicComponent, UiKitContentDynamicComponent, UiKitDynamicComponent, UiKitLayoutDynamicComponent, UnsetPayload, ValidationRules, YComponent, YComponentProps, YComponentsArray, arrayToYArray, copyDynamicComponent, createIdArrayKey, createPositionArrayKey, customAlphabet, defineDynamicComponent, defineDynamicComponents, dynamicComponentPropsToYComponentProps, dynamicComponentToYComponent, dynamicComponentToYMap, dynamicComponentsToYArray, entriesOf, existsInPath, extractIdFromArrayKey, extractPositionFromArrayKey, findInYArray, findIndexInYArray, findYComponentInArray, generateKeyBetween, getComponentPropertyPath, getComponentsSubtreeByPath, getComponentsSubtreeByRPath, getDataObjectKey, getFromPath, getFromYPath, getIndexByArrayKey, getRelativePoint, getSortedYArray, getYArrayIndexByArrayKey, getYArrayRefsByPosition, getYComponentComponentsArray, getYComponentProps, getYComponentsArrayParentComponent, insertInPath, insertYMapAfter, insertYMapBefore, insertYMapToEnd, isArrayKey, isBiblePassageComponent, isBibleQuoteComponent, isCallable, isChatMessageDelayComponent, isChatTextMessageComponent, isCheckboxComponent, isCheckboxGroupComponent, isCollectionComponent, isColumnComponent, isComputedValueComponent, isConfirmDeletionInputComponent, isContainerValue, isDateTimePickerComponent, isEmbedCodeComponent, isEmptyArray, isEmptyContainer, isEntitySelectComponent, isEqualPath, isFileUploaderComponent, isHeadingComponent, isIdArrayKey, isImageComponent, isImageUploaderComponent, isIndex, isLegacyContentComponent, isNullOrUndefined, isNumber, isNumberInputComponent, isObject, isPositionArrayKey, isPracticeComponent, isRadioGroupComponent, isRawImageUploaderComponent, isRawImagesUploaderComponent, isRepeatableCollectionComponent, isRichText, isRichTextComponent, isRichTextEditorComponent, isRowComponent, isRowSettingsComponent, isSamePath, isSelectComponent, isSimpleImageUploaderComponent, isSlugComponent, isStatementComponent, isString, isSwitchComponent, isTestComponent, isTextInputComponent, isTextareaComponent, isYArray, isYComponent, isYMap, joinPath, keysOf, makeDynamicComponentsWithPosition, moveInPath, moveInYPath, moveYMapAfter, moveYMapBefore, moveYMapToEnd, moveYMapToStart, objectToYMap, pullFromPath, pullFromYPath, pushInPath, pushInYPath, searchDynamicComponentInTree, setInPath, setInYPath, sortByPosition, sortDynamicComponents, uid, unsetPath, unsetYPath, urlAlphabet, yComponentHasComponentsYArray, yComponentToDynamicComponent };
1816
+ //# sourceMappingURL=index.d.ts.map