@qwanyx/carousel 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import React$1, { CSSProperties, ReactNode } from 'react';
1
+ import * as React$1 from 'react';
2
+ import React__default, { CSSProperties, ReactNode } from 'react';
2
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
4
 
4
5
  /**
@@ -313,11 +314,132 @@ declare function createImageSlide(id: string, src: string, options?: {
313
314
  objectFit?: ImageObject['objectFit'];
314
315
  background?: SlideBackground;
315
316
  }): Slide;
317
+ /**
318
+ * Timecode in milliseconds
319
+ * Display format: MM:SS:mmm (e.g., 01:30:500 = 90500ms)
320
+ */
321
+ type Timecode = number;
322
+ /**
323
+ * Convert timecode to display string MM:SS:mmm
324
+ */
325
+ declare function formatTimecode(ms: Timecode): string;
326
+ /**
327
+ * Parse display string MM:SS:mmm to timecode
328
+ */
329
+ declare function parseTimecode(str: string): Timecode;
330
+ /**
331
+ * Blend modes for layers
332
+ */
333
+ type BlendMode = 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn';
334
+ /**
335
+ * Easing functions for keyframe interpolation
336
+ */
337
+ type EasingType = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'step-start' | 'step-end';
338
+ /**
339
+ * Animatable properties for keyframes
340
+ */
341
+ interface KeyframeProperties {
342
+ visible?: boolean;
343
+ opacity?: number;
344
+ x?: number;
345
+ y?: number;
346
+ scaleX?: number;
347
+ scaleY?: number;
348
+ rotation?: number;
349
+ volume?: number;
350
+ }
351
+ /**
352
+ * Timeline keyframe - a point in time with property values
353
+ */
354
+ interface TimelineKeyframe {
355
+ id: string;
356
+ time: Timecode;
357
+ properties: KeyframeProperties;
358
+ easing?: EasingType;
359
+ }
360
+ /**
361
+ * Base for all layer tree nodes
362
+ */
363
+ interface LayerNodeBase {
364
+ id: string;
365
+ name: string;
366
+ visible: boolean;
367
+ locked: boolean;
368
+ opacity: number;
369
+ blendMode?: BlendMode;
370
+ keyframes?: TimelineKeyframe[];
371
+ }
372
+ /**
373
+ * Layer folder - contains other folders or items
374
+ */
375
+ interface LayerFolder extends LayerNodeBase {
376
+ type: 'folder';
377
+ collapsed?: boolean;
378
+ children: LayerNode[];
379
+ }
380
+ /**
381
+ * Layer item - contains a single object (image, text, etc.)
382
+ */
383
+ interface LayerItem extends LayerNodeBase {
384
+ type: 'item';
385
+ object: SlideObject;
386
+ }
387
+ /**
388
+ * Union type for layer tree nodes
389
+ */
390
+ type LayerNode = LayerFolder | LayerItem;
391
+ /**
392
+ * Audio track configuration
393
+ */
394
+ interface AudioTrack {
395
+ id: string;
396
+ name: string;
397
+ src: string;
398
+ startTime?: Timecode;
399
+ endTime?: Timecode;
400
+ offset?: Timecode;
401
+ volume?: number;
402
+ muted?: boolean;
403
+ loop?: boolean;
404
+ }
405
+ /**
406
+ * Composition - a timeline-based animation with layers
407
+ */
408
+ interface Composition {
409
+ id: string;
410
+ name: string;
411
+ width: number;
412
+ height: number;
413
+ aspectRatio?: string;
414
+ duration: Timecode;
415
+ frameRate?: number;
416
+ audioTracks?: AudioTrack[];
417
+ layers: LayerNode[];
418
+ background?: SlideBackground;
419
+ createdAt?: string;
420
+ updatedAt?: string;
421
+ }
422
+ /**
423
+ * Create an empty composition
424
+ */
425
+ declare function createComposition(id: string, name: string, options?: Partial<Omit<Composition, 'id' | 'name' | 'layers'>>): Composition;
426
+ /**
427
+ * Create a layer folder
428
+ */
429
+ declare function createLayerFolder(id: string, name: string, children?: LayerNode[]): LayerFolder;
430
+ /**
431
+ * Create a layer item
432
+ */
433
+ declare function createLayerItem(id: string, name: string, object: SlideObject): LayerItem;
434
+ /**
435
+ * Create a keyframe
436
+ */
437
+ declare function createKeyframe(time: Timecode, properties: KeyframeProperties, easing?: EasingType): TimelineKeyframe;
316
438
 
317
439
  /**
318
440
  * Qwanyx Carousel - Universal slide/presentation engine
319
441
  */
