@economic/taco 2.36.2 → 2.37.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. package/dist/components/Table3/Table3.d.ts +6 -6
  2. package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +1 -1
  3. package/dist/components/Table3/components/Row/Editing/CreateRowButton.d.ts +1 -1
  4. package/dist/components/Table3/features/useTableEditing.d.ts +3 -3
  5. package/dist/components/Table3/types.d.ts +5 -3
  6. package/dist/esm/packages/taco/src/components/Table3/Table3.js +2 -2
  7. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  8. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +1 -1
  9. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
  10. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js +4 -4
  11. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js.map +1 -1
  12. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +108 -52
  13. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  14. package/dist/esm/packages/taco/src/components/Table3/useTable3.js +3 -3
  15. package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
  16. package/dist/esm/packages/taco/src/components/Table3/util/editing.js +15 -2
  17. package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
  18. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +19 -4
  19. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  20. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js +5 -2
  21. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js.map +1 -1
  22. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  23. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +3 -2
  24. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  25. package/dist/esm/packages/taco/src/types.js.map +1 -1
  26. package/dist/primitives/Table/Core/components/Body/EmptyStateBody.d.ts +2 -1
  27. package/dist/primitives/Table/types.d.ts +6 -3
  28. package/dist/taco.cjs.development.js +160 -72
  29. package/dist/taco.cjs.development.js.map +1 -1
  30. package/dist/taco.cjs.production.min.js +1 -1
  31. package/dist/taco.cjs.production.min.js.map +1 -1
  32. package/dist/types.d.ts +1 -0
  33. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/setup.ts"],"sourcesContent":["import React from 'react';\nimport {\n createColumnHelper,\n getExpandedRowModel,\n getFilteredRowModel,\n getGroupedRowModel,\n getSortedRowModel,\n TableOptions as ReactTableOptions,\n Row as ReactTableRow,\n Column as ReactTableColumn,\n ColumnDef as ReactTableColumnDef,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSizingState as ReactTableColumnSizingState,\n ColumnSort as ReactTableColumnSort,\n TableState as ReactTableState,\n VisibilityState as ReactTableVisibilityState,\n} from '@tanstack/react-table';\nimport get from 'lodash/get';\n\nimport { useTableManagerInternalColumns, useTableManagerInternalColumn } from '../types';\nimport { TableColumnProps, TableFeatureProps, TableGroupProps, TableProps, TableSettings } from '../../types';\nimport { getSortingFn } from './sorting';\nimport { ensureOrdering, freezeUptoExternalColumn, getCellMinWidth, unfreezeAllExternalColumns } from './columns';\nimport { columnFilterFn, globalFilterFn } from './filtering';\nimport { ignoreInternalColumns } from './settings';\n\n// mapping children to react-table columns\nfunction processChildren<TType>(\n child: React.ReactChild | React.ReactFragment | React.ReactPortal,\n columns: ReactTableColumnDef<TType>[],\n defaultSizing: ReactTableColumnSizingState,\n defaultSorting: ReactTableColumnSort[],\n defaultVisibility: ReactTableVisibilityState,\n settings: TableSettings,\n defaultRowGroupColumnId?: keyof TType\n): ReactTableColumnDef<TType>[] {\n const columnHelper = createColumnHelper<TType>();\n\n if (React.isValidElement<TableGroupProps>(child) && child.props.children) {\n const { children, id, header } = child.props;\n\n columns.push(\n columnHelper.group({\n id,\n header,\n columns: React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId\n ),\n []\n ),\n // we don't want to let column groups be grouped/aggregrated\n enableGrouping: false,\n })\n );\n } else if (React.isValidElement<TableColumnProps<TType>>(child) && (child.props.accessor || child.props.id)) {\n const {\n id,\n accessor: accessorKey = id,\n // renderers\n renderer,\n aggregate,\n footer,\n header,\n // options\n aggregationFn,\n defaultHidden,\n defaultWidth,\n enableFiltering: enableColumnFilter = true,\n enableGrouping = false,\n enableHiding = true,\n enableOrdering = true,\n enablePrinting = true,\n enableResizing = true,\n enableSearch: enableGlobalFilter = true,\n enableSorting = true,\n enableTruncate = false,\n minWidth: minSize = getCellMinWidth(settings.fontSize),\n sort,\n sortFn,\n ...meta\n } = child.props;\n\n if (defaultHidden && enableHiding) {\n defaultVisibility[id] = false;\n }\n\n if (defaultWidth) {\n defaultSizing[id] = defaultWidth as any;\n }\n\n const isGrouped = defaultRowGroupColumnId === id;\n\n if (child.props.sort !== undefined || isGrouped) {\n defaultSorting.push({\n id,\n desc: sort === 'desc',\n });\n }\n\n const column: ReactTableColumnDef<TType, any> = {\n id,\n accessorKey,\n // To avoid errors caused by undefined row data values, we pass accessorFn as a preventive measure\n // accessorKey can be dot notated strings, so we use lodash.get to access deeply nested children\n accessorFn: row => get(row, accessorKey),\n header: header,\n // features\n enableColumnFilter,\n enableGlobalFilter,\n enableGrouping,\n enableHiding: isGrouped ? false : enableHiding,\n enableResizing,\n enableSorting,\n // config - sizing\n minSize,\n // meta\n meta: {\n ...(meta as any),\n defaultWidth,\n enableOrdering: isGrouped ? false : enableOrdering,\n enablePrinting,\n enableTruncate,\n header,\n renderer,\n },\n };\n\n // renderers\n if (typeof renderer === 'function') {\n column.cell = info => renderer(info.getValue(), info.row.original);\n }\n\n if (typeof footer === 'function') {\n column.footer = info =>\n footer(info.table.getRowModel().rows.flatMap(row => (row.original !== undefined ? row.original : [])));\n }\n\n // config - filtering\n if (enableColumnFilter) {\n column.filterFn = 'tacoFilter' as any;\n }\n\n // config - grouping/aggregation\n if (enableGrouping) {\n column.aggregationFn = aggregationFn;\n\n if (typeof aggregate === 'function') {\n column.aggregatedCell = info => aggregate(info.getValue(), info.row.original);\n }\n }\n\n // config - sorting\n if (enableSorting) {\n column.sortingFn = getSortingFn<TType>(child.props.dataType, sortFn);\n column.sortDescFirst = false;\n column.sortUndefined = 1;\n }\n\n columns.push(column);\n }\n\n return columns;\n}\n\nfunction createInternalColumn<TType = unknown>(\n id: string,\n column: useTableManagerInternalColumn<TType>,\n defaultSizing: ReactTableColumnSizingState\n) {\n if (column.size) {\n defaultSizing[id] = column.size;\n }\n\n return {\n id,\n accessorKey: id,\n header: column.header,\n cell: column.renderer,\n // features\n enableColumnFilter: false,\n enableGlobalFilter: false,\n enableGrouping: false,\n enableHiding: false,\n enableResizing: false,\n enableSorting: false,\n // config - sizing\n size: column.size,\n minSize: column.size,\n // meta\n meta: {\n ...(column.meta as any),\n enableOrdering: false,\n enablePrinting: false,\n enableTruncate: false,\n },\n } as ReactTableColumnDef<TType, any>;\n}\n\nexport function mapTableChildrenToColumns<TType = unknown>(\n props: TableProps<TType>,\n settings: TableSettings,\n options: TableFeatureProps<TType>,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\n const { children, defaultRowGroupColumnId } = props;\n const defaultSizing: ReactTableColumnSizingState = {};\n const defaultSorting: ReactTableColumnSort[] = [];\n const defaultVisibility: ReactTableVisibilityState = {};\n\n const columns = React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId\n ),\n\n []\n );\n\n if (internalColumns) {\n if (options.enableRowExpansion && props.rowExpansionRenderer && internalColumns.rowExpansion) {\n const column = createInternalColumn<TType>('__expansion', internalColumns.rowExpansion, defaultSizing);\n columns.unshift(column);\n }\n\n if ((options.enableRowSelection || options.enableRowSelectionSingle) && internalColumns.rowSelection) {\n const column = createInternalColumn<TType>('__select', internalColumns.rowSelection, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowDrag && props.onRowDrag && internalColumns.rowDrag) {\n const column = createInternalColumn<TType>('__drag', internalColumns.rowDrag, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowActions && props.rowActions?.length && internalColumns.rowActions) {\n const column = createInternalColumn<TType>('__actions', internalColumns.rowActions, defaultSizing);\n columns.push(column);\n }\n }\n\n return { columns, defaultSizing, defaultSorting, defaultVisibility };\n}\n\nexport function configureReactTableOptions<TType = unknown>(options: TableFeatureProps<TType>, props: TableProps<TType>) {\n const enableRowSelection = options.enableRowSelection || options.enableRowSelectionSingle;\n const tableOptions: Partial<ReactTableOptions<TType>> = {\n defaultColumn: {\n enableColumnFilter: options.enableFiltering || true,\n enableGrouping: false,\n enableHiding: options.enableColumnHiding || true,\n enableResizing: options.enableColumnResizing || true,\n enableGlobalFilter: options.enableSearch || true,\n enableSorting: options.enableSorting || true,\n minSize: 1,\n // the default is 150, which is a bit random\n size: 1,\n },\n enableColumnFilters: options.enableFiltering ?? false,\n enableColumnResizing: options.enableColumnResizing ?? false,\n enableExpanding: options.enableRowExpansion ?? false,\n enableGrouping: true, // users can't customise row grouping, so it can just be always enabled and left to the defaultRowGroupColumnId prop\n enableHiding: options.enableColumnHiding ?? false,\n enablePinning: options.enableColumnFreezing ?? false,\n enableRowSelection: enableRowSelection ?? false,\n enableMultiRowSelection: options.enableRowSelectionSingle === true ? false : enableRowSelection,\n enableSorting: options.enableSorting ?? false,\n // models for default features\n getExpandedRowModel: getExpandedRowModel<TType>(),\n getGroupedRowModel: getGroupedRowModel<TType>(),\n groupedColumnMode: false,\n };\n\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n if (tableOptions.enableColumnFilters) {\n // enter controlled filter mode (controlled could be local state, but usually the server)\n if (props.onChangeFilter) {\n // tableOptions.manualFiltering = true;\n // we don't set it because it breaks global filtering (used for search, which is fully client side)\n //\n // tableOptions.onColumnFiltersChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onFilter\n } else {\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.filterFns = {\n tacoFilter: (row: ReactTableRow<TType>, columnId: string, filter: any) =>\n columnFilterFn(row.getValue(columnId), filter),\n };\n }\n }\n\n if (options.enableSearch) {\n // always set these because enableGlobalFilter can be toggled on and off by the user\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.globalFilterFn = globalFilterFn;\n tableOptions.getColumnCanGlobalFilter = (column: ReactTableColumn<TType>) => column.columnDef.meta?.enableSearch ?? true;\n\n // enter controlled search mode (controlled could be local state, but usually the server)\n if (props.onChangeSearch) {\n // tableOptions.manualFiltering = true;\n // we don't set this because controlled search is not currently supported, search is always client side\n //\n // tableOptions.onGlobalFilterChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSearch.\n //\n // we also don't always filter when searching, we have the highlight functionality as the default\n // and filtering can be toggled by the user\n }\n }\n\n if (tableOptions.enableSorting) {\n // enter controlled sort mode (controlled could be local state, but usually the server)\n if (props.onChangeSort) {\n tableOptions.manualSorting = true;\n\n // tableOptions.onSortingChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSort\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n\nexport function useReactTableInitialState<TType = unknown>(\n props: TableProps<TType>,\n columns: ReactTableColumnDef<TType>[],\n persistedSettings: TableSettings,\n defaults: {\n defaultSizing: ReactTableColumnSizingState;\n defaultSorting: ReactTableColumnSort[];\n defaultVisibility: ReactTableVisibilityState;\n }\n): Partial<ReactTableState> {\n return React.useMemo(() => {\n const ignoreNotDefinedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n const columnPinning: ReactTableColumnPinningState =\n persistedSettings.columnPinning ?? props.defaultSettings?.columnPinning ?? {};\n\n const columnOrder = ensureOrdering<TType>(\n columns,\n persistedSettings.columnOrder ?? props.defaultSettings?.columnOrder,\n columnPinning.left\n );\n\n // ensure internal columns are pinned, and are pinned in the correct order\n if (columnPinning?.left?.length) {\n columnPinning.left = freezeUptoExternalColumn(\n columnOrder.indexOf(columnPinning.left[columnPinning.left.length - 1]),\n columnOrder\n );\n } else {\n if (props.defaultColumnFreezingIndex) {\n columnPinning.left = freezeUptoExternalColumn(props.defaultColumnFreezingIndex, columnOrder);\n } else {\n columnPinning.left = unfreezeAllExternalColumns(columnOrder);\n }\n }\n\n const state: Partial<ReactTableState> = {\n columnFilters: persistedSettings.columnFilters ?? props.defaultSettings?.columnFilters ?? [],\n columnOrder,\n columnPinning,\n columnSizing: ignoreInternalColumns(\n persistedSettings.columnSizing ?? props.defaultSettings?.columnSizing ?? defaults.defaultSizing ?? {}\n ),\n columnVisibility:\n persistedSettings.columnVisibility ?? props.defaultSettings?.columnVisibility ?? defaults.defaultVisibility ?? {},\n globalFilter: persistedSettings.searchQuery ?? props.defaultSettings?.searchQuery,\n sorting: persistedSettings.sorting\n ? persistedSettings.sorting.filter(ignoreNotDefinedColumns)\n : props.defaultSettings?.sorting ?? defaults.defaultSorting,\n };\n\n if (props.defaultRowGroupColumnId) {\n state.grouping = [props.defaultRowGroupColumnId as string];\n // row groups should (all) always be expanded by default\n state.expanded = true;\n }\n\n return state;\n }, []);\n}\n"],"names":["processChildren","child","columns","defaultSizing","defaultSorting","defaultVisibility","settings","defaultRowGroupColumnId","columnHelper","createColumnHelper","React","isValidElement","props","children","id","header","push","group","Children","toArray","reduce","enableGrouping","accessor","accessorKey","renderer","aggregate","footer","aggregationFn","defaultHidden","defaultWidth","enableFiltering","enableColumnFilter","enableHiding","enableOrdering","enablePrinting","enableResizing","enableSearch","enableGlobalFilter","enableSorting","enableTruncate","minWidth","minSize","getCellMinWidth","fontSize","sort","sortFn","meta","isGrouped","undefined","desc","column","accessorFn","row","get","cell","info","getValue","original","table","getRowModel","rows","flatMap","filterFn","aggregatedCell","sortingFn","getSortingFn","dataType","sortDescFirst","sortUndefined","createInternalColumn","size","mapTableChildrenToColumns","options","internalColumns","_props$rowActions","enableRowExpansion","rowExpansionRenderer","rowExpansion","unshift","enableRowSelection","enableRowSelectionSingle","rowSelection","enableRowDrag","onRowDrag","rowDrag","enableRowActions","rowActions","length","configureReactTableOptions","tableOptions","defaultColumn","enableColumnHiding","enableColumnResizing","enableColumnFilters","_options$enableFilter","_options$enableColumn","enableExpanding","_options$enableRowExp","_options$enableColumn2","enablePinning","_options$enableColumn3","enableColumnFreezing","enableMultiRowSelection","_options$enableSortin","getExpandedRowModel","getGroupedRowModel","groupedColumnMode","columnResizeMode","onChangeFilter","getFilteredRowModel","filterFns","tacoFilter","columnId","filter","columnFilterFn","globalFilterFn","getColumnCanGlobalFilter","_column$columnDef$met","_column$columnDef$met2","columnDef","onChangeSort","manualSorting","getSortedRowModel","useReactTableInitialState","persistedSettings","defaults","useMemo","ignoreNotDefinedColumns","find","definedColumn","columnPinning","_ref","_persistedSettings$co","_props$defaultSetting","defaultSettings","columnOrder","ensureOrdering","_persistedSettings$co2","_props$defaultSetting2","left","_columnPinning$left","freezeUptoExternalColumn","indexOf","defaultColumnFreezingIndex","unfreezeAllExternalColumns","state","columnFilters","_ref2","_persistedSettings$co3","_props$defaultSetting3","columnSizing","ignoreInternalColumns","_ref3","_ref4","_persistedSettings$co4","_props$defaultSetting4","columnVisibility","_ref5","_ref6","_persistedSettings$co5","_props$defaultSetting5","globalFilter","_persistedSettings$se","searchQuery","_props$defaultSetting6","sorting","_props$defaultSetting7","_props$defaultSetting8","grou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cAAAG,KAAA,cAAAA,KAAA,GAAI5B,QAAQ,CAAC1H,aAAa,cAAAqJ,KAAA,cAAAA,KAAA,GAAI,EAAE,CACxG;MACDI,gBAAgB,GAAAC,KAAA,IAAAC,KAAA,IAAAC,sBAAA,GACZnC,iBAAiB,CAACgC,gBAAgB,cAAAG,sBAAA,cAAAA,sBAAA,IAAAC,sBAAA,GAAIpJ,KAAK,CAAC0H,eAAe,cAAA0B,sBAAA,uBAArBA,sBAAA,CAAuBJ,gBAAgB,cAAAE,KAAA,cAAAA,KAAA,GAAIjC,QAAQ,CAACxH,iBAAiB,cAAAwJ,KAAA,cAAAA,KAAA,GAAI,EAAE;MACrHI,YAAY,GAAAC,qBAAA,GAAEtC,iBAAiB,CAACuC,WAAW,cAAAD,qBAAA,cAAAA,qBAAA,IAAAE,sBAAA,GAAIxJ,KAAK,CAAC0H,eAAe,cAAA8B,sBAAA,uBAArBA,sBAAA,CAAuBD,WAAW;MACjFE,OAAO,EAAEzC,iBAAiB,CAACyC,OAAO,GAC5BzC,iBAAiB,CAACyC,OAAO,CAACpD,MAAM,CAACc,uBAAuB,CAAC,IAAAuC,sBAAA,IAAAC,sBAAA,GACzD3J,KAAK,CAAC0H,eAAe,cAAAiC,sBAAA,uBAArBA,sBAAA,CAAuBF,OAAO,cAAAC,sBAAA,cAAAA,sBAAA,GAAIzC,QAAQ,CAACzH;KACpD;IAED,IAAIQ,KAAK,CAACL,uBAAuB,EAAE;MAC/B0I,KAAK,CAACuB,QAAQ,GAAG,CAAC5J,KAAK,CAACL,uBAAiC,CAAC;;MAE1D0I,KAAK,CAACwB,QAAQ,GAAG,IAAI;;IAGzB,OAAOxB,KAAK;GACf,EAAE,EAAE,CAAC;AACV;;;;"}
