@lucasbernardosn/react-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 +21 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/components/column-menu/column-menu-check.d.ts +8 -0
- package/dist/components/column-menu/column-menu-check.d.ts.map +1 -0
- package/dist/components/column-menu/column-menu-check.js +17 -0
- package/dist/components/column-menu/column-menu-check.js.map +1 -0
- package/dist/components/column-menu/column-menu-hide-item.d.ts +23 -0
- package/dist/components/column-menu/column-menu-hide-item.d.ts.map +1 -0
- package/dist/components/column-menu/column-menu-hide-item.js +28 -0
- package/dist/components/column-menu/column-menu-hide-item.js.map +1 -0
- package/dist/components/column-menu/column-menu-labels.d.ts +21 -0
- package/dist/components/column-menu/column-menu-labels.d.ts.map +1 -0
- package/dist/components/column-menu/column-menu-labels.js +14 -0
- package/dist/components/column-menu/column-menu-labels.js.map +1 -0
- package/dist/components/column-menu/column-menu-pin-items.d.ts +25 -0
- package/dist/components/column-menu/column-menu-pin-items.d.ts.map +1 -0
- package/dist/components/column-menu/column-menu-pin-items.js +65 -0
- package/dist/components/column-menu/column-menu-pin-items.js.map +1 -0
- package/dist/components/column-menu/column-menu-popup.d.ts +39 -0
- package/dist/components/column-menu/column-menu-popup.d.ts.map +1 -0
- package/dist/components/column-menu/column-menu-popup.js +66 -0
- package/dist/components/column-menu/column-menu-popup.js.map +1 -0
- package/dist/components/column-menu/column-menu-root.d.ts +34 -0
- package/dist/components/column-menu/column-menu-root.d.ts.map +1 -0
- package/dist/components/column-menu/column-menu-root.js +36 -0
- package/dist/components/column-menu/column-menu-root.js.map +1 -0
- package/dist/components/column-menu/column-menu-sort-items.d.ts +29 -0
- package/dist/components/column-menu/column-menu-sort-items.d.ts.map +1 -0
- package/dist/components/column-menu/column-menu-sort-items.js +61 -0
- package/dist/components/column-menu/column-menu-sort-items.js.map +1 -0
- package/dist/components/column-menu/column-menu-trigger.d.ts +23 -0
- package/dist/components/column-menu/column-menu-trigger.d.ts.map +1 -0
- package/dist/components/column-menu/column-menu-trigger.js +38 -0
- package/dist/components/column-menu/column-menu-trigger.js.map +1 -0
- package/dist/components/column-menu/index.d.ts +2 -0
- package/dist/components/column-menu/index.js +2 -0
- package/dist/components/column-menu/index.parts.d.ts +13 -0
- package/dist/components/column-menu/index.parts.d.ts.map +1 -0
- package/dist/components/column-menu/index.parts.js +20 -0
- package/dist/components/column-menu/index.parts.js.map +1 -0
- package/dist/components/columns-panel/columns-panel-item.d.ts +31 -0
- package/dist/components/columns-panel/columns-panel-item.d.ts.map +1 -0
- package/dist/components/columns-panel/columns-panel-item.js +92 -0
- package/dist/components/columns-panel/columns-panel-item.js.map +1 -0
- package/dist/components/columns-panel/columns-panel-root.d.ts +51 -0
- package/dist/components/columns-panel/columns-panel-root.d.ts.map +1 -0
- package/dist/components/columns-panel/columns-panel-root.js +134 -0
- package/dist/components/columns-panel/columns-panel-root.js.map +1 -0
- package/dist/components/columns-panel/get-columns-panel-column-order.d.ts +16 -0
- package/dist/components/columns-panel/get-columns-panel-column-order.d.ts.map +1 -0
- package/dist/components/columns-panel/get-columns-panel-column-order.js +24 -0
- package/dist/components/columns-panel/get-columns-panel-column-order.js.map +1 -0
- package/dist/components/columns-panel/index.d.ts +2 -0
- package/dist/components/columns-panel/index.js +2 -0
- package/dist/components/columns-panel/index.parts.d.ts +8 -0
- package/dist/components/columns-panel/index.parts.d.ts.map +1 -0
- package/dist/components/columns-panel/index.parts.js +12 -0
- package/dist/components/columns-panel/index.parts.js.map +1 -0
- package/dist/components/data-table/body/data-table-body.d.ts +58 -0
- package/dist/components/data-table/body/data-table-body.d.ts.map +1 -0
- package/dist/components/data-table/body/data-table-body.js +99 -0
- package/dist/components/data-table/body/data-table-body.js.map +1 -0
- package/dist/components/data-table/body/data-table-cell.d.ts +26 -0
- package/dist/components/data-table/body/data-table-cell.d.ts.map +1 -0
- package/dist/components/data-table/body/data-table-cell.js +80 -0
- package/dist/components/data-table/body/data-table-cell.js.map +1 -0
- package/dist/components/data-table/body/data-table-empty.d.ts +38 -0
- package/dist/components/data-table/body/data-table-empty.d.ts.map +1 -0
- package/dist/components/data-table/body/data-table-empty.js +71 -0
- package/dist/components/data-table/body/data-table-empty.js.map +1 -0
- package/dist/components/data-table/body/data-table-row-focus.d.ts +32 -0
- package/dist/components/data-table/body/data-table-row-focus.d.ts.map +1 -0
- package/dist/components/data-table/body/data-table-row-focus.js +58 -0
- package/dist/components/data-table/body/data-table-row-focus.js.map +1 -0
- package/dist/components/data-table/body/data-table-row.d.ts +67 -0
- package/dist/components/data-table/body/data-table-row.d.ts.map +1 -0
- package/dist/components/data-table/body/data-table-row.js +150 -0
- package/dist/components/data-table/body/data-table-row.js.map +1 -0
- package/dist/components/data-table/body/use-data-table-row-focus-recovery.d.ts +19 -0
- package/dist/components/data-table/body/use-data-table-row-focus-recovery.d.ts.map +1 -0
- package/dist/components/data-table/body/use-data-table-row-focus-recovery.js +64 -0
- package/dist/components/data-table/body/use-data-table-row-focus-recovery.js.map +1 -0
- package/dist/components/data-table/header/data-table-header-button.d.ts +25 -0
- package/dist/components/data-table/header/data-table-header-button.d.ts.map +1 -0
- package/dist/components/data-table/header/data-table-header-button.js +57 -0
- package/dist/components/data-table/header/data-table-header-button.js.map +1 -0
- package/dist/components/data-table/header/data-table-header-cell.d.ts +34 -0
- package/dist/components/data-table/header/data-table-header-cell.d.ts.map +1 -0
- package/dist/components/data-table/header/data-table-header-cell.js +97 -0
- package/dist/components/data-table/header/data-table-header-cell.js.map +1 -0
- package/dist/components/data-table/header/data-table-header-content.d.ts +21 -0
- package/dist/components/data-table/header/data-table-header-content.d.ts.map +1 -0
- package/dist/components/data-table/header/data-table-header-content.js +37 -0
- package/dist/components/data-table/header/data-table-header-content.js.map +1 -0
- package/dist/components/data-table/header/data-table-header-row.d.ts +15 -0
- package/dist/components/data-table/header/data-table-header-row.d.ts.map +1 -0
- package/dist/components/data-table/header/data-table-header-row.js +28 -0
- package/dist/components/data-table/header/data-table-header-row.js.map +1 -0
- package/dist/components/data-table/header/data-table-header.d.ts +46 -0
- package/dist/components/data-table/header/data-table-header.d.ts.map +1 -0
- package/dist/components/data-table/header/data-table-header.js +80 -0
- package/dist/components/data-table/header/data-table-header.js.map +1 -0
- package/dist/components/data-table/index.d.ts +2 -0
- package/dist/components/data-table/index.js +2 -0
- package/dist/components/data-table/index.parts.d.ts +32 -0
- package/dist/components/data-table/index.parts.d.ts.map +1 -0
- package/dist/components/data-table/index.parts.js +60 -0
- package/dist/components/data-table/index.parts.js.map +1 -0
- package/dist/components/data-table/loading/get-data-table-loading-without-rows.d.ts +16 -0
- package/dist/components/data-table/loading/get-data-table-loading-without-rows.d.ts.map +1 -0
- package/dist/components/data-table/loading/get-data-table-loading-without-rows.js +18 -0
- package/dist/components/data-table/loading/get-data-table-loading-without-rows.js.map +1 -0
- package/dist/components/data-table/loading/use-data-table-loading-inert.d.ts +16 -0
- package/dist/components/data-table/loading/use-data-table-loading-inert.d.ts.map +1 -0
- package/dist/components/data-table/loading/use-data-table-loading-inert.js +54 -0
- package/dist/components/data-table/loading/use-data-table-loading-inert.js.map +1 -0
- package/dist/components/data-table/loading/use-data-table-loading.d.ts +13 -0
- package/dist/components/data-table/loading/use-data-table-loading.d.ts.map +1 -0
- package/dist/components/data-table/loading/use-data-table-loading.js +40 -0
- package/dist/components/data-table/loading/use-data-table-loading.js.map +1 -0
- package/dist/components/data-table/pagination/data-table-page-button.d.ts +45 -0
- package/dist/components/data-table/pagination/data-table-page-button.d.ts.map +1 -0
- package/dist/components/data-table/pagination/data-table-page-button.js +67 -0
- package/dist/components/data-table/pagination/data-table-page-button.js.map +1 -0
- package/dist/components/data-table/pagination/data-table-page-size-select.d.ts +47 -0
- package/dist/components/data-table/pagination/data-table-page-size-select.d.ts.map +1 -0
- package/dist/components/data-table/pagination/data-table-page-size-select.js +68 -0
- package/dist/components/data-table/pagination/data-table-page-size-select.js.map +1 -0
- package/dist/components/data-table/pagination/data-table-page-status.d.ts +43 -0
- package/dist/components/data-table/pagination/data-table-page-status.d.ts.map +1 -0
- package/dist/components/data-table/pagination/data-table-page-status.js +48 -0
- package/dist/components/data-table/pagination/data-table-page-status.js.map +1 -0
- package/dist/components/data-table/pagination/data-table-pagination.d.ts +38 -0
- package/dist/components/data-table/pagination/data-table-pagination.d.ts.map +1 -0
- package/dist/components/data-table/pagination/data-table-pagination.js +87 -0
- package/dist/components/data-table/pagination/data-table-pagination.js.map +1 -0
- package/dist/components/data-table/pagination/data-table-row-range.d.ts +49 -0
- package/dist/components/data-table/pagination/data-table-row-range.d.ts.map +1 -0
- package/dist/components/data-table/pagination/data-table-row-range.js +63 -0
- package/dist/components/data-table/pagination/data-table-row-range.js.map +1 -0
- package/dist/components/data-table/pagination/data-table-selected-count.d.ts +37 -0
- package/dist/components/data-table/pagination/data-table-selected-count.d.ts.map +1 -0
- package/dist/components/data-table/pagination/data-table-selected-count.js +44 -0
- package/dist/components/data-table/pagination/data-table-selected-count.js.map +1 -0
- package/dist/components/data-table/pagination/use-data-table-page-scroll-reset.d.ts +15 -0
- package/dist/components/data-table/pagination/use-data-table-page-scroll-reset.d.ts.map +1 -0
- package/dist/components/data-table/pagination/use-data-table-page-scroll-reset.js +38 -0
- package/dist/components/data-table/pagination/use-data-table-page-scroll-reset.js.map +1 -0
- package/dist/components/data-table/resize/data-table-resize-handle.d.ts +48 -0
- package/dist/components/data-table/resize/data-table-resize-handle.d.ts.map +1 -0
- package/dist/components/data-table/resize/data-table-resize-handle.js +115 -0
- package/dist/components/data-table/resize/data-table-resize-handle.js.map +1 -0
- package/dist/components/data-table/resize/use-data-table-resize-scroll.d.ts +18 -0
- package/dist/components/data-table/resize/use-data-table-resize-scroll.d.ts.map +1 -0
- package/dist/components/data-table/resize/use-data-table-resize-scroll.js +55 -0
- package/dist/components/data-table/resize/use-data-table-resize-scroll.js.map +1 -0
- package/dist/components/data-table/root/data-table-grid-classes.d.ts +10 -0
- package/dist/components/data-table/root/data-table-grid-classes.d.ts.map +1 -0
- package/dist/components/data-table/root/data-table-grid-classes.js +22 -0
- package/dist/components/data-table/root/data-table-grid-classes.js.map +1 -0
- package/dist/components/data-table/root/data-table-root.d.ts +41 -0
- package/dist/components/data-table/root/data-table-root.d.ts.map +1 -0
- package/dist/components/data-table/root/data-table-root.js +72 -0
- package/dist/components/data-table/root/data-table-root.js.map +1 -0
- package/dist/components/data-table/root/data-table-scroll-area.d.ts +21 -0
- package/dist/components/data-table/root/data-table-scroll-area.d.ts.map +1 -0
- package/dist/components/data-table/root/data-table-scroll-area.js +127 -0
- package/dist/components/data-table/root/data-table-scroll-area.js.map +1 -0
- package/dist/components/data-table/root/get-data-table-column-layout.d.ts +45 -0
- package/dist/components/data-table/root/get-data-table-column-layout.d.ts.map +1 -0
- package/dist/components/data-table/root/get-data-table-column-layout.js +55 -0
- package/dist/components/data-table/root/get-data-table-column-layout.js.map +1 -0
- package/dist/components/data-table/root/get-data-table-column-pinning.d.ts +46 -0
- package/dist/components/data-table/root/get-data-table-column-pinning.d.ts.map +1 -0
- package/dist/components/data-table/root/get-data-table-column-pinning.js +46 -0
- package/dist/components/data-table/root/get-data-table-column-pinning.js.map +1 -0
- package/dist/components/data-table/root/get-data-table-scroll-parent.d.ts +13 -0
- package/dist/components/data-table/root/get-data-table-scroll-parent.d.ts.map +1 -0
- package/dist/components/data-table/root/get-data-table-scroll-parent.js +20 -0
- package/dist/components/data-table/root/get-data-table-scroll-parent.js.map +1 -0
- package/dist/components/data-table/root/use-data-table-column-layout.d.ts +25 -0
- package/dist/components/data-table/root/use-data-table-column-layout.d.ts.map +1 -0
- package/dist/components/data-table/root/use-data-table-column-layout.js +106 -0
- package/dist/components/data-table/root/use-data-table-column-layout.js.map +1 -0
- package/dist/components/data-table/root/use-data-table-header-offset.d.ts +15 -0
- package/dist/components/data-table/root/use-data-table-header-offset.d.ts.map +1 -0
- package/dist/components/data-table/root/use-data-table-header-offset.js +35 -0
- package/dist/components/data-table/root/use-data-table-header-offset.js.map +1 -0
- package/dist/components/data-table/selection/data-table-row-checkbox.d.ts +33 -0
- package/dist/components/data-table/selection/data-table-row-checkbox.d.ts.map +1 -0
- package/dist/components/data-table/selection/data-table-row-checkbox.js +50 -0
- package/dist/components/data-table/selection/data-table-row-checkbox.js.map +1 -0
- package/dist/components/data-table/selection/data-table-select-all-checkbox.d.ts +31 -0
- package/dist/components/data-table/selection/data-table-select-all-checkbox.d.ts.map +1 -0
- package/dist/components/data-table/selection/data-table-select-all-checkbox.js +44 -0
- package/dist/components/data-table/selection/data-table-select-all-checkbox.js.map +1 -0
- package/dist/components/data-table/selection/selection-column-def.d.ts +54 -0
- package/dist/components/data-table/selection/selection-column-def.d.ts.map +1 -0
- package/dist/components/data-table/selection/selection-column-def.js +55 -0
- package/dist/components/data-table/selection/selection-column-def.js.map +1 -0
- package/dist/components/data-table/sorting/data-table-sort-indicator.d.ts +26 -0
- package/dist/components/data-table/sorting/data-table-sort-indicator.d.ts.map +1 -0
- package/dist/components/data-table/sorting/data-table-sort-indicator.js +64 -0
- package/dist/components/data-table/sorting/data-table-sort-indicator.js.map +1 -0
- package/dist/components/data-table/sorting/data-table-sort-trigger.d.ts +31 -0
- package/dist/components/data-table/sorting/data-table-sort-trigger.d.ts.map +1 -0
- package/dist/components/data-table/sorting/data-table-sort-trigger.js +46 -0
- package/dist/components/data-table/sorting/data-table-sort-trigger.js.map +1 -0
- package/dist/components/data-table/toolbar/data-table-density-select.d.ts +39 -0
- package/dist/components/data-table/toolbar/data-table-density-select.d.ts.map +1 -0
- package/dist/components/data-table/toolbar/data-table-density-select.js +60 -0
- package/dist/components/data-table/toolbar/data-table-density-select.js.map +1 -0
- package/dist/components/data-table/toolbar/data-table-sort-column-select.d.ts +47 -0
- package/dist/components/data-table/toolbar/data-table-sort-column-select.d.ts.map +1 -0
- package/dist/components/data-table/toolbar/data-table-sort-column-select.js +78 -0
- package/dist/components/data-table/toolbar/data-table-sort-column-select.js.map +1 -0
- package/dist/components/data-table/toolbar/data-table-sort-direction-select.d.ts +40 -0
- package/dist/components/data-table/toolbar/data-table-sort-direction-select.d.ts.map +1 -0
- package/dist/components/data-table/toolbar/data-table-sort-direction-select.js +66 -0
- package/dist/components/data-table/toolbar/data-table-sort-direction-select.js.map +1 -0
- package/dist/features/active-row/active-row-feature.d.ts +22 -0
- package/dist/features/active-row/active-row-feature.d.ts.map +1 -0
- package/dist/features/active-row/active-row-feature.js +55 -0
- package/dist/features/active-row/active-row-feature.js.map +1 -0
- package/dist/features/active-row/active-row-feature.types.d.ts +64 -0
- package/dist/features/active-row/active-row-feature.types.d.ts.map +1 -0
- package/dist/features/active-row/active-row-feature.types.js +0 -0
- package/dist/features/column-alignment/column-alignment-feature.d.ts +23 -0
- package/dist/features/column-alignment/column-alignment-feature.d.ts.map +1 -0
- package/dist/features/column-alignment/column-alignment-feature.js +34 -0
- package/dist/features/column-alignment/column-alignment-feature.js.map +1 -0
- package/dist/features/column-alignment/column-alignment-feature.types.d.ts +34 -0
- package/dist/features/column-alignment/column-alignment-feature.types.d.ts.map +1 -0
- package/dist/features/column-alignment/column-alignment-feature.types.js +0 -0
- package/dist/features/index.d.ts +9 -0
- package/dist/features/index.js +5 -0
- package/dist/features/loading/loading-feature.d.ts +30 -0
- package/dist/features/loading/loading-feature.d.ts.map +1 -0
- package/dist/features/loading/loading-feature.js +48 -0
- package/dist/features/loading/loading-feature.js.map +1 -0
- package/dist/features/loading/loading-feature.types.d.ts +50 -0
- package/dist/features/loading/loading-feature.types.d.ts.map +1 -0
- package/dist/features/loading/loading-feature.types.js +0 -0
- package/dist/features/row-density/row-density-feature.d.ts +26 -0
- package/dist/features/row-density/row-density-feature.d.ts.map +1 -0
- package/dist/features/row-density/row-density-feature.js +44 -0
- package/dist/features/row-density/row-density-feature.js.map +1 -0
- package/dist/features/row-density/row-density-feature.types.d.ts +53 -0
- package/dist/features/row-density/row-density-feature.types.d.ts.map +1 -0
- package/dist/features/row-density/row-density-feature.types.js +0 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +0 -0
- package/dist/types/table-with.d.ts +96 -0
- package/dist/types/table-with.d.ts.map +1 -0
- package/dist/types/table-with.js +0 -0
- package/dist/utils/get-default-column-label.d.ts +17 -0
- package/dist/utils/get-default-column-label.d.ts.map +1 -0
- package/dist/utils/get-default-column-label.js +18 -0
- package/dist/utils/get-default-column-label.js.map +1 -0
- package/dist/utils/has-feature.d.ts +54 -0
- package/dist/utils/has-feature.d.ts.map +1 -0
- package/dist/utils/has-feature.js +55 -0
- package/dist/utils/has-feature.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +3 -0
- package/package.json +80 -3
- package/README.md +0 -3
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { activeRowFeature } from "./active-row/active-row-feature.js";
|
|
2
|
+
import { columnAlignmentFeature } from "./column-alignment/column-alignment-feature.js";
|
|
3
|
+
import { loadingFeature } from "./loading/loading-feature.js";
|
|
4
|
+
import { rowDensityFeature } from "./row-density/row-density-feature.js";
|
|
5
|
+
export { activeRowFeature, columnAlignmentFeature, loadingFeature, rowDensityFeature };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TableFeature } from "@tanstack/react-table";
|
|
2
|
+
//#region src/features/loading/loading-feature.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Feature do TanStack Table para o carregamento dos dados. Registre com essa chave:
|
|
5
|
+
* `tableFeatures({ loadingFeature })`.
|
|
6
|
+
*
|
|
7
|
+
* Só guarda o estado: o `DataTable.Root` marca o grid enquanto carrega, o `DataTable.Body`
|
|
8
|
+
* bloqueia as linhas e, sem linhas, desenha linhas-fantasma.
|
|
9
|
+
*
|
|
10
|
+
* Carregar é ter na tela linhas que não são as da consulta atual: as de outra página ou ordem,
|
|
11
|
+
* à espera das novas, ou nenhuma na primeira carga. Uma busca em segundo plano que só confirma
|
|
12
|
+
* o que já está na tela não conta: marcá-la cobriria com o skeleton as linhas certas. No
|
|
13
|
+
* TanStack Query, com `placeholderData: keepPreviousData`, isso é `isPending || isPlaceholderData`,
|
|
14
|
+
* e não `isFetching`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const features = tableFeatures({ columnSizingFeature, loadingFeature });
|
|
19
|
+
*
|
|
20
|
+
* const table = useTable({
|
|
21
|
+
* features,
|
|
22
|
+
* columns,
|
|
23
|
+
* data: query.data ?? [],
|
|
24
|
+
* state: { isLoading: query.isPending || query.isPlaceholderData },
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const loadingFeature: TableFeature;
|
|
29
|
+
//#endregion
|
|
30
|
+
//# sourceMappingURL=loading-feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading-feature.d.ts","names":[],"sources":["../../../src/features/loading/loading-feature.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;qBAyCa,gBAAgB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { assignTableAPIs, makeStateUpdater, setStateSlice } from "@tanstack/react-table";
|
|
2
|
+
//#region src/features/loading/loading-feature.ts
|
|
3
|
+
/** O carregamento sem `initialState`. */
|
|
4
|
+
const DEFAULT_IS_LOADING = false;
|
|
5
|
+
/** O carregamento de um estado inicial, ou o padrão quando ele não traz. */
|
|
6
|
+
const getInitialIsLoading = (initialState) => initialState.isLoading ?? DEFAULT_IS_LOADING;
|
|
7
|
+
/**
|
|
8
|
+
* Feature do TanStack Table para o carregamento dos dados. Registre com essa chave:
|
|
9
|
+
* `tableFeatures({ loadingFeature })`.
|
|
10
|
+
*
|
|
11
|
+
* Só guarda o estado: o `DataTable.Root` marca o grid enquanto carrega, o `DataTable.Body`
|
|
12
|
+
* bloqueia as linhas e, sem linhas, desenha linhas-fantasma.
|
|
13
|
+
*
|
|
14
|
+
* Carregar é ter na tela linhas que não são as da consulta atual: as de outra página ou ordem,
|
|
15
|
+
* à espera das novas, ou nenhuma na primeira carga. Uma busca em segundo plano que só confirma
|
|
16
|
+
* o que já está na tela não conta: marcá-la cobriria com o skeleton as linhas certas. No
|
|
17
|
+
* TanStack Query, com `placeholderData: keepPreviousData`, isso é `isPending || isPlaceholderData`,
|
|
18
|
+
* e não `isFetching`.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const features = tableFeatures({ columnSizingFeature, loadingFeature });
|
|
23
|
+
*
|
|
24
|
+
* const table = useTable({
|
|
25
|
+
* features,
|
|
26
|
+
* columns,
|
|
27
|
+
* data: query.data ?? [],
|
|
28
|
+
* state: { isLoading: query.isPending || query.isPlaceholderData },
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
const loadingFeature = {
|
|
33
|
+
getInitialState: (initialState) => ({
|
|
34
|
+
isLoading: DEFAULT_IS_LOADING,
|
|
35
|
+
...initialState
|
|
36
|
+
}),
|
|
37
|
+
getDefaultTableOptions: (table) => ({ onIsLoadingChange: makeStateUpdater("isLoading", table) }),
|
|
38
|
+
constructTableAPIs: (table) => {
|
|
39
|
+
assignTableAPIs("loadingFeature", table, {
|
|
40
|
+
table_setIsLoading: { fn: (updater) => setStateSlice(table, "isLoading", updater) },
|
|
41
|
+
table_resetIsLoading: { fn: (defaultState) => setStateSlice(table, "isLoading", defaultState ? DEFAULT_IS_LOADING : getInitialIsLoading(table.initialState)) }
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { loadingFeature };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=loading-feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading-feature.js","names":[],"sources":["../../../src/features/loading/loading-feature.ts"],"sourcesContent":["import {\n assignTableAPIs,\n makeStateUpdater,\n setStateSlice,\n type TableFeature,\n type TableState_All,\n type Updater,\n} from '@tanstack/react-table';\n\n/** O carregamento sem `initialState`. */\nconst DEFAULT_IS_LOADING = false;\n\n/** O carregamento de um estado inicial, ou o padrão quando ele não traz. */\nconst getInitialIsLoading = (initialState: Partial<TableState_All>) =>\n initialState.isLoading ?? DEFAULT_IS_LOADING;\n\n/**\n * Feature do TanStack Table para o carregamento dos dados. Registre com essa chave:\n * `tableFeatures({ loadingFeature })`.\n *\n * Só guarda o estado: o `DataTable.Root` marca o grid enquanto carrega, o `DataTable.Body`\n * bloqueia as linhas e, sem linhas, desenha linhas-fantasma.\n *\n * Carregar é ter na tela linhas que não são as da consulta atual: as de outra página ou ordem,\n * à espera das novas, ou nenhuma na primeira carga. Uma busca em segundo plano que só confirma\n * o que já está na tela não conta: marcá-la cobriria com o skeleton as linhas certas. No\n * TanStack Query, com `placeholderData: keepPreviousData`, isso é `isPending || isPlaceholderData`,\n * e não `isFetching`.\n *\n * @example\n * ```ts\n * const features = tableFeatures({ columnSizingFeature, loadingFeature });\n *\n * const table = useTable({\n * features,\n * columns,\n * data: query.data ?? [],\n * state: { isLoading: query.isPending || query.isPlaceholderData },\n * });\n * ```\n */\nexport const loadingFeature: TableFeature = {\n getInitialState: (initialState) => ({\n isLoading: DEFAULT_IS_LOADING,\n ...initialState,\n }),\n\n getDefaultTableOptions: (table) => ({\n onIsLoadingChange: makeStateUpdater('isLoading', table),\n }),\n\n constructTableAPIs: (table) => {\n assignTableAPIs('loadingFeature', table, {\n table_setIsLoading: {\n fn: (updater: Updater<boolean>) =>\n setStateSlice(table, 'isLoading', updater),\n },\n table_resetIsLoading: {\n fn: (defaultState?: boolean) =>\n setStateSlice(\n table,\n 'isLoading',\n defaultState\n ? DEFAULT_IS_LOADING\n : getInitialIsLoading(table.initialState),\n ),\n },\n });\n },\n};\n"],"mappings":";;;AAUA,MAAM,qBAAqB;;AAG3B,MAAM,uBAAuB,iBAC3B,aAAa,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;AA2B5B,MAAa,iBAA+B;CAC1C,kBAAkB,kBAAkB;EAClC,WAAW;EACX,GAAG;CACL;CAEA,yBAAyB,WAAW,EAClC,mBAAmB,iBAAiB,aAAa,KAAK,EACxD;CAEA,qBAAqB,UAAU;EAC7B,gBAAgB,kBAAkB,OAAO;GACvC,oBAAoB,EAClB,KAAK,YACH,cAAc,OAAO,aAAa,OAAO,EAC7C;GACA,sBAAsB,EACpB,KAAK,iBACH,cACE,OACA,aACA,eACI,qBACA,oBAAoB,MAAM,YAAY,CAC5C,EACJ;EACF,CAAC;CACH;AACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { OnChangeFn, RowData, TableFeature, TableFeatures, Updater } from "@tanstack/react-table";
|
|
2
|
+
//#region src/features/loading/loading-feature.types.d.ts
|
|
3
|
+
/** O estado da feature. */
|
|
4
|
+
export type TableState_Loading = {
|
|
5
|
+
/**
|
|
6
|
+
* Se os dados da tabela estão carregando.
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
};
|
|
11
|
+
/** As opções da feature. */
|
|
12
|
+
export type TableOptions_Loading = {
|
|
13
|
+
/**
|
|
14
|
+
* Chamada a cada troca do carregamento, com o updater. Para ligar o carregamento ao da consulta
|
|
15
|
+
* do app, passe `state.isLoading` (ver a `loadingFeature`).
|
|
16
|
+
*/
|
|
17
|
+
onIsLoadingChange?: OnChangeFn<boolean>;
|
|
18
|
+
};
|
|
19
|
+
/** As APIs da feature na tabela. */
|
|
20
|
+
export type Table_Loading = {
|
|
21
|
+
/** Liga ou desliga o carregamento, com um valor ou um updater. */
|
|
22
|
+
setIsLoading: (updater: Updater<boolean>) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Volta o carregamento ao do `initialState`. Com `defaultState`, volta ao padrão da feature,
|
|
25
|
+
* `false`.
|
|
26
|
+
*/
|
|
27
|
+
resetIsLoading: (defaultState?: boolean) => void;
|
|
28
|
+
};
|
|
29
|
+
declare module '@tanstack/react-table' {
|
|
30
|
+
interface Plugins {
|
|
31
|
+
loadingFeature: TableFeature;
|
|
32
|
+
}
|
|
33
|
+
interface TableState_FeatureMap {
|
|
34
|
+
loadingFeature: TableState_Loading;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* O `TableState_All` não junta os plugins sozinho. Sem a chave aqui, o `setStateSlice` e a
|
|
38
|
+
* leitura do `initialState` dentro da feature não a conhecem. Opcional, como as chaves do
|
|
39
|
+
* TanStack.
|
|
40
|
+
*/
|
|
41
|
+
interface TableState_All extends Partial<TableState_Loading> {}
|
|
42
|
+
interface TableOptions_FeatureMap<TFeatures extends TableFeatures, TData extends RowData> {
|
|
43
|
+
loadingFeature: TableOptions_Loading;
|
|
44
|
+
}
|
|
45
|
+
interface Table_FeatureMap<TFeatures extends TableFeatures, TData extends RowData> {
|
|
46
|
+
loadingFeature: Table_Loading;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//# sourceMappingURL=loading-feature.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading-feature.types.d.ts","names":[],"sources":["../../../src/features/loading/loading-feature.types.ts"],"mappings":";;;YAUY;;;;;EAKV;;;YAIU;;;;;EAKV,oBAAoB;;;YAIV;;EAEV,eAAe,SAAS;;;;;EAKxB,iBAAiB;;;YASP;IACR,gBAAgB;;YAGR;IACR,gBAAgB;;;;;;;YAQR,uBAAuB,QAAQ;YAE/B,wBACR,kBAAkB,eAClB,cAAc;IAEd,gBAAgB;;YAGR,iBACR,kBAAkB,eAClB,cAAc;IAEd,gBAAgB"}
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TableFeature } from "@tanstack/react-table";
|
|
2
|
+
//#region src/features/row-density/row-density-feature.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Feature do TanStack Table para a densidade das linhas. Registre com essa chave:
|
|
5
|
+
* `tableFeatures({ rowDensityFeature })`.
|
|
6
|
+
*
|
|
7
|
+
* Só guarda o estado: o `DataTable.Root` o lê e marca o grid com `data-density`, de onde as
|
|
8
|
+
* células tiram altura e espaçamento.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const features = tableFeatures({ columnSizingFeature, rowDensityFeature });
|
|
13
|
+
*
|
|
14
|
+
* const table = useTable({
|
|
15
|
+
* features,
|
|
16
|
+
* columns,
|
|
17
|
+
* data,
|
|
18
|
+
* initialState: { rowDensity: 'compact' },
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* table.setRowDensity('comfortable');
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const rowDensityFeature: TableFeature;
|
|
25
|
+
//#endregion
|
|
26
|
+
//# sourceMappingURL=row-density-feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-density-feature.d.ts","names":[],"sources":["../../../src/features/row-density/row-density-feature.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;qBAsCa,mBAAmB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { assignTableAPIs, makeStateUpdater, setStateSlice } from "@tanstack/react-table";
|
|
2
|
+
//#region src/features/row-density/row-density-feature.ts
|
|
3
|
+
/** A densidade sem `initialState`. */
|
|
4
|
+
const DEFAULT_ROW_DENSITY = "standard";
|
|
5
|
+
/** A densidade de um estado inicial, ou a padrão quando ele não traz. */
|
|
6
|
+
const getInitialRowDensity = (initialState) => initialState.rowDensity ?? DEFAULT_ROW_DENSITY;
|
|
7
|
+
/**
|
|
8
|
+
* Feature do TanStack Table para a densidade das linhas. Registre com essa chave:
|
|
9
|
+
* `tableFeatures({ rowDensityFeature })`.
|
|
10
|
+
*
|
|
11
|
+
* Só guarda o estado: o `DataTable.Root` o lê e marca o grid com `data-density`, de onde as
|
|
12
|
+
* células tiram altura e espaçamento.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const features = tableFeatures({ columnSizingFeature, rowDensityFeature });
|
|
17
|
+
*
|
|
18
|
+
* const table = useTable({
|
|
19
|
+
* features,
|
|
20
|
+
* columns,
|
|
21
|
+
* data,
|
|
22
|
+
* initialState: { rowDensity: 'compact' },
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* table.setRowDensity('comfortable');
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
const rowDensityFeature = {
|
|
29
|
+
getInitialState: (initialState) => ({
|
|
30
|
+
rowDensity: DEFAULT_ROW_DENSITY,
|
|
31
|
+
...initialState
|
|
32
|
+
}),
|
|
33
|
+
getDefaultTableOptions: (table) => ({ onRowDensityChange: makeStateUpdater("rowDensity", table) }),
|
|
34
|
+
constructTableAPIs: (table) => {
|
|
35
|
+
assignTableAPIs("rowDensityFeature", table, {
|
|
36
|
+
table_setRowDensity: { fn: (updater) => setStateSlice(table, "rowDensity", updater) },
|
|
37
|
+
table_resetRowDensity: { fn: (defaultState) => setStateSlice(table, "rowDensity", defaultState ? DEFAULT_ROW_DENSITY : getInitialRowDensity(table.initialState)) }
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { rowDensityFeature };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=row-density-feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-density-feature.js","names":[],"sources":["../../../src/features/row-density/row-density-feature.ts"],"sourcesContent":["import {\n assignTableAPIs,\n makeStateUpdater,\n setStateSlice,\n type TableFeature,\n type TableState_All,\n type Updater,\n} from '@tanstack/react-table';\nimport type { RowDensity } from './row-density-feature.types';\n\n/** A densidade sem `initialState`. */\nconst DEFAULT_ROW_DENSITY: RowDensity = 'standard';\n\n/** A densidade de um estado inicial, ou a padrão quando ele não traz. */\nconst getInitialRowDensity = (initialState: Partial<TableState_All>) =>\n initialState.rowDensity ?? DEFAULT_ROW_DENSITY;\n\n/**\n * Feature do TanStack Table para a densidade das linhas. Registre com essa chave:\n * `tableFeatures({ rowDensityFeature })`.\n *\n * Só guarda o estado: o `DataTable.Root` o lê e marca o grid com `data-density`, de onde as\n * células tiram altura e espaçamento.\n *\n * @example\n * ```ts\n * const features = tableFeatures({ columnSizingFeature, rowDensityFeature });\n *\n * const table = useTable({\n * features,\n * columns,\n * data,\n * initialState: { rowDensity: 'compact' },\n * });\n *\n * table.setRowDensity('comfortable');\n * ```\n */\nexport const rowDensityFeature: TableFeature = {\n getInitialState: (initialState) => ({\n rowDensity: DEFAULT_ROW_DENSITY,\n ...initialState,\n }),\n\n getDefaultTableOptions: (table) => ({\n onRowDensityChange: makeStateUpdater('rowDensity', table),\n }),\n\n constructTableAPIs: (table) => {\n assignTableAPIs('rowDensityFeature', table, {\n table_setRowDensity: {\n fn: (updater: Updater<RowDensity>) =>\n setStateSlice(table, 'rowDensity', updater),\n },\n table_resetRowDensity: {\n fn: (defaultState?: boolean) =>\n setStateSlice(\n table,\n 'rowDensity',\n defaultState\n ? DEFAULT_ROW_DENSITY\n : getInitialRowDensity(table.initialState),\n ),\n },\n });\n },\n};\n"],"mappings":";;;AAWA,MAAM,sBAAkC;;AAGxC,MAAM,wBAAwB,iBAC5B,aAAa,cAAc;;;;;;;;;;;;;;;;;;;;;;AAuB7B,MAAa,oBAAkC;CAC7C,kBAAkB,kBAAkB;EAClC,YAAY;EACZ,GAAG;CACL;CAEA,yBAAyB,WAAW,EAClC,oBAAoB,iBAAiB,cAAc,KAAK,EAC1D;CAEA,qBAAqB,UAAU;EAC7B,gBAAgB,qBAAqB,OAAO;GAC1C,qBAAqB,EACnB,KAAK,YACH,cAAc,OAAO,cAAc,OAAO,EAC9C;GACA,uBAAuB,EACrB,KAAK,iBACH,cACE,OACA,cACA,eACI,sBACA,qBAAqB,MAAM,YAAY,CAC7C,EACJ;EACF,CAAC;CACH;AACF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { OnChangeFn, RowData, TableFeature, TableFeatures, Updater } from "@tanstack/react-table";
|
|
2
|
+
//#region src/features/row-density/row-density-feature.types.d.ts
|
|
3
|
+
/** A densidade das linhas: altura e espaçamento de células e headers. */
|
|
4
|
+
export type RowDensity = 'compact' | 'standard' | 'comfortable';
|
|
5
|
+
/** O estado da feature. */
|
|
6
|
+
export type TableState_RowDensity = {
|
|
7
|
+
/**
|
|
8
|
+
* A densidade das linhas.
|
|
9
|
+
* @default 'standard'
|
|
10
|
+
*/
|
|
11
|
+
rowDensity: RowDensity;
|
|
12
|
+
};
|
|
13
|
+
/** As opções da feature. */
|
|
14
|
+
export type TableOptions_RowDensity = {
|
|
15
|
+
/**
|
|
16
|
+
* Chamada a cada troca da densidade, com o updater. Sem ela, a tabela guarda a densidade
|
|
17
|
+
* sozinha. Para controlar o estado (ex.: guardar a preferência do usuário), passe esta função e
|
|
18
|
+
* `state.rowDensity`.
|
|
19
|
+
*/
|
|
20
|
+
onRowDensityChange?: OnChangeFn<RowDensity>;
|
|
21
|
+
};
|
|
22
|
+
/** As APIs da feature na tabela. */
|
|
23
|
+
export type Table_RowDensity = {
|
|
24
|
+
/** Troca a densidade, com um valor ou um updater. */
|
|
25
|
+
setRowDensity: (updater: Updater<RowDensity>) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Volta a densidade à do `initialState`. Com `defaultState`, volta ao padrão da feature,
|
|
28
|
+
* `'standard'`.
|
|
29
|
+
*/
|
|
30
|
+
resetRowDensity: (defaultState?: boolean) => void;
|
|
31
|
+
};
|
|
32
|
+
declare module '@tanstack/react-table' {
|
|
33
|
+
interface Plugins {
|
|
34
|
+
rowDensityFeature: TableFeature;
|
|
35
|
+
}
|
|
36
|
+
interface TableState_FeatureMap {
|
|
37
|
+
rowDensityFeature: TableState_RowDensity;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* O `TableState_All` não junta os plugins sozinho. Sem a chave aqui, o `setStateSlice` e a
|
|
41
|
+
* leitura do `initialState` dentro da feature não a conhecem. Opcional, como as chaves do
|
|
42
|
+
* TanStack.
|
|
43
|
+
*/
|
|
44
|
+
interface TableState_All extends Partial<TableState_RowDensity> {}
|
|
45
|
+
interface TableOptions_FeatureMap<TFeatures extends TableFeatures, TData extends RowData> {
|
|
46
|
+
rowDensityFeature: TableOptions_RowDensity;
|
|
47
|
+
}
|
|
48
|
+
interface Table_FeatureMap<TFeatures extends TableFeatures, TData extends RowData> {
|
|
49
|
+
rowDensityFeature: Table_RowDensity;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//# sourceMappingURL=row-density-feature.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-density-feature.types.d.ts","names":[],"sources":["../../../src/features/row-density/row-density-feature.types.ts"],"mappings":";;;YAUY;;YAGA;;;;;EAKV,YAAY;;;YAIF;;;;;;EAMV,qBAAqB,WAAW;;;YAItB;;EAEV,gBAAgB,SAAS,QAAQ;;;;;EAKjC,kBAAkB;;;YASR;IACR,mBAAmB;;YAGX;IACR,mBAAmB;;;;;;;YAQX,uBAAuB,QAAQ;YAE/B,wBACR,kBAAkB,eAClB,cAAc;IAEd,mBAAmB;;YAGX,iBACR,kBAAkB,eAClB,cAAc;IAEd,mBAAmB"}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Atoms, CellData, Column, Column_FeatureMap, Header, Header_FeatureMap, Plugins, Row, RowData, Row_FeatureMap, StockFeatures, Table, TableFeature, TableFeatures, TableOptions_FeatureMap, Table_FeatureMap, UnionToIntersection } from "@tanstack/react-table";
|
|
2
|
+
//#region src/types/table-with.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Nome de uma feature da tabela: do TanStack (`rowSortingFeature`, `columnSizingFeature`…) ou
|
|
5
|
+
* própria, registrada por declaration merging no `Plugins`. Vem do registro, e não de um
|
|
6
|
+
* FeatureMap: uma feature sem API de tabela, como a de alinhamento, ficaria de fora.
|
|
7
|
+
*/
|
|
8
|
+
export type TableFeatureKey = keyof StockFeatures | keyof Plugins;
|
|
9
|
+
/**
|
|
10
|
+
* As interfaces de um FeatureMap para as features pedidas, intersectadas. Sem nenhuma entrada no
|
|
11
|
+
* mapa, `unknown`, que é neutro na interseção.
|
|
12
|
+
*/
|
|
13
|
+
type FeatureMapTypes<TFeatureMap, TKey> = [Extract<TKey, keyof TFeatureMap>] extends [never] ? unknown : UnionToIntersection<TFeatureMap[Extract<TKey, keyof TFeatureMap>]>;
|
|
14
|
+
/**
|
|
15
|
+
* Os atoms do estado das features pedidas. O `Atoms<TFeatures>` também é derivado do condicional,
|
|
16
|
+
* então os atoms vêm de um conjunto concreto com só essas features.
|
|
17
|
+
*/
|
|
18
|
+
type FeatureAtoms<TKey extends TableFeatureKey> = Atoms<{ [K in TKey & keyof TableFeatures]: TableFeature; }>;
|
|
19
|
+
/**
|
|
20
|
+
* Tabela com as features `TKey`: as APIs de tabela delas, os atoms do estado
|
|
21
|
+
* (`table.atoms.pagination`) e as opções (`table.options.manualPagination`). Aceita a tabela do
|
|
22
|
+
* `useTable` e a dos contextos de célula e de header.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* const PageStatus = <TFeatures extends TableFeatures, TData extends RowData>(props: {
|
|
27
|
+
* table: TableWith<TFeatures, TData, 'rowPaginationFeature'>;
|
|
28
|
+
* }) => <span>{props.table.getPageCount()} páginas</span>;
|
|
29
|
+
*
|
|
30
|
+
* <PageStatus table={table} />
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export type TableWith<TFeatures extends TableFeatures, TData extends RowData, TKey extends TableFeatureKey> = Table<TFeatures, TData> & FeatureMapTypes<Table_FeatureMap<TFeatures, TData>, TKey> & {
|
|
34
|
+
atoms: FeatureAtoms<TKey>;
|
|
35
|
+
options: FeatureMapTypes<TableOptions_FeatureMap<TFeatures, TData>, TKey>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Coluna com as APIs de coluna das features `TKey`, e a `table` dela com as de tabela e os atoms
|
|
39
|
+
* das mesmas features. Aceita `header.column`, `cell.column` e os itens de `getAllLeafColumns()`.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* const SortButton = <TFeatures extends TableFeatures, TData extends RowData>(props: {
|
|
44
|
+
* column: ColumnWith<TFeatures, TData, 'rowSortingFeature'>;
|
|
45
|
+
* }) => <button onClick={props.column.getToggleSortingHandler()}>Ordenar</button>;
|
|
46
|
+
*
|
|
47
|
+
* <SortButton column={header.column} />
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export type ColumnWith<TFeatures extends TableFeatures, TData extends RowData, TKey extends TableFeatureKey, TValue = unknown> = Column<TFeatures, TData, TValue> & FeatureMapTypes<Column_FeatureMap<TFeatures, TData>, TKey> & {
|
|
51
|
+
table: TableWith<TFeatures, TData, TKey>;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Header com as APIs de header das features `TKey`, e a `column` dele com as de coluna das
|
|
55
|
+
* mesmas features. Aceita os headers de `getHeaderGroups()` e o do contexto de header.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* const ResizeHandle = <TFeatures extends TableFeatures, TData extends RowData>(props: {
|
|
60
|
+
* header: HeaderWith<TFeatures, TData, 'columnResizingFeature' | 'columnSizingFeature'>;
|
|
61
|
+
* }) =>
|
|
62
|
+
* props.header.column.getCanResize() ? (
|
|
63
|
+
* <div onMouseDown={props.header.getResizeHandler()} />
|
|
64
|
+
* ) : null;
|
|
65
|
+
*
|
|
66
|
+
* <ResizeHandle header={header} />
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export type HeaderWith<TFeatures extends TableFeatures, TData extends RowData, TKey extends TableFeatureKey, TValue extends CellData = CellData> = Header<TFeatures, TData, TValue> & FeatureMapTypes<Header_FeatureMap, TKey> & {
|
|
70
|
+
column: ColumnWith<TFeatures, TData, TKey, TValue>;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Linha com as APIs de linha das features `TKey`, e a `table` dela com as de tabela e os atoms
|
|
74
|
+
* das mesmas features. Aceita as linhas de `getRowModel().rows`, `cell.row` e a do contexto de
|
|
75
|
+
* célula.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```tsx
|
|
79
|
+
* const RowCheckbox = <TFeatures extends TableFeatures, TData extends RowData>(props: {
|
|
80
|
+
* row: RowWith<TFeatures, TData, 'rowSelectionFeature'>;
|
|
81
|
+
* }) => (
|
|
82
|
+
* <input
|
|
83
|
+
* type="checkbox"
|
|
84
|
+
* checked={props.row.getIsSelected()}
|
|
85
|
+
* onChange={props.row.getToggleSelectedHandler()}
|
|
86
|
+
* />
|
|
87
|
+
* );
|
|
88
|
+
*
|
|
89
|
+
* columnHelper.display({ id: 'select', cell: ({ row }) => <RowCheckbox row={row} /> });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export type RowWith<TFeatures extends TableFeatures, TData extends RowData, TKey extends TableFeatureKey> = Row<TFeatures, TData> & FeatureMapTypes<Row_FeatureMap<TFeatures, TData>, TKey> & {
|
|
93
|
+
table: TableWith<TFeatures, TData, TKey>;
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
//# sourceMappingURL=table-with.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-with.d.ts","names":[],"sources":["../../src/types/table-with.ts"],"mappings":";;;;;;;YAwCY,wBAAwB,sBAAsB;;;;;KAMrD,gBAAgB,aAAa,SAChC,QAAQ,YAAY,0CAGlB,oBAAoB,YAAY,QAAQ,YAAY;;;;;KAMnD,aAAa,aAAa,mBAAmB,SAC/C,KAAK,aAAa,gBAAgB;;;;;;;;;;;;;;;YAiBzB,UACV,kBAAkB,eAClB,cAAc,SACd,aAAa,mBACX,MAAM,WAAW,SACnB,gBAAgB,iBAAiB,WAAW,QAAQ;EAClD,OAAO,aAAa;EACpB,SAAS,gBAAgB,wBAAwB,WAAW,QAAQ;;;;;;;;;;;;;;;YAgB5D,WACV,kBAAkB,eAClB,cAAc,SACd,aAAa,iBACb,oBACE,OAAO,WAAW,OAAO,UAC3B,gBAAgB,kBAAkB,WAAW,QAAQ;EACnD,OAAO,UAAU,WAAW,OAAO;;;;;;;;;;;;;;;;;;YAmB3B,WACV,kBAAkB,eAClB,cAAc,SACd,aAAa,iBACb,eAAe,WAAW,YACxB,OAAO,WAAW,OAAO,UAC3B,gBAAgB,mBAAmB;EACjC,QAAQ,WAAW,WAAW,OAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;YAuBnC,QACV,kBAAkB,eAClB,cAAc,SACd,aAAa,mBACX,IAAI,WAAW,SACjB,gBAAgB,eAAe,WAAW,QAAQ;EAChD,OAAO,UAAU,WAAW,OAAO"}
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Column, RowData, TableFeatures } from "@tanstack/react-table";
|
|
2
|
+
//#region src/utils/get-default-column-label.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* O nome de uma coluna fora do cabeçalho: o `header` quando é texto, e o id quando não é (um
|
|
5
|
+
* `header` em função ou nenhum). É o nome padrão das partes que listam colunas, como o
|
|
6
|
+
* `ColumnsPanel.Item` e o `DataTable.SortColumnSelect`; o app o usa para mostrar o mesmo nome em
|
|
7
|
+
* outro lugar, ou como base de um `getLabel` próprio.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const getLabel = (column: Column<typeof features, Person>) =>
|
|
12
|
+
* labels[column.id] ?? getDefaultColumnLabel(column);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const getDefaultColumnLabel: <TFeatures extends TableFeatures, TData extends RowData, TValue>(column: Column<TFeatures, TData, TValue>) => string;
|
|
16
|
+
//#endregion
|
|
17
|
+
//# sourceMappingURL=get-default-column-label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-default-column-label.d.ts","names":[],"sources":["../../src/utils/get-default-column-label.ts"],"mappings":";;;;;;;;;;;;;;qBAca,wBACX,kBAAkB,eAClB,cAAc,SACd,QAEA,QAAQ,OAAO,WAAW,OAAO"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/utils/get-default-column-label.ts
|
|
2
|
+
/**
|
|
3
|
+
* O nome de uma coluna fora do cabeçalho: o `header` quando é texto, e o id quando não é (um
|
|
4
|
+
* `header` em função ou nenhum). É o nome padrão das partes que listam colunas, como o
|
|
5
|
+
* `ColumnsPanel.Item` e o `DataTable.SortColumnSelect`; o app o usa para mostrar o mesmo nome em
|
|
6
|
+
* outro lugar, ou como base de um `getLabel` próprio.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const getLabel = (column: Column<typeof features, Person>) =>
|
|
11
|
+
* labels[column.id] ?? getDefaultColumnLabel(column);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
const getDefaultColumnLabel = (column) => typeof column.columnDef.header === "string" ? column.columnDef.header : column.id;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { getDefaultColumnLabel };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=get-default-column-label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-default-column-label.js","names":[],"sources":["../../src/utils/get-default-column-label.ts"],"sourcesContent":["import type { Column, RowData, TableFeatures } from '@tanstack/react-table';\n\n/**\n * O nome de uma coluna fora do cabeçalho: o `header` quando é texto, e o id quando não é (um\n * `header` em função ou nenhum). É o nome padrão das partes que listam colunas, como o\n * `ColumnsPanel.Item` e o `DataTable.SortColumnSelect`; o app o usa para mostrar o mesmo nome em\n * outro lugar, ou como base de um `getLabel` próprio.\n *\n * @example\n * ```ts\n * const getLabel = (column: Column<typeof features, Person>) =>\n * labels[column.id] ?? getDefaultColumnLabel(column);\n * ```\n */\nexport const getDefaultColumnLabel = <\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n>(\n column: Column<TFeatures, TData, TValue>,\n) =>\n typeof column.columnDef.header === 'string'\n ? column.columnDef.header\n : column.id;\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,yBAKX,WAEA,OAAO,OAAO,UAAU,WAAW,WAC/B,OAAO,UAAU,SACjB,OAAO"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ColumnWith, HeaderWith, RowWith, TableFeatureKey, TableWith } from "../types/table-with.js";
|
|
2
|
+
import "../types/index.js";
|
|
3
|
+
import { CellData, Column, Header, Row, RowData, Table, TableFeatures } from "@tanstack/react-table";
|
|
4
|
+
//#region src/utils/has-feature.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Se a tabela registrou as features pedidas. Estreita a tabela para as APIs e os atoms só dessas
|
|
7
|
+
* features: para uma parte que se adapta a uma feature que não exige.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* if (hasTableFeature(table, 'rowPaginationFeature')) {
|
|
12
|
+
* table.getPageCount();
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const hasTableFeature: <TFeatures extends TableFeatures, TData extends RowData, TKey extends TableFeatureKey>(table: Table<TFeatures, TData>, ...keys: TKey[]) => table is TableWith<TFeatures, TData, TKey>;
|
|
17
|
+
/**
|
|
18
|
+
* Se a tabela do header registrou as features pedidas. Estreita o header, e a `column` dele, para
|
|
19
|
+
* as APIs só dessas features.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* if (hasHeaderFeature(header, 'columnSizingFeature')) {
|
|
24
|
+
* header.getSize();
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const hasHeaderFeature: <TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData, TKey extends TableFeatureKey>(header: Header<TFeatures, TData, TValue>, ...keys: TKey[]) => header is HeaderWith<TFeatures, TData, TKey, TValue>;
|
|
29
|
+
/**
|
|
30
|
+
* Se a tabela da coluna registrou as features pedidas. Estreita a coluna para as APIs só dessas
|
|
31
|
+
* features.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* if (hasColumnFeature(cell.column, 'columnPinningFeature')) {
|
|
36
|
+
* cell.column.getIsPinned();
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare const hasColumnFeature: <TFeatures extends TableFeatures, TData extends RowData, TValue, TKey extends TableFeatureKey>(column: Column<TFeatures, TData, TValue>, ...keys: TKey[]) => column is ColumnWith<TFeatures, TData, TKey, TValue>;
|
|
41
|
+
/**
|
|
42
|
+
* Se a tabela da linha registrou as features pedidas. Estreita a linha para as APIs só dessas
|
|
43
|
+
* features.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* if (hasRowFeature(row, 'columnVisibilityFeature')) {
|
|
48
|
+
* row.getVisibleCells();
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare const hasRowFeature: <TFeatures extends TableFeatures, TData extends RowData, TKey extends TableFeatureKey>(row: Row<TFeatures, TData>, ...keys: TKey[]) => row is RowWith<TFeatures, TData, TKey>;
|
|
53
|
+
//#endregion
|
|
54
|
+
//# sourceMappingURL=has-feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-feature.d.ts","names":[],"sources":["../../src/utils/has-feature.ts"],"mappings":";;;;;;;;;;;;;;;qBA4Ca,kBACX,kBAAkB,eAClB,cAAc,SACd,aAAa,iBAEb,OAAO,MAAM,WAAW,WACrB,MAAM,WACR,SAAS,UAAU,WAAW,OAAO;;;;;;;;;;;;qBAc3B,mBACX,kBAAkB,eAClB,cAAc,SACd,eAAe,UACf,aAAa,iBAEb,QAAQ,OAAO,WAAW,OAAO,YAC9B,MAAM,WACR,UAAU,WAAW,WAAW,OAAO,MAAM;;;;;;;;;;;;qBAcnC,mBACX,kBAAkB,eAClB,cAAc,SACd,QACA,aAAa,iBAEb,QAAQ,OAAO,WAAW,OAAO,YAC9B,MAAM,WACR,UAAU,WAAW,WAAW,OAAO,MAAM;;;;;;;;;;;;qBAcnC,gBACX,kBAAkB,eAClB,cAAc,SACd,aAAa,iBAEb,KAAK,IAAI,WAAW,WACjB,MAAM,WACR,OAAO,QAAQ,WAAW,OAAO"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//#region src/utils/has-feature.ts
|
|
2
|
+
/** Se todas as features pedidas estão entre as registradas pelo app. */
|
|
3
|
+
const hasFeatures = (features, keys) => keys.every((key) => key in features);
|
|
4
|
+
/**
|
|
5
|
+
* Se a tabela registrou as features pedidas. Estreita a tabela para as APIs e os atoms só dessas
|
|
6
|
+
* features: para uma parte que se adapta a uma feature que não exige.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* if (hasTableFeature(table, 'rowPaginationFeature')) {
|
|
11
|
+
* table.getPageCount();
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
const hasTableFeature = (table, ...keys) => hasFeatures(table.options.features, keys);
|
|
16
|
+
/**
|
|
17
|
+
* Se a tabela do header registrou as features pedidas. Estreita o header, e a `column` dele, para
|
|
18
|
+
* as APIs só dessas features.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* if (hasHeaderFeature(header, 'columnSizingFeature')) {
|
|
23
|
+
* header.getSize();
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
const hasHeaderFeature = (header, ...keys) => hasFeatures(header.table.options.features, keys);
|
|
28
|
+
/**
|
|
29
|
+
* Se a tabela da coluna registrou as features pedidas. Estreita a coluna para as APIs só dessas
|
|
30
|
+
* features.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* if (hasColumnFeature(cell.column, 'columnPinningFeature')) {
|
|
35
|
+
* cell.column.getIsPinned();
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
const hasColumnFeature = (column, ...keys) => hasFeatures(column.table.options.features, keys);
|
|
40
|
+
/**
|
|
41
|
+
* Se a tabela da linha registrou as features pedidas. Estreita a linha para as APIs só dessas
|
|
42
|
+
* features.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* if (hasRowFeature(row, 'columnVisibilityFeature')) {
|
|
47
|
+
* row.getVisibleCells();
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
const hasRowFeature = (row, ...keys) => hasFeatures(row.table.options.features, keys);
|
|
52
|
+
//#endregion
|
|
53
|
+
export { hasColumnFeature, hasHeaderFeature, hasRowFeature, hasTableFeature };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=has-feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-feature.js","names":[],"sources":["../../src/utils/has-feature.ts"],"sourcesContent":["import type {\n CellData,\n Column,\n Header,\n Row,\n RowData,\n Table,\n TableFeatures,\n} from '@tanstack/react-table';\nimport type {\n ColumnWith,\n HeaderWith,\n RowWith,\n TableFeatureKey,\n TableWith,\n} from '../types';\n\n/*\n * Guards para os objetos que saem de outro (os headers de `getHeaderGroups()`, as linhas de\n * `getRowModel()`, a `column` de uma célula) e para a feature opcional de uma tabela. Esses vêm\n * com o tipo comum do TanStack, sem as features, e o guard os estreita para o `*With` das\n * features conferidas.\n *\n * A checagem é exata e em runtime: a feature está na lista que o app passou em `features`, e só\n * então o TanStack põe as APIs dela no protótipo. O `in` direto na API (`'getSize' in header`)\n * não serve: ele estreita para o membro do tipo que tem todas as features, e deixaria chamar a\n * API de uma que não foi conferida.\n */\n\n/** Se todas as features pedidas estão entre as registradas pelo app. */\nconst hasFeatures = (features: object, keys: readonly TableFeatureKey[]) =>\n keys.every((key) => key in features);\n\n/**\n * Se a tabela registrou as features pedidas. Estreita a tabela para as APIs e os atoms só dessas\n * features: para uma parte que se adapta a uma feature que não exige.\n *\n * @example\n * ```ts\n * if (hasTableFeature(table, 'rowPaginationFeature')) {\n * table.getPageCount();\n * }\n * ```\n */\nexport const hasTableFeature = <\n TFeatures extends TableFeatures,\n TData extends RowData,\n TKey extends TableFeatureKey,\n>(\n table: Table<TFeatures, TData>,\n ...keys: TKey[]\n): table is TableWith<TFeatures, TData, TKey> =>\n hasFeatures(table.options.features, keys);\n\n/**\n * Se a tabela do header registrou as features pedidas. Estreita o header, e a `column` dele, para\n * as APIs só dessas features.\n *\n * @example\n * ```ts\n * if (hasHeaderFeature(header, 'columnSizingFeature')) {\n * header.getSize();\n * }\n * ```\n */\nexport const hasHeaderFeature = <\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData,\n TKey extends TableFeatureKey,\n>(\n header: Header<TFeatures, TData, TValue>,\n ...keys: TKey[]\n): header is HeaderWith<TFeatures, TData, TKey, TValue> =>\n hasFeatures(header.table.options.features, keys);\n\n/**\n * Se a tabela da coluna registrou as features pedidas. Estreita a coluna para as APIs só dessas\n * features.\n *\n * @example\n * ```ts\n * if (hasColumnFeature(cell.column, 'columnPinningFeature')) {\n * cell.column.getIsPinned();\n * }\n * ```\n */\nexport const hasColumnFeature = <\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n TKey extends TableFeatureKey,\n>(\n column: Column<TFeatures, TData, TValue>,\n ...keys: TKey[]\n): column is ColumnWith<TFeatures, TData, TKey, TValue> =>\n hasFeatures(column.table.options.features, keys);\n\n/**\n * Se a tabela da linha registrou as features pedidas. Estreita a linha para as APIs só dessas\n * features.\n *\n * @example\n * ```ts\n * if (hasRowFeature(row, 'columnVisibilityFeature')) {\n * row.getVisibleCells();\n * }\n * ```\n */\nexport const hasRowFeature = <\n TFeatures extends TableFeatures,\n TData extends RowData,\n TKey extends TableFeatureKey,\n>(\n row: Row<TFeatures, TData>,\n ...keys: TKey[]\n): row is RowWith<TFeatures, TData, TKey> =>\n hasFeatures(row.table.options.features, keys);\n"],"mappings":";;AA8BA,MAAM,eAAe,UAAkB,SACrC,KAAK,OAAO,QAAQ,OAAO,QAAQ;;;;;;;;;;;;AAarC,MAAa,mBAKX,OACA,GAAG,SAEH,YAAY,MAAM,QAAQ,UAAU,IAAI;;;;;;;;;;;;AAa1C,MAAa,oBAMX,QACA,GAAG,SAEH,YAAY,OAAO,MAAM,QAAQ,UAAU,IAAI;;;;;;;;;;;;AAajD,MAAa,oBAMX,QACA,GAAG,SAEH,YAAY,OAAO,MAAM,QAAQ,UAAU,IAAI;;;;;;;;;;;;AAajD,MAAa,iBAKX,KACA,GAAG,SAEH,YAAY,IAAI,MAAM,QAAQ,UAAU,IAAI"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { getDefaultColumnLabel } from "./get-default-column-label.js";
|
|
2
|
+
import { hasColumnFeature, hasHeaderFeature, hasRowFeature, hasTableFeature } from "./has-feature.js";
|
|
3
|
+
export { getDefaultColumnLabel, hasColumnFeature, hasHeaderFeature, hasRowFeature, hasTableFeature };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { getDefaultColumnLabel } from "./get-default-column-label.js";
|
|
2
|
+
import { hasColumnFeature, hasHeaderFeature, hasRowFeature, hasTableFeature } from "./has-feature.js";
|
|
3
|
+
export { getDefaultColumnLabel, hasColumnFeature, hasHeaderFeature, hasRowFeature, hasTableFeature };
|