@economic/taco 2.12.1 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (231) hide show
  1. package/dist/components/Field/Field.d.ts +4 -2
  2. package/dist/components/Icon/components/Location.d.ts +3 -0
  3. package/dist/components/Icon/components/index.d.ts +1 -1
  4. package/dist/components/Input/Input.d.ts +1 -1
  5. package/dist/components/Menu/components/Item.d.ts +1 -1
  6. package/dist/components/Menu/components/Link.d.ts +1 -1
  7. package/dist/components/Navigation2/components/Link.d.ts +1 -1
  8. package/dist/components/Provider/Localization.d.ts +1 -113
  9. package/dist/components/Select2/components/Option.d.ts +7 -5
  10. package/dist/components/Select2/components/Search.d.ts +1 -1
  11. package/dist/components/Table3/Table3.d.ts +9 -1
  12. package/dist/components/Table3/components/columns/header/Group.d.ts +15 -0
  13. package/dist/components/Table3/components/columns/header/Header.d.ts +5 -0
  14. package/dist/components/Table3/components/columns/internal/EditingActions.d.ts +1 -1
  15. package/dist/components/Table3/components/columns/styles.d.ts +2 -2
  16. package/dist/components/Table3/components/toolbar/Filter/filters/components/Filter.d.ts +4 -4
  17. package/dist/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.d.ts +3 -2
  18. package/dist/components/Table3/components/toolbar/Filter/filters/components/Placeholder.d.ts +3 -2
  19. package/dist/components/Table3/components/toolbar/FontSize.d.ts +4 -0
  20. package/dist/components/Table3/hooks/features/useHeaderOffsetStyle.d.ts +3 -0
  21. package/dist/components/Table3/hooks/useCssGrid.d.ts +2 -1
  22. package/dist/components/Table3/hooks/useTable.d.ts +1 -1
  23. package/dist/components/Table3/types.d.ts +8 -1
  24. package/dist/components/Tag/Tag.d.ts +1 -1
  25. package/dist/esm/index.css +24 -6
  26. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js +1 -1
  27. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js.map +1 -1
  28. package/dist/esm/packages/taco/src/components/Field/Field.js +6 -4
  29. package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
  30. package/dist/esm/packages/taco/src/components/Icon/components/Location.js +17 -0
  31. package/dist/esm/packages/taco/src/components/Icon/components/Location.js.map +1 -0
  32. package/dist/esm/packages/taco/src/components/Icon/components/index.js +2 -0
  33. package/dist/esm/packages/taco/src/components/Icon/components/index.js.map +1 -1
  34. package/dist/esm/packages/taco/src/components/Provider/Localization.js +1 -110
  35. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  36. package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +1 -1
  37. package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
  38. package/dist/esm/packages/taco/src/components/Select2/components/Option.js +13 -6
  39. package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
  40. package/dist/esm/packages/taco/src/components/Select2/components/Search.js +1 -1
  41. package/dist/esm/packages/taco/src/components/Select2/components/Search.js.map +1 -1
  42. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +7 -6
  43. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  44. package/dist/esm/packages/taco/src/components/Table3/Table3.js +29 -11
  45. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  46. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +2 -5
  47. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
  48. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +1 -4
  49. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
  50. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js.map +1 -1
  51. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Group.js +70 -0
  52. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Group.js.map +1 -0
  53. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js +26 -8
  54. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js.map +1 -1
  55. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js +6 -1
  56. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js.map +1 -1
  57. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +3 -2
  58. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
  59. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js +13 -9
  60. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js.map +1 -1
  61. package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js +14 -2
  62. package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js.map +1 -1
  63. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js +10 -7
  64. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js.map +1 -1
  65. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +15 -8
  66. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -1
  67. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js +2 -2
  68. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js.map +1 -1
  69. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js +25 -4
  70. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js.map +1 -1
  71. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js +0 -1
  72. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js.map +1 -1
  73. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterValue.js +5 -3
  74. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterValue.js.map +1 -1
  75. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js +2 -2
  76. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js.map +1 -1
  77. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/FontSize.js +9 -4
  78. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/FontSize.js.map +1 -1
  79. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +2 -3
  80. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -1
  81. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/RowHeight.js +3 -2
  82. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/RowHeight.js.map +1 -1
  83. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Settings.js +1 -1
  84. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useHeaderOffsetStyle.js +24 -0
  85. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useHeaderOffsetStyle.js.map +1 -0
  86. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js +6 -7
  87. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js.map +1 -1
  88. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js +48 -0
  89. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map +1 -1
  90. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js +34 -9
  91. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -1
  92. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js +6 -5
  93. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js.map +1 -1
  94. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js +11 -9
  95. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js.map +1 -1
  96. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
  97. package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
  98. package/dist/esm/packages/taco/src/index.js +1 -2
  99. package/dist/esm/packages/taco/src/index.js.map +1 -1
  100. package/dist/esm/packages/taco/src/utils/dom.js +1 -2
  101. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  102. package/dist/index.css +24 -6
  103. package/dist/index.d.ts +0 -1
  104. package/dist/taco.cjs.development.js +697 -4100
  105. package/dist/taco.cjs.development.js.map +1 -1
  106. package/dist/taco.cjs.production.min.js +1 -1
  107. package/dist/taco.cjs.production.min.js.map +1 -1
  108. package/package.json +2 -2
  109. package/tailwind.config.js +3 -0
  110. package/types.json +14334 -32345
  111. package/dist/components/Table2/Table2.d.ts +0 -130
  112. package/dist/components/Table2/components/BatchActionsMenu.d.ts +0 -10
  113. package/dist/components/Table2/components/ColumnSettingsButton.d.ts +0 -6
  114. package/dist/components/Table2/components/EditModeButton.d.ts +0 -8
  115. package/dist/components/Table2/components/RowDensityButton.d.ts +0 -7
  116. package/dist/components/Table2/components/Search.d.ts +0 -3
  117. package/dist/components/Table2/components/ShortcutsGuideButton.d.ts +0 -7
  118. package/dist/components/Table2/components/column/Base.d.ts +0 -14
  119. package/dist/components/Table2/components/column/Cell.d.ts +0 -15
  120. package/dist/components/Table2/components/column/Footer.d.ts +0 -9
  121. package/dist/components/Table2/components/column/Header.d.ts +0 -11
  122. package/dist/components/Table2/components/column/Indicator.d.ts +0 -17
  123. package/dist/components/Table2/components/column/ValidationError.d.ts +0 -5
  124. package/dist/components/Table2/components/column/utils.d.ts +0 -3
  125. package/dist/components/Table2/components/filters/FiltersButton.d.ts +0 -7
  126. package/dist/components/Table2/components/filters/components/Column.d.ts +0 -11
  127. package/dist/components/Table2/components/filters/components/ColumnFilter.d.ts +0 -10
  128. package/dist/components/Table2/components/filters/components/Comparator.d.ts +0 -11
  129. package/dist/components/Table2/components/filters/components/EmptyFilter.d.ts +0 -13
  130. package/dist/components/Table2/components/filters/components/InferredControl.d.ts +0 -10
  131. package/dist/components/Table2/components/row/Context.d.ts +0 -24
  132. package/dist/components/Table2/components/row/ExpandedRow.d.ts +0 -6
  133. package/dist/components/Table2/components/row/Row.d.ts +0 -2
  134. package/dist/components/Table2/hooks/listeners/useActiveCellStateListener.d.ts +0 -3
  135. package/dist/components/Table2/hooks/listeners/useActiveRowStateListener.d.ts +0 -3
  136. package/dist/components/Table2/hooks/listeners/useColumnOffsetStateListener.d.ts +0 -3
  137. package/dist/components/Table2/hooks/listeners/useFilterStateListener.d.ts +0 -3
  138. package/dist/components/Table2/hooks/listeners/useRowSelectionListener.d.ts +0 -3
  139. package/dist/components/Table2/hooks/listeners/useSettingsStateListener.d.ts +0 -3
  140. package/dist/components/Table2/hooks/useActiveCell.d.ts +0 -26
  141. package/dist/components/Table2/hooks/useActiveRow.d.ts +0 -10
  142. package/dist/components/Table2/hooks/useColumnDefinitions.d.ts +0 -37
  143. package/dist/components/Table2/hooks/useEditMode.d.ts +0 -28
  144. package/dist/components/Table2/hooks/useGridTemplate.d.ts +0 -2
  145. package/dist/components/Table2/hooks/useTable.d.ts +0 -46
  146. package/dist/components/Table2/hooks/useTableShortcuts.d.ts +0 -2
  147. package/dist/components/Table2/hooks/useVirtualiser.d.ts +0 -23
  148. package/dist/components/Table2/types.d.ts +0 -148
  149. package/dist/components/Table2/utilities/cell.d.ts +0 -14
  150. package/dist/components/Table2/utilities/columns.d.ts +0 -16
  151. package/dist/components/Table2/utilities/filterFn.d.ts +0 -3
  152. package/dist/esm/packages/taco/src/components/Table2/Table2.js +0 -422
  153. package/dist/esm/packages/taco/src/components/Table2/Table2.js.map +0 -1
  154. package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js +0 -83
  155. package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js.map +0 -1
  156. package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js +0 -116
  157. package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js.map +0 -1
  158. package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js +0 -81
  159. package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js.map +0 -1
  160. package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js +0 -47
  161. package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js.map +0 -1
  162. package/dist/esm/packages/taco/src/components/Table2/components/Search.js +0 -62
  163. package/dist/esm/packages/taco/src/components/Table2/components/Search.js.map +0 -1
  164. package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js +0 -32
  165. package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js.map +0 -1
  166. package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js +0 -605
  167. package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js.map +0 -1
  168. package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js +0 -32
  169. package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js.map +0 -1
  170. package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js +0 -243
  171. package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js.map +0 -1
  172. package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js +0 -73
  173. package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js.map +0 -1
  174. package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js +0 -30
  175. package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js.map +0 -1
  176. package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js +0 -39
  177. package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js.map +0 -1
  178. package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js +0 -155
  179. package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js.map +0 -1
  180. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js +0 -31
  181. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js.map +0 -1
  182. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js +0 -129
  183. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js.map +0 -1
  184. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js +0 -68
  185. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js.map +0 -1
  186. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/EmptyFilter.js +0 -63
  187. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/EmptyFilter.js.map +0 -1
  188. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js +0 -99
  189. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js.map +0 -1
  190. package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js +0 -58
  191. package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js.map +0 -1
  192. package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js +0 -36
  193. package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js.map +0 -1
  194. package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js +0 -44
  195. package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js.map +0 -1
  196. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js +0 -19
  197. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js.map +0 -1
  198. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js +0 -28
  199. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js.map +0 -1
  200. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useFilterStateListener.js +0 -12
  201. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useFilterStateListener.js.map +0 -1
  202. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js +0 -18
  203. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js.map +0 -1
  204. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js +0 -25
  205. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js.map +0 -1
  206. package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js +0 -33
  207. package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js.map +0 -1
  208. package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js +0 -122
  209. package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js.map +0 -1
  210. package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js +0 -112
  211. package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js.map +0 -1
  212. package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js +0 -34
  213. package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js.map +0 -1
  214. package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js +0 -222
  215. package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js.map +0 -1
  216. package/dist/esm/packages/taco/src/components/Table2/hooks/useTableShortcuts.js +0 -46
  217. package/dist/esm/packages/taco/src/components/Table2/hooks/useTableShortcuts.js.map +0 -1
  218. package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js +0 -48
  219. package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js.map +0 -1
  220. package/dist/esm/packages/taco/src/components/Table2/types.js +0 -18
  221. package/dist/esm/packages/taco/src/components/Table2/types.js.map +0 -1
  222. package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js +0 -41
  223. package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js.map +0 -1
  224. package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js +0 -387
  225. package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js.map +0 -1
  226. package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js +0 -100
  227. package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js.map +0 -1
  228. package/dist/esm/packages/taco/src/components/Truncate/Truncate.js +0 -32
  229. package/dist/esm/packages/taco/src/components/Truncate/Truncate.js.map +0 -1
  230. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js +0 -20
  231. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"Base.js","sources":["../../../../../../../../../src/components/Table2/components/column/Base.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Column as RTColumn, Table as RTTable, TableMeta } from '@tanstack/react-table';\nimport { getCellAlignmentClasses, getFrozenShadowClasses } from '../../utilities/cell';\n\nexport type ColumnBaseProps<TType = any> = React.HTMLAttributes<HTMLDivElement> & {\n column: RTColumn<TType, any>;\n frozenColumnIds: string[];\n scrolled: boolean;\n table: RTTable<TType>;\n};\n\nexport const ColumnBase = React.forwardRef<HTMLDivElement, ColumnBaseProps>(function Table2ColumnBase(props, ref) {\n const { column, frozenColumnIds, scrolled, style, table, ...attributes } = props;\n const isFrozenColumn = !!column.getIsPinned();\n const meta = table.options.meta as TableMeta<any>;\n const left = meta.columnOffsets[column.id];\n\n const className = cn(\n 'border-grey-300',\n getCellAlignmentClasses(column.columnDef.meta?.align),\n getFrozenShadowClasses(column, frozenColumnIds, scrolled),\n {\n 'cursor-pointer': !!attributes.onClick,\n },\n attributes.className\n );\n\n return (\n <div\n {...attributes}\n className={className}\n style={{ ...style, left: isFrozenColumn && Number.isInteger(left) ? left : undefined }}\n ref={ref}\n />\n );\n});\n"],"names":["ColumnBase","React","forwardRef","Table2ColumnBase","props","ref","column","frozenColumnIds","scrolled","style","table","attributes","isFrozenColumn","getIsPinned","meta","options","left","columnOffsets","id","className","cn","getCellAlignmentClasses","_column$columnDef$met","columnDef","align","getFrozenShadowClasses","onClick","Number","isInteger","undefined"],"mappings":";;;;MAYaA,UAAU,gBAAGC,cAAK,CAACC,UAAU,CAAkC,SAASC,gBAAgBA,CAACC,KAAK,EAAEC,GAAG;;EAC5G,MAAM;IAAEC,MAAM;IAAEC,eAAe;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGP,KAAK;EAChF,MAAMQ,cAAc,GAAG,CAAC,CAACN,MAAM,CAACO,WAAW,EAAE;EAC7C,MAAMC,IAAI,GAAGJ,KAAK,CAACK,OAAO,CAACD,IAAsB;EACjD,MAAME,IAAI,GAAGF,IAAI,CAACG,aAAa,CAACX,MAAM,CAACY,EAAE,CAAC;EAE1C,MAAMC,SAAS,GAAGC,EAAE,CAChB,iBAAiB,EACjBC,uBAAuB,EAAAC,qBAAA,GAAChB,MAAM,CAACiB,SAAS,CAACT,IAAI,cAAAQ,qBAAA,uBAArBA,qBAAA,CAAuBE,KAAK,CAAC,EACrDC,sBAAsB,CAACnB,MAAM,EAAEC,eAAe,EAAEC,QAAQ,CAAC,EACzD;IACI,gBAAgB,EAAE,CAAC,CAACG,UAAU,CAACe;GAClC,EACDf,UAAU,CAACQ,SAAS,CACvB;EAED,oBACIlB,sDACQU,UAAU;IACdQ,SAAS,EAAEA,SAAS;IACpBV,KAAK,EAAE;MAAE,GAAGA,KAAK;MAAEO,IAAI,EAAEJ,cAAc,IAAIe,MAAM,CAACC,SAAS,CAACZ,IAAI,CAAC,GAAGA,IAAI,GAAGa;KAAW;IACtFxB,GAAG,EAAEA;KACP;AAEV,CAAC;;;;"}
