@takeshape/purchase-order-chat 1.51.0-beta.9 → 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 CHANGED
@@ -1,74 +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
- ## Installation
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
- # or
12
- yarn add @takeshape/purchase-order-chat
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 three entry points:
52
+ This library provides two entry points:
22
53
 
23
54
  | Import | Use Case | CSS Handling |
24
55
  | ----------------------------------------- | -------------------------- | ----------------------------------- |
25
56
  | `@takeshape/purchase-order-chat` | Default - works everywhere | Shadow DOM with bundled CSS |
26
57
  | `@takeshape/purchase-order-chat/tailwind` | Tailwind v4 projects | Integrates with your Tailwind setup |
27
- | `@takeshape/purchase-order-chat/testing` | Unit tests and Storybook | Mock BigCommerce client |
28
58
 
29
- **Default (recommended for most projects):**
30
-
31
- ```tsx
32
- import { PurchaseOrderChatWidget } from "@takeshape/purchase-order-chat";
33
- ```
59
+ ### Default (recommended for most projects)
34
60
 
35
- **For Tailwind v4 projects** (like Catalyst with Tailwind v4):
61
+ The default version wraps the component in a Shadow DOM with all styles bundled, ensuring no CSS conflicts with your existing styles.
36
62
 
37
63
  ```tsx
38
- import { PurchaseOrderChatWidget } from "@takeshape/purchase-order-chat/tailwind";
64
+ import { PurchaseOrderChat } from "@takeshape/purchase-order-chat";
39
65
  ```
40
66
 
41
- The default version wraps the component in a Shadow DOM with all styles bundled, ensuring no CSS conflicts with your existing styles.
42
-
43
- ## Basic Usage
67
+ ### Advanced, for Tailwind v4 projects
44
68
 
45
- The simplest way to integrate the component:
69
+ This gives you more control, and allows for more efficient style generation.
46
70
 
47
71
  ```tsx
48
- import { PurchaseOrderChatWidget } from "@takeshape/purchase-order-chat";
49
-
50
- function App() {
51
- return (
52
- <PurchaseOrderChatWidget
53
- takeshape={{
54
- projectId: "your-project-id",
55
- apiKey: "your-api-key",
56
- }}
57
- bigcommerce={{
58
- endpoint: "https://store-{hash}.mybigcommerce.com/graphql",
59
- storefrontToken: "your-storefront-token",
60
- channelId: 1,
61
- }}
62
- onViewProduct={(product) => {
63
- window.location.href = product.path || `/product/${product.sku}`;
64
- }}
65
- />
66
- );
67
- }
72
+ import { PurchaseOrderChat } from "@takeshape/purchase-order-chat/tailwind";
68
73
  ```
69
74
 
70
- ## Catalyst (Next.js) Integration
71
-
72
75
  For BigCommerce Catalyst storefronts, the recommended approach uses a proxy API route to avoid CORS issues and keep your storefront token server-side.
73
76
 
74
77
  ### 1. Install the package
@@ -84,7 +87,10 @@ Add the library's source files to your Tailwind config:
84
87
  ```css
85
88
  /* In your global CSS file */
86
89
  @import "tailwindcss";
87
- @source "../node_modules/@takeshape/purchase-order-chat/src";
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";
88
94
  ```
89
95
 
90
96
  ### 3. Create a BigCommerce proxy route
