@kaspernj/api-maker 1.0.321 → 1.0.323

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/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  ]
17
17
  },
18
18
  "name": "@kaspernj/api-maker",
19
- "version": "1.0.321",
19
+ "version": "1.0.323",
20
20
  "type": "module",
21
21
  "description": "",
22
22
  "main": "index.js",
@@ -61,7 +61,6 @@
61
61
  "peerDependencies": {
62
62
  "prop-types": "^15.7.2",
63
63
  "prop-types-exact": ">= 1.2.0",
64
- "source-map": "^0.7.3",
65
64
  "stacktrace-parser": ">= 0.1.9"
66
65
  },
67
66
  "devDependencies": {
@@ -3,7 +3,7 @@ import EventListener from "../../../event-listener"
3
3
  import PropTypes from "prop-types"
4
4
  import PropTypesExact from "prop-types-exact"
5
5
  import {memo, useCallback, useRef} from "react"
6
- import useShape from "set-state-compare/src/use-s.js"
6
+ import useShape from "set-state-compare/src/use-shape.js"
7
7
 
8
8
  const ApiMakerSuperAdminLayoutHeader = ({actions, onTriggerMenu, title}) => {
9
9
  const s = useShape()
@@ -8,7 +8,7 @@ import PropTypes from "prop-types"
8
8
  import PropTypesExact from "prop-types-exact"
9
9
  import {memo, useCallback, useEffect} from "react"
10
10
  import useCurrentUser from "../../use-current-user"
11
- import useShape from "set-state-compare/src/use-s.js"
11
+ import useShape from "set-state-compare/src/use-shape.js"
12
12
 
13
13
  const NoAccess = React.lazy(() => import("./no-access"))
14
14
 
@@ -8,22 +8,25 @@ import {useCallback, useEffect} from "react"
8
8
  import useShape from "set-state-compare/src/use-shape.js"
9
9
  import useQueryParams from "on-location-changed/src/use-query-params.js"
10
10
 
11
- const useCollection = ({
12
- abilities,
13
- collection,
14
- defaultParams,
15
- groupBy = ["id"],
16
- modelClass,
17
- noRecordsAvailableContent = undefined,
18
- noRecordsFoundContent = undefined,
19
- onModelsLoaded,
20
- pagination = false,
21
- preloads = [],
22
- queryMethod,
23
- queryName,
24
- select = {},
25
- selectColumns
26
- }) => {
11
+ const useCollection = (
12
+ {
13
+ abilities,
14
+ collection,
15
+ defaultParams,
16
+ groupBy = ["id"],
17
+ modelClass,
18
+ noRecordsAvailableContent = undefined,
19
+ noRecordsFoundContent = undefined,
20
+ onModelsLoaded,
21
+ pagination = false,
22
+ preloads = [],
23
+ queryMethod,
24
+ queryName,
25
+ select = {},
26
+ selectColumns
27
+ },
28
+ cacheKeys = []
29
+ ) => {
27
30
  const s = useShape({
28
31
  abilities,
29
32
  collection,
@@ -216,10 +219,13 @@ const useCollection = ({
216
219
  if (models.length === 0 && s.p.noRecordsFoundContent) return true
217
220
  }, [])
218
221
 
219
- useEffect(() => {
220
- loadQParams()
221
- loadModels()
222
- }, [queryParams[s.s.queryQName], queryParams[s.s.queryPageName], queryParams[s.s.queryPerKey], queryParams[s.s.querySName], collection])
222
+ useEffect(
223
+ () => {
224
+ loadQParams()
225
+ loadModels()
226
+ },
227
+ [queryParams[s.s.queryQName], queryParams[s.s.queryPageName], queryParams[s.s.queryPerKey], queryParams[s.s.querySName], collection].concat(cacheKeys)
228
+ )
223
229
 
224
230
  useEffect(() => {
225
231
  if (s.p.noRecordsAvailableContent) loadOverallCount()
@@ -251,8 +257,10 @@ const useCollection = ({
251
257
  }, [modelIdsCacheString])
252
258
 
253
259
  const result = Object.assign({}, s.state)
260
+ const modelVariableName = inflection.pluralize(inflection.camelize(modelClass.modelClassData().name, true))
254
261
 
255
262
  result.modelIdsCacheString = modelIdsCacheString
263
+ result[modelVariableName] = s.s.models
256
264
 
257
265
  return result
258
266
  }