@empathyco/x-components 3.0.0-alpha.76 → 3.0.0-alpha.79

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 (193) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/core/index.js +0 -1
  3. package/core/index.js.map +1 -1
  4. package/design-system/default-theme.css +100 -100
  5. package/docs/API-reference/api/x-components.actionstree.md +1 -1
  6. package/docs/API-reference/api/x-components.anyactionstree.md +1 -1
  7. package/docs/API-reference/api/x-components.anygetterstree.md +1 -1
  8. package/docs/API-reference/api/x-components.anymutationstree.md +1 -1
  9. package/docs/API-reference/api/x-components.compilemessage.md +1 -1
  10. package/docs/API-reference/api/x-components.extraparams.md +2 -2
  11. package/docs/API-reference/api/x-components.extraparamsmutations.setparams.md +1 -1
  12. package/docs/API-reference/api/x-components.extraparamsstate.md +1 -1
  13. package/docs/API-reference/api/x-components.extraparamsxevents.md +4 -4
  14. package/docs/API-reference/api/x-components.getterstree.md +1 -1
  15. package/docs/API-reference/api/x-components.identifierresultsmutations.setparams.md +1 -1
  16. package/docs/API-reference/api/x-components.identifierresultsstate.md +1 -1
  17. package/docs/API-reference/api/x-components.md +0 -8
  18. package/docs/API-reference/api/x-components.mutationstree.md +1 -1
  19. package/docs/API-reference/api/x-components.nextqueriesmutations.setparams.md +1 -1
  20. package/docs/API-reference/api/x-components.nextqueriesstate.md +1 -1
  21. package/docs/API-reference/api/x-components.popularsearchesmutations.setparams.md +1 -1
  22. package/docs/API-reference/api/x-components.popularsearchesstate.md +1 -1
  23. package/docs/API-reference/api/x-components.querysuggestionsmutations.setparams.md +1 -1
  24. package/docs/API-reference/api/x-components.querysuggestionsstate.md +1 -1
  25. package/docs/API-reference/api/x-components.recommendationsmutations.setparams.md +1 -1
  26. package/docs/API-reference/api/x-components.recommendationsstate.md +1 -1
  27. package/docs/API-reference/api/x-components.relatedtagsmutations.setparams.md +1 -1
  28. package/docs/API-reference/api/x-components.relatedtagsstate.md +1 -1
  29. package/docs/API-reference/api/x-components.renderlessextraparams.md +1 -1
  30. package/docs/API-reference/api/x-components.returns.md +0 -2
  31. package/docs/API-reference/api/x-components.scrollstate.md +1 -1
  32. package/docs/API-reference/api/x-components.searchmutations.setparams.md +1 -1
  33. package/docs/API-reference/api/x-components.searchstate.md +2 -2
  34. package/docs/API-reference/api/x-components.setextraparams.md +1 -1
  35. package/docs/API-reference/api/x-components.setidentifierresultsextraparams.md +1 -1
  36. package/docs/API-reference/api/x-components.setinitialextraparams.md +1 -1
  37. package/docs/API-reference/api/x-components.setnextqueriesextraparams.md +1 -1
  38. package/docs/API-reference/api/x-components.setpopularsearchesextraparams.md +1 -1
  39. package/docs/API-reference/api/x-components.setquerysuggestionsextraparams.md +1 -1
  40. package/docs/API-reference/api/x-components.setrecommendationsextraparams.md +1 -1
  41. package/docs/API-reference/api/x-components.setrelatedtagsextraparams.md +1 -1
  42. package/docs/API-reference/api/x-components.setsearchextraparams.md +1 -1
  43. package/docs/API-reference/api/x-components.simplestateselector.md +0 -2
  44. package/docs/API-reference/api/x-components.snippetconfigextraparams.md +1 -1
  45. package/docs/API-reference/api/x-components.urlhandler.md +1 -1
  46. package/docs/API-reference/api/x-components.urlmutations.setinitialextraparams.md +1 -1
  47. package/docs/API-reference/api/x-components.urlstate.md +1 -1
  48. package/docs/API-reference/api/x-components.urlxevents.extraparamsloadedfromurl.md +1 -1
  49. package/docs/API-reference/api/x-components.urlxevents.md +1 -1
  50. package/docs/API-reference/api/x-components.vuecssclasses.md +0 -2
  51. package/docs/API-reference/api/x-components.wiring.md +1 -1
  52. package/js/components/global-x-bus.vue.js.map +1 -1
  53. package/js/components/global-x-bus.vue_rollup-plugin-vue_script.vue.js +1 -1
  54. package/js/components/global-x-bus.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  55. package/js/components/snippet-callbacks.vue.js.map +1 -1
  56. package/js/components/snippet-callbacks.vue_rollup-plugin-vue_script.vue.js +1 -1
  57. package/js/components/snippet-callbacks.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  58. package/js/components/suggestions/base-suggestion.vue.js.map +1 -1
  59. package/js/components/suggestions/base-suggestion.vue_rollup-plugin-vue_script.vue.js +1 -1
  60. package/js/components/suggestions/base-suggestion.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  61. package/js/filters/compile-message.filter.js.map +1 -1
  62. package/js/index.js +0 -1
  63. package/js/index.js.map +1 -1
  64. package/js/plugins/x-emitters.js +1 -1
  65. package/js/plugins/x-emitters.js.map +1 -1
  66. package/js/plugins/x-plugin.js +1 -2
  67. package/js/plugins/x-plugin.js.map +1 -1
  68. package/js/store/utils/getters-proxy.utils.js +1 -1
  69. package/js/store/utils/getters-proxy.utils.js.map +1 -1
  70. package/js/store/utils/store-emitters.utils.js.map +1 -1
  71. package/js/x-installer/x-installer/x-installer.js +1 -1
  72. package/js/x-installer/x-installer/x-installer.js.map +1 -1
  73. package/js/x-modules/extra-params/components/extra-params.vue.js.map +1 -1
  74. package/js/x-modules/extra-params/components/extra-params.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  75. package/js/x-modules/extra-params/components/renderless-extra-param.vue.js.map +1 -1
  76. package/js/x-modules/extra-params/components/renderless-extra-param.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  77. package/js/x-modules/extra-params/components/snippet-config-extra-params.vue.js.map +1 -1
  78. package/js/x-modules/extra-params/components/snippet-config-extra-params.vue_rollup-plugin-vue_script.vue.js +1 -2
  79. package/js/x-modules/extra-params/components/snippet-config-extra-params.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  80. package/js/x-modules/facets/components/facets/facets.vue.js +2 -2
  81. package/js/x-modules/facets/components/facets/facets.vue.js.map +1 -1
  82. package/js/x-modules/facets/components/facets/facets.vue_rollup-plugin-vue_script.vue.js +1 -1
  83. package/js/x-modules/facets/components/facets/facets.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  84. package/js/x-modules/facets/store/getters/facets.getter.js +1 -1
  85. package/js/x-modules/facets/store/getters/facets.getter.js.map +1 -1
  86. package/js/x-modules/facets/store/getters/selected-filters-by-facet.getter.js +1 -1
  87. package/js/x-modules/facets/store/getters/selected-filters-by-facet.getter.js.map +1 -1
  88. package/js/x-modules/scroll/components/scroll-to-top.vue.js.map +1 -1
  89. package/js/x-modules/scroll/components/scroll-to-top.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  90. package/js/x-modules/search/store/actions/reset-state.action.js +1 -1
  91. package/js/x-modules/search/store/actions/reset-state.action.js.map +1 -1
  92. package/js/x-modules/url/components/url-handler.vue.js.map +1 -1
  93. package/js/x-modules/url/components/url-handler.vue_rollup-plugin-vue_script.vue.js +1 -1
  94. package/js/x-modules/url/components/url-handler.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  95. package/js/x-modules/url/store/getters/url-params.getter.js +1 -1
  96. package/js/x-modules/url/store/getters/url-params.getter.js.map +1 -1
  97. package/js/x-modules/url/store/mutations/set-params.mutation.js +1 -1
  98. package/js/x-modules/url/store/mutations/set-params.mutation.js.map +1 -1
  99. package/package.json +13 -15
  100. package/report/tsdoc-metadata.json +1 -1
  101. package/report/x-adapter.api.json +1 -1
  102. package/report/x-components.api.json +688 -1054
  103. package/report/x-components.api.md +1 -24
  104. package/report/x-types.api.json +1 -1
  105. package/types/components/snippet-callbacks.vue.d.ts.map +1 -1
  106. package/types/components/suggestions/base-suggestion.vue.d.ts.map +1 -1
  107. package/types/filters/compile-message.filter.d.ts +1 -1
  108. package/types/filters/compile-message.filter.d.ts.map +1 -1
  109. package/types/plugins/x-emitters.d.ts.map +1 -1
  110. package/types/plugins/x-plugin.d.ts.map +1 -1
  111. package/types/store/actions.types.d.ts +2 -1
  112. package/types/store/actions.types.d.ts.map +1 -1
  113. package/types/store/getters.types.d.ts +1 -1
  114. package/types/store/getters.types.d.ts.map +1 -1
  115. package/types/store/mutations.types.d.ts +1 -1
  116. package/types/store/mutations.types.d.ts.map +1 -1
  117. package/types/store/utils/getters-proxy.utils.d.ts.map +1 -1
  118. package/types/store/utils/store-emitters.utils.d.ts +2 -1
  119. package/types/store/utils/store-emitters.utils.d.ts.map +1 -1
  120. package/types/utils/index.d.ts +0 -1
  121. package/types/utils/index.d.ts.map +1 -1
  122. package/types/utils/types.d.ts +1 -9
  123. package/types/utils/types.d.ts.map +1 -1
  124. package/types/wiring/wiring.types.d.ts +2 -1
  125. package/types/wiring/wiring.types.d.ts.map +1 -1
  126. package/types/x-installer/x-installer/x-installer.d.ts.map +1 -1
  127. package/types/x-modules/extra-params/components/extra-params.vue.d.ts +1 -1
  128. package/types/x-modules/extra-params/components/extra-params.vue.d.ts.map +1 -1
  129. package/types/x-modules/extra-params/components/renderless-extra-param.vue.d.ts +1 -1
  130. package/types/x-modules/extra-params/components/renderless-extra-param.vue.d.ts.map +1 -1
  131. package/types/x-modules/extra-params/components/snippet-config-extra-params.vue.d.ts +1 -1
  132. package/types/x-modules/extra-params/components/snippet-config-extra-params.vue.d.ts.map +1 -1
  133. package/types/x-modules/extra-params/events.types.d.ts +1 -1
  134. package/types/x-modules/extra-params/events.types.d.ts.map +1 -1
  135. package/types/x-modules/extra-params/store/emitters.d.ts +1 -1
  136. package/types/x-modules/extra-params/store/types.d.ts +1 -1
  137. package/types/x-modules/extra-params/store/types.d.ts.map +1 -1
  138. package/types/x-modules/extra-params/wiring.d.ts +4 -4
  139. package/types/x-modules/extra-params/wiring.d.ts.map +1 -1
  140. package/types/x-modules/facets/components/facets/facets.vue.d.ts +1 -1
  141. package/types/x-modules/facets/components/facets/facets.vue.d.ts.map +1 -1
  142. package/types/x-modules/identifier-results/store/types.d.ts +1 -1
  143. package/types/x-modules/identifier-results/store/types.d.ts.map +1 -1
  144. package/types/x-modules/identifier-results/wiring.d.ts +2 -2
  145. package/types/x-modules/identifier-results/wiring.d.ts.map +1 -1
  146. package/types/x-modules/next-queries/store/types.d.ts +1 -1
  147. package/types/x-modules/next-queries/store/types.d.ts.map +1 -1
  148. package/types/x-modules/next-queries/wiring.d.ts +2 -2
  149. package/types/x-modules/next-queries/wiring.d.ts.map +1 -1
  150. package/types/x-modules/popular-searches/store/types.d.ts +1 -1
  151. package/types/x-modules/popular-searches/store/types.d.ts.map +1 -1
  152. package/types/x-modules/popular-searches/wiring.d.ts +2 -2
  153. package/types/x-modules/popular-searches/wiring.d.ts.map +1 -1
  154. package/types/x-modules/query-suggestions/store/types.d.ts +1 -1
  155. package/types/x-modules/query-suggestions/store/types.d.ts.map +1 -1
  156. package/types/x-modules/query-suggestions/wiring.d.ts +2 -2
  157. package/types/x-modules/query-suggestions/wiring.d.ts.map +1 -1
  158. package/types/x-modules/recommendations/store/types.d.ts +1 -1
  159. package/types/x-modules/recommendations/store/types.d.ts.map +1 -1
  160. package/types/x-modules/recommendations/wiring.d.ts +2 -2
  161. package/types/x-modules/recommendations/wiring.d.ts.map +1 -1
  162. package/types/x-modules/related-tags/store/types.d.ts +1 -1
  163. package/types/x-modules/related-tags/store/types.d.ts.map +1 -1
  164. package/types/x-modules/related-tags/wiring.d.ts +2 -2
  165. package/types/x-modules/related-tags/wiring.d.ts.map +1 -1
  166. package/types/x-modules/scroll/components/scroll-to-top.vue.d.ts +1 -1
  167. package/types/x-modules/scroll/components/scroll-to-top.vue.d.ts.map +1 -1
  168. package/types/x-modules/scroll/store/types.d.ts +1 -1
  169. package/types/x-modules/scroll/store/types.d.ts.map +1 -1
  170. package/types/x-modules/search/store/types.d.ts +1 -1
  171. package/types/x-modules/search/store/types.d.ts.map +1 -1
  172. package/types/x-modules/search/wiring.d.ts +2 -2
  173. package/types/x-modules/search/wiring.d.ts.map +1 -1
  174. package/types/x-modules/url/components/url-handler.vue.d.ts +1 -1
  175. package/types/x-modules/url/components/url-handler.vue.d.ts.map +1 -1
  176. package/types/x-modules/url/events.types.d.ts +3 -2
  177. package/types/x-modules/url/events.types.d.ts.map +1 -1
  178. package/types/x-modules/url/store/types.d.ts +1 -1
  179. package/types/x-modules/url/store/types.d.ts.map +1 -1
  180. package/types/x-modules/url/wiring.d.ts +2 -2
  181. package/types/x-modules/url/wiring.d.ts.map +1 -1
  182. package/docs/API-reference/api/x-components.cleanundefined.md +0 -26
  183. package/docs/API-reference/api/x-components.dictionary.md +0 -13
  184. package/docs/API-reference/api/x-components.every.md +0 -27
  185. package/docs/API-reference/api/x-components.foreach.md +0 -25
  186. package/docs/API-reference/api/x-components.getnewandupdatedkeys.md +0 -27
  187. package/docs/API-reference/api/x-components.map.md +0 -27
  188. package/docs/API-reference/api/x-components.objectfilter.md +0 -27
  189. package/docs/API-reference/api/x-components.reduce.md +0 -28
  190. package/js/utils/object.js +0 -115
  191. package/js/utils/object.js.map +0 -1
  192. package/types/utils/object.d.ts +0 -70
  193. package/types/utils/object.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"store-emitters.utils.js","sources":["../../../../src/store/utils/store-emitters.utils.ts"],"sourcesContent":["import { WatchOptions } from 'vue';\nimport { Dictionary, Returns } from '../../utils/types';\nimport { XEvent, XEventPayload } from '../../wiring/events.types';\nimport { AnyXStoreModule } from '../store.types';\n\n/**\n * Selects a part of the store state or getters (AKA \"getter\" inside\n * {@link https://vuex.vuejs.org/ | Vuex} watchers).\n *\n * @param ReturnType - The type of the state or getters property selected.\n * @param State - The type of the state of the {@link XModule} where this selector is used.\n * @param Getters - The type of the getters of the {@link XModule} where this selector is used.\n * @public\n */\nexport type SimpleStateSelector<\n ReturnType,\n State extends Dictionary,\n Getters extends Dictionary\n> = (state: State, getters: Getters) => ReturnType;\n\n/**\n * Composition type of {@link SimpleStateSelector} which allows to indicate if the state selector\n * should be executed in first instance (first assignment of values). Selector is the\n * {@link SimpleStateSelector} and immediate flags if the selector should be executed when it is\n * initialized for first time.\n *\n * @param ReturnType - The type of the state or getters property selected.\n * @param State - The type of the state of the {@link XModule} where this selector is used.\n * @param Getters - The type of the getters of the {@link XModule} where this selector is used.\n * @public\n */\nexport interface StateSelector<ReturnType, State extends Dictionary, Getters extends Dictionary>\n extends WatchOptions {\n selector: SimpleStateSelector<ReturnType, State, Getters>;\n /**\n * Checks if the value of the selector has changed.\n *\n * @remarks\n * This function exist because Vue will not stop reactivity propagation if the observed variable\n * is an `object`, an `Array`, or the `deep` mode has been enabled.\n *\n * @param newValue - The new value.\n * @param oldValue - The old value.\n * @returns True if the value has really changed.\n */\n filter?(newValue: ReturnType, oldValue: ReturnType): boolean;\n}\n\n/**\n * Dictionary where the key is a {@link XEvent}, and the value is {@link SimpleStateSelector} or\n * {@link StateSelector}. This {@link SimpleStateSelector} or {@link StateSelector} can only\n * access the state and getters from the {@link XStoreModule} passed as param type. This\n * dictionary is used to emits a {@link XEvent} when the part of the store selected by\n * {@link SimpleStateSelector} changes.\n *\n * @param StoreModule - The store module that these store emitters will be able to access.\n * @public\n */\nexport type StoreEmitters<StoreModule extends AnyXStoreModule> = {\n [Event in XEvent]?:\n | SimpleStateSelector<\n XEventPayload<Event>,\n ReturnType<StoreModule['state']>,\n Returns<StoreModule['getters']>\n >\n | StateSelector<\n XEventPayload<Event>,\n ReturnType<StoreModule['state']>,\n Returns<StoreModule['getters']>\n >;\n};\n/**\n * Alias for any simple state selector.\n *\n * @public\n */\nexport type AnySimpleStateSelector = SimpleStateSelector<any, any, any>;\n/**\n * Alias for any state selector.\n *\n * @public\n */\nexport type AnyStateSelector = StateSelector<any, any, any>;\n/**\n * Alias for any store emitters.\n *\n * @public\n */\nexport type AnyStoreEmitters = StoreEmitters<AnyXStoreModule>;\n\n/**\n * Helper function for creating type-safe {@link StoreEmitters}.\n *\n * @param storeModule - The store module that the emitters will be associated to.\n * @param emitters - The {@link StoreEmitters} to create.\n * @returns A type-safe function for storeEmitters.\n * @public\n */\nexport function createStoreEmitters<\n Module extends AnyXStoreModule,\n Emitters extends StoreEmitters<Module>\n // eslint-disable-next-line @typescript-eslint/no-unused-vars-experimental\n>(storeModule: Module, emitters: Emitters): Emitters {\n return emitters;\n}\n"],"names":[],"mappings":"AA0FA;;;;;;;;SAQgB,mBAAmB,CAIjC,WAAmB,EAAE,QAAkB;IACvC,OAAO,QAAQ,CAAC;AAClB;;;;"}
