@plasmicapp/react-web 0.2.99 → 0.2.100
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/react-web.cjs.development.js +1 -1
- package/dist/react-web.cjs.development.js.map +1 -1
- package/dist/react-web.cjs.production.min.js +1 -1
- package/dist/react-web.cjs.production.min.js.map +1 -1
- package/dist/react-web.esm.js +1 -1
- package/dist/react-web.esm.js.map +1 -1
- package/package.json +1 -1
- package/skinny/dist/render/PlasmicImg/index.js +1 -1
- package/skinny/dist/render/PlasmicImg/index.js.map +1 -1
- package/skinny/dist/collection-utils-3487dd27.js +0 -238
- package/skinny/dist/collection-utils-3487dd27.js.map +0 -1
- package/skinny/dist/collection-utils-47e89cbe.js +0 -238
- package/skinny/dist/collection-utils-47e89cbe.js.map +0 -1
- package/skinny/dist/collection-utils-4dae6efa.js +0 -292
- package/skinny/dist/collection-utils-4dae6efa.js.map +0 -1
- package/skinny/dist/collection-utils-57ec40f9.js +0 -292
- package/skinny/dist/collection-utils-57ec40f9.js.map +0 -1
- package/skinny/dist/collection-utils-96cde83c.js +0 -238
- package/skinny/dist/collection-utils-96cde83c.js.map +0 -1
- package/skinny/dist/collection-utils-b0b8f30e.js +0 -291
- package/skinny/dist/collection-utils-b0b8f30e.js.map +0 -1
- package/skinny/dist/plume-utils-5c413fd1.js +0 -35
- package/skinny/dist/plume-utils-5c413fd1.js.map +0 -1
- package/skinny/dist/props-utils-4633caf6.js +0 -8
- package/skinny/dist/props-utils-4633caf6.js.map +0 -1
- package/skinny/dist/props-utils-5c0ad25a.js +0 -59
- package/skinny/dist/props-utils-5c0ad25a.js.map +0 -1
- package/skinny/dist/props-utils-754f655a.js +0 -39
- package/skinny/dist/props-utils-754f655a.js.map +0 -1
- package/skinny/dist/props-utils-c632595f.js +0 -59
- package/skinny/dist/props-utils-c632595f.js.map +0 -1
- package/skinny/dist/props-utils-fd5f444e.js +0 -59
- package/skinny/dist/props-utils-fd5f444e.js.map +0 -1
- package/skinny/dist/react-utils-118d8539.js +0 -190
- package/skinny/dist/react-utils-118d8539.js.map +0 -1
- package/skinny/dist/react-utils-2a2fd6c9.js +0 -339
- package/skinny/dist/react-utils-2a2fd6c9.js.map +0 -1
- package/skinny/dist/react-utils-2d70bbbe.js +0 -172
- package/skinny/dist/react-utils-2d70bbbe.js.map +0 -1
- package/skinny/dist/react-utils-675565b4.js +0 -334
- package/skinny/dist/react-utils-675565b4.js.map +0 -1
- package/skinny/dist/render/PlasmicImg.d.ts +0 -62
- package/skinny/dist/ssr-64e38713.js +0 -108
- package/skinny/dist/ssr-64e38713.js.map +0 -1
- package/skinny/dist/ssr-902d1292.js +0 -105
- package/skinny/dist/ssr-902d1292.js.map +0 -1
- package/skinny/dist/ssr-a8081074.js +0 -108
- package/skinny/dist/ssr-a8081074.js.map +0 -1
- package/skinny/dist/ssr-d2fd94f2.js +0 -31
- package/skinny/dist/ssr-d2fd94f2.js.map +0 -1
- package/skinny/dist/tslib.es6-00014098.js +0 -148
- package/skinny/dist/tslib.es6-00014098.js.map +0 -1
- package/skinny/dist/tslib.es6-73236e8e.js +0 -141
- package/skinny/dist/tslib.es6-73236e8e.js.map +0 -1
package/package.json
CHANGED
|
@@ -65,7 +65,7 @@ var PlasmicImg = React__default.forwardRef(function PlasmicImg(props, outerRef)
|
|
|
65
65
|
? Buffer.from(spacerSvg).toString("base64")
|
|
66
66
|
: window.btoa(spacerSvg);
|
|
67
67
|
var wrapperStyle = __assign({}, (style || {}));
|
|
68
|
-
var spacerStyle = pick(style || {}, "objectFit", "objectPosition");
|
|
68
|
+
var spacerStyle = __assign({}, pick(style || {}, "objectFit", "objectPosition"));
|
|
69
69
|
if (displayWidth != null && displayWidth !== "auto") {
|
|
70
70
|
// If width is set, set it on the wrapper along with min/max width
|
|
71
71
|
// and just use `width: 100%` on the spacer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/render/PlasmicImg/index.tsx"],"sourcesContent":["/**\n * Responsive `<img/>` replacement, based on `next/image`\n */\n\nimport classNames from \"classnames\";\nimport React, { CSSProperties } from \"react\";\nimport { pick } from \"../../common\";\nimport { mergeRefs } from \"../../react-utils\";\n\nexport interface ImageLoader {\n supportsUrl: (url: string) => boolean;\n transformUrl: (opts: {\n src: string;\n width?: number;\n quality?: number;\n format?: \"webp\";\n }) => string;\n}\n\ntype ImgTagProps = Omit<\n React.ComponentProps<\"img\">,\n \"src\" | \"srcSet\" | \"ref\" | \"style\"\n>;\n\n// Default image sizes to snap to\n// TODO: make this configurable?\nconst IMG_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];\nconst DEVICE_SIZES = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];\nconst ALL_SIZES = [...IMG_SIZES, ...DEVICE_SIZES];\n\nexport interface PlasmicImgProps extends ImgTagProps {\n /**\n * Either an object with the src string, and its full width and height,\n * or just a src string with unknown intrinsic dimensions.\n */\n src?:\n | string\n | {\n src: string;\n fullHeight: number;\n fullWidth: number;\n // We might also get a more precise aspectRatio for SVGs\n // instead of relyiing on fullWidth / fullHeight, because\n // those values might be rounded and not so accurate.\n aspectRatio?: number;\n };\n\n /**\n * className applied to the wrapper element if one is used.\n */\n className?: string;\n\n /**\n * css width\n */\n displayWidth?: number | string;\n\n /**\n * css height\n */\n displayHeight?: number | string;\n\n /**\n * css min-width\n */\n displayMinWidth?: number | string;\n\n /**\n * css min-height\n */\n displayMinHeight?: number | string;\n\n /**\n * css max-width\n */\n displayMaxWidth?: number | string;\n\n /**\n * css max-height\n */\n displayMaxHeight?: number | string;\n\n /**\n * For variable quality formats like jpg, the quality from 0 to 100\n */\n quality?: number;\n\n /**\n * ImageLoader to use for loading different dimensions of the image.\n * If none specified, will not attempt to load different dimensions.\n */\n loader?: \"plasmic\" | ImageLoader;\n\n /**\n * Style applied to the wrapper element. objectFit and objectPosition\n * rules are applied to the img element.\n */\n style?: React.CSSProperties;\n\n /**\n * Ref for the img element. The normal <PlasmicImg ref={...} />\n * prop gives the root element instead, which may be the img element\n * or a wrapper element\n */\n imgRef?: React.Ref<HTMLImageElement>;\n}\n\nexport const PlasmicImg = React.forwardRef(function PlasmicImg(\n props: PlasmicImgProps,\n outerRef: React.Ref<HTMLElement>\n) {\n let {\n src,\n className,\n displayWidth,\n displayHeight,\n displayMinWidth,\n displayMinHeight,\n displayMaxWidth,\n displayMaxHeight,\n quality,\n loader,\n imgRef,\n style,\n loading,\n ...rest\n } = props;\n\n const imgProps = Object.assign({}, rest, {\n // Default loading to \"lazy\" if not specified (which is different from the\n // html img, which defaults to eager!)\n loading: loading ?? \"lazy\",\n });\n\n const { fullWidth, fullHeight, aspectRatio } =\n typeof src === \"string\" || !src\n ? { fullWidth: undefined, fullHeight: undefined, aspectRatio: undefined }\n : src;\n const srcStr = src ? (typeof src === \"string\" ? src : src.src) : \"\";\n\n // Assume external image if either dimension is null and use usual <img>\n if (fullHeight == null || fullWidth == null) {\n return (\n <img\n src={srcStr}\n className={className}\n style={style}\n {...imgProps}\n loading={loading}\n ref={mergeRefs(imgRef, outerRef) as any}\n />\n );\n }\n\n if (\n isSvg(srcStr) &&\n (displayHeight == null || displayHeight === \"auto\") &&\n (displayWidth == null || displayWidth === \"auto\")\n ) {\n displayWidth = \"100%\";\n }\n\n if (\n fullWidth &&\n fullHeight &&\n (!displayWidth || displayWidth === \"auto\") &&\n !!getPixelLength(displayHeight)\n ) {\n // If there's a pixel length specified for displayHeight but not displayWidth,\n // then we can derive the pixel length for displayWidth. Having an explicit\n // displayWidth makes this a fixed-size image, which makes it possible for us to\n // generate better markup!\n if (!isSvg(srcStr)) {\n // We shouldn't do it for SVGs though, because `fullWidth` and\n // `fullHeight` might have rounded values so the final\n // `displayWidth` could differ by 1px or so.\n displayWidth = (getPixelLength(displayHeight)! * fullWidth) / fullHeight;\n }\n }\n\n let spacerWidth = fullWidth;\n let spacerHeight = fullHeight;\n if (aspectRatio && isFinite(aspectRatio) && isSvg(srcStr)) {\n // For SVGs, fullWidth and fullHeight can be rounded values, which would\n // cause some discrepancy between the actual aspect ratio and the aspect\n // ratio from those values. So, for those cases, we set large width / height\n // values to get a more precise ratio from the spacer.\n spacerWidth = DEFAULT_SVG_WIDTH;\n spacerHeight = Math.round(spacerWidth / aspectRatio);\n }\n\n const { sizes, widthDescs } = getWidths(displayWidth, fullWidth, {\n minWidth: displayMinWidth,\n });\n const imageLoader = getImageLoader(loader);\n const spacerSvg = `<svg width=\"${spacerWidth}\" height=\"${spacerHeight}\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"/>`;\n const spacerSvgBase64 =\n typeof window === \"undefined\"\n ? Buffer.from(spacerSvg).toString(\"base64\")\n : window.btoa(spacerSvg);\n\n let wrapperStyle: CSSProperties = { ...(style || {}) };\n let spacerStyle: CSSProperties = pick(\n style || {},\n \"objectFit\",\n \"objectPosition\"\n );\n\n if (displayWidth != null && displayWidth !== \"auto\") {\n // If width is set, set it on the wrapper along with min/max width\n // and just use `width: 100%` on the spacer\n spacerStyle.width = \"100%\";\n // Rely on the styles set by `classname` on the wrapper:\n // wrapperStyle.width = displayWidth;\n // wrapperStyle.minWidth = displayMinWidth;\n // wrapperStyle.maxWidth = displayMaxWidth;\n } else {\n // Otherwise, we want auto sizing from the spacer, so set width there.\n //\n // But if we have min/max width, it should be set in the wrapper and it\n // can be percentage values (and we add corresponding min/max width to\n // 100% in the spacer). In general it ends up with the correct effect,\n // but some edge cases might make `min-width: 100%` shrink the image more\n // than it should.\n spacerStyle.width = displayWidth;\n wrapperStyle.width = \"auto\";\n if (displayMinWidth) {\n spacerStyle.minWidth = \"100%\";\n // Rely on min-width set by `classname` on the wrapper:\n // wrapperStyle.minWidth = displayMinWidth;\n }\n if (displayMaxWidth != null && displayMaxWidth !== \"none\") {\n spacerStyle.maxWidth = \"100%\";\n // Rely on max-width set by `classname` on the wrapper:\n // wrapperStyle.maxWidth = displayMaxWidth;\n }\n }\n\n if (displayHeight != null && displayHeight !== \"auto\") {\n spacerStyle.height = \"100%\";\n // wrapperStyle.height = displayHeight;\n // wrapperStyle.minHeight = displayMinHeight;\n // wrapperStyle.maxHeight = displayMaxHeight;\n } else {\n spacerStyle.height = displayHeight;\n wrapperStyle.height = \"auto\";\n if (displayMinHeight) {\n spacerStyle.minHeight = \"100%\";\n // wrapperStyle.minHeight = displayMinHeight;\n }\n if (displayMaxHeight != null && displayMaxHeight !== \"none\") {\n spacerStyle.maxHeight = \"100%\";\n // wrapperStyle.maxHeight = displayMaxHeight;\n }\n }\n\n return (\n <div\n className={classNames(className, \"__wab_img-wrapper\")}\n ref={outerRef as any}\n style={wrapperStyle}\n >\n <img\n alt=\"\"\n aria-hidden\n className=\"__wab_img-spacer-svg\"\n src={`data:image/svg+xml;base64,${spacerSvgBase64}`}\n style={spacerStyle}\n />\n {makePicture({\n imageLoader,\n widthDescs,\n sizes,\n src: srcStr,\n quality,\n ref: imgRef,\n style: style ? pick(style, \"objectFit\", \"objectPosition\") : undefined,\n imgProps,\n className: \"__wab_img\",\n })}\n </div>\n );\n});\n\nfunction makePicture(opts: {\n imageLoader?: ImageLoader;\n widthDescs: WidthDesc[];\n sizes?: string;\n src: string;\n quality?: number;\n style?: React.CSSProperties;\n className?: string;\n imgProps: ImgTagProps;\n ref?: React.Ref<HTMLImageElement>;\n}) {\n // If imageLoader is undefined, then this renders to just a normal\n // <img />. Else it will render to a <picture> with a <source> for\n // webp, and srcSet/sizes set according to width requirements.\n const {\n imageLoader,\n widthDescs,\n src,\n quality,\n style,\n className,\n sizes,\n imgProps,\n ref,\n } = opts;\n return (\n <picture className=\"__wab_picture\">\n {imageLoader && imageLoader.supportsUrl(src) && (\n <source\n type=\"image/webp\"\n srcSet={widthDescs\n .map(\n (wd) =>\n `${imageLoader.transformUrl({\n src,\n quality,\n width: wd.width,\n format: \"webp\",\n })} ${wd.desc}`\n )\n .join(\", \")}\n />\n )}\n <img\n {...imgProps}\n ref={ref}\n className={className}\n decoding=\"async\"\n src={\n imageLoader && imageLoader.supportsUrl(src)\n ? imageLoader.transformUrl({\n src,\n quality,\n width: widthDescs[widthDescs.length - 1].width,\n })\n : src\n }\n srcSet={\n imageLoader && imageLoader.supportsUrl(src)\n ? widthDescs\n .map(\n (wd) =>\n `${imageLoader.transformUrl({\n src,\n quality,\n width: wd.width,\n })} ${wd.desc}`\n )\n .join(\", \")\n : undefined\n }\n sizes={imageLoader && imageLoader.supportsUrl(src) ? sizes : undefined}\n style={{\n ...(style ? pick(style, \"objectFit\", \"objectPosition\") : {}),\n width: 0,\n height: 0,\n }}\n />\n </picture>\n );\n}\n\nconst DEFAULT_SVG_WIDTH = 10000;\n\nfunction isSvg(src: string) {\n return src.endsWith(\".svg\") || src.startsWith(\"data:image/svg\");\n}\n\ninterface WidthDesc {\n width?: number;\n desc: string;\n}\n\nfunction getClosestPresetSize(width: number, fullWidth: number) {\n const nextBiggerIndex =\n ALL_SIZES.findIndex((w) => w >= width) ?? ALL_SIZES.length - 1;\n const nextBigger = ALL_SIZES[nextBiggerIndex];\n if (nextBigger >= fullWidth) {\n // If the requested width is larger than the fullWidth,\n // we just use the original width instead. It's impossible\n // to make an image bigger than fullWidth!\n return undefined;\n } else if (\n nextBiggerIndex + 1 < ALL_SIZES.length &&\n fullWidth <= ALL_SIZES[nextBiggerIndex + 1]\n ) {\n // If the fullWidth is just between nextBigger and the one after that,\n // then also might as well just use the original size (so, width is 30,\n // nextBigger is 32, then we just use the original as long as fullWidth is\n // less than 48)\n return undefined;\n }\n\n return nextBigger;\n}\n\n/**\n * Computes the appropriate srcSet and sizes to use\n */\nfunction getWidths(\n width: number | string | undefined,\n fullWidth: number,\n extra?: { minWidth: string | number | undefined }\n): { sizes: string | undefined; widthDescs: WidthDesc[] } {\n const minWidth = extra?.minWidth;\n const pixelWidth = getPixelLength(width);\n const pixelMinWidth = getPixelLength(minWidth);\n if (pixelWidth != null && (!minWidth || pixelMinWidth != null)) {\n // If there's an exact width, then we just need to display it at 1x and 2x density\n return {\n widthDescs: [\n {\n width: getClosestPresetSize(\n Math.max(pixelWidth, pixelMinWidth ?? 0),\n fullWidth\n ),\n desc: \"1x\",\n },\n {\n width: getClosestPresetSize(\n Math.max(pixelWidth, pixelMinWidth ?? 0) * 2,\n fullWidth\n ),\n desc: \"2x\",\n },\n ],\n sizes: undefined,\n };\n }\n // Otherwise we don't know what sizes we'll end up, so we just cap it at\n // device width. TODO: do better!\n const usefulSizes = DEVICE_SIZES.filter(\n (size) => !fullWidth || size < fullWidth\n );\n if (!!fullWidth && usefulSizes.length === 0) {\n // image fullWidth is smaller than all device sizes. So all we can do\n // is offer 1x\n return {\n widthDescs: [\n {\n width: getClosestPresetSize(fullWidth, fullWidth),\n desc: \"1x\",\n },\n ],\n sizes: undefined,\n };\n }\n return {\n widthDescs: usefulSizes.map((size) => ({\n width: getClosestPresetSize(size, fullWidth),\n // If this is the last (buggest) useful width, but it is\n // still within the bounds set by DEVICE_SIZES, then just\n // use the original, unresized image. This means if we match\n // the largest size, we use unresized and best quality image.\n // We only do this, though, if fullWidth is \"reasonable\" --\n // smaller than the largest size we would consider.\n // i === usefulSizes.length - 1 &&\n // fullWidth < DEVICE_SIZES[DEVICE_SIZES.length - 1]\n // ? undefined\n // : size,\n desc: `${size}w`,\n })),\n sizes: \"100vw\",\n };\n}\n\nfunction getPixelLength(length: number | string | undefined) {\n if (length == null || length == \"\") {\n return undefined;\n }\n\n if (typeof length === \"number\") {\n return length;\n }\n\n const parsed = parseNumeric(length);\n if (parsed && (!parsed.units || parsed.units === \"px\")) {\n return parsed.num;\n }\n\n return undefined;\n}\n\nfunction parseNumeric(val: string) {\n // Parse strings like \"30\", \"30px\", \"30%\", \"30px /* blah blah */\"\n const res = val.match(\n /^\\s*(-?(?:\\d+\\.\\d*|\\d*\\.\\d+|\\d+))\\s*([a-z]*|%)\\s*(?:\\/\\*.*)?$/i\n );\n if (res == null) {\n return undefined;\n }\n const num = res[1];\n const units = res[2];\n return { num: +num, units };\n}\n\nfunction getImageLoader(loader: \"plasmic\" | ImageLoader | undefined) {\n if (loader == null) {\n return undefined;\n } else if (loader === \"plasmic\") {\n return PLASMIC_IMAGE_LOADER;\n } else {\n return loader;\n }\n}\n\nconst PLASMIC_IMAGE_LOADER: ImageLoader = {\n supportsUrl: (src) => {\n return src.startsWith(\"https://img.plasmic.app\") && !isSvg(src);\n },\n transformUrl: (opts) => {\n const params = [\n opts.width ? `w=${opts.width}` : undefined,\n `q=${opts.quality ?? 75}`,\n opts.format ? `f=${opts.format}` : undefined,\n ].filter((x) => !!x);\n return `${opts.src}?${params.join(\"&\")}`;\n },\n};\n"],"names":["React"],"mappings":";;;;;AAAA;;;AAwBA;AACA;AACA,IAAM,SAAS,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACtD,IAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACnE,IAAM,SAAS,mCAAO,SAAS,GAAK,YAAY,CAAC,CAAC;IA+ErC,UAAU,GAAGA,cAAK,CAAC,UAAU,CAAC,SAAS,UAAU,CAC5D,KAAsB,EACtB,QAAgC;IAG9B,IAAA,GAAG,GAcD,KAAK,IAdJ,EACH,SAAS,GAaP,KAAK,UAbE,EACT,YAAY,GAYV,KAAK,aAZK,EACZ,aAAa,GAWX,KAAK,cAXM,EACb,eAAe,GAUb,KAAK,gBAVQ,EACf,gBAAgB,GASd,KAAK,iBATS,EAChB,eAAe,GAQb,KAAK,gBARQ,EACf,gBAAgB,GAOd,KAAK,iBAPS,EAChB,OAAO,GAML,KAAK,QANA,EACP,MAAM,GAKJ,KAAK,OALD,EACN,MAAM,GAIJ,KAAK,OAJD,EACN,KAAK,GAGH,KAAK,MAHF,EACL,OAAO,GAEL,KAAK,QAFA,EACJ,IAAI,UACL,KAAK,EAfL,sLAe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CAAG,CAAC;KAC1C;CACF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/render/PlasmicImg/index.tsx"],"sourcesContent":["/**\n * Responsive `<img/>` replacement, based on `next/image`\n */\n\nimport classNames from \"classnames\";\nimport React, { CSSProperties } from \"react\";\nimport { pick } from \"../../common\";\nimport { mergeRefs } from \"../../react-utils\";\n\nexport interface ImageLoader {\n supportsUrl: (url: string) => boolean;\n transformUrl: (opts: {\n src: string;\n width?: number;\n quality?: number;\n format?: \"webp\";\n }) => string;\n}\n\ntype ImgTagProps = Omit<\n React.ComponentProps<\"img\">,\n \"src\" | \"srcSet\" | \"ref\" | \"style\"\n>;\n\n// Default image sizes to snap to\n// TODO: make this configurable?\nconst IMG_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];\nconst DEVICE_SIZES = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];\nconst ALL_SIZES = [...IMG_SIZES, ...DEVICE_SIZES];\n\nexport interface PlasmicImgProps extends ImgTagProps {\n /**\n * Either an object with the src string, and its full width and height,\n * or just a src string with unknown intrinsic dimensions.\n */\n src?:\n | string\n | {\n src: string;\n fullHeight: number;\n fullWidth: number;\n // We might also get a more precise aspectRatio for SVGs\n // instead of relyiing on fullWidth / fullHeight, because\n // those values might be rounded and not so accurate.\n aspectRatio?: number;\n };\n\n /**\n * className applied to the wrapper element if one is used.\n */\n className?: string;\n\n /**\n * css width\n */\n displayWidth?: number | string;\n\n /**\n * css height\n */\n displayHeight?: number | string;\n\n /**\n * css min-width\n */\n displayMinWidth?: number | string;\n\n /**\n * css min-height\n */\n displayMinHeight?: number | string;\n\n /**\n * css max-width\n */\n displayMaxWidth?: number | string;\n\n /**\n * css max-height\n */\n displayMaxHeight?: number | string;\n\n /**\n * For variable quality formats like jpg, the quality from 0 to 100\n */\n quality?: number;\n\n /**\n * ImageLoader to use for loading different dimensions of the image.\n * If none specified, will not attempt to load different dimensions.\n */\n loader?: \"plasmic\" | ImageLoader;\n\n /**\n * Style applied to the wrapper element. objectFit and objectPosition\n * rules are applied to the img element.\n */\n style?: React.CSSProperties;\n\n /**\n * Ref for the img element. The normal <PlasmicImg ref={...} />\n * prop gives the root element instead, which may be the img element\n * or a wrapper element\n */\n imgRef?: React.Ref<HTMLImageElement>;\n}\n\nexport const PlasmicImg = React.forwardRef(function PlasmicImg(\n props: PlasmicImgProps,\n outerRef: React.Ref<HTMLElement>\n) {\n let {\n src,\n className,\n displayWidth,\n displayHeight,\n displayMinWidth,\n displayMinHeight,\n displayMaxWidth,\n displayMaxHeight,\n quality,\n loader,\n imgRef,\n style,\n loading,\n ...rest\n } = props;\n\n const imgProps = Object.assign({}, rest, {\n // Default loading to \"lazy\" if not specified (which is different from the\n // html img, which defaults to eager!)\n loading: loading ?? \"lazy\",\n });\n\n const { fullWidth, fullHeight, aspectRatio } =\n typeof src === \"string\" || !src\n ? { fullWidth: undefined, fullHeight: undefined, aspectRatio: undefined }\n : src;\n const srcStr = src ? (typeof src === \"string\" ? src : src.src) : \"\";\n\n // Assume external image if either dimension is null and use usual <img>\n if (fullHeight == null || fullWidth == null) {\n return (\n <img\n src={srcStr}\n className={className}\n style={style}\n {...imgProps}\n loading={loading}\n ref={mergeRefs(imgRef, outerRef) as any}\n />\n );\n }\n\n if (\n isSvg(srcStr) &&\n (displayHeight == null || displayHeight === \"auto\") &&\n (displayWidth == null || displayWidth === \"auto\")\n ) {\n displayWidth = \"100%\";\n }\n\n if (\n fullWidth &&\n fullHeight &&\n (!displayWidth || displayWidth === \"auto\") &&\n !!getPixelLength(displayHeight)\n ) {\n // If there's a pixel length specified for displayHeight but not displayWidth,\n // then we can derive the pixel length for displayWidth. Having an explicit\n // displayWidth makes this a fixed-size image, which makes it possible for us to\n // generate better markup!\n if (!isSvg(srcStr)) {\n // We shouldn't do it for SVGs though, because `fullWidth` and\n // `fullHeight` might have rounded values so the final\n // `displayWidth` could differ by 1px or so.\n displayWidth = (getPixelLength(displayHeight)! * fullWidth) / fullHeight;\n }\n }\n\n let spacerWidth = fullWidth;\n let spacerHeight = fullHeight;\n if (aspectRatio && isFinite(aspectRatio) && isSvg(srcStr)) {\n // For SVGs, fullWidth and fullHeight can be rounded values, which would\n // cause some discrepancy between the actual aspect ratio and the aspect\n // ratio from those values. So, for those cases, we set large width / height\n // values to get a more precise ratio from the spacer.\n spacerWidth = DEFAULT_SVG_WIDTH;\n spacerHeight = Math.round(spacerWidth / aspectRatio);\n }\n\n const { sizes, widthDescs } = getWidths(displayWidth, fullWidth, {\n minWidth: displayMinWidth,\n });\n const imageLoader = getImageLoader(loader);\n const spacerSvg = `<svg width=\"${spacerWidth}\" height=\"${spacerHeight}\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"/>`;\n const spacerSvgBase64 =\n typeof window === \"undefined\"\n ? Buffer.from(spacerSvg).toString(\"base64\")\n : window.btoa(spacerSvg);\n\n let wrapperStyle: CSSProperties = { ...(style || {}) };\n let spacerStyle: CSSProperties = {...pick(\n style || {},\n \"objectFit\",\n \"objectPosition\"\n )};\n\n if (displayWidth != null && displayWidth !== \"auto\") {\n // If width is set, set it on the wrapper along with min/max width\n // and just use `width: 100%` on the spacer\n spacerStyle.width = \"100%\";\n // Rely on the styles set by `classname` on the wrapper:\n // wrapperStyle.width = displayWidth;\n // wrapperStyle.minWidth = displayMinWidth;\n // wrapperStyle.maxWidth = displayMaxWidth;\n } else {\n // Otherwise, we want auto sizing from the spacer, so set width there.\n //\n // But if we have min/max width, it should be set in the wrapper and it\n // can be percentage values (and we add corresponding min/max width to\n // 100% in the spacer). In general it ends up with the correct effect,\n // but some edge cases might make `min-width: 100%` shrink the image more\n // than it should.\n spacerStyle.width = displayWidth;\n wrapperStyle.width = \"auto\";\n if (displayMinWidth) {\n spacerStyle.minWidth = \"100%\";\n // Rely on min-width set by `classname` on the wrapper:\n // wrapperStyle.minWidth = displayMinWidth;\n }\n if (displayMaxWidth != null && displayMaxWidth !== \"none\") {\n spacerStyle.maxWidth = \"100%\";\n // Rely on max-width set by `classname` on the wrapper:\n // wrapperStyle.maxWidth = displayMaxWidth;\n }\n }\n\n if (displayHeight != null && displayHeight !== \"auto\") {\n spacerStyle.height = \"100%\";\n // wrapperStyle.height = displayHeight;\n // wrapperStyle.minHeight = displayMinHeight;\n // wrapperStyle.maxHeight = displayMaxHeight;\n } else {\n spacerStyle.height = displayHeight;\n wrapperStyle.height = \"auto\";\n if (displayMinHeight) {\n spacerStyle.minHeight = \"100%\";\n // wrapperStyle.minHeight = displayMinHeight;\n }\n if (displayMaxHeight != null && displayMaxHeight !== \"none\") {\n spacerStyle.maxHeight = \"100%\";\n // wrapperStyle.maxHeight = displayMaxHeight;\n }\n }\n\n return (\n <div\n className={classNames(className, \"__wab_img-wrapper\")}\n ref={outerRef as any}\n style={wrapperStyle}\n >\n <img\n alt=\"\"\n aria-hidden\n className=\"__wab_img-spacer-svg\"\n src={`data:image/svg+xml;base64,${spacerSvgBase64}`}\n style={spacerStyle}\n />\n {makePicture({\n imageLoader,\n widthDescs,\n sizes,\n src: srcStr,\n quality,\n ref: imgRef,\n style: style ? pick(style, \"objectFit\", \"objectPosition\") : undefined,\n imgProps,\n className: \"__wab_img\",\n })}\n </div>\n );\n});\n\nfunction makePicture(opts: {\n imageLoader?: ImageLoader;\n widthDescs: WidthDesc[];\n sizes?: string;\n src: string;\n quality?: number;\n style?: React.CSSProperties;\n className?: string;\n imgProps: ImgTagProps;\n ref?: React.Ref<HTMLImageElement>;\n}) {\n // If imageLoader is undefined, then this renders to just a normal\n // <img />. Else it will render to a <picture> with a <source> for\n // webp, and srcSet/sizes set according to width requirements.\n const {\n imageLoader,\n widthDescs,\n src,\n quality,\n style,\n className,\n sizes,\n imgProps,\n ref,\n } = opts;\n return (\n <picture className=\"__wab_picture\">\n {imageLoader && imageLoader.supportsUrl(src) && (\n <source\n type=\"image/webp\"\n srcSet={widthDescs\n .map(\n (wd) =>\n `${imageLoader.transformUrl({\n src,\n quality,\n width: wd.width,\n format: \"webp\",\n })} ${wd.desc}`\n )\n .join(\", \")}\n />\n )}\n <img\n {...imgProps}\n ref={ref}\n className={className}\n decoding=\"async\"\n src={\n imageLoader && imageLoader.supportsUrl(src)\n ? imageLoader.transformUrl({\n src,\n quality,\n width: widthDescs[widthDescs.length - 1].width,\n })\n : src\n }\n srcSet={\n imageLoader && imageLoader.supportsUrl(src)\n ? widthDescs\n .map(\n (wd) =>\n `${imageLoader.transformUrl({\n src,\n quality,\n width: wd.width,\n })} ${wd.desc}`\n )\n .join(\", \")\n : undefined\n }\n sizes={imageLoader && imageLoader.supportsUrl(src) ? sizes : undefined}\n style={{\n ...(style ? pick(style, \"objectFit\", \"objectPosition\") : {}),\n width: 0,\n height: 0,\n }}\n />\n </picture>\n );\n}\n\nconst DEFAULT_SVG_WIDTH = 10000;\n\nfunction isSvg(src: string) {\n return src.endsWith(\".svg\") || src.startsWith(\"data:image/svg\");\n}\n\ninterface WidthDesc {\n width?: number;\n desc: string;\n}\n\nfunction getClosestPresetSize(width: number, fullWidth: number) {\n const nextBiggerIndex =\n ALL_SIZES.findIndex((w) => w >= width) ?? ALL_SIZES.length - 1;\n const nextBigger = ALL_SIZES[nextBiggerIndex];\n if (nextBigger >= fullWidth) {\n // If the requested width is larger than the fullWidth,\n // we just use the original width instead. It's impossible\n // to make an image bigger than fullWidth!\n return undefined;\n } else if (\n nextBiggerIndex + 1 < ALL_SIZES.length &&\n fullWidth <= ALL_SIZES[nextBiggerIndex + 1]\n ) {\n // If the fullWidth is just between nextBigger and the one after that,\n // then also might as well just use the original size (so, width is 30,\n // nextBigger is 32, then we just use the original as long as fullWidth is\n // less than 48)\n return undefined;\n }\n\n return nextBigger;\n}\n\n/**\n * Computes the appropriate srcSet and sizes to use\n */\nfunction getWidths(\n width: number | string | undefined,\n fullWidth: number,\n extra?: { minWidth: string | number | undefined }\n): { sizes: string | undefined; widthDescs: WidthDesc[] } {\n const minWidth = extra?.minWidth;\n const pixelWidth = getPixelLength(width);\n const pixelMinWidth = getPixelLength(minWidth);\n if (pixelWidth != null && (!minWidth || pixelMinWidth != null)) {\n // If there's an exact width, then we just need to display it at 1x and 2x density\n return {\n widthDescs: [\n {\n width: getClosestPresetSize(\n Math.max(pixelWidth, pixelMinWidth ?? 0),\n fullWidth\n ),\n desc: \"1x\",\n },\n {\n width: getClosestPresetSize(\n Math.max(pixelWidth, pixelMinWidth ?? 0) * 2,\n fullWidth\n ),\n desc: \"2x\",\n },\n ],\n sizes: undefined,\n };\n }\n // Otherwise we don't know what sizes we'll end up, so we just cap it at\n // device width. TODO: do better!\n const usefulSizes = DEVICE_SIZES.filter(\n (size) => !fullWidth || size < fullWidth\n );\n if (!!fullWidth && usefulSizes.length === 0) {\n // image fullWidth is smaller than all device sizes. So all we can do\n // is offer 1x\n return {\n widthDescs: [\n {\n width: getClosestPresetSize(fullWidth, fullWidth),\n desc: \"1x\",\n },\n ],\n sizes: undefined,\n };\n }\n return {\n widthDescs: usefulSizes.map((size) => ({\n width: getClosestPresetSize(size, fullWidth),\n // If this is the last (buggest) useful width, but it is\n // still within the bounds set by DEVICE_SIZES, then just\n // use the original, unresized image. This means if we match\n // the largest size, we use unresized and best quality image.\n // We only do this, though, if fullWidth is \"reasonable\" --\n // smaller than the largest size we would consider.\n // i === usefulSizes.length - 1 &&\n // fullWidth < DEVICE_SIZES[DEVICE_SIZES.length - 1]\n // ? undefined\n // : size,\n desc: `${size}w`,\n })),\n sizes: \"100vw\",\n };\n}\n\nfunction getPixelLength(length: number | string | undefined) {\n if (length == null || length == \"\") {\n return undefined;\n }\n\n if (typeof length === \"number\") {\n return length;\n }\n\n const parsed = parseNumeric(length);\n if (parsed && (!parsed.units || parsed.units === \"px\")) {\n return parsed.num;\n }\n\n return undefined;\n}\n\nfunction parseNumeric(val: string) {\n // Parse strings like \"30\", \"30px\", \"30%\", \"30px /* blah blah */\"\n const res = val.match(\n /^\\s*(-?(?:\\d+\\.\\d*|\\d*\\.\\d+|\\d+))\\s*([a-z]*|%)\\s*(?:\\/\\*.*)?$/i\n );\n if (res == null) {\n return undefined;\n }\n const num = res[1];\n const units = res[2];\n return { num: +num, units };\n}\n\nfunction getImageLoader(loader: \"plasmic\" | ImageLoader | undefined) {\n if (loader == null) {\n return undefined;\n } else if (loader === \"plasmic\") {\n return PLASMIC_IMAGE_LOADER;\n } else {\n return loader;\n }\n}\n\nconst PLASMIC_IMAGE_LOADER: ImageLoader = {\n supportsUrl: (src) => {\n return src.startsWith(\"https://img.plasmic.app\") && !isSvg(src);\n },\n transformUrl: (opts) => {\n const params = [\n opts.width ? `w=${opts.width}` : undefined,\n `q=${opts.quality ?? 75}`,\n opts.format ? `f=${opts.format}` : undefined,\n ].filter((x) => !!x);\n return `${opts.src}?${params.join(\"&\")}`;\n },\n};\n"],"names":["React"],"mappings":";;;;;AAAA;;;AAwBA;AACA;AACA,IAAM,SAAS,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACtD,IAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACnE,IAAM,SAAS,mCAAO,SAAS,GAAK,YAAY,CAAC,CAAC;IA+ErC,UAAU,GAAGA,cAAK,CAAC,UAAU,CAAC,SAAS,UAAU,CAC5D,KAAsB,EACtB,QAAgC;IAG9B,IAAA,GAAG,GAcD,KAAK,IAdJ,EACH,SAAS,GAaP,KAAK,UAbE,EACT,YAAY,GAYV,KAAK,aAZK,EACZ,aAAa,GAWX,KAAK,cAXM,EACb,eAAe,GAUb,KAAK,gBAVQ,EACf,gBAAgB,GASd,KAAK,iBATS,EAChB,eAAe,GAQb,KAAK,gBARQ,EACf,gBAAgB,GAOd,KAAK,iBAPS,EAChB,OAAO,GAML,KAAK,QANA,EACP,MAAM,GAKJ,KAAK,OALD,EACN,MAAM,GAIJ,KAAK,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A,CAAC,CAAC,CAAC,GAAA,CAAC,CAAC;QACrB,OAAU,IAAI,CAAC,GAAG,SAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAG,CAAC;KAC1C;CACF;;;;"}
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { a as __assign, d as isString } from './tslib.es6-d26ffe68.js';
|
|
2
|
-
import React__default from 'react';
|
|
3
|
-
import { Item, Section } from 'react-stately';
|
|
4
|
-
import { t as toChildArray, g as getElementTypeName } from './react-utils-7c01e440.js';
|
|
5
|
-
import { g as getPlumeType, P as PLUME_STRICT_MODE } from './plume-utils-27cd384f.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* In general, we try not to expose react-aria's Collections API to Plume users.
|
|
9
|
-
* The Collections API is how react-aria users pass data about collections of
|
|
10
|
-
* things using the built-in Item and Section components, which are abstract,
|
|
11
|
-
* metadata-only components that don't render anything but only serve to specify
|
|
12
|
-
* data. For example, here's how you would use react-spectrum's Picker:
|
|
13
|
-
*
|
|
14
|
-
* <Picker>
|
|
15
|
-
* <Section title="Asia">
|
|
16
|
-
* <Item key="taiwan">Taiwan</Item>
|
|
17
|
-
* <Item key="japan">Japan</Item>
|
|
18
|
-
* <Item key="china">China</Item>
|
|
19
|
-
* </Section>
|
|
20
|
-
* <Section title="Europe">
|
|
21
|
-
* <Item key="germany">Germany</Item>
|
|
22
|
-
* <Item key="france">France</Item>
|
|
23
|
-
* </Section>
|
|
24
|
-
* </Picker>
|
|
25
|
-
*
|
|
26
|
-
* You would re-use this same Item/Section components to pass similar things to
|
|
27
|
-
* Menu, Tabs, etc.
|
|
28
|
-
*
|
|
29
|
-
* For Plasmic, this API is too abstract. The user has explicitly designed components
|
|
30
|
-
* like Select.Option and Select.OptionGroup, and it is weird that they don't actually
|
|
31
|
-
* use these components. It is more natural to do:
|
|
32
|
-
*
|
|
33
|
-
* <Select>
|
|
34
|
-
* <Select.OptionGroup title="Asia">
|
|
35
|
-
* <Select.Option key="taiwan">Taiwan</Select>
|
|
36
|
-
* </Select.OptionGroup>
|
|
37
|
-
* </Select>
|
|
38
|
-
*
|
|
39
|
-
* For Plume, we let users directly use the components they designed, both to collect
|
|
40
|
-
* information and to perform actual rendering. For example, for Plume,
|
|
41
|
-
* you'd use Select.Option instead of Item, and Select.OptionGroup instead of Section.
|
|
42
|
-
* This means that the Select.Option props will collect the same information Item
|
|
43
|
-
* does.
|
|
44
|
-
*
|
|
45
|
-
* A component like Select.Option then serves two purposes:
|
|
46
|
-
*
|
|
47
|
-
* 1. Allow users to specify the collection of data, like in the above example
|
|
48
|
-
* Here, we're mainly interested in the props in those ReactElements so
|
|
49
|
-
* we can pass the Item/Section data onto react-aria's APIs. We are not
|
|
50
|
-
* actually rendering these elements.
|
|
51
|
-
* 2. Once react-aria's Collections API has gone through them and built
|
|
52
|
-
* Collection "nodes", we then create cloned versions of these elements
|
|
53
|
-
* with the corresponding node passed in as a secret prop. These ReactElements
|
|
54
|
-
* are then actually used to _render_ the corresponding Option / OptionGroup.
|
|
55
|
-
*
|
|
56
|
-
* This file contains helper functions to help with implementing the above.
|
|
57
|
-
*
|
|
58
|
-
* Note also that most of the collections-based react-aria components expose
|
|
59
|
-
* a parallel API that accepts a list of "items" and a render prop, instead
|
|
60
|
-
* of list of Item/Section elements. This is for efficiency, but we are opting
|
|
61
|
-
* to only support the composite-component pattern for now for simplicity.
|
|
62
|
-
*/
|
|
63
|
-
/**
|
|
64
|
-
* Given children of a component like Select or Menu, derive the items
|
|
65
|
-
* that we will pass into the Collections API. These will be
|
|
66
|
-
* ReactElement<ItemLikeProps|SectionLikeProps>[].
|
|
67
|
-
*
|
|
68
|
-
* Will also assign keys to items by their index in the collection,
|
|
69
|
-
* and collect the keys of disabled items.
|
|
70
|
-
*/
|
|
71
|
-
function deriveItemsFromChildren(children, opts) {
|
|
72
|
-
if (!children) {
|
|
73
|
-
return {
|
|
74
|
-
items: [],
|
|
75
|
-
disabledKeys: [],
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
var itemPlumeType = opts.itemPlumeType, sectionPlumeType = opts.sectionPlumeType, invalidChildError = opts.invalidChildError;
|
|
79
|
-
// For Plume items without an explicit key, we assign a key as the index
|
|
80
|
-
// of the collection.
|
|
81
|
-
var itemCount = 0;
|
|
82
|
-
var sectionCount = 0;
|
|
83
|
-
var ensureValue = function (element) {
|
|
84
|
-
if (!propInChild(element, "value")) {
|
|
85
|
-
if (opts.requireItemValue && PLUME_STRICT_MODE) {
|
|
86
|
-
throw new Error("Must specify a \"value\" prop for " + getElementTypeName(element));
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
return cloneChild(element, { value: "" + itemCount++ });
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
// Still increment count even if key is present, so that the
|
|
94
|
-
// auto-assigned key really reflects the index
|
|
95
|
-
itemCount++;
|
|
96
|
-
return element;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
var disabledKeys = [];
|
|
100
|
-
var flattenedChildren = function (children) {
|
|
101
|
-
return toChildArray(children).flatMap(function (child) {
|
|
102
|
-
var _a;
|
|
103
|
-
if (React__default.isValidElement(child)) {
|
|
104
|
-
if (child.type === React__default.Fragment) {
|
|
105
|
-
return flattenedChildren(child.props.children);
|
|
106
|
-
}
|
|
107
|
-
var type = getPlumeType(child);
|
|
108
|
-
if (type === itemPlumeType) {
|
|
109
|
-
child = ensureValue(child);
|
|
110
|
-
var childKey = getItemLikeKey(child);
|
|
111
|
-
if (getChildProp(child, "isDisabled") && !!childKey) {
|
|
112
|
-
disabledKeys.push(childKey);
|
|
113
|
-
}
|
|
114
|
-
return [child];
|
|
115
|
-
}
|
|
116
|
-
if (type === sectionPlumeType) {
|
|
117
|
-
return [
|
|
118
|
-
cloneChild(child, {
|
|
119
|
-
// key of section doesn't actually matter, just needs
|
|
120
|
-
// to be unique
|
|
121
|
-
key: (_a = child.key) !== null && _a !== void 0 ? _a : "section-" + sectionCount++,
|
|
122
|
-
children: flattenedChildren(getChildProp(child, "children")),
|
|
123
|
-
}),
|
|
124
|
-
];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
{
|
|
128
|
-
throw new Error(invalidChildError !== null && invalidChildError !== void 0 ? invalidChildError : "Unexpected child");
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
return { items: flattenedChildren(children), disabledKeys: disabledKeys };
|
|
133
|
-
}
|
|
134
|
-
function useDerivedItemsFromChildren(children, opts) {
|
|
135
|
-
var itemPlumeType = opts.itemPlumeType, sectionPlumeType = opts.sectionPlumeType, invalidChildError = opts.invalidChildError, requireItemValue = opts.requireItemValue;
|
|
136
|
-
return React__default.useMemo(function () {
|
|
137
|
-
return deriveItemsFromChildren(children, {
|
|
138
|
-
itemPlumeType: itemPlumeType,
|
|
139
|
-
sectionPlumeType: sectionPlumeType,
|
|
140
|
-
invalidChildError: invalidChildError,
|
|
141
|
-
requireItemValue: requireItemValue,
|
|
142
|
-
});
|
|
143
|
-
}, [
|
|
144
|
-
children,
|
|
145
|
-
itemPlumeType,
|
|
146
|
-
sectionPlumeType,
|
|
147
|
-
invalidChildError,
|
|
148
|
-
requireItemValue,
|
|
149
|
-
]);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Given a Collection node, create the React element that we should use
|
|
153
|
-
* to render it.
|
|
154
|
-
*/
|
|
155
|
-
function renderCollectionNode(node) {
|
|
156
|
-
// node.rendered should already have our item-like or section-like Plume
|
|
157
|
-
// component elements, so we just need to clone them with a secret
|
|
158
|
-
// _node prop that we use to render.
|
|
159
|
-
return cloneChild(node.rendered, {
|
|
160
|
-
_node: node,
|
|
161
|
-
key: node.key,
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Renders a item-like or section-like Plume component element into an
|
|
166
|
-
* Item or a Section element.
|
|
167
|
-
*/
|
|
168
|
-
function renderAsCollectionChild(child, opts) {
|
|
169
|
-
var _a;
|
|
170
|
-
var plumeType = getPlumeType(child);
|
|
171
|
-
if (plumeType === opts.itemPlumeType) {
|
|
172
|
-
var option = child;
|
|
173
|
-
// We look at the children passed to the item-like element, and derive key
|
|
174
|
-
// or textValue from it if it is a string
|
|
175
|
-
var content = getChildProp(option, "children");
|
|
176
|
-
// The children render prop needs to return an <Item/>
|
|
177
|
-
return (React__default.createElement(Item
|
|
178
|
-
// We use ItemLike.value if the user explicitly specified a value,
|
|
179
|
-
// and we fallback to key. If the user specified neither, then
|
|
180
|
-
// the Collections API will generate a unique key for this item.
|
|
181
|
-
, {
|
|
182
|
-
// We use ItemLike.value if the user explicitly specified a value,
|
|
183
|
-
// and we fallback to key. If the user specified neither, then
|
|
184
|
-
// the Collections API will generate a unique key for this item.
|
|
185
|
-
key: getItemLikeKey(option),
|
|
186
|
-
// textValue is either explicitly specified by the user, or we
|
|
187
|
-
// try to derive it if `content` is a string.
|
|
188
|
-
textValue: (_a = getChildProp(option, "textValue")) !== null && _a !== void 0 ? _a : (isString(content)
|
|
189
|
-
? content
|
|
190
|
-
: propInChild(option, "value")
|
|
191
|
-
? getChildProp(option, "value")
|
|
192
|
-
: option.key), "aria-label": getChildProp(option, "aria-label") }, option));
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
var group = child;
|
|
196
|
-
return (React__default.createElement(Section
|
|
197
|
-
// Note that we are using the whole section-like element as the title
|
|
198
|
-
// here, and not group.props.title; we want the entire section-like
|
|
199
|
-
// Plume element to end up as Node.rendered.
|
|
200
|
-
, {
|
|
201
|
-
// Note that we are using the whole section-like element as the title
|
|
202
|
-
// here, and not group.props.title; we want the entire section-like
|
|
203
|
-
// Plume element to end up as Node.rendered.
|
|
204
|
-
title: group, "aria-label": getChildProp(group, "aria-label"),
|
|
205
|
-
// We are flattening and deriving the descendant Options as items here.
|
|
206
|
-
// group.props.children should've already been cleaned up by
|
|
207
|
-
// deriveItemsFromChildren()
|
|
208
|
-
items: getChildProp(group, "children") }, function (c) { return renderAsCollectionChild(c, opts); }));
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
function getItemLikeKey(element) {
|
|
212
|
-
var _a;
|
|
213
|
-
return (_a = getChildProp(element, "value")) !== null && _a !== void 0 ? _a : element.key;
|
|
214
|
-
}
|
|
215
|
-
// PlasmicLoader-aware function to get prop from child.
|
|
216
|
-
function getChildProp(child, prop) {
|
|
217
|
-
return "componentProps" in child.props
|
|
218
|
-
? child.props.componentProps[prop]
|
|
219
|
-
: child.props[prop];
|
|
220
|
-
}
|
|
221
|
-
// PlasmicLoader-aware function to check `if (prop in element.props)`.
|
|
222
|
-
function propInChild(child, prop) {
|
|
223
|
-
return "componentProps" in child.props
|
|
224
|
-
? prop in child.props.componentProps
|
|
225
|
-
: prop in child.props;
|
|
226
|
-
}
|
|
227
|
-
// PlasmicLoader-aware function to clone React element.
|
|
228
|
-
function cloneChild(child, props) {
|
|
229
|
-
if (child.type.getPlumeType) {
|
|
230
|
-
// If React element has getPlumeType(), assume that it is PlasmicLoader,
|
|
231
|
-
// so add nodeProps to componentProps instead of element props.
|
|
232
|
-
return React__default.cloneElement(child, __assign({ componentProps: __assign(__assign({}, child.props.componentProps), props) }, (props.key ? { key: props.key } : {})));
|
|
233
|
-
}
|
|
234
|
-
return React__default.cloneElement(child, props);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export { renderAsCollectionChild as a, getChildProp as g, renderCollectionNode as r, useDerivedItemsFromChildren as u };
|
|
238
|
-
//# sourceMappingURL=collection-utils-3487dd27.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collection-utils-3487dd27.js","sources":["../../src/plume/collection-utils.tsx"],"sourcesContent":["/**\n * In general, we try not to expose react-aria's Collections API to Plume users.\n * The Collections API is how react-aria users pass data about collections of\n * things using the built-in Item and Section components, which are abstract,\n * metadata-only components that don't render anything but only serve to specify\n * data. For example, here's how you would use react-spectrum's Picker:\n *\n * <Picker>\n * <Section title=\"Asia\">\n * <Item key=\"taiwan\">Taiwan</Item>\n * <Item key=\"japan\">Japan</Item>\n * <Item key=\"china\">China</Item>\n * </Section>\n * <Section title=\"Europe\">\n * <Item key=\"germany\">Germany</Item>\n * <Item key=\"france\">France</Item>\n * </Section>\n * </Picker>\n *\n * You would re-use this same Item/Section components to pass similar things to\n * Menu, Tabs, etc.\n *\n * For Plasmic, this API is too abstract. The user has explicitly designed components\n * like Select.Option and Select.OptionGroup, and it is weird that they don't actually\n * use these components. It is more natural to do:\n *\n * <Select>\n * <Select.OptionGroup title=\"Asia\">\n * <Select.Option key=\"taiwan\">Taiwan</Select>\n * </Select.OptionGroup>\n * </Select>\n *\n * For Plume, we let users directly use the components they designed, both to collect\n * information and to perform actual rendering. For example, for Plume,\n * you'd use Select.Option instead of Item, and Select.OptionGroup instead of Section.\n * This means that the Select.Option props will collect the same information Item\n * does.\n *\n * A component like Select.Option then serves two purposes:\n *\n * 1. Allow users to specify the collection of data, like in the above example\n * Here, we're mainly interested in the props in those ReactElements so\n * we can pass the Item/Section data onto react-aria's APIs. We are not\n * actually rendering these elements.\n * 2. Once react-aria's Collections API has gone through them and built\n * Collection \"nodes\", we then create cloned versions of these elements\n * with the corresponding node passed in as a secret prop. These ReactElements\n * are then actually used to _render_ the corresponding Option / OptionGroup.\n *\n * This file contains helper functions to help with implementing the above.\n *\n * Note also that most of the collections-based react-aria components expose\n * a parallel API that accepts a list of \"items\" and a render prop, instead\n * of list of Item/Section elements. This is for efficiency, but we are opting\n * to only support the composite-component pattern for now for simplicity.\n */\n\nimport { Node } from \"@react-types/shared\";\nimport React from \"react\";\nimport { Item, Section } from \"react-stately\";\nimport { isString } from \"../common\";\nimport { getElementTypeName, toChildArray } from \"../react-utils\";\nimport { getPlumeType, PLUME_STRICT_MODE } from \"./plume-utils\";\n\nexport interface PlasmicLoaderProps<T> {\n component: string;\n componentProps: T;\n}\n\n/**\n * Props for a Plume component that corresponds to an Item\n */\nexport interface ItemLikeProps {\n /**\n * value key corresponding to this item. Not required if you use the\n * `key` prop instead.\n */\n value?: string | null;\n\n /**\n * The text string value corresponding to this item. Used to support\n * keyboard type-ahead. If not specified, then will be derived from\n * `children` if it is a string, or the `value` or `key`.\n */\n textValue?: string;\n\n /**\n * aria-label for this item.\n */\n \"aria-label\"?: string;\n\n /**\n * Primary content label for this item.\n */\n children?: React.ReactNode;\n\n /**\n * If true, this item will not be selectable.\n */\n isDisabled?: boolean;\n}\n\ntype LoaderAwareItemLikeProps =\n | ItemLikeProps\n | PlasmicLoaderProps<ItemLikeProps>;\n\n/**\n * Props for a Plume component that corresponds to a Section\n */\nexport interface SectionLikeProps {\n /**\n * Heading content of the title\n */\n title?: React.ReactNode;\n\n /**\n * aria-label for this section\n */\n \"aria-label\"?: string;\n\n /**\n * A list of items that belong in this group\n */\n children?: React.ReactNode;\n}\n\ntype LoaderAwareSectionLikeProps =\n | SectionLikeProps\n | PlasmicLoaderProps<SectionLikeProps>;\n\n/**\n * Given children of a component like Select or Menu, derive the items\n * that we will pass into the Collections API. These will be\n * ReactElement<ItemLikeProps|SectionLikeProps>[].\n *\n * Will also assign keys to items by their index in the collection,\n * and collect the keys of disabled items.\n */\nexport function deriveItemsFromChildren<T extends React.ReactElement>(\n children: React.ReactNode,\n opts: {\n itemPlumeType: string;\n sectionPlumeType?: string;\n invalidChildError?: string;\n requireItemValue: boolean;\n }\n) {\n if (!children) {\n return {\n items: [] as T[],\n disabledKeys: [] as React.Key[],\n };\n }\n\n const { itemPlumeType, sectionPlumeType, invalidChildError } = opts;\n\n // For Plume items without an explicit key, we assign a key as the index\n // of the collection.\n let itemCount = 0;\n let sectionCount = 0;\n\n const ensureValue = (element: React.ReactElement) => {\n if (!propInChild(element, \"value\")) {\n if (opts.requireItemValue && PLUME_STRICT_MODE) {\n throw new Error(\n `Must specify a \"value\" prop for ${getElementTypeName(element)}`\n );\n } else {\n return cloneChild(element, { value: `${itemCount++}` });\n }\n } else {\n // Still increment count even if key is present, so that the\n // auto-assigned key really reflects the index\n itemCount++;\n return element;\n }\n };\n\n const disabledKeys: React.Key[] = [];\n\n const flattenedChildren = (\n children: React.ReactNode\n ): React.ReactElement[] => {\n return toChildArray(children).flatMap((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n return flattenedChildren(child.props.children);\n }\n const type = getPlumeType(child);\n if (type === itemPlumeType) {\n child = ensureValue(child);\n const childKey = getItemLikeKey(child);\n if (getChildProp(child, \"isDisabled\") && !!childKey) {\n disabledKeys.push(childKey);\n }\n return [child];\n }\n if (type === sectionPlumeType) {\n return [\n cloneChild(child, {\n // key of section doesn't actually matter, just needs\n // to be unique\n key: child.key ?? `section-${sectionCount++}`,\n children: flattenedChildren(getChildProp(child, \"children\")),\n }),\n ];\n }\n }\n\n if (PLUME_STRICT_MODE) {\n throw new Error(invalidChildError ?? `Unexpected child`);\n } else {\n return [];\n }\n });\n };\n\n return { items: flattenedChildren(children) as T[], disabledKeys };\n}\n\nexport function useDerivedItemsFromChildren<T extends React.ReactElement>(\n children: React.ReactNode,\n opts: {\n itemPlumeType: string;\n sectionPlumeType?: string;\n invalidChildError?: string;\n requireItemValue: boolean;\n }\n) {\n const {\n itemPlumeType,\n sectionPlumeType,\n invalidChildError,\n requireItemValue,\n } = opts;\n return React.useMemo(() => {\n return deriveItemsFromChildren<T>(children, {\n itemPlumeType,\n sectionPlumeType,\n invalidChildError,\n requireItemValue,\n });\n }, [\n children,\n itemPlumeType,\n sectionPlumeType,\n invalidChildError,\n requireItemValue,\n ]);\n}\n\n/**\n * Given a Collection node, create the React element that we should use\n * to render it.\n */\nexport function renderCollectionNode(node: Node<any>) {\n // node.rendered should already have our item-like or section-like Plume\n // component elements, so we just need to clone them with a secret\n // _node prop that we use to render.\n return cloneChild(node.rendered as React.ReactElement, {\n _node: node,\n key: node.key,\n });\n}\n\n/**\n * Renders a item-like or section-like Plume component element into an\n * Item or a Section element.\n */\nexport function renderAsCollectionChild<\n T extends React.ReactElement<\n LoaderAwareItemLikeProps | LoaderAwareSectionLikeProps\n >\n>(\n child: T,\n opts: {\n itemPlumeType: string;\n sectionPlumeType?: string;\n }\n) {\n const plumeType = getPlumeType(child);\n if (plumeType === opts.itemPlumeType) {\n const option = child as React.ReactElement<LoaderAwareItemLikeProps>;\n\n // We look at the children passed to the item-like element, and derive key\n // or textValue from it if it is a string\n const content = getChildProp(option, \"children\");\n\n // The children render prop needs to return an <Item/>\n return (\n <Item\n // We use ItemLike.value if the user explicitly specified a value,\n // and we fallback to key. If the user specified neither, then\n // the Collections API will generate a unique key for this item.\n key={getItemLikeKey(option)}\n // textValue is either explicitly specified by the user, or we\n // try to derive it if `content` is a string.\n textValue={\n getChildProp(option, \"textValue\") ??\n (isString(content)\n ? content\n : propInChild(option, \"value\")\n ? getChildProp(option, \"value\")\n : option.key)\n }\n aria-label={getChildProp(option, \"aria-label\")}\n >\n {\n // Note that what we setting the item-like element as the children\n // here, and not content; we want the entire item-like Plume element to\n // end up as Node.rendered.\n }\n {option}\n </Item>\n );\n } else {\n const group = child as React.ReactElement<LoaderAwareSectionLikeProps>;\n return (\n <Section\n // Note that we are using the whole section-like element as the title\n // here, and not group.props.title; we want the entire section-like\n // Plume element to end up as Node.rendered.\n title={group}\n aria-label={getChildProp(group, \"aria-label\")}\n // We are flattening and deriving the descendant Options as items here.\n // group.props.children should've already been cleaned up by\n // deriveItemsFromChildren()\n items={getChildProp(group, \"children\") as React.ReactElement[]}\n >\n {\n // We use the same render function to turn descendent Options into Items\n }\n {(c: React.ReactElement) => renderAsCollectionChild(c, opts)}\n </Section>\n );\n }\n}\n\nfunction getItemLikeKey(element: React.ReactElement<LoaderAwareItemLikeProps>) {\n return getChildProp(element, \"value\") ?? element.key;\n}\n\n// PlasmicLoader-aware function to get prop from child.\nexport function getChildProp(child: React.ReactElement, prop: string) {\n return \"componentProps\" in child.props\n ? child.props.componentProps[prop]\n : child.props[prop];\n}\n\n// PlasmicLoader-aware function to check `if (prop in element.props)`.\nfunction propInChild(child: React.ReactElement, prop: string): boolean {\n return \"componentProps\" in child.props\n ? prop in child.props.componentProps\n : prop in child.props;\n}\n\n// PlasmicLoader-aware function to clone React element.\nfunction cloneChild(child: React.ReactElement, props: Record<string, any>) {\n if ((child.type as any).getPlumeType) {\n // If React element has getPlumeType(), assume that it is PlasmicLoader,\n // so add nodeProps to componentProps instead of element props.\n return React.cloneElement(child, {\n componentProps: {\n ...child.props.componentProps,\n ...props,\n },\n ...(props.key ? { key: props.key } : {}),\n });\n }\n\n return React.cloneElement(child, props);\n}\n"],"names":["React"],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkIA;;;;;;;;SAQgB,uBAAuB,CACrC,QAAyB,EACzB,IAKC;IAED,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO;YACL,KAAK,EAAE,EAAS;YAChB,YAAY,EAAE,EAAiB;SAChC,CAAC;KACH;IAEO,IAAA,aAAa,GAA0C,IAAI,cAA9C,EAAE,gBAAgB,GAAwB,IAAI,iBAA5B,EAAE,iBAAiB,GAAK,IAAI,kBAAT,CAAU;;;IAIpE,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,IAAM,WAAW,GAAG,UAAC,OAA2B;QAC9C,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE;YAClC,IAAI,IAAI,CAAC,gBAAgB,IAAI,iBAAiB,EAAE;gBAC9C,MAAM,IAAI,KAAK,CACb,uCAAmC,kBAAkB,CAAC,OAAO,CAAG,CACjE,CAAC;aACH;iBAAM;gBACL,OAAO,UAAU,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAG,SAAS,EAAI,EAAE,CAAC,CAAC;aACzD;SACF;aAAM;;;YAGL,SAAS,EAAE,CAAC;YACZ,OAAO,OAAO,CAAC;SAChB;KACF,CAAC;IAEF,IAAM,YAAY,GAAgB,EAAE,CAAC;IAErC,IAAM,iBAAiB,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