@parallelworks/ui 0.88.2 → 0.89.0

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.
@@ -1,5 +1,5 @@
1
1
  export { ActionToolbar, type ToolbarAction, ToolbarButton, type ToolbarItem, } from './ActionToolbar.js';
2
- export { type ActiveFilter, applyFilterList, DATE_PRESETS, type DatePreset, dateFilterRange, decodeFilters, encodeFilters, type FilterField, type FilterKind, type FilterOperator, type FilterOption, type FilterRowValue, filterParamKeys, matchFilter, sameFilters, withFilterParams, } from './filterModel.js';
2
+ export { type ActiveFilter, applyFilterList, DATE_PRESETS, type DatePreset, dateFilterRange, decodeFilters, encodeFilters, type FilterField, type FilterKind, type FilterOperator, type FilterOption, type FilterRowValue, filterParamKeys, matchFilter, type QuickFilter, sameFilters, withFilterParams, } from './filterModel.js';
3
3
  export { AddFilterMenu, type AddFilterMenuProps, FilterChip, ListFilterBar, type ListFilterBarProps, } from './ListFilterBar.js';
4
4
  export { GroupRow, ListColumns, ListPage, type ListPageEmpty, type ListPageProps, ListRow, ListRowActionsProvider, useListNavigate, } from './ListPage.js';
5
5
  export { actionsColumnWidth, ListActionsHeader, ListCellText, ListError, ListSelectAllHeader, ListSkeleton, listTableFixedProps, listTableProps, NAME_MIN_WIDTH_PX, NameCell, RowSelectCheckbox, STRETCHED_LINK, } from './ListTable.js';
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
- import type { ActiveFilter, FilterField } from './filterModel.js';
2
+ import type { ActiveFilter, FilterField, QuickFilter } from './filterModel.js';
3
3
  import { type FilterStore, type ListFilters } from './useListFilters.js';
4
4
  /** A toggleable column. Rendering stays in the page's row component, gated by
5
5
  * {@link ListView.isVisible}; this is just the header metadata + visibility. */
