dgz-ui-shared 1.2.10 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/datatable/index.cjs.js +1 -1
- package/dist/components/datatable/index.cjs.js.map +1 -1
- package/dist/components/datatable/index.es.js +42 -41
- package/dist/components/datatable/index.es.js.map +1 -1
- package/dist/types/components/datatable/DataTable.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),_=require("../../chunks/index-ClQFzqcq.cjs.js"),V=require("dgz-ui/button"),D=require("dgz-ui/dropdown"),o=require("dgz-ui/utils"),M=require("../../chunks/lodash-BjH0kD7j.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),_=require("../../chunks/index-ClQFzqcq.cjs.js"),V=require("dgz-ui/button"),D=require("dgz-ui/dropdown"),o=require("dgz-ui/utils"),M=require("../../chunks/lodash-BjH0kD7j.cjs.js"),L=require("lucide-react"),a=require("react"),m=require("react-i18next"),J=require("../../chunks/useSortable-B3LF1tg8.cjs.js"),P=require("../../chunks/Actions-CXOiCjx0.cjs.js"),ee=require("../../chunks/ExportData-CrB0H1Ts.cjs.js"),u=require("../../chunks/Search-hHeGlXqd.cjs.js"),se=require("../../chunks/Loader-D_jX_Wgx.cjs.js"),y=require("../../chunks/MyPagination-CnF3468f.cjs.js"),G=require("dgz-ui/form"),c=require("dgz-ui/table"),I=require("../../chunks/SortOrder-81BrXp3i.cjs.js"),le=require("../../chunks/Empty-BYOOFAab.cjs.js"),Q=({rows:l=[],columns:h,onRowClick:q,rowKey:f,params:n={page:1,limit:y.DEFAULT_LIMIT},hasNumbers:E=!1,hasCheckbox:N=!1,selectedItems:b,onSelectedItemsChange:k,onSortOrderChange:F,isStickyHeader:t,className:H,...O})=>{const{sortObject:x,handleSort:p}=J.useSortable({sortField:n==null?void 0:n.sortField,sortOrder:n==null?void 0:n.sortOrder,onSortOrderChange:F}),{selectedRows:T,isRowSelected:w,isAllRowsSelected:j,handleSelectAllRows:$,handleSelectRow:v}=J.useDataTable({rows:l,defaultSelectedRows:b});return a.useEffect(()=>{JSON.stringify(b)!==JSON.stringify(T)&&T&&(k==null||k(T))},[T,b,k]),e.jsxs(c.Table,{...O,className:o.cn("relative",H),children:[e.jsx(c.TableHeader,{className:o.cn("bg-bg",t&&"sticky top-0 z-1"),children:e.jsxs(c.TableRow,{children:[N&&e.jsx(c.TableHead,{className:"w-12 p-3",children:e.jsx(G.Checkbox,{className:"mt-1",checked:j(f),onCheckedChange:s=>$(f,!!s),"aria-label":"Select all"})}),E&&e.jsx(c.TableHead,{className:"w-12 p-2",children:"#"}),h.filter(s=>!s.hidden).map(s=>e.jsx(c.TableHead,{style:s.styles,className:o.cn("p-2",s.sortable&&"cursor-pointer"),onClick:()=>s.sortable&&p(s.dataIndex),children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.name," ",s.sortable&&((x==null?void 0:x.sortField)===s.key?e.jsxs(e.Fragment,{children:[(x==null?void 0:x.sortOrder)===I.SortOrder.DESC&&e.jsx(L.ArrowDownWideNarrow,{size:15}),(x==null?void 0:x.sortOrder)===I.SortOrder.ASC&&e.jsx(L.ArrowUpWideNarrow,{size:15})]}):e.jsx(L.ArrowUpDown,{size:15}))]})},s.key))]})}),e.jsx(c.TableBody,{className:"[&>tr:nth-child(even)]:bg-bg-secondary",children:l.length?l.map((s,g)=>e.jsxs(c.TableRow,{onClick:()=>q==null?void 0:q(s),className:o.cn(q&&"cursor-pointer"),"data-state":w(s[f])&&"selected",children:[N&&e.jsx(c.TableCell,{className:"w-12 p-3",onClick:r=>r.stopPropagation(),children:e.jsx(G.Checkbox,{className:"mt-1",checked:w(s[f]),onCheckedChange:r=>v(s[f],!!r),"aria-label":"Select row"})}),E&&e.jsx(c.TableCell,{className:"w-12 p-2",children:(n.page-1)*(n.limit||y.DEFAULT_LIMIT)+g+1}),h.filter(r=>!r.hidden).map(r=>e.jsx(c.TableCell,{className:"text-body-xs-medium max-w-xs p-2",style:r.styles,children:r.render?r.render(M.lodashExports.get(s,r.dataIndex),s):M.lodashExports.get(s,r.dataIndex,"")},`${g}-${r.key}`))]},`${s[f]}`)):e.jsx(c.TableRow,{children:e.jsx(c.TableCell,{colSpan:E?N?h.length+2:h.length+1:h.length,children:e.jsx(le.Empty,{})})})})]})},te=({dataSource:l,columns:h,onRowClick:q,rowKey:f,hasNumbers:n,hasSearch:E,exportOptions:N,hasCheckbox:b,hasPagination:k,isStickyHeader:F,onParamChange:t,dataKey:H="docs",loading:O,tableKey:x,filters:p,actions:T,handleFilterChange:w,params:j,exportLoading:$=!1,onColumnsUpdate:v,hasColumnsVisibilityDropdown:s,onSelectedItemsChange:g,actionProps:r,filterWrapperProps:X,exportOptionsProps:Y,columnsVisibilityProps:i,paginationProps:Z,searchProps:A,...U})=>{const{t:W}=m.useTranslation(),[R,K]=a.useState([]),{formattedColumns:z,handleColumnsChange:S,resetColumns:C}=J.useColumns({key:x,columns:h});return a.useEffect(()=>{v==null||v(z)},[z,v]),a.useEffect(()=>{g==null||g(R)},[R,g]),e.jsxs("div",{className:"border-border-alpha-light flex grow flex-col overflow-auto rounded-xl border shadow-xs",children:[(E||s&&x||!M.lodashExports.isEmpty(N)||!M.lodashExports.isEmpty(p))&&e.jsxs("div",{className:"flex shrink-0 flex-col items-center justify-between gap-3 p-4 lg:flex-row",children:[e.jsx("div",{className:"w-full shrink",children:E&&e.jsx(u.Search,{...A,className:o.cn("h-8 max-w-60",A==null?void 0:A.className),defaultValue:M.lodashExports.get(j,"search",""),onSearchChange:d=>t==null?void 0:t({...j,search:d,page:1})})}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-3",children:[N&&e.jsx(ee.ExportData,{...Y,options:N,loading:$}),s&&x&&e.jsxs(D.DropdownMenu,{children:[e.jsx(D.DropdownMenuTrigger,{asChild:!0,...i==null?void 0:i.triggerProps,children:e.jsx(V.Button,{variant:"secondary",size:"sm",className:"ml-auto rounded-lg px-3",children:(i==null?void 0:i.title)||e.jsxs(e.Fragment,{children:[e.jsx(_.yn,{})," ",e.jsx("span",{className:"hidden lg:!inline",children:W("Customize columns")}),e.jsx(_.f1,{})]})})}),e.jsxs(D.DropdownMenuContent,{align:"end",...i==null?void 0:i.contentProps,children:[e.jsxs(D.DropdownMenuItem,{className:"capitalize",onClick:C,children:[e.jsx(L.RefreshCw,{})," ",(i==null?void 0:i.resetText)||W("Reset columns")]}),e.jsx(D.DropdownMenuSeparator,{}),z.map(d=>e.jsx(D.DropdownMenuCheckboxItem,{className:"capitalize",checked:!d.hidden,onCheckedChange:B=>S(d,!B),children:d.name},d.key))]})]}),T&&e.jsx(P.Actions,{...r,actions:T}),p&&e.jsx(u.FilterWrapper,{...X,filters:p,params:j,onChange:w,onFilter:d=>{t==null||t({...j,...d,page:1}),w==null||w(d)}})]})]}),e.jsx("div",{className:"flex flex-col overflow-auto border-y",children:O?e.jsx(se.Loader,{}):e.jsx(Q,{...U,params:{page:(l==null?void 0:l.page)||1,limit:l==null?void 0:l.limit,...j},rows:M.lodashExports.get(l,H,[]),rowKey:f,selectedItems:R,isStickyHeader:F,columns:z,hasCheckbox:b,hasNumbers:n,onRowClick:q,onSelectedItemsChange:K,onSortOrderChange:({sortField:d,sortOrder:B})=>{t==null||t({...j,sortField:d,sortOrder:B})}})}),k&&e.jsxs("div",{className:"flex shrink-0 flex-col items-center justify-between gap-3 p-4 lg:flex-row",children:[e.jsx("div",{className:"text-sm",children:e.jsx(y.MyLimitSelect,{onLimitChange:d=>t==null?void 0:t({...j,limit:d,page:1}),defaultValue:l==null?void 0:l.limit})}),e.jsx("div",{className:"text-muted-foreground text-sm",children:W("{{selectedCount}} of {{total}} row(s) selected",{selectedCount:R.length,total:(l==null?void 0:l.total)||0})}),e.jsx("div",{children:e.jsx(y.MyPagination,{...Z,onPageChange:d=>t==null?void 0:t({...j,page:d}),currentPage:l==null?void 0:l.page,totalPages:l==null?void 0:l.totalPages})})]})]})};exports.DataTable=te;exports.MyTable=Q;
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../../src/components/datatable/MyTable.tsx","../../../src/components/datatable/DataTable.tsx"],"sourcesContent":["import { Checkbox } from 'dgz-ui/form';\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from 'dgz-ui/table';\nimport { cn } from 'dgz-ui/utils';\nimport { get } from 'lodash';\nimport {\n ArrowDownWideNarrow,\n ArrowUpDown,\n ArrowUpWideNarrow,\n} from 'lucide-react';\nimport { type ComponentProps, useEffect } from 'react';\nimport { SortOrder } from '../../enums';\nimport { useDataTable, useSortable, type UseSortableProps } from '../../hooks';\nimport type { ColumnType } from '../../types';\nimport { Empty } from '../empty';\nimport { DEFAULT_LIMIT } from '../pagination/MyLimitSelect';\n\n/**\n * Props for the MyTable component.\n * @template TData - The type of data in the table.\n */\nexport interface MyTableProps<TData> extends ComponentProps<'table'> {\n /** Array of data rows to display. */\n rows?: TData[];\n /** Column definitions. */\n columns: ColumnType<TData>[];\n /** Callback when a row is clicked. */\n onRowClick?: (row: TData) => void;\n /** Whether to show row numbers. */\n hasNumbers?: boolean;\n /** Whether to show selection checkboxes. */\n hasCheckbox?: boolean;\n /** Unique key for each row. */\n rowKey: keyof TData;\n /** Current table parameters (page, limit, sort). */\n params?: Record<string, unknown>;\n /** Total number of items (optional, often used with pagination context). */\n total?: number;\n /** Array of currently selected item keys. */\n selectedItems?: TData[keyof TData][];\n /** Callback when selected items change. */\n onSelectedItemsChange?: (selectedItems: TData[keyof TData][]) => void;\n /** Callback when sort order changes. */\n onSortOrderChange?: (\n params: Omit<UseSortableProps<TData>, 'onSortOrderChange'>\n ) => void;\n /** Whether the header should stick to the top. */\n isStickyHeader?: true;\n}\n\n/**\n * MyTable renders a generic data table with optional numbering, selection checkboxes,\n * sortable columns and sticky header. It is a presentational component and delegates\n * sorting/selection state via hooks and callbacks.\n *\n * @template TData - The row data type.\n * @param props - Component props.\n * @returns React element containing the table.\n */\nexport const MyTable = <TData,>({\n rows = [],\n columns,\n onRowClick,\n rowKey,\n params = {\n page: 1,\n limit: DEFAULT_LIMIT,\n },\n hasNumbers = false,\n hasCheckbox = false,\n selectedItems,\n onSelectedItemsChange,\n onSortOrderChange,\n isStickyHeader,\n className,\n ...props\n}: MyTableProps<TData>) => {\n const { sortObject, handleSort } = useSortable<TData>({\n sortField: params?.sortField as keyof TData | undefined,\n sortOrder: params?.sortOrder as SortOrder | undefined,\n onSortOrderChange,\n });\n const {\n selectedRows,\n isRowSelected,\n isAllRowsSelected,\n handleSelectAllRows,\n handleSelectRow,\n } = useDataTable<TData>({ rows, defaultSelectedRows: selectedItems });\n\n useEffect(() => {\n if (\n JSON.stringify(selectedItems) !== JSON.stringify(selectedRows) &&\n selectedRows\n ) {\n onSelectedItemsChange?.(selectedRows);\n }\n }, [selectedRows, selectedItems, onSelectedItemsChange]);\n\n return (\n <Table {...props} className={cn('relative', className)}>\n <TableHeader\n className={cn('bg-bg', isStickyHeader && 'sticky top-0 z-1')}\n >\n <TableRow>\n {hasCheckbox && (\n <TableHead className={'w-12 p-3'}>\n <Checkbox\n className={'mt-1'}\n checked={isAllRowsSelected(rowKey)}\n onCheckedChange={(value) =>\n handleSelectAllRows(rowKey, !!value)\n }\n aria-label=\"Select all\"\n />\n </TableHead>\n )}\n {hasNumbers && <TableHead className={'w-12 p-2'}>#</TableHead>}\n {columns\n .filter((column) => !column.hidden)\n .map((column) => (\n <TableHead\n key={column.key}\n style={column.styles}\n className={cn('p-2', column.sortable && 'cursor-pointer')}\n onClick={() => column.sortable && handleSort(column.dataIndex)}\n >\n <div className={'flex items-center gap-2'}>\n {column.name}{' '}\n {column.sortable &&\n (sortObject?.sortField === column.key ? (\n <>\n {sortObject?.sortOrder === SortOrder.DESC && (\n <ArrowDownWideNarrow size={15} />\n )}\n {sortObject?.sortOrder === SortOrder.ASC && (\n <ArrowUpWideNarrow size={15} />\n )}\n </>\n ) : (\n <ArrowUpDown size={15} />\n ))}\n </div>\n </TableHead>\n ))}\n </TableRow>\n </TableHeader>\n <TableBody className={'[&>tr:nth-child(even)]:bg-bg-secondary'}>\n {rows.length ? (\n rows.map((row, index) => (\n <TableRow\n key={`${row[rowKey]}`}\n onClick={() => onRowClick?.(row)}\n className={cn(onRowClick && 'cursor-pointer')}\n data-state={isRowSelected(row[rowKey]) && 'selected'}\n >\n {hasCheckbox && (\n <TableCell\n className={'w-12 p-3'}\n onClick={(evt) => evt.stopPropagation()}\n >\n <Checkbox\n className={'mt-1'}\n checked={isRowSelected(row[rowKey])}\n onCheckedChange={(value) =>\n handleSelectRow(row[rowKey], !!value)\n }\n aria-label=\"Select row\"\n />\n </TableCell>\n )}\n {hasNumbers && (\n <TableCell className={'w-12 p-2'}>\n {((params.page as number) - 1) *\n ((params.limit || DEFAULT_LIMIT) as number) +\n index +\n 1}\n </TableCell>\n )}\n {columns\n .filter((column) => !column.hidden)\n .map((column) => (\n <TableCell\n className={'text-body-xs-medium max-w-xs p-2'}\n style={column.styles}\n key={`${index}-${column.key}`}\n >\n {column.render\n ? column.render(get(row, column.dataIndex), row)\n : get(row, column.dataIndex, '')}\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : (\n <TableRow>\n <TableCell\n colSpan={\n hasNumbers\n ? hasCheckbox\n ? columns.length + 2\n : columns.length + 1\n : columns.length\n }\n >\n <Empty />\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n );\n};\n","import { RiArrowDownSLine, RiLayoutColumnLine } from '@remixicon/react';\nimport { Button } from 'dgz-ui/button';\nimport {\n type DropdownContainerProps,\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from 'dgz-ui/dropdown';\nimport { cn } from 'dgz-ui/utils';\nimport { get, isEmpty } from 'lodash';\nimport { RefreshCw } from 'lucide-react';\nimport { type ReactNode, useEffect, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useColumns } from '../../hooks';\nimport type { ColumnType } from '../../types';\nimport { type ActionInterface, Actions, type ActionsProps } from '../actions';\nimport {\n ExportData,\n type ExportDataInterface,\n type ExportDataProps,\n} from '../export';\nimport {\n type FilterInterface,\n FilterWrapper,\n type FilterWrapperProps,\n Search,\n type SearchProps,\n} from '../filters';\nimport { Loader } from '../loader';\nimport { MyLimitSelect, MyPagination } from '../pagination';\nimport type { MyPaginationProps } from '../pagination/MyPagination.tsx';\nimport { MyTable, type MyTableProps } from './MyTable';\n\n/**\n * Minimal pagination wrapper contract used by `DataTable`.\n *\n * Notes\n * - Only `page`, `limit`, and `totalPages` are required. Other fields are optional and\n * may be provided by your API for convenience.\n * - The actual rows array can be stored in any key, controlled via `dataKey` prop\n * (defaults to `\"docs\"`).\n */\nexport interface PaginationInterface<TData> {\n /** Array of rows for the current page. Used when `dataKey` is set to `\"docs\"`. */\n docs?: TData[];\n /** Zero-based index of the first item on the current page (if provided by API). */\n offset?: number;\n /** Page size (items per page). */\n limit: number;\n /** Total number of pages available. */\n totalPages: number;\n /** Total number of items across all pages (if available). */\n total?: number;\n /** Current page number (1-based). */\n page: number;\n /** Convenience counter for the first item index on the page (if provided). */\n pagingCounter?: number;\n /** Whether a previous page exists. */\n hasPrevPage?: boolean;\n /** Whether a next page exists. */\n hasNextPage?: boolean;\n /** Previous page number, if available. */\n prevPage?: number;\n /** Next page number, if available. */\n nextPage?: number;\n}\n\n/**\n * Props for the DataTable component.\n *\n * @template TData - Row data type.\n * @template TPaginationData - Pagination wrapper type.\n */\nexport interface DataTableProps<\n TData,\n TPaginationData extends PaginationInterface<TData>,\n> extends Omit<MyTableProps<TData>, 'rows'> {\n /** Pagination data source. */\n dataSource?: TPaginationData;\n /** Callback for parameter changes (pagination, sorting, filtering). */\n onParamChange?: (param: Record<string, unknown>) => void;\n /** Whether to enable pagination. */\n hasPagination?: true;\n /** Options for the export data dropdown. */\n exportOptions?: ExportDataInterface[];\n /** Whether to enable search functionality. */\n hasSearch?: true;\n /** Whether the table data is loading. */\n loading?: boolean;\n /** Array of filters to display. */\n filters?: FilterInterface[];\n /** Array of actions to display. */\n actions?: ActionInterface[];\n /** Callback for filter changes. */\n handleFilterChange?: (filters: Record<string, unknown>) => void;\n /** Unique key for the table, used for column persistence. */\n tableKey: string;\n /** The key in dataSource where the data array is located. Defaults to \"docs\". */\n dataKey?: keyof TPaginationData;\n /** Whether to show the columns visibility dropdown. */\n hasColumnsVisibilityDropdown?: true;\n /** Callback when columns are updated (e.g., visibility toggled). */\n onColumnsUpdate?: (columns: ColumnType<TData>[]) => void;\n /** Whether the export action is loading. */\n exportLoading?: boolean;\n /** Props for the Actions component. */\n actionProps?: Partial<ActionsProps>;\n /** Props for the FilterWrapper component. */\n filterWrapperProps?: Partial<FilterWrapperProps>;\n /** Props for the ExportData component. */\n exportOptionsProps?: Partial<ExportDataProps>;\n searchProps?: Partial<SearchProps>;\n paginationProps?: Partial<MyPaginationProps>;\n /** Props for the columns visibility dropdown. */\n columnsVisibilityProps?: DropdownContainerProps & {\n title?: ReactNode;\n resetText?: ReactNode;\n };\n}\n\n/**\n * DataTable is a composable, high-level table that brings together search, filters,\n * column visibility management, header actions, exporting, and pagination.\n * It renders `MyTable` for rows and, when enabled, shows header controls and a footer with pagination.\n *\n * Generic Types\n * - `TData` — Row data shape (type of each item in the rows array).\n * - `TPaginationData` — Pagination wrapper type containing rows and pagination meta; defaults to\n * `PaginationInterface<TData>`.\n *\n * Key Behaviors\n * - Emits `onParamChange` when search text, filters, page, limit, or sort order change.\n * - Persists column visibility per `tableKey` via `useColumns` and informs parent with `onColumnsUpdate`.\n * - Renders header controls only when the related feature is enabled/has content.\n *\n * Props Overview\n * - `dataSource` — Paginated data source object that contains rows (see `dataKey`) and pagination metadata.\n * - `columns` — Column definitions passed to `MyTable`.\n * - `onRowClick` — Callback when a row is clicked.\n * - `rowKey` — Property name used as a unique row key.\n * - `hasNumbers` — Whether to show the row numbers column.\n * - `hasSearch` — Set to `true` to display the search input in the header.\n * - `exportOptions` — Export menu options shown by `ExportData` (see `ExportDataInterface[]`).\n * - `exportLoading` — When `true`, shows a spinner in the Export button to indicate an export action is in progress.\n * - `hasCheckbox` — Whether to show the selection checkbox column.\n * - `hasPagination` — Set to `true` to render the pagination footer.\n * - `isStickyHeader` — Whether to keep the table header sticky.\n * - `onParamChange` — Emits parameter changes for pagination/sorting/search/filters.\n * - `dataKey` — Key within `dataSource` that contains the row array. Defaults to `\"docs\"`.\n * - `loading` — If `true`, shows a loading state instead of the table rows.\n * - `tableKey` — Unique key for persisting column visibility state.\n * - `filters` — Filter configurations to render in the header.\n * - `actions` — Header actions independent of selected rows.\n * - `handleFilterChange` — Callback executed when filter values change.\n * - `params` — Current list parameters (pagination, sort, search, filters).\n * - `hasColumnsVisibilityDropdown` — Set to `true` to show the columns customize dropdown.\n * - `onColumnsUpdate` — Notifies parent whenever the internal columns state changes (after formatting/visibility).\n * - `actionProps` — Props passed to the `Actions` component.\n * - `filterWrapperProps` — Props passed to the `FilterWrapper` component.\n * - `exportOptionsProps` — Props passed to the `ExportData` component.\n * - `columnsVisibilityProps` — Props passed to the columns visibility dropdown.\n * - `onSelectedItemsChange` — Callback when selected rows change (requires `hasCheckbox`).\n *\n * Accessibility\n * - Header controls and dropdowns reuse shared primitives that include keyboard and ARIA support.\n *\n * Internationalization\n * - Text such as \"Export\", \"Customize columns\", and \"Reset columns\" are resolved via `react-i18next`.\n *\n * Usage Examples\n * 1) Minimal paginated table (uses default `dataKey = \"docs\"`)\n * ```tsx\n * type User = { id: string; name: string };\n * const data = { docs: [{ id: '1', name: 'Ada' }], page: 1, limit: 10, totalPages: 1 };\n *\n * <DataTable<User>\n * tableKey=\"users-table\"\n * columns={[{ key: 'name', name: 'Name' }]}\n * rowKey=\"id\"\n * dataSource={data}\n * hasPagination\n * />\n * ```\n *\n * 2) Custom `dataKey` and column visibility persistence\n * ```tsx\n * type Row = { id: number; title: string };\n * const payload = { items: [{ id: 1, title: 'Hello' }], page: 1, limit: 20, totalPages: 1 };\n *\n * <DataTable<Row>\n * tableKey=\"posts\"\n * columns={[{ key: 'title', name: 'Title' }]}\n * rowKey=\"id\"\n * dataSource={payload}\n * dataKey=\"items\"\n * hasColumnsVisibilityDropdown\n * />\n * ```\n *\n * 3) Responding to user interactions via `onParamChange`\n * ```tsx\n * const [params, setParams] = useState({ page: 1, limit: 10 });\n *\n * <DataTable\n * tableKey=\"logs\"\n * columns={[{ key: 'message', name: 'Message' }]}\n * rowKey=\"id\"\n * params={params}\n * onParamChange={setParams}\n * hasSearch\n * hasPagination\n * />\n * ```\n *\n * Notes and Best Practices\n * - Ensure `rowKey` points to a stable unique field in `TData` to avoid key collisions.\n * - When arrays like `exportOptions`, `filters`, or `actions` are empty, their sections are not rendered.\n * - Sorting emits `{ sortField, sortOrder }` through `onParamChange` when the user toggles a column sort.\n *\n * Returns\n * - React element that renders a complete data table experience.\n */\nexport const DataTable = <\n TData,\n TPaginationData extends PaginationInterface<TData> =\n PaginationInterface<TData>,\n>({\n dataSource,\n columns,\n onRowClick,\n rowKey,\n hasNumbers,\n hasSearch,\n exportOptions,\n hasCheckbox,\n hasPagination,\n isStickyHeader,\n onParamChange,\n dataKey = 'docs',\n loading,\n tableKey,\n filters,\n actions,\n handleFilterChange,\n params,\n exportLoading = false,\n onColumnsUpdate,\n hasColumnsVisibilityDropdown,\n onSelectedItemsChange,\n actionProps,\n filterWrapperProps,\n exportOptionsProps,\n columnsVisibilityProps,\n paginationProps,\n searchProps,\n ...props\n}: DataTableProps<TData, TPaginationData>) => {\n const { t } = useTranslation();\n const [selectedRows, setSelectedRows] = useState<TData[keyof TData][]>([]);\n const { formattedColumns, handleColumnsChange, resetColumns } =\n useColumns<TData>({ key: tableKey, columns });\n\n useEffect(() => {\n onColumnsUpdate?.(formattedColumns);\n }, [formattedColumns, onColumnsUpdate]);\n\n useEffect(() => {\n onSelectedItemsChange?.(selectedRows);\n }, [selectedRows, onSelectedItemsChange]);\n\n return (\n <div\n className={\n 'border-border-alpha-light flex grow flex-col overflow-auto rounded-xl border shadow-xs'\n }\n >\n {(hasSearch ||\n (hasColumnsVisibilityDropdown && tableKey) ||\n !isEmpty(exportOptions) ||\n !isEmpty(filters)) && (\n <div className=\"flex shrink-0 flex-col items-center justify-between gap-3 p-4 lg:flex-row\">\n <div className={'w-full shrink'}>\n {hasSearch && (\n <Search\n {...searchProps}\n className={cn('h-8 max-w-60', searchProps?.className)}\n defaultValue={get(params, 'search', '') as string}\n onSearchChange={(search) =>\n onParamChange?.({ ...params, search, page: 1 })\n }\n />\n )}\n </div>\n <div className={'flex shrink-0 items-center justify-end gap-3'}>\n {exportOptions && (\n <ExportData\n {...exportOptionsProps}\n options={exportOptions}\n loading={exportLoading}\n />\n )}\n {hasColumnsVisibilityDropdown && tableKey && (\n <DropdownMenu>\n <DropdownMenuTrigger\n asChild\n {...columnsVisibilityProps?.triggerProps}\n >\n <Button\n variant=\"secondary\"\n size={'sm'}\n className={'ml-auto rounded-lg px-3'}\n >\n {columnsVisibilityProps?.title || (\n <>\n <RiLayoutColumnLine />{' '}\n <span className={'hidden lg:!inline'}>\n {t('Customize columns')}\n </span>\n <RiArrowDownSLine />\n </>\n )}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"end\"\n {...columnsVisibilityProps?.contentProps}\n >\n <DropdownMenuItem\n className=\"capitalize\"\n onClick={resetColumns}\n >\n <RefreshCw />{' '}\n {columnsVisibilityProps?.resetText || t('Reset columns')}\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n {formattedColumns.map((column) => {\n return (\n <DropdownMenuCheckboxItem\n key={column.key}\n className=\"capitalize\"\n checked={!column.hidden}\n onCheckedChange={(value) =>\n handleColumnsChange(column, !value)\n }\n >\n {column.name}\n </DropdownMenuCheckboxItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n {actions && <Actions {...actionProps} actions={actions} />}\n {filters && (\n <FilterWrapper\n {...filterWrapperProps}\n filters={filters}\n params={params}\n onFilter={(filter) => {\n onParamChange?.({ ...params, ...filter, page: 1 });\n handleFilterChange?.(filter);\n }}\n />\n )}\n </div>\n </div>\n )}\n <div className={'flex flex-col overflow-auto border-y'}>\n {!loading ? (\n <MyTable<TData>\n {...props}\n params={{\n page: dataSource?.page || 1,\n limit: dataSource?.limit,\n ...params,\n }}\n rows={get(dataSource, dataKey, []) as TData[]}\n rowKey={rowKey}\n selectedItems={selectedRows}\n isStickyHeader={isStickyHeader}\n columns={formattedColumns}\n hasCheckbox={hasCheckbox}\n hasNumbers={hasNumbers}\n onRowClick={onRowClick}\n onSelectedItemsChange={setSelectedRows}\n onSortOrderChange={({ sortField, sortOrder }) => {\n onParamChange?.({ ...params, sortField, sortOrder });\n }}\n />\n ) : (\n <Loader />\n )}\n </div>\n {hasPagination && (\n <div className=\"flex shrink-0 flex-col items-center justify-between gap-3 p-4 lg:flex-row\">\n <div className=\"text-sm\">\n <MyLimitSelect\n onLimitChange={(limit) =>\n onParamChange?.({ ...params, limit, page: 1 })\n }\n defaultValue={dataSource?.limit}\n />\n </div>\n <div className=\"text-muted-foreground text-sm\">\n {t('{{selectedCount}} of {{total}} row(s) selected', {\n selectedCount: selectedRows.length,\n total: dataSource?.total || 0,\n })}\n </div>\n <div>\n <MyPagination\n {...paginationProps}\n onPageChange={(page) => onParamChange?.({ ...params, page })}\n currentPage={dataSource?.page}\n totalPages={dataSource?.totalPages}\n />\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"names":["MyTable","rows","columns","onRowClick","rowKey","params","DEFAULT_LIMIT","hasNumbers","hasCheckbox","selectedItems","onSelectedItemsChange","onSortOrderChange","isStickyHeader","className","props","sortObject","handleSort","useSortable","selectedRows","isRowSelected","isAllRowsSelected","handleSelectAllRows","handleSelectRow","useDataTable","useEffect","jsxs","Table","cn","jsx","TableHeader","TableRow","TableHead","Checkbox","value","column","Fragment","SortOrder","ArrowDownWideNarrow","ArrowUpWideNarrow","ArrowUpDown","TableBody","row","index","TableCell","evt","get","Empty","DataTable","dataSource","hasSearch","exportOptions","hasPagination","onParamChange","dataKey","loading","tableKey","filters","actions","handleFilterChange","exportLoading","onColumnsUpdate","hasColumnsVisibilityDropdown","actionProps","filterWrapperProps","exportOptionsProps","columnsVisibilityProps","paginationProps","searchProps","t","useTranslation","setSelectedRows","useState","formattedColumns","handleColumnsChange","resetColumns","useColumns","isEmpty","Search","search","ExportData","DropdownMenu","DropdownMenuTrigger","Button","RiLayoutColumnLine","RiArrowDownSLine","DropdownMenuContent","DropdownMenuItem","RefreshCw","DropdownMenuSeparator","DropdownMenuCheckboxItem","Actions","FilterWrapper","filter","Loader","sortField","sortOrder","MyLimitSelect","limit","MyPagination","page"],"mappings":"g0BAiEaA,EAAU,CAAS,CAC9B,KAAAC,EAAO,CAAA,EACP,QAAAC,EACA,WAAAC,EACA,OAAAC,EACA,OAAAC,EAAS,CACP,KAAM,EACN,MAAOC,EAAAA,aAAA,EAET,WAAAC,EAAa,GACb,YAAAC,EAAc,GACd,cAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,UAAAC,EACA,GAAGC,CACL,IAA2B,CACzB,KAAM,CAAE,WAAAC,EAAY,WAAAC,CAAA,EAAeC,cAAmB,CACpD,UAAWZ,GAAA,YAAAA,EAAQ,UACnB,UAAWA,GAAA,YAAAA,EAAQ,UACnB,kBAAAM,CAAA,CACD,EACK,CACJ,aAAAO,EACA,cAAAC,EACA,kBAAAC,EACA,oBAAAC,EACA,gBAAAC,CAAA,EACEC,EAAAA,aAAoB,CAAE,KAAAtB,EAAM,oBAAqBQ,EAAe,EAEpEe,OAAAA,EAAAA,UAAU,IAAM,CAEZ,KAAK,UAAUf,CAAa,IAAM,KAAK,UAAUS,CAAY,GAC7DA,IAEAR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AA,CAAI,UAAU,UACb,SAAAA,EAAAA,IAACoE,EAAAA,cAAA,CACC,cAAgBC,GACd7C,GAAA,YAAAA,EAAgB,CAAE,GAAG/C,EAAQ,MAAA4F,EAAO,KAAM,IAE5C,aAAcjD,GAAA,YAAAA,EAAY,KAAA,CAAA,EAE9B,EACApB,EAAAA,IAAC,MAAA,CAAI,UAAU,gCACZ,WAAE,iDAAkD,CACnD,cAAeV,EAAa,OAC5B,OAAO8B,GAAA,YAAAA,EAAY,QAAS,CAAA,CAC7B,EACH,QACC,MAAA,CACC,SAAApB,EAAAA,IAACsE,EAAAA,aAAA,CACE,GAAGhC,EACJ,aAAeiC,GAAS/C,GAAA,YAAAA,EAAgB,CAAE,GAAG/C,EAAQ,KAAA8F,IACrD,YAAanD,GAAA,YAAAA,EAAY,KACzB,WAAYA,GAAA,YAAAA,EAAY,UAAA,CAAA,CAC1B,CACF,CAAA,CAAA,CACF,CAAA,CAAA,CAAA,CAIR"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../src/components/datatable/MyTable.tsx","../../../src/components/datatable/DataTable.tsx"],"sourcesContent":["import { Checkbox } from 'dgz-ui/form';\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from 'dgz-ui/table';\nimport { cn } from 'dgz-ui/utils';\nimport { get } from 'lodash';\nimport {\n ArrowDownWideNarrow,\n ArrowUpDown,\n ArrowUpWideNarrow,\n} from 'lucide-react';\nimport { type ComponentProps, useEffect } from 'react';\nimport { SortOrder } from '../../enums';\nimport { useDataTable, useSortable, type UseSortableProps } from '../../hooks';\nimport type { ColumnType } from '../../types';\nimport { Empty } from '../empty';\nimport { DEFAULT_LIMIT } from '../pagination/MyLimitSelect';\n\n/**\n * Props for the MyTable component.\n * @template TData - The type of data in the table.\n */\nexport interface MyTableProps<TData> extends ComponentProps<'table'> {\n /** Array of data rows to display. */\n rows?: TData[];\n /** Column definitions. */\n columns: ColumnType<TData>[];\n /** Callback when a row is clicked. */\n onRowClick?: (row: TData) => void;\n /** Whether to show row numbers. */\n hasNumbers?: boolean;\n /** Whether to show selection checkboxes. */\n hasCheckbox?: boolean;\n /** Unique key for each row. */\n rowKey: keyof TData;\n /** Current table parameters (page, limit, sort). */\n params?: Record<string, unknown>;\n /** Total number of items (optional, often used with pagination context). */\n total?: number;\n /** Array of currently selected item keys. */\n selectedItems?: TData[keyof TData][];\n /** Callback when selected items change. */\n onSelectedItemsChange?: (selectedItems: TData[keyof TData][]) => void;\n /** Callback when sort order changes. */\n onSortOrderChange?: (\n params: Omit<UseSortableProps<TData>, 'onSortOrderChange'>\n ) => void;\n /** Whether the header should stick to the top. */\n isStickyHeader?: true;\n}\n\n/**\n * MyTable renders a generic data table with optional numbering, selection checkboxes,\n * sortable columns and sticky header. It is a presentational component and delegates\n * sorting/selection state via hooks and callbacks.\n *\n * @template TData - The row data type.\n * @param props - Component props.\n * @returns React element containing the table.\n */\nexport const MyTable = <TData,>({\n rows = [],\n columns,\n onRowClick,\n rowKey,\n params = {\n page: 1,\n limit: DEFAULT_LIMIT,\n },\n hasNumbers = false,\n hasCheckbox = false,\n selectedItems,\n onSelectedItemsChange,\n onSortOrderChange,\n isStickyHeader,\n className,\n ...props\n}: MyTableProps<TData>) => {\n const { sortObject, handleSort } = useSortable<TData>({\n sortField: params?.sortField as keyof TData | undefined,\n sortOrder: params?.sortOrder as SortOrder | undefined,\n onSortOrderChange,\n });\n const {\n selectedRows,\n isRowSelected,\n isAllRowsSelected,\n handleSelectAllRows,\n handleSelectRow,\n } = useDataTable<TData>({ rows, defaultSelectedRows: selectedItems });\n\n useEffect(() => {\n if (\n JSON.stringify(selectedItems) !== JSON.stringify(selectedRows) &&\n selectedRows\n ) {\n onSelectedItemsChange?.(selectedRows);\n }\n }, [selectedRows, selectedItems, onSelectedItemsChange]);\n\n return (\n <Table {...props} className={cn('relative', className)}>\n <TableHeader\n className={cn('bg-bg', isStickyHeader && 'sticky top-0 z-1')}\n >\n <TableRow>\n {hasCheckbox && (\n <TableHead className={'w-12 p-3'}>\n <Checkbox\n className={'mt-1'}\n checked={isAllRowsSelected(rowKey)}\n onCheckedChange={(value) =>\n handleSelectAllRows(rowKey, !!value)\n }\n aria-label=\"Select all\"\n />\n </TableHead>\n )}\n {hasNumbers && <TableHead className={'w-12 p-2'}>#</TableHead>}\n {columns\n .filter((column) => !column.hidden)\n .map((column) => (\n <TableHead\n key={column.key}\n style={column.styles}\n className={cn('p-2', column.sortable && 'cursor-pointer')}\n onClick={() => column.sortable && handleSort(column.dataIndex)}\n >\n <div className={'flex items-center gap-2'}>\n {column.name}{' '}\n {column.sortable &&\n (sortObject?.sortField === column.key ? (\n <>\n {sortObject?.sortOrder === SortOrder.DESC && (\n <ArrowDownWideNarrow size={15} />\n )}\n {sortObject?.sortOrder === SortOrder.ASC && (\n <ArrowUpWideNarrow size={15} />\n )}\n </>\n ) : (\n <ArrowUpDown size={15} />\n ))}\n </div>\n </TableHead>\n ))}\n </TableRow>\n </TableHeader>\n <TableBody className={'[&>tr:nth-child(even)]:bg-bg-secondary'}>\n {rows.length ? (\n rows.map((row, index) => (\n <TableRow\n key={`${row[rowKey]}`}\n onClick={() => onRowClick?.(row)}\n className={cn(onRowClick && 'cursor-pointer')}\n data-state={isRowSelected(row[rowKey]) && 'selected'}\n >\n {hasCheckbox && (\n <TableCell\n className={'w-12 p-3'}\n onClick={(evt) => evt.stopPropagation()}\n >\n <Checkbox\n className={'mt-1'}\n checked={isRowSelected(row[rowKey])}\n onCheckedChange={(value) =>\n handleSelectRow(row[rowKey], !!value)\n }\n aria-label=\"Select row\"\n />\n </TableCell>\n )}\n {hasNumbers && (\n <TableCell className={'w-12 p-2'}>\n {((params.page as number) - 1) *\n ((params.limit || DEFAULT_LIMIT) as number) +\n index +\n 1}\n </TableCell>\n )}\n {columns\n .filter((column) => !column.hidden)\n .map((column) => (\n <TableCell\n className={'text-body-xs-medium max-w-xs p-2'}\n style={column.styles}\n key={`${index}-${column.key}`}\n >\n {column.render\n ? column.render(get(row, column.dataIndex), row)\n : get(row, column.dataIndex, '')}\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : (\n <TableRow>\n <TableCell\n colSpan={\n hasNumbers\n ? hasCheckbox\n ? columns.length + 2\n : columns.length + 1\n : columns.length\n }\n >\n <Empty />\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n );\n};\n","import { RiArrowDownSLine, RiLayoutColumnLine } from '@remixicon/react';\nimport { Button } from 'dgz-ui/button';\nimport {\n type DropdownContainerProps,\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from 'dgz-ui/dropdown';\nimport { cn } from 'dgz-ui/utils';\nimport { get, isEmpty } from 'lodash';\nimport { RefreshCw } from 'lucide-react';\nimport { type ReactNode, useEffect, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useColumns } from '../../hooks';\nimport type { ColumnType } from '../../types';\nimport { type ActionInterface, Actions, type ActionsProps } from '../actions';\nimport {\n ExportData,\n type ExportDataInterface,\n type ExportDataProps,\n} from '../export';\nimport {\n type FilterInterface,\n FilterWrapper,\n type FilterWrapperProps,\n Search,\n type SearchProps,\n} from '../filters';\nimport { Loader } from '../loader';\nimport { MyLimitSelect, MyPagination } from '../pagination';\nimport type { MyPaginationProps } from '../pagination/MyPagination.tsx';\nimport { MyTable, type MyTableProps } from './MyTable';\n\n/**\n * Minimal pagination wrapper contract used by `DataTable`.\n *\n * Notes\n * - Only `page`, `limit`, and `totalPages` are required. Other fields are optional and\n * may be provided by your API for convenience.\n * - The actual rows array can be stored in any key, controlled via `dataKey` prop\n * (defaults to `\"docs\"`).\n */\nexport interface PaginationInterface<TData> {\n /** Array of rows for the current page. Used when `dataKey` is set to `\"docs\"`. */\n docs?: TData[];\n /** Zero-based index of the first item on the current page (if provided by API). */\n offset?: number;\n /** Page size (items per page). */\n limit: number;\n /** Total number of pages available. */\n totalPages: number;\n /** Total number of items across all pages (if available). */\n total?: number;\n /** Current page number (1-based). */\n page: number;\n /** Convenience counter for the first item index on the page (if provided). */\n pagingCounter?: number;\n /** Whether a previous page exists. */\n hasPrevPage?: boolean;\n /** Whether a next page exists. */\n hasNextPage?: boolean;\n /** Previous page number, if available. */\n prevPage?: number;\n /** Next page number, if available. */\n nextPage?: number;\n}\n\n/**\n * Props for the DataTable component.\n *\n * @template TData - Row data type.\n * @template TPaginationData - Pagination wrapper type.\n */\nexport interface DataTableProps<\n TData,\n TPaginationData extends PaginationInterface<TData>,\n> extends Omit<MyTableProps<TData>, 'rows'> {\n /** Pagination data source. */\n dataSource?: TPaginationData;\n /** Callback for parameter changes (pagination, sorting, filtering). */\n onParamChange?: (param: Record<string, unknown>) => void;\n /** Whether to enable pagination. */\n hasPagination?: true;\n /** Options for the export data dropdown. */\n exportOptions?: ExportDataInterface[];\n /** Whether to enable search functionality. */\n hasSearch?: true;\n /** Whether the table data is loading. */\n loading?: boolean;\n /** Array of filters to display. */\n filters?: FilterInterface[];\n /** Array of actions to display. */\n actions?: ActionInterface[];\n /** Callback for filter changes. */\n handleFilterChange?: (filters: Record<string, unknown>) => void;\n /** Unique key for the table, used for column persistence. */\n tableKey: string;\n /** The key in dataSource where the data array is located. Defaults to \"docs\". */\n dataKey?: keyof TPaginationData;\n /** Whether to show the columns visibility dropdown. */\n hasColumnsVisibilityDropdown?: true;\n /** Callback when columns are updated (e.g., visibility toggled). */\n onColumnsUpdate?: (columns: ColumnType<TData>[]) => void;\n /** Whether the export action is loading. */\n exportLoading?: boolean;\n /** Props for the Actions component. */\n actionProps?: Partial<ActionsProps>;\n /** Props for the FilterWrapper component. */\n filterWrapperProps?: Partial<FilterWrapperProps>;\n /** Props for the ExportData component. */\n exportOptionsProps?: Partial<ExportDataProps>;\n searchProps?: Partial<SearchProps>;\n paginationProps?: Partial<MyPaginationProps>;\n /** Props for the columns visibility dropdown. */\n columnsVisibilityProps?: DropdownContainerProps & {\n title?: ReactNode;\n resetText?: ReactNode;\n };\n}\n\n/**\n * DataTable is a composable, high-level table that brings together search, filters,\n * column visibility management, header actions, exporting, and pagination.\n * It renders `MyTable` for rows and, when enabled, shows header controls and a footer with pagination.\n *\n * Generic Types\n * - `TData` — Row data shape (type of each item in the rows array).\n * - `TPaginationData` — Pagination wrapper type containing rows and pagination meta; defaults to\n * `PaginationInterface<TData>`.\n *\n * Key Behaviors\n * - Emits `onParamChange` when search text, filters, page, limit, or sort order change.\n * - Persists column visibility per `tableKey` via `useColumns` and informs parent with `onColumnsUpdate`.\n * - Renders header controls only when the related feature is enabled/has content.\n *\n * Props Overview\n * - `dataSource` — Paginated data source object that contains rows (see `dataKey`) and pagination metadata.\n * - `columns` — Column definitions passed to `MyTable`.\n * - `onRowClick` — Callback when a row is clicked.\n * - `rowKey` — Property name used as a unique row key.\n * - `hasNumbers` — Whether to show the row numbers column.\n * - `hasSearch` — Set to `true` to display the search input in the header.\n * - `exportOptions` — Export menu options shown by `ExportData` (see `ExportDataInterface[]`).\n * - `exportLoading` — When `true`, shows a spinner in the Export button to indicate an export action is in progress.\n * - `hasCheckbox` — Whether to show the selection checkbox column.\n * - `hasPagination` — Set to `true` to render the pagination footer.\n * - `isStickyHeader` — Whether to keep the table header sticky.\n * - `onParamChange` — Emits parameter changes for pagination/sorting/search/filters.\n * - `dataKey` — Key within `dataSource` that contains the row array. Defaults to `\"docs\"`.\n * - `loading` — If `true`, shows a loading state instead of the table rows.\n * - `tableKey` — Unique key for persisting column visibility state.\n * - `filters` — Filter configurations to render in the header.\n * - `actions` — Header actions independent of selected rows.\n * - `handleFilterChange` — Callback executed when filter values change.\n * - `params` — Current list parameters (pagination, sort, search, filters).\n * - `hasColumnsVisibilityDropdown` — Set to `true` to show the columns customize dropdown.\n * - `onColumnsUpdate` — Notifies parent whenever the internal columns state changes (after formatting/visibility).\n * - `actionProps` — Props passed to the `Actions` component.\n * - `filterWrapperProps` — Props passed to the `FilterWrapper` component.\n * - `exportOptionsProps` — Props passed to the `ExportData` component.\n * - `columnsVisibilityProps` — Props passed to the columns visibility dropdown.\n * - `onSelectedItemsChange` — Callback when selected rows change (requires `hasCheckbox`).\n *\n * Accessibility\n * - Header controls and dropdowns reuse shared primitives that include keyboard and ARIA support.\n *\n * Internationalization\n * - Text such as \"Export\", \"Customize columns\", and \"Reset columns\" are resolved via `react-i18next`.\n *\n * Usage Examples\n * 1) Minimal paginated table (uses default `dataKey = \"docs\"`)\n * ```tsx\n * type User = { id: string; name: string };\n * const data = { docs: [{ id: '1', name: 'Ada' }], page: 1, limit: 10, totalPages: 1 };\n *\n * <DataTable<User>\n * tableKey=\"users-table\"\n * columns={[{ key: 'name', name: 'Name' }]}\n * rowKey=\"id\"\n * dataSource={data}\n * hasPagination\n * />\n * ```\n *\n * 2) Custom `dataKey` and column visibility persistence\n * ```tsx\n * type Row = { id: number; title: string };\n * const payload = { items: [{ id: 1, title: 'Hello' }], page: 1, limit: 20, totalPages: 1 };\n *\n * <DataTable<Row>\n * tableKey=\"posts\"\n * columns={[{ key: 'title', name: 'Title' }]}\n * rowKey=\"id\"\n * dataSource={payload}\n * dataKey=\"items\"\n * hasColumnsVisibilityDropdown\n * />\n * ```\n *\n * 3) Responding to user interactions via `onParamChange`\n * ```tsx\n * const [params, setParams] = useState({ page: 1, limit: 10 });\n *\n * <DataTable\n * tableKey=\"logs\"\n * columns={[{ key: 'message', name: 'Message' }]}\n * rowKey=\"id\"\n * params={params}\n * onParamChange={setParams}\n * hasSearch\n * hasPagination\n * />\n * ```\n *\n * Notes and Best Practices\n * - Ensure `rowKey` points to a stable unique field in `TData` to avoid key collisions.\n * - When arrays like `exportOptions`, `filters`, or `actions` are empty, their sections are not rendered.\n * - Sorting emits `{ sortField, sortOrder }` through `onParamChange` when the user toggles a column sort.\n *\n * Returns\n * - React element that renders a complete data table experience.\n */\nexport const DataTable = <\n TData,\n TPaginationData extends PaginationInterface<TData> =\n PaginationInterface<TData>,\n>({\n dataSource,\n columns,\n onRowClick,\n rowKey,\n hasNumbers,\n hasSearch,\n exportOptions,\n hasCheckbox,\n hasPagination,\n isStickyHeader,\n onParamChange,\n dataKey = 'docs',\n loading,\n tableKey,\n filters,\n actions,\n handleFilterChange,\n params,\n exportLoading = false,\n onColumnsUpdate,\n hasColumnsVisibilityDropdown,\n onSelectedItemsChange,\n actionProps,\n filterWrapperProps,\n exportOptionsProps,\n columnsVisibilityProps,\n paginationProps,\n searchProps,\n ...props\n}: DataTableProps<TData, TPaginationData>) => {\n const { t } = useTranslation();\n const [selectedRows, setSelectedRows] = useState<TData[keyof TData][]>([]);\n const { formattedColumns, handleColumnsChange, resetColumns } =\n useColumns<TData>({ key: tableKey, columns });\n\n useEffect(() => {\n onColumnsUpdate?.(formattedColumns);\n }, [formattedColumns, onColumnsUpdate]);\n\n useEffect(() => {\n onSelectedItemsChange?.(selectedRows);\n }, [selectedRows, onSelectedItemsChange]);\n\n return (\n <div\n className={\n 'border-border-alpha-light flex grow flex-col overflow-auto rounded-xl border shadow-xs'\n }\n >\n {(hasSearch ||\n (hasColumnsVisibilityDropdown && tableKey) ||\n !isEmpty(exportOptions) ||\n !isEmpty(filters)) && (\n <div className=\"flex shrink-0 flex-col items-center justify-between gap-3 p-4 lg:flex-row\">\n <div className={'w-full shrink'}>\n {hasSearch && (\n <Search\n {...searchProps}\n className={cn('h-8 max-w-60', searchProps?.className)}\n defaultValue={get(params, 'search', '') as string}\n onSearchChange={(search) =>\n onParamChange?.({ ...params, search, page: 1 })\n }\n />\n )}\n </div>\n <div className={'flex shrink-0 items-center justify-end gap-3'}>\n {exportOptions && (\n <ExportData\n {...exportOptionsProps}\n options={exportOptions}\n loading={exportLoading}\n />\n )}\n {hasColumnsVisibilityDropdown && tableKey && (\n <DropdownMenu>\n <DropdownMenuTrigger\n asChild\n {...columnsVisibilityProps?.triggerProps}\n >\n <Button\n variant=\"secondary\"\n size={'sm'}\n className={'ml-auto rounded-lg px-3'}\n >\n {columnsVisibilityProps?.title || (\n <>\n <RiLayoutColumnLine />{' '}\n <span className={'hidden lg:!inline'}>\n {t('Customize columns')}\n </span>\n <RiArrowDownSLine />\n </>\n )}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"end\"\n {...columnsVisibilityProps?.contentProps}\n >\n <DropdownMenuItem\n className=\"capitalize\"\n onClick={resetColumns}\n >\n <RefreshCw />{' '}\n {columnsVisibilityProps?.resetText || t('Reset columns')}\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n {formattedColumns.map((column) => {\n return (\n <DropdownMenuCheckboxItem\n key={column.key}\n className=\"capitalize\"\n checked={!column.hidden}\n onCheckedChange={(value) =>\n handleColumnsChange(column, !value)\n }\n >\n {column.name}\n </DropdownMenuCheckboxItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n {actions && <Actions {...actionProps} actions={actions} />}\n {filters && (\n <FilterWrapper\n {...filterWrapperProps}\n filters={filters}\n params={params}\n onChange={handleFilterChange}\n onFilter={(filter) => {\n onParamChange?.({ ...params, ...filter, page: 1 });\n handleFilterChange?.(filter);\n }}\n />\n )}\n </div>\n </div>\n )}\n <div className={'flex flex-col overflow-auto border-y'}>\n {!loading ? (\n <MyTable<TData>\n {...props}\n params={{\n page: dataSource?.page || 1,\n limit: dataSource?.limit,\n ...params,\n }}\n rows={get(dataSource, dataKey, []) as TData[]}\n rowKey={rowKey}\n selectedItems={selectedRows}\n isStickyHeader={isStickyHeader}\n columns={formattedColumns}\n hasCheckbox={hasCheckbox}\n hasNumbers={hasNumbers}\n onRowClick={onRowClick}\n onSelectedItemsChange={setSelectedRows}\n onSortOrderChange={({ sortField, sortOrder }) => {\n onParamChange?.({ ...params, sortField, sortOrder });\n }}\n />\n ) : (\n <Loader />\n )}\n </div>\n {hasPagination && (\n <div className=\"flex shrink-0 flex-col items-center justify-between gap-3 p-4 lg:flex-row\">\n <div className=\"text-sm\">\n <MyLimitSelect\n onLimitChange={(limit) =>\n onParamChange?.({ ...params, limit, page: 1 })\n }\n defaultValue={dataSource?.limit}\n />\n </div>\n <div className=\"text-muted-foreground text-sm\">\n {t('{{selectedCount}} of {{total}} row(s) selected', {\n selectedCount: selectedRows.length,\n total: dataSource?.total || 0,\n })}\n </div>\n <div>\n <MyPagination\n {...paginationProps}\n onPageChange={(page) => onParamChange?.({ ...params, page })}\n currentPage={dataSource?.page}\n totalPages={dataSource?.totalPages}\n />\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"names":["MyTable","rows","columns","onRowClick","rowKey","params","DEFAULT_LIMIT","hasNumbers","hasCheckbox","selectedItems","onSelectedItemsChange","onSortOrderChange","isStickyHeader","className","props","sortObject","handleSort","useSortable","selectedRows","isRowSelected","isAllRowsSelected","handleSelectAllRows","handleSelectRow","useDataTable","useEffect","jsxs","Table","cn","jsx","TableHeader","TableRow","TableHead","Checkbox","value","column","Fragment","SortOrder","ArrowDownWideNarrow","ArrowUpWideNarrow","ArrowUpDown","TableBody","row","index","TableCell","evt","get","Empty","DataTable","dataSource","hasSearch","exportOptions","hasPagination","onParamChange","dataKey","loading","tableKey","filters","actions","handleFilterChange","exportLoading","onColumnsUpdate","hasColumnsVisibilityDropdown","actionProps","filterWrapperProps","exportOptionsProps","columnsVisibilityProps","paginationProps","searchProps","t","useTranslation","setSelectedRows","useState","formattedColumns","handleColumnsChange","resetColumns","useColumns","isEmpty","Search","search","ExportData","DropdownMenu","DropdownMenuTrigger","Button","RiLayoutColumnLine","RiArrowDownSLine","DropdownMenuContent","DropdownMenuItem","RefreshCw","DropdownMenuSeparator","DropdownMenuCheckboxItem","Actions","FilterWrapper","filter","Loader","sortField","sortOrder","MyLimitSelect","limit","MyPagination","page"],"mappings":"g0BAiEaA,EAAU,CAAS,CAC9B,KAAAC,EAAO,CAAA,EACP,QAAAC,EACA,WAAAC,EACA,OAAAC,EACA,OAAAC,EAAS,CACP,KAAM,EACN,MAAOC,EAAAA,aAAA,EAET,WAAAC,EAAa,GACb,YAAAC,EAAc,GACd,cAAAC,EACA,sBAAAC,EACA,k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24
|
rowKey: p,
|
|
25
25
|
params: N = {
|
|
26
26
|
page: 1,
|
|
27
27
|
limit: q
|
|
28
28
|
},
|
|
29
|
-
hasNumbers:
|
|
29
|
+
hasNumbers: T = !1,
|
|
30
30
|
hasCheckbox: w = !1,
|
|
31
31
|
selectedItems: E,
|
|
32
|
-
onSelectedItemsChange:
|
|
32
|
+
onSelectedItemsChange: D,
|
|
33
33
|
onSortOrderChange: $,
|
|
34
34
|
isStickyHeader: d,
|
|
35
|
-
className:
|
|
36
|
-
...
|
|
35
|
+
className: o,
|
|
36
|
+
...B
|
|
37
37
|
}) => {
|
|
38
38
|
const { sortObject: f, handleSort: A } = ce({
|
|
39
39
|
sortField: N == null ? void 0 : N.sortField,
|
|
@@ -41,14 +41,14 @@ const ze = ({
|
|
|
41
41
|
onSortOrderChange: $
|
|
42
42
|
}), {
|
|
43
43
|
selectedRows: g,
|
|
44
|
-
isRowSelected:
|
|
44
|
+
isRowSelected: n,
|
|
45
45
|
isAllRowsSelected: c,
|
|
46
|
-
handleSelectAllRows:
|
|
46
|
+
handleSelectAllRows: H,
|
|
47
47
|
handleSelectRow: m
|
|
48
48
|
} = pe({ rows: t, defaultSelectedRows: E });
|
|
49
49
|
return j(() => {
|
|
50
|
-
JSON.stringify(E) !== JSON.stringify(g) && g && (
|
|
51
|
-
}, [g, E,
|
|
50
|
+
JSON.stringify(E) !== JSON.stringify(g) && g && (D == null || D(g));
|
|
51
|
+
}, [g, E, D]), /* @__PURE__ */ i(me, { ...B, className: z("relative", o), children: [
|
|
52
52
|
/* @__PURE__ */ e(
|
|
53
53
|
Me,
|
|
54
54
|
{
|
|
@@ -59,11 +59,11 @@ const ze = ({
|
|
|
59
59
|
{
|
|
60
60
|
className: "mt-1",
|
|
61
61
|
checked: c(p),
|
|
62
|
-
onCheckedChange: (l) =>
|
|
62
|
+
onCheckedChange: (l) => H(p, !!l),
|
|
63
63
|
"aria-label": "Select all"
|
|
64
64
|
}
|
|
65
65
|
) }),
|
|
66
|
-
|
|
66
|
+
T && /* @__PURE__ */ e(_, { className: "w-12 p-2", children: "#" }),
|
|
67
67
|
h.filter((l) => !l.hidden).map((l) => /* @__PURE__ */ e(
|
|
68
68
|
_,
|
|
69
69
|
{
|
|
@@ -84,12 +84,12 @@ const ze = ({
|
|
|
84
84
|
] })
|
|
85
85
|
}
|
|
86
86
|
),
|
|
87
|
-
/* @__PURE__ */ e(Ee, { className: "[&>tr:nth-child(even)]:bg-bg-secondary", children: t.length ? t.map((l,
|
|
87
|
+
/* @__PURE__ */ e(Ee, { className: "[&>tr:nth-child(even)]:bg-bg-secondary", children: t.length ? t.map((l, k) => /* @__PURE__ */ i(
|
|
88
88
|
O,
|
|
89
89
|
{
|
|
90
|
-
onClick: () =>
|
|
91
|
-
className: z(
|
|
92
|
-
"data-state":
|
|
90
|
+
onClick: () => v == null ? void 0 : v(l),
|
|
91
|
+
className: z(v && "cursor-pointer"),
|
|
92
|
+
"data-state": n(l[p]) && "selected",
|
|
93
93
|
children: [
|
|
94
94
|
w && /* @__PURE__ */ e(
|
|
95
95
|
W,
|
|
@@ -100,14 +100,14 @@ const ze = ({
|
|
|
100
100
|
G,
|
|
101
101
|
{
|
|
102
102
|
className: "mt-1",
|
|
103
|
-
checked:
|
|
103
|
+
checked: n(l[p]),
|
|
104
104
|
onCheckedChange: (s) => m(l[p], !!s),
|
|
105
105
|
"aria-label": "Select row"
|
|
106
106
|
}
|
|
107
107
|
)
|
|
108
108
|
}
|
|
109
109
|
),
|
|
110
|
-
|
|
110
|
+
T && /* @__PURE__ */ e(W, { className: "w-12 p-2", children: (N.page - 1) * (N.limit || q) + k + 1 }),
|
|
111
111
|
h.filter((s) => !s.hidden).map((s) => /* @__PURE__ */ e(
|
|
112
112
|
W,
|
|
113
113
|
{
|
|
@@ -115,7 +115,7 @@ const ze = ({
|
|
|
115
115
|
style: s.styles,
|
|
116
116
|
children: s.render ? s.render(M.get(l, s.dataIndex), l) : M.get(l, s.dataIndex, "")
|
|
117
117
|
},
|
|
118
|
-
`${
|
|
118
|
+
`${k}-${s.key}`
|
|
119
119
|
))
|
|
120
120
|
]
|
|
121
121
|
},
|
|
@@ -123,7 +123,7 @@ const ze = ({
|
|
|
123
123
|
)) : /* @__PURE__ */ e(O, { children: /* @__PURE__ */ e(
|
|
124
124
|
W,
|
|
125
125
|
{
|
|
126
|
-
colSpan:
|
|
126
|
+
colSpan: T ? w ? h.length + 2 : h.length + 1 : h.length,
|
|
127
127
|
children: /* @__PURE__ */ e(Ae, {})
|
|
128
128
|
}
|
|
129
129
|
) }) })
|
|
@@ -131,26 +131,26 @@ const ze = ({
|
|
|
131
131
|
}, be = ({
|
|
132
132
|
dataSource: t,
|
|
133
133
|
columns: h,
|
|
134
|
-
onRowClick:
|
|
134
|
+
onRowClick: v,
|
|
135
135
|
rowKey: p,
|
|
136
136
|
hasNumbers: N,
|
|
137
|
-
hasSearch:
|
|
137
|
+
hasSearch: T,
|
|
138
138
|
exportOptions: w,
|
|
139
139
|
hasCheckbox: E,
|
|
140
|
-
hasPagination:
|
|
140
|
+
hasPagination: D,
|
|
141
141
|
isStickyHeader: $,
|
|
142
142
|
onParamChange: d,
|
|
143
|
-
dataKey:
|
|
144
|
-
loading:
|
|
143
|
+
dataKey: o = "docs",
|
|
144
|
+
loading: B,
|
|
145
145
|
tableKey: f,
|
|
146
146
|
filters: A,
|
|
147
147
|
actions: g,
|
|
148
|
-
handleFilterChange:
|
|
148
|
+
handleFilterChange: n,
|
|
149
149
|
params: c,
|
|
150
|
-
exportLoading:
|
|
150
|
+
exportLoading: H = !1,
|
|
151
151
|
onColumnsUpdate: m,
|
|
152
152
|
hasColumnsVisibilityDropdown: l,
|
|
153
|
-
onSelectedItemsChange:
|
|
153
|
+
onSelectedItemsChange: k,
|
|
154
154
|
actionProps: s,
|
|
155
155
|
filterWrapperProps: Y,
|
|
156
156
|
exportOptionsProps: Z,
|
|
@@ -159,18 +159,18 @@ const ze = ({
|
|
|
159
159
|
searchProps: L,
|
|
160
160
|
...U
|
|
161
161
|
}) => {
|
|
162
|
-
const { t:
|
|
162
|
+
const { t: J } = Ne(), [R, I] = xe([]), { formattedColumns: F, handleColumnsChange: a, resetColumns: K } = he({ key: f, columns: h });
|
|
163
163
|
return j(() => {
|
|
164
164
|
m == null || m(F);
|
|
165
165
|
}, [F, m]), j(() => {
|
|
166
|
-
|
|
167
|
-
}, [R,
|
|
166
|
+
k == null || k(R);
|
|
167
|
+
}, [R, k]), /* @__PURE__ */ i(
|
|
168
168
|
"div",
|
|
169
169
|
{
|
|
170
170
|
className: "border-border-alpha-light flex grow flex-col overflow-auto rounded-xl border shadow-xs",
|
|
171
171
|
children: [
|
|
172
|
-
(
|
|
173
|
-
/* @__PURE__ */ e("div", { className: "w-full shrink", children:
|
|
172
|
+
(T || l && f || !M.isEmpty(w) || !M.isEmpty(A)) && /* @__PURE__ */ i("div", { className: "flex shrink-0 flex-col items-center justify-between gap-3 p-4 lg:flex-row", children: [
|
|
173
|
+
/* @__PURE__ */ e("div", { className: "w-full shrink", children: T && /* @__PURE__ */ e(
|
|
174
174
|
ne,
|
|
175
175
|
{
|
|
176
176
|
...L,
|
|
@@ -185,7 +185,7 @@ const ze = ({
|
|
|
185
185
|
{
|
|
186
186
|
...Z,
|
|
187
187
|
options: w,
|
|
188
|
-
loading:
|
|
188
|
+
loading: H
|
|
189
189
|
}
|
|
190
190
|
),
|
|
191
191
|
l && f && /* @__PURE__ */ i(u, { children: [
|
|
@@ -203,7 +203,7 @@ const ze = ({
|
|
|
203
203
|
children: (x == null ? void 0 : x.title) || /* @__PURE__ */ i(X, { children: [
|
|
204
204
|
/* @__PURE__ */ e(S, {}),
|
|
205
205
|
" ",
|
|
206
|
-
/* @__PURE__ */ e("span", { className: "hidden lg:!inline", children:
|
|
206
|
+
/* @__PURE__ */ e("span", { className: "hidden lg:!inline", children: J("Customize columns") }),
|
|
207
207
|
/* @__PURE__ */ e(V, {})
|
|
208
208
|
] })
|
|
209
209
|
}
|
|
@@ -224,7 +224,7 @@ const ze = ({
|
|
|
224
224
|
children: [
|
|
225
225
|
/* @__PURE__ */ e(ie, {}),
|
|
226
226
|
" ",
|
|
227
|
-
(x == null ? void 0 : x.resetText) ||
|
|
227
|
+
(x == null ? void 0 : x.resetText) || J("Reset columns")
|
|
228
228
|
]
|
|
229
229
|
}
|
|
230
230
|
),
|
|
@@ -250,14 +250,15 @@ const ze = ({
|
|
|
250
250
|
...Y,
|
|
251
251
|
filters: A,
|
|
252
252
|
params: c,
|
|
253
|
+
onChange: n,
|
|
253
254
|
onFilter: (r) => {
|
|
254
|
-
d == null || d({ ...c, ...r, page: 1 }),
|
|
255
|
+
d == null || d({ ...c, ...r, page: 1 }), n == null || n(r);
|
|
255
256
|
}
|
|
256
257
|
}
|
|
257
258
|
)
|
|
258
259
|
] })
|
|
259
260
|
] }),
|
|
260
|
-
/* @__PURE__ */ e("div", { className: "flex flex-col overflow-auto border-y", children:
|
|
261
|
+
/* @__PURE__ */ e("div", { className: "flex flex-col overflow-auto border-y", children: B ? /* @__PURE__ */ e(ve, {}) : /* @__PURE__ */ e(
|
|
261
262
|
ze,
|
|
262
263
|
{
|
|
263
264
|
...U,
|
|
@@ -266,21 +267,21 @@ const ze = ({
|
|
|
266
267
|
limit: t == null ? void 0 : t.limit,
|
|
267
268
|
...c
|
|
268
269
|
},
|
|
269
|
-
rows: M.get(t,
|
|
270
|
+
rows: M.get(t, o, []),
|
|
270
271
|
rowKey: p,
|
|
271
272
|
selectedItems: R,
|
|
272
273
|
isStickyHeader: $,
|
|
273
274
|
columns: F,
|
|
274
275
|
hasCheckbox: E,
|
|
275
276
|
hasNumbers: N,
|
|
276
|
-
onRowClick:
|
|
277
|
+
onRowClick: v,
|
|
277
278
|
onSelectedItemsChange: I,
|
|
278
279
|
onSortOrderChange: ({ sortField: r, sortOrder: y }) => {
|
|
279
280
|
d == null || d({ ...c, sortField: r, sortOrder: y });
|
|
280
281
|
}
|
|
281
282
|
}
|
|
282
283
|
) }),
|
|
283
|
-
|
|
284
|
+
D && /* @__PURE__ */ i("div", { className: "flex shrink-0 flex-col items-center justify-between gap-3 p-4 lg:flex-row", children: [
|
|
284
285
|
/* @__PURE__ */ e("div", { className: "text-sm", children: /* @__PURE__ */ e(
|
|
285
286
|
Te,
|
|
286
287
|
{
|
|
@@ -288,7 +289,7 @@ const ze = ({
|
|
|
288
289
|
defaultValue: t == null ? void 0 : t.limit
|
|
289
290
|
}
|
|
290
291
|
) }),
|
|
291
|
-
/* @__PURE__ */ e("div", { className: "text-muted-foreground text-sm", children:
|
|
292
|
+
/* @__PURE__ */ e("div", { className: "text-muted-foreground text-sm", children: J("{{selectedCount}} of {{total}} row(s) selected", {
|
|
292
293
|
selectedCount: R.length,
|
|
293
294
|
total: (t == null ? void 0 : t.total) || 0
|
|
294
295
|
}) }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../../src/components/datatable/MyTable.tsx","../../../src/components/datatable/DataTable.tsx"],"sourcesContent":["import { Checkbox } from 'dgz-ui/form';\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from 'dgz-ui/table';\nimport { cn } from 'dgz-ui/utils';\nimport { get } from 'lodash';\nimport {\n ArrowDownWideNarrow,\n ArrowUpDown,\n ArrowUpWideNarrow,\n} from 'lucide-react';\nimport { type ComponentProps, useEffect } from 'react';\nimport { SortOrder } from '../../enums';\nimport { useDataTable, useSortable, type UseSortableProps } from '../../hooks';\nimport type { ColumnType } from '../../types';\nimport { Empty } from '../empty';\nimport { DEFAULT_LIMIT } from '../pagination/MyLimitSelect';\n\n/**\n * Props for the MyTable component.\n * @template TData - The type of data in the table.\n */\nexport interface MyTableProps<TData> extends ComponentProps<'table'> {\n /** Array of data rows to display. */\n rows?: TData[];\n /** Column definitions. */\n columns: ColumnType<TData>[];\n /** Callback when a row is clicked. */\n onRowClick?: (row: TData) => void;\n /** Whether to show row numbers. */\n hasNumbers?: boolean;\n /** Whether to show selection checkboxes. */\n hasCheckbox?: boolean;\n /** Unique key for each row. */\n rowKey: keyof TData;\n /** Current table parameters (page, limit, sort). */\n params?: Record<string, unknown>;\n /** Total number of items (optional, often used with pagination context). */\n total?: number;\n /** Array of currently selected item keys. */\n selectedItems?: TData[keyof TData][];\n /** Callback when selected items change. */\n onSelectedItemsChange?: (selectedItems: TData[keyof TData][]) => void;\n /** Callback when sort order changes. */\n onSortOrderChange?: (\n params: Omit<UseSortableProps<TData>, 'onSortOrderChange'>\n ) => void;\n /** Whether the header should stick to the top. */\n isStickyHeader?: true;\n}\n\n/**\n * MyTable renders a generic data table with optional numbering, selection checkboxes,\n * sortable columns and sticky header. It is a presentational component and delegates\n * sorting/selection state via hooks and callbacks.\n *\n * @template TData - The row data type.\n * @param props - Component props.\n * @returns React element containing the table.\n */\nexport const MyTable = <TData,>({\n rows = [],\n columns,\n onRowClick,\n rowKey,\n params = {\n page: 1,\n limit: DEFAULT_LIMIT,\n },\n hasNumbers = false,\n hasCheckbox = false,\n selectedItems,\n onSelectedItemsChange,\n onSortOrderChange,\n isStickyHeader,\n className,\n ...props\n}: MyTableProps<TData>) => {\n const { sortObject, handleSort } = useSortable<TData>({\n sortField: params?.sortField as keyof TData | undefined,\n sortOrder: params?.sortOrder as SortOrder | undefined,\n onSortOrderChange,\n });\n const {\n selectedRows,\n isRowSelected,\n isAllRowsSelected,\n handleSelectAllRows,\n handleSelectRow,\n } = useDataTable<TData>({ rows, defaultSelectedRows: selectedItems });\n\n useEffect(() => {\n if (\n JSON.stringify(selectedItems) !== JSON.stringify(selectedRows) &&\n selectedRows\n ) {\n onSelectedItemsChange?.(selectedRows);\n }\n }, [selectedRows, selectedItems, onSelectedItemsChange]);\n\n return (\n <Table {...props} className={cn('relative', className)}>\n <TableHeader\n className={cn('bg-bg', isStickyHeader && 'sticky top-0 z-1')}\n >\n <TableRow>\n {hasCheckbox && (\n <TableHead className={'w-12 p-3'}>\n <Checkbox\n className={'mt-1'}\n checked={isAllRowsSelected(rowKey)}\n onCheckedChange={(value) =>\n handleSelectAllRows(rowKey, !!value)\n }\n aria-label=\"Select all\"\n />\n </TableHead>\n )}\n {hasNumbers && <TableHead className={'w-12 p-2'}>#</TableHead>}\n {columns\n .filter((column) => !column.hidden)\n .map((column) => (\n <TableHead\n key={column.key}\n style={column.styles}\n className={cn('p-2', column.sortable && 'cursor-pointer')}\n onClick={() => column.sortable && handleSort(column.dataIndex)}\n >\n <div className={'flex items-center gap-2'}>\n {column.name}{' '}\n {column.sortable &&\n (sortObject?.sortField === column.key ? (\n <>\n {sortObject?.sortOrder === SortOrder.DESC && (\n <ArrowDownWideNarrow size={15} />\n )}\n {sortObject?.sortOrder === SortOrder.ASC && (\n <ArrowUpWideNarrow size={15} />\n )}\n </>\n ) : (\n <ArrowUpDown size={15} />\n ))}\n </div>\n </TableHead>\n ))}\n </TableRow>\n </TableHeader>\n <TableBody className={'[&>tr:nth-child(even)]:bg-bg-secondary'}>\n {rows.length ? (\n rows.map((row, index) => (\n <TableRow\n key={`${row[rowKey]}`}\n onClick={() => onRowClick?.(row)}\n className={cn(onRowClick && 'cursor-pointer')}\n data-state={isRowSelected(row[rowKey]) && 'selected'}\n >\n {hasCheckbox && (\n <TableCell\n className={'w-12 p-3'}\n onClick={(evt) => evt.stopPropagation()}\n >\n <Checkbox\n className={'mt-1'}\n checked={isRowSelected(row[rowKey])}\n onCheckedChange={(value) =>\n handleSelectRow(row[rowKey], !!value)\n }\n aria-label=\"Select row\"\n />\n </TableCell>\n )}\n {hasNumbers && (\n <TableCell className={'w-12 p-2'}>\n {((params.page as number) - 1) *\n ((params.limit || DEFAULT_LIMIT) as number) +\n index +\n 1}\n </TableCell>\n )}\n {columns\n .filter((column) => !column.hidden)\n .map((column) => (\n <TableCell\n className={'text-body-xs-medium max-w-xs p-2'}\n style={column.styles}\n key={`${index}-${column.key}`}\n >\n {column.render\n ? column.render(get(row, column.dataIndex), row)\n : get(row, column.dataIndex, '')}\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : (\n <TableRow>\n <TableCell\n colSpan={\n hasNumbers\n ? hasCheckbox\n ? columns.length + 2\n : columns.length + 1\n : columns.length\n }\n >\n <Empty />\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n );\n};\n","import { RiArrowDownSLine, RiLayoutColumnLine } from '@remixicon/react';\nimport { Button } from 'dgz-ui/button';\nimport {\n type DropdownContainerProps,\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from 'dgz-ui/dropdown';\nimport { cn } from 'dgz-ui/utils';\nimport { get, isEmpty } from 'lodash';\nimport { RefreshCw } from 'lucide-react';\nimport { type ReactNode, useEffect, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useColumns } from '../../hooks';\nimport type { ColumnType } from '../../types';\nimport { type ActionInterface, Actions, type ActionsProps } from '../actions';\nimport {\n ExportData,\n type ExportDataInterface,\n type ExportDataProps,\n} from '../export';\nimport {\n type FilterInterface,\n FilterWrapper,\n type FilterWrapperProps,\n Search,\n type SearchProps,\n} from '../filters';\nimport { Loader } from '../loader';\nimport { MyLimitSelect, MyPagination } from '../pagination';\nimport type { MyPaginationProps } from '../pagination/MyPagination.tsx';\nimport { MyTable, type MyTableProps } from './MyTable';\n\n/**\n * Minimal pagination wrapper contract used by `DataTable`.\n *\n * Notes\n * - Only `page`, `limit`, and `totalPages` are required. Other fields are optional and\n * may be provided by your API for convenience.\n * - The actual rows array can be stored in any key, controlled via `dataKey` prop\n * (defaults to `\"docs\"`).\n */\nexport interface PaginationInterface<TData> {\n /** Array of rows for the current page. Used when `dataKey` is set to `\"docs\"`. */\n docs?: TData[];\n /** Zero-based index of the first item on the current page (if provided by API). */\n offset?: number;\n /** Page size (items per page). */\n limit: number;\n /** Total number of pages available. */\n totalPages: number;\n /** Total number of items across all pages (if available). */\n total?: number;\n /** Current page number (1-based). */\n page: number;\n /** Convenience counter for the first item index on the page (if provided). */\n pagingCounter?: number;\n /** Whether a previous page exists. */\n hasPrevPage?: boolean;\n /** Whether a next page exists. */\n hasNextPage?: boolean;\n /** Previous page number, if available. */\n prevPage?: number;\n /** Next page number, if available. */\n nextPage?: number;\n}\n\n/**\n * Props for the DataTable component.\n *\n * @template TData - Row data type.\n * @template TPaginationData - Pagination wrapper type.\n */\nexport interface DataTableProps<\n TData,\n TPaginationData extends PaginationInterface<TData>,\n> extends Omit<MyTableProps<TData>, 'rows'> {\n /** Pagination data source. */\n dataSource?: TPaginationData;\n /** Callback for parameter changes (pagination, sorting, filtering). */\n onParamChange?: (param: Record<string, unknown>) => void;\n /** Whether to enable pagination. */\n hasPagination?: true;\n /** Options for the export data dropdown. */\n exportOptions?: ExportDataInterface[];\n /** Whether to enable search functionality. */\n hasSearch?: true;\n /** Whether the table data is loading. */\n loading?: boolean;\n /** Array of filters to display. */\n filters?: FilterInterface[];\n /** Array of actions to display. */\n actions?: ActionInterface[];\n /** Callback for filter changes. */\n handleFilterChange?: (filters: Record<string, unknown>) => void;\n /** Unique key for the table, used for column persistence. */\n tableKey: string;\n /** The key in dataSource where the data array is located. Defaults to \"docs\". */\n dataKey?: keyof TPaginationData;\n /** Whether to show the columns visibility dropdown. */\n hasColumnsVisibilityDropdown?: true;\n /** Callback when columns are updated (e.g., visibility toggled). */\n onColumnsUpdate?: (columns: ColumnType<TData>[]) => void;\n /** Whether the export action is loading. */\n exportLoading?: boolean;\n /** Props for the Actions component. */\n actionProps?: Partial<ActionsProps>;\n /** Props for the FilterWrapper component. */\n filterWrapperProps?: Partial<FilterWrapperProps>;\n /** Props for the ExportData component. */\n exportOptionsProps?: Partial<ExportDataProps>;\n searchProps?: Partial<SearchProps>;\n paginationProps?: Partial<MyPaginationProps>;\n /** Props for the columns visibility dropdown. */\n columnsVisibilityProps?: DropdownContainerProps & {\n title?: ReactNode;\n resetText?: ReactNode;\n };\n}\n\n/**\n * DataTable is a composable, high-level table that brings together search, filters,\n * column visibility management, header actions, exporting, and pagination.\n * It renders `MyTable` for rows and, when enabled, shows header controls and a footer with pagination.\n *\n * Generic Types\n * - `TData` — Row data shape (type of each item in the rows array).\n * - `TPaginationData` — Pagination wrapper type containing rows and pagination meta; defaults to\n * `PaginationInterface<TData>`.\n *\n * Key Behaviors\n * - Emits `onParamChange` when search text, filters, page, limit, or sort order change.\n * - Persists column visibility per `tableKey` via `useColumns` and informs parent with `onColumnsUpdate`.\n * - Renders header controls only when the related feature is enabled/has content.\n *\n * Props Overview\n * - `dataSource` — Paginated data source object that contains rows (see `dataKey`) and pagination metadata.\n * - `columns` — Column definitions passed to `MyTable`.\n * - `onRowClick` — Callback when a row is clicked.\n * - `rowKey` — Property name used as a unique row key.\n * - `hasNumbers` — Whether to show the row numbers column.\n * - `hasSearch` — Set to `true` to display the search input in the header.\n * - `exportOptions` — Export menu options shown by `ExportData` (see `ExportDataInterface[]`).\n * - `exportLoading` — When `true`, shows a spinner in the Export button to indicate an export action is in progress.\n * - `hasCheckbox` — Whether to show the selection checkbox column.\n * - `hasPagination` — Set to `true` to render the pagination footer.\n * - `isStickyHeader` — Whether to keep the table header sticky.\n * - `onParamChange` — Emits parameter changes for pagination/sorting/search/filters.\n * - `dataKey` — Key within `dataSource` that contains the row array. Defaults to `\"docs\"`.\n * - `loading` — If `true`, shows a loading state instead of the table rows.\n * - `tableKey` — Unique key for persisting column visibility state.\n * - `filters` — Filter configurations to render in the header.\n * - `actions` — Header actions independent of selected rows.\n * - `handleFilterChange` — Callback executed when filter values change.\n * - `params` — Current list parameters (pagination, sort, search, filters).\n * - `hasColumnsVisibilityDropdown` — Set to `true` to show the columns customize dropdown.\n * - `onColumnsUpdate` — Notifies parent whenever the internal columns state changes (after formatting/visibility).\n * - `actionProps` — Props passed to the `Actions` component.\n * - `filterWrapperProps` — Props passed to the `FilterWrapper` component.\n * - `exportOptionsProps` — Props passed to the `ExportData` component.\n * - `columnsVisibilityProps` — Props passed to the columns visibility dropdown.\n * - `onSelectedItemsChange` — Callback when selected rows change (requires `hasCheckbox`).\n *\n * Accessibility\n * - Header controls and dropdowns reuse shared primitives that include keyboard and ARIA support.\n *\n * Internationalization\n * - Text such as \"Export\", \"Customize columns\", and \"Reset columns\" are resolved via `react-i18next`.\n *\n * Usage Examples\n * 1) Minimal paginated table (uses default `dataKey = \"docs\"`)\n * ```tsx\n * type User = { id: string; name: string };\n * const data = { docs: [{ id: '1', name: 'Ada' }], page: 1, limit: 10, totalPages: 1 };\n *\n * <DataTable<User>\n * tableKey=\"users-table\"\n * columns={[{ key: 'name', name: 'Name' }]}\n * rowKey=\"id\"\n * dataSource={data}\n * hasPagination\n * />\n * ```\n *\n * 2) Custom `dataKey` and column visibility persistence\n * ```tsx\n * type Row = { id: number; title: string };\n * const payload = { items: [{ id: 1, title: 'Hello' }], page: 1, limit: 20, totalPages: 1 };\n *\n * <DataTable<Row>\n * tableKey=\"posts\"\n * columns={[{ key: 'title', name: 'Title' }]}\n * rowKey=\"id\"\n * dataSource={payload}\n * dataKey=\"items\"\n * hasColumnsVisibilityDropdown\n * />\n * ```\n *\n * 3) Responding to user interactions via `onParamChange`\n * ```tsx\n * const [params, setParams] = useState({ page: 1, limit: 10 });\n *\n * <DataTable\n * tableKey=\"logs\"\n * columns={[{ key: 'message', name: 'Message' }]}\n * rowKey=\"id\"\n * params={params}\n * onParamChange={setParams}\n * hasSearch\n * hasPagination\n * />\n * ```\n *\n * Notes and Best Practices\n * - Ensure `rowKey` points to a stable unique field in `TData` to avoid key collisions.\n * - When arrays like `exportOptions`, `filters`, or `actions` are empty, their sections are not rendered.\n * - Sorting emits `{ sortField, sortOrder }` through `onParamChange` when the user toggles a column sort.\n *\n * Returns\n * - React element that renders a complete data table experience.\n */\nexport const DataTable = <\n TData,\n TPaginationData extends PaginationInterface<TData> =\n PaginationInterface<TData>,\n>({\n dataSource,\n columns,\n onRowClick,\n rowKey,\n hasNumbers,\n hasSearch,\n exportOptions,\n hasCheckbox,\n hasPagination,\n isStickyHeader,\n onParamChange,\n dataKey = 'docs',\n loading,\n tableKey,\n filters,\n actions,\n handleFilterChange,\n params,\n exportLoading = false,\n onColumnsUpdate,\n hasColumnsVisibilityDropdown,\n onSelectedItemsChange,\n actionProps,\n filterWrapperProps,\n exportOptionsProps,\n columnsVisibilityProps,\n paginationProps,\n searchProps,\n ...props\n}: DataTableProps<TData, TPaginationData>) => {\n const { t } = useTranslation();\n const [selectedRows, setSelectedRows] = useState<TData[keyof TData][]>([]);\n const { formattedColumns, handleColumnsChange, resetColumns } =\n useColumns<TData>({ key: tableKey, columns });\n\n useEffect(() => {\n onColumnsUpdate?.(formattedColumns);\n }, [formattedColumns, onColumnsUpdate]);\n\n useEffect(() => {\n onSelectedItemsChange?.(selectedRows);\n }, [selectedRows, onSelectedItemsChange]);\n\n return (\n <div\n className={\n 'border-border-alpha-light flex grow flex-col overflow-auto rounded-xl border shadow-xs'\n }\n >\n {(hasSearch ||\n (hasColumnsVisibilityDropdown && tableKey) ||\n !isEmpty(exportOptions) ||\n !isEmpty(filters)) && (\n <div className=\"flex shrink-0 flex-col items-center justify-between gap-3 p-4 lg:flex-row\">\n <div className={'w-full shrink'}>\n {hasSearch && (\n <Search\n {...searchProps}\n className={cn('h-8 max-w-60', searchProps?.className)}\n defaultValue={get(params, 'search', '') as string}\n onSearchChange={(search) =>\n onParamChange?.({ ...params, search, page: 1 })\n }\n />\n )}\n </div>\n <div className={'flex shrink-0 items-center justify-end gap-3'}>\n {exportOptions && (\n <ExportData\n {...exportOptionsProps}\n options={exportOptions}\n loading={exportLoading}\n />\n )}\n {hasColumnsVisibilityDropdown && tableKey && (\n <DropdownMenu>\n <DropdownMenuTrigger\n asChild\n {...columnsVisibilityProps?.triggerProps}\n >\n <Button\n variant=\"secondary\"\n size={'sm'}\n className={'ml-auto rounded-lg px-3'}\n >\n {columnsVisibilityProps?.title || (\n <>\n <RiLayoutColumnLine />{' '}\n <span className={'hidden lg:!inline'}>\n {t('Customize columns')}\n </span>\n <RiArrowDownSLine />\n </>\n )}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"end\"\n {...columnsVisibilityProps?.contentProps}\n >\n <DropdownMenuItem\n className=\"capitalize\"\n onClick={resetColumns}\n >\n <RefreshCw />{' '}\n {columnsVisibilityProps?.resetText || t('Reset columns')}\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n {formattedColumns.map((column) => {\n return (\n <DropdownMenuCheckboxItem\n key={column.key}\n className=\"capitalize\"\n checked={!column.hidden}\n onCheckedChange={(value) =>\n handleColumnsChange(column, !value)\n }\n >\n {column.name}\n </DropdownMenuCheckboxItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n {actions && <Actions {...actionProps} actions={actions} />}\n {filters && (\n <FilterWrapper\n {...filterWrapperProps}\n filters={filters}\n params={params}\n onFilter={(filter) => {\n onParamChange?.({ ...params, ...filter, page: 1 });\n handleFilterChange?.(filter);\n }}\n />\n )}\n </div>\n </div>\n )}\n <div className={'flex flex-col overflow-auto border-y'}>\n {!loading ? (\n <MyTable<TData>\n {...props}\n params={{\n page: dataSource?.page || 1,\n limit: dataSource?.limit,\n ...params,\n }}\n rows={get(dataSource, dataKey, []) as TData[]}\n rowKey={rowKey}\n selectedItems={selectedRows}\n isStickyHeader={isStickyHeader}\n columns={formattedColumns}\n hasCheckbox={hasCheckbox}\n hasNumbers={hasNumbers}\n onRowClick={onRowClick}\n onSelectedItemsChange={setSelectedRows}\n onSortOrderChange={({ sortField, sortOrder }) => {\n onParamChange?.({ ...params, sortField, sortOrder });\n }}\n />\n ) : (\n <Loader />\n )}\n </div>\n {hasPagination && (\n <div className=\"flex shrink-0 flex-col items-center justify-between gap-3 p-4 lg:flex-row\">\n <div className=\"text-sm\">\n <MyLimitSelect\n onLimitChange={(limit) =>\n onParamChange?.({ ...params, limit, page: 1 })\n }\n defaultValue={dataSource?.limit}\n />\n </div>\n <div className=\"text-muted-foreground text-sm\">\n {t('{{selectedCount}} of {{total}} row(s) selected', {\n selectedCount: selectedRows.length,\n total: dataSource?.total || 0,\n })}\n </div>\n <div>\n <MyPagination\n {...paginationProps}\n onPageChange={(page) => onParamChange?.({ ...params, page })}\n currentPage={dataSource?.page}\n totalPages={dataSource?.totalPages}\n />\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"names":["MyTable","rows","columns","onRowClick","rowKey","params","DEFAULT_LIMIT","hasNumbers","hasCheckbox","selectedItems","onSelectedItemsChange","onSortOrderChange","isStickyHeader","className","props","sortObject","handleSort","useSortable","selectedRows","isRowSelected","isAllRowsSelected","handleSelectAllRows","handleSelectRow","useDataTable","useEffect","jsxs","Table","cn","jsx","TableHeader","TableRow","TableHead","Checkbox","value","column","Fragment","SortOrder","ArrowDownWideNarrow","ArrowUpWideNarrow","ArrowUpDown","TableBody","row","index","TableCell","evt","get","Empty","DataTable","dataSource","hasSearch","exportOptions","hasPagination","onParamChange","dataKey","loading","tableKey","filters","actions","handleFilterChange","exportLoading","onColumnsUpdate","hasColumnsVisibilityDropdown","actionProps","filterWrapperProps","exportOptionsProps","columnsVisibilityProps","paginationProps","searchProps","t","useTranslation","setSelectedRows","useState","formattedColumns","handleColumnsChange","resetColumns","useColumns","isEmpty","Search","search","ExportData","DropdownMenu","DropdownMenuTrigger","Button","RiLayoutColumnLine","RiArrowDownSLine","DropdownMenuContent","DropdownMenuItem","RefreshCw","DropdownMenuSeparator","DropdownMenuCheckboxItem","Actions","FilterWrapper","filter","Loader","sortField","sortOrder","MyLimitSelect","limit","MyPagination","page"],"mappings":";;;;;;;;;;;;;;;;;;;AAiEO,MAAMA,KAAU,CAAS;AAAA,EAC9B,MAAAC,IAAO,CAAA;AAAA,EACP,SAAAC;AAAA,EACA,YAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,IACP,MAAM;AAAA,IACN,OAAOC;AAAA,EAAA;AAAA,EAET,YAAAC,IAAa;AAAA,EACb,aAAAC,IAAc;AAAA,EACd,eAAAC;AAAA,EACA,uBAAAC;AAAA,EACA,mBA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ources":["../../../src/components/datatable/MyTable.tsx","../../../src/components/datatable/DataTable.tsx"],"sourcesContent":["import { Checkbox } from 'dgz-ui/form';\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from 'dgz-ui/table';\nimport { cn } from 'dgz-ui/utils';\nimport { get } from 'lodash';\nimport {\n ArrowDownWideNarrow,\n ArrowUpDown,\n ArrowUpWideNarrow,\n} from 'lucide-react';\nimport { type ComponentProps, useEffect } from 'react';\nimport { SortOrder } from '../../enums';\nimport { useDataTable, useSortable, type UseSortableProps } from '../../hooks';\nimport type { ColumnType } from '../../types';\nimport { Empty } from '../empty';\nimport { DEFAULT_LIMIT } from '../pagination/MyLimitSelect';\n\n/**\n * Props for the MyTable component.\n * @template TData - The type of data in the table.\n */\nexport interface MyTableProps<TData> extends ComponentProps<'table'> {\n /** Array of data rows to display. */\n rows?: TData[];\n /** Column definitions. */\n columns: ColumnType<TData>[];\n /** Callback when a row is clicked. */\n onRowClick?: (row: TData) => void;\n /** Whether to show row numbers. */\n hasNumbers?: boolean;\n /** Whether to show selection checkboxes. */\n hasCheckbox?: boolean;\n /** Unique key for each row. */\n rowKey: keyof TData;\n /** Current table parameters (page, limit, sort). */\n params?: Record<string, unknown>;\n /** Total number of items (optional, often used with pagination context). */\n total?: number;\n /** Array of currently selected item keys. */\n selectedItems?: TData[keyof TData][];\n /** Callback when selected items change. */\n onSelectedItemsChange?: (selectedItems: TData[keyof TData][]) => void;\n /** Callback when sort order changes. */\n onSortOrderChange?: (\n params: Omit<UseSortableProps<TData>, 'onSortOrderChange'>\n ) => void;\n /** Whether the header should stick to the top. */\n isStickyHeader?: true;\n}\n\n/**\n * MyTable renders a generic data table with optional numbering, selection checkboxes,\n * sortable columns and sticky header. It is a presentational component and delegates\n * sorting/selection state via hooks and callbacks.\n *\n * @template TData - The row data type.\n * @param props - Component props.\n * @returns React element containing the table.\n */\nexport const MyTable = <TData,>({\n rows = [],\n columns,\n onRowClick,\n rowKey,\n params = {\n page: 1,\n limit: DEFAULT_LIMIT,\n },\n hasNumbers = false,\n hasCheckbox = false,\n selectedItems,\n onSelectedItemsChange,\n onSortOrderChange,\n isStickyHeader,\n className,\n ...props\n}: MyTableProps<TData>) => {\n const { sortObject, handleSort } = useSortable<TData>({\n sortField: params?.sortField as keyof TData | undefined,\n sortOrder: params?.sortOrder as SortOrder | undefined,\n onSortOrderChange,\n });\n const {\n selectedRows,\n isRowSelected,\n isAllRowsSelected,\n handleSelectAllRows,\n handleSelectRow,\n } = useDataTable<TData>({ rows, defaultSelectedRows: selectedItems });\n\n useEffect(() => {\n if (\n JSON.stringify(selectedItems) !== JSON.stringify(selectedRows) &&\n selectedRows\n ) {\n onSelectedItemsChange?.(selectedRows);\n }\n }, [selectedRows, selectedItems, onSelectedItemsChange]);\n\n return (\n <Table {...props} className={cn('relative', className)}>\n <TableHeader\n className={cn('bg-bg', isStickyHeader && 'sticky top-0 z-1')}\n >\n <TableRow>\n {hasCheckbox && (\n <TableHead className={'w-12 p-3'}>\n <Checkbox\n className={'mt-1'}\n checked={isAllRowsSelected(rowKey)}\n onCheckedChange={(value) =>\n handleSelectAllRows(rowKey, !!value)\n }\n aria-label=\"Select all\"\n />\n </TableHead>\n )}\n {hasNumbers && <TableHead className={'w-12 p-2'}>#</TableHead>}\n {columns\n .filter((column) => !column.hidden)\n .map((column) => (\n <TableHead\n key={column.key}\n style={column.styles}\n className={cn('p-2', column.sortable && 'cursor-pointer')}\n onClick={() => column.sortable && handleSort(column.dataIndex)}\n >\n <div className={'flex items-center gap-2'}>\n {column.name}{' '}\n {column.sortable &&\n (sortObject?.sortField === column.key ? (\n <>\n {sortObject?.sortOrder === SortOrder.DESC && (\n <ArrowDownWideNarrow size={15} />\n )}\n {sortObject?.sortOrder === SortOrder.ASC && (\n <ArrowUpWideNarrow size={15} />\n )}\n </>\n ) : (\n <ArrowUpDown size={15} />\n ))}\n </div>\n </TableHead>\n ))}\n </TableRow>\n </TableHeader>\n <TableBody className={'[&>tr:nth-child(even)]:bg-bg-secondary'}>\n {rows.length ? (\n rows.map((row, index) => (\n <TableRow\n key={`${row[rowKey]}`}\n onClick={() => onRowClick?.(row)}\n className={cn(onRowClick && 'cursor-pointer')}\n data-state={isRowSelected(row[rowKey]) && 'selected'}\n >\n {hasCheckbox && (\n <TableCell\n className={'w-12 p-3'}\n onClick={(evt) => evt.stopPropagation()}\n >\n <Checkbox\n className={'mt-1'}\n checked={isRowSelected(row[rowKey])}\n onCheckedChange={(value) =>\n handleSelectRow(row[rowKey], !!value)\n }\n aria-label=\"Select row\"\n />\n </TableCell>\n )}\n {hasNumbers && (\n <TableCell className={'w-12 p-2'}>\n {((params.page as number) - 1) *\n ((params.limit || DEFAULT_LIMIT) as number) +\n index +\n 1}\n </TableCell>\n )}\n {columns\n .filter((column) => !column.hidden)\n .map((column) => (\n <TableCell\n className={'text-body-xs-medium max-w-xs p-2'}\n style={column.styles}\n key={`${index}-${column.key}`}\n >\n {column.render\n ? column.render(get(row, column.dataIndex), row)\n : get(row, column.dataIndex, '')}\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : (\n <TableRow>\n <TableCell\n colSpan={\n hasNumbers\n ? hasCheckbox\n ? columns.length + 2\n : columns.length + 1\n : columns.length\n }\n >\n <Empty />\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n );\n};\n","import { RiArrowDownSLine, RiLayoutColumnLine } from '@remixicon/react';\nimport { Button } from 'dgz-ui/button';\nimport {\n type DropdownContainerProps,\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from 'dgz-ui/dropdown';\nimport { cn } from 'dgz-ui/utils';\nimport { get, isEmpty } from 'lodash';\nimport { RefreshCw } from 'lucide-react';\nimport { type ReactNode, useEffect, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useColumns } from '../../hooks';\nimport type { ColumnType } from '../../types';\nimport { type ActionInterface, Actions, type ActionsProps } from '../actions';\nimport {\n ExportData,\n type ExportDataInterface,\n type ExportDataProps,\n} from '../export';\nimport {\n type FilterInterface,\n FilterWrapper,\n type FilterWrapperProps,\n Search,\n type SearchProps,\n} from '../filters';\nimport { Loader } from '../loader';\nimport { MyLimitSelect, MyPagination } from '../pagination';\nimport type { MyPaginationProps } from '../pagination/MyPagination.tsx';\nimport { MyTable, type MyTableProps } from './MyTable';\n\n/**\n * Minimal pagination wrapper contract used by `DataTable`.\n *\n * Notes\n * - Only `page`, `limit`, and `totalPages` are required. Other fields are optional and\n * may be provided by your API for convenience.\n * - The actual rows array can be stored in any key, controlled via `dataKey` prop\n * (defaults to `\"docs\"`).\n */\nexport interface PaginationInterface<TData> {\n /** Array of rows for the current page. Used when `dataKey` is set to `\"docs\"`. */\n docs?: TData[];\n /** Zero-based index of the first item on the current page (if provided by API). */\n offset?: number;\n /** Page size (items per page). */\n limit: number;\n /** Total number of pages available. */\n totalPages: number;\n /** Total number of items across all pages (if available). */\n total?: number;\n /** Current page number (1-based). */\n page: number;\n /** Convenience counter for the first item index on the page (if provided). */\n pagingCounter?: number;\n /** Whether a previous page exists. */\n hasPrevPage?: boolean;\n /** Whether a next page exists. */\n hasNextPage?: boolean;\n /** Previous page number, if available. */\n prevPage?: number;\n /** Next page number, if available. */\n nextPage?: number;\n}\n\n/**\n * Props for the DataTable component.\n *\n * @template TData - Row data type.\n * @template TPaginationData - Pagination wrapper type.\n */\nexport interface DataTableProps<\n TData,\n TPaginationData extends PaginationInterface<TData>,\n> extends Omit<MyTableProps<TData>, 'rows'> {\n /** Pagination data source. */\n dataSource?: TPaginationData;\n /** Callback for parameter changes (pagination, sorting, filtering). */\n onParamChange?: (param: Record<string, unknown>) => void;\n /** Whether to enable pagination. */\n hasPagination?: true;\n /** Options for the export data dropdown. */\n exportOptions?: ExportDataInterface[];\n /** Whether to enable search functionality. */\n hasSearch?: true;\n /** Whether the table data is loading. */\n loading?: boolean;\n /** Array of filters to display. */\n filters?: FilterInterface[];\n /** Array of actions to display. */\n actions?: ActionInterface[];\n /** Callback for filter changes. */\n handleFilterChange?: (filters: Record<string, unknown>) => void;\n /** Unique key for the table, used for column persistence. */\n tableKey: string;\n /** The key in dataSource where the data array is located. Defaults to \"docs\". */\n dataKey?: keyof TPaginationData;\n /** Whether to show the columns visibility dropdown. */\n hasColumnsVisibilityDropdown?: true;\n /** Callback when columns are updated (e.g., visibility toggled). */\n onColumnsUpdate?: (columns: ColumnType<TData>[]) => void;\n /** Whether the export action is loading. */\n exportLoading?: boolean;\n /** Props for the Actions component. */\n actionProps?: Partial<ActionsProps>;\n /** Props for the FilterWrapper component. */\n filterWrapperProps?: Partial<FilterWrapperProps>;\n /** Props for the ExportData component. */\n exportOptionsProps?: Partial<ExportDataProps>;\n searchProps?: Partial<SearchProps>;\n paginationProps?: Partial<MyPaginationProps>;\n /** Props for the columns visibility dropdown. */\n columnsVisibilityProps?: DropdownContainerProps & {\n title?: ReactNode;\n resetText?: ReactNode;\n };\n}\n\n/**\n * DataTable is a composable, high-level table that brings together search, filters,\n * column visibility management, header actions, exporting, and pagination.\n * It renders `MyTable` for rows and, when enabled, shows header controls and a footer with pagination.\n *\n * Generic Types\n * - `TData` — Row data shape (type of each item in the rows array).\n * - `TPaginationData` — Pagination wrapper type containing rows and pagination meta; defaults to\n * `PaginationInterface<TData>`.\n *\n * Key Behaviors\n * - Emits `onParamChange` when search text, filters, page, limit, or sort order change.\n * - Persists column visibility per `tableKey` via `useColumns` and informs parent with `onColumnsUpdate`.\n * - Renders header controls only when the related feature is enabled/has content.\n *\n * Props Overview\n * - `dataSource` — Paginated data source object that contains rows (see `dataKey`) and pagination metadata.\n * - `columns` — Column definitions passed to `MyTable`.\n * - `onRowClick` — Callback when a row is clicked.\n * - `rowKey` — Property name used as a unique row key.\n * - `hasNumbers` — Whether to show the row numbers column.\n * - `hasSearch` — Set to `true` to display the search input in the header.\n * - `exportOptions` — Export menu options shown by `ExportData` (see `ExportDataInterface[]`).\n * - `exportLoading` — When `true`, shows a spinner in the Export button to indicate an export action is in progress.\n * - `hasCheckbox` — Whether to show the selection checkbox column.\n * - `hasPagination` — Set to `true` to render the pagination footer.\n * - `isStickyHeader` — Whether to keep the table header sticky.\n * - `onParamChange` — Emits parameter changes for pagination/sorting/search/filters.\n * - `dataKey` — Key within `dataSource` that contains the row array. Defaults to `\"docs\"`.\n * - `loading` — If `true`, shows a loading state instead of the table rows.\n * - `tableKey` — Unique key for persisting column visibility state.\n * - `filters` — Filter configurations to render in the header.\n * - `actions` — Header actions independent of selected rows.\n * - `handleFilterChange` — Callback executed when filter values change.\n * - `params` — Current list parameters (pagination, sort, search, filters).\n * - `hasColumnsVisibilityDropdown` — Set to `true` to show the columns customize dropdown.\n * - `onColumnsUpdate` — Notifies parent whenever the internal columns state changes (after formatting/visibility).\n * - `actionProps` — Props passed to the `Actions` component.\n * - `filterWrapperProps` — Props passed to the `FilterWrapper` component.\n * - `exportOptionsProps` — Props passed to the `ExportData` component.\n * - `columnsVisibilityProps` — Props passed to the columns visibility dropdown.\n * - `onSelectedItemsChange` — Callback when selected rows change (requires `hasCheckbox`).\n *\n * Accessibility\n * - Header controls and dropdowns reuse shared primitives that include keyboard and ARIA support.\n *\n * Internationalization\n * - Text such as \"Export\", \"Customize columns\", and \"Reset columns\" are resolved via `react-i18next`.\n *\n * Usage Examples\n * 1) Minimal paginated table (uses default `dataKey = \"docs\"`)\n * ```tsx\n * type User = { id: string; name: string };\n * const data = { docs: [{ id: '1', name: 'Ada' }], page: 1, limit: 10, totalPages: 1 };\n *\n * <DataTable<User>\n * tableKey=\"users-table\"\n * columns={[{ key: 'name', name: 'Name' }]}\n * rowKey=\"id\"\n * dataSource={data}\n * hasPagination\n * />\n * ```\n *\n * 2) Custom `dataKey` and column visibility persistence\n * ```tsx\n * type Row = { id: number; title: string };\n * const payload = { items: [{ id: 1, title: 'Hello' }], page: 1, limit: 20, totalPages: 1 };\n *\n * <DataTable<Row>\n * tableKey=\"posts\"\n * columns={[{ key: 'title', name: 'Title' }]}\n * rowKey=\"id\"\n * dataSource={payload}\n * dataKey=\"items\"\n * hasColumnsVisibilityDropdown\n * />\n * ```\n *\n * 3) Responding to user interactions via `onParamChange`\n * ```tsx\n * const [params, setParams] = useState({ page: 1, limit: 10 });\n *\n * <DataTable\n * tableKey=\"logs\"\n * columns={[{ key: 'message', name: 'Message' }]}\n * rowKey=\"id\"\n * params={params}\n * onParamChange={setParams}\n * hasSearch\n * hasPagination\n * />\n * ```\n *\n * Notes and Best Practices\n * - Ensure `rowKey` points to a stable unique field in `TData` to avoid key collisions.\n * - When arrays like `exportOptions`, `filters`, or `actions` are empty, their sections are not rendered.\n * - Sorting emits `{ sortField, sortOrder }` through `onParamChange` when the user toggles a column sort.\n *\n * Returns\n * - React element that renders a complete data table experience.\n */\nexport const DataTable = <\n TData,\n TPaginationData extends PaginationInterface<TData> =\n PaginationInterface<TData>,\n>({\n dataSource,\n columns,\n onRowClick,\n rowKey,\n hasNumbers,\n hasSearch,\n exportOptions,\n hasCheckbox,\n hasPagination,\n isStickyHeader,\n onParamChange,\n dataKey = 'docs',\n loading,\n tableKey,\n filters,\n actions,\n handleFilterChange,\n params,\n exportLoading = false,\n onColumnsUpdate,\n hasColumnsVisibilityDropdown,\n onSelectedItemsChange,\n actionProps,\n filterWrapperProps,\n exportOptionsProps,\n columnsVisibilityProps,\n paginationProps,\n searchProps,\n ...props\n}: DataTableProps<TData, TPaginationData>) => {\n const { t } = useTranslation();\n const [selectedRows, setSelectedRows] = useState<TData[keyof TData][]>([]);\n const { formattedColumns, handleColumnsChange, resetColumns } =\n useColumns<TData>({ key: tableKey, columns });\n\n useEffect(() => {\n onColumnsUpdate?.(formattedColumns);\n }, [formattedColumns, onColumnsUpdate]);\n\n useEffect(() => {\n onSelectedItemsChange?.(selectedRows);\n }, [selectedRows, onSelectedItemsChange]);\n\n return (\n <div\n className={\n 'border-border-alpha-light flex grow flex-col overflow-auto rounded-xl border shadow-xs'\n }\n >\n {(hasSearch ||\n (hasColumnsVisibilityDropdown && tableKey) ||\n !isEmpty(exportOptions) ||\n !isEmpty(filters)) && (\n <div className=\"flex shrink-0 flex-col items-center justify-between gap-3 p-4 lg:flex-row\">\n <div className={'w-full shrink'}>\n {hasSearch && (\n <Search\n {...searchProps}\n className={cn('h-8 max-w-60', searchProps?.className)}\n defaultValue={get(params, 'search', '') as string}\n onSearchChange={(search) =>\n onParamChange?.({ ...params, search, page: 1 })\n }\n />\n )}\n </div>\n <div className={'flex shrink-0 items-center justify-end gap-3'}>\n {exportOptions && (\n <ExportData\n {...exportOptionsProps}\n options={exportOptions}\n loading={exportLoading}\n />\n )}\n {hasColumnsVisibilityDropdown && tableKey && (\n <DropdownMenu>\n <DropdownMenuTrigger\n asChild\n {...columnsVisibilityProps?.triggerProps}\n >\n <Button\n variant=\"secondary\"\n size={'sm'}\n className={'ml-auto rounded-lg px-3'}\n >\n {columnsVisibilityProps?.title || (\n <>\n <RiLayoutColumnLine />{' '}\n <span className={'hidden lg:!inline'}>\n {t('Customize columns')}\n </span>\n <RiArrowDownSLine />\n </>\n )}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"end\"\n {...columnsVisibilityProps?.contentProps}\n >\n <DropdownMenuItem\n className=\"capitalize\"\n onClick={resetColumns}\n >\n <RefreshCw />{' '}\n {columnsVisibilityProps?.resetText || t('Reset columns')}\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n {formattedColumns.map((column) => {\n return (\n <DropdownMenuCheckboxItem\n key={column.key}\n className=\"capitalize\"\n checked={!column.hidden}\n onCheckedChange={(value) =>\n handleColumnsChange(column, !value)\n }\n >\n {column.name}\n </DropdownMenuCheckboxItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n {actions && <Actions {...actionProps} actions={actions} />}\n {filters && (\n <FilterWrapper\n {...filterWrapperProps}\n filters={filters}\n params={params}\n onChange={handleFilterChange}\n onFilter={(filter) => {\n onParamChange?.({ ...params, ...filter, page: 1 });\n handleFilterChange?.(filter);\n }}\n />\n )}\n </div>\n </div>\n )}\n <div className={'flex flex-col overflow-auto border-y'}>\n {!loading ? (\n <MyTable<TData>\n {...props}\n params={{\n page: dataSource?.page || 1,\n limit: dataSource?.limit,\n ...params,\n }}\n rows={get(dataSource, dataKey, []) as TData[]}\n rowKey={rowKey}\n selectedItems={selectedRows}\n isStickyHeader={isStickyHeader}\n columns={formattedColumns}\n hasCheckbox={hasCheckbox}\n hasNumbers={hasNumbers}\n onRowClick={onRowClick}\n onSelectedItemsChange={setSelectedRows}\n onSortOrderChange={({ sortField, sortOrder }) => {\n onParamChange?.({ ...params, sortField, sortOrder });\n }}\n />\n ) : (\n <Loader />\n )}\n </div>\n {hasPagination && (\n <div className=\"flex shrink-0 flex-col items-center justify-between gap-3 p-4 lg:flex-row\">\n <div className=\"text-sm\">\n <MyLimitSelect\n onLimitChange={(limit) =>\n onParamChange?.({ ...params, limit, page: 1 })\n }\n defaultValue={dataSource?.limit}\n />\n </div>\n <div className=\"text-muted-foreground text-sm\">\n {t('{{selectedCount}} of {{total}} row(s) selected', {\n selectedCount: selectedRows.length,\n total: dataSource?.total || 0,\n })}\n </div>\n <div>\n <MyPagination\n {...paginationProps}\n onPageChange={(page) => onParamChange?.({ ...params, page })}\n currentPage={dataSource?.page}\n totalPages={dataSource?.totalPages}\n />\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"names":["MyTable","rows","columns","onRowClick","rowKey","params","DEFAULT_LIMIT","hasNumbers","hasCheckbox","selectedItems","onSelectedItemsChange","onSortOrderChange","isStickyHeader","className","props","sortObject","handleSort","useSortable","selectedRows","isRowSelected","isAllRowsSelected","handleSelectAllRows","handleSelectRow","useDataTable","useEffect","jsxs","Table","cn","jsx","TableHeader","TableRow","TableHead","Checkbox","value","column","Fragment","SortOrder","ArrowDownWideNarrow","ArrowUpWideNarrow","ArrowUpDown","TableBody","row","index","TableCell","evt","get","Empty","DataTable","dataSource","hasSearch","exportOptions","hasPagination","onParamChange","dataKey","loading","tableKey","filters","actions","handleFilterChange","exportLoading","onColumnsUpdate","hasColumnsVisibilityDropdown","actionProps","filterWrapperProps","exportOptionsProps","columnsVisibilityProps","paginationProps","searchProps","t","useTranslation","setSelectedRows","useState","formattedColumns","handleColumnsChange","resetColumns","useColumns","isEmpty","Search","search","ExportData","DropdownMenu","DropdownMenuTrigger","Button","RiLayoutColumnLine","RiArrowDownSLine","DropdownMenuContent","DropdownMenuItem","RefreshCw","DropdownMenuSeparator","DropdownMenuCheckboxItem","Actions","FilterWrapper","filter","Loader","sortField","sortOrder","MyLimitSelect","limit","MyPagination","page"],"mappings":";;;;;;;;;;;;;;;;;;;AAiEO,MAAMA,KAAU,CAAS;AAAA,EAC9B,MAAAC,IAAO,CAAA;AAAA,EACP,SAAAC;AAAA,EACA,YAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,IACP,MAAM;AAAA,IACN,OAAOC;AAAA,EAAA;AAAA,EAET,YAAAC,IAAa;AAAA,EACb,aAAAC,IAAc;AAAA,EACd,eAAAC;AAAA,EACA,uBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,MAA2B;AACzB,QAAM,EAAE,YAAAC,GAAY,YAAAC,EAAA,IAAeC,GAAmB;AAAA,IACpD,WAAWZ,KAAA,gBAAAA,EAAQ;AAAA,IACnB,WAAWA,KAAA,gBAAAA,EAAQ;AAAA,IACnB,mBAAAM;AAAA,EAAA,CACD,GACK;AAAA,IACJ,cAAAO;AAAA,IACA,eAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,iBAAAC;AAAA,EAAA,IACEC,GAAoB,EAAE,MAAAtB,GAAM,qBAAqBQ,GAAe;AAEpE,SAAAe,EAAU,MAAM;AACd,IACE,KAAK,UAAUf,CAAa,MAAM,KAAK,UAAUS,CAAY,KAC7DA,MAEAR,KAAA,QAAAA,EAAwBQ;AA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