@tellescope/react-components 1.184.0 → 1.185.0

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 (42) hide show
  1. package/lib/cjs/Forms/hooks.js +4 -4
  2. package/lib/cjs/Forms/hooks.js.map +1 -1
  3. package/lib/cjs/layout.js +1 -1
  4. package/lib/cjs/layout.js.map +1 -1
  5. package/lib/cjs/state.d.ts +3 -1
  6. package/lib/cjs/state.d.ts.map +1 -1
  7. package/lib/cjs/state.js +79 -11
  8. package/lib/cjs/state.js.map +1 -1
  9. package/lib/cjs/table.d.ts.map +1 -1
  10. package/lib/cjs/table.js +3 -2
  11. package/lib/cjs/table.js.map +1 -1
  12. package/lib/esm/CMS/components.d.ts +0 -1
  13. package/lib/esm/CMS/components.d.ts.map +1 -1
  14. package/lib/esm/Forms/form_responses.d.ts +0 -1
  15. package/lib/esm/Forms/form_responses.d.ts.map +1 -1
  16. package/lib/esm/Forms/forms.d.ts +3 -3
  17. package/lib/esm/Forms/hooks.js +4 -4
  18. package/lib/esm/Forms/hooks.js.map +1 -1
  19. package/lib/esm/Forms/inputs.d.ts +1 -1
  20. package/lib/esm/Forms/inputs.native.d.ts +0 -1
  21. package/lib/esm/Forms/inputs.native.d.ts.map +1 -1
  22. package/lib/esm/controls.d.ts +2 -2
  23. package/lib/esm/inputs.d.ts +1 -1
  24. package/lib/esm/inputs.native.d.ts +0 -1
  25. package/lib/esm/inputs.native.d.ts.map +1 -1
  26. package/lib/esm/layout.js +1 -1
  27. package/lib/esm/layout.js.map +1 -1
  28. package/lib/esm/state.d.ts +292 -290
  29. package/lib/esm/state.d.ts.map +1 -1
  30. package/lib/esm/state.js +79 -11
  31. package/lib/esm/state.js.map +1 -1
  32. package/lib/esm/table.d.ts.map +1 -1
  33. package/lib/esm/table.js +3 -2
  34. package/lib/esm/table.js.map +1 -1
  35. package/lib/esm/theme.native.d.ts +0 -1
  36. package/lib/esm/theme.native.d.ts.map +1 -1
  37. package/lib/tsconfig.tsbuildinfo +1 -1
  38. package/package.json +9 -9
  39. package/src/Forms/hooks.tsx +1 -1
  40. package/src/layout.tsx +1 -1
  41. package/src/state.tsx +53 -7
  42. package/src/table.tsx +8 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/react-components",
3
- "version": "1.184.0",
3
+ "version": "1.185.0",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -47,13 +47,13 @@
47
47
  "@reduxjs/toolkit": "^1.6.2",
48
48
  "@stripe/react-stripe-js": "^2.9.0",
49
49
  "@stripe/stripe-js": "^1.52.1",
50
- "@tellescope/constants": "^1.184.0",
51
- "@tellescope/sdk": "^1.184.0",
52
- "@tellescope/types-client": "^1.184.0",
53
- "@tellescope/types-models": "^1.184.0",
54
- "@tellescope/types-utilities": "^1.184.0",
55
- "@tellescope/utilities": "^1.184.0",
56
- "@tellescope/validation": "^1.184.0",
50
+ "@tellescope/constants": "^1.185.0",
51
+ "@tellescope/sdk": "^1.185.0",
52
+ "@tellescope/types-client": "^1.185.0",
53
+ "@tellescope/types-models": "^1.185.0",
54
+ "@tellescope/types-utilities": "^1.185.0",
55
+ "@tellescope/utilities": "^1.185.0",
56
+ "@tellescope/validation": "^1.185.0",
57
57
  "@typescript-eslint/eslint-plugin": "^4.33.0",
58
58
  "@typescript-eslint/parser": "^4.33.0",
59
59
  "css-to-react-native": "^3.0.0",
@@ -84,7 +84,7 @@
84
84
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
85
85
  "react-native": "^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.71.0"
86
86
  },
