@uniformdev/canvas-react 19.139.0 → 19.140.2-alpha.7

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,5 @@
1
1
  import React$1, { Key, ReactNode, PropsWithChildren } from 'react';
2
- import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions } from '@uniformdev/canvas';
2
+ import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions, UpdateContextualEditingStateInternalMessage } from '@uniformdev/canvas';
3
3
  export { GetParameterAttributesProps, createUniformApiEnhancer } from '@uniformdev/canvas';
4
4
  import { P as PureUniformTextProps } from './PureUniformText-B3GAm6Dc.mjs';
5
5
  import { RichTextNode } from '@uniformdev/richtext';
@@ -430,26 +430,31 @@ type UseUniformContextualEditingStateProps = {
430
430
  **/
431
431
  global?: boolean;
432
432
  };
433
+ type UseUniformContextualEditingStateReturnType = {
434
+ /**
435
+ * Returns `true` when the app is rendered inside Canvas editor. Regardless of which preview mode is currently selected ("editor" or "preview").
436
+ */
437
+ isContextualEditing: boolean;
438
+ /**
439
+ * A reference to the currently selected component in Canvas editor.
440
+ * Returns `undefined` if the selected component is not part of the current React component.
441
+ * Set the `global` option to `true` to get a reference of the selected component anywhere in the composition tree.
442
+ */
443
+ selectedComponentReference: UpdateContextualEditingStateInternalMessage['state']['selectedComponentReference'];
444
+ /**
445
+ * Returns the current preview mode in Canvas editor ("editor" or "preview").
446
+ * Returns `undefined` when the app is not rendered inside Canvas editor.
447
+ * Learn more about the preview modes: https://docs.uniform.app/docs/guides/composition/visual-editing#editing-and-preview-mode
448
+ * @deprecated this is an experimental property, it might receive breaking changes in minor releases ⚠️
449
+ */
450
+ previewMode: UpdateContextualEditingStateInternalMessage['state']['previewMode'] | undefined;
451
+ };
433
452
  /**
434
453
  * Returns the state of contextual editing, when the app is open inside Canvas Editor.
435
454
  * This hook can be used to improve the editing experience of your team.
436
455
  * For example: You can use `selectedComponentReference` to control which element to show inside a carousel or an accordion.
437
456
  */
438
- declare const useUniformContextualEditingState: ({ global, }?: UseUniformContextualEditingStateProps) => {
439
- isContextualEditing: boolean;
440
- selectedComponentReference: {
441
- id: string;
442
- slotName?: string | undefined;
443
- componentIndex?: number | undefined;
444
- totalComponents?: number | undefined;
445
- componentName?: string | undefined;
446
- componentTitle?: string | undefined;
447
- parentId?: string | undefined;
448
- parentType?: string | undefined;
449
- isLocalized?: boolean | undefined;
450
- isReadOnly?: boolean | undefined;
451
- } | undefined;
452
- };
457
+ declare const useUniformContextualEditingState: ({ global, }?: UseUniformContextualEditingStateProps) => UseUniformContextualEditingStateReturnType;
453
458
 
454
459
  declare const componentStore: ComponentStore;
