@uniformdev/canvas-react 19.51.1-alpha.1 → 19.51.1-alpha.22

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/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import React$1, { Key, ReactNode, PropsWithChildren } from 'react';
2
- import * as _uniformdev_canvas from '@uniformdev/canvas';
3
2
  import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions } from '@uniformdev/canvas';
4
3
  export { GetParameterAttributesProps, createUniformApiEnhancer } from '@uniformdev/canvas';
5
4
  import { PureUniformTextProps } from './core.mjs';
@@ -243,8 +242,10 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
243
242
  */
244
243
  declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
245
244
 
246
- type UniformPlaygroundDecorator = (options: {
245
+ type UniformPlaygroundDecorator = (props: {
246
+ /** The rendered component instance, needs to wrapped and rendered by the decorator */
247
247
  children: React$1.ReactNode;
248
+ /** The component instance data */
248
249
  data: ComponentInstance | RootComponentInstance;
249
250
  }) => React$1.ReactElement;
250
251
  type UniformPlaygroundProps = {
@@ -378,7 +379,18 @@ type UseUniformContextualEditingStateProps = {
378
379
  */
379
380
  declare const useUniformContextualEditingState: ({ global, }?: UseUniformContextualEditingStateProps) => {
380
381
  isContextualEditing: boolean;
381
- selectedComponentReference: Omit<_uniformdev_canvas.ContextualEditingComponentReference, "elements"> | undefined;
382
+ selectedComponentReference: {
383
+ id: string;
384
+ slotName?: string | undefined;
385
+ componentIndex?: number | undefined;
386
+ totalComponents?: number | undefined;
387
+ componentName?: string | undefined;
388
+ componentTitle?: string | undefined;
389
+ parentId?: string | undefined;
390
+ parentType?: string | undefined;
391
+ isLocalized?: boolean | undefined;
392
+ isReadOnly?: boolean | undefined;
393
+ } | undefined;
382
394
  };
383
395
 
384
396
  declare const componentStore: ComponentStore;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import React$1, { Key, ReactNode, PropsWithChildren } from 'react';
2
- import * as _uniformdev_canvas from '@uniformdev/canvas';
3
2
  import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions } from '@uniformdev/canvas';
4
3
  export { GetParameterAttributesProps, createUniformApiEnhancer } from '@uniformdev/canvas';
5
4
  import { PureUniformTextProps } from './core.js';
@@ -243,8 +242,10 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
243
242
  */
244
243
  declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
245
244
 
246
- type UniformPlaygroundDecorator = (options: {
245
+ type UniformPlaygroundDecorator = (props: {
246
+ /** The rendered component instance, needs to wrapped and rendered by the decorator */
247
247
  children: React$1.ReactNode;
248
+ /** The component instance data */
248
249
  data: ComponentInstance | RootComponentInstance;
249
250
  }) => React$1.ReactElement;
250
251
  type UniformPlaygroundProps = {
@@ -378,7 +379,18 @@ type UseUniformContextualEditingStateProps = {
378
379
  */
379
380
  declare const useUniformContextualEditingState: ({ global, }?: UseUniformContextualEditingStateProps) => {
380
381
  isContextualEditing: boolean;
381
- selectedComponentReference: Omit<_uniformdev_canvas.ContextualEditingComponentReference, "elements"> | undefined;
382
+ selectedComponentReference: {
383
+ id: string;
384
+ slotName?: string | undefined;
385
+ componentIndex?: number | undefined;
386
+ totalComponents?: number | undefined;
387
+ componentName?: string | undefined;
388
+ componentTitle?: string | undefined;
389
+ parentId?: string | undefined;
390
+ parentType?: string | undefined;
391
+ isLocalized?: boolean | undefined;
392
+ isReadOnly?: boolean | undefined;
393
+ } | undefined;
382
394
  };
383
395
 
384
396
  declare const componentStore: ComponentStore;
package/dist/index.esm.js CHANGED
@@ -186,7 +186,7 @@ import {
186
186
  CANVAS_LOCALE_TAG_PARAM,
187
187
  IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
188
188
  IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
189
- PLACEHOLDER_ID
189
+ isComponentPlaceholderId
190
190
  } from "@uniformdev/canvas";
191
191
  import React4 from "react";
192
192
 
@@ -200,6 +200,7 @@ import {
200
200
  EMPTY_COMPOSITION,
201
201
  IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
202
202
  IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
203
+ isAllowedReferrer,
203
204
  isUpdateCompositionInternalMessage
204
205
  } from "@uniformdev/canvas";
205
206
  import { useEffect, useMemo, useState } from "react";
@@ -276,10 +277,7 @@ function isInContextEditingMode() {
276
277
  const isOpenedByInContextEditor = new URLSearchParams(window.location.search).has(
277
278
  IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
278
279
  );
279
- const isAllowlistedReferrer = Boolean(
280
- window.document.referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|localhost:\d{4})\//)
281
- );
282
- return isOpenedByInContextEditor && isAllowlistedReferrer;
280
+ return isOpenedByInContextEditor && isAllowedReferrer(window.document.referrer);
283
281
  }
284
282
 
285
283
  // src/components/UniformComposition.tsx
@@ -331,7 +329,7 @@ function ContextualEditingComponentWrapper({
331
329
  children
332
330
  }) {
333
331
  var _a, _b, _c, _d, _e;
334
- const isPlaceholder = (component == null ? void 0 : component._id) === PLACEHOLDER_ID;
332
+ const isPlaceholder = isComponentPlaceholderId(component == null ? void 0 : component._id);
335
333
  const { isContextualEditing } = useUniformCurrentComposition();
336
334
  const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
337
335
  return !isContextualEditing ? /* @__PURE__ */ React4.createElement(React4.Fragment, null, children) : isPlaceholder && emptyPlaceholder === null ? null : /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(
@@ -577,7 +575,7 @@ var UniformPlayground = ({
577
575
  if (!composition) {
578
576
  return null;
579
577
  }
580
- let component = /* @__PURE__ */ React7.createElement(
578
+ let component = /* @__PURE__ */ React7.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ React7.createElement(
581
579
  UniformComponent,
582
580
  {
583
581
  data: composition,
@@ -586,7 +584,7 @@ var UniformPlayground = ({
586
584
  contextualEditingDefaultPlaceholder
587
585
  },
588
586
  children
589
- );
587
+ ));
590
588
  decorators.forEach((Decorator) => {
591
589
  component = /* @__PURE__ */ React7.createElement(Decorator, { data: composition }, component);
592
590
  });
@@ -604,7 +602,7 @@ var UniformPlayground = ({
604
602
  {
605
603
  value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
606
604
  },
607
- /* @__PURE__ */ React7.createElement(ContextualEditingComponentWrapper, { component: composition }, renderedComponent)
605
+ renderedComponent
608
606
  );
609
607
  };
610
608
 
@@ -928,11 +926,14 @@ var useUniformContextualEditingState = ({
928
926
  return () => {
929
927
  unsubscribe();
930
928
  };
931
- }, [global, channel, componentData == null ? void 0 : componentData._id]);
932
- return {
933
- isContextualEditing,
934
- selectedComponentReference
935
- };
929
+ }, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference]);
930
+ return useMemo4(
931
+ () => ({
932
+ isContextualEditing,
933
+ selectedComponentReference
934
+ }),
935
+ [isContextualEditing, selectedComponentReference]
936
+ );
936
937
  };
937
938
  export {
938
939
  DefaultNotImplementedComponent,
package/dist/index.js CHANGED
@@ -310,10 +310,7 @@ function isInContextEditingMode() {
310
310
  const isOpenedByInContextEditor = new URLSearchParams(window.location.search).has(
311
311
  import_canvas3.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
312
312
  );
313
- const isAllowlistedReferrer = Boolean(
314
- window.document.referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|localhost:\d{4})\//)
315
- );
316
- return isOpenedByInContextEditor && isAllowlistedReferrer;
313
+ return isOpenedByInContextEditor && (0, import_canvas3.isAllowedReferrer)(window.document.referrer);
317
314
  }
318
315
 
319
316
  // src/components/UniformComposition.tsx
@@ -365,7 +362,7 @@ function ContextualEditingComponentWrapper({
365
362
  children
366
363
  }) {
367
364
  var _a, _b, _c, _d, _e;
368
- const isPlaceholder = (component == null ? void 0 : component._id) === import_canvas4.PLACEHOLDER_ID;
365
+ const isPlaceholder = (0, import_canvas4.isComponentPlaceholderId)(component == null ? void 0 : component._id);
369
366
  const { isContextualEditing } = useUniformCurrentComposition();
370
367
  const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
371
368
  return !isContextualEditing ? /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, children) : isPlaceholder && emptyPlaceholder === null ? null : /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(
@@ -611,7 +608,7 @@ var UniformPlayground = ({
611
608
  if (!composition) {
612
609
  return null;
613
610
  }
614
- let component = /* @__PURE__ */ import_react7.default.createElement(
611
+ let component = /* @__PURE__ */ import_react7.default.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ import_react7.default.createElement(
615
612
  UniformComponent,
616
613
  {
617
614
  data: composition,
@@ -620,7 +617,7 @@ var UniformPlayground = ({
620
617
  contextualEditingDefaultPlaceholder
621
618
  },
622
619
  children
623
- );
620
+ ));
624
621
  decorators.forEach((Decorator) => {
625
622
  component = /* @__PURE__ */ import_react7.default.createElement(Decorator, { data: composition }, component);
626
623
  });
@@ -638,7 +635,7 @@ var UniformPlayground = ({
638
635
  {
639
636
  value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
640
637
  },
641
- /* @__PURE__ */ import_react7.default.createElement(ContextualEditingComponentWrapper, { component: composition }, renderedComponent)
638
+ renderedComponent
642
639
  );
643
640
  };
644
641
 
@@ -946,11 +943,14 @@ var useUniformContextualEditingState = ({
946
943
  return () => {
947
944
  unsubscribe();
948
945
  };
949
- }, [global, channel, componentData == null ? void 0 : componentData._id]);
950
- return {
951
- isContextualEditing,
952
- selectedComponentReference
953
- };
946
+ }, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference]);
947
+ return (0, import_react21.useMemo)(
948
+ () => ({
949
+ isContextualEditing,
950
+ selectedComponentReference
951
+ }),
952
+ [isContextualEditing, selectedComponentReference]
953
+ );
954
954
  };
955
955
  // Annotate the CommonJS export names for ESM import in node:
956
956
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -186,7 +186,7 @@ import {
186
186
  CANVAS_LOCALE_TAG_PARAM,
187
187
  IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
188
188
  IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
189
- PLACEHOLDER_ID
189
+ isComponentPlaceholderId
190
190
  } from "@uniformdev/canvas";
191
191
  import React4 from "react";
192
192
 
@@ -200,6 +200,7 @@ import {
200
200
  EMPTY_COMPOSITION,
201
201
  IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
202
202
  IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
203
+ isAllowedReferrer,
203
204
  isUpdateCompositionInternalMessage
204
205
  } from "@uniformdev/canvas";
205
206
  import { useEffect, useMemo, useState } from "react";
@@ -276,10 +277,7 @@ function isInContextEditingMode() {
276
277
  const isOpenedByInContextEditor = new URLSearchParams(window.location.search).has(
277
278
  IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
278
279
  );
279
- const isAllowlistedReferrer = Boolean(
280
- window.document.referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|localhost:\d{4})\//)
281
- );
282
- return isOpenedByInContextEditor && isAllowlistedReferrer;
280
+ return isOpenedByInContextEditor && isAllowedReferrer(window.document.referrer);
283
281
  }
284
282
 
285
283
  // src/components/UniformComposition.tsx
@@ -331,7 +329,7 @@ function ContextualEditingComponentWrapper({
331
329
  children
332
330
  }) {
333
331
  var _a, _b, _c, _d, _e;
334
- const isPlaceholder = (component == null ? void 0 : component._id) === PLACEHOLDER_ID;
332
+ const isPlaceholder = isComponentPlaceholderId(component == null ? void 0 : component._id);
335
333
  const { isContextualEditing } = useUniformCurrentComposition();
336
334
  const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
337
335
  return !isContextualEditing ? /* @__PURE__ */ React4.createElement(React4.Fragment, null, children) : isPlaceholder && emptyPlaceholder === null ? null : /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(
@@ -577,7 +575,7 @@ var UniformPlayground = ({
577
575
  if (!composition) {
578
576
  return null;
579
577
  }
580
- let component = /* @__PURE__ */ React7.createElement(
578
+ let component = /* @__PURE__ */ React7.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ React7.createElement(
581
579
  UniformComponent,
582
580
  {
583
581
  data: composition,
@@ -586,7 +584,7 @@ var UniformPlayground = ({
586
584
  contextualEditingDefaultPlaceholder
587
585
  },
588
586
  children
589
- );
587
+ ));
590
588
  decorators.forEach((Decorator) => {
591
589
  component = /* @__PURE__ */ React7.createElement(Decorator, { data: composition }, component);
592
590
  });
@@ -604,7 +602,7 @@ var UniformPlayground = ({
604
602
  {
605
603
  value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
606
604
  },
607
- /* @__PURE__ */ React7.createElement(ContextualEditingComponentWrapper, { component: composition }, renderedComponent)
605
+ renderedComponent
608
606
  );
609
607
  };
610
608
 
@@ -928,11 +926,14 @@ var useUniformContextualEditingState = ({
928
926
  return () => {
929
927
  unsubscribe();
930
928
  };
931
- }, [global, channel, componentData == null ? void 0 : componentData._id]);
932
- return {
933
- isContextualEditing,
934
- selectedComponentReference
935
- };
929
+ }, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference]);
930
+ return useMemo4(
931
+ () => ({
932
+ isContextualEditing,
933
+ selectedComponentReference
934
+ }),
935
+ [isContextualEditing, selectedComponentReference]
936
+ );
936
937
  };
937
938
  export {
938
939
  DefaultNotImplementedComponent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-react",
3
- "version": "19.51.1-alpha.1+e55ae6c1e",
3
+ "version": "19.51.1-alpha.22+ee274f045",
4
4
  "description": "React SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -45,10 +45,10 @@
45
45
  "document": "api-extractor run --local"
46
46
  },
47
47
  "dependencies": {
48
- "@uniformdev/canvas": "19.51.1-alpha.1+e55ae6c1e",
49
- "@uniformdev/context": "19.51.1-alpha.1+e55ae6c1e",
50
- "@uniformdev/context-react": "19.51.1-alpha.1+e55ae6c1e",
51
- "@uniformdev/richtext": "19.51.1-alpha.1+e55ae6c1e"
48
+ "@uniformdev/canvas": "19.51.1-alpha.22+ee274f045",
49
+ "@uniformdev/context": "19.51.1-alpha.22+ee274f045",
50
+ "@uniformdev/context-react": "19.51.1-alpha.22+ee274f045",
51
+ "@uniformdev/richtext": "19.51.1-alpha.22+ee274f045"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "react": ">= 16 || 17 || 18",
@@ -65,5 +65,5 @@
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
- "gitHead": "e55ae6c1ea8df19f04a9dba22769d76e16d28d70"
68
+ "gitHead": "ee274f04521c4024826b21fee01d50fcc1e414a1"
69
69
  }