@gravity-ui/page-constructor 8.14.2 → 8.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/build/cjs/components/ReactPlayer/ReactPlayer.css +0 -50
  2. package/build/cjs/components/ReactPlayer/ReactPlayer.js +4 -16
  3. package/build/cjs/components/ReactPlayer/ReactPlayer.js.map +1 -1
  4. package/build/cjs/components/VideoBlock/VideoBlock.css +0 -30
  5. package/build/cjs/components/VideoBlock/VideoBlock.d.ts +2 -1
  6. package/build/cjs/components/VideoBlock/VideoBlock.js +18 -2
  7. package/build/cjs/components/VideoBlock/VideoBlock.js.map +1 -1
  8. package/build/cjs/components/VideoButton/VideoButton.css +64 -0
  9. package/build/cjs/components/VideoButton/VideoButton.d.ts +9 -0
  10. package/build/cjs/components/VideoButton/VideoButton.js +50 -0
  11. package/build/cjs/components/VideoButton/VideoButton.js.map +1 -0
  12. package/build/cjs/context/projectSettingsContext/ProjectSettingsContext.d.ts +7 -0
  13. package/build/cjs/context/projectSettingsContext/ProjectSettingsContext.js.map +1 -1
  14. package/build/cjs/models/constructor-items/common.d.ts +8 -1
  15. package/build/cjs/models/constructor-items/common.js +1 -0
  16. package/build/cjs/models/constructor-items/common.js.map +1 -1
  17. package/build/esm/components/ReactPlayer/ReactPlayer.css +0 -50
  18. package/build/esm/components/ReactPlayer/ReactPlayer.js +4 -16
  19. package/build/esm/components/ReactPlayer/ReactPlayer.js.map +1 -1
  20. package/build/esm/components/VideoBlock/VideoBlock.css +0 -30
  21. package/build/esm/components/VideoBlock/VideoBlock.d.ts +2 -1
  22. package/build/esm/components/VideoBlock/VideoBlock.js +19 -3
  23. package/build/esm/components/VideoBlock/VideoBlock.js.map +1 -1
  24. package/build/esm/components/VideoButton/VideoButton.css +64 -0
  25. package/build/esm/components/VideoButton/VideoButton.d.ts +10 -0
  26. package/build/esm/components/VideoButton/VideoButton.js +48 -0
  27. package/build/esm/components/VideoButton/VideoButton.js.map +1 -0
  28. package/build/esm/context/projectSettingsContext/ProjectSettingsContext.d.ts +7 -0
  29. package/build/esm/context/projectSettingsContext/ProjectSettingsContext.js.map +1 -1
  30. package/build/esm/models/constructor-items/common.d.ts +8 -1
  31. package/build/esm/models/constructor-items/common.js +1 -0
  32. package/build/esm/models/constructor-items/common.js.map +1 -1
  33. package/package.json +1 -1
  34. package/server/models/constructor-items/common.d.ts +8 -1
  35. package/server/models/constructor-items/common.js +1 -0
  36. package/widget/index.js +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"../../../../src","sources":["models/constructor-items/common.ts"],"names":[],"mappings":";;;AAQA,QAAQ;AACR,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,+BAAiB,CAAA;IACjB,2BAAa,CAAA;AACjB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAED,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IACxB,+CAA2B,CAAA;IAC3B,yCAAqB,CAAA;AACzB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAY,eAMX;AAND,WAAY,eAAe;IACvB,gCAAa,CAAA;IACb,kCAAe,CAAA;IACf,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,8BAAW,CAAA;AACf,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,qCAAmB,CAAA;IACnB,+BAAa,CAAA;AACjB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IACxB,iCAAa,CAAA;IACb,iCAAa,CAAA;AACjB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC1B,yDAAmC,CAAA;IACnC,oEAA8C,CAAA;AAClD,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAED,IAAY,+BAIX;AAJD,WAAY,+BAA+B;IACvC,gDAAa,CAAA;IACb,kDAAe,CAAA;IACf,oDAAiB,CAAA;AACrB,CAAC,EAJW,+BAA+B,+CAA/B,+BAA+B,QAI1C;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;AACrB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAC9B,6CAAmB,CAAA;IACnB,2CAAiB,CAAA;AACrB,CAAC,EAHW,sBAAsB,sCAAtB,sBAAsB,QAGjC;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACjB,gCAAmB,CAAA;IACnB,6CAAgC,CAAA;AACpC,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAuED,SAAS;AAET,IAAY,MAIX;AAJD,WAAY,MAAM;IACd,6BAAmB,CAAA;IACnB,2BAAiB,CAAA;IACjB,2BAAiB,CAAA;AACrB,CAAC,EAJW,MAAM,sBAAN,MAAM,QAIjB","sourcesContent":["import * as React from 'react';\n\nimport * as icons from '@gravity-ui/icons';\nimport {ButtonView, IconData, ButtonProps as UikitButtonProps} from '@gravity-ui/uikit';\n\nimport {ThemeSupporting} from '../../utils';\nimport {AnalyticsEventsBase, AnalyticsEventsProp, ClassNameProps, QAProps} from '../common';\n\n// enums\nexport enum AuthorType {\n Column = 'column',\n Line = 'line',\n}\n\nexport enum PriceDetailsType {\n MARKED_LIST = 'marked-list',\n SETTINGS = 'settings',\n}\n\nexport enum PriceLabelColor {\n BLUE = 'blue',\n GREEN = 'green',\n YELLOW = 'yellow',\n PURPLE = 'purple',\n RED = 'red',\n}\n\nexport enum PlayButtonType {\n Default = 'default',\n Text = 'text',\n}\n\nexport enum PlayButtonThemes {\n Blue = 'blue',\n Grey = 'grey',\n}\n\nexport enum CustomControlsType {\n WithMuteButton = 'with-mute-button',\n WithPlayPauseButton = 'with-play-pause-button',\n}\n\nexport enum CustomControlsButtonPositioning {\n Left = 'left',\n Right = 'right',\n Center = 'center',\n}\n\nexport enum MediaVideoType {\n Default = 'default',\n Player = 'player',\n}\n\nexport enum MediaVideoControlsType {\n Default = 'default',\n Custom = 'custom',\n}\n\nexport enum QuoteType {\n Chevron = 'chevron', // « »\n EnglishDouble = 'english-double', // “ ”\n}\n\n// types\nexport type TextTheme = 'light' | 'dark';\nexport type TextSize = 'xs' | 's' | 'sm' | 'm' | 'l';\nexport type DividerSize = '0' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';\nexport type HeaderWidth = 's' | 'm' | 'l';\nexport type HeaderImageSize = 's' | 'm';\nexport type HeaderOffset = 'default' | 'large';\nexport type Justify = 'start' | 'center' | 'end';\nexport type ColumnsCount = 1 | 2 | 3 | 4;\nexport type LegendTableMarkerType = 'disk' | 'tick';\nexport type LinkTheme = 'file-link' | 'normal' | 'back' | 'underline';\nexport type MediaDirection = 'media-content' | 'content-media';\nexport type PriceDescriptionColor = 'cornflower' | 'black';\nexport type ContentSize = 's' | 'm' | 'l' | 'xl';\nexport type ContentTextSize = 's' | 'm' | 'l';\nexport type ContentTheme = 'default' | 'dark' | 'light';\nexport type FileLinkType = 'vertical' | 'horizontal';\nexport type ImageCardMargins = 's' | 'm';\nexport type LayoutItemContentMargin = 'm' | 'l';\nexport type GravityIconProps = string | {name: keyof typeof icons; color: 'brand' | 'text-color'};\n\n// modifiers\nexport interface Themable {\n theme?: TextTheme;\n}\n\nexport interface Justifyable {\n justify?: Justify;\n}\n\nexport interface Stylable {\n className?: string;\n}\n\nexport interface Animatable {\n animated?: boolean;\n}\n\nexport interface Tabbable {\n tabIndex?: number;\n}\n\nexport interface Roleable {\n role?: React.AriaRole;\n}\n\nexport interface AriaProps {\n ariaProps?: React.AriaAttributes;\n}\n\n//common props\nexport interface Background {\n image?: string;\n color?: string;\n}\n\nexport interface AnchorProps {\n text: string;\n url: string;\n}\n\n/**\n * @deprecated Component VideoBlock will be deleted, which uses this logic\n */\ninterface LoopProps {\n start: number;\n end?: number;\n}\n\n// images\n\nexport enum Device {\n Desktop = 'desktop',\n Mobile = 'mobile',\n Tablet = 'tablet',\n}\n\nexport interface ImageInfoProps\n extends Pick<\n React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>,\n 'aria-describedby' | 'loading'\n >,\n ImageDevicesVisibleProps {\n alt?: string;\n fetchPriority?: 'high' | 'low' | 'auto';\n disableCompress?: boolean;\n}\n\nexport interface ImageObjectProps extends ImageInfoProps {\n src: string;\n}\n\nexport interface ImageDeviceProps extends ImageInfoProps {\n [Device.Desktop]: string;\n [Device.Mobile]: string;\n [Device.Tablet]?: string;\n}\n\nexport interface ImageDevicesVisibleProps {\n hide?: boolean | Partial<Record<Device, boolean>>;\n}\n\nexport type ImageProps = string | ImageObjectProps | ImageDeviceProps;\nexport type ThemedImage = ThemeSupporting<ImageProps>;\n\nexport interface BackgroundImageProps\n extends React.HTMLProps<HTMLDivElement>,\n Partial<ImageDeviceProps>,\n Partial<ImageObjectProps>,\n QAProps,\n ImageDevicesVisibleProps {\n style?: React.CSSProperties;\n imageClassName?: string;\n}\n\n//components props\nexport interface MediaVideoProps extends AnalyticsEventsBase {\n src: string[];\n type?: MediaVideoType;\n loop?: LoopProps | boolean;\n muted?: boolean;\n autoplay?: boolean;\n elapsedTime?: number;\n playButton?: PlayButtonProps;\n controls?: MediaVideoControlsType;\n customControlsOptions?: CustomControlsOptions;\n ariaLabel?: string;\n contain?: boolean;\n onVideoEnd?: () => void;\n ref?: React.Ref<HTMLVideoElement | null>;\n}\n\n// links\nexport interface LinkProps extends AnalyticsEventsBase, Stylable, Tabbable {\n url: string;\n urlTitle?: string;\n text?: string;\n textSize?: TextSize;\n theme?: LinkTheme;\n colorTheme?: TextTheme;\n arrow?: boolean;\n target?: string;\n extraProps?: React.HTMLProps<HTMLAnchorElement>;\n}\n\nexport interface FileLinkProps extends ClassNameProps, Tabbable {\n href: string;\n text: React.ReactNode;\n type?: FileLinkType;\n textSize?: TextSize;\n theme?: ContentTheme;\n urlTitle?: string;\n onClick?: () => void;\n extraProps?: React.HTMLProps<HTMLAnchorElement>;\n}\n\n// buttons\nexport type ButtonTheme =\n | ButtonView\n | 'github'\n | 'app-store'\n | 'google-play'\n | 'scale'\n | 'monochrome';\n\nexport interface ButtonProps extends AnalyticsEventsBase {\n text: string;\n url: string;\n urlTitle?: string;\n primary?: boolean;\n theme?: ButtonTheme;\n img?: ButtonImageProps | string;\n target?: string;\n size?: UikitButtonProps['size'];\n width?: UikitButtonProps['width'];\n extraProps?: UikitButtonProps['extraProps'];\n}\n\nexport type ButtonImagePosition = 'left' | 'right';\n\nexport interface ButtonImageProps {\n url?: string;\n position?: ButtonImagePosition;\n alt?: string;\n iconData?: IconData;\n iconSize?: number;\n className?: string;\n}\n\nexport interface CustomControlsOptions {\n type?: CustomControlsType;\n muteButtonShown?: boolean;\n positioning?: CustomControlsButtonPositioning;\n}\n\nexport interface PlayButtonProps extends ClassNameProps {\n type?: PlayButtonType;\n theme?: PlayButtonThemes;\n text?: string;\n}\n\nexport type ThemedMediaVideoProps = ThemeSupporting<MediaVideoProps>;\n\nexport interface MediaComponentVideoProps extends AnalyticsEventsBase {\n video: MediaVideoProps;\n height?: number;\n ratio?: number | 'auto';\n previewImg?: string;\n}\n\nexport interface MediaComponentVideoIframeProps {\n videoIframe: string;\n}\n\nexport interface MediaComponentYoutubeProps {\n youtube: string;\n previewImg?: string;\n fullscreen?: boolean;\n}\n\nexport interface MediaComponentImageProps {\n image: ImageProps | ImageProps[] | ImageDeviceProps;\n video?: MediaVideoProps;\n parallax?: boolean;\n height?: number;\n disableImageSliderForArrayInput?: boolean;\n}\n\nexport interface MediaComponentDataLensProps {\n dataLens: DataLensProps;\n}\n\nexport interface MediaComponentIframeProps {\n iframe: IframeProps;\n margins?: boolean;\n}\n\nexport interface MediaProps\n extends Animatable,\n Partial<MediaComponentDataLensProps>,\n Partial<MediaComponentYoutubeProps>,\n Partial<MediaComponentVideoIframeProps>,\n Partial<MediaComponentImageProps>,\n Partial<MediaComponentIframeProps>,\n Partial<MediaComponentVideoProps> {\n color?: string;\n videoMicrodata?: {\n name?: string;\n description?: string;\n duration?: string;\n uploadDate?: string;\n contentUrl?: string;\n thumbnailUrl?: string;\n };\n}\n\nexport interface BackgroundMediaProps extends MediaProps, Animatable, QAProps {\n fullWidthMedia?: boolean;\n className?: string;\n mediaClassName?: string;\n}\n\nexport type Coordinate = [number, number];\n\nexport interface MapBaseProps {\n zoom?: number;\n className?: string;\n forceAspectRatio?: boolean;\n}\n\nexport interface GMapProps extends MapBaseProps {\n address: string;\n}\n\nexport type YMapMargin =\n | number\n | [vertical: number, horizontal: number]\n | [top: number, right: number, bottom: number, left: number];\n\nexport interface YMapCopyrightPosition {\n top?: number;\n right?: number;\n bottom?: number;\n left?: number;\n}\n\nexport interface YMapProps extends MapBaseProps {\n markers: YMapMarker[];\n disableControls?: boolean;\n disableBalloons?: boolean;\n areaMargin?: YMapMargin;\n copyrightPosition?: YMapCopyrightPosition;\n id: string;\n}\n\nexport interface YMapMarker {\n address?: string;\n coordinate?: Coordinate;\n label?: YMapMarkerLabel;\n}\n\nexport interface YMapMarkerLabel {\n iconCaption?: string;\n iconContent?: string;\n iconColor?: string;\n iconImageHref?: string;\n iconImageSize?: [number, number];\n iconImageOffset?: [number, number];\n iconImageClipRect?: [[number, number], [number, number]];\n iconLayout?: 'default#image';\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n iconShape?: Record<string, any>;\n preset?: string;\n}\n\nexport interface YMapMarkerPrivate extends YMapMarker {\n label?: YMapMarkerLabelPrivate;\n}\n\nexport interface YMapMarkerLabelPrivate extends YMapMarkerLabel {\n cursor?: string;\n interactivityModel?: string;\n}\n\nexport type MapProps = GMapProps | YMapProps;\n\nexport type ThemedMediaProps = ThemeSupporting<MediaProps>;\n\nexport interface DataLensObjectProps {\n id: string;\n theme: 'dark' | 'light';\n}\n\nexport interface IframeProps {\n src: string;\n width?: number;\n height?: number;\n title?: string;\n name?: string;\n}\n\nexport type DataLensProps = string | DataLensObjectProps;\n\nexport interface AuthorItem {\n firstName: string;\n secondName: string;\n description?: string;\n avatar?: ThemeSupporting<ImageProps> | JSX.Element;\n}\n\nexport interface HeaderBreadCrumbsProps extends ClassNameProps, QAProps {\n items: {\n url: string;\n text: React.ReactNode;\n }[];\n theme?: TextTheme;\n analyticsEvents?: AnalyticsEventsProp;\n}\n\nexport interface TitleItemProps extends Justifyable, TitleItemBaseProps, AnalyticsEventsBase {\n navTitle?: string;\n anchor?: string;\n}\n\nexport interface TitleItemBaseProps {\n text: string;\n textSize?: TextSize;\n url?: string;\n urlTitle?: string;\n custom?: string | React.ReactNode;\n onClick?: () => void;\n}\n\nexport type MediaView = 'fit' | 'full';\n\n// card\nexport type MediaBorder = 'shadow' | 'line' | 'none';\nexport type CardBorder = MediaBorder;\nexport type ControlPosition = 'content' | 'footer';\n\nexport interface CardBaseProps {\n border?: CardBorder;\n}\n\nexport type CardLayoutProps = {\n controlPosition?: ControlPosition;\n};\n\n//price\nexport interface PriceDescriptionProps {\n title: string;\n detailedTitle?: string;\n description: string;\n label?: {\n color: PriceLabelColor;\n text?: string;\n size?: TextSize;\n };\n}\n\nexport interface PriceDetailsSettingsProps {\n title: string;\n description: string;\n}\n\nexport interface PriceDetailsListProps {\n text: string;\n}\n\nexport interface PriceDetailsProps {\n items?: PriceDetailsSettingsProps[] | PriceDetailsListProps[];\n}\n\nexport interface PriceItemProps\n extends PriceDetailsProps,\n PriceDescriptionProps,\n AnalyticsEventsBase {}\n\nexport interface PriceFoldableDetailsProps {\n title: string;\n size?: TextSize;\n titleColor?: PriceDescriptionColor;\n}\n\n/** @deprecated */\nexport interface PriceDetailedProps extends CardBaseProps {\n items: PriceItemProps[];\n description?: {\n titleSize?: TextSize;\n descriptionSize?: TextSize;\n titleColor?: PriceDescriptionColor;\n };\n details?: {\n titleSize?: TextSize;\n descriptionSize?: TextSize;\n };\n priceType?: PriceDetailsType;\n numberGroupItems?: 3 | 4 | 5;\n isCombined?: boolean;\n useMixedView?: boolean;\n foldable?: PriceFoldableDetailsProps;\n labelsDefaultText?: Record<PriceLabelColor, string>;\n}\n\nexport interface AuthorProps extends QAProps {\n author: AuthorItem;\n className?: string;\n authorContainerClassName?: string;\n type?: AuthorType;\n theme?: ContentTheme;\n}\n\nexport interface TitleProps {\n title?: TitleItemProps | string;\n subtitle?: string;\n}\n\nexport interface YandexFormProps extends AnalyticsEventsBase {\n id: number | string;\n containerId?: string;\n theme?: string;\n className?: string;\n headerHeight?: number;\n customFormOrigin?: string;\n customFormSection?: string;\n params?: {[key: string]: string};\n\n onSubmit?: () => void;\n onLoad?: () => void;\n}\n\nexport interface WithBorder {\n border?: MediaBorder;\n /**\n * @deprecated use custom class for media-component\n */\n disableShadow?: boolean;\n}\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"../../../../src","sources":["models/constructor-items/common.ts"],"names":[],"mappings":";;;AAQA,QAAQ;AACR,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,+BAAiB,CAAA;IACjB,2BAAa,CAAA;AACjB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAED,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IACxB,+CAA2B,CAAA;IAC3B,yCAAqB,CAAA;AACzB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAY,eAMX;AAND,WAAY,eAAe;IACvB,gCAAa,CAAA;IACb,kCAAe,CAAA;IACf,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,8BAAW,CAAA;AACf,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,qCAAmB,CAAA;IACnB,+BAAa,CAAA;AACjB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IACxB,iCAAa,CAAA;IACb,iCAAa,CAAA;IACb,qCAAiB,CAAA;AACrB,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B;AAED,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC1B,yDAAmC,CAAA;IACnC,oEAA8C,CAAA;AAClD,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAED,IAAY,+BAIX;AAJD,WAAY,+BAA+B;IACvC,gDAAa,CAAA;IACb,kDAAe,CAAA;IACf,oDAAiB,CAAA;AACrB,CAAC,EAJW,+BAA+B,+CAA/B,+BAA+B,QAI1C;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;AACrB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAC9B,6CAAmB,CAAA;IACnB,2CAAiB,CAAA;AACrB,CAAC,EAHW,sBAAsB,sCAAtB,sBAAsB,QAGjC;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACjB,gCAAmB,CAAA;IACnB,6CAAgC,CAAA;AACpC,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAuED,SAAS;AAET,IAAY,MAIX;AAJD,WAAY,MAAM;IACd,6BAAmB,CAAA;IACnB,2BAAiB,CAAA;IACjB,2BAAiB,CAAA;AACrB,CAAC,EAJW,MAAM,sBAAN,MAAM,QAIjB","sourcesContent":["import * as React from 'react';\n\nimport * as icons from '@gravity-ui/icons';\nimport {ButtonView, IconData, ButtonProps as UikitButtonProps} from '@gravity-ui/uikit';\n\nimport {ThemeSupporting} from '../../utils';\nimport {AnalyticsEventsBase, AnalyticsEventsProp, ClassNameProps, QAProps} from '../common';\n\n// enums\nexport enum AuthorType {\n Column = 'column',\n Line = 'line',\n}\n\nexport enum PriceDetailsType {\n MARKED_LIST = 'marked-list',\n SETTINGS = 'settings',\n}\n\nexport enum PriceLabelColor {\n BLUE = 'blue',\n GREEN = 'green',\n YELLOW = 'yellow',\n PURPLE = 'purple',\n RED = 'red',\n}\n\nexport enum PlayButtonType {\n Default = 'default',\n Text = 'text',\n}\n\nexport enum PlayButtonThemes {\n Blue = 'blue',\n Grey = 'grey',\n Custom = 'custom',\n}\n\nexport enum CustomControlsType {\n WithMuteButton = 'with-mute-button',\n WithPlayPauseButton = 'with-play-pause-button',\n}\n\nexport enum CustomControlsButtonPositioning {\n Left = 'left',\n Right = 'right',\n Center = 'center',\n}\n\nexport enum MediaVideoType {\n Default = 'default',\n Player = 'player',\n}\n\nexport enum MediaVideoControlsType {\n Default = 'default',\n Custom = 'custom',\n}\n\nexport enum QuoteType {\n Chevron = 'chevron', // « »\n EnglishDouble = 'english-double', // “ ”\n}\n\n// types\nexport type TextTheme = 'light' | 'dark';\nexport type TextSize = 'xs' | 's' | 'sm' | 'm' | 'l';\nexport type DividerSize = '0' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';\nexport type HeaderWidth = 's' | 'm' | 'l';\nexport type HeaderImageSize = 's' | 'm';\nexport type HeaderOffset = 'default' | 'large';\nexport type Justify = 'start' | 'center' | 'end';\nexport type ColumnsCount = 1 | 2 | 3 | 4;\nexport type LegendTableMarkerType = 'disk' | 'tick';\nexport type LinkTheme = 'file-link' | 'normal' | 'back' | 'underline';\nexport type MediaDirection = 'media-content' | 'content-media';\nexport type PriceDescriptionColor = 'cornflower' | 'black';\nexport type ContentSize = 's' | 'm' | 'l' | 'xl';\nexport type ContentTextSize = 's' | 'm' | 'l';\nexport type ContentTheme = 'default' | 'dark' | 'light';\nexport type FileLinkType = 'vertical' | 'horizontal';\nexport type ImageCardMargins = 's' | 'm';\nexport type LayoutItemContentMargin = 'm' | 'l';\nexport type GravityIconProps = string | {name: keyof typeof icons; color: 'brand' | 'text-color'};\n\n// modifiers\nexport interface Themable {\n theme?: TextTheme;\n}\n\nexport interface Justifyable {\n justify?: Justify;\n}\n\nexport interface Stylable {\n className?: string;\n}\n\nexport interface Animatable {\n animated?: boolean;\n}\n\nexport interface Tabbable {\n tabIndex?: number;\n}\n\nexport interface Roleable {\n role?: React.AriaRole;\n}\n\nexport interface AriaProps {\n ariaProps?: React.AriaAttributes;\n}\n\n//common props\nexport interface Background {\n image?: string;\n color?: string;\n}\n\nexport interface AnchorProps {\n text: string;\n url: string;\n}\n\n/**\n * @deprecated Component VideoBlock will be deleted, which uses this logic\n */\ninterface LoopProps {\n start: number;\n end?: number;\n}\n\n// images\n\nexport enum Device {\n Desktop = 'desktop',\n Mobile = 'mobile',\n Tablet = 'tablet',\n}\n\nexport interface ImageInfoProps\n extends Pick<\n React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>,\n 'aria-describedby' | 'loading'\n >,\n ImageDevicesVisibleProps {\n alt?: string;\n fetchPriority?: 'high' | 'low' | 'auto';\n disableCompress?: boolean;\n}\n\nexport interface ImageObjectProps extends ImageInfoProps {\n src: string;\n}\n\nexport interface ImageDeviceProps extends ImageInfoProps {\n [Device.Desktop]: string;\n [Device.Mobile]: string;\n [Device.Tablet]?: string;\n}\n\nexport interface ImageDevicesVisibleProps {\n hide?: boolean | Partial<Record<Device, boolean>>;\n}\n\nexport type ImageProps = string | ImageObjectProps | ImageDeviceProps;\nexport type ThemedImage = ThemeSupporting<ImageProps>;\n\nexport interface BackgroundImageProps\n extends React.HTMLProps<HTMLDivElement>,\n Partial<ImageDeviceProps>,\n Partial<ImageObjectProps>,\n QAProps,\n ImageDevicesVisibleProps {\n style?: React.CSSProperties;\n imageClassName?: string;\n}\n\n//components props\nexport interface MediaVideoProps extends AnalyticsEventsBase {\n src: string[];\n type?: MediaVideoType;\n loop?: LoopProps | boolean;\n muted?: boolean;\n autoplay?: boolean;\n elapsedTime?: number;\n playButton?: PlayButtonProps;\n controls?: MediaVideoControlsType;\n customControlsOptions?: CustomControlsOptions;\n ariaLabel?: string;\n contain?: boolean;\n onVideoEnd?: () => void;\n ref?: React.Ref<HTMLVideoElement | null>;\n}\n\n// links\nexport interface LinkProps extends AnalyticsEventsBase, Stylable, Tabbable {\n url: string;\n urlTitle?: string;\n text?: string;\n textSize?: TextSize;\n theme?: LinkTheme;\n colorTheme?: TextTheme;\n arrow?: boolean;\n target?: string;\n extraProps?: React.HTMLProps<HTMLAnchorElement>;\n}\n\nexport interface FileLinkProps extends ClassNameProps, Tabbable {\n href: string;\n text: React.ReactNode;\n type?: FileLinkType;\n textSize?: TextSize;\n theme?: ContentTheme;\n urlTitle?: string;\n onClick?: () => void;\n extraProps?: React.HTMLProps<HTMLAnchorElement>;\n}\n\n// buttons\nexport type ButtonTheme =\n | ButtonView\n | 'github'\n | 'app-store'\n | 'google-play'\n | 'scale'\n | 'monochrome';\n\nexport interface ButtonProps extends AnalyticsEventsBase {\n text: string;\n url: string;\n urlTitle?: string;\n primary?: boolean;\n theme?: ButtonTheme;\n img?: ButtonImageProps | string;\n target?: string;\n size?: UikitButtonProps['size'];\n width?: UikitButtonProps['width'];\n extraProps?: UikitButtonProps['extraProps'];\n}\n\nexport type ButtonImagePosition = 'left' | 'right';\n\nexport interface ButtonImageProps {\n url?: string;\n position?: ButtonImagePosition;\n alt?: string;\n iconData?: IconData;\n iconSize?: number;\n className?: string;\n}\n\nexport interface CustomControlsOptions {\n type?: CustomControlsType;\n muteButtonShown?: boolean;\n positioning?: CustomControlsButtonPositioning;\n}\n\nexport interface PlayButtonColors {\n circleColor?: string;\n circleHoverColor?: string;\n triangleColor?: string;\n triangleHoverColor?: string;\n}\n\nexport interface PlayButtonProps extends ClassNameProps {\n type?: PlayButtonType;\n theme?: PlayButtonThemes;\n text?: string;\n}\n\nexport type ThemedMediaVideoProps = ThemeSupporting<MediaVideoProps>;\n\nexport interface MediaComponentVideoProps extends AnalyticsEventsBase {\n video: MediaVideoProps;\n height?: number;\n ratio?: number | 'auto';\n previewImg?: string;\n}\n\nexport interface MediaComponentVideoIframeProps {\n videoIframe: string;\n}\n\nexport interface MediaComponentYoutubeProps {\n youtube: string;\n previewImg?: string;\n fullscreen?: boolean;\n}\n\nexport interface MediaComponentImageProps {\n image: ImageProps | ImageProps[] | ImageDeviceProps;\n video?: MediaVideoProps;\n parallax?: boolean;\n height?: number;\n disableImageSliderForArrayInput?: boolean;\n}\n\nexport interface MediaComponentDataLensProps {\n dataLens: DataLensProps;\n}\n\nexport interface MediaComponentIframeProps {\n iframe: IframeProps;\n margins?: boolean;\n}\n\nexport interface MediaProps\n extends Animatable,\n Partial<MediaComponentDataLensProps>,\n Partial<MediaComponentYoutubeProps>,\n Partial<MediaComponentVideoIframeProps>,\n Partial<MediaComponentImageProps>,\n Partial<MediaComponentIframeProps>,\n Partial<MediaComponentVideoProps> {\n color?: string;\n videoMicrodata?: {\n name?: string;\n description?: string;\n duration?: string;\n uploadDate?: string;\n contentUrl?: string;\n thumbnailUrl?: string;\n };\n}\n\nexport interface BackgroundMediaProps extends MediaProps, Animatable, QAProps {\n fullWidthMedia?: boolean;\n className?: string;\n mediaClassName?: string;\n}\n\nexport type Coordinate = [number, number];\n\nexport interface MapBaseProps {\n zoom?: number;\n className?: string;\n forceAspectRatio?: boolean;\n}\n\nexport interface GMapProps extends MapBaseProps {\n address: string;\n}\n\nexport type YMapMargin =\n | number\n | [vertical: number, horizontal: number]\n | [top: number, right: number, bottom: number, left: number];\n\nexport interface YMapCopyrightPosition {\n top?: number;\n right?: number;\n bottom?: number;\n left?: number;\n}\n\nexport interface YMapProps extends MapBaseProps {\n markers: YMapMarker[];\n disableControls?: boolean;\n disableBalloons?: boolean;\n areaMargin?: YMapMargin;\n copyrightPosition?: YMapCopyrightPosition;\n id: string;\n}\n\nexport interface YMapMarker {\n address?: string;\n coordinate?: Coordinate;\n label?: YMapMarkerLabel;\n}\n\nexport interface YMapMarkerLabel {\n iconCaption?: string;\n iconContent?: string;\n iconColor?: string;\n iconImageHref?: string;\n iconImageSize?: [number, number];\n iconImageOffset?: [number, number];\n iconImageClipRect?: [[number, number], [number, number]];\n iconLayout?: 'default#image';\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n iconShape?: Record<string, any>;\n preset?: string;\n}\n\nexport interface YMapMarkerPrivate extends YMapMarker {\n label?: YMapMarkerLabelPrivate;\n}\n\nexport interface YMapMarkerLabelPrivate extends YMapMarkerLabel {\n cursor?: string;\n interactivityModel?: string;\n}\n\nexport type MapProps = GMapProps | YMapProps;\n\nexport type ThemedMediaProps = ThemeSupporting<MediaProps>;\n\nexport interface DataLensObjectProps {\n id: string;\n theme: 'dark' | 'light';\n}\n\nexport interface IframeProps {\n src: string;\n width?: number;\n height?: number;\n title?: string;\n name?: string;\n}\n\nexport type DataLensProps = string | DataLensObjectProps;\n\nexport interface AuthorItem {\n firstName: string;\n secondName: string;\n description?: string;\n avatar?: ThemeSupporting<ImageProps> | JSX.Element;\n}\n\nexport interface HeaderBreadCrumbsProps extends ClassNameProps, QAProps {\n items: {\n url: string;\n text: React.ReactNode;\n }[];\n theme?: TextTheme;\n analyticsEvents?: AnalyticsEventsProp;\n}\n\nexport interface TitleItemProps extends Justifyable, TitleItemBaseProps, AnalyticsEventsBase {\n navTitle?: string;\n anchor?: string;\n}\n\nexport interface TitleItemBaseProps {\n text: string;\n textSize?: TextSize;\n url?: string;\n urlTitle?: string;\n custom?: string | React.ReactNode;\n onClick?: () => void;\n}\n\nexport type MediaView = 'fit' | 'full';\n\n// card\nexport type MediaBorder = 'shadow' | 'line' | 'none';\nexport type CardBorder = MediaBorder;\nexport type ControlPosition = 'content' | 'footer';\n\nexport interface CardBaseProps {\n border?: CardBorder;\n}\n\nexport type CardLayoutProps = {\n controlPosition?: ControlPosition;\n};\n\n//price\nexport interface PriceDescriptionProps {\n title: string;\n detailedTitle?: string;\n description: string;\n label?: {\n color: PriceLabelColor;\n text?: string;\n size?: TextSize;\n };\n}\n\nexport interface PriceDetailsSettingsProps {\n title: string;\n description: string;\n}\n\nexport interface PriceDetailsListProps {\n text: string;\n}\n\nexport interface PriceDetailsProps {\n items?: PriceDetailsSettingsProps[] | PriceDetailsListProps[];\n}\n\nexport interface PriceItemProps\n extends PriceDetailsProps,\n PriceDescriptionProps,\n AnalyticsEventsBase {}\n\nexport interface PriceFoldableDetailsProps {\n title: string;\n size?: TextSize;\n titleColor?: PriceDescriptionColor;\n}\n\n/** @deprecated */\nexport interface PriceDetailedProps extends CardBaseProps {\n items: PriceItemProps[];\n description?: {\n titleSize?: TextSize;\n descriptionSize?: TextSize;\n titleColor?: PriceDescriptionColor;\n };\n details?: {\n titleSize?: TextSize;\n descriptionSize?: TextSize;\n };\n priceType?: PriceDetailsType;\n numberGroupItems?: 3 | 4 | 5;\n isCombined?: boolean;\n useMixedView?: boolean;\n foldable?: PriceFoldableDetailsProps;\n labelsDefaultText?: Record<PriceLabelColor, string>;\n}\n\nexport interface AuthorProps extends QAProps {\n author: AuthorItem;\n className?: string;\n authorContainerClassName?: string;\n type?: AuthorType;\n theme?: ContentTheme;\n}\n\nexport interface TitleProps {\n title?: TitleItemProps | string;\n subtitle?: string;\n}\n\nexport interface YandexFormProps extends AnalyticsEventsBase {\n id: number | string;\n containerId?: string;\n theme?: string;\n className?: string;\n headerHeight?: number;\n customFormOrigin?: string;\n customFormSection?: string;\n params?: {[key: string]: string};\n\n onSubmit?: () => void;\n onLoad?: () => void;\n}\n\nexport interface WithBorder {\n border?: MediaBorder;\n /**\n * @deprecated use custom class for media-component\n */\n disableShadow?: boolean;\n}\n"]}
@@ -18,50 +18,6 @@ unpredictable css rules order in build */
18
18
  top: 0;
19
19
  left: 0;
20
20
  }
