@wordrhyme/auto-crud 1.9.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -264,6 +264,11 @@ interface AutoCrudTableProps<TSchema> {
264
264
  table?: {
265
265
  hidden?: string[]; // 隐藏的列
266
266
  overrides?: Record<string, any>; // 列覆盖配置
267
+ getRowId?: (record: z.output<TSchema>) => string; // 稳定行标识;展开时必填
268
+ expandedRow?: (
269
+ record: z.output<TSchema>,
270
+ row: Row<z.output<TSchema>>,
271
+ ) => React.ReactNode; // 展开行内容,row 提供已解析的单元格上下文
267
272
  filterModes?: FilterMode | FilterMode[]; // 过滤模式
268
273
  batchFields?: (string | BatchUpdateField)[]; // 批量更新字段
269
274
  /** @deprecated 新代码请使用 actions.batch */
@@ -294,6 +299,33 @@ interface AutoCrudTableProps<TSchema> {
294
299
  }
295
300
  ```
296
301
 
302
+ #### 展开行详情
303
+
304
+ 配置 `table.expandedRow` 后,表格自动添加展开箭头。默认全部收起,允许同时展开多行。设置 `table.defaultExpanded: true` 可在首次展示时展开全部行;刷新保留用户的展开选择。该选项仅用于初始化,不控制当前展开状态。
305
+ 必须提供 TanStack Table 的 `getRowId`,使用稳定且唯一的业务主键,避免分页、排序后展开错位。
306
+ 展开内容可使用 `cqw` 单位,以表格可视区域的宽度为基准,避免宽表中的详情被横向裁切。
307
+
308
+ ```tsx
309
+ <AutoCrudTable
310
+ schema={orderSchema}
311
+ resource={resource}
312
+ table={{
313
+ getRowId: (order) => order.id,
314
+ expandedRow: (order) => <OrderDetails orderId={order.id} />,
315
+ }}
316
+ />
317
+ ```
318
+
319
+ 回调接收当前行的原始记录,并同步返回 React 内容。详情组件只在展开时挂载,收起时卸载;
320
+ 可由详情组件按订单 ID 查询数据并处理加载、错误和重试,也可直接使用记录中已有的明细。
321
+ 明细数据及其字段权限由业务组件和现有服务负责。
322
+
323
+ 详情区域跨全部可见列,不计入分页条数,也不参与主表选择或导出。
324
+ 未启用 `defaultExpanded` 时,数据更新后的展开状态遵循 TanStack Table 默认重置行为。
325
+ `AutoTable` 同样支持 `getRowId` 和 `expandedRow`;直接使用 `DataTable` 时,需自行配置 TanStack 展开能力及触发按钮。
326
+
327
+ `expandedRow` 的第二个参数是当前 TanStack `Row`,可通过 `row.getAllCells()` 读取已解析的列和单元格上下文,复用字段渲染器及数据源标签。只接收订单数据的单参数回调仍可使用。
328
+
297
329
  ### `useAutoCrudResource()`
298
330
 
299
331
  连接数据源到组件的 Hook。
package/dist/index.cjs CHANGED
@@ -566,7 +566,7 @@ function formatDate(date, opts = {}, preset) {
566
566
 
567
567
  //#endregion
568
568
  //#region src/components/data-table/data-table.tsx
569
- function DataTable({ table, actionBar, pagination, children, className, classNames,...props }) {
569
+ function DataTable({ table, actionBar, pagination, expandedRow, children, className, classNames,...props }) {
570
570
  useDateFormatterVersion();
571
571
  const columns = [
572
572
  ...table.getLeftVisibleLeafColumns(),
@@ -581,6 +581,7 @@ function DataTable({ table, actionBar, pagination, children, className, classNam
581
581
  children,
582
582
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
583
583
  className: "overflow-hidden rounded-md border",
584
+ style: expandedRow ? { containerType: "inline-size" } : void 0,
584
585
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__wordrhyme_shadcn.Table, {
585
586
  className: classNames?.table,
586
587
  style: hasWidthCap ? {
@@ -606,7 +607,7 @@ function DataTable({ table, actionBar, pagination, children, className, classNam
606
607
  }),
607
608
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.TableBody, {
608
609
  className: classNames?.tbody,
609
- children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.TableRow, {
610
+ children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.TableRow, {
610
611
  className: classNames?.tr,
611
612
  "data-state": row.getIsSelected() && "selected",
612
613
  children: row.getVisibleCells().map((cell) => {
@@ -617,7 +618,14 @@ function DataTable({ table, actionBar, pagination, children, className, classNam
617
618
  children: (0, __tanstack_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext())
618
619
  }, cell.id);
619
620
  })
620
- }, row.id)) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.TableRow, {
621
+ }), expandedRow && row.getCanExpand() && row.getIsExpanded() && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.TableRow, {
622
+ className: classNames?.tr,
623
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.TableCell, {
624
+ colSpan: row.getVisibleCells().length,
625
+ className: classNames?.td,
626
+ children: expandedRow(row.original, row)
627
+ })
628
+ })] }, row.id)) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.TableRow, {
621
629
  className: classNames?.tr,
622
630
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.TableCell, {
623
631
  colSpan: table.getAllColumns().length,
@@ -3906,9 +3914,12 @@ function coerceRowValues(rows, schema) {
3906
3914
 
3907
3915
  //#endregion
3908
3916
  //#region src/lib/export.ts
3917
+ function getExportColumnIds(table) {
3918
+ return table.getAllLeafColumns().filter((column) => column.accessorFn).map((column) => column.id);
3919
+ }
3909
3920
  function exportTableToCSV(table, opts = {}) {
3910
3921
  const { filename = "table", excludeColumns = [], onlySelected = false } = opts;
3911
- const headers = table.getAllLeafColumns().map((column) => column.id).filter((id) => !excludeColumns.includes(id));
3922
+ const headers = getExportColumnIds(table).filter((id) => !excludeColumns.includes(id));
3912
3923
  downloadCSV([headers.join(","), ...(onlySelected ? table.getFilteredSelectedRowModel().rows : table.getRowModel().rows).map((row) => headers.map((header) => {
3913
3924
  const cellValue = row.getValue(header);
3914
3925
  return typeof cellValue === "string" ? `"${cellValue.replace(/"/g, "\"\"")}"` : cellValue;
@@ -4419,7 +4430,9 @@ const filterModeConfig = {
4419
4430
  tooltip: "Linear-style command filters"
4420
4431
  }
4421
4432
  };