320
- declare const Carousel: React$1.ForwardRefExoticComponent<CarouselProps & React$1.RefAttributes<CarouselRef>>;
442
+ declare const Carousel: React__default.ForwardRefExoticComponent<CarouselProps & React__default.RefAttributes<CarouselRef>>;
321
443
 
322
444
  interface SlideRendererProps {
323
445
  slide: Slide;
@@ -346,6 +468,383 @@ interface ThumbnailsProps {
346
468
  */
347
469
  declare function Thumbnails({ slides, currentIndex, onSelect, onReorder, onDelete, position, size, theme, }: ThumbnailsProps): react_jsx_runtime.JSX.Element;
348
470
 
471
+ interface AnimationEditorProps {
472
+ composition: Composition;
473
+ isOpen: boolean;
474
+ onClose: () => void;
475
+ onSave: (composition: Composition) => void;
476
+ }
477
+ declare function AnimationEditor({ composition: initialComposition, isOpen, onClose, onSave, }: AnimationEditorProps): react_jsx_runtime.JSX.Element | null;
478
+
479
+ /**
480
+ * Animation Editor Types
481
+ *
482
+ * Types specific to the animation editor UI and state management.
483
+ * Core composition types are in ../../types.ts
484
+ */
485
+
486
+ /**
487
+ * Selection state in the editor
488
+ */
489
+ interface EditorSelection {
490
+ layerIds: string[];
491
+ keyframeIds: string[];
492
+ }
493
+ /**
494
+ * Playback state
495
+ */
496
+ interface PlaybackState {
497
+ isPlaying: boolean;
498
+ currentTime: Timecode;
499
+ playbackRate: number;
500
+ }
501
+ /**
502
+ * Timeline view state
503
+ */
504
+ interface TimelineViewState {
505
+ zoom: number;
506
+ scrollX: number;
507
+ scrollY: number;
508
+ snapToGrid: boolean;
509
+ gridSize: Timecode;
510
+ }
511
+ /**
512
+ * Tool mode for the editor
513
+ */
514
+ type EditorTool = 'select' | 'move' | 'scale' | 'rotate' | 'keyframe';
515
+ /**
516
+ * Panel visibility state
517
+ */
518
+ interface PanelState {
519
+ layers: boolean;
520
+ properties: boolean;
521
+ timeline: boolean;
522
+ }
523
+ /**
524
+ * Complete editor state
525
+ */
526
+ interface AnimationEditorState {
527
+ composition: Composition;
528
+ selection: EditorSelection;
529
+ playback: PlaybackState;
530
+ timeline: TimelineViewState;
531
+ tool: EditorTool;
532
+ panels: PanelState;
533
+ isDirty: boolean;
534
+ }
535
+ type EditorAction = {
536
+ type: 'SET_COMPOSITION';
537
+ payload: Composition;
538
+ } | {
539
+ type: 'UPDATE_COMPOSITION';
540
+ payload: Partial<Composition>;
541
+ } | {
542
+ type: 'ADD_LAYER';
543
+ payload: {
544
+ layer: LayerNode;
545
+ parentId?: string;
546
+ index?: number;
547
+ };
548
+ } | {
549
+ type: 'REMOVE_LAYER';
550
+ payload: {
551
+ layerId: string;
552
+ };
553
+ } | {
554
+ type: 'UPDATE_LAYER';
555
+ payload: {
556
+ layerId: string;
557
+ updates: Partial<LayerNode>;
558
+ };
559
+ } | {
560
+ type: 'MOVE_LAYER';
561
+ payload: {
562
+ layerId: string;
563
+ targetParentId?: string;
564
+ index: number;
565
+ };
566
+ } | {
567
+ type: 'TOGGLE_LAYER_VISIBILITY';
568
+ payload: {
569
+ layerId: string;
570
+ };
571
+ } | {
572
+ type: 'TOGGLE_LAYER_LOCK';
573
+ payload: {
574
+ layerId: string;
575
+ };
576
+ } | {
577
+ type: 'TOGGLE_FOLDER_COLLAPSED';
578
+ payload: {
579
+ folderId: string;
580
+ };
581
+ } | {
582
+ type: 'ADD_KEYFRAME';
583
+ payload: {
584
+ layerId: string;
585
+ keyframe: TimelineKeyframe;
586
+ };
587
+ } | {
588
+ type: 'REMOVE_KEYFRAME';
589
+ payload: {
590
+ layerId: string;
591
+ keyframeId: string;
592
+ };
593
+ } | {
594
+ type: 'UPDATE_KEYFRAME';
595
+ payload: {
596
+ layerId: string;
597
+ keyframeId: string;
598
+ updates: Partial<TimelineKeyframe>;
599
+ };
600
+ } | {
601
+ type: 'MOVE_KEYFRAME';
602
+ payload: {
603
+ layerId: string;
604
+ keyframeId: string;
605
+ newTime: Timecode;
606
+ };
607
+ } | {
608
+ type: 'SELECT_LAYERS';
609
+ payload: {
610
+ layerIds: string[];
611
+ additive?: boolean;
612
+ };
613
+ } | {
614
+ type: 'SELECT_KEYFRAMES';
615
+ payload: {
616
+ keyframeIds: string[];
617
+ additive?: boolean;
618
+ };
619
+ } | {
620
+ type: 'CLEAR_SELECTION';
621
+ } | {
622
+ type: 'PLAY';
623
+ } | {
624
+ type: 'PAUSE';
625
+ } | {
626
+ type: 'STOP';
627
+ } | {
628
+ type: 'SEEK';
629
+ payload: {
630
+ time: Timecode;
631
+ };
632
+ } | {
633
+ type: 'SET_PLAYBACK_RATE';
634
+ payload: {
635
+ rate: number;
636
+ };
637
+ } | {
638
+ type: 'SET_TIMELINE_ZOOM';
639
+ payload: {
640
+ zoom: number;
641
+ };
642
+ } | {
643
+ type: 'SET_TIMELINE_SCROLL';
644
+ payload: {
645
+ scrollX?: number;
646
+ scrollY?: number;
647
+ };
648
+ } | {
649
+ type: 'TOGGLE_SNAP_TO_GRID';
650
+ } | {
651
+ type: 'SET_GRID_SIZE';
652
+ payload: {
653
+ size: Timecode;
654
+ };
655
+ } | {
656
+ type: 'SET_TOOL';
657
+ payload: {
658
+ tool: EditorTool;
659
+ };
660
+ } | {
661
+ type: 'TOGGLE_PANEL';
662
+ payload: {
663
+ panel: keyof PanelState;
664
+ };
665
+ } | {
666
+ type: 'UNDO';
667
+ } | {
668
+ type: 'REDO';
669
+ } | {
670
+ type: 'MARK_SAVED';
671
+ };
672
+ interface AnimationEditorContextValue {
673
+ state: AnimationEditorState;
674
+ dispatch: React.Dispatch<EditorAction>;
675
+ selectedLayers: LayerNode[];
676
+ flattenedLayers: LayerNode[];
677
+ currentTimeFormatted: string;
678
+ durationFormatted: string;
679
+ }
680
+ interface LayerPanelProps$1 {
681
+ layers: LayerNode[];
682
+ selectedIds: string[];
683
+ onSelect: (layerId: string, additive: boolean) => void;
684
+ onToggleVisibility: (layerId: string) => void;
685
+ onToggleLock: (layerId: string) => void;
686
+ onToggleCollapsed: (folderId: string) => void;
687
+ onReorder: (layerId: string, targetParentId: string | undefined, index: number) => void;
688
+ onAddFolder: () => void;
689
+ onAddItem: () => void;
690
+ onDelete: (layerId: string) => void;
691
+ onRename: (layerId: string, name: string) => void;
692
+ }
693
+ interface TimelineProps$1 {
694
+ composition: Composition;
695
+ currentTime: Timecode;
696
+ zoom: number;
697
+ scrollX: number;
698
+ selectedKeyframeIds: string[];
699
+ onSeek: (time: Timecode) => void;
700
+ onZoomChange: (zoom: number) => void;
701
+ onScrollChange: (scrollX: number) => void;
702
+ onKeyframeSelect: (keyframeId: string, additive: boolean) => void;
703
+ onKeyframeMove: (layerId: string, keyframeId: string, newTime: Timecode) => void;
704
+ onKeyframeAdd: (layerId: string, time: Timecode) => void;
705
+ onKeyframeDelete: (layerId: string, keyframeId: string) => void;
706
+ }
707
+ interface PreviewCanvasProps$1 {
708
+ composition: Composition;
709
+ currentTime: Timecode;
710
+ selectedLayerIds: string[];
711
+ onLayerSelect: (layerId: string) => void;
712
+ }
713
+ interface PropertiesPanelProps$1 {
714
+ selectedLayers: LayerNode[];
715
+ currentTime: Timecode;
716
+ onUpdateLayer: (layerId: string, updates: Partial<LayerNode>) => void;
717
+ onAddKeyframe: (layerId: string) => void;
718
+ }
719
+
720
+ /**
721
+ * Find a layer by ID in the tree
722
+ */
723
+ declare function findLayerById(layers: LayerNode[], id: string): LayerNode | null;
724
+ /**
725
+ * Flatten layer tree for timeline display
726
+ */
727
+ declare function flattenLayers(layers: LayerNode[], collapsedIds?: Set<string>): LayerNode[];
728
+ declare function useComposition(initialComposition: Composition): {
729
+ state: AnimationEditorState;
730
+ dispatch: React$1.Dispatch<EditorAction>;
731
+ selectedLayers: LayerNode[];
732
+ flattenedLayers: LayerNode[];
733
+ };
734
+
735
+ /**
736
+ * usePlayback Hook
737
+ *
738
+ * Handles playback timing, audio synchronization, and animation frame updates.
739
+ */
740
+
741
+ interface PlaybackOptions {
742
+ duration: Timecode;
743
+ currentTime: Timecode;
744
+ isPlaying: boolean;
745
+ playbackRate: number;
746
+ audioTracks?: AudioTrack[];
747
+ onTimeUpdate: (time: Timecode) => void;
748
+ onPlaybackEnd?: () => void;
749
+ }
750
+ declare function usePlayback({ duration, currentTime, isPlaying, playbackRate, audioTracks, onTimeUpdate, onPlaybackEnd, }: PlaybackOptions): {
751
+ seek: (time: Timecode) => void;
752
+ getAudioWaveform: (trackId: string) => Promise<number[] | null>;
753
+ audioElements: Map<string, HTMLAudioElement>;
754
+ };
755
+
756
+ /**
757
+ * useKeyframes Hook
758
+ *
759
+ * Interpolates keyframe values at a given time.
760
+ */
761
+
762
+ /**
763
+ * Interpolate keyframe properties at a given time
764
+ */
765
+ declare function interpolateKeyframes(keyframes: TimelineKeyframe[], time: Timecode): KeyframeProperties;
766
+ /**
767
+ * Get computed properties for a layer at a given time
768
+ * Combines layer base properties with keyframe interpolation
769
+ */
770
+ declare function getLayerPropertiesAtTime(layer: LayerNode, time: Timecode): KeyframeProperties & {
771
+ layerVisible: boolean;
772
+ layerOpacity: number;
773
+ };
774
+ interface UseKeyframesOptions {
775
+ layers: LayerNode[];
776
+ currentTime: Timecode;
777
+ }
778
+ interface LayerState {
779
+ id: string;
780
+ properties: KeyframeProperties & {
781
+ layerVisible: boolean;
782
+ layerOpacity: number;
783
+ };
784
+ }
785
+ /**
786
+ * Hook to get interpolated properties for all layers at current time
787
+ */
788
+ declare function useKeyframes({ layers, currentTime }: UseKeyframesOptions): {
789
+ layerStates: LayerState[];
790
+ layerStatesMap: Map<string, LayerState>;
791
+ getLayerState: (layerId: string) => LayerState | undefined;
792
+ };
793
+
794
+ interface LayerPanelProps {
795
+ layers: LayerNode[];
796
+ selectedIds: string[];
797
+ onSelect: (layerId: string, additive: boolean) => void;
798
+ onToggleVisibility: (layerId: string) => void;
799
+ onToggleLock: (layerId: string) => void;
800
+ onToggleCollapsed: (folderId: string) => void;
801
+ onAddFolder: () => void;
802
+ onAddItem: (type: 'image' | 'text' | 'shape') => void;
803
+ onDelete: (layerId: string) => void;
804
+ onRename: (layerId: string, name: string) => void;
805
+ }
806
+ declare function LayerPanel({ layers, selectedIds, onSelect, onToggleVisibility, onToggleLock, onToggleCollapsed, onAddFolder, onAddItem, onDelete, onRename, }: LayerPanelProps): react_jsx_runtime.JSX.Element;
807
+
808
+ interface TimelineProps {
809
+ composition: Composition;
810
+ currentTime: Timecode;
811
+ isPlaying: boolean;
812
+ zoom: number;
813
+ scrollX: number;
814
+ selectedLayerIds: string[];
815
+ selectedKeyframeIds: string[];
816
+ snapToGrid: boolean;
817
+ gridSize: Timecode;
818
+ onSeek: (time: Timecode) => void;
819
+ onZoomChange: (zoom: number) => void;
820
+ onScrollChange: (scrollX: number) => void;
821
+ onKeyframeSelect: (keyframeId: string, additive: boolean) => void;
822
+ onKeyframeMove: (layerId: string, keyframeId: string, newTime: Timecode) => void;
823
+ onKeyframeAdd: (layerId: string, time: Timecode) => void;
824
+ onKeyframeDelete: (layerId: string, keyframeId: string) => void;
825
+ onPlay: () => void;
826
+ onPause: () => void;
827
+ onStop: () => void;
828
+ }
829
+ declare function Timeline({ composition, currentTime, isPlaying, zoom, scrollX, selectedLayerIds, selectedKeyframeIds, snapToGrid, gridSize, onSeek, onZoomChange, onScrollChange, onKeyframeSelect, onKeyframeMove, onKeyframeAdd, onKeyframeDelete, onPlay, onPause, onStop, }: TimelineProps): react_jsx_runtime.JSX.Element;
830
+
831
+ interface PreviewCanvasProps {
832
+ composition: Composition;
833
+ currentTime: Timecode;
834
+ selectedLayerIds: string[];
835
+ onLayerSelect: (layerId: string) => void;
836
+ onClearSelection: () => void;
837
+ }
838
+ declare function PreviewCanvas({ composition, currentTime, selectedLayerIds, onLayerSelect, onClearSelection, }: PreviewCanvasProps): react_jsx_runtime.JSX.Element;
839
+
840
+ interface PropertiesPanelProps {
841
+ selectedLayers: LayerNode[];
842
+ currentTime: Timecode;
843
+ onUpdateLayer: (layerId: string, updates: Partial<LayerNode>) => void;
844
+ onAddKeyframe: (layerId: string, property: string) => void;
845
+ }
846
+ declare function PropertiesPanel({ selectedLayers, currentTime, onUpdateLayer, onAddKeyframe, }: PropertiesPanelProps): react_jsx_runtime.JSX.Element;
847
+
349
848
  interface UseCarouselOptions {
350
849
  slides: Slide[];
351
850
  initialIndex?: number;
@@ -398,7 +897,7 @@ declare const createSlide: {
398
897
  component: (id: string, render: (props: {
399
898
  isActive: boolean;
400
899
  slideIndex: number;
401
- }) => React$1.ReactNode, options?: Partial<Omit<Slide, "id" | "layers">>) => Slide;
900
+ }) => React__default.ReactNode, options?: Partial<Omit<Slide, "id" | "layers">>) => Slide;
402
901
  /**
403
902
  * Create a slide to display a markdown file
404
903
  */
@@ -415,4 +914,4 @@ declare const createSlide: {
415
914
  }) => Slide;
