@softistx/pulsarix-widget 0.6.0 → 0.7.1

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.
@@ -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
- export type Position = "bottom-right" | "bottom-left";
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
- /** A launcher offset: a number is pixels, a string is any CSS length (`"2rem"`, `"env(...)"`). */
8
- export interface LauncherOffset {
9
- bottom?: number | string;
10
- side?: number | string;
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
- position: Position;
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 offsets (`offset-bottom`, `offset-side`), as CSS lengths, or null. */
20
- offset: {
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", "position", "launcher", "offset-bottom", "offset-side", "accent-color", "inherit-theme", "api-base", "mask-text", "attachments", "privacy-url", "prefill-email", "prefill-title", "metadata", "identity"];
63
- /**
64
- * A CSS length for the launcher offset (a number of pixels, or `<number><unit>`, or a balanced
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. */
@@ -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" | "locale" | "mask-text" | "metadata" | "offset-bottom" | "offset-side" | "position" | "prefill-email" | "prefill-title" | "privacy-url" | "project-key" | "theme")[];
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;
@@ -1,3 +1,3 @@
1
- export type { LauncherMode, LauncherOffset, Locale, Position, ThemeMode, WidgetConfig, } from "./config";
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";
@@ -1,10 +1,9 @@
1
- import { type LauncherMode, type LauncherOffset, type Locale, type ThemeMode } from "./config";
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
- /** The floating button: `"auto"`, `"pill"` and `"icon"` all give the round FAB (kept for compatibility), or `false` for none. */
18
- launcher?: boolean | LauncherMode;
19
- /** Launcher distance from the bottom and its side (16 px default): pixels, or a CSS length. */
20
- offset?: LauncherOffset;
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"`). */
@@ -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 | Effect |
254
- | --------------------------------------------------- | ------------------------------------------------------------------ |
255
- | `data-project-key` / `projectKey` | the public key (required) |
256
- | `data-api-base` / `apiBase` | the pulsarix origin; required on the npm route |
257
- | `data-locale` / `locale` | `en` (default) or `fr` |
258
- | `data-theme` / `theme` | `light`, `dark` or `auto` (default) |
259
- | `data-position` / `position` | `bottom-right` (default) or `bottom-left` |
260
- | `data-accent-color` / `accentColor` | a hex seed for the theme |
261
- | `data-launcher` / `launcher` | `false` for none; any other value gives the round FAB (section 11) |
262
- | `data-offset-bottom`, `data-offset-side` / `offset` | launcher distance from the bottom and its side (section 11) |
263
- | `data-attachments="false"` | no screenshot and no file controls |
264
- | `data-mask-text="true"` | "Mask the text on the page" starts on |
265
- | `data-privacy-url` / `privacyUrl` | an http(s) link to your privacy page |
266
- | `data-prefill-email`, `data-prefill-title` | starting values of the form |
267
- | `data-identity` / `identity` | the signed token (section 3) |
268
- | `data-metadata` / `metadata` | a JSON object of strings stored with each report |
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,59 @@ Rules:
466
473
 
467
474
  ## 11. The launcher: look, position and visibility
468
475
 
469
- The floating button that opens the dialog. Three options shape it; each has a script-tag
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 one round floating action button (FAB) with the pulsarix mark, at every width. The
475
- `launcher` option no longer changes its look: `"auto"`, `"pill"` and `"icon"` all give the FAB (they
476
- are still read so existing embeds keep working), and `false` removes it (open the dialog with `open()`).
477
-
478
- Without a token the FAB opens the report form directly. With a token it opens a small menu anchored
479
- to it with two items, "Report a problem" and "My requests" (with its unread badge); each opens one
480
- view, never tabs. The FAB keeps the localized label as its accessible name and carries the unread
481
- count in it ("Report a problem, 3"), with a visible focus ring.
482
-
483
- ```html
484
- <script src="https://<pulsarix-host>/widget/v1/loader.js" async
485
- data-project-key="pk_live_xxx" data-launcher="icon"></script>
486
- ```
480
+ The launcher is an icon button, 44 x 44 px on wide screens, docked flush to the viewport edge and
481
+ rounded on the content side only. On phones (viewport 600 px or less) it is 24 x 44 px: the mark shrinks
482
+ to 16 px, there is no peek, and the hit area is exactly the visible tab.
483
+ To avoid any overlap, reserve `padding-inline-end` (`-start` for a left tab) of 24 px on phones and
484
+ 44-48 px on wide screens.
485
+ It wears the pulsarix mark and the unread badge. On wide screens it peeks 6 px less at rest; it slides
486
+ fully in on hover, focus and while dragged. Its label is a tooltip only
487
+ ("Report a problem", with "Drag to move" on a second line): shown on hover or keyboard focus after a short
488
+ delay, hidden while dragging and on screens with no hover. The `launcher` option no longer changes its
489
+ look: `"auto"`, `"pill"` and `"icon"` are still read so existing embeds keep working, and `false` removes it
490
+ (open the dialog with `open()`).
491
+
492
+ Without a token the tab opens the report form directly. With a token it opens a small menu beside it
493
+ with two items, "Report a problem" and "My requests" (with its unread badge); each opens one
494
+ view, never tabs. The tab keeps the localized label as its accessible name and carries the unread
495
+ count in it ("Report a problem, 3 unread requests"). It has `aria-expanded`, `aria-controls` and
496
+ `aria-keyshortcuts="Alt+ArrowUp Alt+ArrowDown"`, a visible focus ring, and respects `prefers-reduced-motion`.
497
+
498
+ ### Position: `launcher.side` and `launcher.offset`
499
+
500
+ You choose where the tab starts: the edge (`"right"` default, or `"left"`) and a vertical fraction
501
+ `offset` from `0` (top) to `1` (bottom), `0.5` by default. A value outside 0..1 is clamped, junk is the
502
+ default.
487
503
 
488
504
  ```ts
489
- mount({ projectKey: "pk_live_xxx", launcher: "auto" });
490
- ```
491
-
492
- ### Offset: `offset` and the CSS custom properties
493
-
494
- The launcher sits 16 px from the bottom and from its side, plus the device's safe area
495
- (`env(safe-area-inset-bottom)`) at the bottom. Move it to clear a sticky action bar:
496
-
497
- ```ts
498
- mount({ projectKey: "pk_live_xxx", offset: { bottom: 88, side: "1.5rem" } });
505
+ mount({ projectKey: "pk_live_xxx", launcher: { side: "left", offset: 0.3 } });
499
506
  ```
500
507
 
501
508
  ```html
502
- <script ... data-offset-bottom="88" data-offset-side="1.5rem"></script>
509
+ <script ... data-launcher-side="left" data-launcher-offset="0.3"></script>
503
510
  ```
504
511
 
505
- A number is pixels; a string is any CSS length (`"2rem"`, `"calc(var(--bar-height) + 8px)"`,
506
- `"env(...)"`). Negative values and anything that is not a length are ignored. The option sets two custom
507
- properties on the `<pulsarix-widget>` element, which a host can also set in its own stylesheet (for example
508
- from a media query, or following the height of its bar); the widget only ever removes a property it set itself:
512
+ The reporter can then move it along the edge, by dragging it (pointer or touch) or with
513
+ Alt+ArrowUp / Alt+ArrowDown (each move is announced in a live region). A drag never opens the dialog; only a
514
+ click, Enter or Space does. The tab keeps a 16 px gap from the top and the bottom of the viewport, also
515
+ when the window is resized. The position is saved in `localStorage` under a key of your page's origin
516
+ (inside a try/catch: with storage blocked, it lasts until the page closes) and wins over your starting
517
+ point from then on.
509
518
 
510
- ```css
511
- pulsarix-widget {
512
- --pulsarix-launcher-bottom: 88px;
513
- --pulsarix-launcher-side: 24px;
514
- }
515
- ```
519
+ Alt+ArrowUp and Alt+ArrowDown may clash with an assistive technology or a window manager shortcut; dragging the tab always remains available.
520
+
521
+ ### Migrating from 0.6 (breaking)
516
522
 
517
- `side` is the distance from the edge named by `position` (`bottom-right` by default).
523
+ `position`, `data-position`, `offset`, `data-offset-bottom`, `data-offset-side` and the custom properties
524
+ `--pulsarix-launcher-bottom` / `--pulsarix-launcher-side` are removed. Use `launcher.side` and
525
+ `launcher.offset` (a fraction of the height, no longer pixels or CSS lengths). The tab is flush to the
526
+ edge, so there is no side distance. A host that reserved room for the round button can drop that
527
+ reserve. To clear a sticky bar, use `holdLauncher()` (below). The `Position` and `LauncherOffset`
528
+ types are replaced by `LauncherSide` and `LauncherPlacement`.
518
529
 
519
530
  ### Visibility: `setLauncherVisible(visible)`
520
531
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softistx/pulsarix-widget",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
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.279.0",
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",