@cimplify/sdk 0.44.12 → 0.44.14

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.
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "session-message-banner",
3
+ "title": "SessionMessageBanner",
4
+ "description": "Top-of-page banner for session-scoped messages (promo nudges, abandoned cart prompts, low-stock alerts) with dismiss tracking.",
5
+ "type": "component",
6
+ "registryDependencies": [
7
+ "cn"
8
+ ],
9
+ "files": [
10
+ {
11
+ "path": "session-message-banner.tsx",
12
+ "content": "\"use client\";\n\nimport React from \"react\";\nimport type { SessionMessage } from \"../activity\";\nimport { useActivityState } from \"./hooks/use-activity-state\";\nimport { cn } from \"@cimplify/sdk/react\";\n\nexport interface SessionMessageBannerClassNames {\n root?: string;\n message?: string;\n text?: string;\n dismissButton?: string;\n empty?: string;\n}\n\nexport interface SessionMessageBannerProps {\n /** Override messages (skips fetch). For SSR, pass pre-fetched messages. */\n messages?: SessionMessage[];\n /** Called when a message is dismissed. Receives the message code. */\n onDismiss?: (code: string) => void;\n /** Custom message renderer. */\n renderMessage?: (message: SessionMessage) => React.ReactNode;\n className?: string;\n classNames?: SessionMessageBannerClassNames;\n}\n\n/**\n * SessionMessageBanner — renders activity-based session messages.\n *\n * Displays dismissible message cards with level-based styling (info, promotion, urgency, suggestion).\n * Returns `null` when there are no messages.\n */\nexport function SessionMessageBanner({\n messages: messagesProp,\n onDismiss,\n renderMessage,\n className,\n classNames,\n}: SessionMessageBannerProps): React.ReactElement | null {\n const { messages: fetched, isLoading, dismissMessage } = useActivityState({\n enabled: messagesProp === undefined,\n });\n\n const messages = messagesProp ?? fetched;\n\n const handleDismiss = async (code: string): Promise<void> => {\n if (onDismiss) {\n onDismiss(code);\n } else {\n await dismissMessage(code);\n }\n };\n\n if (isLoading && messages.length === 0) {\n return (\n <div\n data-cimplify-session-message-banner\n aria-busy=\"true\"\n className={cn(className, classNames?.root)}\n />\n );\n }\n\n if (messages.length === 0) {\n return null;\n }\n\n return (\n <div data-cimplify-session-message-banner className={cn(className, classNames?.root)}>\n {messages.map((msg) => (\n <div\n key={msg.code}\n data-cimplify-session-message\n data-level={msg.level}\n className={classNames?.message}\n >\n {renderMessage ? (\n renderMessage(msg)\n ) : (\n <>\n <span data-cimplify-session-message-text className={classNames?.text}>\n {msg.text}\n </span>\n {msg.dismissible && (\n <button\n type=\"button\"\n onClick={() => void handleDismiss(msg.code)}\n data-cimplify-session-message-dismiss\n className={classNames?.dismissButton}\n aria-label=\"Dismiss message\"\n >\n &times;\n </button>\n )}\n </>\n )}\n </div>\n ))}\n </div>\n );\n}\n"
13
+ }
14
+ ]
15
+ }
@@ -98,6 +98,18 @@ app/
98
98
  - `components/newsletter.tsx` (homepage strip) similarly fakes submit. Wire to a real list provider.
99
99
  - Hero / lookbook imagery is Unsplash placeholder — replace with merchant assets.
100
100
 
101
+ ## Customizing SDK components
102
+
103
+ For anything beyond `lib/brand.ts` + `app/globals.css`, lean on the SDK's prebuilt components rather than reinvent. **Especially for product customization** (variants, add-ons, bundles, composites, services with scheduling) — the SDK already gets price math, axis matching, and cart payload contracts right. Default to ejecting and restyling:
104
+
105
+ ```bash
106
+ bunx @cimplify/sdk add cart-drawer
107
+ bunx @cimplify/sdk add variant-selector
108
+ bunx @cimplify/sdk add product-page
109
+ ```
110
+
111
+ Then edit the local copy. **Don't change the cart payload shape** unless you're also touching the SDK mock + backend lens. Full ejection rules and the customizer contract are in the SDK-level [`AGENTS.md`](../../AGENTS.md) → "Don't reinvent product customization".
112
+
101
113
  ## Quick start
102
114
 