416
915
  };
417
916
 
418
- export { type Animation, type AnimationKeyframe, type AudioObject, type AutoplayOptions, type BaseObject, Carousel, type CarouselInfo, type CarouselProps, type CarouselRef, type ComponentObject, type GroupObject, type ImageObject, type Layer, type NavigationOptions, type ObjectType, type Position, type ShapeObject, type Size, type Slide, type SlideBackground, type SlideObject, SlideRenderer, type SlideTransition, type TextObject, Thumbnails, type Transform, type TransitionType, type VideoObject, createImageSlide, createSimpleSlide, createSlide, useCarousel };
917
+ export { type Animation, AnimationEditor, type AnimationEditorContextValue, type AnimationEditorProps, type AnimationEditorState, type AnimationKeyframe, type AudioObject, type AudioTrack, type AutoplayOptions, type BaseObject, type BlendMode, Carousel, type CarouselInfo, type CarouselProps, type CarouselRef, type ComponentObject, type Composition, type EasingType, type EditorAction, type EditorSelection, type EditorTool, type GroupObject, type ImageObject, type KeyframeProperties, type Layer, type LayerFolder, type LayerItem, type LayerNode, LayerPanel, type LayerPanelProps$1 as LayerPanelProps, type NavigationOptions, type ObjectType, type PanelState, type PlaybackState, type Position, PreviewCanvas, type PreviewCanvasProps$1 as PreviewCanvasProps, PropertiesPanel, type PropertiesPanelProps$1 as PropertiesPanelProps, type ShapeObject, type Size, type Slide, type SlideBackground, type SlideObject, SlideRenderer, type SlideTransition, type TextObject, Thumbnails, type Timecode, Timeline, type TimelineKeyframe, type TimelineProps$1 as TimelineProps, type TimelineViewState, type Transform, type TransitionType, type VideoObject, createComposition, createImageSlide, createKeyframe, createLayerFolder, createLayerItem, createSimpleSlide, createSlide, findLayerById, flattenLayers, formatTimecode, getLayerPropertiesAtTime, interpolateKeyframes, parseTimecode, useCarousel, useComposition, useKeyframes, usePlayback };