1
+ {"version":3,"file":"store-emitters.utils.js","sources":["../../../../src/store/utils/store-emitters.utils.ts"],"sourcesContent":["import { Dictionary } from '@empathyco/x-utils';\nimport { WatchOptions } from 'vue';\nimport { Returns } from '../../utils/types';\nimport { XEvent, XEventPayload } from '../../wiring/events.types';\nimport { AnyXStoreModule } from '../store.types';\n\n/**\n * Selects a part of the store state or getters (AKA \"getter\" inside\n * {@link https://vuex.vuejs.org/ | Vuex} watchers).\n *\n * @param ReturnType - The type of the state or getters property selected.\n * @param State - The type of the state of the {@link XModule} where this selector is used.\n * @param Getters - The type of the getters of the {@link XModule} where this selector is used.\n * @public\n */\nexport type SimpleStateSelector<\n ReturnType,\n State extends Dictionary,\n Getters extends Dictionary\n> = (state: State, getters: Getters) => ReturnType;\n\n/**\n * Composition type of {@link SimpleStateSelector} which allows to indicate if the state selector\n * should be executed in first instance (first assignment of values). Selector is the\n * {@link SimpleStateSelector} and immediate flags if the selector should be executed when it is\n * initialized for first time.\n *\n * @param ReturnType - The type of the state or getters property selected.\n * @param State - The type of the state of the {@link XModule} where this selector is used.\n * @param Getters - The type of the getters of the {@link XModule} where this selector is used.\n * @public\n */\nexport interface StateSelector<ReturnType, State extends Dictionary, Getters extends Dictionary>\n extends WatchOptions {\n selector: SimpleStateSelector<ReturnType, State, Getters>;\n /**\n * Checks if the value of the selector has changed.\n *\n * @remarks\n * This function exist because Vue will not stop reactivity propagation if the observed variable\n * is an `object`, an `Array`, or the `deep` mode has been enabled.\n *\n * @param newValue - The new value.\n * @param oldValue - The old value.\n * @returns True if the value has really changed.\n */\n filter?(newValue: ReturnType, oldValue: ReturnType): boolean;\n}\n\n/**\n * Dictionary where the key is a {@link XEvent}, and the value is {@link SimpleStateSelector} or\n * {@link StateSelector}. This {@link SimpleStateSelector} or {@link StateSelector} can only\n * access the state and getters from the {@link XStoreModule} passed as param type. This\n * dictionary is used to emits a {@link XEvent} when the part of the store selected by\n * {@link SimpleStateSelector} changes.\n *\n * @param StoreModule - The store module that these store emitters will be able to access.\n * @public\n */\nexport type StoreEmitters<StoreModule extends AnyXStoreModule> = {\n [Event in XEvent]?:\n | SimpleStateSelector<\n XEventPayload<Event>,\n ReturnType<StoreModule['state']>,\n Returns<StoreModule['getters']>\n >\n | StateSelector<\n XEventPayload<Event>,\n ReturnType<StoreModule['state']>,\n Returns<StoreModule['getters']>\n >;\n};\n/**\n * Alias for any simple state selector.\n *\n * @public\n */\nexport type AnySimpleStateSelector = SimpleStateSelector<any, any, any>;\n/**\n * Alias for any state selector.\n *\n * @public\n */\nexport type AnyStateSelector = StateSelector<any, any, any>;\n/**\n * Alias for any store emitters.\n *\n * @public\n */\nexport type AnyStoreEmitters = StoreEmitters<AnyXStoreModule>;\n\n/**\n * Helper function for creating type-safe {@link StoreEmitters}.\n *\n * @param storeModule - The store module that the emitters will be associated to.\n * @param emitters - The {@link StoreEmitters} to create.\n * @returns A type-safe function for storeEmitters.\n * @public\n */\nexport function createStoreEmitters<\n Module extends AnyXStoreModule,\n Emitters extends StoreEmitters<Module>\n // eslint-disable-next-line @typescript-eslint/no-unused-vars-experimental\n>(storeModule: Module, emitters: Emitters): Emitters {\n return emitters;\n}\n"],"names":[],"mappings":"AA2FA;;;;;;;;SAQgB,mBAAmB,CAIjC,WAAmB,EAAE,QAAkB;IACvC,OAAO,QAAQ,CAAC;AAClB;;;;"}
@@ -1,8 +1,8 @@
1
1
  import { deepMerge } from '@empathyco/x-deep-merge';
2
+ import { cleanUndefined, forEach } from '@empathyco/x-utils';
2
3
  import Vue from 'vue';
3
4
  import { BaseXBus } from '../../plugins/x-bus.js';
4
5
  import { XPlugin } from '../../plugins/x-plugin.js';
5
- import { cleanUndefined, forEach } from '../../utils/object.js';
6
6
  import { BaseXAPI } from '../api/base-api.js';
7
7
 