@@ -1,605 +0,0 @@
1
- import React__default from 'react';
2
- import cn from 'classnames';
3
- import { useMergedRef } from '../../../../hooks/useMergedRef.js';
4
- import { Input } from '../../../Input/Input.js';
5
- import { Datepicker } from '../../../Datepicker/Datepicker.js';
6
- import { _catch } from '../../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
7
- import { Switch } from '../../../Switch/Switch.js';
8
- import { flexRender } from '@tanstack/react-table';
9
- import { useRowContext } from '../row/Context.js';
10
- import { isInternalColumn } from '../../utilities/columns.js';
11
- import { getCellSizingClasses, isKeyboardFocusableElement, getCellAlignmentClasses } from '../../utilities/cell.js';
12
- import { ColumnBase } from './Base.js';
13
- import { globalFilterFn, columnFilterFn } from '../../utilities/filterFn.js';
14
- import { MOVE_DIR } from '../../hooks/useEditMode.js';
15
- import { IndicatorReason, Indicator } from './Indicator.js';
16
- import { ValidationError } from './ValidationError.js';
17
- import { clickableNodeNames, hasChanged, willRowMoveAfterSorting } from './utils.js';
18
-
19
- const Cell = function Cell(props) {
20
- var _cell$column$columnDe, _cell$column$columnDe2, _table$options$meta;
21
- const {
22
- cell,
23
- index,
24
- isLastRow,
25
- rowIndex,
26
- rows,
27
- scrollToIndex,
28
- scrollToOffset,
29
- table,
30
- tableRef,
31
- ...columnProps
32
- } = props;
33
- const meta = table.options.meta;
34
- const {
35
- addFocussableColumnIndex,
36
- focussableColumnIndexes: allFocussableColumnIndexes
37
- } = meta;
38
- const {
39
- editMode: {
40
- validationErrors,
41
- rowMoveReason
42
- },
43
- isHovered: isHoveredRow
44
- } = useRowContext();
45
- const hasValidationErrorsInRow = !!validationErrors;
46
- const internalRef = React__default.useRef(null);
47
- const controlRef = React__default.useRef(null);
48
- const cellClassName = (_cell$column$columnDe = cell.column.columnDef.meta) === null || _cell$column$columnDe === void 0 ? void 0 : _cell$column$columnDe.className;
49
- const isActiveRow = meta.activeRowIndex === rowIndex;
50
- const isFrozen = !!cell.column.getIsPinned();
51
- const isDragging = meta.dragging[cell.row.id];
52
- const isSelected = cell.row.getIsSelected();
53
- const isDataColumn = !isInternalColumn(cell.column.id);
54
- const hasCellControl = !!((_cell$column$columnDe2 = cell.column.columnDef.meta) !== null && _cell$column$columnDe2 !== void 0 && _cell$column$columnDe2.control);
55
- const allVisibleColumns = table.getVisibleLeafColumns();
56
- const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;
57
- // editing
58
- const isEditingThisRow = meta.editMode.isEditing && isActiveRow;
59
- const canEditThisCell = isEditingThisRow && isDataColumn;
60
- const isEditingThisCell = canEditThisCell && meta.editMode.columnIndex === index;
61
- const isHoveringThisRowWhileEditing = meta.editMode.isEditing && isHoveredRow && !meta.shouldPauseHoverState;
62
- const isIndicatorVisible = Object.keys(rowMoveReason).length > 0;
63
- React__default.useEffect(() => {
64
- // Adds padding to the table so that indicator doesn't get cropped
65
- if (isIndicatorVisible && isLastRow) {
66
- var _tableRef$current;
67
- (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.classList.add('pb-4');
68
- }
69
- return () => {
70
- var _tableRef$current2;
71
- return (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : _tableRef$current2.classList.remove('pb-4');
72
- };
73
- }, [isIndicatorVisible, isLastRow]);
74
- const className = cn('[&>[data-taco="tag"]]:-my-0.5', '[[data-dragged-over="true"]_&]:bg-grey-100', {
75
- 'border-b': !isLastRow,
76
- 'sticky z-[1]': isFrozen,
77
- // use isHoveredRow rather than css group-hover/row because we want to hide hover state when keyboard navigating
78
- 'bg-white': !isActiveRow && !isSelected,
79
- 'group-hover/row:bg-grey-100': !isActiveRow && !isSelected && !meta.shouldPauseHoverState,
80
- 'bg-grey-200 group-hover/row:bg-grey-200': isActiveRow && !isSelected,
81
- 'bg-blue-100': isSelected,
82
- '!wcag-blue-500': isDragging,
83
- '[&>*]:!grayscale [&_.bg-white]:!bg-grey-100': !isEditingThisRow && isHoveringThisRowWhileEditing,
84
- '!bg-red-100': hasValidationErrorsInRow,
85
- 'z-[1]': isFrozen && isActiveRow,
86
- // First column should have higher z-index so that row indicator always show on top of the cell
87
- // control components. A z-index of 3, will show the indicator when columns are pinned.
88
- 'z-[3]': isFrozen && isActiveRow && index === 0,
89
- 'border-blue !border-y-2 border-x-0': isIndicatorVisible,
90
- 'border-l-2 rounded-l': isIndicatorVisible && index === 0,
91
- 'border-r-2 rounded-r': isIndicatorVisible && index === lastColumnIndex
92
- }, getCellSizingClasses((_table$options$meta = table.options.meta) === null || _table$options$meta === void 0 ? void 0 : _table$options$meta.rowDensity, (isEditingThisRow || isHoveringThisRowWhileEditing) && hasCellControl), typeof cellClassName === 'function' ? cellClassName(cell.row, table) : cellClassName);
93
- const handleMouseDown = event => {
94
- // only detect left clicks
95
- if (event.button === 0) {
96
- const activeElement = document.activeElement;
97
- const isActiveElementControl = activeElement === null || activeElement === void 0 ? void 0 : activeElement.closest('[role="cell"]');
98
- const hasActiveRowChanged = meta.activeRowIndex !== rowIndex;
99
- // When user clicks on a cell that is not in the active row, for some reason blur event is not called on the cell
100
- // previous cell control element so we need to manually call it in order to save the changes in that cell
101
- if (isActiveElementControl && hasActiveRowChanged) {
102
- activeElement.blur();
103
- }
104
- meta.setActiveRowIndex(rowIndex);
105
- if (meta.editMode.isEditing) {
106
- if (allFocussableColumnIndexes.includes(index)) {
107
- meta.editMode.setColumn(index);
108
- } else {
109
- meta.editMode.setColumn(allFocussableColumnIndexes[0]);
110
- }
111
- }
112
- }
113
- };
114
- const attributes = {
115
- ...columnProps,
116
- // base props,
117
- column: cell.column,
118
- table,
119
- // dom attributes
120
- className,
121
- 'data-column-index': index,
122
- 'data-row-index': rowIndex,
123
- onMouseDown: handleMouseDown,
124
- ref: internalRef,
125
- role: 'cell'
126
- };
127
- const [detailModeEditing, setDetailModeEditing] = React__default.useState(false);
128
- // reset the editing state when we move column
129
- React__default.useEffect(() => {
130
- if (meta.editMode.columnIndex !== index) {
131
- setDetailModeEditing(false);
132
- }
133
- }, [meta.editMode.columnIndex]);
134
- React__default.useEffect(() => {
135
- if (isEditingThisRow && controlRef.current && isKeyboardFocusableElement(controlRef.current)) {
136
- addFocussableColumnIndex(index);
137
- }
138
- }, [isEditingThisRow, allFocussableColumnIndexes, addFocussableColumnIndex, index]);
139
- const moveRow = moveDirection => {
140
- if (moveDirection === MOVE_DIR.PREV) {
141
- meta.moveToPreviousRow(rows, nextIndex => scrollToIndex(nextIndex - 1));
142
- } else if (moveDirection === MOVE_DIR.NEXT) {
143
- meta.moveToNextRow(rows, nextIndex => scrollToIndex(nextIndex + 2));
144
- }
145
- };
146
- if (meta.editMode.onSave && hasCellControl && (canEditThisCell || isHoveringThisRowWhileEditing && isDataColumn)) {
147
- attributes.onMouseDown = event => {
148
- const target = event.target;
149
- const isTargetInput = target !== null && target.nodeName === 'INPUT';
150
- // In Edit mode, If mouse click is happening outside of cell (in case of any dropdowns like date picker or select),
151
- // then it should not be processed as a click on a cell.
152
- if (!event.currentTarget.contains(target)) {
153
- return;
154
- }
155
- handleMouseDown(event);
156
- // event.target?.select is only truthy for input elements
157
- // if event.target is active element, then that means we should select the text
158
- if (isTargetInput && target !== document.activeElement) {
159
- event.preventDefault();
160
- setTimeout(() => {
161
- target.select();
162
- }, 1);
163
- } else if (isTargetInput && target === document.activeElement) {
164
- // if user left clicks on the input then we are into edit mode
165
- // only detect left clicks
166
- if (event.button === 0) {
167
- setDetailModeEditing(true);
168
- }
169
- }
170
- };
171
- attributes.onBlur = () => {
172
- setDetailModeEditing(false);
173
- };
174
- if (canEditThisCell) {
175
- var _allFocussableColumnI, _allFocussableColumnI2;
176
- const firstDataColumnIndex = (_allFocussableColumnI = allFocussableColumnIndexes.at(0)) !== null && _allFocussableColumnI !== void 0 ? _allFocussableColumnI : 0;
177
- const lastDataColumnIndex = (_allFocussableColumnI2 = allFocussableColumnIndexes.at(-1)) !== null && _allFocussableColumnI2 !== void 0 ? _allFocussableColumnI2 : 0;
178
- attributes.onKeyDown = event => {
179
- const control = event.target;
180
- const isControlInput = control.nodeName === 'INPUT' && (control === null || control === void 0 ? void 0 : control.getAttribute('data-inline-editing-component')) === 'true';
181
- // For some reason, Taco Input keyboard event always return true when "event.isDefaultPrevented()" is
182
- // called. So we need to check if the control is input or not so that we don't return early.
183
- if (!isControlInput && (event.isDefaultPrevented() || event.isPropagationStopped())) {
184
- return;
185
- }
186
- if (control.tagName === 'INPUT') {
187
- if (event.key === 'Enter') {
188
- event.preventDefault();
189
- const input = control;
190
- if (!detailModeEditing) {
191
- var _input$setSelectionRa, _input$value, _input$value2;
192
- (_input$setSelectionRa = input.setSelectionRange) === null || _input$setSelectionRa === void 0 ? void 0 : _input$setSelectionRa.call(input, (_input$value = input.value) === null || _input$value === void 0 ? void 0 : _input$value.length, (_input$value2 = input.value) === null || _input$value2 === void 0 ? void 0 : _input$value2.length);
193
- } else {
194
- var _input$select;
195
- input === null || input === void 0 ? void 0 : (_input$select = input.select) === null || _input$select === void 0 ? void 0 : _input$select.call(input);
196
- }
197
- setDetailModeEditing(!detailModeEditing);
198
- return;
199
- }
200
- // Datepicker doesn't have keydown event handler its value doesn't change when user types inside
201
- // datepicker input, so we need to explicitly enable detail editing mode on typing any alphanumeric
202
- // character
203
- if (control !== null && control !== void 0 && control.closest('[data-taco="datepicker"]') && /^[a-z0-9]$/i.test(event.key)) {
204
- setDetailModeEditing(true);
205
- }
206
- }
207
- // Don't exit edit mode if the target of the escape isn't a child of the cell (e.g. if its a popover).
208
- if (event.key === 'Escape' && event.currentTarget.contains(control)) {
209
- event.preventDefault();
210
- if (detailModeEditing) {
211
- setDetailModeEditing(false);
212
- } else {
213
- var _tableRef$current3;
214
- meta.editMode.toggleEditing(false);
215
- (_tableRef$current3 = tableRef.current) === null || _tableRef$current3 === void 0 ? void 0 : _tableRef$current3.focus();
216
- }
217
- return;
218
- }
219
- if (!detailModeEditing && event.key === 'ArrowLeft' || event.key === 'Tab' && event.shiftKey) {
220
- event.preventDefault();
221
- const isFirstRow = rowIndex === 0;
222
- const isFirstColumn = index === firstDataColumnIndex;
223
- if (event.ctrlKey || event.metaKey) {
224
- // If the current active column is the first column then we don't do any thing so that focus
225
- // remains on the first column.
226
- if (!isFirstColumn) {
227
- control.blur();
228
- meta.editMode.moveToFirstColumn(allFocussableColumnIndexes);
229
- }
230
- } else {
231
- // If it is first row and first column, then don't move column.
232
- if (!isFirstRow || !isFirstColumn) {
233
- control.blur();
234
- meta.editMode.moveToPreviousColumn(allFocussableColumnIndexes, moveRow);
235
- }
236
- }
237
- return;
238
- }
239
- if (!detailModeEditing && event.key === 'ArrowRight' || event.key === 'Tab' && !event.shiftKey) {
240
- event.preventDefault();
241
- const isLastColumn = index === lastDataColumnIndex;
242
- if (event.ctrlKey || event.metaKey) {
243
- // If the current active column is the last column then we don't do any thing so that focus
244
- // remains on the last column.
245
- if (!isLastColumn) {
246
- control.blur();
247
- meta.editMode.moveToLastColumn(allFocussableColumnIndexes);
248
- }
249
- } else {
250
- // If it is last row and last column, then don't move column.
251
- if (!isLastRow || !isLastColumn) {
252
- control.blur();
253
- meta.editMode.moveToNextColumn(allFocussableColumnIndexes, moveRow);
254
- }
255
- }
256
- return;
257
- }
258
- if (!detailModeEditing && event.key === 'ArrowUp') {
259
- event.preventDefault();
260
- // if it is the first row then return early, so that focus on the cell is not lost
261
- if (rowIndex === 0) {
262
- return;
263
- }
264
- control.blur();
265
- if (event.ctrlKey || event.metaKey) {
266
- meta.setActiveRowIndex(0);
267
- scrollToOffset(0);
268
- } else {
269
- moveRow(MOVE_DIR.PREV);
270
- }
271
- meta.setShouldPauseHoverState(true);
272
- return;
273
- }
274
- if (!detailModeEditing && event.key === 'ArrowDown') {
275
- event.preventDefault();
276
- // if it is the last row then return early, so that focus on the cell is not lost
277
- if (rowIndex === rows.length - 1) {
278
- return;
279
- }
280
- control.blur();
281
- if (event.ctrlKey || event.metaKey) {
282
- meta.setActiveRowIndex(rows.length - 1);
283
- scrollToIndex(rows.length + 20);
284
- } else {
285
- moveRow(MOVE_DIR.NEXT);
286
- }
287
- meta.setShouldPauseHoverState(true);
288
- return;
289
- }
290
- };
291
- }
292
- return /*#__PURE__*/React__default.createElement(ColumnBase, Object.assign({}, attributes), /*#__PURE__*/React__default.createElement(EditingCell, {
293
- detailModeEditing: detailModeEditing,
294
- cell: cell,
295
- cellRef: internalRef,
296
- columnIndex: index,
297
- isEditingThisCell: isEditingThisCell,
298
- onSave: meta.editMode.onSave,
299
- rowIndex: rowIndex,
300
- table: table,
301
- tableRef: tableRef,
302
- ref: controlRef,
303
- rowValues: rows[rowIndex].original,
304
- rowsLength: rows.length,
305
- enableDetailModeEditing: () => {
306
- if (!detailModeEditing) {
307
- setDetailModeEditing(true);
308
- }
309
- }
310
- }));
311
- } else {
312
- if (meta.onRowClick) {
313
- attributes.onClick = event => {
314
- const {
315
- target
316
- } = event;
317
- // This check prevents triggering row click, when a click is performed in the dropdown (e.g. Select option or DayPicker date selection)
318
- if (internalRef.current && target instanceof HTMLElement && internalRef.current.contains(target)) {
319
- var _meta$onRowClick;
320
- // Checking that target is clickable element or it is a child of clickable element
321
- if (clickableNodeNames.includes(target.tagName) || target.closest(clickableNodeNames.map(tag => `[role=row] ${tag}`).join(','))) {
322
- return;
323
- }
324
- (_meta$onRowClick = meta.onRowClick) === null || _meta$onRowClick === void 0 ? void 0 : _meta$onRowClick.call(meta, cell.row.original);
325
- }
326
- };
327
- }
328
- }
329
- return /*#__PURE__*/React__default.createElement(ColumnBase, Object.assign({}, attributes), flexRender(cell.column.columnDef.cell, cell.getContext()));
330
- };
331
- const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__default.forwardRef((props, ref) => {
332
- var _cell$column$columnDe3, _cell$column$columnDe4, _cellRef$current2, _cellRef$current2$par, _rowMoveReason$cellId;
333
- const {
334
- cell,
335
- cellRef,
336
- columnIndex,
337
- detailModeEditing,
338
- isEditingThisCell = false,
339
- onSave: handleSave,
340
- rowIndex,
341
- rowValues,
342
- table,
343
- tableRef,
344
- enableDetailModeEditing
345
- } = props;
346
- const {
347
- editMode: {
348
- validationErrors,
349
- setValidationErrors,
350
- rowMoveReason,
351
- setRowMoveReason
352
- },
353
- isHovered
354
- } = useRowContext();
355
- const controlRef = useMergedRef(ref);
356
- const cellId = cell.column.id;
357
- const cellValidationError = validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors[cellId];
358
- const value = cell.getValue();
359
- const ariaLabel = cell.column.columnDef.header;
360
- const meta = table.options.meta;
361
- const {
362
- globalFilter
363
- } = table.getState();
364
- const [state, setState] = React__default.useState(value);
365
- const isHoveringAnotherRowWhileEditing = meta.editMode.isEditing && meta.activeRowIndex !== rowIndex && isHovered;
366
- const hasValidationError = !isHoveringAnotherRowWhileEditing && !!cellValidationError;
367
- // On each save, the initialValue will be set to the new value of the cell
368
- const initialValue = React__default.useRef(value);
369
- const stateReset = React__default.useRef(false);
370
- // It is important that we let consumers pass a newValue as an argument because when setState is called before
371
- // onBlur then saveIfChanged method gets the stale state value. This happens because the rerender hasn't happened
372
- // before the saveIfChanged method is called.
373
- const saveIfChanged = function (eventOrNewValue) {
374
- try {
375
- let newValue = state;
376
- // if eventOrNewValue is not an event object
377
- if (!(eventOrNewValue !== null && eventOrNewValue !== void 0 && eventOrNewValue.target)) {
378
- newValue = eventOrNewValue;
379
- }
380
- const _temp2 = function () {
381
- if (hasChanged(value, newValue)) {
382
- const _temp = _catch(function () {
383
- const updatedRow = {
384
- ...cell.row.original,
385
- [cellId]: newValue
386
- };
387
- return Promise.resolve(handleSave(updatedRow, cellId)).then(function () {
388
- // If sorting is paused then update the last sorted or filtered rows to store the newly updated row
389
- if (meta.shouldPauseSortingAndFiltering) {
390
- meta.lastSortedOrFilteredRows.current = meta.lastSortedOrFilteredRows.current.map(row => {
391
- if (row.id === cell.row.id) {
392
- row.original = updatedRow;
393
- }
394
- return row;
395
- });
396
- }
397
- // Reset error if save was successful
398
- setValidationErrors(null);
399
- });
400
- }, function (error) {
401
- setValidationErrors({
402
- ...validationErrors,
403
- ...error
404
- });
405
- });
406
- if (_temp && _temp.then) return _temp.then(function () {});
407
- }
408
- }();
409
- return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
410
- } catch (e) {
411
- return Promise.reject(e);
412
- }
413
- };
414
- // Ensures we "auto focus" the field if the cell is being edited.
415
- React__default.useEffect(() => {
416
- var _meta$tableRef$curren;
417
- const isFocusInsideTable = (_meta$tableRef$curren = meta.tableRef.current) === null || _meta$tableRef$curren === void 0 ? void 0 : _meta$tableRef$curren.contains(document.activeElement);
418
- // When control is blurred then body gets the focus that's why we have to make sure if activeElement
419
- // is body then we focus the cell if it is being edited.
420
- const isBodyFocussed = document.body === document.activeElement;
421
- // Don't focus cell if any table popup(filter popup, column settings popup) is open.
422
- if (isEditingThisCell && (isFocusInsideTable || isBodyFocussed)) {
423
- var _controlRef$current, _controlRef$current$f;
424
- (_controlRef$current = controlRef.current) === null || _controlRef$current === void 0 ? void 0 : (_controlRef$current$f = _controlRef$current.focus) === null || _controlRef$current$f === void 0 ? void 0 : _controlRef$current$f.call(_controlRef$current);
425
- }
426
- }, [isEditingThisCell, controlRef.current]);
427
- const pinnedColumnsWidth = React__default.useMemo(() => {
428
- const pinnedColumns = table.getState().columnPinning.left;
429
- if (Array.isArray(pinnedColumns) && pinnedColumns.length > 0) {
430
- const lastFrozenColumn = pinnedColumns[pinnedColumns.length - 1];
431
- const lastFrozenColumnOffset = meta.columnOffsets[lastFrozenColumn];
432
- if (lastFrozenColumnOffset !== undefined) {
433
- var _table$getState$colum;
434
- return lastFrozenColumnOffset + ((_table$getState$colum = table.getState().columnSizing[lastFrozenColumn]) !== null && _table$getState$colum !== void 0 ? _table$getState$colum : 0);
435
- }
436
- }
437
- return 0;
438
- }, [meta.columnOffsets, table.getState().columnSizing]);
439
- React__default.useEffect(() => {
440
- if (hasChanged(initialValue.current, state)) {
441
- var _controlRef$current2;
442
- // For an input we want to make sure that if the value is changed then we go into detail mode, so that
443
- // arrow keys doesn't trigger the quick mode shortcuts.
444
- if (((_controlRef$current2 = controlRef.current) === null || _controlRef$current2 === void 0 ? void 0 : _controlRef$current2.nodeName) === 'INPUT') {
445
- enableDetailModeEditing();
446
- }
447
- showIndicator();
448
- } else {
449
- hideIndicator();
450
- }
451
- return hideIndicator;
452
- }, [state]);
453
- // This effect makes sure we select the input control value when escape key is pressed
454
- React__default.useEffect(() => {
455
- var _controlRef$current3, _controlRef$current4;
456
- const isControlInput = ((_controlRef$current3 = controlRef.current) === null || _controlRef$current3 === void 0 ? void 0 : _controlRef$current3.nodeName) === 'INPUT' && ((_controlRef$current4 = controlRef.current) === null || _controlRef$current4 === void 0 ? void 0 : _controlRef$current4.getAttribute('data-inline-editing-component')) === 'true';
457
- if (stateReset.current && isControlInput) {
458
- var _controlRef$current5;
459
- (_controlRef$current5 = controlRef.current) === null || _controlRef$current5 === void 0 ? void 0 : _controlRef$current5.select();
460
- }
461
- stateReset.current = false;
462
- }, [stateReset.current]);
463
- const handleFocus = event => {
464
- var _event$target, _cellRef$current;
465
- meta.editMode.setColumn(columnIndex);
466
- if ((_event$target = event.target) !== null && _event$target !== void 0 && _event$target.select) {
467
- var _event$target2;
468
- (_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : _event$target2.select();
469
- }
470
- // ensure the field is always visible (e.g. not hidden behind the pinned columns)
471
- const rect = (_cellRef$current = cellRef.current) === null || _cellRef$current === void 0 ? void 0 : _cellRef$current.getBoundingClientRect();
472
- const leftOffset = meta.columnOffsets[cellId];
473
- if (rect && leftOffset && rect.left < pinnedColumnsWidth) {
474
- var _tableRef$current4;
475
- (_tableRef$current4 = tableRef.current) === null || _tableRef$current4 === void 0 ? void 0 : _tableRef$current4.scrollTo(leftOffset - pinnedColumnsWidth, tableRef.current.scrollTop);
476
- }
477
- };
478
- // In order to reset the value of an input when escape key is pressed this keydown handler is required.
479
- // Instead of adding this event handler in parent component, this handler is added here because we have access
480
- // to the state handler of the control component.
481
- const handleKeyDown = event => {
482
- const control = event.target;
483
- const isControlInput = control.nodeName === 'INPUT' && (control === null || control === void 0 ? void 0 : control.getAttribute('data-inline-editing-component')) === 'true';
484
- if (isControlInput && event.key === 'Escape') {
485
- setState(initialValue.current);
486
- stateReset.current = true;
487
- }
488
- };
489
- const showIndicator = () => {
490
- var _table$getState$sorti;
491
- let willRowMoveReason = null;
492
- const isFilteredByGlobalFilter = Object.values({
493
- ...rowValues,
494
- [cellId]: state
495
- }).some(cellValue =>
496
- // Global filter can be undefined when there is no text being searched so we pass an empty string to
497
- // globalFilterFn as query in that case.
498
- globalFilterFn(String(cellValue), globalFilter ? String(globalFilter) : ''));
499
- if (!isFilteredByGlobalFilter) {
500
- willRowMoveReason = IndicatorReason.SEARCH;
501
- } else if (cell.column.getIsFiltered() && !columnFilterFn(state, cell.column.getFilterValue())) {
502
- willRowMoveReason = IndicatorReason.FILTER;
503
- } else if (!willRowMoveReason && cell.column.getIsSorted() && willRowMoveAfterSorting(state, cell, rowIndex, table.getRowModel().rows, !!((_table$getState$sorti = table.getState().sorting.find(s => s.id === cell.column.id)) !== null && _table$getState$sorti !== void 0 && _table$getState$sorti.desc))) {
504
- willRowMoveReason = IndicatorReason.SORTING;
505
- }
506
- if (willRowMoveReason !== null) {
507
- meta.setShouldPauseSortingAndFiltering(true);
508
- setRowMoveReason({
509
- [cellId]: willRowMoveReason
510
- });
511
- }
512
- };
513
- const hideIndicator = () => {
514
- setRowMoveReason(prevState => {
515
- const newState = {
516
- ...prevState
517
- };
518
- delete newState[cellId];
519
- return newState;
520
- });
521
- };
522
- const cellControl = (_cell$column$columnDe3 = cell.column.columnDef.meta) === null || _cell$column$columnDe3 === void 0 ? void 0 : _cell$column$columnDe3.control;
523
- const attributes = {
524
- 'aria-label': ariaLabel,
525
- onBlur: saveIfChanged,
526
- onFocus: handleFocus,
527
- ref,
528
- // This is a temporary fix to enable up/down arrow key shortcuts on input in quick mode. For some reason,
529
- // the preventDefault is true on Taco Input, so the keyboard shortcuts doesn't work. By adding this
530
- // data attribute we make sure the event is coming from a control component, and then we can make sure
531
- // keyboard shortcut works as expected.
532
- 'data-inline-editing-component': 'true'
533
- };
534
- const className = cn(getCellAlignmentClasses((_cell$column$columnDe4 = cell.column.columnDef.meta) === null || _cell$column$columnDe4 === void 0 ? void 0 : _cell$column$columnDe4.align));
535
- const indicatorMountNode = (_cellRef$current2 = cellRef.current) === null || _cellRef$current2 === void 0 ? void 0 : (_cellRef$current2$par = _cellRef$current2.parentElement) === null || _cellRef$current2$par === void 0 ? void 0 : _cellRef$current2$par.querySelector(':first-child');
536
- let controlComponent;
537
- const detailModeClassName = cn({
538
- '!yt-focus-dark': detailModeEditing
539
- });
540
- if (cellControl) {
541
- if (typeof cellControl === 'function') {
542
- controlComponent = cellControl({
543
- invalid: hasValidationError,
544
- onBlur: saveIfChanged,
545
- onFocus: handleFocus,
546
- ref: controlRef,
547
- setValue: setState,
548
- value: state,
549
- 'data-inline-editing-component': 'true'
550
- }, cell.row.original);
551
- } else {
552
- switch (cellControl) {
553
- case 'datepicker':
554
- controlComponent = /*#__PURE__*/React__default.createElement(Datepicker, Object.assign({}, attributes, {
555
- className: cn({
556
- '[&_input]:!shadow-[0_0_0_4px_rgba(0,99,255,0.25)]': detailModeEditing
557
- }),
558
- invalid: hasValidationError,
559
- onBlur: event => {
560
- const newDate = event.detail;
561
- saveIfChanged(newDate);
562
- },
563
- onChange: event => {
564
- setState(event.detail);
565
- },
566
- ref: controlRef,
567
- value: state
568
- }));
569
- break;
570
- case 'switch':
571
- controlComponent = /*#__PURE__*/React__default.createElement(Switch, Object.assign({}, attributes, {
572
- className: cn('mx-2 mt-1.5', detailModeClassName),
573
- checked: Boolean(state),
574
- onChange: setState,
575
- ref: controlRef
576
- }));
577
- break;
578
- default:
579
- controlComponent = /*#__PURE__*/React__default.createElement(Input, Object.assign({}, attributes, {
580
- className: cn(className, detailModeClassName),
581
- invalid: hasValidationError,
582
- onChange: event => {
583
- setState(event.target.value);
584
- },
585
- ref: controlRef,
586
- value: String(state !== null && state !== void 0 ? state : ''),
587
- onKeyDown: handleKeyDown
588
- }));
589
- break;
590
- }
591
- }
592
- }
593
- const indicatorReason = (_rowMoveReason$cellId = rowMoveReason[cellId]) !== null && _rowMoveReason$cellId !== void 0 ? _rowMoveReason$cellId : null;
594
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, indicatorReason !== null && /*#__PURE__*/React__default.createElement(Indicator, {
595
- reason: indicatorReason,
596
- columnName: String(cell.column.columnDef.header),
597
- mountNode: indicatorMountNode,
598
- validationErrors: validationErrors
599
- }), /*#__PURE__*/React__default.createElement("span", {
600
- className: "relative flex-grow"
601
- }, controlComponent, hasValidationError && /*#__PURE__*/React__default.createElement(ValidationError, null, String(cellValidationError))));
602
- }));
603
-
604
- export { Cell };
605
- //# sourceMappingURL=Cell.js.map