@dropins/storefront-cart 1.6.0-alpha6 → 3.0.0-alpha002
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/LICENSE.md +25 -25
- package/chunks/CartSummaryList.js +1 -1
- package/chunks/CartSummaryList.js.map +1 -1
- package/chunks/ChevronDown.js +1 -1
- package/chunks/ChevronDown.js.map +1 -1
- package/chunks/ChevronUp.js +1 -1
- package/chunks/ChevronUp.js.map +1 -1
- package/chunks/Coupons.js +1 -1
- package/chunks/Coupons.js.map +1 -1
- package/chunks/GiftCard.js +1 -1
- package/chunks/GiftCard.js.map +1 -1
- package/chunks/OrderSummary.js +1 -1
- package/chunks/OrderSummary.js.map +1 -1
- package/chunks/WarningWithCircle.js +1 -1
- package/chunks/WarningWithCircle.js.map +1 -1
- package/chunks/refreshCart.js +7 -7
- package/chunks/refreshCart.js.map +1 -1
- package/containers/GiftOptions.js +1 -1
- package/containers/GiftOptions.js.map +1 -1
- package/containers/MiniCart.js +1 -1
- package/containers/MiniCart.js.map +1 -1
- package/lib/decodeHTMLEntities.d.ts +25 -0
- package/package.json +1 -1
- package/render.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GiftOptions.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/CheckWithCircle.svg","../../node_modules/@adobe-commerce/elsie/src/icons/Gift.svg","/@dropins/storefront-cart/src/hooks/useFocusTrap.tsx","/@dropins/storefront-cart/src/components/GiftOptions/Elements/GiftOptionModal.tsx","/@dropins/storefront-cart/src/components/GiftOptions/Elements/GiftLoader.tsx","/@dropins/storefront-cart/src/components/GiftOptions/Elements/CheckboxGroup.tsx","/@dropins/storefront-cart/src/components/GiftOptions/Elements/FormFields.tsx","/@dropins/storefront-cart/src/components/GiftOptions/Elements/ReadOnlyFormView.tsx","/@dropins/storefront-cart/src/components/GiftOptions/GiftOptions.tsx","/@dropins/storefront-cart/src/lib/giftOptionsHelper.ts","/@dropins/storefront-cart/src/hooks/useGiftOptions.tsx","/@dropins/storefront-cart/src/containers/GiftOptions/GiftOptions.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgCheckWithCircle = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z\", stroke: \"currentColor\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M6.75 12.762L10.2385 15.75L17.25 9\", stroke: \"currentColor\" }));\nexport default SvgCheckWithCircle;\n","import * as React from \"react\";\nconst SvgGift = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 20, height: 23, viewBox: \"0 0 20 23\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { d: \"M10 6L10 21.5M10 6H12.25C13.4926 6 14.5 4.99264 14.5 3.75C14.5 2.50736 13.4926 1.5 12.25 1.5C11.0074 1.5 10 2.50736 10 3.75M10 6V3.75M10 6H7.75C6.50736 6 5.5 4.99264 5.5 3.75C5.5 2.50736 6.50736 1.5 7.75 1.5C8.99264 1.5 10 2.50736 10 3.75M3.25 10.75H16.75C17.9926 10.75 19 9.74264 19 8.5C19 7.25736 17.9926 6.25 16.75 6.25H3.25C2.00736 6.25 1 7.25736 1 8.5C1 9.74264 2.00736 10.75 3.25 10.75ZM4.75 21.5H15.25C16.4926 21.5 17.5 20.4926 17.5 19.25V13.25C17.5 12.0074 16.4926 11 15.25 11H4.75C3.50736 11 2.5 12.0074 2.5 13.25V19.25C2.5 20.4926 3.50736 21.5 4.75 21.5Z\", stroke: \"currentColor\", strokeWidth: 1.5 }));\nexport default SvgGift;\n","import { useEffect, useRef } from 'preact/hooks';\n\nexport function useFocusTrap(showModal: boolean) {\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (!showModal || !containerRef.current) return;\n\n const container = containerRef.current;\n\n const focusableElements = container.querySelectorAll<HTMLElement>(\n 'a, button, input, textarea, select, details, [tabindex]:not([tabindex=\"-1\"])'\n );\n\n if (focusableElements.length === 0) return;\n\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n function handleKeyDown(event: KeyboardEvent) {\n if (event.key === 'Tab') {\n if (event.shiftKey && document.activeElement === firstElement) {\n event.preventDefault();\n lastElement.focus();\n } else if (!event.shiftKey && document.activeElement === lastElement) {\n event.preventDefault();\n firstElement.focus();\n }\n }\n }\n\n container.addEventListener('keydown', handleKeyDown);\n\n return () => {\n container.removeEventListener('keydown', handleKeyDown);\n };\n }, [showModal]);\n\n return containerRef;\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent, JSX, VNode } from 'preact';\nimport {\n Modal,\n Button,\n ImageSwatch,\n Price,\n ContentGrid,\n ImageNodeRenderProps,\n} from '@adobe-commerce/elsie/components';\nimport { useState, useEffect } from 'preact/hooks';\nimport { GiftWrappingConfigProps, GiftOptionsViewProps } from '@/cart/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { useFocusTrap } from '@/cart/hooks/useFocusTrap';\n\ninterface GiftOptionModalProps {\n giftWrappingConfig: GiftWrappingConfigProps[];\n showModal: boolean;\n productName: string;\n view: GiftOptionsViewProps;\n imageSwatchImageNode?: VNode | ((props: ImageNodeRenderProps) => JSX.Element);\n setShowModal: () => void;\n updateGiftOptions: (\n name: string,\n value?: string | boolean | number,\n extraGiftOptions?: Record<string, string | boolean | number>\n ) => void;\n}\n\nexport const GiftOptionModal: FunctionComponent<GiftOptionModalProps> = ({\n view,\n showModal,\n productName,\n giftWrappingConfig,\n imageSwatchImageNode,\n setShowModal,\n updateGiftOptions,\n}) => {\n const containerRef = useFocusTrap(showModal);\n\n const dictionary = useText({\n modalTitle: 'Cart.GiftOptions.modal.title',\n defaultTitle: 'Cart.GiftOptions.modal.defaultTitle',\n modalWrappingText: 'Cart.GiftOptions.modal.wrappingText',\n modalWrappingSubText: 'Cart.GiftOptions.modal.wrappingSubText',\n modalConfirmButton: 'Cart.GiftOptions.modal.modalConfirmButton',\n modalCancelButton: 'Cart.GiftOptions.modal.modalCancelButton',\n ariaLabelModal: 'Cart.GiftOptions.modal.ariaLabelModal',\n ariaLabelModalOpen: 'Cart.GiftOptions.modal.ariaLabelModalOpen',\n ariaLabelModalClose: 'Cart.GiftOptions.modal.ariaLabelModalClose',\n ariaLabelWrapping: 'Cart.GiftOptions.modal.ariaLabelWrapping',\n });\n\n const [giftWrappingItem, setGiftWrappingItem] =\n useState<GiftWrappingConfigProps>();\n\n useEffect(() => {\n const selectedGiftWrapping =\n giftWrappingConfig.find((item) => item.selected) ?? giftWrappingConfig[0];\n\n setGiftWrappingItem(selectedGiftWrapping);\n }, [giftWrappingConfig]);\n\n useEffect(() => {\n const focusElement = document?.querySelector(\n '.cart-gift-options-view__modal-wrapper'\n ) as HTMLElement;\n\n if (focusElement) focusElement?.focus();\n }, []);\n\n if (!showModal || !giftWrappingConfig.length) return null;\n\n const renderTitle = productName\n ? `${dictionary.modalTitle} ${productName}`\n : dictionary.defaultTitle;\n\n return (\n <div\n ref={containerRef}\n className=\"cart-gift-options-view__modal-wrapper\"\n tabIndex={0}\n aria-label={`${dictionary.ariaLabelModal} ${\n showModal\n ? dictionary.ariaLabelModalOpen\n : dictionary.ariaLabelModalClose\n } ${productName}`}\n >\n <Modal\n data-testid={`gift-option-modal-${view}`}\n className={'cart-gift-options-view__modal'}\n size={'medium'}\n title={\n <>\n <span>{renderTitle}</span>\n {giftWrappingItem && giftWrappingItem?.price?.value > 0 ? (\n <Price\n amount={giftWrappingItem.price.value}\n currency={giftWrappingItem.price.currency}\n weight=\"normal\"\n />\n ) : null}\n </>\n }\n centered={true}\n onClose={setShowModal}\n >\n <div className=\"cart-gift-options-view__modal-content\">\n <span className=\"cart-gift-options-view__modal-text\">\n {dictionary.modalWrappingText}\n </span>\n <ContentGrid\n emptyGridContent={<></>}\n maxColumns={6}\n columnWidth=\"100px\"\n className=\"cart-gift-options-view__modal-grid\"\n >\n {giftWrappingConfig.map((wrapItem) => (\n <ImageSwatch\n groupAriaLabel={dictionary.ariaLabelWrapping}\n selected={giftWrappingItem?.uid === wrapItem?.uid}\n onValue={() => {\n setGiftWrappingItem(wrapItem);\n }}\n imageNode={imageSwatchImageNode}\n name={'giftWrappingId'}\n value={wrapItem.uid}\n src={wrapItem.image.url}\n alt={wrapItem.design}\n label={wrapItem.design}\n key={wrapItem.uid}\n data-testid={`gift-option-modal-image-${wrapItem.uid}`}\n className={'cart-gift-options-view__modal-grid-item'}\n />\n ))}\n </ContentGrid>\n <span className=\"cart-gift-options-view__modal-sub-text\">\n {giftWrappingItem?.design}\n </span>\n </div>\n\n <Button\n data-testid=\"gift-option-modal-confirm-button\"\n type=\"button\"\n onClick={() => {\n updateGiftOptions('giftWrappingId', giftWrappingItem?.uid, {\n isGiftWrappingSelected: true,\n });\n setShowModal();\n }}\n >\n {dictionary.modalConfirmButton}\n </Button>\n <Button\n type=\"button\"\n variant=\"secondary\"\n onClick={setShowModal}\n data-testid=\"gift-option-modal-cancel-button\"\n >\n {dictionary.modalCancelButton}\n </Button>\n </Modal>\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\n\nexport const GiftLoader: FunctionComponent = () => {\n return (\n <Skeleton>\n <SkeletonRow\n variant=\"row\"\n size=\"small\"\n fullWidth={true}\n lines={1}\n multilineGap=\"small\"\n />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Checkbox, Field, Button, Price } from '@adobe-commerce/elsie/components';\nimport {\n GiftOptionsViewProps,\n GiftWrappingConfigProps,\n GiftFormDataType,\n ProductGiftOptionsConfig,\n} from '@/cart/types';\nimport { CartModel, Item, Price as PriceType } from '@/cart/data/models';\nimport { state } from '@/cart/lib/state';\nimport { StateUpdater, Dispatch, useId } from 'preact/hooks';\n\ninterface CheckboxGroupProps {\n className: string;\n view: GiftOptionsViewProps;\n item: Item | ProductGiftOptionsConfig;\n giftOptions: GiftFormDataType;\n disabled: boolean;\n cartData: CartModel | null;\n giftWrappingConfig: GiftWrappingConfigProps[] | [];\n areGiftOptionsVisible: Record<string, boolean>;\n setShowModal: Dispatch<StateUpdater<boolean>>;\n onInputChange: (event: Event) => void;\n}\n\nexport const CheckboxGroup: FunctionComponent<CheckboxGroupProps> = ({\n className,\n view,\n item,\n giftOptions,\n disabled,\n cartData,\n giftWrappingConfig,\n setShowModal,\n onInputChange,\n areGiftOptionsVisible,\n}) => {\n const id = useId();\n const dictionary = useText({\n customize: `Cart.GiftOptions.${view}.customize`,\n giftReceiptIncludedTitle: `Cart.GiftOptions.${view}.giftReceiptIncluded.title`,\n giftReceiptIncludedText: `Cart.GiftOptions.${view}.giftReceiptIncluded.subtitle`,\n printedCardIncludedTitle: `Cart.GiftOptions.${view}.printedCardIncluded.title`,\n printedCardIncludedText: `Cart.GiftOptions.${view}.printedCardIncluded.subtitle`,\n giftOptionsWrapTitle: `Cart.GiftOptions.${view}.giftOptionsWrap.title`,\n giftOptionsWrapText: `Cart.GiftOptions.${view}.giftOptionsWrap.subtitle`,\n requiredFieldError: 'Cart.GiftOptions.formText.requiredFieldError',\n });\n\n const productGiftWrappingOptions = item?.productGiftWrapping;\n const orderGiftWrappingOptions = cartData?.cartGiftWrapping;\n const giftWrappingOptions =\n view === 'product' ? productGiftWrappingOptions : orderGiftWrappingOptions;\n\n const selectedGiftWrapping = giftWrappingOptions?.find(\n (el: GiftWrappingConfigProps) => el.uid === giftOptions.giftWrappingId\n );\n const selectedGiftWrappingLabel = selectedGiftWrapping?.design ?? '';\n\n // Product level configurations\n const productGiftWrappingPrice = item?.giftWrappingPrice;\n const renderSelectedGiftWrappingLabel = selectedGiftWrappingLabel\n ? `${dictionary.giftOptionsWrapText} ${selectedGiftWrappingLabel}`\n : '';\n\n const printedCardPrice =\n +(state.config?.printedCardPrice?.value ?? 0) > 0\n ? state.config?.printedCardPrice\n : null;\n\n let productWrappingPrice = null;\n\n // Product level configurations have higher priority\n if (productGiftWrappingPrice?.value) {\n productWrappingPrice = productGiftWrappingPrice;\n } else if (selectedGiftWrapping?.price?.value) {\n productWrappingPrice = selectedGiftWrapping.price;\n }\n\n const renderPrice = (price?: PriceType | null) => {\n if (!price) return null;\n\n return (\n <span>\n (+\n <Price amount={price.value} currency={price.currency} weight=\"normal\" />\n )\n </span>\n );\n };\n\n return (\n <div\n className={classes([\n className,\n [`${className}--hidden`, !areGiftOptionsVisible.isGiftOptionsVisible],\n ])}\n >\n {areGiftOptionsVisible.isGiftReceiptVisible ? (\n <Field\n disabled={disabled}\n className={'cart-gift-options-view__field-gift-receipt'}\n >\n <Checkbox\n id={`giftReceiptIncluded-${id}`}\n disabled={disabled}\n name={'giftReceiptIncluded'}\n checked={giftOptions.giftReceiptIncluded}\n placeholder={dictionary.giftReceiptIncludedTitle}\n label={dictionary.giftReceiptIncludedTitle}\n description={dictionary.giftReceiptIncludedText}\n onChange={onInputChange}\n />\n </Field>\n ) : null}\n {areGiftOptionsVisible.isPrintedCartVisible ? (\n <Field\n disabled={disabled}\n className={'cart-gift-options-view__field-printed-card'}\n >\n <Checkbox\n id={`printedCardIncluded-${id}`}\n disabled={disabled}\n name={'printedCardIncluded'}\n checked={giftOptions.printedCardIncluded}\n placeholder={dictionary.printedCardIncludedTitle}\n label={\n <>\n {dictionary.printedCardIncludedTitle}\n {renderPrice(printedCardPrice)}\n </>\n }\n description={dictionary.printedCardIncludedText}\n onChange={onInputChange}\n />\n </Field>\n ) : null}\n {areGiftOptionsVisible.isGiftWrappingVisible ? (\n <>\n <Field\n disabled={disabled}\n className={'cart-gift-options-view__field-gift-wrap'}\n >\n <Checkbox\n id={`giftOptionsWrap-${id}`}\n disabled={disabled}\n name={'isGiftWrappingSelected'}\n checked={giftOptions.isGiftWrappingSelected}\n placeholder={dictionary.giftOptionsWrapTitle}\n label={\n <>\n {dictionary.giftOptionsWrapTitle}\n {renderPrice(productWrappingPrice)}\n </>\n }\n description={renderSelectedGiftWrappingLabel}\n onChange={onInputChange}\n />\n </Field>\n\n <Button\n disabled={disabled || !giftWrappingConfig.length}\n type=\"button\"\n data-testid={`gift-option-customize-${view}`}\n variant=\"tertiary\"\n onClick={() => setShowModal(true)}\n >\n {dictionary.customize}\n </Button>\n </>\n ) : null}\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Field, Input, TextArea } from '@adobe-commerce/elsie/components';\nimport { GiftOptionsViewProps, GiftFormDataType } from '@/cart/types';\nimport { useId } from 'preact/hooks';\n\ninterface FormFieldsProps {\n view: GiftOptionsViewProps;\n giftOptions: GiftFormDataType;\n disabled: boolean;\n errorMessage: Record<string, string>;\n onInputChange: (value: Event) => void;\n onBlur: (event: Event) => void;\n isGiftMessageVisible: boolean;\n}\n\nexport const FormFields: FunctionComponent<FormFieldsProps> = ({\n view,\n giftOptions,\n disabled,\n errorMessage,\n onInputChange,\n onBlur,\n isGiftMessageVisible,\n}) => {\n const id = useId();\n const dictionary = useText({\n formTitle: `Cart.GiftOptions.${view}.formContent.formTitle`,\n formTo: `Cart.GiftOptions.${view}.formContent.formTo`,\n formFrom: `Cart.GiftOptions.${view}.formContent.formFrom`,\n giftMessageTitle: `Cart.GiftOptions.${view}.formContent.giftMessageTitle`,\n formToPlaceholder: `Cart.GiftOptions.${view}.formContent.formToPlaceholder`,\n formFromPlaceholder: `Cart.GiftOptions.${view}.formContent.formFromPlaceholder`,\n formMessagePlaceholder: `Cart.GiftOptions.${view}.formContent.formMessagePlaceholder`,\n });\n\n if (!isGiftMessageVisible) return null;\n\n return (\n <>\n <span>{dictionary.formTitle}</span>\n <div>\n <span>{dictionary.formTo}</span>\n <Field disabled={disabled} error={errorMessage.recipientName}>\n <Input\n id={`recipientName-${id}`}\n disabled={disabled}\n type=\"text\"\n name={'recipientName'}\n value={giftOptions.recipientName}\n placeholder={dictionary.formToPlaceholder}\n onChange={onInputChange}\n onBlur={onBlur}\n />\n </Field>\n </div>\n <div>\n <span>{dictionary.formFrom}</span>\n <Field disabled={disabled} error={errorMessage.senderName}>\n <Input\n id={`senderName-${id}`}\n disabled={disabled}\n type=\"text\"\n name={'senderName'}\n value={giftOptions.senderName}\n placeholder={dictionary.formFromPlaceholder}\n onChange={onInputChange}\n onBlur={onBlur}\n />\n </Field>\n </div>\n <div>\n <span>{dictionary.giftMessageTitle}</span>\n <Field disabled={disabled}>\n <TextArea\n id={`message-${id}`}\n errorMessage={errorMessage.message}\n disabled={disabled}\n name={'message'}\n value={giftOptions.message}\n label={dictionary.formMessagePlaceholder}\n onChange={onInputChange}\n onBlur={onBlur}\n />\n </Field>\n </div>\n </>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport {\n Price,\n Icon,\n Card,\n Accordion,\n AccordionSection,\n} from '@adobe-commerce/elsie/components';\nimport {\n ChevronDown,\n ChevronUp,\n Gift,\n CheckWithCircle,\n} from '@adobe-commerce/elsie/icons';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport {\n GiftFormDataType,\n GiftWrappingConfigProps,\n GiftOptionsReadOnlyViewProps,\n GiftOptionsViewProps,\n} from '@/cart/types';\n\nexport interface ReadOnlyFormViewProps {\n view: GiftOptionsViewProps;\n giftOptions: GiftFormDataType;\n readOnlyFormOrderView: GiftOptionsReadOnlyViewProps;\n giftWrappingConfig: GiftWrappingConfigProps[] | [];\n}\n\nexport const ReadOnlyFormView: FunctionComponent<ReadOnlyFormViewProps> = ({\n view,\n giftOptions,\n giftWrappingConfig,\n readOnlyFormOrderView,\n}) => {\n const dictionary = useText({\n readOnlyProductTitle: 'Cart.GiftOptions.product.readOnlyFormView.title',\n wrapping: 'Cart.GiftOptions.product.readOnlyFormView.wrapping',\n recipient: 'Cart.GiftOptions.product.readOnlyFormView.recipient',\n sender: 'Cart.GiftOptions.product.readOnlyFormView.sender',\n message: 'Cart.GiftOptions.product.readOnlyFormView.message',\n\n readOnlyOrderTitle: 'Cart.GiftOptions.order.readOnlyFormView.title',\n readOnlyOrderGiftReceiptTitle:\n 'Cart.GiftOptions.order.readOnlyFormView.giftReceipt',\n readOnlyOrderGiftReceiptText:\n 'Cart.GiftOptions.order.readOnlyFormView.giftReceiptText',\n readOnlyOrderGiftPrintCardTitle:\n 'Cart.GiftOptions.order.readOnlyFormView.printCard',\n readOnlyOrderGiftPrintCardText:\n 'Cart.GiftOptions.order.readOnlyFormView.printCardText',\n readOnlyOrderGiftWrapTitle:\n 'Cart.GiftOptions.order.readOnlyFormView.giftWrap',\n readOnlyOrderGiftWrapOptionsText:\n 'Cart.GiftOptions.order.readOnlyFormView.giftWrapOptions',\n\n readOnlyOrderFormTitle: 'Cart.GiftOptions.order.readOnlyFormView.formTitle',\n readOnlyOrderFormTo: 'Cart.GiftOptions.order.readOnlyFormView.formTo',\n readOnlyOrderFormFrom: 'Cart.GiftOptions.order.readOnlyFormView.formFrom',\n readOnlyOrderFormMessageTitle:\n 'Cart.GiftOptions.order.readOnlyFormView.formMessageTitle',\n });\n\n const {\n recipientName,\n senderName,\n message,\n giftReceiptIncluded,\n printedCardIncluded,\n isGiftWrappingSelected,\n } = giftOptions;\n\n const giftWrapCart = giftWrappingConfig?.find(\n ({ uid }) => uid === giftOptions?.giftWrappingId\n );\n const isGiftMessageProvided = !!recipientName || !!senderName || !!message;\n const giftWrapProductSelectLabel = giftWrapCart?.design;\n const shouldRenderGiftOptions =\n giftReceiptIncluded || printedCardIncluded || giftWrapCart?.selected;\n\n const productGiftOptionsConfig = [\n {\n id: 1,\n title: dictionary.wrapping,\n message: isGiftWrappingSelected ? giftWrapProductSelectLabel : '',\n },\n {\n id: 2,\n title: dictionary.recipient,\n message: recipientName,\n },\n {\n id: 3,\n title: dictionary.sender,\n message: senderName,\n },\n {\n id: 4,\n title: dictionary.message,\n message,\n },\n ];\n\n const noProductGiftOptionsApplied = productGiftOptionsConfig.every(\n ({ message }) => !message\n );\n\n if (view === 'product' && !noProductGiftOptionsApplied) {\n return (\n <Accordion\n data-testid=\"gift-options-product\"\n iconClose={ChevronUp}\n iconOpen={ChevronDown}\n actionIconPosition=\"right\"\n >\n <AccordionSection\n title={dictionary.readOnlyProductTitle}\n showIconLeft={true}\n iconLeft={Gift}\n defaultOpen={false}\n renderContentWhenClosed={false}\n >\n <div>\n {productGiftOptionsConfig\n .filter((element) => element.message)\n .map((config) => {\n return (\n <p key={config.id}>\n {config.title} {config.message}\n </p>\n );\n })}\n </div>\n </AccordionSection>\n </Accordion>\n );\n }\n\n if (view === 'order' && (isGiftMessageProvided || shouldRenderGiftOptions)) {\n const renderHeader = (\n <div className=\"cart-gift-options-readonly__header\">\n <Icon source={Gift} size=\"24\" />\n <span>{dictionary.readOnlyOrderTitle}</span>\n </div>\n );\n\n const selectedGiftOptions = (\n <>\n {giftReceiptIncluded ? (\n <div className=\"cart-gift-options-readonly__checkboxes cart-gift-options-readonly__checkboxes--gift-receipt\">\n <Icon source={CheckWithCircle} size=\"16\" />\n <p>{dictionary.readOnlyOrderGiftReceiptTitle}</p>\n <p>{dictionary.readOnlyOrderGiftReceiptText}</p>\n </div>\n ) : null}\n {printedCardIncluded ? (\n <div className=\"cart-gift-options-readonly__checkboxes cart-gift-options-readonly__checkboxes--print-card\">\n <Icon source={CheckWithCircle} size=\"16\" />\n <p>{dictionary.readOnlyOrderGiftPrintCardTitle}</p>\n <p>{dictionary.readOnlyOrderGiftPrintCardText}</p>\n </div>\n ) : null}\n {giftWrapCart?.selected ? (\n <div className=\"cart-gift-options-readonly__checkboxes cart-gift-options-readonly__checkboxes--gift-wrap\">\n <Icon source={CheckWithCircle} size=\"16\" />\n <p>\n {dictionary.readOnlyOrderGiftWrapTitle} (+\n <Price\n amount={giftWrapCart.price.value}\n currency={giftWrapCart.price.currency}\n weight=\"normal\"\n />\n )\n </p>\n <p>{`${dictionary.readOnlyOrderGiftWrapOptionsText} ${giftWrapCart?.design}`}</p>\n </div>\n ) : null}\n </>\n );\n\n const enteredGiftMessage = isGiftMessageProvided ? (\n <div className=\"cart-gift-options-readonly__form\">\n <div>{dictionary.readOnlyOrderFormTitle}</div>\n <div>\n <p>\n <span>{dictionary.readOnlyOrderFormTo}</span>\n <span>{recipientName}</span>\n </p>\n <p>\n <span>{dictionary.readOnlyOrderFormFrom}</span>\n <span>{senderName}</span>\n </p>\n </div>\n <div>\n <p>{dictionary.readOnlyOrderFormMessageTitle}</p>\n <p>{message}</p>\n </div>\n </div>\n ) : null;\n\n return (\n <Card variant={readOnlyFormOrderView}>\n {renderHeader}\n {selectedGiftOptions}\n {enteredGiftMessage}\n </Card>\n );\n }\n\n return null;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useCallback, StateUpdater, Dispatch } from 'preact/hooks';\nimport { FunctionComponent, JSX, VNode } from 'preact';\nimport { GiftOptionModal } from './Elements/GiftOptionModal';\nimport { GiftLoader } from './Elements/GiftLoader';\nimport { CheckboxGroup } from './Elements/CheckboxGroup';\nimport { FormFields } from './Elements/FormFields';\nimport { ReadOnlyFormView } from './Elements/ReadOnlyFormView';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport {\n Accordion,\n AccordionSection,\n Card,\n Icon,\n ImageNodeRenderProps,\n ProgressSpinner,\n} from '@adobe-commerce/elsie/components';\nimport {\n ChevronDown,\n ChevronUp,\n CheckWithCircle,\n Gift,\n} from '@adobe-commerce/elsie/icons';\nimport {\n GiftWrappingConfigProps,\n GiftOptionsViewProps,\n GiftFormDataType,\n GiftOptionsReadOnlyViewProps,\n ProductGiftOptionsConfig,\n} from '@/cart/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { CartModel, Item } from '@/cart/data/models';\nimport '@/cart/components/GiftOptions/GiftOptions.css';\n\nexport interface GiftOptionsProps {\n readOnlyFormOrderView: GiftOptionsReadOnlyViewProps;\n cartData: CartModel | null;\n errorsField: Record<string, string>;\n isGiftMessageVisible: boolean;\n fieldsDisabled: boolean;\n loading: boolean;\n showModal: boolean;\n isEditable: boolean;\n isGiftOptionsApplied: boolean;\n updateLoading: boolean;\n areGiftOptionsVisible: Record<string, boolean>;\n view: GiftOptionsViewProps;\n giftOptions: GiftFormDataType;\n imageSwatchImageNode?: VNode | ((props: ImageNodeRenderProps) => JSX.Element);\n item: Item | ProductGiftOptionsConfig;\n giftWrappingConfig: GiftWrappingConfigProps[] | [];\n updateGiftOptions: (\n name: string,\n value?: string | boolean | number,\n extraGiftOptions?: Record<string, string | boolean | number>\n ) => void;\n setShowModal: Dispatch<StateUpdater<boolean>>;\n handleFormMouseLeave: () => void;\n onInputChange: (event: Event) => void;\n onBlur: (event: Event) => void;\n}\n\nexport const GiftOptions: FunctionComponent<GiftOptionsProps> = ({\n item,\n view,\n loading,\n giftOptions,\n showModal,\n isEditable,\n errorsField,\n updateLoading,\n cartData,\n fieldsDisabled,\n isGiftOptionsApplied,\n giftWrappingConfig,\n readOnlyFormOrderView,\n isGiftMessageVisible,\n areGiftOptionsVisible,\n imageSwatchImageNode,\n onBlur,\n setShowModal,\n updateGiftOptions,\n onInputChange,\n handleFormMouseLeave,\n}) => {\n const dictionary = useText({\n accordionHeading: `Cart.GiftOptions.${view}.accordionHeading`,\n });\n\n const renderAccordion = useCallback(\n (defaultOpen: boolean) => {\n return (\n <Accordion\n data-testid=\"gift-options-product\"\n iconClose={ChevronUp}\n iconOpen={ChevronDown}\n actionIconPosition=\"right\"\n >\n <AccordionSection\n title={\n <div className=\"cart-gift-options-view__icon--success\">\n <span>{dictionary.accordionHeading}</span>\n {isGiftOptionsApplied ? (\n <Icon source={CheckWithCircle} size=\"16\" />\n ) : null}\n </div>\n }\n ariaLabelTitle={dictionary.accordionHeading}\n showIconLeft={true}\n iconLeft={Gift}\n defaultOpen={isGiftOptionsApplied || defaultOpen}\n renderContentWhenClosed={false}\n >\n <>\n <CheckboxGroup\n className={'cart-gift-options-view__top'}\n view={view}\n item={item}\n giftOptions={giftOptions}\n disabled={fieldsDisabled}\n onInputChange={onInputChange}\n cartData={cartData}\n giftWrappingConfig={giftWrappingConfig}\n setShowModal={setShowModal}\n areGiftOptionsVisible={areGiftOptionsVisible}\n />\n <form\n className=\"cart-gift-options-view__footer\"\n onMouseLeave={handleFormMouseLeave}\n >\n <FormFields\n view={view}\n giftOptions={giftOptions}\n disabled={fieldsDisabled}\n errorMessage={errorsField}\n onInputChange={onInputChange}\n onBlur={onBlur}\n isGiftMessageVisible={isGiftMessageVisible}\n />\n </form>\n </>\n </AccordionSection>\n </Accordion>\n );\n },\n [\n view,\n item,\n cartData,\n dictionary,\n errorsField,\n giftOptions,\n fieldsDisabled,\n giftWrappingConfig,\n areGiftOptionsVisible,\n isGiftOptionsApplied,\n isGiftMessageVisible,\n onBlur,\n setShowModal,\n onInputChange,\n handleFormMouseLeave,\n ]\n );\n\n if (!areGiftOptionsVisible.isGiftOptionsVisible && !isGiftMessageVisible) {\n return null;\n }\n\n return (\n <div\n id=\"cart-gift-options-view\"\n className={classes([\n 'cart-gift-options-view',\n `cart-gift-options-view--${view}`,\n ['cart-gift-options-view--loading', updateLoading],\n ])}\n >\n {updateLoading ? (\n <ProgressSpinner className=\"cart-gift-options-view__spinner\" />\n ) : null}\n {!loading ? (\n <>\n {!isEditable ? (\n <div className={'cart-gift-options-view--readonly'}>\n <ReadOnlyFormView\n view={view}\n giftOptions={giftOptions}\n giftWrappingConfig={giftWrappingConfig}\n readOnlyFormOrderView={readOnlyFormOrderView}\n />\n </div>\n ) : null}\n {showModal ? (\n <GiftOptionModal\n view={view}\n productName={item && 'name' in item ? item?.name : ''}\n showModal={showModal}\n giftWrappingConfig={giftWrappingConfig}\n setShowModal={() => setShowModal(false)}\n updateGiftOptions={updateGiftOptions}\n imageSwatchImageNode={imageSwatchImageNode}\n />\n ) : null}\n {view === 'product' && isEditable ? renderAccordion(false) : null}\n {view === 'order' && isEditable ? (\n <Card variant={'secondary'}>{renderAccordion(true)}</Card>\n ) : null}\n </>\n ) : (\n <GiftLoader />\n )}\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CartModel, Item } from '@/cart/data/models';\nimport { state } from '@/cart/lib/state';\nimport {\n GiftWrappingConfigProps,\n GiftOptionsViewProps,\n ProductGiftOptionsConfig,\n} from '@/cart/types';\n\n// This helper is specifically designed for small functions needed in useGiftOptions for formSections configuration manipulation.\nexport const DEFAULT_FORM_STATE = {\n recipientName: '',\n senderName: '',\n message: '',\n};\n\nexport const DEFAULT_CHECKBOXES_STATE = {\n giftReceiptIncluded: false,\n printedCardIncluded: false,\n isGiftWrappingSelected: false,\n};\n\nexport const shouldShowGiftMessage = (\n item: CartModel['items'][0] | ProductGiftOptionsConfig,\n isProductView: boolean\n) => {\n if (!isProductView) return !!state.config?.allowGiftMessageOnOrder;\n\n const allowGiftMessageOnOrderItems =\n state.config?.allowGiftMessageOnOrderItems ?? false;\n\n return typeof item?.giftMessageAvailable === 'boolean'\n ? item?.giftMessageAvailable\n : allowGiftMessageOnOrderItems;\n};\n\nexport const getSelectedGiftWrapping = (\n giftWrappingOptions: GiftWrappingConfigProps[] | []\n): GiftWrappingConfigProps | undefined => {\n const fallbackGiftWrappingData = {\n uid: '',\n design: '',\n selected: false,\n image: {\n url: '',\n design: '',\n },\n price: {\n currency: 'USD',\n value: 0,\n },\n };\n\n if (!giftWrappingOptions || giftWrappingOptions.length === 0) {\n return fallbackGiftWrappingData;\n }\n\n const isNotSelected = giftWrappingOptions?.every((wrap) => !wrap.selected);\n\n if (isNotSelected) {\n return giftWrappingOptions[0];\n }\n\n return giftWrappingOptions.find((wrap) => wrap.selected);\n};\n\nexport const areGiftOptionsDisabled = (\n view: GiftOptionsViewProps,\n item: Item | ProductGiftOptionsConfig\n) => {\n const {\n allowGiftWrappingOnOrder,\n allowGiftWrappingOnOrderItems,\n allowGiftMessageOnOrder,\n allowGiftMessageOnOrderItems,\n allowGiftReceipt,\n allowPrintedCard,\n } = state.config || {};\n\n const isGiftOptionsOnProductDisabled =\n !allowGiftMessageOnOrderItems &&\n !allowGiftWrappingOnOrderItems &&\n !shouldShowGiftMessage(item, true);\n\n const isGiftOptionsOnOrderDisabled =\n !allowGiftWrappingOnOrder &&\n !allowGiftMessageOnOrder &&\n !allowGiftReceipt &&\n !allowPrintedCard;\n\n if (view === 'product' && isGiftOptionsOnProductDisabled) {\n return true;\n }\n\n if (view === 'order' && isGiftOptionsOnOrderDisabled) {\n return true;\n }\n\n return false;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useCallback, useEffect, useState, useMemo } from 'preact/hooks';\nimport { events } from '@adobe-commerce/event-bus';\nimport { CartModel, Item } from '@/cart/data/models';\nimport { setGiftOptionsOnCart, updateProductsFromCart } from '@/cart/api';\nimport {\n DEFAULT_FORM_STATE,\n DEFAULT_CHECKBOXES_STATE,\n shouldShowGiftMessage,\n areGiftOptionsDisabled,\n} from '@/cart/lib/giftOptionsHelper';\nimport {\n GiftOptionsDataSourcesProps,\n GiftOptionsViewProps,\n GiftWrappingConfigProps,\n GiftFormDataType,\n ProductGiftOptionsConfig,\n} from '@/cart/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { state } from '@/cart/lib/state';\n\nexport interface UseGiftOptionsProps {\n item: Item | ProductGiftOptionsConfig;\n view: GiftOptionsViewProps;\n dataSource: GiftOptionsDataSourcesProps;\n initialLoading: boolean;\n handleItemsLoading?: (uid: string, state: boolean) => void;\n handleItemsError?: (uid: string, message?: string) => void;\n onItemUpdate?: ({ item }: { item: Item }) => void;\n onGiftOptionsChange?: (data: GiftFormDataType) => void;\n}\n\nexport const useGiftOptions = ({\n item,\n view,\n dataSource,\n initialLoading,\n handleItemsLoading,\n handleItemsError,\n onItemUpdate,\n onGiftOptionsChange,\n}: UseGiftOptionsProps) => {\n const isProductView = view === 'product';\n\n const dictionary = useText({\n requiredFieldError: 'Cart.GiftOptions.formText.requiredFieldError',\n });\n\n const [loading, setLoading] = useState(() => initialLoading);\n const [areGiftOptionsVisible, setAreGiftOptionsVisible] = useState({\n isGiftReceiptVisible: true,\n isPrintedCartVisible: true,\n isGiftWrappingVisible: true,\n isGiftOptionsVisible: true,\n });\n const [isGiftMessageVisible, setIsGiftMessageVisible] = useState(true);\n const [updateLoading, setUpdateLoading] = useState(false);\n const [fieldsDisabled, setFieldsDisabled] = useState(false);\n const [isDataChanged, setIsDataChanged] = useState(false);\n const [isFormTouched, setIsFormTouched] = useState(false);\n const [showModal, setShowModal] = useState<boolean>(false);\n const [giftWrappingConfig, setGiftWrappingConfig] = useState<\n GiftWrappingConfigProps[] | []\n >([]);\n const [cartData, setCartData] = useState<CartModel | null>(null);\n const [errorsField, setErrorsField] =\n useState<typeof DEFAULT_FORM_STATE>(DEFAULT_FORM_STATE);\n const [giftOptions, setGiftOptions] = useState<GiftFormDataType>(() => ({\n giftWrappingId: '',\n ...DEFAULT_FORM_STATE,\n ...DEFAULT_CHECKBOXES_STATE,\n }));\n\n const isFormFilled =\n giftOptions.recipientName?.trim() &&\n giftOptions.senderName?.trim() &&\n giftOptions.message?.trim();\n\n const isFormEmpty =\n !giftOptions.recipientName?.trim() &&\n !giftOptions.senderName?.trim() &&\n !giftOptions.message?.trim();\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const applyGiftOptionsToCart = useCallback(\n async (updatedGiftOptions: GiftFormDataType) => {\n // Update loading state used to render loading indicator required only in order view\n setUpdateLoading(view === 'order');\n setFieldsDisabled(true);\n\n switch (view) {\n case 'product':\n {\n if ('uid' in item) {\n handleItemsLoading?.(item.uid, true);\n handleItemsError?.(item.uid);\n }\n\n const {\n recipientName,\n senderName,\n message,\n giftWrappingId,\n isGiftWrappingSelected,\n } = updatedGiftOptions;\n\n const giftOptions = {\n gift_message: {\n to: recipientName ?? '',\n from: senderName ?? '',\n message: message ?? '',\n },\n gift_wrapping_id: isGiftWrappingSelected ? giftWrappingId : null,\n };\n\n if ('uid' in item && 'quantity' in item) {\n await updateProductsFromCart([\n {\n uid: item.uid,\n quantity: item.quantity,\n giftOptions,\n },\n ])\n .then(() => {\n onItemUpdate?.({ item });\n })\n .finally(() => {\n handleItemsLoading?.(item.uid, false);\n setFieldsDisabled(false);\n setIsDataChanged(false);\n setUpdateLoading(false);\n })\n .catch((error: any) => {\n console.warn(error);\n });\n }\n }\n break;\n case 'order':\n await setGiftOptionsOnCart(updatedGiftOptions).finally(() => {\n setFieldsDisabled(false);\n setIsDataChanged(false);\n setUpdateLoading(false);\n });\n break;\n default:\n console.error(\n 'Incorrect \"view\" prop value provided for GiftOptions container (storefront-cart)'\n );\n break;\n }\n },\n [handleItemsError, handleItemsLoading, item, onItemUpdate, view]\n );\n\n const updateGiftOptions = useCallback(\n (\n name: string,\n value: string | boolean | number | undefined,\n extraGiftOptions: Record<string, string | boolean | number> = {}\n ) => {\n setGiftOptions((prevGiftOptions: GiftFormDataType) => {\n const isValidGiftFormKey = (\n key: string\n ): key is keyof GiftFormDataType => key in prevGiftOptions;\n\n const getPrevValue = (key: string) =>\n isValidGiftFormKey(key) ? prevGiftOptions[key] : undefined;\n\n const hasChanged =\n getPrevValue(name) !== value ||\n Object.keys(extraGiftOptions).some(\n (key) => getPrevValue(key) !== extraGiftOptions[key]\n );\n\n if (!hasChanged) {\n onGiftOptionsChange?.(prevGiftOptions);\n return prevGiftOptions;\n }\n\n const updatedGiftOptions = {\n ...prevGiftOptions,\n [name]: value,\n ...extraGiftOptions,\n };\n\n if (\n !updatedGiftOptions.recipientName &&\n !updatedGiftOptions.senderName &&\n !updatedGiftOptions.message\n ) {\n setIsFormTouched(true);\n }\n\n if (\n typeof value === 'boolean' ||\n [\n 'giftWrappingId',\n 'giftReceiptIncluded',\n 'printedCardIncluded',\n ].includes(name)\n ) {\n setIsFormTouched(false);\n typeof onGiftOptionsChange === 'function'\n ? onGiftOptionsChange(updatedGiftOptions)\n : applyGiftOptionsToCart(updatedGiftOptions);\n }\n\n setIsDataChanged(true);\n\n onGiftOptionsChange?.(updatedGiftOptions);\n return updatedGiftOptions;\n });\n },\n [applyGiftOptionsToCart, onGiftOptionsChange]\n );\n\n const handleFormMouseLeave = useCallback(\n async () => {\n // Fields disabled if other event handler already triggered\n if (fieldsDisabled) return;\n if (typeof onGiftOptionsChange === 'function') return;\n\n // Case when user removed all form fields - reset to initial state\n if (isFormEmpty && isFormTouched) {\n setErrorsField(DEFAULT_FORM_STATE);\n setIsFormTouched(false);\n await applyGiftOptionsToCart(giftOptions);\n }\n\n // Case when user edited one of form fields\n if (isDataChanged && isFormFilled) {\n setIsFormTouched(true);\n await applyGiftOptionsToCart(giftOptions);\n }\n },\n [\n applyGiftOptionsToCart,\n giftOptions,\n isDataChanged,\n isFormEmpty,\n isFormTouched,\n fieldsDisabled,\n onGiftOptionsChange,\n isFormFilled\n ]\n );\n\n const handleBlur = useCallback(\n async (event: Event) => {\n // Fields disabled if other event handler already triggered\n if (fieldsDisabled) return;\n if (typeof onGiftOptionsChange === 'function') return;\n\n const { name, value } = event.target as HTMLInputElement;\n\n setErrorsField((prevErrors: typeof DEFAULT_FORM_STATE) => ({\n ...prevErrors,\n [name]: value.trim() ? '' : dictionary.requiredFieldError,\n }));\n\n // Case when user removed all form fields - reset to initial state\n if (isFormEmpty && isFormTouched) {\n setErrorsField(DEFAULT_FORM_STATE);\n setIsFormTouched(false);\n await applyGiftOptionsToCart(giftOptions);\n }\n\n if (isDataChanged && isFormFilled) {\n await applyGiftOptionsToCart(giftOptions);\n }\n },\n [\n fieldsDisabled,\n isFormEmpty,\n isFormTouched,\n isDataChanged,\n isFormFilled,\n dictionary,\n applyGiftOptionsToCart,\n giftOptions,\n onGiftOptionsChange,\n ]\n );\n\n const onInputChange = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const name = target.name;\n const value = target.type === 'checkbox' ? target.checked : target.value;\n\n updateGiftOptions(name, value);\n },\n [updateGiftOptions]\n );\n\n useEffect(() => {\n if (isProductView) return;\n\n const dataEvent = events.on(\n // @ts-ignore\n dataSource === 'cart' ? 'cart/data' : 'order/data',\n (payload: CartModel) => {\n setCartData(payload);\n // Gift wrapping is allowed for the cart if at least one item has gift wrapping available\n const isCartGiftWrappingAllowed = payload?.items?.some(\n ({ giftWrappingAvailable }: { giftWrappingAvailable: boolean }) =>\n giftWrappingAvailable\n );\n const isCartGiftWrappingApplied = payload?.cartGiftWrapping?.some(\n (wrap: GiftWrappingConfigProps) => wrap.selected\n );\n\n // If gift wrapping is not allowed and it is applied, remove it\n if (!isCartGiftWrappingAllowed && isCartGiftWrappingApplied) {\n applyGiftOptionsToCart({\n ...giftOptions,\n giftWrappingId: '',\n isGiftWrappingSelected: false,\n });\n }\n },\n { eager: true }\n );\n return () => {\n dataEvent?.off();\n };\n }, [setCartData, applyGiftOptionsToCart, dataSource, giftOptions, isProductView]);\n\n const giftOptionsState: GiftFormDataType | null = useMemo(() => {\n if (!cartData && !item) return null;\n\n const giftWrappingOptions: GiftWrappingConfigProps[] = isProductView\n ? item?.productGiftWrapping?.map(\n (wrap: GiftWrappingConfigProps): GiftWrappingConfigProps => ({\n ...wrap,\n price:\n item?.giftWrappingPrice && item?.giftWrappingPrice?.value > 0\n ? item.giftWrappingPrice\n : wrap.price,\n })\n )\n : cartData?.cartGiftWrapping || [];\n\n const selectedWrap = giftWrappingOptions?.find((wrap) => wrap.selected);\n const selectedGiftWrappingId =\n selectedWrap?.uid ?? giftWrappingOptions?.[0]?.uid;\n\n const isGiftWrappingSelected = !!selectedWrap;\n\n const giftMessageConfig = isProductView\n ? item.giftMessage\n : cartData?.giftMessage;\n const printedCardIncluded = cartData?.printedCardIncluded;\n const giftReceiptIncluded = cartData?.giftReceiptIncluded;\n\n const giftMessageAvailable = shouldShowGiftMessage(item, isProductView);\n\n const allowGiftWrappingOnOrder = state.config?.allowGiftWrappingOnOrder;\n const allowGiftReceipt = state.config?.allowGiftReceipt;\n const allowPrintedCard = state.config?.allowPrintedCard;\n const isGiftWrappingAvailableForSome = cartData?.items?.some(\n (item: { giftWrappingAvailable: boolean }) => item.giftWrappingAvailable\n );\n const allowGiftWrappingOnProduct = item?.giftWrappingAvailable;\n const isGiftReceiptVisible = isProductView ? false : !!allowGiftReceipt;\n const isPrintedCartVisible = isProductView ? false : !!allowPrintedCard;\n const isGiftWrappingVisible = isProductView\n ? !!allowGiftWrappingOnProduct && !!giftWrappingOptions.length\n : !!allowGiftWrappingOnOrder &&\n !!giftWrappingOptions.length &&\n !!isGiftWrappingAvailableForSome;\n const checkBoxesIsHidden =\n !isGiftReceiptVisible && !isPrintedCartVisible && !isGiftWrappingVisible;\n\n setAreGiftOptionsVisible({\n isGiftReceiptVisible,\n isPrintedCartVisible,\n isGiftWrappingVisible,\n isGiftOptionsVisible: !checkBoxesIsHidden,\n });\n setIsGiftMessageVisible(giftMessageAvailable);\n\n return {\n ...(item && 'uid' in item ? { itemId: item.uid } : {}),\n ...(!isProductView\n ? {\n printedCardIncluded,\n giftReceiptIncluded,\n }\n : {}),\n ...giftMessageConfig,\n giftWrappingId: selectedGiftWrappingId,\n isGiftWrappingSelected,\n giftWrappingOptions,\n };\n }, [cartData, item, isProductView]);\n\n useEffect(() => {\n if (!giftOptionsState) return;\n\n const { giftWrappingOptions, ...giftOptionsFetchData } = giftOptionsState;\n\n setGiftOptions(giftOptionsFetchData);\n\n if (giftWrappingOptions?.length) {\n setGiftWrappingConfig(giftWrappingOptions);\n }\n\n setLoading(false);\n }, [giftOptionsState]);\n\n const isGiftOptionsApplied = useMemo(() => {\n return Object.entries(giftOptions)\n .filter(([key]) => key !== 'itemId' && key !== 'giftWrappingId')\n .some(([, value]) => Boolean(value));\n }, [giftOptions]);\n\n const isGiftOptionsHidden = useMemo(() => {\n return !loading && !!state?.config && areGiftOptionsDisabled(view, item);\n }, [item, loading, view]);\n\n return {\n loading,\n giftOptions,\n showModal,\n errorsField,\n updateLoading,\n cartData,\n fieldsDisabled,\n isGiftOptionsApplied,\n giftWrappingConfig,\n setFieldsDisabled,\n handleFormMouseLeave,\n onInputChange,\n updateGiftOptions,\n setShowModal,\n handleBlur,\n isGiftMessageVisible,\n areGiftOptionsVisible,\n isGiftOptionsHidden,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { GiftOptions as GiftOptionsComponent } from '@/cart/components';\nimport { Item } from '@/cart/data/models';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { useGiftOptions } from '@/cart/hooks/useGiftOptions';\nimport {\n GiftOptionsViewProps,\n GiftOptionsDataSourcesProps,\n GiftFormDataType,\n ProductGiftOptionsConfig,\n GiftOptionsReadOnlyViewProps,\n} from '@/cart/types';\nimport { ImageNodeRenderProps, ImageProps } from '@adobe-commerce/elsie/components';\n\nexport interface GiftOptionsProps {\n item: Item | ProductGiftOptionsConfig;\n view?: GiftOptionsViewProps;\n readOnlyFormOrderView: GiftOptionsReadOnlyViewProps;\n dataSource?: GiftOptionsDataSourcesProps;\n isEditable?: boolean;\n initialLoading?: boolean;\n handleItemsLoading?: (uid: string, state: boolean) => void;\n handleItemsError?: (uid: string, message?: string) => void;\n onItemUpdate?: ({ item }: { item: Item }) => void;\n onGiftOptionsChange?: (data: GiftFormDataType) => void;\n slots?: {\n SwatchImage?: SlotProps<{ \n item: Item | ProductGiftOptionsConfig\n imageSwatchContext: ImageNodeRenderProps['imageSwatchContext']\n defaultImageProps: ImageProps\n }>;\n };\n}\n\nexport const GiftOptions: Container<GiftOptionsProps> = ({\n item,\n view = 'order',\n readOnlyFormOrderView = 'primary',\n dataSource = 'cart',\n isEditable = true,\n initialLoading = true,\n slots,\n handleItemsLoading,\n handleItemsError,\n onItemUpdate,\n onGiftOptionsChange,\n}: GiftOptionsProps) => {\n const {\n isGiftMessageVisible,\n areGiftOptionsVisible,\n loading,\n giftOptions,\n showModal,\n errorsField,\n updateLoading,\n cartData,\n isGiftOptionsApplied,\n fieldsDisabled,\n giftWrappingConfig,\n handleFormMouseLeave,\n updateGiftOptions,\n setShowModal,\n onInputChange,\n handleBlur,\n isGiftOptionsHidden,\n } = useGiftOptions({\n item,\n view,\n dataSource,\n initialLoading,\n handleItemsLoading,\n handleItemsError,\n onItemUpdate,\n onGiftOptionsChange,\n });\n\n if (isGiftOptionsHidden) {\n return null;\n }\n\n return (\n <GiftOptionsComponent\n item={item}\n view={view}\n loading={loading}\n onBlur={handleBlur}\n giftOptions={giftOptions}\n showModal={showModal}\n isEditable={isEditable}\n errorsField={errorsField}\n setShowModal={setShowModal}\n updateLoading={updateLoading}\n updateGiftOptions={updateGiftOptions}\n cartData={cartData}\n isGiftOptionsApplied={isGiftOptionsApplied}\n fieldsDisabled={fieldsDisabled}\n giftWrappingConfig={giftWrappingConfig}\n handleFormMouseLeave={handleFormMouseLeave}\n readOnlyFormOrderView={readOnlyFormOrderView}\n onInputChange={onInputChange}\n isGiftMessageVisible={isGiftMessageVisible}\n areGiftOptionsVisible={areGiftOptionsVisible}\n imageSwatchImageNode={\n slots?.SwatchImage ? ({ imageSwatchContext, ...defaultImageProps }) => (\n // No need to provide default content, as the slot will only be rendered if it's actually provided.\n <Slot \n name=\"SwatchImage\"\n slotTag='span'\n contentTag='span'\n slot={slots.SwatchImage} \n context={{ item, imageSwatchContext, defaultImageProps }} \n />\n ) : undefined\n }\n />\n );\n};\n"],"names":["SvgCheckWithCircle","props","React","SvgGift","useFocusTrap","showModal","containerRef","useRef","useEffect","container","focusableElements","firstElement","lastElement","handleKeyDown","event","GiftOptionModal","view","productName","giftWrappingConfig","imageSwatchImageNode","setShowModal","updateGiftOptions","dictionary","useText","giftWrappingItem","setGiftWrappingItem","useState","selectedGiftWrapping","item","focusElement","renderTitle","jsx","jsxs","Modal","Fragment","_a","Price","ContentGrid","wrapItem","ImageSwatch","Button","GiftLoader","Skeleton","SkeletonRow","CheckboxGroup","className","giftOptions","disabled","cartData","onInputChange","areGiftOptionsVisible","id","useId","productGiftWrappingOptions","orderGiftWrappingOptions","giftWrappingOptions","el","selectedGiftWrappingLabel","productGiftWrappingPrice","renderSelectedGiftWrappingLabel","printedCardPrice","_b","state","_c","productWrappingPrice","_d","renderPrice","price","classes","Field","Checkbox","FormFields","errorMessage","onBlur","isGiftMessageVisible","Input","TextArea","ReadOnlyFormView","readOnlyFormOrderView","recipientName","senderName","message","giftReceiptIncluded","printedCardIncluded","isGiftWrappingSelected","giftWrapCart","uid","isGiftMessageProvided","giftWrapProductSelectLabel","shouldRenderGiftOptions","productGiftOptionsConfig","noProductGiftOptionsApplied","Accordion","ChevronUp","ChevronDown","AccordionSection","Gift","element","config","renderHeader","Icon","selectedGiftOptions","CheckWithCircle","enteredGiftMessage","Card","GiftOptions","loading","isEditable","errorsField","updateLoading","fieldsDisabled","isGiftOptionsApplied","handleFormMouseLeave","renderAccordion","useCallback","defaultOpen","ProgressSpinner","DEFAULT_FORM_STATE","DEFAULT_CHECKBOXES_STATE","shouldShowGiftMessage","isProductView","allowGiftMessageOnOrderItems","areGiftOptionsDisabled","allowGiftWrappingOnOrder","allowGiftWrappingOnOrderItems","allowGiftMessageOnOrder","allowGiftReceipt","allowPrintedCard","isGiftOptionsOnProductDisabled","isGiftOptionsOnOrderDisabled","useGiftOptions","dataSource","initialLoading","handleItemsLoading","handleItemsError","onItemUpdate","onGiftOptionsChange","setLoading","setAreGiftOptionsVisible","setIsGiftMessageVisible","setUpdateLoading","setFieldsDisabled","isDataChanged","setIsDataChanged","isFormTouched","setIsFormTouched","setGiftWrappingConfig","setCartData","setErrorsField","setGiftOptions","isFormFilled","isFormEmpty","_e","_f","applyGiftOptionsToCart","updatedGiftOptions","giftWrappingId","updateProductsFromCart","error","setGiftOptionsOnCart","name","value","extraGiftOptions","prevGiftOptions","isValidGiftFormKey","key","getPrevValue","handleBlur","prevErrors","target","dataEvent","events","payload","isCartGiftWrappingAllowed","giftWrappingAvailable","isCartGiftWrappingApplied","wrap","giftOptionsState","useMemo","selectedWrap","selectedGiftWrappingId","giftMessageConfig","giftMessageAvailable","isGiftWrappingAvailableForSome","allowGiftWrappingOnProduct","isGiftReceiptVisible","isPrintedCartVisible","isGiftWrappingVisible","giftOptionsFetchData","isGiftOptionsHidden","slots","GiftOptionsComponent","imageSwatchContext","defaultImageProps","Slot"],"mappings":"8nCACA,MAAMA,GAAsBC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAK,EAAoBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,0JAA2J,OAAQ,cAAc,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,qCAAsC,OAAQ,cAAc,CAAE,CAAC,ECAxlBC,GAAWF,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAK,EAAoBC,EAAM,cAAc,OAAQ,CAAE,EAAG,ujBAAwjB,OAAQ,eAAgB,YAAa,GAAK,CAAA,CAAC,ECCj0B,SAASE,GAAaC,EAAoB,CACzC,MAAAC,EAAeC,GAA8B,IAAI,EAEvD,OAAAC,EAAU,IAAM,CACd,GAAI,CAACH,GAAa,CAACC,EAAa,QAAS,OAEzC,MAAMG,EAAYH,EAAa,QAEzBI,EAAoBD,EAAU,iBAClC,8EACF,EAEI,GAAAC,EAAkB,SAAW,EAAG,OAE9B,MAAAC,EAAeD,EAAkB,CAAC,EAClCE,EAAcF,EAAkBA,EAAkB,OAAS,CAAC,EAElE,SAASG,EAAcC,EAAsB,CACvCA,EAAM,MAAQ,QACZA,EAAM,UAAY,SAAS,gBAAkBH,GAC/CG,EAAM,eAAe,EACrBF,EAAY,MAAM,GACT,CAACE,EAAM,UAAY,SAAS,gBAAkBF,IACvDE,EAAM,eAAe,EACrBH,EAAa,MAAM,GAE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oB,kBAAAC,CAAkB,CAAA,CAAA,EAEvD,MAAA,CAER,CAEJ","x_google_ignoreList":[0,1]}
|
|
1
|
+
{"version":3,"file":"GiftOptions.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/CheckWithCircle.svg","../../node_modules/@adobe-commerce/elsie/src/icons/Gift.svg","/@dropins/storefront-cart/src/hooks/useFocusTrap.tsx","/@dropins/storefront-cart/src/components/GiftOptions/Elements/GiftOptionModal.tsx","/@dropins/storefront-cart/src/components/GiftOptions/Elements/GiftLoader.tsx","/@dropins/storefront-cart/src/components/GiftOptions/Elements/CheckboxGroup.tsx","/@dropins/storefront-cart/src/components/GiftOptions/Elements/FormFields.tsx","/@dropins/storefront-cart/src/components/GiftOptions/Elements/ReadOnlyFormView.tsx","/@dropins/storefront-cart/src/components/GiftOptions/GiftOptions.tsx","/@dropins/storefront-cart/src/lib/giftOptionsHelper.ts","/@dropins/storefront-cart/src/hooks/useGiftOptions.tsx","/@dropins/storefront-cart/src/containers/GiftOptions/GiftOptions.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgCheckWithCircle = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z\", stroke: \"currentColor\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M6.75 12.762L10.2385 15.75L17.25 9\", stroke: \"currentColor\" }));\nexport default SvgCheckWithCircle;\n","import * as React from \"react\";\nconst SvgGift = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 20, height: 23, viewBox: \"0 0 20 23\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M10 6L10 21.5M10 6H12.25C13.4926 6 14.5 4.99264 14.5 3.75C14.5 2.50736 13.4926 1.5 12.25 1.5C11.0074 1.5 10 2.50736 10 3.75M10 6V3.75M10 6H7.75C6.50736 6 5.5 4.99264 5.5 3.75C5.5 2.50736 6.50736 1.5 7.75 1.5C8.99264 1.5 10 2.50736 10 3.75M3.25 10.75H16.75C17.9926 10.75 19 9.74264 19 8.5C19 7.25736 17.9926 6.25 16.75 6.25H3.25C2.00736 6.25 1 7.25736 1 8.5C1 9.74264 2.00736 10.75 3.25 10.75ZM4.75 21.5H15.25C16.4926 21.5 17.5 20.4926 17.5 19.25V13.25C17.5 12.0074 16.4926 11 15.25 11H4.75C3.50736 11 2.5 12.0074 2.5 13.25V19.25C2.5 20.4926 3.50736 21.5 4.75 21.5Z\", stroke: \"currentColor\", strokeWidth: 1 }));\nexport default SvgGift;\n","import { useEffect, useRef } from 'preact/hooks';\n\nexport function useFocusTrap(showModal: boolean) {\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (!showModal || !containerRef.current) return;\n\n const container = containerRef.current;\n\n const focusableElements = container.querySelectorAll<HTMLElement>(\n 'a, button, input, textarea, select, details, [tabindex]:not([tabindex=\"-1\"])'\n );\n\n if (focusableElements.length === 0) return;\n\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n function handleKeyDown(event: KeyboardEvent) {\n if (event.key === 'Tab') {\n if (event.shiftKey && document.activeElement === firstElement) {\n event.preventDefault();\n lastElement.focus();\n } else if (!event.shiftKey && document.activeElement === lastElement) {\n event.preventDefault();\n firstElement.focus();\n }\n }\n }\n\n container.addEventListener('keydown', handleKeyDown);\n\n return () => {\n container.removeEventListener('keydown', handleKeyDown);\n };\n }, [showModal]);\n\n return containerRef;\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent, JSX, VNode } from 'preact';\nimport {\n Modal,\n Button,\n ImageSwatch,\n Price,\n ContentGrid,\n ImageNodeRenderProps,\n} from '@adobe-commerce/elsie/components';\nimport { useState, useEffect } from 'preact/hooks';\nimport { GiftWrappingConfigProps, GiftOptionsViewProps } from '@/cart/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { useFocusTrap } from '@/cart/hooks/useFocusTrap';\n\ninterface GiftOptionModalProps {\n giftWrappingConfig: GiftWrappingConfigProps[];\n showModal: boolean;\n productName: string;\n view: GiftOptionsViewProps;\n imageSwatchImageNode?: VNode | ((props: ImageNodeRenderProps) => JSX.Element);\n setShowModal: () => void;\n updateGiftOptions: (\n name: string,\n value?: string | boolean | number,\n extraGiftOptions?: Record<string, string | boolean | number>\n ) => void;\n}\n\nexport const GiftOptionModal: FunctionComponent<GiftOptionModalProps> = ({\n view,\n showModal,\n productName,\n giftWrappingConfig,\n imageSwatchImageNode,\n setShowModal,\n updateGiftOptions,\n}) => {\n const containerRef = useFocusTrap(showModal);\n\n const dictionary = useText({\n modalTitle: 'Cart.GiftOptions.modal.title',\n defaultTitle: 'Cart.GiftOptions.modal.defaultTitle',\n modalWrappingText: 'Cart.GiftOptions.modal.wrappingText',\n modalWrappingSubText: 'Cart.GiftOptions.modal.wrappingSubText',\n modalConfirmButton: 'Cart.GiftOptions.modal.modalConfirmButton',\n modalCancelButton: 'Cart.GiftOptions.modal.modalCancelButton',\n ariaLabelModal: 'Cart.GiftOptions.modal.ariaLabelModal',\n ariaLabelModalOpen: 'Cart.GiftOptions.modal.ariaLabelModalOpen',\n ariaLabelModalClose: 'Cart.GiftOptions.modal.ariaLabelModalClose',\n ariaLabelWrapping: 'Cart.GiftOptions.modal.ariaLabelWrapping',\n });\n\n const [giftWrappingItem, setGiftWrappingItem] =\n useState<GiftWrappingConfigProps>();\n\n useEffect(() => {\n const selectedGiftWrapping =\n giftWrappingConfig.find((item) => item.selected) ?? giftWrappingConfig[0];\n\n setGiftWrappingItem(selectedGiftWrapping);\n }, [giftWrappingConfig]);\n\n useEffect(() => {\n const focusElement = document?.querySelector(\n '.cart-gift-options-view__modal-wrapper'\n ) as HTMLElement;\n\n if (focusElement) focusElement?.focus();\n }, []);\n\n if (!showModal || !giftWrappingConfig.length) return null;\n\n const renderTitle = productName\n ? `${dictionary.modalTitle} ${productName}`\n : dictionary.defaultTitle;\n\n return (\n <div\n ref={containerRef}\n className=\"cart-gift-options-view__modal-wrapper\"\n tabIndex={0}\n aria-label={`${dictionary.ariaLabelModal} ${\n showModal\n ? dictionary.ariaLabelModalOpen\n : dictionary.ariaLabelModalClose\n } ${productName}`}\n >\n <Modal\n data-testid={`gift-option-modal-${view}`}\n className={'cart-gift-options-view__modal'}\n size={'medium'}\n title={\n <>\n <span>{renderTitle}</span>\n {giftWrappingItem && giftWrappingItem?.price?.value > 0 ? (\n <Price\n amount={giftWrappingItem.price.value}\n currency={giftWrappingItem.price.currency}\n weight=\"normal\"\n />\n ) : null}\n </>\n }\n centered={true}\n onClose={setShowModal}\n >\n <div className=\"cart-gift-options-view__modal-content\">\n <span className=\"cart-gift-options-view__modal-text\">\n {dictionary.modalWrappingText}\n </span>\n <ContentGrid\n emptyGridContent={<></>}\n maxColumns={6}\n columnWidth=\"100px\"\n className=\"cart-gift-options-view__modal-grid\"\n >\n {giftWrappingConfig.map((wrapItem) => (\n <ImageSwatch\n groupAriaLabel={dictionary.ariaLabelWrapping}\n selected={giftWrappingItem?.uid === wrapItem?.uid}\n onValue={() => {\n setGiftWrappingItem(wrapItem);\n }}\n imageNode={imageSwatchImageNode}\n name={'giftWrappingId'}\n value={wrapItem.uid}\n src={wrapItem.image.url}\n alt={wrapItem.design}\n label={wrapItem.design}\n key={wrapItem.uid}\n data-testid={`gift-option-modal-image-${wrapItem.uid}`}\n className={'cart-gift-options-view__modal-grid-item'}\n />\n ))}\n </ContentGrid>\n <span className=\"cart-gift-options-view__modal-sub-text\">\n {giftWrappingItem?.design}\n </span>\n </div>\n\n <Button\n data-testid=\"gift-option-modal-confirm-button\"\n type=\"button\"\n onClick={() => {\n updateGiftOptions('giftWrappingId', giftWrappingItem?.uid, {\n isGiftWrappingSelected: true,\n });\n setShowModal();\n }}\n >\n {dictionary.modalConfirmButton}\n </Button>\n <Button\n type=\"button\"\n variant=\"secondary\"\n onClick={setShowModal}\n data-testid=\"gift-option-modal-cancel-button\"\n >\n {dictionary.modalCancelButton}\n </Button>\n </Modal>\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\n\nexport const GiftLoader: FunctionComponent = () => {\n return (\n <Skeleton>\n <SkeletonRow\n variant=\"row\"\n size=\"small\"\n fullWidth={true}\n lines={1}\n multilineGap=\"small\"\n />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Checkbox, Field, Button, Price } from '@adobe-commerce/elsie/components';\nimport {\n GiftOptionsViewProps,\n GiftWrappingConfigProps,\n GiftFormDataType,\n ProductGiftOptionsConfig,\n} from '@/cart/types';\nimport { CartModel, Item, Price as PriceType } from '@/cart/data/models';\nimport { state } from '@/cart/lib/state';\nimport { StateUpdater, Dispatch, useId } from 'preact/hooks';\n\ninterface CheckboxGroupProps {\n className: string;\n view: GiftOptionsViewProps;\n item: Item | ProductGiftOptionsConfig;\n giftOptions: GiftFormDataType;\n disabled: boolean;\n cartData: CartModel | null;\n giftWrappingConfig: GiftWrappingConfigProps[] | [];\n areGiftOptionsVisible: Record<string, boolean>;\n setShowModal: Dispatch<StateUpdater<boolean>>;\n onInputChange: (event: Event) => void;\n}\n\nexport const CheckboxGroup: FunctionComponent<CheckboxGroupProps> = ({\n className,\n view,\n item,\n giftOptions,\n disabled,\n cartData,\n giftWrappingConfig,\n setShowModal,\n onInputChange,\n areGiftOptionsVisible,\n}) => {\n const id = useId();\n const dictionary = useText({\n customize: `Cart.GiftOptions.${view}.customize`,\n giftReceiptIncludedTitle: `Cart.GiftOptions.${view}.giftReceiptIncluded.title`,\n giftReceiptIncludedText: `Cart.GiftOptions.${view}.giftReceiptIncluded.subtitle`,\n printedCardIncludedTitle: `Cart.GiftOptions.${view}.printedCardIncluded.title`,\n printedCardIncludedText: `Cart.GiftOptions.${view}.printedCardIncluded.subtitle`,\n giftOptionsWrapTitle: `Cart.GiftOptions.${view}.giftOptionsWrap.title`,\n giftOptionsWrapText: `Cart.GiftOptions.${view}.giftOptionsWrap.subtitle`,\n requiredFieldError: 'Cart.GiftOptions.formText.requiredFieldError',\n });\n\n const productGiftWrappingOptions = item?.productGiftWrapping;\n const orderGiftWrappingOptions = cartData?.cartGiftWrapping;\n const giftWrappingOptions =\n view === 'product' ? productGiftWrappingOptions : orderGiftWrappingOptions;\n\n const selectedGiftWrapping = giftWrappingOptions?.find(\n (el: GiftWrappingConfigProps) => el.uid === giftOptions.giftWrappingId\n );\n const selectedGiftWrappingLabel = selectedGiftWrapping?.design ?? '';\n\n // Product level configurations\n const productGiftWrappingPrice = item?.giftWrappingPrice;\n const renderSelectedGiftWrappingLabel = selectedGiftWrappingLabel\n ? `${dictionary.giftOptionsWrapText} ${selectedGiftWrappingLabel}`\n : '';\n\n const printedCardPrice =\n +(state.config?.printedCardPrice?.value ?? 0) > 0\n ? state.config?.printedCardPrice\n : null;\n\n let productWrappingPrice = null;\n\n // Product level configurations have higher priority\n if (productGiftWrappingPrice?.value) {\n productWrappingPrice = productGiftWrappingPrice;\n } else if (selectedGiftWrapping?.price?.value) {\n productWrappingPrice = selectedGiftWrapping.price;\n }\n\n const renderPrice = (price?: PriceType | null) => {\n if (!price) return null;\n\n return (\n <span>\n (+\n <Price amount={price.value} currency={price.currency} weight=\"normal\" />\n )\n </span>\n );\n };\n\n return (\n <div\n className={classes([\n className,\n [`${className}--hidden`, !areGiftOptionsVisible.isGiftOptionsVisible],\n ])}\n >\n {areGiftOptionsVisible.isGiftReceiptVisible ? (\n <Field\n disabled={disabled}\n className={'cart-gift-options-view__field-gift-receipt'}\n >\n <Checkbox\n id={`giftReceiptIncluded-${id}`}\n disabled={disabled}\n name={'giftReceiptIncluded'}\n checked={giftOptions.giftReceiptIncluded}\n placeholder={dictionary.giftReceiptIncludedTitle}\n label={dictionary.giftReceiptIncludedTitle}\n description={dictionary.giftReceiptIncludedText}\n onChange={onInputChange}\n />\n </Field>\n ) : null}\n {areGiftOptionsVisible.isPrintedCartVisible ? (\n <Field\n disabled={disabled}\n className={'cart-gift-options-view__field-printed-card'}\n >\n <Checkbox\n id={`printedCardIncluded-${id}`}\n disabled={disabled}\n name={'printedCardIncluded'}\n checked={giftOptions.printedCardIncluded}\n placeholder={dictionary.printedCardIncludedTitle}\n label={\n <>\n {dictionary.printedCardIncludedTitle}\n {renderPrice(printedCardPrice)}\n </>\n }\n description={dictionary.printedCardIncludedText}\n onChange={onInputChange}\n />\n </Field>\n ) : null}\n {areGiftOptionsVisible.isGiftWrappingVisible ? (\n <>\n <Field\n disabled={disabled}\n className={'cart-gift-options-view__field-gift-wrap'}\n >\n <Checkbox\n id={`giftOptionsWrap-${id}`}\n disabled={disabled}\n name={'isGiftWrappingSelected'}\n checked={giftOptions.isGiftWrappingSelected}\n placeholder={dictionary.giftOptionsWrapTitle}\n label={\n <>\n {dictionary.giftOptionsWrapTitle}\n {renderPrice(productWrappingPrice)}\n </>\n }\n description={renderSelectedGiftWrappingLabel}\n onChange={onInputChange}\n />\n </Field>\n\n <Button\n disabled={disabled || !giftWrappingConfig.length}\n type=\"button\"\n data-testid={`gift-option-customize-${view}`}\n variant=\"tertiary\"\n onClick={() => setShowModal(true)}\n >\n {dictionary.customize}\n </Button>\n </>\n ) : null}\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Field, Input, TextArea } from '@adobe-commerce/elsie/components';\nimport { GiftOptionsViewProps, GiftFormDataType } from '@/cart/types';\nimport { useId } from 'preact/hooks';\n\ninterface FormFieldsProps {\n view: GiftOptionsViewProps;\n giftOptions: GiftFormDataType;\n disabled: boolean;\n errorMessage: Record<string, string>;\n onInputChange: (value: Event) => void;\n onBlur: (event: Event) => void;\n isGiftMessageVisible: boolean;\n}\n\nexport const FormFields: FunctionComponent<FormFieldsProps> = ({\n view,\n giftOptions,\n disabled,\n errorMessage,\n onInputChange,\n onBlur,\n isGiftMessageVisible,\n}) => {\n const id = useId();\n const dictionary = useText({\n formTitle: `Cart.GiftOptions.${view}.formContent.formTitle`,\n formTo: `Cart.GiftOptions.${view}.formContent.formTo`,\n formFrom: `Cart.GiftOptions.${view}.formContent.formFrom`,\n giftMessageTitle: `Cart.GiftOptions.${view}.formContent.giftMessageTitle`,\n formToPlaceholder: `Cart.GiftOptions.${view}.formContent.formToPlaceholder`,\n formFromPlaceholder: `Cart.GiftOptions.${view}.formContent.formFromPlaceholder`,\n formMessagePlaceholder: `Cart.GiftOptions.${view}.formContent.formMessagePlaceholder`,\n });\n\n if (!isGiftMessageVisible) return null;\n\n return (\n <>\n <span>{dictionary.formTitle}</span>\n <div>\n <span>{dictionary.formTo}</span>\n <Field disabled={disabled} error={errorMessage.recipientName}>\n <Input\n id={`recipientName-${id}`}\n disabled={disabled}\n type=\"text\"\n name={'recipientName'}\n value={giftOptions.recipientName}\n placeholder={dictionary.formToPlaceholder}\n onChange={onInputChange}\n onBlur={onBlur}\n />\n </Field>\n </div>\n <div>\n <span>{dictionary.formFrom}</span>\n <Field disabled={disabled} error={errorMessage.senderName}>\n <Input\n id={`senderName-${id}`}\n disabled={disabled}\n type=\"text\"\n name={'senderName'}\n value={giftOptions.senderName}\n placeholder={dictionary.formFromPlaceholder}\n onChange={onInputChange}\n onBlur={onBlur}\n />\n </Field>\n </div>\n <div>\n <span>{dictionary.giftMessageTitle}</span>\n <Field disabled={disabled}>\n <TextArea\n id={`message-${id}`}\n errorMessage={errorMessage.message}\n disabled={disabled}\n name={'message'}\n value={giftOptions.message}\n label={dictionary.formMessagePlaceholder}\n onChange={onInputChange}\n onBlur={onBlur}\n />\n </Field>\n </div>\n </>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport {\n Price,\n Icon,\n Card,\n Accordion,\n AccordionSection,\n} from '@adobe-commerce/elsie/components';\nimport {\n ChevronDown,\n ChevronUp,\n Gift,\n CheckWithCircle,\n} from '@adobe-commerce/elsie/icons';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport {\n GiftFormDataType,\n GiftWrappingConfigProps,\n GiftOptionsReadOnlyViewProps,\n GiftOptionsViewProps,\n} from '@/cart/types';\n\nexport interface ReadOnlyFormViewProps {\n view: GiftOptionsViewProps;\n giftOptions: GiftFormDataType;\n readOnlyFormOrderView: GiftOptionsReadOnlyViewProps;\n giftWrappingConfig: GiftWrappingConfigProps[] | [];\n}\n\nexport const ReadOnlyFormView: FunctionComponent<ReadOnlyFormViewProps> = ({\n view,\n giftOptions,\n giftWrappingConfig,\n readOnlyFormOrderView,\n}) => {\n const dictionary = useText({\n readOnlyProductTitle: 'Cart.GiftOptions.product.readOnlyFormView.title',\n wrapping: 'Cart.GiftOptions.product.readOnlyFormView.wrapping',\n recipient: 'Cart.GiftOptions.product.readOnlyFormView.recipient',\n sender: 'Cart.GiftOptions.product.readOnlyFormView.sender',\n message: 'Cart.GiftOptions.product.readOnlyFormView.message',\n\n readOnlyOrderTitle: 'Cart.GiftOptions.order.readOnlyFormView.title',\n readOnlyOrderGiftReceiptTitle:\n 'Cart.GiftOptions.order.readOnlyFormView.giftReceipt',\n readOnlyOrderGiftReceiptText:\n 'Cart.GiftOptions.order.readOnlyFormView.giftReceiptText',\n readOnlyOrderGiftPrintCardTitle:\n 'Cart.GiftOptions.order.readOnlyFormView.printCard',\n readOnlyOrderGiftPrintCardText:\n 'Cart.GiftOptions.order.readOnlyFormView.printCardText',\n readOnlyOrderGiftWrapTitle:\n 'Cart.GiftOptions.order.readOnlyFormView.giftWrap',\n readOnlyOrderGiftWrapOptionsText:\n 'Cart.GiftOptions.order.readOnlyFormView.giftWrapOptions',\n\n readOnlyOrderFormTitle: 'Cart.GiftOptions.order.readOnlyFormView.formTitle',\n readOnlyOrderFormTo: 'Cart.GiftOptions.order.readOnlyFormView.formTo',\n readOnlyOrderFormFrom: 'Cart.GiftOptions.order.readOnlyFormView.formFrom',\n readOnlyOrderFormMessageTitle:\n 'Cart.GiftOptions.order.readOnlyFormView.formMessageTitle',\n });\n\n const {\n recipientName,\n senderName,\n message,\n giftReceiptIncluded,\n printedCardIncluded,\n isGiftWrappingSelected,\n } = giftOptions;\n\n const giftWrapCart = giftWrappingConfig?.find(\n ({ uid }) => uid === giftOptions?.giftWrappingId\n );\n const isGiftMessageProvided = !!recipientName || !!senderName || !!message;\n const giftWrapProductSelectLabel = giftWrapCart?.design;\n const shouldRenderGiftOptions =\n giftReceiptIncluded || printedCardIncluded || giftWrapCart?.selected;\n\n const productGiftOptionsConfig = [\n {\n id: 1,\n title: dictionary.wrapping,\n message: isGiftWrappingSelected ? giftWrapProductSelectLabel : '',\n },\n {\n id: 2,\n title: dictionary.recipient,\n message: recipientName,\n },\n {\n id: 3,\n title: dictionary.sender,\n message: senderName,\n },\n {\n id: 4,\n title: dictionary.message,\n message,\n },\n ];\n\n const noProductGiftOptionsApplied = productGiftOptionsConfig.every(\n ({ message }) => !message\n );\n\n if (view === 'product' && !noProductGiftOptionsApplied) {\n return (\n <Accordion\n data-testid=\"gift-options-product\"\n iconClose={ChevronUp}\n iconOpen={ChevronDown}\n actionIconPosition=\"right\"\n >\n <AccordionSection\n title={dictionary.readOnlyProductTitle}\n showIconLeft={true}\n iconLeft={Gift}\n defaultOpen={false}\n renderContentWhenClosed={false}\n >\n <div>\n {productGiftOptionsConfig\n .filter((element) => element.message)\n .map((config) => {\n return (\n <p key={config.id}>\n {config.title} {config.message}\n </p>\n );\n })}\n </div>\n </AccordionSection>\n </Accordion>\n );\n }\n\n if (view === 'order' && (isGiftMessageProvided || shouldRenderGiftOptions)) {\n const renderHeader = (\n <div className=\"cart-gift-options-readonly__header\">\n <Icon source={Gift} size=\"24\" />\n <span>{dictionary.readOnlyOrderTitle}</span>\n </div>\n );\n\n const selectedGiftOptions = (\n <>\n {giftReceiptIncluded ? (\n <div className=\"cart-gift-options-readonly__checkboxes cart-gift-options-readonly__checkboxes--gift-receipt\">\n <Icon source={CheckWithCircle} size=\"16\" />\n <p>{dictionary.readOnlyOrderGiftReceiptTitle}</p>\n <p>{dictionary.readOnlyOrderGiftReceiptText}</p>\n </div>\n ) : null}\n {printedCardIncluded ? (\n <div className=\"cart-gift-options-readonly__checkboxes cart-gift-options-readonly__checkboxes--print-card\">\n <Icon source={CheckWithCircle} size=\"16\" />\n <p>{dictionary.readOnlyOrderGiftPrintCardTitle}</p>\n <p>{dictionary.readOnlyOrderGiftPrintCardText}</p>\n </div>\n ) : null}\n {giftWrapCart?.selected ? (\n <div className=\"cart-gift-options-readonly__checkboxes cart-gift-options-readonly__checkboxes--gift-wrap\">\n <Icon source={CheckWithCircle} size=\"16\" />\n <p>\n {dictionary.readOnlyOrderGiftWrapTitle} (+\n <Price\n amount={giftWrapCart.price.value}\n currency={giftWrapCart.price.currency}\n weight=\"normal\"\n />\n )\n </p>\n <p>{`${dictionary.readOnlyOrderGiftWrapOptionsText} ${giftWrapCart?.design}`}</p>\n </div>\n ) : null}\n </>\n );\n\n const enteredGiftMessage = isGiftMessageProvided ? (\n <div className=\"cart-gift-options-readonly__form\">\n <div>{dictionary.readOnlyOrderFormTitle}</div>\n <div>\n <p>\n <span>{dictionary.readOnlyOrderFormTo}</span>\n <span>{recipientName}</span>\n </p>\n <p>\n <span>{dictionary.readOnlyOrderFormFrom}</span>\n <span>{senderName}</span>\n </p>\n </div>\n <div>\n <p>{dictionary.readOnlyOrderFormMessageTitle}</p>\n <p>{message}</p>\n </div>\n </div>\n ) : null;\n\n return (\n <Card variant={readOnlyFormOrderView}>\n {renderHeader}\n {selectedGiftOptions}\n {enteredGiftMessage}\n </Card>\n );\n }\n\n return null;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useCallback, StateUpdater, Dispatch } from 'preact/hooks';\nimport { FunctionComponent, JSX, VNode } from 'preact';\nimport { GiftOptionModal } from './Elements/GiftOptionModal';\nimport { GiftLoader } from './Elements/GiftLoader';\nimport { CheckboxGroup } from './Elements/CheckboxGroup';\nimport { FormFields } from './Elements/FormFields';\nimport { ReadOnlyFormView } from './Elements/ReadOnlyFormView';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport {\n Accordion,\n AccordionSection,\n Card,\n Icon,\n ImageNodeRenderProps,\n ProgressSpinner,\n} from '@adobe-commerce/elsie/components';\nimport {\n ChevronDown,\n ChevronUp,\n CheckWithCircle,\n Gift,\n} from '@adobe-commerce/elsie/icons';\nimport {\n GiftWrappingConfigProps,\n GiftOptionsViewProps,\n GiftFormDataType,\n GiftOptionsReadOnlyViewProps,\n ProductGiftOptionsConfig,\n} from '@/cart/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { CartModel, Item } from '@/cart/data/models';\nimport '@/cart/components/GiftOptions/GiftOptions.css';\n\nexport interface GiftOptionsProps {\n readOnlyFormOrderView: GiftOptionsReadOnlyViewProps;\n cartData: CartModel | null;\n errorsField: Record<string, string>;\n isGiftMessageVisible: boolean;\n fieldsDisabled: boolean;\n loading: boolean;\n showModal: boolean;\n isEditable: boolean;\n isGiftOptionsApplied: boolean;\n updateLoading: boolean;\n areGiftOptionsVisible: Record<string, boolean>;\n view: GiftOptionsViewProps;\n giftOptions: GiftFormDataType;\n imageSwatchImageNode?: VNode | ((props: ImageNodeRenderProps) => JSX.Element);\n item: Item | ProductGiftOptionsConfig;\n giftWrappingConfig: GiftWrappingConfigProps[] | [];\n updateGiftOptions: (\n name: string,\n value?: string | boolean | number,\n extraGiftOptions?: Record<string, string | boolean | number>\n ) => void;\n setShowModal: Dispatch<StateUpdater<boolean>>;\n handleFormMouseLeave: () => void;\n onInputChange: (event: Event) => void;\n onBlur: (event: Event) => void;\n}\n\nexport const GiftOptions: FunctionComponent<GiftOptionsProps> = ({\n item,\n view,\n loading,\n giftOptions,\n showModal,\n isEditable,\n errorsField,\n updateLoading,\n cartData,\n fieldsDisabled,\n isGiftOptionsApplied,\n giftWrappingConfig,\n readOnlyFormOrderView,\n isGiftMessageVisible,\n areGiftOptionsVisible,\n imageSwatchImageNode,\n onBlur,\n setShowModal,\n updateGiftOptions,\n onInputChange,\n handleFormMouseLeave,\n}) => {\n const dictionary = useText({\n accordionHeading: `Cart.GiftOptions.${view}.accordionHeading`,\n });\n\n const renderAccordion = useCallback(\n (defaultOpen: boolean) => {\n return (\n <Accordion\n data-testid=\"gift-options-product\"\n iconClose={ChevronUp}\n iconOpen={ChevronDown}\n actionIconPosition=\"right\"\n >\n <AccordionSection\n title={\n <div className=\"cart-gift-options-view__icon--success\">\n <span>{dictionary.accordionHeading}</span>\n {isGiftOptionsApplied ? (\n <Icon source={CheckWithCircle} size=\"16\" />\n ) : null}\n </div>\n }\n ariaLabelTitle={dictionary.accordionHeading}\n showIconLeft={true}\n iconLeft={Gift}\n defaultOpen={isGiftOptionsApplied || defaultOpen}\n renderContentWhenClosed={false}\n >\n <>\n <CheckboxGroup\n className={'cart-gift-options-view__top'}\n view={view}\n item={item}\n giftOptions={giftOptions}\n disabled={fieldsDisabled}\n onInputChange={onInputChange}\n cartData={cartData}\n giftWrappingConfig={giftWrappingConfig}\n setShowModal={setShowModal}\n areGiftOptionsVisible={areGiftOptionsVisible}\n />\n <form\n className=\"cart-gift-options-view__footer\"\n onMouseLeave={handleFormMouseLeave}\n >\n <FormFields\n view={view}\n giftOptions={giftOptions}\n disabled={fieldsDisabled}\n errorMessage={errorsField}\n onInputChange={onInputChange}\n onBlur={onBlur}\n isGiftMessageVisible={isGiftMessageVisible}\n />\n </form>\n </>\n </AccordionSection>\n </Accordion>\n );\n },\n [\n view,\n item,\n cartData,\n dictionary,\n errorsField,\n giftOptions,\n fieldsDisabled,\n giftWrappingConfig,\n areGiftOptionsVisible,\n isGiftOptionsApplied,\n isGiftMessageVisible,\n onBlur,\n setShowModal,\n onInputChange,\n handleFormMouseLeave,\n ]\n );\n\n if (!areGiftOptionsVisible.isGiftOptionsVisible && !isGiftMessageVisible) {\n return null;\n }\n\n return (\n <div\n id=\"cart-gift-options-view\"\n className={classes([\n 'cart-gift-options-view',\n `cart-gift-options-view--${view}`,\n ['cart-gift-options-view--loading', updateLoading],\n ])}\n >\n {updateLoading ? (\n <ProgressSpinner className=\"cart-gift-options-view__spinner\" />\n ) : null}\n {!loading ? (\n <>\n {!isEditable ? (\n <div className={'cart-gift-options-view--readonly'}>\n <ReadOnlyFormView\n view={view}\n giftOptions={giftOptions}\n giftWrappingConfig={giftWrappingConfig}\n readOnlyFormOrderView={readOnlyFormOrderView}\n />\n </div>\n ) : null}\n {showModal ? (\n <GiftOptionModal\n view={view}\n productName={item && 'name' in item ? item?.name : ''}\n showModal={showModal}\n giftWrappingConfig={giftWrappingConfig}\n setShowModal={() => setShowModal(false)}\n updateGiftOptions={updateGiftOptions}\n imageSwatchImageNode={imageSwatchImageNode}\n />\n ) : null}\n {view === 'product' && isEditable ? renderAccordion(false) : null}\n {view === 'order' && isEditable ? (\n <Card variant={'secondary'}>{renderAccordion(true)}</Card>\n ) : null}\n </>\n ) : (\n <GiftLoader />\n )}\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CartModel, Item } from '@/cart/data/models';\nimport { state } from '@/cart/lib/state';\nimport {\n GiftWrappingConfigProps,\n GiftOptionsViewProps,\n ProductGiftOptionsConfig,\n} from '@/cart/types';\n\n// This helper is specifically designed for small functions needed in useGiftOptions for formSections configuration manipulation.\nexport const DEFAULT_FORM_STATE = {\n recipientName: '',\n senderName: '',\n message: '',\n};\n\nexport const DEFAULT_CHECKBOXES_STATE = {\n giftReceiptIncluded: false,\n printedCardIncluded: false,\n isGiftWrappingSelected: false,\n};\n\nexport const shouldShowGiftMessage = (\n item: CartModel['items'][0] | ProductGiftOptionsConfig,\n isProductView: boolean\n) => {\n if (!isProductView) return !!state.config?.allowGiftMessageOnOrder;\n\n const allowGiftMessageOnOrderItems =\n state.config?.allowGiftMessageOnOrderItems ?? false;\n\n return typeof item?.giftMessageAvailable === 'boolean'\n ? item?.giftMessageAvailable\n : allowGiftMessageOnOrderItems;\n};\n\nexport const getSelectedGiftWrapping = (\n giftWrappingOptions: GiftWrappingConfigProps[] | []\n): GiftWrappingConfigProps | undefined => {\n const fallbackGiftWrappingData = {\n uid: '',\n design: '',\n selected: false,\n image: {\n url: '',\n design: '',\n },\n price: {\n currency: 'USD',\n value: 0,\n },\n };\n\n if (!giftWrappingOptions || giftWrappingOptions.length === 0) {\n return fallbackGiftWrappingData;\n }\n\n const isNotSelected = giftWrappingOptions?.every((wrap) => !wrap.selected);\n\n if (isNotSelected) {\n return giftWrappingOptions[0];\n }\n\n return giftWrappingOptions.find((wrap) => wrap.selected);\n};\n\nexport const areGiftOptionsDisabled = (\n view: GiftOptionsViewProps,\n item: Item | ProductGiftOptionsConfig\n) => {\n const {\n allowGiftWrappingOnOrder,\n allowGiftWrappingOnOrderItems,\n allowGiftMessageOnOrder,\n allowGiftMessageOnOrderItems,\n allowGiftReceipt,\n allowPrintedCard,\n } = state.config || {};\n\n const isGiftOptionsOnProductDisabled =\n !allowGiftMessageOnOrderItems &&\n !allowGiftWrappingOnOrderItems &&\n !shouldShowGiftMessage(item, true);\n\n const isGiftOptionsOnOrderDisabled =\n !allowGiftWrappingOnOrder &&\n !allowGiftMessageOnOrder &&\n !allowGiftReceipt &&\n !allowPrintedCard;\n\n if (view === 'product' && isGiftOptionsOnProductDisabled) {\n return true;\n }\n\n if (view === 'order' && isGiftOptionsOnOrderDisabled) {\n return true;\n }\n\n return false;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useCallback, useEffect, useState, useMemo } from 'preact/hooks';\nimport { events } from '@adobe-commerce/event-bus';\nimport { CartModel, Item } from '@/cart/data/models';\nimport { setGiftOptionsOnCart, updateProductsFromCart } from '@/cart/api';\nimport {\n DEFAULT_FORM_STATE,\n DEFAULT_CHECKBOXES_STATE,\n shouldShowGiftMessage,\n areGiftOptionsDisabled,\n} from '@/cart/lib/giftOptionsHelper';\nimport {\n GiftOptionsDataSourcesProps,\n GiftOptionsViewProps,\n GiftWrappingConfigProps,\n GiftFormDataType,\n ProductGiftOptionsConfig,\n} from '@/cart/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { state } from '@/cart/lib/state';\n\nexport interface UseGiftOptionsProps {\n item: Item | ProductGiftOptionsConfig;\n view: GiftOptionsViewProps;\n dataSource: GiftOptionsDataSourcesProps;\n initialLoading: boolean;\n handleItemsLoading?: (uid: string, state: boolean) => void;\n handleItemsError?: (uid: string, message?: string) => void;\n onItemUpdate?: ({ item }: { item: Item }) => void;\n onGiftOptionsChange?: (data: GiftFormDataType) => void;\n}\n\nexport const useGiftOptions = ({\n item,\n view,\n dataSource,\n initialLoading,\n handleItemsLoading,\n handleItemsError,\n onItemUpdate,\n onGiftOptionsChange,\n}: UseGiftOptionsProps) => {\n const isProductView = view === 'product';\n\n const dictionary = useText({\n requiredFieldError: 'Cart.GiftOptions.formText.requiredFieldError',\n });\n\n const [loading, setLoading] = useState(() => initialLoading);\n const [areGiftOptionsVisible, setAreGiftOptionsVisible] = useState({\n isGiftReceiptVisible: true,\n isPrintedCartVisible: true,\n isGiftWrappingVisible: true,\n isGiftOptionsVisible: true,\n });\n const [isGiftMessageVisible, setIsGiftMessageVisible] = useState(true);\n const [updateLoading, setUpdateLoading] = useState(false);\n const [fieldsDisabled, setFieldsDisabled] = useState(false);\n const [isDataChanged, setIsDataChanged] = useState(false);\n const [isFormTouched, setIsFormTouched] = useState(false);\n const [showModal, setShowModal] = useState<boolean>(false);\n const [giftWrappingConfig, setGiftWrappingConfig] = useState<\n GiftWrappingConfigProps[] | []\n >([]);\n const [cartData, setCartData] = useState<CartModel | null>(null);\n const [errorsField, setErrorsField] =\n useState<typeof DEFAULT_FORM_STATE>(DEFAULT_FORM_STATE);\n const [giftOptions, setGiftOptions] = useState<GiftFormDataType>(() => ({\n giftWrappingId: '',\n ...DEFAULT_FORM_STATE,\n ...DEFAULT_CHECKBOXES_STATE,\n }));\n\n const isFormFilled =\n giftOptions.recipientName?.trim() &&\n giftOptions.senderName?.trim() &&\n giftOptions.message?.trim();\n\n const isFormEmpty =\n !giftOptions.recipientName?.trim() &&\n !giftOptions.senderName?.trim() &&\n !giftOptions.message?.trim();\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const applyGiftOptionsToCart = useCallback(\n async (updatedGiftOptions: GiftFormDataType) => {\n // Update loading state used to render loading indicator required only in order view\n setUpdateLoading(view === 'order');\n setFieldsDisabled(true);\n\n switch (view) {\n case 'product':\n {\n if ('uid' in item) {\n handleItemsLoading?.(item.uid, true);\n handleItemsError?.(item.uid);\n }\n\n const {\n recipientName,\n senderName,\n message,\n giftWrappingId,\n isGiftWrappingSelected,\n } = updatedGiftOptions;\n\n const giftOptions = {\n gift_message: {\n to: recipientName ?? '',\n from: senderName ?? '',\n message: message ?? '',\n },\n gift_wrapping_id: isGiftWrappingSelected ? giftWrappingId : null,\n };\n\n if ('uid' in item && 'quantity' in item) {\n await updateProductsFromCart([\n {\n uid: item.uid,\n quantity: item.quantity,\n giftOptions,\n },\n ])\n .then(() => {\n onItemUpdate?.({ item });\n })\n .finally(() => {\n handleItemsLoading?.(item.uid, false);\n setFieldsDisabled(false);\n setIsDataChanged(false);\n setUpdateLoading(false);\n })\n .catch((error: any) => {\n console.warn(error);\n });\n }\n }\n break;\n case 'order':\n await setGiftOptionsOnCart(updatedGiftOptions).finally(() => {\n setFieldsDisabled(false);\n setIsDataChanged(false);\n setUpdateLoading(false);\n });\n break;\n default:\n console.error(\n 'Incorrect \"view\" prop value provided for GiftOptions container (storefront-cart)'\n );\n break;\n }\n },\n [handleItemsError, handleItemsLoading, item, onItemUpdate, view]\n );\n\n const updateGiftOptions = useCallback(\n (\n name: string,\n value: string | boolean | number | undefined,\n extraGiftOptions: Record<string, string | boolean | number> = {}\n ) => {\n setGiftOptions((prevGiftOptions: GiftFormDataType) => {\n const isValidGiftFormKey = (\n key: string\n ): key is keyof GiftFormDataType => key in prevGiftOptions;\n\n const getPrevValue = (key: string) =>\n isValidGiftFormKey(key) ? prevGiftOptions[key] : undefined;\n\n const hasChanged =\n getPrevValue(name) !== value ||\n Object.keys(extraGiftOptions).some(\n (key) => getPrevValue(key) !== extraGiftOptions[key]\n );\n\n if (!hasChanged) {\n onGiftOptionsChange?.(prevGiftOptions);\n return prevGiftOptions;\n }\n\n const updatedGiftOptions = {\n ...prevGiftOptions,\n [name]: value,\n ...extraGiftOptions,\n };\n\n if (\n !updatedGiftOptions.recipientName &&\n !updatedGiftOptions.senderName &&\n !updatedGiftOptions.message\n ) {\n setIsFormTouched(true);\n }\n\n if (\n typeof value === 'boolean' ||\n [\n 'giftWrappingId',\n 'giftReceiptIncluded',\n 'printedCardIncluded',\n ].includes(name)\n ) {\n setIsFormTouched(false);\n typeof onGiftOptionsChange === 'function'\n ? onGiftOptionsChange(updatedGiftOptions)\n : applyGiftOptionsToCart(updatedGiftOptions);\n }\n\n setIsDataChanged(true);\n\n onGiftOptionsChange?.(updatedGiftOptions);\n return updatedGiftOptions;\n });\n },\n [applyGiftOptionsToCart, onGiftOptionsChange]\n );\n\n const handleFormMouseLeave = useCallback(\n async () => {\n // Fields disabled if other event handler already triggered\n if (fieldsDisabled) return;\n if (typeof onGiftOptionsChange === 'function') return;\n\n // Case when user removed all form fields - reset to initial state\n if (isFormEmpty && isFormTouched) {\n setErrorsField(DEFAULT_FORM_STATE);\n setIsFormTouched(false);\n await applyGiftOptionsToCart(giftOptions);\n }\n\n // Case when user edited one of form fields\n if (isDataChanged && isFormFilled) {\n setIsFormTouched(true);\n await applyGiftOptionsToCart(giftOptions);\n }\n },\n [\n applyGiftOptionsToCart,\n giftOptions,\n isDataChanged,\n isFormEmpty,\n isFormTouched,\n fieldsDisabled,\n onGiftOptionsChange,\n isFormFilled\n ]\n );\n\n const handleBlur = useCallback(\n async (event: Event) => {\n // Fields disabled if other event handler already triggered\n if (fieldsDisabled) return;\n if (typeof onGiftOptionsChange === 'function') return;\n\n const { name, value } = event.target as HTMLInputElement;\n\n setErrorsField((prevErrors: typeof DEFAULT_FORM_STATE) => ({\n ...prevErrors,\n [name]: value.trim() ? '' : dictionary.requiredFieldError,\n }));\n\n // Case when user removed all form fields - reset to initial state\n if (isFormEmpty && isFormTouched) {\n setErrorsField(DEFAULT_FORM_STATE);\n setIsFormTouched(false);\n await applyGiftOptionsToCart(giftOptions);\n }\n\n if (isDataChanged && isFormFilled) {\n await applyGiftOptionsToCart(giftOptions);\n }\n },\n [\n fieldsDisabled,\n isFormEmpty,\n isFormTouched,\n isDataChanged,\n isFormFilled,\n dictionary,\n applyGiftOptionsToCart,\n giftOptions,\n onGiftOptionsChange,\n ]\n );\n\n const onInputChange = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const name = target.name;\n const value = target.type === 'checkbox' ? target.checked : target.value;\n\n updateGiftOptions(name, value);\n },\n [updateGiftOptions]\n );\n\n useEffect(() => {\n if (isProductView) return;\n\n const dataEvent = events.on(\n // @ts-ignore\n dataSource === 'cart' ? 'cart/data' : 'order/data',\n (payload: CartModel) => {\n setCartData(payload);\n // Gift wrapping is allowed for the cart if at least one item has gift wrapping available\n const isCartGiftWrappingAllowed = payload?.items?.some(\n ({ giftWrappingAvailable }: { giftWrappingAvailable: boolean }) =>\n giftWrappingAvailable\n );\n const isCartGiftWrappingApplied = payload?.cartGiftWrapping?.some(\n (wrap: GiftWrappingConfigProps) => wrap.selected\n );\n\n // If gift wrapping is not allowed and it is applied, remove it\n if (!isCartGiftWrappingAllowed && isCartGiftWrappingApplied) {\n applyGiftOptionsToCart({\n ...giftOptions,\n giftWrappingId: '',\n isGiftWrappingSelected: false,\n });\n }\n },\n { eager: true }\n );\n return () => {\n dataEvent?.off();\n };\n }, [setCartData, applyGiftOptionsToCart, dataSource, giftOptions, isProductView]);\n\n const giftOptionsState: GiftFormDataType | null = useMemo(() => {\n if (!cartData && !item) return null;\n\n const giftWrappingOptions: GiftWrappingConfigProps[] = isProductView\n ? item?.productGiftWrapping?.map(\n (wrap: GiftWrappingConfigProps): GiftWrappingConfigProps => ({\n ...wrap,\n price:\n item?.giftWrappingPrice && item?.giftWrappingPrice?.value > 0\n ? item.giftWrappingPrice\n : wrap.price,\n })\n )\n : cartData?.cartGiftWrapping || [];\n\n const selectedWrap = giftWrappingOptions?.find((wrap) => wrap.selected);\n const selectedGiftWrappingId =\n selectedWrap?.uid ?? giftWrappingOptions?.[0]?.uid;\n\n const isGiftWrappingSelected = !!selectedWrap;\n\n const giftMessageConfig = isProductView\n ? item.giftMessage\n : cartData?.giftMessage;\n const printedCardIncluded = cartData?.printedCardIncluded;\n const giftReceiptIncluded = cartData?.giftReceiptIncluded;\n\n const giftMessageAvailable = shouldShowGiftMessage(item, isProductView);\n\n const allowGiftWrappingOnOrder = state.config?.allowGiftWrappingOnOrder;\n const allowGiftReceipt = state.config?.allowGiftReceipt;\n const allowPrintedCard = state.config?.allowPrintedCard;\n const isGiftWrappingAvailableForSome = cartData?.items?.some(\n (item: { giftWrappingAvailable: boolean }) => item.giftWrappingAvailable\n );\n const allowGiftWrappingOnProduct = item?.giftWrappingAvailable;\n const isGiftReceiptVisible = isProductView ? false : !!allowGiftReceipt;\n const isPrintedCartVisible = isProductView ? false : !!allowPrintedCard;\n const isGiftWrappingVisible = isProductView\n ? !!allowGiftWrappingOnProduct && !!giftWrappingOptions.length\n : !!allowGiftWrappingOnOrder &&\n !!giftWrappingOptions.length &&\n !!isGiftWrappingAvailableForSome;\n const checkBoxesIsHidden =\n !isGiftReceiptVisible && !isPrintedCartVisible && !isGiftWrappingVisible;\n\n setAreGiftOptionsVisible({\n isGiftReceiptVisible,\n isPrintedCartVisible,\n isGiftWrappingVisible,\n isGiftOptionsVisible: !checkBoxesIsHidden,\n });\n setIsGiftMessageVisible(giftMessageAvailable);\n\n return {\n ...(item && 'uid' in item ? { itemId: item.uid } : {}),\n ...(!isProductView\n ? {\n printedCardIncluded,\n giftReceiptIncluded,\n }\n : {}),\n ...giftMessageConfig,\n giftWrappingId: selectedGiftWrappingId,\n isGiftWrappingSelected,\n giftWrappingOptions,\n };\n }, [cartData, item, isProductView]);\n\n useEffect(() => {\n if (!giftOptionsState) return;\n\n const { giftWrappingOptions, ...giftOptionsFetchData } = giftOptionsState;\n\n setGiftOptions(giftOptionsFetchData);\n\n if (giftWrappingOptions?.length) {\n setGiftWrappingConfig(giftWrappingOptions);\n }\n\n setLoading(false);\n }, [giftOptionsState]);\n\n const isGiftOptionsApplied = useMemo(() => {\n return Object.entries(giftOptions)\n .filter(([key]) => key !== 'itemId' && key !== 'giftWrappingId')\n .some(([, value]) => Boolean(value));\n }, [giftOptions]);\n\n const isGiftOptionsHidden = useMemo(() => {\n return !loading && !!state?.config && areGiftOptionsDisabled(view, item);\n }, [item, loading, view]);\n\n return {\n loading,\n giftOptions,\n showModal,\n errorsField,\n updateLoading,\n cartData,\n fieldsDisabled,\n isGiftOptionsApplied,\n giftWrappingConfig,\n setFieldsDisabled,\n handleFormMouseLeave,\n onInputChange,\n updateGiftOptions,\n setShowModal,\n handleBlur,\n isGiftMessageVisible,\n areGiftOptionsVisible,\n isGiftOptionsHidden,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { GiftOptions as GiftOptionsComponent } from '@/cart/components';\nimport { Item } from '@/cart/data/models';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { useGiftOptions } from '@/cart/hooks/useGiftOptions';\nimport {\n GiftOptionsViewProps,\n GiftOptionsDataSourcesProps,\n GiftFormDataType,\n ProductGiftOptionsConfig,\n GiftOptionsReadOnlyViewProps,\n} from '@/cart/types';\nimport { ImageNodeRenderProps, ImageProps } from '@adobe-commerce/elsie/components';\n\nexport interface GiftOptionsProps {\n item: Item | ProductGiftOptionsConfig;\n view?: GiftOptionsViewProps;\n readOnlyFormOrderView: GiftOptionsReadOnlyViewProps;\n dataSource?: GiftOptionsDataSourcesProps;\n isEditable?: boolean;\n initialLoading?: boolean;\n handleItemsLoading?: (uid: string, state: boolean) => void;\n handleItemsError?: (uid: string, message?: string) => void;\n onItemUpdate?: ({ item }: { item: Item }) => void;\n onGiftOptionsChange?: (data: GiftFormDataType) => void;\n slots?: {\n SwatchImage?: SlotProps<{ \n item: Item | ProductGiftOptionsConfig\n imageSwatchContext: ImageNodeRenderProps['imageSwatchContext']\n defaultImageProps: ImageProps\n }>;\n };\n}\n\nexport const GiftOptions: Container<GiftOptionsProps> = ({\n item,\n view = 'order',\n readOnlyFormOrderView = 'primary',\n dataSource = 'cart',\n isEditable = true,\n initialLoading = true,\n slots,\n handleItemsLoading,\n handleItemsError,\n onItemUpdate,\n onGiftOptionsChange,\n}: GiftOptionsProps) => {\n const {\n isGiftMessageVisible,\n areGiftOptionsVisible,\n loading,\n giftOptions,\n showModal,\n errorsField,\n updateLoading,\n cartData,\n isGiftOptionsApplied,\n fieldsDisabled,\n giftWrappingConfig,\n handleFormMouseLeave,\n updateGiftOptions,\n setShowModal,\n onInputChange,\n handleBlur,\n isGiftOptionsHidden,\n } = useGiftOptions({\n item,\n view,\n dataSource,\n initialLoading,\n handleItemsLoading,\n handleItemsError,\n onItemUpdate,\n onGiftOptionsChange,\n });\n\n if (isGiftOptionsHidden) {\n return null;\n }\n\n return (\n <GiftOptionsComponent\n item={item}\n view={view}\n loading={loading}\n onBlur={handleBlur}\n giftOptions={giftOptions}\n showModal={showModal}\n isEditable={isEditable}\n errorsField={errorsField}\n setShowModal={setShowModal}\n updateLoading={updateLoading}\n updateGiftOptions={updateGiftOptions}\n cartData={cartData}\n isGiftOptionsApplied={isGiftOptionsApplied}\n fieldsDisabled={fieldsDisabled}\n giftWrappingConfig={giftWrappingConfig}\n handleFormMouseLeave={handleFormMouseLeave}\n readOnlyFormOrderView={readOnlyFormOrderView}\n onInputChange={onInputChange}\n isGiftMessageVisible={isGiftMessageVisible}\n areGiftOptionsVisible={areGiftOptionsVisible}\n imageSwatchImageNode={\n slots?.SwatchImage ? ({ imageSwatchContext, ...defaultImageProps }) => (\n // No need to provide default content, as the slot will only be rendered if it's actually provided.\n <Slot \n name=\"SwatchImage\"\n slotTag='span'\n contentTag='span'\n slot={slots.SwatchImage} \n context={{ item, imageSwatchContext, defaultImageProps }} \n />\n ) : undefined\n }\n />\n );\n};\n"],"names":["SvgCheckWithCircle","props","React","SvgGift","useFocusTrap","showModal","containerRef","useRef","useEffect","container","focusableElements","firstElement","lastElement","handleKeyDown","event","GiftOptionModal","view","productName","giftWrappingConfig","imageSwatchImageNode","setShowModal","updateGiftOptions","dictionary","useText","giftWrappingItem","setGiftWrappingItem","useState","selectedGiftWrapping","item","focusElement","renderTitle","jsx","jsxs","Modal","Fragment","_a","Price","ContentGrid","wrapItem","ImageSwatch","Button","GiftLoader","Skeleton","SkeletonRow","CheckboxGroup","className","giftOptions","disabled","cartData","onInputChange","areGiftOptionsVisible","id","useId","productGiftWrappingOptions","orderGiftWrappingOptions","giftWrappingOptions","el","selectedGiftWrappingLabel","productGiftWrappingPrice","renderSelectedGiftWrappingLabel","printedCardPrice","_b","state","_c","productWrappingPrice","_d","renderPrice","price","classes","Field","Checkbox","FormFields","errorMessage","onBlur","isGiftMessageVisible","Input","TextArea","ReadOnlyFormView","readOnlyFormOrderView","recipientName","senderName","message","giftReceiptIncluded","printedCardIncluded","isGiftWrappingSelected","giftWrapCart","uid","isGiftMessageProvided","giftWrapProductSelectLabel","shouldRenderGiftOptions","productGiftOptionsConfig","noProductGiftOptionsApplied","Accordion","ChevronUp","ChevronDown","AccordionSection","Gift","element","config","renderHeader","Icon","selectedGiftOptions","CheckWithCircle","enteredGiftMessage","Card","GiftOptions","loading","isEditable","errorsField","updateLoading","fieldsDisabled","isGiftOptionsApplied","handleFormMouseLeave","renderAccordion","useCallback","defaultOpen","ProgressSpinner","DEFAULT_FORM_STATE","DEFAULT_CHECKBOXES_STATE","shouldShowGiftMessage","isProductView","allowGiftMessageOnOrderItems","areGiftOptionsDisabled","allowGiftWrappingOnOrder","allowGiftWrappingOnOrderItems","allowGiftMessageOnOrder","allowGiftReceipt","allowPrintedCard","isGiftOptionsOnProductDisabled","isGiftOptionsOnOrderDisabled","useGiftOptions","dataSource","initialLoading","handleItemsLoading","handleItemsError","onItemUpdate","onGiftOptionsChange","setLoading","setAreGiftOptionsVisible","setIsGiftMessageVisible","setUpdateLoading","setFieldsDisabled","isDataChanged","setIsDataChanged","isFormTouched","setIsFormTouched","setGiftWrappingConfig","setCartData","setErrorsField","setGiftOptions","isFormFilled","isFormEmpty","_e","_f","applyGiftOptionsToCart","updatedGiftOptions","giftWrappingId","updateProductsFromCart","error","setGiftOptionsOnCart","name","value","extraGiftOptions","prevGiftOptions","isValidGiftFormKey","key","getPrevValue","handleBlur","prevErrors","target","dataEvent","events","payload","isCartGiftWrappingAllowed","giftWrappingAvailable","isCartGiftWrappingApplied","wrap","giftOptionsState","useMemo","selectedWrap","selectedGiftWrappingId","giftMessageConfig","giftMessageAvailable","isGiftWrappingAvailableForSome","allowGiftWrappingOnProduct","isGiftReceiptVisible","isPrintedCartVisible","isGiftWrappingVisible","giftOptionsFetchData","isGiftOptionsHidden","slots","GiftOptionsComponent","imageSwatchContext","defaultImageProps","Slot"],"mappings":"8nCACA,MAAMA,GAAsBC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAK,EAAoBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,0JAA2J,OAAQ,cAAc,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,qCAAsC,OAAQ,cAAc,CAAE,CAAC,ECAxlBC,GAAWF,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAO,EAAkBC,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A,WAAAmH,EACA,eAAAC,EACA,mBAAAC,EACA,iBAAAC,EACA,aAAAC,EACA,oBAAAC,CAAA,CACD,EAED,OAAIqD,GACK,KAIP9J,EAACgK,GAAA,CACC,KAAAnK,EACA,KAAAZ,EACA,QAAA0F,EACA,OAAQ6D,EACR,YAAAzH,EACA,UAAAzC,EACA,WAAAsG,EACA,YAAAC,EACA,aAAAxF,EACA,cAAAyF,EACA,kBAAAxF,EACA,SAAA2B,EACA,qBAAA+D,EACA,eAAAD,EACA,mBAAA5F,EACA,qBAAA8F,EACA,sBAAAlC,EACA,cAAA7B,EACA,qBAAAyB,EACA,sBAAAxB,EACA,qBACE4I,GAAA,MAAAA,EAAO,YAAc,CAAC,CAAE,mBAAAE,EAAoB,GAAGC,CAAkB,IAE/DlK,EAACmK,GAAA,CACC,KAAK,cACL,QAAQ,OACR,WAAW,OACX,KAAMJ,EAAM,YACZ,QAAS,CAAE,KAAAlK,EAAM,mBAAAoK,EAAoB,kBAAAC,CAAkB,CAAA,CAAA,EAEvD,MAAA,CAER,CAEJ","x_google_ignoreList":[0,1]}
|
package/containers/MiniCart.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as e,jsxs as
|
|
3
|
+
import{jsx as e,jsxs as d,Fragment as B}from"@dropins/tools/preact-jsx-runtime.js";import{useState as O,useEffect as j,useCallback as V}from"@dropins/tools/preact-compat.js";import{classes as y,VComponent as o,Slot as _}from"@dropins/tools/lib.js";import{g as Y}from"../chunks/persisted-data.js";import{events as $}from"@dropins/tools/event-bus.js";import{Button as k,Price as P}from"@dropins/tools/components.js";/* empty css */import{useText as T}from"@dropins/tools/i18n.js";import"@dropins/tools/preact-hooks.js";import{s as h}from"../chunks/resetCart.js";import{a as q}from"../chunks/acdl.js";import{u as z}from"../chunks/updateProductsFromCart.js";import"../chunks/CartSummaryGrid.js";import{C as J}from"../chunks/CartSummaryList.js";import"../chunks/OrderSummary.js";import"../chunks/CartSummaryTable2.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/refreshCart.js";import"../fragments.js";import"../chunks/EmptyCart2.js";import"../chunks/createGuestCart.js";import"../chunks/WarningWithCircle.js";import"../chunks/ChevronDown.js";import"../chunks/getEstimatedTotals.js";import"../chunks/OrderSummaryLine.js";import"../chunks/ChevronUp.js";import"../chunks/Coupon.js";import"../chunks/GiftCard.js";import"../chunks/EmptyCart.js";import"../chunks/Close.js";const K=({className:x,products:p,productListFooter:b,subtotal:t,subtotalExcludingTaxes:I,preCheckoutSection:m,ctas:a,...f})=>{const l=T({subtotal:"Cart.MiniCart.subtotal",subtotalExcludingTaxes:"Cart.MiniCart.subtotalExcludingTaxes"});return e("div",{...f,className:y(["cart-mini-cart",x]),children:p&&d(B,{children:[e("div",{className:"cart-mini-cart__products","data-testid":"mini-cart-products-wrapper",children:p}),b&&e("div",{className:y(["cart-mini-cart__productListFooter"]),"data-testid":"mini-cart-product-list-footer",children:e(o,{node:b})}),d("div",{className:"cart-mini-cart__footer","data-testid":"mini-cart-subtotals",children:[t&&d("div",{className:"cart-mini-cart__footer__estimated-total","data-testid":"mini-cart-subtotal",children:[l.subtotal,e(o,{node:t})]}),I&&d("div",{className:"cart-mini-cart__footer__estimated-total-excluding-taxes","data-testid":"mini-cart-subtotal-excluding-taxes",children:[l.subtotalExcludingTaxes,e(o,{node:I,className:y(["dropin-price-summary__price","dropin-price-summary__price--muted"])})]}),m&&e("div",{className:y(["cart-mini-cart__preCheckoutSection"]),"data-testid":"mini-cart-pre-checkout-section",children:e(o,{node:m})}),a&&e(o,{node:a,className:"cart-mini-cart__footer__ctas"})]})]})})},W=100,Z=({children:x,initialData:p=null,hideFooter:b=!0,slots:t,routeProduct:I,routeCart:m,routeCheckout:a,routeEmptyCartCTA:f,showDiscount:l,showSavings:S,enableItemRemoval:D=!0,enableQuantityUpdate:A=!1,hideHeading:Q=!1,undo:U=!1,...E})=>{var C,L,N;const[i,F]=O(p),n=(C=h.config)==null?void 0:C.shoppingCartDisplaySetting;j(()=>{const r=$.on("cart/data",c=>{F(c)},{eager:!0});return()=>{r==null||r.off()}},[]);const g=T({cartLink:"Cart.MiniCart.cartLink",checkoutLink:"Cart.MiniCart.checkoutLink"}),v=(r,c)=>z([{uid:r,quantity:c}]),M=r=>v(r,0),u=i==null?void 0:i.hasOutOfStockItems,G=V(r=>{i&&!u&&(r.preventDefault(),q(i,h.locale),setTimeout(()=>{const c=a==null?void 0:a();c&&(window.location.href=c)},W))},[i,u,a]),H=e(_,{name:"ProductList",slot:t==null?void 0:t.ProductList,context:{itemQuantityUpdateHandler:v,itemRemoveHandler:M,totalQuantity:i==null?void 0:i.totalQuantity},children:e(J,{"data-testid":"default-cart-summary-list",routeProduct:I,routeEmptyCartCTA:f,initialData:i,maxItems:(L=h.config)==null?void 0:L.miniCartMaxItemsDisplay,showMaxItems:!!((N=h.config)!=null&&N.miniCartMaxItemsDisplay),hideHeading:Q||!(i!=null&&i.totalQuantity),hideFooter:b,enableRemoveItem:D,enableUpdateItemQuantity:A,showDiscount:l,showSavings:S,undo:U,slots:{Thumbnail:t==null?void 0:t.Thumbnail,Heading:t==null?void 0:t.Heading,EmptyCart:t==null?void 0:t.EmptyCart,Footer:t==null?void 0:t.Footer,ProductAttributes:t==null?void 0:t.ProductAttributes,CartSummaryFooter:t==null?void 0:t.CartSummaryFooter,CartItem:t==null?void 0:t.CartItem,UndoBanner:t==null?void 0:t.UndoBanner,ItemTitle:t==null?void 0:t.ItemTitle,ItemPrice:t==null?void 0:t.ItemPrice,ItemQuantity:t==null?void 0:t.ItemQuantity,ItemTotal:t==null?void 0:t.ItemTotal,ItemSku:t==null?void 0:t.ItemSku,ItemRemoveAction:t==null?void 0:t.ItemRemoveAction}})}),R=r=>e(_,{name:"ProductListFooter",slot:t==null?void 0:t.ProductListFooter,context:{data:r}}),X=r=>e(_,{name:"PreCheckoutSection",slot:t==null?void 0:t.PreCheckoutSection,context:{data:r}}),w=()=>(n==null?void 0:n.subtotal)==="INCLUDING_TAX"||(n==null?void 0:n.subtotal)==="INCLUDING_EXCLUDING_TAX"?{amount:i==null?void 0:i.subtotal.includingTax.value,currency:i==null?void 0:i.subtotal.includingTax.currency,"data-testid":"subtotal-including-tax",style:{font:"inherit"}}:{amount:i==null?void 0:i.subtotal.excludingTax.value,currency:i==null?void 0:i.subtotal.excludingTax.currency,"data-testid":"subtotal-excluding-tax",style:{font:"inherit"}};return e(K,{...E,productListFooter:R(i),subtotal:i!=null&&i.totalQuantity?(i==null?void 0:i.subtotal)&&e(P,{...w()}):void 0,subtotalExcludingTaxes:i!=null&&i.totalQuantity?(i==null?void 0:i.subtotal)&&((n==null?void 0:n.subtotal)==="INCLUDING_EXCLUDING_TAX"?e(P,{amount:i==null?void 0:i.subtotal.excludingTax.value,currency:i==null?void 0:i.subtotal.excludingTax.currency,"data-testid":"subtotal-including-excluding-tax",style:{font:"inherit"}}):void 0):void 0,preCheckoutSection:X(i),ctas:i!=null&&i.totalQuantity?d("div",{children:[a&&e(k,{"data-testid":"route-checkout-button",variant:"primary",href:u?void 0:a(),disabled:u,"aria-disabled":u,onClick:G,children:g.checkoutLink}),m&&e(k,{"data-testid":"route-cart-button",variant:"tertiary",href:m(),children:g.cartLink})]}):void 0,products:H})};Z.getInitialData=async function(){return Y()};export{Z as MiniCart,Z as default};
|
|
4
4
|
//# sourceMappingURL=MiniCart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiniCart.js","sources":["/@dropins/storefront-cart/src/components/MiniCart/MiniCart.tsx","/@dropins/storefront-cart/src/containers/MiniCart/MiniCart.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { VComponent, classes } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nimport '@/cart/components/MiniCart/MiniCart.css';\n\nexport interface MiniCartProps extends HTMLAttributes<HTMLDivElement> {\n products?: VNode;\n productListFooter?: VNode;\n subtotal?: VNode;\n subtotalExcludingTaxes?: VNode;\n preCheckoutSection?: VNode;\n ctas?: VNode;\n}\n\nexport const MiniCart: FunctionComponent<MiniCartProps> = ({\n className,\n products,\n productListFooter,\n subtotal,\n subtotalExcludingTaxes,\n preCheckoutSection,\n ctas,\n ...props\n}) => {\n const dictionary = useText({\n subtotal: 'Cart.MiniCart.subtotal',\n subtotalExcludingTaxes: 'Cart.MiniCart.subtotalExcludingTaxes',\n });\n\n return (\n <div {...props} className={classes(['cart-mini-cart', className])}>\n {/* Content */}\n {products && (\n <>\n <div\n className=\"cart-mini-cart__products\"\n data-testid=\"mini-cart-products-wrapper\"\n >\n {products}\n </div>\n\n {/* Product List Footer */}\n {productListFooter && (\n <div\n className={classes(['cart-mini-cart__productListFooter'])}\n data-testid=\"mini-cart-product-list-footer\"\n >\n <VComponent node={productListFooter} />\n </div>\n )}\n\n <div\n className=\"cart-mini-cart__footer\"\n data-testid=\"mini-cart-subtotals\"\n >\n {/* Subtotal */}\n {subtotal && (\n <div\n className=\"cart-mini-cart__footer__estimated-total\"\n data-testid=\"mini-cart-subtotal\"\n >\n {dictionary.subtotal}\n <VComponent node={subtotal} />\n </div>\n )}\n {/* Subtotal Excluding Taxes */}\n {subtotalExcludingTaxes && (\n <div\n className=\"cart-mini-cart__footer__estimated-total-excluding-taxes\"\n data-testid=\"mini-cart-subtotal-excluding-taxes\"\n >\n {dictionary.subtotalExcludingTaxes}\n <VComponent\n node={subtotalExcludingTaxes}\n className={classes([\n 'dropin-price-summary__price',\n 'dropin-price-summary__price--muted',\n ])}\n />\n </div>\n )}\n\n {/* Pre-checkout section */}\n {preCheckoutSection && (\n <div\n className={classes(['cart-mini-cart__preCheckoutSection'])}\n data-testid=\"mini-cart-pre-checkout-section\"\n >\n <VComponent node={preCheckoutSection} />\n </div>\n )}\n\n {ctas && (\n <VComponent\n node={ctas}\n className=\"cart-mini-cart__footer__ctas\"\n />\n )}\n </div>\n </>\n )}\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n HTMLAttributes,\n useCallback,\n useEffect,\n useState,\n} from 'preact/compat';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { CartModel } from '@/cart/data/models';\nimport { getPersistedCartData } from '@/cart/lib/persisted-data';\nimport { events } from '@adobe-commerce/event-bus';\nimport { MiniCart as MiniCartComponent } from '@/cart/components';\nimport { CartSummaryList } from '@/cart/containers';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Button, ImageProps, Price } from '@adobe-commerce/elsie/components';\nimport { updateProductsFromCart } from '@/cart/api';\nimport { publishInitiateCheckoutEvent } from '@/cart/lib/acdl';\nimport { state } from '@/cart/lib/state';\n\nexport interface MiniCartProps extends HTMLAttributes<HTMLDivElement> {\n routeProduct?: (item: CartModel['items'][0]) => string;\n routeCart?: () => string;\n routeCheckout?: () => string;\n routeEmptyCartCTA?: () => string;\n slots?: {\n ProductList?: SlotProps;\n ProductListFooter?: SlotProps;\n PreCheckoutSection?: SlotProps;\n Thumbnail?: SlotProps<{\n item: CartModel['items'][number];\n defaultImageProps: ImageProps;\n }>;\n Heading?: SlotProps;\n EmptyCart?: SlotProps;\n Footer?: SlotProps;\n ProductAttributes?: SlotProps;\n CartSummaryFooter?: SlotProps;\n CartItem?: SlotProps; // For backward compatibility\n UndoBanner?: SlotProps<{\n item: CartModel['items'][0];\n loading: boolean;\n error?: string;\n onUndo: () => void;\n onDismiss: () => void;\n }>;\n ItemTitle?: SlotProps<{ item: CartModel['items'][number] }>;\n ItemPrice?: SlotProps<{ item: CartModel['items'][number] }>;\n ItemQuantity?: SlotProps<{\n item: CartModel['items'][number];\n enableUpdateItemQuantity: boolean;\n handleItemQuantityUpdate: (\n item: CartModel['items'][number],\n quantity: number\n ) => void;\n itemsLoading: Set<string>;\n handleItemsError: (uid: string, message?: string) => void;\n handleItemsLoading: (uid: string, state: boolean) => void;\n onItemUpdate?: ({ item }: { item: CartModel['items'][number] }) => void;\n }>;\n ItemTotal?: SlotProps<{ item: CartModel['items'][number] }>;\n ItemSku?: SlotProps<{ item: CartModel['items'][number] }>;\n ItemRemoveAction?: SlotProps<{\n item: CartModel['items'][number];\n enableRemoveItem: boolean;\n handleItemQuantityUpdate: (\n item: CartModel['items'][number],\n quantity: number\n ) => void;\n handleItemsError: (uid: string, message?: string) => void;\n handleItemsLoading: (uid: string, state: boolean) => void;\n onItemUpdate?: ({ item }: { item: CartModel['items'][number] }) => void;\n itemsLoading: Set<string>;\n }>;\n };\n hideFooter?: boolean;\n displayAllItems?: boolean;\n showDiscount?: boolean;\n showSavings?: boolean;\n enableItemRemoval?: boolean;\n enableQuantityUpdate?: boolean;\n hideHeading?: boolean;\n undo?: boolean;\n}\n\nexport const MiniCart: Container<MiniCartProps, CartModel | null> = ({\n children,\n initialData = null,\n hideFooter = true, // Default to true for MiniCart\n slots,\n routeProduct,\n routeCart,\n routeCheckout,\n routeEmptyCartCTA,\n showDiscount,\n showSavings,\n enableItemRemoval = true, // Default to true for MiniCart\n enableQuantityUpdate = false, // Default to false for MiniCart\n hideHeading = false, // Default to false for MiniCart\n undo = false,\n ...props\n}) => {\n const [data, setData] = useState<CartModel | null>(initialData);\n const cartTaxesConfig = state.config?.shoppingCartDisplaySetting;\n\n useEffect(() => {\n const event = events.on(\n 'cart/data',\n (payload) => {\n setData(payload as CartModel);\n },\n { eager: true }\n );\n\n return () => {\n event?.off();\n };\n }, []);\n\n const dictionary = useText({\n cartLink: 'Cart.MiniCart.cartLink',\n checkoutLink: 'Cart.MiniCart.checkoutLink',\n });\n\n const handleItemQuantityUpdate = (uid: string, quantity: number) => {\n return updateProductsFromCart([{ uid, quantity }]);\n };\n\n const handleItemRemove = (uid: string) => handleItemQuantityUpdate(uid, 0);\n\n const checkoutLinkDisabled = data?.hasOutOfStockItems;\n\n const handleInitiateCheckout = useCallback(() => {\n if (data && !checkoutLinkDisabled) {\n publishInitiateCheckoutEvent(data, state.locale);\n }\n }, [data, checkoutLinkDisabled]);\n\n const productList = (\n <Slot\n name=\"ProductList\"\n slot={slots?.ProductList}\n context={{\n itemQuantityUpdateHandler: handleItemQuantityUpdate,\n itemRemoveHandler: handleItemRemove,\n totalQuantity: data?.totalQuantity,\n }}\n >\n <CartSummaryList\n data-testid=\"default-cart-summary-list\"\n routeProduct={routeProduct}\n routeEmptyCartCTA={routeEmptyCartCTA}\n initialData={data}\n maxItems={state.config?.miniCartMaxItemsDisplay}\n showMaxItems={!!state.config?.miniCartMaxItemsDisplay}\n hideHeading={hideHeading || !data?.totalQuantity}\n hideFooter={hideFooter}\n enableRemoveItem={enableItemRemoval}\n enableUpdateItemQuantity={enableQuantityUpdate}\n showDiscount={showDiscount}\n showSavings={showSavings}\n undo={undo}\n slots={{\n Thumbnail: slots?.Thumbnail,\n Heading: slots?.Heading,\n EmptyCart: slots?.EmptyCart,\n Footer: slots?.Footer,\n ProductAttributes: slots?.ProductAttributes,\n CartSummaryFooter: slots?.CartSummaryFooter,\n CartItem: slots?.CartItem, // Keep for backward compatibility\n UndoBanner: slots?.UndoBanner,\n ItemTitle: slots?.ItemTitle,\n ItemPrice: slots?.ItemPrice,\n ItemQuantity: slots?.ItemQuantity,\n ItemTotal: slots?.ItemTotal,\n ItemSku: slots?.ItemSku,\n ItemRemoveAction: slots?.ItemRemoveAction,\n }}\n />\n </Slot>\n );\n\n const getProductListFooter = (data: CartModel | null) => {\n return (\n <Slot\n name=\"ProductListFooter\"\n slot={slots?.ProductListFooter}\n context={{\n data,\n }}\n />\n );\n };\n\n const getPreCheckoutSection = (data: CartModel | null) => {\n return (\n <Slot\n name=\"PreCheckoutSection\"\n slot={slots?.PreCheckoutSection}\n context={{\n data,\n }}\n />\n );\n };\n\n const getSubtotalPriceProps = () =>\n cartTaxesConfig?.subtotal === 'INCLUDING_TAX' ||\n cartTaxesConfig?.subtotal === 'INCLUDING_EXCLUDING_TAX'\n ? {\n amount: data?.subtotal.includingTax.value,\n currency: data?.subtotal.includingTax.currency,\n 'data-testid': 'subtotal-including-tax',\n style: { font: 'inherit' },\n }\n : {\n amount: data?.subtotal.excludingTax.value,\n currency: data?.subtotal.excludingTax.currency,\n 'data-testid': 'subtotal-excluding-tax',\n style: { font: 'inherit' },\n };\n\n return (\n <MiniCartComponent\n {...props}\n productListFooter={getProductListFooter(data)}\n subtotal={\n !data?.totalQuantity\n ? undefined\n : data?.subtotal && <Price {...getSubtotalPriceProps()} />\n }\n subtotalExcludingTaxes={\n !data?.totalQuantity\n ? undefined\n : data?.subtotal &&\n (cartTaxesConfig?.subtotal === 'INCLUDING_EXCLUDING_TAX' ? (\n <Price\n amount={data?.subtotal.excludingTax.value}\n currency={data?.subtotal.excludingTax.currency}\n data-testid=\"subtotal-including-excluding-tax\"\n style={{ font: 'inherit' }}\n />\n ) : undefined)\n }\n preCheckoutSection={getPreCheckoutSection(data)}\n ctas={\n !data?.totalQuantity ? undefined : (\n <div>\n {routeCheckout && (\n <Button\n data-testid=\"route-checkout-button\"\n variant=\"primary\"\n href={checkoutLinkDisabled ? undefined : routeCheckout()}\n disabled={checkoutLinkDisabled}\n aria-disabled={checkoutLinkDisabled}\n onClick={handleInitiateCheckout}\n >\n {dictionary.checkoutLink}\n </Button>\n )}\n {routeCart && (\n <Button\n data-testid=\"route-cart-button\"\n variant=\"tertiary\"\n href={routeCart()}\n >\n {dictionary.cartLink}\n </Button>\n )}\n </div>\n )\n }\n products={productList}\n />\n );\n};\n\nMiniCart.getInitialData = async function () {\n return getPersistedCartData();\n};\n"],"names":["MiniCart","className","products","productListFooter","subtotal","subtotalExcludingTaxes","preCheckoutSection","ctas","props","dictionary","useText","jsx","classes","jsxs","Fragment","VComponent","children","initialData","hideFooter","slots","routeProduct","routeCart","routeCheckout","routeEmptyCartCTA","showDiscount","showSavings","enableItemRemoval","enableQuantityUpdate","hideHeading","undo","data","setData","useState","cartTaxesConfig","_a","state","useEffect","event","events","payload","handleItemQuantityUpdate","uid","quantity","updateProductsFromCart","handleItemRemove","checkoutLinkDisabled","handleInitiateCheckout","useCallback","publishInitiateCheckoutEvent","productList","Slot","CartSummaryList","_b","_c","getProductListFooter","getPreCheckoutSection","getSubtotalPriceProps","MiniCartComponent","Price","Button","getPersistedCartData"],"mappings":"mxCAiCO,MAAMA,EAA6C,CAAC,CACzD,UAAAC,EACA,SAAAC,EACA,kBAAAC,EACA,SAAAC,EACA,uBAAAC,EACA,mBAAAC,EACA,KAAAC,EACA,GAAGC,CACL,IAAM,CACJ,MAAMC,EAAaC,EAAQ,CACzB,SAAU,yBACV,uBAAwB,sCAAA,CACzB,EAED,OACGC,EAAA,MAAA,CAAK,GAAGH,EAAO,UAAWI,EAAQ,CAAC,iBAAkBX,CAAS,CAAC,EAE7D,SAAAC,GAEGW,EAAAC,EAAA,CAAA,SAAA,CAAAH,EAAC,MAAA,CACC,UAAU,2BACV,cAAY,6BAEX,SAAAT,CAAA,CACH,EAGCC,GACCQ,EAAC,MAAA,CACC,UAAWC,EAAQ,CAAC,mCAAmC,CAAC,EACxD,cAAY,gCAEZ,SAAAD,EAACI,EAAW,CAAA,KAAMZ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,GAAA,MAAAA,EAAM,gBACJ,MACE,CAAA,SAAA,CACCR,GAAAX,EAACgD,EAAA,CACC,cAAY,wBACZ,QAAQ,UACR,KAAMd,EAAuB,OAAYvB,EAAc,EACvD,SAAUuB,EACV,gBAAeA,EACf,QAASC,EAER,SAAWrC,EAAA,YAAA,CACd,EAEDY,GACCV,EAACgD,EAAA,CACC,cAAY,oBACZ,QAAQ,WACR,KAAMtC,EAAU,EAEf,SAAWZ,EAAA,QAAA,CAAA,CACd,EAEJ,EAvBqB,OA0BzB,SAAUwC,CAAA,CACZ,CAEJ,EAEAjD,EAAS,eAAiB,gBAAkB,CAC1C,OAAO4D,EAAqB,CAC9B"}
|
|
1
|
+
{"version":3,"file":"MiniCart.js","sources":["/@dropins/storefront-cart/src/components/MiniCart/MiniCart.tsx","/@dropins/storefront-cart/src/containers/MiniCart/MiniCart.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { VComponent, classes } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nimport '@/cart/components/MiniCart/MiniCart.css';\n\nexport interface MiniCartProps extends HTMLAttributes<HTMLDivElement> {\n products?: VNode;\n productListFooter?: VNode;\n subtotal?: VNode;\n subtotalExcludingTaxes?: VNode;\n preCheckoutSection?: VNode;\n ctas?: VNode;\n}\n\nexport const MiniCart: FunctionComponent<MiniCartProps> = ({\n className,\n products,\n productListFooter,\n subtotal,\n subtotalExcludingTaxes,\n preCheckoutSection,\n ctas,\n ...props\n}) => {\n const dictionary = useText({\n subtotal: 'Cart.MiniCart.subtotal',\n subtotalExcludingTaxes: 'Cart.MiniCart.subtotalExcludingTaxes',\n });\n\n return (\n <div {...props} className={classes(['cart-mini-cart', className])}>\n {/* Content */}\n {products && (\n <>\n <div\n className=\"cart-mini-cart__products\"\n data-testid=\"mini-cart-products-wrapper\"\n >\n {products}\n </div>\n\n {/* Product List Footer */}\n {productListFooter && (\n <div\n className={classes(['cart-mini-cart__productListFooter'])}\n data-testid=\"mini-cart-product-list-footer\"\n >\n <VComponent node={productListFooter} />\n </div>\n )}\n\n <div\n className=\"cart-mini-cart__footer\"\n data-testid=\"mini-cart-subtotals\"\n >\n {/* Subtotal */}\n {subtotal && (\n <div\n className=\"cart-mini-cart__footer__estimated-total\"\n data-testid=\"mini-cart-subtotal\"\n >\n {dictionary.subtotal}\n <VComponent node={subtotal} />\n </div>\n )}\n {/* Subtotal Excluding Taxes */}\n {subtotalExcludingTaxes && (\n <div\n className=\"cart-mini-cart__footer__estimated-total-excluding-taxes\"\n data-testid=\"mini-cart-subtotal-excluding-taxes\"\n >\n {dictionary.subtotalExcludingTaxes}\n <VComponent\n node={subtotalExcludingTaxes}\n className={classes([\n 'dropin-price-summary__price',\n 'dropin-price-summary__price--muted',\n ])}\n />\n </div>\n )}\n\n {/* Pre-checkout section */}\n {preCheckoutSection && (\n <div\n className={classes(['cart-mini-cart__preCheckoutSection'])}\n data-testid=\"mini-cart-pre-checkout-section\"\n >\n <VComponent node={preCheckoutSection} />\n </div>\n )}\n\n {ctas && (\n <VComponent\n node={ctas}\n className=\"cart-mini-cart__footer__ctas\"\n />\n )}\n </div>\n </>\n )}\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n HTMLAttributes,\n useCallback,\n useEffect,\n useState,\n} from 'preact/compat';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { CartModel } from '@/cart/data/models';\nimport { getPersistedCartData } from '@/cart/lib/persisted-data';\nimport { events } from '@adobe-commerce/event-bus';\nimport { MiniCart as MiniCartComponent } from '@/cart/components';\nimport { CartSummaryList } from '@/cart/containers';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Button, ImageProps, Price } from '@adobe-commerce/elsie/components';\nimport { updateProductsFromCart } from '@/cart/api';\nimport { publishInitiateCheckoutEvent } from '@/cart/lib/acdl';\nimport { state } from '@/cart/lib/state';\n\n// Delay navigation to allow analytics event to be sent before page unload.\n// 100ms provides a reasonable balance between user experience and event reliability.\nconst ANALYTICS_NAVIGATION_DELAY_MS = 100;\n\nexport interface MiniCartProps extends HTMLAttributes<HTMLDivElement> {\n routeProduct?: (item: CartModel['items'][0]) => string;\n routeCart?: () => string;\n routeCheckout?: () => string;\n routeEmptyCartCTA?: () => string;\n slots?: {\n ProductList?: SlotProps;\n ProductListFooter?: SlotProps;\n PreCheckoutSection?: SlotProps;\n Thumbnail?: SlotProps<{\n item: CartModel['items'][number];\n defaultImageProps: ImageProps;\n }>;\n Heading?: SlotProps;\n EmptyCart?: SlotProps;\n Footer?: SlotProps;\n ProductAttributes?: SlotProps;\n CartSummaryFooter?: SlotProps;\n CartItem?: SlotProps; // For backward compatibility\n UndoBanner?: SlotProps<{\n item: CartModel['items'][0];\n loading: boolean;\n error?: string;\n onUndo: () => void;\n onDismiss: () => void;\n }>;\n ItemTitle?: SlotProps<{ item: CartModel['items'][number] }>;\n ItemPrice?: SlotProps<{ item: CartModel['items'][number] }>;\n ItemQuantity?: SlotProps<{\n item: CartModel['items'][number];\n enableUpdateItemQuantity: boolean;\n handleItemQuantityUpdate: (\n item: CartModel['items'][number],\n quantity: number\n ) => void;\n itemsLoading: Set<string>;\n handleItemsError: (uid: string, message?: string) => void;\n handleItemsLoading: (uid: string, state: boolean) => void;\n onItemUpdate?: ({ item }: { item: CartModel['items'][number] }) => void;\n }>;\n ItemTotal?: SlotProps<{ item: CartModel['items'][number] }>;\n ItemSku?: SlotProps<{ item: CartModel['items'][number] }>;\n ItemRemoveAction?: SlotProps<{\n item: CartModel['items'][number];\n enableRemoveItem: boolean;\n handleItemQuantityUpdate: (\n item: CartModel['items'][number],\n quantity: number\n ) => void;\n handleItemsError: (uid: string, message?: string) => void;\n handleItemsLoading: (uid: string, state: boolean) => void;\n onItemUpdate?: ({ item }: { item: CartModel['items'][number] }) => void;\n itemsLoading: Set<string>;\n }>;\n };\n hideFooter?: boolean;\n displayAllItems?: boolean;\n showDiscount?: boolean;\n showSavings?: boolean;\n enableItemRemoval?: boolean;\n enableQuantityUpdate?: boolean;\n hideHeading?: boolean;\n undo?: boolean;\n}\n\nexport const MiniCart: Container<MiniCartProps, CartModel | null> = ({\n children,\n initialData = null,\n hideFooter = true, // Default to true for MiniCart\n slots,\n routeProduct,\n routeCart,\n routeCheckout,\n routeEmptyCartCTA,\n showDiscount,\n showSavings,\n enableItemRemoval = true, // Default to true for MiniCart\n enableQuantityUpdate = false, // Default to false for MiniCart\n hideHeading = false, // Default to false for MiniCart\n undo = false,\n ...props\n}) => {\n const [data, setData] = useState<CartModel | null>(initialData);\n const cartTaxesConfig = state.config?.shoppingCartDisplaySetting;\n\n useEffect(() => {\n const event = events.on(\n 'cart/data',\n (payload) => {\n setData(payload as CartModel);\n },\n { eager: true }\n );\n\n return () => {\n event?.off();\n };\n }, []);\n\n const dictionary = useText({\n cartLink: 'Cart.MiniCart.cartLink',\n checkoutLink: 'Cart.MiniCart.checkoutLink',\n });\n\n const handleItemQuantityUpdate = (uid: string, quantity: number) => {\n return updateProductsFromCart([{ uid, quantity }]);\n };\n\n const handleItemRemove = (uid: string) => handleItemQuantityUpdate(uid, 0);\n\n const checkoutLinkDisabled = data?.hasOutOfStockItems;\n\n const handleInitiateCheckout = useCallback((e: MouseEvent) => {\n if (data && !checkoutLinkDisabled) {\n e.preventDefault();\n publishInitiateCheckoutEvent(data, state.locale);\n \n setTimeout(() => {\n const checkoutUrl = routeCheckout?.();\n if (checkoutUrl) {\n window.location.href = checkoutUrl;\n }\n }, ANALYTICS_NAVIGATION_DELAY_MS);\n }\n }, [data, checkoutLinkDisabled, routeCheckout]);\n\n const productList = (\n <Slot\n name=\"ProductList\"\n slot={slots?.ProductList}\n context={{\n itemQuantityUpdateHandler: handleItemQuantityUpdate,\n itemRemoveHandler: handleItemRemove,\n totalQuantity: data?.totalQuantity,\n }}\n >\n <CartSummaryList\n data-testid=\"default-cart-summary-list\"\n routeProduct={routeProduct}\n routeEmptyCartCTA={routeEmptyCartCTA}\n initialData={data}\n maxItems={state.config?.miniCartMaxItemsDisplay}\n showMaxItems={!!state.config?.miniCartMaxItemsDisplay}\n hideHeading={hideHeading || !data?.totalQuantity}\n hideFooter={hideFooter}\n enableRemoveItem={enableItemRemoval}\n enableUpdateItemQuantity={enableQuantityUpdate}\n showDiscount={showDiscount}\n showSavings={showSavings}\n undo={undo}\n slots={{\n Thumbnail: slots?.Thumbnail,\n Heading: slots?.Heading,\n EmptyCart: slots?.EmptyCart,\n Footer: slots?.Footer,\n ProductAttributes: slots?.ProductAttributes,\n CartSummaryFooter: slots?.CartSummaryFooter,\n CartItem: slots?.CartItem, // Keep for backward compatibility\n UndoBanner: slots?.UndoBanner,\n ItemTitle: slots?.ItemTitle,\n ItemPrice: slots?.ItemPrice,\n ItemQuantity: slots?.ItemQuantity,\n ItemTotal: slots?.ItemTotal,\n ItemSku: slots?.ItemSku,\n ItemRemoveAction: slots?.ItemRemoveAction,\n }}\n />\n </Slot>\n );\n\n const getProductListFooter = (data: CartModel | null) => {\n return (\n <Slot\n name=\"ProductListFooter\"\n slot={slots?.ProductListFooter}\n context={{\n data,\n }}\n />\n );\n };\n\n const getPreCheckoutSection = (data: CartModel | null) => {\n return (\n <Slot\n name=\"PreCheckoutSection\"\n slot={slots?.PreCheckoutSection}\n context={{\n data,\n }}\n />\n );\n };\n\n const getSubtotalPriceProps = () =>\n cartTaxesConfig?.subtotal === 'INCLUDING_TAX' ||\n cartTaxesConfig?.subtotal === 'INCLUDING_EXCLUDING_TAX'\n ? {\n amount: data?.subtotal.includingTax.value,\n currency: data?.subtotal.includingTax.currency,\n 'data-testid': 'subtotal-including-tax',\n style: { font: 'inherit' },\n }\n : {\n amount: data?.subtotal.excludingTax.value,\n currency: data?.subtotal.excludingTax.currency,\n 'data-testid': 'subtotal-excluding-tax',\n style: { font: 'inherit' },\n };\n\n return (\n <MiniCartComponent\n {...props}\n productListFooter={getProductListFooter(data)}\n subtotal={\n !data?.totalQuantity\n ? undefined\n : data?.subtotal && <Price {...getSubtotalPriceProps()} />\n }\n subtotalExcludingTaxes={\n !data?.totalQuantity\n ? undefined\n : data?.subtotal &&\n (cartTaxesConfig?.subtotal === 'INCLUDING_EXCLUDING_TAX' ? (\n <Price\n amount={data?.subtotal.excludingTax.value}\n currency={data?.subtotal.excludingTax.currency}\n data-testid=\"subtotal-including-excluding-tax\"\n style={{ font: 'inherit' }}\n />\n ) : undefined)\n }\n preCheckoutSection={getPreCheckoutSection(data)}\n ctas={\n !data?.totalQuantity ? undefined : (\n <div>\n {routeCheckout && (\n <Button\n data-testid=\"route-checkout-button\"\n variant=\"primary\"\n href={checkoutLinkDisabled ? undefined : routeCheckout()}\n disabled={checkoutLinkDisabled}\n aria-disabled={checkoutLinkDisabled}\n onClick={handleInitiateCheckout}\n >\n {dictionary.checkoutLink}\n </Button>\n )}\n {routeCart && (\n <Button\n data-testid=\"route-cart-button\"\n variant=\"tertiary\"\n href={routeCart()}\n >\n {dictionary.cartLink}\n </Button>\n )}\n </div>\n )\n }\n products={productList}\n />\n );\n};\n\nMiniCart.getInitialData = async function () {\n return getPersistedCartData();\n};\n"],"names":["MiniCart","className","products","productListFooter","subtotal","subtotalExcludingTaxes","preCheckoutSection","ctas","props","dictionary","useText","jsx","classes","jsxs","Fragment","VComponent","ANALYTICS_NAVIGATION_DELAY_MS","children","initialData","hideFooter","slots","routeProduct","routeCart","routeCheckout","routeEmptyCartCTA","showDiscount","showSavings","enableItemRemoval","enableQuantityUpdate","hideHeading","undo","data","setData","useState","cartTaxesConfig","_a","state","useEffect","event","events","payload","handleItemQuantityUpdate","uid","quantity","updateProductsFromCart","handleItemRemove","checkoutLinkDisabled","handleInitiateCheckout","useCallback","e","publishInitiateCheckoutEvent","checkoutUrl","productList","Slot","CartSummaryList","_b","_c","getProductListFooter","getPreCheckoutSection","getSubtotalPriceProps","MiniCartComponent","Price","Button","getPersistedCartData"],"mappings":"mxCAiCO,MAAMA,EAA6C,CAAC,CACzD,UAAAC,EACA,SAAAC,EACA,kBAAAC,EACA,SAAAC,EACA,uBAAAC,EACA,mBAAAC,EACA,KAAAC,EACA,GAAGC,CACL,IAAM,CACJ,MAAMC,EAAaC,EAAQ,CACzB,SAAU,yBACV,uBAAwB,sCAAA,CACzB,EAED,OACGC,EAAA,MAAA,CAAK,GAAGH,EAAO,UAAWI,EAAQ,CAAC,iBAAkBX,CAAS,CAAC,EAE7D,SAAAC,GAEGW,EAAAC,EAAA,CAAA,SAAA,CAAAH,EAAC,MAAA,CACC,UAAU,2BACV,cAAY,6BAEX,SAAAT,CAAA,CACH,EAGCC,GACCQ,EAAC,MAAA,CACC,UAAWC,EAAQ,CAAC,mCAAmC,CAAC,EACxD,cAAY,gCAEZ,SAAAD,EAACI,EAAW,CAAA,KAAMZ,CAAmB,CAAA,CAAA,CACvC,EAGFU,EAAC,MAAA,CACC,UAAU,yBACV,cAAY,sBAGX,SAAA,CACCT,GAAAS,EAAC,MAAA,CACC,UAAU,0CACV,cAAY,qBAEX,SAAA,CAAWJ,EAAA,SACZE,EAACI,EAAW,CAAA,KAAMX,CAAU,CAAA,CAAA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Z,EAACmD,EAAA,CACC,cAAY,wBACZ,QAAQ,UACR,KAAMhB,EAAuB,OAAYvB,EAAc,EACvD,SAAUuB,EACV,gBAAeA,EACf,QAASC,EAER,SAAWtC,EAAA,YAAA,CACd,EAEDa,GACCX,EAACmD,EAAA,CACC,cAAY,oBACZ,QAAQ,WACR,KAAMxC,EAAU,EAEf,SAAWb,EAAA,QAAA,CAAA,CACd,EAEJ,EAvBqB,OA0BzB,SAAU2C,CAAA,CACZ,CAEJ,EAEApD,EAAS,eAAiB,gBAAkB,CAC1C,OAAO+D,EAAqB,CAC9B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2024 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
/**
|
|
18
|
+
* Decodes HTML entities in a string (e.g., " -> ", & -> &)
|
|
19
|
+
* Uses DOMParser to safely decode entities and extract text content.
|
|
20
|
+
* Note: This will also strip any HTML tags from the decoded result.
|
|
21
|
+
* @param text - The text containing HTML entities to decode
|
|
22
|
+
* @returns The decoded text with HTML entities converted to their characters
|
|
23
|
+
*/
|
|
24
|
+
export declare const decodeHTMLEntities: (text: string) => string;
|
|
25
|
+
//# sourceMappingURL=decodeHTMLEntities.d.ts.map
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-cart", "version": "
|
|
1
|
+
{"name": "@dropins/storefront-cart", "version": "3.0.0-alpha002", "@dropins/tools": "1.6.0-beta3", "license": "SEE LICENSE IN LICENSE.md"}
|