@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.
Files changed (42) hide show
  1. package/README.md +438 -0
  2. package/dist/components/DynamicComponentDebug.d.ts +3 -0
  3. package/dist/components/DynamicComponentDebug.d.ts.map +1 -0
  4. package/dist/components/DynamicComponents.d.ts +12 -0
  5. package/dist/components/DynamicComponents.d.ts.map +1 -0
  6. package/dist/components/card-ui/Card.d.ts +40 -0
  7. package/dist/components/card-ui/Card.d.ts.map +1 -0
  8. package/dist/components/card-ui/DefaultCard.d.ts +3 -0
  9. package/dist/components/card-ui/DefaultCard.d.ts.map +1 -0
  10. package/dist/components/index.d.ts +4 -0
  11. package/dist/components/index.d.ts.map +1 -0
  12. package/dist/data/index.d.ts +2 -0
  13. package/dist/data/index.d.ts.map +1 -0
  14. package/dist/data/mock.types.d.ts +70 -0
  15. package/dist/data/mock.types.d.ts.map +1 -0
  16. package/dist/hook/useCardData.d.ts +371 -0
  17. package/dist/hook/useCardData.d.ts.map +1 -0
  18. package/dist/hook/useComponent.d.ts +4 -0
  19. package/dist/hook/useComponent.d.ts.map +1 -0
  20. package/dist/hook/useComponents.d.ts +2 -0
  21. package/dist/hook/useComponents.d.ts.map +1 -0
  22. package/dist/hook/useDesignSystemSync.d.ts +1 -0
  23. package/dist/hook/useDesignSystemSync.d.ts.map +1 -0
  24. package/dist/hook/useDynamicComponents.d.ts +3 -0
  25. package/dist/hook/useDynamicComponents.d.ts.map +1 -0
  26. package/dist/index.d.ts +440 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.esm.js +3049 -0
  29. package/dist/index.esm.js.map +1 -0
  30. package/dist/index.js +3062 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/providers/StrataProvider.d.ts +60 -0
  33. package/dist/providers/StrataProvider.d.ts.map +1 -0
  34. package/dist/providers/index.d.ts +2 -0
  35. package/dist/providers/index.d.ts.map +1 -0
  36. package/dist/registry/ComponentFactory.d.ts +39 -0
  37. package/dist/registry/ComponentFactory.d.ts.map +1 -0
  38. package/dist/registry/ComponentRegistry.d.ts +29 -0
  39. package/dist/registry/ComponentRegistry.d.ts.map +1 -0
  40. package/dist/types/card-types.d.ts +185 -0
  41. package/dist/types/card-types.d.ts.map +1 -0
  42. package/package.json +74 -0