8
8
  const defaultAdapterConfig = {
@@ -1 +1 @@
1
- {"version":3,"file":"x-installer.js","sources":["../../../../src/x-installer/x-installer/x-installer.ts"],"sourcesContent":["import { EmpathyAdapterConfig } from '@empathyco/x-adapter';\nimport { deepMerge } from '@empathyco/x-deep-merge';\nimport Vue, { PluginObject, VueConstructor } from 'vue';\nimport { BaseXBus } from '../../plugins/x-bus';\nimport { XBus } from '../../plugins/x-bus.types';\nimport { XPlugin } from '../../plugins/x-plugin';\nimport { XPluginOptions } from '../../plugins/x-plugin.types';\nimport { cleanUndefined, forEach } from '../../utils/object';\nimport { DeepPartial } from '../../utils/types';\nimport { SnippetConfig, XAPI } from '../api/api.types';\nimport { BaseXAPI } from '../api/base-api';\nimport { InitWrapper, InstallXOptions, VueConstructorPartialArgument } from './types';\n\ndeclare global {\n interface Window {\n X?: XAPI;\n initX?: (() => SnippetConfig) | SnippetConfig;\n }\n}\n\nconst defaultAdapterConfig: DeepPartial<EmpathyAdapterConfig> = {\n env: 'live',\n requestParams: {\n lang: 'es',\n scope: 'default'\n }\n};\n\n/**\n * The purpose of this class is to offer a quick way to initialize the XComponents in a setup\n * project. It allows to receive all the options in {@link InstallXOptions} which is an extension\n * of {@link XPluginOptions} with all the options for the plugin and some options more.\n *\n * This class does multiple things:\n * 1. Install the {@link XPlugin} with the {@link XPluginOptions}.\n * 2. Creates the public {@link XAPI} and add it to global window.\n * 3. Creates the Vue Application for the customer project.\n *\n * The steps 2 & 3 are optional and depends on the options passed in {@link InstallXOptions}.\n *\n * @example The way to use this class is the next:\n * 1. Create the installer passing in the {@link InstallXOptions}. This only save the options:\n *\n * ```\n * const installer = new XInstaller(installXOptions)\n * ```\n *\n * 2. Initialize passing the {@link SnippetConfig}. This installs the plugin and creates the App.\n * There are 3 different ways to do this:\n *\n * 2.1 Using the created installer:\n *\n * ```\n * installer.init(snippetConfig)\n * ```\n *\n * 2.2 If the API option is enabled (`createAPI` is `true` in {@link InstallXOptions}, or\n * is not present as the default value is `true`) then this init step can be done with\n * the Public API:\n *\n * ```\n * window.X.init(snippetConfig)\n * ```\n *\n * 2.3 When the script of the project build is loaded it searches for a global `initX`\n * variable that the customer must have in their web site. This variable can be a\n * function that returns the {@link SnippetConfig} or an object that contains the\n * {@link SnippetConfig} itself:\n *\n * ```\n * window.initX = function() {\n * return {\n * instance,\n * env,\n * scope,\n * lang,\n * searchLang,\n * currency,\n * consent,\n * documentDirection\n * };\n * };\n * ```\n *\n * ```\n * window.initX = {\n * instance,\n * env,\n * scope,\n * lang,\n * searchLang,\n * currency,\n * consent,\n * documentDirection\n * };\n * ```\n *\n * @public\n */\nexport class XInstaller {\n private api?: XAPI;\n\n /**\n * The configuration coming from the snippet {@link SnippetConfig}.\n *\n * @internal\n */\n protected snippetConfig!: SnippetConfig;\n\n /**\n * Receives the {@link InstallXOptions} and merges it with the default fallback options. Also\n * creates the public {@link XAPI}.\n *\n * @remarks Auto initializes the Vue application if window.initX is defined as a function or\n * object specifying the {@link SnippetConfig | snippet config}.\n *\n *\n * @param options - The {@link InstallXOptions}.\n *\n * @public\n */\n public constructor(protected readonly options: InstallXOptions) {\n this.createAPI();\n }\n\n /**\n * Creates the public {@link XAPI} using the `api` option from {@link InstallXOptions}. If this\n * `api` option is not passed, then a default {@link BaseXAPI} is created. To disable the API\n * creation the value `false` must be passed in the `api` option.\n *\n * @internal\n */\n protected createAPI(): void {\n const { api } = this.options;\n if (api !== false) {\n this.api = api ?? new BaseXAPI();\n this.api.setInitCallback(this.init.bind(this));\n this.api.setSnippetConfigCallback(this.updateSnippetConfig.bind(this));\n window.X = this.api;\n }\n }\n\n /**\n * Retrieves the {@link SnippetConfig | snippet config} it is defined in the window.initX.\n *\n * @returns The snippet config if it is defined or undefined otherwise.\n *\n * @internal\n */\n private retrieveSnippetConfig(): SnippetConfig | undefined {\n if (typeof window.initX === 'function') {\n return window.initX();\n } else if (typeof window.initX === 'object') {\n return window.initX;\n }\n }\n\n /**\n * Receives the {@link SnippetConfig | snippet config} or retrieves it from window.initX and\n * installs the plugin and initializes the Vue application.\n *\n * @param snippetConfig - The {@link SnippetConfig} that receives from snippet integration.\n *\n * @returns If {@link SnippetConfig | snippet config} is passed or configured in window.initX,\n * returns an object with the {@link XAPI}, the {@link XBus}, the {@link XPlugin} and the Vue App\n * used in the application. Else, a rejected promise is returned.\n *\n * @public\n */\n init(snippetConfig: SnippetConfig): Promise<InitWrapper>;\n init(): Promise<InitWrapper | void>;\n async init(snippetConfig = this.retrieveSnippetConfig()): Promise<InitWrapper | void> {\n if (snippetConfig) {\n const adapterConfig = this.getAdapterConfig(snippetConfig);\n this.applyConfigToAdapter(adapterConfig);\n const bus = this.createBus();\n const pluginOptions = this.getPluginOptions();\n const plugin = this.installPlugin(pluginOptions, bus);\n const extraPlugins = await this.installExtraPlugins(snippetConfig, bus);\n const app = this.createApp(extraPlugins, snippetConfig);\n this.api?.setBus(bus);\n\n return {\n api: this.api,\n app,\n bus,\n plugin\n };\n }\n\n return Promise.resolve();\n }\n\n /**\n * Creates the Adapter Config object using the {@link SnippetConfig} to do it. It also\n * merges the default configuration.\n *\n * @param options - The {@link SnippetConfig}.\n *\n * @returns The Adapter Config object.\n *\n * @internal\n */\n protected getAdapterConfig({ instance, env, lang, searchLang, scope }: SnippetConfig): unknown {\n return deepMerge(\n defaultAdapterConfig,\n cleanUndefined<DeepPartial<EmpathyAdapterConfig>>({\n instance,\n env,\n requestParams: {\n lang: searchLang ?? lang,\n scope\n }\n })\n );\n }\n\n /**\n * Creates the {@link XPluginOptions} object.\n *\n * @returns The {@link XPluginOptions} object.\n *\n * @internal\n */\n protected getPluginOptions(): XPluginOptions {\n const { adapter, store, initialXModules, xModules, __PRIVATE__xModules } = this.options;\n return {\n adapter,\n store,\n xModules,\n initialXModules,\n __PRIVATE__xModules\n };\n }\n\n /**\n * It applies the snippet configuration to the Adapter. Not all the parameters are for the Adapter\n * but they appear destructured to not include them in the `extraParams` parameter.\n *\n * @param adapterConfig - The Adapter config object.\n *\n * @internal\n */\n protected applyConfigToAdapter(adapterConfig: any): void {\n this.options.adapter.setConfig?.(adapterConfig);\n }\n\n /**\n * This method returns the bus instance to be used in the {@link XPlugin} and in the {@link XAPI}.\n * It returns the `bus` parameter in the {@link InstallXOptions} or if not provided, then\n * creates a new instance of {@link BaseXBus}.\n *\n * @returns XBus - The bus instance.\n *\n * @internal\n */\n protected createBus(): XBus {\n return this.options.bus ?? new BaseXBus();\n }\n\n /**\n * This method returns the VueConstructor to use to create the App instance.\n * It returns the `vue` parameter in the {@link InstallXOptions} or if not provided, then\n * returns the default Vue.\n *\n * @remarks The purpose of this option is mainly the testing. In a test we can use this option\n * to pass the local vue instance created by `createLocalVue` method.\n *\n * @returns VueConstructor - The vue constructor to create the App instance.\n *\n * @internal\n */\n protected getVue(): VueConstructor {\n return this.options.vue ?? Vue;\n }\n\n /**\n * Creates and install the Vue Plugin. If `plugin` parameter is passed in the\n * {@link InstallXOptions}, then it is used. If not, then a new instance of {@link XPlugin} is\n * created and installed.\n *\n * @param pluginOptions - The {@link XPluginOptions} to passed as parameter to the install method\n * of the plugin.\n * @param bus - The {@link XBus} to be used to create the XPlugin.\n *\n * @returns PluginObject<XPluginOption> - The plugin instance.\n * @internal\n */\n protected installPlugin(pluginOptions: XPluginOptions, bus: XBus): PluginObject<XPluginOptions> {\n const plugin = this.options.plugin ?? new XPlugin(bus);\n const vue = this.getVue();\n vue.use(plugin, pluginOptions);\n return plugin;\n }\n\n /**\n * Install more plugins to Vue defined by the user.\n *\n * @param snippet - The snippet configuration.\n * @param bus - The events bus used in the application.\n * @returns The arguments from the plugins installation to be used in Vue's constructor.\n * @internal\n */\n protected installExtraPlugins(\n snippet: SnippetConfig,\n bus: XBus\n ): Promise<VueConstructorPartialArgument> {\n const vue = this.getVue();\n return Promise.resolve(this.options.installExtraPlugins?.({ vue, snippet, bus }));\n }\n\n /**\n * In the case that the `app` parameter is present in the {@link InstallXOptions}, then a new Vue\n * application is created using that app.\n *\n * @param extraPlugins - Vue plugins initialisation data.\n * @param snippetConfig - Configuration from the client snippet.\n * @returns The Created Vue application or undefined if not created.\n *\n * @internal\n */\n protected createApp(\n extraPlugins: VueConstructorPartialArgument,\n snippetConfig: SnippetConfig\n ): Vue | undefined {\n if (this.options.app !== undefined) {\n const vue = this.getVue();\n this.snippetConfig = vue.observable(snippetConfig);\n return new vue({\n ...extraPlugins,\n ...this.options.vueOptions,\n provide() {\n return {\n snippetConfig\n };\n },\n store: this.options.store,\n el: this.getMountingTarget(this.options.domElement),\n render: h => h(this.options.app)\n });\n }\n }\n\n /**\n * It returns the HTML element to mount the Vue Application. If the `domElement` parameter in the\n * {@link InstallXOptions} is an Element or a string, then it is used. If it is\n * not present then a new <div> Element is created and append to the body to be used.\n *\n * @param elementOrSelector - String or Element used to mount the Vue App.\n *\n * @returns The Element to use as mounting point for the Vue App.\n * @internal\n */\n protected getMountingTarget(elementOrSelector?: string | Element): Element {\n if (typeof elementOrSelector === 'string') {\n const target = document.querySelector(elementOrSelector);\n if (!target) {\n throw Error(\n `XComponents app couldn't be mounted: Element \"${elementOrSelector}\" couldn't be found`\n );\n }\n return target;\n } else if (elementOrSelector !== undefined) {\n return elementOrSelector;\n } else {\n return document.body.appendChild(document.createElement('div'));\n }\n }\n\n /**\n * It updates all the provided properties from the current snippet config.\n *\n * @param snippetConfig - All the properties to be updated in the {@link SnippetConfig}.\n *\n * @internal\n */\n protected updateSnippetConfig(snippetConfig: Partial<SnippetConfig>): void {\n forEach(snippetConfig, (name, value) => {\n this.getVue().set(this.snippetConfig, name, value);\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;AAoBA,MAAM,oBAAoB,GAAsC;IAC9D,GAAG,EAAE,MAAM;IACX,aAAa,EAAE;QACb,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,SAAS;KACjB;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAuEa,UAAU;;;;;;;;;;;;;IAsBrB,YAAsC,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;QAC5D,IAAI,CAAC,SAAS,EAAE,CAAC;KAClB;;;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AM,CAAC;SACf;aAAM,IAAI,iBAAiB,KAAK,SAAS,EAAE;YAC1C,OAAO,iBAAiB,CAAC;SAC1B;aAAM;YACL,OAAO,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;SACjE;KACF;;;;;;;;IASS,mBAAmB,CAAC,aAAqC;QACjE,OAAO,CAAC,aAAa,EAAE,CAAC,IAAI,EAAE,KAAK;YACjC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;SACpD,CAAC,CAAC;KACJ;;;;;"}
1
+ {"version":3,"file":"x-installer.js","sources":["../../../../src/x-installer/x-installer/x-installer.ts"],"sourcesContent":["import { EmpathyAdapterConfig } from '@empathyco/x-adapter';\nimport { deepMerge } from '@empathyco/x-deep-merge';\nimport { cleanUndefined, forEach } from '@empathyco/x-utils';\nimport Vue, { PluginObject, VueConstructor } from 'vue';\nimport { BaseXBus } from '../../plugins/x-bus';\nimport { XBus } from '../../plugins/x-bus.types';\nimport { XPlugin } from '../../plugins/x-plugin';\nimport { XPluginOptions } from '../../plugins/x-plugin.types';\nimport { DeepPartial } from '../../utils/types';\nimport { SnippetConfig, XAPI } from '../api/api.types';\nimport { BaseXAPI } from '../api/base-api';\nimport { InitWrapper, InstallXOptions, VueConstructorPartialArgument } from './types';\n\ndeclare global {\n interface Window {\n X?: XAPI;\n initX?: (() => SnippetConfig) | SnippetConfig;\n }\n}\n\nconst defaultAdapterConfig: DeepPartial<EmpathyAdapterConfig> = {\n env: 'live',\n requestParams: {\n lang: 'es',\n scope: 'default'\n }\n};\n\n/**\n * The purpose of this class is to offer a quick way to initialize the XComponents in a setup\n * project. It allows to receive all the options in {@link InstallXOptions} which is an extension\n * of {@link XPluginOptions} with all the options for the plugin and some options more.\n *\n * This class does multiple things:\n * 1. Install the {@link XPlugin} with the {@link XPluginOptions}.\n * 2. Creates the public {@link XAPI} and add it to global window.\n * 3. Creates the Vue Application for the customer project.\n *\n * The steps 2 & 3 are optional and depends on the options passed in {@link InstallXOptions}.\n *\n * @example The way to use this class is the next:\n * 1. Create the installer passing in the {@link InstallXOptions}. This only save the options:\n *\n * ```\n * const installer = new XInstaller(installXOptions)\n * ```\n *\n * 2. Initialize passing the {@link SnippetConfig}. This installs the plugin and creates the App.\n * There are 3 different ways to do this:\n *\n * 2.1 Using the created installer:\n *\n * ```\n * installer.init(snippetConfig)\n * ```\n *\n * 2.2 If the API option is enabled (`createAPI` is `true` in {@link InstallXOptions}, or\n * is not present as the default value is `true`) then this init step can be done with\n * the Public API:\n *\n * ```\n * window.X.init(snippetConfig)\n * ```\n *\n * 2.3 When the script of the project build is loaded it searches for a global `initX`\n * variable that the customer must have in their web site. This variable can be a\n * function that returns the {@link SnippetConfig} or an object that contains the\n * {@link SnippetConfig} itself:\n *\n * ```\n * window.initX = function() {\n * return {\n * instance,\n * env,\n * scope,\n * lang,\n * searchLang,\n * currency,\n * consent,\n * documentDirection\n * };\n * };\n * ```\n *\n * ```\n * window.initX = {\n * instance,\n * env,\n * scope,\n * lang,\n * searchLang,\n * currency,\n * consent,\n * documentDirection\n * };\n * ```\n *\n * @public\n */\nexport class XInstaller {\n private api?: XAPI;\n\n /**\n * The configuration coming from the snippet {@link SnippetConfig}.\n *\n * @internal\n */\n protected snippetConfig!: SnippetConfig;\n\n /**\n * Receives the {@link InstallXOptions} and merges it with the default fallback options. Also\n * creates the public {@link XAPI}.\n *\n * @remarks Auto initializes the Vue application if window.initX is defined as a function or\n * object specifying the {@link SnippetConfig | snippet config}.\n *\n *\n * @param options - The {@link InstallXOptions}.\n *\n * @public\n */\n public constructor(protected readonly options: InstallXOptions) {\n this.createAPI();\n }\n\n /**\n * Creates the public {@link XAPI} using the `api` option from {@link InstallXOptions}. If this\n * `api` option is not passed, then a default {@link BaseXAPI} is created. To disable the API\n * creation the value `false` must be passed in the `api` option.\n *\n * @internal\n */\n protected createAPI(): void {\n const { api } = this.options;\n if (api !== false) {\n this.api = api ?? new BaseXAPI();\n this.api.setInitCallback(this.init.bind(this));\n this.api.setSnippetConfigCallback(this.updateSnippetConfig.bind(this));\n window.X = this.api;\n }\n }\n\n /**\n * Retrieves the {@link SnippetConfig | snippet config} it is defined in the window.initX.\n *\n * @returns The snippet config if it is defined or undefined otherwise.\n *\n * @internal\n */\n private retrieveSnippetConfig(): SnippetConfig | undefined {\n if (typeof window.initX === 'function') {\n return window.initX();\n } else if (typeof window.initX === 'object') {\n return window.initX;\n }\n }\n\n /**\n * Receives the {@link SnippetConfig | snippet config} or retrieves it from window.initX and\n * installs the plugin and initializes the Vue application.\n *\n * @param snippetConfig - The {@link SnippetConfig} that receives from snippet integration.\n *\n * @returns If {@link SnippetConfig | snippet config} is passed or configured in window.initX,\n * returns an object with the {@link XAPI}, the {@link XBus}, the {@link XPlugin} and the Vue App\n * used in the application. Else, a rejected promise is returned.\n *\n * @public\n */\n init(snippetConfig: SnippetConfig): Promise<InitWrapper>;\n init(): Promise<InitWrapper | void>;\n async init(snippetConfig = this.retrieveSnippetConfig()): Promise<InitWrapper | void> {\n if (snippetConfig) {\n const adapterConfig = this.getAdapterConfig(snippetConfig);\n this.applyConfigToAdapter(adapterConfig);\n const bus = this.createBus();\n const pluginOptions = this.getPluginOptions();\n const plugin = this.installPlugin(pluginOptions, bus);\n const extraPlugins = await this.installExtraPlugins(snippetConfig, bus);\n const app = this.createApp(extraPlugins, snippetConfig);\n this.api?.setBus(bus);\n\n return {\n api: this.api,\n app,\n bus,\n plugin\n };\n }\n\n return Promise.resolve();\n }\n\n /**\n * Creates the Adapter Config object using the {@link SnippetConfig} to do it. It also\n * merges the default configuration.\n *\n * @param options - The {@link SnippetConfig}.\n *\n * @returns The Adapter Config object.\n *\n * @internal\n */\n protected getAdapterConfig({ instance, env, lang, searchLang, scope }: SnippetConfig): unknown {\n return deepMerge(\n defaultAdapterConfig,\n cleanUndefined<DeepPartial<EmpathyAdapterConfig>>({\n instance,\n env,\n requestParams: {\n lang: searchLang ?? lang,\n scope\n }\n })\n );\n }\n\n /**\n * Creates the {@link XPluginOptions} object.\n *\n * @returns The {@link XPluginOptions} object.\n *\n * @internal\n */\n protected getPluginOptions(): XPluginOptions {\n const { adapter, store, initialXModules, xModules, __PRIVATE__xModules } = this.options;\n return {\n adapter,\n store,\n xModules,\n initialXModules,\n __PRIVATE__xModules\n };\n }\n\n /**\n * It applies the snippet configuration to the Adapter. Not all the parameters are for the Adapter\n * but they appear destructured to not include them in the `extraParams` parameter.\n *\n * @param adapterConfig - The Adapter config object.\n *\n * @internal\n */\n protected applyConfigToAdapter(adapterConfig: any): void {\n this.options.adapter.setConfig?.(adapterConfig);\n }\n\n /**\n * This method returns the bus instance to be used in the {@link XPlugin} and in the {@link XAPI}.\n * It returns the `bus` parameter in the {@link InstallXOptions} or if not provided, then\n * creates a new instance of {@link BaseXBus}.\n *\n * @returns XBus - The bus instance.\n *\n * @internal\n */\n protected createBus(): XBus {\n return this.options.bus ?? new BaseXBus();\n }\n\n /**\n * This method returns the VueConstructor to use to create the App instance.\n * It returns the `vue` parameter in the {@link InstallXOptions} or if not provided, then\n * returns the default Vue.\n *\n * @remarks The purpose of this option is mainly the testing. In a test we can use this option\n * to pass the local vue instance created by `createLocalVue` method.\n *\n * @returns VueConstructor - The vue constructor to create the App instance.\n *\n * @internal\n */\n protected getVue(): VueConstructor {\n return this.options.vue ?? Vue;\n }\n\n /**\n * Creates and install the Vue Plugin. If `plugin` parameter is passed in the\n * {@link InstallXOptions}, then it is used. If not, then a new instance of {@link XPlugin} is\n * created and installed.\n *\n * @param pluginOptions - The {@link XPluginOptions} to passed as parameter to the install method\n * of the plugin.\n * @param bus - The {@link XBus} to be used to create the XPlugin.\n *\n * @returns PluginObject<XPluginOption> - The plugin instance.\n * @internal\n */\n protected installPlugin(pluginOptions: XPluginOptions, bus: XBus): PluginObject<XPluginOptions> {\n const plugin = this.options.plugin ?? new XPlugin(bus);\n const vue = this.getVue();\n vue.use(plugin, pluginOptions);\n return plugin;\n }\n\n /**\n * Install more plugins to Vue defined by the user.\n *\n * @param snippet - The snippet configuration.\n * @param bus - The events bus used in the application.\n * @returns The arguments from the plugins installation to be used in Vue's constructor.\n * @internal\n */\n protected installExtraPlugins(\n snippet: SnippetConfig,\n bus: XBus\n ): Promise<VueConstructorPartialArgument> {\n const vue = this.getVue();\n return Promise.resolve(this.options.installExtraPlugins?.({ vue, snippet, bus }));\n }\n\n /**\n * In the case that the `app` parameter is present in the {@link InstallXOptions}, then a new Vue\n * application is created using that app.\n *\n * @param extraPlugins - Vue plugins initialisation data.\n * @param snippetConfig - Configuration from the client snippet.\n * @returns The Created Vue application or undefined if not created.\n *\n * @internal\n */\n protected createApp(\n extraPlugins: VueConstructorPartialArgument,\n snippetConfig: SnippetConfig\n ): Vue | undefined {\n if (this.options.app !== undefined) {\n const vue = this.getVue();\n this.snippetConfig = vue.observable(snippetConfig);\n return new vue({\n ...extraPlugins,\n ...this.options.vueOptions,\n provide() {\n return {\n snippetConfig\n };\n },\n store: this.options.store,\n el: this.getMountingTarget(this.options.domElement),\n render: h => h(this.options.app)\n });\n }\n }\n\n /**\n * It returns the HTML element to mount the Vue Application. If the `domElement` parameter in the\n * {@link InstallXOptions} is an Element or a string, then it is used. If it is\n * not present then a new <div> Element is created and append to the body to be used.\n *\n * @param elementOrSelector - String or Element used to mount the Vue App.\n *\n * @returns The Element to use as mounting point for the Vue App.\n * @internal\n */\n protected getMountingTarget(elementOrSelector?: string | Element): Element {\n if (typeof elementOrSelector === 'string') {\n const target = document.querySelector(elementOrSelector);\n if (!target) {\n throw Error(\n `XComponents app couldn't be mounted: Element \"${elementOrSelector}\" couldn't be found`\n );\n }\n return target;\n } else if (elementOrSelector !== undefined) {\n return elementOrSelector;\n } else {\n return document.body.appendChild(document.createElement('div'));\n }\n }\n\n /**\n * It updates all the provided properties from the current snippet config.\n *\n * @param snippetConfig - All the properties to be updated in the {@link SnippetConfig}.\n *\n * @internal\n */\n protected updateSnippetConfig(snippetConfig: Partial<SnippetConfig>): void {\n forEach(snippetConfig, (name, value) => {\n this.getVue().set(this.snippetConfig, name, value);\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;AAoBA,MAAM,oBAAoB,GAAsC;IAC9D,GAAG,EAAE,MAAM;IACX,aAAa,EAAE;QACb,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,SAAS;KACjB;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAuEa,UAAU;;;;;;;;;;;;;IAsBrB,YAAsC,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;QAC5D,IAAI,CAAC,SAAS,EAAE,CAAC;KAClB;;;;;;;;IASS,SAAS;QACjB,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,GAAG,KAAK,KAAK,EAAE;YACjB,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,IAAI,QAAQ,EAAE,CAAC;YACjC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/C,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACvE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;SACrB;KACF;;;;;;;;IASO,qBAAqB;QAC3B,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,UAAU,EAAE;YACtC,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;SACvB;aAAM,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,EAAE;YAC3C,OAAO,MAAM,CAAC,KAAK,CAAC;SACrB;KACF;IAgBD,MAAM,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,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AAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;gBACzB,EAAE,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;gBACnD,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;aACjC,CAAC,CAAC;SACJ;KACF;;;;;;;;;;;IAYS,iBAAiB,CAAC,iBAAoC;QAC9D,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE;YACzC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;YACzD,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,KAAK,CACT,iDAAiD,iBAAiB,qBAAqB,CACxF,CAAC;aACH;YACD,OAAO,MAAM,CAAC;SACf;aAAM,IAAI,iBAAiB,KAAK,SAAS,EAAE;YAC1C,OAAO,iBAAiB,CAAC;SAC1B;aAAM;YACL,OAAO,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;SACjE;KACF;;;;;;;;IASS,mBAAmB,CAAC,aAAqC;QACjE,OAAO,CAAC,aAAa,EAAE,CAAC,IAAI,EAAE,KAAK;YACjC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;SACpD,CAAC,CAAC;KACJ;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"extra-params.vue.js","sources":["../../../../../src/x-modules/extra-params/components/extra-params.vue"],"sourcesContent":["<script lang=\"ts\">\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { State, xComponentMixin, XEmit } from '../../../components';\n import { Dictionary } from '../../../utils';\n import { extraParamsXModule } from '../x-module';\n\n /**\n * It emits a {@link ExtraParamsXEvents.ExtraParamsProvided} with the values\n * received as a prop.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(extraParamsXModule)]\n })\n export default class ExtraParams extends Vue {\n /**\n * Emits the initial extra params, overriding with the state extra params, just in case, those\n * values were already set by XComponents initialization (url, plugin config, etc.).\n */\n mounted(): void {\n this.$x.emit('ExtraParamsInitialized', { ...this.values });\n this.$x.emit('ExtraParamsProvided', { ...this.values, ...this.storeExtraParams });\n }\n\n /**\n * (Required) A Dictionary where the keys are the extra param names and its values.\n *\n * @remarks Emits the {@link ExtraParamsXEvents.ExtraParamsProvided} when the\n * component is rendered or the values changed.\n *\n * @public\n */\n @XEmit('ExtraParamsProvided', { deep: true })\n @Prop({ required: true })\n public values!: Dictionary<unknown>;\n\n /**\n * State extra params. Used to override the initial extra params.\n */\n @State('extraParams', 'params')\n public storeExtraParams!: Dictionary<unknown>;\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n render(): void {}\n }\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\n- [`ExtraParamsProvided`][1]\n\n[1](./../../api/x-components.extraparamsxevents.extraparamsprovided.md)\n\n## See it in action\n\n_See how the event is triggered when the component is rendered._\n\n```vue\n<template>\n <ExtraParams :values=\"values\" />\n</template>\n\n<script>\n import { ExtraParams } from '@empathyco/x-components/extra-params';\n\n export default {\n name: 'ExtraParamsDemo',\n components: {\n ExtraParams\n },\n data() {\n return {\n values: {\n warehouse: 1234\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"extra-params.vue.js","sources":["../../../../../src/x-modules/extra-params/components/extra-params.vue"],"sourcesContent":["<script lang=\"ts\">\n import { Dictionary } from '@empathyco/x-utils';\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { State, xComponentMixin, XEmit } from '../../../components';\n import { extraParamsXModule } from '../x-module';\n\n /**\n * It emits a {@link ExtraParamsXEvents.ExtraParamsProvided} with the values\n * received as a prop.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(extraParamsXModule)]\n })\n export default class ExtraParams extends Vue {\n /**\n * Emits the initial extra params, overriding with the state extra params, just in case, those\n * values were already set by XComponents initialization (url, plugin config, etc.).\n */\n mounted(): void {\n this.$x.emit('ExtraParamsInitialized', { ...this.values });\n this.$x.emit('ExtraParamsProvided', { ...this.values, ...this.storeExtraParams });\n }\n\n /**\n * (Required) A Dictionary where the keys are the extra param names and its values.\n *\n * @remarks Emits the {@link ExtraParamsXEvents.ExtraParamsProvided} when the\n * component is rendered or the values changed.\n *\n * @public\n */\n @XEmit('ExtraParamsProvided', { deep: true })\n @Prop({ required: true })\n public values!: Dictionary<unknown>;\n\n /**\n * State extra params. Used to override the initial extra params.\n */\n @State('extraParams', 'params')\n public storeExtraParams!: Dictionary<unknown>;\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n render(): void {}\n }\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\n- [`ExtraParamsProvided`][1]\n\n[1](./../../api/x-components.extraparamsxevents.extraparamsprovided.md)\n\n## See it in action\n\n_See how the event is triggered when the component is rendered._\n\n```vue\n<template>\n <ExtraParams :values=\"values\" />\n</template>\n\n<script>\n import { ExtraParams } from '@empathyco/x-components/extra-params';\n\n export default {\n name: 'ExtraParamsDemo',\n components: {\n ExtraParams\n },\n data() {\n return {\n values: {\n warehouse: 1234\n }\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"extra-params.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../src/x-modules/extra-params/components/extra-params.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\nimport Vue from 'vue';\nimport { Component, Prop } from 'vue-property-decorator';\nimport { State, xComponentMixin, XEmit } from '../../../components';\nimport { Dictionary } from '../../../utils';\nimport { extraParamsXModule } from '../x-module';\n\n/**\n * It emits a {@link ExtraParamsXEvents.ExtraParamsProvided} with the values\n * received as a prop.\n *\n * @public\n */\n@Component({\n mixins: [xComponentMixin(extraParamsXModule)]\n})\nexport default class ExtraParams extends Vue {\n /**\n * Emits the initial extra params, overriding with the state extra params, just in case, those\n * values were already set by XComponents initialization (url, plugin config, etc.).\n */\n mounted(): void {\n this.$x.emit('ExtraParamsInitialized', { ...this.values });\n this.$x.emit('ExtraParamsProvided', { ...this.values, ...this.storeExtraParams });\n }\n\n /**\n * (Required) A Dictionary where the keys are the extra param names and its values.\n *\n * @remarks Emits the {@link ExtraParamsXEvents.ExtraParamsProvided} when the\n * component is rendered or the values changed.\n *\n * @public\n */\n @XEmit('ExtraParamsProvided', { deep: true })\n @Prop({ required: true })\n public values!: Dictionary<unknown>;\n\n /**\n * State extra params. Used to override the initial extra params.\n */\n @State('extraParams', 'params')\n public storeExtraParams!: Dictionary<unknown>;\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n render(): void {}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;;;;;;AASA,IAAqB,WAAW,GAAhC,MAAqB,WAAY,SAAQ,GAAG;;;;;IAK1C,OAAO;QACL,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;KACnF;;IAqBD,MAAM,MAAW;CAClB,CAAA;AAVC;IAFC,KAAK,CAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC5C,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;2CACW;AAMpC;IADC,KAAK,CAAC,aAAa,EAAE,QAAQ,CAAC;qDACe;AA1B3B,WAAW;IAH/B,SAAS,CAAC;QACT,MAAM,EAAE,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;KAC9C,CAAC;GACmB,WAAW,CA8B/B;aA9BoB,WAAW;;;;"}
1
+ {"version":3,"file":"extra-params.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../src/x-modules/extra-params/components/extra-params.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\nimport { Dictionary } from '@empathyco/x-utils';\nimport Vue from 'vue';\nimport { Component, Prop } from 'vue-property-decorator';\nimport { State, xComponentMixin, XEmit } from '../../../components';\nimport { extraParamsXModule } from '../x-module';\n\n/**\n * It emits a {@link ExtraParamsXEvents.ExtraParamsProvided} with the values\n * received as a prop.\n *\n * @public\n */\n@Component({\n mixins: [xComponentMixin(extraParamsXModule)]\n})\nexport default class ExtraParams extends Vue {\n /**\n * Emits the initial extra params, overriding with the state extra params, just in case, those\n * values were already set by XComponents initialization (url, plugin config, etc.).\n */\n mounted(): void {\n this.$x.emit('ExtraParamsInitialized', { ...this.values });\n this.$x.emit('ExtraParamsProvided', { ...this.values, ...this.storeExtraParams });\n }\n\n /**\n * (Required) A Dictionary where the keys are the extra param names and its values.\n *\n * @remarks Emits the {@link ExtraParamsXEvents.ExtraParamsProvided} when the\n * component is rendered or the values changed.\n *\n * @public\n */\n @XEmit('ExtraParamsProvided', { deep: true })\n @Prop({ required: true })\n public values!: Dictionary<unknown>;\n\n /**\n * State extra params. Used to override the initial extra params.\n */\n @State('extraParams', 'params')\n public storeExtraParams!: Dictionary<unknown>;\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n render(): void {}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;;;;;;AASA,IAAqB,WAAW,GAAhC,MAAqB,WAAY,SAAQ,GAAG;;;;;IAK1C,OAAO;QACL,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;KACnF;;IAqBD,MAAM,MAAW;CAClB,CAAA;AAVC;IAFC,KAAK,CAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC5C,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;2CACW;AAMpC;IADC,KAAK,CAAC,aAAa,EAAE,QAAQ,CAAC;qDACe;AA1B3B,WAAW;IAH/B,SAAS,CAAC;QACT,MAAM,EAAE,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;KAC9C,CAAC;GACmB,WAAW,CA8B/B;aA9BoB,WAAW;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"renderless-extra-param.vue.js","sources":["../../../../../src/x-modules/extra-params/components/renderless-extra-param.vue"],"sourcesContent":["<template>\n <NoElement>\n <slot v-bind=\"{ value, updateValue }\"></slot>\n </NoElement>\n</template>\n\n<script lang=\"ts\">\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { NoElement, State, xComponentMixin } from '../../../components';\n import { Dictionary } from '../../../utils';\n import { extraParamsXModule } from '../x-module';\n\n /**\n * It emits a {@link ExtraParamsXEvents.UserChangedExtraParams} when the `updateValue`\n * is called.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(extraParamsXModule)],\n components: {\n NoElement\n }\n })\n export default class RenderlessExtraParam extends Vue {\n /**\n * The extra param's name.\n *\n * @public\n */\n @Prop({ required: true })\n public name!: string;\n\n /**\n * A dictionary with the extra params in the store state.\n *\n * @public\n */\n @State('extraParams', 'params')\n public stateParams!: Dictionary<unknown>;\n\n /**\n * It returns the value of the extra param from the store.\n *\n * @returns - The value from the store.\n *\n * @internal\n */\n protected get value(): unknown {\n return this.stateParams[this.name];\n }\n\n /**\n * It sets the new value to the store.\n *\n * @param newValue - The new value of the extra param.\n *\n * @internal\n */\n protected updateValue(newValue: unknown): void {\n this.$x.emit('UserChangedExtraParams', { [this.name]: newValue });\n }\n }\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nRenders default slot content. It binds to the default slot the name of the extra parameter and the\ndefault value of it.\n\n### Basic usage\n\n```vue\n<template>\n <RenderlessExtraParam #default=\"{ value, updateValue }\" name=\"store\">\n <BaseDropdown @change=\"updateValue\" :value=\"value\" :items=\"items\" />\n </RenderlessExtraParam>\n</template>\n\n<script>\n import { RenderlessExtraParams } from '@empathyco/x-components/extra-params';\n import { BaseDropdown } from '@empathyco/x-components';\n\n export default {\n name: 'RenderlessExtraParamsDemo',\n components: {\n RenderlessExtraParams,\n BaseDropdown\n },\n props: ['name'],\n data() {\n return {\n items: ['spain', 'portugal']\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"renderless-extra-param.vue.js","sources":["../../../../../src/x-modules/extra-params/components/renderless-extra-param.vue"],"sourcesContent":["<template>\n <NoElement>\n <slot v-bind=\"{ value, updateValue }\"></slot>\n </NoElement>\n</template>\n\n<script lang=\"ts\">\n import { Dictionary } from '@empathyco/x-utils';\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { NoElement, State, xComponentMixin } from '../../../components';\n import { extraParamsXModule } from '../x-module';\n\n /**\n * It emits a {@link ExtraParamsXEvents.UserChangedExtraParams} when the `updateValue`\n * is called.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(extraParamsXModule)],\n components: {\n NoElement\n }\n })\n export default class RenderlessExtraParam extends Vue {\n /**\n * The extra param's name.\n *\n * @public\n */\n @Prop({ required: true })\n public name!: string;\n\n /**\n * A dictionary with the extra params in the store state.\n *\n * @public\n */\n @State('extraParams', 'params')\n public stateParams!: Dictionary<unknown>;\n\n /**\n * It returns the value of the extra param from the store.\n *\n * @returns - The value from the store.\n *\n * @internal\n */\n protected get value(): unknown {\n return this.stateParams[this.name];\n }\n\n /**\n * It sets the new value to the store.\n *\n * @param newValue - The new value of the extra param.\n *\n * @internal\n */\n protected updateValue(newValue: unknown): void {\n this.$x.emit('UserChangedExtraParams', { [this.name]: newValue });\n }\n }\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\nRenders default slot content. It binds to the default slot the name of the extra parameter and the\ndefault value of it.\n\n### Basic usage\n\n```vue\n<template>\n <RenderlessExtraParam #default=\"{ value, updateValue }\" name=\"store\">\n <BaseDropdown @change=\"updateValue\" :value=\"value\" :items=\"items\" />\n </RenderlessExtraParam>\n</template>\n\n<script>\n import { RenderlessExtraParams } from '@empathyco/x-components/extra-params';\n import { BaseDropdown } from '@empathyco/x-components';\n\n export default {\n name: 'RenderlessExtraParamsDemo',\n components: {\n RenderlessExtraParams,\n BaseDropdown\n },\n props: ['name'],\n data() {\n return {\n items: ['spain', 'portugal']\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"renderless-extra-param.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../src/x-modules/extra-params/components/renderless-extra-param.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\nimport Vue from 'vue';\nimport { Component, Prop } from 'vue-property-decorator';\nimport { NoElement, State, xComponentMixin } from '../../../components';\nimport { Dictionary } from '../../../utils';\nimport { extraParamsXModule } from '../x-module';\n\n/**\n * It emits a {@link ExtraParamsXEvents.UserChangedExtraParams} when the `updateValue`\n * is called.\n *\n * @public\n */\n@Component({\n mixins: [xComponentMixin(extraParamsXModule)],\n components: {\n NoElement\n }\n})\nexport default class RenderlessExtraParam extends Vue {\n /**\n * The extra param's name.\n *\n * @public\n */\n @Prop({ required: true })\n public name!: string;\n\n /**\n * A dictionary with the extra params in the store state.\n *\n * @public\n */\n @State('extraParams', 'params')\n public stateParams!: Dictionary<unknown>;\n\n /**\n * It returns the value of the extra param from the store.\n *\n * @returns - The value from the store.\n *\n * @internal\n */\n protected get value(): unknown {\n return this.stateParams[this.name];\n }\n\n /**\n * It sets the new value to the store.\n *\n * @param newValue - The new value of the extra param.\n *\n * @internal\n */\n protected updateValue(newValue: unknown): void {\n this.$x.emit('UserChangedExtraParams', { [this.name]: newValue });\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;;;;;;AAYA,IAAqB,oBAAoB,GAAzC,MAAqB,oBAAqB,SAAQ,GAAG;;;;;;;;IAwBnD,IAAc,KAAK;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACpC;;;;;;;;IASS,WAAW,CAAC,QAAiB;QACrC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,QAAQ,EAAE,CAAC,CAAC;KACnE;CACF,CAAA;AA/BC;IADC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDACJ;AAQrB;IADC,KAAK,CAAC,aAAa,EAAE,QAAQ,CAAC;yDACU;AAftB,oBAAoB;IANxC,SAAS,CAAC;QACT,MAAM,EAAE,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;QAC7C,UAAU,EAAE;YACV,SAAS;SACV;KACF,CAAC;GACmB,oBAAoB,CAsCxC;aAtCoB,oBAAoB;;;;"}
1
+ {"version":3,"file":"renderless-extra-param.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../src/x-modules/extra-params/components/renderless-extra-param.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\nimport { Dictionary } from '@empathyco/x-utils';\nimport Vue from 'vue';\nimport { Component, Prop } from 'vue-property-decorator';\nimport { NoElement, State, xComponentMixin } from '../../../components';\nimport { extraParamsXModule } from '../x-module';\n\n/**\n * It emits a {@link ExtraParamsXEvents.UserChangedExtraParams} when the `updateValue`\n * is called.\n *\n * @public\n */\n@Component({\n mixins: [xComponentMixin(extraParamsXModule)],\n components: {\n NoElement\n }\n})\nexport default class RenderlessExtraParam extends Vue {\n /**\n * The extra param's name.\n *\n * @public\n */\n @Prop({ required: true })\n public name!: string;\n\n /**\n * A dictionary with the extra params in the store state.\n *\n * @public\n */\n @State('extraParams', 'params')\n public stateParams!: Dictionary<unknown>;\n\n /**\n * It returns the value of the extra param from the store.\n *\n * @returns - The value from the store.\n *\n * @internal\n */\n protected get value(): unknown {\n return this.stateParams[this.name];\n }\n\n /**\n * It sets the new value to the store.\n *\n * @param newValue - The new value of the extra param.\n *\n * @internal\n */\n protected updateValue(newValue: unknown): void {\n this.$x.emit('UserChangedExtraParams', { [this.name]: newValue });\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;;;;;;AAYA,IAAqB,oBAAoB,GAAzC,MAAqB,oBAAqB,SAAQ,GAAG;;;;;;;;IAwBnD,IAAc,KAAK;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACpC;;;;;;;;IASS,WAAW,CAAC,QAAiB;QACrC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,QAAQ,EAAE,CAAC,CAAC;KACnE;CACF,CAAA;AA/BC;IADC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDACJ;AAQrB;IADC,KAAK,CAAC,aAAa,EAAE,QAAQ,CAAC;yDACU;AAftB,oBAAoB;IANxC,SAAS,CAAC;QACT,MAAM,EAAE,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;QAC7C,UAAU,EAAE;YACV,SAAS;SACV;KACF,CAAC;GACmB,oBAAoB,CAsCxC;aAtCoB,oBAAoB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"snippet-config-extra-params.vue.js","sources":["../../../../../src/x-modules/extra-params/components/snippet-config-extra-params.vue"],"sourcesContent":["<template>\n <ExtraParams :values=\"extraParams\" />\n</template>\n\n<script lang=\"ts\">\n import Vue from 'vue';\n import { Component, Watch, Inject, Prop } from 'vue-property-decorator';\n import { xComponentMixin } from '../../../components';\n import { Dictionary, forEach } from '../../../utils';\n import { SnippetConfig } from '../../../x-installer';\n import { extraParamsXModule } from '../x-module';\n import ExtraParams from './extra-params.vue';\n\n /**\n * Extracts the extra parameters from the {@link SnippetConfig} and syncs it with the request\n * objects of every x-module.\n *\n * @public\n */\n @Component({\n components: { ExtraParams },\n mixins: [xComponentMixin(extraParamsXModule)]\n })\n export default class SnippetConfigExtraParams extends Vue {\n /**\n * It injects {@link SnippetConfig} provided by an ancestor as snippetConfig.\n *\n * @internal\n */\n @Inject('snippetConfig')\n public snippetConfig!: SnippetConfig;\n\n /**\n * A Dictionary where the keys are the extra param names and its values.\n *\n * @public\n */\n @Prop()\n protected values?: Dictionary<unknown>;\n\n /**\n * Custom object containing the extra params from the snippet config.\n *\n * @remarks This object keeps manually the desired snippet config properties to avoid\n * unnecessary re-renders.\n *\n * @internal\n */\n protected extraParams: Dictionary<unknown> = {};\n\n /**\n * Collection of properties from the snippet config not allowed to be sent as extra params.\n *\n * @internal\n */\n protected notAllowedExtraParams: Array<keyof SnippetConfig> = [\n 'callbacks',\n 'productId',\n 'instance',\n 'lang',\n 'searchLang',\n 'consent',\n 'documentDirection',\n 'currency'\n ];\n\n /**\n * Updates the extraParams object when the snippet config changes.\n *\n * @param snippetConfig - The new snippet config.\n *\n * @internal\n */\n @Watch('snippetConfig', { deep: true, immediate: true })\n syncExtraParams(snippetConfig: SnippetConfig): void {\n forEach({ ...this.values, ...snippetConfig }, (name, value) => {\n if (this.notAllowedExtraParams.includes(name)) {\n return;\n }\n this.$set(this.extraParams, name, value);\n });\n }\n }\n</script>\n\n<docs lang=\"mdx\">\n## See it in action\n\n_See how the snippet config is injected and passed to the SnippetConfigExtraParams component._\n\n```vue\n<template>\n <Provider>\n <SnippetConfigExtraParams />\n </Provider>\n</template>\n\n<script>\n import { SnippetConfigExtraParams } from '@empathyco/x-components/extra-params';\n\n const Provider = {\n provide: {\n snippetConfig: {\n instance: 'demo',\n lang: 'es',\n warehouse: 1234\n }\n }\n };\n\n export default {\n name: 'SnippetConfigExtraParamsDemo',\n components: {\n Provider,\n SnippetConfigExtraParams\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"snippet-config-extra-params.vue.js","sources":["../../../../../src/x-modules/extra-params/components/snippet-config-extra-params.vue"],"sourcesContent":["<template>\n <ExtraParams :values=\"extraParams\" />\n</template>\n\n<script lang=\"ts\">\n import { forEach, Dictionary } from '@empathyco/x-utils';\n import Vue from 'vue';\n import { Component, Watch, Inject, Prop } from 'vue-property-decorator';\n import { xComponentMixin } from '../../../components';\n import { SnippetConfig } from '../../../x-installer';\n import { extraParamsXModule } from '../x-module';\n import ExtraParams from './extra-params.vue';\n\n /**\n * Extracts the extra parameters from the {@link SnippetConfig} and syncs it with the request\n * objects of every x-module.\n *\n * @public\n */\n @Component({\n components: { ExtraParams },\n mixins: [xComponentMixin(extraParamsXModule)]\n })\n export default class SnippetConfigExtraParams extends Vue {\n /**\n * It injects {@link SnippetConfig} provided by an ancestor as snippetConfig.\n *\n * @internal\n */\n @Inject('snippetConfig')\n public snippetConfig!: SnippetConfig;\n\n /**\n * A Dictionary where the keys are the extra param names and its values.\n *\n * @public\n */\n @Prop()\n protected values?: Dictionary<unknown>;\n\n /**\n * Custom object containing the extra params from the snippet config.\n *\n * @remarks This object keeps manually the desired snippet config properties to avoid\n * unnecessary re-renders.\n *\n * @internal\n */\n protected extraParams: Dictionary<unknown> = {};\n\n /**\n * Collection of properties from the snippet config not allowed to be sent as extra params.\n *\n * @internal\n */\n protected notAllowedExtraParams: Array<keyof SnippetConfig> = [\n 'callbacks',\n 'productId',\n 'instance',\n 'lang',\n 'searchLang',\n 'consent',\n 'documentDirection',\n 'currency'\n ];\n\n /**\n * Updates the extraParams object when the snippet config changes.\n *\n * @param snippetConfig - The new snippet config.\n *\n * @internal\n */\n @Watch('snippetConfig', { deep: true, immediate: true })\n syncExtraParams(snippetConfig: SnippetConfig): void {\n forEach({ ...this.values, ...snippetConfig }, (name, value) => {\n if (this.notAllowedExtraParams.includes(name)) {\n return;\n }\n this.$set(this.extraParams, name, value);\n });\n }\n }\n</script>\n\n<docs lang=\"mdx\">\n## See it in action\n\n_See how the snippet config is injected and passed to the SnippetConfigExtraParams component._\n\n```vue\n<template>\n <Provider>\n <SnippetConfigExtraParams />\n </Provider>\n</template>\n\n<script>\n import { SnippetConfigExtraParams } from '@empathyco/x-components/extra-params';\n\n const Provider = {\n provide: {\n snippetConfig: {\n instance: 'demo',\n lang: 'es',\n warehouse: 1234\n }\n }\n };\n\n export default {\n name: 'SnippetConfigExtraParamsDemo',\n components: {\n Provider,\n SnippetConfigExtraParams\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,5 @@
1
1
  import { __decorate } from 'tslib';
2
+ import { forEach } from '@empathyco/x-utils';
2
3
  import Vue from 'vue';
3
4
  import { Inject, Prop, Watch, Component } from 'vue-property-decorator';
4
5
  import '../../../components/animations/animate-width.vue.js';
@@ -115,8 +116,6 @@ import 'rxjs/operators';
115
116
  import 'vue-class-component';
116
117
  import '../../../components/items-list-injection.mixin.js';
117
118
  import { xComponentMixin } from '../../../components/x-component.mixin.js';
118
- import { forEach } from '../../../utils/object.js';
119
- import '../../../utils/storage.js';
120
119
  import { extraParamsXModule } from '../x-module.js';
121
120
  import __vue_component__ from './extra-params.vue.js';
122
121
 
@@ -1 +1 @@
1
- {"version":3,"file":"snippet-config-extra-params.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../src/x-modules/extra-params/components/snippet-config-extra-params.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\nimport Vue from 'vue';\nimport { Component, Watch, Inject, Prop } from 'vue-property-decorator';\nimport { xComponentMixin } from '../../../components';\nimport { Dictionary, forEach } from '../../../utils';\nimport { SnippetConfig } from '../../../x-installer';\nimport { extraParamsXModule } from '../x-module';\nimport ExtraParams from './extra-params.vue';\n\n/**\n * Extracts the extra parameters from the {@link SnippetConfig} and syncs it with the request\n * objects of every x-module.\n *\n * @public\n */\n@Component({\n components: { ExtraParams },\n mixins: [xComponentMixin(extraParamsXModule)]\n})\nexport default class SnippetConfigExtraParams extends Vue {\n /**\n * It injects {@link SnippetConfig} provided by an ancestor as snippetConfig.\n *\n * @internal\n */\n @Inject('snippetConfig')\n public snippetConfig!: SnippetConfig;\n\n /**\n * A Dictionary where the keys are the extra param names and its values.\n *\n * @public\n */\n @Prop()\n protected values?: Dictionary<unknown>;\n\n /**\n * Custom object containing the extra params from the snippet config.\n *\n * @remarks This object keeps manually the desired snippet config properties to avoid\n * unnecessary re-renders.\n *\n * @internal\n */\n protected extraParams: Dictionary<unknown> = {};\n\n /**\n * Collection of properties from the snippet config not allowed to be sent as extra params.\n *\n * @internal\n */\n protected notAllowedExtraParams: Array<keyof SnippetConfig> = [\n 'callbacks',\n 'productId',\n 'instance',\n 'lang',\n 'searchLang',\n 'consent',\n 'documentDirection',\n 'currency'\n ];\n\n /**\n * Updates the extraParams object when the snippet config changes.\n *\n * @param snippetConfig - The new snippet config.\n *\n * @internal\n */\n @Watch('snippetConfig', { deep: true, immediate: true })\n syncExtraParams(snippetConfig: SnippetConfig): void {\n forEach({ ...this.values, ...snippetConfig }, (name, value) => {\n if (this.notAllowedExtraParams.includes(name)) {\n return;\n }\n this.$set(this.extraParams, name, value);\n });\n }\n}\n"],"names":["ExtraParams"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;;;;;;AAUA,IAAqB,wBAAwB,GAA7C,MAAqB,wBAAyB,SAAQ,GAAG;IAAzD;;;;;;;;;;QAyBY,gBAAW,GAAwB,EAAE,CAAC;;;;;;QAOtC,0BAAqB,GAA+B;YAC5D,WAAW;YACX,WAAW;YACX,UAAU;YACV,MAAM;YACN,YAAY;YACZ,SAAS;YACT,mBAAmB;YACnB,UAAU;SACX,CAAC;KAkBH;;;;;;;;IARC,eAAe,CAAC,aAA4B;QAC1C,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,aAAa,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK;YACxD,IAAI,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAC7C,OAAO;aACR;YACD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;SAC1C,CAAC,CAAC;KACJ;CACF,CAAA;AApDC;IADC,MAAM,CAAC,eAAe,CAAC;+DACa;AAQrC;IADC,IAAI,EAAE;wDACgC;AAoCvC;IADC,KAAK,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;+DAQvD;AA1DkB,wBAAwB;IAJ5C,SAAS,CAAC;QACT,UAAU,EAAE,eAAEA,iBAAW,EAAE;QAC3B,MAAM,EAAE,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;KAC9C,CAAC;GACmB,wBAAwB,CA2D5C;aA3DoB,wBAAwB;;;;"}
1
+ {"version":3,"file":"snippet-config-extra-params.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../src/x-modules/extra-params/components/snippet-config-extra-params.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\nimport { forEach, Dictionary } from '@empathyco/x-utils';\nimport Vue from 'vue';\nimport { Component, Watch, Inject, Prop } from 'vue-property-decorator';\nimport { xComponentMixin } from '../../../components';\nimport { SnippetConfig } from '../../../x-installer';\nimport { extraParamsXModule } from '../x-module';\nimport ExtraParams from './extra-params.vue';\n\n/**\n * Extracts the extra parameters from the {@link SnippetConfig} and syncs it with the request\n * objects of every x-module.\n *\n * @public\n */\n@Component({\n components: { ExtraParams },\n mixins: [xComponentMixin(extraParamsXModule)]\n})\nexport default class SnippetConfigExtraParams extends Vue {\n /**\n * It injects {@link SnippetConfig} provided by an ancestor as snippetConfig.\n *\n * @internal\n */\n @Inject('snippetConfig')\n public snippetConfig!: SnippetConfig;\n\n /**\n * A Dictionary where the keys are the extra param names and its values.\n *\n * @public\n */\n @Prop()\n protected values?: Dictionary<unknown>;\n\n /**\n * Custom object containing the extra params from the snippet config.\n *\n * @remarks This object keeps manually the desired snippet config properties to avoid\n * unnecessary re-renders.\n *\n * @internal\n */\n protected extraParams: Dictionary<unknown> = {};\n\n /**\n * Collection of properties from the snippet config not allowed to be sent as extra params.\n *\n * @internal\n */\n protected notAllowedExtraParams: Array<keyof SnippetConfig> = [\n 'callbacks',\n 'productId',\n 'instance',\n 'lang',\n 'searchLang',\n 'consent',\n 'documentDirection',\n 'currency'\n ];\n\n /**\n * Updates the extraParams object when the snippet config changes.\n *\n * @param snippetConfig - The new snippet config.\n *\n * @internal\n */\n @Watch('snippetConfig', { deep: true, immediate: true })\n syncExtraParams(snippetConfig: SnippetConfig): void {\n forEach({ ...this.values, ...snippetConfig }, (name, value) => {\n if (this.notAllowedExtraParams.includes(name)) {\n return;\n }\n this.$set(this.extraParams, name, value);\n });\n }\n}\n"],"names":["ExtraParams"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;;;;;;AAUA,IAAqB,wBAAwB,GAA7C,MAAqB,wBAAyB,SAAQ,GAAG;IAAzD;;;;;;;;;;QAyBY,gBAAW,GAAwB,EAAE,CAAC;;;;;;QAOtC,0BAAqB,GAA+B;YAC5D,WAAW;YACX,WAAW;YACX,UAAU;YACV,MAAM;YACN,YAAY;YACZ,SAAS;YACT,mBAAmB;YACnB,UAAU;SACX,CAAC;KAkBH;;;;;;;;IARC,eAAe,CAAC,aAA4B;QAC1C,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,aAAa,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK;YACxD,IAAI,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAC7C,OAAO;aACR;YACD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;SAC1C,CAAC,CAAC;KACJ;CACF,CAAA;AApDC;IADC,MAAM,CAAC,eAAe,CAAC;+DACa;AAQrC;IADC,IAAI,EAAE;wDACgC;AAoCvC;IADC,KAAK,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;+DAQvD;AA1DkB,wBAAwB;IAJ5C,SAAS,CAAC;QACT,UAAU,EAAE,eAAEA,iBAAW,EAAE;QAC3B,MAAM,EAAE,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;KAC9C,CAAC;GACmB,wBAAwB,CA2D5C;aA3DoB,wBAAwB;;;;"}
@@ -66,11 +66,11 @@ __vue_render__._withStripped = true;
66
66
  /* style */
67
67
  const __vue_inject_styles__ = function (inject) {
68
68
  if (!inject) return
69
- inject("data-v-49ae9daa_0", { source: ".x-facets-list[data-v-49ae9daa] {\n list-style-type: none;\n}", map: undefined, media: undefined });
69
+ inject("data-v-71111ef5_0", { source: ".x-facets-list[data-v-71111ef5] {\n list-style-type: none;\n}", map: undefined, media: undefined });
70
70
 
71
71
  };
72
72
  /* scoped */
73
- const __vue_scope_id__ = "data-v-49ae9daa";
73
+ const __vue_scope_id__ = "data-v-71111ef5";
74
74
  /* module identifier */
75
75
  const __vue_module_identifier__ = undefined;
76
76
  /* functional template */
@@ -1 +1 @@
1
- {"version":3,"file":"facets.vue.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <component\n :is=\"animation\"\n v-if=\"hasFacets\"\n class=\"x-list x-facets-list\"\n data-test=\"facets\"\n tag=\"ul\"\n >\n <li\n v-for=\"({ facet, slotName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n -->\n <slot\n v-if=\"$scopedSlots[slotName]\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || []\n }\"\n :name=\"slotName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || []\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { Facet } from '@empathyco/x-types';\n import { Component, Prop, Vue } from 'vue-property-decorator';\n import { Getter } from '../../../../components/decorators/store.decorators';\n import { xComponentMixin } from '../../../../components/x-component.mixin';\n import { toKebabCase } from '../../../../utils/string';\n import { map, objectFilter } from '../../../../utils/object';\n import { Dictionary } from '../../../../utils/types';\n import FacetsMixin from '../facets.mixin';\n import { facetsXModule } from '../../x-module';\n\n /**\n * Custom interface to provide a slot name to a Facet.\n *\n * @internal\n */\n interface RenderFacet {\n slotName: string;\n facet: Facet;\n }\n\n /**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @remarks It extends {@link FacetsMixin}.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(facetsXModule)]\n })\n export default class Facets extends FacetsMixin {\n /**\n * Animation component that will be used to animate the facets.\n *\n * @public\n */\n @Prop({ default: 'ul' })\n public animation!: Vue | string;\n\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n *\n * @public\n */\n @Prop()\n public renderableFacets!: string | undefined;\n\n /**\n * Dictionary of facets in the state.\n *\n * @internal\n */\n @Getter('facets', 'facets')\n public facets!: Record<Facet['id'], Facet>;\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n *\n * @internal\n */\n protected get mappedFacets(): Dictionary<RenderFacet> {\n return map(this.facetsToRender, (facetId, facet) => ({\n slotName: toKebabCase(facetId),\n facet\n }));\n }\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n *\n * @internal\n */\n protected get facetsToRender(): Dictionary<Facet> {\n if (!this.renderableFacets) {\n return this.facets;\n } else {\n const excludedRegExp = /^!/;\n const facetIds: string[] = this.renderableFacets.split(',').map(facetId => facetId.trim());\n const included: string[] = [];\n const excluded: string[] = [];\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''));\n } else {\n included.push(facetId);\n }\n });\n\n return this.filterFacetsToRender(included, excluded);\n }\n }\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n * @internal\n */\n protected get hasFacets(): boolean {\n return !!Object.keys(this.facetsToRender).length;\n }\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n *\n * @internal\n */\n private filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0;\n return objectFilter(this.facets, facetKey => {\n const isIncluded = included.includes(String(facetKey));\n const isExcluded = excluded.includes(String(facetKey));\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded;\n });\n }\n }\n</script>\n\n<style lang=\"scss\" scoped>\n .x-facets-list {\n list-style-type: none;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ ${facet.label} }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example. of\nthe `Facets` component using the `FiltersSearch` `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel`.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script>\n import {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter\n } from '@empathyco/x-components/facets';\n\n import { BasePriceFilterLabel } from '@empathyco/x-components';\n\n export default {\n components: {\n Facets,\n MultiSelectFilters,\n FiltersSearch,\n SimpleFilter,\n Filters,\n HierarchicalFilter,\n NumberRangeFilter,\n BasePriceFilterLabel\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"facets.vue.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue"],"sourcesContent":["<template>\n <component\n :is=\"animation\"\n v-if=\"hasFacets\"\n class=\"x-list x-facets-list\"\n data-test=\"facets\"\n tag=\"ul\"\n >\n <li\n v-for=\"({ facet, slotName }, facetId) in mappedFacets\"\n :key=\"facetId\"\n class=\"x-facets-list__item\"\n data-test=\"facets-facet\"\n >\n <!--\n @slot Customized Facet rendering. Specifying a slot with the facet's name will result in the\n facet using that slot composition to render.\n @binding {Facet} facet - Facet to render\n -->\n <slot\n v-if=\"$scopedSlots[slotName]\"\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || []\n }\"\n :name=\"slotName\"\n />\n <!--\n @slot (required) Default Facet rendering. This slot will be used by default for rendering\n the facets without an specific slot implementation.\n @binding {Facet} facet - Facet to render\n -->\n <slot\n v-else\n v-bind=\"{\n facet,\n selectedFilters: selectedFiltersByFacet[facetId] || []\n }\"\n >\n This is the {{ facet.label }} facet. Pass something into its slot to display content.\n </slot>\n </li>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { Facet } from '@empathyco/x-types';\n import { Dictionary, map, objectFilter } from '@empathyco/x-utils';\n import { Component, Prop, Vue } from 'vue-property-decorator';\n import { Getter } from '../../../../components/decorators/store.decorators';\n import { xComponentMixin } from '../../../../components/x-component.mixin';\n import { toKebabCase } from '../../../../utils/string';\n import FacetsMixin from '../facets.mixin';\n import { facetsXModule } from '../../x-module';\n\n /**\n * Custom interface to provide a slot name to a Facet.\n *\n * @internal\n */\n interface RenderFacet {\n slotName: string;\n facet: Facet;\n }\n\n /**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @remarks It extends {@link FacetsMixin}.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(facetsXModule)]\n })\n export default class Facets extends FacetsMixin {\n /**\n * Animation component that will be used to animate the facets.\n *\n * @public\n */\n @Prop({ default: 'ul' })\n public animation!: Vue | string;\n\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n *\n * @public\n */\n @Prop()\n public renderableFacets!: string | undefined;\n\n /**\n * Dictionary of facets in the state.\n *\n * @internal\n */\n @Getter('facets', 'facets')\n public facets!: Record<Facet['id'], Facet>;\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n *\n * @internal\n */\n protected get mappedFacets(): Dictionary<RenderFacet> {\n return map(this.facetsToRender, (facetId, facet) => ({\n slotName: toKebabCase(facetId),\n facet\n }));\n }\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n *\n * @internal\n */\n protected get facetsToRender(): Dictionary<Facet> {\n if (!this.renderableFacets) {\n return this.facets;\n } else {\n const excludedRegExp = /^!/;\n const facetIds: string[] = this.renderableFacets.split(',').map(facetId => facetId.trim());\n const included: string[] = [];\n const excluded: string[] = [];\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''));\n } else {\n included.push(facetId);\n }\n });\n\n return this.filterFacetsToRender(included, excluded);\n }\n }\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n * @internal\n */\n protected get hasFacets(): boolean {\n return !!Object.keys(this.facetsToRender).length;\n }\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n *\n * @internal\n */\n private filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0;\n return objectFilter(this.facets, facetKey => {\n const isIncluded = included.includes(String(facetKey));\n const isExcluded = excluded.includes(String(facetKey));\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded;\n });\n }\n }\n</script>\n\n<style lang=\"scss\" scoped>\n .x-facets-list {\n list-style-type: none;\n }\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThis component renders the list of facets stored in the Facets module. Facets can be rendered\ndifferently based on their purpose and this can be achieved using the exposed slots:\n\n- A default and required slot.\n- A custom slot for each facet with the facetId as its name. This allows each facet to be rendered\n differently based on its needs.\n\nBelow, there are some examples showing how to use the component with its different configurations.\n\n### Default usage\n\nThe default slot of this component is mandatory. If no other slot is defined, every Facet will be\nrendered as specified in the default slot.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ ${facet.label} }}</h1>\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} selected` }}</span>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Customized usage\n\nCustomized compositions for a specific Facet can be achieved by using a slot with the same id as the\nfacet to customize. For example, the Facet with the id \"color\" requires a composition that differs\nfrom the rest of the Facets. Doing it in a slot with the name \"color\" will apply this customization\njust to the \"color\" Facet. The other facets will fallback to the composition of the default slot.\n\n```vue\n<template>\n <Facets>\n <template #color=\"{ facet, selectedFilters }\">\n <span v-if=\"selectedFilters.length > 0\">{{ `${selectedFilters.length} colors chosen` }}</span>\n\n <ul v-for=\"filter in facet.filters\" :key=\"filter.id\">\n <li v-if=\"!filter.selected\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Render specific facets I\n\nBy default, this component will render all existing facets. However, it has the renderableFacets\nprop to filter which facets will be rendered. Its value is a string containing the different facets\nids. This value is treated as an include or exclude list (to exclude a facet from being rendered,\njust prefix its id with a `!`). The component will only render included facets and discard excluded\nones. In the following example, the component will only render color and category facets.\n\n```vue\n<template>\n <Facets renderableFacets=\"color, category\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Render specific facets II\n\nExclude facets so the component does not render them. In the following example, the component will\nrender every facet except color and price.\n\n```vue\n<template>\n <Facets renderableFacets=\"!color, !price\">\n <template #default=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n\n <ul>\n <li v-for=\"filter in facet.filters\" :key=\"filter.id\">\n {{ filter.label }}\n </li>\n </ul>\n </template>\n </Facets>\n</template>\n\n<script>\n import { Facets } from '@empathyco/x-components/facets';\n\n export default {\n components: {\n Facets\n }\n };\n</script>\n```\n\n### Integrating with the filters components\n\nThere are many components that will help you build your own awesome filters list. `Facets` just\nrenders the list, but what to render for each facet is up to you. Below you can see an example. of\nthe `Facets` component using the `FiltersSearch` `MultiSelectFilters`, `SimpleFilter`, `Filters`,\n`HierarchicalFilter`, `NumberRangeFilter` and `BasePriceFilterLabel`.\n\n```vue\n<template>\n <Facets>\n <template #default=\"{ facet, selectedFilters }\">\n <h1>{{ facet.label }}</h1>\n <FiltersSearch :filters=\"facet.filters\">\n <MultiSelectFilters v-slot=\"{ filter }\">\n <SimpleFilter :filter=\"filter\" />\n </MultiSelectFilters>\n </FiltersSearch>\n </template>\n\n <template #category=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <HierarchicalFilter :filter=\"filter\" />\n </Filters>\n </template>\n\n <template #price=\"{ facet }\">\n <h1>{{ facet.label }}</h1>\n <Filters v-slot=\"{ filter }\" :filters=\"facet.filters\">\n <NumberRangeFilter :filter=\"filter\">\n <BasePriceFilterLabel :filter=\"filter\" />\n </NumberRangeFilter>\n </Filters>\n </template>\n </Facets>\n</template>\n\n<script>\n import {\n Facets,\n Filters,\n FiltersSearch,\n HierarchicalFilter,\n MultiSelectFilters,\n NumberRangeFilter,\n SimpleFilter\n } from '@empathyco/x-components/facets';\n\n import { BasePriceFilterLabel } from '@empathyco/x-components';\n\n export default {\n components: {\n Facets,\n MultiSelectFilters,\n FiltersSearch,\n SimpleFilter,\n Filters,\n HierarchicalFilter,\n NumberRangeFilter,\n BasePriceFilterLabel\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,9 +1,9 @@
1
1
  import { __decorate } from 'tslib';
2
+ import { map, objectFilter } from '@empathyco/x-utils';
2
3
  import { Prop, Component } from 'vue-property-decorator';
3
4
  import { Getter } from '../../../../components/decorators/store.decorators.js';
4
5
  import { xComponentMixin } from '../../../../components/x-component.mixin.js';
5
6
  import { toKebabCase } from '../../../../utils/string.js';
6
- import { map, objectFilter } from '../../../../utils/object.js';
7
7
  import FacetsMixin from '../facets.mixin.js';
8
8
  import { facetsXModule } from '../../x-module.js';
9
9
 
@@ -1 +1 @@
1
- {"version":3,"file":"facets.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../../src/x-modules/facets/components/facets/facets.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nimport { Facet } from '@empathyco/x-types';\nimport { Component, Prop, Vue } from 'vue-property-decorator';\nimport { Getter } from '../../../../components/decorators/store.decorators';\nimport { xComponentMixin } from '../../../../components/x-component.mixin';\nimport { toKebabCase } from '../../../../utils/string';\nimport { map, objectFilter } from '../../../../utils/object';\nimport { Dictionary } from '../../../../utils/types';\nimport FacetsMixin from '../facets.mixin';\nimport { facetsXModule } from '../../x-module';\n\n/**\n * Custom interface to provide a slot name to a Facet.\n *\n * @internal\n */\ninterface RenderFacet {\n slotName: string;\n facet: Facet;\n}\n\n/**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @remarks It extends {@link FacetsMixin}.\n *\n * @public\n */\n@Component({\n mixins: [xComponentMixin(facetsXModule)]\n})\nexport default class Facets extends FacetsMixin {\n /**\n * Animation component that will be used to animate the facets.\n *\n * @public\n */\n @Prop({ default: 'ul' })\n public animation!: Vue | string;\n\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n *\n * @public\n */\n @Prop()\n public renderableFacets!: string | undefined;\n\n /**\n * Dictionary of facets in the state.\n *\n * @internal\n */\n @Getter('facets', 'facets')\n public facets!: Record<Facet['id'], Facet>;\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n *\n * @internal\n */\n protected get mappedFacets(): Dictionary<RenderFacet> {\n return map(this.facetsToRender, (facetId, facet) => ({\n slotName: toKebabCase(facetId),\n facet\n }));\n }\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n *\n * @internal\n */\n protected get facetsToRender(): Dictionary<Facet> {\n if (!this.renderableFacets) {\n return this.facets;\n } else {\n const excludedRegExp = /^!/;\n const facetIds: string[] = this.renderableFacets.split(',').map(facetId => facetId.trim());\n const included: string[] = [];\n const excluded: string[] = [];\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''));\n } else {\n included.push(facetId);\n }\n });\n\n return this.filterFacetsToRender(included, excluded);\n }\n }\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n * @internal\n */\n protected get hasFacets(): boolean {\n return !!Object.keys(this.facetsToRender).length;\n }\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n *\n * @internal\n */\n private filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0;\n return objectFilter(this.facets, facetKey => {\n const isIncluded = included.includes(String(facetKey));\n const isExcluded = excluded.includes(String(facetKey));\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded;\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAkEA;;;;;;;;;;;AAcA,IAAqB,MAAM,GAA3B,MAAqB,MAAO,SAAQ,WAAW;;;;;;;;IAgD7C,IAAc,YAAY;QACxB,OAAO,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE,KAAK,MAAM;YACnD,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC;YAC9B,KAAK;SACN,CAAC,CAAC,CAAC;KACL;;;;;;;;;IAUD,IAAc,cAAc;QAC1B,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;YAC1B,OAAO,IAAI,CAAC,MAAM,CAAC;SACpB;aAAM;YACL,MAAM,cAAc,GAAG,IAAI,CAAC;YAC5B,MAAM,QAAQ,GAAa,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAC3F,MAAM,QAAQ,GAAa,EAAE,CAAC;YAC9B,MAAM,QAAQ,GAAa,EAAE,CAAC;YAC9B,QAAQ,CAAC,OAAO,CAAC,OAAO;gBACtB,IAAI,cAAc,CAAC,IAAI,CAAC,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facets/facets.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nimport { Facet } from '@empathyco/x-types';\nimport { Dictionary, map, objectFilter } from '@empathyco/x-utils';\nimport { Component, Prop, Vue } from 'vue-property-decorator';\nimport { Getter } from '../../../../components/decorators/store.decorators';\nimport { xComponentMixin } from '../../../../components/x-component.mixin';\nimport { toKebabCase } from '../../../../utils/string';\nimport FacetsMixin from '../facets.mixin';\nimport { facetsXModule } from '../../x-module';\n\n/**\n * Custom interface to provide a slot name to a Facet.\n *\n * @internal\n */\ninterface RenderFacet {\n slotName: string;\n facet: Facet;\n}\n\n/**\n * This component renders the list of facets stored in the Facets module. Facets can be rendered\n * differently based on their purpose and this can be achieved using the exposed slots:\n * - A default and required slot.\n * - A custom slot for each facet with the facetId as its name. This allows each facet to be\n * rendered differently based on its needs.\n *\n * @remarks It extends {@link FacetsMixin}.\n *\n * @public\n */\n@Component({\n mixins: [xComponentMixin(facetsXModule)]\n})\nexport default class Facets extends FacetsMixin {\n /**\n * Animation component that will be used to animate the facets.\n *\n * @public\n */\n @Prop({ default: 'ul' })\n public animation!: Vue | string;\n\n /**\n * Discriminates the facets rendered by this component. It expects a string containing facets\n * ids, comma separated. This property will include or exclude facets based on its value.\n * The default value is an empty string and the component will render all existing facets.\n *\n * @remarks\n * To behave as a `include`, simply set the facets ids, comma separated:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"brand, category\"`\n *\n * The component will render brand and category facets.\n *\n * On the other hand, to simulate an `exclude` behaviour and exclude a facet from being\n * rendered, append a '!' before its id:\n * `existingFacets=[{ brand: ... }, category: { ... }, color: { ... }, price: { ... }]`\n * `renderableFacets=\"!brand,!price\"`\n *\n * The component will render category and color facets.\n *\n * @public\n */\n @Prop()\n public renderableFacets!: string | undefined;\n\n /**\n * Dictionary of facets in the state.\n *\n * @internal\n */\n @Getter('facets', 'facets')\n public facets!: Record<Facet['id'], Facet>;\n\n /**\n * Transforms a dictionary of Facets including the slot name.\n *\n * @returns A dictionary of facets with the slot name.\n *\n * @internal\n */\n protected get mappedFacets(): Dictionary<RenderFacet> {\n return map(this.facetsToRender, (facetId, facet) => ({\n slotName: toKebabCase(facetId),\n facet\n }));\n }\n\n /**\n * The facets to be rendered after filtering {@link Facets.facets} by\n * {@link Facets.renderableFacets} content.\n *\n * @returns The list of facets to be rendered.\n *\n * @internal\n */\n protected get facetsToRender(): Dictionary<Facet> {\n if (!this.renderableFacets) {\n return this.facets;\n } else {\n const excludedRegExp = /^!/;\n const facetIds: string[] = this.renderableFacets.split(',').map(facetId => facetId.trim());\n const included: string[] = [];\n const excluded: string[] = [];\n facetIds.forEach(facetId => {\n if (excludedRegExp.test(facetId)) {\n excluded.push(facetId.replace(excludedRegExp, ''));\n } else {\n included.push(facetId);\n }\n });\n\n return this.filterFacetsToRender(included, excluded);\n }\n }\n\n /**\n * Indicates if there are facets available to show.\n *\n * @returns True if there are facets available and false otherwise.\n * @internal\n */\n protected get hasFacets(): boolean {\n return !!Object.keys(this.facetsToRender).length;\n }\n\n /**\n * Filter facets dictionary retrieving those included and/or removing excluded.\n *\n * @param included - List of facets to render.\n * @param excluded - List of not renderable facets.\n *\n * @returns The filtered list of facets to render.\n *\n * @internal\n */\n private filterFacetsToRender(included: string[], excluded: string[]): Dictionary<Facet> {\n const hasAnyFacetIncluded = included.length > 0;\n return objectFilter(this.facets, facetKey => {\n const isIncluded = included.includes(String(facetKey));\n const isExcluded = excluded.includes(String(facetKey));\n\n return hasAnyFacetIncluded ? isIncluded && !isExcluded : !isExcluded;\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAiEA;;;;;;;;;;;AAcA,IAAqB,MAAM,GAA3B,MAAqB,MAAO,SAAQ,WAAW;;;;;;;;IAgD7C,IAAc,YAAY;QACxB,OAAO,GA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CAAC,QAAQ,CAAC,CAAC,CAAC;YACvD,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YAEvD,OAAO,mBAAmB,GAAG,UAAU,IAAI,CAAC,UAAU,GAAG,CAAC,UAAU,CAAC;SACtE,CAAC,CAAC;KACJ;CACF,CAAA;AAzGC;IADC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCACQ;AAwBhC;IADC,IAAI,EAAE;gDACsC;AAQ7C;IADC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC;sCACgB;AAvCxB,MAAM;IAH1B,SAAS,CAAC;QACT,MAAM,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;KACzC,CAAC;GACmB,MAAM,CAgH1B;aAhHoB,MAAM;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { isFacetFilter } from '@empathyco/x-types';
2
+ import { map } from '@empathyco/x-utils';
2
3
  import { groupItemsBy } from '../../../../utils/array.js';
3
- import { map } from '../../../../utils/object.js';
4
4
 
5
5
  /**
6
6
  * Default implementation for the {@link FacetsGetters.facets} getter.
@@ -1 +1 @@
1
- {"version":3,"file":"facets.getter.js","sources":["../../../../../../src/x-modules/facets/store/getters/facets.getter.ts"],"sourcesContent":["import { isFacetFilter } from '@empathyco/x-types';\nimport { groupItemsBy } from '../../../../utils/array';\nimport { map } from '../../../../utils/object';\nimport { FacetsXStoreModule } from '../types';\n\n/**\n * Default implementation for the {@link FacetsGetters.facets} getter.\n *\n * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the facets\n * module.\n * @returns An array containing the facets with the filters.\n *\n * @public\n */\nexport const facets: FacetsXStoreModule['getters']['facets'] = state => {\n const filtersByFacet = groupItemsBy(Object.values(state.filters), filter =>\n isFacetFilter(filter) ? filter.facetId : '__unknown-facet__'\n );\n return map(state.facets, (_id, facet) => ({\n ...facet,\n filters: filtersByFacet[facet.id] ?? []\n }));\n};\n"],"names":[],"mappings":";;;;AAKA;;;;;;;;;MASa,MAAM,GAA4C,KAAK;IAClE,MAAM,cAAc,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,IACtE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,GAAG,mBAAmB,CAC7D,CAAC;IACF,OAAO,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,MAAM;QACxC,GAAG,KAAK;QACR,OAAO,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE;KACxC,CAAC,CAAC,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"facets.getter.js","sources":["../../../../../../src/x-modules/facets/store/getters/facets.getter.ts"],"sourcesContent":["import { isFacetFilter } from '@empathyco/x-types';\nimport { map } from '@empathyco/x-utils';\nimport { groupItemsBy } from '../../../../utils/array';\nimport { FacetsXStoreModule } from '../types';\n\n/**\n * Default implementation for the {@link FacetsGetters.facets} getter.\n *\n * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the facets\n * module.\n * @returns An array containing the facets with the filters.\n *\n * @public\n */\nexport const facets: FacetsXStoreModule['getters']['facets'] = state => {\n const filtersByFacet = groupItemsBy(Object.values(state.filters), filter =>\n isFacetFilter(filter) ? filter.facetId : '__unknown-facet__'\n );\n return map(state.facets, (_id, facet) => ({\n ...facet,\n filters: filtersByFacet[facet.id] ?? []\n }));\n};\n"],"names":[],"mappings":";;;;AAKA;;;;;;;;;MASa,MAAM,GAA4C,KAAK;IAClE,MAAM,cAAc,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,IACtE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,GAAG,mBAAmB,CAC7D,CAAC;IACF,OAAO,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,MAAM;QACxC,GAAG,KAAK;QACR,OAAO,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE;KACxC,CAAC,CAAC,CAAC;AACN;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { isFacetFilter } from '@empathyco/x-types';
2
+ import { map } from '@empathyco/x-utils';
2
3
  import { groupItemsBy } from '../../../../utils/array.js';
3
- import { map } from '../../../../utils/object.js';
4
4
 
5
5
  /**
6
6
  * Default implementation for the {@link FacetsGetters.selectedFiltersByFacet} getter.
@@ -1 +1 @@
1
- {"version":3,"file":"selected-filters-by-facet.getter.js","sources":["../../../../../../src/x-modules/facets/store/getters/selected-filters-by-facet.getter.ts"],"sourcesContent":["import { isFacetFilter } from '@empathyco/x-types';\nimport { groupItemsBy } from '../../../../utils/array';\nimport { map } from '../../../../utils/object';\nimport { FacetsXStoreModule, FiltersByFacet } from '../types';\n\n/**\n * Default implementation for the {@link FacetsGetters.selectedFiltersByFacet} getter.\n *\n * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the facets\n * module.\n * @param getters - Current {@link https://vuex.vuejs.org/guide/getters.html | getters} of the\n * facets module.\n *\n * @returns A record containing the selected filters indexed by its facet id.\n * @remarks If there are filters without facet Id (RawFilter), they will be grouped under\n * `__unknown-facet__` key.\n *\n * @public\n */\nexport const selectedFiltersByFacet: FacetsXStoreModule['getters']['selectedFiltersByFacet'] = (\n state,\n getters\n): FiltersByFacet => {\n // The `emptyRecord` is to return an empty array for those facets that haven't selected filters.\n const emptyRecord: FiltersByFacet = map(state.facets, () => []);\n const filtersByFacet = groupItemsBy(getters.selectedFilters, filter =>\n isFacetFilter(filter) ? filter.facetId : '__unknown-facet__'\n );\n return Object.assign(emptyRecord, filtersByFacet);\n};\n"],"names":[],"mappings":";;;;AAKA;;;;;;;;;;;;;;MAca,sBAAsB,GAA4D,CAC7F,KAAK,EACL,OAAO;;IAGP,MAAM,WAAW,GAAmB,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAChE,MAAM,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,eAAe,EAAE,MAAM,IACjE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,GAAG,mBAAmB,CAC7D,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;AACpD;;;;"}
1
+ {"version":3,"file":"selected-filters-by-facet.getter.js","sources":["../../../../../../src/x-modules/facets/store/getters/selected-filters-by-facet.getter.ts"],"sourcesContent":["import { isFacetFilter } from '@empathyco/x-types';\nimport { map } from '@empathyco/x-utils';\nimport { groupItemsBy } from '../../../../utils/array';\nimport { FacetsXStoreModule, FiltersByFacet } from '../types';\n\n/**\n * Default implementation for the {@link FacetsGetters.selectedFiltersByFacet} getter.\n *\n * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the facets\n * module.\n * @param getters - Current {@link https://vuex.vuejs.org/guide/getters.html | getters} of the\n * facets module.\n *\n * @returns A record containing the selected filters indexed by its facet id.\n * @remarks If there are filters without facet Id (RawFilter), they will be grouped under\n * `__unknown-facet__` key.\n *\n * @public\n */\nexport const selectedFiltersByFacet: FacetsXStoreModule['getters']['selectedFiltersByFacet'] = (\n state,\n getters\n): FiltersByFacet => {\n // The `emptyRecord` is to return an empty array for those facets that haven't selected filters.\n const emptyRecord: FiltersByFacet = map(state.facets, () => []);\n const filtersByFacet = groupItemsBy(getters.selectedFilters, filter =>\n isFacetFilter(filter) ? filter.facetId : '__unknown-facet__'\n );\n return Object.assign(emptyRecord, filtersByFacet);\n};\n"],"names":[],"mappings":";;;;AAKA;;;;;;;;;;;;;;MAca,sBAAsB,GAA4D,CAC7F,KAAK,EACL,OAAO;;IAGP,MAAM,WAAW,GAAmB,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAChE,MAAM,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,eAAe,EAAE,MAAM,IACjE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,GAAG,mBAAmB,CAC7D,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;AACpD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-to-top.vue.js","sources":["../../../../../src/x-modules/scroll/components/scroll-to-top.vue"],"sourcesContent":["<template>\n <component :is=\"animation\">\n <BaseEventButton\n v-if=\"isVisible\"\n v-on=\"$listeners\"\n class=\"x-button x-scroll-to-top\"\n data-test=\"scroll-to-top\"\n :events=\"events\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n </component>\n</template>\n\n<script lang=\"ts\">\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { State, xComponentMixin } from '../../../components';\n import BaseEventButton from '../../../components/base-event-button.vue';\n import { NoElement } from '../../../components/no-element';\n import { Dictionary } from '../../../utils';\n import { XEventsTypes } from '../../../wiring';\n import { ScrollComponentState } from '../store';\n import { scrollXModule } from '../x-module';\n import { MainScrollId } from './scroll.const';\n\n /**\n * The `ScrollToTop` component is a button that the user can click to make a container scroll\n * up to its initial position.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(scrollXModule)],\n components: { BaseEventButton }\n })\n export default class ScrollToTop extends Vue {\n /**\n * Animation to use for showing/hiding the button.\n *\n * @public\n */\n @Prop({ default: () => NoElement })\n public animation!: Vue | string;\n\n /**\n * Threshold in pixels from the top to show the button.\n *\n * @public\n */\n @Prop()\n public thresholdPx?: number;\n\n /**\n * Id of the target scroll component.\n *\n * @public\n */\n @Prop({ default: MainScrollId })\n public scrollId!: string;\n\n /**\n * State of all the scroll components in this module.\n *\n * @internal\n */\n // TODO: Directly retrieve the needed data in this computed property\n @State('scroll', 'data')\n public scrollPositionsMap!: Dictionary<ScrollComponentState>;\n\n /**\n * The scroll data retrieved for this component.\n *\n * @returns The scroll data for this component if a valid {@link ScrollToTop.scrollId} has been\n * passed. Otherwise it returns `null`.\n * @internal\n */\n protected get scrollData(): ScrollComponentState {\n return this.scrollId && this.scrollPositionsMap[this.scrollId]\n ? this.scrollPositionsMap[this.scrollId]\n : {\n position: 0,\n direction: 'UP',\n hasReachedStart: false,\n hasAlmostReachedEnd: false,\n hasReachedEnd: false\n };\n }\n\n /**\n * Event that will be emitted when the scroll to top is clicked.\n *\n * @returns The event to be emitted when the scroll to top is clicked. The id as a payload.\n * @internal\n */\n protected get events(): Partial<XEventsTypes> {\n return { UserClickedScrollToTop: this.scrollId };\n }\n\n /**\n * Checks if the thresholdPx prop has been provided and if it is a number.\n *\n * @returns If the thresholdPx is a number or not.\n * @internal\n */\n protected get useThresholdStrategy(): boolean {\n return typeof this.thresholdPx === 'number';\n }\n\n /**\n * Checks if the threshold has been reached in case the threshold strategy is in use.\n *\n * @returns If the scrollTop is bigger than the thresholdPx.\n * @internal\n */\n protected get isThresholdReached(): boolean {\n return this.useThresholdStrategy && this.scrollData.position > this.thresholdPx!;\n }\n\n /**\n * Whether if the button is visible or not depending on the strategy being used.\n *\n * @returns If the button should be visible or not.\n * @internal\n */\n protected get isVisible(): boolean {\n return this.useThresholdStrategy ? this.isThresholdReached : this.hasAlmostReachedScrollEnd;\n }\n\n /**\n * Returns if the scroll has almost reached its end or not.\n *\n * @returns True if the scroll has almost reached the end and the user is still scrolling down.\n * @internal\n */\n protected get hasAlmostReachedScrollEnd(): boolean {\n return this.scrollData.hasAlmostReachedEnd && this.scrollData.direction === 'DOWN';\n }\n }\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\n### Basic example\n\nThe component renders whatever is passed to it in the default slot and scrolls to top the scroll\nwith an id `scrollId`.\n\nIt also receives an optional threshold in pixels. When the threshold is reached from the top, the\ncomponent will be shown once the user scrolls `UP`.\n\nIf this parameter is not provided the button will be visible when the user almost reaches the end of\nthe scroll.\n\n```vue\n<template>\n <div>\n <ScrollToTop scroll-id=\"scrollId\" :threshold-px=\"1000\">\n <span>Scroll to top</span>\n </ScrollToTop>\n </div>\n</template>\n\n<script>\n import { ScrollToTop } from '@empathyco/x-components/scroll';\n\n export default {\n name: 'ScrollToTopTest',\n components: {\n ScrollToTop\n }\n };\n</script>\n```\n\n## Events\n\nA list of events that the component will emit:\n\n- `UserClickedScrollToTop`: the event is emitted after the user clicks the button. The event payload\n is the id of the scroll that it going to be scrolled.\n</docs>\n"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"scroll-to-top.vue.js","sources":["../../../../../src/x-modules/scroll/components/scroll-to-top.vue"],"sourcesContent":["<template>\n <component :is=\"animation\">\n <BaseEventButton\n v-if=\"isVisible\"\n v-on=\"$listeners\"\n class=\"x-button x-scroll-to-top\"\n data-test=\"scroll-to-top\"\n :events=\"events\"\n >\n <!-- @slot (Required) Button content with a text, an icon or both -->\n <slot />\n </BaseEventButton>\n </component>\n</template>\n\n<script lang=\"ts\">\n import { Dictionary } from '@empathyco/x-utils';\n import Vue from 'vue';\n import { Component, Prop } from 'vue-property-decorator';\n import { State, xComponentMixin } from '../../../components';\n import BaseEventButton from '../../../components/base-event-button.vue';\n import { NoElement } from '../../../components/no-element';\n import { XEventsTypes } from '../../../wiring';\n import { ScrollComponentState } from '../store';\n import { scrollXModule } from '../x-module';\n import { MainScrollId } from './scroll.const';\n\n /**\n * The `ScrollToTop` component is a button that the user can click to make a container scroll\n * up to its initial position.\n *\n * @public\n */\n @Component({\n mixins: [xComponentMixin(scrollXModule)],\n components: { BaseEventButton }\n })\n export default class ScrollToTop extends Vue {\n /**\n * Animation to use for showing/hiding the button.\n *\n * @public\n */\n @Prop({ default: () => NoElement })\n public animation!: Vue | string;\n\n /**\n * Threshold in pixels from the top to show the button.\n *\n * @public\n */\n @Prop()\n public thresholdPx?: number;\n\n /**\n * Id of the target scroll component.\n *\n * @public\n */\n @Prop({ default: MainScrollId })\n public scrollId!: string;\n\n /**\n * State of all the scroll components in this module.\n *\n * @internal\n */\n // TODO: Directly retrieve the needed data in this computed property\n @State('scroll', 'data')\n public scrollPositionsMap!: Dictionary<ScrollComponentState>;\n\n /**\n * The scroll data retrieved for this component.\n *\n * @returns The scroll data for this component if a valid {@link ScrollToTop.scrollId} has been\n * passed. Otherwise it returns `null`.\n * @internal\n */\n protected get scrollData(): ScrollComponentState {\n return this.scrollId && this.scrollPositionsMap[this.scrollId]\n ? this.scrollPositionsMap[this.scrollId]\n : {\n position: 0,\n direction: 'UP',\n hasReachedStart: false,\n hasAlmostReachedEnd: false,\n hasReachedEnd: false\n };\n }\n\n /**\n * Event that will be emitted when the scroll to top is clicked.\n *\n * @returns The event to be emitted when the scroll to top is clicked. The id as a payload.\n * @internal\n */\n protected get events(): Partial<XEventsTypes> {\n return { UserClickedScrollToTop: this.scrollId };\n }\n\n /**\n * Checks if the thresholdPx prop has been provided and if it is a number.\n *\n * @returns If the thresholdPx is a number or not.\n * @internal\n */\n protected get useThresholdStrategy(): boolean {\n return typeof this.thresholdPx === 'number';\n }\n\n /**\n * Checks if the threshold has been reached in case the threshold strategy is in use.\n *\n * @returns If the scrollTop is bigger than the thresholdPx.\n * @internal\n */\n protected get isThresholdReached(): boolean {\n return this.useThresholdStrategy && this.scrollData.position > this.thresholdPx!;\n }\n\n /**\n * Whether if the button is visible or not depending on the strategy being used.\n *\n * @returns If the button should be visible or not.\n * @internal\n */\n protected get isVisible(): boolean {\n return this.useThresholdStrategy ? this.isThresholdReached : this.hasAlmostReachedScrollEnd;\n }\n\n /**\n * Returns if the scroll has almost reached its end or not.\n *\n * @returns True if the scroll has almost reached the end and the user is still scrolling down.\n * @internal\n */\n protected get hasAlmostReachedScrollEnd(): boolean {\n return this.scrollData.hasAlmostReachedEnd && this.scrollData.direction === 'DOWN';\n }\n }\n</script>\n\n<docs lang=\"mdx\">\n## Examples\n\n### Basic example\n\nThe component renders whatever is passed to it in the default slot and scrolls to top the scroll\nwith an id `scrollId`.\n\nIt also receives an optional threshold in pixels. When the threshold is reached from the top, the\ncomponent will be shown once the user scrolls `UP`.\n\nIf this parameter is not provided the button will be visible when the user almost reaches the end of\nthe scroll.\n\n```vue\n<template>\n <div>\n <ScrollToTop scroll-id=\"scrollId\" :threshold-px=\"1000\">\n <span>Scroll to top</span>\n </ScrollToTop>\n </div>\n</template>\n\n<script>\n import { ScrollToTop } from '@empathyco/x-components/scroll';\n\n export default {\n name: 'ScrollToTopTest',\n components: {\n ScrollToTop\n }\n };\n</script>\n```\n\n## Events\n\nA list of events that the component will emit:\n\n- `UserClickedScrollToTop`: the event is emitted after the user clicks the button. The event payload\n is the id of the scroll that it going to be scrolled.\n</docs>\n"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-to-top.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../src/x-modules/scroll/components/scroll-to-top.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nimport Vue from 'vue';\nimport { Component, Prop } from 'vue-property-decorator';\nimport { State, xComponentMixin } from '../../../components';\nimport BaseEventButton from '../../../components/base-event-button.vue';\nimport { NoElement } from '../../../components/no-element';\nimport { Dictionary } from '../../../utils';\nimport { XEventsTypes } from '../../../wiring';\nimport { ScrollComponentState } from '../store';\nimport { scrollXModule } from '../x-module';\nimport { MainScrollId } from './scroll.const';\n\n/**\n * The `ScrollToTop` component is a button that the user can click to make a container scroll\n * up to its initial position.\n *\n * @public\n */\n@Component({\n mixins: [xComponentMixin(scrollXModule)],\n components: { BaseEventButton }\n})\nexport default class ScrollToTop extends Vue {\n /**\n * Animation to use for showing/hiding the button.\n *\n * @public\n */\n @Prop({ default: () => NoElement })\n public animation!: Vue | string;\n\n /**\n * Threshold in pixels from the top to show the button.\n *\n * @public\n */\n @Prop()\n public thresholdPx?: number;\n\n /**\n * Id of the target scroll component.\n *\n * @public\n */\n @Prop({ default: MainScrollId })\n public scrollId!: string;\n\n /**\n * State of all the scroll components in this module.\n *\n * @internal\n */\n // TODO: Directly retrieve the needed data in this computed property\n @State('scroll', 'data')\n public scrollPositionsMap!: Dictionary<ScrollComponentState>;\n\n /**\n * The scroll data retrieved for this component.\n *\n * @returns The scroll data for this component if a valid {@link ScrollToTop.scrollId} has been\n * passed. Otherwise it returns `null`.\n * @internal\n */\n protected get scrollData(): ScrollComponentState {\n return this.scrollId && this.scrollPositionsMap[this.scrollId]\n ? this.scrollPositionsMap[this.scrollId]\n : {\n position: 0,\n direction: 'UP',\n hasReachedStart: false,\n hasAlmostReachedEnd: false,\n hasReachedEnd: false\n };\n }\n\n /**\n * Event that will be emitted when the scroll to top is clicked.\n *\n * @returns The event to be emitted when the scroll to top is clicked. The id as a payload.\n * @internal\n */\n protected get events(): Partial<XEventsTypes> {\n return { UserClickedScrollToTop: this.scrollId };\n }\n\n /**\n * Checks if the thresholdPx prop has been provided and if it is a number.\n *\n * @returns If the thresholdPx is a number or not.\n * @internal\n */\n protected get useThresholdStrategy(): boolean {\n return typeof this.thresholdPx === 'number';\n }\n\n /**\n * Checks if the threshold has been reached in case the threshold strategy is in use.\n *\n * @returns If the scrollTop is bigger than the thresholdPx.\n * @internal\n */\n protected get isThresholdReached(): boolean {\n return this.useThresholdStrategy && this.scrollData.position > this.thresholdPx!;\n }\n\n /**\n * Whether if the button is visible or not depending on the strategy being used.\n *\n * @returns If the button should be visible or not.\n * @internal\n */\n protected get isVisible(): boolean {\n return this.useThresholdStrategy ? this.isThresholdReached : this.hasAlmostReachedScrollEnd;\n }\n\n /**\n * Returns if the scroll has almost reached its end or not.\n *\n * @returns True if the scroll has almost reached the end and the user is still scrolling down.\n * @internal\n */\n protected get hasAlmostReachedScrollEnd(): boolean {\n return this.scrollData.hasAlmostReachedEnd &&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S,EAAE,CAAC;8CACH;AAQhC;IADC,IAAI,EAAE;gDACqB;AAQ5B;IADC,IAAI,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;6CACP;AASzB;IADC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;uDACqC;AAhC1C,WAAW;IAJ/B,SAAS,CAAC;QACT,MAAM,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;QACxC,UAAU,EAAE,mBAAEA,iBAAe,EAAE;KAChC,CAAC;GACmB,WAAW,CAsG/B;aAtGoB,WAAW;;;;"}
1
+ {"version":3,"file":"scroll-to-top.vue_rollup-plugin-vue_script.vue.js","sources":["../../../../../src/x-modules/scroll/components/scroll-to-top.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nimport { Dictionary } from '@empathyco/x-utils';\nimport Vue from 'vue';\nimport { Component, Prop } from 'vue-property-decorator';\nimport { State, xComponentMixin } from '../../../components';\nimport BaseEventButton from '../../../components/base-event-button.vue';\nimport { NoElement } from '../../../components/no-element';\nimport { XEventsTypes } from '../../../wiring';\nimport { ScrollComponentState } from '../store';\nimport { scrollXModule } from '../x-module';\nimport { MainScrollId } from './scroll.const';\n\n/**\n * The `ScrollToTop` component is a button that the user can click to make a container scroll\n * up to its initial position.\n *\n * @public\n */\n@Component({\n mixins: [xComponentMixin(scrollXModule)],\n components: { BaseEventButton }\n})\nexport default class ScrollToTop extends Vue {\n /**\n * Animation to use for showing/hiding the button.\n *\n * @public\n */\n @Prop({ default: () => NoElement })\n public animation!: Vue | string;\n\n /**\n * Threshold in pixels from the top to show the button.\n *\n * @public\n */\n @Prop()\n public thresholdPx?: number;\n\n /**\n * Id of the target scroll component.\n *\n * @public\n */\n @Prop({ default: MainScrollId })\n public scrollId!: string;\n\n /**\n * State of all the scroll components in this module.\n *\n * @internal\n */\n // TODO: Directly retrieve the needed data in this computed property\n @State('scroll', 'data')\n public scrollPositionsMap!: Dictionary<ScrollComponentState>;\n\n /**\n * The scroll data retrieved for this component.\n *\n * @returns The scroll data for this component if a valid {@link ScrollToTop.scrollId} has been\n * passed. Otherwise it returns `null`.\n * @internal\n */\n protected get scrollData(): ScrollComponentState {\n return this.scrollId && this.scrollPositionsMap[this.scrollId]\n ? this.scrollPositionsMap[this.scrollId]\n : {\n position: 0,\n direction: 'UP',\n hasReachedStart: false,\n hasAlmostReachedEnd: false,\n hasReachedEnd: false\n };\n }\n\n /**\n * Event that will be emitted when the scroll to top is clicked.\n *\n * @returns The event to be emitted when the scroll to top is clicked. The id as a payload.\n * @internal\n */\n protected get events(): Partial<XEventsTypes> {\n return { UserClickedScrollToTop: this.scrollId };\n }\n\n /**\n * Checks if the thresholdPx prop has been provided and if it is a number.\n *\n * @returns If the thresholdPx is a number or not.\n * @internal\n */\n protected get useThresholdStrategy(): boolean {\n return typeof this.thresholdPx === 'number';\n }\n\n /**\n * Checks if the threshold has been reached in case the threshold strategy is in use.\n *\n * @returns If the scrollTop is bigger than the thresholdPx.\n * @internal\n */\n protected get isThresholdReached(): boolean {\n return this.useThresholdStrategy && this.scrollData.position > this.thresholdPx!;\n }\n\n /**\n * Whether if the button is visible or not depending on the strategy being used.\n *\n * @returns If the button should be visible or not.\n * @internal\n */\n protected get isVisible(): boolean {\n return this.useThresholdStrategy ? this.isThresholdReached : this.hasAlmostReachedScrollEnd;\n }\n\n /**\n * Returns if the scroll has almost reached its end or not.\n *\n * @returns True if the scroll has almost reached the end and the user is still scrolling down.\n * @internal\n */\n protected get hasAlmostReachedScrollEnd(): boolean {\n return this.scrollData.hasAlmostReachedEnd && this.scrollData.direction === 'DOWN';\n }\n}\n"],"names":["BaseEventButton"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA;;;;;;AAUA,IAAqB,WAAW,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eAAe,CAAC,aAAa,CAAC,CAAC;QACxC,UAAU,EAAE,mBAAEA,iBAAe,EAAE;KAChC,CAAC;GACmB,WAAW,CAsG/B;aAtGoB,WAAW;;;;"}
@@ -1,5 +1,5 @@
1
+ import { getNewAndUpdatedKeys } from '@empathyco/x-utils';
1
2
  import { isArrayEmpty } from '../../../../utils/array.js';
2
- import { getNewAndUpdatedKeys } from '../../../../utils/object.js';
3
3
 
4
4
  /**
5
5
  * Default implementation for the {@link SearchActions.resetState}.
@@ -1 +1 @@
1
- {"version":3,"file":"reset-state.action.js","sources":["../../../../../../src/x-modules/search/store/actions/reset-state.action.ts"],"sourcesContent":["import { isArrayEmpty } from '../../../../utils/array';\nimport { getNewAndUpdatedKeys } from '../../../../utils/object';\nimport { SearchXStoreModule } from '../types';\n\n/**\n * Default implementation for the {@link SearchActions.resetState}.\n *\n * @param context - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the actions,\n * provided by Vuex.\n *\n * @public\n */\nexport const resetState: SearchXStoreModule['actions']['resetState'] = (\n { commit, state },\n { newRequest, oldRequest }\n) => {\n const changedKeys = getNewAndUpdatedKeys(newRequest, oldRequest);\n\n if (!isArrayEmpty(changedKeys)) {\n if (!changedKeys.includes('page')) {\n commit('setPage', 1);\n }\n if (changedKeys.includes('query')) {\n commit('setSort', '');\n }\n\n const haveExtraParamsChanged = changedKeys.some(key => key in state.params);\n if (haveExtraParamsChanged) {\n commit('setPage', 1);\n commit('setSort', '');\n }\n }\n};\n"],"names":[],"mappings":";;;AAIA;;;;;;;;MAQa,UAAU,GAAgD,CACrE,EAAE,MAAM,EAAE,KAAK,EAAE,EACjB,EAAE,UAAU,EAAE,UAAU,EAAE;IAE1B,MAAM,WAAW,GAAG,oBAAoB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAEjE,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE;QAC9B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACjC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;SACtB;QACD,IAAI,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YACjC,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;SACvB;QAED,MAAM,sBAAsB,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5E,IAAI,sBAAsB,EAAE;YAC1B,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YACrB,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;SACvB;KACF;AACH;;;;"}
1
+ {"version":3,"file":"reset-state.action.js","sources":["../../../../../../src/x-modules/search/store/actions/reset-state.action.ts"],"sourcesContent":["import { getNewAndUpdatedKeys } from '@empathyco/x-utils';\nimport { isArrayEmpty } from '../../../../utils/array';\nimport { SearchXStoreModule } from '../types';\n\n/**\n * Default implementation for the {@link SearchActions.resetState}.\n *\n * @param context - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the actions,\n * provided by Vuex.\n *\n * @public\n */\nexport const resetState: SearchXStoreModule['actions']['resetState'] = (\n { commit, state },\n { newRequest, oldRequest }\n) => {\n const changedKeys = getNewAndUpdatedKeys(newRequest, oldRequest);\n\n if (!isArrayEmpty(changedKeys)) {\n if (!changedKeys.includes('page')) {\n commit('setPage', 1);\n }\n if (changedKeys.includes('query')) {\n commit('setSort', '');\n }\n\n const haveExtraParamsChanged = changedKeys.some(key => key in state.params);\n if (haveExtraParamsChanged) {\n commit('setPage', 1);\n commit('setSort', '');\n }\n }\n};\n"],"names":[],"mappings":";;;AAIA;;;;;;;;MAQa,UAAU,GAAgD,CACrE,EAAE,MAAM,EAAE,KAAK,EAAE,EACjB,EAAE,UAAU,EAAE,UAAU,EAAE;IAE1B,MAAM,WAAW,GAAG,oBAAoB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAEjE,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE;QAC9B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACjC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;SACtB;QACD,IAAI,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YACjC,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;SACvB;QAED,MAAM,sBAAsB,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5E,IAAI,sBAAsB,EAAE;YAC1B,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YACrB,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;SACvB;KACF;AACH;;;;"}