UNPKG

@commercelayer/react-components

Version:
2 lines 897 B
"use client"; "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ParcelsCount=ParcelsCount;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),ShipmentChildrenContext_1=tslib_1.__importDefault(require("../../context/ShipmentChildrenContext")),useCustomContext_1=tslib_1.__importDefault(require("../../utils/hooks/useCustomContext"));function ParcelsCount({children,...p}){const{parcels}=(0,useCustomContext_1.default)({context:ShipmentChildrenContext_1.default,contextComponentName:"ShipmentsContainer",currentComponentName:"ParcelsCount",key:"parcels"}),quantity=parcels?.length??0,childrenProps={...p,quantity,parcels};return children?(0,jsx_runtime_1.jsx)(Parent_1.default,{...childrenProps,children}):(0,jsx_runtime_1.jsx)("span",{...p,children:quantity})}exports.default=ParcelsCount;