@tensorpass/aiconnect-react 0.1.5 → 0.1.6

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.
@@ -8,13 +8,12 @@ import { ChatFrame } from "./parts/ChatFrame.js";
8
8
  import { moduleClass } from "./parts/moduleClass.js";
9
9
  import { useModuleChat } from "./parts/useModuleChat.js";
10
10
  import { useModuleHandle } from "./parts/useModuleHandle.js";
11
- import { useFocusTrap, useOverlay, useScrollLock } from "./useOverlay.js";
11
+ import { useFocusTrap, useOverlay } from "./useOverlay.js";
12
12
  export function AiChatPage({ ref, ...props }) {
13
13
  const { moduleMessages, isPickerOpen } = useAiConnect();
14
14
  const chat = useModuleChat(props);
15
- const { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId } = useOverlay(props);
15
+ const { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId, } = useOverlay(props, 'always');
16
16
  useModuleHandle(ref, chat.ask, show);
17
- useScrollLock(open);
18
17
  // The connect window opens over the page mode and keeps the focus while it is open.
19
18
  useFocusTrap(layerRef, open && !isPickerOpen);
20
19
  const title = props.title ?? moduleMessages.pageTitle;
@@ -1 +1 @@
1
- {"version":3,"file":"AiChatPage.js","sourceRoot":"","sources":["../../src/modules/AiChatPage.tsx"],"names":[],"mappings":";AAAA,kGAAkG;AAClG,kGAAkG;AAClG,+FAA+F;AAE/F,OAAO,EAAE,YAAY,EAAE,MAAM,yBAA0B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAuB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,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,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EACtF,OAAO,EAAE,KAAK,GAAI,GAChB,GACE,IACT,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// A full page AI mode: the chat takes the whole window over the site, in one centred column, with\n// the page's scroll held and the focus kept inside until the visitor closes it. It opens from its\n// own button, placed where the site renders the module, or from the site's own through `open`.\n\nimport { useAiConnect } from '../AiConnectProvider.tsx';\nimport { Launcher } from './Launcher.tsx';\nimport { ChatFrame } from './parts/ChatFrame.tsx';\nimport { moduleClass } from './parts/moduleClass.ts';\nimport { useModuleChat } from './parts/useModuleChat.ts';\nimport { useModuleHandle } from './parts/useModuleHandle.ts';\nimport type { AiModuleProps, AiOverlayProps } from './types.ts';\nimport { useFocusTrap, useOverlay, useScrollLock } from './useOverlay.ts';\n\nexport interface AiChatPageProps extends AiModuleProps, AiOverlayProps {}\n\nexport function AiChatPage({ ref, ...props }: AiChatPageProps) {\n const { moduleMessages, isPickerOpen } = useAiConnect();\n const chat = useModuleChat(props);\n const { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId } = useOverlay(props);\n useModuleHandle(ref, chat.ask, show);\n useScrollLock(open);\n // The connect window opens over the page mode and keeps the focus while it is open.\n useFocusTrap(layerRef, open && !isPickerOpen);\n const title = props.title ?? moduleMessages.pageTitle;\n return (\n <>\n {props.hideLauncher ? null : (\n <Launcher label={props.launcherLabel ?? title} open={open} controls={layerId} onClick={toggle}\n launcherRef={launcherRef} />\n )}\n <section ref={layerRef} id={layerId} className={moduleClass('page', props.className)}\n dir={moduleMessages.dir} role=\"dialog\" aria-modal=\"true\" aria-labelledby={titleId} tabIndex={-1}\n hidden={!open}>\n <div className=\"aic-page-column\">\n <ChatFrame module={props} chat={chat} title={title} titleId={titleId} fieldRef={fieldRef}\n onClose={close} />\n </div>\n </section>\n </>\n );\n}\n"]}
1
+ {"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,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAC3F,WAAW,EAAE,WAAW,GAAI,CAC/B,EACD,kBAAS,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,EAClF,GAAG,EAAE,cAAc,CAAC,GAAG,EAAE,IAAI,EAAC,QAAQ,gBAAY,MAAM,qBAAkB,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAC/F,MAAM,EAAE,CAAC,IAAI,YACb,cAAK,SAAS,EAAC,iBAAiB,YAC9B,KAAC,SAAS,IAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EACtF,OAAO,EAAE,KAAK,GAAI,GAChB,GACE,IACT,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// A full page AI mode: the chat takes the whole window over the site, in one centred column, with\n// the page's scroll held and the focus kept inside until the visitor closes it. It opens from its\n// own button, placed where the site renders the module, or from the site's own through `open`.\n\nimport { useAiConnect } from '../AiConnectProvider.tsx';\nimport { Launcher } from './Launcher.tsx';\nimport { ChatFrame } from './parts/ChatFrame.tsx';\nimport { moduleClass } from './parts/moduleClass.ts';\nimport { useModuleChat } from './parts/useModuleChat.ts';\nimport { useModuleHandle } from './parts/useModuleHandle.ts';\nimport type { AiModuleProps, AiOverlayProps } from './types.ts';\nimport { useFocusTrap, useOverlay } from './useOverlay.ts';\n\nexport interface AiChatPageProps extends AiModuleProps, AiOverlayProps {}\n\nexport function AiChatPage({ ref, ...props }: AiChatPageProps) {\n const { moduleMessages, isPickerOpen } = useAiConnect();\n const chat = useModuleChat(props);\n const {\n open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId,\n } = useOverlay(props, 'always');\n useModuleHandle(ref, chat.ask, show);\n // The connect window opens over the page mode and keeps the focus while it is open.\n useFocusTrap(layerRef, open && !isPickerOpen);\n const title = props.title ?? moduleMessages.pageTitle;\n return (\n <>\n {props.hideLauncher ? null : (\n <Launcher label={props.launcherLabel ?? title} open={open} controls={layerId} onClick={toggle}\n launcherRef={launcherRef} />\n )}\n <section ref={layerRef} id={layerId} className={moduleClass('page', props.className)}\n dir={moduleMessages.dir} role=\"dialog\" aria-modal=\"true\" aria-labelledby={titleId} tabIndex={-1}\n hidden={!open}>\n <div className=\"aic-page-column\">\n <ChatFrame module={props} chat={chat} title={title} titleId={titleId} fieldRef={fieldRef}\n onClose={close} />\n </div>\n </section>\n </>\n );\n}\n"]}
@@ -2,8 +2,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  // A chat docked in a side panel at the page's edge. It opens from its own button, placed where the
3
3
  // site renders the module, or from the site's own button through `open`. The page stays usable
4
4
  // beside it, and the conversation stays while the panel is closed. The panel docks on the right in
5
- // left to right languages and on the left in right to left ones, and takes the whole screen on a
6
- // phone.
5
+ // left to right languages and on the left in right to left ones. On a phone it takes the whole
6
+ // screen, and the page behind it holds its scroll while it is open.
7
7
  import { useAiConnect } from "../AiConnectProvider.js";
8
8
  import { Launcher } from "./Launcher.js";
9
9
  import { ChatFrame } from "./parts/ChatFrame.js";
