@runtypelabs/persona 3.1.0 → 3.2.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 +32 -3
- package/dist/index.cjs +38 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -2
- package/dist/index.d.ts +41 -2
- package/dist/index.global.js +51 -51
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +38 -38
- package/dist/index.js.map +1 -1
- package/dist/widget.css +12 -0
- package/package.json +1 -1
- package/src/components/launcher.test.ts +58 -0
- package/src/components/launcher.ts +10 -6
- package/src/styles/widget.css +12 -0
- package/src/types.ts +39 -2
- package/src/ui.ts +18 -2
package/dist/index.d.cts
CHANGED
|
@@ -1375,6 +1375,13 @@ type AgentWidgetLauncherConfig = {
|
|
|
1375
1375
|
* @default "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)"
|
|
1376
1376
|
*/
|
|
1377
1377
|
shadow?: string;
|
|
1378
|
+
/**
|
|
1379
|
+
* CSS `max-width` for the floating launcher button when the panel is closed.
|
|
1380
|
+
* Title and subtitle each truncate with an ellipsis when space is tight; full strings are available via the native `title` tooltip. Does not affect the open chat panel (`width` / `launcherWidth`).
|
|
1381
|
+
*
|
|
1382
|
+
* @example "min(380px, calc(100vw - 48px))"
|
|
1383
|
+
*/
|
|
1384
|
+
collapsedMaxWidth?: string;
|
|
1378
1385
|
};
|
|
1379
1386
|
type AgentWidgetSendButtonConfig = {
|
|
1380
1387
|
borderWidth?: string;
|
|
@@ -2797,11 +2804,15 @@ type AgentWidgetConfig = {
|
|
|
2797
2804
|
*
|
|
2798
2805
|
* This hook runs synchronously and must return the (potentially modified) state.
|
|
2799
2806
|
*
|
|
2807
|
+
* Returning `{ state, open: true }` also signals that the widget panel should
|
|
2808
|
+
* open after initialization — useful when injecting a post-navigation message
|
|
2809
|
+
* that the user should immediately see.
|
|
2810
|
+
*
|
|
2800
2811
|
* @example
|
|
2801
2812
|
* ```typescript
|
|
2813
|
+
* // Plain state transform (existing form, still supported)
|
|
2802
2814
|
* config: {
|
|
2803
2815
|
* onStateLoaded: (state) => {
|
|
2804
|
-
* // Check for pending navigation message
|
|
2805
2816
|
* const navMessage = consumeNavigationFlag();
|
|
2806
2817
|
* if (navMessage) {
|
|
2807
2818
|
* return {
|
|
@@ -2818,8 +2829,36 @@ type AgentWidgetConfig = {
|
|
|
2818
2829
|
* }
|
|
2819
2830
|
* }
|
|
2820
2831
|
* ```
|
|
2832
|
+
*
|
|
2833
|
+
* @example
|
|
2834
|
+
* ```typescript
|
|
2835
|
+
* // Return { state, open: true } to also open the panel
|
|
2836
|
+
* config: {
|
|
2837
|
+
* onStateLoaded: (state) => {
|
|
2838
|
+
* const navMessage = consumeNavigationFlag();
|
|
2839
|
+
* if (navMessage) {
|
|
2840
|
+
* return {
|
|
2841
|
+
* state: {
|
|
2842
|
+
* ...state,
|
|
2843
|
+
* messages: [...(state.messages || []), {
|
|
2844
|
+
* id: `nav-${Date.now()}`,
|
|
2845
|
+
* role: 'assistant',
|
|
2846
|
+
* content: navMessage,
|
|
2847
|
+
* createdAt: new Date().toISOString()
|
|
2848
|
+
* }]
|
|
2849
|
+
* },
|
|
2850
|
+
* open: true
|
|
2851
|
+
* };
|
|
2852
|
+
* }
|
|
2853
|
+
* return state;
|
|
2854
|
+
* }
|
|
2855
|
+
* }
|
|
2856
|
+
* ```
|
|
2821
2857
|
*/
|
|
2822
|
-
onStateLoaded?: (state: AgentWidgetStoredState) => AgentWidgetStoredState
|
|
2858
|
+
onStateLoaded?: (state: AgentWidgetStoredState) => AgentWidgetStoredState | {
|
|
2859
|
+
state: AgentWidgetStoredState;
|
|
2860
|
+
open?: boolean;
|
|
2861
|
+
};
|
|
2823
2862
|
/**
|
|
2824
2863
|
* Registry of custom components that can be rendered from JSON directives.
|
|
2825
2864
|
* Components are registered by name and can be invoked via JSON responses
|
package/dist/index.d.ts
CHANGED
|
@@ -1375,6 +1375,13 @@ type AgentWidgetLauncherConfig = {
|
|
|
1375
1375
|
* @default "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)"
|
|
1376
1376
|
*/
|
|
1377
1377
|
shadow?: string;
|
|
1378
|
+
/**
|
|
1379
|
+
* CSS `max-width` for the floating launcher button when the panel is closed.
|
|
1380
|
+
* Title and subtitle each truncate with an ellipsis when space is tight; full strings are available via the native `title` tooltip. Does not affect the open chat panel (`width` / `launcherWidth`).
|
|
1381
|
+
*
|
|
1382
|
+
* @example "min(380px, calc(100vw - 48px))"
|
|
1383
|
+
*/
|
|
1384
|
+
collapsedMaxWidth?: string;
|
|
1378
1385
|
};
|
|
1379
1386
|
type AgentWidgetSendButtonConfig = {
|
|
1380
1387
|
borderWidth?: string;
|
|
@@ -2797,11 +2804,15 @@ type AgentWidgetConfig = {
|
|
|
2797
2804
|
*
|
|
2798
2805
|
* This hook runs synchronously and must return the (potentially modified) state.
|
|
2799
2806
|
*
|
|
2807
|
+
* Returning `{ state, open: true }` also signals that the widget panel should
|
|
2808
|
+
* open after initialization — useful when injecting a post-navigation message
|
|
2809
|
+
* that the user should immediately see.
|
|
2810
|
+
*
|
|
2800
2811
|
* @example
|
|
2801
2812
|
* ```typescript
|
|
2813
|
+
* // Plain state transform (existing form, still supported)
|
|
2802
2814
|
* config: {
|
|
2803
2815
|
* onStateLoaded: (state) => {
|
|
2804
|
-
* // Check for pending navigation message
|
|
2805
2816
|
* const navMessage = consumeNavigationFlag();
|
|
2806
2817
|
* if (navMessage) {
|
|
2807
2818
|
* return {
|
|
@@ -2818,8 +2829,36 @@ type AgentWidgetConfig = {
|
|
|
2818
2829
|
* }
|
|
2819
2830
|
* }
|
|
2820
2831
|
* ```
|
|
2832
|
+
*
|
|
2833
|
+
* @example
|
|
2834
|
+
* ```typescript
|
|
2835
|
+
* // Return { state, open: true } to also open the panel
|
|
2836
|
+
* config: {
|
|
2837
|
+
* onStateLoaded: (state) => {
|
|
2838
|
+
* const navMessage = consumeNavigationFlag();
|
|
2839
|
+
* if (navMessage) {
|
|
2840
|
+
* return {
|
|
2841
|
+
* state: {
|
|
2842
|
+
* ...state,
|
|
2843
|
+
* messages: [...(state.messages || []), {
|
|
2844
|
+
* id: `nav-${Date.now()}`,
|
|
2845
|
+
* role: 'assistant',
|
|
2846
|
+
* content: navMessage,
|
|
2847
|
+
* createdAt: new Date().toISOString()
|
|
2848
|
+
* }]
|
|
2849
|
+
* },
|
|
2850
|
+
* open: true
|
|
2851
|
+
* };
|
|
2852
|
+
* }
|
|
2853
|
+
* return state;
|
|
2854
|
+
* }
|
|
2855
|
+
* }
|
|
2856
|
+
* ```
|
|
2821
2857
|
*/
|
|
2822
|
-
onStateLoaded?: (state: AgentWidgetStoredState) => AgentWidgetStoredState
|
|
2858
|
+
onStateLoaded?: (state: AgentWidgetStoredState) => AgentWidgetStoredState | {
|
|
2859
|
+
state: AgentWidgetStoredState;
|
|
2860
|
+
open?: boolean;
|
|
2861
|
+
};
|
|
2823
2862
|
/**
|
|
2824
2863
|
* Registry of custom components that can be rendered from JSON directives.
|
|
2825
2864
|
* Components are registered by name and can be invoked via JSON responses
|