piral-search 1.6.0-beta.7240 → 1.6.0-beta.7243

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/lib/Search.js +6 -10
  2. package/lib/Search.js.map +1 -1
  3. package/lib/SearchInput.js +6 -10
  4. package/lib/SearchInput.js.map +1 -1
  5. package/lib/actions.js +6 -10
  6. package/lib/actions.js.map +1 -1
  7. package/lib/components.js +4 -7
  8. package/lib/components.js.map +1 -1
  9. package/lib/create.js +19 -23
  10. package/lib/create.js.map +1 -1
  11. package/lib/default.js +5 -11
  12. package/lib/default.js.map +1 -1
  13. package/lib/index.js +6 -9
  14. package/lib/index.js.map +1 -1
  15. package/lib/types.js +1 -2
  16. package/lib/useDebounce.js +4 -8
  17. package/lib/useDebounce.js.map +1 -1
  18. package/lib/useSearch.js +9 -13
  19. package/lib/useSearch.js.map +1 -1
  20. package/package.json +8 -22
  21. package/esm/Search.d.ts +0 -2
  22. package/esm/Search.js +0 -8
  23. package/esm/Search.js.map +0 -1
  24. package/esm/SearchInput.d.ts +0 -2
  25. package/esm/SearchInput.js +0 -8
  26. package/esm/SearchInput.js.map +0 -1
  27. package/esm/actions.d.ts +0 -12
  28. package/esm/actions.js +0 -114
  29. package/esm/actions.js.map +0 -1
  30. package/esm/components.d.ts +0 -4
  31. package/esm/components.js +0 -5
  32. package/esm/components.js.map +0 -1
  33. package/esm/create.d.ts +0 -49
  34. package/esm/create.js +0 -92
  35. package/esm/create.js.map +0 -1
  36. package/esm/default.d.ts +0 -5
  37. package/esm/default.js +0 -6
  38. package/esm/default.js.map +0 -1
  39. package/esm/index.d.ts +0 -6
  40. package/esm/index.js +0 -7
  41. package/esm/index.js.map +0 -1
  42. package/esm/types.d.ts +0 -196
  43. package/esm/types.js +0 -2
  44. package/esm/types.js.map +0 -1
  45. package/esm/useDebounce.d.ts +0 -8
  46. package/esm/useDebounce.js +0 -17
  47. package/esm/useDebounce.js.map +0 -1
  48. package/esm/useSearch.d.ts +0 -11
  49. package/esm/useSearch.js +0 -25
  50. package/esm/useSearch.js.map +0 -1
package/lib/Search.js CHANGED
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Search = void 0;
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)))));
1
+ import * as React from 'react';
2
+ import { useGlobalState } from 'piral-core';
3
+ import { PiralSearchContainer, PiralSearchResult } from './components';
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)))));
10
7
  };
11
- exports.Search = Search;
12
8
  //# 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,+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"}
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"}
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SearchInput = void 0;
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
- return React.createElement(components_1.PiralSearchInput, { setValue: setValue, value: value });
1
+ import * as React from 'react';
2
+ import { useSearch } from './useSearch';
3
+ import { PiralSearchInput } from './components';
4
+ export const SearchInput = () => {
5
+ const [value, setValue] = useSearch();
6
+ return React.createElement(PiralSearchInput, { setValue: setValue, value: value });
10
7
  };
11
- exports.SearchInput = SearchInput;
12
8
  //# sourceMappingURL=SearchInput.js.map
@@ -1 +1 @@
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"}
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/lib/actions.js CHANGED
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createActions = void 0;
4
- const piral_core_1 = require("piral-core");
1
+ import { appendItems, prependItems, withKey, withoutKey } from 'piral-core';
5
2
  function defaultFilter(_, providerNames) {
6
3
  return providerNames;
7
4
  }
8
- function createActions(config = {}) {
5
+ export function createActions(config = {}) {
9
6
  const { emptyTrigger = false, filter = defaultFilter } = config;
10
7
  return {
11
8
  setSearchInput(ctx, input) {
@@ -77,7 +74,7 @@ function createActions(config = {}) {
77
74
  ...state.search,
78
75
  results: {
79
76
  loading: !done,
80
- items: (0, piral_core_1.appendItems)(state.search.results.items, items),
77
+ items: appendItems(state.search.results.items, items),
81
78
  },
82
79
  },
83
80
  }));
@@ -89,7 +86,7 @@ function createActions(config = {}) {
89
86
  ...state.search,
90
87
  results: {
91
88
  loading: !done,
92
- items: (0, piral_core_1.prependItems)(state.search.results.items, items),
89
+ items: prependItems(state.search.results.items, items),
93
90
  },
94
91
  },
95
92
  }));
@@ -99,7 +96,7 @@ function createActions(config = {}) {
99
96
  ...state,
100
97
  registry: {
101
98
  ...state.registry,
102
- searchProviders: (0, piral_core_1.withKey)(state.registry.searchProviders, name, value),
99
+ searchProviders: withKey(state.registry.searchProviders, name, value),
103
100
  },
104
101
  }));
105
102
  },
@@ -108,11 +105,10 @@ function createActions(config = {}) {
108
105
  ...state,
109
106
  registry: {
110
107
  ...state.registry,
111
- searchProviders: (0, piral_core_1.withoutKey)(state.registry.searchProviders, name),
108
+ searchProviders: withoutKey(state.registry.searchProviders, name),
112
109
  },
113
110
  }));
