@ethlete/query 0.1.0-next.2 → 0.1.0-next.4
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/esm2020/lib/directives/infinity-query.directive.mjs +11 -2
- package/esm2020/lib/query-form/query-form.mjs +7 -4
- package/esm2020/lib/query-form/query-form.types.mjs +1 -1
- package/esm2020/lib/query-form/query-form.utils.mjs +21 -1
- package/fesm2015/ethlete-query.mjs +37 -4
- package/fesm2015/ethlete-query.mjs.map +1 -1
- package/fesm2020/ethlete-query.mjs +36 -4
- package/fesm2020/ethlete-query.mjs.map +1 -1
- package/lib/directives/infinity-query.directive.d.ts +3 -0
- package/lib/query-form/query-form.d.ts +1 -1
- package/lib/query-form/query-form.types.d.ts +11 -1
- package/lib/query-form/query-form.utils.d.ts +5 -0
- package/package.json +1 -1
|
@@ -909,6 +909,7 @@ class InfinityQueryDirective {
|
|
|
909
909
|
this._viewContainerRef = inject(ViewContainerRef);
|
|
910
910
|
this._mainTemplateRef = inject((TemplateRef));
|
|
911
911
|
this._errorHandler = inject(ErrorHandler);
|
|
912
|
+
this._data$ = new BehaviorSubject([]);
|
|
912
913
|
this._isMainViewCreated = false;
|
|
913
914
|
}
|
|
914
915
|
get infinityQuery() {
|
|
@@ -925,6 +926,12 @@ class InfinityQueryDirective {
|
|
|
925
926
|
get instance() {
|
|
926
927
|
return this._infinityQueryInstance;
|
|
927
928
|
}
|
|
929
|
+
get data$() {
|
|
930
|
+
return this._data$.asObservable();
|
|
931
|
+
}
|
|
932
|
+
get data() {
|
|
933
|
+
return this._data$.getValue();
|
|
934
|
+
}
|
|
928
935
|
static ngTemplateContextGuard(dir, ctx) {
|
|
929
936
|
return true;
|
|
930
937
|
}
|
|
@@ -972,6 +979,7 @@ class InfinityQueryDirective {
|
|
|
972
979
|
this._viewContext.currentPage = null;
|
|
973
980
|
this._viewContext.itemsPerPage = null;
|
|
974
981
|
this._viewContext.totalPages = null;
|
|
982
|
+
this._data$.next([]);
|
|
975
983
|
}
|
|
976
984
|
this._cdr.markForCheck();
|
|
977
985
|
}), takeUntil(this._destroy$))
|
|
@@ -979,6 +987,7 @@ class InfinityQueryDirective {
|
|
|
979
987
|
instance.data$
|
|
980
988
|
.pipe(tap((data) => {
|
|
981
989
|
this._viewContext.infinityQuery = this._viewContext.$implicit = data;
|
|
990
|
+
this._data$.next(data);
|
|
982
991
|
this._cdr.markForCheck();
|
|
983
992
|
}), takeUntil(this._destroy$))
|
|
984
993
|
.subscribe();
|
|
@@ -1279,10 +1288,11 @@ class QueryForm {
|
|
|
1279
1288
|
const queryParams = this._activatedRoute.snapshot.queryParams;
|
|
1280
1289
|
for (const [key, field] of Object.entries(this._fields)) {
|
|
1281
1290
|
const value = queryParams[key];
|
|
1282
|
-
|
|
1291
|
+
// We only check using == because the value types can be different (e.g. "1" and 1)
|
|
1292
|
+
if (value === undefined || value == field.control.value) {
|
|
1283
1293
|
continue;
|
|
1284
1294
|
}
|
|
1285
|
-
const deserializedValue = field.data.
|
|
1295
|
+
const deserializedValue = field.data.queryParamToValueTransformFn?.(value) ?? value;
|
|
1286
1296
|
field.setValue(deserializedValue);
|
|
1287
1297
|
}
|
|
1288
1298
|
}
|
|
@@ -1332,7 +1342,9 @@ class QueryForm {
|
|
|
1332
1342
|
delete queryParams[key];
|
|
1333
1343
|
}
|
|
1334
1344
|
else {
|
|
1335
|
-
queryParams[key] =
|
|
1345
|
+
queryParams[key] = this._fields[key].data.valueToQueryParamTransformFn
|
|
1346
|
+
? this._fields[key].data.valueToQueryParamTransformFn?.(value)
|
|
1347
|
+
: value;
|
|
1336
1348
|
}
|
|
1337
1349
|
}
|
|
1338
1350
|
this._router.navigate([], {
|
|
@@ -1414,10 +1426,30 @@ const transformToDateArray = (value) => {
|
|
|
1414
1426
|
}
|
|
1415
1427
|
return null;
|
|
1416
1428
|
};
|
|
1429
|
+
const transformToSort = (value) => {
|
|
1430
|
+
if (typeof value === 'string') {
|
|
1431
|
+
const [active, direction] = value.split(':');
|
|
1432
|
+
return {
|
|
1433
|
+
active,
|
|
1434
|
+
direction: direction,
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
return null;
|
|
1438
|
+
};
|
|
1439
|
+
const transformToSortQueryParam = (value) => {
|
|
1440
|
+
if (typeof value === 'string') {
|
|
1441
|
+
return value;
|
|
1442
|
+
}
|
|
1443
|
+
if (value && typeof value === 'object' && 'active' in value && 'direction' in value) {
|
|
1444
|
+
const valAsSort = value;
|
|
1445
|
+
return valAsSort.direction ? `${valAsSort.active}:${valAsSort.direction}` : null;
|
|
1446
|
+
}
|
|
1447
|
+
return null;
|
|
1448
|
+
};
|
|
1417
1449
|
|
|
1418
1450
|
/**
|
|
1419
1451
|
* Generated bundle index. Do not edit.
|
|
1420
1452
|
*/
|
|
1421
1453
|
|
|
1422
|
-
export { BasicAuthProvider, BearerAuthProvider, CustomHeaderAuthProvider, INFINITY_QUERY_TOKEN, InfinityQuery, InfinityQueryDirective, InfinityQueryTriggerDirective, Query, QueryClient, QueryDirective, QueryError, QueryField, QueryForm, QueryStore, buildBody, buildErrorMessage, buildGqlCacheKey, buildQueryArrayString, buildQueryString, buildRequestError, buildRoute, buildTimestampFromSeconds, createInfinityQueryConfig, decryptBearer, deepFreeze, def, extractExpiresInSeconds, filterFailure, filterInvalidParams, filterSuccess, gql, guessContentType, invalidBaseRouteError, invalidBodyError, invalidRouteError, isAbortRequestError, isBasicAuthProvider, isBearerAuthProvider, isCustomHeaderAuthProvider, isFetchResponse, isGqlQueryConfig, isParamValid, isQueryStateCancelled, isQueryStateFailure, isQueryStateLoading, isQueryStatePrepared, isQueryStateSuccess, isRequestError, mergeHeaders, pathParamsMissingInRouteFunctionError, queryStateAlreadyHasKeyError, queryStateCannotTransformError, queryStateDoesNotContainKeyError, request, shouldCacheQuery, skipPaginationPageParamCalculator, takeUntilResponse, transformGql, transformMethod, transformToBoolean, transformToBooleanArray, transformToDate, transformToDateArray, transformToNumber, transformToNumberArray, transformToString, transformToStringArray };
|
|
1454
|
+
export { BasicAuthProvider, BearerAuthProvider, CustomHeaderAuthProvider, INFINITY_QUERY_TOKEN, InfinityQuery, InfinityQueryDirective, InfinityQueryTriggerDirective, Query, QueryClient, QueryDirective, QueryError, QueryField, QueryForm, QueryStore, buildBody, buildErrorMessage, buildGqlCacheKey, buildQueryArrayString, buildQueryString, buildRequestError, buildRoute, buildTimestampFromSeconds, createInfinityQueryConfig, decryptBearer, deepFreeze, def, extractExpiresInSeconds, filterFailure, filterInvalidParams, filterSuccess, gql, guessContentType, invalidBaseRouteError, invalidBodyError, invalidRouteError, isAbortRequestError, isBasicAuthProvider, isBearerAuthProvider, isCustomHeaderAuthProvider, isFetchResponse, isGqlQueryConfig, isParamValid, isQueryStateCancelled, isQueryStateFailure, isQueryStateLoading, isQueryStatePrepared, isQueryStateSuccess, isRequestError, mergeHeaders, pathParamsMissingInRouteFunctionError, queryStateAlreadyHasKeyError, queryStateCannotTransformError, queryStateDoesNotContainKeyError, request, shouldCacheQuery, skipPaginationPageParamCalculator, takeUntilResponse, transformGql, transformMethod, transformToBoolean, transformToBooleanArray, transformToDate, transformToDateArray, transformToNumber, transformToNumberArray, transformToSort, transformToSortQueryParam, transformToString, transformToStringArray };
|
|
1423
1455
|
//# sourceMappingURL=ethlete-query.mjs.map
|