@plasmicapp/react-web 0.2.396 → 0.2.398
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/all.d.ts +344 -184
- package/dist/index-common.d.ts +4 -3
- package/dist/index.cjs.js +1061 -898
- package/dist/index.cjs.js.map +1 -1
- package/dist/react-web.esm.js +1059 -899
- package/dist/react-web.esm.js.map +1 -1
- package/dist/render/elements.d.ts +1 -1
- package/dist/render/global-variants.d.ts +49 -1
- package/dist/render/style-tokens.d.ts +114 -0
- package/package.json +9 -9
- package/skinny/dist/index-common.d.ts +4 -3
- package/skinny/dist/index.js +256 -96
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/render/elements.d.ts +1 -1
- package/skinny/dist/render/global-variants.d.ts +49 -1
- package/skinny/dist/render/style-tokens.d.ts +114 -0
package/dist/index.cjs.js
CHANGED
|
@@ -5,8 +5,8 @@ var classNames$1 = require('classnames');
|
|
|
5
5
|
var dataSourcesContext = require('@plasmicapp/data-sources-context');
|
|
6
6
|
var plasmicQuery = require('@plasmicapp/query');
|
|
7
7
|
var React = require('react');
|
|
8
|
-
var get = require('dlv');
|
|
9
8
|
var host = require('@plasmicapp/host');
|
|
9
|
+
var get = require('dlv');
|
|
10
10
|
var ReactDOM = require('react-dom');
|
|
11
11
|
var ssr = require('@react-aria/ssr');
|
|
12
12
|
var focus = require('@react-aria/focus');
|
|
@@ -461,6 +461,88 @@ function mapValues(obj, mapper) {
|
|
|
461
461
|
return result;
|
|
462
462
|
}
|
|
463
463
|
|
|
464
|
+
var PlasmicHeadContext = React__namespace.createContext(undefined);
|
|
465
|
+
function PlasmicHead(props) {
|
|
466
|
+
var Head = React__namespace.useContext(PlasmicHeadContext);
|
|
467
|
+
var headMetadata =
|
|
468
|
+
// Check if `HeadMetadataContext` is exported for backward compatibility
|
|
469
|
+
"HeadMetadataContext" in plasmicQuery__namespace
|
|
470
|
+
? React__namespace.useContext(plasmicQuery__namespace.HeadMetadataContext)
|
|
471
|
+
: undefined;
|
|
472
|
+
if (headMetadata) {
|
|
473
|
+
// If we have the Head metadata object specified, mutate it so to ensure it
|
|
474
|
+
// stores the data that should go in the <head>.
|
|
475
|
+
if (props.image) {
|
|
476
|
+
headMetadata.image = props.image;
|
|
477
|
+
}
|
|
478
|
+
if (props.title) {
|
|
479
|
+
headMetadata.title = props.title;
|
|
480
|
+
}
|
|
481
|
+
if (props.description) {
|
|
482
|
+
headMetadata.description = props.description;
|
|
483
|
+
}
|
|
484
|
+
if (props.canonical) {
|
|
485
|
+
headMetadata.canonical = props.canonical;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
if (!Head) {
|
|
489
|
+
console.warn("Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider.");
|
|
490
|
+
// TODO: Link to doc about Head.
|
|
491
|
+
return null;
|
|
492
|
+
}
|
|
493
|
+
// Helmet does not support React.Fragments, so we need to use `[<meta />,
|
|
494
|
+
// <meta />]` instead of `<><meta /><meta /></>`.
|
|
495
|
+
return (React__namespace.createElement(Head, null,
|
|
496
|
+
props.image ? ([
|
|
497
|
+
React__namespace.createElement("meta", { key: "twitter:card", name: "twitter:card", content: "summary_large_image" }),
|
|
498
|
+
React__namespace.createElement("meta", { key: "og:image", property: "og:image", content: props.image }),
|
|
499
|
+
React__namespace.createElement("meta", { key: "twitter:image", name: "twitter:image", content: props.image }),
|
|
500
|
+
]) : (React__namespace.createElement("meta", { key: "twitter:card", name: "twitter:card", content: "summary" })),
|
|
501
|
+
props.title && [
|
|
502
|
+
React__namespace.createElement("title", { key: "title" }, props.title),
|
|
503
|
+
React__namespace.createElement("meta", { key: "og:title", property: "og:title", content: props.title }),
|
|
504
|
+
React__namespace.createElement("meta", { key: "twitter:title", property: "twitter:title", content: props.title }),
|
|
505
|
+
],
|
|
506
|
+
props.description && [
|
|
507
|
+
React__namespace.createElement("meta", { key: "description", name: "description", content: props.description }),
|
|
508
|
+
React__namespace.createElement("meta", { key: "og:description", property: "og:description", content: props.description }),
|
|
509
|
+
React__namespace.createElement("meta", { key: "twitter:description", name: "twitter:description", content: props.description }),
|
|
510
|
+
],
|
|
511
|
+
props.canonical && (React__namespace.createElement("link", { key: "canonical", rel: "canonical", href: props.canonical }))));
|
|
512
|
+
}
|
|
513
|
+
var plasmicHeadMeta = {
|
|
514
|
+
name: "hostless-plasmic-head",
|
|
515
|
+
displayName: "Page Metadata Override",
|
|
516
|
+
description: "Set page metadata (HTML <head />) to dynamic values.",
|
|
517
|
+
importName: "PlasmicHead",
|
|
518
|
+
importPath: "@plasmicapp/react-web",
|
|
519
|
+
isRepeatable: false,
|
|
520
|
+
styleSections: false,
|
|
521
|
+
props: {
|
|
522
|
+
title: {
|
|
523
|
+
type: "string",
|
|
524
|
+
displayName: "Title",
|
|
525
|
+
},
|
|
526
|
+
description: {
|
|
527
|
+
type: "string",
|
|
528
|
+
displayName: "Description",
|
|
529
|
+
},
|
|
530
|
+
image: {
|
|
531
|
+
type: "imageUrl",
|
|
532
|
+
displayName: "Image",
|
|
533
|
+
},
|
|
534
|
+
canonical: {
|
|
535
|
+
type: "string",
|
|
536
|
+
displayName: "Canonical URL",
|
|
537
|
+
},
|
|
538
|
+
},
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
function PlasmicIcon(props) {
|
|
542
|
+
var PlasmicIconType = props.PlasmicIconType, rest = __rest(props, ["PlasmicIconType"]);
|
|
543
|
+
return React__namespace.createElement(PlasmicIconType, __assign({}, rest));
|
|
544
|
+
}
|
|
545
|
+
|
|
464
546
|
var isBrowser = typeof window !== "undefined";
|
|
465
547
|
var NONE = Symbol("NONE");
|
|
466
548
|
var useIsomorphicLayoutEffect$1 = isBrowser
|
|
@@ -656,989 +738,958 @@ function getElementTypeName(element) {
|
|
|
656
738
|
}
|
|
657
739
|
}
|
|
658
740
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
var
|
|
669
|
-
var
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
741
|
+
/**
|
|
742
|
+
* Responsive `<img/>` replacement, based on `next/image`
|
|
743
|
+
*/
|
|
744
|
+
var IMG_OPTIMIZER_HOST = "https://img.plasmic.app";
|
|
745
|
+
// Default image sizes to snap to
|
|
746
|
+
// TODO: make this configurable?
|
|
747
|
+
var IMG_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];
|
|
748
|
+
var DEVICE_SIZES = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];
|
|
749
|
+
var ALL_SIZES = __spreadArray(__spreadArray([], __read(IMG_SIZES), false), __read(DEVICE_SIZES), false);
|
|
750
|
+
var PlasmicImg = React.forwardRef(function PlasmicImg(props, outerRef) {
|
|
751
|
+
var src = props.src, className = props.className, displayWidth = props.displayWidth, displayHeight = props.displayHeight, displayMinWidth = props.displayMinWidth, displayMinHeight = props.displayMinHeight, displayMaxWidth = props.displayMaxWidth, displayMaxHeight = props.displayMaxHeight, quality = props.quality, loader = props.loader, imgRef = props.imgRef, style = props.style, loading = props.loading, rest = __rest(props, ["src", "className", "displayWidth", "displayHeight", "displayMinWidth", "displayMinHeight", "displayMaxWidth", "displayMaxHeight", "quality", "loader", "imgRef", "style", "loading"]);
|
|
752
|
+
var imgProps = Object.assign({}, rest, {
|
|
753
|
+
// Default loading to "lazy" if not specified (which is different from the
|
|
754
|
+
// html img, which defaults to eager!)
|
|
755
|
+
loading: loading !== null && loading !== void 0 ? loading : "lazy",
|
|
673
756
|
});
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
main: makeStackImpl("main"),
|
|
690
|
-
nav: makeStackImpl("nav"),
|
|
691
|
-
});
|
|
692
|
-
|
|
693
|
-
function hasVariant(variants, groupName, variant) {
|
|
694
|
-
if (variants == null) {
|
|
695
|
-
return false;
|
|
696
|
-
}
|
|
697
|
-
var groupVariants = variants[groupName];
|
|
698
|
-
if (groupVariants == null) {
|
|
699
|
-
return false;
|
|
757
|
+
var _a = !src
|
|
758
|
+
? { fullWidth: undefined, fullHeight: undefined, aspectRatio: undefined }
|
|
759
|
+
: typeof src === "string"
|
|
760
|
+
? getImageSizeData(getPixelLength(props.width), getPixelLength(props.height))
|
|
761
|
+
: src, fullWidth = _a.fullWidth, fullHeight = _a.fullHeight, aspectRatio = _a.aspectRatio;
|
|
762
|
+
var srcStr = src
|
|
763
|
+
? typeof src === "string"
|
|
764
|
+
? src
|
|
765
|
+
: typeof src.src === "string"
|
|
766
|
+
? src.src
|
|
767
|
+
: src.src.src
|
|
768
|
+
: "";
|
|
769
|
+
// Assume external image if either dimension is null and use usual <img>
|
|
770
|
+
if (fullHeight == null || fullWidth == null) {
|
|
771
|
+
return (React.createElement("img", __assign({ src: srcStr, className: className, style: style }, imgProps, { loading: loading, ref: mergeRefs(imgRef, outerRef) })));
|
|
700
772
|
}
|
|
701
|
-
|
|
702
|
-
|
|
773
|
+
if (isSvg(srcStr) &&
|
|
774
|
+
(displayHeight == null || displayHeight === "auto") &&
|
|
775
|
+
(displayWidth == null || displayWidth === "auto")) {
|
|
776
|
+
displayWidth = "100%";
|
|
703
777
|
}
|
|
704
|
-
|
|
705
|
-
|
|
778
|
+
var computedDisplayWidth = displayWidth;
|
|
779
|
+
if (fullWidth &&
|
|
780
|
+
fullHeight &&
|
|
781
|
+
(!displayWidth || displayWidth === "auto") &&
|
|
782
|
+
!!getPixelLength(displayHeight)) {
|
|
783
|
+
// If there's a pixel length specified for displayHeight but not displayWidth,
|
|
784
|
+
// then we can derive the pixel length for displayWidth. Having an explicit
|
|
785
|
+
// displayWidth makes this a fixed-size image, which makes it possible for us to
|
|
786
|
+
// generate better markup!
|
|
787
|
+
if (!isSvg(srcStr)) {
|
|
788
|
+
// We shouldn't do it for SVGs though, because `fullWidth` and
|
|
789
|
+
// `fullHeight` might have rounded values so the final
|
|
790
|
+
// `displayWidth` could differ by 1px or so.
|
|
791
|
+
computedDisplayWidth =
|
|
792
|
+
(getPixelLength(displayHeight) * fullWidth) / fullHeight;
|
|
793
|
+
}
|
|
706
794
|
}
|
|
707
|
-
|
|
708
|
-
|
|
795
|
+
var spacerWidth = fullWidth;
|
|
796
|
+
var spacerHeight = fullHeight;
|
|
797
|
+
if (aspectRatio && isFinite(aspectRatio) && isSvg(srcStr)) {
|
|
798
|
+
// For SVGs, fullWidth and fullHeight can be rounded values, which would
|
|
799
|
+
// cause some discrepancy between the actual aspect ratio and the aspect
|
|
800
|
+
// ratio from those values. So, for those cases, we set large width / height
|
|
801
|
+
// values to get a more precise ratio from the spacer.
|
|
802
|
+
spacerWidth = DEFAULT_SVG_WIDTH;
|
|
803
|
+
spacerHeight = Math.round(spacerWidth / aspectRatio);
|
|
709
804
|
}
|
|
710
|
-
|
|
711
|
-
|
|
805
|
+
var _b = getWidths(computedDisplayWidth, fullWidth, {
|
|
806
|
+
minWidth: displayMinWidth,
|
|
807
|
+
}), sizes = _b.sizes, widthDescs = _b.widthDescs;
|
|
808
|
+
var imageLoader = getImageLoader(loader);
|
|
809
|
+
var spacerSvg = "<svg width=\"".concat(spacerWidth, "\" height=\"").concat(spacerHeight, "\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"/>");
|
|
810
|
+
var spacerSvgBase64 =
|
|
811
|
+
// if btoa exists, use btoa, as it works in browser and in
|
|
812
|
+
// cloudflare edge workers. For node, use Buffer.from().
|
|
813
|
+
typeof globalThis.btoa === "function"
|
|
814
|
+
? globalThis.btoa(spacerSvg)
|
|
815
|
+
: Buffer.from(spacerSvg).toString("base64");
|
|
816
|
+
var wrapperStyle = __assign({}, (style || {}));
|
|
817
|
+
var spacerStyle = __assign({}, pick(style || {}, "objectFit", "objectPosition"));
|
|
818
|
+
if (displayWidth != null && displayWidth !== "auto") {
|
|
819
|
+
// If width is set, set it on the wrapper along with min/max width
|
|
820
|
+
// and just use `width: 100%` on the spacer
|
|
821
|
+
spacerStyle.width = "100%";
|
|
822
|
+
// Rely on the styles set by `classname` on the wrapper:
|
|
823
|
+
// wrapperStyle.width = displayWidth;
|
|
824
|
+
// wrapperStyle.minWidth = displayMinWidth;
|
|
825
|
+
// wrapperStyle.maxWidth = displayMaxWidth;
|
|
712
826
|
}
|
|
713
827
|
else {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
828
|
+
// Otherwise, we want auto sizing from the spacer, so set width there.
|
|
829
|
+
//
|
|
830
|
+
// But if we have min/max width, it should be set in the wrapper and it
|
|
831
|
+
// can be percentage values (and we add corresponding min/max width to
|
|
832
|
+
// 100% in the spacer). In general it ends up with the correct effect,
|
|
833
|
+
// but some edge cases might make `min-width: 100%` shrink the image more
|
|
834
|
+
// than it should.
|
|
835
|
+
spacerStyle.width = displayWidth;
|
|
836
|
+
wrapperStyle.width = "auto";
|
|
837
|
+
if (displayMinWidth) {
|
|
838
|
+
spacerStyle.minWidth = "100%";
|
|
839
|
+
// Rely on min-width set by `classname` on the wrapper:
|
|
840
|
+
// wrapperStyle.minWidth = displayMinWidth;
|
|
841
|
+
}
|
|
842
|
+
if (displayMaxWidth != null && displayMaxWidth !== "none") {
|
|
843
|
+
spacerStyle.maxWidth = "100%";
|
|
844
|
+
// Rely on max-width set by `classname` on the wrapper:
|
|
845
|
+
// wrapperStyle.maxWidth = displayMaxWidth;
|
|
846
|
+
}
|
|
725
847
|
}
|
|
726
|
-
|
|
727
|
-
|
|
848
|
+
if (displayHeight != null && displayHeight !== "auto") {
|
|
849
|
+
spacerStyle.height = "100%";
|
|
850
|
+
// wrapperStyle.height = displayHeight;
|
|
851
|
+
// wrapperStyle.minHeight = displayMinHeight;
|
|
852
|
+
// wrapperStyle.maxHeight = displayMaxHeight;
|
|
728
853
|
}
|
|
729
854
|
else {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
(typeof override === "object" && Object.keys(override).length === 0)) {
|
|
736
|
-
return createElementWithChildren(defaultRoot, defaultProps, defaultProps.children);
|
|
737
|
-
}
|
|
738
|
-
var override2 = deriveOverride(override);
|
|
739
|
-
var props = mergeOverrideProps(defaultProps, override2.props);
|
|
740
|
-
if (override2.type === "render") {
|
|
741
|
-
return override2.render(props, defaultRoot);
|
|
742
|
-
}
|
|
743
|
-
var root = defaultRoot;
|
|
744
|
-
if (override2.type === "as" && override2.as) {
|
|
745
|
-
if (defaultRoot === Stack) {
|
|
746
|
-
// If there was an "as" override specified, but the default type is
|
|
747
|
-
// a Stack, then we don't want to switch to using "as" as the root,
|
|
748
|
-
// because then we'd lose the flex wrapper that Stack provides.
|
|
749
|
-
// Instead, we specify the "as" as the "as" prop to Stack.
|
|
750
|
-
props.as = override2.as;
|
|
855
|
+
spacerStyle.height = displayHeight;
|
|
856
|
+
wrapperStyle.height = "auto";
|
|
857
|
+
if (displayMinHeight) {
|
|
858
|
+
spacerStyle.minHeight = "100%";
|
|
859
|
+
// wrapperStyle.minHeight = displayMinHeight;
|
|
751
860
|
}
|
|
752
|
-
|
|
753
|
-
|
|
861
|
+
if (displayMaxHeight != null && displayMaxHeight !== "none") {
|
|
862
|
+
spacerStyle.maxHeight = "100%";
|
|
863
|
+
// wrapperStyle.maxHeight = displayMaxHeight;
|
|
754
864
|
}
|
|
755
865
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
866
|
+
return (React.createElement("div", { className: classNames$1(className, "__wab_img-wrapper"), ref: outerRef, style: wrapperStyle },
|
|
867
|
+
React.createElement("img", { alt: "", "aria-hidden": true, className: "__wab_img-spacer-svg", src: "data:image/svg+xml;base64,".concat(spacerSvgBase64), style: spacerStyle }),
|
|
868
|
+
makePicture({
|
|
869
|
+
imageLoader: imageLoader,
|
|
870
|
+
widthDescs: widthDescs,
|
|
871
|
+
sizes: sizes,
|
|
872
|
+
src: srcStr,
|
|
873
|
+
quality: quality,
|
|
874
|
+
ref: imgRef,
|
|
875
|
+
style: style ? pick(style, "objectFit", "objectPosition") : undefined,
|
|
876
|
+
imgProps: imgProps,
|
|
877
|
+
className: "__wab_img",
|
|
878
|
+
})));
|
|
879
|
+
});
|
|
880
|
+
function makePicture(opts) {
|
|
881
|
+
// If imageLoader is undefined, then this renders to just a normal
|
|
882
|
+
// <img />. Else it will render to a <picture> with a <source> for
|
|
883
|
+
// webp, and srcSet/sizes set according to width requirements.
|
|
884
|
+
var imageLoader = opts.imageLoader, widthDescs = opts.widthDescs, src = opts.src, quality = opts.quality, style = opts.style, className = opts.className, sizes = opts.sizes, imgProps = opts.imgProps, ref = opts.ref;
|
|
885
|
+
return (React.createElement("picture", { className: "__wab_picture" },
|
|
886
|
+
imageLoader && imageLoader.supportsUrl(src) && (React.createElement("source", { type: "image/webp", srcSet: widthDescs
|
|
887
|
+
.map(function (wd) {
|
|
888
|
+
return "".concat(imageLoader.transformUrl({
|
|
889
|
+
src: src,
|
|
890
|
+
quality: quality,
|
|
891
|
+
width: wd.width,
|
|
892
|
+
format: "webp",
|
|
893
|
+
}), " ").concat(wd.desc);
|
|
894
|
+
})
|
|
895
|
+
.join(", ") })),
|
|
896
|
+
React.createElement("img", __assign({}, imgProps, { ref: ref, className: className, decoding: "async", src: imageLoader && imageLoader.supportsUrl(src)
|
|
897
|
+
? imageLoader.transformUrl({
|
|
898
|
+
src: src,
|
|
899
|
+
quality: quality,
|
|
900
|
+
width: widthDescs[widthDescs.length - 1].width,
|
|
901
|
+
})
|
|
902
|
+
: src, srcSet: imageLoader && imageLoader.supportsUrl(src)
|
|
903
|
+
? widthDescs
|
|
904
|
+
.map(function (wd) {
|
|
905
|
+
return "".concat(imageLoader.transformUrl({
|
|
906
|
+
src: src,
|
|
907
|
+
quality: quality,
|
|
908
|
+
width: wd.width,
|
|
909
|
+
}), " ").concat(wd.desc);
|
|
910
|
+
})
|
|
911
|
+
.join(", ")
|
|
912
|
+
: undefined, sizes: imageLoader && imageLoader.supportsUrl(src) ? sizes : undefined, style: __assign(__assign({}, (style ? pick(style, "objectFit", "objectPosition") : {})), { width: 0, height: 0 }) }))));
|
|
769
913
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
function
|
|
775
|
-
// We use seenElements to keep track of elements that has been rendered by
|
|
776
|
-
// createPlasmicElementProxy(). When a JSX tree is evaluated, the JSX factory
|
|
777
|
-
// is invoked from the leaf to the root as the last call. So we can store
|
|
778
|
-
// all the elements we've created until we encounter the leaf, at which point
|
|
779
|
-
// we will clear this map. We are guaranteed that this map will only contain
|
|
780
|
-
// elements from one Plasmic* component at a time, because we're just creating
|
|
781
|
-
// elements and not "rendering" at this point; even if this JSX tree references
|
|
782
|
-
// other Plasmic* elements, we'll just create an element referencing that component,
|
|
783
|
-
// rather than following into the content of that component.
|
|
784
|
-
//
|
|
785
|
-
// TODO: is this ConcurrentMode friendly?
|
|
914
|
+
var DEFAULT_SVG_WIDTH = 10000;
|
|
915
|
+
function isSvg(src) {
|
|
916
|
+
return src.endsWith(".svg") || src.startsWith("data:image/svg");
|
|
917
|
+
}
|
|
918
|
+
function getClosestPresetSize(width, fullWidth) {
|
|
786
919
|
var _a;
|
|
787
|
-
var
|
|
788
|
-
|
|
789
|
-
|
|
920
|
+
var nextBiggerIndex = (_a = ALL_SIZES.findIndex(function (w) { return w >= width; })) !== null && _a !== void 0 ? _a : ALL_SIZES.length - 1;
|
|
921
|
+
var nextBigger = ALL_SIZES[nextBiggerIndex];
|
|
922
|
+
if (nextBigger >= fullWidth) {
|
|
923
|
+
// If the requested width is larger than the fullWidth,
|
|
924
|
+
// we just use the original width instead. It's impossible
|
|
925
|
+
// to make an image bigger than fullWidth!
|
|
926
|
+
return undefined;
|
|
790
927
|
}
|
|
791
|
-
if (
|
|
792
|
-
|
|
928
|
+
else if (nextBiggerIndex + 1 < ALL_SIZES.length &&
|
|
929
|
+
fullWidth <= ALL_SIZES[nextBiggerIndex + 1]) {
|
|
930
|
+
// If the fullWidth is just between nextBigger and the one after that,
|
|
931
|
+
// then also might as well just use the original size (so, width is 30,
|
|
932
|
+
// nextBigger is 32, then we just use the original as long as fullWidth is
|
|
933
|
+
// less than 48)
|
|
934
|
+
return undefined;
|
|
793
935
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
var
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
936
|
+
return nextBigger;
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Computes the appropriate srcSet and sizes to use
|
|
940
|
+
*/
|
|
941
|
+
function getWidths(width, fullWidth, extra) {
|
|
942
|
+
var minWidth = extra === null || extra === void 0 ? void 0 : extra.minWidth;
|
|
943
|
+
var pixelWidth = getPixelLength(width);
|
|
944
|
+
var pixelMinWidth = getPixelLength(minWidth);
|
|
945
|
+
if (pixelWidth != null && (!minWidth || pixelMinWidth != null)) {
|
|
946
|
+
// If there's an exact width, then we just need to display it at 1x and 2x density
|
|
947
|
+
return {
|
|
948
|
+
widthDescs: [
|
|
949
|
+
{
|
|
950
|
+
width: getClosestPresetSize(Math.max(pixelWidth, pixelMinWidth !== null && pixelMinWidth !== void 0 ? pixelMinWidth : 0), fullWidth),
|
|
951
|
+
desc: "1x",
|
|
952
|
+
},
|
|
953
|
+
{
|
|
954
|
+
width: getClosestPresetSize(Math.max(pixelWidth, pixelMinWidth !== null && pixelMinWidth !== void 0 ? pixelMinWidth : 0) * 2, fullWidth),
|
|
955
|
+
desc: "2x",
|
|
956
|
+
},
|
|
957
|
+
],
|
|
958
|
+
sizes: undefined,
|
|
959
|
+
};
|
|
804
960
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
961
|
+
// Otherwise we don't know what sizes we'll end up, so we just cap it at
|
|
962
|
+
// device width. TODO: do better!
|
|
963
|
+
var usefulSizes = DEVICE_SIZES.filter(function (size) { return !fullWidth || size < fullWidth; });
|
|
964
|
+
if (!!fullWidth && usefulSizes.length === 0) {
|
|
965
|
+
// image fullWidth is smaller than all device sizes. So all we can do
|
|
966
|
+
// is offer 1x
|
|
967
|
+
return {
|
|
968
|
+
widthDescs: [
|
|
969
|
+
{
|
|
970
|
+
width: getClosestPresetSize(fullWidth, fullWidth),
|
|
971
|
+
desc: "1x",
|
|
972
|
+
},
|
|
973
|
+
],
|
|
974
|
+
sizes: undefined,
|
|
975
|
+
};
|
|
814
976
|
}
|
|
815
|
-
return
|
|
977
|
+
return {
|
|
978
|
+
widthDescs: usefulSizes.map(function (size) { return ({
|
|
979
|
+
width: getClosestPresetSize(size, fullWidth),
|
|
980
|
+
// If this is the last (buggest) useful width, but it is
|
|
981
|
+
// still within the bounds set by DEVICE_SIZES, then just
|
|
982
|
+
// use the original, unresized image. This means if we match
|
|
983
|
+
// the largest size, we use unresized and best quality image.
|
|
984
|
+
// We only do this, though, if fullWidth is "reasonable" --
|
|
985
|
+
// smaller than the largest size we would consider.
|
|
986
|
+
// i === usefulSizes.length - 1 &&
|
|
987
|
+
// fullWidth < DEVICE_SIZES[DEVICE_SIZES.length - 1]
|
|
988
|
+
// ? undefined
|
|
989
|
+
// : size,
|
|
990
|
+
desc: "".concat(size, "w"),
|
|
991
|
+
}); }),
|
|
992
|
+
sizes: "100vw",
|
|
993
|
+
};
|
|
816
994
|
}
|
|
817
|
-
function
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
821
|
-
children[_i - 2] = arguments[_i];
|
|
995
|
+
function getPixelLength(length) {
|
|
996
|
+
if (length == null || length == "") {
|
|
997
|
+
return undefined;
|
|
822
998
|
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
? {}
|
|
832
|
-
: { children: children.length === 1 ? children[0] : children }], __read(triggerProps), false)), wrapFlexChild);
|
|
999
|
+
if (typeof length === "number") {
|
|
1000
|
+
return length;
|
|
1001
|
+
}
|
|
1002
|
+
var parsed = parseNumeric(length);
|
|
1003
|
+
if (parsed && (!parsed.units || parsed.units === "px")) {
|
|
1004
|
+
return parsed.num;
|
|
1005
|
+
}
|
|
1006
|
+
return undefined;
|
|
833
1007
|
}
|
|
834
|
-
function
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
1008
|
+
function parseNumeric(val) {
|
|
1009
|
+
// Parse strings like "30", "30px", "30%", "30px /* blah blah */"
|
|
1010
|
+
var res = val.match(/^\s*(-?(?:\d+\.\d*|\d*\.\d+|\d+))\s*([a-z]*|%)\s*(?:\/\*.*)?$/i);
|
|
1011
|
+
if (res == null) {
|
|
1012
|
+
return undefined;
|
|
838
1013
|
}
|
|
839
|
-
|
|
1014
|
+
var num = res[1];
|
|
1015
|
+
var units = res[2];
|
|
1016
|
+
return { num: +num, units: units };
|
|
840
1017
|
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
1018
|
+
function getImageSizeData(width, height) {
|
|
1019
|
+
var aspectRatio = width && height ? width / height : undefined;
|
|
1020
|
+
return {
|
|
1021
|
+
fullWidth: width,
|
|
1022
|
+
fullHeight: height,
|
|
1023
|
+
aspectRatio: aspectRatio && isFinite(aspectRatio) ? aspectRatio : undefined,
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
function getImageLoader(loader) {
|
|
1027
|
+
if (loader == null) {
|
|
1028
|
+
return undefined;
|
|
846
1029
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
for (var _b = __values(Object.keys(overrides)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
850
|
-
var key = _c.value;
|
|
851
|
-
var defaultVal = defaults[key];
|
|
852
|
-
var overrideVal = overrides[key];
|
|
853
|
-
if (overrideVal === UNSET) {
|
|
854
|
-
delete result[key];
|
|
855
|
-
}
|
|
856
|
-
else {
|
|
857
|
-
// We use the NONE sentinel if the overrideVal is nil, and is not one of the
|
|
858
|
-
// props that we merge by default -- which are className, style, and
|
|
859
|
-
// event handlers. This means for all other "normal" props -- like children,
|
|
860
|
-
// title, etc -- a nil value will unset the default.
|
|
861
|
-
if (overrideVal == null &&
|
|
862
|
-
key !== "className" &&
|
|
863
|
-
key !== "style" &&
|
|
864
|
-
!(key.startsWith("on") && typeof defaultVal === "function")) {
|
|
865
|
-
overrideVal = NONE;
|
|
866
|
-
}
|
|
867
|
-
result[key] = mergePropVals(key, defaultVal, overrideVal);
|
|
868
|
-
}
|
|
869
|
-
}
|
|
1030
|
+
else if (loader === "plasmic") {
|
|
1031
|
+
return PLASMIC_IMAGE_LOADER;
|
|
870
1032
|
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
try {
|
|
874
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
875
|
-
}
|
|
876
|
-
finally { if (e_1) throw e_1.error; }
|
|
1033
|
+
else {
|
|
1034
|
+
return loader;
|
|
877
1035
|
}
|
|
878
|
-
return result;
|
|
879
1036
|
}
|
|
880
|
-
function
|
|
881
|
-
|
|
882
|
-
? element.key || undefined
|
|
883
|
-
: undefined;
|
|
884
|
-
return React__namespace.createElement("div", {
|
|
885
|
-
key: key,
|
|
886
|
-
className: className,
|
|
887
|
-
style: {
|
|
888
|
-
display: "grid",
|
|
889
|
-
},
|
|
890
|
-
}, element);
|
|
1037
|
+
function isInternalKey(src) {
|
|
1038
|
+
return /^([a-f0-9]{32})\..{1,16}$/i.test(src);
|
|
891
1039
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
1040
|
+
var PLASMIC_IMAGE_LOADER = {
|
|
1041
|
+
supportsUrl: function (src) {
|
|
1042
|
+
return (src.startsWith("http") || isInternalKey(src)) && !isSvg(src);
|
|
1043
|
+
},
|
|
1044
|
+
transformUrl: function (opts) {
|
|
1045
|
+
var _a;
|
|
1046
|
+
var params = [
|
|
1047
|
+
"src=".concat(encodeURIComponent(opts.src)),
|
|
1048
|
+
opts.width ? "w=".concat(opts.width) : undefined,
|
|
1049
|
+
"q=".concat((_a = opts.quality) !== null && _a !== void 0 ? _a : 75),
|
|
1050
|
+
opts.format ? "f=".concat(opts.format) : undefined,
|
|
1051
|
+
].filter(function (x) { return !!x; });
|
|
1052
|
+
return "".concat(IMG_OPTIMIZER_HOST, "/img-optimizer/v1/img?").concat(params.join("&"));
|
|
1053
|
+
},
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
var PlasmicLink = React.forwardRef(function PlasmicLink(props, ref) {
|
|
1057
|
+
var _a;
|
|
1058
|
+
// The usePlasmicLinkMaybe function may be undefined, if host is not up-to-date
|
|
1059
|
+
var Link = (_a = host.usePlasmicLinkMaybe === null || host.usePlasmicLinkMaybe === void 0 ? void 0 : host.usePlasmicLinkMaybe()) !== null && _a !== void 0 ? _a : PlasmicLinkInternal;
|
|
1060
|
+
if (Link === PlasmicLink || Link === PlasmicLinkInternal) {
|
|
1061
|
+
// Just in case, break the cycle
|
|
1062
|
+
return React.createElement(PlasmicLinkInternal, __assign({}, props, { ref: ref }));
|
|
899
1063
|
}
|
|
900
|
-
else
|
|
901
|
-
//
|
|
902
|
-
return {
|
|
903
|
-
type: "default",
|
|
904
|
-
props: {
|
|
905
|
-
children: x,
|
|
906
|
-
},
|
|
907
|
-
};
|
|
1064
|
+
else {
|
|
1065
|
+
// Don't pass component/platform props to non-PlasmicLinkInternal
|
|
1066
|
+
return React.createElement(Link, __assign({}, omit(props, "component", "platform"), { ref: ref }));
|
|
908
1067
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
1068
|
+
});
|
|
1069
|
+
var PlasmicLinkInternal = React.forwardRef(function PlasmicLinkInternal(props, ref) {
|
|
1070
|
+
var _a;
|
|
1071
|
+
// props.href is required for nextjs; if no props.href,
|
|
1072
|
+
// then we just render the default anchor element
|
|
1073
|
+
if (props.platform === "nextjs" && props.href) {
|
|
1074
|
+
var nextjsProps = [
|
|
1075
|
+
"href",
|
|
1076
|
+
"replace",
|
|
1077
|
+
"scroll",
|
|
1078
|
+
"shallow",
|
|
1079
|
+
"passHref",
|
|
1080
|
+
"prefetch",
|
|
1081
|
+
"locale",
|
|
1082
|
+
];
|
|
1083
|
+
// If this is a fragment identifier link, then we set
|
|
1084
|
+
// scroll={false} so that smooth scrolling works
|
|
1085
|
+
var isFragment = (_a = props.href) === null || _a === void 0 ? void 0 : _a.startsWith("#");
|
|
1086
|
+
return React.createElement(props.component, __assign(__assign({ scroll: !isFragment }, pick.apply(void 0, __spreadArray([props], __read(nextjsProps), false))), { legacyBehavior: true }), React.createElement("a", __assign({}, omit.apply(void 0, __spreadArray([props, "component", "platform"], __read(nextjsProps), false)), { ref: ref })));
|
|
1087
|
+
}
|
|
1088
|
+
if (props.platform === "gatsby" && isInternalHref(props.href)) {
|
|
1089
|
+
return React.createElement(props.component, __assign(__assign({}, omit(props, "component", "platform", "href")), { to: props.href, ref: ref }));
|
|
1090
|
+
}
|
|
1091
|
+
if (props.platform === "tanstack" && isInternalHref(props.href)) {
|
|
1092
|
+
return React.createElement(props.component, __assign(__assign({}, omit(props, "component", "platform", "href")), { to: props.href, ref: ref }));
|
|
1093
|
+
}
|
|
1094
|
+
return React.createElement("a", __assign({}, omit(props, "component", "platform"), { ref: ref }));
|
|
1095
|
+
});
|
|
1096
|
+
function isInternalHref(href) {
|
|
1097
|
+
return /^\/(?!\/)/.test(href);
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
// Make the refactor to host backwards compatible for loader
|
|
1101
|
+
var PlasmicTranslatorContext = host.PlasmicTranslatorContext !== null && host.PlasmicTranslatorContext !== void 0 ? host.PlasmicTranslatorContext : React.createContext(undefined);
|
|
1102
|
+
var usePlasmicTranslator = host.usePlasmicTranslator !== null && host.usePlasmicTranslator !== void 0 ? host.usePlasmicTranslator : (function () {
|
|
1103
|
+
var _t = React.useContext(PlasmicTranslatorContext);
|
|
1104
|
+
var translator = _t
|
|
1105
|
+
? typeof _t === "function"
|
|
1106
|
+
? _t
|
|
1107
|
+
: _t.translator
|
|
1108
|
+
: undefined;
|
|
1109
|
+
return translator;
|
|
1110
|
+
});
|
|
1111
|
+
function genTranslatableString(elt, opts) {
|
|
1112
|
+
var components = {};
|
|
1113
|
+
var componentsCount = 0;
|
|
1114
|
+
var getText = function (node) {
|
|
1115
|
+
var _a;
|
|
1116
|
+
if (!node) {
|
|
1117
|
+
return "";
|
|
914
1118
|
}
|
|
915
|
-
|
|
916
|
-
|
|
1119
|
+
if (typeof node === "number" ||
|
|
1120
|
+
typeof node === "boolean" ||
|
|
1121
|
+
typeof node === "string") {
|
|
1122
|
+
return node.toString();
|
|
917
1123
|
}
|
|
918
|
-
|
|
919
|
-
return
|
|
1124
|
+
if (typeof node !== "object") {
|
|
1125
|
+
return "";
|
|
920
1126
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
1127
|
+
if (Array.isArray(node) || isIterable(node)) {
|
|
1128
|
+
return Array.from(node)
|
|
1129
|
+
.map(function (child) { return getText(child); })
|
|
1130
|
+
.filter(function (child) { return !!child; })
|
|
1131
|
+
.join("");
|
|
925
1132
|
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1133
|
+
var nodeChildren = (hasKey(node, "props") &&
|
|
1134
|
+
hasKey(node.props, "children") &&
|
|
1135
|
+
node.props.children) ||
|
|
1136
|
+
(hasKey(node, "children") && node.children) ||
|
|
1137
|
+
[];
|
|
1138
|
+
var contents = "".concat(React.Children.toArray(nodeChildren)
|
|
1139
|
+
.map(function (child) { return getText(child); })
|
|
1140
|
+
.filter(function (child) { return !!child; })
|
|
1141
|
+
.join(""));
|
|
1142
|
+
if (React.isValidElement(node) && node.type === React.Fragment) {
|
|
1143
|
+
return contents;
|
|
1144
|
+
}
|
|
1145
|
+
var prefix = (_a = opts === null || opts === void 0 ? void 0 : opts.tagPrefix) !== null && _a !== void 0 ? _a : "";
|
|
1146
|
+
var componentId = "".concat(prefix).concat(componentsCount + 1);
|
|
1147
|
+
componentsCount++;
|
|
1148
|
+
components[componentId] = React.isValidElement(node)
|
|
1149
|
+
? React.cloneElement(node, {
|
|
1150
|
+
key: componentId,
|
|
1151
|
+
children: undefined,
|
|
1152
|
+
})
|
|
1153
|
+
: node;
|
|
1154
|
+
return "<".concat(componentId, ">").concat(contents, "</").concat(componentId, ">");
|
|
1155
|
+
};
|
|
1156
|
+
var str = getText(elt);
|
|
1157
|
+
return {
|
|
1158
|
+
str: str,
|
|
1159
|
+
components: components,
|
|
1160
|
+
componentsCount: componentsCount,
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
function Trans(_a) {
|
|
1164
|
+
var transKey = _a.transKey, children = _a.children;
|
|
1165
|
+
var _t = React.useContext(PlasmicTranslatorContext);
|
|
1166
|
+
var translator = _t
|
|
1167
|
+
? typeof _t === "function"
|
|
1168
|
+
? _t
|
|
1169
|
+
: _t.translator
|
|
1170
|
+
: undefined;
|
|
1171
|
+
if (!translator) {
|
|
1172
|
+
warnNoTranslationFunctionAtMostOnce();
|
|
1173
|
+
return children;
|
|
937
1174
|
}
|
|
938
|
-
|
|
1175
|
+
var _b = genTranslatableString(children, {
|
|
1176
|
+
tagPrefix: typeof _t === "object" ? _t.tagPrefix : undefined,
|
|
1177
|
+
}), str = _b.str, components = _b.components, componentsCount = _b.componentsCount;
|
|
1178
|
+
return translator(transKey !== null && transKey !== void 0 ? transKey : str, componentsCount > 0 ? { components: components } : undefined);
|
|
939
1179
|
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
1180
|
+
var hasWarned = false;
|
|
1181
|
+
function warnNoTranslationFunctionAtMostOnce() {
|
|
1182
|
+
if (!hasWarned) {
|
|
1183
|
+
console.warn("Using Plasmic Translation but no translation function has been provided");
|
|
1184
|
+
hasWarned = true;
|
|
943
1185
|
}
|
|
944
|
-
return __assign(__assign({}, v1), v2);
|
|
945
1186
|
}
|
|
946
|
-
function
|
|
947
|
-
return
|
|
948
|
-
var variantGroup = _a.variantGroup, statePath = _a.statePath;
|
|
949
|
-
return [
|
|
950
|
-
variantGroup,
|
|
951
|
-
get($state, statePath),
|
|
952
|
-
];
|
|
953
|
-
})));
|
|
1187
|
+
function hasKey(v, key) {
|
|
1188
|
+
return typeof v === "object" && v !== null && key in v;
|
|
954
1189
|
}
|
|
955
|
-
function
|
|
956
|
-
|
|
957
|
-
return a1 || a2 || {};
|
|
958
|
-
}
|
|
959
|
-
return __assign(__assign({}, a1), a2);
|
|
1190
|
+
function isIterable(val) {
|
|
1191
|
+
return val != null && typeof val[Symbol.iterator] === "function";
|
|
960
1192
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
var
|
|
967
|
-
var
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
merged[key] = mergeFlexOverride(o1[key], o2[key]);
|
|
972
|
-
}
|
|
1193
|
+
|
|
1194
|
+
function PlasmicSlot(props) {
|
|
1195
|
+
return renderPlasmicSlot(props);
|
|
1196
|
+
}
|
|
1197
|
+
function renderPlasmicSlot(opts) {
|
|
1198
|
+
var as = opts.as, defaultContents = opts.defaultContents, value = opts.value, rest = __rest(opts, ["as", "defaultContents", "value"]);
|
|
1199
|
+
var content = value === undefined ? defaultContents : value;
|
|
1200
|
+
if (typeof content !== "number" &&
|
|
1201
|
+
(!content || (Array.isArray(content) && content.length === 0))) {
|
|
1202
|
+
return null;
|
|
973
1203
|
}
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1204
|
+
// If the content is a raw string, then we need to wrap the raw string
|
|
1205
|
+
// into an element, in case the slot is inside a flex-gap
|
|
1206
|
+
// container (you cannot apply margin to just a text node).
|
|
1207
|
+
var maybeString = maybeAsString(content);
|
|
1208
|
+
if (maybeString) {
|
|
1209
|
+
content = (React__namespace.createElement("span", { className: "__wab_slot-string-wrapper \u03C1sw" }, maybeString));
|
|
980
1210
|
}
|
|
981
|
-
return
|
|
1211
|
+
var nonEmptyProps = Object.keys(rest).filter(function (p) { return !!rest[p]; });
|
|
1212
|
+
if (nonEmptyProps.length === 0) {
|
|
1213
|
+
// No attrs to apply to the slot (which means the slot is unstyled), then
|
|
1214
|
+
// just render the content directly; no need for style wrapper.
|
|
1215
|
+
return content;
|
|
1216
|
+
}
|
|
1217
|
+
return React__namespace.createElement(as || "span", mergeProps({ className: "__wab_slot ρs" }, rest), content);
|
|
982
1218
|
}
|
|
983
|
-
function
|
|
984
|
-
|
|
985
|
-
if (
|
|
986
|
-
|
|
1219
|
+
function maybeAsString(node) {
|
|
1220
|
+
// Unwrap fragments
|
|
1221
|
+
if (React__namespace.isValidElement(node)) {
|
|
1222
|
+
// Fragment doesn't render DOM elements
|
|
1223
|
+
if (node.type === React__namespace.Fragment) {
|
|
1224
|
+
return maybeAsString(node.props.children);
|
|
1225
|
+
}
|
|
1226
|
+
else if (node.type === Trans) {
|
|
1227
|
+
// Trans also doesn't render DOM elements. But we don't want to just render
|
|
1228
|
+
// its content string, because we want to keep the <Trans/> for the localization.
|
|
1229
|
+
// So we render the same node, to be wrapped into __wab_slot-string-wrapper.
|
|
1230
|
+
return node;
|
|
1231
|
+
}
|
|
987
1232
|
}
|
|
988
|
-
if (
|
|
989
|
-
return
|
|
1233
|
+
if (typeof node === "string") {
|
|
1234
|
+
return node;
|
|
990
1235
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
var wrap = chainSingleArgFuncs.apply(void 0, __spreadArray([], __read([o1.wrap, o2.wrap].filter(notNil)), false));
|
|
994
|
-
var wrapChildren = chainSingleArgFuncs.apply(void 0, __spreadArray([], __read([o1.wrapChildren, o2.wrapChildren].filter(notNil)), false));
|
|
995
|
-
// "render" type always takes precedence, but we still merge the props
|
|
996
|
-
var props = mergeOverrideProps((_a = o1.props) !== null && _a !== void 0 ? _a : {}, o2.props);
|
|
997
|
-
if (o2.type === "render") {
|
|
998
|
-
return {
|
|
999
|
-
render: o2.render,
|
|
1000
|
-
props: props,
|
|
1001
|
-
wrap: wrap,
|
|
1002
|
-
wrapChildren: wrapChildren,
|
|
1003
|
-
};
|
|
1236
|
+
if (typeof node === "number") {
|
|
1237
|
+
return "".concat(node);
|
|
1004
1238
|
}
|
|
1005
|
-
if (
|
|
1006
|
-
return
|
|
1007
|
-
render: o1.render,
|
|
1008
|
-
props: props,
|
|
1009
|
-
wrap: wrap,
|
|
1010
|
-
wrapChildren: wrapChildren,
|
|
1011
|
-
};
|
|
1239
|
+
if (Array.isArray(node) && node.length === 1 && typeof node[0] === "string") {
|
|
1240
|
+
return node[0];
|
|
1012
1241
|
}
|
|
1013
|
-
|
|
1014
|
-
var as = (_b = (o2.type === "as" ? o2.as : undefined)) !== null && _b !== void 0 ? _b : (o1.type === "as" ? o1.as : undefined);
|
|
1015
|
-
return __assign({ props: props, wrap: wrap, wrapChildren: wrapChildren }, (as ? { as: as } : {}));
|
|
1242
|
+
return undefined;
|
|
1016
1243
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
var
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1244
|
+
|
|
1245
|
+
function hasVariant(variants, groupName, variant) {
|
|
1246
|
+
if (variants == null) {
|
|
1247
|
+
return false;
|
|
1248
|
+
}
|
|
1249
|
+
var groupVariants = variants[groupName];
|
|
1250
|
+
if (groupVariants == null) {
|
|
1251
|
+
return false;
|
|
1252
|
+
}
|
|
1253
|
+
else if (groupVariants === true) {
|
|
1254
|
+
return variant === groupName;
|
|
1255
|
+
}
|
|
1256
|
+
else if (groupVariants === false) {
|
|
1257
|
+
return false;
|
|
1258
|
+
}
|
|
1259
|
+
else if (Array.isArray(groupVariants)) {
|
|
1260
|
+
return groupVariants.includes(variant);
|
|
1261
|
+
}
|
|
1262
|
+
else if (typeof groupVariants === "string") {
|
|
1263
|
+
return groupVariants === variant;
|
|
1264
|
+
}
|
|
1265
|
+
else {
|
|
1266
|
+
return (groupVariants[variant] !== undefined && groupVariants[variant] !== false);
|
|
1034
1267
|
}
|
|
1035
|
-
return { variants: variants, args: args, overrides: overrides };
|
|
1036
1268
|
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
return
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
console.warn("Plasmic context value for global variant \"".concat(key, "\" was not provided; please use ").concat(providerName, " at the root of your React app. Learn More: https://www.plasmic.app/learn/other-assets/#global-variants"));
|
|
1053
|
-
}
|
|
1054
|
-
});
|
|
1055
|
-
return globalVariantValues;
|
|
1269
|
+
function wrapFlexContainerChildren(children, hasGap) {
|
|
1270
|
+
// We need to always wrap the children, even if there are no gaps, because
|
|
1271
|
+
// otherwise if we toggle between with and without gap, React reconciliation
|
|
1272
|
+
// will blow away the children tree and all state if we switch from having
|
|
1273
|
+
// a wrapper and not.
|
|
1274
|
+
var className = hasGap ? "__wab_flex-container ρfc" : "__wab_passthrough";
|
|
1275
|
+
if (!children) {
|
|
1276
|
+
return null;
|
|
1277
|
+
}
|
|
1278
|
+
else if (Array.isArray(children)) {
|
|
1279
|
+
return React__namespace.createElement.apply(React__namespace, __spreadArray(["div", { className: className }], __read(children), false));
|
|
1280
|
+
}
|
|
1281
|
+
else {
|
|
1282
|
+
return React__namespace.createElement("div", { className: className }, children);
|
|
1283
|
+
}
|
|
1056
1284
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
if (
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
if (props.description) {
|
|
1076
|
-
headMetadata.description = props.description;
|
|
1285
|
+
function createPlasmicElement(override, defaultRoot, defaultProps, wrapChildrenInFlex) {
|
|
1286
|
+
if (!override ||
|
|
1287
|
+
(typeof override === "object" && Object.keys(override).length === 0)) {
|
|
1288
|
+
return createElementWithChildren(defaultRoot, defaultProps, defaultProps.children);
|
|
1289
|
+
}
|
|
1290
|
+
var override2 = deriveOverride(override);
|
|
1291
|
+
var props = mergeOverrideProps(defaultProps, override2.props);
|
|
1292
|
+
if (override2.type === "render") {
|
|
1293
|
+
return override2.render(props, defaultRoot);
|
|
1294
|
+
}
|
|
1295
|
+
var root = defaultRoot;
|
|
1296
|
+
if (override2.type === "as" && override2.as) {
|
|
1297
|
+
if (defaultRoot === Stack) {
|
|
1298
|
+
// If there was an "as" override specified, but the default type is
|
|
1299
|
+
// a Stack, then we don't want to switch to using "as" as the root,
|
|
1300
|
+
// because then we'd lose the flex wrapper that Stack provides.
|
|
1301
|
+
// Instead, we specify the "as" as the "as" prop to Stack.
|
|
1302
|
+
props.as = override2.as;
|
|
1077
1303
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1304
|
+
else {
|
|
1305
|
+
root = override2.as;
|
|
1080
1306
|
}
|
|
1081
1307
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
return null;
|
|
1308
|
+
var children = props.children;
|
|
1309
|
+
if (override2.wrapChildren) {
|
|
1310
|
+
children = override2.wrapChildren(ensureNotArray(children));
|
|
1086
1311
|
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
React__namespace.createElement("title", { key: "title" }, props.title),
|
|
1097
|
-
React__namespace.createElement("meta", { key: "og:title", property: "og:title", content: props.title }),
|
|
1098
|
-
React__namespace.createElement("meta", { key: "twitter:title", property: "twitter:title", content: props.title }),
|
|
1099
|
-
],
|
|
1100
|
-
props.description && [
|
|
1101
|
-
React__namespace.createElement("meta", { key: "description", name: "description", content: props.description }),
|
|
1102
|
-
React__namespace.createElement("meta", { key: "og:description", property: "og:description", content: props.description }),
|
|
1103
|
-
React__namespace.createElement("meta", { key: "twitter:description", name: "twitter:description", content: props.description }),
|
|
1104
|
-
],
|
|
1105
|
-
props.canonical && (React__namespace.createElement("link", { key: "canonical", rel: "canonical", href: props.canonical }))));
|
|
1312
|
+
if (wrapChildrenInFlex) {
|
|
1313
|
+
// For legacy, we still support data-plasmic-wrap-flex-children
|
|
1314
|
+
children = wrapFlexContainerChildren(children, true);
|
|
1315
|
+
}
|
|
1316
|
+
var result = createElementWithChildren(root, props, children);
|
|
1317
|
+
if (override2.wrap) {
|
|
1318
|
+
result = override2.wrap(result);
|
|
1319
|
+
}
|
|
1320
|
+
return result;
|
|
1106
1321
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
},
|
|
1124
|
-
image: {
|
|
1125
|
-
type: "imageUrl",
|
|
1126
|
-
displayName: "Image",
|
|
1127
|
-
},
|
|
1128
|
-
canonical: {
|
|
1129
|
-
type: "string",
|
|
1130
|
-
displayName: "Canonical URL",
|
|
1131
|
-
},
|
|
1132
|
-
},
|
|
1133
|
-
};
|
|
1134
|
-
|
|
1135
|
-
function PlasmicIcon(props) {
|
|
1136
|
-
var PlasmicIconType = props.PlasmicIconType, rest = __rest(props, ["PlasmicIconType"]);
|
|
1137
|
-
return React__namespace.createElement(PlasmicIconType, __assign({}, rest));
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
/**
|
|
1141
|
-
* Responsive `<img/>` replacement, based on `next/image`
|
|
1142
|
-
*/
|
|
1143
|
-
var IMG_OPTIMIZER_HOST = "https://img.plasmic.app";
|
|
1144
|
-
// Default image sizes to snap to
|
|
1145
|
-
// TODO: make this configurable?
|
|
1146
|
-
var IMG_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];
|
|
1147
|
-
var DEVICE_SIZES = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];
|
|
1148
|
-
var ALL_SIZES = __spreadArray(__spreadArray([], __read(IMG_SIZES), false), __read(DEVICE_SIZES), false);
|
|
1149
|
-
var PlasmicImg = React.forwardRef(function PlasmicImg(props, outerRef) {
|
|
1150
|
-
var src = props.src, className = props.className, displayWidth = props.displayWidth, displayHeight = props.displayHeight, displayMinWidth = props.displayMinWidth, displayMinHeight = props.displayMinHeight, displayMaxWidth = props.displayMaxWidth, displayMaxHeight = props.displayMaxHeight, quality = props.quality, loader = props.loader, imgRef = props.imgRef, style = props.style, loading = props.loading, rest = __rest(props, ["src", "className", "displayWidth", "displayHeight", "displayMinWidth", "displayMinHeight", "displayMaxWidth", "displayMaxHeight", "quality", "loader", "imgRef", "style", "loading"]);
|
|
1151
|
-
var imgProps = Object.assign({}, rest, {
|
|
1152
|
-
// Default loading to "lazy" if not specified (which is different from the
|
|
1153
|
-
// html img, which defaults to eager!)
|
|
1154
|
-
loading: loading !== null && loading !== void 0 ? loading : "lazy",
|
|
1155
|
-
});
|
|
1156
|
-
var _a = !src
|
|
1157
|
-
? { fullWidth: undefined, fullHeight: undefined, aspectRatio: undefined }
|
|
1158
|
-
: typeof src === "string"
|
|
1159
|
-
? getImageSizeData(getPixelLength(props.width), getPixelLength(props.height))
|
|
1160
|
-
: src, fullWidth = _a.fullWidth, fullHeight = _a.fullHeight, aspectRatio = _a.aspectRatio;
|
|
1161
|
-
var srcStr = src
|
|
1162
|
-
? typeof src === "string"
|
|
1163
|
-
? src
|
|
1164
|
-
: typeof src.src === "string"
|
|
1165
|
-
? src.src
|
|
1166
|
-
: src.src.src
|
|
1167
|
-
: "";
|
|
1168
|
-
// Assume external image if either dimension is null and use usual <img>
|
|
1169
|
-
if (fullHeight == null || fullWidth == null) {
|
|
1170
|
-
return (React.createElement("img", __assign({ src: srcStr, className: className, style: style }, imgProps, { loading: loading, ref: mergeRefs(imgRef, outerRef) })));
|
|
1171
|
-
}
|
|
1172
|
-
if (isSvg(srcStr) &&
|
|
1173
|
-
(displayHeight == null || displayHeight === "auto") &&
|
|
1174
|
-
(displayWidth == null || displayWidth === "auto")) {
|
|
1175
|
-
displayWidth = "100%";
|
|
1176
|
-
}
|
|
1177
|
-
var computedDisplayWidth = displayWidth;
|
|
1178
|
-
if (fullWidth &&
|
|
1179
|
-
fullHeight &&
|
|
1180
|
-
(!displayWidth || displayWidth === "auto") &&
|
|
1181
|
-
!!getPixelLength(displayHeight)) {
|
|
1182
|
-
// If there's a pixel length specified for displayHeight but not displayWidth,
|
|
1183
|
-
// then we can derive the pixel length for displayWidth. Having an explicit
|
|
1184
|
-
// displayWidth makes this a fixed-size image, which makes it possible for us to
|
|
1185
|
-
// generate better markup!
|
|
1186
|
-
if (!isSvg(srcStr)) {
|
|
1187
|
-
// We shouldn't do it for SVGs though, because `fullWidth` and
|
|
1188
|
-
// `fullHeight` might have rounded values so the final
|
|
1189
|
-
// `displayWidth` could differ by 1px or so.
|
|
1190
|
-
computedDisplayWidth =
|
|
1191
|
-
(getPixelLength(displayHeight) * fullWidth) / fullHeight;
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
var spacerWidth = fullWidth;
|
|
1195
|
-
var spacerHeight = fullHeight;
|
|
1196
|
-
if (aspectRatio && isFinite(aspectRatio) && isSvg(srcStr)) {
|
|
1197
|
-
// For SVGs, fullWidth and fullHeight can be rounded values, which would
|
|
1198
|
-
// cause some discrepancy between the actual aspect ratio and the aspect
|
|
1199
|
-
// ratio from those values. So, for those cases, we set large width / height
|
|
1200
|
-
// values to get a more precise ratio from the spacer.
|
|
1201
|
-
spacerWidth = DEFAULT_SVG_WIDTH;
|
|
1202
|
-
spacerHeight = Math.round(spacerWidth / aspectRatio);
|
|
1203
|
-
}
|
|
1204
|
-
var _b = getWidths(computedDisplayWidth, fullWidth, {
|
|
1205
|
-
minWidth: displayMinWidth,
|
|
1206
|
-
}), sizes = _b.sizes, widthDescs = _b.widthDescs;
|
|
1207
|
-
var imageLoader = getImageLoader(loader);
|
|
1208
|
-
var spacerSvg = "<svg width=\"".concat(spacerWidth, "\" height=\"").concat(spacerHeight, "\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"/>");
|
|
1209
|
-
var spacerSvgBase64 =
|
|
1210
|
-
// if btoa exists, use btoa, as it works in browser and in
|
|
1211
|
-
// cloudflare edge workers. For node, use Buffer.from().
|
|
1212
|
-
typeof globalThis.btoa === "function"
|
|
1213
|
-
? globalThis.btoa(spacerSvg)
|
|
1214
|
-
: Buffer.from(spacerSvg).toString("base64");
|
|
1215
|
-
var wrapperStyle = __assign({}, (style || {}));
|
|
1216
|
-
var spacerStyle = __assign({}, pick(style || {}, "objectFit", "objectPosition"));
|
|
1217
|
-
if (displayWidth != null && displayWidth !== "auto") {
|
|
1218
|
-
// If width is set, set it on the wrapper along with min/max width
|
|
1219
|
-
// and just use `width: 100%` on the spacer
|
|
1220
|
-
spacerStyle.width = "100%";
|
|
1221
|
-
// Rely on the styles set by `classname` on the wrapper:
|
|
1222
|
-
// wrapperStyle.width = displayWidth;
|
|
1223
|
-
// wrapperStyle.minWidth = displayMinWidth;
|
|
1224
|
-
// wrapperStyle.maxWidth = displayMaxWidth;
|
|
1225
|
-
}
|
|
1226
|
-
else {
|
|
1227
|
-
// Otherwise, we want auto sizing from the spacer, so set width there.
|
|
1228
|
-
//
|
|
1229
|
-
// But if we have min/max width, it should be set in the wrapper and it
|
|
1230
|
-
// can be percentage values (and we add corresponding min/max width to
|
|
1231
|
-
// 100% in the spacer). In general it ends up with the correct effect,
|
|
1232
|
-
// but some edge cases might make `min-width: 100%` shrink the image more
|
|
1233
|
-
// than it should.
|
|
1234
|
-
spacerStyle.width = displayWidth;
|
|
1235
|
-
wrapperStyle.width = "auto";
|
|
1236
|
-
if (displayMinWidth) {
|
|
1237
|
-
spacerStyle.minWidth = "100%";
|
|
1238
|
-
// Rely on min-width set by `classname` on the wrapper:
|
|
1239
|
-
// wrapperStyle.minWidth = displayMinWidth;
|
|
1240
|
-
}
|
|
1241
|
-
if (displayMaxWidth != null && displayMaxWidth !== "none") {
|
|
1242
|
-
spacerStyle.maxWidth = "100%";
|
|
1243
|
-
// Rely on max-width set by `classname` on the wrapper:
|
|
1244
|
-
// wrapperStyle.maxWidth = displayMaxWidth;
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
if (displayHeight != null && displayHeight !== "auto") {
|
|
1248
|
-
spacerStyle.height = "100%";
|
|
1249
|
-
// wrapperStyle.height = displayHeight;
|
|
1250
|
-
// wrapperStyle.minHeight = displayMinHeight;
|
|
1251
|
-
// wrapperStyle.maxHeight = displayMaxHeight;
|
|
1252
|
-
}
|
|
1253
|
-
else {
|
|
1254
|
-
spacerStyle.height = displayHeight;
|
|
1255
|
-
wrapperStyle.height = "auto";
|
|
1256
|
-
if (displayMinHeight) {
|
|
1257
|
-
spacerStyle.minHeight = "100%";
|
|
1258
|
-
// wrapperStyle.minHeight = displayMinHeight;
|
|
1259
|
-
}
|
|
1260
|
-
if (displayMaxHeight != null && displayMaxHeight !== "none") {
|
|
1261
|
-
spacerStyle.maxHeight = "100%";
|
|
1262
|
-
// wrapperStyle.maxHeight = displayMaxHeight;
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
return (React.createElement("div", { className: classNames$1(className, "__wab_img-wrapper"), ref: outerRef, style: wrapperStyle },
|
|
1266
|
-
React.createElement("img", { alt: "", "aria-hidden": true, className: "__wab_img-spacer-svg", src: "data:image/svg+xml;base64,".concat(spacerSvgBase64), style: spacerStyle }),
|
|
1267
|
-
makePicture({
|
|
1268
|
-
imageLoader: imageLoader,
|
|
1269
|
-
widthDescs: widthDescs,
|
|
1270
|
-
sizes: sizes,
|
|
1271
|
-
src: srcStr,
|
|
1272
|
-
quality: quality,
|
|
1273
|
-
ref: imgRef,
|
|
1274
|
-
style: style ? pick(style, "objectFit", "objectPosition") : undefined,
|
|
1275
|
-
imgProps: imgProps,
|
|
1276
|
-
className: "__wab_img",
|
|
1277
|
-
})));
|
|
1278
|
-
});
|
|
1279
|
-
function makePicture(opts) {
|
|
1280
|
-
// If imageLoader is undefined, then this renders to just a normal
|
|
1281
|
-
// <img />. Else it will render to a <picture> with a <source> for
|
|
1282
|
-
// webp, and srcSet/sizes set according to width requirements.
|
|
1283
|
-
var imageLoader = opts.imageLoader, widthDescs = opts.widthDescs, src = opts.src, quality = opts.quality, style = opts.style, className = opts.className, sizes = opts.sizes, imgProps = opts.imgProps, ref = opts.ref;
|
|
1284
|
-
return (React.createElement("picture", { className: "__wab_picture" },
|
|
1285
|
-
imageLoader && imageLoader.supportsUrl(src) && (React.createElement("source", { type: "image/webp", srcSet: widthDescs
|
|
1286
|
-
.map(function (wd) {
|
|
1287
|
-
return "".concat(imageLoader.transformUrl({
|
|
1288
|
-
src: src,
|
|
1289
|
-
quality: quality,
|
|
1290
|
-
width: wd.width,
|
|
1291
|
-
format: "webp",
|
|
1292
|
-
}), " ").concat(wd.desc);
|
|
1293
|
-
})
|
|
1294
|
-
.join(", ") })),
|
|
1295
|
-
React.createElement("img", __assign({}, imgProps, { ref: ref, className: className, decoding: "async", src: imageLoader && imageLoader.supportsUrl(src)
|
|
1296
|
-
? imageLoader.transformUrl({
|
|
1297
|
-
src: src,
|
|
1298
|
-
quality: quality,
|
|
1299
|
-
width: widthDescs[widthDescs.length - 1].width,
|
|
1300
|
-
})
|
|
1301
|
-
: src, srcSet: imageLoader && imageLoader.supportsUrl(src)
|
|
1302
|
-
? widthDescs
|
|
1303
|
-
.map(function (wd) {
|
|
1304
|
-
return "".concat(imageLoader.transformUrl({
|
|
1305
|
-
src: src,
|
|
1306
|
-
quality: quality,
|
|
1307
|
-
width: wd.width,
|
|
1308
|
-
}), " ").concat(wd.desc);
|
|
1309
|
-
})
|
|
1310
|
-
.join(", ")
|
|
1311
|
-
: undefined, sizes: imageLoader && imageLoader.supportsUrl(src) ? sizes : undefined, style: __assign(__assign({}, (style ? pick(style, "objectFit", "objectPosition") : {})), { width: 0, height: 0 }) }))));
|
|
1312
|
-
}
|
|
1313
|
-
var DEFAULT_SVG_WIDTH = 10000;
|
|
1314
|
-
function isSvg(src) {
|
|
1315
|
-
return src.endsWith(".svg") || src.startsWith("data:image/svg");
|
|
1316
|
-
}
|
|
1317
|
-
function getClosestPresetSize(width, fullWidth) {
|
|
1322
|
+
// We use data-plasmic-XXX attributes for custom properties since Typescript doesn't
|
|
1323
|
+
// support type check on jsx pragma. See https://github.com/microsoft/TypeScript/issues/21699
|
|
1324
|
+
// for more info.
|
|
1325
|
+
var seenElements = new Map();
|
|
1326
|
+
function createPlasmicElementProxy(defaultElement, props) {
|
|
1327
|
+
// We use seenElements to keep track of elements that has been rendered by
|
|
1328
|
+
// createPlasmicElementProxy(). When a JSX tree is evaluated, the JSX factory
|
|
1329
|
+
// is invoked from the leaf to the root as the last call. So we can store
|
|
1330
|
+
// all the elements we've created until we encounter the leaf, at which point
|
|
1331
|
+
// we will clear this map. We are guaranteed that this map will only contain
|
|
1332
|
+
// elements from one Plasmic* component at a time, because we're just creating
|
|
1333
|
+
// elements and not "rendering" at this point; even if this JSX tree references
|
|
1334
|
+
// other Plasmic* elements, we'll just create an element referencing that component,
|
|
1335
|
+
// rather than following into the content of that component.
|
|
1336
|
+
//
|
|
1337
|
+
// TODO: is this ConcurrentMode friendly?
|
|
1318
1338
|
var _a;
|
|
1319
|
-
var
|
|
1320
|
-
var
|
|
1321
|
-
|
|
1322
|
-
// If the requested width is larger than the fullWidth,
|
|
1323
|
-
// we just use the original width instead. It's impossible
|
|
1324
|
-
// to make an image bigger than fullWidth!
|
|
1325
|
-
return undefined;
|
|
1326
|
-
}
|
|
1327
|
-
else if (nextBiggerIndex + 1 < ALL_SIZES.length &&
|
|
1328
|
-
fullWidth <= ALL_SIZES[nextBiggerIndex + 1]) {
|
|
1329
|
-
// If the fullWidth is just between nextBigger and the one after that,
|
|
1330
|
-
// then also might as well just use the original size (so, width is 30,
|
|
1331
|
-
// nextBigger is 32, then we just use the original as long as fullWidth is
|
|
1332
|
-
// less than 48)
|
|
1333
|
-
return undefined;
|
|
1334
|
-
}
|
|
1335
|
-
return nextBigger;
|
|
1336
|
-
}
|
|
1337
|
-
/**
|
|
1338
|
-
* Computes the appropriate srcSet and sizes to use
|
|
1339
|
-
*/
|
|
1340
|
-
function getWidths(width, fullWidth, extra) {
|
|
1341
|
-
var minWidth = extra === null || extra === void 0 ? void 0 : extra.minWidth;
|
|
1342
|
-
var pixelWidth = getPixelLength(width);
|
|
1343
|
-
var pixelMinWidth = getPixelLength(minWidth);
|
|
1344
|
-
if (pixelWidth != null && (!minWidth || pixelMinWidth != null)) {
|
|
1345
|
-
// If there's an exact width, then we just need to display it at 1x and 2x density
|
|
1346
|
-
return {
|
|
1347
|
-
widthDescs: [
|
|
1348
|
-
{
|
|
1349
|
-
width: getClosestPresetSize(Math.max(pixelWidth, pixelMinWidth !== null && pixelMinWidth !== void 0 ? pixelMinWidth : 0), fullWidth),
|
|
1350
|
-
desc: "1x",
|
|
1351
|
-
},
|
|
1352
|
-
{
|
|
1353
|
-
width: getClosestPresetSize(Math.max(pixelWidth, pixelMinWidth !== null && pixelMinWidth !== void 0 ? pixelMinWidth : 0) * 2, fullWidth),
|
|
1354
|
-
desc: "2x",
|
|
1355
|
-
},
|
|
1356
|
-
],
|
|
1357
|
-
sizes: undefined,
|
|
1358
|
-
};
|
|
1359
|
-
}
|
|
1360
|
-
// Otherwise we don't know what sizes we'll end up, so we just cap it at
|
|
1361
|
-
// device width. TODO: do better!
|
|
1362
|
-
var usefulSizes = DEVICE_SIZES.filter(function (size) { return !fullWidth || size < fullWidth; });
|
|
1363
|
-
if (!!fullWidth && usefulSizes.length === 0) {
|
|
1364
|
-
// image fullWidth is smaller than all device sizes. So all we can do
|
|
1365
|
-
// is offer 1x
|
|
1366
|
-
return {
|
|
1367
|
-
widthDescs: [
|
|
1368
|
-
{
|
|
1369
|
-
width: getClosestPresetSize(fullWidth, fullWidth),
|
|
1370
|
-
desc: "1x",
|
|
1371
|
-
},
|
|
1372
|
-
],
|
|
1373
|
-
sizes: undefined,
|
|
1374
|
-
};
|
|
1375
|
-
}
|
|
1376
|
-
return {
|
|
1377
|
-
widthDescs: usefulSizes.map(function (size) { return ({
|
|
1378
|
-
width: getClosestPresetSize(size, fullWidth),
|
|
1379
|
-
// If this is the last (buggest) useful width, but it is
|
|
1380
|
-
// still within the bounds set by DEVICE_SIZES, then just
|
|
1381
|
-
// use the original, unresized image. This means if we match
|
|
1382
|
-
// the largest size, we use unresized and best quality image.
|
|
1383
|
-
// We only do this, though, if fullWidth is "reasonable" --
|
|
1384
|
-
// smaller than the largest size we would consider.
|
|
1385
|
-
// i === usefulSizes.length - 1 &&
|
|
1386
|
-
// fullWidth < DEVICE_SIZES[DEVICE_SIZES.length - 1]
|
|
1387
|
-
// ? undefined
|
|
1388
|
-
// : size,
|
|
1389
|
-
desc: "".concat(size, "w"),
|
|
1390
|
-
}); }),
|
|
1391
|
-
sizes: "100vw",
|
|
1392
|
-
};
|
|
1393
|
-
}
|
|
1394
|
-
function getPixelLength(length) {
|
|
1395
|
-
if (length == null || length == "") {
|
|
1396
|
-
return undefined;
|
|
1397
|
-
}
|
|
1398
|
-
if (typeof length === "number") {
|
|
1399
|
-
return length;
|
|
1400
|
-
}
|
|
1401
|
-
var parsed = parseNumeric(length);
|
|
1402
|
-
if (parsed && (!parsed.units || parsed.units === "px")) {
|
|
1403
|
-
return parsed.num;
|
|
1404
|
-
}
|
|
1405
|
-
return undefined;
|
|
1406
|
-
}
|
|
1407
|
-
function parseNumeric(val) {
|
|
1408
|
-
// Parse strings like "30", "30px", "30%", "30px /* blah blah */"
|
|
1409
|
-
var res = val.match(/^\s*(-?(?:\d+\.\d*|\d*\.\d+|\d+))\s*([a-z]*|%)\s*(?:\/\*.*)?$/i);
|
|
1410
|
-
if (res == null) {
|
|
1411
|
-
return undefined;
|
|
1339
|
+
var children = [];
|
|
1340
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1341
|
+
children[_i - 2] = arguments[_i];
|
|
1412
1342
|
}
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
return { num: +num, units: units };
|
|
1416
|
-
}
|
|
1417
|
-
function getImageSizeData(width, height) {
|
|
1418
|
-
var aspectRatio = width && height ? width / height : undefined;
|
|
1419
|
-
return {
|
|
1420
|
-
fullWidth: width,
|
|
1421
|
-
fullHeight: height,
|
|
1422
|
-
aspectRatio: aspectRatio && isFinite(aspectRatio) ? aspectRatio : undefined,
|
|
1423
|
-
};
|
|
1424
|
-
}
|
|
1425
|
-
function getImageLoader(loader) {
|
|
1426
|
-
if (loader == null) {
|
|
1427
|
-
return undefined;
|
|
1343
|
+
if (props == null) {
|
|
1344
|
+
props = {};
|
|
1428
1345
|
}
|
|
1429
|
-
|
|
1430
|
-
|
|
1346
|
+
var name = props["data-plasmic-name"];
|
|
1347
|
+
var isRoot = props["data-plasmic-root"];
|
|
1348
|
+
var forNodeName = props["data-plasmic-for-node"];
|
|
1349
|
+
delete props["data-plasmic-name"];
|
|
1350
|
+
delete props["data-plasmic-root"];
|
|
1351
|
+
delete props["data-plasmic-for-node"];
|
|
1352
|
+
var element = createPlasmicElementFromJsx.apply(void 0, __spreadArray([defaultElement,
|
|
1353
|
+
props], __read(children), false));
|
|
1354
|
+
if (name) {
|
|
1355
|
+
seenElements.set(name, element);
|
|
1431
1356
|
}
|
|
1432
|
-
|
|
1433
|
-
|
|
1357
|
+
if (isRoot) {
|
|
1358
|
+
// If this is the root, and we requested a specific node by specifying data-plasmic-for-node,
|
|
1359
|
+
// then return that node instead
|
|
1360
|
+
var forNode = forNodeName
|
|
1361
|
+
? (_a = seenElements.get(forNodeName)) !== null && _a !== void 0 ? _a : null
|
|
1362
|
+
: element;
|
|
1363
|
+
// Clear out the seenElements map, as we're done rendering this Plasmic* component.
|
|
1364
|
+
seenElements.clear();
|
|
1365
|
+
return forNode;
|
|
1434
1366
|
}
|
|
1367
|
+
return element;
|
|
1435
1368
|
}
|
|
1436
|
-
function
|
|
1437
|
-
return /^([a-f0-9]{32})\..{1,16}$/i.test(src);
|
|
1438
|
-
}
|
|
1439
|
-
var PLASMIC_IMAGE_LOADER = {
|
|
1440
|
-
supportsUrl: function (src) {
|
|
1441
|
-
return (src.startsWith("http") || isInternalKey(src)) && !isSvg(src);
|
|
1442
|
-
},
|
|
1443
|
-
transformUrl: function (opts) {
|
|
1444
|
-
var _a;
|
|
1445
|
-
var params = [
|
|
1446
|
-
"src=".concat(encodeURIComponent(opts.src)),
|
|
1447
|
-
opts.width ? "w=".concat(opts.width) : undefined,
|
|
1448
|
-
"q=".concat((_a = opts.quality) !== null && _a !== void 0 ? _a : 75),
|
|
1449
|
-
opts.format ? "f=".concat(opts.format) : undefined,
|
|
1450
|
-
].filter(function (x) { return !!x; });
|
|
1451
|
-
return "".concat(IMG_OPTIMIZER_HOST, "/img-optimizer/v1/img?").concat(params.join("&"));
|
|
1452
|
-
},
|
|
1453
|
-
};
|
|
1454
|
-
|
|
1455
|
-
var PlasmicLink = React.forwardRef(function PlasmicLink(props, ref) {
|
|
1369
|
+
function createPlasmicElementFromJsx(defaultElement, props) {
|
|
1456
1370
|
var _a;
|
|
1457
|
-
|
|
1458
|
-
var
|
|
1459
|
-
|
|
1460
|
-
// Just in case, break the cycle
|
|
1461
|
-
return React.createElement(PlasmicLinkInternal, __assign({}, props, { ref: ref }));
|
|
1371
|
+
var children = [];
|
|
1372
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1373
|
+
children[_i - 2] = arguments[_i];
|
|
1462
1374
|
}
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1375
|
+
var override = props["data-plasmic-override"];
|
|
1376
|
+
var wrapFlexChild = props["data-plasmic-wrap-flex-child"];
|
|
1377
|
+
var triggerProps = ((_a = props["data-plasmic-trigger-props"]) !== null && _a !== void 0 ? _a : []);
|
|
1378
|
+
delete props["data-plasmic-override"];
|
|
1379
|
+
delete props["data-plasmic-wrap-flex-child"];
|
|
1380
|
+
delete props["data-plasmic-trigger-props"];
|
|
1381
|
+
return createPlasmicElement(override, defaultElement, mergeProps.apply(void 0, __spreadArray([props,
|
|
1382
|
+
children.length === 0
|
|
1383
|
+
? {}
|
|
1384
|
+
: { children: children.length === 1 ? children[0] : children }], __read(triggerProps), false)), wrapFlexChild);
|
|
1385
|
+
}
|
|
1386
|
+
function makeFragment() {
|
|
1387
|
+
var children = [];
|
|
1388
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1389
|
+
children[_i] = arguments[_i];
|
|
1466
1390
|
}
|
|
1467
|
-
});
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
if (
|
|
1473
|
-
|
|
1474
|
-
"href",
|
|
1475
|
-
"replace",
|
|
1476
|
-
"scroll",
|
|
1477
|
-
"shallow",
|
|
1478
|
-
"passHref",
|
|
1479
|
-
"prefetch",
|
|
1480
|
-
"locale",
|
|
1481
|
-
];
|
|
1482
|
-
// If this is a fragment identifier link, then we set
|
|
1483
|
-
// scroll={false} so that smooth scrolling works
|
|
1484
|
-
var isFragment = (_a = props.href) === null || _a === void 0 ? void 0 : _a.startsWith("#");
|
|
1485
|
-
return React.createElement(props.component, __assign(__assign({ scroll: !isFragment }, pick.apply(void 0, __spreadArray([props], __read(nextjsProps), false))), { legacyBehavior: true }), React.createElement("a", __assign({}, omit.apply(void 0, __spreadArray([props, "component", "platform"], __read(nextjsProps), false)), { ref: ref })));
|
|
1391
|
+
return React__namespace.createElement.apply(React__namespace, __spreadArray([React__namespace.Fragment, {}], __read(children), false));
|
|
1392
|
+
}
|
|
1393
|
+
var UNSET = Symbol("UNSET");
|
|
1394
|
+
function mergeOverrideProps(defaults, overrides) {
|
|
1395
|
+
var e_1, _a;
|
|
1396
|
+
if (!overrides) {
|
|
1397
|
+
return defaults;
|
|
1486
1398
|
}
|
|
1487
|
-
|
|
1488
|
-
|
|
1399
|
+
var result = __assign({}, defaults);
|
|
1400
|
+
try {
|
|
1401
|
+
for (var _b = __values(Object.keys(overrides)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1402
|
+
var key = _c.value;
|
|
1403
|
+
var defaultVal = defaults[key];
|
|
1404
|
+
var overrideVal = overrides[key];
|
|
1405
|
+
if (overrideVal === UNSET) {
|
|
1406
|
+
delete result[key];
|
|
1407
|
+
}
|
|
1408
|
+
else {
|
|
1409
|
+
// We use the NONE sentinel if the overrideVal is nil, and is not one of the
|
|
1410
|
+
// props that we merge by default -- which are className, style, and
|
|
1411
|
+
// event handlers. This means for all other "normal" props -- like children,
|
|
1412
|
+
// title, etc -- a nil value will unset the default.
|
|
1413
|
+
if (overrideVal == null &&
|
|
1414
|
+
key !== "className" &&
|
|
1415
|
+
key !== "style" &&
|
|
1416
|
+
!(key.startsWith("on") && typeof defaultVal === "function")) {
|
|
1417
|
+
overrideVal = NONE;
|
|
1418
|
+
}
|
|
1419
|
+
result[key] = mergePropVals(key, defaultVal, overrideVal);
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1489
1422
|
}
|
|
1490
|
-
|
|
1491
|
-
|
|
1423
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1424
|
+
finally {
|
|
1425
|
+
try {
|
|
1426
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1427
|
+
}
|
|
1428
|
+
finally { if (e_1) throw e_1.error; }
|
|
1492
1429
|
}
|
|
1493
|
-
return
|
|
1494
|
-
});
|
|
1495
|
-
function isInternalHref(href) {
|
|
1496
|
-
return /^\/(?!\/)/.test(href);
|
|
1430
|
+
return result;
|
|
1497
1431
|
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
var usePlasmicTranslator = host.usePlasmicTranslator !== null && host.usePlasmicTranslator !== void 0 ? host.usePlasmicTranslator : (function () {
|
|
1502
|
-
var _t = React.useContext(PlasmicTranslatorContext);
|
|
1503
|
-
var translator = _t
|
|
1504
|
-
? typeof _t === "function"
|
|
1505
|
-
? _t
|
|
1506
|
-
: _t.translator
|
|
1432
|
+
function wrapWithClassName(element, className) {
|
|
1433
|
+
var key = React__namespace.isValidElement(element)
|
|
1434
|
+
? element.key || undefined
|
|
1507
1435
|
: undefined;
|
|
1508
|
-
return
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
if (!node) {
|
|
1516
|
-
return "";
|
|
1517
|
-
}
|
|
1518
|
-
if (typeof node === "number" ||
|
|
1519
|
-
typeof node === "boolean" ||
|
|
1520
|
-
typeof node === "string") {
|
|
1521
|
-
return node.toString();
|
|
1522
|
-
}
|
|
1523
|
-
if (typeof node !== "object") {
|
|
1524
|
-
return "";
|
|
1525
|
-
}
|
|
1526
|
-
if (Array.isArray(node) || isIterable(node)) {
|
|
1527
|
-
return Array.from(node)
|
|
1528
|
-
.map(function (child) { return getText(child); })
|
|
1529
|
-
.filter(function (child) { return !!child; })
|
|
1530
|
-
.join("");
|
|
1531
|
-
}
|
|
1532
|
-
var nodeChildren = (hasKey(node, "props") &&
|
|
1533
|
-
hasKey(node.props, "children") &&
|
|
1534
|
-
node.props.children) ||
|
|
1535
|
-
(hasKey(node, "children") && node.children) ||
|
|
1536
|
-
[];
|
|
1537
|
-
var contents = "".concat(React.Children.toArray(nodeChildren)
|
|
1538
|
-
.map(function (child) { return getText(child); })
|
|
1539
|
-
.filter(function (child) { return !!child; })
|
|
1540
|
-
.join(""));
|
|
1541
|
-
if (React.isValidElement(node) && node.type === React.Fragment) {
|
|
1542
|
-
return contents;
|
|
1543
|
-
}
|
|
1544
|
-
var prefix = (_a = opts === null || opts === void 0 ? void 0 : opts.tagPrefix) !== null && _a !== void 0 ? _a : "";
|
|
1545
|
-
var componentId = "".concat(prefix).concat(componentsCount + 1);
|
|
1546
|
-
componentsCount++;
|
|
1547
|
-
components[componentId] = React.isValidElement(node)
|
|
1548
|
-
? React.cloneElement(node, {
|
|
1549
|
-
key: componentId,
|
|
1550
|
-
children: undefined,
|
|
1551
|
-
})
|
|
1552
|
-
: node;
|
|
1553
|
-
return "<".concat(componentId, ">").concat(contents, "</").concat(componentId, ">");
|
|
1554
|
-
};
|
|
1555
|
-
var str = getText(elt);
|
|
1556
|
-
return {
|
|
1557
|
-
str: str,
|
|
1558
|
-
components: components,
|
|
1559
|
-
componentsCount: componentsCount,
|
|
1560
|
-
};
|
|
1436
|
+
return React__namespace.createElement("div", {
|
|
1437
|
+
key: key,
|
|
1438
|
+
className: className,
|
|
1439
|
+
style: {
|
|
1440
|
+
display: "grid",
|
|
1441
|
+
},
|
|
1442
|
+
}, element);
|
|
1561
1443
|
}
|
|
1562
|
-
function
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
if (
|
|
1571
|
-
|
|
1572
|
-
return
|
|
1444
|
+
function deriveOverride(x) {
|
|
1445
|
+
if (!x) {
|
|
1446
|
+
// undefined Binding is an empty Binding
|
|
1447
|
+
return {
|
|
1448
|
+
type: "default",
|
|
1449
|
+
props: {},
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
else if (isReactNode(x)) {
|
|
1453
|
+
// If ReactNode, then assume this is the children
|
|
1454
|
+
return {
|
|
1455
|
+
type: "default",
|
|
1456
|
+
props: {
|
|
1457
|
+
children: x,
|
|
1458
|
+
},
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
else if (typeof x === "object") {
|
|
1462
|
+
// If any of the overrideKeys is a key of this object, then assume
|
|
1463
|
+
// this is a full Override
|
|
1464
|
+
if ("as" in x) {
|
|
1465
|
+
return __assign(__assign({}, x), { props: x.props || {}, type: "as" });
|
|
1466
|
+
}
|
|
1467
|
+
else if ("render" in x) {
|
|
1468
|
+
return __assign(__assign({}, x), { type: "render" });
|
|
1469
|
+
}
|
|
1470
|
+
else if ("props" in x) {
|
|
1471
|
+
return __assign(__assign({}, x), { props: x.props || {}, type: "default" });
|
|
1472
|
+
}
|
|
1473
|
+
else if (isSubset(Object.keys(x), ["wrap", "wrapChildren"])) {
|
|
1474
|
+
// Only twiddling functions present, so assume no props overrides
|
|
1475
|
+
// (otherwise we'd assume these were props).
|
|
1476
|
+
return __assign(__assign({}, x), { props: {}, type: "default" });
|
|
1477
|
+
}
|
|
1478
|
+
// Else, assume this is just a props object.
|
|
1479
|
+
return {
|
|
1480
|
+
type: "default",
|
|
1481
|
+
props: x,
|
|
1482
|
+
};
|
|
1573
1483
|
}
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
}
|
|
1579
|
-
var hasWarned = false;
|
|
1580
|
-
function warnNoTranslationFunctionAtMostOnce() {
|
|
1581
|
-
if (!hasWarned) {
|
|
1582
|
-
console.warn("Using Plasmic Translation but no translation function has been provided");
|
|
1583
|
-
hasWarned = true;
|
|
1484
|
+
else if (typeof x === "function") {
|
|
1485
|
+
return {
|
|
1486
|
+
type: "render",
|
|
1487
|
+
render: x,
|
|
1488
|
+
};
|
|
1584
1489
|
}
|
|
1490
|
+
throw new Error("Unexpected override: ".concat(x));
|
|
1585
1491
|
}
|
|
1586
|
-
function
|
|
1587
|
-
|
|
1492
|
+
function mergeVariants(v1, v2) {
|
|
1493
|
+
if (!v1 || !v2) {
|
|
1494
|
+
return v1 || v2 || {};
|
|
1495
|
+
}
|
|
1496
|
+
return __assign(__assign({}, v1), v2);
|
|
1588
1497
|
}
|
|
1589
|
-
function
|
|
1590
|
-
return
|
|
1498
|
+
function mergeVariantsWithStates(variants, $state, linkedStates) {
|
|
1499
|
+
return __assign(__assign({}, variants), Object.fromEntries(linkedStates.map(function (_a) {
|
|
1500
|
+
var variantGroup = _a.variantGroup, statePath = _a.statePath;
|
|
1501
|
+
return [
|
|
1502
|
+
variantGroup,
|
|
1503
|
+
get($state, statePath),
|
|
1504
|
+
];
|
|
1505
|
+
})));
|
|
1591
1506
|
}
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1507
|
+
function mergeArgs(a1, a2) {
|
|
1508
|
+
if (!a1 || !a2) {
|
|
1509
|
+
return a1 || a2 || {};
|
|
1510
|
+
}
|
|
1511
|
+
return __assign(__assign({}, a1), a2);
|
|
1595
1512
|
}
|
|
1596
|
-
function
|
|
1597
|
-
var
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
(!content || (Array.isArray(content) && content.length === 0))) {
|
|
1601
|
-
return null;
|
|
1513
|
+
function mergeFlexOverrides(o1, o2) {
|
|
1514
|
+
var e_2, _a;
|
|
1515
|
+
if (!o2) {
|
|
1516
|
+
return o1;
|
|
1602
1517
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1518
|
+
var keys = Array.from(new Set(__spreadArray(__spreadArray([], __read(Object.keys(o1)), false), __read(Object.keys(o2)), false)));
|
|
1519
|
+
var merged = {};
|
|
1520
|
+
try {
|
|
1521
|
+
for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
|
|
1522
|
+
var key = keys_1_1.value;
|
|
1523
|
+
merged[key] = mergeFlexOverride(o1[key], o2[key]);
|
|
1524
|
+
}
|
|
1609
1525
|
}
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1526
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1527
|
+
finally {
|
|
1528
|
+
try {
|
|
1529
|
+
if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
|
|
1530
|
+
}
|
|
1531
|
+
finally { if (e_2) throw e_2.error; }
|
|
1615
1532
|
}
|
|
1616
|
-
return
|
|
1533
|
+
return merged;
|
|
1617
1534
|
}
|
|
1618
|
-
function
|
|
1619
|
-
|
|
1620
|
-
if (
|
|
1621
|
-
|
|
1622
|
-
if (node.type === React__namespace.Fragment) {
|
|
1623
|
-
return maybeAsString(node.props.children);
|
|
1624
|
-
}
|
|
1625
|
-
else if (node.type === Trans) {
|
|
1626
|
-
// Trans also doesn't render DOM elements. But we don't want to just render
|
|
1627
|
-
// its content string, because we want to keep the <Trans/> for the localization.
|
|
1628
|
-
// So we render the same node, to be wrapped into __wab_slot-string-wrapper.
|
|
1629
|
-
return node;
|
|
1630
|
-
}
|
|
1535
|
+
function mergeFlexOverride(fo1, fo2) {
|
|
1536
|
+
var _a, _b;
|
|
1537
|
+
if (!fo1) {
|
|
1538
|
+
return fo2;
|
|
1631
1539
|
}
|
|
1632
|
-
if (
|
|
1633
|
-
return
|
|
1540
|
+
if (!fo2) {
|
|
1541
|
+
return fo1;
|
|
1634
1542
|
}
|
|
1635
|
-
|
|
1636
|
-
|
|
1543
|
+
var o1 = deriveOverride(fo1);
|
|
1544
|
+
var o2 = deriveOverride(fo2);
|
|
1545
|
+
var wrap = chainSingleArgFuncs.apply(void 0, __spreadArray([], __read([o1.wrap, o2.wrap].filter(notNil)), false));
|
|
1546
|
+
var wrapChildren = chainSingleArgFuncs.apply(void 0, __spreadArray([], __read([o1.wrapChildren, o2.wrapChildren].filter(notNil)), false));
|
|
1547
|
+
// "render" type always takes precedence, but we still merge the props
|
|
1548
|
+
var props = mergeOverrideProps((_a = o1.props) !== null && _a !== void 0 ? _a : {}, o2.props);
|
|
1549
|
+
if (o2.type === "render") {
|
|
1550
|
+
return {
|
|
1551
|
+
render: o2.render,
|
|
1552
|
+
props: props,
|
|
1553
|
+
wrap: wrap,
|
|
1554
|
+
wrapChildren: wrapChildren,
|
|
1555
|
+
};
|
|
1637
1556
|
}
|
|
1638
|
-
if (
|
|
1639
|
-
return
|
|
1557
|
+
if (o1.type === "render") {
|
|
1558
|
+
return {
|
|
1559
|
+
render: o1.render,
|
|
1560
|
+
props: props,
|
|
1561
|
+
wrap: wrap,
|
|
1562
|
+
wrapChildren: wrapChildren,
|
|
1563
|
+
};
|
|
1640
1564
|
}
|
|
1641
|
-
|
|
1565
|
+
// "as" will take precedence
|
|
1566
|
+
var as = (_b = (o2.type === "as" ? o2.as : undefined)) !== null && _b !== void 0 ? _b : (o1.type === "as" ? o1.as : undefined);
|
|
1567
|
+
return __assign({ props: props, wrap: wrap, wrapChildren: wrapChildren }, (as ? { as: as } : {}));
|
|
1568
|
+
}
|
|
1569
|
+
function deriveRenderOpts(props, config) {
|
|
1570
|
+
var _a;
|
|
1571
|
+
var name = config.name, descendantNames = config.descendantNames, internalVariantPropNames = config.internalVariantPropNames, internalArgPropNames = config.internalArgPropNames;
|
|
1572
|
+
var reservedPropNames = ["variants", "args", "overrides"];
|
|
1573
|
+
var variants = mergeVariants(omit.apply(void 0, __spreadArray([pick.apply(void 0, __spreadArray([props], __read(internalVariantPropNames), false))], __read(reservedPropNames), false)), props.variants);
|
|
1574
|
+
var args = mergeArgs(omit.apply(void 0, __spreadArray([pick.apply(void 0, __spreadArray([props], __read(internalArgPropNames), false))], __read(reservedPropNames), false)), props.args);
|
|
1575
|
+
var overrides = mergeFlexOverrides(omit.apply(void 0, __spreadArray(__spreadArray(__spreadArray([pick.apply(void 0, __spreadArray([props], __read(descendantNames), false))], __read(internalArgPropNames), false), __read(internalVariantPropNames), false), __read(reservedPropNames), false)), props.overrides);
|
|
1576
|
+
var leftoverProps = omit.apply(void 0, __spreadArray(__spreadArray(__spreadArray([props,
|
|
1577
|
+
"variants",
|
|
1578
|
+
"args",
|
|
1579
|
+
"overrides"], __read(descendantNames), false), __read(internalVariantPropNames), false), __read(internalArgPropNames), false));
|
|
1580
|
+
if (Object.keys(leftoverProps).length > 0) {
|
|
1581
|
+
overrides = mergeFlexOverrides(overrides, (_a = {},
|
|
1582
|
+
_a[name] = {
|
|
1583
|
+
props: leftoverProps,
|
|
1584
|
+
},
|
|
1585
|
+
_a));
|
|
1586
|
+
}
|
|
1587
|
+
return { variants: variants, args: args, overrides: overrides };
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
function renderStack(as, props, hasGap, ref) {
|
|
1591
|
+
var children = props.children, rest = __rest(props, ["children"]);
|
|
1592
|
+
var wrappedChildren = wrapFlexContainerChildren(children, hasGap !== null && hasGap !== void 0 ? hasGap : false);
|
|
1593
|
+
return createElementWithChildren(as, __assign({ ref: ref }, rest), wrappedChildren);
|
|
1594
|
+
}
|
|
1595
|
+
function FlexStack_(props, outerRef) {
|
|
1596
|
+
var as = props.as, hasGap = props.hasGap, rest = __rest(props, ["as", "hasGap"]);
|
|
1597
|
+
return renderStack(as !== null && as !== void 0 ? as : "div", rest, hasGap, outerRef);
|
|
1598
|
+
}
|
|
1599
|
+
var FlexStack = React__namespace.forwardRef(FlexStack_);
|
|
1600
|
+
var makeStackImpl = function (as) {
|
|
1601
|
+
return React__namespace.forwardRef(function (props, ref) {
|
|
1602
|
+
var hasGap = props.hasGap, rest = __rest(props, ["hasGap"]);
|
|
1603
|
+
return renderStack(as, rest, hasGap, ref);
|
|
1604
|
+
});
|
|
1605
|
+
};
|
|
1606
|
+
var Stack = Object.assign(FlexStack, {
|
|
1607
|
+
div: makeStackImpl("div"),
|
|
1608
|
+
a: makeStackImpl("a"),
|
|
1609
|
+
button: makeStackImpl("button"),
|
|
1610
|
+
h1: makeStackImpl("h1"),
|
|
1611
|
+
h2: makeStackImpl("h2"),
|
|
1612
|
+
h3: makeStackImpl("h3"),
|
|
1613
|
+
h4: makeStackImpl("h4"),
|
|
1614
|
+
h5: makeStackImpl("h5"),
|
|
1615
|
+
h6: makeStackImpl("h6"),
|
|
1616
|
+
label: makeStackImpl("label"),
|
|
1617
|
+
form: makeStackImpl("form"),
|
|
1618
|
+
section: makeStackImpl("section"),
|
|
1619
|
+
head: makeStackImpl("head"),
|
|
1620
|
+
main: makeStackImpl("main"),
|
|
1621
|
+
nav: makeStackImpl("nav"),
|
|
1622
|
+
});
|
|
1623
|
+
|
|
1624
|
+
var isDefaultValue = function (val) {
|
|
1625
|
+
return val === "PLEASE_RENDER_INSIDE_PROVIDER";
|
|
1626
|
+
};
|
|
1627
|
+
var seenDefaultVariants = {};
|
|
1628
|
+
/**
|
|
1629
|
+
* Usage:
|
|
1630
|
+
* ```
|
|
1631
|
+
* // plasmic.ts
|
|
1632
|
+
* import { usePlatform } from "./PlasmicGlobalVariant__Platform";
|
|
1633
|
+
* import { useTheme } from "./PlasmicGlobalVariant__Theme";
|
|
1634
|
+
*
|
|
1635
|
+
* export const useGlobalVariants = createUseGlobalVariants({
|
|
1636
|
+
* platform: usePlatform,
|
|
1637
|
+
* theme: useTheme,
|
|
1638
|
+
* });
|
|
1639
|
+
*
|
|
1640
|
+
* // PlasmicComponent.tsx
|
|
1641
|
+
* import { useGlobalVariants } from "./plasmic_project";
|
|
1642
|
+
*
|
|
1643
|
+
* export function PlasmicComponent() {
|
|
1644
|
+
* // ...
|
|
1645
|
+
* const globalVariants = useGlobalVariants();
|
|
1646
|
+
* // ...
|
|
1647
|
+
* }
|
|
1648
|
+
* ```
|
|
1649
|
+
*/
|
|
1650
|
+
function createUseGlobalVariants(globalVariantHooks) {
|
|
1651
|
+
return function () {
|
|
1652
|
+
return ensureGlobalVariants(Object.fromEntries(Object.entries(globalVariantHooks).map(function (_a) {
|
|
1653
|
+
var _b = __read(_a, 2), globalVariant = _b[0], useHook = _b[1];
|
|
1654
|
+
return [globalVariant, useHook()];
|
|
1655
|
+
})));
|
|
1656
|
+
};
|
|
1657
|
+
}
|
|
1658
|
+
/**
|
|
1659
|
+
* @deprecated - new generated code should use `useGlobalVariants` instead
|
|
1660
|
+
*
|
|
1661
|
+
* Usage:
|
|
1662
|
+
* ```
|
|
1663
|
+
* // PlasmicComponent.tsx
|
|
1664
|
+
* import { useTheme } from "./PlasmicGlobalVariant__Theme";
|
|
1665
|
+
* import { usePlatform } from "./PlasmicGlobalVariant__Platform";
|
|
1666
|
+
*
|
|
1667
|
+
* export function PlasmicComponent() {
|
|
1668
|
+
* // ...
|
|
1669
|
+
* const globalVariants = ensureGlobalVariants({
|
|
1670
|
+
* platform: usePlatform(),
|
|
1671
|
+
* theme: useTheme(),
|
|
1672
|
+
* });
|
|
1673
|
+
* // ...
|
|
1674
|
+
* }
|
|
1675
|
+
* ```
|
|
1676
|
+
*/
|
|
1677
|
+
function ensureGlobalVariants(globalVariants) {
|
|
1678
|
+
Object.entries(globalVariants)
|
|
1679
|
+
.filter(function (_a) {
|
|
1680
|
+
var _b = __read(_a, 2); _b[0]; var value = _b[1];
|
|
1681
|
+
return isDefaultValue(value);
|
|
1682
|
+
})
|
|
1683
|
+
.forEach(function (_a) {
|
|
1684
|
+
var _b = __read(_a, 2), key = _b[0]; _b[1];
|
|
1685
|
+
globalVariants[key] = undefined;
|
|
1686
|
+
if (!seenDefaultVariants[key] && process.env.NODE_ENV === "development") {
|
|
1687
|
+
seenDefaultVariants[key] = true;
|
|
1688
|
+
var providerName = "".concat(key[0].toUpperCase()).concat(key.substring(1), "Context.Provider");
|
|
1689
|
+
console.warn("Plasmic context value for global variant \"".concat(key, "\" was not provided; please use ").concat(providerName, " at the root of your React app. Learn More: https://www.plasmic.app/learn/other-assets/#global-variants"));
|
|
1690
|
+
}
|
|
1691
|
+
});
|
|
1692
|
+
return globalVariants;
|
|
1642
1693
|
}
|
|
1643
1694
|
|
|
1644
1695
|
var listeners = [];
|
|
@@ -1784,6 +1835,115 @@ function MaybeWrap(props) {
|
|
|
1784
1835
|
return props.cond ? props.wrapper(props.children) : props.children;
|
|
1785
1836
|
}
|
|
1786
1837
|
|
|
1838
|
+
/**
|
|
1839
|
+
* Context that enables a project's style tokens to be propagated across projects.
|
|
1840
|
+
*
|
|
1841
|
+
* The value is an array of class names, including the class name for the base
|
|
1842
|
+
* variant and active global variants. The class names should be applied to all
|
|
1843
|
+
* Plasmic content.
|
|
1844
|
+
*/
|
|
1845
|
+
var StyleTokensContext = React.createContext(undefined);
|
|
1846
|
+
/**
|
|
1847
|
+
* Returns style tokens. If the context is not available, falls back to the
|
|
1848
|
+
* current project's styles.
|
|
1849
|
+
*
|
|
1850
|
+
* Usage:
|
|
1851
|
+
* ```
|
|
1852
|
+
* // PlasmicStyleTokensProvider.ts
|
|
1853
|
+
* export const useStyleTokens = createUseStyleTokens(
|
|
1854
|
+
* projectStyleTokenData,
|
|
1855
|
+
* useGlobalVariants,
|
|
1856
|
+
* );
|
|
1857
|
+
*
|
|
1858
|
+
* // PlasmicPage.tsx
|
|
1859
|
+
* import { useStyleTokens } from "./plasmic_project";
|
|
1860
|
+
*
|
|
1861
|
+
* export function PlasmicPage() {
|
|
1862
|
+
* const styleTokensClassNames = useStyleTokens();
|
|
1863
|
+
* return (
|
|
1864
|
+
* <div className={classNames(
|
|
1865
|
+
* projectcss.all,
|
|
1866
|
+
* projectcss.root_reset,
|
|
1867
|
+
* projectcss.plasmic_default_styles,
|
|
1868
|
+
* projectcss.plasmic_mixins,
|
|
1869
|
+
* styleTokensClassNames,
|
|
1870
|
+
* )}>
|
|
1871
|
+
* <h1 className={projectcss.all}>
|
|
1872
|
+
* Hello, world!
|
|
1873
|
+
* </h1>
|
|
1874
|
+
* </div>
|
|
1875
|
+
* );
|
|
1876
|
+
* }
|
|
1877
|
+
* ```
|
|
1878
|
+
*/
|
|
1879
|
+
function createUseStyleTokens(tokenData, useGlobalVariants) {
|
|
1880
|
+
return function () {
|
|
1881
|
+
var overrides = React.useContext(StyleTokensContext);
|
|
1882
|
+
var globalVariants = useGlobalVariants();
|
|
1883
|
+
return React.useMemo(function () {
|
|
1884
|
+
if (overrides && overrides.length > 0) {
|
|
1885
|
+
return overrides;
|
|
1886
|
+
}
|
|
1887
|
+
else {
|
|
1888
|
+
return activeTokensClassNames(tokenData, globalVariants);
|
|
1889
|
+
}
|
|
1890
|
+
}, [overrides, globalVariants, tokenData]);
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
/**
|
|
1894
|
+
* Creates a StyleTokens context provider for a given project, which includes
|
|
1895
|
+
* its tokens, overrides, and all tokens from its dependencies.
|
|
1896
|
+
*
|
|
1897
|
+
* Usage:
|
|
1898
|
+
* ```
|
|
1899
|
+
* // PlasmicStyleTokensProvider.ts
|
|
1900
|
+
* export const StyleTokensProvider = createStyleTokensProvider(
|
|
1901
|
+
* projectStyleTokenData,
|
|
1902
|
+
* useGlobalVariants,
|
|
1903
|
+
* );
|
|
1904
|
+
*
|
|
1905
|
+
* // Page.tsx
|
|
1906
|
+
* import { StyleTokensProvider } from "./plasmic_project";
|
|
1907
|
+
*
|
|
1908
|
+
* export default function Page() {
|
|
1909
|
+
* return (
|
|
1910
|
+
* <PlatformContext.Provider value="osx">
|
|
1911
|
+
* <ThemeContext.Provider value="dark">
|
|
1912
|
+
* <StyleTokensProvider>
|
|
1913
|
+
* <PlasmicPage />
|
|
1914
|
+
* </StyleTokensProvider>
|
|
1915
|
+
* </ThemeContext.Provider>
|
|
1916
|
+
* </PlatformContext.Provider>
|
|
1917
|
+
* );
|
|
1918
|
+
* }
|
|
1919
|
+
* ```
|
|
1920
|
+
*/
|
|
1921
|
+
function createStyleTokensProvider(tokenData, useGlobalVariants) {
|
|
1922
|
+
return function (props) {
|
|
1923
|
+
var globalVariants = useGlobalVariants();
|
|
1924
|
+
var tokens = React.useMemo(function () {
|
|
1925
|
+
return activeTokensClassNames(tokenData, globalVariants);
|
|
1926
|
+
}, [globalVariants, tokenData]);
|
|
1927
|
+
return (React.createElement(StyleTokensContext.Provider, { value: tokens }, props.children));
|
|
1928
|
+
};
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Gets the class names for the base tokens and the varianted tokens for active
|
|
1932
|
+
* global variants.
|
|
1933
|
+
*/
|
|
1934
|
+
function activeTokensClassNames(tokenData, globalVariants) {
|
|
1935
|
+
var varianted = tokenData.varianted
|
|
1936
|
+
.filter(function (_a) {
|
|
1937
|
+
var groupName = _a.groupName, variant = _a.variant;
|
|
1938
|
+
return hasVariant(globalVariants, groupName, variant);
|
|
1939
|
+
})
|
|
1940
|
+
.map(function (_a) {
|
|
1941
|
+
var className = _a.className;
|
|
1942
|
+
return className;
|
|
1943
|
+
});
|
|
1944
|
+
return __spreadArray([tokenData.base], __read(varianted), false);
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1787
1947
|
function useFocused(opts) {
|
|
1788
1948
|
var _a = focus.useFocusRing({
|
|
1789
1949
|
within: false,
|
|
@@ -4119,7 +4279,10 @@ exports.Trans = Trans;
|
|
|
4119
4279
|
exports.TriggeredOverlayContext = TriggeredOverlayContext;
|
|
4120
4280
|
exports.classNames = classNames;
|
|
4121
4281
|
exports.createPlasmicElementProxy = createPlasmicElementProxy;
|
|
4282
|
+
exports.createStyleTokensProvider = createStyleTokensProvider;
|
|
4283
|
+
exports.createUseGlobalVariants = createUseGlobalVariants;
|
|
4122
4284
|
exports.createUseScreenVariants = createUseScreenVariants;
|
|
4285
|
+
exports.createUseStyleTokens = createUseStyleTokens;
|
|
4123
4286
|
exports.deriveRenderOpts = deriveRenderOpts;
|
|
4124
4287
|
exports.ensureGlobalVariants = ensureGlobalVariants;
|
|
4125
4288
|
exports.genTranslatableString = genTranslatableString;
|