Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@markprompt/react

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@markprompt/react - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

dist/useToggle.d.ts

2

dist/index.d.ts
export { useMarkprompt, type UseMarkpromptOptions, type UseMarkpromptResult, } from './useMarkprompt.js';
export { Answer, AutoScroller, Close, Content, Description, DialogTrigger, Form, Overlay, Portal, Prompt, References, Root, SearchResult, SearchResults, Title, type AnswerProps, type AutoScrollerProps, type CloseProps, type ContentProps, type DescriptionProps, type DialogTriggerProps, type FormProps, type OverlayProps, type PortalProps, type PromptProps, type ReferencesProps, type RootProps, type SearchResultProps, type SearchResultsProps, type TitleProps, } from './primitives/headless.js';
export { Markprompt, type MarkpromptProps } from './Markprompt.js';
export { Markprompt, type MarkpromptProps, openMarkprompt, } from './Markprompt.js';
export { useMarkpromptContext } from './context.js';

@@ -5,0 +5,0 @@ export { getHref } from './utils.js';

export { useMarkprompt, } from './useMarkprompt.js';
export { Answer, AutoScroller, Close, Content, Description, DialogTrigger, Form, Overlay, Portal, Prompt, References, Root, SearchResult, SearchResults, Title, } from './primitives/headless.js';
export { Markprompt } from './Markprompt.js';
export { Markprompt, openMarkprompt, } from './Markprompt.js';
export { useMarkpromptContext } from './context.js';

@@ -5,0 +5,0 @@ export { getHref } from './utils.js';

@@ -7,4 +7,9 @@ import { type ReactElement } from 'react';

};
/**
* Open Markprompt programmatically. Useful for building a custom trigger or opening the
* Markprompt dialog in response to other user actions.
*/
declare function openMarkprompt(): void;
declare function Markprompt(props: MarkpromptProps): ReactElement;
export { Markprompt, type MarkpromptProps };
export { Markprompt, openMarkprompt, type MarkpromptProps };
//# sourceMappingURL=Markprompt.d.ts.map
import * as AccessibleIcon from '@radix-ui/react-accessible-icon';
import * as web from '@react-spring/web';
import React, { useEffect, useMemo, useRef, useState, } from 'react';
import { animated, useSpring } from '@react-spring/web';
import Emittery from 'emittery';
import React, { useEffect, useRef, useState, } from 'react';
import { Answer } from './Answer.js';

@@ -11,5 +12,10 @@ import { useMarkpromptContext } from './context.js';

import {} from './types.js';
function useToggle(initial) {
const [on, set] = useState(initial);
return useMemo(() => [on, () => set((prev) => !prev)], [on]);
import { useToggle } from './useToggle.js';
const emitter = new Emittery();
/**
* Open Markprompt programmatically. Useful for building a custom trigger or opening the
* Markprompt dialog in response to other user actions.
*/
function openMarkprompt() {
emitter.emit('open');
}

@@ -20,6 +26,13 @@ function Markprompt(props) {

const [showSearch, toggle] = useToggle(search?.enabled ?? false);
useEffect(() => {
if (!trigger?.customElement)
return;
const onOpen = () => setOpen(true);
emitter.on('open', onOpen);
return () => emitter.off('open', onOpen);
}, [trigger?.customElement]);
return (React.createElement(BaseMarkprompt.Root, { projectKey: projectKey, isSearchActive: showSearch, promptOptions: prompt, searchOptions: search, open: open, onOpenChange: setOpen, ...dialogProps },
trigger?.floating !== false ? (React.createElement(BaseMarkprompt.DialogTrigger, { className: "MarkpromptFloatingTrigger" },
!trigger?.customElement && (React.createElement(React.Fragment, null, trigger?.floating !== false ? (React.createElement(BaseMarkprompt.DialogTrigger, { className: "MarkpromptFloatingTrigger" },
React.createElement(AccessibleIcon.Root, { label: trigger?.label ?? 'Open Markprompt' },
React.createElement(ChatIcon, { className: "MarkpromptChatIcon", width: "24", height: "24" })))) : (React.createElement(SearchBoxTrigger, { trigger: trigger, setOpen: setOpen, open: open })),
React.createElement(ChatIcon, { className: "MarkpromptChatIcon", width: "24", height: "24" })))) : (React.createElement(SearchBoxTrigger, { trigger: trigger, setOpen: setOpen, open: open })))),
React.createElement(BaseMarkprompt.Portal, null,

@@ -55,3 +68,3 @@ React.createElement(BaseMarkprompt.Overlay, { className: "MarkpromptOverlay" }),

const [display, setDisplay] = useState(isVisible ? 'block' : 'none');
const styles = web.useSpring({
const styles = useSpring({
opacity: isVisible ? 1 : 0,

@@ -74,3 +87,3 @@ x: isVisible ? '0%' : isFlipped ? '100%' : '-100%',

});
return (React.createElement(web.animated.div, { style: {
return (React.createElement(animated.div, { style: {
position: 'absolute',

@@ -186,3 +199,3 @@ inset: 0,

}
export { Markprompt };
export { Markprompt, openMarkprompt };
//# sourceMappingURL=Markprompt.js.map

@@ -108,2 +108,4 @@ import { type Source, type SubmitPromptOptions, type SubmitSearchQueryOptions } from '@markprompt/core';

floating?: boolean;
/** Do you use a custom element as the dialog trigger? */
customElement?: boolean;
};

@@ -110,0 +112,0 @@ title?: {

{
"name": "@markprompt/react",
"version": "0.7.0",
"version": "0.8.0",
"description": "A headless React component for adding GPT-4 powered search using the Markprompt API.",

@@ -24,3 +24,3 @@ "repository": {

"dependencies": {
"@markprompt/core": "^0.5.0",
"@markprompt/core": "^0.6.0",
"@radix-ui/react-accessible-icon": "^1.0.3",

@@ -31,2 +31,3 @@ "@radix-ui/react-dialog": "^1.0.4",

"clsx": "^1.2.1",
"emittery": "^1.0.1",
"github-slugger": "^2.0.0",

@@ -33,0 +34,0 @@ "p-debounce": "^4.0.0",

@@ -91,2 +91,3 @@ # Markprompt React

- `trigger` (`object`): Options for the trigger
- `trigger.customElement` (`boolean`): Use a custom element as the trigger. Will disable rendering any trigger element. Use `openMarkprompt()` to trigger the Markprompt dialog. (Default: `false`)
- `trigger.label` (`string`): `aria-label` for the open button (Default: `Open Markprompt`)

@@ -99,2 +100,11 @@ - `trigger.placeholder` (`string`): Placeholder text for non-floating element (Default: `Ask docs`)

When rendering the Markprompt component, it will render a search input-like button by default. You have two other options:
- set `trigger.floating = true` to render a floating button
- set `trigger.customElement = true`, then `import { openMarkprompt } from '@markprompt/react'` and call `openMarkprompt()` from your code. This gives you the flexibility to render your own trigger element and attach whatever event handlers you would like and/or open the Markprompt dialog programmatically.
### `openMarkprompt()`
A function to open the Markprompt dialog programmatically. Takes no arguments.
### `<Answer />`

@@ -101,0 +111,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc