@empathyco/x-components 3.0.0-alpha.64 → 3.0.0-alpha.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/core/index.js.map +1 -1
- package/design-system/default-theme.css +40 -40
- package/design-system/full-theme.css +37 -36
- package/docs/API-reference/api/x-adapter.empathyqueryablerequestmapper.map.md +2 -2
- package/docs/API-reference/api/x-adapter.empathyqueryablerequestmapper.md +1 -1
- package/docs/API-reference/api/x-adapter.md +0 -1
- package/docs/API-reference/api/x-adapter.queryablerequest.md +0 -1
- package/docs/API-reference/api/x-components.arraytoobject_1.md +2 -2
- package/docs/API-reference/api/x-components.deepfilter.md +8 -6
- package/docs/API-reference/api/x-components.deepflat.md +8 -6
- package/docs/API-reference/api/x-components.historyqueriesmutations.md +2 -1
- package/docs/API-reference/api/x-components.historyqueriesstate.md +2 -1
- package/docs/API-reference/api/x-components.identifierresultsmutations.md +2 -2
- package/docs/API-reference/api/x-components.identifierresultsstate.md +2 -2
- package/docs/API-reference/api/x-components.md +6 -3
- package/docs/API-reference/api/x-components.nextqueriesmutations.md +2 -2
- package/docs/API-reference/api/x-components.nextqueriesstate.md +2 -2
- package/docs/API-reference/api/x-components.propswithtype.md +6 -7
- package/docs/API-reference/api/x-components.querysuggestionsmutations.md +2 -2
- package/docs/API-reference/api/x-components.querysuggestionsstate.md +2 -2
- package/docs/API-reference/api/x-components.relatedtagsgetters.md +1 -0
- package/docs/API-reference/api/x-components.relatedtagsgetters.query.md +13 -0
- package/docs/API-reference/api/x-components.relatedtagsmutations.md +2 -3
- package/docs/API-reference/api/x-components.relatedtagsquery.md +13 -0
- package/docs/API-reference/api/x-components.relatedtagsstate.md +2 -3
- package/docs/API-reference/api/x-components.searchboxmutations.md +2 -1
- package/docs/API-reference/api/x-components.searchboxstate.md +2 -1
- package/docs/API-reference/api/x-components.searchgetters.md +1 -0
- package/docs/API-reference/api/x-components.searchgetters.query.md +13 -0
- package/docs/API-reference/api/x-components.searchmutations.md +2 -2
- package/docs/API-reference/api/x-components.searchquery.md +13 -0
- package/docs/API-reference/api/x-components.searchstate.md +2 -2
- package/docs/API-reference/api/x-components.subobject.md +29 -0
- package/docs/API-reference/api/x-components.urlmutations.md +2 -1
- package/docs/API-reference/api/x-components.urlstate.initialextraparams.md +11 -0
- package/docs/API-reference/api/x-components.urlstate.md +9 -5
- package/docs/API-reference/api/x-components.wireservice.md +1 -1
- package/docs/API-reference/api/x-components.wireservicewithoutpayload.md +1 -1
- package/docs/API-reference/api/x-components.wiring.md +1 -1
- package/docs/API-reference/api/x-types.relatedtag.md +0 -2
- package/js/index.js +2 -0
- package/js/index.js.map +1 -1
- package/js/store/utils/query.utils.js +37 -0
- package/js/store/utils/query.utils.js.map +1 -0
- package/js/utils/array.js +25 -55
- package/js/utils/array.js.map +1 -1
- package/js/wiring/wires.factory.js.map +1 -1
- package/js/x-modules/history-queries/store/module.js +2 -3
- package/js/x-modules/history-queries/store/module.js.map +1 -1
- package/js/x-modules/identifier-results/store/module.js +2 -3
- package/js/x-modules/identifier-results/store/module.js.map +1 -1
- package/js/x-modules/next-queries/store/module.js +2 -3
- package/js/x-modules/next-queries/store/module.js.map +1 -1
- package/js/x-modules/query-suggestions/store/module.js +2 -3
- package/js/x-modules/query-suggestions/store/module.js.map +1 -1
- package/js/x-modules/related-tags/store/actions/set-url-params.action.js +1 -3
- package/js/x-modules/related-tags/store/actions/set-url-params.action.js.map +1 -1
- package/js/x-modules/related-tags/store/getters/query.getter.js +18 -0
- package/js/x-modules/related-tags/store/getters/query.getter.js.map +1 -0
- package/js/x-modules/related-tags/store/getters/request.getter.js +3 -2
- package/js/x-modules/related-tags/store/getters/request.getter.js.map +1 -1
- package/js/x-modules/related-tags/store/module.js +5 -4
- package/js/x-modules/related-tags/store/module.js.map +1 -1
- package/js/x-modules/scroll/components/window-scroll.vue.js.map +1 -1
- package/js/x-modules/scroll/components/window-scroll.vue_rollup-plugin-vue_script.vue.js +0 -2
- package/js/x-modules/scroll/components/window-scroll.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/search/store/getters/query.getter.js +18 -0
- package/js/x-modules/search/store/getters/query.getter.js.map +1 -0
- package/js/x-modules/search/store/getters/request.getter.js +2 -3
- package/js/x-modules/search/store/getters/request.getter.js.map +1 -1
- package/js/x-modules/search/store/module.js +5 -4
- package/js/x-modules/search/store/module.js.map +1 -1
- package/js/x-modules/search-box/store/module.js +2 -3
- package/js/x-modules/search-box/store/module.js.map +1 -1
- package/js/x-modules/url/store/module.js +2 -3
- package/js/x-modules/url/store/module.js.map +1 -1
- package/package.json +10 -10
- package/related-tags/index.js +1 -0
- package/report/tsdoc-metadata.json +1 -1
- package/report/x-adapter.api.json +3 -134
- package/report/x-components.api.json +672 -284
- package/report/x-components.api.md +51 -33
- package/report/x-types.api.json +1 -53
- package/search/index.js +1 -0
- package/types/store/utils/query.utils.d.ts +56 -0
- package/types/store/utils/query.utils.d.ts.map +1 -0
- package/types/utils/array.d.ts +19 -17
- package/types/utils/array.d.ts.map +1 -1
- package/types/utils/types.d.ts +27 -9
- package/types/utils/types.d.ts.map +1 -1
- package/types/wiring/wires.factory.d.ts +3 -2
- package/types/wiring/wires.factory.d.ts.map +1 -1
- package/types/wiring/wiring.types.d.ts +8 -7
- package/types/wiring/wiring.types.d.ts.map +1 -1
- package/types/x-modules/history-queries/store/module.d.ts.map +1 -1
- package/types/x-modules/history-queries/store/types.d.ts +3 -2
- package/types/x-modules/history-queries/store/types.d.ts.map +1 -1
- package/types/x-modules/identifier-results/store/module.d.ts.map +1 -1
- package/types/x-modules/identifier-results/store/types.d.ts +3 -2
- package/types/x-modules/identifier-results/store/types.d.ts.map +1 -1
- package/types/x-modules/next-queries/store/module.d.ts.map +1 -1
- package/types/x-modules/next-queries/store/types.d.ts +3 -2
- package/types/x-modules/next-queries/store/types.d.ts.map +1 -1
- package/types/x-modules/query-suggestions/store/module.d.ts.map +1 -1
- package/types/x-modules/query-suggestions/store/types.d.ts +3 -2
- package/types/x-modules/query-suggestions/store/types.d.ts.map +1 -1
- package/types/x-modules/related-tags/store/actions/set-url-params.action.d.ts.map +1 -1
- package/types/x-modules/related-tags/store/getters/query.getter.d.ts +13 -0
- package/types/x-modules/related-tags/store/getters/query.getter.d.ts.map +1 -0
- package/types/x-modules/related-tags/store/getters/request.getter.d.ts +2 -0
- package/types/x-modules/related-tags/store/getters/request.getter.d.ts.map +1 -1
- package/types/x-modules/related-tags/store/index.d.ts +1 -0
- package/types/x-modules/related-tags/store/index.d.ts.map +1 -1
- package/types/x-modules/related-tags/store/module.d.ts.map +1 -1
- package/types/x-modules/related-tags/store/types.d.ts +5 -10
- package/types/x-modules/related-tags/store/types.d.ts.map +1 -1
- package/types/x-modules/scroll/components/window-scroll.vue.d.ts.map +1 -1
- package/types/x-modules/search/store/getters/query.getter.d.ts +13 -0
- package/types/x-modules/search/store/getters/query.getter.d.ts.map +1 -0
- package/types/x-modules/search/store/getters/request.getter.d.ts.map +1 -1
- package/types/x-modules/search/store/index.d.ts +1 -0
- package/types/x-modules/search/store/index.d.ts.map +1 -1
- package/types/x-modules/search/store/module.d.ts.map +1 -1
- package/types/x-modules/search/store/types.d.ts +5 -2
- package/types/x-modules/search/store/types.d.ts.map +1 -1
- package/types/x-modules/search-box/store/module.d.ts.map +1 -1
- package/types/x-modules/search-box/store/types.d.ts +3 -2
- package/types/x-modules/search-box/store/types.d.ts.map +1 -1
- package/types/x-modules/url/store/module.d.ts.map +1 -1
- package/types/x-modules/url/store/types.d.ts +4 -3
- package/types/x-modules/url/store/types.d.ts.map +1 -1
- package/docs/API-reference/api/x-adapter.empathyrequestrelatedtagsquerymapper.map.md +0 -23
- package/docs/API-reference/api/x-adapter.empathyrequestrelatedtagsquerymapper.md +0 -21
- package/docs/API-reference/api/x-adapter.queryablerequest.relatedtags.md +0 -11
- package/docs/API-reference/api/x-components.relatedtagsmutations.setquery.md +0 -24
- package/docs/API-reference/api/x-components.relatedtagsstate.query.md +0 -13
- package/docs/API-reference/api/x-types.relatedtag.previous.md +0 -13
- package/docs/API-reference/api/x-types.relatedtag.selected.md +0 -13
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [relatedTagsQuery](./x-components.relatedtagsquery.md)
|
|
4
|
+
|
|
5
|
+
## relatedTagsQuery variable
|
|
6
|
+
|
|
7
|
+
Default implementation for the [RelatedTagsGetters.query](./x-components.relatedtagsgetters.query.md) getter.
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
query: RelatedTagsXStoreModule['getters']['query']
|
|
13
|
+
```
|
|
@@ -9,9 +9,9 @@ RelatedTags store state.
|
|
|
9
9
|
<b>Signature:</b>
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export interface RelatedTagsState extends StatusState
|
|
12
|
+
export interface RelatedTagsState extends StatusState, QueryState
|
|
13
13
|
```
|
|
14
|
-
<b>Extends:</b> [StatusState](./x-components.statusstate.md)
|
|
14
|
+
<b>Extends:</b> [StatusState](./x-components.statusstate.md)<!-- -->, QueryState
|
|
15
15
|
|
|
16
16
|
## Properties
|
|
17
17
|
|
|
@@ -19,7 +19,6 @@ export interface RelatedTagsState extends StatusState
|
|
|
19
19
|
| --- | --- | --- |
|
|
20
20
|
| [config](./x-components.relatedtagsstate.config.md) | [RelatedTagsConfig](./x-components.relatedtagsconfig.md) | The configuration of the related tags module. |
|
|
21
21
|
| [params](./x-components.relatedtagsstate.params.md) | [Dictionary](./x-components.dictionary.md)<!-- --><unknown> | The extra params property of the state. |
|
|
22
|
-
| [query](./x-components.relatedtagsstate.query.md) | string | The internal query of the module. Used to request the related tags. |
|
|
23
22
|
| [relatedTags](./x-components.relatedtagsstate.relatedtags.md) | RelatedTag\[\] | The list of the related tags, related to the <code>query</code> property of the state. |
|
|
24
23
|
| [selectedRelatedTags](./x-components.relatedtagsstate.selectedrelatedtags.md) | RelatedTag\[\] | The list of the selected related tags. |
|
|
25
24
|
|
|
@@ -16,5 +16,6 @@ export interface SearchGetters
|
|
|
16
16
|
|
|
17
17
|
| Property | Type | Description |
|
|
18
18
|
| --- | --- | --- |
|
|
19
|
+
| [query](./x-components.searchgetters.query.md) | string | The combination of the query and the selected related tags. |
|
|
19
20
|
| [request](./x-components.searchgetters.request.md) | [InternalSearchRequest](./x-components.internalsearchrequest.md) \| null | The adapter request object for retrieving the results, or null if there is not valid data to create a request. |
|
|
20
21
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [SearchGetters](./x-components.searchgetters.md) > [query](./x-components.searchgetters.query.md)
|
|
4
|
+
|
|
5
|
+
## SearchGetters.query property
|
|
6
|
+
|
|
7
|
+
The combination of the query and the selected related tags.
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
query: string;
|
|
13
|
+
```
|
|
@@ -9,9 +9,9 @@ Search store mutations.
|
|
|
9
9
|
<b>Signature:</b>
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export interface SearchMutations extends StatusMutations
|
|
12
|
+
export interface SearchMutations extends StatusMutations, QueryMutations
|
|
13
13
|
```
|
|
14
|
-
<b>Extends:</b> [StatusMutations](./x-components.statusmutations.md)
|
|
14
|
+
<b>Extends:</b> [StatusMutations](./x-components.statusmutations.md)<!-- -->, QueryMutations
|
|
15
15
|
|
|
16
16
|
## Methods
|
|
17
17
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [searchQuery](./x-components.searchquery.md)
|
|
4
|
+
|
|
5
|
+
## searchQuery variable
|
|
6
|
+
|
|
7
|
+
Default implementation for the [SearchState.query](./x-components.searchstate.query.md) getter.
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
query: SearchXStoreModule['getters']['query']
|
|
13
|
+
```
|
|
@@ -9,9 +9,9 @@ Search store state.
|
|
|
9
9
|
<b>Signature:</b>
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export interface SearchState extends StatusState
|
|
12
|
+
export interface SearchState extends StatusState, QueryState
|
|
13
13
|
```
|
|
14
|
-
<b>Extends:</b> [StatusState](./x-components.statusstate.md)
|
|
14
|
+
<b>Extends:</b> [StatusState](./x-components.statusstate.md)<!-- -->, QueryState
|
|
15
15
|
|
|
16
16
|
## Properties
|
|
17
17
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [SubObject](./x-components.subobject.md)
|
|
4
|
+
|
|
5
|
+
## SubObject type
|
|
6
|
+
|
|
7
|
+
Extracts a sub-type with the properties of `SomeObject` that have the `TargetPropertyType` type.
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export declare type SubObject<SomeObject, TargetPropertyType> = {
|
|
13
|
+
[Key in keyof SomeObject as SomeObject[Key] extends TargetPropertyType ? Key : never]: TargetPropertyType & SomeObject[Key];
|
|
14
|
+
};
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Example
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
interface Person {
|
|
22
|
+
name: string,
|
|
23
|
+
surname: string,
|
|
24
|
+
age: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type StringPersonProperties = SubObject<Person, string>; // { name: string; surname: string; };
|
|
28
|
+
```
|
|
29
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [UrlState](./x-components.urlstate.md) > [initialExtraParams](./x-components.urlstate.initialextraparams.md)
|
|
4
|
+
|
|
5
|
+
## UrlState.initialExtraParams property
|
|
6
|
+
|
|
7
|
+
<b>Signature:</b>
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
initialExtraParams: Dictionary<unknown>;
|
|
11
|
+
```
|
|
@@ -2,16 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [UrlState](./x-components.urlstate.md)
|
|
4
4
|
|
|
5
|
-
## UrlState
|
|
5
|
+
## UrlState interface
|
|
6
6
|
|
|
7
7
|
URL store state.
|
|
8
8
|
|
|
9
9
|
<b>Signature:</b>
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export
|
|
13
|
-
initialExtraParams: Dictionary<unknown>;
|
|
14
|
-
};
|
|
12
|
+
export interface UrlState extends QueryState, UrlParams
|
|
15
13
|
```
|
|
16
|
-
<b>
|
|
14
|
+
<b>Extends:</b> QueryState, [UrlParams](./x-components.urlparams.md)
|
|
15
|
+
|
|
16
|
+
## Properties
|
|
17
|
+
|
|
18
|
+
| Property | Type | Description |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| [initialExtraParams](./x-components.urlstate.initialextraparams.md) | [Dictionary](./x-components.dictionary.md)<!-- --><unknown> | |
|
|
17
21
|
|
|
@@ -10,7 +10,7 @@ The Wiring is a record where each key is an EmpathyX event, and the value is a d
|
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
12
|
export declare type Wiring = {
|
|
13
|
-
[
|
|
13
|
+
[Event in XEvent]: Dictionary<WireForEvent<Event>>;
|
|
14
14
|
};
|
|
15
15
|
```
|
|
16
16
|
<b>References:</b> [XEvent](./x-components.xevent.md)<!-- -->, [Dictionary](./x-components.dictionary.md)<!-- -->, [WireForEvent](./x-components.wireforevent.md)
|
|
@@ -18,7 +18,5 @@ export interface RelatedTag extends NamedModel<'RelatedTag'>, Previewable
|
|
|
18
18
|
| Property | Type | Description |
|
|
19
19
|
| --- | --- | --- |
|
|
20
20
|
| [isCurated?](./x-types.relatedtag.iscurated.md) | boolean | <i>(Optional)</i> If it's a curated related tag. |
|
|
21
|
-
| [previous](./x-types.relatedtag.previous.md) | string | The query to refine. |
|
|
22
|
-
| [selected](./x-types.relatedtag.selected.md) | boolean | If selection mode is enabled, tells if this related tag is selected or not. |
|
|
23
21
|
| [tag](./x-types.relatedtag.tag.md) | string | The term to add to the current query. |
|
|
24
22
|
|
package/js/index.js
CHANGED
|
@@ -279,6 +279,7 @@ export { fetchRelatedTags } from './x-modules/related-tags/store/actions/fetch-r
|
|
|
279
279
|
export { toggleRelatedTag } from './x-modules/related-tags/store/actions/toggle-related-tag.action.js';
|
|
280
280
|
export { relatedTagsEmitters } from './x-modules/related-tags/store/emitters.js';
|
|
281
281
|
export { relatedTags } from './x-modules/related-tags/store/getters/related-tags.getter.js';
|
|
282
|
+
export { query as relatedTagsQuery } from './x-modules/related-tags/store/getters/query.getter.js';
|
|
282
283
|
export { request as relatedTagsRequest } from './x-modules/related-tags/store/getters/request.getter.js';
|
|
283
284
|
export { relatedTagsXStoreModule } from './x-modules/related-tags/store/module.js';
|
|
284
285
|
export { cancelFetchAndSaveRelatedTagsWire, clearRelatedTagsQuery, clearSelectedRelatedTags, fetchAndSaveRelatedTagsWire, relatedTagsWiring, setRelatedTagsExtraParams, setRelatedTagsQuery, setUrlParamsWire, toggleRelatedTagWire } from './x-modules/related-tags/wiring.js';
|
|
@@ -310,6 +311,7 @@ export { cancelFetchAndSaveSearchResponse, fetchAndSaveSearchResponse } from './
|
|
|
310
311
|
export { fetchSearchResponse } from './x-modules/search/store/actions/fetch-search-response.action.js';
|
|
311
312
|
export { searchEmitters } from './x-modules/search/store/emitters.js';
|
|
312
313
|
export { request as searchRequest } from './x-modules/search/store/getters/request.getter.js';
|
|
314
|
+
export { query as searchQuery } from './x-modules/search/store/getters/query.getter.js';
|
|
313
315
|
export { searchXStoreModule } from './x-modules/search/store/module.js';
|
|
314
316
|
export { cancelFetchAndSaveSearchResponseWire, fetchAndSaveSearchResponseWire, increasePageAppendingResults, resetAppending, resetSpellcheckQuery, resetStateWire, saveOriginWire, searchWiring, setPageSize, setRelatedTags, setSearchExtraParams, setSearchPage, setSearchQuery, setSelectedFilters, setSort, setUrlParams } from './x-modules/search/wiring.js';
|
|
315
317
|
export { searchXModule } from './x-modules/search/x-module.js';
|
package/js/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the query of the module.
|
|
3
|
+
*
|
|
4
|
+
* @param state - State of the module.
|
|
5
|
+
* @param query - The new query to set.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
function setQuery(state, query) {
|
|
9
|
+
state.query = query;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates a getter that combines the current selected related tags and the query of the module.
|
|
13
|
+
*
|
|
14
|
+
* @param options - Options on how the getter should behave.
|
|
15
|
+
* @returns A getter that combines the selected related tags with the query.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
function createRelatedTagsQueryGetter({ getRelatedTags }) {
|
|
19
|
+
return function relatedTagsQuery(state, getters) {
|
|
20
|
+
const query = state.query.trim();
|
|
21
|
+
return query ? getRelatedTags(state, getters).reduce(concatRelatedTag, query).trim() : '';
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Joins a query and a related tag respecting the tag position.
|
|
26
|
+
*
|
|
27
|
+
* @param partialQuery - The query to concatenate the related tag with.
|
|
28
|
+
* @param relatedTag - The related tag to concatenate.
|
|
29
|
+
* @returns The query and the related tag joined.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
function concatRelatedTag(partialQuery, { tag, query: relatedTagQuery }) {
|
|
33
|
+
return relatedTagQuery.startsWith(tag) ? `${tag} ${partialQuery}` : `${partialQuery} ${tag}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { createRelatedTagsQueryGetter, setQuery };
|
|
37
|
+
//# sourceMappingURL=query.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.utils.js","sources":["../../../../src/store/utils/query.utils.ts"],"sourcesContent":["import { RelatedTag } from '@empathyco/x-types';\n\n/**\n * Query state type, containing a property to hold the current query of the module.\n *\n * @public\n */\nexport interface QueryState {\n /** The query of the module. Different modules may have queries that differ in value\n * or time. */\n query: string;\n}\n\n/**\n * The {@link QueryState} mutations.\n *\n * @public\n */\nexport interface QueryMutations {\n /**\n * Sets the query.\n *\n * @param query - The new query.\n */\n setQuery(query: string): void;\n}\n\n/**\n * Options to create a getter that combines the query with the selected related tags.\n *\n * @public\n */\nexport interface CreateRelatedTagsQueryGetterOptions<State, Getters> {\n /**\n * Retrieves the selected related tags of the module.\n *\n * @param state - The state of the module.\n * @param getters - The getters of the module.\n * @returns The list of selected related tags.\n */\n getRelatedTags: (state: State, getters: Getters) => RelatedTag[];\n}\n\n/**\n * Sets the query of the module.\n *\n * @param state - State of the module.\n * @param query - The new query to set.\n * @public\n */\nexport function setQuery(state: QueryState, query: string): void {\n state.query = query;\n}\n\n/**\n * Creates a getter that combines the current selected related tags and the query of the module.\n *\n * @param options - Options on how the getter should behave.\n * @returns A getter that combines the selected related tags with the query.\n * @public\n */\nexport function createRelatedTagsQueryGetter<State extends QueryState, Getters>({\n getRelatedTags\n}: CreateRelatedTagsQueryGetterOptions<State, Getters>): (\n state: State,\n getters: Getters\n) => string {\n return function relatedTagsQuery(state, getters) {\n const query = state.query.trim();\n return query ? getRelatedTags(state, getters).reduce(concatRelatedTag, query).trim() : '';\n };\n}\n\n/**\n * Joins a query and a related tag respecting the tag position.\n *\n * @param partialQuery - The query to concatenate the related tag with.\n * @param relatedTag - The related tag to concatenate.\n * @returns The query and the related tag joined.\n * @internal\n */\nfunction concatRelatedTag(\n partialQuery: string,\n { tag, query: relatedTagQuery }: RelatedTag\n): string {\n return relatedTagQuery.startsWith(tag) ? `${tag} ${partialQuery}` : `${partialQuery} ${tag}`;\n}\n"],"names":[],"mappings":"AA2CA;;;;;;;SAOgB,QAAQ,CAAC,KAAiB,EAAE,KAAa;IACvD,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;AACtB,CAAC;AAED;;;;;;;SAOgB,4BAA4B,CAAoC,EAC9E,cAAc,EACsC;IAIpD,OAAO,SAAS,gBAAgB,CAAC,KAAK,EAAE,OAAO;QAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACjC,OAAO,KAAK,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC;KAC3F,CAAC;AACJ,CAAC;AAED;;;;;;;;AAQA,SAAS,gBAAgB,CACvB,YAAoB,EACpB,EAAE,GAAG,EAAE,KAAK,EAAE,eAAe,EAAc;IAE3C,OAAO,eAAe,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,IAAI,YAAY,EAAE,GAAG,GAAG,YAAY,IAAI,GAAG,EAAE,CAAC;AAC/F;;;;"}
|
package/js/utils/array.js
CHANGED
|
@@ -56,13 +56,13 @@ function groupItemsBy(array, groupBy) {
|
|
|
56
56
|
}, {});
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
* Filters an array with all elements that pass the test implemented by the
|
|
60
|
-
* function.
|
|
61
|
-
*
|
|
59
|
+
* Filters an array with all elements that pass the test implemented by the given filter
|
|
60
|
+
* function. If an item has another list of items in the `childrenKey` property it recursively
|
|
61
|
+
* filters that new list, adding it to the returned one.
|
|
62
62
|
*
|
|
63
63
|
* @param array - Array to be filtered.
|
|
64
|
-
* @param
|
|
65
|
-
* to keep the element; or false otherwise.
|
|
64
|
+
* @param condition - Predicate function to test each element of the array. It should return `true`
|
|
65
|
+
* to keep the element; or `false` otherwise.
|
|
66
66
|
* @param childrenKey - Property name within the array used to perform a recursive call.
|
|
67
67
|
*
|
|
68
68
|
* @example
|
|
@@ -130,68 +130,38 @@ function groupItemsBy(array, groupBy) {
|
|
|
130
130
|
* ]
|
|
131
131
|
* ```
|
|
132
132
|
*
|
|
133
|
-
* @returns A new array with the elements that pass the
|
|
133
|
+
* @returns A new array with the elements that pass the condition, or an empty array if no one
|
|
134
134
|
* pass the test.
|
|
135
135
|
*
|
|
136
136
|
* @public
|
|
137
137
|
*/
|
|
138
|
-
function deepFilter(array,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}, initialArray);
|
|
147
|
-
};
|
|
148
|
-
return filterArray(array);
|
|
138
|
+
function deepFilter(array, condition, childrenKey) {
|
|
139
|
+
return array.reduce(function filter(filteredArray, item) {
|
|
140
|
+
if (condition(item)) {
|
|
141
|
+
filteredArray.push(item);
|
|
142
|
+
item[childrenKey]?.reduce(filter, filteredArray);
|
|
143
|
+
}
|
|
144
|
+
return filteredArray;
|
|
145
|
+
}, []);
|
|
149
146
|
}
|
|
150
147
|
/**
|
|
151
|
-
* Flat an
|
|
152
|
-
* child which is also ArrayType[].
|
|
148
|
+
* Flat an `Item[]` deeply using the given `childrenKey` to access to his children.
|
|
153
149
|
*
|
|
154
|
-
* @param array -
|
|
155
|
-
*
|
|
156
|
-
* @param childrenKey -
|
|
157
|
-
*
|
|
150
|
+
* @param array - The list of items to flat. Each item may have another list of items of
|
|
151
|
+
* the same type to flat.
|
|
152
|
+
* @param childrenKey - Property name where each of the items of the given array may have another
|
|
153
|
+
* list of items to be flattened.
|
|
158
154
|
*
|
|
159
|
-
* @returns
|
|
160
|
-
* level.
|
|
155
|
+
* @returns A flat list with all the found items.
|
|
161
156
|
*
|
|
162
157
|
* @public
|
|
163
158
|
*/
|
|
164
159
|
function deepFlat(array, childrenKey) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
* - If not, the item is pushed to the resultantArray.
|
|
171
|
-
* - Finally, flatArray function is called again with the currentItem children and the process
|
|
172
|
-
* starts again.
|
|
173
|
-
*
|
|
174
|
-
* It's the main function of the parent. See the description above
|
|
175
|
-
* for further information.
|
|
176
|
-
*
|
|
177
|
-
* @param resultantArray - Flattened array.
|
|
178
|
-
* @param currentItem - ArrayType object.
|
|
179
|
-
*
|
|
180
|
-
* @returns Flattened ArrayType[].
|
|
181
|
-
*
|
|
182
|
-
* @internal
|
|
183
|
-
*/
|
|
184
|
-
function flatArray(resultantArray, currentItem) {
|
|
185
|
-
if (!currentItem) {
|
|
186
|
-
return resultantArray;
|
|
187
|
-
}
|
|
188
|
-
if (Array.isArray(currentItem)) {
|
|
189
|
-
return currentItem.reduce(flatArray, resultantArray);
|
|
190
|
-
}
|
|
191
|
-
resultantArray.push(currentItem);
|
|
192
|
-
return flatArray(resultantArray, currentItem[childrenKey]);
|
|
193
|
-
}
|
|
194
|
-
return flatArray([], array);
|
|
160
|
+
return array.reduce(function flat(flattenedArray, item) {
|
|
161
|
+
flattenedArray.push(item);
|
|
162
|
+
item[childrenKey]?.reduce(flat, flattenedArray);
|
|
163
|
+
return flattenedArray;
|
|
164
|
+
}, []);
|
|
195
165
|
}
|
|
196
166
|
/**
|
|
197
167
|
* Creates an Emitter filter function to compare two arrays and filter those that are equal.
|
package/js/utils/array.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sources":["../../../src/utils/array.ts"],"sourcesContent":["import { PropsWithType } from './types';\n\n/**\n * Returns if the given array is `null`, `undefined`, or has no elements.\n *\n * @param array - The array to check if it is empty.\n * @returns `true` if the array is `null`, `undefined`, or has no elements. `false` otherwise.\n * @public\n */\nexport function isArrayEmpty(array: unknown[] | undefined | null): array is undefined | null | [] {\n return array == null || array.length === 0;\n}\n\n/**\n * Reduce an array of strings to an object which properties names are the value of each string,\n * and the value under that property are also the string.\n *\n * @param array - Array of strings that will be used to create the object.\n *\n * @returns New object which properties object[key] contains object of each iteration in the\n * array.\n *\n * @example Converting an array to an object:\n * arrayToObject(['a', 'b', 'c']) === \\{a: 'a', b: 'b', c: 'c'\\}\n *\n * @public\n */\nexport function arrayToObject(array: string[]): Record<string, string>;\n/**\n * Reduce an array of objects to an object which properties names are the value of each object[key],\n * and the value under that property are each object. 'key' is the the parameter passed to this\n * function.\n *\n * @param array - Array of objects that contains objects which have object[key] string as a property\n * value.\n * @param key - Key used to access to each object[key] value, used for each property name in the new\n * object.\n *\n * @returns New object which properties object[key] contains object of each iteration in the array.\n *\n * @public\n */\nexport function arrayToObject<ArrayType, KeyType extends string | number>(\n array: ArrayType[],\n key: PropsWithType<ArrayType, KeyType>\n): Record<string, ArrayType>;\n/**\n * Reduce an array to an object. The type of the object returned depends on the type of the params.\n * If the 'key' is passed then the function returns an object which properties names are the value\n * of each object[key] and the value under that property are each object.\n * If the 'key' is not passed then the function returns an object which properties names are each\n * array item, and the value is also the array item.\n *\n * @param array - Array from which to create an object.\n * @param key - Key used to access to each object[key] value, used for each property name in the\n * new object.\n *\n * @returns New object which properties object[key] contains each item in the array and the key is\n * either the item of the array or a property of each item designated by 'key' param.\n *\n * @public\n */\nexport function arrayToObject<ArrayType, KeyType extends string | number>(\n array: ArrayType[],\n key?: PropsWithType<ArrayType, KeyType>\n): Record<string, ArrayType> {\n return array.reduce<Record<string, ArrayType>>((accumulator, current) => {\n if (key) {\n accumulator[current[key] as unknown as string] = current;\n } else if (typeof current === 'string') {\n accumulator[current] = current;\n }\n return accumulator;\n }, {});\n}\n\n/**\n * Groups the array items based on the provided `groupBy` function.\n *\n * @param array - The array to iterate, grouping its items in different arrays based on the\n * `groupBy` function.\n * @param groupBy - A function to determine the group name of a single item.\n * @returns The items grouped in a dictionary.\n *\n * @public\n */\nexport function groupItemsBy<ArrayType, ReturnType extends string | number>(\n array: ArrayType[],\n groupBy: (item: ArrayType, index: number) => ReturnType\n): Record<ReturnType, ArrayType[]> {\n return array.reduce<Record<ReturnType, ArrayType[]>>((accumulator, current, index) => {\n const keyValue = groupBy(current, index);\n if (!accumulator[keyValue]) {\n accumulator[keyValue] = [];\n }\n accumulator[keyValue].push(current);\n return accumulator;\n }, {} as Record<ReturnType, ArrayType[]>);\n}\n\n/**\n * Filters an array with all elements that pass the test implemented by the provided filter\n * function. It also does it recursively if the property accessed, whose name is the parameter\n * childrenKey, to the current iteration in an array.\n *\n * @param array - Array to be filtered.\n * @param filter - Predicate function to test each element of the array. It should return true\n * to keep the element; or false otherwise.\n * @param childrenKey - Property name within the array used to perform a recursive call.\n *\n * @example\n * Input - Output example\n *\n * ```\n * const hierarchicalFilters: Filter[] = [\n * {\n * id: 'filter1'\n * selected: true,\n * children: [\n * {\n * id: 'filter1-1'\n * selected: true,\n * children: []\n * },\n * {\n * id: 'filter1-2'\n * selected: false,\n * children: []\n * }\n * ]\n * },\n * {\n * id: 'filter2',\n * selected: false,\n * children: [\n * {\n * id: 'filter2-1',\n * selected: true // not should happen\n * }\n * ]\n * }\n * ]\n *\n * const filteredArray: Filter[] = deepFilterArray(\n * hierarchicalFilters,\n * filter => filter.selected,\n * 'children'\n * )\n *\n * /*\n * filteredArray = [\n * {\n * id: 'filter1'\n * selected: true,\n * children: [\n * {\n * id: 'filter1-1'\n * selected: true,\n * children: []\n * },\n * {\n * id: 'filter1-2'\n * selected: false,\n * children: []\n * }\n * ]\n * },\n * {\n * id: 'filter1-1'\n * selected: true,\n * children: []\n * }\n * ]\n * ```\n *\n * @returns A new array with the elements that pass the test, or an empty array if no one\n * pass the test.\n *\n * @public\n */\nexport function deepFilter<ArrayType, Key extends PropsWithType<ArrayType, ArrayType[]>>(\n array: ArrayType[],\n filter: (item: ArrayType) => boolean,\n childrenKey: Key\n): ArrayType[] {\n const filterArray = function (\n currentArray: ArrayType[],\n initialArray: ArrayType[] = []\n ): ArrayType[] {\n return currentArray.reduce((result, currentItem) => {\n if (filter(currentItem)) {\n result.push(currentItem);\n filterArray(currentItem[childrenKey], result);\n }\n\n return result;\n }, initialArray);\n };\n\n return filterArray(array);\n}\n\n/**\n * Flat an ArrayType[] recursively using the childrenKey passed as parameter to access to his nested\n * child which is also ArrayType[].\n *\n * @param array - ArrayType[] which each ArrayType has a property childrenKey which value is also\n * an ArrayType[].\n * @param childrenKey - Key used to access to each ArrayType[childrenKey] value which is also\n * an ArrayType[].\n *\n * @returns ArrayType[] with all the nested ArrayType, including the nested ones, at the same depth\n * level.\n *\n * @public\n */\nexport function deepFlat<ArrayType, Key extends PropsWithType<ArrayType, ArrayType[] | undefined>>(\n array: ArrayType[],\n childrenKey: Key\n): ArrayType[] {\n /**\n * Flats an array recursively. In each iteration:\n * - If the currentItem is an array, flatArray is used to reduce it. So, the order of the\n * flatArray arguments defined is important. This happens when the function is called passing an\n * array as the second parameter.\n * - If not, the item is pushed to the resultantArray.\n * - Finally, flatArray function is called again with the currentItem children and the process\n * starts again.\n *\n * It's the main function of the parent. See the description above\n * for further information.\n *\n * @param resultantArray - Flattened array.\n * @param currentItem - ArrayType object.\n *\n * @returns Flattened ArrayType[].\n *\n * @internal\n */\n function flatArray(\n resultantArray: ArrayType[],\n currentItem: ArrayType | ArrayType[]\n ): ArrayType[] {\n if (!currentItem) {\n return resultantArray;\n }\n\n if (Array.isArray(currentItem)) {\n return currentItem.reduce(flatArray, resultantArray);\n }\n resultantArray.push(currentItem);\n return flatArray(resultantArray, currentItem[childrenKey]);\n }\n\n return flatArray([], array);\n}\n\n/**\n * Creates an Emitter filter function to compare two arrays and filter those that are equal.\n *\n * @param comparator - String with the name of the field of the arrays items to compare, or function\n * to compare items directly.\n * @returns The comparator function that receives two arrays to compare them.\n *\n * @internal\n */\nexport function createEmitterArrayFilter<T>(\n comparator: keyof T | ((item1: T, item2: T) => boolean)\n): (newCollection: Array<T>, oldCollection: Array<T>) => boolean {\n const comparatorFn =\n typeof comparator === 'function'\n ? comparator\n : (newItem: T, oldItem: T) => newItem[comparator] === oldItem[comparator];\n return function (newCollection: Array<T>, oldCollection: Array<T>): boolean {\n return (\n newCollection.length !== oldCollection.length ||\n newCollection.some(newItem => !oldCollection.find(oldItem => comparatorFn(newItem, oldItem)))\n );\n };\n}\n"],"names":[],"mappings":"AAEA;;;;;;;SAOgB,YAAY,CAAC,KAAmC;IAC9D,OAAO,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;AAC7C,CAAC;AAmCD;;;;;;;;;;;;;;;;SAgBgB,aAAa,CAC3B,KAAkB,EAClB,GAAuC;IAEvC,OAAO,KAAK,CAAC,MAAM,CAA4B,CAAC,WAAW,EAAE,OAAO;QAClE,IAAI,GAAG,EAAE;YACP,WAAW,CAAC,OAAO,CAAC,GAAG,CAAsB,CAAC,GAA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EAClB,WAAgB;;;;;;;;;;;;;;;;;;;;IAqBhB,SAAS,SAAS,CAChB,cAA2B,EAC3B,WAAoC;QAEpC,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,cAAc,CAAC;SACvB;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;YAC9B,OAAO,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;SACtD;QACD,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjC,OAAO,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;KAC5D;IAED,OAAO,SAAS,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;;;;SASgB,wBAAwB,CACtC,UAAuD;IAEvD,MAAM,YAAY,GAChB,OAAO,UAAU,KAAK,UAAU;UAC5B,UAAU;UACV,CAAC,OAAU,EAAE,OAAU,KAAK,OAAO,CAAC,UAAU,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9E,OAAO,UAAU,aAAuB,EAAE,aAAuB;QAC/D,QACE,aAAa,CAAC,MAAM,KAAK,aAAa,CAAC,MAAM;YAC7C,aAAa,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAC7F;KACH,CAAC;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"array.js","sources":["../../../src/utils/array.ts"],"sourcesContent":["import { PropsWithType } from './types';\n\n/**\n * Returns if the given array is `null`, `undefined`, or has no elements.\n *\n * @param array - The array to check if it is empty.\n * @returns `true` if the array is `null`, `undefined`, or has no elements. `false` otherwise.\n * @public\n */\nexport function isArrayEmpty(array: unknown[] | undefined | null): array is undefined | null | [] {\n return array == null || array.length === 0;\n}\n\n/**\n * Reduce an array of strings to an object which properties names are the value of each string,\n * and the value under that property are also the string.\n *\n * @param array - Array of strings that will be used to create the object.\n *\n * @returns New object which properties object[key] contains object of each iteration in the\n * array.\n *\n * @example Converting an array to an object:\n * arrayToObject(['a', 'b', 'c']) === \\{a: 'a', b: 'b', c: 'c'\\}\n *\n * @public\n */\nexport function arrayToObject(array: string[]): Record<string, string>;\n/**\n * Reduce an array of objects to an object which properties names are the value of each object[key],\n * and the value under that property are each object. 'key' is the the parameter passed to this\n * function.\n *\n * @param array - Array of objects that contains objects which have object[key] string as a property\n * value.\n * @param key - Key used to access to each object[key] value, used for each property name in the new\n * object.\n *\n * @returns New object which properties object[key] contains object of each iteration in the array.\n *\n * @public\n */\nexport function arrayToObject<ArrayType>(\n array: ArrayType[],\n key: PropsWithType<ArrayType, string | number>\n): Record<string, ArrayType>;\n/**\n * Reduce an array to an object. The type of the object returned depends on the type of the params.\n * If the 'key' is passed then the function returns an object which properties names are the value\n * of each object[key] and the value under that property are each object.\n * If the 'key' is not passed then the function returns an object which properties names are each\n * array item, and the value is also the array item.\n *\n * @param array - Array from which to create an object.\n * @param key - Key used to access to each object[key] value, used for each property name in the\n * new object.\n *\n * @returns New object which properties object[key] contains each item in the array and the key is\n * either the item of the array or a property of each item designated by 'key' param.\n *\n * @public\n */\nexport function arrayToObject<ArrayType>(\n array: ArrayType[],\n key?: PropsWithType<ArrayType, string | number>\n): Record<string, ArrayType> {\n return array.reduce<Record<string, ArrayType>>((accumulator, current) => {\n if (key) {\n accumulator[current[key] as any] = current;\n } else if (typeof current === 'string') {\n accumulator[current] = current;\n }\n return accumulator;\n }, {});\n}\n\n/**\n * Groups the array items based on the provided `groupBy` function.\n *\n * @param array - The array to iterate, grouping its items in different arrays based on the\n * `groupBy` function.\n * @param groupBy - A function to determine the group name of a single item.\n * @returns The items grouped in a dictionary.\n *\n * @public\n */\nexport function groupItemsBy<ArrayType, ReturnType extends string | number>(\n array: ArrayType[],\n groupBy: (item: ArrayType, index: number) => ReturnType\n): Record<ReturnType, ArrayType[]> {\n return array.reduce<Record<ReturnType, ArrayType[]>>((accumulator, current, index) => {\n const keyValue = groupBy(current, index);\n if (!accumulator[keyValue]) {\n accumulator[keyValue] = [];\n }\n accumulator[keyValue].push(current);\n return accumulator;\n }, {} as Record<ReturnType, ArrayType[]>);\n}\n\n/**\n * Filters an array with all elements that pass the test implemented by the given filter\n * function. If an item has another list of items in the `childrenKey` property it recursively\n * filters that new list, adding it to the returned one.\n *\n * @param array - Array to be filtered.\n * @param condition - Predicate function to test each element of the array. It should return `true`\n * to keep the element; or `false` otherwise.\n * @param childrenKey - Property name within the array used to perform a recursive call.\n *\n * @example\n * Input - Output example\n *\n * ```\n * const hierarchicalFilters: Filter[] = [\n * {\n * id: 'filter1'\n * selected: true,\n * children: [\n * {\n * id: 'filter1-1'\n * selected: true,\n * children: []\n * },\n * {\n * id: 'filter1-2'\n * selected: false,\n * children: []\n * }\n * ]\n * },\n * {\n * id: 'filter2',\n * selected: false,\n * children: [\n * {\n * id: 'filter2-1',\n * selected: true // not should happen\n * }\n * ]\n * }\n * ]\n *\n * const filteredArray: Filter[] = deepFilterArray(\n * hierarchicalFilters,\n * filter => filter.selected,\n * 'children'\n * )\n *\n * /*\n * filteredArray = [\n * {\n * id: 'filter1'\n * selected: true,\n * children: [\n * {\n * id: 'filter1-1'\n * selected: true,\n * children: []\n * },\n * {\n * id: 'filter1-2'\n * selected: false,\n * children: []\n * }\n * ]\n * },\n * {\n * id: 'filter1-1'\n * selected: true,\n * children: []\n * }\n * ]\n * ```\n *\n * @returns A new array with the elements that pass the condition, or an empty array if no one\n * pass the test.\n *\n * @public\n */\nexport function deepFilter<Item extends { [key in Key]?: Item[] }, Key extends keyof Item>(\n array: Item[],\n condition: (item: Item) => boolean,\n childrenKey: Key\n): Item[] {\n return array.reduce<Item[]>(function filter(filteredArray, item) {\n if (condition(item)) {\n filteredArray.push(item);\n item[childrenKey]?.reduce(filter, filteredArray);\n }\n return filteredArray;\n }, []);\n}\n\n/**\n * Flat an `Item[]` deeply using the given `childrenKey` to access to his children.\n *\n * @param array - The list of items to flat. Each item may have another list of items of\n * the same type to flat.\n * @param childrenKey - Property name where each of the items of the given array may have another\n * list of items to be flattened.\n *\n * @returns A flat list with all the found items.\n *\n * @public\n */\nexport function deepFlat<Item extends { [key in Key]?: Item[] }, Key extends keyof Item>(\n array: Item[],\n childrenKey: Key\n): Item[] {\n return array.reduce<Item[]>(function flat(flattenedArray, item) {\n flattenedArray.push(item);\n item[childrenKey]?.reduce(flat, flattenedArray);\n return flattenedArray;\n }, []);\n}\n\n/**\n * Creates an Emitter filter function to compare two arrays and filter those that are equal.\n *\n * @param comparator - String with the name of the field of the arrays items to compare, or function\n * to compare items directly.\n * @returns The comparator function that receives two arrays to compare them.\n *\n * @internal\n */\nexport function createEmitterArrayFilter<T>(\n comparator: keyof T | ((item1: T, item2: T) => boolean)\n): (newCollection: Array<T>, oldCollection: Array<T>) => boolean {\n const comparatorFn =\n typeof comparator === 'function'\n ? comparator\n : (newItem: T, oldItem: T) => newItem[comparator] === oldItem[comparator];\n return function (newCollection: Array<T>, oldCollection: Array<T>): boolean {\n return (\n newCollection.length !== oldCollection.length ||\n newCollection.some(newItem => !oldCollection.find(oldItem => comparatorFn(newItem, oldItem)))\n );\n };\n}\n"],"names":[],"mappings":"AAEA;;;;;;;SAOgB,YAAY,CAAC,KAAmC;IAC9D,OAAO,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;AAC7C,CAAC;AAmCD;;;;;;;;;;;;;;;;SAgBgB,aAAa,CAC3B,KAAkB,EAClB,GAA+C;IAE/C,OAAO,KAAK,CAAC,MAAM,CAA4B,CAAC,WAAW,EAAE,OAAO;QAClE,IAAI,GAAG,EAAE;YACP,WAAW,CAAC,OAAO,CAAC,GAAG,CAAQ,CAAC,GAAG,OAAO,CAAC;SAC5C;aAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YACtC,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;S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;QAChD,OAAO,cAAc,CAAC;KACvB,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED;;;;;;;;;SASgB,wBAAwB,CACtC,UAAuD;IAEvD,MAAM,YAAY,GAChB,OAAO,UAAU,KAAK,UAAU;UAC5B,UAAU;UACV,CAAC,OAAU,EAAE,OAAU,KAAK,OAAO,CAAC,UAAU,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9E,OAAO,UAAU,aAAuB,EAAE,aAAuB;QAC/D,QACE,aAAa,CAAC,MAAM,KAAK,aAAa,CAAC,MAAM;YAC7C,aAAa,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAC7F;KACH,CAAC;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wires.factory.js","sources":["../../../src/wiring/wires.factory.ts"],"sourcesContent":["import { Store } from 'vuex';\nimport { RootXStoreState } from '../store/store.types';\nimport {\n AnyWire,\n PayloadFactoryData,\n Wire,\n WireParams,\n WirePayload,\n WireService,\n WireServiceWithoutPayload\n} from './wiring.types';\n\n/**\n * Creates a wire that executes the function passed. This function will receive a\n * {@link WireParams} object.\n *\n * @param fn - The function to execute whenever a new value is emitted to the observable.\n * @returns The Wire function.\n * @public\n */\nexport function createWireFromFunction<Payload>(\n fn: (parameters: WireParams<Payload>) => void\n): Wire<Payload> {\n return (observable, store) =>\n observable.subscribe(({ metadata, eventPayload }) => {\n fn({ eventPayload, store, metadata });\n });\n}\n\n/**\n * Creates a wire that commits a mutation to the store. This wire receives a function. This function\n * is used to get the actual payload value passed to mutation.\n * This wire can be used in every event, as it does not have a payload type associated.\n *\n * @param mutation - The full mutation path to commit. I.e. `x/searchBox/setQuery`.\n * @param payloadFactory - A function that receives a {@link PayloadFactoryData | object}\n * with the Store state, getters, payload and metadata as parameter.\n * @returns A {@link AnyWire} wire that commits the mutation with the payload returned by the\n * payloadFactory.\n * @public\n */\nexport function wireCommit<Payload>(\n mutation: string,\n payloadFactory: (params: PayloadFactoryData<Payload>) => any\n): AnyWire;\n/**\n * Creates a wire that commits a mutation to the store. This wire can receive any value as payload.\n * This wire can be used in every event, as it does not have a payload type associated.\n *\n * @param mutation - The full mutation path to commit. I.e. `x/searchBox/setQuery`.\n * @param staticPayload - A static payload to pass to the mutation.\n * @returns {@link AnyWire} A wire that commits the mutation with the staticPayload payload.\n * @public\n */\nexport function wireCommit(mutation: string, staticPayload: any): AnyWire;\n/**\n * Creates a wire that commits a mutation to the store. This wire will commit to the store the\n * payload that it receives in the observable.\n *\n * @param mutation - The full mutation path to commit. I.e. `x/searchBox/setQuery`.\n * @typeParam Payload - The type of the payload that this wire will receive\n * @returns {@link Wire} A wire that commits the mutation with the payload that it receives\n * in the observable.\n * @public\n */\nexport function wireCommit<Payload>(mutation: string): Wire<Payload>;\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function wireCommit<Payload>(mutation: string, payload?: Payload): Wire<Payload> {\n return (observable, store) =>\n observable.subscribe(createSubscriptionCallback(store, 'commit', mutation, payload));\n}\n\n/**\n * Creates a wire that commits a mutation to the store, but without any payload. This wire can\n * be used in every event, as it does not have a payload type associated.\n *\n * @param mutation - The full mutation path to commit. I.e. `x/searchBox/setQuery`.\n * @returns {@link AnyWire} A wire that commits the mutation without any payload.\n * @public\n */\nexport function wireCommitWithoutPayload(mutation: string): AnyWire {\n return (observable, store) => observable.subscribe(() => store.commit(mutation));\n}\n\n/**\n * Creates a wire that dispatch an action to the store. This wire receives a function. This function\n * is used to get the actual payload value passed to action.\n * This wire can be used in every event, as it does not have a payload type associated.\n *\n * @param action - The full action path to dispatch. I.e. `x/querySuggestions/fetchSuggestions`.\n * @param payloadFactory - A function that receives a {@link PayloadFactoryData | object}\n * with the Store state, getters, payload and metadata as parameter.\n * @returns A {@link AnyWire} wire that dispatches the action with the payload returned by the\n * payloadFactory.\n * @public\n */\nexport function wireDispatch<Payload>(\n action: string,\n payloadFactory: (params: PayloadFactoryData<Payload>) => any\n): AnyWire;\n/**\n * Creates a wire that dispatches an action to the store. This wire can be used in every event,\n * as it does not have a payload type associated.\n *\n * @param action - The full action path to dispatch. I.e. `x/querySuggestions/fetchSuggestions`.\n * @param staticPayload - A static payload to pass to the action which will be dispatched.\n * @returns {@link AnyWire} A wire that dispatches the action with the staticPayload payload.\n * @public\n */\nexport function wireDispatch(action: string, staticPayload: any): AnyWire;\n/**\n * Creates a wire that dispatches an action to the store. This wire will pass the payload\n * received in the observable to the action.\n *\n * @param action - The full action path to dispatch. I.e. `x/querySuggestions/fetchSuggestions`.\n * @typeParam Payload - The type of the payload that this wire will receive\n * @returns {@link Wire} A wire that dispatches the action with the payload that it receives\n * in the observable.\n * @public\n */\nexport function wireDispatch<Payload>(action: string): Wire<Payload>;\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function wireDispatch<Payload>(action: string, payload?: Payload): Wire<Payload> {\n return (observable, store) =>\n observable.subscribe(createSubscriptionCallback(store, 'dispatch', action, payload));\n}\n\n/**\n * Creates a wire that dispatches an action to the store, but without any payload. This wire can\n * be used in every event, as it does not have a payload type associated.\n *\n * @param action - The full action path to dispatch. I.e. `x/querySuggestions/fetchSuggestions`.\n * @returns {@link AnyWire} A wire that dispatches the action without any payload.\n * @public\n */\nexport function wireDispatchWithoutPayload(action: string): AnyWire {\n return (observable, store) => observable.subscribe(() => store.dispatch(action));\n}\n\n/**\n * Creates a wires factory that can create wires that will invoke the service methods.\n *\n * @param service - The service to invoke its methods.\n * @returns A factory to create wires that invoke the service methods.\n * @public\n */\nexport function wireService<SomeService>(service: SomeService): WireService<SomeService> {\n return (method, payload?) => {\n return observable =>\n observable.subscribe(\n payload !== undefined\n ? () => service[method](payload)\n : observablePayload => service[method](observablePayload.eventPayload)\n );\n };\n}\n\n/**\n * Creates a wires factory that can create wires that will invoke the service methods but\n * without payload.\n *\n * @param service - The service to invoke its methods.\n * @returns A factory to create wires that invoke the service methods without payload.\n * @public\n */\nexport function wireServiceWithoutPayload<SomeService>(\n service: SomeService\n): WireServiceWithoutPayload<SomeService> {\n return method => {\n return observable => observable.subscribe(() => service[method]());\n };\n}\n\n/**\n * Creates the callback function for the {@link wireCommit} and {@link wireDispatch}\n * subscriptions. It can be based on the payload as function which retrieves the observable\n * payload from the store, a static payload or the event value from the observable.\n *\n * @param store - The {@link RootXStoreState} store.\n * @param commitOrDispatch - The executor over store. It can be `commit` or `dispatch`.\n * @param mutationOrAction - The mutation or action to commit or dispatch respectively.\n * @param payload - The payload for the store executor. It can be a function which retrieves the\n * payload from the store, a static payload or the event value from the observable.\n * @typeParam Payload - The type of the payload to get the observable event value type.\n * @returns A function to commit or dispatch a payload value over store.\n * @internal\n */\nfunction createSubscriptionCallback<Payload>(\n store: Store<RootXStoreState>,\n commitOrDispatch: 'commit' | 'dispatch',\n mutationOrAction: string,\n payload?: Payload\n): (observableValue: WirePayload<Payload>) => void {\n const storeExecutor = store[commitOrDispatch];\n return typeof payload === 'function'\n ? wirePayload => {\n return storeExecutor(\n mutationOrAction,\n payload({\n state: store.state,\n getters: store.getters,\n ...wirePayload\n })\n );\n }\n : payload !== undefined\n ? () => {\n storeExecutor(mutationOrAction, payload);\n }\n : observableValue => {\n storeExecutor(mutationOrAction, observableValue.eventPayload);\n };\n}\n"],"names":[],"mappings":"AAYA;;;;;;;;SAQgB,sBAAsB,CACpC,EAA6C;IAE7C,OAAO,CAAC,UAAU,EAAE,KAAK,KACvB,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE;QAC9C,EAAE,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;KACvC,CAAC,CAAC;AACP,CAAC;AAuCD;SACgB,UAAU,CAAU,QAAgB,EAAE,OAAiB;IACrE,OAAO,CAAC,UAAU,EAAE,KAAK,KACvB,UAAU,CAAC,SAAS,CAAC,0BAA0B,CA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GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC9C,OAAO,OAAO,OAAO,KAAK,UAAU;UAChC,WAAW;YACT,OAAO,aAAa,CAClB,gBAAgB,EAChB,OAAO,CAAC;gBACN,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,GAAG,WAAW;aACf,CAAC,CACH,CAAC;SACH;UACD,OAAO,KAAK,SAAS;cACrB;gBACE,aAAa,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;aAC1C;cACD,eAAe;gBACb,aAAa,CAAC,gBAAgB,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;aAC/D,CAAC;AACR;;;;"}
|
|
1
|
+
{"version":3,"file":"wires.factory.js","sources":["../../../src/wiring/wires.factory.ts"],"sourcesContent":["import { Store } from 'vuex';\nimport { RootXStoreState } from '../store/store.types';\nimport { MonadicFunction, NiladicFunction, SubObject } from '../utils/index';\nimport {\n AnyWire,\n PayloadFactoryData,\n Wire,\n WireParams,\n WirePayload,\n WireService,\n WireServiceWithoutPayload\n} from './wiring.types';\n\n/**\n * Creates a wire that executes the function passed. This function will receive a\n * {@link WireParams} object.\n *\n * @param fn - The function to execute whenever a new value is emitted to the observable.\n * @returns The Wire function.\n * @public\n */\nexport function createWireFromFunction<Payload>(\n fn: (parameters: WireParams<Payload>) => void\n): Wire<Payload> {\n return (observable, store) =>\n observable.subscribe(({ metadata, eventPayload }) => {\n fn({ eventPayload, store, metadata });\n });\n}\n\n/**\n * Creates a wire that commits a mutation to the store. This wire receives a function. This function\n * is used to get the actual payload value passed to mutation.\n * This wire can be used in every event, as it does not have a payload type associated.\n *\n * @param mutation - The full mutation path to commit. I.e. `x/searchBox/setQuery`.\n * @param payloadFactory - A function that receives a {@link PayloadFactoryData | object}\n * with the Store state, getters, payload and metadata as parameter.\n * @returns A {@link AnyWire} wire that commits the mutation with the payload returned by the\n * payloadFactory.\n * @public\n */\nexport function wireCommit<Payload>(\n mutation: string,\n payloadFactory: (params: PayloadFactoryData<Payload>) => any\n): AnyWire;\n/**\n * Creates a wire that commits a mutation to the store. This wire can receive any value as payload.\n * This wire can be used in every event, as it does not have a payload type associated.\n *\n * @param mutation - The full mutation path to commit. I.e. `x/searchBox/setQuery`.\n * @param staticPayload - A static payload to pass to the mutation.\n * @returns {@link AnyWire} A wire that commits the mutation with the staticPayload payload.\n * @public\n */\nexport function wireCommit(mutation: string, staticPayload: any): AnyWire;\n/**\n * Creates a wire that commits a mutation to the store. This wire will commit to the store the\n * payload that it receives in the observable.\n *\n * @param mutation - The full mutation path to commit. I.e. `x/searchBox/setQuery`.\n * @typeParam Payload - The type of the payload that this wire will receive\n * @returns {@link Wire} A wire that commits the mutation with the payload that it receives\n * in the observable.\n * @public\n */\nexport function wireCommit<Payload>(mutation: string): Wire<Payload>;\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function wireCommit<Payload>(mutation: string, payload?: Payload): Wire<Payload> {\n return (observable, store) =>\n observable.subscribe(createSubscriptionCallback(store, 'commit', mutation, payload));\n}\n\n/**\n * Creates a wire that commits a mutation to the store, but without any payload. This wire can\n * be used in every event, as it does not have a payload type associated.\n *\n * @param mutation - The full mutation path to commit. I.e. `x/searchBox/setQuery`.\n * @returns {@link AnyWire} A wire that commits the mutation without any payload.\n * @public\n */\nexport function wireCommitWithoutPayload(mutation: string): AnyWire {\n return (observable, store) => observable.subscribe(() => store.commit(mutation));\n}\n\n/**\n * Creates a wire that dispatch an action to the store. This wire receives a function. This function\n * is used to get the actual payload value passed to action.\n * This wire can be used in every event, as it does not have a payload type associated.\n *\n * @param action - The full action path to dispatch. I.e. `x/querySuggestions/fetchSuggestions`.\n * @param payloadFactory - A function that receives a {@link PayloadFactoryData | object}\n * with the Store state, getters, payload and metadata as parameter.\n * @returns A {@link AnyWire} wire that dispatches the action with the payload returned by the\n * payloadFactory.\n * @public\n */\nexport function wireDispatch<Payload>(\n action: string,\n payloadFactory: (params: PayloadFactoryData<Payload>) => any\n): AnyWire;\n/**\n * Creates a wire that dispatches an action to the store. This wire can be used in every event,\n * as it does not have a payload type associated.\n *\n * @param action - The full action path to dispatch. I.e. `x/querySuggestions/fetchSuggestions`.\n * @param staticPayload - A static payload to pass to the action which will be dispatched.\n * @returns {@link AnyWire} A wire that dispatches the action with the staticPayload payload.\n * @public\n */\nexport function wireDispatch(action: string, staticPayload: any): AnyWire;\n/**\n * Creates a wire that dispatches an action to the store. This wire will pass the payload\n * received in the observable to the action.\n *\n * @param action - The full action path to dispatch. I.e. `x/querySuggestions/fetchSuggestions`.\n * @typeParam Payload - The type of the payload that this wire will receive\n * @returns {@link Wire} A wire that dispatches the action with the payload that it receives\n * in the observable.\n * @public\n */\nexport function wireDispatch<Payload>(action: string): Wire<Payload>;\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function wireDispatch<Payload>(action: string, payload?: Payload): Wire<Payload> {\n return (observable, store) =>\n observable.subscribe(createSubscriptionCallback(store, 'dispatch', action, payload));\n}\n\n/**\n * Creates a wire that dispatches an action to the store, but without any payload. This wire can\n * be used in every event, as it does not have a payload type associated.\n *\n * @param action - The full action path to dispatch. I.e. `x/querySuggestions/fetchSuggestions`.\n * @returns {@link AnyWire} A wire that dispatches the action without any payload.\n * @public\n */\nexport function wireDispatchWithoutPayload(action: string): AnyWire {\n return (observable, store) => observable.subscribe(() => store.dispatch(action));\n}\n\n/**\n * Creates a wires factory that can create wires that will invoke the service methods.\n *\n * @param service - The service to invoke its methods.\n * @returns A factory to create wires that invoke the service methods.\n * @public\n */\nexport function wireService<SomeService>(\n service: SomeService & SubObject<SomeService, MonadicFunction>\n): WireService<SubObject<SomeService, MonadicFunction>> {\n return (method, payload?) => {\n return observable =>\n observable.subscribe(\n payload !== undefined\n ? () => service[method](payload)\n : observablePayload => service[method](observablePayload.eventPayload)\n );\n };\n}\n\n/**\n * Creates a wires factory that can create wires that will invoke the service methods but\n * without payload.\n *\n * @param service - The service to invoke its methods.\n * @returns A factory to create wires that invoke the service methods without payload.\n * @public\n */\nexport function wireServiceWithoutPayload<SomeService>(\n service: SomeService & SubObject<SomeService, NiladicFunction>\n): WireServiceWithoutPayload<SubObject<SomeService, NiladicFunction>> {\n return method => {\n return observable => observable.subscribe(() => service[method]());\n };\n}\n\n/**\n * Creates the callback function for the {@link wireCommit} and {@link wireDispatch}\n * subscriptions. It can be based on the payload as function which retrieves the observable\n * payload from the store, a static payload or the event value from the observable.\n *\n * @param store - The {@link RootXStoreState} store.\n * @param commitOrDispatch - The executor over store. It can be `commit` or `dispatch`.\n * @param mutationOrAction - The mutation or action to commit or dispatch respectively.\n * @param payload - The payload for the store executor. It can be a function which retrieves the\n * payload from the store, a static payload or the event value from the observable.\n * @typeParam Payload - The type of the payload to get the observable event value type.\n * @returns A function to commit or dispatch a payload value over store.\n * @internal\n */\nfunction createSubscriptionCallback<Payload>(\n store: Store<RootXStoreState>,\n commitOrDispatch: 'commit' | 'dispatch',\n mutationOrAction: string,\n payload?: Payload\n): (observableValue: WirePayload<Payload>) => void {\n const storeExecutor = store[commitOrDispatch];\n return typeof payload === 'function'\n ? wirePayload => {\n return storeExecutor(\n mutationOrAction,\n payload({\n state: store.state,\n getters: store.getters,\n ...wirePayload\n })\n );\n }\n : payload !== undefined\n ? () => {\n storeExecutor(mutationOrAction, payload);\n }\n : observableValue => {\n storeExecutor(mutationOrAction, observableValue.eventPayload);\n };\n}\n"],"names":[],"mappings":"AAaA;;;;;;;;SAQgB,sBAAsB,CACpC,EAA6C;IAE7C,OAAO,CAAC,UAAU,EAAE,KAAK,KACvB,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE;QAC9C,EAAE,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;KACvC,CAAC,CAAC;AACP,CAAC;AAuCD;SACgB,UAAU,CAAU,QAAgB,EAAE,OAAiB;IACrE,OAAO,CAAC,UAAU,EAAE,KAAK,KACvB,UAAU,CAAC,SA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;IAEjB,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC9C,OAAO,OAAO,OAAO,KAAK,UAAU;UAChC,WAAW;YACT,OAAO,aAAa,CAClB,gBAAgB,EAChB,OAAO,CAAC;gBACN,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,GAAG,WAAW;aACf,CAAC,CACH,CAAC;SACH;UACD,OAAO,KAAK,SAAS;cACrB;gBACE,aAAa,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;aAC1C;cACD,eAAe;gBACb,aAAa,CAAC,gBAAgB,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;aAC/D,CAAC;AACR;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setQuery } from '../../../store/utils/query.utils.js';
|
|
1
2
|
import { addQueryToHistory } from './actions/add-query-to-history.action.js';
|
|
2
3
|
import { loadHistoryQueriesFromBrowserStorage } from './actions/load-history-queries-from-browser-storage.action.js';
|
|
3
4
|
import { refreshSession } from './actions/refresh-session.action.js';
|
|
@@ -39,9 +40,7 @@ const historyQueriesXStoreModule = {
|
|
|
39
40
|
setSessionTimeStamp(state, sessionTimeStamp) {
|
|
40
41
|
state.sessionTimeStampInMs = sessionTimeStamp;
|
|
41
42
|
},
|
|
42
|
-
setQuery
|
|
43
|
-
state.query = query;
|
|
44
|
-
}
|
|
43
|
+
setQuery
|
|
45
44
|
},
|
|
46
45
|
actions: {
|
|
47
46
|
addQueryToHistory,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sources":["../../../../../src/x-modules/history-queries/store/module.ts"],"sourcesContent":["import { addQueryToHistory } from './actions/add-query-to-history.action';\n// eslint-disable-next-line max-len\nimport { loadHistoryQueriesFromBrowserStorage } from './actions/load-history-queries-from-browser-storage.action';\nimport { refreshSession } from './actions/refresh-session.action';\nimport { removeFromHistory } from './actions/remove-query-from-history.action';\nimport { setHistoryQueries } from './actions/set-history-queries.action';\nimport { setUrlParams } from './actions/set-url-params.action';\nimport { historyQueries } from './getters/history-queries.getter';\nimport { normalizedQuery } from './getters/normalized-query.getter';\nimport { sessionHistoryQueries } from './getters/session-history-queries.getter';\nimport { storageKey } from './getters/storage-key.getter';\nimport { HistoryQueriesXStoreModule } from './types';\n\n/**\n * {@link XStoreModule} For the history-queries module.\n *\n * @internal\n */\nexport const historyQueriesXStoreModule: HistoryQueriesXStoreModule = {\n state: () => ({\n config: {\n debounceInMs: 150,\n maxItemsToStore: 50,\n hideIfEqualsQuery: true,\n sessionTTLInMs: 30 * 60 * 1000\n },\n query: '',\n historyQueries: [],\n sessionTimeStampInMs: Date.now()\n }),\n getters: {\n historyQueries,\n normalizedQuery,\n sessionHistoryQueries,\n storageKey\n },\n mutations: {\n setHistoryQueries(state, historyQueries) {\n state.historyQueries = historyQueries;\n },\n setSessionTimeStamp(state, sessionTimeStamp) {\n state.sessionTimeStampInMs = sessionTimeStamp;\n },\n setQuery
|
|
1
|
+
{"version":3,"file":"module.js","sources":["../../../../../src/x-modules/history-queries/store/module.ts"],"sourcesContent":["import { setQuery } from '../../../store/utils/query.utils';\nimport { addQueryToHistory } from './actions/add-query-to-history.action';\n// eslint-disable-next-line max-len\nimport { loadHistoryQueriesFromBrowserStorage } from './actions/load-history-queries-from-browser-storage.action';\nimport { refreshSession } from './actions/refresh-session.action';\nimport { removeFromHistory } from './actions/remove-query-from-history.action';\nimport { setHistoryQueries } from './actions/set-history-queries.action';\nimport { setUrlParams } from './actions/set-url-params.action';\nimport { historyQueries } from './getters/history-queries.getter';\nimport { normalizedQuery } from './getters/normalized-query.getter';\nimport { sessionHistoryQueries } from './getters/session-history-queries.getter';\nimport { storageKey } from './getters/storage-key.getter';\nimport { HistoryQueriesXStoreModule } from './types';\n\n/**\n * {@link XStoreModule} For the history-queries module.\n *\n * @internal\n */\nexport const historyQueriesXStoreModule: HistoryQueriesXStoreModule = {\n state: () => ({\n config: {\n debounceInMs: 150,\n maxItemsToStore: 50,\n hideIfEqualsQuery: true,\n sessionTTLInMs: 30 * 60 * 1000\n },\n query: '',\n historyQueries: [],\n sessionTimeStampInMs: Date.now()\n }),\n getters: {\n historyQueries,\n normalizedQuery,\n sessionHistoryQueries,\n storageKey\n },\n mutations: {\n setHistoryQueries(state, historyQueries) {\n state.historyQueries = historyQueries;\n },\n setSessionTimeStamp(state, sessionTimeStamp) {\n state.sessionTimeStampInMs = sessionTimeStamp;\n },\n setQuery\n },\n actions: {\n addQueryToHistory,\n loadHistoryQueriesFromBrowserStorage,\n refreshSession,\n removeFromHistory,\n setHistoryQueries,\n setUrlParams\n }\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAcA;;;;;MAKa,0BAA0B,GAA+B;IACpE,KAAK,EAAE,OAAO;QACZ,MAAM,EAAE;YACN,YAAY,EAAE,GAAG;YACjB,eAAe,EAAE,EAAE;YACnB,iBAAiB,EAAE,IAAI;YACvB,cAAc,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;SAC/B;QACD,KAAK,EAAE,EAAE;QACT,cAAc,EAAE,EAAE;QAClB,oBAAoB,EAAE,IAAI,CAAC,GAAG,EAAE;KACjC,CAAC;IACF,OAAO,EAAE;QACP,cAAc;QACd,eAAe;QACf,qBAAqB;QACrB,UAAU;KACX;IACD,SAAS,EAAE;QACT,iBAAiB,CAAC,KAAK,EAAE,cAAc;YACrC,KAAK,CAAC,cAAc,GAAG,cAAc,CAAC;SACvC;QACD,mBAAmB,CAAC,KAAK,EAAE,gBAAgB;YACzC,KAAK,CAAC,oBAAoB,GAAG,gBAAgB,CAAC;SAC/C;QACD,QAAQ;KACT;IACD,OAAO,EAAE;QACP,iBAAiB;QACjB,oCAAoC;QACpC,cAAc;QACd,iBAAiB;QACjB,iBAAiB;QACjB,YAAY;KACb;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setQuery } from '../../../store/utils/query.utils.js';
|
|
1
2
|
import { setStatus } from '../../../store/utils/status-store.utils.js';
|
|
2
3
|
import { cancelFetchAndSaveIdentifierResults, fetchAndSaveIdentifierResults } from './actions/fetch-and-save-identifier-results.action.js';
|
|
3
4
|
import { fetchIdentifierResults } from './actions/fetch-identifier-results.action.js';
|
|
@@ -41,9 +42,7 @@ const identifierResultsXStoreModule = {
|
|
|
41
42
|
setParams(state, params) {
|
|
42
43
|
state.params = params;
|
|
43
44
|
},
|
|
44
|
-
setQuery
|
|
45
|
-
state.query = query;
|
|
46
|
-
},
|
|
45
|
+
setQuery,
|
|
47
46
|
setStatus
|
|
48
47
|
},
|
|
49
48
|
actions: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sources":["../../../../../src/x-modules/identifier-results/store/module.ts"],"sourcesContent":["import { setStatus } from '../../../store/utils/status-store.utils';\nimport {\n cancelFetchAndSaveIdentifierResults,\n fetchAndSaveIdentifierResults\n} from './actions/fetch-and-save-identifier-results.action';\nimport { fetchIdentifierResults } from './actions/fetch-identifier-results.action';\nimport { saveOrigin } from './actions/save-origin.action';\nimport { saveQuery } from './actions/save-query.action';\nimport { identifierDetectionRegexp } from './getters/identifier-detection-regexp.getter';\nimport { identifierHighlightRegexp } from './getters/identifier-highlight-regexp.getter';\nimport { identifierResultsRequest } from './getters/identifier-results-request.getter';\nimport { IdentifierResultsXStoreModule } from './types';\n\n/**\n * {@link XStoreModule} For the identifier results module.\n *\n * @internal\n */\nexport const identifierResultsXStoreModule: IdentifierResultsXStoreModule = {\n state: () => ({\n config: {\n debounceInMs: 600,\n maxItemsToRequest: 10,\n identifierDetectionRegexp: '^[0-9]{2,}$',\n separatorChars: '-/ '\n },\n identifierResults: [],\n origin: null,\n query: '',\n params: {},\n status: 'initial'\n }),\n getters: {\n identifierResultsRequest,\n identifierHighlightRegexp,\n identifierDetectionRegexp\n },\n mutations: {\n setIdentifierResults(state, identifierResults) {\n state.identifierResults = identifierResults;\n },\n setOrigin(state, origin = null) {\n state.origin = origin;\n },\n setParams(state, params) {\n state.params = params;\n },\n setQuery
|
|
1
|
+
{"version":3,"file":"module.js","sources":["../../../../../src/x-modules/identifier-results/store/module.ts"],"sourcesContent":["import { setQuery } from '../../../store/utils/query.utils';\nimport { setStatus } from '../../../store/utils/status-store.utils';\nimport {\n cancelFetchAndSaveIdentifierResults,\n fetchAndSaveIdentifierResults\n} from './actions/fetch-and-save-identifier-results.action';\nimport { fetchIdentifierResults } from './actions/fetch-identifier-results.action';\nimport { saveOrigin } from './actions/save-origin.action';\nimport { saveQuery } from './actions/save-query.action';\nimport { identifierDetectionRegexp } from './getters/identifier-detection-regexp.getter';\nimport { identifierHighlightRegexp } from './getters/identifier-highlight-regexp.getter';\nimport { identifierResultsRequest } from './getters/identifier-results-request.getter';\nimport { IdentifierResultsXStoreModule } from './types';\n\n/**\n * {@link XStoreModule} For the identifier results module.\n *\n * @internal\n */\nexport const identifierResultsXStoreModule: IdentifierResultsXStoreModule = {\n state: () => ({\n config: {\n debounceInMs: 600,\n maxItemsToRequest: 10,\n identifierDetectionRegexp: '^[0-9]{2,}$',\n separatorChars: '-/ '\n },\n identifierResults: [],\n origin: null,\n query: '',\n params: {},\n status: 'initial'\n }),\n getters: {\n identifierResultsRequest,\n identifierHighlightRegexp,\n identifierDetectionRegexp\n },\n mutations: {\n setIdentifierResults(state, identifierResults) {\n state.identifierResults = identifierResults;\n },\n setOrigin(state, origin = null) {\n state.origin = origin;\n },\n setParams(state, params) {\n state.params = params;\n },\n setQuery,\n setStatus\n },\n actions: {\n cancelFetchAndSaveIdentifierResults,\n fetchIdentifierResults,\n fetchAndSaveIdentifierResults,\n saveOrigin,\n saveQuery\n }\n};\n"],"names":[],"mappings":";;;;;;;;;;AAcA;;;;;MAKa,6BAA6B,GAAkC;IAC1E,KAAK,EAAE,OAAO;QACZ,MAAM,EAAE;YACN,YAAY,EAAE,GAAG;YACjB,iBAAiB,EAAE,EAAE;YACrB,yBAAyB,EAAE,aAAa;YACxC,cAAc,EAAE,KAAK;SACtB;QACD,iBAAiB,EAAE,EAAE;QACrB,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,SAAS;KAClB,CAAC;IACF,OAAO,EAAE;QACP,wBAAwB;QACxB,yBAAyB;QACzB,yBAAyB;KAC1B;IACD,SAAS,EAAE;QACT,oBAAoB,CAAC,KAAK,EAAE,iBAAiB;YAC3C,KAAK,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;SAC7C;QACD,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;YAC5B,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;SACvB;QACD,SAAS,CAAC,KAAK,EAAE,MAAM;YACrB,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;SACvB;QACD,QAAQ;QACR,SAAS;KACV;IACD,OAAO,EAAE;QACP,mCAAmC;QACnC,sBAAsB;QACtB,6BAA6B;QAC7B,UAAU;QACV,SAAS;KACV;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setQuery } from '../../../store/utils/query.utils.js';
|
|
1
2
|
import { setStatus } from '../../../store/utils/status-store.utils.js';
|
|
2
3
|
import { cancelFetchAndSaveNextQueries, fetchAndSaveNextQueries } from './actions/fetch-and-save-next-queries.action.js';
|
|
3
4
|
import { fetchNextQueries } from './actions/fetch-next-queries.action.js';
|
|
@@ -29,9 +30,7 @@ const nextQueriesXStoreModule = {
|
|
|
29
30
|
nextQueries
|
|
30
31
|
},
|
|
31
32
|
mutations: {
|
|
32
|
-
setQuery
|
|
33
|
-
state.query = newQuery;
|
|
34
|
-
},
|
|
33
|
+
setQuery,
|
|
35
34
|
setNextQueries(state, nextQueries) {
|
|
36
35
|
state.nextQueries = nextQueries;
|
|
37
36
|
},
|