21
- .pc-ReactPlayer__button {
22
- display: inline-block;
23
- margin: 0;
24
- padding: 0;
25
- font: inherit;
26
- border: none;
27
- outline: none;
28
- color: inherit;
29
- background: none;
30
- cursor: pointer;
31
- display: flex;
32
- justify-content: center;
33
- align-items: center;
34
- position: absolute;
35
- width: 64px;
36
- height: 64px;
37
- border-radius: 166px;
38
- }
39
- .pc-ReactPlayer__button:focus {
40
- outline: 2px solid var(--g-color-line-focus);
41
- outline-offset: 0;
42
- }
43
- .pc-ReactPlayer__button:focus:not(:focus-visible) {
44
- outline: 0;
45
- }
46
- .pc-ReactPlayer__button_theme_blue {
47
- color: var(--g-color-base-background);
48
- background-color: var(--g-color-base-brand);
49
- }
50
- .pc-ReactPlayer__button_theme_grey {
51
- color: var(--pc-text-header-color);
52
- background-color: #eff2f8;
53
- }
54
- .pc-ReactPlayer__button_text {
55
- padding: 16px 32px;
56
- font-weight: 400;
57
- font-size: 24px;
58
- line-height: 32px;
59
- width: auto;
60
- height: auto;
61
- }
62
- .pc-ReactPlayer__icon {
63
- margin-left: 1px;
64
- }
65
21
  .pc-ReactPlayer_controls_custom::before {
66
22
  display: none;
67
23
  position: absolute;
@@ -77,10 +33,4 @@ unpredictable css rules order in build */
77
33
  }
