@uniformdev/canvas-react 19.46.1-alpha.8 → 19.47.1-alpha.11
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/core.d.mts +41 -0
- package/dist/core.d.ts +41 -0
- package/dist/core.js +90 -0
- package/dist/core.mjs +55 -0
- package/dist/index.d.mts +23 -30
- package/dist/index.d.ts +23 -30
- package/dist/index.esm.js +138 -54
- package/dist/index.js +155 -69
- package/dist/index.mjs +138 -54
- package/package.json +31 -10
package/dist/index.esm.js
CHANGED
|
@@ -558,60 +558,110 @@ function resolveChildren({
|
|
|
558
558
|
return renderChildren;
|
|
559
559
|
}
|
|
560
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
|
+
|
|
561
611
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
562
612
|
import {
|
|
563
613
|
isRichTextValue,
|
|
564
614
|
isRichTextValueConsideredEmpty
|
|
565
615
|
} from "@uniformdev/richtext";
|
|
566
|
-
import
|
|
616
|
+
import React17, { useMemo as useMemo3 } from "react";
|
|
567
617
|
|
|
568
618
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
569
619
|
import { isRichTextNode } from "@uniformdev/richtext";
|
|
570
|
-
import
|
|
620
|
+
import React16 from "react";
|
|
571
621
|
|
|
572
622
|
// src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
|
|
573
|
-
import
|
|
623
|
+
import React8 from "react";
|
|
574
624
|
var HeadingRichTextNode = ({ children, node }) => {
|
|
575
625
|
const { tag } = node;
|
|
576
626
|
const HTag = tag != null ? tag : "h1";
|
|
577
|
-
return /* @__PURE__ */
|
|
627
|
+
return /* @__PURE__ */ React8.createElement(HTag, null, children);
|
|
578
628
|
};
|
|
579
629
|
|
|
580
630
|
// src/components/UniformRichText/nodes/LinebreakRichTextNode.tsx
|
|
581
|
-
import
|
|
631
|
+
import React9 from "react";
|
|
582
632
|
var LinebreakRichTextNode = () => {
|
|
583
|
-
return /* @__PURE__ */
|
|
633
|
+
return /* @__PURE__ */ React9.createElement("br", null);
|
|
584
634
|
};
|
|
585
635
|
|
|
586
636
|
// src/components/UniformRichText/nodes/LinkRichTextNode.tsx
|
|
587
637
|
import { linkParamValueToHref } from "@uniformdev/richtext";
|
|
588
|
-
import
|
|
638
|
+
import React10 from "react";
|
|
589
639
|
var LinkRichTextNode = ({ children, node }) => {
|
|
590
640
|
const { link } = node;
|
|
591
|
-
return /* @__PURE__ */
|
|
641
|
+
return /* @__PURE__ */ React10.createElement("a", { href: linkParamValueToHref(link) }, children);
|
|
592
642
|
};
|
|
593
643
|
|
|
594
644
|
// src/components/UniformRichText/nodes/ListItemRichTextNode.tsx
|
|
595
|
-
import
|
|
645
|
+
import React11 from "react";
|
|
596
646
|
var ListItemRichTextNode = ({ children, node }) => {
|
|
597
647
|
const { value } = node;
|
|
598
|
-
return /* @__PURE__ */
|
|
648
|
+
return /* @__PURE__ */ React11.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
|
|
599
649
|
};
|
|
600
650
|
|
|
601
651
|
// src/components/UniformRichText/nodes/ListRichTextNode.tsx
|
|
602
|
-
import
|
|
652
|
+
import React12 from "react";
|
|
603
653
|
var ListRichTextNode = ({ children, node }) => {
|
|
604
654
|
const { tag, start } = node;
|
|
605
655
|
const ListTag = tag != null ? tag : "ul";
|
|
606
|
-
return /* @__PURE__ */
|
|
656
|
+
return /* @__PURE__ */ React12.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
|
|
607
657
|
};
|
|
608
658
|
|
|
609
659
|
// src/components/UniformRichText/nodes/ParagraphRichTextNode.tsx
|
|
610
660
|
import { isPureDirection, isPureTextAlign } from "@uniformdev/richtext";
|
|
611
|
-
import
|
|
661
|
+
import React13 from "react";
|
|
612
662
|
var ParagraphRichTextNode = ({ children, node }) => {
|
|
613
663
|
const { format, direction } = node;
|
|
614
|
-
return /* @__PURE__ */
|
|
664
|
+
return /* @__PURE__ */ React13.createElement(
|
|
615
665
|
"p",
|
|
616
666
|
{
|
|
617
667
|
dir: isPureDirection(direction) ? direction : void 0,
|
|
@@ -622,18 +672,18 @@ var ParagraphRichTextNode = ({ children, node }) => {
|
|
|
622
672
|
};
|
|
623
673
|
|
|
624
674
|
// src/components/UniformRichText/nodes/TabRichTextNode.tsx
|
|
625
|
-
import
|
|
675
|
+
import React14 from "react";
|
|
626
676
|
var TabRichTextNode = () => {
|
|
627
|
-
return /* @__PURE__ */
|
|
677
|
+
return /* @__PURE__ */ React14.createElement(React14.Fragment, null, " ");
|
|
628
678
|
};
|
|
629
679
|
|
|
630
680
|
// src/components/UniformRichText/nodes/TextRichTextNode.tsx
|
|
631
681
|
import { getRichTextTagsFromTextFormat } from "@uniformdev/richtext";
|
|
632
|
-
import
|
|
682
|
+
import React15 from "react";
|
|
633
683
|
var TextRichTextNode = ({ node }) => {
|
|
634
684
|
const { text, format } = node;
|
|
635
685
|
const tags = getRichTextTagsFromTextFormat(format);
|
|
636
|
-
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);
|
|
637
687
|
};
|
|
638
688
|
|
|
639
689
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
@@ -648,8 +698,8 @@ function UniformRichTextNode({ node, ...props }) {
|
|
|
648
698
|
if (!NodeRenderer) {
|
|
649
699
|
return null;
|
|
650
700
|
}
|
|
651
|
-
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */
|
|
652
|
-
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);
|
|
653
703
|
}
|
|
654
704
|
var rendererMap = /* @__PURE__ */ new Map([
|
|
655
705
|
["heading", HeadingRichTextNode],
|
|
@@ -658,12 +708,12 @@ var rendererMap = /* @__PURE__ */ new Map([
|
|
|
658
708
|
["list", ListRichTextNode],
|
|
659
709
|
["listitem", ListItemRichTextNode],
|
|
660
710
|
["paragraph", ParagraphRichTextNode],
|
|
661
|
-
["quote", ({ children }) => /* @__PURE__ */
|
|
711
|
+
["quote", ({ children }) => /* @__PURE__ */ React16.createElement("blockquote", null, children)],
|
|
662
712
|
[
|
|
663
713
|
"code",
|
|
664
|
-
({ children }) => /* @__PURE__ */
|
|
714
|
+
({ children }) => /* @__PURE__ */ React16.createElement("pre", null, /* @__PURE__ */ React16.createElement("code", null, children))
|
|
665
715
|
],
|
|
666
|
-
["root", ({ children }) => /* @__PURE__ */
|
|
716
|
+
["root", ({ children }) => /* @__PURE__ */ React16.createElement(React16.Fragment, null, children)],
|
|
667
717
|
["text", TextRichTextNode],
|
|
668
718
|
["tab", TabRichTextNode]
|
|
669
719
|
]);
|
|
@@ -672,69 +722,101 @@ var resolveRichTextDefaultRenderer = (node) => {
|
|
|
672
722
|
};
|
|
673
723
|
|
|
674
724
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
675
|
-
var UniformRichText =
|
|
725
|
+
var UniformRichText = React17.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
|
|
676
726
|
const { data: componentData } = useUniformCurrentComponent();
|
|
677
|
-
const parameter =
|
|
727
|
+
const parameter = useMemo3(() => {
|
|
678
728
|
var _a;
|
|
679
729
|
return (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
|
|
680
730
|
}, [componentData, parameterId]);
|
|
681
|
-
const value =
|
|
731
|
+
const value = useMemo3(() => parameter == null ? void 0 : parameter.value, [parameter]);
|
|
682
732
|
if (!value || !isRichTextValue(value) || isRichTextValueConsideredEmpty(value))
|
|
683
733
|
return null;
|
|
684
|
-
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 }));
|
|
685
735
|
});
|
|
686
736
|
|
|
687
737
|
// src/components/UniformText.tsx
|
|
688
|
-
import
|
|
689
|
-
|
|
738
|
+
import React19, { useState as useState2 } from "react";
|
|
739
|
+
|
|
740
|
+
// src/components/PureUniformText.tsx
|
|
741
|
+
import React18 from "react";
|
|
742
|
+
var PureUniformText = ({
|
|
690
743
|
as: Tag = "span",
|
|
691
744
|
parameterId,
|
|
745
|
+
component,
|
|
746
|
+
skipCustomRendering,
|
|
747
|
+
isContextualEditing,
|
|
692
748
|
isMultiline = false,
|
|
693
749
|
placeholder,
|
|
694
750
|
render = (value) => value,
|
|
695
751
|
...props
|
|
696
752
|
}) => {
|
|
697
|
-
var _a
|
|
698
|
-
const
|
|
699
|
-
const { isContextualEditing } = useUniformCurrentComposition();
|
|
700
|
-
const [isFocused, setIsFocused] = useState2(false);
|
|
701
|
-
const parameter = useMemo3(() => {
|
|
702
|
-
var _a2;
|
|
703
|
-
return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[parameterId];
|
|
704
|
-
}, [componentData, parameterId]);
|
|
753
|
+
var _a;
|
|
754
|
+
const parameter = (_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[parameterId];
|
|
705
755
|
const value = parameter == null ? void 0 : parameter.value;
|
|
706
|
-
const isEditable = (_b = (_a = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _a.isEditable) != null ? _b : false;
|
|
707
|
-
const shouldSkipCustomRendering = isFocused && isEditable;
|
|
708
|
-
const handleOnFocus = useCallback(() => {
|
|
709
|
-
setIsFocused(true);
|
|
710
|
-
}, [setIsFocused]);
|
|
711
|
-
const handleOnBlur = useCallback(() => {
|
|
712
|
-
setIsFocused(false);
|
|
713
|
-
}, [setIsFocused]);
|
|
714
756
|
if (!parameter) {
|
|
715
757
|
return null;
|
|
716
758
|
}
|
|
717
759
|
if (!isContextualEditing) {
|
|
718
|
-
return /* @__PURE__ */
|
|
760
|
+
return /* @__PURE__ */ React18.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
|
|
719
761
|
}
|
|
720
|
-
const
|
|
721
|
-
|
|
722
|
-
return /* @__PURE__ */ React17.createElement(
|
|
762
|
+
const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
|
|
763
|
+
return /* @__PURE__ */ React18.createElement(
|
|
723
764
|
Tag,
|
|
724
765
|
{
|
|
725
766
|
...props,
|
|
726
767
|
...getParameterAttributes({
|
|
727
|
-
component
|
|
768
|
+
component,
|
|
728
769
|
id: parameterId,
|
|
729
770
|
isMultiline
|
|
730
771
|
}),
|
|
731
772
|
"data-uniform-parameter-type": "text",
|
|
732
773
|
"data-uniform-placeholder": computedPlaceholder,
|
|
733
|
-
style: isMultiline ? { whiteSpace: "pre-wrap" } : {}
|
|
734
|
-
onFocus: handleOnFocus,
|
|
735
|
-
onBlur: handleOnBlur
|
|
774
|
+
style: isMultiline ? { whiteSpace: "pre-wrap" } : {}
|
|
736
775
|
},
|
|
737
|
-
|
|
776
|
+
skipCustomRendering ? value : render(value)
|
|
777
|
+
);
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
// src/components/UniformText.tsx
|
|
781
|
+
var UniformText = ({
|
|
782
|
+
as: tag = "span",
|
|
783
|
+
parameterId,
|
|
784
|
+
isMultiline = false,
|
|
785
|
+
placeholder,
|
|
786
|
+
render = (value) => value,
|
|
787
|
+
...props
|
|
788
|
+
}) => {
|
|
789
|
+
var _a, _b, _c;
|
|
790
|
+
const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
|
|
791
|
+
const { isContextualEditing } = useUniformCurrentComposition();
|
|
792
|
+
const [isFocused, setIsFocused] = useState2(false);
|
|
793
|
+
const parameter = (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
|
|
794
|
+
const isEditable = (_c = (_b = parameter == null ? void 0 : parameter._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
|
|
795
|
+
const shouldSkipCustomRendering = isFocused && isEditable;
|
|
796
|
+
if (!parameter) {
|
|
797
|
+
return null;
|
|
798
|
+
}
|
|
799
|
+
const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
|
|
800
|
+
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
801
|
+
return /* @__PURE__ */ React19.createElement(
|
|
802
|
+
PureUniformText,
|
|
803
|
+
{
|
|
804
|
+
...props,
|
|
805
|
+
as: tag,
|
|
806
|
+
parameterId,
|
|
807
|
+
component: componentData,
|
|
808
|
+
skipCustomRendering: shouldSkipCustomRendering,
|
|
809
|
+
isContextualEditing,
|
|
810
|
+
placeholder: computedPlaceholder,
|
|
811
|
+
render,
|
|
812
|
+
isMultiline,
|
|
813
|
+
onFocus: () => {
|
|
814
|
+
setIsFocused(true);
|
|
815
|
+
},
|
|
816
|
+
onBlur: () => {
|
|
817
|
+
setIsFocused(false);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
738
820
|
);
|
|
739
821
|
};
|
|
740
822
|
|
|
@@ -840,6 +922,8 @@ export {
|
|
|
840
922
|
NOT_IMPLEMENTED_COMPONENT,
|
|
841
923
|
UniformComponent,
|
|
842
924
|
UniformComposition,
|
|
925
|
+
UniformCompositionContext,
|
|
926
|
+
UniformPlayground,
|
|
843
927
|
UniformRichText,
|
|
844
928
|
UniformRichTextNode,
|
|
845
929
|
UniformSlot,
|