@commercelayer/react-components 4.0.0-beta.2 → 4.0.0-beta.3

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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),Parent_1=tslib_1.__importDefault(require("./Parent")),react_1=require("react"),placeholderImages_1=require("../../utils/placeholderImages");function GenericFieldComponent(props){const{children,tagElement,attribute,context,...p}=props,resourceContext=(0,react_1.useContext)(context);let attributeValue="";const keysContext=Object.keys(resourceContext).filter(key=>key===p.resource);if(console.log("keys",Object.keys(resourceContext)),console.log("p.resource",p.resource),console.log("keyContext",keysContext),keysContext.length===1){const[keyResource]=keysContext;keyResource&&attribute&&(attributeValue=resourceContext[keyResource][attribute])}const Tag=tagElement||"span";if(Tag==="img"&&!children){const src=attributeValue||placeholderImages_1.defaultImgUrl,name="";return(0,jsx_runtime_1.jsx)("img",{alt:name,src,...p})}const parentProps={attributeValue,tagElement,...p};return children?(0,jsx_runtime_1.jsx)(Parent_1.default,{...parentProps,children}):(0,jsx_runtime_1.jsx)(Tag,{...p,children:attributeValue})}exports.default=GenericFieldComponent;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),Parent_1=tslib_1.__importDefault(require("./Parent")),react_1=require("react"),placeholderImages_1=require("../../utils/placeholderImages");function GenericFieldComponent(props){const{children,tagElement,attribute,context,...p}=props,resourceContext=(0,react_1.useContext)(context);let attributeValue="";const keysContext=Object.keys(resourceContext).filter(key=>key===p.resource);if(keysContext.length===1){const[keyResource]=keysContext;keyResource&&attribute&&(attributeValue=resourceContext[keyResource][attribute])}const Tag=tagElement||"span";if(Tag==="img"&&!children){const src=attributeValue||placeholderImages_1.defaultImgUrl,name="";return(0,jsx_runtime_1.jsx)("img",{alt:name,src,...p})}const parentProps={attributeValue,tagElement,...p};return children?(0,jsx_runtime_1.jsx)(Parent_1.default,{...parentProps,children}):(0,jsx_runtime_1.jsx)(Tag,{...p,children:attributeValue})}exports.default=GenericFieldComponent;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import Parent from"./Parent";import{useContext}from"react";import{defaultImgUrl}from"../../utils/placeholderImages";export default function GenericFieldComponent(props){const{children,tagElement,attribute,context,...p}=props,resourceContext=useContext(context);let attributeValue="";const keysContext=Object.keys(resourceContext).filter(key=>key===p.resource);if(console.log("keys",Object.keys(resourceContext)),console.log("p.resource",p.resource),console.log("keyContext",keysContext),keysContext.length===1){const[keyResource]=keysContext;keyResource&&attribute&&(attributeValue=resourceContext[keyResource][attribute])}const Tag=tagElement||"span";if(Tag==="img"&&!children)return _jsx("img",{alt:"",src:attributeValue||defaultImgUrl,...p});const parentProps={attributeValue,tagElement,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx(Tag,{...p,children:attributeValue})}
1
+ import{jsx as _jsx}from"react/jsx-runtime";import Parent from"./Parent";import{useContext}from"react";import{defaultImgUrl}from"../../utils/placeholderImages";export default function GenericFieldComponent(props){const{children,tagElement,attribute,context,...p}=props,resourceContext=useContext(context);let attributeValue="";const keysContext=Object.keys(resourceContext).filter(key=>key===p.resource);if(keysContext.length===1){const[keyResource]=keysContext;keyResource&&attribute&&(attributeValue=resourceContext[keyResource][attribute])}const Tag=tagElement||"span";if(Tag==="img"&&!children)return _jsx("img",{alt:"",src:attributeValue||defaultImgUrl,...p});const parentProps={attributeValue,tagElement,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx(Tag,{...p,children:attributeValue})}