78
34
  .pc-ReactPlayer_auto-ratio video {
79
35
  object-fit: cover;
80
- }
81
- @media only screen and (max-width: 577px) {
82
- .pc-ReactPlayer__button_text {
83
- font-size: 20px;
84
- line-height: 24px;
85
- }
86
36
  }
@@ -1,7 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
- import { PlayFill } from '@gravity-ui/icons';
4
- import { Icon } from '@gravity-ui/uikit';
5
3
  import debounce from "lodash/debounce.js";
6
4
  import _ReactPlayer from 'react-player';
7
5
  import { MobileContext } from "../../context/mobileContext/index.js";
@@ -9,8 +7,8 @@ import { VideoContext } from "../../context/videoContext/index.js";
9
7
  import { useAnalytics, useImageSize, useMount } from "../../hooks/index.js";
10
8
  import { CustomControlsButtonPositioning, CustomControlsType, DefaultEventNames, MediaVideoControlsType, PlayButtonThemes, PlayButtonType, PredefinedEventTypes, } from "../../models/index.js";
11
9
  import { block } from "../../utils/index.js";
10
+ import VideoButton from "../VideoButton/VideoButton.js";
12
11
  import CustomBarControls from "./CustomBarControls.js";
13
- import { i18n } from "./i18n/index.js";
14
12
  import { checkYoutubeVideos } from "./utils.js";