87
- "gitHead": "ad996fbec7a2840e68b90a0df0b2ff182e348ee3",
87
+ "gitHead": "cfec3c3b78a63582657d3fbf942cdbe2a0375f22",
88
88
  "publishConfig": {
89
89
  "access": "public"
90
90
  }
@@ -1100,7 +1100,7 @@ export const useTellescopeForm = ({ isPublicForm, form, urlLogicValue, customiza
1100
1100
  // ensure Question Group responses are included
1101
1101
 
1102
1102
  for (const r of responsesToSubmit) {
1103
- if (r.answer.type !== 'Question Group') continue
1103
+ if (r?.answer?.type !== 'Question Group') continue
1104
1104
 
1105
1105
  for (const f of r.answer.value ?? []) {
1106
1106
  const match = responses.find(r => r.fieldId === f?.id)
package/src/layout.tsx CHANGED
@@ -407,7 +407,7 @@ export const ScrollingList = <T extends { id: string | number }>({
407
407
  {({ data, index, style }) => (
408
408
  <div style={style}>
409
409
  <Item key={data[index].id} item={data[index]} index={index} />
410
- {index === items.length -1 && loadMore &&
410
+ {index === items.length -1 && loadMore && !doneLoading?.() &&
411
411
  <div style={{ textAlign: 'center' }}>
412
412
  <LoadingButton submitText="Load Older Data" submittingText="Loading..."
413
413
  disabled={doneLoading?.()} onClick={loadMore}
package/src/state.tsx CHANGED
@@ -1049,6 +1049,9 @@ export const useListStateHook = <T extends { id: string | number }, ADD extends
1049
1049
  if (es.value.length < limit && !loadFilter && !mdbFilter) {
1050
1050
  setFetched('id' + modelName + DONE_LOADING_TOKEN, true)
1051
1051
  }
1052
+ else if (es.value.length < limit) {
1053
+ setFetched(fetchKey + DONE_LOADING_TOKEN, true)
1054
+ }
1052
1055
  if (es.value.length) { // don't store oldest record from a filter, may skip some pages
1053
1056
  setLastId(fetchKey, es.value[es.value.length - 1]?.id?.toString())
1054
1057
  const createdAt: any = (es.value[es.value.length - 1] as any).createdAt;
@@ -1083,9 +1086,28 @@ export const useListStateHook = <T extends { id: string | number }, ADD extends
1083
1086
  load(false)
1084
1087
  }, [load, options?.unbounceMS])
1085
1088
 
1086
- const doneLoading = useCallback((key="id") => (
1087
- didFetch(key + modelName + DONE_LOADING_TOKEN)
1088
- ), [didFetch, modelName])
1089
+ const doneLoading = useCallback((key="id") => {
1090
+ const unfileteredCase = didFetch(key + modelName + DONE_LOADING_TOKEN)
1091
+ if (unfileteredCase) return true
1092
+
1093
+ const sort = options?.sort
1094
+ const sortBy = options?.sortBy
1095
+
1096
+ const _filter = options?.loadFilter
1097
+ const filter = (_filter && object_is_empty(_filter)) ? undefined : _filter
1098
+
1099
+ const _mdbFilter = options?.mdbFilter
1100
+ const mdbFilter = (_mdbFilter && _mdbFilter?.$and?.length) ? _mdbFilter : undefined
1101
+
1102
+ const filterKey = (
1103
+ (mdbFilter || filter || sort || sortBy)
1104
+ ? JSON.stringify({ ...mdbFilter, ...filter, sort, sortBy }) + modelName
1105
+ : modelName
1106
+ )
1107
+ if (didFetch(filterKey + DONE_LOADING_TOKEN)) return true
1108
+
1109
+ return false
1110
+ }, [didFetch, modelName, options?.loadFilter, options?.mdbFilter, options?.sort, options?.sortBy])
1089
1111
 
1090
1112
  const loadMore = useCallback(async (loadOptions?: LoadMoreOptions<T>) => {
1091
1113
  const sort = options?.sort
@@ -1127,6 +1149,9 @@ export const useListStateHook = <T extends { id: string | number }, ADD extends
1127
1149
  if (es.value.length < limit && !mdbFilter && (!filter || object_is_empty(filter))) {
1128
1150
  setFetched(key + modelName + DONE_LOADING_TOKEN, true)
1129
1151
  }
1152
+ else if (es.value.length < limit) {
1153
+ setFetched(filterKey + DONE_LOADING_TOKEN, true)
1154
+ }
1130
1155
  const newLastId = es.value[es.value.length - 1]?.id?.toString()
1131
1156
  if (newLastId) {
1132
1157
  setLastId(filterKey, newLastId)
@@ -2888,14 +2913,35 @@ export const useCalendarEventsForUser = (options={} as HookOptions<CalendarEvent
2888
2913
 
2889
2914
  const [eventsLoading, { addLocalElements, filtered }] = useCalendarEvents()
2890
2915
 
2891
- const loadEvents = useCallback((options?: LoadEventOptions) => {
2916
+ const loadEvents = useCallback(async (options?: LoadEventOptions & { to?: Date }) => {
2892
2917
  const key = JSON.stringify(options ?? {})
2893
2918
  if (loadedRef.current[key]) return
2894
2919
  loadedRef.current[key] = Date.now()
2895
2920
 
2896
- fetchEvents(options)
2897
- .then(es => addLocalElements(es, { replaceIfMatch: true }))
2898
- .catch(console.error)
2921
+ const load = (from?: Date) => (
2922
+ console.log('Loading events from', from, 'to', options?.to),
2923
+ fetchEvents({ ...options, from })
2924
+ .then(es => addLocalElements(es, { replaceIfMatch: true }))
2925
+ .catch(console.error)
2926
+ )
2927
+
2928
+ let i = 0
2929
+ let from = options?.from
2930
+ while (i < 10) {
2931
+ i++
2932
+ const loaded = await load(from)
2933
+
2934
+ const to = options?.to
2935
+ if (!to) { break }
2936
+ if (!loaded) { break }
2937
+ if (loaded.length === 0) { break }
2938
+
2939
+ if (loaded.find(e => new Date(e.startTimeInMS).getTime() > to.getTime())) {
2940
+ break
2941
+ }
2942
+ // else continue to loop (up to 10 times) until we find events after the to date
2943
+ from = new Date(Math.max(...loaded.map(e => e.startTimeInMS)))
2944
+ }
2899
2945
  }, [session, loadedRef, fetchEvents, addLocalElements])
2900
2946
 
2901
2947
  return [eventsLoading, { loadEvents, filtered }] as const
package/src/table.tsx CHANGED
@@ -977,7 +977,7 @@ export const Table = <T extends Item>({
977
977
  }, [sorted, localFilters, fields])
978
978
 
979
979
  // make sure filterCounts incorporates column filters whose state is in Table, not parent component
980
- const filterCounts = _filterCounts ? { ..._filterCounts, filtered: filtered.length } : undefined
980
+ const filterCounts = (_filterCounts && !paginated) ? { ..._filterCounts, filtered: filtered.length } : undefined
981
981
 
982
982
  const headerFilterIsActive = (
983
983
  !!(fields.find(f => f.filterIsActive) || localFilters.find(f => f?.query))
@@ -1101,12 +1101,13 @@ export const Table = <T extends Item>({
1101
1101
  {emptyText || 'No results found the current filter'}
1102
1102
  </Typography>
1103
1103
 
1104
- <div style={{ paddingLeft: horizontalPadding, paddingBottom: horizontalPadding }}>
1105
- <LoadingButton submitText="Load Older Data" submittingText="Loading..."
1106
- disabled={doneLoading?.()} onClick={loadMore}
1107
- variant="outlined" style={{ width: 200, textAlign: 'center', marginTop: 10 }}
1108
- />
1109
- </div>
1104
+ {loadMore && !doneLoading?.() &&
1105
+ <div style={{ paddingLeft: horizontalPadding, paddingBottom: horizontalPadding }}>
1106
+ <LoadingButton submitText="Load Older Data" submittingText="Loading..." onClick={loadMore}
1107
+ variant="outlined" style={{ width: 200, textAlign: 'center', marginTop: 10 }}
1108
+ />
1109
+ </div>
1110
+ }
1110
1111
  </>
1111
1112
  )
1112
1113
  : undefined