@stoker-platform/web-app 0.5.164 → 0.5.165

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,14 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.165
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: add secondary sort feature
8
+ - @stoker-platform/node-client@0.5.66
9
+ - @stoker-platform/utils@0.5.57
10
+ - @stoker-platform/web-client@0.5.67
11
+
3
12
  ## 0.5.164
4
13
 
5
14
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.164",
3
+ "version": "0.5.165",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
@@ -51,9 +51,9 @@
51
51
  "@radix-ui/react-tooltip": "^1.2.8",
52
52
  "@react-google-maps/api": "^2.20.8",
53
53
  "@sentry/react": "^10.56.0",
54
- "@stoker-platform/node-client": "0.5.65",
55
- "@stoker-platform/utils": "0.5.56",
56
- "@stoker-platform/web-client": "0.5.66",
54
+ "@stoker-platform/node-client": "0.5.66",
55
+ "@stoker-platform/utils": "0.5.57",
56
+ "@stoker-platform/web-client": "0.5.67",
57
57
  "@tanstack/react-table": "^8.21.3",
58
58
  "@types/react": "18.3.13",
59
59
  "@types/react-dom": "18.3.1",
@@ -183,6 +183,13 @@ function Collection({
183
183
  }
184
184
  | undefined
185
185
  >(undefined)
186
+ const [secondarySort, setSecondarySort] = useState<
187
+ | {
188
+ field: string
189
+ direction?: "asc" | "desc"
190
+ }
191
+ | undefined
192
+ >(undefined)
186
193
 
187
194
  const [state, setStokerState] = useStokerState()
188
195
  const setState = useCallback(
@@ -1194,6 +1201,16 @@ function Collection({
1194
1201
  }
1195
1202
  | undefined
1196
1203
  setDefaultSort(defaultSortOverride || defaultSort)
1204
+ const secondarySort = (await getCachedConfigValue(customization, [
1205
+ ...collectionAdminPath,
1206
+ "secondarySort",
1207
+ ])) as
1208
+ | {
1209
+ field: string
1210
+ direction?: "asc" | "desc"
1211
+ }
1212
+ | undefined
1213
+ setSecondarySort(secondarySort)
1197
1214
  const sortState = state[`collection-sort-${labels.collection.toLowerCase()}`]
1198
1215
  if (sortState && !relationList) {
1199
1216
  const newSorting = JSON.parse(sortState)
@@ -2513,6 +2530,7 @@ function Collection({
2513
2530
  setBackToStartKey={setBackToStartKey}
2514
2531
  search={search}
2515
2532
  defaultSort={defaultSort}
2533
+ secondarySort={secondarySort}
2516
2534
  setOptimisticList={setOptimisticList}
2517
2535
  relationList={relationList}
2518
2536
  relationCollection={relationCollection}
package/src/List.tsx CHANGED
@@ -212,6 +212,12 @@ interface ListProps {
212
212
  direction?: "asc" | "desc"
213
213
  }
214
214
  | undefined
215
+ secondarySort:
216
+ | {
217
+ field: string
218
+ direction?: "asc" | "desc"
219
+ }
220
+ | undefined
215
221
  setOptimisticList: () => void
216
222
  relationList?: RelationList
217
223
  relationCollection?: CollectionSchema
@@ -237,6 +243,7 @@ export function List({
237
243
  setBackToStartKey,
238
244
  search,
239
245
  defaultSort,
246
+ secondarySort,
240
247
  setOptimisticList,
241
248
  relationList,
242
249
  relationCollection,
@@ -838,7 +845,10 @@ export function List({
838
845
  } else if (recordTitleField) {
839
846
  setSorting([{ id: recordTitleField, desc: false }])
840
847
  }
841
- }, [table, recordTitleField])
848
+ if ((isPreloadCacheEnabled || isServerReadOnly) && secondarySort) {
849
+ setSorting((prev) => [...prev, { id: secondarySort.field, desc: secondarySort.direction === "desc" }])
850
+ }
851
+ }, [table, recordTitleField, secondarySort, isPreloadCacheEnabled, isServerReadOnly])
842
852
 
843
853
  useEffect(() => {
844
854
  if (isPreloadCacheEnabled || isServerReadOnly) {