@@ -137,7 +143,7 @@ export default function PurchaseOrderAgentPage() {
137
143
  const router = useRouter();
138
144
 
139
145
  return (
140
- <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">
141
147
  <PurchaseOrderChatWidget
142
148
  takeshape={{
143
149
  projectId: process.env.NEXT_PUBLIC_TAKESHAPE_PROJECT_ID!,
@@ -172,32 +178,7 @@ The widget is now available at `/purchase-order-agent`.
172
178
 
173
179
  For BigCommerce B2B Edition stores, you can enable B2B features (company addresses, B2B checkout) by providing a `getB2BJwt` callback.
174
180
 
175
- ### Stencil Themes
176
-
177
- For Stencil storefronts, use the built-in `stencilB2BJwt` function:
178
-
179
- ```tsx
180
- import {
181
- PurchaseOrderChatWidget,
182
- stencilB2BJwt,
183
- } from "@takeshape/purchase-order-chat";
184
-
185
- <PurchaseOrderChatWidget
186
- takeshape={{
187
- projectId: "your-project-id",
188
- apiKey: "your-api-key",
189
- }}
190
- bigcommerce={{
191
- endpoint: "/graphql",
192
- channelId: 1,
193
- getB2BJwt: stencilB2BJwt,
194
- }}
195
- />;
196
- ```
197
-
198
- ### Custom Implementation
199
-
200
- For other platforms (like Catalyst/Next.js), implement your own token fetcher:
181
+ To do this, you'll need implement your own token fetcher:
201
182
 
202
183
  ```tsx
203
184
  const getB2BJwt = async (channelId: number) => {
@@ -234,72 +215,9 @@ const getB2BJwt = async (channelId: number) => {
234
215
 
235
216
  ### BigCommerceConfigProps
236
217
 
237
- | Prop | Type | Required | Description |
238
- | ----------------- | ------------------------------------------------ | -------- | ---------------------------------------------------------------------------------------------------- |
239
- | `endpoint` | `string` | Yes | GraphQL endpoint URL (absolute or relative for proxy) |
240
- | `storefrontToken` | `string` | No | Storefront API token. Optional when using a proxy |
241
- | `channelId` | `number` | Yes | BigCommerce channel ID |
242
- | `getB2BJwt` | `(channelId: number) => Promise<string \| null>` | No | B2B JWT fetcher. Receives channelId, returns B2B storefront token. For Stencil, use `stencilB2BJwt`. |
243
-
244
- ## Advanced Usage (Base Component)
245
-
246
- For advanced use cases requiring custom provider setup or client management, use `PurchaseOrderChat` with `TakeShapeConfigProvider`:
247
-
248
- ```tsx
249
- import {
250
- PurchaseOrderChat,
251
- TakeShapeConfigProvider,
252
- createBigCommerceClient,
253
- } from "@takeshape/purchase-order-chat/tailwind";
254
-
255
- const bigCommerceClient = createBigCommerceClient({
256
- endpoint: "https://store-{hash}.mybigcommerce.com/graphql",
257
- storefrontToken: "your-storefront-token",
258
- channelId: 1,
259
- });
260
-
261
- function App() {
262
- return (
263
- <TakeShapeConfigProvider projectId="your-project-id" apiKey="your-api-key">
264
- <PurchaseOrderChat
265
- bigcommerce={{
266
- client: bigCommerceClient,
267
- onViewProduct: (product) => {
268
- window.location.href = product.path || `/product/${product.sku}`;
269
- },
270
- onCheckout: (checkoutUrl) => {
271
- window.location.href = checkoutUrl;
272
- },
273
- }}
274
- />
275
- </TakeShapeConfigProvider>
276
- );
277
- }
278
- ```
279
-
280
- For testing, import `createMockBigCommerceClient` from the `/testing` entry point:
281
-
282
- ```tsx
283
- import { createMockBigCommerceClient } from "@takeshape/purchase-order-chat/testing";
284
-
285
- const mockClient = createMockBigCommerceClient();
286
- ```
287
-
288
- ## Styling
289
-
290
- ### For Tailwind v4 Projects
291
-
292
- Configure Tailwind to scan the package source files:
293
-
294
- ```css
295
- @import "tailwindcss";
296
- @source "../node_modules/@takeshape/purchase-order-chat/src";
297
- ```
298
-
299
- ### For Tailwind v3 or Non-Tailwind Projects
300
-
301
- Use the default import - styles are bundled in a Shadow DOM:
302
-
303
- ```tsx
304
- import { PurchaseOrderChatWidget } from "@takeshape/purchase-order-chat";
305
- ```
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 CHANGED
@@ -36,10 +36,12 @@ export declare interface Product {
36
36
  };
37
37
  }
38
38
 
39
- export declare function PurchaseOrderChat(props: Omit<PurchaseOrderChatWidgetProps, 'onViewProduct' | 'onCheckout'> & {
39
+ export declare function PurchaseOrderAgent(props: PurchaseOrderAgentProps): JSX.Element;
40
+
41
+ export declare type PurchaseOrderAgentProps = Omit<PurchaseOrderChatWidgetProps, 'onViewProduct' | 'onCheckout'> & {
40
42
  productPath?: string | false;
41
43
  checkoutUrl?: string | false;
42
- }): JSX.Element;
44
+ };
43
45
 
44
46
  export declare interface PurchaseOrderChatWidgetProps {
45
47
  /** TakeShape API configuration */
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
  import { jsx as e } from "react/jsx-runtime";
3
- import { r as o } from "./purchase-order-chat-wrapper-Cd-OCJJ6.js";
4
- import { PurchaseOrderChat as a } from "./shadow.js";
5
- function i(r) {
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
6
  return /* @__PURE__ */ e(
7
- a,
7
+ c,
8
8
  {
9
9
  ...r,
10
10
  onViewProduct: (t) => {
@@ -17,6 +17,6 @@ function i(r) {
17
17
  );
18
18
  }
19
19
  export {
20
- i as PurchaseOrderChat
20
+ n as PurchaseOrderAgent
21
21
  };
22
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +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 function PurchaseOrderChat(\n props: Omit<PurchaseOrderChatWidgetProps, 'onViewProduct' | 'onCheckout'> & {\n productPath?: string | false;\n checkoutUrl?: string | false;\n }\n) {\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":["PurchaseOrderChat","props","jsx","ShadowPurchaseOrderChat","product","resolveProductPath","checkoutUrl"],"mappings":";;;AAiBO,SAASA,EACdC,GAIA;AACA,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;"}
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;"}