@plasmicpkgs/plasmic-cms 0.0.152 → 0.0.154

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.
@@ -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=e(require("@plasmicapp/host/registerComponent")),r=e(require("@plasmicapp/host/registerGlobalContext")),n=require("@plasmicapp/host"),a=require("@plasmicapp/query"),i=e(require("dayjs")),o=require("react"),l=e(o);function u(e,t,r,n,a,i,o){try{var l=e[i](o),u=l.value}catch(e){return void r(e)}l.done?t(u):Promise.resolve(u).then(n,a)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){u(i,n,a,o,l,"next",e)}function l(e){u(i,n,a,o,l,"throw",e)}o(void 0)}))}}function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function m(e,t,r){return(m=p()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&f(a,r.prototype),a}).apply(null,arguments)}function h(e){var t="function"==typeof Map?new Map:void 0;return(h=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return m(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,e)})(e)}function v(e,t){if(null==e)return{};var r,n,a={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(a[r]=e[r]);return a}function y(e,t){return e(t={exports:{}},t.exports),t.exports}var b=y((function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var a=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new E(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(a,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw i;return{value:void 0,done:!0}}for(r.method=a,r.arg=i;;){var o=r.delegate;if(o){var l=w(o,r);if(l){if(l===c)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,i),a}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var c={};function d(){}function f(){}function p(){}var m={};l(m,a,(function(){return this}));var h=Object.getPrototypeOf,v=h&&h(h(C([])));v&&v!==t&&r.call(v,a)&&(m=v);var y=p.prototype=d.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var n;this._invoke=function(a,i){function o(){return new t((function(n,o){!function n(a,i,o,l){var u=s(e[a],e,i);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,o,l)}),(function(e){n("throw",e,o,l)})):t.resolve(d).then((function(e){c.value=e,o(c)}),(function(e){return n("throw",e,o,l)}))}l(u.arg)}(a,i,n,o)}))}return n=n?n.then(o,o):o()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,c;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function M(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function C(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:N}}function N(){return{value:void 0,done:!0}}return f.prototype=p,l(y,"constructor",p),l(p,"constructor",f),f.displayName=l(p,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,o,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},b(g.prototype),l(g.prototype,i,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,a,i){void 0===i&&(i=Promise);var o=new g(u(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},b(y),l(y,o,"Generator"),l(y,a,(function(){return this})),l(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(M),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(l){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,c):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),M(r),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;M(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}));function g(e){return{where:e.where,limit:e.limit,order:e.orderBy?[{field:e.orderBy,dir:e.desc?"desc":"asc"}]:void 0}}var w=function(e){var t,r;function n(t,r){var n;return(n=e.call(this,r)||this).status=t,n}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,f(t,r),n}(h(Error)),x=function(){function e(e){this.config=e}var t=e.prototype;return t.get=function(){var e=s(b.mark((function e(t,r){var n,a,i,o,l;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r={}),(n=new URL(this.config.host+"/api/v1/cms/databases/"+this.config.databaseId+t)).search=new URLSearchParams(r).toString(),e.next=5,fetch(n.toString(),{method:"GET",headers:{accept:"*/*","x-plasmic-api-cms-tokens":this.config.databaseId+":"+this.config.databaseToken},mode:"cors"});case 5:if(200===(a=e.sent).status){e.next=12;break}return e.next=9,a.text();case 9:i=e.sent;try{l=JSON.parse(i),null!=(o=l.error)&&o.message&&(i=l.error.message)}catch(e){}throw new w(a.status,i);case 12:return e.next=14,a.json();case 14:return e.abrupt("return",e.sent);case 15:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.fetchTables=function(){var e=s(b.mark((function e(){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.get("");case 3:return e.abrupt("return",e.sent.tables);case 7:throw e.prev=7,e.t0=e.catch(0),console.error(e.t0),e.t0;case 11:case"end":return e.stop()}}),e,this,[[0,7]])})));return function(){return e.apply(this,arguments)}}(),t.query=function(){var e=s(b.mark((function e(t,r){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r={}),e.prev=1,e.next=4,this.get("/tables/"+t+"/query",{q:JSON.stringify(g(r)),draft:Number(r.useDraft),locale:this.config.locale});case 4:return e.abrupt("return",e.sent.rows);case 8:throw e.prev=8,e.t0=e.catch(1),console.error(e.t0),e.t0;case 12:case"end":return e.stop()}}),e,this,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}(),e}();function M(e){if(!e)throw new Error("Component must be wrapped in 'CMS Data Provider'.");return new x(e)}var E=function(e){return"plasmicCms"+N(e)+"Collection"},C=function(e){return"plasmicCms"+N(e)+"Item"};function N(e){var t;return(null==(t=e[0])?void 0:t.toUpperCase())+e.slice(1)}function F(){return n.useSelector("plasmicCmsDatabase")}function P(e){return l.createElement(n.DataProvider,{name:"plasmicCmsDatabase",data:e.config,hidden:!0},e.children)}function S(){return n.useSelector("plasmicCmsTables")}function L(e){return l.createElement(n.DataProvider,{name:"plasmicCmsTables",data:e.tables,hidden:!0},e.children)}function D(e){var t=e.children,r=e.rows,a=e.hidden;return l.createElement(n.DataProvider,{name:E(e.table),data:r,hidden:a},t)}function O(){var e=n.useDataEnv(),t=S();if(e&&t){var r=function(e,t){return[].concat(Object.keys(e).reverse()).filter((function(e){return e.endsWith("Item")}))}(e);return t.filter((function(e){return r.some((function(t){return C(e.identifier)===t}))}))}}function Y(e,t){var r=n.useDataEnv();if(r)return!t&&e&&e.length>0&&(t=e[0].identifier),t?{table:t,row:r[C(t)]}:void 0}function k(e){var t=e.children,r=e.row;return l.createElement(n.DataProvider,{name:C(e.table),data:r},t)}function j(e){return e?e.map((function(e){return{value:e.identifier,label:e.name}})):[]}function V(e,t,r){if(!e)return[];var n=e.find((function(e){return e.identifier===t}));if(!n)return[];var a=n.schema.fields;return r&&(a=a.filter((function(e){return r.includes(e.type)}))),a.map((function(e){return{value:e.identifier,label:e.name||e.identifier}}))}var R=["className","table","field","dateFormat","setControlContextData"],_=["table","field","valueProp","children","setControlContextData"],T="@plasmicpkgs/plasmic-cms",I="hostless-plasmic-cms",q="https://studio.plasmic.app",A={name:I+"-credentials-provider",displayName:"CMS Credentials Provider",description:"\nFind your CMS in the [dashboard](https://studio.plasmic.app), and go to the Settings tab for the ID and token.\n\nSee also the [getting started video](https://www.youtube.com/watch?v=-Rrn92VtRBc).",importName:"CmsCredentialsProvider",importPath:T,providesData:!0,props:{host:{type:"string",displayName:"Studio URL",description:"The default host for use in production is "+q+".",defaultValue:q,defaultValueHint:q},databaseId:{type:"string",displayName:"CMS ID",description:"The ID of the CMS (database) to use. (Can get on the CMS settings page)"},databaseToken:{type:"string",displayName:"CMS Public Token",description:"The Public Token of the CMS (database) you are using. (Can get on the CMS settings page)"},locale:{type:"string",displayName:"Locale",description:"The locale to use for localized values, leave empty for the default locale."}}};function H(e){return l.createElement(P,{config:{databaseId:e.databaseId,databaseToken:e.databaseToken,locale:e.locale,host:e.host||q}},l.createElement(G,null,e.children))}function G(e){var t=e.children,r=F(),i=JSON.stringify({component:"TablesFetcher",databaseConfig:r}),u=a.usePlasmicQueryData(i,s(b.mark((function e(){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(J(r)){e.next=2;break}return e.abrupt("return",[]);case 2:return e.next=4,M(r).fetchTables();case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e)})))),c=!!o.useContext(n.PlasmicCanvasContext);return l.createElement(L,{tables:u.data},c&&u.error?l.createElement("div",null,"CMS Error: ",u.error.message):t)}function J(e){return(null==e?void 0:e.databaseId)&&(null==e?void 0:e.databaseToken)}var B={name:I+"-query-repeater",displayName:"CMS Data Loader",description:"Fetches CMS data and repeats content of children once for every row fetched.",importName:"CmsQueryRepeater",importPath:T,providesData:!0,defaultStyles:{display:"flex",width:"stretch",maxWidth:"100%",flexDirection:"column"},props:{children:{type:"slot",isRepeated:!0,defaultValue:{type:"vbox",children:[{type:"component",name:I+"-row-field"}]}},table:{type:"choice",displayName:"Model",description:"CMS model (table) to query.",options:function(e,t){return j(null==t?void 0:t.tables)},defaultValueHint:function(e,t){return null==t?void 0:t.table}},useDraft:{type:"boolean",displayName:"Use drafts?",description:"If set, also query unpublished content.",defaultValue:!1,hidden:function(){return!0}},where:{type:"object",displayName:"Filter",description:"Filter clause, in JSON format.",hidden:function(){return!0}},filterField:{type:"choice",displayName:"Filter field",description:"Field (from model schema) to filter by",options:function(e,t){var r;return V(null==t?void 0:t.tables,null!=(r=null==t?void 0:t.table)?r:e.table,["number","boolean","text","long-text"])}},filterValue:{type:"string",displayName:"Filter value",description:"Value to filter by, should be of filter field type"},orderBy:{type:"choice",displayName:"Order by",description:"Field to order by.",options:function(e,t){return V(null==t?void 0:t.tables,null==t?void 0:t.table,["number","boolean","date-time","long-text","text"])}},desc:{type:"boolean",displayName:"Sort descending?",description:'Sort descending by "Order by" field.',defaultValue:!1},limit:{type:"number",displayName:"Limit",description:"Maximum number of entries to fetch (0 for unlimited).",defaultValue:0},emptyMessage:{type:"slot",defaultValue:{type:"text",value:"No matching published entries found."}},forceEmptyState:{type:"boolean",displayName:"Force empty state",description:"If set, will render as if no matching entries were found.",defaultValue:!1},loadingMessage:{type:"slot",defaultValue:{type:"text",value:"Loading..."}},forceLoadingState:{type:"boolean",displayName:"Force loading state",description:"If set, will render as if it is waiting for the query to run.",defaultValue:!1},noLayout:{type:"boolean",displayName:"No layout",description:"When set, CMS Data Loader will not layout its children; instead, the layout set on its parent element will be used. Useful if you want to set flex gap or control container tag type.",defaultValue:!1},noAutoRepeat:{type:"boolean",displayName:"No auto-repeat",description:"Do not automatically repeat children for every entry.",defaultValue:!1}}};function U(e){var t,r=e.table,i=e.children,u=e.setControlContextData,c=e.where,d=e.useDraft,f=e.orderBy,p=e.desc,m=e.limit,h=e.emptyMessage,v=e.forceEmptyState,y=e.loadingMessage,g=e.forceLoadingState,x=e.noLayout,C=e.noAutoRepeat,N=e.className,P=e.filterField,L=e.filterValue,O=F(),Y=S();P&&L&&((t={})[P]=L,c=t);var j={where:c,useDraft:d,orderBy:f,desc:p,limit:m};!r&&Y&&Y.length>0&&(r=Y[0].identifier);var V=JSON.stringify({component:"CmsQueryLoader",table:r,databaseConfig:O,params:j});Y&&(null==u||u({tables:Y,table:r}));var R=a.usePlasmicQueryData(V,s(b.mark((function e(){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(J(O)){e.next=2;break}throw new Error("You must specify a CMS ID and API key");case 2:if(r){e.next=6;break}throw new Error("You must select a model to query");case 6:if(!Y||Y.find((function(e){return e.identifier===r}))){e.next=10;break}throw new Error('There is no model called "'+r+'"');case 10:return e.abrupt("return",M(O).query(r,j));case 11:case"end":return e.stop()}}),e)})))),_=function(e,t,a,o,u,s){if("error"in e){var c=e.error;return o?c&&c instanceof w&&404===c.status?l.createElement("div",null,"Error: Data not found"):l.createElement("div",null,"Error: ",null==c?void 0:c.message):l.createElement(l.Fragment,null,null!=u?u:l.createElement("div",null,"Loading..."))}return!("data"in e)||s?l.createElement(l.Fragment,null,null!=u?u:l.createElement("div",null,"Loading...")):0===(d=e.data).length||v?l.createElement(D,{table:r,rows:d},h):C?i:l.createElement(D,{table:r,rows:d},d.map((function(e,t){return l.createElement(k,{key:t,table:r,row:e},n.repeatedElement(t,i))})));var d}(R,0,0,!!o.useContext(n.PlasmicCanvasContext),y,g);return l.createElement(n.DataProvider,{data:null==R?void 0:R.data,name:r?E(r)+"s":void 0},x?l.createElement(l.Fragment,null," ",_," "):l.createElement("div",{className:N}," ",_," "))}var Q={name:I+"-row-field",displayName:"CMS Entry Field",importName:"CmsRowField",importPath:T,props:{table:{type:"choice",displayName:"Model",description:"CMS model (table) to use.",options:function(e,t){return j(null==t?void 0:t.tables)},defaultValueHint:function(e,t){return null==t?void 0:t.table}},field:{type:"choice",displayName:"Field",description:"Field (from model schema) to use.",options:function(e,t){var r;return V(null==t?void 0:t.tables,null!=(r=null==t?void 0:t.table)?r:e.table,["number","boolean","text","long-text","date-time","rich-text","image","file"])},defaultValueHint:function(e,t){var r,n;return(null==t||null==(r=t.fieldMeta)?void 0:r.name)||(null==t||null==(n=t.fieldMeta)?void 0:n.identifier)}},dateFormat:{type:"choice",displayName:"Date Format",hidden:function(e,t){var r=e.field;if(!t)return!0;var n=t.table,a=t.tables,i=null==a?void 0:a.find((function(e){return e.identifier===n}));if(!i)return!0;var o=i.schema.fields.find((function(e){return e.identifier===r}));return!o||"date-time"!==o.type},options:[{label:"July 26, 2014",value:"MMMM D, YYYY"},{label:"July 26, 2014 10:02 PM",value:"MMMM D, YYYY h:mm A"},{label:"Jul 26, 2014",value:"MMM D, YYYY"},{label:"Jul 26, 2014 10:02 PM",value:"MMM D, YYYY h:mm A"},{label:"Saturday, July 26, 2014",value:"dddd, MMMM D, YYYY"},{label:"7/26/2014",value:"M/D/YYYY"},{label:"7/26/2014 10:02 PM",value:"M/D/YYYY h:mm A"},{label:"26/7/2014",value:"D/M/YYYY"},{label:"26/7/2014 10:02 PM",value:"D/M/YYYY h:mm A"},{label:"7/26/14",value:"M/D/YY"},{label:"7/26/14 10:02 PM",value:"M/D/YY h:mm A"},{label:"26/7/14",value:"D/M/YY"},{label:"26/7/14 10:02 PM",value:"D/M/YY h:mm A"}]}},defaultStyles:{objectFit:"cover"}};function W(e){var t,r=e.className,n=e.table,a=e.field,o=e.dateFormat,u=e.setControlContextData,s=v(e,R),d=O(),f=Y(d,n),p=l.createElement("div",Object.assign({className:r},s),"Field ",null!=n?n:"Unknown Model",".",null!=a?a:"Unknown Field");if(!f)return p;if(!f.row)return l.createElement("div",{className:r},"Error: No CMS Entry found");var m=K({table:f.table,tables:d,field:a,typeFilters:["text","long-text","rich-text"]});if(d&&(null==u||u({tables:d,table:f.table,row:f.row,fieldMeta:m})),!m)return p;var h=null==(t=f.row.data)?void 0:t[m.identifier];return h?("date-time"===m.type&&o&&(h=i(h).format(o)),h?function(e,t,r){switch(t){case"number":case"boolean":case"text":case"long-text":case"date-time":return l.createElement("div",Object.assign({},r),e);case"rich-text":return l.createElement("div",Object.assign({dangerouslySetInnerHTML:{__html:e},style:{whiteSpace:"normal"}},r));case"image":return e&&"object"==typeof e&&e.url&&e.imageMeta?l.createElement("img",Object.assign({src:e.url,width:e.imageMeta.width,height:e.imageMeta.height},r)):null;case"file":return e&&"object"==typeof e&&e.url&&e.name?l.createElement("a",Object.assign({href:e.url,target:"_blank"},r),e.name):null;default:!function(e){throw new Error("unexpected branch taken")}()}}(h,m.type,c({className:r},s)):null):null}var z=["text"];function K(e){var t,r=e.table,n=e.tables,a=e.field,i=e.typeFilters;if(r){var o=null==n||null==(t=n.find((function(e){return e.identifier===r})))?void 0:t.schema;return a?null==o?void 0:o.fields.find((function(e){return e.identifier===a})):null==o?void 0:o.fields.find((function(e){return(null!=i?i:z).includes(e.type)}))}}var X={name:I+"-row-link",displayName:"CMS Entry Link",importName:"CmsRowLink",importPath:T,props:{children:{type:"slot",defaultValue:{type:"text",tag:"a",value:"Link"}},table:{type:"choice",displayName:"Model",description:"CMS model (table) to use.",options:function(e,t){return j(null==t?void 0:t.tables)},defaultValueHint:function(e,t){return null==t?void 0:t.table}},field:{type:"choice",displayName:"Field",description:"Field (from model schema) to use.",options:function(e,t){var r;return V(null==t?void 0:t.tables,null!=(r=null==t?void 0:t.table)?r:e.table)},defaultValueHint:function(e,t){var r,n;return(null==t||null==(r=t.fieldMeta)?void 0:r.name)||(null==t||null==(n=t.fieldMeta)?void 0:n.identifier)}},hrefProp:{type:"string",displayName:'"href" prop',description:"Prop to inject into children",defaultValue:"href"},prefix:{type:"string",displayName:"Optional prefix",description:"Prefix to prepend to prop value.",hidden:function(e,t){var r;return"file"===(null==t||null==(r=t.fieldMeta)?void 0:r.type)}},suffix:{type:"string",displayName:"Optional suffix",description:"Suffix to append to prop value.",hidden:function(e,t){var r;return"file"===(null==t||null==(r=t.fieldMeta)?void 0:r.type)}}}};function Z(e){var t,r=e.table,n=e.field,a=e.hrefProp,i=e.children,o=e.setControlContextData,u=e.prefix,s=e.suffix,c=O(),d=Y(c,r);if(!d||!d.row)return l.createElement(l.Fragment,null,i);var f=K({table:d.table,tables:c,field:n,typeFilters:["file","text"]});if(c&&(null==o||o({tables:c,table:d.table,row:d.row,fieldMeta:f})),!f)return l.createElement(l.Fragment,null,i);if(!i)return null;var p=(null==(t=d.row.data)?void 0:t[f.identifier])||"",m=l.Children.map(i,(function(e){var t;return l.isValidElement(e)?l.cloneElement(e,((t={})[a]="file"===f.type?p.url:u||s?""+(u||"")+p+(s||""):p,t)):e}));return l.createElement(l.Fragment,null,null!=m?m:null)}var $={name:I+"-row-image",displayName:"CMS Entry Image",importName:"CmsRowImage",importPath:T,props:{children:{type:"slot",defaultValue:{type:"img",src:"https://studio.plasmic.app/static/img/placeholder-full.png"}},table:{type:"choice",displayName:"Model",description:"CMS model (table) to use.",options:function(e,t){return j(null==t?void 0:t.tables)},defaultValueHint:function(e,t){return null==t?void 0:t.table}},field:{type:"choice",displayName:"Field",description:"Field (from model schema) to use.",options:function(e,t){var r;return V(null==t?void 0:t.tables,null!=(r=null==t?void 0:t.table)?r:e.table,["image"])},defaultValueHint:function(e,t){var r,n;return(null==t||null==(r=t.fieldMeta)?void 0:r.name)||(null==t||null==(n=t.fieldMeta)?void 0:n.identifier)}},srcProp:{type:"string",displayName:'Image "src" prop',description:"Prop to inject into children",defaultValue:"src"}}};function ee(e){var t,r=e.table,n=e.field,a=e.srcProp,i=e.children,o=e.setControlContextData,u=O(),s=Y(u,r);if(!s||!s.row)return l.createElement(l.Fragment,null,i);var c=K({table:s.table,tables:u,field:n,typeFilters:["image"]});if(u&&(null==o||o({tables:u,table:s.table,row:s.row,fieldMeta:c})),!c)return l.createElement(l.Fragment,null,i);var d=(null==(t=s.row.data)?void 0:t[c.identifier])||"",f=l.Children.map(i,(function(e){var t,r;return l.isValidElement(e)&&d?l.cloneElement(e,"object"==typeof d&&d.url&&d.imageMeta?((r={})[a]={src:d.url,fullHeight:d.imageMeta.height,fullWidth:d.imageMeta.width},r):((t={})[a]=d,t)):e}));return l.createElement(l.Fragment,null,f)}var te={name:I+"-row-value",displayName:"CMS Entry Value",importName:"CmsRowFieldValue",importPath:T,props:{children:{type:"slot"},table:{type:"choice",displayName:"Model",description:"CMS model (table) to use.",options:function(e,t){return j(null==t?void 0:t.tables)},defaultValueHint:function(e,t){return null==t?void 0:t.table}},field:{type:"choice",displayName:"Field",description:"Field (from model schema) to use.",options:function(e,t){var r;return V(null==t?void 0:t.tables,null!=(r=null==t?void 0:t.table)?r:e.table)},defaultValueHint:function(e,t){var r,n;return(null==t||null==(r=t.fieldMeta)?void 0:r.name)||(null==t||null==(n=t.fieldMeta)?void 0:n.identifier)}},valueProp:{type:"string",displayName:"Value prop",description:"Prop to inject into children as",defaultValue:"children"}}};function re(e){var t,r=e.table,n=e.field,a=e.valueProp,i=e.children,o=e.setControlContextData,u=v(e,_),s=O(),d=Y(s,r);if(!d||!d.row)return l.createElement(l.Fragment,null,i);var f=K({table:d.table,tables:s,field:n,typeFilters:["text"]});if(s&&(null==o||o({tables:s,table:d.table,row:d.row,fieldMeta:f})),!f)return l.createElement(l.Fragment,null,i);var p=(null==(t=d.row.data)?void 0:t[f.identifier])||"",m=l.Children.map(i,(function(e){var t;return l.isValidElement(e)?l.cloneElement(e,c({},u,((t={})[a]=p,t))):e}));return l.createElement(l.Fragment,null,m)}exports.API=x,exports.CmsCredentialsProvider=H,exports.CmsQueryRepeater=U,exports.CmsRowField=W,exports.CmsRowFieldValue=re,exports.CmsRowImage=ee,exports.CmsRowLink=Z,exports.HttpError=w,exports.cmsCredentialsProviderMeta=A,exports.cmsQueryRepeaterMeta=B,exports.cmsRowFieldMeta=Q,exports.cmsRowFieldValueMeta=te,exports.cmsRowImageMeta=$,exports.cmsRowLinkMeta=X,exports.mkApi=M,exports.registerAll=function(e){var n,a,i=function(r,n){e?e.registerComponent(r,n):t(r,n)};n=H,a=A,e?e.registerGlobalContext(n,a):r(n,a),i(U,B),i(W,Q),i(Z,X),i(ee,$),i(re,te)};
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=e(require("@plasmicapp/host/registerComponent")),r=e(require("@plasmicapp/host/registerGlobalContext")),n=require("@plasmicapp/host"),a=require("@plasmicapp/query"),i=e(require("dayjs")),o=require("react"),l=e(o);function u(e,t,r,n,a,i,o){try{var l=e[i](o),u=l.value}catch(e){return void r(e)}l.done?t(u):Promise.resolve(u).then(n,a)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){u(i,n,a,o,l,"next",e)}function l(e){u(i,n,a,o,l,"throw",e)}o(void 0)}))}}function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function m(e,t,r){return(m=p()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&f(a,r.prototype),a}).apply(null,arguments)}function h(e){var t="function"==typeof Map?new Map:void 0;return(h=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return m(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,e)})(e)}function v(e,t){if(null==e)return{};var r,n,a={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(a[r]=e[r]);return a}function y(e,t){return e(t={exports:{}},t.exports),t.exports}var b=y((function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var a=Object.create((t&&t.prototype instanceof d?t:d).prototype),i=new E(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(a,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw i;return{value:void 0,done:!0}}for(r.method=a,r.arg=i;;){var o=r.delegate;if(o){var l=w(o,r);if(l){if(l===c)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,i),a}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var c={};function d(){}function f(){}function p(){}var m={};l(m,a,(function(){return this}));var h=Object.getPrototypeOf,v=h&&h(h(C([])));v&&v!==t&&r.call(v,a)&&(m=v);var y=p.prototype=d.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var n;this._invoke=function(a,i){function o(){return new t((function(n,o){!function n(a,i,o,l){var u=s(e[a],e,i);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,o,l)}),(function(e){n("throw",e,o,l)})):t.resolve(d).then((function(e){c.value=e,o(c)}),(function(e){return n("throw",e,o,l)}))}l(u.arg)}(a,i,n,o)}))}return n=n?n.then(o,o):o()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,c;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function M(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function E(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function C(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:N}}function N(){return{value:void 0,done:!0}}return f.prototype=p,l(y,"constructor",p),l(p,"constructor",f),f.displayName=l(p,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,o,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},b(g.prototype),l(g.prototype,i,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,a,i){void 0===i&&(i=Promise);var o=new g(u(t,r,n,a),i);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},b(y),l(y,o,"Generator"),l(y,a,(function(){return this})),l(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=C,E.prototype={constructor:E,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(M),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(l){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,c):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),M(r),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;M(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}));function g(e){return{where:e.where,limit:e.limit,order:e.orderBy?[{field:e.orderBy,dir:e.desc?"desc":"asc"}]:void 0}}var w=function(e){var t,r;function n(t,r){var n;return(n=e.call(this,r)||this).status=t,n}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,f(t,r),n}(h(Error)),x=function(){function e(e){this.config=e}var t=e.prototype;return t.get=function(){var e=s(b.mark((function e(t,r){var n,a,i,o,l;return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r={}),(n=new URL(this.config.host+"/api/v1/cms/databases/"+this.config.databaseId+t)).search=new URLSearchParams(r).toString(),e.next=5,fetch(n.toString(),{method:"GET",headers:{accept:"*/*","x-plasmic-api-cms-tokens":this.config.databaseId+":"+this.config.databaseToken},mode:"cors"});case 5:if(200===(a=e.sent).status){e.next=12;break}return e.next=9,a.text();case 9:i=e.sent;try{l=JSON.parse(i),null!=(o=l.error)&&o.message&&(i=l.error.message)}catch(e){}throw new w(a.status,i);case 12:return e.next=14,a.json();case 14:return e.abrupt("return",e.sent);case 15:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.fetchTables=function(){var e=s(b.mark((function e(){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.get("");case 3:return e.abrupt("return",e.sent.tables);case 7:throw e.prev=7,e.t0=e.catch(0),console.error(e.t0),e.t0;case 11:case"end":return e.stop()}}),e,this,[[0,7]])})));return function(){return e.apply(this,arguments)}}(),t.query=function(){var e=s(b.mark((function e(t,r){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r={}),e.prev=1,e.next=4,this.get("/tables/"+t+"/query",{q:JSON.stringify(g(r)),draft:Number(r.useDraft),locale:this.config.locale});case 4:return e.abrupt("return",e.sent.rows);case 8:throw e.prev=8,e.t0=e.catch(1),console.error(e.t0),e.t0;case 12:case"end":return e.stop()}}),e,this,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}(),e}();function M(e){if(!e)throw new Error("Component must be wrapped in 'CMS Data Provider'.");return new x(e)}var E=function(e){return"plasmicCms"+N(e)+"Collection"},C=function(e){return"plasmicCms"+N(e)+"Item"};function N(e){var t;return(null==(t=e[0])?void 0:t.toUpperCase())+e.slice(1)}function F(){return n.useSelector("plasmicCmsDatabase")}function S(e){return l.createElement(n.DataProvider,{name:"plasmicCmsDatabase",data:e.config,hidden:!0},e.children)}function P(){return n.useSelector("plasmicCmsTables")}function L(e){return l.createElement(n.DataProvider,{name:"plasmicCmsTables",data:e.tables,hidden:!0},e.children)}function O(e){var t=e.children,r=e.table,a=e.rows,i=e.hidden;return l.createElement(n.DataProvider,{name:r?E(r):void 0,data:a,hidden:i},t)}function Y(){var e=n.useDataEnv(),t=P();if(e&&t){var r=function(e,t){return[].concat(Object.keys(e).reverse()).filter((function(e){return e.endsWith("Item")}))}(e);return t.filter((function(e){return r.some((function(t){return C(e.identifier)===t}))}))}}function D(e,t){var r=n.useDataEnv();if(r)return!t&&e&&e.length>0&&(t=e[0].identifier),t?{table:t,row:r[C(t)]}:void 0}function k(e){var t=e.children,r=e.row;return l.createElement(n.DataProvider,{name:C(e.table),data:r},t)}function j(e){return e?e.map((function(e){return{value:e.identifier,label:e.name}})):[]}function V(e,t,r){if(!e)return[];var n=e.find((function(e){return e.identifier===t}));if(!n)return[];var a=n.schema.fields;return r&&(a=a.filter((function(e){return r.includes(e.type)}))),a.map((function(e){return{value:e.identifier,label:e.name||e.identifier}}))}var R=["className","table","field","dateFormat","setControlContextData"],_=["table","field","valueProp","children","setControlContextData"],T="@plasmicpkgs/plasmic-cms",I="hostless-plasmic-cms",q="https://studio.plasmic.app",A={name:I+"-credentials-provider",displayName:"CMS Credentials Provider",description:"\nFind your CMS in the [dashboard](https://studio.plasmic.app), and go to the Settings tab for the ID and token.\n\nSee also the [getting started video](https://www.youtube.com/watch?v=-Rrn92VtRBc).",importName:"CmsCredentialsProvider",importPath:T,providesData:!0,props:{host:{type:"string",displayName:"Studio URL",description:"The default host for use in production is "+q+".",defaultValue:q,defaultValueHint:q},databaseId:{type:"string",displayName:"CMS ID",description:"The ID of the CMS (database) to use. (Can get on the CMS settings page)"},databaseToken:{type:"string",displayName:"CMS Public Token",description:"The Public Token of the CMS (database) you are using. (Can get on the CMS settings page)"},locale:{type:"string",displayName:"Locale",description:"The locale to use for localized values, leave empty for the default locale."}}};function H(e){return l.createElement(S,{config:{databaseId:e.databaseId,databaseToken:e.databaseToken,locale:e.locale,host:e.host||q}},l.createElement(G,null,e.children))}function G(e){var t=e.children,r=F(),i=JSON.stringify({component:"TablesFetcher",databaseConfig:r}),u=a.usePlasmicQueryData(i,s(b.mark((function e(){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(J(r)){e.next=2;break}return e.abrupt("return",[]);case 2:return e.next=4,M(r).fetchTables();case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e)})))),c=!!o.useContext(n.PlasmicCanvasContext);return l.createElement(L,{tables:u.data},c&&u.error?l.createElement("div",null,"CMS Error: ",u.error.message):t)}function J(e){return(null==e?void 0:e.databaseId)&&(null==e?void 0:e.databaseToken)}var B={name:I+"-query-repeater",displayName:"CMS Data Loader",description:"Fetches CMS data and repeats content of children once for every row fetched.",importName:"CmsQueryRepeater",importPath:T,providesData:!0,defaultStyles:{display:"flex",width:"stretch",maxWidth:"100%",flexDirection:"column"},props:{children:{type:"slot",isRepeated:!0,defaultValue:{type:"vbox",children:[{type:"component",name:I+"-row-field"}]}},table:{type:"choice",displayName:"Model",description:"CMS model (table) to query.",options:function(e,t){return j(null==t?void 0:t.tables)},defaultValueHint:function(e,t){return null==t?void 0:t.table}},useDraft:{type:"boolean",displayName:"Use drafts?",description:"If set, also query unpublished content.",defaultValue:!1,hidden:function(){return!0}},where:{type:"object",displayName:"Filter",description:"Filter clause, in JSON format.",hidden:function(){return!0}},filterField:{type:"choice",displayName:"Filter field",description:"Field (from model schema) to filter by",options:function(e,t){var r;return V(null==t?void 0:t.tables,null!=(r=null==t?void 0:t.table)?r:e.table,["number","boolean","text","long-text"])}},filterValue:{type:"string",displayName:"Filter value",description:"Value to filter by, should be of filter field type"},orderBy:{type:"choice",displayName:"Order by",description:"Field to order by.",options:function(e,t){return V(null==t?void 0:t.tables,null==t?void 0:t.table,["number","boolean","date-time","long-text","text"])}},desc:{type:"boolean",displayName:"Sort descending?",description:'Sort descending by "Order by" field.',defaultValue:!1},limit:{type:"number",displayName:"Limit",description:"Maximum number of entries to fetch (0 for unlimited).",defaultValue:0},emptyMessage:{type:"slot",defaultValue:{type:"text",value:"No matching published entries found."}},forceEmptyState:{type:"boolean",displayName:"Force empty state",description:"If set, will render as if no matching entries were found.",defaultValue:!1},loadingMessage:{type:"slot",defaultValue:{type:"text",value:"Loading..."}},forceLoadingState:{type:"boolean",displayName:"Force loading state",description:"If set, will render as if it is waiting for the query to run.",defaultValue:!1},noLayout:{type:"boolean",displayName:"No layout",description:"When set, CMS Data Loader will not layout its children; instead, the layout set on its parent element will be used. Useful if you want to set flex gap or control container tag type.",defaultValue:!1},noAutoRepeat:{type:"boolean",displayName:"No auto-repeat",description:"Do not automatically repeat children for every entry.",defaultValue:!1}}};function U(e){var t,r=e.table,i=e.children,u=e.setControlContextData,c=e.where,d=e.useDraft,f=e.orderBy,p=e.desc,m=e.limit,h=e.emptyMessage,v=e.forceEmptyState,y=e.loadingMessage,g=e.forceLoadingState,x=e.noLayout,E=e.noAutoRepeat,C=e.className,N=e.filterField,S=e.filterValue,L=F(),Y=P();N&&S&&((t={})[N]=S,c=t);var D={where:c,useDraft:d,orderBy:f,desc:p,limit:m};!r&&Y&&Y.length>0&&(r=Y[0].identifier);var j=JSON.stringify({component:"CmsQueryLoader",table:r,databaseConfig:L,params:D});Y&&(null==u||u({tables:Y,table:r}));var V=a.usePlasmicQueryData(j,s(b.mark((function e(){return b.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(J(L)){e.next=2;break}throw new Error("You must specify a CMS ID and API key");case 2:if(r){e.next=6;break}throw new Error("You must select a model to query");case 6:if(!Y||Y.find((function(e){return e.identifier===r}))){e.next=10;break}throw new Error('There is no model called "'+r+'"');case 10:return e.abrupt("return",M(L).query(r,D));case 11:case"end":return e.stop()}}),e)})))),R=function(e,t,a,o,u,s){if("error"in e){var c=e.error;return o?c&&c instanceof w&&404===c.status?l.createElement("div",null,"Error: Data not found"):l.createElement("div",null,"Error: ",null==c?void 0:c.message):l.createElement(l.Fragment,null,null!=u?u:l.createElement("div",null,"Loading..."))}return!("data"in e)||s?l.createElement(l.Fragment,null,null!=u?u:l.createElement("div",null,"Loading...")):0===(d=e.data).length||v?h:E?i:d.map((function(e,t){return l.createElement(k,{key:t,table:r,row:e},n.repeatedElement(t,i))}));var d}(V,0,0,!!o.useContext(n.PlasmicCanvasContext),y,g);return l.createElement(O,{rows:null==V?void 0:V.data,table:r},x?l.createElement(l.Fragment,null," ",R," "):l.createElement("div",{className:C}," ",R," "))}var Q={name:I+"-row-field",displayName:"CMS Entry Field",importName:"CmsRowField",importPath:T,props:{table:{type:"choice",displayName:"Model",description:"CMS model (table) to use.",options:function(e,t){return j(null==t?void 0:t.tables)},defaultValueHint:function(e,t){return null==t?void 0:t.table}},field:{type:"choice",displayName:"Field",description:"Field (from model schema) to use.",options:function(e,t){var r;return V(null==t?void 0:t.tables,null!=(r=null==t?void 0:t.table)?r:e.table,["number","boolean","text","long-text","date-time","rich-text","image","file"])},defaultValueHint:function(e,t){var r,n;return(null==t||null==(r=t.fieldMeta)?void 0:r.name)||(null==t||null==(n=t.fieldMeta)?void 0:n.identifier)}},dateFormat:{type:"choice",displayName:"Date Format",hidden:function(e,t){var r=e.field;if(!t)return!0;var n=t.table,a=t.tables,i=null==a?void 0:a.find((function(e){return e.identifier===n}));if(!i)return!0;var o=i.schema.fields.find((function(e){return e.identifier===r}));return!o||"date-time"!==o.type},options:[{label:"July 26, 2014",value:"MMMM D, YYYY"},{label:"July 26, 2014 10:02 PM",value:"MMMM D, YYYY h:mm A"},{label:"Jul 26, 2014",value:"MMM D, YYYY"},{label:"Jul 26, 2014 10:02 PM",value:"MMM D, YYYY h:mm A"},{label:"Saturday, July 26, 2014",value:"dddd, MMMM D, YYYY"},{label:"7/26/2014",value:"M/D/YYYY"},{label:"7/26/2014 10:02 PM",value:"M/D/YYYY h:mm A"},{label:"26/7/2014",value:"D/M/YYYY"},{label:"26/7/2014 10:02 PM",value:"D/M/YYYY h:mm A"},{label:"7/26/14",value:"M/D/YY"},{label:"7/26/14 10:02 PM",value:"M/D/YY h:mm A"},{label:"26/7/14",value:"D/M/YY"},{label:"26/7/14 10:02 PM",value:"D/M/YY h:mm A"}]}},defaultStyles:{objectFit:"cover"}};function W(e){var t,r=e.className,n=e.table,a=e.field,o=e.dateFormat,u=e.setControlContextData,s=v(e,R),d=Y(),f=D(d,n),p=l.createElement("div",Object.assign({className:r},s),"Field ",null!=n?n:"Unknown Model",".",null!=a?a:"Unknown Field");if(!f)return p;if(!f.row)return l.createElement("div",{className:r},"Error: No CMS Entry found");var m=K({table:f.table,tables:d,field:a,typeFilters:["text","long-text","rich-text"]});if(d&&(null==u||u({tables:d,table:f.table,row:f.row,fieldMeta:m})),!m)return p;var h=null==(t=f.row.data)?void 0:t[m.identifier];return h?("date-time"===m.type&&o&&(h=i(h).format(o)),h?function(e,t,r){switch(t){case"number":case"boolean":case"text":case"long-text":case"date-time":return l.createElement("div",Object.assign({},r),e);case"rich-text":return l.createElement("div",Object.assign({dangerouslySetInnerHTML:{__html:e},style:{whiteSpace:"normal"}},r));case"image":return e&&"object"==typeof e&&e.url&&e.imageMeta?l.createElement("img",Object.assign({src:e.url,width:e.imageMeta.width,height:e.imageMeta.height},r)):null;case"file":return e&&"object"==typeof e&&e.url&&e.name?l.createElement("a",Object.assign({href:e.url,target:"_blank"},r),e.name):null;default:!function(e){throw new Error("unexpected branch taken")}()}}(h,m.type,c({className:r},s)):null):null}var z=["text"];function K(e){var t,r=e.table,n=e.tables,a=e.field,i=e.typeFilters;if(r){var o=null==n||null==(t=n.find((function(e){return e.identifier===r})))?void 0:t.schema;return a?null==o?void 0:o.fields.find((function(e){return e.identifier===a})):null==o?void 0:o.fields.find((function(e){return(null!=i?i:z).includes(e.type)}))}}var X={name:I+"-row-link",displayName:"CMS Entry Link",importName:"CmsRowLink",importPath:T,props:{children:{type:"slot",defaultValue:{type:"text",tag:"a",value:"Link"}},table:{type:"choice",displayName:"Model",description:"CMS model (table) to use.",options:function(e,t){return j(null==t?void 0:t.tables)},defaultValueHint:function(e,t){return null==t?void 0:t.table}},field:{type:"choice",displayName:"Field",description:"Field (from model schema) to use.",options:function(e,t){var r;return V(null==t?void 0:t.tables,null!=(r=null==t?void 0:t.table)?r:e.table)},defaultValueHint:function(e,t){var r,n;return(null==t||null==(r=t.fieldMeta)?void 0:r.name)||(null==t||null==(n=t.fieldMeta)?void 0:n.identifier)}},hrefProp:{type:"string",displayName:'"href" prop',description:"Prop to inject into children",defaultValue:"href"},prefix:{type:"string",displayName:"Optional prefix",description:"Prefix to prepend to prop value.",hidden:function(e,t){var r;return"file"===(null==t||null==(r=t.fieldMeta)?void 0:r.type)}},suffix:{type:"string",displayName:"Optional suffix",description:"Suffix to append to prop value.",hidden:function(e,t){var r;return"file"===(null==t||null==(r=t.fieldMeta)?void 0:r.type)}}}};function Z(e){var t,r=e.table,n=e.field,a=e.hrefProp,i=e.children,o=e.setControlContextData,u=e.prefix,s=e.suffix,c=Y(),d=D(c,r);if(!d||!d.row)return l.createElement(l.Fragment,null,i);var f=K({table:d.table,tables:c,field:n,typeFilters:["file","text"]});if(c&&(null==o||o({tables:c,table:d.table,row:d.row,fieldMeta:f})),!f)return l.createElement(l.Fragment,null,i);if(!i)return null;var p=(null==(t=d.row.data)?void 0:t[f.identifier])||"",m=l.Children.map(i,(function(e){var t;return l.isValidElement(e)?l.cloneElement(e,((t={})[a]="file"===f.type?p.url:u||s?""+(u||"")+p+(s||""):p,t)):e}));return l.createElement(l.Fragment,null,null!=m?m:null)}var $={name:I+"-row-image",displayName:"CMS Entry Image",importName:"CmsRowImage",importPath:T,props:{children:{type:"slot",defaultValue:{type:"img",src:"https://studio.plasmic.app/static/img/placeholder-full.png"}},table:{type:"choice",displayName:"Model",description:"CMS model (table) to use.",options:function(e,t){return j(null==t?void 0:t.tables)},defaultValueHint:function(e,t){return null==t?void 0:t.table}},field:{type:"choice",displayName:"Field",description:"Field (from model schema) to use.",options:function(e,t){var r;return V(null==t?void 0:t.tables,null!=(r=null==t?void 0:t.table)?r:e.table,["image"])},defaultValueHint:function(e,t){var r,n;return(null==t||null==(r=t.fieldMeta)?void 0:r.name)||(null==t||null==(n=t.fieldMeta)?void 0:n.identifier)}},srcProp:{type:"string",displayName:'Image "src" prop',description:"Prop to inject into children",defaultValue:"src"}}};function ee(e){var t,r=e.table,n=e.field,a=e.srcProp,i=e.children,o=e.setControlContextData,u=Y(),s=D(u,r);if(!s||!s.row)return l.createElement(l.Fragment,null,i);var c=K({table:s.table,tables:u,field:n,typeFilters:["image"]});if(u&&(null==o||o({tables:u,table:s.table,row:s.row,fieldMeta:c})),!c)return l.createElement(l.Fragment,null,i);var d=(null==(t=s.row.data)?void 0:t[c.identifier])||"",f=l.Children.map(i,(function(e){var t,r;return l.isValidElement(e)&&d?l.cloneElement(e,"object"==typeof d&&d.url&&d.imageMeta?((r={})[a]={src:d.url,fullHeight:d.imageMeta.height,fullWidth:d.imageMeta.width},r):((t={})[a]=d,t)):e}));return l.createElement(l.Fragment,null,f)}var te={name:I+"-row-value",displayName:"CMS Entry Value",importName:"CmsRowFieldValue",importPath:T,props:{children:{type:"slot"},table:{type:"choice",displayName:"Model",description:"CMS model (table) to use.",options:function(e,t){return j(null==t?void 0:t.tables)},defaultValueHint:function(e,t){return null==t?void 0:t.table}},field:{type:"choice",displayName:"Field",description:"Field (from model schema) to use.",options:function(e,t){var r;return V(null==t?void 0:t.tables,null!=(r=null==t?void 0:t.table)?r:e.table)},defaultValueHint:function(e,t){var r,n;return(null==t||null==(r=t.fieldMeta)?void 0:r.name)||(null==t||null==(n=t.fieldMeta)?void 0:n.identifier)}},valueProp:{type:"string",displayName:"Value prop",description:"Prop to inject into children as",defaultValue:"children"}}};function re(e){var t,r=e.table,n=e.field,a=e.valueProp,i=e.children,o=e.setControlContextData,u=v(e,_),s=Y(),d=D(s,r);if(!d||!d.row)return l.createElement(l.Fragment,null,i);var f=K({table:d.table,tables:s,field:n,typeFilters:["text"]});if(s&&(null==o||o({tables:s,table:d.table,row:d.row,fieldMeta:f})),!f)return l.createElement(l.Fragment,null,i);var p=(null==(t=d.row.data)?void 0:t[f.identifier])||"",m=l.Children.map(i,(function(e){var t;return l.isValidElement(e)?l.cloneElement(e,c({},u,((t={})[a]=p,t))):e}));return l.createElement(l.Fragment,null,m)}exports.API=x,exports.CmsCredentialsProvider=H,exports.CmsQueryRepeater=U,exports.CmsRowField=W,exports.CmsRowFieldValue=re,exports.CmsRowImage=ee,exports.CmsRowLink=Z,exports.HttpError=w,exports.cmsCredentialsProviderMeta=A,exports.cmsQueryRepeaterMeta=B,exports.cmsRowFieldMeta=Q,exports.cmsRowFieldValueMeta=te,exports.cmsRowImageMeta=$,exports.cmsRowLinkMeta=X,exports.mkApi=M,exports.registerAll=function(e){var n,a,i=function(r,n){e?e.registerComponent(r,n):t(r,n)};n=H,a=A,e?e.registerGlobalContext(n,a):r(n,a),i(U,B),i(W,Q),i(Z,X),i(ee,$),i(re,te)};
2
2
  //# sourceMappingURL=plasmic-cms.cjs.production.min.js.map