@@ -0,0 +1,440 @@
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ type TokenType = "color" | "string" | "dimension" | "font family" | "font weight" | "duration" | "number" | "cubic-bezier" | "spacer" | "shadow" | "transition" | "border" | "display" | "layout";
6
+ type DesignToken = {
7
+ name: string;
8
+ value: string;
9
+ type: TokenType;
10
+ unit: string | null;
11
+ comment: string;
12
+ category?: string;
13
+ deprecated?: boolean;
14
+ };
15
+ type ComponentProperty = {
16
+ value: string;
17
+ unit: string | null;
18
+ type: TokenType;
19
+ comment: string;
20
+ resolvedValue?: string;
21
+ sourceToken?: string;
22
+ };
23
+ type LinkedElement = {
24
+ htmlTag: string;
25
+ attributes: Record<string, string>;
26
+ requiredAttributes?: string[];
27
+ optionalAttributes?: string[];
28
+ attributeDescriptions?: Record<string, string>;
29
+ };
30
+ type ComponentVariant = {
31
+ description?: string;
32
+ properties: Record<string, ComponentProperty>;
33
+ linkedElement?: Partial<LinkedElement>;
34
+ textContent?: string;
35
+ children?: Record<string, ComponentNode> | null;
36
+ states?: Record<string, Record<string, ComponentProperty>>;
37
+ };
38
+ interface ComponentNode {
39
+ displayName?: string;
40
+ description?: string;
41
+ properties?: Record<string, ComponentProperty>;
42
+ children?: Record<string, ComponentNode> | null;
43
+ linkedElement?: LinkedElement;
44
+ textContent?: string;
45
+ variant?: string;
46
+ variants?: Record<string, ComponentVariant>;
47
+ states?: Record<string, Record<string, ComponentProperty>>;
48
+ }
49
+ interface DesignSystemData {
50
+ metadata?: {
51
+ name?: string;
52
+ version?: string;
53
+ lastUpdated?: string;
54
+ };
55
+ variables: Record<string, DesignToken>;
56
+ components: Record<string, ComponentNode>;
57
+ custom?: CustomDesignSystemData;
58
+ }
59
+ type SelectedItem = (DesignToken & {
60
+ key: string;
61
+ name: string;
62
+ displayValue: string;
63
+ }) | ({
64
+ component: string;
65
+ property: string;
66
+ displayValue: string;
67
+ } & ComponentProperty);
68
+ type SelectedType = "variable" | "component_property" | "component" | null;
69
+ type FilterType = "all" | "default" | "custom";
70
+ interface CustomDesignSystemData {
71
+ variables: Record<string, DesignToken>;
72
+ components: Record<string, ComponentNode>;
73
+ }
74
+
75
+ interface StrataContextType {
76
+ designSystem: DesignSystemData;
77
+ updateDesignSystem: (newData: DesignSystemData) => void;
78
+ syncStatus: "idle" | "syncing" | "success" | "error";
79
+ lastSynced: Date | null;
80
+ forceSync: () => Promise<void>;
81
+ syncVersion: number;
82
+ syncUrl: string;
83
+ syncEnabled: boolean;
84
+ syncInterval: number;
85
+ syncToken: string | undefined;
86
+ snapshotCdnBase: string | undefined;
87
+ projectId: string | undefined;
88
+ }
89
+ declare const useStrata: () => StrataContextType;
90
+ interface StrataProviderProps {
91
+ children: React__default.ReactNode;
92
+ initialData?: DesignSystemData;
93
+ userDesignSystem?: DesignSystemData;
94
+ syncEnabled?: boolean;
95
+ syncUrl?: string;
96
+ syncInterval?: number;
97
+ /**
98
+ * Sync token generated from the Strata project dashboard (e.g. "pt_live_xxxxxxxx").
99
+ * When provided, all sync fetches include an Authorization: Bearer header so the
100
+ * project does not need to be fully public — the token acts as the access credential.
101
+ */
102
+ syncToken?: string;
103
+ /**
104
+ * Base CDN URL where snapshot files are served.
105
+ * E.g. "https://cdn.strata.charisol.io"
106
+ * When set together with `projectId`, the provider fetches
107
+ * `${snapshotCdnBase}/snapshots/${projectId}/strata.json`
108
+ * in a single request instead of 3 API calls.
109
+ * Takes precedence over `syncUrl` when both are provided.
110
+ */
111
+ snapshotCdnBase?: string;
112
+ /**
113
+ * Your Strata project ID (shown in the dashboard URL and project settings).
114
+ * Required when using `snapshotCdnBase`.
115
+ */
116
+ projectId?: string;
117
+ /**
118
+ * Callback invoked when a sync cycle fails. Receives a structured error object
119
+ * containing an HTTP status `code` (0 for non-HTTP errors), a human-readable
120
+ * `message`, and a `source` indicating where the failure originated
121
+ * (`"cdn"` or `"sync"`).
122
+ */
123
+ onSyncError?: (error: {
124
+ code: number;
125
+ message: string;
126
+ source: string;
127
+ }) => void;
128
+ onSyncSuccess?: (data: DesignSystemData) => void;
129
+ }
130
+ declare const StrataProvider: React__default.FC<StrataProviderProps>;
131
+
132
+ declare const DefaultCard: React__default.FC;
133
+
134
+ declare const Card: {
135
+ ({ children, width, maxWidth, fontFamily, ...props }: any): react_jsx_runtime.JSX.Element | null;
136
+ Container: ({ children, width, maxWidth, ...props }: any) => react_jsx_runtime.JSX.Element | null;
137
+ Header: ({ children, padding, ...props }: any) => react_jsx_runtime.JSX.Element | null;
138
+ HeaderContent: ({ children, ...props }: any) => react_jsx_runtime.JSX.Element | null;
139
+ HeaderTitle: ({ children, fontSize, fontWeight, color, ...props }: any) => react_jsx_runtime.JSX.Element | null;
140
+ HeaderTimer: ({ children, fontSize, fontFamily, color, ...props }: any) => react_jsx_runtime.JSX.Element | null;
141
+ Body: ({ children, padding, ...props }: any) => react_jsx_runtime.JSX.Element | null;
142
+ BodyDriver: ({ children, backgroundColor, borderRadius, padding, ...props }: any) => react_jsx_runtime.JSX.Element | null;
143
+ BodyImage: ({ src, alt, width, height, borderRadius, ...props }: any) => react_jsx_runtime.JSX.Element | null;
144
+ BodyInfo: ({ children, flexGrow, ...props }: any) => react_jsx_runtime.JSX.Element | null;
145
+ BodyName: ({ children, fontWeight, color, ...props }: any) => react_jsx_runtime.JSX.Element | null;
146
+ BodySpan: ({ children, fontSize, color, ...props }: any) => react_jsx_runtime.JSX.Element | null;
147
+ BodyActions: ({ children, ...props }: any) => react_jsx_runtime.JSX.Element | null;
148
+ BodyActionButton: ({ children, variant, backgroundColor, color, hoverBackgroundColor, border, padding, borderRadius, onClick, ...props }: any) => react_jsx_runtime.JSX.Element | null;
149
+ BodyActionIcon: ({ children, width, height, color, ...props }: any) => react_jsx_runtime.JSX.Element;
150
+ Route: ({ children, paddingX, paddingBottom, ...props }: any) => react_jsx_runtime.JSX.Element | null;
151
+ RouteContainer: ({ children, gap, ...props }: any) => react_jsx_runtime.JSX.Element | null;
152
+ RouteItem: ({ children, icon, iconBackgroundColor, title, subtitle, ...props }: {
153
+ children?: React.ReactNode;
154
+ icon?: React.ReactNode;
155
+ iconBackgroundColor?: string;
156
+ title?: string;
157
+ subtitle?: string;
158
+ } & any) => react_jsx_runtime.JSX.Element | null;
159
+ Payment: ({ children, paddingX, paddingBottom, ...props }: any) => react_jsx_runtime.JSX.Element | null;
160
+ PaymentContainer: ({ children, backgroundColor, borderRadius, padding, ...props }: any) => react_jsx_runtime.JSX.Element | null;
161
+ PaymentContent: ({ children, ...props }: any) => react_jsx_runtime.JSX.Element;
162
+ PaymentIconContainer: ({ children, width, height, backgroundColor, ...props }: any) => react_jsx_runtime.JSX.Element;
163
+ PaymentDetails: ({ children, ...props }: any) => react_jsx_runtime.JSX.Element;
164
+ Number: ({ children, color, fontWeight, fontSize, ...props }: any) => react_jsx_runtime.JSX.Element | null;
165
+ Type: ({ children, fontSize, color, ...props }: any) => react_jsx_runtime.JSX.Element | null;
166
+ TotalSection: ({ children, paddingX, paddingY, borderTop, borderColor, ...props }: any) => react_jsx_runtime.JSX.Element | null;
167
+ TotalContent: ({ children, ...props }: any) => react_jsx_runtime.JSX.Element;
168
+ TotalLabel: ({ children, color, fontWeight, ...props }: any) => react_jsx_runtime.JSX.Element | null;
169
+ TotalAmount: ({ children, fontSize, fontWeight, color, ...props }: any) => react_jsx_runtime.JSX.Element | null;
170
+ };
171
+
172
+ declare const StrataDebug: React__default.FC;
173
+
174
+ interface CardProps {
175
+ children?: React__default.ReactNode;
176
+ width?: string;
177
+ maxWidth?: string;
178
+ backgroundColor?: string;
179
+ fontFamily?: string;
180
+ }
181
+ interface CardContainerProps {
182
+ children?: React__default.ReactNode;
183
+ width?: string;
184
+ maxWidth?: string;
185
+ }
186
+ interface CardHeaderProps {
187
+ children?: React__default.ReactNode;
188
+ padding?: string | number;
189
+ }
190
+ interface CardHeaderContentProps {
191
+ children?: React__default.ReactNode;
192
+ }
193
+ interface CardHeaderTitleProps {
194
+ children?: React__default.ReactNode;
195
+ fontSize?: string;
196
+ fontWeight?: string;
197
+ color?: string;
198
+ }
199
+ interface CardHeaderTimerProps {
200
+ children?: React__default.ReactNode;
201
+ fontSize?: string;
202
+ fontFamily?: string;
203
+ color?: string;
204
+ }
205
+ interface CardBodyProps {
206
+ children?: React__default.ReactNode;
207
+ padding?: string | number;
208
+ }
209
+ interface CardBodyDriverProps {
210
+ children?: React__default.ReactNode;
211
+ backgroundColor?: string;
212
+ borderRadius?: string;
213
+ padding?: string | number;
214
+ }
215
+ interface CardBodyImageProps {
216
+ src?: string;
217
+ alt?: string;
218
+ width?: string | number;
219
+ height?: string | number;
220
+ borderRadius?: string;
221
+ }
222
+ interface CardBodyInfoProps {
223
+ children?: React__default.ReactNode;
224
+ flexGrow?: number;
225
+ }
226
+ interface CardBodyNameProps {
227
+ children?: React__default.ReactNode;
228
+ fontWeight?: string;
229
+ color?: string;
230
+ }
231
+ interface CardBodySpanProps {
232
+ children?: React__default.ReactNode;
233
+ fontSize?: string;
234
+ color?: string;
235
+ }
236
+ interface CardBodyActionsProps {
237
+ children?: React__default.ReactNode;
238
+ }
239
+ interface CardBodyActionButtonProps {
240
+ children?: React__default.ReactNode;
241
+ padding?: string | number;
242
+ borderRadius?: string;
243
+ border?: string;
244
+ borderColor?: string;
245
+ backgroundColor?: string;
246
+ hoverBackgroundColor?: string;
247
+ transition?: string;
248
+ onClick?: () => void;
249
+ }
250
+ interface CardBodyActionIconProps {
251
+ children?: React__default.ReactNode;
252
+ width?: string | number;
253
+ height?: string | number;
254
+ color?: string;
255
+ }
256
+ interface CardRouteProps {
257
+ children?: React__default.ReactNode;
258
+ paddingX?: string | number;
259
+ paddingBottom?: string | number;
260
+ }
261
+ interface CardRouteContainerProps {
262
+ children?: React__default.ReactNode;
263
+ gap?: string | number;
264
+ }
265
+ interface CardRouteItemProps {
266
+ children?: React__default.ReactNode;
267
+ icon?: React__default.ReactNode;
268
+ iconBackgroundColor?: string;
269
+ title?: string;
270
+ subtitle?: string;
271
+ }
272
+ interface CardPaymentProps {
273
+ children?: React__default.ReactNode;
274
+ paddingX?: string | number;
275
+ paddingBottom?: string | number;
276
+ }
277
+ interface CardPaymentContainerProps {
278
+ children?: React__default.ReactNode;
279
+ backgroundColor?: string;
280
+ borderRadius?: string;
281
+ padding?: string | number;
282
+ }
283
+ interface CardPaymentContentProps {
284
+ children?: React__default.ReactNode;
285
+ }
286
+ interface CardPaymentIconContainerProps {
287
+ children?: React__default.ReactNode;
288
+ width?: string | number;
289
+ height?: string | number;
290
+ backgroundColor?: string;
291
+ }
292
+ interface CardPaymentDetailsProps {
293
+ children?: React__default.ReactNode;
294
+ }
295
+ interface CardNumberProps {
296
+ children?: React__default.ReactNode;
297
+ color?: string;
298
+ fontWeight?: string;
299
+ fontSize?: string;
300
+ }
301
+ interface CardTypeProps {
302
+ children?: React__default.ReactNode;
303
+ fontSize?: string;
304
+ color?: string;
305
+ }
306
+ interface CardTotalSectionProps {
307
+ children?: React__default.ReactNode;
308
+ paddingX?: string | number;
309
+ paddingY?: string | number;
310
+ borderTop?: string;
311
+ borderColor?: string;
312
+ }
313
+ interface CardTotalContentProps {
314
+ children?: React__default.ReactNode;
315
+ }
316
+ interface CardTotalLabelProps {
317
+ children?: React__default.ReactNode;
318
+ color?: string;
319
+ fontWeight?: string;
320
+ }
321
+ interface CardTotalAmountProps {
322
+ children?: React__default.ReactNode;
323
+ fontSize?: string;
324
+ fontWeight?: string;
325
+ color?: string;
326
+ }
327
+ interface CardComponent extends React__default.FC<CardProps> {
328
+ Container: React__default.FC<CardContainerProps>;
329
+ Header: React__default.FC<CardHeaderProps>;
330
+ HeaderContent: React__default.FC<CardHeaderContentProps>;
331
+ HeaderTitle: React__default.FC<CardHeaderTitleProps>;
332
+ HeaderTimer: React__default.FC<CardHeaderTimerProps>;
333
+ Body: React__default.FC<CardBodyProps>;
334
+ BodyDriver: React__default.FC<CardBodyDriverProps>;
335
+ BodyImage: React__default.FC<CardBodyImageProps>;
336
+ BodyInfo: React__default.FC<CardBodyInfoProps>;
337
+ BodyName: React__default.FC<CardBodyNameProps>;
338
+ BodySpan: React__default.FC<CardBodySpanProps>;
339
+ BodyActions: React__default.FC<CardBodyActionsProps>;
340
+ BodyActionButton: React__default.FC<CardBodyActionButtonProps>;
341
+ BodyActionIcon: React__default.FC<CardBodyActionIconProps>;
342
+ Route: React__default.FC<CardRouteProps>;
343
+ RouteContainer: React__default.FC<CardRouteContainerProps>;
344
+ RouteItem: React__default.FC<CardRouteItemProps>;
345
+ Payment: React__default.FC<CardPaymentProps>;
346
+ PaymentContainer: React__default.FC<CardPaymentContainerProps>;
347
+ PaymentContent: React__default.FC<CardPaymentContentProps>;
348
+ PaymentIconContainer: React__default.FC<CardPaymentIconContainerProps>;
349
+ PaymentDetails: React__default.FC<CardPaymentDetailsProps>;
350
+ Number: React__default.FC<CardNumberProps>;
351
+ Type: React__default.FC<CardTypeProps>;
352
+ TotalSection: React__default.FC<CardTotalSectionProps>;
353
+ TotalContent: React__default.FC<CardTotalContentProps>;
354
+ TotalLabel: React__default.FC<CardTotalLabelProps>;
355
+ TotalAmount: React__default.FC<CardTotalAmountProps>;
356
+ }
357
+
358
+ interface DynamicComponentProps {
359
+ children?: React__default.ReactNode;
360
+ style?: React__default.CSSProperties;
361
+ className?: string;
362
+ [key: string]: any;
363
+ }
364
+ declare class StrataComponentFactory {
365
+ static createComponent(componentName: string, componentData: ComponentNode, designSystem: DesignSystemData): React__default.ComponentType<DynamicComponentProps>;
366
+ static createSubComponent(componentName: string, componentData: ComponentNode, designSystem: DesignSystemData): React__default.ComponentType<DynamicComponentProps>;
367
+ private static processAllAttributes;
368
+ private static resolveAttributesWithVariables;
369
+ private static resolveCssVariables;
370
+ private static processHtmlAttributes;
371
+ private static processInputAttributes;
372
+ private static processButtonAttributes;
373
+ private static processImageAttributes;
374
+ private static processLinkAttributes;
375
+ private static processTextareaAttributes;
376
+ private static processVideoAttributes;
377
+ private static processAudioAttributes;
378
+ private static processFormAttributes;
379
+ private static processSelectAttributes;
380
+ private static processSvgAttributes;
381
+ private static processCanvasAttributes;
382
+ private static mergeClassNames;
383
+ private static cleanAttributes;
384
+ private static determineHtmlTag;
385
+ private static resolveComponentStyles;
386
+ private static kebabToCamelCase;
387
+ private static camelToKebabCase;
388
+ static validateComponent(componentData: ComponentNode): {
389
+ isValid: boolean;
390
+ errors: string[];
391
+ };
392
+ static createDebugComponent(componentName: string, componentData: ComponentNode, designSystem: DesignSystemData): React__default.ComponentType<DynamicComponentProps>;
393
+ }
394
+
395
+ interface ComponentRegistry {
396
+ [componentName: string]: React__default.ComponentType<DynamicComponentProps> & {
397
+ [subComponentName: string]: React__default.ComponentType<DynamicComponentProps>;
398
+ };
399
+ }
400
+ declare class ComponentRegistryService {
401
+ private registry;
402
+ private listeners;
403
+ private originalToPascalMap;
404
+ private formatComponentName;
405
+ testPascalCaseConversion(): void;
406
+ registerComponent(componentName: string, componentData: ComponentNode, designSystem: DesignSystemData): void;
407
+ private addNestedComponents;
408
+ getRegistry(): ComponentRegistry;
409
+ getComponentMapping(): Map<string, string>;
410
+ hasComponent(componentName: string): boolean;
411
+ getComponent(componentName: string): React__default.ComponentType<DynamicComponentProps> | null;
412
+ syncWithDesignSystem(designSystem: DesignSystemData): void;
413
+ subscribe(listener: (registry: ComponentRegistry) => void): () => void;
414
+ private notifyListeners;
415
+ clear(): void;
416
+ getPascalCaseName(originalName: string): string;
417
+ }
418
+ declare const strataRegistry: ComponentRegistryService;
419
+
420
+ declare const useDynamicComponents: () => ComponentRegistry;
421
+
422
+ declare const useComponents: () => ComponentRegistry;
423
+
424
+ declare const useComponent: (componentName: string) => (React.ComponentType<DynamicComponentProps> & {
425
+ [subComponentName: string]: React.ComponentType<DynamicComponentProps>;
426
+ }) | null;
427
+
428
+ declare const DynamicComponent: React__default.FC<{
429
+ name: string;
430
+ children?: React__default.ReactNode;
431
+ [key: string]: any;
432
+ }>;
433
+ declare const AutoForm: React__default.FC<{
434
+ formName?: string;
435
+ children?: React__default.ReactNode;
436
+ [key: string]: any;
437
+ }>;
438
+
439
+ export { AutoForm, Card, DefaultCard, DynamicComponent, StrataComponentFactory, StrataDebug, StrataProvider, strataRegistry, useComponent, useComponents, useDynamicComponents, useStrata };
440
+ export type { CardComponent, CardProps, ComponentNode, ComponentProperty, ComponentVariant, CustomDesignSystemData, DesignSystemData, DesignToken, FilterType, LinkedElement, SelectedItem, SelectedType, TokenType };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACnE,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC"}