@empathyco/x-components 6.0.0-alpha.104 → 6.0.0-alpha.106
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/CHANGELOG.md +16 -0
- package/docs/API-reference/api/x-components.relatedpromptsmutations.md +1 -0
- package/docs/API-reference/api/x-components.relatedpromptsmutations.setfilteredrelatedpromptsproducts.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptsstate.md +1 -0
- package/docs/API-reference/api/x-components.relatedpromptsstate.relatedpromptsfiltered.md +13 -0
- package/docs/API-reference/api/x-components.relatedpromptstaglist.md +9 -0
- package/docs/API-reference/components/related-prompts/x-components.related-prompts-tag-list.md +9 -8
- package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue.js.map +1 -1
- package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue2.js +16 -6
- package/js/x-modules/related-prompts/components/related-prompts-tag-list.vue2.js.map +1 -1
- package/js/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.js +3 -1
- package/js/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.js.map +1 -1
- package/js/x-modules/related-prompts/store/module.js +4 -0
- package/js/x-modules/related-prompts/store/module.js.map +1 -1
- package/js/x-modules/related-prompts/store/utils/related-prompts.utils.js +62 -0
- package/js/x-modules/related-prompts/store/utils/related-prompts.utils.js.map +1 -0
- package/package.json +3 -3
- package/report/x-components.api.json +89 -3
- package/report/x-components.api.md +12 -1
- package/types/x-modules/related-prompts/components/related-prompts-tag-list.vue.d.ts +19 -0
- package/types/x-modules/related-prompts/components/related-prompts-tag-list.vue.d.ts.map +1 -1
- package/types/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.d.ts.map +1 -1
- package/types/x-modules/related-prompts/store/module.d.ts.map +1 -1
- package/types/x-modules/related-prompts/store/types.d.ts +8 -0
- package/types/x-modules/related-prompts/store/types.d.ts.map +1 -1
- package/types/x-modules/related-prompts/store/utils/related-prompts.utils.d.ts +11 -0
- package/types/x-modules/related-prompts/store/utils/related-prompts.utils.d.ts.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 6.0.0-alpha.106 (2025-07-01)
|
|
7
|
+
|
|
8
|
+
* feat: save filtered related prompts in the related prompts state (#1816) ([bded354](https://github.com/empathyco/x/commit/bded354)), closes [#1816](https://github.com/empathyco/x/issues/1816)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 6.0.0-alpha.105 (2025-06-30)
|
|
15
|
+
|
|
16
|
+
* chore(deps): pin dependency @empathyco/x-tailwindcss to 2.0.0-alpha.12 (#1814) ([d9a1522](https://github.com/empathyco/x/commit/d9a1522)), closes [#1814](https://github.com/empathyco/x/issues/1814)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## 6.0.0-alpha.104 (2025-06-27)
|
|
7
23
|
|
|
8
24
|
* chore(deps): update vue-router and vue-i18n (#1813) ([11563f7](https://github.com/empathyco/x/commit/11563f7)), closes [#1813](https://github.com/empathyco/x/issues/1813)
|
|
@@ -19,6 +19,7 @@ export interface RelatedPromptsMutations extends StatusMutations, QueryMutations
|
|
|
19
19
|
| --- | --- | --- | --- |
|
|
20
20
|
| [resetRelatedPromptsState](./x-components.relatedpromptsmutations.resetrelatedpromptsstate.md) | | () => void | Resets the related prompts state. |
|
|
21
21
|
| [resetSelectedPrompt](./x-components.relatedpromptsmutations.resetselectedprompt.md) | | () => void | Resets the selected related prompt number. |
|
|
22
|
+
| [setFilteredRelatedPromptsProducts](./x-components.relatedpromptsmutations.setfilteredrelatedpromptsproducts.md) | | (products: RelatedPrompt\[\]) => void | Sets the filtered related prompts of the module. |
|
|
22
23
|
| [setParams](./x-components.relatedpromptsmutations.setparams.md) | | (params: Dictionary<unknown>) => void | Sets the extra params of the module. |
|
|
23
24
|
| [setRelatedPromptsProducts](./x-components.relatedpromptsmutations.setrelatedpromptsproducts.md) | | (products: RelatedPrompt\[\]) => void | Sets the related prompts of the module. |
|
|
24
25
|
| [setRelatedPromptsRelatedTags](./x-components.relatedpromptsmutations.setrelatedpromptsrelatedtags.md) | | (relatedTags: RelatedTag\[\]) => void | Sets the related tags of the module. |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [RelatedPromptsMutations](./x-components.relatedpromptsmutations.md) > [setFilteredRelatedPromptsProducts](./x-components.relatedpromptsmutations.setfilteredrelatedpromptsproducts.md)
|
|
4
|
+
|
|
5
|
+
## RelatedPromptsMutations.setFilteredRelatedPromptsProducts property
|
|
6
|
+
|
|
7
|
+
Sets the filtered related prompts of the module.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
setFilteredRelatedPromptsProducts: (products: RelatedPrompt[]) => void;
|
|
13
|
+
```
|
|
@@ -19,6 +19,7 @@ export interface RelatedPromptsState extends StatusState, QueryState
|
|
|
19
19
|
| --- | --- | --- | --- |
|
|
20
20
|
| [params](./x-components.relatedpromptsstate.params.md) | | Dictionary<unknown> | The extra params property of the state. |
|
|
21
21
|
| [relatedPrompts](./x-components.relatedpromptsstate.relatedprompts.md) | | RelatedPrompt\[\] | The list of the related-prompts, related to the <code>query</code> property of the state. |
|
|
22
|
+
| [relatedPromptsFiltered](./x-components.relatedpromptsstate.relatedpromptsfiltered.md) | | RelatedPrompt\[\] | The list of the filtered related-prompts, related to the <code>query</code> property of the state. |
|
|
22
23
|
| [relatedTags](./x-components.relatedpromptsstate.relatedtags.md) | | RelatedTag\[\] | The list of the related tags, related to the <code>query</code> property of the state. |
|
|
23
24
|
| [selectedPrompt](./x-components.relatedpromptsstate.selectedprompt.md) | | number | The index of the selected related-prompt. |
|
|
24
25
|
| [selectedQuery](./x-components.relatedpromptsstate.selectedquery.md) | | number | The index of the selected next query. |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [RelatedPromptsState](./x-components.relatedpromptsstate.md) > [relatedPromptsFiltered](./x-components.relatedpromptsstate.relatedpromptsfiltered.md)
|
|
4
|
+
|
|
5
|
+
## RelatedPromptsState.relatedPromptsFiltered property
|
|
6
|
+
|
|
7
|
+
The list of the filtered related-prompts, related to the `query` property of the state.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
relatedPromptsFiltered: RelatedPrompt[];
|
|
13
|
+
```
|
|
@@ -24,6 +24,10 @@ _default: import("vue").DefineComponent<{
|
|
|
24
24
|
type: NumberConstructor;
|
|
25
25
|
default: number;
|
|
26
26
|
};
|
|
27
|
+
useFilteredRelatedPrompts: {
|
|
28
|
+
type: BooleanConstructor;
|
|
29
|
+
default: boolean;
|
|
30
|
+
};
|
|
27
31
|
}, {
|
|
28
32
|
onSelect: (selectedIndex: number) => void;
|
|
29
33
|
onBeforeEnter: (el: Element) => void;
|
|
@@ -66,8 +70,13 @@ _default: import("vue").DefineComponent<{
|
|
|
66
70
|
type: NumberConstructor;
|
|
67
71
|
default: number;
|
|
68
72
|
};
|
|
73
|
+
useFilteredRelatedPrompts: {
|
|
74
|
+
type: BooleanConstructor;
|
|
75
|
+
default: boolean;
|
|
76
|
+
};
|
|
69
77
|
}>>, {
|
|
70
78
|
showButtons: boolean;
|
|
71
79
|
animationDurationInMs: number;
|
|
80
|
+
useFilteredRelatedPrompts: boolean;
|
|
72
81
|
}, {}>
|
|
73
82
|
```
|
package/docs/API-reference/components/related-prompts/x-components.related-prompts-tag-list.md
CHANGED
|
@@ -13,14 +13,15 @@ necessary to handle the selection of the related prompt and to trigger the stagg
|
|
|
13
13
|
|
|
14
14
|
## Props
|
|
15
15
|
|
|
16
|
-
| Name
|
|
17
|
-
|
|
|
18
|
-
| <code>buttonClass</code>
|
|
19
|
-
| <code>showButtons</code>
|
|
20
|
-
| <code>scrollContainerClass</code>
|
|
21
|
-
| <code>tagClass</code>
|
|
22
|
-
| <code>tagColors</code>
|
|
23
|
-
| <code>animationDurationInMs</code>
|
|
16
|
+
| Name | Description | Type | Default |
|
|
17
|
+
| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------ |
|
|
18
|
+
| <code>buttonClass</code> | The CSS class for the left and right button of the sliding panel. | <code>string</code> | <code></code> |
|
|
19
|
+
| <code>showButtons</code> | The boolean prop to handle the visiblity of sliding pannel buttons. | <code>boolean</code> | <code>true</code> |
|
|
20
|
+
| <code>scrollContainerClass</code> | The CSS class for the wrapper of all the related prompt wrapper elements. | <code>string</code> | <code></code> |
|
|
21
|
+
| <code>tagClass</code> | The CSS class for all the related prompt wrapper elements. | <code>string</code> | <code></code> |
|
|
22
|
+
| <code>tagColors</code> | Array of colors to apply to the related prompts. It will be applied to tag<br />elements cyclically according to their index in the nex way: `tagColors[index % tagColors.length]`. | <code>string[]</code> | <code></code> |
|
|
23
|
+
| <code>animationDurationInMs</code> | The duration of the total animation in milliseconds. | <code>number</code> | <code>700</code> |
|
|
24
|
+
| <code>useFilteredRelatedPrompts</code> | The boolean prop to handle if we should use the relatedPromptsFiltered or relatedPrompts. | <code>boolean</code> | <code>false</code> |
|
|
24
25
|
|
|
25
26
|
## Slots
|
|
26
27
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"related-prompts-tag-list.vue.js","sources":["../../../../../src/x-modules/related-prompts/components/related-prompts-tag-list.vue"],"sourcesContent":["<template>\n <SlidingPanel\n :key=\"x.query.search\"\n :reset-on-content-change=\"false\"\n :button-class=\"buttonClass\"\n :show-buttons=\"showButtons && selectedPromptIndex === -1\"\n :scroll-container-class=\"[\n 'x-related-prompts-tag-list-scroll-container',\n scrollContainerClass || '',\n ]\"\n >\n <template #sliding-panel-left-button>\n <!--\n @slot sliding-panel-left-button - The button to be displayed on the left side of the sliding panel.\n -->\n <slot name=\"sliding-panel-left-button\" />\n </template>\n <transition-group\n class=\"x-related-prompts-tag-list\"\n :css=\"false\"\n tag=\"ul\"\n appear\n @before-enter=\"onBeforeEnter\"\n @enter=\"onEnter\"\n @leave=\"onLeave\"\n >\n <li\n v-for=\"{ index, ...relatedPrompt } in visibleRelatedPrompts\"\n ref=\"listItems\"\n :key=\"relatedPrompt.suggestionText\"\n class=\"x-related-prompts-tag-list-item\"\n :class=\"[tagClass, tagColors && tagColors[index % tagColors.length]]\"\n :data-index=\"index\"\n :style=\"{\n ...(selectedPromptIndex === index && { width: '100%' }),\n ...(isAnimating && { pointerEvents: 'none' }),\n }\"\n data-test=\"related-prompts-tag-list-item\"\n >\n <!--\n @slot - The slot to render related prompt information.\n @prop {Object} relatedPrompt - The related prompt object.\n @prop {Function} onSelect - The function to select the related prompt.\n @prop {Boolean} isSelected - Indicates if the related prompt is currently selected.\n -->\n <slot\n :related-prompt=\"relatedPrompt\"\n :on-select=\"() => onSelect(index)\"\n :is-selected=\"selectedPromptIndex === index\"\n >\n <DisplayEmitter\n :payload=\"relatedPrompt.tagging?.toolingDisplayTagging\"\n :event-metadata=\"{\n feature: 'related-prompts',\n displayOriginalQuery: x.query.searchBox,\n replaceable: false,\n }\"\n >\n <RelatedPrompt\n :related-prompt=\"relatedPrompt\"\n :selected=\"selectedPromptIndex === index\"\n @click=\"onSelect(index)\"\n >\n <template #related-prompt-extra-content>\n <!--\n @slot related-prompt-extra-content - The slot to render related prompt extra information.\n @prop {Object} relatedPrompt - The related prompt object.\n -->\n <slot name=\"related-prompt-extra-content\" :related-prompt=\"relatedPrompt\" />\n </template>\n </RelatedPrompt>\n </DisplayEmitter>\n </slot>\n </li>\n </transition-group>\n <template #sliding-panel-right-button>\n <!--\n @slot sliding-panel-right-button - The button to be displayed on the right side of the sliding panel.\n -->\n <slot name=\"sliding-panel-right-button\" />\n </template>\n </SlidingPanel>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport { computed, defineComponent, onBeforeUnmount, ref } from 'vue'\nimport DisplayEmitter from '../../../components/display-emitter.vue'\nimport SlidingPanel from '../../../components/sliding-panel.vue'\nimport { use$x, useState } from '../../../composables'\nimport { relatedPromptsXModule } from '../x-module'\nimport RelatedPrompt from './related-prompt.vue'\n\n/**\n * This component shows the list of `RelatedPrompts` components.\n *\n * If the default slot is reimplemented in the consumer, `onSelect` function will be\n * necessary to handle the selection of the related prompt and to trigger the stagger-fade-slide animation.\n *\n * @public\n */\nexport default defineComponent({\n name: 'RelatedPromptsTagList',\n xModule: relatedPromptsXModule.name,\n components: { DisplayEmitter, RelatedPrompt, SlidingPanel },\n props: {\n /**\n * The CSS class for the left and right button of the sliding panel.\n *\n * @public\n */\n buttonClass: String,\n /**\n * The boolean prop to handle the visiblity of sliding pannel buttons.\n *\n * @public\n */\n showButtons: { type: Boolean, default: true },\n /**\n * The CSS class for the wrapper of all the related prompt wrapper elements.\n *\n * @public\n */\n scrollContainerClass: String,\n /**\n * The CSS class for all the related prompt wrapper elements.\n *\n * @public\n */\n tagClass: String,\n /**\n * Array of colors to apply to the related prompts. It will be applied to tag\n * elements cyclically according to their index in the nex way: `tagColors[index % tagColors.length]`.\n *\n * @public\n */\n tagColors: Array as PropType<string[]>,\n /**\n * The duration of the total animation in milliseconds.\n *\n * @public\n */\n animationDurationInMs: {\n type: Number,\n default: 700,\n },\n },\n setup(props) {\n const x = use$x()\n const { relatedPrompts, selectedPrompt: selectedPromptIndex } = useState('relatedPrompts')\n\n const clickedListItemIndex = ref<number | null>(null)\n const initialOffsetLefts: Record<number, number> = {}\n const isAnimating = ref(false)\n const listItems = ref<HTMLElement[]>([])\n\n const sortedListItems = computed<HTMLElement[]>(() =>\n [...listItems.value].sort(\n (a: HTMLElement, b: HTMLElement) =>\n Number.parseInt(b.getAttribute('data-index')!) -\n Number.parseInt(a.getAttribute('data-index')!),\n ),\n )\n\n // The duration of a single animation (enter or leave) in milliseconds\n // if a related prompt is clicked (clickedListItemIndex.value !== null), the duration is divided by the number of related\n // prompts -1 (the clicked one is synchronized with the last one to leave or the first one to enter)\n const singleAnimationDurationInMs = computed(\n () =>\n props.animationDurationInMs /\n (clickedListItemIndex.value !== null\n ? relatedPrompts.value.length - 1\n : relatedPrompts.value.length),\n )\n\n const indexRelatedPrompts = computed(() =>\n relatedPrompts.value.map((relatedPrompt, index) => ({ ...relatedPrompt, index })),\n )\n\n const visibleRelatedPrompts = computed(() =>\n selectedPromptIndex.value !== -1\n ? [indexRelatedPrompts.value[selectedPromptIndex.value]]\n : indexRelatedPrompts.value,\n )\n\n let timeOutId: number\n const resetTransitionStyle = (excludedProperties: Array<string> = ['width']) => {\n if (timeOutId) {\n clearTimeout(timeOutId)\n }\n\n isAnimating.value = true\n timeOutId = +setTimeout(() => {\n isAnimating.value = false\n clickedListItemIndex.value = null\n\n sortedListItems.value.forEach(element => {\n element.style.cssText\n .split(';')\n .map(rule => rule.split(':')[0]?.trim())\n .forEach(property => {\n if (!excludedProperties.includes(property)) {\n element.style.removeProperty(property)\n }\n })\n })\n }, props.animationDurationInMs)\n }\n\n const onSelect = (selectedIndex: number): void => {\n resetTransitionStyle()\n\n clickedListItemIndex.value = selectedIndex\n const selected: HTMLElement = sortedListItems.value.find(\n element => Number.parseInt(element.getAttribute('data-index')!) === selectedIndex,\n )!\n\n // selectedPromptIndex.value === -1 ? 'SELECTING' : 'DESELECTING'\n if (selectedPromptIndex.value === -1) {\n // Prepare all the elements for the leave animation (~ 'beforeLeave' hook). Remember the elements are\n // sorted in descending order by index.\n sortedListItems.value.forEach(element => {\n const index = Number.parseInt(element.getAttribute('data-index')!)\n\n initialOffsetLefts[index] = element.offsetLeft\n element.style.left = `${element.offsetLeft}px`\n element.style.position = 'absolute'\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`\n\n if (index !== selectedIndex) {\n element.style.opacity = '1'\n element.style.transitionDelay = `${\n (index < selectedIndex ? index : index - 1) * singleAnimationDurationInMs.value\n }ms`\n }\n })\n\n // Synchronize the transition delay of the selected element with the last\n // element to leave\n selected.style.transitionDelay = `${\n (relatedPrompts.value.length > 1 ? relatedPrompts.value.length - 2 : 0) *\n singleAnimationDurationInMs.value\n }ms`\n\n // Trigger the animation (selecting) for the selected element\n requestAnimationFrame(() => {\n const maxWidth = getComputedStyle(selected).maxWidth\n\n selected.style.left = '0px'\n selected.style.setProperty(\n 'width',\n `${maxWidth !== 'none' ? maxWidth : '100%'}`,\n 'important',\n )\n })\n } else {\n // Prepare the selected element for the deselecting animation\n selected.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`\n selected.style.left = '0px'\n selected.style.position = 'absolute'\n\n // Trigger the animation (deselecting) for the selected element\n selected.style.removeProperty('width')\n requestAnimationFrame(() => {\n selected.style.left = `${initialOffsetLefts[selectedIndex]}px`\n })\n }\n\n x.emit('UserSelectedARelatedPrompt', selectedIndex, {\n relatedPrompt: relatedPrompts.value[selectedIndex],\n selectedPrompt: selectedPromptIndex.value,\n })\n }\n\n const onBeforeEnter = (el: Element) => {\n const element = el as HTMLElement\n const index = Number.parseInt(element.getAttribute('data-index')!)\n\n // Prepare the element for the enter animation\n element.style.opacity = '0'\n element.style.transform = 'translateY(5px)'\n element.style.transitionDelay = `${\n (clickedListItemIndex.value !== null && index > clickedListItemIndex.value\n ? index - 1\n : index) * singleAnimationDurationInMs.value\n }ms`\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`\n }\n\n const onEnter = (el: Element, done: () => void) => {\n const element = el as HTMLElement\n const index = Number.parseInt(element.getAttribute('data-index')!)\n\n // Also part of the preparation for the enter animation, but it needs to be done\n // once the element is inserted in DOM (if not the offsetLeft will be always 0)\n element.style.left = `${initialOffsetLefts[index] ?? element.offsetLeft}px`\n\n // trigger enter animation\n requestAnimationFrame(() => {\n element.style.opacity = '1'\n element.style.position = 'absolute'\n element.style.transform = 'translateY(0)'\n })\n\n done()\n }\n\n const onLeave = (el: Element, done: () => void) => {\n const element = el as HTMLElement\n\n // trigger leave animation\n requestAnimationFrame(() => {\n element.style.opacity = '0'\n element.style.transform = 'translateY(5px)'\n })\n\n // Wait for the animation to finish (done() exectution extracts the element from the DOM)\n setTimeout(done, props.animationDurationInMs)\n }\n\n // Changing the request will trigger the appear animation, so we need to reset the\n // style after it finishes\n x.on('SearchRequestChanged', false).subscribe(() => {\n resetTransitionStyle([])\n })\n\n onBeforeUnmount(() => {\n x.emit('RelatedPromptsUnmounted')\n })\n\n return {\n onSelect,\n onBeforeEnter,\n onEnter,\n onLeave,\n selectedPromptIndex,\n visibleRelatedPrompts,\n listItems,\n isAnimating,\n x,\n }\n },\n})\n</script>\n\n<style lang=\"css\">\n.x-related-prompts-tag-list-scroll-container {\n height: 100%;\n position: relative;\n}\n.x-related-prompts-tag-list {\n display: flex;\n gap: 16px;\n min-width: 100%;\n width: 100%;\n}\n.x-related-prompts-tag-list-item {\n height: 100%;\n flex-shrink: 0;\n}\n</style>\n"],"names":["_resolveComponent","_openBlock","_createBlock","buttonClass","showButtons","scrollContainerClass","_renderSlot","_withCtx","_createVNode","_TransitionGroup","onLeave","_createElementBlock","_Fragment","_renderList","_normalizeClass","selectedPromptIndex","isAnimating","_normalizeStyle","onSelect","x"],"mappings":";;;;;;;;;kCACEA,gBAgFe,CAAA,cAAA,CAAA,CAAA;SA9EZC,SAA8B,EAAA,EAAAC,WAAA,CAAA,uBAAA,EAAA;AAAA,IAC9B,GAAcC,EAAAA,IAAAA,CAAAA,CAAAA,CAAAA,KAAAA,CAAAA,MAAAA;AAAAA,IACd,yBAAcC,EAAAA,KAAAA;AAAAA,IACd,cAAA,EAAA,IAAA,CAAA,WAAA;AAAA,IAAA,cAAA,EAAA,IAAA,C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CAAA;;AAAA,aAAA,CAAA;AAAA,YAAA,GAAA;AAAA;AAAA,WAAA;AAAA,SAAA,CAAA;;;AAAA,OAAA,EAAA,CAAA,EAAA,CAAA,eAAA,EAAA,SAAA,EAAA,SAAA,CAAA,CAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"related-prompts-tag-list.vue.js","sources":["../../../../../src/x-modules/related-prompts/components/related-prompts-tag-list.vue"],"sourcesContent":["<template>\n <SlidingPanel\n :key=\"x.query.search\"\n :reset-on-content-change=\"false\"\n :button-class=\"buttonClass\"\n :show-buttons=\"showButtons && selectedPromptIndex === -1\"\n :scroll-container-class=\"[\n 'x-related-prompts-tag-list-scroll-container',\n scrollContainerClass || '',\n ]\"\n >\n <template #sliding-panel-left-button>\n <!--\n @slot sliding-panel-left-button - The button to be displayed on the left side of the sliding panel.\n -->\n <slot name=\"sliding-panel-left-button\" />\n </template>\n <transition-group\n class=\"x-related-prompts-tag-list\"\n :css=\"false\"\n tag=\"ul\"\n appear\n @before-enter=\"onBeforeEnter\"\n @enter=\"onEnter\"\n @leave=\"onLeave\"\n >\n <li\n v-for=\"{ index, ...relatedPrompt } in visibleRelatedPrompts\"\n ref=\"listItems\"\n :key=\"relatedPrompt.suggestionText\"\n class=\"x-related-prompts-tag-list-item\"\n :class=\"[tagClass, tagColors && tagColors[index % tagColors.length]]\"\n :data-index=\"index\"\n :style=\"{\n ...(selectedPromptIndex === index && { width: '100%' }),\n ...(isAnimating && { pointerEvents: 'none' }),\n }\"\n data-test=\"related-prompts-tag-list-item\"\n >\n <!--\n @slot - The slot to render related prompt information.\n @prop {Object} relatedPrompt - The related prompt object.\n @prop {Function} onSelect - The function to select the related prompt.\n @prop {Boolean} isSelected - Indicates if the related prompt is currently selected.\n -->\n <slot\n :related-prompt=\"relatedPrompt\"\n :on-select=\"() => onSelect(index)\"\n :is-selected=\"selectedPromptIndex === index\"\n >\n <DisplayEmitter\n :payload=\"relatedPrompt.tagging?.toolingDisplayTagging\"\n :event-metadata=\"{\n feature: 'related-prompts',\n displayOriginalQuery: x.query.searchBox,\n replaceable: false,\n }\"\n >\n <RelatedPrompt\n :related-prompt=\"relatedPrompt\"\n :selected=\"selectedPromptIndex === index\"\n @click=\"onSelect(index)\"\n >\n <template #related-prompt-extra-content>\n <!--\n @slot related-prompt-extra-content - The slot to render related prompt extra information.\n @prop {Object} relatedPrompt - The related prompt object.\n -->\n <slot name=\"related-prompt-extra-content\" :related-prompt=\"relatedPrompt\" />\n </template>\n </RelatedPrompt>\n </DisplayEmitter>\n </slot>\n </li>\n </transition-group>\n <template #sliding-panel-right-button>\n <!--\n @slot sliding-panel-right-button - The button to be displayed on the right side of the sliding panel.\n -->\n <slot name=\"sliding-panel-right-button\" />\n </template>\n </SlidingPanel>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport { computed, defineComponent, onBeforeUnmount, ref } from 'vue'\nimport DisplayEmitter from '../../../components/display-emitter.vue'\nimport SlidingPanel from '../../../components/sliding-panel.vue'\nimport { use$x, useState } from '../../../composables'\nimport { relatedPromptsXModule } from '../x-module'\nimport RelatedPrompt from './related-prompt.vue'\n\n/**\n * This component shows the list of `RelatedPrompts` components.\n *\n * If the default slot is reimplemented in the consumer, `onSelect` function will be\n * necessary to handle the selection of the related prompt and to trigger the stagger-fade-slide animation.\n *\n * @public\n */\nexport default defineComponent({\n name: 'RelatedPromptsTagList',\n xModule: relatedPromptsXModule.name,\n components: { DisplayEmitter, RelatedPrompt, SlidingPanel },\n props: {\n /**\n * The CSS class for the left and right button of the sliding panel.\n *\n * @public\n */\n buttonClass: String,\n /**\n * The boolean prop to handle the visiblity of sliding pannel buttons.\n *\n * @public\n */\n showButtons: { type: Boolean, default: true },\n /**\n * The CSS class for the wrapper of all the related prompt wrapper elements.\n *\n * @public\n */\n scrollContainerClass: String,\n /**\n * The CSS class for all the related prompt wrapper elements.\n *\n * @public\n */\n tagClass: String,\n /**\n * Array of colors to apply to the related prompts. It will be applied to tag\n * elements cyclically according to their index in the nex way: `tagColors[index % tagColors.length]`.\n *\n * @public\n */\n tagColors: Array as PropType<string[]>,\n /**\n * The duration of the total animation in milliseconds.\n *\n * @public\n */\n animationDurationInMs: {\n type: Number,\n default: 700,\n },\n /**\n * The boolean prop to handle if we should use the relatedPromptsFiltered or relatedPrompts.\n *\n * @public\n */\n useFilteredRelatedPrompts: {\n type: Boolean,\n default: false,\n },\n },\n setup(props) {\n const x = use$x()\n const {\n relatedPrompts,\n relatedPromptsFiltered,\n selectedPrompt: selectedPromptIndex,\n } = useState('relatedPrompts')\n\n const clickedListItemIndex = ref<number | null>(null)\n const initialOffsetLefts: Record<number, number> = {}\n const isAnimating = ref(false)\n const listItems = ref<HTMLElement[]>([])\n\n const relatedPromptsList = computed(() =>\n props.useFilteredRelatedPrompts ? relatedPromptsFiltered.value : relatedPrompts.value,\n )\n\n const sortedListItems = computed<HTMLElement[]>(() =>\n [...listItems.value].sort(\n (a: HTMLElement, b: HTMLElement) =>\n Number.parseInt(b.getAttribute('data-index')!) -\n Number.parseInt(a.getAttribute('data-index')!),\n ),\n )\n\n // The duration of a single animation (enter or leave) in milliseconds\n // if a related prompt is clicked (clickedListItemIndex.value !== null), the duration is divided by the number of related\n // prompts -1 (the clicked one is synchronized with the last one to leave or the first one to enter)\n const singleAnimationDurationInMs = computed(\n () =>\n props.animationDurationInMs /\n (clickedListItemIndex.value !== null\n ? relatedPromptsList.value.length - 1\n : relatedPromptsList.value.length),\n )\n\n const indexRelatedPrompts = computed(() =>\n relatedPromptsList.value.map((relatedPrompt, index) => ({ ...relatedPrompt, index })),\n )\n\n const visibleRelatedPrompts = computed(() =>\n selectedPromptIndex.value !== -1\n ? [indexRelatedPrompts.value[selectedPromptIndex.value]]\n : indexRelatedPrompts.value,\n )\n\n let timeOutId: number\n const resetTransitionStyle = (excludedProperties: Array<string> = ['width']) => {\n if (timeOutId) {\n clearTimeout(timeOutId)\n }\n\n isAnimating.value = true\n timeOutId = +setTimeout(() => {\n isAnimating.value = false\n clickedListItemIndex.value = null\n\n sortedListItems.value.forEach(element => {\n element.style.cssText\n .split(';')\n .map(rule => rule.split(':')[0]?.trim())\n .forEach(property => {\n if (!excludedProperties.includes(property)) {\n element.style.removeProperty(property)\n }\n })\n })\n }, props.animationDurationInMs)\n }\n\n const onSelect = (selectedIndex: number): void => {\n resetTransitionStyle()\n\n clickedListItemIndex.value = selectedIndex\n const selected: HTMLElement = sortedListItems.value.find(\n element => Number.parseInt(element.getAttribute('data-index')!) === selectedIndex,\n )!\n\n // selectedPromptIndex.value === -1 ? 'SELECTING' : 'DESELECTING'\n if (selectedPromptIndex.value === -1) {\n // Prepare all the elements for the leave animation (~ 'beforeLeave' hook). Remember the elements are\n // sorted in descending order by index.\n sortedListItems.value.forEach(element => {\n const index = Number.parseInt(element.getAttribute('data-index')!)\n\n initialOffsetLefts[index] = element.offsetLeft\n element.style.left = `${element.offsetLeft}px`\n element.style.position = 'absolute'\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`\n\n if (index !== selectedIndex) {\n element.style.opacity = '1'\n element.style.transitionDelay = `${\n (index < selectedIndex ? index : index - 1) * singleAnimationDurationInMs.value\n }ms`\n }\n })\n\n // Synchronize the transition delay of the selected element with the last\n // element to leave\n selected.style.transitionDelay = `${\n (relatedPromptsList.value.length > 1 ? relatedPromptsList.value.length - 2 : 0) *\n singleAnimationDurationInMs.value\n }ms`\n\n // Trigger the animation (selecting) for the selected element\n requestAnimationFrame(() => {\n const maxWidth = getComputedStyle(selected).maxWidth\n\n selected.style.left = '0px'\n selected.style.setProperty(\n 'width',\n `${maxWidth !== 'none' ? maxWidth : '100%'}`,\n 'important',\n )\n })\n } else {\n // Prepare the selected element for the deselecting animation\n selected.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`\n selected.style.left = '0px'\n selected.style.position = 'absolute'\n\n // Trigger the animation (deselecting) for the selected element\n selected.style.removeProperty('width')\n requestAnimationFrame(() => {\n selected.style.left = `${initialOffsetLefts[selectedIndex]}px`\n })\n }\n\n x.emit('UserSelectedARelatedPrompt', selectedIndex, {\n relatedPrompt: relatedPromptsList.value[selectedIndex],\n selectedPrompt: selectedPromptIndex.value,\n })\n }\n\n const onBeforeEnter = (el: Element) => {\n const element = el as HTMLElement\n const index = Number.parseInt(element.getAttribute('data-index')!)\n\n // Prepare the element for the enter animation\n element.style.opacity = '0'\n element.style.transform = 'translateY(5px)'\n element.style.transitionDelay = `${\n (clickedListItemIndex.value !== null && index > clickedListItemIndex.value\n ? index - 1\n : index) * singleAnimationDurationInMs.value\n }ms`\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`\n }\n\n const onEnter = (el: Element, done: () => void) => {\n const element = el as HTMLElement\n const index = Number.parseInt(element.getAttribute('data-index')!)\n\n // Also part of the preparation for the enter animation, but it needs to be done\n // once the element is inserted in DOM (if not the offsetLeft will be always 0)\n element.style.left = `${initialOffsetLefts[index] ?? element.offsetLeft}px`\n\n // trigger enter animation\n requestAnimationFrame(() => {\n element.style.opacity = '1'\n element.style.position = 'absolute'\n element.style.transform = 'translateY(0)'\n })\n\n done()\n }\n\n const onLeave = (el: Element, done: () => void) => {\n const element = el as HTMLElement\n\n // trigger leave animation\n requestAnimationFrame(() => {\n element.style.opacity = '0'\n element.style.transform = 'translateY(5px)'\n })\n\n // Wait for the animation to finish (done() exectution extracts the element from the DOM)\n setTimeout(done, props.animationDurationInMs)\n }\n\n // Changing the request will trigger the appear animation, so we need to reset the\n // style after it finishes\n x.on('SearchRequestChanged', false).subscribe(() => {\n resetTransitionStyle([])\n })\n\n onBeforeUnmount(() => {\n x.emit('RelatedPromptsUnmounted')\n })\n\n return {\n onSelect,\n onBeforeEnter,\n onEnter,\n onLeave,\n selectedPromptIndex,\n visibleRelatedPrompts,\n listItems,\n isAnimating,\n x,\n }\n },\n})\n</script>\n\n<style lang=\"css\">\n.x-related-prompts-tag-list-scroll-container {\n height: 100%;\n position: relative;\n}\n.x-related-prompts-tag-list {\n display: flex;\n gap: 16px;\n min-width: 100%;\n width: 100%;\n}\n.x-related-prompts-tag-list-item {\n height: 100%;\n flex-shrink: 0;\n}\n</style>\n"],"names":["_resolveComponent","_openBlock","_createBlock","buttonClass","showButtons","scrollContainerClass","_renderSlot","_withCtx","_createVNode","_TransitionGroup","onLeave","_createElementBlock","_Fragment","_renderList","_normalizeClass","selectedPromptIndex","isAnimating","_normalizeStyle","onSelect","x"],"mappings":";;;;;;;;;kCACEA,gBAgFe,CAAA,cAAA,CAAA,CAAA;SA9EZC,SAA8B,EAAA,EAAAC,WAAA,CAAA,uBAAA,EAAA;AAAA,IAC9B,GAAcC,EAAAA,IAAAA,CAAAA,CAAAA,CAAAA,KAAAA,CAAAA,MAAAA;AAAAA,IACd,yBAAcC,EAAAA,KAAAA;AAAAA,IACd,cAAA,EAAA,IAAA,CAAA,WAAA;AAAA,IAAA,cAAA,EAAA,IAAA,CAAA,WAAA,IAAA,IAAA,CAAA,mBAAA,KAAA,CAAA,CAAA;AAAqFC,IAAAA,wBAAAA,EAAAA;AAAAA,MAAAA,6CAAAA;;AAK3E,KAAA;AAAA,GAAA,EAAA;;MAgEAC,UAIiC,CAAA,IAAA,CAAA,MAAA,EAAA,2BAAA,CAAA;AAAA,KAAA,CAAA;;MA/EhDA,UA0EuB,CAAA,IAAA,CAAA,MAAA,EAAA,4BAAA,CAAA;AAAA,KAAA,CAAA;aAxDZC,OAAC,CAAA,MAAA;AAAA,MACKC,WAAA,CAAAC,eAAA,EAAA;AAAA,QACX,KAAI,EAAA,4BAAA;AAAA,QACJ,GAAA,EAAA,KAAA;AAAA,QACC,GAAA,EAAA,IAAA;AAAA,QACA,MAAK,EAAA,EAAA;AAAA,QACL,aAAOC,EAAAA,IAAAA,CAAAA,aAAAA;AAAAA,QAAAA,OAAAA,EAAAA,IAAAA,CAAAA,OAAAA;AAxBd,QAAA,OAAA,EAAA,IAAA,CAAA,OAAA;AAAA,OAAA,EAAA;;AAAA,WAAAT,SAAA,CAAA,IAAA,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A;;;;;6BAO9FZ,OAAgB,CAAA,MAAA;AAAA,sBAAAC,WAAA,CACNO,wBAAmB,EAAA;AAAA,wBAC7B,gBAAK,EAAA,aAAA;AAAA,wBAAA,QAAA,EAAA,IAAA,CAAA,mBAAA,KAAA,KAAA;wBAEK,OAA4B,EAAA,CAAA,MAAA,KAAA,IAAA,CAAA,QAAA,CAAA,KAAA,CAAA;AAAA,uBAAA,EAAA;;AA/DrD,0BAAAT,UAAA,CAAA,IAAA,CAAA,MAAA,EAAA,8BAAA,EAAA,EAAA,aAAA,EAAA,CAAA;AAAA,yBAAA,CAAA;;;AAAA,uBAAA,EAAA,IAAA,EAAA,CAAA,gBAAA,EAAA,UAAA,EAAA,SAAA,CAAA,CAAA;AAAA,qBAAA,CAAA;;;AAAA,mBAAA,EAAA,IAAA,EAAA,CAAA,SAAA,EAAA,gBAAA,CAAA,CAAA;AAAA,iBAAA,CAAA;;AAAA,aAAA,CAAA;AAAA,YAAA,GAAA;AAAA;AAAA,WAAA;AAAA,SAAA,CAAA;;;AAAA,OAAA,EAAA,CAAA,EAAA,CAAA,eAAA,EAAA,SAAA,EAAA,SAAA,CAAA,CAAA;AAAA,KAAA,CAAA;;;;;;;;;"}
|
|
@@ -70,14 +70,24 @@ var _sfc_main = defineComponent({
|
|
|
70
70
|
type: Number,
|
|
71
71
|
default: 700,
|
|
72
72
|
},
|
|
73
|
+
/**
|
|
74
|
+
* The boolean prop to handle if we should use the relatedPromptsFiltered or relatedPrompts.
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
useFilteredRelatedPrompts: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: false,
|
|
81
|
+
},
|
|
73
82
|
},
|
|
74
83
|
setup(props) {
|
|
75
84
|
const x = use$x();
|
|
76
|
-
const { relatedPrompts, selectedPrompt: selectedPromptIndex } = useState('relatedPrompts');
|
|
85
|
+
const { relatedPrompts, relatedPromptsFiltered, selectedPrompt: selectedPromptIndex, } = useState('relatedPrompts');
|
|
77
86
|
const clickedListItemIndex = ref(null);
|
|
78
87
|
const initialOffsetLefts = {};
|
|
79
88
|
const isAnimating = ref(false);
|
|
80
89
|
const listItems = ref([]);
|
|
90
|
+
const relatedPromptsList = computed(() => props.useFilteredRelatedPrompts ? relatedPromptsFiltered.value : relatedPrompts.value);
|
|
81
91
|
const sortedListItems = computed(() => [...listItems.value].sort((a, b) => Number.parseInt(b.getAttribute('data-index')) -
|
|
82
92
|
Number.parseInt(a.getAttribute('data-index'))));
|
|
83
93
|
// The duration of a single animation (enter or leave) in milliseconds
|
|
@@ -85,9 +95,9 @@ var _sfc_main = defineComponent({
|
|
|
85
95
|
// prompts -1 (the clicked one is synchronized with the last one to leave or the first one to enter)
|
|
86
96
|
const singleAnimationDurationInMs = computed(() => props.animationDurationInMs /
|
|
87
97
|
(clickedListItemIndex.value !== null
|
|
88
|
-
?
|
|
89
|
-
:
|
|
90
|
-
const indexRelatedPrompts = computed(() =>
|
|
98
|
+
? relatedPromptsList.value.length - 1
|
|
99
|
+
: relatedPromptsList.value.length));
|
|
100
|
+
const indexRelatedPrompts = computed(() => relatedPromptsList.value.map((relatedPrompt, index) => ({ ...relatedPrompt, index })));
|
|
91
101
|
const visibleRelatedPrompts = computed(() => selectedPromptIndex.value !== -1
|
|
92
102
|
? [indexRelatedPrompts.value[selectedPromptIndex.value]]
|
|
93
103
|
: indexRelatedPrompts.value);
|
|
@@ -133,7 +143,7 @@ var _sfc_main = defineComponent({
|
|
|
133
143
|
});
|
|
134
144
|
// Synchronize the transition delay of the selected element with the last
|
|
135
145
|
// element to leave
|
|
136
|
-
selected.style.transitionDelay = `${(
|
|
146
|
+
selected.style.transitionDelay = `${(relatedPromptsList.value.length > 1 ? relatedPromptsList.value.length - 2 : 0) *
|
|
137
147
|
singleAnimationDurationInMs.value}ms`;
|
|
138
148
|
// Trigger the animation (selecting) for the selected element
|
|
139
149
|
requestAnimationFrame(() => {
|
|
@@ -154,7 +164,7 @@ var _sfc_main = defineComponent({
|
|
|
154
164
|
});
|
|
155
165
|
}
|
|
156
166
|
x.emit('UserSelectedARelatedPrompt', selectedIndex, {
|
|
157
|
-
relatedPrompt:
|
|
167
|
+
relatedPrompt: relatedPromptsList.value[selectedIndex],
|
|
158
168
|
selectedPrompt: selectedPromptIndex.value,
|
|
159
169
|
});
|
|
160
170
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"related-prompts-tag-list.vue2.js","sources":["../../../../../src/x-modules/related-prompts/components/related-prompts-tag-list.vue"],"sourcesContent":["<template>\n <SlidingPanel\n :key=\"x.query.search\"\n :reset-on-content-change=\"false\"\n :button-class=\"buttonClass\"\n :show-buttons=\"showButtons && selectedPromptIndex === -1\"\n :scroll-container-class=\"[\n 'x-related-prompts-tag-list-scroll-container',\n scrollContainerClass || '',\n ]\"\n >\n <template #sliding-panel-left-button>\n <!--\n @slot sliding-panel-left-button - The button to be displayed on the left side of the sliding panel.\n -->\n <slot name=\"sliding-panel-left-button\" />\n </template>\n <transition-group\n class=\"x-related-prompts-tag-list\"\n :css=\"false\"\n tag=\"ul\"\n appear\n @before-enter=\"onBeforeEnter\"\n @enter=\"onEnter\"\n @leave=\"onLeave\"\n >\n <li\n v-for=\"{ index, ...relatedPrompt } in visibleRelatedPrompts\"\n ref=\"listItems\"\n :key=\"relatedPrompt.suggestionText\"\n class=\"x-related-prompts-tag-list-item\"\n :class=\"[tagClass, tagColors && tagColors[index % tagColors.length]]\"\n :data-index=\"index\"\n :style=\"{\n ...(selectedPromptIndex === index && { width: '100%' }),\n ...(isAnimating && { pointerEvents: 'none' }),\n }\"\n data-test=\"related-prompts-tag-list-item\"\n >\n <!--\n @slot - The slot to render related prompt information.\n @prop {Object} relatedPrompt - The related prompt object.\n @prop {Function} onSelect - The function to select the related prompt.\n @prop {Boolean} isSelected - Indicates if the related prompt is currently selected.\n -->\n <slot\n :related-prompt=\"relatedPrompt\"\n :on-select=\"() => onSelect(index)\"\n :is-selected=\"selectedPromptIndex === index\"\n >\n <DisplayEmitter\n :payload=\"relatedPrompt.tagging?.toolingDisplayTagging\"\n :event-metadata=\"{\n feature: 'related-prompts',\n displayOriginalQuery: x.query.searchBox,\n replaceable: false,\n }\"\n >\n <RelatedPrompt\n :related-prompt=\"relatedPrompt\"\n :selected=\"selectedPromptIndex === index\"\n @click=\"onSelect(index)\"\n >\n <template #related-prompt-extra-content>\n <!--\n @slot related-prompt-extra-content - The slot to render related prompt extra information.\n @prop {Object} relatedPrompt - The related prompt object.\n -->\n <slot name=\"related-prompt-extra-content\" :related-prompt=\"relatedPrompt\" />\n </template>\n </RelatedPrompt>\n </DisplayEmitter>\n </slot>\n </li>\n </transition-group>\n <template #sliding-panel-right-button>\n <!--\n @slot sliding-panel-right-button - The button to be displayed on the right side of the sliding panel.\n -->\n <slot name=\"sliding-panel-right-button\" />\n </template>\n </SlidingPanel>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport { computed, defineComponent, onBeforeUnmount, ref } from 'vue'\nimport DisplayEmitter from '../../../components/display-emitter.vue'\nimport SlidingPanel from '../../../components/sliding-panel.vue'\nimport { use$x, useState } from '../../../composables'\nimport { relatedPromptsXModule } from '../x-module'\nimport RelatedPrompt from './related-prompt.vue'\n\n/**\n * This component shows the list of `RelatedPrompts` components.\n *\n * If the default slot is reimplemented in the consumer, `onSelect` function will be\n * necessary to handle the selection of the related prompt and to trigger the stagger-fade-slide animation.\n *\n * @public\n */\nexport default defineComponent({\n name: 'RelatedPromptsTagList',\n xModule: relatedPromptsXModule.name,\n components: { DisplayEmitter, RelatedPrompt, SlidingPanel },\n props: {\n /**\n * The CSS class for the left and right button of the sliding panel.\n *\n * @public\n */\n buttonClass: String,\n /**\n * The boolean prop to handle the visiblity of sliding pannel buttons.\n *\n * @public\n */\n showButtons: { type: Boolean, default: true },\n /**\n * The CSS class for the wrapper of all the related prompt wrapper elements.\n *\n * @public\n */\n scrollContainerClass: String,\n /**\n * The CSS class for all the related prompt wrapper elements.\n *\n * @public\n */\n tagClass: String,\n /**\n * Array of colors to apply to the related prompts. It will be applied to tag\n * elements cyclically according to their index in the nex way: `tagColors[index % tagColors.length]`.\n *\n * @public\n */\n tagColors: Array as PropType<string[]>,\n /**\n * The duration of the total animation in milliseconds.\n *\n * @public\n */\n animationDurationInMs: {\n type: Number,\n default: 700,\n },\n },\n setup(props) {\n const x = use$x()\n const { relatedPrompts, selectedPrompt: selectedPromptIndex } = useState('relatedPrompts')\n\n const clickedListItemIndex = ref<number | null>(null)\n const initialOffsetLefts: Record<number, number> = {}\n const isAnimating = ref(false)\n const listItems = ref<HTMLElement[]>([])\n\n const sortedListItems = computed<HTMLElement[]>(() =>\n [...listItems.value].sort(\n (a: HTMLElement, b: HTMLElement) =>\n Number.parseInt(b.getAttribute('data-index')!) -\n Number.parseInt(a.getAttribute('data-index')!),\n ),\n )\n\n // The duration of a single animation (enter or leave) in milliseconds\n // if a related prompt is clicked (clickedListItemIndex.value !== null), the duration is divided by the number of related\n // prompts -1 (the clicked one is synchronized with the last one to leave or the first one to enter)\n const singleAnimationDurationInMs = computed(\n () =>\n props.animationDurationInMs /\n (clickedListItemIndex.value !== null\n ? relatedPrompts.value.length - 1\n : relatedPrompts.value.length),\n )\n\n const indexRelatedPrompts = computed(() =>\n relatedPrompts.value.map((relatedPrompt, index) => ({ ...relatedPrompt, index })),\n )\n\n const visibleRelatedPrompts = computed(() =>\n selectedPromptIndex.value !== -1\n ? [indexRelatedPrompts.value[selectedPromptIndex.value]]\n : indexRelatedPrompts.value,\n )\n\n let timeOutId: number\n const resetTransitionStyle = (excludedProperties: Array<string> = ['width']) => {\n if (timeOutId) {\n clearTimeout(timeOutId)\n }\n\n isAnimating.value = true\n timeOutId = +setTimeout(() => {\n isAnimating.value = false\n clickedListItemIndex.value = null\n\n sortedListItems.value.forEach(element => {\n element.style.cssText\n .split(';')\n .map(rule => rule.split(':')[0]?.trim())\n .forEach(property => {\n if (!excludedProperties.includes(property)) {\n element.style.removeProperty(property)\n }\n })\n })\n }, props.animationDurationInMs)\n }\n\n const onSelect = (selectedIndex: number): void => {\n resetTransitionStyle()\n\n clickedListItemIndex.value = selectedIndex\n const selected: HTMLElement = sortedListItems.value.find(\n element => Number.parseInt(element.getAttribute('data-index')!) === selectedIndex,\n )!\n\n // selectedPromptIndex.value === -1 ? 'SELECTING' : 'DESELECTING'\n if (selectedPromptIndex.value === -1) {\n // Prepare all the elements for the leave animation (~ 'beforeLeave' hook). Remember the elements are\n // sorted in descending order by index.\n sortedListItems.value.forEach(element => {\n const index = Number.parseInt(element.getAttribute('data-index')!)\n\n initialOffsetLefts[index] = element.offsetLeft\n element.style.left = `${element.offsetLeft}px`\n element.style.position = 'absolute'\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`\n\n if (index !== selectedIndex) {\n element.style.opacity = '1'\n element.style.transitionDelay = `${\n (index < selectedIndex ? index : index - 1) * singleAnimationDurationInMs.value\n }ms`\n }\n })\n\n // Synchronize the transition delay of the selected element with the last\n // element to leave\n selected.style.transitionDelay = `${\n (relatedPrompts.value.length > 1 ? relatedPrompts.value.length - 2 : 0) *\n singleAnimationDurationInMs.value\n }ms`\n\n // Trigger the animation (selecting) for the selected element\n requestAnimationFrame(() => {\n const maxWidth = getComputedStyle(selected).maxWidth\n\n selected.style.left = '0px'\n selected.style.setProperty(\n 'width',\n `${maxWidth !== 'none' ? maxWidth : '100%'}`,\n 'important',\n )\n })\n } else {\n // Prepare the selected element for the deselecting animation\n selected.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`\n selected.style.left = '0px'\n selected.style.position = 'absolute'\n\n // Trigger the animation (deselecting) for the selected element\n selected.style.removeProperty('width')\n requestAnimationFrame(() => {\n selected.style.left = `${initialOffsetLefts[selectedIndex]}px`\n })\n }\n\n x.emit('UserSelectedARelatedPrompt', selectedIndex, {\n relatedPrompt: relatedPrompts.value[selectedIndex],\n selectedPrompt: selectedPromptIndex.value,\n })\n }\n\n const onBeforeEnter = (el: Element) => {\n const element = el as HTMLElement\n const index = Number.parseInt(element.getAttribute('data-index')!)\n\n // Prepare the element for the enter animation\n element.style.opacity = '0'\n element.style.transform = 'translateY(5px)'\n element.style.transitionDelay = `${\n (clickedListItemIndex.value !== null && index > clickedListItemIndex.value\n ? index - 1\n : index) * singleAnimationDurationInMs.value\n }ms`\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`\n }\n\n const onEnter = (el: Element, done: () => void) => {\n const element = el as HTMLElement\n const index = Number.parseInt(element.getAttribute('data-index')!)\n\n // Also part of the preparation for the enter animation, but it needs to be done\n // once the element is inserted in DOM (if not the offsetLeft will be always 0)\n element.style.left = `${initialOffsetLefts[index] ?? element.offsetLeft}px`\n\n // trigger enter animation\n requestAnimationFrame(() => {\n element.style.opacity = '1'\n element.style.position = 'absolute'\n element.style.transform = 'translateY(0)'\n })\n\n done()\n }\n\n const onLeave = (el: Element, done: () => void) => {\n const element = el as HTMLElement\n\n // trigger leave animation\n requestAnimationFrame(() => {\n element.style.opacity = '0'\n element.style.transform = 'translateY(5px)'\n })\n\n // Wait for the animation to finish (done() exectution extracts the element from the DOM)\n setTimeout(done, props.animationDurationInMs)\n }\n\n // Changing the request will trigger the appear animation, so we need to reset the\n // style after it finishes\n x.on('SearchRequestChanged', false).subscribe(() => {\n resetTransitionStyle([])\n })\n\n onBeforeUnmount(() => {\n x.emit('RelatedPromptsUnmounted')\n })\n\n return {\n onSelect,\n onBeforeEnter,\n onEnter,\n onLeave,\n selectedPromptIndex,\n visibleRelatedPrompts,\n listItems,\n isAnimating,\n x,\n }\n },\n})\n</script>\n\n<style lang=\"css\">\n.x-related-prompts-tag-list-scroll-container {\n height: 100%;\n position: relative;\n}\n.x-related-prompts-tag-list {\n display: flex;\n gap: 16px;\n min-width: 100%;\n width: 100%;\n}\n.x-related-prompts-tag-list-item {\n height: 100%;\n flex-shrink: 0;\n}\n</style>\n"],"names":["DisplayEmitter"],"mappings":";;;;;;;;;;;;;;;;;;;AA6FA;;;;;;;AA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AC,UAAU,IAAG,CAAA;;YAG1E,qBAAqB,CAAC,MAAM;AAC1B,gBAAA,OAAO,CAAC,KAAK,CAAC,OAAM,GAAI,GAAE,CAAA;AAC1B,gBAAA,OAAO,CAAC,KAAK,CAAC,QAAO,GAAI,UAAS,CAAA;AAClC,gBAAA,OAAO,CAAC,KAAK,CAAC,SAAU,GAAE,eAAc,CAAA;AAC1C,aAAC,CAAA,CAAA;AAED,YAAA,IAAI,EAAC,CAAA;AACP,SAAA,CAAA;AAEA,QAAA,MAAM,UAAU,CAAC,EAAW,EAAE,IAAgB,KAAK;YACjD,MAAM,OAAQ,GAAE,EAAgB,CAAA;;YAGhC,qBAAqB,CAAC,MAAM;AAC1B,gBAAA,OAAO,CAAC,KAAK,CAAC,OAAM,GAAI,GAAE,CAAA;AAC1B,gBAAA,OAAO,CAAC,KAAK,CAAC,YAAY,iBAAgB,CAAA;AAC5C,aAAC,CAAA,CAAA;;AAGD,YAAA,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,qBAAqB,CAAA,CAAA;AAC9C,SAAA,CAAA;;;QAIA,CAAC,CAAC,EAAE,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM;YAClD,oBAAoB,CAAC,EAAE,CAAA,CAAA;AACzB,SAAC,CAAA,CAAA;QAED,eAAe,CAAC,MAAM;AACpB,YAAA,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAA,CAAA;AAClC,SAAC,CAAA,CAAA;QAED,OAAO;YACL,QAAQ;YACR,aAAa;YACb,OAAO;YACP,OAAO;YACP,mBAAmB;YACnB,qBAAqB;YACrB,SAAS;YACT,WAAW;YACX,CAAC;SACH,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"related-prompts-tag-list.vue2.js","sources":["../../../../../src/x-modules/related-prompts/components/related-prompts-tag-list.vue"],"sourcesContent":["<template>\n <SlidingPanel\n :key=\"x.query.search\"\n :reset-on-content-change=\"false\"\n :button-class=\"buttonClass\"\n :show-buttons=\"showButtons && selectedPromptIndex === -1\"\n :scroll-container-class=\"[\n 'x-related-prompts-tag-list-scroll-container',\n scrollContainerClass || '',\n ]\"\n >\n <template #sliding-panel-left-button>\n <!--\n @slot sliding-panel-left-button - The button to be displayed on the left side of the sliding panel.\n -->\n <slot name=\"sliding-panel-left-button\" />\n </template>\n <transition-group\n class=\"x-related-prompts-tag-list\"\n :css=\"false\"\n tag=\"ul\"\n appear\n @before-enter=\"onBeforeEnter\"\n @enter=\"onEnter\"\n @leave=\"onLeave\"\n >\n <li\n v-for=\"{ index, ...relatedPrompt } in visibleRelatedPrompts\"\n ref=\"listItems\"\n :key=\"relatedPrompt.suggestionText\"\n class=\"x-related-prompts-tag-list-item\"\n :class=\"[tagClass, tagColors && tagColors[index % tagColors.length]]\"\n :data-index=\"index\"\n :style=\"{\n ...(selectedPromptIndex === index && { width: '100%' }),\n ...(isAnimating && { pointerEvents: 'none' }),\n }\"\n data-test=\"related-prompts-tag-list-item\"\n >\n <!--\n @slot - The slot to render related prompt information.\n @prop {Object} relatedPrompt - The related prompt object.\n @prop {Function} onSelect - The function to select the related prompt.\n @prop {Boolean} isSelected - Indicates if the related prompt is currently selected.\n -->\n <slot\n :related-prompt=\"relatedPrompt\"\n :on-select=\"() => onSelect(index)\"\n :is-selected=\"selectedPromptIndex === index\"\n >\n <DisplayEmitter\n :payload=\"relatedPrompt.tagging?.toolingDisplayTagging\"\n :event-metadata=\"{\n feature: 'related-prompts',\n displayOriginalQuery: x.query.searchBox,\n replaceable: false,\n }\"\n >\n <RelatedPrompt\n :related-prompt=\"relatedPrompt\"\n :selected=\"selectedPromptIndex === index\"\n @click=\"onSelect(index)\"\n >\n <template #related-prompt-extra-content>\n <!--\n @slot related-prompt-extra-content - The slot to render related prompt extra information.\n @prop {Object} relatedPrompt - The related prompt object.\n -->\n <slot name=\"related-prompt-extra-content\" :related-prompt=\"relatedPrompt\" />\n </template>\n </RelatedPrompt>\n </DisplayEmitter>\n </slot>\n </li>\n </transition-group>\n <template #sliding-panel-right-button>\n <!--\n @slot sliding-panel-right-button - The button to be displayed on the right side of the sliding panel.\n -->\n <slot name=\"sliding-panel-right-button\" />\n </template>\n </SlidingPanel>\n</template>\n\n<script lang=\"ts\">\nimport type { PropType } from 'vue'\nimport { computed, defineComponent, onBeforeUnmount, ref } from 'vue'\nimport DisplayEmitter from '../../../components/display-emitter.vue'\nimport SlidingPanel from '../../../components/sliding-panel.vue'\nimport { use$x, useState } from '../../../composables'\nimport { relatedPromptsXModule } from '../x-module'\nimport RelatedPrompt from './related-prompt.vue'\n\n/**\n * This component shows the list of `RelatedPrompts` components.\n *\n * If the default slot is reimplemented in the consumer, `onSelect` function will be\n * necessary to handle the selection of the related prompt and to trigger the stagger-fade-slide animation.\n *\n * @public\n */\nexport default defineComponent({\n name: 'RelatedPromptsTagList',\n xModule: relatedPromptsXModule.name,\n components: { DisplayEmitter, RelatedPrompt, SlidingPanel },\n props: {\n /**\n * The CSS class for the left and right button of the sliding panel.\n *\n * @public\n */\n buttonClass: String,\n /**\n * The boolean prop to handle the visiblity of sliding pannel buttons.\n *\n * @public\n */\n showButtons: { type: Boolean, default: true },\n /**\n * The CSS class for the wrapper of all the related prompt wrapper elements.\n *\n * @public\n */\n scrollContainerClass: String,\n /**\n * The CSS class for all the related prompt wrapper elements.\n *\n * @public\n */\n tagClass: String,\n /**\n * Array of colors to apply to the related prompts. It will be applied to tag\n * elements cyclically according to their index in the nex way: `tagColors[index % tagColors.length]`.\n *\n * @public\n */\n tagColors: Array as PropType<string[]>,\n /**\n * The duration of the total animation in milliseconds.\n *\n * @public\n */\n animationDurationInMs: {\n type: Number,\n default: 700,\n },\n /**\n * The boolean prop to handle if we should use the relatedPromptsFiltered or relatedPrompts.\n *\n * @public\n */\n useFilteredRelatedPrompts: {\n type: Boolean,\n default: false,\n },\n },\n setup(props) {\n const x = use$x()\n const {\n relatedPrompts,\n relatedPromptsFiltered,\n selectedPrompt: selectedPromptIndex,\n } = useState('relatedPrompts')\n\n const clickedListItemIndex = ref<number | null>(null)\n const initialOffsetLefts: Record<number, number> = {}\n const isAnimating = ref(false)\n const listItems = ref<HTMLElement[]>([])\n\n const relatedPromptsList = computed(() =>\n props.useFilteredRelatedPrompts ? relatedPromptsFiltered.value : relatedPrompts.value,\n )\n\n const sortedListItems = computed<HTMLElement[]>(() =>\n [...listItems.value].sort(\n (a: HTMLElement, b: HTMLElement) =>\n Number.parseInt(b.getAttribute('data-index')!) -\n Number.parseInt(a.getAttribute('data-index')!),\n ),\n )\n\n // The duration of a single animation (enter or leave) in milliseconds\n // if a related prompt is clicked (clickedListItemIndex.value !== null), the duration is divided by the number of related\n // prompts -1 (the clicked one is synchronized with the last one to leave or the first one to enter)\n const singleAnimationDurationInMs = computed(\n () =>\n props.animationDurationInMs /\n (clickedListItemIndex.value !== null\n ? relatedPromptsList.value.length - 1\n : relatedPromptsList.value.length),\n )\n\n const indexRelatedPrompts = computed(() =>\n relatedPromptsList.value.map((relatedPrompt, index) => ({ ...relatedPrompt, index })),\n )\n\n const visibleRelatedPrompts = computed(() =>\n selectedPromptIndex.value !== -1\n ? [indexRelatedPrompts.value[selectedPromptIndex.value]]\n : indexRelatedPrompts.value,\n )\n\n let timeOutId: number\n const resetTransitionStyle = (excludedProperties: Array<string> = ['width']) => {\n if (timeOutId) {\n clearTimeout(timeOutId)\n }\n\n isAnimating.value = true\n timeOutId = +setTimeout(() => {\n isAnimating.value = false\n clickedListItemIndex.value = null\n\n sortedListItems.value.forEach(element => {\n element.style.cssText\n .split(';')\n .map(rule => rule.split(':')[0]?.trim())\n .forEach(property => {\n if (!excludedProperties.includes(property)) {\n element.style.removeProperty(property)\n }\n })\n })\n }, props.animationDurationInMs)\n }\n\n const onSelect = (selectedIndex: number): void => {\n resetTransitionStyle()\n\n clickedListItemIndex.value = selectedIndex\n const selected: HTMLElement = sortedListItems.value.find(\n element => Number.parseInt(element.getAttribute('data-index')!) === selectedIndex,\n )!\n\n // selectedPromptIndex.value === -1 ? 'SELECTING' : 'DESELECTING'\n if (selectedPromptIndex.value === -1) {\n // Prepare all the elements for the leave animation (~ 'beforeLeave' hook). Remember the elements are\n // sorted in descending order by index.\n sortedListItems.value.forEach(element => {\n const index = Number.parseInt(element.getAttribute('data-index')!)\n\n initialOffsetLefts[index] = element.offsetLeft\n element.style.left = `${element.offsetLeft}px`\n element.style.position = 'absolute'\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`\n\n if (index !== selectedIndex) {\n element.style.opacity = '1'\n element.style.transitionDelay = `${\n (index < selectedIndex ? index : index - 1) * singleAnimationDurationInMs.value\n }ms`\n }\n })\n\n // Synchronize the transition delay of the selected element with the last\n // element to leave\n selected.style.transitionDelay = `${\n (relatedPromptsList.value.length > 1 ? relatedPromptsList.value.length - 2 : 0) *\n singleAnimationDurationInMs.value\n }ms`\n\n // Trigger the animation (selecting) for the selected element\n requestAnimationFrame(() => {\n const maxWidth = getComputedStyle(selected).maxWidth\n\n selected.style.left = '0px'\n selected.style.setProperty(\n 'width',\n `${maxWidth !== 'none' ? maxWidth : '100%'}`,\n 'important',\n )\n })\n } else {\n // Prepare the selected element for the deselecting animation\n selected.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`\n selected.style.left = '0px'\n selected.style.position = 'absolute'\n\n // Trigger the animation (deselecting) for the selected element\n selected.style.removeProperty('width')\n requestAnimationFrame(() => {\n selected.style.left = `${initialOffsetLefts[selectedIndex]}px`\n })\n }\n\n x.emit('UserSelectedARelatedPrompt', selectedIndex, {\n relatedPrompt: relatedPromptsList.value[selectedIndex],\n selectedPrompt: selectedPromptIndex.value,\n })\n }\n\n const onBeforeEnter = (el: Element) => {\n const element = el as HTMLElement\n const index = Number.parseInt(element.getAttribute('data-index')!)\n\n // Prepare the element for the enter animation\n element.style.opacity = '0'\n element.style.transform = 'translateY(5px)'\n element.style.transitionDelay = `${\n (clickedListItemIndex.value !== null && index > clickedListItemIndex.value\n ? index - 1\n : index) * singleAnimationDurationInMs.value\n }ms`\n element.style.transitionDuration = `${singleAnimationDurationInMs.value}ms`\n }\n\n const onEnter = (el: Element, done: () => void) => {\n const element = el as HTMLElement\n const index = Number.parseInt(element.getAttribute('data-index')!)\n\n // Also part of the preparation for the enter animation, but it needs to be done\n // once the element is inserted in DOM (if not the offsetLeft will be always 0)\n element.style.left = `${initialOffsetLefts[index] ?? element.offsetLeft}px`\n\n // trigger enter animation\n requestAnimationFrame(() => {\n element.style.opacity = '1'\n element.style.position = 'absolute'\n element.style.transform = 'translateY(0)'\n })\n\n done()\n }\n\n const onLeave = (el: Element, done: () => void) => {\n const element = el as HTMLElement\n\n // trigger leave animation\n requestAnimationFrame(() => {\n element.style.opacity = '0'\n element.style.transform = 'translateY(5px)'\n })\n\n // Wait for the animation to finish (done() exectution extracts the element from the DOM)\n setTimeout(done, props.animationDurationInMs)\n }\n\n // Changing the request will trigger the appear animation, so we need to reset the\n // style after it finishes\n x.on('SearchRequestChanged', false).subscribe(() => {\n resetTransitionStyle([])\n })\n\n onBeforeUnmount(() => {\n x.emit('RelatedPromptsUnmounted')\n })\n\n return {\n onSelect,\n onBeforeEnter,\n onEnter,\n onLeave,\n selectedPromptIndex,\n visibleRelatedPrompts,\n listItems,\n isAnimating,\n x,\n }\n },\n})\n</script>\n\n<style lang=\"css\">\n.x-related-prompts-tag-list-scroll-container {\n height: 100%;\n position: relative;\n}\n.x-related-prompts-tag-list {\n display: flex;\n gap: 16px;\n min-width: 100%;\n width: 100%;\n}\n.x-related-prompts-tag-list-item {\n height: 100%;\n flex-shrink: 0;\n}\n</style>\n"],"names":["DisplayEmitter"],"mappings":";;;;;;;;;;;;;;;;;;;AA6FA;;;;;;;AAOE;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,uBAAuB;IAC7B,OAAO,EAAE,qBAAqB,CAAC,IAAI;AACnC,IAAA,UAAU,EAAE,kBAAEA,WAAc,EAAE,aAAa,EAAE,YAAW,EAAG;AAC3D,IAAA,KAAK,E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|
2
|
+
import { getRelatedPromptsByQuery } from '../utils/related-prompts.utils.js';
|
|
2
3
|
|
|
3
4
|
const { fetchAndSave, cancelPrevious } = createFetchAndSaveActions({
|
|
4
5
|
async fetch({ dispatch }, request) {
|
|
5
6
|
return dispatch('fetchRelatedPrompts', request);
|
|
6
7
|
},
|
|
7
|
-
onSuccess({ commit }, relatedPrompts) {
|
|
8
|
+
onSuccess({ commit, state }, relatedPrompts) {
|
|
8
9
|
if (relatedPrompts) {
|
|
9
10
|
commit('setRelatedPromptsProducts', relatedPrompts);
|
|
11
|
+
commit('setFilteredRelatedPromptsProducts', getRelatedPromptsByQuery(relatedPrompts, state.query));
|
|
10
12
|
}
|
|
11
13
|
},
|
|
12
14
|
});
|
package/js/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-and-save-related-prompts.action.js","sources":["../../../../../../src/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.ts"],"sourcesContent":["import type { RelatedPrompt, RelatedPromptsRequest } from '@empathyco/x-types'\nimport type { RelatedPromptsActionContext } from '../types'\nimport { createFetchAndSaveActions } from '../../../../store/utils/fetch-and-save-action.utils'\n\nconst { fetchAndSave, cancelPrevious } = createFetchAndSaveActions<\n RelatedPromptsActionContext,\n RelatedPromptsRequest | null,\n RelatedPrompt[] | null\n>({\n async fetch({ dispatch }, request) {\n return dispatch('fetchRelatedPrompts', request)\n },\n onSuccess({ commit }, relatedPrompts) {\n if (relatedPrompts) {\n commit('setRelatedPromptsProducts', relatedPrompts)\n }\n },\n})\n\n/**\n * Default implementation for\n * {@link RelatedPromptsActions.fetchAndSaveRelatedPrompts} action.\n *\n * @public\n */\nexport const fetchAndSaveRelatedPrompts = fetchAndSave\n\n/**\n * Default implementation for\n * {@link RelatedPromptsActions.cancelFetchAndSaveRelatedPrompts} action.\n *\n * @public\n */\nexport const cancelFetchAndSaveRelatedPrompts = cancelPrevious\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch-and-save-related-prompts.action.js","sources":["../../../../../../src/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.ts"],"sourcesContent":["import type { RelatedPrompt, RelatedPromptsRequest } from '@empathyco/x-types'\nimport type { RelatedPromptsActionContext } from '../types'\nimport { createFetchAndSaveActions } from '../../../../store/utils/fetch-and-save-action.utils'\nimport { getRelatedPromptsByQuery } from '../utils/related-prompts.utils'\n\nconst { fetchAndSave, cancelPrevious } = createFetchAndSaveActions<\n RelatedPromptsActionContext,\n RelatedPromptsRequest | null,\n RelatedPrompt[] | null\n>({\n async fetch({ dispatch }, request) {\n return dispatch('fetchRelatedPrompts', request)\n },\n onSuccess({ commit, state }, relatedPrompts) {\n if (relatedPrompts) {\n commit('setRelatedPromptsProducts', relatedPrompts)\n commit(\n 'setFilteredRelatedPromptsProducts',\n getRelatedPromptsByQuery(relatedPrompts, state.query),\n )\n }\n },\n})\n\n/**\n * Default implementation for\n * {@link RelatedPromptsActions.fetchAndSaveRelatedPrompts} action.\n *\n * @public\n */\nexport const fetchAndSaveRelatedPrompts = fetchAndSave\n\n/**\n * Default implementation for\n * {@link RelatedPromptsActions.cancelFetchAndSaveRelatedPrompts} action.\n *\n * @public\n */\nexport const cancelFetchAndSaveRelatedPrompts = cancelPrevious\n"],"names":[],"mappings":";;;AAKA,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,yBAAyB,CAIhE;AACA,IAAA,MAAM,KAAK,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAA;AAC/B,QAAA,OAAO,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAA;KAChD;AACD,IAAA,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,cAAc,EAAA;AACzC,QAAA,IAAI,cAAc,EAAE;AAClB,YAAA,MAAM,CAAC,2BAA2B,EAAE,cAAc,CAAC,CAAA;AACnD,YAAA,MAAM,CACJ,mCAAmC,EACnC,wBAAwB,CAAC,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,CACtD,CAAA;AACF,SAAA;KACF;AACF,CAAA,CAAC,CAAA;AAEF;;;;;AAKG;AACI,MAAM,0BAA0B,GAAG,aAAY;AAEtD;;;;;AAKG;AACI,MAAM,gCAAgC,GAAG;;;;"}
|
|
@@ -15,6 +15,7 @@ const relatedPromptsXStoreModule = {
|
|
|
15
15
|
state: () => ({
|
|
16
16
|
query: '',
|
|
17
17
|
relatedPrompts: [],
|
|
18
|
+
relatedPromptsFiltered: [],
|
|
18
19
|
selectedPrompt: -1,
|
|
19
20
|
selectedQuery: -1,
|
|
20
21
|
status: 'initial',
|
|
@@ -34,6 +35,9 @@ const relatedPromptsXStoreModule = {
|
|
|
34
35
|
setRelatedPromptsProducts(state, products) {
|
|
35
36
|
state.relatedPrompts = products;
|
|
36
37
|
},
|
|
38
|
+
setFilteredRelatedPromptsProducts(state, products) {
|
|
39
|
+
state.relatedPromptsFiltered = products;
|
|
40
|
+
},
|
|
37
41
|
setSelectedPrompt(state, selectedPrompt) {
|
|
38
42
|
state.selectedPrompt = state.selectedPrompt === selectedPrompt ? -1 : selectedPrompt;
|
|
39
43
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sources":["../../../../../src/x-modules/related-prompts/store/module.ts"],"sourcesContent":["import type { RelatedPromptsXStoreModule } from './types'\nimport { setQuery } from '../../../store/utils/query.utils'\nimport { setStatus } from '../../../store/utils/status-store.utils'\nimport {\n cancelFetchAndSaveRelatedPrompts,\n fetchAndSaveRelatedPrompts,\n} from './actions/fetch-and-save-related-prompts.action'\nimport { fetchRelatedPrompts } from './actions/fetch-related-prompts.action'\nimport { setUrlParams } from './actions/set-url-params.action'\nimport { query } from './getters/related-prompts-query.getter'\nimport { request } from './getters/request.getter'\n\n/**\n * {@link XStoreModule} For the related prompt module.\n *\n * @internal\n */\nexport const relatedPromptsXStoreModule: RelatedPromptsXStoreModule = {\n state: () => ({\n query: '',\n relatedPrompts: [],\n selectedPrompt: -1,\n selectedQuery: -1,\n status: 'initial',\n params: {},\n relatedTags: [],\n }),\n getters: {\n request,\n query,\n },\n mutations: {\n setStatus,\n setQuery,\n setParams(state, params) {\n state.params = params\n },\n setRelatedPromptsProducts(state, products) {\n state.relatedPrompts = products\n },\n setSelectedPrompt(state, selectedPrompt) {\n state.selectedPrompt = state.selectedPrompt === selectedPrompt ? -1 : selectedPrompt\n },\n setSelectedQuery(state, selectedQuery) {\n state.selectedQuery = selectedQuery\n },\n resetRelatedPromptsState(state) {\n state.selectedQuery = -1\n state.selectedPrompt = -1\n state.relatedPrompts = []\n },\n resetSelectedPrompt(state) {\n state.selectedPrompt = -1\n },\n setRelatedPromptsRelatedTags(state, relatedTags) {\n state.relatedTags = relatedTags\n },\n },\n actions: {\n fetchRelatedPrompts,\n fetchAndSaveRelatedPrompts,\n cancelFetchAndSaveRelatedPrompts,\n setUrlParams,\n },\n}\n"],"names":[],"mappings":";;;;;;;;AAYA;;;;AAIG;AACU,MAAA,0BAA0B,GAA+B;AACpE,IAAA,KAAK,EAAE,OAAO;AACZ,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,cAAc,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"module.js","sources":["../../../../../src/x-modules/related-prompts/store/module.ts"],"sourcesContent":["import type { RelatedPromptsXStoreModule } from './types'\nimport { setQuery } from '../../../store/utils/query.utils'\nimport { setStatus } from '../../../store/utils/status-store.utils'\nimport {\n cancelFetchAndSaveRelatedPrompts,\n fetchAndSaveRelatedPrompts,\n} from './actions/fetch-and-save-related-prompts.action'\nimport { fetchRelatedPrompts } from './actions/fetch-related-prompts.action'\nimport { setUrlParams } from './actions/set-url-params.action'\nimport { query } from './getters/related-prompts-query.getter'\nimport { request } from './getters/request.getter'\n\n/**\n * {@link XStoreModule} For the related prompt module.\n *\n * @internal\n */\nexport const relatedPromptsXStoreModule: RelatedPromptsXStoreModule = {\n state: () => ({\n query: '',\n relatedPrompts: [],\n relatedPromptsFiltered: [],\n selectedPrompt: -1,\n selectedQuery: -1,\n status: 'initial',\n params: {},\n relatedTags: [],\n }),\n getters: {\n request,\n query,\n },\n mutations: {\n setStatus,\n setQuery,\n setParams(state, params) {\n state.params = params\n },\n setRelatedPromptsProducts(state, products) {\n state.relatedPrompts = products\n },\n setFilteredRelatedPromptsProducts(state, products) {\n state.relatedPromptsFiltered = products\n },\n setSelectedPrompt(state, selectedPrompt) {\n state.selectedPrompt = state.selectedPrompt === selectedPrompt ? -1 : selectedPrompt\n },\n setSelectedQuery(state, selectedQuery) {\n state.selectedQuery = selectedQuery\n },\n resetRelatedPromptsState(state) {\n state.selectedQuery = -1\n state.selectedPrompt = -1\n state.relatedPrompts = []\n },\n resetSelectedPrompt(state) {\n state.selectedPrompt = -1\n },\n setRelatedPromptsRelatedTags(state, relatedTags) {\n state.relatedTags = relatedTags\n },\n },\n actions: {\n fetchRelatedPrompts,\n fetchAndSaveRelatedPrompts,\n cancelFetchAndSaveRelatedPrompts,\n setUrlParams,\n },\n}\n"],"names":[],"mappings":";;;;;;;;AAYA;;;;AAIG;AACU,MAAA,0BAA0B,GAA+B;AACpE,IAAA,KAAK,EAAE,OAAO;AACZ,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,cAAc,EAAE,EAAE;AAClB,QAAA,sBAAsB,EAAE,EAAE;QAC1B,cAAc,EAAE,CAAC,CAAC;QAClB,aAAa,EAAE,CAAC,CAAC;AACjB,QAAA,MAAM,EAAE,SAAS;AACjB,QAAA,MAAM,EAAE,EAAE;AACV,QAAA,WAAW,EAAE,EAAE;KAChB,CAAC;AACF,IAAA,OAAO,EAAE;QACP,OAAO;QACP,KAAK;AACN,KAAA;AACD,IAAA,SAAS,EAAE;QACT,SAAS;QACT,QAAQ;QACR,SAAS,CAAC,KAAK,EAAE,MAAM,EAAA;AACrB,YAAA,KAAK,CAAC,MAAM,GAAG,MAAM,CAAA;SACtB;QACD,yBAAyB,CAAC,KAAK,EAAE,QAAQ,EAAA;AACvC,YAAA,KAAK,CAAC,cAAc,GAAG,QAAQ,CAAA;SAChC;QACD,iCAAiC,CAAC,KAAK,EAAE,QAAQ,EAAA;AAC/C,YAAA,KAAK,CAAC,sBAAsB,GAAG,QAAQ,CAAA;SACxC;QACD,iBAAiB,CAAC,KAAK,EAAE,cAAc,EAAA;AACrC,YAAA,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,KAAK,cAAc,GAAG,CAAC,CAAC,GAAG,cAAc,CAAA;SACrF;QACD,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAA;AACnC,YAAA,KAAK,CAAC,aAAa,GAAG,aAAa,CAAA;SACpC;AACD,QAAA,wBAAwB,CAAC,KAAK,EAAA;AAC5B,YAAA,KAAK,CAAC,aAAa,GAAG,CAAC,CAAC,CAAA;AACxB,YAAA,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAA;AACzB,YAAA,KAAK,CAAC,cAAc,GAAG,EAAE,CAAA;SAC1B;AACD,QAAA,mBAAmB,CAAC,KAAK,EAAA;AACvB,YAAA,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAA;SAC1B;QACD,4BAA4B,CAAC,KAAK,EAAE,WAAW,EAAA;AAC7C,YAAA,KAAK,CAAC,WAAW,GAAG,WAAW,CAAA;SAChC;AACF,KAAA;AACD,IAAA,OAAO,EAAE;QACP,mBAAmB;QACnB,0BAA0B;QAC1B,gCAAgC;QAChC,YAAY;AACb,KAAA;;;;;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters and sorts related prompts based on whether their next queries include
|
|
3
|
+
* any word from the given query.
|
|
4
|
+
*
|
|
5
|
+
* @param relatedPrompts - Array of RelatedPrompt objects to filter and sort.
|
|
6
|
+
* @param query - The query string to match against next queries.
|
|
7
|
+
* @returns Array of RelatedPrompt objects with sorted nextQueries.
|
|
8
|
+
*/
|
|
9
|
+
function getRelatedPromptsByQuery(relatedPrompts, query) {
|
|
10
|
+
const curatedRelatedPrompts = removeDuplicatesByNextQueries(relatedPrompts);
|
|
11
|
+
return curatedRelatedPrompts
|
|
12
|
+
.filter(relatedPrompt => relatedPrompt.nextQueries.some((nextQuery) => isQueryIncluded(nextQuery, query)))
|
|
13
|
+
.map(relatedPrompt => ({
|
|
14
|
+
...relatedPrompt,
|
|
15
|
+
nextQueries: relatedPrompt.nextQueries.sort((a, b) => {
|
|
16
|
+
const foundInA = isQueryIncluded(a, query);
|
|
17
|
+
const foundInB = isQueryIncluded(b, query);
|
|
18
|
+
if (foundInA === foundInB) {
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
return foundInA ? -1 : 1;
|
|
22
|
+
}),
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Checks if any word from the query is included in the given text.
|
|
27
|
+
*
|
|
28
|
+
* @param text - The text to search within.
|
|
29
|
+
* @param query - The query string containing words to search for.
|
|
30
|
+
* @returns True if any word from the query is found in the text, otherwise false.
|
|
31
|
+
*/
|
|
32
|
+
function isQueryIncluded(text, query) {
|
|
33
|
+
const queryWords = query.trim().toLowerCase().split(' ');
|
|
34
|
+
const textWords = text.trim().toLowerCase().split(' ');
|
|
35
|
+
return queryWords.some(queryWord => textWords.includes(queryWord));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Removes related prompts that mach at leat 2 nextQueries with another relatedPrompt.
|
|
39
|
+
*
|
|
40
|
+
* @param relatedPrompts - Array of RelatedPrompt objects to remove duplicated nextQueries.
|
|
41
|
+
* @returns Array of RelatedPrompt objects with no duplicated nextQueries.
|
|
42
|
+
*/
|
|
43
|
+
function removeDuplicatesByNextQueries(relatedPrompts) {
|
|
44
|
+
const uniquePromptsMap = [];
|
|
45
|
+
for (const currentPrompt of relatedPrompts) {
|
|
46
|
+
let hasMatch = false;
|
|
47
|
+
for (const previousPrompt of uniquePromptsMap) {
|
|
48
|
+
const matches = currentPrompt.nextQueries.filter(query => previousPrompt.nextQueries.includes(query));
|
|
49
|
+
if (matches.length >= 2) {
|
|
50
|
+
hasMatch = true;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (!hasMatch) {
|
|
55
|
+
uniquePromptsMap.push(currentPrompt);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return uniquePromptsMap;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { getRelatedPromptsByQuery };
|
|
62
|
+
//# sourceMappingURL=related-prompts.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"related-prompts.utils.js","sources":["../../../../../../src/x-modules/related-prompts/store/utils/related-prompts.utils.ts"],"sourcesContent":["import type { RelatedPrompt } from '@empathyco/x-types'\n\n/**\n * Filters and sorts related prompts based on whether their next queries include\n * any word from the given query.\n *\n * @param relatedPrompts - Array of RelatedPrompt objects to filter and sort.\n * @param query - The query string to match against next queries.\n * @returns Array of RelatedPrompt objects with sorted nextQueries.\n */\nexport function getRelatedPromptsByQuery(\n relatedPrompts: Array<RelatedPrompt>,\n query: string,\n): Array<RelatedPrompt> {\n const curatedRelatedPrompts = removeDuplicatesByNextQueries(relatedPrompts)\n return curatedRelatedPrompts\n .filter(relatedPrompt =>\n relatedPrompt.nextQueries.some((nextQuery: string) => isQueryIncluded(nextQuery, query)),\n )\n .map(relatedPrompt => ({\n ...relatedPrompt,\n nextQueries: relatedPrompt.nextQueries.sort((a, b) => {\n const foundInA = isQueryIncluded(a, query)\n const foundInB = isQueryIncluded(b, query)\n\n if (foundInA === foundInB) {\n return 0\n }\n\n return foundInA ? -1 : 1\n }),\n }))\n}\n\n/**\n * Checks if any word from the query is included in the given text.\n *\n * @param text - The text to search within.\n * @param query - The query string containing words to search for.\n * @returns True if any word from the query is found in the text, otherwise false.\n */\nfunction isQueryIncluded(text: string, query: string): boolean {\n const queryWords = query.trim().toLowerCase().split(' ')\n const textWords = text.trim().toLowerCase().split(' ')\n return queryWords.some(queryWord => textWords.includes(queryWord))\n}\n\n/**\n * Removes related prompts that mach at leat 2 nextQueries with another relatedPrompt.\n *\n * @param relatedPrompts - Array of RelatedPrompt objects to remove duplicated nextQueries.\n * @returns Array of RelatedPrompt objects with no duplicated nextQueries.\n */\nfunction removeDuplicatesByNextQueries(relatedPrompts: Array<RelatedPrompt>): Array<RelatedPrompt> {\n const uniquePromptsMap: Array<RelatedPrompt> = []\n\n for (const currentPrompt of relatedPrompts) {\n let hasMatch = false\n\n for (const previousPrompt of uniquePromptsMap) {\n const matches = currentPrompt.nextQueries.filter(query =>\n previousPrompt.nextQueries.includes(query),\n )\n if (matches.length >= 2) {\n hasMatch = true\n break\n }\n }\n\n if (!hasMatch) {\n uniquePromptsMap.push(currentPrompt)\n }\n }\n\n return uniquePromptsMap\n}\n"],"names":[],"mappings":"AAEA;;;;;;;AAOG;AACa,SAAA,wBAAwB,CACtC,cAAoC,EACpC,KAAa,EAAA;AAEb,IAAA,MAAM,qBAAqB,GAAG,6BAA6B,CAAC,cAAc,CAAC,CAAA;AAC3E,IAAA,OAAO,qBAAqB;SACzB,MAAM,CAAC,aAAa,IACnB,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,SAAiB,KAAK,eAAe,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CACzF;AACA,SAAA,GAAG,CAAC,aAAa,KAAK;AACrB,QAAA,GAAG,aAAa;AAChB,QAAA,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAI;YACnD,MAAM,QAAQ,GAAG,eAAe,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;YAC1C,MAAM,QAAQ,GAAG,eAAe,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;YAE1C,IAAI,QAAQ,KAAK,QAAQ,EAAE;AACzB,gBAAA,OAAO,CAAC,CAAA;AACT,aAAA;YAED,OAAO,QAAQ,GAAG,CAAC,CAAC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
|
3
|
+
"version": "6.0.0-alpha.106",
|
|
4
4
|
"description": "Empathy X Components",
|
|
5
5
|
"author": "Empathy Systems Corporation S.L.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"@badeball/cypress-cucumber-preprocessor": "22.0.1",
|
|
98
98
|
"@bahmutov/cypress-esbuild-preprocessor": "2.2.5",
|
|
99
99
|
"@cucumber/messages": "27.2.0",
|
|
100
|
-
"@empathyco/x-tailwindcss": "
|
|
100
|
+
"@empathyco/x-tailwindcss": "2.0.0-alpha.12",
|
|
101
101
|
"@microsoft/api-documenter": "7.23.0",
|
|
102
102
|
"@microsoft/api-extractor": "7.52.8",
|
|
103
103
|
"@testing-library/jest-dom": "5.17.0",
|
|
@@ -142,5 +142,5 @@
|
|
|
142
142
|
"access": "public",
|
|
143
143
|
"directory": "dist"
|
|
144
144
|
},
|
|
145
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "feb1ff94529305d16fa6415254f9b89b24c0352e"
|
|
146
146
|
}
|
|
@@ -52632,6 +52632,42 @@
|
|
|
52632
52632
|
"endIndex": 2
|
|
52633
52633
|
}
|
|
52634
52634
|
},
|
|
52635
|
+
{
|
|
52636
|
+
"kind": "PropertySignature",
|
|
52637
|
+
"canonicalReference": "@empathyco/x-components!RelatedPromptsMutations#setFilteredRelatedPromptsProducts:member",
|
|
52638
|
+
"docComment": "/**\n * Sets the filtered related prompts of the module.\n *\n * @param products - The new related prompts to save to the state.\n */\n",
|
|
52639
|
+
"excerptTokens": [
|
|
52640
|
+
{
|
|
52641
|
+
"kind": "Content",
|
|
52642
|
+
"text": "setFilteredRelatedPromptsProducts: "
|
|
52643
|
+
},
|
|
52644
|
+
{
|
|
52645
|
+
"kind": "Content",
|
|
52646
|
+
"text": "(products: "
|
|
52647
|
+
},
|
|
52648
|
+
{
|
|
52649
|
+
"kind": "Reference",
|
|
52650
|
+
"text": "RelatedPrompt",
|
|
52651
|
+
"canonicalReference": "@empathyco/x-components!RelatedPrompt_2:interface"
|
|
52652
|
+
},
|
|
52653
|
+
{
|
|
52654
|
+
"kind": "Content",
|
|
52655
|
+
"text": "[]) => void"
|
|
52656
|
+
},
|
|
52657
|
+
{
|
|
52658
|
+
"kind": "Content",
|
|
52659
|
+
"text": ";"
|
|
52660
|
+
}
|
|
52661
|
+
],
|
|
52662
|
+
"isReadonly": false,
|
|
52663
|
+
"isOptional": false,
|
|
52664
|
+
"releaseTag": "Public",
|
|
52665
|
+
"name": "setFilteredRelatedPromptsProducts",
|
|
52666
|
+
"propertyTypeTokenRange": {
|
|
52667
|
+
"startIndex": 1,
|
|
52668
|
+
"endIndex": 4
|
|
52669
|
+
}
|
|
52670
|
+
},
|
|
52635
52671
|
{
|
|
52636
52672
|
"kind": "PropertySignature",
|
|
52637
52673
|
"canonicalReference": "@empathyco/x-components!RelatedPromptsMutations#setParams:member",
|
|
@@ -52903,6 +52939,38 @@
|
|
|
52903
52939
|
"endIndex": 3
|
|
52904
52940
|
}
|
|
52905
52941
|
},
|
|
52942
|
+
{
|
|
52943
|
+
"kind": "PropertySignature",
|
|
52944
|
+
"canonicalReference": "@empathyco/x-components!RelatedPromptsState#relatedPromptsFiltered:member",
|
|
52945
|
+
"docComment": "/**\n * The list of the filtered related-prompts, related to the `query` property of the state.\n */\n",
|
|
52946
|
+
"excerptTokens": [
|
|
52947
|
+
{
|
|
52948
|
+
"kind": "Content",
|
|
52949
|
+
"text": "relatedPromptsFiltered: "
|
|
52950
|
+
},
|
|
52951
|
+
{
|
|
52952
|
+
"kind": "Reference",
|
|
52953
|
+
"text": "RelatedPrompt",
|
|
52954
|
+
"canonicalReference": "@empathyco/x-components!RelatedPrompt_2:interface"
|
|
52955
|
+
},
|
|
52956
|
+
{
|
|
52957
|
+
"kind": "Content",
|
|
52958
|
+
"text": "[]"
|
|
52959
|
+
},
|
|
52960
|
+
{
|
|
52961
|
+
"kind": "Content",
|
|
52962
|
+
"text": ";"
|
|
52963
|
+
}
|
|
52964
|
+
],
|
|
52965
|
+
"isReadonly": false,
|
|
52966
|
+
"isOptional": false,
|
|
52967
|
+
"releaseTag": "Public",
|
|
52968
|
+
"name": "relatedPromptsFiltered",
|
|
52969
|
+
"propertyTypeTokenRange": {
|
|
52970
|
+
"startIndex": 1,
|
|
52971
|
+
"endIndex": 3
|
|
52972
|
+
}
|
|
52973
|
+
},
|
|
52906
52974
|
{
|
|
52907
52975
|
"kind": "PropertySignature",
|
|
52908
52976
|
"canonicalReference": "@empathyco/x-components!RelatedPromptsState#relatedTags:member",
|
|
@@ -53075,7 +53143,16 @@
|
|
|
53075
53143
|
},
|
|
53076
53144
|
{
|
|
53077
53145
|
"kind": "Content",
|
|
53078
|
-
"text": ";\n default: number;\n };\n
|
|
53146
|
+
"text": ";\n default: number;\n };\n useFilteredRelatedPrompts: {\n type: "
|
|
53147
|
+
},
|
|
53148
|
+
{
|
|
53149
|
+
"kind": "Reference",
|
|
53150
|
+
"text": "BooleanConstructor",
|
|
53151
|
+
"canonicalReference": "!BooleanConstructor:interface"
|
|
53152
|
+
},
|
|
53153
|
+
{
|
|
53154
|
+
"kind": "Content",
|
|
53155
|
+
"text": ";\n default: boolean;\n };\n}, {\n onSelect: (selectedIndex: number) => void;\n onBeforeEnter: (el: "
|
|
53079
53156
|
},
|
|
53080
53157
|
{
|
|
53081
53158
|
"kind": "Reference",
|
|
@@ -53435,7 +53512,16 @@
|
|
|
53435
53512
|
},
|
|
53436
53513
|
{
|
|
53437
53514
|
"kind": "Content",
|
|
53438
|
-
"text": ";\n default: number;\n };\n
|
|
53515
|
+
"text": ";\n default: number;\n };\n useFilteredRelatedPrompts: {\n type: "
|
|
53516
|
+
},
|
|
53517
|
+
{
|
|
53518
|
+
"kind": "Reference",
|
|
53519
|
+
"text": "BooleanConstructor",
|
|
53520
|
+
"canonicalReference": "!BooleanConstructor:interface"
|
|
53521
|
+
},
|
|
53522
|
+
{
|
|
53523
|
+
"kind": "Content",
|
|
53524
|
+
"text": ";\n default: boolean;\n };\n}>>, {\n showButtons: boolean;\n animationDurationInMs: number;\n useFilteredRelatedPrompts: boolean;\n}, {}>"
|
|
53439
53525
|
}
|
|
53440
53526
|
],
|
|
53441
53527
|
"fileUrlPath": "dist/types/x-modules/related-prompts/components/related-prompts-tag-list.vue.d.ts",
|
|
@@ -53444,7 +53530,7 @@
|
|
|
53444
53530
|
"name": "RelatedPromptsTagList",
|
|
53445
53531
|
"variableTypeTokenRange": {
|
|
53446
53532
|
"startIndex": 1,
|
|
53447
|
-
"endIndex":
|
|
53533
|
+
"endIndex": 100
|
|
53448
53534
|
}
|
|
53449
53535
|
},
|
|
53450
53536
|
{
|
|
@@ -5907,6 +5907,7 @@ showOnlyAfterOffset: boolean;
|
|
|
5907
5907
|
export interface RelatedPromptsMutations extends StatusMutations, QueryMutations {
|
|
5908
5908
|
resetRelatedPromptsState: () => void;
|
|
5909
5909
|
resetSelectedPrompt: () => void;
|
|
5910
|
+
setFilteredRelatedPromptsProducts: (products: RelatedPrompt_2[]) => void;
|
|
5910
5911
|
setParams: (params: Dictionary<unknown>) => void;
|
|
5911
5912
|
setRelatedPromptsProducts: (products: RelatedPrompt_2[]) => void;
|
|
5912
5913
|
setRelatedPromptsRelatedTags: (relatedTags: RelatedTag_2[]) => void;
|
|
@@ -5918,6 +5919,7 @@ export interface RelatedPromptsMutations extends StatusMutations, QueryMutations
|
|
|
5918
5919
|
export interface RelatedPromptsState extends StatusState, QueryState {
|
|
5919
5920
|
params: Dictionary<unknown>;
|
|
5920
5921
|
relatedPrompts: RelatedPrompt_2[];
|
|
5922
|
+
relatedPromptsFiltered: RelatedPrompt_2[];
|
|
5921
5923
|
relatedTags: RelatedTag_2[];
|
|
5922
5924
|
selectedPrompt: number;
|
|
5923
5925
|
selectedQuery: number;
|
|
@@ -5944,6 +5946,10 @@ animationDurationInMs: {
|
|
|
5944
5946
|
type: NumberConstructor;
|
|
5945
5947
|
default: number;
|
|
5946
5948
|
};
|
|
5949
|
+
useFilteredRelatedPrompts: {
|
|
5950
|
+
type: BooleanConstructor;
|
|
5951
|
+
default: boolean;
|
|
5952
|
+
};
|
|
5947
5953
|
}, {
|
|
5948
5954
|
onSelect: (selectedIndex: number) => void;
|
|
5949
5955
|
onBeforeEnter: (el: Element) => void;
|
|
@@ -5986,9 +5992,14 @@ animationDurationInMs: {
|
|
|
5986
5992
|
type: NumberConstructor;
|
|
5987
5993
|
default: number;
|
|
5988
5994
|
};
|
|
5995
|
+
useFilteredRelatedPrompts: {
|
|
5996
|
+
type: BooleanConstructor;
|
|
5997
|
+
default: boolean;
|
|
5998
|
+
};
|
|
5989
5999
|
}>>, {
|
|
5990
6000
|
showButtons: boolean;
|
|
5991
6001
|
animationDurationInMs: number;
|
|
6002
|
+
useFilteredRelatedPrompts: boolean;
|
|
5992
6003
|
}, {}>;
|
|
5993
6004
|
|
|
5994
6005
|
// @internal
|
|
@@ -9304,7 +9315,7 @@ export type XStoreModuleOptions<StoreModule extends AnyXStoreModule> = StoreModu
|
|
|
9304
9315
|
// dist/types/x-modules/facets/components/filters/all-filter.vue.d.ts:16:9 - (ae-forgotten-export) The symbol "Facet" needs to be exported by the entry point index.d.ts
|
|
9305
9316
|
// dist/types/x-modules/facets/components/filters/editable-number-range-filter.vue.d.ts:25:9 - (ae-forgotten-export) The symbol "EditableNumberRangeFilter_2" needs to be exported by the entry point index.d.ts
|
|
9306
9317
|
// dist/types/x-modules/facets/components/lists/selected-filters-list.vue.d.ts:35:5 - (ae-forgotten-export) The symbol "RenderFilter" needs to be exported by the entry point index.d.ts
|
|
9307
|
-
// dist/types/x-modules/related-prompts/components/related-prompts-tag-list.vue.d.ts:
|
|
9318
|
+
// dist/types/x-modules/related-prompts/components/related-prompts-tag-list.vue.d.ts:71:9 - (ae-forgotten-export) The symbol "RelatedPromptNextQuery" needs to be exported by the entry point index.d.ts
|
|
9308
9319
|
// dist/types/x-modules/search/components/banner.vue.d.ts:23:9 - (ae-forgotten-export) The symbol "Banner_2" needs to be exported by the entry point index.d.ts
|
|
9309
9320
|
// dist/types/x-modules/search/components/partial-results-list.vue.d.ts:27:5 - (ae-forgotten-export) The symbol "PartialResult" needs to be exported by the entry point index.d.ts
|
|
9310
9321
|
// dist/types/x-modules/search/components/sort-list.vue.d.ts:30:5 - (ae-forgotten-export) The symbol "SortListItem" needs to be exported by the entry point index.d.ts
|
|
@@ -51,6 +51,15 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
51
51
|
type: NumberConstructor;
|
|
52
52
|
default: number;
|
|
53
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* The boolean prop to handle if we should use the relatedPromptsFiltered or relatedPrompts.
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
useFilteredRelatedPrompts: {
|
|
60
|
+
type: BooleanConstructor;
|
|
61
|
+
default: boolean;
|
|
62
|
+
};
|
|
54
63
|
}, {
|
|
55
64
|
onSelect: (selectedIndex: number) => void;
|
|
56
65
|
onBeforeEnter: (el: Element) => void;
|
|
@@ -124,9 +133,19 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
124
133
|
type: NumberConstructor;
|
|
125
134
|
default: number;
|
|
126
135
|
};
|
|
136
|
+
/**
|
|
137
|
+
* The boolean prop to handle if we should use the relatedPromptsFiltered or relatedPrompts.
|
|
138
|
+
*
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
useFilteredRelatedPrompts: {
|
|
142
|
+
type: BooleanConstructor;
|
|
143
|
+
default: boolean;
|
|
144
|
+
};
|
|
127
145
|
}>>, {
|
|
128
146
|
showButtons: boolean;
|
|
129
147
|
animationDurationInMs: number;
|
|
148
|
+
useFilteredRelatedPrompts: boolean;
|
|
130
149
|
}, {}>;
|
|
131
150
|
export default _default;
|
|
132
151
|
//# sourceMappingURL=related-prompts-tag-list.vue?vue&type=script&lang.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"related-prompts-tag-list.vue?vue&type=script&lang.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/related-prompts/components/related-prompts-tag-list.vue?vue&type=script&lang.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AAQnC;;;;;;;GAOG;;IAMC;;;;OAIG;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;;OAKG;;IAEH;;;;OAIG;;;;;;
|
|
1
|
+
{"version":3,"file":"related-prompts-tag-list.vue?vue&type=script&lang.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/related-prompts/components/related-prompts-tag-list.vue?vue&type=script&lang.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AAQnC;;;;;;;GAOG;;IAMC;;;;OAIG;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;;OAKG;;IAEH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;;8BA4E8B,MAAM,KAAG,IAAI;wBAiEnB,OAAO;kBAeb,OAAO,QAAQ,MAAM,IAAI;kBAkBzB,OAAO,QAAQ,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;IA1N9C;;;;OAIG;;IAEH;;;;OAIG;;;;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;;OAKG;;IAEH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;;;;;;AAjDP,wBAkQE"}
|
package/types/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-and-save-related-prompts.action.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC9E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"fetch-and-save-related-prompts.action.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/related-prompts/store/actions/fetch-and-save-related-prompts.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC9E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAA;AAuB3D;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,uGAAe,CAAA;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,YAAiB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/related-prompts/store/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAYzD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/related-prompts/store/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAYzD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,0BAmDxC,CAAA"}
|
|
@@ -12,6 +12,8 @@ import type { UrlParams } from '../../../types';
|
|
|
12
12
|
export interface RelatedPromptsState extends StatusState, QueryState {
|
|
13
13
|
/** The list of the related-prompts, related to the `query` property of the state. */
|
|
14
14
|
relatedPrompts: RelatedPrompt[];
|
|
15
|
+
/** The list of the filtered related-prompts, related to the `query` property of the state. */
|
|
16
|
+
relatedPromptsFiltered: RelatedPrompt[];
|
|
15
17
|
/** The index of the selected related-prompt. */
|
|
16
18
|
selectedPrompt: number;
|
|
17
19
|
/** The index of the selected next query. */
|
|
@@ -53,6 +55,12 @@ export interface RelatedPromptsMutations extends StatusMutations, QueryMutations
|
|
|
53
55
|
* @param products - The new related prompts to save to the state.
|
|
54
56
|
*/
|
|
55
57
|
setRelatedPromptsProducts: (products: RelatedPrompt[]) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Sets the filtered related prompts of the module.
|
|
60
|
+
*
|
|
61
|
+
* @param products - The new related prompts to save to the state.
|
|
62
|
+
*/
|
|
63
|
+
setFilteredRelatedPromptsProducts: (products: RelatedPrompt[]) => void;
|
|
56
64
|
/**
|
|
57
65
|
* Sets the selected related prompt.
|
|
58
66
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/related-prompts/store/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC1F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAA;AAC3F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,WAAW,EAAE,UAAU;IAClE,qFAAqF;IACrF,cAAc,EAAE,aAAa,EAAE,CAAA;IAC/B,gDAAgD;IAChD,cAAc,EAAE,MAAM,CAAA;IACtB,4CAA4C;IAC5C,aAAa,EAAE,MAAM,CAAA;IACrB,8CAA8C;IAC9C,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAC3B,kFAAkF;IAClF,WAAW,EAAE,UAAU,EAAE,CAAA;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,EAAE,qBAAqB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
|
+
* Filters and sorts related prompts based on whether their next queries include
|
|
4
|
+
* any word from the given query.
|
|
5
|
+
*
|
|
6
|
+
* @param relatedPrompts - Array of RelatedPrompt objects to filter and sort.
|
|
7
|
+
* @param query - The query string to match against next queries.
|
|
8
|
+
* @returns Array of RelatedPrompt objects with sorted nextQueries.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getRelatedPromptsByQuery(relatedPrompts: Array<RelatedPrompt>, query: string): Array<RelatedPrompt>;
|
|
11
|
+
//# sourceMappingURL=related-prompts.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"related-prompts.utils.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/related-prompts/store/utils/related-prompts.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,EACpC,KAAK,EAAE,MAAM,GACZ,KAAK,CAAC,aAAa,CAAC,CAmBtB"}
|