4422
- function AutoTable({ schema, data, pageCount = 1, pagination, total, overrides, classNames, enableRowSelection = true, exclude, filterOnly, actions, pinnedColumns, filterMode, search = false, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows }) {
4433
+ function AutoTable({ schema, data, getRowId, expandedRow, defaultExpanded = false, pageCount = 1, pagination, total, overrides, classNames, enableRowSelection = true, exclude, filterOnly, actions, pinnedColumns, filterMode, search = false, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows }) {
4434
+ if (expandedRow && !getRowId) throw new Error("AutoTable requires getRowId when expandedRow is provided.");
4435
+ const enableExpansion = !!expandedRow;
4423
4436
  const modes = filterMode ? Array.isArray(filterMode) ? filterMode : [filterMode] : DEFAULT_MODES;
4424
4437
  const [currentMode, setCurrentMode] = useQueryState("filterMode", parseAsStringEnum(modes).withDefault(modes[0] ?? "simple"));
4425
4438
  const showToggle = modes.length > 1;
@@ -4433,7 +4446,7 @@ function AutoTable({ schema, data, pageCount = 1, pagination, total, overrides,
4433
4446
  });
4434
4447
  const searchConfig = search && typeof search === "object" ? search : {};
4435
4448
  const enableAdvancedFilter = true;
4436
- const columns = (0, react.useMemo)(() => {
4449
+ const { columns, expandColumnId } = (0, react.useMemo)(() => {
4437
4450
  const columnOverrides = Object.assign({}, overrides);
4438
4451
  for (const key of filterOnly ?? []) {
4439
4452
  const field = key;
@@ -4454,31 +4467,67 @@ function AutoTable({ schema, data, pageCount = 1, pagination, total, overrides,
4454
4467
  } : column;
4455
4468
  });
4456
4469
  const result = enableRowSelection ? [createSelectColumn(), ...dataColumns] : dataColumns;
4470
+ let expandColumnId$1 = "expand";
4471
+ if (enableExpansion) {
4472
+ while (expandColumnId$1 in schema.shape || result.some((column) => column.id === expandColumnId$1)) expandColumnId$1 = `_${expandColumnId$1}`;
4473
+ result.unshift({
4474
+ id: expandColumnId$1,
4475
+ header: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4476
+ className: "sr-only",
4477
+ children: "Row details"
4478
+ }),
4479
+ cell: ({ row }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__wordrhyme_shadcn.Button, {
4480
+ type: "button",
4481
+ variant: "ghost",
4482
+ size: "icon-sm",
4483
+ "aria-label": row.getIsExpanded() ? "Collapse row" : "Expand row",
4484
+ "aria-expanded": row.getIsExpanded(),
4485
+ onClick: row.getToggleExpandedHandler(),
4486
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRightIcon, { className: row.getIsExpanded() ? "size-4 rotate-90" : "size-4" })
4487
+ }),
4488
+ enableHiding: false,
4489
+ enableSorting: false,
4490
+ size: 40
4491
+ });
4492
+ }
4457
4493
  if (actions) result.push(createActionsColumn(actions));
4458
- return result;
4494
+ return {
4495
+ columns: result,
4496
+ expandColumnId: expandColumnId$1
4497
+ };
4459
4498
  }, [
4460
4499
  schema,
4461
4500
  overrides,
4462
4501
  enableRowSelection,
4502
+ enableExpansion,
4463
4503
  exclude,
4464
4504
  actions,
4465
4505
  filterOnly
4466
4506
  ]);
4467
4507
  const stableInitialState = (0, react.useMemo)(() => ({
4468
4508
  sorting: initialSorting,
4509
+ expanded: enableExpansion && defaultExpanded ? true : {},
4469
4510
  columnPinning: pinnedColumns ?? {
4470
- left: enableRowSelection ? ["select"] : [],
4511
+ left: [...enableExpansion ? [expandColumnId] : [], ...enableRowSelection ? ["select"] : []],
4471
4512
  right: actions ? ["actions"] : []
4472
4513
  }
4473
4514
  }), [
4474
4515
  initialSorting,
4475
4516
  pinnedColumns,
4476
4517
  enableRowSelection,
4518
+ enableExpansion,
4519
+ defaultExpanded,
4520
+ expandColumnId,
4477
4521
  actions
4478
4522
  ]);
4523
+ const expandedRowModel = (0, react.useMemo)(() => (0, __tanstack_react_table.getExpandedRowModel)(), []);
4479
4524
  const { table, shallow, debounceMs, throttleMs } = useDataTable({
4480
4525
  data,
4481
4526
  columns,
4527
+ getRowId,
4528
+ getRowCanExpand: () => enableExpansion,
4529
+ getExpandedRowModel: enableExpansion ? expandedRowModel : void 0,
4530
+ autoResetExpanded: defaultExpanded ? false : void 0,
4482
4531
  pageCount,
4483
4532
  ...total !== void 0 ? { rowCount: total } : {},
4484
4533
  enableAdvancedFilter,
@@ -4610,7 +4659,8 @@ function AutoTable({ schema, data, pageCount = 1, pagination, total, overrides,
4610
4659
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTable, {
4611
4660
  pagination,
4612
4661
  table,
4613
- classNames
4662
+ classNames,
4663
+ expandedRow
4614
4664
  }),
4615
4665
  enableRowSelection && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AutoTableActionBar, {
4616
4666
  table,
@@ -7553,7 +7603,7 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7553
7603
  return {
7554
7604
  ...action$1,
7555
7605
  onClick: (_rows, { table }) => {
7556
- const headers = table.getAllLeafColumns().map((column) => column.id).filter((key) => key !== "select" && key !== "actions" && !denyFields?.includes(key));
7606
+ const headers = getExportColumnIds(table).filter((key) => key !== "select" && key !== "actions" && !denyFields?.includes(key));
7557
7607
  exportAllToCSV(table.getFilteredSelectedRowModel().rows.map((row) => formatExportRow(row.original, resolvedFields, Object.fromEntries(headers.map((key) => [key, row.getValue(key)])))), {
7558
7608
  filename: "table",
7559
7609
  headers
@@ -7813,6 +7863,9 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7813
7863
  ...pagination
7814
7864
  } : void 0,
7815
7865
  ...resource.tableData.total !== void 0 ? { total: resource.tableData.total } : {},
7866
+ getRowId: tableConfig?.getRowId,
7867
+ expandedRow: tableConfig?.expandedRow,
7868
+ defaultExpanded: tableConfig?.defaultExpanded,
7816
7869
  overrides: tableOverrides,
7817
7870
  classNames: tableConfig?.classNames,
7818
7871
  exclude: hiddenColumns.filter((key) => !filterOnly.includes(key)),
package/dist/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { a as positionActions, i as matchesPosition, n as actionPositionSchema, r as compareOrder, t as ActionPosition } from "./position-DoBV7yB6.cjs";
2
- import * as react_jsx_runtime4 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime8 from "react/jsx-runtime";
3
3
  import * as React$1 from "react";
4
+ import { ComponentProps, ReactNode } from "react";
4
5
  import * as _tanstack_react_table0 from "@tanstack/react-table";
5
6
  import { Column, ColumnDef, ColumnMeta, ColumnSort, Row, RowData, Table, TableOptions, TableState } from "@tanstack/react-table";
6
7
  import { z } from "zod";
@@ -651,6 +652,26 @@ interface CrudPermissions {
651
652
  deny?: string[];
652
653
  }
653
654
  //#endregion
655
+ //#region src/components/data-table/data-table.d.ts
656
+ interface DataTableProps<TData> extends ComponentProps<'div'> {
657
+ table: Table<TData>;
658
+ pagination?: TablePaginationOptions;
659
+ classNames?: DataTableClassNames;
660
+ actionBar?: ReactNode;
661
+ /** Content mounted below an expanded row; row provides resolved cell contexts. */
662
+ expandedRow?: (record: TData, row: Row<TData>) => ReactNode;
663
+ }
664
+ declare function DataTable<TData>({
665
+ table,
666
+ actionBar,
667
+ pagination,
668
+ expandedRow,
669
+ children,
670
+ className,
671
+ classNames,
672
+ ...props
673
+ }: DataTableProps<TData>): react_jsx_runtime8.JSX.Element;
674
+ //#endregion
654
675
  //#region src/components/auto-crud/auto-table-action-bar.d.ts
655
676
  /** 批量更新字段配置 */
656
677
  interface BatchUpdateField {
@@ -738,7 +759,7 @@ declare function AutoTableActionBar<TData>({
738
759
  extraActions,
739
760
  actions,
740
761
  deleteConfirmation
741
- }: AutoTableActionBarProps<TData>): react_jsx_runtime4.JSX.Element;
762
+ }: AutoTableActionBarProps<TData>): react_jsx_runtime8.JSX.Element;
742
763
  //#endregion
743
764
  //#region src/lib/schema-bridge/types.d.ts
744
765
  /**
@@ -847,9 +868,13 @@ declare function createActionsColumn<T>(items: ActionsColumnConfig<T>): ColumnDe
847
868
  //#region src/components/auto-crud/auto-table.d.ts
848
869
  /** 过滤模式类型 */
849
870
  type FilterMode = 'simple' | 'advanced' | 'command';
850
- interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> {
871
+ interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> extends Pick<DataTableProps<z.infer<T>>, 'expandedRow'> {
851
872
  schema: T;
852
873
  data: z.infer<T>[];
874
+ /** Stable row identity; required when expandedRow is provided. */
875
+ getRowId?: TableOptions<z.infer<T>>['getRowId'];
876
+ /** Initially expand all rows. Defaults to false; only applies with expandedRow. */
877
+ defaultExpanded?: boolean;
853
878
  pageCount?: number;
854
879
  pagination?: TablePaginationOptions;
855
880
  /** Total rows matching the current search and filters. */
@@ -905,6 +930,9 @@ interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> {
905
930
  declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
906
931
  schema,
907
932
  data,
933
+ getRowId,
934
+ expandedRow,
935
+ defaultExpanded,
908
936
  pageCount,
909
937
  pagination,
910
938
  total,
@@ -929,7 +957,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
929
957
  onSelectedCountChange,
930
958
  onSelectedRowsChange,
931
959
  getSelectedRows
932
- }: AutoTableProps<T>): react_jsx_runtime4.JSX.Element;
960
+ }: AutoTableProps<T>): react_jsx_runtime8.JSX.Element;
933
961
  //#endregion
934
962
  //#region src/lib/row-action-dialog.d.ts
935
963
  interface RowActionDialogProps {
@@ -1401,7 +1429,7 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
1401
1429
  batchActions?: BatchActionConfig<z.output<TSchema>>;
1402
1430
  /** 默认排序 */
1403
1431
  defaultSort?: any[];
1404
- };
1432
+ } & Pick<AutoTableProps<TSchema>, 'getRowId' | 'expandedRow' | 'defaultExpanded'>;
1405
1433
  /** 表单配置 */
1406
1434
  form?: {
1407
1435
  /** 表单覆盖配置(兼容旧 API,优先级低于 fieldOverrides) */
@@ -1483,7 +1511,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
1483
1511
  toolbarActions,
1484
1512
  locale: localeProp,
1485
1513
  onCreate
1486
- }: AutoCrudTableProps<TSchema>): react_jsx_runtime4.JSX.Element;
1514
+ }: AutoCrudTableProps<TSchema>): react_jsx_runtime8.JSX.Element;
1487
1515
  //#endregion
1488
1516
  //#region src/components/auto-crud/auto-form.d.ts
1489
1517
  interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
@@ -1522,7 +1550,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
1522
1550
  labelAlign,
1523
1551
  labelWidth,
1524
1552
  showSubmitButton
1525
- }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime4.JSX.Element;
1553
+ }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime8.JSX.Element;
1526
1554
  declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
