@cimplify/sdk 0.79.0 → 0.81.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/dist/advanced.d.mts +1 -1
- package/dist/advanced.d.ts +1 -1
- package/dist/advanced.js +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-3BKMNVTR.mjs → chunk-7BM56JET.mjs} +1 -0
- package/dist/{chunk-FURKCWVG.mjs → chunk-7PAQR3VC.mjs} +2 -2
- package/dist/{chunk-BNA4GW4D.mjs → chunk-BRVIXGUW.mjs} +60 -0
- package/dist/{chunk-5BPBDWAA.js → chunk-GFM5JW45.js} +57 -36
- package/dist/{chunk-CV5QMDQS.js → chunk-HPN5R3K2.js} +1 -0
- package/dist/{chunk-T7ALPOK7.js → chunk-IZDJEDR4.js} +4 -4
- package/dist/{chunk-LBFTEXGD.mjs → chunk-NWUEWUX2.mjs} +22 -1
- package/dist/{chunk-OSTOGR4F.js → chunk-SRJEMEVZ.js} +60 -0
- package/dist/{client-Cn5trGYV.d.ts → client-BmDNlUMx.d.ts} +44 -2
- package/dist/{client-Byysg2IX.d.mts → client-C51FFhDz.d.mts} +2 -2
- package/dist/{client-D16qfHAB.d.mts → client-Cx3WLhMj.d.mts} +44 -2
- package/dist/{client-BAzvXSLJ.d.ts → client-Q_m-GkTl.d.ts} +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +69 -69
- package/dist/index.mjs +3 -3
- package/dist/mock/cli.mjs +60 -0
- package/dist/mock/library.js +60 -0
- package/dist/mock/library.mjs +60 -0
- package/dist/mock/msw.js +60 -0
- package/dist/mock/msw.mjs +60 -0
- package/dist/react.d.mts +51 -4
- package/dist/react.d.ts +51 -4
- package/dist/react.js +371 -65
- package/dist/react.mjs +337 -53
- package/dist/{server-Daq42vK7.d.ts → server-N4Q24CnO.d.ts} +21 -0
- package/dist/{server-CGO4zneR.d.mts → server-hP9NLtTh.d.mts} +21 -0
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +7 -7
- package/dist/server.mjs +2 -2
- package/dist/testing/msw.d.mts +1 -1
- package/dist/testing/msw.d.ts +1 -1
- package/dist/testing/msw.js +2 -2
- package/dist/testing/msw.mjs +1 -1
- package/dist/testing/suite.d.mts +4 -4
- package/dist/testing/suite.d.ts +4 -4
- package/dist/testing/suite.js +23 -23
- package/dist/testing/suite.mjs +4 -4
- package/dist/testing.d.mts +18 -18
- package/dist/testing.d.ts +18 -18
- package/dist/testing.js +79 -79
- package/dist/testing.mjs +5 -5
- package/package.json +7 -2
- package/registry/catalogue-page.json +1 -1
- package/registry/product-card.json +1 -1
- package/registry/product-grid.json +1 -1
- package/registry/product-image-gallery.json +1 -1
- package/registry/product-page.json +1 -1
- package/registry/recently-viewed.json +1 -1
- package/registry/recommendation-carousel.json +1 -1
- package/registry/search-input.json +1 -1
- package/dist/server-BXT62nBC.d.mts +0 -1186
- package/dist/server-BXT62nBC.d.ts +0 -1186
package/dist/testing.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { $ZodType } from 'zod/v4/core';
|
|
3
|
-
export { A as AddFirstProductOptions, a as AddFirstProductResult, P as ProductSummary, T as TestClientHandle, c as createTestClient, f as fixtures } from './client-
|
|
4
|
-
import './client-
|
|
3
|
+
export { A as AddFirstProductOptions, a as AddFirstProductResult, P as ProductSummary, T as TestClientHandle, c as createTestClient, f as fixtures } from './client-Q_m-GkTl.js';
|
|
4
|
+
import './client-BmDNlUMx.js';
|
|
5
5
|
import './product-BgFOFmQw.js';
|
|
6
6
|
import './payment-mVIJIJcq.js';
|
|
7
|
-
import './server-
|
|
7
|
+
import './server-N4Q24CnO.js';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -54,8 +54,8 @@ declare const CountryCodeSchema: z.ZodString;
|
|
|
54
54
|
declare const LocaleSchema: z.ZodString;
|
|
55
55
|
declare const PhoneE164Schema: z.ZodString;
|
|
56
56
|
declare const SeedNameSchema: z.ZodEnum<{
|
|
57
|
-
default: "default";
|
|
58
57
|
empty: "empty";
|
|
58
|
+
default: "default";
|
|
59
59
|
"reesa-storefront": "reesa-storefront";
|
|
60
60
|
restaurant: "restaurant";
|
|
61
61
|
retail: "retail";
|
|
@@ -71,11 +71,11 @@ declare const ProductTypeSchema: z.ZodEnum<{
|
|
|
71
71
|
composite: "composite";
|
|
72
72
|
}>;
|
|
73
73
|
declare const LineTypeSchema: z.ZodEnum<{
|
|
74
|
+
simple: "simple";
|
|
74
75
|
service: "service";
|
|
75
76
|
digital: "digital";
|
|
76
77
|
bundle: "bundle";
|
|
77
78
|
composite: "composite";
|
|
78
|
-
simple: "simple";
|
|
79
79
|
}>;
|
|
80
80
|
declare const ServiceStatusSchema: z.ZodEnum<{
|
|
81
81
|
pending: "pending";
|
|
@@ -365,8 +365,8 @@ declare const BrandSchema: z.ZodObject<{
|
|
|
365
365
|
}, z.core.$strip>;
|
|
366
366
|
mock: z.ZodObject<{
|
|
367
367
|
seed: z.ZodEnum<{
|
|
368
|
-
default: "default";
|
|
369
368
|
empty: "empty";
|
|
369
|
+
default: "default";
|
|
370
370
|
"reesa-storefront": "reesa-storefront";
|
|
371
371
|
restaurant: "restaurant";
|
|
372
372
|
retail: "retail";
|
|
@@ -531,7 +531,7 @@ declare const assertBrand: (value: unknown) => asserts value is {
|
|
|
531
531
|
summary: string;
|
|
532
532
|
};
|
|
533
533
|
mock: {
|
|
534
|
-
seed: "
|
|
534
|
+
seed: "empty" | "default" | "reesa-storefront" | "restaurant" | "retail" | "services" | "grocery" | "fashion";
|
|
535
535
|
businessId: string;
|
|
536
536
|
};
|
|
537
537
|
trustItems?: {
|
|
@@ -780,11 +780,11 @@ declare const CartItemSchema: z.ZodObject<{
|
|
|
780
780
|
quantity: z.ZodNumber;
|
|
781
781
|
line_key: z.ZodString;
|
|
782
782
|
line_type: z.ZodEnum<{
|
|
783
|
+
simple: "simple";
|
|
783
784
|
service: "service";
|
|
784
785
|
digital: "digital";
|
|
785
786
|
bundle: "bundle";
|
|
786
787
|
composite: "composite";
|
|
787
|
-
simple: "simple";
|
|
788
788
|
}>;
|
|
789
789
|
name: z.ZodString;
|
|
790
790
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -926,7 +926,7 @@ declare const assertCartItem: (value: unknown) => asserts value is {
|
|
|
926
926
|
item_id: string;
|
|
927
927
|
quantity: number;
|
|
928
928
|
line_key: string;
|
|
929
|
-
line_type: "
|
|
929
|
+
line_type: "simple" | "service" | "digital" | "bundle" | "composite";
|
|
930
930
|
name: string;
|
|
931
931
|
is_available: boolean;
|
|
932
932
|
base_price: string;
|
|
@@ -1079,11 +1079,11 @@ declare const CartSchema: z.ZodObject<{
|
|
|
1079
1079
|
quantity: z.ZodNumber;
|
|
1080
1080
|
line_key: z.ZodString;
|
|
1081
1081
|
line_type: z.ZodEnum<{
|
|
1082
|
+
simple: "simple";
|
|
1082
1083
|
service: "service";
|
|
1083
1084
|
digital: "digital";
|
|
1084
1085
|
bundle: "bundle";
|
|
1085
1086
|
composite: "composite";
|
|
1086
|
-
simple: "simple";
|
|
1087
1087
|
}>;
|
|
1088
1088
|
name: z.ZodString;
|
|
1089
1089
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -1255,7 +1255,7 @@ declare const assertCart: (value: unknown) => asserts value is {
|
|
|
1255
1255
|
item_id: string;
|
|
1256
1256
|
quantity: number;
|
|
1257
1257
|
line_key: string;
|
|
1258
|
-
line_type: "
|
|
1258
|
+
line_type: "simple" | "service" | "digital" | "bundle" | "composite";
|
|
1259
1259
|
name: string;
|
|
1260
1260
|
is_available: boolean;
|
|
1261
1261
|
base_price: string;
|
|
@@ -1471,10 +1471,10 @@ declare const assertCheckoutBody: (value: unknown) => asserts value is {
|
|
|
1471
1471
|
};
|
|
1472
1472
|
declare const AuthorizationTypeSchema: z.ZodEnum<{
|
|
1473
1473
|
phone: "phone";
|
|
1474
|
-
address: "address";
|
|
1475
1474
|
otp: "otp";
|
|
1476
1475
|
pin: "pin";
|
|
1477
1476
|
birthday: "birthday";
|
|
1477
|
+
address: "address";
|
|
1478
1478
|
}>;
|
|
1479
1479
|
declare const NextActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1480
1480
|
type: z.ZodLiteral<"none">;
|
|
@@ -1494,10 +1494,10 @@ declare const CheckoutResponseSchema: z.ZodObject<{
|
|
|
1494
1494
|
requires_authorization: z.ZodBoolean;
|
|
1495
1495
|
authorization_type: z.ZodOptional<z.ZodEnum<{
|
|
1496
1496
|
phone: "phone";
|
|
1497
|
-
address: "address";
|
|
1498
1497
|
otp: "otp";
|
|
1499
1498
|
pin: "pin";
|
|
1500
1499
|
birthday: "birthday";
|
|
1500
|
+
address: "address";
|
|
1501
1501
|
}>>;
|
|
1502
1502
|
next_action: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1503
1503
|
type: z.ZodLiteral<"none">;
|
|
@@ -1534,7 +1534,7 @@ declare const assertCheckoutResponse: (value: unknown) => asserts value is {
|
|
|
1534
1534
|
display_text?: string | undefined;
|
|
1535
1535
|
};
|
|
1536
1536
|
payment_reference?: string | undefined;
|
|
1537
|
-
authorization_type?: "phone" | "
|
|
1537
|
+
authorization_type?: "phone" | "otp" | "pin" | "birthday" | "address" | undefined;
|
|
1538
1538
|
provider?: string | undefined;
|
|
1539
1539
|
authorization_url?: string | undefined;
|
|
1540
1540
|
display_text?: string | undefined;
|
|
@@ -1733,8 +1733,8 @@ declare const PUBLIC_SCHEMAS: {
|
|
|
1733
1733
|
}, z.core.$strip>;
|
|
1734
1734
|
mock: z.ZodObject<{
|
|
1735
1735
|
seed: z.ZodEnum<{
|
|
1736
|
-
default: "default";
|
|
1737
1736
|
empty: "empty";
|
|
1737
|
+
default: "default";
|
|
1738
1738
|
"reesa-storefront": "reesa-storefront";
|
|
1739
1739
|
restaurant: "restaurant";
|
|
1740
1740
|
retail: "retail";
|
|
@@ -1794,11 +1794,11 @@ declare const PUBLIC_SCHEMAS: {
|
|
|
1794
1794
|
quantity: z.ZodNumber;
|
|
1795
1795
|
line_key: z.ZodString;
|
|
1796
1796
|
line_type: z.ZodEnum<{
|
|
1797
|
+
simple: "simple";
|
|
1797
1798
|
service: "service";
|
|
1798
1799
|
digital: "digital";
|
|
1799
1800
|
bundle: "bundle";
|
|
1800
1801
|
composite: "composite";
|
|
1801
|
-
simple: "simple";
|
|
1802
1802
|
}>;
|
|
1803
1803
|
name: z.ZodString;
|
|
1804
1804
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -1965,11 +1965,11 @@ declare const PUBLIC_SCHEMAS: {
|
|
|
1965
1965
|
quantity: z.ZodNumber;
|
|
1966
1966
|
line_key: z.ZodString;
|
|
1967
1967
|
line_type: z.ZodEnum<{
|
|
1968
|
+
simple: "simple";
|
|
1968
1969
|
service: "service";
|
|
1969
1970
|
digital: "digital";
|
|
1970
1971
|
bundle: "bundle";
|
|
1971
1972
|
composite: "composite";
|
|
1972
|
-
simple: "simple";
|
|
1973
1973
|
}>;
|
|
1974
1974
|
name: z.ZodString;
|
|
1975
1975
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -2146,10 +2146,10 @@ declare const PUBLIC_SCHEMAS: {
|
|
|
2146
2146
|
requires_authorization: z.ZodBoolean;
|
|
2147
2147
|
authorization_type: z.ZodOptional<z.ZodEnum<{
|
|
2148
2148
|
phone: "phone";
|
|
2149
|
-
address: "address";
|
|
2150
2149
|
otp: "otp";
|
|
2151
2150
|
pin: "pin";
|
|
2152
2151
|
birthday: "birthday";
|
|
2152
|
+
address: "address";
|
|
2153
2153
|
}>>;
|
|
2154
2154
|
next_action: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
2155
2155
|
type: z.ZodLiteral<"none">;
|
package/dist/testing.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-
|
|
3
|
+
var chunkIZDJEDR4_js = require('./chunk-IZDJEDR4.js');
|
|
4
|
+
require('./chunk-SRJEMEVZ.js');
|
|
5
|
+
require('./chunk-GFM5JW45.js');
|
|
6
|
+
require('./chunk-HPN5R3K2.js');
|
|
7
7
|
require('./chunk-7Y2O3E4D.js');
|
|
8
8
|
require('./chunk-XA3ZNR75.js');
|
|
9
9
|
require('./chunk-OWW5GUSB.js');
|
|
10
10
|
var zod = require('zod');
|
|
11
11
|
|
|
12
12
|
var PUBLIC_SCHEMAS = {
|
|
13
|
-
Brand:
|
|
14
|
-
AddItemPayload:
|
|
15
|
-
Cart:
|
|
16
|
-
CartItem:
|
|
17
|
-
CartPricing:
|
|
18
|
-
CheckoutBody:
|
|
19
|
-
CheckoutResponse:
|
|
20
|
-
VariantInfo:
|
|
13
|
+
Brand: chunkIZDJEDR4_js.BrandSchema,
|
|
14
|
+
AddItemPayload: chunkIZDJEDR4_js.AddItemPayloadSchema,
|
|
15
|
+
Cart: chunkIZDJEDR4_js.CartSchema,
|
|
16
|
+
CartItem: chunkIZDJEDR4_js.CartItemSchema,
|
|
17
|
+
CartPricing: chunkIZDJEDR4_js.CartPricingSchema,
|
|
18
|
+
CheckoutBody: chunkIZDJEDR4_js.CheckoutBodySchema,
|
|
19
|
+
CheckoutResponse: chunkIZDJEDR4_js.CheckoutResponseSchema,
|
|
20
|
+
VariantInfo: chunkIZDJEDR4_js.VariantInfoSchema
|
|
21
21
|
};
|
|
22
22
|
function exportJsonSchemas() {
|
|
23
23
|
const out = {};
|
|
24
24
|
for (const [name, schema] of Object.entries(PUBLIC_SCHEMAS)) {
|
|
25
|
-
const meta =
|
|
26
|
-
const json = zod.z.toJSONSchema(schema, { metadata:
|
|
25
|
+
const meta = chunkIZDJEDR4_js.cimplifyRegistry.get(schema);
|
|
26
|
+
const json = zod.z.toJSONSchema(schema, { metadata: chunkIZDJEDR4_js.cimplifyRegistry });
|
|
27
27
|
if (meta) {
|
|
28
28
|
json.$id = meta.id;
|
|
29
29
|
json["x-cimplify-version"] = meta.version;
|
|
@@ -35,16 +35,16 @@ function exportJsonSchemas() {
|
|
|
35
35
|
function listRegisteredSchemas() {
|
|
36
36
|
const entries = [];
|
|
37
37
|
for (const schema of [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
chunkIZDJEDR4_js.BrandSchema,
|
|
39
|
+
chunkIZDJEDR4_js.AddItemPayloadSchema,
|
|
40
|
+
chunkIZDJEDR4_js.CartSchema,
|
|
41
|
+
chunkIZDJEDR4_js.CartItemSchema,
|
|
42
|
+
chunkIZDJEDR4_js.CartPricingSchema,
|
|
43
|
+
chunkIZDJEDR4_js.CheckoutBodySchema,
|
|
44
|
+
chunkIZDJEDR4_js.CheckoutResponseSchema,
|
|
45
|
+
chunkIZDJEDR4_js.VariantInfoSchema
|
|
46
46
|
]) {
|
|
47
|
-
const meta =
|
|
47
|
+
const meta = chunkIZDJEDR4_js.cimplifyRegistry.get(schema);
|
|
48
48
|
if (meta) entries.push({ schema, meta });
|
|
49
49
|
}
|
|
50
50
|
return entries;
|
|
@@ -52,227 +52,227 @@ function listRegisteredSchemas() {
|
|
|
52
52
|
|
|
53
53
|
Object.defineProperty(exports, "AddItemPayloadSchema", {
|
|
54
54
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
55
|
+
get: function () { return chunkIZDJEDR4_js.AddItemPayloadSchema; }
|
|
56
56
|
});
|
|
57
57
|
Object.defineProperty(exports, "AddOnDetailsSchema", {
|
|
58
58
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
59
|
+
get: function () { return chunkIZDJEDR4_js.AddOnDetailsSchema; }
|
|
60
60
|
});
|
|
61
61
|
Object.defineProperty(exports, "AddOnGroupDetailsSchema", {
|
|
62
62
|
enumerable: true,
|
|
63
|
-
get: function () { return
|
|
63
|
+
get: function () { return chunkIZDJEDR4_js.AddOnGroupDetailsSchema; }
|
|
64
64
|
});
|
|
65
65
|
Object.defineProperty(exports, "AddOnInDetailsSchema", {
|
|
66
66
|
enumerable: true,
|
|
67
|
-
get: function () { return
|
|
67
|
+
get: function () { return chunkIZDJEDR4_js.AddOnInDetailsSchema; }
|
|
68
68
|
});
|
|
69
69
|
Object.defineProperty(exports, "AddOnOptionDetailsSchema", {
|
|
70
70
|
enumerable: true,
|
|
71
|
-
get: function () { return
|
|
71
|
+
get: function () { return chunkIZDJEDR4_js.AddOnOptionDetailsSchema; }
|
|
72
72
|
});
|
|
73
73
|
Object.defineProperty(exports, "AuthorizationTypeSchema", {
|
|
74
74
|
enumerable: true,
|
|
75
|
-
get: function () { return
|
|
75
|
+
get: function () { return chunkIZDJEDR4_js.AuthorizationTypeSchema; }
|
|
76
76
|
});
|
|
77
77
|
Object.defineProperty(exports, "BrandContactSchema", {
|
|
78
78
|
enumerable: true,
|
|
79
|
-
get: function () { return
|
|
79
|
+
get: function () { return chunkIZDJEDR4_js.BrandContactSchema; }
|
|
80
80
|
});
|
|
81
81
|
Object.defineProperty(exports, "BrandFaqSchema", {
|
|
82
82
|
enumerable: true,
|
|
83
|
-
get: function () { return
|
|
83
|
+
get: function () { return chunkIZDJEDR4_js.BrandFaqSchema; }
|
|
84
84
|
});
|
|
85
85
|
Object.defineProperty(exports, "BrandHeroSchema", {
|
|
86
86
|
enumerable: true,
|
|
87
|
-
get: function () { return
|
|
87
|
+
get: function () { return chunkIZDJEDR4_js.BrandHeroSchema; }
|
|
88
88
|
});
|
|
89
89
|
Object.defineProperty(exports, "BrandNavLinkSchema", {
|
|
90
90
|
enumerable: true,
|
|
91
|
-
get: function () { return
|
|
91
|
+
get: function () { return chunkIZDJEDR4_js.BrandNavLinkSchema; }
|
|
92
92
|
});
|
|
93
93
|
Object.defineProperty(exports, "BrandPolicyPageSchema", {
|
|
94
94
|
enumerable: true,
|
|
95
|
-
get: function () { return
|
|
95
|
+
get: function () { return chunkIZDJEDR4_js.BrandPolicyPageSchema; }
|
|
96
96
|
});
|
|
97
97
|
Object.defineProperty(exports, "BrandPolicySectionSchema", {
|
|
98
98
|
enumerable: true,
|
|
99
|
-
get: function () { return
|
|
99
|
+
get: function () { return chunkIZDJEDR4_js.BrandPolicySectionSchema; }
|
|
100
100
|
});
|
|
101
101
|
Object.defineProperty(exports, "BrandSchema", {
|
|
102
102
|
enumerable: true,
|
|
103
|
-
get: function () { return
|
|
103
|
+
get: function () { return chunkIZDJEDR4_js.BrandSchema; }
|
|
104
104
|
});
|
|
105
105
|
Object.defineProperty(exports, "BrandSocialSchema", {
|
|
106
106
|
enumerable: true,
|
|
107
|
-
get: function () { return
|
|
107
|
+
get: function () { return chunkIZDJEDR4_js.BrandSocialSchema; }
|
|
108
108
|
});
|
|
109
109
|
Object.defineProperty(exports, "BundleResolvedSchema", {
|
|
110
110
|
enumerable: true,
|
|
111
|
-
get: function () { return
|
|
111
|
+
get: function () { return chunkIZDJEDR4_js.BundleResolvedSchema; }
|
|
112
112
|
});
|
|
113
113
|
Object.defineProperty(exports, "BundleSelectionInputSchema", {
|
|
114
114
|
enumerable: true,
|
|
115
|
-
get: function () { return
|
|
115
|
+
get: function () { return chunkIZDJEDR4_js.BundleSelectionInputSchema; }
|
|
116
116
|
});
|
|
117
117
|
Object.defineProperty(exports, "CartItemSchema", {
|
|
118
118
|
enumerable: true,
|
|
119
|
-
get: function () { return
|
|
119
|
+
get: function () { return chunkIZDJEDR4_js.CartItemSchema; }
|
|
120
120
|
});
|
|
121
121
|
Object.defineProperty(exports, "CartPricingSchema", {
|
|
122
122
|
enumerable: true,
|
|
123
|
-
get: function () { return
|
|
123
|
+
get: function () { return chunkIZDJEDR4_js.CartPricingSchema; }
|
|
124
124
|
});
|
|
125
125
|
Object.defineProperty(exports, "CartSchema", {
|
|
126
126
|
enumerable: true,
|
|
127
|
-
get: function () { return
|
|
127
|
+
get: function () { return chunkIZDJEDR4_js.CartSchema; }
|
|
128
128
|
});
|
|
129
129
|
Object.defineProperty(exports, "CheckoutBodySchema", {
|
|
130
130
|
enumerable: true,
|
|
131
|
-
get: function () { return
|
|
131
|
+
get: function () { return chunkIZDJEDR4_js.CheckoutBodySchema; }
|
|
132
132
|
});
|
|
133
133
|
Object.defineProperty(exports, "CheckoutCustomerSchema", {
|
|
134
134
|
enumerable: true,
|
|
135
|
-
get: function () { return
|
|
135
|
+
get: function () { return chunkIZDJEDR4_js.CheckoutCustomerSchema; }
|
|
136
136
|
});
|
|
137
137
|
Object.defineProperty(exports, "CheckoutResponseSchema", {
|
|
138
138
|
enumerable: true,
|
|
139
|
-
get: function () { return
|
|
139
|
+
get: function () { return chunkIZDJEDR4_js.CheckoutResponseSchema; }
|
|
140
140
|
});
|
|
141
141
|
Object.defineProperty(exports, "ChosenPriceSchema", {
|
|
142
142
|
enumerable: true,
|
|
143
|
-
get: function () { return
|
|
143
|
+
get: function () { return chunkIZDJEDR4_js.ChosenPriceSchema; }
|
|
144
144
|
});
|
|
145
145
|
Object.defineProperty(exports, "CompositeResolvedSchema", {
|
|
146
146
|
enumerable: true,
|
|
147
|
-
get: function () { return
|
|
147
|
+
get: function () { return chunkIZDJEDR4_js.CompositeResolvedSchema; }
|
|
148
148
|
});
|
|
149
149
|
Object.defineProperty(exports, "CompositeSelectionInputSchema", {
|
|
150
150
|
enumerable: true,
|
|
151
|
-
get: function () { return
|
|
151
|
+
get: function () { return chunkIZDJEDR4_js.CompositeSelectionInputSchema; }
|
|
152
152
|
});
|
|
153
153
|
Object.defineProperty(exports, "CountryCodeSchema", {
|
|
154
154
|
enumerable: true,
|
|
155
|
-
get: function () { return
|
|
155
|
+
get: function () { return chunkIZDJEDR4_js.CountryCodeSchema; }
|
|
156
156
|
});
|
|
157
157
|
Object.defineProperty(exports, "CurrencyCodeSchema", {
|
|
158
158
|
enumerable: true,
|
|
159
|
-
get: function () { return
|
|
159
|
+
get: function () { return chunkIZDJEDR4_js.CurrencyCodeSchema; }
|
|
160
160
|
});
|
|
161
161
|
Object.defineProperty(exports, "CustomerInputValueSchema", {
|
|
162
162
|
enumerable: true,
|
|
163
|
-
get: function () { return
|
|
163
|
+
get: function () { return chunkIZDJEDR4_js.CustomerInputValueSchema; }
|
|
164
164
|
});
|
|
165
165
|
Object.defineProperty(exports, "DiscountDetailsSchema", {
|
|
166
166
|
enumerable: true,
|
|
167
|
-
get: function () { return
|
|
167
|
+
get: function () { return chunkIZDJEDR4_js.DiscountDetailsSchema; }
|
|
168
168
|
});
|
|
169
169
|
Object.defineProperty(exports, "IsoDateTimeSchema", {
|
|
170
170
|
enumerable: true,
|
|
171
|
-
get: function () { return
|
|
171
|
+
get: function () { return chunkIZDJEDR4_js.IsoDateTimeSchema; }
|
|
172
172
|
});
|
|
173
173
|
Object.defineProperty(exports, "LineTypeSchema", {
|
|
174
174
|
enumerable: true,
|
|
175
|
-
get: function () { return
|
|
175
|
+
get: function () { return chunkIZDJEDR4_js.LineTypeSchema; }
|
|
176
176
|
});
|
|
177
177
|
Object.defineProperty(exports, "LocaleSchema", {
|
|
178
178
|
enumerable: true,
|
|
179
|
-
get: function () { return
|
|
179
|
+
get: function () { return chunkIZDJEDR4_js.LocaleSchema; }
|
|
180
180
|
});
|
|
181
181
|
Object.defineProperty(exports, "MoneyLooseSchema", {
|
|
182
182
|
enumerable: true,
|
|
183
|
-
get: function () { return
|
|
183
|
+
get: function () { return chunkIZDJEDR4_js.MoneyLooseSchema; }
|
|
184
184
|
});
|
|
185
185
|
Object.defineProperty(exports, "MoneySchema", {
|
|
186
186
|
enumerable: true,
|
|
187
|
-
get: function () { return
|
|
187
|
+
get: function () { return chunkIZDJEDR4_js.MoneySchema; }
|
|
188
188
|
});
|
|
189
189
|
Object.defineProperty(exports, "NextActionSchema", {
|
|
190
190
|
enumerable: true,
|
|
191
|
-
get: function () { return
|
|
191
|
+
get: function () { return chunkIZDJEDR4_js.NextActionSchema; }
|
|
192
192
|
});
|
|
193
193
|
Object.defineProperty(exports, "PhoneE164Schema", {
|
|
194
194
|
enumerable: true,
|
|
195
|
-
get: function () { return
|
|
195
|
+
get: function () { return chunkIZDJEDR4_js.PhoneE164Schema; }
|
|
196
196
|
});
|
|
197
197
|
Object.defineProperty(exports, "ProductTypeSchema", {
|
|
198
198
|
enumerable: true,
|
|
199
|
-
get: function () { return
|
|
199
|
+
get: function () { return chunkIZDJEDR4_js.ProductTypeSchema; }
|
|
200
200
|
});
|
|
201
201
|
Object.defineProperty(exports, "SchemaViolationError", {
|
|
202
202
|
enumerable: true,
|
|
203
|
-
get: function () { return
|
|
203
|
+
get: function () { return chunkIZDJEDR4_js.SchemaViolationError; }
|
|
204
204
|
});
|
|
205
205
|
Object.defineProperty(exports, "SeedNameSchema", {
|
|
206
206
|
enumerable: true,
|
|
207
|
-
get: function () { return
|
|
207
|
+
get: function () { return chunkIZDJEDR4_js.SeedNameSchema; }
|
|
208
208
|
});
|
|
209
209
|
Object.defineProperty(exports, "SelectedAddOnOptionSchema", {
|
|
210
210
|
enumerable: true,
|
|
211
|
-
get: function () { return
|
|
211
|
+
get: function () { return chunkIZDJEDR4_js.SelectedAddOnOptionSchema; }
|
|
212
212
|
});
|
|
213
213
|
Object.defineProperty(exports, "ServiceStatusSchema", {
|
|
214
214
|
enumerable: true,
|
|
215
|
-
get: function () { return
|
|
215
|
+
get: function () { return chunkIZDJEDR4_js.ServiceStatusSchema; }
|
|
216
216
|
});
|
|
217
217
|
Object.defineProperty(exports, "TimestampSchema", {
|
|
218
218
|
enumerable: true,
|
|
219
|
-
get: function () { return
|
|
219
|
+
get: function () { return chunkIZDJEDR4_js.TimestampSchema; }
|
|
220
220
|
});
|
|
221
221
|
Object.defineProperty(exports, "VariantDetailsSchema", {
|
|
222
222
|
enumerable: true,
|
|
223
|
-
get: function () { return
|
|
223
|
+
get: function () { return chunkIZDJEDR4_js.VariantDetailsSchema; }
|
|
224
224
|
});
|
|
225
225
|
Object.defineProperty(exports, "VariantDisplayAttributeSchema", {
|
|
226
226
|
enumerable: true,
|
|
227
|
-
get: function () { return
|
|
227
|
+
get: function () { return chunkIZDJEDR4_js.VariantDisplayAttributeSchema; }
|
|
228
228
|
});
|
|
229
229
|
Object.defineProperty(exports, "VariantInfoSchema", {
|
|
230
230
|
enumerable: true,
|
|
231
|
-
get: function () { return
|
|
231
|
+
get: function () { return chunkIZDJEDR4_js.VariantInfoSchema; }
|
|
232
232
|
});
|
|
233
233
|
Object.defineProperty(exports, "assertAddItemPayload", {
|
|
234
234
|
enumerable: true,
|
|
235
|
-
get: function () { return
|
|
235
|
+
get: function () { return chunkIZDJEDR4_js.assertAddItemPayload; }
|
|
236
236
|
});
|
|
237
237
|
Object.defineProperty(exports, "assertBrand", {
|
|
238
238
|
enumerable: true,
|
|
239
|
-
get: function () { return
|
|
239
|
+
get: function () { return chunkIZDJEDR4_js.assertBrand; }
|
|
240
240
|
});
|
|
241
241
|
Object.defineProperty(exports, "assertCart", {
|
|
242
242
|
enumerable: true,
|
|
243
|
-
get: function () { return
|
|
243
|
+
get: function () { return chunkIZDJEDR4_js.assertCart; }
|
|
244
244
|
});
|
|
245
245
|
Object.defineProperty(exports, "assertCartItem", {
|
|
246
246
|
enumerable: true,
|
|
247
|
-
get: function () { return
|
|
247
|
+
get: function () { return chunkIZDJEDR4_js.assertCartItem; }
|
|
248
248
|
});
|
|
249
249
|
Object.defineProperty(exports, "assertCheckoutBody", {
|
|
250
250
|
enumerable: true,
|
|
251
|
-
get: function () { return
|
|
251
|
+
get: function () { return chunkIZDJEDR4_js.assertCheckoutBody; }
|
|
252
252
|
});
|
|
253
253
|
Object.defineProperty(exports, "assertCheckoutResponse", {
|
|
254
254
|
enumerable: true,
|
|
255
|
-
get: function () { return
|
|
255
|
+
get: function () { return chunkIZDJEDR4_js.assertCheckoutResponse; }
|
|
256
256
|
});
|
|
257
257
|
Object.defineProperty(exports, "cimplifyRegistry", {
|
|
258
258
|
enumerable: true,
|
|
259
|
-
get: function () { return
|
|
259
|
+
get: function () { return chunkIZDJEDR4_js.cimplifyRegistry; }
|
|
260
260
|
});
|
|
261
261
|
Object.defineProperty(exports, "createTestClient", {
|
|
262
262
|
enumerable: true,
|
|
263
|
-
get: function () { return
|
|
263
|
+
get: function () { return chunkIZDJEDR4_js.createTestClient; }
|
|
264
264
|
});
|
|
265
265
|
Object.defineProperty(exports, "fixtures", {
|
|
266
266
|
enumerable: true,
|
|
267
|
-
get: function () { return
|
|
267
|
+
get: function () { return chunkIZDJEDR4_js.fixtures; }
|
|
268
268
|
});
|
|
269
269
|
Object.defineProperty(exports, "makeAssertion", {
|
|
270
270
|
enumerable: true,
|
|
271
|
-
get: function () { return
|
|
271
|
+
get: function () { return chunkIZDJEDR4_js.makeAssertion; }
|
|
272
272
|
});
|
|
273
273
|
Object.defineProperty(exports, "registerSchema", {
|
|
274
274
|
enumerable: true,
|
|
275
|
-
get: function () { return
|
|
275
|
+
get: function () { return chunkIZDJEDR4_js.registerSchema; }
|
|
276
276
|
});
|
|
277
277
|
exports.exportJsonSchemas = exportJsonSchemas;
|
|
278
278
|
exports.listRegisteredSchemas = listRegisteredSchemas;
|
package/dist/testing.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { VariantInfoSchema, CheckoutResponseSchema, CheckoutBodySchema, CartPricingSchema, CartItemSchema, CartSchema, AddItemPayloadSchema, BrandSchema, cimplifyRegistry } from './chunk-
|
|
2
|
-
export { AddItemPayloadSchema, AddOnDetailsSchema, AddOnGroupDetailsSchema, AddOnInDetailsSchema, AddOnOptionDetailsSchema, AuthorizationTypeSchema, BrandContactSchema, BrandFaqSchema, BrandHeroSchema, BrandNavLinkSchema, BrandPolicyPageSchema, BrandPolicySectionSchema, BrandSchema, BrandSocialSchema, BundleResolvedSchema, BundleSelectionInputSchema, CartItemSchema, CartPricingSchema, CartSchema, CheckoutBodySchema, CheckoutCustomerSchema, CheckoutResponseSchema, ChosenPriceSchema, CompositeResolvedSchema, CompositeSelectionInputSchema, CountryCodeSchema, CurrencyCodeSchema, CustomerInputValueSchema, DiscountDetailsSchema, IsoDateTimeSchema, LineTypeSchema, LocaleSchema, MoneyLooseSchema, MoneySchema, NextActionSchema, PhoneE164Schema, ProductTypeSchema, SchemaViolationError, SeedNameSchema, SelectedAddOnOptionSchema, ServiceStatusSchema, TimestampSchema, VariantDetailsSchema, VariantDisplayAttributeSchema, VariantInfoSchema, assertAddItemPayload, assertBrand, assertCart, assertCartItem, assertCheckoutBody, assertCheckoutResponse, cimplifyRegistry, createTestClient, fixtures, makeAssertion, registerSchema } from './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
import './chunk-
|
|
5
|
-
import './chunk-
|
|
1
|
+
import { VariantInfoSchema, CheckoutResponseSchema, CheckoutBodySchema, CartPricingSchema, CartItemSchema, CartSchema, AddItemPayloadSchema, BrandSchema, cimplifyRegistry } from './chunk-7PAQR3VC.mjs';
|
|
2
|
+
export { AddItemPayloadSchema, AddOnDetailsSchema, AddOnGroupDetailsSchema, AddOnInDetailsSchema, AddOnOptionDetailsSchema, AuthorizationTypeSchema, BrandContactSchema, BrandFaqSchema, BrandHeroSchema, BrandNavLinkSchema, BrandPolicyPageSchema, BrandPolicySectionSchema, BrandSchema, BrandSocialSchema, BundleResolvedSchema, BundleSelectionInputSchema, CartItemSchema, CartPricingSchema, CartSchema, CheckoutBodySchema, CheckoutCustomerSchema, CheckoutResponseSchema, ChosenPriceSchema, CompositeResolvedSchema, CompositeSelectionInputSchema, CountryCodeSchema, CurrencyCodeSchema, CustomerInputValueSchema, DiscountDetailsSchema, IsoDateTimeSchema, LineTypeSchema, LocaleSchema, MoneyLooseSchema, MoneySchema, NextActionSchema, PhoneE164Schema, ProductTypeSchema, SchemaViolationError, SeedNameSchema, SelectedAddOnOptionSchema, ServiceStatusSchema, TimestampSchema, VariantDetailsSchema, VariantDisplayAttributeSchema, VariantInfoSchema, assertAddItemPayload, assertBrand, assertCart, assertCartItem, assertCheckoutBody, assertCheckoutResponse, cimplifyRegistry, createTestClient, fixtures, makeAssertion, registerSchema } from './chunk-7PAQR3VC.mjs';
|
|
3
|
+
import './chunk-BRVIXGUW.mjs';
|
|
4
|
+
import './chunk-NWUEWUX2.mjs';
|
|
5
|
+
import './chunk-7BM56JET.mjs';
|
|
6
6
|
import './chunk-TD3AY34U.mjs';
|
|
7
7
|
import './chunk-AMZXALF6.mjs';
|
|
8
8
|
import './chunk-3G6RQLXK.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cimplify/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.0",
|
|
4
4
|
"description": "Cimplify Commerce SDK for storefronts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cimplify",
|
|
@@ -113,7 +113,8 @@
|
|
|
113
113
|
"@paystack/inline-js": "^2.22.8",
|
|
114
114
|
"react": ">=17.0.0",
|
|
115
115
|
"msw": ">=2.0.0",
|
|
116
|
-
"vitest": ">=2.0.0"
|
|
116
|
+
"vitest": ">=2.0.0",
|
|
117
|
+
"react-dom": ">=17.0.0"
|
|
117
118
|
},
|
|
118
119
|
"peerDependenciesMeta": {
|
|
119
120
|
"@paystack/inline-js": {
|
|
@@ -127,6 +128,9 @@
|
|
|
127
128
|
},
|
|
128
129
|
"vitest": {
|
|
129
130
|
"optional": true
|
|
131
|
+
},
|
|
132
|
+
"react-dom": {
|
|
133
|
+
"optional": true
|
|
130
134
|
}
|
|
131
135
|
},
|
|
132
136
|
"devDependencies": {
|
|
@@ -139,6 +143,7 @@
|
|
|
139
143
|
"@testing-library/react": "^16.3.2",
|
|
140
144
|
"@types/node": "^25.6.0",
|
|
141
145
|
"@types/react": "^19.2.14",
|
|
146
|
+
"@types/react-dom": "^19",
|
|
142
147
|
"@typescript/native-preview": "^7.0.0-dev.20260503.1",
|
|
143
148
|
"hono": "^4.7.7",
|
|
144
149
|
"jsdom": "^29.1.1",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
{
|
|
14
14
|
"path": "catalogue-page.tsx",
|
|
15
|
-
"content": "\"use client\";\n\nimport React, { useState, useCallback } from \"react\";\nimport type { Product, Category, PropertyFacet } from \"@cimplify/sdk\";\nimport { useProducts, useCategories } from \"@cimplify/sdk/react\";\nimport type { CatalogueLayoutProps } from \"./catalogue-layouts/shared\";\nimport { DefaultCatalogueLayout } from \"./catalogue-layouts/default-catalogue-layout\";\nimport { CompactCatalogueLayout } from \"./catalogue-layouts/compact-catalogue-layout\";\nimport { cn } from \"@cimplify/sdk/react\";\n\nexport type { CatalogueLayoutProps };\n\nexport enum CatalogueTemplate {\n Default = \"default\",\n Compact = \"compact\",\n}\n\nexport interface CataloguePageClassNames {\n root?: string;\n}\n\nexport interface CataloguePageProps {\n /** Explicit template. */\n template?: CatalogueTemplate;\n /** Layout map for overrides. */\n layouts?: Partial<Record<CatalogueTemplate | string, React.ComponentType<CatalogueLayoutProps>>>;\n /** Page title. */\n title?: string;\n /** Pre-fetched products for SSR. */\n products?: Product[];\n /** Pre-fetched categories for SSR. */\n categories?: Category[];\n /** Pre-fetched property facets for sidebar. */\n facets?: PropertyFacet[];\n /** Available tags for filtering. */\n availableTags?: string[];\n /** Products per page. */\n pageSize?: number;\n /** Default sort. */\n defaultSort?: { by: string; order: string };\n /** Custom card renderer. */\n renderCard?: (product: Product) => React.ReactNode;\n /** Custom image renderer. */\n renderImage?: (props: { src: string; alt: string; className?: string }) => React.ReactNode;\n /** Custom link renderer. */\n renderLink?: (props: { href: string; className?: string; children: React.ReactNode }) => React.ReactElement;\n /** Quick-add handler. */\n onQuickAdd?: (product: Product) => void;\n /** Product click handler. */\n onProductClick?: (product: Product) => void;\n className?: string;\n classNames?: CataloguePageClassNames;\n}\n\nconst BUILT_IN_LAYOUTS: Record<string, React.ComponentType<CatalogueLayoutProps>> = {\n [CatalogueTemplate.Default]: DefaultCatalogueLayout,\n [CatalogueTemplate.Compact]: CompactCatalogueLayout,\n};\n\nfunction useDebounce(value: string, delay: number): string {\n const [debounced, setDebounced] = React.useState(value);\n React.useEffect(() => {\n const timer = setTimeout(() => setDebounced(value), delay);\n return () => clearTimeout(timer);\n }, [value, delay]);\n return debounced;\n}\n\nexport function CataloguePage({\n template,\n layouts,\n title,\n products: productsProp,\n categories: categoriesProp,\n facets,\n availableTags,\n pageSize,\n defaultSort,\n renderCard,\n renderImage,\n renderLink,\n onQuickAdd,\n onProductClick,\n className,\n classNames,\n}: CataloguePageProps): React.ReactElement {\n const [selectedCategory, setSelectedCategory] = useState<string | null>(null);\n const [searchQuery, setSearchQuery] = useState(\"\");\n const [sortBy, setSortBy] = useState(defaultSort?.by ?? \"created_at\");\n const [sortOrder, setSortOrder] = useState(defaultSort?.order ?? \"desc\");\n const [inStockOnly, setInStockOnly] = useState(false);\n const [selectedTags, setSelectedTags] = useState<string[]>([]);\n const [minPrice, setMinPrice] = useState(\"\");\n const [maxPrice, setMaxPrice] = useState(\"\");\n const [page, setPage] = useState(1);\n\n const debouncedSearch = useDebounce(searchQuery, 300);\n\n const
|
|
15
|
+
"content": "\"use client\";\n\nimport React, { useState, useCallback, useMemo } from \"react\";\nimport type { Product, Category, PropertyFacet } from \"@cimplify/sdk\";\nimport { useProducts, useCategories, type UseProductsOptions } from \"@cimplify/sdk/react\";\nimport { prefetchProducts } from \"./hooks/use-products\";\nimport { speculate } from \"./utils/prefetch-policy\";\nimport { useOptionalCimplifyClient } from \"@cimplify/sdk/react\";\nimport type { CatalogueLayoutProps } from \"./catalogue-layouts/shared\";\nimport { DefaultCatalogueLayout } from \"./catalogue-layouts/default-catalogue-layout\";\nimport { CompactCatalogueLayout } from \"./catalogue-layouts/compact-catalogue-layout\";\nimport { cn } from \"@cimplify/sdk/react\";\n\nexport type { CatalogueLayoutProps };\n\nexport enum CatalogueTemplate {\n Default = \"default\",\n Compact = \"compact\",\n}\n\nexport interface CataloguePageClassNames {\n root?: string;\n}\n\nexport interface CataloguePageProps {\n /** Explicit template. */\n template?: CatalogueTemplate;\n /** Layout map for overrides. */\n layouts?: Partial<Record<CatalogueTemplate | string, React.ComponentType<CatalogueLayoutProps>>>;\n /** Page title. */\n title?: string;\n /** Pre-fetched products for SSR. */\n products?: Product[];\n /** Pre-fetched categories for SSR. */\n categories?: Category[];\n /** Pre-fetched property facets for sidebar. */\n facets?: PropertyFacet[];\n /** Available tags for filtering. */\n availableTags?: string[];\n /** Products per page. */\n pageSize?: number;\n /** Default sort. */\n defaultSort?: { by: string; order: string };\n /** Custom card renderer. */\n renderCard?: (product: Product) => React.ReactNode;\n /** Custom image renderer. */\n renderImage?: (props: { src: string; alt: string; className?: string }) => React.ReactNode;\n /** Custom link renderer. */\n renderLink?: (props: { href: string; className?: string; children: React.ReactNode }) => React.ReactElement;\n /** Quick-add handler. */\n onQuickAdd?: (product: Product) => void;\n /** Product click handler. */\n onProductClick?: (product: Product) => void;\n className?: string;\n classNames?: CataloguePageClassNames;\n}\n\nconst BUILT_IN_LAYOUTS: Record<string, React.ComponentType<CatalogueLayoutProps>> = {\n [CatalogueTemplate.Default]: DefaultCatalogueLayout,\n [CatalogueTemplate.Compact]: CompactCatalogueLayout,\n};\n\nfunction useDebounce(value: string, delay: number): string {\n const [debounced, setDebounced] = React.useState(value);\n React.useEffect(() => {\n const timer = setTimeout(() => setDebounced(value), delay);\n return () => clearTimeout(timer);\n }, [value, delay]);\n return debounced;\n}\n\nexport function CataloguePage({\n template,\n layouts,\n title,\n products: productsProp,\n categories: categoriesProp,\n facets,\n availableTags,\n pageSize,\n defaultSort,\n renderCard,\n renderImage,\n renderLink,\n onQuickAdd,\n onProductClick,\n className,\n classNames,\n}: CataloguePageProps): React.ReactElement {\n const [selectedCategory, setSelectedCategory] = useState<string | null>(null);\n const [searchQuery, setSearchQuery] = useState(\"\");\n const [sortBy, setSortBy] = useState(defaultSort?.by ?? \"created_at\");\n const [sortOrder, setSortOrder] = useState(defaultSort?.order ?? \"desc\");\n const [inStockOnly, setInStockOnly] = useState(false);\n const [selectedTags, setSelectedTags] = useState<string[]>([]);\n const [minPrice, setMinPrice] = useState(\"\");\n const [maxPrice, setMaxPrice] = useState(\"\");\n const [page, setPage] = useState(1);\n\n const debouncedSearch = useDebounce(searchQuery, 300);\n\n const filterOptions = useMemo<UseProductsOptions>(\n () => ({\n category: selectedCategory ?? undefined,\n search: debouncedSearch.length >= 2 ? debouncedSearch : undefined,\n sort_by: sortBy as \"name\" | \"price\" | \"created_at\" | \"updated_at\",\n sort_order: sortOrder as \"asc\" | \"desc\",\n in_stock: inStockOnly || undefined,\n tags: selectedTags.length > 0 ? selectedTags : undefined,\n min_price: minPrice ? parseFloat(minPrice) : undefined,\n max_price: maxPrice ? parseFloat(maxPrice) : undefined,\n limit: pageSize,\n }),\n [selectedCategory, debouncedSearch, sortBy, sortOrder, inStockOnly, selectedTags, minPrice, maxPrice, pageSize],\n );\n\n const { products: fetchedProducts, isLoading, pagination } = useProducts({\n ...filterOptions,\n enabled: productsProp === undefined,\n page,\n });\n\n const { categories: fetchedCategories } = useCategories({\n enabled: categoriesProp === undefined,\n });\n\n const products = productsProp ?? fetchedProducts;\n const categories = categoriesProp ?? fetchedCategories;\n const totalPages = pagination?.total_pages ?? 1;\n\n const context = useOptionalCimplifyClient();\n if (\n context &&\n context.prefetch.mode !== \"off\" &&\n productsProp === undefined &&\n !isLoading &&\n page < totalPages\n ) {\n speculate(() => prefetchProducts(context.client, { ...filterOptions, page: page + 1 }));\n }\n\n const handleCategoryChange = useCallback((id: string | null) => {\n setSelectedCategory(id);\n setPage(1);\n }, []);\n\n const handleSortChange = useCallback((by: string, order: string) => {\n setSortBy(by);\n setSortOrder(order);\n setPage(1);\n }, []);\n\n const handleTagToggle = useCallback((tag: string) => {\n setSelectedTags((prev) =>\n prev.includes(tag) ? prev.filter((t) => t !== tag) : [...prev, tag],\n );\n setPage(1);\n }, []);\n\n const handlePriceRangeChange = useCallback((min: string, max: string) => {\n setMinPrice(min);\n setMaxPrice(max);\n setPage(1);\n }, []);\n\n const key = template ?? CatalogueTemplate.Default;\n const Layout = layouts?.[key] ?? BUILT_IN_LAYOUTS[key] ?? DefaultCatalogueLayout;\n\n return (\n <div data-cimplify-catalogue-page className={cn(className, classNames?.root)}>\n <Layout\n products={products}\n categories={categories}\n facets={facets}\n isLoading={isLoading}\n selectedCategory={selectedCategory}\n onCategoryChange={handleCategoryChange}\n searchQuery={searchQuery}\n onSearchChange={setSearchQuery}\n sortBy={sortBy}\n sortOrder={sortOrder}\n onSortChange={handleSortChange}\n inStockOnly={inStockOnly}\n onInStockChange={setInStockOnly}\n selectedTags={selectedTags}\n availableTags={availableTags}\n onTagToggle={handleTagToggle}\n minPrice={minPrice}\n maxPrice={maxPrice}\n onPriceRangeChange={handlePriceRangeChange}\n page={page}\n totalPages={totalPages}\n onPageChange={setPage}\n renderCard={renderCard}\n renderImage={renderImage}\n renderLink={renderLink}\n onQuickAdd={onQuickAdd}\n onProductClick={onProductClick}\n title={title}\n />\n </div>\n );\n}\n"
|
|
16
16
|
}
|
|
17
17
|
]
|
|
18
18
|
}
|