@economic/taco 2.45.0-alpha.1 → 2.45.0-alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. package/dist/components/Popover/Popover.d.ts +1 -1
  2. package/dist/components/Provider/Localization.d.ts +2 -0
  3. package/dist/components/Report/Report.d.ts +1 -1
  4. package/dist/components/Select2/components/Search.d.ts +0 -6
  5. package/dist/components/Table3/Table3.d.ts +2 -14
  6. package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +3 -4
  7. package/dist/components/Table3/components/Editing/DiscardChangesConfirmationDialog.d.ts +7 -0
  8. package/dist/components/Table3/components/Row/Editing/CreateNewRow.d.ts +14 -0
  9. package/dist/components/Table3/components/Row/Editing/TemporaryRow.d.ts +11 -0
  10. package/dist/components/Table3/features/useEditingState.d.ts +29 -0
  11. package/dist/components/Table3/features/useTableEditing.d.ts +26 -36
  12. package/dist/components/Table3/listeners/useTableEditingListener.d.ts +1 -1
  13. package/dist/components/Table3/types.d.ts +24 -8
  14. package/dist/components/Table3/useTable3.d.ts +6 -0
  15. package/dist/components/Table3/util/editing.d.ts +7 -1
  16. package/dist/esm/index.css +35 -4
  17. package/dist/esm/packages/taco/src/components/Button/util.js +1 -1
  18. package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
  19. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js +2 -2
  20. package/dist/esm/packages/taco/src/components/ModeSwitch/ModeSwitch.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Popover/Popover.js.map +1 -1
  22. package/dist/esm/packages/taco/src/components/Provider/Localization.js +5 -3
  23. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  24. package/dist/esm/packages/taco/src/components/Select2/Select2.js +21 -40
  25. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  26. package/dist/esm/packages/taco/src/components/Select2/components/Search.js +2 -12
  27. package/dist/esm/packages/taco/src/components/Select2/components/Search.js.map +1 -1
  28. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +19 -1
  29. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  30. package/dist/esm/packages/taco/src/components/Switch/Switch.js +1 -1
  31. package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
  32. package/dist/esm/packages/taco/src/components/Table3/Table3.js +14 -6
  33. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  34. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js +1 -2
  35. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js.map +1 -1
  36. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +33 -11
  37. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  38. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +7 -39
  39. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
  40. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +17 -12
  41. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
  42. package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js +34 -0
  43. package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js.map +1 -0
  44. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +104 -0
  45. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -0
  46. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js +2 -14
  47. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js.map +1 -1
  48. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +96 -0
  49. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -0
  50. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js +39 -6
  51. package/dist/esm/packages/taco/src/components/Table3/components/Row/Row.js.map +1 -1
  52. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js +4 -17
  53. package/dist/esm/packages/taco/src/components/Table3/components/Toolbar/Editing/Editing.js.map +1 -1
  54. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +519 -0
  55. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -0
  56. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +29 -406
  57. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  58. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +44 -33
  59. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
  60. package/dist/esm/packages/taco/src/components/Table3/useTable3.js +44 -14
  61. package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
  62. package/dist/esm/packages/taco/src/components/Table3/util/editing.js +11 -23
  63. package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
  64. package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js +18 -0
  65. package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js.map +1 -1
  66. package/dist/esm/packages/taco/src/primitives/Listbox2/components/Option.js +0 -5
  67. package/dist/esm/packages/taco/src/primitives/Listbox2/components/Option.js.map +1 -1
  68. package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js +1 -0
  69. package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js.map +1 -1
  70. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +6 -4
  71. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  72. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +30 -17
  73. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
  74. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +10 -7
  75. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
  76. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
  77. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +6 -3
  78. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
  79. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +4 -2
  80. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js.map +1 -1
  81. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js +2 -1
  82. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js.map +1 -1
  83. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js +8 -1
  84. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js.map +1 -1
  85. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +29 -7
  86. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  87. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js +2 -2
  88. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
  89. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  90. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowSelection.js +2 -1
  91. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowSelection.js.map +1 -1
  92. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +1 -1
  93. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  94. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +11 -0
  95. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  96. package/dist/esm/packages/taco/src/utils/dom.js +20 -10
  97. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  98. package/dist/index.css +35 -4
  99. package/dist/primitives/Collection/components/Root.d.ts +2 -0
  100. package/dist/primitives/Table/Core/components/Body/util.d.ts +4 -4
  101. package/dist/primitives/Table/Core/components/Columns/Internal/Actions.d.ts +3 -1
  102. package/dist/primitives/Table/Core/components/Footer/Footer.d.ts +1 -1
  103. package/dist/primitives/Table/Core/components/Row/RowContext.d.ts +1 -0
  104. package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +2 -2
  105. package/dist/primitives/Table/Core/features/useTableStyle.d.ts +3 -3
  106. package/dist/primitives/Table/Core/types.d.ts +4 -0
  107. package/dist/primitives/Table/Core/useTable.d.ts +2 -2
  108. package/dist/primitives/Table/types.d.ts +2 -2
  109. package/dist/primitives/Table/useTableManager/useTableManager.d.ts +1 -1
  110. package/dist/taco.cjs.development.js +1119 -743
  111. package/dist/taco.cjs.development.js.map +1 -1
  112. package/dist/taco.cjs.production.min.js +1 -1
  113. package/dist/taco.cjs.production.min.js.map +1 -1
  114. package/dist/utils/dom.d.ts +2 -1
  115. package/package.json +17 -17
  116. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js +0 -90
  117. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateRowButton.js.map +0 -1
