@webstudio-is/sdk-components-react 0.71.0 → 0.73.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.
- package/lib/__generated__/button.props.js +0 -6
- package/lib/__generated__/image.props.js +0 -1
- package/lib/__generated__/link-block.props.js +1 -7
- package/lib/__generated__/link.props.js +1 -7
- package/lib/__generated__/rich-text-link.props.js +1 -7
- package/lib/__generated__/{radio-button-field.props.js → vimeo-play-button.props.js} +14 -0
- package/lib/__generated__/vimeo-preview-image.props.js +441 -0
- package/lib/__generated__/{checkbox-field.props.js → vimeo-spinner.props.js} +0 -1
- package/lib/__generated__/vimeo.props.js +555 -0
- package/lib/blockquote.ws.js +1 -1
- package/lib/box.js +2 -1
- package/lib/button.js +1 -6
- package/lib/button.ws.js +9 -2
- package/lib/checkbox.ws.js +19 -1
- package/lib/cjs/__generated__/button.props.js +0 -6
- package/lib/cjs/__generated__/image.props.js +0 -1
- package/lib/cjs/__generated__/link-block.props.js +1 -7
- package/lib/cjs/__generated__/link.props.js +1 -7
- package/lib/cjs/__generated__/rich-text-link.props.js +1 -7
- package/lib/cjs/__generated__/{text-block.props.js → text.props.js} +3 -3
- package/lib/cjs/__generated__/{radio-button-field.props.js → vimeo-play-button.props.js} +17 -3
- package/lib/cjs/__generated__/vimeo-preview-image.props.js +461 -0
- package/lib/cjs/__generated__/{checkbox-field.props.js → vimeo-spinner.props.js} +3 -4
- package/lib/cjs/__generated__/vimeo.props.js +575 -0
- package/lib/cjs/blockquote.ws.js +1 -1
- package/lib/cjs/box.js +2 -1
- package/lib/cjs/button.js +1 -6
- package/lib/cjs/button.ws.js +9 -2
- package/lib/cjs/checkbox.ws.js +19 -1
- package/lib/cjs/code-text.ws.js +1 -1
- package/lib/cjs/components.js +11 -9
- package/lib/cjs/heading.ws.js +1 -1
- package/lib/cjs/image.js +3 -3
- package/lib/cjs/image.ws.js +12 -9
- package/lib/cjs/label.ws.js +3 -6
- package/lib/cjs/link.js +1 -1
- package/lib/cjs/link.ws.js +3 -3
- package/lib/cjs/list-item.ws.js +1 -1
- package/lib/cjs/metas.js +11 -9
- package/lib/cjs/paragraph.ws.js +2 -2
- package/lib/cjs/props.js +11 -9
- package/lib/cjs/radio-button.ws.js +19 -1
- package/lib/cjs/rich-text-link.ws.js +3 -10
- package/lib/cjs/span.ws.js +1 -1
- package/lib/cjs/{text-block.js → text.js} +6 -6
- package/lib/cjs/{text-block.ws.js → text.ws.js} +10 -10
- package/lib/cjs/{link-block.js → vimeo-play-button.js} +17 -9
- package/lib/cjs/{link-block.ws.js → vimeo-play-button.ws.js} +13 -22
- package/lib/cjs/vimeo-preview-image.js +40 -0
- package/lib/cjs/{radio-button-field.js → vimeo-preview-image.ws.js} +17 -10
- package/lib/cjs/{checkbox-field.js → vimeo-spinner.js} +16 -8
- package/lib/cjs/{checkbox-field.ws.js → vimeo-spinner.ws.js} +11 -30
- package/lib/cjs/vimeo.js +294 -0
- package/lib/cjs/vimeo.ws.js +345 -0
- package/lib/code-text.ws.js +1 -1
- package/lib/components.js +11 -9
- package/lib/heading.ws.js +1 -1
- package/lib/image.js +6 -5
- package/lib/image.ws.js +12 -9
- package/lib/label.ws.js +4 -7
- package/lib/link.js +3 -3
- package/lib/link.ws.js +3 -3
- package/lib/list-item.ws.js +1 -1
- package/lib/metas.js +52 -50
- package/lib/paragraph.ws.js +2 -2
- package/lib/props.js +52 -50
- package/lib/radio-button.ws.js +19 -1
- package/lib/rich-text-link.ws.js +3 -10
- package/lib/span.ws.js +1 -1
- package/lib/{text-block.js → text.js} +3 -3
- package/lib/{text-block.ws.js → text.ws.js} +7 -7
- package/lib/types/__generated__/vimeo-spinner.props.d.ts +2 -0
- package/lib/types/__generated__/vimeo.props.d.ts +2 -0
- package/lib/types/box.d.ts +1 -1
- package/lib/types/button.d.ts +2 -6
- package/lib/types/button.stories.d.ts +2 -6
- package/lib/types/components.d.ts +5 -4
- package/lib/types/image.d.ts +5 -6
- package/lib/types/image.stories.d.ts +555 -6
- package/lib/types/image.ws.d.ts +8 -0
- package/lib/types/link.d.ts +1 -3
- package/lib/types/link.stories.d.ts +2 -6
- package/lib/types/metas.d.ts +5 -4
- package/lib/types/props.d.ts +5 -4
- package/lib/types/rich-text-link.stories.d.ts +2 -6
- package/lib/types/{text-block.d.ts → text.d.ts} +1 -1
- package/lib/types/{text-block.stories.d.ts → text.stories.d.ts} +1 -1
- package/lib/types/vimeo-play-button.d.ts +4 -0
- package/lib/types/vimeo-play-button.stories.d.ts +5 -0
- package/lib/types/vimeo-preview-image.d.ts +281 -0
- package/lib/types/vimeo-preview-image.stories.d.ts +562 -0
- package/lib/types/vimeo-spinner.d.ts +2 -0
- package/lib/types/vimeo-spinner.stories.d.ts +5 -0
- package/lib/types/{link-block.ws.d.ts → vimeo-spinner.ws.d.ts} +1 -1
- package/lib/types/vimeo.d.ts +73 -0
- package/lib/types/vimeo.stories.d.ts +71 -0
- package/lib/types/vimeo.ws.d.ts +3 -0
- package/lib/vimeo-play-button.js +21 -0
- package/lib/vimeo-play-button.ws.js +26 -0
- package/lib/vimeo-preview-image.js +23 -0
- package/lib/vimeo-preview-image.ws.js +20 -0
- package/lib/vimeo-spinner.js +20 -0
- package/lib/vimeo-spinner.ws.js +25 -0
- package/lib/vimeo.js +282 -0
- package/lib/vimeo.ws.js +327 -0
- package/package.json +9 -7
- package/src/LICENSE +21 -0
- package/src/__generated__/button.props.ts +0 -6
- package/src/__generated__/image.props.ts +0 -1
- package/src/__generated__/link-block.props.ts +1 -7
- package/src/__generated__/link.props.ts +1 -7
- package/src/__generated__/rich-text-link.props.ts +1 -7
- package/src/__generated__/{checkbox-field.props.ts → vimeo-play-button.props.ts} +14 -0
- package/src/__generated__/vimeo-preview-image.props.ts +486 -0
- package/src/__generated__/{radio-button-field.props.ts → vimeo-spinner.props.ts} +0 -1
- package/src/__generated__/vimeo.props.ts +621 -0
- package/src/blockquote.ws.tsx +1 -1
- package/src/box.tsx +1 -1
- package/src/button.tsx +3 -11
- package/src/button.ws.tsx +8 -1
- package/src/checkbox.ws.tsx +19 -1
- package/src/code-text.ws.tsx +1 -1
- package/src/components.ts +5 -4
- package/src/heading.ws.tsx +1 -1
- package/src/image.tsx +6 -5
- package/src/image.ws.tsx +11 -9
- package/src/label.ws.tsx +4 -7
- package/src/link.tsx +5 -11
- package/src/link.ws.tsx +3 -3
- package/src/list-item.ws.tsx +1 -1
- package/src/metas.ts +5 -4
- package/src/paragraph.ws.tsx +2 -2
- package/src/props.ts +5 -4
- package/src/radio-button.ws.tsx +19 -1
- package/src/rich-text-link.ws.tsx +3 -11
- package/src/span.ws.tsx +1 -1
- package/src/text.stories.tsx +16 -0
- package/src/{text-block.tsx → text.tsx} +2 -2
- package/src/{text-block.ws.tsx → text.ws.tsx} +8 -8
- package/src/vimeo-play-button.stories.tsx +17 -0
- package/src/vimeo-play-button.tsx +24 -0
- package/src/vimeo-play-button.ws.ts +29 -0
- package/src/vimeo-preview-image.stories.tsx +17 -0
- package/src/vimeo-preview-image.tsx +30 -0
- package/src/vimeo-preview-image.ws.ts +22 -0
- package/src/vimeo-spinner.stories.tsx +17 -0
- package/src/vimeo-spinner.tsx +25 -0
- package/src/vimeo-spinner.ws.ts +27 -0
- package/src/vimeo.stories.tsx +17 -0
- package/src/vimeo.tsx +430 -0
- package/src/vimeo.ws.ts +331 -0
- package/lib/checkbox-field.js +0 -9
- package/lib/checkbox-field.ws.js +0 -44
- package/lib/cjs/radio-button-field.ws.js +0 -62
- package/lib/link-block.js +0 -10
- package/lib/link-block.ws.js +0 -33
- package/lib/radio-button-field.js +0 -9
- package/lib/radio-button-field.ws.js +0 -44
- package/lib/types/checkbox-field.d.ts +0 -3
- package/lib/types/link-block.d.ts +0 -3
- package/lib/types/link-block.stories.d.ts +0 -13
- package/lib/types/radio-button-field.d.ts +0 -3
- package/src/checkbox-field.tsx +0 -10
- package/src/checkbox-field.ws.tsx +0 -47
- package/src/link-block.stories.tsx +0 -16
- package/src/link-block.tsx +0 -9
- package/src/link-block.ws.tsx +0 -38
- package/src/radio-button-field.tsx +0 -10
- package/src/radio-button-field.ws.tsx +0 -47
- package/src/text-block.stories.tsx +0 -16
- /package/lib/__generated__/{text-block.props.js → text.props.js} +0 -0
- /package/lib/types/__generated__/{checkbox-field.props.d.ts → text.props.d.ts} +0 -0
- /package/lib/types/__generated__/{radio-button-field.props.d.ts → vimeo-play-button.props.d.ts} +0 -0
- /package/lib/types/__generated__/{text-block.props.d.ts → vimeo-preview-image.props.d.ts} +0 -0
- /package/lib/types/{checkbox-field.ws.d.ts → text.ws.d.ts} +0 -0
- /package/lib/types/{radio-button-field.ws.d.ts → vimeo-play-button.ws.d.ts} +0 -0
- /package/lib/types/{text-block.ws.d.ts → vimeo-preview-image.ws.d.ts} +0 -0
- /package/src/__generated__/{text-block.props.ts → text.props.ts} +0 -0
|
@@ -16,14 +16,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
22
|
-
defaultTag: () => defaultTag
|
|
19
|
+
var vimeo_spinner_exports = {};
|
|
20
|
+
__export(vimeo_spinner_exports, {
|
|
21
|
+
VimeoSpinner: () => VimeoSpinner
|
|
23
22
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(vimeo_spinner_exports);
|
|
25
24
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
25
|
var import_react = require("react");
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
26
|
+
var import_vimeo = require("./vimeo");
|
|
27
|
+
const defaultTag = "div";
|
|
28
|
+
const VimeoSpinner = (0, import_react.forwardRef)(
|
|
29
|
+
(props, ref) => {
|
|
30
|
+
const vimeoContext = (0, import_react.useContext)(import_vimeo.VimeoContext);
|
|
31
|
+
if (vimeoContext.status !== "initialized") {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...props, ref });
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
VimeoSpinner.displayName = "VimeoSpinner";
|
|
@@ -16,47 +16,28 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var vimeo_spinner_ws_exports = {};
|
|
20
|
+
__export(vimeo_spinner_ws_exports, {
|
|
21
21
|
meta: () => meta,
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
25
|
-
var import_svg = require("@webstudio-is/icons/svg");
|
|
24
|
+
module.exports = __toCommonJS(vimeo_spinner_ws_exports);
|
|
26
25
|
var import_react_sdk = require("@webstudio-is/react-sdk");
|
|
26
|
+
var import_vimeo_spinner = require("./__generated__/vimeo-spinner.props");
|
|
27
27
|
var import_css_normalize = require("@webstudio-is/react-sdk/css-normalize");
|
|
28
|
-
var
|
|
28
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
29
29
|
const presetStyle = {
|
|
30
|
-
|
|
31
|
-
...import_css_normalize.label,
|
|
32
|
-
{ property: "display", value: { type: "keyword", value: "flex" } }
|
|
33
|
-
]
|
|
30
|
+
div: import_css_normalize.div
|
|
34
31
|
};
|
|
35
32
|
const meta = {
|
|
36
|
-
category: "forms",
|
|
37
33
|
type: "container",
|
|
38
|
-
|
|
39
|
-
icon: import_svg.CheckboxCheckedIcon,
|
|
34
|
+
icon: import_svg.BoxIcon,
|
|
40
35
|
states: import_react_sdk.defaultStates,
|
|
41
36
|
presetStyle,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
component: "CheckboxField",
|
|
46
|
-
children: [
|
|
47
|
-
{ type: "instance", component: "Checkbox", children: [] },
|
|
48
|
-
{
|
|
49
|
-
type: "instance",
|
|
50
|
-
component: "TextBlock",
|
|
51
|
-
label: "Checkbox Label",
|
|
52
|
-
props: [],
|
|
53
|
-
children: [{ type: "text", value: "Checkbox" }]
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
]
|
|
37
|
+
category: "hidden",
|
|
38
|
+
label: "Spinner",
|
|
39
|
+
requiredAncestors: ["Vimeo"]
|
|
58
40
|
};
|
|
59
41
|
const propsMeta = {
|
|
60
|
-
props:
|
|
61
|
-
initialProps: []
|
|
42
|
+
props: import_vimeo_spinner.props
|
|
62
43
|
};
|
package/lib/cjs/vimeo.js
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var vimeo_exports = {};
|
|
20
|
+
__export(vimeo_exports, {
|
|
21
|
+
Vimeo: () => Vimeo,
|
|
22
|
+
VimeoContext: () => VimeoContext
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(vimeo_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_colord = require("colord");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_react_sdk = require("@webstudio-is/react-sdk");
|
|
29
|
+
var import_shallow_equal = require("shallow-equal");
|
|
30
|
+
const defaultTag = "div";
|
|
31
|
+
const getUrl = (options) => {
|
|
32
|
+
if (options.url === void 0) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
let url;
|
|
36
|
+
try {
|
|
37
|
+
const userUrl = new URL(options.url);
|
|
38
|
+
url = new URL(IFRAME_CDN);
|
|
39
|
+
url.pathname = `/video${userUrl.pathname}`;
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
if (url === void 0) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let option;
|
|
46
|
+
for (option in options) {
|
|
47
|
+
const value = options[option];
|
|
48
|
+
if (option === "url" || value === void 0) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
url.searchParams.append(option, value.toString());
|
|
52
|
+
}
|
|
53
|
+
url.searchParams.set("autoplay", "true");
|
|
54
|
+
if (typeof options.color === "string") {
|
|
55
|
+
const color = (0, import_colord.colord)(options.color).toHex().replace("#", "");
|
|
56
|
+
url.searchParams.set("color", color);
|
|
57
|
+
}
|
|
58
|
+
if (options.portrait) {
|
|
59
|
+
url.searchParams.set("title", "true");
|
|
60
|
+
}
|
|
61
|
+
if (options.byline) {
|
|
62
|
+
url.searchParams.set("portrait", "true");
|
|
63
|
+
url.searchParams.set("title", "true");
|
|
64
|
+
}
|
|
65
|
+
return url.toString();
|
|
66
|
+
};
|
|
67
|
+
const preconnect = (url) => {
|
|
68
|
+
const link = document.createElement("link");
|
|
69
|
+
link.rel = "preconnect";
|
|
70
|
+
link.href = url;
|
|
71
|
+
link.crossOrigin = "true";
|
|
72
|
+
document.head.append(link);
|
|
73
|
+
};
|
|
74
|
+
let warmed = false;
|
|
75
|
+
const PLAYER_CDN = "https://f.vimeocdn.com";
|
|
76
|
+
const IFRAME_CDN = "https://player.vimeo.com";
|
|
77
|
+
const IMAGE_CDN = "https://i.vimeocdn.com";
|
|
78
|
+
const warmConnections = () => {
|
|
79
|
+
if (warmed) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
preconnect(PLAYER_CDN);
|
|
83
|
+
preconnect(IFRAME_CDN);
|
|
84
|
+
preconnect(IMAGE_CDN);
|
|
85
|
+
warmed = true;
|
|
86
|
+
};
|
|
87
|
+
const createPlayer = (parent, options, callback) => {
|
|
88
|
+
const url = getUrl(options);
|
|
89
|
+
if (url === void 0) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const iframe = document.createElement("iframe");
|
|
93
|
+
iframe.setAttribute(
|
|
94
|
+
"allow",
|
|
95
|
+
"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture;"
|
|
96
|
+
);
|
|
97
|
+
iframe.setAttribute("frameborder", "0");
|
|
98
|
+
iframe.setAttribute("allowfullscreen", "true");
|
|
99
|
+
iframe.setAttribute("src", url);
|
|
100
|
+
iframe.setAttribute(
|
|
101
|
+
"style",
|
|
102
|
+
"position: absolute; width: 100%; height: 100%; opacity: 0; transition: opacity 1s;"
|
|
103
|
+
);
|
|
104
|
+
iframe.addEventListener(
|
|
105
|
+
"load",
|
|
106
|
+
() => {
|
|
107
|
+
iframe.style.opacity = "1";
|
|
108
|
+
callback();
|
|
109
|
+
},
|
|
110
|
+
{ once: true }
|
|
111
|
+
);
|
|
112
|
+
parent.appendChild(iframe);
|
|
113
|
+
return () => {
|
|
114
|
+
iframe.parentElement?.removeChild(iframe);
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
const getVideoId = (url) => {
|
|
118
|
+
try {
|
|
119
|
+
const parsedUrl = new URL(url);
|
|
120
|
+
const id = parsedUrl.pathname.split("/")[1];
|
|
121
|
+
if (id === "" || id == null) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
return id;
|
|
125
|
+
} catch {
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const loadPreviewImage = async (element, videoUrl) => {
|
|
129
|
+
const videoId = getVideoId(videoUrl);
|
|
130
|
+
const apiUrl = `https://vimeo.com/api/v2/video/${videoId}.json`;
|
|
131
|
+
const response = (await (await fetch(apiUrl)).json())[0];
|
|
132
|
+
const thumbnail = response.thumbnail_large;
|
|
133
|
+
const imgId = thumbnail.substr(thumbnail.lastIndexOf("/") + 1).split("_")[0];
|
|
134
|
+
const imageUrl = new URL(IMAGE_CDN);
|
|
135
|
+
imageUrl.pathname = `/video/${imgId}.webp`;
|
|
136
|
+
imageUrl.searchParams.append("mw", "1100");
|
|
137
|
+
imageUrl.searchParams.append("mh", "619");
|
|
138
|
+
imageUrl.searchParams.append("q", "70");
|
|
139
|
+
return imageUrl;
|
|
140
|
+
};
|
|
141
|
+
const useVimeo = ({
|
|
142
|
+
options,
|
|
143
|
+
renderer,
|
|
144
|
+
showPreview
|
|
145
|
+
}) => {
|
|
146
|
+
const [playerStatus, setPlayerStatus] = (0, import_react.useState)("initial");
|
|
147
|
+
const elementRef = (0, import_react.useRef)(null);
|
|
148
|
+
const [previewImageUrl, setPreviewImageUrl] = (0, import_react.useState)();
|
|
149
|
+
(0, import_react.useEffect)(() => {
|
|
150
|
+
setPlayerStatus(
|
|
151
|
+
options.autoplay && renderer !== "canvas" ? "initialized" : "initial"
|
|
152
|
+
);
|
|
153
|
+
}, [options.autoplay, renderer]);
|
|
154
|
+
(0, import_react.useEffect)(() => {
|
|
155
|
+
if (elementRef.current === null || playerStatus === "ready" || options.url === void 0) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (showPreview) {
|
|
159
|
+
loadPreviewImage(elementRef.current, options.url).then(
|
|
160
|
+
setPreviewImageUrl
|
|
161
|
+
);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
setPreviewImageUrl(void 0);
|
|
165
|
+
}, [renderer, showPreview, options.url, playerStatus]);
|
|
166
|
+
const optionsRef = (0, import_react.useRef)(options);
|
|
167
|
+
const stableOptions = (0, import_react.useMemo)(() => {
|
|
168
|
+
if ((0, import_shallow_equal.shallowEqual)(options, optionsRef.current) === false) {
|
|
169
|
+
optionsRef.current = options;
|
|
170
|
+
}
|
|
171
|
+
return optionsRef.current;
|
|
172
|
+
}, [options]);
|
|
173
|
+
(0, import_react.useEffect)(() => {
|
|
174
|
+
if (elementRef.current === null || playerStatus === "initial") {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
return createPlayer(elementRef.current, stableOptions, () => {
|
|
178
|
+
setPlayerStatus("ready");
|
|
179
|
+
});
|
|
180
|
+
}, [stableOptions, playerStatus]);
|
|
181
|
+
return { previewImageUrl, playerStatus, setPlayerStatus, elementRef };
|
|
182
|
+
};
|
|
183
|
+
const Vimeo = (0, import_react.forwardRef)(
|
|
184
|
+
({
|
|
185
|
+
url,
|
|
186
|
+
autoplay = false,
|
|
187
|
+
autopause = true,
|
|
188
|
+
backgroundMode = false,
|
|
189
|
+
showByline = false,
|
|
190
|
+
showControls = true,
|
|
191
|
+
doNotTrack = false,
|
|
192
|
+
keyboard = true,
|
|
193
|
+
loop = false,
|
|
194
|
+
muted = false,
|
|
195
|
+
pip = false,
|
|
196
|
+
playsinline = true,
|
|
197
|
+
showPortrait = true,
|
|
198
|
+
quality = "auto",
|
|
199
|
+
responsive = true,
|
|
200
|
+
speed = false,
|
|
201
|
+
showTitle = false,
|
|
202
|
+
transparent = true,
|
|
203
|
+
showPreview = false,
|
|
204
|
+
autopip,
|
|
205
|
+
controlsColor,
|
|
206
|
+
interactiveParams,
|
|
207
|
+
texttrack,
|
|
208
|
+
children,
|
|
209
|
+
...rest
|
|
210
|
+
}, ref) => {
|
|
211
|
+
const { renderer } = (0, import_react.useContext)(import_react_sdk.ReactSdkContext);
|
|
212
|
+
const { previewImageUrl, playerStatus, setPlayerStatus, elementRef } = useVimeo({
|
|
213
|
+
renderer,
|
|
214
|
+
showPreview,
|
|
215
|
+
options: {
|
|
216
|
+
url,
|
|
217
|
+
autoplay,
|
|
218
|
+
autopause,
|
|
219
|
+
keyboard,
|
|
220
|
+
loop,
|
|
221
|
+
muted,
|
|
222
|
+
pip,
|
|
223
|
+
playsinline,
|
|
224
|
+
quality,
|
|
225
|
+
responsive,
|
|
226
|
+
speed,
|
|
227
|
+
transparent,
|
|
228
|
+
portrait: showPortrait,
|
|
229
|
+
byline: showByline,
|
|
230
|
+
title: showTitle,
|
|
231
|
+
color: controlsColor,
|
|
232
|
+
controls: showControls,
|
|
233
|
+
interactive_params: interactiveParams,
|
|
234
|
+
background: backgroundMode,
|
|
235
|
+
dnt: doNotTrack
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
239
|
+
VimeoContext.Provider,
|
|
240
|
+
{
|
|
241
|
+
value: {
|
|
242
|
+
status: playerStatus,
|
|
243
|
+
previewImageUrl,
|
|
244
|
+
onInitPlayer() {
|
|
245
|
+
if (renderer !== "canvas") {
|
|
246
|
+
setPlayerStatus("initialized");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
251
|
+
"div",
|
|
252
|
+
{
|
|
253
|
+
...rest,
|
|
254
|
+
ref: (value) => {
|
|
255
|
+
elementRef.current = value;
|
|
256
|
+
if (ref !== null) {
|
|
257
|
+
typeof ref === "function" ? ref(value) : ref.current = value;
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
onPointerOver: () => {
|
|
261
|
+
if (renderer !== "canvas") {
|
|
262
|
+
warmConnections();
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
children: url === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyState, {}) : children
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
);
|
|
272
|
+
Vimeo.displayName = "Vimeo";
|
|
273
|
+
const EmptyState = () => {
|
|
274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
275
|
+
"div",
|
|
276
|
+
{
|
|
277
|
+
style: {
|
|
278
|
+
display: "flex",
|
|
279
|
+
width: "100%",
|
|
280
|
+
height: "100%",
|
|
281
|
+
alignItems: "center",
|
|
282
|
+
justifyContent: "center",
|
|
283
|
+
fontSize: "1.2em"
|
|
284
|
+
},
|
|
285
|
+
children: "Open the Properties panel and paste a video URL, e.g. https://vimeo.com/831343124."
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
};
|
|
289
|
+
const VimeoContext = (0, import_react.createContext)({
|
|
290
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
291
|
+
onInitPlayer: () => {
|
|
292
|
+
},
|
|
293
|
+
status: "initial"
|
|
294
|
+
});
|