@economic/taco 2.17.1 → 2.17.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Table3/components/columns/cell/EditingCell.d.ts +1 -0
- package/dist/components/Table3/components/columns/cell/Indicator.d.ts +5 -0
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +12 -7
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +11 -6
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Indicator.js +15 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Indicator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +6 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js +10 -4
- package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableRowSelectionListener.js +7 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableRowSelectionListener.js.map +1 -1
- package/dist/taco.cjs.development.js +121 -85
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
- package/types.json +3083 -2937
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EditingActions.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/internal/EditingActions.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { CellContext, TableMeta, DisplayColumnDef } from '@tanstack/react-table';\nimport { Spinner } from '../../../../Spinner/Spinner';\nimport { SavingStatusValue, useEditing } from '../../../hooks/features/useEditing';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { Menu } from '../../../../Menu/Menu';\nimport { RowContext } from '../../rows/RowContext';\nimport { DisplayCell } from '../cell/DisplayCell';\nimport { Header as ColumnHeader } from '../header/Header';\nimport { Footer } from '../footer/Footer';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport useTimer from '../../../../../utils/hooks/useTimer';\nimport { Icon } from '../../../../Icon/Icon';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { Dialog } from '../../../../Dialog/Dialog';\nimport { Group } from '../../../../Group/Group';\nimport { Button } from '../../../../Button/Button';\nimport { lastCellIndex } from '../../rows/Row';\nimport { getColumnIndex } from '../../../util/editing';\n\nexport type EditingActionsProps<TType = unknown> = CellContext<TType, unknown> & {\n className?: string;\n isHovered: boolean;\n};\n\nconst savingIndicatorHideDelay = 3000;\n\nexport const COLUMN_ID = '__editing_actions';\n\ntype MemoedCellProps<TType = unknown> = CellContext<TType, unknown> & {\n hasChanges: boolean;\n isActiveRow: boolean;\n editing: ReturnType<typeof useEditing>;\n rowIdentifier?: string;\n};\n\nconst MemoedCell = React.memo(function MemoedCell<TType = unknown>(props: MemoedCellProps<TType>) {\n const { hasChanges, isActiveRow, row, editing, rowIdentifier, table } = props;\n\n const savingStatus = editing.getSavingStatus(row.id);\n const [isSavedIndicatorVisible, setIsSavingIndicatorVisible] = React.useState(false);\n const { texts } = useLocalization();\n const [clearConfirmationOpen, setClearConfirmationOpen] = React.useState(false);\n const columns = table.getAllFlatColumns();\n const column = columns.find(column => column.id === rowIdentifier);\n const rowIdentifierHeader = column?.columnDef.meta?.header;\n const edititngActionsRef = React.useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n const handleSaved = () => {\n setIsSavingIndicatorVisible(false);\n editing.resetSavingStatus(row.id);\n };\n const timer = useTimer(savingIndicatorHideDelay, handleSaved);\n\n React.useEffect(() => {\n if (savingStatus && savingStatus === SavingStatusValue.Saved && !isSavedIndicatorVisible) {\n setIsSavingIndicatorVisible(true);\n timer.start();\n }\n }, [savingStatus]);\n\n React.useEffect(() => {\n tableMeta.shortcutsState.pause(clearConfirmationOpen);\n }, [clearConfirmationOpen]);\n\n let content;\n\n if (savingStatus) {\n if (savingStatus === SavingStatusValue.Saving) {\n content = (\n <Tooltip title={texts.table3.editing.saving.progress}>\n <Spinner delay={0} className=\"!text-grey-700 mr-1 !h-5 !w-5\" />\n </Tooltip>\n );\n } else if (isSavedIndicatorVisible) {\n content = (\n <Tooltip title={texts.table3.editing.saving.complete}>\n <Icon name=\"tick\" className=\"!text-grey-700 mr-1 !h-5 !w-5\" />\n </Tooltip>\n );\n }\n }\n\n if (editing.isEditing && isActiveRow) {\n content = (\n <>\n {content}\n <IconButton\n ref={edititngActionsRef}\n appearance=\"transparent\"\n aria-label={texts.table3.editing.actions.tooltip}\n icon=\"more\"\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n <Menu.Item icon=\"tick\" disabled={!hasChanges} onClick={() => editing.saveChangesIfNeeded()}>\n {texts.table3.editing.actions.save}\n </Menu.Item>\n <Menu.Item icon=\"close\" disabled={!hasChanges} onClick={() => setClearConfirmationOpen(true)}>\n {texts.table3.editing.actions.clear}\n </Menu.Item>\n <Menu.Item icon=\"undo\" onClick={() => editing.toggleEditing(false)}>\n {texts.table3.editing.actions.exit}\n </Menu.Item>\n </Menu.Content>\n </Menu>\n )}\n tabIndex={isActiveRow ? 0 : -1}\n />\n <Dialog\n size=\"xs\"\n open={clearConfirmationOpen}\n onClose={() => {\n setClearConfirmationOpen(false);\n requestAnimationFrame(() => {\n if (edititngActionsRef.current) {\n edititngActionsRef.current.focus();\n // When table looses focus, we need to re-set the last column index\n lastCellIndex.value = getColumnIndex(edititngActionsRef.current);\n }\n });\n }}>\n <Dialog.Content aria-label={texts.table3.editing.clearChangesConfirmationDialog.title}>\n <Dialog.Title>{texts.table3.editing.clearChangesConfirmationDialog.title}</Dialog.Title>\n\n <p>\n {texts.table3.editing.clearChangesConfirmationDialog.description\n .replace(\n '[ROW_IDENTIFIER]',\n rowIdentifier && rowIdentifierHeader ? rowIdentifierHeader : texts.table3.validation.index\n )\n .replace(\n '[ROW_IDENTIFIER_VALUE]',\n rowIdentifier && rowIdentifierHeader ? row.original[rowIdentifier] : row.index\n )}\n </p>\n\n <Dialog.Footer>\n <Group>\n <Dialog.Close>\n <Button tabIndex={0}>{texts.table3.editing.clearChangesConfirmationDialog.cancel}</Button>\n </Dialog.Close>\n <Dialog.Close>\n <Button\n tabIndex={0}\n appearance=\"primary\"\n autoFocus\n onClick={() => editing.resetChange(row.id)}>\n {texts.table3.editing.clearChangesConfirmationDialog.confirm}\n </Button>\n </Dialog.Close>\n </Group>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n </>\n );\n }\n\n const contentClassName = cn('flex items-center justify-end text-right', { '-mb-2 -mt-2': isActiveRow });\n return (\n <DisplayCell {...props} className={cn({ '!sticky': !!content })}>\n {content ? <span className={contentClassName}>{content}</span> : undefined}\n </DisplayCell>\n );\n}) as <TType = unknown>(props: MemoedCellProps<TType>) => JSX.Element;\n\ntype CellProps<TType = unknown> = CellContext<TType, unknown> & {\n rowIdentifier?: string;\n};\n\nfunction Cell<TType = unknown>(props: CellProps<TType>) {\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = props.table.options.meta as TableMeta<TType>;\n const changeset = tableMeta.editing.changes ? Object.keys(tableMeta.editing.changes) : [];\n\n return (\n <MemoedCell\n {...props}\n hasChanges={changeset.indexOf(props.row.id) >= 0}\n isActiveRow={tableMeta.rowActive.rowActiveIndex === rowIndex}\n editing={tableMeta.editing}\n />\n );\n}\n\nexport const EDITING_ACTIONS_WIDTH = 60;\n\nexport function createRowEditingActionsColumn<TType = unknown>(rowIdentifier?: string): DisplayColumnDef<TType, unknown> {\n return {\n id: COLUMN_ID,\n header: ColumnHeader,\n cell: (context: CellContext<TType, unknown>) => <Cell {...context} rowIdentifier={rowIdentifier} />,\n footer: Footer,\n meta: {\n align: 'right',\n className: cn(\n 'items-center print:opacity-0 [[role=\"table\"][data-editing=\"true\"]_&]:group-[[data-current=\"true\"]]/row:sticky right-0 !pl-0 !pr-1',\n '[[role=\"table\"][data-editing=\"true\"]_&]:group-[[data-current=\"true\"]]/row:shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]',\n 'group-[[data-current=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: '',\n headerClassName: 'items-center !p-0',\n },\n // options\n enableResizing: false,\n size: EDITING_ACTIONS_WIDTH,\n minSize: EDITING_ACTIONS_WIDTH,\n };\n}\n"],"names":["savingIndicatorHideDelay","COLUMN_ID","MemoedCell","React","memo","props","hasChanges","isActiveRow","row","editing","rowIdentifier","table","savingStatus","getSavingStatus","id","isSavedIndicatorVisible","setIsSavingIndicatorVisible","useState","texts","useLocalization","clearConfirmationOpen","setClearConfirmationOpen","columns","getAllFlatColumns","column","find","rowIdentifierHeader","_column$columnDef$met","columnDef","meta","header","edititngActionsRef","useRef","tableMeta","options","handleSaved","resetSavingStatus","timer","useTimer","useEffect","SavingStatusValue","Saved","start","shortcutsState","pause","content","Saving","Tooltip","title","table3","saving","progress","Spinner","delay","className","complete","Icon","name","isEditing","IconButton","ref","appearance","actions","tooltip","icon","menu","menuProps","Menu","Content","Item","disabled","onClick","saveChangesIfNeeded","save","clear","toggleEditing","exit","tabIndex","Dialog","size","open","onClose","requestAnimationFrame","current","focus","lastCellIndex","value","getColumnIndex","clearChangesConfirmationDialog","Title","description","replace","validation","index","original","Footer","Group","Close","Button","cancel","autoFocus","resetChange","confirm","contentClassName","cn","DisplayCell","undefined","Cell","rowIndex","useContext","RowContext","changeset","changes","Object","keys","indexOf","rowActive","rowActiveIndex","EDITING_ACTIONS_WIDTH","createRowEditingActionsColumn","ColumnHeader","cell","context","footer","align","enableOrdering","enableSearch","enableTruncate","headerClassName","enableResizing","minSize"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BA,MAAMA,wBAAwB,GAAG,IAAI;MAExBC,SAAS,GAAG;AASzB,MAAMC,UAAU,gBAAGC,cAAK,CAACC,IAAI,CAAC,SAASF,UAAUA,CAAkBG,KAA6B;;EAC5F,MAAM;IAAEC,UAAU;IAAEC,WAAW;IAAEC,GAAG;IAAEC,OAAO;IAAEC,aAAa;IAAEC;GAAO,GAAGN,KAAK;EAE7E,MAAMO,YAAY,GAAGH,OAAO,CAACI,eAAe,CAACL,GAAG,CAACM,EAAE,CAAC;EACpD,MAAM,CAACC,uBAAuB,EAAEC,2BAA2B,CAAC,GAAGb,cAAK,CAACc,QAAQ,CAAC,KAAK,CAAC;EACpF,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAM,CAACC,qBAAqB,EAAEC,wBAAwB,CAAC,GAAGlB,cAAK,CAACc,QAAQ,CAAC,KAAK,CAAC;EAC/E,MAAMK,OAAO,GAAGX,KAAK,CAACY,iBAAiB,EAAE;EACzC,MAAMC,MAAM,GAAGF,OAAO,CAACG,IAAI,CAACD,MAAM,IAAIA,MAAM,CAACV,EAAE,KAAKJ,aAAa,CAAC;EAClE,MAAMgB,mBAAmB,GAAGF,MAAM,aAANA,MAAM,wBAAAG,qBAAA,GAANH,MAAM,CAAEI,SAAS,CAACC,IAAI,cAAAF,qBAAA,uBAAtBA,qBAAA,CAAwBG,MAAM;EAC1D,MAAMC,kBAAkB,GAAG5B,cAAK,CAAC6B,MAAM,CAAwC,IAAI,CAAC;EACpF,MAAMC,SAAS,GAAGtB,KAAK,CAACuB,OAAO,CAACL,IAAwB;EAExD,MAAMM,WAA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ACnBC,cAAc,EAAE,KAAK;MACrBjG,MAAM,EAAE,EAAE;MACVkG,eAAe,EAAE;KACpB;;IAEDC,cAAc,EAAE,KAAK;IACrBlD,IAAI,EAAEuC,qBAAqB;IAC3BY,OAAO,EAAEZ;GACZ;AACL;;;;"}
|
1
|
+
{"version":3,"file":"EditingActions.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/internal/EditingActions.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { CellContext, TableMeta, DisplayColumnDef } from '@tanstack/react-table';\nimport { Spinner } from '../../../../Spinner/Spinner';\nimport { SavingStatusValue, useEditing } from '../../../hooks/features/useEditing';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { Menu } from '../../../../Menu/Menu';\nimport { RowContext } from '../../rows/RowContext';\nimport { DisplayCell } from '../cell/DisplayCell';\nimport { Header as ColumnHeader } from '../header/Header';\nimport { Footer } from '../footer/Footer';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport useTimer from '../../../../../utils/hooks/useTimer';\nimport { Icon } from '../../../../Icon/Icon';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { Dialog } from '../../../../Dialog/Dialog';\nimport { Group } from '../../../../Group/Group';\nimport { Button } from '../../../../Button/Button';\nimport { lastCellIndex } from '../../rows/Row';\nimport { getColumnIndex } from '../../../util/editing';\nimport { getIndicatorCellClassName, isIndicatorVisible } from '../cell/Indicator';\n\nexport type EditingActionsProps<TType = unknown> = CellContext<TType, unknown> & {\n className?: string;\n isHovered: boolean;\n};\n\nconst savingIndicatorHideDelay = 3000;\n\nexport const COLUMN_ID = '__editing_actions';\n\ntype MemoedCellProps<TType = unknown> = CellContext<TType, unknown> & {\n className?: string;\n editing: ReturnType<typeof useEditing>;\n hasChanges: boolean;\n isActiveRow: boolean;\n rowIdentifier?: string;\n};\n\nconst MemoedCell = React.memo(function MemoedCell<TType = unknown>(props: MemoedCellProps<TType>) {\n const { className, editing, hasChanges, isActiveRow, row, rowIdentifier, table } = props;\n\n const savingStatus = editing.getSavingStatus(row.id);\n const [isSavedIndicatorVisible, setIsSavingIndicatorVisible] = React.useState(false);\n const { texts } = useLocalization();\n const [clearConfirmationOpen, setClearConfirmationOpen] = React.useState(false);\n const columns = table.getAllFlatColumns();\n const column = columns.find(column => column.id === rowIdentifier);\n const rowIdentifierHeader = column?.columnDef.meta?.header;\n const edititngActionsRef = React.useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n const handleSaved = () => {\n setIsSavingIndicatorVisible(false);\n editing.resetSavingStatus(row.id);\n };\n const timer = useTimer(savingIndicatorHideDelay, handleSaved);\n\n React.useEffect(() => {\n if (savingStatus && savingStatus === SavingStatusValue.Saved && !isSavedIndicatorVisible) {\n setIsSavingIndicatorVisible(true);\n timer.start();\n }\n }, [savingStatus]);\n\n React.useEffect(() => {\n tableMeta.shortcutsState.pause(clearConfirmationOpen);\n }, [clearConfirmationOpen]);\n\n let content;\n\n if (savingStatus) {\n if (savingStatus === SavingStatusValue.Saving) {\n content = (\n <Tooltip title={texts.table3.editing.saving.progress}>\n <Spinner delay={0} className=\"!text-grey-700 mr-1 !h-5 !w-5\" />\n </Tooltip>\n );\n } else if (isSavedIndicatorVisible) {\n content = (\n <Tooltip title={texts.table3.editing.saving.complete}>\n <Icon name=\"tick\" className=\"!text-grey-700 mr-1 !h-5 !w-5\" />\n </Tooltip>\n );\n }\n }\n\n if (editing.isEditing && isActiveRow) {\n content = (\n <>\n {content}\n <IconButton\n ref={edititngActionsRef}\n appearance=\"transparent\"\n aria-label={texts.table3.editing.actions.tooltip}\n icon=\"more\"\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n <Menu.Item icon=\"tick\" disabled={!hasChanges} onClick={() => editing.saveChangesIfNeeded()}>\n {texts.table3.editing.actions.save}\n </Menu.Item>\n <Menu.Item icon=\"close\" disabled={!hasChanges} onClick={() => setClearConfirmationOpen(true)}>\n {texts.table3.editing.actions.clear}\n </Menu.Item>\n <Menu.Item icon=\"undo\" onClick={() => editing.toggleEditing(false)}>\n {texts.table3.editing.actions.exit}\n </Menu.Item>\n </Menu.Content>\n </Menu>\n )}\n tabIndex={isActiveRow ? 0 : -1}\n />\n <Dialog\n size=\"xs\"\n open={clearConfirmationOpen}\n onClose={() => {\n setClearConfirmationOpen(false);\n requestAnimationFrame(() => {\n if (edititngActionsRef.current) {\n edititngActionsRef.current.focus();\n // When table looses focus, we need to re-set the last column index\n lastCellIndex.value = getColumnIndex(edititngActionsRef.current);\n }\n });\n }}>\n <Dialog.Content aria-label={texts.table3.editing.clearChangesConfirmationDialog.title}>\n <Dialog.Title>{texts.table3.editing.clearChangesConfirmationDialog.title}</Dialog.Title>\n\n <p>\n {texts.table3.editing.clearChangesConfirmationDialog.description\n .replace(\n '[ROW_IDENTIFIER]',\n rowIdentifier && rowIdentifierHeader ? rowIdentifierHeader : texts.table3.validation.index\n )\n .replace(\n '[ROW_IDENTIFIER_VALUE]',\n rowIdentifier && rowIdentifierHeader ? row.original[rowIdentifier] : row.index\n )}\n </p>\n\n <Dialog.Footer>\n <Group>\n <Dialog.Close>\n <Button tabIndex={0}>{texts.table3.editing.clearChangesConfirmationDialog.cancel}</Button>\n </Dialog.Close>\n <Dialog.Close>\n <Button\n tabIndex={0}\n appearance=\"primary\"\n autoFocus\n onClick={() => editing.resetChange(row.id)}>\n {texts.table3.editing.clearChangesConfirmationDialog.confirm}\n </Button>\n </Dialog.Close>\n </Group>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n </>\n );\n }\n\n const contentClassName = cn('flex items-center justify-end text-right', { '-mb-2 -mt-2': isActiveRow });\n return (\n <DisplayCell {...props} className={cn(className, { '!sticky': !!content })}>\n {content ? <span className={contentClassName}>{content}</span> : undefined}\n </DisplayCell>\n );\n}) as <TType = unknown>(props: MemoedCellProps<TType>) => JSX.Element;\n\ntype CellProps<TType = unknown> = CellContext<TType, unknown> & {\n rowIdentifier?: string;\n};\n\nfunction Cell<TType = unknown>(props: CellProps<TType>) {\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = props.table.options.meta as TableMeta<TType>;\n const changeset = tableMeta.editing.changes ? Object.keys(tableMeta.editing.changes) : [];\n const allVisibleColumns = props.table.getVisibleLeafColumns();\n const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;\n const className = isIndicatorVisible(rowIndex, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.rowMoveReason)\n ? getIndicatorCellClassName(props.index, lastColumnIndex)\n : undefined;\n\n return (\n <MemoedCell\n {...props}\n className={className}\n editing={tableMeta.editing}\n hasChanges={changeset.indexOf(props.row.id) >= 0}\n isActiveRow={tableMeta.rowActive.rowActiveIndex === rowIndex}\n />\n );\n}\n\nexport const EDITING_ACTIONS_WIDTH = 60;\n\nexport function createRowEditingActionsColumn<TType = unknown>(rowIdentifier?: string): DisplayColumnDef<TType, unknown> {\n return {\n id: COLUMN_ID,\n header: ColumnHeader,\n cell: (context: CellContext<TType, unknown>) => <Cell {...context} rowIdentifier={rowIdentifier} />,\n footer: Footer,\n meta: {\n align: 'right',\n className: cn(\n 'items-center print:opacity-0 [[role=\"table\"][data-editing=\"true\"]_&]:group-[[data-current=\"true\"]]/row:sticky right-0 !pl-0 !pr-1',\n '[[role=\"table\"][data-editing=\"true\"]_&]:group-[[data-current=\"true\"]]/row:shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]',\n 'group-[[data-current=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: '',\n headerClassName: 'items-center !p-0',\n },\n // options\n enableResizing: false,\n size: EDITING_ACTIONS_WIDTH,\n minSize: EDITING_ACTIONS_WIDTH,\n };\n}\n"],"names":["savingIndicatorHideDelay","COLUMN_ID","MemoedCell","React","memo","props","className","editing","hasChanges","isActiveRow","row","rowIdentifier","table","savingStatus","getSavingStatus","id","isSavedIndicatorVisible","setIsSavingIndicatorVisible","useState","texts","useLocalization","clearConfirmationOpen","setClearConfirmationOpen","columns","getAllFlatColumns","column","find","rowIdentifierHeader","_column$columnDef$met","columnDef","meta","header","edititngActionsRef","useRef","tableMeta","options","handleSaved","resetSavingStatus","timer","useTimer","useEffect","SavingStatusValue","Saved","start","shortcutsState","pause","content","Saving","Tooltip","title","table3","saving","progress","Spinner","delay","complete","Icon","name","isEditing","IconButton","ref","appearance","actions","tooltip","icon","menu","menuProps","Menu","Content","Item","disabled","onClick","saveChangesIfNeeded","save","clear","toggleEditing","exit","tabIndex","Dialog","size","open","onClose","requestAnimationFrame","current","focus","lastCellIndex","value","getColumnIndex","clearChangesConfirmationDialog","Title","description","replace","validation","index","original","Footer","Group","Close","Button","cancel","autoFocus","resetChange","confirm","contentClassName","cn","DisplayCell","undefined","Cell","rowIndex","useContext","RowContext","changeset","changes","Object","keys","allVisibleColumns","getVisibleLeafColumns","lastColumnIndex","length","isIndicatorVisible","rowActive","rowActiveIndex","rowMoveReason","getIndicatorCellClassName","indexOf","EDITING_ACTIONS_WIDTH","createRowEditingActionsColumn","ColumnHeader","cell","context","footer","align","enableOrdering","enableSearch","enableTruncate","headerClassName","enableResizing","minSize"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,MAAMA,wBAAwB,GAAG,IAAI;MAExBC,SAAS,GAAG;AAUzB,MAAMC,UAAU,gBAAGC,cAAK,CAACC,IAAI,CAAC,SAASF,UAAUA,CAAkBG,KAA6B;;EAC5F,MAAM;IAAEC,SAAS;IAAEC,OAAO;IAAEC,UAAU;IAAEC,WAAW;IAAEC,GAAG;IAAEC,aAAa;IAAEC;GAAO,GAAGP,KAAK;EAExF,MAAMQ,YAAY,GAAGN,OAAO,CAACO,eAAe,CAACJ,GAAG,CAACK,EAAE,CAAC;EACpD,MAAM,CAACC,uBAAuB,EAAEC,2BAA2B,CA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EAAEZ;GACZ;AACL;;;;"}
|
package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js
CHANGED
@@ -62,8 +62,8 @@ import '../../../../Table/components/PaginatedTable.js';
|
|
62
62
|
import '../../../../Table/components/WindowedTable.js';
|
63
63
|
import '../../../../Table/util/rowIndexPath.js';
|
64
64
|
import '../../../../Table/hooks/useRowCreation.js';
|
65
|
-
import '../../../../../hooks/useLazyEffect.js';
|
66
65
|
import ReactDOM from 'react-dom';
|
66
|
+
import '../../../../../hooks/useLazyEffect.js';
|
67
67
|
import '../../../../Textarea/Textarea.js';
|
68
68
|
import '../../../../../hooks/useMatchMedia.js';
|
69
69
|
import '../../../../../hooks/useIsLargeScreen.js';
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import { useLazyEffect } from '../../../../hooks/useLazyEffect.js';
|
2
2
|
|
3
3
|
function useTableRowSelectionListener(table, onRowSelect) {
|
4
|
-
const
|
4
|
+
const rowSelection = table.getState().rowSelection;
|
5
5
|
useLazyEffect(() => {
|
6
|
+
const selectedRows = table.getSelectedRowModel().rows;
|
6
7
|
if (table.options.enableRowSelection && typeof onRowSelect === 'function') {
|
7
8
|
if (table.options.enableMultiRowSelection) {
|
8
9
|
onRowSelect(selectedRows.map(row => row.original));
|
@@ -11,7 +12,11 @@ function useTableRowSelectionListener(table, onRowSelect) {
|
|
11
12
|
onRowSelect((_ref = [(_selectedRows$ = selectedRows[0]) === null || _selectedRows$ === void 0 ? void 0 : _selectedRows$.original]) !== null && _ref !== void 0 ? _ref : []);
|
12
13
|
}
|
13
14
|
}
|
14
|
-
|
15
|
+
// It is important to stringify either rowSelection state or selectedRows, because we don't
|
16
|
+
// know if the array or object that is returned by react-table has the same reference or not.
|
17
|
+
// rowSelection state is used here because it will be more expensive to strigify selectedRows
|
18
|
+
// than rowSelection state.
|
19
|
+
}, [table.options.enableRowSelection, table.options.enableMultiRowSelection, JSON.stringify(rowSelection)]);
|
15
20
|
}
|
16
21
|
|
17
22
|
export { useTableRowSelectionListener };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableRowSelectionListener.js","sources":["../../../../../../../../../src/primitives/Table/useTable/listeners/useTableRowSelectionListener.ts"],"sourcesContent":["import { Table as ReactTable } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { TableRowSelectHandler } from '../../types';\n\nexport function useTableRowSelectionListener<TType = unknown>(\n table: ReactTable<TType>,\n onRowSelect?: TableRowSelectHandler<TType>\n) {\n const
|
1
|
+
{"version":3,"file":"useTableRowSelectionListener.js","sources":["../../../../../../../../../src/primitives/Table/useTable/listeners/useTableRowSelectionListener.ts"],"sourcesContent":["import { Table as ReactTable } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { TableRowSelectHandler } from '../../types';\n\nexport function useTableRowSelectionListener<TType = unknown>(\n table: ReactTable<TType>,\n onRowSelect?: TableRowSelectHandler<TType>\n) {\n const rowSelection = table.getState().rowSelection;\n\n useLazyEffect(() => {\n const selectedRows = table.getSelectedRowModel().rows;\n\n if (table.options.enableRowSelection && typeof onRowSelect === 'function') {\n if (table.options.enableMultiRowSelection) {\n onRowSelect(selectedRows.map(row => row.original));\n } else {\n onRowSelect([selectedRows[0]?.original] ?? []);\n }\n }\n // It is important to stringify either rowSelection state or selectedRows, because we don't\n // know if the array or object that is returned by react-table has the same reference or not.\n // rowSelection state is used here because it will be more expensive to strigify selectedRows\n // than rowSelection state.\n }, [table.options.enableRowSelection, table.options.enableMultiRowSelection, JSON.stringify(rowSelection)]);\n}\n"],"names":["useTableRowSelectionListener","table","onRowSelect","rowSelection","getState","useLazyEffect","selectedRows","getSelectedRowModel","rows","options","enableRowSelection","enableMultiRowSelection","map","row","original","_ref","_selectedRows$","JSON","stringify"],"mappings":";;SAIgBA,4BAA4BA,CACxCC,KAAwB,EACxBC,WAA0C;EAE1C,MAAMC,YAAY,GAAGF,KAAK,CAACG,QAAQ,EAAE,CAACD,YAAY;EAElDE,aAAa,CAAC;IACV,MAAMC,YAAY,GAAGL,KAAK,CAACM,mBAAmB,EAAE,CAACC,IAAI;IAErD,IAAIP,KAAK,CAACQ,OAAO,CAACC,kBAAkB,IAAI,OAAOR,WAAW,KAAK,UAAU,EAAE;MACvE,IAAID,KAAK,CAACQ,OAAO,CAACE,uBAAuB,EAAE;QACvCT,WAAW,CAACI,YAAY,CAACM,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACC,QAAQ,CAAC,CAAC;OACrD,MAAM;QAAA,IAAAC,IAAA,EAAAC,cAAA;QACHd,WAAW,EAAAa,IAAA,GAAC,EAAAC,cAAA,GAACV,YAAY,CAAC,CAAC,CAAC,cAAAU,cAAA,uBAAfA,cAAA,CAAiBF,QAAQ,CAAC,cAAAC,IAAA,cAAAA,IAAA,GAAI,EAAE,CAAC;;;;;;;GAOzD,EAAE,CAACd,KAAK,CAACQ,OAAO,CAACC,kBAAkB,EAAET,KAAK,CAACQ,OAAO,CAACE,uBAAuB,EAAEM,IAAI,CAACC,SAAS,CAACf,YAAY,CAAC,CAAC,CAAC;AAC/G;;;;"}
|
@@ -12897,7 +12897,7 @@ function DisplayCell(props) {
|
|
12897
12897
|
index,
|
12898
12898
|
tableRef
|
12899
12899
|
};
|
12900
|
-
}, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex]);
|
12900
|
+
}, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex, className]);
|
12901
12901
|
return /*#__PURE__*/React__default.createElement(MemoedDisplayCell, Object.assign({}, memoedProps, {
|
12902
12902
|
highlighted: highlighted,
|
12903
12903
|
highlightedAsCurrent: highlightedAsCurrent
|
@@ -13010,6 +13010,85 @@ function FontSize$1(props) {
|
|
13010
13010
|
}, texts.table3.fontSize.sizes.large)));
|
13011
13011
|
}
|
13012
13012
|
|
13013
|
+
var IndicatorReason;
|
13014
|
+
(function (IndicatorReason) {
|
13015
|
+
IndicatorReason["SEARCH"] = "SEARCH";
|
13016
|
+
IndicatorReason["SORTING"] = "SORTING";
|
13017
|
+
IndicatorReason["FILTER"] = "FILTER";
|
13018
|
+
})(IndicatorReason || (IndicatorReason = {}));
|
13019
|
+
const useIndicatorText = reason => {
|
13020
|
+
let title = '';
|
13021
|
+
let description = '';
|
13022
|
+
const {
|
13023
|
+
texts
|
13024
|
+
} = useLocalization();
|
13025
|
+
switch (reason) {
|
13026
|
+
case IndicatorReason.FILTER:
|
13027
|
+
title = texts.table3.editing.rowIndicator.rowWillBeHidden;
|
13028
|
+
description = texts.table3.editing.rowIndicator.rowWillMoveReasonFilter;
|
13029
|
+
break;
|
13030
|
+
case IndicatorReason.SEARCH:
|
13031
|
+
title = texts.table3.editing.rowIndicator.rowWillBeHidden;
|
13032
|
+
description = texts.table3.editing.rowIndicator.rowWillMoveReasonSearch;
|
13033
|
+
break;
|
13034
|
+
case IndicatorReason.SORTING:
|
13035
|
+
title = texts.table3.editing.rowIndicator.rowWillMove;
|
13036
|
+
description = texts.table3.editing.rowIndicator.rowWillMoveReasonSorting;
|
13037
|
+
break;
|
13038
|
+
}
|
13039
|
+
return {
|
13040
|
+
title,
|
13041
|
+
description
|
13042
|
+
};
|
13043
|
+
};
|
13044
|
+
const Indicator = ({
|
13045
|
+
reason,
|
13046
|
+
columnName,
|
13047
|
+
mountNode,
|
13048
|
+
validationErrors
|
13049
|
+
}) => {
|
13050
|
+
const container = React__default.useMemo(() => {
|
13051
|
+
const element = document.createElement('div');
|
13052
|
+
element.className += 'rounded-b-md items-center wcag-blue-500 absolute left-0 top-full ml-1 whitespace-nowrap px-1 py-0.5 text-xs font-bold shadow-sm';
|
13053
|
+
return element;
|
13054
|
+
}, []);
|
13055
|
+
const indicatorText = useIndicatorText(reason);
|
13056
|
+
const hasValidationErrorsInRow = !!validationErrors;
|
13057
|
+
React__default.useEffect(() => {
|
13058
|
+
// mountNode could be null when rows are filtered
|
13059
|
+
// Pinned columns has z-20 class assigned, which overlaps indicator element, need to add z-21 to overlap pinned columns.
|
13060
|
+
mountNode === null || mountNode === void 0 ? void 0 : mountNode.classList.add('!z-[21]', 'relative');
|
13061
|
+
mountNode === null || mountNode === void 0 ? void 0 : mountNode.appendChild(container);
|
13062
|
+
return () => {
|
13063
|
+
mountNode === null || mountNode === void 0 ? void 0 : mountNode.classList.remove('!z-[21]', 'relative');
|
13064
|
+
mountNode === null || mountNode === void 0 ? void 0 : mountNode.removeChild(container);
|
13065
|
+
};
|
13066
|
+
}, [hasValidationErrorsInRow, mountNode]);
|
13067
|
+
// Using react portal inside a react tree component is an unorthodox way, but in order to avoid much code refactoring
|
13068
|
+
// and being able to use Taco Tooltip component in side the visual indicator, portal is used.
|
13069
|
+
return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React__default.createElement(Tooltip, {
|
13070
|
+
title: indicatorText.description.replace('[COLUMN]', columnName)
|
13071
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
13072
|
+
className: "flex gap-1 hover:cursor-pointer"
|
13073
|
+
}, /*#__PURE__*/React__default.createElement(Icon, {
|
13074
|
+
name: "info",
|
13075
|
+
className: "!h-4 !w-4 rounded-full bg-white !p-0 text-blue-500"
|
13076
|
+
}), indicatorText.title)), container);
|
13077
|
+
};
|
13078
|
+
/**
|
13079
|
+
* Generates class names needed to highlight row cells, used when row has a move indicator
|
13080
|
+
*/
|
13081
|
+
function getIndicatorCellClassName(columnIndex, lastColumnIndex) {
|
13082
|
+
return cn('!border-blue !border-y-2 border-x-0', {
|
13083
|
+
'border-l-2 rounded-l': columnIndex === 0,
|
13084
|
+
'border-r-2 rounded-r': columnIndex === lastColumnIndex
|
13085
|
+
});
|
13086
|
+
}
|
13087
|
+
function isIndicatorVisible(rowIndex, rowActiveIndex, rowMoveReason) {
|
13088
|
+
const isActiveRow = rowActiveIndex === rowIndex;
|
13089
|
+
return isActiveRow && rowMoveReason;
|
13090
|
+
}
|
13091
|
+
|
13013
13092
|
const COLUMN_ID = '__actions';
|
13014
13093
|
const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
|
13015
13094
|
const {
|
@@ -13054,7 +13133,7 @@ const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
|
|
13054
13133
|
// Adjust negative margin on row actions cell to ensure that the cell aligns vertically.
|
13055
13134
|
'-mt-2': fontSize === FONT_SIZE.small,
|
13056
13135
|
'-mt-1.5': fontSize !== FONT_SIZE.small
|
13057
|
-
});
|
13136
|
+
}, props.className);
|
13058
13137
|
content = /*#__PURE__*/React__default.createElement("span", {
|
13059
13138
|
className: className,
|
13060
13139
|
ref: ref
|
@@ -13089,9 +13168,13 @@ function Cell(context) {
|
|
13089
13168
|
rowIndex
|
13090
13169
|
} = React__default.useContext(RowContext);
|
13091
13170
|
const tableMeta = context.table.options.meta;
|
13171
|
+
const allVisibleColumns = context.table.getVisibleLeafColumns();
|
13172
|
+
const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;
|
13173
|
+
const className = isIndicatorVisible(rowIndex, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.rowMoveReason) ? getIndicatorCellClassName(context.index, lastColumnIndex) : undefined;
|
13092
13174
|
return /*#__PURE__*/React__default.createElement(MemoedCell, Object.assign({}, context, {
|
13093
13175
|
actions: tableMeta.rowActions.actionsForRow,
|
13094
13176
|
actionsLength: tableMeta.rowActions.actionsForRowLength,
|
13177
|
+
className: className,
|
13095
13178
|
fontSize: tableMeta.fontSize.size,
|
13096
13179
|
isActiveRow: tableMeta.rowActive.rowActiveIndex === rowIndex,
|
13097
13180
|
isEditing: tableMeta.editing.isEditing,
|
@@ -13526,8 +13609,9 @@ function useLazyEffect(effect, deps) {
|
|
13526
13609
|
}
|
13527
13610
|
|
13528
13611
|
function useTableRowSelectionListener(table, onRowSelect) {
|
13529
|
-
const
|
13612
|
+
const rowSelection = table.getState().rowSelection;
|
13530
13613
|
useLazyEffect(() => {
|
13614
|
+
const selectedRows = table.getSelectedRowModel().rows;
|
13531
13615
|
if (table.options.enableRowSelection && typeof onRowSelect === 'function') {
|
13532
13616
|
if (table.options.enableMultiRowSelection) {
|
13533
13617
|
onRowSelect(selectedRows.map(row => row.original));
|
@@ -13536,7 +13620,11 @@ function useTableRowSelectionListener(table, onRowSelect) {
|
|
13536
13620
|
onRowSelect((_ref = [(_selectedRows$ = selectedRows[0]) === null || _selectedRows$ === void 0 ? void 0 : _selectedRows$.original]) !== null && _ref !== void 0 ? _ref : []);
|
13537
13621
|
}
|
13538
13622
|
}
|
13539
|
-
|
13623
|
+
// It is important to stringify either rowSelection state or selectedRows, because we don't
|
13624
|
+
// know if the array or object that is returned by react-table has the same reference or not.
|
13625
|
+
// rowSelection state is used here because it will be more expensive to strigify selectedRows
|
13626
|
+
// than rowSelection state.
|
13627
|
+
}, [table.options.enableRowSelection, table.options.enableMultiRowSelection, JSON.stringify(rowSelection)]);
|
13540
13628
|
}
|
13541
13629
|
|
13542
13630
|
function useRowDrag(isEnabled) {
|
@@ -13907,72 +13995,6 @@ function useRowDrop(isEnabled, handler) {
|
|
13907
13995
|
};
|
13908
13996
|
}
|
13909
13997
|
|
13910
|
-
var IndicatorReason;
|
13911
|
-
(function (IndicatorReason) {
|
13912
|
-
IndicatorReason["SEARCH"] = "SEARCH";
|
13913
|
-
IndicatorReason["SORTING"] = "SORTING";
|
13914
|
-
IndicatorReason["FILTER"] = "FILTER";
|
13915
|
-
})(IndicatorReason || (IndicatorReason = {}));
|
13916
|
-
const useIndicatorText = reason => {
|
13917
|
-
let title = '';
|
13918
|
-
let description = '';
|
13919
|
-
const {
|
13920
|
-
texts
|
13921
|
-
} = useLocalization();
|
13922
|
-
switch (reason) {
|
13923
|
-
case IndicatorReason.FILTER:
|
13924
|
-
title = texts.table3.editing.rowIndicator.rowWillBeHidden;
|
13925
|
-
description = texts.table3.editing.rowIndicator.rowWillMoveReasonFilter;
|
13926
|
-
break;
|
13927
|
-
case IndicatorReason.SEARCH:
|
13928
|
-
title = texts.table3.editing.rowIndicator.rowWillBeHidden;
|
13929
|
-
description = texts.table3.editing.rowIndicator.rowWillMoveReasonSearch;
|
13930
|
-
break;
|
13931
|
-
case IndicatorReason.SORTING:
|
13932
|
-
title = texts.table3.editing.rowIndicator.rowWillMove;
|
13933
|
-
description = texts.table3.editing.rowIndicator.rowWillMoveReasonSorting;
|
13934
|
-
break;
|
13935
|
-
}
|
13936
|
-
return {
|
13937
|
-
title,
|
13938
|
-
description
|
13939
|
-
};
|
13940
|
-
};
|
13941
|
-
const Indicator = ({
|
13942
|
-
reason,
|
13943
|
-
columnName,
|
13944
|
-
mountNode,
|
13945
|
-
validationErrors
|
13946
|
-
}) => {
|
13947
|
-
const container = React__default.useMemo(() => {
|
13948
|
-
const element = document.createElement('div');
|
13949
|
-
element.className += 'rounded-b-md items-center wcag-blue-500 absolute left-0 top-full ml-1 whitespace-nowrap px-1 py-0.5 text-xs font-bold shadow-sm';
|
13950
|
-
return element;
|
13951
|
-
}, []);
|
13952
|
-
const indicatorText = useIndicatorText(reason);
|
13953
|
-
const hasValidationErrorsInRow = !!validationErrors;
|
13954
|
-
React__default.useEffect(() => {
|
13955
|
-
// mountNode could be null when rows are filtered
|
13956
|
-
// Pinned columns has z-20 class assigned, which overlaps indicator element, need to add z-21 to overlap pinned columns.
|
13957
|
-
mountNode === null || mountNode === void 0 ? void 0 : mountNode.classList.add('!z-[21]', 'relative');
|
13958
|
-
mountNode === null || mountNode === void 0 ? void 0 : mountNode.appendChild(container);
|
13959
|
-
return () => {
|
13960
|
-
mountNode === null || mountNode === void 0 ? void 0 : mountNode.classList.remove('!z-[21]', 'relative');
|
13961
|
-
mountNode === null || mountNode === void 0 ? void 0 : mountNode.removeChild(container);
|
13962
|
-
};
|
13963
|
-
}, [hasValidationErrorsInRow, mountNode]);
|
13964
|
-
// Using react portal inside a react tree component is an unorthodox way, but in order to avoid much code refactoring
|
13965
|
-
// and being able to use Taco Tooltip component in side the visual indicator, portal is used.
|
13966
|
-
return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React__default.createElement(Tooltip, {
|
13967
|
-
title: indicatorText.description.replace('[COLUMN]', columnName)
|
13968
|
-
}, /*#__PURE__*/React__default.createElement("span", {
|
13969
|
-
className: "flex gap-1 hover:cursor-pointer"
|
13970
|
-
}, /*#__PURE__*/React__default.createElement(Icon, {
|
13971
|
-
name: "info",
|
13972
|
-
className: "!h-4 !w-4 rounded-full bg-white !p-0 text-blue-500"
|
13973
|
-
}), indicatorText.title)), container);
|
13974
|
-
};
|
13975
|
-
|
13976
13998
|
const focussableNodeNames = ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'DETAILS'];
|
13977
13999
|
const focusableSelector = /*#__PURE__*/focussableNodeNames.join(', ');
|
13978
14000
|
const hasChanged = (value, newValue) => {
|
@@ -14627,10 +14649,11 @@ const COLUMN_ID$1 = '__editing_actions';
|
|
14627
14649
|
const MemoedCell$1 = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
|
14628
14650
|
var _column$columnDef$met;
|
14629
14651
|
const {
|
14652
|
+
className,
|
14653
|
+
editing,
|
14630
14654
|
hasChanges,
|
14631
14655
|
isActiveRow,
|
14632
14656
|
row,
|
14633
|
-
editing,
|
14634
14657
|
rowIdentifier,
|
14635
14658
|
table
|
14636
14659
|
} = props;
|
@@ -14724,7 +14747,7 @@ const MemoedCell$1 = /*#__PURE__*/React__default.memo(function MemoedCell(props)
|
|
14724
14747
|
'-mb-2 -mt-2': isActiveRow
|
14725
14748
|
});
|
14726
14749
|
return /*#__PURE__*/React__default.createElement(DisplayCell, Object.assign({}, props, {
|
14727
|
-
className: cn({
|
14750
|
+
className: cn(className, {
|
14728
14751
|
'!sticky': !!content
|
14729
14752
|
})
|
14730
14753
|
}), content ? /*#__PURE__*/React__default.createElement("span", {
|
@@ -14737,10 +14760,14 @@ function Cell$1(props) {
|
|
14737
14760
|
} = React__default.useContext(RowContext);
|
14738
14761
|
const tableMeta = props.table.options.meta;
|
14739
14762
|
const changeset = tableMeta.editing.changes ? Object.keys(tableMeta.editing.changes) : [];
|
14763
|
+
const allVisibleColumns = props.table.getVisibleLeafColumns();
|
14764
|
+
const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;
|
14765
|
+
const className = isIndicatorVisible(rowIndex, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.rowMoveReason) ? getIndicatorCellClassName(props.index, lastColumnIndex) : undefined;
|
14740
14766
|
return /*#__PURE__*/React__default.createElement(MemoedCell$1, Object.assign({}, props, {
|
14767
|
+
className: className,
|
14768
|
+
editing: tableMeta.editing,
|
14741
14769
|
hasChanges: changeset.indexOf(props.row.id) >= 0,
|
14742
|
-
isActiveRow: tableMeta.rowActive.rowActiveIndex === rowIndex
|
14743
|
-
editing: tableMeta.editing
|
14770
|
+
isActiveRow: tableMeta.rowActive.rowActiveIndex === rowIndex
|
14744
14771
|
}));
|
14745
14772
|
}
|
14746
14773
|
const EDITING_ACTIONS_WIDTH = 60;
|
@@ -15197,7 +15224,10 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
15197
15224
|
React__default.useEffect(() => {
|
15198
15225
|
// To avoid reseting move reason on another row hover,
|
15199
15226
|
// we need to check for changes only if value got changed in the current row.
|
15200
|
-
if (!isActiveRow
|
15227
|
+
if (!isActiveRow) {
|
15228
|
+
return;
|
15229
|
+
}
|
15230
|
+
if (error) {
|
15201
15231
|
if (tableMeta.editing.rowMoveReason) {
|
15202
15232
|
removeMoveReason();
|
15203
15233
|
}
|
@@ -15207,9 +15237,11 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
15207
15237
|
const moveReason = getRowMoveReason(table, rowIndex,
|
15208
15238
|
// cannot use row.index, as this is not kept in sync once a column is sorted.
|
15209
15239
|
row.original, cell, value, tableMeta.search.excludeUnmatchedResults);
|
15210
|
-
|
15211
|
-
|
15212
|
-
|
15240
|
+
if (moveReason) {
|
15241
|
+
tableMeta.editing.setRowMoveReason({
|
15242
|
+
[cell.column.id]: moveReason
|
15243
|
+
});
|
15244
|
+
}
|
15213
15245
|
} else {
|
15214
15246
|
removeMoveReason();
|
15215
15247
|
}
|
@@ -15219,7 +15251,7 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
15219
15251
|
const className = cn('py-[calc(var(--table3-cell-padding-y)_-_0.06rem)]', {
|
15220
15252
|
// Textarea control is positioned absolute, when column is in enableTruncate mode, so the cell need to be positioned relative
|
15221
15253
|
relative: controlRenderer === 'textarea' && columnMeta.enableTruncate
|
15222
|
-
}, typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className);
|
15254
|
+
}, props.className, typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className);
|
15223
15255
|
const fieldClassName = cn('!min-h-0 w-full !pb-0', {
|
15224
15256
|
'!pb-3': !!error
|
15225
15257
|
});
|
@@ -15302,7 +15334,8 @@ function Cell$2(props) {
|
|
15302
15334
|
} = props;
|
15303
15335
|
const {
|
15304
15336
|
isHovered: isHoveredRow,
|
15305
|
-
hasError
|
15337
|
+
hasError,
|
15338
|
+
rowIndex
|
15306
15339
|
} = useRowContext();
|
15307
15340
|
const rows = table.getRowModel().rows;
|
15308
15341
|
const tableMeta = table.options.meta;
|
@@ -15312,15 +15345,15 @@ function Cell$2(props) {
|
|
15312
15345
|
const rowActiveIndex = tableMeta.rowActive.rowActiveIndex;
|
15313
15346
|
const isActiveRow = rowActiveIndex !== undefined && ((_rows$rowActiveIndex = rows[rowActiveIndex]) === null || _rows$rowActiveIndex === void 0 ? void 0 : _rows$rowActiveIndex.id) === row.id;
|
15314
15347
|
let value = getValue();
|
15348
|
+
const allVisibleColumns = table.getVisibleLeafColumns();
|
15349
|
+
const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;
|
15350
|
+
const className = isIndicatorVisible(rowIndex, rowActiveIndex, tableMeta.editing.rowMoveReason) ? getIndicatorCellClassName(index, lastColumnIndex) : undefined;
|
15315
15351
|
// When row has changes we always need to show the editing state value, end revert it to original value only when row got saved successfully.
|
15316
15352
|
// Otherwise it might confuse user because it will look like display value is getting reverted everytime user leaves the row.
|
15317
15353
|
if (tableMeta.editing.isEditing) {
|
15318
15354
|
const editingValue = tableMeta.editing.getCellValue(cell);
|
15319
15355
|
value = editingValue !== null && editingValue !== void 0 ? editingValue : value;
|
15320
15356
|
}
|
15321
|
-
const {
|
15322
|
-
rowIndex
|
15323
|
-
} = React__default.useContext(RowContext);
|
15324
15357
|
const memoedHighlight = React__default.useMemo(() => {
|
15325
15358
|
var _tableMeta$search$que;
|
15326
15359
|
if (!tableMeta.search.isHighlightingEnabled || !columnMeta.enableSearch) {
|
@@ -15348,10 +15381,13 @@ function Cell$2(props) {
|
|
15348
15381
|
if (tableMeta.editing.isEditing && columnMeta.control && (isActiveRow || isHoveredRow && !tableMeta.rowActive.isHoverStatePaused ||
|
15349
15382
|
// When cell has error, we renderimg it in edit mode (UX reqirement)
|
15350
15383
|
isColumnError)) {
|
15351
|
-
return /*#__PURE__*/React__default.createElement(EditingCell, Object.assign({}, props, highlightProps
|
15384
|
+
return /*#__PURE__*/React__default.createElement(EditingCell, Object.assign({}, props, highlightProps, {
|
15385
|
+
className: className
|
15386
|
+
}));
|
15352
15387
|
}
|
15353
15388
|
return /*#__PURE__*/React__default.createElement(DisplayCell, Object.assign({}, props, highlightProps, {
|
15354
|
-
value: value
|
15389
|
+
value: value,
|
15390
|
+
className: className
|
15355
15391
|
}));
|
15356
15392
|
}
|
15357
15393
|
|