@ganeshdole/brainbox-widget 0.1.0 → 0.3.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 +15 -5
- package/dist/index.d.ts +2 -1
- package/dist/index.js +152 -99
- package/dist/lib/config.d.ts +2 -1
- package/dist/lib/shadow-host.d.ts +4 -1
- package/dist/lib/theme.d.ts +7 -0
- package/dist/lib/widget-store.d.ts +9 -0
- package/dist/mount.d.ts +10 -3
- package/dist/use-brainbox-widget.d.ts +5 -1
- package/dist/widget.d.ts +4 -2
- package/dist/widget.js +7 -7
- package/package.json +4 -4
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import type { Brainbox } from "@ganeshdole/brainbox-core";
|
|
2
|
+
/** What a report starts as: a marked-up screenshot, or a recording. */
|
|
3
|
+
export type CaptureMode = "screenshot" | "record";
|
|
2
4
|
/** Whether the widget UI is open, shared between `<BrainboxWidget />` and
|
|
3
5
|
* whoever wants to open it: a host button, `window.Brainbox.open()`. Core
|
|
4
6
|
* has no idea of "open"; that is a UI matter, so it lives here. */
|
|
5
7
|
export interface WidgetStore {
|
|
6
8
|
isOpen(): boolean;
|
|
7
9
|
subscribe(listener: () => void): () => void;
|
|
10
|
+
/** Open on the chooser, where the user picks screenshot or recording. */
|
|
8
11
|
open(): void;
|
|
12
|
+
/** Open straight into a screenshot or a recording, skipping the chooser.
|
|
13
|
+
* For a host that offers the two choices in its own UI. */
|
|
14
|
+
start(mode: CaptureMode): void;
|
|
15
|
+
/** The mode `start()` asked for, cleared as it is read. The widget reads it
|
|
16
|
+
* when it opens; null means show the chooser. */
|
|
17
|
+
takeStart(): CaptureMode | null;
|
|
9
18
|
close(): void;
|
|
10
19
|
}
|
|
11
20
|
export declare function createWidgetStore(): WidgetStore;
|
package/dist/mount.d.ts
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import { type BrainboxOptions, type Identity } from "@ganeshdole/brainbox-core";
|
|
2
|
-
import type { TriggerMode } from "@ganeshdole/brainbox-shared";
|
|
1
|
+
import { type BrainboxOptions, type Identity, type ReportField } from "@ganeshdole/brainbox-core";
|
|
2
|
+
import type { TriggerMode, WidgetTheme } from "@ganeshdole/brainbox-shared";
|
|
3
3
|
import type { Position } from "./lib/position.ts";
|
|
4
|
+
import { type CaptureMode } from "./lib/widget-store.ts";
|
|
4
5
|
export interface MountOptions extends BrainboxOptions {
|
|
5
6
|
trigger?: TriggerMode;
|
|
6
7
|
position?: Position;
|
|
8
|
+
theme?: WidgetTheme;
|
|
7
9
|
}
|
|
8
10
|
/** The mounted widget, for a host with no React tree of its own. */
|
|
9
11
|
export interface WidgetHandle {
|
|
12
|
+
/** Show the chooser. */
|
|
10
13
|
open(): void;
|
|
14
|
+
/** Go straight into a screenshot or a recording, skipping the chooser. */
|
|
15
|
+
start(mode: CaptureMode): void;
|
|
11
16
|
close(): void;
|
|
12
17
|
identify(identity: Identity): void;
|
|
18
|
+
/** Replaces your app's details sent with every report. */
|
|
19
|
+
setFields(fields: ReportField[]): void;
|
|
13
20
|
/** Unmount the UI, remove it from the page and destroy the instance. */
|
|
14
21
|
destroy(): void;
|
|
15
22
|
}
|
|
16
23
|
/** Put the widget on the page. This is what the script-tag bundle calls; a
|
|
17
24
|
* React host should render `<BrainboxWidget />` instead. */
|
|
18
|
-
export declare function mount({ trigger, position, ...options }: MountOptions): WidgetHandle;
|
|
25
|
+
export declare function mount({ trigger, position, theme, ...options }: MountOptions): WidgetHandle;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { type CaptureMode } from "./lib/widget-store.ts";
|
|
2
|
+
/** Open or close the widget from anywhere under the same provider. `open()`
|
|
3
|
+
* shows the chooser; `start(mode)` skips it, for a host that offers
|
|
4
|
+
* screenshot and recording as separate choices in its own UI. */
|
|
2
5
|
export declare function useBrainboxWidget(): {
|
|
3
6
|
isOpen: boolean;
|
|
4
7
|
open(): void;
|
|
8
|
+
start(mode: CaptureMode): void;
|
|
5
9
|
close(): void;
|
|
6
10
|
};
|
package/dist/widget.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TriggerMode } from "@ganeshdole/brainbox-shared";
|
|
1
|
+
import type { TriggerMode, WidgetTheme } from "@ganeshdole/brainbox-shared";
|
|
2
2
|
import type { Position } from "./lib/position.ts";
|
|
3
3
|
export interface BrainboxWidgetProps {
|
|
4
4
|
/** `floating` renders our launcher button; `manual` waits for
|
|
@@ -6,6 +6,8 @@ export interface BrainboxWidgetProps {
|
|
|
6
6
|
trigger?: TriggerMode;
|
|
7
7
|
/** Which corner the launcher and panels sit in. */
|
|
8
8
|
position?: Position;
|
|
9
|
+
/** `dark` (default), `light`, or `system` to follow the visitor's OS. */
|
|
10
|
+
theme?: WidgetTheme;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* Brainbox's own capture UI, for a React tree that has a `<BrainboxProvider>`
|
|
@@ -13,4 +15,4 @@ export interface BrainboxWidgetProps {
|
|
|
13
15
|
* it sits in the tree: the host's styles cannot reach it there, and no
|
|
14
16
|
* ancestor's `overflow` or `transform` can trap its fixed-position panels.
|
|
15
17
|
*/
|
|
16
|
-
export declare function BrainboxWidget({ trigger, position }: BrainboxWidgetProps): import("react").ReactPortal | null;
|
|
18
|
+
export declare function BrainboxWidget({ trigger, position, theme, }: BrainboxWidgetProps): import("react").ReactPortal | null;
|