@plasmicpkgs/plasmic-wordpress-graphql 0.0.151 → 0.0.153

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.
@@ -442,7 +442,7 @@ function WordpressFetcher(_ref2) {
442
442
  creds: creds
443
443
  });
444
444
  var _usePlasmicQueryData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
445
- var data;
445
+ var res;
446
446
  return _regeneratorRuntime().wrap(function _callee$(_context) {
447
447
  while (1) switch (_context.prev = _context.next) {
448
448
  case 0:
@@ -461,9 +461,9 @@ function WordpressFetcher(_ref2) {
461
461
  }
462
462
  });
463
463
  case 4:
464
- data = _context.sent;
464
+ res = _context.sent;
465
465
  _context.next = 7;
466
- return data.json();
466
+ return res.json();
467
467
  case 7:
468
468
  return _context.abrupt("return", _context.sent);
469
469
  case 8:
@@ -1 +1 @@
1
- {"version":3,"file":"plasmic-wordpress-graphql.cjs.development.js","sources":["../src/wordpress.tsx","../src/index.tsx"],"sourcesContent":["import {\n ComponentMeta,\n DataProvider,\n GlobalContextMeta,\n repeatedElement,\n useSelector,\n} from \"@plasmicapp/host\";\nimport { usePlasmicQueryData } from \"@plasmicapp/query\";\nimport get from \"dlv\";\nimport React, { ReactNode, useContext } from \"react\";\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\nconst modulePath = \"@plasmicpkgs/plasmic-wordpress-graphql\";\n\ninterface WordpressProviderProps {\n graphqlEndpoint: string;\n}\n\nconst CredentialsContext = React.createContext<\n WordpressProviderProps | undefined\n>(undefined);\n\nexport const WordpressProviderMeta: GlobalContextMeta<WordpressProviderProps> = {\n name: \"WordpressGraphQLProvider\",\n displayName: \"Wordpress GraphQL Provider\",\n description: \"The GraphQL API Endpoint of your Wordpress\",\n importName: \"WordpressProvider\",\n importPath: modulePath,\n props: {\n graphqlEndpoint: {\n type: \"string\",\n displayName: \"GraphQL API Endpoint\",\n description: \"GraphQL API Endpoint of your Wordpress\",\n defaultValue: \"https://demo.wpgraphql.com/graphql\",\n },\n },\n};\n\nexport function WordpressProvider({\n graphqlEndpoint,\n children,\n}: React.PropsWithChildren<WordpressProviderProps>) {\n return (\n <CredentialsContext.Provider value={{ graphqlEndpoint }}>\n {children}\n </CredentialsContext.Provider>\n );\n}\n\ninterface WordpressFetcherProps {\n children?: ReactNode;\n className?: string;\n noLayout?: boolean;\n noAutoRepeat?: boolean;\n query?: string;\n setControlContextData?: (data: { endpoint?: string }) => void;\n}\n\nexport const WordpressFetcherMeta: ComponentMeta<WordpressFetcherProps> = {\n name: \"WordpressGraphQLFetcher\",\n displayName: \"Wordpress Fetcher\",\n importName: \"WordpressFetcher\",\n importPath: modulePath,\n providesData: true,\n description:\n \"Fetches Wordpress data and repeats content of children once for every row fetched. \",\n defaultStyles: {\n display: \"grid\",\n gridTemplateColumns: \"1fr 1fr 1fr 1fr\",\n gridRowGap: \"8px\",\n gridColumnGap: \"8px\",\n padding: \"8px\",\n maxWidth: \"100%\",\n },\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n styles: {\n padding: \"8px\",\n },\n children: {\n type: \"component\",\n name: \"WordpressGraphQLField\",\n },\n },\n },\n query: {\n type: \"code\",\n lang: \"graphql\",\n endpoint: (props, ctx) => ctx?.endpoint ?? \"\",\n },\n noAutoRepeat: {\n type: \"boolean\",\n displayName: \"No auto-repeat\",\n description: \"Do not automatically repeat children for every entry.\",\n defaultValue: false,\n },\n noLayout: {\n type: \"boolean\",\n displayName: \"No layout\",\n description:\n \"When set, Wordpress Fetcher 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.\",\n defaultValue: false,\n },\n },\n};\n\nfunction compact(arr: any[]) {\n return arr.filter((x) => !!x);\n}\n\nexport function WordpressFetcher({\n query,\n children,\n className,\n noLayout,\n noAutoRepeat,\n setControlContextData,\n}: WordpressFetcherProps) {\n const creds = ensure(useContext(CredentialsContext));\n const cacheKey = JSON.stringify({\n query,\n creds,\n });\n const { data } = usePlasmicQueryData<any | null>(cacheKey, async () => {\n if (!query) {\n return null;\n }\n const data = await fetch(creds.graphqlEndpoint, {\n method: \"POST\",\n body: JSON.stringify(query),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n return await data.json();\n });\n\n setControlContextData?.({\n endpoint: creds.graphqlEndpoint,\n });\n\n if (!query) {\n return <div>Please make a query in order to fetch data</div>;\n }\n\n if (!creds.graphqlEndpoint) {\n return (\n <div>\n Please specify a valid API Credentials: GraphQL Endpoint of your\n Wordpress project\n </div>\n );\n }\n\n if (!data?.data || compact(Object.values(data?.data)).length === 0) {\n return <div>Data not found</div>;\n }\n\n const renderedData = noAutoRepeat\n ? children\n : Object.values(data?.data).flatMap((model: any, i: number) =>\n (Array.isArray(model) ? model : [model]).map((item: any, j: number) => (\n <DataProvider\n key={JSON.stringify(item)}\n name={\"currentWordpressItem\"}\n data={item}\n >\n {repeatedElement(i === 0 && j === 0, children)}\n </DataProvider>\n ))\n );\n return noLayout ? (\n <> {renderedData} </>\n ) : (\n <div className={className}> {renderedData} </div>\n );\n}\n\ninterface WordpressFieldProps {\n className?: string;\n path?: string;\n setControlContextData?: (data: { data: any }) => void;\n}\nexport const WordpressFieldMeta: ComponentMeta<WordpressFieldProps> = {\n name: \"WordpressGraphQLField\",\n displayName: \"Wordpress Field\",\n importName: \"WordpressField\",\n importPath: modulePath,\n props: {\n path: {\n type: \"dataSelector\",\n data: (props: any, ctx: any) => ctx?.data ?? {},\n displayName: \"Field\",\n description: \"Field to be displayed.\",\n },\n },\n};\nexport function WordpressField({\n className,\n path,\n setControlContextData,\n}: WordpressFieldProps) {\n const item = useSelector(\"currentWordpressItem\");\n\n if (!item) {\n return <div>WordpressField must be used within a WordpressFetcher </div>;\n }\n\n setControlContextData?.({\n data: item,\n });\n\n if (!path) {\n return <div>Please specify a valid path or select a field.</div>;\n }\n const data = get(item, path as string);\n if (typeof data === \"object\" && data.mediaType === \"image\") {\n return (\n <img className={className} src={data.mediaItemUrl} srcSet={data.srcSet} />\n );\n } else if (\n path.slice(-1)[0] === \"content\" ||\n path.slice(-1)[0] === \"excerpt\"\n ) {\n return (\n <div className={className} dangerouslySetInnerHTML={{ __html: data }} />\n );\n } else if (!data || typeof data === \"object\") {\n return <div className={className}>Please specify a valid field.</div>;\n } else {\n return <div className={className}> {data} </div>;\n }\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\nimport {\n WordpressFetcher,\n WordpressFetcherMeta,\n WordpressField,\n WordpressFieldMeta,\n WordpressProvider,\n WordpressProviderMeta,\n} from \"./wordpress\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n\n if (loader) {\n loader.registerGlobalContext(WordpressProvider, WordpressProviderMeta);\n } else {\n registerGlobalContext(WordpressProvider, WordpressProviderMeta);\n }\n\n _registerComponent(WordpressFetcher, WordpressFetcherMeta);\n _registerComponent(WordpressField, WordpressFieldMeta);\n}\n\nexport * from \"./wordpress\";\n"],"names":["ensure","x","undefined","Error","modulePath","CredentialsContext","React","createContext","WordpressProviderMeta","name","displayName","description","importName","importPath","props","graphqlEndpoint","type","defaultValue","WordpressProvider","_ref","children","Provider","value","WordpressFetcherMeta","providesData","defaultStyles","display","gridTemplateColumns","gridRowGap","gridColumnGap","padding","maxWidth","styles","query","lang","endpoint","ctx","_ctx$endpoint","noAutoRepeat","noLayout","compact","arr","filter","WordpressFetcher","_ref2","className","setControlContextData","creds","useContext","cacheKey","JSON","stringify","_usePlasmicQueryData","usePlasmicQueryData","_asyncToGenerator","_regeneratorRuntime","mark","_callee","data","wrap","_callee$","_context","prev","next","abrupt","fetch","method","body","headers","sent","json","stop","Object","values","length","renderedData","flatMap","model","i","Array","isArray","map","item","j","DataProvider","key","repeatedElement","WordpressFieldMeta","path","_ctx$data","WordpressField","_ref4","useSelector","get","mediaType","src","mediaItemUrl","srcSet","slice","dangerouslySetInnerHTML","__html","registerAll","loader","_registerComponent","Component","defaultMeta","registerComponent","registerGlobalContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAWgBA,MAAMA,CAAIC,CAAuB;EAC/C,IAAIA,CAAC,KAAK,IAAI,IAAIA,CAAC,KAAKC,SAAS,EAAE;IACjC;IACA,MAAM,IAAIC,KAAK,sCAAsC,CAAC;GACvD,MAAM;IACL,OAAOF,CAAC;;AAEZ;AAEA,IAAMG,UAAU,GAAG,wCAAwC;AAM3D,IAAMC,kBAAkB,gBAAGC,cAAK,CAACC,aAAa,CAE5CL,SAAS,CAAC;IAECM,qBAAqB,GAA8C;EAC9EC,IAAI,EAAE,0BAA0B;EAChCC,WAAW,EAAE,4BAA4B;EACzCC,WAAW,EAAE,4CAA4C;EACzDC,UAAU,EAAE,mBAAmB;EAC/BC,UAAU,EAAET,UAAU;EACtBU,KAAK,EAAE;IACLC,eAAe,E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,CAACsC,YAAY;MAAEC,MAAM,EAAEvC,IAAI,CAACuC;MAAU;GAE7E,MAAM,IACLT,IAAI,CAACU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,IAC/BV,IAAI,CAACU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,EAC/B;IACA,OACE5F;MAAKuC,SAAS,EAAEA,SAAS;MAAEsD,uBAAuB,EAAE;QAAEC,MAAM,EAAE1C;;MAAU;GAE3E,MAAM,IAAI,CAACA,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5C,OAAOpD;MAAKuC,SAAS,EAAEA;uCAA8C;GACtE,MAAM;IACL,OAAOvC;MAAKuC,SAAS,EAAEA;YAAaa,IAAI,MAAQ;;AAEpD;;SCtOgB2C,WAAWA,CAACC,MAG3B;EACC,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CACtBC,SAAY,EACZC,WAAmD;IAEnD,IAAIH,MAAM,EAAE;MACVA,MAAM,CAACI,iBAAiB,CAACF,SAAS,EAAEC,WAAW,CAAC;KACjD,MAAM;MACLC,iBAAiB,CAACF,SAAS,EAAEC,WAAW,CAAC;;GAE5C;EAED,IAAIH,MAAM,EAAE;IACVA,MAAM,CAACK,qBAAqB,CAACzF,iBAAiB,EAAEV,qBAAqB,CAAC;GACvE,MAAM;IACLmG,qBAAqB,CAACzF,iBAAiB,EAAEV,qBAAqB,CAAC;;EAGjE+F,kBAAkB,CAAC5D,gBAAgB,EAAEpB,oBAAoB,CAAC;EAC1DgF,kBAAkB,CAACb,cAAc,EAAEH,kBAAkB,CAAC;AACxD;;;;;;;;;;;"}
1
+ {"version":3,"file":"plasmic-wordpress-graphql.cjs.development.js","sources":["../src/wordpress.tsx","../src/index.tsx"],"sourcesContent":["import {\n DataProvider,\n GlobalContextMeta,\n repeatedElement,\n useSelector,\n} from \"@plasmicapp/host\";\nimport { CodeComponentMeta } from \"@plasmicapp/host/registerComponent\";\nimport { usePlasmicQueryData } from \"@plasmicapp/query\";\nimport get from \"dlv\";\nimport React, { ReactNode, useContext } from \"react\";\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\nconst modulePath = \"@plasmicpkgs/plasmic-wordpress-graphql\";\n\ninterface WordpressProviderProps {\n graphqlEndpoint: string;\n}\n\nconst CredentialsContext = React.createContext<\n WordpressProviderProps | undefined\n>(undefined);\n\nexport const WordpressProviderMeta: GlobalContextMeta<WordpressProviderProps> =\n {\n name: \"WordpressGraphQLProvider\",\n displayName: \"Wordpress GraphQL Provider\",\n description: \"The GraphQL API Endpoint of your Wordpress\",\n importName: \"WordpressProvider\",\n importPath: modulePath,\n props: {\n graphqlEndpoint: {\n type: \"string\",\n displayName: \"GraphQL API Endpoint\",\n description: \"GraphQL API Endpoint of your Wordpress\",\n defaultValue: \"https://demo.wpgraphql.com/graphql\",\n },\n },\n };\n\nexport function WordpressProvider({\n graphqlEndpoint,\n children,\n}: React.PropsWithChildren<WordpressProviderProps>) {\n return (\n <CredentialsContext.Provider value={{ graphqlEndpoint }}>\n {children}\n </CredentialsContext.Provider>\n );\n}\n\ninterface WordpressFetcherProps {\n children?: ReactNode;\n className?: string;\n noLayout?: boolean;\n noAutoRepeat?: boolean;\n query?: string;\n setControlContextData?: (data: { endpoint?: string }) => void;\n}\n\nexport const WordpressFetcherMeta: CodeComponentMeta<WordpressFetcherProps> = {\n name: \"WordpressGraphQLFetcher\",\n displayName: \"Wordpress Fetcher\",\n importName: \"WordpressFetcher\",\n importPath: modulePath,\n providesData: true,\n description:\n \"Fetches Wordpress data and repeats content of children once for every row fetched. \",\n defaultStyles: {\n display: \"grid\",\n gridTemplateColumns: \"1fr 1fr 1fr 1fr\",\n gridRowGap: \"8px\",\n gridColumnGap: \"8px\",\n padding: \"8px\",\n maxWidth: \"100%\",\n },\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n styles: {\n padding: \"8px\",\n },\n children: {\n type: \"component\",\n name: \"WordpressGraphQLField\",\n },\n },\n },\n query: {\n type: \"code\",\n lang: \"graphql\",\n endpoint: (props, ctx) => ctx?.endpoint ?? \"\",\n },\n noAutoRepeat: {\n type: \"boolean\",\n displayName: \"No auto-repeat\",\n description: \"Do not automatically repeat children for every entry.\",\n defaultValue: false,\n },\n noLayout: {\n type: \"boolean\",\n displayName: \"No layout\",\n description:\n \"When set, Wordpress Fetcher 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.\",\n defaultValue: false,\n },\n },\n};\n\nfunction compact(arr: any[]) {\n return arr.filter((x) => !!x);\n}\n\nexport function WordpressFetcher({\n query,\n children,\n className,\n noLayout,\n noAutoRepeat,\n setControlContextData,\n}: WordpressFetcherProps) {\n const creds = ensure(useContext(CredentialsContext));\n const cacheKey = JSON.stringify({\n query,\n creds,\n });\n const { data } = usePlasmicQueryData<any | null>(cacheKey, async () => {\n if (!query) {\n return null;\n }\n const res = await fetch(creds.graphqlEndpoint, {\n method: \"POST\",\n body: JSON.stringify(query),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n return await res.json();\n });\n\n setControlContextData?.({\n endpoint: creds.graphqlEndpoint,\n });\n\n if (!query) {\n return <div>Please make a query in order to fetch data</div>;\n }\n\n if (!creds.graphqlEndpoint) {\n return (\n <div>\n Please specify a valid API Credentials: GraphQL Endpoint of your\n Wordpress project\n </div>\n );\n }\n\n if (!data?.data || compact(Object.values(data?.data)).length === 0) {\n return <div>Data not found</div>;\n }\n\n const renderedData = noAutoRepeat\n ? children\n : Object.values(data?.data).flatMap((model: any, i: number) =>\n (Array.isArray(model) ? model : [model]).map((item: any, j: number) => (\n <DataProvider\n key={JSON.stringify(item)}\n name={\"currentWordpressItem\"}\n data={item}\n >\n {repeatedElement(i === 0 && j === 0, children)}\n </DataProvider>\n ))\n );\n return noLayout ? (\n <> {renderedData} </>\n ) : (\n <div className={className}> {renderedData} </div>\n );\n}\n\ninterface WordpressFieldProps {\n className?: string;\n path?: string;\n setControlContextData?: (data: { data: any }) => void;\n}\nexport const WordpressFieldMeta: CodeComponentMeta<WordpressFieldProps> = {\n name: \"WordpressGraphQLField\",\n displayName: \"Wordpress Field\",\n importName: \"WordpressField\",\n importPath: modulePath,\n props: {\n path: {\n type: \"dataSelector\",\n data: (props: any, ctx: any) => ctx?.data ?? {},\n displayName: \"Field\",\n description: \"Field to be displayed.\",\n },\n },\n};\nexport function WordpressField({\n className,\n path,\n setControlContextData,\n}: WordpressFieldProps) {\n const item = useSelector(\"currentWordpressItem\");\n\n if (!item) {\n return <div>WordpressField must be used within a WordpressFetcher </div>;\n }\n\n setControlContextData?.({\n data: item,\n });\n\n if (!path) {\n return <div>Please specify a valid path or select a field.</div>;\n }\n const data = get(item, path as string);\n if (typeof data === \"object\" && data.mediaType === \"image\") {\n return (\n <img className={className} src={data.mediaItemUrl} srcSet={data.srcSet} />\n );\n } else if (\n path.slice(-1)[0] === \"content\" ||\n path.slice(-1)[0] === \"excerpt\"\n ) {\n return (\n <div className={className} dangerouslySetInnerHTML={{ __html: data }} />\n );\n } else if (!data || typeof data === \"object\") {\n return <div className={className}>Please specify a valid field.</div>;\n } else {\n return <div className={className}> {data} </div>;\n }\n}\n","import registerComponent, {\n CodeComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\nimport {\n WordpressFetcher,\n WordpressFetcherMeta,\n WordpressField,\n WordpressFieldMeta,\n WordpressProvider,\n WordpressProviderMeta,\n} from \"./wordpress\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: CodeComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n\n if (loader) {\n loader.registerGlobalContext(WordpressProvider, WordpressProviderMeta);\n } else {\n registerGlobalContext(WordpressProvider, WordpressProviderMeta);\n }\n\n _registerComponent(WordpressFetcher, WordpressFetcherMeta);\n _registerComponent(WordpressField, WordpressFieldMeta);\n}\n\nexport * from \"./wordpress\";\n"],"names":["ensure","x","undefined","Error","modulePath","CredentialsContext","React","createContext","WordpressProviderMeta","name","displayName","description","importName","importPath","props","graphqlEndpoint","type","defaultValue","WordpressProvider","_ref","children","Provider","value","WordpressFetcherMeta","providesData","defaultStyles","display","gridTemplateColumns","gridRowGap","gridColumnGap","padding","maxWidth","styles","query","lang","endpoint","ctx","_ctx$endpoint","noAutoRepeat","noLayout","compact","arr","filter","WordpressFetcher","_ref2","className","setControlContextData","creds","useContext","cacheKey","JSON","stringify","_usePlasmicQueryData","usePlasmicQueryData","_asyncToGenerator","_regeneratorRuntime","mark","_callee","res","wrap","_callee$","_context","prev","next","abrupt","fetch","method","body","headers","sent","json","stop","data","Object","values","length","renderedData","flatMap","model","i","Array","isArray","map","item","j","DataProvider","key","repeatedElement","WordpressFieldMeta","path","_ctx$data","WordpressField","_ref4","useSelector","get","mediaType","src","mediaItemUrl","srcSet","slice","dangerouslySetInnerHTML","__html","registerAll","loader","_registerComponent","Component","defaultMeta","registerComponent","registerGlobalContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAACF,SAAS,EAAEC,WAAW,CAAC;;GAE5C;EAED,IAAIH,MAAM,EAAE;IACVA,MAAM,CAACK,qBAAqB,CAAC1F,iBAAiB,EAAEV,qBAAqB,CAAC;GACvE,MAAM;IACLoG,qBAAqB,CAAC1F,iBAAiB,EAAEV,qBAAqB,CAAC;;EAGjEgG,kBAAkB,CAAC7D,gBAAgB,EAAEpB,oBAAoB,CAAC;EAC1DiF,kBAAkB,CAACb,cAAc,EAAEH,kBAAkB,CAAC;AACxD;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"plasmic-wordpress-graphql.cjs.production.min.js","sources":["../src/wordpress.tsx","../src/index.tsx"],"sourcesContent":["import {\n ComponentMeta,\n DataProvider,\n GlobalContextMeta,\n repeatedElement,\n useSelector,\n} from \"@plasmicapp/host\";\nimport { usePlasmicQueryData } from \"@plasmicapp/query\";\nimport get from \"dlv\";\nimport React, { ReactNode, useContext } from \"react\";\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\nconst modulePath = \"@plasmicpkgs/plasmic-wordpress-graphql\";\n\ninterface WordpressProviderProps {\n graphqlEndpoint: string;\n}\n\nconst CredentialsContext = React.createContext<\n WordpressProviderProps | undefined\n>(undefined);\n\nexport const WordpressProviderMeta: GlobalContextMeta<WordpressProviderProps> = {\n name: \"WordpressGraphQLProvider\",\n displayName: \"Wordpress GraphQL Provider\",\n description: \"The GraphQL API Endpoint of your Wordpress\",\n importName: \"WordpressProvider\",\n importPath: modulePath,\n props: {\n graphqlEndpoint: {\n type: \"string\",\n displayName: \"GraphQL API Endpoint\",\n description: \"GraphQL API Endpoint of your Wordpress\",\n defaultValue: \"https://demo.wpgraphql.com/graphql\",\n },\n },\n};\n\nexport function WordpressProvider({\n graphqlEndpoint,\n children,\n}: React.PropsWithChildren<WordpressProviderProps>) {\n return (\n <CredentialsContext.Provider value={{ graphqlEndpoint }}>\n {children}\n </CredentialsContext.Provider>\n );\n}\n\ninterface WordpressFetcherProps {\n children?: ReactNode;\n className?: string;\n noLayout?: boolean;\n noAutoRepeat?: boolean;\n query?: string;\n setControlContextData?: (data: { endpoint?: string }) => void;\n}\n\nexport const WordpressFetcherMeta: ComponentMeta<WordpressFetcherProps> = {\n name: \"WordpressGraphQLFetcher\",\n displayName: \"Wordpress Fetcher\",\n importName: \"WordpressFetcher\",\n importPath: modulePath,\n providesData: true,\n description:\n \"Fetches Wordpress data and repeats content of children once for every row fetched. \",\n defaultStyles: {\n display: \"grid\",\n gridTemplateColumns: \"1fr 1fr 1fr 1fr\",\n gridRowGap: \"8px\",\n gridColumnGap: \"8px\",\n padding: \"8px\",\n maxWidth: \"100%\",\n },\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n styles: {\n padding: \"8px\",\n },\n children: {\n type: \"component\",\n name: \"WordpressGraphQLField\",\n },\n },\n },\n query: {\n type: \"code\",\n lang: \"graphql\",\n endpoint: (props, ctx) => ctx?.endpoint ?? \"\",\n },\n noAutoRepeat: {\n type: \"boolean\",\n displayName: \"No auto-repeat\",\n description: \"Do not automatically repeat children for every entry.\",\n defaultValue: false,\n },\n noLayout: {\n type: \"boolean\",\n displayName: \"No layout\",\n description:\n \"When set, Wordpress Fetcher 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.\",\n defaultValue: false,\n },\n },\n};\n\nfunction compact(arr: any[]) {\n return arr.filter((x) => !!x);\n}\n\nexport function WordpressFetcher({\n query,\n children,\n className,\n noLayout,\n noAutoRepeat,\n setControlContextData,\n}: WordpressFetcherProps) {\n const creds = ensure(useContext(CredentialsContext));\n const cacheKey = JSON.stringify({\n query,\n creds,\n });\n const { data } = usePlasmicQueryData<any | null>(cacheKey, async () => {\n if (!query) {\n return null;\n }\n const data = await fetch(creds.graphqlEndpoint, {\n method: \"POST\",\n body: JSON.stringify(query),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n return await data.json();\n });\n\n setControlContextData?.({\n endpoint: creds.graphqlEndpoint,\n });\n\n if (!query) {\n return <div>Please make a query in order to fetch data</div>;\n }\n\n if (!creds.graphqlEndpoint) {\n return (\n <div>\n Please specify a valid API Credentials: GraphQL Endpoint of your\n Wordpress project\n </div>\n );\n }\n\n if (!data?.data || compact(Object.values(data?.data)).length === 0) {\n return <div>Data not found</div>;\n }\n\n const renderedData = noAutoRepeat\n ? children\n : Object.values(data?.data).flatMap((model: any, i: number) =>\n (Array.isArray(model) ? model : [model]).map((item: any, j: number) => (\n <DataProvider\n key={JSON.stringify(item)}\n name={\"currentWordpressItem\"}\n data={item}\n >\n {repeatedElement(i === 0 && j === 0, children)}\n </DataProvider>\n ))\n );\n return noLayout ? (\n <> {renderedData} </>\n ) : (\n <div className={className}> {renderedData} </div>\n );\n}\n\ninterface WordpressFieldProps {\n className?: string;\n path?: string;\n setControlContextData?: (data: { data: any }) => void;\n}\nexport const WordpressFieldMeta: ComponentMeta<WordpressFieldProps> = {\n name: \"WordpressGraphQLField\",\n displayName: \"Wordpress Field\",\n importName: \"WordpressField\",\n importPath: modulePath,\n props: {\n path: {\n type: \"dataSelector\",\n data: (props: any, ctx: any) => ctx?.data ?? {},\n displayName: \"Field\",\n description: \"Field to be displayed.\",\n },\n },\n};\nexport function WordpressField({\n className,\n path,\n setControlContextData,\n}: WordpressFieldProps) {\n const item = useSelector(\"currentWordpressItem\");\n\n if (!item) {\n return <div>WordpressField must be used within a WordpressFetcher </div>;\n }\n\n setControlContextData?.({\n data: item,\n });\n\n if (!path) {\n return <div>Please specify a valid path or select a field.</div>;\n }\n const data = get(item, path as string);\n if (typeof data === \"object\" && data.mediaType === \"image\") {\n return (\n <img className={className} src={data.mediaItemUrl} srcSet={data.srcSet} />\n );\n } else if (\n path.slice(-1)[0] === \"content\" ||\n path.slice(-1)[0] === \"excerpt\"\n ) {\n return (\n <div className={className} dangerouslySetInnerHTML={{ __html: data }} />\n );\n } else if (!data || typeof data === \"object\") {\n return <div className={className}>Please specify a valid field.</div>;\n } else {\n return <div className={className}> {data} </div>;\n }\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\nimport {\n WordpressFetcher,\n WordpressFetcherMeta,\n WordpressField,\n WordpressFieldMeta,\n WordpressProvider,\n WordpressProviderMeta,\n} from \"./wordpress\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n\n if (loader) {\n loader.registerGlobalContext(WordpressProvider, WordpressProviderMeta);\n } else {\n registerGlobalContext(WordpressProvider, WordpressProviderMeta);\n }\n\n _registerComponent(WordpressFetcher, WordpressFetcherMeta);\n _registerComponent(WordpressField, WordpressFieldMeta);\n}\n\nexport * from \"./wordpress\";\n"],"names":["ensure","x","Error","modulePath","CredentialsContext","React","createContext","undefined","WordpressProviderMeta","name","displayName","description","importName","importPath","props","graphqlEndpoint","type","defaultValue","WordpressProvider","_ref","Provider","value","children","WordpressFetcherMeta","providesData","defaultStyles","display","gridTemplateColumns","gridRowGap","gridColumnGap","padding","maxWidth","styles","query","lang","endpoint","ctx","_ctx$endpoint","noAutoRepeat","noLayout","WordpressFetcher","_ref2","arr","className","setControlContextData","creds","useContext","cacheKey","JSON","stringify","data","usePlasmicQueryData","_asyncToGenerator","_regeneratorRuntime","mark","_callee","wrap","_context","prev","next","abrupt","fetch","method","body","headers","Content-Type","sent","json","stop","Object","values","filter","length","renderedData","flatMap","model","i","Array","isArray","map","item","j","DataProvider","key","repeatedElement","WordpressFieldMeta","path","_ctx$data","WordpressField","_ref4","useSelector","get","mediaType","src","mediaItemUrl","srcSet","slice","dangerouslySetInnerHTML","__html","loader","_registerComponent","Component","defaultMeta","registerComponent","registerGlobalContext"],"mappings":"wgOAWgBA,EAAUC,GACxB,GAAIA,MAAAA,EAEF,MAAM,IAAIC,6CAEV,OAAOD,EAIX,IAAME,EAAa,yCAMbC,EAAqBC,EAAMC,mBAE/BC,GAEWC,EAAmE,CAC9EC,KAAM,2BACNC,YAAa,6BACbC,YAAa,6CACbC,WAAY,oBACZC,WAAYV,EACZW,MAAO,CACLC,gBAAiB,CACfC,KAAM,SACNN,YAAa,uBACbC,YAAa,yCACbM,aAAc,iDAKJC,EAAiBC,GAI/B,OACEd,gBAACD,EAAmBgB,UAASC,MAAO,CAAEN,gBAJzBI,EAAfJ,kBACQI,EAARG,cAkBWC,EAA6D,CACxEd,KAAM,0BACNC,YAAa,oBACbE,WAAY,mBACZC,WAAYV,EACZqB,cAAc,EACdb,YACE,sFACFc,cAAe,CACbC,QAAS,OACTC,oBAAqB,kBACrBC,WAAY,MACZC,cAAe,MACfC,QAAS,MACTC,SAAU,QAEZjB,MAAO,CACLQ,SAAU,CACRN,KAAM,OACNC,aAAc,CACZD,KAAM,OACNgB,OAAQ,CACNF,QAAS,OAEXR,SAAU,CACRN,KAAM,YACNP,KAAM,2BAIZwB,MAAO,CACLjB,KAAM,OACNkB,KAAM,UACNC,SAAU,SAACrB,EAAOsB,GAAG,IAAAC,EAAA,cAAAA,QAAKD,SAAAA,EAAKD,UAAQE,EAAI,KAE7CC,aAAc,CACZtB,KAAM,UACNN,YAAa,iBACbC,YAAa,wDACbM,cAAc,GAEhBsB,SAAU,CACRvB,KAAM,UACNN,YAAa,YACbC,YACE,0LACFM,cAAc,cASJuB,EAAgBC,OAJfC,EAKfT,EAAKQ,EAALR,MACAX,EAAQmB,EAARnB,SACAqB,EAASF,EAATE,UACAJ,EAAQE,EAARF,SACAD,EAAYG,EAAZH,aACAM,EAAqBH,EAArBG,sBAEMC,EAAQ7C,EAAO8C,aAAW1C,IAC1B2C,EAAWC,KAAK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EACZW,MAAO,CACLwE,KAAM,CACJtE,KAAM,eACNkC,KAAM,SAACpC,EAAYsB,GAAQ,IAAAmD,EAAA,cAAAA,QAAKnD,SAAAA,EAAKc,MAAIqC,EAAI,IAC7C7E,YAAa,QACbC,YAAa,qCAIH6E,EAAcC,OAC5B9C,EAAS8C,EAAT9C,UACA2C,EAAIG,EAAJH,KACA1C,EAAqB6C,EAArB7C,sBAEMoC,EAAOU,cAAY,wBAEzB,IAAKV,EACH,OAAO3E,qFAOT,SAJAuC,GAAAA,EAAwB,CACtBM,KAAM8B,KAGHM,EACH,OAAOjF,6EAET,IAAM6C,EAAOyC,EAAIX,EAAMM,GACvB,MAAoB,iBAATpC,GAAwC,UAAnBA,EAAK0C,UAEjCvF,uBAAKsC,UAAWA,EAAWkD,IAAK3C,EAAK4C,aAAcC,OAAQ7C,EAAK6C,SAG5C,YAAtBT,EAAKU,OAAO,GAAG,IACO,YAAtBV,EAAKU,OAAO,GAAG,GAGb3F,uBAAKsC,UAAWA,EAAWsD,wBAAyB,CAAEC,OAAQhD,KAEtDA,GAAwB,iBAATA,EAGlB7C,uBAAKsC,UAAWA,OAAaO,OAF7B7C,uBAAKsC,UAAWA,8PClOCwD,GAI1B,IAAMC,EAAqB,SACzBC,EACAC,GAEIH,EACFA,EAAOI,kBAAkBF,EAAWC,GAEpCC,EAAkBF,EAAWC,IAI7BH,EACFA,EAAOK,sBAAsBtF,EAAmBV,GAEhDgG,EAAsBtF,EAAmBV,GAG3C4F,EAAmB5D,EAAkBjB,GACrC6E,EAAmBZ,EAAgBH"}
1
+ {"version":3,"file":"plasmic-wordpress-graphql.cjs.production.min.js","sources":["../src/wordpress.tsx","../src/index.tsx"],"sourcesContent":["import {\n DataProvider,\n GlobalContextMeta,\n repeatedElement,\n useSelector,\n} from \"@plasmicapp/host\";\nimport { CodeComponentMeta } from \"@plasmicapp/host/registerComponent\";\nimport { usePlasmicQueryData } from \"@plasmicapp/query\";\nimport get from \"dlv\";\nimport React, { ReactNode, useContext } from \"react\";\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\nconst modulePath = \"@plasmicpkgs/plasmic-wordpress-graphql\";\n\ninterface WordpressProviderProps {\n graphqlEndpoint: string;\n}\n\nconst CredentialsContext = React.createContext<\n WordpressProviderProps | undefined\n>(undefined);\n\nexport const WordpressProviderMeta: GlobalContextMeta<WordpressProviderProps> =\n {\n name: \"WordpressGraphQLProvider\",\n displayName: \"Wordpress GraphQL Provider\",\n description: \"The GraphQL API Endpoint of your Wordpress\",\n importName: \"WordpressProvider\",\n importPath: modulePath,\n props: {\n graphqlEndpoint: {\n type: \"string\",\n displayName: \"GraphQL API Endpoint\",\n description: \"GraphQL API Endpoint of your Wordpress\",\n defaultValue: \"https://demo.wpgraphql.com/graphql\",\n },\n },\n };\n\nexport function WordpressProvider({\n graphqlEndpoint,\n children,\n}: React.PropsWithChildren<WordpressProviderProps>) {\n return (\n <CredentialsContext.Provider value={{ graphqlEndpoint }}>\n {children}\n </CredentialsContext.Provider>\n );\n}\n\ninterface WordpressFetcherProps {\n children?: ReactNode;\n className?: string;\n noLayout?: boolean;\n noAutoRepeat?: boolean;\n query?: string;\n setControlContextData?: (data: { endpoint?: string }) => void;\n}\n\nexport const WordpressFetcherMeta: CodeComponentMeta<WordpressFetcherProps> = {\n name: \"WordpressGraphQLFetcher\",\n displayName: \"Wordpress Fetcher\",\n importName: \"WordpressFetcher\",\n importPath: modulePath,\n providesData: true,\n description:\n \"Fetches Wordpress data and repeats content of children once for every row fetched. \",\n defaultStyles: {\n display: \"grid\",\n gridTemplateColumns: \"1fr 1fr 1fr 1fr\",\n gridRowGap: \"8px\",\n gridColumnGap: \"8px\",\n padding: \"8px\",\n maxWidth: \"100%\",\n },\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n styles: {\n padding: \"8px\",\n },\n children: {\n type: \"component\",\n name: \"WordpressGraphQLField\",\n },\n },\n },\n query: {\n type: \"code\",\n lang: \"graphql\",\n endpoint: (props, ctx) => ctx?.endpoint ?? \"\",\n },\n noAutoRepeat: {\n type: \"boolean\",\n displayName: \"No auto-repeat\",\n description: \"Do not automatically repeat children for every entry.\",\n defaultValue: false,\n },\n noLayout: {\n type: \"boolean\",\n displayName: \"No layout\",\n description:\n \"When set, Wordpress Fetcher 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.\",\n defaultValue: false,\n },\n },\n};\n\nfunction compact(arr: any[]) {\n return arr.filter((x) => !!x);\n}\n\nexport function WordpressFetcher({\n query,\n children,\n className,\n noLayout,\n noAutoRepeat,\n setControlContextData,\n}: WordpressFetcherProps) {\n const creds = ensure(useContext(CredentialsContext));\n const cacheKey = JSON.stringify({\n query,\n creds,\n });\n const { data } = usePlasmicQueryData<any | null>(cacheKey, async () => {\n if (!query) {\n return null;\n }\n const res = await fetch(creds.graphqlEndpoint, {\n method: \"POST\",\n body: JSON.stringify(query),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n return await res.json();\n });\n\n setControlContextData?.({\n endpoint: creds.graphqlEndpoint,\n });\n\n if (!query) {\n return <div>Please make a query in order to fetch data</div>;\n }\n\n if (!creds.graphqlEndpoint) {\n return (\n <div>\n Please specify a valid API Credentials: GraphQL Endpoint of your\n Wordpress project\n </div>\n );\n }\n\n if (!data?.data || compact(Object.values(data?.data)).length === 0) {\n return <div>Data not found</div>;\n }\n\n const renderedData = noAutoRepeat\n ? children\n : Object.values(data?.data).flatMap((model: any, i: number) =>\n (Array.isArray(model) ? model : [model]).map((item: any, j: number) => (\n <DataProvider\n key={JSON.stringify(item)}\n name={\"currentWordpressItem\"}\n data={item}\n >\n {repeatedElement(i === 0 && j === 0, children)}\n </DataProvider>\n ))\n );\n return noLayout ? (\n <> {renderedData} </>\n ) : (\n <div className={className}> {renderedData} </div>\n );\n}\n\ninterface WordpressFieldProps {\n className?: string;\n path?: string;\n setControlContextData?: (data: { data: any }) => void;\n}\nexport const WordpressFieldMeta: CodeComponentMeta<WordpressFieldProps> = {\n name: \"WordpressGraphQLField\",\n displayName: \"Wordpress Field\",\n importName: \"WordpressField\",\n importPath: modulePath,\n props: {\n path: {\n type: \"dataSelector\",\n data: (props: any, ctx: any) => ctx?.data ?? {},\n displayName: \"Field\",\n description: \"Field to be displayed.\",\n },\n },\n};\nexport function WordpressField({\n className,\n path,\n setControlContextData,\n}: WordpressFieldProps) {\n const item = useSelector(\"currentWordpressItem\");\n\n if (!item) {\n return <div>WordpressField must be used within a WordpressFetcher </div>;\n }\n\n setControlContextData?.({\n data: item,\n });\n\n if (!path) {\n return <div>Please specify a valid path or select a field.</div>;\n }\n const data = get(item, path as string);\n if (typeof data === \"object\" && data.mediaType === \"image\") {\n return (\n <img className={className} src={data.mediaItemUrl} srcSet={data.srcSet} />\n );\n } else if (\n path.slice(-1)[0] === \"content\" ||\n path.slice(-1)[0] === \"excerpt\"\n ) {\n return (\n <div className={className} dangerouslySetInnerHTML={{ __html: data }} />\n );\n } else if (!data || typeof data === \"object\") {\n return <div className={className}>Please specify a valid field.</div>;\n } else {\n return <div className={className}> {data} </div>;\n }\n}\n","import registerComponent, {\n CodeComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\nimport {\n WordpressFetcher,\n WordpressFetcherMeta,\n WordpressField,\n WordpressFieldMeta,\n WordpressProvider,\n WordpressProviderMeta,\n} from \"./wordpress\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: CodeComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n\n if (loader) {\n loader.registerGlobalContext(WordpressProvider, WordpressProviderMeta);\n } else {\n registerGlobalContext(WordpressProvider, WordpressProviderMeta);\n }\n\n _registerComponent(WordpressFetcher, WordpressFetcherMeta);\n _registerComponent(WordpressField, WordpressFieldMeta);\n}\n\nexport * from \"./wordpress\";\n"],"names":["ensure","x","Error","modulePath","CredentialsContext","React","createContext","undefined","WordpressProviderMeta","name","displayName","description","importName","importPath","props","graphqlEndpoint","type","defaultValue","WordpressProvider","_ref","Provider","value","children","WordpressFetcherMeta","providesData","defaultStyles","display","gridTemplateColumns","gridRowGap","gridColumnGap","padding","maxWidth","styles","query","lang","endpoint","ctx","_ctx$endpoint","noAutoRepeat","noLayout","WordpressFetcher","_ref2","arr","className","setControlContextData","creds","useContext","cacheKey","JSON","stringify","data","usePlasmicQueryData","_asyncToGenerator","_regeneratorRuntime","mark","_callee","res","wrap","_context","prev","next","abrupt","fetch","method","body","headers","Content-Type","sent","json","stop","Object","values","filter","length","renderedData","flatMap","model","i","Array","isArray","map","item","j","DataProvider","key","repeatedElement","WordpressFieldMeta","path","_ctx$data","WordpressField","_ref4","useSelector","get","mediaType","src","mediaItemUrl","srcSet","slice","dangerouslySetInnerHTML","__html","loader","_registerComponent","Component","defaultMeta","registerComponent","registerGlobalContext"],"mappings":"wgOAWgBA,EAAUC,GACxB,GAAIA,MAAAA,EAEF,MAAM,IAAIC,6CAEV,OAAOD,EAIX,IAAME,EAAa,yCAMbC,EAAqBC,EAAMC,mBAE/BC,GAEWC,EACX,CACEC,KAAM,2BACNC,YAAa,6BACbC,YAAa,6CACbC,WAAY,oBACZC,WAAYV,EACZW,MAAO,CACLC,gBAAiB,CACfC,KAAM,SACNN,YAAa,uBACbC,YAAa,yCACbM,aAAc,iDAKNC,EAAiBC,GAI/B,OACEd,gBAACD,EAAmBgB,UAASC,MAAO,CAAEN,gBAJzBI,EAAfJ,kBACQI,EAARG,cAkBWC,EAAiE,CAC5Ed,KAAM,0BACNC,YAAa,oBACbE,WAAY,mBACZC,WAAYV,EACZqB,cAAc,EACdb,YACE,sFACFc,cAAe,C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AG,IACO,YAAtBV,EAAKU,OAAO,GAAG,GAGb5F,uBAAKsC,UAAWA,EAAWuD,wBAAyB,CAAEC,OAAQjD,KAEtDA,GAAwB,iBAATA,EAGlB7C,uBAAKsC,UAAWA,OAAaO,OAF7B7C,uBAAKsC,UAAWA,8PCnOCyD,GAI1B,IAAMC,EAAqB,SACzBC,EACAC,GAEIH,EACFA,EAAOI,kBAAkBF,EAAWC,GAEpCC,EAAkBF,EAAWC,IAI7BH,EACFA,EAAOK,sBAAsBvF,EAAmBV,GAEhDiG,EAAsBvF,EAAmBV,GAG3C6F,EAAmB7D,EAAkBjB,GACrC8E,EAAmBZ,EAAgBH"}
@@ -435,7 +435,7 @@ function WordpressFetcher(_ref2) {
435
435
  creds: creds
436
436
  });
437
437
  var _usePlasmicQueryData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
438
- var data;
438
+ var res;
439
439
  return _regeneratorRuntime().wrap(function _callee$(_context) {
440
440
  while (1) switch (_context.prev = _context.next) {
441
441
  case 0:
@@ -454,9 +454,9 @@ function WordpressFetcher(_ref2) {
454
454
  }
455
455
  });
456
456
  case 4:
457
- data = _context.sent;
457
+ res = _context.sent;
458
458
  _context.next = 7;
459
- return data.json();
459
+ return res.json();
460
460
  case 7:
461
461
  return _context.abrupt("return", _context.sent);
462
462
  case 8:
@@ -1 +1 @@
1
- {"version":3,"file":"plasmic-wordpress-graphql.esm.js","sources":["../src/wordpress.tsx","../src/index.tsx"],"sourcesContent":["import {\n ComponentMeta,\n DataProvider,\n GlobalContextMeta,\n repeatedElement,\n useSelector,\n} from \"@plasmicapp/host\";\nimport { usePlasmicQueryData } from \"@plasmicapp/query\";\nimport get from \"dlv\";\nimport React, { ReactNode, useContext } from \"react\";\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\nconst modulePath = \"@plasmicpkgs/plasmic-wordpress-graphql\";\n\ninterface WordpressProviderProps {\n graphqlEndpoint: string;\n}\n\nconst CredentialsContext = React.createContext<\n WordpressProviderProps | undefined\n>(undefined);\n\nexport const WordpressProviderMeta: GlobalContextMeta<WordpressProviderProps> = {\n name: \"WordpressGraphQLProvider\",\n displayName: \"Wordpress GraphQL Provider\",\n description: \"The GraphQL API Endpoint of your Wordpress\",\n importName: \"WordpressProvider\",\n importPath: modulePath,\n props: {\n graphqlEndpoint: {\n type: \"string\",\n displayName: \"GraphQL API Endpoint\",\n description: \"GraphQL API Endpoint of your Wordpress\",\n defaultValue: \"https://demo.wpgraphql.com/graphql\",\n },\n },\n};\n\nexport function WordpressProvider({\n graphqlEndpoint,\n children,\n}: React.PropsWithChildren<WordpressProviderProps>) {\n return (\n <CredentialsContext.Provider value={{ graphqlEndpoint }}>\n {children}\n </CredentialsContext.Provider>\n );\n}\n\ninterface WordpressFetcherProps {\n children?: ReactNode;\n className?: string;\n noLayout?: boolean;\n noAutoRepeat?: boolean;\n query?: string;\n setControlContextData?: (data: { endpoint?: string }) => void;\n}\n\nexport const WordpressFetcherMeta: ComponentMeta<WordpressFetcherProps> = {\n name: \"WordpressGraphQLFetcher\",\n displayName: \"Wordpress Fetcher\",\n importName: \"WordpressFetcher\",\n importPath: modulePath,\n providesData: true,\n description:\n \"Fetches Wordpress data and repeats content of children once for every row fetched. \",\n defaultStyles: {\n display: \"grid\",\n gridTemplateColumns: \"1fr 1fr 1fr 1fr\",\n gridRowGap: \"8px\",\n gridColumnGap: \"8px\",\n padding: \"8px\",\n maxWidth: \"100%\",\n },\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n styles: {\n padding: \"8px\",\n },\n children: {\n type: \"component\",\n name: \"WordpressGraphQLField\",\n },\n },\n },\n query: {\n type: \"code\",\n lang: \"graphql\",\n endpoint: (props, ctx) => ctx?.endpoint ?? \"\",\n },\n noAutoRepeat: {\n type: \"boolean\",\n displayName: \"No auto-repeat\",\n description: \"Do not automatically repeat children for every entry.\",\n defaultValue: false,\n },\n noLayout: {\n type: \"boolean\",\n displayName: \"No layout\",\n description:\n \"When set, Wordpress Fetcher 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.\",\n defaultValue: false,\n },\n },\n};\n\nfunction compact(arr: any[]) {\n return arr.filter((x) => !!x);\n}\n\nexport function WordpressFetcher({\n query,\n children,\n className,\n noLayout,\n noAutoRepeat,\n setControlContextData,\n}: WordpressFetcherProps) {\n const creds = ensure(useContext(CredentialsContext));\n const cacheKey = JSON.stringify({\n query,\n creds,\n });\n const { data } = usePlasmicQueryData<any | null>(cacheKey, async () => {\n if (!query) {\n return null;\n }\n const data = await fetch(creds.graphqlEndpoint, {\n method: \"POST\",\n body: JSON.stringify(query),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n return await data.json();\n });\n\n setControlContextData?.({\n endpoint: creds.graphqlEndpoint,\n });\n\n if (!query) {\n return <div>Please make a query in order to fetch data</div>;\n }\n\n if (!creds.graphqlEndpoint) {\n return (\n <div>\n Please specify a valid API Credentials: GraphQL Endpoint of your\n Wordpress project\n </div>\n );\n }\n\n if (!data?.data || compact(Object.values(data?.data)).length === 0) {\n return <div>Data not found</div>;\n }\n\n const renderedData = noAutoRepeat\n ? children\n : Object.values(data?.data).flatMap((model: any, i: number) =>\n (Array.isArray(model) ? model : [model]).map((item: any, j: number) => (\n <DataProvider\n key={JSON.stringify(item)}\n name={\"currentWordpressItem\"}\n data={item}\n >\n {repeatedElement(i === 0 && j === 0, children)}\n </DataProvider>\n ))\n );\n return noLayout ? (\n <> {renderedData} </>\n ) : (\n <div className={className}> {renderedData} </div>\n );\n}\n\ninterface WordpressFieldProps {\n className?: string;\n path?: string;\n setControlContextData?: (data: { data: any }) => void;\n}\nexport const WordpressFieldMeta: ComponentMeta<WordpressFieldProps> = {\n name: \"WordpressGraphQLField\",\n displayName: \"Wordpress Field\",\n importName: \"WordpressField\",\n importPath: modulePath,\n props: {\n path: {\n type: \"dataSelector\",\n data: (props: any, ctx: any) => ctx?.data ?? {},\n displayName: \"Field\",\n description: \"Field to be displayed.\",\n },\n },\n};\nexport function WordpressField({\n className,\n path,\n setControlContextData,\n}: WordpressFieldProps) {\n const item = useSelector(\"currentWordpressItem\");\n\n if (!item) {\n return <div>WordpressField must be used within a WordpressFetcher </div>;\n }\n\n setControlContextData?.({\n data: item,\n });\n\n if (!path) {\n return <div>Please specify a valid path or select a field.</div>;\n }\n const data = get(item, path as string);\n if (typeof data === \"object\" && data.mediaType === \"image\") {\n return (\n <img className={className} src={data.mediaItemUrl} srcSet={data.srcSet} />\n );\n } else if (\n path.slice(-1)[0] === \"content\" ||\n path.slice(-1)[0] === \"excerpt\"\n ) {\n return (\n <div className={className} dangerouslySetInnerHTML={{ __html: data }} />\n );\n } else if (!data || typeof data === \"object\") {\n return <div className={className}>Please specify a valid field.</div>;\n } else {\n return <div className={className}> {data} </div>;\n }\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\nimport {\n WordpressFetcher,\n WordpressFetcherMeta,\n WordpressField,\n WordpressFieldMeta,\n WordpressProvider,\n WordpressProviderMeta,\n} from \"./wordpress\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n\n if (loader) {\n loader.registerGlobalContext(WordpressProvider, WordpressProviderMeta);\n } else {\n registerGlobalContext(WordpressProvider, WordpressProviderMeta);\n }\n\n _registerComponent(WordpressFetcher, WordpressFetcherMeta);\n _registerComponent(WordpressField, WordpressFieldMeta);\n}\n\nexport * from \"./wordpress\";\n"],"names":["ensure","x","undefined","Error","modulePath","CredentialsContext","React","createContext","WordpressProviderMeta","name","displayName","description","importName","importPath","props","graphqlEndpoint","type","defaultValue","WordpressProvider","_ref","children","Provider","value","WordpressFetcherMeta","providesData","defaultStyles","display","gridTemplateColumns","gridRowGap","gridColumnGap","padding","maxWidth","styles","query","lang","endpoint","ctx","_ctx$endpoint","noAutoRepeat","noLayout","compact","arr","filter","WordpressFetcher","_ref2","className","setControlContextData","creds","useContext","cacheKey","JSON","stringify","_usePlasmicQueryData","usePlasmicQueryData","_asyncToGenerator","_regeneratorRuntime","mark","_callee","data","wrap","_callee$","_context","prev","next","abrupt","fetch","method","body","headers","sent","json","stop","Object","values","length","renderedData","flatMap","model","i","Array","isArray","map","item","j","DataProvider","key","repeatedElement","WordpressFieldMeta","path","_ctx$data","WordpressField","_ref4","useSelector","get","mediaType","src","mediaItemUrl","srcSet","slice","dangerouslySetInnerHTML","__html","registerAll","loader","_registerComponent","Component","defaultMeta","registerComponent","registerGlobalContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAWgBA,MAAMA,CAAIC,CAAuB;EAC/C,IAAIA,CAAC,KAAK,IAAI,IAAIA,CAAC,KAAKC,SAAS,EAAE;IACjC;IACA,MAAM,IAAIC,KAAK,sCAAsC,CAAC;GACvD,MAAM;IACL,OAAOF,CAAC;;AAEZ;AAEA,IAAMG,UAAU,GAAG,wCA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AAoB,CAAC;EAC1DgF,kBAAkB,CAACb,cAAc,EAAEH,kBAAkB,CAAC;AACxD;;;;"}
1
+ {"version":3,"file":"plasmic-wordpress-graphql.esm.js","sources":["../src/wordpress.tsx","../src/index.tsx"],"sourcesContent":["import {\n DataProvider,\n GlobalContextMeta,\n repeatedElement,\n useSelector,\n} from \"@plasmicapp/host\";\nimport { CodeComponentMeta } from \"@plasmicapp/host/registerComponent\";\nimport { usePlasmicQueryData } from \"@plasmicapp/query\";\nimport get from \"dlv\";\nimport React, { ReactNode, useContext } from \"react\";\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\nconst modulePath = \"@plasmicpkgs/plasmic-wordpress-graphql\";\n\ninterface WordpressProviderProps {\n graphqlEndpoint: string;\n}\n\nconst CredentialsContext = React.createContext<\n WordpressProviderProps | undefined\n>(undefined);\n\nexport const WordpressProviderMeta: GlobalContextMeta<WordpressProviderProps> =\n {\n name: \"WordpressGraphQLProvider\",\n displayName: \"Wordpress GraphQL Provider\",\n description: \"The GraphQL API Endpoint of your Wordpress\",\n importName: \"WordpressProvider\",\n importPath: modulePath,\n props: {\n graphqlEndpoint: {\n type: \"string\",\n displayName: \"GraphQL API Endpoint\",\n description: \"GraphQL API Endpoint of your Wordpress\",\n defaultValue: \"https://demo.wpgraphql.com/graphql\",\n },\n },\n };\n\nexport function WordpressProvider({\n graphqlEndpoint,\n children,\n}: React.PropsWithChildren<WordpressProviderProps>) {\n return (\n <CredentialsContext.Provider value={{ graphqlEndpoint }}>\n {children}\n </CredentialsContext.Provider>\n );\n}\n\ninterface WordpressFetcherProps {\n children?: ReactNode;\n className?: string;\n noLayout?: boolean;\n noAutoRepeat?: boolean;\n query?: string;\n setControlContextData?: (data: { endpoint?: string }) => void;\n}\n\nexport const WordpressFetcherMeta: CodeComponentMeta<WordpressFetcherProps> = {\n name: \"WordpressGraphQLFetcher\",\n displayName: \"Wordpress Fetcher\",\n importName: \"WordpressFetcher\",\n importPath: modulePath,\n providesData: true,\n description:\n \"Fetches Wordpress data and repeats content of children once for every row fetched. \",\n defaultStyles: {\n display: \"grid\",\n gridTemplateColumns: \"1fr 1fr 1fr 1fr\",\n gridRowGap: \"8px\",\n gridColumnGap: \"8px\",\n padding: \"8px\",\n maxWidth: \"100%\",\n },\n props: {\n children: {\n type: \"slot\",\n defaultValue: {\n type: \"vbox\",\n styles: {\n padding: \"8px\",\n },\n children: {\n type: \"component\",\n name: \"WordpressGraphQLField\",\n },\n },\n },\n query: {\n type: \"code\",\n lang: \"graphql\",\n endpoint: (props, ctx) => ctx?.endpoint ?? \"\",\n },\n noAutoRepeat: {\n type: \"boolean\",\n displayName: \"No auto-repeat\",\n description: \"Do not automatically repeat children for every entry.\",\n defaultValue: false,\n },\n noLayout: {\n type: \"boolean\",\n displayName: \"No layout\",\n description:\n \"When set, Wordpress Fetcher 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.\",\n defaultValue: false,\n },\n },\n};\n\nfunction compact(arr: any[]) {\n return arr.filter((x) => !!x);\n}\n\nexport function WordpressFetcher({\n query,\n children,\n className,\n noLayout,\n noAutoRepeat,\n setControlContextData,\n}: WordpressFetcherProps) {\n const creds = ensure(useContext(CredentialsContext));\n const cacheKey = JSON.stringify({\n query,\n creds,\n });\n const { data } = usePlasmicQueryData<any | null>(cacheKey, async () => {\n if (!query) {\n return null;\n }\n const res = await fetch(creds.graphqlEndpoint, {\n method: \"POST\",\n body: JSON.stringify(query),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n return await res.json();\n });\n\n setControlContextData?.({\n endpoint: creds.graphqlEndpoint,\n });\n\n if (!query) {\n return <div>Please make a query in order to fetch data</div>;\n }\n\n if (!creds.graphqlEndpoint) {\n return (\n <div>\n Please specify a valid API Credentials: GraphQL Endpoint of your\n Wordpress project\n </div>\n );\n }\n\n if (!data?.data || compact(Object.values(data?.data)).length === 0) {\n return <div>Data not found</div>;\n }\n\n const renderedData = noAutoRepeat\n ? children\n : Object.values(data?.data).flatMap((model: any, i: number) =>\n (Array.isArray(model) ? model : [model]).map((item: any, j: number) => (\n <DataProvider\n key={JSON.stringify(item)}\n name={\"currentWordpressItem\"}\n data={item}\n >\n {repeatedElement(i === 0 && j === 0, children)}\n </DataProvider>\n ))\n );\n return noLayout ? (\n <> {renderedData} </>\n ) : (\n <div className={className}> {renderedData} </div>\n );\n}\n\ninterface WordpressFieldProps {\n className?: string;\n path?: string;\n setControlContextData?: (data: { data: any }) => void;\n}\nexport const WordpressFieldMeta: CodeComponentMeta<WordpressFieldProps> = {\n name: \"WordpressGraphQLField\",\n displayName: \"Wordpress Field\",\n importName: \"WordpressField\",\n importPath: modulePath,\n props: {\n path: {\n type: \"dataSelector\",\n data: (props: any, ctx: any) => ctx?.data ?? {},\n displayName: \"Field\",\n description: \"Field to be displayed.\",\n },\n },\n};\nexport function WordpressField({\n className,\n path,\n setControlContextData,\n}: WordpressFieldProps) {\n const item = useSelector(\"currentWordpressItem\");\n\n if (!item) {\n return <div>WordpressField must be used within a WordpressFetcher </div>;\n }\n\n setControlContextData?.({\n data: item,\n });\n\n if (!path) {\n return <div>Please specify a valid path or select a field.</div>;\n }\n const data = get(item, path as string);\n if (typeof data === \"object\" && data.mediaType === \"image\") {\n return (\n <img className={className} src={data.mediaItemUrl} srcSet={data.srcSet} />\n );\n } else if (\n path.slice(-1)[0] === \"content\" ||\n path.slice(-1)[0] === \"excerpt\"\n ) {\n return (\n <div className={className} dangerouslySetInnerHTML={{ __html: data }} />\n );\n } else if (!data || typeof data === \"object\") {\n return <div className={className}>Please specify a valid field.</div>;\n } else {\n return <div className={className}> {data} </div>;\n }\n}\n","import registerComponent, {\n CodeComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\nimport {\n WordpressFetcher,\n WordpressFetcherMeta,\n WordpressField,\n WordpressFieldMeta,\n WordpressProvider,\n WordpressProviderMeta,\n} from \"./wordpress\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: CodeComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n\n if (loader) {\n loader.registerGlobalContext(WordpressProvider, WordpressProviderMeta);\n } else {\n registerGlobalContext(WordpressProvider, WordpressProviderMeta);\n }\n\n _registerComponent(WordpressFetcher, WordpressFetcherMeta);\n _registerComponent(WordpressField, WordpressFieldMeta);\n}\n\nexport * from \"./wordpress\";\n"],"names":["ensure","x","undefined","Error","modulePath","CredentialsContext","React","createContext","WordpressProviderMeta","name","displayName","description","importName","importPath","props","graphqlEndpoint","type","defaultValue","WordpressProvider","_ref","children","Provider","value","WordpressFetcherMeta","providesData","defaultStyles","display","gridTemplateColumns","gridRowGap","gridColumnGap","padding","maxWidth","styles","query","lang","endpoint","ctx","_ctx$endpoint","noAutoRepeat","noLayout","compact","arr","filter","WordpressFetcher","_ref2","className","setControlContextData","creds","useContext","cacheKey","JSON","stringify","_usePlasmicQueryData","usePlasmicQueryData","_asyncToGenerator","_regeneratorRuntime","mark","_callee","res","wrap","_callee$","_context","prev","next","abrupt","fetch","method","body","headers","sent","json","stop","data","Object","values","length","renderedData","flatMap","model","i","Array","isArray","map","item","j","DataProvider","key","repeatedElement","WordpressFieldMeta","path","_ctx$data","WordpressField","_ref4","useSelector","get","mediaType","src","mediaItemUrl","srcSet","slice","dangerouslySetInnerHTML","__html","registerAll","loader","_registerComponent","Component","defaultMeta","registerComponent","registerGlobalContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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2B,IAAI,MAAQ;;AAEpD;;SCvOgB8B,WAAWA,CAACC,MAG3B;EACC,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CACtBC,SAAY,EACZC,WAAuD;IAEvD,IAAIH,MAAM,EAAE;MACVA,MAAM,CAACI,iBAAiB,CAACF,SAAS,EAAEC,WAAW,CAAC;KACjD,MAAM;MACLC,iBAAiB,CAACF,SAAS,EAAEC,WAAW,CAAC;;GAE5C;EAED,IAAIH,MAAM,EAAE;IACVA,MAAM,CAACK,qBAAqB,CAAC1F,iBAAiB,EAAEV,qBAAqB,CAAC;GACvE,MAAM;IACLoG,qBAAqB,CAAC1F,iBAAiB,EAAEV,qBAAqB,CAAC;;EAGjEgG,kBAAkB,CAAC7D,gBAAgB,EAAEpB,oBAAoB,CAAC;EAC1DiF,kBAAkB,CAACb,cAAc,EAAEH,kBAAkB,CAAC;AACxD;;;;"}
@@ -1,4 +1,5 @@
1
- import { ComponentMeta, GlobalContextMeta } from "@plasmicapp/host";
1
+ import { GlobalContextMeta } from "@plasmicapp/host";
2
+ import { CodeComponentMeta } from "@plasmicapp/host/registerComponent";
2
3
  import React, { ReactNode } from "react";
3
4
  export declare function ensure<T>(x: T | null | undefined): T;
4
5
  interface WordpressProviderProps {
@@ -16,7 +17,7 @@ interface WordpressFetcherProps {
16
17
  endpoint?: string;
17
18
  }) => void;
18
19
  }
19
- export declare const WordpressFetcherMeta: ComponentMeta<WordpressFetcherProps>;
20
+ export declare const WordpressFetcherMeta: CodeComponentMeta<WordpressFetcherProps>;
20
21
  export declare function WordpressFetcher({ query, children, className, noLayout, noAutoRepeat, setControlContextData, }: WordpressFetcherProps): React.JSX.Element;
21
22
  interface WordpressFieldProps {
22
23
  className?: string;
@@ -25,6 +26,6 @@ interface WordpressFieldProps {
25
26
  data: any;
26
27
  }) => void;
27
28
  }
28
- export declare const WordpressFieldMeta: ComponentMeta<WordpressFieldProps>;
29
+ export declare const WordpressFieldMeta: CodeComponentMeta<WordpressFieldProps>;
29
30
  export declare function WordpressField({ className, path, setControlContextData, }: WordpressFieldProps): React.JSX.Element;
30
31
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicpkgs/plasmic-wordpress-graphql",
3
- "version": "0.0.151",
3
+ "version": "0.0.153",
4
4
  "description": "Plasmic Wordpress GraphQL components.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  }
35
35
  ],
36
36
  "devDependencies": {
37
- "@plasmicapp/host": "1.0.234",
37
+ "@plasmicapp/host": "1.0.235",
38
38
  "@plasmicapp/query": "0.1.82",
39
39
  "@types/react": "^18.0.27",
40
40
  "@types/react-dom": "^18.0.10",
@@ -48,5 +48,5 @@
48
48
  "@types/dlv": "^1.1.2",
49
49
  "dlv": "^1.1.3"
50
50
  },
51
- "gitHead": "30e1d9c40c46f513d507349568dc16bc5f3e9572"
51
+ "gitHead": "380a91b2e7eac342c9b2ddafdacd84b4a812b795"
52
52
  }