@uniformdev/canvas-react 19.38.3-alpha.70 → 19.38.3-alpha.78
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 +35 -3
- package/dist/index.d.ts +35 -3
- package/dist/index.esm.js +99 -48
- package/dist/index.js +117 -64
- package/dist/index.mjs +99 -48
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -257,6 +257,7 @@ type UniformCompositionContextValue = {
|
|
|
257
257
|
behaviorTracking?: UniformCompositionProps['behaviorTracking'];
|
|
258
258
|
isContextualEditing: boolean;
|
|
259
259
|
};
|
|
260
|
+
declare const UniformCompositionContext: React$1.Context<UniformCompositionContextValue>;
|
|
260
261
|
/**
|
|
261
262
|
* Gets the data of the closest `<UniformComposition />` ancestor.
|
|
262
263
|
*/
|
|
@@ -268,6 +269,24 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
|
|
|
268
269
|
*/
|
|
269
270
|
declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
|
|
270
271
|
|
|
272
|
+
type UniformPlaygroundDecorator = (options: {
|
|
273
|
+
children: React$1.ReactNode;
|
|
274
|
+
data: ComponentInstance | RootComponentInstance;
|
|
275
|
+
}) => React$1.ReactElement;
|
|
276
|
+
type UniformPlaygroundProps = {
|
|
277
|
+
/**
|
|
278
|
+
* Allows wrapping the playground in custom components.
|
|
279
|
+
* Useful to customize the playground to allow previewing the components in realistic scenarios
|
|
280
|
+
* (e.g. different background color, different parent size)
|
|
281
|
+
* @deprecated This feature is not stable yet and might be changed or removed in a minor release. Do not use it in production environments.
|
|
282
|
+
*/
|
|
283
|
+
decorators?: UniformPlaygroundDecorator[];
|
|
284
|
+
} & Omit<UniformCompositionProps, 'data'>;
|
|
285
|
+
/**
|
|
286
|
+
* Playground where you can freely live preview your components and pattern.
|
|
287
|
+
*/
|
|
288
|
+
declare const UniformPlayground: ({ resolveRenderer, decorators, contextualEditingEnhancer, behaviorTracking, contextualEditingDefaultPlaceholder, children, }: UniformPlaygroundProps) => React$1.JSX.Element;
|
|
289
|
+
|
|
271
290
|
type RichTextComponentProps<TNode extends RichTextNode = RichTextNode> = {
|
|
272
291
|
node: TNode;
|
|
273
292
|
};
|
|
@@ -324,6 +343,10 @@ type CustomSlotChildRenderFunc = (options: {
|
|
|
324
343
|
component: ComponentInstance;
|
|
325
344
|
key: Key;
|
|
326
345
|
}) => JSX.Element;
|
|
346
|
+
type UniformSlotWrapperComponentProps = {
|
|
347
|
+
items: ReactNode[];
|
|
348
|
+
slotName: string;
|
|
349
|
+
};
|
|
327
350
|
type UniformSlotProps<TSlotNames extends string> = {
|
|
328
351
|
/** Name of the slot to render */
|
|
329
352
|
name: TSlotNames;
|
|
@@ -332,8 +355,17 @@ type UniformSlotProps<TSlotNames extends string> = {
|
|
|
332
355
|
* If not specified, the resolveRenderer function on the nearest Layout will be used, if any.
|
|
333
356
|
*/
|
|
334
357
|
resolveRenderer?: RenderComponentResolver;
|
|
335
|
-
/**
|
|
358
|
+
/**
|
|
359
|
+
* Optional render props enables wrapping all child components in the slot with some markup
|
|
360
|
+
*
|
|
361
|
+
* @deprecated Use `wrapperComponent` instead and define wrapping component for slot children inside.
|
|
362
|
+
*/
|
|
336
363
|
children?: CustomSlotChildRenderFunc;
|
|
364
|
+
/**
|
|
365
|
+
* Optional wrapper component around list of slot items that allows to control
|
|
366
|
+
* exactly how to render slot items, otherwise React.Fragment is being used
|
|
367
|
+
*/
|
|
368
|
+
wrapperComponent?: React$1.ComponentType<UniformSlotWrapperComponentProps>;
|
|
337
369
|
/**
|
|
338
370
|
* Optional ReactNode to use as a placeholder in Canvas editor when the slot is empty.
|
|
339
371
|
* The node is used to render a placeholder with realistic dimensions and it's never shown to users.
|
|
@@ -342,7 +374,7 @@ type UniformSlotProps<TSlotNames extends string> = {
|
|
|
342
374
|
emptyPlaceholder?: React$1.ReactNode;
|
|
343
375
|
};
|
|
344
376
|
/** Renders a named Slot within a Composition. */
|
|
345
|
-
declare function UniformSlot<TSlotNames extends string = string>({ name, resolveRenderer, children, emptyPlaceholder, }: UniformSlotProps<TSlotNames>): JSX.Element | null;
|
|
377
|
+
declare function UniformSlot<TSlotNames extends string = string>({ name, resolveRenderer, children, emptyPlaceholder, wrapperComponent, }: UniformSlotProps<TSlotNames>): JSX.Element | null;
|
|
346
378
|
|
|
347
379
|
/**
|
|
348
380
|
* Returns the attributes needed to annotate a Uniform parameter for inline editing.
|
|
@@ -391,4 +423,4 @@ declare const createComponentStoreResolver: (options: {
|
|
|
391
423
|
defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
|
|
392
424
|
}) => RenderComponentResolver;
|
|
393
425
|
|
|
394
|
-
export { ComponentProps, ComponentStore, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
|
|
426
|
+
export { ComponentProps, ComponentStore, CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionContext, UniformCompositionProps, UniformPlayground, UniformPlaygroundDecorator, UniformPlaygroundProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformSlotWrapperComponentProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
|
package/dist/index.d.ts
CHANGED
|
@@ -257,6 +257,7 @@ type UniformCompositionContextValue = {
|
|
|
257
257
|
behaviorTracking?: UniformCompositionProps['behaviorTracking'];
|
|
258
258
|
isContextualEditing: boolean;
|
|
259
259
|
};
|
|
260
|
+
declare const UniformCompositionContext: React$1.Context<UniformCompositionContextValue>;
|
|
260
261
|
/**
|
|
261
262
|
* Gets the data of the closest `<UniformComposition />` ancestor.
|
|
262
263
|
*/
|
|
@@ -268,6 +269,24 @@ declare function useUniformCurrentComposition(): UniformCompositionContextValue;
|
|
|
268
269
|
*/
|
|
269
270
|
declare function UniformComposition<TRenderProps = unknown>({ data, behaviorTracking, children, resolveRenderer, contextualEditingEnhancer, contextualEditingDefaultPlaceholder, }: UniformCompositionProps<TRenderProps>): React$1.JSX.Element;
|
|
270
271
|
|
|
272
|
+
type UniformPlaygroundDecorator = (options: {
|
|
273
|
+
children: React$1.ReactNode;
|
|
274
|
+
data: ComponentInstance | RootComponentInstance;
|
|
275
|
+
}) => React$1.ReactElement;
|
|
276
|
+
type UniformPlaygroundProps = {
|
|
277
|
+
/**
|
|
278
|
+
* Allows wrapping the playground in custom components.
|
|
279
|
+
* Useful to customize the playground to allow previewing the components in realistic scenarios
|
|
280
|
+
* (e.g. different background color, different parent size)
|
|
281
|
+
* @deprecated This feature is not stable yet and might be changed or removed in a minor release. Do not use it in production environments.
|
|
282
|
+
*/
|
|
283
|
+
decorators?: UniformPlaygroundDecorator[];
|
|
284
|
+
} & Omit<UniformCompositionProps, 'data'>;
|
|
285
|
+
/**
|
|
286
|
+
* Playground where you can freely live preview your components and pattern.
|
|
287
|
+
*/
|
|
288
|
+
declare const UniformPlayground: ({ resolveRenderer, decorators, contextualEditingEnhancer, behaviorTracking, contextualEditingDefaultPlaceholder, children, }: UniformPlaygroundProps) => React$1.JSX.Element;
|
|
289
|
+
|
|
271
290
|
type RichTextComponentProps<TNode extends RichTextNode = RichTextNode> = {
|
|
272
291
|
node: TNode;
|
|
273
292
|
};
|
|
@@ -324,6 +343,10 @@ type CustomSlotChildRenderFunc = (options: {
|
|
|
324
343
|
component: ComponentInstance;
|
|
325
344
|
key: Key;
|
|
326
345
|
}) => JSX.Element;
|
|
346
|
+
type UniformSlotWrapperComponentProps = {
|
|
347
|
+
items: ReactNode[];
|
|
348
|
+
slotName: string;
|
|
349
|
+
};
|
|
327
350
|
type UniformSlotProps<TSlotNames extends string> = {
|
|
328
351
|
/** Name of the slot to render */
|
|
329
352
|
name: TSlotNames;
|
|
@@ -332,8 +355,17 @@ type UniformSlotProps<TSlotNames extends string> = {
|
|
|
332
355
|
* If not specified, the resolveRenderer function on the nearest Layout will be used, if any.
|
|
333
356
|
*/
|
|
334
357
|
resolveRenderer?: RenderComponentResolver;
|
|
335
|
-
/**
|
|
358
|
+
/**
|
|
359
|
+
* Optional render props enables wrapping all child components in the slot with some markup
|
|
360
|
+
*
|
|
361
|
+
* @deprecated Use `wrapperComponent` instead and define wrapping component for slot children inside.
|
|
362
|
+
*/
|
|
336
363
|
children?: CustomSlotChildRenderFunc;
|
|
364
|
+
/**
|
|
365
|
+
* Optional wrapper component around list of slot items that allows to control
|
|
366
|
+
* exactly how to render slot items, otherwise React.Fragment is being used
|
|
367
|
+
*/
|
|
368
|
+
wrapperComponent?: React$1.ComponentType<UniformSlotWrapperComponentProps>;
|
|
337
369
|
/**
|
|
338
370
|
* Optional ReactNode to use as a placeholder in Canvas editor when the slot is empty.
|
|
339
371
|
* The node is used to render a placeholder with realistic dimensions and it's never shown to users.
|
|
@@ -342,7 +374,7 @@ type UniformSlotProps<TSlotNames extends string> = {
|
|
|
342
374
|
emptyPlaceholder?: React$1.ReactNode;
|
|
343
375
|
};
|
|
344
376
|
/** Renders a named Slot within a Composition. */
|
|
345
|
-
declare function UniformSlot<TSlotNames extends string = string>({ name, resolveRenderer, children, emptyPlaceholder, }: UniformSlotProps<TSlotNames>): JSX.Element | null;
|
|
377
|
+
declare function UniformSlot<TSlotNames extends string = string>({ name, resolveRenderer, children, emptyPlaceholder, wrapperComponent, }: UniformSlotProps<TSlotNames>): JSX.Element | null;
|
|
346
378
|
|
|
347
379
|
/**
|
|
348
380
|
* Returns the attributes needed to annotate a Uniform parameter for inline editing.
|
|
@@ -391,4 +423,4 @@ declare const createComponentStoreResolver: (options: {
|
|
|
391
423
|
defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
|
|
392
424
|
}) => RenderComponentResolver;
|
|
393
425
|
|
|
394
|
-
export { ComponentProps, ComponentStore, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
|
|
426
|
+
export { ComponentProps, ComponentStore, CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, RenderComponentResolver, RenderRichTextComponentResolver, RichTextComponentProps, RichTextRendererComponent, SystemRenderConfig, SystemRenderFunction, UniformComponent, UniformComponentContextValue, UniformComponentProps, UniformComposition, UniformCompositionContext, UniformCompositionProps, UniformPlayground, UniformPlaygroundDecorator, UniformPlaygroundProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformSlotWrapperComponentProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
|
package/dist/index.esm.js
CHANGED
|
@@ -330,9 +330,10 @@ function ContextualEditingComponentWrapper({
|
|
|
330
330
|
emptyPlaceholder,
|
|
331
331
|
children
|
|
332
332
|
}) {
|
|
333
|
-
var _a, _b, _c, _d;
|
|
333
|
+
var _a, _b, _c, _d, _e;
|
|
334
334
|
const isPlaceholder = (component == null ? void 0 : component._id) === PLACEHOLDER_ID;
|
|
335
335
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
336
|
+
const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
|
|
336
337
|
return !isContextualEditing ? /* @__PURE__ */ React4.createElement(React4.Fragment, null, children) : isPlaceholder && emptyPlaceholder === null ? null : /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(
|
|
337
338
|
"script",
|
|
338
339
|
{
|
|
@@ -345,8 +346,9 @@ function ContextualEditingComponentWrapper({
|
|
|
345
346
|
"data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
|
|
346
347
|
"data-component-name": component == null ? void 0 : component.type,
|
|
347
348
|
"data-is-placeholder": isPlaceholder ? "true" : void 0,
|
|
348
|
-
"data-is-localized": ((
|
|
349
|
-
"data-component-title": (
|
|
349
|
+
"data-is-localized": ((_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b[CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
|
|
350
|
+
"data-component-title": (_e = (_d = (_c = component == null ? void 0 : component.parameters) == null ? void 0 : _c.title) == null ? void 0 : _d.value) != null ? _e : "",
|
|
351
|
+
"data-is-readonly": isReadOnly
|
|
350
352
|
}
|
|
351
353
|
), isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder : children, /* @__PURE__ */ React4.createElement("script", { "data-role": IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
|
|
352
354
|
}
|
|
@@ -356,7 +358,8 @@ function UniformSlot({
|
|
|
356
358
|
name,
|
|
357
359
|
resolveRenderer,
|
|
358
360
|
children,
|
|
359
|
-
emptyPlaceholder
|
|
361
|
+
emptyPlaceholder,
|
|
362
|
+
wrapperComponent
|
|
360
363
|
}) {
|
|
361
364
|
var _a;
|
|
362
365
|
const { data: parentData, resolveRenderer: parentResolveRenderer } = useUniformCurrentComponent();
|
|
@@ -374,12 +377,10 @@ function UniformSlot({
|
|
|
374
377
|
return null;
|
|
375
378
|
}
|
|
376
379
|
const resolver = resolveRenderer != null ? resolveRenderer : parentResolveRenderer;
|
|
377
|
-
const systemResolver = defaultSystemComponentResolver;
|
|
378
380
|
const finalChildren = slot.map((component, index) => {
|
|
379
381
|
const child = renderComponent({
|
|
380
382
|
component,
|
|
381
383
|
resolveRenderer: resolver,
|
|
382
|
-
resolveSystem: systemResolver,
|
|
383
384
|
key: `inner-${index}`,
|
|
384
385
|
indexInSlot: index,
|
|
385
386
|
slotName: name,
|
|
@@ -390,12 +391,15 @@ function UniformSlot({
|
|
|
390
391
|
const elements = children ? children({ child, component, key: `wrapped-inner-${index}` }) : child;
|
|
391
392
|
return React5.createElement(React5.Fragment, { key: index }, elements);
|
|
392
393
|
});
|
|
393
|
-
|
|
394
|
+
if (!wrapperComponent) {
|
|
395
|
+
return React5.createElement(React5.Fragment, void 0, finalChildren);
|
|
396
|
+
}
|
|
397
|
+
const Wrapper = wrapperComponent;
|
|
398
|
+
return /* @__PURE__ */ React5.createElement(Wrapper, { items: finalChildren, slotName: name });
|
|
394
399
|
}
|
|
395
400
|
function renderComponent({
|
|
396
401
|
component,
|
|
397
402
|
resolveRenderer,
|
|
398
|
-
resolveSystem,
|
|
399
403
|
key = 0,
|
|
400
404
|
indexInSlot,
|
|
401
405
|
slotName,
|
|
@@ -405,7 +409,7 @@ function renderComponent({
|
|
|
405
409
|
}) {
|
|
406
410
|
const RenderComponent = resolveRenderer == null ? void 0 : resolveRenderer(component);
|
|
407
411
|
if (component.type === CANVAS_TEST_TYPE) {
|
|
408
|
-
const testComponent =
|
|
412
|
+
const testComponent = defaultSystemComponentResolver.test(
|
|
409
413
|
component,
|
|
410
414
|
key,
|
|
411
415
|
(variantComponent, key2) => {
|
|
@@ -413,7 +417,6 @@ function renderComponent({
|
|
|
413
417
|
return renderComponent({
|
|
414
418
|
component: variantComponent,
|
|
415
419
|
resolveRenderer,
|
|
416
|
-
resolveSystem,
|
|
417
420
|
key: key2,
|
|
418
421
|
parentComponent: component,
|
|
419
422
|
slotName: CANVAS_TEST_SLOT,
|
|
@@ -437,7 +440,7 @@ function renderComponent({
|
|
|
437
440
|
testComponent
|
|
438
441
|
);
|
|
439
442
|
} else if (component.type === CANVAS_PERSONALIZE_TYPE) {
|
|
440
|
-
const personalizationComponent =
|
|
443
|
+
const personalizationComponent = defaultSystemComponentResolver.personalization(
|
|
441
444
|
component,
|
|
442
445
|
key,
|
|
443
446
|
(variantComponent, key2) => {
|
|
@@ -445,7 +448,6 @@ function renderComponent({
|
|
|
445
448
|
return renderComponent({
|
|
446
449
|
component: variantComponent,
|
|
447
450
|
resolveRenderer,
|
|
448
|
-
resolveSystem,
|
|
449
451
|
key: key2,
|
|
450
452
|
parentComponent: component,
|
|
451
453
|
slotName: CANVAS_PERSONALIZE_SLOT,
|
|
@@ -556,60 +558,110 @@ function resolveChildren({
|
|
|
556
558
|
return renderChildren;
|
|
557
559
|
}
|
|
558
560
|
|
|
561
|
+
// src/components/UniformPlayground.tsx
|
|
562
|
+
import { EMPTY_COMPOSITION as EMPTY_COMPOSITION3 } from "@uniformdev/canvas";
|
|
563
|
+
import React7, { useMemo as useMemo2 } from "react";
|
|
564
|
+
var UniformPlayground = ({
|
|
565
|
+
resolveRenderer,
|
|
566
|
+
decorators = [],
|
|
567
|
+
contextualEditingEnhancer,
|
|
568
|
+
behaviorTracking,
|
|
569
|
+
contextualEditingDefaultPlaceholder,
|
|
570
|
+
children
|
|
571
|
+
}) => {
|
|
572
|
+
const { composition, isContextualEditing } = useUniformContextualEditing({
|
|
573
|
+
initialCompositionValue: EMPTY_COMPOSITION3,
|
|
574
|
+
enhance: contextualEditingEnhancer
|
|
575
|
+
});
|
|
576
|
+
const renderedComponent = useMemo2(() => {
|
|
577
|
+
if (!composition) {
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
let component = /* @__PURE__ */ React7.createElement(
|
|
581
|
+
UniformComponent,
|
|
582
|
+
{
|
|
583
|
+
data: composition,
|
|
584
|
+
behaviorTracking,
|
|
585
|
+
resolveRenderer,
|
|
586
|
+
contextualEditingDefaultPlaceholder
|
|
587
|
+
},
|
|
588
|
+
children
|
|
589
|
+
);
|
|
590
|
+
decorators.forEach((Decorator) => {
|
|
591
|
+
component = /* @__PURE__ */ React7.createElement(Decorator, { data: composition }, component);
|
|
592
|
+
});
|
|
593
|
+
return component;
|
|
594
|
+
}, [
|
|
595
|
+
children,
|
|
596
|
+
resolveRenderer,
|
|
597
|
+
decorators,
|
|
598
|
+
composition,
|
|
599
|
+
behaviorTracking,
|
|
600
|
+
contextualEditingDefaultPlaceholder
|
|
601
|
+
]);
|
|
602
|
+
return /* @__PURE__ */ React7.createElement(
|
|
603
|
+
UniformCompositionContext.Provider,
|
|
604
|
+
{
|
|
605
|
+
value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
|
|
606
|
+
},
|
|
607
|
+
/* @__PURE__ */ React7.createElement(ContextualEditingComponentWrapper, { component: composition }, renderedComponent)
|
|
608
|
+
);
|
|
609
|
+
};
|
|
610
|
+
|
|
559
611
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
560
612
|
import {
|
|
561
613
|
isRichTextValue,
|
|
562
614
|
isRichTextValueConsideredEmpty
|
|
563
615
|
} from "@uniformdev/richtext";
|
|
564
|
-
import
|
|
616
|
+
import React17, { useMemo as useMemo3 } from "react";
|
|
565
617
|
|
|
566
618
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
567
619
|
import { isRichTextNode } from "@uniformdev/richtext";
|
|
568
|
-
import
|
|
620
|
+
import React16 from "react";
|
|
569
621
|
|
|
570
622
|
// src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
|
|
571
|
-
import
|
|
623
|
+
import React8 from "react";
|
|
572
624
|
var HeadingRichTextNode = ({ children, node }) => {
|
|
573
625
|
const { tag } = node;
|
|
574
626
|
const HTag = tag != null ? tag : "h1";
|
|
575
|
-
return /* @__PURE__ */
|
|
627
|
+
return /* @__PURE__ */ React8.createElement(HTag, null, children);
|
|
576
628
|
};
|
|
577
629
|
|
|
578
630
|
// src/components/UniformRichText/nodes/LinebreakRichTextNode.tsx
|
|
579
|
-
import
|
|
631
|
+
import React9 from "react";
|
|
580
632
|
var LinebreakRichTextNode = () => {
|
|
581
|
-
return /* @__PURE__ */
|
|
633
|
+
return /* @__PURE__ */ React9.createElement("br", null);
|
|
582
634
|
};
|
|
583
635
|
|
|
584
636
|
// src/components/UniformRichText/nodes/LinkRichTextNode.tsx
|
|
585
637
|
import { linkParamValueToHref } from "@uniformdev/richtext";
|
|
586
|
-
import
|
|
638
|
+
import React10 from "react";
|
|
587
639
|
var LinkRichTextNode = ({ children, node }) => {
|
|
588
640
|
const { link } = node;
|
|
589
|
-
return /* @__PURE__ */
|
|
641
|
+
return /* @__PURE__ */ React10.createElement("a", { href: linkParamValueToHref(link) }, children);
|
|
590
642
|
};
|
|
591
643
|
|
|
592
644
|
// src/components/UniformRichText/nodes/ListItemRichTextNode.tsx
|
|
593
|
-
import
|
|
645
|
+
import React11 from "react";
|
|
594
646
|
var ListItemRichTextNode = ({ children, node }) => {
|
|
595
647
|
const { value } = node;
|
|
596
|
-
return /* @__PURE__ */
|
|
648
|
+
return /* @__PURE__ */ React11.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
|
|
597
649
|
};
|
|
598
650
|
|
|
599
651
|
// src/components/UniformRichText/nodes/ListRichTextNode.tsx
|
|
600
|
-
import
|
|
652
|
+
import React12 from "react";
|
|
601
653
|
var ListRichTextNode = ({ children, node }) => {
|
|
602
654
|
const { tag, start } = node;
|
|
603
655
|
const ListTag = tag != null ? tag : "ul";
|
|
604
|
-
return /* @__PURE__ */
|
|
656
|
+
return /* @__PURE__ */ React12.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
|
|
605
657
|
};
|
|
606
658
|
|
|
607
659
|
// src/components/UniformRichText/nodes/ParagraphRichTextNode.tsx
|
|
608
660
|
import { isPureDirection, isPureTextAlign } from "@uniformdev/richtext";
|
|
609
|
-
import
|
|
661
|
+
import React13 from "react";
|
|
610
662
|
var ParagraphRichTextNode = ({ children, node }) => {
|
|
611
663
|
const { format, direction } = node;
|
|
612
|
-
return /* @__PURE__ */
|
|
664
|
+
return /* @__PURE__ */ React13.createElement(
|
|
613
665
|
"p",
|
|
614
666
|
{
|
|
615
667
|
dir: isPureDirection(direction) ? direction : void 0,
|
|
@@ -620,18 +672,18 @@ var ParagraphRichTextNode = ({ children, node }) => {
|
|
|
620
672
|
};
|
|
621
673
|
|
|
622
674
|
// src/components/UniformRichText/nodes/TabRichTextNode.tsx
|
|
623
|
-
import
|
|
675
|
+
import React14 from "react";
|
|
624
676
|
var TabRichTextNode = () => {
|
|
625
|
-
return /* @__PURE__ */
|
|
677
|
+
return /* @__PURE__ */ React14.createElement(React14.Fragment, null, " ");
|
|
626
678
|
};
|
|
627
679
|
|
|
628
680
|
// src/components/UniformRichText/nodes/TextRichTextNode.tsx
|
|
629
681
|
import { getRichTextTagsFromTextFormat } from "@uniformdev/richtext";
|
|
630
|
-
import
|
|
682
|
+
import React15 from "react";
|
|
631
683
|
var TextRichTextNode = ({ node }) => {
|
|
632
684
|
const { text, format } = node;
|
|
633
685
|
const tags = getRichTextTagsFromTextFormat(format);
|
|
634
|
-
return /* @__PURE__ */
|
|
686
|
+
return /* @__PURE__ */ React15.createElement(React15.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ React15.createElement(Tag, null, children), text) : text);
|
|
635
687
|
};
|
|
636
688
|
|
|
637
689
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
@@ -646,8 +698,8 @@ function UniformRichTextNode({ node, ...props }) {
|
|
|
646
698
|
if (!NodeRenderer) {
|
|
647
699
|
return null;
|
|
648
700
|
}
|
|
649
|
-
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */
|
|
650
|
-
return /* @__PURE__ */
|
|
701
|
+
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ React16.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
|
|
702
|
+
return /* @__PURE__ */ React16.createElement(NodeRenderer, { node }, children);
|
|
651
703
|
}
|
|
652
704
|
var rendererMap = /* @__PURE__ */ new Map([
|
|
653
705
|
["heading", HeadingRichTextNode],
|
|
@@ -656,12 +708,12 @@ var rendererMap = /* @__PURE__ */ new Map([
|
|
|
656
708
|
["list", ListRichTextNode],
|
|
657
709
|
["listitem", ListItemRichTextNode],
|
|
658
710
|
["paragraph", ParagraphRichTextNode],
|
|
659
|
-
["quote", ({ children }) => /* @__PURE__ */
|
|
711
|
+
["quote", ({ children }) => /* @__PURE__ */ React16.createElement("blockquote", null, children)],
|
|
660
712
|
[
|
|
661
713
|
"code",
|
|
662
|
-
({ children }) => /* @__PURE__ */
|
|
714
|
+
({ children }) => /* @__PURE__ */ React16.createElement("pre", null, /* @__PURE__ */ React16.createElement("code", null, children))
|
|
663
715
|
],
|
|
664
|
-
["root", ({ children }) => /* @__PURE__ */
|
|
716
|
+
["root", ({ children }) => /* @__PURE__ */ React16.createElement(React16.Fragment, null, children)],
|
|
665
717
|
["text", TextRichTextNode],
|
|
666
718
|
["tab", TabRichTextNode]
|
|
667
719
|
]);
|
|
@@ -670,20 +722,20 @@ var resolveRichTextDefaultRenderer = (node) => {
|
|
|
670
722
|
};
|
|
671
723
|
|
|
672
724
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
673
|
-
var UniformRichText =
|
|
725
|
+
var UniformRichText = React17.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
|
|
674
726
|
const { data: componentData } = useUniformCurrentComponent();
|
|
675
|
-
const parameter =
|
|
727
|
+
const parameter = useMemo3(() => {
|
|
676
728
|
var _a;
|
|
677
729
|
return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
|
|
678
730
|
}, [componentData, parameterId]);
|
|
679
|
-
const value =
|
|
731
|
+
const value = useMemo3(() => parameter == null ? void 0 : parameter.value, [parameter]);
|
|
680
732
|
if (!value || !isRichTextValue(value) || isRichTextValueConsideredEmpty(value))
|
|
681
733
|
return null;
|
|
682
|
-
return Tag === null ? /* @__PURE__ */
|
|
734
|
+
return Tag === null ? /* @__PURE__ */ React17.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React17.createElement(Tag, { ref, ...props }, /* @__PURE__ */ React17.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }));
|
|
683
735
|
});
|
|
684
736
|
|
|
685
737
|
// src/components/UniformText.tsx
|
|
686
|
-
import
|
|
738
|
+
import React18, { useCallback, useMemo as useMemo4, useState as useState2 } from "react";
|
|
687
739
|
var UniformText = ({
|
|
688
740
|
as: Tag = "span",
|
|
689
741
|
parameterId,
|
|
@@ -696,7 +748,7 @@ var UniformText = ({
|
|
|
696
748
|
const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
|
|
697
749
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
698
750
|
const [isFocused, setIsFocused] = useState2(false);
|
|
699
|
-
const parameter =
|
|
751
|
+
const parameter = useMemo4(() => {
|
|
700
752
|
var _a2;
|
|
701
753
|
return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
|
|
702
754
|
}, [componentData, parameterId]);
|
|
@@ -710,17 +762,14 @@ var UniformText = ({
|
|
|
710
762
|
setIsFocused(false);
|
|
711
763
|
}, [setIsFocused]);
|
|
712
764
|
if (!parameter) {
|
|
713
|
-
console.warn(
|
|
714
|
-
`UniformText: The parameterId "${parameterId}" was not found in the component of type "${componentData == null ? void 0 : componentData.type}"`
|
|
715
|
-
);
|
|
716
765
|
return null;
|
|
717
766
|
}
|
|
718
767
|
if (!isContextualEditing) {
|
|
719
|
-
return /* @__PURE__ */
|
|
768
|
+
return /* @__PURE__ */ React18.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
|
|
720
769
|
}
|
|
721
770
|
const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
|
|
722
771
|
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
723
|
-
return /* @__PURE__ */
|
|
772
|
+
return /* @__PURE__ */ React18.createElement(
|
|
724
773
|
Tag,
|
|
725
774
|
{
|
|
726
775
|
...props,
|
|
@@ -795,14 +844,14 @@ import {
|
|
|
795
844
|
createCanvasChannel as createCanvasChannel2,
|
|
796
845
|
isUpdateContextualEditingStateInternalMessage
|
|
797
846
|
} from "@uniformdev/canvas";
|
|
798
|
-
import { useEffect as useEffect3, useMemo as
|
|
847
|
+
import { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
|
|
799
848
|
var useUniformContextualEditingState = ({
|
|
800
849
|
global = false
|
|
801
850
|
} = {}) => {
|
|
802
851
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
803
852
|
const { data: componentData } = useUniformCurrentComponent();
|
|
804
853
|
const [selectedComponentReference, setSelectedComponentReference] = useState3();
|
|
805
|
-
const channel =
|
|
854
|
+
const channel = useMemo5(() => {
|
|
806
855
|
if (!isContextualEditing) {
|
|
807
856
|
return;
|
|
808
857
|
}
|
|
@@ -841,6 +890,8 @@ export {
|
|
|
841
890
|
NOT_IMPLEMENTED_COMPONENT,
|
|
842
891
|
UniformComponent,
|
|
843
892
|
UniformComposition,
|
|
893
|
+
UniformCompositionContext,
|
|
894
|
+
UniformPlayground,
|
|
844
895
|
UniformRichText,
|
|
845
896
|
UniformRichTextNode,
|
|
846
897
|
UniformSlot,
|