1
+ {"version":3,"file":"setup.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/setup.ts"],"sourcesContent":["import React from 'react';\nimport {\n createColumnHelper,\n getExpandedRowModel,\n getFilteredRowModel,\n getGroupedRowModel,\n getSortedRowModel,\n TableOptions as ReactTableOptions,\n Row as ReactTableRow,\n Column as ReactTableColumn,\n ColumnDef as ReactTableColumnDef,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSizingState as ReactTableColumnSizingState,\n ColumnSort as ReactTableColumnSort,\n TableState as ReactTableState,\n VisibilityState as ReactTableVisibilityState,\n} from '@tanstack/react-table';\nimport get from 'lodash/get';\n\nimport { useTableManagerInternalColumns, useTableManagerInternalColumn } from '../types';\nimport { TableColumnProps, TableFeatureProps, TableGroupProps, TableProps, TableSettings } from '../../types';\nimport { getSortingFn } from './sorting';\nimport { ensureOrdering, freezeUptoExternalColumn, getCellMinWidth, unfreezeAllExternalColumns } from './columns';\nimport { columnFilterFn, globalFilterFn } from './filtering';\nimport { ignoreInternalColumns } from './settings';\n\n// mapping children to react-table columns\nfunction processChildren<TType>(\n child: React.ReactChild | React.ReactFragment | React.ReactPortal,\n columns: ReactTableColumnDef<TType>[],\n defaultSizing: ReactTableColumnSizingState,\n defaultSorting: ReactTableColumnSort[],\n defaultVisibility: ReactTableVisibilityState,\n settings: TableSettings,\n defaultRowGroupColumnId?: keyof TType\n): ReactTableColumnDef<TType>[] {\n const columnHelper = createColumnHelper<TType>();\n\n if (React.isValidElement<TableGroupProps>(child) && child.props.children) {\n const { children, id, header } = child.props;\n\n columns.push(\n columnHelper.group({\n id,\n header,\n columns: React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId\n ),\n []\n ),\n // we don't want to let column groups be grouped/aggregrated\n enableGrouping: false,\n })\n );\n } else if (React.isValidElement<TableColumnProps<TType>>(child) && (child.props.accessor || child.props.id)) {\n const {\n id: untypedId,\n accessor: accessorKey = untypedId,\n // renderers\n renderer,\n aggregate,\n footer,\n header,\n // options\n aggregationFn,\n defaultHidden,\n defaultWidth,\n enableFiltering: enableColumnFilter = true,\n enableGrouping = false,\n enableHiding = true,\n enableOrdering = true,\n enablePrinting = true,\n enableResizing = true,\n enableSearch: enableGlobalFilter = true,\n enableSorting = true,\n enableTruncate = false,\n minWidth: minSize = getCellMinWidth(settings.fontSize),\n sort,\n sortFn,\n ...meta\n } = child.props;\n const id = untypedId as string;\n\n if (defaultHidden && enableHiding) {\n defaultVisibility[id] = false;\n }\n\n if (defaultWidth) {\n defaultSizing[id] = defaultWidth as any;\n }\n\n const isGrouped = defaultRowGroupColumnId === id;\n\n if (child.props.sort !== undefined || isGrouped) {\n defaultSorting.push({\n id,\n desc: sort === 'desc',\n });\n }\n\n const column: ReactTableColumnDef<TType, any> = {\n id,\n accessorKey,\n // To avoid errors caused by undefined row data values, we pass accessorFn as a preventive measure\n // accessorKey can be dot notated strings, so we use lodash.get to access deeply nested children\n accessorFn: row => get(row, accessorKey),\n header: header,\n // features\n enableColumnFilter,\n enableGlobalFilter,\n enableGrouping,\n enableHiding: isGrouped ? false : enableHiding,\n enableResizing,\n enableSorting,\n // config - sizing\n minSize,\n // meta\n meta: {\n ...(meta as any),\n defaultWidth,\n enableOrdering: isGrouped ? false : enableOrdering,\n enablePrinting,\n enableTruncate,\n header,\n renderer,\n },\n };\n\n // renderers\n if (typeof renderer === 'function') {\n column.cell = info => renderer(info.getValue(), info.row.original);\n }\n\n if (typeof footer === 'function') {\n column.footer = info =>\n footer(info.table.getRowModel().rows.flatMap(row => (row.original !== undefined ? row.original : [])));\n }\n\n // config - filtering\n if (enableColumnFilter) {\n column.filterFn = 'tacoFilter' as any;\n }\n\n // config - grouping/aggregation\n if (enableGrouping) {\n column.aggregationFn = aggregationFn;\n\n if (typeof aggregate === 'function') {\n column.aggregatedCell = info => aggregate(info.getValue(), info.row.original);\n }\n }\n\n // config - sorting\n if (enableSorting) {\n column.sortingFn = getSortingFn<TType>(child.props.dataType, sortFn);\n column.sortDescFirst = false;\n column.sortUndefined = 1;\n }\n\n columns.push(column);\n }\n\n return columns;\n}\n\nfunction createInternalColumn<TType = unknown>(\n id: string,\n column: useTableManagerInternalColumn<TType>,\n defaultSizing: ReactTableColumnSizingState\n) {\n if (column.size) {\n defaultSizing[id] = column.size;\n }\n\n return {\n id,\n accessorKey: id,\n header: column.header,\n cell: column.renderer,\n // features\n enableColumnFilter: false,\n enableGlobalFilter: false,\n enableGrouping: false,\n enableHiding: false,\n enableResizing: false,\n enableSorting: false,\n // config - sizing\n size: column.size,\n minSize: column.size,\n // meta\n meta: {\n ...(column.meta as any),\n enableOrdering: false,\n enablePrinting: false,\n enableTruncate: false,\n },\n } as ReactTableColumnDef<TType, any>;\n}\n\nexport function mapTableChildrenToColumns<TType = unknown>(\n props: TableProps<TType>,\n settings: TableSettings,\n options: TableFeatureProps<TType>,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\n const { children, defaultRowGroupColumnId } = props;\n const defaultSizing: ReactTableColumnSizingState = {};\n const defaultSorting: ReactTableColumnSort[] = [];\n const defaultVisibility: ReactTableVisibilityState = {};\n\n const columns = React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId\n ),\n\n []\n );\n\n if (internalColumns) {\n if (options.enableRowExpansion && props.rowExpansionRenderer && internalColumns.rowExpansion) {\n const column = createInternalColumn<TType>('__expansion', internalColumns.rowExpansion, defaultSizing);\n columns.unshift(column);\n }\n\n if ((options.enableRowSelection || options.enableRowSelectionSingle) && internalColumns.rowSelection) {\n const column = createInternalColumn<TType>('__select', internalColumns.rowSelection, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowDrag && props.onRowDrag && internalColumns.rowDrag) {\n const column = createInternalColumn<TType>('__drag', internalColumns.rowDrag, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowActions && props.rowActions?.length && internalColumns.rowActions) {\n const column = createInternalColumn<TType>('__actions', internalColumns.rowActions, defaultSizing);\n columns.push(column);\n }\n }\n\n return { columns, defaultSizing, defaultSorting, defaultVisibility };\n}\n\nexport function configureReactTableOptions<TType = unknown>(options: TableFeatureProps<TType>, props: TableProps<TType>) {\n const enableRowSelection = options.enableRowSelection || options.enableRowSelectionSingle;\n const tableOptions: Partial<ReactTableOptions<TType>> = {\n defaultColumn: {\n enableColumnFilter: options.enableFiltering || true,\n enableGrouping: false,\n enableHiding: options.enableColumnHiding || true,\n enableResizing: options.enableColumnResizing || true,\n enableGlobalFilter: options.enableSearch || true,\n enableSorting: options.enableSorting || true,\n minSize: 1,\n // the default is 150, which is a bit random\n size: 1,\n },\n enableColumnFilters: options.enableFiltering ?? false,\n enableColumnResizing: options.enableColumnResizing ?? false,\n enableExpanding: options.enableRowExpansion ?? false,\n enableGrouping: true, // users can't customise row grouping, so it can just be always enabled and left to the defaultRowGroupColumnId prop\n enableHiding: options.enableColumnHiding ?? false,\n enablePinning: options.enableColumnFreezing ?? false,\n enableRowSelection: enableRowSelection ?? false,\n enableMultiRowSelection: options.enableRowSelectionSingle === true ? false : enableRowSelection,\n enableSorting: options.enableSorting ?? false,\n // models for default features\n getExpandedRowModel: getExpandedRowModel<TType>(),\n getGroupedRowModel: getGroupedRowModel<TType>(),\n groupedColumnMode: false,\n };\n\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n if (tableOptions.enableColumnFilters) {\n // enter controlled filter mode (controlled could be local state, but usually the server)\n if (props.onChangeFilter) {\n // tableOptions.manualFiltering = true;\n // we don't set it because it breaks global filtering (used for search, which is fully client side)\n //\n // tableOptions.onColumnFiltersChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onFilter\n } else {\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.filterFns = {\n tacoFilter: (row: ReactTableRow<TType>, columnId: string, filter: any) =>\n columnFilterFn(row.getValue(columnId), filter),\n };\n }\n }\n\n if (options.enableSearch) {\n // always set these because enableGlobalFilter can be toggled on and off by the user\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.globalFilterFn = globalFilterFn;\n tableOptions.getColumnCanGlobalFilter = (column: ReactTableColumn<TType>) => column.columnDef.meta?.enableSearch ?? true;\n\n // enter controlled search mode (controlled could be local state, but usually the server)\n if (props.onChangeSearch) {\n // tableOptions.manualFiltering = true;\n // we don't set this because controlled search is not currently supported, search is always client side\n //\n // tableOptions.onGlobalFilterChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSearch.\n //\n // we also don't always filter when searching, we have the highlight functionality as the default\n // and filtering can be toggled by the user\n }\n }\n\n if (tableOptions.enableSorting) {\n // enter controlled sort mode (controlled could be local state, but usually the server)\n if (props.onChangeSort) {\n tableOptions.manualSorting = true;\n\n // tableOptions.onSortingChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSort\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n\nexport function useReactTableInitialState<TType = unknown>(\n props: TableProps<TType>,\n columns: ReactTableColumnDef<TType>[],\n persistedSettings: TableSettings,\n defaults: {\n defaultSizing: ReactTableColumnSizingState;\n defaultSorting: ReactTableColumnSort[];\n defaultVisibility: ReactTableVisibilityState;\n }\n): Partial<ReactTableState> {\n return React.useMemo(() => {\n const ignoreNotDefinedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n const columnPinning: ReactTableColumnPinningState =\n persistedSettings.columnPinning ?? props.defaultSettings?.columnPinning ?? {};\n\n const columnOrder = ensureOrdering<TType>(\n columns,\n persistedSettings.columnOrder ?? props.defaultSettings?.columnOrder,\n columnPinning.left\n );\n\n // ensure internal columns are pinned, and are pinned in the correct order\n if (columnPinning?.left?.length) {\n columnPinning.left = freezeUptoExternalColumn(\n columnOrder.indexOf(columnPinning.left[columnPinning.left.length - 1]),\n columnOrder\n );\n } else {\n if (props.defaultColumnFreezingIndex) {\n columnPinning.left = freezeUptoExternalColumn(props.defaultColumnFreezingIndex, columnOrder);\n } else {\n columnPinning.left = unfreezeAllExternalColumns(columnOrder);\n }\n }\n\n const state: Partial<ReactTableState> = {\n columnFilters: persistedSettings.columnFilters ?? props.defaultSettings?.columnFilters ?? [],\n columnOrder,\n columnPinning,\n columnSizing: ignoreInternalColumns(\n persistedSettings.columnSizing ?? props.defaultSettings?.columnSizing ?? defaults.defaultSizing ?? {}\n ),\n columnVisibility:\n persistedSettings.columnVisibility ?? props.defaultSettings?.columnVisibility ?? defaults.defaultVisibility ?? {},\n globalFilter: persistedSettings.searchQuery ?? props.defaultSettings?.searchQuery,\n sorting: persistedSettings.sorting\n ? persistedSettings.sorting.filter(ignoreNotDefinedColumns)\n : props.defaultSettings?.sorting ?? defaults.defaultSorting,\n };\n\n if (props.defaultRowGroupColumnId) {\n state.grouping = [props.defaultRowGroupColumnId as string];\n // row groups should (all) always be expanded by default\n state.expanded = true;\n }\n\n return state;\n }, []);\n}\n"],"names":["processChildren","child","columns","defaultSizing","defaultSorting","defaultVisibility","settings","defaultRowGroupColumnId","columnHelper","createColumnHelper","React","isValidElement","props","children","id","header","push","group","Children","toArray","reduce","enableGrouping","accessor","untypedId","accessorKey","renderer","aggregate","footer","aggregationFn","defaultHidden","defaultWidth","enableFiltering","enableColumnFilter","enableHiding","enableOrdering","enablePrinting","enableResizing","enableSearch","enableGlobalFilter","enableSorting","enableTruncate","minWidth","minSize","getCellMinWidth","fontSize","sort","sortFn","meta","isGrouped","undefined","desc","column","accessorFn","row","get","cell","info","getValue","original","table","getRowModel","rows","flatMap","filterFn","aggregatedCell","sortingFn","getSortingFn","dataType","sortDescFirst","sortUndefined","createInternalColumn","size","mapTableChildrenToColumns","options","internalColumns","_props$rowActions","enableRowExpansion","rowExpansionRenderer","rowExpansion","unshift","enableRowSelection","enableRowSelectionSingle","rowSelection","enableRowDrag","onRowDrag","rowDrag","enableRowActions","rowActions","length","configureReactTableOptions","tableOptions","defaultColumn","enableColumnHiding","enableColumnResizing","enableColumnFilters","_options$enableFilter","_options$enableColumn","enableExpanding","_options$enableRowExp","_options$enableColumn2","enablePinning","_options$enableColumn3","enableColumnFreezing","enableMultiRowSelection","_options$enableSortin","getExpandedRowModel","getGroupedRowModel","groupedColumnMode","columnResizeMode","onChangeFilter","getFilteredRowModel","filterFns","tacoFilter","columnId","filter","columnFilterFn","globalFilterFn","getColumnCanGlobalFilter","_column$columnDef$met","_column$columnDef$met2","columnDef","onChangeSort","manualSorting","getSortedRowModel","useReactTableInitialState","persistedSettings","defaults","useMemo","ignoreNotDefinedColumns","find","definedColumn","columnPinning","_ref","_persistedSettings$co","_props$defaultSetting","defaultSettings","columnOrder","ensureOrdering","_persistedSettings$co2","_props$defaultSetting2","left","_columnPinning$left","freezeUptoExternalColumn","indexOf","defaultColumnFreezingIndex","unfreezeAllExternalColumns","state","columnFilters","_ref2","_persistedSettings$co3","_props$defaultSetting3","columnSizing","ignoreInternalColumns","_ref3","_ref4","_persistedSettings$co4","_props$defaultSetting4","columnVisibility","_ref5","_ref6","_persistedSettings$co5","_props$defaultSetting5","globalFilter","_persistedSettings$se","searchQuery","_props$defaultSetting6","sorting","_props$defaultSetting7","_props$defaultSetting8","grouping","expanded"],"mappings":";;;;;;;;AA0BA;AACA,SAASA,eAAeA,CACpBC,KAAiE,EACjEC,OAAqC,EACrCC,aAA0C,EAC1CC,cAAsC,EACtCC,iBAA4C,EAC5CC,QAAuB,EACvBC,uBAAqC;EAErC,MAAMC,YAAY,GAAGC,kBAAkB,EAAS;EAEhD,kBAAIC,cAAK,CAACC,cAAc,CAAkBV,KAAK,CAAC,IAAIA,KAAK,CAACW,KAAK,CAACC,QAAQ,EAAE;IACtE,MAAM;MAAEA,QAAQ;MAAEC,EAAE;MAAEC;KAAQ,GAAGd,KAAK,CAACW,KAAK;IAE5CV,OAAO,CAACc,IAAI,CACRR,YAAY,CAACS,KAAK,CAAC;MACfH,EAAE;MACFC,MAAM;MACNb,OA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,YAAY,GAAAC,qBAAA,GAAEtC,iBAAiB,CAACuC,WAAW,cAAAD,qBAAA,cAAAA,qBAAA,IAAAE,sBAAA,GAAIzJ,KAAK,CAAC2H,eAAe,cAAA8B,sBAAA,uBAArBA,sBAAA,CAAuBD,WAAW;MACjFE,OAAO,EAAEzC,iBAAiB,CAACyC,OAAO,GAC5BzC,iBAAiB,CAACyC,OAAO,CAACpD,MAAM,CAACc,uBAAuB,CAAC,IAAAuC,sBAAA,IAAAC,sBAAA,GACzD5J,KAAK,CAAC2H,eAAe,cAAAiC,sBAAA,uBAArBA,sBAAA,CAAuBF,OAAO,cAAAC,sBAAA,cAAAA,sBAAA,GAAIzC,QAAQ,CAAC1H;KACpD;IAED,IAAIQ,KAAK,CAACL,uBAAuB,EAAE;MAC/B2I,KAAK,CAACuB,QAAQ,GAAG,CAAC7J,KAAK,CAACL,uBAAiC,CAAC;;MAE1D2I,KAAK,CAACwB,QAAQ,GAAG,IAAI;;IAGzB,OAAOxB,KAAK;GACf,EAAE,EAAE,CAAC;AACV;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../../src/types.ts"],"sourcesContent":["import React from 'react';\nimport { AVAILABLE_COLORS } from './utils/tailwind';\n\nexport type Appearance = 'default' | 'primary' | 'danger' | 'ghost' | 'discrete' | 'transparent';\nexport type State = 'default' | 'success' | 'error' | 'warning' | 'information';\nexport type Locale = 'en-GB' | 'da-DK' | 'sv-SE' | 'no-NO';\nexport type Orientation = 'horizontal' | 'vertical';\nexport type Align = 'start' | 'center' | 'end';\nexport type Placement = 'right' | 'left' | 'top' | 'bottom';\nexport type Color = (typeof AVAILABLE_COLORS)[number];\n\nexport enum FontSizes {\n small = 'small',\n medium = 'medium',\n large = 'large',\n}\nexport type FontSize = keyof typeof FontSizes;\n\n// helpers\ntype FixedForwardRef = <T, P = {}>(\n render: (props: P, ref: React.Ref<T>) => JSX.Element\n) => (props: P & React.RefAttributes<T>) => JSX.Element;\n\nexport const fixedForwardRef = React.forwardRef as FixedForwardRef;\n\nexport type ValueOf<T> = T[keyof T];\n"],"names":["FontSizes","fixedForwardRef","React","forwardRef"],"mappings":";;IAWYA;AAAZ,WAAYA,SAAS;EACjBA,4BAAe;EACfA,8BAAiB;EACjBA,4BAAe;AACnB,CAAC,EAJWA,SAAS,KAATA,SAAS;MAYRC,eAAe,GAAGC,cAAK,CAACC;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../../../src/types.ts"],"sourcesContent":["import React from 'react';\nimport { AVAILABLE_COLORS } from './utils/tailwind';\n\nexport type Appearance = 'default' | 'primary' | 'danger' | 'ghost' | 'discrete' | 'transparent';\nexport type State = 'default' | 'success' | 'error' | 'warning' | 'information';\nexport type Locale = 'en-GB' | 'da-DK' | 'sv-SE' | 'no-NO';\nexport type Orientation = 'horizontal' | 'vertical';\nexport type Align = 'start' | 'center' | 'end';\nexport type Placement = 'right' | 'left' | 'top' | 'bottom';\nexport type Color = (typeof AVAILABLE_COLORS)[number];\n\nexport enum FontSizes {\n small = 'small',\n medium = 'medium',\n large = 'large',\n}\nexport type FontSize = keyof typeof FontSizes;\n\n// helpers\ntype FixedForwardRef = <T, P = {}>(\n render: (props: P, ref: React.Ref<T>) => JSX.Element\n) => (props: P & React.RefAttributes<T>) => JSX.Element;\n\nexport const fixedForwardRef = React.forwardRef as FixedForwardRef;\n\nexport type ValueOf<T> = T[keyof T];\n\nexport type StringWithAutocompleteOptions<T> = T | (string & {});\n"],"names":["FontSizes","fixedForwardRef","React","forwardRef"],"mappings":";;IAWYA;AAAZ,WAAYA,SAAS;EACjBA,4BAAe;EACfA,8BAAiB;EACjBA,4BAAe;AACnB,CAAC,EAJWA,SAAS,KAATA,SAAS;MAYRC,eAAe,GAAGC,cAAK,CAACC;;;;"}
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
- import { TableEmptyStateRenderer } from '../../../types';
2
+ import { TableEmptyStateReason, TableEmptyStateRenderer } from '../../../types';
3
3
  declare type EmptyStateProps = React.HTMLAttributes<HTMLTableSectionElement> & {
4
4
  emptyState?: TableEmptyStateRenderer;
5
+ reason: TableEmptyStateReason;
5
6
  };
