@takeshape/purchase-order-chat 1.51.0 → 1.52.1
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/README.md +90 -174
- package/dist/index.d.ts +77 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/purchase-order-chat-wrapper-CWQKcJDM.js +7160 -0
- package/dist/purchase-order-chat-wrapper-CWQKcJDM.js.map +1 -0
- package/dist/shadow.d.ts +4 -1457
- package/dist/shadow.js +18 -46
- package/dist/shadow.js.map +1 -1
- package/dist/tailwind.d.ts +15 -0
- package/dist/tailwind.js +617 -11
- package/dist/tailwind.js.map +1 -1
- package/package.json +27 -48
- package/dist/pdf-CYwqEJpJ.js +0 -20562
- package/dist/pdf-CYwqEJpJ.js.map +0 -1
- package/dist/pdf.worker-eoyvlo7V.js +0 -37634
- package/dist/pdf.worker-eoyvlo7V.js.map +0 -1
- package/dist/purchase-order-chat-wrapper-wN_xvG7z.js +0 -7901
- package/dist/purchase-order-chat-wrapper-wN_xvG7z.js.map +0 -1
- package/dist/testing.d.ts +0 -456
- package/dist/testing.js +0 -610
- package/dist/testing.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,72 +1,77 @@
|
|
|
1
1
|
# @takeshape/purchase-order-chat
|
|
2
2
|
|
|
3
|
-
A React component library for purchase order chat integration with BigCommerce storefronts.
|
|
3
|
+
A React component library for purchase order chat integration with BigCommerce Catalyst storefronts.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Catalyst Quick Start
|
|
6
|
+
|
|
7
|
+
### Install
|
|
8
|
+
|
|
9
|
+
From your Catalyst project's `core` directory:
|
|
6
10
|
|
|
7
11
|
```bash
|
|
8
|
-
npm install @takeshape/purchase-order-chat
|
|
9
|
-
# or
|
|
10
12
|
pnpm add @takeshape/purchase-order-chat
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Create a page
|
|
16
|
+
|
|
17
|
+
Create a new `page.tsx` somewhere, e.g. `app/[locale]/(default)/purchase-order-agent/page.tsx`
|
|
18
|
+
|
|
19
|
+
Copy and paste the following, and fill in the the required values:
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { PurchaseOrderAgent } from "@takeshape/purchase-order-chat";
|
|
23
|
+
|
|
24
|
+
export default async function Page() {
|
|
25
|
+
return (
|
|
26
|
+
<div className="min-h-[800px] container mx-auto px-4 py-8 items-center justify-center flex">
|
|
27
|
+
<PurchaseOrderAgent
|
|
28
|
+
takeshape={{
|
|
29
|
+
projectId: "your-project-id",
|
|
30
|
+
apiKey: "your-api-key",
|
|
31
|
+
}}
|
|
32
|
+
bigcommerce={{
|
|
33
|
+
endpoint: "https://store-{hash}.mybigcommerce.com/graphql",
|
|
34
|
+
storefrontToken: "your-storefront-token",
|
|
35
|
+
channelId: 1,
|
|
36
|
+
}}
|
|
37
|
+
productPath="/product/:sku"
|
|
38
|
+
checkoutUrl="https://mysite.com/after-checkout"
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
13
43
|
```
|
|
14
44
|
|
|
15
45
|
## Requirements
|
|
16
46
|
|
|
17
47
|
- React 19+
|
|
48
|
+
- Node 24+
|
|
18
49
|
|
|
19
50
|
## Choosing an Import
|
|
20
51
|
|
|
21
|
-
This library provides
|
|
52
|
+
This library provides two entry points:
|
|
22
53
|
|
|
23
|
-
| Import
|
|
24
|
-
|
|
25
|
-
| `@takeshape/purchase-order-chat`
|
|
26
|
-
| `@takeshape/purchase-order-chat/tailwind` | Tailwind v4 projects
|
|
27
|
-
| `@takeshape/purchase-order-chat/testing` | Unit tests and Storybook | Mock BigCommerce client |
|
|
54
|
+
| Import | Use Case | CSS Handling |
|
|
55
|
+
| ----------------------------------------- | -------------------------- | ----------------------------------- |
|
|
56
|
+
| `@takeshape/purchase-order-chat` | Default - works everywhere | Shadow DOM with bundled CSS |
|
|
57
|
+
| `@takeshape/purchase-order-chat/tailwind` | Tailwind v4 projects | Integrates with your Tailwind setup |
|
|
28
58
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
```
|
|
59
|
+
### Default (recommended for most projects)
|
|
60
|
+
|
|
61
|
+
The default version wraps the component in a Shadow DOM with all styles bundled, ensuring no CSS conflicts with your existing styles.
|
|
33
62
|
|
|
34
|
-
**For Tailwind v4 projects** (like Catalyst with Tailwind v4):
|
|
35
63
|
```tsx
|
|
36
|
-
import {
|
|
64
|
+
import { PurchaseOrderChat } from "@takeshape/purchase-order-chat";
|
|
37
65
|
```
|
|
38
66
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
## Basic Usage
|
|
67
|
+
### Advanced, for Tailwind v4 projects
|
|
42
68
|
|
|
43
|
-
|
|
69
|
+
This gives you more control, and allows for more efficient style generation.
|
|
44
70
|
|
|
45
71
|
```tsx
|
|
46
|
-
import {
|
|
47
|
-
|
|
48
|
-
function App() {
|
|
49
|
-
return (
|
|
50
|
-
<PurchaseOrderChatWidget
|
|
51
|
-
takeshape={{
|
|
52
|
-
projectId: 'your-project-id',
|
|
53
|
-
apiKey: 'your-api-key'
|
|
54
|
-
}}
|
|
55
|
-
bigcommerce={{
|
|
56
|
-
endpoint: 'https://store-{hash}.mybigcommerce.com/graphql',
|
|
57
|
-
storefrontToken: 'your-storefront-token',
|
|
58
|
-
channelId: 1
|
|
59
|
-
}}
|
|
60
|
-
onViewProduct={(product) => {
|
|
61
|
-
window.location.href = product.path || `/product/${product.sku}`;
|
|
62
|
-
}}
|
|
63
|
-
/>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
72
|
+
import { PurchaseOrderChat } from "@takeshape/purchase-order-chat/tailwind";
|
|
66
73
|
```
|
|
67
74
|
|
|
68
|
-
## Catalyst (Next.js) Integration
|
|
69
|
-
|
|
70
75
|
For BigCommerce Catalyst storefronts, the recommended approach uses a proxy API route to avoid CORS issues and keep your storefront token server-side.
|
|
71
76
|
|
|
72
77
|
### 1. Install the package
|
|
@@ -82,7 +87,10 @@ Add the library's source files to your Tailwind config:
|
|
|
82
87
|
```css
|
|
83
88
|
/* In your global CSS file */
|
|
84
89
|
@import "tailwindcss";
|
|
85
|
-
|
|
90
|
+
/* Add these imports */
|
|
91
|
+
@import "@takeshape/purchase-order-chat/theme.css";
|
|
92
|
+
@import "@takeshape/purchase-order-chat/utilities.css";
|
|
93
|
+
@import "@takeshape/purchase-order-chat/sources.css";
|
|
86
94
|
```
|
|
87
95
|
|
|
88
96
|
### 3. Create a BigCommerce proxy route
|
|
@@ -90,7 +98,7 @@ Add the library's source files to your Tailwind config:
|
|
|
90
98
|
Create `app/api/bigcommerce/graphql/route.ts`:
|
|
91
99
|
|
|
92
100
|
```typescript
|
|
93
|
-
import { NextRequest, NextResponse } from
|
|
101
|
+
import { NextRequest, NextResponse } from "next/server";
|
|
94
102
|
|
|
95
103
|
const BIGCOMMERCE_STORE_HASH = process.env.BIGCOMMERCE_STORE_HASH;
|
|
96
104
|
const BIGCOMMERCE_STOREFRONT_TOKEN = process.env.BIGCOMMERCE_STOREFRONT_TOKEN;
|
|
@@ -98,8 +106,8 @@ const BIGCOMMERCE_STOREFRONT_TOKEN = process.env.BIGCOMMERCE_STOREFRONT_TOKEN;
|
|
|
98
106
|
export async function POST(request: NextRequest) {
|
|
99
107
|
if (!BIGCOMMERCE_STORE_HASH || !BIGCOMMERCE_STOREFRONT_TOKEN) {
|
|
100
108
|
return NextResponse.json(
|
|
101
|
-
{ errors: [{ message:
|
|
102
|
-
{ status: 500 }
|
|
109
|
+
{ errors: [{ message: "BigCommerce configuration missing" }] },
|
|
110
|
+
{ status: 500 },
|
|
103
111
|
);
|
|
104
112
|
}
|
|
105
113
|
|
|
@@ -107,13 +115,13 @@ export async function POST(request: NextRequest) {
|
|
|
107
115
|
const response = await fetch(
|
|
108
116
|
`https://store-${BIGCOMMERCE_STORE_HASH}.mybigcommerce.com/graphql`,
|
|
109
117
|
{
|
|
110
|
-
method:
|
|
118
|
+
method: "POST",
|
|
111
119
|
headers: {
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
"Content-Type": "application/json",
|
|
121
|
+
Authorization: `Bearer ${BIGCOMMERCE_STOREFRONT_TOKEN}`,
|
|
114
122
|
},
|
|
115
123
|
body: JSON.stringify(body),
|
|
116
|
-
}
|
|
124
|
+
},
|
|
117
125
|
);
|
|
118
126
|
|
|
119
127
|
const data = await response.json();
|
|
@@ -126,24 +134,24 @@ export async function POST(request: NextRequest) {
|
|
|
126
134
|
Create `app/[locale]/(default)/purchase-order-agent/page.tsx`:
|
|
127
135
|
|
|
128
136
|
```tsx
|
|
129
|
-
|
|
137
|
+
"use client";
|
|
130
138
|
|
|
131
|
-
import { useRouter } from
|
|
132
|
-
import { PurchaseOrderChatWidget } from
|
|
139
|
+
import { useRouter } from "~/i18n/routing";
|
|
140
|
+
import { PurchaseOrderChatWidget } from "@takeshape/purchase-order-chat/tailwind";
|
|
133
141
|
|
|
134
142
|
export default function PurchaseOrderAgentPage() {
|
|
135
143
|
const router = useRouter();
|
|
136
144
|
|
|
137
145
|
return (
|
|
138
|
-
<div className="container mx-auto px-4 py-8">
|
|
146
|
+
<div className="min-h-[800px] container mx-auto px-4 py-8 items-center justify-center flex">
|
|
139
147
|
<PurchaseOrderChatWidget
|
|
140
148
|
takeshape={{
|
|
141
149
|
projectId: process.env.NEXT_PUBLIC_TAKESHAPE_PROJECT_ID!,
|
|
142
|
-
apiKey: process.env.NEXT_PUBLIC_TAKESHAPE_API_KEY
|
|
150
|
+
apiKey: process.env.NEXT_PUBLIC_TAKESHAPE_API_KEY!,
|
|
143
151
|
}}
|
|
144
152
|
bigcommerce={{
|
|
145
|
-
endpoint:
|
|
146
|
-
channelId: Number(process.env.NEXT_PUBLIC_BIGCOMMERCE_CHANNEL_ID)
|
|
153
|
+
endpoint: "/api/bigcommerce/graphql",
|
|
154
|
+
channelId: Number(process.env.NEXT_PUBLIC_BIGCOMMERCE_CHANNEL_ID),
|
|
147
155
|
}}
|
|
148
156
|
onViewProduct={(product) => product.path && router.push(product.path)}
|
|
149
157
|
onCheckout={(checkoutUrl) => router.push(checkoutUrl)}
|
|
@@ -170,29 +178,7 @@ The widget is now available at `/purchase-order-agent`.
|
|
|
170
178
|
|
|
171
179
|
For BigCommerce B2B Edition stores, you can enable B2B features (company addresses, B2B checkout) by providing a `getB2BJwt` callback.
|
|
172
180
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
For Stencil storefronts, use the built-in `stencilB2BJwt` function:
|
|
176
|
-
|
|
177
|
-
```tsx
|
|
178
|
-
import { PurchaseOrderChatWidget, stencilB2BJwt } from '@takeshape/purchase-order-chat';
|
|
179
|
-
|
|
180
|
-
<PurchaseOrderChatWidget
|
|
181
|
-
takeshape={{
|
|
182
|
-
projectId: 'your-project-id',
|
|
183
|
-
apiKey: 'your-api-key'
|
|
184
|
-
}}
|
|
185
|
-
bigcommerce={{
|
|
186
|
-
endpoint: '/graphql',
|
|
187
|
-
channelId: 1,
|
|
188
|
-
getB2BJwt: stencilB2BJwt
|
|
189
|
-
}}
|
|
190
|
-
/>
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Custom Implementation
|
|
194
|
-
|
|
195
|
-
For other platforms (like Catalyst/Next.js), implement your own token fetcher:
|
|
181
|
+
To do this, you'll need implement your own token fetcher:
|
|
196
182
|
|
|
197
183
|
```tsx
|
|
198
184
|
const getB2BJwt = async (channelId: number) => {
|
|
@@ -207,101 +193,31 @@ const getB2BJwt = async (channelId: number) => {
|
|
|
207
193
|
|
|
208
194
|
### PurchaseOrderChatWidgetProps
|
|
209
195
|
|
|
210
|
-
| Prop
|
|
211
|
-
|
|
212
|
-
| `takeshape`
|
|
213
|
-
| `bigcommerce`
|
|
214
|
-
| `agentName`
|
|
215
|
-
| `inputName`
|
|
216
|
-
| `onViewProduct` | `(product) => void`
|
|
217
|
-
| `onCheckout`
|
|
218
|
-
| `className`
|
|
219
|
-
| `expandOnReady` | `boolean`
|
|
196
|
+
| Prop | Type | Required | Description |
|
|
197
|
+
| --------------- | ---------------------------------------- | -------- | ------------------------------------------------------------------------------ |
|
|
198
|
+
| `takeshape` | `TakeShapeConfigProps` | Yes | TakeShape API configuration |
|
|
199
|
+
| `bigcommerce` | `BigCommerceConfigProps` | Yes | BigCommerce storefront configuration |
|
|
200
|
+
| `agentName` | `string` | No | TakeShape agent name. Defaults to `'bigcommercePurchaseOrderAgent'` |
|
|
201
|
+
| `inputName` | `string` | No | TakeShape input name. Defaults to `'bigcommercePurchaseOrderAgent'` |
|
|
202
|
+
| `onViewProduct` | `(product) => void` | No | Called when user clicks to view a product |
|
|
203
|
+
| `onCheckout` | `(checkoutUrl) => void \| Promise<void>` | No | Called when checkout is initiated. Defaults to `window.location.href` redirect |
|
|
204
|
+
| `className` | `string` | No | CSS class for the container |
|
|
205
|
+
| `expandOnReady` | `boolean` | No | Auto-expand to fullscreen modal when ready |
|
|
220
206
|
|
|
221
207
|
### TakeShapeConfigProps
|
|
222
208
|
|
|
223
|
-
| Prop
|
|
224
|
-
|
|
225
|
-
| `projectId` | `string` | Yes
|
|
226
|
-
| `apiKey`
|
|
227
|
-
| `origin`
|
|
228
|
-
| `sseOrigin` | `string` | No
|
|
209
|
+
| Prop | Type | Required | Description |
|
|
210
|
+
| ----------- | -------- | -------- | ------------------------------------------------------------------ |
|
|
211
|
+
| `projectId` | `string` | Yes | TakeShape project ID |
|
|
212
|
+
| `apiKey` | `string` | Yes | TakeShape API key |
|
|
213
|
+
| `origin` | `string` | No | TakeShape API origin URL. Defaults to `'https://api.takeshape.io'` |
|
|
214
|
+
| `sseOrigin` | `string` | No | TakeShape SSE origin URL. Defaults to `'https://api.takeshape.io'` |
|
|
229
215
|
|
|
230
216
|
### BigCommerceConfigProps
|
|
231
217
|
|
|
232
|
-
| Prop
|
|
233
|
-
|
|
234
|
-
| `endpoint`
|
|
235
|
-
| `storefrontToken` | `string`
|
|
236
|
-
| `channelId`
|
|
237
|
-
| `getB2BJwt`
|
|
238
|
-
|
|
239
|
-
## Advanced Usage (Base Component)
|
|
240
|
-
|
|
241
|
-
For advanced use cases requiring custom provider setup or client management, use `PurchaseOrderChat` with `TakeShapeConfigProvider`:
|
|
242
|
-
|
|
243
|
-
```tsx
|
|
244
|
-
import {
|
|
245
|
-
PurchaseOrderChat,
|
|
246
|
-
TakeShapeConfigProvider,
|
|
247
|
-
createBigCommerceClient
|
|
248
|
-
} from '@takeshape/purchase-order-chat/tailwind';
|
|
249
|
-
|
|
250
|
-
const bigCommerceClient = createBigCommerceClient({
|
|
251
|
-
endpoint: 'https://store-{hash}.mybigcommerce.com/graphql',
|
|
252
|
-
storefrontToken: 'your-storefront-token',
|
|
253
|
-
channelId: 1
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
function App() {
|
|
257
|
-
return (
|
|
258
|
-
<TakeShapeConfigProvider
|
|
259
|
-
projectId="your-project-id"
|
|
260
|
-
apiKey="your-api-key"
|
|
261
|
-
>
|
|
262
|
-
<PurchaseOrderChat
|
|
263
|
-
bigcommerce={{
|
|
264
|
-
client: bigCommerceClient,
|
|
265
|
-
onViewProduct: (product) => {
|
|
266
|
-
window.location.href = product.path || `/product/${product.sku}`;
|
|
267
|
-
},
|
|
268
|
-
onCheckout: (checkoutUrl) => {
|
|
269
|
-
window.location.href = checkoutUrl;
|
|
270
|
-
}
|
|
271
|
-
}}
|
|
272
|
-
/>
|
|
273
|
-
</TakeShapeConfigProvider>
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
For testing, import `createMockBigCommerceClient` from the `/testing` entry point:
|
|
279
|
-
|
|
280
|
-
```tsx
|
|
281
|
-
import { createMockBigCommerceClient } from '@takeshape/purchase-order-chat/testing';
|
|
282
|
-
|
|
283
|
-
const mockClient = createMockBigCommerceClient();
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
## Styling
|
|
287
|
-
|
|
288
|
-
### For Tailwind v4 Projects
|
|
289
|
-
|
|
290
|
-
Configure Tailwind to scan the package source files:
|
|
291
|
-
|
|
292
|
-
```css
|
|
293
|
-
@import "tailwindcss";
|
|
294
|
-
@source "../node_modules/@takeshape/purchase-order-chat/src";
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
### For Tailwind v3 or Non-Tailwind Projects
|
|
298
|
-
|
|
299
|
-
Use the default import - styles are bundled in a Shadow DOM:
|
|
300
|
-
|
|
301
|
-
```tsx
|
|
302
|
-
import { PurchaseOrderChatWidget } from '@takeshape/purchase-order-chat';
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
## License
|
|
306
|
-
|
|
307
|
-
MIT
|
|
218
|
+
| Prop | Type | Required | Description |
|
|
219
|
+
| ----------------- | ------------------------------------------------ | -------- | ------------------------------------------------------------------ |
|
|
220
|
+
| `endpoint` | `string` | Yes | GraphQL endpoint URL (absolute or relative for proxy) |
|
|
221
|
+
| `storefrontToken` | `string` | No | Storefront API token. Optional when using a proxy |
|
|
222
|
+
| `channelId` | `number` | Yes | BigCommerce channel ID |
|
|
223
|
+
| `getB2BJwt` | `(channelId: number) => Promise<string \| null>` | No | B2B JWT fetcher. Receives channelId, returns B2B storefront token. |
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { JSX } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
export declare interface BigCommerceConfigProps {
|
|
4
|
+
/** GraphQL endpoint URL (absolute or relative for proxy) */
|
|
5
|
+
endpoint: string;
|
|
6
|
+
/** Storefront API token. Optional when using a proxy that handles authentication server-side. */
|
|
7
|
+
storefrontToken?: string;
|
|
8
|
+
/** BigCommerce channel ID */
|
|
9
|
+
channelId: number;
|
|
10
|
+
/** B2B JWT fetcher. Receives channelId and returns a B2B storefront token. For Stencil, use `stencilB2BJwt`. */
|
|
11
|
+
getB2BJwt?: (channelId: number) => Promise<string | null>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare interface CartItem extends Product {
|
|
15
|
+
quantity: number;
|
|
16
|
+
status: 'matched' | 'price-mismatch' | 'unavailable' | 'pending';
|
|
17
|
+
poPriceValue?: number;
|
|
18
|
+
poPriceCurrencyCode?: string;
|
|
19
|
+
catalogPriceCurrencyCode?: string;
|
|
20
|
+
bcLineItemEntityId?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export declare interface Product {
|
|
24
|
+
id: string;
|
|
25
|
+
sku: string;
|
|
26
|
+
name: string;
|
|
27
|
+
path?: string;
|
|
28
|
+
price?: number;
|
|
29
|
+
imageUrl?: string;
|
|
30
|
+
availableQuantity?: number;
|
|
31
|
+
isInStock?: boolean;
|
|
32
|
+
productEntityId?: number;
|
|
33
|
+
variantEntityId?: number;
|
|
34
|
+
defaultImage?: {
|
|
35
|
+
urlTemplate?: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export declare function PurchaseOrderAgent(props: PurchaseOrderAgentProps): JSX.Element;
|
|
40
|
+
|
|
41
|
+
export declare type PurchaseOrderAgentProps = Omit<PurchaseOrderChatWidgetProps, 'onViewProduct' | 'onCheckout'> & {
|
|
42
|
+
productPath?: string | false;
|
|
43
|
+
checkoutUrl?: string | false;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export declare interface PurchaseOrderChatWidgetProps {
|
|
47
|
+
/** TakeShape API configuration */
|
|
48
|
+
takeshape: TakeShapeConfigProps;
|
|
49
|
+
/** BigCommerce storefront configuration */
|
|
50
|
+
bigcommerce: BigCommerceConfigProps;
|
|
51
|
+
/** TakeShape agent name. Defaults to 'bigcommercePurchaseOrderAgent'. */
|
|
52
|
+
agentName?: string;
|
|
53
|
+
/** TakeShape input name. Defaults to 'bigcommercePurchaseOrderAgent'. */
|
|
54
|
+
inputName?: string;
|
|
55
|
+
/** Called when user clicks to view a product */
|
|
56
|
+
onViewProduct?: (product: {
|
|
57
|
+
productEntityId?: number;
|
|
58
|
+
sku: string;
|
|
59
|
+
name: string;
|
|
60
|
+
path?: string;
|
|
61
|
+
}) => void;
|
|
62
|
+
/** Called when checkout is initiated. If not provided, defaults to window.location.href redirect. */
|
|
63
|
+
onCheckout?: (checkoutUrl: string) => void | Promise<void>;
|
|
64
|
+
/** CSS class for the container */
|
|
65
|
+
className?: string;
|
|
66
|
+
/** When true, launches ChatView in a fullscreen modal on transition to ready state */
|
|
67
|
+
expandOnReady?: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export declare interface TakeShapeConfigProps {
|
|
71
|
+
projectId: string;
|
|
72
|
+
apiKey: string;
|
|
73
|
+
origin?: string;
|
|
74
|
+
sseOrigin?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { r as o } from "./purchase-order-chat-wrapper-CWQKcJDM.js";
|
|
4
|
+
import { PurchaseOrderChat as c } from "./shadow.js";
|
|
5
|
+
function n(r) {
|
|
6
|
+
return /* @__PURE__ */ e(
|
|
7
|
+
c,
|
|
8
|
+
{
|
|
9
|
+
...r,
|
|
10
|
+
onViewProduct: (t) => {
|
|
11
|
+
r.productPath !== !1 && (window.location.href = r.productPath ? o(r.productPath, t) : t.path || `/product/${t.sku}`);
|
|
12
|
+
},
|
|
13
|
+
onCheckout: (t) => {
|
|
14
|
+
r.checkoutUrl !== !1 && (window.location.href = r.checkoutUrl || t);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
n as PurchaseOrderAgent
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["'use client';\n\n// Default entry point - Exports Shadow DOM wrapper with bundled CSS (works everywhere)\n// For Tailwind v4 projects, use @takeshape/purchase-order-chat/tailwind\n\nimport { resolveProductPath } from './lib/utils.js';\nimport { PurchaseOrderChat as ShadowPurchaseOrderChat } from './shadow.js';\nimport type { PurchaseOrderChatWidgetProps } from './types.js';\n\nexport type {\n BigCommerceConfigProps,\n CartItem,\n Product,\n PurchaseOrderChatWidgetProps,\n TakeShapeConfigProps\n} from './types.js';\n\nexport type PurchaseOrderAgentProps = Omit<\n PurchaseOrderChatWidgetProps,\n 'onViewProduct' | 'onCheckout'\n> & {\n productPath?: string | false;\n checkoutUrl?: string | false;\n};\n\nexport function PurchaseOrderAgent(props: PurchaseOrderAgentProps) {\n return (\n <ShadowPurchaseOrderChat\n {...props}\n onViewProduct={(product) => {\n if (props.productPath === false) return;\n\n window.location.href = props.productPath\n ? resolveProductPath(props.productPath, product)\n : product.path || `/product/${product.sku}`;\n }}\n onCheckout={(checkoutUrl) => {\n if (props.checkoutUrl === false) return;\n\n window.location.href = props.checkoutUrl || checkoutUrl;\n }}\n />\n );\n}\n"],"names":["PurchaseOrderAgent","props","jsx","ShadowPurchaseOrderChat","product","resolveProductPath","checkoutUrl"],"mappings":";;;AAyBO,SAASA,EAAmBC,GAAgC;AACjE,SACE,gBAAAC;AAAA,IAACC;AAAAA,IAAA;AAAA,MACE,GAAGF;AAAA,MACJ,eAAe,CAACG,MAAY;AAC1B,QAAIH,EAAM,gBAAgB,OAE1B,OAAO,SAAS,OAAOA,EAAM,cACzBI,EAAmBJ,EAAM,aAAaG,CAAO,IAC7CA,EAAQ,QAAQ,YAAYA,EAAQ,GAAG;AAAA,MAC7C;AAAA,MACA,YAAY,CAACE,MAAgB;AAC3B,QAAIL,EAAM,gBAAgB,OAE1B,OAAO,SAAS,OAAOA,EAAM,eAAeK;AAAA,MAC9C;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|