@plasmicpkgs/plasmic-basic-components 0.0.2 → 0.0.6
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/Data.d.ts +32 -59
- package/dist/Embed.d.ts +5 -3
- package/dist/Iframe.d.ts +8 -3
- package/dist/ScrollRevealer.d.ts +12 -6
- package/dist/Video.d.ts +6 -0
- package/dist/index.d.ts +3 -1
- package/dist/plasmic-basic-components.cjs.development.js +151 -172
- package/dist/plasmic-basic-components.cjs.development.js.map +1 -1
- package/dist/plasmic-basic-components.cjs.production.min.js +1 -1
- package/dist/plasmic-basic-components.cjs.production.min.js.map +1 -1
- package/dist/plasmic-basic-components.esm.js +134 -169
- package/dist/plasmic-basic-components.esm.js.map +1 -1
- package/package.json +4 -13
- package/Data/dist/Data.d.ts +0 -97
- package/Data/dist/common.d.ts +0 -2
- package/Data/dist/index.cjs.js +0 -267
- package/Data/dist/index.cjs.js.map +0 -1
- package/Data/dist/index.esm.js +0 -246
- package/Data/dist/index.esm.js.map +0 -1
- package/Data/package.json +0 -6
- package/Embed/dist/Embed.d.ts +0 -8
- package/Embed/dist/common.d.ts +0 -2
- package/Embed/dist/index.cjs.js +0 -64
- package/Embed/dist/index.cjs.js.map +0 -1
- package/Embed/dist/index.esm.js +0 -55
- package/Embed/dist/index.esm.js.map +0 -1
- package/Embed/package.json +0 -6
- package/Iframe/dist/Iframe.d.ts +0 -8
- package/Iframe/dist/index.cjs.js +0 -62
- package/Iframe/dist/index.cjs.js.map +0 -1
- package/Iframe/dist/index.esm.js +0 -53
- package/Iframe/dist/index.esm.js.map +0 -1
- package/Iframe/package.json +0 -6
- package/ScrollRevealer/dist/ScrollRevealer.d.ts +0 -20
- package/ScrollRevealer/dist/index.cjs.js +0 -87
- package/ScrollRevealer/dist/index.cjs.js.map +0 -1
- package/ScrollRevealer/dist/index.esm.js +0 -77
- package/ScrollRevealer/dist/index.esm.js.map +0 -1
- package/ScrollRevealer/package.json +0 -6
- package/Video/dist/Video.d.ts +0 -3
- package/Video/dist/index.cjs.js +0 -100
- package/Video/dist/index.cjs.js.map +0 -1
- package/Video/dist/index.esm.js +0 -91
- package/Video/dist/index.esm.js.map +0 -1
- package/Video/package.json +0 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@plasmicapp/host"),r=e(require("@plasmicapp/host/registerComponent")),o=require("react"),a=e(o);function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}function i(e,t){if(null==e)return{};var r,o,a={},n=Object.keys(e);for(o=0;o<n.length;o++)t.indexOf(r=n[o])>=0||(a[r]=e[r]);return a}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function s(e){if(null==e)throw new Error("Value must not be undefined or null");return e}var c=o.createContext(void 0);function p(e,t){if(t){for(var r,o=e,a=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,void 0):void 0}}(e))){r&&(e=r);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t.split("."));!(r=a()).done;){var n;o=null==(n=o)?void 0:n[r.value]}return o}}function u(e){return p(m(),e)}function d(e){void 0===e&&(e={});var t=m();return Object.fromEntries(Object.entries(e).filter((function(e){return!!e[0]&&!!e[1]})).map((function(e){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t}(e[0],p(t,e[1]))})))}function m(){return o.useContext(c)}function h(e){var t,r,o=e.name,i=e.data,l=e.children,s=null!=(t=m())?t:{};return o?a.createElement(c.Provider,{value:n({},s,(r={},r[o]=i,r))},l):a.createElement(a.Fragment,null,l)}function f(e){var t=e.tag,r=void 0===t?"div":t,a=e.className,l=e.children,s=e.propSelectors,c=i(e,["tag","className","children","propSelectors"]),p=d(s);return o.createElement(r,n({children:l},c,p,{className:a+" "+p.className}))}function y(e){var t=e.selector,r=e.propSelectors,o=i(e,["selector","propSelectors"]);return a.createElement(f,Object.assign({},o,{propSelectors:n({},r,{children:t})}),"(DynamicText requires a selector)")}function v(e){var t=e.selector,r=e.propSelectors,o=i(e,["selector","propSelectors"]);return a.createElement(f,Object.assign({tag:"img",loading:"lazy",style:{objectFit:"cover"}},o,{propSelectors:n({},r,{src:t}),src:"https://studio.plasmic.app/static/img/placeholder.png"}))}function b(e){var r,o=e.selector,n=e.loopItemName,l=e.children,s=e.data,c=e.keySelector,d=i(e,["selector","loopItemName","children","data","keySelector"]),m=null!=(r=null!=s?s:u(o))?r:[1,2,3];return a.createElement(f,Object.assign({},d),null==m||null==m.map?void 0:m.map((function(e,r){var o;return a.createElement(h,{key:null!=(o=p(e,c))?o:r,name:n,data:e},t.repeatedElement(0===r,l))})))}function g(e){var t=e.columns,r=e.columnGap,o=void 0===r?0:r,n=e.rowGap,l=void 0===n?0:n,s=i(e,["columns","columnGap","rowGap"]);return a.createElement(b,Object.assign({},s,{style:{display:"grid",gridTemplateColumns:"repeat("+t+", 1fr)",columnGap:o+"px",rowGap:l+"px"}}))}var x="@plasmicpkgs/plasmic-basic-components/Data";r(h,{name:"DataProvider",importPath:x,props:{name:{type:"string",defaultValue:"celebrities",description:"The name of the variable to store the data in"},data:{type:"object",defaultValue:[{name:"Fill Murray",birthYear:1950,profilePicture:["https://www.fillmurray.com/200/300"]},{name:"Place Cage",birthYear:1950,profilePicture:["https://www.placecage.com/200/300"]}]},children:{type:"slot",defaultValue:[{type:"component",name:"DynamicText",props:{selector:"celebrities.0.name"}},{type:"component",name:"DynamicImage",props:{selector:"celebrities.0.profilePicture"}}]}}});var w={propSelectors:{type:"object",description:"An object whose keys are prop names and values are selector expressions. Use this to set any prop to a dynamic value."}},E=n({},w,{tag:{type:"string",description:"The HTML tag to use"}});r(f,{name:"DynamicElement",importPath:x,props:n({},E,{children:"slot"})}),r(y,{name:"DynamicText",importPath:x,props:n({},E,{selector:{type:"string",description:"The selector expression to use to get the text, such as: someVariable.0.someField"}})}),r(v,{name:"DynamicImage",importPath:x,props:n({},w,{selector:{type:"string",description:"The selector expression to use to get the image source URL, such as: someVariable.0.someField"}})});var S=n({},E,{selector:{type:"string",description:"The selector expression to use to get the array of data to loop over, such as: someVariable.0.someField"},loopItemName:{type:"string",defaultValue:"item",description:"The name of the variable to use to store the current item in the loop"},children:"slot"});r(b,{name:"DynamicCollection",importPath:x,props:S});var P=n({},S,{columns:{type:"number",defaultValue:2,description:"The number of columns to use in the grid"},columnGap:{type:"number",defaultValue:8,description:"The gap between columns"},rowGap:{type:"number",defaultValue:8,description:"The gap between rows"}});function N(e){var t=e.className,r=e.code,n=e.hideInEditor,i=void 0!==n&&n,l=o.useRef(null);return o.useEffect((function(){i||Array.from(s(l.current).querySelectorAll("script")).forEach((function(e){var t=document.createElement("script");Array.from(e.attributes).forEach((function(e){return t.setAttribute(e.name,e.value)})),t.appendChild(document.createTextNode(e.innerHTML)),s(e.parentNode).replaceChild(t,e)}))}),[r,i]),a.createElement("div",{ref:l,className:t,dangerouslySetInnerHTML:{__html:i?"":r}})}function T(e){var r=e.hideInEditor,n=e.src,i=e.className;return o.useContext(t.PlasmicCanvasContext)&&!r?a.createElement("div",{className:i},a.createElement("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"#eee",color:"#888",fontSize:"36px",fontFamily:"sans-serif",fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"}},"Iframe placeholder")):a.createElement("iframe",{src:n,className:i})}function D(e){var t=e.children,r=e.className,n=e.scrollDownThreshold,i=void 0===n?.5:n,l=e.scrollUpThreshold,s=void 0===l?0:l,c=o.useRef(null),p=function(e){var t=e.ref,r=e.scrollDownThreshold,a=void 0===r?.5:r,n=e.scrollUpThreshold,i=void 0===n?0:n,l=o.useState(!1),s=l[0],c=l[1];return o.useEffect((function(){if(t.current&&"function"==typeof IntersectionObserver){var e=new IntersectionObserver((function(e){e[0].intersectionRatio>=a?c(!0):e[0].intersectionRatio<=i&&c(!1)}),{root:null,rootMargin:"0%",threshold:[i,a]});return e.observe(t.current),function(){c(!1),e.disconnect()}}return function(){}}),[t.current,a,i]),s}({ref:c,scrollUpThreshold:s,scrollDownThreshold:i});return a.createElement("div",{className:r,ref:c},p?t:null)}r(g,{name:"DynamicCollectionGrid",importPath:x,props:P}),r(N,{name:"Embed",importPath:"@plasmicpkgs/plasmic-basic-components/Embed",props:{code:{type:"string",defaultValue:"https://www.example.com"},hideInEditor:{type:"boolean",displayName:"Hide in editor",description:"Disable running the code while editing in Plasmic Studio (may require reload)"}},isDefaultExport:!0,defaultStyles:{maxWidth:"100%"}}),r(T,{name:"Iframe",importPath:"@plasmicpkgs/plasmic-basic-components/Iframe",props:{src:{type:"string",defaultValue:"https://www.example.com"},hideInEditor:{type:"boolean",displayName:"Preview",description:"Load the iframe while editing in Plasmic Studio"}},isDefaultExport:!0,defaultStyles:{width:"300px",height:"150px",maxWidth:"100%"}}),r(D,{name:"ScrollRevealer",displayName:"Scroll Revealer",importPath:"@plasmicpkgs/plasmic-basic-components/ScrollRevealer",props:{children:"slot",scrollDownThreshold:{type:"number",displayName:"Scroll down threshold",description:"How much of the element (as a fraction) must you scroll into view for it to appear (defaults to 0.5)"},scrollUpThreshold:{type:"number",displayName:"Scroll up threshold",description:"While scrolling up, how much of the element (as a fraction) can still be scrolled in view before it disappears (defaults to 0, meaning you must scroll up until it's completely out of view)"}},isDefaultExport:!0,defaultStyles:{width:"stretch",maxWidth:"100%"}});var I=a.forwardRef((function(e,t){return a.createElement("video",Object.assign({ref:t},e))}));r(I,{name:"Video",importPath:"@plasmicpkgs/plasmic-basic-components/Video",props:{src:{type:"string",defaultValue:"https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm",displayName:"Source URL",description:"URL to a video file."},autoPlay:{type:"boolean",displayName:"Auto Play",description:"Whether the video show automatically start playing when the player loads"},controls:{type:"boolean",displayName:"Show Controls",description:"Whether the video player controls should be displayed"},playsInline:{type:"boolean",displayName:"Plays inline",description:"Usually on mobile, when tilted landscape, videos can play fullscreen. Turn this on to prevent that."},loop:{type:"boolean",displayName:"Loop",description:"Whether the video should be played again after it finishes"},muted:{type:"boolean",displayName:"Muted",description:"Whether audio should be muted"},preload:{type:"choice",options:["none","metadata","auto"],displayName:"Preload",description:"Whether to preload nothing, metadata only, or the full video"}},isDefaultExport:!0,defaultStyles:{height:"hug",width:"640px",maxWidth:"100%"}}),exports.DataContext=c,exports.DataProvider=h,exports.DynamicCollection=b,exports.DynamicCollectionGrid=g,exports.DynamicElement=f,exports.DynamicImage=v,exports.DynamicText=y,exports.Embed=N,exports.Iframe=T,exports.ScrollRevealer=D,exports.Video=I,exports.applySelector=p,exports.dynamicCollectionGridProps=P,exports.dynamicCollectionProps=S,exports.useDataEnv=m,exports.useSelector=u,exports.useSelectors=d;
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@plasmicapp/host"),r=e(require("@plasmicapp/host/registerComponent")),o=require("react"),a=e(o);function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}function i(e,t){if(null==e)return{};var r,o,a={},n=Object.keys(e);for(o=0;o<n.length;o++)t.indexOf(r=n[o])>=0||(a[r]=e[r]);return a}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}var s=o.createContext(void 0),c="@plasmicpkgs/plasmic-basic-components";function p(e,t){if(t){for(var r,o=e,a=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,void 0):void 0}}(e))){r&&(e=r);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t.split("."));!(r=a()).done;){var n;o=null==(n=o)?void 0:n[r.value]}return o}}function m(e){return p(d(),e)}function u(e){void 0===e&&(e={});var t=d();return Object.fromEntries(Object.entries(e).filter((function(e){return!!e[0]&&!!e[1]})).map((function(e){return function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t}(e[0],p(t,e[1]))})))}function d(){return o.useContext(s)}function h(e){var t,r,o=e.name,i=e.data,l=e.children,c=null!=(t=d())?t:{};return o?a.createElement(s.Provider,{value:n({},c,(r={},r[o]=i,r))},l):a.createElement(a.Fragment,null,l)}function f(e){var t=e.tag,r=void 0===t?"div":t,a=e.className,l=e.children,s=e.propSelectors,c=i(e,["tag","className","children","propSelectors"]),p=u(s);return o.createElement(r,n({children:l},c,p,{className:a+" "+p.className}))}function y(e){var t=e.selector,r=e.propSelectors,o=i(e,["selector","propSelectors"]);return a.createElement(f,Object.assign({},o,{propSelectors:n({},r,{children:t})}),"(DynamicText requires a selector)")}function v(e){var t=e.selector,r=e.propSelectors,o=i(e,["selector","propSelectors"]);return a.createElement(f,Object.assign({tag:"img",loading:"lazy",style:{objectFit:"cover"}},o,{propSelectors:n({},r,{src:t}),src:"https://studio.plasmic.app/static/img/placeholder.png"}))}function g(e){var r,o=e.children,n=e.loopItemName,i=e.keySelector,l=e.data,s=null!=(r=null!=l?l:m(e.selector))?r:[1,2,3];return a.createElement(a.Fragment,null,null==s||null==s.map?void 0:s.map((function(e,r){var l;return a.createElement(h,{key:null!=(l=p(e,i))?l:r,name:n,data:e},t.repeatedElement(0===r,o))})))}var x={selector:{type:"string",description:"The selector expression to use to get the array of data to loop over, such as: someVariable.0.someField"},loopItemName:{type:"string",defaultValue:"item",description:"The name of the variable to use to store the current item in the loop"},children:"slot"},b={name:"hostless-dynamic-repeater",displayName:"Dynamic Repeater",importName:"DynamicRepeater",importPath:c,props:x},w={name:"hostless-data-provider",displayName:"Data Provider",importName:"DataProvider",importPath:c,props:{name:{type:"string",defaultValue:"celebrities",description:"The name of the variable to store the data in"},data:{type:"object",defaultValue:[{name:"Fill Murray",birthYear:1950,profilePicture:["https://www.fillmurray.com/200/300"]},{name:"Place Cage",birthYear:1950,profilePicture:["https://www.placecage.com/200/300"]}]},children:{type:"slot",defaultValue:[{type:"component",name:"hostless-dynamic-text",props:{selector:"celebrities.0.name"}},{type:"component",name:"hostless-dynamic-image",props:{selector:"celebrities.0.profilePicture"}}]}}},N={propSelectors:{type:"object",defaultValueHint:{},description:"An object whose keys are prop names and values are selector expressions. Use this to set any prop to a dynamic value."}},S=n({},N,{tag:{type:"string",defaultValueHint:"div",description:"The HTML tag to use"}}),D={name:"hostless-dynamic-element",displayName:"Dynamic Element",importName:"DynamicElement",importPath:c,props:n({},S,{children:"slot"})},P={name:"hostless-dynamic-text",importName:"DynamicText",displayName:"Dynamic Text",importPath:c,props:n({},S,{selector:{type:"string",description:"The selector expression to use to get the text, such as: someVariable.0.someField"}})},T={name:"hostless-dynamic-image",displayName:"Dynamic Image",importName:"DynamicImage",importPath:c,props:n({},N,{selector:{type:"string",description:"The selector expression to use to get the image source URL, such as: someVariable.0.someField"}})};function E(e){var r=e.preview,n=e.src,i=e.className;return o.useContext(t.PlasmicCanvasContext)&&!r?a.createElement("div",{className:i},a.createElement("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"#eee",color:"#888",fontSize:"36px",fontFamily:"sans-serif",fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"}},"Iframe placeholder")):a.createElement("iframe",{src:n,className:i})}var I={name:"hostless-iframe",displayName:"Iframe",importName:"Iframe",importPath:"@plasmicpkgs/plasmic-basic-components",props:{src:{type:"string",defaultValue:"https://www.example.com"},preview:{type:"boolean",description:"Load the iframe while editing in Plasmic Studio"}},defaultStyles:{width:"300px",height:"150px",maxWidth:"100%"}};function C(e){var t=e.ref,r=e.scrollDownThreshold,a=void 0===r?.5:r,n=e.scrollUpThreshold,i=void 0===n?0:n,l=o.useState(!1),s=l[0],c=l[1];return o.useEffect((function(){if(t.current&&"function"==typeof IntersectionObserver){var e=new IntersectionObserver((function(e){e[0].intersectionRatio>=a?c(!0):e[0].intersectionRatio<=i&&c(!1)}),{root:null,rootMargin:"0%",threshold:[i,a]});return e.observe(t.current),function(){c(!1),e.disconnect()}}return function(){}}),[t.current,a,i]),s}function j(e){var t=e.children,r=e.className,n=e.scrollDownThreshold,i=void 0===n?.5:n,l=e.scrollUpThreshold,s=void 0===l?0:l,c=o.useRef(null),p=C({ref:c,scrollUpThreshold:s,scrollDownThreshold:i});return a.createElement("div",{className:r,ref:c},p?t:null)}var R={name:"hostless-scroll-revealer",importName:"ScrollRevealer",displayName:"Scroll Revealer",importPath:"@plasmicpkgs/plasmic-basic-components",props:{children:"slot",scrollDownThreshold:{type:"number",displayName:"Scroll down threshold",defaultValueHint:.5,description:"How much of the element (as a fraction) must you scroll into view for it to appear (defaults to 0.5)"},scrollUpThreshold:{type:"number",displayName:"Scroll up threshold",defaultValueHint:0,description:"While scrolling up, how much of the element (as a fraction) can still be scrolled in view before it disappears (defaults to 0, meaning you must scroll up until it's completely out of view)"}},defaultStyles:{width:"stretch",maxWidth:"100%"}},V=a.forwardRef((function(e,t){return a.createElement("video",Object.assign({ref:t},e))})),M={name:"hostless-html-video",importName:"Video",displayName:"HTML Video",importPath:"@plasmicpkgs/plasmic-basic-components",props:{src:{type:"string",defaultValue:"https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm",displayName:"Source URL",description:"URL to a video file."},autoPlay:{type:"boolean",displayName:"Auto Play",description:"Whether the video show automatically start playing when the player loads"},controls:{type:"boolean",displayName:"Show Controls",description:"Whether the video player controls should be displayed"},playsInline:{type:"boolean",displayName:"Plays inline",description:"Usually on mobile, when tilted landscape, videos can play fullscreen. Turn this on to prevent that."},loop:{type:"boolean",displayName:"Loop",description:"Whether the video should be played again after it finishes"},muted:{type:"boolean",displayName:"Muted",description:"Whether audio should be muted"},poster:{type:"imageUrl",displayName:"Poster (placeholder) image",description:"Image to show while video is downloading"},preload:{type:"choice",options:["none","metadata","auto"],displayName:"Preload",description:"Whether to preload nothing, metadata only, or the full video"}},defaultStyles:{height:"hug",width:"640px",maxWidth:"100%"}};exports.DataContext=s,exports.DataProvider=h,exports.DynamicElement=f,exports.DynamicImage=v,exports.DynamicRepeater=g,exports.DynamicText=y,exports.Iframe=E,exports.ScrollRevealer=j,exports.Video=V,exports.applySelector=p,exports.dataProviderMeta=w,exports.dynamicElementMeta=D,exports.dynamicImageMeta=T,exports.dynamicRepeaterMeta=b,exports.dynamicRepeaterProps=x,exports.dynamicTextMeta=P,exports.iframeMeta=I,exports.registerDataProvider=function(e,t){e?e.registerComponent(h,null!=t?t:w):r(h,null!=t?t:w)},exports.registerDynamicElement=function(e,t){e?e.registerComponent(f,null!=t?t:D):r(f,null!=t?t:D)},exports.registerDynamicImage=function(e,t){e?e.registerComponent(v,null!=t?t:T):r(v,null!=t?t:T)},exports.registerDynamicRepeater=function(e,t){e?e.registerComponent(g,null!=t?t:b):r(g,null!=t?t:b)},exports.registerDynamicText=function(e,t){e?e.registerComponent(y,null!=t?t:P):r(y,null!=t?t:P)},exports.registerIframe=function(e,t){e?e.registerComponent(E,null!=t?t:I):r(E,null!=t?t:I)},exports.registerScrollRevealer=function(e,t){e?e.registerComponent(j,null!=t?t:R):r(j,null!=t?t:R)},exports.registerVideo=function(e,t){e?e.registerComponent(V,null!=t?t:M):r(V,null!=t?t:M)},exports.scrollRevealerMeta=R,exports.useDataEnv=d,exports.useDirectionalIntersection=C,exports.useSelector=m,exports.useSelectors=u,exports.videoMeta=M;
|
|
2
2
|
//# sourceMappingURL=plasmic-basic-components.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plasmic-basic-components.cjs.production.min.js","sources":["../src/common.ts","../src/Data.tsx","../src/Embed.tsx","../src/Iframe.tsx","../src/ScrollRevealer.tsx","../src/Video.tsx"],"sourcesContent":["export const tuple = <T extends any[]>(...args: T): T => args;\n\nexport function ensure<T>(x: T | null | undefined): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(`Value must not be undefined or null`);\n } else {\n return x;\n }\n}\n","/** @format */\n\nimport { repeatedElement } from \"@plasmicapp/host\";\nimport registerComponent from \"@plasmicapp/host/registerComponent\";\nimport React, {\n ComponentProps,\n createContext,\n createElement,\n CSSProperties,\n ReactNode,\n useContext,\n} from \"react\";\nimport { tuple } from \"./common\";\n\nexport type DataDict = Record<string, any>;\n\nexport const DataContext = createContext<DataDict | undefined>(undefined);\n\nexport function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface CommonDynamicProps {\n className?: string;\n tag?: string;\n propSelectors?: SelectorDict;\n}\n\nexport function DynamicElement<\n Tag extends keyof JSX.IntrinsicElements = \"div\"\n>({\n tag = \"div\",\n className,\n children,\n propSelectors,\n ...props\n}: CommonDynamicProps & ComponentProps<Tag>) {\n const computed = useSelectors(propSelectors);\n return createElement(tag, {\n children,\n ...props,\n ...computed,\n className: className + \" \" + computed.className,\n });\n}\n\nexport function DynamicText({\n selector,\n propSelectors,\n ...props\n}: CommonDynamicProps & {\n selector?: string;\n}) {\n return (\n <DynamicElement\n {...props}\n propSelectors={{ ...propSelectors, children: selector }}\n >\n {/*This is the default text*/}\n (DynamicText requires a selector)\n </DynamicElement>\n );\n}\n\nexport function DynamicImage({\n selector,\n propSelectors,\n ...props\n}: CommonDynamicProps &\n ComponentProps<\"img\"> & {\n selector?: string;\n }) {\n return (\n <DynamicElement<\"img\">\n tag={\"img\"}\n loading={\"lazy\"}\n style={{\n objectFit: \"cover\",\n }}\n {...props}\n propSelectors={{ ...propSelectors, src: selector }}\n // Default image placeholder\n src=\"https://studio.plasmic.app/static/img/placeholder.png\"\n />\n );\n}\n\nexport interface DynamicCollectionProps extends CommonDynamicProps {\n children?: ReactNode;\n style?: CSSProperties;\n loopItemName?: string;\n keySelector?: string;\n selector?: string;\n data?: any;\n}\n\nexport function DynamicCollection({\n selector,\n loopItemName,\n children,\n data,\n keySelector,\n ...props\n}: DynamicCollectionProps) {\n // Defaults to an array of three items.\n const finalData = data ?? useSelector(selector) ?? [1, 2, 3];\n return (\n <DynamicElement {...props}>\n {finalData?.map?.((item: any, index: number) => (\n <DataProvider\n key={applySelector(item, keySelector) ?? index}\n name={loopItemName}\n data={item}\n >\n {repeatedElement(index === 0, children)}\n </DataProvider>\n ))}\n </DynamicElement>\n );\n}\n\nexport interface DynamicCollectionGridProps extends DynamicCollectionProps {\n columns?: number;\n columnGap?: number;\n rowGap?: number;\n}\n\nexport function DynamicCollectionGrid({\n columns,\n columnGap = 0,\n rowGap = 0,\n ...props\n}: DynamicCollectionGridProps) {\n return (\n <DynamicCollection\n {...props}\n style={{\n display: \"grid\",\n gridTemplateColumns: `repeat(${columns}, 1fr)`,\n columnGap: `${columnGap}px`,\n rowGap: `${rowGap}px`,\n }}\n />\n );\n}\n\nconst thisModule = \"@plasmicpkgs/plasmic-basic-components/Data\";\n\nregisterComponent(DataProvider, {\n name: \"DataProvider\",\n importPath: thisModule,\n // description: \"Makes some specified data available to the subtree in a context\",\n props: {\n name: {\n type: \"string\",\n defaultValue: \"celebrities\",\n description: \"The name of the variable to store the data in\",\n },\n data: {\n type: \"object\",\n defaultValue: [\n {\n name: \"Fill Murray\",\n birthYear: 1950,\n profilePicture: [\"https://www.fillmurray.com/200/300\"],\n },\n {\n name: \"Place Cage\",\n birthYear: 1950,\n profilePicture: [\"https://www.placecage.com/200/300\"],\n },\n ],\n },\n children: {\n type: \"slot\",\n defaultValue: [\n {\n type: \"component\",\n name: \"DynamicText\",\n props: {\n selector: \"celebrities.0.name\",\n },\n },\n {\n type: \"component\",\n name: \"DynamicImage\",\n props: {\n selector: \"celebrities.0.profilePicture\",\n },\n },\n ],\n },\n },\n});\n\nconst dynamicPropsWithoutTag = {\n propSelectors: {\n type: \"object\",\n // defaultValueHint: {},\n description:\n \"An object whose keys are prop names and values are selector expressions. Use this to set any prop to a dynamic value.\",\n },\n} as const;\n\nconst dynamicProps = {\n ...dynamicPropsWithoutTag,\n tag: {\n type: \"string\",\n // defaultValueHint: \"div\",\n description: \"The HTML tag to use\",\n },\n} as const;\n\n// TODO Eventually we'll want to expose all the base HTML properties, but in the nicer way that we do within the studio.\n\nregisterComponent(DynamicElement, {\n name: \"DynamicElement\",\n importPath: thisModule,\n props: { ...dynamicProps, children: \"slot\" },\n});\n\nregisterComponent(DynamicText, {\n name: \"DynamicText\",\n importPath: thisModule,\n props: {\n ...dynamicProps,\n selector: {\n type: \"string\",\n description:\n \"The selector expression to use to get the text, such as: someVariable.0.someField\",\n },\n },\n});\n\nregisterComponent(DynamicImage, {\n name: \"DynamicImage\",\n importPath: thisModule,\n props: {\n ...dynamicPropsWithoutTag,\n selector: {\n type: \"string\",\n description:\n \"The selector expression to use to get the image source URL, such as: someVariable.0.someField\",\n },\n },\n});\n\nexport const dynamicCollectionProps = {\n ...dynamicProps,\n selector: {\n type: \"string\",\n description:\n \"The selector expression to use to get the array of data to loop over, such as: someVariable.0.someField\",\n },\n loopItemName: {\n type: \"string\",\n defaultValue: \"item\",\n description:\n \"The name of the variable to use to store the current item in the loop\",\n },\n children: \"slot\",\n} as const;\n\nregisterComponent(DynamicCollection, {\n name: \"DynamicCollection\",\n importPath: thisModule,\n props: dynamicCollectionProps,\n});\n\nexport const dynamicCollectionGridProps = {\n ...dynamicCollectionProps,\n columns: {\n type: \"number\",\n defaultValue: 2,\n description: \"The number of columns to use in the grid\",\n },\n columnGap: {\n type: \"number\",\n defaultValue: 8,\n description: \"The gap between columns\",\n },\n rowGap: {\n type: \"number\",\n defaultValue: 8,\n description: \"The gap between rows\",\n },\n} as const;\n\nregisterComponent(DynamicCollectionGrid, {\n name: \"DynamicCollectionGrid\",\n importPath: thisModule,\n props: dynamicCollectionGridProps,\n});\n","/** @format */\n\nimport registerComponent from \"@plasmicapp/host/registerComponent\";\nimport React, { useEffect, useRef } from \"react\";\nimport { ensure } from \"./common\";\n\nexport interface EmbedProps {\n className?: string;\n code: string;\n hideInEditor?: boolean;\n}\n\nexport default function Embed({\n className,\n code,\n hideInEditor = false,\n}: EmbedProps) {\n const rootElt = useRef<HTMLDivElement>(null);\n useEffect(() => {\n if (hideInEditor) {\n return;\n }\n Array.from(ensure(rootElt.current).querySelectorAll(\"script\")).forEach(\n (oldScript) => {\n const newScript = document.createElement(\"script\");\n Array.from(oldScript.attributes).forEach((attr) =>\n newScript.setAttribute(attr.name, attr.value)\n );\n newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n ensure(oldScript.parentNode).replaceChild(newScript, oldScript);\n }\n );\n }, [code, hideInEditor]);\n const effectiveCode = hideInEditor ? \"\" : code;\n return (\n <div\n ref={rootElt}\n className={className}\n dangerouslySetInnerHTML={{ __html: effectiveCode }}\n />\n );\n}\n\nregisterComponent(Embed, {\n name: \"Embed\",\n importPath: \"@plasmicpkgs/plasmic-basic-components/Embed\",\n props: {\n code: {\n type: \"string\",\n defaultValue: \"https://www.example.com\",\n },\n hideInEditor: {\n type: \"boolean\",\n displayName: \"Hide in editor\",\n description:\n \"Disable running the code while editing in Plasmic Studio (may require reload)\",\n },\n },\n isDefaultExport: true,\n defaultStyles: {\n maxWidth: \"100%\",\n },\n});\n","/** @format */\n\nimport { PlasmicCanvasContext } from \"@plasmicapp/host\";\nimport registerComponent from \"@plasmicapp/host/registerComponent\";\nimport React, { useContext } from \"react\";\n\nexport interface IframeProps {\n src: string;\n hideInEditor?: boolean;\n className?: string;\n}\n\nexport default function Iframe({ hideInEditor, src, className }: IframeProps) {\n const isEditing = useContext(PlasmicCanvasContext);\n if (isEditing && !hideInEditor) {\n return (\n <div className={className}>\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n background: \"#eee\",\n color: \"#888\",\n fontSize: \"36px\",\n fontFamily: \"sans-serif\",\n fontWeight: \"bold\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n }}\n >\n Iframe placeholder\n </div>\n </div>\n );\n }\n return <iframe src={src} className={className} />;\n}\n\nregisterComponent(Iframe, {\n name: \"Iframe\",\n importPath: \"@plasmicpkgs/plasmic-basic-components/Iframe\",\n props: {\n src: {\n type: \"string\",\n defaultValue: \"https://www.example.com\",\n },\n hideInEditor: {\n type: \"boolean\",\n displayName: \"Preview\",\n description: \"Load the iframe while editing in Plasmic Studio\",\n },\n },\n isDefaultExport: true,\n defaultStyles: {\n width: \"300px\",\n height: \"150px\",\n maxWidth: \"100%\",\n },\n});\n","import registerComponent from \"@plasmicapp/host/registerComponent\";\nimport React, {\n ReactNode,\n RefObject,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nexport function useDirectionalIntersection({\n ref,\n scrollDownThreshold = 0.5,\n scrollUpThreshold = 0,\n}: {\n ref: RefObject<HTMLElement>;\n scrollDownThreshold?: number;\n scrollUpThreshold?: number;\n}) {\n const [revealed, setRevealed] = useState(false);\n useEffect(() => {\n if (ref.current && typeof IntersectionObserver === \"function\") {\n const handler = (entries: IntersectionObserverEntry[]) => {\n if (entries[0].intersectionRatio >= scrollDownThreshold) {\n setRevealed(true);\n } else if (entries[0].intersectionRatio <= scrollUpThreshold) {\n setRevealed(false);\n }\n };\n\n const observer = new IntersectionObserver(handler, {\n root: null,\n rootMargin: \"0%\",\n threshold: [scrollUpThreshold, scrollDownThreshold],\n });\n observer.observe(ref.current);\n\n return () => {\n setRevealed(false);\n observer.disconnect();\n };\n }\n return () => {};\n }, [ref.current, scrollDownThreshold, scrollUpThreshold]);\n return revealed;\n}\n\n/**\n * Unlike react-awesome-reveal, ScrollRevealer:\n *\n * - has configurable thresholds\n * - triggers arbitrary render/unrender animations\n *\n * TODO: Merge this inta a general Reveal component, perhaps forking react-awesome-reveal, so that we don't have two different reveal components for users.\n */\nexport default function ScrollRevealer({\n children,\n className,\n scrollDownThreshold = 0.5,\n scrollUpThreshold = 0,\n}: {\n children?: ReactNode;\n className?: string;\n scrollUpThreshold?: number;\n scrollDownThreshold?: number;\n}) {\n const intersectionRef = useRef<HTMLDivElement>(null);\n const revealed = useDirectionalIntersection({\n ref: intersectionRef,\n scrollUpThreshold,\n scrollDownThreshold,\n });\n return (\n <div className={className} ref={intersectionRef}>\n {revealed ? children : null}\n </div>\n );\n}\n\nregisterComponent(ScrollRevealer, {\n name: \"ScrollRevealer\",\n displayName: \"Scroll Revealer\",\n importPath: \"@plasmicpkgs/plasmic-basic-components/ScrollRevealer\",\n props: {\n children: \"slot\",\n scrollDownThreshold: {\n type: \"number\",\n displayName: \"Scroll down threshold\",\n // defaultValueHint: 0.5,\n description:\n \"How much of the element (as a fraction) must you scroll into view for it to appear (defaults to 0.5)\",\n },\n scrollUpThreshold: {\n type: \"number\",\n displayName: \"Scroll up threshold\",\n // defaultValueHint: 0,\n description:\n \"While scrolling up, how much of the element (as a fraction) can still be scrolled in view before it disappears (defaults to 0, meaning you must scroll up until it's completely out of view)\",\n },\n },\n isDefaultExport: true,\n defaultStyles: {\n width: \"stretch\",\n maxWidth: \"100%\",\n },\n});\n","import registerComponent from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\ntype VideoProps = Pick<\n React.ComponentProps<\"video\">,\n | \"autoPlay\"\n | \"controls\"\n | \"loop\"\n | \"muted\"\n | \"playsInline\"\n | \"poster\"\n | \"preload\"\n | \"src\"\n>;\n\nconst Video = React.forwardRef<HTMLVideoElement, VideoProps>(\n (props: VideoProps, ref) => {\n return <video ref={ref} {...props} />;\n }\n);\n\nexport default Video;\n\nregisterComponent(Video, {\n name: \"Video\",\n importPath: \"@plasmicpkgs/plasmic-basic-components/Video\",\n props: {\n src: {\n type: \"string\",\n defaultValue:\n \"https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm\",\n displayName: \"Source URL\",\n description: \"URL to a video file.\",\n },\n autoPlay: {\n type: \"boolean\",\n displayName: \"Auto Play\",\n description:\n \"Whether the video show automatically start playing when the player loads\",\n },\n controls: {\n type: \"boolean\",\n displayName: \"Show Controls\",\n description: \"Whether the video player controls should be displayed\",\n },\n playsInline: {\n type: \"boolean\",\n displayName: \"Plays inline\",\n description:\n \"Usually on mobile, when tilted landscape, videos can play fullscreen. Turn this on to prevent that.\",\n },\n loop: {\n type: \"boolean\",\n displayName: \"Loop\",\n description: \"Whether the video should be played again after it finishes\",\n },\n muted: {\n type: \"boolean\",\n displayName: \"Muted\",\n description: \"Whether audio should be muted\",\n },\n // TODO enable this once image is a type\n // poster: {\n // type: \"image\",\n // displayName: \"Poster (placeholder) image\",\n // description:\n // \"Image to show while video is downloading\",\n // },\n preload: {\n type: \"choice\",\n options: [\"none\", \"metadata\", \"auto\"],\n displayName: \"Preload\",\n description:\n \"Whether to preload nothing, metadata only, or the full video\",\n },\n },\n isDefaultExport: true,\n defaultStyles: {\n height: \"hug\",\n width: \"640px\",\n maxWidth: \"100%\",\n },\n});\n"],"names":["ensure","x","Error","DataContext","createContext","undefined","applySelector","rawData","selector","curData","split","_curData","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","map","args","tuple","useContext","DataProvider","name","data","children","existingEnv","React","Provider","value","DynamicElement","tag","className","propSelectors","props","computed","createElement","DynamicText","DynamicImage","loading","style","objectFit","src","DynamicCollection","loopItemName","keySelector","finalData","item","index","key","repeatedElement","DynamicCollectionGrid","columns","columnGap","rowGap","display","gridTemplateColumns","thisModule","registerComponent","importPath","type","defaultValue","description","birthYear","profilePicture","dynamicPropsWithoutTag","dynamicProps","dynamicCollectionProps","dynamicCollectionGridProps","Embed","code","hideInEditor","rootElt","useRef","useEffect","Array","from","current","querySelectorAll","forEach","oldScript","newScript","document","attributes","attr","setAttribute","appendChild","createTextNode","innerHTML","parentNode","replaceChild","ref","dangerouslySetInnerHTML","__html","Iframe","PlasmicCanvasContext","position","top","left","right","bottom","background","color","fontSize","fontFamily","fontWeight","alignItems","justifyContent","overflow","ScrollRevealer","scrollDownThreshold","scrollUpThreshold","intersectionRef","revealed","useState","setRevealed","IntersectionObserver","observer","intersectionRatio","root","rootMargin","threshold","observe","disconnect","useDirectionalIntersection","displayName","isDefaultExport","defaultStyles","maxWidth","width","height","Video","forwardRef","autoPlay","controls","playsInline","loop","muted","preload","options"],"mappings":"+rBAEgBA,EAAUC,MACpBA,MAAAA,QAEI,IAAIC,oDAEHD,MCSEE,EAAcC,qBAAoCC,YAE/CC,EACdC,EACAC,MAEKA,aAGDC,EAAUF,wrBACIC,EAASE,MAAM,qBAAM,OACrCD,WAAUA,UAAAE,kBAELF,YAKOG,EAAYJ,UAEnBF,EADSO,IACcL,YAGhBM,EAAaC,YAAAA,IAAAA,EAA0B,QAC/CR,EAAUM,WACTG,OAAOC,YACZD,OAAOE,QAAQH,GACZI,QAAO,oCACPC,KAAI,mBD5CU,sCAAqBC,2BAAAA,yBAAeA,EC4CzBC,MAAWhB,EAAcC,aAIzD,SAAgBM,WACPU,aAAWpB,YASJqB,aAAeC,IAAAA,KAAMC,IAAAA,KAAMC,IAAAA,SACnCC,WAAcf,OAAgB,UAC/BY,EAIDI,gBAAC1B,EAAY2B,UAASC,WAAYH,UAAcH,GAAOC,OACpDC,GAJEE,gCAAGF,YAgBEK,aAGdC,IAAAA,aAAM,QACNC,IAAAA,UACAP,IAAAA,SACAQ,IAAAA,cACGC,sDAEGC,EAAWvB,EAAaqB,UACvBG,gBAAcL,KACnBN,SAAAA,GACGS,EACAC,GACHH,UAAWA,EAAY,IAAMG,EAASH,sBAI1BK,SACd/B,IAAAA,SACA2B,IAAAA,cACGC,2CAKDP,gBAACG,mBACKI,GACJD,mBAAoBA,GAAeR,SAAUnB,oDAQnCgC,SACdhC,IAAAA,SACA2B,IAAAA,cACGC,2CAMDP,gBAACG,iBACCC,IAAK,MACLQ,QAAS,OACTC,MAAO,CACLC,UAAW,UAETP,GACJD,mBAAoBA,GAAeS,IAAKpC,IAExCoC,IAAI,oEAcMC,WACdrC,IAAAA,SACAsC,IAAAA,aACAnB,IAAAA,SACAD,IAAAA,KACAqB,IAAAA,YACGX,mEAGGY,iBAAY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,iBACNsG,YAAa,kBACblE,WAAY,uDACZzB,MAAO,CACLT,SAAU,OACVqF,oBAAqB,CACnBlD,KAAM,SACNiE,YAAa,wBAEb/D,YACE,wGAEJiD,kBAAmB,CACjBnD,KAAM,SACNiE,YAAa,sBAEb/D,YACE,iMAGNgE,iBAAiB,EACjBC,cAAe,CACbE,MAAO,UACPD,SAAU,cCvFRG,EAAQxG,EAAMyG,YAClB,SAAClG,EAAmByD,UACXhE,uCAAOgE,IAAKA,GAASzD,OAIhCwB,EAEkByE,EAAO,CACvB5G,KAAM,QACNoC,WAAY,8CACZzB,MAAO,CACLQ,IAAK,CACHkB,KAAM,SACNC,aACE,4EACFgE,YAAa,aACb/D,YAAa,wBAEfuE,SAAU,CACRzE,KAAM,UACNiE,YAAa,YACb/D,YACE,4EAEJwE,SAAU,CACR1E,KAAM,UACNiE,YAAa,gBACb/D,YAAa,yDAEfyE,YAAa,CACX3E,KAAM,UACNiE,YAAa,eACb/D,YACE,uGAEJ0E,KAAM,CACJ5E,KAAM,UACNiE,YAAa,OACb/D,YAAa,8DAEf2E,MAAO,CACL7E,KAAM,UACNiE,YAAa,QACb/D,YAAa,iCASf4E,QAAS,CACP9E,KAAM,SACN+E,QAAS,CAAC,OAAQ,WAAY,QAC9Bd,YAAa,UACb/D,YACE,iEAGNgE,iBAAiB,EACjBC,cAAe,CACbG,OAAQ,MACRD,MAAO,QACPD,SAAU"}
|
|
1
|
+
{"version":3,"file":"plasmic-basic-components.cjs.production.min.js","sources":["../src/common.ts","../src/Data.tsx","../src/Iframe.tsx","../src/ScrollRevealer.tsx","../src/Video.tsx"],"sourcesContent":["export const tuple = <T extends any[]>(...args: T): T => args;\n\nexport function ensure<T>(x: T | null | undefined): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(`Value must not be undefined or null`);\n } else {\n return x;\n }\n}\n","import { ComponentMeta, repeatedElement } from \"@plasmicapp/host\";\nimport registerComponent from \"@plasmicapp/host/registerComponent\";\nimport React, {\n ComponentProps,\n createContext,\n createElement,\n ReactNode,\n useContext,\n} from \"react\";\nimport { tuple } from \"./common\";\n\nexport type DataDict = Record<string, any>;\n\nexport const DataContext = createContext<DataDict | undefined>(undefined);\n\nconst thisModule = \"@plasmicpkgs/plasmic-basic-components\";\n\nexport function applySelector(\n rawData: DataDict | undefined,\n selector: string | undefined\n): any {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n}\n\nexport type SelectorDict = Record<string, string | undefined>;\n\nexport function useSelector(selector: string | undefined): any {\n const rawData = useDataEnv();\n return applySelector(rawData, selector);\n}\n\nexport function useSelectors(selectors: SelectorDict = {}): any {\n const rawData = useDataEnv();\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => tuple(key, applySelector(rawData, selector)))\n );\n}\n\nexport function useDataEnv() {\n return useContext(DataContext);\n}\n\nexport interface DataProviderProps {\n name?: string;\n data?: any;\n children?: ReactNode;\n}\n\nexport function DataProvider({ name, data, children }: DataProviderProps) {\n const existingEnv = useDataEnv() ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n return (\n <DataContext.Provider value={{ ...existingEnv, [name]: data }}>\n {children}\n </DataContext.Provider>\n );\n }\n}\n\nexport interface CommonDynamicProps {\n className?: string;\n tag?: string;\n propSelectors?: SelectorDict;\n}\n\nexport function DynamicElement<\n Tag extends keyof JSX.IntrinsicElements = \"div\"\n>({\n tag = \"div\",\n className,\n children,\n propSelectors,\n ...props\n}: CommonDynamicProps & ComponentProps<Tag>) {\n const computed = useSelectors(propSelectors);\n return createElement(tag, {\n children,\n ...props,\n ...computed,\n className: className + \" \" + computed.className,\n });\n}\n\nexport interface DynamicTextProps extends CommonDynamicProps {\n selector?: string;\n}\n\nexport function DynamicText({\n selector,\n propSelectors,\n ...props\n}: DynamicTextProps) {\n return (\n <DynamicElement\n {...props}\n propSelectors={{ ...propSelectors, children: selector }}\n >\n {/*This is the default text*/}\n (DynamicText requires a selector)\n </DynamicElement>\n );\n}\n\nexport interface DynamicImageProps\n extends CommonDynamicProps,\n ComponentProps<\"img\"> {\n selector?: string;\n}\n\nexport function DynamicImage({\n selector,\n propSelectors,\n ...props\n}: DynamicImageProps) {\n return (\n <DynamicElement<\"img\">\n tag={\"img\"}\n loading={\"lazy\"}\n style={{\n objectFit: \"cover\",\n }}\n {...props}\n propSelectors={{ ...propSelectors, src: selector }}\n // Default image placeholder\n src=\"https://studio.plasmic.app/static/img/placeholder.png\"\n />\n );\n}\n\nexport interface DynamicRepeaterProps {\n children?: ReactNode;\n loopItemName?: string;\n keySelector?: string;\n selector?: string;\n data?: any;\n}\n\nexport function DynamicRepeater({\n children,\n loopItemName,\n keySelector,\n selector,\n data,\n}: DynamicRepeaterProps) {\n // Defaults to an array of three items.\n const finalData = data ?? useSelector(selector) ?? [1, 2, 3];\n return (\n <>\n {finalData?.map?.((item: any, index: number) => (\n <DataProvider\n key={applySelector(item, keySelector) ?? index}\n name={loopItemName}\n data={item}\n >\n {repeatedElement(index === 0, children)}\n </DataProvider>\n ))}\n </>\n );\n}\n\nexport const dynamicRepeaterProps = {\n selector: {\n type: \"string\",\n description:\n \"The selector expression to use to get the array of data to loop over, such as: someVariable.0.someField\",\n },\n loopItemName: {\n type: \"string\",\n defaultValue: \"item\",\n description:\n \"The name of the variable to use to store the current item in the loop\",\n },\n children: \"slot\",\n} as const;\n\nexport const dynamicRepeaterMeta: ComponentMeta<DynamicRepeaterProps> = {\n name: \"hostless-dynamic-repeater\",\n displayName: \"Dynamic Repeater\",\n importName: \"DynamicRepeater\",\n importPath: thisModule,\n props: dynamicRepeaterProps,\n};\n\nexport function registerDynamicRepeater(\n loader?: { registerComponent: typeof registerComponent },\n customDynamicRepeaterMeta?: ComponentMeta<DynamicRepeaterProps>\n) {\n if (loader) {\n loader.registerComponent(\n DynamicRepeater,\n customDynamicRepeaterMeta ?? dynamicRepeaterMeta\n );\n } else {\n registerComponent(\n DynamicRepeater,\n customDynamicRepeaterMeta ?? dynamicRepeaterMeta\n );\n }\n}\n\nexport const dataProviderMeta: ComponentMeta<DataProviderProps> = {\n name: \"hostless-data-provider\",\n displayName: \"Data Provider\",\n importName: \"DataProvider\",\n importPath: thisModule,\n // description: \"Makes some specified data available to the subtree in a context\",\n props: {\n name: {\n type: \"string\",\n defaultValue: \"celebrities\",\n description: \"The name of the variable to store the data in\",\n },\n data: {\n type: \"object\",\n defaultValue: [\n {\n name: \"Fill Murray\",\n birthYear: 1950,\n profilePicture: [\"https://www.fillmurray.com/200/300\"],\n },\n {\n name: \"Place Cage\",\n birthYear: 1950,\n profilePicture: [\"https://www.placecage.com/200/300\"],\n },\n ],\n },\n children: {\n type: \"slot\",\n defaultValue: [\n {\n type: \"component\",\n name: \"hostless-dynamic-text\",\n props: {\n selector: \"celebrities.0.name\",\n },\n },\n {\n type: \"component\",\n name: \"hostless-dynamic-image\",\n props: {\n selector: \"celebrities.0.profilePicture\",\n },\n },\n ],\n },\n },\n};\n\nexport function registerDataProvider(\n loader?: { registerComponent: typeof registerComponent },\n customDataProviderMeta?: ComponentMeta<DataProviderProps>\n) {\n if (loader) {\n loader.registerComponent(\n DataProvider,\n customDataProviderMeta ?? dataProviderMeta\n );\n } else {\n registerComponent(DataProvider, customDataProviderMeta ?? dataProviderMeta);\n }\n}\n\nconst dynamicPropsWithoutTag = {\n propSelectors: {\n type: \"object\",\n defaultValueHint: {},\n description:\n \"An object whose keys are prop names and values are selector expressions. Use this to set any prop to a dynamic value.\",\n },\n} as const;\n\nconst dynamicProps = {\n ...dynamicPropsWithoutTag,\n tag: {\n type: \"string\",\n defaultValueHint: \"div\",\n description: \"The HTML tag to use\",\n },\n} as const;\n\n// TODO Eventually we'll want to expose all the base HTML properties, but in the nicer way that we do within the studio.\n\nexport const dynamicElementMeta: ComponentMeta<CommonDynamicProps> = {\n name: \"hostless-dynamic-element\",\n displayName: \"Dynamic Element\",\n importName: \"DynamicElement\",\n importPath: thisModule,\n props: { ...dynamicProps, children: \"slot\" },\n};\n\nexport function registerDynamicElement(\n loader?: { registerComponent: typeof registerComponent },\n customDynamicElementMeta?: ComponentMeta<CommonDynamicProps>\n) {\n if (loader) {\n loader.registerComponent(\n DynamicElement,\n customDynamicElementMeta ?? dynamicElementMeta\n );\n } else {\n registerComponent(\n DynamicElement,\n customDynamicElementMeta ?? dynamicElementMeta\n );\n }\n}\n\nexport const dynamicTextMeta: ComponentMeta<DynamicTextProps> = {\n name: \"hostless-dynamic-text\",\n importName: \"DynamicText\",\n displayName: \"Dynamic Text\",\n importPath: thisModule,\n props: {\n ...dynamicProps,\n selector: {\n type: \"string\",\n description:\n \"The selector expression to use to get the text, such as: someVariable.0.someField\",\n },\n },\n};\n\nexport function registerDynamicText(\n loader?: { registerComponent: typeof registerComponent },\n customDynamicTextMeta?: ComponentMeta<DynamicTextProps>\n) {\n if (loader) {\n loader.registerComponent(\n DynamicText,\n customDynamicTextMeta ?? dynamicTextMeta\n );\n } else {\n registerComponent(DynamicText, customDynamicTextMeta ?? dynamicTextMeta);\n }\n}\n\nexport const dynamicImageMeta: ComponentMeta<DynamicImageProps> = {\n name: \"hostless-dynamic-image\",\n displayName: \"Dynamic Image\",\n importName: \"DynamicImage\",\n importPath: thisModule,\n props: {\n ...dynamicPropsWithoutTag,\n selector: {\n type: \"string\",\n description:\n \"The selector expression to use to get the image source URL, such as: someVariable.0.someField\",\n },\n },\n};\n\nexport function registerDynamicImage(\n loader?: { registerComponent: typeof registerComponent },\n customDynamicImageMeta?: ComponentMeta<DynamicImageProps>\n) {\n if (loader) {\n loader.registerComponent(\n DynamicImage,\n customDynamicImageMeta ?? dynamicImageMeta\n );\n } else {\n registerComponent(DynamicImage, customDynamicImageMeta ?? dynamicImageMeta);\n }\n}\n","import { ComponentMeta, PlasmicCanvasContext } from \"@plasmicapp/host\";\nimport registerComponent from \"@plasmicapp/host/registerComponent\";\nimport React, { useContext } from \"react\";\n\nexport interface IframeProps {\n src: string;\n preview?: boolean;\n className?: string;\n}\n\nexport default function Iframe({ preview, src, className }: IframeProps) {\n const isEditing = useContext(PlasmicCanvasContext);\n if (isEditing && !preview) {\n return (\n <div className={className}>\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n background: \"#eee\",\n color: \"#888\",\n fontSize: \"36px\",\n fontFamily: \"sans-serif\",\n fontWeight: \"bold\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n }}\n >\n Iframe placeholder\n </div>\n </div>\n );\n }\n return <iframe src={src} className={className} />;\n}\n\nexport const iframeMeta: ComponentMeta<IframeProps> = {\n name: \"hostless-iframe\",\n displayName: \"Iframe\",\n importName: \"Iframe\",\n importPath: \"@plasmicpkgs/plasmic-basic-components\",\n props: {\n src: {\n type: \"string\",\n defaultValue: \"https://www.example.com\",\n },\n preview: {\n type: \"boolean\",\n description: \"Load the iframe while editing in Plasmic Studio\",\n },\n },\n defaultStyles: {\n width: \"300px\",\n height: \"150px\",\n maxWidth: \"100%\",\n },\n};\n\nexport function registerIframe(\n loader?: { registerComponent: typeof registerComponent },\n customIframeMeta?: ComponentMeta<IframeProps>\n) {\n if (loader) {\n loader.registerComponent(Iframe, customIframeMeta ?? iframeMeta);\n } else {\n registerComponent(Iframe, customIframeMeta ?? iframeMeta);\n }\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React, {\n ReactNode,\n RefObject,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nexport function useDirectionalIntersection({\n ref,\n scrollDownThreshold = 0.5,\n scrollUpThreshold = 0,\n}: {\n ref: RefObject<HTMLElement>;\n scrollDownThreshold?: number;\n scrollUpThreshold?: number;\n}) {\n const [revealed, setRevealed] = useState(false);\n useEffect(() => {\n if (ref.current && typeof IntersectionObserver === \"function\") {\n const handler = (entries: IntersectionObserverEntry[]) => {\n if (entries[0].intersectionRatio >= scrollDownThreshold) {\n setRevealed(true);\n } else if (entries[0].intersectionRatio <= scrollUpThreshold) {\n setRevealed(false);\n }\n };\n\n const observer = new IntersectionObserver(handler, {\n root: null,\n rootMargin: \"0%\",\n threshold: [scrollUpThreshold, scrollDownThreshold],\n });\n observer.observe(ref.current);\n\n return () => {\n setRevealed(false);\n observer.disconnect();\n };\n }\n return () => {};\n }, [ref.current, scrollDownThreshold, scrollUpThreshold]);\n return revealed;\n}\n\nexport interface ScrollRevealerProps {\n children?: ReactNode;\n className?: string;\n scrollUpThreshold?: number;\n scrollDownThreshold?: number;\n}\n\n/**\n * Unlike react-awesome-reveal, ScrollRevealer:\n *\n * - has configurable thresholds\n * - triggers arbitrary render/unrender animations\n *\n * TODO: Merge this inta a general Reveal component, perhaps forking react-awesome-reveal, so that we don't have two different reveal components for users.\n */\nexport default function ScrollRevealer({\n children,\n className,\n scrollDownThreshold = 0.5,\n scrollUpThreshold = 0,\n}: ScrollRevealerProps) {\n const intersectionRef = useRef<HTMLDivElement>(null);\n const revealed = useDirectionalIntersection({\n ref: intersectionRef,\n scrollUpThreshold,\n scrollDownThreshold,\n });\n return (\n <div className={className} ref={intersectionRef}>\n {revealed ? children : null}\n </div>\n );\n}\n\nexport const scrollRevealerMeta: ComponentMeta<ScrollRevealerProps> = {\n name: \"hostless-scroll-revealer\",\n importName: \"ScrollRevealer\",\n displayName: \"Scroll Revealer\",\n importPath: \"@plasmicpkgs/plasmic-basic-components\",\n props: {\n children: \"slot\",\n scrollDownThreshold: {\n type: \"number\",\n displayName: \"Scroll down threshold\",\n defaultValueHint: 0.5,\n description:\n \"How much of the element (as a fraction) must you scroll into view for it to appear (defaults to 0.5)\",\n },\n scrollUpThreshold: {\n type: \"number\",\n displayName: \"Scroll up threshold\",\n defaultValueHint: 0,\n description:\n \"While scrolling up, how much of the element (as a fraction) can still be scrolled in view before it disappears (defaults to 0, meaning you must scroll up until it's completely out of view)\",\n },\n },\n defaultStyles: {\n width: \"stretch\",\n maxWidth: \"100%\",\n },\n};\n\nexport function registerScrollRevealer(\n loader?: { registerComponent: typeof registerComponent },\n customScrollRevealerMeta?: ComponentMeta<ScrollRevealerProps>\n) {\n if (loader) {\n loader.registerComponent(\n ScrollRevealer,\n customScrollRevealerMeta ?? scrollRevealerMeta\n );\n } else {\n registerComponent(\n ScrollRevealer,\n customScrollRevealerMeta ?? scrollRevealerMeta\n );\n }\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport type VideoProps = Pick<\n React.ComponentProps<\"video\">,\n | \"autoPlay\"\n | \"controls\"\n | \"loop\"\n | \"muted\"\n | \"playsInline\"\n | \"poster\"\n | \"preload\"\n | \"src\"\n>;\n\nconst Video = React.forwardRef<HTMLVideoElement, VideoProps>(\n (props: VideoProps, ref) => {\n return <video ref={ref} {...props} />;\n }\n);\n\nexport default Video;\n\nexport const videoMeta: ComponentMeta<VideoProps> = {\n name: \"hostless-html-video\",\n importName: \"Video\",\n displayName: \"HTML Video\",\n importPath: \"@plasmicpkgs/plasmic-basic-components\",\n props: {\n src: {\n type: \"string\",\n defaultValue:\n \"https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm\",\n displayName: \"Source URL\",\n description: \"URL to a video file.\",\n },\n autoPlay: {\n type: \"boolean\",\n displayName: \"Auto Play\",\n description:\n \"Whether the video show automatically start playing when the player loads\",\n },\n controls: {\n type: \"boolean\",\n displayName: \"Show Controls\",\n description: \"Whether the video player controls should be displayed\",\n },\n playsInline: {\n type: \"boolean\",\n displayName: \"Plays inline\",\n description:\n \"Usually on mobile, when tilted landscape, videos can play fullscreen. Turn this on to prevent that.\",\n },\n loop: {\n type: \"boolean\",\n displayName: \"Loop\",\n description: \"Whether the video should be played again after it finishes\",\n },\n muted: {\n type: \"boolean\",\n displayName: \"Muted\",\n description: \"Whether audio should be muted\",\n },\n poster: {\n type: \"imageUrl\",\n displayName: \"Poster (placeholder) image\",\n description: \"Image to show while video is downloading\",\n },\n preload: {\n type: \"choice\",\n options: [\"none\", \"metadata\", \"auto\"],\n displayName: \"Preload\",\n description:\n \"Whether to preload nothing, metadata only, or the full video\",\n },\n },\n defaultStyles: {\n height: \"hug\",\n width: \"640px\",\n maxWidth: \"100%\",\n },\n};\n\nexport function registerVideo(\n loader?: { registerComponent: typeof registerComponent },\n customVideoMeta?: ComponentMeta<VideoProps>\n) {\n if (loader) {\n loader.registerComponent(Video, customVideoMeta ?? videoMeta);\n } else {\n registerComponent(Video, customVideoMeta ?? videoMeta);\n }\n}\n"],"names":["DataContext","createContext","undefined","thisModule","applySelector","rawData","selector","curData","split","_curData","useSelector","useDataEnv","useSelectors","selectors","Object","fromEntries","entries","filter","map","args","tuple","useContext","DataProvider","name","data","children","existingEnv","React","Provider","value","DynamicElement","tag","className","propSelectors","props","computed","createElement","DynamicText","DynamicImage","loading","style","objectFit","src","DynamicRepeater","loopItemName","keySelector","finalData","item","index","key","repeatedElement","dynamicRepeaterProps","type","description","defaultValue","dynamicRepeaterMeta","displayName","importName","importPath","dataProviderMeta","birthYear","profilePicture","dynamicPropsWithoutTag","defaultValueHint","dynamicProps","dynamicElementMeta","dynamicTextMeta","dynamicImageMeta","Iframe","preview","PlasmicCanvasContext","position","top","left","right","bottom","background","color","fontSize","fontFamily","fontWeight","display","alignItems","justifyContent","overflow","iframeMeta","defaultStyles","width","height","maxWidth","useDirectionalIntersection","ref","scrollDownThreshold","scrollUpThreshold","useState","revealed","setRevealed","useEffect","current","IntersectionObserver","observer","intersectionRatio","root","rootMargin","threshold","observe","disconnect","ScrollRevealer","intersectionRef","useRef","scrollRevealerMeta","Video","forwardRef","videoMeta","autoPlay","controls","playsInline","loop","muted","poster","preload","options","loader","customDataProviderMeta","registerComponent","customDynamicElementMeta","customDynamicImageMeta","customDynamicRepeaterMeta","customDynamicTextMeta","customIframeMeta","customScrollRevealerMeta","customVideoMeta"],"mappings":"srBAAO,ICaMA,EAAcC,qBAAoCC,GAEzDC,EAAa,iDAEHC,EACdC,EACAC,MAEKA,a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,EAA0B3D,6CAlL5DuD,EACAK,GAEIL,EACFA,EAAOE,kBACLjF,QACAoF,EAAAA,EAA6BxE,GAG/BqE,EACEjF,QACAoF,EAAAA,EAA6BxE,yCAiIjCmE,EACAM,GAEIN,EACFA,EAAOE,kBACLvF,QACA2F,EAAAA,EAAyB9D,GAG3B0D,EAAkBvF,QAAa2F,EAAAA,EAAyB9D,oCCzR1DwD,EACAO,GAEIP,EACFA,EAAOE,kBAAkBxD,QAAQ6D,EAAAA,EAAoB5C,GAErDuC,EAAkBxD,QAAQ6D,EAAAA,EAAoB5C,4CCyChDqC,EACAQ,GAEIR,EACFA,EAAOE,kBACLjB,QACAuB,EAAAA,EAA4BpB,GAG9Bc,EACEjB,QACAuB,EAAAA,EAA4BpB,mCCpChCY,EACAS,GAEIT,EACFA,EAAOE,kBAAkBb,QAAOoB,EAAAA,EAAmBlB,GAEnDW,EAAkBb,QAAOoB,EAAAA,EAAmBlB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { repeatedElement, PlasmicCanvasContext } from '@plasmicapp/host';
|
|
2
2
|
import registerComponent from '@plasmicapp/host/registerComponent';
|
|
3
|
-
import React, { createContext, useContext, createElement, useRef,
|
|
3
|
+
import React, { createContext, useContext, createElement, useRef, useState, useEffect } from 'react';
|
|
4
4
|
|
|
5
5
|
function _extends() {
|
|
6
6
|
_extends = Object.assign || function (target) {
|
|
@@ -80,16 +80,9 @@ var tuple = function tuple() {
|
|
|
80
80
|
|
|
81
81
|
return args;
|
|
82
82
|
};
|
|
83
|
-
function ensure(x) {
|
|
84
|
-
if (x === null || x === undefined) {
|
|
85
|
-
debugger;
|
|
86
|
-
throw new Error("Value must not be undefined or null");
|
|
87
|
-
} else {
|
|
88
|
-
return x;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
83
|
|
|
92
84
|
var DataContext = /*#__PURE__*/createContext(undefined);
|
|
85
|
+
var thisModule = "@plasmicpkgs/plasmic-basic-components";
|
|
93
86
|
function applySelector(rawData, selector) {
|
|
94
87
|
if (!selector) {
|
|
95
88
|
return undefined;
|
|
@@ -192,19 +185,17 @@ function DynamicImage(_ref6) {
|
|
|
192
185
|
src: "https://studio.plasmic.app/static/img/placeholder.png"
|
|
193
186
|
}));
|
|
194
187
|
}
|
|
195
|
-
function
|
|
188
|
+
function DynamicRepeater(_ref7) {
|
|
196
189
|
var _ref8;
|
|
197
190
|
|
|
198
|
-
var
|
|
191
|
+
var children = _ref7.children,
|
|
199
192
|
loopItemName = _ref7.loopItemName,
|
|
200
|
-
children = _ref7.children,
|
|
201
|
-
data = _ref7.data,
|
|
202
193
|
keySelector = _ref7.keySelector,
|
|
203
|
-
|
|
204
|
-
|
|
194
|
+
selector = _ref7.selector,
|
|
195
|
+
data = _ref7.data;
|
|
205
196
|
// Defaults to an array of three items.
|
|
206
197
|
var finalData = (_ref8 = data != null ? data : useSelector(selector)) != null ? _ref8 : [1, 2, 3];
|
|
207
|
-
return React.createElement(
|
|
198
|
+
return React.createElement(React.Fragment, null, finalData == null ? void 0 : finalData.map == null ? void 0 : finalData.map(function (item, index) {
|
|
208
199
|
var _applySelector;
|
|
209
200
|
|
|
210
201
|
return React.createElement(DataProvider, {
|
|
@@ -214,26 +205,36 @@ function DynamicCollection(_ref7) {
|
|
|
214
205
|
}, repeatedElement(index === 0, children));
|
|
215
206
|
}));
|
|
216
207
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
208
|
+
var dynamicRepeaterProps = {
|
|
209
|
+
selector: {
|
|
210
|
+
type: "string",
|
|
211
|
+
description: "The selector expression to use to get the array of data to loop over, such as: someVariable.0.someField"
|
|
212
|
+
},
|
|
213
|
+
loopItemName: {
|
|
214
|
+
type: "string",
|
|
215
|
+
defaultValue: "item",
|
|
216
|
+
description: "The name of the variable to use to store the current item in the loop"
|
|
217
|
+
},
|
|
218
|
+
children: "slot"
|
|
219
|
+
};
|
|
220
|
+
var dynamicRepeaterMeta = {
|
|
221
|
+
name: "hostless-dynamic-repeater",
|
|
222
|
+
displayName: "Dynamic Repeater",
|
|
223
|
+
importName: "DynamicRepeater",
|
|
224
|
+
importPath: thisModule,
|
|
225
|
+
props: dynamicRepeaterProps
|
|
226
|
+
};
|
|
227
|
+
function registerDynamicRepeater(loader, customDynamicRepeaterMeta) {
|
|
228
|
+
if (loader) {
|
|
229
|
+
loader.registerComponent(DynamicRepeater, customDynamicRepeaterMeta != null ? customDynamicRepeaterMeta : dynamicRepeaterMeta);
|
|
230
|
+
} else {
|
|
231
|
+
registerComponent(DynamicRepeater, customDynamicRepeaterMeta != null ? customDynamicRepeaterMeta : dynamicRepeaterMeta);
|
|
232
|
+
}
|
|
233
233
|
}
|
|
234
|
-
var
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
var dataProviderMeta = {
|
|
235
|
+
name: "hostless-data-provider",
|
|
236
|
+
displayName: "Data Provider",
|
|
237
|
+
importName: "DataProvider",
|
|
237
238
|
importPath: thisModule,
|
|
238
239
|
// description: "Makes some specified data available to the subtree in a context",
|
|
239
240
|
props: {
|
|
@@ -258,24 +259,31 @@ registerComponent(DataProvider, {
|
|
|
258
259
|
type: "slot",
|
|
259
260
|
defaultValue: [{
|
|
260
261
|
type: "component",
|
|
261
|
-
name: "
|
|
262
|
+
name: "hostless-dynamic-text",
|
|
262
263
|
props: {
|
|
263
264
|
selector: "celebrities.0.name"
|
|
264
265
|
}
|
|
265
266
|
}, {
|
|
266
267
|
type: "component",
|
|
267
|
-
name: "
|
|
268
|
+
name: "hostless-dynamic-image",
|
|
268
269
|
props: {
|
|
269
270
|
selector: "celebrities.0.profilePicture"
|
|
270
271
|
}
|
|
271
272
|
}]
|
|
272
273
|
}
|
|
273
274
|
}
|
|
274
|
-
}
|
|
275
|
+
};
|
|
276
|
+
function registerDataProvider(loader, customDataProviderMeta) {
|
|
277
|
+
if (loader) {
|
|
278
|
+
loader.registerComponent(DataProvider, customDataProviderMeta != null ? customDataProviderMeta : dataProviderMeta);
|
|
279
|
+
} else {
|
|
280
|
+
registerComponent(DataProvider, customDataProviderMeta != null ? customDataProviderMeta : dataProviderMeta);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
275
283
|
var dynamicPropsWithoutTag = {
|
|
276
284
|
propSelectors: {
|
|
277
285
|
type: "object",
|
|
278
|
-
|
|
286
|
+
defaultValueHint: {},
|
|
279
287
|
description: "An object whose keys are prop names and values are selector expressions. Use this to set any prop to a dynamic value."
|
|
280
288
|
}
|
|
281
289
|
};
|
|
@@ -283,137 +291,74 @@ var dynamicPropsWithoutTag = {
|
|
|
283
291
|
var dynamicProps = /*#__PURE__*/_extends({}, dynamicPropsWithoutTag, {
|
|
284
292
|
tag: {
|
|
285
293
|
type: "string",
|
|
286
|
-
|
|
294
|
+
defaultValueHint: "div",
|
|
287
295
|
description: "The HTML tag to use"
|
|
288
296
|
}
|
|
289
297
|
}); // TODO Eventually we'll want to expose all the base HTML properties, but in the nicer way that we do within the studio.
|
|
290
298
|
|
|
291
299
|
|
|
292
|
-
|
|
293
|
-
name: "
|
|
300
|
+
var dynamicElementMeta = {
|
|
301
|
+
name: "hostless-dynamic-element",
|
|
302
|
+
displayName: "Dynamic Element",
|
|
303
|
+
importName: "DynamicElement",
|
|
294
304
|
importPath: thisModule,
|
|
295
|
-
props: _extends({}, dynamicProps, {
|
|
305
|
+
props: /*#__PURE__*/_extends({}, dynamicProps, {
|
|
296
306
|
children: "slot"
|
|
297
307
|
})
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
308
|
+
};
|
|
309
|
+
function registerDynamicElement(loader, customDynamicElementMeta) {
|
|
310
|
+
if (loader) {
|
|
311
|
+
loader.registerComponent(DynamicElement, customDynamicElementMeta != null ? customDynamicElementMeta : dynamicElementMeta);
|
|
312
|
+
} else {
|
|
313
|
+
registerComponent(DynamicElement, customDynamicElementMeta != null ? customDynamicElementMeta : dynamicElementMeta);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
var dynamicTextMeta = {
|
|
317
|
+
name: "hostless-dynamic-text",
|
|
318
|
+
importName: "DynamicText",
|
|
319
|
+
displayName: "Dynamic Text",
|
|
301
320
|
importPath: thisModule,
|
|
302
|
-
props: _extends({}, dynamicProps, {
|
|
321
|
+
props: /*#__PURE__*/_extends({}, dynamicProps, {
|
|
303
322
|
selector: {
|
|
304
323
|
type: "string",
|
|
305
324
|
description: "The selector expression to use to get the text, such as: someVariable.0.someField"
|
|
306
325
|
}
|
|
307
326
|
})
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
327
|
+
};
|
|
328
|
+
function registerDynamicText(loader, customDynamicTextMeta) {
|
|
329
|
+
if (loader) {
|
|
330
|
+
loader.registerComponent(DynamicText, customDynamicTextMeta != null ? customDynamicTextMeta : dynamicTextMeta);
|
|
331
|
+
} else {
|
|
332
|
+
registerComponent(DynamicText, customDynamicTextMeta != null ? customDynamicTextMeta : dynamicTextMeta);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
var dynamicImageMeta = {
|
|
336
|
+
name: "hostless-dynamic-image",
|
|
337
|
+
displayName: "Dynamic Image",
|
|
338
|
+
importName: "DynamicImage",
|
|
311
339
|
importPath: thisModule,
|
|
312
|
-
props: _extends({}, dynamicPropsWithoutTag, {
|
|
340
|
+
props: /*#__PURE__*/_extends({}, dynamicPropsWithoutTag, {
|
|
313
341
|
selector: {
|
|
314
342
|
type: "string",
|
|
315
343
|
description: "The selector expression to use to get the image source URL, such as: someVariable.0.someField"
|
|
316
344
|
}
|
|
317
345
|
})
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
loopItemName: {
|
|
325
|
-
type: "string",
|
|
326
|
-
defaultValue: "item",
|
|
327
|
-
description: "The name of the variable to use to store the current item in the loop"
|
|
328
|
-
},
|
|
329
|
-
children: "slot"
|
|
330
|
-
});
|
|
331
|
-
registerComponent(DynamicCollection, {
|
|
332
|
-
name: "DynamicCollection",
|
|
333
|
-
importPath: thisModule,
|
|
334
|
-
props: dynamicCollectionProps
|
|
335
|
-
});
|
|
336
|
-
var dynamicCollectionGridProps = /*#__PURE__*/_extends({}, dynamicCollectionProps, {
|
|
337
|
-
columns: {
|
|
338
|
-
type: "number",
|
|
339
|
-
defaultValue: 2,
|
|
340
|
-
description: "The number of columns to use in the grid"
|
|
341
|
-
},
|
|
342
|
-
columnGap: {
|
|
343
|
-
type: "number",
|
|
344
|
-
defaultValue: 8,
|
|
345
|
-
description: "The gap between columns"
|
|
346
|
-
},
|
|
347
|
-
rowGap: {
|
|
348
|
-
type: "number",
|
|
349
|
-
defaultValue: 8,
|
|
350
|
-
description: "The gap between rows"
|
|
346
|
+
};
|
|
347
|
+
function registerDynamicImage(loader, customDynamicImageMeta) {
|
|
348
|
+
if (loader) {
|
|
349
|
+
loader.registerComponent(DynamicImage, customDynamicImageMeta != null ? customDynamicImageMeta : dynamicImageMeta);
|
|
350
|
+
} else {
|
|
351
|
+
registerComponent(DynamicImage, customDynamicImageMeta != null ? customDynamicImageMeta : dynamicImageMeta);
|
|
351
352
|
}
|
|
352
|
-
});
|
|
353
|
-
registerComponent(DynamicCollectionGrid, {
|
|
354
|
-
name: "DynamicCollectionGrid",
|
|
355
|
-
importPath: thisModule,
|
|
356
|
-
props: dynamicCollectionGridProps
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
/** @format */
|
|
360
|
-
function Embed(_ref) {
|
|
361
|
-
var className = _ref.className,
|
|
362
|
-
code = _ref.code,
|
|
363
|
-
_ref$hideInEditor = _ref.hideInEditor,
|
|
364
|
-
hideInEditor = _ref$hideInEditor === void 0 ? false : _ref$hideInEditor;
|
|
365
|
-
var rootElt = useRef(null);
|
|
366
|
-
useEffect(function () {
|
|
367
|
-
if (hideInEditor) {
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
Array.from(ensure(rootElt.current).querySelectorAll("script")).forEach(function (oldScript) {
|
|
372
|
-
var newScript = document.createElement("script");
|
|
373
|
-
Array.from(oldScript.attributes).forEach(function (attr) {
|
|
374
|
-
return newScript.setAttribute(attr.name, attr.value);
|
|
375
|
-
});
|
|
376
|
-
newScript.appendChild(document.createTextNode(oldScript.innerHTML));
|
|
377
|
-
ensure(oldScript.parentNode).replaceChild(newScript, oldScript);
|
|
378
|
-
});
|
|
379
|
-
}, [code, hideInEditor]);
|
|
380
|
-
var effectiveCode = hideInEditor ? "" : code;
|
|
381
|
-
return React.createElement("div", {
|
|
382
|
-
ref: rootElt,
|
|
383
|
-
className: className,
|
|
384
|
-
dangerouslySetInnerHTML: {
|
|
385
|
-
__html: effectiveCode
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
353
|
}
|
|
389
|
-
registerComponent(Embed, {
|
|
390
|
-
name: "Embed",
|
|
391
|
-
importPath: "@plasmicpkgs/plasmic-basic-components/Embed",
|
|
392
|
-
props: {
|
|
393
|
-
code: {
|
|
394
|
-
type: "string",
|
|
395
|
-
defaultValue: "https://www.example.com"
|
|
396
|
-
},
|
|
397
|
-
hideInEditor: {
|
|
398
|
-
type: "boolean",
|
|
399
|
-
displayName: "Hide in editor",
|
|
400
|
-
description: "Disable running the code while editing in Plasmic Studio (may require reload)"
|
|
401
|
-
}
|
|
402
|
-
},
|
|
403
|
-
isDefaultExport: true,
|
|
404
|
-
defaultStyles: {
|
|
405
|
-
maxWidth: "100%"
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
354
|
|
|
409
|
-
/** @format */
|
|
410
355
|
function Iframe(_ref) {
|
|
411
|
-
var
|
|
356
|
+
var preview = _ref.preview,
|
|
412
357
|
src = _ref.src,
|
|
413
358
|
className = _ref.className;
|
|
414
359
|
var isEditing = useContext(PlasmicCanvasContext);
|
|
415
360
|
|
|
416
|
-
if (isEditing && !
|
|
361
|
+
if (isEditing && !preview) {
|
|
417
362
|
return React.createElement("div", {
|
|
418
363
|
className: className
|
|
419
364
|
}, React.createElement("div", {
|
|
@@ -441,27 +386,34 @@ function Iframe(_ref) {
|
|
|
441
386
|
className: className
|
|
442
387
|
});
|
|
443
388
|
}
|
|
444
|
-
|
|
445
|
-
name: "
|
|
446
|
-
|
|
389
|
+
var iframeMeta = {
|
|
390
|
+
name: "hostless-iframe",
|
|
391
|
+
displayName: "Iframe",
|
|
392
|
+
importName: "Iframe",
|
|
393
|
+
importPath: "@plasmicpkgs/plasmic-basic-components",
|
|
447
394
|
props: {
|
|
448
395
|
src: {
|
|
449
396
|
type: "string",
|
|
450
397
|
defaultValue: "https://www.example.com"
|
|
451
398
|
},
|
|
452
|
-
|
|
399
|
+
preview: {
|
|
453
400
|
type: "boolean",
|
|
454
|
-
displayName: "Preview",
|
|
455
401
|
description: "Load the iframe while editing in Plasmic Studio"
|
|
456
402
|
}
|
|
457
403
|
},
|
|
458
|
-
isDefaultExport: true,
|
|
459
404
|
defaultStyles: {
|
|
460
405
|
width: "300px",
|
|
461
406
|
height: "150px",
|
|
462
407
|
maxWidth: "100%"
|
|
463
408
|
}
|
|
464
|
-
}
|
|
409
|
+
};
|
|
410
|
+
function registerIframe(loader, customIframeMeta) {
|
|
411
|
+
if (loader) {
|
|
412
|
+
loader.registerComponent(Iframe, customIframeMeta != null ? customIframeMeta : iframeMeta);
|
|
413
|
+
} else {
|
|
414
|
+
registerComponent(Iframe, customIframeMeta != null ? customIframeMeta : iframeMeta);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
465
417
|
|
|
466
418
|
function useDirectionalIntersection(_ref) {
|
|
467
419
|
var ref = _ref.ref,
|
|
@@ -527,40 +479,49 @@ function ScrollRevealer(_ref2) {
|
|
|
527
479
|
ref: intersectionRef
|
|
528
480
|
}, revealed ? children : null);
|
|
529
481
|
}
|
|
530
|
-
|
|
531
|
-
name: "
|
|
482
|
+
var scrollRevealerMeta = {
|
|
483
|
+
name: "hostless-scroll-revealer",
|
|
484
|
+
importName: "ScrollRevealer",
|
|
532
485
|
displayName: "Scroll Revealer",
|
|
533
|
-
importPath: "@plasmicpkgs/plasmic-basic-components
|
|
486
|
+
importPath: "@plasmicpkgs/plasmic-basic-components",
|
|
534
487
|
props: {
|
|
535
488
|
children: "slot",
|
|
536
489
|
scrollDownThreshold: {
|
|
537
490
|
type: "number",
|
|
538
491
|
displayName: "Scroll down threshold",
|
|
539
|
-
|
|
492
|
+
defaultValueHint: 0.5,
|
|
540
493
|
description: "How much of the element (as a fraction) must you scroll into view for it to appear (defaults to 0.5)"
|
|
541
494
|
},
|
|
542
495
|
scrollUpThreshold: {
|
|
543
496
|
type: "number",
|
|
544
497
|
displayName: "Scroll up threshold",
|
|
545
|
-
|
|
498
|
+
defaultValueHint: 0,
|
|
546
499
|
description: "While scrolling up, how much of the element (as a fraction) can still be scrolled in view before it disappears (defaults to 0, meaning you must scroll up until it's completely out of view)"
|
|
547
500
|
}
|
|
548
501
|
},
|
|
549
|
-
isDefaultExport: true,
|
|
550
502
|
defaultStyles: {
|
|
551
503
|
width: "stretch",
|
|
552
504
|
maxWidth: "100%"
|
|
553
505
|
}
|
|
554
|
-
}
|
|
506
|
+
};
|
|
507
|
+
function registerScrollRevealer(loader, customScrollRevealerMeta) {
|
|
508
|
+
if (loader) {
|
|
509
|
+
loader.registerComponent(ScrollRevealer, customScrollRevealerMeta != null ? customScrollRevealerMeta : scrollRevealerMeta);
|
|
510
|
+
} else {
|
|
511
|
+
registerComponent(ScrollRevealer, customScrollRevealerMeta != null ? customScrollRevealerMeta : scrollRevealerMeta);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
555
514
|
|
|
556
515
|
var Video = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
557
516
|
return React.createElement("video", Object.assign({
|
|
558
517
|
ref: ref
|
|
559
518
|
}, props));
|
|
560
519
|
});
|
|
561
|
-
|
|
562
|
-
name: "
|
|
563
|
-
|
|
520
|
+
var videoMeta = {
|
|
521
|
+
name: "hostless-html-video",
|
|
522
|
+
importName: "Video",
|
|
523
|
+
displayName: "HTML Video",
|
|
524
|
+
importPath: "@plasmicpkgs/plasmic-basic-components",
|
|
564
525
|
props: {
|
|
565
526
|
src: {
|
|
566
527
|
type: "string",
|
|
@@ -593,13 +554,11 @@ registerComponent(Video, {
|
|
|
593
554
|
displayName: "Muted",
|
|
594
555
|
description: "Whether audio should be muted"
|
|
595
556
|
},
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
// "Image to show while video is downloading",
|
|
602
|
-
// },
|
|
557
|
+
poster: {
|
|
558
|
+
type: "imageUrl",
|
|
559
|
+
displayName: "Poster (placeholder) image",
|
|
560
|
+
description: "Image to show while video is downloading"
|
|
561
|
+
},
|
|
603
562
|
preload: {
|
|
604
563
|
type: "choice",
|
|
605
564
|
options: ["none", "metadata", "auto"],
|
|
@@ -607,13 +566,19 @@ registerComponent(Video, {
|
|
|
607
566
|
description: "Whether to preload nothing, metadata only, or the full video"
|
|
608
567
|
}
|
|
609
568
|
},
|
|
610
|
-
isDefaultExport: true,
|
|
611
569
|
defaultStyles: {
|
|
612
570
|
height: "hug",
|
|
613
571
|
width: "640px",
|
|
614
572
|
maxWidth: "100%"
|
|
615
573
|
}
|
|
616
|
-
}
|
|
574
|
+
};
|
|
575
|
+
function registerVideo(loader, customVideoMeta) {
|
|
576
|
+
if (loader) {
|
|
577
|
+
loader.registerComponent(Video, customVideoMeta != null ? customVideoMeta : videoMeta);
|
|
578
|
+
} else {
|
|
579
|
+
registerComponent(Video, customVideoMeta != null ? customVideoMeta : videoMeta);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
617
582
|
|
|
618
|
-
export { DataContext, DataProvider,
|
|
583
|
+
export { DataContext, DataProvider, DynamicElement, DynamicImage, DynamicRepeater, DynamicText, Iframe, ScrollRevealer, Video, applySelector, dataProviderMeta, dynamicElementMeta, dynamicImageMeta, dynamicRepeaterMeta, dynamicRepeaterProps, dynamicTextMeta, iframeMeta, registerDataProvider, registerDynamicElement, registerDynamicImage, registerDynamicRepeater, registerDynamicText, registerIframe, registerScrollRevealer, registerVideo, scrollRevealerMeta, useDataEnv, useDirectionalIntersection, useSelector, useSelectors, videoMeta };
|
|
619
584
|
//# sourceMappingURL=plasmic-basic-components.esm.js.map
|