103
115
  ```bash
@@ -94,7 +94,27 @@ app/
94
94
 
95
95
  ## Mock seed
96
96
 
97
- Wired to `--seed retail` (Currents Electronics catalogue — the closest stand-in until an apparel seed ships). Replace with apparel data in production.
97
+ Wired to `--seed fashion` (Studio FRX apparel catalogue — 14 products with size variants XS–2XL, Drop 04 + Best Sellers collections, full-bleed product imagery served from `static-tmp.cimplify.io`).
98
+
99
+ ## Customizing SDK components
100
+
101
+ For anything beyond `lib/brand.ts` + `app/globals.css`, you'll likely want to lean on the SDK's prebuilt components rather than reinvent. Particularly for **product customization** (variants, add-ons, bundles, composites, services with scheduling), the SDK already gets the price math, variant axis matching, and cart payload contracts right. Default to ejecting and restyling:
102
+
103
+ ```bash
104
+ bunx @cimplify/sdk add variant-selector # copies into ./components/
105
+ bunx @cimplify/sdk add cart-drawer
106
+ bunx @cimplify/sdk add product-page
107
+ ```
108
+
109
+ Then edit the local copy. **Don't change the cart payload shape** unless you're also touching the SDK's mock and the backend lens.
110
+
111
+ If you're considering a from-scratch rebuild of the customizer, read these SDK source files first to understand the contract you must reproduce:
112
+ - `src/react/product-customizer.tsx` — top-level state machine + final `onAddToCart` payload assembly
113
+ - `src/react/variant-selector.tsx` — multi-axis matching via `display_attributes`; default-variant init runs in a `useEffect` and is easy to break
114
+ - `src/react/{add-on,bundle,composite}-selector.tsx` — group constraints, exclusivity rules, per-component variants
115
+ - `src/mock/domain/cart/{index,pricing}.ts` — the contract: `computeUnitPrice`, `computeBundlePrice`, `computeCompositePrice` (4 modes), `computeLineKey`
116
+
117
+ Full ejection + customization rules are in the SDK-level [`AGENTS.md`](../../AGENTS.md) under "Don't reinvent product customization".
98
118
 
99
119
  ## Quick start
100
120
 
@@ -74,6 +74,18 @@ app/
74
74
  - Contact + newsletter fake submits.
75
75
  - Hero / category / product imagery is Unsplash placeholder — replace with merchant photography.
76
76
 
77
+ ## Customizing SDK components
78
+
79
+ For anything beyond `lib/brand.ts` + `app/globals.css`, lean on the SDK's prebuilt components rather than reinvent. **Especially for product customization** (variants, add-ons, bundles, composites) — the SDK already gets price math, axis matching, and cart payload contracts right. Default to ejecting and restyling:
80
+
81
+ ```bash
82
+ bunx @cimplify/sdk add cart-drawer
83
+ bunx @cimplify/sdk add add-on-selector
84
+ bunx @cimplify/sdk add product-page
85
+ ```
86
+
87
+ Then edit the local copy. **Don't change the cart payload shape** unless you're also touching the SDK mock + backend lens. Full ejection rules and the customizer contract are in the SDK-level [`AGENTS.md`](../../AGENTS.md) → "Don't reinvent product customization".
88
+
77
89
  ## Quick start
78
90
 
79
91
  ```bash
@@ -80,6 +80,18 @@ app/
80
80
  - Contact form + newsletter fake their submits.
81
81
  - Hero / dish photography is Unsplash — replace with merchant photos.
82
82
 
83
+ ## Customizing SDK components
84
+
85
+ For anything beyond `lib/brand.ts` + `app/globals.css`, lean on the SDK's prebuilt components rather than reinvent. **Especially for product customization** (variants, add-ons, bundles, composites, services with scheduling) — the SDK already gets price math, axis matching, and cart payload contracts right. Default to ejecting and restyling:
86
+
87
+ ```bash
88
+ bunx @cimplify/sdk add cart-drawer
89
+ bunx @cimplify/sdk add add-on-selector
90
+ bunx @cimplify/sdk add product-page
91
+ ```
92
+
93
+ Then edit the local copy. **Don't change the cart payload shape** unless you're also touching the SDK mock + backend lens. Full ejection rules and the customizer contract are in the SDK-level [`AGENTS.md`](../../AGENTS.md) → "Don't reinvent product customization".
94
+
83
95
  ## Quick start
84
96
 
85
97
  ```bash
@@ -95,6 +95,18 @@ app/
95
95
 
96
96
  Wired to `--seed retail` (Currents Electronics). Edit `dev:mock` in `package.json` to preview another seed.
97
97
 
98
+ ## Customizing SDK components
99
+
100
+ For anything beyond `lib/brand.ts` + `app/globals.css`, lean on the SDK's prebuilt components rather than reinvent. **Especially for product customization** (variants, add-ons, bundles, composites, services with scheduling) — the SDK already gets price math, axis matching, and cart payload contracts right. Default to ejecting and restyling:
101
+
102
+ ```bash
103
+ bunx @cimplify/sdk add cart-drawer
104
+ bunx @cimplify/sdk add variant-selector
105
+ bunx @cimplify/sdk add product-page
106
+ ```
107
+
108
+ Then edit the local copy. **Don't change the cart payload shape** unless you're also touching the SDK mock + backend lens. Full ejection rules and the customizer contract are in the SDK-level [`AGENTS.md`](../../AGENTS.md) → "Don't reinvent product customization".
109
+
98
110
  ## Quick start
99
111
 
100
112
  ```bash
@@ -79,6 +79,18 @@ app/
79
79
  - `/book` widget shows every slot as available. For production, wire `useAvailableSlots({ serviceId, date })` from `@cimplify/sdk/react` to filter to genuinely-free windows.
80
80
  - Contact + newsletter fake submits.
81
81
 
82
+ ## Customizing SDK components
83
+
84
+ For anything beyond `lib/brand.ts` + `app/globals.css`, lean on the SDK's prebuilt components rather than reinvent. **Especially for service scheduling, booking widgets, and add-on selectors** — the SDK already gets price math, slot matching, and cart payload contracts right. Default to ejecting and restyling:
85
+
86
+ ```bash
87
+ bunx @cimplify/sdk add cart-drawer
88
+ bunx @cimplify/sdk add product-page
89
+ bunx @cimplify/sdk add booking-card
90
+ ```
91
+
92
+ Then edit the local copy. **Don't change the cart payload shape** (`scheduled_start`, `scheduled_end`, `staff_id`, `customer_inputs`, etc.) unless you're also touching the SDK mock + backend lens. Full ejection rules and the customizer contract are in the SDK-level [`AGENTS.md`](../../AGENTS.md) → "Don't reinvent product customization".
93
+
82
94
  ## Quick start
83
95
 
84
96
  ```bash