114
111
  },
115
112
  };
116
113
  }
117
- exports.createActions = createActions;
118
114
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";;;AACA,2CAA4G;AAG5G,SAAS,aAAa,CAAC,CAAS,EAAE,aAA4B;IAC5D,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAgB,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,CAAC;gBACvB,GAAG,KAAK;gBACR,MAAM,EAAE;oBACN,GAAG,KAAK,CAAC,MAAM;oBACf,KAAK;iBACN;aACF,CAAC,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,CAAC,QAAQ,C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;QACN,CAAC;QACD,sBAAsB,CAAC,GAAuB,EAAE,IAAY,EAAE,KAAiC;YAC7F,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACvB,GAAG,KAAK;gBACR,QAAQ,EAAE;oBACR,GAAG,KAAK,CAAC,QAAQ;oBACjB,eAAe,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,EAAE,KAAK,CAAC;iBACtE;aACF,CAAC,CAAC,CAAC;QACN,CAAC;QACD,wBAAwB,CAAC,GAAuB,EAAE,IAAY;YAC5D,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACvB,GAAG,KAAK;gBACR,QAAQ,EAAE;oBACR,GAAG,KAAK,CAAC,QAAQ;oBACjB,eAAe,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC;iBAClE;aACF,CAAC,CAAC,CAAC;QACN,CAAC;KACF,CAAC;AACJ,CAAC"}
package/lib/components.js CHANGED
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PiralSearchResult = exports.PiralSearchInput = exports.PiralSearchContainer = void 0;
4
- const piral_core_1 = require("piral-core");
5
- exports.PiralSearchContainer = (0, piral_core_1.getPiralComponent)('SearchContainer');
6
- exports.PiralSearchInput = (0, piral_core_1.getPiralComponent)('SearchInput');
7
- exports.PiralSearchResult = (0, piral_core_1.getPiralComponent)('SearchResult');
1
+ import { getPiralComponent } from 'piral-core';
2
+ export const PiralSearchContainer = getPiralComponent('SearchContainer');
3
+ export const PiralSearchInput = getPiralComponent('SearchInput');
4
+ export const PiralSearchResult = getPiralComponent('SearchResult');
8
5
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":";;;AAAA,2CAA+C;AAElC,QAAA,oBAAoB,GAAG,IAAA,8BAAiB,EAAC,iBAAiB,CAAC,CAAC;AAC5D,QAAA,gBAAgB,GAAG,IAAA,8BAAiB,EAAC,aAAa,CAAC,CAAC;AACpD,QAAA,iBAAiB,GAAG,IAAA,8BAAiB,EAAC,cAAc,CAAC,CAAC"}
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/lib/create.js CHANGED
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSearchApi = void 0;
4
- const react_1 = require("react");
5
- const piral_core_1 = require("piral-core");
6
- const actions_1 = require("./actions");
7
- const default_1 = require("./default");
8
- const Search_1 = require("./Search");
9
- const SearchInput_1 = require("./SearchInput");
1
+ import { isValidElement, createElement } from 'react';
2
+ import { isfunc, buildName, withApi, withAll, withRootExtension, } from 'piral-core';
3
+ import { createActions } from './actions';
4
+ import { DefaultContainer, DefaultInput, DefaultResult } from './default';
5
+ import { Search } from './Search';
6
+ import { SearchInput } from './SearchInput';
10
7
  function noop() { }
11
8
  function createSearchRegistration(pilet, search, settings = {}) {
12
9
  const { onlyImmediate = false, onCancel = noop, onClear = noop, ...rest } = settings;
@@ -14,8 +11,8 @@ function createSearchRegistration(pilet, search, settings = {}) {
14
11
  ...rest,
15
12
  pilet,
16
13
  onlyImmediate,
17
- cancel: (0, piral_core_1.isfunc)(onCancel) ? onCancel : noop,
18
- clear: (0, piral_core_1.isfunc)(onClear) ? onClear : noop,
14
+ cancel: isfunc(onCancel) ? onCancel : noop,
15
+ clear: isfunc(onClear) ? onClear : noop,
19
16
  search,
20
17
  };
21
18
  }
@@ -28,12 +25,12 @@ function getSearchProviders(providers) {
28
25
  return searchProviders;
29
26
  }