1527
1555
  ref?: React.Ref<AutoFormRef>;
1528
1556
  }) => ReturnType<typeof AutoFormInner>;
@@ -1541,7 +1569,7 @@ declare function AutoTableSimpleFilters<TData>({
1541
1569
  filters: externalFilters,
1542
1570
  onFiltersChange,
1543
1571
  leading
1544
- }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime4.JSX.Element | null;
1572
+ }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime8.JSX.Element | null;
1545
1573
  //#endregion
1546
1574
  //#region src/components/auto-crud/form-modal.d.ts
1547
1575
  type ModalVariant = 'dialog' | 'sheet';
@@ -1585,7 +1613,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
1585
1613
  labelAlign,
1586
1614
  labelWidth,
1587
1615
  className
1588
- }: CrudFormModalProps<T>): react_jsx_runtime4.JSX.Element;
1616
+ }: CrudFormModalProps<T>): react_jsx_runtime8.JSX.Element;
1589
1617
  //#endregion
1590
1618
  //#region src/components/auto-crud/import-dialog.d.ts
1591
1619
  interface ImportDialogProps {
@@ -1607,7 +1635,7 @@ declare function ImportDialog({
1607
1635
  columns,
1608
1636
  title,
1609
1637
  locale
1610
- }: ImportDialogProps): react_jsx_runtime4.JSX.Element;
1638
+ }: ImportDialogProps): react_jsx_runtime8.JSX.Element;
1611
1639
  //#endregion
1612
1640
  //#region src/components/auto-crud/export-dialog.d.ts
1613
1641
  type ExportMode = 'selected' | 'filtered';
@@ -1627,24 +1655,7 @@ declare function ExportDialog({
1627
1655
  selectedCount,
1628
1656
  onExport,
1629
1657
  canExportFiltered
1630
- }: ExportDialogProps): react_jsx_runtime4.JSX.Element;
1631
- //#endregion
1632
- //#region src/components/data-table/data-table.d.ts
1633
- interface DataTableProps<TData> extends React$1.ComponentProps<'div'> {
1634
- table: Table<TData>;
1635
- pagination?: TablePaginationOptions;
1636
- classNames?: DataTableClassNames;
1637
- actionBar?: React$1.ReactNode;
1638
- }
1639
- declare function DataTable<TData>({
1640
- table,
1641
- actionBar,
1642
- pagination,
1643
- children,
1644
- className,
1645
- classNames,
1646
- ...props
1647
- }: DataTableProps<TData>): react_jsx_runtime4.JSX.Element;
1658
+ }: ExportDialogProps): react_jsx_runtime8.JSX.Element;
1648
1659
  //#endregion
1649
1660
  //#region src/components/data-table/data-table-advanced-toolbar.d.ts
1650
1661
  interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<'div'> {
@@ -1655,7 +1666,7 @@ declare function DataTableAdvancedToolbar<TData>({
1655
1666
  children,
1656
1667
  className,
1657
1668
  ...props
1658
- }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime4.JSX.Element;
1669
+ }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime8.JSX.Element;
1659
1670
  //#endregion
1660
1671
  //#region src/components/data-table/data-table-column-header.d.ts
1661
1672
  interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
@@ -1667,7 +1678,7 @@ declare function DataTableColumnHeader<TData, TValue>({
1667
1678
  label,
1668
1679
  className,
1669
1680
  ...props
1670
- }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime4.JSX.Element;
1681
+ }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime8.JSX.Element;
1671
1682
  //#endregion
1672
1683
  //#region src/components/data-table/data-table-faceted-filter.d.ts
1673
1684
  interface DataTableFacetedFilterProps<TData, TValue> {
@@ -1681,7 +1692,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
1681
1692
  title,
1682
1693
  options,
1683
1694
  multiple
1684
- }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime4.JSX.Element;
1695
+ }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime8.JSX.Element;
1685
1696
  //#endregion
1686
1697
  //#region src/components/data-table/data-table-pagination.d.ts
1687
1698
  interface DataTablePaginationProps<TData> extends React.ComponentProps<'div'>, TablePaginationOptions {
@@ -1697,7 +1708,7 @@ declare function DataTablePagination<TData>({
1697
1708
  pageJumpLabel,
1698
1709
  className,
1699
1710
  ...props
1700
- }: DataTablePaginationProps<TData>): react_jsx_runtime4.JSX.Element;
1711
+ }: DataTablePaginationProps<TData>): react_jsx_runtime8.JSX.Element;
1701
1712
  //#endregion
1702
1713
  //#region src/components/data-table/data-table-toolbar.d.ts
1703
1714
  interface DataTableToolbarProps<TData> extends React$1.ComponentProps<'div'> {
@@ -1708,7 +1719,7 @@ declare function DataTableToolbar<TData>({
1708
1719
  children,
1709
1720
  className,
1710
1721
  ...props
1711
- }: DataTableToolbarProps<TData>): react_jsx_runtime4.JSX.Element;
1722
+ }: DataTableToolbarProps<TData>): react_jsx_runtime8.JSX.Element;
1712
1723
  //#endregion
1713
1724
  //#region src/components/data-table/data-table-view-options.d.ts
1714
1725
  interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
@@ -1719,7 +1730,7 @@ declare function DataTableViewOptions<TData>({
1719
1730
  table,
1720
1731
  disabled,
1721
1732
  ...props
1722
- }: DataTableViewOptionsProps<TData>): react_jsx_runtime4.JSX.Element;
1733
+ }: DataTableViewOptionsProps<TData>): react_jsx_runtime8.JSX.Element;
1723
1734
  //#endregion
1724
1735
  //#region src/lib/crud-actions.d.ts
1725
1736
  type CrudActionZone = 'toolbar' | 'row' | 'batch';
@@ -2113,4 +2124,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
2113
2124
  */
2114
2125
  declare function downloadCSVTemplate(headers: string[], filename?: string): void;
2115
2126
  //#endregion