6
7
  export declare function EmptyStateBody(props: EmptyStateProps): JSX.Element;
7
8
  export {};
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { ColumnFilter as ReactTableColumnFilter, ColumnFiltersState as ReactTableColumnFilterState, ColumnOrderState as ReactTableColumnOrderState, ColumnPinningState as ReactTableColumnPinningState, ColumnSort as ReactTableColumnSort, ColumnSizingState as ReactTableColumnSizingState, VisibilityState as ReactTableColumnVisibilityState, SortingState as ReactTableSortingState, BuiltInAggregationFn as ReactTableBuiltInAggregationFn, BuiltInSortingFn as ReactTableBuiltInSortingFn } from '@tanstack/react-table';
3
- import { FontSize, FontSizes, ValueOf } from '../../types';
3
+ import { FontSize, FontSizes, StringWithAutocompleteOptions, ValueOf } from '../../types';
4
4
  import { MenuItemProps } from '../../components/Menu/components/Item';
5
5
  export declare type TableRef = HTMLTableElement & {
6
6
  instance: {
@@ -98,7 +98,10 @@ export declare type TableSettingsHandler = (settings: TableSettings) => void | P
98
98
  export declare type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;
99
99
  export declare type TableSortHandler = (sorting: TableColumnSort[]) => void | Promise<void>;
100
100
  export declare type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];
101
- export declare type TableEmptyStateRenderer = () => JSX.Element | null;
101
+ export declare type TableEmptyStateReason = 'empty' | 'filtering' | 'searching';
102
+ export declare type TableEmptyStateRenderer = (props: {
103
+ reason: TableEmptyStateReason;
104
+ }) => JSX.Element;
102
105
  export declare type TableSettings = {
103
106
  columnFilters?: ReactTableColumnFilterState;
104
107
  columnOrder?: ReactTableColumnOrderState;
@@ -191,7 +194,7 @@ export declare type TableProps<TType = unknown> = TableClientProps<TType> | Tabl
191
194
  export declare type TableColumnProps<TType = unknown> = ValueOf<{
192
195
  [Key in keyof TType]: {
193
196
  accessor?: Key;
194
- id: string;
197
+ id: StringWithAutocompleteOptions<Key>;
195
198
  renderer?: TableColumnRenderer<TType, TType[Key]>;
196
199
  /** Renderer to use if the cell is an aggregate cell and part of a grouped row */
197
200
  aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;
@@ -43,6 +43,7 @@ var set = _interopDefault(require('lodash/set'));
43
43
  var unset = _interopDefault(require('lodash/unset'));
44
44
  var compact = _interopDefault(require('lodash/compact'));
45
45
  var pullAt = _interopDefault(require('lodash/pullAt'));
46
+ var lodash = require('lodash');
46
47
  var TabsPrimitive = require('@radix-ui/react-tabs');
47
48
  var Joyride = require('react-joyride');
48
49
  var Joyride__default = _interopDefault(Joyride);
@@ -10059,8 +10060,8 @@ function processChildren(child, columns, defaultSizing, defaultSorting, defaultV
10059
10060
  }));
10060
10061
  } else if ( /*#__PURE__*/React__default.isValidElement(child) && (child.props.accessor || child.props.id)) {
10061
10062
  const {
10062
- id,
10063
- accessor: accessorKey = id,
10063
+ id: untypedId,
10064
+ accessor: accessorKey = untypedId,
10064
10065
  // renderers
10065
10066
  renderer,
10066
10067
  aggregate,
@@ -10084,6 +10085,7 @@ function processChildren(child, columns, defaultSizing, defaultSorting, defaultV
10084
10085
  sortFn,
10085
10086
  ...meta
10086
10087
  } = child.props;
10088
+ const id = untypedId;
10087
10089
  if (defaultHidden && enableHiding) {
10088
10090
  defaultVisibility[id] = false;
10089
10091
  }
@@ -13629,7 +13631,8 @@ const MemoedFooter = /*#__PURE__*/React__default.memo(function MemoedFooter(prop
13629
13631
 
13630
13632
  function EmptyStateBody(props) {
13631
13633
  const {
13632
- emptyState: Placeholder = null,
13634
+ emptyState: Placeholder,
13635
+ reason,
13633
13636
  ...attributes
13634
13637
  } = props;
13635
13638
  return /*#__PURE__*/React__default.createElement("tbody", Object.assign({}, attributes, {
@@ -13638,7 +13641,9 @@ function EmptyStateBody(props) {
13638
13641
  className: "!auto-rows-fr"
13639
13642
  }, /*#__PURE__*/React__default.createElement("td", {
13640
13643
  className: "col-span-full !border-0 !p-0 hover:!bg-white"
13641
- }, Placeholder ? /*#__PURE__*/React__default.createElement(Placeholder, null) : null)));
13644
+ }, Placeholder ? /*#__PURE__*/React__default.createElement(Placeholder, {
13645
+ reason: reason
13646
+ }) : undefined)));
13642
13647
  }
13643
13648
 
13644
13649
  const SearchInput2 = /*#__PURE__*/React__default.forwardRef(function SearchInput2(props, ref) {
@@ -16573,6 +16578,19 @@ function Table(props) {
16573
16578
  }
16574
16579
  Table.Toolbar = TableToolbar;
16575
16580
  Table.Grid = TableGrid;
16581
+ function getFilterReason(table) {
16582
+ if (table.instance.getFilteredRowModel().rows.length === 0 && table.instance.getCoreRowModel().rows.length !== 0) {
16583
+ const state = table.instance.getState();
16584
+ if (table.meta.search.enableGlobalFilter && !!state.globalFilter) {
16585
+ return 'searching';
16586
+ }
16587
+ return 'filtering';
16588
+ }
16589
+ if (table.instance.getCoreRowModel().rows.length === 0) {
16590
+ return 'empty';
16591
+ }
16592
+ return null;
16593
+ }
16576
16594
  function TableGrid(props) {
16577
16595
  var _table$state$grouping;
16578
16596
  const {
@@ -16583,6 +16601,7 @@ function TableGrid(props) {
16583
16601
  const handleFocus = table.meta.rowActive.rowActiveIndex === undefined ? event => {
16584
16602
  table.meta.rowActive.handleFocus(event, table.meta.length, table.renderer.scrollToIndex);
16585
16603
  } : undefined;
16604
+ const filterReason = getFilterReason(table);
16586
16605
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("style", null, table.stylesheet), /*#__PURE__*/React__default.createElement(focus.FocusScope, null, /*#__PURE__*/React__default.createElement("table", Object.assign({}, attributes, {
16587
16606
  id: table.id,
16588
16607
  "data-table-font-size": table.meta.fontSize.size,
@@ -16603,7 +16622,10 @@ function TableGrid(props) {
16603
16622
  key: props.id,
16604
16623
  header: props,
16605
16624
  scrollToIndex: table.renderer.scrollToIndex
16606
- }))))))), table.instance.getCoreRowModel().rows.length ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Body, {
16625
+ }))))))), filterReason ? ( /*#__PURE__*/React__default.createElement(EmptyStateBody, {
16626
+ emptyState: props.table.props.emptyState,
16627
+ reason: filterReason
16628
+ })) : ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Body, {
16607
16629
  enableHorizontalArrowKeyNavigation: enableHorizontalArrowKeyNavigation,
16608
16630
  table: table.instance,
16609
16631
  tableElement: table.ref.current,
@@ -16614,9 +16636,7 @@ function TableGrid(props) {
16614
16636
  } : table.renderer.style
16615
16637
  }, table.renderer.rows, props.children), table.meta.footer.isEnabled ? /*#__PURE__*/React__default.createElement(Foot, {
16616
16638
  table: table.instance
16617
- }) : null)) : ( /*#__PURE__*/React__default.createElement(EmptyStateBody, {
16618
- emptyState: table.props.emptyState
16619
- })))));
16639
+ }) : null)))));
16620
16640
  }
