@empathyco/x-components 3.0.0-alpha.366 → 3.0.0-alpha.368

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/design-system/deprecated-full-theme.css +18 -18
  3. package/docs/API-reference/api/x-components.basecurrency.md +20 -11
  4. package/docs/API-reference/api/x-components.basesuggestion.md +48 -23
  5. package/docs/API-reference/api/x-components.md +2 -2
  6. package/js/components/currency/base-currency.vue.js.map +1 -1
  7. package/js/components/currency/base-currency.vue_rollup-plugin-vue_script.vue.js +51 -38
  8. package/js/components/currency/base-currency.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  9. package/js/components/result/base-result-image.vue.js +1 -1
  10. package/js/components/result/base-result-image.vue.js.map +1 -1
  11. package/js/components/result/base-result-image.vue_rollup-plugin-vue_script.vue.js +6 -1
  12. package/js/components/result/base-result-image.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  13. package/js/components/result/base-result-image.vue_rollup-plugin-vue_styles.0.vue.js +1 -1
  14. package/js/components/suggestions/base-suggestion.vue.js +6 -2
  15. package/js/components/suggestions/base-suggestion.vue.js.map +1 -1
  16. package/js/components/suggestions/base-suggestion.vue_rollup-plugin-vue_script.vue.js +124 -94
  17. package/js/components/suggestions/base-suggestion.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  18. package/package.json +13 -13
  19. package/report/x-components.api.json +345 -409
  20. package/report/x-components.api.md +67 -23
  21. package/types/components/currency/base-currency.vue.d.ts +26 -20
  22. package/types/components/currency/base-currency.vue.d.ts.map +1 -1
  23. package/types/components/result/base-result-image.vue.d.ts.map +1 -1
  24. package/types/components/suggestions/base-suggestion.vue.d.ts +55 -36
  25. package/types/components/suggestions/base-suggestion.vue.d.ts.map +1 -1
  26. package/docs/API-reference/api/x-components.basecurrency.format.md +0 -13
  27. package/docs/API-reference/api/x-components.basecurrency.injectedformat.md +0 -13
  28. package/docs/API-reference/api/x-components.basecurrency.value.md +0 -18
  29. package/docs/API-reference/api/x-components.basesuggestion.dynamiccssclasses.md +0 -18
  30. package/docs/API-reference/api/x-components.basesuggestion.emitevents.md +0 -17
  31. package/docs/API-reference/api/x-components.basesuggestion.events.md +0 -18
  32. package/docs/API-reference/api/x-components.basesuggestion.feature.md +0 -13
  33. package/docs/API-reference/api/x-components.basesuggestion.filter.md +0 -13
  34. package/docs/API-reference/api/x-components.basesuggestion.highlightcurated.md +0 -13
  35. package/docs/API-reference/api/x-components.basesuggestion.query.md +0 -13
  36. package/docs/API-reference/api/x-components.basesuggestion.suggestion.md +0 -13
  37. package/docs/API-reference/api/x-components.basesuggestion.suggestionselectedevents.md +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"base-suggestion.vue.js","sources":["../../../../src/components/suggestions/base-suggestion.vue"],"sourcesContent":["<template>\n <button @click=\"emitEvents\" v-on=\"$listeners\" :class=\"dynamicCSSClasses\">\n <!--\n @slot Button content\n @binding {Suggestion} suggestion - Suggestion data\n @binding {String} query - The query that the suggestion belongs to\n @binding {Filter} filter - Suggestion's filter\n -->\n <slot v-bind=\"{ suggestion, query, filter }\">\n <Highlight class=\"x-suggestion__query\" :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\" class=\"x-suggestion__filter\">{{ filter.label }}</span>\n </slot>\n </button>\n</template>\n\n<script lang=\"ts\">\n import { BooleanFilter, Suggestion } from '@empathyco/x-types';\n import { forEach } from '@empathyco/x-utils';\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { QueryFeature } from '../../types';\n import { VueCSSClasses } from '../../utils/types';\n import { XEventsTypes } from '../../wiring/events.types';\n import Highlight from '../highlight.vue';\n\n /**\n * Renders a button with a default slot. It receives a query, which should be the query of the\n * module using this component, a suggestion, the {@link XEvent | XEvents} that will be emitted\n * on click with a given feature.\n *\n * The default slot receives the suggestion and the matched query has props.\n *\n * @public\n */\n @Component({\n components: { Highlight }\n })\n export default class BaseSuggestion extends Vue {\n /**\n * The normalized query of the module using this component.\n *\n * @public\n */\n @Prop({ default: '' })\n protected query!: string;\n\n /**\n * The suggestion to render and use in the default slot.\n *\n * @public\n */\n @Prop({ required: true })\n protected suggestion!: Suggestion;\n\n /**\n * The feature from which the events will be emitted.\n *\n * @public\n */\n @Prop() //TODO: set to true when the suggestions components pass it.\n protected feature?: QueryFeature;\n\n /**\n * The {@link XEvent | XEvents} that will be emitted when selecting a suggestion.\n *\n * @public\n */\n @Prop({ required: true })\n protected suggestionSelectedEvents!: Partial<XEventsTypes>;\n\n /**\n * Indicates if the curated suggestion should be highlighted.\n *\n * @public\n */\n @Prop({ default: false, type: Boolean })\n protected highlightCurated!: boolean;\n\n /**\n * The event handler that will be triggered when clicking on a suggestion.\n *\n * @remarks\n * UserAcceptedAQuery: suggestion.query\n * UserSelectedASuggestion: suggestion\n * UserClickedAFilter: suggestion.facets[0].filters[0]\n * Merges the events defined in the suggestionSelectedEvents prop and also emits them\n *\n * @returns The {@link XEvent | XEvents} to emit.\n * @public\n */\n protected get events(): Partial<XEventsTypes> {\n const filterEvent: Partial<XEventsTypes> = this.filter\n ? { UserClickedAFilter: this.filter }\n : {};\n return {\n UserAcceptedAQuery: this.suggestion.query,\n UserSelectedASuggestion: this.suggestion,\n ...this.suggestionSelectedEvents,\n ...filterEvent\n };\n }\n\n /**\n * Emits the events when the button is clicked.\n *\n * @public\n */\n protected emitEvents(): void {\n forEach(this.events, (event, payload) => {\n this.$x.emit(event, payload, {\n target: this.$el as HTMLElement,\n feature: this.feature\n });\n });\n }\n\n /**\n * Returns the suggestion filter object.\n * It is a BooleanFilter because the label is needed.\n * It returns only the first element because the facets and filters are being planned\n * in the BaseSuggestions component.\n *\n * @returns The filter.\n * @public\n */\n protected get filter(): BooleanFilter | undefined {\n return this.suggestion.facets?.[0]?.filters[0] as BooleanFilter;\n }\n\n /**\n * Checks if the suggestion is curated and if it should be highlighted.\n *\n * @returns True if the suggestion is curated and should be highlighted.\n *\n * @internal\n */\n protected get shouldHighlightCurated(): boolean {\n return this.highlightCurated && !!this.suggestion.isCurated;\n }\n\n /**\n * Generates css classes dynamically.\n *\n * @remarks\n * 'x-suggestion--matching added when the query should be matched.\n *\n * @returns The {@link VueCSSClasses} classes.\n * @public\n */\n protected get dynamicCSSClasses(): VueCSSClasses {\n return {\n 'x-suggestion--is-curated': this.shouldHighlightCurated\n };\n }\n }\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- `UserAcceptedAQuery`: the event is emitted after the user clicks the button. The event payload is\n the suggestion query data.\n- `UserSelectedASuggestion`: the event is emitted after the user clicks the button. The event\n payload is the suggestion data.\n- `UserClickedAFilter`: the event is emitted after the user clicks the button if the suggestion\n includes a filter. The event payload is the suggestion filter.\n- The component can emit more events on click using the `suggestionSelectedEvents` prop.\n\n## See it in action\n\nThis suggestion component expects a suggestion to render and pass to its default slot, a normalized\nquery to compare with the suggestion's query and highlight its matching parts, and events to emit\nwhen the suggestion is selected.\n\nIf the suggestion contains a filter, it is displayed next to the suggestion.\n\n```vue live\n<template>\n <BaseSuggestion v-bind=\"{ query, suggestion }\" />\n</template>\n<script>\n import { BaseSuggestion } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionDemo',\n components: {\n BaseSuggestion\n },\n data() {\n return {\n query: 'st',\n suggestion: {\n modelName: 'QuerySuggestion',\n query: 'steak',\n facet: {\n namedModel: 'SimpleFacet',\n id: 'category',\n label: 'Category',\n filters: [\n {\n id: 'category:groceries',\n modelName: 'SimpleFilter',\n facetId: 'category-facet',\n label: 'Groceries',\n selected: false,\n totalResults: 10\n }\n ]\n }\n }\n };\n }\n };\n</script>\n```\n\n### Customise the content\n\nYou can make this component render any content you want by using the `default` slot.\n\n```vue live\n<template>\n <BaseSuggestion v-bind=\"{ query, suggestion }\" #default=\"{ suggestion, query, filter }\">\n <span>🔍</span>\n <Highlight :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\">{{ filter.label }}</span>\n </BaseSuggestion>\n</template>\n<script>\n import { BaseSuggestion } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionDemo',\n components: {\n BaseSuggestion\n },\n data() {\n return {\n query: 'st',\n suggestion: {\n modelName: 'QuerySuggestion',\n query: 'steak'\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA,MAAc,cAAA,GAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"base-suggestion.vue.js","sources":["../../../../src/components/suggestions/base-suggestion.vue"],"sourcesContent":["<template>\n <button ref=\"el\" @click=\"emitEvents\" v-on=\"$listeners\" :class=\"dynamicCSSClasses\">\n <!--\n @slot Button content\n @binding {Suggestion} suggestion - Suggestion data\n @binding {String} query - The query that the suggestion belongs to\n @binding {Filter} filter - Suggestion's filter\n -->\n <slot v-bind=\"{ query, suggestion, filter }\">\n <Highlight class=\"x-suggestion__query\" :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\" class=\"x-suggestion__filter\">{{ filter.label }}</span>\n </slot>\n </button>\n</template>\n\n<script lang=\"ts\">\n import { BooleanFilter, Suggestion } from '@empathyco/x-types';\n import { forEach } from '@empathyco/x-utils';\n import { computed, defineComponent, PropType, ref } from 'vue';\n import { QueryFeature } from '../../types';\n import { VueCSSClasses } from '../../utils/types';\n import { XEventsTypes } from '../../wiring/events.types';\n import Highlight from '../highlight.vue';\n import { use$x } from '../../composables/index';\n\n /**\n * Renders a button with a default slot. It receives a query, which should be the query of the\n * module using this component, a suggestion, the {@link XEvent | XEvents} that will be emitted\n * on click with a given feature.\n *\n * The default slot receives the suggestion and the matched query has props.\n *\n * @public\n */\n export default defineComponent({\n components: { Highlight },\n props: {\n /**\n * The normalized query of the module using this component.\n *\n * @public\n */\n query: {\n type: String,\n default: ''\n },\n\n /**\n * The suggestion to render and use in the default slot.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<Suggestion>,\n required: true\n },\n\n /**\n * The feature from which the events will be emitted.\n *\n * @public\n */\n //TODO: set to true when the suggestions components pass it.\n feature: {\n type: String as PropType<QueryFeature>\n },\n\n /**\n * The {@link XEvent | XEvents} that will be emitted when selecting a suggestion.\n *\n * @public\n */\n suggestionSelectedEvents: {\n type: Object as PropType<Partial<XEventsTypes>>,\n required: true\n },\n\n /**\n * Indicates if the curated suggestion should be highlighted.\n *\n * @public\n */\n highlightCurated: {\n type: Boolean\n }\n },\n\n setup(props) {\n const el = ref<HTMLElement | null>(null);\n\n const $x = use$x();\n\n /**\n * Returns the suggestion filter object.\n * It is a BooleanFilter because the label is needed.\n * It returns only the first element because the facets and filters are being planned\n * in the BaseSuggestions component.\n *\n * @returns The filter.\n * @public\n */\n const filter = computed<BooleanFilter | undefined>(\n () => props.suggestion.facets?.[0]?.filters[0] as BooleanFilter\n );\n\n /**\n * The event handler that will be triggered when clicking on a suggestion.\n *\n * @remarks\n * UserAcceptedAQuery: suggestion.query\n * UserSelectedASuggestion: suggestion\n * UserClickedAFilter: suggestion.facets[0].filters[0]\n * Merges the events defined in the suggestionSelectedEvents prop and also emits them\n *\n * @returns The {@link XEvent | XEvents} to emit.\n * @public\n */\n const events = computed<Partial<XEventsTypes>>(() => {\n const filterEvent: Partial<XEventsTypes> = filter.value\n ? { UserClickedAFilter: filter.value }\n : {};\n return {\n UserAcceptedAQuery: props.suggestion.query,\n UserSelectedASuggestion: props.suggestion,\n ...props.suggestionSelectedEvents,\n ...filterEvent\n };\n });\n\n /**\n * Emits the events when the button is clicked.\n *\n * @public\n */\n const emitEvents = (): void => {\n forEach(events.value, (event, payload): void => {\n $x.emit(event, payload, {\n target: el.value!,\n feature: props.feature\n });\n });\n };\n\n /**\n * Checks if the suggestion is curated and if it should be highlighted.\n *\n * @returns True if the suggestion is curated and should be highlighted.\n *\n * @internal\n */\n const shouldHighlightCurated = computed<boolean>(\n () => props.highlightCurated && !!props.suggestion.isCurated\n );\n\n /**\n * Generates css classes dynamically.\n *\n * @remarks\n * 'x-suggestion--matching added when the query should be matched.\n *\n * @returns The {@link VueCSSClasses} classes.\n * @public\n */\n const dynamicCSSClasses = computed<VueCSSClasses>(() => ({\n 'x-suggestion--is-curated': shouldHighlightCurated.value\n }));\n\n return {\n el,\n filter,\n emitEvents,\n dynamicCSSClasses\n };\n }\n });\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- `UserAcceptedAQuery`: the event is emitted after the user clicks the button. The event payload is\n the suggestion query data.\n- `UserSelectedASuggestion`: the event is emitted after the user clicks the button. The event\n payload is the suggestion data.\n- `UserClickedAFilter`: the event is emitted after the user clicks the button if the suggestion\n includes a filter. The event payload is the suggestion filter.\n- The component can emit more events on click using the `suggestionSelectedEvents` prop.\n\n## See it in action\n\nThis suggestion component expects a suggestion to render and pass to its default slot, a normalized\nquery to compare with the suggestion's query and highlight its matching parts, and events to emit\nwhen the suggestion is selected.\n\nIf the suggestion contains a filter, it is displayed next to the suggestion.\n\n```vue live\n<template>\n <BaseSuggestion v-bind=\"{ query, suggestion }\" />\n</template>\n<script>\n import { BaseSuggestion } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionDemo',\n components: {\n BaseSuggestion\n },\n data() {\n return {\n query: 'st',\n suggestion: {\n modelName: 'QuerySuggestion',\n query: 'steak',\n facet: {\n namedModel: 'SimpleFacet',\n id: 'category',\n label: 'Category',\n filters: [\n {\n id: 'category:groceries',\n modelName: 'SimpleFilter',\n facetId: 'category-facet',\n label: 'Groceries',\n selected: false,\n totalResults: 10\n }\n ]\n }\n }\n };\n }\n };\n</script>\n```\n\n### Customise the content\n\nYou can make this component render any content you want by using the `default` slot.\n\n```vue live\n<template>\n <BaseSuggestion v-bind=\"{ query, suggestion }\" #default=\"{ suggestion, query, filter }\">\n <span>🔍</span>\n <Highlight :text=\"suggestion.query\" :highlight=\"query\" />\n <span v-if=\"filter\">{{ filter.label }}</span>\n </BaseSuggestion>\n</template>\n<script>\n import { BaseSuggestion } from '@empathyco/x-components';\n\n export default {\n name: 'BaseSuggestionDemo',\n components: {\n BaseSuggestion\n },\n data() {\n return {\n query: 'st',\n suggestion: {\n modelName: 'QuerySuggestion',\n query: 'steak'\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA,MAAc,cAAA,GAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,8 +1,8 @@
1
- import { __decorate } from 'tslib';
2
1
  import { forEach } from '@empathyco/x-utils';
3
- import Vue from 'vue';
4
- import { Prop, Component } from 'vue-property-decorator';
2
+ import { defineComponent, ref, computed } from 'vue';
5
3
  import __vue_component__ from '../highlight.vue.js';
4
+ import '../../composables/create-use-device.composable.js';
5
+ import { use$x } from '../../composables/use-_x.js';
6
6
 
7
7
  /**
8
8
  * Renders a button with a default slot. It receives a query, which should be the query of the
@@ -13,101 +13,131 @@ import __vue_component__ from '../highlight.vue.js';
13
13
  *
14
14
  * @public
15
15
  */
16
- let BaseSuggestion = class BaseSuggestion extends Vue {
17
- /**
18
- * The event handler that will be triggered when clicking on a suggestion.
19
- *
20
- * @remarks
21
- * UserAcceptedAQuery: suggestion.query
22
- * UserSelectedASuggestion: suggestion
23
- * UserClickedAFilter: suggestion.facets[0].filters[0]
24
- * Merges the events defined in the suggestionSelectedEvents prop and also emits them
25
- *
26
- * @returns The {@link XEvent | XEvents} to emit.
27
- * @public
28
- */
29
- get events() {
30
- const filterEvent = this.filter
31
- ? { UserClickedAFilter: this.filter }
32
- : {};
33
- return {
34
- UserAcceptedAQuery: this.suggestion.query,
35
- UserSelectedASuggestion: this.suggestion,
36
- ...this.suggestionSelectedEvents,
37
- ...filterEvent
38
- };
39
- }
40
- /**
41
- * Emits the events when the button is clicked.
42
- *
43
- * @public
44
- */
45
- emitEvents() {
46
- forEach(this.events, (event, payload) => {
47
- this.$x.emit(event, payload, {
48
- target: this.$el,
49
- feature: this.feature
50
- });
16
+ var script = defineComponent({
17
+ components: { Highlight: __vue_component__ },
18
+ props: {
19
+ /**
20
+ * The normalized query of the module using this component.
21
+ *
22
+ * @public
23
+ */
24
+ query: {
25
+ type: String,
26
+ default: ''
27
+ },
28
+ /**
29
+ * The suggestion to render and use in the default slot.
30
+ *
31
+ * @public
32
+ */
33
+ suggestion: {
34
+ type: Object,
35
+ required: true
36
+ },
37
+ /**
38
+ * The feature from which the events will be emitted.
39
+ *
40
+ * @public
41
+ */
42
+ //TODO: set to true when the suggestions components pass it.
43
+ feature: {
44
+ type: String
45
+ },
46
+ /**
47
+ * The {@link XEvent | XEvents} that will be emitted when selecting a suggestion.
48
+ *
49
+ * @public
50
+ */
51
+ suggestionSelectedEvents: {
52
+ type: Object,
53
+ required: true
54
+ },
55
+ /**
56
+ * Indicates if the curated suggestion should be highlighted.
57
+ *
58
+ * @public
59
+ */
60
+ highlightCurated: {
61
+ type: Boolean
62
+ }
63
+ },
64
+ setup(props) {
65
+ const el = ref(null);
66
+ const $x = use$x();
67
+ /**
68
+ * Returns the suggestion filter object.
69
+ * It is a BooleanFilter because the label is needed.
70
+ * It returns only the first element because the facets and filters are being planned
71
+ * in the BaseSuggestions component.
72
+ *
73
+ * @returns The filter.
74
+ * @public
75
+ */
76
+ const filter = computed(() => props.suggestion.facets?.[0]?.filters[0]);
77
+ /**
78
+ * The event handler that will be triggered when clicking on a suggestion.
79
+ *
80
+ * @remarks
81
+ * UserAcceptedAQuery: suggestion.query
82
+ * UserSelectedASuggestion: suggestion
83
+ * UserClickedAFilter: suggestion.facets[0].filters[0]
84
+ * Merges the events defined in the suggestionSelectedEvents prop and also emits them
85
+ *
86
+ * @returns The {@link XEvent | XEvents} to emit.
87
+ * @public
88
+ */
89
+ const events = computed(() => {
90
+ const filterEvent = filter.value
91
+ ? { UserClickedAFilter: filter.value }
92
+ : {};
93
+ return {
94
+ UserAcceptedAQuery: props.suggestion.query,
95
+ UserSelectedASuggestion: props.suggestion,
96
+ ...props.suggestionSelectedEvents,
97
+ ...filterEvent
98
+ };
51
99
  });
52
- }
53
- /**
54
- * Returns the suggestion filter object.
55
- * It is a BooleanFilter because the label is needed.
56
- * It returns only the first element because the facets and filters are being planned
57
- * in the BaseSuggestions component.
58
- *
59
- * @returns The filter.
60
- * @public
61
- */
62
- get filter() {
63
- return this.suggestion.facets?.[0]?.filters[0];
64
- }
65
- /**
66
- * Checks if the suggestion is curated and if it should be highlighted.
67
- *
68
- * @returns True if the suggestion is curated and should be highlighted.
69
- *
70
- * @internal
71
- */
72
- get shouldHighlightCurated() {
73
- return this.highlightCurated && !!this.suggestion.isCurated;
74
- }
75
- /**
76
- * Generates css classes dynamically.
77
- *
78
- * @remarks
79
- * 'x-suggestion--matching added when the query should be matched.
80
- *
81
- * @returns The {@link VueCSSClasses} classes.
82
- * @public
83
- */
84
- get dynamicCSSClasses() {
100
+ /**
101
+ * Emits the events when the button is clicked.
102
+ *
103
+ * @public
104
+ */
105
+ const emitEvents = () => {
106
+ forEach(events.value, (event, payload) => {
107
+ $x.emit(event, payload, {
108
+ target: el.value,
109
+ feature: props.feature
110
+ });
111
+ });
112
+ };
113
+ /**
114
+ * Checks if the suggestion is curated and if it should be highlighted.
115
+ *
116
+ * @returns True if the suggestion is curated and should be highlighted.
117
+ *
118
+ * @internal
119
+ */
120
+ const shouldHighlightCurated = computed(() => props.highlightCurated && !!props.suggestion.isCurated);
121
+ /**
122
+ * Generates css classes dynamically.
123
+ *
124
+ * @remarks
125
+ * 'x-suggestion--matching added when the query should be matched.
126
+ *
127
+ * @returns The {@link VueCSSClasses} classes.
128
+ * @public
129
+ */
130
+ const dynamicCSSClasses = computed(() => ({
131
+ 'x-suggestion--is-curated': shouldHighlightCurated.value
132
+ }));
85
133
  return {
86
- 'x-suggestion--is-curated': this.shouldHighlightCurated
134
+ el,
135
+ filter,
136
+ emitEvents,
137
+ dynamicCSSClasses
87
138
  };
88
139
  }
89
- };
90
- __decorate([
91
- Prop({ default: '' })
92
- ], BaseSuggestion.prototype, "query", void 0);
93
- __decorate([
94
- Prop({ required: true })
95
- ], BaseSuggestion.prototype, "suggestion", void 0);
96
- __decorate([
97
- Prop() //TODO: set to true when the suggestions components pass it.
98
- ], BaseSuggestion.prototype, "feature", void 0);
99
- __decorate([
100
- Prop({ required: true })
101
- ], BaseSuggestion.prototype, "suggestionSelectedEvents", void 0);
102
- __decorate([
103
- Prop({ default: false, type: Boolean })
104
- ], BaseSuggestion.prototype, "highlightCurated", void 0);
105
- BaseSuggestion = __decorate([
106
- Component({
107
- components: { Highlight: __vue_component__ }
108
- })
109
- ], BaseSuggestion);
110
- var script = BaseSuggestion;
140
+ });
111
141
 
112
142
  export { script as default };
113
143
  //# sourceMappingURL=base-suggestion.vue_rollup-plugin-vue_script.vue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-suggestion.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../src/components/suggestions/base-suggestion.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n import { BooleanFilter, Suggestion } from '@empathyco/x-types';\n import { forEach } from '@empathyco/x-utils';\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { QueryFeature } from '../../types';\n import { VueCSSClasses } from '../../utils/types';\n import { XEventsTypes } from '../../wiring/events.types';\n import Highlight from '../highlight.vue';\n\n /**\n * Renders a button with a default slot. It receives a query, which should be the query of the\n * module using this component, a suggestion, the {@link XEvent | XEvents} that will be emitted\n * on click with a given feature.\n *\n * The default slot receives the suggestion and the matched query has props.\n *\n * @public\n */\n @Component({\n components: { Highlight }\n })\n export default class BaseSuggestion extends Vue {\n /**\n * The normalized query of the module using this component.\n *\n * @public\n */\n @Prop({ default: '' })\n protected query!: string;\n\n /**\n * The suggestion to render and use in the default slot.\n *\n * @public\n */\n @Prop({ required: true })\n protected suggestion!: Suggestion;\n\n /**\n * The feature from which the events will be emitted.\n *\n * @public\n */\n @Prop() //TODO: set to true when the suggestions components pass it.\n protected feature?: QueryFeature;\n\n /**\n * The {@link XEvent | XEvents} that will be emitted when selecting a suggestion.\n *\n * @public\n */\n @Prop({ required: true })\n protected suggestionSelectedEvents!: Partial<XEventsTypes>;\n\n /**\n * Indicates if the curated suggestion should be highlighted.\n *\n * @public\n */\n @Prop({ default: false, type: Boolean })\n protected highlightCurated!: boolean;\n\n /**\n * The event handler that will be triggered when clicking on a suggestion.\n *\n * @remarks\n * UserAcceptedAQuery: suggestion.query\n * UserSelectedASuggestion: suggestion\n * UserClickedAFilter: suggestion.facets[0].filters[0]\n * Merges the events defined in the suggestionSelectedEvents prop and also emits them\n *\n * @returns The {@link XEvent | XEvents} to emit.\n * @public\n */\n protected get events(): Partial<XEventsTypes> {\n const filterEvent: Partial<XEventsTypes> = this.filter\n ? { UserClickedAFilter: this.filter }\n : {};\n return {\n UserAcceptedAQuery: this.suggestion.query,\n UserSelectedASuggestion: this.suggestion,\n ...this.suggestionSelectedEvents,\n ...filterEvent\n };\n }\n\n /**\n * Emits the events when the button is clicked.\n *\n * @public\n */\n protected emitEvents(): void {\n forEach(this.events, (event, payload) => {\n this.$x.emit(event, payload, {\n target: this.$el as HTMLElement,\n feature: this.feature\n });\n });\n }\n\n /**\n * Returns the suggestion filter object.\n * It is a BooleanFilter because the label is needed.\n * It returns only the first element because the facets and filters are being planned\n * in the BaseSuggestions component.\n *\n * @returns The filter.\n * @public\n */\n protected get filter(): BooleanFilter | undefined {\n return this.suggestion.facets?.[0]?.filters[0] as BooleanFilter;\n }\n\n /**\n * Checks if the suggestion is curated and if it should be highlighted.\n *\n * @returns True if the suggestion is curated and should be highlighted.\n *\n * @internal\n */\n protected get shouldHighlightCurated(): boolean {\n return this.highlightCurated && !!this.suggestion.isCurated;\n }\n\n /**\n * Generates css classes dynamically.\n *\n * @remarks\n * 'x-suggestion--matching added when the query should be matched.\n *\n * @returns The {@link VueCSSClasses} classes.\n * @public\n */\n protected get dynamicCSSClasses(): VueCSSClasses {\n return {\n 'x-suggestion--is-curated': this.shouldHighlightCurated\n };\n }\n }\n"],"names":["Highlight"],"mappings":";;;;;;AAyBE;;;;;;;;AAQG;AAIY,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,GAAG,CAAA;AAyC7C;;;;;;;;;;;AAWG;AACH,IAAA,IAAc,MAAM,GAAA;AAClB,QAAA,MAAM,WAAW,GAA0B,IAAI,CAAC,MAAM;AACpD,cAAE,EAAE,kBAAkB,EAAE,IAAI,CAAC,MAAM,EAAE;cACnC,EAAE,CAAC;QACP,OAAO;AACL,YAAA,kBAAkB,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK;YACzC,uBAAuB,EAAE,IAAI,CAAC,UAAU;YACxC,GAAG,IAAI,CAAC,wBAAwB;AAChC,YAAA,GAAG,WAAW;SACf,CAAC;KACH;AAED;;;;AAIG;IACO,UAAU,GAAA;QAClB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAI;YACtC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE;gBAC3B,MAAM,EAAE,IAAI,CAAC,GAAkB;gBAC/B,OAAO,EAAE,IAAI,CAAC,OAAO;AACtB,aAAA,CAAC,CAAC;AACL,SAAC,CAAC,CAAC;KACJ;AAED;;;;;;;;AAQG;AACH,IAAA,IAAc,MAAM,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAkB,CAAC;KACjE;AAED;;;;;;AAMG;AACH,IAAA,IAAc,sBAAsB,GAAA;QAClC,OAAO,IAAI,CAAC,gBAAgB,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;KAC7D;AAED;;;;;;;;AAQG;AACH,IAAA,IAAc,iBAAiB,GAAA;QAC7B,OAAO;YACL,0BAA0B,EAAE,IAAI,CAAC,sBAAsB;SACxD,CAAC;KACH;CACF,CAAA;AA9GC,UAAA,CAAA;AADC,IAAA,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACG,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAQzB,UAAA,CAAA;AADC,IAAA,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACS,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,YAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAQlC,UAAA,CAAA;IADC,IAAI,EAAE;AAC0B,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAQjC,UAAA,CAAA;AADC,IAAA,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACkC,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,0BAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAQ3D,UAAA,CAAA;IADC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACH,CAAA,EAAA,cAAA,CAAA,SAAA,EAAA,kBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAvClB,cAAc,GAAA,UAAA,CAAA;AAHlC,IAAA,SAAS,CAAC;QACT,UAAU,EAAE,aAAEA,iBAAS,EAAE;KAC1B,CAAC;AACmB,CAAA,EAAA,cAAc,CAqHlC,CAAA;aArHoB,cAAc;;;;"}
1
+ {"version":3,"file":"base-suggestion.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../src/components/suggestions/base-suggestion.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n import { BooleanFilter, Suggestion } from '@empathyco/x-types';\n import { forEach } from '@empathyco/x-utils';\n import { computed, defineComponent, PropType, ref } from 'vue';\n import { QueryFeature } from '../../types';\n import { VueCSSClasses } from '../../utils/types';\n import { XEventsTypes } from '../../wiring/events.types';\n import Highlight from '../highlight.vue';\n import { use$x } from '../../composables/index';\n\n /**\n * Renders a button with a default slot. It receives a query, which should be the query of the\n * module using this component, a suggestion, the {@link XEvent | XEvents} that will be emitted\n * on click with a given feature.\n *\n * The default slot receives the suggestion and the matched query has props.\n *\n * @public\n */\n export default defineComponent({\n components: { Highlight },\n props: {\n /**\n * The normalized query of the module using this component.\n *\n * @public\n */\n query: {\n type: String,\n default: ''\n },\n\n /**\n * The suggestion to render and use in the default slot.\n *\n * @public\n */\n suggestion: {\n type: Object as PropType<Suggestion>,\n required: true\n },\n\n /**\n * The feature from which the events will be emitted.\n *\n * @public\n */\n //TODO: set to true when the suggestions components pass it.\n feature: {\n type: String as PropType<QueryFeature>\n },\n\n /**\n * The {@link XEvent | XEvents} that will be emitted when selecting a suggestion.\n *\n * @public\n */\n suggestionSelectedEvents: {\n type: Object as PropType<Partial<XEventsTypes>>,\n required: true\n },\n\n /**\n * Indicates if the curated suggestion should be highlighted.\n *\n * @public\n */\n highlightCurated: {\n type: Boolean\n }\n },\n\n setup(props) {\n const el = ref<HTMLElement | null>(null);\n\n const $x = use$x();\n\n /**\n * Returns the suggestion filter object.\n * It is a BooleanFilter because the label is needed.\n * It returns only the first element because the facets and filters are being planned\n * in the BaseSuggestions component.\n *\n * @returns The filter.\n * @public\n */\n const filter = computed<BooleanFilter | undefined>(\n () => props.suggestion.facets?.[0]?.filters[0] as BooleanFilter\n );\n\n /**\n * The event handler that will be triggered when clicking on a suggestion.\n *\n * @remarks\n * UserAcceptedAQuery: suggestion.query\n * UserSelectedASuggestion: suggestion\n * UserClickedAFilter: suggestion.facets[0].filters[0]\n * Merges the events defined in the suggestionSelectedEvents prop and also emits them\n *\n * @returns The {@link XEvent | XEvents} to emit.\n * @public\n */\n const events = computed<Partial<XEventsTypes>>(() => {\n const filterEvent: Partial<XEventsTypes> = filter.value\n ? { UserClickedAFilter: filter.value }\n : {};\n return {\n UserAcceptedAQuery: props.suggestion.query,\n UserSelectedASuggestion: props.suggestion,\n ...props.suggestionSelectedEvents,\n ...filterEvent\n };\n });\n\n /**\n * Emits the events when the button is clicked.\n *\n * @public\n */\n const emitEvents = (): void => {\n forEach(events.value, (event, payload): void => {\n $x.emit(event, payload, {\n target: el.value!,\n feature: props.feature\n });\n });\n };\n\n /**\n * Checks if the suggestion is curated and if it should be highlighted.\n *\n * @returns True if the suggestion is curated and should be highlighted.\n *\n * @internal\n */\n const shouldHighlightCurated = computed<boolean>(\n () => props.highlightCurated && !!props.suggestion.isCurated\n );\n\n /**\n * Generates css classes dynamically.\n *\n * @remarks\n * 'x-suggestion--matching added when the query should be matched.\n *\n * @returns The {@link VueCSSClasses} classes.\n * @public\n */\n const dynamicCSSClasses = computed<VueCSSClasses>(() => ({\n 'x-suggestion--is-curated': shouldHighlightCurated.value\n }));\n\n return {\n el,\n filter,\n emitEvents,\n dynamicCSSClasses\n };\n }\n });\n"],"names":["Highlight"],"mappings":";;;;;;AAyBE;;;;;;;;AAQG;AACH,aAAe,eAAe,CAAC;IAC7B,UAAU,EAAE,aAAEA,iBAAS,EAAE;AACzB,IAAA,KAAK,EAAE;AACL;;;;AAIG;AACH,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,OAAO,EAAE,EAAE;AACZ,SAAA;AAED;;;;AAIG;AACH,QAAA,UAAU,EAAE;AACV,YAAA,IAAI,EAAE,MAA8B;AACpC,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AAED;;;;AAIG;;AAEH,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,MAAgC;AACvC,SAAA;AAED;;;;AAIG;AACH,QAAA,wBAAwB,EAAE;AACxB,YAAA,IAAI,EAAE,MAAyC;AAC/C,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AAED;;;;AAIG;AACH,QAAA,gBAAgB,EAAE;AAChB,YAAA,IAAI,EAAE,OAAO;AACd,SAAA;AACF,KAAA;AAED,IAAA,KAAK,CAAC,KAAK,EAAA;AACT,QAAA,MAAM,EAAE,GAAG,GAAG,CAAqB,IAAI,CAAC,CAAC;AAEzC,QAAA,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;AAEnB;;;;;;;;AAQG;QACH,MAAM,MAAM,GAAG,QAAQ,CACrB,MAAM,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAkB,CAChE,CAAC;AAEF;;;;;;;;;;;AAWG;AACH,QAAA,MAAM,MAAM,GAAG,QAAQ,CAAwB,MAAK;AAClD,YAAA,MAAM,WAAW,GAA0B,MAAM,CAAC,KAAK;AACrD,kBAAE,EAAE,kBAAkB,EAAE,MAAM,CAAC,KAAK,EAAE;kBACpC,EAAE,CAAC;YACP,OAAO;AACL,gBAAA,kBAAkB,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK;gBAC1C,uBAAuB,EAAE,KAAK,CAAC,UAAU;gBACzC,GAAG,KAAK,CAAC,wBAAwB;AACjC,gBAAA,GAAG,WAAW;aACf,CAAC;AACJ,SAAC,CAAC,CAAC;AAEH;;;;AAIG;QACH,MAAM,UAAU,GAAG,MAAW;YAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAU;AAC7C,gBAAA,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE;oBACtB,MAAM,EAAE,EAAE,CAAC,KAAM;oBACjB,OAAO,EAAE,KAAK,CAAC,OAAO;AACvB,iBAAA,CAAC,CAAC;AACL,aAAC,CAAC,CAAC;AACL,SAAC,CAAC;AAEF;;;;;;AAMG;AACH,QAAA,MAAM,sBAAsB,GAAG,QAAQ,CACrC,MAAM,KAAK,CAAC,gBAAgB,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAC7D,CAAC;AAEF;;;;;;;;AAQG;AACH,QAAA,MAAM,iBAAiB,GAAG,QAAQ,CAAgB,OAAO;YACvD,0BAA0B,EAAE,sBAAsB,CAAC,KAAK;AACzD,SAAA,CAAC,CAAC,CAAC;QAEJ,OAAO;YACL,EAAE;YACF,MAAM;YACN,UAAU;YACV,iBAAiB;SAClB,CAAC;KACH;AACF,CAAA,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empathyco/x-components",
3
- "version": "3.0.0-alpha.366",
3
+ "version": "3.0.0-alpha.368",
4
4
  "description": "Empathy X Components",
5
5
  "author": "Empathy Systems Corporation S.L.",
6
6
  "license": "Apache-2.0",
@@ -40,7 +40,7 @@
40
40
  "directory": "packages/x-components"
41
41
  },
42
42
  "engines": {
43
- "node": ">=16"
43
+ "node": ">=18"
44
44
  },
45
45
  "scripts": {
46
46
  "serve": "vue-cli-service serve",
@@ -67,14 +67,14 @@
67
67
  "prepublishOnly": "pnpm run build"
68
68
  },
69
69
  "dependencies": {
70
- "@empathyco/x-adapter": "^8.0.0-alpha.28",
71
- "@empathyco/x-adapter-platform": "^1.0.0-alpha.71",
72
- "@empathyco/x-bus": "^0.1.0-alpha.12",
73
- "@empathyco/x-deep-merge": "^1.3.0-alpha.34",
70
+ "@empathyco/x-adapter": "^8.0.0-alpha.29",
71
+ "@empathyco/x-adapter-platform": "^1.0.0-alpha.72",
72
+ "@empathyco/x-bus": "^1.0.0-alpha.0",
73
+ "@empathyco/x-deep-merge": "^2.0.0-alpha.0",
74
74
  "@empathyco/x-logger": "^1.2.0-alpha.11",
75
- "@empathyco/x-storage-service": "^2.0.0-alpha.11",
76
- "@empathyco/x-types": "^10.0.0-alpha.66",
77
- "@empathyco/x-utils": "^1.0.0-alpha.19",
75
+ "@empathyco/x-storage-service": "^2.0.0-alpha.13",
76
+ "@empathyco/x-types": "^10.0.0-alpha.67",
77
+ "@empathyco/x-utils": "^1.0.0-alpha.20",
78
78
  "@vue/devtools-api": "~6.5.0",
79
79
  "@vueuse/core": "~9.13.0",
80
80
  "rxjs": "~7.8.0",
@@ -89,10 +89,10 @@
89
89
  "vuex": "^3.0.0"
90
90
  },
91
91
  "devDependencies": {
92
- "@badeball/cypress-cucumber-preprocessor": "~16.0.0",
92
+ "@badeball/cypress-cucumber-preprocessor": "~17.0.0",
93
93
  "@bahmutov/cypress-esbuild-preprocessor": "~2.2.0",
94
94
  "@cypress/vue2": "~2.0.1",
95
- "@empathyco/x-tailwindcss": "^1.0.0-alpha.29",
95
+ "@empathyco/x-tailwindcss": "^1.0.0-alpha.30",
96
96
  "@microsoft/api-documenter": "~7.22.0",
97
97
  "@microsoft/api-extractor": "~7.34.0",
98
98
  "@rollup/plugin-commonjs": "~24.1.0",
@@ -100,7 +100,7 @@
100
100
  "@types/autoprefixer": "~10.2.0",
101
101
  "@types/glob": "^8.0.1",
102
102
  "@types/jest": "~27.5.0",
103
- "@types/node": "~16.18.0",
103
+ "@types/node": "~18.16.0",
104
104
  "@types/testing-library__jest-dom": "~5.14.5",
105
105
  "@vue/cli-plugin-e2e-cypress": "~5.0.4",
106
106
  "@vue/cli-plugin-typescript": "~5.0.4",
@@ -143,5 +143,5 @@
143
143
  "access": "public",
144
144
  "directory": "dist"
145
145
  },
146
- "gitHead": "23b076bb03324bbf4a6671fe4d664d162bcc2668"
146
+ "gitHead": "c7794658570688883d32c6b2b28f0e3a88e87483"
147
147
  }