@trackunit/filters-asset-filter-definitions 2.24.10 → 2.24.11
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/index.cjs.js +296 -411
- package/index.esm.js +297 -412
- package/package.json +19 -19
- package/src/defaultFilters/defaults/hooks/useCustomerData.d.ts +3 -3
- package/src/defaultFilters/defaults/summaryConnectionTypes.d.ts +0 -17
- package/src/defaultFilters/defaults/test/summaryConnectionTestUtils.d.ts +8 -1
- package/src/defaultFilters/defaults/useFacetConnectionOptions.d.ts +65 -0
- package/src/defaultFilters/defaults/useFacetLimitedOptions.d.ts +38 -0
- package/src/defaultFilters/defaults/useFacetLocalOptions.d.ts +14 -0
- package/src/defaultFilters/defaults/useFacetMissingCount.d.ts +2 -2
- package/migrations/entry.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/filters-asset-filter-definitions",
|
|
3
|
-
"version": "2.24.
|
|
3
|
+
"version": "2.24.11",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -12,24 +12,24 @@
|
|
|
12
12
|
"zod": "^3.25.76",
|
|
13
13
|
"string-ts": "^2.0.0",
|
|
14
14
|
"tailwind-merge": "^2.0.0",
|
|
15
|
-
"@trackunit/iris-app-build-utilities": "2.7.
|
|
16
|
-
"@trackunit/filters-filter-bar": "2.10.
|
|
17
|
-
"@trackunit/react-core-hooks": "1.25.
|
|
18
|
-
"@trackunit/react-filter-components": "2.10.
|
|
19
|
-
"@trackunit/react-form-components": "2.10.
|
|
20
|
-
"@trackunit/filters-graphql-hook": "2.23.
|
|
21
|
-
"@trackunit/utilization-indicator": "2.10.
|
|
22
|
-
"@trackunit/geo-json-utils": "1.18.
|
|
23
|
-
"@trackunit/react-components": "3.8.
|
|
24
|
-
"@trackunit/shared-utils": "1.19.
|
|
25
|
-
"@trackunit/translations-machine-type": "2.8.
|
|
26
|
-
"@trackunit/criticality-indicator": "2.10.
|
|
27
|
-
"@trackunit/iris-app-api": "2.9.
|
|
28
|
-
"@trackunit/react-core-contexts-test": "1.22.
|
|
29
|
-
"@trackunit/i18n-library-translation": "2.8.
|
|
30
|
-
"@trackunit/iris-app-runtime-core-api": "1.21.
|
|
31
|
-
"@trackunit/react-graphql-hooks": "2.10.
|
|
32
|
-
"@trackunit/translations-device": "1.22.
|
|
15
|
+
"@trackunit/iris-app-build-utilities": "2.7.4",
|
|
16
|
+
"@trackunit/filters-filter-bar": "2.10.7",
|
|
17
|
+
"@trackunit/react-core-hooks": "1.25.4",
|
|
18
|
+
"@trackunit/react-filter-components": "2.10.7",
|
|
19
|
+
"@trackunit/react-form-components": "2.10.7",
|
|
20
|
+
"@trackunit/filters-graphql-hook": "2.23.11",
|
|
21
|
+
"@trackunit/utilization-indicator": "2.10.7",
|
|
22
|
+
"@trackunit/geo-json-utils": "1.18.4",
|
|
23
|
+
"@trackunit/react-components": "3.8.1",
|
|
24
|
+
"@trackunit/shared-utils": "1.19.4",
|
|
25
|
+
"@trackunit/translations-machine-type": "2.8.5",
|
|
26
|
+
"@trackunit/criticality-indicator": "2.10.7",
|
|
27
|
+
"@trackunit/iris-app-api": "2.9.4",
|
|
28
|
+
"@trackunit/react-core-contexts-test": "1.22.4",
|
|
29
|
+
"@trackunit/i18n-library-translation": "2.8.4",
|
|
30
|
+
"@trackunit/iris-app-runtime-core-api": "1.21.4",
|
|
31
|
+
"@trackunit/react-graphql-hooks": "2.10.7",
|
|
32
|
+
"@trackunit/translations-device": "1.22.8"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@apollo/client": "^3.13.8",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FilterCustomSearch } from "@trackunit/filters-filter-bar";
|
|
1
2
|
import { FilterBarValues } from "@trackunit/iris-app-runtime-core-api";
|
|
2
3
|
import { GetCustomerIdSummaryQuery } from "../../../generated/graphql-api/graphql";
|
|
3
4
|
/**
|
|
@@ -5,11 +6,10 @@ import { GetCustomerIdSummaryQuery } from "../../../generated/graphql-api/graphq
|
|
|
5
6
|
*
|
|
6
7
|
* @param filterValues - The current values from the filter bar.
|
|
7
8
|
* @param customerId - The ID of the customer that owns the customers shown in the filter bar.
|
|
8
|
-
* @returns {object}
|
|
9
|
+
* @returns {object} The fetched data, `loading` (only true while there are no customers yet) and the `customSearch` for the filter.
|
|
9
10
|
*/
|
|
10
11
|
export declare const useCustomerData: (filterValues: FilterBarValues | undefined, customerId?: string) => {
|
|
11
12
|
data: GetCustomerIdSummaryQuery | undefined;
|
|
12
13
|
loading: boolean;
|
|
13
|
-
|
|
14
|
-
setSearchText: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
14
|
+
customSearch: FilterCustomSearch;
|
|
15
15
|
};
|
|
@@ -146,23 +146,6 @@ export declare const asSummaryConnectionNode: (node: unknown) => {
|
|
|
146
146
|
* for a facet. `DefaultCheckboxFilter` pins the option carrying this key to the bottom of the list.
|
|
147
147
|
*/
|
|
148
148
|
export declare const UNDEFINED_SUMMARY_KEY = "UNDEFINED";
|
|
149
|
-
/**
|
|
150
|
-
* Flattens connection edges into plain summary entries, appending the bucket of assets without
|
|
151
|
-
* a value when one is reported.
|
|
152
|
-
*
|
|
153
|
-
* @param edges the edges of a key/count summary connection
|
|
154
|
-
* @param missing the number of assets without a value, counted by a separate query
|
|
155
|
-
* @param loading whether either query behind the facet is still fetching, which suppresses the
|
|
156
|
-
* entries until the first page arrives. The two queries resolve independently, and
|
|
157
|
-
* `FilterResults` only renders its loading state for an empty list, so without this a facet
|
|
158
|
-
* would briefly show whichever of the two landed first as its only content — the undefined
|
|
159
|
-
* bucket alone, or a set of values that the undefined bucket is about to be appended to.
|
|
160
|
-
* @returns {Array<{ key: string; count: number }>} the summary entries to render as filter options
|
|
161
|
-
*/
|
|
162
|
-
export declare const toSummaryEntries: (edges: Array<AssetSummaryConnectionEdge>, missing: number | null | undefined, loading?: boolean) => Array<{
|
|
163
|
-
key: string;
|
|
164
|
-
count: number;
|
|
165
|
-
}>;
|
|
166
149
|
/**
|
|
167
150
|
* Reads a group summary node.
|
|
168
151
|
*
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { AssetFiltersInput } from "../../../generated/graphql-api/graphql";
|
|
2
|
+
declare const pageInfoMock: {
|
|
3
|
+
hasNextPage: boolean;
|
|
4
|
+
hasPreviousPage: boolean;
|
|
5
|
+
endCursor: string;
|
|
6
|
+
startCursor: string;
|
|
7
|
+
};
|
|
2
8
|
/**
|
|
3
9
|
* Builds a mock result for a plain key/count summary connection.
|
|
4
10
|
*
|
|
5
11
|
* @param connectionField name of the connection field on `assetSummary`
|
|
6
12
|
* @param items the summary entries to expose as edges
|
|
13
|
+
* @param pageInfo overrides for the page info, e.g. to expose a next page
|
|
7
14
|
* @returns {object} the mocked query result
|
|
8
15
|
*/
|
|
9
16
|
export declare const createSummaryConnectionMockData: (connectionField: string, items: Array<{
|
|
10
17
|
key: string;
|
|
11
18
|
count: number;
|
|
12
|
-
}>) => {
|
|
19
|
+
}>, pageInfo?: Partial<typeof pageInfoMock>) => {
|
|
13
20
|
assetSummary: {
|
|
14
21
|
[x: string]: Record<string, unknown>;
|
|
15
22
|
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { TypedDocumentNode } from "@graphql-typed-document-node/core";
|
|
2
|
+
import { FilterCustomSearch, FilterOption, FilterViewProps } from "@trackunit/filters-filter-bar";
|
|
3
|
+
import { RelayTableSupport } from "@trackunit/react-components";
|
|
4
|
+
import { AssetFiltersInput } from "../../generated/graphql-api/graphql";
|
|
5
|
+
import { AssetSummaryQueryShape, FacetMissingCountVariables, FleetSummaryConnectionVariables } from "./summaryConnectionTypes";
|
|
6
|
+
type SummaryEntry = {
|
|
7
|
+
key: string;
|
|
8
|
+
count: number;
|
|
9
|
+
};
|
|
10
|
+
type FacetMissingDocument = TypedDocumentNode<AssetSummaryQueryShape, FacetMissingCountVariables>;
|
|
11
|
+
type FacetConnectionSource<TData extends AssetSummaryQueryShape> = {
|
|
12
|
+
/** The generated `…SummaryConnection` query. */
|
|
13
|
+
document: TypedDocumentNode<TData, FleetSummaryConnectionVariables>;
|
|
14
|
+
/** Name of the connection field on `assetSummary`. */
|
|
15
|
+
connectionField: string;
|
|
16
|
+
/** Narrows the active filters for this facet's own queries, typically by clearing the facet's own key. */
|
|
17
|
+
scope: (activeFilters: AssetFiltersInput) => AssetFiltersInput;
|
|
18
|
+
/** Whether options carry their count. Defaults to true. */
|
|
19
|
+
showCount?: boolean;
|
|
20
|
+
/** Apollo context for both the connection and the missing count query. */
|
|
21
|
+
context?: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
/** A facet whose nodes are plain `{ key, count }` summary entries. */
|
|
24
|
+
type SummaryEntryFacet = {
|
|
25
|
+
/** Maps a summary entry to an option. The missing row arrives here too, keyed `UNDEFINED`. */
|
|
26
|
+
toOption: (entry: SummaryEntry) => FilterOption;
|
|
27
|
+
node?: never;
|
|
28
|
+
/** Adds the row of assets without a value, counted by its own query. */
|
|
29
|
+
missing?: {
|
|
30
|
+
document: FacetMissingDocument;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** A facet whose nodes carry more than a key, such as a group or an account. */
|
|
34
|
+
type CustomNodeFacet<TNode> = {
|
|
35
|
+
node: {
|
|
36
|
+
/** Reads the raw edge node, usually with one of the `as…ConnectionNode` readers. */
|
|
37
|
+
read: (node: unknown) => TNode;
|
|
38
|
+
toOption: (node: TNode) => FilterOption;
|
|
39
|
+
};
|
|
40
|
+
toOption?: never;
|
|
41
|
+
/** Adds the row of assets without a value, counted by its own query, under the given label. */
|
|
42
|
+
missing?: {
|
|
43
|
+
document: FacetMissingDocument;
|
|
44
|
+
label: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type FacetConnectionConfig<TData extends AssetSummaryQueryShape, TNode> = FacetConnectionSource<TData> & (SummaryEntryFacet | CustomNodeFacet<TNode>);
|
|
48
|
+
/**
|
|
49
|
+
* Everything `DefaultCheckboxFilter` needs for a facet backed by a paginated `assetSummary` connection:
|
|
50
|
+
* the shared search box, the paged options with the optional missing row, and the loading state.
|
|
51
|
+
*
|
|
52
|
+
* `loading` is only true while there is nothing to show yet, so refreshing a list on screen does not
|
|
53
|
+
* flash the loading state.
|
|
54
|
+
*
|
|
55
|
+
* @param filterState the filter state handed to the filter view
|
|
56
|
+
* @param config the facet's data source and how its nodes become options
|
|
57
|
+
* @returns {object} props to spread into `DefaultCheckboxFilter`
|
|
58
|
+
*/
|
|
59
|
+
export declare const useFacetConnectionOptions: <TData extends AssetSummaryQueryShape, TNode>(filterState: FilterViewProps<unknown>["filterState"], config: FacetConnectionConfig<TData, TNode>) => {
|
|
60
|
+
customSearch: FilterCustomSearch;
|
|
61
|
+
loading: boolean;
|
|
62
|
+
options: Array<FilterOption>;
|
|
63
|
+
pagination: RelayTableSupport;
|
|
64
|
+
};
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TypedDocumentNode } from "@graphql-typed-document-node/core";
|
|
2
|
+
import { FilterCustomSearch, FilterOption, FilterViewProps } from "@trackunit/filters-filter-bar";
|
|
3
|
+
import { AssetFiltersInput } from "../../generated/graphql-api/graphql";
|
|
4
|
+
/** How many rows a limited facet fetches. A full page means there may be more, so the user is asked to search. */
|
|
5
|
+
export declare const FACET_FETCH_LIMIT = 1000;
|
|
6
|
+
/** The variables every limited facet summary query accepts. */
|
|
7
|
+
export type FacetLimitedVariables = {
|
|
8
|
+
filters: AssetFiltersInput | null | undefined;
|
|
9
|
+
search: string | null | undefined;
|
|
10
|
+
limit: number;
|
|
11
|
+
};
|
|
12
|
+
/** Describes one facet backed by a summary query that returns up to {@link FACET_FETCH_LIMIT} rows. */
|
|
13
|
+
export type FacetLimitedConfig<TData, TItem> = {
|
|
14
|
+
/** The generated summary query. */
|
|
15
|
+
document: TypedDocumentNode<TData, FacetLimitedVariables>;
|
|
16
|
+
/** Narrows the active filters for this facet's query, typically by clearing the facet's own key. */
|
|
17
|
+
scope: (activeFilters: AssetFiltersInput) => AssetFiltersInput;
|
|
18
|
+
/** Picks the summary rows out of the query result. */
|
|
19
|
+
read: (data: TData) => ReadonlyArray<TItem> | null | undefined;
|
|
20
|
+
/** Maps one summary row to a checkbox option. */
|
|
21
|
+
toOption: (item: TItem) => FilterOption;
|
|
22
|
+
/** Whether options carry their count. Defaults to true. */
|
|
23
|
+
showCount?: boolean;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Supplies a `DefaultCheckboxFilter` whose options come from one summary query capped at
|
|
27
|
+
* {@link FACET_FETCH_LIMIT} rows. The search text is sent as typed once debounced.
|
|
28
|
+
*
|
|
29
|
+
* @param filterState the filter view's state, used to resolve the active asset filters
|
|
30
|
+
* @param config which query to run and how to turn its rows into options
|
|
31
|
+
* @returns {object} props to spread onto `DefaultCheckboxFilter`; `loading` is only true while there are no options yet
|
|
32
|
+
*/
|
|
33
|
+
export declare const useFacetLimitedOptions: <TData, TItem>(filterState: FilterViewProps<unknown>["filterState"], config: FacetLimitedConfig<TData, TItem>) => {
|
|
34
|
+
customSearch: FilterCustomSearch;
|
|
35
|
+
loading: boolean;
|
|
36
|
+
options: Array<FilterOption>;
|
|
37
|
+
showRequestMoreUseSearch: boolean;
|
|
38
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FilterCustomSearch, FilterOption } from "@trackunit/filters-filter-bar";
|
|
2
|
+
/**
|
|
3
|
+
* Supplies a `DefaultCheckboxFilter` whose options are all fetched up front and searched locally.
|
|
4
|
+
* Matching is on the label, trimmed and case-insensitive, once the search is debounced.
|
|
5
|
+
*
|
|
6
|
+
* @param allOptions every option the facet can show
|
|
7
|
+
* @param loading whether the query behind `allOptions` is loading
|
|
8
|
+
* @returns {object} props to spread onto `DefaultCheckboxFilter`; `loading` is only true while there are no options yet
|
|
9
|
+
*/
|
|
10
|
+
export declare const useFacetLocalOptions: (allOptions: Array<FilterOption>, loading: boolean) => {
|
|
11
|
+
customSearch: FilterCustomSearch;
|
|
12
|
+
loading: boolean;
|
|
13
|
+
options: Array<FilterOption>;
|
|
14
|
+
};
|
|
@@ -12,13 +12,13 @@ type UseFacetMissingCountOptions = {
|
|
|
12
12
|
* the facet search term and outside paging, so it is identical on every page and would only be
|
|
13
13
|
* re-fetched for nothing if it rode along with the paginated query.
|
|
14
14
|
*
|
|
15
|
-
* @param document the generated `…SummaryMissing` query
|
|
15
|
+
* @param document the generated `…SummaryMissing` query, or undefined for a facet without a missing row
|
|
16
16
|
* @param connectionField name of the connection field on `assetSummary`
|
|
17
17
|
* @param filters the filters scoping the summary, the same ones the paginated query uses
|
|
18
18
|
* @param options optional skip flag and Apollo context
|
|
19
19
|
* @returns {object} the count of assets without a value, plus loading state
|
|
20
20
|
*/
|
|
21
|
-
export declare const useFacetMissingCount: <TData extends AssetSummaryQueryShape>(document: TypedDocumentNode<TData, FacetMissingCountVariables
|
|
21
|
+
export declare const useFacetMissingCount: <TData extends AssetSummaryQueryShape>(document: TypedDocumentNode<TData, FacetMissingCountVariables> | undefined, connectionField: string, filters: AssetFiltersInput | null | undefined, options?: UseFacetMissingCountOptions) => {
|
|
22
22
|
missing: number | null | undefined;
|
|
23
23
|
loading: boolean;
|
|
24
24
|
};
|
package/migrations/entry.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/filters/asset-filter-definitions/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["export {};\n"]}
|