30
27
  function toChild(content, api, context) {
31
- if (typeof content === 'string' || (0, react_1.isValidElement)(content)) {
28
+ if (typeof content === 'string' || isValidElement(content)) {
32
29
  return content;
33
30
  }
34
31
  else {
35
- const component = (0, piral_core_1.withApi)(context, content, api, 'extension');
36
- return (0, react_1.createElement)(component);
32
+ const component = withApi(context, content, api, 'extension');
33
+ return createElement(component);
37
34
  }
38
35
  }
39
36
  function wrapResults(result, api, context) {
@@ -44,9 +41,9 @@ function withSearch(searchProviders, query, items) {
44
41
  return (state) => ({
45
42
  ...state,
46
43
  components: {
47
- SearchContainer: default_1.DefaultContainer,
48
- SearchInput: default_1.DefaultInput,
49
- SearchResult: default_1.DefaultResult,
44
+ SearchContainer: DefaultContainer,
45
+ SearchInput: DefaultInput,
46
+ SearchResult: DefaultResult,
50
47
  ...state.components,
51
48
  },
52
49
  registry: {
@@ -65,11 +62,11 @@ function withSearch(searchProviders, query, items) {
65
62
  /**
66
63
  * Creates new Pilet API extensions for search and filtering.
67
64
  */
68
- function createSearchApi(config = {}) {
65
+ export function createSearchApi(config = {}) {
69
66
  const { providers = [], results = [], query = '', ...actionConfig } = config;
70
67
  return (context) => {
71
- context.defineActions((0, actions_1.createActions)(actionConfig));
72
- context.dispatch((0, piral_core_1.withAll)(withSearch(getSearchProviders(providers), query, results), (0, piral_core_1.withRootExtension)('piral-search', Search_1.Search), (0, piral_core_1.withRootExtension)('piral-search-input', SearchInput_1.SearchInput)));
68
+ context.defineActions(createActions(actionConfig));
69
+ context.dispatch(withAll(withSearch(getSearchProviders(providers), query, results), withRootExtension('piral-search', Search), withRootExtension('piral-search-input', SearchInput)));
73
70
  return (api, target) => {
74
71
  const pilet = target.name;
75
72
  let next = 0;
@@ -80,17 +77,16 @@ function createSearchApi(config = {}) {
80
77
  provider = name;
81
78
  name = next++;
82
79
  }
83
- const id = (0, piral_core_1.buildName)(pilet, name);
80
+ const id = buildName(pilet, name);
84
81
  context.registerSearchProvider(id, createSearchRegistration(pilet, (q) => Promise.resolve(provider(q, api)).then((results) => wrapResults(results, api, context), () => []), settings));
85
82
  return () => api.unregisterSearchProvider(name);
86
83
  },
87
84
  unregisterSearchProvider(name) {
88
- const id = (0, piral_core_1.buildName)(pilet, name);
85
+ const id = buildName(pilet, name);
89
86
  context.unregisterSearchProvider(id);
90
87
  },
91
88
  };
92
89
  };
93
90
  };
94
91
  }
95
- exports.createSearchApi = createSearchApi;
96
92
  //# sourceMappingURL=create.js.map
package/lib/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;AAAA,iCAAkE;AAClE,2CAWoB;AACpB,uCAA0C;AAC1C,uCAA0E;AAC1E,qCAAkC;AAClC,+CAA4C;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,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC;IACrF,OAAO;QACL,GAAG,IAAI;QACP,KAAK;QACL,aAAa;QACb,MAAM,EAAE,IAAA,mBAAM,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI;QAC1C,KAAK,EAAE,IAAA,mBAAM,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;QACvC,MAAM;KACP,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,SAAuC;IACjE,MAAM,eAAe,GAAqC,EAAE,CAAC;IAC7D,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,KAAK,MAAM,E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,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBAClC,OAAO,CAAC,sBAAsB,CAC5B,EAAE,EACF,wBAAwB,CACtB,KAAK,EACL,CAAC,CAAC,EAAE,EAAE,CACJ,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/lib/default.js CHANGED
@@ -1,12 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultInput = exports.DefaultResult = exports.DefaultContainer = void 0;
4
- const React = require("react");
5
- const piral_core_1 = require("piral-core");
6
- const DefaultContainer = (props) => (0, piral_core_1.defaultRender)(props.children);
7
- exports.DefaultContainer = DefaultContainer;
8
- const DefaultResult = (props) => (0, piral_core_1.defaultRender)(props.children);
9
- exports.DefaultResult = DefaultResult;
10
- const DefaultInput = (props) => (React.createElement("input", { onChange: (e) => props.setValue(e.target.value), value: props.value }));
11
- exports.DefaultInput = DefaultInput;
1
+ import * as React from 'react';
2
+ import { defaultRender } from 'piral-core';
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 }));
12
6
  //# sourceMappingURL=default.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"default.js","sourceRoot":"","sources":["../src/default.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2CAA2C;AAGpC,MAAM,gBAAgB,GAAmC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,0BAAa,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAA5F,QAAA,gBAAgB,oBAA4E;AAClG,MAAM,aAAa,GAAgC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,0BAAa,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAAtF,QAAA,aAAa,iBAAyE;AAC5F,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;AAFW,QAAA,YAAY,gBAEvB"}
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/lib/index.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./create"), exports);
5
- tslib_1.__exportStar(require("./components"), exports);
6
- tslib_1.__exportStar(require("./SearchInput"), exports);
7
- tslib_1.__exportStar(require("./Search"), exports);
8
- tslib_1.__exportStar(require("./types"), exports);
9
- tslib_1.__exportStar(require("./useSearch"), exports);
1
+ export * from './create';
2
+ export * from './components';
3
+ export * from './SearchInput';
4
+ export * from './Search';
5
+ export * from './types';
6
+ export * from './useSearch';
10
7
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,uDAA6B;AAC7B,wDAA8B;AAC9B,mDAAyB;AACzB,kDAAwB;AACxB,sDAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
package/lib/types.js CHANGED
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=types.js.map
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useDebounce = void 0;
4
- const react_1 = require("react");
1
+ import { useState, useEffect } from 'react';
5
2
  /**
6
3
  * Hook that returns the debounced (i.e., delayed) value.
7
4
  * Useful when user input should not fire immediately, but rather
@@ -9,13 +6,12 @@ const react_1 = require("react");
9
6
  * @param value The value to consider.
10
7
  * @param delay The timespan to pass before applying the value.
11
8
  */
12
- function useDebounce(value, delay = 300) {
13
- const [debouncedValue, setDebouncedValue] = (0, react_1.useState)(value);
14
- (0, react_1.useEffect)(() => {
9
+ export function useDebounce(value, delay = 300) {
10
+ const [debouncedValue, setDebouncedValue] = useState(value);
11
+ useEffect(() => {
15
12
  const handler = setTimeout(() => setDebouncedValue(value), delay);
16
13
  return () => clearTimeout(handler);
17
14
  }, [value, delay]);
18
15
  return debouncedValue;
19
16
  }
20
- exports.useDebounce = useDebounce;
21
17
  //# sourceMappingURL=useDebounce.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDebounce.js","sourceRoot":"","sources":["../src/useDebounce.ts"],"names":[],"mappings":";;;AAAA,iCAA4C;AAE5C;;;;;;GAMG;AACH,SAAgB,WAAW,CAAI,KAAQ,EAAE,KAAK,GAAG,GAAG;IAClD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAE5D,IAAA,iBAAS,EAAC,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;AATD,kCASC"}
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/lib/useSearch.js CHANGED
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSearch = void 0;
4
- const react_1 = require("react");
5
- const piral_core_1 = require("piral-core");
6
- const useDebounce_1 = require("./useDebounce");
1
+ import { useEffect, useRef } from 'react';
2
+ import { useGlobalState, useActions } from 'piral-core';
3
+ import { useDebounce } from './useDebounce';
7
4
  /**
8
5
  * Hook that yields the possibility of searching in Piral.
9
6
  * Returns the current (live, i.e., non-debounced) input value
@@ -14,16 +11,15 @@ const useDebounce_1 = require("./useDebounce");
14
11
  * will be integrated as they arrive.
15
12
  * @param delay The delay [ms] to be used for the debounce.
16
13
  */
17
- function useSearch(delay) {
18
- const { setSearchInput, triggerSearch } = (0, piral_core_1.useActions)();
19
- const searchInput = (0, piral_core_1.useGlobalState)((m) => m.search.input);
20
- const query = (0, useDebounce_1.useDebounce)(searchInput, delay);
21
- const cancel = (0, react_1.useRef)(undefined);
22
- (0, react_1.useEffect)(() => {
14
+ export function useSearch(delay) {
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(() => {
23
20
  cancel.current && cancel.current();
24
21
  cancel.current = triggerSearch(query, false);
25
22
  }, [query]);
26
23
  return [searchInput, setSearchInput];
27
24
  }
28
- exports.useSearch = useSearch;
29
25
  //# sourceMappingURL=useSearch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSearch.js","sourceRoot":"","sources":["../src/useSearch.ts"],"names":[],"mappings":";;;AAAA,iCAA0C;AAC1C,2CAAoE;AACpE,+CAA4C;AAE5C;;;;;;;;;GASG;AACH,SAAgB,SAAS,CAAC,KAAc;IACtC,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,IAAA,uBAAU,GAAE,CAAC;IACvD,MAAM,WAAW,GAAG,IAAA,2BAAc,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,IAAA,yBAAW,EAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,IAAA,cAAM,EAAa,SAAS,CAAC,CAAC;IAE7C,IAAA,iBAAS,EAAC,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;AAZD,8BAYC"}
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-search",
3
- "version": "1.6.0-beta.7240",
3
+ "version": "1.6.0-beta.7243",
4
4
  "description": "Plugin for centralizing search in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -17,29 +17,16 @@
17
17
  "author": "smapiot",
18
18
  "homepage": "https://piral.io",
19
19
  "license": "MIT",
20
- "module": "esm/index.js",
20
+ "module": "lib/index.js",
21
21
  "main": "lib/index.js",
22
22
  "typings": "lib/index.d.ts",
23
23
  "exports": {
24
- ".": {
25
- "import": "./esm/index.js",
26
- "require": "./lib/index.js"
27
- },
28
- "./esm/*": {
29
- "import": "./esm/*"
30
- },
31
- "./lib/*": {
32
- "require": "./lib/*"
33
- },
34
- "./_/*": {
35
- "import": "./esm/*.js",
36
- "require": "./lib/*.js"
37
- },
24
+ ".": "./lib/index.js",
25
+ "./lib/*": "./lib/*",
38
26
  "./package.json": "./package.json"
39
27
  },
40
28
  "sideEffects": false,
41
29
  "files": [
42
- "esm",
43
30
  "lib",
44
31
  "src",
45
32
  "piral-search.min.js"
@@ -53,17 +40,16 @@
53
40
  },
54
41
  "scripts": {
55
42
  "cleanup": "rimraf esm lib piral-search.min.js",
56
- "build": "yarn build:bundle && yarn build:commonjs && yarn build:esnext",
43
+ "build": "yarn build:bundle && yarn build:esnext",
57
44
  "build:bundle": "esbuild src/index.ts --outfile=piral-search.min.js --bundle --external:piral-core --external:react --minify --global-name=piralSearch",
58
- "build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs",
59
- "build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext",
45
+ "build:esnext": "tsc --project tsconfig.json --outDir lib --module esnext",
60
46
  "typedoc": "typedoc --json ../../../docs/types/piral-search.json src --exclude \"src/**/*.test.*\"",
61
47
  "test": "echo \"Error: run tests from root\" && exit 1"
62
48
  },
63
49
  "devDependencies": {
64
50
  "@types/react": "^18.0.0",
65
- "piral-core": "1.6.0-beta.7240",
51
+ "piral-core": "1.6.0-beta.7243",
66
52
  "react": "^18.0.0"
67
53
  },
68
- "gitHead": "2fd8ff47d9a7e0666e4e6bc1dc5a7ef45e8e9f39"
54
+ "gitHead": "bbb6e4f78c61b6ef753099a5b378ad2708565ce3"
69
55
  }
package/esm/Search.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import * as React from 'react';
2
- export declare const Search: React.FC;
package/esm/Search.js DELETED
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- import { useGlobalState } from 'piral-core';
3
- import { PiralSearchContainer, PiralSearchResult } from './components';
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
- };
8
- //# sourceMappingURL=Search.js.map
package/esm/Search.js.map DELETED
@@ -1 +0,0 @@
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"}
@@ -1,2 +0,0 @@
1
- import * as React from 'react';
2
- export declare const SearchInput: React.FC;
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- import { useSearch } from './useSearch';
3
- import { PiralSearchInput } from './components';
4
- export const SearchInput = () => {
5
- const [value, setValue] = useSearch();
6
- return React.createElement(PiralSearchInput, { setValue: setValue, value: value });
7
- };
8
- //# sourceMappingURL=SearchInput.js.map
@@ -1 +0,0 @@
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.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import { ReactChild } from 'react';
2
- import { Disposable, GlobalStateContext } from 'piral-core';
3
- import { SearchProviderRegistration, SearchActionsConfig } from './types';
4
- export declare function createActions(config?: SearchActionsConfig): {
5
- setSearchInput(ctx: GlobalStateContext, input: string): void;
6
- triggerSearch(ctx: GlobalStateContext, query?: string, immediate?: boolean): Disposable;
7
- resetSearchResults(ctx: GlobalStateContext, input: string, loading: boolean): void;
8
- appendSearchResults(ctx: GlobalStateContext, items: Array<ReactChild>, done: boolean): void;
9
- prependSearchResults(ctx: GlobalStateContext, items: Array<ReactChild>, done: boolean): void;
10
- registerSearchProvider(ctx: GlobalStateContext, name: string, value: SearchProviderRegistration): void;
11
- unregisterSearchProvider(ctx: GlobalStateContext, name: string): void;
12
- };
package/esm/actions.js DELETED
@@ -1,114 +0,0 @@
1
- import { appendItems, prependItems, withKey, withoutKey } from 'piral-core';
2
- function defaultFilter(_, providerNames) {
3
- return providerNames;
4
- }
5
- export function createActions(config = {}) {
6
- const { emptyTrigger = false, filter = defaultFilter } = config;
7
- return {
8
- setSearchInput(ctx, input) {
9
- ctx.dispatch((state) => ({
10
- ...state,
11
- search: {
12
- ...state.search,
13
- input,
14
- },
15
- }));
16
- },
17
- triggerSearch(ctx, query, immediate = false) {
18
- const providers = ctx.readState((state) => state.registry.searchProviders);
19
- const { input, results } = ctx.readState((state) => state.search);
20
- const { loading } = results;
21
- if (query === undefined) {
22
- query = input;
23
- }
24
- if (input !== query || !loading) {
25
- const selectedProviders = filter(query, Object.keys(providers));
26
- const providerKeys = selectedProviders.filter((m) => !providers[m].onlyImmediate || immediate);
27
- const acceptQuery = emptyTrigger || !!query;
28
- const load = acceptQuery && providerKeys.length > 0;
29
- ctx.resetSearchResults(query, load);
30
- if (load) {
31
- let searchCount = providerKeys.length;
32
- let active = true;
33
- const opts = {
34
- query,
35
- immediate,
36
- };
37
- providerKeys.forEach((key) => {
38
- const provider = providers[key];
39
- provider.search(opts).then((results) => {
40
- active && ctx.appendSearchResults(results, --searchCount === 0);
41
- }, (ex) => {
42
- console.warn(ex);
43
- active && --searchCount === 0 && ctx.appendSearchResults([], true);
44
- });
45
- });
46
- return () => {
47
- active = false;
48
- providerKeys.forEach((key) => providers[key].cancel());
49
- ctx.appendSearchResults([], load);
50
- };
51
- }
52
- else if (!query) {
53
- selectedProviders.forEach((key) => providers[key].clear());
54
- }
55
- }
56
- return () => { };
57
- },
58
- resetSearchResults(ctx, input, loading) {
59
- ctx.dispatch((state) => ({
60
- ...state,
61
- search: {
62
- input,
63
- results: {
64
- loading,
65
- items: [],
66
- },
67
- },
68
- }));
69
- },
70
- appendSearchResults(ctx, items, done) {
71
- ctx.dispatch((state) => ({
72
- ...state,
73
- search: {
74
- ...state.search,
75
- results: {
76
- loading: !done,
77
- items: appendItems(state.search.results.items, items),
78
- },
79
- },
80
- }));
81
- },
82
- prependSearchResults(ctx, items, done) {
83
- ctx.dispatch((state) => ({
84
- ...state,
85
- search: {
86
- ...state.search,
87
- results: {
88
- loading: !done,
89
- items: prependItems(state.search.results.items, items),
90
- },
91
- },
92
- }));
93
- },
94
- registerSearchProvider(ctx, name, value) {
95
- ctx.dispatch((state) => ({
96
- ...state,
97
- registry: {
98
- ...state.registry,
99
- searchProviders: withKey(state.registry.searchProviders, name, value),
100
- },
101
- }));
102
- },
103
- unregisterSearchProvider(ctx, name) {
104
- ctx.dispatch((state) => ({
105
- ...state,
106
- registry: {
107
- ...state.registry,
108
- searchProviders: withoutKey(state.registry.searchProviders, name),
109
- },
110
- }));
111
- },
112
- };
113
- }
114
- //# sourceMappingURL=actions.js.map
@@ -1 +0,0 @@
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,GAA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;aACF,CAAC,CAAC,CAAC;QACN,CAAC;QACD,wBAAwB,CAAC,GAAuB,EAAE,IAAY;YAC5D,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACvB,GAAG,KAAK;gBACR,QAAQ,EAAE;oBACR,GAAG,KAAK,CAAC,QAAQ;oBACjB,eAAe,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC;iBAClE;aACF,CAAC,CAAC,CAAC;QACN,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,4 +0,0 @@
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 DELETED
@@ -1,5 +0,0 @@
1
- import { getPiralComponent } from 'piral-core';
2
- export const PiralSearchContainer = getPiralComponent('SearchContainer');
3
- export const PiralSearchInput = getPiralComponent('SearchInput');
4
- export const PiralSearchResult = getPiralComponent('SearchResult');
5
- //# sourceMappingURL=components.js.map
@@ -1 +0,0 @@
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.d.ts DELETED
@@ -1,49 +0,0 @@
1
- import { ReactChild } from 'react';
2
- import { PiralPlugin } from 'piral-core';
3
- import { PiletSearchApi, SearchSettings, SearchHandler, SearchActionsConfig } from './types';
4
- export interface InitialSearchProvider {
5
- /**
6
- * Defines the search handler.
7
- */
8
- search: SearchHandler;
9
- /**
10
- * The optional settings to be defined.
11
- */
12
- settings?: SearchSettings;
13
- }
14
- /**
15
- * Available configuration options for the search plugin.
16
- */
17
- export interface SearchConfig extends SearchActionsConfig {
18
- /**
19
- * Sets the providers to be given by the app shell.
20
- * @default []
21
- */
22
- providers?: Array<InitialSearchProvider>;
23
- /**
24
- * Sets the initial results of the search.
25
- * @default []
26
- */
27
- results?: Array<ReactChild>;
28
- /**
29
- * Sets the initial query.
30
- * @default ''
31
- */
32
- query?: string;
33
- /**
34
- * Determines if the providers are also used for an empty query.
35
- * @default false
36
- */
37
- emptyTrigger?: boolean;
38
- /**
39
- * Allows filtering of the search providers to query.
40
- * @param query The query that should be run.
41
- * @param providerNames The names of the available search providers.
42
- * @default undefined
43
- */
44
- filter?(query: string, providerNames: Array<string>): Array<string>;
45
- }
46
- /**
47
- * Creates new Pilet API extensions for search and filtering.
48
- */
49
- export declare function createSearchApi(config?: SearchConfig): PiralPlugin<PiletSearchApi>;
package/esm/create.js DELETED
@@ -1,92 +0,0 @@
1
- import { isValidElement, createElement } from 'react';
2
- import { isfunc, buildName, withApi, withAll, withRootExtension, } from 'piral-core';
3
- import { createActions } from './actions';
4
- import { DefaultContainer, DefaultInput, DefaultResult } from './default';
5
- import { Search } from './Search';
6
- import { SearchInput } from './SearchInput';
7
- function noop() { }
8
- function createSearchRegistration(pilet, search, settings = {}) {
9
- const { onlyImmediate = false, onCancel = noop, onClear = noop, ...rest } = settings;
10
- return {
11
- ...rest,
12
- pilet,
13
- onlyImmediate,
14
- cancel: isfunc(onCancel) ? onCancel : noop,
15
- clear: isfunc(onClear) ? onClear : noop,
16
- search,
17
- };
18
- }
19
- function getSearchProviders(providers) {
20
- const searchProviders = {};
21
- let i = 0;
22
- for (const { search, settings } of providers) {
23
- searchProviders[`global-${i++}`] = createSearchRegistration(undefined, search, settings);
24
- }
25
- return searchProviders;
26
- }
27
- function toChild(content, api, context) {
28
- if (typeof content === 'string' || isValidElement(content)) {
29
- return content;
30
- }
31
- else {
32
- const component = withApi(context, content, api, 'extension');
33
- return createElement(component);
34
- }
35
- }
36
- function wrapResults(result, api, context) {
37
- const results = Array.isArray(result) ? result : [result];
38
- return results.map((item) => toChild(item, api, context));
39
- }
40
- function withSearch(searchProviders, query, items) {
41
- return (state) => ({
42
- ...state,
43
- components: {
44
- SearchContainer: DefaultContainer,
45
- SearchInput: DefaultInput,
46
- SearchResult: DefaultResult,
47
- ...state.components,
48
- },
49
- registry: {
50
- ...state.registry,
51
- searchProviders,
52
- },
53
- search: {
54
- input: query,
55
- results: {
56
- loading: false,
57
- items,
58
- },
59
- },
60
- });
61
- }
62
- /**
63
- * Creates new Pilet API extensions for search and filtering.
64
- */
65
- export function createSearchApi(config = {}) {
66
- const { providers = [], results = [], query = '', ...actionConfig } = config;
67
- return (context) => {
68
- context.defineActions(createActions(actionConfig));
69
- context.dispatch(withAll(withSearch(getSearchProviders(providers), query, results), withRootExtension('piral-search', Search), withRootExtension('piral-search-input', SearchInput)));
70
- return (api, target) => {
71
- const pilet = target.name;
72
- let next = 0;
73
- return {
74
- registerSearchProvider(name, provider, settings) {
75
- if (typeof name !== 'string') {
76
- settings = provider;
77
- provider = name;
78
- name = next++;
79
- }
80
- const id = buildName(pilet, name);
81
- context.registerSearchProvider(id, createSearchRegistration(pilet, (q) => Promise.resolve(provider(q, api)).then((results) => wrapResults(results, api, context), () => []), settings));
82
- return () => api.unregisterSearchProvider(name);
83
- },
84
- unregisterSearchProvider(name) {
85
- const id = buildName(pilet, name);
86
- context.unregisterSearchProvider(id);
87
- },
88
- };
89
- };
90
- };
91
- }
92
- //# sourceMappingURL=create.js.map
package/esm/create.js.map DELETED
@@ -1 +0,0 @@
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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AAC;gBACvC,CAAC;aACF,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
package/esm/default.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import * as React from 'react';
2
- import { SearchContainerProps, SearchInputProps, SearchResultProps } from './types';
3
- export declare const DefaultContainer: React.FC<SearchContainerProps>;
4
- export declare const DefaultResult: React.FC<SearchResultProps>;
5
- export declare const DefaultInput: React.FC<SearchInputProps>;
package/esm/default.js DELETED
@@ -1,6 +0,0 @@
1
- import * as React from 'react';
2
- import { defaultRender } from 'piral-core';
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
- //# sourceMappingURL=default.js.map
@@ -1 +0,0 @@
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/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './create';
2
- export * from './components';
3
- export * from './SearchInput';
4
- export * from './Search';
5
- export * from './types';
6
- export * from './useSearch';
package/esm/index.js DELETED
@@ -1,7 +0,0 @@
1
- export * from './create';
2
- export * from './components';
3
- export * from './SearchInput';
4
- export * from './Search';
5
- export * from './types';
6
- export * from './useSearch';
7
- //# sourceMappingURL=index.js.map
package/esm/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
package/esm/types.d.ts DELETED
@@ -1,196 +0,0 @@
1
- import type { ReactChild, ComponentType, ReactElement, ReactNode } from 'react';
2
- import type { Dict, Disposable, PiletApi, BaseRegistration, AnyComponent, BaseComponentProps, RegistrationDisposer } from 'piral-core';
3
- declare module 'piral-core/lib/types/custom' {
4
- interface PiletCustomApi extends PiletSearchApi {
5
- }
6
- interface PiralCustomState {
7
- /**
8
- * The relevant state for the in-site search.
9
- */
10
- search: SearchState;
11
- }
12
- interface PiralCustomActions {
13
- /**
14
- * Registers a new search provider.
15
- * @param name The name of the search provider.
16
- * @param value The value representing the provider.
17
- */
18
- registerSearchProvider(name: string, value: SearchProviderRegistration): void;
19
- /**
20
- * Unregisters an existing search provider.
21
- * @param name The name of the search provider.
22
- */
23
- unregisterSearchProvider(name: string): void;
24
- /**
25
- * Sets the current search input.
26
- * @param input The input to set.
27
- */
28
- setSearchInput(input: string): void;
29
- /**
30
- * Resets the search results.
31
- * @param input The input to set.
32
- * @param loading Determines if further results are currently loading.
33
- */
34
- resetSearchResults(input: string, loading: boolean): void;
35
- /**
36
- * Appends more results to the existing results.
37
- * @param items The items to append.
38
- * @param done Determines if more results are pending.
39
- */
40
- appendSearchResults(items: Array<ReactChild>, done: boolean): void;
41
- /**
42
- * Prepends more results to the existing results.
43
- * @param items The items to prepend.
44
- * @param done Determines if more results are pending.
45
- */
46
- prependSearchResults(items: Array<ReactChild>, done: boolean): void;
47
- /**
48
- * Triggers the search explicitly.
49
- * @param input Optionally sets the query to look for. Otherwise the current input is taken.
50
- * @param immediate Optionally, determins if the search was invoked immediately.
51
- */
52
- triggerSearch(input?: string, immediate?: boolean): Disposable;
53
- }
54
- interface PiralCustomRegistryState {
55
- /**
56
- * The registered search providers for context aware search.
57
- */
58
- searchProviders: Dict<SearchProviderRegistration>;
59
- }
60
- interface PiralCustomComponentsState {
61
- /**
62
- * The component for showing the results of the search.
63
- */
64
- SearchResult: ComponentType<SearchResultProps>;
65
- /**
66
- * The container for showing search.
67
- */
68
- SearchContainer: ComponentType<SearchContainerProps>;
69
- /**
70
- * The input component for search capability.
71
- */
72
- SearchInput: ComponentType<SearchInputProps>;
73
- }
74
- }
75
- export interface SearchContainerProps {
76
- /**
77
- * Gets if the results are still gathered.
78
- */
79
- loading: boolean;
80
- /**
81
- * The search to display.
82
- */
83
- children?: ReactNode;
84
- }
85
- export interface SearchInputProps {
86
- setValue(value: string): void;
87
- value: string;
88
- }
89
- export interface SearchResultComponentProps extends BaseComponentProps {
90
- }
91
- export interface SearchResultProps {
92
- /**
93
- * The search results to display.
94
- */
95
- children?: ReactNode;
96
- }
97
- export type SearchResultType = string | ReactElement<any> | AnyComponent<SearchResultComponentProps>;
98
- export interface SearchProvider {
99
- (options: SearchOptions, api: PiletApi): Promise<SearchResultType | Array<SearchResultType>>;
100
- }
101
- export interface SearchState {
102
- /**
103
- * Gets the current input value.
104
- */
105
- input: string;
106
- /**
107
- * Gets the current result state.
108
- */
109
- results: {
110
- /**
111
- * Gets weather the search is still loading.
112
- */
113
- loading: boolean;
114
- /**
115
- * The results to display for the current search.
116
- */
117
- items: Array<ReactChild>;
118
- };
119
- }
120
- export interface SearchOptions {
121
- /**
122
- * Gets the query for the search. This is currently available input
123
- * value.
124
- */
125
- query: string;
126
- /**
127
- * Gets if the search was requested immediately, e.g., via pressing
128
- * the enter key.
129
- */
130
- immediate: boolean;
131
- }
132
- export interface SearchSettings {
133
- /**
134
- * Only invoke the search provider if its an immediate search.
135
- */
136
- onlyImmediate?: boolean;
137
- /**
138
- * Callback to be fired when the search is cleared.
139
- */
140
- onClear?(): void;
141
- /**
142
- * Callback to be fired when an existing search is cancelled.
143
- */
144
- onCancel?(): void;
145
- }
146
- export interface SearchHandler {
147
- (options: SearchOptions): Promise<Array<ReactChild>>;
148
- }
149
- export interface SearchWrapper {
150
- (component: AnyComponent<SearchResultComponentProps>): ComponentType;
151
- }
152
- export interface SearchProviderRegistration extends BaseRegistration {
153
- search: SearchHandler;
154
- cancel(): void;
155
- clear(): void;
156
- onlyImmediate: boolean;
157
- }
158
- export interface PiletSearchApi {
159
- /**
160
- * Registers a search provider to respond to search queries.
161
- * The name has to be unique within the current pilet.
162
- * @param name The name of the search provider.
163
- * @param provider The callback to be used for searching.
164
- * @param settings The optional settings for the search provider.
165
- */
166
- registerSearchProvider(name: string, provider: SearchProvider, settings?: SearchSettings): RegistrationDisposer;
167
- /**
168
- * Registers a search provider to respond to search queries.
169
- * @param provider The callback to be used for searching.
170
- * @param settings The optional settings for the search provider.
171
- */
172
- registerSearchProvider(provider: SearchProvider, settings?: SearchSettings): RegistrationDisposer;
173
- /**
174
- * Unregisters a search provider known by the given name.
175
- * Only previously registered search providers can be unregistered.
176
- * @param name The name of the search provider to unregister.
177
- */
178
- unregisterSearchProvider(name: string): void;
179
- }
180
- /**
181
- * Configuration for creating the search actions.
182
- */
183
- export interface SearchActionsConfig {
184
- /**
185
- * Determines if the providers are also used for an empty query.
186
- * @default false
187
- */
188
- emptyTrigger?: boolean;
189
- /**
190
- * Allows filtering of the search providers to query.
191
- * @param query The query that should be run.
192
- * @param providerNames The names of the available search providers.
193
- * @default undefined
194
- */
195
- filter?(query: string, providerNames: Array<string>): Array<string>;
196
- }
package/esm/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
package/esm/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -1,8 +0,0 @@
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;
@@ -1,17 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Hook that yields the possibility of searching in Piral.
3
- * Returns the current (live, i.e., non-debounced) input value
4
- * and the ability to change the input value.
5
- * Changing the input value uses a debounce function to
6
- * properly cancel any current search and start a new search.
7
- * All registered search providers are used and search results
8
- * will be integrated as they arrive.
9
- * @param delay The delay [ms] to be used for the debounce.
10
- */
11
- export declare function useSearch(delay?: number): [string, (value: string) => void];
package/esm/useSearch.js DELETED
@@ -1,25 +0,0 @@
1
- import { useEffect, useRef } from 'react';
2
- import { useGlobalState, useActions } from 'piral-core';
3
- import { useDebounce } from './useDebounce';
4
- /**
5
- * Hook that yields the possibility of searching in Piral.
6
- * Returns the current (live, i.e., non-debounced) input value
7
- * and the ability to change the input value.
8
- * Changing the input value uses a debounce function to
9
- * properly cancel any current search and start a new search.
10
- * All registered search providers are used and search results
11
- * will be integrated as they arrive.
12
- * @param delay The delay [ms] to be used for the debounce.
13
- */
14
- export function useSearch(delay) {
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(() => {
20
- cancel.current && cancel.current();
21
- cancel.current = triggerSearch(query, false);
22
- }, [query]);
23
- return [searchInput, setSearchInput];
24
- }
25
- //# sourceMappingURL=useSearch.js.map
@@ -1 +0,0 @@
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"}