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/@types/common/index.d.ts
CHANGED
|
@@ -83,11 +83,26 @@ export type ParameterizedCallback<Parameter> = (parameter?: Parameter) => void;
|
|
|
83
83
|
export type Callback = () => void;
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* The SortKey type represents a value that can be used by
|
|
86
|
+
* The SortKey type represents a Cell value, or `undefined`, that can be used by
|
|
87
|
+
* a sort function.
|
|
87
88
|
* @category Parameter
|
|
88
89
|
* @since v1.0.0
|
|
89
90
|
*/
|
|
90
|
-
export type SortKey =
|
|
91
|
+
export type SortKey = CellOrUndefined;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The Sorter type represents a function that compares two SortKey values.
|
|
95
|
+
*
|
|
96
|
+
* A Sorter is provided to methods that sort Row Ids when the default
|
|
97
|
+
* alphanumeric ordering is not appropriate. Return a positive or negative
|
|
98
|
+
* number to indicate which of the two SortKey values should be ordered first.
|
|
99
|
+
* @param sortKey1 The first item of the pair to compare.
|
|
100
|
+
* @param sortKey2 The second item of the pair to compare.
|
|
101
|
+
* @returns A number indicating how to sort the pair.
|
|
102
|
+
* @category Parameter
|
|
103
|
+
* @since v9.1.0
|
|
104
|
+
*/
|
|
105
|
+
export type Sorter = (sortKey1: SortKey, sortKey2: SortKey) => number;
|
|
91
106
|
|
|
92
107
|
/**
|
|
93
108
|
* The GetNow type is used to represent a function that returns the current time
|
|
@@ -95,11 +95,27 @@ export type ParameterizedCallback<Parameter> = (parameter?: Parameter) => void;
|
|
|
95
95
|
export type Callback = () => void;
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
* The SortKey type represents a value that can be used by
|
|
98
|
+
* The SortKey type represents a Cell value, or `undefined`, that can be used by
|
|
99
|
+
* a sort function.
|
|
99
100
|
* @category Parameter
|
|
100
101
|
* @since v1.0.0
|
|
101
102
|
*/
|
|
102
|
-
export type SortKey =
|
|
103
|
+
export type SortKey =
|
|
104
|
+
string | number | boolean | null | AnyObject | AnyArray | undefined;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The Sorter type represents a function that compares two SortKey values.
|
|
108
|
+
*
|
|
109
|
+
* A Sorter is provided to methods that sort Row Ids when the default
|
|
110
|
+
* alphanumeric ordering is not appropriate. Return a positive or negative
|
|
111
|
+
* number to indicate which of the two SortKey values should be ordered first.
|
|
112
|
+
* @param sortKey1 The first item of the pair to compare.
|
|
113
|
+
* @param sortKey2 The second item of the pair to compare.
|
|
114
|
+
* @returns A number indicating how to sort the pair.
|
|
115
|
+
* @category Parameter
|
|
116
|
+
* @since v9.1.0
|
|
117
|
+
*/
|
|
118
|
+
export type Sorter = (sortKey1: SortKey, sortKey2: SortKey) => number;
|
|
103
119
|
|
|
104
120
|
/**
|
|
105
121
|
* The GetNow type is used to represent a function that returns the current time
|
package/@types/store/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
IdOrNull,
|
|
19
19
|
Ids,
|
|
20
20
|
Json,
|
|
21
|
+
Sorter,
|
|
21
22
|
} from '../common/index.d.ts';
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -625,7 +626,7 @@ export type DoRollback = (store: Store) => boolean;
|
|
|
625
626
|
* the getSortedRowIds method.
|
|
626
627
|
*
|
|
627
628
|
* It's an object containing the Id of the Table in the Store, and optional
|
|
628
|
-
* `cellId`, `descending`, `offset`, and `
|
|
629
|
+
* `cellId`, `descending`, `offset`, `limit`, and `sorter` parameters. See the
|
|
629
630
|
* getSortedRowIds method for specific examples.
|
|
630
631
|
* @category Store
|
|
631
632
|
* @since v6.1.0
|
|
@@ -662,6 +663,13 @@ export type SortedRowIdsArgs = {
|
|
|
662
663
|
* @since v6.1.0
|
|
663
664
|
*/
|
|
664
665
|
limit?: number;
|
|
666
|
+
/**
|
|
667
|
+
* A custom function for comparing the sorting values, defaulting to the
|
|
668
|
+
* defaultSorter function.
|
|
669
|
+
* @category Argument
|
|
670
|
+
* @since v9.1.0
|
|
671
|
+
*/
|
|
672
|
+
sorter?: Sorter;
|
|
665
673
|
};
|
|
666
674
|
|
|
667
675
|
/**
|
|
@@ -2196,10 +2204,11 @@ export interface Store {
|
|
|
2196
2204
|
* The getSortedRowIds method returns the Ids of every Row in a given Table,
|
|
2197
2205
|
* sorted according to the values in a specified Cell.
|
|
2198
2206
|
*
|
|
2199
|
-
*
|
|
2200
|
-
* should be in descending order. The `offset` and `limit`
|
|
2201
|
-
* to paginate results, but default to `0` and
|
|
2202
|
-
* available Row Ids if not specified.
|
|
2207
|
+
* By default the sorting of the rows is alphanumeric, and you can indicate
|
|
2208
|
+
* whether it should be in descending order. The `offset` and `limit`
|
|
2209
|
+
* parameters are used to paginate results, but default to `0` and
|
|
2210
|
+
* `undefined` to return all available Row Ids if not specified. The `sorter`
|
|
2211
|
+
* parameter can provide a custom comparison function.
|
|
2203
2212
|
*
|
|
2204
2213
|
* Note that every call to this method will perform the sorting afresh - there
|
|
2205
2214
|
* is no caching of the results - and so you are advised to memoize the
|
|
@@ -2216,6 +2225,8 @@ export interface Store {
|
|
|
2216
2225
|
* any.
|
|
2217
2226
|
* @param limit The maximum number of Row Ids to return, or `undefined` for
|
|
2218
2227
|
* all.
|
|
2228
|
+
* @param sorter A custom function for comparing the sorting values, or
|
|
2229
|
+
* `undefined` to use the defaultSorter function.
|
|
2219
2230
|
* @returns An array of the sorted Ids of appropriate Rows in the Table.
|
|
2220
2231
|
* @example
|
|
2221
2232
|
* This example retrieves sorted Row Ids in a Table.
|
|
@@ -2287,6 +2298,24 @@ export interface Store {
|
|
|
2287
2298
|
* // -> ['cujo', 'felix', 'fido']
|
|
2288
2299
|
* ```
|
|
2289
2300
|
* @example
|
|
2301
|
+
* This example retrieves Row Ids sorted numerically by their own value.
|
|
2302
|
+
*
|
|
2303
|
+
* ```js
|
|
2304
|
+
* import {createStore} from 'tinybase';
|
|
2305
|
+
*
|
|
2306
|
+
* const store = createStore();
|
|
2307
|
+
* ['1', '10', '2'].forEach((rowId) =>
|
|
2308
|
+
* store.setRow('pets', rowId, {sold: false}),
|
|
2309
|
+
* );
|
|
2310
|
+
* const numericSorter = (sortKey1, sortKey2) =>
|
|
2311
|
+
* Number(sortKey1) - Number(sortKey2);
|
|
2312
|
+
*
|
|
2313
|
+
* console.log(
|
|
2314
|
+
* store.getSortedRowIds({tableId: 'pets', sorter: numericSorter}),
|
|
2315
|
+
* );
|
|
2316
|
+
* // -> ['1', '2', '10']
|
|
2317
|
+
* ```
|
|
2318
|
+
* @example
|
|
2290
2319
|
* This example retrieves the sorted Row Ids of a Table that does not exist,
|
|
2291
2320
|
* returning an empty array.
|
|
2292
2321
|
*
|
|
@@ -2306,13 +2335,14 @@ export interface Store {
|
|
|
2306
2335
|
descending?: boolean,
|
|
2307
2336
|
offset?: number,
|
|
2308
2337
|
limit?: number,
|
|
2338
|
+
sorter?: Sorter,
|
|
2309
2339
|
): Ids;
|
|
2310
2340
|
|
|
2311
2341
|
/**
|
|
2312
2342
|
* When called with one object argument, the getSortedRowIds method
|
|
2313
2343
|
* destructures it to make it easier to skip optional parameters.
|
|
2314
2344
|
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
2315
|
-
* Store, and optional `cellId`, `descending`, `offset`, and `
|
|
2345
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
2316
2346
|
* parameters.
|
|
2317
2347
|
* @returns An array of the sorted Ids of appropriate Rows in the Table.
|
|
2318
2348
|
* @example
|
|
@@ -5813,7 +5843,7 @@ export interface Store {
|
|
|
5813
5843
|
* addSortedRowIdsListener method destructures it to make it easier to skip
|
|
5814
5844
|
* optional parameters.
|
|
5815
5845
|
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
5816
|
-
* Store, and optional `cellId`, `descending`, `offset`, and `
|
|
5846
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
5817
5847
|
* parameters.
|
|
5818
5848
|
* @param listener The function that will be called whenever the sorted Row
|
|
5819
5849
|
* Ids in the Table change.
|
|
@@ -29,6 +29,7 @@ import type {
|
|
|
29
29
|
IdOrNull,
|
|
30
30
|
Ids,
|
|
31
31
|
Json,
|
|
32
|
+
Sorter,
|
|
32
33
|
} from '../../common/with-schemas/index.d.ts';
|
|
33
34
|
|
|
34
35
|
/**
|
|
@@ -947,7 +948,7 @@ export type DoRollback<Schemas extends OptionalSchemas> = (
|
|
|
947
948
|
* the getSortedRowIds method.
|
|
948
949
|
*
|
|
949
950
|
* It's an object containing the Id of the Table in the Store, and optional
|
|
950
|
-
* `cellId`, `descending`, `offset`, and `
|
|
951
|
+
* `cellId`, `descending`, `offset`, `limit`, and `sorter` parameters. See the
|
|
951
952
|
* getSortedRowIds method for specific examples.
|
|
952
953
|
* @category Store
|
|
953
954
|
* @since v6.1.0
|
|
@@ -989,6 +990,13 @@ export type SortedRowIdsArgs<
|
|
|
989
990
|
* @since v6.1.0
|
|
990
991
|
*/
|
|
991
992
|
limit?: number;
|
|
993
|
+
/**
|
|
994
|
+
* A custom function for comparing the sorting values, defaulting to the
|
|
995
|
+
* defaultSorter function.
|
|
996
|
+
* @category Argument
|
|
997
|
+
* @since v9.1.0
|
|
998
|
+
*/
|
|
999
|
+
sorter?: Sorter;
|
|
992
1000
|
};
|
|
993
1001
|
|
|
994
1002
|
/**
|
|
@@ -3216,13 +3224,15 @@ export interface Store<in out Schemas extends OptionalSchemas> {
|
|
|
3216
3224
|
* descending?: boolean,
|
|
3217
3225
|
* offset?: number,
|
|
3218
3226
|
* limit?: number,
|
|
3227
|
+
* sorter?: Sorter,
|
|
3219
3228
|
* ): Ids;
|
|
3220
3229
|
* ```
|
|
3221
3230
|
*
|
|
3222
|
-
*
|
|
3223
|
-
* should be in descending order. The `offset` and `limit`
|
|
3224
|
-
* to paginate results, but default to `0` and
|
|
3225
|
-
* available Row Ids if not specified.
|
|
3231
|
+
* By default the sorting of the rows is alphanumeric, and you can indicate
|
|
3232
|
+
* whether it should be in descending order. The `offset` and `limit`
|
|
3233
|
+
* parameters are used to paginate results, but default to `0` and
|
|
3234
|
+
* `undefined` to return all available Row Ids if not specified. The `sorter`
|
|
3235
|
+
* parameter can provide a custom comparison function.
|
|
3226
3236
|
*
|
|
3227
3237
|
* Note that every call to this method will perform the sorting afresh - there
|
|
3228
3238
|
* is no caching of the results - and so you are advised to memoize the
|
|
@@ -3239,6 +3249,8 @@ export interface Store<in out Schemas extends OptionalSchemas> {
|
|
|
3239
3249
|
* any.
|
|
3240
3250
|
* @param limit The maximum number of Row Ids to return, or `undefined` for
|
|
3241
3251
|
* all.
|
|
3252
|
+
* @param sorter A custom function for comparing the sorting values, or
|
|
3253
|
+
* `undefined` to use the defaultSorter function.
|
|
3242
3254
|
* @returns An array of the sorted Ids of appropriate Rows in the Table.
|
|
3243
3255
|
* @example
|
|
3244
3256
|
* This example retrieves sorted Row Ids in a Table.
|
|
@@ -3310,6 +3322,24 @@ export interface Store<in out Schemas extends OptionalSchemas> {
|
|
|
3310
3322
|
* // -> ['cujo', 'felix', 'fido']
|
|
3311
3323
|
* ```
|
|
3312
3324
|
* @example
|
|
3325
|
+
* This example retrieves Row Ids sorted numerically by their own value.
|
|
3326
|
+
*
|
|
3327
|
+
* ```js
|
|
3328
|
+
* import {createStore} from 'tinybase';
|
|
3329
|
+
*
|
|
3330
|
+
* const store = createStore();
|
|
3331
|
+
* ['1', '10', '2'].forEach((rowId) =>
|
|
3332
|
+
* store.setRow('pets', rowId, {sold: false}),
|
|
3333
|
+
* );
|
|
3334
|
+
* const numericSorter = (sortKey1, sortKey2) =>
|
|
3335
|
+
* Number(sortKey1) - Number(sortKey2);
|
|
3336
|
+
*
|
|
3337
|
+
* console.log(
|
|
3338
|
+
* store.getSortedRowIds({tableId: 'pets', sorter: numericSorter}),
|
|
3339
|
+
* );
|
|
3340
|
+
* // -> ['1', '2', '10']
|
|
3341
|
+
* ```
|
|
3342
|
+
* @example
|
|
3313
3343
|
* This example retrieves the sorted Row Ids of a Table that does not exist,
|
|
3314
3344
|
* returning an empty array.
|
|
3315
3345
|
*
|
|
@@ -3329,13 +3359,14 @@ export interface Store<in out Schemas extends OptionalSchemas> {
|
|
|
3329
3359
|
descending?: boolean,
|
|
3330
3360
|
offset?: number,
|
|
3331
3361
|
limit?: number,
|
|
3362
|
+
sorter?: Sorter,
|
|
3332
3363
|
): Ids;
|
|
3333
3364
|
|
|
3334
3365
|
/**
|
|
3335
3366
|
* When called with one object argument, the getSortedRowIds method
|
|
3336
3367
|
* destructures it to make it easier to skip optional parameters.
|
|
3337
3368
|
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
3338
|
-
* Store, and optional `cellId`, `descending`, `offset`, and `
|
|
3369
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
3339
3370
|
* parameters.
|
|
3340
3371
|
* @returns An array of the sorted Ids of appropriate Rows in the Table.
|
|
3341
3372
|
* @example
|
|
@@ -7295,7 +7326,7 @@ export interface Store<in out Schemas extends OptionalSchemas> {
|
|
|
7295
7326
|
* addSortedRowIdsListener method destructures it to make it easier to skip
|
|
7296
7327
|
* optional parameters.
|
|
7297
7328
|
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
7298
|
-
* Store, and optional `cellId`, `descending`, `offset`, and `
|
|
7329
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
7299
7330
|
* parameters.
|
|
7300
7331
|
* @param listener The function that will be called whenever the sorted Row
|
|
7301
7332
|
* Ids in the Table change.
|
|
@@ -36,6 +36,7 @@ import type {
|
|
|
36
36
|
IdOrNull,
|
|
37
37
|
Ids,
|
|
38
38
|
ParameterizedCallback,
|
|
39
|
+
Sorter,
|
|
39
40
|
} from '../common/index.d.ts';
|
|
40
41
|
import type {
|
|
41
42
|
Indexes,
|
|
@@ -1797,6 +1798,7 @@ export function useSortedRowIds(
|
|
|
1797
1798
|
descending?: boolean,
|
|
1798
1799
|
offset?: number,
|
|
1799
1800
|
limit?: number,
|
|
1801
|
+
sorterOrStoreOrStoreId?: Sorter | StoreOrStoreId,
|
|
1800
1802
|
storeOrStoreId?: StoreOrStoreId,
|
|
1801
1803
|
): Ids;
|
|
1802
1804
|
|
|
@@ -1804,7 +1806,8 @@ export function useSortedRowIds(
|
|
|
1804
1806
|
* When called with an object as the first argument, the useSortedRowIds method
|
|
1805
1807
|
* destructures it to make it easier to skip optional parameters.
|
|
1806
1808
|
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
1807
|
-
* Store, and optional `cellId`, `descending`, `offset`, and `
|
|
1809
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
1810
|
+
* parameters.
|
|
1808
1811
|
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
1809
1812
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
1810
1813
|
* reference.
|
|
@@ -5178,7 +5181,8 @@ export function useSortedRowIdsListener(
|
|
|
5178
5181
|
* When called with an object as the first argument, the useSortedRowIds method
|
|
5179
5182
|
* destructures it to make it easier to skip optional parameters.
|
|
5180
5183
|
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
5181
|
-
* Store, and optional `cellId`, `descending`, `offset`, and `
|
|
5184
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
5185
|
+
* parameters.
|
|
5182
5186
|
* @param listener The function that will be called whenever the sorted Row Ids
|
|
5183
5187
|
* in the Table change.
|
|
5184
5188
|
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
@@ -82,6 +82,7 @@ import type {
|
|
|
82
82
|
IdOrNull,
|
|
83
83
|
Ids,
|
|
84
84
|
ParameterizedCallback,
|
|
85
|
+
Sorter,
|
|
85
86
|
} from '../../common/with-schemas/index.d.ts';
|
|
86
87
|
import type {
|
|
87
88
|
Indexes,
|
|
@@ -1901,6 +1902,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
1901
1902
|
* descending?: boolean,
|
|
1902
1903
|
* offset?: number,
|
|
1903
1904
|
* limit?: number,
|
|
1905
|
+
* sorterOrStoreOrStoreId?: Sorter | StoreOrStoreId,
|
|
1904
1906
|
* storeOrStoreId?: StoreOrStoreId,
|
|
1905
1907
|
* ): Ids;
|
|
1906
1908
|
* ```
|
|
@@ -2032,6 +2034,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
2032
2034
|
descending?: boolean,
|
|
2033
2035
|
offset?: number,
|
|
2034
2036
|
limit?: number,
|
|
2037
|
+
sorterOrStoreOrStoreId?: Sorter | StoreOrStoreId<Schemas>,
|
|
2035
2038
|
storeOrStoreId?: StoreOrStoreId<Schemas>,
|
|
2036
2039
|
): Ids;
|
|
2037
2040
|
|
|
@@ -2039,7 +2042,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
2039
2042
|
* When called with an object as the first argument, the useSortedRowIds method
|
|
2040
2043
|
* destructures it to make it easier to skip optional parameters.
|
|
2041
2044
|
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
2042
|
-
* Store, and optional `cellId`, `descending`, `offset`, and `
|
|
2045
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
2046
|
+
* parameters.
|
|
2043
2047
|
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
2044
2048
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
2045
2049
|
* reference.
|
|
@@ -5957,7 +5961,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
5957
5961
|
* When called with an object as the first argument, the useSortedRowIds method
|
|
5958
5962
|
* destructures it to make it easier to skip optional parameters.
|
|
5959
5963
|
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
5960
|
-
* Store, and optional `cellId`, `descending`, `offset`, and `
|
|
5964
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
5965
|
+
* parameters.
|
|
5961
5966
|
* @param listener The function that will be called whenever the sorted Row Ids
|
|
5962
5967
|
* in the Table change.
|
|
5963
5968
|
* @param listenerDeps An optional array of dependencies for the `listener`
|
|
@@ -38,6 +38,7 @@ import type {
|
|
|
38
38
|
IdOrNull,
|
|
39
39
|
Ids,
|
|
40
40
|
ParameterizedCallback,
|
|
41
|
+
Sorter,
|
|
41
42
|
} from '../common/index.d.ts';
|
|
42
43
|
import type {
|
|
43
44
|
Indexes,
|
|
@@ -1418,6 +1419,8 @@ export function useRowIds(
|
|
|
1418
1419
|
* @param descending Whether the sorting should be in descending order.
|
|
1419
1420
|
* @param offset The number of Row Ids to skip for pagination purposes, if any.
|
|
1420
1421
|
* @param limit The maximum number of Row Ids to return, or `undefined` for all.
|
|
1422
|
+
* @param sorter A custom function for comparing the sorting values, or
|
|
1423
|
+
* `undefined` to use the default alphanumeric sorting.
|
|
1421
1424
|
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
1422
1425
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
1423
1426
|
* reference.
|
|
@@ -1441,6 +1444,7 @@ export function useRowIds(
|
|
|
1441
1444
|
* false,
|
|
1442
1445
|
* 0,
|
|
1443
1446
|
* undefined,
|
|
1447
|
+
* undefined,
|
|
1444
1448
|
* store,
|
|
1445
1449
|
* );
|
|
1446
1450
|
* console.log(JSON.stringify(rowIds()));
|
|
@@ -1457,6 +1461,7 @@ export function useSortedRowIds(
|
|
|
1457
1461
|
descending?: MaybeAccessor<boolean | undefined>,
|
|
1458
1462
|
offset?: MaybeAccessor<number | undefined>,
|
|
1459
1463
|
limit?: MaybeAccessor<number | undefined>,
|
|
1464
|
+
sorter?: Sorter,
|
|
1460
1465
|
storeOrStoreId?: MaybeAccessor<StoreOrStoreId | undefined>,
|
|
1461
1466
|
): Accessor<Ids>;
|
|
1462
1467
|
|
|
@@ -1464,7 +1469,8 @@ export function useSortedRowIds(
|
|
|
1464
1469
|
* When called with an object as the first argument, the useSortedRowIds method
|
|
1465
1470
|
* destructures it to make it easier to skip optional parameters.
|
|
1466
1471
|
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
1467
|
-
* Store, and optional `cellId`, `descending`, `offset`, and `
|
|
1472
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
1473
|
+
* parameters.
|
|
1468
1474
|
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
1469
1475
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
1470
1476
|
* reference.
|
|
@@ -4517,7 +4523,8 @@ export function useSortedRowIdsListener(
|
|
|
4517
4523
|
* When called with an object as the first argument, the useSortedRowIds method
|
|
4518
4524
|
* destructures it to make it easier to skip optional parameters.
|
|
4519
4525
|
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
4520
|
-
* Store, and optional `cellId`, `descending`, `offset`, and `
|
|
4526
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
4527
|
+
* parameters.
|
|
4521
4528
|
* @param listener The function that will be called whenever the sorted Row Ids
|
|
4522
4529
|
* in the Table change.
|
|
4523
4530
|
* @param mutator An optional boolean that indicates that the listener mutates
|
|
@@ -84,6 +84,7 @@ import type {
|
|
|
84
84
|
IdOrNull,
|
|
85
85
|
Ids,
|
|
86
86
|
ParameterizedCallback,
|
|
87
|
+
Sorter,
|
|
87
88
|
} from '../../common/with-schemas/index.d.ts';
|
|
88
89
|
import type {
|
|
89
90
|
Indexes,
|
|
@@ -1635,6 +1636,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
1635
1636
|
* descending?: MaybeAccessor<boolean | undefined>,
|
|
1636
1637
|
* offset?: MaybeAccessor<number | undefined>,
|
|
1637
1638
|
* limit?: MaybeAccessor<number | undefined>,
|
|
1639
|
+
* sorter?: Sorter,
|
|
1638
1640
|
* storeOrStoreId?: MaybeAccessor<StoreOrStoreId | undefined>,
|
|
1639
1641
|
* ): Accessor<Ids>;
|
|
1640
1642
|
* ```
|
|
@@ -1654,6 +1656,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
1654
1656
|
* @param descending Whether the sorting should be in descending order.
|
|
1655
1657
|
* @param offset The number of Row Ids to skip for pagination purposes, if any.
|
|
1656
1658
|
* @param limit The maximum number of Row Ids to return, or `undefined` for all.
|
|
1659
|
+
* @param sorter A custom function for comparing the sorting values, or
|
|
1660
|
+
* `undefined` to use the default alphanumeric sorting.
|
|
1657
1661
|
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
1658
1662
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
1659
1663
|
* reference.
|
|
@@ -1677,6 +1681,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
1677
1681
|
* false,
|
|
1678
1682
|
* 0,
|
|
1679
1683
|
* undefined,
|
|
1684
|
+
* undefined,
|
|
1680
1685
|
* store,
|
|
1681
1686
|
* );
|
|
1682
1687
|
* console.log(JSON.stringify(rowIds()));
|
|
@@ -1697,6 +1702,7 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
1697
1702
|
descending?: MaybeAccessor<boolean | undefined>,
|
|
1698
1703
|
offset?: MaybeAccessor<number | undefined>,
|
|
1699
1704
|
limit?: MaybeAccessor<number | undefined>,
|
|
1705
|
+
sorter?: Sorter,
|
|
1700
1706
|
storeOrStoreId?: MaybeAccessor<StoreOrStoreId<Schemas> | undefined>,
|
|
1701
1707
|
): Accessor<Ids>;
|
|
1702
1708
|
|
|
@@ -1704,7 +1710,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
1704
1710
|
* When called with an object as the first argument, the useSortedRowIds method
|
|
1705
1711
|
* destructures it to make it easier to skip optional parameters.
|
|
1706
1712
|
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
1707
|
-
* Store, and optional `cellId`, `descending`, `offset`, and `
|
|
1713
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
1714
|
+
* parameters.
|
|
1708
1715
|
* @param storeOrStoreId The Store to be accessed: omit for the default context
|
|
1709
1716
|
* Store, provide an Id for a named context Store, or provide an explicit
|
|
1710
1717
|
* reference.
|
|
@@ -5274,7 +5281,8 @@ export type WithSchemas<Schemas extends OptionalSchemas> = {
|
|
|
5274
5281
|
* When called with an object as the first argument, the useSortedRowIds method
|
|
5275
5282
|
* destructures it to make it easier to skip optional parameters.
|
|
5276
5283
|
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
5277
|
-
* Store, and optional `cellId`, `descending`, `offset`, and `
|
|
5284
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
5285
|
+
* parameters.
|
|
5278
5286
|
* @param listener The function that will be called whenever the sorted Row Ids
|
|
5279
5287
|
* in the Table change.
|
|
5280
5288
|
* @param mutator An optional boolean that indicates that the listener mutates
|
|
@@ -35,7 +35,7 @@ import type {
|
|
|
35
35
|
CheckpointListener,
|
|
36
36
|
Checkpoints,
|
|
37
37
|
} from '../checkpoints/index.d.ts';
|
|
38
|
-
import type {Id, IdOrNull, Ids} from '../common/index.d.ts';
|
|
38
|
+
import type {Id, IdOrNull, Ids, Sorter} from '../common/index.d.ts';
|
|
39
39
|
import type {
|
|
40
40
|
Indexes,
|
|
41
41
|
SliceIdsListener,
|
|
@@ -82,6 +82,7 @@ import type {
|
|
|
82
82
|
RowCountListener,
|
|
83
83
|
RowIdsListener,
|
|
84
84
|
RowListener,
|
|
85
|
+
SortedRowIdsArgs,
|
|
85
86
|
SortedRowIdsListener,
|
|
86
87
|
Store,
|
|
87
88
|
Table,
|
|
@@ -2893,6 +2894,8 @@ export function getRowIds(
|
|
|
2893
2894
|
* @param descending Whether to sort descending (or a getter returning it).
|
|
2894
2895
|
* @param offset The starting Row offset (or a getter returning it).
|
|
2895
2896
|
* @param limit The maximum number of Rows to return (or a getter returning it).
|
|
2897
|
+
* @param sorter A custom function for comparing the sorting values, or
|
|
2898
|
+
* `undefined` to use the default alphanumeric sorting.
|
|
2896
2899
|
* @param storeOrStoreId The Store to use (plain value or getter), or its Id.
|
|
2897
2900
|
* @returns A reactive object with a `current` Ids property.
|
|
2898
2901
|
* @example
|
|
@@ -2907,7 +2910,15 @@ export function getRowIds(
|
|
|
2907
2910
|
*
|
|
2908
2911
|
* let {store} = $props();
|
|
2909
2912
|
*
|
|
2910
|
-
* const result = getSortedRowIds(
|
|
2913
|
+
* const result = getSortedRowIds(
|
|
2914
|
+
* 'pets',
|
|
2915
|
+
* 'sold',
|
|
2916
|
+
* false,
|
|
2917
|
+
* 0,
|
|
2918
|
+
* undefined,
|
|
2919
|
+
* undefined,
|
|
2920
|
+
* store,
|
|
2921
|
+
* );
|
|
2911
2922
|
* </script>
|
|
2912
2923
|
*
|
|
2913
2924
|
* {JSON.stringify(result.current)}
|
|
@@ -2941,6 +2952,23 @@ export function getSortedRowIds(
|
|
|
2941
2952
|
descending?: MaybeGetter<boolean>,
|
|
2942
2953
|
offset?: MaybeGetter<number>,
|
|
2943
2954
|
limit?: MaybeGetter<number | undefined>,
|
|
2955
|
+
sorter?: Sorter,
|
|
2956
|
+
storeOrStoreId?: MaybeGetter<StoreOrStoreId | undefined>,
|
|
2957
|
+
): {readonly current: Ids};
|
|
2958
|
+
|
|
2959
|
+
/**
|
|
2960
|
+
* When called with an object as the first argument, the getSortedRowIds
|
|
2961
|
+
* function destructures it to make it easier to skip optional parameters.
|
|
2962
|
+
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
2963
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
2964
|
+
* parameters.
|
|
2965
|
+
* @param storeOrStoreId The Store to use (plain value or getter), or its Id.
|
|
2966
|
+
* @returns A reactive object with a `current` Ids property.
|
|
2967
|
+
* @category Getter
|
|
2968
|
+
* @since v9.1.0
|
|
2969
|
+
*/
|
|
2970
|
+
export function getSortedRowIds(
|
|
2971
|
+
args: SortedRowIdsArgs,
|
|
2944
2972
|
storeOrStoreId?: MaybeGetter<StoreOrStoreId | undefined>,
|
|
2945
2973
|
): {readonly current: Ids};
|
|
2946
2974
|
|
|
@@ -6936,6 +6964,26 @@ export function onSortedRowIds(
|
|
|
6936
6964
|
storeOrStoreId?: MaybeGetter<StoreOrStoreId | undefined>,
|
|
6937
6965
|
): void;
|
|
6938
6966
|
|
|
6967
|
+
/**
|
|
6968
|
+
* When called with an object as the first argument, the onSortedRowIds function
|
|
6969
|
+
* destructures it to make it easier to skip optional parameters.
|
|
6970
|
+
* @param args A SortedRowIdsArgs object containing the Id of the Table in the
|
|
6971
|
+
* Store, and optional `cellId`, `descending`, `offset`, `limit`, and `sorter`
|
|
6972
|
+
* parameters.
|
|
6973
|
+
* @param listener The function to call when sorted Row Ids change.
|
|
6974
|
+
* @param mutator An optional boolean indicating the listener mutates Store
|
|
6975
|
+
* data.
|
|
6976
|
+
* @param storeOrStoreId The Store to use, or its Id.
|
|
6977
|
+
* @category Listener
|
|
6978
|
+
* @since v9.1.0
|
|
6979
|
+
*/
|
|
6980
|
+
export function onSortedRowIds(
|
|
6981
|
+
args: SortedRowIdsArgs,
|
|
6982
|
+
listener: SortedRowIdsListener,
|
|
6983
|
+
mutator?: boolean,
|
|
6984
|
+
storeOrStoreId?: MaybeGetter<StoreOrStoreId | undefined>,
|
|
6985
|
+
): void;
|
|
6986
|
+
|
|
6939
6987
|
/**
|
|
6940
6988
|
* The onHasRow function registers a listener that is called whenever a
|
|
6941
6989
|
* specified Row is added to or removed from a Table.
|