@softistx/pulsarix-widget 0.6.0 → 0.7.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 +54 -29
- package/dist/index.js +1488 -1320
- package/dist/types/config.d.ts +17 -21
- package/dist/types/element.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/mount.d.ts +8 -6
- package/docs/integration.md +57 -50
- package/package.json +2 -2
package/dist/types/config.d.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
/** The widget's configuration (plan section 10): read from attributes, validated, defaulted. */
|
|
2
2
|
export type Locale = "en" | "fr";
|
|
3
3
|
export type ThemeMode = "light" | "dark" | "auto";
|
|
4
|
-
|
|
5
|
-
/** Every value gives the round FAB; the values are read so existing embeds keep working. */
|
|
4
|
+
/** Every value gives the edge tab; the values are read so existing embeds keep working. */
|
|
6
5
|
export type LauncherMode = "auto" | "pill" | "icon";
|
|
7
|
-
/**
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
/** The edge the launcher is docked to. */
|
|
7
|
+
export type LauncherSide = "right" | "left";
|
|
8
|
+
/**
|
|
9
|
+
* Where the launcher starts: its edge and a vertical fraction of the free height (0 top, 1 bottom).
|
|
10
|
+
* The reporter can move it along the edge; what they chose wins over this starting point.
|
|
11
|
+
*/
|
|
12
|
+
export interface LauncherPlacement {
|
|
13
|
+
side: LauncherSide;
|
|
14
|
+
offset: number;
|
|
11
15
|
}
|
|
16
|
+
export declare const DEFAULT_PLACEMENT: LauncherPlacement;
|
|
12
17
|
export interface WidgetConfig {
|
|
13
18
|
projectKey: string | null;
|
|
14
19
|
locale: Locale;
|
|
15
20
|
theme: ThemeMode;
|
|
16
|
-
|
|
17
|
-
/** Read for compatibility (`launcher="pill"`, `"icon"`): the launcher is always the round FAB; `launcher="false"` is read by the element. */
|
|
21
|
+
/** Read for compatibility (`launcher="pill"`, `"icon"`): the launcher is always the edge tab; `launcher="false"` is read by the element. */
|
|
18
22
|
launcherMode: LauncherMode;
|
|
19
|
-
/** The launcher's
|
|
20
|
-
|
|
21
|
-
bottom: string | null;
|
|
22
|
-
side: string | null;
|
|
23
|
-
};
|
|
23
|
+
/** The launcher's starting edge and height (`launcher-side`, `launcher-offset`). */
|
|
24
|
+
launcher: LauncherPlacement;
|
|
24
25
|
/** A valid hex seed from the host, or null: the built-in lavande theme then applies. */
|
|
25
26
|
accentColor: string | null;
|
|
26
27
|
/**
|
|
@@ -59,14 +60,9 @@ export declare const METADATA_KEY_MAX = 64;
|
|
|
59
60
|
export declare const METADATA_VALUE_MAX = 512;
|
|
60
61
|
export declare const METADATA_MAX_BYTES = 2048;
|
|
61
62
|
/** The attributes the element observes, in their HTML spelling. */
|
|
62
|
-
export declare const OBSERVED_ATTRIBUTES: readonly ["project-key", "locale", "theme", "
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
* `calc()`, `min()`, `max()`, `clamp()`, `var()`, `env()` call), or null. A negative value, or
|
|
66
|
-
* anything else (`;`, `}`, quotes, a bare word), is dropped. The browser's `CSS.supports` has
|
|
67
|
-
* the last word where it exists.
|
|
68
|
-
*/
|
|
69
|
-
export declare function lengthOf(value: string | number | null | undefined): string | null;
|
|
63
|
+
export declare const OBSERVED_ATTRIBUTES: readonly ["project-key", "locale", "theme", "launcher", "launcher-side", "launcher-offset", "accent-color", "inherit-theme", "api-base", "mask-text", "attachments", "privacy-url", "prefill-email", "prefill-title", "metadata", "identity"];
|
|
64
|
+
/** A launcher offset: a number from 0 to 1 (a fraction of the free height), else the default 0.5. */
|
|
65
|
+
export declare function offsetOf(value: string | number | null | undefined): number;
|
|
70
66
|
/** A hex colour (#rgb or #rrggbb): the only form accepted as a seed. */
|
|
71
67
|
export declare function isHexColor(value: string | null): value is string;
|
|
72
68
|
/** An http(s) URL's origin (plus path prefix), or null: anything else is not a base. */
|
package/dist/types/element.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type WidgetEvent = "pulsarix:ready" | "pulsarix:open" | "pulsarix:close"
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class PulsarixWidgetElement extends HTMLElement {
|
|
12
12
|
#private;
|
|
13
|
-
static observedAttributes: ("accent-color" | "api-base" | "attachments" | "identity" | "inherit-theme" | "launcher" | "
|
|
13
|
+
static observedAttributes: ("accent-color" | "api-base" | "attachments" | "identity" | "inherit-theme" | "launcher" | "launcher-offset" | "launcher-side" | "locale" | "mask-text" | "metadata" | "prefill-email" | "prefill-title" | "privacy-url" | "project-key" | "theme")[];
|
|
14
14
|
get config(): WidgetConfig;
|
|
15
15
|
get isOpen(): boolean;
|
|
16
16
|
connectedCallback(): void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { LauncherMode,
|
|
1
|
+
export type { LauncherMode, LauncherPlacement, LauncherSide, Locale, ThemeMode, WidgetConfig, } from "./config";
|
|
2
2
|
export { defineWidget, type MountMetadata, PulsarixWidgetElement, TAG_NAME, type WidgetEvent, } from "./element";
|
|
3
3
|
export { type MountOptions, mount, type WidgetHandle } from "./mount";
|
package/dist/types/mount.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { LauncherMode, LauncherPlacement, Locale, ThemeMode } from "./config";
|
|
2
2
|
import { type MountMetadata, type PulsarixWidgetElement, type WidgetEvent } from "./element";
|
|
3
3
|
export interface MountOptions {
|
|
4
4
|
projectKey: string;
|
|
5
5
|
locale?: "en" | "fr";
|
|
6
6
|
theme?: "light" | "dark" | "auto";
|
|
7
|
-
position?: "bottom-left" | "bottom-right";
|
|
8
7
|
accentColor?: string;
|
|
9
8
|
/**
|
|
10
9
|
* Wear the host app's `@softistx/material` theme (colours, radius, light or dark) and follow
|
|
@@ -14,10 +13,13 @@ export interface MountOptions {
|
|
|
14
13
|
inheritTheme?: boolean;
|
|
15
14
|
/** Origin of the pulsarix host (`https://pulsarix.example.com`); the loader fills it in. */
|
|
16
15
|
apiBase?: string;
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The edge tab: `false` for none, `"auto"`, `"pill"` and `"icon"` (kept for compatibility) for the
|
|
18
|
+
* default one, or `{ side, offset }` for its starting edge (`"right"` default or `"left"`) and
|
|
19
|
+
* height (a fraction from 0, top, to 1, bottom; 0.5 default). The reporter can move it along the
|
|
20
|
+
* edge, and what they chose wins.
|
|
21
|
+
*/
|
|
22
|
+
launcher?: boolean | LauncherMode | Partial<LauncherPlacement>;
|
|
21
23
|
/** The screenshot's "Mask the text on the page" option starts on. */
|
|
22
24
|
maskText?: boolean;
|
|
23
25
|
/** `false` hides the screenshot and file controls (`data-attachments="false"`). */
|
package/docs/integration.md
CHANGED
|
@@ -238,6 +238,13 @@ Content-Security-Policy:
|
|
|
238
238
|
(fetched on the first capture) and the markdown renderer of the team's replies (`chat-markdown-*.js`,
|
|
239
239
|
about 740 KB, 221 KB gzipped, fetched when a thread opens; plain text shows until it arrives). Serve
|
|
240
240
|
every file of the widget's folder beside the entry, with the bundle's cache headers.
|
|
241
|
+
- The icons (the type and impact cards, the camera button) come from a small sheet at
|
|
242
|
+
`<apiBase>/widget/v1/icons/duotone.svg`, where `apiBase` is the loader's origin unless you set
|
|
243
|
+
`data-api-base`. Only the few icons the widget draws are in it. It is fetched once with CORS (no
|
|
244
|
+
credentials) and inlined into the widget's shadow root, so `connect-src` needs the `apiBase` origin
|
|
245
|
+
(already there for the API). An unavailable sheet, or an `apiBase` that is not `https` (or
|
|
246
|
+
`http://localhost`), leaves those icons blank; the form still works. Serve `icons/` with the rest of
|
|
247
|
+
the widget's folder.
|
|
241
248
|
- The widget's styles are adopted into its shadow root: no `style-src 'unsafe-inline'`. The requests
|
|
242
249
|
thread injects one `<style>` element; under a strict `style-src` give your page a nonce, which the
|
|
243
250
|
widget reads from a `nonce` attribute on a `style` or `script` element or from this tag:
|
|
@@ -250,22 +257,22 @@ Content-Security-Policy:
|
|
|
250
257
|
|
|
251
258
|
Script-tag attributes and `init` / `mount` options (all optional except the key):
|
|
252
259
|
|
|
253
|
-
| Attribute / option
|
|
254
|
-
|
|
|
255
|
-
| `data-project-key` / `projectKey`
|
|
256
|
-
| `data-api-base` / `apiBase`
|
|
257
|
-
| `data-locale` / `locale`
|
|
258
|
-
| `data-theme` / `theme`
|
|
259
|
-
| `data-
|
|
260
|
-
| `data-
|
|
261
|
-
| `data-
|
|
262
|
-
| `data-
|
|
263
|
-
| `data-attachments="false"`
|
|
264
|
-
| `data-mask-text="true"`
|
|
265
|
-
| `data-privacy-url` / `privacyUrl`
|
|
266
|
-
| `data-prefill-email`, `data-prefill-title`
|
|
267
|
-
| `data-identity` / `identity`
|
|
268
|
-
| `data-metadata` / `metadata`
|
|
260
|
+
| Attribute / option | Effect |
|
|
261
|
+
| ------------------------------------------ | ----------------------------------------------------------------- |
|
|
262
|
+
| `data-project-key` / `projectKey` | the public key (required) |
|
|
263
|
+
| `data-api-base` / `apiBase` | the pulsarix origin; required on the npm route |
|
|
264
|
+
| `data-locale` / `locale` | `en` (default) or `fr` |
|
|
265
|
+
| `data-theme` / `theme` | `light`, `dark` or `auto` (default) |
|
|
266
|
+
| `data-launcher-side` / `launcher.side` | `right` (default) or `left` (section 11) |
|
|
267
|
+
| `data-launcher-offset` / `launcher.offset` | a fraction from 0 (top) to 1 (bottom), `0.5` default (section 11) |
|
|
268
|
+
| `data-accent-color` / `accentColor` | a hex seed for the theme |
|
|
269
|
+
| `data-launcher` / `launcher` | `false` for none; any other value gives the edge tab (section 11) |
|
|
270
|
+
| `data-attachments="false"` | no screenshot and no file controls |
|
|
271
|
+
| `data-mask-text="true"` | "Mask the text on the page" starts on |
|
|
272
|
+
| `data-privacy-url` / `privacyUrl` | an http(s) link to your privacy page |
|
|
273
|
+
| `data-prefill-email`, `data-prefill-title` | starting values of the form |
|
|
274
|
+
| `data-identity` / `identity` | the signed token (section 3) |
|
|
275
|
+
| `data-metadata` / `metadata` | a JSON object of strings stored with each report |
|
|
269
276
|
|
|
270
277
|
`metadata` carries facts about the session that help triage: at most 20 entries, keys of 64 characters,
|
|
271
278
|
values of 512, 2 KB in all; the rest is dropped. The keys `capture-N-page` are reserved: the widget
|
|
@@ -466,55 +473,55 @@ Rules:
|
|
|
466
473
|
|
|
467
474
|
## 11. The launcher: look, position and visibility
|
|
468
475
|
|
|
469
|
-
The
|
|
470
|
-
attribute and a `mount()` option.
|
|
476
|
+
The edge tab that opens the dialog. Two options shape it; each has script-tag attributes and a `mount()` option.
|
|
471
477
|
|
|
472
478
|
### Look: `launcher`
|
|
473
479
|
|
|
474
|
-
The launcher is
|
|
475
|
-
|
|
476
|
-
|
|
480
|
+
The launcher is an icon button, 44 x 44 px at every width, docked flush to the viewport edge and
|
|
481
|
+
rounded on the content side only. It wears the pulsarix mark and the unread badge. At rest it peeks 6 px
|
|
482
|
+
less; it slides fully in on hover, focus and while dragged. Its label is a tooltip only
|
|
483
|
+
("Report a problem", with "Drag to move" on a second line): shown on hover or keyboard focus after a short
|
|
484
|
+
delay, hidden while dragging and on screens with no hover. The `launcher` option no longer changes its
|
|
485
|
+
look: `"auto"`, `"pill"` and `"icon"` are still read so existing embeds keep working, and `false` removes it
|
|
486
|
+
(open the dialog with `open()`).
|
|
477
487
|
|
|
478
|
-
Without a token the
|
|
479
|
-
|
|
480
|
-
view, never tabs. The
|
|
481
|
-
count in it ("Report a problem, 3")
|
|
488
|
+
Without a token the tab opens the report form directly. With a token it opens a small menu beside it
|
|
489
|
+
with two items, "Report a problem" and "My requests" (with its unread badge); each opens one
|
|
490
|
+
view, never tabs. The tab keeps the localized label as its accessible name and carries the unread
|
|
491
|
+
count in it ("Report a problem, 3 unread requests"). It has `aria-expanded`, `aria-controls` and
|
|
492
|
+
`aria-keyshortcuts="Alt+ArrowUp Alt+ArrowDown"`, a visible focus ring, and respects `prefers-reduced-motion`.
|
|
482
493
|
|
|
483
|
-
|
|
484
|
-
<script src="https://<pulsarix-host>/widget/v1/loader.js" async
|
|
485
|
-
data-project-key="pk_live_xxx" data-launcher="icon"></script>
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
```ts
|
|
489
|
-
mount({ projectKey: "pk_live_xxx", launcher: "auto" });
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
### Offset: `offset` and the CSS custom properties
|
|
494
|
+
### Position: `launcher.side` and `launcher.offset`
|
|
493
495
|
|
|
494
|
-
|
|
495
|
-
(`
|
|
496
|
+
You choose where the tab starts: the edge (`"right"` default, or `"left"`) and a vertical fraction
|
|
497
|
+
`offset` from `0` (top) to `1` (bottom), `0.5` by default. A value outside 0..1 is clamped, junk is the
|
|
498
|
+
default.
|
|
496
499
|
|
|
497
500
|
```ts
|
|
498
|
-
mount({ projectKey: "pk_live_xxx",
|
|
501
|
+
mount({ projectKey: "pk_live_xxx", launcher: { side: "left", offset: 0.3 } });
|
|
499
502
|
```
|
|
500
503
|
|
|
501
504
|
```html
|
|
502
|
-
<script ... data-
|
|
505
|
+
<script ... data-launcher-side="left" data-launcher-offset="0.3"></script>
|
|
503
506
|
```
|
|
504
507
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
508
|
+
The reporter can then move it along the edge, by dragging it (pointer or touch) or with
|
|
509
|
+
Alt+ArrowUp / Alt+ArrowDown (each move is announced in a live region). A drag never opens the dialog; only a
|
|
510
|
+
click, Enter or Space does. The tab keeps a 16 px gap from the top and the bottom of the viewport, also
|
|
511
|
+
when the window is resized. The position is saved in `localStorage` under a key of your page's origin
|
|
512
|
+
(inside a try/catch: with storage blocked, it lasts until the page closes) and wins over your starting
|
|
513
|
+
point from then on.
|
|
509
514
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
--pulsarix-launcher-side: 24px;
|
|
514
|
-
}
|
|
515
|
-
```
|
|
515
|
+
Alt+ArrowUp and Alt+ArrowDown may clash with an assistive technology or a window manager shortcut; dragging the tab always remains available.
|
|
516
|
+
|
|
517
|
+
### Migrating from 0.6 (breaking)
|
|
516
518
|
|
|
517
|
-
`
|
|
519
|
+
`position`, `data-position`, `offset`, `data-offset-bottom`, `data-offset-side` and the custom properties
|
|
520
|
+
`--pulsarix-launcher-bottom` / `--pulsarix-launcher-side` are removed. Use `launcher.side` and
|
|
521
|
+
`launcher.offset` (a fraction of the height, no longer pixels or CSS lengths). The tab is flush to the
|
|
522
|
+
edge, so there is no side distance. A host that reserved room for the round button can drop that
|
|
523
|
+
reserve. To clear a sticky bar, use `holdLauncher()` (below). The `Position` and `LauncherOffset`
|
|
524
|
+
types are replaced by `LauncherSide` and `LauncherPlacement`.
|
|
518
525
|
|
|
519
526
|
### Visibility: `setLauncherVisible(visible)`
|
|
520
527
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softistx/pulsarix-widget",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Embeddable client-issue intake widget for pulsarix, rendered in a Shadow DOM",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@graphql-codegen/typescript": "^7.0.1",
|
|
19
19
|
"@graphql-codegen/typescript-operations": "^7.0.1",
|
|
20
20
|
"@happy-dom/global-registrator": "^21.0.4",
|
|
21
|
-
"@softistx/material": "^3.
|
|
21
|
+
"@softistx/material": "^3.281.0",
|
|
22
22
|
"@softistx/material-core": "^0.96.1",
|
|
23
23
|
"@tailwindcss/cli": "^4.3.3",
|
|
24
24
|
"@testing-library/dom": "^10.4.2",
|