@ui-organized/svelte-table 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/README.md +99 -2
- package/dist/DataTable/DataTable.svelte +62 -0
- package/dist/DataTable/DataTable.svelte.d.ts +29 -0
- package/dist/DataTable/DataTable.svelte.d.ts.map +1 -0
- package/dist/DataTable/DataTable.test.svelte.d.ts +2 -0
- package/dist/DataTable/DataTable.test.svelte.d.ts.map +1 -0
- package/dist/DataTable/DataTable.test.svelte.js +360 -0
- package/dist/DataTable/index.d.ts +2 -0
- package/dist/DataTable/index.d.ts.map +1 -0
- package/dist/DataTable/index.js +1 -0
- package/dist/components/Table/CellEditor.svelte +29 -0
- package/dist/components/Table/CellEditor.svelte.d.ts +8 -0
- package/dist/components/Table/CellEditor.svelte.d.ts.map +1 -0
- package/dist/components/Table/MoveButtons.svelte +60 -0
- package/dist/components/Table/MoveButtons.svelte.d.ts +8 -0
- package/dist/components/Table/MoveButtons.svelte.d.ts.map +1 -0
- package/dist/components/Table/ResizeHandle.svelte +82 -0
- package/dist/components/Table/ResizeHandle.svelte.d.ts +28 -0
- package/dist/components/Table/ResizeHandle.svelte.d.ts.map +1 -0
- package/dist/components/Table/Table.svelte +17 -0
- package/dist/components/Table/Table.svelte.d.ts +9 -0
- package/dist/components/Table/Table.svelte.d.ts.map +1 -0
- package/dist/components/Table/TableBody.svelte +78 -0
- package/dist/components/Table/TableBody.svelte.d.ts +30 -0
- package/dist/components/Table/TableBody.svelte.d.ts.map +1 -0
- package/dist/components/Table/TableCell.svelte +106 -0
- package/dist/components/Table/TableCell.svelte.d.ts +34 -0
- package/dist/components/Table/TableCell.svelte.d.ts.map +1 -0
- package/dist/components/Table/TableFooter.svelte +34 -0
- package/dist/components/Table/TableFooter.svelte.d.ts +9 -0
- package/dist/components/Table/TableFooter.svelte.d.ts.map +1 -0
- package/dist/components/Table/TableHeadCell.svelte +157 -0
- package/dist/components/Table/TableHeadCell.svelte.d.ts +29 -0
- package/dist/components/Table/TableHeadCell.svelte.d.ts.map +1 -0
- package/dist/components/Table/TableHeader.svelte +22 -0
- package/dist/components/Table/TableHeader.svelte.d.ts +7 -0
- package/dist/components/Table/TableHeader.svelte.d.ts.map +1 -0
- package/dist/components/Table/TableRow.svelte +84 -0
- package/dist/components/Table/TableRow.svelte.d.ts +32 -0
- package/dist/components/Table/TableRow.svelte.d.ts.map +1 -0
- package/dist/components/Table/TableViewport.svelte +69 -0
- package/dist/components/Table/TableViewport.svelte.d.ts +10 -0
- package/dist/components/Table/TableViewport.svelte.d.ts.map +1 -0
- package/dist/components/Table/index.d.ts +23 -0
- package/dist/components/Table/index.d.ts.map +1 -0
- package/dist/components/Table/index.js +22 -0
- package/dist/components/TableCards/TableCard.svelte +96 -0
- package/dist/components/TableCards/TableCard.svelte.d.ts +31 -0
- package/dist/components/TableCards/TableCard.svelte.d.ts.map +1 -0
- package/dist/components/TableCards/TableCards.svelte +61 -0
- package/dist/components/TableCards/TableCards.svelte.d.ts +7 -0
- package/dist/components/TableCards/TableCards.svelte.d.ts.map +1 -0
- package/dist/components/TableCards/index.d.ts +3 -0
- package/dist/components/TableCards/index.d.ts.map +1 -0
- package/dist/components/TableCards/index.js +2 -0
- package/dist/components/TableDetailSheet/TableDetailSheet.svelte +130 -0
- package/dist/components/TableDetailSheet/TableDetailSheet.svelte.d.ts +8 -0
- package/dist/components/TableDetailSheet/TableDetailSheet.svelte.d.ts.map +1 -0
- package/dist/components/TableDetailSheet/index.d.ts +2 -0
- package/dist/components/TableDetailSheet/index.d.ts.map +1 -0
- package/dist/components/TableDetailSheet/index.js +1 -0
- package/dist/components/TableFilters/TableFilterAdd.svelte +89 -0
- package/dist/components/TableFilters/TableFilterAdd.svelte.d.ts +15 -0
- package/dist/components/TableFilters/TableFilterAdd.svelte.d.ts.map +1 -0
- package/dist/components/TableFilters/TableFilterChip.svelte +164 -0
- package/dist/components/TableFilters/TableFilterChip.svelte.d.ts +9 -0
- package/dist/components/TableFilters/TableFilterChip.svelte.d.ts.map +1 -0
- package/dist/components/TableFilters/TableFilterEditor.svelte +40 -0
- package/dist/components/TableFilters/TableFilterEditor.svelte.d.ts +9 -0
- package/dist/components/TableFilters/TableFilterEditor.svelte.d.ts.map +1 -0
- package/dist/components/TableFilters/TableFilterValueEditor.svelte +209 -0
- package/dist/components/TableFilters/TableFilterValueEditor.svelte.d.ts +10 -0
- package/dist/components/TableFilters/TableFilterValueEditor.svelte.d.ts.map +1 -0
- package/dist/components/TableFilters/TableFilters.svelte +51 -0
- package/dist/components/TableFilters/TableFilters.svelte.d.ts +7 -0
- package/dist/components/TableFilters/TableFilters.svelte.d.ts.map +1 -0
- package/dist/components/TableFilters/index.d.ts +7 -0
- package/dist/components/TableFilters/index.d.ts.map +1 -0
- package/dist/components/TableFilters/index.js +6 -0
- package/dist/components/TableFilters/useAutoFocusField.d.ts +30 -0
- package/dist/components/TableFilters/useAutoFocusField.d.ts.map +1 -0
- package/dist/components/TableFilters/useAutoFocusField.js +59 -0
- package/dist/components/TablePagination/TablePagination.svelte +61 -0
- package/dist/components/TablePagination/TablePagination.svelte.d.ts +9 -0
- package/dist/components/TablePagination/TablePagination.svelte.d.ts.map +1 -0
- package/dist/components/TablePagination/index.d.ts +2 -0
- package/dist/components/TablePagination/index.d.ts.map +1 -0
- package/dist/components/TablePagination/index.js +1 -0
- package/dist/components/TableRowActions/TableRowActions.svelte +68 -0
- package/dist/components/TableRowActions/TableRowActions.svelte.d.ts +37 -0
- package/dist/components/TableRowActions/TableRowActions.svelte.d.ts.map +1 -0
- package/dist/components/TableRowActions/index.d.ts +2 -0
- package/dist/components/TableRowActions/index.d.ts.map +1 -0
- package/dist/components/TableRowActions/index.js +1 -0
- package/dist/components/TableSelectionBar/TableSelectionBar.svelte +88 -0
- package/dist/components/TableSelectionBar/TableSelectionBar.svelte.d.ts +30 -0
- package/dist/components/TableSelectionBar/TableSelectionBar.svelte.d.ts.map +1 -0
- package/dist/components/TableSelectionBar/index.d.ts +2 -0
- package/dist/components/TableSelectionBar/index.d.ts.map +1 -0
- package/dist/components/TableSelectionBar/index.js +1 -0
- package/dist/components/TableSelectionFooter/TableSelectionFooter.svelte +38 -0
- package/dist/components/TableSelectionFooter/TableSelectionFooter.svelte.d.ts +7 -0
- package/dist/components/TableSelectionFooter/TableSelectionFooter.svelte.d.ts.map +1 -0
- package/dist/components/TableSelectionFooter/index.d.ts +2 -0
- package/dist/components/TableSelectionFooter/index.d.ts.map +1 -0
- package/dist/components/TableSelectionFooter/index.js +1 -0
- package/dist/components/TableSheets/TableFilterSheet.svelte +150 -0
- package/dist/components/TableSheets/TableFilterSheet.svelte.d.ts +8 -0
- package/dist/components/TableSheets/TableFilterSheet.svelte.d.ts.map +1 -0
- package/dist/components/TableSheets/TableFilterSheetCondition.svelte +53 -0
- package/dist/components/TableSheets/TableFilterSheetCondition.svelte.d.ts +9 -0
- package/dist/components/TableSheets/TableFilterSheetCondition.svelte.d.ts.map +1 -0
- package/dist/components/TableSheets/TableSheetButton.svelte +44 -0
- package/dist/components/TableSheets/TableSheetButton.svelte.d.ts +15 -0
- package/dist/components/TableSheets/TableSheetButton.svelte.d.ts.map +1 -0
- package/dist/components/TableSheets/TableSortSheet.svelte +100 -0
- package/dist/components/TableSheets/TableSortSheet.svelte.d.ts +8 -0
- package/dist/components/TableSheets/TableSortSheet.svelte.d.ts.map +1 -0
- package/dist/components/TableSheets/index.d.ts +4 -0
- package/dist/components/TableSheets/index.d.ts.map +1 -0
- package/dist/components/TableSheets/index.js +3 -0
- package/dist/components/TableStates/TableEmpty.svelte +35 -0
- package/dist/components/TableStates/TableEmpty.svelte.d.ts +11 -0
- package/dist/components/TableStates/TableEmpty.svelte.d.ts.map +1 -0
- package/dist/components/TableStates/TableError.svelte +26 -0
- package/dist/components/TableStates/TableError.svelte.d.ts +10 -0
- package/dist/components/TableStates/TableError.svelte.d.ts.map +1 -0
- package/dist/components/TableStates/TableLoading.svelte +33 -0
- package/dist/components/TableStates/TableLoading.svelte.d.ts +8 -0
- package/dist/components/TableStates/TableLoading.svelte.d.ts.map +1 -0
- package/dist/components/TableStates/index.d.ts +4 -0
- package/dist/components/TableStates/index.d.ts.map +1 -0
- package/dist/components/TableStates/index.js +3 -0
- package/dist/components/TableSubBar/TableSubBar.svelte +34 -0
- package/dist/components/TableSubBar/TableSubBar.svelte.d.ts +7 -0
- package/dist/components/TableSubBar/TableSubBar.svelte.d.ts.map +1 -0
- package/dist/components/TableSubBar/index.d.ts +2 -0
- package/dist/components/TableSubBar/index.d.ts.map +1 -0
- package/dist/components/TableSubBar/index.js +1 -0
- package/dist/components/TableToolbar/TableActions.svelte +40 -0
- package/dist/components/TableToolbar/TableActions.svelte.d.ts +9 -0
- package/dist/components/TableToolbar/TableActions.svelte.d.ts.map +1 -0
- package/dist/components/TableToolbar/TableExportMenu.svelte +60 -0
- package/dist/components/TableToolbar/TableExportMenu.svelte.d.ts +8 -0
- package/dist/components/TableToolbar/TableExportMenu.svelte.d.ts.map +1 -0
- package/dist/components/TableToolbar/TableReorderToggle.svelte +27 -0
- package/dist/components/TableToolbar/TableReorderToggle.svelte.d.ts +7 -0
- package/dist/components/TableToolbar/TableReorderToggle.svelte.d.ts.map +1 -0
- package/dist/components/TableToolbar/TableScrollButtons.svelte +54 -0
- package/dist/components/TableToolbar/TableScrollButtons.svelte.d.ts +9 -0
- package/dist/components/TableToolbar/TableScrollButtons.svelte.d.ts.map +1 -0
- package/dist/components/TableToolbar/TableSearch.svelte +24 -0
- package/dist/components/TableToolbar/TableSearch.svelte.d.ts +9 -0
- package/dist/components/TableToolbar/TableSearch.svelte.d.ts.map +1 -0
- package/dist/components/TableToolbar/TableSortMenu.svelte +97 -0
- package/dist/components/TableToolbar/TableSortMenu.svelte.d.ts +8 -0
- package/dist/components/TableToolbar/TableSortMenu.svelte.d.ts.map +1 -0
- package/dist/components/TableToolbar/TableToolbar.svelte +113 -0
- package/dist/components/TableToolbar/TableToolbar.svelte.d.ts +9 -0
- package/dist/components/TableToolbar/TableToolbar.svelte.d.ts.map +1 -0
- package/dist/components/TableToolbar/TableViewOptions.svelte +69 -0
- package/dist/components/TableToolbar/TableViewOptions.svelte.d.ts +8 -0
- package/dist/components/TableToolbar/TableViewOptions.svelte.d.ts.map +1 -0
- package/dist/components/TableToolbar/index.d.ts +9 -0
- package/dist/components/TableToolbar/index.d.ts.map +1 -0
- package/dist/components/TableToolbar/index.js +8 -0
- package/dist/core/ActionsHeader.svelte +8 -0
- package/dist/core/ActionsHeader.svelte.d.ts +27 -0
- package/dist/core/ActionsHeader.svelte.d.ts.map +1 -0
- package/dist/core/SelectAllCell.svelte +21 -0
- package/dist/core/SelectAllCell.svelte.d.ts +19 -0
- package/dist/core/SelectAllCell.svelte.d.ts.map +1 -0
- package/dist/core/SelectCell.svelte +37 -0
- package/dist/core/SelectCell.svelte.d.ts +8 -0
- package/dist/core/SelectCell.svelte.d.ts.map +1 -0
- package/dist/core/createDataTable.svelte.d.ts +4 -0
- package/dist/core/createDataTable.svelte.d.ts.map +1 -0
- package/dist/core/createDataTable.svelte.js +1152 -0
- package/dist/core/createDataTable.test.svelte.d.ts +2 -0
- package/dist/core/createDataTable.test.svelte.d.ts.map +1 -0
- package/dist/core/createDataTable.test.svelte.js +156 -0
- package/dist/core/createDeferred.svelte.d.ts +38 -0
- package/dist/core/createDeferred.svelte.d.ts.map +1 -0
- package/dist/core/createDeferred.svelte.js +81 -0
- package/dist/core/elementRef.d.ts +17 -0
- package/dist/core/elementRef.d.ts.map +1 -0
- package/dist/core/elementRef.js +20 -0
- package/dist/core/props.d.ts +3 -0
- package/dist/core/props.d.ts.map +1 -0
- package/dist/core/props.js +46 -0
- package/dist/core/systemColumns.d.ts +16 -0
- package/dist/core/systemColumns.d.ts.map +1 -0
- package/dist/core/systemColumns.js +53 -0
- package/dist/core/tableContext.d.ts +7 -0
- package/dist/core/tableContext.d.ts.map +1 -0
- package/dist/core/tableContext.js +30 -0
- package/dist/core/trackStore.svelte.d.ts +24 -0
- package/dist/core/trackStore.svelte.d.ts.map +1 -0
- package/dist/core/trackStore.svelte.js +28 -0
- package/dist/core/types.d.ts +397 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/styles.css +895 -0
- package/package.json +77 -3
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Wraps the library's `Pagination`, which takes a page *count* — the conversion
|
|
3
|
+
from row count and page size happens here so consumers never do that arithmetic
|
|
4
|
+
themselves and get the off-by-one wrong.
|
|
5
|
+
-->
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import { clsx } from "clsx";
|
|
8
|
+
import { Pagination, Select } from "@ui-organized/svelte";
|
|
9
|
+
import { PAGE_SIZE_OPTIONS, pageSizeOptions } from "@ui-organized/table-core";
|
|
10
|
+
import { getTable } from "../../core/tableContext.js";
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
showPageSize = true,
|
|
14
|
+
pageSizes = [...PAGE_SIZE_OPTIONS],
|
|
15
|
+
class: className,
|
|
16
|
+
}: { showPageSize?: boolean; pageSizes?: number[]; class?: string } = $props();
|
|
17
|
+
|
|
18
|
+
const table = getTable();
|
|
19
|
+
const pagination = $derived(table.state.pagination);
|
|
20
|
+
const pageIndex = $derived(pagination?.pageIndex ?? 0);
|
|
21
|
+
const pageSize = $derived(pagination?.pageSize ?? 10);
|
|
22
|
+
const total = $derived(table.selection.totalMatching);
|
|
23
|
+
const pageCount = $derived(Math.max(1, Math.ceil(total / pageSize)));
|
|
24
|
+
|
|
25
|
+
const first = $derived(total === 0 ? 0 : pageIndex * pageSize + 1);
|
|
26
|
+
const last = $derived(Math.min(total, (pageIndex + 1) * pageSize));
|
|
27
|
+
const status = $derived(total === 0 ? "No rows" : `${first}–${last} of ${total}`);
|
|
28
|
+
const sizeOptions = $derived(
|
|
29
|
+
pageSizeOptions(pageSizes, pageSize).map((entry) => ({
|
|
30
|
+
value: String(entry),
|
|
31
|
+
label: String(entry),
|
|
32
|
+
})),
|
|
33
|
+
);
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<div class={clsx("data-table__pagination", className)}>
|
|
37
|
+
<!--
|
|
38
|
+
Announced on change, because the rows it describes change underneath a screen
|
|
39
|
+
reader user with no other signal that anything happened.
|
|
40
|
+
-->
|
|
41
|
+
<span class="data-table__pagination-status" aria-live="polite">{status}</span>
|
|
42
|
+
|
|
43
|
+
<Pagination
|
|
44
|
+
page={pageIndex + 1}
|
|
45
|
+
count={pageCount}
|
|
46
|
+
onPageChange={(page) => table.table.setPageIndex(page - 1)}
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
{#if showPageSize}
|
|
50
|
+
<div class="data-table__page-size">
|
|
51
|
+
<Select
|
|
52
|
+
size={table.size}
|
|
53
|
+
variant="ghost"
|
|
54
|
+
label="Rows per page"
|
|
55
|
+
value={String(pageSize)}
|
|
56
|
+
options={sizeOptions}
|
|
57
|
+
onValueChange={(next) => table.table.setPageSize(Number(next))}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
{/if}
|
|
61
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type $$ComponentProps = {
|
|
2
|
+
showPageSize?: boolean;
|
|
3
|
+
pageSizes?: number[];
|
|
4
|
+
class?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const TablePagination: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type TablePagination = ReturnType<typeof TablePagination>;
|
|
8
|
+
export default TablePagination;
|
|
9
|
+
//# sourceMappingURL=TablePagination.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TablePagination.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/TablePagination/TablePagination.svelte.ts"],"names":[],"mappings":"AAQC,KAAK,gBAAgB,GAAI;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA+C3F,QAAA,MAAM,eAAe,sDAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/TablePagination/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TablePagination } from "./TablePagination.svelte";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Per-row actions, as a menu rather than a row of buttons.
|
|
3
|
+
|
|
4
|
+
A menu is one tab stop per row instead of three, which matters a great deal
|
|
5
|
+
when there are two hundred rows — and it is the only affordance that survives
|
|
6
|
+
card mode unchanged.
|
|
7
|
+
-->
|
|
8
|
+
<script lang="ts" generics="T extends RowData">
|
|
9
|
+
import { Button, Menu, MenuContent, MenuItem, MenuTrigger } from "@ui-organized/svelte";
|
|
10
|
+
import type { RowData } from "@ui-organized/table-core";
|
|
11
|
+
import { getTable } from "../../core/tableContext.js";
|
|
12
|
+
import type { RowAction } from "../../core/types.js";
|
|
13
|
+
import { internalGlyph as glyph } from "@ui-organized/svelte";
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
row,
|
|
17
|
+
actions,
|
|
18
|
+
label = "Row actions",
|
|
19
|
+
}: {
|
|
20
|
+
/** The row the actions operate on. */
|
|
21
|
+
row: T;
|
|
22
|
+
/**
|
|
23
|
+
* Overrides the table's own `rowActions`. Only needed when the part is used
|
|
24
|
+
* outside a `<DataTable>`.
|
|
25
|
+
*/
|
|
26
|
+
actions?: RowAction<T>[];
|
|
27
|
+
/** Accessible name for the trigger. Defaults to "Row actions". */
|
|
28
|
+
label?: string;
|
|
29
|
+
} = $props();
|
|
30
|
+
|
|
31
|
+
const table = getTable<T>();
|
|
32
|
+
const items = $derived(actions ?? table.options.rowActions ?? []);
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
{#if items.length > 0}
|
|
36
|
+
<Menu>
|
|
37
|
+
<!--
|
|
38
|
+
`asChild` as a snippet, which is Ark Svelte's own convention: the trigger
|
|
39
|
+
hands its props in and the consumer spreads them at the point of use. That
|
|
40
|
+
is what puts the trigger's `id`, `aria-expanded` and click handler on the
|
|
41
|
+
Button rather than on a wrapper around it.
|
|
42
|
+
-->
|
|
43
|
+
<MenuTrigger>
|
|
44
|
+
{#snippet asChild(props)}
|
|
45
|
+
<Button
|
|
46
|
+
{...(props() as Record<string, never>)}
|
|
47
|
+
intent="ghost"
|
|
48
|
+
size={table.size}
|
|
49
|
+
icon={glyph("menu")}
|
|
50
|
+
aria-label={label}
|
|
51
|
+
/>
|
|
52
|
+
{/snippet}
|
|
53
|
+
</MenuTrigger>
|
|
54
|
+
<MenuContent align="end">
|
|
55
|
+
{#each items as action (action.id)}
|
|
56
|
+
<MenuItem
|
|
57
|
+
value={action.id}
|
|
58
|
+
icon={action.icon}
|
|
59
|
+
destructive={action.destructive}
|
|
60
|
+
disabled={action.disabled?.(row)}
|
|
61
|
+
onSelect={() => void action.onRun(row)}
|
|
62
|
+
>
|
|
63
|
+
{action.label}
|
|
64
|
+
</MenuItem>
|
|
65
|
+
{/each}
|
|
66
|
+
</MenuContent>
|
|
67
|
+
</Menu>
|
|
68
|
+
{/if}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { RowData } from "@ui-organized/table-core";
|
|
2
|
+
import type { RowAction } from "../../core/types.js";
|
|
3
|
+
declare function $$render<T extends RowData>(): {
|
|
4
|
+
props: {
|
|
5
|
+
/** The row the actions operate on. */
|
|
6
|
+
row: T;
|
|
7
|
+
/**
|
|
8
|
+
* Overrides the table's own `rowActions`. Only needed when the part is used
|
|
9
|
+
* outside a `<DataTable>`.
|
|
10
|
+
*/
|
|
11
|
+
actions?: RowAction<T>[];
|
|
12
|
+
/** Accessible name for the trigger. Defaults to "Row actions". */
|
|
13
|
+
label?: string;
|
|
14
|
+
};
|
|
15
|
+
exports: {};
|
|
16
|
+
bindings: "";
|
|
17
|
+
slots: {};
|
|
18
|
+
events: {};
|
|
19
|
+
};
|
|
20
|
+
declare class __sveltets_Render<T extends RowData> {
|
|
21
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
22
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
23
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
24
|
+
bindings(): "";
|
|
25
|
+
exports(): {};
|
|
26
|
+
}
|
|
27
|
+
interface $$IsomorphicComponent {
|
|
28
|
+
new <T extends RowData>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
29
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
30
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
31
|
+
<T extends RowData>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
32
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
33
|
+
}
|
|
34
|
+
declare const TableRowActions: $$IsomorphicComponent;
|
|
35
|
+
type TableRowActions<T extends RowData> = InstanceType<typeof TableRowActions<T>>;
|
|
36
|
+
export default TableRowActions;
|
|
37
|
+
//# sourceMappingURL=TableRowActions.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableRowActions.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/TableRowActions/TableRowActions.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,iBAAS,QAAQ,CAAC,CAAC,SAAS,OAAO;;QAO/B,sCAAsC;aACjC,CAAC;QACN;;;WAGG;kBACO,SAAS,CAAC,CAAC,CAAC,EAAE;QACxB,kEAAkE;gBAC1D,MAAM;;;;;;EAiCuG;AACzH,cAAM,iBAAiB,CAAC,CAAC,SAAS,OAAO;IACrC,KAAK,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAChD,MAAM,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAClD,KAAK,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAChD,QAAQ;IACR,OAAO;CACV;AAED,UAAU,qBAAqB;IAC3B,KAAK,CAAC,SAAS,OAAO,EAAE,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;KAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC5Y,CAAC,CAAC,SAAS,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3I,YAAY,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;CACjE;AACD,QAAA,MAAM,eAAe,EAAE,qBAAmC,CAAC;AACzC,KAAK,eAAe,CAAC,CAAC,SAAS,OAAO,IAAI,YAAY,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;AACpF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/TableRowActions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TableRowActions } from "./TableRowActions.svelte";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Appears only while something is selected, and then takes the place of the
|
|
3
|
+
toolbar's sort, filter and table actions: with rows selected, what to do with
|
|
4
|
+
them is the decision in front of the user, so it sits where they were already
|
|
5
|
+
looking rather than on a line of its own. The count, and the offer to select
|
|
6
|
+
the rows off screen, are in `TableSelectionFooter` under the rows.
|
|
7
|
+
|
|
8
|
+
Plain buttons in a labelled group, with no surface of its own. It shares the
|
|
9
|
+
toolbar row with the search box, so `role="toolbar"`'s roving focus would make
|
|
10
|
+
it the only cluster in that row that Tab skips through. Destructive actions
|
|
11
|
+
route through `AlertDialog`; "archive 40,000 rows" is not an undo-able
|
|
12
|
+
mis-click.
|
|
13
|
+
-->
|
|
14
|
+
<script lang="ts" generics="T extends RowData">
|
|
15
|
+
import { clsx } from "clsx";
|
|
16
|
+
import {
|
|
17
|
+
AlertDialog,
|
|
18
|
+
AlertDialogCancel,
|
|
19
|
+
AlertDialogConfirm,
|
|
20
|
+
AlertDialogContent,
|
|
21
|
+
AlertDialogDescription,
|
|
22
|
+
AlertDialogFooter,
|
|
23
|
+
AlertDialogTitle,
|
|
24
|
+
Button,
|
|
25
|
+
} from "@ui-organized/svelte";
|
|
26
|
+
import type { RowData } from "@ui-organized/table-core";
|
|
27
|
+
import { getTable } from "../../core/tableContext.js";
|
|
28
|
+
import type { BulkAction } from "../../core/types.js";
|
|
29
|
+
|
|
30
|
+
let { actions, class: className }: { actions?: BulkAction<T>[]; class?: string } = $props();
|
|
31
|
+
const table = getTable<T>();
|
|
32
|
+
|
|
33
|
+
let confirming = $state<BulkAction<T> | null>(null);
|
|
34
|
+
const items = $derived(actions ?? table.options.bulkActions ?? []);
|
|
35
|
+
const count = $derived(table.selection.count);
|
|
36
|
+
const rowsWord = $derived(count === 1 ? "1 row" : `${count} rows`);
|
|
37
|
+
|
|
38
|
+
const run = (action: BulkAction<T>) => {
|
|
39
|
+
void action.onRun(table.selection.rows, table.selection.asBulk());
|
|
40
|
+
};
|
|
41
|
+
const choose = (action: BulkAction<T>) => {
|
|
42
|
+
if (action.destructive) confirming = action;
|
|
43
|
+
else run(action);
|
|
44
|
+
};
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
{#if count > 0}
|
|
48
|
+
<div role="group" class={clsx("data-table__selection-bar", className)} aria-label="Bulk actions">
|
|
49
|
+
{#each items as action (action.id)}
|
|
50
|
+
<Button
|
|
51
|
+
size={table.size}
|
|
52
|
+
intent={action.destructive ? "destructive-ghost" : "ghost"}
|
|
53
|
+
icon={action.icon}
|
|
54
|
+
onclick={() => choose(action)}
|
|
55
|
+
>
|
|
56
|
+
{action.label}
|
|
57
|
+
</Button>
|
|
58
|
+
{/each}
|
|
59
|
+
|
|
60
|
+
<Button size={table.size} intent="ghost" onclick={() => table.selection.clear()}>
|
|
61
|
+
Clear
|
|
62
|
+
</Button>
|
|
63
|
+
|
|
64
|
+
<AlertDialog open={confirming !== null} onOpenChange={(open) => !open && (confirming = null)}>
|
|
65
|
+
<AlertDialogContent>
|
|
66
|
+
<AlertDialogTitle>
|
|
67
|
+
{confirming?.confirm?.title ?? `${confirming?.label ?? "Continue"}?`}
|
|
68
|
+
</AlertDialogTitle>
|
|
69
|
+
<AlertDialogDescription>
|
|
70
|
+
{confirming?.confirm?.description ??
|
|
71
|
+
`This will ${confirming?.label.toLowerCase() ?? "act on"} ${rowsWord}. This cannot be undone.`}
|
|
72
|
+
</AlertDialogDescription>
|
|
73
|
+
<AlertDialogFooter>
|
|
74
|
+
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
75
|
+
<AlertDialogConfirm
|
|
76
|
+
intent="destructive"
|
|
77
|
+
onclick={() => {
|
|
78
|
+
if (confirming) run(confirming);
|
|
79
|
+
confirming = null;
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
{confirming?.confirm?.confirmLabel ?? confirming?.label ?? "Confirm"}
|
|
83
|
+
</AlertDialogConfirm>
|
|
84
|
+
</AlertDialogFooter>
|
|
85
|
+
</AlertDialogContent>
|
|
86
|
+
</AlertDialog>
|
|
87
|
+
</div>
|
|
88
|
+
{/if}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RowData } from "@ui-organized/table-core";
|
|
2
|
+
import type { BulkAction } from "../../core/types.js";
|
|
3
|
+
declare function $$render<T extends RowData>(): {
|
|
4
|
+
props: {
|
|
5
|
+
actions?: BulkAction<T>[];
|
|
6
|
+
class?: string;
|
|
7
|
+
};
|
|
8
|
+
exports: {};
|
|
9
|
+
bindings: "";
|
|
10
|
+
slots: {};
|
|
11
|
+
events: {};
|
|
12
|
+
};
|
|
13
|
+
declare class __sveltets_Render<T extends RowData> {
|
|
14
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
15
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
16
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
17
|
+
bindings(): "";
|
|
18
|
+
exports(): {};
|
|
19
|
+
}
|
|
20
|
+
interface $$IsomorphicComponent {
|
|
21
|
+
new <T extends RowData>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
22
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
23
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
24
|
+
<T extends RowData>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
25
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
26
|
+
}
|
|
27
|
+
declare const TableSelectionBar: $$IsomorphicComponent;
|
|
28
|
+
type TableSelectionBar<T extends RowData> = InstanceType<typeof TableSelectionBar<T>>;
|
|
29
|
+
export default TableSelectionBar;
|
|
30
|
+
//# sourceMappingURL=TableSelectionBar.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableSelectionBar.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/TableSelectionBar/TableSelectionBar.svelte.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,iBAAS,QAAQ,CAAC,CAAC,SAAS,OAAO;;kBAMK,UAAU,CAAC,CAAC,CAAC,EAAE;gBAAU,MAAM;;;;;;EAwDkD;AACzH,cAAM,iBAAiB,CAAC,CAAC,SAAS,OAAO;IACrC,KAAK,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAChD,MAAM,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAClD,KAAK,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAChD,QAAQ;IACR,OAAO;CACV;AAED,UAAU,qBAAqB;IAC3B,KAAK,CAAC,SAAS,OAAO,EAAE,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;KAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC5Y,CAAC,CAAC,SAAS,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3I,YAAY,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;CACjE;AACD,QAAA,MAAM,iBAAiB,EAAE,qBAAmC,CAAC;AAC3C,KAAK,iBAAiB,CAAC,CAAC,SAAS,OAAO,IAAI,YAAY,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AACxF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/TableSelectionBar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TableSelectionBar } from "./TableSelectionBar.svelte";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Under the rows: how many are selected, and the offer to select the matching
|
|
3
|
+
rows that are not on screen.
|
|
4
|
+
|
|
5
|
+
At the bottom rather than in the toolbar, because that is where the user's
|
|
6
|
+
eye is once they have ticked down a page — and where the visible rows run out
|
|
7
|
+
is where "there are more of these" belongs. The bulk actions stay in the
|
|
8
|
+
toolbar (see `TableSelectionBar`).
|
|
9
|
+
|
|
10
|
+
The offer is a real button, and counts the rows it would *add*: "Select
|
|
11
|
+
99,981 hidden rows" says plainly that the ticks so far only reached what was
|
|
12
|
+
visible.
|
|
13
|
+
-->
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
import { clsx } from "clsx";
|
|
16
|
+
import { Button } from "@ui-organized/svelte";
|
|
17
|
+
import { selectHiddenLabel, selectionCountLabel } from "@ui-organized/table-core";
|
|
18
|
+
import { getTable } from "../../core/tableContext.js";
|
|
19
|
+
|
|
20
|
+
let { class: className }: { class?: string } = $props();
|
|
21
|
+
const table = getTable();
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
{#if table.selection.count > 0}
|
|
25
|
+
<div class={clsx("data-table__selection-footer", className)}>
|
|
26
|
+
<!-- Announced on change: ticking a row changes nothing else a screen
|
|
27
|
+
reader user would hear. -->
|
|
28
|
+
<span class="data-table__selection-count" aria-live="polite">
|
|
29
|
+
{selectionCountLabel(table.selection.count)}
|
|
30
|
+
</span>
|
|
31
|
+
|
|
32
|
+
{#if table.selection.canSelectAllMatching}
|
|
33
|
+
<Button size={table.size} intent="secondary" onclick={() => table.selection.selectAllMatching()}>
|
|
34
|
+
{selectHiddenLabel(table.selection.totalMatching, table.selection.count)}
|
|
35
|
+
</Button>
|
|
36
|
+
{/if}
|
|
37
|
+
</div>
|
|
38
|
+
{/if}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type $$ComponentProps = {
|
|
2
|
+
class?: string;
|
|
3
|
+
};
|
|
4
|
+
declare const TableSelectionFooter: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
5
|
+
type TableSelectionFooter = ReturnType<typeof TableSelectionFooter>;
|
|
6
|
+
export default TableSelectionFooter;
|
|
7
|
+
//# sourceMappingURL=TableSelectionFooter.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableSelectionFooter.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/TableSelectionFooter/TableSelectionFooter.svelte.ts"],"names":[],"mappings":"AAQC,KAAK,gBAAgB,GAAI;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA6B7C,QAAA,MAAM,oBAAoB,sDAAwC,CAAC;AACnE,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACpE,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/TableSelectionFooter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TableSelectionFooter } from "./TableSelectionFooter.svelte";
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Every filterable field at once, one accordion section each, so filtering on a
|
|
3
|
+
phone is "open the field, pick the value" rather than "add a filter, choose
|
|
4
|
+
its field, then pick the value".
|
|
5
|
+
|
|
6
|
+
Each section edits a real condition. While the sheet is open every field has
|
|
7
|
+
at least one, so its editor has something to write to: the sheet adds an
|
|
8
|
+
empty draft for any field without one. A draft is an incomplete condition,
|
|
9
|
+
which the filter model keeps but never applies, so drafts change nothing
|
|
10
|
+
until they are given a value; the badge counts only complete conditions; and
|
|
11
|
+
closing the sheet removes the drafts nobody filled in.
|
|
12
|
+
-->
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import { untrack } from "svelte";
|
|
15
|
+
import {
|
|
16
|
+
Accordion,
|
|
17
|
+
Button,
|
|
18
|
+
Sheet,
|
|
19
|
+
SheetClose,
|
|
20
|
+
SheetContent,
|
|
21
|
+
SheetFooter,
|
|
22
|
+
SheetTitle,
|
|
23
|
+
SheetTrigger,
|
|
24
|
+
} from "@ui-organized/svelte";
|
|
25
|
+
import type { AccordionItem } from "@ui-organized/svelte";
|
|
26
|
+
import { getTable } from "../../core/tableContext.js";
|
|
27
|
+
import TableFilterSheetCondition from "./TableFilterSheetCondition.svelte";
|
|
28
|
+
import TableSheetButton from "./TableSheetButton.svelte";
|
|
29
|
+
import { internalGlyph as glyph } from "@ui-organized/svelte";
|
|
30
|
+
|
|
31
|
+
let { label = "Filter", class: className }: { label?: string; class?: string } = $props();
|
|
32
|
+
const table = getTable();
|
|
33
|
+
|
|
34
|
+
let open = $state(false);
|
|
35
|
+
const fields = $derived(table.filters.fields);
|
|
36
|
+
const conditions = $derived(table.filters.conditions);
|
|
37
|
+
const applied = $derived(conditions.filter((c) => table.filters.describe(c).complete));
|
|
38
|
+
const count = $derived(applied.length);
|
|
39
|
+
|
|
40
|
+
// Re-run on every change while open, not just on opening: "Clear" empties a
|
|
41
|
+
// field, and that field then needs a fresh draft to keep its editor.
|
|
42
|
+
const missingKey = $derived(
|
|
43
|
+
open
|
|
44
|
+
? fields
|
|
45
|
+
.filter((field) => !conditions.some((c) => c.columnId === field.columnId))
|
|
46
|
+
.map((field) => field.columnId)
|
|
47
|
+
.join(",")
|
|
48
|
+
: "",
|
|
49
|
+
);
|
|
50
|
+
$effect(() => {
|
|
51
|
+
const key = missingKey;
|
|
52
|
+
if (!key) return;
|
|
53
|
+
untrack(() => {
|
|
54
|
+
for (const columnId of key.split(",")) table.filters.add(columnId);
|
|
55
|
+
// `filters.add` also marks the condition as being edited, which opens a
|
|
56
|
+
// chip's popover in table mode. There are no chips here; undo it.
|
|
57
|
+
table.filters.setEditing(null);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const onOpenChange = (next: boolean) => {
|
|
62
|
+
open = next;
|
|
63
|
+
if (!next) {
|
|
64
|
+
for (const condition of table.filters.conditions) {
|
|
65
|
+
if (!table.filters.describe(condition).complete) table.filters.remove(condition.id);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const items = $derived<AccordionItem[]>(
|
|
71
|
+
fields.map((field) => ({
|
|
72
|
+
value: field.columnId,
|
|
73
|
+
title: sectionTitle,
|
|
74
|
+
content: sectionContent,
|
|
75
|
+
})),
|
|
76
|
+
);
|
|
77
|
+
const fieldOf = (item: AccordionItem) => fields.find((f) => f.columnId === item.value);
|
|
78
|
+
const conditionsOf = (item: AccordionItem) => conditions.filter((c) => c.columnId === item.value);
|
|
79
|
+
const summaryOf = (item: AccordionItem) =>
|
|
80
|
+
conditionsOf(item)
|
|
81
|
+
.map((c) => table.filters.describe(c))
|
|
82
|
+
.filter((d) => d.complete)
|
|
83
|
+
.map((d) => `${d.relative} ${d.value}`)
|
|
84
|
+
.join("; ");
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
{#snippet sectionTitle(item: AccordionItem)}
|
|
88
|
+
{@const summary = summaryOf(item)}
|
|
89
|
+
<span class="data-table__sheet-section-title">
|
|
90
|
+
<span>{fieldOf(item)?.label}</span>
|
|
91
|
+
<!-- What is applied stays readable with the section collapsed. -->
|
|
92
|
+
{#if summary}<span class="data-table__sheet-section-summary">{summary}</span>{/if}
|
|
93
|
+
</span>
|
|
94
|
+
{/snippet}
|
|
95
|
+
|
|
96
|
+
{#snippet sectionContent(item: AccordionItem)}
|
|
97
|
+
<div class="data-table__sheet-section">
|
|
98
|
+
{#each conditionsOf(item) as condition (condition.id)}
|
|
99
|
+
<TableFilterSheetCondition {condition} fieldLabel={fieldOf(item)?.label ?? ""} />
|
|
100
|
+
{/each}
|
|
101
|
+
</div>
|
|
102
|
+
{/snippet}
|
|
103
|
+
|
|
104
|
+
{#if fields.length > 0}
|
|
105
|
+
<Sheet {open} {onOpenChange}>
|
|
106
|
+
<SheetTrigger>
|
|
107
|
+
{#snippet asChild(props)}
|
|
108
|
+
<TableSheetButton
|
|
109
|
+
{...props()}
|
|
110
|
+
icon={glyph("filter")}
|
|
111
|
+
{label}
|
|
112
|
+
{count}
|
|
113
|
+
unit="applied"
|
|
114
|
+
class={className}
|
|
115
|
+
/>
|
|
116
|
+
{/snippet}
|
|
117
|
+
</SheetTrigger>
|
|
118
|
+
<SheetContent side="bottom" size="lg" class="data-table__sheet">
|
|
119
|
+
<SheetTitle>{label}</SheetTitle>
|
|
120
|
+
<div class="data-table__sheet-body">
|
|
121
|
+
<!--
|
|
122
|
+
Every section starts collapsed, so the whole list of fields fits on
|
|
123
|
+
screen at once; each header says what it applies, so nothing is
|
|
124
|
+
hidden by being closed. Open one to edit it.
|
|
125
|
+
-->
|
|
126
|
+
<Accordion multiple class="data-table__sheet-sections" {items}
|
|
127
|
+
/>
|
|
128
|
+
</div>
|
|
129
|
+
<SheetFooter>
|
|
130
|
+
<Button
|
|
131
|
+
intent="ghost"
|
|
132
|
+
size="lg"
|
|
133
|
+
disabled={count === 0}
|
|
134
|
+
onclick={() => {
|
|
135
|
+
for (const condition of applied) table.filters.remove(condition.id);
|
|
136
|
+
}}
|
|
137
|
+
>
|
|
138
|
+
Clear all
|
|
139
|
+
</Button>
|
|
140
|
+
<SheetClose>
|
|
141
|
+
{#snippet asChild(props)}
|
|
142
|
+
<Button {...(props() as Record<string, never>)} intent="primary" size="lg">
|
|
143
|
+
Done
|
|
144
|
+
</Button>
|
|
145
|
+
{/snippet}
|
|
146
|
+
</SheetClose>
|
|
147
|
+
</SheetFooter>
|
|
148
|
+
</SheetContent>
|
|
149
|
+
</Sheet>
|
|
150
|
+
{/if}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type $$ComponentProps = {
|
|
2
|
+
label?: string;
|
|
3
|
+
class?: string;
|
|
4
|
+
};
|
|
5
|
+
declare const TableFilterSheet: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
6
|
+
type TableFilterSheet = ReturnType<typeof TableFilterSheet>;
|
|
7
|
+
export default TableFilterSheet;
|
|
8
|
+
//# sourceMappingURL=TableFilterSheet.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableFilterSheet.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/TableSheets/TableFilterSheet.svelte.ts"],"names":[],"mappings":"AAoBC,KAAK,gBAAgB,GAAI;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAqH7D,QAAA,MAAM,gBAAgB,sDAAwC,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
One condition inside a field's section: its relation, its value, and a way to
|
|
3
|
+
clear it. The field is the section, so there is no field control.
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { Button, Select } from "@ui-organized/svelte";
|
|
7
|
+
import type { TableFilterCondition } from "@ui-organized/table-core";
|
|
8
|
+
import { getTable } from "../../core/tableContext.js";
|
|
9
|
+
import TableFilterValueEditor from "../TableFilters/TableFilterValueEditor.svelte";
|
|
10
|
+
import { internalGlyph as glyph } from "@ui-organized/svelte";
|
|
11
|
+
|
|
12
|
+
let { condition, fieldLabel }: { condition: TableFilterCondition; fieldLabel: string } =
|
|
13
|
+
$props();
|
|
14
|
+
const table = getTable();
|
|
15
|
+
|
|
16
|
+
// The sheet is a modal dialog, which hides everything outside itself from
|
|
17
|
+
// assistive tech; a Select or Listbox that portals to <body> would be painted
|
|
18
|
+
// but unreachable. Portalling into the condition keeps it inside.
|
|
19
|
+
let container = $state<HTMLElement | null>(null);
|
|
20
|
+
const description = $derived(table.filters.describe(condition));
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<div class="data-table__sheet-filter" bind:this={container} data-filter-id={condition.id}>
|
|
24
|
+
<Select
|
|
25
|
+
size={table.size}
|
|
26
|
+
label="Condition"
|
|
27
|
+
options={table.filters
|
|
28
|
+
.operatorsFor(condition)
|
|
29
|
+
.map((op) => ({ value: op.id, label: op.label }))}
|
|
30
|
+
value={condition.operator}
|
|
31
|
+
onValueChange={(operator) => table.filters.update(condition.id, { operator })}
|
|
32
|
+
portalContainer={container}
|
|
33
|
+
/>
|
|
34
|
+
<div class="data-table__sheet-filter-value">
|
|
35
|
+
<TableFilterValueEditor
|
|
36
|
+
{condition}
|
|
37
|
+
arity={table.filters.arityOf(condition)}
|
|
38
|
+
portalContainer={container}
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
{#if description.complete}
|
|
42
|
+
<Button
|
|
43
|
+
intent="ghost"
|
|
44
|
+
size={table.size}
|
|
45
|
+
icon={glyph("close")}
|
|
46
|
+
class="data-table__sheet-remove"
|
|
47
|
+
aria-label={`Clear filter: ${description.text}`}
|
|
48
|
+
onclick={() => table.filters.remove(condition.id)}
|
|
49
|
+
>
|
|
50
|
+
{`Clear ${fieldLabel}`}
|
|
51
|
+
</Button>
|
|
52
|
+
{/if}
|
|
53
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TableFilterCondition } from "@ui-organized/table-core";
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
condition: TableFilterCondition;
|
|
4
|
+
fieldLabel: string;
|
|
5
|
+
};
|
|
6
|
+
declare const TableFilterSheetCondition: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type TableFilterSheetCondition = ReturnType<typeof TableFilterSheetCondition>;
|
|
8
|
+
export default TableFilterSheetCondition;
|
|
9
|
+
//# sourceMappingURL=TableFilterSheetCondition.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableFilterSheetCondition.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/TableSheets/TableFilterSheetCondition.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAKpE,KAAK,gBAAgB,GAAI;IAAE,SAAS,EAAE,oBAAoB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAoClF,QAAA,MAAM,yBAAyB,sDAAwC,CAAC;AACxE,KAAK,yBAAyB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC9E,eAAe,yBAAyB,CAAC"}
|