@webstudio-is/sdk-components-react 0.70.0 → 0.72.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__/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__/vimeo-play-button.props.js +414 -0
- package/lib/__generated__/vimeo-preview-image.props.js +442 -0
- package/lib/__generated__/vimeo-spinner.props.js +398 -0
- package/lib/__generated__/vimeo.props.js +555 -0
- package/lib/box.js +2 -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__/vimeo-play-button.props.js +434 -0
- package/lib/cjs/__generated__/vimeo-preview-image.props.js +462 -0
- package/lib/cjs/__generated__/vimeo-spinner.props.js +418 -0
- package/lib/cjs/__generated__/vimeo.props.js +575 -0
- package/lib/cjs/box.js +2 -1
- package/lib/cjs/components.js +9 -1
- package/lib/cjs/image.ws.js +11 -7
- package/lib/cjs/link-block.ws.js +1 -8
- package/lib/cjs/link.ws.js +1 -1
- package/lib/cjs/metas.js +9 -1
- package/lib/cjs/props.js +9 -1
- package/lib/cjs/rich-text-link.ws.js +3 -10
- package/lib/cjs/vimeo-play-button.js +38 -0
- package/lib/cjs/vimeo-play-button.ws.js +44 -0
- package/lib/cjs/vimeo-preview-image.js +40 -0
- package/lib/cjs/vimeo-preview-image.ws.js +36 -0
- package/lib/cjs/vimeo-spinner.js +37 -0
- package/lib/cjs/vimeo-spinner.ws.js +43 -0
- package/lib/cjs/vimeo.js +294 -0
- package/lib/cjs/vimeo.ws.js +340 -0
- package/lib/components.js +9 -1
- package/lib/image.ws.js +11 -7
- package/lib/link-block.ws.js +1 -8
- package/lib/link.ws.js +1 -1
- package/lib/metas.js +9 -1
- package/lib/props.js +9 -1
- package/lib/rich-text-link.ws.js +3 -10
- package/lib/types/__generated__/vimeo-play-button.props.d.ts +2 -0
- package/lib/types/__generated__/vimeo-preview-image.props.d.ts +2 -0
- 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/components.d.ts +4 -0
- package/lib/types/image.ws.d.ts +8 -0
- package/lib/types/link-block.stories.d.ts +2 -6
- package/lib/types/link.d.ts +1 -3
- package/lib/types/link.stories.d.ts +2 -6
- package/lib/types/metas.d.ts +4 -0
- package/lib/types/props.d.ts +4 -0
- package/lib/types/rich-text-link.stories.d.ts +2 -6
- package/lib/types/vimeo-play-button.d.ts +6 -0
- package/lib/types/vimeo-play-button.stories.d.ts +9 -0
- package/lib/types/vimeo-play-button.ws.d.ts +3 -0
- package/lib/types/vimeo-preview-image.d.ts +6 -0
- package/lib/types/vimeo-preview-image.stories.d.ts +13 -0
- package/lib/types/vimeo-preview-image.ws.d.ts +3 -0
- package/lib/types/vimeo-spinner.d.ts +2 -0
- package/lib/types/vimeo-spinner.stories.d.ts +5 -0
- package/lib/types/vimeo-spinner.ws.d.ts +3 -0
- 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 +322 -0
- package/package.json +8 -6
- package/src/LICENSE +21 -0
- 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__/vimeo-play-button.props.ts +459 -0
- package/src/__generated__/vimeo-preview-image.props.ts +487 -0
- package/src/__generated__/vimeo-spinner.props.ts +443 -0
- package/src/__generated__/vimeo.props.ts +621 -0
- package/src/box.tsx +1 -1
- package/src/components.ts +4 -0
- package/src/image.ws.tsx +11 -6
- package/src/link-block.ws.tsx +1 -8
- package/src/link.tsx +2 -7
- package/src/link.ws.tsx +1 -1
- package/src/metas.ts +4 -0
- package/src/props.ts +4 -0
- package/src/rich-text-link.ws.tsx +3 -11
- 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 +326 -0
package/lib/cjs/metas.js
CHANGED
|
@@ -50,7 +50,11 @@ __export(metas_exports, {
|
|
|
50
50
|
SuccessMessage: () => import_success_message.meta,
|
|
51
51
|
Superscript: () => import_superscript.meta,
|
|
52
52
|
TextBlock: () => import_text_block.meta,
|
|
53
|
-
Textarea: () => import_textarea.meta
|
|
53
|
+
Textarea: () => import_textarea.meta,
|
|
54
|
+
Vimeo: () => import_vimeo.meta,
|
|
55
|
+
VimeoPlayButton: () => import_vimeo_play_button.meta,
|
|
56
|
+
VimeoPreviewImage: () => import_vimeo_preview_image.meta,
|
|
57
|
+
VimeoSpinner: () => import_vimeo_spinner.meta
|
|
54
58
|
});
|
|
55
59
|
module.exports = __toCommonJS(metas_exports);
|
|
56
60
|
var import_slot = require("./slot.ws");
|
|
@@ -86,3 +90,7 @@ var import_radio_button_field = require("./radio-button-field.ws");
|
|
|
86
90
|
var import_radio_button = require("./radio-button.ws");
|
|
87
91
|
var import_checkbox_field = require("./checkbox-field.ws");
|
|
88
92
|
var import_checkbox = require("./checkbox.ws");
|
|
93
|
+
var import_vimeo = require("./vimeo.ws");
|
|
94
|
+
var import_vimeo_preview_image = require("./vimeo-preview-image.ws");
|
|
95
|
+
var import_vimeo_play_button = require("./vimeo-play-button.ws");
|
|
96
|
+
var import_vimeo_spinner = require("./vimeo-spinner.ws");
|
package/lib/cjs/props.js
CHANGED
|
@@ -50,7 +50,11 @@ __export(props_exports, {
|
|
|
50
50
|
SuccessMessage: () => import_success_message.propsMeta,
|
|
51
51
|
Superscript: () => import_superscript.propsMeta,
|
|
52
52
|
TextBlock: () => import_text_block.propsMeta,
|
|
53
|
-
Textarea: () => import_textarea.propsMeta
|
|
53
|
+
Textarea: () => import_textarea.propsMeta,
|
|
54
|
+
Vimeo: () => import_vimeo.propsMeta,
|
|
55
|
+
VimeoPlayButton: () => import_vimeo_play_button.propsMeta,
|
|
56
|
+
VimeoPreviewImage: () => import_vimeo_preview_image.propsMeta,
|
|
57
|
+
VimeoSpinner: () => import_vimeo_spinner.propsMeta
|
|
54
58
|
});
|
|
55
59
|
module.exports = __toCommonJS(props_exports);
|
|
56
60
|
var import_slot = require("./slot.ws");
|
|
@@ -86,3 +90,7 @@ var import_radio_button_field = require("./radio-button-field.ws");
|
|
|
86
90
|
var import_radio_button = require("./radio-button.ws");
|
|
87
91
|
var import_checkbox_field = require("./checkbox-field.ws");
|
|
88
92
|
var import_checkbox = require("./checkbox.ws");
|
|
93
|
+
var import_vimeo = require("./vimeo.ws");
|
|
94
|
+
var import_vimeo_preview_image = require("./vimeo-preview-image.ws");
|
|
95
|
+
var import_vimeo_play_button = require("./vimeo-play-button.ws");
|
|
96
|
+
var import_vimeo_spinner = require("./vimeo-spinner.ws");
|
|
@@ -22,18 +22,11 @@ __export(rich_text_link_ws_exports, {
|
|
|
22
22
|
propsMeta: () => propsMeta
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(rich_text_link_ws_exports);
|
|
25
|
-
var import_rich_text_link = require("./__generated__/rich-text-link.props");
|
|
26
25
|
var import_link = require("./link.ws");
|
|
27
|
-
const { category, ...linkMetaRest } = import_link.meta;
|
|
28
26
|
const meta = {
|
|
29
|
-
...
|
|
27
|
+
...import_link.meta,
|
|
28
|
+
category: "hidden",
|
|
30
29
|
type: "rich-text-child",
|
|
31
30
|
template: []
|
|
32
31
|
};
|
|
33
|
-
const propsMeta =
|
|
34
|
-
initialProps: import_link.propsMeta.initialProps,
|
|
35
|
-
props: {
|
|
36
|
-
...import_rich_text_link.props,
|
|
37
|
-
href: import_link.propsMeta.props.href
|
|
38
|
-
}
|
|
39
|
-
};
|
|
32
|
+
const propsMeta = import_link.propsMeta;
|
|
@@ -0,0 +1,38 @@
|
|
|
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_play_button_exports = {};
|
|
20
|
+
__export(vimeo_play_button_exports, {
|
|
21
|
+
VimeoPlayButton: () => VimeoPlayButton,
|
|
22
|
+
defaultTag: () => import_button.defaultTag
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(vimeo_play_button_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_vimeo = require("./vimeo");
|
|
28
|
+
var import_button = require("./button");
|
|
29
|
+
const VimeoPlayButton = (0, import_react.forwardRef)(
|
|
30
|
+
(props, ref) => {
|
|
31
|
+
const vimeoContext = (0, import_react.useContext)(import_vimeo.VimeoContext);
|
|
32
|
+
if (vimeoContext.status !== "initial") {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { ...props, onClick: vimeoContext.onInitPlayer, ref });
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
VimeoPlayButton.displayName = "VimeoPlayButton";
|
|
@@ -0,0 +1,44 @@
|
|
|
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_play_button_ws_exports = {};
|
|
20
|
+
__export(vimeo_play_button_ws_exports, {
|
|
21
|
+
meta: () => meta,
|
|
22
|
+
propsMeta: () => propsMeta
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(vimeo_play_button_ws_exports);
|
|
25
|
+
var import_react_sdk = require("@webstudio-is/react-sdk");
|
|
26
|
+
var import_vimeo_play_button = require("./__generated__/vimeo-play-button.props");
|
|
27
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
28
|
+
var import_css_normalize = require("@webstudio-is/react-sdk/css-normalize");
|
|
29
|
+
const presetStyle = {
|
|
30
|
+
button: import_css_normalize.button
|
|
31
|
+
};
|
|
32
|
+
const meta = {
|
|
33
|
+
category: "hidden",
|
|
34
|
+
type: "container",
|
|
35
|
+
invalidAncestors: ["Button"],
|
|
36
|
+
requiredAncestors: ["Vimeo"],
|
|
37
|
+
label: "Play Button",
|
|
38
|
+
icon: import_svg.ButtonElementIcon,
|
|
39
|
+
presetStyle,
|
|
40
|
+
states: import_react_sdk.defaultStates
|
|
41
|
+
};
|
|
42
|
+
const propsMeta = {
|
|
43
|
+
props: import_vimeo_play_button.props
|
|
44
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
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_preview_image_exports = {};
|
|
20
|
+
__export(vimeo_preview_image_exports, {
|
|
21
|
+
VimeoPreviewImage: () => VimeoPreviewImage
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(vimeo_preview_image_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_image = require("./image");
|
|
27
|
+
var import_vimeo = require("./vimeo");
|
|
28
|
+
const base64Preview = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkOAMAANIAzr59FiYAAAAASUVORK5CYII=`;
|
|
29
|
+
const VimeoPreviewImage = (0, import_react.forwardRef)(({ src, ...rest }, ref) => {
|
|
30
|
+
const vimeoContext = (0, import_react.useContext)(import_vimeo.VimeoContext);
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
32
|
+
import_image.Image,
|
|
33
|
+
{
|
|
34
|
+
...rest,
|
|
35
|
+
src: String(vimeoContext.previewImageUrl ?? src ?? base64Preview),
|
|
36
|
+
ref
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
VimeoPreviewImage.displayName = "VimeoPreviewImage";
|
|
@@ -0,0 +1,36 @@
|
|
|
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_preview_image_ws_exports = {};
|
|
20
|
+
__export(vimeo_preview_image_ws_exports, {
|
|
21
|
+
meta: () => meta,
|
|
22
|
+
propsMeta: () => propsMeta
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(vimeo_preview_image_ws_exports);
|
|
25
|
+
var import_image = require("./image.ws");
|
|
26
|
+
var import_vimeo_preview_image = require("./__generated__/vimeo-preview-image.props");
|
|
27
|
+
const meta = {
|
|
28
|
+
...import_image.meta,
|
|
29
|
+
category: "hidden",
|
|
30
|
+
label: "Preview Image",
|
|
31
|
+
requiredAncestors: ["Vimeo"]
|
|
32
|
+
};
|
|
33
|
+
const propsMeta = {
|
|
34
|
+
props: { ...import_vimeo_preview_image.props, ...import_image.propsOverrides },
|
|
35
|
+
initialProps: import_image.propsMeta.initialProps
|
|
36
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
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_spinner_exports = {};
|
|
20
|
+
__export(vimeo_spinner_exports, {
|
|
21
|
+
VimeoSpinner: () => VimeoSpinner
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(vimeo_spinner_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
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";
|
|
@@ -0,0 +1,43 @@
|
|
|
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_spinner_ws_exports = {};
|
|
20
|
+
__export(vimeo_spinner_ws_exports, {
|
|
21
|
+
meta: () => meta,
|
|
22
|
+
propsMeta: () => propsMeta
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(vimeo_spinner_ws_exports);
|
|
25
|
+
var import_react_sdk = require("@webstudio-is/react-sdk");
|
|
26
|
+
var import_vimeo_spinner = require("./__generated__/vimeo-spinner.props");
|
|
27
|
+
var import_css_normalize = require("@webstudio-is/react-sdk/css-normalize");
|
|
28
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
29
|
+
const presetStyle = {
|
|
30
|
+
div: import_css_normalize.div
|
|
31
|
+
};
|
|
32
|
+
const meta = {
|
|
33
|
+
type: "container",
|
|
34
|
+
icon: import_svg.BoxIcon,
|
|
35
|
+
states: import_react_sdk.defaultStates,
|
|
36
|
+
presetStyle,
|
|
37
|
+
category: "hidden",
|
|
38
|
+
label: "Spinner",
|
|
39
|
+
requiredAncestors: ["Vimeo"]
|
|
40
|
+
};
|
|
41
|
+
const propsMeta = {
|
|
42
|
+
props: import_vimeo_spinner.props
|
|
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
|
+
});
|