UNPKG

256 kBTypeScriptView Raw
1/**
2 * A function which when called will unsubscribe from the observable.
3 *
4 * @since 1.0.0
5 */
6type UnsubscribeFunction = () => void;
7/**
8 * The interface each component of uiloos/core implements so it
9 * can be subscribed to.
10 *
11 * Note: there is no reason to ever implement the `Observable`
12 * interface yourself. It is only exposed so bindings to frameworks
13 * can use the type.
14 *
15 * @since 1.4.0
16 */
17interface Observable<T, E> {
18 /**
19 * Subscribe to changes of the Observable. The function you provide
20 * will get called whenever changes occur in the Observable.
21 *
22 * Returns an unsubscribe function which when called will
23 * unsubscribe from the Observable.
24 *
25 * @param {Subscriber<T, E>} subscriber The subscriber which responds to changes in the Observable.
26 * @returns {UnsubscribeFunction} A function which when called will unsubscribe from the Observable.
27 *
28 * @since 1.4.0
29 */
30 subscribe(subscriber: Subscriber<T, E>): UnsubscribeFunction;
31}
32/**
33 * A function which when called will subscribe to the observable.
34 *
35 * @since 1.4.0
36 */
37type Subscriber<T, E> = (observerable: T, event: E) => void;
38
39/**
40 * Checks / validates the license for "uiloos".
41 *
42 * Note: you are not supposed to use this class directly. Use the
43 * variable `licenseChecker` instead.
44 *
45 * @since 1.0.0
46 */
47declare class _LicenseChecker {
48 private _licenseKey;
49 private _logOnSuccess;
50 private _success;
51 /**
52 * With `activateLicense` you can set activate your license key for
53 * uiloos. Make sure that you set your license key before using any
54 * functionality that uiloos provides.
55 *
56 * You can purchase a license at https://www.uiloos.dev.
57 *
58 * @param {string} licenseKey The license key of uiloos you want to activate.
59 * @param {ActivateLicenseOptions} options The optional options for the `activateLicense` function, can be used to suppress the "license activated" message.
60 * @since 1.0.0
61 */
62 activateLicense(licenseKey: string, options?: ActivateLicenseOptions): void;
63 /**
64 * Checks the current license to see if it is valid.
65 *
66 * Note: this method is for internal use inside uiloos only.
67 *
68 * @since 1.0.0
69 */
70 _checkLicense(): void;
71}
72/**
73 * The sole instance (a singleton) of the `_LicenseChecker` class.
74 *
75 * Use this instance of `_LicenseChecker` to call `activateLicense` to
76 * activate your license.
77 *
78 * @see _LicenseChecker
79 * @since 1.0.0
80 *
81 * @example
82 *
83 * Activating license
84 *
85 * You activate the license by calling "activateLicense" on the
86 * "licenseChecker" instance.
87 *
88 * ```js
89 * import { licenseChecker } from '@uiloos/core';
90 * licenseChecker.activateLicense("{LICENSE-HERE}");
91 * ```
92 */
93declare let licenseChecker: _LicenseChecker;
94/**
95 * The options for the `activateLicense` functions. Can be used
96 * to silence the "license activated" message.
97 *
98 * @since 1.0.0
99 */
100type ActivateLicenseOptions = {
101 /**
102 * Whether or not to silence the "license activated" message
103 * when the license is valid.
104 *
105 * @since 1.0.0
106 */
107 logLicenseActivated: boolean;
108};
109
110/**
111 * Configures the initial state of the `ActiveList`
112 *
113 * @since 1.0.0
114 */
115type ActiveListConfig<T> = {
116 /**
117 * The contents which you want to display, can be an array of anything
118 * you want.
119 *
120 * Note: the `ActiveList` will wrap each item in the `contents` array
121 * inside of a `ActiveListContent` item.
122 *
123 * Defaults to `[]` meaning there is no content.
124 *
125 * @since 1.0.0
126 */
127 contents?: T[];
128 /**
129 * How many items can be active at the same time.
130 *
131 * When the value of `limit` is `false` there is no limit to the
132 * number of active items.
133 *
134 * Defaults to `1`.
135 *
136 * @since 1.0.0
137 */
138 maxActivationLimit?: number | false;
139 /**
140 * How the limit is enforced. In other words what the behavior
141 * should be when the limit is surpassed.
142 *
143 * The modes are strings which can be the following values:
144 *
145 * 1. 'circular': the first item which was added will be removed so
146 * the last item can be added without violating the limit. This
147 * basically means that the first one in is the first one out.
148 *
149 * 2. 'error': An error is thrown whenever the limit is surpassed,
150 * the error is called the `ActiveListActivationLimitReachedError`.
151 *
152 * 3. 'ignore': Nothing happens when an item is added and the limit
153 * is reached. The item is simply not added, but no error is
154 * thrown.
155 *
156 * Defaults to 'circular'.
157 *
158 * @since 1.0.0
159 */
160 maxActivationLimitBehavior?: ActiveListMaxActivationLimitBehavior;
161 /**
162 * Which item or items in the content array are currently active.
163 *
164 * When the `active` is an array each item in the array is activated
165 * from left to right one at a time.
166 *
167 * Note: "active" is chosen over the "activeIndexes" property.
168 *
169 * Defaults to `[]` meaning no content is active.
170 *
171 * @since 1.0.0
172 */
173 active?: T | T[];
174 /**
175 * Which index or indexes of the content array are currently active.
176 *
177 * When the `activeIndexes` is an array each index in the array
178 * is activated from left to right one at a time.
179 *
180 * Note: "active" is chosen over the "activeIndexes" property.
181 *
182 * Defaults to `[]` meaning no content is active.
183 *
184 * @since 1.0.0
185 */
186 activeIndexes?: number | number[];
187 /**
188 * Whether or not the content starts back at the beginning when
189 * the end of the content is reached, and whether the content should
190 * go to the end when moving left of the start.
191 *
192 * Defaults to `true`.
193 *
194 * @since 1.0.0
195 */
196 isCircular?: boolean;
197 /**
198 * Whether or not `autoPlay` is enabled. When `autoPlay` is enabled
199 * it will automatically move to the next content, based on the
200 * `duration`.
201 *
202 * When `isCircular` is `true` content will move to the right
203 * indefinitely. When `isCircular` is `false` it will stop autoPlay
204 * at the end of the content.
205 *
206 * Note: autoPlay will only start when one or more contents are
207 * currently active. The reason for this is that the `duration`, is
208 * based on the `ActiveList` `lastActivatedContent` property.
209 * Whenever there are no more items to activate the autoPlay will
210 * stop.
211 *
212 * Defaults to no autoPlay.
213 *
214 * @since 1.0.0
215 */
216 autoPlay?: ActiveListAutoPlayConfig<T>;
217 /**
218 * Describes which strings should be associated with what
219 * direction, will be the value of the `ActiveList` property
220 * `direction`.
221 *
222 * So when setting the direction `next` to "up"` and the content
223 * moves up, the `ActiveList.direction` will be "up". Useful when
224 * wanting to apply CSS classes based on the direction.
225 *
226 * Defaults to `{ next: 'right', previous: 'left' }`.
227 *
228 * @since 1.0.0
229 */
230 directions?: ActiveListDirection;
231 /**
232 * For how many items the `history` may contain in the `ActiveList`.
233 *
234 * Defaults to `0` meaning that it will not track history.
235 *
236 * @since 1.0.0
237 */
238 keepHistoryFor?: number;
239 /**
240 * The `cooldown` is the number of milliseconds before another
241 * activation / deactivation is allowed. For example if the
242 * `cooldown` is `5000` the `ActiveList` will not allow
243 * transitions until after 5 seconds have passed. Any activation /
244 * deactivation in that period will simply be ignored.
245 *
246 * This can be useful when you have an animation which should be
247 * finished before allowing user interaction again.
248 *
249 * This global `cooldown` is the same for all transitions you might trigger.
250 * If you want a `cooldown` that differs per button use the `cooldown`
251 * in the `ActiveListActivationOptions` instead.
252 *
253 * Note that the `cooldown` options with the `ActiveListActivationOptions` takes
254 * precedence over this more global cooldown.
255 *
256 * IMPORTANT: `cooldown` is only ran when `isUserInteraction` within
257 * the `ActiveListActivationOptions` is `true`. This means that `autoPlay`, which
258 * is not a user interaction, ignores the `cooldown`.
259 *
260 * @since 1.0.0
261 */
262 cooldown?: ActiveListCooldownConfig<T>;
263};
264/**
265 * Describes all the behaviors for when the limit of the ActiveList
266 * is surpassed.
267 *
268 * 1. 'circular': the first item which was added will be removed so
269 * the last item can be added without violating the limit. This
270 * basically means that the first one in is the first one out.
271 *
272 * 2. 'error': An error is thrown whenever the limit is surpassed,
273 * the error is called the `ActiveListActivationLimitReachedError`.
274 *
275 * 3. 'ignore': Nothing happens when an item is added and the limit
276 * is reached. The item is simply not added, but no error is
277 * thrown.
278 *
279 * @since 1.0.0
280 */
281type ActiveListMaxActivationLimitBehavior = 'circular' | 'ignore' | 'error';
282/**
283 * Represents options for activation / deactivation methods.
284 *
285 * @since 1.0.0
286 */
287type ActiveListActivationOptions<T> = {
288 /**
289 * Whether or not the action was taken by a user / human. This
290 * affects the `autoPlay` when `stopsOnUserInteraction` is `true`,
291 * the `autoPlay` stops, when `false` the autoPlay is debounced.
292 *
293 * Also affects the `cooldown` when `isUserInteraction` is `true`,
294 * the `cooldown` is checked, otherwise when `false`
295 * the `cooldown` is ignored.
296 *
297 * Defaults to `true`.
298 *
299 * @since 1.0.0
300 */
301 isUserInteraction?: boolean;
302 /**
303 * The `cooldown` is the number of milliseconds before another
304 * activation / deactivation is allowed. For example if the
305 * `cooldown` is `5000` the `ActiveList` will not allow
306 * transitions until after 5 seconds have passed. Any activation /
307 * deactivation in that period will simply be ignored.
308 *
309 * This can be useful when you have an animation which should be
310 * finished before allowing user interaction again.
311 *
312 * The benefit of this `cooldown` over the `cooldown` in the
313 * `Config`, is that this `cooldown` can be different for different
314 * actions. For example: it allows you to create two buttons each
315 * with a different cooldown.
316 *
317 * Note that the `cooldown` options within the `ActiveListActivationOptions`
318 * takes precedence over the `cooldown` in the `Config`.
319 *
320 * IMPORTANT: `cooldown` is only ran when `isUserInteraction` within
321 * the `ActiveListActivationOptions` is `true`. This means that
322 * `autoPlay`, which is not a user interaction, ignores the
323 * `cooldown`.
324 *
325 * @since 1.0.0
326 */
327 cooldown?: ActiveListCooldownConfig<T>;
328};
329/**
330 * The subscriber which is informed of all state changes the
331 * ActiveList goes through.
332 *
333 * @param {ActiveList<T>} activeList The ActiveList which had changes.
334 * @param {ActiveListEvent<T>} event The event that occurred.
335 *
336 * @since 1.0.0
337 */
338type ActiveListSubscriber<T> = (activeList: ActiveList<T>, event: ActiveListEvent<T>) => void;
339/**
340 * Represents a bundle of data which is given as the first parameter
341 * to the ContentPredicate function. Based on this data the
342 * ContentPredicate must either return `true` or `false`.
343 *
344 * @since 1.0.0
345 */
346type ActiveListContentPredicateData<T> = {
347 /**
348 * The value the ActiveListContent wraps.
349 *
350 * @since 1.0.0
351 */
352 value: T;
353 /**
354 * The index the ActiveListContent has within the ActiveList
355 *
356 * @since 1.0.0
357 */
358 index: number;
359 /**
360 * A reference to the ActiveListContent which wraps the value.
361 *
362 * @since 1.0.0
363 */
364 content: ActiveListContent<T>;
365 /**
366 * A reference to the ActiveList itself.
367 *
368 * @since 1.0.0
369 */
370 activeList: ActiveList<T>;
371};
372/**
373 * Represents a callback which is given all relevant data for the
374 * action, and expects either `true` or `false` to be returned. If
375 * `true` is returned will perform the action.
376 *
377 * @param {ActiveListContentPredicateData<T>} data The data for which this predicate will determine if the action needs to be performed.
378 * @returns {boolean} Whether or not to perform the action associated with the predicate based on the given item and index.
379 *
380 * @since 1.0.0
381 */
382type ActiveListContentPredicate<T> = (data: ActiveListContentPredicateData<T>) => boolean;
383/**
384 * Represents a bundle of data which is given whenever the
385 * AutoPlayDurationCallbackData function must determine the number
386 * of milliseconds the content should be active for.
387 *
388 * @since 1.0.0
389 */
390type ActiveListAutoPlayDurationCallbackData<T> = {
391 /**
392 * The value which is currently asking which autoPlay duration it should have.
393 *
394 * @since 1.0.0
395 */
396 value: T;
397 /**
398 * The index the value has within the ActiveList
399 *
400 * @since 1.0.0
401 */
402 index: number;
403 /**
404 * A reference to the ActiveListContent which wraps the value.
405 *
406 * @since 1.0.0
407 */
408 content: ActiveListContent<T>;
409 /**
410 * A reference to the ActiveList itself.
411 *
412 * @since 1.0.0
413 */
414 activeList: ActiveList<T>;
415};
416/**
417 * Represents a callback function which is given all relevant autoPlay
418 * duration data, and expects to be given back the number of
419 * milliseconds the content should be active before autoPlay moves on.
420 *
421 * @param {ActiveListAutoPlayDurationCallbackData<T>} data An object containing all relevant duration data for which the callback function must determine the number of milliseconds the content is active for.
422 * @returns {number} The time in milliseconds the content is active for the given AutoPlayDurationCallbackData.
423 *
424 * @since 1.0.0
425 */
426type ActiveListAutoPlayDurationCallback<T> = (config: ActiveListAutoPlayDurationCallbackData<T>) => number;
427/**
428 * Represents the configuration for AutoPlay. AutoPlay means
429 * that the ActiveList will move to the next content by itself
430 * after a duration.
431 *
432 * @since 1.0.0
433 */
434type ActiveListAutoPlayConfig<T> = {
435 /**
436 * The time in milliseconds the ActiveListContent should remain active, before
437 * moving to the next ActiveListContent.
438 *
439 * @since 1.0.0
440 */
441 duration: ActiveListAutoPlayDurationCallback<T> | number;
442 /**
443 * Whether or not the user interacting with the component should
444 * stop the autoPlay.
445 *
446 * When `true` any activation / deactivation method called on
447 * the `ActiveList` will stop the autoPlay. When `false` it will
448 * debounce the autoPlay instead by the duration.
449 *
450 * Defaults to `false`.
451 *
452 * @since 1.0.0
453 */
454 stopsOnUserInteraction?: boolean;
455};
456/**
457 * AutoPlay means that the ActiveList will move to the next content by
458 * itself after a duration.
459 *
460 * Contains whether or not the autoPlay is playing via `isPlaying` and
461 * the current duration via `duration`.
462 *
463 * @since 1.0.0
464 */
465type ActiveListAutoPlay = {
466 /**
467 * Whether or not the ActiveList is playing. In other words whether
468 * or not the ActiveList is going to cycle through the content
469 * automatically.
470 *
471 * @since 1.0.0
472 */
473 isPlaying: boolean;
474 /**
475 * The amount of milliseconds the item should remain active before
476 * jumping to the next item.
477 *
478 * This duration is the duration for the current item which is
479 * playing. It is not affected by calling pause, meaning that
480 * when the duration is set to 200ms and you pause after 100ms,
481 * the duration will still be 200ms.
482 *
483 * When calling `stop`, or when `stop` is called when the autoPlay
484 * reaches the end, the duration will be set to zero.
485 *
486 * @since 1.0.0
487 */
488 duration: number;
489 /**
490 * Whether or not the ActiveList had the autoPlay stopped at one
491 * point before.
492 *
493 * Use case: say you are making a carousel which should stop on
494 * any user interaction, so you set `stopsOnUserInteraction` to
495 * `true`. Say you also have another feature: a pause whenever
496 * the user hovers over the carousel. These two features would cause
497 * a conflict:
498 *
499 * Whenever the mouse over happens you call `play()`, which negates
500 * the `stopsOnUserInteraction`, causing the carousel to play again.
501 *
502 * To fix this problem you should on the mouse over not call
503 * `play()` whenever `hasBeenStoppedBefore` is `true`.
504 *
505 * @since 1.1.0
506 */
507 hasBeenStoppedBefore: boolean;
508};
509/**
510 * Represents the configuration of the cooldown.
511 *
512 * Can be two possible things:
513 *
514 * 1. A callback function which receives the relevant cooldown data,
515 * and which is required to return the duration in milliseconds.
516 * Useful for providing a different cooldown for different items.
517 *
518 * 2. A number in milliseconds. When it is a number all items will
519 * have the same cooldown.
520 *
521 * @since 1.0.0
522 */
523type ActiveListCooldownConfig<T> = ActiveListCooldownDurationCallback<T> | number;
524/**
525 * Represents a bundle of data which is given whenever the
526 * CooldownDurationCallback function must determine what the number of
527 * milliseconds the content should be in a cooldown state.
528 *
529 * @since 1.0.0
530 */
531type ActiveListCooldownDurationCallbackData<T> = {
532 /**
533 * The value which is currently asking which cooldown it should have.
534 *
535 * @since 1.0.0
536 */
537 value: T;
538 /**
539 * The index the value has within the ActiveList
540 *
541 * @since 1.0.0
542 */
543 index: number;
544 /**
545 * A reference to the ActiveListContent which wraps the value.
546 *
547 * @since 1.0.0
548 */
549 content: ActiveListContent<T>;
550 /**
551 * A reference to the ActiveList itself.
552 *
553 * @since 1.0.0
554 */
555 activeList: ActiveList<T>;
556};
557/**
558 * Represents a callback function which is given all relevant cooldown
559 * duration data, and expects to be given back the number of
560 * milliseconds the content should be cooled down before it responds
561 * to user interaction again.
562 *
563 * WARNING: do not return a negative number or zero in this callback
564 * as this results in a `ActiveListCooldownDurationError`. The action
565 * will still occur however, this means that the ActiveList is invalid
566 * when this happens.
567 *
568 * @param {ActiveListCooldownDurationCallbackData<T>} data An object containing all relevant cooldown data for which the callback function must determine the cooldown duration in number of milliseconds.
569 * @returns {number} The time in milliseconds of the duration of the cooldown for the given CooldownCallbackData.
570 *
571 * @since 1.0.0
572 */
573type ActiveListCooldownDurationCallback<T> = (data: ActiveListCooldownDurationCallbackData<T>) => number;
574/**
575 * A Cooldown is a time period in which all user made activations
576 * and deactivations are prevented / ignored. Activations and
577 * deactivations where the `isUserInteraction` is set to `false`
578 * always bypass the cooldown.
579 *
580 * The use-case is a cooldown can guarantees that animations are
581 * completed, before another is triggered.
582 *
583 * Contains whether or not the cooldown is active via `isActive` and
584 * the current duration via `duration`.
585 *
586 * @since 1.0.0
587 */
588type ActiveListCooldown = {
589 /**
590 * Whether or not the ActiveList is currently in the cooldown state.
591 * When in cooldown all activations and deactivations are ignored.
592 *
593 * @since 1.0.0
594 */
595 isActive: boolean;
596 /**
597 * The amount of milliseconds the ActiveList should remain in
598 * the cooldown state.
599 *
600 * @since 1.0.0
601 */
602 duration: number;
603};
604/**
605 * Describes which strings should be associated with what
606 * direction. For example it could be "right" and "left",
607 * or "down" and "up".
608 *
609 * Will be the value of the `ActiveList` property `direction`.
610 *
611 * Useful for when animations have a certain direction and you
612 * name your animation CSS classes `left-animation` and
613 * `right-animation`.
614 *
615 * @since 1.0.0
616 */
617type ActiveListDirection = {
618 /**
619 * The name of the direction when moving to the next item of the
620 * `ActiveList`.
621 *
622 * Could for example be "right" or "down".
623 *
624 * @since 1.0.0
625 */
626 next: string;
627 /**
628 * The name of the direction when moving to the previous item of the
629 * `ActiveList`.
630 *
631 * Could for example be "left" or "up".
632 *
633 * @since 1.0.0
634 */
635 previous: string;
636};
637/**
638 * Represents whether the `ActiveListEvent` was inserted, removed, activated
639 * swapped, etc etc.
640 *
641 * @since 1.0.0
642 */
643type ActiveListEventType = 'INITIALIZED' | 'INSERTED' | 'REMOVED' | 'REMOVED_MULTIPLE' | 'ACTIVATED' | 'ACTIVATED_MULTIPLE' | 'SWAPPED' | 'MOVED' | 'DEACTIVATED' | 'DEACTIVATED_MULTIPLE' | 'AUTO_PLAY_PLAYING' | 'AUTO_PLAY_PAUSED' | 'AUTO_PLAY_STOPPED' | 'COOLDOWN_STARTED' | 'COOLDOWN_ENDED';
644/**
645 * Represents an event which happened in the ActiveList. Based
646 * on the `type` you can determine which event occurred.
647 *
648 * @since 1.0.0
649 */
650type ActiveListBaseEvent = {
651 /**
652 * Which event occurred
653 *
654 * @since 1.0.0
655 */
656 type: ActiveListEventType;
657 /**
658 * The time the event occurred on as a Date object.
659 *
660 * @since 1.0.0
661 */
662 time: Date;
663};
664/**
665 * Represents the initialization of the ActiveList
666 *
667 * @since 1.0.0
668 */
669type ActiveListInitializedEvent<T> = ActiveListBaseEvent & {
670 /**
671 * Which type occurred
672 *
673 * @since 1.0.0
674 */
675 type: 'INITIALIZED';
676 /**
677 * The values which were active upon initialization.
678 *
679 * Note: these are the values at the time of the initialization, they might
680 * no longer be accurate. Keep in mind that when the `value` is
681 * an object or an array, they can still be mutated, because no
682 * copy is made.
683 *
684 * @since 1.0.0
685 */
686 values: T[];
687 /**
688 * The indexes of the values which were active upon initialization.
689 *
690 * Note: these are the indexes at the time of the initialization, it might
691 * no longer be accurate.
692 *
693 * @since 1.0.0
694 */
695 indexes: number[];
696};
697/**
698 * Represents an insertion into the ActiveList.
699 *
700 * @since 1.0.0
701 */
702type ActiveListInsertedEvent<T> = ActiveListBaseEvent & {
703 /**
704 * Which type occurred
705 *
706 * @since 1.0.0
707 */
708 type: 'INSERTED';
709 /**
710 * The value which was inserted.
711 *
712 * Note: this was the value at the time of insertion, it might
713 * no longer be accurate. Keep in mind that when the `value` is
714 * an object or an array, they can still be mutated, because no
715 * copy is made.
716 *
717 * @since 1.0.0
718 */
719 value: T;
720 /**
721 * The index of the insertion.
722 *
723 * Note: this was the index at the time of the insertion, it might
724 * no longer be accurate.
725 *
726 * @since 1.0.0
727 */
728 index: number;
729};
730/**
731 * Represents an removal of an item of the ActiveList.
732 *
733 * @since 1.0.0
734 */
735type ActiveListRemovedEvent<T> = ActiveListBaseEvent & {
736 /**
737 * Which type occurred
738 *
739 * @since 1.0.0
740 */
741 type: 'REMOVED';
742 /**
743 * The value which was removed.
744 *
745 * Note: this was the value at the time of removal, it might
746 * no longer be accurate. Keep in mind that when the `value` is
747 * an object or an array, they can still be mutated, because no
748 * copy is made.
749 *
750 * @since 1.0.0
751 */
752 value: T;
753 /**
754 * The index of removed item.
755 *
756 * Note: this was the index at the time of the removal, it might
757 * no longer be accurate.
758 *
759 * @since 1.0.0
760 */
761 index: number;
762};
763/**
764 * Represents multiple removals of items in the ActiveList.
765 *
766 * @since 1.0.0
767 */
768type ActiveListRemovedMultipleEvent<T> = ActiveListBaseEvent & {
769 /**
770 * Which type occurred
771 *
772 * @since 1.0.0
773 */
774 type: 'REMOVED_MULTIPLE';
775 /**
776 * The values which were removed
777 *
778 * Note: these are the values at the time of removal, they might
779 * no longer be accurate. Keep in mind that when the `value` is
780 * an object or an array, they can still be mutated, because no
781 * copy is made.
782 *
783 * @since 1.0.0
784 */
785 values: T[];
786 /**
787 * The indexes of the removed items.
788 *
789 * Note: these are the indexes at the time of the removal, it might
790 * no longer be accurate.
791 *
792 * @since 1.0.0
793 */
794 indexes: number[];
795};
796/**
797 * Represents an activation of an ActiveList.
798 *
799 * @since 1.0.0
800 */
801type ActiveListActivatedEvent<T> = ActiveListBaseEvent & {
802 /**
803 * Which type occurred
804 *
805 * @since 1.0.0
806 */
807 type: 'ACTIVATED';
808 /**
809 * The value which was activated.
810 *
811 * Note: this was the value at the time of activation, it might
812 * no longer be accurate. Keep in mind that when the `value` is
813 * an object or an array, they can still be mutated, because no
814 * copy is made.
815 *
816 * @since 1.0.0
817 */
818 value: T;
819 /**
820 * The index of the activated item.
821 *
822 * Note: this was the index at the time of the activation, it might
823 * no longer be accurate.
824 *
825 * @since 1.0.0
826 */
827 index: number;
828 /**
829 * The value which was deactivated, will be `null` when no value
830 * was deactivated as part of the activation.
831 *
832 * A deactivation will only happen as part of an activation when
833 * `maxActivationLimit` is set to a `number` and
834 * `maxActivationLimitBehavior` is set to `circular`.
835 *
836 * Note: these are the values at the time of deactivation, they might
837 * no longer be accurate. Keep in mind that when the `value` is
838 * an object or an array, they can still be mutated, because no
839 * copy is made.
840 *
841 * @since 1.5.0
842 */
843 deactivatedValue: T | null;
844 /**
845 * The index of the deactivated item, will be `-1` when no index
846 * was deactivated as part of the activation.
847 *
848 * A deactivation will only happen as part of an activation when
849 * `maxActivationLimit` is set to a `number` and
850 * `maxActivationLimitBehavior` is set to `circular`.
851 *
852 * Note: this was the index at the time of the deactivation, it might
853 * no longer be accurate.
854 *
855 * @since 1.5.0
856 */
857 deactivatedIndex: number;
858};
859/**
860 * Represents multiple activations happening at the same time in an
861 * ActiveList.
862 *
863 * @since 1.0.0
864 */
865type ActiveListActivatedMultipleEvent<T> = ActiveListBaseEvent & {
866 /**
867 * Which type occurred
868 *
869 * @since 1.0.0
870 */
871 type: 'ACTIVATED_MULTIPLE';
872 /**
873 * The values which were activated.
874 *
875 * Note: these are the values at the time of activation, they might
876 * no longer be accurate. Keep in mind that when the `value` is
877 * an object or an array, they can still be mutated, because no
878 * copy is made.
879 *
880 * @since 1.0.0
881 */
882 values: T[];
883 /**
884 * The indexes of the activated items.
885 *
886 * Note: these are the indexes at the time of the activation, it might
887 * no longer be accurate.
888 *
889 * @since 1.0.0
890 */
891 indexes: number[];
892 /**
893 * The values which were deactivated.
894 *
895 * A deactivation will only happen as part of an activation when
896 * `maxActivationLimit` is set to a `number` and
897 * `maxActivationLimitBehavior` is set to `circular`.
898 *
899 * Note: these are the values at the time of deactivation, they might
900 * no longer be accurate. Keep in mind that when the `value` is
901 * an object or an array, they can still be mutated, because no
902 * copy is made.
903 *
904 * @since 1.5.0
905 */
906 deactivatedValues: T[];
907 /**
908 * The indexes of the deactivated items.
909 *
910 * A deactivation will only happen as part of an activation when
911 * `maxActivationLimit` is set to a `number` and
912 * `maxActivationLimitBehavior` is set to `circular`.
913 *
914 * Note: these are the indexes at the time of the deactivation, it might
915 * no longer be accurate.
916 *
917 * @since 1.5.0
918 */
919 deactivatedIndexes: number[];
920};
921/**
922 * Represents a deactivation of an ActiveList.
923 *
924 * IMPORTANT: this event is only fired as a result of a direct
925 * deactivation call. So not when activating an item also deactivated
926 * an item due to a `maxActivationLimit` being set.
927 *
928 * @since 1.0.0
929 */
930type ActiveListDeactivatedEvent<T> = ActiveListBaseEvent & {
931 /**
932 * Which type occurred
933 *
934 * @since 1.0.0
935 */
936 type: 'DEACTIVATED';
937 /**
938 * The value which was deactivated.
939 *
940 * Note: this was the value at the time of deactivation, it might
941 * no longer be accurate. Keep in mind that when the `value` is
942 * an object or an array, they can still be mutated, because no
943 * copy is made.
944 *
945 * @since 1.0.0
946 */
947 value: T;
948 /**
949 * The index of the deactivated item.
950 *
951 * Note: this was the index at the time of the deactivation, it might
952 * no longer be accurate.
953 *
954 * @since 1.0.0
955 */
956 index: number;
957};
958/**
959 * Represents multiple deactivations happening at the same time in an
960 * ActiveList.
961 *
962 * IMPORTANT: this event is only fired as a result of a direct
963 * deactivation call. So not when activating an item also deactivated
964 * an item due to a `maxActivationLimit` being set.
965 *
966 *
967 * @since 1.0.0
968 */
969type ActiveListDeactivatedMultipleEvent<T> = ActiveListBaseEvent & {
970 /**
971 * Which type occurred
972 *
973 * @since 1.0.0
974 */
975 type: 'DEACTIVATED_MULTIPLE';
976 /**
977 * The values which were deactivated.
978 *
979 * Note: these are the values at the time of deactivation, they might
980 * no longer be accurate. Keep in mind that when the `value` is
981 * an object or an array, they can still be mutated, because no
982 * copy is made.
983 *
984 * @since 1.0.0
985 */
986 values: T[];
987 /**
988 * The indexes of the deactivated items.
989 *
990 * Note: these are the indexes at the time of the deactivation, it might
991 * no longer be accurate.
992 *
993 * @since 1.0.0
994 */
995 indexes: number[];
996};
997/**
998 * Represents an activation of an ActiveList.
999 *
1000 * @since 1.0.0
1001 */
1002type ActiveListSwappedEvent<T> = ActiveListBaseEvent & {
1003 /**
1004 * Which type occurred
1005 *
1006 * @since 1.0.0
1007 */
1008 type: 'SWAPPED';
1009 /**
1010 * An object containing the value of the items which were swapped.
1011 *
1012 * @since 1.0.0
1013 */
1014 value: {
1015 /**
1016 * The value of the first item which was swapped.
1017 *
1018 * Note: this was the value at the time of the swap, it might
1019 * no longer be accurate. Keep in mind that when the `value` is
1020 * an object or an array, they can still be mutated, because no
1021 * copy is made.
1022 *
1023 * @since 1.0.0
1024 */
1025 a: T;
1026 /**
1027 * The value of the second item which was swapped.
1028 *
1029 * Note: this was the value at the time of the swap, it might
1030 * no longer be accurate. Keep in mind that when the `value` is
1031 * an object or an array, they can still be mutated, because no
1032 * copy is made.
1033 *
1034 * @since 1.0.0
1035 */
1036 b: T;
1037 };
1038 /**
1039 * An object containing the indexes of the items which were swapped.
1040 *
1041 * @since 1.0.0
1042 */
1043 index: {
1044 /**
1045 * The index of the first item before it was swapped.
1046 *
1047 * Note: this was the index at the time of the activation, it might
1048 * no longer be accurate.
1049 *
1050 * @since 1.0.0
1051 */
1052 a: number;
1053 /**
1054 * The index of the second item before it was swapped.
1055 *
1056 * Note: this was the index at the time of the activation, it might
1057 * no longer be accurate.
1058 *
1059 * @since 1.0.0
1060 */
1061 b: number;
1062 };
1063};
1064/**
1065 * Represents an activation of an ActiveList.
1066 *
1067 * @since 1.0.0
1068 */
1069type ActiveListMovedEvent<T> = ActiveListBaseEvent & {
1070 /**
1071 * Which type occurred
1072 *
1073 * @since 1.0.0
1074 */
1075 type: 'MOVED';
1076 /**
1077 * The value which was moved.
1078 *
1079 * Note: this was the value at the time of the move, it might
1080 * no longer be accurate. Keep in mind that when the `value` is
1081 * an object or an array, they can still be mutated, because no
1082 * copy is made.
1083 *
1084 * @since 1.0.0
1085 */
1086 value: T;
1087 /**
1088 * An object containing the "from" and "to" index of the item which
1089 * were moved.
1090 *
1091 * Note: this was the index at the time of the activation, it might
1092 * no longer be accurate.
1093 *
1094 * @since 1.0.0
1095 */
1096 index: {
1097 /**
1098 * The index of the "from" item before it was moved.
1099 *
1100 * Note: this was the index at the time of the activation, it might
1101 * no longer be accurate.
1102 *
1103 * @since 1.0.0
1104 */
1105 from: number;
1106 /**
1107 * The index of the "to" item before it was moved.
1108 *
1109 * Note: this was the index at the time of the activation, it might
1110 * no longer be accurate.
1111 *
1112 * @since 1.0.0
1113 */
1114 to: number;
1115 };
1116};
1117/**
1118 * Represents an ActiveList autoPlay being restarted again when it was
1119 * stopped or paused.
1120 *
1121 * Note: this event is not fired when a ActiveList is initialized
1122 * even though this does start the autoPlay.
1123 *
1124 * @since 1.0.0
1125 */
1126type ActiveListAutoPlayPlayingEvent = ActiveListBaseEvent & {
1127 /**
1128 * Which type occurred
1129 *
1130 * @since 1.0.0
1131 */
1132 type: 'AUTO_PLAY_PLAYING';
1133};
1134/**
1135 * Represents an ActiveList autoPlay being paused.
1136 *
1137 * @since 1.0.0
1138 */
1139type ActiveListAutoPlayPausedEvent = ActiveListBaseEvent & {
1140 /**
1141 * Which type occurred
1142 *
1143 * @since 1.0.0
1144 */
1145 type: 'AUTO_PLAY_PAUSED';
1146};
1147/**
1148 * Represents an ActiveList autoPlay being stopped.
1149 *
1150 * Can be fired for four reasons:
1151 *
1152 * 1. The `stop` method on the `ActiveList` is called.
1153 *
1154 * 2. The autoPlay reached the last of the items, which can only
1155 * happen when `isCircular` is `false`.
1156 *
1157 * 3. When all content items are removed when the autoPlay is playing.
1158 * It will then stop automatically since there are no more items.
1159 *
1160 * 4. When no more items are left active, in this case the autoPlay
1161 * will stop as well.
1162 *
1163 * Note: due to reasons 3 and 4 this event can be fired right before
1164 * a 'REMOVED', 'REMOVED_MULTIPLE', 'DEACTIVATED' and
1165 * 'DEACTIVATED_MULTIPLE' event.
1166 *
1167 * @since 1.0.0
1168 */
1169type ActiveListAutoPlayStoppedEvent = ActiveListBaseEvent & {
1170 /**
1171 * Which type occurred
1172 *
1173 * @since 1.0.0
1174 */
1175 type: 'AUTO_PLAY_STOPPED';
1176};
1177/**
1178 * Represents an ActiveList being in a cooldown state, meaning no
1179 * activations or deactivations can occur.
1180 *
1181 * @since 1.0.0
1182 */
1183type ActiveListCooldownStartedEvent = ActiveListBaseEvent & {
1184 /**
1185 * Which type occurred
1186 *
1187 * @since 1.0.0
1188 */
1189 type: 'COOLDOWN_STARTED';
1190};
1191/**
1192 * Represents an ActiveList moving out of the cooldown state, meaning
1193 * all activation and deactivations can occur again.
1194 *
1195 * @since 1.0.0
1196 */
1197type ActiveListCooldownEndedEvent = ActiveListBaseEvent & {
1198 /**
1199 * Which type occurred
1200 *
1201 * @since 1.0.0
1202 */
1203 type: 'COOLDOWN_ENDED';
1204};
1205/**
1206 * A ActiveListEvent represents an event happened in the ActiveList.
1207 * For example the insertion, removal, or activation of a
1208 * ActiveListContent<T>.
1209 *
1210 * @since 1.0.0
1211 */
1212type ActiveListEvent<T> = ActiveListInitializedEvent<T> | ActiveListInsertedEvent<T> | ActiveListRemovedEvent<T> | ActiveListRemovedMultipleEvent<T> | ActiveListActivatedEvent<T> | ActiveListActivatedMultipleEvent<T> | ActiveListSwappedEvent<T> | ActiveListMovedEvent<T> | ActiveListDeactivatedEvent<T> | ActiveListDeactivatedMultipleEvent<T> | ActiveListAutoPlayPlayingEvent | ActiveListAutoPlayPausedEvent | ActiveListAutoPlayStoppedEvent | ActiveListCooldownStartedEvent | ActiveListCooldownEndedEvent;
1213/**
1214 * Represents where the action needs to take place for when a
1215 * predicate is provided.
1216 *
1217 * 1. When the mode is 'at', the `ActiveListContent` is inserted to the
1218 * position where the predicate matches. This is the `default`
1219 * mode.
1220 *
1221 * 2. When the mode is 'after', the `ActiveListContent` is inserted to after
1222 * the position where the predicate matches.
1223 *
1224 * 3. When the mode is 'before', the `ActiveListContent` is inserted to
1225 * before the position where the predicate matches.
1226 *
1227 * @since 1.0.0
1228 */
1229type ActiveListPredicateMode = 'at' | 'before' | 'after';
1230/**
1231 * Represents options for methods which require predicates.
1232 *
1233 * @since 1.0.0
1234 */
1235type ActiveListPredicateOptions = {
1236 /**
1237 * Represents where the action needs to take place for when a
1238 * predicate is provided.
1239 *
1240 * Represents where the action needs to take place for when a
1241 * predicate is provided.
1242 *
1243 * 1. When the mode is 'at', the `ActiveListContent` is inserted to the
1244 * position where the predicate matches. This is the `default`
1245 * mode.
1246 *
1247 * 2. When the mode is 'after', the `ActiveListContent` is inserted to after
1248 * the position where the predicate matches.
1249 *
1250 * 3. When the mode is 'before', the `ActiveListContent` is inserted to
1251 * before the position where the predicate matches.
1252 *
1253 * @since 1.0.0
1254 */
1255 mode: ActiveListPredicateMode;
1256};
1257
1258/**
1259 * Represents a piece of content in the `contents` array of the `ActiveList`.
1260 *
1261 * The purpose of the ActiveListContent is to act as a wrapper around the
1262 * value which is actually in the contents array. It knows things like
1263 * whether the item is active or not.
1264 *
1265 * It also contains methods to activate, remove, swap and move itself
1266 * within the ActiveList.
1267 *
1268 * @since 1.0.0
1269 */
1270declare class ActiveListContent<T> {
1271 /**
1272 * Reference to the ActiveList is it a part of.
1273 *
1274 * @since 1.0.0
1275 */
1276 activeList: ActiveList<T>;
1277 /**
1278 * The index of the `ActiveListContent` which it has within the `contents`.
1279 *
1280 * @since 1.0.0
1281 */
1282 index: number;
1283 /**
1284 * The actual `value` of the `ActiveListContent` it can be whatever the
1285 * developer wants it to be.
1286 *
1287 * @since 1.0.0
1288 */
1289 value: T;
1290 /**
1291 * Whether or not the `ActiveListContent` is currently active.
1292 *
1293 * @since 1.0.0
1294 */
1295 isActive: boolean;
1296 /**
1297 * Whether or not the `ActiveListContent` has been active at least once
1298 * in the past.
1299 *
1300 * @since 1.0.0
1301 */
1302 hasBeenActiveBefore: boolean;
1303 /**
1304 * Whether or not the `ActiveListContent` is considered to be the first
1305 * item in the `contents`.
1306 *
1307 * @since 1.0.0
1308 */
1309 isFirst: boolean;
1310 /**
1311 * Whether or not the `ActiveListContent` is considered to be the last
1312 * item in the `contents`.
1313 *
1314 * @since 1.0.0
1315 */
1316 isLast: boolean;
1317 /**
1318 * Whether this `ActiveListContent` has at least one other `ActiveListContent` coming
1319 * after it in the `contents`
1320 *
1321 * @since 1.0.0
1322 */
1323 hasNext: boolean;
1324 /**
1325 * Whether this `ActiveListContent` has at least one other `ActiveListContent` coming
1326 * before it in the `contents`.
1327 *
1328 * @since 1.0.0
1329 */
1330 hasPrevious: boolean;
1331 /**
1332 * Whether this `ActiveListContent` comes directly after the `ActiveListContent`, in the
1333 * `contents` array, which is currently the `lastActiveList`.
1334 *
1335 * @since 1.0.0
1336 */
1337 isNext: boolean;
1338 /**
1339 * Whether this `ActiveListContent` comes directly before the `ActiveListContent`, in the
1340 * `contents` array, which is currently the `lastActiveList`.
1341 *
1342 * @since 1.0.0
1343 */
1344 isPrevious: boolean;
1345 /**
1346 * Creates an ActiveListContent which belongs to the given ActiveList.
1347 *
1348 * Note: you should never create instances of ActiveListContent yourself. You
1349 * are supposed to let ActiveList do this for you.
1350 *
1351 * @param {ActiveList<T>} activeList The ActiveList this ActiveListContent belongs to.
1352 * @param {number} index The index of this ActiveListContent within the ActiveList.
1353 * @param {T} value The value this ActiveListContent wraps.
1354 *
1355 * @since 1.0.0
1356 */
1357 constructor(activeList: ActiveList<T>, index: number, value: T);
1358 /**
1359 * When calling `activate` it will make this `ActiveListContent` active.
1360 *
1361 * @param {ActiveListActivationOptions<T>} [activationOptions] The activation options @see ActiveListActivationOptions<T>
1362 *
1363 * @since 1.0.0
1364 */
1365 activate(activationOptions?: ActiveListActivationOptions<T>): void;
1366 /**
1367 * When calling `deactivate` it will make this `ActiveListContent` inactive.
1368 *
1369 * @param {ActiveListActivationOptions<T>} [activationOptions] The activation options @see ActiveListActivationOptions<T>
1370 *
1371 * @since 1.0.0
1372 */
1373 deactivate(activationOptions?: ActiveListActivationOptions<T>): void;
1374 /**
1375 * When calling `toggle` it will flip the this `ActiveListContent`
1376 * `isActive` state.
1377 *
1378 * So when `isActive` is `true` and `toggle` is called, `isActive`
1379 * will become `false`. When `isActive` is `false` and `toggle` is
1380 * called, `isActive` will become `true`.
1381 *
1382 * With the `activationOptions` you can determine the effects
1383 * on `cooldown` and `autoPlay`.
1384 *
1385 * @param {ActiveListActivationOptions<T>} [activationOptions] The activation options @see ActiveListActivationOptions<T>
1386 *
1387 * @since 1.0.0
1388 */
1389 toggle(activationOptions?: ActiveListActivationOptions<T>): void;
1390 /**
1391 * When calling `remove` it will remove this `ActiveListContent`, and return
1392 * the `value` the ActiveListContent held.
1393 *
1394 * @returns {T} The removed value
1395 *
1396 * @since 1.0.0
1397 */
1398 remove(): T;
1399 /**
1400 * Swaps the `ActiveListContent` with the `ActiveListContent` at the given index.
1401 *
1402 * Note: if the active `ActiveListContent` is swapped, it will stay active,
1403 * it will only get a new position.
1404 *
1405 * @param {number} index The index to swap the current `ActiveListContent` with.
1406 * @throws {ActiveListItemNotFoundError} Item not found error
1407 *
1408 * @since 1.0.0
1409 */
1410 swapWith(item: T): void;
1411 /**
1412 * Swaps the `ActiveListContent` with the `ActiveListContent` at the given index.
1413 *
1414 * Note: if the active `ActiveListContent` is swapped, it will stay active,
1415 * it will only get a new position.
1416 *
1417 * @param {number} index] The index to swap the current `ActiveListContent` with.
1418 * @throws {ActiveListIndexOutOfBoundsError} Index out of bounds error.
1419 *
1420 * @since 1.0.0
1421 */
1422 swapWithByIndex(index: number): void;
1423 /**
1424 * Swaps the `ActiveListContent` with the next `ActiveListContent` in the sequence.
1425 *
1426 * If `isCircular` of the `ActiveList` is `true` swapping whilst on
1427 * the last index will make this `ActiveListContent` swap with the
1428 * first index. If `isCircular` is `false` it will do nothing,
1429 * and keep the `ActiveListContent` on the last index.
1430 *
1431 * Note: if the active `ActiveListContent` is swapped, it will stay active,
1432 * it will only get a new position.
1433 *
1434 * @since 1.0.0
1435 */
1436 swapWithNext(): void;
1437 /**
1438 * Swaps the `ActiveListContent` with the previous `ActiveListContent` in the sequence.
1439 *
1440 * If `isCircular` of the `ActiveList` is `true` swapping whilst on
1441 * the first index will make this `ActiveListContent` swap with the
1442 * last index. If `isCircular` is `false` it will do nothing,
1443 * and keep the `ActiveListContent` on the first index.
1444 *
1445 * Note: if the active `ActiveListContent` is swapped, it will stay active,
1446 * it will only get a new position.
1447 *
1448 * @since 1.0.0
1449 */
1450 swapWithPrevious(): void;
1451 /**
1452 * Moves the `ActiveListContent` to the position at index "to".
1453 *
1454 * It is possible to move the `ActiveListContent` to the last place by making
1455 * the "to" index the length of the `contents` array.
1456 *
1457 * Note: if the active `ActiveListContent` is moved it will stay active,
1458 * meaning that the activeIndex will get updated.
1459 *
1460 * @param {number} to The location the `from` needs to move "to".
1461 * @throws {ActiveListIndexOutOfBoundsError} Index out of bounds error.
1462 *
1463 * @since 1.0.0
1464 */
1465 moveToIndex(to: number): void;
1466 /**
1467 * Moves the `ActiveListContent` to the position of the item for which
1468 * the predicate returns `true`.
1469 *
1470 * If no item matches the predicate nothing is moved.
1471 *
1472 * The position to where the `ActiveListContent` is inserted can be altered by
1473 * providing a mode:
1474 *
1475 * 1. When the mode is 'at', the `ActiveListContent` is inserted to the
1476 * position where the predicate matches. This is the `default`
1477 * mode.
1478 *
1479 * 2. When the mode is 'after', the `ActiveListContent` is inserted to after
1480 * the position where the predicate matches.
1481 *
1482 * 3. When the mode is 'before', the `ActiveListContent` is inserted to
1483 * before the position where the predicate matches.
1484 *
1485 * @param {ActiveListContentPredicate<T>} predicate The predicate function which when `true` is returned moves the item to after that position.
1486 * @param {ActiveListPredicateOptions} options The options for the predicate, when no options are provided the mode will default to "at".
1487 *
1488 * @since 1.0.0
1489 */
1490 moveToPredicate(predicate: ActiveListContentPredicate<T>, options?: ActiveListPredicateOptions): void;
1491 /**
1492 * Moves the `ActiveListContent` to the first position in the contents array.
1493 *
1494 * Note: if the active `ActiveListContent` is moved it will stay active,
1495 * meaning that the activeIndex will get updated.
1496 *
1497 * @since 1.0.0
1498 */
1499 moveToFirst(): void;
1500 /**
1501 * Moves the `ActiveListContent` to the last position in the contents array.
1502 *
1503 * Note: if the active `ActiveListContent` is moved it will stay active,
1504 * meaning that the activeIndex will get updated.
1505 *
1506 * @since 1.0.0
1507 */
1508 moveToLast(): void;
1509}
1510
1511/**
1512 * ActiveList is a class which represents visual elements which
1513 * have multiple pieces of content which can be active or inactive.
1514 *
1515 * The `ActiveList` can be used to implement multiple types of
1516 * components:
1517 *
1518 * 1. A tabs component for which one tab can be active at a time.
1519 *
1520 * 2. A carrousel component: the user sees single slide, which will
1521 * autoPlay to the next slide automatically.
1522 *
1523 * 3. A dropdown menu with one active menu item.
1524 *
1525 * 4. A accordion component from which the user can open multiple
1526 * items at once.
1527 *
1528 * 5. A list the user can sort and move around.
1529 *
1530 * 6. Etc etc
1531 *
1532 * Another way of defining the ActiveList is that it is an array
1533 * / list like data structure, because it supports things like
1534 * insertion and removal.
1535 *
1536 * ActiveList will make sure that when content is inserted, that
1537 * the active content is not affected.
1538 *
1539 * @since 1.0.0
1540 */
1541declare class ActiveList<T> implements Observable<ActiveList<T>, ActiveListEvent<T>> {
1542 /**
1543 * Whether or not to inform subscribers of changes / record history.
1544 * Used in the `initialize` to temporarily stop subscriptions running
1545 * the initial activation, and altering the history.
1546 */
1547 private _isInitializing;
1548 /**
1549 * The `ActiveListContent` instances which the `ActiveList` holds.
1550 *
1551 * @since 1.0.0
1552 */
1553 readonly contents: ActiveListContent<T>[];
1554 /**
1555 * How many items can be active at the same time.
1556 *
1557 * When the value of `limit` is `false` there is no limit to the
1558 * number of active items.
1559 *
1560 * Defaults to 1.
1561 *
1562 * @since 1.0.0
1563 */
1564 maxActivationLimit: number | false;
1565 /**
1566 * How the `maxActivationLimit` is enforced. In other words what the
1567 * behavior should be when the limit is surpassed.
1568 *
1569 * The modes are strings which can be the following values:
1570 *
1571 * 1. 'circular': the first item which was added will be removed so
1572 * the last item can be added without violating the limit. This
1573 * basically means that the first one in is the first one out.
1574 *
1575 * 2. 'error': An error is thrown whenever the limit is surpassed,
1576 * the error is called the `ActiveListActivationLimitReachedError`.
1577 *
1578 * 3. 'ignore': Nothing happens when an item is added and the limit
1579 * is reached. The item is simply not added, but no error is
1580 * thrown.
1581 *
1582 * Defaults to 'circular'.
1583 *
1584 * @since 1.0.0
1585 */
1586 maxActivationLimitBehavior: ActiveListMaxActivationLimitBehavior;
1587 /**
1588 * All `value` of the content which are currently considered active.
1589 *
1590 * @since 1.0.0
1591 */
1592 readonly active: T[];
1593 /**
1594 * All `ActiveListContent` which are currently considered active.
1595 *
1596 * @since 1.0.0
1597 */
1598 readonly activeContents: ActiveListContent<T>[];
1599 /**
1600 * All indexes of which are currently considered active.
1601 *
1602 * @since 1.0.0
1603 */
1604 readonly activeIndexes: number[];
1605 /**
1606 * Which `value` from within an `ActiveListContent` was the last
1607 * value which was activated.
1608 *
1609 * In other words: of all active values which value was activated
1610 * the last chronologically.
1611 *
1612 * When nothing is activated in the `ActiveList` the value of
1613 * `lastActivated` will be `null`.
1614 *
1615 * @since 1.0.0
1616 */
1617 lastActivated: T | null;
1618 /**
1619 * Which `ActiveListContent` is the last ActiveListContent which
1620 * was activated.
1621 *
1622 * In other words: of all active contents which content was
1623 * activated the last chronologically.
1624 *
1625 * When nothing is activated in the `ActiveList` the value of
1626 * `lastActivatedContent` will be `null`.
1627 *
1628 * @since 1.0.0
1629 */
1630 lastActivatedContent: ActiveListContent<T> | null;
1631 /**
1632 * Which index of the `contents` array was the last index which
1633 * was activated.
1634 *
1635 * In other words: of all active indexes which index was activated
1636 * the last chronologically.
1637 *
1638 * When nothing is activated in the `ActiveList` the value of
1639 * `lastActivatedIndex` will be `-1`.
1640 *
1641 * @since 1.0.0
1642 */
1643 lastActivatedIndex: number;
1644 /**
1645 * Which `value` from within an `ActiveListContent` was the last
1646 * value which was deactivated.
1647 *
1648 * When nothing was deactivated previously in the `ActiveList` the
1649 * value of `lastDeactivated` will be `null`.
1650 *
1651 * @since 1.5.0
1652 */
1653 lastDeactivated: T | null;
1654 /**
1655 * Which `ActiveListContent` is the last ActiveListContent which
1656 * was deactivated.
1657 *
1658 * When nothing was deactivated previously in the `ActiveList` the
1659 * value of `lastDeactivatedContent` will be `null`.
1660 *
1661 * @since 1.5.0
1662 */
1663 lastDeactivatedContent: ActiveListContent<T> | null;
1664 /**
1665 * Which index of the `contents` array was the last index which
1666 * was deactivated.
1667 *
1668 * When nothing was deactivated previously in the `ActiveList` the
1669 * value of `lastDeactivatedIndex` will be `-1`.
1670 *
1671 * @since 1.5.0
1672 */
1673 lastDeactivatedIndex: number;
1674 /**
1675 * Whether or not the content starts back at the beginning when
1676 * the end of the content is reached, and whether the content should
1677 * go to the end when moving left of the start.
1678 *
1679 * Defaults to `false`.
1680 *
1681 * @since 1.0.0
1682 */
1683 isCircular: boolean;
1684 /**
1685 * The direction the `ActiveList` has previously moved to on
1686 * activation or deactivation.
1687 *
1688 * Useful for when animating the `ActiveList` when wanting to
1689 * animate differently based on the direction the content is
1690 * activating towards.
1691 *
1692 * The direction is determined using the following rules for
1693 * activation:
1694 *
1695 * 1. When `isCircular` is `false`:
1696 *
1697 * a. If the `lastActivatedIndex` is -1 the direction is always `next`.
1698 * The `lastActivatedIndex` is -1 when no item is active.
1699 *
1700 * b. If the `lastActivatedIndex` lies before the activated index the
1701 * direction is `next`.
1702 *
1703 * c. If the `lastActivatedIndex` lies after the activated index the
1704 * direction is `previous`.
1705 *
1706 * 2. When `isCircular` is `true`,
1707 *
1708 * a. If the `lastActivatedIndex` is -1 the direction is always `next`.
1709 * The `lastActivatedIndex` is -1 when no item is active.
1710 *
1711 * b. The direction is determined by checking which direction
1712 * is the shortest path. If the shortest paths are tied, the
1713 * direction will become `next`.
1714 *
1715 * Note: the direction is only changed upon activation and
1716 * deactivation. Removing / inserting, moving and swapping do not
1717 * affect the direction.
1718 *
1719 * Defaults to the value of the `Config` property `direction.next`.
1720 *
1721 * @since 1.0.0
1722 */
1723 direction: string;
1724 /**
1725 * The opposite of the `direction` property of the `ActiveList`.
1726 * If the `direction` is `next` the opposite direction is always
1727 * `previous` and vice versa.
1728 *
1729 * Defaults to the value of the `Config` property `direction.previous`.
1730 *
1731 * @since 1.5.0
1732 */
1733 oppositeDirection: string;
1734 private _history;
1735 /**
1736 * Contains the history of the changes in the contents array.
1737 *
1738 * Tracks 15 types of changes:
1739 *
1740 * 1. INITIALIZED: fired when ActiveList is initialized.
1741 *
1742 * 2. INSERTED: fired when an item is added.
1743 *
1744 * 3. REMOVED: fired when an item is removed.
1745 *
1746 * 4. REMOVED_MULTIPLE: fired when multiple items are removed with a predicate.
1747 *
1748 * 5. ACTIVATED: fired when an item is activated.
1749 *
1750 * 6 ACTIVATED_MULTIPLE: fired when multiple items are activated with a predicate.
1751 *
1752 * 7. DEACTIVATED: fired when an item is deactivated.
1753 *
1754 * 8. DEACTIVATED_MULTIPLE: fired when multiple items are deactivated with a predicate.
1755 *
1756 * 9. SWAPPED: fired when an item is swapped.
1757 *
1758 * 10. MOVED: fired when an item is moved.
1759 *
1760 * 11. AUTO_PLAY_PLAYING: fired when play is called.
1761 *
1762 * 12. AUTO_PLAY_PAUSED: fired when pause is called.
1763 *
1764 * 13. AUTO_PLAY_STOPPED: fired when stop is called, or the autoPlay stops due to a condition.
1765 *
1766 * 14. COOLDOWN_STARTED: fired when ActiveList goes into cooldown state
1767 *
1768 * 15. COOLDOWN_ENDED: fired when ActiveList goes out of cooldown state
1769 *
1770 * Goes only as far back as configured in the `Config` property
1771 * `keepHistoryFor`, to prevent an infinitely growing history.
1772 * Note that by default no history is kept, as `keepHistoryFor`
1773 * is zero by default.
1774 *
1775 * The last item in the `history` is the current active item. The
1776 * further to the left the further in the past you go.
1777 *
1778 * This means that a history at index 0 is further in the past than
1779 * an item at index 1.
1780 *
1781 * WARNING: all events store indexes, values and combinations thereof.
1782 * The `index` of an item in the history may no longer be accurate, it
1783 * is the index at the time of the event. Same goes for the `value`
1784 * when it is an array of object, as it might have been mutated, the
1785 * history items do not store copies of the values.
1786 *
1787 * @since 1.0.0
1788 */
1789 readonly history: ActiveListEvent<T>[];
1790 private _observer;
1791 /**
1792 * Whether or not the `active` item has changed at least once.
1793 * Useful when you want to know if the `ActiveList` is still
1794 * in its initial state.
1795 *
1796 * Note: when the `initialize` method of the `Actions` is called this
1797 * boolean is reset.
1798 *
1799 * @since 1.0.0
1800 */
1801 hasActiveChangedAtLeastOnce: boolean;
1802 private _activationCooldownTimer;
1803 /**
1804 * A Cooldown is a time period in which all user made activations
1805 * and deactivations are prevented / ignored. Activations and
1806 * deactivations where the `isUserInteraction` is set to `false`
1807 * always bypass the cooldown.
1808 *
1809 * The use-case is a cooldown can guarantees that animations are
1810 * completed, before another is triggered.
1811 *
1812 * Contains whether or not the cooldown is active via `isActive` and
1813 * the current duration via `duration`.
1814 *
1815 * @since 1.0.0
1816 */
1817 readonly cooldown: ActiveListCooldown;
1818 private _autoPlay;
1819 /**
1820 * AutoPlay means that the ActiveList will move to the next content by
1821 * itself after a duration.
1822 *
1823 * Contains whether or not the autoPlay is playing via `isPlaying`,
1824 * the current duration via `duration`, and whether or not the
1825 * autoPlay has been stopped before via `hasBeenStoppedBefore`
1826 *
1827 * @since 1.0.0
1828 */
1829 readonly autoPlay: ActiveListAutoPlay;
1830 private _directions;
1831 /**
1832 * Creates an ActiveList based on the ActiveListConfig config.
1833 *
1834 * You can also optionally provide an subscriber so you can get
1835 * informed of the changes happening to the ActiveList.
1836 *
1837 * @param {ActiveListConfig<T>} config The initial configuration of the ActiveList.
1838 * @param {ActiveListSubscriber<T> | undefined} subscriber An optional subscriber which responds to changes in the ActiveList.
1839 * @throws {ActiveListAutoPlayDurationError} autoPlay duration must be a positive number when defined
1840 * @throws {ActiveListActivationLimitReachedError} thrown when maxActivationLimit is exceeded, and maxActivationLimitBehavior is "error".
1841 * @since 1.0.0
1842 */
1843 constructor(config?: ActiveListConfig<T>, subscriber?: ActiveListSubscriber<T>);
1844 /**
1845 * Subscribe to changes of the ActiveList. The function you
1846 * provide will get called whenever changes occur in the
1847 * ActiveList.
1848 *
1849 * Returns an unsubscribe function which when called will unsubscribe
1850 * from the ActiveList.
1851 *
1852 * @param {ActiveListSubscriber<T>} subscriber The subscriber which responds to changes in the ActiveList.
1853 * @returns {UnsubscribeFunction} A function which when called will unsubscribe from the ActiveList.
1854 *
1855 * @since 1.0.0
1856 */
1857 subscribe(subscriber: ActiveListSubscriber<T>): UnsubscribeFunction;
1858 /**
1859 * Unsubscribe the subscriber so it no longer receives changes / updates
1860 * of the state changes of the ActiveList.
1861 *
1862 * @param {ActiveListSubscriber<T>} subscriber The subscriber which you want to unsubscribe.
1863 *
1864 * @since 1.0.0
1865 */
1866 unsubscribe(subscriber: ActiveListSubscriber<T>): void;
1867 /**
1868 * Unsubscribes all subscribers at once, all subscribers will no
1869 * longer receives changes / updates of the state changes of
1870 * the ActiveList.
1871 *
1872 * @since 1.5.0
1873 */
1874 unsubscribeAll(): void;
1875 /**
1876 * Initializes the ActiveList based on the config provided. This can
1877 * effectively reset the ActiveList when called, including the
1878 * history, autoPlay and cooldown.
1879 *
1880 * @param {ActiveListConfig<T>} config The new configuration which will override the old one
1881 * @throws {ActiveListAutoPlayDurationError} autoPlay duration must be a positive number when defined
1882 * @throws {ActiveListActivationLimitReachedError} thrown when maxActivationLimit is exceeded, and maxActivationLimitBehavior is "error".
1883 * @since 1.0.0
1884 */
1885 initialize(config: ActiveListConfig<T>): void;
1886 private _initializeABrokenContent;
1887 /**
1888 * Activates an item based on the index in the content array.
1889 *
1890 * If the index does not exist an error will be thrown.
1891 *
1892 * With the `activationOptions` you can determine the effects
1893 * on `cooldown` and `autoPlay`.
1894 *
1895 * @param {number} index The index to activate
1896 * @param {ActiveListActivationOptions<T>} ActiveListActivationOptions The activation options
1897 * @throws {ActiveListIndexOutOfBoundsError} index cannot be out of bounds
1898 * @throws {ActiveListActivationLimitReachedError} thrown when maxActivationLimit is exceeded, and maxActivationLimitBehavior is "error".
1899 * @throws {ActiveListCooldownDurationError} cooldown duration must be a positive number when defined
1900 *
1901 * @since 1.0.0
1902 */
1903 activateByIndex(index: number, activationOptions?: ActiveListActivationOptions<T>): void;
1904 private _doActivateByIndex;
1905 /**
1906 * Activates the given item based on identity by comparing the item
1907 * via a `===` check. When multiple items match on `===` only the
1908 * first matching item is activated.
1909 *
1910 * If the item does not exist in the content array it will
1911 * throw an error.
1912 *
1913 * With the `activationOptions` you can determine the effects
1914 * on `cooldown` and `autoPlay`.
1915 *
1916 * @param {T} item The item to activate
1917 * @param {ActiveListActivationOptions<T>} ActiveListActivationOptions The activation options
1918 * @throws {ActiveListItemNotFoundError} item must be in the contents array based on === equality
1919 * @throws {ActiveListActivationLimitReachedError} thrown when maxActivationLimit is exceeded, and maxActivationLimitBehavior is "error".
1920 * @throws {ActiveListCooldownDurationError} cooldown duration must be a positive number when defined
1921 *
1922 * @since 1.0.0
1923 */
1924 activate(item: T, activationOptions?: ActiveListActivationOptions<T>): void;
1925 /**
1926 * Activates all items that match the predicate.
1927 *
1928 * If no items match the predicate nothing happens.
1929 *
1930 * If multiple items were activated as a result of calling
1931 * `activateByPredicate` they will be activated in order of
1932 * appearance in the contents array.
1933 *
1934 * Items can also be deactivated if the `maxActivationLimit` is set
1935 * to a number and the `maxActivationLimitBehavior` is set to
1936 * "circular", if space needs to be made for the new activations.
1937 *
1938 * When `maxActivationLimitBehavior` is set to "error", all items
1939 * that can be accommodated are activated, but when the limit is
1940 * exceeded the activation stops. The subscribers are then informed
1941 * of which items were activated, and then the error is thrown.
1942 *
1943 * Even through each item is activated sequentially, only one event
1944 * is emitted, and one call is made to the subscribers, even if
1945 * multiple items are activated and deactivated.
1946 *
1947 * Within the `ActiveListActivatedMultipleEvent` only the end
1948 * activate / deactivate results are reported.
1949 *
1950 * With the `activationOptions` you can determine the effects
1951 * on `cooldown` and `autoPlay`. When the cooldown is configured
1952 * as a function, the last activated content will be the parameter
1953 * to the cooldown function.
1954 *
1955 * @param {ActiveListContentPredicate<T>} predicate A predicate function, when the predicate returns `true` it will activate that item.
1956 * @param {ActiveListActivationOptions<T>} ActiveListActivationOptions The activation options
1957 * @throws {ActiveListActivationLimitReachedError} thrown when maxActivationLimit is exceeded, and maxActivationLimitBehavior is "error".
1958 * @throws {ActiveListCooldownDurationError} cooldown duration must be a positive number when defined
1959 *
1960 * @since 1.0.0
1961 */
1962 activateByPredicate(predicate: ActiveListContentPredicate<T>, activationOptions?: ActiveListActivationOptions<T>): void;
1963 /**
1964 * Activates the next item in the sequence based on the `lastActivated`
1965 * ActiveListContent.
1966 *
1967 * If no `lastActivated` is present when `activateNext` is called
1968 * the first element is activated.
1969 *
1970 * If the `contents` are empty when `activateNext` is called
1971 * nothing will happen.
1972 *
1973 * When on the last position: if `isCircular` is `true` it will circle
1974 * around and activate the first position. When `isCircular` is `false`
1975 * it will stay on the last position and do nothing.
1976 *
1977 * With the `activationOptions` you can determine the effects
1978 * on `cooldown` and `autoPlay`.
1979 *
1980 * @param {ActiveListActivationOptions<T>} ActiveListActivationOptions The activation options
1981 * @throws {ActiveListActivationLimitReachedError} thrown when maxActivationLimit is exceeded, and maxActivationLimitBehavior is "error".
1982 * @throws {ActiveListCooldownDurationError} cooldown duration must be a positive number when defined
1983 *
1984 * @since 1.0.0
1985 */
1986 activateNext(activationOptions?: ActiveListActivationOptions<T>): void;
1987 /**
1988 * Activates the previous item in the sequence based on the
1989 * `lastActivated` ActiveListContent.
1990 *
1991 * If no `lastActivated` is present when `activatePrevious` is called
1992 * the first element is activated.
1993 *
1994 * If the `contents` are empty when `activatePrevious` is called
1995 * nothing will happen.
1996 *
1997 * When on the first position: if `isCircular` is `true` it will circle
1998 * around and activate the last position. When `isCircular` is `false`
1999 * it will stay on the first position and do nothing.
2000 *
2001 * With the `activationOptions` you can determine the effects
2002 * on `cooldown` and `autoPlay`.
2003 *
2004 * @param {ActiveListActivationOptions<T>} ActiveListActivationOptions The activation options
2005 * @throws {ActiveListActivationLimitReachedError} thrown when maxActivationLimit is exceeded, and maxActivationLimitBehavior is "error".
2006 * @throws {ActiveListCooldownDurationError} cooldown duration must be a positive number when defined
2007 *
2008 * @since 1.0.0
2009 */
2010 activatePrevious(activationOptions?: ActiveListActivationOptions<T>): void;
2011 /**
2012 * Activates the first item of the contents.
2013 *
2014 * If the `contents` are empty when `activateFirst` is called
2015 * nothing will happen.
2016 *
2017 * With the `activationOptions` you can determine the effects
2018 * on `cooldown` and `autoPlay`.
2019 *
2020 * @param {ActiveListActivationOptions<T>} ActiveListActivationOptions The activation options
2021 * @throws {ActiveListActivationLimitReachedError} thrown when maxActivationLimit is exceeded, and maxActivationLimitBehavior is "error".
2022 * @throws {ActiveListCooldownDurationError} cooldown duration must be a positive number when defined
2023 *
2024 * @since 1.0.0
2025 */
2026 activateFirst(activationOptions?: ActiveListActivationOptions<T>): void;
2027 /**
2028 * Activates the last item of the contents.
2029 *
2030 * If the `contents` are empty when `activateLast` is called
2031 * nothing will happen.
2032 *
2033 * With the `activationOptions` you can determine the effects
2034 * on `cooldown` and `autoPlay`.
2035 *
2036 * @param {ActiveListActivationOptions<T>} ActiveListActivationOptions The activation options
2037 * @throws {ActiveListActivationLimitReachedError} thrown when maxActivationLimit is exceeded, and maxActivationLimitBehavior is "error".
2038 * @throws {ActiveListCooldownDurationError} cooldown duration must be a positive number when defined
2039 *
2040 * @since 1.0.0
2041 */
2042 activateLast(activationOptions?: ActiveListActivationOptions<T>): void;
2043 /**
2044 * Deactivates an item based on the index in the content array.
2045 *
2046 * If the index does not exist an error will be thrown.
2047 *
2048 * With the `activationOptions` you can determine the effects
2049 * on `cooldown` and `autoPlay`.
2050 *
2051 * @param {number} index The index to deactivate
2052 * @param {ActiveListActivationOptions<T>} ActiveListActivationOptions The activation options
2053 * @throws {ActiveListIndexOutOfBoundsError} index cannot be out of bounds
2054 * @throws {ActiveListCooldownDurationError} cooldown duration must be a positive number when defined
2055 *
2056 * @since 1.0.0
2057 */
2058 deactivateByIndex(index: number, activationOptions?: ActiveListActivationOptions<T>): void;
2059 private _doDeactivateByIndex;
2060 /**
2061 * Deactivates the given item based on identity by comparing the item
2062 * via a `===` check. When multiple items match on `===` only the
2063 * first matching item is activated.
2064 *
2065 * If the item does not exist in the content array it will
2066 * throw an error.
2067 *
2068 * With the `activationOptions` you can determine the effects
2069 * on `cooldown` and `autoPlay`.
2070 *
2071 * @param {T} item The item to deactivate
2072 * @param {ActiveListActivationOptions<T>} ActiveListActivationOptions The activation options
2073 * @throws {ActiveListItemNotFoundError} item must be in the contents array based on === equality
2074 * @throws {ActiveListCooldownDurationError} cooldown duration must be a positive number when defined
2075 *
2076 * @since 1.0.0
2077 */
2078 deactivate(item: T, activationOptions?: ActiveListActivationOptions<T>): void;
2079 /**
2080 * Deactivates all items that match the predicate.
2081 *
2082 * If no items match the predicate nothing happens.
2083 *
2084 * If multiple items match they will be deactivated in order of
2085 * appearance in the contents array. Only one call is made to the
2086 * subscribers, even if multiple items are deactivated.
2087 *
2088 * With the `activationOptions` you can determine the effects
2089 * on `cooldown` and `autoPlay`. When the cooldown is configured
2090 * as a function, the last deactivated content will be the parameter
2091 * to the cooldown function.
2092 *
2093 * @param {ActiveListContentPredicate<T>} predicate A predicate function, when the predicate returns `true` it will deactivate that item.
2094 * @param {ActiveListActivationOptions<T>} ActiveListActivationOptions The activation options
2095 * @throws {ActiveListCooldownDurationError} cooldown duration must be a positive number when defined
2096 *
2097 * @since 1.0.0
2098 */
2099 deactivateByPredicate(predicate: ActiveListContentPredicate<T>, activationOptions?: ActiveListActivationOptions<T>): void;
2100 /**
2101 * When calling `toggleByIndex` it will flip the `ActiveListContent`
2102 * which resides on the index `isActive` state .
2103 *
2104 * So when `isActive` is `true` and `toggle` is called, `isActive`
2105 * will become `false`. When `isActive` is `false` and `toggle` is
2106 * called, `isActive` will become `true`.
2107 *
2108 * If the index does not exist an error will be thrown.
2109 *
2110 * With the `activationOptions` you can determine the effects
2111 * on `cooldown` and `autoPlay`.
2112 *
2113 * @param {number} index The index to activate
2114 * @param {ActiveListActivationOptions<T>} [activationOptions] The activation options
2115 * @throws {ActiveListIndexOutOfBoundsError} index cannot be out of bounds
2116 *
2117 * @since 1.0.0
2118 */
2119 toggleByIndex(index: number, activationOptions?: ActiveListActivationOptions<T>): void;
2120 /**
2121 * Toggles the given item based on identity by comparing the item
2122 * via a `===` check. When multiple items match on `===` only the
2123 * first matching item is activated.
2124 *
2125 * So when `isActive` is `true` and `toggle` is called, `isActive`
2126 * will become `false`. When `isActive` is `false` and `toggle` is
2127 * called, `isActive` will become `true`.
2128 *
2129 * If the item does not exist in the content array it will
2130 * throw an error.
2131 *
2132 * With the `activationOptions` you can determine the effects
2133 * on `cooldown` and `autoPlay`.
2134 *
2135 * @param {T} item The item to toggle
2136 * @param {ActiveListActivationOptions<T>} ActiveListActivationOptions The activation options
2137 * @throws {ActiveListItemNotFoundError} item must be in the contents array based on === equality
2138 *
2139 * @since 1.0.0
2140 */
2141 toggle(item: T, activationOptions?: ActiveListActivationOptions<T>): void;
2142 /**
2143 * Will start playing the ActiveList based on the active
2144 * autoPlayConfig. When `autoPlayConfig` is not defined nothing
2145 * will happen when calling play.
2146 *
2147 * When there is no more content the playing will stop automatically.
2148 *
2149 * Note: autoPlay will only start when one or more contents are
2150 * currently active. The reason for this is that the `duration`, is
2151 * based on the `ActiveList` `lastActivatedContent` property.
2152 * Whenever there are no more items to activate the autoPlay will
2153 * stop.
2154 *
2155 * @throws {ActiveListAutoPlayDurationError} autoPlay duration must be a positive number when defined
2156 *
2157 * @since 1.0.0
2158 */
2159 play(): void;
2160 /**
2161 * When the ActiveList is playing it will pause the autoPlay.
2162 *
2163 * When paused, the current autoPlay duration is remember and resumed
2164 * from that position, when `play` is called again.
2165 *
2166 * For example: when the duration is 1 second and the `pause` is
2167 * called after 0.8 seconds, it will after `play` is called, take
2168 * 0.2 seconds to go to the next content.
2169 *
2170 * Note: if the autoPlay is already paused calling `pause` again
2171 * will do nothing, the time used for the remaining duration is
2172 * based on the first pause.
2173 *
2174 * @since 1.0.0
2175 */
2176 pause(): void;
2177 /**
2178 * When the ActiveList is playing it will stop the autoPlay.
2179 *
2180 * By calling `play` again it is possible to restart the autoPlay.
2181 * However the duration will behave in this scenario as it if was
2182 * reset.
2183 *
2184 * For example: when the duration is 1 second and the `stop` is
2185 * called after 0.8 seconds, it will after `play` is called, take
2186 * 1 second to go to the next content.
2187 *
2188 * @since 1.0.0
2189 */
2190 stop(): void;
2191 /**
2192 * Configures the autoPlay, when the autoPlay is `null` the autoPlay
2193 * is stopped.
2194 *
2195 * Can be used to reconfigure the speed of the autoPlay after the
2196 * ActiveList has been created.
2197 *
2198 * Note: calling `configureAutoPlay` will not set (reset) the
2199 * hasBeenStoppedBefore` to `false` when called.
2200 *
2201 * @param {ActiveListAutoPlayConfig<T> | null} autoPlayConfig The new autoPlay configuration
2202 * @throws {ActiveListAutoPlayDurationError} autoPlay duration must be a positive number when defined
2203 *
2204 * @since 1.0.0
2205 */
2206 configureAutoPlay(autoPlayConfig: ActiveListAutoPlayConfig<T> | null): void;
2207 /**
2208 * Will add an item to the `contents` array, at the specified `index`.
2209 *
2210 * Note: `insertAtIndex` will not allow holes to be created, this
2211 * means that the index can only be between `0` and `contents.length`.
2212 * If you give it a larger or smaller index it will throw an error.
2213 *
2214 * @param {T} item The item to insert.
2215 * @param {number} index The index at which to insert the item.
2216 * @returns {ActiveListContent<T>} The newly inserted item wrapped in an `ActiveListContent`
2217 * @throws {ActiveListIndexOutOfBoundsError} index cannot be out of bounds
2218 *
2219 * @since 1.0.0
2220 */
2221 insertAtIndex(item: T, index: number): ActiveListContent<T>;
2222 /**
2223 * Will add an item to the end of the `contents` array.
2224 *
2225 * @param {T} item The item to insert.
2226 * @returns {ActiveListContent<T>} The newly inserted item wrapped in an `ActiveListContent`
2227 *
2228 * @since 1.0.0
2229 */
2230 push(item: T): ActiveListContent<T>;
2231 /**
2232 * Will add an item at the start of the `contents` array.
2233 *
2234 * @param {T} item The item to insert.
2235 * @returns {ActiveListContent<T>} The newly inserted item wrapped in an `ActiveListContent`
2236 *
2237 * @since 1.0.0
2238 */
2239 unshift(item: T): ActiveListContent<T>;
2240 /**
2241 * Will add an item at the position in the `contents` array when when
2242 * the predicate returns `true` for the `item` and `index`.
2243 *
2244 * If no item matches the predicate nothing is inserted and `null`
2245 * will be returned.
2246 *
2247 * The position to where the `ActiveListContent` is inserted can be altered by
2248 * providing a mode:
2249 *
2250 * 1. When the mode is 'at', the `ActiveListContent` is inserted to the
2251 * position where the predicate matches. This is the `default`
2252 * mode.
2253 *
2254 * 2. When the mode is 'after', the `ActiveListContent` is inserted to after
2255 * the position where the predicate matches.
2256 *
2257 * 3. When the mode is 'before', the `ActiveListContent` is inserted to
2258 * before the position where the predicate matches.
2259 *
2260 * @param {T} item The item to insert.
2261 * @param {ActiveListContentPredicate<T>} predicate A predicate function, when the predicate returns `true` it will move the item to that position.
2262 * @param {ActiveListPredicateOptions} options The options for the predicate, when no options are provided the mode will default to "at".
2263 *
2264 * @since 1.0.0
2265 */
2266 insertByPredicate(item: T, predicate: ActiveListContentPredicate<T>, options?: ActiveListPredicateOptions): ActiveListContent<T> | null;
2267 /**
2268 * Will remove an item in the `contents` array, at the specified `index`.
2269 *
2270 * If you remove the `lastDeactivated` item it will be set to null.
2271 *
2272 * Throws an error if the index does not exist within the `contents`
2273 * array.
2274 *
2275 * @param {number} index The index at which to remove the item.
2276 * @returns {T} The removed value
2277 * @throws {ActiveListIndexOutOfBoundsError} index cannot be out of bounds
2278 *
2279 * @since 1.0.0
2280 */
2281 removeByIndex(index: number): T;
2282 private _doRemoveAtIndex;
2283 /**
2284 * Removes the given item based on identity by comparing the item
2285 * via a `===` check. When multiple items match on `===` only the
2286 * first matching item is removed.
2287 *
2288 * If you remove the `lastDeactivated` item it will be set to null.
2289 *
2290 * If the item does not exist in the content array it will
2291 * throw an error.
2292 *
2293 * @param {T} item The item to remove
2294 * @returns {T} The removed item
2295 * @throws {ActiveListItemNotFoundError} item must be in the contents array based on === equality
2296 *
2297 * @since 1.0.0
2298 */
2299 remove(item: T): T;
2300 /**
2301 * Removes the last item of the of the `contents` array.
2302 *
2303 * If you remove the `lastDeactivated` item it will be set to null.
2304 *
2305 * If the `contents` array at the time of the `pop` is empty
2306 * `undefined` is returned.
2307 *
2308 * @param {ActiveListActivationOptions<T>} ActiveListActivationOptions The activation options
2309 * @returns {T | undefined} The removed value, or undefined if the `contents` array is empty.
2310 *
2311 * @since 1.0.0
2312 */
2313 pop(): T | undefined;
2314 /**
2315 * Removes the first item of the `contents` array.
2316 *
2317 * If you remove the `lastDeactivated` item it will be set to null.
2318 *
2319 * If the `contents` array at the time of the `shift` is empty
2320 * `undefined` is returned.
2321 *
2322 * @returns {T | undefined} The removed value, or undefined if the `contents` array is empty.
2323 *
2324 * @since 1.0.0
2325 */
2326 shift(): T | undefined;
2327 /**
2328 * Will remove all items from the `contents` array for which the
2329 * predicate based on the `item` and `index` returns `true`.
2330 *
2331 * If no item matches the predicate nothing is removed and an empty
2332 * array will be returned.
2333 *
2334 * If you remove the `lastDeactivated` item it will be set to null.
2335 *
2336 * @param {T} item The item to insert.
2337 * @param {ActiveListContentPredicate<T>} predicate A predicate function, when the predicate returns `true` it will remove the item.
2338 * @returns {T[]} The removed items.
2339 *
2340 * @since 1.0.0
2341 */
2342 removeByPredicate(predicate: ActiveListContentPredicate<T>): T[];
2343 /**
2344 * Swaps the `ActiveListContent` at index a, with the `ActiveListContent` at index b.
2345 *
2346 * Note: if the active `ActiveListContent` is swapped, it will stay active,
2347 * it will only get a new position.
2348 *
2349 * @param {number} a The first index to swap.
2350 * @param {number} b The second index to swap.
2351 * @throws {ActiveListIndexOutOfBoundsError} index cannot be out of bounds
2352 *
2353 * @since 1.0.0
2354 */
2355 swapByIndex(a: number, b: number): void;
2356 /**
2357 * Swaps the `ActiveListContent` with item a, with the `ActiveListContent` with
2358 * item b. Swaps the items based on identity by comparing the items
2359 * via a `===` check. When multiple items match on `===` only the
2360 * first matching item is swapped.
2361 *
2362 * Note: if the active `ActiveListContent` is swapped, it will stay active,
2363 * it will only get a new position.
2364 *
2365 * @param {T} a The first item to swap.
2366 * @param {T} b The second item to swap.
2367 * @throws {ActiveListItemNotFoundError} item must be in the contents array based on === equality
2368 *
2369 * @since 1.0.0
2370 */
2371 swap(a: T, b: T): void;
2372 /**
2373 * Moves the `ActiveListContent` at index "from", to the position at index "to".
2374 *
2375 * It is possible to move the `ActiveListContent` to the last place by making
2376 * the "to" index the length of the `contents` array.
2377 *
2378 * Note: if the active `ActiveListContent` is moved it will stay active,
2379 * meaning that the lastActivatedIndex will get updated.
2380 *
2381 * @param {number} from The "from" index which needs to be moved
2382 * @param {number} to The location the `from` needs to move "to".
2383 * @throws {ActiveListIndexOutOfBoundsError} index cannot be out of bounds
2384 *
2385 * @since 1.0.0
2386 */
2387 moveByIndex(from: number, to: number): void;
2388 /**
2389 * Moves the item, to the position at index "to".
2390 *
2391 * It is possible to move the `ActiveListContent` to the last place by making
2392 * the "to" index the length of the `contents` array.
2393 *
2394 * Note: if the active `ActiveListContent` is moved it will stay active,
2395 * meaning that the lastActivatedIndex will get updated.
2396 *
2397 * @param {T} item The item to move
2398 * @param {number} to The location the `item` needs to move "to".
2399 * @throws {ActiveListItemNotFoundError} item must be in the contents array based on === equality
2400 * @throws {ActiveListIndexOutOfBoundsError} index cannot be out of bounds
2401 *
2402 * @since 1.0.0
2403 */
2404 move(item: T, to: number): void;
2405 /**
2406 * Moves the `ActiveListContent`, at the index, to the position of the
2407 * item for which the predicate returns `true`.
2408 *
2409 * If no item matches the predicate nothing is moved.
2410 *
2411 * The position to where the `ActiveListContent` moves can be altered by
2412 * providing a mode:
2413 *
2414 * 1. When the mode is 'at', the `ActiveListContent` is moved to the position
2415 * where the predicate matches. This is the `default` mode.
2416 *
2417 * 2. When the mode is 'after', the `ActiveListContent` is moved to after the
2418 * position where the predicate matches.
2419 *
2420 * 3. When the mode is 'before', the `ActiveListContent` is moved to before
2421 * the position where the predicate matches.
2422 *
2423 * @param {number} index The index to move.
2424 * @param {ActiveListContentPredicate<T>} predicate A predicate function, when the predicate returns `true` it will move the item to that position.
2425 * @param {ActiveListPredicateOptions} options The options for the predicate, when no options are provided the mode will default to "at".
2426 *
2427 * @since 1.0.0
2428 */
2429 moveByIndexByPredicate(index: number, predicate: ActiveListContentPredicate<T>, options?: ActiveListPredicateOptions): void;
2430 /**
2431 * Moves the `ActiveListContent` which matches the value of the item based
2432 * on `===` equality. To the position of the item for which
2433 * the predicate returns `true`.
2434 *
2435 * When multiple items match on `===` only the first matching item is moved.
2436 *
2437 * If no item matches the predicate nothing is moved.
2438 *
2439 * The position to where the `ActiveListContent` moves can be altered by
2440 * providing a mode:
2441 *
2442 * 1. When the mode is 'at', the `ActiveListContent` is moved to the position
2443 * where the predicate matches. This is the `default` mode.
2444 *
2445 * 2. When the mode is 'after', the `ActiveListContent` is moved to after the
2446 * position where the predicate matches.
2447 *
2448 * 3. When the mode is 'before', the `ActiveListContent` is moved to before
2449 * the position where the predicate matches.
2450 *
2451 * @param {T} item The item to move.
2452 * @param {ActiveListContentPredicate<T>} predicate A predicate function, when the predicate returns `true` it will move the item to after that position.
2453 * @param {ActiveListPredicateOptions} options The options for the predicate, when no options are provided the mode will default to "at".
2454 * @throws {ActiveListItemNotFoundError} item must be in the contents array based on === equality
2455 *
2456 * @since 1.0.0
2457 */
2458 moveByPredicate(item: T, predicate: ActiveListContentPredicate<T>, options?: ActiveListPredicateOptions): void;
2459 /**
2460 * Gets the index for a given item.
2461 *
2462 * If the item does not exist in the content array it will
2463 * throw an error.
2464 *
2465 * @param {T} item The item to get the index for.
2466 * @returns {number} The index of the given item.
2467 * @throws {ActiveListItemNotFoundError} item must be in the contents array based on === equality
2468 *
2469 * @since 1.0.0
2470 */
2471 getIndex(item: T): number;
2472 /**
2473 * Returns the final index available in the contents array.
2474 *
2475 * @returns {number} The last index of the contents array.
2476 *
2477 * @since 1.0.0
2478 */
2479 getLastIndex(): number;
2480 _getBoundedNextIndex(index: number): number;
2481 _getBoundedPreviousIndex(index: number): number;
2482 _getUnboundedNextIndex(index: number): number;
2483 _getUnboundedPreviousIndex(index: number): number;
2484 /**
2485 * Whether or not the contents is an empty array.
2486 *
2487 * @since 1.0.0
2488 */
2489 isEmpty(): boolean;
2490 private _getDirectionWhenMovingToIndex;
2491 private _repairContents;
2492 private _repairContent;
2493 private _emptyLastActives;
2494 private _emptyLastDeactivated;
2495 private _becameEmpty;
2496 private _setLastActives;
2497 private _deactivateContent;
2498 private _execPred;
2499 _inform(event: ActiveListEvent<T>): void;
2500 private _checkIndex;
2501 private _modeToMod;
2502}
2503
2504/**
2505 * The configuration for the `createActiveListSubscriber` function.
2506 *
2507 * You should provide all methods for the events that you want to
2508 * listen to, the ones you are not interested
2509 *
2510 * @since 1.5.0
2511 */
2512type CreateActiveListSubscriberConfig<T> = {
2513 /**
2514 * Optionally whether or not you want to show debug logging.
2515 *
2516 * When `debug` is enabled whenever an event method is not provided
2517 * but the event is fired, a `console.warn` message is logged. This
2518 * allows you to easier detect missing methods during development.
2519 *
2520 * Defaults to `false`, meaning nothing will be logged to the console.
2521 *
2522 * @since 1.5.0
2523 */
2524 debug?: boolean;
2525 /**
2526 * Method which is called whenever an `MOVED` event is fired
2527 * from within the ActiveList.
2528 *
2529 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2530 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2531 * @since 1.5.0
2532 */
2533 onMoved?: (event: ActiveListMovedEvent<T>, activeList: ActiveList<T>) => void;
2534 /**
2535 * Method which is called whenever an `INSERTED` event is fired
2536 * from within the ActiveList.
2537 *
2538 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2539 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2540 * @since 1.5.0
2541 */
2542 onInserted?: (event: ActiveListInsertedEvent<T>, activeList: ActiveList<T>) => void;
2543 /**
2544 * Method which is called whenever an `INITIALIZED` event is fired
2545 * from within the ActiveList.
2546 *
2547 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2548 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2549 * @since 1.5.0
2550 */
2551 onInitialized?: (event: ActiveListInitializedEvent<T>, activeList: ActiveList<T>) => void;
2552 /**
2553 * Method which is called whenever an `COOLDOWN_STARTED` event is
2554 * fired from within the ActiveList.
2555 *
2556 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2557 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2558 * @since 1.5.0
2559 */
2560 onCooldownStarted?: (event: ActiveListCooldownStartedEvent, activeList: ActiveList<T>) => void;
2561 /**
2562 * Method which is called whenever an `COOLDOWN_ENDED` event is
2563 * fired from within the ActiveList.
2564 *
2565 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2566 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2567 * @since 1.5.0
2568 */
2569 onCooldownEnded?: (event: ActiveListCooldownEndedEvent, activeList: ActiveList<T>) => void;
2570 /**
2571 * Method which is called whenever an `AUTO_PLAY_STOPPED` event is
2572 * fired from within the ActiveList.
2573 *
2574 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2575 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2576 * @since 1.5.0
2577 */
2578 onAutoPlayStopped?: (event: ActiveListAutoPlayStoppedEvent, activeList: ActiveList<T>) => void;
2579 /**
2580 * Method which is called whenever an `AUTO_PLAY_PLAYING` event is
2581 * fired from within the ActiveList.
2582 *
2583 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2584 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2585 * @since 1.5.0
2586 */
2587 onAutoPlayPlaying?: (event: ActiveListAutoPlayPlayingEvent, activeList: ActiveList<T>) => void;
2588 /**
2589 * Method which is called whenever an `AUTO_PLAY_PAUSED` event is fired
2590 * from within the ActiveList.
2591 *
2592 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2593 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2594 * @since 1.5.0
2595 */
2596 onAutoPlayPaused?: (event: ActiveListAutoPlayPausedEvent, activeList: ActiveList<T>) => void;
2597 /**
2598 * Method which is called whenever an `ACTIVATED_MULTIPLE` event is fired
2599 * from within the ActiveList.
2600 *
2601 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2602 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2603 * @since 1.5.0
2604 */
2605 onActivatedMultiple?: (event: ActiveListActivatedMultipleEvent<T>, activeList: ActiveList<T>) => void;
2606 /**
2607 * Method which is called whenever an `ACTIVATED` event is fired
2608 * from within the ActiveList.
2609 *
2610 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2611 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2612 * @since 1.5.0
2613 */
2614 onActivated?: (event: ActiveListActivatedEvent<T>, activeList: ActiveList<T>) => void;
2615 /**
2616 * Method which is called whenever an `DEACTIVATED_MULTIPLE` event is fired
2617 * from within the ActiveList.
2618 *
2619 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2620 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2621 * @since 1.5.0
2622 */
2623 onDeactivatedMultiple?: (event: ActiveListDeactivatedMultipleEvent<T>, activeList: ActiveList<T>) => void;
2624 /**
2625 * Method which is called whenever an `DEACTIVATED` event is fired
2626 * from within the ActiveList.
2627 *
2628 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2629 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2630 * @since 1.5.0
2631 */
2632 onDeactivated?: (event: ActiveListDeactivatedEvent<T>, activeList: ActiveList<T>) => void;
2633 /**
2634 * Method which is called whenever an `SWAPPED` event is fired
2635 * from within the ActiveList.
2636 *
2637 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2638 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2639 * @since 1.5.0
2640 */
2641 onSwapped?: (event: ActiveListSwappedEvent<T>, activeList: ActiveList<T>) => void;
2642 /**
2643 * Method which is called whenever an `REMOVED` event is fired
2644 * from within the ActiveList.
2645 *
2646 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2647 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2648 * @since 1.5.0
2649 */
2650 onRemoved?: (event: ActiveListRemovedEvent<T>, activeList: ActiveList<T>) => void;
2651 /**
2652 * Method which is called whenever an `REMOVED_MULTIPLE` event is fired
2653 * from within the ActiveList.
2654 *
2655 * @param {ActiveListMovedEvent<T>} event The event that was fired.
2656 * @param {ActiveList<T>} activeList The ActiveList the event was fired from
2657 * @since 1.5.0
2658 */
2659 onRemovedMultiple?: (event: ActiveListRemovedMultipleEvent<T>, activeList: ActiveList<T>) => void;
2660};
2661/**
2662 * A function that creates an `ActiveListSubscriber` which you can
2663 * provide to an `ActiveList`, which maps all `ActiveListEvent` to
2664 * methods.
2665 *
2666 * You provide `createActiveListSubscriber` with an object with all
2667 * the events you want to handle as methods and it will call the
2668 * methods for you. This way your code will not have any switch or
2669 * if-statement to distinguish between events.
2670 *
2671 * For example if you wanted to handle the `ACTIVATED` event, you
2672 * provide a method called `onActivated` within the config. Whenever
2673 * the `ACTIVATED` event occurs `onActivated` will be called.
2674 *
2675 * All methods are called with two parameters: the first is the
2676 * `event` that occurred and the second the `ActiveList` the event
2677 * occurred on.
2678 *
2679 * `createActiveListSubscriber` should only be used when using
2680 * Vanilla JavaScript or TypeScript and not when using a reactive
2681 * framework because reactive frameworks (such as React or Vue) will
2682 * handle the DOM manipulation for you.
2683 *
2684 * If an event is fired that you did not provide a method for,
2685 * an `SubscriberMissingMethodError` error will be thrown.
2686 *
2687 * @param {CreateActiveListSubscriberConfig<T>} config An object containing all methods you want to listen to.
2688 * @returns {ActiveListSubscriber<T>} A subscriber function which can be passed to an ActiveList.
2689 * @since 1.5.0
2690 *
2691 * @example
2692 * A. Simple example
2693 *
2694 * The example below shows what the subscriber could look like for
2695 * a carousel component which has one slide active at a time.
2696 *
2697 * ```js
2698 * import {
2699 * ActiveList,
2700 * createActiveListSubscriber
2701 * } from "uiloos/core";
2702 *
2703 * const carouselSubscriber = createActiveListSubscriber({
2704 * onActivated() {
2705 * // Activate the active slide
2706 * activeList.lastDeactivated.classList.remove('active');
2707 *
2708 * // Deactivates the last activated slide
2709 * activeList.lastActivated.classList.add('active');
2710 * },
2711 * });
2712 *
2713 * const activeList = new ActiveList({
2714 * // The slide div elements are the contents of the ActiveList
2715 * contents: Array.from(document.querySelectorAll('.carousel .slide'))
2716 * }, carouselSubscriber)
2717 * ```
2718 *
2719 * @example
2720 * B. All methods implemented
2721 *
2722 * Here is a nice example to get started which includes stub
2723 * implementations for all method:
2724 *
2725 * ```js
2726 * const subscriber = createActiveListSubscriber({
2727 * onInitialized(event, activeList) {
2728 * console.log('onInitialized', event, activeList);
2729 * },
2730 *
2731 * onActivated(event, activeList) {
2732 * console.log('onActivated', event, activeList);
2733 * },
2734 *
2735 * onDeactivated(event, activeList) {
2736 * console.log('onDeactivated', event, activeList);
2737 * },
2738 *
2739 * onInserted(event, activeList) {
2740 * console.log('onInserted', event, activeList);
2741 * },
2742 *
2743 * onRemoved(event, activeList) {
2744 * console.log('onRemoved', event, activeList);
2745 * },
2746 *
2747 * onSwapped(event, activeList) {
2748 * console.log('onSwapped', event, activeList);
2749 * },
2750 *
2751 * onMoved(event, activeList) {
2752 * console.log('onMoved', event, activeList);
2753 * },
2754 *
2755 * onCooldownStarted(event, activeList) {
2756 * console.log('onCooldownStarted', event, activeList);
2757 * },
2758 *
2759 * onCooldownEnded(event, activeList) {
2760 * console.log('onCooldownEnded', event, activeList);
2761 * },
2762 *
2763 * onAutoPlayStopped(event, activeList) {
2764 * console.log('onAutoPlayStopped', event, activeList);
2765 * },
2766 *
2767 * onAutoPlayPlaying(event, activeList) {
2768 * console.log('onAutoPlayPlaying', event, activeList);
2769 * },
2770 *
2771 * onAutoPlayPaused(event, activeList) {
2772 * console.log('onAutoPlayPaused', event, activeList);
2773 * },
2774 *
2775 * onActivatedMultiple(event, activeList) {
2776 * console.log('onActivatedMultiple', event, activeList);
2777 * },
2778 *
2779 * onDeactivatedMultiple(event, activeList) {
2780 * console.log('onDeactivatedMultiple', event, activeList);
2781 * },
2782 *
2783 * onRemovedMultiple(event, activeList) {
2784 * console.log('onRemovedMultiple', event, activeList);
2785 * },
2786 * });
2787 * ```
2788 */
2789declare function createActiveListSubscriber<T>(config: CreateActiveListSubscriberConfig<T>): ActiveListSubscriber<T>;
2790
2791/**
2792 * Error which is thrown whenever the ActiveList is in
2793 * `ActiveListMaxActivationLimitBehavior` mode `error`, when the
2794 * `maxActivationLimit` is exceeded.
2795 *
2796 * @since 1.0.0
2797 */
2798declare class ActiveListActivationLimitReachedError extends Error {
2799 /**
2800 * ActiveListActivationLimitReachedError constructor
2801 *
2802 * @since 1.0.0
2803 */
2804 constructor();
2805}
2806
2807/**
2808 * Error which is thrown whenever the autoPlay duration is zero or
2809 * less than zero.
2810 *
2811 * @since 1.0.0
2812 */
2813declare class ActiveListAutoPlayDurationError extends Error {
2814 /**
2815 * ActiveListAutoPlayDurationError constructor
2816 *
2817 * @since 1.0.0
2818 */
2819 constructor();
2820}
2821
2822/**
2823 * Error which is thrown whenever the cooldown duration is zero or
2824 * less than zero.
2825 *
2826 * WARNING: when this error is thrown because a
2827 * `ActiveListCooldownDurationCallback` callback function returned a
2828 * negative or zero duration, the activation / deactivation will still
2829 * have occurred! This error is considered a developer error on your
2830 * part and you should prevent it, as the ActiveList is now invalid.
2831 *
2832 * @since 1.0.0
2833 */
2834declare class ActiveListCooldownDurationError extends Error {
2835 /**
2836 * ActiveListCooldownDurationError constructor
2837 *
2838 * @since 1.0.0
2839 */
2840 constructor();
2841}
2842
2843/**
2844 * Error which is thrown whenever an index is out of bounds.
2845 *
2846 * @since 1.0.0
2847 */
2848declare class ActiveListIndexOutOfBoundsError extends Error {
2849 /**
2850 * ActiveListIndexOutOfBoundsError constructor
2851 *
2852 * @since 1.0.0
2853 */
2854 constructor(message: string);
2855}
2856
2857/**
2858 * Error which is thrown whenever an item cannot be found in the
2859 * `ActiveList` contents array based on '===' equality.
2860 *
2861 * @since 1.0.0
2862 */
2863declare class ActiveListItemNotFoundError extends Error {
2864 /**
2865 * ActiveListItemNotFoundError constructor
2866 *
2867 * @since 1.0.0
2868 */
2869 constructor();
2870}
2871
2872/**
2873 * A ViewChannel is a class which represents an area on the screen
2874 * which contains visual elements (views) which are visible for a
2875 * certain amount of time, or until when the user performs a certain
2876 * action.
2877 *
2878 * The `ViewChannel` can be used to implement multiple types of
2879 * components:
2880 *
2881 * 1. A notification side bar in which the user sees notifications
2882 * of the application for a limited amount of time.
2883 *
2884 * 2. A flash message area which contain messages that tell the user
2885 * an action was successful or not. They disappear after a certain
2886 * amount of time, or when the user clicks on them.
2887 *
2888 * 3. A modal: a window / frame which appears when the user must
2889 * perform a specific action. The modal closes when the user
2890 * either performs the action, or when the user cancels the
2891 * action.
2892 *
2893 * 4. A confirmation dialog: a small window / frame which appears
2894 * asking the user if they are sure they want to perform a
2895 * certain action.
2896 *
2897 * The general idea is that often areas on the screen exists which
2898 * contain contain a specific type of visual element. These elements
2899 * are often presented (triggered) from code at a distance from the
2900 * area they are displayed in. This is why `ViewChannel` is considered
2901 * a "channel", it is a way of transporting views.
2902 *
2903 * This way you can have one part of the code consume the channel,
2904 * and use it to simply display the views, and many places (in code)
2905 * where you put views on the channel.
2906 *
2907 * The idea of the ViewChannel is that you instantiate one for each
2908 * type of View you want to support, for example: you might have a
2909 * flash message and a modal ViewChannel instance. Then you use these
2910 * instances to send "views" to the channel.
2911 *
2912 * The ViewChannel also has a concept of "priority". Sometimes one
2913 * view has more priority than another view. The ViewChannel will
2914 * make sure that the views are sorted by priority. The higher the
2915 * priority the earlier in the `views` array the view is placed.
2916 * This makes the ViewChannel a priority queue like data structure.
2917 *
2918 * @since 1.0.0
2919 */
2920declare class ViewChannel<T, R = void> implements Observable<ViewChannel<T, R>, ViewChannelEvent<T, R>> {
2921 /**
2922 * The `ViewChannelView` instances which the `ViewChannel` holds.
2923 *
2924 * @since 1.0.0
2925 */
2926 readonly views: ViewChannelView<T, R>[];
2927 private _history;
2928 /**
2929 * Contains the history of the changes in the views array.
2930 *
2931 * Tracks 8 types of changes:
2932 *
2933 * 1. INITIALIZED: fired when ViewChannel is initialized.
2934 *
2935 * 2. PRESENTED: fired when ViewChannel presented a ViewChannelView.
2936 *
2937 * 3. DISMISSED: fired when ViewChannel dismissed a ViewChannelView.
2938 *
2939 * 4. DISMISSED_ALL: fired when ViewChannel dismisses all ViewChannelView's.
2940 *
2941 * 5. AUTO_DISMISS_PLAYING: fired when ViewChannelView started to
2942 * play after a stop or pause.
2943 *
2944 * 6. AUTO_DISMISS_PAUSED: fired when a ViewChannelView auto
2945 * dismiss was paused.
2946 *
2947 * 7. AUTO_DISMISS_STOPPED: fired when a ViewChannelView auto
2948 * dismiss was stopped.
2949 *
2950 * 8. DATA_CHANGED: fired when a ViewChannelView data is changed.
2951 *
2952 * Goes only as far back as configured in the `Config` property
2953 * `keepHistoryFor`, to prevent an infinitely growing history.
2954 * Note that by default no history is kept, as `keepHistoryFor`
2955 * is zero by default.
2956 *
2957 * The last item in the `history` is the current active item. The
2958 * further to the left the further in the past you go.
2959 *
2960 * This means that a history at index 0 is further in the past than
2961 * an item at index 1.
2962 *
2963 * @since 1.0.0
2964 */
2965 history: ViewChannelEvent<T, R>[];
2966 private _observer;
2967 /**
2968 * Creates an ViewChannel based on the ViewChannelConfig config.
2969 *
2970 * You can also optionally provide an subscriber so you can get
2971 * informed of the changes happening to the ViewChannel.
2972 *
2973 * @param {ViewChannelConfig<T>} config The initial configuration of the ViewChannel.
2974 * @param {ViewChannelSubscriber<T> | undefined} subscriber An optional subscriber which responds to changes in the ViewChannel.
2975 *
2976 * @since 1.0.0
2977 */
2978 constructor(config?: ViewChannelConfig, subscriber?: ViewChannelSubscriber<T, R>);
2979 /**
2980 * Initializes the ViewChannel based on the config provided.
2981 *
2982 * This effectively resets the ViewChannel when called, including
2983 * the history.
2984 *
2985 * @param {ViewChannelConfig<T>} config The new configuration which will override the old one
2986 *
2987 * @since 1.0.0
2988 */
2989 initialize(config: ViewChannelConfig): void;
2990 /**
2991 * Subscribe to changes of the ViewChannel. The function you
2992 * provide will get called whenever changes occur in the
2993 * ViewChannel.
2994 *
2995 * Returns an unsubscribe function which when called will unsubscribe
2996 * from the ViewChannel.
2997 *
2998 * @param {ViewChannelSubscriber<T>} subscriber The subscriber which responds to changes in the ViewChannel.
2999 * @returns {UnsubscribeFunction} A function which when called will unsubscribe from the ViewChannel.
3000 *
3001 * @since 1.0.0
3002 */
3003 subscribe(subscriber: ViewChannelSubscriber<T, R>): UnsubscribeFunction;
3004 /**
3005 * Unsubscribe the subscriber so it no longer receives changes / updates
3006 * of the state changes of the ViewChannel.
3007 *
3008 * @param {ViewChannelSubscriber<T>} subscriber The subscriber which you want to unsubscribe.
3009 *
3010 * @since 1.0.0
3011 */
3012 unsubscribe(subscriber: ViewChannelSubscriber<T, R>): void;
3013 /**
3014 * Unsubscribes all subscribers at once, all subscribers will no
3015 * longer receives changes / updates of the state changes of
3016 * the ViewChannel.
3017 *
3018 * @since 1.5.0
3019 */
3020 unsubscribeAll(): void;
3021 /**
3022 * Takes the provided `ViewChannelViewConfig` turns it into a
3023 * `ViewChannelView`, and places the `ViewChannelView` into the
3024 * `views` array based on the priority given.
3025 *
3026 * @param {ViewChannelConfig<T, R>} viewConfig The configuration for the view which is presented and returned.
3027 * @returns {ViewChannelView<R>} The view which was presented
3028 * @throws {ViewChannelAutoDismissDurationError} autoDismiss duration must be a positive number when defined
3029 *
3030 * @since 1.0.0
3031 */
3032 present(viewConfig: ViewChannelViewConfig<T, R>): ViewChannelView<T, R>;
3033 _doRemoveByIndex(index: number, result: R, reason: ViewChannelViewDismissedEventReason): void;
3034 /**
3035 * Dismisses the `ViewChannelView` which resides at the index of
3036 * the `views` array, with the given result.
3037 *
3038 * The result (R) is the value with which the promise of the
3039 * `ViewChannelView` will be resolved. For example when making a
3040 * confirmation dialog, you could set the result to `"CONFIRM"` when
3041 * the user presses the confirm button, and set the result to
3042 * `"CANCEL"` when the user either presses the cancel button, or
3043 * clicks outside of the dialog.
3044 *
3045 * If the index does not exist an error will be thrown.
3046 *
3047 * @param {number} index The index of the ViewChannelView to dismiss
3048 * @param {R} result The value to resolve the promise of the ViewChannelView with.
3049 * @throws {ViewChannelIndexOutOfBoundsError} index cannot be out of bounds
3050 * @since 1.0.0
3051 */
3052 dismissByIndex(index: number, result: R): void;
3053 /**
3054 * Dismisses the `ViewChannelView` with the given result.
3055 *
3056 * The result (R) is the value with which the promise of the
3057 * `ViewChannelView` will be resolved. For example when making a
3058 * confirmation dialog, you could set the result to `"CONFIRM"` when
3059 * the user presses the confirm button, and set the result to
3060 * `"CANCEL"` when the user either presses the cancel button, or
3061 * clicks outside of the dialog.
3062 *
3063 * Note: if the `ViewChannelView` `isPresented` is `false` the
3064 * removal is ignored.
3065 *
3066 * Note: if the `ViewChannelView` does not exist in the views array it
3067 * will throw an error.
3068 *
3069 * @param {ViewChannelView<T, R>} view The ViewChannelView to dismiss
3070 * @param {R} result The value to resolve the promise of the ViewChannelView with.
3071 * @throws {ViewChannelNotFoundError} item must be in the views array based on === equality
3072 * @since 1.0.0
3073 */
3074 dismiss(view: ViewChannelView<T, R>, result: R): void;
3075 /**
3076 * Dismisses all `ViewChannelView`s within this `ViewChannel` with
3077 * the given result.
3078 *
3079 * The result (R) is the value with which the promise of all the
3080 * `ViewChannelView` will be resolved with . For example when making
3081 * a notifications bar, you could set the result to `"CLEARED"` when
3082 * the user presses the a "clear all" button.
3083 *
3084 * Note: when there are no ViewChannelViews displayed (in the views
3085 * array) calling dismissAll will result in nothing happening.
3086 *
3087 * @param {R} result The value to resolve the promises of all the ViewChannelViews within the ViewChannel.
3088 * @since 1.0.0
3089 */
3090 dismissAll(result: R): void;
3091 /**
3092 * Changes the data of the given ViewChannelView, and informs
3093 * the subscribers of the change.
3094 *
3095 * Note: if you provide the exact same `data` it will still set the
3096 * `data` and inform the subscribers, even though nothing has
3097 * actually changed.
3098 *
3099 * This way, when `data` is an object or an array, you can mutate
3100 * the object / array directly, and pass in the same `data` object
3101 * to the `changeData`, without having to create copies.
3102 *
3103 * @param {number} index The index of the ViewChannelView to change the data for.
3104 * @param {T} data The new data for the ViewChannelView
3105 * @throws {ViewChannelIndexOutOfBoundsError} index cannot be out of bounds
3106 * @since 1.6.0
3107 */
3108 changeDataByIndex(index: number, data: T): void;
3109 /**
3110 * Changes the data of the given ViewChannelView, and informs
3111 * the subscribers of the change.
3112 *
3113 * Note: if you provide the exact same `data` it will still set the
3114 * `data` and inform the subscribers, even though nothing has
3115 * actually changed.
3116 *
3117 * This way, when `data` is an object or an array, you can mutate
3118 * the object / array directly, and pass in the same `data` object
3119 * to the `changeData`, without having to create copies.
3120 *
3121 * @param {ViewChannelView<T, R>} view The ViewChannelView to change the data for
3122 * @param {T} data The new data for the ViewChannelView
3123 * @throws {ViewChannelNotFoundError} item must be in the views array based on === equality
3124 * @since 1.6.0
3125 */
3126 changeData(view: ViewChannelView<T, R>, data: T): void;
3127 private _getIndexForPriority;
3128 private _getPriorityAtLevel;
3129 private _repairIndexes;
3130 private _clearViews;
3131 _inform(event: ViewChannelEvent<T, R>): void;
3132}
3133
3134/**
3135 * Configures the initial state of the `ViewChannel`.
3136 *
3137 * @since 1.0.0
3138 */
3139type ViewChannelConfig = {
3140 /**
3141 * For how many items the `history` may contain in the `ViewChannel`.
3142 *
3143 * Defaults to `0` meaning that it will not track history.
3144 *
3145 * @since 1.0.0
3146 */
3147 keepHistoryFor?: number;
3148};
3149/**
3150 * Represents the configuration for AutoDismiss. AutoDismiss means
3151 * that the ViewChannelView will remove itself after a duration.
3152 *
3153 * @since 1.0.0
3154 */
3155type ViewChannelViewAutoDismissConfig<R> = {
3156 /**
3157 * The amount of milliseconds the view should remain visible to
3158 * the user. Once the duration has passed the view is removed
3159 * from the `ViewChannel` automatically.
3160 *
3161 * @since 1.0.0
3162 */
3163 duration: number;
3164 /**
3165 * The value (R) to resolve the promise of the `ViewChannelView`
3166 * with. This allows you to distinguish between user events,
3167 * such as clicking a cancel / save button or an auto dismissal.
3168 *
3169 * @since 1.0.0
3170 */
3171 result: R;
3172};
3173/**
3174 * AutoDismiss means that the ViewChannelView will dismiss itself
3175 * after a duration.
3176 *
3177 * Contains wether or not the autoDismiss is playing via `isPlaying`
3178 * and the current duration via `duration`.
3179 *
3180 * @since 1.0.0
3181 */
3182type ViewChannelViewAutoDismiss = {
3183 /**
3184 * Whether or not the ViewChannelView is playing. In other words
3185 * whether or not the ViewChannelView is going to be autoDismissed
3186 * after a duration.
3187 *
3188 * @since 1.0.0
3189 */
3190 isPlaying: boolean;
3191 /**
3192 * The amount of milliseconds the view should remain visible to
3193 * the user. Once the duration has passed the view is removed
3194 * from the `ViewChannel` automatically.
3195 *
3196 * This duration is the duration for when the ViewChannelView
3197 * started playing. It is not affected by calling pause, meaning
3198 * that when the duration is set to 200ms and you pause after
3199 * 100ms, the duration will still be 200ms.
3200 *
3201 * When calling `stop`, or when the ViewChannelView is dismissed
3202 * the duration will be set to zero.
3203 *
3204 * @since 1.0.0
3205 */
3206 duration: number;
3207};
3208/**
3209 * Holds the configuration of a view which is placed in the
3210 * `ViewChannel`. From this configuration the actual
3211 * `ViewChannelView` is created.
3212 *
3213 * @since 1.0.0
3214 */
3215type ViewChannelViewConfig<T, R> = {
3216 /**
3217 * The data for the presented view, "data" can be be anything from
3218 * an object, string, array etc etc. It is used to pass along data
3219 * to the view you might need to display the view, such as the
3220 * text for a flash message or confirmation dialog.
3221 *
3222 * By default the value is `undefined`.
3223 *
3224 * @since 1.0.0
3225 */
3226 data: T;
3227 /**
3228 * Whether or not `autoDismiss` is enabled. When `autoDismiss` is
3229 * enabled it will dismiss the view, based on the `duration`.
3230 *
3231 * Defaults to no autoDismiss, meaning it will stay visible forever,
3232 * until it is dismissed.
3233 *
3234 * @since 1.0.0
3235 */
3236 autoDismiss?: ViewChannelViewAutoDismissConfig<R>;
3237 /**
3238 * The priority the `ViewChannelView` will have within the
3239 * `ViewChannel`. The lower the priority the closer it will be to
3240 * the start of the `ViewChannel` views array.
3241 *
3242 * A priority is expressed as an array of numbers, each index in the
3243 * array represents a "level" in the priority, the earlier levels
3244 * (the lower indexes) have higher priority over the later levels
3245 * (the higher indexes).
3246 *
3247 * If two priorities are compared, first the level at index zero
3248 * is compared, if they are the same the index at the second level
3249 * is compared, if the second level is also the same the third
3250 * level is compared, and so on and so on until there are no more
3251 * levels.
3252 *
3253 * A couple examples:
3254 *
3255 * 1. [0, 0, 0] has a higher priority than [1, 0, 0]
3256 *
3257 * 2. [1, 0, 0] has a higher priority than [2, 0, 0]
3258 *
3259 * 3. [0, 0, 0] has a higher priority than [0, 1, 0]
3260 *
3261 * 4. [0, 1, 0] has a higher priority than [0, 2, 0]
3262 *
3263 * 5. [0, 0, 0] has a higher priority than [0, 0, 1]
3264 *
3265 * 6. [0, 0, 1] has a higher priority than [0, 0, 2]
3266 *
3267 * 7. [0, 0, 1] has a higher priority than [1, 0, 0]
3268 *
3269 * If the priority arrays when compared differ in size, the missing
3270 * items are considered zeros. So for example:
3271 *
3272 * 1. [0] has a higher priority than [1, 0, 0]
3273 *
3274 * 2. [0, 0] has a higher priority than [0, 1, 1]
3275 *
3276 * If two priorities match exactly the view is placed after the
3277 * existing view with the same priority. This means that the
3278 * order will be the order of insertion.
3279 *
3280 * Note: you can provide a number instead of an array instead, in
3281 * this case an array is created with the provided number as the
3282 * first value in the array. So providing `5` will be treated as
3283 * `[5]`.
3284 *
3285 * Defaults to `[0]` when no priority is given, this makes it the
3286 * highest priority.
3287 *
3288 * @since 1.0.0
3289 */
3290 priority?: number | number[];
3291};
3292/**
3293 * The subscriber which is informed of all state changes the
3294 * ViewChannel goes through.
3295 *
3296 * @param {ViewChannel<T, R>} viewChannel The ViewChannel which had changes.
3297 * @param {ViewChannelEvent<T>} event The event that occurred.
3298 *
3299 * @since 1.0.0
3300 */
3301type ViewChannelSubscriber<T, R> = (viewChannel: ViewChannel<T, R>, event: ViewChannelEvent<T, R>) => void;
3302/**
3303 * Represents whether the `ViewChannelEvent` was presented, dismissed
3304 * or initialized.
3305 *
3306 * @since 1.0.0
3307 */
3308type ViewChannelEventType = 'INITIALIZED' | 'PRESENTED' | 'DISMISSED' | 'DISMISSED_ALL' | 'AUTO_DISMISS_PLAYING' | 'AUTO_DISMISS_PAUSED' | 'AUTO_DISMISS_STOPPED' | 'DATA_CHANGED';
3309/**
3310 * Represents an event which happened in the ViewChannel. Based
3311 * on the `type` you can determine which event occurred.
3312 *
3313 * @since 1.0.0
3314 */
3315type ViewChannelBaseEvent = {
3316 /**
3317 * Which event occurred
3318 *
3319 * @since 1.0.0
3320 */
3321 type: ViewChannelEventType;
3322 /**
3323 * The time the event occurred on as a Date object.
3324 *
3325 * @since 1.0.0
3326 */
3327 time: Date;
3328};
3329/**
3330 * Represents the initialization of the ViewChannel
3331 *
3332 * @since 1.0.0
3333 */
3334type ViewChannelInitializedEvent = ViewChannelBaseEvent & {
3335 /**
3336 * Which type occurred
3337 *
3338 * @since 1.0.0
3339 */
3340 type: 'INITIALIZED';
3341};
3342/**
3343 * Represents an insertion of a ViewChannelView into the ViewChannel.
3344 *
3345 * @since 1.0.0
3346 */
3347type ViewChannelViewPresentedEvent<T, R> = ViewChannelBaseEvent & {
3348 /**
3349 * Which type occurred
3350 *
3351 * @since 1.0.0
3352 */
3353 type: 'PRESENTED';
3354 /**
3355 * The view which was inserted.
3356 *
3357 * Note: this was the view at the time of insertion, it might
3358 * currently be removed, so be aware that this view might no
3359 * longer be displayed in the `ViewChannel`.
3360 *
3361 * @since 1.0.0
3362 */
3363 view: ViewChannelView<T, R>;
3364 /**
3365 * The index of the insertion.
3366 *
3367 * Note: this was the index at the time of the insertion, it might
3368 * no longer be accurate.
3369 *
3370 * @since 1.0.0
3371 */
3372 index: number;
3373};
3374/**
3375 * The reason for dismissal, this can either be because the
3376 * `duration` of the view passed, in which case it is
3377 * `DURATION_PASSED`, or because the user closed the View, then
3378 * the reason will be `USER_INTERACTION`.
3379 *
3380 * @since 1.0.0
3381 */
3382type ViewChannelViewDismissedEventReason = 'AUTO_DISMISS' | 'USER_INTERACTION';
3383/**
3384 * Represents a dismissal of an ViewChannelView of the ViewChannel.
3385 *
3386 * Note: when this event is fired the "AUTO_DISMISS_STOPPED" event
3387 * will not be fired even when autoDismiss is playing. The reason for
3388 * this is because on "DISMISSED" the entire view should be cleared.
3389 *
3390 * @since 1.0.0
3391 */
3392type ViewChannelViewDismissedEvent<T, R> = ViewChannelBaseEvent & {
3393 /**
3394 * Which type occurred
3395 *
3396 * @since 1.0.0
3397 */
3398 type: 'DISMISSED';
3399 /**
3400 * The reason for dismissal, this can either be because the
3401 * `duration` of the view passed, in which case it is
3402 * `DURATION_PASSED`, or because the user closed the View, then
3403 * the reason will be `USER_INTERACTION`.
3404 *
3405 * @since 1.0.0
3406 */
3407 reason: ViewChannelViewDismissedEventReason;
3408 /**
3409 * The view which was removed.
3410 *
3411 * @since 1.0.0
3412 */
3413 view: ViewChannelView<T, R>;
3414 /**
3415 * The index of removed item.
3416 *
3417 * Note: this was the index at the time of the dismissal, it might
3418 * no longer be accurate.
3419 *
3420 * @since 1.0.0
3421 */
3422 index: number;
3423};
3424/**
3425 * Represents an dismissal of all ViewChannelViews of the ViewChannel.
3426 *
3427 * @since 1.0.0
3428 */
3429type ViewChannelViewDismissedAllEvent<T, R> = ViewChannelBaseEvent & {
3430 /**
3431 * Which type occurred
3432 *
3433 * @since 1.0.0
3434 */
3435 type: 'DISMISSED_ALL';
3436 /**
3437 * The views which were removed.
3438 *
3439 * @since 1.0.0
3440 */
3441 views: ViewChannelView<T, R>[];
3442 /**
3443 * The indexes of the dismissed views.
3444 *
3445 * Note: there are the indexes at the time of the dismissal, it might
3446 * no longer be accurate.
3447 *
3448 * @since 1.0.0
3449 */
3450 indexes: number[];
3451};
3452/**
3453 * Represents a ViewChannelView autoDismiss being restarted again
3454 * when it was stopped or paused.
3455 *
3456 * Note: this event is not fired when a ViewChannelView is presented
3457 * initially, even though this does start the autoDismiss.
3458 *
3459 * @since 1.0.0
3460 */
3461type ViewChannelViewAutoDismissPlayingEvent<T, R> = ViewChannelBaseEvent & {
3462 /**
3463 * Which type occurred
3464 *
3465 * @since 1.0.0
3466 */
3467 type: 'AUTO_DISMISS_PLAYING';
3468 /**
3469 * The view which had its auto dismiss started / played.
3470 *
3471 * @since 1.0.0
3472 */
3473 view: ViewChannelView<T, R>;
3474 /**
3475 * The index of the view which had its auto dismiss started /
3476 * played.
3477 *
3478 * Note: this was the index at the time of playing, it might no
3479 * longer be accurate.
3480 *
3481 * @since 1.0.0
3482 */
3483 index: number;
3484};
3485/**
3486 * Represents a ViewChannelView autoDismiss being paused of the given
3487 * ViewChannel.
3488 *
3489 * @since 1.0.0
3490 */
3491type ViewChannelViewAutoDismissPausedEvent<T, R> = ViewChannelBaseEvent & {
3492 /**
3493 * Which type occurred
3494 *
3495 * @since 1.0.0
3496 */
3497 type: 'AUTO_DISMISS_PAUSED';
3498 /**
3499 * The view which had its auto dismiss paused.
3500 *
3501 * @since 1.0.0
3502 */
3503 view: ViewChannelView<T, R>;
3504 /**
3505 * The index of the view which had its auto dismiss paused.
3506 *
3507 * Note: this was the index at the time of pausing, it might no
3508 * longer be accurate.
3509 *
3510 * @since 1.0.0
3511 */
3512 index: number;
3513};
3514/**
3515 * Represents a ViewChannelView autoDismiss being stopped of the given
3516 * ViewChannel.
3517 *
3518 * @since 1.0.0
3519 */
3520type ViewChannelViewAutoDismissStoppedEvent<T, R> = ViewChannelBaseEvent & {
3521 /**
3522 * Which type occurred
3523 *
3524 * @since 1.0.0
3525 */
3526 type: 'AUTO_DISMISS_STOPPED';
3527 /**
3528 * The view which had its auto dismiss stopped.
3529 *
3530 * @since 1.0.0
3531 */
3532 view: ViewChannelView<T, R>;
3533 /**
3534 * The index of the view which had its auto dismiss stopped.
3535 *
3536 * Note: this was the index at the time of stopping, it might no
3537 * longer be accurate.
3538 *
3539 * @since 1.0.0
3540 */
3541 index: number;
3542};
3543/**
3544 * Represents a changing of the data of a ViewChannelView
3545 *
3546 * @since 1.6.0
3547 */
3548type ViewChannelViewDataChangedEvent<T, R> = ViewChannelBaseEvent & {
3549 /**
3550 * Which type occurred
3551 *
3552 * @since 1.6.0
3553 */
3554 type: 'DATA_CHANGED';
3555 /**
3556 * The views which had its data changed
3557 *
3558 * @since 1.6.0
3559 */
3560 view: ViewChannelView<T, R>;
3561 /**
3562 * The new data for the ViewChannelView
3563 *
3564 * @since 1.6.0
3565 */
3566 data: T;
3567 /**
3568 * The index of the view which had its data changed
3569 *
3570 * Note: this was the index at the time of changing, it might no
3571 * longer be accurate.
3572 *
3573 * @since 1.6.0
3574 */
3575 index: number;
3576};
3577/**
3578 * A ViewChannelEvent represents an event happened in the ViewChannel.
3579 * For example the presented and dismissal of the ViewChannelView.
3580 *
3581 * @since 1.0.0
3582 */
3583type ViewChannelEvent<T, R> = ViewChannelInitializedEvent | ViewChannelViewPresentedEvent<T, R> | ViewChannelViewDismissedEvent<T, R> | ViewChannelViewDismissedAllEvent<T, R> | ViewChannelViewAutoDismissPlayingEvent<T, R> | ViewChannelViewAutoDismissPausedEvent<T, R> | ViewChannelViewAutoDismissStoppedEvent<T, R> | ViewChannelViewDataChangedEvent<T, R>;
3584
3585/**
3586 * A ViewChannelView is a class which represents visual elements which
3587 * are visible for a certain amount of time, or until when the user
3588 * performs a certain action.
3589 *
3590 * For example:
3591 *
3592 * 1. A notification, a piece of text telling the user some event
3593 * happened within the application.
3594 *
3595 * 2. A flash message, a small temporary message telling the user
3596 * an action was successful or failed. They disappear after a
3597 * certain amount of time, or when the user clicks on them.
3598 *
3599 * 3. A modal: a window / frame which appears when the user must
3600 * perform a specific action. The modal closes when the user
3601 * either performs the action, or when the user cancels the
3602 * action.
3603 *
3604 * 4. A confirmation dialog: a small window / frame which appears
3605 * asking the user if they are sure they want to perform a
3606 * certain action.
3607 *
3608 * A ViewChannelView is always tied to a ViewChannel in which it
3609 * appears.
3610 *
3611 * You should never instantiate a `ViewChannelView` directly, instead
3612 * you should call `present` on the `ViewChannel` and provide a
3613 * `ViewChannelViewConfig` from which the `ViewChannelView` is
3614 * instantiated.
3615 *
3616 * @since 1.0.0
3617 */
3618declare class ViewChannelView<T, R> {
3619 /**
3620 * Whether or not this ViewChannelView is presented.
3621 *
3622 * @since 1.0.0
3623 */
3624 isPresented: boolean;
3625 /**
3626 * Reference to the ViewChannel is it a part of.
3627 *
3628 * @since 1.0.0
3629 */
3630 viewChannel: ViewChannel<T, R>;
3631 /**
3632 * The index of the `ViewChannelView` which it has within the `contents`.
3633 *
3634 * @since 1.0.0
3635 */
3636 index: number;
3637 /**
3638 * The data for the presented view, "data" can be be anything from
3639 * an object, string, array etc etc. It is used to pass along data
3640 * to the view you might need to display the view, such as the
3641 * text for a flash message or confirmation dialog.
3642 *
3643 * By default the value is `undefined`.
3644 *
3645 * @since 1.0.0
3646 */
3647 data: T;
3648 /**
3649 * The priority the `ViewChannelView` will have within the
3650 * `ViewChannel` the lower the priority the closer it will be
3651 * to the start of the `ViewChannel` content array.
3652 *
3653 * @since 1.0.0
3654 */
3655 priority: number[];
3656 /**
3657 * Whether or not `autoDismiss` is enabled. When `autoDismiss` is
3658 * enabled it will dismiss the view, based on the `duration`.
3659 *
3660 * Defaults to no autoDismiss, meaning it will stay visible forever,
3661 * until it is dismissed.
3662 *
3663 * @since 1.0.0
3664 */
3665 private _autoDismiss;
3666 /**
3667 * AutoDismiss means that the ViewChannelView will dismiss itself
3668 * after a duration.
3669 *
3670 * Contains whether or not the autoDismiss is playing via `isPlaying`
3671 * and the current duration via `duration`.
3672 *
3673 * @since 1.0.0
3674 */
3675 readonly autoDismiss: ViewChannelViewAutoDismiss;
3676 /**
3677 * A promise which will be resolved with the result (R) when this
3678 * ViewChannelView is dismissed. This promise will never be rejected
3679 * only resolved.
3680 *
3681 * For example when making a confirmation dialog, you could set the
3682 * result to `"CONFIRM"` when the user presses the confirm button,
3683 * and set the result to `"CANCEL"` when the user either presses the
3684 * cancel button, or clicks outside of the dialog.
3685 *
3686 * This allows you to `await` for the promise to be fulfilled, and
3687 * take the result an perform actions based on that result.
3688 *
3689 * Note: this promise might never get resolved if "dismiss" is
3690 * never called.
3691 *
3692 * @since 1.0.0
3693 */
3694 result: Promise<R>;
3695 _resolve: (result: R | PromiseLike<R>) => void;
3696 /**
3697 * Creates an ViewChannelView which belongs to the given ViewChannel.
3698 *
3699 * Note: you should never create instances of ViewChannelView yourself. You
3700 * are supposed to let ViewChannel do this for you.
3701 *
3702 * @param {ViewChannel<T, R>} viewChannel The ViewChannel this ViewChannelView belongs to.
3703 * @param {number} index The index of this ViewChannelView within the ViewChannel.
3704 * @param {T} data The data of this ViewChannelView.
3705 * @param {number} priority The priority this ViewChannelView has within the ViewChannel
3706 * @param {ViewChannelViewAutoDismissConfig<R>} autoDismiss Whether or not this ViewChannelView is auto dismissed after a duration.
3707 *
3708 * @since 1.0.0
3709 */
3710 constructor(viewChannel: ViewChannel<T, R>, index: number, data: T, priority: number[], autoDismissConfig?: ViewChannelViewAutoDismissConfig<R>);
3711 /**
3712 * Dismisses the `ViewChannelView` with the given result.
3713 *
3714 * The result (R) is the value with which the promise of the
3715 * `ViewChannelView` will be resolved. For example when making a
3716 * confirmation dialog, you could set the result to `"CONFIRM"` when
3717 * the user presses the confirm button, and set the result to
3718 * `"CANCEL"` when the user either presses the cancel button, or
3719 * clicks outside of the dialog.
3720 *
3721 * Note: if the `ViewChannelView` property `isPresented` is `false`
3722 * the removal is ignored.
3723 *
3724 * Note: if the `ViewChannelView` does not exist in the views array it
3725 * will throw an error.
3726 *
3727 * @param {number} index The index of the ViewChannelView to dismiss
3728 * @param {R} result The value to resolve the promise of the ViewChannelView with.
3729 * @throws {ViewChannelNotFoundError} item must be in the views array based on === equality
3730 * @since 1.0.0
3731 */
3732 dismiss(result: R): void;
3733 /**
3734 * Will resume auto dismissing the ViewChannelView based on the
3735 * active autoDismiss. When `autoDismiss` is not defined nothing
3736 * will happen when calling play.
3737 *
3738 * Important: you only need to call `play` yourself when also using
3739 * either `pause` or `stop`, as `play` is called automatically when
3740 * a view is presented.
3741 *
3742 * @throws {ViewChannelAutoDismissDurationError} autoDismiss duration must be a positive number when defined
3743 *
3744 * @since 1.0.0
3745 */
3746 play(): void;
3747 /**
3748 * When the ViewChannelView is playing it will pause the
3749 * autoDismiss.
3750 *
3751 * When paused, the current autoDismiss duration is remember and
3752 * resumed from that position, when `play` is called again.
3753 *
3754 * For example: when the duration is 1 second and the `pause` is
3755 * called after 0.8 seconds, it will after `play` is called, take
3756 * 0.2 seconds to dismiss this view.
3757 *
3758 * Note: if the autoDismiss is already paused calling `pause` again
3759 * will do nothing, the time used for the remaining duration is
3760 * based on the first pause.
3761 *
3762 * @since 1.0.0
3763 */
3764 pause(): void;
3765 /**
3766 * When the ViewChannelView is playing it will stop the autoDismiss.
3767 *
3768 * By calling `play` again it is possible to restart the autoDismiss.
3769 * However the duration will behave in this scenario as it if was
3770 * reset.
3771 *
3772 * For example: when the duration is 1 second and the `stop` is
3773 * called after 0.8 seconds, it will after `play` is called, take
3774 * 1 second to dismiss this view.
3775 *
3776 * @since 1.0.0
3777 */
3778 stop(): void;
3779 /**
3780 * Changes the data of this ViewChannelView, and informs the
3781 * subscribers of the change.
3782 *
3783 * Note: if you provide the exact same `data` it will still set the
3784 * `data` and inform the subscribers, even though nothing has
3785 * actually changed.
3786 *
3787 * This way, when `data` is an object or an array, you can mutate
3788 * the object / array directly, and pass in the same `data` object
3789 * to the `changeData`, without having to create copies.
3790 *
3791 *
3792 * @param {T} data The new data for this ViewChannelView
3793 * @since 1.6.0
3794 */
3795 changeData(data: T): void;
3796}
3797
3798/**
3799 * Error which is thrown whenever an index is out of bounds.
3800 *
3801 * @since 1.0.0
3802 */
3803declare class ViewChannelIndexOutOfBoundsError extends Error {
3804 /**
3805 * ViewChannelIndexOutOfBoundsError constructor
3806 *
3807 * @since 1.0.0
3808 */
3809 constructor(method: string);
3810}
3811
3812/**
3813 * Error which is thrown whenever the `ViewChannelView` was not found
3814 * inside of the `views` array of the `ViewChannel`.
3815 *
3816 * @since 1.0.0
3817 */
3818declare class ViewChannelViewNotFoundError extends Error {
3819 /**
3820 * ViewChannelViewNotFoundError constructor
3821 *
3822 * @since 1.0.0
3823 */
3824 constructor(method: string);
3825}
3826
3827/**
3828 * Error which is thrown whenever the autoDismiss duration is zero or
3829 * less than zero.
3830 *
3831 * @since 1.0.0
3832 */
3833declare class ViewChannelAutoDismissDurationError extends Error {
3834 /**
3835 * ViewChannelAutoDismissDurationError constructor
3836 *
3837 * @since 1.0.0
3838 */
3839 constructor();
3840}
3841
3842/**
3843 * The configuration for the `createViewChannelSubscriber` function.
3844 *
3845 * You should provide all methods for the events that you want to
3846 * listen to, the ones you are not interested
3847 *
3848 * @since 1.5.0
3849 */
3850type CreateViewChannelSubscriberConfig<T, R> = {
3851 /**
3852 * Optionally whether or not you want to show debug logging.
3853 *
3854 * When `debug` is enabled whenever an event method is not provided
3855 * but the event is fired, a `console.warn` message is logged. This
3856 * allows you to easier detect missing methods during development.
3857 *
3858 * Defaults to `false`, meaning nothing will be logged to the console.
3859 *
3860 * @since 1.5.0
3861 */
3862 debug?: boolean;
3863 /**
3864 * Method which is called whenever an `INITIALIZED` event is fired
3865 * from within the ViewChannel.
3866 *
3867 * @param {ViewChannelInitializedEvent} event The event that was fired.
3868 * @param {ViewChannel<T, R>} viewChannel The ViewChannel the event was fired from
3869 * @since 1.5.0
3870 */
3871 onInitialized?: (event: ViewChannelInitializedEvent, viewChannel: ViewChannel<T, R>) => void;
3872 /**
3873 * Method which is called whenever an `PRESENTED` event is fired
3874 * from within the ViewChannel.
3875 *
3876 * @param {ViewChannelViewPresentedEvent<T, R>} event The event that was fired.
3877 * @param {ViewChannel<T, R>} viewChannel The ViewChannel the event was fired from
3878 * @since 1.5.0
3879 */
3880 onPresented?: (event: ViewChannelViewPresentedEvent<T, R>, viewChannel: ViewChannel<T, R>) => void;
3881 /**
3882 * Method which is called whenever an `DISMISSED` event is fired
3883 * from within the ViewChannel.
3884 *
3885 * @param {ViewChannelViewDismissedEvent<T, R>} event The event that was fired.
3886 * @param {ViewChannel<T, R>} viewChannel The ViewChannel the event was fired from
3887 * @since 1.5.0
3888 */
3889 onDismissed?: (event: ViewChannelViewDismissedEvent<T, R>, viewChannel: ViewChannel<T, R>) => void;
3890 /**
3891 * Method which is called whenever an `DISMISSED_ALL` event is fired
3892 * from within the ViewChannel.
3893 *
3894 * @param {ViewChannelViewDismissedAllEvent<T, R>} event The event that was fired.
3895 * @param {ViewChannel<T, R>} viewChannel The ViewChannel the event was fired from
3896 * @since 1.5.0
3897 */
3898 onDismissedAll?: (event: ViewChannelViewDismissedAllEvent<T, R>, viewChannel: ViewChannel<T, R>) => void;
3899 /**
3900 * Method which is called whenever an `AUTO_DISMISS_PLAYING` event is fired
3901 * from within the ViewChannel.
3902 *
3903 * @param {ViewChannelViewAutoDismissPlayingEvent<T, R>} event The event that was fired.
3904 * @param {ViewChannel<T, R>} viewChannel The ViewChannel the event was fired from
3905 * @since 1.5.0
3906 */
3907 onAutoDismissPlaying?: (event: ViewChannelViewAutoDismissPlayingEvent<T, R>, viewChannel: ViewChannel<T, R>) => void;
3908 /**
3909 * Method which is called whenever an `AUTO_DISMISS_PAUSED` event is fired
3910 * from within the ViewChannel.
3911 *
3912 * @param {ViewChannelViewAutoDismissPausedEvent<T, R>} event The event that was fired.
3913 * @param {ViewChannel<T, R>} viewChannel The ViewChannel the event was fired from
3914 * @since 1.5.0
3915 */
3916 onAutoDismissPaused?: (event: ViewChannelViewAutoDismissPausedEvent<T, R>, viewChannel: ViewChannel<T, R>) => void;
3917 /**
3918 * Method which is called whenever an `AUTO_DISMISS_STOPPED` event is fired
3919 * from within the ViewChannel.
3920 *
3921 * @param {ViewChannelViewAutoDismissStoppedEvent<T, R>} event The event that was fired.
3922 * @param {ViewChannel<T, R>} viewChannel The ViewChannel the event was fired from
3923 * @since 1.5.0
3924 */
3925 onAutoDismissStopped?: (event: ViewChannelViewAutoDismissStoppedEvent<T, R>, viewChannel: ViewChannel<T, R>) => void;
3926 /**
3927 * Method which is called whenever an `DATA_CHANGED` event is fired
3928 * from within the ViewChannel.
3929 *
3930 * @param {ViewChannelViewDataChangedEvent<T, R>} event The event that was fired.
3931 * @param {ViewChannel<T, R>} viewChannel The ViewChannel the event was fired from
3932 * @since 1.5.0
3933 */
3934 onDataChanged?: (event: ViewChannelViewDataChangedEvent<T, R>, viewChannel: ViewChannel<T, R>) => void;
3935};
3936/**
3937 * A function that creates an `ViewChannelSubscriber` which you can
3938 * provide to an `ViewChannel`, which maps all `ViewChannelEvent` to
3939 * methods.
3940 *
3941 * You provide `createViewChannelSubscriber` with an object with all
3942 * the events you want to handle as methods and it will call the
3943 * methods for you. This way your code will not have any switch or
3944 * if-statement to distinguish between events.
3945 *
3946 * For example if you wanted to handle the `DISMISSED` event, you
3947 * provide a method called `onDismissed` within the config. Whenever
3948 * the `DISMISSED` event occurs `onDismissed` will be called.
3949 *
3950 * All methods are called with two parameters: the first is the
3951 * `event` that occurred and the second the `ViewChannel` the event
3952 * occurred on.
3953 *
3954 * `createViewChannelSubscriber` should only be used when using
3955 * Vanilla JavaScript or TypeScript and not when using a reactive
3956 * framework because reactive frameworks (such as React or Vue) will
3957 * handle the DOM manipulation for you.
3958 *
3959 * If an event is fired that you did not provide a method for,
3960 * an `SubscriberMissingMethodError` error will be thrown.
3961 *
3962 * @param {CreateViewChannelSubscriberConfig<T>} config An object containing all methods you want to listen to.
3963 * @returns {ViewChannelSubscriber<T>} A subscriber function which can be passed to an ViewChannel.
3964 * @since 1.5.0
3965 *
3966 * @example
3967 * A. Simple example
3968 *
3969 * The example below shows what the subscriber could look like for
3970 * a modal channel which presents and dismisses modal windows.
3971 *
3972 * ```js
3973 * import {
3974 * ViewChannel,
3975 * createViewChannelSubscriber
3976 * } from 'uiloos/core';
3977 *
3978 * const subscriber = createViewChannelSubscriber({
3979 * onPresented() {
3980 * // Show the view here
3981 * },
3982 *
3983 * onDismissed() {
3984 * // Hide the view here
3985 * },
3986 * });
3987 *
3988 * export const modalChannel = new ViewChannel(
3989 * {},
3990 * subscriber
3991 * );
3992 * ```
3993 *
3994 * @example
3995 * B. All methods implemented
3996 *
3997 * Here is a nice example to get started which includes stub
3998 * implementations for all method:
3999 *
4000 * ```js
4001 * const subscriber = createViewChannelSubscriber({
4002 * onInitialized(event, viewChannel) {
4003 * console.log('onInitialized', event, viewChannel);
4004 * },
4005 *
4006 * onPresented(event, viewChannel) {
4007 * console.log('onPresented', event, viewChannel);
4008 * },
4009 *
4010 * onDismissed(event, viewChannel) {
4011 * console.log('onDismissed', event, viewChannel);
4012 * },
4013 *
4014 * onDismissedAll(event, viewChannel) {
4015 * console.log('onDismissedAll', event, viewChannel);
4016 * },
4017 *
4018 * onAutoDismissPlaying(event, viewChannel) {
4019 * console.log('onAutoDismissPlaying', event, viewChannel);
4020 * },
4021 *
4022 * onAutoDismissPaused(event, viewChannel) {
4023 * console.log('onAutoDismissPaused', event, viewChannel);
4024 * },
4025 *
4026 * onAutoDismissStopped(event, viewChannel) {
4027 * console.log('onAutoDismissStopped', event, viewChannel);
4028 * },
4029 *
4030 * onDataChanged(event, viewChannel) {
4031 * console.log('onDataChanged', event, viewChannel);
4032 * },
4033 * });
4034 * ```
4035 */
4036declare function createViewChannelSubscriber<T, R>(config: CreateViewChannelSubscriberConfig<T, R>): ViewChannelSubscriber<T, R>;
4037
4038/**
4039 * Represents a cursor within a Typewriter.
4040 *
4041 * Note: when `initialize` is called on a `Typewriter` all cursors
4042 * are reset, and the previously attached cursors become detached,
4043 * this means that the positions of the cursors are no longer
4044 * accurate.
4045 *
4046 * You should never instantiate a `TypewriterCursor` directly. It
4047 * should always be given to you by the `Typewriter`.
4048 *
4049 * @since 1.2.0
4050 */
4051declare class TypewriterCursor<T> {
4052 private _typewriter;
4053 /**
4054 * The position of the cursor within the `Typewriter` text.
4055 *
4056 * If the cursor also has a `selection`, the `position` will always
4057 * either on the `start` or `end` of the `selection`.
4058 *
4059 * Note: when `initialize` is called on a `Typewriter` all cursors
4060 * become detached, and the position is no longer accurate.
4061 *
4062 * @since 1.2.0
4063 */
4064 position: number;
4065 /**
4066 * The data for the cursor, "data" can be be anything from an
4067 * object, string, array etc etc. The idea is that you can store
4068 * any information here you need to render the cursor. For example
4069 * you could set the data to an object, containing the "name" and
4070 * "color" for that cursor.
4071 *
4072 * By default the value is `undefined`.
4073 *
4074 * @since 1.2.0
4075 */
4076 data?: T;
4077 /**
4078 * The range of positions which this cursor has selected, or when
4079 * it is `undefined` signifying no selection.
4080 *
4081 * The `position` of a cursors is always either on the `start` or
4082 * `end` of the `selection`.
4083 *
4084 * Note: whenever the cursor stops selecting text the selection
4085 * will be turned into `undefined`. So be careful not to keep any
4086 * references to selections.
4087 *
4088 * @since 1.2.0
4089 */
4090 selection?: TypewriterCursorSelection;
4091 /**
4092 * Whether or not this cursor is blinking.
4093 *
4094 * A cursor does not blink when the user is typing, only when the
4095 * user has stopped typing then after a little while the cursor
4096 * will start blinking again.
4097 *
4098 * The time until the cursors blinks again is the `Typewriter`'s
4099 * `blinkAfter` property.
4100 *
4101 * @since 1.2.0
4102 */
4103 isBlinking: boolean;
4104 private _blinkTimeoutId;
4105 /**
4106 * Creates an TypewriterCursor which belongs to the given Typewriter.
4107 *
4108 * Note: you should never create instances of TypewriterCursor
4109 * yourself. You are supposed to let the Typewriter do this for you.
4110 *
4111 * @param {Typewriter<T>} typewriter The Typewriter this TypewriterCursor belongs to.
4112 * @param {number} position The position of this TypewriterCursor within the Typewriter text.
4113 * @param {T} data The data for this TypewriterCursor
4114 * @param {selection} selection The selection of the TypewriterCursor
4115 *
4116 * @since 1.2.0
4117 */
4118 constructor(typewriter: Typewriter<T>, position: number, data?: T, selection?: TypewriterCursorSelection);
4119 _startBlink(): void;
4120 _clearBlink(): void;
4121}
4122
4123/**
4124 * Represents the selection of a cursor. A selection has a `start`
4125 * and and `end` which are both numbers representing two positions
4126 * within a `Typewriter`'s `text` property.
4127 *
4128 * The `start` will always lie before the `end`.
4129 *
4130 * The `position` of a cursors is always either on the `start` or
4131 * `end` of the `selection`.
4132 *
4133 * @since 1.2.0
4134 */
4135type TypewriterCursorSelection = {
4136 /**
4137 * The start position of the selection.
4138 *
4139 * @since 1.2.0
4140 */
4141 start: number;
4142 /**
4143 * The end position of the selection.
4144 *
4145 * @since 1.2.0
4146 */
4147 end: number;
4148};
4149/**
4150 * Configures the initial state of the `TypewriterCursor`.
4151 *
4152 * @since 1.2.0
4153 */
4154type TypewriterCursorConfig<T> = {
4155 /**
4156 * The position of the cursor within the `Typewriter` text.
4157 *
4158 * @since 1.2.0
4159 */
4160 position: number;
4161 /**
4162 * The data for the cursor, "data" can be be anything from an
4163 * object, string, array etc etc. The idea is that you can store
4164 * any information here you need to render the cursor. For example
4165 * you could set the data to an object, containing the "name" and
4166 * "color" for that cursor.
4167 *
4168 * By default the value is `undefined`.
4169 *
4170 * @since 1.2.0
4171 */
4172 data?: T;
4173 /**
4174 * The range of positions which this cursor has selected.
4175 *
4176 * Defaults to undefined, meaning no selection has been made.
4177 *
4178 * @since 1.2.0
4179 */
4180 selection?: TypewriterCursorSelection;
4181};
4182/**
4183 * Configures the initial state of the `Typewriter`.
4184 *
4185 * @since 1.2.0
4186 */
4187type TypewriterConfig<T> = {
4188 /**
4189 * The cursors the `Typewriter` is going to have.
4190 *
4191 * Defaults to one cursor at the end of the provided `text`
4192 * with an empty name.
4193 *
4194 * @since 1.2.0
4195 */
4196 cursors?: TypewriterCursorConfig<T>[];
4197 /**
4198 * The actions this `Typewriter` is set to enter. Each stroke
4199 * represents a key press on the Typewriter. A stroke can add
4200 * or remove characters, or move the cursor.
4201 *
4202 * Defaults to an empty array, meaning no actions will be made.
4203 *
4204 * @since 1.2.0
4205 */
4206 actions?: TypewriterAction[];
4207 /**
4208 * The initial text the `Typewriter` starts with.
4209 *
4210 * Defaults to '' meaning that the Typewriter will not have an
4211 * initial text.
4212 *
4213 * @since 1.2.0
4214 */
4215 text?: string;
4216 /**
4217 * The time it takes until a cursor starts blinking again after
4218 * the cursor was used.
4219 *
4220 * A cursor does not blink when it is used until after a certain
4221 * time. So if you keep typing the cursor does not blink, until
4222 * you stop typing for some "predefined amount" of time.
4223 *
4224 * The `blinkAfter` is what represents that 'predefined amount' of
4225 * time, you can also say this is a debounce time.
4226 *
4227 * Note: when you set the `blinkAfter` to a number lower or equal to
4228 * the `delay` of a `TypewriterAction`, it will negate the debounce.
4229 * The effect is that all "CHANGED" events will have a "BLINKING"
4230 * event. This might not "visually" affect your animation, but
4231 * will make the `Typewriter` send extra events. If this happens it
4232 * is technically as "misconfiguration" on your part, but the
4233 * Typewriter will not throw any errors, since visually nothing
4234 * bad happens.
4235 *
4236 * Defaults to after `250` milliseconds.
4237 *
4238 * @since 1.2.0
4239 */
4240 blinkAfter?: number;
4241 /**
4242 * For how many items the `history` may contain in the `Typewriter`.
4243 *
4244 * Defaults to `0` meaning that it will not track history.
4245 *
4246 * @since 1.2.0
4247 */
4248 keepHistoryFor?: number;
4249 /**
4250 * Whether or not the animation will immediately start playing.
4251 *
4252 * When `true` the animation will start playing immediately, when
4253 * `false` the animation will start when `play()` is called.
4254 *
4255 * Note: the animation will only start playing when there are
4256 * actions defined.
4257 *
4258 * Defaults to `true` meaning that the animation will play instantly.
4259 *
4260 * @since 1.2.0
4261 */
4262 autoPlay?: boolean;
4263 /**
4264 * Whether or not this animation repeats and how often.
4265 *
4266 * There are three ways to define `repeat`.
4267 *
4268 * 1. When `repeat` is `false` or `1` it will never repeat the
4269 * animation, the animation will run only once.
4270 *
4271 * 2. When `repeat` is `true` it will repeat the animation forever.
4272 *
4273 * 3. When `repeat` is a number it will repeat the animation
4274 * for given number of times. If the number is 0 or a negative
4275 * number is provided a error occurs.
4276 *
4277 * Defaults to `false` meaning that the animation will run once.
4278 *
4279 * @since 1.2.0
4280 */
4281 repeat?: boolean | number;
4282 /**
4283 * The time in milliseconds the animation is paused in between
4284 * repeats.
4285 *
4286 * Defaults to `0` milliseconds, meaning an almost instant repeat.
4287 *
4288 * @since 1.2.0
4289 */
4290 repeatDelay?: number;
4291};
4292/**
4293 * The subscriber which is informed of all state changes the
4294 * Typewriter goes through.
4295 *
4296 * @param {Typewriter<T>} typewriter The Typewriter which had changes.
4297 * @param {TypewriterEvent<T>} event The event that occurred.
4298 *
4299 * @since 1.2.0
4300 */
4301type TypewriterSubscriber<T> = (typewriter: Typewriter<T>, event: TypewriterEvent<T>) => void;
4302/**
4303 * The type of action which occurred on the Typewriter, can either
4304 * be a keyboard press or a mouse click.
4305 *
4306 * @since 1.2.0
4307 */
4308type TypewriterActionType = 'mouse' | 'keyboard';
4309/**
4310 * Represents an action taken by the user can either be a key press,
4311 * or a mouse click.
4312 *
4313 * @since 1.2.0
4314 */
4315type BaseTypewriterAction = {
4316 /**
4317 * The time in milliseconds after the previous action to wait until
4318 * the action is performed.
4319 *
4320 * @since 1.2.0
4321 */
4322 delay: number;
4323 /**
4324 * The type of action which will be taken.
4325 *
4326 * @since 1.2.0
4327 */
4328 type: TypewriterActionType;
4329 /**
4330 * The cursor responsible for the action. Is the value
4331 * is the index of the cursor in the Typewriters cursors array.
4332 *
4333 * @since 1.2.0
4334 */
4335 cursor: number;
4336};
4337/**
4338 * Represents the user entering text via the keyboard.
4339 *
4340 * @since 1.2.0
4341 */
4342type TypewriterActionKeyboard = BaseTypewriterAction & {
4343 /**
4344 * The type signifying it is a keyboard event.
4345 *
4346 * @since 1.2.0
4347 */
4348 type: 'keyboard';
4349 /**
4350 * The string that was typed in, can either be a word or a single
4351 * character or a special symbol representing a special key on the
4352 * keyboard. There are six special keys:
4353 *
4354 * 1. A backspace represented by '⌫'. It will when nothing is
4355 * selected delete the previous character, and when the cursor
4356 * does have a selection, remove all characters in the selection.
4357 *
4358 * 2. 'Clear all' represented by '⎚', it clears the entire text.
4359 *
4360 * 3. The left arrow key represented by '←'. When nothing is
4361 * selected is will move the cursor one position to the left.
4362 * When a selection is made it will move the cursor to the start
4363 * of the selection.
4364 *
4365 * 4. The right arrow key represented by '→'. When nothing is
4366 * selected is will move the cursor one position to the right.
4367 * When a selection is made it will move the cursor to the end of
4368 * the selection.
4369 *
4370 * 5. Select left, represented by ⇧←', when repeated grows the
4371 * selection.
4372 *
4373 * 6. Select right, represented by ⇧→', when repeated grows the
4374 * selection.
4375 *
4376 * @since 1.2.0
4377 */
4378 text: string;
4379};
4380/**
4381 * Represents the user clicking somewhere in the text, moving
4382 * the cursor to the position.
4383 *
4384 * @since 1.2.0
4385 */
4386type TypewriterActionMouse = BaseTypewriterAction & {
4387 /**
4388 * The type signifying it is a mouse event.
4389 *
4390 * @since 1.2.0
4391 */
4392 type: 'mouse';
4393 /**
4394 * The position the mouse click moves the cursor to.
4395 *
4396 * @since 1.2.0
4397 */
4398 position: number;
4399 /**
4400 * Optionally the selection the mouse made when clicking.
4401 *
4402 * Normally there are two ways a someone can create selections with
4403 * a mouse: the first is clicking and dragging the mouse, the second
4404 * is double clicking on a word.
4405 *
4406 * The idea is that the `selection` covers the second use-case:
4407 * double clicking on a word. In the animation you will see the
4408 * selection happen instantly.
4409 *
4410 * For first use-case: mouse click selection, it is better to use
4411 * a keyboard event using `⇧←` or `⇧→`. This way you animate the
4412 * selection growing.
4413 *
4414 * @since 1.2.0
4415 */
4416 selection?: TypewriterCursorSelection;
4417};
4418/**
4419 * The type of action which occurred on the Typewriter, can either
4420 * be a keyboard press or a mouse click.
4421 *
4422 * @since 1.2.0
4423 */
4424type TypewriterAction = TypewriterActionMouse | TypewriterActionKeyboard;
4425/**
4426 * Represents whether the `TypewriterEvent` has changed the text,
4427 * is playing, stopped or paused.
4428 *
4429 * @since 1.2.0
4430 */
4431type TypewriterEventType = 'INITIALIZED' | 'CHANGED' | 'PLAYING' | 'PAUSED' | 'STOPPED' | 'FINISHED' | 'BLINKING' | 'REPEATING';
4432/**
4433 * Represents an event which happened in the Typewriter. Based on the
4434 * `type` you can determine which event occurred.
4435 *
4436 * @since 1.2.0
4437 */
4438type TypewriterBaseEvent = {
4439 /**
4440 * Which event occurred.
4441 *
4442 * @since 1.2.0
4443 */
4444 type: TypewriterEventType;
4445 /**
4446 * The time the event occurred on as a Date object.
4447 *
4448 * @since 1.2.0
4449 */
4450 time: Date;
4451};
4452/**
4453 * When you loop over a Typewriter, using a `for-of` statement, you
4454 * iterate over all positions in the Typewriters text. These positions
4455 * are represented by a `TypewriterPosition`.
4456 *
4457 * `TypewriterPosition` contains the character for that position,
4458 * the position (index) of that character, and all cursors currently
4459 * on the position. Lastly it will contain all cursors that have
4460 * selected the position.
4461 *
4462 * @since 1.2.0
4463 */
4464type TypewriterPosition<T> = {
4465 /**
4466 * The position of the 'character' in the text.
4467 *
4468 * IMPORTANT: in JavaScript some unicode characters have a length
4469 * bigger than 1. For example "😃".length is 2 not 1.
4470 *
4471 * The Typewriter "normalizes" these so all unicode characters have
4472 * a length of 1, by calling `Array.from(text)`.
4473 *
4474 * @since 1.2.0
4475 */
4476 position: number;
4477 /**
4478 * The character which is at this position in the text.
4479 *
4480 * @since 1.2.0
4481 */
4482 character: string;
4483 /**
4484 * The cursors that are on this position.
4485 *
4486 * @since 1.2.0
4487 */
4488 cursors: TypewriterCursor<T>[];
4489 /**
4490 * The cursors that have selected this position.
4491 *
4492 * @since 1.2.0
4493 */
4494 selected: TypewriterCursor<T>[];
4495};
4496/**
4497 * Represents the initialization of the Typewriter
4498 *
4499 * @since 1.2.0
4500 */
4501type TypewriterInitializedEvent = TypewriterBaseEvent & {
4502 /**
4503 * Which type occurred
4504 *
4505 * @since 1.2.0
4506 */
4507 type: 'INITIALIZED';
4508};
4509/**
4510 * Represents a change in the text of the typewriter, the moving
4511 * of a cursor, or a change in a cursors selection.
4512 *
4513 * This also means that the typewriter is no longer blinking at
4514 * this time, until the `BLINKING` event is triggered again.
4515 *
4516 * @since 1.2.0
4517 */
4518type TypewriterChangedEvent<T> = TypewriterBaseEvent & {
4519 /**
4520 * Which type occurred
4521 *
4522 * @since 1.2.0
4523 */
4524 type: 'CHANGED';
4525 /**
4526 * The action that happened which triggered this
4527 * `TypewriterChangedEvent`.
4528 *
4529 * @since 1.2.0
4530 */
4531 action: TypewriterAction;
4532 /**
4533 * The cursor which triggered the changed event
4534 *
4535 * @since 1.2.0
4536 */
4537 cursor: TypewriterCursor<T>;
4538};
4539/**
4540 * Represents that the Typewriter is currently playing.
4541 *
4542 * @since 1.2.0
4543 */
4544type TypewriterPlayingEvent = TypewriterBaseEvent & {
4545 /**
4546 * Which type occurred
4547 *
4548 * @since 1.2.0
4549 */
4550 type: 'PLAYING';
4551};
4552/**
4553 * Represents that the Typewriter is now paused.
4554 *
4555 * @since 1.2.0
4556 */
4557type TypewriterPausedEvent = TypewriterBaseEvent & {
4558 /**
4559 * Which type occurred
4560 *
4561 * @since 1.2.0
4562 */
4563 type: 'PAUSED';
4564};
4565/**
4566 * Represents that the Typewriter is was stopped.
4567 *
4568 * @since 1.2.0
4569 */
4570type TypewriterStoppedEvent = TypewriterBaseEvent & {
4571 /**
4572 * Which type occurred
4573 *
4574 * @since 1.2.0
4575 */
4576 type: 'STOPPED';
4577};
4578/**
4579 * Represents that the Typewriter has finished the animation.
4580 *
4581 * Important: finishing only refers to the fact that the 'text' will
4582 * no longer change, but a cursor might start blinking after the
4583 * animation is finished.
4584 *
4585 * Also when you call `play()` again the animation restarts,
4586 * for both these reasons "FINISHED" is not necessarily the last
4587 * event that will take place.
4588 *
4589 * @since 1.2.0
4590 */
4591type TypewriterFinishedEvent<T> = TypewriterBaseEvent & {
4592 /**
4593 * Which type occurred
4594 *
4595 * @since 1.2.0
4596 */
4597 type: 'FINISHED';
4598 /**
4599 * The action that happened which triggered this
4600 * `TypewriterFinishedEvent`.
4601 *
4602 * @since 1.2.0
4603 */
4604 action: TypewriterAction;
4605 /**
4606 * The cursor which triggered the finished event.
4607 *
4608 * @since 1.2.0
4609 */
4610 cursor: TypewriterCursor<T>;
4611};
4612/**
4613 * Represents that a Typewriters cursor should now be blinking.
4614 *
4615 * @since 1.2.0
4616 */
4617type TypewriterBlinkingEvent<T> = TypewriterBaseEvent & {
4618 /**
4619 * Which type occurred
4620 *
4621 * @since 1.2.0
4622 */
4623 type: 'BLINKING';
4624 /**
4625 * The cursor which has started blinking.
4626 *
4627 * @since 1.2.0
4628 */
4629 cursor: TypewriterCursor<T>;
4630};
4631/**
4632 * Represents that the Typewriters has started repeating the animation.
4633 *
4634 * @since 1.2.0
4635 */
4636type TypewriterRepeatingEvent<T> = TypewriterBaseEvent & {
4637 /**
4638 * Which type occurred
4639 *
4640 * @since 1.2.0
4641 */
4642 type: 'REPEATING';
4643 /**
4644 * The cursor which triggered the repeating event.
4645 *
4646 * @since 1.2.0
4647 */
4648 cursor: TypewriterCursor<T>;
4649};
4650/**
4651 * A TypewriterEvent represents an event happened in the Typewriter.
4652 * For example changing of the text or finishing the animation.
4653 *
4654 * @since 1.2.0
4655 */
4656type TypewriterEvent<T> = TypewriterInitializedEvent | TypewriterChangedEvent<T> | TypewriterPlayingEvent | TypewriterPausedEvent | TypewriterStoppedEvent | TypewriterFinishedEvent<T> | TypewriterBlinkingEvent<T> | TypewriterRepeatingEvent<T>;
4657
4658/**
4659 * A component to create versatile typewriter animations with.
4660 *
4661 * A typewriter animation is an type of text based animation in which
4662 * a piece of text is typed one letter at a time at a certain interval.
4663 *
4664 * Has support for: multiple cursors, cursor selection, mouse movement,
4665 * and keyboard movement.
4666 *
4667 * There are two main ways to create a typewriter animation:
4668 *
4669 * 1. By using the `typewriterFromSentences` function, it can create
4670 * single cursor animations from sentences (strings). It does do
4671 * by comparing and diffing the sentences and generating the
4672 * required keystrokes to go from one sentence to another.
4673 *
4674 * 2. You can use the typewriter composer, a web based tool to
4675 * generate the animations using your own keyboard.
4676 *
4677 * It can be found at:
4678 *
4679 * https://www.uiloos.dev/docs/typewriter/composer/
4680 *
4681 * @since 1.2.0
4682 */
4683declare class Typewriter<T = void> implements Observable<Typewriter<T>, TypewriterEvent<T>> {
4684 /**
4685 * The cursors the `Typewriter` has.
4686 *
4687 * @since 1.2.0
4688 */
4689 readonly cursors: TypewriterCursor<T>[];
4690 private readonly _originalCursors;
4691 /**
4692 * The actions which the `Typewriter` is going to perform.
4693 *
4694 * Basically the representation of the entire animation.
4695 *
4696 * The actions happen in a linear fashion, meaning the first item
4697 * in the array is chronologically the first action, and the last
4698 * item in the array the last action.
4699 *
4700 * @since 1.2.0
4701 */
4702 readonly actions: TypewriterAction[];
4703 /**
4704 * The last action that was performed by the Typewriter.
4705 *
4706 * Note: `lastPerformedAction` is not affected by repeats.
4707 *
4708 * @since 1.2.0
4709 */
4710 lastPerformedAction: TypewriterAction | null;
4711 /**
4712 * The current text of the `Typewriter` which it currently displays.
4713 *
4714 * For example if the actions are type in 'a' 3 times then a
4715 * backspace. The `text` would be the following, after each of
4716 * the 4 actions:
4717 *
4718 * 1. 'a'
4719 * 2. 'aa'
4720 * 3. 'aaa'
4721 * 4. 'aa'
4722 *
4723 * @since 1.2.0
4724 */
4725 text: string;
4726 private _originalText;
4727 /**
4728 * The time it takes until a cursor starts blinking again after
4729 * the cursor was used.
4730 *
4731 * A cursor does not blink when it is used until after a certain
4732 * time. So if you keep typing the cursor does not blink, until
4733 * you stop typing for some "predefined amount" of time.
4734 *
4735 * The `blinkAfter` is what represents that 'predefined amount' of
4736 * time, you can also say this is a debounce time.
4737 *
4738 * Note: when you set the `blinkAfter` to a number lower or equal to
4739 * the `delay` of a `TypewriterAction`, it will negate the debounce.
4740 * The effect is that all "CHANGED" events will have a "BLINKING"
4741 * event. This might not "visually" affect your animation, but
4742 * will make the `Typewriter` send extra events. If this happens it
4743 * is technically as "misconfiguration" on your part, but the
4744 * Typewriter will not throw any errors, since visually nothing
4745 * bad happens.
4746 *
4747 * Defaults to after `250` milliseconds.
4748 *
4749 * @since 1.2.0
4750 */
4751 blinkAfter: number;
4752 /**
4753 * Whether or not the `Typewriter` is currently playing.
4754 *
4755 * @since 1.2.0
4756 */
4757 isPlaying: boolean;
4758 private _stopped;
4759 /**
4760 * Whether or not the `Typewriter` has finished playing the entire
4761 * animation.
4762 *
4763 * Note: when `repeat` is configured as `true` the animation will
4764 * never finish.
4765 *
4766 * Note: when the `Typewriter` is initialized the `isFinished`
4767 * boolean will always be set to `false`, regardless of whether
4768 * or not there are any actions.
4769 *
4770 * @since 1.2.0
4771 */
4772 isFinished: boolean;
4773 /**
4774 * Whether or not this animation repeats and how often.
4775 *
4776 * There are three ways to define `repeat`.
4777 *
4778 * 1. When `repeat` is `false` or `1` it will never repeat the
4779 * animation, the animation will run only once.
4780 *
4781 * 2. When `repeat` is `true` it will repeat the animation forever.
4782 *
4783 * 3. When `repeat` is a number it will repeat the animation
4784 * for given number of times. If the number is 0 or a negative
4785 * number is provided a error occurs.
4786 *
4787 * Defaults to `false` meaning that the animation will run once.
4788 *
4789 * @since 1.2.0
4790 */
4791 repeat: boolean | number;
4792 /**
4793 * The time in milliseconds the animation is paused in between repeats.
4794 *
4795 * @since 1.2.0
4796 */
4797 repeatDelay: number;
4798 private _repeated;
4799 /**
4800 * Whether or not the Typewriter has been stopped at one point
4801 * before during the current animation.
4802 *
4803 * The `hasBeenStoppedBefore` is tied to the lifecycle of an
4804 * animation, and reflects if the current animation has been
4805 * stopped before or not.
4806 *
4807 * Whenever a new animation starts the `hasBeenStoppedBefore`
4808 * resets to `false`. An animation starts whenever `play()` is
4809 * called, or through autoPlay, and lasts until there are no
4810 * more actions, or `stop()` is called.
4811 *
4812 * Use case: say you are making an animation which has a stop button
4813 * to stop the animation. Say you also have another feature: a pause
4814 * whenever the user hovers over the typewriter animation. These two
4815 * features would cause a conflict:
4816 *
4817 * Whenever the mouse over happens you call `play()`, which negates
4818 * the `stop()`, causing the typewriter to play again.
4819 *
4820 * To fix this problem you should on the mouse over not call
4821 * `play()` whenever `hasBeenStoppedBefore` is `true`.
4822 *
4823 * `hasBeenStoppedBefore` is tied to the animation cycle so a user
4824 * clicks on the stop button, and then on the play button, the
4825 * hover on pause will work again. The hover now works only because
4826 * `hasBeenStoppedBefore` is now false.
4827 *
4828 * @since 1.2.0
4829 */
4830 hasBeenStoppedBefore: boolean;
4831 private _index;
4832 private _animationTimeoutId;
4833 private _tickStarted;
4834 private _pauseStarted;
4835 private _history;
4836 /**
4837 * Contains the history of the changes in the views array.
4838 *
4839 * Tracks 8 types of changes:
4840 *
4841 * 1. INITIALIZED: fired when Typewriter is initialized
4842 *
4843 * 2. CHANGED: fired when a change in the text of the typewriter
4844 * occurred, when a cursor moves, or a when a cursors selection
4845 * changes.
4846 *
4847 * 3. PLAYING: fired when play is called.
4848 *
4849 * 4. PAUSED: fired when pause is called.
4850 *
4851 * 5. STOPPED: fire when stop is called.
4852 *
4853 * 6. FINISHED: fired when the animation was finished. When the
4854 * Typewriter is configured to repeat indefinitely the FINISHED
4855 * event will never fire.
4856 *
4857 * 7. BLINKING: fired when one of the cursors started blinking.
4858 *
4859 * 8. REPEATING: fired when the animation starts repeating.
4860 *
4861 * Goes only as far back as configured in the `Config` property
4862 * `keepHistoryFor`, to prevent an infinitely growing history.
4863 * Note that by default no history is kept, as `keepHistoryFor`
4864 * is zero by default.
4865 *
4866 * The last item in the `history` is the current active item. The
4867 * further to the left the further in the past you go.
4868 *
4869 * This means that a history at index 0 is further in the past than
4870 * an item at index 1.
4871 *
4872 * @since 1.2.0
4873 */
4874 history: TypewriterEvent<T>[];
4875 private _observer;
4876 /**
4877 * Creates an Typewriter based on the TypewriterConfig config.
4878 *
4879 * You can also optionally provide an subscriber so you can get
4880 * informed of the changes happening to the Typewriter.
4881 *
4882 * @param {TypewriterConfig<T>} config The initial configuration of the Typewriter.
4883 * @param {TypewriterSubscriber<T> | undefined} subscriber An optional subscriber which responds to changes in the Typewriter.
4884 * @throws {TypewriterBlinkAfterError} blinkAfter duration must be a positive number
4885 * @throws {TypewriterDelayError} delay duration must be a positive number
4886 * @throws {TypewriterRepeatError} repeat must be a positive number
4887 * @throws {TypewriterRepeatDelayError} repeatDelay must be a positive number or zero
4888 * @throws {TypewriterRepeatDelayError} repeatDelay must be a positive number or zero
4889 * @throws {TypewriterCursorOutOfBoundsError} cursor must be in bounds of text
4890 * @throws {TypewriterCursorNotAtSelectionEdgeError} when cursor has a selection the cursor must be on edges of the selection
4891 * @throws {TypewriterCursorSelectionOutOfBoundsError} the start and end of the selection must be in bounds of the text
4892 * @throws {TypewriterCursorSelectionInvalidRangeError} the start of a selection must on or after the end of a selection
4893 * @throws {TypewriterActionUnknownCursorError} actions must use cursors that exist
4894 * @since 1.2.0
4895 */
4896 constructor(config?: TypewriterConfig<T>, subscriber?: TypewriterSubscriber<T>);
4897 /**
4898 * Initializes the Typewriter based on the config provided.
4899 *
4900 * This effectively resets the Typewriter when called,
4901 * including the history.
4902 *
4903 * @param {TypewriterConfig<T>} config The new configuration which will override the old one
4904 * @throws {TypewriterBlinkAfterError} blinkAfter duration must be a positive number
4905 * @throws {TypewriterDelayError} delay duration must be a positive number
4906 * @throws {TypewriterRepeatError} repeat must be a positive number
4907 * @throws {TypewriterRepeatDelayError} repeatDelay must be a positive number or zero
4908 * @throws {TypewriterRepeatDelayError} repeatDelay must be a positive number or zero
4909 * @throws {TypewriterCursorOutOfBoundsError} cursor must be in bounds of text
4910 * @throws {TypewriterCursorNotAtSelectionEdgeError} when cursor has a selection the cursor must be on edges of the selection
4911 * @throws {TypewriterCursorSelectionOutOfBoundsError} the start and end of the selection must be in bounds of the text
4912 * @throws {TypewriterCursorSelectionInvalidRangeError} the start of a selection must on or after the end of a selection
4913 * @throws {TypewriterActionUnknownCursorError} actions must use cursors that exist
4914 * @since 1.2.0
4915 */
4916 initialize(config: TypewriterConfig<T>): void;
4917 /**
4918 * Subscribe to changes of the Typewriter. The function you provide
4919 * will get called whenever changes occur in the Typewriter.
4920 *
4921 * Returns an unsubscribe function which when called will
4922 * unsubscribe from the Typewriter.
4923 *
4924 * @param {TypewriterSubscriber<T>} subscriber The subscriber which responds to changes in the Typewriter.
4925 * @returns {UnsubscribeFunction} A function which when called will unsubscribe from the Typewriter.
4926 *
4927 * @since 1.2.0
4928 */
4929 subscribe(subscriber: TypewriterSubscriber<T>): UnsubscribeFunction;
4930 /**
4931 * Unsubscribe the subscriber so it no longer receives changes / updates
4932 * of the state changes of the Typewriter.
4933 *
4934 * @param {TypewriterSubscriber<T>} subscriber The subscriber which you want to unsubscribe.
4935 *
4936 * @since 1.2.0
4937 */
4938 unsubscribe(subscriber: TypewriterSubscriber<T>): void;
4939 /**
4940 * Unsubscribes all subscribers at once, all subscribers will no
4941 * longer receives changes / updates of the state changes of
4942 * the Typewriter.
4943 *
4944 * @since 1.5.0
4945 */
4946 unsubscribeAll(): void;
4947 /**
4948 * When the Typewriter is paused or stopped it will start the
4949 * animation from that point. If the animation was finished calling
4950 * `play()` will restart the animation.
4951 *
4952 * When there are is no more animations the Typewriter will stop
4953 * automatically.
4954 *
4955 * Is called automatically when the Typewriter is instantiated
4956 * and there are `actions` configured and `autoPlay` is `true`.
4957 *
4958 * Note: the animation will only start when there are one or more
4959 * actions are defined.
4960 *
4961 * @since 1.2.0
4962 */
4963 play(): void;
4964 /**
4965 * When the Typewriter is playing it will pause the animation, as
4966 * if the person using the typewriter stops typing, this means that
4967 * the cursors will start blinking again.
4968 *
4969 * Calling `play()` again will continue the animation.
4970 *
4971 * For example: when the `pause` of the current `TypewriterAction`
4972 * is 1 second and the `pause` is called after 0.8 seconds, it will
4973 * after `play` is called, take 0.2 seconds to go to the next
4974 * action.
4975 *
4976 * @since 1.2.0
4977 */
4978 pause(): void;
4979 /**
4980 * When the Typewriter is playing it will stop the animation.
4981 *
4982 * Calling `play()` again will restart the animation.
4983 *
4984 * Note: this will keep the text of the Typewriter as is, util
4985 * `play()` is called again then the text will reset.
4986 *
4987 * Note: calling stop will also reset the number of repeats if
4988 * `repeat` was set to a number.
4989 *
4990 * @since 1.2.0
4991 */
4992 stop(): void;
4993 private _init;
4994 private _tick;
4995 private _clearAnimation;
4996 private _resetTandC;
4997 private _overlap;
4998 private _same;
4999 private _actionLorR;
5000 private _actionSLorR;
5001 private _change;
5002 _inform(event: TypewriterEvent<T>): void;
5003 /**
5004 * Iterates over the Typewriters text, and returns all positions in
5005 * the text. For each position you will be given a object of type:
5006 * `TypewriterPosition`, which contains all information about that
5007 * position, such as which cursors are on that position, and the
5008 * character on that position.
5009 *
5010 * When there is a cursor on the last position, you will receive an
5011 * additional `TypewriterPosition` which has an empty string for
5012 * the `character` field.
5013 *
5014 * IMPORTANT: in JavaScript some unicode characters have a length
5015 * bigger than 1. For example `"😃".length` is `2` not `1`.
5016 *
5017 * The Typewriter "normalizes" these so all unicode characters have
5018 * a length of 1, by calling `Array.from(text)`.
5019 *
5020 * This means that the `.length` of the `Typewriter.text` can differ
5021 * from the number of iterations you get from iterating over the
5022 * Typewriter!
5023 *
5024 * @returns {Iterator<TypewriterPosition<T>>} an iterator which yields TypewriterCursor and strings.
5025 * @since 1.2.0
5026 */
5027 [Symbol.iterator](): Iterator<TypewriterPosition<T>>;
5028}
5029
5030/**
5031 * The configuration for the `createTypewriterSubscriber` function.
5032 *
5033 * You should provide all methods for the events that you want to
5034 * listen to, the ones you are not interested
5035 *
5036 * @since 1.5.0
5037 */
5038type CreateTypewriterSubscriberConfig<T> = {
5039 /**
5040 * Optionally whether or not you want to show debug logging.
5041 *
5042 * When `debug` is enabled whenever an event method is not provided
5043 * but the event is fired, a `console.warn` message is logged. This
5044 * allows you to easier detect missing methods during development.
5045 *
5046 * Defaults to `false`, meaning nothing will be logged to the console.
5047 *
5048 * @since 1.5.0
5049 */
5050 debug?: boolean;
5051 /**
5052 * Method which is called whenever an `INITIALIZED` event is fired
5053 * from within the Typewriter.
5054 *
5055 * @param {TypewriterInitializedEvent} event The event that was fired.
5056 * @param {Typewriter<T>} typewriter The Typewriter the event was fired from
5057 * @since 1.5.0
5058 */
5059 onInitialized?: (event: TypewriterInitializedEvent, typewriter: Typewriter<T>) => void;
5060 /**
5061 * Method which is called whenever an `CHANGED` event is fired
5062 * from within the Typewriter.
5063 *
5064 * @param {TypewriterChangedEvent<T>} event The event that was fired.
5065 * @param {Typewriter<T>} typewriter The Typewriter the event was fired from
5066 * @since 1.5.0
5067 */
5068 onChanged?: (event: TypewriterChangedEvent<T>, typewriter: Typewriter<T>) => void;
5069 /**
5070 * Method which is called whenever an `PLAYING` event is fired
5071 * from within the Typewriter.
5072 *
5073 * @param {TypewriterPlayingEvent} event The event that was fired.
5074 * @param {Typewriter<T>} typewriter The Typewriter the event was fired from
5075 * @since 1.5.0
5076 */
5077 onPlaying?: (event: TypewriterPlayingEvent, typewriter: Typewriter<T>) => void;
5078 /**
5079 * Method which is called whenever an `PAUSED` event is fired
5080 * from within the Typewriter.
5081 *
5082 * @param {TypewriterPausedEvent} event The event that was fired.
5083 * @param {Typewriter<T>} typewriter The Typewriter the event was fired from
5084 * @since 1.5.0
5085 */
5086 onPaused?: (event: TypewriterPausedEvent, typewriter: Typewriter<T>) => void;
5087 /**
5088 * Method which is called whenever an `STOPPED` event is fired
5089 * from within the Typewriter.
5090 *
5091 * @param {TypewriterStoppedEvent} event The event that was fired.
5092 * @param {Typewriter<T>} typewriter The Typewriter the event was fired from
5093 * @since 1.5.0
5094 */
5095 onStopped?: (event: TypewriterStoppedEvent, typewriter: Typewriter<T>) => void;
5096 /**
5097 * Method which is called whenever an `FINISHED` event is fired
5098 * from within the Typewriter.
5099 *
5100 * @param {TypewriterFinishedEvent<T>} event The event that was fired.
5101 * @param {Typewriter<T>} typewriter The Typewriter the event was fired from
5102 * @since 1.5.0
5103 */
5104 onFinished?: (event: TypewriterFinishedEvent<T>, typewriter: Typewriter<T>) => void;
5105 /**
5106 * Method which is called whenever an `BLINKING` event is fired
5107 * from within the Typewriter.
5108 *
5109 * @param {TypewriterBlinkingEvent<T>} event The event that was fired.
5110 * @param {Typewriter<T>} typewriter The Typewriter the event was fired from
5111 * @since 1.5.0
5112 */
5113 onBlinking?: (event: TypewriterBlinkingEvent<T>, typewriter: Typewriter<T>) => void;
5114 /**
5115 * Method which is called whenever an `REPEATING` event is fired
5116 * from within the Typewriter.
5117 *
5118 * @param {TypewriterRepeatingEvent<T>} event The event that was fired.
5119 * @param {Typewriter<T>} typewriter The Typewriter the event was fired from
5120 * @since 1.5.0
5121 */
5122 onRepeating?: (event: TypewriterRepeatingEvent<T>, typewriter: Typewriter<T>) => void;
5123};
5124/**
5125 * A function that creates an `TypewriterSubscriber` which you can
5126 * provide to an `Typewriter`, which maps all `TypewriterEvent` to
5127 * methods.
5128 *
5129 * You provide `createTypewriterSubscriber` with an object with all
5130 * the events you want to handle as methods and it will call the
5131 * methods for you. This way your code will not have any switch or
5132 * if-statement to distinguish between events.
5133 *
5134 * For example if you wanted to handle the `CHANGED` event, you
5135 * provide a method called `onChanged` within the config. Whenever
5136 * the `CHANGED` event occurs `onChanged` will be called.
5137 *
5138 * All methods are called with two parameters: the first is the
5139 * `event` that occurred and the second the `Typewriter` the event
5140 * occurred on.
5141 *
5142 * `createTypewriterSubscriber` should only be used when using
5143 * Vanilla JavaScript or TypeScript and not when using a reactive
5144 * framework because reactive frameworks (such as Angular or Svelte) will
5145 * handle the DOM manipulation for you.
5146 *
5147 * If an event is fired that you did not provide a method for,
5148 * an `SubscriberMissingMethodError` error will be thrown.
5149 *
5150 * @param {CreateTypewriterSubscriberConfig<T>} config An object containing all methods you want to listen to.
5151 * @returns {TypewriterSubscriber<T>} A subscriber function which can be passed to an Typewriter.
5152 * @since 1.5.0
5153 *
5154 * @example
5155 * A. Simple example
5156 *
5157 * The example below shows what the subscriber could look like for
5158 * a typewriter which only listens to the 'CHANGED' event:
5159 *
5160 * ```js
5161 * import {
5162 * Typewriter,
5163 * createTypewriterSubscriber
5164 * } from "uiloos/core";
5165 *
5166 * const subscriber = createTypewriterSubscriber({
5167 * onChanged() {
5168 * const typewriterEl = document.getElementById('typewriter');
5169 * typewriterEl.textContent = typewriter.text;
5170 * }
5171 * });
5172 *
5173 * const typewriter = new Typewriter({
5174 * repeat: true,
5175 * repeatDelay: 1000,
5176 * autoPlay: false,
5177 * actions: [
5178 * {
5179 * type: 'keyboard',
5180 * cursor: 0,
5181 * text: 'H',
5182 * delay: 150,
5183 * },
5184 * {
5185 * type: 'keyboard',
5186 * cursor: 0,
5187 * text: 'e',
5188 * delay: 132,
5189 * },
5190 * {
5191 * type: 'keyboard',
5192 * cursor: 0,
5193 * text: 'y',
5194 * delay: 84,
5195 * },
5196 * ],
5197 * }, subscriber);
5198 * ```
5199 *
5200 * @example
5201 * B. All methods implemented
5202 *
5203 * Here is a nice example to get started which includes stub
5204 * implementations for all method:
5205 *
5206 * ```js
5207 * const subscriber = createTypewriterSubscriber({
5208 * onInitialized(event, typewriter) {
5209 * console.log('onInitialized', event, typewriter);
5210 * },
5211 *
5212 * onChanged(event, typewriter) {
5213 * console.log('onChanged', event, typewriter);
5214 * },
5215 *
5216 * onPlaying(event, typewriter) {
5217 * console.log('onPlaying', event, typewriter);
5218 * },
5219 *
5220 * onPaused(event, typewriter) {
5221 * console.log('onPaused', event, typewriter);
5222 * },
5223 *
5224 * onStopped(event, typewriter) {
5225 * console.log('onStopped', event, typewriter);
5226 * },
5227 *
5228 * onFinished(event, typewriter) {
5229 * console.log('onFinished', event, typewriter);
5230 * },
5231 *
5232 * onBlinking(event, typewriter) {
5233 * console.log('onBlinking', event, typewriter);
5234 * },
5235 *
5236 * onRepeating(event, typewriter) {
5237 * console.log('onRepeating', event, typewriter);
5238 * }
5239 * });
5240 * ```
5241 */
5242declare function createTypewriterSubscriber<T>(config: CreateTypewriterSubscriberConfig<T>): TypewriterSubscriber<T>;
5243
5244/**
5245 * Error which is thrown whenever the configured blinkAfter is zero
5246 * or less than zero.
5247 *
5248 * @since 1.2.0
5249 */
5250declare class TypewriterBlinkAfterError extends Error {
5251 /**
5252 * TypewriterBlinkAfterError constructor
5253 *
5254 * @since 1.2.0
5255 */
5256 constructor();
5257}
5258
5259/**
5260 * Error which is thrown whenever the configured delay for a
5261 * TypewriterAction is zero or less than zero.
5262 *
5263 * @since 1.2.0
5264 */
5265declare class TypewriterDelayError extends Error {
5266 /**
5267 * TypewriterDelayError constructor
5268 *
5269 * @since 1.2.0
5270 */
5271 constructor();
5272}
5273
5274/**
5275 * Error which is thrown whenever the configured repeat is zero
5276 * or less than zero.
5277 *
5278 * @since 1.2.0
5279 */
5280declare class TypewriterRepeatError extends Error {
5281 /**
5282 * TypewriterRepeatError constructor
5283 *
5284 * @since 1.2.0
5285 */
5286 constructor();
5287}
5288
5289/**
5290 * Error which is thrown whenever the configured repeatDelay is less
5291 * than zero.
5292 *
5293 * @since 1.2.0
5294 */
5295declare class TypewriterRepeatDelayError extends Error {
5296 /**
5297 * TypewriterRepeatDelayError constructor
5298 *
5299 * @since 1.2.0
5300 */
5301 constructor();
5302}
5303
5304/**
5305 * Error which is thrown whenever the cursors are placed outside
5306 * of the text of the Typewriter.
5307 *
5308 * @since 1.2.0
5309 */
5310declare class TypewriterCursorOutOfBoundsError extends Error {
5311 /**
5312 * TypewriterCursorOutOfBoundsError constructor
5313 *
5314 * @since 1.2.0
5315 */
5316 constructor();
5317}
5318
5319/**
5320 * Error which is thrown whenever the cursor has a selection but the
5321 * cursor itself is not placed at either the start or end of the
5322 * selection.
5323 *
5324 * @since 1.2.0
5325 */
5326declare class TypewriterCursorNotAtSelectionEdgeError extends Error {
5327 /**
5328 * TypewriterCursorNotAtSelectionEdgeError constructor
5329 *
5330 * @since 1.2.0
5331 */
5332 constructor();
5333}
5334
5335/**
5336 * Error which is thrown whenever a cursors selection is
5337 * initialized to be outside of the text of the Typewriter.
5338 *
5339 * @since 1.2.0
5340 */
5341declare class TypewriterCursorSelectionOutOfBoundsError extends Error {
5342 /**
5343 * TypewriterCursorSelectionOutOfBoundsError constructor
5344 *
5345 * @since 1.2.0
5346 */
5347 constructor(name: 'start' | 'end');
5348}
5349
5350/**
5351 * Error which is thrown whenever a cursors selection has a start
5352 * which does not lie before the end. This happens when the start
5353 * of the selection has a higher or equal value to the end of
5354 * the selection.
5355 *
5356 * @since 1.2.0
5357 */
5358declare class TypewriterCursorSelectionInvalidRangeError extends Error {
5359 /**
5360 * TypewriterCursorSelectionInvalidRangeError constructor
5361 *
5362 * @since 1.2.0
5363 */
5364 constructor();
5365}
5366
5367/**
5368 * Error which is thrown whenever the Typewriter is configured with an
5369 * action which uses a cursor which does not exist.
5370 *
5371 * @since 1.2.0
5372 */
5373declare class TypewriterActionUnknownCursorError extends Error {
5374 /**
5375 * TypewriterActionUnknownCursorError constructor
5376 *
5377 * @since 1.2.0
5378 */
5379 constructor();
5380}
5381
5382/**
5383 * The configuration for the `typewriterFromSentences` function.
5384 *
5385 * @since 1.2.0
5386 */
5387type TypewriterFromSentencesConfig = {
5388 /**
5389 * The sentences the Typewriter should animate.
5390 *
5391 * @since 1.2.0
5392 */
5393 sentences: string[];
5394 /**
5395 * The delay in between letters, meaning the speed at which to type.
5396 *
5397 * Defaults to 50ms
5398 *
5399 * @since 1.2.0
5400 */
5401 delay?: number;
5402 /**
5403 * The delay in between sentences.
5404 *
5405 * Defaults to 2000ms
5406 *
5407 * @since 1.2.0
5408 */
5409 sentenceDelay?: number;
5410 /**
5411 * The initial text the `Typewriter` starts with.
5412 *
5413 * Defaults to '' meaning that the Typewriter will not have an
5414 * initial text.
5415 *
5416 * @since 1.2.0
5417 */
5418 text?: string;
5419 /**
5420 * The time it takes until a cursor starts blinking again after
5421 * the cursor was used.
5422 *
5423 * A cursor does not blink when it is used until after a certain
5424 * time. So if you keep typing the cursor does not blink, until
5425 * you stop typing for some "predefined amount" of time.
5426 *
5427 * The `blinkAfter` is what represents that 'predefined amount' of
5428 * time, you can also say this is a debounce time.
5429 *
5430 * Note: when you set the `blinkAfter` to a number lower or equal to
5431 * the `delay` of a `TypewriterAction`, it will negate the debounce.
5432 * The effect is that all "CHANGED" events will have a "BLINKING"
5433 * event. This might not "visually" affect your animation, but
5434 * will make the `Typewriter` send extra events. If this happens it
5435 * is technically as "misconfiguration" on your part, but the
5436 * Typewriter will not throw any errors, since visually nothing
5437 * bad happens.
5438 *
5439 * Defaults to after `250` milliseconds.
5440 *
5441 * @since 1.2.0
5442 */
5443 blinkAfter?: number;
5444 /**
5445 * For how many items the `history` may contain in the `Typewriter`.
5446 *
5447 * Defaults to `0` meaning that it will not track history.
5448 *
5449 * @since 1.2.0
5450 */
5451 keepHistoryFor?: number;
5452 /**
5453 * Whether or not the animation will immediately start playing.
5454 *
5455 * When `true` the animation will start playing immediately, when
5456 * `false` the animation will start when `play()` is called.
5457 *
5458 * Note: the animation will only start playing when there are
5459 * actions defined.
5460 *
5461 * Defaults to `true` meaning that the animation will play instantly.
5462 *
5463 * @since 1.2.0
5464 */
5465 autoPlay?: boolean;
5466 /**
5467 * Whether or not this animation repeats and how often.
5468 *
5469 * There are three ways to define `repeat`.
5470 *
5471 * 1. When `repeat` is `false` or `1` it will never repeat the
5472 * animation, the animation will run only once.
5473 *
5474 * 2. When `repeat` is `true` it will repeat the animation forever.
5475 *
5476 * 3. When `repeat` is a number it will repeat the animation
5477 * for given number of times. If the number is 0 or a negative
5478 * number is provided a error occurs.
5479 *
5480 * Defaults to `false` meaning that the animation will run once.
5481 *
5482 * @since 1.2.0
5483 */
5484 repeat?: boolean | number;
5485 /**
5486 * The time in milliseconds the animation is paused in between
5487 * repeats.
5488 *
5489 * Defaults to `0` milliseconds, meaning an almost instant repeat.
5490 *
5491 * @since 1.2.0
5492 */
5493 repeatDelay?: number;
5494};
5495/**
5496 * Creates a Typewriter which will type in the provided sentences
5497 * using a single cursor.
5498 *
5499 * Intelligently moves from one sentence to another, only removing
5500 * parts of the sentence if necessary.
5501 *
5502 * For example when providing the following sentences array:
5503 * `['I love dogs', 'I love cats]`.
5504 *
5505 * The Typewriter will type the sentence "I love dogs" first. Then it
5506 * will do four backspaces to end up with "I love". Finally it will
5507 * type in "dogs".
5508 *
5509 * @param {TypewriterFromSentencesConfig} config The configuration of the Typewriter.
5510 * @param {TypewriterSubscriber | undefined} subscriber An optional subscriber which responds to changes in the Typewriter.
5511 * @returns {Typewriter<void>} a configured typewriter
5512 * @since 1.2.0
5513 */
5514declare function typewriterFromSentences(config: TypewriterFromSentencesConfig, subscriber?: TypewriterSubscriber<void>): Typewriter<void>;
5515
5516/**
5517 * A `DateGalleryEvent` represents things like birthdays, meetings
5518 * doctors appointments etc etc inside of a `DateGallery`.
5519 *
5520 * A `DateGalleryEvent` keeps track of the events start and end date.
5521 *
5522 * Custom pieces of information can be found in the `data` property,
5523 * which can be anything you'd like, from an object to a string. For
5524 * example you could store the title and description of the event
5525 * there.
5526 *
5527 * The `overlapsWith` property will tell you all the events that this
5528 * event currently overlaps with.
5529 *
5530 * You should never instantiate a `DateGalleryEvent` directly, instead
5531 * you should call `addEvent` on the `DateGallery` and provide a
5532 * `DateGalleryEventConfig` from which the `DateGalleryEvent` is
5533 * instantiated.
5534 *
5535 * Alternatively you can also provide events via the
5536 * `DateGalleryConfig`s `events` property.
5537 *
5538 * @since 1.6.0
5539 */
5540declare class DateGalleryEvent<T> {
5541 /**
5542 * Reference to the DateGallery is it a part of.
5543 *
5544 * @since 1.6.0
5545 */
5546 dateGallery: DateGallery<T>;
5547 /**
5548 * The data for this event, "data" can be be anything from an
5549 * object, string, array etc etc. It is used to pass along data
5550 * to the event you might need to display the event, such as the
5551 * text for the event.
5552 *
5553 * By default the value is `undefined`.
5554 *
5555 * @since 1.6.0
5556 */
5557 data: T;
5558 /**
5559 * The start date of the event, includes the time.
5560 *
5561 * The `startDate` is inclusive: meaning if the event has a `startDate`
5562 * which is monday and an `endDate` on wednesday, the event runs on
5563 * monday, tuesday and wednesday.
5564 *
5565 * @since 1.6.0
5566 */
5567 startDate: Date;
5568 /**
5569 * The end date of the event, includes the time.
5570 *
5571 * The `endDate` is inclusive: meaning if the event has a `startDate`
5572 * which is monday and an `endDate` on wednesday, the event runs on
5573 * monday, tuesday and wednesday.
5574 *
5575 * @since 1.6.0
5576 */
5577 endDate: Date;
5578 /**
5579 * The other events in the `DateGallery` this event overlaps with.
5580 *
5581 * @since 1.6.0
5582 */
5583 readonly overlappingEvents: DateGalleryEvent<T>[];
5584 /**
5585 * Whether or not this `DateGalleryEvent` overlaps with other
5586 * events.
5587 *
5588 * @since 1.6.0
5589 */
5590 isOverlapping: boolean;
5591 /**
5592 * Whether or not this events spans over multiple days.
5593 *
5594 * Is `false` when the `startDate` and `endDate` are on the same
5595 * day, is `true` when the `startDate` and `endDate` are
5596 * on different days.
5597 *
5598 * @since 1.6.0
5599 */
5600 spansMultipleDays: boolean;
5601 /**
5602 * Creates an DateGalleryEvent which belongs to the given DateGallery.
5603 *
5604 * Note: you should never create instances of DateGalleryEvent
5605 * yourself. You are supposed to let DateGallery do this for you.
5606 *
5607 * @param {DateGallery<T>} dateGallery The DateGallery this DateGalleryEvent belongs to.
5608 * @param {T} index The index of this DateGalleryEvent within the DateGallery.
5609 * @param {T} data The data of this DateGalleryEvent
5610 *
5611 * @since 1.6.0
5612 */
5613 constructor(dateGallery: DateGallery<T>, data: T, startDate: Date, endDate: Date);
5614 _recalculate(): void;
5615 /**
5616 * Removes this `DateGalleryEvent` from the `DateGallery` it belongs
5617 * to.
5618 *
5619 * @param {DateGalleryEvent<T>} event The event you want to remove.
5620 * @since 1.6.0
5621 */
5622 remove(): void;
5623 /**
5624 * Moves this `DateGalleryEvent` chronologically, or in other words
5625 * it changes the events start and end time to the given range.
5626 *
5627 * @param {DateGalleryRange} range The new start and end times of the event.
5628 * @throws {DateGalleryEventInvalidRangeError} an events start date must lie before on on the end date.
5629 * @throws {DateGalleryEventNotFoundError} the provided event must be part of the DateGallery.
5630 * @since 1.6.0
5631 */
5632 move(range: DateGalleryRange): void;
5633 /**
5634 * Changes the data of this `DateGalleryEvent`, and informs the
5635 * subscribers of the change.
5636 *
5637 * Note: if you provide the exact same `data` it will still set the
5638 * `data` and inform the subscribers, even though nothing has
5639 * actually changed.
5640 *
5641 * This way, when `data` is an object or an array, you can mutate
5642 * the object / array directly, and pass in the same `data` object
5643 * to the `changeData`, without having to create copies.
5644 *
5645 * @param {T} data The new data for this DateGalleryEvent
5646 * @since 1.6.0
5647 */
5648 changeData(data: T): void;
5649}
5650
5651/**
5652 * Represents a date inside of one of the `DateGallery` frames.
5653 *
5654 * A `DateGalleryDate` knows whether it has been selected or not,
5655 * whether it is a padded date, which `DateGalleryEvent` lie on
5656 * the date etc etc.
5657 *
5658 * You should never instantiate a `DateGalleryDate` directly instead
5659 * the `DateGallery` should provide them to you.
5660 *
5661 * @since 1.6.0
5662 */
5663declare class DateGalleryDate<T> {
5664 /**
5665 * Reference to the DateGallery is it a part of.
5666 *
5667 * @since 1.6.0
5668 */
5669 dateGallery: DateGallery<T>;
5670 /**
5671 * The date associated with this `DateGalleryDate`, the time of
5672 * this date is midnight on 0 offset UTC.
5673 *
5674 * @since 1.6.0
5675 */
5676 date: Date;
5677 /**
5678 * The events that occur on this date.
5679 *
5680 * @since 1.6.0
5681 */
5682 events: DateGalleryEvent<T>[];
5683 /**
5684 * Whether or not this `DateGalleryDate` is padding for the date
5685 * frame. Visually these are often "greyed out" dates on month
5686 * calendars, used to pad out the calendar for a nicer visual.
5687 *
5688 * Padding can only occur in one of the month modes.
5689 *
5690 * @since 1.6.0
5691 */
5692 isPadding: boolean;
5693 /**
5694 * Whether or not this `DateGalleryDate` is selected.
5695 *
5696 * @since 1.6.0
5697 */
5698 isSelected: boolean;
5699 /**
5700 * Whether or not this `DateGalleryDate` can be selected, is
5701 * determined by calling the `canSelect` from the `DateGalleryConfig`
5702 * at the time of the `DateGalleryDate` construction.
5703 *
5704 * @since 1.6.0
5705 */
5706 canBeSelected: boolean;
5707 /**
5708 * Whether or not this `DateGalleryDate` represents a date which is
5709 * today.
5710 *
5711 * @since 1.6.0
5712 */
5713 isToday: boolean;
5714 /**
5715 * Whether or not this `DateGalleryDate` has any events.
5716 *
5717 * @since 1.6.0
5718 */
5719 hasEvents: boolean;
5720 /**
5721 * Whether or not this `DateGalleryDate` has events that
5722 * overlap with each other. In other words whether this day has
5723 * events on the same times as each other.
5724 *
5725 * @since 1.6.0
5726 */
5727 hasEventsWithOverlap: boolean;
5728 /**
5729 * Creates an DateGalleryDate which belongs to the given DateGallery.
5730 *
5731 * Note: you should never create instances of DateGalleryDate yourself. You
5732 * are supposed to let DateGallery do this for you.
5733 *
5734 * @param {DateGallery<T>} dateGallery The DateGallery this DateGalleryDate belongs to.
5735 * @param {Date} Date The date this `DateGalleryDate` represents.
5736 * @param {DateGalleryEvent<T>[]} events The events that lie on this date.
5737 * @param {boolean} isPadding Whether or not this DateGalleryDate is padding.
5738 * @param {boolean} isSelected Whether or not this DateGalleryDate is selected.
5739 * @since 1.6.0
5740 */
5741 constructor(dateGallery: DateGallery<T>, date: Date, events: DateGalleryEvent<T>[], isPadding: boolean, isSelected: boolean);
5742 /**
5743 * Selects the date represented by this DateGalleryDate.
5744 *
5745 * @since 1.6.0
5746 */
5747 select(): void;
5748 /**
5749 * Deselects the date represented by this DateGalleryDate.
5750 *
5751 * @since 1.6.0
5752 */
5753 deselect(): void;
5754 /**
5755 * Toggles the date selection the date represented by this
5756 * DateGalleryDate.
5757 *
5758 * If the date is selected it becomes deselected, if the date is
5759 * deselected it becomes selected.
5760 *
5761 * @since 1.6.0
5762 */
5763 toggle(): void;
5764}
5765
5766/**
5767 * Configures the initial state of the `DateGallery`.
5768 *
5769 * @since 1.6.0
5770 */
5771type DateGalleryConfig<T> = {
5772 /**
5773 * The mode the `DateGallery` is going to start on.
5774 *
5775 * Can be one of these modes:
5776 *
5777 * 1. 'day': a single day per frame.
5778 *
5779 * 2. 'week': seven days per frame, starting at the configured
5780 * `firstDayOfWeek`.
5781 *
5782 * 3. 'month': all days within a calendar month per frame. A frame
5783 * will then always start on the first of the month, and end on
5784 * the last day of the month.
5785 *
5786 * 4. 'month-six-weeks': all days within a calendar month, but padded
5787 * out to six weeks. Meaning that there are always 42 days in the
5788 * frame. Useful for when you want you calendar / datepicker to be
5789 * visually stable height wise.
5790 *
5791 * Starts the days on the configured `firstDayOfWeek`.
5792 *
5793 * 5. 'month-pad-to-week': all days within a calendar month, but
5794 * padded out to the closest `firstDayOfWeek`.
5795 *
5796 * For example given that firstDayOfWeek is set to 0 / Sunday:
5797 * if the first day of the month starts on Wednesday it will pad to
5798 * the previous Sunday of the previous month.
5799 *
5800 * If the month ends on a friday, it will add the next saturday
5801 * of the next month.
5802 *
5803 * Starts the days on the configured `firstDayOfWeek`.
5804 *
5805 * 6. 'year': a frame will contain all 365 days (or 366 when a leap year)
5806 * within a year.
5807 *
5808 * Defaults to 'month-six-weeks'.
5809 *
5810 * @since 1.6.0
5811 */
5812 mode?: DateGalleryMode;
5813 /**
5814 * Whether the `DateGallery` is in UTC mode or not.
5815 *
5816 * When the `DateGallery` is in UTC mode all dates that are given
5817 * to you via the `DateGallery` through a `DateGalleryDate` are
5818 * given in UTC.
5819 *
5820 * Also all operations on `Date` objects within the `DateGallery`
5821 * or done via the `UTC` variants.
5822 *
5823 * UTC is useful for when you want all datepickers / calendars
5824 * to look the same al around the world, which is not very often.
5825 *
5826 * Defaults to `false` meaning the browsers local offset is used.
5827 *
5828 * @since 1.6.0
5829 */
5830 isUTC?: boolean;
5831 /**
5832 * A date that will act as the initial anchor date for the date
5833 * frame.
5834 *
5835 * It will set the date frame to the "closest" date given the
5836 * `mode`.
5837 *
5838 * Can either be a `Date` instance, or a `string` which can be
5839 * passed to the `Date` constructor to make a date.
5840 *
5841 * For example if you use "2023-06-23" as the `initialDate` and the
5842 * `mode` is set to 'year', the date frame will be the year 2023. If
5843 * for the same `initialDate` the `mode` was set to `month-six-weeks`
5844 * the month of `June` would have been the date frame instead.
5845 *
5846 * Defaults to the current date.
5847 *
5848 * @since 1.6.0
5849 */
5850 initialDate?: Date | string;
5851 /**
5852 * What is to be considered the first day of the week, is used in
5853 * modes such as 'week' to determine on which day of the week to
5854 * start the frame.
5855 *
5856 * The `firstDayOfWeek` is a number between 0 and 6, were each
5857 * number represents a day of the week:
5858 *
5859 * 0 = Sunday
5860 * 1 = Monday
5861 * 2 = Tuesday
5862 * 3 = Wednesday
5863 * 4 = Thursday
5864 * 5 = Friday
5865 * 6 = Saturday
5866 *
5867 * Defaults to '0' which is 'sunday'.
5868 *
5869 * @since 1.6.0
5870 */
5871 firstDayOfWeek?: DateGalleryDayOfWeek;
5872 /**
5873 * For how many items the `history` may contain in the `DateGallery`.
5874 *
5875 * Defaults to `0` meaning that it will not track history.
5876 *
5877 * @since 1.6.0
5878 */
5879 keepHistoryFor?: number;
5880 /**
5881 * The initial events the `DateGallery` will start out with. Events
5882 * in the sense of events on a calendar: birthdays / dentist
5883 * appointments etc.
5884 *
5885 * Defaults to `[]` for no events.
5886 *
5887 * @since 1.6.0
5888 */
5889 events?: DateGalleryEventConfig<T>[];
5890 /**
5891 * How many dates can be selected at the same time.
5892 *
5893 * When the value of `limit` is `false` there is no limit to the
5894 * number of active items.
5895 *
5896 * Defaults to `false`.
5897 *
5898 * @since 1.6.0
5899 */
5900 maxSelectionLimit?: number | false;
5901 /**
5902 * How the limit is enforced. In other words what the behavior
5903 * should be when the limit is surpassed.
5904 *
5905 * The modes are strings which can be the following values:
5906 *
5907 * 1. 'circular': the first date that was selected which will be
5908 * removed so the last selected date can be added without
5909 * violating the limit. This basically means that the first one in
5910 * is the first one out.
5911 *
5912 * 2. 'error': An error is thrown whenever the limit is surpassed,
5913 * the error is called the `DateGallerySelectionLimitReachedError`.
5914 *
5915 * 3. 'ignore': Nothing happens when an date is selected and the limit
5916 * is reached. The date is simply not selected, but no error is
5917 * thrown.
5918 *
5919 * Defaults to 'circular'.
5920 *
5921 * @since 1.6.0
5922 */
5923 maxSelectionLimitBehavior?: DateGalleryMaxSelectionLimitBehavior;
5924 /**
5925 * The dates that are considered selected when the `DateGallery` is
5926 * initialized.
5927 *
5928 * The dates you provide will be converted to midnight.
5929 *
5930 * Are passed through the `canSelect` predicate any date that
5931 * cannot be selected is filtered out of the array.
5932 *
5933 * Defaults to `[]` for no events.
5934 *
5935 * @since 1.6.0
5936 */
5937 selectedDates?: (Date | string)[];
5938 /**
5939 * An optional callback predicate that is given a `DateGalleryDate`
5940 * and must return a boolean, when the boolean is `true` that date
5941 * can be selected, when `false` the date cannot be selected.
5942 *
5943 * Useful for when wanting to implement a min and max date, or
5944 * prevent the weekends from being selected, or dates that have
5945 * events.
5946 *
5947 * This callback is called when:
5948 *
5949 * 1. A `DateGalleryDate` is constructed for a frame to determine
5950 * the value of the `DateGalleryDate`s `canBeSelected` boolean.
5951 * This happens when the frame changes, or when an event is
5952 * added / removed, or a date is selected / deselected.
5953 *
5954 * 2. Whenever a date is about to get selected, to check if that
5955 * date can be selected. Happens for example when `selectDate`
5956 * or `selectRange` etc etc is called.
5957 *
5958 * IMPORTANT: try to make the predicate pure to make it easier to
5959 * reason about. Otherwise you might get a scenario in which a
5960 * `DateGalleryDate`s `canBeSelected` is `true`, but can still be
5961 * selected via `selectDate`.
5962 *
5963 * Defaults to `undefined` meaning all dates an be selected.
5964 *
5965 * @since 1.6.0
5966 */
5967 canSelect?: DateGalleryCanSelectPredicate<T>;
5968 /**
5969 * The number of frames that are visible at a time for the end user.
5970 *
5971 * This is useful for when you want to show a multiple frames at
5972 * the same time. For example if you an entire years worth of
5973 * `month-single-month` calendars you'd set the `numberOfFrames`
5974 * to `12`.
5975 *
5976 * Defaults to `1` for a single frame at a time.
5977 *
5978 * @since 1.6.0
5979 */
5980 numberOfFrames?: number;
5981};
5982/**
5983 * Represents a callback predicate which is given a `DateGalleryDate`
5984 * and needs to return a boolean, when `true` is returned the
5985 * `DateGalleryDate` can be selected, when `false` is returned
5986 * the `DateGalleryDate` cannot be selected.
5987 *
5988 * @param {DateGalleryDate<T>} dateGalleryDate The DateGalleryDate for which this predicate will determine if it can be selected.
5989 * @returns {boolean} Whether or not the DateGalleryDate can be selected.
5990 *
5991 * @since 1.6.0
5992 */
5993type DateGalleryCanSelectPredicate<T> = (dateGalleryDate: DateGalleryDate<T>) => boolean;
5994/**
5995 * The configuration object for the `DateGallery`'s `changeConfig`
5996 * method.
5997 *
5998 * All properties are optional and can be used in any combination.
5999 * Meaning you can change the `mode` and `numberOfFrames`, or the
6000 * `mode` and `initialDate` or just the `numberOfFrames`.
6001 *
6002 * @since 1.6.0
6003 */
6004type DateGalleryChangeConfig = {
6005 /**
6006 * The mode the `DateGallery` is going to start on.
6007 *
6008 * Can be one of these modes:
6009 *
6010 * 1. 'day': a single day per frame.
6011 *
6012 * 2. 'week': seven days per frame, starting at the configured
6013 * `firstDayOfWeek`.
6014 *
6015 * 3. 'month': all days within a calendar month per frame. A frame
6016 * will then always start on the first of the month, and end on
6017 * the last day of the month.
6018 *
6019 * 4. 'month-six-weeks': all days within a calendar month, but padded
6020 * out to six weeks. Meaning that there are always 42 days in the
6021 * frame. Useful for when you want you calendar / datepicker to be
6022 * visually stable height wise.
6023 *
6024 * Starts the days on the configured `firstDayOfWeek`.
6025 *
6026 * 5. 'month-pad-to-week': all days within a calendar month, but
6027 * padded out to the closest `firstDayOfWeek`.
6028 *
6029 * For example given that firstDayOfWeek is set to 0 / Sunday:
6030 * if the first day of the month starts on Wednesday it will pad to
6031 * the previous Sunday of the previous month.
6032 *
6033 * If the month ends on a friday, it will add the next saturday
6034 * of the next month.
6035 *
6036 * Starts the days on the configured `firstDayOfWeek`.
6037 *
6038 * 6. 'year': a frame will contain all 365 days (or 366 when a leap year)
6039 * within a year.
6040 *
6041 * Defaults to `undefined` meaning the mode is not changed.
6042 *
6043 * @since 1.6.0
6044 */
6045 mode?: DateGalleryMode;
6046 /**
6047 * An optional date that will act as the initial anchor date
6048 * for the date frame.
6049 *
6050 * When no `date` is provided the DateGallery will move to the
6051 * `anchorDate` of the `firstFrame`.
6052 *
6053 * Some examples:
6054 *
6055 * 1. When going from `day` to `year` the year will be set to the
6056 * year of the `anchorDate`.
6057 *
6058 * 2. When moving from `year` to `month` it will go to January
6059 * 1st of the year of the `anchorDate`
6060 *
6061 * 3. When moving from `week` to `month` it will go to the first
6062 * of the month from the start of the week.
6063 *
6064 * Can either be a `Date` instance, or a `string` which can be
6065 * passed to the `Date` constructor to make a date.
6066 *
6067 * For example if you use "2023-06-23" as the `initialDate` and the
6068 * `mode` is set to 'year', the date frame will be the year 2023. If
6069 * for the same `initialDate` the `mode` was set to `month-six-weeks`
6070 * the month of `June` would have been the date frame instead.
6071 *
6072 * Defaults `undefined` meaning the current anchor date is used.
6073 *
6074 * @since 1.6.0
6075 */
6076 initialDate?: Date | string;
6077 /**
6078 * The number of frames that are visible at a time for the end user.
6079 *
6080 * This is useful for when you want to show a multiple frames at
6081 * the same time. For example if you an entire years worth of
6082 * `month-single-month` calendars you'd set the `numberOfFrames`
6083 * to `12`.
6084 *
6085 * Defaults to `undefined` meaning the current `numberOfFrames`
6086 * is used
6087 *
6088 * @since 1.6.0
6089 */
6090 numberOfFrames?: number;
6091};
6092/**
6093 * Represents a frame within the `DateGallery` it is an object
6094 * containing all dates and events that belong on the frame.
6095 *
6096 * @since 1.6.0
6097 */
6098type DateGalleryFrame<T> = {
6099 /**
6100 * All dates that belong to this frame.
6101 *
6102 * @since 1.6.0
6103 */
6104 dates: DateGalleryDate<T>[];
6105 /**
6106 * All events that occur within this frame
6107 *
6108 * @since 1.6.0
6109 */
6110 events: DateGalleryEvent<T>[];
6111 /**
6112 * The date this frame is anchored to.
6113 *
6114 * For month based modes it is the first date of the month, for
6115 * `'week'` it is the first day of the week, for `'year'` it is
6116 * the first day of the year.
6117 *
6118 * Basically the same as the first date in the `dates` array which
6119 * is not a padded date.
6120 *
6121 * @since 1.6.0
6122 */
6123 anchorDate: Date;
6124};
6125/**
6126 * Holds the configuration of an event which is placed in the
6127 * `DateGallery`. From this configuration the actual
6128 * `DateGalleryEvent` is created.
6129 *
6130 * @since 1.6.0
6131 */
6132type DateGalleryEventConfig<T> = {
6133 /**
6134 * The data for this event, "data" can be be anything from an
6135 * object, string, array etc etc. It is used to pass along data
6136 * to the event you might need to display the event, such as the
6137 * text for the event.
6138 *
6139 * By default the value is `undefined`.
6140 *
6141 * @since 1.6.0
6142 */
6143 data: T;
6144 /**
6145 * The start date of the event, includes the time.
6146 *
6147 * The `startDate` is inclusive: meaning if the event has a `startDate`
6148 * which is monday and an `endDate` on wednesday, the event runs on
6149 * monday, tuesday and wednesday.
6150 *
6151 * Can either be a Date instance, or a string which can be passed
6152 * to the `Date` constructor to make a date.
6153 *
6154 * @since 1.6.0
6155 */
6156 startDate: Date | string;
6157 /**
6158 * The end date of the event, includes the time.
6159 *
6160 * The `endDate` is inclusive: meaning if the event has a `startDate`
6161 * which is monday and an `endDate` on wednesday, the event runs on
6162 * monday, tuesday and wednesday.
6163 *
6164 * Can either be a Date instance, or a string which can be passed
6165 * to the `Date` constructor to make a date.
6166 *
6167 * @since 1.6.0
6168 */
6169 endDate: Date | string;
6170};
6171/**
6172 * Represents all valid values that can be given to the
6173 * `DateGalleryConfig`s `firstDayOfWeek` property.
6174 *
6175 * @since 1.6.0
6176 */
6177type DateGalleryDayOfWeek = 0 | 1 | 2 | 3 | 4 | 5 | 6;
6178/**
6179 * An array of strings containing all predefined modes of the
6180 * `DateGallery`.
6181 *
6182 * @see DateGalleryMode
6183 * @since 1.6.0
6184 */
6185declare const DATE_GALLERY_MODES: readonly ["day", "week", "month", "month-six-weeks", "month-pad-to-week", "year"];
6186/**
6187 * All predefined modes of the `DateGallery`:
6188 *
6189 * 1. 'day': a single day per frame.
6190 *
6191 * 2. 'week': seven days per frame, starting at the configured
6192 * `firstDayOfWeek`.
6193 *
6194 * 3. 'month': all days within a calendar month per frame. A frame
6195 * will then always start on the first of the month, and end on
6196 * the last day of the month.
6197 *
6198 * 4. 'month-six-weeks': all days within a calendar month, but padded
6199 * out to six weeks. Meaning that there are always 42 days in the
6200 * frame. Useful for when you want you calendar / datepicker to be
6201 * visually stable height wise.
6202 *
6203 * Starts the days on the configured `firstDayOfWeek`.
6204 *
6205 * 5. 'month-pad-to-week': all days within a calendar month, but padded
6206 * out to the closest `firstDayOfWeek`.
6207 *
6208 * For example given that firstDayOfWeek is set to 0 / Sunday:
6209 * if the first day of the month starts on Wednesday it will pad to
6210 * the previous Sunday of the previous month.
6211 *
6212 * If the month ends on a friday, it will add the next saturday
6213 * of the next month.
6214 *
6215 * Starts the days on the configured `firstDayOfWeek`.
6216 *
6217 * 6. 'year': a frame will contain all 365 days (or 366 when a leap year)
6218 * within a year.
6219 *
6220 * @since 1.6.0
6221 */
6222type DateGalleryMode = (typeof DATE_GALLERY_MODES)[number];
6223/**
6224 * Describes all the behaviors for when the selection limit of the
6225 * DateGallery is surpassed.
6226 *
6227 * 1. 'circular': the first date that was selected which will be
6228 * removed so the last selected date can be added without
6229 * violating the limit. This basically means that the first one in
6230 * is the first one out.
6231 *
6232 * 2. 'error': An error is thrown whenever the limit is surpassed,
6233 * the error is called the `DateGallerySelectionLimitReachedError`.
6234 *
6235 * 3. 'ignore': Nothing happens when an date is selected and the limit
6236 * is reached. The date is simply not selected, but no error is
6237 * thrown.
6238 *
6239 * @since 1.6.0
6240 */
6241type DateGalleryMaxSelectionLimitBehavior = 'circular' | 'ignore' | 'error';
6242/**
6243 * Represents a range of dates, from a start date to and end date.
6244 *
6245 * @since 1.6.0
6246 */
6247type DateGalleryRange = {
6248 /**
6249 * The start date of the range, includes the time.
6250 *
6251 * The `startDate` is inclusive: meaning if the event has a `startDate`
6252 * which is monday and an `endDate` on wednesday, the range runs on
6253 * monday, tuesday and wednesday.
6254 *
6255 * Can either be a Date instance, or a string which can be passed
6256 * to the `Date` constructor to make a date.
6257 *
6258 * @since 1.6.0
6259 */
6260 startDate: Date | string;
6261 /**
6262 * The end date of the range, includes the time.
6263 *
6264 * The `endDate` is inclusive: meaning if the event has a `startDate`
6265 * which is monday and an `endDate` on wednesday, the range runs on
6266 * monday, tuesday and wednesday.
6267 *
6268 * Can either be a Date instance, or a string which can be passed
6269 * to the `Date` constructor to make a date.
6270 *
6271 * @since 1.6.0
6272 */
6273 endDate: Date | string;
6274};
6275/**
6276 * The subscriber which is informed of all state changes the
6277 * DateGallery goes through.
6278 *
6279 * @param {DateGallery<T>} DateGallery The DateGallery which had changes.
6280 * @param {DateGallerySubscriberEvent<T>} event The event that occurred.
6281 *
6282 * @since 1.6.0
6283 */
6284type DateGallerySubscriber<T> = (DateGallery: DateGallery<T>, event: DateGallerySubscriberEvent<T>) => void;
6285/**
6286 * Represents whether the `DateGallery` changed frames, added an
6287 * event, selected a date etc etc.
6288 *
6289 * @since 1.6.0
6290 */
6291type DateGallerySubscriberEventType = 'INITIALIZED' | 'FRAME_CHANGED' | 'CONFIG_CHANGED' | 'DATE_SELECTED' | 'DATE_SELECTED_MULTIPLE' | 'DATE_DESELECTED' | 'DATE_DESELECTED_MULTIPLE' | 'EVENT_ADDED' | 'EVENT_REMOVED' | 'EVENT_MOVED' | 'EVENT_DATA_CHANGED';
6292/**
6293 * Represents an event which happened in the DateGallery. Based
6294 * on the `type` you can determine which event occurred.
6295 *
6296 * @since 1.6.0
6297 */
6298type DateGalleryBaseEvent = {
6299 /**
6300 * Which event occurred
6301 *
6302 * @since 1.6.0
6303 */
6304 type: DateGallerySubscriberEventType;
6305 /**
6306 * The time the event occurred on as a Date object.
6307 *
6308 * @since 1.6.0
6309 */
6310 time: Date;
6311};
6312/**
6313 * Represents the initialization of the DateGallery
6314 *
6315 * @since 1.6.0
6316 */
6317type DateGalleryInitializedEvent = DateGalleryBaseEvent & {
6318 /**
6319 * Which type occurred
6320 *
6321 * @since 1.6.0
6322 */
6323 type: 'INITIALIZED';
6324};
6325/**
6326 * Represents the fact that the date frame has how changed, this
6327 * occurs when the frame is moved to the next or previous frame.
6328 *
6329 * @since 1.6.0
6330 */
6331type DateGalleryFrameChangedEvent<T> = DateGalleryBaseEvent & {
6332 /**
6333 * Which type occurred
6334 *
6335 * @since 1.6.0
6336 */
6337 type: 'FRAME_CHANGED';
6338 /**
6339 * The newly visible frames.
6340 *
6341 * @since 1.6.0
6342 */
6343 frames: DateGalleryFrame<T>[];
6344};
6345/**
6346 * Represents the fact that a date has been selected.
6347 *
6348 * @since 1.6.0
6349 */
6350type DateGalleryDateSelectedEvent = DateGalleryBaseEvent & {
6351 /**
6352 * Which type occurred
6353 *
6354 * @since 1.6.0
6355 */
6356 type: 'DATE_SELECTED';
6357 /**
6358 * The date that was selected.
6359 *
6360 * @since 1.6.0
6361 */
6362 date: Date;
6363 /**
6364 * The date which was deselected, will be `null` when no value
6365 * was deselected as part of the selection.
6366 *
6367 * A deselection will only happen as part of a selection when
6368 * `maxSelectionLimit` is set to a `number` and
6369 * `maxSelectionLimitBehavior` is set to `circular`.
6370 *
6371 * @since 1.6.0
6372 */
6373 deselectedDate: Date | null;
6374};
6375/**
6376 * Represents the fact that multiple dates have been selected.
6377 *
6378 * @since 1.6.0
6379 */
6380type DateGalleryDateSelectedMultipleEvent = DateGalleryBaseEvent & {
6381 /**
6382 * Which type occurred
6383 *
6384 * @since 1.6.0
6385 */
6386 type: 'DATE_SELECTED_MULTIPLE';
6387 /**
6388 * The dates that were selected.
6389 *
6390 * @since 1.6.0
6391 */
6392 dates: Date[];
6393 /**
6394 * The dates which were deselected.
6395 *
6396 * A deselection will only happen as part of a selection when
6397 * `maxSelectionLimit` is set to a `number` and
6398 * `maxSelectionLimitBehavior` is set to `circular`.
6399 *
6400 * @since 1.6.0
6401 */
6402 deselectedDates: Date[];
6403};
6404/**
6405 * Represents the fact that a date has been deselected
6406 *
6407 * @since 1.6.0
6408 */
6409type DateGalleryDateDeselectedEvent = DateGalleryBaseEvent & {
6410 /**
6411 * Which type occurred
6412 *
6413 * @since 1.6.0
6414 */
6415 type: 'DATE_DESELECTED';
6416 /**
6417 * The date that was deselected.
6418 *
6419 * @since 1.6.0
6420 */
6421 date: Date;
6422};
6423/**
6424 * Represents the fact that multiple dates have been deselected
6425 *
6426 * @since 1.6.0
6427 */
6428type DateGalleryDateDeselectedMultipleEvent = DateGalleryBaseEvent & {
6429 /**
6430 * Which type occurred
6431 *
6432 * @since 1.6.0
6433 */
6434 type: 'DATE_DESELECTED_MULTIPLE';
6435 /**
6436 * The dates that were deselected.
6437 *
6438 * @since 1.6.0
6439 */
6440 dates: Date[];
6441};
6442/**
6443 * Represents the fact that an event has been added to the
6444 * DateGallery.
6445 *
6446 * @since 1.6.0
6447 */
6448type DateGalleryEventAddedEvent<T> = DateGalleryBaseEvent & {
6449 /**
6450 * Which type occurred
6451 *
6452 * @since 1.6.0
6453 */
6454 type: 'EVENT_ADDED';
6455 /**
6456 * The event that was added
6457 *
6458 * @since 1.6.0
6459 */
6460 event: DateGalleryEvent<T>;
6461};
6462/**
6463 * Represents the fact that an event has been removed from the
6464 * DateGallery.
6465 *
6466 * @since 1.6.0
6467 */
6468type DateGalleryEventRemovedEvent<T> = DateGalleryBaseEvent & {
6469 /**
6470 * Which type occurred
6471 *
6472 * @since 1.6.0
6473 */
6474 type: 'EVENT_REMOVED';
6475 /**
6476 * The event that was removed
6477 *
6478 * @since 1.6.0
6479 */
6480 event: DateGalleryEvent<T>;
6481};
6482/**
6483 * Represents the fact that an event was moved, it got either
6484 * a new start or end date.
6485 *
6486 * @since 1.6.0
6487 */
6488type DateGalleryEventMovedEvent<T> = DateGalleryBaseEvent & {
6489 /**
6490 * Which type occurred
6491 *
6492 * @since 1.6.0
6493 */
6494 type: 'EVENT_MOVED';
6495 /**
6496 * The event that was moved
6497 *
6498 * @since 1.6.0
6499 */
6500 event: DateGalleryEvent<T>;
6501};
6502/**
6503 * Represents a changing of the data of an event.
6504 *
6505 * @since 1.6.0
6506 */
6507type DateGalleryEventDataChangedEvent<T> = DateGalleryBaseEvent & {
6508 /**
6509 * Which type occurred
6510 *
6511 * @since 1.6.0
6512 */
6513 type: 'EVENT_DATA_CHANGED';
6514 /**
6515 * The event which had its data changed
6516 *
6517 * @since 1.6.0
6518 */
6519 event: DateGalleryEvent<T>;
6520 /**
6521 * The new data for the DateGalleryEvent
6522 *
6523 * @since 1.6.0
6524 */
6525 data: T;
6526};
6527/**
6528 * Represents a changing in the DateGallery's `mode`, `initialDate`,
6529 * or `numberOfFrames`
6530 *
6531 * @since 1.6.0
6532 */
6533type DateGalleryConfigChangedEvent<T> = DateGalleryBaseEvent & {
6534 /**
6535 * Which type occurred
6536 *
6537 * @since 1.6.0
6538 */
6539 type: 'CONFIG_CHANGED';
6540 /**
6541 * The current `mode` the DateGallery now has.
6542 *
6543 * @since 1.6.0
6544 */
6545 mode: DateGalleryMode;
6546 /**
6547 * The current anchor date the firstFrame of the DateGallery now has.
6548 *
6549 * @since 1.6.0
6550 */
6551 anchorDate: Date;
6552 /**
6553 * The current `numberOfFrames` the DateGallery now has.
6554 *
6555 * @since 1.6.0
6556 */
6557 numberOfFrames: number;
6558 /**
6559 * The newly visible frames.
6560 *
6561 * @since 1.6.0
6562 */
6563 frames: DateGalleryFrame<T>[];
6564};
6565/**
6566 * A DateGallerySubscriberEvent represents an event happened in the DateGallery.
6567 * For example the insertion, removal, or activation of a
6568 * DateGalleryContent<T>.
6569 *
6570 * @since 1.6.0
6571 */
6572type DateGallerySubscriberEvent<T> = DateGalleryInitializedEvent | DateGalleryFrameChangedEvent<T> | DateGalleryDateSelectedEvent | DateGalleryDateDeselectedEvent | DateGalleryEventAddedEvent<T> | DateGalleryEventRemovedEvent<T> | DateGalleryDateSelectedMultipleEvent | DateGalleryDateDeselectedMultipleEvent | DateGalleryEventMovedEvent<T> | DateGalleryEventDataChangedEvent<T> | DateGalleryConfigChangedEvent<T>;
6573
6574/**
6575 * A DateGallery is a class that represents a frame of dates, a frame
6576 * of dates is a sequence of chronologically sequential dates of a
6577 * certain length.
6578 *
6579 * The idea is that whenever you are creating components that use
6580 * sequences of dates, so for example: date pickers, range selectors,
6581 * or calendars, that you can use the DateGallery class to handle the
6582 * dates for you.
6583 *
6584 * The DateGallery comes in various modes:
6585 *
6586 * 1. 'day': a single day per frame.
6587 *
6588 * 2. 'week': seven days per frame, starting at the configured
6589 * `firstDayOfWeek`.
6590 *
6591 * 3. 'month': all days within a calendar month per frame. A frame
6592 * will then always start on the first of the month, and end on
6593 * the last day of the month.
6594 *
6595 * 4. 'month-six-weeks': all days within a calendar month, but padded
6596 * out to six weeks. Meaning that there are always 42 days in the
6597 * frame. Useful for when you want you calendar / datepicker to be
6598 * visually stable height wise.
6599 *
6600 * Starts the days on the configured `firstDayOfWeek`.
6601 *
6602 * 5. 'month-pad-to-week': all days within a calendar month, but
6603 * padded out to the closest `firstDayOfWeek`.
6604 *
6605 * For example given that firstDayOfWeek is set to 0 / Sunday:
6606 * if the first day of the month starts on Wednesday it will pad to
6607 * the previous Sunday of the previous month.
6608 *
6609 * If the month ends on a friday, it will add the next saturday
6610 * of the next month.
6611 *
6612 * Starts the days on the configured `firstDayOfWeek`.
6613 *
6614 * 6. 'year': a frame will contain all 365 days (or 366 when a leap year)
6615 * within a year.
6616 *
6617 * The frame part of a DateGallery is what is visually displayed to a
6618 * user, when making a monthly based calendar you are making a whole
6619 * year available but only show one month at a time. The month that
6620 * you show is a "frames", the dates that are visually displayed.
6621 *
6622 * The DateGallery provides methods for navigating through frames,
6623 * for example you can go to the next / previous frame.
6624 *
6625 * You can ask the DateGallery for multiple frames at the same time
6626 * by stetting the `numberOfFrames` property, this allows you to for
6627 * example display three months at the same time, or five years at
6628 * the same time.
6629 *
6630 * DateGallery also supports having events such as birthdays or
6631 * holidays. For each "frame" that the DateGallery provides it will
6632 * also tell you which events fall on that frame. Events also know
6633 * if they are overlapping with other events.
6634 *
6635 * Finally the DateGallery can help you select dates. It will also
6636 * put this information in each frame so you know which dates are
6637 * selected.
6638 *
6639 * @since 1.6.0
6640 */
6641declare class DateGallery<T> implements Observable<DateGallery<T>, DateGallerySubscriberEvent<T>> {
6642 /**
6643 * Whether or not to inform subscribers of changes / record history.
6644 * Used in the `initialize` to temporarily stop subscriptions running
6645 * the initial activation, and altering the history.
6646 */
6647 private _isInitializing;
6648 /**
6649 * Whether the `DateGallery` is in UTC mode or not.
6650 *
6651 * When the `DateGallery` is in UTC mode all dates that are given
6652 * to you via the `DateGallery` through a `DateGalleryDate` are
6653 * given in UTC.
6654 *
6655 * Also all operations on `Date` objects within the `DateGallery`
6656 * or done via the `UTC` variants.
6657 *
6658 * UTC is useful for when you want all datepickers / calendars
6659 * to look the same al around the world, which is not very often.
6660 *
6661 * @since 1.60
6662 */
6663 isUTC: boolean;
6664 /**
6665 * The frames of dates that are currently visible to the user.
6666 *
6667 * @since 1.6.0
6668 */
6669 readonly frames: DateGalleryFrame<T>[];
6670 /**
6671 * The first frame of dates that is visible to the user.
6672 *
6673 * Is a shortcut to the first frame in the `frames` property.
6674 *
6675 * If `numberOfFrames` is 1 this will be the only visible frame.
6676 *
6677 * @since 1.6.0
6678 */
6679 firstFrame: DateGalleryFrame<T>;
6680 /**
6681 * The number of frames that are visible at a time for the end user.
6682 *
6683 * This is useful for when you want to show a multiple frames at
6684 * the same time. For example if you an entire years worth of
6685 * `month-single-month` calendars you'd set the `numberOfFrames`
6686 * to `12`.
6687 *
6688 * @since 1.6.0
6689 */
6690 numberOfFrames: number;
6691 /**
6692 * How many dates can be selected at the same time.
6693 *
6694 * When the value of `limit` is `false` there is no limit to the
6695 * number of active items.
6696 *
6697 * Defaults to `false`.
6698 *
6699 * @since 1.6.0
6700 */
6701 maxSelectionLimit: number | false;
6702 /**
6703 * How the limit is enforced. In other words what the behavior
6704 * should be when the limit is surpassed.
6705 *
6706 * The modes are strings which can be the following values:
6707 *
6708 * 1. 'circular': the first date that was selected which will be
6709 * removed so the last selected date can be added without
6710 * violating the limit. This basically means that the first one in
6711 * is the first one out.
6712 *
6713 * 2. 'error': An error is thrown whenever the limit is surpassed,
6714 * the error is called the `DateGallerySelectionLimitReachedError`.
6715 *
6716 * 3. 'ignore': Nothing happens when an date is selected and the limit
6717 * is reached. The date is simply not selected, but no error is
6718 * thrown.
6719 *
6720 * Defaults to 'circular'.
6721 *
6722 * @since 1.6.0
6723 */
6724 maxSelectionLimitBehavior: DateGalleryMaxSelectionLimitBehavior;
6725 /**
6726 * All dates which are currently considered selected.
6727 *
6728 * All dates will have their time set at midnight.
6729 *
6730 * The array is not sorted, the items will appear in insertion
6731 * order.
6732 *
6733 * @since 1.6.0
6734 */
6735 readonly selectedDates: Date[];
6736 _canSelect: DateGalleryCanSelectPredicate<T> | undefined;
6737 /**
6738 * All events, such as birthdays, meetings etc that are associated
6739 * with this `DateGallery`.
6740 *
6741 * Is sorted from old to new, events that appear earlier in the
6742 * array are earlier than events that appear later in the array.
6743 *
6744 * @since 1.6.0
6745 */
6746 readonly events: DateGalleryEvent<T>[];
6747 /**
6748 * The mode the `DateGallery` is on.
6749 *
6750 * 1. 'day': a single day per frame.
6751 *
6752 * 2. 'week': seven days per frame, starting at the configured
6753 * `firstDayOfWeek`.
6754 *
6755 * 3. 'month': all days within a calendar month per frame. A frame
6756 * will then always start on the first of the month, and end on
6757 * the last day of the month.
6758 *
6759 * 4. 'month-six-weeks': all days within a calendar month, but padded
6760 * out to six weeks. Meaning that there are always 42 days in the
6761 * frame. Useful for when you want you calendar / datepicker to be
6762 * visually stable height wise.
6763 *
6764 * Starts the days on the configured `firstDayOfWeek`.
6765 *
6766 * 5. 'month-pad-to-week': all days within a calendar month, but
6767 * padded out to the closest `firstDayOfWeek`.
6768 *
6769 * For example given that firstDayOfWeek is set to 0 / Sunday:
6770 * if the first day of the month starts on Wednesday it will pad to
6771 * the previous Sunday of the previous month.
6772 *
6773 * If the month ends on a friday, it will add the next saturday
6774 * of the next month.
6775 *
6776 * Starts the days on the configured `firstDayOfWeek`.
6777 *
6778 * 6. 'year': a frame will contain all 365 days (or 366 when a leap year)
6779 * within a year.
6780 *
6781 * @since 1.6.0
6782 */
6783 mode: DateGalleryMode;
6784 /**
6785 * What is to be considered the first day of the week, is used in
6786 * modes such as 'week' to determine on which day of the week to
6787 * start the frame.
6788 *
6789 * The `firstDayOfWeek` is a number between 0 and 6, were each
6790 * number represents a day of the week:
6791 *
6792 * 0 = Sunday
6793 * 1 = Monday
6794 * 2 = Tuesday
6795 * 3 = Wednesday
6796 * 4 = Thursday
6797 * 5 = Friday
6798 * 6 = Saturday
6799 *
6800 * @since 1.6.0
6801 */
6802 firstDayOfWeek: DateGalleryDayOfWeek;
6803 private _anchorDate;
6804 private _history;
6805 /**
6806 * Contains the history of the changes in the contents array.
6807 *
6808 * Tracks 11 types of changes:
6809 *
6810 * 1. INITIALIZED: fired when DateGallery is initialized.
6811 *
6812 * 2. FRAME_CHANGED: fired when the frames changes.
6813 *
6814 * 3. CONFIG_CHANGED: fires when the config is changed.
6815 *
6816 * 4. DATE_SELECTED: fires when a date is selected.
6817 *
6818 * 5. DATE_SELECTED_MULTIPLE: fires when multiple dates are selected.
6819 *
6820 * 6. DATE_DESELECTED: fires when a date is deselected.
6821 *
6822 * 7. DATE_DESELECTED_MULTIPLE: fires when multiple dates are
6823 * deselected.
6824 *
6825 * 8. EVENT_ADDED: fires when an event such as a birthday /
6826 * appointment is added.
6827 *
6828 * 9. EVENT_REMOVED: fires when an event such as a birthday /
6829 * appointment is removed.
6830 *
6831 * 10. EVENT_MOVED': fires when an event such as a birthday /
6832 * appointment is moved.
6833 *
6834 * 11. EVENT_MOVED': fires when an event such as a birthday /
6835 * appointment has its data changed.
6836 *
6837 * Goes only as far back as configured in the `Config` property
6838 * `keepHistoryFor`, to prevent an infinitely growing history.
6839 * Note that by default no history is kept, as `keepHistoryFor`
6840 * is zero by default.
6841 *
6842 * The last item in the `history` is the current active item. The
6843 * further to the left the further in the past you go.
6844 *
6845 * This means that a history at index 0 is further in the past than
6846 * an item at index 1.
6847 *
6848 * @since 1.6.0
6849 */
6850 readonly history: DateGallerySubscriberEvent<T>[];
6851 private _observer;
6852 /**
6853 * Creates an DateGallery based on the DateGalleryConfig config.
6854 *
6855 * You can also optionally provide an subscriber so you can get
6856 * informed of the changes happening to the DateGallery.
6857 *
6858 * @param {DateGalleryConfig<T>} config The initial configuration of the DateGallery.
6859 * @param {DateGallerySubscriber<T> | undefined} subscriber An optional subscriber which responds to changes in the DateGallery.
6860 * @throws {DateGalleryEventInvalidRangeError} an events start date must lie before on on the end date.
6861 * @throws {DateGalleryFirstDayOfWeekError} the configured day of the week must be between 0 and 6 inclusive.
6862 * @throws {DateGalleryInvalidDateError} dates provided must be valid dates
6863 * @throws {DateGalleryModeError} the mode must be one of the predefined modes
6864 * @throws {DateGallerySelectionLimitReachedError} thrown when maxSelectionLimit is exceeded, and maxSelectionLimitBehavior is "error".
6865 * @since 1.6.0
6866 */
6867 constructor(config?: DateGalleryConfig<T>, subscriber?: DateGallerySubscriber<T>);
6868 /**
6869 * Subscribe to changes of the DateGallery. The function you
6870 * provide will get called whenever changes occur in the
6871 * DateGallery.
6872 *
6873 * Returns an unsubscribe function which when called will unsubscribe
6874 * from the DateGallery.
6875 *
6876 * @param {DateGallerySubscriber<T>} subscriber The subscriber which responds to changes in the DateGallery.
6877 * @returns {UnsubscribeFunction} A function which when called will unsubscribe from the DateGallery.
6878 *
6879 * @since 1.6.0
6880 */
6881 subscribe(subscriber: DateGallerySubscriber<T>): UnsubscribeFunction;
6882 /**
6883 * Unsubscribe the subscriber so it no longer receives changes / updates
6884 * of the state changes of the DateGallery.
6885 *
6886 * @param {DateGallerySubscriber<T>} subscriber The subscriber which you want to unsubscribe.
6887 *
6888 * @since 1.6.0
6889 */
6890 unsubscribe(subscriber: DateGallerySubscriber<T>): void;
6891 /**
6892 * Unsubscribes all subscribers at once, all subscribers will no
6893 * longer receives changes / updates of the state changes of
6894 * the DateGallery.
6895 *
6896 * @since 1.6.0
6897 */
6898 unsubscribeAll(): void;
6899 /**
6900 * Initializes the DateGallery based on the config provided. This can
6901 * effectively reset the DateGallery when called, including the
6902 * frames and history.
6903 *
6904 * @param {DateGalleryConfig<T>} config The new configuration which will override the old one
6905 * @throws {DateGalleryEventInvalidRangeError} an events start date must lie before on on the end date.
6906 * @throws {DateGalleryFirstDayOfWeekError} the configured day of the week must be between 0 and 6 inclusive.
6907 * @throws {DateGalleryInvalidDateError} dates provided must be valid dates
6908 * @throws {DateGalleryModeError} the mode must be one of the predefined modes
6909 * @throws {DateGalleryNumberOfFramesError} numberOfFrames must be a positive number when defined
6910 * @throws {DateGallerySelectionLimitReachedError} thrown when maxSelectionLimit is exceeded, and maxSelectionLimitBehavior is "error".
6911 * @since 1.6.0
6912 */
6913 initialize(config: DateGalleryConfig<T>): void;
6914 private _doInitialize;
6915 /**
6916 * Changes the configuration of the DateGallery, allowing you
6917 * to change the `mode` the initial date and `numberOfFrames`.
6918 *
6919 * All properties are optional and can be used in any combination.
6920 * Meaning you can change the `mode` and `numberOfFrames`, or the
6921 * `mode` and `initialDate` or just the `numberOfFrames`.
6922 *
6923 * Note: the `events` and `selectedDates` are kept as is.
6924 *
6925 * @param {DateGalleryChangeConfig} config The new configuration.
6926 * @throws {DateGalleryModeError} the mode must be one of the predefined modes
6927 * @throws {DateGalleryInvalidDateError} the initialDate when provided must be valid date
6928 * @throws {DateGalleryNumberOfFramesError} numberOfFrames must be a positive number when defined
6929 * @since 1.6.0
6930 */
6931 changeConfig(config: DateGalleryChangeConfig): void;
6932 /**
6933 * Changes the anchor date of the DateGallery to today.
6934 *
6935 * @since 1.6.0
6936 */
6937 today(): void;
6938 private _buildFrames;
6939 /**
6940 * Moves the frame of the DateGallery to the next frame.
6941 *
6942 * For example if the mode is set to `month` and the current anchor
6943 * date is in March it will move to April.
6944 *
6945 * @since 1.6.0
6946 */
6947 next(): void;
6948 /**
6949 * Moves the frame of the DateGallery to the previous frame.
6950 *
6951 * For example if the mode is set to `month` and the current anchor
6952 * date is in April it will move to March.
6953 *
6954 * @since 1.6.0
6955 */
6956 previous(): void;
6957 private _moveFrame;
6958 /**
6959 * Selects the given date, the date can either be a `Date` instance,
6960 * or a `string` which can be passed to the `Date`constructor to
6961 * make a date.
6962 *
6963 * The given date will be converted to midnight, so all times in
6964 * the `selectedDates` array are always at midnight.
6965 *
6966 * When a `canSelect` predicate is configured, the date is first
6967 * checked to see if it can be added. When a date does not pass the
6968 * check nothing happens, and no error is thrown.
6969 *
6970 * @param {Date | string} date An optional date to act as the new initial date
6971 * @throws {DateGalleryModeError} the mode must be one of the predefined modes
6972 * @throws {DateGalleryInvalidDateError} date provided must be valid date
6973 * @throws {DateGallerySelectionLimitReachedError} thrown when maxSelectionLimit is exceeded, and maxSelectionLimitBehavior is "error".
6974 * @since 1.6.0
6975 */
6976 selectDate(date: string | Date): void;
6977 _doSelectDate(date: Date, method: string): void;
6978 _pushSelectDate(date: Date, method: string, deselectedDates: Date[]): Date | null;
6979 /**
6980 * Deselects the given date, the date can either be a `Date`
6981 * instance, or a `string` which can be passed to the `Date`
6982 * constructor to make a date.
6983 *
6984 * The given date will be converted to midnight so it better matches
6985 * the `selectedDates` which are always at midnight.
6986 *
6987 * @param {Date | string} date An optional date to act as the new initial date
6988 * @throws {DateGalleryModeError} the mode must be one of the predefined modes
6989 * @throws {DateGalleryInvalidDateError} date provided must be valid date
6990 * @since 1.6.0
6991 */
6992 deselectDate(date: string | Date): void;
6993 _doDeselectDate(index: number, date: Date): void;
6994 /**
6995 * Toggles the date selection of the given date, if the date is
6996 * selected it becomes deselected, if the date is deselected it
6997 * becomes selected.
6998 *
6999 * The given date can either be a `Date` instance, or a `string`
7000 * which can be passed to the `Date` constructor to make a date.
7001 *
7002 * The given date will be converted to midnight, so all times in
7003 * the `selectedDates` array are always at midnight.
7004 *
7005 * When a `canSelect` predicate is configured, the date is first
7006 * checked to see if it can be added. When a date does not pass the
7007 * check nothing happens, and no error is thrown.
7008 *
7009 * @param {Date | string} date An optional date to act as the new initial date
7010 * @throws {DateGalleryModeError} the mode must be one of the predefined modes
7011 * @throws {DateGalleryInvalidDateError} date provided must be valid date
7012 * @throws {DateGallerySelectionLimitReachedError} thrown when maxSelectionLimit is exceeded, and maxSelectionLimitBehavior is "error".
7013 * @since 1.6.0
7014 */
7015 toggleDateSelection(date: string | Date): void;
7016 private _indexOfDate;
7017 /**
7018 * Deselects all dates, effectively clearing the `selectedDates`
7019 * property.
7020 *
7021 * @since 1.6.0
7022 */
7023 deselectAll(): void;
7024 /**
7025 * Selects all dates from within the given date range.
7026 *
7027 * If the range is end inclusive meaning if the starts on Monday
7028 * and end ends on Friday: Monday, Tuesday, Wednesday, Thursday
7029 * and Friday are selected.
7030 *
7031 * The given dates can either be a `Date` instance, or a `string`
7032 * which can be passed to the `Date` constructor to make a date.
7033 *
7034 * The order of the two parameters does not matter as `selectRange`
7035 * will check whether `a` or `b` is the earlier date.
7036 *
7037 * If a date is already selected and falls within the range the date
7038 * will stay selected.
7039 *
7040 * When a `canSelect` predicate is configured, the date is first
7041 * checked to see if it can be added. When a date does not pass the
7042 * check nothing happens, and no error is thrown.
7043 *
7044 * Dates can also become deselected if the `maxSelection` is set
7045 * to a number and the `maxSelectionLimitBehavior` is set to
7046 * "circular", if space needs to be made for the new dates.
7047 *
7048 * When `maxSelectionLimitBehavior` is set to "error", all dates
7049 * that can be accommodated become selected, but when the limit is
7050 * exceeded the selection stops. The subscribers are then informed
7051 * of which dates were selected, and then the error is thrown.
7052 *
7053 * Even through each date is selected sequentially, only one event
7054 * is emitted, and one call is made to the subscribers, even if
7055 * multiple dates are selected and deselected.
7056 *
7057 * Within the `DateGalleryDateSelectedMultipleEvent` only the end
7058 * activate / deactivate results are reported.
7059 *
7060 * @param {Date | string} a the start or end date of the range
7061 * @param {Date | string} b The start or end date of the range
7062 * @throws {DateGalleryInvalidDateError} dates provided must be valid dates
7063 * @throws {DateGallerySelectionLimitReachedError} thrown when maxSelectionLimit is exceeded, and maxSelectionLimitBehavior is "error".
7064 * @since 1.6.0
7065 */
7066 selectRange(a: Date | string, b: Date | string): void;
7067 /**
7068 * Takes a `DateGalleryEventConfig` and adds that config as a
7069 * `DateGalleryEvent` to the `DateGallery`.
7070 *
7071 * @param {DateGalleryEventConfig<T>} event The config of the event you want to add.
7072 * @throws {DateGalleryEventInvalidRangeError} an events start date must lie before on on the end date.
7073 * @throws {DateGalleryInvalidDateError} dates provided must be valid dates
7074 * @returns {DateGalleryEvent} The created DateGalleryEvent.
7075 * @since 1.6.0
7076 */
7077 addEvent(event: DateGalleryEventConfig<T>): DateGalleryEvent<T>;
7078 private _doAddEvent;
7079 /**
7080 * Takes a `DateGalleryEvent` and removes that event from this
7081 * `DateGallery`, and all associated frames.
7082 *
7083 * Note: if the event cannot be found within the `DateGallery`
7084 * nothing happens.
7085 *
7086 * @param {DateGalleryEvent<T>} event The event you want to remove.
7087 * @returns {DateGalleryEvent} The removed DateGalleryEvent.
7088 * @since 1.6.0
7089 */
7090 removeEvent(event: DateGalleryEvent<T>): DateGalleryEvent<T>;
7091 /**
7092 * Takes a `DateGalleryEvent` and moves that event chronologically,
7093 * in other words it changes the events start and end time to the
7094 * given range.
7095 *
7096 * @param {DateGalleryEvent<T>} event The event you want to move / change the start / end time for.
7097 * @param {DateGalleryRange} range The new start and end times of the event.
7098 * @throws {DateGalleryEventInvalidRangeError} an events start date must lie before on on the end date.
7099 * @throws {DateGalleryEventNotFoundError} the provided event must be part of the DateGallery.
7100 * @since 1.6.0
7101 */
7102 moveEvent(event: DateGalleryEvent<T>, range: DateGalleryRange): void;
7103 /**
7104 * Changes the data of the given DateGalleryEvent, and informs
7105 * the subscribers of the change.
7106 *
7107 * Note: if you provide the exact same `data` it will still set the
7108 * `data` and inform the subscribers, even though nothing has
7109 * actually changed.
7110 *
7111 * This way, when `data` is an object or an array, you can mutate
7112 * the object / array directly, and pass in the same `data` object
7113 * to the `changeData`, without having to create copies.
7114 *
7115 * @param {DateGalleryEvent<T>} view The DateGalleryEvent to change the data for
7116 * @param {T} data The new data for the DateGalleryEvent
7117 * @throws {DateGalleryEventNotFoundError} item must be in the views array based on === equality
7118 * @since 1.6.0
7119 */
7120 changeEventData(event: DateGalleryEvent<T>, data: T): void;
7121 private _dragAnchor;
7122 _inform(event: DateGallerySubscriberEvent<T>): void;
7123 private _toDate;
7124 private _checkDate;
7125 private _firstDayOfWeek;
7126 private _addNoDates;
7127 private _addMonth;
7128 private _pushDay;
7129 private _makeDate;
7130 /**
7131 * Compares two dates and returns whether or not they are on the
7132 * same date.
7133 *
7134 * The given dates can either be a `Date` instance, or a `string`
7135 * which can be passed to the `Date` constructor to make a date.
7136 *
7137 * Takes into account the `isUTC` of the `DateGallery` when UTC is
7138 * `true` it will compare the UTC dates.
7139 *
7140 * @param {Date | string} a The first date you want to check
7141 * @param {Date | string} b The second date you want to check
7142 * @throws {DateGalleryInvalidDateError} dates provided must be valid dates
7143 * @returns {boolean} whether or not the dates are on the same date.
7144 * @since 1.6.0
7145 */
7146 isSameDay(a: Date | string, b: Date | string): boolean;
7147 _sameDay(a: Date, b: Date): boolean;
7148 private _getFullYear;
7149 private _getMonth;
7150 private _getDate;
7151 private _getDay;
7152 private _checkMode;
7153 private _toMidnight;
7154 private _moveDateBy;
7155}
7156
7157/**
7158 * Error which is thrown whenever an event has a startDate that lies
7159 * after the endDate.
7160 *
7161 * @since 1.6.0
7162 */
7163declare class DateGalleryEventInvalidRangeError extends Error {
7164 /**
7165 * DateGalleryEventInvalidRangeError constructor
7166 *
7167 * @since 1.6.0
7168 */
7169 constructor();
7170}
7171
7172/**
7173 * Error which is thrown whenever the DateGallery is configured
7174 * with a `firstDayOfWeek` which is not a number from 0 to 6,
7175 * including 6.
7176 *
7177 * @since 1.6.0
7178 */
7179declare class DateGalleryFirstDayOfWeekError extends Error {
7180 /**
7181 * DateGalleryFirstDayOfWeekError constructor
7182 *
7183 * @since 1.6.0
7184 */
7185 constructor();
7186}
7187
7188/**
7189 * Error which is thrown whenever the DateGallery is given an invalid
7190 * Date object, or when Date object cannot be constructed from
7191 * a string.
7192 *
7193 * An example of an invalid date would be '2000-42-42' as there is
7194 * no 42th month.
7195 *
7196 * @since 1.6.0
7197 */
7198declare class DateGalleryInvalidDateError extends Error {
7199 /**
7200 * DateGalleryInvalidDateError constructor
7201 *
7202 * @since 1.6.0
7203 */
7204 constructor(method: string, dateName: string);
7205}
7206
7207/**
7208 * Error which is thrown whenever the mode is unknown, meaning not
7209 * part of the `DATE_FRAME_MODES` array of known modes.
7210 *
7211 * @since 1.6.0
7212 */
7213declare class DateGalleryModeError extends Error {
7214 /**
7215 * DateGalleryModeError constructor
7216 *
7217 * @since 1.6.0
7218 */
7219 constructor(mode: string);
7220}
7221
7222/**
7223 * Error which is thrown whenever the numberOfFrames is zero or
7224 * less than zero.
7225 *
7226 * @since 1.6.0
7227 */
7228declare class DateGalleryNumberOfFramesError extends Error {
7229 /**
7230 * DateGalleryNumberOfFramesError constructor
7231 *
7232 * @since 1.6.0
7233 */
7234 constructor();
7235}
7236
7237/**
7238 * Error which is thrown whenever a move is performed on an
7239 * DateGalleryEvent, but that event is not found within the
7240 * DateGallery that is performing the move,
7241 *
7242 * This can occur whenever an event is removed and the instance
7243 * is then moved.
7244 *
7245 * @since 1.6.0
7246 */
7247declare class DateGalleryEventNotFoundError extends Error {
7248 /**
7249 * DateGalleryEventNotFoundError constructor
7250 *
7251 * @since 1.6.0
7252 */
7253 constructor(method: string);
7254}
7255
7256/**
7257 * Error which is thrown whenever the DateGallery is in
7258 * `DateGalleryMaxSelectionLimitBehavior` mode `error`, when the
7259 * `maxSelectionLimit` is exceeded.
7260 *
7261 * @since 1.6.0
7262 */
7263declare class DateGallerySelectionLimitReachedError extends Error {
7264 /**
7265 * DateGallerySelectionLimitReachedError constructor
7266 *
7267 * @since 1.6.0
7268 */
7269 constructor(method: string);
7270}
7271
7272/**
7273 * The configuration for the `createDateGallery` function.
7274 *
7275 * You should provide all methods for the events that you want to
7276 * listen to, the ones you are not interested
7277 *
7278 * @since 1.6.0
7279 */
7280type CreateDateGallerySubscriberConfig<T> = {
7281 /**
7282 * Optionally whether or not you want to show debug logging.
7283 *
7284 * When `debug` is enabled whenever an event method is not provided
7285 * but the event is fired, a `console.warn` message is logged. This
7286 * allows you to easier detect missing methods during development.
7287 *
7288 * Defaults to `false`, meaning nothing will be logged to the console.
7289 *
7290 * @since 1.6.0
7291 */
7292 debug?: boolean;
7293 /**
7294 * Method which is called whenever an `INITIALIZED` event is fired
7295 * from within the DateGallery.
7296 *
7297 * @param {DateGalleryInitializedEvent} event The event that was fired.
7298 * @param {DateGallery<T>} dateGallery The DateGallery the event was fired from
7299 * @since 1.6.0
7300 */
7301 onInitialized?: (event: DateGalleryInitializedEvent, dateGallery: DateGallery<T>) => void;
7302 /**
7303 * Method which is called whenever an `FRAME_CHANGED` event is fired
7304 * from within the DateGallery.
7305 *
7306 * @param {DateGalleryFrameChangedEvent<T>} event The event that was fired.
7307 * @param {DateGallery<T>} dateGallery The DateGallery the event was fired from
7308 * @since 1.6.0
7309 */
7310 onFrameChanged?: (event: DateGalleryFrameChangedEvent<T>, dateGallery: DateGallery<T>) => void;
7311 /**
7312 * Method which is called whenever an `CONFIG_CHANGED` event is fired
7313 * from within the DateGallery.
7314 *
7315 * @param {DateGalleryConfigChangedEvent<T>} event The event that was fired.
7316 * @param {DateGallery<T>} dateGallery The DateGallery the event was fired from
7317 * @since 1.6.0
7318 */
7319 onConfigChanged?: (event: DateGalleryConfigChangedEvent<T>, dateGallery: DateGallery<T>) => void;
7320 /**
7321 * Method which is called whenever an `MOVED` event is fired
7322 * from within the DateGallery.
7323 *
7324 * @param {DateGalleryDateSelectedEvent} event The event that was fired.
7325 * @param {DateGallery<T>} dateGallery The DateGallery the event was fired from
7326 * @since 1.6.0
7327 */
7328 onDateSelected?: (event: DateGalleryDateSelectedEvent, dateGallery: DateGallery<T>) => void;
7329 /**
7330 * Method which is called whenever an `MOVED` event is fired
7331 * from within the DateGallery.
7332 *
7333 * @param {DateGalleryDateSelectedMultipleEvent} event The event that was fired.
7334 * @param {DateGallery<T>} dateGallery The DateGallery the event was fired from
7335 * @since 1.6.0
7336 */
7337 onDateSelectedMultiple?: (event: DateGalleryDateSelectedMultipleEvent, dateGallery: DateGallery<T>) => void;
7338 /**
7339 * Method which is called whenever an `MOVED` event is fired
7340 * from within the DateGallery.
7341 *
7342 * @param {DateGalleryDateDeselectedEvent} event The event that was fired.
7343 * @param {DateGallery<T>} dateGallery The DateGallery the event was fired from
7344 * @since 1.6.0
7345 */
7346 onDateDeselected?: (event: DateGalleryDateDeselectedEvent, dateGallery: DateGallery<T>) => void;
7347 /**
7348 * Method which is called whenever an `MOVED` event is fired
7349 * from within the DateGallery.
7350 *
7351 * @param {DateGalleryDateDeselectedMultipleEvent} event The event that was fired.
7352 * @param {DateGallery<T>} dateGallery The DateGallery the event was fired from
7353 * @since 1.6.0
7354 */
7355 onDateDeselectedMultiple?: (event: DateGalleryDateDeselectedMultipleEvent, dateGallery: DateGallery<T>) => void;
7356 /**
7357 * Method which is called whenever an `MOVED` event is fired
7358 * from within the DateGallery.
7359 *
7360 * @param {DateGalleryEventAddedEvent<T>} event The event that was fired.
7361 * @param {DateGallery<T>} dateGallery The DateGallery the event was fired from
7362 * @since 1.6.0
7363 */
7364 onEventAdded?: (event: DateGalleryEventAddedEvent<T>, dateGallery: DateGallery<T>) => void;
7365 /**
7366 * Method which is called whenever an `MOVED` event is fired
7367 * from within the DateGallery.
7368 *
7369 * @param {DateGalleryEventRemovedEvent<T>} event The event that was fired.
7370 * @param {DateGallery<T>} dateGallery The DateGallery the event was fired from
7371 * @since 1.6.0
7372 */
7373 onEventRemoved?: (event: DateGalleryEventRemovedEvent<T>, dateGallery: DateGallery<T>) => void;
7374 /**
7375 * Method which is called whenever an `MOVED` event is fired
7376 * from within the DateGallery.
7377 *
7378 * @param {DateGalleryEventMovedEvent<T>} event The event that was fired.
7379 * @param {DateGallery<T>} dateGallery The DateGallery the event was fired from
7380 * @since 1.6.0
7381 */
7382 onEventMoved?: (event: DateGalleryEventMovedEvent<T>, dateGallery: DateGallery<T>) => void;
7383 /**
7384 * Method which is called whenever an `EVENT_DATA_CHANGED` event is fired
7385 * from within the DateGallery.
7386 *
7387 * @param {DateGalleryEventDataChangedEvent<T>} event The event that was fired.
7388 * @param {DateGallery<T>} dateGallery The DateGallery the event was fired from
7389 * @since 1.6.0
7390 */
7391 onEventDataChanged?: (event: DateGalleryEventDataChangedEvent<T>, dateGallery: DateGallery<T>) => void;
7392};
7393/**
7394 * A function that creates an `DateGallerySubscriber` which you can
7395 * provide to an `DateGallery`, which maps all `DateGalleryEvent` to
7396 * methods.
7397 *
7398 * You provide `createDateGallery` with an object with all the events
7399 * you want to handle as methods and it will call the methods for you.
7400 * This way your code will not have any switch or if-statement to
7401 * distinguish between events.
7402 *
7403 * For example if you wanted to handle the `FRAME_CHANGED` event, you
7404 * provide a method called `onFrameChanged` within the config.
7405 * Whenever the `FRAME_CHANGED` event occurs `onFrameChanged` will be
7406 * called.
7407 *
7408 * All methods are called with two parameters: the first is the
7409 * `event` that occurred and the second the `DateGallery` the event
7410 * occurred on.
7411 *
7412 * `createDateGallery` should only be used when using
7413 * Vanilla JavaScript or TypeScript and not when using a reactive
7414 * framework because reactive frameworks (such as React or Vue) will
7415 * handle the DOM manipulation for you.
7416 *
7417 * If an event is fired that you did not provide a method for,
7418 * an `SubscriberMissingMethodError` error will be thrown.
7419 *
7420 * @param {createDateGallerySubscriberConfig} config An object containing all methods you want to listen to.
7421 * @returns {DateGallerySubscriber<T>} A subscriber function which can be passed to an DateGallery.
7422 * @since 1.6.0
7423 *
7424 * @example
7425 * A. Simple example
7426 *
7427 * The example below shows what the subscriber could look like for
7428 * a calendar view which can change frames.
7429 *
7430 * ```js
7431 * import {
7432 * DateGallery,
7433 * createDateGallerySubscriber
7434 * } from 'uiloos/core';
7435 *
7436 * const subscriber = createDateGallerySubscriber({
7437 * onInitialized() {
7438 * // Setup initial week calendar UI
7439 * },
7440 *
7441 * onFrameChanged() {
7442 * // Whenever the user changes weeks re-render them.
7443 * },
7444 * });
7445 *
7446 * export const weekCalendar = new DateGallery(
7447 * {
7448 * mode: 'week'
7449 * },
7450 * subscriber
7451 * );
7452 * ```
7453 *
7454 * @example
7455 * B. All methods implemented
7456 *
7457 * Here is a nice example to get started which includes stub
7458 * implementations for all method:
7459 *
7460 * ```js
7461 * const subscriber = createDateGallery({
7462 * onInitialized(event, dateGallery) {
7463 * console.log('onInitialized', event, dateGallery)
7464 * },
7465 *
7466 * onFrameChanged(event, dateGallery) {
7467 * console.log('onFrameChanged', event, dateGallery)
7468 * },
7469 *
7470 * onConfigChanged(event, dateGallery) {
7471 * console.log('onConfigChanged', event, dateGallery)
7472 * },
7473 *
7474 * onDateSelected(event, dateGallery) {
7475 * console.log('onDateSelected', event, dateGallery)
7476 * },
7477 *
7478 * onDateSelectedMultiple(event, dateGallery) {
7479 * console.log('onDateSelectedMultiple', event, dateGallery)
7480 * },
7481 *
7482 * onDateDeselected(event, dateGallery) {
7483 * console.log('onDateDeselected', event, dateGallery)
7484 * },
7485 *
7486 * onDateDeselectedMultiple(event, dateGallery) {
7487 * console.log('onDateDeselectedMultiple', event, dateGallery)
7488 * },
7489 *
7490 * onEventAdded(event, dateGallery) {
7491 * console.log('onEventAdded', event, dateGallery)
7492 * },
7493 *
7494 * onEventRemoved(event, dateGallery) {
7495 * console.log('onEventRemoved', event, dateGallery)
7496 * },
7497 *
7498 * onEventMoved(event, dateGallery) {
7499 * console.log('onEventMoved', event, dateGallery)
7500 * },
7501 *
7502 * onEventDataChanged(event, dateGallery) {
7503 * console.log('onEventDataChanged', event, dateGallery)
7504 * },
7505 * });
7506 * ```
7507 */
7508declare function createDateGallerySubscriber<T>(config: CreateDateGallerySubscriberConfig<T>): DateGallerySubscriber<T>;
7509
7510export { ActivateLicenseOptions, ActiveList, ActiveListActivatedEvent, ActiveListActivatedMultipleEvent, ActiveListActivationLimitReachedError, ActiveListActivationOptions, ActiveListAutoPlay, ActiveListAutoPlayConfig, ActiveListAutoPlayDurationCallback, ActiveListAutoPlayDurationCallbackData, ActiveListAutoPlayDurationError, ActiveListAutoPlayPausedEvent, ActiveListAutoPlayPlayingEvent, ActiveListAutoPlayStoppedEvent, ActiveListBaseEvent, ActiveListConfig, ActiveListContent, ActiveListContentPredicate, ActiveListContentPredicateData, ActiveListCooldown, ActiveListCooldownConfig, ActiveListCooldownDurationCallback, ActiveListCooldownDurationCallbackData, ActiveListCooldownDurationError, ActiveListCooldownEndedEvent, ActiveListCooldownStartedEvent, ActiveListDeactivatedEvent, ActiveListDeactivatedMultipleEvent, ActiveListDirection, ActiveListEvent, ActiveListEventType, ActiveListIndexOutOfBoundsError, ActiveListInitializedEvent, ActiveListInsertedEvent, ActiveListItemNotFoundError, ActiveListMaxActivationLimitBehavior, ActiveListMovedEvent, ActiveListPredicateMode, ActiveListPredicateOptions, ActiveListRemovedEvent, ActiveListRemovedMultipleEvent, ActiveListSubscriber, ActiveListSwappedEvent, BaseTypewriterAction, CreateActiveListSubscriberConfig, CreateDateGallerySubscriberConfig, CreateTypewriterSubscriberConfig, CreateViewChannelSubscriberConfig, DATE_GALLERY_MODES, DateGallery, DateGalleryBaseEvent, DateGalleryCanSelectPredicate, DateGalleryChangeConfig, DateGalleryConfig, DateGalleryConfigChangedEvent, DateGalleryDate, DateGalleryDateDeselectedEvent, DateGalleryDateDeselectedMultipleEvent, DateGalleryDateSelectedEvent, DateGalleryDateSelectedMultipleEvent, DateGalleryDayOfWeek, DateGalleryEvent, DateGalleryEventAddedEvent, DateGalleryEventConfig, DateGalleryEventDataChangedEvent, DateGalleryEventInvalidRangeError, DateGalleryEventMovedEvent, DateGalleryEventNotFoundError, DateGalleryEventRemovedEvent, DateGalleryFirstDayOfWeekError, DateGalleryFrame, DateGalleryFrameChangedEvent, DateGalleryInitializedEvent, DateGalleryInvalidDateError, DateGalleryMaxSelectionLimitBehavior, DateGalleryMode, DateGalleryModeError, DateGalleryNumberOfFramesError, DateGalleryRange, DateGallerySelectionLimitReachedError, DateGallerySubscriber, DateGallerySubscriberEvent, DateGallerySubscriberEventType, Observable, Subscriber, Typewriter, TypewriterAction, TypewriterActionKeyboard, TypewriterActionMouse, TypewriterActionType, TypewriterActionUnknownCursorError, TypewriterBaseEvent, TypewriterBlinkAfterError, TypewriterBlinkingEvent, TypewriterChangedEvent, TypewriterConfig, TypewriterCursor, TypewriterCursorConfig, TypewriterCursorNotAtSelectionEdgeError, TypewriterCursorOutOfBoundsError, TypewriterCursorSelection, TypewriterCursorSelectionInvalidRangeError, TypewriterCursorSelectionOutOfBoundsError, TypewriterDelayError, TypewriterEvent, TypewriterEventType, TypewriterFinishedEvent, TypewriterFromSentencesConfig, TypewriterInitializedEvent, TypewriterPausedEvent, TypewriterPlayingEvent, TypewriterPosition, TypewriterRepeatDelayError, TypewriterRepeatError, TypewriterRepeatingEvent, TypewriterStoppedEvent, TypewriterSubscriber, UnsubscribeFunction, ViewChannel, ViewChannelAutoDismissDurationError, ViewChannelBaseEvent, ViewChannelConfig, ViewChannelEvent, ViewChannelEventType, ViewChannelIndexOutOfBoundsError, ViewChannelInitializedEvent, ViewChannelSubscriber, ViewChannelView, ViewChannelViewAutoDismiss, ViewChannelViewAutoDismissConfig, ViewChannelViewAutoDismissPausedEvent, ViewChannelViewAutoDismissPlayingEvent, ViewChannelViewAutoDismissStoppedEvent, ViewChannelViewConfig, ViewChannelViewDataChangedEvent, ViewChannelViewDismissedAllEvent, ViewChannelViewDismissedEvent, ViewChannelViewDismissedEventReason, ViewChannelViewNotFoundError, ViewChannelViewPresentedEvent, _LicenseChecker, createActiveListSubscriber, createDateGallerySubscriber, createTypewriterSubscriber, createViewChannelSubscriber, licenseChecker, typewriterFromSentences };