@stoker-platform/web-app 0.5.162 → 0.5.164

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.164
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: provide previous to onChange
8
+
9
+ ## 0.5.163
10
+
11
+ ### Patch Changes
12
+
13
+ - fix: improve list search results sorting
14
+
3
15
  ## 0.5.162
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.162",
3
+ "version": "0.5.164",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
package/src/Form.tsx CHANGED
@@ -3733,6 +3733,8 @@ function RecordForm({
3733
3733
 
3734
3734
  const suppressDraftSaveRef = useRef(false)
3735
3735
 
3736
+ const previous = useRef<StokerRecord | undefined>(undefined)
3737
+
3736
3738
  useEffect(() => {
3737
3739
  if (!(suppressDraftSaveRef?.current || !isDirty)) {
3738
3740
  if (
@@ -3764,7 +3766,7 @@ function RecordForm({
3764
3766
  tryPromise(customization.admin.onChange, [
3765
3767
  operation,
3766
3768
  cloneDeep(form.getValues()) as StokerRecord,
3767
- prevState as StokerRecord,
3769
+ previous.current as StokerRecord,
3768
3770
  ]).then((updatedRecord: StokerRecord) => {
3769
3771
  if (updatedRecord && !isEqual(updatedRecord, formValues)) {
3770
3772
  Object.entries(updatedRecord).forEach(([key, value]) => {
@@ -3773,6 +3775,7 @@ function RecordForm({
3773
3775
  }
3774
3776
  })
3775
3777
  }
3778
+ previous.current = cloneDeep(form.getValues()) as StokerRecord
3776
3779
  }, 0)
3777
3780
  }, [form.watch()])
3778
3781
 
@@ -5226,7 +5229,7 @@ function RecordForm({
5226
5229
  Are you absolutely sure?
5227
5230
  </AlertDialogTitle>
5228
5231
  <AlertDialogDescription>
5229
- {`This will remove system access for this ${labels.record}.`}
5232
+ {`This will remove system access for this ${recordTitle}.`}
5230
5233
  </AlertDialogDescription>
5231
5234
  </AlertDialogHeader>
5232
5235
  <AlertDialogFooter>
package/src/List.tsx CHANGED
@@ -635,10 +635,19 @@ export function List({
635
635
  return [selectColumnDef, ...fieldColumns]
636
636
  }, [fields, isPreloadCacheEnabled, isServerReadOnly, recordTitleField, connectionStatus])
637
637
 
638
+ const isSearchRelevanceOrder = !!(search && isPreloadCacheEnabled)
639
+
638
640
  const searchList = useMemo(() => {
639
641
  if (search && (isPreloadCacheEnabled || isServerReadOnly)) {
640
- const searchResults = localFullTextSearch(collection, search, list || []).map((result) => result.id)
641
- return list?.filter((record) => searchResults.includes(record.id)) || []
642
+ const searchResults = localFullTextSearch(collection, search, list || [])
643
+ if (isPreloadCacheEnabled) {
644
+ const recordsById = new Map((list || []).map((record) => [record.id, record]))
645
+ return searchResults
646
+ .map((result) => recordsById.get(result.id))
647
+ .filter((record): record is StokerRecord => record !== undefined)
648
+ }
649
+ const searchResultIds = searchResults.map((result) => result.id)
650
+ return list?.filter((record) => searchResultIds.includes(record.id)) || []
642
651
  }
643
652
  return list || []
644
653
  }, [isPreloadCacheEnabled, isServerReadOnly, list, search])
@@ -658,6 +667,7 @@ export function List({
658
667
  getCoreRowModel: getCoreRowModel(),
659
668
  getPaginationRowModel: getPaginationRowModel(),
660
669
  onSortingChange: (sortingUpdater) => {
670
+ if (isSearchRelevanceOrder) return
661
671
  if (typeof sortingUpdater === "function") {
662
672
  const newSorting = sortingUpdater(sorting)
663
673
  const field = getField(fields, newSorting[0].id)
@@ -697,9 +707,9 @@ export function List({
697
707
  onRowSelectionChange: setRowSelection,
698
708
  pageCount,
699
709
  autoResetPageIndex: false,
700
- enableSorting: true,
710
+ enableSorting: !isSearchRelevanceOrder,
701
711
  state: {
702
- sorting,
712
+ sorting: isSearchRelevanceOrder ? [] : sorting,
703
713
  columnFilters,
704
714
  rowSelection,
705
715
  pagination: {