@strata-ds/core 2.1.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/README.md +438 -0
- package/dist/components/DynamicComponentDebug.d.ts +3 -0
- package/dist/components/DynamicComponentDebug.d.ts.map +1 -0
- package/dist/components/DynamicComponents.d.ts +12 -0
- package/dist/components/DynamicComponents.d.ts.map +1 -0
- package/dist/components/card-ui/Card.d.ts +40 -0
- package/dist/components/card-ui/Card.d.ts.map +1 -0
- package/dist/components/card-ui/DefaultCard.d.ts +3 -0
- package/dist/components/card-ui/DefaultCard.d.ts.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/data/index.d.ts +2 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/mock.types.d.ts +70 -0
- package/dist/data/mock.types.d.ts.map +1 -0
- package/dist/hook/useCardData.d.ts +371 -0
- package/dist/hook/useCardData.d.ts.map +1 -0
- package/dist/hook/useComponent.d.ts +4 -0
- package/dist/hook/useComponent.d.ts.map +1 -0
- package/dist/hook/useComponents.d.ts +2 -0
- package/dist/hook/useComponents.d.ts.map +1 -0
- package/dist/hook/useDesignSystemSync.d.ts +1 -0
- package/dist/hook/useDesignSystemSync.d.ts.map +1 -0
- package/dist/hook/useDynamicComponents.d.ts +3 -0
- package/dist/hook/useDynamicComponents.d.ts.map +1 -0
- package/dist/index.d.ts +440 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +3049 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +3062 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/StrataProvider.d.ts +60 -0
- package/dist/providers/StrataProvider.d.ts.map +1 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/registry/ComponentFactory.d.ts +39 -0
- package/dist/registry/ComponentFactory.d.ts.map +1 -0
- package/dist/registry/ComponentRegistry.d.ts +29 -0
- package/dist/registry/ComponentRegistry.d.ts.map +1 -0
- package/dist/types/card-types.d.ts +185 -0
- package/dist/types/card-types.d.ts.map +1 -0
- package/package.json +74 -0
package/README.md
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
# @strata-ds/core
|
|
2
|
+
|
|
3
|
+
> The runtime component library for [Strata](https://strata.charisol.io) — connect your React app to your design system and ship updates live.
|
|
4
|
+
|
|
5
|
+
`@strata-ds/core` is a dynamic React component library and stylesheet runtime. It enables teams to consume design tokens and components directly from a centralised Strata design system, ensuring that what designers create is exactly what developers ship — consistently, across platforms, and in real time.
|
|
6
|
+
|
|
7
|
+
> Design once in Strata. Ship everywhere.
|
|
8
|
+
|
|
9
|
+
## Why @strata-ds/core?
|
|
10
|
+
|
|
11
|
+
### The Problem
|
|
12
|
+
|
|
13
|
+
Design and engineering teams often drift apart:
|
|
14
|
+
|
|
15
|
+
- Designers update Figma files
|
|
16
|
+
- Developers re-implement styles manually
|
|
17
|
+
- Components slowly diverge from the original design
|
|
18
|
+
- Consistency breaks across products and platforms
|
|
19
|
+
|
|
20
|
+
This results in duplicate work, inconsistent UI, broken design intent, and slow iteration.
|
|
21
|
+
|
|
22
|
+
### The Solution
|
|
23
|
+
|
|
24
|
+
`@strata-ds/core` bridges this gap by acting as:
|
|
25
|
+
|
|
26
|
+
- A component library
|
|
27
|
+
- A stylesheet generator runtime
|
|
28
|
+
- A live consumer of design tokens and components
|
|
29
|
+
|
|
30
|
+
All powered by your **Strata** project.
|
|
31
|
+
|
|
32
|
+
Instead of hardcoding styles, **components dynamically reference design tokens** fetched from the design system. This establishes a single **source of truth** for design.
|
|
33
|
+
|
|
34
|
+
## Core Principles
|
|
35
|
+
|
|
36
|
+
### 1. Separation of Concerns
|
|
37
|
+
|
|
38
|
+
`@strata-ds/core` strictly separates:
|
|
39
|
+
|
|
40
|
+
- **Variables (Design Tokens)** — Colors, spacing, typography, radii, shadows, etc.
|
|
41
|
+
- **Components** — Buttons, Cards, Forms, Navbars, etc.
|
|
42
|
+
|
|
43
|
+
Components never own styles directly — they reference tokens.
|
|
44
|
+
|
|
45
|
+
### 2. Single Source of Truth
|
|
46
|
+
|
|
47
|
+
Design tokens live in your Strata project, not inside applications.
|
|
48
|
+
|
|
49
|
+
- Tokens are defined once
|
|
50
|
+
- Components reference them dynamically
|
|
51
|
+
- Updates propagate automatically
|
|
52
|
+
|
|
53
|
+
### 3. Dynamic & Real-Time Sync
|
|
54
|
+
|
|
55
|
+
`@strata-ds/core` can:
|
|
56
|
+
|
|
57
|
+
- Fetch updated tokens and components from the Strata backend
|
|
58
|
+
- Detect changes via checksum
|
|
59
|
+
- Rebuild styles automatically
|
|
60
|
+
- Fall back to cached data when offline
|
|
61
|
+
|
|
62
|
+
## Architecture Overview
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
Figma / Style Dictionary
|
|
66
|
+
↓
|
|
67
|
+
Strata Design System
|
|
68
|
+
↓
|
|
69
|
+
Machine-parseable JSON
|
|
70
|
+
↓
|
|
71
|
+
@strata-ds/core Component Library
|
|
72
|
+
↓
|
|
73
|
+
Your React Application
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Quick Start
|
|
77
|
+
|
|
78
|
+
### 1. Create a Strata project
|
|
79
|
+
|
|
80
|
+
Go to [strata.charisol.io](https://strata.charisol.io), create a project, and import your design tokens (Style Dictionary JSON or Figma).
|
|
81
|
+
|
|
82
|
+
### 2. Get your sync URL
|
|
83
|
+
|
|
84
|
+
Once your tokens are imported, your project's sync URL is shown on the project page:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
https://api-production-charisol-design-system-be.aws.charisol.io/v1/project/YOUR_PROJECT_ID/data
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Copy it — you'll need it in step 4.
|
|
91
|
+
|
|
92
|
+
### 3. Install
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm install @strata-ds/core
|
|
96
|
+
# or
|
|
97
|
+
yarn add @strata-ds/core
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 4. Wrap your app
|
|
101
|
+
|
|
102
|
+
**CDN Snapshot Sync (recommended — 1 request per poll, edge-cached):**
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
"use client"; // Next.js App Router only
|
|
106
|
+
import { StrataProvider } from "@strata-ds/core";
|
|
107
|
+
|
|
108
|
+
export default function RootLayout({
|
|
109
|
+
children,
|
|
110
|
+
}: {
|
|
111
|
+
children: React.ReactNode;
|
|
112
|
+
}) {
|
|
113
|
+
return (
|
|
114
|
+
<StrataProvider
|
|
115
|
+
syncEnabled={true}
|
|
116
|
+
projectId="YOUR_PROJECT_ID"
|
|
117
|
+
snapshotCdnBase="https://cdn.strata.charisol.io"
|
|
118
|
+
syncToken="pt_live_your_token_here"
|
|
119
|
+
syncInterval={5000}
|
|
120
|
+
>
|
|
121
|
+
{children}
|
|
122
|
+
</StrataProvider>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
> 💡 Get your `projectId` and `syncToken` from the **Publish & Sync** tab on your Strata project dashboard.
|
|
128
|
+
|
|
129
|
+
### Legacy sync (syncUrl — still supported, not recommended for new projects)
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
"use client"; // Next.js App Router only
|
|
133
|
+
import { StrataProvider } from "@strata-ds/core";
|
|
134
|
+
|
|
135
|
+
export default function RootLayout({
|
|
136
|
+
children,
|
|
137
|
+
}: {
|
|
138
|
+
children: React.ReactNode;
|
|
139
|
+
}) {
|
|
140
|
+
return (
|
|
141
|
+
<StrataProvider
|
|
142
|
+
syncEnabled={true}
|
|
143
|
+
syncUrl="https://api-production-charisol-design-system-be.aws.charisol.io/v1/project/YOUR_PROJECT_ID/data"
|
|
144
|
+
syncToken="pt_live_your_token_here"
|
|
145
|
+
syncInterval={3000}
|
|
146
|
+
>
|
|
147
|
+
{children}
|
|
148
|
+
</StrataProvider>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
> 💡 Replace `YOUR_PROJECT_ID` with the ID from your Strata project dashboard. Get your `syncToken` from the **Publish & Sync** tab — it starts with `pt_live_`.
|
|
154
|
+
|
|
155
|
+
### 5. Use your components
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
"use client";
|
|
159
|
+
import { useComponents } from "@strata-ds/core";
|
|
160
|
+
|
|
161
|
+
function App() {
|
|
162
|
+
// Components you created in your Strata project
|
|
163
|
+
const { Button, Navbar } = useComponents();
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<>
|
|
167
|
+
{Button && (
|
|
168
|
+
<Button onClick={() => console.log("clicked")}>Click me</Button>
|
|
169
|
+
)}
|
|
170
|
+
{Navbar && <Navbar />}
|
|
171
|
+
</>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Installation
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
npm install @strata-ds/core
|
|
180
|
+
# or
|
|
181
|
+
yarn add @strata-ds/core
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Project Setup (React)
|
|
185
|
+
|
|
186
|
+
`@strata-ds/core` works with React 18+, Next.js (App Router or Pages Router), and any standard React setup.
|
|
187
|
+
|
|
188
|
+
### 1. Create a new project
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npx create-next-app@latest my-strata-app --typescript
|
|
192
|
+
cd my-strata-app
|
|
193
|
+
npm install @strata-ds/core
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### 2. Integrate the StrataProvider
|
|
197
|
+
|
|
198
|
+
Wrap your application's root component with `StrataProvider`. This provider manages the connection to the Strata backend.
|
|
199
|
+
|
|
200
|
+
| Prop | Type | Description |
|
|
201
|
+
| :----------------- | :------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
202
|
+
| `syncEnabled` | `boolean` | If `true`, the library will fetch and sync tokens/components from the server. |
|
|
203
|
+
| `snapshotCdnBase` | `string` | **Recommended.** Base CDN URL for snapshot files (e.g. `"https://cdn.strata.charisol.io"`). When set together with `projectId`, the provider fetches a single `strata.json` snapshot per poll cycle instead of 3 API calls. Takes precedence over `syncUrl`. |
|
|
204
|
+
| `projectId` | `string` | Your Strata project ID (shown in the dashboard URL and project settings). Required when using `snapshotCdnBase`. |
|
|
205
|
+
| `syncUrl` | `string` | Legacy base sync URL. `StrataProvider` will append `/variables`, `/components`, and `/custom` to this URL. Ignored when `snapshotCdnBase` + `projectId` are provided. |
|
|
206
|
+
| `syncInterval` | `number` | Polling interval in milliseconds to check for design system updates. Default: `3000`. |
|
|
207
|
+
| `syncToken` | `string` | Sync token from your project dashboard. When set, all sync requests carry `Authorization: Bearer <token>`. Required if your project is not fully public. |
|
|
208
|
+
| `initialData` | `DesignSystemData` | Initial design system data to use before the first sync. |
|
|
209
|
+
| `userDesignSystem` | `DesignSystemData` | Override design system data — useful for storybook, testing, or static mode. Takes precedence over `initialData`. |
|
|
210
|
+
| `onSyncError` | `(error: { code: number; message: string; source: string }) => void` | Callback invoked when a sync cycle fails. `code` is the HTTP status (0 for non-HTTP errors), `message` is a human-readable description, and `source` is `"cdn"` or `"sync"`. |
|
|
211
|
+
| `onSyncSuccess` | `(data: DesignSystemData) => void` | Callback invoked whenever a sync cycle succeeds with new data. |
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
// app/layout.tsx (Next.js App Router)
|
|
215
|
+
"use client";
|
|
216
|
+
import { StrataProvider } from "@strata-ds/core";
|
|
217
|
+
|
|
218
|
+
export default function RootLayout({
|
|
219
|
+
children,
|
|
220
|
+
}: {
|
|
221
|
+
children: React.ReactNode;
|
|
222
|
+
}) {
|
|
223
|
+
return (
|
|
224
|
+
<html lang="en">
|
|
225
|
+
<body>
|
|
226
|
+
<StrataProvider
|
|
227
|
+
syncEnabled={true}
|
|
228
|
+
projectId="YOUR_PROJECT_ID"
|
|
229
|
+
snapshotCdnBase="https://cdn.strata.charisol.io"
|
|
230
|
+
syncInterval={5000}
|
|
231
|
+
>
|
|
232
|
+
{children}
|
|
233
|
+
</StrataProvider>
|
|
234
|
+
</body>
|
|
235
|
+
</html>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
> 💡 Replace `YOUR_PROJECT_ID` with the ID from your Strata project dashboard. For private projects, add `syncToken="pt_live_your_token_here"` (get it from the **Publish & Sync** tab).
|
|
241
|
+
|
|
242
|
+
### Sync token authentication
|
|
243
|
+
|
|
244
|
+
If your project has a sync token set in the Strata dashboard, pass it as `syncToken`. Every polling request will automatically include `Authorization: Bearer <token>`.
|
|
245
|
+
|
|
246
|
+
Projects with `syncToken` set are only readable by clients that present the correct token. This is the recommended way to gate read access to your design system without managing user accounts.
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
<StrataProvider
|
|
250
|
+
syncEnabled={true}
|
|
251
|
+
projectId="YOUR_PROJECT_ID"
|
|
252
|
+
snapshotCdnBase="https://cdn.strata.charisol.io"
|
|
253
|
+
syncToken="pt_live_your_token_here"
|
|
254
|
+
syncInterval={5000}
|
|
255
|
+
>
|
|
256
|
+
{children}
|
|
257
|
+
</StrataProvider>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Using Design System Components
|
|
261
|
+
|
|
262
|
+
`@strata-ds/core` provides dynamic access to your components defined in Strata.
|
|
263
|
+
|
|
264
|
+
### Accessing Components with `useComponents`
|
|
265
|
+
|
|
266
|
+
```tsx
|
|
267
|
+
"use client";
|
|
268
|
+
import { useComponents } from "@strata-ds/core";
|
|
269
|
+
|
|
270
|
+
function AppContent() {
|
|
271
|
+
// Components are named exactly as you defined them in your Strata project
|
|
272
|
+
const { Button, Navbar, Card } = useComponents();
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<>
|
|
276
|
+
{/* Render conditionally while components are loading */}
|
|
277
|
+
{Button && (
|
|
278
|
+
<Button onClick={() => console.log("clicked")}>Click me</Button>
|
|
279
|
+
)}
|
|
280
|
+
|
|
281
|
+
{Card && <Card style={{ padding: "20px" }}>Card content here</Card>}
|
|
282
|
+
</>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Accessing Design System Context with `useStrata`
|
|
288
|
+
|
|
289
|
+
```tsx
|
|
290
|
+
"use client";
|
|
291
|
+
import { useStrata } from "@strata-ds/core";
|
|
292
|
+
|
|
293
|
+
function StatusBar() {
|
|
294
|
+
const { designSystem, syncStatus, lastSynced } = useStrata();
|
|
295
|
+
|
|
296
|
+
return (
|
|
297
|
+
<div>
|
|
298
|
+
<p>Sync status: {syncStatus}</p>
|
|
299
|
+
<p>Last synced: {lastSynced?.toLocaleTimeString() || "Never"}</p>
|
|
300
|
+
<p>Components: {Object.keys(designSystem.components).join(", ")}</p>
|
|
301
|
+
</div>
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Customisation and Overrides
|
|
307
|
+
|
|
308
|
+
**Token-Driven Styling (Default)**
|
|
309
|
+
|
|
310
|
+
By default, all components are styled based on the latest tokens fetched from your Strata project. This ensures perfect design-to-code fidelity.
|
|
311
|
+
|
|
312
|
+
**Local Overrides**
|
|
313
|
+
|
|
314
|
+
Override any style locally using standard React props:
|
|
315
|
+
|
|
316
|
+
```tsx
|
|
317
|
+
<Button
|
|
318
|
+
style={{ backgroundColor: "#007bff", color: "white" }}
|
|
319
|
+
className="my-custom-class"
|
|
320
|
+
>
|
|
321
|
+
Custom styled button
|
|
322
|
+
</Button>
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Dynamic Updates (Hot-Reloading)
|
|
326
|
+
|
|
327
|
+
`@strata-ds/core` intelligently handles design updates:
|
|
328
|
+
|
|
329
|
+
1. A designer makes a change in Strata (e.g., updates a colour token or modifies a component).
|
|
330
|
+
2. Strata generates a new checksum.
|
|
331
|
+
3. Your `StrataProvider` (via `syncInterval`) polls the `syncUrl`.
|
|
332
|
+
4. If the checksum has changed, the library fetches new design tokens and component configurations, and your app's components are dynamically restyled — without a page refresh.
|
|
333
|
+
|
|
334
|
+
## Debugging & Inspection
|
|
335
|
+
|
|
336
|
+
### `StrataDebug`
|
|
337
|
+
|
|
338
|
+
The `<StrataDebug />` component renders a debug panel showing the active sync mode, connection details, and the component registry. Useful during development to verify that tokens and components have loaded correctly.
|
|
339
|
+
|
|
340
|
+
```tsx
|
|
341
|
+
import { StrataDebug } from "@strata-ds/core";
|
|
342
|
+
|
|
343
|
+
// Place anywhere inside StrataProvider
|
|
344
|
+
<StrataDebug />;
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
The panel automatically displays the relevant fields for the active sync mode:
|
|
348
|
+
|
|
349
|
+
- **CDN mode** (`snapshotCdnBase` + `projectId` set): shows `✅ CDN Snapshot`, Project ID, resolved Snapshot URL, token presence, and sync interval.
|
|
350
|
+
- **Legacy mode** (`syncUrl` set): shows `⚠️ Legacy (3 requests/poll)`, Sync URL, token presence, and sync interval.
|
|
351
|
+
- **Disabled**: shows `❌ Disabled`.
|
|
352
|
+
|
|
353
|
+
> 🔒 The `syncToken` value is **never** rendered — the panel only shows `✅ Present` or `❌ None`.
|
|
354
|
+
|
|
355
|
+
### Programmatic inspection
|
|
356
|
+
|
|
357
|
+
```tsx
|
|
358
|
+
import { useStrata, useDynamicComponents } from "@strata-ds/core";
|
|
359
|
+
|
|
360
|
+
function DebugPanel() {
|
|
361
|
+
const { designSystem, syncStatus, syncUrl, syncEnabled } = useStrata();
|
|
362
|
+
const dynamicComponents = useDynamicComponents();
|
|
363
|
+
|
|
364
|
+
return (
|
|
365
|
+
<pre>
|
|
366
|
+
{JSON.stringify(
|
|
367
|
+
{
|
|
368
|
+
syncStatus,
|
|
369
|
+
syncEnabled,
|
|
370
|
+
syncUrl,
|
|
371
|
+
designSystemComponents: Object.keys(designSystem.components),
|
|
372
|
+
registryComponents: Object.keys(dynamicComponents),
|
|
373
|
+
},
|
|
374
|
+
null,
|
|
375
|
+
2,
|
|
376
|
+
)}
|
|
377
|
+
</pre>
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Hooks reference
|
|
383
|
+
|
|
384
|
+
| Hook / Property | Description |
|
|
385
|
+
| :----------------------- | :--------------------------------------------------------------------------------------------------------------------------------------- |
|
|
386
|
+
| `useStrata()` | Returns full context: `designSystem`, `syncStatus`, `lastSynced`, `syncUrl`, `snapshotCdnBase`, `projectId`, `syncEnabled`, `forceSync`. |
|
|
387
|
+
| `useComponents()` | Returns ready-to-use React components by PascalCase name. |
|
|
388
|
+
| `useDynamicComponents()` | Returns the raw component registry map. |
|
|
389
|
+
|
|
390
|
+
## Network Debugging
|
|
391
|
+
|
|
392
|
+
If components are not loading, check your browser's Network tab:
|
|
393
|
+
|
|
394
|
+
- **CDN pattern:** When `snapshotCdnBase` and `projectId` are set, the provider makes a single request to `${snapshotCdnBase}/snapshots/${projectId}/strata.json` per poll cycle. Verify the response is a JSON object with `variables`, `components`, and `custom` keys.
|
|
395
|
+
- **Legacy pattern:** When `syncUrl` is set, the provider makes 3 requests per poll cycle: `${syncUrl}/variables`, `${syncUrl}/components`, and `${syncUrl}/custom`. Each should return the corresponding JSON object.
|
|
396
|
+
- **Errors:** Check the console for `❌ Sync failed:` messages.
|
|
397
|
+
|
|
398
|
+
## Registry API
|
|
399
|
+
|
|
400
|
+
`strataRegistry` is the underlying singleton registry that stores all registered components.
|
|
401
|
+
|
|
402
|
+
```tsx
|
|
403
|
+
import { strataRegistry } from "@strata-ds/core";
|
|
404
|
+
|
|
405
|
+
// Check if a component is registered
|
|
406
|
+
strataRegistry.hasComponent("Button");
|
|
407
|
+
|
|
408
|
+
// Get a component by name
|
|
409
|
+
const ButtonComponent = strataRegistry.getComponent("Button");
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
## Component Factory
|
|
413
|
+
|
|
414
|
+
`StrataComponentFactory` creates React components from Strata component definitions.
|
|
415
|
+
|
|
416
|
+
```tsx
|
|
417
|
+
import { StrataComponentFactory } from "@strata-ds/core";
|
|
418
|
+
|
|
419
|
+
const MyComponent = StrataComponentFactory.createComponent(
|
|
420
|
+
"MyComponent",
|
|
421
|
+
componentData,
|
|
422
|
+
designSystem,
|
|
423
|
+
);
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
## Key Features
|
|
427
|
+
|
|
428
|
+
- 🔁 Live sync with Strata backend
|
|
429
|
+
- 🧠 Token-driven styling
|
|
430
|
+
- 🧩 Dynamic component registry
|
|
431
|
+
- 🛠 Inline style overrides supported
|
|
432
|
+
- 📦 Installable via npm
|
|
433
|
+
- 📴 Offline-first fallback
|
|
434
|
+
- 🧪 Debug tools included (`StrataDebug`)
|
|
435
|
+
|
|
436
|
+
## License
|
|
437
|
+
|
|
438
|
+
MIT © [Charisol](https://strata.charisol.io)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamicComponentDebug.d.ts","sourceRoot":"","sources":["../../src/components/DynamicComponentDebug.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EA+D/B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const DynamicComponent: React.FC<{
|
|
3
|
+
name: string;
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const AutoForm: React.FC<{
|
|
8
|
+
formName?: string;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=DynamicComponents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamicComponents.d.ts","sourceRoot":"","sources":["../../src/components/DynamicComponents.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAUA,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CASA,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare const Card: {
|
|
3
|
+
({ children, width, maxWidth, fontFamily, ...props }: any): import("react/jsx-runtime").JSX.Element | null;
|
|
4
|
+
Container: ({ children, width, maxWidth, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
5
|
+
Header: ({ children, padding, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
HeaderContent: ({ children, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
HeaderTitle: ({ children, fontSize, fontWeight, color, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
HeaderTimer: ({ children, fontSize, fontFamily, color, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
Body: ({ children, padding, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
BodyDriver: ({ children, backgroundColor, borderRadius, padding, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
11
|
+
BodyImage: ({ src, alt, width, height, borderRadius, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
BodyInfo: ({ children, flexGrow, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
+
BodyName: ({ children, fontWeight, color, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
+
BodySpan: ({ children, fontSize, color, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
BodyActions: ({ children, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
16
|
+
BodyActionButton: ({ children, variant, backgroundColor, color, hoverBackgroundColor, border, padding, borderRadius, onClick, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
17
|
+
BodyActionIcon: ({ children, width, height, color, ...props }: any) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
Route: ({ children, paddingX, paddingBottom, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
19
|
+
RouteContainer: ({ children, gap, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
20
|
+
RouteItem: ({ children, icon, iconBackgroundColor, title, subtitle, ...props }: {
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
icon?: React.ReactNode;
|
|
23
|
+
iconBackgroundColor?: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
subtitle?: string;
|
|
26
|
+
} & any) => import("react/jsx-runtime").JSX.Element | null;
|
|
27
|
+
Payment: ({ children, paddingX, paddingBottom, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
28
|
+
PaymentContainer: ({ children, backgroundColor, borderRadius, padding, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
29
|
+
PaymentContent: ({ children, ...props }: any) => import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
PaymentIconContainer: ({ children, width, height, backgroundColor, ...props }: any) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
PaymentDetails: ({ children, ...props }: any) => import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
Number: ({ children, color, fontWeight, fontSize, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
33
|
+
Type: ({ children, fontSize, color, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
34
|
+
TotalSection: ({ children, paddingX, paddingY, borderTop, borderColor, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
35
|
+
TotalContent: ({ children, ...props }: any) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
TotalLabel: ({ children, color, fontWeight, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
37
|
+
TotalAmount: ({ children, fontSize, fontWeight, color, ...props }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
38
|
+
};
|
|
39
|
+
export default Card;
|
|
40
|
+
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../src/components/card-ui/Card.tsx"],"names":[],"mappings":"AA6nBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAslB/B,QAAA,MAAM,IAAI;0DAAyD,GAAG;yDA/jBN,GAAG;8CAsBd,GAAG;4CAgBL,GAAG;uEAiBwB,GAAG;uEAiBH,GAAG;4CAkB9B,GAAG;iFAqBnD,GAAG;qEAoBsE,GAAG;iDAkBvB,GAAG;0DAeM,GAAG;wDAgBL,GAAG;0CAgBjB,GAAG;8IA2BjD,GAAG;mEA0EH,GAAG;6DAiB8D,GAAG;kDAgBd,GAAG;oFAuBzD;QACD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QAC3B,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,GAAG;+DA0C+D,GAAG;uFAsBtE,GAAG;6CAiB8C,GAAG;mFAcpD,GAAG;6CAgB8C,GAAG;kEAIkB,GAAG;oDAiBjB,GAAG;uFAwB3D,GAAG;2CAkB4C,GAAG;4DAQc,GAAG;uEAgBQ,GAAG;CAiChF,CAAC;AAgCF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultCard.d.ts","sourceRoot":"","sources":["../../../src/components/card-ui/DefaultCard.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EA8G/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export type TokenType = "color" | "string" | "dimension" | "font family" | "font weight" | "duration" | "number" | "cubic-bezier" | "spacer" | "shadow" | "transition" | "border" | "display" | "layout";
|
|
2
|
+
export type DesignToken = {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
type: TokenType;
|
|
6
|
+
unit: string | null;
|
|
7
|
+
comment: string;
|
|
8
|
+
category?: string;
|
|
9
|
+
deprecated?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type ComponentProperty = {
|
|
12
|
+
value: string;
|
|
13
|
+
unit: string | null;
|
|
14
|
+
type: TokenType;
|
|
15
|
+
comment: string;
|
|
16
|
+
resolvedValue?: string;
|
|
17
|
+
sourceToken?: string;
|
|
18
|
+
};
|
|
19
|
+
export type LinkedElement = {
|
|
20
|
+
htmlTag: string;
|
|
21
|
+
attributes: Record<string, string>;
|
|
22
|
+
requiredAttributes?: string[];
|
|
23
|
+
optionalAttributes?: string[];
|
|
24
|
+
attributeDescriptions?: Record<string, string>;
|
|
25
|
+
};
|
|
26
|
+
export type ComponentVariant = {
|
|
27
|
+
description?: string;
|
|
28
|
+
properties: Record<string, ComponentProperty>;
|
|
29
|
+
linkedElement?: Partial<LinkedElement>;
|
|
30
|
+
textContent?: string;
|
|
31
|
+
children?: Record<string, ComponentNode> | null;
|
|
32
|
+
states?: Record<string, Record<string, ComponentProperty>>;
|
|
33
|
+
};
|
|
34
|
+
export interface ComponentNode {
|
|
35
|
+
displayName?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
properties?: Record<string, ComponentProperty>;
|
|
38
|
+
children?: Record<string, ComponentNode> | null;
|
|
39
|
+
linkedElement?: LinkedElement;
|
|
40
|
+
textContent?: string;
|
|
41
|
+
variant?: string;
|
|
42
|
+
variants?: Record<string, ComponentVariant>;
|
|
43
|
+
states?: Record<string, Record<string, ComponentProperty>>;
|
|
44
|
+
}
|
|
45
|
+
export interface DesignSystemData {
|
|
46
|
+
metadata?: {
|
|
47
|
+
name?: string;
|
|
48
|
+
version?: string;
|
|
49
|
+
lastUpdated?: string;
|
|
50
|
+
};
|
|
51
|
+
variables: Record<string, DesignToken>;
|
|
52
|
+
components: Record<string, ComponentNode>;
|
|
53
|
+
custom?: CustomDesignSystemData;
|
|
54
|
+
}
|
|
55
|
+
export type SelectedItem = (DesignToken & {
|
|
56
|
+
key: string;
|
|
57
|
+
name: string;
|
|
58
|
+
displayValue: string;
|
|
59
|
+
}) | ({
|
|
60
|
+
component: string;
|
|
61
|
+
property: string;
|
|
62
|
+
displayValue: string;
|
|
63
|
+
} & ComponentProperty);
|
|
64
|
+
export type SelectedType = "variable" | "component_property" | "component" | null;
|
|
65
|
+
export type FilterType = "all" | "default" | "custom";
|
|
66
|
+
export interface CustomDesignSystemData {
|
|
67
|
+
variables: Record<string, DesignToken>;
|
|
68
|
+
components: Record<string, ComponentNode>;
|
|
69
|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