2116
- export { type ActionConfig, type ActionItem, type ActionPosition, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudQueryCapabilities, type AutoCrudRowActionContext, type AutoCrudRowOpenOptions, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableClassNames, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type DateFormatPreset, type DateFormatter, type DateLocaleOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldOption, type FieldTableDisplay, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, type RowActionConfig, type RowActionDialogProps, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type TablePaginationOptions, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, actionPositionSchema, cn, coerceRowValues, compareOrder, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, matchesPosition, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, positionActions, resolveLocale, setDateFormatter, setSearchParams, setToolbarResolver, tablePagination, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
2127
+ export { type ActionConfig, type ActionItem, type ActionPosition, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudQueryCapabilities, type AutoCrudRowActionContext, type AutoCrudRowOpenOptions, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, type AutoQueryParams, AutoTable, AutoTableActionBar, type AutoTableProps, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableClassNames, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, type DataTableProps, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type DateFormatPreset, type DateFormatter, type DateLocaleOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldOption, type FieldTableDisplay, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, type RowActionConfig, type RowActionDialogProps, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type TablePaginationOptions, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, actionPositionSchema, cn, coerceRowValues, compareOrder, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, matchesPosition, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, positionActions, resolveLocale, setDateFormatter, setSearchParams, setToolbarResolver, tablePagination, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { a as positionActions, i as matchesPosition, n as actionPositionSchema, r as compareOrder, t as ActionPosition } from "./position-mYekVBBH.js";
2
2
  import * as React$1 from "react";
3
+ import { ComponentProps, ReactNode } from "react";
3
4
  import * as _tanstack_react_table0 from "@tanstack/react-table";
4
5
  import { Column, ColumnDef, ColumnMeta, ColumnSort, Row, RowData, Table, TableOptions, TableState } from "@tanstack/react-table";
5
6
  import { DropdownMenuTrigger, PopoverContent } from "@wordrhyme/shadcn";
6
7
  import { ClassValue } from "clsx";
7
- import * as react_jsx_runtime2 from "react/jsx-runtime";
8
+ import * as react_jsx_runtime8 from "react/jsx-runtime";
8
9
  import { MultiCombobox, MultiComboboxOption, MultiComboboxProps, MultiComboboxTriggerRenderProps, Select, SelectMode, SelectOption, SelectProps, SelectSearchableDynamicProps, SelectSearchableMultipleProps, SelectSearchableProps, SelectSearchableSingleProps, SelectSimpleProps, SelectTriggerRenderProps } from "@wordrhyme/shadcn-ui";
9
10
  import { DropdownMenuItem as DropdownMenuItem$1 } from "@wordrhyme/ui";
10
11
  import { z } from "zod";
@@ -651,6 +652,26 @@ interface CrudPermissions {
651
652
  deny?: string[];
652
653
  }
653
654
  //#endregion
655
+ //#region src/components/data-table/data-table.d.ts
656
+ interface DataTableProps<TData> extends ComponentProps<'div'> {
657
+ table: Table<TData>;
658
+ pagination?: TablePaginationOptions;
659
+ classNames?: DataTableClassNames;
660
+ actionBar?: ReactNode;
661
+ /** Content mounted below an expanded row; row provides resolved cell contexts. */
662
+ expandedRow?: (record: TData, row: Row<TData>) => ReactNode;
663
+ }
664
+ declare function DataTable<TData>({
665
+ table,
666
+ actionBar,
667
+ pagination,
668
+ expandedRow,
669
+ children,
670
+ className,
671
+ classNames,
672
+ ...props
673
+ }: DataTableProps<TData>): react_jsx_runtime8.JSX.Element;
674
+ //#endregion
654
675
  //#region src/components/auto-crud/auto-table-action-bar.d.ts
655
676
  /** 批量更新字段配置 */
656
677
  interface BatchUpdateField {
@@ -738,7 +759,7 @@ declare function AutoTableActionBar<TData>({
738
759
  extraActions,
739
760
  actions,
740
761
  deleteConfirmation
741
- }: AutoTableActionBarProps<TData>): react_jsx_runtime2.JSX.Element;
762
+ }: AutoTableActionBarProps<TData>): react_jsx_runtime8.JSX.Element;
742
763
  //#endregion
743
764
  //#region src/lib/schema-bridge/types.d.ts
744
765
  /**
@@ -847,9 +868,13 @@ declare function createActionsColumn<T>(items: ActionsColumnConfig<T>): ColumnDe
847
868
  //#region src/components/auto-crud/auto-table.d.ts
848
869
  /** 过滤模式类型 */
849
870
  type FilterMode = 'simple' | 'advanced' | 'command';
850
- interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> {
871
+ interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> extends Pick<DataTableProps<z.infer<T>>, 'expandedRow'> {
851
872
  schema: T;
852
873
  data: z.infer<T>[];
874
+ /** Stable row identity; required when expandedRow is provided. */
875
+ getRowId?: TableOptions<z.infer<T>>['getRowId'];
876
+ /** Initially expand all rows. Defaults to false; only applies with expandedRow. */
877
+ defaultExpanded?: boolean;
853
878
  pageCount?: number;
854
879
  pagination?: TablePaginationOptions;
855
880
  /** Total rows matching the current search and filters. */
@@ -905,6 +930,9 @@ interface AutoTableProps<T extends z.ZodObject<z.ZodRawShape>> {
905
930
  declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
906
931
  schema,
907
932
  data,
933
+ getRowId,
934
+ expandedRow,
935
+ defaultExpanded,
908
936
  pageCount,
909
937
  pagination,
910
938
  total,
@@ -929,7 +957,7 @@ declare function AutoTable<T extends z.ZodObject<z.ZodRawShape>>({
929
957
  onSelectedCountChange,
930
958
  onSelectedRowsChange,
931
959
  getSelectedRows
932
- }: AutoTableProps<T>): react_jsx_runtime2.JSX.Element;
960
+ }: AutoTableProps<T>): react_jsx_runtime8.JSX.Element;
933
961
  //#endregion
934
962
  //#region src/lib/row-action-dialog.d.ts
935
963
  interface RowActionDialogProps {
@@ -1401,7 +1429,7 @@ interface AutoCrudTableProps<TSchema extends z.ZodObject<z.ZodRawShape>> {
1401
1429
  batchActions?: BatchActionConfig<z.output<TSchema>>;
1402
1430
  /** 默认排序 */
1403
1431
  defaultSort?: any[];
1404
- };
1432
+ } & Pick<AutoTableProps<TSchema>, 'getRowId' | 'expandedRow' | 'defaultExpanded'>;
1405
1433
  /** 表单配置 */
1406
1434
  form?: {
1407
1435
  /** 表单覆盖配置(兼容旧 API,优先级低于 fieldOverrides) */
@@ -1483,7 +1511,7 @@ declare function AutoCrudTable<TSchema extends z.ZodObject<z.ZodRawShape>>({
1483
1511
  toolbarActions,
1484
1512
  locale: localeProp,
1485
1513
  onCreate
1486
- }: AutoCrudTableProps<TSchema>): react_jsx_runtime2.JSX.Element;
1514
+ }: AutoCrudTableProps<TSchema>): react_jsx_runtime8.JSX.Element;
1487
1515
  //#endregion
1488
1516
  //#region src/components/auto-crud/auto-form.d.ts
1489
1517
  interface AutoFormProps<T extends z.ZodObject<z.ZodRawShape>> {
@@ -1522,7 +1550,7 @@ declare function AutoFormInner<T extends z.ZodObject<z.ZodRawShape>>({
1522
1550
  labelAlign,
1523
1551
  labelWidth,
1524
1552
  showSubmitButton
1525
- }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime2.JSX.Element;
1553
+ }: AutoFormProps<T>, ref: React.Ref<AutoFormRef>): react_jsx_runtime8.JSX.Element;
1526
1554
  declare const AutoForm: <T extends z.ZodObject<z.ZodRawShape>>(props: AutoFormProps<T> & {
1527
1555
  ref?: React.Ref<AutoFormRef>;
1528
1556
  }) => ReturnType<typeof AutoFormInner>;
@@ -1541,7 +1569,7 @@ declare function AutoTableSimpleFilters<TData>({
1541
1569
  filters: externalFilters,
1542
1570
  onFiltersChange,
1543
1571
  leading
1544
- }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime2.JSX.Element | null;
1572
+ }: AutoTableSimpleFiltersProps<TData>): react_jsx_runtime8.JSX.Element | null;
1545
1573
  //#endregion
1546
1574
  //#region src/components/auto-crud/form-modal.d.ts
1547
1575
  type ModalVariant = 'dialog' | 'sheet';
@@ -1585,7 +1613,7 @@ declare function CrudFormModal<T extends z.ZodObject<z.ZodRawShape>>({
1585
1613
  labelAlign,
1586
1614
  labelWidth,
1587
1615
  className
1588
- }: CrudFormModalProps<T>): react_jsx_runtime2.JSX.Element;
1616
+ }: CrudFormModalProps<T>): react_jsx_runtime8.JSX.Element;
1589
1617
  //#endregion
1590
1618
  //#region src/components/auto-crud/import-dialog.d.ts
1591
1619
  interface ImportDialogProps {
@@ -1607,7 +1635,7 @@ declare function ImportDialog({
1607
1635
  columns,
1608
1636
  title,
1609
1637
  locale
1610
- }: ImportDialogProps): react_jsx_runtime2.JSX.Element;
1638
+ }: ImportDialogProps): react_jsx_runtime8.JSX.Element;
1611
1639
  //#endregion
1612
1640
  //#region src/components/auto-crud/export-dialog.d.ts
1613
1641
  type ExportMode = 'selected' | 'filtered';
@@ -1627,24 +1655,7 @@ declare function ExportDialog({
1627
1655
  selectedCount,
1628
1656
  onExport,
1629
1657
  canExportFiltered
1630
- }: ExportDialogProps): react_jsx_runtime2.JSX.Element;
1631
- //#endregion
1632
- //#region src/components/data-table/data-table.d.ts
1633
- interface DataTableProps<TData> extends React$1.ComponentProps<'div'> {
1634
- table: Table<TData>;
1635
- pagination?: TablePaginationOptions;
1636
- classNames?: DataTableClassNames;
1637
- actionBar?: React$1.ReactNode;
1638
- }
1639
- declare function DataTable<TData>({
1640
- table,
1641
- actionBar,
1642
- pagination,
1643
- children,
1644
- className,
1645
- classNames,
1646
- ...props
1647
- }: DataTableProps<TData>): react_jsx_runtime2.JSX.Element;
1658
+ }: ExportDialogProps): react_jsx_runtime8.JSX.Element;
1648
1659
  //#endregion
1649
1660
  //#region src/components/data-table/data-table-advanced-toolbar.d.ts
1650
1661
  interface DataTableAdvancedToolbarProps<TData> extends React$1.ComponentProps<'div'> {
@@ -1655,7 +1666,7 @@ declare function DataTableAdvancedToolbar<TData>({
1655
1666
  children,
1656
1667
  className,
1657
1668
  ...props
1658
- }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
1669
+ }: DataTableAdvancedToolbarProps<TData>): react_jsx_runtime8.JSX.Element;
1659
1670
  //#endregion
1660
1671
  //#region src/components/data-table/data-table-column-header.d.ts
