@atscript/ui-table 0.1.110 → 0.1.112
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/dist/index.cjs +8 -1
- package/dist/index.d.cts +24 -0
- package/dist/index.d.mts +24 -0
- package/dist/index.mjs +8 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1172,7 +1172,8 @@ function makeParserSafeAnd(children) {
|
|
|
1172
1172
|
function buildTableQuery(opts) {
|
|
1173
1173
|
const userFilter = filtersToUniqueryFilter(opts.filters);
|
|
1174
1174
|
const filter = mergeFilters(opts.forceFilters, userFilter);
|
|
1175
|
-
const
|
|
1175
|
+
const userSorters = opts.ignoreSorters ? [] : opts.sorters;
|
|
1176
|
+
const sorters = opts.forceSorters?.length ? mergeSorters(opts.forceSorters, userSorters) : userSorters;
|
|
1176
1177
|
const $sort = {};
|
|
1177
1178
|
for (const s of sorters) $sort[s.field] = s.direction === "asc" ? 1 : -1;
|
|
1178
1179
|
const controls = {};
|
|
@@ -1222,6 +1223,7 @@ function stateToUrlQueryString(state, defaults) {
|
|
|
1222
1223
|
filters,
|
|
1223
1224
|
search: searchOff ? void 0 : state.searchTerm || void 0
|
|
1224
1225
|
});
|
|
1226
|
+
if (!searchOff && state.searchTerm && state.ignoreSorters !== void 0 && state.ignoreSorters !== (defaults.defaultIgnoreSorters ?? false)) query.controls.$relevance = state.ignoreSorters ? 1 : 0;
|
|
1225
1227
|
if (!paginationOff) {
|
|
1226
1228
|
const itemsPerPage = state.itemsPerPage ?? defaults.defaultItemsPerPage;
|
|
1227
1229
|
const page = state.page ?? 1;
|
|
@@ -1294,6 +1296,11 @@ function urlQueryStringToState(urlString, opts = {}) {
|
|
|
1294
1296
|
sorters,
|
|
1295
1297
|
searchTerm: !searchOff && typeof $search === "string" ? $search : ""
|
|
1296
1298
|
};
|
|
1299
|
+
if (!searchOff) {
|
|
1300
|
+
const $relevance = parsed.controls?.$relevance;
|
|
1301
|
+
if ($relevance === "1" || $relevance === 1) out.ignoreSorters = true;
|
|
1302
|
+
else if ($relevance === "0" || $relevance === 0) out.ignoreSorters = false;
|
|
1303
|
+
}
|
|
1297
1304
|
if (!paginationOff) {
|
|
1298
1305
|
const $skip = parsed.controls?.$skip;
|
|
1299
1306
|
if (typeof $skip === "number" && $skip > 0 && Number.isFinite($skip)) out.skip = $skip;
|
package/dist/index.d.cts
CHANGED
|
@@ -585,6 +585,12 @@ interface BuildTableQueryOptions {
|
|
|
585
585
|
sorters: SortControl[];
|
|
586
586
|
/** Always-applied sorters (prepended before user sorters). */
|
|
587
587
|
forceSorters?: SortControl[];
|
|
588
|
+
/**
|
|
589
|
+
* When true, user `sorters` are omitted from `$sort`; `forceSorters` still
|
|
590
|
+
* apply. Used to preserve search relevance ranking — the caller computes
|
|
591
|
+
* the search-active condition; this function just honours the flag.
|
|
592
|
+
*/
|
|
593
|
+
ignoreSorters?: boolean;
|
|
588
594
|
/** User-configured field filters. */
|
|
589
595
|
filters: FieldFilters;
|
|
590
596
|
/** Always-applied Uniquery filter (AND'd with user filters). */
|
|
@@ -648,6 +654,14 @@ interface UrlQueryStateLike {
|
|
|
648
654
|
itemsPerPage?: number;
|
|
649
655
|
/** Full-text search term. Omitted from the URL when empty. */
|
|
650
656
|
searchTerm?: string;
|
|
657
|
+
/**
|
|
658
|
+
* Runtime "preserve relevance ranking" flag — while true and a search is
|
|
659
|
+
* active, user sorters are suppressed at query time. Serialized as
|
|
660
|
+
* `$relevance=1|0` only when a search term is present AND the value differs
|
|
661
|
+
* from `defaultIgnoreSorters`, so a link shared mid-search reproduces what
|
|
662
|
+
* the sharer saw.
|
|
663
|
+
*/
|
|
664
|
+
ignoreSorters?: boolean;
|
|
651
665
|
}
|
|
652
666
|
/** Snapshot recovered from a URL string — partial on purpose so callers can layer it onto state. */
|
|
653
667
|
interface UrlQueryStateSnapshot {
|
|
@@ -661,6 +675,11 @@ interface UrlQueryStateSnapshot {
|
|
|
661
675
|
*/
|
|
662
676
|
skip?: number;
|
|
663
677
|
searchTerm: string;
|
|
678
|
+
/**
|
|
679
|
+
* Runtime relevance flag decoded from `$relevance` (omitted when the URL
|
|
680
|
+
* carries no explicit value — the recipient keeps their configured default).
|
|
681
|
+
*/
|
|
682
|
+
ignoreSorters?: boolean;
|
|
664
683
|
}
|
|
665
684
|
/**
|
|
666
685
|
* Per-aspect opt-in/out for the URL bridge. Honoured symmetrically by both
|
|
@@ -691,6 +710,11 @@ interface UrlQueryDefaults {
|
|
|
691
710
|
defaultItemsPerPage: number;
|
|
692
711
|
/** Per-aspect sync gates. Omitted = full sync (existing behaviour). */
|
|
693
712
|
sync?: UrlQuerySync;
|
|
713
|
+
/**
|
|
714
|
+
* Consumer's configured `ignoreSortersWhenSearched` default. `$relevance`
|
|
715
|
+
* is emitted only when the runtime flag differs from this. Default `false`.
|
|
716
|
+
*/
|
|
717
|
+
defaultIgnoreSorters?: boolean;
|
|
694
718
|
}
|
|
695
719
|
/**
|
|
696
720
|
* Resolve a `boolean | string[]` aspect gate into a tri-state:
|
package/dist/index.d.mts
CHANGED
|
@@ -585,6 +585,12 @@ interface BuildTableQueryOptions {
|
|
|
585
585
|
sorters: SortControl[];
|
|
586
586
|
/** Always-applied sorters (prepended before user sorters). */
|
|
587
587
|
forceSorters?: SortControl[];
|
|
588
|
+
/**
|
|
589
|
+
* When true, user `sorters` are omitted from `$sort`; `forceSorters` still
|
|
590
|
+
* apply. Used to preserve search relevance ranking — the caller computes
|
|
591
|
+
* the search-active condition; this function just honours the flag.
|
|
592
|
+
*/
|
|
593
|
+
ignoreSorters?: boolean;
|
|
588
594
|
/** User-configured field filters. */
|
|
589
595
|
filters: FieldFilters;
|
|
590
596
|
/** Always-applied Uniquery filter (AND'd with user filters). */
|
|
@@ -648,6 +654,14 @@ interface UrlQueryStateLike {
|
|
|
648
654
|
itemsPerPage?: number;
|
|
649
655
|
/** Full-text search term. Omitted from the URL when empty. */
|
|
650
656
|
searchTerm?: string;
|
|
657
|
+
/**
|
|
658
|
+
* Runtime "preserve relevance ranking" flag — while true and a search is
|
|
659
|
+
* active, user sorters are suppressed at query time. Serialized as
|
|
660
|
+
* `$relevance=1|0` only when a search term is present AND the value differs
|
|
661
|
+
* from `defaultIgnoreSorters`, so a link shared mid-search reproduces what
|
|
662
|
+
* the sharer saw.
|
|
663
|
+
*/
|
|
664
|
+
ignoreSorters?: boolean;
|
|
651
665
|
}
|
|
652
666
|
/** Snapshot recovered from a URL string — partial on purpose so callers can layer it onto state. */
|
|
653
667
|
interface UrlQueryStateSnapshot {
|
|
@@ -661,6 +675,11 @@ interface UrlQueryStateSnapshot {
|
|
|
661
675
|
*/
|
|
662
676
|
skip?: number;
|
|
663
677
|
searchTerm: string;
|
|
678
|
+
/**
|
|
679
|
+
* Runtime relevance flag decoded from `$relevance` (omitted when the URL
|
|
680
|
+
* carries no explicit value — the recipient keeps their configured default).
|
|
681
|
+
*/
|
|
682
|
+
ignoreSorters?: boolean;
|
|
664
683
|
}
|
|
665
684
|
/**
|
|
666
685
|
* Per-aspect opt-in/out for the URL bridge. Honoured symmetrically by both
|
|
@@ -691,6 +710,11 @@ interface UrlQueryDefaults {
|
|
|
691
710
|
defaultItemsPerPage: number;
|
|
692
711
|
/** Per-aspect sync gates. Omitted = full sync (existing behaviour). */
|
|
693
712
|
sync?: UrlQuerySync;
|
|
713
|
+
/**
|
|
714
|
+
* Consumer's configured `ignoreSortersWhenSearched` default. `$relevance`
|
|
715
|
+
* is emitted only when the runtime flag differs from this. Default `false`.
|
|
716
|
+
*/
|
|
717
|
+
defaultIgnoreSorters?: boolean;
|
|
694
718
|
}
|
|
695
719
|
/**
|
|
696
720
|
* Resolve a `boolean | string[]` aspect gate into a tri-state:
|
package/dist/index.mjs
CHANGED
|
@@ -1171,7 +1171,8 @@ function makeParserSafeAnd(children) {
|
|
|
1171
1171
|
function buildTableQuery(opts) {
|
|
1172
1172
|
const userFilter = filtersToUniqueryFilter(opts.filters);
|
|
1173
1173
|
const filter = mergeFilters(opts.forceFilters, userFilter);
|
|
1174
|
-
const
|
|
1174
|
+
const userSorters = opts.ignoreSorters ? [] : opts.sorters;
|
|
1175
|
+
const sorters = opts.forceSorters?.length ? mergeSorters(opts.forceSorters, userSorters) : userSorters;
|
|
1175
1176
|
const $sort = {};
|
|
1176
1177
|
for (const s of sorters) $sort[s.field] = s.direction === "asc" ? 1 : -1;
|
|
1177
1178
|
const controls = {};
|
|
@@ -1221,6 +1222,7 @@ function stateToUrlQueryString(state, defaults) {
|
|
|
1221
1222
|
filters,
|
|
1222
1223
|
search: searchOff ? void 0 : state.searchTerm || void 0
|
|
1223
1224
|
});
|
|
1225
|
+
if (!searchOff && state.searchTerm && state.ignoreSorters !== void 0 && state.ignoreSorters !== (defaults.defaultIgnoreSorters ?? false)) query.controls.$relevance = state.ignoreSorters ? 1 : 0;
|
|
1224
1226
|
if (!paginationOff) {
|
|
1225
1227
|
const itemsPerPage = state.itemsPerPage ?? defaults.defaultItemsPerPage;
|
|
1226
1228
|
const page = state.page ?? 1;
|
|
@@ -1293,6 +1295,11 @@ function urlQueryStringToState(urlString, opts = {}) {
|
|
|
1293
1295
|
sorters,
|
|
1294
1296
|
searchTerm: !searchOff && typeof $search === "string" ? $search : ""
|
|
1295
1297
|
};
|
|
1298
|
+
if (!searchOff) {
|
|
1299
|
+
const $relevance = parsed.controls?.$relevance;
|
|
1300
|
+
if ($relevance === "1" || $relevance === 1) out.ignoreSorters = true;
|
|
1301
|
+
else if ($relevance === "0" || $relevance === 0) out.ignoreSorters = false;
|
|
1302
|
+
}
|
|
1296
1303
|
if (!paginationOff) {
|
|
1297
1304
|
const $skip = parsed.controls?.$skip;
|
|
1298
1305
|
if (typeof $skip === "number" && $skip > 0 && Number.isFinite($skip)) out.skip = $skip;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/ui-table",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.112",
|
|
4
4
|
"description": "Framework-agnostic filter model, filter-to-Uniquery conversion, and preset serialization for atscript tables",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@atscript/ui": "0.1.
|
|
45
|
+
"@atscript/ui": "0.1.112"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@atscript/db-client": "^0.1.
|
|
48
|
+
"@atscript/db-client": "^0.1.111",
|
|
49
49
|
"@uniqu/core": "^0.1.6",
|
|
50
50
|
"@uniqu/url": "^0.1.6",
|
|
51
51
|
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@atscript/db-client": "^0.1.
|
|
54
|
+
"@atscript/db-client": "^0.1.111",
|
|
55
55
|
"@uniqu/core": "^0.1.6",
|
|
56
56
|
"@uniqu/url": "^0.1.6"
|
|
57
57
|
},
|