@@ -14,7 +14,7 @@ import { useOverlay } from "./useOverlay.js";
14
14
  export function AiChatPanel({ ref, ...props }) {
15
15
  const { moduleMessages } = useAiConnect();
16
16
  const chat = useModuleChat(props);
17
- const { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId } = useOverlay(props);
17
+ const { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId, } = useOverlay(props, 'phone');
18
18
  useModuleHandle(ref, chat.ask, show);
19
19
  const title = props.title ?? moduleMessages.title;
20
20
  return (_jsxs(_Fragment, { children: [props.hideLauncher ? null : (_jsx(Launcher, { label: props.launcherLabel ?? title, open: open, controls: layerId, onClick: toggle, launcherRef: launcherRef })), _jsx("section", { ref: layerRef, id: layerId, className: moduleClass('panel', props.className), dir: moduleMessages.dir, role: "dialog", "aria-labelledby": titleId, tabIndex: -1, hidden: !open, children: _jsx(ChatFrame, { module: props, chat: chat, title: title, titleId: titleId, fieldRef: fieldRef, onClose: close }) })] }));
@@ -1 +1 @@
1
- {"version":3,"file":"AiChatPanel.js","sourceRoot":"","sources":["../../src/modules/AiChatPanel.tsx"],"names":[],"mappings":";AAAA,mGAAmG;AACnG,+FAA+F;AAC/F,mGAAmG;AACnG,iGAAiG;AACjG,SAAS;AAET,OAAO,EAAE,YAAY,EAAE,MAAM,yBAA0B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAuB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,MAAM,UAAU,WAAW,CAAC,EAAE,GAAG,EAAE,GAAG,KAAK,EAAoB;IAC7D,MAAM,EAAE,cAAc,EAAE,GAAG,YAAY,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3G,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,cAAc,CAAC,KAAK,CAAC;IAClD,OAAO,CACL,8BACG,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC3B,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,aAAa,IAAI,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAC3F,WAAW,EAAE,WAAW,GAAI,CAC/B,EACD,kBAAS,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,EACnF,GAAG,EAAE,cAAc,CAAC,GAAG,EAAE,IAAI,EAAC,QAAQ,qBAAkB,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,YAC5F,KAAC,SAAS,IAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EACtF,OAAO,EAAE,KAAK,GAAI,GACZ,IACT,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// A chat docked in a side panel at the page's edge. It opens from its own button, placed where the\n// site renders the module, or from the site's own button through `open`. The page stays usable\n// beside it, and the conversation stays while the panel is closed. The panel docks on the right in\n// left to right languages and on the left in right to left ones, and takes the whole screen on a\n// phone.\n\nimport { useAiConnect } from '../AiConnectProvider.tsx';\nimport { Launcher } from './Launcher.tsx';\nimport { ChatFrame } from './parts/ChatFrame.tsx';\nimport { moduleClass } from './parts/moduleClass.ts';\nimport { useModuleChat } from './parts/useModuleChat.ts';\nimport { useModuleHandle } from './parts/useModuleHandle.ts';\nimport type { AiModuleProps, AiOverlayProps } from './types.ts';\nimport { useOverlay } from './useOverlay.ts';\n\nexport interface AiChatPanelProps extends AiModuleProps, AiOverlayProps {}\n\nexport function AiChatPanel({ ref, ...props }: AiChatPanelProps) {\n const { moduleMessages } = useAiConnect();\n const chat = useModuleChat(props);\n const { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId } = useOverlay(props);\n useModuleHandle(ref, chat.ask, show);\n const title = props.title ?? moduleMessages.title;\n return (\n <>\n {props.hideLauncher ? null : (\n <Launcher label={props.launcherLabel ?? title} open={open} controls={layerId} onClick={toggle}\n launcherRef={launcherRef} />\n )}\n <section ref={layerRef} id={layerId} className={moduleClass('panel', props.className)}\n dir={moduleMessages.dir} role=\"dialog\" aria-labelledby={titleId} tabIndex={-1} hidden={!open}>\n <ChatFrame module={props} chat={chat} title={title} titleId={titleId} fieldRef={fieldRef}\n onClose={close} />\n </section>\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"AiChatPanel.js","sourceRoot":"","sources":["../../src/modules/AiChatPanel.tsx"],"names":[],"mappings":";AAAA,mGAAmG;AACnG,+FAA+F;AAC/F,mGAAmG;AACnG,+FAA+F;AAC/F,oEAAoE;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAA0B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAuB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,MAAM,UAAU,WAAW,CAAC,EAAE,GAAG,EAAE,GAAG,KAAK,EAAoB;IAC7D,MAAM,EAAE,cAAc,EAAE,GAAG,YAAY,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,EACJ,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAC7E,GAAG,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC/B,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,cAAc,CAAC,KAAK,CAAC;IAClD,OAAO,CACL,8BACG,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC3B,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,aAAa,IAAI,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAC3F,WAAW,EAAE,WAAW,GAAI,CAC/B,EACD,kBAAS,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,EACnF,GAAG,EAAE,cAAc,CAAC,GAAG,EAAE,IAAI,EAAC,QAAQ,qBAAkB,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,YAC5F,KAAC,SAAS,IAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EACtF,OAAO,EAAE,KAAK,GAAI,GACZ,IACT,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// A chat docked in a side panel at the page's edge. It opens from its own button, placed where the\n// site renders the module, or from the site's own button through `open`. The page stays usable\n// beside it, and the conversation stays while the panel is closed. The panel docks on the right in\n// left to right languages and on the left in right to left ones. On a phone it takes the whole\n// screen, and the page behind it holds its scroll while it is open.\n\nimport { useAiConnect } from '../AiConnectProvider.tsx';\nimport { Launcher } from './Launcher.tsx';\nimport { ChatFrame } from './parts/ChatFrame.tsx';\nimport { moduleClass } from './parts/moduleClass.ts';\nimport { useModuleChat } from './parts/useModuleChat.ts';\nimport { useModuleHandle } from './parts/useModuleHandle.ts';\nimport type { AiModuleProps, AiOverlayProps } from './types.ts';\nimport { useOverlay } from './useOverlay.ts';\n\nexport interface AiChatPanelProps extends AiModuleProps, AiOverlayProps {}\n\nexport function AiChatPanel({ ref, ...props }: AiChatPanelProps) {\n const { moduleMessages } = useAiConnect();\n const chat = useModuleChat(props);\n const {\n open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId,\n } = useOverlay(props, 'phone');\n useModuleHandle(ref, chat.ask, show);\n const title = props.title ?? moduleMessages.title;\n return (\n <>\n {props.hideLauncher ? null : (\n <Launcher label={props.launcherLabel ?? title} open={open} controls={layerId} onClick={toggle}\n launcherRef={launcherRef} />\n )}\n <section ref={layerRef} id={layerId} className={moduleClass('panel', props.className)}\n dir={moduleMessages.dir} role=\"dialog\" aria-labelledby={titleId} tabIndex={-1} hidden={!open}>\n <ChatFrame module={props} chat={chat} title={title} titleId={titleId} fieldRef={fieldRef}\n onClose={close} />\n </section>\n </>\n );\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  // A floating button at the page's corner that opens a chat popup above it. The button shows the
3
3
  // wallet's wave mark and turns into a close mark while the popup is open. The popup sits in the
4
- // bottom right corner in left to right languages and in the bottom left in right to left ones, and
5
- // takes the whole screen on a phone.
4
+ // bottom right corner in left to right languages and in the bottom left in right to left ones. On a
5
+ // phone it takes the whole screen, and the page behind it holds its scroll while it is open.
6
6
  import { useAiConnect } from "../AiConnectProvider.js";
7
7
  import { ChatFrame } from "./parts/ChatFrame.js";
8
8
  import { moduleClass } from "./parts/moduleClass.js";
@@ -13,7 +13,7 @@ import { useOverlay } from "./useOverlay.js";
13
13
  export function AiChatPopup({ ref, ...props }) {
14
14
  const { moduleMessages } = useAiConnect();
15
15
  const chat = useModuleChat(props);
16
- const { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId } = useOverlay(props);
16
+ const { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId, } = useOverlay(props, 'phone');
17
17
  useModuleHandle(ref, chat.ask, show);
18
18
  const label = props.launcherLabel ?? (open ? moduleMessages.closeChat : moduleMessages.openChat);
19
19
  return (_jsxs(_Fragment, { children: [_jsx("section", { ref: layerRef, id: layerId, className: moduleClass('popup', props.className), dir: moduleMessages.dir, role: "dialog", "aria-labelledby": titleId, tabIndex: -1, hidden: !open, children: _jsx(ChatFrame, { module: props, chat: chat, title: props.title ?? moduleMessages.title, titleId: titleId, fieldRef: fieldRef, onClose: close }) }), props.hideLauncher ? null : (_jsxs("button", { ref: launcherRef, type: "button", className: "aic-fab", dir: moduleMessages.dir, "aria-label": label, title: label, "aria-expanded": open, "aria-controls": layerId, "data-open": open || undefined, "data-live": chat.busy || undefined, onClick: toggle, children: [_jsx(WaveIcon, { size: 26, className: "aic-fab-wave" }), _jsx("span", { className: "aic-fab-close", children: _jsx(CloseIcon, {}) })] }))] }));
@@ -1 +1 @@
1
- {"version":3,"file":"AiChatPopup.js","sourceRoot":"","sources":["../../src/modules/AiChatPopup.tsx"],"names":[],"mappings":";AAAA,gGAAgG;AAChG,gGAAgG;AAChG,mGAAmG;AACnG,qCAAqC;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAA0B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAuB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAmB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,MAAM,UAAU,WAAW,CAAC,EAAE,GAAG,EAAE,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B,IAAI,mBAAiB,OAAO,eAAa,IAAI,IAAI,SAAS,eAC5E,IAAI,CAAC,IAAI,IAAI,SAAS,EAAE,OAAO,EAAE,MAAM,aAClD,KAAC,QAAQ,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,cAAc,GAAG,EAC/C,eAAM,SAAS,EAAC,eAAe,YAAC,KAAC,SAAS,KAAG,GAAO,IAC7C,CACV,IACA,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// A floating button at the page's corner that opens a chat popup above it. The button shows the\n// wallet's wave mark and turns into a close mark while the popup is open. The popup sits in the\n// bottom right corner in left to right languages and in the bottom left in right to left ones, and\n// takes the whole screen on a phone.\n\nimport { useAiConnect } from '../AiConnectProvider.tsx';\nimport { ChatFrame } from './parts/ChatFrame.tsx';\nimport { moduleClass } from './parts/moduleClass.ts';\nimport { CloseIcon, WaveIcon } from './parts/icons.tsx';\nimport { useModuleChat } from './parts/useModuleChat.ts';\nimport { useModuleHandle } from './parts/useModuleHandle.ts';\nimport type { AiModuleProps, AiOverlayProps } from './types.ts';\nimport { useOverlay } from './useOverlay.ts';\n\nexport interface AiChatPopupProps extends AiModuleProps, AiOverlayProps {}\n\nexport function AiChatPopup({ ref, ...props }: AiChatPopupProps) {\n const { moduleMessages } = useAiConnect();\n const chat = useModuleChat(props);\n const { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId } = useOverlay(props);\n useModuleHandle(ref, chat.ask, show);\n const label = props.launcherLabel ?? (open ? moduleMessages.closeChat : moduleMessages.openChat);\n return (\n <>\n <section ref={layerRef} id={layerId} className={moduleClass('popup', props.className)}\n dir={moduleMessages.dir} role=\"dialog\" aria-labelledby={titleId} tabIndex={-1} hidden={!open}>\n <ChatFrame module={props} chat={chat} title={props.title ?? moduleMessages.title} titleId={titleId}\n fieldRef={fieldRef} onClose={close} />\n </section>\n {props.hideLauncher ? null : (\n <button ref={launcherRef} type=\"button\" className=\"aic-fab\" dir={moduleMessages.dir} aria-label={label}\n title={label} aria-expanded={open} aria-controls={layerId} data-open={open || undefined}\n data-live={chat.busy || undefined} onClick={toggle}>\n <WaveIcon size={26} className=\"aic-fab-wave\" />\n <span className=\"aic-fab-close\"><CloseIcon /></span>\n </button>\n )}\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"AiChatPopup.js","sourceRoot":"","sources":["../../src/modules/AiChatPopup.tsx"],"names":[],"mappings":";AAAA,gGAAgG;AAChG,gGAAgG;AAChG,oGAAoG;AACpG,6FAA6F;AAE7F,OAAO,EAAE,YAAY,EAAE,MAAM,yBAA0B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAuB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAmB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,MAAM,UAAU,WAAW,CAAC,EAAE,GAAG,EAAE,GAAG,KAAK,EAAoB;IAC7D,MAAM,EAAE,cAAc,EAAE,GAAG,YAAY,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,EACJ,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAC7E,GAAG,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC/B,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,KAAK,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IACjG,OAAO,CACL,8BACE,kBAAS,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,EACnF,GAAG,EAAE,cAAc,CAAC,GAAG,EAAE,IAAI,EAAC,QAAQ,qBAAkB,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,YAC5F,KAAC,SAAS,IAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAChG,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,GAAI,GAChC,EACT,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC3B,kBAAQ,GAAG,EAAE,WAAW,EAAE,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,SAAS,EAAC,GAAG,EAAE,cAAc,CAAC,GAAG,gBAAc,KAAK,EACpG,KAAK,EAAE,KAAK,mBAAiB,IAAI,mBAAiB,OAAO,eAAa,IAAI,IAAI,SAAS,eAC5E,IAAI,CAAC,IAAI,IAAI,SAAS,EAAE,OAAO,EAAE,MAAM,aAClD,KAAC,QAAQ,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,cAAc,GAAG,EAC/C,eAAM,SAAS,EAAC,eAAe,YAAC,KAAC,SAAS,KAAG,GAAO,IAC7C,CACV,IACA,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// A floating button at the page's corner that opens a chat popup above it. The button shows the\n// wallet's wave mark and turns into a close mark while the popup is open. The popup sits in the\n// bottom right corner in left to right languages and in the bottom left in right to left ones. On a\n// phone it takes the whole screen, and the page behind it holds its scroll while it is open.\n\nimport { useAiConnect } from '../AiConnectProvider.tsx';\nimport { ChatFrame } from './parts/ChatFrame.tsx';\nimport { moduleClass } from './parts/moduleClass.ts';\nimport { CloseIcon, WaveIcon } from './parts/icons.tsx';\nimport { useModuleChat } from './parts/useModuleChat.ts';\nimport { useModuleHandle } from './parts/useModuleHandle.ts';\nimport type { AiModuleProps, AiOverlayProps } from './types.ts';\nimport { useOverlay } from './useOverlay.ts';\n\nexport interface AiChatPopupProps extends AiModuleProps, AiOverlayProps {}\n\nexport function AiChatPopup({ ref, ...props }: AiChatPopupProps) {\n const { moduleMessages } = useAiConnect();\n const chat = useModuleChat(props);\n const {\n open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId,\n } = useOverlay(props, 'phone');\n useModuleHandle(ref, chat.ask, show);\n const label = props.launcherLabel ?? (open ? moduleMessages.closeChat : moduleMessages.openChat);\n return (\n <>\n <section ref={layerRef} id={layerId} className={moduleClass('popup', props.className)}\n dir={moduleMessages.dir} role=\"dialog\" aria-labelledby={titleId} tabIndex={-1} hidden={!open}>\n <ChatFrame module={props} chat={chat} title={props.title ?? moduleMessages.title} titleId={titleId}\n fieldRef={fieldRef} onClose={close} />\n </section>\n {props.hideLauncher ? null : (\n <button ref={launcherRef} type=\"button\" className=\"aic-fab\" dir={moduleMessages.dir} aria-label={label}\n title={label} aria-expanded={open} aria-controls={layerId} data-open={open || undefined}\n data-live={chat.busy || undefined} onClick={toggle}>\n <WaveIcon size={26} className=\"aic-fab-wave\" />\n <span className=\"aic-fab-close\"><CloseIcon /></span>\n </button>\n )}\n </>\n );\n}\n"]}
@@ -0,0 +1,11 @@
1
+ export declare const COVERS_SCREEN = "(max-width: 640px)";
2
+ export declare const COARSE_POINTER = "(pointer: coarse)";
3
+ type MatchMedia = (query: string) => Pick<MediaQueryList, 'matches' | 'addEventListener' | 'removeEventListener'>;
4
+ export interface MediaQueryStore {
5
+ subscribe: (onChange: () => void) => () => void;
6
+ getSnapshot: () => boolean;
7
+ }
8
+ export declare function mediaQueryStore(matchMedia: MatchMedia, query: string): MediaQueryStore;
9
+ export declare function useMediaQuery(query: string): boolean;
10
+ export declare function pointsByTouch(): boolean;
11
+ export {};
@@ -0,0 +1,30 @@
1
+ // The media conditions the modules that float over the page follow: whether the screen is narrow enough
2
+ // for the panel and the popup to cover it, and whether the visitor points by touch. A condition is read
3
+ // as a store, so a module follows a resize or a rotation while it is open.
4
+ import { useMemo, useSyncExternalStore } from 'react';
5
+ // The width under which the panel and the popup take the whole screen, the breakpoint of forms.css.
6
+ export const COVERS_SCREEN = '(max-width: 640px)';
7
+ // A touch screen, where focusing the question box opens the keyboard.
8
+ export const COARSE_POINTER = '(pointer: coarse)';
9
+ export function mediaQueryStore(matchMedia, query) {
10
+ return {
11
+ subscribe: (onChange) => {
12
+ const list = matchMedia(query);
13
+ list.addEventListener('change', onChange);
14
+ return () => list.removeEventListener('change', onChange);
15
+ },
16
+ getSnapshot: () => matchMedia(query).matches,
17
+ };
18
+ }
19
+ // Whether the page matches the query now. A page rendered on the server matches none, and the module
20
+ // follows the browser's answer once it hydrates.
21
+ export function useMediaQuery(query) {
22
+ const store = useMemo(() => mediaQueryStore((text) => window.matchMedia(text), query), [query]);
23
+ return useSyncExternalStore(store.subscribe, store.getSnapshot, () => false);
24
+ }
25
+ // Read once, when a module opens: a module opened by touch keeps the keyboard closed until the visitor
26
+ // taps the question box.
27
+ export function pointsByTouch() {
28
+ return window.matchMedia(COARSE_POINTER).matches;
29
+ }
30
+ //# sourceMappingURL=mediaQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mediaQuery.js","sourceRoot":"","sources":["../../src/modules/mediaQuery.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,wGAAwG;AACxG,2EAA2E;AAE3E,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAEtD,oGAAoG;AACpG,MAAM,CAAC,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAElD,sEAAsE;AACtE,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC;AASlD,MAAM,UAAU,eAAe,CAAC,UAAsB,EAAE,KAAa;IACnE,OAAO;QACL,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE;YACtB,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;YAC/B,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC1C,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC5D,CAAC;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO;KAC7C,CAAC;AACJ,CAAC;AAED,qGAAqG;AACrG,iDAAiD;AACjD,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAChG,OAAO,oBAAoB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AAC/E,CAAC;AAED,uGAAuG;AACvG,yBAAyB;AACzB,MAAM,UAAU,aAAa;IAC3B,OAAO,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC;AACnD,CAAC","sourcesContent":["// The media conditions the modules that float over the page follow: whether the screen is narrow enough\n// for the panel and the popup to cover it, and whether the visitor points by touch. A condition is read\n// as a store, so a module follows a resize or a rotation while it is open.\n\nimport { useMemo, useSyncExternalStore } from 'react';\n\n// The width under which the panel and the popup take the whole screen, the breakpoint of forms.css.\nexport const COVERS_SCREEN = '(max-width: 640px)';\n\n// A touch screen, where focusing the question box opens the keyboard.\nexport const COARSE_POINTER = '(pointer: coarse)';\n\ntype MatchMedia = (query: string) => Pick<MediaQueryList, 'matches' | 'addEventListener' | 'removeEventListener'>;\n\nexport interface MediaQueryStore {\n subscribe: (onChange: () => void) => () => void;\n getSnapshot: () => boolean;\n}\n\nexport function mediaQueryStore(matchMedia: MatchMedia, query: string): MediaQueryStore {\n return {\n subscribe: (onChange) => {\n const list = matchMedia(query);\n list.addEventListener('change', onChange);\n return () => list.removeEventListener('change', onChange);\n },\n getSnapshot: () => matchMedia(query).matches,\n };\n}\n\n// Whether the page matches the query now. A page rendered on the server matches none, and the module\n// follows the browser's answer once it hydrates.\nexport function useMediaQuery(query: string): boolean {\n const store = useMemo(() => mediaQueryStore((text) => window.matchMedia(text), query), [query]);\n return useSyncExternalStore(store.subscribe, store.getSnapshot, () => false);\n}\n\n// Read once, when a module opens: a module opened by touch keeps the keyboard closed until the visitor\n// taps the question box.\nexport function pointsByTouch(): boolean {\n return window.matchMedia(COARSE_POINTER).matches;\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import type { RefObject } from 'react';
2
+ export interface LockableStyle {
3
+ overflow: string;
4
+ overscrollBehavior: string;
5
+ }
6
+ export interface ScrollingView {
7
+ scrollX: number;
8
+ scrollY: number;
9
+ scrollTo: (options: ScrollToOptions) => void;
10
+ addEventListener: (type: 'scroll', listener: () => void) => void;
11
+ removeEventListener: (type: 'scroll', listener: () => void) => void;
12
+ }
13
+ export declare function lockPageScroll(style: LockableStyle, view: ScrollingView): () => void;
14
+ export declare function useScrollLock(enabled: boolean): void;
15
+ export declare const VIEWPORT_TOP = "--aic-viewport-top";
16
+ export declare const VIEWPORT_HEIGHT = "--aic-viewport-height";
17
+ type LayerStyle = Pick<CSSStyleDeclaration, 'setProperty' | 'removeProperty'>;
18
+ export declare function fitToViewport(style: LayerStyle, viewport: Pick<VisualViewport, 'offsetTop' | 'height'>): void;
19
+ export declare function releaseViewport(style: LayerStyle): void;
20
+ export declare function useViewportFit(layerRef: RefObject<HTMLElement | null>, enabled: boolean): void;
21
+ export declare function useCoveringLayer(layerRef: RefObject<HTMLElement | null>, covers: boolean): void;
22
+ export {};
@@ -0,0 +1,76 @@
1
+ // The page behind a module that covers the screen: the full page mode always, the panel and the popup on a
2
+ // phone. While the module covers it, the page holds its scroll, so a swipe on the module's header or past
3
+ // the end of its conversation leaves the page and the browser's address bar in place under the module.
4
+ // The module also follows the visual viewport, the part of the page the keyboard leaves visible, so the
5
+ // question box stays in view once the keyboard opens.
6
+ import { useEffect } from 'react';
7
+ // Holds the page's scroll and returns the release. Hidden overflow stops the visitor's swipes, and no
8
+ // overscroll keeps the address bar and the pull to refresh still. A scroll the page's own code or the
9
+ // browser makes meanwhile, such as a site's scrollBy or a pan towards a focused field, is put back at
10
+ // once, since hidden overflow leaves those possible. The release gives back the inline values the
11
+ // site had set and the visitor's scroll position.
12
+ export function lockPageScroll(style, view) {
13
+ const previous = { overflow: style.overflow, overscrollBehavior: style.overscrollBehavior };
14
+ const { scrollX, scrollY } = view;
15
+ // Instant, so a site's smooth scrolling never shows the page sliding back.
16
+ const hold = () => {
17
+ if (view.scrollX !== scrollX || view.scrollY !== scrollY) {
18
+ view.scrollTo({ left: scrollX, top: scrollY, behavior: 'instant' });
19
+ }
20
+ };
21
+ style.overflow = 'hidden';
22
+ style.overscrollBehavior = 'none';
23
+ view.addEventListener('scroll', hold);
24
+ return () => {
25
+ view.removeEventListener('scroll', hold);
26
+ style.overflow = previous.overflow;
27
+ style.overscrollBehavior = previous.overscrollBehavior;
28
+ hold();
29
+ };
30
+ }
31
+ export function useScrollLock(enabled) {
32
+ useEffect(() => {
33
+ if (!enabled) {
34
+ return undefined;
35
+ }
36
+ return lockPageScroll(document.documentElement.style, window);
37
+ }, [enabled]);
38
+ }
39
+ // The custom properties forms.css places a covering module with. Without them, the module fills the
40
+ // layout viewport as before.
41
+ export const VIEWPORT_TOP = '--aic-viewport-top';
42
+ export const VIEWPORT_HEIGHT = '--aic-viewport-height';
43
+ export function fitToViewport(style, viewport) {
44
+ style.setProperty(VIEWPORT_TOP, `${viewport.offsetTop}px`);
45
+ style.setProperty(VIEWPORT_HEIGHT, `${viewport.height}px`);
46
+ }
47
+ export function releaseViewport(style) {
48
+ style.removeProperty(VIEWPORT_TOP);
49
+ style.removeProperty(VIEWPORT_HEIGHT);
50
+ }
51
+ // Keeps the layer on the visual viewport while it covers the screen. The keyboard shrinks the visual
52
+ // viewport and the browser may scroll it, so both events place the layer again.
53
+ export function useViewportFit(layerRef, enabled) {
54
+ useEffect(() => {
55
+ const layer = layerRef.current;
56
+ const viewport = window.visualViewport;
57
+ if (!enabled || !layer || !viewport) {
58
+ return undefined;
59
+ }
60
+ const fit = () => fitToViewport(layer.style, viewport);
61
+ fit();
62
+ viewport.addEventListener('resize', fit);
63
+ viewport.addEventListener('scroll', fit);
64
+ return () => {
65
+ viewport.removeEventListener('resize', fit);
66
+ viewport.removeEventListener('scroll', fit);
67
+ releaseViewport(layer.style);
68
+ };
69
+ }, [layerRef, enabled]);
70
+ }
71
+ // Everything a module does while it covers the screen.
72
+ export function useCoveringLayer(layerRef, covers) {
73
+ useScrollLock(covers);
74
+ useViewportFit(layerRef, covers);
75
+ }
76
+ //# sourceMappingURL=pageLock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pageLock.js","sourceRoot":"","sources":["../../src/modules/pageLock.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,0GAA0G;AAC1G,uGAAuG;AACvG,wGAAwG;AACxG,sDAAsD;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAkBlC,sGAAsG;AACtG,sGAAsG;AACtG,sGAAsG;AACtG,kGAAkG;AAClG,kDAAkD;AAClD,MAAM,UAAU,cAAc,CAAC,KAAoB,EAAE,IAAmB;IACtE,MAAM,QAAQ,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAAE,CAAC;IAC5F,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAClC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AAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AACnC,CAAC","sourcesContent":["// The page behind a module that covers the screen: the full page mode always, the panel and the popup on a\n// phone. While the module covers it, the page holds its scroll, so a swipe on the module's header or past\n// the end of its conversation leaves the page and the browser's address bar in place under the module.\n// The module also follows the visual viewport, the part of the page the keyboard leaves visible, so the\n// question box stays in view once the keyboard opens.\n\nimport { useEffect } from 'react';\nimport type { RefObject } from 'react';\n\n// The root's inline style the lock sets and gives back.\nexport interface LockableStyle {\n overflow: string;\n overscrollBehavior: string;\n}\n\n// The window whose scroll the lock holds.\nexport interface ScrollingView {\n scrollX: number;\n scrollY: number;\n scrollTo: (options: ScrollToOptions) => void;\n addEventListener: (type: 'scroll', listener: () => void) => void;\n removeEventListener: (type: 'scroll', listener: () => void) => void;\n}\n\n// Holds the page's scroll and returns the release. Hidden overflow stops the visitor's swipes, and no\n// overscroll keeps the address bar and the pull to refresh still. A scroll the page's own code or the\n// browser makes meanwhile, such as a site's scrollBy or a pan towards a focused field, is put back at\n// once, since hidden overflow leaves those possible. The release gives back the inline values the\n// site had set and the visitor's scroll position.\nexport function lockPageScroll(style: LockableStyle, view: ScrollingView): () => void {\n const previous = { overflow: style.overflow, overscrollBehavior: style.overscrollBehavior };\n const { scrollX, scrollY } = view;\n // Instant, so a site's smooth scrolling never shows the page sliding back.\n const hold = () => {\n if (view.scrollX !== scrollX || view.scrollY !== scrollY) {\n view.scrollTo({ left: scrollX, top: scrollY, behavior: 'instant' });\n }\n };\n style.overflow = 'hidden';\n style.overscrollBehavior = 'none';\n view.addEventListener('scroll', hold);\n return () => {\n view.removeEventListener('scroll', hold);\n style.overflow = previous.overflow;\n style.overscrollBehavior = previous.overscrollBehavior;\n hold();\n };\n}\n\nexport function useScrollLock(enabled: boolean) {\n useEffect(() => {\n if (!enabled) {\n return undefined;\n }\n return lockPageScroll(document.documentElement.style, window);\n }, [enabled]);\n}\n\n// The custom properties forms.css places a covering module with. Without them, the module fills the\n// layout viewport as before.\nexport const VIEWPORT_TOP = '--aic-viewport-top';\nexport const VIEWPORT_HEIGHT = '--aic-viewport-height';\n\ntype LayerStyle = Pick<CSSStyleDeclaration, 'setProperty' | 'removeProperty'>;\n\nexport function fitToViewport(style: LayerStyle, viewport: Pick<VisualViewport, 'offsetTop' | 'height'>): void {\n style.setProperty(VIEWPORT_TOP, `${viewport.offsetTop}px`);\n style.setProperty(VIEWPORT_HEIGHT, `${viewport.height}px`);\n}\n\nexport function releaseViewport(style: LayerStyle): void {\n style.removeProperty(VIEWPORT_TOP);\n style.removeProperty(VIEWPORT_HEIGHT);\n}\n\n// Keeps the layer on the visual viewport while it covers the screen. The keyboard shrinks the visual\n// viewport and the browser may scroll it, so both events place the layer again.\nexport function useViewportFit(layerRef: RefObject<HTMLElement | null>, enabled: boolean) {\n useEffect(() => {\n const layer = layerRef.current;\n const viewport = window.visualViewport;\n if (!enabled || !layer || !viewport) {\n return undefined;\n }\n const fit = () => fitToViewport(layer.style, viewport);\n fit();\n viewport.addEventListener('resize', fit);\n viewport.addEventListener('scroll', fit);\n return () => {\n viewport.removeEventListener('resize', fit);\n viewport.removeEventListener('scroll', fit);\n releaseViewport(layer.style);\n };\n }, [layerRef, enabled]);\n}\n\n// Everything a module does while it covers the screen.\nexport function useCoveringLayer(layerRef: RefObject<HTMLElement | null>, covers: boolean) {\n useScrollLock(covers);\n useViewportFit(layerRef, covers);\n}\n"]}
@@ -1,13 +1,13 @@
1
1
  import type { RefObject } from 'react';
2
2
  import type { AiOverlayProps } from './types.ts';
3
+ export type OverlayCover = 'always' | 'phone';
3
4
  export interface OverlayRefs {
4
5
  layerRef: RefObject<HTMLElement | null>;
5
6
  fieldRef: RefObject<HTMLTextAreaElement | null>;
6
7
  launcherRef: RefObject<HTMLButtonElement | null>;
7
8
  }
8
9
  export declare function useFocusTrap(layerRef: RefObject<HTMLElement | null>, enabled: boolean): void;
9
- export declare function useScrollLock(enabled: boolean): void;
10
- export declare function useOverlay(props: AiOverlayProps): {
10
+ export declare function useOverlay(props: AiOverlayProps, cover: OverlayCover): {
11
11
  open: boolean;
12
12
  show: () => void;
13
13
  close: () => void;
@@ -1,9 +1,12 @@
1
1
  // How a module that floats over the page opens and closes: the open state, kept by the site or by
2
- // the module; Escape to close, which the connect window takes first while it is open; focus moved
3
- // to the question box on open and back to the module's button on close. The full page mode also
4
- // holds the page's scroll and keeps the focus inside while it is open.
2
+ // the module; Escape to close, which the connect window takes first while it is open; the page held
3
+ // behind the module while it covers the screen (pageLock.ts); focus moved into the module on open and
4
+ // back to the module's button on close. The full page mode also keeps the focus inside while it is
5
+ // open.
5
6
  import { useCallback, useEffect, useId, useRef, useState } from 'react';
6
7
  import { useAiConnect } from "../AiConnectProvider.js";
8
+ import { COVERS_SCREEN, pointsByTouch, useMediaQuery } from "./mediaQuery.js";
9
+ import { useCoveringLayer } from "./pageLock.js";
7
10
  const FOCUSABLE = 'a[href], button:not([disabled]), textarea, input, [tabindex]:not([tabindex="-1"])';
8
11
  function useOpenState({ open, defaultOpen = false, onOpenChange }) {
9
12
  const [own, setOwn] = useState(defaultOpen);
@@ -28,8 +31,9 @@ function useEscape(open, close) {
28
31
  return () => document.removeEventListener('keydown', onKey);
29
32
  }, [open, isPickerOpen, close]);
30
33
  }
31
- // On open the focus moves to the question box; on close it goes back to the module's button, or, for a
32
- // module the site opened from its own control, to the element that held it before.
34
+ // On open the focus moves to the question box, or to the module itself on a touch screen, where the
35
+ // box would open the keyboard before the visitor asks for it. On close it goes back to the module's
36
+ // button, or, for a module the site opened from its own control, to the element that held it before.
33
37
  function useFocusOnOpen(open, { layerRef, fieldRef, launcherRef }) {
34
38
  const wasOpen = useRef(open);
35
39
  const opener = useRef(null);
@@ -40,7 +44,7 @@ function useFocusOnOpen(open, { layerRef, fieldRef, launcherRef }) {
40
44
  wasOpen.current = open;
41
45
  if (open) {
42
46
  opener.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
43
- (fieldRef.current ?? layerRef.current)?.focus();
47
+ (pointsByTouch() ? layerRef.current : fieldRef.current ?? layerRef.current)?.focus();
44
48
  }
45
49
  else {
46
50
  (launcherRef.current ?? opener.current)?.focus();
@@ -72,20 +76,7 @@ export function useFocusTrap(layerRef, enabled) {
72
76
  return () => layer.removeEventListener('keydown', onKey);
73
77
  }, [layerRef, enabled]);
74
78
  }
75
- export function useScrollLock(enabled) {
76
- useEffect(() => {
77
- if (!enabled) {
78
- return undefined;
79
- }
80
- const root = document.documentElement;
81
- const previous = root.style.overflow;
82
- root.style.overflow = 'hidden';
83
- return () => {
84
- root.style.overflow = previous;
85
- };
86
- }, [enabled]);
87
- }
88
- export function useOverlay(props) {
79
+ export function useOverlay(props, cover) {
89
80
  const [open, setOpen] = useOpenState(props);
90
81
  const layerRef = useRef(null);
91
82
  const fieldRef = useRef(null);
@@ -96,6 +87,9 @@ export function useOverlay(props) {
96
87
  const close = useCallback(() => setOpen(false), [setOpen]);
97
88
  const toggle = useCallback(() => setOpen(!open), [setOpen, open]);
98
89
  useEscape(open, close);
90
+ // The page is held before the focus moves, so the position the lock gives back is the visitor's.
91
+ const phone = useMediaQuery(COVERS_SCREEN);
92
+ useCoveringLayer(layerRef, open && (cover === 'always' || phone));
99
93
  useFocusOnOpen(open, { layerRef, fieldRef, launcherRef });
100
94
  return { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId };
101
95
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useOverlay.js","sourceRoot":"","sources":["../../src/modules/useOverlay.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,kGAAkG;AAClG,gGAAgG;AAChG,uEAAuE;AAEvE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAA0B,CAAC;AAGxD,MAAM,SAAS,GAAG,mFAAmF,CAAC;AAQtG,SAAS,YAAY,CAAC,EAAE,IAAI,EAAE,WAAW,GAAG,KA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IAC3C,MAAM,QAAQ,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAC;IACnD,MAAM,WAAW,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;IACxB,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;IACxB,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAClE,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvB,cAAc,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;IAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC1F,CAAC","sourcesContent":["// How a module that floats over the page opens and closes: the open state, kept by the site or by\n// the module; Escape to close, which the connect window takes first while it is open; focus moved\n// to the question box on open and back to the module's button on close. The full page mode also\n// holds the page's scroll and keeps the focus inside while it is open.\n\nimport { useCallback, useEffect, useId, useRef, useState } from 'react';\nimport type { RefObject } from 'react';\nimport { useAiConnect } from '../AiConnectProvider.tsx';\nimport type { AiOverlayProps } from './types.ts';\n\nconst FOCUSABLE = 'a[href], button:not([disabled]), textarea, input, [tabindex]:not([tabindex=\"-1\"])';\n\nexport interface OverlayRefs {\n layerRef: RefObject<HTMLElement | null>;\n fieldRef: RefObject<HTMLTextAreaElement | null>;\n launcherRef: RefObject<HTMLButtonElement | null>;\n}\n\nfunction useOpenState({ open, defaultOpen = false, onOpenChange }: AiOverlayProps) {\n const [own, setOwn] = useState(defaultOpen);\n const setOpen = useCallback((next: boolean) => {\n setOwn(next);\n onOpenChange?.(next);\n }, [onOpenChange]);\n return [open ?? own, setOpen] as const;\n}\n\nfunction useEscape(open: boolean, close: () => void) {\n const { isPickerOpen } = useAiConnect();\n useEffect(() => {\n if (!open || isPickerOpen) {\n return undefined;\n }\n const onKey = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n close();\n }\n };\n document.addEventListener('keydown', onKey);\n return () => document.removeEventListener('keydown', onKey);\n }, [open, isPickerOpen, close]);\n}\n\n// On open the focus moves to the question box; on close it goes back to the module's button, or, for a\n// module the site opened from its own control, to the element that held it before.\nfunction useFocusOnOpen(open: boolean, { layerRef, fieldRef, launcherRef }: OverlayRefs) {\n const wasOpen = useRef(open);\n const opener = useRef<HTMLElement | null>(null);\n useEffect(() => {\n if (open === wasOpen.current) {\n return;\n }\n wasOpen.current = open;\n if (open) {\n opener.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n (fieldRef.current ?? layerRef.current)?.focus();\n } else {\n (launcherRef.current ?? opener.current)?.focus();\n }\n }, [open, layerRef, fieldRef, launcherRef]);\n}\n\n// The element with focus, read from the layer's own root so it works inside a shadow root too.\nfunction activeElement(layer: HTMLElement): Element | null {\n return (layer.getRootNode() as Document | ShadowRoot).activeElement;\n}\n\nexport function useFocusTrap(layerRef: RefObject<HTMLElement | null>, enabled: boolean) {\n useEffect(() => {\n const layer = layerRef.current;\n if (!enabled || !layer) {\n return undefined;\n }\n const onKey = (event: KeyboardEvent) => {\n const focusable = [...layer.querySelectorAll<HTMLElement>(FOCUSABLE)];\n if (event.key !== 'Tab' || focusable.length === 0) {\n return;\n }\n const edge = event.shiftKey ? focusable[0] : focusable[focusable.length - 1];\n if (activeElement(layer) === edge) {\n event.preventDefault();\n (event.shiftKey ? focusable[focusable.length - 1] : focusable[0]).focus();\n }\n };\n layer.addEventListener('keydown', onKey);\n return () => layer.removeEventListener('keydown', onKey);\n }, [layerRef, enabled]);\n}\n\nexport function useScrollLock(enabled: boolean) {\n useEffect(() => {\n if (!enabled) {\n return undefined;\n }\n const root = document.documentElement;\n const previous = root.style.overflow;\n root.style.overflow = 'hidden';\n return () => {\n root.style.overflow = previous;\n };\n }, [enabled]);\n}\n\nexport function useOverlay(props: AiOverlayProps) {\n const [open, setOpen] = useOpenState(props);\n const layerRef = useRef<HTMLElement>(null);\n const fieldRef = useRef<HTMLTextAreaElement>(null);\n const launcherRef = useRef<HTMLButtonElement>(null);\n const titleId = useId();\n const layerId = useId();\n const show = useCallback(() => setOpen(true), [setOpen]);\n const close = useCallback(() => setOpen(false), [setOpen]);\n const toggle = useCallback(() => setOpen(!open), [setOpen, open]);\n useEscape(open, close);\n useFocusOnOpen(open, { layerRef, fieldRef, launcherRef });\n return { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId };\n}\n"]}
1
+ {"version":3,"file":"useOverlay.js","sourceRoot":"","sources":["../../src/modules/useOverlay.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,oGAAoG;AACpG,sGAAsG;AACtG,mGAAmG;AACnG,QAAQ;AAER,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAA0B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAOjD,MAAM,SAAS,GAAG,mFAAmF,CAAC;AAQtG,SAAS,YAAY,CAAC,EAAE,IAAI,EAAE,WAAW,GAAG,KAAK,EAAE,YAAY,EAAkB;IAC/E,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,G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M,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAClE,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvB,iGAAiG;IACjG,MAAM,KAAK,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;IAC3C,gBAAgB,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC;IAClE,cAAc,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;IAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC1F,CAAC","sourcesContent":["// How a module that floats over the page opens and closes: the open state, kept by the site or by\n// the module; Escape to close, which the connect window takes first while it is open; the page held\n// behind the module while it covers the screen (pageLock.ts); focus moved into the module on open and\n// back to the module's button on close. The full page mode also keeps the focus inside while it is\n// open.\n\nimport { useCallback, useEffect, useId, useRef, useState } from 'react';\nimport type { RefObject } from 'react';\nimport { useAiConnect } from '../AiConnectProvider.tsx';\nimport { COVERS_SCREEN, pointsByTouch, useMediaQuery } from './mediaQuery.ts';\nimport { useCoveringLayer } from './pageLock.ts';\nimport type { AiOverlayProps } from './types.ts';\n\n// When a module covers the screen: the full page mode always, the panel and the popup on a phone, where\n// forms.css gives them the whole screen. On a wider screen the page beside them stays usable.\nexport type OverlayCover = 'always' | 'phone';\n\nconst FOCUSABLE = 'a[href], button:not([disabled]), textarea, input, [tabindex]:not([tabindex=\"-1\"])';\n\nexport interface OverlayRefs {\n layerRef: RefObject<HTMLElement | null>;\n fieldRef: RefObject<HTMLTextAreaElement | null>;\n launcherRef: RefObject<HTMLButtonElement | null>;\n}\n\nfunction useOpenState({ open, defaultOpen = false, onOpenChange }: AiOverlayProps) {\n const [own, setOwn] = useState(defaultOpen);\n const setOpen = useCallback((next: boolean) => {\n setOwn(next);\n onOpenChange?.(next);\n }, [onOpenChange]);\n return [open ?? own, setOpen] as const;\n}\n\nfunction useEscape(open: boolean, close: () => void) {\n const { isPickerOpen } = useAiConnect();\n useEffect(() => {\n if (!open || isPickerOpen) {\n return undefined;\n }\n const onKey = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n close();\n }\n };\n document.addEventListener('keydown', onKey);\n return () => document.removeEventListener('keydown', onKey);\n }, [open, isPickerOpen, close]);\n}\n\n// On open the focus moves to the question box, or to the module itself on a touch screen, where the\n// box would open the keyboard before the visitor asks for it. On close it goes back to the module's\n// button, or, for a module the site opened from its own control, to the element that held it before.\nfunction useFocusOnOpen(open: boolean, { layerRef, fieldRef, launcherRef }: OverlayRefs) {\n const wasOpen = useRef(open);\n const opener = useRef<HTMLElement | null>(null);\n useEffect(() => {\n if (open === wasOpen.current) {\n return;\n }\n wasOpen.current = open;\n if (open) {\n opener.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n (pointsByTouch() ? layerRef.current : fieldRef.current ?? layerRef.current)?.focus();\n } else {\n (launcherRef.current ?? opener.current)?.focus();\n }\n }, [open, layerRef, fieldRef, launcherRef]);\n}\n\n// The element with focus, read from the layer's own root so it works inside a shadow root too.\nfunction activeElement(layer: HTMLElement): Element | null {\n return (layer.getRootNode() as Document | ShadowRoot).activeElement;\n}\n\nexport function useFocusTrap(layerRef: RefObject<HTMLElement | null>, enabled: boolean) {\n useEffect(() => {\n const layer = layerRef.current;\n if (!enabled || !layer) {\n return undefined;\n }\n const onKey = (event: KeyboardEvent) => {\n const focusable = [...layer.querySelectorAll<HTMLElement>(FOCUSABLE)];\n if (event.key !== 'Tab' || focusable.length === 0) {\n return;\n }\n const edge = event.shiftKey ? focusable[0] : focusable[focusable.length - 1];\n if (activeElement(layer) === edge) {\n event.preventDefault();\n (event.shiftKey ? focusable[focusable.length - 1] : focusable[0]).focus();\n }\n };\n layer.addEventListener('keydown', onKey);\n return () => layer.removeEventListener('keydown', onKey);\n }, [layerRef, enabled]);\n}\n\nexport function useOverlay(props: AiOverlayProps, cover: OverlayCover) {\n const [open, setOpen] = useOpenState(props);\n const layerRef = useRef<HTMLElement>(null);\n const fieldRef = useRef<HTMLTextAreaElement>(null);\n const launcherRef = useRef<HTMLButtonElement>(null);\n const titleId = useId();\n const layerId = useId();\n const show = useCallback(() => setOpen(true), [setOpen]);\n const close = useCallback(() => setOpen(false), [setOpen]);\n const toggle = useCallback(() => setOpen(!open), [setOpen, open]);\n useEscape(open, close);\n // The page is held before the focus moves, so the position the lock gives back is the visitor's.\n const phone = useMediaQuery(COVERS_SCREEN);\n useCoveringLayer(layerRef, open && (cover === 'always' || phone));\n useFocusOnOpen(open, { layerRef, fieldRef, launcherRef });\n return { open, show, close, toggle, layerRef, fieldRef, launcherRef, titleId, layerId };\n}\n"]}
package/dist/styles.css CHANGED
@@ -908,6 +908,7 @@
908
908
  caret-color: var(--aic-cyan);
909
909
  resize: none;
910
910
  overflow-y: hidden;
911
+ overscroll-behavior: contain;
911
912
  }
912
913
  :is(.aic-field-input, .aic-search-input):focus {
913
914
  outline: none;
@@ -1048,7 +1049,8 @@
1048
1049
  }
1049
1050
  .aic-page {
1050
1051
  position: fixed;
1051
- inset: 0;
1052
+ inset: var(--aic-viewport-top, 0px) 0 auto;
1053
+ height: var(--aic-viewport-height, 100%);
1052
1054
  z-index: var(--aic-layer);
1053
1055
  display: flex;
1054
1056
  justify-content: center;
@@ -1138,9 +1140,9 @@
1138
1140
  @media (max-width: 640px) {
1139
1141
  .aic-panel,
1140
1142
  .aic-popup {
1141
- inset: 0;
1143
+ inset: var(--aic-viewport-top, 0px) 0 auto;
1142
1144
  width: 100%;
1143
- height: 100%;
1145
+ height: var(--aic-viewport-height, 100%);
1144
1146
  border: 0;
1145
1147
  border-radius: 0;
1146
1148
  }
@@ -1511,6 +1513,7 @@ svg.aic-web-mark {
1511
1513
  width: min(var(--aic-width), 100%);
1512
1514
  max-height: calc(100dvh - 32px);
1513
1515
  overflow-y: auto;
1516
+ overscroll-behavior: contain;
1514
1517
  padding: 8px 20px 18px;
1515
1518
  border: 1px solid var(--aic-border);
1516
1519
  border-radius: var(--aic-radius);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tensorpass/aiconnect-react",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "React provider picker and chat hook for AI Connect.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -33,8 +33,8 @@
33
33
  "build": "rm -rf dist tsconfig.tsbuildinfo && tsc -b && esbuild src/styles.css --bundle --outfile=dist/styles.css --log-level=warning && cp src/modules/styles/launchers.css dist/launchers.css"
34
34
  },
35
35
  "dependencies": {
36
- "@tensorpass/aiconnect": "0.1.5",
37
- "@tensorpass/aiconnect-design": "0.1.5"
36
+ "@tensorpass/aiconnect": "0.1.6",
37
+ "@tensorpass/aiconnect-design": "0.1.6"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": ">=19"