16621
16641
 
16622
16642
  function Column$1(_) {
@@ -18233,9 +18253,22 @@ function willRowMoveAfterSorting(cell, change, rowIndex) {
18233
18253
  if (rowIndex < rows.length - 1) {
18234
18254
  miniSortRows.push(rows[rowIndex + 1]);
18235
18255
  }
18236
- let resortedRows = [...miniSortRows].sort((a, b) => cell.column.getSortingFn()(a, b, cell.column.id));
18256
+ const resortedRows = [...miniSortRows].sort((rowA, rowB) => {
18257
+ const sortFn = cell.column.getSortingFn();
18258
+ const sortUndefined = cell.column.columnDef.sortUndefined;
18259
+ if (!table.options.manualSorting && sortUndefined) {
18260
+ const aValue = rowA.getValue(cell.column.id);
18261
+ const bValue = rowB.getValue(cell.column.id);
18262
+ const aUndefined = aValue === undefined;
18263
+ const bUndefined = bValue === undefined;
18264
+ if (aUndefined || bUndefined) {
18265
+ return aUndefined && bUndefined ? 0 : aUndefined ? sortUndefined : -sortUndefined;
18266
+ }
18267
+ }
18268
+ return sortFn(rowA, rowB, cell.column.id);
18269
+ });
18237
18270
  if (cell.column.getIsSorted() === 'desc') {
18238
- resortedRows = resortedRows.reverse();
18271
+ resortedRows.reverse();
18239
18272
  }
18240
18273
  return ((_resortedRows$index = resortedRows[index]) === null || _resortedRows$index === void 0 ? void 0 : _resortedRows$index.id) !== cell.row.id;
18241
18274
  }
@@ -18259,7 +18292,7 @@ function animateCreateRow(id) {
18259
18292
  }
18260
18293
  }
