@stoker-platform/web-app 0.5.124 → 0.5.126

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.126
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: fix preload cache spinner issue
8
+
9
+ ## 0.5.125
10
+
11
+ ### Patch Changes
12
+
13
+ - feat: improve mobile collection transitions
14
+
3
15
  ## 0.5.124
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.124",
3
+ "version": "0.5.126",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
package/src/App.css CHANGED
@@ -1,5 +1,11 @@
1
1
  html,
2
2
  body {
3
+ background-color: #ffffff !important;
4
+ background-image: none !important;
5
+ }
6
+
7
+ html[data-mode="app"],
8
+ html[data-mode="app"] body {
3
9
  background-color: #000000 !important;
4
10
  background-image: none !important;
5
11
  }
@@ -710,15 +710,15 @@ function Collection({
710
710
  const cacheLoading = useCallback(() => {
711
711
  if (!cacheLoadingStarted.current) {
712
712
  isCacheLoading.current = true
713
- setIsRouteLoading("+", location.pathname)
713
+ setIsRouteLoading("+", location.pathname, true)
714
714
  cacheLoadingStarted.current = true
715
715
  }
716
- }, [location, isCacheLoading.current, cacheLoadingStarted.current])
716
+ }, [location.pathname, setIsRouteLoading])
717
717
  const cacheLoaded = useCallback(() => {
718
718
  isCacheLoading.current = false
719
- setIsRouteLoading("-", location.pathname)
719
+ setIsRouteLoading("-", location.pathname, true)
720
720
  setCacheLoadingCompleted(true)
721
- }, [location, isCacheLoading.current])
721
+ }, [location.pathname, setIsRouteLoading])
722
722
 
723
723
  const hasRunSingleton = useRef(false)
724
724
 
