piral-search 1.0.0-pre.2296 → 1.0.1-beta.5640
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/LICENSE +1 -1
- package/README.md +8 -2
- package/esm/Search.js +3 -3
- package/esm/Search.js.map +1 -1
- package/esm/SearchInput.js +2 -2
- package/esm/SearchInput.js.map +1 -1
- package/esm/actions.js +46 -49
- package/esm/actions.js.map +1 -1
- package/esm/components.d.ts +4 -5
- package/esm/components.js +3 -3
- package/esm/components.js.map +1 -1
- package/esm/create.js +37 -38
- package/esm/create.js.map +1 -1
- package/esm/default.js +3 -3
- package/esm/default.js.map +1 -1
- package/esm/types.d.ts +11 -3
- package/esm/useDebounce.d.ts +8 -0
- package/esm/useDebounce.js +17 -0
- package/esm/useDebounce.js.map +1 -0
- package/esm/useSearch.js +7 -6
- package/esm/useSearch.js.map +1 -1
- package/lib/Search.js +7 -6
- package/lib/Search.js.map +1 -1
- package/lib/SearchInput.js +6 -5
- package/lib/SearchInput.js.map +1 -1
- package/lib/actions.js +49 -52
- package/lib/actions.js.map +1 -1
- package/lib/components.d.ts +4 -5
- package/lib/components.js +4 -4
- package/lib/components.js.map +1 -1
- package/lib/create.js +43 -44
- package/lib/create.js.map +1 -1
- package/lib/default.js +8 -5
- package/lib/default.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/types.d.ts +11 -3
- package/lib/useDebounce.d.ts +8 -0
- package/lib/useDebounce.js +21 -0
- package/lib/useDebounce.js.map +1 -0
- package/lib/useSearch.js +8 -7
- package/lib/useSearch.js.map +1 -1
- package/package.json +27 -8
- package/piral-search.min.js +1 -0
- package/src/actions.test.ts +45 -44
- package/src/components.tsx +3 -5
- package/src/create.test.ts +16 -4
- package/src/create.ts +45 -23
- package/src/types.ts +12 -3
- package/src/useDebounce.test.ts +67 -0
- package/src/useDebounce.ts +19 -0
- package/src/useSearch.test.ts +17 -7
- package/src/useSearch.ts +2 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
[](https://piral.io)
|
|
2
2
|
|
|
3
|
-
# [Piral Search](https://piral.io) · [](https://github.com/smapiot/piral/blob/
|
|
3
|
+
# [Piral Search](https://piral.io) · [](https://github.com/smapiot/piral/blob/main/LICENSE) [](https://www.npmjs.com/package/piral-search) [](https://jestjs.io) [](https://gitter.im/piral-io/community)
|
|
4
4
|
|
|
5
5
|
This is a plugin that only has a peer dependency to `piral-core`. What `piral-search` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core` to bring enhanced search capabilities to pilets via your Piral instance.
|
|
6
6
|
|
|
@@ -10,6 +10,12 @@ By default, these API extensions are not integrated in `piral`, so you'd need to
|
|
|
10
10
|
|
|
11
11
|
In many cases the frontend should provide an extensive search functionality. If this search can or should also work in context-sensitive ways (e.g., depending on which microfrontends are loaded different search options are used or available) then this plugin might be useful. It allows pilets to register search providers which can handle search queries.
|
|
12
12
|
|
|
13
|
+
## Video
|
|
14
|
+
|
|
15
|
+
We also have a video for this plugin:
|
|
16
|
+
|
|
17
|
+
@[youtube](https://youtu.be/ik9Ixck6maI)
|
|
18
|
+
|
|
13
19
|
## Documentation
|
|
14
20
|
|
|
15
21
|
The following functions are brought to the Pilet API.
|
package/esm/Search.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useGlobalState } from 'piral-core';
|
|
3
3
|
import { PiralSearchContainer, PiralSearchResult } from './components';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
return (React.createElement(PiralSearchContainer, { loading: loading }, items.map(
|
|
4
|
+
export const Search = () => {
|
|
5
|
+
const { loading, items } = useGlobalState((m) => m.search.results);
|
|
6
|
+
return (React.createElement(PiralSearchContainer, { loading: loading }, items.map((item, i) => (React.createElement(PiralSearchResult, { key: i }, item)))));
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=Search.js.map
|
package/esm/Search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Search.js","sourceRoot":"","sources":["../src/Search.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"Search.js","sourceRoot":"","sources":["../src/Search.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,CAAC,MAAM,MAAM,GAAa,GAAG,EAAE;IACnC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEnE,OAAO,CACL,oBAAC,oBAAoB,IAAC,OAAO,EAAE,OAAO,IACnC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CACtB,oBAAC,iBAAiB,IAAC,GAAG,EAAE,CAAC,IAAG,IAAI,CAAqB,CACtD,CAAC,CACmB,CACxB,CAAC;AACJ,CAAC,CAAC"}
|
package/esm/SearchInput.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useSearch } from './useSearch';
|
|
3
3
|
import { PiralSearchInput } from './components';
|
|
4
|
-
export
|
|
5
|
-
|
|
4
|
+
export const SearchInput = () => {
|
|
5
|
+
const [value, setValue] = useSearch();
|
|
6
6
|
return React.createElement(PiralSearchInput, { setValue: setValue, value: value });
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=SearchInput.js.map
|
package/esm/SearchInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.js","sourceRoot":"","sources":["../src/SearchInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"SearchInput.js","sourceRoot":"","sources":["../src/SearchInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,CAAC,MAAM,WAAW,GAAa,GAAG,EAAE;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,SAAS,EAAE,CAAC;IACtC,OAAO,oBAAC,gBAAgB,IAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAI,CAAC;AAChE,CAAC,CAAC"}
|
package/esm/actions.js
CHANGED
|
@@ -1,83 +1,80 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { appendItems, prependItems, withKey, withoutKey } from 'piral-core';
|
|
3
2
|
function defaultFilter(_, providerNames) {
|
|
4
3
|
return providerNames;
|
|
5
4
|
}
|
|
6
|
-
export function createActions(config) {
|
|
7
|
-
|
|
8
|
-
var _a = config.emptyTrigger, emptyTrigger = _a === void 0 ? false : _a, _b = config.filter, filter = _b === void 0 ? defaultFilter : _b;
|
|
5
|
+
export function createActions(config = {}) {
|
|
6
|
+
const { emptyTrigger = false, filter = defaultFilter } = config;
|
|
9
7
|
return {
|
|
10
|
-
setSearchInput
|
|
11
|
-
ctx.dispatch(
|
|
8
|
+
setSearchInput(ctx, input) {
|
|
9
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { search: Object.assign(Object.assign({}, state.search), { input }) })));
|
|
12
10
|
},
|
|
13
|
-
triggerSearch
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var loading = results.loading;
|
|
11
|
+
triggerSearch(ctx, query, immediate = false) {
|
|
12
|
+
const providers = ctx.readState((state) => state.registry.searchProviders);
|
|
13
|
+
const { input, results } = ctx.readState((state) => state.search);
|
|
14
|
+
const { loading } = results;
|
|
18
15
|
if (query === undefined) {
|
|
19
16
|
query = input;
|
|
20
17
|
}
|
|
21
18
|
if (input !== query || !loading) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
ctx.resetSearchResults(query,
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
query
|
|
32
|
-
immediate
|
|
19
|
+
const selectedProviders = filter(query, Object.keys(providers));
|
|
20
|
+
const providerKeys = selectedProviders.filter((m) => !providers[m].onlyImmediate || immediate);
|
|
21
|
+
const acceptQuery = emptyTrigger || !!query;
|
|
22
|
+
const load = acceptQuery && providerKeys.length > 0;
|
|
23
|
+
ctx.resetSearchResults(query, load);
|
|
24
|
+
if (load) {
|
|
25
|
+
let searchCount = providerKeys.length;
|
|
26
|
+
let active = true;
|
|
27
|
+
const opts = {
|
|
28
|
+
query,
|
|
29
|
+
immediate,
|
|
33
30
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
provider.search(
|
|
37
|
-
|
|
38
|
-
},
|
|
31
|
+
providerKeys.forEach((key) => {
|
|
32
|
+
const provider = providers[key];
|
|
33
|
+
provider.search(opts).then((results) => {
|
|
34
|
+
active && ctx.appendSearchResults(results, --searchCount === 0);
|
|
35
|
+
}, (ex) => {
|
|
39
36
|
console.warn(ex);
|
|
40
|
-
|
|
37
|
+
active && --searchCount === 0 && ctx.appendSearchResults([], true);
|
|
41
38
|
});
|
|
42
39
|
});
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
ctx.appendSearchResults([],
|
|
40
|
+
return () => {
|
|
41
|
+
active = false;
|
|
42
|
+
providerKeys.forEach((key) => providers[key].cancel());
|
|
43
|
+
ctx.appendSearchResults([], load);
|
|
47
44
|
};
|
|
48
45
|
}
|
|
49
46
|
else if (!query) {
|
|
50
|
-
selectedProviders.forEach(
|
|
47
|
+
selectedProviders.forEach((key) => providers[key].clear());
|
|
51
48
|
}
|
|
52
49
|
}
|
|
53
|
-
return
|
|
50
|
+
return () => { };
|
|
54
51
|
},
|
|
55
|
-
resetSearchResults
|
|
56
|
-
ctx.dispatch(
|
|
57
|
-
input
|
|
52
|
+
resetSearchResults(ctx, input, loading) {
|
|
53
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { search: {
|
|
54
|
+
input,
|
|
58
55
|
results: {
|
|
59
|
-
loading
|
|
56
|
+
loading,
|
|
60
57
|
items: [],
|
|
61
58
|
},
|
|
62
|
-
} }))
|
|
59
|
+
} })));
|
|
63
60
|
},
|
|
64
|
-
appendSearchResults
|
|
65
|
-
ctx.dispatch(
|
|
61
|
+
appendSearchResults(ctx, items, done) {
|
|
62
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { search: Object.assign(Object.assign({}, state.search), { results: {
|
|
66
63
|
loading: !done,
|
|
67
64
|
items: appendItems(state.search.results.items, items),
|
|
68
|
-
} }) }))
|
|
65
|
+
} }) })));
|
|
69
66
|
},
|
|
70
|
-
prependSearchResults
|
|
71
|
-
ctx.dispatch(
|
|
67
|
+
prependSearchResults(ctx, items, done) {
|
|
68
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { search: Object.assign(Object.assign({}, state.search), { results: {
|
|
72
69
|
loading: !done,
|
|
73
70
|
items: prependItems(state.search.results.items, items),
|
|
74
|
-
} }) }))
|
|
71
|
+
} }) })));
|
|
75
72
|
},
|
|
76
|
-
registerSearchProvider
|
|
77
|
-
ctx.dispatch(
|
|
73
|
+
registerSearchProvider(ctx, name, value) {
|
|
74
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { searchProviders: withKey(state.registry.searchProviders, name, value) }) })));
|
|
78
75
|
},
|
|
79
|
-
unregisterSearchProvider
|
|
80
|
-
ctx.dispatch(
|
|
76
|
+
unregisterSearchProvider(ctx, name) {
|
|
77
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { searchProviders: withoutKey(state.registry.searchProviders, name) }) })));
|
|
81
78
|
},
|
|
82
79
|
};
|
|
83
80
|
}
|
package/esm/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAsB,MAAM,YAAY,CAAC;AAG5G,SAAS,aAAa,CAAC,CAAS,EAAE,aAA4B;IAC5D,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,SAA8B,EAAE;IAC5D,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,GAAG,MAAM,CAAC;IAChE,OAAO;QACL,cAAc,CAAC,GAAuB,EAAE,KAAa;YACnD,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,MAAM,kCACD,KAAK,CAAC,MAAM,KACf,KAAK,OAEP,CAAC,CAAC;QACN,CAAC;QACD,aAAa,CAAC,GAAuB,EAAE,KAAc,EAAE,SAAS,GAAG,KAAK;YACtE,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAA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AC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;qBACtD,OAEH,CAAC,CAAC;QACN,CAAC;QACD,oBAAoB,CAAC,GAAuB,EAAE,KAAwB,EAAE,IAAa;YACnF,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,MAAM,kCACD,KAAK,CAAC,MAAM,KACf,OAAO,EAAE;wBACP,OAAO,EAAE,CAAC,IAAI;wBACd,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;qBACvD,OAEH,CAAC,CAAC;QACN,CAAC;QACD,sBAAsB,CAAC,GAAuB,EAAE,IAAY,EAAE,KAAiC;YAC7F,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,QAAQ,kCACH,KAAK,CAAC,QAAQ,KACjB,eAAe,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,EAAE,KAAK,CAAC,OAEvE,CAAC,CAAC;QACN,CAAC;QACD,wBAAwB,CAAC,GAAuB,EAAE,IAAY;YAC5D,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,QAAQ,kCACH,KAAK,CAAC,QAAQ,KACjB,eAAe,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,OAEnE,CAAC,CAAC;QACN,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/esm/components.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const PiralSearchResult: React.ComponentType<SearchResultProps>;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const PiralSearchContainer: import("react").ComponentType<import("./types").SearchContainerProps>;
|
|
3
|
+
export declare const PiralSearchInput: import("react").ComponentType<import("./types").SearchInputProps>;
|
|
4
|
+
export declare const PiralSearchResult: import("react").ComponentType<import("./types").SearchResultProps>;
|
package/esm/components.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getPiralComponent } from 'piral-core';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
export const PiralSearchContainer = getPiralComponent('SearchContainer');
|
|
3
|
+
export const PiralSearchInput = getPiralComponent('SearchInput');
|
|
4
|
+
export const PiralSearchResult = getPiralComponent('SearchResult');
|
|
5
5
|
//# sourceMappingURL=components.js.map
|
package/esm/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;AACzE,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC"}
|
package/esm/create.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isfunc } from 'piral-base';
|
|
1
|
+
import { __rest } from "tslib";
|
|
3
2
|
import { isValidElement, createElement } from 'react';
|
|
4
|
-
import { buildName, withApi } from 'piral-core';
|
|
3
|
+
import { isfunc, buildName, withApi, withAll, withRootExtension, } from 'piral-core';
|
|
5
4
|
import { createActions } from './actions';
|
|
6
5
|
import { DefaultContainer, DefaultInput, DefaultResult } from './default';
|
|
6
|
+
import { Search } from './Search';
|
|
7
|
+
import { SearchInput } from './SearchInput';
|
|
7
8
|
function noop() { }
|
|
8
|
-
function createSearchRegistration(pilet, search, settings) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
onlyImmediate: onlyImmediate, cancel: isfunc(onCancel) ? onCancel : noop, clear: isfunc(onClear) ? onClear : noop, search: search });
|
|
9
|
+
function createSearchRegistration(pilet, search, settings = {}) {
|
|
10
|
+
const { onlyImmediate = false, onCancel = noop, onClear = noop } = settings, rest = __rest(settings, ["onlyImmediate", "onCancel", "onClear"]);
|
|
11
|
+
return Object.assign(Object.assign({}, rest), { pilet,
|
|
12
|
+
onlyImmediate, cancel: isfunc(onCancel) ? onCancel : noop, clear: isfunc(onClear) ? onClear : noop, search });
|
|
13
13
|
}
|
|
14
14
|
function getSearchProviders(providers) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
for (
|
|
18
|
-
|
|
19
|
-
searchProviders["global-" + i++] = createSearchRegistration(undefined, search, settings);
|
|
15
|
+
const searchProviders = {};
|
|
16
|
+
let i = 0;
|
|
17
|
+
for (const { search, settings } of providers) {
|
|
18
|
+
searchProviders[`global-${i++}`] = createSearchRegistration(undefined, search, settings);
|
|
20
19
|
}
|
|
21
20
|
return searchProviders;
|
|
22
21
|
}
|
|
@@ -25,47 +24,47 @@ function toChild(content, api, context) {
|
|
|
25
24
|
return content;
|
|
26
25
|
}
|
|
27
26
|
else {
|
|
28
|
-
|
|
27
|
+
const component = withApi(context, content, api, 'extension');
|
|
29
28
|
return createElement(component);
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
function wrapResults(result, api, context) {
|
|
33
|
-
|
|
34
|
-
return results.map(
|
|
32
|
+
const results = Array.isArray(result) ? result : [result];
|
|
33
|
+
return results.map((item) => toChild(item, api, context));
|
|
34
|
+
}
|
|
35
|
+
function withSearch(searchProviders, query, items) {
|
|
36
|
+
return (state) => (Object.assign(Object.assign({}, state), { components: Object.assign({ SearchContainer: DefaultContainer, SearchInput: DefaultInput, SearchResult: DefaultResult }, state.components), registry: Object.assign(Object.assign({}, state.registry), { searchProviders }), search: {
|
|
37
|
+
input: query,
|
|
38
|
+
results: {
|
|
39
|
+
loading: false,
|
|
40
|
+
items,
|
|
41
|
+
},
|
|
42
|
+
} }));
|
|
35
43
|
}
|
|
36
44
|
/**
|
|
37
45
|
* Creates new Pilet API extensions for search and filtering.
|
|
38
46
|
*/
|
|
39
|
-
export function createSearchApi(config) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return function (context) {
|
|
47
|
+
export function createSearchApi(config = {}) {
|
|
48
|
+
const { providers = [], results = [], query = '' } = config, actionConfig = __rest(config, ["providers", "results", "query"]);
|
|
49
|
+
return (context) => {
|
|
43
50
|
context.defineActions(createActions(actionConfig));
|
|
44
|
-
context.dispatch(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
items: results,
|
|
49
|
-
},
|
|
50
|
-
} })); });
|
|
51
|
-
return function (api, target) {
|
|
52
|
-
var pilet = target.name;
|
|
53
|
-
var next = 0;
|
|
51
|
+
context.dispatch(withAll(withSearch(getSearchProviders(providers), query, results), withRootExtension('piral-search', Search), withRootExtension('piral-search-input', SearchInput)));
|
|
52
|
+
return (api, target) => {
|
|
53
|
+
const pilet = target.name;
|
|
54
|
+
let next = 0;
|
|
54
55
|
return {
|
|
55
|
-
registerSearchProvider
|
|
56
|
+
registerSearchProvider(name, provider, settings) {
|
|
56
57
|
if (typeof name !== 'string') {
|
|
57
58
|
settings = provider;
|
|
58
59
|
provider = name;
|
|
59
60
|
name = next++;
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
context.registerSearchProvider(id, createSearchRegistration(pilet,
|
|
63
|
-
|
|
64
|
-
}, settings));
|
|
65
|
-
return function () { return api.unregisterSearchProvider(name); };
|
|
62
|
+
const id = buildName(pilet, name);
|
|
63
|
+
context.registerSearchProvider(id, createSearchRegistration(pilet, (q) => Promise.resolve(provider(q, api)).then((results) => wrapResults(results, api, context), () => []), settings));
|
|
64
|
+
return () => api.unregisterSearchProvider(name);
|
|
66
65
|
},
|
|
67
|
-
unregisterSearchProvider
|
|
68
|
-
|
|
66
|
+
unregisterSearchProvider(name) {
|
|
67
|
+
const id = buildName(pilet, name);
|
|
69
68
|
context.unregisterSearchProvider(id);
|
|
70
69
|
},
|
|
71
70
|
};
|
package/esm/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";AAAA,OAAO,EAAc,cAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EACL,MAAM,EACN,SAAS,EAGT,OAAO,EAGP,OAAO,EAEP,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAsD5C,SAAS,IAAI,KAAI,CAAC;AAElB,SAAS,wBAAwB,CAC/B,KAAa,EACb,MAAqB,EACrB,WAA2B,EAAE;IAE7B,MAAM,EAAE,aAAa,GAAG,KAAK,EAAE,QAAQ,GAAG,IAAI,EAAE,OAAO,GAAG,IAAI,KAAc,QAAQ,EAAjB,IAAI,UAAK,QAAQ,EAA9E,wCAAmE,CAAW,CAAC;IACrF,uCACK,IAAI,KACP,KAAK;QACL,aAAa,EACb,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAC1C,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC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OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CACpC,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAC/C,GAAG,EAAE,CAAC,EAAE,CACT,EACH,QAAQ,CACT,CACF,CAAC;oBACF,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;gBAClD,CAAC;gBACD,wBAAwB,CAAC,IAAI;oBAC3B,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBAClC,OAAO,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAAC;gBACvC,CAAC;aACF,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/esm/default.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { defaultRender } from 'piral-core';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
3
|
+
export const DefaultContainer = (props) => defaultRender(props.children);
|
|
4
|
+
export const DefaultResult = (props) => defaultRender(props.children);
|
|
5
|
+
export const DefaultInput = (props) => (React.createElement("input", { onChange: (e) => props.setValue(e.target.value), value: props.value }));
|
|
6
6
|
//# sourceMappingURL=default.js.map
|
package/esm/default.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../src/default.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../src/default.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,MAAM,CAAC,MAAM,gBAAgB,GAAmC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACzG,MAAM,CAAC,MAAM,aAAa,GAAgC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACnG,MAAM,CAAC,MAAM,YAAY,GAA+B,CAAC,KAAK,EAAE,EAAE,CAAC,CACjE,+BAAO,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAI,CAC/E,CAAC"}
|
package/esm/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactChild, ComponentType, ReactElement } from 'react';
|
|
2
|
-
import { Dict, Disposable, PiletApi, BaseRegistration, AnyComponent, BaseComponentProps, RegistrationDisposer } from 'piral-core';
|
|
1
|
+
import type { ReactChild, ComponentType, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type { Dict, Disposable, PiletApi, BaseRegistration, AnyComponent, BaseComponentProps, RegistrationDisposer } from 'piral-core';
|
|
3
3
|
declare module 'piral-core/lib/types/custom' {
|
|
4
4
|
interface PiletCustomApi extends PiletSearchApi {
|
|
5
5
|
}
|
|
@@ -77,6 +77,10 @@ export interface SearchContainerProps {
|
|
|
77
77
|
* Gets if the results are still gathered.
|
|
78
78
|
*/
|
|
79
79
|
loading: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The search to display.
|
|
82
|
+
*/
|
|
83
|
+
children?: ReactNode;
|
|
80
84
|
}
|
|
81
85
|
export interface SearchInputProps {
|
|
82
86
|
setValue(value: string): void;
|
|
@@ -85,8 +89,12 @@ export interface SearchInputProps {
|
|
|
85
89
|
export interface SearchResultComponentProps extends BaseComponentProps {
|
|
86
90
|
}
|
|
87
91
|
export interface SearchResultProps {
|
|
92
|
+
/**
|
|
93
|
+
* The search results to display.
|
|
94
|
+
*/
|
|
95
|
+
children?: ReactNode;
|
|
88
96
|
}
|
|
89
|
-
export
|
|
97
|
+
export type SearchResultType = string | ReactElement<any> | AnyComponent<SearchResultComponentProps>;
|
|
90
98
|
export interface SearchProvider {
|
|
91
99
|
(options: SearchOptions, api: PiletApi): Promise<SearchResultType | Array<SearchResultType>>;
|
|
92
100
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook that returns the debounced (i.e., delayed) value.
|
|
3
|
+
* Useful when user input should not fire immediately, but rather
|
|
4
|
+
* only after a certain timespan without any changes passed.
|
|
5
|
+
* @param value The value to consider.
|
|
6
|
+
* @param delay The timespan to pass before applying the value.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useDebounce<T>(value: T, delay?: number): T;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Hook that returns the debounced (i.e., delayed) value.
|
|
4
|
+
* Useful when user input should not fire immediately, but rather
|
|
5
|
+
* only after a certain timespan without any changes passed.
|
|
6
|
+
* @param value The value to consider.
|
|
7
|
+
* @param delay The timespan to pass before applying the value.
|
|
8
|
+
*/
|
|
9
|
+
export function useDebounce(value, delay = 300) {
|
|
10
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
13
|
+
return () => clearTimeout(handler);
|
|
14
|
+
}, [value, delay]);
|
|
15
|
+
return debouncedValue;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=useDebounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebounce.js","sourceRoot":"","sources":["../src/useDebounce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAI,KAAQ,EAAE,KAAK,GAAG,GAAG;IAClD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5D,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;QAClE,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAEnB,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
package/esm/useSearch.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
|
-
import { useGlobalState,
|
|
2
|
+
import { useGlobalState, useActions } from 'piral-core';
|
|
3
|
+
import { useDebounce } from './useDebounce';
|
|
3
4
|
/**
|
|
4
5
|
* Hook that yields the possibility of searching in Piral.
|
|
5
6
|
* Returns the current (live, i.e., non-debounced) input value
|
|
@@ -11,11 +12,11 @@ import { useGlobalState, useDebounce, useActions } from 'piral-core';
|
|
|
11
12
|
* @param delay The delay [ms] to be used for the debounce.
|
|
12
13
|
*/
|
|
13
14
|
export function useSearch(delay) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
useEffect(
|
|
15
|
+
const { setSearchInput, triggerSearch } = useActions();
|
|
16
|
+
const searchInput = useGlobalState((m) => m.search.input);
|
|
17
|
+
const query = useDebounce(searchInput, delay);
|
|
18
|
+
const cancel = useRef(undefined);
|
|
19
|
+
useEffect(() => {
|
|
19
20
|
cancel.current && cancel.current();
|
|
20
21
|
cancel.current = triggerSearch(query, false);
|
|
21
22
|
}, [query]);
|
package/esm/useSearch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSearch.js","sourceRoot":"","sources":["../src/useSearch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"useSearch.js","sourceRoot":"","sources":["../src/useSearch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAc,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,UAAU,EAAE,CAAC;IACvD,MAAM,WAAW,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,MAAM,CAAa,SAAS,CAAC,CAAC;IAE7C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnC,MAAM,CAAC,OAAO,GAAG,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;AACvC,CAAC"}
|
package/lib/Search.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Search = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return (React.createElement(components_1.PiralSearchContainer, { loading: loading }, items.map(
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const piral_core_1 = require("piral-core");
|
|
6
|
+
const components_1 = require("./components");
|
|
7
|
+
const Search = () => {
|
|
8
|
+
const { loading, items } = (0, piral_core_1.useGlobalState)((m) => m.search.results);
|
|
9
|
+
return (React.createElement(components_1.PiralSearchContainer, { loading: loading }, items.map((item, i) => (React.createElement(components_1.PiralSearchResult, { key: i }, item)))));
|
|
10
10
|
};
|
|
11
|
+
exports.Search = Search;
|
|
11
12
|
//# sourceMappingURL=Search.js.map
|
package/lib/Search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Search.js","sourceRoot":"","sources":["../src/Search.tsx"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"Search.js","sourceRoot":"","sources":["../src/Search.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2CAA4C;AAC5C,6CAAuE;AAEhE,MAAM,MAAM,GAAa,GAAG,EAAE;IACnC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,IAAA,2BAAc,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEnE,OAAO,CACL,oBAAC,iCAAoB,IAAC,OAAO,EAAE,OAAO,IACnC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CACtB,oBAAC,8BAAiB,IAAC,GAAG,EAAE,CAAC,IAAG,IAAI,CAAqB,CACtD,CAAC,CACmB,CACxB,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,MAAM,UAUjB"}
|
package/lib/SearchInput.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SearchInput = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const useSearch_1 = require("./useSearch");
|
|
6
|
+
const components_1 = require("./components");
|
|
7
|
+
const SearchInput = () => {
|
|
8
|
+
const [value, setValue] = (0, useSearch_1.useSearch)();
|
|
9
9
|
return React.createElement(components_1.PiralSearchInput, { setValue: setValue, value: value });
|
|
10
10
|
};
|
|
11
|
+
exports.SearchInput = SearchInput;
|
|
11
12
|
//# sourceMappingURL=SearchInput.js.map
|
package/lib/SearchInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.js","sourceRoot":"","sources":["../src/SearchInput.tsx"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"SearchInput.js","sourceRoot":"","sources":["../src/SearchInput.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2CAAwC;AACxC,6CAAgD;AAEzC,MAAM,WAAW,GAAa,GAAG,EAAE;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,qBAAS,GAAE,CAAC;IACtC,OAAO,oBAAC,6BAAgB,IAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAI,CAAC;AAChE,CAAC,CAAC;AAHW,QAAA,WAAW,eAGtB"}
|