@12-apps/ui 6.57.0 → 6.58.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.
- package/dist/_internal/components/data-display/Avatar/Avatar.js +2 -2
- package/dist/_internal/components/data-display/Badge/Badge.js +2 -2
- package/dist/_internal/components/data-display/Carousel/Carousel.js +2 -2
- package/dist/_internal/components/data-display/Chart/Chart.js +4 -4
- package/dist/_internal/components/data-display/Chart/SpecChart.js +6 -6
- package/dist/_internal/components/data-display/Chart/chart-context.js +2 -2
- package/dist/_internal/components/data-display/Chart/chart-renderers.js +3 -3
- package/dist/_internal/components/data-display/DataGrid/DataGrid.js +2 -2
- package/dist/_internal/components/data-display/DataViews/DataViewsGrid.js +18 -18
- package/dist/_internal/components/data-display/DataViews/DataViewsTableBase.js +20 -19
- package/dist/_internal/components/data-display/DataViews/base-list-card-geometry.js +5 -3
- package/dist/_internal/components/data-display/DataViews/base-list-card-layout.js +45 -0
- package/dist/_internal/components/data-display/DataViews/base-list-card-layout.js.map +1 -0
- package/dist/_internal/components/data-display/DataViews/base-list-card-slots.js +2 -2
- package/dist/_internal/components/data-display/DataViews/base-list-card.js +5 -4
- package/dist/_internal/components/data-display/DataViews/data-views-category-pill.js +1 -1
- package/dist/_internal/components/data-display/DataViews/data-views-filter-panel.js +4 -4
- package/dist/_internal/components/data-display/DataViews/data-views-grid-bodies.js +4 -4
- package/dist/_internal/components/data-display/DataViews/data-views-grid-parts.js +17 -17
- package/dist/_internal/components/data-display/DataViews/data-views-inline-bar.js +6 -6
- package/dist/_internal/components/data-display/DataViews/data-views-more-fields.js +4 -4
- package/dist/_internal/components/data-display/DataViews/data-views-more-filters.js +5 -5
- package/dist/_internal/components/data-display/DataViews/data-views-range-pill.js +2 -2
- package/dist/_internal/components/data-display/DataViews/data-views-selection-extra.js +3 -1
- package/dist/_internal/components/data-display/DataViews/data-views-shell-toolbar.js +3 -3
- package/dist/_internal/components/data-display/DataViews/data-views-table-parts.js +1 -1
- package/dist/_internal/components/data-display/DataViews/data-views-toolbar.js +2 -2
- package/dist/_internal/components/data-display/DataViews/data-views-url-echo.js +13 -0
- package/dist/_internal/components/data-display/DataViews/data-views-url-echo.js.map +1 -0
- package/dist/_internal/components/data-display/DataViews/list-card-rails.js +1 -1
- package/dist/_internal/components/data-display/FleetMap/FleetMap.fixtures.js +1 -1
- package/dist/_internal/components/data-display/index.js +14 -14
- package/dist/_internal/components/index.js +22 -22
- package/dist/_internal/components/layout/ContentToolbar/ContentToolbar.js +1 -1
- package/dist/_internal/components/layout/index.js +1 -1
- package/dist/_internal/components/navigation/SectionNav/SectionNav.bar.js +6 -6
- package/dist/_internal/components/navigation/SectionNav/SectionNav.js +9 -9
- package/dist/_internal/components/navigation/SectionNav/SectionNav.parts.js +3 -3
- package/dist/_internal/components/navigation/SectionNav/SectionNav.primary.js +4 -4
- package/dist/_internal/components/navigation/SectionNav/SectionNav.rail.js +5 -5
- package/dist/_internal/components/navigation/SectionNav/SectionNav.railCreate.js +4 -4
- package/dist/_internal/components/navigation/SectionNav/SectionNav.sheet.js +4 -4
- package/dist/_internal/components/navigation/index.js +9 -9
- package/dist/_internal/en-US.data-display.js +1 -1
- package/dist/_internal/pt-BR.data-display.js +1 -1
- package/dist/_internal/user-avatar/user-avatar.js +3 -3
- package/dist/charts.js +6 -6
- package/dist/{chunk-MKAA3YIJ.js → chunk-3K7WN2PO.js} +3 -3
- package/dist/{chunk-573XC4HK.js → chunk-4QKS5Y35.js} +2 -2
- package/dist/{chunk-KX75HM5U.js → chunk-5YDS6HO3.js} +7 -2
- package/dist/{chunk-KX75HM5U.js.map → chunk-5YDS6HO3.js.map} +1 -1
- package/dist/{chunk-N4MR4EMC.js → chunk-6D2PFC5C.js} +2 -2
- package/dist/{chunk-LJKWWXZD.js → chunk-6OSUK2C7.js} +28 -22
- package/dist/chunk-6OSUK2C7.js.map +1 -0
- package/dist/{chunk-ICSXPZXT.js → chunk-6QBT5TPS.js} +2 -2
- package/dist/{chunk-C67FDYG7.js → chunk-7CWZI6MQ.js} +5 -5
- package/dist/{chunk-JL77BSOL.js → chunk-AQI3UK6P.js} +2 -2
- package/dist/{chunk-A6EUQDRK.js → chunk-ARJIKW56.js} +4 -2
- package/dist/chunk-ARJIKW56.js.map +1 -0
- package/dist/{chunk-GI24X7XA.js → chunk-DZIRCD2W.js} +2 -2
- package/dist/{chunk-53ACGKBW.js → chunk-EDBP62WG.js} +3 -3
- package/dist/{chunk-YXIVQFNW.js → chunk-EWIKSTJV.js} +4 -4
- package/dist/{chunk-LWZ2K225.js → chunk-FXZUVZON.js} +6 -6
- package/dist/chunk-G6EJLEVV.js +75 -0
- package/dist/chunk-G6EJLEVV.js.map +1 -0
- package/dist/{chunk-IK2ZVV3M.js → chunk-GK7JNSMK.js} +2 -2
- package/dist/{chunk-HFBQCJNP.js → chunk-HCYRCU4W.js} +2 -2
- package/dist/{chunk-BJMNAPKH.js → chunk-HH7PM5HT.js} +10 -22
- package/dist/chunk-HH7PM5HT.js.map +1 -0
- package/dist/{chunk-7AAJYWC3.js → chunk-HPO7PB4F.js} +2 -2
- package/dist/{chunk-WF3P7GE5.js → chunk-I3CQBEKS.js} +2 -2
- package/dist/{chunk-RREWYOKS.js → chunk-IL4FCC54.js} +2 -2
- package/dist/{chunk-7M3DRP7Q.js → chunk-ILNO4ZJ6.js} +3 -3
- package/dist/{chunk-2CJZLL5Y.js → chunk-NHVL2QPG.js} +2 -1
- package/dist/{chunk-2CJZLL5Y.js.map → chunk-NHVL2QPG.js.map} +1 -1
- package/dist/{chunk-45PGSVOH.js → chunk-NTJUAPJM.js} +10 -8
- package/dist/chunk-NTJUAPJM.js.map +1 -0
- package/dist/{chunk-EUPUEMFX.js → chunk-PC4H5LVB.js} +7 -7
- package/dist/{chunk-KEKOPD43.js → chunk-PQ7RWH7L.js} +4 -2
- package/dist/chunk-PQ7RWH7L.js.map +1 -0
- package/dist/{chunk-HRMB72E4.js → chunk-QHP5PZNC.js} +2 -1
- package/dist/{chunk-HRMB72E4.js.map → chunk-QHP5PZNC.js.map} +1 -1
- package/dist/{chunk-GNBCSTXF.js → chunk-QKAYXAQE.js} +6 -6
- package/dist/{chunk-GNBCSTXF.js.map → chunk-QKAYXAQE.js.map} +1 -1
- package/dist/{chunk-TZFBJ47T.js → chunk-SFLNHCA2.js} +39 -15
- package/dist/chunk-SFLNHCA2.js.map +1 -0
- package/dist/{chunk-OBMPE6PW.js → chunk-SSDYEOU4.js} +5 -5
- package/dist/{chunk-I6ESCBY3.js → chunk-TF27Z27K.js} +2 -2
- package/dist/{chunk-JF5LQOGB.js → chunk-U47KRLEW.js} +57 -45
- package/dist/chunk-U47KRLEW.js.map +1 -0
- package/dist/{chunk-RBHBJDOZ.js → chunk-UEU5NSIG.js} +4 -4
- package/dist/chunk-V4V2N6YJ.js +55 -0
- package/dist/chunk-V4V2N6YJ.js.map +1 -0
- package/dist/{chunk-G76BNXWE.js → chunk-XW5SEW3H.js} +6 -6
- package/dist/{chunk-46ZATLQV.js → chunk-YIKFYWKD.js} +3 -3
- package/dist/{chunk-4JBS6NOT.js → chunk-ZWBGQYVO.js} +35 -6
- package/dist/chunk-ZWBGQYVO.js.map +1 -0
- package/dist/{chunk-VWW2EXH7.js → chunk-ZYJZHXFU.js} +4 -4
- package/dist/data-display/Avatar.js +2 -2
- package/dist/data-display/Badge.js +2 -2
- package/dist/data-display/CardKit.js +10 -10
- package/dist/data-display/Carousel.js +2 -2
- package/dist/data-display/Chart.js +6 -6
- package/dist/data-display/DataGrid.js +2 -2
- package/dist/data-display/DataViews.js +25 -23
- package/dist/en-US.js +1 -1
- package/dist/layout/ContentToolbar.js +1 -1
- package/dist/locales.js +2 -2
- package/dist/navigation/SectionNav.js +9 -9
- package/dist/pt-BR.js +1 -1
- package/dist/types/components/data-display/DataViews/DataViewsTableBase.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/base-list-card-geometry.d.ts +29 -1
- package/dist/types/components/data-display/DataViews/base-list-card-geometry.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/base-list-card-layout.d.ts +46 -0
- package/dist/types/components/data-display/DataViews/base-list-card-layout.d.ts.map +1 -0
- package/dist/types/components/data-display/DataViews/base-list-card-slots.d.ts +5 -2
- package/dist/types/components/data-display/DataViews/base-list-card-slots.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/base-list-card.d.ts +10 -1
- package/dist/types/components/data-display/DataViews/base-list-card.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/data-views-copy.d.ts +7 -0
- package/dist/types/components/data-display/DataViews/data-views-copy.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/data-views-grid-parts.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/data-views-selection-extra.d.ts +2 -0
- package/dist/types/components/data-display/DataViews/data-views-selection-extra.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/data-views-shell-toolbar.d.ts +3 -1
- package/dist/types/components/data-display/DataViews/data-views-shell-toolbar.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/data-views-toolbar.d.ts +2 -0
- package/dist/types/components/data-display/DataViews/data-views-toolbar.d.ts.map +1 -1
- package/dist/types/components/data-display/DataViews/data-views-url-echo.d.ts +47 -0
- package/dist/types/components/data-display/DataViews/data-views-url-echo.d.ts.map +1 -0
- package/dist/types/components/data-display/DataViews/list-card-rails.d.ts +17 -2
- package/dist/types/components/data-display/DataViews/list-card-rails.d.ts.map +1 -1
- package/dist/types/components/layout/ContentToolbar/ContentToolbar.d.ts +3 -2
- package/dist/types/components/layout/ContentToolbar/ContentToolbar.d.ts.map +1 -1
- package/dist/types/components/layout/ContentToolbar/ContentToolbar.types.d.ts +14 -0
- package/dist/types/components/layout/ContentToolbar/ContentToolbar.types.d.ts.map +1 -1
- package/dist/types/en-US.data-display.d.ts.map +1 -1
- package/dist/types/pt-BR.data-display.d.ts.map +1 -1
- package/dist/user-avatar.js +3 -3
- package/package.json +1 -1
- package/src/components/data-display/DataViews/DataViewsTableBase.tsx +7 -36
- package/src/components/data-display/DataViews/base-list-card-geometry.tsx +114 -40
- package/src/components/data-display/DataViews/base-list-card-layout.tsx +104 -0
- package/src/components/data-display/DataViews/base-list-card-slots.tsx +47 -3
- package/src/components/data-display/DataViews/base-list-card.tsx +65 -68
- package/src/components/data-display/DataViews/data-views-copy.ts +7 -0
- package/src/components/data-display/DataViews/data-views-grid-parts.tsx +2 -1
- package/src/components/data-display/DataViews/data-views-selection-extra.ts +10 -1
- package/src/components/data-display/DataViews/data-views-shell-toolbar.tsx +4 -0
- package/src/components/data-display/DataViews/data-views-toolbar.tsx +4 -0
- package/src/components/data-display/DataViews/data-views-url-echo.ts +134 -0
- package/src/components/data-display/DataViews/list-card-rails.tsx +22 -6
- package/src/components/layout/ContentToolbar/ContentToolbar.md +5 -2
- package/src/components/layout/ContentToolbar/ContentToolbar.tsx +51 -10
- package/src/components/layout/ContentToolbar/ContentToolbar.types.ts +14 -0
- package/src/en-US.data-display.ts +1 -0
- package/src/pt-BR.data-display.ts +1 -0
- package/dist/chunk-45PGSVOH.js.map +0 -1
- package/dist/chunk-4JBS6NOT.js.map +0 -1
- package/dist/chunk-A6EUQDRK.js.map +0 -1
- package/dist/chunk-BJMNAPKH.js.map +0 -1
- package/dist/chunk-JF5LQOGB.js.map +0 -1
- package/dist/chunk-KEKOPD43.js.map +0 -1
- package/dist/chunk-LJKWWXZD.js.map +0 -1
- package/dist/chunk-TZFBJ47T.js.map +0 -1
- /package/dist/{chunk-MKAA3YIJ.js.map → chunk-3K7WN2PO.js.map} +0 -0
- /package/dist/{chunk-573XC4HK.js.map → chunk-4QKS5Y35.js.map} +0 -0
- /package/dist/{chunk-N4MR4EMC.js.map → chunk-6D2PFC5C.js.map} +0 -0
- /package/dist/{chunk-ICSXPZXT.js.map → chunk-6QBT5TPS.js.map} +0 -0
- /package/dist/{chunk-C67FDYG7.js.map → chunk-7CWZI6MQ.js.map} +0 -0
- /package/dist/{chunk-JL77BSOL.js.map → chunk-AQI3UK6P.js.map} +0 -0
- /package/dist/{chunk-GI24X7XA.js.map → chunk-DZIRCD2W.js.map} +0 -0
- /package/dist/{chunk-53ACGKBW.js.map → chunk-EDBP62WG.js.map} +0 -0
- /package/dist/{chunk-YXIVQFNW.js.map → chunk-EWIKSTJV.js.map} +0 -0
- /package/dist/{chunk-LWZ2K225.js.map → chunk-FXZUVZON.js.map} +0 -0
- /package/dist/{chunk-IK2ZVV3M.js.map → chunk-GK7JNSMK.js.map} +0 -0
- /package/dist/{chunk-HFBQCJNP.js.map → chunk-HCYRCU4W.js.map} +0 -0
- /package/dist/{chunk-7AAJYWC3.js.map → chunk-HPO7PB4F.js.map} +0 -0
- /package/dist/{chunk-WF3P7GE5.js.map → chunk-I3CQBEKS.js.map} +0 -0
- /package/dist/{chunk-RREWYOKS.js.map → chunk-IL4FCC54.js.map} +0 -0
- /package/dist/{chunk-7M3DRP7Q.js.map → chunk-ILNO4ZJ6.js.map} +0 -0
- /package/dist/{chunk-EUPUEMFX.js.map → chunk-PC4H5LVB.js.map} +0 -0
- /package/dist/{chunk-OBMPE6PW.js.map → chunk-SSDYEOU4.js.map} +0 -0
- /package/dist/{chunk-I6ESCBY3.js.map → chunk-TF27Z27K.js.map} +0 -0
- /package/dist/{chunk-RBHBJDOZ.js.map → chunk-UEU5NSIG.js.map} +0 -0
- /package/dist/{chunk-G76BNXWE.js.map → chunk-XW5SEW3H.js.map} +0 -0
- /package/dist/{chunk-46ZATLQV.js.map → chunk-YIKFYWKD.js.map} +0 -0
- /package/dist/{chunk-VWW2EXH7.js.map → chunk-ZYJZHXFU.js.map} +0 -0
|
@@ -23,6 +23,7 @@ export function ShellToolbar<T extends Record<string, unknown>>({
|
|
|
23
23
|
rowActions,
|
|
24
24
|
bulkActions,
|
|
25
25
|
selectionExtra,
|
|
26
|
+
allOnPageSelected,
|
|
26
27
|
toolbarRightSlot,
|
|
27
28
|
showInline,
|
|
28
29
|
compactControls,
|
|
@@ -43,6 +44,8 @@ export function ShellToolbar<T extends Record<string, unknown>>({
|
|
|
43
44
|
bulkActions?: (selectedRows: T[], clearSelection: () => void) => React.ReactNode;
|
|
44
45
|
/** Already resolved by the shell, which is the party that knows the page. */
|
|
45
46
|
selectionExtra?: React.ReactNode;
|
|
47
|
+
/** Every row on the page is ticked: the select-all box reads checked, else partial. */
|
|
48
|
+
allOnPageSelected?: boolean;
|
|
46
49
|
toolbarRightSlot?: React.ReactNode;
|
|
47
50
|
/** Search + filters, rendered on the toolbar line (see `GridToolbar`). */
|
|
48
51
|
filterControls?: React.ReactNode;
|
|
@@ -75,6 +78,7 @@ export function ShellToolbar<T extends Record<string, unknown>>({
|
|
|
75
78
|
rowActions={rowActions}
|
|
76
79
|
bulkActions={bulkActions}
|
|
77
80
|
selectionExtra={selectionExtra}
|
|
81
|
+
allOnPageSelected={allOnPageSelected}
|
|
78
82
|
sortFields={c.resolvedSortFields}
|
|
79
83
|
activeSortField={c.activeSortField}
|
|
80
84
|
activeSortOrder={c.activeSortOrder}
|
|
@@ -28,6 +28,8 @@ export interface GridToolbarProps<T extends Record<string, unknown>> {
|
|
|
28
28
|
bulkActions?: (selectedRows: T[], clearSelection: () => void) => React.ReactNode;
|
|
29
29
|
/** A control between the count and the actions menu — see `selectionExtra`. */
|
|
30
30
|
selectionExtra?: React.ReactNode;
|
|
31
|
+
/** Every row on the page is ticked: the select-all box reads checked, else partial. */
|
|
32
|
+
allOnPageSelected?: boolean;
|
|
31
33
|
sortFields: SortFieldDefinition[];
|
|
32
34
|
activeSortField: string;
|
|
33
35
|
activeSortOrder: "asc" | "desc";
|
|
@@ -160,11 +162,13 @@ export function GridToolbar<T extends Record<string, unknown>>(props: GridToolba
|
|
|
160
162
|
clearAllText={copy.filters.clearAll}
|
|
161
163
|
hasSelection={selectedRows.length > 0}
|
|
162
164
|
selectedCount={selectedRows.length}
|
|
165
|
+
selectedCountLabel={copy.selection.selectedCount}
|
|
163
166
|
selectAll={props.selectAll}
|
|
164
167
|
clearSelection={props.clearSelection}
|
|
165
168
|
selectAllTestId={`${testIdPrefix}-select-all`}
|
|
166
169
|
clearAllTestId={`${testIdPrefix}-clear-all`}
|
|
167
170
|
selectionExtra={props.selectionExtra}
|
|
171
|
+
allSelected={props.allOnPageSelected}
|
|
168
172
|
actions={renderBulkActions({
|
|
169
173
|
rowActions: props.rowActions,
|
|
170
174
|
bulkActions: props.bulkActions,
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
|
|
5
|
+
import type { RangeValue } from "./data-views-range-types";
|
|
6
|
+
import type { DataViewServer, DataViewState, DataViewSyncState } from "./data-views-types";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A server-mode grid's URL round trip, and the echo it must not re-apply.
|
|
10
|
+
*
|
|
11
|
+
* A server-mode host mirrors the grid's query into its URL and hands it back as
|
|
12
|
+
* `initialState`, which the base turns into `syncState` and MERGES over the live
|
|
13
|
+
* state, so browser back/forward moves the controls. But the browser shows the
|
|
14
|
+
* new URL before React renders it. An edit made in that window, such as
|
|
15
|
+
* clearing a date bound right after typing it, is overwritten when the render
|
|
16
|
+
* carrying the PREVIOUS query lands. The grid then re-emits that stale query,
|
|
17
|
+
* and the cleared filter comes back and sticks in the URL (FUT-3182, the
|
|
18
|
+
* audit trail's "De" bound).
|
|
19
|
+
*
|
|
20
|
+
* So the base records every query it emits. An `initialState` matching one
|
|
21
|
+
* still pending is the host echoing it back, not a navigation, and it is not
|
|
22
|
+
* merged. Anything else (back/forward, a deep link, a host-side reset) still is.
|
|
23
|
+
* A host whose round trip changes the slice's shape never matches, and keeps
|
|
24
|
+
* the old behaviour rather than losing a navigation.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** The URL-carried part of a grid state or query. */
|
|
28
|
+
type UrlSlice = Pick<DataViewState, "search" | "pills" | "ranges" | "sortBy" | "scope">;
|
|
29
|
+
|
|
30
|
+
/** Hosts drop unset bounds on the way through the URL, so the key drops them too. */
|
|
31
|
+
function bounds(range: RangeValue): RangeValue | null {
|
|
32
|
+
const set = (value: number | string | undefined): boolean => value !== undefined && value !== "";
|
|
33
|
+
const kept: RangeValue = {
|
|
34
|
+
...(set(range.min) ? { min: range.min } : {}),
|
|
35
|
+
...(set(range.max) ? { max: range.max } : {}),
|
|
36
|
+
};
|
|
37
|
+
return Object.keys(kept).length > 0 ? kept : null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const byKey = ([a]: [string, unknown], [b]: [string, unknown]): number => a.localeCompare(b);
|
|
41
|
+
|
|
42
|
+
/** One comparable string for a URL slice: empty pills and unbounded ranges left out. */
|
|
43
|
+
export function urlSliceKey(slice: UrlSlice): string {
|
|
44
|
+
const pills = Object.entries(slice.pills ?? {})
|
|
45
|
+
.filter(([, values]) => values.length > 0)
|
|
46
|
+
.sort(byKey);
|
|
47
|
+
const ranges = Object.entries(slice.ranges ?? {})
|
|
48
|
+
.map(([id, range]): [string, RangeValue | null] => [id, bounds(range)])
|
|
49
|
+
.filter(([, range]) => range !== null)
|
|
50
|
+
.sort(byKey);
|
|
51
|
+
return JSON.stringify({
|
|
52
|
+
q: slice.search ?? "",
|
|
53
|
+
pills,
|
|
54
|
+
ranges,
|
|
55
|
+
sort: slice.sortBy ?? [],
|
|
56
|
+
scope: slice.scope ?? null,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Enough to cover a burst of edits; older entries can no longer echo. */
|
|
61
|
+
const MAX_PENDING = 20;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Record what the grid emits, and recognise it coming back.
|
|
65
|
+
*
|
|
66
|
+
* `consumeEcho` answers whether a URL slice is one of the queries still in
|
|
67
|
+
* flight. A match drops it and every older one, since the host has caught up to
|
|
68
|
+
* at least that far; a miss is a navigation and clears the list.
|
|
69
|
+
*/
|
|
70
|
+
export function useUrlEchoGuard(server: DataViewServer | undefined): {
|
|
71
|
+
server: DataViewServer | undefined;
|
|
72
|
+
consumeEcho: (slice: UrlSlice) => boolean;
|
|
73
|
+
} {
|
|
74
|
+
const pending = useRef<string[]>([]);
|
|
75
|
+
const recorded: DataViewServer | undefined = server && {
|
|
76
|
+
...server,
|
|
77
|
+
onQueryChange: (query) => {
|
|
78
|
+
pending.current = [...pending.current, urlSliceKey(query)].slice(-MAX_PENDING);
|
|
79
|
+
server.onQueryChange(query);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
const consumeEcho = (slice: UrlSlice): boolean => {
|
|
83
|
+
const at = pending.current.lastIndexOf(urlSliceKey(slice));
|
|
84
|
+
pending.current = at === -1 ? [] : pending.current.slice(at + 1);
|
|
85
|
+
return at !== -1;
|
|
86
|
+
};
|
|
87
|
+
return { server: recorded, consumeEcho };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function syncFrom(serverMode: boolean, initialState: DataViewState | undefined): DataViewSyncState | undefined {
|
|
91
|
+
if (!serverMode || !initialState) return undefined;
|
|
92
|
+
return {
|
|
93
|
+
search: initialState.search,
|
|
94
|
+
pills: initialState.pills,
|
|
95
|
+
ranges: initialState.ranges,
|
|
96
|
+
sortBy: initialState.sortBy,
|
|
97
|
+
// The scope belongs in the URL-driven slice alongside them: a
|
|
98
|
+
// `?view=recusados`-style deep link and browser back/forward must move the
|
|
99
|
+
// tab strip, and they must do it WITHOUT resetting the user's hidden
|
|
100
|
+
// columns — which is the whole reason this is a merging `syncState` and
|
|
101
|
+
// not a replacing `appliedState`.
|
|
102
|
+
scope: initialState.scope,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Derive the grid's reactive `syncState` from the URL-seeded `initialState` in
|
|
108
|
+
* server mode, so browser back/forward RE-APPLIES the search/pills/sort controls
|
|
109
|
+
* (merging over live state, preserving hidden columns — see
|
|
110
|
+
* {@link DataViewSyncState}). Client-mode tables (no `server`) get `undefined`.
|
|
111
|
+
*
|
|
112
|
+
* Seeded on the first render, so a deep link shows on mount. After that a new
|
|
113
|
+
* `initialState` reference is re-applied unless it is the grid's own query
|
|
114
|
+
* coming back (`consumeEcho`), which would overwrite an edit made since.
|
|
115
|
+
*/
|
|
116
|
+
export function useUrlSyncState(
|
|
117
|
+
server: DataViewServer | undefined,
|
|
118
|
+
initialState: DataViewState | undefined,
|
|
119
|
+
consumeEcho: (slice: UrlSlice) => boolean,
|
|
120
|
+
): DataViewSyncState | undefined {
|
|
121
|
+
const serverMode = server !== undefined;
|
|
122
|
+
const [syncState, setSyncState] = useState(() => syncFrom(serverMode, initialState));
|
|
123
|
+
const seen = useRef({ serverMode, initialState });
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
const last = seen.current;
|
|
126
|
+
if (last.serverMode === serverMode && last.initialState === initialState) return;
|
|
127
|
+
seen.current = { serverMode, initialState };
|
|
128
|
+
const next = syncFrom(serverMode, initialState);
|
|
129
|
+
if (next && consumeEcho(next)) return;
|
|
130
|
+
setSyncState(next);
|
|
131
|
+
// `consumeEcho` reads a ref; only a new URL seed or a mode change re-runs this.
|
|
132
|
+
}, [serverMode, initialState]);
|
|
133
|
+
return syncState;
|
|
134
|
+
}
|
|
@@ -206,16 +206,32 @@ export const RAIL_COUNT = 8;
|
|
|
206
206
|
*/
|
|
207
207
|
const CELL_FIXED_RAILS = 4;
|
|
208
208
|
|
|
209
|
-
/**
|
|
210
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Tracks for a cell-configured row: gutters, leading, the cells, then the menu.
|
|
211
|
+
*
|
|
212
|
+
* `gutters` says which of the three head gutters RENDER. A group reserves all
|
|
213
|
+
* three (the default), so every row spans the same tracks. A standalone row
|
|
214
|
+
* renders a gutter only when it uses it, and a track whose slot renders nothing
|
|
215
|
+
* is not a reserved gap: grid auto-placement fills it with the NEXT slot. So the
|
|
216
|
+
* checkbox landed in the disclosure track, the glyph in the drag track, and
|
|
217
|
+
* every cell two tracks early, in a column sized for something else. The named-
|
|
218
|
+
* slot layout already drops absent gutters ({@link railsTemplateFor}); this is
|
|
219
|
+
* the same rule for configured cells.
|
|
220
|
+
*/
|
|
221
|
+
export function cellRailsTemplate(
|
|
222
|
+
cells: readonly string[],
|
|
223
|
+
gutters: { disclose: boolean; drag: boolean; select: boolean } = { disclose: true, drag: true, select: true },
|
|
224
|
+
): string {
|
|
211
225
|
return [
|
|
212
|
-
DEFAULT_RAILS.disclose,
|
|
213
|
-
DEFAULT_RAILS.drag,
|
|
214
|
-
DEFAULT_RAILS.select,
|
|
226
|
+
gutters.disclose ? DEFAULT_RAILS.disclose : null,
|
|
227
|
+
gutters.drag ? DEFAULT_RAILS.drag : null,
|
|
228
|
+
gutters.select ? DEFAULT_RAILS.select : null,
|
|
215
229
|
DEFAULT_RAILS.leading,
|
|
216
230
|
...cells,
|
|
217
231
|
DEFAULT_RAILS.actions,
|
|
218
|
-
]
|
|
232
|
+
]
|
|
233
|
+
.filter((rail): rail is string => rail != null)
|
|
234
|
+
.join(" ");
|
|
219
235
|
}
|
|
220
236
|
|
|
221
237
|
/** How many tracks such a row spans — the fixed head/tail plus one per cell. */
|
|
@@ -13,8 +13,10 @@ pages and projects.
|
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
- **Left cluster** — always shows **Select All**. Once `hasSelection` is true it
|
|
16
|
-
adds **Clear All**,
|
|
17
|
-
`selectionExtra` then `actions`.
|
|
16
|
+
adds **Clear All**, the selection count, and two optional slots:
|
|
17
|
+
`selectionExtra` then `actions`. The count's words come from the required
|
|
18
|
+
`selectedCountLabel(count)` ("1 selecionado", "3 selecionados"); the
|
|
19
|
+
package ships no default, and DataViews feeds it `copy.selection.selectedCount`.
|
|
18
20
|
- **`selectionExtra` vs `actions`** — `actions` is what HAPPENS to the selection
|
|
19
21
|
(delete, export, send). `selectionExtra` is what the selection IS: the
|
|
20
22
|
"select all N matching the filter" widening a paginated list needs once its
|
|
@@ -48,6 +50,7 @@ import {
|
|
|
48
50
|
<ContentToolbar
|
|
49
51
|
hasSelection={selected.size > 0}
|
|
50
52
|
selectedCount={selected.size}
|
|
53
|
+
selectedCountLabel={(n) => `${n} ${n === 1 ? 'selecionado' : 'selecionados'}`}
|
|
51
54
|
selectAll={selectAll}
|
|
52
55
|
clearSelection={clear}
|
|
53
56
|
actions={<DeleteButton />}
|
|
@@ -27,6 +27,8 @@ type SelectionClusterProps = Pick<
|
|
|
27
27
|
ContentToolbarProps,
|
|
28
28
|
| 'hasSelection'
|
|
29
29
|
| 'selectedCount'
|
|
30
|
+
| 'selectedCountLabel'
|
|
31
|
+
| 'allSelected'
|
|
30
32
|
| 'selectAll'
|
|
31
33
|
| 'clearSelection'
|
|
32
34
|
| 'actions'
|
|
@@ -39,10 +41,42 @@ type SelectionClusterProps = Pick<
|
|
|
39
41
|
| 'clearAllText'
|
|
40
42
|
>;
|
|
41
43
|
|
|
44
|
+
/**
|
|
45
|
+
* The phone's select-all box. Checked only when everything is ticked and
|
|
46
|
+
* partial while some is, when the host says which (`allSelected`) — the same
|
|
47
|
+
* reading as the table's header checkbox. A partial box selects the rest, as
|
|
48
|
+
* the header does; a full one clears.
|
|
49
|
+
*/
|
|
50
|
+
function SelectAllBox({
|
|
51
|
+
hasSelection,
|
|
52
|
+
allSelected,
|
|
53
|
+
selectAll,
|
|
54
|
+
clearSelection,
|
|
55
|
+
selectAllTestId,
|
|
56
|
+
selectAllLabel,
|
|
57
|
+
}: Pick<
|
|
58
|
+
ContentToolbarProps,
|
|
59
|
+
'hasSelection' | 'allSelected' | 'selectAll' | 'clearSelection' | 'selectAllTestId' | 'selectAllLabel'
|
|
60
|
+
>): React.JSX.Element {
|
|
61
|
+
return (
|
|
62
|
+
<Checkbox
|
|
63
|
+
size="small"
|
|
64
|
+
checked={allSelected ?? hasSelection}
|
|
65
|
+
indeterminate={hasSelection && allSelected === false}
|
|
66
|
+
onChange={() => (hasSelection && allSelected !== false ? clearSelection() : selectAll())}
|
|
67
|
+
data-testid={`${selectAllTestId}-checkbox`}
|
|
68
|
+
inputProps={{ 'aria-label': selectAllLabel }}
|
|
69
|
+
sx={{ p: 0.5, display: { xs: 'inline-flex', md: 'none' } }}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
42
74
|
/** The left cluster: Select All + (when selecting) Clear All / count / actions. */
|
|
43
75
|
function SelectionCluster({
|
|
44
76
|
hasSelection,
|
|
77
|
+
allSelected,
|
|
45
78
|
selectedCount,
|
|
79
|
+
selectedCountLabel,
|
|
46
80
|
selectAll,
|
|
47
81
|
clearSelection,
|
|
48
82
|
actions,
|
|
@@ -95,17 +129,18 @@ function SelectionCluster({
|
|
|
95
129
|
>
|
|
96
130
|
{selectAllText}
|
|
97
131
|
</Button>
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
132
|
+
<SelectAllBox
|
|
133
|
+
hasSelection={hasSelection}
|
|
134
|
+
allSelected={allSelected}
|
|
135
|
+
selectAll={selectAll}
|
|
136
|
+
clearSelection={clearSelection}
|
|
137
|
+
selectAllTestId={selectAllTestId}
|
|
138
|
+
selectAllLabel={selectAllLabel}
|
|
105
139
|
/>
|
|
106
140
|
{hasSelection ? (
|
|
107
141
|
<SelectionState
|
|
108
142
|
selectedCount={selectedCount}
|
|
143
|
+
selectedCountLabel={selectedCountLabel}
|
|
109
144
|
clearSelection={clearSelection}
|
|
110
145
|
clearAllTestId={clearAllTestId}
|
|
111
146
|
clearAllText={clearAllText}
|
|
@@ -128,13 +163,14 @@ function SelectionCluster({
|
|
|
128
163
|
*/
|
|
129
164
|
function SelectionState({
|
|
130
165
|
selectedCount,
|
|
166
|
+
selectedCountLabel,
|
|
131
167
|
clearSelection,
|
|
132
168
|
clearAllTestId,
|
|
133
169
|
clearAllText,
|
|
134
170
|
selectionExtra,
|
|
135
171
|
}: Pick<
|
|
136
172
|
ContentToolbarProps,
|
|
137
|
-
'selectedCount' | 'clearSelection' | 'clearAllTestId' | 'clearAllText' | 'selectionExtra'
|
|
173
|
+
'selectedCount' | 'selectedCountLabel' | 'clearSelection' | 'clearAllTestId' | 'clearAllText' | 'selectionExtra'
|
|
138
174
|
>): React.JSX.Element {
|
|
139
175
|
return (
|
|
140
176
|
<>
|
|
@@ -154,7 +190,7 @@ function SelectionState({
|
|
|
154
190
|
data-testid="selected-count-indicator"
|
|
155
191
|
sx={{ fontSize: sxRem(14), color: 'text.secondary', whiteSpace: 'nowrap', flexShrink: 0 }}
|
|
156
192
|
>
|
|
157
|
-
{selectedCount}
|
|
193
|
+
{selectedCountLabel(selectedCount)}
|
|
158
194
|
</Typography>
|
|
159
195
|
{selectionExtra !== undefined && (
|
|
160
196
|
<>
|
|
@@ -246,7 +282,7 @@ function BrowsingClusters({
|
|
|
246
282
|
/**
|
|
247
283
|
* Shared toolbar for content pages (Favorites, Personal Space, Recents, …). The
|
|
248
284
|
* left cluster owns selection chrome — **Select All**, and once items are
|
|
249
|
-
* selected, **Clear All** +
|
|
285
|
+
* selected, **Clear All** + the count (`selectedCountLabel`) + an optional `actions`
|
|
250
286
|
* slot. The right cluster is a free `rightControls` slot for page-specific
|
|
251
287
|
* controls (ViewSelector, SortByDropdown, MultiSelectDropdown, FilterTrigger).
|
|
252
288
|
*
|
|
@@ -259,6 +295,7 @@ function BrowsingClusters({
|
|
|
259
295
|
* <ContentToolbar
|
|
260
296
|
* hasSelection={selected.size > 0}
|
|
261
297
|
* selectedCount={selected.size}
|
|
298
|
+
* selectedCountLabel={(n) => `${n} ${n === 1 ? 'selecionado' : 'selecionados'}`}
|
|
262
299
|
* selectAll={selectAll}
|
|
263
300
|
* clearSelection={clear}
|
|
264
301
|
* rightControls={
|
|
@@ -274,7 +311,9 @@ function BrowsingClusters({
|
|
|
274
311
|
*/
|
|
275
312
|
export function ContentToolbar({
|
|
276
313
|
hasSelection,
|
|
314
|
+
allSelected,
|
|
277
315
|
selectedCount,
|
|
316
|
+
selectedCountLabel,
|
|
278
317
|
selectAll,
|
|
279
318
|
clearSelection,
|
|
280
319
|
rightControls,
|
|
@@ -316,7 +355,9 @@ export function ContentToolbar({
|
|
|
316
355
|
selectAllText={selectAllText}
|
|
317
356
|
clearAllText={clearAllText}
|
|
318
357
|
hasSelection={hasSelection}
|
|
358
|
+
allSelected={allSelected}
|
|
319
359
|
selectedCount={selectedCount}
|
|
360
|
+
selectedCountLabel={selectedCountLabel}
|
|
320
361
|
selectAll={selectAll}
|
|
321
362
|
clearSelection={clearSelection}
|
|
322
363
|
actions={actions}
|
|
@@ -17,6 +17,20 @@ export interface ContentToolbarProps {
|
|
|
17
17
|
hasSelection: boolean;
|
|
18
18
|
/** Number of currently selected items. */
|
|
19
19
|
selectedCount: number;
|
|
20
|
+
/**
|
|
21
|
+
* The words for that count — "1 selecionado", "3 selecionados".
|
|
22
|
+
* A function because the noun agrees with the number. REQUIRED: this package
|
|
23
|
+
* ships no default copy, and the English it used to hardcode here was the one
|
|
24
|
+
* string on a pt-BR admin list a host could not replace (FUT-1443).
|
|
25
|
+
*/
|
|
26
|
+
selectedCountLabel: (count: number) => string;
|
|
27
|
+
/**
|
|
28
|
+
* Whether EVERYTHING the select-all box covers is selected. When given, the
|
|
29
|
+
* box reads checked only then, and partial (indeterminate) while just some
|
|
30
|
+
* rows are — as the table's own header checkbox does. Omitted, it keeps
|
|
31
|
+
* reading checked for any selection.
|
|
32
|
+
*/
|
|
33
|
+
allSelected?: boolean;
|
|
20
34
|
/** Select every item on the page. */
|
|
21
35
|
selectAll: () => void;
|
|
22
36
|
/** Clear the current selection. */
|
|
@@ -230,6 +230,7 @@ export const EN_US_DATA_VIEWS_COPY: DataViewsCopy = {
|
|
|
230
230
|
clearSelection: "Clear selection",
|
|
231
231
|
selectAll: "Select all",
|
|
232
232
|
onThisPage: (count) => `${count} on this page`,
|
|
233
|
+
selectedCount: (count) => `${count} ${count === 1 ? "item selected" : "items selected"}`,
|
|
233
234
|
selectRow: "Select",
|
|
234
235
|
expandRow: "Expand details",
|
|
235
236
|
collapseRow: "Collapse details",
|
|
@@ -222,6 +222,7 @@ export const PT_BR_DATA_VIEWS_COPY: DataViewsCopy = {
|
|
|
222
222
|
clearSelection: "Limpar seleção",
|
|
223
223
|
selectAll: "Selecionar tudo",
|
|
224
224
|
onThisPage: (count) => `${count} nesta página`,
|
|
225
|
+
selectedCount: (count) => `${count} ${count === 1 ? "selecionado" : "selecionados"}`,
|
|
225
226
|
selectRow: "Selecionar",
|
|
226
227
|
expandRow: "Expandir detalhes",
|
|
227
228
|
collapseRow: "Recolher detalhes",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/data-display/DataViews/data-views-grid-parts.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\nimport { TableFilter } from \"../../layout/TableFilter\";\nimport { Stack } from \"../../../mui/Stack\";\n\nimport {\n DataViewsLayoutProvider,\n useDataViewsLayout,\n type DataViewsLayout,\n} from \"./data-views-layout-context\";\nimport { FilterDialog, GridFilterPanel } from \"./data-views-filter-panel\";\nimport { GridMain } from \"./data-views-grid-bodies\";\nimport type { ListGroupConfig } from \"./list-card-rails\";\nimport { InlineFilterControls } from \"./data-views-inline-bar\";\nimport { toOverflowFields, useFilterOverflow, type OverflowSplit } from \"./data-views-overflow\";\nimport { GridHeaderRow } from \"./data-views-header-row\";\nimport { resolveSelectionExtra, type SelectionExtraRender } from \"./data-views-selection-extra\";\nimport { ShellToolbar } from \"./data-views-shell-toolbar\";\nimport type { DisplayPanelView } from \"./data-views-display-panel\";\nimport type { DataViewExport } from \"./data-views-export\";\nimport { useDataViewsCopy } from \"./data-views-copy-context\";\nimport { DataViewsEmpty } from \"./data-views-empty\";\nimport { DataViewsPagination } from \"./data-views-pagination\";\nimport type { BoardConfig } from \"./DataViewsBoard\";\nimport { type ScopeConfig } from \"./data-views-scopes\";\nimport { ScopeTabsSlot } from \"./data-views-scope-tabs\";\nimport { togglePillValues } from \"./data-views-grid-helpers\";\nimport type {\n DataViewCardSelection,\n FilterFieldConfig,\n RangeFieldConfig,\n RangeValue,\n RowAction,\n} from \"./data-views-types\";\nimport type { DataViewRowDetail } from \"./data-views-row-detail\";\nimport type { DataViewsController } from \"./use-data-views-state\";\n\n/* ── Layout ⇄ view-state mirror ──────────────────────────────────────────── */\n\n/**\n * Mirrors the LIVE layout back into the view state, so saving a view captures\n * the layout the user is actually looking at.\n *\n * A component rather than a callback prop because only something INSIDE the\n * provider can read the layout, and only the controller can write the state.\n * The `stored !== layout` guard is what makes it idempotent: `c` is rebuilt on\n * every render, so an unguarded effect here would patch → re-render → patch.\n *\n * It re-fires when `stored` changes too, which is the case that matters after\n * applying a saved view: `appliedState` REPLACES the state, so a view saved\n * before layouts were captured clears `state.layout`, and the mirror puts the\n * current one back rather than leaving the next save with nothing to store.\n */\nfunction LayoutStateSync<T extends Record<string, unknown>>({\n c,\n}: {\n c: DataViewsController<T>;\n}): null {\n const { layout } = useDataViewsLayout();\n const stored = c.state.layout;\n useEffect(() => {\n if (stored !== layout) c.patch({ layout });\n // `c` is intentionally out of the deps — see the guard above.\n }, [layout, stored]);\n return null;\n}\n\n/* ── Shell (composes toolbar + body + panel) ─────────────────────────────── */\n\n/** The shared filter-surface props consumed by the inline bar, panel, and modal. */\ninterface FilterSurfaceProps<T extends Record<string, unknown>> {\n testIdPrefix: string;\n search: string;\n fields: FilterFieldConfig<T>[];\n rangeFields: RangeFieldConfig<T>[];\n pills: Record<string, string[]>;\n ranges: Record<string, RangeValue>;\n onSearchChange: (value: string) => void;\n onTogglePill: (fieldId: string, value: string, checked: boolean) => void;\n onChangeRange: (fieldId: string, range: RangeValue) => void;\n onClearField: (fieldId: string) => void;\n onClearAll: () => void;\n}\n\n/**\n * Derives the responsive filter state (which surface to show at this width) and\n * the filter-mutation handlers from the controller — pulled out of `GridShell`\n * so the component body stays under the size/complexity budget.\n */\n/** Grouped rather than positional: the list had grown past readability. */\ninterface GridShellFiltersArgs<T extends Record<string, unknown>> {\n c: DataViewsController<T>;\n inlineFilters: boolean;\n fields: FilterFieldConfig<T>[];\n rangeFields: RangeFieldConfig<T>[];\n testIdPrefix: string;\n alwaysShowSearch: boolean;\n /** Is \"Exportar\" on the bar? Half the right cluster's cost when it is not. */\n hasExport: boolean;\n}\n\nfunction useGridShellFilters<T extends Record<string, unknown>>({\n c,\n inlineFilters,\n fields,\n rangeFields,\n testIdPrefix,\n alwaysShowSearch,\n hasExport,\n}: GridShellFiltersArgs<T>): {\n showInline: boolean;\n useModal: boolean;\n inlineVisible: boolean;\n filterProps: FilterSurfaceProps<T>;\n split: OverflowSplit<T>;\n onControlOpenChange: (open: boolean) => void;\n} {\n const { state } = c;\n // How many filter controls are open. A COUNT, not a flag: closing one popover\n // by opening another overlaps, and a boolean would unfreeze mid-handover.\n const [openControls, setOpenControls] = useState(0);\n // ONE measurement for the whole shell: the filter row decides which controls\n // it can keep, and the TOOLBAR needs the same answer to drop its labels.\n // Measuring twice would let the two disagree at the crossover width.\n const split = useFilterOverflow(\n toOverflowFields(fields, rangeFields),\n state.pills,\n c.ranges,\n openControls > 0,\n hasExport,\n );\n // THE BAR RENDERS AT EVERY WIDTH. It used to be swapped for a full-screen\n // filter MODAL below `lg`, which was the responsive strategy before the\n // measured ladder existed — and the two now do the same job, badly together:\n // the modal took the bar away at 1199px, and with it the very degradation\n // (labels off, search collapsed, filters into \"Mais\") that exists to make a\n // narrow bar work. So a 900px window got no bar and no ladder, and the\n // operator lost the search entirely rather than gaining a compact one.\n //\n // The ladder is measured, so it already covers every width the modal did.\n const showInline = inlineFilters;\n const useModal = false;\n const inlineVisible =\n showInline &&\n (alwaysShowSearch || fields.length > 0 || rangeFields.length > 0 || state.search !== \"\");\n const filterProps: FilterSurfaceProps<T> = {\n testIdPrefix,\n search: state.search,\n fields,\n rangeFields,\n pills: state.pills,\n ranges: c.ranges,\n onSearchChange: (value) => c.patch({ search: value }),\n // Updater, never the render's `state` — see {@link DataViewStatePatch}.\n onTogglePill: (fieldId, value, checked) =>\n c.patch(({ pills }) => ({ pills: { ...pills, [fieldId]: togglePillValues(pills[fieldId], value, checked) } })),\n onChangeRange: (fieldId, range) => c.patch({ ranges: { ...c.ranges, [fieldId]: range } }),\n onClearField: (fieldId) => c.patch({ pills: { ...state.pills, [fieldId]: [] } }),\n onClearAll: () => c.patch({ search: \"\", pills: {}, ranges: {} }),\n };\n return {\n showInline,\n useModal,\n inlineVisible,\n filterProps,\n split,\n onControlOpenChange: (open) =>\n setOpenControls((count) => Math.max(0, count + (open ? 1 : -1))),\n };\n}\n\ninterface GridShellProps<T extends Record<string, unknown>> {\n c: DataViewsController<T>;\n rows: T[];\n fields: FilterFieldConfig<T>[];\n rangeFields: RangeFieldConfig<T>[];\n getRowId: (row: T) => string | number;\n testIdPrefix: string;\n dataTestId?: string;\n emptyState?: React.ReactNode;\n toolbarRightSlot?: React.ReactNode;\n rowActions?: RowAction<T>[];\n bulkActions?: (selectedRows: T[], clearSelection: () => void) => React.ReactNode;\n /** A widening control beside the selection count — see `resolveSelectionExtra`. */\n selectionExtra?: SelectionExtraRender<T>;\n /** Opt-in \"Grade\" (cards) layout: renders each row as an entity-supplied card.\n * Omit ⇒ table only (no layout toggle). */\n renderCard?: (row: T, selection: DataViewCardSelection) => React.ReactNode;\n /**\n * Opt-in \"Quadro\" (board) layout. Needs `renderCard` too — the board reuses\n * the entity's card, so a board config without one simply offers no board\n * rather than failing: that is a config gap, not a runtime error.\n */\n board?: BoardConfig<T>;\n /** Opt-in \"Lista\" layout: one full-width, entity-rendered row per record. */\n renderListRow?: (row: T, selection: DataViewCardSelection) => React.ReactNode;\n /** The Lista's shared columns, so its rows line up by construction. */\n listGroup?: ListGroupConfig<T>;\n /** Opt-in expandable rows, drawn by the table layout only. */\n rowDetail?: DataViewRowDetail<T>;\n /** The page-level partition rendered as tabs under the toolbar. */\n scopes?: ScopeConfig[];\n /**\n * The row field the scopes partition by. Compared against the board's\n * `groupBy` so the two are not shown as the same partition twice.\n */\n scopeFieldId?: string;\n /** Per-sort-field value kind, so directions read in the column's own terms. */\n sortKinds?: Record<string, string>;\n /** The saved-view chrome bracketing the Exibir panel. */\n displayView?: DisplayPanelView;\n /** Injected export — the host re-queries; the grid never fetches. */\n exportConfig?: DataViewExport;\n /** Page title in the grid's own header row, above the scopes + toolbar. */\n title?: string;\n /** Primary page actions rendered at the header row's right. */\n headerActions?: React.ReactNode;\n /** Which layout to show first when the user has expressed no preference (default \"table\"). */\n defaultLayout?: DataViewsLayout;\n /** Pin to `defaultLayout`, ignoring the remembered preference (stories/docs). */\n ignoreStoredLayout?: boolean;\n /**\n * Opt into the responsive inline filter UX: a collapsible filter row below the\n * toolbar on wide screens and a modal on narrow ones. When false (default),\n * keep the classic slide-in filter panel opened by the \"Filtros\" button.\n */\n inlineFilters?: boolean;\n /**\n * Keep the inline search box on screen even with no filter fields and no\n * active search. Without it a grid whose only filter IS the search (`fields`\n * empty) can never OFFER one: the row renders only once a search exists, so\n * the operator would have to hand-edit the URL to start one. Default false —\n * every grid that ships filter fields already shows the row.\n */\n alwaysShowSearch?: boolean;\n}\n\n/** The scrollable content region: scope tabs, toolbar, filter bar, body, pager. */\nfunction ShellStack<T extends Record<string, unknown>>({\n props,\n filters,\n}: {\n props: GridShellProps<T>;\n filters: ReturnType<typeof useGridShellFilters<T>>;\n}): React.JSX.Element {\n const copy = useDataViewsCopy();\n const { c, testIdPrefix, dataTestId, scopes = [], emptyState, inlineFilters = false } = props;\n const { showInline, useModal, inlineVisible, filterProps, split, onControlOpenChange } = filters;\n // The grid renders the FILTERED empty state itself — it is the only party\n // that knows a filter is applied. See {@link DataViewsEmpty}.\n const body = (\n <DataViewsEmpty\n filtered={c.activeFilterCount > 0 || c.state.search !== \"\"}\n onClearFilters={() => c.patch({ search: \"\", pills: {}, ranges: {} })}\n emptyState={emptyState}\n testIdPrefix={testIdPrefix}\n />\n );\n return (\n <TableFilter\n copy={copy.tableFilter} open={c.filterOpen} onOpenChange={c.setFilterOpen}\n hasActiveFilters={c.activeFilterCount > 0}\n >\n <Stack spacing={0} data-testid={dataTestId ? `${dataTestId}-container` : undefined}>\n <GridHeaderRow title={props.title} headerActions={props.headerActions} testIdPrefix={testIdPrefix} />\n <ShellToolbar\n c={c}\n rows={props.rows}\n sortKinds={props.sortKinds}\n displayView={props.displayView}\n exportConfig={props.exportConfig}\n filterControls={\n inlineVisible ? (\n <InlineFilterControls\n {...filterProps} split={split} activeFilterCount={c.activeFilterCount}\n onControlOpenChange={onControlOpenChange}\n />\n ) : undefined\n }\n barRef={split.barRef}\n testIdPrefix={testIdPrefix}\n rowActions={props.rowActions}\n bulkActions={props.bulkActions}\n selectionExtra={resolveSelectionExtra(props)}\n toolbarRightSlot={props.toolbarRightSlot}\n compactControls={showInline && split.compactControls}\n counterHidden={showInline && split.counterHidden}\n showInline={showInline}\n />\n <ScopeTabsSlot\n scopes={scopes} scopeFieldId={props.scopeFieldId} board={props.board}\n value={c.scope} onChange={c.setScope} counts={c.scopeCounts}\n testIdPrefix={testIdPrefix}\n />\n <TableFilter.Layout>\n <TableFilter.Main>\n <GridMain\n c={c}\n getRowId={props.getRowId}\n renderCard={props.renderCard}\n renderListRow={props.renderListRow}\n listGroup={props.listGroup}\n board={props.board}\n rowDetail={props.rowDetail}\n dataTestId={dataTestId}\n testIdPrefix={testIdPrefix}\n emptyState={body}\n />\n <DataViewsPagination c={c} testIdPrefix={testIdPrefix} />\n </TableFilter.Main>\n {inlineFilters ? null : <GridFilterPanel {...filterProps} />}\n </TableFilter.Layout>\n {useModal && <FilterDialog open={c.filterOpen} onClose={() => c.setFilterOpen(false)} {...filterProps} />}\n </Stack>\n </TableFilter>\n );\n}\n\nexport function GridShell<T extends Record<string, unknown>>(props: GridShellProps<T>): React.JSX.Element {\n const {\n c,\n fields,\n rangeFields,\n testIdPrefix,\n renderCard,\n renderListRow,\n board,\n defaultLayout,\n ignoreStoredLayout,\n inlineFilters = false,\n alwaysShowSearch = false,\n } = props;\n const filters = useGridShellFilters({\n c,\n inlineFilters,\n fields,\n rangeFields,\n testIdPrefix,\n alwaysShowSearch,\n hasExport: props.exportConfig !== undefined,\n });\n return (\n <DataViewsLayoutProvider\n canUseCards={Boolean(renderCard)}\n canUseList={Boolean(renderListRow)}\n // The board reuses the entity's card, so it needs BOTH — a `board` with no\n // `renderCard` offers no board rather than throwing.\n canUseBoard={Boolean(board && renderCard)}\n defaultLayout={defaultLayout}\n ignoreStoredLayout={ignoreStoredLayout}\n viewLayout={c.state.layout}\n >\n <LayoutStateSync c={c} />\n <ShellStack props={props} filters={filters} />\n </DataViewsLayoutProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,WAAW,gBAAgB;AA2PhC,cA4CM,YA5CN;AAtMJ,SAAS,gBAAmD;AAAA,EAC1D;AACF,GAES;AACP,QAAM,EAAE,OAAO,IAAI,mBAAmB;AACtC,QAAM,SAAS,EAAE,MAAM;AACvB,YAAU,MAAM;AACd,QAAI,WAAW,OAAQ,GAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EAE3C,GAAG,CAAC,QAAQ,MAAM,CAAC;AACnB,SAAO;AACT;AAoCA,SAAS,oBAAuD;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAOE;AACA,QAAM,EAAE,MAAM,IAAI;AAGlB,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,CAAC;AAIlD,QAAM,QAAQ;AAAA,IACZ,iBAAiB,QAAQ,WAAW;AAAA,IACpC,MAAM;AAAA,IACN,EAAE;AAAA,IACF,eAAe;AAAA,IACf;AAAA,EACF;AAUA,QAAM,aAAa;AACnB,QAAM,WAAW;AACjB,QAAM,gBACJ,eACC,oBAAoB,OAAO,SAAS,KAAK,YAAY,SAAS,KAAK,MAAM,WAAW;AACvF,QAAM,cAAqC;AAAA,IACzC;AAAA,IACA,QAAQ,MAAM;AAAA,IACd;AAAA,IACA;AAAA,IACA,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,WAAW,MAAM;AAAA,gBACjB,OAAO,MAAM;AAAA,gBACb,WAAW,MAAM;AAAA,gBACjB;AAAA,gBACA;AAAA,gBACA,YAAY;AAAA;AAAA,YACd;AAAA,YACA,oBAAC,uBAAoB,GAAM,cAA4B;AAAA,aACzD;AAAA,UACC,gBAAgB,OAAO,oBAAC,mBAAiB,GAAG,aAAa;AAAA,WAC5D;AAAA,QACC,YAAY,oBAAC,gBAAa,MAAM,EAAE,YAAY,SAAS,MAAM,EAAE,cAAc,KAAK,GAAI,GAAG,aAAa;AAAA,SACzG;AAAA;AAAA,EACF;AAEJ;AAEO,SAAS,UAA6C,OAA6C;AACxG,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB,mBAAmB;AAAA,EACrB,IAAI;AACJ,QAAM,UAAU,oBAAoB;AAAA,IAClC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,MAAM,iBAAiB;AAAA,EACpC,CAAC;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAa,QAAQ,UAAU;AAAA,MAC/B,YAAY,QAAQ,aAAa;AAAA,MAGjC,aAAa,QAAQ,SAAS,UAAU;AAAA,MACxC;AAAA,MACA;AAAA,MACA,YAAY,EAAE,MAAM;AAAA,MAEtB;AAAA,4BAAC,mBAAgB,GAAM;AAAA,QACvB,oBAAC,cAAW,OAAc,SAAkB;AAAA;AAAA;AAAA,EAC5C;AAEJ;","names":["default"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/data-display/DataViews/base-list-card-slots.tsx"],"sourcesContent":["\"use client\";\n\nimport { Fragment, type ReactNode } from \"react\";\n\nimport { DescriptionItem, type DescriptionItemProps } from \"../DescriptionItem\";\nimport { RAIL_GAP_PX } from \"./list-card-rails\";\nimport { Box } from \"../../../mui/Box\";\nimport { Text } from \"../../typography/Text\";\nimport type { Theme } from \"@mui/material/styles/index.js\";\n\nimport { rem, sxRem } from \"../../../tokens/relative\";\n\n/**\n * WHAT SITS IN EACH RAIL.\n *\n * Split from `base-list-card` at the size gate: that module is the shell, the\n * rails and the states; this is the content of each column.\n */\n\n/** Below this the row drops its middle columns. */\nexport const META_BREAK = 520;\n/** …and below this it leaves the shared rails and goes two-line. */\nexport const STACK_BREAK = 360;\n\n/** Money and dates line up only if their digits are the same width. */\nconst TABULAR = { fontVariantNumeric: \"tabular-nums\" } as const;\n\nconst CLAMP = {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n} as const;\n\n/**\n * Title over subtitle — and, when the row navigates, the anchor that covers it.\n *\n * The link is a real `<a>` stretched by `::after` over the whole card rather\n * than a click handler on a `<div>`. That buys cmd-click, middle-click, \"copy\n * link address\", the status bar preview and correct tab order, and it stops the\n * buttons elsewhere in the row from being interactive elements nested inside a\n * clickable one.\n */\nexport function ListCardCaption({\n title,\n subtitle,\n href,\n target,\n testId,\n}: {\n title?: ReactNode;\n subtitle?: ReactNode;\n href?: string;\n target?: string;\n testId?: string;\n}): React.JSX.Element {\n return (\n <Box data-slot=\"caption\" sx={{ minWidth: 0 }}>\n {title != null && (\n <Text variant=\"heading\" size=\"sm\" weight=\"bold\" as=\"p\">\n <Box\n {...(href ? { component: \"a\", href, target } : { component: \"span\" })}\n data-testid={testId}\n sx={{\n display: \"block\",\n lineHeight: 1.2,\n fontSize: sxRem(14.4),\n color: \"inherit\",\n textDecoration: \"none\",\n ...CLAMP,\n ...(href\n ? {\n \"&::after\": {\n content: '\"\"',\n position: \"absolute\",\n inset: 0,\n // Under the checkbox, drag grip, actions and menu, which\n // all raise themselves to 1.\n zIndex: 0,\n },\n \"&:hover\": { textDecoration: \"underline\" },\n }\n : {}),\n }}\n >\n {title}\n </Box>\n </Text>\n )}\n {subtitle != null && (\n <Text variant=\"caption\" size=\"xs\" color=\"secondary\" as=\"p\">\n <Box component=\"span\" sx={{ display: \"block\", ...CLAMP }}>\n {subtitle}\n </Box>\n </Text>\n )}\n </Box>\n );\n}\n\n/** One rule between two columns. Shared, so every gap gets the same mark. */\nfunction MetaRule(): React.JSX.Element {\n return (\n <Box\n aria-hidden\n sx={{\n flex: \"0 0 auto\",\n color: \"text.disabled\",\n opacity: 0.5,\n userSelect: \"none\",\n fontSize: sxRem(14),\n // A cancelled row strikes the whole meta cluster, and a struck `|` is a\n // dagger. The rule is punctuation, not data — nothing to void.\n textDecoration: \"none\",\n }}\n >\n |\n </Box>\n );\n}\n\n/**\n * The middle columns: stacked label-over-value pairs, separated by a rule.\n *\n * Stacked rather than side by side because `DATA 05/08/2026` inline spends the\n * horizontal room the value rail needs, and the separator is what stops two\n * adjacent pairs reading as one four-word phrase.\n *\n * EVEN GAPS, NOT EVEN BOXES. The rail takes a share of the row's spare width\n * per pair (see `metaRail`), and the obvious way to spend it — give every pair\n * an equal-width box and centre its content — puts the separator on the BOX\n * boundary, which is only the visual midpoint when both pairs are the same\n * width. They never are: `05/08/2026, 13:45` reaches almost to the edge of its\n * box while `PIX` stops well short of its own, so the rule ends up crowded\n * against the date and adrift from the method.\n *\n * So the pairs are sized to their content and the SPARE space is what gets\n * divided evenly. `space-evenly` gives every gap — including the two either\n * side of each separator — the same width, which puts each rule exactly halfway\n * between the two labels it separates, whatever they happen to say.\n */\nexport function ListCardMeta({\n meta,\n metaSlot,\n trailingRule,\n}: {\n meta?: DescriptionItemProps[];\n metaSlot?: ReactNode;\n /** Close the run with a rule, dividing the last pair from the value. */\n trailingRule?: boolean;\n}): React.JSX.Element {\n const items = meta ?? [];\n return (\n <Box\n data-slot=\"meta\"\n sx={(theme) => ({\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-evenly\",\n // A FLOOR, not the spacing itself: `space-evenly` supplies the rest, and\n // this is only what keeps a rail with no room to spare from running the\n // date straight into the rule.\n gap: 1,\n whiteSpace: \"nowrap\",\n ...TABULAR,\n // Rung 1 of the ladder.\n [`@container (max-width: ${rem(theme, META_BREAK)})`]: { display: \"none\" },\n })}\n >\n {items.map((item, index) => (\n <Fragment key={`${item.label}-${index}`}>\n {/* ITS OWN ITEM, not the first child of the pair that follows it.\n Nested inside, the rule travelled with that pair's centred content\n and came to rest nearer one label than the other — a separator\n visibly closer to MÉTODO than to DATA reads as belonging to it. */}\n {index > 0 && <MetaRule />}\n {/* Centred: a stacked pair sitting in its own column reads as one\n unit only when the label is over the value rather than flush left\n of a value shorter than it — `MÉTODO` above `PIX` was visibly\n unhinged from it. Overridable per item. */}\n <Box\n sx={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n minWidth: 0,\n // Sized to the pair, so the gaps either side of it are free space\n // that `space-evenly` can equalise.\n flex: \"0 0 auto\",\n }}\n >\n <DescriptionItem orientation=\"vertical\" align=\"center\" {...item} />\n </Box>\n </Fragment>\n ))}\n {metaSlot}\n {trailingRule && items.length > 0 && <MetaRule />}\n </Box>\n );\n}\n\n/**\n * The value sits flush against the meta rail, with no gap of its own.\n *\n * Its divider is now the LAST ITEM OF THE META CLUSTER, placed by the same\n * `space-evenly` that places the rules between the pairs — so it is equidistant\n * from `PIX` and from `R$ 13,90` for free, which a rule centred in the rail gap\n * could never be: the cluster's content stops well short of the rail's right\n * edge, leaving that rule 150px from the method and 12px from the money.\n *\n * Cancelling this one gap is what makes the two distances equal. Below\n * `META_BREAK` the cluster (and its rule) are gone, so the gap comes back —\n * otherwise the value would sit straight against the title.\n */\nconst valueFlush = (theme: Theme) => ({\n marginLeft: rem(theme, -RAIL_GAP_PX),\n [`@container (max-width: ${rem(theme, META_BREAK)})`]: { marginLeft: 0 },\n});\n\n/** The value, on its own rail, never truncated and never shunted by the chip. */\nfunction ListCardValue({ value }: { value: ReactNode }): React.JSX.Element {\n return (\n <Text variant=\"body\" size=\"sm\" weight=\"medium\" as=\"span\">\n <Box\n component=\"span\"\n sx={{ fontSize: sxRem(14), whiteSpace: \"nowrap\", ...TABULAR }}\n >\n {value}\n </Box>\n </Text>\n );\n}\n\n/**\n * The actions and the menu, at the end of the row.\n *\n * Actions are revealed on hover and `:focus-within` — always-visible buttons on\n * every row of fifty is a lot of chrome for something used on one of them.\n * `:focus-within` is what keeps them reachable by keyboard, and `visibility`\n * rather than `display` keeps their space reserved so nothing shifts.\n */\nexport function ListCardActions({\n actions,\n alwaysVisible,\n menu,\n testId,\n}: {\n actions?: ReactNode;\n alwaysVisible?: boolean;\n menu?: ReactNode;\n testId: (slot: string) => string | undefined;\n}): React.JSX.Element | null {\n if (actions == null && menu == null) return null;\n return (\n // z-index 1: above the stretched link, so these stay clickable.\n <Box\n data-slot=\"actions\"\n sx={{ display: \"flex\", alignItems: \"center\", gap: 0.5, position: \"relative\", zIndex: 1 }}\n >\n {actions && (\n <Box\n data-testid={testId(\"actions\")}\n onClick={(event) => event.stopPropagation()}\n sx={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 0.5,\n ...(alwaysVisible\n ? {}\n : {\n visibility: \"hidden\",\n \".MuiPaper-root:hover &, .MuiPaper-root:focus-within &\": {\n visibility: \"visible\",\n },\n }),\n }}\n >\n {actions}\n </Box>\n )}\n {menu && (\n <Box data-testid={testId(\"menu\")} onClick={(event) => event.stopPropagation()}>\n {menu}\n </Box>\n )}\n </Box>\n );\n}\n\n/** Value and actions — separate rails, not one flex run. */\nexport function ListCardTail({\n value,\n separated,\n actions,\n actionsAlwaysVisible,\n menu,\n testId,\n}: {\n value?: ReactNode;\n /** Whether a meta cluster precedes the value and wants dividing from it. */\n separated?: boolean;\n actions?: ReactNode;\n actionsAlwaysVisible?: boolean;\n menu?: ReactNode;\n testId: (slot: string) => string | undefined;\n}): React.JSX.Element {\n return (\n <>\n <Box\n data-slot=\"value\"\n sx={(theme) => ({\n textAlign: \"right\",\n ...(separated && value != null ? valueFlush(theme) : {}),\n })}\n data-testid={testId(\"value\")}\n >\n {value != null && <ListCardValue value={value} />}\n </Box>\n <ListCardActions\n actions={actions}\n alwaysVisible={actionsAlwaysVisible}\n menu={menu}\n testId={testId}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAEA,SAAS,gBAAgC;AAsDrC,SA0PA,YAAAA,WAvPM,KAHN;AApCG,IAAM,aAAa;AAEnB,IAAM,cAAc;AAG3B,IAAM,UAAU,EAAE,oBAAoB,eAAe;AAErD,IAAM,QAAQ;AAAA,EACZ,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AACd;AAWO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMsB;AACpB,SACE,qBAACC,UAAA,EAAI,aAAU,WAAU,IAAI,EAAE,UAAU,EAAE,GACxC;AAAA,aAAS,QACR,oBAAC,QAAK,SAAQ,WAAU,MAAK,MAAK,QAAO,QAAO,IAAG,KACjD;AAAA,MAACA;AAAA,MAAA;AAAA,QACE,GAAI,OAAO,EAAE,WAAW,KAAK,MAAM,OAAO,IAAI,EAAE,WAAW,OAAO;AAAA,QACnE,eAAa;AAAA,QACb,IAAI;AAAA,UACF,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,UAAU,MAAM,IAAI;AAAA,UACpB,OAAO;AAAA,UACP,gBAAgB;AAAA,UAChB,GAAG;AAAA,UACH,GAAI,OACA;AAAA,YACE,YAAY;AAAA,cACV,SAAS;AAAA,cACT,UAAU;AAAA,cACV,OAAO;AAAA;AAAA;AAAA,cAGP,QAAQ;AAAA,YACV;AAAA,YACA,WAAW,EAAE,gBAAgB,YAAY;AAAA,UAC3C,IACA,CAAC;AAAA,QACP;AAAA,QAEC;AAAA;AAAA,IACH,GACF;AAAA,IAED,YAAY,QACX,oBAAC,QAAK,SAAQ,WAAU,MAAK,MAAK,OAAM,aAAY,IAAG,KACrD,8BAACA,UAAA,EAAI,WAAU,QAAO,IAAI,EAAE,SAAS,SAAS,GAAG,MAAM,GACpD,oBACH,GACF;A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AAAA,EACA;AACF,GAQsB;AACpB,SACE,qBAAAD,WAAA,EACE;AAAA;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,aAAU;AAAA,QACV,IAAI,CAAC,WAAW;AAAA,UACd,WAAW;AAAA,UACX,GAAI,aAAa,SAAS,OAAO,WAAW,KAAK,IAAI,CAAC;AAAA,QACxD;AAAA,QACA,eAAa,OAAO,OAAO;AAAA,QAE1B,mBAAS,QAAQ,oBAAC,iBAAc,OAAc;AAAA;AAAA,IACjD;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,eAAe;AAAA,QACf;AAAA,QACA;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":["Fragment","default"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/data-display/DataViews/data-views-shell-toolbar.tsx"],"sourcesContent":["\"use client\";\n\n/**\n * The toolbar band, fed from the controller — ~25 props of pure forwarding and\n * nothing else, which is why it lives in its own file rather than in the shell.\n */\nimport { type ColumnVisibilityOption } from \"../../layout/ContentToolbar\";\n\nimport type { DisplayPanelView } from \"./data-views-display-panel\";\nimport type { DataViewExport } from \"./data-views-export\";\nimport { GridToolbar } from \"./data-views-toolbar\";\nimport type { RowAction } from \"./data-views-types\";\nimport type { DataViewsController } from \"./use-data-views-state\";\n\n/**\n * The toolbar band, fed from the controller. Split out of `GridShell` for that\n * function's size budget — it is ~25 props of pure forwarding and nothing else.\n */\nexport function ShellToolbar<T extends Record<string, unknown>>({\n c,\n rows,\n testIdPrefix,\n rowActions,\n bulkActions,\n selectionExtra,\n toolbarRightSlot,\n showInline,\n compactControls,\n counterHidden,\n sortKinds,\n displayView,\n exportConfig,\n filterControls,\n barRef,\n}: {\n c: DataViewsController<T>;\n rows: T[];\n testIdPrefix: string;\n sortKinds?: Record<string, string>;\n displayView?: DisplayPanelView;\n exportConfig?: DataViewExport;\n rowActions?: RowAction<T>[];\n bulkActions?: (selectedRows: T[], clearSelection: () => void) => React.ReactNode;\n /** Already resolved by the shell, which is the party that knows the page. */\n selectionExtra?: React.ReactNode;\n toolbarRightSlot?: React.ReactNode;\n /** Search + filters, rendered on the toolbar line (see `GridToolbar`). */\n filterControls?: React.ReactNode;\n barRef?: React.Ref<HTMLDivElement>;\n showInline: boolean;\n /** Step 2 of the ladder: Exibir/Exportar as icons only. */\n compactControls?: boolean;\n /** Step 5, last resort: drop the counter so the row still fits one line. */\n counterHidden?: boolean;\n}): React.JSX.Element {\n const columnOptions: ColumnVisibilityOption[] = c.hideableColumns.map((col) => ({\n id: col.id,\n label: col.label,\n visible: c.state.visibleColumns.includes(col.id),\n }));\n return (\n <GridToolbar\n c={c}\n sortKinds={sortKinds}\n displayView={displayView}\n exportConfig={exportConfig}\n filterControls={filterControls}\n barRef={barRef}\n compactControls={compactControls}\n counterHidden={counterHidden}\n testIdPrefix={testIdPrefix}\n selectedRows={c.selectedRows}\n selectAll={c.selectAll}\n clearSelection={c.clearSelection}\n rowActions={rowActions}\n bulkActions={bulkActions}\n selectionExtra={selectionExtra}\n sortFields={c.resolvedSortFields}\n activeSortField={c.activeSortField}\n activeSortOrder={c.activeSortOrder}\n onChangeSort={(field, order) => c.patch({ sortBy: [{ id: field, dir: order }] })}\n matchedCount={c.matched.length}\n totalCount={c.serverMode ? c.serverTotalCount : rows.length}\n toolbarRightSlot={toolbarRightSlot}\n columnOptions={columnOptions}\n onToggleColumn={c.toggleColumn}\n filterOpen={c.filterOpen}\n setFilterOpen={c.setFilterOpen}\n activeFilterCount={c.activeFilterCount}\n showFilterTrigger={!showInline}\n />\n );\n}\n\n/** Wires the controller into the shared toolbar + filter panel + grid/cards body. */\n"],"mappings":";;;;;AA6DI;AA3CG,SAAS,aAAgD;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAoBsB;AACpB,QAAM,gBAA0C,EAAE,gBAAgB,IAAI,CAAC,SAAS;AAAA,IAC9E,IAAI,IAAI;AAAA,IACR,OAAO,IAAI;AAAA,IACX,SAAS,EAAE,MAAM,eAAe,SAAS,IAAI,EAAE;AAAA,EACjD,EAAE;AACF,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc,EAAE;AAAA,MAChB,WAAW,EAAE;AAAA,MACb,gBAAgB,EAAE;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA,YAAY,EAAE;AAAA,MACd,iBAAiB,EAAE;AAAA,MACnB,iBAAiB,EAAE;AAAA,MACnB,cAAc,CAAC,OAAO,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,IAAI,OAAO,KAAK,MAAM,CAAC,EAAE,CAAC;AAAA,MAC/E,cAAc,EAAE,QAAQ;AAAA,MACxB,YAAY,EAAE,aAAa,EAAE,mBAAmB,KAAK;AAAA,MACrD;AAAA,MACA;AAAA,MACA,gBAAgB,EAAE;AAAA,MAClB,YAAY,EAAE;AAAA,MACd,eAAe,EAAE;AAAA,MACjB,mBAAmB,EAAE;AAAA,MACrB,mBAAmB,CAAC;AAAA;AAAA,EACtB;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/data-display/DataViews/DataViewsTableBase.tsx"],"sourcesContent":["\"use client\";\n\nimport type { SortFieldDefinition } from \"../../layout/ContentToolbar\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { DataViewsGrid } from \"./DataViewsGrid\";\nimport type { SelectionExtraRender } from \"./data-views-selection-extra\";\nimport type { ListGroupConfig } from \"./list-card-rails\";\nimport type { DisplayPanelView } from \"./data-views-display-panel\";\nimport { viewStateKey } from \"./data-views-dirty\";\nimport { DeleteViewDialog } from \"./DeleteViewDialog\";\nimport type { BoardConfig } from \"./DataViewsBoard\";\nimport type { DataViewExport } from \"./data-views-export\";\nimport type { ScopeConfig } from \"./data-views-scopes\";\nimport type { DataViewRowDetail } from \"./data-views-row-detail\";\nimport { ViewDialogs, ViewMutationErrorAlert } from \"./data-views-table-parts\";\nimport {\n useSavedViewsController,\n type SavedViewsController,\n} from \"./use-saved-views-controller\";\nimport {\n type DataViewColumn,\n type DataViewsLayout,\n type DataViewServer,\n type DataViewState,\n type DataViewSyncState,\n type DataViewPersistence,\n type DataViewRouter,\n type FilterFieldConfig,\n type RangeFieldConfig,\n type DataViewCardSelection,\n type RowAction,\n type SavedViewSummary,\n} from \"./data-views-types\";\n\nexport interface DataViewsTableBaseProps<T extends Record<string, unknown>> {\n /** The applied-view id read from the URL (`?view=`) on load, or null. */\n initialViewId?: string | null;\n /** Injected saved-view persistence (create/update/delete). */\n persistence: DataViewPersistence;\n /** Injected router side-effects (URL sync + refresh). */\n router: DataViewRouter;\n rows: T[];\n columns: DataViewColumn<T>[];\n fields: FilterFieldConfig<T>[];\n /** Optional numeric min/max range filters (advanced \"filter by amount\"). */\n rangeFields?: RangeFieldConfig<T>[];\n getRowId: (row: T) => string | number;\n onRowClick?: (row: T) => void;\n emptyState?: React.ReactNode;\n dataTestId?: string;\n testIdPrefix?: string;\n /** The user's + shared views for this table (from the server). */\n views: SavedViewSummary[];\n /** Big page title in the table header, beside the funnel + gear (GTA layout). */\n title?: string;\n /** Primary page actions (e.g. \"Novo produto\") rendered at the header's right. */\n headerActions?: React.ReactNode;\n /** Sort options for the toolbar's \"Sort By\" dropdown (defaults to sortable columns). */\n sortFields?: SortFieldDefinition[];\n /**\n * Per-sort-field VALUE KIND (`\"currency\" | \"number\" | \"date\" | \"text\"`), so the\n * Exibir panel phrases the direction in that column's own terms. \"Crescente\"\n * on a currency column is a puzzle; \"Menor → maior\" is not. Defaults to text.\n */\n sortKinds?: Record<string, string>;\n /**\n * Opt-in \"Exportar\" control. The grid hands the host the current query,\n * UNPAGINATED, and the host re-queries — the grid never fetches, and an\n * export therefore follows the filters rather than the loaded page.\n */\n exportConfig?: DataViewExport;\n /** Notified with the currently-visible (filtered) rows, so Export matches the view. */\n onVisibleRowsChange?: (rows: T[]) => void;\n /** Reusable row actions driving both the row \"⋮\" kebab and the bulk menu. */\n rowActions?: RowAction<T>[];\n /** Leading control in the auto kebab column (e.g. a favourite star). */\n rowActionsLeading?: (row: T) => React.ReactNode;\n /** Low-level bulk-action override; prefer `rowActions`. */\n bulkActions?: (selectedRows: T[], clearSelection: () => void) => React.ReactNode;\n /** A selection-widening control beside the count (e.g. \"select all matching\"). */\n selectionExtra?: SelectionExtraRender<T>;\n /** Bespoke per-row menu (an entity's self-contained 3-dots menu) instead of the auto kebab. */\n renderRowMenu?: (row: T) => React.ReactNode;\n /** Opt-in expandable rows (table layout only) — see {@link DataViewRowDetail}. */\n rowDetail?: DataViewRowDetail<T>;\n /** Opt-in \"Grade\" (cards) layout — a card renderer per row; adds a Grade/Tabela toggle. */\n renderCard?: (row: T, selection: DataViewCardSelection) => React.ReactNode;\n /** Opt-in \"Quadro\" (board) layout — the loaded page as columns of one field. Needs `renderCard`. */\n board?: BoardConfig<T>;\n /** Opt-in \"Lista\" layout — one full-width, entity-rendered row per record (FUT-733). */\n renderListRow?: (row: T, selection: DataViewCardSelection) => React.ReactNode;\n /** The Lista's shared columns, so its rows line up by construction not convention. */\n listGroup?: ListGroupConfig<T>;\n /** The page-level partition rendered as tabs under the toolbar (server mode only). */\n scopes?: ScopeConfig[];\n /** The row field the scopes partition by — used only to reject a pill over the same field. */\n scopeFieldId?: string;\n /** Which layout to show first when the user has expressed no preference (default \"table\"). */\n defaultLayout?: DataViewsLayout;\n /**\n * Ignore the remembered cross-screen layout preference and pin to\n * `defaultLayout`. For tables that exist to SHOW a layout — stories, docs,\n * screenshots — not for real screens.\n */\n ignoreStoredLayout?: boolean;\n /** Opt into the responsive inline filter UX (collapsible row / modal). Default keeps the panel. */\n inlineFilters?: boolean;\n /** Keep the inline search visible with no filter fields and no active search. */\n alwaysShowSearch?: boolean;\n /** Server-mode wiring (FUT-180): backend-driven rows/total + re-fetch. Omit for client mode. */\n server?: DataViewServer;\n /** Seed the initial view state (search/pills/ranges/sort) from the URL when no saved view applies. */\n initialState?: DataViewState;\n}\n\n/**\n * Derive the grid's reactive `syncState` from the URL-seeded `initialState` in\n * server mode so browser back/forward RE-APPLIES the search/pills/sort controls\n * (merging over live state, preserving hidden columns — see {@link DataViewSyncState}).\n * Client-mode tables (no `server`) get `undefined`. Callers memoize `initialState`\n * on the URL, so this reference only changes on genuine navigations.\n */\nfunction useUrlSyncState(\n server: DataViewServer | undefined,\n initialState: DataViewState | undefined,\n): DataViewSyncState | undefined {\n const isServerMode = server !== undefined;\n return useMemo<DataViewSyncState | undefined>(\n () =>\n isServerMode && initialState\n ? {\n search: initialState.search,\n pills: initialState.pills,\n ranges: initialState.ranges,\n sortBy: initialState.sortBy,\n // The scope belongs in the URL-driven slice alongside them: a\n // `?view=recusados`-style deep link and browser back/forward must\n // move the tab strip, and they must do it WITHOUT resetting the\n // user's hidden columns — which is the whole reason this is a\n // merging `syncState` and not a replacing `appliedState`.\n scope: initialState.scope,\n }\n : undefined,\n [isServerMode, initialState],\n );\n}\n\n/**\n * Resolve the initial applied view: a `?view=<id>` shortcut (FUT-90) wins, else\n * the user's default view, else none. Drives the seed state + trigger label.\n */\nfunction resolveInitialView(\n views: SavedViewSummary[],\n requestedId: string | null,\n): SavedViewSummary | undefined {\n const requested = requestedId ? views.find((view) => view.id === requestedId) : undefined;\n return requested ?? views.find((view) => view.isDefault);\n}\n\n/**\n * The Exibir panel's view chrome, assembled from the saved-views controller.\n * Extracted so {@link DataViewsTableBase} stays inside its size budget.\n */\nfunction buildDisplayView({\n ctl,\n views,\n activeView,\n dirty,\n onRequestDelete,\n}: {\n ctl: SavedViewsController;\n views: SavedViewSummary[];\n activeView: SavedViewSummary | undefined;\n dirty: boolean;\n /** Opens the confirmation; the delete itself happens on confirm. */\n onRequestDelete: (view: SavedViewSummary) => void;\n}): DisplayPanelView {\n return {\n activeViewName: ctl.activeViewName,\n dirty,\n onReset: () => (activeView ? ctl.applyView(activeView) : ctl.selectMain()),\n // Only offer \"Atualizar\" when there IS a view to update — otherwise the\n // single footer button is a plain \"Salvar visão\".\n onUpdate: activeView ? () => ctl.openEdit(activeView) : undefined,\n onSaveAs: ctl.openCreate,\n // The views themselves, not a dropdown: the panel renders them in its own\n // body (see `data-views-view-nav`), so there is no second popover to clip\n // the row actions.\n nav: {\n views,\n activeViewId: activeView?.id ?? null,\n onSelectView: (id) => {\n const next = id === null ? null : views.find((view) => view.id === id);\n if (next) ctl.applyView(next);\n else ctl.selectMain();\n },\n onEditView: ctl.openEdit,\n onPatchView: (view, changes) => void ctl.patchView(view, changes),\n onDeleteView: onRequestDelete,\n },\n };\n}\n\n/**\n * \"Are there unsaved changes?\" — the dot on Exibir, and whether Redefinir and\n * Salvar visão are live.\n *\n * Two things it gets right that the inline version did not. It compares\n * NORMALISED states (`viewStateKey`), so a filter applied and then removed is\n * clean again rather than clean-looking but flagged; and it re-baselines after\n * a SAVE, because the state just written is the clean one from that point.\n *\n * The baseline is the first state the grid emits for a view, not the view\n * itself: the grid normalises what it is handed — resolving visible columns,\n * filling in layout — so the applied view is never byte-identical to the state\n * it produces.\n */\nfunction useDirtyTracking(ctl: SavedViewsController): {\n dirty: boolean;\n noteState: (state: DataViewState) => void;\n markSaved: () => void;\n} {\n const [dirty, setDirty] = useState(false);\n const [savedAt, setSavedAt] = useState(0);\n const baseline = useRef<string | null>(null);\n const appliedKey = JSON.stringify(ctl.applied ?? null);\n\n useEffect(() => {\n baseline.current = null;\n setDirty(false);\n }, [appliedKey, savedAt]);\n\n return {\n dirty,\n noteState: (state) => {\n ctl.currentRef.current = state;\n const key = viewStateKey(state);\n if (baseline.current === null) {\n baseline.current = key;\n setDirty(false);\n return;\n }\n const next = key !== baseline.current;\n setDirty((prev) => (prev === next ? prev : next));\n },\n markSaved: () => setSavedAt((tick) => tick + 1),\n };\n}\n\n/**\n * The reusable admin table (FUT-89): the DataViews grid plus the full saved-views\n * experience — a views dropdown, a save/edit modal (with preview), and a manage\n * dialog. Framework-agnostic: saved-view persistence and router side-effects are\n * INJECTED (`persistence`, `router`, `initialViewId`) so the host app wires them\n * to its backend + framework router. A default view auto-applies on load; applying\n * a view restores its filters + columns + sort. Each table supplies its own columns\n * + filter fields; everything else is shared.\n */\nexport function DataViewsTableBase<T extends Record<string, unknown>>(\n props: DataViewsTableBaseProps<T>,\n): React.JSX.Element {\n // Forwarded as a whole rather than restated name-by-name twice (as in\n // DataViewsGrid): this component only ADDS the saved-views chrome, and a\n // 30-name destructure repeated in the JSX is exactly where a newly added prop\n // silently stops being passed on.\n const {\n initialViewId = null,\n persistence,\n router,\n columns,\n fields,\n testIdPrefix = \"table\",\n views,\n server,\n initialState,\n } = props;\n const initialView = resolveInitialView(views, initialViewId);\n const columnIds = columns.map((col) => col.id);\n const ctl = useSavedViewsController(persistence, router, columnIds, views, initialView, initialState);\n // Unsaved-changes flag for the Exibir panel. Set from `onStateChange` rather\n // than derived in render because the live state lives in a REF (the grid owns\n // it); the equality bail-out in `setDirty` is what stops the update loop.\n const { dirty, noteState, markSaved } = useDirtyTracking(ctl);\n // Deleting a saved view is confirmed, not immediate — see `DeleteViewDialog`.\n const [pendingDelete, setPendingDelete] = useState<SavedViewSummary | null>(null);\n // The view the panel's \"Redefinir\" restores: the applied one, or the built-in\n // \"Visão principal\" when none is.\n const activeView = views.find((view) => view.name === ctl.activeViewName);\n const displayView = buildDisplayView({\n ctl,\n views,\n activeView,\n dirty,\n onRequestDelete: setPendingDelete,\n });\n // Server-mode lists re-apply URL-derived controls on back/forward (not just the mount seed).\n const syncState = useUrlSyncState(server, initialState);\n\n return (\n <>\n <ViewMutationErrorAlert error={ctl.mutationError} onClose={ctl.clearMutationError} testIdPrefix={testIdPrefix} />\n <DataViewsGrid<T>\n {...props}\n testIdPrefix={testIdPrefix}\n appliedState={ctl.applied}\n syncState={syncState}\n onStateChange={noteState}\n // The saved-views menu is NOT a toolbar control any more: it lives in\n // the Exibir panel's VISÃO header, passed through `displayView`.\n displayView={displayView}\n />\n {renderViewDialogs(ctl, fields, columns, views, testIdPrefix, markSaved)}\n <DeleteViewDialog\n view={pendingDelete}\n onClose={() => setPendingDelete(null)}\n onConfirm={(view) => {\n void ctl.handleDelete(view);\n setPendingDelete(null);\n }}\n testIdPrefix={testIdPrefix}\n />\n </>\n );\n}\n\n/** The save + manage saved-view dialogs, split out to keep the base thin. */\nfunction renderViewDialogs<T extends Record<string, unknown>>(\n ctl: SavedViewsController,\n fields: DataViewsTableBaseProps<T>[\"fields\"],\n columns: DataViewsTableBaseProps<T>[\"columns\"],\n views: SavedViewSummary[],\n testIdPrefix: string,\n onSaved: () => void,\n): React.JSX.Element {\n return (\n <ViewDialogs<T>\n saveOpen={ctl.saveOpen}\n onCloseSave={ctl.closeSave}\n currentState={ctl.editing ? ctl.editing.state : ctl.currentRef.current}\n fields={fields}\n columns={columns}\n editing={ctl.editing}\n onSave={async (payload) => {\n await ctl.handleSave(payload);\n // The saved state is the clean one from here on.\n onSaved();\n }}\n manageOpen={ctl.manageOpen}\n onCloseManage={() => ctl.setManageOpen(false)}\n views={views}\n onEditFromManage={ctl.editFromManage}\n onDelete={(view) => void ctl.handleDelete(view)}\n testIdPrefix={testIdPrefix}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAGA,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AAySjD,mBACE,KADF;AAjLJ,SAAS,gBACP,QACA,cAC+B;AAC/B,QAAM,eAAe,WAAW;AAChC,SAAO;AAAA,IACL,MACE,gBAAgB,eACZ;AAAA,MACE,QAAQ,aAAa;AAAA,MACrB,OAAO,aAAa;AAAA,MACpB,QAAQ,aAAa;AAAA,MACrB,QAAQ,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMrB,OAA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,kBAAkB,KAAK,QAAQ,SAAS,OAAO,cAAc,SAAS;AAAA,IACvE;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,SAAS,MAAM,iBAAiB,IAAI;AAAA,QACpC,WAAW,CAAC,SAAS;AACnB,eAAK,IAAI,aAAa,IAAI;AAC1B,2BAAiB,IAAI;AAAA,QACvB;AAAA,QACA;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;AAGA,SAAS,kBACP,KACA,QACA,SACA,OACA,cACA,SACmB;AACnB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU,IAAI;AAAA,MACd,aAAa,IAAI;AAAA,MACjB,cAAc,IAAI,UAAU,IAAI,QAAQ,QAAQ,IAAI,WAAW;AAAA,MAC/D;AAAA,MACA;AAAA,MACA,SAAS,IAAI;AAAA,MACb,QAAQ,OAAO,YAAY;AACzB,cAAM,IAAI,WAAW,OAAO;AAE5B,gBAAQ;AAAA,MACV;AAAA,MACA,YAAY,IAAI;AAAA,MAChB,eAAe,MAAM,IAAI,cAAc,KAAK;AAAA,MAC5C;AAAA,MACA,kBAAkB,IAAI;AAAA,MACtB,UAAU,CAAC,SAAS,KAAK,IAAI,aAAa,IAAI;AAAA,MAC9C;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/data-display/DataViews/base-list-card-geometry.tsx"],"sourcesContent":["\"use client\";\n\nimport { useTheme, type Theme } from \"@mui/material/styles/index.js\";\n\nimport {\n CARD_RADIUS,\n cardSurfaceStyles,\n isActionable,\n isSelectable,\n slotTestIds,\n} from \"./card-surface\";\nimport { useDragItem } from \"./data-views-drag\";\nimport { DENSITY_ROW_PADDING } from \"./data-views-layout-context\";\nimport { RAIL_COUNT, RAIL_GAP, railsTemplateFor, useListRails } from \"./list-card-rails\";\nimport { STACK_BREAK } from \"./base-list-card-slots\";\nimport type { BaseListCardProps } from \"./base-list-card\";\nimport { rem } from \"../../../tokens/relative\";\n\n/**\n * THE ROW'S GEOMETRY AND SURFACE, split from the component at the size gate.\n *\n * Everything here answers \"what shape is this row, and where do its slots land\"\n * — the rails, the density padding, the two-line collapse, the drag and\n * selection plumbing. None of it renders anything, which is why the two halves\n * can live apart without either becoming harder to follow.\n */\n/**\n * Whether a click was really a click, or the tail of a text selection.\n *\n * Without this, selecting an order id to copy it navigates away instead — the\n * single most annoying thing a clickable row does.\n */\nfunction isTextSelection(): boolean {\n return (globalThis.getSelection?.()?.toString().length ?? 0) > 0;\n}\n\n/** Keyboard equivalence for a card that acts but does not navigate. */\nfunction clickKeys(onClick: () => void) {\n return (event: React.KeyboardEvent): void => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n onClick();\n };\n}\n\n/**\n * Geometry: the rails, the density padding, the two-line collapse.\n *\n * SCALE IS `zoom`, NOT A SET OF MULTIPLIED FONT SIZES.\n *\n * It used to be the latter, on exactly three values — title, value, row padding\n * — so the slider left the subtitle, the meta labels, the rules, the checkbox,\n * the grip, the chip and the menu at their fixed sizes, and the row came apart\n * as you dragged it. Multiplying the rest is not a fix: the checkbox and the\n * chip are MUI internals sized in their own px, and no prop we pass reaches\n * them.\n *\n * `zoom` scales the used value of every length in the subtree — ours and theirs\n * — and unlike `transform: scale` it REFLOWS, so the row still occupies the\n * space it draws and the rails still resolve. Verified against the group: at\n * 1.4 all four rows keep identical rail edges, because subgrid tracks and the\n * zoom that reads them are the same for every row.\n */\n/** What {@link rowSx} needs to know about the row it lays out. */\ninterface RowSxOptions {\n inGroup: boolean;\n railCount: number;\n cellTemplate: string | null;\n gutters: { disclose: boolean; drag: boolean; select: boolean };\n metaColumns: number;\n pad: number;\n padY: number;\n scale: number;\n divider: boolean;\n interactive: boolean;\n draggable: boolean;\n}\n\n/**\n * DIVIDER COMPOSES WITH THE VARIANT — it changes the row's SHAPE, not its\n * surface.\n *\n * It used to set `border: 0` and hard-code its own rule colour, which discarded\n * whatever the variant had drawn: `outline`, `text` and `ghost` all collapsed\n * to one identical flush row, and the variant control silently stopped meaning\n * anything the moment `divider` was on.\n *\n * Now only the GEOMETRY changes here — the box's sides go, one edge stays — and\n * no `borderColor` is written, so the colour set by `cardSurfaceStyles` survives.\n * A variant that draws no border of its own gets the neutral rule from\n * {@link rowStyles}.\n */\nexport const rowSx = (theme: Theme, opts: RowSxOptions): Record<string, unknown> => {\n const { inGroup, railCount, cellTemplate, gutters, metaColumns, pad, padY, scale, divider, interactive, draggable } = opts;\n return {\n position: \"relative\",\n borderRadius: CARD_RADIUS,\n display: \"grid\",\n zoom: scale,\n // SUBGRID AND `container-type` CANNOT COEXIST on one element: containment\n // makes the box size independently of its parent, so the browser drops the\n // subgrid and every slot stacks into one column. (Observed exactly that —\n // computed `grid-template-columns: 1222px` on a card asking for subgrid.)\n //\n // So inside a group the GROUP is the query container and the row is the\n // subgrid; standalone, the row is both the container and its own grid.\n ...(inGroup\n ? { gridColumn: `span ${railCount}`, gridTemplateColumns: \"subgrid\" }\n : {\n containerType: \"inline-size\",\n gridTemplateColumns: cellTemplate ?? railsTemplateFor(gutters, metaColumns),\n }),\n alignItems: \"center\",\n // Wide enough that the meta cluster, the value and the status read as three\n // columns rather than one run of text — the complaint that started all this\n // was `MÉTODO PIX R$ 13,90` scanning as a single phrase.\n columnGap: RAIL_GAP,\n width: \"100%\",\n px: pad,\n py: padY,\n cursor: draggable ? \"grab\" : interactive ? \"pointer\" : undefined,\n ...(draggable ? { touchAction: \"none\", \"&:active\": { cursor: \"grabbing\" } } : {}),\n ...(interactive ? { \"&:hover\": { backgroundColor: \"action.hover\" } } : {}),\n // A real focus ring, which a clickable <div> never had.\n \"&:focus-visible\": {\n outline: `${rem(theme, 2)} solid`,\n outlineStyle: \"solid\",\n outlineColor: \"primary.main\",\n outlineOffset: rem(theme, 2),\n },\n // TWO-LINE, below the point where the shared rails stop helping.\n //\n // The standard mobile transaction row: what the record IS and what it COST\n // on the first line, the supporting detail on the second. Better than\n // truncating four columns into ellipses, and the reason each slot carries a\n // `data-slot` — the placement is explicit rather than whatever order the\n // children happen to be in.\n //\n // [ select ][ leading ][ title …………… ][ menu ]\n // [ (cells) …………… ][ value ]\n //\n // The MENU stays in the top-right corner at every width. It is the row's\n // one fixed landmark — an overflow that moves to the second line on a phone\n // is an overflow nobody finds twice.\n [`@container (max-width: ${rem(theme, STACK_BREAK)})`]: {\n gridTemplateColumns: \"auto auto minmax(0, 1fr) max-content\",\n ...(inGroup ? { gridColumn: `span ${RAIL_COUNT}` } : {}),\n rowGap: 0.75,\n columnGap: 1,\n '& > [data-slot=\"drag\"]': { display: \"none\" },\n '& > [data-slot=\"select\"]': { gridArea: \"1 / 1\" },\n '& > [data-slot=\"leading\"]': { gridArea: \"1 / 2\" },\n '& > [data-slot=\"caption\"]': { gridArea: \"1 / 3\" },\n '& > [data-slot=\"actions\"]': { gridArea: \"1 / 4\", justifyContent: \"flex-end\" },\n '& > [data-slot=\"meta\"]': { display: \"none\" },\n // Second line, starting under the title rather than under the checkbox.\n '& > [data-slot=\"value\"]': { gridArea: \"2 / 4\", textAlign: \"right\" },\n },\n ...(divider\n ? { borderRadius: 0, borderWidth: 0, borderBottomWidth: 1, borderStyle: \"solid\" }\n : {}),\n };\n};\n\n/**\n * A selectable full-width row: a marker, a title over a subtitle, labelled\n * middle columns, a value, a status, actions and a menu.\n *\n * A SHELL, like {@link BaseCard}. Domain rows live in the app and compose it.\n */\n/**\n * The id this row drags under, or nothing.\n *\n * `undefined` is the inert answer: `useDragItem` treats a missing id as \"no\n * drag\", which is how the card's own veto (`draggable={false}`) and an\n * unactionable record both switch dragging off without the card knowing\n * anything about the container above it.\n */\nfunction dragIdFor(\n props: BaseListCardProps,\n actionable: boolean,\n): string | number | undefined {\n return props.draggable === false || !actionable ? undefined : props.dragId;\n}\n\n/**\n * What the meta cluster amounts to — asked once, used three times: to size the\n * rail, to close the cluster with a rule, and to decide whether the value has\n * anything to be divided FROM.\n */\nexport function metaShape(props: BaseListCardProps): { columns: number; present: boolean } {\n const columns = props.meta?.length ?? 0;\n return { columns, present: columns > 0 || props.metaSlot != null };\n}\n\n/**\n * Everything the row derives before it can render — extracted so the component\n * stays inside the size budget.\n */\nexport function useRowShell(props: BaseListCardProps) {\n const actionable = isActionable(props.state);\n const group = useListRails();\n const scale = props.scale ?? 1;\n return {\n group,\n actionable,\n scale,\n theme: useTheme(),\n selectable: isSelectable(props),\n slot: slotTestIds(props.testId),\n drag: useDragItem(dragIdFor(props, actionable)),\n // Standalone holds no gutter open: there is no list beside it to line up\n // with, so a reserved-but-empty rail is pure inset.\n reserve: group?.reserveGutters ?? false,\n // 1, not 1.5. The row's contents still have to line up with the toolbar\n // above them, but 12px of card padding stacked on the checkbox's own 9px\n // and an empty drag gutter's 24px read as a row indented for no reason.\n //\n // Not multiplied by `scale` — the row's `zoom` already scales it, and doing\n // both would square the factor on padding alone.\n pad: 1,\n padY: DENSITY_ROW_PADDING[group?.density ?? props.density ?? \"cozy\"],\n // A card that navigates does so with a real anchor, so it takes no click\n // handler of its own — the stretched link IS the target.\n acts: props.onClick != null && props.href == null && actionable,\n };\n}\n\n/** The click/keyboard props a row that acts (but does not navigate) needs. */\nexport function actionProps(onClick: (() => void) | undefined) {\n return {\n role: \"button\",\n tabIndex: 0,\n onClick: () => {\n if (isTextSelection()) return;\n onClick?.();\n },\n onKeyDown: clickKeys(() => onClick?.()),\n };\n}\n\n/** The surface and the geometry, merged — the row's whole `sx` in one place. */\n\n/**\n * The row's painted surface, plus the divider's colour fallback.\n *\n * A variant with no border of its own (`text`, `ghost`) would draw its rule in\n * the inherited colour — the TEXT colour, i.e. a black bar across the row. The\n * neutral divider token is supplied only in that case; a variant that has a\n * border keeps it, which is the whole point of composing the two.\n */\nfunction rowSurface(\n props: BaseListCardProps,\n shell: ReturnType<typeof useRowShell>,\n): Record<string, unknown> {\n const { theme, selectable, drag } = shell;\n const surface = cardSurfaceStyles(\n { ...props, selectable, shape: \"row\", state: drag.dragging ? \"disabled\" : props.state },\n theme,\n );\n if (props.divider !== true || surface.borderColor != null) return surface;\n return { ...surface, borderBottomColor: theme.palette.divider };\n}\n\nexport function rowStyles(\n props: BaseListCardProps,\n shell: ReturnType<typeof useRowShell>,\n cellTemplate: string | null,\n): Record<string, unknown> {\n const { theme, group, selectable, drag, reserve, pad, padY, scale, acts } = shell;\n return {\n ...rowSurface(props, shell),\n ...rowSx(theme, {\n inGroup: group !== null,\n railCount: group?.railCount ?? RAIL_COUNT,\n cellTemplate,\n gutters: {\n disclose: reserve || props.children != null,\n drag: reserve || drag.draggable,\n select: reserve || selectable,\n },\n metaColumns: metaShape(props).columns,\n pad,\n padY,\n scale,\n divider: props.divider ?? false,\n interactive: acts || props.href != null,\n draggable: drag.draggable && drag.handleProps === undefined,\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,gBAA4B;AA8BrC,SAAS,kBAA2B;AAClC,UAAQ,WAAW,eAAe,GAAG,SAAS,EAAE,UAAU,KAAK;AACjE;AAGA,SAAS,UAAU,SAAqB;AACtC,SAAO,CAAC,UAAqC;AAC3C,QAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,IAAK;AAChD,UAAM,eAAe;AACrB,YAAQ;AAAA,EACV;AACF;AAiDO,IAAM,QAAQ,CAAC,OAAc,SAAgD;AAClF,QAAM,EAAE,SAAS,WAAW,cAAc,SAAS,aAAa,KAAK,MAAM,OAAO,SAAS,aAAa,UAAU,IAAI;AACtH,SAAO;AAAA,IACL,UAAU;AAAA,IACV,cAAc;AAAA,IACd,SAAS;AAAA,IACT,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQN,GAAI,UACA,EAAE,YAAY,QAAQ,SAAS,IAAI,qBAAqB,UAAU,IAClE;AAAA,MACE,eAAe;AAAA,MACf,qBAAqB,gBAAgB,iBAAiB,SAAS,WAAW;AAAA,IAC5E;AAAA,IACJ,YAAY;AAAA;AAAA;AAAA;AAAA,IAIZ,WAAW;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YAAY,MAAM,SAAS,KAAK,MAAM,OAAO,KAAK,IAAI;AAC5E,SAAO;AAAA,IACL,GAAG,WAAW,OAAO,KAAK;AAAA,IAC1B,GAAG,MAAM,OAAO;AAAA,MACd,SAAS,UAAU;AAAA,MACnB,WAAW,OAAO,aAAa;AAAA,MAC/B;AAAA,MACA,SAAS;AAAA,QACP,UAAU,WAAW,MAAM,YAAY;AAAA,QACvC,MAAM,WAAW,KAAK;AAAA,QACtB,QAAQ,WAAW;AAAA,MACrB;AAAA,MACA,aAAa,UAAU,KAAK,EAAE;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,MAAM,WAAW;AAAA,MAC1B,aAAa,QAAQ,MAAM,QAAQ;AAAA,MACnC,WAAW,KAAK,aAAa,KAAK,gBAAgB;AAAA,IACpD,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/data-display/DataViews/data-views-toolbar.tsx"],"sourcesContent":["\"use client\";\n\nimport Divider from \"@mui/material/Divider/index.js\";\n\nimport {\n ContentToolbar,\n FilterTrigger,\n type ColumnVisibilityOption,\n type SortFieldDefinition,\n} from \"../../layout/ContentToolbar\";\nimport { Box } from \"../../../mui/Box\";\nimport { Text } from \"../../typography/Text\";\n\nimport { useDataViewsCopy } from \"./data-views-copy-context\";\nimport { DataViewsDisplayPanel, type DisplayPanelView } from \"./data-views-display-panel\";\nimport { DataViewsExportMenu, type DataViewExport } from \"./data-views-export\";\nimport { renderBulkActions } from \"./data-views-grid-helpers\";\nimport type { RowAction } from \"./data-views-types\";\nimport type { DataViewsController } from \"./use-data-views-state\";\nimport { sxRem } from \"../../../tokens/relative\";\n\nexport interface GridToolbarProps<T extends Record<string, unknown>> {\n testIdPrefix: string;\n selectedRows: T[];\n selectAll: () => void;\n clearSelection: () => void;\n rowActions?: RowAction<T>[];\n bulkActions?: (selectedRows: T[], clearSelection: () => void) => React.ReactNode;\n /** A control between the count and the actions menu — see `selectionExtra`. */\n selectionExtra?: React.ReactNode;\n sortFields: SortFieldDefinition[];\n activeSortField: string;\n activeSortOrder: \"asc\" | \"desc\";\n onChangeSort: (field: string, order: \"asc\" | \"desc\") => void;\n matchedCount: number;\n totalCount: number;\n toolbarRightSlot?: React.ReactNode;\n columnOptions: ColumnVisibilityOption[];\n onToggleColumn: (id: string, visible: boolean) => void;\n filterOpen: boolean;\n setFilterOpen: (open: boolean) => void;\n activeFilterCount: number;\n /** Hide the \"Filtros\" slide-in trigger (compact layout shows filters inline). */\n showFilterTrigger?: boolean;\n /**\n * Search + filter controls, rendered ON the toolbar line rather than on a row\n * beneath it. Absent ⇒ the toolbar keeps its plain two-cluster shape.\n */\n filterControls?: React.ReactNode;\n /** Measures the toolbar ROW for the filter overflow — see `useFilterOverflow`. */\n barRef?: React.Ref<HTMLDivElement>;\n /** The controller, so \"Exibir\" can drive sort, columns, order and format. */\n c: DataViewsController<T>;\n /** Per-sort-field value kind, so directions read in the column's own terms. */\n sortKinds?: Record<string, string>;\n /** The saved-view chrome bracketing the Exibir panel, when the host has views. */\n displayView?: DisplayPanelView;\n /** Injected export. Absent ⇒ no Exportar control. */\n exportConfig?: DataViewExport;\n /**\n * Step 2 of the degradation ladder: Exibir/Exportar as icons only.\n * MEASURED upstream (see `useFilterOverflow`) rather than switched at a\n * breakpoint, so a two-filter page keeps its labels where a five-filter one\n * has already given them up.\n */\n compactControls?: boolean;\n /**\n * Step 5 of the ladder, and its floor: on a screen too narrow for even the\n * fully-collapsed row, the counter is dropped so the controls still fit one\n * line instead of spilling outside the toolbar.\n */\n counterHidden?: boolean;\n}\n\n/** The right-aligned toolbar controls: Sort By, the counter, zoom/layout/columns, filters. */\nfunction ToolbarRightControls<T extends Record<string, unknown>>(props: GridToolbarProps<T>): React.JSX.Element {\n const { testIdPrefix, matchedCount, totalCount, filterOpen, setFilterOpen } = props;\n return (\n <>\n {/* MEASURED, never breakpointed: `RESERVED.counter` prices it into the\n ladder, so hiding it at `md` was the ladder and a breakpoint\n disagreeing about the same pixels — which broke the row at exactly\n 900px. It is dropped only as the ladder's last rung. */}\n {!props.counterHidden && (\n <>\n <Text variant=\"caption\" as=\"span\">\n <Box\n component=\"span\"\n data-testid={`${testIdPrefix}-counter`}\n sx={{ whiteSpace: \"nowrap\" }}\n >\n {matchedCount} de {totalCount}\n </Box>\n </Text>\n {/* Divides the READING of the list from the controls that change it —\n the counter states what is on screen, everything right of here\n acts on it. */}\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={{ height: sxRem(20), alignSelf: \"center\", mx: 0.5 }}\n />\n </>\n )}\n {props.toolbarRightSlot}\n {/* Sort + columns + format, in ONE control — see DataViewsDisplayPanel. */}\n <DataViewsDisplayPanel\n c={props.c}\n testIdPrefix={testIdPrefix}\n sortKinds={props.sortKinds}\n view={props.displayView}\n compact={props.compactControls}\n />\n {props.exportConfig && (\n <DataViewsExportMenu\n config={props.exportConfig}\n query={props.c.currentQuery}\n totalCount={props.totalCount}\n selectedIds={[...props.c.selectedIds]}\n columns={props.columnOptions.filter((col) => col.visible).map((col) => ({ id: col.id, label: col.label }))}\n testIdPrefix={testIdPrefix}\n compact={props.compactControls}\n />\n )}\n {props.showFilterTrigger !== false && (\n <FilterTrigger\n open={filterOpen}\n onOpenChange={setFilterOpen}\n activeCount={props.activeFilterCount}\n data-testid={`${testIdPrefix}-filters-toggle`}\n />\n )}\n </>\n );\n}\n\n/**\n * The bordered toolbar band: selection chrome + Sort By, the result counter, the\n * saved-views slot, and the filter funnel. The negative margin lets the top/bottom\n * separators reach the sidebar's vertical line and the window edge.\n */\nexport function GridToolbar<T extends Record<string, unknown>>(props: GridToolbarProps<T>): React.JSX.Element {\n const copy = useDataViewsCopy();\n const { testIdPrefix, selectedRows } = props;\n return (\n <Box\n ref={props.barRef}\n sx={{\n borderTop: 1,\n borderBottom: 1,\n borderColor: \"divider\",\n py: 1.25,\n mx: { xs: -2, md: -3 },\n px: { xs: 2, md: 3 },\n }}\n >\n <ContentToolbar\n selectAllLabel={copy.selection.selectAll}\n selectAllText={copy.selection.selectAllOnPage}\n clearAllText={copy.filters.clearAll}\n hasSelection={selectedRows.length > 0}\n selectedCount={selectedRows.length}\n selectAll={props.selectAll}\n clearSelection={props.clearSelection}\n selectAllTestId={`${testIdPrefix}-select-all`}\n clearAllTestId={`${testIdPrefix}-clear-all`}\n selectionExtra={props.selectionExtra}\n actions={renderBulkActions({\n rowActions: props.rowActions,\n bulkActions: props.bulkActions,\n selectedRows,\n clearSelection: props.clearSelection,\n testIdPrefix,\n })}\n leadingControls={props.filterControls}\n // Selection takes the whole line: no Select All while browsing, and no\n // search/filters/Exibir/Exportar once a row is ticked.\n exclusiveSelection\n rightControls={<ToolbarRightControls {...props} />}\n />\n </Box>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,aAAa;AAkFZ,mBACE,KACE,YAFJ;AATR,SAAS,qBAAwD,OAA+C;AAC9G,QAAM,EAAE,cAAc,cAAc,YAAY,YAAY,cAAc,IAAI;AAC9E,SACE,iCAKG;AAAA,KAAC,MAAM,iBACN,iCACE;AAAA,0BAAC,QAAK,SAAQ,WAAU,IAAG,QACzB;AAAA,QAACA;AAAA,QAAA;AAAA,UACC,WAAU;AAAA,UACV,eAAa,GAAG,YAAY;AAAA,UAC5B,IAAI,EAAE,YAAY,SAAS;AAAA,UAE1B;AAAA;AAAA,YAAa;AAAA,YAAK;AAAA;AAAA;AAAA,MACrB,GACF;AAAA,MAIA;AAAA,QAAC;AAAA;AAAA,UACC,aAAY;AAAA,UACZ,UAAQ;AAAA,UACR,IAAI,EAAE,QAAQ,MAAM,EAAE,GAAG,WAAW,UAAU,IAAI,IAAI;AAAA;AAAA,MACxD;AAAA,OACF;AAAA,IAED,MAAM;AAAA,IAEP;AAAA,MAAC;AAAA;AAAA,QACC,GAAG,MAAM;AAAA,QACT;AAAA,QACA,WAAW,MAAM;AAAA,QACjB,MAAM,MAAM;AAAA,QACZ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