@runtypelabs/persona 3.7.0 → 3.8.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/dist/index.cjs +40 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -4
- package/dist/index.d.ts +43 -4
- package/dist/index.global.js +59 -59
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +40 -40
- package/dist/index.js.map +1 -1
- package/dist/theme-editor.cjs +198 -24
- package/dist/theme-editor.d.cts +43 -4
- package/dist/theme-editor.d.ts +43 -4
- package/dist/theme-editor.js +198 -24
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +34 -0
- package/dist/theme-reference.d.ts +34 -0
- package/dist/widget.css +4 -0
- package/package.json +1 -1
- package/src/components/artifact-card.ts +1 -1
- package/src/components/header-builder.ts +3 -0
- package/src/components/launcher.ts +7 -2
- package/src/components/panel.ts +3 -1
- package/src/runtime/host-layout.test.ts +1 -1
- package/src/runtime/host-layout.ts +2 -1
- package/src/styles/widget.css +4 -0
- package/src/types/theme.ts +35 -0
- package/src/types.ts +9 -4
- package/src/ui.overlay-z-index.test.ts +34 -2
- package/src/ui.ts +87 -8
- package/src/utils/constants.ts +13 -0
- package/src/utils/dropdown.ts +2 -1
- package/src/utils/overlay-host-stacking.test.ts +61 -0
- package/src/utils/overlay-host-stacking.ts +38 -0
- package/src/utils/scroll-lock.test.ts +64 -0
- package/src/utils/scroll-lock.ts +62 -0
- package/src/utils/tokens.ts +63 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
interface ScrollLockState {
|
|
2
|
+
originalOverflow: string;
|
|
3
|
+
originalPosition: string;
|
|
4
|
+
originalTop: string;
|
|
5
|
+
originalWidth: string;
|
|
6
|
+
scrollY: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let lockCount = 0;
|
|
10
|
+
let savedState: ScrollLockState | null = null;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Acquire a document-level scroll lock. The page body becomes non-scrollable
|
|
14
|
+
* via `overflow: hidden` with an iOS-safe `position: fixed` pattern that
|
|
15
|
+
* preserves the visual scroll position.
|
|
16
|
+
*
|
|
17
|
+
* Ref-counted: multiple callers can acquire; the lock is only released when
|
|
18
|
+
* all callers have released. Each release call is idempotent.
|
|
19
|
+
*
|
|
20
|
+
* @returns A release function. Call it exactly once per acquisition.
|
|
21
|
+
*/
|
|
22
|
+
export function acquireScrollLock(doc: Document = document): () => void {
|
|
23
|
+
lockCount++;
|
|
24
|
+
|
|
25
|
+
if (lockCount === 1) {
|
|
26
|
+
const body = doc.body;
|
|
27
|
+
const win = doc.defaultView ?? window;
|
|
28
|
+
const scrollY = win.scrollY || doc.documentElement.scrollTop;
|
|
29
|
+
|
|
30
|
+
savedState = {
|
|
31
|
+
originalOverflow: body.style.overflow,
|
|
32
|
+
originalPosition: body.style.position,
|
|
33
|
+
originalTop: body.style.top,
|
|
34
|
+
originalWidth: body.style.width,
|
|
35
|
+
scrollY,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
body.style.overflow = "hidden";
|
|
39
|
+
body.style.position = "fixed";
|
|
40
|
+
body.style.top = `-${scrollY}px`;
|
|
41
|
+
body.style.width = "100%";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let released = false;
|
|
45
|
+
|
|
46
|
+
return () => {
|
|
47
|
+
if (released) return;
|
|
48
|
+
released = true;
|
|
49
|
+
lockCount = Math.max(0, lockCount - 1);
|
|
50
|
+
|
|
51
|
+
if (lockCount === 0 && savedState) {
|
|
52
|
+
const body = doc.body;
|
|
53
|
+
const win = doc.defaultView ?? window;
|
|
54
|
+
body.style.overflow = savedState.originalOverflow;
|
|
55
|
+
body.style.position = savedState.originalPosition;
|
|
56
|
+
body.style.top = savedState.originalTop;
|
|
57
|
+
body.style.width = savedState.originalWidth;
|
|
58
|
+
win.scrollTo(0, savedState.scrollY);
|
|
59
|
+
savedState = null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
package/src/utils/tokens.ts
CHANGED
|
@@ -312,6 +312,7 @@ export const DEFAULT_COMPONENTS: ComponentTokens = {
|
|
|
312
312
|
border: 'palette.colors.gray.200',
|
|
313
313
|
shadow: 'palette.shadows.sm',
|
|
314
314
|
},
|
|
315
|
+
border: 'semantic.colors.border',
|
|
315
316
|
},
|
|
316
317
|
toolBubble: {
|
|
317
318
|
shadow: 'palette.shadows.sm',
|
|
@@ -334,6 +335,28 @@ export const DEFAULT_COMPONENTS: ComponentTokens = {
|
|
|
334
335
|
prose: {
|
|
335
336
|
fontFamily: 'inherit',
|
|
336
337
|
},
|
|
338
|
+
codeBlock: {
|
|
339
|
+
background: 'semantic.colors.container',
|
|
340
|
+
borderColor: 'semantic.colors.border',
|
|
341
|
+
textColor: 'inherit',
|
|
342
|
+
},
|
|
343
|
+
table: {
|
|
344
|
+
headerBackground: 'semantic.colors.container',
|
|
345
|
+
borderColor: 'semantic.colors.border',
|
|
346
|
+
},
|
|
347
|
+
hr: {
|
|
348
|
+
color: 'semantic.colors.divider',
|
|
349
|
+
},
|
|
350
|
+
blockquote: {
|
|
351
|
+
borderColor: 'palette.colors.gray.900',
|
|
352
|
+
background: 'transparent',
|
|
353
|
+
textColor: 'palette.colors.gray.500',
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
collapsibleWidget: {
|
|
357
|
+
container: 'palette.colors.gray.50',
|
|
358
|
+
surface: 'semantic.colors.surface',
|
|
359
|
+
border: 'semantic.colors.border',
|
|
337
360
|
},
|
|
338
361
|
voice: {
|
|
339
362
|
recording: {
|
|
@@ -823,6 +846,46 @@ export function themeToCssVariables(theme: PersonaTheme): Record<string, string>
|
|
|
823
846
|
cssVars['--persona-md-prose-font-family'] = mdProseFont;
|
|
824
847
|
}
|
|
825
848
|
|
|
849
|
+
// Markdown code block
|
|
850
|
+
cssVars['--persona-md-code-block-bg'] =
|
|
851
|
+
cssVars['--persona-components-markdown-codeBlock-background'] ?? cssVars['--persona-container'];
|
|
852
|
+
cssVars['--persona-md-code-block-border-color'] =
|
|
853
|
+
cssVars['--persona-components-markdown-codeBlock-borderColor'] ?? cssVars['--persona-border'];
|
|
854
|
+
cssVars['--persona-md-code-block-text-color'] =
|
|
855
|
+
cssVars['--persona-components-markdown-codeBlock-textColor'] ?? 'inherit';
|
|
856
|
+
|
|
857
|
+
// Markdown table
|
|
858
|
+
cssVars['--persona-md-table-header-bg'] =
|
|
859
|
+
cssVars['--persona-components-markdown-table-headerBackground'] ?? cssVars['--persona-container'];
|
|
860
|
+
cssVars['--persona-md-table-border-color'] =
|
|
861
|
+
cssVars['--persona-components-markdown-table-borderColor'] ?? cssVars['--persona-border'];
|
|
862
|
+
|
|
863
|
+
// Markdown HR
|
|
864
|
+
cssVars['--persona-md-hr-color'] =
|
|
865
|
+
cssVars['--persona-components-markdown-hr-color'] ?? cssVars['--persona-divider'];
|
|
866
|
+
|
|
867
|
+
// Markdown blockquote
|
|
868
|
+
cssVars['--persona-md-blockquote-border-color'] =
|
|
869
|
+
cssVars['--persona-components-markdown-blockquote-borderColor'] ??
|
|
870
|
+
cssVars['--persona-palette-colors-gray-900'];
|
|
871
|
+
cssVars['--persona-md-blockquote-bg'] =
|
|
872
|
+
cssVars['--persona-components-markdown-blockquote-background'] ?? 'transparent';
|
|
873
|
+
cssVars['--persona-md-blockquote-text-color'] =
|
|
874
|
+
cssVars['--persona-components-markdown-blockquote-textColor'] ??
|
|
875
|
+
cssVars['--persona-palette-colors-gray-500'];
|
|
876
|
+
|
|
877
|
+
// Collapsible widget chrome (tool/reasoning/approval bubbles)
|
|
878
|
+
cssVars['--cw-container'] =
|
|
879
|
+
cssVars['--persona-components-collapsibleWidget-container'] ?? cssVars['--persona-surface'];
|
|
880
|
+
cssVars['--cw-surface'] =
|
|
881
|
+
cssVars['--persona-components-collapsibleWidget-surface'] ?? cssVars['--persona-surface'];
|
|
882
|
+
cssVars['--cw-border'] =
|
|
883
|
+
cssVars['--persona-components-collapsibleWidget-border'] ?? cssVars['--persona-border'];
|
|
884
|
+
|
|
885
|
+
// Message border
|
|
886
|
+
cssVars['--persona-message-border'] =
|
|
887
|
+
cssVars['--persona-components-message-border'] ?? cssVars['--persona-border'];
|
|
888
|
+
|
|
826
889
|
// Icon button tokens
|
|
827
890
|
const components = theme.components;
|
|
828
891
|
const iconBtn = components?.iconButton;
|