15
13
  import { isYoutubePlayerInstance } from "./utils/youtube.js";
16
14
  import './ReactPlayer.css';
@@ -23,7 +21,6 @@ const ReactPlayer = 'default' in _ReactPlayer && _ReactPlayer.default
23
21
  export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
24
22
  const isMobile = React.useContext(MobileContext);
25
23
  const { src, previewImgUrl, loop = false, controls = MediaVideoControlsType.Default, customControlsOptions = {}, muted: initiallyMuted = false, elapsedTime, playButton, className, customBarControlsClassName, showPreview, onClickPreview, onIntrinsicSizeChange, disableAutoSizing, analyticsEvents, height, ariaLabel, ratio, autoRatio, contain = true, } = props;
26
- const { type = PlayButtonType.Default, theme = PlayButtonThemes.Blue, text, className: buttonClassName, } = playButton || {};
27
24
  const { type: customControlsType = CustomControlsType.WithMuteButton, muteButtonShown, positioning = CustomControlsButtonPositioning.Center, } = customControlsOptions;
28
25
  const autoPlay = Boolean(!isMobile && !previewImgUrl && props.autoplay);
29
26
  const mute = initiallyMuted || autoPlay;
@@ -126,18 +123,9 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
126
123
  const playEvents = React.useMemo(() => eventsArray?.filter((e) => e.type === PredefinedEventTypes.Play), [eventsArray]);
127
124
  const stopEvents = React.useMemo(() => eventsArray?.filter((e) => e.type === PredefinedEventTypes.Stop), [eventsArray]);
