@saar-ai/web-widget 0.2.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.
@@ -0,0 +1,33 @@
1
+ import type { WidgetAvatar } from './avatar.js';
2
+ import type { BotState } from './bot-state.js';
3
+ /**
4
+ * Dispatches to whichever avatar a tenant published — `BotFace` (`'orb'`)
5
+ * or `RopeKnot` (`'knot'`) — with one shared, EXHAUSTIVE `switch` over
6
+ * {@link WidgetAvatar}. `concierge-shell.tsx` (the panel's `lg` slot) and
7
+ * `concierge-launcher.tsx` (the pill's `sm` slot) used to each hardcode
8
+ * their own `avatar === 'knot' ? <RopeKnot/> : <BotFace/>` ternary — fine
9
+ * for exactly two avatars, but a duplicated decision with no compiler
10
+ * backstop: a THIRD avatar added to `WIDGET_AVATARS` (`avatar.ts`) would
11
+ * silently fall through to the orb at both call sites instead of failing to
12
+ * build. The `never` branch below is what turns that into a compile error.
13
+ *
14
+ * The two avatars' own trigger props don't line up 1:1 — `BotFace`'s
15
+ * one-shot flourish is `messageArrived` (a boolean, CSS-class-driven);
16
+ * `RopeKnot`'s is `tightenKey` (a number, restarted via `classList` — see
17
+ * that file's own doc comment for why). Both are accepted here and each is
18
+ * forwarded ONLY to the avatar that understands it; the other simply never
19
+ * receives it, exactly as the two duplicated ternaries already did.
20
+ */
21
+ export interface AvatarFaceProps {
22
+ readonly avatar: WidgetAvatar;
23
+ readonly state: BotState;
24
+ readonly size: 'sm' | 'lg';
25
+ /** Accessible name. Omitted ⇒ decorative; see `bot-face.tsx`'s `labelProps`. */
26
+ readonly label?: string;
27
+ /** `BotFace`-only: the orb's one-shot nod when the visitor's own message lands. */
28
+ readonly messageArrived?: boolean;
29
+ /** `RopeKnot`-only: bumped to replay its click/message-arrived tighten pulse. */
30
+ readonly tightenKey?: number;
31
+ }
32
+ export declare function AvatarFace({ avatar, state, size, label, messageArrived, tightenKey, }: AvatarFaceProps): import("react").JSX.Element;
33
+ //# sourceMappingURL=avatar-face.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar-face.d.ts","sourceRoot":"","sources":["../src/avatar-face.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,mFAAmF;IACnF,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,iFAAiF;IACjF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,KAAK,EACL,IAAI,EACJ,KAAK,EACL,cAAc,EACd,UAAU,GACX,EAAE,eAAe,+BAajB"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Which face the widget draws — a per-tenant `appearance.avatar` choice.
3
+ *
4
+ * `'orb'` is `BotFace`, the animated gradient blob this widget has always
5
+ * shipped. `'knot'` is `RopeKnot`, a hand-drawn rope line that ties and
6
+ * unties itself through the same four {@link BotState}s. Kept as data,
7
+ * separate from the components, for the same reason `bot-state.ts` keeps
8
+ * `BotState` separate from `BotFace`: parsing and defaulting have to be
9
+ * assertable without rendering either avatar.
10
+ */
11
+ export declare const WIDGET_AVATARS: readonly ['orb', 'knot'];
12
+ export type WidgetAvatar = (typeof WIDGET_AVATARS)[number];
13
+ /** What every layer in this package falls back to when a tenant never published one. */
14
+ export declare const DEFAULT_WIDGET_AVATAR: WidgetAvatar;
15
+ /** Whether a value is an avatar this widget knows how to render. Mirrors `bot-state.ts`'s `isBotState`. */
16
+ export declare function isWidgetAvatar(value: unknown): value is WidgetAvatar;
17
+ //# sourceMappingURL=avatar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../src/avatar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,YAAI,KAAK,EAAE,MAAM,CAAU,CAAC;AAEvD,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,wFAAwF;AACxF,eAAO,MAAM,qBAAqB,EAAE,YAAoB,CAAC;AAEzD,2GAA2G;AAC3G,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE"}
@@ -36,4 +36,21 @@ export declare function BotFace({ state, size, messageArrived, label, }: {
36
36
  /** Accessible name. Omitted ⇒ decorative; see this module's doc comment. */
37
37
  label?: string;
38
38
  }): import("react").JSX.Element;
39
+ /**
40
+ * `role="img"` + a name, or nothing at all — never a name we invented.
41
+ *
42
+ * Exported so `rope-knot.tsx` (the 'knot' avatar) shares this exact
43
+ * accessibility contract rather than redeclaring it — both avatars are
44
+ * decorative-by-default for the identical reason (see this module's doc
45
+ * comment), and a second copy would be free to drift.
46
+ */
47
+ export declare function labelProps(label: string | undefined): {
48
+ readonly 'aria-hidden': true;
49
+ readonly role?: undefined;
50
+ readonly 'aria-label'?: undefined;
51
+ } | {
52
+ readonly 'aria-hidden'?: undefined;
53
+ readonly role: 'img';
54
+ readonly 'aria-label': string;
55
+ };
39
56
  //# sourceMappingURL=bot-face.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bot-face.d.ts","sourceRoot":"","sources":["../src/bot-face.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAExB,wBAAgB,OAAO,CAAC,EACtB,KAAc,EACd,IAAW,EACX,cAAsB,EACtB,KAAK,GACN,EAAE;IACD,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,+BAKA"}
1
+ {"version":3,"file":"bot-face.d.ts","sourceRoot":"","sources":["../src/bot-face.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAExB,wBAAgB,OAAO,CAAC,EACtB,KAAc,EACd,IAAW,EACX,cAAsB,EACtB,KAAK,GACN,EAAE;IACD,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,+BAKA;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS;;;;;;mBAGrC,KAAK;;EACnB"}