18261
18294
 
18262
- function useTableEditing(isEnabled = false, handleSave, validator) {
18295
+ function useTableEditing(isEnabled = false, handleSave, handleChange, validator) {
18263
18296
  // used to switch the table into editing mode
18264
18297
  const [isEditing, toggleEditing] = React__default.useState(false);
18265
18298
  // used to switch the editing between "detailed" mode
@@ -18269,7 +18302,7 @@ function useTableEditing(isEnabled = false, handleSave, validator) {
18269
18302
  // store pending changes for each row
18270
18303
  // changes are saved as soon as the active row changes, so in most cases this will only contain the active row's changes
18271
18304
  // but not always - if validation or server requests fail when saving, those rows remain until the failure is resolved
18272
- const pendingChangesFns = usePendingChanges(isEnabled, handleSave, validator);
18305
+ const pendingChangesFns = usePendingChanges(isEnabled, handleSave, handleChange, validator);
18273
18306
  useGlobalKeyDown(isEnabled && isEditing ? {
18274
18307
  key: 's',
18275
18308
  meta: true,
@@ -18289,12 +18322,12 @@ function useTableEditing(isEnabled = false, handleSave, validator) {
18289
18322
  ...pendingChangesFns
18290
18323
  };
18291
18324
  }
18292
- function usePendingChanges(isEnabled, handleSave, validator) {
18325
+ function usePendingChanges(isEnabled, handleSave, handleChange, validator) {
18293
18326
  const saveChanges = function (rowId = undefined) {
18294
18327
  try {
18295
18328
  let _exit = false;
18296
18329
  if (!handleSave) {
18297
- console.warn('Tried to save, but Table has no onSave handler');
18330
+ console.warn('Tried to save, but Table has no onEditingSave handler');
18298
18331
  return Promise.resolve();
18299
18332
  }
18300
18333
  // we save back to pendingChanges, so make a copy of it's state when save was triggered
@@ -18335,7 +18368,7 @@ function usePendingChanges(isEnabled, handleSave, validator) {
18335
18368
  }();
18336
18369
  return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2); // send new data to the server
18337
18370
  }, function (error) {
18338
- // the onSave handler should throw errors when something fails, e.g. validation, network errors etc
18371
+ // the onEditingSave handler should throw errors when something fails, e.g. validation, network errors etc
18339
18372
  // this code handles those errors and maps them either to row errors or cell specific errors
18340
18373
  let rowError;
18341
18374
  let cellErrors;
@@ -18409,26 +18442,42 @@ function usePendingChanges(isEnabled, handleSave, validator) {
18409
18442
  return Promise.reject(e);
18410
18443
  }
18411
18444
  };
18445
+ const setCellValue = function (cell, change, rowIndex) {
18446
+ try {
18447
+ const changes = {
18448
+ [cell.column.id]: change
18449
+ };
18450
+ setPendingChanges(currentChanges => {
18451
+ const nextChanges = createPendingChangesSetter(currentChanges, cell.row, rowIndex, changes);
18452
+ pendingChangesUpdater.syncCellChanges(nextChanges);
18453
+ return nextChanges;
18454
+ });
18455
+ pendingChangesUpdater.runCellUpdates(changes, cell, rowIndex);
18456
+ return Promise.resolve();
18457
+ } catch (e) {
18458
+ return Promise.reject(e);
18459
+ }
18460
+ };
18412
18461
  const addCreatedRowChangeset = function (row) {
18413
18462
  try {
18414
18463
  const cells = row.getAllCells();
18415
18464
  setPendingChanges(currentChanges => {
18416
18465
  return cells.reduce((changes, cell) => {
18417
18466
  if (cell.getValue()) {
18418
- var _currentChanges$cell$4, _currentChanges$cell$5, _currentChanges$cell$6;
18467
+ var _currentChanges$cell$, _currentChanges$cell$2, _currentChanges$cell$3;
18419
18468
  return {
18420
18469
  ...changes,
18421
18470
  [cell.row.id]: {
18422
18471
  ...changes[cell.row.id],
18423
18472
  [cell.column.id]: cell.getValue(),
18424
18473
  _meta: {
18425
- ...((_currentChanges$cell$4 = currentChanges[cell.row.id]) === null || _currentChanges$cell$4 === void 0 ? void 0 : _currentChanges$cell$4._meta),
18474
+ ...((_currentChanges$cell$ = currentChanges[cell.row.id]) === null || _currentChanges$cell$ === void 0 ? void 0 : _currentChanges$cell$._meta),
18426
18475
  original: cell.row.original,
18427
18476
  moveReason: {
18428
- ...((_currentChanges$cell$5 = currentChanges[cell.row.id]) === null || _currentChanges$cell$5 === void 0 ? void 0 : _currentChanges$cell$5._meta.moveReason)
18477
+ ...((_currentChanges$cell$2 = currentChanges[cell.row.id]) === null || _currentChanges$cell$2 === void 0 ? void 0 : _currentChanges$cell$2._meta.moveReason)
18429
18478
  },
18430
18479
  errors: {
18431
- ...((_currentChanges$cell$6 = currentChanges[cell.row.id]) === null || _currentChanges$cell$6 === void 0 ? void 0 : _currentChanges$cell$6._meta.errors)
18480
+ ...((_currentChanges$cell$3 = currentChanges[cell.row.id]) === null || _currentChanges$cell$3 === void 0 ? void 0 : _currentChanges$cell$3._meta.errors)
18432
18481
  }
18433
18482
  }
18434
18483
  }
@@ -18454,49 +18503,7 @@ function usePendingChanges(isEnabled, handleSave, validator) {
18454
18503
  var _pendingChanges$cell$2, _pendingChanges$cell$3, _pendingChanges$cell$4;
18455
18504
  return (_pendingChanges$cell$2 = pendingChanges[cell.row.id]) === null || _pendingChanges$cell$2 === void 0 ? void 0 : (_pendingChanges$cell$3 = _pendingChanges$cell$2._meta.errors) === null || _pendingChanges$cell$3 === void 0 ? void 0 : (_pendingChanges$cell$4 = _pendingChanges$cell$3.cells) === null || _pendingChanges$cell$4 === void 0 ? void 0 : _pendingChanges$cell$4[cell.column.id];
18456
18505
  }
18457
- const setCellValue = React__default.useCallback(function (cell, change, rowIndex) {
18458
- setPendingChanges(currentChanges => {
18459
- var _currentChanges$cell$, _currentChanges$cell$2, _currentChanges$cell$3;
18460
- const nextChanges = {
18461
- ...currentChanges
18462
- };
18463
- const rowChanges = {
18464
- ...currentChanges[cell.row.id],
18465
- _meta: {
18466
- ...((_currentChanges$cell$ = currentChanges[cell.row.id]) === null || _currentChanges$cell$ === void 0 ? void 0 : _currentChanges$cell$._meta),
18467
- original: cell.row.original,
18468
- moveReason: {
18469
- ...((_currentChanges$cell$2 = currentChanges[cell.row.id]) === null || _currentChanges$cell$2 === void 0 ? void 0 : _currentChanges$cell$2._meta.moveReason)
18470
- },
18471
- errors: {
18472
- ...((_currentChanges$cell$3 = currentChanges[cell.row.id]) === null || _currentChanges$cell$3 === void 0 ? void 0 : _currentChanges$cell$3._meta.errors)
18473
- }
18474
- }
18475
- };
18476
- // update if the change is different to the original (saved) value,
18477
- // otherwise remove any change - no point saving the same value
18478
- if (change !== cell.row.original[cell.column.id]) {
18479
- rowChanges[cell.column.id] = change;
18480
- // determine if the row will move position based on this change, and save why it will move
18481
- const reason = willRowMove(cell, change, rowIndex);
18482
- if (reason) {
18483
- rowChanges._meta.moveReason[cell.column.id] = reason;
18484
- } else {
18485
- delete rowChanges._meta.moveReason[cell.column.id];
18486
- }
18487
- } else {
18488
- delete rowChanges[cell.column.id];
18489
- }
18490
- // set the changes for the row...
18491
- // or delete if there are no changes left, so that we don't store changes with unchanged data
18492
- if (Object.keys(rowChanges).filter(k => k !== '_meta').length) {
18493
- nextChanges[cell.row.id] = rowChanges;
18494
- } else {
18495
- delete nextChanges[cell.row.id];
18496
- }
18497
- return nextChanges;
18498
- });
18499
- }, []);
18506
+ const pendingChangesUpdater = usePendingChangesUpdater(handleChange, setPendingChanges);
18500
18507
  function hasRowErrors(rowId) {
18501
18508
  var _pendingChanges$rowId, _pendingChanges$rowId2, _pendingChanges$rowId3, _pendingChanges$rowId4, _pendingChanges$rowId5;
18502
18509
  if (!isEnabled) {
@@ -18617,6 +18624,87 @@ function useLastFocusedCellIndex() {
18617
18624
  }, []);
18618
18625
  return [lastFocusedCellIndexRef.current, setLastFocusedCellIndex];
18619
18626
  }
18627
+ function usePendingChangesUpdater(handleChange, setPendingChanges) {
18628
+ const updatersRef = React__default.useRef({});
18629
+ const runCellUpdates = React__default.useCallback(lodash.debounce(function (changes, cell, rowIndex) {
18630
+ try {
18631
+ const _temp4 = function () {
18632
+ if (typeof handleChange === 'function') {
18633
+ const previousValues = {
18634
+ ...cell.row.original,
18635
+ ...getChangesetFromChanges(updatersRef.current[cell.row.id])
18636
+ };
18637
+ const nextValues = {
18638
+ ...previousValues,
18639
+ ...changes
18640
+ };
18641
+ return Promise.resolve(handleChange(cell.column.id, changes[cell.column.id], nextValues, previousValues)).then(function (updates) {
18642
+ if (updates && Object.keys(updates).length) {
18643
+ setPendingChanges(currentChanges => createPendingChangesSetter(currentChanges, cell.row, rowIndex, updates));
18644
+ }
18645
+ });
18646
+ }
18647
+ }();
18648
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
18649
+ } catch (e) {
18650
+ return Promise.reject(e);
18651
+ }
18652
+ }, 250), []);
18653
+ function syncCellChanges(changes) {
18654
+ updatersRef.current = changes;
18655
+ }
18656
+ return {
18657
+ syncCellChanges,
18658
+ runCellUpdates
18659
+ };
18660
+ }
18661
+ function createPendingChangesSetter(currentChanges, row, rowIndex, changes) {
18662
+ var _currentChanges$row$i, _currentChanges$row$i2, _currentChanges$row$i3;
18663
+ // prepare
18664
+ const nextChanges = {
18665
+ ...currentChanges
18666
+ };
18667
+ const rowChanges = {
18668
+ ...currentChanges[row.id],
18669
+ _meta: {
18670
+ ...((_currentChanges$row$i = currentChanges[row.id]) === null || _currentChanges$row$i === void 0 ? void 0 : _currentChanges$row$i._meta),
18671
+ original: row.original,
18672
+ moveReason: {
18673
+ ...((_currentChanges$row$i2 = currentChanges[row.id]) === null || _currentChanges$row$i2 === void 0 ? void 0 : _currentChanges$row$i2._meta.moveReason)
18674
+ },
18675
+ errors: {
18676
+ ...((_currentChanges$row$i3 = currentChanges[row.id]) === null || _currentChanges$row$i3 === void 0 ? void 0 : _currentChanges$row$i3._meta.errors)
18677
+ }
18678
+ }
18679
+ };
18680
+ // run changes
18681
+ const cells = row._getAllCellsByColumnId();
18682
+ for (const [accessor, change] of Object.entries(changes)) {
18683
+ // update if the change is different to the original (saved) value,
18684
+ // otherwise remove any change - no point saving the same value
18685
+ if (change !== row.original[accessor]) {
18686
+ rowChanges[accessor] = change;
18687
+ // determine if the row will move position based on this change, and save why it will move
18688
+ const reason = willRowMove(cells[accessor], change, rowIndex);
18689
+ if (reason) {
18690
+ rowChanges._meta.moveReason[accessor] = reason;
18691
+ } else {
18692
+ delete rowChanges._meta.moveReason[accessor];
18693
+ }
18694
+ } else {
18695
+ delete rowChanges[accessor];
18696
+ delete rowChanges._meta.moveReason[accessor];
18697
+ }
18698
+ }
18699
+ // set changes
18700
+ // or delete if there are no changes left, so that we don't store changes with unchanged data
18701
+ if (Object.keys(rowChanges).filter(k => k !== '_meta').length) {
18702
+ nextChanges[row.id] = rowChanges;
18703
+ } else {
18704
+ delete nextChanges[row.id];
18705
+ }
18706
+ return nextChanges;
18707
+ }
18620
18708
  function getChangesetFromChanges(changes) {
18621
18709
  // extract the original data from the row changes
18622
18710
  const {
@@ -19102,7 +19190,7 @@ function EditingActionMenu(props) {
19102
19190
  hasErrors,
19103
19191
  onClear: handleClear,
19104
19192
  onExit: handleExit,
19105
- onSave: handleSave,
19193
+ onEditingSave: handleSave,
19106
19194
  isLastRow
19107
19195
  } = props;
19108
19196
  const {
@@ -19240,8 +19328,8 @@ const RENDERERS$1 = {
19240
19328
  cell: Cell$5
19241
19329
  };
19242
19330
  function useTable3(props, ref) {
19243
- const editing = useTableEditing(props.enableEditing, props.onSave, props.validator);
19244
- const creationEnabled = editing.isEnabled && !!props.enableCreation;
19331
+ const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.validator);
19332
+ const creationEnabled = editing.isEnabled && !!props.onEditingCreate;
19245
19333
  const extendedProps = {
19246
19334
  ...props,
19247
19335
  enableRowActions: editing.isEditing ? true : props.enableRowActions,
@@ -19249,7 +19337,7 @@ function useTable3(props, ref) {
19249
19337
  hasChanges: editing.hasChanges(rowId),
19250
19338
  hasErrors: editing.hasRowErrors(rowId),
19251
19339
  onClear: () => editing.resetChanges(rowId),
19252
- onSave: () => editing.saveChanges(rowId),
19340
+ onEditingSave: () => editing.saveChanges(rowId),
19253
19341
  onExit: () => editing.toggleEditing(false),
19254
19342
  isLastRow: !creationEnabled && table.meta.rowActive.rowActiveIndex === table.meta.length - 1
19255
19343
  }))] : props.rowActions
@@ -19399,7 +19487,7 @@ function FilterResetDialog(props) {
19399
19487
 
19400
19488
  function CreateNewRowButton(props) {
19401
19489
  const {
19402
- onCreate,
19490
+ onEditingCreate,
19403
19491
  scrollToIndex,
19404
19492
  table,
19405
19493
  tableMeta
@@ -19418,7 +19506,7 @@ function CreateNewRowButton(props) {
19418
19506
  };
19419
19507
  const handleCreate = function () {
19420
19508
  try {
19421
- if (!onCreate) {
19509
+ if (!onEditingCreate) {
19422
19510
  return Promise.resolve();
19423
19511
  }
19424
19512
  const createdRow = rows.find(row => {
@@ -19429,14 +19517,14 @@ function CreateNewRowButton(props) {
19429
19517
  if (createdRow) {
19430
19518
  return Promise.resolve(tableMeta.editing.saveChanges()).then(function () {
19431
19519
  if (!tableMeta.editing.hasRowErrors(createdRow.id)) {
19432
- const rowFinder = onCreate();
19520
+ const rowFinder = onEditingCreate();
19433
19521
  setRowCreated({
19434
19522
  rowFinder
19435
19523
  });
19436
19524
  }
19437
19525
  });
19438
19526
  } else {
19439
- const rowFinder = onCreate();
19527
+ const rowFinder = onEditingCreate();
19440
19528
  setRowCreated({
19441
19529
  rowFinder
19442
19530
  });
@@ -19536,7 +19624,7 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
19536
19624
  enableHorizontalArrowKeyNavigation: table3.meta.editing.isEditing
19537
19625
  };
19538
19626
  const hasValidationErrors = table3.meta.editing.hasErrors(table3.instance, table3.ref);
19539
- const showCreateRowButton = table3.meta.editing.isEnabled && props.enableCreation && props.onCreate;
19627
+ const showCreateRowButton = table3.meta.editing.isEnabled && props.onEditingCreate;
19540
19628
  return /*#__PURE__*/React__default.createElement(Table, null, /*#__PURE__*/React__default.createElement(Table.Toolbar, {
19541
19629
  table: table3
19542
19630
  }, table3.meta.editing.isEnabled ? ( /*#__PURE__*/React__default.createElement(Editing, {
@@ -19553,7 +19641,7 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
19553
19641
  }), showCreateRowButton && ( /*#__PURE__*/React__default.createElement(CreateNewRowButton, {
19554
19642
  table: table3.instance,
19555
19643
  tableMeta: table3.meta,
19556
- onCreate: props.onCreate,
19644
+ onEditingCreate: props.onEditingCreate,
19557
19645
  scrollToIndex: table3.renderer.scrollToIndex
19558
19646
  }))));
19559
19647
  });