@@ -97,6 +97,9 @@ export interface ListViewConfig<T> {
97
97
  filterStore?: FilterStore | undefined;
98
98
  /** False leaves remembering the filters to `filterStore` alone. */
99
99
  rememberFilters?: boolean | undefined;
100
+ /** Fields whose values also show as toggles above the chips, such as a job's state with how
101
+ * many jobs are in each. */
102
+ quickFilters?: readonly QuickFilter[] | undefined;
100
103
  actions?: ActionDef[];
101
104
  /** Explicit pinned-button count when not using actions+isPinned; sizes the actions column. */
102
105
  actionCount?: number;
@@ -192,5 +195,5 @@ export interface ListView<T> extends ListViewChrome {
192
195
  }
193
196
  /** Persisted grouping + column-visibility + field-filter state for a list page,
194
197
  * driving the shared Display/Filter menus. */
195
- export declare function useListView<T>({ storageKey, sharedFiltersKey, columns, groupBys, defaultGroupBy, orderBys, defaultOrderBy, facets, filterFields, defaultFilters, filterStore, rememberFilters, actions, actionCount, defaultShowColumnHeaders, defaultShowActions, isFavorite, isOn, createdAt, }: ListViewConfig<T>): ListView<T>;
198
+ export declare function useListView<T>({ storageKey, sharedFiltersKey, columns, groupBys, defaultGroupBy, orderBys, defaultOrderBy, facets, filterFields, defaultFilters, filterStore, rememberFilters, quickFilters, actions, actionCount, defaultShowColumnHeaders, defaultShowActions, isFavorite, isOn, createdAt, }: ListViewConfig<T>): ListView<T>;
196
199
  export {};
@@ -28,7 +28,7 @@ var DEFAULT_ORDER = "__default";
28
28
  var FAVORITE_ORDER = "__favorite";
29
29
  /** Persisted grouping + column-visibility + field-filter state for a list page,
30
30
  * driving the shared Display/Filter menus. */
31
- function useListView({ storageKey, sharedFiltersKey, columns, groupBys = [], defaultGroupBy, orderBys = [], defaultOrderBy, facets = [], filterFields, defaultFilters, filterStore, rememberFilters = true, actions = [], actionCount, defaultShowColumnHeaders = true, defaultShowActions = true, isFavorite, isOn, createdAt }) {
31
+ function useListView({ storageKey, sharedFiltersKey, columns, groupBys = [], defaultGroupBy, orderBys = [], defaultOrderBy, facets = [], filterFields, defaultFilters, filterStore, rememberFilters = true, quickFilters, actions = [], actionCount, defaultShowColumnHeaders = true, defaultShowActions = true, isFavorite, isOn, createdAt }) {
32
32
  const t = useStrings().list;
33
33
  const tiebreak = orderBys[0]?.compare;
34
34
  const effectiveOrderBys = useMemo(() => {
@@ -76,7 +76,8 @@ function useListView({ storageKey, sharedFiltersKey, columns, groupBys = [], def
76
76
  fields,
77
77
  defaultFilters,
78
78
  store: filterStore,
79
- remember: rememberFilters
79
+ remember: rememberFilters,
80
+ quick: quickFilters
80
81
  });
81
82
  const filters = useMemo(() => {
82
83
  const out = {};
@@ -1,4 +1,4 @@
1
- import { type ActiveFilter, type FilterField, type FilterOperator } from './filterModel.js';
1
+ import { type ActiveFilter, type FilterField, type FilterOperator, type QuickFilter } from './filterModel.js';
2
2
  /** Where filters live besides what the list remembers, such as the page's URL. */
3
3
  export interface FilterStore {
4
4
  /** The filters it holds, or `null` when it holds none, such as a URL with no filter params,
@@ -20,6 +20,8 @@ export interface ListFiltersConfig<T> {
20
20
  store?: FilterStore | undefined;
21
21
  /** False leaves remembering to the store alone. */
22
22
  remember?: boolean | undefined;
23
+ /** Fields whose values also show as toggles above the chips. */
24
+ quick?: readonly QuickFilter[] | undefined;
23
25
  }
24
26
  /** A request for a chip to open one of its pickers, which the chip clears once it has. */
25
27
  export interface FilterEditRequest {
@@ -30,6 +32,8 @@ export interface FilterEditRequest {
30
32
  /** A list's filters, the state behind the chip row and the Filter menu. */
31
33
  export interface ListFilters {
32
34
  fields: readonly FilterField<any>[];
35
+ /** Fields whose values also show as toggles above the chips. */
36
+ quick: readonly QuickFilter[];
33
37
  /** The filters in effect, in the order they were added. */
34
38
  active: readonly ActiveFilter[];
35
39
  /** The chips to show: the filters in effect, then one being added that has no value yet. */
@@ -65,4 +69,4 @@ export interface ListFilters {
65
69
  /** A list's active filters: which, in what order, where they are remembered and how rows
66
70
  * match them. `useListView` builds one from its facets and fields; a page not on it, or
67
71
  * filtering on the server, can call this alone. */
68
- export declare function useListFilters<T>({ storageKey, sharedFiltersKey, fields, defaultFilters, store, remember, }: ListFiltersConfig<T>): ListFilters;
72
+ export declare function useListFilters<T>({ storageKey, sharedFiltersKey, fields, defaultFilters, store, remember, quick, }: ListFiltersConfig<T>): ListFilters;
@@ -3,10 +3,11 @@ import { applyFilterList, fieldOperators, fromStored, isComplete, sameFilters, t
3
3
  import { useCallback, useMemo, useRef, useState } from "react";
4
4
  //#region src/list/useListFilters.ts
5
5
  var NONE = [];
6
+ var NO_QUICK = [];
6
7
  /** A list's active filters: which, in what order, where they are remembered and how rows
7
8
  * match them. `useListView` builds one from its facets and fields; a page not on it, or
8
9
  * filtering on the server, can call this alone. */
9
- function useListFilters({ storageKey, sharedFiltersKey, fields, defaultFilters = NONE, store, remember = true }) {
10
+ function useListFilters({ storageKey, sharedFiltersKey, fields, defaultFilters = NONE, store, remember = true, quick = NO_QUICK }) {
10
11
  const sharedKeys = useMemo(() => new Set(fields.filter((f) => f.shared).map((f) => f.key)), [fields]);
11
12
  const defaults = useMemo(() => defaultFilters.filter((f) => !sharedKeys.has(f.field)), [defaultFilters, sharedKeys]);
12
13
  const sharedDefaults = useMemo(() => defaultFilters.filter((f) => sharedKeys.has(f.field)), [defaultFilters, sharedKeys]);
@@ -218,6 +219,7 @@ function useListFilters({ storageKey, sharedFiltersKey, fields, defaultFilters =
218
219
  const apply = useCallback((rows) => applyFilterList(rows, active, fields), [active, fields]);
219
220
  return {
220
221
  fields,
222
+ quick,
221
223
  active,
222
224
  chips: useMemo(() => {
223
225
  if (!draft) return active;