@gravity-ui/page-constructor 8.14.2 → 8.16.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 (75) hide show
  1. package/README.md +31 -9
  2. package/build/cjs/components/ReactPlayer/ReactPlayer.css +0 -50
  3. package/build/cjs/components/ReactPlayer/ReactPlayer.js +4 -16
  4. package/build/cjs/components/ReactPlayer/ReactPlayer.js.map +1 -1
  5. package/build/cjs/components/VideoBlock/VideoBlock.css +0 -30
  6. package/build/cjs/components/VideoBlock/VideoBlock.d.ts +2 -1
  7. package/build/cjs/components/VideoBlock/VideoBlock.js +18 -2
  8. package/build/cjs/components/VideoBlock/VideoBlock.js.map +1 -1
  9. package/build/cjs/components/VideoButton/VideoButton.css +64 -0
  10. package/build/cjs/components/VideoButton/VideoButton.d.ts +9 -0
  11. package/build/cjs/components/VideoButton/VideoButton.js +50 -0
  12. package/build/cjs/components/VideoButton/VideoButton.js.map +1 -0
  13. package/build/cjs/context/projectSettingsContext/ProjectSettingsContext.d.ts +7 -0
  14. package/build/cjs/context/projectSettingsContext/ProjectSettingsContext.js.map +1 -1
  15. package/build/cjs/models/constructor-items/common.d.ts +8 -1
  16. package/build/cjs/models/constructor-items/common.js +1 -0
  17. package/build/cjs/models/constructor-items/common.js.map +1 -1
  18. package/build/docs/INDEX.md +191 -0
  19. package/build/docs/blocks/Banner.md +59 -0
  20. package/build/docs/blocks/CardLayout.md +79 -0
  21. package/build/docs/blocks/Companies.md +67 -0
  22. package/build/docs/blocks/ContentLayout.md +54 -0
  23. package/build/docs/blocks/ExtendedFeatures.md +74 -0
  24. package/build/docs/blocks/FilterBlock.md +112 -0
  25. package/build/docs/blocks/FoldableList.md +78 -0
  26. package/build/docs/blocks/Footer.md +110 -0
  27. package/build/docs/blocks/Form.md +89 -0
  28. package/build/docs/blocks/Header.md +70 -0
  29. package/build/docs/blocks/HeaderSlider.md +70 -0
  30. package/build/docs/blocks/Hero.md +67 -0
  31. package/build/docs/blocks/Icons.md +61 -0
  32. package/build/docs/blocks/Info.md +73 -0
  33. package/build/docs/blocks/Map.md +81 -0
  34. package/build/docs/blocks/Media.md +63 -0
  35. package/build/docs/blocks/PromoFeaturesBlock.md +74 -0
  36. package/build/docs/blocks/Questions.md +78 -0
  37. package/build/docs/blocks/Share.md +45 -0
  38. package/build/docs/blocks/Slider.md +89 -0
  39. package/build/docs/blocks/SliderOld.md +63 -0
  40. package/build/docs/blocks/Table.md +64 -0
  41. package/build/docs/blocks/Tabs.md +92 -0
  42. package/build/docs/guides/data-preparation-ru.md +257 -0
  43. package/build/docs/guides/data-preparation.md +259 -0
  44. package/build/docs/sub-blocks/BackgroundCard.md +63 -0
  45. package/build/docs/sub-blocks/BannerCard.md +57 -0
  46. package/build/docs/sub-blocks/BasicCard.md +60 -0
  47. package/build/docs/sub-blocks/Content.md +58 -0
  48. package/build/docs/sub-blocks/Divider.md +47 -0
  49. package/build/docs/sub-blocks/HubspotForm.md +47 -0
  50. package/build/docs/sub-blocks/ImageCard.md +59 -0
  51. package/build/docs/sub-blocks/LayoutItem.md +70 -0
  52. package/build/docs/sub-blocks/MediaCard.md +66 -0
  53. package/build/docs/sub-blocks/PriceCard.md +60 -0
  54. package/build/docs/sub-blocks/PriceDetailed.md +74 -0
  55. package/build/docs/sub-blocks/Quote.md +74 -0
  56. package/build/esm/components/ReactPlayer/ReactPlayer.css +0 -50
  57. package/build/esm/components/ReactPlayer/ReactPlayer.js +4 -16
  58. package/build/esm/components/ReactPlayer/ReactPlayer.js.map +1 -1
  59. package/build/esm/components/VideoBlock/VideoBlock.css +0 -30
  60. package/build/esm/components/VideoBlock/VideoBlock.d.ts +2 -1
  61. package/build/esm/components/VideoBlock/VideoBlock.js +19 -3
  62. package/build/esm/components/VideoBlock/VideoBlock.js.map +1 -1
  63. package/build/esm/components/VideoButton/VideoButton.css +64 -0
  64. package/build/esm/components/VideoButton/VideoButton.d.ts +10 -0
  65. package/build/esm/components/VideoButton/VideoButton.js +48 -0
  66. package/build/esm/components/VideoButton/VideoButton.js.map +1 -0
  67. package/build/esm/context/projectSettingsContext/ProjectSettingsContext.d.ts +7 -0
  68. package/build/esm/context/projectSettingsContext/ProjectSettingsContext.js.map +1 -1
  69. package/build/esm/models/constructor-items/common.d.ts +8 -1
  70. package/build/esm/models/constructor-items/common.js +1 -0
  71. package/build/esm/models/constructor-items/common.js.map +1 -1
  72. package/package.json +3 -2
  73. package/server/models/constructor-items/common.d.ts +8 -1
  74. package/server/models/constructor-items/common.js +1 -0
  75. package/widget/index.js +1 -1