1661
1672
  interface DataTableColumnHeaderProps<TData, TValue> extends React.ComponentProps<typeof DropdownMenuTrigger> {
@@ -1667,7 +1678,7 @@ declare function DataTableColumnHeader<TData, TValue>({
1667
1678
  label,
1668
1679
  className,
1669
1680
  ...props
1670
- }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
1681
+ }: DataTableColumnHeaderProps<TData, TValue>): react_jsx_runtime8.JSX.Element;
1671
1682
  //#endregion
1672
1683
  //#region src/components/data-table/data-table-faceted-filter.d.ts
1673
1684
  interface DataTableFacetedFilterProps<TData, TValue> {
@@ -1681,7 +1692,7 @@ declare function DataTableFacetedFilter<TData, TValue>({
1681
1692
  title,
1682
1693
  options,
1683
1694
  multiple
1684
- }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime2.JSX.Element;
1695
+ }: DataTableFacetedFilterProps<TData, TValue>): react_jsx_runtime8.JSX.Element;
1685
1696
  //#endregion
1686
1697
  //#region src/components/data-table/data-table-pagination.d.ts
1687
1698
  interface DataTablePaginationProps<TData> extends React.ComponentProps<'div'>, TablePaginationOptions {
@@ -1697,7 +1708,7 @@ declare function DataTablePagination<TData>({
1697
1708
  pageJumpLabel,
1698
1709
  className,
1699
1710
  ...props
1700
- }: DataTablePaginationProps<TData>): react_jsx_runtime2.JSX.Element;
1711
+ }: DataTablePaginationProps<TData>): react_jsx_runtime8.JSX.Element;
1701
1712
  //#endregion
1702
1713
  //#region src/components/data-table/data-table-toolbar.d.ts
1703
1714
  interface DataTableToolbarProps<TData> extends React$1.ComponentProps<'div'> {
@@ -1708,7 +1719,7 @@ declare function DataTableToolbar<TData>({
1708
1719
  children,
1709
1720
  className,
1710
1721
  ...props
1711
- }: DataTableToolbarProps<TData>): react_jsx_runtime2.JSX.Element;
1722
+ }: DataTableToolbarProps<TData>): react_jsx_runtime8.JSX.Element;
1712
1723
  //#endregion
1713
1724
  //#region src/components/data-table/data-table-view-options.d.ts
1714
1725
  interface DataTableViewOptionsProps<TData> extends React$1.ComponentProps<typeof PopoverContent> {
@@ -1719,7 +1730,7 @@ declare function DataTableViewOptions<TData>({
1719
1730
  table,
1720
1731
  disabled,
1721
1732
  ...props
1722
- }: DataTableViewOptionsProps<TData>): react_jsx_runtime2.JSX.Element;
1733
+ }: DataTableViewOptionsProps<TData>): react_jsx_runtime8.JSX.Element;
1723
1734
  //#endregion
1724
1735
  //#region src/lib/crud-actions.d.ts
1725
1736
  type CrudActionZone = 'toolbar' | 'row' | 'batch';
