@helpai/elements 0.30.0 → 0.31.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/configurator.mjs +24 -1
- package/elements-web-component.esm.js +29 -29
- package/elements-web-component.esm.js.map +4 -4
- package/elements.cjs.js +29 -29
- package/elements.cjs.js.map +4 -4
- package/elements.esm.js +29 -29
- package/elements.esm.js.map +4 -4
- package/elements.js +27 -27
- package/elements.js.map +4 -4
- package/index.d.ts +87 -26
- package/index.mjs +628 -524
- package/package.json +1 -1
- package/schema.d.ts +105 -27
- package/schema.json +100 -2
- package/schema.mjs +27 -1
- package/web-component.d.ts +11 -5
- package/web-component.mjs +422 -346
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, H as HandshakeResponse, L as Link, S as ServerConfig, b as SiteConfig, W as WidgetConfig, c as WidgetConfigPartial, d as WidgetSettings, e as WidgetSettingsPartial } from './deployment-
|
|
1
|
+
export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, H as HandshakeResponse, L as Link, S as ServerConfig, b as SiteConfig, W as WidgetConfig, c as WidgetConfigPartial, d as WidgetSettings, e as WidgetSettingsPartial } from './deployment-DRGLrW2j.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -505,6 +505,46 @@ interface FormDef {
|
|
|
505
505
|
* `/activity` records for such forms).
|
|
506
506
|
*/
|
|
507
507
|
reviewable?: boolean;
|
|
508
|
+
/** BCP-47 locale the top-level strings (title / fields copy) are authored in. */
|
|
509
|
+
defaultLocale?: string;
|
|
510
|
+
/**
|
|
511
|
+
* Per-locale string overrides. The data module trims this to the requested
|
|
512
|
+
* `?locale=` (≤1 entry); the widget overlays it onto the default copy at
|
|
513
|
+
* resolve time (`overlayFormDef`). Absent strings fall back to the default.
|
|
514
|
+
*/
|
|
515
|
+
translations?: FormTranslation[];
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Per-locale overrides of a form's HUMAN-FACING strings only. Structure (field
|
|
519
|
+
* `name` / `type` / `validation`, option `value`) is shared across locales and
|
|
520
|
+
* stays canonical, so submissions + validation are locale-independent — a
|
|
521
|
+
* translation matches the canonical form by the stable `name` (field) / `value`
|
|
522
|
+
* (option) keys. Absent strings fall back to the top-level (defaultLocale) copy.
|
|
523
|
+
*
|
|
524
|
+
* The data module trims `FormDef.translations` to the requested `?locale=` (≤1
|
|
525
|
+
* entry) on read; the widget overlays that entry onto the default fields. Mirror
|
|
526
|
+
* of `module-help-ai-data-api` `DynamicFormTranslation`.
|
|
527
|
+
*/
|
|
528
|
+
interface FieldOptionTranslation {
|
|
529
|
+
/** The canonical option `value` this localizes. */
|
|
530
|
+
value: string;
|
|
531
|
+
label?: string;
|
|
532
|
+
description?: string;
|
|
533
|
+
}
|
|
534
|
+
interface FormFieldTranslation {
|
|
535
|
+
/** The canonical field `name` this localizes. */
|
|
536
|
+
name: string;
|
|
537
|
+
label?: string;
|
|
538
|
+
placeholder?: string;
|
|
539
|
+
validationHint?: string;
|
|
540
|
+
options?: FieldOptionTranslation[];
|
|
541
|
+
}
|
|
542
|
+
interface FormTranslation {
|
|
543
|
+
locale: string;
|
|
544
|
+
title?: string;
|
|
545
|
+
description?: string;
|
|
546
|
+
submitLabel?: string;
|
|
547
|
+
fields?: FormFieldTranslation[];
|
|
508
548
|
}
|
|
509
549
|
/** The `forms` block is an ordered list (max 20); order = priority. */
|
|
510
550
|
type FormsOptions = FormDef[];
|
|
@@ -1392,6 +1432,52 @@ interface EventMap {
|
|
|
1392
1432
|
}
|
|
1393
1433
|
type EventName = keyof EventMap;
|
|
1394
1434
|
|
|
1435
|
+
/**
|
|
1436
|
+
* Derives the `data-mode` attribute value from App state.
|
|
1437
|
+
*
|
|
1438
|
+
* Kept as a pure helper (no DOM, no React) so tests can pin the critical
|
|
1439
|
+
* invariants cheaply:
|
|
1440
|
+
*
|
|
1441
|
+
* - `isOpen === false` → `"closed"` regardless of `panelSize`.
|
|
1442
|
+
* This is the reason closing from fullscreen doesn't hide the launcher:
|
|
1443
|
+
* the `[data-mode="fullscreen"] .__P__-fab { display: none }` rule never
|
|
1444
|
+
* matches when the widget is closed.
|
|
1445
|
+
* - `panelSize` is preserved across close → open, so reopening the widget
|
|
1446
|
+
* restores the user's last layout (normal / expanded / fullscreen).
|
|
1447
|
+
* - Inline + standalone are terminal modes: they override any panelSize
|
|
1448
|
+
* because the widget isn't a popover and can't be "closed".
|
|
1449
|
+
*/
|
|
1450
|
+
|
|
1451
|
+
type HostMode = "page" | "standalone" | "inline" | "modal" | "drawer" | "fullscreen" | "expanded" | "open" | "closed";
|
|
1452
|
+
|
|
1453
|
+
/**
|
|
1454
|
+
* Shared widget runtime — the one composition both entry points wrap around
|
|
1455
|
+
* `<App>`.
|
|
1456
|
+
*
|
|
1457
|
+
* `mount()` (`src/index.ts`, programmatic, `widgetId`-keyed registry, returns a
|
|
1458
|
+
* handle) and `<web-ai-chat>` (`src/web-component.ts`, declarative, N-per-page,
|
|
1459
|
+
* no registry) used to each hand-roll the same four things around the App tree:
|
|
1460
|
+
* the ErrorBoundary wrapper, the handshake-config merge, the usage tracker, and
|
|
1461
|
+
* the host-attribute application (position / theme / `data-mode`). That parallel
|
|
1462
|
+
* code drifted three separate times (mode-merge, tracker, ErrorBoundary). This
|
|
1463
|
+
* module is the single source of that composition so it can't drift again — both
|
|
1464
|
+
* entry points only own what's genuinely theirs (mount: iframe + handle + hooks
|
|
1465
|
+
* + registry; web-component: attribute parsing + the custom-element lifecycle).
|
|
1466
|
+
*/
|
|
1467
|
+
|
|
1468
|
+
/**
|
|
1469
|
+
* Determine what `data-mode` the host should start at — matching what App's
|
|
1470
|
+
* mount-time `useEffect` will produce on its first render. Used for the initial
|
|
1471
|
+
* paint in both entry points (and `mount()`'s iframe sizing); after that, App
|
|
1472
|
+
* owns `data-mode` for the lifetime of the instance.
|
|
1473
|
+
*
|
|
1474
|
+
* `resolveInitialPanelState` is the one source of truth for "what does the first
|
|
1475
|
+
* render look like" — App.tsx uses it too. If these two paths ever pick
|
|
1476
|
+
* different initial states, an iframe physically resizes between mount and App's
|
|
1477
|
+
* first effect (the closed→open→closed flicker this pins against).
|
|
1478
|
+
*/
|
|
1479
|
+
declare function resolveInitialHostMode(options: ResolvedOptions): HostMode;
|
|
1480
|
+
|
|
1395
1481
|
/**
|
|
1396
1482
|
* Global lifecycle-hook registry.
|
|
1397
1483
|
*
|
|
@@ -1437,24 +1523,6 @@ declare const HOOK_WILDCARD = "*";
|
|
|
1437
1523
|
*/
|
|
1438
1524
|
type HookListener = (instance: ChatWidgetInstance, event: EventName, data: unknown) => void;
|
|
1439
1525
|
|
|
1440
|
-
/**
|
|
1441
|
-
* Derives the `data-mode` attribute value from App state.
|
|
1442
|
-
*
|
|
1443
|
-
* Kept as a pure helper (no DOM, no React) so tests can pin the critical
|
|
1444
|
-
* invariants cheaply:
|
|
1445
|
-
*
|
|
1446
|
-
* - `isOpen === false` → `"closed"` regardless of `panelSize`.
|
|
1447
|
-
* This is the reason closing from fullscreen doesn't hide the launcher:
|
|
1448
|
-
* the `[data-mode="fullscreen"] .__P__-fab { display: none }` rule never
|
|
1449
|
-
* matches when the widget is closed.
|
|
1450
|
-
* - `panelSize` is preserved across close → open, so reopening the widget
|
|
1451
|
-
* restores the user's last layout (normal / expanded / fullscreen).
|
|
1452
|
-
* - Inline + standalone are terminal modes: they override any panelSize
|
|
1453
|
-
* because the widget isn't a popover and can't be "closed".
|
|
1454
|
-
*/
|
|
1455
|
-
|
|
1456
|
-
type HostMode = "page" | "standalone" | "inline" | "modal" | "drawer" | "fullscreen" | "expanded" | "open" | "closed";
|
|
1457
|
-
|
|
1458
1526
|
/**
|
|
1459
1527
|
* Public ESM entry for `@<brand>/elements`.
|
|
1460
1528
|
*
|
|
@@ -1652,12 +1720,5 @@ declare const brand: {
|
|
|
1652
1720
|
readonly domain: string;
|
|
1653
1721
|
readonly siteUrl: string;
|
|
1654
1722
|
};
|
|
1655
|
-
/**
|
|
1656
|
-
* Determine what `data-mode` the host should start at — matching what
|
|
1657
|
-
* App's mount-time `useEffect` will produce on its first render. Exposed
|
|
1658
|
-
* only for the initial paint path in `mount()` (and the test suite);
|
|
1659
|
-
* after that, App owns `data-mode` for the lifetime of the instance.
|
|
1660
|
-
*/
|
|
1661
|
-
declare function resolveInitialHostMode(options: ResolvedOptions): HostMode;
|
|
1662
1723
|
|
|
1663
1724
|
export { type ChatWidgetInstance, type ChatWidgetOptions, type EventMap, type EventName, HOOK_WILDCARD, type HookListener, type LogEntry, type LogLevel, type ResolvedOptions, brand, destroy, getAllInstances, getInstance, hook, init, mount, resolveInitialHostMode, version };
|