455
460
  declare const registerUniformComponent: ({ type, variantId, component, }: {
@@ -467,4 +472,4 @@ declare const createComponentStoreResolver: (options: {
467
472
  defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
468
473
  }) => RenderComponentResolver;
469
474
 
470
- export { type ComponentProps, type ComponentStore, type CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, type RenderComponentResolver, type RenderRichTextComponentResolver, type RichTextComponentProps, type RichTextRendererComponent, type SystemRenderConfig, type SystemRenderFunction, UniformComponent, type UniformComponentContextValue, type UniformComponentProps, UniformComposition, UniformCompositionContext, type UniformCompositionProps, UniformPlayground, type UniformPlaygroundDecorator, type UniformPlaygroundProps, UniformRichText, UniformRichTextNode, type UniformRichTextNodeProps, type UniformRichTextProps, UniformSlot, type UniformSlotProps, type UniformSlotWrapperComponentProps, UniformText, type UniformTextProps, type UseCompositionEventEffectOptions, type UseUniformContextualEditingProps, type UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, convertComponentToProps, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
475
+ export { type ComponentProps, type ComponentStore, type CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, type RenderComponentResolver, type RenderRichTextComponentResolver, type RichTextComponentProps, type RichTextRendererComponent, type SystemRenderConfig, type SystemRenderFunction, UniformComponent, type UniformComponentContextValue, type UniformComponentProps, UniformComposition, UniformCompositionContext, type UniformCompositionProps, UniformPlayground, type UniformPlaygroundDecorator, type UniformPlaygroundProps, UniformRichText, UniformRichTextNode, type UniformRichTextNodeProps, type UniformRichTextProps, UniformSlot, type UniformSlotProps, type UniformSlotWrapperComponentProps, UniformText, type UniformTextProps, type UseCompositionEventEffectOptions, type UseUniformContextualEditingProps, type UseUniformContextualEditingStateProps, type UseUniformContextualEditingStateReturnType, componentStore, componentStoreResolver, convertComponentToProps, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React$1, { Key, ReactNode, PropsWithChildren } from 'react';
2
- import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions } from '@uniformdev/canvas';
2
+ import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions, UpdateContextualEditingStateInternalMessage } from '@uniformdev/canvas';
3
3
  export { GetParameterAttributesProps, createUniformApiEnhancer } from '@uniformdev/canvas';
4
4
  import { P as PureUniformTextProps } from './PureUniformText-B3GAm6Dc.js';
5
5
  import { RichTextNode } from '@uniformdev/richtext';
@@ -430,26 +430,31 @@ type UseUniformContextualEditingStateProps = {
430
430
  **/
431
431
  global?: boolean;
432
432
  };
433
+ type UseUniformContextualEditingStateReturnType = {
434
+ /**
435
+ * Returns `true` when the app is rendered inside Canvas editor. Regardless of which preview mode is currently selected ("editor" or "preview").
436
+ */
437
+ isContextualEditing: boolean;
438
+ /**
439
+ * A reference to the currently selected component in Canvas editor.
440
+ * Returns `undefined` if the selected component is not part of the current React component.
441
+ * Set the `global` option to `true` to get a reference of the selected component anywhere in the composition tree.
442
+ */
443
+ selectedComponentReference: UpdateContextualEditingStateInternalMessage['state']['selectedComponentReference'];
444
+ /**
445
+ * Returns the current preview mode in Canvas editor ("editor" or "preview").
446
+ * Returns `undefined` when the app is not rendered inside Canvas editor.
447
+ * Learn more about the preview modes: https://docs.uniform.app/docs/guides/composition/visual-editing#editing-and-preview-mode
448
+ * @deprecated this is an experimental property, it might receive breaking changes in minor releases ⚠️
449
+ */
450
+ previewMode: UpdateContextualEditingStateInternalMessage['state']['previewMode'] | undefined;
451
+ };
433
452
  /**
434
453
  * Returns the state of contextual editing, when the app is open inside Canvas Editor.
435
454
  * This hook can be used to improve the editing experience of your team.
436
455
  * For example: You can use `selectedComponentReference` to control which element to show inside a carousel or an accordion.
437
456
  */
438
- declare const useUniformContextualEditingState: ({ global, }?: UseUniformContextualEditingStateProps) => {
439
- isContextualEditing: boolean;
440
- selectedComponentReference: {
441
- id: string;
442
- slotName?: string | undefined;
443
- componentIndex?: number | undefined;
444
- totalComponents?: number | undefined;
445
- componentName?: string | undefined;
446
- componentTitle?: string | undefined;
447
- parentId?: string | undefined;
448
- parentType?: string | undefined;
449
- isLocalized?: boolean | undefined;
450
- isReadOnly?: boolean | undefined;
451
- } | undefined;
452
- };
457
+ declare const useUniformContextualEditingState: ({ global, }?: UseUniformContextualEditingStateProps) => UseUniformContextualEditingStateReturnType;
453
458
 
454
459
  declare const componentStore: ComponentStore;
455
460
  declare const registerUniformComponent: ({ type, variantId, component, }: {
@@ -467,4 +472,4 @@ declare const createComponentStoreResolver: (options: {
467
472
  defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
468
473
  }) => RenderComponentResolver;
469
474
 
470
- export { type ComponentProps, type ComponentStore, type CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, type RenderComponentResolver, type RenderRichTextComponentResolver, type RichTextComponentProps, type RichTextRendererComponent, type SystemRenderConfig, type SystemRenderFunction, UniformComponent, type UniformComponentContextValue, type UniformComponentProps, UniformComposition, UniformCompositionContext, type UniformCompositionProps, UniformPlayground, type UniformPlaygroundDecorator, type UniformPlaygroundProps, UniformRichText, UniformRichTextNode, type UniformRichTextNodeProps, type UniformRichTextProps, UniformSlot, type UniformSlotProps, type UniformSlotWrapperComponentProps, UniformText, type UniformTextProps, type UseCompositionEventEffectOptions, type UseUniformContextualEditingProps, type UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, convertComponentToProps, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
475
+ export { type ComponentProps, type ComponentStore, type CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, type RenderComponentResolver, type RenderRichTextComponentResolver, type RichTextComponentProps, type RichTextRendererComponent, type SystemRenderConfig, type SystemRenderFunction, UniformComponent, type UniformComponentContextValue, type UniformComponentProps, UniformComposition, UniformCompositionContext, type UniformCompositionProps, UniformPlayground, type UniformPlaygroundDecorator, type UniformPlaygroundProps, UniformRichText, UniformRichTextNode, type UniformRichTextNodeProps, type UniformRichTextProps, UniformSlot, type UniformSlotProps, type UniformSlotWrapperComponentProps, UniformText, type UniformTextProps, type UseCompositionEventEffectOptions, type UseUniformContextualEditingProps, type UseUniformContextualEditingStateProps, type UseUniformContextualEditingStateReturnType, componentStore, componentStoreResolver, convertComponentToProps, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
package/dist/index.esm.js CHANGED
@@ -940,6 +940,9 @@ var useUniformContextualEditingState = ({
940
940
  const { isContextualEditing } = useUniformCurrentComposition();
941
941
  const { data: componentData } = useUniformCurrentComponent();
942
942
  const [selectedComponentReference, setSelectedComponentReference] = useState3();
943
+ const [previewMode, setPreviewMode] = useState3(
944
+ isContextualEditing ? "editor" : void 0
945
+ );
943
946
  const channel = useMemo4(() => {
944
947
  if (!isContextualEditing) {
945
948
  return;
@@ -959,6 +962,7 @@ var useUniformContextualEditingState = ({
959
962
  if (!isUpdateContextualEditingStateInternalMessage(message)) {
960
963
  return;
961
964
  }
965
+ setPreviewMode(message.state.previewMode);
962
966
  if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
963
967
  setSelectedComponentReference(void 0);
964
968
  return;
@@ -968,13 +972,14 @@ var useUniformContextualEditingState = ({
968
972
  return () => {
969
973
  unsubscribe();
970
974
  };
971
- }, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference]);
975
+ }, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference, setPreviewMode]);
972
976
  return useMemo4(
973
977
  () => ({
974
978
  isContextualEditing,
975
- selectedComponentReference
979
+ selectedComponentReference,
980
+ previewMode
976
981
  }),
977
- [isContextualEditing, selectedComponentReference]
982
+ [isContextualEditing, selectedComponentReference, previewMode]
978
983
  );
979
984
  };
980
985
  export {
package/dist/index.js CHANGED
@@ -956,6 +956,9 @@ var useUniformContextualEditingState = ({
956
956
  const { isContextualEditing } = useUniformCurrentComposition();
957
957
  const { data: componentData } = useUniformCurrentComponent();
958
958
  const [selectedComponentReference, setSelectedComponentReference] = (0, import_react22.useState)();
959
+ const [previewMode, setPreviewMode] = (0, import_react22.useState)(
960
+ isContextualEditing ? "editor" : void 0
961
+ );
959
962
  const channel = (0, import_react22.useMemo)(() => {
960
963
  if (!isContextualEditing) {
961
964
  return;
@@ -975,6 +978,7 @@ var useUniformContextualEditingState = ({
975
978
  if (!(0, import_canvas12.isUpdateContextualEditingStateInternalMessage)(message)) {
976
979
  return;
977
980
  }
981
+ setPreviewMode(message.state.previewMode);
978
982
  if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
979
983
  setSelectedComponentReference(void 0);
980
984
  return;
@@ -984,13 +988,14 @@ var useUniformContextualEditingState = ({
984
988
  return () => {
985
989
  unsubscribe();
986
990
  };
987
- }, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference]);
991
+ }, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference, setPreviewMode]);
988
992
  return (0, import_react22.useMemo)(
989
993
  () => ({
990
994
  isContextualEditing,
991
- selectedComponentReference
995
+ selectedComponentReference,
996
+ previewMode
992
997
  }),
993
- [isContextualEditing, selectedComponentReference]
998
+ [isContextualEditing, selectedComponentReference, previewMode]
994
999
  );
995
1000
  };
996
1001
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -940,6 +940,9 @@ var useUniformContextualEditingState = ({
940
940
  const { isContextualEditing } = useUniformCurrentComposition();
941
941
  const { data: componentData } = useUniformCurrentComponent();
942
942
  const [selectedComponentReference, setSelectedComponentReference] = useState3();
943
+ const [previewMode, setPreviewMode] = useState3(
944
+ isContextualEditing ? "editor" : void 0
945
+ );
943
946
  const channel = useMemo4(() => {
944
947
  if (!isContextualEditing) {
945
948
  return;
@@ -959,6 +962,7 @@ var useUniformContextualEditingState = ({
959
962
  if (!isUpdateContextualEditingStateInternalMessage(message)) {
960
963
  return;
961
964
  }
965
+ setPreviewMode(message.state.previewMode);
962
966
  if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
963
967
  setSelectedComponentReference(void 0);
964
968
  return;
@@ -968,13 +972,14 @@ var useUniformContextualEditingState = ({
968
972
  return () => {
969
973
  unsubscribe();
970
974
  };
971
- }, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference]);
975
+ }, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference, setPreviewMode]);
972
976
  return useMemo4(
973
977
  () => ({
974
978
  isContextualEditing,
975
- selectedComponentReference
979
+ selectedComponentReference,
980
+ previewMode
976
981
  }),
977
- [isContextualEditing, selectedComponentReference]
982
+ [isContextualEditing, selectedComponentReference, previewMode]
978
983
  );
979
984
  };
980
985
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-react",
3
- "version": "19.139.0",
3
+ "version": "19.140.2-alpha.7+b328af635c",
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.139.0",
49
- "@uniformdev/context": "19.139.0",
50
- "@uniformdev/context-react": "19.139.0",
51
- "@uniformdev/richtext": "19.139.0"
48
+ "@uniformdev/canvas": "19.140.2-alpha.7+b328af635c",
49
+ "@uniformdev/context": "19.140.2-alpha.7+b328af635c",
50
+ "@uniformdev/context-react": "19.140.2-alpha.7+b328af635c",
51
+ "@uniformdev/richtext": "19.140.2-alpha.7+b328af635c"
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": "86f2f88868e7f17acf970e1cbf7612650761e961"
68
+ "gitHead": "b328af635c3bf3547580cef498cb277a30912339"
69
69
  }