@lls/store 24.1.67-e402e708 → 24.1.67-e4a0b752
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/lib/index.js +17 -4
- package/package.json +10 -4
package/lib/index.js
CHANGED
|
@@ -747,6 +747,8 @@ import { makeEntitiesFilter } from "@lls/utils";
|
|
|
747
747
|
// src/selectors/crud.ts
|
|
748
748
|
init_define_import_meta();
|
|
749
749
|
import { createSearchSelector, makeGetAllEntities, makeGetEntityById } from "@lls/utils";
|
|
750
|
+
import { useMemo } from "react";
|
|
751
|
+
import { useSelector } from "react-redux";
|
|
750
752
|
var crud = (entityName, { search: search25 }) => {
|
|
751
753
|
const getElements = makeGetAllEntities(entityName);
|
|
752
754
|
const makeSearchElements = () => createSearchSelector(
|
|
@@ -756,15 +758,23 @@ var crud = (entityName, { search: search25 }) => {
|
|
|
756
758
|
);
|
|
757
759
|
const methodName = `${entityName.charAt(0).toUpperCase()}${entityName.slice(1)}`;
|
|
758
760
|
const getElementById = makeGetEntityById(entityName);
|
|
761
|
+
const useSearch = makeUseSearch(makeSearchElements);
|
|
759
762
|
const back = {
|
|
760
763
|
[`get${methodName}`]: getElements,
|
|
761
764
|
[`search${methodName}`]: makeSearchElements(),
|
|
762
765
|
[`get${methodName.replace(/s$/, "")}`]: getElementById,
|
|
763
766
|
[`makeSearch${methodName}`]: makeSearchElements,
|
|
764
|
-
[`filter${methodName}`]: search25
|
|
767
|
+
[`filter${methodName}`]: search25,
|
|
768
|
+
[`useSearch${methodName}`]: useSearch
|
|
765
769
|
};
|
|
766
770
|
return back;
|
|
767
771
|
};
|
|
772
|
+
var makeUseSearch = (makeSearchElements) => {
|
|
773
|
+
return (params) => {
|
|
774
|
+
const fn = useMemo(makeSearchElements, []);
|
|
775
|
+
return useSelector((state) => fn(state, params));
|
|
776
|
+
};
|
|
777
|
+
};
|
|
768
778
|
|
|
769
779
|
// src/selectors/school.ts
|
|
770
780
|
var search = ({ ids }) => makeEntitiesFilter({ id: ids });
|
|
@@ -814,7 +824,7 @@ var search2 = ({
|
|
|
814
824
|
_2.isFunction(sortByQuery) ? sortByQuery : sortByQuery ? _2.sortBy(sortByQuery) : _2.identity
|
|
815
825
|
);
|
|
816
826
|
};
|
|
817
|
-
var { getBooks, getBook, searchBooks, makeSearchBooks, filterBooks } = crud("books", {
|
|
827
|
+
var { getBooks, getBook, searchBooks, makeSearchBooks, filterBooks, useSearchBooks } = crud("books", {
|
|
818
828
|
search: search2
|
|
819
829
|
});
|
|
820
830
|
var makeSearchValidBooks = () => createSearchSelector2(makeSearchBooks(), (books) => _2.filter({ valid: true, hasNewDesign: true }, books));
|
|
@@ -915,7 +925,7 @@ var getDraftPages = makeGetAllEntities2("drafts");
|
|
|
915
925
|
var makeGetDraftPage = () => makeGetEntityById3("drafts");
|
|
916
926
|
var getDraftPage = makeGetDraftPage();
|
|
917
927
|
var makeSearchDraftPages = () => createSearchSelector3(
|
|
918
|
-
|
|
928
|
+
makeGetAllEntities2("drafts"),
|
|
919
929
|
(_state, params) => params,
|
|
920
930
|
(pages, params) => search5(params)(pages)
|
|
921
931
|
);
|
|
@@ -926,6 +936,7 @@ var makeSearchModifiedPages = () => createSearchSelector3(
|
|
|
926
936
|
(pages, params) => search5({ ...params, isOriginal: false })(pages)
|
|
927
937
|
);
|
|
928
938
|
var searchModifiedPages = makeSearchModifiedPages();
|
|
939
|
+
var useSearchModifiedPages = makeUseSearch(makeSearchModifiedPages);
|
|
929
940
|
|
|
930
941
|
// src/selectors/collection.ts
|
|
931
942
|
init_define_import_meta();
|
|
@@ -1680,5 +1691,7 @@ export {
|
|
|
1680
1691
|
searchTools,
|
|
1681
1692
|
searchUsers,
|
|
1682
1693
|
searchValidBooks,
|
|
1683
|
-
setEntitiesReducer
|
|
1694
|
+
setEntitiesReducer,
|
|
1695
|
+
useSearchBooks,
|
|
1696
|
+
useSearchModifiedPages
|
|
1684
1697
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@lls/store",
|
|
3
3
|
"description": "model de donnée et selecteurs",
|
|
4
4
|
"homepage": "https://github.com/lelivrescolaire/monorepo/tree/dev/libs/store",
|
|
5
|
-
"version": "24.1.67-
|
|
5
|
+
"version": "24.1.67-e4a0b752",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./lib/builttypes/store/src/index.d.ts",
|
|
8
8
|
"exports": {
|
|
@@ -25,24 +25,30 @@
|
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@lls/utils": "*",
|
|
27
27
|
"lodash": "*",
|
|
28
|
-
"react": "*"
|
|
28
|
+
"react": "*",
|
|
29
|
+
"react-redux": "*",
|
|
30
|
+
"redux": "*"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
33
|
"@biomejs/biome": "1.9.1",
|
|
34
|
+
"@testing-library/react": "16.0.1",
|
|
32
35
|
"@types/lodash": "4.17.7",
|
|
33
36
|
"@types/node": "22.5.5",
|
|
34
37
|
"@types/react": "18.3.6",
|
|
38
|
+
"@types/react-redux": "7.1.34",
|
|
35
39
|
"@vitejs/plugin-react-swc": "3.7.0",
|
|
36
40
|
"esbuild": "0.23.1",
|
|
37
41
|
"lodash": "4.17.21",
|
|
38
42
|
"react": "18.3.1",
|
|
43
|
+
"react-redux": "8.1.1",
|
|
44
|
+
"redux": "5.0.1",
|
|
39
45
|
"reselect": "4.1.8",
|
|
40
46
|
"typescript": "5.6.2",
|
|
41
47
|
"vite": "5.4.6",
|
|
42
48
|
"vite-tsconfig-paths": "5.0.1",
|
|
43
49
|
"vitest": "2.1.1",
|
|
44
|
-
"@lls/utils": "24.1.67-
|
|
45
|
-
"@lls/vitescripts": "24.1.67-
|
|
50
|
+
"@lls/utils": "24.1.67-e4a0b752",
|
|
51
|
+
"@lls/vitescripts": "24.1.67-e4a0b752"
|
|
46
52
|
},
|
|
47
53
|
"license": "ISC",
|
|
48
54
|
"dependencies": {
|