@@ -19,7 +19,7 @@ function Alert(props) {
19
19
  const validationTexts = texts.table3.editing.validation;
20
20
  const tableMeta = table.options.meta;
21
21
  const [showFilterResetDialog, setShowFilterResetDialog] = React__default.useState(false);
22
- const pendingChangesWithErrors = tableMeta.editing.getAlertErrors();
22
+ const pendingChangesWithErrors = tableMeta.editing.getErrorsShownInAlert();
23
23
  function scrollToRow(rowIndex) {
24
24
  tableMeta.rowActive.setRowActiveIndex(rowIndex);
25
25
  scrollToIndex(rowIndex, {
@@ -38,38 +38,43 @@ function Alert(props) {
38
38
  const title = (pendingChangesWithErrors.length === 1 ? validationTexts.alert.titleOne : validationTexts.alert.titlePlural).replace('[COUNT]', String(pendingChangesWithErrors.length));
39
39
  // generate links to each invalid row, to go into the error message
40
40
  const links = [];
41
- const rowIdentityColumn = tableMeta.rowIdentityColumnId ? table.getColumn(tableMeta.rowIdentityColumnId) : undefined;
42
- pendingChangesWithErrors.forEach((error, index) => {
41
+ const visibleColumns = table.getVisibleFlatColumns().map(c => c.id);
42
+ const rowIdentityColumn = tableMeta.rowIdentityAccessor && visibleColumns.includes(String(tableMeta.rowIdentityAccessor)) ? table.getColumn(String(tableMeta.rowIdentityAccessor)) : undefined;
43
+ pendingChangesWithErrors.forEach((pendingChangeWithError, index) => {
43
44
  // if appropriate, concatenate the item with the text "and"
44
45
  if (pendingChangesWithErrors.length > 1 && index === pendingChangesWithErrors.length - 1) {
45
46
  // Add space before and after `messageAnd` text
46
47
  links.push(` ${validationTexts.alert.messageAnd} `);
47
48
  }
48
- const rowIndex = table.getRowModel().rows.findIndex(row => row.id === error.rowId);
49
+ const rowIndex = table.getRowModel().rows.findIndex(row => row.id === pendingChangeWithError.rowId);
49
50
  const handleClick = () => {
51
+ // if row is visible
50
52
  if (rowIndex > -1) {
51
53
  scrollToRow(rowIndex);
52
- } else {
53
- setShowFilterResetDialog(error.rowId);
54
+ }
55
+ // if row is filtered out
56
+ else {
57
+ setShowFilterResetDialog(pendingChangeWithError.rowId);
54
58
  }
55
59
  };
56
60
  let tooltip;
57
- if (error.pendingChange._meta.errors.row) {
58
- tooltip = error.pendingChange._meta.errors.row;
61
+ if (pendingChangeWithError.errors.row) {
62
+ tooltip = pendingChangeWithError.errors.row;
59
63
  } else {
60
64
  var _table$getAllColumns$, _table$getAllColumns$2;
61
- const firstCellErrorColumnId = Object.keys(error.pendingChange._meta.errors.cells)[0];
65
+ const firstCellErrorColumnId = Object.keys(pendingChangeWithError.errors.cells)[0];
62
66
  const columnName = (_table$getAllColumns$ = table.getAllColumns().find(column => column.id === firstCellErrorColumnId)) === null || _table$getAllColumns$ === void 0 ? void 0 : (_table$getAllColumns$2 = _table$getAllColumns$.columnDef.meta) === null || _table$getAllColumns$2 === void 0 ? void 0 : _table$getAllColumns$2.header;
63
- tooltip = `${columnName}: ${error.pendingChange._meta.errors.cells[firstCellErrorColumnId]}`;
67
+ tooltip = `${columnName}: ${pendingChangeWithError.errors.cells[firstCellErrorColumnId]}`;
64
68
  }
69
+ const row = table.getRow(pendingChangeWithError.rowId).original;
65
70
  links.push(/*#__PURE__*/React__default.createElement(Tooltip, {
66
- key: error.rowId,
71
+ key: pendingChangeWithError.rowId,
67
72
  title: tooltip
68
73
  }, /*#__PURE__*/React__default.createElement("span", {
69
74
  className: "text-blue",
70
75
  onClick: handleClick,
71
76
  role: "button"
72
- }, rowIdentityColumn ? error.pendingChange._meta.original[rowIdentityColumn.id] : rowIndex + 1)));
77
+ }, rowIdentityColumn ? row[rowIdentityColumn.id] : rowIndex + 1)));
73
78
  // if appropriate, concatenate the item with the text ","
74
79
  if (pendingChangesWithErrors.length > 2 && index < pendingChangesWithErrors.length - 2) {
75
80
  links.push(', ');
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.js","sources":["../../../../../../../../../src/components/Table3/components/Editing/Alert.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { ScrollToOptions as ReactVirtualScrollToOptions } from '@tanstack/react-virtual';\nimport { Alert as BaseAlert, AlertProps as BaseAlertProps } from '../../../Alert/Alert';\nimport { TableRef } from '../../../../primitives/Table/types';\nimport { Tooltip } from '../../../Tooltip/Tooltip';\nimport { useLocalization } from '../../../Provider/Localization';\nimport { Dialog, DialogProps } from '../../../Dialog/Dialog';\nimport { Group } from '../../../Group/Group';\nimport { Button } from '../../../Button/Button';\n\ntype AlertProps<TType = unknown> = Omit<BaseAlertProps, 'children'> & {\n scrollToIndex: (index: number, options: ReactVirtualScrollToOptions) => void;\n table: ReactTable<TType>;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function Alert<TType = unknown>(props: AlertProps<TType>) {\n const { scrollToIndex, table, tableRef, ...attributes } = props;\n const { texts } = useLocalization();\n const validationTexts = texts.table3.editing.validation;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const [showFilterResetDialog, setShowFilterResetDialog] = React.useState<string | false>(false);\n const pendingChangesWithErrors = tableMeta.editing.getAlertErrors<TType>();\n\n function scrollToRow(rowIndex: number) {\n tableMeta.rowActive.setRowActiveIndex(rowIndex);\n scrollToIndex(rowIndex, { align: 'center' });\n\n requestAnimationFrame(() => {\n const cell = tableRef.current?.querySelector(\n 'tbody > tr[data-row-active=\"true\"] > td[data-cell-editing-invalid=\"true\"]'\n );\n\n if (cell) {\n (cell as HTMLElement).focus?.();\n }\n });\n }\n\n // generate the \"N unsaved entries\" title\n const title = (\n pendingChangesWithErrors.length === 1 ? validationTexts.alert.titleOne : validationTexts.alert.titlePlural\n ).replace('[COUNT]', String(pendingChangesWithErrors.length));\n\n // generate links to each invalid row, to go into the error message\n const links: React.ReactNode[] = [];\n const rowIdentityColumn = tableMeta.rowIdentityColumnId ? table.getColumn(tableMeta.rowIdentityColumnId) : undefined;\n\n pendingChangesWithErrors.forEach((error, index) => {\n // if appropriate, concatenate the item with the text \"and\"\n if (pendingChangesWithErrors.length > 1 && index === pendingChangesWithErrors.length - 1) {\n // Add space before and after `messageAnd` text\n links.push(` ${validationTexts.alert.messageAnd} `);\n }\n const rowIndex = table.getRowModel().rows.findIndex(row => row.id === error.rowId);\n\n const handleClick = () => {\n if (rowIndex > -1) {\n scrollToRow(rowIndex);\n } else {\n setShowFilterResetDialog(error.rowId);\n }\n };\n\n let tooltip;\n\n if (error.pendingChange._meta.errors.row) {\n tooltip = error.pendingChange._meta.errors.row;\n } else {\n const firstCellErrorColumnId = Object.keys(error.pendingChange._meta.errors.cells)[0];\n const columnName = table.getAllColumns().find(column => column.id === firstCellErrorColumnId)?.columnDef.meta?.header;\n tooltip = `${columnName}: ${error.pendingChange._meta.errors.cells[firstCellErrorColumnId]}`;\n }\n\n links.push(\n <Tooltip key={error.rowId} title={tooltip}>\n <span className=\"text-blue\" onClick={handleClick} role=\"button\">\n {rowIdentityColumn ? (error.pendingChange._meta.original as any)[rowIdentityColumn.id] : rowIndex + 1}\n </span>\n </Tooltip>\n );\n\n // if appropriate, concatenate the item with the text \",\"\n if (pendingChangesWithErrors.length > 2 && index < pendingChangesWithErrors.length - 2) {\n links.push(', ');\n }\n });\n\n // generate the \"Row N is incomplete and hasn't been saved\" error message\n const message = (links.length === 1 ? validationTexts.alert.messageOne : validationTexts.alert.messagePlural)\n .split(/(\\[\\w+\\])/)\n .map(part => {\n if (part === '[COLUMN]') {\n return rowIdentityColumn?.columnDef.meta?.header ?? validationTexts.alert.messageRow;\n }\n\n if (part === '[ROW]') {\n return links;\n }\n\n return part;\n });\n\n const handleResetFilters = () => {\n table.resetGlobalFilter();\n table.resetColumnFilters();\n\n requestAnimationFrame(() => {\n const rowIndex = table.getRowModel().rows.findIndex(row => row.id === showFilterResetDialog);\n\n if (rowIndex > -1) {\n scrollToRow(rowIndex);\n }\n\n setShowFilterResetDialog(false);\n });\n };\n\n return (\n <>\n <BaseAlert {...attributes} state=\"error\">\n <span className=\"font-bold\">{title}</span>&nbsp;{message}\n </BaseAlert>\n <FilterResetDialog\n open={showFilterResetDialog !== false}\n onChange={() => setShowFilterResetDialog(false)}\n onSubmit={handleResetFilters}\n />\n </>\n );\n}\n\ntype FilterResetDialogProps = Omit<DialogProps, 'children'> & {\n onSubmit: () => void;\n};\n\nfunction FilterResetDialog(props: FilterResetDialogProps) {\n const { onSubmit: handleSubmit, ...dialogProps } = props;\n const { texts } = useLocalization();\n\n return (\n <Dialog {...dialogProps} size=\"xs\">\n <Dialog.Content aria-label=\"Create a new account\">\n <Dialog.Title>{texts.table3.editing.validation.resetFiltersDialog.title}</Dialog.Title>\n\n <p>{texts.table3.editing.validation.resetFiltersDialog.description}</p>\n\n <Dialog.Footer>\n <Group>\n <Dialog.Close>\n <Button>{texts.table3.editing.validation.resetFiltersDialog.cancel}</Button>\n </Dialog.Close>\n <Button appearance=\"primary\" onClick={handleSubmit}>\n {texts.table3.editing.validation.resetFiltersDialog.confirm}\n </Button>\n </Group>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n );\n}\n"],"names":["Alert","props","scrollToIndex","table","tableRef","attributes","texts","useLocalization","validationTexts","table3","editing","validation","tableMeta","options","meta","showFilterResetDialog","setShowFilterResetDialog","React","useState","pendingChangesWithErrors","getAlertErrors","scrollToRow","rowIndex","rowActive","setRowActiveIndex","align","requestAnimationFrame","cell","_tableRef$current","current","querySelector","_cell$focus","focus","call","title","length","alert","titleOne","titlePlural","replace","String","links","rowIdentityColumn","rowIdentityColumnId","getColumn","undefined","forEach","error","index","push","messageAnd","getRowModel","rows","findIndex","row","id","rowId","handleClick","tooltip","pendingChange","_meta","errors","_table$getAllColumns$","_table$getAllColumns$2","firstCellErrorColumnId","Object","keys","cells","columnName","getAllColumns","find","column","columnDef","header","Tooltip","key","className","onClick","role","original","message","messageOne","messagePlural","split","map","part","_rowIdentityColumn$co","_rowIdentityColumn$co2","messageRow","handleResetFilters","resetGlobalFilter","resetColumnFilters","BaseAlert","state","FilterResetDialog","open","onChange","onSubmit","handleSubmit","dialogProps","Dialog","size","Content","Title","resetFiltersDialog","description","Footer","Group","Close","Button","cancel","appearance","confirm"],"mappings":";;;;;;;;SAiBgBA,KAAKA,CAAkBC,KAAwB;EAC3D,MAAM;IAAEC,aAAa;IAAEC,KAAK;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAC/D,MAAM;IAAEK;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,eAAe,GAAGF,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,UAAU;EACvD,MAAMC,SAAS,GAAGT,KAAK,CAACU,OAAO,CAACC,IAA6B;EAC7D,MAA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AK,CAACG,MAAM,CAACC,OAAO,CAACC,UAAU,CAAC6F,kBAAkB,CAACQ,OAAO,CACtD,CACL,CACI,CACH,CACZ;AAEjB;;;;"}
1
+ {"version":3,"file":"Alert.js","sources":["../../../../../../../../../src/components/Table3/components/Editing/Alert.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { ScrollToOptions as ReactVirtualScrollToOptions } from '@tanstack/react-virtual';\nimport { Alert as BaseAlert, AlertProps as BaseAlertProps } from '../../../Alert/Alert';\nimport { TableRef } from '../../../../primitives/Table/types';\nimport { Tooltip } from '../../../Tooltip/Tooltip';\nimport { useLocalization } from '../../../Provider/Localization';\nimport { Dialog, DialogProps } from '../../../Dialog/Dialog';\nimport { Group } from '../../../Group/Group';\nimport { Button } from '../../../Button/Button';\n\ntype AlertProps<TType = unknown> = Omit<BaseAlertProps, 'children'> & {\n scrollToIndex: (index: number, options: ReactVirtualScrollToOptions) => void;\n table: ReactTable<TType>;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function Alert<TType = unknown>(props: AlertProps<TType>) {\n const { scrollToIndex, table, tableRef, ...attributes } = props;\n const { texts } = useLocalization();\n const validationTexts = texts.table3.editing.validation;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const [showFilterResetDialog, setShowFilterResetDialog] = React.useState<string | false>(false);\n const pendingChangesWithErrors = tableMeta.editing.getErrorsShownInAlert<TType>();\n\n function scrollToRow(rowIndex: number) {\n tableMeta.rowActive.setRowActiveIndex(rowIndex);\n scrollToIndex(rowIndex, { align: 'center' });\n\n requestAnimationFrame(() => {\n const cell = tableRef.current?.querySelector(\n 'tbody > tr[data-row-active=\"true\"] > td[data-cell-editing-invalid=\"true\"]'\n );\n\n if (cell) {\n (cell as HTMLElement).focus?.();\n }\n });\n }\n\n // generate the \"N unsaved entries\" title\n const title = (\n pendingChangesWithErrors.length === 1 ? validationTexts.alert.titleOne : validationTexts.alert.titlePlural\n ).replace('[COUNT]', String(pendingChangesWithErrors.length));\n\n // generate links to each invalid row, to go into the error message\n const links: React.ReactNode[] = [];\n const visibleColumns = table.getVisibleFlatColumns().map(c => c.id);\n const rowIdentityColumn =\n tableMeta.rowIdentityAccessor && visibleColumns.includes(String(tableMeta.rowIdentityAccessor))\n ? table.getColumn(String(tableMeta.rowIdentityAccessor))\n : undefined;\n\n pendingChangesWithErrors.forEach((pendingChangeWithError, index) => {\n // if appropriate, concatenate the item with the text \"and\"\n if (pendingChangesWithErrors.length > 1 && index === pendingChangesWithErrors.length - 1) {\n // Add space before and after `messageAnd` text\n links.push(` ${validationTexts.alert.messageAnd} `);\n }\n\n const rowIndex = table.getRowModel().rows.findIndex(row => row.id === pendingChangeWithError.rowId);\n\n const handleClick = () => {\n // if row is visible\n if (rowIndex > -1) {\n scrollToRow(rowIndex);\n }\n // if row is filtered out\n else {\n setShowFilterResetDialog(pendingChangeWithError.rowId);\n }\n };\n\n let tooltip;\n\n if (pendingChangeWithError.errors.row) {\n tooltip = pendingChangeWithError.errors.row;\n } else {\n const firstCellErrorColumnId = Object.keys(pendingChangeWithError.errors.cells)[0];\n const columnName = table.getAllColumns().find(column => column.id === firstCellErrorColumnId)?.columnDef.meta?.header;\n tooltip = `${columnName}: ${pendingChangeWithError.errors.cells[firstCellErrorColumnId]}`;\n }\n\n const row = table.getRow(pendingChangeWithError.rowId).original;\n\n links.push(\n <Tooltip key={pendingChangeWithError.rowId} title={tooltip}>\n <span className=\"text-blue\" onClick={handleClick} role=\"button\">\n {rowIdentityColumn ? row[rowIdentityColumn.id] : rowIndex + 1}\n </span>\n </Tooltip>\n );\n\n // if appropriate, concatenate the item with the text \",\"\n if (pendingChangesWithErrors.length > 2 && index < pendingChangesWithErrors.length - 2) {\n links.push(', ');\n }\n });\n\n // generate the \"Row N is incomplete and hasn't been saved\" error message\n const message = (links.length === 1 ? validationTexts.alert.messageOne : validationTexts.alert.messagePlural)\n .split(/(\\[\\w+\\])/)\n .map(part => {\n if (part === '[COLUMN]') {\n return rowIdentityColumn?.columnDef.meta?.header ?? validationTexts.alert.messageRow;\n }\n\n if (part === '[ROW]') {\n return links;\n }\n\n return part;\n });\n\n const handleResetFilters = () => {\n table.resetGlobalFilter();\n table.resetColumnFilters();\n\n requestAnimationFrame(() => {\n const rowIndex = table.getRowModel().rows.findIndex(row => row.id === showFilterResetDialog);\n\n if (rowIndex > -1) {\n scrollToRow(rowIndex);\n }\n\n setShowFilterResetDialog(false);\n });\n };\n\n return (\n <>\n <BaseAlert {...attributes} state=\"error\">\n <span className=\"font-bold\">{title}</span>&nbsp;{message}\n </BaseAlert>\n <FilterResetDialog\n open={showFilterResetDialog !== false}\n onChange={() => setShowFilterResetDialog(false)}\n onSubmit={handleResetFilters}\n />\n </>\n );\n}\n\ntype FilterResetDialogProps = Omit<DialogProps, 'children'> & {\n onSubmit: () => void;\n};\n\nfunction FilterResetDialog(props: FilterResetDialogProps) {\n const { onSubmit: handleSubmit, ...dialogProps } = props;\n const { texts } = useLocalization();\n\n return (\n <Dialog {...dialogProps} size=\"xs\">\n <Dialog.Content aria-label=\"Create a new account\">\n <Dialog.Title>{texts.table3.editing.validation.resetFiltersDialog.title}</Dialog.Title>\n\n <p>{texts.table3.editing.validation.resetFiltersDialog.description}</p>\n\n <Dialog.Footer>\n <Group>\n <Dialog.Close>\n <Button>{texts.table3.editing.validation.resetFiltersDialog.cancel}</Button>\n </Dialog.Close>\n <Button appearance=\"primary\" onClick={handleSubmit}>\n {texts.table3.editing.validation.resetFiltersDialog.confirm}\n </Button>\n </Group>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n );\n}\n"],"names":["Alert","props","scrollToIndex","table","tableRef","attributes","texts","useLocalization","validationTexts","table3","editing","validation","tableMeta","options","meta","showFilterResetDialog","setShowFilterResetDialog","React","useState","pendingChangesWithErrors","getErrorsShownInAlert","scrollToRow","rowIndex","rowActive","setRowActiveIndex","align","requestAnimationFrame","cell","_tableRef$current","current","querySelector","_cell$focus","focus","call","title","length","alert","titleOne","titlePlural","replace","String","links","visibleColumns","getVisibleFlatColumns","map","c","id","rowIdentityColumn","rowIdentityAccessor","includes","getColumn","undefined","forEach","pendingChangeWithError","index","push","messageAnd","getRowModel","rows","findIndex","row","rowId","handleClick","tooltip","errors","_table$getAllColumns$","_table$getAllColumns$2","firstCellErrorColumnId","Object","keys","cells","columnName","getAllColumns","find","column","columnDef","header","getRow","original","Tooltip","key","className","onClick","role","message","messageOne","messagePlural","split","part","_rowIdentityColumn$co","_rowIdentityColumn$co2","messageRow","handleResetFilters","resetGlobalFilter","resetColumnFilters","BaseAlert","state","FilterResetDialog","open","onChange","onSubmit","handleSubmit","dialogProps","Dialog","size","Content","Title","resetFiltersDialog","description","Footer","Group","Close","Button","cancel","appearance","confirm"],"mappings":";;;;;;;;SAiBgBA,KAAKA,CAAkBC,KAAwB;EAC3D,MAAM;IAAEC,aAAa;IAAEC,KAAK;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAC/D,MAAM;IAAEK;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,eAAe,GAAGF,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,UAAU;EACvD,MAAMC,SAAS,GAAGT,KAAK,CAACU,OAAO,CAACC,IAA6B;EAC7D,MAAM,CAACC,qBAAqB,EAAEC,wBAAwB,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAiB,KAAK,CAAC;EAC/F,MAAMC,wBAAwB,GAAGP,SAAS,CAACF,OAAO,CAACU,qBAAqB,EAAS;EAEjF,SAASC,WAAWA,CAACC,QAAgB;IACjCV,SAAS,CAACW,SAAS,CAACC,iBAAiB,CAACF,QAAQ,CAAC;IAC/CpB,aAAa,CAACoB,QAAQ,EAAE;MAAEG,KAAK,EAAE;KAAU,CAAC;IAE5CC,qBAAqB,CAAC;;MAClB,MAAMC,IAAI,IAAAC,iBAAA,GAAGxB,QAAQ,CAACyB,OAAO,cAAAD,iBAAA,uBAAhBA,iB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C;mBAC7B/E;IAAMgE,SAAS,EAAC;KAAa/C,KAAK,CAAQ,YAAOkD,OAAO,CAChD,eACZnE,6BAACgF,iBAAiB;IACdC,IAAI,EAAEnF,qBAAqB,KAAK,KAAK;IACrCoF,QAAQ,EAAEA,MAAMnF,wBAAwB,CAAC,KAAK,CAAC;IAC/CoF,QAAQ,EAAER;IACZ,CACH;AAEX;AAMA,SAASK,iBAAiBA,CAAChG,KAA6B;EACpD,MAAM;IAAEmG,QAAQ,EAAEC,YAAY;IAAE,GAAGC;GAAa,GAAGrG,KAAK;EACxD,MAAM;IAAEK;GAAO,GAAGC,eAAe,EAAE;EAEnC,oBACIU,6BAACsF,MAAM,oBAAKD,WAAW;IAAEE,IAAI,EAAC;mBAC1BvF,6BAACsF,MAAM,CAACE,OAAO;kBAAY;kBACvBxF,6BAACsF,MAAM,CAACG,KAAK,QAAEpG,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,UAAU,CAACgG,kBAAkB,CAACzE,KAAK,CAAgB,eAEvFjB,wCAAIX,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,UAAU,CAACgG,kBAAkB,CAACC,WAAW,CAAK,eAEvE3F,6BAACsF,MAAM,CAACM,MAAM,qBACV5F,6BAAC6F,KAAK,qBACF7F,6BAACsF,MAAM,CAACQ,KAAK,qBACT9F,6BAAC+F,MAAM,QAAE1G,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,UAAU,CAACgG,kBAAkB,CAACM,MAAM,CAAU,CACjE,eACfhG,6BAAC+F,MAAM;IAACE,UAAU,EAAC,SAAS;IAAChC,OAAO,EAAEmB;KACjC/F,KAAK,CAACG,MAAM,CAACC,OAAO,CAACC,UAAU,CAACgG,kBAAkB,CAACQ,OAAO,CACtD,CACL,CACI,CACH,CACZ;AAEjB;;;;"}
@@ -0,0 +1,34 @@
1
+ import React__default from 'react';
2
+ import { useLocalization } from '../../../Provider/Localization.js';
3
+ import { Button } from '../../../Button/Button.js';
4
+ import { Dialog } from '../../../Dialog/Dialog.js';
5
+ import { Group } from '../../../Group/Group.js';
6
+
7
+ function DiscardChangesConfirmationDialog(props) {
8
+ const {
9
+ onDiscard: handleDiscard,
10
+ ...dialogProps
11
+ } = props;
12
+ const {
13
+ texts
14
+ } = useLocalization();
15
+ const handleClickInsideDialogContent = event => {
16
+ // Prevents the click event from propagating to the table, ensuring the row isn't saved when a click occurs
17
+ // inside the dialog
18
+ event.stopPropagation();
19
+ };
20
+ return /*#__PURE__*/React__default.createElement(Dialog, Object.assign({}, dialogProps), /*#__PURE__*/React__default.createElement(Dialog.Content, {
21
+ "aria-label": texts.table3.editing.clearChangesConfirmationDialog.title,
22
+ onClick: handleClickInsideDialogContent
23
+ }, /*#__PURE__*/React__default.createElement(Dialog.Title, null, texts.table3.editing.clearChangesConfirmationDialog.title), /*#__PURE__*/React__default.createElement("p", null, texts.table3.editing.clearChangesConfirmationDialog.description), /*#__PURE__*/React__default.createElement(Dialog.Footer, null, /*#__PURE__*/React__default.createElement(Group, null, /*#__PURE__*/React__default.createElement(Dialog.Close, null, /*#__PURE__*/React__default.createElement(Button, {
24
+ tabIndex: 0
25
+ }, texts.table3.editing.clearChangesConfirmationDialog.cancel)), /*#__PURE__*/React__default.createElement(Dialog.Close, null, /*#__PURE__*/React__default.createElement(Button, {
26
+ autoFocus: true,
27
+ tabIndex: 0,
28
+ appearance: "primary",
29
+ onClick: handleDiscard
30
+ }, texts.table3.editing.clearChangesConfirmationDialog.confirm))))));
31
+ }
32
+
33
+ export { DiscardChangesConfirmationDialog };
34
+ //# sourceMappingURL=DiscardChangesConfirmationDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiscardChangesConfirmationDialog.js","sources":["../../../../../../../../../src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.tsx"],"sourcesContent":["import React from 'react';\nimport { Dialog, DialogProps } from '../../../Dialog/Dialog';\nimport { useLocalization } from '../../../Provider/Localization';\nimport { Group } from '../../../Group/Group';\nimport { Button } from '../../../Button/Button';\n\ntype DiscardChangesConfirmationDialogProps = Partial<DialogProps> & {\n onDiscard: () => void;\n};\n\nexport function DiscardChangesConfirmationDialog(props: DiscardChangesConfirmationDialogProps) {\n const { onDiscard: handleDiscard, ...dialogProps } = props;\n const { texts } = useLocalization();\n\n const handleClickInsideDialogContent = (event: React.MouseEvent) => {\n // Prevents the click event from propagating to the table, ensuring the row isn't saved when a click occurs\n // inside the dialog\n event.stopPropagation();\n };\n\n return (\n <Dialog {...dialogProps}>\n <Dialog.Content\n aria-label={texts.table3.editing.clearChangesConfirmationDialog.title}\n onClick={handleClickInsideDialogContent}>\n <Dialog.Title>{texts.table3.editing.clearChangesConfirmationDialog.title}</Dialog.Title>\n\n <p>{texts.table3.editing.clearChangesConfirmationDialog.description}</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 autoFocus tabIndex={0} appearance=\"primary\" onClick={handleDiscard}>\n {texts.table3.editing.clearChangesConfirmationDialog.confirm}\n </Button>\n </Dialog.Close>\n </Group>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n );\n}\n"],"names":["DiscardChangesConfirmationDialog","props","onDiscard","handleDiscard","dialogProps","texts","useLocalization","handleClickInsideDialogContent","event","stopPropagation","React","Dialog","Content","table3","editing","clearChangesConfirmationDialog","title","onClick","Title","description","Footer","Group","Close","Button","tabIndex","cancel","autoFocus","appearance","confirm"],"mappings":";;;;;;SAUgBA,gCAAgCA,CAACC,KAA4C;EACzF,MAAM;IAAEC,SAAS,EAAEC,aAAa;IAAE,GAAGC;GAAa,GAAGH,KAAK;EAC1D,MAAM;IAAEI;GAAO,GAAGC,eAAe,EAAE;EAEnC,MAAMC,8BAA8B,GAAIC,KAAuB;;;IAG3DA,KAAK,CAACC,eAAe,EAAE;GAC1B;EAED,oBACIC,6BAACC,MAAM,oBAAKP,WAAW,gBACnBM,6BAACC,MAAM,CAACC,OAAO;kBACCP,KAAK,CAACQ,MAAM,CAACC,OAAO,CAACC,8BAA8B,CAACC,KAAK;IACrEC,OAAO,EAAEV;kBACTG,6BAACC,MAAM,CAACO,KAAK,QAAEb,KAAK,CAACQ,MAAM,CAACC,OAAO,CAACC,8BAA8B,CAACC,KAAK,CAAgB,eAExFN,wCAAIL,KAAK,CAACQ,MAAM,CAACC,OAAO,CAACC,8BAA8B,CAACI,WAAW,CAAK,eAExET,6BAACC,MAAM,CAACS,MAAM,qBACVV,6BAACW,KAAK,qBACFX,6BAACC,MAAM,CAACW,KAAK,qBACTZ,6BAACa,MAAM;IAACC,QAAQ,EAAE;KAAInB,KAAK,CAACQ,MAAM,CAACC,OAAO,CAACC,8BAA8B,CAACU,MAAM,CAAU,CAC/E,eACff,6BAACC,MAAM,CAACW,KAAK,qBACTZ,6BAACa,MAAM;IAACG,SAAS;IAACF,QAAQ,EAAE,CAAC;IAAEG,UAAU,EAAC,SAAS;IAACV,OAAO,EAAEd;KACxDE,KAAK,CAACQ,MAAM,CAACC,OAAO,CAACC,8BAA8B,CAACa,OAAO,CACvD,CACE,CACX,CACI,CACH,CACZ;AAEjB;;;;"}
@@ -0,0 +1,104 @@
1
+ import React__default from 'react';
2
+ import cn from 'clsx';
3
+ import { Icon } from '../../../../Icon/Icon.js';
4
+ import { useLocalization } from '../../../../Provider/Localization.js';
5
+ import { Button } from '../../../../Button/Button.js';
6
+ import { Shortcut } from '../../../../Shortcut/Shortcut.js';
7
+
8
+ function CreateNewRow(props) {
9
+ var _temporaryRows$0$tabl, _temporaryRows$, _table$getState$colum, _tableRef$current2;
10
+ const {
11
+ buttonRef,
12
+ onEditingCreate: handleEditingCreate,
13
+ scrollToIndex,
14
+ table,
15
+ tableMeta,
16
+ tableRef
17
+ } = props;
18
+ const {
19
+ texts
20
+ } = useLocalization();
21
+ const temporaryRows = tableMeta.editing.temporaryRows;
22
+ const temporaryRowId = (_temporaryRows$0$tabl = (_temporaryRows$ = temporaryRows[0]) === null || _temporaryRows$ === void 0 ? void 0 : _temporaryRows$[tableMeta.rowIdentityAccessor]) !== null && _temporaryRows$0$tabl !== void 0 ? _temporaryRows$0$tabl : '';
23
+ const isDisabled = !!table.getState().globalFilter || !!((_table$getState$colum = table.getState().columnFilters) !== null && _table$getState$colum !== void 0 && _table$getState$colum.length) || !!temporaryRowId && !!tableMeta.editing.hasRowErrors(temporaryRowId);
24
+ const isSaving = !!temporaryRowId && tableMeta.editing.getRowStatus(temporaryRowId) === 'saving';
25
+ const createRow = function (row) {
26
+ try {
27
+ if (!handleEditingCreate || isDisabled) {
28
+ return Promise.resolve();
29
+ }
30
+ return Promise.resolve(tableMeta.editing.saveChanges(table)).then(function (saved) {
31
+ if (!saved) {
32
+ return;
33
+ }
34
+ const changeset = row !== null && row !== void 0 ? row : handleEditingCreate();
35
+ try {
36
+ if (changeset) {
37
+ const rowId = tableMeta.editing.createRow(changeset);
38
+ table.getRow(rowId).pin('bottom');
39
+ // set the active row to the new row before toggling editing on
40
+ const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
41
+ tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
42
+ tableMeta.editing.toggleEditing(true, table, scrollToIndex);
43
+ tableMeta.editing.setLastFocusedCellIndex(0);
44
+ }
45
+ } catch (error) {
46
+ console.error(error);
47
+ }
48
+ });
49
+ } catch (e) {
50
+ return Promise.reject(e);
51
+ }
52
+ };
53
+ // allow programmatic access to creating rows from outside the table
54
+ React__default.useEffect(() => {
55
+ var _tableRef$current;
56
+ if (tableRef !== null && tableRef !== void 0 && (_tableRef$current = tableRef.current) !== null && _tableRef$current !== void 0 && _tableRef$current.instance) {
57
+ tableRef.current.instance.createRow = createRow;
58
+ }
59
+ }, [tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : _tableRef$current2.instance, createRow]);
60
+ const handleCreate = function () {
61
+ return createRow();
62
+ };
63
+ const shortcut = {
64
+ key: 'Enter',
65
+ meta: true
66
+ };
67
+ let tooltip;
68
+ if (isSaving) {
69
+ tooltip = texts.table3.editing.buttons.create.saving;
70
+ } else if (isDisabled) {
71
+ tooltip = texts.table3.editing.buttons.create.disabled;
72
+ } else {
73
+ tooltip = /*#__PURE__*/React__default.createElement(Shortcut, {
74
+ keys: shortcut
75
+ });
76
+ }
77
+ const isScrolled = tableRef.current ? tableRef.current.scrollHeight > tableRef.current.clientHeight : false;
78
+ const className = cn('group/row border-grey-300 !sticky z-[21]', {
79
+ 'bottom-10': tableMeta.footer.isEnabled,
80
+ 'bottom-0': !tableMeta.footer.isEnabled,
81
+ 'border-t-2': isScrolled,
82
+ 'border-b': !isScrolled
83
+ });
84
+ return /*#__PURE__*/React__default.createElement("tr", {
85
+ "data-row-create": true,
86
+ className: className,
87
+ tabIndex: -1
88
+ }, /*#__PURE__*/React__default.createElement("td", {
89
+ className: "!bg-grey-50 col-span-full !border-b-0 !px-1"
90
+ }, /*#__PURE__*/React__default.createElement(Button, {
91
+ appearance: "transparent",
92
+ className: "group-hover:bg-grey-200 sticky left-[4px]",
93
+ disabled: isDisabled,
94
+ onClick: handleCreate,
95
+ ref: buttonRef,
96
+ shortcut: shortcut,
97
+ tooltip: tooltip
98
+ }, /*#__PURE__*/React__default.createElement(Icon, {
99
+ name: "circle-plus"
100
+ }), texts.table3.editing.buttons.create.label)));
101
+ }
102
+
103
+ export { CreateNewRow };
104
+ //# sourceMappingURL=CreateNewRow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreateNewRow.js","sources":["../../../../../../../../../../src/components/Table3/components/Row/Editing/CreateNewRow.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { Button } from '../../../../Button/Button';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Icon } from '../../../../Icon/Icon';\nimport { Table3EditingCreateHandler, Table3Ref } from '../../../types';\nimport { TableRef } from '../../../../../primitives/Table/types';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\nimport clsx from 'clsx';\n\ntype CreateNewRowProps<TType = unknown> = {\n buttonRef: React.Ref<HTMLButtonElement>;\n onEditingCreate?: Table3EditingCreateHandler<TType>;\n scrollToIndex: (index: number) => void;\n table: ReactTable<TType>;\n tableMeta: ReactTableMeta<TType>;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function CreateNewRow<TType = unknown>(props: CreateNewRowProps<TType>) {\n const { buttonRef, onEditingCreate: handleEditingCreate, scrollToIndex, table, tableMeta, tableRef } = props;\n const { texts } = useLocalization();\n\n const temporaryRows = tableMeta.editing.temporaryRows as TType[];\n const temporaryRowId: string = temporaryRows[0]?.[tableMeta.rowIdentityAccessor as string] ?? '';\n\n const isDisabled =\n !!table.getState().globalFilter ||\n !!table.getState().columnFilters?.length ||\n (!!temporaryRowId && !!tableMeta.editing.hasRowErrors(temporaryRowId));\n const isSaving = !!temporaryRowId && tableMeta.editing.getRowStatus(temporaryRowId) === 'saving';\n\n const createRow = async (row?: Partial<TType>) => {\n if (!handleEditingCreate || isDisabled) {\n return;\n }\n\n const saved = await tableMeta.editing.saveChanges(table);\n\n if (!saved) {\n return;\n }\n\n const changeset = row ?? handleEditingCreate();\n\n try {\n if (changeset) {\n const rowId = tableMeta.editing.createRow(changeset);\n table.getRow(rowId).pin('bottom');\n\n // set the active row to the new row before toggling editing on\n const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;\n tableMeta.rowActive.setRowActiveIndex(nextRowIndex);\n\n tableMeta.editing.toggleEditing(true, table, scrollToIndex);\n tableMeta.editing.setLastFocusedCellIndex(0);\n }\n } catch (error) {\n console.error(error);\n }\n };\n\n // allow programmatic access to creating rows from outside the table\n React.useEffect(() => {\n if (tableRef?.current?.instance) {\n (tableRef.current as Table3Ref).instance.createRow = createRow as (row: unknown) => Promise<void>;\n }\n }, [tableRef?.current?.instance, createRow]);\n\n const handleCreate = async () => createRow();\n const shortcut = { key: 'Enter', meta: true };\n\n let tooltip;\n\n if (isSaving) {\n tooltip = texts.table3.editing.buttons.create.saving;\n } else if (isDisabled) {\n tooltip = texts.table3.editing.buttons.create.disabled;\n } else {\n tooltip = <Shortcut keys={shortcut} />;\n }\n\n const isScrolled = tableRef.current ? tableRef.current.scrollHeight > tableRef.current.clientHeight : false;\n\n const className = clsx('group/row border-grey-300 !sticky z-[21]', {\n 'bottom-10': tableMeta.footer.isEnabled,\n 'bottom-0': !tableMeta.footer.isEnabled,\n 'border-t-2': isScrolled,\n 'border-b': !isScrolled,\n });\n\n return (\n <tr data-row-create className={className} tabIndex={-1}>\n <td className=\"!bg-grey-50 col-span-full !border-b-0 !px-1\">\n <Button\n appearance=\"transparent\"\n className=\"group-hover:bg-grey-200 sticky left-[4px]\"\n disabled={isDisabled}\n onClick={handleCreate}\n ref={buttonRef}\n shortcut={shortcut}\n tooltip={tooltip}>\n <Icon name=\"circle-plus\" />\n {texts.table3.editing.buttons.create.label}\n </Button>\n </td>\n </tr>\n );\n}\n"],"names":["CreateNewRow","props","buttonRef","onEditingCreate","handleEditingCreate","scrollToIndex","table","tableMeta","tableRef","texts","useLocalization","temporaryRows","editing","temporaryRowId","_temporaryRows$0$tabl","_temporaryRows$","rowIdentityAccessor","isDisabled","getState","globalFilter","_table$getState$colum","columnFilters","length","hasRowErrors","isSaving","getRowStatus","createRow","row","Promise","resolve","saveChanges","then","saved","changeset","rowId","getRow","pin","nextRowIndex","rowActive","setRowActiveIndex","toggleEditing","setLastFocusedCellIndex","error","console","e","reject","React","useEffect","_tableRef$current","current","instance","_tableRef$current2","handleCreate","shortcut","key","meta","tooltip","table3","buttons","create","saving","disabled","Shortcut","keys","isScrolled","scrollHeight","clientHeight","className","clsx","footer","isEnabled","tabIndex","Button","appearance","onClick","ref","Icon","name","label"],"mappings":";;;;;;;SAmBgBA,YAAYA,CAAkBC,KAA+B;;EACzE,MAAM;IAAEC,SAAS;IAAEC,eAAe,EAAEC,mBAAmB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AAU,EAAE;IACnBuC,OAAO,GAAG/C,KAAK,CAACgD,MAAM,CAAC7C,OAAO,CAAC8C,OAAO,CAACC,MAAM,CAACE,QAAQ;GACzD,MAAM;IACHL,OAAO,gBAAGV,6BAACgB,QAAQ;MAACC,IAAI,EAAEV;MAAY;;EAG1C,MAAMW,UAAU,GAAGxD,QAAQ,CAACyC,OAAO,GAAGzC,QAAQ,CAACyC,OAAO,CAACgB,YAAY,GAAGzD,QAAQ,CAACyC,OAAO,CAACiB,YAAY,GAAG,KAAK;EAE3G,MAAMC,SAAS,GAAGC,EAAI,CAAC,0CAA0C,EAAE;IAC/D,WAAW,EAAE7D,SAAS,CAAC8D,MAAM,CAACC,SAAS;IACvC,UAAU,EAAE,CAAC/D,SAAS,CAAC8D,MAAM,CAACC,SAAS;IACvC,YAAY,EAAEN,UAAU;IACxB,UAAU,EAAE,CAACA;GAChB,CAAC;EAEF,oBACIlB;;IAAoBqB,SAAS,EAAEA,SAAS;IAAEI,QAAQ,EAAE,CAAC;kBACjDzB;IAAIqB,SAAS,EAAC;kBACVrB,6BAAC0B,MAAM;IACHC,UAAU,EAAC,aAAa;IACxBN,SAAS,EAAC,2CAA2C;IACrDN,QAAQ,EAAE5C,UAAU;IACpByD,OAAO,EAAEtB,YAAY;IACrBuB,GAAG,EAAEzE,SAAS;IACdmD,QAAQ,EAAEA,QAAQ;IAClBG,OAAO,EAAEA;kBACTV,6BAAC8B,IAAI;IAACC,IAAI,EAAC;IAAgB,EAC1BpE,KAAK,CAACgD,MAAM,CAAC7C,OAAO,CAAC8C,OAAO,CAACC,MAAM,CAACmB,KAAK,CACrC,CACR,CACJ;AAEb;;;;"}
@@ -5,7 +5,6 @@ import { Tooltip } from '../../../../Tooltip/Tooltip.js';
5
5
  import { useLocalization } from '../../../../Provider/Localization.js';
6
6
  import { Spinner } from '../../../../Spinner/Spinner.js';
7
7
 
8
- const COMPLETE_INDICATOR_DELAY = 3000;
9
8
  function SaveStatus(props) {
10
9
  const {
11
10
  rowId,
@@ -15,18 +14,7 @@ function SaveStatus(props) {
15
14
  texts
16
15
  } = useLocalization();
17
16
  const tableMeta = table.options.meta;
18
- const status = tableMeta.editing.getRowSaveStatus(rowId);
19
- React__default.useEffect(() => {
20
- let timeout;
21
- if (status === 'complete') {
22
- timeout = window.setTimeout(() => {
23
- tableMeta.editing.setRowSaveStatus(rowId, undefined);
24
- }, COMPLETE_INDICATOR_DELAY);
25
- }
26
- return () => {
27
- clearTimeout(timeout);
28
- };
29
- }, [status]);
17
+ const status = tableMeta.editing.getRowStatus(rowId);
30
18
  const className = cn('col-span-full sticky ml-auto right-0 top-0 -mb-[100%] z-10 h-8 bg-[inherit] flex items-center px-1.5 shadow-[-6px_0px_6px_var(--table-row-actions-shadow)]', {
31
19
  'mt-0.5': tableMeta.rowHeight.height === 'short',
32
20
  'mt-1': tableMeta.rowHeight.height === 'medium',
@@ -37,7 +25,7 @@ function SaveStatus(props) {
37
25
  className: "!contents"
38
26
  }, /*#__PURE__*/React__default.createElement("span", {
39
27
  className: className
40
- }, status === 'pending' ? (/*#__PURE__*/React__default.createElement(Tooltip, {
28
+ }, status === 'saving' ? (/*#__PURE__*/React__default.createElement(Tooltip, {
41
29
  title: texts.table3.editing.saving.progress
42
30
  }, /*#__PURE__*/React__default.createElement(Spinner, {
43
31
  delay: 0,
@@ -1 +1 @@
1
- {"version":3,"file":"SaveStatus.js","sources":["../../../../../../../../../../src/components/Table3/components/Row/Editing/SaveStatus.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport clsx from 'clsx';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { BadgeIcon } from '../../../../BadgeIcon/BadgeIcon';\nimport { Spinner } from '../../../../Spinner/Spinner';\n\nconst COMPLETE_INDICATOR_DELAY = 3000;\n\ntype SaveStatusProps<TType = unknown> = {\n rowId: string;\n table: ReactTable<TType>;\n};\n\nexport function SaveStatus<TType = unknown>(props: SaveStatusProps<TType>) {\n const { rowId, table } = props;\n const { texts } = useLocalization();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const status = tableMeta.editing.getRowSaveStatus(rowId);\n\n React.useEffect(() => {\n let timeout: number;\n\n if (status === 'complete') {\n timeout = window.setTimeout(() => {\n tableMeta.editing.setRowSaveStatus(rowId, undefined);\n }, COMPLETE_INDICATOR_DELAY);\n }\n\n return () => {\n clearTimeout(timeout);\n };\n }, [status]);\n\n const className = clsx(\n 'col-span-full sticky ml-auto right-0 top-0 -mb-[100%] z-10 h-8 bg-[inherit] flex items-center px-1.5 shadow-[-6px_0px_6px_var(--table-row-actions-shadow)]',\n {\n 'mt-0.5': tableMeta.rowHeight.height === 'short',\n 'mt-1': tableMeta.rowHeight.height === 'medium',\n 'mt-1.5': tableMeta.rowHeight.height === 'tall',\n 'mt-2': tableMeta.rowHeight.height === 'extra-tall',\n }\n );\n\n return (\n <td className=\"!contents\">\n <span className={className}>\n {status === 'pending' ? (\n <Tooltip title={texts.table3.editing.saving.progress}>\n <Spinner delay={0} className=\"mr-1 !h-5 !w-5\" />\n </Tooltip>\n ) : (\n <Tooltip title={texts.table3.editing.saving.complete}>\n <BadgeIcon icon=\"tick\" color=\"green\" subtle className=\"mr-1\" />\n </Tooltip>\n )}\n </span>\n </td>\n );\n}\n"],"names":["COMPLETE_INDICATOR_DELAY","SaveStatus","props","rowId","table","texts","useLocalization","tableMeta","options","meta","status","editing","getRowSaveStatus","React","useEffect","timeout","window","setTimeout","setRowSaveStatus","undefined","clearTimeout","className","clsx","rowHeight","height","Tooltip","title","table3","saving","progress","Spinner","delay","complete","BadgeIcon","icon","color","subtle"],"mappings":";;;;;;;AAQA,MAAMA,wBAAwB,GAAG,IAAI;SAOrBC,UAAUA,CAAkBC,KAA6B;EACrE,MAAM;IAAEC,KAAK;IAAEC;GAAO,GAAGF,KAAK;EAC9B,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE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C;IAAS,CACzD,CACb,CACE,CACN;AAEb;;;;"}
1
+ {"version":3,"file":"SaveStatus.js","sources":["../../../../../../../../../../src/components/Table3/components/Row/Editing/SaveStatus.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport clsx from 'clsx';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { BadgeIcon } from '../../../../BadgeIcon/BadgeIcon';\nimport { Spinner } from '../../../../Spinner/Spinner';\n\ntype SaveStatusProps<TType = unknown> = {\n rowId: string;\n table: ReactTable<TType>;\n};\n\nexport function SaveStatus<TType = unknown>(props: SaveStatusProps<TType>) {\n const { rowId, table } = props;\n const { texts } = useLocalization();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const status = tableMeta.editing.getRowStatus(rowId);\n\n const className = clsx(\n 'col-span-full sticky ml-auto right-0 top-0 -mb-[100%] z-10 h-8 bg-[inherit] flex items-center px-1.5 shadow-[-6px_0px_6px_var(--table-row-actions-shadow)]',\n {\n 'mt-0.5': tableMeta.rowHeight.height === 'short',\n 'mt-1': tableMeta.rowHeight.height === 'medium',\n 'mt-1.5': tableMeta.rowHeight.height === 'tall',\n 'mt-2': tableMeta.rowHeight.height === 'extra-tall',\n }\n );\n\n return (\n <td className=\"!contents\">\n <span className={className}>\n {status === 'saving' ? (\n <Tooltip title={texts.table3.editing.saving.progress}>\n <Spinner delay={0} className=\"mr-1 !h-5 !w-5\" />\n </Tooltip>\n ) : (\n <Tooltip title={texts.table3.editing.saving.complete}>\n <BadgeIcon icon=\"tick\" color=\"green\" subtle className=\"mr-1\" />\n </Tooltip>\n )}\n </span>\n </td>\n );\n}\n"],"names":["SaveStatus","props","rowId","table","texts","useLocalization","tableMeta","options","meta","status","editing","getRowStatus","className","clsx","rowHeight","height","React","Tooltip","title","table3","saving","progress","Spinner","delay","complete","BadgeIcon","icon","color","subtle"],"mappings":";;;;;;;SAagBA,UAAUA,CAAkBC,KAA6B;EACrE,MAAM;IAAEC,KAAK;IAAEC;GAAO,GAAGF,KAAK;EAC9B,MAAM;IAAEG;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAA6B;EAC7D,MAAMC,MAAM,GAAGH,SAAS,CAACI,OAAO,CAACC,YAAY,CAACT,KAAK,CAAC;EAEpD,MAAMU,SAAS,GAAGC,EAAI,CAClB,4JAA4J,EAC5J;IACI,QAAQ,EAAEP,SAAS,CAACQ,SAAS,CAACC,MAAM,KAAK,OAAO;IAChD,MAAM,EAAET,SAAS,CAACQ,SAAS,CAACC,MAAM,KAAK,QAAQ;IAC/C,QAAQ,EAAET,SAAS,CAACQ,SAAS,CAACC,MAAM,KAAK,MAAM;IAC/C,MAAM,EAAET,SAAS,CAACQ,SAAS,CAACC,MAAM,KAAK;GAC1C,CACJ;EAED,oBACIC;IAAIJ,SAAS,EAAC;kBACVI;IAAMJ,SAAS,EAAEA;KACZH,MAAM,KAAK,QAAQ,iBAChBO,6BAACC,OAAO;IAACC,KAAK,EAAEd,KAAK,CAACe,MAAM,CAACT,OAAO,CAACU,MAAM,CAACC;kBACxCL,6BAACM,OAAO;IAACC,KAAK,EAAE,CAAC;IAAEX,SAAS,EAAC;IAAmB,CAC1C,kBAEVI,6BAACC,OAAO;IAACC,KAAK,EAAEd,KAAK,CAACe,MAAM,CAACT,OAAO,CAACU,MAAM,CAACI;kBACxCR,6BAACS,SAAS;IAACC,IAAI,EAAC,MAAM;IAACC,KAAK,EAAC,OAAO;IAACC,MAAM;IAAChB,SAAS,EAAC;IAAS,CACzD,CACb,CACE,CACN;AAEb;;;;"}
@@ -0,0 +1,96 @@
1
+ import React__default from 'react';
2
+ import cn from 'clsx';
3
+ import { isElementTriggeredFromContainer } from '../../../../../utils/dom.js';
4
+ import { Row } from '../../../../../primitives/Table/Core/components/Row/Row.js';
5
+ import { TEMPORARY_ROW_ID_PREFIX } from '../../../util/editing.js';
6
+ import { RENDERERS } from '../../../useTable3.js';
7
+
8
+ function TemporaryRow(props) {
9
+ const {
10
+ createRowButtonRef,
11
+ table,
12
+ tableMeta,
13
+ tableRef
14
+ } = props;
15
+ const handleKeyDown = function (event) {
16
+ try {
17
+ const _temp2 = function () {
18
+ if (event.key === 'ArrowDown') {
19
+ event.preventDefault();
20
+ const _temp = function () {
21
+ if (!isElementTriggeredFromContainer(event.target, event.currentTarget)) {
22
+ return Promise.resolve(tableMeta.editing.saveChanges(table)).then(function (saved) {
23
+ if (saved) {
24
+ var _createRowButtonRef$c;
25
+ (_createRowButtonRef$c = createRowButtonRef.current) === null || _createRowButtonRef$c === void 0 ? void 0 : _createRowButtonRef$c.focus();
26
+ }
27
+ });
28
+ }
29
+ }();
30
+ if (_temp && _temp.then) return _temp.then(function () {});
31
+ } else if (event.key === 'ArrowUp') {
32
+ event.preventDefault();
33
+ event.stopPropagation();
34
+ if (tableRef.current) {
35
+ var _tableRef$current$que, _tableRef$current$que2, _tableRef$current$que3;
36
+ const availableRows = Array.from((_tableRef$current$que = tableRef.current.querySelectorAll(`tbody tr:not([data-row-id^='${TEMPORARY_ROW_ID_PREFIX}'])`)) !== null && _tableRef$current$que !== void 0 ? _tableRef$current$que : []);
37
+ const footerHeight = (_tableRef$current$que2 = (_tableRef$current$que3 = tableRef.current.querySelector('tfoot')) === null || _tableRef$current$que3 === void 0 ? void 0 : _tableRef$current$que3.getBoundingClientRect().height) !== null && _tableRef$current$que2 !== void 0 ? _tableRef$current$que2 : 0;
38
+ const newRowHeight = event.currentTarget.getBoundingClientRect().height;
39
+ const visibleHeight = tableRef.current.clientHeight - footerHeight - newRowHeight;
40
+ const tableTopOffset = tableRef.current.getBoundingClientRect().top;
41
+ let nextRowIndex;
42
+ // iterate available rows in reverse order, since we're working at the bottom
43
+ for (let index = availableRows.length - 1; index >= 0; index--) {
44
+ const rowRect = availableRows[index].getBoundingClientRect();
45
+ const topPlusHalfRow = rowRect.top + rowRect.height / 2;
46
+ if (topPlusHalfRow - tableTopOffset <= visibleHeight) {
47
+ nextRowIndex = index;
48
+ break;
49
+ }
50
+ }
51
+ if (nextRowIndex) {
52
+ tableMeta.rowActive.setRowActiveIndex(Number(availableRows[nextRowIndex < 0 ? 0 : nextRowIndex].getAttribute('data-row-index')));
53
+ }
54
+ }
55
+ }
56
+ }();
57
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
58
+ } catch (e) {
59
+ return Promise.reject(e);
60
+ }
61
+ };
62
+ const handleKeyDownCapture = event => {
63
+ if (event.key === 'ArrowLeft' && tableMeta.editing.lastFocusedCellIndex === 0) {
64
+ event.preventDefault();
65
+ event.stopPropagation();
66
+ } else if (event.key === 'ArrowRight' && tableMeta.editing.lastFocusedCellIndex) {
67
+ if (tableMeta.editing.lastFocusedCellIndex === table.getVisibleFlatColumns().length - 1) {
68
+ event.preventDefault();
69
+ event.stopPropagation();
70
+ }
71
+ }
72
+ };
73
+ const isScrolled = tableRef.current ? tableRef.current.scrollHeight > tableRef.current.clientHeight : false;
74
+ const className = cn('group/row border-grey-300 !sticky z-[22]', {
75
+ 'bottom-[calc(5rem_+_3px)] data-[row-editing-move]:bottom-[calc(5rem_+_2px)]': tableMeta.footer.isEnabled,
76
+ 'bottom-[calc(2.5rem_+_3px)] data-[row-editing-move]:bottom-[calc(2.5rem_+_2px)]': !tableMeta.footer.isEnabled,
77
+ 'border-t-2 shadow-[0px_-5px_20px_0px_rgba(0,0,0,0.1)] [&>td]:!border-b-0': isScrolled
78
+ });
79
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, table.getBottomRows().map(row => (/*#__PURE__*/React__default.createElement(Row, {
80
+ key: row.id,
81
+ cellRenderer: RENDERERS.cell,
82
+ index: tableMeta.length,
83
+ measureRow: () => null,
84
+ renderer: RENDERERS.row,
85
+ row: row,
86
+ table: table,
87
+ className: className,
88
+ onKeyDown: handleKeyDown,
89
+ onKeyDownCapture: handleKeyDownCapture,
90
+ // Row actions should only be hidden on temporary rows when editing is turned off
91
+ hideRowActions: !tableMeta.editing.isEditing
92
+ }))));
93
+ }
94
+
95
+ export { TemporaryRow };
96
+ //# sourceMappingURL=TemporaryRow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemporaryRow.js","sources":["../../../../../../../../../../src/components/Table3/components/Row/Editing/TemporaryRow.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport clsx from 'clsx';\nimport { Row } from '../../../../../primitives/Table/Core/components/Row/Row';\nimport { RENDERERS } from '../../../useTable3';\nimport { isElementTriggeredFromContainer } from '../../../../../utils/dom';\nimport { TableRef } from '../../../../../primitives/Table/types';\nimport { TEMPORARY_ROW_ID_PREFIX } from '../../../util/editing';\n\ntype TemporaryRowProps<TType = unknown> = {\n createRowButtonRef: React.RefObject<HTMLButtonElement>;\n table: ReactTable<TType>;\n tableMeta: ReactTableMeta<TType>;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function TemporaryRow<TType = unknown>(props: TemporaryRowProps<TType>) {\n const { createRowButtonRef, table, tableMeta, tableRef } = props;\n\n const handleKeyDown = async (event: React.KeyboardEvent<HTMLTableRowElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n\n if (!isElementTriggeredFromContainer(event.target as Element, event.currentTarget)) {\n const saved = await tableMeta.editing.saveChanges(table);\n\n if (saved) {\n createRowButtonRef.current?.focus();\n }\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n\n if (tableRef.current) {\n const availableRows = Array.from(\n tableRef.current.querySelectorAll(`tbody tr:not([data-row-id^='${TEMPORARY_ROW_ID_PREFIX}'])`) ?? []\n );\n\n const footerHeight = tableRef.current.querySelector('tfoot')?.getBoundingClientRect().height ?? 0;\n const newRowHeight = event.currentTarget.getBoundingClientRect().height;\n const visibleHeight = tableRef.current.clientHeight - footerHeight - newRowHeight;\n const tableTopOffset = tableRef.current.getBoundingClientRect().top;\n\n let nextRowIndex;\n\n // iterate available rows in reverse order, since we're working at the bottom\n for (let index = availableRows.length - 1; index >= 0; index--) {\n const rowRect = availableRows[index].getBoundingClientRect();\n const topPlusHalfRow = rowRect.top + rowRect.height / 2;\n\n if (topPlusHalfRow - tableTopOffset <= visibleHeight) {\n nextRowIndex = index;\n break;\n }\n }\n\n if (nextRowIndex) {\n tableMeta.rowActive.setRowActiveIndex(\n Number(availableRows[nextRowIndex < 0 ? 0 : nextRowIndex].getAttribute('data-row-index'))\n );\n }\n }\n }\n };\n\n const handleKeyDownCapture = (event: React.KeyboardEvent<HTMLTableRowElement>) => {\n if (event.key === 'ArrowLeft' && tableMeta.editing.lastFocusedCellIndex === 0) {\n event.preventDefault();\n event.stopPropagation();\n } else if (event.key === 'ArrowRight' && tableMeta.editing.lastFocusedCellIndex) {\n if (tableMeta.editing.lastFocusedCellIndex === table.getVisibleFlatColumns().length - 1) {\n event.preventDefault();\n event.stopPropagation();\n }\n }\n };\n\n const isScrolled = tableRef.current ? tableRef.current.scrollHeight > tableRef.current.clientHeight : false;\n\n const className = clsx('group/row border-grey-300 !sticky z-[22]', {\n 'bottom-[calc(5rem_+_3px)] data-[row-editing-move]:bottom-[calc(5rem_+_2px)]': tableMeta.footer.isEnabled,\n 'bottom-[calc(2.5rem_+_3px)] data-[row-editing-move]:bottom-[calc(2.5rem_+_2px)]': !tableMeta.footer.isEnabled,\n 'border-t-2 shadow-[0px_-5px_20px_0px_rgba(0,0,0,0.1)] [&>td]:!border-b-0': isScrolled,\n });\n\n return (\n <>\n {table.getBottomRows().map(row => (\n <Row<TType>\n key={row.id}\n cellRenderer={RENDERERS.cell}\n index={tableMeta.length}\n measureRow={() => null}\n renderer={RENDERERS.row}\n row={row}\n table={table}\n className={className}\n onKeyDown={handleKeyDown}\n onKeyDownCapture={handleKeyDownCapture}\n // Row actions should only be hidden on temporary rows when editing is turned off\n hideRowActions={!tableMeta.editing.isEditing}\n />\n ))}\n </>\n );\n}\n"],"names":["TemporaryRow","props","createRowButtonRef","table","tableMeta","tableRef","handleKeyDown","event","key","preventDefault","_temp","isElementTriggeredFromContainer","target","currentTarget","Promise","resolve","editing","saveChanges","then","saved","_createRowButtonRef$c","current","focus","stopPropagation","_tableRef$current$que","_tableRef$current$que2","_tableRef$current$que3","availableRows","Array","from","querySelectorAll","TEMPORARY_ROW_ID_PREFIX","footerHeight","querySelector","getBoundingClientRect","height","newRowHeight","visibleHeight","clientHeight","tableTopOffset","top","nextRowIndex","index","length","rowRect","topPlusHalfRow","rowActive","setRowActiveIndex","Number","getAttribute","_temp2","e","reject","handleKeyDownCapture","lastFocusedCellIndex","getVisibleFlatColumns","isScrolled","scrollHeight","className","clsx","footer","isEnabled","React","getBottomRows","map","row","Row","id","cellRenderer","RENDERERS","cell","measureRow","renderer","onKeyDown","onKeyDownCapture","hideRowActions","isEditing"],"mappings":";;;;;;;SAgBgBA,YAAYA,CAAkBC,KAA+B;EACzE,MAAM;IAAEC,kBAAkB;IAAEC,KAAK;IAAEC,SAAS;IAAEC;GAAU,GAAGJ,KAAK;EAEhE,MAAMK,aAAa,aAAUC,KAA+C;IAAA;;YACpEA,KAAK,CAACC,GAAG,KAAK,WAAW;UACzBD,KAAK,CAACE,cAAc,EAAE;UAAC,MAAAC,KAAA;YAAA,IAEnB,CAACC,+BAA+B,CAACJ,KAAK,CAACK,MAAiB,EAAEL,KAAK,CAACM,aAAa,CAAC;cAAA,OAAAC,OAAA,CAAAC,OAAA,CAC1DX,SAAS,CAACY,OAAO,CAACC,WAAW,CAACd,KAAK,CAAC,EAAAe,IAAA,WAAlDC,KAAK;gBAAA,IAEPA,KAAK;kBAAA,IAAAC,qBAAA;kBACL,CAAAA,qBAAA,GAAAlB,kBAAkB,CAACmB,OAAO,cAAAD,qBAAA,uBAA1BA,qBAAA,CAA4BE,KAAK,EAAE;;;;;UAAC,IAAAZ,KAAA,IAAAA,KAAA,CAAAQ,IAAA,SAAAR,KAAA,CAAAQ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C;EAEF,oBACIM,4DACK3D,KAAK,CAAC4D,aAAa,EAAE,CAACC,GAAG,CAACC,GAAG,kBAC1BH,6BAACI,GAAG;IACA1D,GAAG,EAAEyD,GAAG,CAACE,EAAE;IACXC,YAAY,EAAEC,SAAS,CAACC,IAAI;IAC5B5B,KAAK,EAAEtC,SAAS,CAACuC,MAAM;IACvB4B,UAAU,EAAEA,MAAM,IAAI;IACtBC,QAAQ,EAAEH,SAAS,CAACJ,GAAG;IACvBA,GAAG,EAAEA,GAAG;IACR9D,KAAK,EAAEA,KAAK;IACZuD,SAAS,EAAEA,SAAS;IACpBe,SAAS,EAAEnE,aAAa;IACxBoE,gBAAgB,EAAErB,oBAAoB;;IAEtCsB,cAAc,EAAE,CAACvE,SAAS,CAACY,OAAO,CAAC4D;IACrC,CACL,CAAC,CACH;AAEX;;;;"}
@@ -1,7 +1,9 @@
1
1
  import React__default from 'react';
2
- import { setDataFocusAttribute } from '../../../../utils/dom.js';
2
+ import { setDataFocusAttribute, isElementTriggeredFromContainer } from '../../../../utils/dom.js';
3
3
  import { DisplayRow } from '../../../../primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js';
4
4
  import { useAugmentedFocusManager } from '../../../../primitives/Table/Core/components/Body/util.js';
5
+ import { isTemporaryRow } from '../../util/editing.js';
6
+ import { DiscardChangesConfirmationDialog } from '../Editing/DiscardChangesConfirmationDialog.js';
5
7
  import { SaveStatus } from './Editing/SaveStatus.js';
6
8
 
7
9
  function Row(props) {
@@ -30,15 +32,46 @@ function Row(props) {
30
32
  }
31
33
  }
32
34
  }, [tableMeta.editing.isEditing, isActiveRow]);
35
+ const rowStatus = tableMeta.editing.getRowStatus(row.id);
36
+ // discard new row
37
+ const [showDiscardDialog, setShowDiscardDialog] = React__default.useState(false);
38
+ function handleDiscard() {
39
+ tableMeta.editing.discardChanges(row.id, table);
40
+ requestAnimationFrame(() => {
41
+ if (isTemporaryRow(row.id)) {
42
+ var _tableMeta$editing$cr;
43
+ (_tableMeta$editing$cr = tableMeta.editing.createRowButtonRef.current) === null || _tableMeta$editing$cr === void 0 ? void 0 : _tableMeta$editing$cr.focus();
44
+ } else {
45
+ focusManager.focusFirst();
46
+ }
47
+ });
48
+ }
49
+ function handleKeyDown(event) {
50
+ if (props.onKeyDown) {
51
+ props.onKeyDown(event);
52
+ }
53
+ if (event.isDefaultPrevented() || event.isPropagationStopped()) {
54
+ return;
55
+ }
56
+ if (event.key === 'Escape' && tableMeta.editing.hasChanges(row.id) && !isElementTriggeredFromContainer(event.target, event.currentTarget)) {
57
+ event.preventDefault();
58
+ setShowDiscardDialog(true);
59
+ }
60
+ }
33
61
  const attributes = {
34
- 'data-row-editing-invalid': tableMeta.editing.isEnabled && tableMeta.editing.hasRowErrors(row.id) ? !tableMeta.editing.hasRowErrorsSeen(row.id) ? 'unseen' : true : undefined,
35
- 'data-row-editing-status': tableMeta.editing.isEnabled && tableMeta.editing.getRowSaveStatus(row.id) ? tableMeta.editing.getRowSaveStatus(row.id) : undefined,
36
- onFocus: handleFocus
62
+ 'data-row-editing-invalid': tableMeta.editing.hasRowErrors(row.id) ? !tableMeta.editing.hasRowErrorsShownInAlert(row.id) ? 'unseen' : true : undefined,
63
+ 'data-row-editing-status': rowStatus,
64
+ onFocus: handleFocus,
65
+ onKeyDown: handleKeyDown
37
66
  };
38
- return /*#__PURE__*/React__default.createElement(DisplayRow, Object.assign({}, props, attributes), tableMeta.editing.getRowSaveStatus(row.id) ? /*#__PURE__*/React__default.createElement(SaveStatus, {
67
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(DisplayRow, Object.assign({}, props, attributes), rowStatus === 'saving' || rowStatus === 'saved' ? /*#__PURE__*/React__default.createElement(SaveStatus, {
39
68
  rowId: row.id,
40
69
  table: table
41
- }) : null);
70
+ }) : null), /*#__PURE__*/React__default.createElement(DiscardChangesConfirmationDialog, {
71
+ open: showDiscardDialog,
72
+ onChange: setShowDiscardDialog,
73
+ onDiscard: handleDiscard
74
+ }));
42
75
  }
43
76
 
44
77
  export { Row };
@@ -1 +1 @@
1
- {"version":3,"file":"Row.js","sources":["../../../../../../../../../src/components/Table3/components/Row/Row.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { DisplayRow, DisplayRowProps } from '../../../../primitives/Table/Core/components/Row/BuiltIns/DisplayRow';\nimport { SaveStatus } from './Editing/SaveStatus';\nimport { useAugmentedFocusManager } from '../../../../primitives/Table/Core/components/Body/util';\nimport { setDataFocusAttribute } from '../../../../utils/dom';\n\nexport function Row<TType = unknown>(props: DisplayRowProps<TType>) {\n const { row, index, table } = props;\n const focusManager = useAugmentedFocusManager();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === index;\n\n React.useEffect(() => {\n if (tableMeta.editing.isEditing && isActiveRow && tableMeta.editing.lastFocusedCellIndex === undefined) {\n const element = focusManager.focusFirst();\n if (element) {\n setDataFocusAttribute(element);\n }\n }\n }, [tableMeta.editing.isEditing, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.lastFocusedCellIndex]);\n\n const handleFocus = React.useCallback(\n (event: React.FocusEvent<HTMLTableRowElement>) => {\n if (tableMeta.editing.isEditing) {\n const cellIndex = Number(event.target.closest('td')?.getAttribute('data-cell-index') ?? undefined);\n\n if (!isNaN(cellIndex)) {\n tableMeta.editing.setLastFocusedCellIndex(Number(cellIndex));\n }\n }\n },\n [tableMeta.editing.isEditing, isActiveRow]\n );\n\n const attributes = {\n 'data-row-editing-invalid':\n tableMeta.editing.isEnabled && tableMeta.editing.hasRowErrors(row.id)\n ? !tableMeta.editing.hasRowErrorsSeen(row.id)\n ? 'unseen'\n : true\n : undefined,\n 'data-row-editing-status':\n tableMeta.editing.isEnabled && tableMeta.editing.getRowSaveStatus(row.id)\n ? tableMeta.editing.getRowSaveStatus(row.id)\n : undefined,\n onFocus: handleFocus,\n };\n\n return (\n <DisplayRow<TType> {...props} {...attributes}>\n {tableMeta.editing.getRowSaveStatus(row.id) ? <SaveStatus rowId={row.id} table={table} /> : null}\n </DisplayRow>\n );\n}\n"],"names":["Row","props","row","index","table","focusManager","useAugmentedFocusManager","tableMeta","options","meta","isActiveRow","rowActive","rowActiveIndex","React","useEffect","editing","isEditing","lastFocusedCellIndex","undefined","element","focusFirst","setDataFocusAttribute","handleFocus","useCallback","event","_event$target$closest","_event$target$closest2","cellIndex","Number","target","closest","getAttribute","isNaN","setLastFocusedCellIndex","attributes","isEnabled","hasRowErrors","id","hasRowErrorsSeen","getRowSaveStatus","onFocus","DisplayRow","SaveStatus","rowId"],"mappings":";;;;;;SAOgBA,GAAGA,CAAkBC,KAA6B;EAC9D,MAAM;IAAEC,GAAG;IAAEC,KAAK;IAAEC;GAAO,GAAGH,KAAK;EACnC,MAAMI,YAAY,GAAGC,wBAAwB,EAAE;EAC/C,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAA6B;EAC7D,MAAMC,WAAW,GAAGH,SAAS,CAACI,SAAS,CAACC,cAAc,KAAKT,KAAK;EAEhEU,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIP,SAAS,CAACQ,OAAO,CAACC,SAAS,IAAIN,WAAW,IAAIH,SAAS,CAACQ,OAAO,CAACE,oBAAoB,KAAKC,SAAS,EAAE;MACpG,MAAMC,OAAO,GAAGd,YAAY,CAACe,UAAU,EAAE;MACzC,IAAID,OAAO,EAAE;QACTE,qBAAqB,CAACF,OAAO,CAAC;;;GAGzC,EAAE,CAACZ,SAAS,CAACQ,OAAO,CAACC,SAAS,EAAET,SAAS,CAACI,SAAS,CAACC,cAAc,EAAEL,SAAS,CAACQ,OAAO,CAACE,oBAAoB,CAAC,CAAC;EAE7G,MAAMK,WAAW,GAAGT,cAAK,CAACU,WAAW,CAChCC,KAA4C;IACzC,IAAIjB,SAAS,CAACQ,OAAO,CAACC,SAAS,EAAE;MAAA,IAAAS,qBAAA,EAAAC,sBAAA;MA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"Row.js","sources":["../../../../../../../../../src/components/Table3/components/Row/Row.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { DisplayRow, DisplayRowProps } from '../../../../primitives/Table/Core/components/Row/BuiltIns/DisplayRow';\nimport { SaveStatus } from './Editing/SaveStatus';\nimport { useAugmentedFocusManager } from '../../../../primitives/Table/Core/components/Body/util';\nimport { isElementTriggeredFromContainer, setDataFocusAttribute } from '../../../../utils/dom';\nimport { DiscardChangesConfirmationDialog } from '../Editing/DiscardChangesConfirmationDialog';\nimport { isTemporaryRow } from '../../util/editing';\n\nexport function Row<TType = unknown>(props: DisplayRowProps<TType>) {\n const { row, index, table } = props;\n const focusManager = useAugmentedFocusManager();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isActiveRow = tableMeta.rowActive.rowActiveIndex === index;\n\n React.useEffect(() => {\n if (tableMeta.editing.isEditing && isActiveRow && tableMeta.editing.lastFocusedCellIndex === undefined) {\n const element = focusManager.focusFirst();\n if (element) {\n setDataFocusAttribute(element);\n }\n }\n }, [tableMeta.editing.isEditing, tableMeta.rowActive.rowActiveIndex, tableMeta.editing.lastFocusedCellIndex]);\n\n const handleFocus = React.useCallback(\n (event: React.FocusEvent<HTMLTableRowElement>) => {\n if (tableMeta.editing.isEditing) {\n const cellIndex = Number(event.target.closest('td')?.getAttribute('data-cell-index') ?? undefined);\n\n if (!isNaN(cellIndex)) {\n tableMeta.editing.setLastFocusedCellIndex(Number(cellIndex));\n }\n }\n },\n [tableMeta.editing.isEditing, isActiveRow]\n );\n\n const rowStatus = tableMeta.editing.getRowStatus(row.id);\n\n // discard new row\n const [showDiscardDialog, setShowDiscardDialog] = React.useState(false);\n\n function handleDiscard() {\n tableMeta.editing.discardChanges(row.id, table);\n requestAnimationFrame(() => {\n if (isTemporaryRow(row.id)) {\n tableMeta.editing.createRowButtonRef.current?.focus();\n } else {\n focusManager.focusFirst();\n }\n });\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLTableRowElement>) {\n if (props.onKeyDown) {\n props.onKeyDown(event);\n }\n\n if (event.isDefaultPrevented() || event.isPropagationStopped()) {\n return;\n }\n\n if (\n event.key === 'Escape' &&\n tableMeta.editing.hasChanges(row.id) &&\n !isElementTriggeredFromContainer(event.target as HTMLElement, event.currentTarget)\n ) {\n event.preventDefault();\n setShowDiscardDialog(true);\n }\n }\n\n const attributes = {\n 'data-row-editing-invalid': tableMeta.editing.hasRowErrors(row.id)\n ? !tableMeta.editing.hasRowErrorsShownInAlert(row.id)\n ? 'unseen'\n : true\n : undefined,\n 'data-row-editing-status': rowStatus,\n onFocus: handleFocus,\n onKeyDown: handleKeyDown,\n };\n\n return (\n <>\n <DisplayRow<TType> {...props} {...attributes}>\n {rowStatus === 'saving' || rowStatus === 'saved' ? <SaveStatus rowId={row.id} table={table} /> : null}\n </DisplayRow>\n <DiscardChangesConfirmationDialog\n open={showDiscardDialog}\n onChange={setShowDiscardDialog}\n onDiscard={handleDiscard}\n />\n </>\n );\n}\n"],"names":["Row","props","row","index","table","focusManager","useAugmentedFocusManager","tableMeta","options","meta","isActiveRow","rowActive","rowActiveIndex","React","useEffect","editing","isEditing","lastFocusedCellIndex","undefined","element","focusFirst","setDataFocusAttribute","handleFocus","useCallback","event","_event$target$closest","_event$target$closest2","cellIndex","Number","target","closest","getAttribute","isNaN","setLastFocusedCellIndex","rowStatus","getRowStatus","id","showDiscardDialog","setShowDiscardDialog","useState","handleDiscard","discardChanges","requestAnimationFrame","isTemporaryRow","_tableMeta$editing$cr","createRowButtonRef","current","focus","handleKeyDown","onKeyDown","isDefaultPrevented","isPropagationStopped","key","hasChanges","isElementTriggeredFromContainer","currentTarget","preventDefault","attributes","hasRowErrors","hasRowErrorsShownInAlert","onFocus","DisplayRow","SaveStatus","rowId","DiscardChangesConfirmationDialog","open","onChange","onDiscard"],"mappings":";;;;;;;;SASgBA,GAAGA,CAAkBC,KAA6B;EAC9D,MAAM;IAAEC,GAAG;IAA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