@docsearch/sidepanel 4.4.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 ADDED
@@ -0,0 +1,51 @@
1
+ # @docsearch/sidepanel
2
+
3
+ React package for [DocSearch Sidepanel](http://docsearch.algolia.com/), a standalone Ask AI chat panel.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ yarn add @docsearch/core@4 @docsearch/sidepanel@4 @docsearch/css@4
9
+ # or
10
+ npm install @docsearch/core@4 @docsearch/sidepanel@4 @docsearch/css@4
11
+ ```
12
+
13
+ If you don’t want to use a package manager, you can use a standalone endpoint:
14
+
15
+ ```html
16
+ <script src="https://cdn.jsdelivr.net/npm/@docsearch/sidepanel-js"></script>
17
+ ```
18
+
19
+ ## Get started
20
+
21
+ DocSearch Sidepanel generates a fully accessible Ask AI chat panel for you.
22
+
23
+ ```jsx App.js
24
+ import { DocSearch } from '@docsearch/core';
25
+ import { SidepanelButton, Sidepanel } from '@docsearch/sidepanel';
26
+
27
+ // Or using individual imports:
28
+ // import { Sidepanel } from '@docsearch/sidepanel/sidepanel';
29
+ // import { SidepanelButton } from '@docsearch/sidepanel/button';
30
+
31
+ import '@docsearch/css/dist/style.css';
32
+ import '@docsearch/css/dist/sidepanel.css';
33
+
34
+ function App() {
35
+ return (
36
+ <DocSearch>
37
+ <SidepanelButton />
38
+ <Sidepanel
39
+ appId="YOUR_APP_ID"
40
+ indexName="YOUR_INDEX_NAME"
41
+ apiKey="YOUR_SEARCH_API_KEY"
42
+ assistantId="YOUR_ASK_AI_ASSISTANT_ID"
43
+ />
44
+ </DocSearch>
45
+ );
46
+ }
47
+ ```
48
+
49
+ ## Documentation
50
+
51
+ [Read documentation →](https://docsearch.algolia.com)
package/button.js ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/esm/SidepanelButton.js';
@@ -0,0 +1,8 @@
1
+ import { DocSearchSidepanelProps } from '@docsearch/react/sidepanel';
2
+ import { JSX } from 'react';
3
+
4
+ type SidepanelProps = DocSearchSidepanelProps['panel'] & Omit<DocSearchSidepanelProps, 'button' | 'panel' | 'theme'>;
5
+ declare function Sidepanel({ portalContainer, ...props }: SidepanelProps): JSX.Element;
6
+
7
+ export { Sidepanel };
8
+ export type { SidepanelProps };
@@ -0,0 +1 @@
1
+ import{useDocSearch as e}from"@docsearch/core";import{Sidepanel as r}from"@docsearch/react/sidepanel";import t from"react";import{createPortal as n}from"react-dom";function o(e,r,t){return(r=function(e){var r=function(e,r){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==typeof r?r:r+""}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function i(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}var c=["portalContainer"];function a(a){var u=a.portalContainer,f=function(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==r.indexOf(n))continue;t[n]=e[n]}return t}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],-1===r.indexOf(t)&&{}.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}(a,c),l=e(),s=l.docsearchState,p=l.setDocsearchState,b=l.keyboardShortcuts,y=l.registerView,m=l.initialAskAiMessage,O=t.useCallback(function(){p("sidepanel")},[p]),d=t.useCallback(function(){p("ready")},[p]),v=t.useMemo(function(){return null!=u?u:document.body},[u]);t.useEffect(function(){y("sidepanel")},[y]);var g=t.useMemo(function(){return function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?i(Object(t),!0).forEach(function(r){o(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):i(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}({isOpen:"sidepanel"===s,onOpen:O,onClose:d,keyboardShortcuts:b,initialMessage:m},f)},[s,O,d,f,b,m]);return n(t.createElement(r,g),v)}export{a as Sidepanel};
@@ -0,0 +1,10 @@
1
+ import { SidepanelButtonProps as SidepanelButtonProps$1 } from '@docsearch/react/sidepanel';
2
+ import { JSX } from 'react';
3
+
4
+ type SidepanelButtonProps = SidepanelButtonProps$1 & {
5
+ portalcontainer?: DocumentFragment | Element | null;
6
+ };
7
+ declare function SidepanelButton({ portalcontainer, ...props }: SidepanelButtonProps): JSX.Element;
8
+
9
+ export { SidepanelButton };
10
+ export type { SidepanelButtonProps };
@@ -0,0 +1 @@
1
+ import{useDocSearch as r}from"@docsearch/core";import{SidepanelButton as e}from"@docsearch/react/sidepanel";import n from"react";import{createPortal as t}from"react-dom";function o(){return o=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var t in n)({}).hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},o.apply(null,arguments)}var a=["portalcontainer"];function c(c){var i=c.portalcontainer,l=function(r,e){if(null==r)return{};var n,t,o=function(r,e){if(null==r)return{};var n={};for(var t in r)if({}.hasOwnProperty.call(r,t)){if(-1!==e.indexOf(t))continue;n[t]=r[t]}return n}(r,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);for(t=0;t<a.length;t++)n=a[t],-1===e.indexOf(n)&&{}.propertyIsEnumerable.call(r,n)&&(o[n]=r[n])}return o}(c,a),u=r(),f=u.setDocsearchState,s=u.keyboardShortcuts,p=u.docsearchState,d=n.useCallback(function(){f("sidepanel"===p?"ready":"sidepanel")},[p,f]),m=n.useMemo(function(){return null!=i?i:document.body},[i]),b=n.useMemo(function(){return n.createElement(e,o({keyboardShortcuts:s,onClick:d},l))},[s,l,d]);return"inline"===l.variant?b:t(b,m)}export{c as SidepanelButton};
@@ -0,0 +1,13 @@
1
+ import { SidepanelButtonProps as SidepanelButtonProps$1, DocSearchSidepanelProps } from '@docsearch/react/sidepanel';
2
+ import { JSX } from 'react';
3
+
4
+ type SidepanelButtonProps = SidepanelButtonProps$1 & {
5
+ portalcontainer?: DocumentFragment | Element | null;
6
+ };
7
+ declare function SidepanelButton({ portalcontainer, ...props }: SidepanelButtonProps): JSX.Element;
8
+
9
+ type SidepanelProps = DocSearchSidepanelProps['panel'] & Omit<DocSearchSidepanelProps, 'button' | 'panel' | 'theme'>;
10
+ declare function Sidepanel({ portalContainer, ...props }: SidepanelProps): JSX.Element;
11
+
12
+ export { Sidepanel, SidepanelButton };
13
+ export type { SidepanelButtonProps, SidepanelProps };
@@ -0,0 +1 @@
1
+ import{useDocSearch as e}from"@docsearch/core";import{SidepanelButton as r,Sidepanel as t}from"@docsearch/react/sidepanel";import n from"react";import{createPortal as o}from"react-dom";function i(e,r,t){return(r=function(e){var r=function(e,r){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==typeof r?r:r+""}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function a(){return a=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},a.apply(null,arguments)}function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function u(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==r.indexOf(n))continue;t[n]=e[n]}return t}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],-1===r.indexOf(t)&&{}.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var l=["portalcontainer"];function s(t){var i=t.portalcontainer,c=u(t,l),s=e(),f=s.setDocsearchState,p=s.keyboardShortcuts,b=s.docsearchState,y=n.useCallback(function(){f("sidepanel"===b?"ready":"sidepanel")},[b,f]),d=n.useMemo(function(){return null!=i?i:document.body},[i]),m=n.useMemo(function(){return n.createElement(r,a({keyboardShortcuts:p,onClick:y},c))},[p,c,y]);return"inline"===c.variant?m:o(m,d)}var f=["portalContainer"];function p(r){var a=r.portalContainer,l=u(r,f),s=e(),p=s.docsearchState,b=s.setDocsearchState,y=s.keyboardShortcuts,d=s.registerView,m=s.initialAskAiMessage,O=n.useCallback(function(){b("sidepanel")},[b]),v=n.useCallback(function(){b("ready")},[b]),g=n.useMemo(function(){return null!=a?a:document.body},[a]);n.useEffect(function(){d("sidepanel")},[d]);var h=n.useMemo(function(){return function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?c(Object(t),!0).forEach(function(r){i(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}({isOpen:"sidepanel"===p,onOpen:O,onClose:v,keyboardShortcuts:y,initialMessage:m},l)},[p,O,v,l,y,m]);return o(n.createElement(t,h),g)}export{p as Sidepanel,s as SidepanelButton};
@@ -0,0 +1,3 @@
1
+ /*! @docsearch/sidepanel 4.4.0 | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
2
+ !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@docsearch/core"),require("@docsearch/react/sidepanel"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","@docsearch/core","@docsearch/react/sidepanel","react","react-dom"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).DocSearchSidepanel={},e.DocSearchCore,e.sidepanel,e.React,e.ReactDOM)}(this,function(e,r,t,n,o){"use strict";function i(e,r,t){return(r=function(e){var r=function(e,r){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==typeof r?r:r+""}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}var a=["portalContainer"];e.Sidepanel=function(e){var u=e.portalContainer,l=function(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==r.indexOf(n))continue;t[n]=e[n]}return t}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],-1===r.indexOf(t)&&{}.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}(e,a),s=r.useDocSearch(),f=s.docsearchState,p=s.setDocsearchState,d=s.keyboardShortcuts,b=s.registerView,y=s.initialAskAiMessage,O=n.useCallback(function(){p("sidepanel")},[p]),m=n.useCallback(function(){p("ready")},[p]),h=n.useMemo(function(){return null!=u?u:document.body},[u]);n.useEffect(function(){b("sidepanel")},[b]);var v=n.useMemo(function(){return function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?c(Object(t),!0).forEach(function(r){i(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}({isOpen:"sidepanel"===f,onOpen:O,onClose:m,keyboardShortcuts:d,initialMessage:y},l)},[f,O,m,l,d,y]);return o.createPortal(n.createElement(t.Sidepanel,v),h)}});
3
+ //# sourceMappingURL=Sidepanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sidepanel.js","sources":["../../src/Sidepanel.tsx"],"sourcesContent":["import { useDocSearch } from '@docsearch/core';\nimport { Sidepanel as SidepanelComp, type DocSearchSidepanelProps } from '@docsearch/react/sidepanel';\nimport React from 'react';\nimport type { JSX } from 'react';\nimport { createPortal } from 'react-dom';\n\nexport type SidepanelProps = DocSearchSidepanelProps['panel'] &\n Omit<DocSearchSidepanelProps, 'button' | 'panel' | 'theme'>;\n\nexport function Sidepanel({ portalContainer, ...props }: SidepanelProps): JSX.Element {\n const { docsearchState, setDocsearchState, keyboardShortcuts, registerView, initialAskAiMessage } = useDocSearch();\n\n const handleOpen = React.useCallback((): void => {\n setDocsearchState('sidepanel');\n }, [setDocsearchState]);\n\n const handleClose = React.useCallback((): void => {\n setDocsearchState('ready');\n }, [setDocsearchState]);\n\n const containerElement = React.useMemo(() => portalContainer ?? document.body, [portalContainer]);\n\n React.useEffect(() => {\n registerView('sidepanel');\n }, [registerView]);\n\n const sidepanelProps = React.useMemo(\n () => ({\n isOpen: docsearchState === 'sidepanel',\n onOpen: handleOpen,\n onClose: handleClose,\n keyboardShortcuts,\n initialMessage: initialAskAiMessage,\n ...props,\n }),\n [docsearchState, handleOpen, handleClose, props, keyboardShortcuts, initialAskAiMessage],\n );\n\n return createPortal(<SidepanelComp {...sidepanelProps} />, containerElement);\n}\n"],"names":["_ref","portalContainer","props","_objectWithoutProperties","_excluded","_useDocSearch","useDocSearch","docsearchState","setDocsearchState","keyboardShortcuts","registerView","initialAskAiMessage","handleOpen","React","useCallback","handleClose","containerElement","useMemo","document","body","useEffect","sidepanelProps","_objectSpread","isOpen","onOpen","onClose","initialMessage","createPortal","createElement","SidepanelComp"],"mappings":";ypCASO,SAAkBA,GAA6D,IAA1DC,EAAeD,EAAfC,gBAAoBC,+WAAKC,CAAAH,EAAAI,GACnDC,EAAoGC,EAAAA,eAA5FC,EAAcF,EAAdE,eAAgBC,EAAiBH,EAAjBG,kBAAmBC,EAAiBJ,EAAjBI,kBAAmBC,EAAYL,EAAZK,aAAcC,EAAmBN,EAAnBM,oBAEtEC,EAAaC,EAAMC,YAAY,WACnCN,EAAkB,YACpB,EAAG,CAACA,IAEEO,EAAcF,EAAMC,YAAY,WACpCN,EAAkB,QACpB,EAAG,CAACA,IAEEQ,EAAmBH,EAAMI,QAAQ,WAAA,OAAMhB,QAAAA,EAAmBiB,SAASC,MAAM,CAAClB,IAEhFY,EAAMO,UAAU,WACdV,EAAa,YACf,EAAG,CAACA,IAEJ,IAAMW,EAAiBR,EAAMI,QAC3B,WAAA,kWAAAK,CAAA,CACEC,OAA2B,cAAnBhB,EACRiB,OAAQZ,EACRa,QAASV,EACTN,kBAAAA,EACAiB,eAAgBf,GACbT,EAAK,EAEV,CAACK,EAAgBK,EAAYG,EAAab,EAAOO,EAAmBE,IAGtE,OAAOgB,EAAAA,aAAad,EAAAe,cAACC,EAAAA,UAAkBR,GAAoBL,EAC7D"}
@@ -0,0 +1,3 @@
1
+ /*! @docsearch/sidepanel 4.4.0 | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
2
+ !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@docsearch/core"),require("@docsearch/react/sidepanel"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","@docsearch/core","@docsearch/react/sidepanel","react","react-dom"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).DocSearchSidepanel={},e.DocSearchCore,e.sidepanel,e.React,e.ReactDOM)}(this,function(e,r,n,t,o){"use strict";function a(){return a=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)({}).hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},a.apply(null,arguments)}var c=["portalcontainer"];e.SidepanelButton=function(e){var i=e.portalcontainer,u=function(e,r){if(null==e)return{};var n,t,o=function(e,r){if(null==e)return{};var n={};for(var t in e)if({}.hasOwnProperty.call(e,t)){if(-1!==r.indexOf(t))continue;n[t]=e[t]}return n}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(t=0;t<a.length;t++)n=a[t],-1===r.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,c),l=r.useDocSearch(),s=l.setDocsearchState,d=l.keyboardShortcuts,f=l.docsearchState,p=t.useCallback(function(){s("sidepanel"===f?"ready":"sidepanel")},[f,s]),h=t.useMemo(function(){return null!=i?i:document.body},[i]),y=t.useMemo(function(){return t.createElement(n.SidepanelButton,a({keyboardShortcuts:d,onClick:p},u))},[d,u,p]);return"inline"===u.variant?y:o.createPortal(y,h)}});
3
+ //# sourceMappingURL=SidepanelButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidepanelButton.js","sources":["../../src/SidepanelButton.tsx"],"sourcesContent":["import { useDocSearch } from '@docsearch/core';\nimport type { SidepanelButtonProps as ButtonProps } from '@docsearch/react/sidepanel';\nimport { SidepanelButton as Button } from '@docsearch/react/sidepanel';\nimport React from 'react';\nimport type { JSX } from 'react';\nimport { createPortal } from 'react-dom';\n\nexport type SidepanelButtonProps = ButtonProps & {\n portalcontainer?: DocumentFragment | Element | null;\n};\n\nexport function SidepanelButton({ portalcontainer, ...props }: SidepanelButtonProps): JSX.Element {\n const { setDocsearchState, keyboardShortcuts, docsearchState } = useDocSearch();\n\n const toggleSidepanelState = React.useCallback(() => {\n const nextState = docsearchState === 'sidepanel' ? 'ready' : 'sidepanel';\n setDocsearchState(nextState);\n }, [docsearchState, setDocsearchState]);\n\n const containerElement = React.useMemo(() => portalcontainer ?? document.body, [portalcontainer]);\n\n const ButtonComp = React.useMemo(\n () => <Button keyboardShortcuts={keyboardShortcuts} onClick={toggleSidepanelState} {...props} />,\n [keyboardShortcuts, props, toggleSidepanelState],\n );\n\n if (props.variant === 'inline') {\n return ButtonComp;\n }\n\n return createPortal(ButtonComp, containerElement);\n}\n"],"names":["_ref","portalcontainer","props","_objectWithoutProperties","_excluded","_useDocSearch","useDocSearch","setDocsearchState","keyboardShortcuts","docsearchState","toggleSidepanelState","React","useCallback","containerElement","useMemo","document","body","ButtonComp","createElement","Button","SidepanelButton","_extends","onClick","variant","createPortal"],"mappings":";8tBAWO,SAAwBA,GAAmE,IAAhEC,EAAeD,EAAfC,gBAAoBC,+WAAKC,CAAAH,EAAAI,GACzDC,EAAiEC,EAAAA,eAAzDC,EAAiBF,EAAjBE,kBAAmBC,EAAiBH,EAAjBG,kBAAmBC,EAAcJ,EAAdI,eAExCC,EAAuBC,EAAMC,YAAY,WAE7CL,EADqC,cAAnBE,EAAiC,QAAU,YAE/D,EAAG,CAACA,EAAgBF,IAEdM,EAAmBF,EAAMG,QAAQ,WAAA,OAAMb,QAAAA,EAAmBc,SAASC,MAAM,CAACf,IAE1EgB,EAAaN,EAAMG,QACvB,WAAA,OAAMH,EAAAO,cAACC,EAAMC,gBAAAC,EAAA,CAACb,kBAAmBA,EAAmBc,QAASZ,GAA0BR,GAAS,EAChG,CAACM,EAAmBN,EAAOQ,IAG7B,MAAsB,WAAlBR,EAAMqB,QACDN,EAGFO,EAAYA,aAACP,EAAYJ,EAClC"}
@@ -0,0 +1,3 @@
1
+ /*! @docsearch/sidepanel 4.4.0 | MIT License | © Algolia, Inc. and contributors | https://docsearch.algolia.com */
2
+ !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@docsearch/core"),require("@docsearch/react/sidepanel"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","@docsearch/core","@docsearch/react/sidepanel","react","react-dom"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).DocSearchSidepanel={},e.DocSearchCore,e.sidepanel,e.React,e.ReactDOM)}(this,function(e,r,t,n,o){"use strict";function a(e,r,t){return(r=function(e){var r=function(e,r){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==typeof r?r:r+""}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},i.apply(null,arguments)}function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function u(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==r.indexOf(n))continue;t[n]=e[n]}return t}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t=a[n],-1===r.indexOf(t)&&{}.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var l=["portalcontainer"];var s=["portalContainer"];e.Sidepanel=function(e){var i=e.portalContainer,l=u(e,s),f=r.useDocSearch(),p=f.docsearchState,d=f.setDocsearchState,b=f.keyboardShortcuts,y=f.registerView,O=f.initialAskAiMessage,h=n.useCallback(function(){d("sidepanel")},[d]),m=n.useCallback(function(){d("ready")},[d]),v=n.useMemo(function(){return null!=i?i:document.body},[i]);n.useEffect(function(){y("sidepanel")},[y]);var S=n.useMemo(function(){return function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?c(Object(t),!0).forEach(function(r){a(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}({isOpen:"sidepanel"===p,onOpen:h,onClose:m,keyboardShortcuts:b,initialMessage:O},l)},[p,h,m,l,b,O]);return o.createPortal(n.createElement(t.Sidepanel,S),v)},e.SidepanelButton=function(e){var a=e.portalcontainer,c=u(e,l),s=r.useDocSearch(),f=s.setDocsearchState,p=s.keyboardShortcuts,d=s.docsearchState,b=n.useCallback(function(){f("sidepanel"===d?"ready":"sidepanel")},[d,f]),y=n.useMemo(function(){return null!=a?a:document.body},[a]),O=n.useMemo(function(){return n.createElement(t.SidepanelButton,i({keyboardShortcuts:p,onClick:b},c))},[p,c,b]);return"inline"===c.variant?O:o.createPortal(O,y)}});
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/Sidepanel.tsx","../../src/SidepanelButton.tsx"],"sourcesContent":["import { useDocSearch } from '@docsearch/core';\nimport { Sidepanel as SidepanelComp, type DocSearchSidepanelProps } from '@docsearch/react/sidepanel';\nimport React from 'react';\nimport type { JSX } from 'react';\nimport { createPortal } from 'react-dom';\n\nexport type SidepanelProps = DocSearchSidepanelProps['panel'] &\n Omit<DocSearchSidepanelProps, 'button' | 'panel' | 'theme'>;\n\nexport function Sidepanel({ portalContainer, ...props }: SidepanelProps): JSX.Element {\n const { docsearchState, setDocsearchState, keyboardShortcuts, registerView, initialAskAiMessage } = useDocSearch();\n\n const handleOpen = React.useCallback((): void => {\n setDocsearchState('sidepanel');\n }, [setDocsearchState]);\n\n const handleClose = React.useCallback((): void => {\n setDocsearchState('ready');\n }, [setDocsearchState]);\n\n const containerElement = React.useMemo(() => portalContainer ?? document.body, [portalContainer]);\n\n React.useEffect(() => {\n registerView('sidepanel');\n }, [registerView]);\n\n const sidepanelProps = React.useMemo(\n () => ({\n isOpen: docsearchState === 'sidepanel',\n onOpen: handleOpen,\n onClose: handleClose,\n keyboardShortcuts,\n initialMessage: initialAskAiMessage,\n ...props,\n }),\n [docsearchState, handleOpen, handleClose, props, keyboardShortcuts, initialAskAiMessage],\n );\n\n return createPortal(<SidepanelComp {...sidepanelProps} />, containerElement);\n}\n","import { useDocSearch } from '@docsearch/core';\nimport type { SidepanelButtonProps as ButtonProps } from '@docsearch/react/sidepanel';\nimport { SidepanelButton as Button } from '@docsearch/react/sidepanel';\nimport React from 'react';\nimport type { JSX } from 'react';\nimport { createPortal } from 'react-dom';\n\nexport type SidepanelButtonProps = ButtonProps & {\n portalcontainer?: DocumentFragment | Element | null;\n};\n\nexport function SidepanelButton({ portalcontainer, ...props }: SidepanelButtonProps): JSX.Element {\n const { setDocsearchState, keyboardShortcuts, docsearchState } = useDocSearch();\n\n const toggleSidepanelState = React.useCallback(() => {\n const nextState = docsearchState === 'sidepanel' ? 'ready' : 'sidepanel';\n setDocsearchState(nextState);\n }, [docsearchState, setDocsearchState]);\n\n const containerElement = React.useMemo(() => portalcontainer ?? document.body, [portalcontainer]);\n\n const ButtonComp = React.useMemo(\n () => <Button keyboardShortcuts={keyboardShortcuts} onClick={toggleSidepanelState} {...props} />,\n [keyboardShortcuts, props, toggleSidepanelState],\n );\n\n if (props.variant === 'inline') {\n return ButtonComp;\n }\n\n return createPortal(ButtonComp, containerElement);\n}\n"],"names":["_ref","portalContainer","props","_objectWithoutProperties","_excluded","_useDocSearch","useDocSearch","docsearchState","setDocsearchState","keyboardShortcuts","registerView","initialAskAiMessage","handleOpen","React","useCallback","handleClose","containerElement","useMemo","document","body","useEffect","sidepanelProps","_objectSpread","isOpen","onOpen","onClose","initialMessage","createPortal","createElement","SidepanelComp","portalcontainer","toggleSidepanelState","ButtonComp","Button","SidepanelButton","_extends","onClick","variant"],"mappings":";0vDASO,SAAkBA,GAA6D,IAA1DC,EAAeD,EAAfC,gBAAoBC,EAAKC,EAAAH,EAAAI,GACnDC,EAAoGC,EAAAA,eAA5FC,EAAcF,EAAdE,eAAgBC,EAAiBH,EAAjBG,kBAAmBC,EAAiBJ,EAAjBI,kBAAmBC,EAAYL,EAAZK,aAAcC,EAAmBN,EAAnBM,oBAEtEC,EAAaC,EAAMC,YAAY,WACnCN,EAAkB,YACpB,EAAG,CAACA,IAEEO,EAAcF,EAAMC,YAAY,WACpCN,EAAkB,QACpB,EAAG,CAACA,IAEEQ,EAAmBH,EAAMI,QAAQ,WAAA,OAAMhB,QAAAA,EAAmBiB,SAASC,MAAM,CAAClB,IAEhFY,EAAMO,UAAU,WACdV,EAAa,YACf,EAAG,CAACA,IAEJ,IAAMW,EAAiBR,EAAMI,QAC3B,WAAA,kWAAAK,CAAA,CACEC,OAA2B,cAAnBhB,EACRiB,OAAQZ,EACRa,QAASV,EACTN,kBAAAA,EACAiB,eAAgBf,GACbT,EAAK,EAEV,CAACK,EAAgBK,EAAYG,EAAab,EAAOO,EAAmBE,IAGtE,OAAOgB,EAAAA,aAAad,EAAAe,cAACC,EAAAA,UAAkBR,GAAoBL,EAC7D,oBC5BO,SAAwBhB,GAAmE,IAAhE8B,EAAe9B,EAAf8B,gBAAoB5B,EAAKC,EAAAH,EAAAI,GACzDC,EAAiEC,EAAAA,eAAzDE,EAAiBH,EAAjBG,kBAAmBC,EAAiBJ,EAAjBI,kBAAmBF,EAAcF,EAAdE,eAExCwB,EAAuBlB,EAAMC,YAAY,WAE7CN,EADqC,cAAnBD,EAAiC,QAAU,YAE/D,EAAG,CAACA,EAAgBC,IAEdQ,EAAmBH,EAAMI,QAAQ,WAAA,OAAMa,QAAAA,EAAmBZ,SAASC,MAAM,CAACW,IAE1EE,EAAanB,EAAMI,QACvB,WAAA,OAAMJ,EAAAe,cAACK,EAAMC,gBAAAC,EAAA,CAAC1B,kBAAmBA,EAAmB2B,QAASL,GAA0B7B,GAAS,EAChG,CAACO,EAAmBP,EAAO6B,IAG7B,MAAsB,WAAlB7B,EAAMmC,QACDL,EAGFL,EAAYA,aAACK,EAAYhB,EAClC"}
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/esm/index.js';
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@docsearch/sidepanel",
3
+ "description": "DocSearch Sidepanel package for Ask AI.",
4
+ "version": "4.4.0",
5
+ "license": "MIT",
6
+ "homepage": "https://docsearch.algolia.com",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/algolia/docsearch.git",
10
+ "directory": "packages/docsearch-sidepanel"
11
+ },
12
+ "author": {
13
+ "name": "Algolia, Inc.",
14
+ "url": "https://www.algolia.com"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "sideEffects": false,
20
+ "files": [
21
+ "dist/",
22
+ "index.js",
23
+ "button.js",
24
+ "sidepanel.js",
25
+ "style/"
26
+ ],
27
+ "exports": {
28
+ ".": "./dist/esm/index.js",
29
+ "./button": "./dist/esm/SidepanelButton.js",
30
+ "./sidepanel": "./dist/esm/Sidepanel.js",
31
+ "./style": "./style/index.js"
32
+ },
33
+ "source": "src/index.ts",
34
+ "types": "dist/esm/index.d.ts",
35
+ "module": "dist/esm/index.js",
36
+ "main": "dist/umd/index.js",
37
+ "umd:main": "dist/umd/index.js",
38
+ "unpkg": "dist/umd/index.js",
39
+ "jsdelivr": "dist/umd/index.js",
40
+ "scripts": {
41
+ "build:clean": "rm -rf ./dist",
42
+ "build:clean-types": "rm -rf ./dist/esm/types",
43
+ "build:types": "tsc -p ./tsconfig.declaration.json --outDir ./dist/esm/types",
44
+ "build:source": "rollup --config --bundleConfigAsCjs",
45
+ "build:dts": "rollup --config rollup.dts.config.js --bundleConfigAsCjs",
46
+ "build": "yarn build:clean && yarn build:types && yarn build:source && yarn build:dts && yarn build:clean-types",
47
+ "on:change": "yarn build",
48
+ "watch": "nodemon --watch src --ext ts,tsx,js,jsx,json --ignore dist/ --ignore node_modules/ --verbose --delay 250ms --exec \"yarn on:change\""
49
+ },
50
+ "dependencies": {
51
+ "@docsearch/core": "4.4.0",
52
+ "@docsearch/css": "4.4.0",
53
+ "@docsearch/react": "4.4.0"
54
+ },
55
+ "devDependencies": {
56
+ "@rollup/plugin-replace": "6.0.2",
57
+ "@testing-library/jest-dom": "6.6.3",
58
+ "@testing-library/react": "16.2.0",
59
+ "nodemon": "^3.1.0",
60
+ "rollup-plugin-dts": "^6.2.1",
61
+ "vitest": "3.0.2"
62
+ },
63
+ "peerDependencies": {
64
+ "@types/react": ">= 16.8.0 < 20.0.0",
65
+ "react": ">= 16.8.0 < 20.0.0",
66
+ "react-dom": ">= 16.8.0 < 20.0.0"
67
+ },
68
+ "peerDependenciesMeta": {
69
+ "@types/react": {
70
+ "optional": true
71
+ },
72
+ "react": {
73
+ "optional": true
74
+ },
75
+ "react-dom": {
76
+ "optional": true
77
+ }
78
+ }
79
+ }
package/sidepanel.js ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/esm/Sidepanel.js';
package/style/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from '@docsearch/css/dist/sidepanel.css';