Skip to content

Commit

Permalink
hofix: fix wrong event props
Browse files Browse the repository at this point in the history
  • Loading branch information
rjborba committed Nov 25, 2024
1 parent 97bdf32 commit a97014e
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 27 deletions.
4 changes: 2 additions & 2 deletions apps/demo-react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function App() {
<div className="component-row">
<OramaChatBox
index={{
api_key: 'yl2JSnjLNBV6FVfUWEyadpjFr6KzPiDR',
endpoint: 'https://cloud.orama.run/v1/indexes/recipes-m7w9mm',
api_key: 'qopIuAERiWP2EZOpDjvczjws7WV40yrj',
endpoint: 'https://cloud.orama.run/v1/indexes/nodejs-org-dev-hhqrzv',
}}
style={{ height: '600px' }}
onAnswerSourceClick={(e: Event) => console.log(e)}
Expand Down
8 changes: 4 additions & 4 deletions packages/ui-stencil/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ declare global {
new (): HTMLOramaChatButtonElement;
};
interface HTMLOramaChatMessagesContainerElementEventMap {
"answerGenerated": OnSearchCompletedCallbackProps;
"answerGenerated": OnAnswerGeneratedCallbackProps;
}
interface HTMLOramaChatMessagesContainerElement extends Components.OramaChatMessagesContainer, HTMLStencilElement {
addEventListener<K extends keyof HTMLOramaChatMessagesContainerElementEventMap>(type: K, listener: (this: HTMLOramaChatMessagesContainerElement, ev: OramaChatMessagesContainerCustomEvent<HTMLOramaChatMessagesContainerElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
Expand Down Expand Up @@ -450,7 +450,7 @@ declare global {
};
interface HTMLOramaSearchElementEventMap {
"searchCompleted": OnSearchCompletedCallbackProps;
"answerGenerated": OnSearchCompletedCallbackProps;
"answerGenerated": OnAnswerGeneratedCallbackProps;
}
interface HTMLOramaSearchElement extends Components.OramaSearch, HTMLStencilElement {
addEventListener<K extends keyof HTMLOramaSearchElementEventMap>(type: K, listener: (this: HTMLOramaSearchElement, ev: OramaSearchCustomEvent<HTMLOramaSearchElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
Expand Down Expand Up @@ -656,7 +656,7 @@ declare namespace LocalJSX {
"chatMarkdownLinkTarget"?: ChatMarkdownLinkTarget;
"chatMarkdownLinkTitle"?: ChatMarkdownLinkTitle;
"interactions"?: TChatInteraction[];
"onAnswerGenerated"?: (event: OramaChatMessagesContainerCustomEvent<OnSearchCompletedCallbackProps>) => void;
"onAnswerGenerated"?: (event: OramaChatMessagesContainerCustomEvent<OnAnswerGeneratedCallbackProps>) => void;
}
interface OramaChatUserMessage {
"interaction"?: TChatInteraction;
Expand Down Expand Up @@ -714,7 +714,7 @@ declare namespace LocalJSX {
"highlightTitle"?: HighlightOptions | false;
"linksRel"?: string;
"linksTarget"?: string;
"onAnswerGenerated"?: (event: OramaSearchCustomEvent<OnSearchCompletedCallbackProps>) => void;
"onAnswerGenerated"?: (event: OramaSearchCustomEvent<OnAnswerGeneratedCallbackProps>) => void;
"onSearchCompleted"?: (event: OramaSearchCustomEvent<OnSearchCompletedCallbackProps>) => void;
"placeholder"?: string;
"sourceBaseUrl"?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
| `linksTarget` | `links-target` | | `string` | `'_blank'` |
| `sourceBaseURL` | `source-base-u-r-l` | | `string` | `''` |
| `sources` | `sources` | | `any` | `undefined` |
| `sourcesMap` | -- | | `{ title?: string; path?: string; description?: string; }` | `{ title: 'title', description: 'description', path: 'path', }` |
| `sourcesMap` | -- | | `{ title?: string; description?: string; path?: string; }` | `{ title: 'title', description: 'description', path: 'path', }` |


## Events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
ChatMarkdownLinkHref,
ChatMarkdownLinkTarget,
ChatMarkdownLinkTitle,
OnAnswerGeneratedCallbackProps,
OnSearchCompletedCallbackProps,
} from '@/types'

Expand All @@ -18,7 +19,7 @@ export class OramaChatMessagesContainer {
@Prop() chatMarkdownLinkHref?: ChatMarkdownLinkHref
@Prop() chatMarkdownLinkTarget?: ChatMarkdownLinkTarget

@Event({ bubbles: true, composed: true }) answerGenerated: EventEmitter<OnSearchCompletedCallbackProps>
@Event({ bubbles: true, composed: true }) answerGenerated: EventEmitter<OnAnswerGeneratedCallbackProps>

@Element() el: HTMLElement

Expand All @@ -27,9 +28,8 @@ export class OramaChatMessagesContainer {
// TODO: I'm not sure about having this here as we're breaking our rule of maintain service access only to the very top level component
onSuggestionClick = (suggestion: string) => {
chatContext.chatService?.sendQuestion(suggestion, undefined, {
onAnswerGeneratedCallback(onAnswerGeneratedCallbackProps) {
this.answerGenerated.emit(onAnswerGeneratedCallbackProps)
},
onAnswerGeneratedCallback: (onAnswerGeneratedCallbackProps) =>
this.answerGenerated.emit(onAnswerGeneratedCallbackProps),
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

## Events

| Event | Description | Type |
| ----------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `answerGenerated` | | `CustomEvent<{ clientSearchParams: ClientSearchParams; result: { results: SearchResultBySection[]; resultsCount: number; facets: Facet[]; }; }>` |
| Event | Description | Type |
| ----------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `answerGenerated` | | `CustomEvent<{ askParams: AskParams; query: string; sources: Results<unknown>; answer: string; segment: string; trigger: string; }>` |


## Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
| `placeholder` | `placeholder` | | `string` | `'Ask me anything'` |
| `showClearChat` | `show-clear-chat` | | `boolean` | `true` |
| `sourceBaseUrl` | `source-base-url` | | `string` | `''` |
| `sourcesMap` | -- | | `{ title?: string; path?: string; description?: string; }` | `undefined` |
| `sourcesMap` | -- | | `{ title?: string; description?: string; path?: string; }` | `undefined` |
| `suggestions` | -- | | `string[]` | `undefined` |
| `systemPrompts` | -- | | `string[]` | `undefined` |

Expand Down
Loading

0 comments on commit a97014e

Please sign in to comment.