@@ -0,0 +1,70 @@
1
+ # LayoutItem
2
+
3
+ Renders a two-part card: a media area (image, video, YouTube, etc.) stacked above a text content area with optional title, body, buttons, links, list, and meta info. Used as the primary content unit inside card-grid blocks.
4
+
5
+ ## Sub-block type
6
+
7
+ `type: 'layout-item'`
8
+
9
+ ## Used in
10
+
11
+ Accepted as `children` by `CardLayout`, `Slider`, `SliderOld`; also used as the card payload in `FilterBlock` items.
12
+
13
+ ## Example
14
+
15
+ ```json
16
+ {
17
+ "type": "layout-item",
18
+ "content": {
19
+ "title": "Lorem ipsum",
20
+ "text": "Dolor sit *amet*",
21
+ "buttons": [
22
+ {"text": "Button 1", "theme": "action", "url": "#test1"},
23
+ {"text": "Button 2", "theme": "outlined", "url": "#test2"}
24
+ ]
25
+ },
26
+ "media": {
27
+ "light": {"image": "/assets/light.png"},
28
+ "dark": {"image": "/assets/dark.png"}
29
+ }
30
+ }
31
+ ```
32
+
33
+ ## Properties
34
+
35
+ | Property | Type | Default | Description |
36
+ | -------------------- | ------------------------------------ | ----------- | --------------------------------------------------------------------------------------------- |
37
+ | `type` _required_ | `'layout-item'` | — | Sub-block discriminator. |
38
+ | `when` | `string` | — | Conditional rendering expression. |
39
+ | `content` _required_ | `object` | — | Text content area. See below. |
40
+ | `media` _required_ | `MediaProps \| {light, dark}` | — | Media area (image / video / youtube / iframe / dataLens). Themed: `T \| {light: T, dark: T}`. |
41
+ | `contentMargin` | `'m' \| 'l'` | `'m'` | Spacing between the media and the content. |
42
+ | `metaInfo` | `string[]` | — | List of meta strings rendered under the media (YFM supported). |
43
+ | `border` | `boolean` | — | Adds a border to the media. |
44
+ | `fullscreen` | `boolean` | — | Enables fullscreen-expandable media (icon + overlay). |
45
+ | `controlPosition` | `'content' \| 'footer'` | `'content'` | Where buttons/links render: inline in the content or at the card footer. |
46
+ | `analyticsEvents` | `AnalyticsEvent \| AnalyticsEvent[]` | — | Analytics events fired on media interaction. |
47
+
48
+ ### `content` object
49
+
50
+ Inherits the `Content` schema (without `colSizes` / `centered`):
51
+
52
+ | Property | Type | Default | Description |
53
+ | ----------------- | -------------------------------- | ------- | --------------------------------------------------------------------- |
54
+ | `title` | `string \| TitleProps` | — | Card title (plain text or a title options object). |
55
+ | `text` | `string` (YFM) | — | Body text in YFM Markdown. |
56
+ | `additionalInfo` | `string` (YFM) | — | Secondary text block below the body. |
57
+ | `size` | `'s' \| 'm' \| 'l' \| 'xl'` | `'s'` | Text/content scale. |
58
+ | `theme` | `'default' \| 'dark' \| 'light'` | — | Content color theme. |
59
+ | `links` | `LinkProps[]` | — | Inline links (each requires `text` + `url`). |
60
+ | `buttons` | `ButtonProps[]` | — | Inline buttons (each requires `text` + `url`). |
61
+ | `list` | `ContentItem[]` | — | Icon + title + text list. Each item requires `icon` or `gravityIcon`. |
62
+ | `controlPosition` | `'default' \| 'bottom'` | — | Inline positioning of buttons/links within the content. |
63
+
64
+ ## Themed values
65
+
66
+ `media` (and the deprecated `icon`) accept `T | {light: T, dark: T}` and are resolved at runtime via the active theme.
67
+
68
+ ## Storybook
69
+
70
+ [LayoutItem](https://preview.gravity-ui.com/page-constructor/?path=/docs/components-cards-layoutitem--docs)
@@ -0,0 +1,66 @@
1
+ # MediaCard
2
+
3
+ Wraps a single media element (image, image slider, video, YouTube, iframe, or DataLens) inside a card with an optional border. Pure media card — no text content.
4
+
5
+ ## Sub-block type
6
+
7
+ `type: 'media-card'`
8
+
9
+ ## Used in
10
+
11
+ Accepted as `children` by `CardLayout`, `Slider`, `SliderOld`; also usable as a card payload in `FilterBlock` items.
12
+
13
+ ## Example
14
+
15
+ ```json
16
+ {
17
+ "type": "media-card",
18
+ "image": {
19
+ "src": "/assets/img_6-12_white.png",
20
+ "alt": "Picture",
21
+ "disableCompress": true
22
+ }
23
+ }
24
+ ```
25
+
26
+ Array of images creates a slider:
27
+
28
+ ```json
29
+ {
30
+ "type": "media-card",
31
+ "image": ["/assets/img1.png", "/assets/img2.png", "/assets/img3.png"]
32
+ }
33
+ ```
34
+
35
+ ## Properties
36
+
37
+ | Property | Type | Default | Description |
38
+ | --------------------------------- | --------------------------------------- | ------- | ----------------------------------------------------------- |
39
+ | `type` _required_ | `'media-card'` | — | Sub-block discriminator. |
40
+ | `when` | `string` | — | Conditional rendering expression. |
41
+ | `border` | `'line' \| 'shadow' \| 'none'` | — | Card border style. |
42
+ | `animated` | `boolean` | — | Enables scroll-triggered entrance animation. |
43
+ | `color` | `string` | — | Background color. |
44
+ | `image` | `ImageProps \| ImageProps[]` | — | Single image or array of images (array becomes a slider). |
45
+ | `disableImageSliderForArrayInput` | `boolean` | — | Render an image array as a static grid instead of a slider. |
46
+ | `video` | `VideoProps` | — | Hosted video (`src` array required). |
47
+ | `youtube` | `string` | — | YouTube video URL or ID. |
48
+ | `videoIframe` | `string` | — | Embeddable video iframe URL. |
49
+ | `autoplay` | `boolean` | — | Autoplay video media. |
50
+ | `parallax` | `boolean` | — | Parallax scroll effect on the media. |
51
+ | `height` | `number` | — | Fixed media height in pixels. |
52
+ | `previewImg` | `string` | — | Poster image shown before video playback. |
53
+ | `dataLens` | `string \| {id, theme}` | — | Embedded DataLens chart/object. |
54
+ | `fullscreen` | `boolean` | — | Enables fullscreen-expandable media. |
55
+ | `ratio` | `number \| 'auto'` | — | Aspect ratio of the media. |
56
+ | `iframe` | `{src, name?, title?, height?, width?}` | — | Generic iframe embed (`src` required). |
57
+ | `margins` | `boolean` | — | Adds inner media margins. |
58
+ | `analyticsEvents` | `AnalyticsEvent \| AnalyticsEvent[]` | — | Analytics events fired on media interaction. |
59
+
60
+ ## Themed values
61
+
62
+ `color`, `image`, and other media fields resolve themed values (`T | {light: T, dark: T}`) at runtime via the active theme.
63
+
64
+ ## Storybook
65
+
66
+ [MediaCard](https://preview.gravity-ui.com/page-constructor/?path=/docs/components-cards-mediacard--docs)
@@ -0,0 +1,60 @@
1
+ # PriceCard
2
+
3
+ Renders a pricing card: a title, a price (with optional period and details), a description, a checklist of features, and optional buttons and links. Typically placed in a grid to compare plans.
4
+
5
+ ## Sub-block type
6
+
7
+ `type: 'price-card'`
8
+
9
+ ## Used in
10
+
11
+ Accepted as `children` by `CardLayout`, `Slider`, `SliderOld`; also usable as a card payload in `FilterBlock` items.
12
+
13
+ ## Example
14
+
15
+ ```json
16
+ {
17
+ "type": "price-card",
18
+ "title": "Lorem ipsum",
19
+ "price": "299.99 $",
20
+ "pricePeriod": "month",
21
+ "priceDetails": "plan details",
22
+ "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
23
+ "list": [
24
+ "Ut enim ad minim veniam [quis nostrud](https://example.com) exercitation.",
25
+ "Ut enim ad minim veniam [quis nostrud](https://example.com) exercitation."
26
+ ],
27
+ "buttons": [
28
+ {"text": "Choose plan", "url": "https://example.com", "width": "max", "theme": "action"}
29
+ ],
30
+ "theme": "light",
31
+ "backgroundColor": "#CCDAFF"
32
+ }
33
+ ```
34
+
35
+ ## Properties
36
+
37
+ | Property | Type | Default | Description |
38
+ | ------------------ | -------------------------------- | ------- | ---------------------------------------------------------------------------- |
39
+ | `type` _required_ | `'price-card'` | — | Sub-block discriminator. |
40
+ | `when` | `string` | — | Conditional rendering expression. |
41
+ | `border` | `'line' \| 'shadow' \| 'none'` | — | Card border style. |
42
+ | `theme` | `'default' \| 'dark' \| 'light'` | — | Content color theme. |
43
+ | `title` _required_ | `string` (YFM) | — | Plan name rendered as YFM. |
44
+ | `price` _required_ | `string` | — | Price value (e.g. `"299.99 $"`). |
45
+ | `pricePeriod` | `string` | — | Billing period shown after the price (e.g. `"month"`). |
46
+ | `priceDetails` | `string` | — | Small print under the price. |
47
+ | `description` | `string` | — | Short plan description. |
48
+ | `list` | `string[]` | — | Feature list; each item rendered with a check icon (YFM/Markdown supported). |
49
+ | `buttons` | `ButtonProps[]` | — | CTA buttons (each requires `text` + `url`). |
50
+ | `links` | `LinkProps[]` | — | Secondary links (each requires `text` + `url`). |
51
+ | `backgroundColor` | `string` | — | Custom card background color. |
52
+ | `controlPosition` | `'content' \| 'footer'` | — | Where buttons/links render within the card. |
53
+
54
+ ## Themed values
55
+
56
+ `backgroundColor` and color-bearing fields resolve themed values (`T | {light: T, dark: T}`) at runtime via the active theme.
57
+
58
+ ## Storybook
59
+
60
+ [PriceCard](https://preview.gravity-ui.com/page-constructor/?path=/docs/components-cards-pricecard--docs)
@@ -0,0 +1,74 @@
1
+ # PriceDetailed
2
+
3
+ > ⚠️ **Deprecated.** This sub-block is deprecated and will be removed in a future major release. Prefer [`PriceCard`](./PriceCard.md) for pricing cards.
4
+
5
+ Renders a detailed pricing comparison table: each item has a title, a per-unit description, an optional label, and a list of details (either a marked list or a settings list). Supports combined or separate layout, foldable details, and per-color default label text.
6
+
7
+ ## Sub-block type
8
+
9
+ `type: 'price-detailed'`
10
+
11
+ ## Used in
12
+
13
+ Accepted as `children` by `CardLayout`, `Slider`, `SliderOld`.
14
+
15
+ ## Example
16
+
17
+ ```json
18
+ {
19
+ "type": "price-detailed",
20
+ "priceType": "settings",
21
+ "description": {"titleSize": "l", "descriptionSize": "m", "titleColor": "cornflower"},
22
+ "details": {"titleSize": "s", "descriptionSize": "m"},
23
+ "items": [
24
+ {
25
+ "title": "Free",
26
+ "detailedTitle": "",
27
+ "description": "For use by individuals and small teams",
28
+ "label": {"color": "blue", "text": "Free", "size": "s"},
29
+ "items": [{"title": "up to 5 users", "description": "up to 5 users"}]
30
+ }
31
+ ]
32
+ }
33
+ ```
34
+
35
+ ## Properties
36
+
37
+ | Property | Type | Default | Description |
38
+ | ----------------------------- | ----------------------------------------- | -------------- | ----------------------------------------------------------------------------- |
39
+ | `type` _required_ | `'price-detailed'` | — | Sub-block discriminator. |
40
+ | `when` | `string` | — | Conditional rendering expression. |
41
+ | `animated` | `boolean` | — | Enables scroll-triggered entrance animation. |
42
+ | `items` _required_ | `PriceItem[]` | — | Pricing columns/rows. See below. |
43
+ | `description` | `object` | — | Sizing/color overrides for the description block. |
44
+ | `description.titleSize` | `'xs' \| 's' \| 'sm' \| 'm' \| 'l'` | `'l'` | Description title size. |
45
+ | `description.descriptionSize` | `'xs' \| 's' \| 'sm' \| 'm' \| 'l'` | `'m'` | Description body size. |
46
+ | `description.titleColor` | `'cornflower' \| 'black'` | `'cornflower'` | Description title color. |
47
+ | `details` | `object` | — | Sizing overrides for the details block. |
48
+ | `details.titleSize` | `'xs' \| 's' \| 'sm' \| 'm' \| 'l'` | `'s'` | Details title size. |
49
+ | `details.descriptionSize` | `'xs' \| 's' \| 'sm' \| 'm' \| 'l'` | `'m'` | Details body size. |
50
+ | `priceType` | `'marked-list' \| 'settings'` | `'settings'` | Layout of each item's `items` list. |
51
+ | `numberGroupItems` | `3 \| 4 \| 5` | — | Items per row in the combined layout. |
52
+ | `isCombined` | `boolean` | `false` | Use the combined grid layout instead of separate columns. |
53
+ | `useMixedView` | `boolean` | `false` | Mix list item views (extended details on desktop, collapse on tablet/mobile). |
54
+ | `foldable` | `{title*required, size?, titleColor?}` | — | Makes the details section collapsible with a toggle. |
55
+ | `labelsDefaultText` | `{blue?, green?, yellow?, purple?, red?}` | — | Default text used for each label color when an item label has no `text`. |
56
+
57
+ ### `PriceItem` object
58
+
59
+ | Property | Type | Default | Description |
60
+ | ------------------------ | ---------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- |
61
+ | `title` _required_ | `string` | — | Plan title (e.g. `"Free"`, `"100$"`). |
62
+ | `description` _required_ | `string` (YFM) | — | Plan description. |
63
+ | `detailedTitle` | `string` | — | Suffix/qualifier shown next to the title (e.g. `"/ month*"`). |
64
+ | `label` | `{color*required, text?, size?}` | — | Colored label badge. `color`: `'blue' \| 'green' \| 'yellow' \| 'purple' \| 'red'`. `size`: `'xs' \| 's' \| 'sm' \| 'm' \| 'l'`. |
65
+ | `items` | `PriceDetailsList[] \| PriceDetailsSettings[]` | — | Detail list. With `priceType: 'marked-list'` each item requires `text`; with `'settings'` each requires `title` + `description`. |
66
+ | `analyticsEvents` | `AnalyticsEvent \| AnalyticsEvent[]` | — | Analytics events. |
67
+
68
+ ## Themed values
69
+
70
+ This sub-block does not consume themed media; sizing/color controls above are explicit.
71
+
72
+ ## Storybook
73
+
74
+ [PriceDetailed](https://preview.gravity-ui.com/page-constructor/?path=/docs/components-cards-pricedetailed-deprecated--docs)
@@ -0,0 +1,74 @@
1
+ # Quote
2
+
3
+ Renders a customer testimonial / quote card: a logo, the quote body, an optional author (name + avatar + description), and an optional CTA button. Paired with a large image on the side.
4
+
5
+ ## Sub-block type
6
+
7
+ `type: 'quote'`
8
+
9
+ ## Used in
10
+
11
+ Accepted as `children` by `CardLayout`, `Slider`, `SliderOld`; also usable as a card payload in `FilterBlock` items.
12
+
13
+ ## Example
14
+
15
+ ```json
16
+ {
17
+ "type": "quote",
18
+ "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
19
+ "quoteType": "chevron",
20
+ "theme": "light",
21
+ "image": {
22
+ "light": {"src": "/assets/img_6-12_light.png"},
23
+ "dark": {"src": "/assets/img_8-12_dark.png"}
24
+ },
25
+ "logo": {"src": "/assets/logo.png", "alt": "Company logo"},
26
+ "author": {
27
+ "firstName": "Lorem",
28
+ "secondName": "ipsum",
29
+ "description": "CEO, Acme",
30
+ "avatar": "/assets/avatar.png"
31
+ },
32
+ "button": {
33
+ "text": "Read the case study",
34
+ "theme": "outlined",
35
+ "url": "https://example.com"
36
+ }
37
+ }
38
+ ```
39
+
40
+ ## Properties
41
+
42
+ | Property | Type | Default | Description |
43
+ | ------------------ | ------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
44
+ | `type` _required_ | `'quote'` | — | Sub-block discriminator. |
45
+ | `when` | `string` | — | Conditional rendering expression. |
46
+ | `text` | `string` | — | Quote body (plain text). Prefer `yfmText` for Markdown. |
47
+ | `yfmText` | `string` (YFM) | — | Quote body in YFM Markdown (overrides `text` when set). |
48
+ | `image` _required_ | `ImageProps \| {light, dark}` | — | Large side image. Themed: `T \| {light: T, dark: T}`. |
49
+ | `logo` _required_ | `ImageProps` | — | Company/personal logo shown above the quote. |
50
+ | `color` | `string` | — | Custom card background color. |
51
+ | `url` | `string` | — | Link URL for the CTA. Deprecated, prefer `button`. |
52
+ | `urlTitle` | `string` | — | Title/tooltip for the CTA link. Deprecated, prefer `button`. |
53
+ | `buttonText` | `string` | — | CTA button text. Deprecated, prefer `button`. |
54
+ | `button` | `ButtonProps` | — | Full button configuration (preferred over `url` / `urlTitle` / `buttonText`). Available on the component model; not part of the JSON schema. |
55
+ | `theme` | `'light' \| 'dark'` | `'light'` | Text color theme. |
56
+ | `quoteType` | `'chevron' \| 'english-double'` | `'chevron'` | Quotation mark style. `chevron` renders `« »`, `english-double` renders `“ ”`. |
57
+ | `author` | `object` | — | Author block. See below. |
58
+
59
+ ### `author` object
60
+
61
+ | Property | Type | Default | Description |
62
+ | ----------------------- | ----------------------------- | ------- | -------------------------- |
63
+ | `firstName` _required_ | `string` | — | Author first name. |
64
+ | `secondName` _required_ | `string` | — | Author second name. |
65
+ | `avatar` | `ImageProps \| {light, dark}` | — | Avatar image (themed). |
66
+ | `description` | `string` (YFM) | — | Author role / description. |
67
+
68
+ ## Themed values
69
+
70
+ `image` and `author.avatar` accept `T | {light: T, dark: T}` and are resolved at runtime via the active theme.
71
+
72
+ ## Storybook
73
+
74
+ [Quote](https://preview.gravity-ui.com/page-constructor/?path=/docs/components-cards-quote--docs)
@@ -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 &&
143
131
  playerRef &&
@@ -1 +1 @@
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,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AACvC,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,EAAC,6BAAoB;AACjE,OAAO,EAGH,+BAA+B,EAC/B,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EAGtB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,GAEvB,8BAAqB;AACtB,OAAO,EAAC,KAAK,EAAC,6BAAoB;AAElC,OAAO,iBAAiB,+BAA4B;AACpD,OAAO,EAAC,IAAI,EAAC,wBAAe;AAC5B,OAAO,EAAC,kBAAkB,EAAC,mBAAgB;AAC3C,OAAO,EAAC,uBAAuB,EAAC,2BAAwB;AAExD,OAAO,mBAAmB,CAAC;AAE3B,MAAM,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC;AAE/B,MAAM,GAAG,GAAG,EAAE,CAAC;AAEf,MAAM,WAAW,GAC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AAC,SAAS;6BACrD;yBACJ;qBACJ,GACH,EACD,QAAQ,KAAK,sBAAsB,CAAC,MAAM,IAAI,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 {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.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,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"]}