| 1 | import type { CSSProperties, ReactNode, ElementType, Ref, ReactElement } from 'react'; |
| 2 | import type { |
| 3 | FragmentAnimation, |
| 4 | MarkdownConfig, |
| 5 | RevealApi, |
| 6 | RevealConfig, |
| 7 | RevealPlugin, |
| 8 | RevealPluginFactory, |
| 9 | TransitionSpeed, |
| 10 | TransitionStyle, |
| 11 | } from 'reveal.js'; |
| 12 | |
| 13 | type DeckConfig = RevealConfig; |
| 14 | type DeckPlugin = RevealPlugin | RevealPluginFactory; |
| 15 | type RevealEventHandler = Parameters<RevealApi['on']>[1]; |
| 16 | |
| 17 | export type DeckProps = { |
| 18 | config?: Omit<DeckConfig, 'plugins'>; |
| 19 | /** Registered during deck initialization only. Subsequent prop updates are ignored. */ |
| 20 | plugins?: DeckPlugin[]; |
| 21 | onReady?: (deck: RevealApi) => void; |
| 22 | onSync?: RevealEventHandler; |
| 23 | onSlideSync?: RevealEventHandler; |
| 24 | onSlideChange?: RevealEventHandler; |
| 25 | onSlideTransitionEnd?: RevealEventHandler; |
| 26 | onFragmentShown?: RevealEventHandler; |
| 27 | onFragmentHidden?: RevealEventHandler; |
| 28 | onOverviewShown?: RevealEventHandler; |
| 29 | onOverviewHidden?: RevealEventHandler; |
| 30 | onPaused?: RevealEventHandler; |
| 31 | onResumed?: RevealEventHandler; |
| 32 | deckRef?: Ref<RevealApi | null>; |
| 33 | className?: string; |
| 34 | style?: CSSProperties; |
| 35 | children?: ReactNode; |
| 36 | }; |
| 37 | |
| 38 | export type SlideDataAttributeValue = string | number | boolean | undefined; |
| 39 | |
| 40 | export type SlideDataAttributes = { |
| 41 | [key: `data-${string}`]: SlideDataAttributeValue; |
| 42 | }; |
| 43 | |
| 44 | export type SlideBackgroundProps = { |
| 45 | background?: string; |
| 46 | backgroundImage?: string; |
| 47 | backgroundVideo?: string; |
| 48 | backgroundVideoLoop?: boolean; |
| 49 | backgroundVideoMuted?: boolean; |
| 50 | backgroundIframe?: string; |
| 51 | backgroundColor?: string; |
| 52 | backgroundGradient?: string; |
| 53 | backgroundSize?: string; |
| 54 | backgroundPosition?: string; |
| 55 | backgroundRepeat?: string; |
| 56 | backgroundOpacity?: number | string; |
| 57 | backgroundTransition?: TransitionStyle; |
| 58 | }; |
| 59 | |
| 60 | export type SlideVisibility = 'hidden' | 'uncounted'; |
| 61 | |
| 62 | export type SlideAutoAnimateProps = { |
| 63 | visibility?: SlideVisibility; |
| 64 | autoAnimate?: boolean; |
| 65 | autoAnimateId?: string; |
| 66 | autoAnimateRestart?: boolean; |
| 67 | autoAnimateUnmatched?: boolean; |
| 68 | autoAnimateEasing?: string; |
| 69 | autoAnimateDuration?: number | string; |
| 70 | autoAnimateDelay?: number | string; |
| 71 | }; |
| 72 | |
| 73 | export type SlideRevealProps = { |
| 74 | transition?: string; |
| 75 | transitionSpeed?: TransitionSpeed; |
| 76 | autoSlide?: number | string; |
| 77 | notes?: string; |
| 78 | backgroundInteractive?: boolean; |
| 79 | preload?: boolean; |
| 80 | }; |
| 81 | |
| 82 | export type SlideProps = React.HTMLAttributes<HTMLElement> & |
| 83 | SlideDataAttributes & |
| 84 | SlideBackgroundProps & |
| 85 | SlideAutoAnimateProps & |
| 86 | SlideRevealProps & { |
| 87 | children?: ReactNode; |
| 88 | }; |
| 89 | |
| 90 | export type MarkdownOptions = Omit< |
| 91 | MarkdownConfig, |
| 92 | 'async' | 'separator' | 'verticalSeparator' | 'notesSeparator' | 'attributes' |
| 93 | > & { |
| 94 | animateLists?: boolean; |
| 95 | }; |
| 96 | |
| 97 | export type MarkdownProps = Omit<SlideProps, 'children'> & { |
| 98 | children?: string; |
| 99 | markdown?: string; |
| 100 | src?: string; |
| 101 | charset?: string; |
| 102 | separator?: string; |
| 103 | verticalSeparator?: string | null; |
| 104 | notesSeparator?: string; |
| 105 | elementAttributesSeparator?: string; |
| 106 | slideAttributesSeparator?: string; |
| 107 | options?: MarkdownOptions; |
| 108 | }; |
| 109 | |
| 110 | export type StackProps = { |
| 111 | className?: string; |
| 112 | style?: CSSProperties; |
| 113 | children?: ReactNode; |
| 114 | }; |
| 115 | |
| 116 | type FragmentBaseProps = { |
| 117 | animation?: FragmentAnimation; |
| 118 | className?: string; |
| 119 | style?: CSSProperties; |
| 120 | index?: number; |
| 121 | }; |
| 122 | |
| 123 | type FragmentElementProps = FragmentBaseProps & { |
| 124 | asChild?: false; |
| 125 | as?: ElementType; |
| 126 | children?: ReactNode; |
| 127 | }; |
| 128 | |
| 129 | type FragmentAsChildProps = FragmentBaseProps & { |
| 130 | asChild: true; |
| 131 | as?: never; |
| 132 | children: ReactElement; |
| 133 | }; |
| 134 | |
| 135 | export type FragmentProps = FragmentElementProps | FragmentAsChildProps; |
| 136 | |
| 137 | export type CodeProps = Omit<React.HTMLAttributes<HTMLPreElement>, 'children'> & { |
| 138 | children?: string; |
| 139 | code?: string; |
| 140 | language?: string; |
| 141 | trim?: boolean; |
| 142 | lineNumbers?: boolean | string; |
| 143 | startFrom?: number; |
| 144 | noEscape?: boolean; |
| 145 | codeClassName?: string; |
| 146 | codeStyle?: CSSProperties; |
| 147 | codeProps?: Omit<React.HTMLAttributes<HTMLElement>, 'children' | 'className' | 'style'>; |
| 148 | }; |
| 149 |