@nextblock-cms/ecom 0.20.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_virtual/_rolldown/runtime.cjs.js +1 -0
- package/index.cjs.js +1 -1
- package/index.es.js +38 -146
- package/lib/CurrencyProvider.cjs.js +1 -1
- package/lib/CurrencyProvider.d.ts +1 -1
- package/lib/CurrencyProvider.es.js +85 -95
- package/lib/PaymentReadinessProvider.cjs.js +1 -1
- package/lib/PaymentReadinessProvider.d.ts +1 -1
- package/lib/PaymentReadinessProvider.es.js +24 -27
- package/lib/cart-store.cjs.js +1 -1
- package/lib/cart-store.es.js +109 -121
- package/lib/components/AccountNavigationMenu.cjs.js +1 -1
- package/lib/components/AccountNavigationMenu.d.ts +1 -1
- package/lib/components/AccountNavigationMenu.es.js +36 -50
- package/lib/components/AddToCartButton.cjs.js +1 -1
- package/lib/components/AddToCartButton.d.ts +1 -1
- package/lib/components/AddToCartButton.es.js +94 -89
- package/lib/components/Cart.cjs.js +1 -1
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +261 -180
- package/lib/components/CartDrawer.cjs.js +1 -1
- package/lib/components/CartDrawer.d.ts +1 -1
- package/lib/components/CartDrawer.es.js +218 -148
- package/lib/components/CartIcon.cjs.js +1 -1
- package/lib/components/CartIcon.d.ts +1 -1
- package/lib/components/CartIcon.es.js +33 -35
- package/lib/components/Checkout.cjs.js +1 -1
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +1092 -1108
- package/lib/components/CouponForm.cjs.js +1 -1
- package/lib/components/CouponForm.d.ts +1 -1
- package/lib/components/CouponForm.es.js +136 -148
- package/lib/components/CurrencySwitcher.cjs.js +1 -1
- package/lib/components/CurrencySwitcher.d.ts +1 -1
- package/lib/components/CurrencySwitcher.es.js +22 -18
- package/lib/components/CustomerProfileForm.cjs.js +1 -1
- package/lib/components/CustomerProfileForm.es.js +454 -313
- package/lib/components/FeaturedProduct.cjs.js +1 -1
- package/lib/components/FeaturedProduct.d.ts +1 -1
- package/lib/components/FeaturedProduct.es.js +98 -83
- package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
- package/lib/components/FreemiusLicensePanel.d.ts +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +70 -65
- package/lib/components/InvoiceDocument.cjs.js +1 -1
- package/lib/components/InvoiceDocument.es.js +256 -192
- package/lib/components/InvoiceViewerShell.cjs.js +2 -2
- package/lib/components/InvoiceViewerShell.d.ts +1 -1
- package/lib/components/InvoiceViewerShell.es.js +75 -106
- package/lib/components/ProductCard.cjs.js +1 -1
- package/lib/components/ProductCard.d.ts +1 -1
- package/lib/components/ProductCard.es.js +186 -171
- package/lib/components/ProductDetailsLayout.cjs.js +1 -1
- package/lib/components/ProductDetailsLayout.es.js +405 -404
- package/lib/components/ProductGallery.cjs.js +1 -1
- package/lib/components/ProductGallery.d.ts +1 -1
- package/lib/components/ProductGallery.es.js +51 -54
- package/lib/components/ProductGrid.cjs.js +1 -1
- package/lib/components/ProductGrid.d.ts +1 -1
- package/lib/components/ProductGrid.es.js +23 -25
- package/lib/components/ShippingEstimator.cjs.js +1 -1
- package/lib/components/ShippingEstimator.d.ts +1 -1
- package/lib/components/ShippingEstimator.es.js +158 -153
- package/lib/components/ShortDescription.cjs.js +1 -1
- package/lib/components/ShortDescription.es.js +17 -17
- package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
- package/lib/components/SimpleTiptapRenderer.es.js +238 -211
- package/lib/components/SubscriptionSelector.cjs.js +1 -1
- package/lib/components/SubscriptionSelector.es.js +159 -154
- package/lib/countries.cjs.js +1 -1
- package/lib/countries.es.js +232 -75
- package/lib/coupon-server.cjs.js +1 -1
- package/lib/coupon-server.es.js +180 -224
- package/lib/coupons.cjs.js +1 -1
- package/lib/coupons.es.js +12 -14
- package/lib/currency-constants.cjs.js +1 -1
- package/lib/currency-constants.es.js +4 -4
- package/lib/currency-rest-client.cjs.js +1 -1
- package/lib/currency-rest-client.es.js +15 -22
- package/lib/currency-store.cjs.js +1 -1
- package/lib/currency-store.es.js +20 -27
- package/lib/currency-sync.cjs.js +1 -1
- package/lib/currency-sync.es.js +124 -170
- package/lib/currency.cjs.js +1 -1
- package/lib/currency.es.js +242 -310
- package/lib/customer-addresses.cjs.js +1 -1
- package/lib/customer-addresses.es.js +80 -109
- package/lib/customer-orders.cjs.js +1 -1
- package/lib/customer-orders.es.js +31 -43
- package/lib/customer.cjs.js +1 -1
- package/lib/customer.es.js +43 -52
- package/lib/export-helpers.cjs.js +1 -1
- package/lib/export-helpers.es.js +53 -52
- package/lib/factory.cjs.js +1 -1
- package/lib/factory.es.js +10 -7
- package/lib/freemius-coupons.cjs.js +1 -1
- package/lib/freemius-coupons.es.js +245 -262
- package/lib/freemius-license-claim.cjs.js +1 -1
- package/lib/freemius-license-claim.es.js +87 -71
- package/lib/freemius-license.cjs.js +1 -1
- package/lib/freemius-license.es.js +32 -39
- package/lib/freemius-order-sync.cjs.js +1 -1
- package/lib/freemius-order-sync.es.js +226 -290
- package/lib/freemius-trial-provision.cjs.js +1 -1
- package/lib/freemius-trial-provision.es.js +136 -130
- package/lib/inventory-settings.cjs.js +1 -1
- package/lib/inventory-settings.es.js +69 -77
- package/lib/invoice-server.cjs.js +3 -3
- package/lib/invoice-server.es.js +94 -141
- package/lib/invoice-ui.cjs.js +1 -1
- package/lib/invoice-ui.es.js +50 -66
- package/lib/invoice.cjs.js +1 -1
- package/lib/invoice.es.js +85 -94
- package/lib/order-inventory.cjs.js +25 -25
- package/lib/order-inventory.es.js +67 -79
- package/lib/order-tax-details.cjs.js +1 -1
- package/lib/order-tax-details.es.js +142 -153
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +227 -185
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
- package/lib/pages/cms/coupons/CouponsPage.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponsPage.es.js +235 -166
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.d.ts +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +35 -34
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.d.ts +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +47 -47
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.d.ts +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +128 -117
- package/lib/pages/cms/coupons/actions.cjs.js +1 -1
- package/lib/pages/cms/coupons/actions.es.js +112 -115
- package/lib/pages/cms/coupons/index.cjs.js +1 -0
- package/lib/pages/cms/coupons/index.es.js +3 -0
- package/lib/pages/cms/coupons/product-options.cjs.js +1 -1
- package/lib/pages/cms/coupons/product-options.es.js +21 -23
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +135 -129
- package/lib/pages/cms/orders/MarkPaidButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +186 -134
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.d.ts +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +15 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.d.ts +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +85 -69
- package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrdersPage.d.ts +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +170 -102
- package/lib/pages/cms/orders/actions.cjs.js +3 -3
- package/lib/pages/cms/orders/actions.es.js +53 -69
- package/lib/pages/cms/orders/export-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/export-actions.es.js +23 -26
- package/lib/pages/cms/orders/index.cjs.js +1 -0
- package/lib/pages/cms/orders/index.es.js +6 -0
- package/lib/pages/cms/orders/server-actions.cjs.js +1 -1
- package/lib/pages/cms/orders/server-actions.es.js +60 -51
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsClient.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +316 -346
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsPage.d.ts +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +29 -32
- package/lib/pages/cms/payments/actions.cjs.js +1 -1
- package/lib/pages/cms/payments/actions.es.js +38 -48
- package/lib/pages/cms/payments/index.cjs.js +1 -0
- package/lib/pages/cms/payments/index.es.js +3 -0
- package/lib/pages/cms/payments/queries.cjs.js +1 -1
- package/lib/pages/cms/payments/queries.es.js +38 -48
- package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
- package/lib/pages/cms/products/ProductsPage.d.ts +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +63 -66
- package/lib/pages/cms/products/[id]/edit/EditProductPage.d.ts +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +138 -155
- package/lib/pages/cms/products/actions.cjs.js +4 -4
- package/lib/pages/cms/products/actions.es.js +121 -162
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +55 -47
- package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
- package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +285 -290
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.d.ts +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +43 -35
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +315 -262
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +115 -113
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.d.ts +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +136 -145
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.d.ts +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +35 -47
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.d.ts +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +106 -84
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +156 -159
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductForm.es.js +872 -693
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +106 -103
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.d.ts +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +303 -294
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.d.ts +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +111 -134
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +29 -35
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +36 -48
- package/lib/pages/cms/products/components/SyncProductForm.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.d.ts +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +396 -405
- package/lib/pages/cms/products/index.cjs.js +1 -0
- package/lib/pages/cms/products/index.es.js +8 -0
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +21 -15
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
- package/lib/pages/cms/products/inventory/InventoryTableClient.d.ts +1 -1
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +230 -209
- package/lib/pages/cms/products/inventory/actions.cjs.js +3 -3
- package/lib/pages/cms/products/inventory/actions.es.js +83 -91
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/new/NewProductPage.d.ts +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +58 -74
- package/lib/pages/cms/products/product-price-sync.cjs.js +1 -1
- package/lib/pages/cms/products/product-price-sync.es.js +74 -89
- package/lib/pages/cms/products/server-actions.cjs.js +1 -1
- package/lib/pages/cms/products/server-actions.es.js +250 -233
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
- package/lib/pages/cms/shipping/ShippingPage.es.js +287 -209
- package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
- package/lib/pages/cms/shipping/components/RateForm.es.js +439 -436
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +245 -224
- package/lib/pages/cms/shipping/index.cjs.js +1 -0
- package/lib/pages/cms/shipping/index.es.js +3 -0
- package/lib/pages/cms/shipping/server-actions.cjs.js +1 -1
- package/lib/pages/cms/shipping/server-actions.es.js +131 -149
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
- package/lib/pages/cms/taxes/TaxesPage.d.ts +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +211 -169
- package/lib/pages/cms/taxes/actions.cjs.js +1 -1
- package/lib/pages/cms/taxes/actions.es.js +41 -53
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.d.ts +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +112 -99
- package/lib/pages/cms/taxes/index.cjs.js +1 -0
- package/lib/pages/cms/taxes/index.es.js +3 -0
- package/lib/payment-config.cjs.js +1 -1
- package/lib/payment-config.es.js +110 -126
- package/lib/product-actions.cjs.js +4 -4
- package/lib/product-actions.es.js +289 -544
- package/lib/product-context.cjs.js +1 -1
- package/lib/product-context.es.js +13 -15
- package/lib/product-schema.cjs.js +1 -1
- package/lib/product-schema.es.js +99 -134
- package/lib/providers/freemius.cjs.js +1 -5
- package/lib/providers/freemius.es.js +446 -530
- package/lib/providers/stripe.cjs.js +1 -1
- package/lib/providers/stripe.es.js +417 -477
- package/lib/server-actions/coupon-actions.cjs.js +1 -1
- package/lib/server-actions/coupon-actions.es.js +22 -22
- package/lib/server-actions/customer-actions.cjs.js +1 -1
- package/lib/server-actions/customer-actions.es.js +26 -28
- package/lib/server-actions/product-actions.cjs.js +1 -1
- package/lib/server-actions/product-actions.es.js +9 -15
- package/lib/server-actions/shipping-actions.cjs.js +1 -1
- package/lib/server-actions/shipping-actions.es.js +27 -24
- package/lib/server-actions/tax-actions.cjs.js +1 -1
- package/lib/server-actions/tax-actions.es.js +33 -39
- package/lib/shared-inventory.cjs.js +2 -2
- package/lib/shared-inventory.es.js +111 -160
- package/lib/shipping/resolver.cjs.js +2 -2
- package/lib/shipping/resolver.es.js +44 -61
- package/lib/shipping-rate-currency.cjs.js +1 -1
- package/lib/shipping-rate-currency.es.js +52 -67
- package/lib/states.cjs.js +1 -1
- package/lib/states.es.js +333 -154
- package/lib/stripe/checkout.cjs.js +1 -1
- package/lib/stripe/checkout.es.js +125 -181
- package/lib/stripe/client.cjs.js +1 -1
- package/lib/stripe/client.es.js +14 -19
- package/lib/stripe/order-sync.cjs.js +1 -1
- package/lib/stripe/order-sync.es.js +106 -126
- package/lib/stripe/webhooks.cjs.js +1 -1
- package/lib/stripe/webhooks.es.js +37 -31
- package/lib/tax-calculation.cjs.js +1 -1
- package/lib/tax-calculation.es.js +84 -98
- package/lib/trials.cjs.js +1 -1
- package/lib/trials.es.js +24 -30
- package/lib/types.cjs.js +1 -1
- package/lib/types.es.js +21 -27
- package/lib/use-cart.cjs.js +1 -1
- package/lib/use-cart.es.js +38 -40
- package/lib/use-price-formatter.cjs.js +1 -1
- package/lib/use-price-formatter.es.js +10 -11
- package/lib/variation-utils.cjs.js +1 -1
- package/lib/variation-utils.es.js +199 -261
- package/lib/zod-config.cjs.js +1 -1
- package/lib/zod-config.es.js +5 -6
- package/package.json +16 -16
- package/server.cjs.js +1 -1
- package/server.es.js +56 -211
|
@@ -1,408 +1,399 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { convertMinorUnitAmount as e, normalizePriceMap as t, normalizeSalePriceMap as n } from "../../../../currency.es.js";
|
|
3
|
+
import { extractSelectedTermsByAttribute as r, generateVariantDrafts as i, resolveAttributeName as a, resolveTermValue as o } from "../../../../variation-utils.es.js";
|
|
4
|
+
import { CurrencyPriceFields as s } from "./CurrencyPriceFields.es.js";
|
|
5
|
+
import { SaleScheduleFields as c } from "./SaleScheduleFields.es.js";
|
|
6
|
+
import { getStoreManagedPriceCurrencyCodes as l, resolveEditorCurrencyPriceMaps as u, sanitizeVariantDraftsForStoreManagedCurrencies as d } from "../product-price-sync.es.js";
|
|
7
|
+
import f from "next/link";
|
|
8
|
+
import { useEffect as p, useMemo as m, useState as h } from "react";
|
|
9
|
+
import { majorUnitAmountToMinor as g, minorUnitAmountToMajor as _ } from "@nextblock-cms/utils";
|
|
10
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
11
|
+
import { Badge as b, Button as x, Input as S, Label as C } from "@nextblock-cms/ui";
|
|
12
|
+
//#region libs/ecommerce/src/lib/pages/cms/products/components/VariationsEditor.tsx
|
|
13
|
+
var w = process.env.NEXT_PUBLIC_R2_BASE_URL || "", T = process.env.NEXT_PUBLIC_SUPABASE_URL || "", E = (e) => e.startsWith("http") ? e : w ? `${w.replace(/\/+$/, "")}/${e.replace(/^\/+/, "")}` : T ? `${T.replace(/\/+$/, "")}/storage/v1/object/public/media/${e.replace(/^\/+/, "")}` : e;
|
|
14
|
+
function D(e, t = "USD") {
|
|
15
|
+
return new Intl.NumberFormat("en-US", {
|
|
16
|
+
style: "currency",
|
|
17
|
+
currency: t
|
|
18
|
+
}).format(e);
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
20
|
+
function O(e) {
|
|
21
|
+
return Object.entries(e).filter(([, e]) => e.length > 0).map(([e, t]) => ({
|
|
22
|
+
attribute_id: e,
|
|
23
|
+
term_ids: t
|
|
24
|
+
}));
|
|
21
25
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
type: "button",
|
|
394
|
-
variant: "ghost",
|
|
395
|
-
size: "sm",
|
|
396
|
-
className: "h-7 text-xs px-2 text-muted-foreground hover:text-destructive",
|
|
397
|
-
onClick: () => j(e.combination_key),
|
|
398
|
-
children: "Remove"
|
|
399
|
-
}
|
|
400
|
-
)
|
|
401
|
-
] })
|
|
402
|
-
] }, e.combination_key);
|
|
403
|
-
}) })
|
|
404
|
-
] });
|
|
26
|
+
function k({ globalAttributes: w, currentLanguageCode: T, baseSku: k, basePrice: A, basePrices: j, baseSalePrice: M, baseSalePrices: N, currencies: P, availableVariantImages: F = [], initialVariationAttributes: I, initialVariants: L, onChange: R }) {
|
|
27
|
+
let [z, B] = h(() => I && I.length > 0 ? I.reduce((e, t) => (e[t.attribute_id] = t.term_ids, e), {}) : r(L || [])), [V, H] = h(d(L || [], P)), U = m(() => w.map((e) => ({
|
|
28
|
+
attribute_id: e.id,
|
|
29
|
+
attribute_name: a(e, T),
|
|
30
|
+
terms: e.terms.filter((t) => (z[e.id] || []).includes(t.id)).map((e) => ({
|
|
31
|
+
...e,
|
|
32
|
+
value: o(e, T)
|
|
33
|
+
}))
|
|
34
|
+
})).filter((e) => e.terms.length > 0), [
|
|
35
|
+
T,
|
|
36
|
+
w,
|
|
37
|
+
z
|
|
38
|
+
]);
|
|
39
|
+
p(() => {
|
|
40
|
+
if (U.length === 0) {
|
|
41
|
+
H([]);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
H((e) => d(i({
|
|
45
|
+
baseSku: k,
|
|
46
|
+
basePrice: A,
|
|
47
|
+
basePrices: t(j),
|
|
48
|
+
baseSalePrice: M,
|
|
49
|
+
baseSalePrices: n(N),
|
|
50
|
+
selectedAttributes: U,
|
|
51
|
+
previousVariants: e
|
|
52
|
+
}), P));
|
|
53
|
+
}, [
|
|
54
|
+
A,
|
|
55
|
+
j,
|
|
56
|
+
M,
|
|
57
|
+
N,
|
|
58
|
+
k,
|
|
59
|
+
P,
|
|
60
|
+
U
|
|
61
|
+
]), p(() => {
|
|
62
|
+
R({
|
|
63
|
+
variationAttributes: O(z),
|
|
64
|
+
variants: V
|
|
65
|
+
});
|
|
66
|
+
}, [
|
|
67
|
+
R,
|
|
68
|
+
z,
|
|
69
|
+
V
|
|
70
|
+
]);
|
|
71
|
+
let W = V.reduce((e, t) => e + (t.stock_quantity || 0), 0), G = P.find((e) => e.is_default) ?? P[0], K = m(() => l(P), [P]), q = (e, t) => {
|
|
72
|
+
B((n) => {
|
|
73
|
+
let r = new Set(n[e] || []);
|
|
74
|
+
return r.has(t) ? r.delete(t) : r.add(t), {
|
|
75
|
+
...n,
|
|
76
|
+
[e]: [...r]
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
}, J = (e, t, n) => {
|
|
80
|
+
H((r) => r.map((r) => {
|
|
81
|
+
if (r.combination_key !== e) return r;
|
|
82
|
+
if (t === "sku") return {
|
|
83
|
+
...r,
|
|
84
|
+
sku: n
|
|
85
|
+
};
|
|
86
|
+
if (t === "upc") return {
|
|
87
|
+
...r,
|
|
88
|
+
upc: n
|
|
89
|
+
};
|
|
90
|
+
if (t === "sale_price" && n === "") return {
|
|
91
|
+
...r,
|
|
92
|
+
sale_price: null
|
|
93
|
+
};
|
|
94
|
+
if (t === "prices" || t === "sale_prices") return r;
|
|
95
|
+
let i = n === "" ? 0 : Number(n);
|
|
96
|
+
return {
|
|
97
|
+
...r,
|
|
98
|
+
[t]: Number.isFinite(i) ? i : 0
|
|
99
|
+
};
|
|
100
|
+
}));
|
|
101
|
+
}, Y = (e, t, n) => {
|
|
102
|
+
H((r) => r.map((r) => r.combination_key === e ? {
|
|
103
|
+
...r,
|
|
104
|
+
[t]: n
|
|
105
|
+
} : r));
|
|
106
|
+
}, X = (e, t, n, r) => {
|
|
107
|
+
let i = P.find((e) => e.is_default) ?? P[0];
|
|
108
|
+
H((a) => a.map((a) => {
|
|
109
|
+
if (a.combination_key !== e) return a;
|
|
110
|
+
let o = {
|
|
111
|
+
...n === "prices" ? a.prices : a.sale_prices,
|
|
112
|
+
[t]: r
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
...a,
|
|
116
|
+
[n]: o,
|
|
117
|
+
...t === i?.code ? n === "prices" ? { price: r ?? 0 } : { sale_price: r } : {}
|
|
118
|
+
};
|
|
119
|
+
}));
|
|
120
|
+
}, Z = (t) => {
|
|
121
|
+
let n = P.find((e) => e.is_default) ?? P[0], r = new Set(K);
|
|
122
|
+
n && H((i) => i.map((i) => {
|
|
123
|
+
if (i.combination_key !== t) return i;
|
|
124
|
+
let a = P.reduce((t, a) => {
|
|
125
|
+
if (a.code !== n.code && r.has(a.code)) return t;
|
|
126
|
+
let o = e({
|
|
127
|
+
amount: g(i.price, n.code),
|
|
128
|
+
fromCurrencyCode: n.code,
|
|
129
|
+
toCurrencyCode: a.code,
|
|
130
|
+
currencies: P,
|
|
131
|
+
applyRounding: !0
|
|
132
|
+
});
|
|
133
|
+
return t[a.code] = _(o, a.code), t;
|
|
134
|
+
}, {}), o = P.reduce((t, a) => {
|
|
135
|
+
if (a.code !== n.code && r.has(a.code)) return t;
|
|
136
|
+
if (typeof i.sale_price != "number") return t[a.code] = null, t;
|
|
137
|
+
let o = e({
|
|
138
|
+
amount: g(i.sale_price, n.code),
|
|
139
|
+
fromCurrencyCode: n.code,
|
|
140
|
+
toCurrencyCode: a.code,
|
|
141
|
+
currencies: P,
|
|
142
|
+
applyRounding: !0
|
|
143
|
+
});
|
|
144
|
+
return t[a.code] = _(o, a.code), t;
|
|
145
|
+
}, {});
|
|
146
|
+
return {
|
|
147
|
+
...i,
|
|
148
|
+
prices: a,
|
|
149
|
+
sale_prices: o
|
|
150
|
+
};
|
|
151
|
+
}));
|
|
152
|
+
}, Q = (e, t) => {
|
|
153
|
+
let n = F.find((e) => e.media_id === t);
|
|
154
|
+
if (!n) return;
|
|
155
|
+
let r = n.file_path, i = E(r);
|
|
156
|
+
H((t) => t.map((t) => t.combination_key === e ? {
|
|
157
|
+
...t,
|
|
158
|
+
main_media_id: n.media_id,
|
|
159
|
+
main_image_url: i
|
|
160
|
+
} : t));
|
|
161
|
+
}, $ = (e) => {
|
|
162
|
+
H((t) => t.map((t) => t.combination_key === e ? {
|
|
163
|
+
...t,
|
|
164
|
+
main_media_id: null,
|
|
165
|
+
main_image_url: null
|
|
166
|
+
} : t));
|
|
167
|
+
};
|
|
168
|
+
return w.length === 0 ? /* @__PURE__ */ y("div", {
|
|
169
|
+
className: "rounded-lg border border-dashed p-6 text-sm text-muted-foreground",
|
|
170
|
+
children: [
|
|
171
|
+
"No global attributes have been created yet. Create them first in",
|
|
172
|
+
" ",
|
|
173
|
+
/* @__PURE__ */ v(f, {
|
|
174
|
+
href: "/cms/products/attributes",
|
|
175
|
+
className: "font-medium text-primary underline-offset-4 hover:underline",
|
|
176
|
+
children: "Attribute Management"
|
|
177
|
+
}),
|
|
178
|
+
"."
|
|
179
|
+
]
|
|
180
|
+
}) : /* @__PURE__ */ y("div", {
|
|
181
|
+
className: "space-y-3",
|
|
182
|
+
children: [/* @__PURE__ */ y("div", {
|
|
183
|
+
className: "space-y-2",
|
|
184
|
+
children: [/* @__PURE__ */ y("div", {
|
|
185
|
+
className: "flex items-center justify-between gap-3",
|
|
186
|
+
children: [/* @__PURE__ */ y("div", {
|
|
187
|
+
className: "flex items-center gap-3",
|
|
188
|
+
children: [
|
|
189
|
+
/* @__PURE__ */ v("span", {
|
|
190
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider leading-none",
|
|
191
|
+
children: "Attributes"
|
|
192
|
+
}),
|
|
193
|
+
/* @__PURE__ */ y(b, {
|
|
194
|
+
variant: "outline",
|
|
195
|
+
className: "text-[10px] px-1.5 h-4",
|
|
196
|
+
children: [V.length, " variants"]
|
|
197
|
+
}),
|
|
198
|
+
/* @__PURE__ */ y(b, {
|
|
199
|
+
variant: "secondary",
|
|
200
|
+
className: "text-[10px] px-1.5 h-4",
|
|
201
|
+
children: ["Stock: ", W]
|
|
202
|
+
})
|
|
203
|
+
]
|
|
204
|
+
}), /* @__PURE__ */ v(x, {
|
|
205
|
+
asChild: !0,
|
|
206
|
+
variant: "outline",
|
|
207
|
+
size: "sm",
|
|
208
|
+
className: "h-7 text-xs px-3",
|
|
209
|
+
children: /* @__PURE__ */ v(f, {
|
|
210
|
+
href: "/cms/products/attributes",
|
|
211
|
+
children: "Manage"
|
|
212
|
+
})
|
|
213
|
+
})]
|
|
214
|
+
}), /* @__PURE__ */ v("div", {
|
|
215
|
+
className: "grid gap-2 lg:grid-cols-2",
|
|
216
|
+
children: w.map((e) => {
|
|
217
|
+
let t = z[e.id] || [];
|
|
218
|
+
return /* @__PURE__ */ y("div", {
|
|
219
|
+
className: "flex items-center gap-3 rounded border p-2.5",
|
|
220
|
+
children: [/* @__PURE__ */ y("div", {
|
|
221
|
+
className: "shrink-0 w-[100px]",
|
|
222
|
+
children: [/* @__PURE__ */ v("span", {
|
|
223
|
+
className: "text-sm font-bold block leading-tight",
|
|
224
|
+
children: a(e, T)
|
|
225
|
+
}), /* @__PURE__ */ y("span", {
|
|
226
|
+
className: "text-[10px] text-muted-foreground leading-none",
|
|
227
|
+
children: [t.length, " selected"]
|
|
228
|
+
})]
|
|
229
|
+
}), /* @__PURE__ */ v("div", {
|
|
230
|
+
className: "flex flex-wrap gap-1.5 flex-1",
|
|
231
|
+
children: e.terms.map((n) => {
|
|
232
|
+
let r = t.includes(n.id);
|
|
233
|
+
return /* @__PURE__ */ v("button", {
|
|
234
|
+
type: "button",
|
|
235
|
+
onClick: () => q(e.id, n.id),
|
|
236
|
+
className: `rounded-full border px-2.5 py-0.5 text-[11px] font-medium transition-colors ${r ? "border-primary bg-primary/10 text-primary" : "border-border bg-background text-foreground hover:border-primary/40"}`,
|
|
237
|
+
children: o(n, T)
|
|
238
|
+
}, n.id);
|
|
239
|
+
})
|
|
240
|
+
})]
|
|
241
|
+
}, e.id);
|
|
242
|
+
})
|
|
243
|
+
})]
|
|
244
|
+
}), V.length === 0 ? /* @__PURE__ */ v("div", {
|
|
245
|
+
className: "rounded border border-dashed p-3 text-xs text-muted-foreground text-center",
|
|
246
|
+
children: "Select terms above to generate variations."
|
|
247
|
+
}) : /* @__PURE__ */ v("div", {
|
|
248
|
+
className: "space-y-2",
|
|
249
|
+
children: V.map((e) => {
|
|
250
|
+
let t = u({
|
|
251
|
+
currencies: P,
|
|
252
|
+
prices: e.prices || {},
|
|
253
|
+
salePrices: e.sale_prices || {},
|
|
254
|
+
fallbackPrice: e.price,
|
|
255
|
+
fallbackSalePrice: e.sale_price
|
|
256
|
+
});
|
|
257
|
+
return /* @__PURE__ */ y("div", {
|
|
258
|
+
className: "rounded border p-3 space-y-2",
|
|
259
|
+
children: [
|
|
260
|
+
/* @__PURE__ */ y("div", {
|
|
261
|
+
className: "flex items-center justify-between gap-3",
|
|
262
|
+
children: [/* @__PURE__ */ y("div", {
|
|
263
|
+
className: "flex items-center gap-2",
|
|
264
|
+
children: [/* @__PURE__ */ v("span", {
|
|
265
|
+
className: "text-sm font-bold",
|
|
266
|
+
children: e.label
|
|
267
|
+
}), /* @__PURE__ */ v("span", {
|
|
268
|
+
className: "text-xs text-muted-foreground",
|
|
269
|
+
children: e.selected_options.map((e) => `${e.attribute_name}: ${e.term_value}`).join(" · ")
|
|
270
|
+
})]
|
|
271
|
+
}), /* @__PURE__ */ y("div", {
|
|
272
|
+
className: "flex items-center gap-3 text-xs text-muted-foreground",
|
|
273
|
+
children: [/* @__PURE__ */ y("span", { children: ["Reg: ", D(e.price, G?.code || "USD")] }), /* @__PURE__ */ y("span", { children: [
|
|
274
|
+
"Sale:",
|
|
275
|
+
" ",
|
|
276
|
+
e.sale_price !== null && e.sale_price !== void 0 ? D(e.sale_price, G?.code || "USD") : "—"
|
|
277
|
+
] })]
|
|
278
|
+
})]
|
|
279
|
+
}),
|
|
280
|
+
/* @__PURE__ */ y("div", {
|
|
281
|
+
className: "grid grid-cols-3 gap-2.5",
|
|
282
|
+
children: [
|
|
283
|
+
/* @__PURE__ */ y("div", {
|
|
284
|
+
className: "flex items-center gap-2",
|
|
285
|
+
children: [/* @__PURE__ */ v(C, {
|
|
286
|
+
htmlFor: `variant-sku-${e.combination_key}`,
|
|
287
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0",
|
|
288
|
+
children: "SKU"
|
|
289
|
+
}), /* @__PURE__ */ v(S, {
|
|
290
|
+
id: `variant-sku-${e.combination_key}`,
|
|
291
|
+
value: e.sku,
|
|
292
|
+
onChange: (t) => J(e.combination_key, "sku", t.target.value),
|
|
293
|
+
placeholder: "SKU",
|
|
294
|
+
className: "h-8 text-sm font-mono"
|
|
295
|
+
})]
|
|
296
|
+
}),
|
|
297
|
+
/* @__PURE__ */ y("div", {
|
|
298
|
+
className: "flex items-center gap-2",
|
|
299
|
+
children: [/* @__PURE__ */ v(C, {
|
|
300
|
+
htmlFor: `variant-upc-${e.combination_key}`,
|
|
301
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0",
|
|
302
|
+
children: "UPC"
|
|
303
|
+
}), /* @__PURE__ */ v(S, {
|
|
304
|
+
id: `variant-upc-${e.combination_key}`,
|
|
305
|
+
value: e.upc ?? "",
|
|
306
|
+
onChange: (t) => J(e.combination_key, "upc", t.target.value),
|
|
307
|
+
placeholder: "—",
|
|
308
|
+
className: "h-8 text-sm font-mono"
|
|
309
|
+
})]
|
|
310
|
+
}),
|
|
311
|
+
/* @__PURE__ */ y("div", {
|
|
312
|
+
className: "flex items-center gap-2",
|
|
313
|
+
children: [/* @__PURE__ */ v(C, {
|
|
314
|
+
htmlFor: `variant-stock-${e.combination_key}`,
|
|
315
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0",
|
|
316
|
+
children: "Qty"
|
|
317
|
+
}), /* @__PURE__ */ v(S, {
|
|
318
|
+
id: `variant-stock-${e.combination_key}`,
|
|
319
|
+
type: "number",
|
|
320
|
+
min: "0",
|
|
321
|
+
value: e.stock_quantity,
|
|
322
|
+
onChange: (t) => J(e.combination_key, "stock_quantity", t.target.value),
|
|
323
|
+
className: "h-8 text-sm font-mono w-20"
|
|
324
|
+
})]
|
|
325
|
+
})
|
|
326
|
+
]
|
|
327
|
+
}),
|
|
328
|
+
/* @__PURE__ */ v(s, {
|
|
329
|
+
idPrefix: `variant-${e.combination_key}`,
|
|
330
|
+
currencies: P,
|
|
331
|
+
prices: t.prices,
|
|
332
|
+
salePrices: t.salePrices,
|
|
333
|
+
managedCurrencyCodes: K,
|
|
334
|
+
onPriceChange: (t, n) => X(e.combination_key, t, "prices", n),
|
|
335
|
+
onSalePriceChange: (t, n) => X(e.combination_key, t, "sale_prices", n),
|
|
336
|
+
onAutoFill: () => Z(e.combination_key),
|
|
337
|
+
helperText: K.length > 0 ? `Store-managed currencies derive from ${G?.code || "the base currency"}.` : void 0,
|
|
338
|
+
trailing: /* @__PURE__ */ v(c, {
|
|
339
|
+
idPrefix: `variant-${e.combination_key}`,
|
|
340
|
+
startAt: e.sale_start_at,
|
|
341
|
+
endAt: e.sale_end_at,
|
|
342
|
+
onChange: (t, n) => Y(e.combination_key, t, n),
|
|
343
|
+
bare: !0
|
|
344
|
+
})
|
|
345
|
+
}),
|
|
346
|
+
/* @__PURE__ */ y("div", {
|
|
347
|
+
className: "flex items-center gap-3 pt-1.5 border-t border-muted/30",
|
|
348
|
+
children: [
|
|
349
|
+
e.main_image_url && /* @__PURE__ */ v("div", {
|
|
350
|
+
className: "h-9 w-9 overflow-hidden rounded border bg-background shrink-0",
|
|
351
|
+
children: /* @__PURE__ */ v("img", {
|
|
352
|
+
src: e.main_image_url,
|
|
353
|
+
alt: `${e.label} image`,
|
|
354
|
+
className: "h-full w-full object-cover"
|
|
355
|
+
})
|
|
356
|
+
}),
|
|
357
|
+
/* @__PURE__ */ v("span", {
|
|
358
|
+
className: "text-xs uppercase font-bold text-muted-foreground tracking-wider shrink-0",
|
|
359
|
+
children: "Image"
|
|
360
|
+
}),
|
|
361
|
+
F.length > 0 ? /* @__PURE__ */ y("select", {
|
|
362
|
+
className: "flex h-8 rounded-md border border-input bg-background px-2 py-1 text-sm min-w-[180px]",
|
|
363
|
+
value: e.main_media_id ?? "",
|
|
364
|
+
onChange: (t) => {
|
|
365
|
+
if (!t.target.value) {
|
|
366
|
+
$(e.combination_key);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
Q(e.combination_key, t.target.value);
|
|
370
|
+
},
|
|
371
|
+
children: [/* @__PURE__ */ v("option", {
|
|
372
|
+
value: "",
|
|
373
|
+
children: "Use parent image"
|
|
374
|
+
}), F.map((e, t) => /* @__PURE__ */ v("option", {
|
|
375
|
+
value: e.media_id,
|
|
376
|
+
children: e.alt?.trim() || `Gallery image ${t + 1}`
|
|
377
|
+
}, e.media_id))]
|
|
378
|
+
}) : /* @__PURE__ */ v("span", {
|
|
379
|
+
className: "text-xs text-muted-foreground",
|
|
380
|
+
children: "Add gallery images first."
|
|
381
|
+
}),
|
|
382
|
+
e.main_media_id && /* @__PURE__ */ v(x, {
|
|
383
|
+
type: "button",
|
|
384
|
+
variant: "ghost",
|
|
385
|
+
size: "sm",
|
|
386
|
+
className: "h-7 text-xs px-2 text-muted-foreground hover:text-destructive",
|
|
387
|
+
onClick: () => $(e.combination_key),
|
|
388
|
+
children: "Remove"
|
|
389
|
+
})
|
|
390
|
+
]
|
|
391
|
+
})
|
|
392
|
+
]
|
|
393
|
+
}, e.combination_key);
|
|
394
|
+
})
|
|
395
|
+
})]
|
|
396
|
+
});
|
|
405
397
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
};
|
|
398
|
+
//#endregion
|
|
399
|
+
export { k as VariationsEditor };
|