@uniformdev/canvas-react 19.141.1-alpha.5 → 19.142.1

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';
@@ -110,6 +110,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
110
110
  connectedData?: {
111
111
  pointer: string;
112
112
  syntax: "jptr";
113
+ failureAction?: "a" | "p" | "t" | "c" | undefined;
114
+ failureLogLevel?: "i" | "e" | "w" | undefined;
115
+ failureDefault?: string | undefined;
113
116
  } | undefined;
114
117
  locales?: {
115
118
  [key: string]: unknown;
@@ -125,7 +128,7 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
125
128
  isSearchHit?: boolean | undefined;
126
129
  queryStrings?: {
127
130
  name: string;
128
- value: string;
131
+ value?: string | undefined;
129
132
  helpText?: string | undefined;
130
133
  }[] | undefined;
131
134
  previewValue?: string | undefined;
@@ -147,6 +150,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
147
150
  connectedData?: {
148
151
  pointer: string;
149
152
  syntax: "jptr";
153
+ failureAction?: "a" | "p" | "t" | "c" | undefined;
154
+ failureLogLevel?: "i" | "e" | "w" | undefined;
155
+ failureDefault?: string | undefined;
150
156
  } | undefined;
151
157
  locales?: {
152
158
  [key: string]: unknown;
@@ -189,6 +195,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
189
195
  connectedData?: {
190
196
  pointer: string;
191
197
  syntax: "jptr";
198
+ failureAction?: "a" | "p" | "t" | "c" | undefined;
199
+ failureLogLevel?: "i" | "e" | "w" | undefined;
200
+ failureDefault?: string | undefined;
192
201
  } | undefined;
193
202
  locales?: {
194
203
  [key: string]: unknown;
@@ -245,6 +254,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
245
254
  connectedData?: {
246
255
  pointer: string;
247
256
  syntax: "jptr";
257
+ failureAction?: "a" | "p" | "t" | "c" | undefined;
258
+ failureLogLevel?: "i" | "e" | "w" | undefined;
259
+ failureDefault?: string | undefined;
248
260
  } | undefined;
249
261
  locales?: {
250
262
  [key: string]: unknown;
@@ -430,26 +442,31 @@ type UseUniformContextualEditingStateProps = {
430
442
  **/
431
443
  global?: boolean;
432
444
  };
445
+ type UseUniformContextualEditingStateReturnType = {
446
+ /**
447
+ * Returns `true` when the app is rendered inside Canvas editor. Regardless of which preview mode is currently selected ("editor" or "preview").
448
+ */
449
+ isContextualEditing: boolean;
450
+ /**
451
+ * A reference to the currently selected component in Canvas editor.
452
+ * Returns `undefined` if the selected component is not part of the current React component.
453
+ * Set the `global` option to `true` to get a reference of the selected component anywhere in the composition tree.
454
+ */
455
+ selectedComponentReference: UpdateContextualEditingStateInternalMessage['state']['selectedComponentReference'];
456
+ /**
457
+ * Returns the current preview mode in Canvas editor ("editor" or "preview").
458
+ * Returns `undefined` when the app is not rendered inside Canvas editor.
459
+ * Learn more about the preview modes: https://docs.uniform.app/docs/guides/composition/visual-editing#editing-and-preview-mode
460
+ * @deprecated this is an experimental property, it might receive breaking changes in minor releases ⚠️
461
+ */
462
+ previewMode: UpdateContextualEditingStateInternalMessage['state']['previewMode'] | undefined;
463
+ };
433
464
  /**
434
465
  * Returns the state of contextual editing, when the app is open inside Canvas Editor.
435
466
  * This hook can be used to improve the editing experience of your team.
436
467
  * For example: You can use `selectedComponentReference` to control which element to show inside a carousel or an accordion.
437
468
  */
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
- };
469
+ declare const useUniformContextualEditingState: ({ global, }?: UseUniformContextualEditingStateProps) => UseUniformContextualEditingStateReturnType;
453
470
 
454
471
  declare const componentStore: ComponentStore;
455
472
  declare const registerUniformComponent: ({ type, variantId, component, }: {
@@ -467,4 +484,4 @@ declare const createComponentStoreResolver: (options: {
467
484
  defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
468
485
  }) => RenderComponentResolver;
469
486
 
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 };
487
+ 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';
@@ -110,6 +110,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
110
110
  connectedData?: {
111
111
  pointer: string;
112
112
  syntax: "jptr";
113
+ failureAction?: "a" | "p" | "t" | "c" | undefined;
114
+ failureLogLevel?: "i" | "e" | "w" | undefined;
115
+ failureDefault?: string | undefined;
113
116
  } | undefined;
114
117
  locales?: {
115
118
  [key: string]: unknown;
@@ -125,7 +128,7 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
125
128
  isSearchHit?: boolean | undefined;
126
129
  queryStrings?: {
127
130
  name: string;
128
- value: string;
131
+ value?: string | undefined;
129
132
  helpText?: string | undefined;
130
133
  }[] | undefined;
131
134
  previewValue?: string | undefined;
@@ -147,6 +150,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
147
150
  connectedData?: {
148
151
  pointer: string;
149
152
  syntax: "jptr";
153
+ failureAction?: "a" | "p" | "t" | "c" | undefined;
154
+ failureLogLevel?: "i" | "e" | "w" | undefined;
155
+ failureDefault?: string | undefined;
150
156
  } | undefined;
151
157
  locales?: {
152
158
  [key: string]: unknown;
@@ -189,6 +195,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
189
195
  connectedData?: {
190
196
  pointer: string;
191
197
  syntax: "jptr";
198
+ failureAction?: "a" | "p" | "t" | "c" | undefined;
199
+ failureLogLevel?: "i" | "e" | "w" | undefined;
200
+ failureDefault?: string | undefined;
192
201
  } | undefined;
193
202
  locales?: {
194
203
  [key: string]: unknown;
@@ -245,6 +254,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
245
254
  connectedData?: {
246
255
  pointer: string;
247
256
  syntax: "jptr";
257
+ failureAction?: "a" | "p" | "t" | "c" | undefined;
258
+ failureLogLevel?: "i" | "e" | "w" | undefined;
259
+ failureDefault?: string | undefined;
248
260
  } | undefined;
249
261
  locales?: {
250
262
  [key: string]: unknown;
@@ -430,26 +442,31 @@ type UseUniformContextualEditingStateProps = {
430
442
  **/
431
443
  global?: boolean;
432
444
  };
445
+ type UseUniformContextualEditingStateReturnType = {
446
+ /**
447
+ * Returns `true` when the app is rendered inside Canvas editor. Regardless of which preview mode is currently selected ("editor" or "preview").
448
+ */
449
+ isContextualEditing: boolean;
450
+ /**
451
+ * A reference to the currently selected component in Canvas editor.
452
+ * Returns `undefined` if the selected component is not part of the current React component.
453
+ * Set the `global` option to `true` to get a reference of the selected component anywhere in the composition tree.
454
+ */
455
+ selectedComponentReference: UpdateContextualEditingStateInternalMessage['state']['selectedComponentReference'];
456
+ /**
457
+ * Returns the current preview mode in Canvas editor ("editor" or "preview").
458
+ * Returns `undefined` when the app is not rendered inside Canvas editor.
459
+ * Learn more about the preview modes: https://docs.uniform.app/docs/guides/composition/visual-editing#editing-and-preview-mode
460
+ * @deprecated this is an experimental property, it might receive breaking changes in minor releases ⚠️
461
+ */
462
+ previewMode: UpdateContextualEditingStateInternalMessage['state']['previewMode'] | undefined;
463
+ };
433
464
  /**
434
465
  * Returns the state of contextual editing, when the app is open inside Canvas Editor.
435
466
  * This hook can be used to improve the editing experience of your team.
436
467
  * For example: You can use `selectedComponentReference` to control which element to show inside a carousel or an accordion.
437
468
  */
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
- };
469
+ declare const useUniformContextualEditingState: ({ global, }?: UseUniformContextualEditingStateProps) => UseUniformContextualEditingStateReturnType;
453
470
 
454
471
  declare const componentStore: ComponentStore;
455
472
  declare const registerUniformComponent: ({ type, variantId, component, }: {
@@ -467,4 +484,4 @@ declare const createComponentStoreResolver: (options: {
467
484
  defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
468
485
  }) => RenderComponentResolver;
469
486
 
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 };
487
+ 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.141.1-alpha.5+4c722bef9c",
3
+ "version": "19.142.1",
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.141.1-alpha.5+4c722bef9c",
49
- "@uniformdev/context": "19.141.1-alpha.5+4c722bef9c",
50
- "@uniformdev/context-react": "19.141.1-alpha.5+4c722bef9c",
51
- "@uniformdev/richtext": "19.141.1-alpha.5+4c722bef9c"
48
+ "@uniformdev/canvas": "19.142.1",
49
+ "@uniformdev/context": "19.142.1",
50
+ "@uniformdev/context-react": "19.142.1",
51
+ "@uniformdev/richtext": "19.142.1"
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": "4c722bef9cfbf90b8981cec47fadec37b02a3c12"
68
+ "gitHead": "e158ea370c3f68625a3ea743298ec9ae4d2fc391"
69
69
  }