@stackable-labs/sdk-extension-react 1.22.0 → 1.22.2

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/dist/index.d.ts CHANGED
@@ -1,7 +1,493 @@
1
- export { createExtension } from './createExtension';
2
- export { createStore } from './store';
3
- export { useSurfaceContext, useCapabilities, useStore, useExtension, } from './hooks';
4
- export type { Store } from './store';
5
- export { Surface } from './Surface';
6
- export * as ui from './ui';
7
- export { useContextData } from './useContextData';
1
+ import React from 'react';
2
+ import { ApiRequest, FetchRequestInit, FetchResponse, ToastPayload, ContextData, AllowedIconName } from '@stackable-labs/sdk-extension-contracts';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ /**
6
+ * createExtension bootstraps the extension runtime in the iframe sandbox.
7
+ * Sets up Remote DOM, RPC listener, and renders the extension's React tree.
8
+ */
9
+
10
+ interface CreateExtensionOptions {
11
+ extensionId?: string;
12
+ }
13
+ /**
14
+ * Bootstrap an extension. Call this as the entry point of your extension bundle.
15
+ *
16
+ * @example
17
+ * export default createExtension(() => (
18
+ * <>
19
+ * <Surface id="slot.header"><Header /></Surface>
20
+ * <Surface id="slot.content"><Content /></Surface>
21
+ * </>
22
+ * ));
23
+ */
24
+ declare const createExtension: (factory: () => React.ReactElement, options?: CreateExtensionOptions) => void;
25
+
26
+ /**
27
+ * Shared Store — cross-surface state coordination.
28
+ * All surfaces in the same extension runtime share a store instance.
29
+ */
30
+ type Listener<T> = (state: T) => void;
31
+ interface Store<T> {
32
+ get(): T;
33
+ set(partial: Partial<T>): void;
34
+ subscribe(listener: Listener<T>): () => void;
35
+ }
36
+ /**
37
+ * Create a shared store for cross-surface coordination.
38
+ *
39
+ * @example
40
+ * const store = createStore({ mode: 'account', selectedId: null });
41
+ * store.set({ mode: 'conversations' });
42
+ * store.subscribe((state) => console.log(state));
43
+ */
44
+ declare const createStore: <T extends object>(initialState: T) => Store<T>;
45
+
46
+ /** Context for extension-level data (provided by createExtension) */
47
+ interface ExtensionContextValue {
48
+ extensionId: string;
49
+ }
50
+
51
+ /**
52
+ * Read the host-provided context for the current surface.
53
+ */
54
+ declare const useSurfaceContext: () => Record<string, unknown>;
55
+ /**
56
+ * Access host-mediated capabilities (data, actions, context).
57
+ */
58
+ declare const useCapabilities: () => {
59
+ data: {
60
+ query: <T = unknown>(payload: ApiRequest) => Promise<T>;
61
+ fetch: (url: string, init?: FetchRequestInit) => Promise<FetchResponse>;
62
+ };
63
+ actions: {
64
+ toast: (payload: ToastPayload) => Promise<void>;
65
+ invoke: <T = unknown>(action: string, payload?: Record<string, unknown>) => Promise<T>;
66
+ };
67
+ context: {
68
+ read: () => Promise<ContextData>;
69
+ };
70
+ };
71
+ /**
72
+ * Subscribe to a shared store with an optional selector.
73
+ */
74
+ declare const useStore: <T, S = T>(store: Store<T>, selector?: (state: T) => S) => S;
75
+ /**
76
+ * Access the extension-level context (extension ID, manifest, etc.)
77
+ */
78
+ declare const useExtension: () => ExtensionContextValue;
79
+
80
+ interface SurfaceProps {
81
+ /** The extension point target ID (e.g., "slot.header") */
82
+ id: string;
83
+ children: React.ReactNode;
84
+ }
85
+ declare const Surface: ({ id, children }: SurfaceProps) => react_jsx_runtime.JSX.Element;
86
+
87
+ type RemoteInputChangeEvent = {
88
+ target: {
89
+ value: string;
90
+ };
91
+ };
92
+ declare const Card: (props: {
93
+ className?: string;
94
+ onClick?: () => void;
95
+ children?: React.ReactNode;
96
+ }) => react_jsx_runtime.JSX.Element;
97
+ declare const CardContent: (props: {
98
+ className?: string;
99
+ children?: React.ReactNode;
100
+ }) => react_jsx_runtime.JSX.Element;
101
+ declare const CardHeader: (props: {
102
+ className?: string;
103
+ children?: React.ReactNode;
104
+ }) => react_jsx_runtime.JSX.Element;
105
+ declare const Stack: (props: {
106
+ gap?: string;
107
+ direction?: "row" | "column";
108
+ align?: string;
109
+ className?: string;
110
+ children?: React.ReactNode;
111
+ }) => react_jsx_runtime.JSX.Element;
112
+ declare const Inline: (props: {
113
+ gap?: string;
114
+ align?: string;
115
+ className?: string;
116
+ children?: React.ReactNode;
117
+ }) => react_jsx_runtime.JSX.Element;
118
+ declare const Text: (props: {
119
+ className?: string;
120
+ tone?: string;
121
+ children?: React.ReactNode;
122
+ }) => react_jsx_runtime.JSX.Element;
123
+ declare const Heading: (props: {
124
+ level?: "1" | "2" | "3" | "4" | "5" | "6";
125
+ className?: string;
126
+ children?: React.ReactNode;
127
+ }) => react_jsx_runtime.JSX.Element;
128
+ declare const Badge: (props: {
129
+ variant?: string;
130
+ tone?: string;
131
+ className?: string;
132
+ children?: React.ReactNode;
133
+ }) => react_jsx_runtime.JSX.Element;
134
+ declare const Button: (props: {
135
+ variant?: string;
136
+ size?: string;
137
+ disabled?: boolean;
138
+ onClick?: () => void;
139
+ type?: string;
140
+ className?: string;
141
+ title?: string;
142
+ children?: React.ReactNode;
143
+ }) => react_jsx_runtime.JSX.Element;
144
+ declare const Input: (props: {
145
+ type?: string;
146
+ placeholder?: string;
147
+ value?: string;
148
+ onChange?: (e: RemoteInputChangeEvent) => void;
149
+ disabled?: boolean;
150
+ className?: string;
151
+ id?: string;
152
+ }) => react_jsx_runtime.JSX.Element;
153
+ declare const Textarea: (props: {
154
+ placeholder?: string;
155
+ value?: string;
156
+ onChange?: (e: RemoteInputChangeEvent) => void;
157
+ disabled?: boolean;
158
+ rows?: string;
159
+ className?: string;
160
+ id?: string;
161
+ }) => react_jsx_runtime.JSX.Element;
162
+ declare const Select: (props: {
163
+ value?: string;
164
+ defaultValue?: string;
165
+ onChange?: (e: RemoteInputChangeEvent) => void;
166
+ placeholder?: string;
167
+ disabled?: boolean;
168
+ className?: string;
169
+ children?: React.ReactNode;
170
+ }) => react_jsx_runtime.JSX.Element;
171
+ declare const SelectOption: (props: {
172
+ value: string;
173
+ disabled?: boolean;
174
+ className?: string;
175
+ children?: React.ReactNode;
176
+ }) => react_jsx_runtime.JSX.Element;
177
+ declare const Checkbox: (props: {
178
+ checked?: boolean;
179
+ onChange?: (e: RemoteInputChangeEvent) => void;
180
+ disabled?: boolean;
181
+ className?: string;
182
+ id?: string;
183
+ }) => react_jsx_runtime.JSX.Element;
184
+ declare const Switch: (props: {
185
+ checked?: boolean;
186
+ onChange?: (e: RemoteInputChangeEvent) => void;
187
+ disabled?: boolean;
188
+ size?: string;
189
+ className?: string;
190
+ id?: string;
191
+ }) => react_jsx_runtime.JSX.Element;
192
+ declare const Label: (props: {
193
+ htmlFor?: string;
194
+ className?: string;
195
+ children?: React.ReactNode;
196
+ }) => react_jsx_runtime.JSX.Element;
197
+ declare const RadioGroup: (props: {
198
+ value?: string;
199
+ defaultValue?: string;
200
+ onChange?: (e: RemoteInputChangeEvent) => void;
201
+ className?: string;
202
+ children?: React.ReactNode;
203
+ }) => react_jsx_runtime.JSX.Element;
204
+ declare const RadioGroupItem: (props: {
205
+ value: string;
206
+ disabled?: boolean;
207
+ className?: string;
208
+ id?: string;
209
+ }) => react_jsx_runtime.JSX.Element;
210
+ declare const Separator: (props: {
211
+ className?: string;
212
+ }) => react_jsx_runtime.JSX.Element;
213
+ declare const Tabs: (props: {
214
+ defaultValue?: string;
215
+ className?: string;
216
+ children?: React.ReactNode;
217
+ }) => react_jsx_runtime.JSX.Element;
218
+ declare const TabsList: (props: {
219
+ className?: string;
220
+ children?: React.ReactNode;
221
+ }) => react_jsx_runtime.JSX.Element;
222
+ declare const TabsTrigger: (props: {
223
+ value: string;
224
+ className?: string;
225
+ children?: React.ReactNode;
226
+ }) => react_jsx_runtime.JSX.Element;
227
+ declare const TabsContent: (props: {
228
+ value: string;
229
+ className?: string;
230
+ children?: React.ReactNode;
231
+ }) => react_jsx_runtime.JSX.Element;
232
+ declare const ScrollArea: (props: {
233
+ className?: string;
234
+ children?: React.ReactNode;
235
+ }) => react_jsx_runtime.JSX.Element;
236
+ declare const Skeleton: (props: {
237
+ width?: string;
238
+ height?: string;
239
+ className?: string;
240
+ }) => react_jsx_runtime.JSX.Element;
241
+ declare const Tooltip: (props: {
242
+ content: string;
243
+ className?: string;
244
+ children?: React.ReactNode;
245
+ }) => react_jsx_runtime.JSX.Element;
246
+ declare const Progress: (props: {
247
+ value?: string;
248
+ className?: string;
249
+ }) => react_jsx_runtime.JSX.Element;
250
+ declare const Alert: (props: {
251
+ variant?: string;
252
+ title?: string;
253
+ className?: string;
254
+ children?: React.ReactNode;
255
+ }) => react_jsx_runtime.JSX.Element;
256
+ declare const Collapsible: (props: {
257
+ defaultOpen?: boolean;
258
+ className?: string;
259
+ children?: React.ReactNode;
260
+ }) => react_jsx_runtime.JSX.Element;
261
+ declare const CollapsibleTrigger: (props: {
262
+ className?: string;
263
+ children?: React.ReactNode;
264
+ }) => react_jsx_runtime.JSX.Element;
265
+ declare const CollapsibleContent: (props: {
266
+ className?: string;
267
+ children?: React.ReactNode;
268
+ }) => react_jsx_runtime.JSX.Element;
269
+ declare const Avatar: (props: {
270
+ src?: string;
271
+ alt?: string;
272
+ className?: string;
273
+ }) => react_jsx_runtime.JSX.Element;
274
+ declare const Icon: (props: {
275
+ name: AllowedIconName;
276
+ size?: string;
277
+ className?: string;
278
+ }) => react_jsx_runtime.JSX.Element;
279
+ declare const Link: (props: {
280
+ href?: string;
281
+ target?: string;
282
+ rel?: string;
283
+ className?: string;
284
+ children?: React.ReactNode;
285
+ }) => react_jsx_runtime.JSX.Element;
286
+ declare const FooterLink: (props: {
287
+ href?: string;
288
+ children?: React.ReactNode;
289
+ }) => react_jsx_runtime.JSX.Element;
290
+ declare const Menu: (props: {
291
+ title?: string;
292
+ className?: string;
293
+ children?: React.ReactNode;
294
+ }) => react_jsx_runtime.JSX.Element;
295
+ declare const MenuItem: (props: {
296
+ icon?: AllowedIconName;
297
+ label: string;
298
+ description?: string;
299
+ onClick?: () => void;
300
+ className?: string;
301
+ }) => react_jsx_runtime.JSX.Element;
302
+ declare global {
303
+ namespace JSX {
304
+ interface IntrinsicElements {
305
+ 'ui-card': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
306
+ 'ui-card-content': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
307
+ 'ui-card-header': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
308
+ 'ui-button': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
309
+ variant?: string;
310
+ size?: string;
311
+ disabled?: boolean;
312
+ type?: string;
313
+ title?: string;
314
+ }, HTMLElement>;
315
+ 'ui-text': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
316
+ tone?: string;
317
+ }, HTMLElement>;
318
+ 'ui-heading': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
319
+ level?: string;
320
+ }, HTMLElement>;
321
+ 'ui-badge': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
322
+ variant?: string;
323
+ tone?: string;
324
+ }, HTMLElement>;
325
+ 'ui-input': Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> & {
326
+ type?: string;
327
+ placeholder?: string;
328
+ value?: string;
329
+ onChange?: (e: RemoteInputChangeEvent) => void;
330
+ disabled?: boolean;
331
+ id?: string;
332
+ };
333
+ 'ui-textarea': Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> & {
334
+ placeholder?: string;
335
+ value?: string;
336
+ onChange?: (e: RemoteInputChangeEvent) => void;
337
+ disabled?: boolean;
338
+ rows?: string;
339
+ id?: string;
340
+ };
341
+ 'ui-select': Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> & {
342
+ value?: string;
343
+ defaultValue?: string;
344
+ onChange?: (e: RemoteInputChangeEvent) => void;
345
+ placeholder?: string;
346
+ disabled?: boolean;
347
+ };
348
+ 'ui-select-option': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
349
+ value?: string;
350
+ disabled?: boolean;
351
+ }, HTMLElement>;
352
+ 'ui-checkbox': Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> & {
353
+ checked?: boolean;
354
+ onChange?: (e: RemoteInputChangeEvent) => void;
355
+ disabled?: boolean;
356
+ id?: string;
357
+ };
358
+ 'ui-switch': Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> & {
359
+ checked?: boolean;
360
+ onChange?: (e: RemoteInputChangeEvent) => void;
361
+ disabled?: boolean;
362
+ size?: string;
363
+ id?: string;
364
+ };
365
+ 'ui-label': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
366
+ htmlFor?: string;
367
+ }, HTMLElement>;
368
+ 'ui-radio-group': Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> & {
369
+ value?: string;
370
+ defaultValue?: string;
371
+ onChange?: (e: RemoteInputChangeEvent) => void;
372
+ };
373
+ 'ui-radio-group-item': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
374
+ value?: string;
375
+ disabled?: boolean;
376
+ id?: string;
377
+ }, HTMLElement>;
378
+ 'ui-stack': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
379
+ gap?: string;
380
+ direction?: string;
381
+ align?: string;
382
+ }, HTMLElement>;
383
+ 'ui-inline': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
384
+ gap?: string;
385
+ align?: string;
386
+ }, HTMLElement>;
387
+ 'ui-separator': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
388
+ 'ui-tabs': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
389
+ defaultValue?: string;
390
+ }, HTMLElement>;
391
+ 'ui-tabs-list': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
392
+ 'ui-tabs-trigger': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
393
+ value?: string;
394
+ }, HTMLElement>;
395
+ 'ui-tabs-content': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
396
+ value?: string;
397
+ }, HTMLElement>;
398
+ 'ui-scroll-area': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
399
+ 'ui-avatar': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
400
+ src?: string;
401
+ alt?: string;
402
+ }, HTMLElement>;
403
+ 'ui-icon': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
404
+ name?: string;
405
+ size?: string;
406
+ }, HTMLElement>;
407
+ 'ui-link': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
408
+ href?: string;
409
+ target?: string;
410
+ rel?: string;
411
+ }, HTMLElement>;
412
+ 'ui-menu-item': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
413
+ icon?: string;
414
+ label?: string;
415
+ description?: string;
416
+ }, HTMLElement>;
417
+ 'ui-menu': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
418
+ title?: string;
419
+ }, HTMLElement>;
420
+ 'ui-skeleton': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
421
+ width?: string;
422
+ height?: string;
423
+ }, HTMLElement>;
424
+ 'ui-tooltip': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
425
+ content?: string;
426
+ }, HTMLElement>;
427
+ 'ui-progress': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
428
+ value?: string;
429
+ }, HTMLElement>;
430
+ 'ui-alert': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
431
+ variant?: string;
432
+ title?: string;
433
+ }, HTMLElement>;
434
+ 'ui-collapsible': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
435
+ defaultOpen?: boolean;
436
+ }, HTMLElement>;
437
+ 'ui-collapsible-trigger': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
438
+ 'ui-collapsible-content': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
439
+ }
440
+ }
441
+ }
442
+
443
+ declare const ui_Alert: typeof Alert;
444
+ declare const ui_Avatar: typeof Avatar;
445
+ declare const ui_Badge: typeof Badge;
446
+ declare const ui_Button: typeof Button;
447
+ declare const ui_Card: typeof Card;
448
+ declare const ui_CardContent: typeof CardContent;
449
+ declare const ui_CardHeader: typeof CardHeader;
450
+ declare const ui_Checkbox: typeof Checkbox;
451
+ declare const ui_Collapsible: typeof Collapsible;
452
+ declare const ui_CollapsibleContent: typeof CollapsibleContent;
453
+ declare const ui_CollapsibleTrigger: typeof CollapsibleTrigger;
454
+ declare const ui_FooterLink: typeof FooterLink;
455
+ declare const ui_Heading: typeof Heading;
456
+ declare const ui_Icon: typeof Icon;
457
+ declare const ui_Inline: typeof Inline;
458
+ declare const ui_Input: typeof Input;
459
+ declare const ui_Label: typeof Label;
460
+ declare const ui_Link: typeof Link;
461
+ declare const ui_Menu: typeof Menu;
462
+ declare const ui_MenuItem: typeof MenuItem;
463
+ declare const ui_Progress: typeof Progress;
464
+ declare const ui_RadioGroup: typeof RadioGroup;
465
+ declare const ui_RadioGroupItem: typeof RadioGroupItem;
466
+ declare const ui_ScrollArea: typeof ScrollArea;
467
+ declare const ui_Select: typeof Select;
468
+ declare const ui_SelectOption: typeof SelectOption;
469
+ declare const ui_Separator: typeof Separator;
470
+ declare const ui_Skeleton: typeof Skeleton;
471
+ declare const ui_Stack: typeof Stack;
472
+ declare const ui_Switch: typeof Switch;
473
+ declare const ui_Tabs: typeof Tabs;
474
+ declare const ui_TabsContent: typeof TabsContent;
475
+ declare const ui_TabsList: typeof TabsList;
476
+ declare const ui_TabsTrigger: typeof TabsTrigger;
477
+ declare const ui_Text: typeof Text;
478
+ declare const ui_Textarea: typeof Textarea;
479
+ declare const ui_Tooltip: typeof Tooltip;
480
+ declare namespace ui {
481
+ export { ui_Alert as Alert, ui_Avatar as Avatar, ui_Badge as Badge, ui_Button as Button, ui_Card as Card, ui_CardContent as CardContent, ui_CardHeader as CardHeader, ui_Checkbox as Checkbox, ui_Collapsible as Collapsible, ui_CollapsibleContent as CollapsibleContent, ui_CollapsibleTrigger as CollapsibleTrigger, ui_FooterLink as FooterLink, ui_Heading as Heading, ui_Icon as Icon, ui_Inline as Inline, ui_Input as Input, ui_Label as Label, ui_Link as Link, ui_Menu as Menu, ui_MenuItem as MenuItem, ui_Progress as Progress, ui_RadioGroup as RadioGroup, ui_RadioGroupItem as RadioGroupItem, ui_ScrollArea as ScrollArea, ui_Select as Select, ui_SelectOption as SelectOption, ui_Separator as Separator, ui_Skeleton as Skeleton, ui_Stack as Stack, ui_Switch as Switch, ui_Tabs as Tabs, ui_TabsContent as TabsContent, ui_TabsList as TabsList, ui_TabsTrigger as TabsTrigger, ui_Text as Text, ui_Textarea as Textarea, ui_Tooltip as Tooltip };
482
+ }
483
+
484
+ /**
485
+ * useContextData — reads host context on mount and returns all context fields.
486
+ */
487
+
488
+ type UseContextDataResult = ContextData & {
489
+ loading: boolean;
490
+ };
491
+ declare const useContextData: () => UseContextDataResult;
492
+
493
+ export { type Store, Surface, createExtension, createStore, ui, useCapabilities, useContextData, useExtension, useStore, useSurfaceContext };