@@ -727,7 +727,6 @@ function Collection({
727
727
  const isPreloading = getLoadingState()[labels.collection]
728
728
  if (!isPreloading || isPreloading === "Loading") {
729
729
  cacheLoading()
730
- cacheLoadingStarted.current = true
731
730
  }
732
731
  document.addEventListener(`stoker:loading:${labels.collection}`, cacheLoading)
733
732
  // Prevent UI flicker
@@ -1687,20 +1686,23 @@ function Collection({
1687
1686
  [recordTitle],
1688
1687
  )
1689
1688
 
1690
- const [showCollection, setShowCollection] = useState(window.innerWidth > 1280)
1691
- useEffect(() => {
1692
- if (isInitialized) {
1693
- setTimeout(() => {
1694
- setShowCollection(true)
1695
- }, 150)
1696
- }
1697
- }, [isInitialized])
1689
+ const willHaveRangeRow = useMemo(() => {
1690
+ return (
1691
+ !formList &&
1692
+ !relationList?.loadAll &&
1693
+ tab !== "calendar" &&
1694
+ (hasRangeFilter ||
1695
+ (isPreloadCacheEnabled && !!preloadCache?.range) ||
1696
+ filters.some((filter) => filter.type === "range") ||
1697
+ (Array.isArray(collection.admin?.filters) &&
1698
+ collection.admin.filters.some((filter) => filter.type === "range")))
1699
+ )
1700
+ }, [formList, relationList, tab, hasRangeFilter, isPreloadCacheEnabled, filters, collection])
1698
1701
 
1699
1702
  if (!permissions.collections?.[labels.collection]) return null
1700
1703
 
1701
1704
  return (
1702
- !collection.singleton &&
1703
- showCollection && (
1705
+ !collection.singleton && (
1704
1706
  <>
1705
1707
  <div
1706
1708
  ref={mainContentRef}
@@ -1826,7 +1828,9 @@ function Collection({
1826
1828
  <Tabs defaultValue="list" onValueChange={onTabChange} value={tab}>
1827
1829
  <div
1828
1830
  className={cn(
1829
- "flex flex-col items-center print:hidden select-none",
1831
+ "flex flex-col items-center justify-between print:hidden select-none",
1832
+ willHaveRangeRow ? "h-[116px]" : "h-[72px]",
1833
+ "lg:h-auto",
1830
1834
  relationList ? "xl:flex-row" : "lg:flex-row",
1831
1835
  )}
1832
1836
  >
@@ -2545,17 +2549,17 @@ function Collection({
2545
2549
  ) : (
2546
2550
  !relationList &&
2547
2551
  (tab === "list" ? (
2548
- <div className="pb-2 pt-[88px] lg:py-2">
2549
- <Card className="min-h-[calc(100vh-88px)] lg:min-h-full lg:h-[calc(100vh-250px)]"></Card>
2552
+ <div className="py-2">
2553
+ <Card className="min-h-screen lg:min-h-full lg:h-[calc(100vh-250px)]"></Card>
2550
2554
  </div>
2551
2555
  ) : tab === "map" ? (
2552
- <div className="pb-2 pt-[88px] lg:py-2">
2553
- <Card className="min-h-[calc(100vh-88px)] lg:min-h-full lg:h-[calc(100vh-204px)]"></Card>
2556
+ <div className="py-2">
2557
+ <Card className="min-h-screen lg:min-h-full lg:h-[calc(100vh-204px)]"></Card>
2554
2558
  </div>
2555
2559
  ) : (
2556
2560
  tab === "calendar" && (
2557
- <div className="pb-2 pt-[44px] lg:py-2">
2558
- <Card className="min-h-[calc(100vh-44px)] lg:min-h-full lg:h-[calc(100vh-204px)]"></Card>
2561
+ <div className="py-2">
2562
+ <Card className="min-h-screen lg:min-h-full lg:h-[calc(100vh-204px)]"></Card>
2559
2563
  </div>
2560
2564
  )
2561
2565
  ))
package/src/Tenant.tsx CHANGED
@@ -60,7 +60,7 @@ import { getFunctions, httpsCallable } from "firebase/functions"
60
60
  import { getApp } from "firebase/app"
61
61
  import { useTheme } from "./components/theme-provider"
62
62
 
63
- const MOBILE_SHEET_CLOSE_MS = 400
63
+ const MOBILE_SHEET_CLOSE_MS = 320
64
64
 
65
65
  function Tenant() {
66
66
  const [dialogContent, setDialogContent] = useDialog()
@@ -290,9 +290,9 @@ function Tenant() {
290
290
 
291
291
  const navigateFromSidebar = useCallback(
292
292
  (path: string) => {
293
- runViewTransition(() => navigate(path))
293
+ setSidebarOpen(false)
294
294
  window.setTimeout(() => {
295
- setSidebarOpen(false)
295
+ runViewTransition(() => navigate(path))
296
296
  }, MOBILE_SHEET_CLOSE_MS)
297
297
  },
298
298
  [navigate],
package/src/main.tsx CHANGED
@@ -89,6 +89,15 @@ function Main() {
89
89
  const [, setDialogContent] = useDialog()
90
90
  const { toast } = useToast()
91
91
 
92
+ useEffect(() => {
93
+ const root = document.documentElement
94
+ if (mode === "app" && !maintenance) {
95
+ root.dataset.mode = "app"
96
+ } else {
97
+ delete root.dataset.mode
98
+ }
99
+ }, [mode, maintenance])
100
+
92
101
  useEffect(() => {
93
102
  if (mode === "maintenance") return
94
103
  const getRoutes = () => {
@@ -1,4 +1,4 @@
1
- import { createContext, useContext, useMemo, useState } from "react"
1
+ import { createContext, useCallback, useContext, useRef, useState } from "react"
2
2
  import debounce from "lodash/debounce.js"
3
3
  import { serverReadOnly } from "@/utils/serverReadOnly"
4
4
  import { useLocation } from "react-router"
@@ -91,25 +91,33 @@ export const RouteLoadingProvider: React.FC<RouteLoadingProviderProps> = ({ chil
91
91
  const [isRouteLoading, setLoading] = useState<Set<string>>(new Set<string>())
92
92
  const [isRouteLoadingImmediate, setLoadingImmediate] = useState<Set<string>>(new Set<string>())
93
93
 
94
- const setIsRouteLoadingDebounced = useMemo(() => {
95
- const debouncedSet = debounce((operation: "+" | "-", route: string) => {
96
- if (operation === "+") {
97
- setLoading((prev) => {
98
- const newSet = new Set(prev)
99
- newSet.add(route)
100
- return newSet
101
- })
102
- } else {
103
- setLoading((prev) => {
104
- const newSet = new Set(prev)
105
- newSet.delete(route)
106
- return newSet
107
- })
108
- }
109
- }, 500)
94
+ const debouncedByRouteRef = useRef(new Map<string, ReturnType<typeof debounce>>())
110
95
 
111
- return (operation: "+" | "-", route: string) => {
112
- debouncedSet(operation, route)
96
+ const setIsRouteLoadingDebounced = useCallback((operation: "+" | "-", route: string) => {
97
+ let debounced = debouncedByRouteRef.current.get(route)
98
+ if (!debounced) {
99
+ debounced = debounce((op: "+" | "-") => {
100
+ if (op === "+") {
101
+ setLoading((prev) => {
102
+ const newSet = new Set(prev)
103
+ newSet.add(route)
104
+ return newSet
105
+ })
106
+ } else {
107
+ setLoading((prev) => {
108
+ const newSet = new Set(prev)
109
+ newSet.delete(route)
110
+ return newSet
111
+ })
112
+ }
113
+ }, 500)
114
+ debouncedByRouteRef.current.set(route, debounced)
115
+ }
116
+ debounced(operation)
117
+ if (operation === "-") {
118
+ debounced.flush()
119
+ debounced.cancel()
120
+ debouncedByRouteRef.current.delete(route)
113
121
  }
114
122
  }, [])
115
123
 
@@ -153,6 +161,8 @@ export const RouteLoadingProvider: React.FC<RouteLoadingProviderProps> = ({ chil
153
161
  // eslint-disable-next-line security/detect-object-injection
154
162
  const collection = schema.collections[collectionName]
155
163
  if ((collection && serverReadOnly(collection)) || immediate) {
164
+ debouncedByRouteRef.current.get(route)?.cancel()
165
+ debouncedByRouteRef.current.delete(route)
156
166
  setIsRouteLoadingImmediate(operation, route)
157
167
  } else {
158
168
  setIsRouteLoadingDebounced(operation, route)