@cntrl-site/sdk-nextjs 1.1.1 → 1.1.2

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.
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
@@ -61,6 +70,18 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
61
70
  }
62
71
  });
63
72
  }, [vimeoPlayer, imgRef]);
73
+ const handleClick = () => __awaiter(void 0, void 0, void 0, function* () {
74
+ if (!vimeoPlayer)
75
+ return;
76
+ const isPaused = yield vimeoPlayer.getPaused();
77
+ if (isPaused) {
78
+ vimeoPlayer.play();
79
+ setIsCoverVisible(false);
80
+ }
81
+ else {
82
+ vimeoPlayer.pause();
83
+ }
84
+ });
64
85
  const onCoverClick = () => {
65
86
  if (!vimeoPlayer || !imgRef)
66
87
  return;
@@ -88,7 +109,13 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
88
109
  width: '100%',
89
110
  top: '0',
90
111
  left: '0'
91
- }, alt: "Cover img" })), (0, jsx_runtime_1.jsx)("iframe", { ref: setIframeRef, className: `embed-video`, src: validUrl || '', allow: "autoplay; fullscreen; picture-in-picture;", allowFullScreen: true, style: Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (_j = frameStateParams === null || frameStateParams === void 0 ? void 0 : frameStateParams.transition) !== null && _j !== void 0 ? _j : 'none' }) })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
112
+ }, alt: "Cover img" })), (!item.commonParams.controls && play === 'on-click') && ((0, jsx_runtime_1.jsx)("div", { onClick: handleClick, style: {
113
+ position: 'absolute',
114
+ height: '100%',
115
+ width: '100%',
116
+ top: '0',
117
+ left: '0'
118
+ } })), (0, jsx_runtime_1.jsx)("iframe", { ref: setIframeRef, className: `embed-video`, src: validUrl || '', allow: "autoplay; fullscreen; picture-in-picture;", allowFullScreen: true, style: Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (_j = frameStateParams === null || frameStateParams === void 0 ? void 0 : frameStateParams.transition) !== null && _j !== void 0 ? _j : 'none' }) })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
92
119
  .embed-video-wrapper-${item.id} {
93
120
  position: absolute;
94
121
  width: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "SDK for Next.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/index.ts",
@@ -61,6 +61,17 @@ export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item, sectionId
61
61
  });
62
62
  }, [vimeoPlayer, imgRef]);
63
63
 
64
+ const handleClick = async () => {
65
+ if (!vimeoPlayer) return;
66
+ const isPaused = await vimeoPlayer.getPaused();
67
+ if (isPaused) {
68
+ vimeoPlayer.play();
69
+ setIsCoverVisible(false);
70
+ } else {
71
+ vimeoPlayer.pause();
72
+ }
73
+ };
74
+
64
75
  const onCoverClick = () => {
65
76
  if (!vimeoPlayer || !imgRef) return;
66
77
  vimeoPlayer!.play();
@@ -109,6 +120,19 @@ export const VimeoEmbedItem: FC<ItemProps<TVimeoEmbedItem>> = ({ item, sectionId
109
120
  alt="Cover img"
110
121
  />
111
122
  )}
123
+ {/* ↓ This is necessary to track clicks on an iframe. */}
124
+ {(!item.commonParams.controls && play === 'on-click') && (
125
+ <div
126
+ onClick={handleClick}
127
+ style={{
128
+ position: 'absolute',
129
+ height: '100%',
130
+ width: '100%',
131
+ top: '0',
132
+ left: '0'
133
+ }}
134
+ />
135
+ )}
112
136
  <iframe
113
137
  ref={setIframeRef}
114
138
  className={`embed-video`}
@@ -1,15 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="HtmlUnknownAttribute" enabled="true" level="WARNING" enabled_by_default="true">
5
- <option name="myValues">
6
- <value>
7
- <list size="1">
8
- <item index="0" class="java.lang.String" itemvalue="jsx" />
9
- </list>
10
- </value>
11
- </option>
12
- <option name="myCustomValuesEnabled" value="true" />
13
- </inspection_tool>
14
- </profile>
15
- </component>