@commercelayer/react-components 2.52.1 → 2.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/LineItem.js +1 -1
- package/lib/cjs/components/LineItemImage.d.ts +5 -1
- package/lib/cjs/components/LineItemImage.js +1 -1
- package/lib/esm/components/LineItem.js +1 -1
- package/lib/esm/components/LineItemImage.d.ts +5 -1
- package/lib/esm/components/LineItemImage.js +1 -1
- package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),LineItemContext_1=(0,tslib_1.__importDefault)(require("../context/LineItemContext")),LineItemChildrenContext_1=(0,tslib_1.__importDefault)(require("../context/LineItemChildrenContext")),components_1=(0,tslib_1.__importDefault)(require("../config/components")),ShipmentChildrenContext_1=(0,tslib_1.__importDefault)(require("../context/ShipmentChildrenContext")),lodash_1=require("lodash"),propTypes=components_1.default.LineItem.propTypes,displayName=components_1.default.LineItem.displayName,LineItem=props=>{const{type="skus",children}=props,{lineItems}=(0,react_1.useContext)(LineItemContext_1.default),{lineItems:shipmentLineItems}=(0,react_1.useContext)(ShipmentChildrenContext_1.default),items=(0,lodash_1.isEmpty)(shipmentLineItems)?lineItems:shipmentLineItems,components=items&&items.filter(l=>l.item_type===type).map((lineItem,k)=>{const lineProps={lineItem};return(0,jsx_runtime_1.jsx)(LineItemChildrenContext_1.default.Provider,Object.assign({value:lineProps},{children}),k)});return(0,jsx_runtime_1.jsx)(react_1.Fragment,{children:components},void 0)};LineItem.propTypes=propTypes,LineItem.displayName=displayName,exports.default=LineItem;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),LineItemContext_1=(0,tslib_1.__importDefault)(require("../context/LineItemContext")),LineItemChildrenContext_1=(0,tslib_1.__importDefault)(require("../context/LineItemChildrenContext")),components_1=(0,tslib_1.__importDefault)(require("../config/components")),ShipmentChildrenContext_1=(0,tslib_1.__importDefault)(require("../context/ShipmentChildrenContext")),lodash_1=require("lodash"),propTypes=components_1.default.LineItem.propTypes,displayName=components_1.default.LineItem.displayName,LineItem=props=>{const{type="skus",children}=props,{lineItems}=(0,react_1.useContext)(LineItemContext_1.default),{lineItems:shipmentLineItems}=(0,react_1.useContext)(ShipmentChildrenContext_1.default),items=(0,lodash_1.isEmpty)(shipmentLineItems)?lineItems:shipmentLineItems,components=items&&items.filter(l=>l.item_type===type).map((lineItem,k)=>{if(lineItem.item_type==="bundles"&&k>0)return null;const lineProps={lineItem};return(0,jsx_runtime_1.jsx)(LineItemChildrenContext_1.default.Provider,Object.assign({value:lineProps},{children}),k)});return(0,jsx_runtime_1.jsx)(react_1.Fragment,{children:components},void 0)};LineItem.propTypes=propTypes,LineItem.displayName=displayName,exports.default=LineItem;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FunctionComponent, ReactNode } from 'react';
|
|
2
2
|
import { LineItem } from '@commercelayer/sdk';
|
|
3
|
+
import { LineItemType } from '../typings/index';
|
|
3
4
|
export declare type LineItemImageType = Omit<LineItemImageProps, 'children'> & {
|
|
4
5
|
src: string;
|
|
5
6
|
lineItem: LineItem;
|
|
@@ -7,6 +8,9 @@ export declare type LineItemImageType = Omit<LineItemImageProps, 'children'> & {
|
|
|
7
8
|
declare type LineItemImageProps = {
|
|
8
9
|
children?: (props: LineItemImageType) => ReactNode;
|
|
9
10
|
width?: number;
|
|
10
|
-
|
|
11
|
+
placeholder?: {
|
|
12
|
+
[K in LineItemType]?: string;
|
|
13
|
+
};
|
|
14
|
+
} & Omit<JSX.IntrinsicElements['img'], 'src' | 'srcSet' | 'placeholder'>;
|
|
11
15
|
declare const LineItemImage: FunctionComponent<LineItemImageProps>;
|
|
12
16
|
export default LineItemImage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=(0,tslib_1.__importDefault)(require("./utils/Parent")),LineItemChildrenContext_1=(0,tslib_1.__importDefault)(require("../context/LineItemChildrenContext")),components_1=(0,tslib_1.__importDefault)(require("../config/components")),propTypes=components_1.default.LineItemImage.propTypes,displayName=components_1.default.LineItemImage.displayName,LineItemImage=props=>{const{lineItem}=(0,react_1.useContext)(LineItemChildrenContext_1.default),src=lineItem==null?void 0:lineItem.image_url
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=(0,tslib_1.__importDefault)(require("./utils/Parent")),LineItemChildrenContext_1=(0,tslib_1.__importDefault)(require("../context/LineItemChildrenContext")),components_1=(0,tslib_1.__importDefault)(require("../config/components")),defaultImgUrl="https://data.commercelayer.app/assets/images/placeholders/img_placeholder.svg",defaultGiftCardImgUrl="https://data.commercelayer.app/assets/images/placeholders/gift_placeholder.svg",propTypes=components_1.default.LineItemImage.propTypes,displayName=components_1.default.LineItemImage.displayName,LineItemImage=props=>{const{placeholder,children}=props,p=(0,tslib_1.__rest)(props,["placeholder","children"]),{lineItem}=(0,react_1.useContext)(LineItemChildrenContext_1.default),itemType=lineItem==null?void 0:lineItem.item_type;let src=lineItem==null?void 0:lineItem.image_url;src||((placeholder==null?void 0:placeholder[itemType])?src=placeholder==null?void 0:placeholder[itemType]:src=itemType==="gift_cards"?defaultGiftCardImgUrl:defaultImgUrl);const parenProps=Object.assign({lineItem,src,placeholder},p);return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parenProps,{children}),void 0):src?(0,jsx_runtime_1.jsx)("img",Object.assign({alt:"",src},p),void 0):null};LineItemImage.propTypes=propTypes,LineItemImage.displayName=displayName,exports.default=LineItemImage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useContext}from"react";import LineItemContext from"../context/LineItemContext";import LineItemChildrenContext from"../context/LineItemChildrenContext";import components from"../config/components";import ShipmentChildrenContext from"../context/ShipmentChildrenContext";import{isEmpty}from"lodash";const propTypes=components.LineItem.propTypes,displayName=components.LineItem.displayName,LineItem=props=>{const{type="skus",children}=props,{lineItems}=useContext(LineItemContext),{lineItems:shipmentLineItems}=useContext(ShipmentChildrenContext),items=isEmpty(shipmentLineItems)?lineItems:shipmentLineItems,components2=items&&items.filter(l=>l.item_type===type).map((lineItem,k)=>{const lineProps={lineItem};return _jsx(LineItemChildrenContext.Provider,Object.assign({value:lineProps},{children}),k)});return _jsx(Fragment,{children:components2},void 0)};LineItem.propTypes=propTypes,LineItem.displayName=displayName;export default LineItem;
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useContext}from"react";import LineItemContext from"../context/LineItemContext";import LineItemChildrenContext from"../context/LineItemChildrenContext";import components from"../config/components";import ShipmentChildrenContext from"../context/ShipmentChildrenContext";import{isEmpty}from"lodash";const propTypes=components.LineItem.propTypes,displayName=components.LineItem.displayName,LineItem=props=>{const{type="skus",children}=props,{lineItems}=useContext(LineItemContext),{lineItems:shipmentLineItems}=useContext(ShipmentChildrenContext),items=isEmpty(shipmentLineItems)?lineItems:shipmentLineItems,components2=items&&items.filter(l=>l.item_type===type).map((lineItem,k)=>{if(lineItem.item_type==="bundles"&&k>0)return null;const lineProps={lineItem};return _jsx(LineItemChildrenContext.Provider,Object.assign({value:lineProps},{children}),k)});return _jsx(Fragment,{children:components2},void 0)};LineItem.propTypes=propTypes,LineItem.displayName=displayName;export default LineItem;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FunctionComponent, ReactNode } from 'react';
|
|
2
2
|
import { LineItem } from '@commercelayer/sdk';
|
|
3
|
+
import { LineItemType } from '../typings/index';
|
|
3
4
|
export declare type LineItemImageType = Omit<LineItemImageProps, 'children'> & {
|
|
4
5
|
src: string;
|
|
5
6
|
lineItem: LineItem;
|
|
@@ -7,6 +8,9 @@ export declare type LineItemImageType = Omit<LineItemImageProps, 'children'> & {
|
|
|
7
8
|
declare type LineItemImageProps = {
|
|
8
9
|
children?: (props: LineItemImageType) => ReactNode;
|
|
9
10
|
width?: number;
|
|
10
|
-
|
|
11
|
+
placeholder?: {
|
|
12
|
+
[K in LineItemType]?: string;
|
|
13
|
+
};
|
|
14
|
+
} & Omit<JSX.IntrinsicElements['img'], 'src' | 'srcSet' | 'placeholder'>;
|
|
11
15
|
declare const LineItemImage: FunctionComponent<LineItemImageProps>;
|
|
12
16
|
export default LineItemImage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"./utils/Parent";import LineItemChildrenContext from"../context/LineItemChildrenContext";import components from"../config/components";const propTypes=components.LineItemImage.propTypes,displayName=components.LineItemImage.displayName,LineItemImage=props=>{const{lineItem}=useContext(LineItemChildrenContext),src=lineItem==null?void 0:lineItem.image_url
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"./utils/Parent";import LineItemChildrenContext from"../context/LineItemChildrenContext";import components from"../config/components";const defaultImgUrl="https://data.commercelayer.app/assets/images/placeholders/img_placeholder.svg",defaultGiftCardImgUrl="https://data.commercelayer.app/assets/images/placeholders/gift_placeholder.svg",propTypes=components.LineItemImage.propTypes,displayName=components.LineItemImage.displayName,LineItemImage=props=>{const{placeholder,children}=props,p=__rest(props,["placeholder","children"]),{lineItem}=useContext(LineItemChildrenContext),itemType=lineItem==null?void 0:lineItem.item_type;let src=lineItem==null?void 0:lineItem.image_url;src||((placeholder==null?void 0:placeholder[itemType])?src=placeholder==null?void 0:placeholder[itemType]:src=itemType==="gift_cards"?defaultGiftCardImgUrl:defaultImgUrl);const parenProps=Object.assign({lineItem,src,placeholder},p);return children?_jsx(Parent,Object.assign({},parenProps,{children}),void 0):src?_jsx("img",Object.assign({alt:"",src},p),void 0):null};LineItemImage.propTypes=propTypes,LineItemImage.displayName=displayName;export default LineItemImage;
|