@@ -2113,4 +2124,4 @@ declare function exportAllToCSV<T extends Record<string, unknown>>(data: T[], op
2113
2124
  */
2114
2125
  declare function downloadCSVTemplate(headers: string[], filename?: string): void;
2115
2126
  //#endregion
2116
- export { type ActionConfig, type ActionItem, type ActionPosition, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudQueryCapabilities, type AutoCrudRowActionContext, type AutoCrudRowOpenOptions, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, type AutoQueryParams, AutoTable, AutoTableActionBar, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableClassNames, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type DateFormatPreset, type DateFormatter, type DateLocaleOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldOption, type FieldTableDisplay, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, type RowActionConfig, type RowActionDialogProps, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type TablePaginationOptions, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, actionPositionSchema, cn, coerceRowValues, compareOrder, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, matchesPosition, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, positionActions, resolveLocale, setDateFormatter, setSearchParams, setToolbarResolver, tablePagination, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
2127
+ export { type ActionConfig, type ActionItem, type ActionPosition, type ActionsColumnConfig, type AutoCrudActionConfig, type AutoCrudActionsConfig, type AutoCrudDataSourceConfig, type AutoCrudDataSourceContext, type AutoCrudDataSourceEntry, type AutoCrudDataSourceLoader, type AutoCrudDataSourceRegistration, type AutoCrudFormComponentConfig, type AutoCrudLocale, type AutoCrudOption, type AutoCrudQueryCapabilities, type AutoCrudRowActionContext, type AutoCrudRowOpenOptions, AutoCrudTable, type AutoCrudTableProps, type AutoCrudToolbarContext, type AutoCrudToolbarResolver, AutoForm, type AutoFormProps, type AutoQueryParams, AutoTable, AutoTableActionBar, type AutoTableProps, AutoTableSimpleFilters, type BatchActionConfig, type BatchActionContext, type BatchActionItem, type BatchBuiltinActionItem, type BatchBuiltinActionType, type BatchCustomActionItem, type BatchUpdateField, type ColumnOverrides, type CreateFormSchemaOptions, type CreateTableSchemaOptions, type CrudActionBase, type CrudActionEntry, type CrudActionRegistration, type CrudActionZone, CrudFormModal, type CrudHooks, type CrudOperationPermissions, type CrudPermissions, type DataSource, DataTable, DataTableAdvancedToolbar, DataTableClassNames, DataTableColumnHeader, DataTableFacetedFilter, DataTablePagination, type DataTableProps, DataTableRowAction, DataTableToolbar, DataTableViewOptions, type DateFormatPreset, type DateFormatter, type DateLocaleOptions, type EnumOption, ExportDialog, type ExportDialogProps, type ExportMode, ExtendedColumnFilter, ExtendedColumnSort, type Field, type FieldOption, type FieldTableDisplay, type FieldType, type Fields, type FilterConfig, FilterOperator, type FilterVariant, type FormSchemaOverrides, ImportDialog, type ImportDialogProps, type ImportResult, type JSONSchema, type JSONSchemaProperty, JoinOperator, type ListParams, type ListResult, type LocaleProp, MultiCombobox, type MultiComboboxOption, type MultiComboboxProps, type MultiComboboxTriggerRenderProps, Option, type ParsedImportData, type ParsedZodField, type Parser, QueryKeys, type RowActionConfig, type RowActionDialogProps, type RowActionItem, type RowBuiltinActionItem, type RowBuiltinActionType, type RowCustomActionItem, SchemaAdapter, Select, type SelectMode, type SelectOption, type SelectProps, type SelectSearchableDynamicProps, type SelectSearchableMultipleProps, type SelectSearchableProps, type SelectSearchableSingleProps, type SelectSimpleProps, type SelectTriggerRenderProps, type SimpleFieldConfig, type SimpleFieldsConfig, type TablePaginationOptions, type ToastAdapter, type ToolbarActionConfig, type ToolbarActionItem, type ToolbarBuiltinActionItem, type ToolbarBuiltinActionType, type ToolbarCustomActionItem, type UnifiedField, type UnifiedSchema, type UrlStateOptions, type UseAutoCrudResourceOptions, type UseAutoCrudResourceParams, type UseAutoCrudResourceReturn, actionPositionSchema, cn, coerceRowValues, compareOrder, components, createActionsColumn, createEditFormSchema, createFormSchema, createMemoryDataSource, createSelectColumn, createTRPCDataSource, createTableSchema, crudActions, dataSources, dataToCSV, deDE, downloadCSVTemplate, enUS, esES, exportAllToCSV, exportTableToCSV, formComponents, formatDate, frFR, generateCSVTemplate, getUrlParams, humanize, jaJP, koKR, matchesPosition, noopToastAdapter, normalizeDataSourceConfig, normalizeOptions, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, parseCSV, parseImportFile, parseJSON, parseZodField, positionActions, resolveLocale, setDateFormatter, setSearchParams, setToolbarResolver, tablePagination, useAutoCrudResource, useDataTable, useQueryState, useQueryStates, useReadableFilters, useUrlState, useUrlStates, zhCN };
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { i as positionActions, n as compareOrder, r as matchesPosition, t as actionPositionSchema } from "./position--p6kJnYA.js";
2
2
  import * as React from "react";
3
- import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
4
- import { ArrowDownUp, BadgeCheck, CalendarIcon, Check, CheckCircle2, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, ChevronsLeft, ChevronsRight, ChevronsUpDown, CommandIcon, Download, Ellipsis, EyeOff, FileDown, FileSpreadsheetIcon, GripVertical, ListFilter, ListFilterIcon, Loader2, PlusCircle, RefreshCw, Settings2, Text, Trash2, Upload, X, XCircle } from "lucide-react";
5
- import { flexRender, getCoreRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
3
+ import { Fragment, forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
4
+ import { ArrowDownUp, BadgeCheck, CalendarIcon, Check, CheckCircle2, ChevronDown, ChevronLeft, ChevronRight, ChevronRightIcon, ChevronUp, ChevronsLeft, ChevronsRight, ChevronsUpDown, CommandIcon, Download, Ellipsis, EyeOff, FileDown, FileSpreadsheetIcon, GripVertical, ListFilter, ListFilterIcon, Loader2, PlusCircle, RefreshCw, Settings2, Text, Trash2, Upload, X, XCircle } from "lucide-react";
5
+ import { flexRender, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
6
6
  import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, Badge, Button, Calendar, Checkbox, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, Input, Label, Popover, PopoverContent, PopoverTrigger, Select as Select$1, SelectContent, SelectItem, SelectTrigger, SelectValue, Separator, Slider, Switch, Table as Table$1, TableBody, TableCell, TableHead, TableHeader, TableRow, cn as cn$1 } from "@wordrhyme/shadcn";
7
7
  import { clsx } from "clsx";
8
8
  import { twMerge } from "tailwind-merge";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
10
  import { customAlphabet } from "nanoid";
11
11
  import { ActionBar, ActionBarClose, ActionBarGroup, ActionBarItem, ActionBarSelection, ActionBarSeparator, Faceted, FacetedBadgeList, FacetedContent, FacetedEmpty, FacetedGroup, FacetedInput, FacetedItem, FacetedList, FacetedTrigger, MultiCombobox, Select, Select as Select$2, Sortable, SortableContent, SortableItem, SortableItemHandle, SortableOverlay } from "@wordrhyme/shadcn-ui";
12
12
  import { AlertDialog as AlertDialog$1, AlertDialogAction as AlertDialogAction$1, AlertDialogCancel as AlertDialogCancel$1, AlertDialogContent as AlertDialogContent$1, AlertDialogDescription as AlertDialogDescription$1, AlertDialogFooter as AlertDialogFooter$1, AlertDialogHeader as AlertDialogHeader$1, AlertDialogTitle as AlertDialogTitle$1, Button as Button$1, Calendar as Calendar$1, Dialog as Dialog$1, DialogContent as DialogContent$1, DialogDescription as DialogDescription$1, DialogHeader as DialogHeader$1, DialogTitle as DialogTitle$1, DropdownMenu as DropdownMenu$1, DropdownMenuContent as DropdownMenuContent$1, DropdownMenuItem as DropdownMenuItem$1, DropdownMenuSeparator, DropdownMenuTrigger as DropdownMenuTrigger$1, Popover as Popover$1, PopoverContent as PopoverContent$1, PopoverTrigger as PopoverTrigger$1, Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@wordrhyme/ui";
@@ -551,7 +551,7 @@ function formatDate(date, opts = {}, preset) {
551
551
 
552
552
  //#endregion
553
553
  //#region src/components/data-table/data-table.tsx
554
- function DataTable({ table, actionBar, pagination, children, className, classNames,...props }) {
554
+ function DataTable({ table, actionBar, pagination, expandedRow, children, className, classNames,...props }) {
555
555
  useDateFormatterVersion();
556
556
  const columns = [
557
557
  ...table.getLeftVisibleLeafColumns(),
@@ -566,6 +566,7 @@ function DataTable({ table, actionBar, pagination, children, className, classNam
566
566
  children,
567
567
  /* @__PURE__ */ jsx("div", {
568
568
  className: "overflow-hidden rounded-md border",
569
+ style: expandedRow ? { containerType: "inline-size" } : void 0,
569
570
  children: /* @__PURE__ */ jsxs(Table$1, {
570
571
  className: classNames?.table,
571
572
  style: hasWidthCap ? {
@@ -591,7 +592,7 @@ function DataTable({ table, actionBar, pagination, children, className, classNam
591
592
  }),
592
593
  /* @__PURE__ */ jsx(TableBody, {
593
594
  className: classNames?.tbody,
594
- children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx(TableRow, {
595
+ children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(TableRow, {
595
596
  className: classNames?.tr,
596
597
  "data-state": row.getIsSelected() && "selected",
597
598
  children: row.getVisibleCells().map((cell) => {
@@ -602,7 +603,14 @@ function DataTable({ table, actionBar, pagination, children, className, classNam
602
603
  children: flexRender(cell.column.columnDef.cell, cell.getContext())
603
604
  }, cell.id);
604
605
  })
605
- }, row.id)) : /* @__PURE__ */ jsx(TableRow, {
606
+ }), expandedRow && row.getCanExpand() && row.getIsExpanded() && /* @__PURE__ */ jsx(TableRow, {
607
+ className: classNames?.tr,
608
+ children: /* @__PURE__ */ jsx(TableCell, {
609
+ colSpan: row.getVisibleCells().length,
610
+ className: classNames?.td,
611
+ children: expandedRow(row.original, row)
612
+ })
613
+ })] }, row.id)) : /* @__PURE__ */ jsx(TableRow, {
606
614
  className: classNames?.tr,
607
615
  children: /* @__PURE__ */ jsx(TableCell, {
608
616
  colSpan: table.getAllColumns().length,
@@ -1959,7 +1967,7 @@ function DataTableFilterMenu({ table, debounceMs = DEBOUNCE_MS$1, throttleMs = T
1959
1967
  onKeyDown: onInputKeyDown
1960
1968
  }), /* @__PURE__ */ jsx(CommandList, {
1961
1969
  onScroll: selectedColumnMeta?.autoCrudFilterOnPopupScroll,
1962
- children: selectedColumn ? /* @__PURE__ */ jsxs(Fragment, { children: [
1970
+ children: selectedColumn ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
1963
1971
  selectedColumn.columnDef.meta?.options && /* @__PURE__ */ jsx(CommandEmpty, { children: "No options found." }),
1964
1972
  /* @__PURE__ */ jsx(FilterValueSelector, {
1965
1973
  column: selectedColumn,
@@ -1978,7 +1986,7 @@ function DataTableFilterMenu({ table, debounceMs = DEBOUNCE_MS$1, throttleMs = T
1978
1986
  className: "sr-only",
1979
1987
  children: "Load more"
1980
1988
  })
1981
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CommandEmpty, { children: "No fields found." }), /* @__PURE__ */ jsx(CommandGroup, { children: columns.map((column) => /* @__PURE__ */ jsxs(CommandItem, {
1989
+ ] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CommandEmpty, { children: "No fields found." }), /* @__PURE__ */ jsx(CommandGroup, { children: columns.map((column) => /* @__PURE__ */ jsxs(CommandItem, {
1982
1990
  value: column.id,
1983
1991
  onSelect: () => {
1984
1992
  setSelectedColumn(column);
@@ -2162,7 +2170,7 @@ function FilterValueSelector({ column, value, onSelect }) {
2162
2170
  value,
2163
2171
  onSelect: () => onSelect(value),
2164
2172
  disabled: isEmpty,
2165
- children: isEmpty ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Text, {}), /* @__PURE__ */ jsx("span", { children: "Type to add filter..." })] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(BadgeCheck, {}), /* @__PURE__ */ jsxs("span", {
2173
+ children: isEmpty ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Text, {}), /* @__PURE__ */ jsx("span", { children: "Type to add filter..." })] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(BadgeCheck, {}), /* @__PURE__ */ jsxs("span", {
2166
2174
  className: "truncate",
2167
2175
  children: [
2168
2176
  "Filter by \"",
@@ -2248,7 +2256,7 @@ function onFilterInputRender({ today, filter, column, inputId, onFilterUpdate, s
2248
2256
  variant: "ghost",
2249
2257
  size: "sm",
2250
2258
  className: "h-full min-w-16 rounded-none border px-1.5 font-normal dark:bg-input/30",
2251
- children: selectedOptions.length === 0 ? filter.variant === "multiSelect" ? "Select options..." : "Select option..." : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
2259
+ children: selectedOptions.length === 0 ? filter.variant === "multiSelect" ? "Select options..." : "Select option..." : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
2252
2260
  className: "flex items-center -space-x-2 rtl:space-x-reverse",
2253
2261
  children: selectedOptions.map((selectedOption) => selectedOption.icon ? /* @__PURE__ */ jsx("div", {
2254
2262
  className: "rounded-full border bg-background p-0.5",
@@ -2961,7 +2969,7 @@ function SimpleFacetedFilter({ title, options, multiple, value, hasMore, loading
2961
2969
  children: /* @__PURE__ */ jsx(XCircle, {})
2962
2970
  }) : /* @__PURE__ */ jsx(PlusCircle, {}),
2963
2971
  title,
2964
- selectedValues.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
2972
+ selectedValues.length > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [
2965
2973
  /* @__PURE__ */ jsx(Separator, {
2966
2974
  orientation: "vertical",
2967
2975
  className: "mx-0.5 h-4"
@@ -3035,7 +3043,7 @@ function SimpleSliderFilter({ title, range, unit, value, onChange }) {
3035
3043
  children: /* @__PURE__ */ jsx(XCircle, {})
3036
3044
  }) : /* @__PURE__ */ jsx(PlusCircle, {}),
3037
3045
  /* @__PURE__ */ jsx("span", { children: title }),
3038
- value && /* @__PURE__ */ jsxs(Fragment, { children: [
3046
+ value && /* @__PURE__ */ jsxs(Fragment$1, { children: [
3039
3047
  /* @__PURE__ */ jsx(Separator, {
3040
3048
  orientation: "vertical",
3041
3049
  className: "mx-0.5 h-4"
@@ -3175,7 +3183,7 @@ function SimpleDateFilter({ title, maxDate, multiple, value, onChange }) {
3175
3183
  children: /* @__PURE__ */ jsx(XCircle, {})
3176
3184
  }) : /* @__PURE__ */ jsx(CalendarIcon, {}),
3177
3185
  /* @__PURE__ */ jsx("span", { children: title }),
3178
- label && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Separator, {
3186
+ label && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Separator, {
3179
3187
  orientation: "vertical",
3180
3188
  className: "mx-0.5 h-4"
3181
3189
  }), /* @__PURE__ */ jsx("span", { children: label })] })
@@ -3277,7 +3285,7 @@ function DataTableColumnHeader({ column, label, className,...props }) {
3277
3285
  }), /* @__PURE__ */ jsxs(DropdownMenuContent, {
3278
3286
  align: "start",
3279
3287
  className: "w-28",
3280
- children: [column.getCanSort() && /* @__PURE__ */ jsxs(Fragment, { children: [
3288
+ children: [column.getCanSort() && /* @__PURE__ */ jsxs(Fragment$1, { children: [
3281
3289
  /* @__PURE__ */ jsxs(DropdownMenuCheckboxItem, {
3282
3290
  className: "relative pr-8 pl-2 [&>span:first-child]:right-2 [&>span:first-child]:left-auto [&_svg]:text-muted-foreground",
3283
3291
  checked: column.getIsSorted() === "asc",
@@ -3891,9 +3899,12 @@ function coerceRowValues(rows, schema) {
3891
3899
 
3892
3900
  //#endregion
3893
3901
  //#region src/lib/export.ts
3902
+ function getExportColumnIds(table) {
3903
+ return table.getAllLeafColumns().filter((column) => column.accessorFn).map((column) => column.id);
3904
+ }
3894
3905
  function exportTableToCSV(table, opts = {}) {
3895
3906
  const { filename = "table", excludeColumns = [], onlySelected = false } = opts;
3896
- const headers = table.getAllLeafColumns().map((column) => column.id).filter((id) => !excludeColumns.includes(id));
3907
+ const headers = getExportColumnIds(table).filter((id) => !excludeColumns.includes(id));
3897
3908
  downloadCSV([headers.join(","), ...(onlySelected ? table.getFilteredSelectedRowModel().rows : table.getRowModel().rows).map((row) => headers.map((header) => {
3898
3909
  const cellValue = row.getValue(header);
3899
3910
  return typeof cellValue === "string" ? `"${cellValue.replace(/"/g, "\"\"")}"` : cellValue;
@@ -4081,7 +4092,7 @@ function AutoTableActionBar({ table, onDeleteSelected, onUpdateSelected, batchUp
4081
4092
  { type: "delete" }
4082
4093
  ]) : actions;
4083
4094
  let resolvedActions = configuredActions?.filter((action$1) => !action$1.hidden);
4084
- if (configuredActions === void 0) return /* @__PURE__ */ jsxs(Fragment, { children: [
4095
+ if (configuredActions === void 0) return /* @__PURE__ */ jsxs(Fragment$1, { children: [
4085
4096
  renderBuiltinAction({ type: "batchUpdate" }),
4086
4097
  extraActions,
4087
4098
  showDefaultExport && renderBuiltinAction({ type: "export" }),
@@ -4104,7 +4115,7 @@ function AutoTableActionBar({ table, onDeleteSelected, onUpdateSelected, batchUp
4104
4115
  if (!hasBuiltin) {
4105
4116
  const startNodes = resolvedActions.filter(isBatchCustomAction).filter((action$1) => action$1.position === "start").map((action$1, index$1) => renderCustomAction(action$1, index$1));
4106
4117
  const endNodes = resolvedActions.filter(isBatchCustomAction).filter((action$1) => action$1.position !== "start").map((action$1, index$1) => renderCustomAction(action$1, index$1));
4107
- return /* @__PURE__ */ jsxs(Fragment, { children: [
4118
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
4108
4119
  startNodes,
4109
4120
  renderBuiltinAction({ type: "batchUpdate" }),
4110
4121
  extraActions,
@@ -4404,7 +4415,9 @@ const filterModeConfig = {
4404
4415
  tooltip: "Linear-style command filters"
4405
4416
  }
4406
4417
  };
4407
- function AutoTable({ schema, data, pageCount = 1, pagination, total, overrides, classNames, enableRowSelection = true, exclude, filterOnly, actions, pinnedColumns, filterMode, search = false, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows }) {
4418
+ function AutoTable({ schema, data, getRowId, expandedRow, defaultExpanded = false, pageCount = 1, pagination, total, overrides, classNames, enableRowSelection = true, exclude, filterOnly, actions, pinnedColumns, filterMode, search = false, onDeleteSelected, onUpdateSelected, batchUpdateFields, actionBarExtra, actionBarActions, deleteConfirmation, initialSorting, enableExport = true, showDefaultExport = true, onSelectedCountChange, onSelectedRowsChange, getSelectedRows }) {
4419
+ if (expandedRow && !getRowId) throw new Error("AutoTable requires getRowId when expandedRow is provided.");
4420
+ const enableExpansion = !!expandedRow;
4408
4421
  const modes = filterMode ? Array.isArray(filterMode) ? filterMode : [filterMode] : DEFAULT_MODES;
4409
4422
  const [currentMode, setCurrentMode] = useQueryState("filterMode", parseAsStringEnum(modes).withDefault(modes[0] ?? "simple"));
4410
4423
  const showToggle = modes.length > 1;
@@ -4418,7 +4431,7 @@ function AutoTable({ schema, data, pageCount = 1, pagination, total, overrides,
4418
4431
  });
4419
4432
  const searchConfig = search && typeof search === "object" ? search : {};
4420
4433
  const enableAdvancedFilter = true;
4421
- const columns = useMemo(() => {
4434
+ const { columns, expandColumnId } = useMemo(() => {
4422
4435
  const columnOverrides = Object.assign({}, overrides);
4423
4436
  for (const key of filterOnly ?? []) {
4424
4437
  const field = key;
@@ -4439,31 +4452,67 @@ function AutoTable({ schema, data, pageCount = 1, pagination, total, overrides,
4439
4452
  } : column;
4440
4453
  });
4441
4454
  const result = enableRowSelection ? [createSelectColumn(), ...dataColumns] : dataColumns;
4455
+ let expandColumnId$1 = "expand";
4456
+ if (enableExpansion) {
4457
+ while (expandColumnId$1 in schema.shape || result.some((column) => column.id === expandColumnId$1)) expandColumnId$1 = `_${expandColumnId$1}`;
4458
+ result.unshift({
4459
+ id: expandColumnId$1,
4460
+ header: () => /* @__PURE__ */ jsx("span", {
4461
+ className: "sr-only",
4462
+ children: "Row details"
4463
+ }),
4464
+ cell: ({ row }) => /* @__PURE__ */ jsx(Button, {
4465
+ type: "button",
4466
+ variant: "ghost",
4467
+ size: "icon-sm",
4468
+ "aria-label": row.getIsExpanded() ? "Collapse row" : "Expand row",
4469
+ "aria-expanded": row.getIsExpanded(),
4470
+ onClick: row.getToggleExpandedHandler(),
4471
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: row.getIsExpanded() ? "size-4 rotate-90" : "size-4" })
4472
+ }),
4473
+ enableHiding: false,
4474
+ enableSorting: false,
4475
+ size: 40
4476
+ });
4477
+ }
4442
4478
  if (actions) result.push(createActionsColumn(actions));
4443
- return result;
4479
+ return {
4480
+ columns: result,
4481
+ expandColumnId: expandColumnId$1
4482
+ };
4444
4483
  }, [
4445
4484
  schema,
4446
4485
  overrides,
4447
4486
  enableRowSelection,
4487
+ enableExpansion,
4448
4488
  exclude,
4449
4489
  actions,
4450
4490
  filterOnly
4451
4491
  ]);
4452
4492
  const stableInitialState = useMemo(() => ({
4453
4493
  sorting: initialSorting,
4494
+ expanded: enableExpansion && defaultExpanded ? true : {},
4454
4495
  columnPinning: pinnedColumns ?? {
4455
- left: enableRowSelection ? ["select"] : [],
4496
+ left: [...enableExpansion ? [expandColumnId] : [], ...enableRowSelection ? ["select"] : []],
4456
4497
  right: actions ? ["actions"] : []
4457
4498
  }
4458
4499
  }), [
4459
4500
  initialSorting,
4460
4501
  pinnedColumns,
4461
4502
  enableRowSelection,
4503
+ enableExpansion,
4504
+ defaultExpanded,
4505
+ expandColumnId,
4462
4506
  actions
4463
4507
  ]);
4508
+ const expandedRowModel = useMemo(() => getExpandedRowModel(), []);
4464
4509
  const { table, shallow, debounceMs, throttleMs } = useDataTable({
4465
4510
  data,
4466
4511
  columns,
4512
+ getRowId,
4513
+ getRowCanExpand: () => enableExpansion,
4514
+ getExpandedRowModel: enableExpansion ? expandedRowModel : void 0,
4515
+ autoResetExpanded: defaultExpanded ? false : void 0,
4467
4516
  pageCount,
4468
4517
  ...total !== void 0 ? { rowCount: total } : {},
4469
4518
  enableAdvancedFilter,
@@ -4595,7 +4644,8 @@ function AutoTable({ schema, data, pageCount = 1, pagination, total, overrides,
4595
4644
  /* @__PURE__ */ jsx(DataTable, {
4596
4645
  pagination,
4597
4646
  table,
4598
- classNames
4647
+ classNames,
4648
+ expandedRow
4599
4649
  }),
4600
4650
  enableRowSelection && /* @__PURE__ */ jsx(AutoTableActionBar, {
4601
4651
  table,
@@ -6041,7 +6091,7 @@ function ImportDialog({ open, onOpenChange, onImport, columns = [], title, local
6041
6091
  ] })] }), /* @__PURE__ */ jsxs("div", {
6042
6092
  className: "space-y-4",
6043
6093
  children: [
6044
- step === "upload" && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
6094
+ step === "upload" && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
6045
6095
  className: `border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${isDragging ? "border-primary bg-primary/5" : "border-muted-foreground/25 hover:border-muted-foreground/50"}`,
6046
6096
  onDragOver: (e) => {
6047
6097
  e.preventDefault();
@@ -6089,7 +6139,7 @@ function ImportDialog({ open, onOpenChange, onImport, columns = [], title, local
6089
6139
  onClick: handleDownloadTemplate,
6090
6140
  children: locale.downloadTemplate
6091
6141
  })] }),
6092
- step === "preview" && parsedData && /* @__PURE__ */ jsxs(Fragment, { children: [
6142
+ step === "preview" && parsedData && /* @__PURE__ */ jsxs(Fragment$1, { children: [
6093
6143
  /* @__PURE__ */ jsx("div", {
6094
6144
  className: "rounded-md border",
6095
6145
  children: /* @__PURE__ */ jsx("div", {
@@ -6144,7 +6194,7 @@ function ImportDialog({ open, onOpenChange, onImport, columns = [], title, local
6144
6194
  children: locale.importingRows(parsedData?.rows.length ?? 0)
6145
6195
  })]
6146
6196
  }),
6147
- step === "result" && result && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
6197
+ step === "result" && result && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
6148
6198
  className: "space-y-3",
6149
6199
  children: [/* @__PURE__ */ jsxs("div", {
6150
6200
  className: "flex gap-4",
@@ -7538,7 +7588,7 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7538
7588
  return {
7539
7589
  ...action$1,
7540
7590
  onClick: (_rows, { table }) => {
7541
- const headers = table.getAllLeafColumns().map((column) => column.id).filter((key) => key !== "select" && key !== "actions" && !denyFields?.includes(key));
7591
+ const headers = getExportColumnIds(table).filter((key) => key !== "select" && key !== "actions" && !denyFields?.includes(key));
7542
7592
  exportAllToCSV(table.getFilteredSelectedRowModel().rows.map((row) => formatExportRow(row.original, resolvedFields, Object.fromEntries(headers.map((key) => [key, row.getValue(key)])))), {
7543
7593
  filename: "table",
7544
7594
  headers
@@ -7798,6 +7848,9 @@ function AutoCrudTable({ id, title, description, schema, resource, fields, table
7798
7848
  ...pagination
7799
7849
  } : void 0,
7800
7850
  ...resource.tableData.total !== void 0 ? { total: resource.tableData.total } : {},
7851
+ getRowId: tableConfig?.getRowId,
7852
+ expandedRow: tableConfig?.expandedRow,
7853
+ defaultExpanded: tableConfig?.defaultExpanded,
7801
7854
  overrides: tableOverrides,
7802
7855
  classNames: tableConfig?.classNames,
7803
7856
  exclude: hiddenColumns.filter((key) => !filterOnly.includes(key)),
@@ -8009,7 +8062,7 @@ function DataTableFacetedFilter({ column, title, options, multiple }) {
8009
8062
  children: /* @__PURE__ */ jsx(XCircle, {})
8010
8063
  }) : /* @__PURE__ */ jsx(PlusCircle, {}),
8011
8064
  title,
8012
- selectedValues$1.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
8065
+ selectedValues$1.length > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [
8013
8066
  /* @__PURE__ */ jsx(Separator, {
8014
8067
  orientation: "vertical",
8015
8068
  className: "mx-0.5 data-[orientation=vertical]:h-4"
@@ -8168,7 +8221,7 @@ function DataTableDateFilter({ column, title, multiple }) {
8168
8221
  const dateText$1 = hasSelectedDates ? formatDateRange(selectedDates) : "Select date range";
8169
8222
  return /* @__PURE__ */ jsxs("span", {
8170
8223
  className: "flex items-center gap-2",
8171
- children: [/* @__PURE__ */ jsx("span", { children: title }), hasSelectedDates && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Separator, {
8224
+ children: [/* @__PURE__ */ jsx("span", { children: title }), hasSelectedDates && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Separator, {
8172
8225
  orientation: "vertical",
8173
8226
  className: "mx-0.5 data-[orientation=vertical]:h-4"
8174
8227
  }), /* @__PURE__ */ jsx("span", { children: dateText$1 })] })]
@@ -8179,7 +8232,7 @@ function DataTableDateFilter({ column, title, multiple }) {
8179
8232
  const dateText = hasSelectedDate ? formatDate$1(selectedDates[0]) : "Select date";
8180
8233
  return /* @__PURE__ */ jsxs("span", {
8181
8234
  className: "flex items-center gap-2",
8182
- children: [/* @__PURE__ */ jsx("span", { children: title }), hasSelectedDate && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Separator, {
8235
+ children: [/* @__PURE__ */ jsx("span", { children: title }), hasSelectedDate && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Separator, {
8183
8236
  orientation: "vertical",
8184
8237
  className: "mx-0.5 data-[orientation=vertical]:h-4"
8185
8238
  }), /* @__PURE__ */ jsx("span", { children: dateText })] })]
@@ -8335,7 +8388,7 @@ function DataTableSliderFilter({ column, title }) {
8335
8388
  children: /* @__PURE__ */ jsx(XCircle, {})
8336
8389
  }) : /* @__PURE__ */ jsx(PlusCircle, {}),
8337
8390
  /* @__PURE__ */ jsx("span", { children: title }),
8338
- columnFilterValue ? /* @__PURE__ */ jsxs(Fragment, { children: [
8391
+ columnFilterValue ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
8339
8392
  /* @__PURE__ */ jsx(Separator, {
8340
8393
  orientation: "vertical",
8341
8394
  className: "mx-0.5 data-[orientation=vertical]:h-4"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wordrhyme/auto-crud",
3
3
  "type": "module",
4
- "version": "1.9.0",
4
+ "version": "1.11.0",
5
5
  "description": "Schema-first CRUD components with auto-generated tables and forms",
6
6
  "author": "wordrhyme",
7
7
  "license": "MIT",
@@ -70,9 +70,9 @@
70
70
  "nanoid": "^5.1.6",
71
71
  "tailwind-merge": "^3.5.0",
72
72
  "vaul": "^1.1.2",
73
+ "@wordrhyme/formily-shadcn": "2.1.1",
73
74
  "@wordrhyme/shadcn": "2.0.1",
74
- "@wordrhyme/shadcn-ui": "2.1.1",
75
- "@wordrhyme/formily-shadcn": "2.1.1"
75
+ "@wordrhyme/shadcn-ui": "2.1.1"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@storybook/react": "^8.6.18",
@@ -93,11 +93,11 @@
93
93
  "tsdown": "^0.15.12",
94
94
  "typescript": "^5.9.3",
95
95
  "vitest": "^3.2.4",
96
- "@internal/prettier-config": "0.0.1",
97
- "@internal/tsdown-config": "0.1.0",
96
+ "@internal/eslint-config": "0.3.0",
98
97
  "@internal/tsconfig": "0.1.0",
99
98
  "@internal/vitest-config": "0.1.0",
100
- "@internal/eslint-config": "0.3.0"
99
+ "@internal/tsdown-config": "0.1.0",
100
+ "@internal/prettier-config": "0.0.1"
101
101
  },
102
102
  "prettier": "@internal/prettier-config",
103
103
  "scripts": {