tinybase 9.1.0-beta.0 → 9.1.0-beta.1
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/@types/common/index.d.ts +17 -2
- package/@types/common/with-schemas/index.d.ts +18 -2
- package/@types/store/index.d.ts +37 -7
- package/@types/store/with-schemas/index.d.ts +38 -7
- package/@types/ui-react/index.d.ts +6 -2
- package/@types/ui-react/with-schemas/index.d.ts +7 -2
- package/@types/ui-solid/index.d.ts +9 -2
- package/@types/ui-solid/with-schemas/index.d.ts +10 -2
- package/@types/ui-svelte/index.d.ts +50 -2
- package/@types/ui-svelte/with-schemas/index.d.ts +88 -25
- package/index.js +34 -6
- package/mergeable-store/index.js +34 -6
- package/mergeable-store/with-schemas/index.js +34 -6
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/mergeable-store/index.js +1 -1
- package/min/mergeable-store/index.js.gz +0 -0
- package/min/mergeable-store/with-schemas/index.js +1 -1
- package/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/store/index.js +1 -1
- package/min/store/index.js.gz +0 -0
- package/min/store/with-schemas/index.js +1 -1
- package/min/store/with-schemas/index.js.gz +0 -0
- package/min/ui-react/index.js +1 -1
- package/min/ui-react/index.js.gz +0 -0
- package/min/ui-react/with-schemas/index.js +1 -1
- package/min/ui-react/with-schemas/index.js.gz +0 -0
- package/min/ui-react-dom/index.js +1 -1
- package/min/ui-react-dom/index.js.gz +0 -0
- package/min/ui-react-dom/with-schemas/index.js +1 -1
- package/min/ui-react-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-react-dom-charts/index.js +1 -1
- package/min/ui-react-dom-charts/index.js.gz +0 -0
- package/min/ui-react-dom-charts/with-schemas/index.js +1 -1
- package/min/ui-react-dom-charts/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-solid/index.js +1 -1
- package/min/ui-solid/index.js.gz +0 -0
- package/min/ui-solid/with-schemas/index.js +1 -1
- package/min/ui-solid/with-schemas/index.js.gz +0 -0
- package/min/ui-solid-dom/index.js +1 -1
- package/min/ui-solid-dom/index.js.gz +0 -0
- package/min/ui-solid-dom/with-schemas/index.js +1 -1
- package/min/ui-solid-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-solid-inspector/index.js +1 -1
- package/min/ui-solid-inspector/index.js.gz +0 -0
- package/min/ui-solid-inspector/with-schemas/index.js +1 -1
- package/min/ui-solid-inspector/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte/index.js +1 -1
- package/min/ui-svelte/index.js.gz +0 -0
- package/min/ui-svelte/with-schemas/index.js +1 -1
- package/min/ui-svelte/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte-dom/index.js +1 -1
- package/min/ui-svelte-dom/index.js.gz +0 -0
- package/min/ui-svelte-dom/with-schemas/index.js +1 -1
- package/min/ui-svelte-dom/with-schemas/index.js.gz +0 -0
- package/min/ui-svelte-inspector/index.js +1 -1
- package/min/ui-svelte-inspector/index.js.gz +0 -0
- package/min/ui-svelte-inspector/with-schemas/index.js +1 -1
- package/min/ui-svelte-inspector/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/omni/index.js +34 -6
- package/omni/with-schemas/index.js +34 -6
- package/package.json +3 -3
- package/releases.md +1 -1
- package/store/index.js +34 -6
- package/store/with-schemas/index.js +34 -6
- package/ui-react/index.js +36 -6
- package/ui-react/with-schemas/index.js +36 -6
- package/ui-react-dom/index.js +24 -4
- package/ui-react-dom/with-schemas/index.js +24 -4
- package/ui-react-dom-charts/index.js +24 -4
- package/ui-react-dom-charts/with-schemas/index.js +24 -4
- package/ui-react-inspector/index.js +58 -10
- package/ui-react-inspector/with-schemas/index.js +58 -10
- package/ui-solid/index.js +32 -2
- package/ui-solid/with-schemas/index.js +32 -2
- package/ui-solid-dom/index.js +17 -1
- package/ui-solid-dom/with-schemas/index.js +17 -1
- package/ui-solid-inspector/index.js +51 -7
- package/ui-solid-inspector/with-schemas/index.js +51 -7
- package/ui-svelte/index.js +73 -31
- package/ui-svelte/with-schemas/index.js +73 -31
- package/ui-svelte-dom/index.js +35 -14
- package/ui-svelte-dom/with-schemas/index.js +35 -14
- package/ui-svelte-inspector/index.js +69 -20
- package/ui-svelte-inspector/with-schemas/index.js +69 -20
- package/with-schemas/index.js +34 -6
package/ui-react-dom/index.js
CHANGED
|
@@ -312,14 +312,29 @@ const useSortedRowIdsImpl = (
|
|
|
312
312
|
descending,
|
|
313
313
|
offset,
|
|
314
314
|
limit,
|
|
315
|
+
sorter,
|
|
315
316
|
storeOrStoreId,
|
|
316
|
-
) =>
|
|
317
|
-
|
|
317
|
+
) => {
|
|
318
|
+
const sortedRowIdsArgs = useMemo(
|
|
319
|
+
() => ({
|
|
320
|
+
tableId,
|
|
321
|
+
cellId,
|
|
322
|
+
descending: descending ?? false,
|
|
323
|
+
offset: offset ?? 0,
|
|
324
|
+
limit,
|
|
325
|
+
sorter,
|
|
326
|
+
}),
|
|
327
|
+
[tableId, cellId, descending, offset, limit, sorter],
|
|
328
|
+
);
|
|
329
|
+
return useListenable(
|
|
318
330
|
SORTED_ROW_IDS,
|
|
319
331
|
useStoreOrStoreById(storeOrStoreId),
|
|
320
332
|
1 /* Array */,
|
|
321
|
-
|
|
333
|
+
isUndefined(sorter)
|
|
334
|
+
? [tableId, cellId, descending, offset, limit]
|
|
335
|
+
: [sortedRowIdsArgs],
|
|
322
336
|
);
|
|
337
|
+
};
|
|
323
338
|
const useStoreOrStoreById = (storeOrStoreId) =>
|
|
324
339
|
useThingOrThingById(storeOrStoreId, OFFSET_STORE);
|
|
325
340
|
const useTableCellIds = (tableId, storeOrStoreId) =>
|
|
@@ -346,6 +361,7 @@ const useSortedRowIds = (
|
|
|
346
361
|
descending,
|
|
347
362
|
offset,
|
|
348
363
|
limit,
|
|
364
|
+
sorterOrStoreOrStoreId,
|
|
349
365
|
storeOrStoreId,
|
|
350
366
|
) =>
|
|
351
367
|
useSortedRowIdsImpl(
|
|
@@ -356,6 +372,7 @@ const useSortedRowIds = (
|
|
|
356
372
|
tableIdOrArgs.descending ?? false,
|
|
357
373
|
tableIdOrArgs.offset ?? 0,
|
|
358
374
|
tableIdOrArgs.limit,
|
|
375
|
+
tableIdOrArgs.sorter,
|
|
359
376
|
cellIdOrStoreOrStoreId,
|
|
360
377
|
]
|
|
361
378
|
: [
|
|
@@ -364,7 +381,10 @@ const useSortedRowIds = (
|
|
|
364
381
|
descending,
|
|
365
382
|
offset,
|
|
366
383
|
limit,
|
|
367
|
-
|
|
384
|
+
isFunction(sorterOrStoreOrStoreId) ? sorterOrStoreOrStoreId : void 0,
|
|
385
|
+
isFunction(sorterOrStoreOrStoreId)
|
|
386
|
+
? storeOrStoreId
|
|
387
|
+
: sorterOrStoreOrStoreId,
|
|
368
388
|
]),
|
|
369
389
|
);
|
|
370
390
|
const useCell = (tableId, rowId, cellId, storeOrStoreId) =>
|
|
@@ -312,14 +312,29 @@ const useSortedRowIdsImpl = (
|
|
|
312
312
|
descending,
|
|
313
313
|
offset,
|
|
314
314
|
limit,
|
|
315
|
+
sorter,
|
|
315
316
|
storeOrStoreId,
|
|
316
|
-
) =>
|
|
317
|
-
|
|
317
|
+
) => {
|
|
318
|
+
const sortedRowIdsArgs = useMemo(
|
|
319
|
+
() => ({
|
|
320
|
+
tableId,
|
|
321
|
+
cellId,
|
|
322
|
+
descending: descending ?? false,
|
|
323
|
+
offset: offset ?? 0,
|
|
324
|
+
limit,
|
|
325
|
+
sorter,
|
|
326
|
+
}),
|
|
327
|
+
[tableId, cellId, descending, offset, limit, sorter],
|
|
328
|
+
);
|
|
329
|
+
return useListenable(
|
|
318
330
|
SORTED_ROW_IDS,
|
|
319
331
|
useStoreOrStoreById(storeOrStoreId),
|
|
320
332
|
1 /* Array */,
|
|
321
|
-
|
|
333
|
+
isUndefined(sorter)
|
|
334
|
+
? [tableId, cellId, descending, offset, limit]
|
|
335
|
+
: [sortedRowIdsArgs],
|
|
322
336
|
);
|
|
337
|
+
};
|
|
323
338
|
const useStoreOrStoreById = (storeOrStoreId) =>
|
|
324
339
|
useThingOrThingById(storeOrStoreId, OFFSET_STORE);
|
|
325
340
|
const useTableCellIds = (tableId, storeOrStoreId) =>
|
|
@@ -346,6 +361,7 @@ const useSortedRowIds = (
|
|
|
346
361
|
descending,
|
|
347
362
|
offset,
|
|
348
363
|
limit,
|
|
364
|
+
sorterOrStoreOrStoreId,
|
|
349
365
|
storeOrStoreId,
|
|
350
366
|
) =>
|
|
351
367
|
useSortedRowIdsImpl(
|
|
@@ -356,6 +372,7 @@ const useSortedRowIds = (
|
|
|
356
372
|
tableIdOrArgs.descending ?? false,
|
|
357
373
|
tableIdOrArgs.offset ?? 0,
|
|
358
374
|
tableIdOrArgs.limit,
|
|
375
|
+
tableIdOrArgs.sorter,
|
|
359
376
|
cellIdOrStoreOrStoreId,
|
|
360
377
|
]
|
|
361
378
|
: [
|
|
@@ -364,7 +381,10 @@ const useSortedRowIds = (
|
|
|
364
381
|
descending,
|
|
365
382
|
offset,
|
|
366
383
|
limit,
|
|
367
|
-
|
|
384
|
+
isFunction(sorterOrStoreOrStoreId) ? sorterOrStoreOrStoreId : void 0,
|
|
385
|
+
isFunction(sorterOrStoreOrStoreId)
|
|
386
|
+
? storeOrStoreId
|
|
387
|
+
: sorterOrStoreOrStoreId,
|
|
368
388
|
]),
|
|
369
389
|
);
|
|
370
390
|
const useCell = (tableId, rowId, cellId, storeOrStoreId) =>
|
|
@@ -917,14 +917,29 @@ const useSortedRowIdsImpl = (
|
|
|
917
917
|
descending,
|
|
918
918
|
offset,
|
|
919
919
|
limit,
|
|
920
|
+
sorter,
|
|
920
921
|
storeOrStoreId,
|
|
921
|
-
) =>
|
|
922
|
-
|
|
922
|
+
) => {
|
|
923
|
+
const sortedRowIdsArgs = useMemo(
|
|
924
|
+
() => ({
|
|
925
|
+
tableId,
|
|
926
|
+
cellId,
|
|
927
|
+
descending: descending ?? false,
|
|
928
|
+
offset: offset ?? 0,
|
|
929
|
+
limit,
|
|
930
|
+
sorter,
|
|
931
|
+
}),
|
|
932
|
+
[tableId, cellId, descending, offset, limit, sorter],
|
|
933
|
+
);
|
|
934
|
+
return useListenable(
|
|
923
935
|
SORTED_ROW_IDS,
|
|
924
936
|
useStoreOrStoreById(storeOrStoreId),
|
|
925
937
|
1 /* Array */,
|
|
926
|
-
|
|
938
|
+
isUndefined(sorter)
|
|
939
|
+
? [tableId, cellId, descending, offset, limit]
|
|
940
|
+
: [sortedRowIdsArgs],
|
|
927
941
|
);
|
|
942
|
+
};
|
|
928
943
|
const useStoreOrStoreById = (storeOrStoreId) =>
|
|
929
944
|
useThingOrThingById(storeOrStoreId, OFFSET_STORE);
|
|
930
945
|
const useSortedRowIds = (
|
|
@@ -933,6 +948,7 @@ const useSortedRowIds = (
|
|
|
933
948
|
descending,
|
|
934
949
|
offset,
|
|
935
950
|
limit,
|
|
951
|
+
sorterOrStoreOrStoreId,
|
|
936
952
|
storeOrStoreId,
|
|
937
953
|
) =>
|
|
938
954
|
useSortedRowIdsImpl(
|
|
@@ -943,6 +959,7 @@ const useSortedRowIds = (
|
|
|
943
959
|
tableIdOrArgs.descending ?? false,
|
|
944
960
|
tableIdOrArgs.offset ?? 0,
|
|
945
961
|
tableIdOrArgs.limit,
|
|
962
|
+
tableIdOrArgs.sorter,
|
|
946
963
|
cellIdOrStoreOrStoreId,
|
|
947
964
|
]
|
|
948
965
|
: [
|
|
@@ -951,7 +968,10 @@ const useSortedRowIds = (
|
|
|
951
968
|
descending,
|
|
952
969
|
offset,
|
|
953
970
|
limit,
|
|
954
|
-
|
|
971
|
+
isFunction(sorterOrStoreOrStoreId) ? sorterOrStoreOrStoreId : void 0,
|
|
972
|
+
isFunction(sorterOrStoreOrStoreId)
|
|
973
|
+
? storeOrStoreId
|
|
974
|
+
: sorterOrStoreOrStoreId,
|
|
955
975
|
]),
|
|
956
976
|
);
|
|
957
977
|
const useCellListener = (
|
|
@@ -917,14 +917,29 @@ const useSortedRowIdsImpl = (
|
|
|
917
917
|
descending,
|
|
918
918
|
offset,
|
|
919
919
|
limit,
|
|
920
|
+
sorter,
|
|
920
921
|
storeOrStoreId,
|
|
921
|
-
) =>
|
|
922
|
-
|
|
922
|
+
) => {
|
|
923
|
+
const sortedRowIdsArgs = useMemo(
|
|
924
|
+
() => ({
|
|
925
|
+
tableId,
|
|
926
|
+
cellId,
|
|
927
|
+
descending: descending ?? false,
|
|
928
|
+
offset: offset ?? 0,
|
|
929
|
+
limit,
|
|
930
|
+
sorter,
|
|
931
|
+
}),
|
|
932
|
+
[tableId, cellId, descending, offset, limit, sorter],
|
|
933
|
+
);
|
|
934
|
+
return useListenable(
|
|
923
935
|
SORTED_ROW_IDS,
|
|
924
936
|
useStoreOrStoreById(storeOrStoreId),
|
|
925
937
|
1 /* Array */,
|
|
926
|
-
|
|
938
|
+
isUndefined(sorter)
|
|
939
|
+
? [tableId, cellId, descending, offset, limit]
|
|
940
|
+
: [sortedRowIdsArgs],
|
|
927
941
|
);
|
|
942
|
+
};
|
|
928
943
|
const useStoreOrStoreById = (storeOrStoreId) =>
|
|
929
944
|
useThingOrThingById(storeOrStoreId, OFFSET_STORE);
|
|
930
945
|
const useSortedRowIds = (
|
|
@@ -933,6 +948,7 @@ const useSortedRowIds = (
|
|
|
933
948
|
descending,
|
|
934
949
|
offset,
|
|
935
950
|
limit,
|
|
951
|
+
sorterOrStoreOrStoreId,
|
|
936
952
|
storeOrStoreId,
|
|
937
953
|
) =>
|
|
938
954
|
useSortedRowIdsImpl(
|
|
@@ -943,6 +959,7 @@ const useSortedRowIds = (
|
|
|
943
959
|
tableIdOrArgs.descending ?? false,
|
|
944
960
|
tableIdOrArgs.offset ?? 0,
|
|
945
961
|
tableIdOrArgs.limit,
|
|
962
|
+
tableIdOrArgs.sorter,
|
|
946
963
|
cellIdOrStoreOrStoreId,
|
|
947
964
|
]
|
|
948
965
|
: [
|
|
@@ -951,7 +968,10 @@ const useSortedRowIds = (
|
|
|
951
968
|
descending,
|
|
952
969
|
offset,
|
|
953
970
|
limit,
|
|
954
|
-
|
|
971
|
+
isFunction(sorterOrStoreOrStoreId) ? sorterOrStoreOrStoreId : void 0,
|
|
972
|
+
isFunction(sorterOrStoreOrStoreId)
|
|
973
|
+
? storeOrStoreId
|
|
974
|
+
: sorterOrStoreOrStoreId,
|
|
955
975
|
]),
|
|
956
976
|
);
|
|
957
977
|
const useCellListener = (
|
|
@@ -2117,13 +2117,36 @@ const createStore = () => {
|
|
|
2117
2117
|
listener,
|
|
2118
2118
|
mutator,
|
|
2119
2119
|
) => {
|
|
2120
|
-
|
|
2120
|
+
const [descending, offset, limit, sorter] = otherArgs;
|
|
2121
|
+
let sortedRowIds = getSortedRowIds(
|
|
2122
|
+
tableId,
|
|
2123
|
+
cellId,
|
|
2124
|
+
descending,
|
|
2125
|
+
offset,
|
|
2126
|
+
limit,
|
|
2127
|
+
sorter,
|
|
2128
|
+
);
|
|
2121
2129
|
return addListener(
|
|
2122
2130
|
() => {
|
|
2123
|
-
const newSortedRowIds = getSortedRowIds(
|
|
2131
|
+
const newSortedRowIds = getSortedRowIds(
|
|
2132
|
+
tableId,
|
|
2133
|
+
cellId,
|
|
2134
|
+
descending,
|
|
2135
|
+
offset,
|
|
2136
|
+
limit,
|
|
2137
|
+
sorter,
|
|
2138
|
+
);
|
|
2124
2139
|
if (!arrayIsEqual(newSortedRowIds, sortedRowIds)) {
|
|
2125
2140
|
sortedRowIds = newSortedRowIds;
|
|
2126
|
-
listener(
|
|
2141
|
+
listener(
|
|
2142
|
+
store,
|
|
2143
|
+
tableId,
|
|
2144
|
+
cellId,
|
|
2145
|
+
descending,
|
|
2146
|
+
offset,
|
|
2147
|
+
limit,
|
|
2148
|
+
sortedRowIds,
|
|
2149
|
+
);
|
|
2127
2150
|
}
|
|
2128
2151
|
},
|
|
2129
2152
|
sortedRowIdsListeners[mutator ? 1 : 0],
|
|
@@ -2177,6 +2200,7 @@ const createStore = () => {
|
|
|
2177
2200
|
descending,
|
|
2178
2201
|
offset = 0,
|
|
2179
2202
|
limit,
|
|
2203
|
+
sorter = defaultSorter,
|
|
2180
2204
|
) =>
|
|
2181
2205
|
isObject(tableIdOrArgs)
|
|
2182
2206
|
? getSortedRowIds(
|
|
@@ -2185,16 +2209,19 @@ const createStore = () => {
|
|
|
2185
2209
|
tableIdOrArgs.descending,
|
|
2186
2210
|
tableIdOrArgs.offset,
|
|
2187
2211
|
tableIdOrArgs.limit,
|
|
2212
|
+
tableIdOrArgs.sorter,
|
|
2188
2213
|
)
|
|
2189
2214
|
: arrayMap(
|
|
2190
2215
|
slice(
|
|
2191
2216
|
arraySort(
|
|
2192
2217
|
mapMap(mapGet(tablesMap, id(tableIdOrArgs)), (row, rowId) => [
|
|
2193
|
-
isUndefined(cellId)
|
|
2218
|
+
isUndefined(cellId)
|
|
2219
|
+
? rowId
|
|
2220
|
+
: decodeIfJson(mapGet(row, id(cellId))),
|
|
2194
2221
|
rowId,
|
|
2195
2222
|
]),
|
|
2196
2223
|
([cell1], [cell2]) =>
|
|
2197
|
-
|
|
2224
|
+
sorter(cell1, cell2) * (descending ? -1 : 1),
|
|
2198
2225
|
),
|
|
2199
2226
|
offset,
|
|
2200
2227
|
isUndefined(limit) ? limit : offset + limit,
|
|
@@ -2672,6 +2699,7 @@ const createStore = () => {
|
|
|
2672
2699
|
tableIdOrArgs.descending ?? false,
|
|
2673
2700
|
tableIdOrArgs.offset ?? 0,
|
|
2674
2701
|
tableIdOrArgs.limit,
|
|
2702
|
+
tableIdOrArgs.sorter,
|
|
2675
2703
|
],
|
|
2676
2704
|
cellIdOrListener,
|
|
2677
2705
|
descendingOrMutator,
|
|
@@ -2679,7 +2707,7 @@ const createStore = () => {
|
|
|
2679
2707
|
: addSortedRowIdsListenerImpl(
|
|
2680
2708
|
tableIdOrArgs,
|
|
2681
2709
|
cellIdOrListener,
|
|
2682
|
-
[descendingOrMutator, offset, limit],
|
|
2710
|
+
[descendingOrMutator, offset, limit, void 0],
|
|
2683
2711
|
listener,
|
|
2684
2712
|
mutator,
|
|
2685
2713
|
);
|
|
@@ -3153,14 +3181,29 @@ const useSortedRowIdsImpl = (
|
|
|
3153
3181
|
descending,
|
|
3154
3182
|
offset,
|
|
3155
3183
|
limit,
|
|
3184
|
+
sorter,
|
|
3156
3185
|
storeOrStoreId,
|
|
3157
|
-
) =>
|
|
3158
|
-
|
|
3186
|
+
) => {
|
|
3187
|
+
const sortedRowIdsArgs = useMemo(
|
|
3188
|
+
() => ({
|
|
3189
|
+
tableId,
|
|
3190
|
+
cellId,
|
|
3191
|
+
descending: descending ?? false,
|
|
3192
|
+
offset: offset ?? 0,
|
|
3193
|
+
limit,
|
|
3194
|
+
sorter,
|
|
3195
|
+
}),
|
|
3196
|
+
[tableId, cellId, descending, offset, limit, sorter],
|
|
3197
|
+
);
|
|
3198
|
+
return useListenable(
|
|
3159
3199
|
SORTED_ROW_IDS,
|
|
3160
3200
|
useStoreOrStoreById(storeOrStoreId),
|
|
3161
3201
|
1 /* Array */,
|
|
3162
|
-
|
|
3202
|
+
isUndefined(sorter)
|
|
3203
|
+
? [tableId, cellId, descending, offset, limit]
|
|
3204
|
+
: [sortedRowIdsArgs],
|
|
3163
3205
|
);
|
|
3206
|
+
};
|
|
3164
3207
|
const useStoreOrStoreById = (storeOrStoreId) =>
|
|
3165
3208
|
useThingOrThingById(storeOrStoreId, OFFSET_STORE);
|
|
3166
3209
|
const useHasTables = (storeOrStoreId) =>
|
|
@@ -3194,6 +3237,7 @@ const useSortedRowIds = (
|
|
|
3194
3237
|
descending,
|
|
3195
3238
|
offset,
|
|
3196
3239
|
limit,
|
|
3240
|
+
sorterOrStoreOrStoreId,
|
|
3197
3241
|
storeOrStoreId,
|
|
3198
3242
|
) =>
|
|
3199
3243
|
useSortedRowIdsImpl(
|
|
@@ -3204,6 +3248,7 @@ const useSortedRowIds = (
|
|
|
3204
3248
|
tableIdOrArgs.descending ?? false,
|
|
3205
3249
|
tableIdOrArgs.offset ?? 0,
|
|
3206
3250
|
tableIdOrArgs.limit,
|
|
3251
|
+
tableIdOrArgs.sorter,
|
|
3207
3252
|
cellIdOrStoreOrStoreId,
|
|
3208
3253
|
]
|
|
3209
3254
|
: [
|
|
@@ -3212,7 +3257,10 @@ const useSortedRowIds = (
|
|
|
3212
3257
|
descending,
|
|
3213
3258
|
offset,
|
|
3214
3259
|
limit,
|
|
3215
|
-
|
|
3260
|
+
isFunction(sorterOrStoreOrStoreId) ? sorterOrStoreOrStoreId : void 0,
|
|
3261
|
+
isFunction(sorterOrStoreOrStoreId)
|
|
3262
|
+
? storeOrStoreId
|
|
3263
|
+
: sorterOrStoreOrStoreId,
|
|
3216
3264
|
]),
|
|
3217
3265
|
);
|
|
3218
3266
|
const useCell = (tableId, rowId, cellId, storeOrStoreId) =>
|
|
@@ -2117,13 +2117,36 @@ const createStore = () => {
|
|
|
2117
2117
|
listener,
|
|
2118
2118
|
mutator,
|
|
2119
2119
|
) => {
|
|
2120
|
-
|
|
2120
|
+
const [descending, offset, limit, sorter] = otherArgs;
|
|
2121
|
+
let sortedRowIds = getSortedRowIds(
|
|
2122
|
+
tableId,
|
|
2123
|
+
cellId,
|
|
2124
|
+
descending,
|
|
2125
|
+
offset,
|
|
2126
|
+
limit,
|
|
2127
|
+
sorter,
|
|
2128
|
+
);
|
|
2121
2129
|
return addListener(
|
|
2122
2130
|
() => {
|
|
2123
|
-
const newSortedRowIds = getSortedRowIds(
|
|
2131
|
+
const newSortedRowIds = getSortedRowIds(
|
|
2132
|
+
tableId,
|
|
2133
|
+
cellId,
|
|
2134
|
+
descending,
|
|
2135
|
+
offset,
|
|
2136
|
+
limit,
|
|
2137
|
+
sorter,
|
|
2138
|
+
);
|
|
2124
2139
|
if (!arrayIsEqual(newSortedRowIds, sortedRowIds)) {
|
|
2125
2140
|
sortedRowIds = newSortedRowIds;
|
|
2126
|
-
listener(
|
|
2141
|
+
listener(
|
|
2142
|
+
store,
|
|
2143
|
+
tableId,
|
|
2144
|
+
cellId,
|
|
2145
|
+
descending,
|
|
2146
|
+
offset,
|
|
2147
|
+
limit,
|
|
2148
|
+
sortedRowIds,
|
|
2149
|
+
);
|
|
2127
2150
|
}
|
|
2128
2151
|
},
|
|
2129
2152
|
sortedRowIdsListeners[mutator ? 1 : 0],
|
|
@@ -2177,6 +2200,7 @@ const createStore = () => {
|
|
|
2177
2200
|
descending,
|
|
2178
2201
|
offset = 0,
|
|
2179
2202
|
limit,
|
|
2203
|
+
sorter = defaultSorter,
|
|
2180
2204
|
) =>
|
|
2181
2205
|
isObject(tableIdOrArgs)
|
|
2182
2206
|
? getSortedRowIds(
|
|
@@ -2185,16 +2209,19 @@ const createStore = () => {
|
|
|
2185
2209
|
tableIdOrArgs.descending,
|
|
2186
2210
|
tableIdOrArgs.offset,
|
|
2187
2211
|
tableIdOrArgs.limit,
|
|
2212
|
+
tableIdOrArgs.sorter,
|
|
2188
2213
|
)
|
|
2189
2214
|
: arrayMap(
|
|
2190
2215
|
slice(
|
|
2191
2216
|
arraySort(
|
|
2192
2217
|
mapMap(mapGet(tablesMap, id(tableIdOrArgs)), (row, rowId) => [
|
|
2193
|
-
isUndefined(cellId)
|
|
2218
|
+
isUndefined(cellId)
|
|
2219
|
+
? rowId
|
|
2220
|
+
: decodeIfJson(mapGet(row, id(cellId))),
|
|
2194
2221
|
rowId,
|
|
2195
2222
|
]),
|
|
2196
2223
|
([cell1], [cell2]) =>
|
|
2197
|
-
|
|
2224
|
+
sorter(cell1, cell2) * (descending ? -1 : 1),
|
|
2198
2225
|
),
|
|
2199
2226
|
offset,
|
|
2200
2227
|
isUndefined(limit) ? limit : offset + limit,
|
|
@@ -2672,6 +2699,7 @@ const createStore = () => {
|
|
|
2672
2699
|
tableIdOrArgs.descending ?? false,
|
|
2673
2700
|
tableIdOrArgs.offset ?? 0,
|
|
2674
2701
|
tableIdOrArgs.limit,
|
|
2702
|
+
tableIdOrArgs.sorter,
|
|
2675
2703
|
],
|
|
2676
2704
|
cellIdOrListener,
|
|
2677
2705
|
descendingOrMutator,
|
|
@@ -2679,7 +2707,7 @@ const createStore = () => {
|
|
|
2679
2707
|
: addSortedRowIdsListenerImpl(
|
|
2680
2708
|
tableIdOrArgs,
|
|
2681
2709
|
cellIdOrListener,
|
|
2682
|
-
[descendingOrMutator, offset, limit],
|
|
2710
|
+
[descendingOrMutator, offset, limit, void 0],
|
|
2683
2711
|
listener,
|
|
2684
2712
|
mutator,
|
|
2685
2713
|
);
|
|
@@ -3153,14 +3181,29 @@ const useSortedRowIdsImpl = (
|
|
|
3153
3181
|
descending,
|
|
3154
3182
|
offset,
|
|
3155
3183
|
limit,
|
|
3184
|
+
sorter,
|
|
3156
3185
|
storeOrStoreId,
|
|
3157
|
-
) =>
|
|
3158
|
-
|
|
3186
|
+
) => {
|
|
3187
|
+
const sortedRowIdsArgs = useMemo(
|
|
3188
|
+
() => ({
|
|
3189
|
+
tableId,
|
|
3190
|
+
cellId,
|
|
3191
|
+
descending: descending ?? false,
|
|
3192
|
+
offset: offset ?? 0,
|
|
3193
|
+
limit,
|
|
3194
|
+
sorter,
|
|
3195
|
+
}),
|
|
3196
|
+
[tableId, cellId, descending, offset, limit, sorter],
|
|
3197
|
+
);
|
|
3198
|
+
return useListenable(
|
|
3159
3199
|
SORTED_ROW_IDS,
|
|
3160
3200
|
useStoreOrStoreById(storeOrStoreId),
|
|
3161
3201
|
1 /* Array */,
|
|
3162
|
-
|
|
3202
|
+
isUndefined(sorter)
|
|
3203
|
+
? [tableId, cellId, descending, offset, limit]
|
|
3204
|
+
: [sortedRowIdsArgs],
|
|
3163
3205
|
);
|
|
3206
|
+
};
|
|
3164
3207
|
const useStoreOrStoreById = (storeOrStoreId) =>
|
|
3165
3208
|
useThingOrThingById(storeOrStoreId, OFFSET_STORE);
|
|
3166
3209
|
const useHasTables = (storeOrStoreId) =>
|
|
@@ -3194,6 +3237,7 @@ const useSortedRowIds = (
|
|
|
3194
3237
|
descending,
|
|
3195
3238
|
offset,
|
|
3196
3239
|
limit,
|
|
3240
|
+
sorterOrStoreOrStoreId,
|
|
3197
3241
|
storeOrStoreId,
|
|
3198
3242
|
) =>
|
|
3199
3243
|
useSortedRowIdsImpl(
|
|
@@ -3204,6 +3248,7 @@ const useSortedRowIds = (
|
|
|
3204
3248
|
tableIdOrArgs.descending ?? false,
|
|
3205
3249
|
tableIdOrArgs.offset ?? 0,
|
|
3206
3250
|
tableIdOrArgs.limit,
|
|
3251
|
+
tableIdOrArgs.sorter,
|
|
3207
3252
|
cellIdOrStoreOrStoreId,
|
|
3208
3253
|
]
|
|
3209
3254
|
: [
|
|
@@ -3212,7 +3257,10 @@ const useSortedRowIds = (
|
|
|
3212
3257
|
descending,
|
|
3213
3258
|
offset,
|
|
3214
3259
|
limit,
|
|
3215
|
-
|
|
3260
|
+
isFunction(sorterOrStoreOrStoreId) ? sorterOrStoreOrStoreId : void 0,
|
|
3261
|
+
isFunction(sorterOrStoreOrStoreId)
|
|
3262
|
+
? storeOrStoreId
|
|
3263
|
+
: sorterOrStoreOrStoreId,
|
|
3216
3264
|
]),
|
|
3217
3265
|
);
|
|
3218
3266
|
const useCell = (tableId, rowId, cellId, storeOrStoreId) =>
|
package/ui-solid/index.js
CHANGED
|
@@ -467,13 +467,25 @@ const useSortedRowIdsImpl = (
|
|
|
467
467
|
descending,
|
|
468
468
|
offset,
|
|
469
469
|
limit,
|
|
470
|
+
sorter,
|
|
470
471
|
storeOrStoreId,
|
|
471
472
|
) =>
|
|
472
473
|
useListenable(
|
|
473
474
|
SORTED_ROW_IDS,
|
|
474
475
|
useStoreOrStoreById(storeOrStoreId),
|
|
475
476
|
1 /* Array */,
|
|
476
|
-
|
|
477
|
+
isUndefined(sorter)
|
|
478
|
+
? [tableId, cellId, descending, offset, limit]
|
|
479
|
+
: [
|
|
480
|
+
() => ({
|
|
481
|
+
tableId: getThing(tableId),
|
|
482
|
+
cellId: getThing(cellId),
|
|
483
|
+
descending: getThing(descending) ?? false,
|
|
484
|
+
offset: getThing(offset) ?? 0,
|
|
485
|
+
limit: getThing(limit),
|
|
486
|
+
sorter: getThing(sorter),
|
|
487
|
+
}),
|
|
488
|
+
],
|
|
477
489
|
);
|
|
478
490
|
const useSortedRowIdsListenerImpl = (
|
|
479
491
|
tableId,
|
|
@@ -481,6 +493,7 @@ const useSortedRowIdsListenerImpl = (
|
|
|
481
493
|
descending,
|
|
482
494
|
offset,
|
|
483
495
|
limit,
|
|
496
|
+
sorter,
|
|
484
497
|
listener,
|
|
485
498
|
mutator,
|
|
486
499
|
storeOrStoreId,
|
|
@@ -489,7 +502,18 @@ const useSortedRowIdsListenerImpl = (
|
|
|
489
502
|
SORTED_ROW_IDS,
|
|
490
503
|
useStoreOrStoreById(storeOrStoreId),
|
|
491
504
|
listener,
|
|
492
|
-
|
|
505
|
+
isUndefined(sorter)
|
|
506
|
+
? [tableId, cellId, descending, offset, limit]
|
|
507
|
+
: [
|
|
508
|
+
() => ({
|
|
509
|
+
tableId: getThing(tableId),
|
|
510
|
+
cellId: getThing(cellId),
|
|
511
|
+
descending: getThing(descending),
|
|
512
|
+
offset: getThing(offset),
|
|
513
|
+
limit: getThing(limit),
|
|
514
|
+
sorter: getThing(sorter),
|
|
515
|
+
}),
|
|
516
|
+
],
|
|
493
517
|
mutator,
|
|
494
518
|
);
|
|
495
519
|
const useCreateStore = (create) => {
|
|
@@ -565,6 +589,7 @@ const useSortedRowIds = (
|
|
|
565
589
|
descending,
|
|
566
590
|
offset,
|
|
567
591
|
limit,
|
|
592
|
+
sorter,
|
|
568
593
|
storeOrStoreId,
|
|
569
594
|
) =>
|
|
570
595
|
isObject(tableIdOrArgs)
|
|
@@ -574,6 +599,7 @@ const useSortedRowIds = (
|
|
|
574
599
|
tableIdOrArgs.descending ?? false,
|
|
575
600
|
tableIdOrArgs.offset ?? 0,
|
|
576
601
|
tableIdOrArgs.limit,
|
|
602
|
+
() => tableIdOrArgs.sorter,
|
|
577
603
|
cellIdOrStoreOrStoreId,
|
|
578
604
|
)
|
|
579
605
|
: useSortedRowIdsImpl(
|
|
@@ -582,6 +608,7 @@ const useSortedRowIds = (
|
|
|
582
608
|
descending,
|
|
583
609
|
offset,
|
|
584
610
|
limit,
|
|
611
|
+
isUndefined(sorter) ? void 0 : () => sorter,
|
|
585
612
|
storeOrStoreId,
|
|
586
613
|
);
|
|
587
614
|
const useHasRow = (tableId, rowId, storeOrStoreId) =>
|
|
@@ -830,6 +857,7 @@ const useSortedRowIdsListener = (
|
|
|
830
857
|
tableIdOrArgs.descending ?? false,
|
|
831
858
|
tableIdOrArgs.offset ?? 0,
|
|
832
859
|
tableIdOrArgs.limit,
|
|
860
|
+
() => tableIdOrArgs.sorter,
|
|
833
861
|
cellIdOrListener,
|
|
834
862
|
descendingOrMutator,
|
|
835
863
|
offsetOrStoreOrStoreId,
|
|
@@ -840,6 +868,7 @@ const useSortedRowIdsListener = (
|
|
|
840
868
|
descendingOrMutator ?? false,
|
|
841
869
|
offsetOrStoreOrStoreId ?? 0,
|
|
842
870
|
limit,
|
|
871
|
+
void 0,
|
|
843
872
|
listener,
|
|
844
873
|
mutator,
|
|
845
874
|
storeOrStoreId,
|
|
@@ -1985,6 +2014,7 @@ const SortedTableView = (props) =>
|
|
|
1985
2014
|
() => props.descending,
|
|
1986
2015
|
() => props.offset,
|
|
1987
2016
|
() => props.limit,
|
|
2017
|
+
void 0,
|
|
1988
2018
|
() => props.store,
|
|
1989
2019
|
),
|
|
1990
2020
|
);
|