128
125
  const playIcon = React.useMemo(() => {
129
- let playButtonContent;
130
- switch (type) {
131
- case PlayButtonType.Text:
132
- playButtonContent = text;
133
- break;
134
- case PlayButtonType.Default:
135
- default:
136
- playButtonContent = _jsx(Icon, { className: b('icon'), data: PlayFill, size: 24 });
137
- break;
138
- }
139
- return (_jsx("button", { className: b('button', { theme, text: Boolean(text) }, buttonClassName), "aria-label": i18n('play'), ref: buttonRef, children: playButtonContent }));
140
- }, [type, theme, text, buttonClassName]);
126
+ const { theme, type } = playButton || {};
127
+ return (_jsx(VideoButton, { ...playButton, theme: theme || PlayButtonThemes.Blue, type: type || PlayButtonType.Default }));
128
+ }, [playButton]);
141
129
  const changeMute = React.useCallback((isMuted) => {
142
130
  if (isMuted &&
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BACJ,EACD,kBAAkB,EAAE,aAAa,EACjC,IAAI,EAAE,kBAAkB,EACxB,QAAQ,EAAE,CAAC,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,EAC3D,WAAW,EAAE,WAAW,GAC1B,CACL,IACY,CACpB,CAAC,CAAC,CAAC,IAAI,GACN,CACT,CAAC;AACN,CAAC,CACJ,CAAC;AAEF,SAAS,SAAS,CAAC,KAAa,EAAE,QAAgB,CAAC,GAAG,EAAE;IACpD,OAAO,KAAK,GAAG,KAAK,CAAC;AACzB,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAoB;IAC1C,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAE5C,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,OAAO,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;AACvF,CAAC;AAED,eAAe,gBAAgB,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {PlayFill} from '@gravity-ui/icons';\nimport {Icon} from '@gravity-ui/uikit';\nimport debounce from 'lodash/debounce';\nimport _ReactPlayer from 'react-player';\nimport type {ReactPlayerProps} from 'react-player';\n\nimport {MobileContext} from '../../context/mobileContext';\nimport {VideoContext} from '../../context/videoContext';\nimport {useAnalytics, useImageSize, useMount} from '../../hooks';\nimport {\n AnalyticsEvent,\n ClassNameProps,\n CustomControlsButtonPositioning,\n CustomControlsType,\n DefaultEventNames,\n MediaVideoControlsType,\n MediaVideoProps,\n PlayButtonProps,\n PlayButtonThemes,\n PlayButtonType,\n PredefinedEventTypes,\n ReactPlayerBlockHandler,\n} from '../../models';\nimport {block} from '../../utils';\n\nimport CustomBarControls from './CustomBarControls';\nimport {i18n} from './i18n';\nimport {checkYoutubeVideos} from './utils';\nimport {isYoutubePlayerInstance} from './utils/youtube';\n\nimport './ReactPlayer.scss';\n\nconst b = block('ReactPlayer');\n\nconst FPS = 60;\n\nconst ReactPlayer =\n 'default' in _ReactPlayer && _ReactPlayer.default\n ? (_ReactPlayer.default as typeof _ReactPlayer)\n : _ReactPlayer;\n\nexport interface ReactPlayerBlockProps\n extends Omit<MediaVideoProps, 'src' | 'ref'>,\n ClassNameProps {\n src: string | string[];\n previewImgUrl?: string;\n customBarControlsClassName?: string;\n showPreview?: boolean;\n onClickPreview?: () => void;\n height?: number;\n ratio?: number;\n autoRatio?: boolean;\n disableAutoSizing?: boolean;\n onIntrinsicSizeChange?: (size: {width: number; height: number}) => void;\n children?: React.ReactNode;\n}\n\ninterface PlayerPropgress {\n played: number;\n playedSeconds: number;\n}\n\n// eslint-disable-next-line react/display-name\nexport const ReactPlayerBlock = React.forwardRef<ReactPlayerBlockHandler, ReactPlayerBlockProps>(\n (props, originRef) => {\n const isMobile = React.useContext(MobileContext);\n const {\n src,\n previewImgUrl,\n loop = false,\n controls = MediaVideoControlsType.Default,\n customControlsOptions = {},\n muted: initiallyMuted = false,\n elapsedTime,\n playButton,\n className,\n customBarControlsClassName,\n showPreview,\n onClickPreview,\n onIntrinsicSizeChange,\n disableAutoSizing,\n analyticsEvents,\n height,\n ariaLabel,\n ratio,\n autoRatio,\n contain = true,\n } = props;\n\n const {\n type = PlayButtonType.Default,\n theme = PlayButtonThemes.Blue,\n text,\n className: buttonClassName,\n } = playButton || ({} as PlayButtonProps);\n const {\n type: customControlsType = CustomControlsType.WithMuteButton,\n muteButtonShown,\n positioning = CustomControlsButtonPositioning.Center,\n } = customControlsOptions;\n\n const autoPlay = Boolean(!isMobile && !previewImgUrl && props.autoplay);\n const mute = initiallyMuted || autoPlay;\n\n const {playingVideoRef, setProps} = React.useContext(VideoContext);\n\n const ref = React.useRef<HTMLDivElement>(null);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n\n const [playerRef, setPlayerRef] = React.useState<_ReactPlayer>();\n const [isPlaying, setIsPlaying] = React.useState(autoPlay);\n const [playedPercent, setPlayedPercent] = React.useState<number>(0);\n const [currentHeight, setCurrentHeight] = React.useState(height);\n const [duration, setDuration] = React.useState<null | number>(null);\n const [width, setWidth] = React.useState<number>(0);\n const [actualRatio, setActualRatio] = React.useState<number>();\n const [muted, setMuted] = React.useState<boolean>(mute);\n const [started, setStarted] = React.useState(autoPlay);\n const [ended, setEnded] = React.useState<boolean>(false);\n const [isMounted, setIsMounted] = React.useState(false);\n const [hovered, setHovered] = React.useState(isMobile);\n\n useMount(() => setIsMounted(true));\n\n const videoSrc = React.useMemo(() => checkYoutubeVideos(src), [src]);\n\n const {imageRef: previewImgRef, onLoad: onPreviewImgLoad} = useImageSize({\n onIntrinsicSizeChange,\n });\n\n const eventsArray = React.useMemo(() => {\n if (analyticsEvents) {\n return Array.isArray(analyticsEvents) ? analyticsEvents : [analyticsEvents];\n }\n\n return [];\n }, [analyticsEvents]);\n const handleAnalytics = useAnalytics(DefaultEventNames.ReactPlayerControls);\n\n React.useImperativeHandle(originRef, () => {\n if (!playerRef) {\n return;\n }\n\n let play, pause, addEventListener;\n const videoInstance = playerRef.getInternalPlayer();\n if (isYoutubePlayerInstance(videoInstance)) {\n ({pauseVideo: pause, playVideo: play, addEventListener} = videoInstance);\n } else {\n // it is assumed that `videoInstance` is HTMLVideoElement by default\n ({play, pause, addEventListener} = videoInstance);\n }\n\n // eslint-disable-next-line consistent-return\n return {\n play: play.bind(videoInstance),\n pause: pause.bind(videoInstance),\n addEventListener: addEventListener.bind(videoInstance),\n };\n }, [playerRef]);\n\n React.useEffect(() => {\n if (ref.current && !playingVideoRef?.contains(ref.current)) {\n setMuted(true);\n }\n }, [playingVideoRef]);\n\n React.useEffect(() => {\n if (showPreview) {\n playerRef?.showPreview();\n }\n }, [showPreview, playerRef]);\n\n React.useEffect(() => {\n if (playerRef && !started) {\n setIsPlaying(autoPlay);\n }\n }, [autoPlay, playerRef, started]);\n\n React.useEffect(() => setMuted(mute), [mute]);\n\n React.useEffect(() => {\n if (!started && isPlaying) {\n setStarted(true);\n }\n }, [isPlaying, started]);\n\n React.useEffect(() => {\n if (started && !Number.isNaN(Number(elapsedTime))) {\n playerRef?.seekTo(elapsedTime ?? 0, 'seconds');\n }\n }, [elapsedTime, playerRef, started]);\n\n React.useEffect(() => {\n if (disableAutoSizing) {\n return;\n }\n\n const updateSize = debounce(() => {\n if (ref.current) {\n // We need to get parent's width does not equal 0\n const parentElement = getParentElement(ref.current);\n const {paddingLeft, paddingRight} = getComputedStyle(parentElement);\n const newWidth =\n parentElement.offsetWidth -\n parseFloat(paddingLeft) -\n parseFloat(paddingRight);\n\n setWidth(newWidth);\n setCurrentHeight(\n Math.floor(\n getHeight(newWidth, ratio ?? (autoRatio ? actualRatio : undefined)),\n ),\n );\n }\n }, 200);\n\n updateSize();\n window.addEventListener('resize', updateSize, {passive: true});\n // eslint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, [actualRatio, autoRatio, disableAutoSizing, playerRef, ratio]);\n\n const playEvents = React.useMemo(\n () => eventsArray?.filter((e: AnalyticsEvent) => e.type === PredefinedEventTypes.Play),\n [eventsArray],\n );\n const stopEvents = React.useMemo(\n () => eventsArray?.filter((e: AnalyticsEvent) => e.type === PredefinedEventTypes.Stop),\n [eventsArray],\n );\n\n const playIcon = React.useMemo(() => {\n let playButtonContent;\n\n switch (type) {\n case PlayButtonType.Text:\n playButtonContent = text;\n break;\n case PlayButtonType.Default:\n default:\n playButtonContent = <Icon className={b('icon')} data={PlayFill} size={24} />;\n break;\n }\n\n return (\n <button\n className={b('button', {theme, text: Boolean(text)}, buttonClassName)}\n aria-label={i18n('play')}\n ref={buttonRef}\n >\n {playButtonContent}\n </button>\n );\n }, [type, theme, text, buttonClassName]);\n\n const changeMute = React.useCallback(\n (isMuted: boolean) => {\n if (\n isMuted &&\n playerRef &&\n controls === MediaVideoControlsType.Custom &&\n customControlsType === CustomControlsType.WithMuteButton\n ) {\n playerRef.seekTo(0);\n setPlayedPercent(0);\n }\n\n const events = isMuted ? playEvents : stopEvents;\n handleAnalytics(events);\n\n if (isMuted) {\n setProps({playingVideoRef: ref.current});\n }\n\n // In order to the progress bar to update (equals 0) before displaying\n setTimeout(() => setMuted(!isMuted), 0);\n },\n [\n playerRef,\n customControlsType,\n playEvents,\n stopEvents,\n handleAnalytics,\n setProps,\n controls,\n ],\n );\n\n const handleClickPreview = React.useCallback(() => {\n setIsPlaying(true);\n onClickPreview?.();\n\n handleAnalytics(playEvents);\n }, [onClickPreview, handleAnalytics, playEvents]);\n\n const onPause = React.useCallback(() => {\n // For support correct state for youtube\n if (\n controls !== MediaVideoControlsType.Custom ||\n customControlsType !== CustomControlsType.WithMuteButton\n ) {\n setIsPlaying(false);\n }\n }, [controls, customControlsType]);\n\n const onStart = React.useCallback(() => {\n if (!autoPlay && !initiallyMuted) {\n setMuted(false);\n }\n }, [autoPlay, initiallyMuted]);\n\n const onPlay = React.useCallback(() => {\n setIsPlaying(true);\n\n if (\n controls === MediaVideoControlsType.Custom &&\n customControlsType === CustomControlsType.WithMuteButton\n ) {\n if (ended) {\n changeMute(false);\n } else if (!isPlaying) {\n changeMute(muted);\n }\n setEnded(false);\n }\n }, [changeMute, controls, customControlsType, ended, isPlaying, muted]);\n\n const onReady = React.useCallback(\n (player: _ReactPlayer) => {\n setPlayerRef(player);\n const videoElement = player.getInternalPlayer();\n const videoWidth = videoElement.videoWidth as number | undefined;\n const videoHeight = videoElement.videoHeight as number | undefined;\n if (videoWidth && videoHeight) {\n setActualRatio(videoHeight / videoWidth);\n onIntrinsicSizeChange?.({width: videoWidth, height: videoHeight});\n }\n },\n [onIntrinsicSizeChange],\n );\n\n const onProgress: ReactPlayerProps['onProgress'] = React.useCallback(\n ({played, playedSeconds}: PlayerPropgress) => {\n setPlayedPercent(played);\n\n if (loop) {\n const {start = 0, end = duration} = typeof loop === 'boolean' ? {} : loop;\n\n // Youtube videos not muted after finishing playing and start again.\n // 'onEnded' does not fire when 'loop' is set to true.\n // It is custom loop with muted sound after finishing playing and start again.\n if (end !== null && playedSeconds >= end) {\n setIsPlaying(true);\n playerRef?.seekTo(start);\n }\n }\n\n if (played === 1) {\n setMuted(true);\n }\n },\n [duration, loop, playerRef],\n );\n\n const onDuration = React.useCallback((currentDuration: number) => {\n setDuration(currentDuration);\n }, []);\n\n const onEnded = React.useCallback(() => {\n setEnded(true);\n }, []);\n\n const onPlayClick = React.useCallback(() => {\n if (isPlaying) {\n onPause();\n } else {\n onPlay();\n }\n }, [isPlaying, onPlay, onPause]);\n\n const handleClick = React.useCallback(() => {\n buttonRef.current?.click();\n\n if (controls === MediaVideoControlsType.Custom) {\n if (customControlsType === CustomControlsType.WithMuteButton) {\n changeMute(muted);\n } else {\n onPlayClick();\n }\n }\n }, [controls, customControlsType, changeMute, muted, onPlayClick]);\n\n const handleKeyDown = React.useCallback((e: React.KeyboardEvent) => {\n const key = e.key.toLowerCase();\n\n if (key === 'enter') {\n buttonRef.current?.click();\n }\n }, []);\n\n const onFocusIn = React.useCallback(() => setHovered(true), []);\n const onFocusOut = React.useCallback(() => setHovered(false), []);\n\n return (\n <div\n className={b(\n {\n wrapper: !currentHeight,\n controls,\n contain,\n 'auto-ratio': autoRatio,\n },\n className,\n )}\n ref={ref}\n onClick={handleClick}\n onMouseEnter={onFocusIn}\n onMouseLeave={onFocusOut}\n onFocus={onFocusIn}\n onBlur={onFocusOut}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n >\n {isMounted ? (\n <React.Fragment>\n <ReactPlayer\n className={b('player')}\n url={videoSrc}\n muted={muted}\n controls={controls === MediaVideoControlsType.Default}\n height={currentHeight || '100%'}\n width={width || '100%'}\n light={\n previewImgUrl && (\n <img\n className={b('preview-img')}\n src={previewImgUrl}\n onLoad={onPreviewImgLoad}\n alt=\"\"\n aria-hidden={true}\n ref={previewImgRef}\n />\n )\n }\n playing={isPlaying}\n playIcon={playIcon}\n progressInterval={FPS}\n onClickPreview={handleClickPreview}\n onStart={onStart}\n onReady={onReady}\n onPlay={onPlay}\n onPause={\n autoPlay && customControlsType !== CustomControlsType.WithMuteButton\n ? undefined\n : onPause\n } // to prevent pause icon flickering when autoplayed video ends\n onProgress={onProgress}\n onEnded={onEnded}\n onDuration={onDuration}\n aria-label={ariaLabel}\n previewTabIndex={-1}\n config={{\n file: {\n attributes: {\n pip: isMobile ? 'false' : undefined,\n playsinline: isMobile ? '' : undefined,\n disablepictureinpicture: isMobile ? '' : undefined,\n },\n },\n }}\n />\n {controls === MediaVideoControlsType.Custom && (\n <CustomBarControls\n className={customBarControlsClassName}\n mute={{\n isMuted: muted,\n changeMute: (event: React.MouseEvent) => {\n event.stopPropagation();\n changeMute(muted);\n },\n }}\n elapsedTimePercent={playedPercent}\n type={customControlsType}\n isPaused={!isPlaying}\n onPlayClick={onPlayClick}\n muteButtonShown={muteButtonShown}\n shown={hovered && ((!started && !previewImgUrl) || started)}\n positioning={positioning}\n />\n )}\n </React.Fragment>\n ) : null}\n </div>\n );\n },\n);\n\nfunction getHeight(width: number, ratio: number = 9 / 16): number {\n return width * ratio;\n}\n\nfunction getParentElement(element: HTMLElement): HTMLElement {\n const parentElement = element.parentElement;\n\n if (!parentElement) {\n return element;\n }\n\n return parentElement.offsetWidth ? parentElement : getParentElement(parentElement);\n}\n\nexport default ReactPlayerBlock;\n"]}
1
+ {"version":3,"file":"ReactPlayer.js","sourceRoot":"../../../../src","sources":["components/ReactPlayer/ReactPlayer.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,QAAQ,2BAAwB;AACvC,OAAO,YAAY,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAC,aAAa,EAAC,6CAAoC;AAC1D,OAAO,EAAC,YAAY,EAAC,4CAAmC;AACxD,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,EA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I,CAC3C,KAAC,iBAAiB,IACd,SAAS,EAAE,0BAA0B,EACrC,IAAI,EAAE;wBACF,OAAO,EAAE,KAAK;wBACd,UAAU,EAAE,CAAC,KAAuB,EAAE,EAAE;4BACpC,KAAK,CAAC,eAAe,EAAE,CAAC;4BACxB,UAAU,CAAC,KAAK,CAAC,CAAC;wBACtB,CAAC;qBACJ,EACD,kBAAkB,EAAE,aAAa,EACjC,IAAI,EAAE,kBAAkB,EACxB,QAAQ,EAAE,CAAC,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,EAC3D,WAAW,EAAE,WAAW,GAC1B,CACL,IACY,CACpB,CAAC,CAAC,CAAC,IAAI,GACN,CACT,CAAC;AACN,CAAC,CACJ,CAAC;AAEF,SAAS,SAAS,CAAC,KAAa,EAAE,QAAgB,CAAC,GAAG,EAAE;IACpD,OAAO,KAAK,GAAG,KAAK,CAAC;AACzB,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAoB;IAC1C,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAE5C,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,OAAO,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;AACvF,CAAC;AAED,eAAe,gBAAgB,CAAC","sourcesContent":["import * as React from 'react';\n\nimport debounce from 'lodash/debounce';\nimport _ReactPlayer from 'react-player';\nimport type {ReactPlayerProps} from 'react-player';\n\nimport {MobileContext} from '../../context/mobileContext';\nimport {VideoContext} from '../../context/videoContext';\nimport {useAnalytics, useImageSize, useMount} from '../../hooks';\nimport {\n AnalyticsEvent,\n ClassNameProps,\n CustomControlsButtonPositioning,\n CustomControlsType,\n DefaultEventNames,\n MediaVideoControlsType,\n MediaVideoProps,\n PlayButtonThemes,\n PlayButtonType,\n PredefinedEventTypes,\n ReactPlayerBlockHandler,\n} from '../../models';\nimport {block} from '../../utils';\nimport VideoButton from '../VideoButton/VideoButton';\n\nimport CustomBarControls from './CustomBarControls';\nimport {checkYoutubeVideos} from './utils';\nimport {isYoutubePlayerInstance} from './utils/youtube';\n\nimport './ReactPlayer.scss';\n\nconst b = block('ReactPlayer');\n\nconst FPS = 60;\n\nconst ReactPlayer =\n 'default' in _ReactPlayer && _ReactPlayer.default\n ? (_ReactPlayer.default as typeof _ReactPlayer)\n : _ReactPlayer;\n\nexport interface ReactPlayerBlockProps\n extends Omit<MediaVideoProps, 'src' | 'ref'>,\n ClassNameProps {\n src: string | string[];\n previewImgUrl?: string;\n customBarControlsClassName?: string;\n showPreview?: boolean;\n onClickPreview?: () => void;\n height?: number;\n ratio?: number;\n autoRatio?: boolean;\n disableAutoSizing?: boolean;\n onIntrinsicSizeChange?: (size: {width: number; height: number}) => void;\n children?: React.ReactNode;\n}\n\ninterface PlayerPropgress {\n played: number;\n playedSeconds: number;\n}\n\n// eslint-disable-next-line react/display-name\nexport const ReactPlayerBlock = React.forwardRef<ReactPlayerBlockHandler, ReactPlayerBlockProps>(\n (props, originRef) => {\n const isMobile = React.useContext(MobileContext);\n const {\n src,\n previewImgUrl,\n loop = false,\n controls = MediaVideoControlsType.Default,\n customControlsOptions = {},\n muted: initiallyMuted = false,\n elapsedTime,\n playButton,\n className,\n customBarControlsClassName,\n showPreview,\n onClickPreview,\n onIntrinsicSizeChange,\n disableAutoSizing,\n analyticsEvents,\n height,\n ariaLabel,\n ratio,\n autoRatio,\n contain = true,\n } = props;\n const {\n type: customControlsType = CustomControlsType.WithMuteButton,\n muteButtonShown,\n positioning = CustomControlsButtonPositioning.Center,\n } = customControlsOptions;\n\n const autoPlay = Boolean(!isMobile && !previewImgUrl && props.autoplay);\n const mute = initiallyMuted || autoPlay;\n\n const {playingVideoRef, setProps} = React.useContext(VideoContext);\n\n const ref = React.useRef<HTMLDivElement>(null);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n\n const [playerRef, setPlayerRef] = React.useState<_ReactPlayer>();\n const [isPlaying, setIsPlaying] = React.useState(autoPlay);\n const [playedPercent, setPlayedPercent] = React.useState<number>(0);\n const [currentHeight, setCurrentHeight] = React.useState(height);\n const [duration, setDuration] = React.useState<null | number>(null);\n const [width, setWidth] = React.useState<number>(0);\n const [actualRatio, setActualRatio] = React.useState<number>();\n const [muted, setMuted] = React.useState<boolean>(mute);\n const [started, setStarted] = React.useState(autoPlay);\n const [ended, setEnded] = React.useState<boolean>(false);\n const [isMounted, setIsMounted] = React.useState(false);\n const [hovered, setHovered] = React.useState(isMobile);\n\n useMount(() => setIsMounted(true));\n\n const videoSrc = React.useMemo(() => checkYoutubeVideos(src), [src]);\n\n const {imageRef: previewImgRef, onLoad: onPreviewImgLoad} = useImageSize({\n onIntrinsicSizeChange,\n });\n\n const eventsArray = React.useMemo(() => {\n if (analyticsEvents) {\n return Array.isArray(analyticsEvents) ? analyticsEvents : [analyticsEvents];\n }\n\n return [];\n }, [analyticsEvents]);\n const handleAnalytics = useAnalytics(DefaultEventNames.ReactPlayerControls);\n\n React.useImperativeHandle(originRef, () => {\n if (!playerRef) {\n return;\n }\n\n let play, pause, addEventListener;\n const videoInstance = playerRef.getInternalPlayer();\n if (isYoutubePlayerInstance(videoInstance)) {\n ({pauseVideo: pause, playVideo: play, addEventListener} = videoInstance);\n } else {\n // it is assumed that `videoInstance` is HTMLVideoElement by default\n ({play, pause, addEventListener} = videoInstance);\n }\n\n // eslint-disable-next-line consistent-return\n return {\n play: play.bind(videoInstance),\n pause: pause.bind(videoInstance),\n addEventListener: addEventListener.bind(videoInstance),\n };\n }, [playerRef]);\n\n React.useEffect(() => {\n if (ref.current && !playingVideoRef?.contains(ref.current)) {\n setMuted(true);\n }\n }, [playingVideoRef]);\n\n React.useEffect(() => {\n if (showPreview) {\n playerRef?.showPreview();\n }\n }, [showPreview, playerRef]);\n\n React.useEffect(() => {\n if (playerRef && !started) {\n setIsPlaying(autoPlay);\n }\n }, [autoPlay, playerRef, started]);\n\n React.useEffect(() => setMuted(mute), [mute]);\n\n React.useEffect(() => {\n if (!started && isPlaying) {\n setStarted(true);\n }\n }, [isPlaying, started]);\n\n React.useEffect(() => {\n if (started && !Number.isNaN(Number(elapsedTime))) {\n playerRef?.seekTo(elapsedTime ?? 0, 'seconds');\n }\n }, [elapsedTime, playerRef, started]);\n\n React.useEffect(() => {\n if (disableAutoSizing) {\n return;\n }\n\n const updateSize = debounce(() => {\n if (ref.current) {\n // We need to get parent's width does not equal 0\n const parentElement = getParentElement(ref.current);\n const {paddingLeft, paddingRight} = getComputedStyle(parentElement);\n const newWidth =\n parentElement.offsetWidth -\n parseFloat(paddingLeft) -\n parseFloat(paddingRight);\n\n setWidth(newWidth);\n setCurrentHeight(\n Math.floor(\n getHeight(newWidth, ratio ?? (autoRatio ? actualRatio : undefined)),\n ),\n );\n }\n }, 200);\n\n updateSize();\n window.addEventListener('resize', updateSize, {passive: true});\n // eslint-disable-next-line consistent-return\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, [actualRatio, autoRatio, disableAutoSizing, playerRef, ratio]);\n\n const playEvents = React.useMemo(\n () => eventsArray?.filter((e: AnalyticsEvent) => e.type === PredefinedEventTypes.Play),\n [eventsArray],\n );\n const stopEvents = React.useMemo(\n () => eventsArray?.filter((e: AnalyticsEvent) => e.type === PredefinedEventTypes.Stop),\n [eventsArray],\n );\n\n const playIcon = React.useMemo(() => {\n const {theme, type} = playButton || {};\n return (\n <VideoButton\n {...playButton}\n theme={theme || PlayButtonThemes.Blue}\n type={type || PlayButtonType.Default}\n />\n );\n }, [playButton]);\n\n const changeMute = React.useCallback(\n (isMuted: boolean) => {\n if (\n isMuted &&\n playerRef &&\n controls === MediaVideoControlsType.Custom &&\n customControlsType === CustomControlsType.WithMuteButton\n ) {\n playerRef.seekTo(0);\n setPlayedPercent(0);\n }\n\n const events = isMuted ? playEvents : stopEvents;\n handleAnalytics(events);\n\n if (isMuted) {\n setProps({playingVideoRef: ref.current});\n }\n\n // In order to the progress bar to update (equals 0) before displaying\n setTimeout(() => setMuted(!isMuted), 0);\n },\n [\n playerRef,\n customControlsType,\n playEvents,\n stopEvents,\n handleAnalytics,\n setProps,\n controls,\n ],\n );\n\n const handleClickPreview = React.useCallback(() => {\n setIsPlaying(true);\n onClickPreview?.();\n\n handleAnalytics(playEvents);\n }, [onClickPreview, handleAnalytics, playEvents]);\n\n const onPause = React.useCallback(() => {\n // For support correct state for youtube\n if (\n controls !== MediaVideoControlsType.Custom ||\n customControlsType !== CustomControlsType.WithMuteButton\n ) {\n setIsPlaying(false);\n }\n }, [controls, customControlsType]);\n\n const onStart = React.useCallback(() => {\n if (!autoPlay && !initiallyMuted) {\n setMuted(false);\n }\n }, [autoPlay, initiallyMuted]);\n\n const onPlay = React.useCallback(() => {\n setIsPlaying(true);\n\n if (\n controls === MediaVideoControlsType.Custom &&\n customControlsType === CustomControlsType.WithMuteButton\n ) {\n if (ended) {\n changeMute(false);\n } else if (!isPlaying) {\n changeMute(muted);\n }\n setEnded(false);\n }\n }, [changeMute, controls, customControlsType, ended, isPlaying, muted]);\n\n const onReady = React.useCallback(\n (player: _ReactPlayer) => {\n setPlayerRef(player);\n const videoElement = player.getInternalPlayer();\n const videoWidth = videoElement.videoWidth as number | undefined;\n const videoHeight = videoElement.videoHeight as number | undefined;\n if (videoWidth && videoHeight) {\n setActualRatio(videoHeight / videoWidth);\n onIntrinsicSizeChange?.({width: videoWidth, height: videoHeight});\n }\n },\n [onIntrinsicSizeChange],\n );\n\n const onProgress: ReactPlayerProps['onProgress'] = React.useCallback(\n ({played, playedSeconds}: PlayerPropgress) => {\n setPlayedPercent(played);\n\n if (loop) {\n const {start = 0, end = duration} = typeof loop === 'boolean' ? {} : loop;\n\n // Youtube videos not muted after finishing playing and start again.\n // 'onEnded' does not fire when 'loop' is set to true.\n // It is custom loop with muted sound after finishing playing and start again.\n if (end !== null && playedSeconds >= end) {\n setIsPlaying(true);\n playerRef?.seekTo(start);\n }\n }\n\n if (played === 1) {\n setMuted(true);\n }\n },\n [duration, loop, playerRef],\n );\n\n const onDuration = React.useCallback((currentDuration: number) => {\n setDuration(currentDuration);\n }, []);\n\n const onEnded = React.useCallback(() => {\n setEnded(true);\n }, []);\n\n const onPlayClick = React.useCallback(() => {\n if (isPlaying) {\n onPause();\n } else {\n onPlay();\n }\n }, [isPlaying, onPlay, onPause]);\n\n const handleClick = React.useCallback(() => {\n buttonRef.current?.click();\n\n if (controls === MediaVideoControlsType.Custom) {\n if (customControlsType === CustomControlsType.WithMuteButton) {\n changeMute(muted);\n } else {\n onPlayClick();\n }\n }\n }, [controls, customControlsType, changeMute, muted, onPlayClick]);\n\n const handleKeyDown = React.useCallback((e: React.KeyboardEvent) => {\n const key = e.key.toLowerCase();\n\n if (key === 'enter') {\n buttonRef.current?.click();\n }\n }, []);\n\n const onFocusIn = React.useCallback(() => setHovered(true), []);\n const onFocusOut = React.useCallback(() => setHovered(false), []);\n\n return (\n <div\n className={b(\n {\n wrapper: !currentHeight,\n controls,\n contain,\n 'auto-ratio': autoRatio,\n },\n className,\n )}\n ref={ref}\n onClick={handleClick}\n onMouseEnter={onFocusIn}\n onMouseLeave={onFocusOut}\n onFocus={onFocusIn}\n onBlur={onFocusOut}\n onKeyDown={handleKeyDown}\n role=\"button\"\n tabIndex={0}\n >\n {isMounted ? (\n <React.Fragment>\n <ReactPlayer\n className={b('player')}\n url={videoSrc}\n muted={muted}\n controls={controls === MediaVideoControlsType.Default}\n height={currentHeight || '100%'}\n width={width || '100%'}\n light={\n previewImgUrl && (\n <img\n className={b('preview-img')}\n src={previewImgUrl}\n onLoad={onPreviewImgLoad}\n alt=\"\"\n aria-hidden={true}\n ref={previewImgRef}\n />\n )\n }\n playing={isPlaying}\n playIcon={playIcon}\n progressInterval={FPS}\n onClickPreview={handleClickPreview}\n onStart={onStart}\n onReady={onReady}\n onPlay={onPlay}\n onPause={\n autoPlay && customControlsType !== CustomControlsType.WithMuteButton\n ? undefined\n : onPause\n } // to prevent pause icon flickering when autoplayed video ends\n onProgress={onProgress}\n onEnded={onEnded}\n onDuration={onDuration}\n aria-label={ariaLabel}\n previewTabIndex={-1}\n config={{\n file: {\n attributes: {\n pip: isMobile ? 'false' : undefined,\n playsinline: isMobile ? '' : undefined,\n disablepictureinpicture: isMobile ? '' : undefined,\n },\n },\n }}\n />\n {controls === MediaVideoControlsType.Custom && (\n <CustomBarControls\n className={customBarControlsClassName}\n mute={{\n isMuted: muted,\n changeMute: (event: React.MouseEvent) => {\n event.stopPropagation();\n changeMute(muted);\n },\n }}\n elapsedTimePercent={playedPercent}\n type={customControlsType}\n isPaused={!isPlaying}\n onPlayClick={onPlayClick}\n muteButtonShown={muteButtonShown}\n shown={hovered && ((!started && !previewImgUrl) || started)}\n positioning={positioning}\n />\n )}\n </React.Fragment>\n ) : null}\n </div>\n );\n },\n);\n\nfunction getHeight(width: number, ratio: number = 9 / 16): number {\n return width * ratio;\n}\n\nfunction getParentElement(element: HTMLElement): HTMLElement {\n const parentElement = element.parentElement;\n\n if (!parentElement) {\n return element;\n }\n\n return parentElement.offsetWidth ? parentElement : getParentElement(parentElement);\n}\n\nexport default ReactPlayerBlock;\n"]}
@@ -22,34 +22,4 @@ unpredictable css rules order in build */
22
22
  .pc-VideoBlock__image-wrapper {
23
23
  height: 100%;
24
24
  width: 100%;
25
- }
26
- .pc-VideoBlock__button {
27
- display: inline-block;
28
- margin: 0;
29
- padding: 0;
30
- font: inherit;
31
- border: none;
32
- outline: none;
33
- color: inherit;
34
- background: none;
35
- cursor: pointer;
36
- display: flex;
37
- justify-content: center;
38
- align-items: center;
39
- position: absolute;
40
- width: 64px;
41
- height: 64px;
42
- color: var(--g-color-base-background);
43
- background-color: var(--g-color-base-brand);
44
- border-radius: 50%;
45
- }
46
- .pc-VideoBlock__button:focus {
47
- outline: 2px solid var(--g-color-line-focus);
48
- outline-offset: 0;
49
- }
50
- .pc-VideoBlock__button:focus:not(:focus-visible) {
51
- outline: 0;
52
- }
53
- .pc-VideoBlock__icon {
54
- margin-left: 1px;
55
25
  }
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { AnalyticsEventsBase } from "../../models/common.js";
3
+ import { VideoButtonProps } from "../VideoButton/VideoButton.js";
3
4
  import './VideoBlock.css';
4
5
  export declare const AUTOPLAY_ATTRIBUTES: {
5
6
  autoplay: number;
@@ -14,7 +15,7 @@ export interface VideoBlockProps extends AnalyticsEventsBase {
14
15
  attributes?: Record<string, string>;
15
16
  className?: string;
16
17
  previewImg?: string;
17
- playButton?: React.ReactNode;
18
+ playButton?: React.ReactNode | VideoButtonProps;
18
19
  playButtonId?: string;
19
20
  height?: number;
20
21
  fullscreen?: boolean;
@@ -1,13 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
- import { PlayFill } from '@gravity-ui/icons';
4
- import { Icon, useActionHandlers, useUniqId } from '@gravity-ui/uikit';
3
+ import { useActionHandlers, useUniqId } from '@gravity-ui/uikit';
5
4
  import debounce from "lodash/debounce.js";
6
5
  import { v4 as uuidv4 } from 'uuid';
7
6
  import { useAnalytics } from "../../hooks/useAnalytics.js";
8
7
  import { DefaultEventNames } from "../../models/common.js";
9
8
  import { block, getPageSearchParams } from "../../utils/index.js";
10
9
  import Image from "../Image/Image.js";
10
+ import VideoButton from "../VideoButton/VideoButton.js";
11
11
  import { i18n } from "./i18n/index.js";
12
12
  import './VideoBlock.css';
13
13
  const RECORD_URL = 'https://www.youtube.com/embed/';
@@ -40,6 +40,18 @@ function getYoutubeVideoSrc(stream, record) {
40
40
  export function getHeight(width) {
41
41
  return (width / 16) * 9;
42
42
  }
43
+ const isReactNode = (value) => {
44
+ if (value === null || typeof value === 'boolean')
45
+ return true;
46
+ if (typeof value === 'string' || typeof value === 'number')
47
+ return true;
48
+ if (React.isValidElement(value))
49
+ return true;
50
+ if (Array.isArray(value)) {
51
+ return value.every(isReactNode);
52
+ }
53
+ return false;
54
+ };
43
55
  const VideoBlock = (props) => {
44
56
  const { stream, record, videoIframe, attributes, className, id, previewImg, playButton, playButtonId, height, fullscreen, analyticsEvents, autoplay, onImageLoad, } = props;
45
57
  const handleAnalytics = useAnalytics(DefaultEventNames.VideoPreview);
@@ -91,10 +103,14 @@ const VideoBlock = (props) => {
91
103
  React.useEffect(() => {
92
104
  setHidePreview(false);
93
105
  }, [src]);
106
+ const buttonProps = React.useMemo(() => isReactNode(playButton)
107
+ ? { customButton: playButton }
108
+ : playButton, [playButton]);
109
+ const buttonLabelId = buttonProps?.customButton ? playButtonId : buttonProps?.id || buttonId;
94
110
  if (!src) {
95
111
  return null;
96
112
  }
97
- return (_jsxs("div", { className: b(null, className), style: { height: currentHeight }, ref: ref, children: [iframeContent, previewImg && !hidePreview && !fullscreen && (_jsxs("div", { className: b('preview'), onClick: onPreviewClick, onKeyDown: onPreviewKeyDown, role: "button", tabIndex: 0, "aria-labelledby": playButton ? playButtonId : buttonId, children: [_jsx(Image, { src: previewImg, className: b('image'), containerClassName: b('image-wrapper'), onLoad: onImageLoad }), playButton || (_jsx("button", { title: "Play", id: buttonId, className: b('button'), children: _jsx(Icon, { className: b('icon'), data: PlayFill, size: 24 }) }))] }))] }));
113
+ return (_jsxs("div", { className: b(null, className), style: { height: currentHeight }, ref: ref, children: [iframeContent, previewImg && !hidePreview && !fullscreen && (_jsxs("div", { className: b('preview'), onClick: onPreviewClick, onKeyDown: onPreviewKeyDown, role: "button", tabIndex: 0, "aria-labelledby": buttonLabelId, children: [_jsx(Image, { src: previewImg, className: b('image'), containerClassName: b('image-wrapper'), onLoad: onImageLoad }), _jsx(VideoButton, { id: buttonId, ...buttonProps })] }))] }));
98
114
  };
99
115
  export default VideoBlock;
100
116
  //# sourceMappingURL=VideoBlock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"VideoBlock.js","sour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AAC;IAED,OAAO,CACH,eAAK,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,EAAC,MAAM,EAAE,aAAa,EAAC,EAAE,GAAG,EAAE,GAAG,aACvE,aAAa,EACb,UAAU,IAAI,CAAC,WAAW,IAAI,CAAC,UAAU,IAAI,CAC1C,eACI,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,EACvB,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,gBAAgB,EAC3B,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,qBACM,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,aAErD,KAAC,KAAK,IACF,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,EACrB,kBAAkB,EAAE,CAAC,CAAC,eAAe,CAAC,EACtC,MAAM,EAAE,WAAW,GACrB,EACD,UAAU,IAAI,CACX,iBAAQ,KAAK,EAAC,MAAM,EAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,YACrD,KAAC,IAAI,IAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,GAAI,GACnD,CACZ,IACC,CACT,IACC,CACT,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {PlayFill} from '@gravity-ui/icons';\nimport {Icon, useActionHandlers, useUniqId} from '@gravity-ui/uikit';\nimport debounce from 'lodash/debounce';\nimport {v4 as uuidv4} from 'uuid';\n\nimport {useAnalytics} from '../../hooks/useAnalytics';\nimport {AnalyticsEventsBase, DefaultEventNames} from '../../models/common';\nimport {block, getPageSearchParams} from '../../utils';\nimport Image from '../Image/Image';\n\nimport {i18n} from './i18n';\n\nimport './VideoBlock.scss';\n\nconst RECORD_URL = 'https://www.youtube.com/embed/';\nconst STREAM_URL = 'https://www.youtube.com/embed/live_stream?channel=';\nconst RECORD_RE = /[0-9A-Za-z_-]{11}/;\nconst STREAM_RE = /[0-9A-Za-z_-]{23,25}/;\nconst AUTOPLAY_DELAY = 300;\n\nexport const AUTOPLAY_ATTRIBUTES = {\n autoplay: 1,\n mute: 1,\n};\nconst NO_AUTOPLAY_ATTRIBUTES = {\n autoplay: 0,\n};\n\nconst b = block('VideoBlock');\n\nfunction getYoutubeVideoSrc(stream?: string, record?: string) {\n if (!stream && !record) {\n return null;\n }\n\n const [videoLink, url, re] = stream\n ? [stream, STREAM_URL, STREAM_RE]\n : [record, RECORD_URL, RECORD_RE];\n const match = videoLink?.match(re);\n let src;\n\n if (match && match.length) {\n src = url + match[0];\n }\n\n return src;\n}\n\nexport function getHeight(width: number): number {\n return (width / 16) * 9;\n}\n\nexport interface VideoBlockProps extends AnalyticsEventsBase {\n id?: string;\n stream?: string;\n record?: string;\n videoIframe?: string;\n attributes?: Record<string, string>;\n className?: string;\n previewImg?: string;\n playButton?: React.ReactNode;\n playButtonId?: string;\n height?: number;\n fullscreen?: boolean;\n autoplay?: boolean;\n onImageLoad?: () => void;\n}\n\nconst VideoBlock = (props: VideoBlockProps) => {\n const {\n stream,\n record,\n videoIframe,\n attributes,\n className,\n id,\n previewImg,\n playButton,\n playButtonId,\n height,\n fullscreen,\n analyticsEvents,\n autoplay,\n onImageLoad,\n } = props;\n const handleAnalytics = useAnalytics(DefaultEventNames.VideoPreview);\n\n const src = videoIframe ? videoIframe : getYoutubeVideoSrc(stream, record);\n const ref = React.useRef<HTMLDivElement>(null);\n const [hidePreview, setHidePreview] = React.useState(false);\n const [currentHeight, setCurrentHeight] = React.useState(height || undefined);\n const fullId = React.useMemo(() => id || uuidv4(), [id]);\n const buttonId = useUniqId();\n\n const [isPlaying, setIsPlaying] = React.useState(!previewImg);\n\n const iframeSrc = React.useMemo(() => {\n if (src && isPlaying) {\n try {\n const url = new URL(src);\n const searchParams = getPageSearchParams({\n ...(attributes || {}),\n ...(previewImg || autoplay ? AUTOPLAY_ATTRIBUTES : NO_AUTOPLAY_ATTRIBUTES),\n });\n\n searchParams.forEach((value, key) => {\n url.searchParams.set(key, value);\n });\n\n return url.href;\n } catch {\n return src;\n }\n }\n\n return undefined;\n }, [attributes, autoplay, isPlaying, previewImg, src]);\n\n const onPreviewClick = React.useCallback(() => {\n handleAnalytics(analyticsEvents);\n\n setIsPlaying(true);\n\n setTimeout(() => setHidePreview(true), AUTOPLAY_DELAY);\n }, [handleAnalytics, analyticsEvents]);\n\n const {onKeyDown: onPreviewKeyDown} = useActionHandlers(onPreviewClick);\n\n React.useEffect(() => {\n const updateSize = debounce(() => {\n setCurrentHeight(\n ref.current ? Math.round(getHeight(ref.current.offsetWidth)) : undefined,\n );\n }, 100);\n\n updateSize();\n window.addEventListener('resize', updateSize, {passive: true});\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, [height]);\n\n const iframeContent = React.useMemo(() => {\n return (\n <iframe\n id={fullId}\n src={iframeSrc}\n width=\"100%\"\n height=\"100%\"\n title={i18n('iframe-title')}\n frameBorder=\"0\"\n allowFullScreen={true}\n scrolling=\"no\"\n allow=\"autoplay; fullscreen; encrypted-media; accelerometer; gyroscope; picture-in-picture; clipboard-write; web-share; screen-wake-lock\"\n loading=\"lazy\"\n />\n );\n }, [fullId, iframeSrc]);\n\n React.useEffect(() => {\n setHidePreview(false);\n }, [src]);\n\n if (!src) {\n return null;\n }\n\n return (\n <div className={b(null, className)} style={{height: currentHeight}} ref={ref}>\n {iframeContent}\n {previewImg && !hidePreview && !fullscreen && (\n <div\n className={b('preview')}\n onClick={onPreviewClick}\n onKeyDown={onPreviewKeyDown}\n role=\"button\"\n tabIndex={0}\n aria-labelledby={playButton ? playButtonId : buttonId}\n >\n <Image\n src={previewImg}\n className={b('image')}\n containerClassName={b('image-wrapper')}\n onLoad={onImageLoad}\n />\n {playButton || (\n <button title=\"Play\" id={buttonId} className={b('button')}>\n <Icon className={b('icon')} data={PlayFill} size={24} />\n </button>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default VideoBlock;\n"]}
1
+ {"version":3,"file":"VideoBlock.js","sourceRoot":"../../../../src","sources":["components/VideoBlock/VideoBlock.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,iBAAiB,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAC/D,OAAO,QAAQ,2BAAwB;AACvC,OAAO,EAAC,EAAE,IAAI,MAAM,EAAC,MAAM,MAAM,CAAC;AAElC,OAAO,EAAC,YAAY,EAAC,oCAAiC;AACtD,OAAO,EAAsB,iBAAiB,EAAC,+BAA4B;AAC3E,OAAO,EAAC,KAAK,EAAE,mBAAmB,EAAC,6BAAoB;AACvD,OAAO,KAAK,0BAAuB;AACnC,OAAO,WAA+B,sCAAmC;AAEzE,OAAO,EAAC,IAAI,EAAC,wBAAe;AAE5B,OAAO,kBAAkB,CAAC;AAE1B,MAAM,UAAU,GAAG,gCAAgC,CAAC;AACpD,MAAM,UAAU,GAAG,oDAAoD,CAAC;AACxE,MAAM,SAAS,GAAG,mBAAmB,CAAC;AACtC,MAAM,SAAS,GAAG,sBAAsB,CAAC;AACzC,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,CAAC;CACV,CAAC;AACF,MAAM,sBAAsB,GAAG;IAC3B,QAAQ,EAAE,CAAC;CACd,CAAC;AAEF,MAAM,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;AAE9B,SAAS,kBAAkB,CAAC,MAAe,EAAE,MAAe;IACxD,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,MAAM;QAC/B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a,aAE9B,KAAC,KAAK,IACF,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,EACrB,kBAAkB,EAAE,CAAC,CAAC,eAAe,CAAC,EACtC,MAAM,EAAE,WAAW,GACrB,EACF,KAAC,WAAW,IAAC,EAAE,EAAE,QAAQ,KAAM,WAAW,GAAI,IAC5C,CACT,IACC,CACT,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {useActionHandlers, useUniqId} from '@gravity-ui/uikit';\nimport debounce from 'lodash/debounce';\nimport {v4 as uuidv4} from 'uuid';\n\nimport {useAnalytics} from '../../hooks/useAnalytics';\nimport {AnalyticsEventsBase, DefaultEventNames} from '../../models/common';\nimport {block, getPageSearchParams} from '../../utils';\nimport Image from '../Image/Image';\nimport VideoButton, {VideoButtonProps} from '../VideoButton/VideoButton';\n\nimport {i18n} from './i18n';\n\nimport './VideoBlock.scss';\n\nconst RECORD_URL = 'https://www.youtube.com/embed/';\nconst STREAM_URL = 'https://www.youtube.com/embed/live_stream?channel=';\nconst RECORD_RE = /[0-9A-Za-z_-]{11}/;\nconst STREAM_RE = /[0-9A-Za-z_-]{23,25}/;\nconst AUTOPLAY_DELAY = 300;\n\nexport const AUTOPLAY_ATTRIBUTES = {\n autoplay: 1,\n mute: 1,\n};\nconst NO_AUTOPLAY_ATTRIBUTES = {\n autoplay: 0,\n};\n\nconst b = block('VideoBlock');\n\nfunction getYoutubeVideoSrc(stream?: string, record?: string) {\n if (!stream && !record) {\n return null;\n }\n\n const [videoLink, url, re] = stream\n ? [stream, STREAM_URL, STREAM_RE]\n : [record, RECORD_URL, RECORD_RE];\n const match = videoLink?.match(re);\n let src;\n\n if (match && match.length) {\n src = url + match[0];\n }\n\n return src;\n}\n\nexport function getHeight(width: number): number {\n return (width / 16) * 9;\n}\n\nconst isReactNode = (value: React.ReactNode | VideoButtonProps) => {\n if (value === null || typeof value === 'boolean') return true;\n\n if (typeof value === 'string' || typeof value === 'number') return true;\n\n if (React.isValidElement(value)) return true;\n\n if (Array.isArray(value)) {\n return value.every(isReactNode);\n }\n\n return false;\n};\n\nexport interface VideoBlockProps extends AnalyticsEventsBase {\n id?: string;\n stream?: string;\n record?: string;\n videoIframe?: string;\n attributes?: Record<string, string>;\n className?: string;\n previewImg?: string;\n playButton?: React.ReactNode | VideoButtonProps;\n playButtonId?: string;\n height?: number;\n fullscreen?: boolean;\n autoplay?: boolean;\n onImageLoad?: () => void;\n}\n\nconst VideoBlock = (props: VideoBlockProps) => {\n const {\n stream,\n record,\n videoIframe,\n attributes,\n className,\n id,\n previewImg,\n playButton,\n playButtonId,\n height,\n fullscreen,\n analyticsEvents,\n autoplay,\n onImageLoad,\n } = props;\n const handleAnalytics = useAnalytics(DefaultEventNames.VideoPreview);\n\n const src = videoIframe ? videoIframe : getYoutubeVideoSrc(stream, record);\n const ref = React.useRef<HTMLDivElement>(null);\n const [hidePreview, setHidePreview] = React.useState(false);\n const [currentHeight, setCurrentHeight] = React.useState(height || undefined);\n const fullId = React.useMemo(() => id || uuidv4(), [id]);\n const buttonId = useUniqId();\n\n const [isPlaying, setIsPlaying] = React.useState(!previewImg);\n\n const iframeSrc = React.useMemo(() => {\n if (src && isPlaying) {\n try {\n const url = new URL(src);\n const searchParams = getPageSearchParams({\n ...(attributes || {}),\n ...(previewImg || autoplay ? AUTOPLAY_ATTRIBUTES : NO_AUTOPLAY_ATTRIBUTES),\n });\n\n searchParams.forEach((value, key) => {\n url.searchParams.set(key, value);\n });\n\n return url.href;\n } catch {\n return src;\n }\n }\n\n return undefined;\n }, [attributes, autoplay, isPlaying, previewImg, src]);\n\n const onPreviewClick = React.useCallback(() => {\n handleAnalytics(analyticsEvents);\n\n setIsPlaying(true);\n\n setTimeout(() => setHidePreview(true), AUTOPLAY_DELAY);\n }, [handleAnalytics, analyticsEvents]);\n\n const {onKeyDown: onPreviewKeyDown} = useActionHandlers(onPreviewClick);\n\n React.useEffect(() => {\n const updateSize = debounce(() => {\n setCurrentHeight(\n ref.current ? Math.round(getHeight(ref.current.offsetWidth)) : undefined,\n );\n }, 100);\n\n updateSize();\n window.addEventListener('resize', updateSize, {passive: true});\n return () => {\n window.removeEventListener('resize', updateSize);\n };\n }, [height]);\n\n const iframeContent = React.useMemo(() => {\n return (\n <iframe\n id={fullId}\n src={iframeSrc}\n width=\"100%\"\n height=\"100%\"\n title={i18n('iframe-title')}\n frameBorder=\"0\"\n allowFullScreen={true}\n scrolling=\"no\"\n allow=\"autoplay; fullscreen; encrypted-media; accelerometer; gyroscope; picture-in-picture; clipboard-write; web-share; screen-wake-lock\"\n loading=\"lazy\"\n />\n );\n }, [fullId, iframeSrc]);\n\n React.useEffect(() => {\n setHidePreview(false);\n }, [src]);\n\n const buttonProps = React.useMemo(\n () =>\n isReactNode(playButton)\n ? {customButton: playButton as React.ReactNode}\n : (playButton as VideoButtonProps | undefined),\n [playButton],\n );\n const buttonLabelId = buttonProps?.customButton ? playButtonId : buttonProps?.id || buttonId;\n\n if (!src) {\n return null;\n }\n\n return (\n <div className={b(null, className)} style={{height: currentHeight}} ref={ref}>\n {iframeContent}\n {previewImg && !hidePreview && !fullscreen && (\n <div\n className={b('preview')}\n onClick={onPreviewClick}\n onKeyDown={onPreviewKeyDown}\n role=\"button\"\n tabIndex={0}\n aria-labelledby={buttonLabelId}\n >\n <Image\n src={previewImg}\n className={b('image')}\n containerClassName={b('image-wrapper')}\n onLoad={onImageLoad}\n />\n <VideoButton id={buttonId} {...buttonProps} />\n </div>\n )}\n </div>\n );\n};\n\nexport default VideoBlock;\n"]}
@@ -0,0 +1,64 @@
1
+ /* use this for style redefinitions to awoid problems with
2
+ unpredictable css rules order in build */
3
+ .pc-video-button {
4
+ display: inline-block;
5
+ margin: 0;
6
+ padding: 0;
7
+ font: inherit;
8
+ border: none;
9
+ outline: none;
10
+ color: inherit;
11
+ background: none;
12
+ cursor: pointer;
13
+ display: flex;
14
+ justify-content: center;
15
+ align-items: center;
16
+ position: absolute;
17
+ width: 64px;
18
+ height: 64px;
19
+ border-radius: 50%;
20
+ transition: color 0.4s, background-color 0.4s;
21
+ }
22
+ .pc-video-button:focus {
23
+ outline: 2px solid var(--g-color-line-focus);
24
+ outline-offset: 0;
25
+ }
26
+ .pc-video-button:focus:not(:focus-visible) {
27
+ outline: 0;
28
+ }
29
+ .pc-video-button_theme_blue {
30
+ color: var(--g-color-base-background);
31
+ background-color: var(--g-color-base-brand);
32
+ }
33
+ .pc-video-button_theme_blue:hover {
34
+ background-color: var(--g-color-base-brand-hover);
35
+ }
36
+ .pc-video-button_theme_grey {
37
+ color: var(--pc-text-header-color);
38
+ background-color: #eff2f8;
39
+ }
40
+ .pc-video-button_theme_custom {
41
+ color: var(--pc-video-button-triangle-color);
42
+ background-color: var(--pc-video-button-circle-color);
43
+ }
44
+ .pc-video-button_theme_custom:hover {
45
+ color: var(--pc-video-button-triangle-hover-color, var(--pc-video-button-triangle-color));
46
+ background-color: var(--pc-video-button-circle-hover-color, var(--pc-video-button-circle-color));
47
+ }
48
+ .pc-video-button_text {
49
+ padding: 16px 32px;
50
+ font-weight: 400;
51
+ font-size: 24px;
52
+ line-height: 32px;
53
+ width: auto;
54
+ height: auto;
55
+ }
56
+ .pc-video-button__icon {
57
+ margin-left: 1px;
58
+ }
59
+ @media only screen and (max-width: 577px) {
60
+ .pc-video-button_text {
61
+ font-size: 20px;
62
+ line-height: 24px;
63
+ }
64
+ }
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { PlayButtonProps } from "../../models/index.js";
3
+ import './VideoButton.css';
4
+ export interface VideoButtonProps extends PlayButtonProps {
5
+ customButton?: React.ReactNode;
6
+ ref?: React.LegacyRef<HTMLButtonElement>;
7
+ id?: string;
8
+ }
9
+ declare const VideoButton: ({ customButton, text, type, theme: initialTheme, className, ref, id, }: VideoButtonProps) => string | number | true | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element;
10
+ export default VideoButton;
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { PlayFill } from '@gravity-ui/icons';
4
+ import { Icon } from '@gravity-ui/uikit';
5
+ import { ProjectSettingsContext } from "../../context/projectSettingsContext/index.js";
6
+ import { useTheme } from "../../context/theme/index.js";
7
+ import { PlayButtonThemes, PlayButtonType } from "../../models/index.js";
8
+ import { block, getThemedValue } from "../../utils/index.js";
9
+ import { i18n } from "../ReactPlayer/i18n/index.js";
10
+ import './VideoButton.css';
11
+ const b = block('video-button');
12
+ const VideoButton = ({ customButton, text, type, theme: initialTheme, className, ref, id, }) => {
13
+ const { defaultVideoButtonSettings } = React.useContext(ProjectSettingsContext);
14
+ const currentTheme = useTheme();
15
+ const playButtonContent = React.useMemo(() => {
16
+ switch (type) {
17
+ case PlayButtonType.Text:
18
+ return text;
19
+ case PlayButtonType.Default:
20
+ default:
21
+ return _jsx(Icon, { className: b('icon'), data: PlayFill, size: 24 });
22
+ }
23
+ }, [text, type]);
24
+ const theme = initialTheme || defaultVideoButtonSettings?.theme || PlayButtonThemes.Blue;
25
+ const style = React.useMemo(() => {
26
+ if (theme !== PlayButtonThemes.Custom) {
27
+ return undefined;
28
+ }
29
+ const themedColors = defaultVideoButtonSettings?.colors
30
+ ? getThemedValue(defaultVideoButtonSettings.colors, currentTheme)
31
+ : undefined;
32
+ const resolveColor = (colorName) => {
33
+ return themedColors?.[colorName];
34
+ };
35
+ return {
36
+ '--pc-video-button-circle-color': resolveColor('circleColor'),
37
+ '--pc-video-button-circle-hover-color': resolveColor('circleHoverColor'),
38
+ '--pc-video-button-triangle-color': resolveColor('triangleColor'),
39
+ '--pc-video-button-triangle-hover-color': resolveColor('triangleHoverColor'),
40
+ };
41
+ }, [currentTheme, defaultVideoButtonSettings?.colors, theme]);
42
+ if (customButton) {
43
+ return customButton;
44
+ }
45
+ return (_jsx("button", { className: b({ theme, text: Boolean(text) }, className), "aria-label": i18n('play'), ref: ref, id: id, style: style, children: playButtonContent }));
46
+ };
47
+ export default VideoButton;
48
+ //# sourceMappingURL=VideoButton.js.map