@webstudio-is/sdk-components-react 0.123.0 → 0.125.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/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # Webstudio SDK Components
2
2
 
3
- Webstudio SDK is a TypeScript API that lets you use your Webstudio site or some components in your custom codebase or just render a complete Remix Document.
3
+ Webstudio SDK is a TypeScript API that lets you use your Webstudio project or some components in your custom codebase or just render a complete Remix Document.
package/lib/components.js CHANGED
@@ -75,7 +75,7 @@ var Placeholder = (props) => {
75
75
  var HtmlEmbed = forwardRef3((props, ref) => {
76
76
  const { renderer } = useContext(ReactSdkContext);
77
77
  const { code, executeScriptOnCanvas, clientOnly, ...rest } = props;
78
- if (code === void 0 || code.trim().length === 0) {
78
+ if (code === void 0 || String(code).trim().length === 0) {
79
79
  return /* @__PURE__ */ jsx3(Placeholder, { innerRef: ref, ...rest });
80
80
  }
81
81
  if (renderer === "canvas" && executeScriptOnCanvas === true || renderer === "preview" || clientOnly) {
@@ -408,8 +408,8 @@ var warmConnections = () => {
408
408
  preconnect(IMAGE_CDN);
409
409
  warmed = true;
410
410
  };
411
- var createPlayer = (parent, options, callback) => {
412
- const url = getUrl(options);
411
+ var createPlayer = (parent, vimeoOptions, extendedOptions, callback) => {
412
+ const url = getUrl(vimeoOptions);
413
413
  if (url === void 0) {
414
414
  return;
415
415
  }
@@ -425,6 +425,9 @@ var createPlayer = (parent, options, callback) => {
425
425
  "style",
426
426
  "position: absolute; width: 100%; height: 100%; opacity: 0; transition: opacity 1s;"
427
427
  );
428
+ if (extendedOptions.loading) {
429
+ iframe.setAttribute("loading", extendedOptions.loading);
430
+ }
428
431
  iframe.addEventListener(
429
432
  "load",
430
433
  () => {
@@ -465,7 +468,8 @@ var loadPreviewImage = async (element, videoUrl) => {
465
468
  var useVimeo = ({
466
469
  options,
467
470
  renderer,
468
- showPreview
471
+ showPreview,
472
+ loading
469
473
  }) => {
470
474
  const [playerStatus, setPlayerStatus] = useState("initial");
471
475
  const elementRef = useRef2(null);
@@ -498,15 +502,16 @@ var useVimeo = ({
498
502
  if (elementRef.current === null || playerStatus === "initial") {
499
503
  return;
500
504
  }
501
- return createPlayer(elementRef.current, stableOptions, () => {
505
+ return createPlayer(elementRef.current, stableOptions, { loading }, () => {
502
506
  setPlayerStatus("ready");
503
507
  });
504
- }, [stableOptions, playerStatus]);
508
+ }, [stableOptions, playerStatus, loading]);
505
509
  return { previewImageUrl, playerStatus, setPlayerStatus, elementRef };
506
510
  };
507
511
  var Vimeo = forwardRef29(
508
512
  ({
509
513
  url,
514
+ loading,
510
515
  autoplay = false,
511
516
  autopause = true,
512
517
  backgroundMode = false,
@@ -536,6 +541,7 @@ var Vimeo = forwardRef29(
536
541
  const { previewImageUrl, playerStatus, setPlayerStatus, elementRef } = useVimeo({
537
542
  renderer,
538
543
  showPreview,
544
+ loading,
539
545
  options: {
540
546
  url,
541
547
  autoplay,
package/lib/props.js CHANGED
@@ -14328,6 +14328,14 @@ var props26 = {
14328
14328
  type: "string",
14329
14329
  description: "Defines the language used in the element."
14330
14330
  },
14331
+ loading: {
14332
+ description: "Not a Vimeo attribute: Loading attribute for the iframe allows to eager or lazy load the source",
14333
+ required: false,
14334
+ control: "radio",
14335
+ type: "string",
14336
+ defaultValue: "lazy",
14337
+ options: ["eager", "lazy"]
14338
+ },
14331
14339
  loop: {
14332
14340
  description: "Whether to restart the video automatically after reaching the end.",
14333
14341
  required: false,
@@ -14419,7 +14427,7 @@ var props26 = {
14419
14427
  defaultValue: true
14420
14428
  },
14421
14429
  showPreview: {
14422
- description: "Whether the preview image should be loaded from Vimeo API. Ideally don't use it, because it will show up with some delay and will make your site feel slower.",
14430
+ description: "Not a Vimeo attribute: Whether the preview image should be loaded from Vimeo API. Ideally don't use it, because it will show up with some delay and will make your project feel slower.",
14423
14431
  required: false,
14424
14432
  control: "boolean",
14425
14433
  type: "boolean",
@@ -14516,6 +14524,7 @@ var initialProps = [
14516
14524
  "quality",
14517
14525
  "showPreview",
14518
14526
  "autoplay",
14527
+ "loading",
14519
14528
  "backgroundMode",
14520
14529
  "doNotTrack",
14521
14530
  "loop",
@@ -44,8 +44,10 @@ type VimeoPlayerOptions = {
44
44
  };
45
45
  type PlayerStatus = "initial" | "initialized" | "ready";
46
46
  export type VimeoOptions = Omit<VimeoPlayerOptions, "dnt" | "interactive_params" | "background" | "controls" | "color" | "byline" | "title" | "portrait"> & {
47
- /** Whether the preview image should be loaded from Vimeo API. Ideally don't use it, because it will show up with some delay and will make your site feel slower. */
47
+ /** Not a Vimeo attribute: Whether the preview image should be loaded from Vimeo API. Ideally don't use it, because it will show up with some delay and will make your project feel slower. */
48
48
  showPreview?: boolean;
49
+ /** Not a Vimeo attribute: Loading attribute for the iframe allows to eager or lazy load the source */
50
+ loading?: "eager" | "lazy";
49
51
  /** Whether to prevent the player from tracking session data, including cookies. Keep in mind that setting this argument to true also blocks video stats. */
50
52
  doNotTrack?: VimeoPlayerOptions["dnt"];
51
53
  /** Key-value pairs representing dynamic parameters that are utilized on interactive videos with live elements, such as title=my-video,subtitle=interactive. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/sdk-components-react",
3
- "version": "0.123.0",
3
+ "version": "0.125.0",
4
4
  "description": "Webstudio default library for react",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -40,9 +40,9 @@
40
40
  "@react-aria/utils": "^3.21.0",
41
41
  "colord": "^2.9.3",
42
42
  "shallow-equal": "^3.1.0",
43
- "@webstudio-is/icons": "0.123.0",
44
- "@webstudio-is/react-sdk": "0.123.0",
45
- "@webstudio-is/image": "0.123.0"
43
+ "@webstudio-is/image": "0.125.0",
44
+ "@webstudio-is/icons": "0.125.0",
45
+ "@webstudio-is/react-sdk": "0.125.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@storybook/react": "^7.4.0",
@@ -51,7 +51,7 @@
51
51
  "react": "^18.2.0",
52
52
  "react-dom": "^18.2.0",
53
53
  "typescript": "5.2.2",
54
- "@webstudio-is/generate-arg-types": "0.123.0",
54
+ "@webstudio-is/generate-arg-types": "0.125.0",
55
55
  "@webstudio-is/storybook-config": "0.0.0",
56
56
  "@webstudio-is/tsconfig": "1.0.7"
57
57
  },