@nextblock-cms/ecom 0.19.2 → 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/lib/components/Cart.cjs.js +1 -1
- package/lib/components/Cart.d.ts +1 -1
- package/lib/components/Cart.es.js +70 -62
- package/lib/components/Checkout.cjs.js +1 -1
- package/lib/components/Checkout.d.ts +1 -1
- package/lib/components/Checkout.es.js +224 -212
- package/lib/components/CustomerProfileForm.d.ts +1 -1
- package/lib/components/FeaturedProduct.cjs.js +1 -1
- package/lib/components/FeaturedProduct.es.js +29 -22
- package/lib/components/ProductDetailsLayout.cjs.js +1 -1
- package/lib/components/ProductDetailsLayout.es.js +27 -28
- package/lib/components/ShippingEstimator.cjs.js +1 -1
- package/lib/components/ShippingEstimator.es.js +64 -58
- 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/media/MediaPickerDialog.d.ts +1 -1
- package/lib/components/media/MediaUploadForm.d.ts +1 -1
- package/lib/order-inventory.d.ts +1 -1
- package/lib/pages/cms/products/actions.d.ts +20 -20
- package/lib/pages/cms/products/attributes/components/AttributeManager.d.ts +1 -1
- package/lib/pages/cms/shipping/components/RateForm.d.ts +1 -1
- package/lib/product-actions.d.ts +31 -31
- 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/package.json +4 -4
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* `products.short_description` is authored as plain text (the visual editor's textarea, the
|
|
4
|
+
* Cortex tools, the seed), but older rows carry HTML, some with an embed. The product page
|
|
5
|
+
* used to render it as HTML and the featured-product block as text, so the same row showed
|
|
6
|
+
* raw tags in one place and a working embed in the other.
|
|
7
|
+
*/
|
|
8
|
+
export declare const isHtmlShortDescription: (value: string) => boolean;
|
|
9
|
+
interface ShortDescriptionProps {
|
|
10
|
+
value: string | null | undefined;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Renders a product's short description the same way everywhere: HTML when the text contains
|
|
15
|
+
* markup (embeds rewritten to the no-cookie host), otherwise as escaped text that keeps its
|
|
16
|
+
* line breaks. Staff-authored either way; no user input reaches this field.
|
|
17
|
+
*/
|
|
18
|
+
export declare function ShortDescription({ value, className }: ShortDescriptionProps): React.JSX.Element | null;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { cn as i } from "@nextblock-cms/utils";
|
|
3
|
+
import { toNoCookieEmbedSrc as n } from "./SimpleTiptapRenderer.es.js";
|
|
4
|
+
const c = /<\/?[a-z][^>]*>/i, m = (r) => c.test(r);
|
|
5
|
+
function f({ value: r, className: o }) {
|
|
6
|
+
const t = r?.trim();
|
|
7
|
+
return t ? m(t) ? /* @__PURE__ */ e(
|
|
8
|
+
"div",
|
|
9
|
+
{
|
|
10
|
+
className: o,
|
|
11
|
+
dangerouslySetInnerHTML: { __html: n(t) ?? t }
|
|
12
|
+
}
|
|
13
|
+
) : /* @__PURE__ */ e("p", { className: i("whitespace-pre-line", o), children: t }) : null;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
f as ShortDescription,
|
|
17
|
+
m as isHtmlShortDescription
|
|
18
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { Database } from '
|
|
2
|
+
import { Database } from '@nextblock-cms/db';
|
|
3
3
|
type Media = Database["public"]["Tables"]["media"]["Row"];
|
|
4
4
|
interface MediaPickerDialogProps {
|
|
5
5
|
triggerLabel?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { Database } from '
|
|
2
|
+
import { Database } from '@nextblock-cms/db';
|
|
3
3
|
type Media = Database['public']['Tables']['media']['Row'];
|
|
4
4
|
interface MediaUploadFormProps {
|
|
5
5
|
onUploadSuccess?: (newMedia: Media) => void;
|
package/lib/order-inventory.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';
|
|
3
3
|
export declare function applyOrderInventoryDeduction(supabase: SupabaseClient<Database>, orderId: string): Promise<{
|
|
4
4
|
method: "rpc";
|
|
5
5
|
} | {
|
|
@@ -14,13 +14,13 @@ export declare function getProducts(options?: {
|
|
|
14
14
|
sku: string;
|
|
15
15
|
upc: string | null;
|
|
16
16
|
price: number;
|
|
17
|
-
prices: import('
|
|
17
|
+
prices: import('@nextblock-cms/db').Json;
|
|
18
18
|
sale_price: number | null;
|
|
19
|
-
sale_prices: import('
|
|
19
|
+
sale_prices: import('@nextblock-cms/db').Json;
|
|
20
20
|
sale_start_at: string | null;
|
|
21
21
|
sale_end_at: string | null;
|
|
22
22
|
scheduled_price: number | null;
|
|
23
|
-
scheduled_prices: import('
|
|
23
|
+
scheduled_prices: import('@nextblock-cms/db').Json;
|
|
24
24
|
scheduled_price_at: string | null;
|
|
25
25
|
is_taxable: boolean;
|
|
26
26
|
product_type: string;
|
|
@@ -44,13 +44,13 @@ export declare function getProducts(options?: {
|
|
|
44
44
|
product_variants: {
|
|
45
45
|
id: string;
|
|
46
46
|
price: number;
|
|
47
|
-
prices: import('
|
|
47
|
+
prices: import('@nextblock-cms/db').Json;
|
|
48
48
|
sale_price: number | null;
|
|
49
|
-
sale_prices: import('
|
|
49
|
+
sale_prices: import('@nextblock-cms/db').Json;
|
|
50
50
|
sale_start_at: string | null;
|
|
51
51
|
sale_end_at: string | null;
|
|
52
52
|
scheduled_price: number | null;
|
|
53
|
-
scheduled_prices: import('
|
|
53
|
+
scheduled_prices: import('@nextblock-cms/db').Json;
|
|
54
54
|
scheduled_price_at: string | null;
|
|
55
55
|
}[];
|
|
56
56
|
freemius_plans: {
|
|
@@ -75,8 +75,8 @@ export declare function getProducts(options?: {
|
|
|
75
75
|
name: string;
|
|
76
76
|
slug: string;
|
|
77
77
|
description: string | null;
|
|
78
|
-
name_translations: import('
|
|
79
|
-
description_translations: import('
|
|
78
|
+
name_translations: import('@nextblock-cms/db').Json;
|
|
79
|
+
description_translations: import('@nextblock-cms/db').Json;
|
|
80
80
|
};
|
|
81
81
|
}[];
|
|
82
82
|
}[];
|
|
@@ -86,7 +86,7 @@ export declare function getProduct(id: string): Promise<{
|
|
|
86
86
|
average_rating: number;
|
|
87
87
|
created_at: string | null;
|
|
88
88
|
custom_canonical: string | null;
|
|
89
|
-
description_json: import('
|
|
89
|
+
description_json: import('@nextblock-cms/db').Json | null;
|
|
90
90
|
freemius_plan_id: string | null;
|
|
91
91
|
freemius_product_id: string | null;
|
|
92
92
|
id: string;
|
|
@@ -94,19 +94,19 @@ export declare function getProduct(id: string): Promise<{
|
|
|
94
94
|
language_id: number;
|
|
95
95
|
meta_description: string | null;
|
|
96
96
|
meta_title: string | null;
|
|
97
|
-
metadata: import('
|
|
97
|
+
metadata: import('@nextblock-cms/db').Json | null;
|
|
98
98
|
payment_provider: string;
|
|
99
99
|
price: number;
|
|
100
|
-
prices: import('
|
|
100
|
+
prices: import('@nextblock-cms/db').Json;
|
|
101
101
|
product_type: string;
|
|
102
102
|
published_at: string | null;
|
|
103
103
|
sale_end_at: string | null;
|
|
104
104
|
sale_price: number | null;
|
|
105
|
-
sale_prices: import('
|
|
105
|
+
sale_prices: import('@nextblock-cms/db').Json | null;
|
|
106
106
|
sale_start_at: string | null;
|
|
107
107
|
scheduled_price: number | null;
|
|
108
108
|
scheduled_price_at: string | null;
|
|
109
|
-
scheduled_prices: import('
|
|
109
|
+
scheduled_prices: import('@nextblock-cms/db').Json | null;
|
|
110
110
|
short_description: string | null;
|
|
111
111
|
sku: string;
|
|
112
112
|
slug: string;
|
|
@@ -142,13 +142,13 @@ export declare function getProduct(id: string): Promise<{
|
|
|
142
142
|
upc: string | null;
|
|
143
143
|
main_media_id: string | null;
|
|
144
144
|
price: number;
|
|
145
|
-
prices: import('
|
|
145
|
+
prices: import('@nextblock-cms/db').Json;
|
|
146
146
|
sale_price: number | null;
|
|
147
|
-
sale_prices: import('
|
|
147
|
+
sale_prices: import('@nextblock-cms/db').Json;
|
|
148
148
|
sale_start_at: string | null;
|
|
149
149
|
sale_end_at: string | null;
|
|
150
150
|
scheduled_price: number | null;
|
|
151
|
-
scheduled_prices: import('
|
|
151
|
+
scheduled_prices: import('@nextblock-cms/db').Json;
|
|
152
152
|
scheduled_price_at: string | null;
|
|
153
153
|
stock_quantity: number;
|
|
154
154
|
media: {
|
|
@@ -165,12 +165,12 @@ export declare function getProduct(id: string): Promise<{
|
|
|
165
165
|
value: string;
|
|
166
166
|
slug: string;
|
|
167
167
|
sort_order: number;
|
|
168
|
-
value_translations: import('
|
|
168
|
+
value_translations: import('@nextblock-cms/db').Json;
|
|
169
169
|
product_attributes: {
|
|
170
170
|
id: string;
|
|
171
171
|
name: string;
|
|
172
172
|
slug: string;
|
|
173
|
-
name_translations: import('
|
|
173
|
+
name_translations: import('@nextblock-cms/db').Json;
|
|
174
174
|
};
|
|
175
175
|
};
|
|
176
176
|
}[];
|
|
@@ -197,8 +197,8 @@ export declare function getProduct(id: string): Promise<{
|
|
|
197
197
|
name: string;
|
|
198
198
|
slug: string;
|
|
199
199
|
description: string | null;
|
|
200
|
-
name_translations: import('
|
|
201
|
-
description_translations: import('
|
|
200
|
+
name_translations: import('@nextblock-cms/db').Json;
|
|
201
|
+
description_translations: import('@nextblock-cms/db').Json;
|
|
202
202
|
};
|
|
203
203
|
}[];
|
|
204
204
|
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProductAttribute } from '../../../../../types';
|
|
2
|
-
import { Database } from '
|
|
2
|
+
import { Database } from '@nextblock-cms/db';
|
|
3
3
|
type Language = Database['public']['Tables']['languages']['Row'];
|
|
4
4
|
interface AttributeManagerProps {
|
|
5
5
|
attributes: ProductAttribute[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Database } from '
|
|
1
|
+
import { Database } from '@nextblock-cms/db';
|
|
2
2
|
import { CurrencyRecord } from '../../../../currency';
|
|
3
3
|
import { ShippingRateCurrencyMode } from '../../../../shipping-rate-currency';
|
|
4
4
|
type Language = Pick<Database['public']['Tables']['languages']['Row'], 'code' | 'name' | 'is_default'>;
|
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,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;
|
package/lib/states.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeCountryCode as
|
|
1
|
+
import { normalizeCountryCode as i } from "./countries.es.js";
|
|
2
2
|
const C = [
|
|
3
3
|
{ code: "AL", name: "Alabama" },
|
|
4
4
|
{ code: "AK", name: "Alaska" },
|
|
@@ -51,7 +51,7 @@ const C = [
|
|
|
51
51
|
{ code: "WV", name: "West Virginia" },
|
|
52
52
|
{ code: "WI", name: "Wisconsin" },
|
|
53
53
|
{ code: "WY", name: "Wyoming" }
|
|
54
|
-
],
|
|
54
|
+
], A = [
|
|
55
55
|
{ code: "AB", name: "Alberta" },
|
|
56
56
|
{ code: "BC", name: "British Columbia" },
|
|
57
57
|
{ code: "MB", name: "Manitoba" },
|
|
@@ -65,10 +65,43 @@ const C = [
|
|
|
65
65
|
{ code: "QC", name: "Quebec" },
|
|
66
66
|
{ code: "SK", name: "Saskatchewan" },
|
|
67
67
|
{ code: "YT", name: "Yukon" }
|
|
68
|
-
],
|
|
68
|
+
], t = {
|
|
69
69
|
US: C,
|
|
70
|
-
CA:
|
|
71
|
-
},
|
|
70
|
+
CA: A
|
|
71
|
+
}, l = {
|
|
72
|
+
CA: {
|
|
73
|
+
BC: "Colombie-Britannique",
|
|
74
|
+
NB: "Nouveau-Brunswick",
|
|
75
|
+
NL: "Terre-Neuve-et-Labrador",
|
|
76
|
+
NS: "Nouvelle-Écosse",
|
|
77
|
+
NT: "Territoires du Nord-Ouest",
|
|
78
|
+
PE: "Île-du-Prince-Édouard",
|
|
79
|
+
QC: "Québec"
|
|
80
|
+
},
|
|
81
|
+
US: {
|
|
82
|
+
CA: "Californie",
|
|
83
|
+
DC: "District de Columbia",
|
|
84
|
+
FL: "Floride",
|
|
85
|
+
GA: "Géorgie",
|
|
86
|
+
HI: "Hawaï",
|
|
87
|
+
LA: "Louisiane",
|
|
88
|
+
NC: "Caroline du Nord",
|
|
89
|
+
ND: "Dakota du Nord",
|
|
90
|
+
NM: "Nouveau-Mexique",
|
|
91
|
+
PA: "Pennsylvanie",
|
|
92
|
+
SC: "Caroline du Sud",
|
|
93
|
+
SD: "Dakota du Sud",
|
|
94
|
+
VA: "Virginie",
|
|
95
|
+
WV: "Virginie-Occidentale"
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
function T(n, e, o) {
|
|
99
|
+
if (!o || !o.toLowerCase().startsWith("fr"))
|
|
100
|
+
return e.name;
|
|
101
|
+
const a = i(n);
|
|
102
|
+
return a && l[a]?.[e.code] || e.name;
|
|
103
|
+
}
|
|
104
|
+
const s = {
|
|
72
105
|
US: {
|
|
73
106
|
CALIFORNIA: "CA",
|
|
74
107
|
NEWYORK: "NY",
|
|
@@ -89,39 +122,40 @@ const C = [
|
|
|
89
122
|
PRINCEEDWARDISLAND: "PE"
|
|
90
123
|
}
|
|
91
124
|
};
|
|
92
|
-
function
|
|
93
|
-
const
|
|
94
|
-
return
|
|
125
|
+
function S(n) {
|
|
126
|
+
const e = i(n);
|
|
127
|
+
return e ? t[e] ?? [] : [];
|
|
95
128
|
}
|
|
96
|
-
function
|
|
97
|
-
return
|
|
129
|
+
function R(n) {
|
|
130
|
+
return S(n).length > 0;
|
|
98
131
|
}
|
|
99
|
-
function
|
|
100
|
-
const o =
|
|
132
|
+
function I(n, e) {
|
|
133
|
+
const o = i(n), a = e?.trim();
|
|
101
134
|
if (!o || !a)
|
|
102
135
|
return a || null;
|
|
103
|
-
const d =
|
|
136
|
+
const d = t[o];
|
|
104
137
|
if (!d?.length)
|
|
105
138
|
return a.toUpperCase();
|
|
106
|
-
const c = a.toUpperCase(),
|
|
107
|
-
if (
|
|
108
|
-
return
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
return
|
|
112
|
-
const
|
|
113
|
-
return
|
|
139
|
+
const c = a.toUpperCase(), m = d.find((r) => r.code === c);
|
|
140
|
+
if (m)
|
|
141
|
+
return m.code;
|
|
142
|
+
const N = d.find((r) => r.name.toUpperCase() === c);
|
|
143
|
+
if (N)
|
|
144
|
+
return N.code;
|
|
145
|
+
const u = c.replace(/\s+/g, "");
|
|
146
|
+
return s[o]?.[c] ?? s[o]?.[u] ?? c;
|
|
114
147
|
}
|
|
115
|
-
function
|
|
116
|
-
const o =
|
|
117
|
-
return !o || !a ?
|
|
148
|
+
function E(n, e) {
|
|
149
|
+
const o = i(n), a = I(n, e);
|
|
150
|
+
return !o || !a ? e ?? null : t[o]?.find(
|
|
118
151
|
(c) => c.code === a
|
|
119
152
|
)?.name ?? a;
|
|
120
153
|
}
|
|
121
154
|
export {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
155
|
+
t as STATES_BY_COUNTRY,
|
|
156
|
+
R as countryUsesStructuredStates,
|
|
157
|
+
S as getStatesForCountry,
|
|
158
|
+
T as getSubdivisionLabel,
|
|
159
|
+
I as normalizeSubdivisionCode,
|
|
160
|
+
E as resolveSubdivisionName
|
|
127
161
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextblock-cms/ecom",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.3",
|
|
4
4
|
"license": "AGPL-3.0-or-later",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
},
|
|
12
12
|
"type": "module",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@nextblock-cms/db": "^0.19.
|
|
15
|
-
"@nextblock-cms/ui": "^0.19.
|
|
16
|
-
"@nextblock-cms/utils": "^0.19.
|
|
14
|
+
"@nextblock-cms/db": "^0.19.3",
|
|
15
|
+
"@nextblock-cms/ui": "^0.19.3",
|
|
16
|
+
"@nextblock-cms/utils": "^0.19.3",
|
|
17
17
|
"@freemius/checkout": "^1.4.1",
|
|
18
18
|
"@freemius/sdk": "^0.3.0",
|
|
19
19
|
"@hookform/resolvers": "^5.2.2",
|