@nextblock-cms/ecom 0.19.0 → 0.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +1 -1
- package/index.es.js +26 -25
- package/lib/CurrencyProvider.cjs.js +1 -1
- package/lib/CurrencyProvider.es.js +41 -45
- package/lib/PaymentReadinessProvider.cjs.js +1 -1
- package/lib/PaymentReadinessProvider.es.js +15 -19
- package/lib/cart-store.cjs.js +1 -1
- package/lib/cart-store.d.ts +4 -0
- package/lib/cart-store.es.js +77 -69
- package/lib/components/AccountNavigationMenu.cjs.js +1 -1
- package/lib/components/AccountNavigationMenu.es.js +44 -62
- package/lib/components/AddToCartButton.cjs.js +1 -1
- package/lib/components/AddToCartButton.es.js +50 -78
- package/lib/components/Cart.cjs.js +1 -1
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +158 -377
- package/lib/components/CartDrawer.cjs.js +1 -1
- package/lib/components/CartDrawer.es.js +143 -297
- package/lib/components/CartIcon.cjs.js +1 -1
- package/lib/components/CartIcon.es.js +21 -47
- package/lib/components/Checkout.cjs.js +1 -1
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +839 -1627
- package/lib/components/CouponForm.cjs.js +1 -1
- package/lib/components/CouponForm.es.js +104 -155
- package/lib/components/CurrencySwitcher.cjs.js +1 -1
- package/lib/components/CurrencySwitcher.es.js +14 -33
- package/lib/components/CustomerProfileForm.cjs.js +1 -1
- package/lib/components/CustomerProfileForm.d.ts +1 -1
- package/lib/components/CustomerProfileForm.es.js +264 -672
- package/lib/components/FeaturedProduct.cjs.js +1 -1
- package/lib/components/FeaturedProduct.es.js +54 -126
- package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
- package/lib/components/FreemiusLicensePanel.es.js +45 -125
- package/lib/components/InvoiceDocument.cjs.js +1 -1
- package/lib/components/InvoiceDocument.es.js +148 -487
- package/lib/components/InvoiceViewerShell.cjs.js +2 -2
- package/lib/components/InvoiceViewerShell.d.ts +4 -1
- package/lib/components/InvoiceViewerShell.es.js +59 -142
- package/lib/components/ProductCard.cjs.js +1 -1
- package/lib/components/ProductCard.d.ts +3 -1
- package/lib/components/ProductCard.es.js +128 -242
- package/lib/components/ProductDetailsLayout.cjs.js +1 -1
- package/lib/components/ProductDetailsLayout.es.js +315 -657
- package/lib/components/ProductGallery.cjs.js +1 -1
- package/lib/components/ProductGallery.d.ts +2 -0
- package/lib/components/ProductGallery.es.js +37 -66
- package/lib/components/ProductGrid.cjs.js +1 -1
- package/lib/components/ProductGrid.es.js +23 -32
- package/lib/components/ShippingEstimator.cjs.js +1 -1
- package/lib/components/ShippingEstimator.es.js +124 -231
- package/lib/components/ShortDescription.cjs.js +1 -0
- package/lib/components/ShortDescription.d.ts +19 -0
- package/lib/components/ShortDescription.es.js +18 -0
- package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
- package/lib/components/SimpleTiptapRenderer.es.js +111 -294
- package/lib/components/SubscriptionSelector.cjs.js +1 -1
- package/lib/components/SubscriptionSelector.es.js +120 -181
- package/lib/components/media/MediaPickerDialog.d.ts +1 -1
- package/lib/components/media/MediaUploadForm.d.ts +1 -1
- package/lib/invoice.cjs.js +1 -1
- package/lib/invoice.d.ts +1 -1
- package/lib/invoice.es.js +6 -5
- package/lib/order-inventory.d.ts +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
- package/lib/pages/cms/coupons/CouponEditorForm.es.js +115 -375
- package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
- package/lib/pages/cms/coupons/CouponsPage.es.js +116 -368
- package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
- package/lib/pages/cms/coupons/CreateCouponDialog.es.js +26 -62
- package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
- package/lib/pages/cms/coupons/EditCouponPage.es.js +35 -71
- package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
- package/lib/pages/cms/coupons/ProductScopePicker.es.js +72 -167
- package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
- package/lib/pages/cms/orders/ExportReportsDialog.es.js +87 -247
- package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderDetailPage.es.js +95 -283
- package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderPrintButton.es.js +9 -21
- package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
- package/lib/pages/cms/orders/OrderStatusForm.es.js +46 -106
- package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
- package/lib/pages/cms/orders/OrdersPage.es.js +78 -257
- package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsClient.es.js +192 -580
- package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
- package/lib/pages/cms/payments/PaymentsPage.es.js +14 -22
- package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
- package/lib/pages/cms/products/ProductsPage.es.js +47 -87
- package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +97 -177
- package/lib/pages/cms/products/actions.d.ts +20 -20
- package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +40 -84
- 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 +192 -455
- package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
- package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +28 -72
- package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
- package/lib/pages/cms/products/categories/components/CategoryManager.es.js +183 -490
- package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
- package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +69 -177
- package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +102 -213
- package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/DeleteProductButton.es.js +25 -45
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
- package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +58 -202
- package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductCategorySelector.es.js +89 -235
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductForm.es.js +526 -1110
- package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductMediaManager.es.js +63 -154
- package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductsBulkTable.es.js +213 -544
- package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
- package/lib/pages/cms/products/components/SaleScheduleFields.es.js +91 -207
- package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
- package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +16 -28
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +25 -37
- package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
- package/lib/pages/cms/products/components/VariationsEditor.es.js +261 -492
- package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
- package/lib/pages/cms/products/inventory/InventoryPage.es.js +12 -32
- package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
- package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +145 -365
- package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
- package/lib/pages/cms/products/new/NewProductPage.es.js +30 -42
- package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
- package/lib/pages/cms/shipping/ShippingPage.es.js +155 -507
- 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 +334 -717
- package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
- package/lib/pages/cms/shipping/components/ZoneForm.es.js +158 -392
- package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
- package/lib/pages/cms/taxes/TaxesPage.es.js +119 -447
- package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
- package/lib/pages/cms/taxes/components/TaxRateForm.es.js +52 -156
- package/lib/product-actions.d.ts +31 -31
- package/lib/product-context.cjs.js +1 -1
- package/lib/product-context.es.js +10 -14
- package/lib/shared-inventory.d.ts +1 -1
- package/lib/states.cjs.js +1 -1
- package/lib/states.d.ts +2 -0
- package/lib/states.es.js +63 -29
- package/lib/trials.cjs.js +1 -1
- package/lib/trials.d.ts +10 -3
- package/lib/trials.es.js +28 -21
- package/lib/types.d.ts +2 -0
- package/lib/use-price-formatter.cjs.js +1 -0
- package/lib/use-price-formatter.d.ts +11 -0
- package/lib/use-price-formatter.es.js +13 -0
- package/lib/variation-utils.cjs.js +1 -1
- package/lib/variation-utils.d.ts +10 -0
- package/lib/variation-utils.es.js +139 -123
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("@nextblock-cms/ui"),u=require("react"),m=require("../../../../countries.cjs.js"),c=require("../../../../states.cjs.js"),S=require("../actions.cjs.js");function C({initialData:e,submitLabel:p="Save tax rate",compact:a=!1}){const l=m.normalizeCountryCode(e?.country_code)||"US",[d,h]=u.useState(l),[o,n]=u.useState(c.normalizeSubdivisionCode(l,e?.state_code)||e?.state_code||""),y=u.useMemo(()=>c.getStatesForCountry(d),[d]),j=c.countryUsesStructuredStates(d);return t.jsxs("form",{action:S.saveTaxRateAction,className:"space-y-4",children:[e?.id?t.jsx("input",{type:"hidden",name:"id",value:e.id}):null,t.jsxs("div",{className:a?"grid gap-4 md:grid-cols-4":"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(s.Label,{htmlFor:e?.id?`country-${e.id}`:"tax-rate-country",children:"Country"}),t.jsx("select",{id:e?.id?`country-${e.id}`:"tax-rate-country",name:"country_code",value:d,onChange:r=>{const x=r.target.value,g=c.getStatesForCountry(x);h(x),n(g.some(v=>v.code===o)?o:"")},className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:m.countries.map(r=>t.jsx("option",{value:r.code,children:r.name},r.code))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(s.Label,{htmlFor:e?.id?`state-${e.id}`:"tax-rate-state",children:"State / Province"}),j?t.jsxs("select",{id:e?.id?`state-${e.id}`:"tax-rate-state",name:"state_code",value:o,onChange:r=>n(r.target.value),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:[t.jsx("option",{value:"",children:"Country-wide / federal"}),y.map(r=>t.jsx("option",{value:r.code,children:r.name},r.code))]}):t.jsx(s.Input,{id:e?.id?`state-${e.id}`:"tax-rate-state",name:"state_code",value:o,onChange:r=>n(r.target.value),placeholder:"Optional"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(s.Label,{htmlFor:e?.id?`name-${e.id}`:"tax-rate-name",children:"Tax name"}),t.jsx(s.Input,{id:e?.id?`name-${e.id}`:"tax-rate-name",name:"tax_name",defaultValue:e?.tax_name||"",placeholder:"GST, PST, State Sales Tax",required:!0})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(s.Label,{htmlFor:e?.id?`rate-${e.id}`:"tax-rate-rate",children:"Rate (%)"}),t.jsx(s.Input,{id:e?.id?`rate-${e.id}`:"tax-rate-rate",name:"tax_rate",type:"number",min:"0",max:"100",step:"0.0001",defaultValue:typeof e?.tax_rate=="number"?e.tax_rate.toString():"",placeholder:"5.0000",required:!0})]})]}),t.jsx("div",{className:"flex justify-end",children:t.jsx(s.Button,{type:"submit",size:a?"sm":"default",children:p})})]})}exports.TaxRateForm=C;
|
|
@@ -1,129 +1,69 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import { Label as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { normalizeCountryCode as
|
|
6
|
-
import { normalizeSubdivisionCode as
|
|
7
|
-
import { saveTaxRateAction as
|
|
8
|
-
function
|
|
2
|
+
import { jsxs as t, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { Label as c, Input as a, Button as S } from "@nextblock-cms/ui";
|
|
4
|
+
import { useState as p, useMemo as b } from "react";
|
|
5
|
+
import { normalizeCountryCode as i, countries as _ } from "../../../../countries.es.js";
|
|
6
|
+
import { normalizeSubdivisionCode as N, getStatesForCountry as x, countryUsesStructuredStates as $ } from "../../../../states.es.js";
|
|
7
|
+
import { saveTaxRateAction as F } from "../actions.es.js";
|
|
8
|
+
function q({
|
|
9
9
|
initialData: e,
|
|
10
|
-
submitLabel:
|
|
11
|
-
compact:
|
|
10
|
+
submitLabel: h = "Save tax rate",
|
|
11
|
+
compact: u = !1
|
|
12
12
|
}) {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
),
|
|
16
|
-
return /* @__PURE__ */
|
|
17
|
-
e?.id ? /* @__PURE__ */
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/* @__PURE__ */ s("div", { className: n ? "grid gap-4 md:grid-cols-4" : "grid gap-4 md:grid-cols-2 xl:grid-cols-4", children: [
|
|
23
|
-
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
24
|
-
/* @__PURE__ */ s(m, { htmlFor: e?.id ? `country-${e.id}` : "tax-rate-country", children: "Country" }, void 0, !1, {
|
|
25
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
26
|
-
lineNumber: 43,
|
|
27
|
-
columnNumber: 11
|
|
28
|
-
}, this),
|
|
29
|
-
/* @__PURE__ */ s(
|
|
13
|
+
const m = i(e?.country_code) || "US", [o, y] = p(m), [s, n] = p(
|
|
14
|
+
N(m, e?.state_code) || e?.state_code || ""
|
|
15
|
+
), f = b(() => x(o), [o]), v = $(o);
|
|
16
|
+
return /* @__PURE__ */ t("form", { action: F, className: "space-y-4", children: [
|
|
17
|
+
e?.id ? /* @__PURE__ */ r("input", { type: "hidden", name: "id", value: e.id }) : null,
|
|
18
|
+
/* @__PURE__ */ t("div", { className: u ? "grid gap-4 md:grid-cols-4" : "grid gap-4 md:grid-cols-2 xl:grid-cols-4", children: [
|
|
19
|
+
/* @__PURE__ */ t("div", { className: "space-y-2", children: [
|
|
20
|
+
/* @__PURE__ */ r(c, { htmlFor: e?.id ? `country-${e.id}` : "tax-rate-country", children: "Country" }),
|
|
21
|
+
/* @__PURE__ */ r(
|
|
30
22
|
"select",
|
|
31
23
|
{
|
|
32
24
|
id: e?.id ? `country-${e.id}` : "tax-rate-country",
|
|
33
25
|
name: "country_code",
|
|
34
26
|
value: o,
|
|
35
|
-
onChange: (
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
onChange: (d) => {
|
|
28
|
+
const l = d.target.value, g = x(l);
|
|
29
|
+
y(l), n(
|
|
30
|
+
g.some((C) => C.code === s) ? s : ""
|
|
39
31
|
);
|
|
40
32
|
},
|
|
41
33
|
className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
42
|
-
children:
|
|
43
|
-
|
|
44
|
-
lineNumber: 62,
|
|
45
|
-
columnNumber: 15
|
|
46
|
-
}, this))
|
|
47
|
-
},
|
|
48
|
-
void 0,
|
|
49
|
-
!1,
|
|
50
|
-
{
|
|
51
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
52
|
-
lineNumber: 46,
|
|
53
|
-
columnNumber: 11
|
|
54
|
-
},
|
|
55
|
-
this
|
|
34
|
+
children: _.map((d) => /* @__PURE__ */ r("option", { value: d.code, children: d.name }, d.code))
|
|
35
|
+
}
|
|
56
36
|
)
|
|
57
|
-
] },
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}, this),
|
|
62
|
-
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
63
|
-
/* @__PURE__ */ s(m, { htmlFor: e?.id ? `state-${e.id}` : "tax-rate-state", children: "State / Province" }, void 0, !1, {
|
|
64
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
65
|
-
lineNumber: 70,
|
|
66
|
-
columnNumber: 11
|
|
67
|
-
}, this),
|
|
68
|
-
b ? /* @__PURE__ */ s(
|
|
37
|
+
] }),
|
|
38
|
+
/* @__PURE__ */ t("div", { className: "space-y-2", children: [
|
|
39
|
+
/* @__PURE__ */ r(c, { htmlFor: e?.id ? `state-${e.id}` : "tax-rate-state", children: "State / Province" }),
|
|
40
|
+
v ? /* @__PURE__ */ t(
|
|
69
41
|
"select",
|
|
70
42
|
{
|
|
71
43
|
id: e?.id ? `state-${e.id}` : "tax-rate-state",
|
|
72
44
|
name: "state_code",
|
|
73
|
-
value:
|
|
74
|
-
onChange: (
|
|
45
|
+
value: s,
|
|
46
|
+
onChange: (d) => n(d.target.value),
|
|
75
47
|
className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
76
48
|
children: [
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
|
|
79
|
-
lineNumber: 81,
|
|
80
|
-
columnNumber: 15
|
|
81
|
-
}, this),
|
|
82
|
-
p.map((r) => /* @__PURE__ */ s("option", { value: r.code, children: r.name }, r.code, !1, {
|
|
83
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
84
|
-
lineNumber: 83,
|
|
85
|
-
columnNumber: 17
|
|
86
|
-
}, this))
|
|
49
|
+
/* @__PURE__ */ r("option", { value: "", children: "Country-wide / federal" }),
|
|
50
|
+
f.map((d) => /* @__PURE__ */ r("option", { value: d.code, children: d.name }, d.code))
|
|
87
51
|
]
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
!0,
|
|
91
|
-
{
|
|
92
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
93
|
-
lineNumber: 74,
|
|
94
|
-
columnNumber: 13
|
|
95
|
-
},
|
|
96
|
-
this
|
|
97
|
-
) : /* @__PURE__ */ s(
|
|
52
|
+
}
|
|
53
|
+
) : /* @__PURE__ */ r(
|
|
98
54
|
a,
|
|
99
55
|
{
|
|
100
56
|
id: e?.id ? `state-${e.id}` : "tax-rate-state",
|
|
101
57
|
name: "state_code",
|
|
102
|
-
value:
|
|
103
|
-
onChange: (
|
|
58
|
+
value: s,
|
|
59
|
+
onChange: (d) => n(d.target.value),
|
|
104
60
|
placeholder: "Optional"
|
|
105
|
-
}
|
|
106
|
-
void 0,
|
|
107
|
-
!1,
|
|
108
|
-
{
|
|
109
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
110
|
-
lineNumber: 89,
|
|
111
|
-
columnNumber: 13
|
|
112
|
-
},
|
|
113
|
-
this
|
|
61
|
+
}
|
|
114
62
|
)
|
|
115
|
-
] },
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}, this),
|
|
120
|
-
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
121
|
-
/* @__PURE__ */ s(m, { htmlFor: e?.id ? `name-${e.id}` : "tax-rate-name", children: "Tax name" }, void 0, !1, {
|
|
122
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
123
|
-
lineNumber: 100,
|
|
124
|
-
columnNumber: 11
|
|
125
|
-
}, this),
|
|
126
|
-
/* @__PURE__ */ s(
|
|
63
|
+
] }),
|
|
64
|
+
/* @__PURE__ */ t("div", { className: "space-y-2", children: [
|
|
65
|
+
/* @__PURE__ */ r(c, { htmlFor: e?.id ? `name-${e.id}` : "tax-rate-name", children: "Tax name" }),
|
|
66
|
+
/* @__PURE__ */ r(
|
|
127
67
|
a,
|
|
128
68
|
{
|
|
129
69
|
id: e?.id ? `name-${e.id}` : "tax-rate-name",
|
|
@@ -131,28 +71,12 @@ function _({
|
|
|
131
71
|
defaultValue: e?.tax_name || "",
|
|
132
72
|
placeholder: "GST, PST, State Sales Tax",
|
|
133
73
|
required: !0
|
|
134
|
-
}
|
|
135
|
-
void 0,
|
|
136
|
-
!1,
|
|
137
|
-
{
|
|
138
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
139
|
-
lineNumber: 103,
|
|
140
|
-
columnNumber: 11
|
|
141
|
-
},
|
|
142
|
-
this
|
|
74
|
+
}
|
|
143
75
|
)
|
|
144
|
-
] },
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}, this),
|
|
149
|
-
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
150
|
-
/* @__PURE__ */ s(m, { htmlFor: e?.id ? `rate-${e.id}` : "tax-rate-rate", children: "Rate (%)" }, void 0, !1, {
|
|
151
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
152
|
-
lineNumber: 113,
|
|
153
|
-
columnNumber: 11
|
|
154
|
-
}, this),
|
|
155
|
-
/* @__PURE__ */ s(
|
|
76
|
+
] }),
|
|
77
|
+
/* @__PURE__ */ t("div", { className: "space-y-2", children: [
|
|
78
|
+
/* @__PURE__ */ r(c, { htmlFor: e?.id ? `rate-${e.id}` : "tax-rate-rate", children: "Rate (%)" }),
|
|
79
|
+
/* @__PURE__ */ r(
|
|
156
80
|
a,
|
|
157
81
|
{
|
|
158
82
|
id: e?.id ? `rate-${e.id}` : "tax-rate-rate",
|
|
@@ -164,41 +88,13 @@ function _({
|
|
|
164
88
|
defaultValue: typeof e?.tax_rate == "number" ? e.tax_rate.toString() : "",
|
|
165
89
|
placeholder: "5.0000",
|
|
166
90
|
required: !0
|
|
167
|
-
}
|
|
168
|
-
void 0,
|
|
169
|
-
!1,
|
|
170
|
-
{
|
|
171
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
172
|
-
lineNumber: 116,
|
|
173
|
-
columnNumber: 11
|
|
174
|
-
},
|
|
175
|
-
this
|
|
91
|
+
}
|
|
176
92
|
)
|
|
177
|
-
] }
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}, this)
|
|
182
|
-
] }, void 0, !0, {
|
|
183
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
184
|
-
lineNumber: 41,
|
|
185
|
-
columnNumber: 7
|
|
186
|
-
}, this),
|
|
187
|
-
/* @__PURE__ */ s("div", { className: "flex justify-end", children: /* @__PURE__ */ s(R, { type: "submit", size: n ? "sm" : "default", children: x }, void 0, !1, {
|
|
188
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
189
|
-
lineNumber: 133,
|
|
190
|
-
columnNumber: 9
|
|
191
|
-
}, this) }, void 0, !1, {
|
|
192
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
193
|
-
lineNumber: 132,
|
|
194
|
-
columnNumber: 7
|
|
195
|
-
}, this)
|
|
196
|
-
] }, void 0, !0, {
|
|
197
|
-
fileName: "C:/Users/desjardinsn/Desktop/NRH-NextBlock/libs/ecommerce/src/lib/pages/cms/taxes/components/TaxRateForm.tsx",
|
|
198
|
-
lineNumber: 38,
|
|
199
|
-
columnNumber: 5
|
|
200
|
-
}, this);
|
|
93
|
+
] })
|
|
94
|
+
] }),
|
|
95
|
+
/* @__PURE__ */ r("div", { className: "flex justify-end", children: /* @__PURE__ */ r(S, { type: "submit", size: u ? "sm" : "default", children: h }) })
|
|
96
|
+
] });
|
|
201
97
|
}
|
|
202
98
|
export {
|
|
203
|
-
|
|
99
|
+
q as TaxRateForm
|
|
204
100
|
};
|
package/lib/product-actions.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
-
import { Database } from '
|
|
2
|
+
import { Database } from '@nextblock-cms/db/types';
|
|
3
3
|
import { ProductFormValues } from './product-schema';
|
|
4
4
|
export declare function getProducts(supabase: SupabaseClient<Database>, { page, limit, offset, search, languageId, categoryId, categoryIds, productIds, translationGroupIds, status, }?: {
|
|
5
5
|
page?: number;
|
|
@@ -28,13 +28,13 @@ export declare function getProducts(supabase: SupabaseClient<Database>, { page,
|
|
|
28
28
|
sku: string;
|
|
29
29
|
upc: string | null;
|
|
30
30
|
price: number;
|
|
31
|
-
prices: import('
|
|
31
|
+
prices: import('@nextblock-cms/db').Json;
|
|
32
32
|
sale_price: number | null;
|
|
33
|
-
sale_prices: import('
|
|
33
|
+
sale_prices: import('@nextblock-cms/db').Json;
|
|
34
34
|
sale_start_at: string | null;
|
|
35
35
|
sale_end_at: string | null;
|
|
36
36
|
scheduled_price: number | null;
|
|
37
|
-
scheduled_prices: import('
|
|
37
|
+
scheduled_prices: import('@nextblock-cms/db').Json;
|
|
38
38
|
scheduled_price_at: string | null;
|
|
39
39
|
is_taxable: boolean;
|
|
40
40
|
product_type: string;
|
|
@@ -58,13 +58,13 @@ export declare function getProducts(supabase: SupabaseClient<Database>, { page,
|
|
|
58
58
|
product_variants: {
|
|
59
59
|
id: string;
|
|
60
60
|
price: number;
|
|
61
|
-
prices: import('
|
|
61
|
+
prices: import('@nextblock-cms/db').Json;
|
|
62
62
|
sale_price: number | null;
|
|
63
|
-
sale_prices: import('
|
|
63
|
+
sale_prices: import('@nextblock-cms/db').Json;
|
|
64
64
|
sale_start_at: string | null;
|
|
65
65
|
sale_end_at: string | null;
|
|
66
66
|
scheduled_price: number | null;
|
|
67
|
-
scheduled_prices: import('
|
|
67
|
+
scheduled_prices: import('@nextblock-cms/db').Json;
|
|
68
68
|
scheduled_price_at: string | null;
|
|
69
69
|
}[];
|
|
70
70
|
freemius_plans: {
|
|
@@ -89,8 +89,8 @@ export declare function getProducts(supabase: SupabaseClient<Database>, { page,
|
|
|
89
89
|
name: string;
|
|
90
90
|
slug: string;
|
|
91
91
|
description: string | null;
|
|
92
|
-
name_translations: import('
|
|
93
|
-
description_translations: import('
|
|
92
|
+
name_translations: import('@nextblock-cms/db').Json;
|
|
93
|
+
description_translations: import('@nextblock-cms/db').Json;
|
|
94
94
|
};
|
|
95
95
|
}[];
|
|
96
96
|
}[]> | {
|
|
@@ -106,7 +106,7 @@ export declare function getProduct(supabase: SupabaseClient<Database>, id: strin
|
|
|
106
106
|
average_rating: number;
|
|
107
107
|
created_at: string | null;
|
|
108
108
|
custom_canonical: string | null;
|
|
109
|
-
description_json: import('
|
|
109
|
+
description_json: import('@nextblock-cms/db').Json | null;
|
|
110
110
|
freemius_plan_id: string | null;
|
|
111
111
|
freemius_product_id: string | null;
|
|
112
112
|
id: string;
|
|
@@ -114,19 +114,19 @@ export declare function getProduct(supabase: SupabaseClient<Database>, id: strin
|
|
|
114
114
|
language_id: number;
|
|
115
115
|
meta_description: string | null;
|
|
116
116
|
meta_title: string | null;
|
|
117
|
-
metadata: import('
|
|
117
|
+
metadata: import('@nextblock-cms/db').Json | null;
|
|
118
118
|
payment_provider: string;
|
|
119
119
|
price: number;
|
|
120
|
-
prices: import('
|
|
120
|
+
prices: import('@nextblock-cms/db').Json;
|
|
121
121
|
product_type: string;
|
|
122
122
|
published_at: string | null;
|
|
123
123
|
sale_end_at: string | null;
|
|
124
124
|
sale_price: number | null;
|
|
125
|
-
sale_prices: import('
|
|
125
|
+
sale_prices: import('@nextblock-cms/db').Json | null;
|
|
126
126
|
sale_start_at: string | null;
|
|
127
127
|
scheduled_price: number | null;
|
|
128
128
|
scheduled_price_at: string | null;
|
|
129
|
-
scheduled_prices: import('
|
|
129
|
+
scheduled_prices: import('@nextblock-cms/db').Json | null;
|
|
130
130
|
short_description: string | null;
|
|
131
131
|
sku: string;
|
|
132
132
|
slug: string;
|
|
@@ -162,13 +162,13 @@ export declare function getProduct(supabase: SupabaseClient<Database>, id: strin
|
|
|
162
162
|
upc: string | null;
|
|
163
163
|
main_media_id: string | null;
|
|
164
164
|
price: number;
|
|
165
|
-
prices: import('
|
|
165
|
+
prices: import('@nextblock-cms/db').Json;
|
|
166
166
|
sale_price: number | null;
|
|
167
|
-
sale_prices: import('
|
|
167
|
+
sale_prices: import('@nextblock-cms/db').Json;
|
|
168
168
|
sale_start_at: string | null;
|
|
169
169
|
sale_end_at: string | null;
|
|
170
170
|
scheduled_price: number | null;
|
|
171
|
-
scheduled_prices: import('
|
|
171
|
+
scheduled_prices: import('@nextblock-cms/db').Json;
|
|
172
172
|
scheduled_price_at: string | null;
|
|
173
173
|
stock_quantity: number;
|
|
174
174
|
media: {
|
|
@@ -185,12 +185,12 @@ export declare function getProduct(supabase: SupabaseClient<Database>, id: strin
|
|
|
185
185
|
value: string;
|
|
186
186
|
slug: string;
|
|
187
187
|
sort_order: number;
|
|
188
|
-
value_translations: import('
|
|
188
|
+
value_translations: import('@nextblock-cms/db').Json;
|
|
189
189
|
product_attributes: {
|
|
190
190
|
id: string;
|
|
191
191
|
name: string;
|
|
192
192
|
slug: string;
|
|
193
|
-
name_translations: import('
|
|
193
|
+
name_translations: import('@nextblock-cms/db').Json;
|
|
194
194
|
};
|
|
195
195
|
};
|
|
196
196
|
}[];
|
|
@@ -217,8 +217,8 @@ export declare function getProduct(supabase: SupabaseClient<Database>, id: strin
|
|
|
217
217
|
name: string;
|
|
218
218
|
slug: string;
|
|
219
219
|
description: string | null;
|
|
220
|
-
name_translations: import('
|
|
221
|
-
description_translations: import('
|
|
220
|
+
name_translations: import('@nextblock-cms/db').Json;
|
|
221
|
+
description_translations: import('@nextblock-cms/db').Json;
|
|
222
222
|
};
|
|
223
223
|
}[];
|
|
224
224
|
}>>;
|
|
@@ -233,7 +233,7 @@ export declare function createProduct(supabase: SupabaseClient<Database>, data:
|
|
|
233
233
|
average_rating: number;
|
|
234
234
|
created_at: string | null;
|
|
235
235
|
custom_canonical: string | null;
|
|
236
|
-
description_json: import('
|
|
236
|
+
description_json: import('@nextblock-cms/db').Json | null;
|
|
237
237
|
freemius_plan_id: string | null;
|
|
238
238
|
freemius_product_id: string | null;
|
|
239
239
|
id: string;
|
|
@@ -241,19 +241,19 @@ export declare function createProduct(supabase: SupabaseClient<Database>, data:
|
|
|
241
241
|
language_id: number;
|
|
242
242
|
meta_description: string | null;
|
|
243
243
|
meta_title: string | null;
|
|
244
|
-
metadata: import('
|
|
244
|
+
metadata: import('@nextblock-cms/db').Json | null;
|
|
245
245
|
payment_provider: string;
|
|
246
246
|
price: number;
|
|
247
|
-
prices: import('
|
|
247
|
+
prices: import('@nextblock-cms/db').Json;
|
|
248
248
|
product_type: string;
|
|
249
249
|
published_at: string | null;
|
|
250
250
|
sale_end_at: string | null;
|
|
251
251
|
sale_price: number | null;
|
|
252
|
-
sale_prices: import('
|
|
252
|
+
sale_prices: import('@nextblock-cms/db').Json | null;
|
|
253
253
|
sale_start_at: string | null;
|
|
254
254
|
scheduled_price: number | null;
|
|
255
255
|
scheduled_price_at: string | null;
|
|
256
|
-
scheduled_prices: import('
|
|
256
|
+
scheduled_prices: import('@nextblock-cms/db').Json | null;
|
|
257
257
|
short_description: string | null;
|
|
258
258
|
sku: string;
|
|
259
259
|
slug: string;
|
|
@@ -272,7 +272,7 @@ export declare function updateProduct(supabase: SupabaseClient<Database>, id: st
|
|
|
272
272
|
average_rating: number;
|
|
273
273
|
created_at: string | null;
|
|
274
274
|
custom_canonical: string | null;
|
|
275
|
-
description_json: import('
|
|
275
|
+
description_json: import('@nextblock-cms/db').Json | null;
|
|
276
276
|
freemius_plan_id: string | null;
|
|
277
277
|
freemius_product_id: string | null;
|
|
278
278
|
id: string;
|
|
@@ -280,19 +280,19 @@ export declare function updateProduct(supabase: SupabaseClient<Database>, id: st
|
|
|
280
280
|
language_id: number;
|
|
281
281
|
meta_description: string | null;
|
|
282
282
|
meta_title: string | null;
|
|
283
|
-
metadata: import('
|
|
283
|
+
metadata: import('@nextblock-cms/db').Json | null;
|
|
284
284
|
payment_provider: string;
|
|
285
285
|
price: number;
|
|
286
|
-
prices: import('
|
|
286
|
+
prices: import('@nextblock-cms/db').Json;
|
|
287
287
|
product_type: string;
|
|
288
288
|
published_at: string | null;
|
|
289
289
|
sale_end_at: string | null;
|
|
290
290
|
sale_price: number | null;
|
|
291
|
-
sale_prices: import('
|
|
291
|
+
sale_prices: import('@nextblock-cms/db').Json | null;
|
|
292
292
|
sale_start_at: string | null;
|
|
293
293
|
scheduled_price: number | null;
|
|
294
294
|
scheduled_price_at: string | null;
|
|
295
|
-
scheduled_prices: import('
|
|
295
|
+
scheduled_prices: import('@nextblock-cms/db').Json | null;
|
|
296
296
|
short_description: string | null;
|
|
297
297
|
sku: string;
|
|
298
298
|
slug: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),e=require("react"),r=e.createContext(void 0),c=({product:t,children:o})=>u.jsx(r.Provider,{value:{product:t},children:o}),n=()=>{const t=e.useContext(r);if(!t)throw new Error("useProduct must be used within a ProductProvider. Ensure the component is wrapped in a ProductProvider.");return t.product};exports.ProductProvider=c;exports.useProduct=n;
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import { createContext as n, useContext as
|
|
4
|
-
const
|
|
5
|
-
product:
|
|
2
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as n, useContext as u } from "react";
|
|
4
|
+
const t = n(void 0), i = ({
|
|
5
|
+
product: r,
|
|
6
6
|
children: o
|
|
7
|
-
}) => /* @__PURE__ */ t
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
columnNumber: 5
|
|
11
|
-
}, void 0), i = () => {
|
|
12
|
-
const e = c(r);
|
|
13
|
-
if (!e)
|
|
7
|
+
}) => /* @__PURE__ */ e(t.Provider, { value: { product: r }, children: o }), s = () => {
|
|
8
|
+
const r = u(t);
|
|
9
|
+
if (!r)
|
|
14
10
|
throw new Error("useProduct must be used within a ProductProvider. Ensure the component is wrapped in a ProductProvider.");
|
|
15
|
-
return
|
|
11
|
+
return r.product;
|
|
16
12
|
};
|
|
17
13
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
i as ProductProvider,
|
|
15
|
+
s as useProduct
|
|
20
16
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
-
import { Database } from '
|
|
2
|
+
import { Database } from '@nextblock-cms/db/types';
|
|
3
3
|
import { ProductFormValues } from './product-schema';
|
|
4
4
|
export type InventoryUsageType = 'product' | 'variant' | 'mixed';
|
|
5
5
|
export interface InventoryItem {
|
package/lib/states.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./countries.cjs.js"),S=[{code:"AL",name:"Alabama"},{code:"AK",name:"Alaska"},{code:"AZ",name:"Arizona"},{code:"AR",name:"Arkansas"},{code:"CA",name:"California"},{code:"CO",name:"Colorado"},{code:"CT",name:"Connecticut"},{code:"DE",name:"Delaware"},{code:"DC",name:"District of Columbia"},{code:"FL",name:"Florida"},{code:"GA",name:"Georgia"},{code:"HI",name:"Hawaii"},{code:"ID",name:"Idaho"},{code:"IL",name:"Illinois"},{code:"IN",name:"Indiana"},{code:"IA",name:"Iowa"},{code:"KS",name:"Kansas"},{code:"KY",name:"Kentucky"},{code:"LA",name:"Louisiana"},{code:"ME",name:"Maine"},{code:"MD",name:"Maryland"},{code:"MA",name:"Massachusetts"},{code:"MI",name:"Michigan"},{code:"MN",name:"Minnesota"},{code:"MS",name:"Mississippi"},{code:"MO",name:"Missouri"},{code:"MT",name:"Montana"},{code:"NE",name:"Nebraska"},{code:"NV",name:"Nevada"},{code:"NH",name:"New Hampshire"},{code:"NJ",name:"New Jersey"},{code:"NM",name:"New Mexico"},{code:"NY",name:"New York"},{code:"NC",name:"North Carolina"},{code:"ND",name:"North Dakota"},{code:"OH",name:"Ohio"},{code:"OK",name:"Oklahoma"},{code:"OR",name:"Oregon"},{code:"PA",name:"Pennsylvania"},{code:"RI",name:"Rhode Island"},{code:"SC",name:"South Carolina"},{code:"SD",name:"South Dakota"},{code:"TN",name:"Tennessee"},{code:"TX",name:"Texas"},{code:"UT",name:"Utah"},{code:"VT",name:"Vermont"},{code:"VA",name:"Virginia"},{code:"WA",name:"Washington"},{code:"WV",name:"West Virginia"},{code:"WI",name:"Wisconsin"},{code:"WY",name:"Wyoming"}],
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./countries.cjs.js"),S=[{code:"AL",name:"Alabama"},{code:"AK",name:"Alaska"},{code:"AZ",name:"Arizona"},{code:"AR",name:"Arkansas"},{code:"CA",name:"California"},{code:"CO",name:"Colorado"},{code:"CT",name:"Connecticut"},{code:"DE",name:"Delaware"},{code:"DC",name:"District of Columbia"},{code:"FL",name:"Florida"},{code:"GA",name:"Georgia"},{code:"HI",name:"Hawaii"},{code:"ID",name:"Idaho"},{code:"IL",name:"Illinois"},{code:"IN",name:"Indiana"},{code:"IA",name:"Iowa"},{code:"KS",name:"Kansas"},{code:"KY",name:"Kentucky"},{code:"LA",name:"Louisiana"},{code:"ME",name:"Maine"},{code:"MD",name:"Maryland"},{code:"MA",name:"Massachusetts"},{code:"MI",name:"Michigan"},{code:"MN",name:"Minnesota"},{code:"MS",name:"Mississippi"},{code:"MO",name:"Missouri"},{code:"MT",name:"Montana"},{code:"NE",name:"Nebraska"},{code:"NV",name:"Nevada"},{code:"NH",name:"New Hampshire"},{code:"NJ",name:"New Jersey"},{code:"NM",name:"New Mexico"},{code:"NY",name:"New York"},{code:"NC",name:"North Carolina"},{code:"ND",name:"North Dakota"},{code:"OH",name:"Ohio"},{code:"OK",name:"Oklahoma"},{code:"OR",name:"Oregon"},{code:"PA",name:"Pennsylvania"},{code:"RI",name:"Rhode Island"},{code:"SC",name:"South Carolina"},{code:"SD",name:"South Dakota"},{code:"TN",name:"Tennessee"},{code:"TX",name:"Texas"},{code:"UT",name:"Utah"},{code:"VT",name:"Vermont"},{code:"VA",name:"Virginia"},{code:"WA",name:"Washington"},{code:"WV",name:"West Virginia"},{code:"WI",name:"Wisconsin"},{code:"WY",name:"Wyoming"}],A=[{code:"AB",name:"Alberta"},{code:"BC",name:"British Columbia"},{code:"MB",name:"Manitoba"},{code:"NB",name:"New Brunswick"},{code:"NL",name:"Newfoundland and Labrador"},{code:"NS",name:"Nova Scotia"},{code:"NT",name:"Northwest Territories"},{code:"NU",name:"Nunavut"},{code:"ON",name:"Ontario"},{code:"PE",name:"Prince Edward Island"},{code:"QC",name:"Quebec"},{code:"SK",name:"Saskatchewan"},{code:"YT",name:"Yukon"}],d={US:S,CA:A},I={CA:{BC:"Colombie-Britannique",NB:"Nouveau-Brunswick",NL:"Terre-Neuve-et-Labrador",NS:"Nouvelle-Écosse",NT:"Territoires du Nord-Ouest",PE:"Île-du-Prince-Édouard",QC:"Québec"},US:{CA:"Californie",DC:"District de Columbia",FL:"Floride",GA:"Géorgie",HI:"Hawaï",LA:"Louisiane",NC:"Caroline du Nord",ND:"Dakota du Nord",NM:"Nouveau-Mexique",PA:"Pennsylvanie",SC:"Caroline du Sud",SD:"Dakota du Sud",VA:"Virginie",WV:"Virginie-Occidentale"}};function T(n,e,a){if(!a||!a.toLowerCase().startsWith("fr"))return e.name;const o=r.normalizeCountryCode(n);return o&&I[o]?.[e.code]||e.name}const u={US:{CALIFORNIA:"CA",NEWYORK:"NY","NEW YORK":"NY",DISTRICTOFCOLUMBIA:"DC","DISTRICT OF COLUMBIA":"DC"},CA:{QUEBEC:"QC",ONTARIO:"ON","BRITISH COLUMBIA":"BC",BRITISHCOLUMBIA:"BC","NEWFOUNDLAND AND LABRADOR":"NL",NEWFOUNDLANDANDLABRADOR:"NL","NORTHWEST TERRITORIES":"NT",NORTHWESTTERRITORIES:"NT","PRINCE EDWARD ISLAND":"PE",PRINCEEDWARDISLAND:"PE"}};function N(n){const e=r.normalizeCountryCode(n);return e?d[e]??[]:[]}function O(n){return N(n).length>0}function C(n,e){const a=r.normalizeCountryCode(n),o=e?.trim();if(!a||!o)return o||null;const c=d[a];if(!c?.length)return o.toUpperCase();const i=o.toUpperCase(),m=c.find(t=>t.code===i);if(m)return m.code;const s=c.find(t=>t.name.toUpperCase()===i);if(s)return s.code;const l=i.replace(/\s+/g,"");return u[a]?.[i]??u[a]?.[l]??i}function D(n,e){const a=r.normalizeCountryCode(n),o=C(n,e);return!a||!o?e??null:d[a]?.find(i=>i.code===o)?.name??o}exports.STATES_BY_COUNTRY=d;exports.countryUsesStructuredStates=O;exports.getStatesForCountry=N;exports.getSubdivisionLabel=T;exports.normalizeSubdivisionCode=C;exports.resolveSubdivisionName=D;
|
package/lib/states.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export interface CountrySubdivision {
|
|
|
3
3
|
name: string;
|
|
4
4
|
}
|
|
5
5
|
export declare const STATES_BY_COUNTRY: Record<string, CountrySubdivision[]>;
|
|
6
|
+
/** The subdivision's name in the visitor's language. The stored value stays the code. */
|
|
7
|
+
export declare function getSubdivisionLabel(countryCode: string | null | undefined, subdivision: CountrySubdivision, lang?: string | null): string;
|
|
6
8
|
export declare function getStatesForCountry(countryCode?: string | null): CountrySubdivision[];
|
|
7
9
|
export declare function countryUsesStructuredStates(countryCode?: string | null): boolean;
|
|
8
10
|
export declare function normalizeSubdivisionCode(countryCode?: string | null, stateCodeOrName?: string | null): string | null;
|