@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 +1 @@
1
- {"version":3,"file":"Actions.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/internal/Actions.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext, DisplayColumnDef, TableMeta } from '@tanstack/react-table';\nimport cn from 'classnames';\nimport { Header as ColumnHeader } from '../header/Header';\nimport { DisplayCell } from '../cell/DisplayCell';\nimport { Table3FontSize, Table3RowActionRenderer } from '../../../types';\nimport { RowContext } from '../../rows/RowContext';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Menu } from '../../../../Menu/Menu';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\nimport { Footer } from '../footer/Footer';\n\nexport const COLUMN_ID = '__actions';\n\ntype MemoedCellProps<TType = unknown> = CellContext<TType, unknown> & {\n actions?: Table3RowActionRenderer<TType>[];\n actionsLength: number;\n fontSize: Table3FontSize;\n isCurrentRow: boolean;\n isEditing: boolean;\n isResizingColumn: boolean;\n isHoverStatePaused: boolean;\n};\n\nconst MemoedCell = React.memo(function MemoedCell<TType = unknown>(props: MemoedCellProps<TType>) {\n const { actions, actionsLength, fontSize, isCurrentRow, isEditing, isResizingColumn, isHoverStatePaused, row } = props;\n const { isHovered } = React.useContext(RowContext);\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLSpanElement | null>(null);\n /*\n const size = table.getState().columnSizing[COLUMN_ID];\n\n // the actions column needs to set its size based on its content, not the actual column\n // so we do this here instead of in the header\n React.useLayoutEffect(() => {\n if (ref.current && !size) {\n const width = ref.current.getBoundingClientRect().width;\n\n table.setColumnSizing(sizes => ({\n ...sizes,\n [COLUMN_ID]: width,\n }));\n }\n }, [ref.current]);\n */\n\n let content;\n\n // We don't want to show actions in edit mode, since we have editing actions,\n // which is shown in edit mode instead.\n if (actions?.length && !isEditing && (isCurrentRow || (isHovered && !isHoverStatePaused && !isResizingColumn))) {\n const visibleActions = actions.map(action => action(row.original)).filter(action => !!action) as JSX.Element[];\n\n const actionsOnRow =\n visibleActions.length === actionsLength ? visibleActions : visibleActions.slice(0, actionsLength - 1);\n const actionsInMenu = visibleActions.slice(visibleActions.length === actionsLength ? actionsLength : actionsLength - 1);\n\n const className = cn('-mb-2 flex justify-end pl-2 text-right', {\n // Adjust negative margin on row actions cell to ensure that the cell aligns vertically.\n '-mt-2': fontSize === 'small',\n '-mt-1.5': fontSize !== 'small',\n });\n\n content = (\n <span className={className} ref={ref}>\n {actionsOnRow.map((button, index) => {\n const tooltip = String(button.props.tooltip ?? button.props['aria-label'] ?? '');\n\n return React.cloneElement(button, {\n appearance: 'transparent',\n key: index,\n tabIndex: isCurrentRow ? 0 : -1,\n tooltip: button.props.shortcut ? (\n <>\n {tooltip}\n <Shortcut className=\"ml-2\" keys={button.props.shortcut} />\n </>\n ) : (\n tooltip\n ),\n });\n })}\n {actionsInMenu.length ? (\n <IconButton\n appearance=\"transparent\"\n aria-label={texts.table3.columns.actions.tooltip}\n icon=\"more\"\n tabIndex={isCurrentRow ? 0 : -1}\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n {actionsInMenu.map((action, i) => (\n <Menu.Item key={i} {...action.props} shortcut={action.props.shortcut}>\n {action.props['aria-label']}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu>\n )}\n />\n ) : null}\n </span>\n );\n }\n\n return <DisplayCell {...props}>{content}</DisplayCell>;\n}) as <TType = unknown>(props: MemoedCellProps<TType>) => JSX.Element;\n\ntype CellProps<TType = unknown> = CellContext<TType, unknown>;\n\nfunction Cell<TType = unknown>(context: CellProps<TType>) {\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = context.table.options.meta as TableMeta<TType>;\n\n return (\n <MemoedCell\n {...context}\n actions={tableMeta.rowActions.actionsForRow}\n actionsLength={tableMeta.rowActions.actionsForRowLength}\n fontSize={tableMeta.fontSize.size}\n isCurrentRow={tableMeta.currentRow.currentRowIndex === rowIndex}\n isEditing={tableMeta.editing.isEditing}\n isResizingColumn={!!context.table.getState().columnSizingInfo.isResizingColumn}\n isHoverStatePaused={!!tableMeta.hoverState.isPaused}\n />\n );\n}\n\nexport function createRowActionsColumn<TType = unknown>(): DisplayColumnDef<TType, unknown> {\n return {\n id: COLUMN_ID,\n header: ColumnHeader,\n cell: Cell,\n footer: Footer,\n meta: {\n align: 'right',\n className: cn(\n '!pt-[var(--table3-cell-padding-y)] print:opacity-0 [[role=\"table\"][data-editing=\"false\"]_&]:group-[[data-current=\"true\"]]/row:sticky [[role=\"table\"][data-pause-hover=\"false\"][data-editing=\"false\"]_&]:group-hover/row:sticky right-0 !pl-1 !pr-1',\n 'shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]',\n 'group-[[data-current=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: '',\n headerClassName: 'items-center !p-0',\n },\n // options\n enableResizing: false,\n };\n}\n"],"names":["COLUMN_ID","MemoedCell","React","memo","props","actions","actionsLength","fontSize","isCurrentRow","isEditing","isResizingColumn","isHoverStatePaused","row","isHovered","useContext","RowContext","texts","useLocalization","ref","useRef","content","length","visibleActions","map","action","original","filter","actionsOnRow","slice","actionsInMenu","className","cn","button","index","tooltip","String","_ref","_button$props$tooltip","cloneElement","appearance","key","tabIndex","shortcut","Shortcut","keys","IconButton","table3","columns","icon","menu","menuProps","Menu","Content","i","Item","DisplayCell","Cell","context","rowIndex","tableMeta","table","options","meta","rowActions","actionsForRow","actionsForRowLength","size","currentRow","currentRowIndex","editing","getState","columnSizingInfo","hoverState","isPaused","createRowActionsColumn","id","header","ColumnHeader","cell","footer","Footer","align","enableOrdering","enableSearch","enableTruncate","headerClassName","enableResizing"],"mappings":";;;;;;;;;;;MAaaA,SAAS,GAAG;AAYzB,MAAMC,UAAU,gBAAGC,cAAK,CAACC,IAAI,CAAC,SAASF,UAAUA,CAAkBG,KAA6B;EAC5F,MAAM;IAAEC,OAAO;IAAEC,aAAa;IAAEC,QAAQ;IAAEC,YAAY;IAAEC,SAAS;IAAEC,gBAAgB;IAAEC,kBAAkB;IAAEC;GAAK,GAAGR,KAAK;EACtH,MAAM;IAAES;GAAW,GAAGX,cAAK,CAACY,UAAU,CAACC,UAAU,CAAC;EAClD,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGhB,cAAK,CAACiB,MAAM,CAAyB,IAAI,CAAC;;;;;;;;;;;;;;;EAkBtD,IAAIC,OAAO;;;EAIX,IAAIf,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEgB,MAAM,IAAI,CAACZ,SAAS,KAAKD,YAAY,IAAKK,SAAS,IAAI,CAACF,kBAAkB,IAAI,CAACD,gBAAiB,CAAC,EAAE;IAC5G,MAAMY,cAAc,GAAGjB,OAAO,CAACkB,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACZ,GAAG,CAACa,QAAQ,CAAC,CAAC,CAACC,MAAM,CAACF,MAAM,IAAI,CAAC,CAACA,MAAM,CAAkB;IAE9G,MAAMG,YAAY,GACdL,cAAc,CAACD,MAAM,KAAKf,aAAa,GAAGgB,cAAc,GAAGA,cAAc,CAACM,KAAK,CAAC,CAAC,EAAEtB,aAAa,GAAG,CAAC,CAAC;IACzG,MAAMuB,aAAa,GAAGP,cAAc,CAACM,KAAK,CAACN,cAAc,CAACD,MAAM,KAAKf,aAAa,GAAGA,aAAa,GAAGA,aAAa,GAAG,CAAC,CAAC;IAEvH,MAAMwB,SAAS,GAAGC,EAAE,CAAC,wCAAwC,EAAE;;MAE3D,OAAO,EAAExB,QAAQ,KAAK,OAAO;MAC7B,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AAE,KAAK;MACrBC,YAAY,EAAE,KAAK;MACnBC,cAAc,EAAE,KAAK;MACrBR,MAAM,EAAE,EAAE;MACVS,eAAe,EAAE;KACpB;;IAEDC,cAAc,EAAE;GACnB;AACL;;;;"}
1
+ {"version":3,"file":"Actions.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/internal/Actions.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext, DisplayColumnDef, TableMeta } from '@tanstack/react-table';\nimport cn from 'classnames';\nimport { Header as ColumnHeader } from '../header/Header';\nimport { DisplayCell } from '../cell/DisplayCell';\nimport { Table3FontSize, Table3RowActionRenderer } from '../../../types';\nimport { RowContext } from '../../rows/RowContext';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { Menu } from '../../../../Menu/Menu';\nimport { Shortcut } from '../../../../Shortcut/Shortcut';\nimport { Footer } from '../footer/Footer';\nimport { FONT_SIZE } from '../../toolbar/FontSize';\n\nexport const COLUMN_ID = '__actions';\n\ntype MemoedCellProps<TType = unknown> = CellContext<TType, unknown> & {\n actions?: Table3RowActionRenderer<TType>[];\n actionsLength: number;\n fontSize: Table3FontSize;\n isCurrentRow: boolean;\n isEditing: boolean;\n isResizingColumn: boolean;\n isHoverStatePaused: boolean;\n};\n\nconst MemoedCell = React.memo(function MemoedCell<TType = unknown>(props: MemoedCellProps<TType>) {\n const { actions, actionsLength, fontSize, isCurrentRow, isEditing, isResizingColumn, isHoverStatePaused, row } = props;\n const { isHovered } = React.useContext(RowContext);\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLSpanElement | null>(null);\n /*\n const size = table.getState().columnSizing[COLUMN_ID];\n\n // the actions column needs to set its size based on its content, not the actual column\n // so we do this here instead of in the header\n React.useLayoutEffect(() => {\n if (ref.current && !size) {\n const width = ref.current.getBoundingClientRect().width;\n\n table.setColumnSizing(sizes => ({\n ...sizes,\n [COLUMN_ID]: width,\n }));\n }\n }, [ref.current]);\n */\n\n let content;\n\n // We don't want to show actions in edit mode, since we have editing actions,\n // which is shown in edit mode instead.\n if (actions?.length && !isEditing && (isCurrentRow || (isHovered && !isHoverStatePaused && !isResizingColumn))) {\n const visibleActions = actions.map(action => action(row.original)).filter(action => !!action) as JSX.Element[];\n\n const actionsOnRow =\n visibleActions.length === actionsLength ? visibleActions : visibleActions.slice(0, actionsLength - 1);\n const actionsInMenu = visibleActions.slice(visibleActions.length === actionsLength ? actionsLength : actionsLength - 1);\n\n const className = cn('-mb-2 flex justify-end pl-2 text-right', {\n // Adjust negative margin on row actions cell to ensure that the cell aligns vertically.\n '-mt-2': fontSize === FONT_SIZE.small,\n '-mt-1.5': fontSize !== FONT_SIZE.small,\n });\n\n content = (\n <span className={className} ref={ref}>\n {actionsOnRow.map((button, index) => {\n const tooltip = String(button.props.tooltip ?? button.props['aria-label'] ?? '');\n\n return React.cloneElement(button, {\n appearance: 'transparent',\n key: index,\n tabIndex: isCurrentRow ? 0 : -1,\n tooltip: button.props.shortcut ? (\n <>\n {tooltip}\n <Shortcut className=\"ml-2\" keys={button.props.shortcut} />\n </>\n ) : (\n tooltip\n ),\n });\n })}\n {actionsInMenu.length ? (\n <IconButton\n appearance=\"transparent\"\n aria-label={texts.table3.columns.actions.tooltip}\n icon=\"more\"\n tabIndex={isCurrentRow ? 0 : -1}\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n {actionsInMenu.map((action, i) => (\n <Menu.Item key={i} {...action.props} shortcut={action.props.shortcut}>\n {action.props['aria-label']}\n </Menu.Item>\n ))}\n </Menu.Content>\n </Menu>\n )}\n />\n ) : null}\n </span>\n );\n }\n\n return <DisplayCell {...props}>{content}</DisplayCell>;\n}) as <TType = unknown>(props: MemoedCellProps<TType>) => JSX.Element;\n\ntype CellProps<TType = unknown> = CellContext<TType, unknown>;\n\nfunction Cell<TType = unknown>(context: CellProps<TType>) {\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = context.table.options.meta as TableMeta<TType>;\n\n return (\n <MemoedCell\n {...context}\n actions={tableMeta.rowActions.actionsForRow}\n actionsLength={tableMeta.rowActions.actionsForRowLength}\n fontSize={tableMeta.fontSize.size}\n isCurrentRow={tableMeta.currentRow.currentRowIndex === rowIndex}\n isEditing={tableMeta.editing.isEditing}\n isResizingColumn={!!context.table.getState().columnSizingInfo.isResizingColumn}\n isHoverStatePaused={!!tableMeta.hoverState.isPaused}\n />\n );\n}\n\nexport function createRowActionsColumn<TType = unknown>(): DisplayColumnDef<TType, unknown> {\n return {\n id: COLUMN_ID,\n header: ColumnHeader,\n cell: Cell,\n footer: Footer,\n meta: {\n align: 'right',\n className: cn(\n '!pt-[var(--table3-cell-padding-y)] print:opacity-0 [[role=\"table\"][data-editing=\"false\"]_&]:group-[[data-current=\"true\"]]/row:sticky [[role=\"table\"][data-pause-hover=\"false\"][data-editing=\"false\"]_&]:group-hover/row:sticky right-0 !pl-1 !pr-1',\n 'shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]',\n 'group-[[data-current=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: '',\n headerClassName: 'items-center !p-0',\n },\n // options\n enableResizing: false,\n };\n}\n"],"names":["COLUMN_ID","MemoedCell","React","memo","props","actions","actionsLength","fontSize","isCurrentRow","isEditing","isResizingColumn","isHoverStatePaused","row","isHovered","useContext","RowContext","texts","useLocalization","ref","useRef","content","length","visibleActions","map","action","original","filter","actionsOnRow","slice","actionsInMenu","className","cn","FONT_SIZE","small","button","index","tooltip","String","_ref","_button$props$tooltip","cloneElement","appearance","key","tabIndex","shortcut","Shortcut","keys","IconButton","table3","columns","icon","menu","menuProps","Menu","Content","i","Item","DisplayCell","Cell","context","rowIndex","tableMeta","table","options","meta","rowActions","actionsForRow","actionsForRowLength","size","currentRow","currentRowIndex","editing","getState","columnSizingInfo","hoverState","isPaused","createRowActionsColumn","id","header","ColumnHeader","cell","footer","Footer","align","enableOrdering","enableSearch","enableTruncate","headerClassName","enableResizing"],"mappings":";;;;;;;;;;;;MAcaA,SAAS,GAAG;AAYzB,MAAMC,UAAU,gBAAGC,cAAK,CAACC,IAAI,CAAC,SAASF,UAAUA,CAAkBG,KAA6B;EAC5F,MAAM;IAAEC,OAAO;IAAEC,aAAa;IAAEC,QAAQ;IAAEC,YAAY;IAAEC,SAAS;IAAEC,gBAAgB;IAAEC,kBAAkB;IAAEC;GAAK,GAAGR,KAAK;EACtH,MAAM;IAAES;GAAW,GAAGX,cAAK,CAACY,UAAU,CAACC,UAAU,CAAC;EAClD,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGhB,cAAK,CAACiB,MAAM,CAAyB,IAAI,CAAC;;;;;;;;;;;;;;;EAkBtD,IAAIC,OAAO;;;EAIX,IAAIf,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEgB,MAAM,IAAI,CAACZ,SAAS,KAAKD,YAAY,IAAKK,SAAS,IAAI,CAACF,kBAAkB,IAAI,CAACD,gBAAiB,CAAC,EAAE;IAC5G,MAAMY,cAAc,GAAGjB,OAAO,CAACkB,GAAG,CAACC,MAAM,IAAIA,MAAM,CAACZ,GAAG,CAACa,QAAQ,CAAC,CAAC,CAACC,MAAM,CAACF,MAAM,IAAI,CAAC,CAACA,MAAM,CAAkB;IAE9G,MAAMG,YAAY,GACdL,cAAc,CAACD,MAAM,KAAKf,aAAa,GAAGgB,cAAc,GAAGA,cAAc,CAACM,KAAK,CAAC,CAAC,EAAEtB,aAAa,GAAG,CAAC,CAAC;IACzG,MAAMuB,aAAa,GAAGP,cAAc,CAACM,KAAK,CAACN,cAAc,CAACD,MAAM,KAAKf,aAAa,GAAGA,aAAa,GAAGA,aAAa,GAAG,CAAC,CAAC;IAEvH,MAAMwB,SAAS,GAAGC,EAAE,CAAC,wCAAwC,EAAE;;MAE3D,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,EACxD,wEAAwE,EACxE,kDAAkD,EAClD,yDAAyD,CAC5D;MACDqD,cAAc,EAAE,KAAK;MACrBC,YAAY,EAAE,KAAK;MACnBC,cAAc,EAAE,KAAK;MACrBR,MAAM,EAAE,EAAE;MACVS,eAAe,EAAE;KACpB;;IAEDC,cAAc,EAAE;GACnB;AACL;;;;"}
@@ -17,6 +17,7 @@ const savingIndicatorHideDelay = 3000;
17
17
  const COLUMN_ID = '__editing_actions';
18
18
  const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
19
19
  const {
20
+ hasChanges,
20
21
  isCurrentRow,
21
22
  isEditing,
22
23
  row,
@@ -25,8 +26,6 @@ const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
25
26
  const tableMeta = table.options.meta;
26
27
  const savingState = tableMeta.editing.savingStates && tableMeta.editing.savingStates[row.id];
27
28
  const [isSavedIndicatorVisible, setIsSavingIndicatorVisible] = React__default.useState(false);
28
- const changeset = tableMeta.editing.changes ? Object.keys(tableMeta.editing.changes) : [];
29
- const isRowInEditingState = changeset.indexOf(row.id) >= 0;
30
29
  const {
31
30
  texts
32
31
  } = useLocalization();
@@ -48,14 +47,14 @@ const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
48
47
  title: texts.table3.editing.saving.progress
49
48
  }, /*#__PURE__*/React__default.createElement(Spinner, {
50
49
  delay: 0,
51
- className: "!text-grey-700 mr-1.5 !h-5 !w-5"
50
+ className: "!text-grey-700 mr-1 !h-5 !w-5"
52
51
  }));
53
52
  } else if (isSavedIndicatorVisible) {
54
53
  content = /*#__PURE__*/React__default.createElement(Tooltip, {
55
54
  title: texts.table3.editing.saving.complete
56
55
  }, /*#__PURE__*/React__default.createElement(Icon, {
57
56
  name: "tick",
58
- className: "!text-grey-700 mr-1"
57
+ className: "!text-grey-700 mr-1 !h-5 !w-5"
59
58
  }));
60
59
  }
61
60
  }
@@ -66,11 +65,11 @@ const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
66
65
  icon: "more",
67
66
  menu: menuProps => /*#__PURE__*/React__default.createElement(Menu, Object.assign({}, menuProps), /*#__PURE__*/React__default.createElement(Menu.Content, null, /*#__PURE__*/React__default.createElement(Menu.Item, {
68
67
  icon: "tick",
69
- disabled: !isRowInEditingState,
68
+ disabled: !hasChanges,
70
69
  onClick: () => tableMeta.editing.saveChangesIfNeeded()
71
70
  }, texts.table3.editing.actions.save), /*#__PURE__*/React__default.createElement(Menu.Item, {
72
71
  icon: "close",
73
- disabled: !isRowInEditingState,
72
+ disabled: !hasChanges,
74
73
  onClick: () => tableMeta.editing.resetChange(row.id)
75
74
  }, texts.table3.editing.actions.clear), /*#__PURE__*/React__default.createElement(Menu.Item, {
76
75
  icon: "undo",
@@ -79,12 +78,15 @@ const MemoedCell = /*#__PURE__*/React__default.memo(function MemoedCell(props) {
79
78
  tabIndex: isCurrentRow ? 0 : -1
80
79
  }));
81
80
  }
81
+ const contentClassName = cn('flex items-center justify-end text-right', {
82
+ '-mb-2 -mt-2': isCurrentRow
83
+ });
82
84
  return /*#__PURE__*/React__default.createElement(DisplayCell, Object.assign({}, props, {
83
85
  className: cn({
84
86
  '!sticky': !!content
85
87
  })
86
88
  }), content ? /*#__PURE__*/React__default.createElement("span", {
87
- className: "-mb-2 -mt-2 flex items-center justify-end text-right"
89
+ className: contentClassName
88
90
  }, content) : undefined);
89
91
  });
90
92
  function Cell(props) {
@@ -92,12 +94,14 @@ function Cell(props) {
92
94
  rowIndex
93
95
  } = React__default.useContext(RowContext);
94
96
  const tableMeta = props.table.options.meta;
97
+ const changeset = tableMeta.editing.changes ? Object.keys(tableMeta.editing.changes) : [];
95
98
  return /*#__PURE__*/React__default.createElement(MemoedCell, Object.assign({}, props, {
99
+ hasChanges: changeset.indexOf(props.row.id) >= 0,
96
100
  isCurrentRow: tableMeta.currentRow.currentRowIndex === rowIndex,
97
101
  isEditing: tableMeta.editing.isEditing
98
102
  }));
99
103
  }
100
- const EDITING_ACTIONS_WIDTH = 45;
104
+ const EDITING_ACTIONS_WIDTH = 60;
101
105
  function createRowEditingActionsColumn() {
102
106
  return {
103
107
  id: COLUMN_ID,
@@ -106,7 +110,7 @@ function createRowEditingActionsColumn() {
106
110
  footer: Footer,
107
111
  meta: {
108
112
  align: 'right',
109
- className: cn('items-center print:opacity-0 [[role="table"][data-editing="true"]_&]:group-[[data-current="true"]]/row:sticky right-0 !pl-0 !pr-1', '[[role="table"][data-editing="true"]_&]:group-[[data-current="true"]]/row:shadow-[-6px_0px_6px] [[role="table"][data-pause-hover="false"][data-editing="true"]_&]:group-hover/row:shadow-[-6px_0px_6px]', 'group-[[data-current="true"][data-selected="false"]]/row:text-grey-200', 'group-[[data-selected="true"]]/row:text-blue-100', 'group-[[data-selected="false"]:hover]/row:text-grey-100'),
113
+ className: cn('items-center print:opacity-0 [[role="table"][data-editing="true"]_&]:group-[[data-current="true"]]/row:sticky right-0 !pl-0 !pr-1', '[[role="table"][data-editing="true"]_&]:group-[[data-current="true"]]/row:shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]', 'group-[[data-current="true"][data-selected="false"]]/row:text-grey-200', 'group-[[data-selected="true"]]/row:text-blue-100', 'group-[[data-selected="false"]:hover]/row:text-grey-100'),
110
114
  enableOrdering: false,
111
115
  enableSearch: false,
112
116
  enableTruncate: false,
@@ -1 +1 @@
1
- {"version":3,"file":"EditingActions.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/internal/EditingActions.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { CellContext, TableMeta, DisplayColumnDef } from '@tanstack/react-table';\nimport { Spinner } from '../../../../Spinner/Spinner';\nimport { SavingStateValue } from '../../../hooks/features/useEditing';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { Menu } from '../../../../Menu/Menu';\nimport { RowContext } from '../../rows/RowContext';\nimport { DisplayCell } from '../cell/DisplayCell';\nimport { Header as ColumnHeader } from '../header/Header';\nimport { Footer } from '../footer/Footer';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport useTimer from '../../../../../utils/hooks/useTimer';\nimport { Icon } from '../../../../Icon/Icon';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\n\nexport type EditingActionsProps<TType = unknown> = CellContext<TType, unknown> & {\n className?: string;\n isHovered: boolean;\n};\n\nconst savingIndicatorHideDelay = 3000;\n\nexport const COLUMN_ID = '__editing_actions';\n\ntype MemoedCellProps<TType = unknown> = CellContext<TType, unknown> & {\n isCurrentRow: boolean;\n isEditing: boolean;\n};\n\nconst MemoedCell = React.memo(function MemoedCell<TType = unknown>(props: MemoedCellProps<TType>) {\n const { isCurrentRow, isEditing, row, table } = props;\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n const savingState = tableMeta.editing.savingStates && tableMeta.editing.savingStates[row.id];\n const [isSavedIndicatorVisible, setIsSavingIndicatorVisible] = React.useState(false);\n const changeset = tableMeta.editing.changes ? Object.keys(tableMeta.editing.changes) : [];\n const isRowInEditingState = changeset.indexOf(row.id) >= 0;\n const { texts } = useLocalization();\n\n const handleSaved = () => {\n setIsSavingIndicatorVisible(false);\n tableMeta.editing.removeSavingState(row.id);\n };\n const timer = useTimer(savingIndicatorHideDelay, handleSaved);\n\n React.useEffect(() => {\n if (savingState && savingState.state === SavingStateValue.Saved && !isSavedIndicatorVisible) {\n setIsSavingIndicatorVisible(true);\n timer.start();\n }\n }, [savingState]);\n\n let content;\n\n if (savingState) {\n if (savingState.state === SavingStateValue.Saving) {\n content = (\n <Tooltip title={texts.table3.editing.saving.progress}>\n <Spinner delay={0} className=\"!text-grey-700 mr-1.5 !h-5 !w-5\" />\n </Tooltip>\n );\n } else if (isSavedIndicatorVisible) {\n content = (\n <Tooltip title={texts.table3.editing.saving.complete}>\n <Icon name=\"tick\" className=\"!text-grey-700 mr-1\" />\n </Tooltip>\n );\n }\n }\n\n if (isEditing && isCurrentRow) {\n content = (\n <>\n {content}\n <IconButton\n appearance=\"transparent\"\n aria-label={texts.table3.editing.actions.tooltip}\n icon=\"more\"\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n <Menu.Item\n icon=\"tick\"\n disabled={!isRowInEditingState}\n onClick={() => tableMeta.editing.saveChangesIfNeeded()}>\n {texts.table3.editing.actions.save}\n </Menu.Item>\n <Menu.Item\n icon=\"close\"\n disabled={!isRowInEditingState}\n onClick={() => tableMeta.editing.resetChange(row.id)}>\n {texts.table3.editing.actions.clear}\n </Menu.Item>\n <Menu.Item icon=\"undo\" onClick={() => tableMeta.editing.toggleEditing(false)}>\n {texts.table3.editing.actions.exit}\n </Menu.Item>\n </Menu.Content>\n </Menu>\n )}\n tabIndex={isCurrentRow ? 0 : -1}\n />\n </>\n );\n }\n\n return (\n <DisplayCell {...props} className={cn({ '!sticky': !!content })}>\n {content ? <span className=\"-mb-2 -mt-2 flex items-center justify-end text-right\">{content}</span> : undefined}\n </DisplayCell>\n );\n}) as <TType = unknown>(props: MemoedCellProps<TType>) => JSX.Element;\n\ntype CellProps<TType = unknown> = CellContext<TType, unknown> & {};\n\nfunction Cell<TType = unknown>(props: CellProps<TType>) {\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = props.table.options.meta as TableMeta<TType>;\n\n return (\n <MemoedCell\n {...props}\n isCurrentRow={tableMeta.currentRow.currentRowIndex === rowIndex}\n isEditing={tableMeta.editing.isEditing}\n />\n );\n}\n\nexport const EDITING_ACTIONS_WIDTH = 45;\n\nexport function createRowEditingActionsColumn<TType = unknown>(): DisplayColumnDef<TType, unknown> {\n return {\n id: COLUMN_ID,\n header: ColumnHeader,\n cell: Cell,\n footer: Footer,\n meta: {\n align: 'right',\n className: cn(\n 'items-center print:opacity-0 [[role=\"table\"][data-editing=\"true\"]_&]:group-[[data-current=\"true\"]]/row:sticky right-0 !pl-0 !pr-1',\n '[[role=\"table\"][data-editing=\"true\"]_&]:group-[[data-current=\"true\"]]/row:shadow-[-6px_0px_6px] [[role=\"table\"][data-pause-hover=\"false\"][data-editing=\"true\"]_&]:group-hover/row:shadow-[-6px_0px_6px]',\n 'group-[[data-current=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: '',\n headerClassName: 'items-center !p-0',\n },\n // options\n enableResizing: false,\n size: EDITING_ACTIONS_WIDTH,\n minSize: EDITING_ACTIONS_WIDTH,\n };\n}\n"],"names":["savingIndicatorHideDelay","COLUMN_ID","MemoedCell","React","memo","props","isCurrentRow","isEditing","row","table","tableMeta","options","meta","savingState","editing","savingStates","id","isSavedIndicatorVisible","setIsSavingIndicatorVisible","useState","changeset","changes","Object","keys","isRowInEditingState","indexOf","texts","useLocalization","handleSaved","removeSavingState","timer","useTimer","useEffect","state","SavingStateValue","Saved","start","content","Saving","Tooltip","title","table3","saving","progress","Spinner","delay","className","complete","Icon","name","IconButton","appearance","actions","tooltip","icon","menu","menuProps","Menu","Content","Item","disabled","onClick","saveChangesIfNeeded","save","resetChange","clear","toggleEditing","exit","tabIndex","DisplayCell","cn","undefined","Cell","rowIndex","useContext","RowContext","currentRow","currentRowIndex","EDITING_ACTIONS_WIDTH","createRowEditingActionsColumn","header","ColumnHeader","cell","footer","Footer","align","enableOrdering","enableSearch","enableTruncate","headerClassName","enableResizing","size","minSize"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAMA,wBAAwB,GAAG,IAAI;MAExBC,SAAS,GAAG;AAOzB,MAAMC,UAAU,gBAAGC,cAAK,CAACC,IAAI,CAAC,SAASF,UAAUA,CAAkBG,KAA6B;EAC5F,MAAM;IAAEC,YAAY;IAAEC,SAAS;IAAEC,GAAG;IAAEC;GAAO,GAAGJ,KAAK;EAErD,MAAMK,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAAwB;EACxD,MAAMC,WAAW,GAAGH,SAAS,CAACI,OAAO,CAACC,YAAY,IAAIL,SAAS,CAACI,OAA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;MAChC,CAET;;EAGL,oBACIH,6BAACkE,WAAW,oBAAKhE,KAAK;IAAEyC,SAAS,EAAEwB,EAAE,CAAC;MAAE,SAAS,EAAE,CAAC,CAACjC;KAAS;MACzDA,OAAO,gBAAGlC;IAAM2C,SAAS,EAAC;KAAwDT,OAAO,CAAQ,GAAGkC,SAAS,CACpG;AAEtB,CAAC,CAAoE;AAIrE,SAASC,IAAIA,CAAkBnE,KAAuB;EAClD,MAAM;IAAEoE;GAAU,GAAGtE,cAAK,CAACuE,UAAU,CAACC,UAAU,CAAC;EACjD,MAAMjE,SAAS,GAAGL,KAAK,CAACI,KAAK,CAACE,OAAO,CAACC,IAAwB;EAE9D,oBACIT,6BAACD,UAAU,oBACHG,KAAK;IACTC,YAAY,EAAEI,SAAS,CAACkE,UAAU,CAACC,eAAe,KAAKJ,QAAQ;IAC/DlE,SAAS,EAAEG,SAAS,CAACI,OAAO,CAACP;KAC/B;AAEV;MAEauE,qBAAqB,GAAG;SAErBC,6BAA6BA;EACzC,OAAO;IACH/D,EAAE,EAAEf,SAAS;IACb+E,MAAM,EAAEC,MAAY;IACpBC,IAAI,EAAEV,IAAI;IACVW,MAAM,EAAEC,MAAM;IACdxE,IAAI,EAAE;MACFyE,KAAK,EAAE,OAAO;MACdvC,SAAS,EAAEwB,EAAE,CACT,mIAAmI,EACnI,yMAAyM,EACzM,wEAAwE,EACxE,kDAAkD,EAClD,yDAAyD,CAC5D;MACDgB,cAAc,EAAE,KAAK;MACrBC,YAAY,EAAE,KAAK;MACnBC,cAAc,EAAE,KAAK;MACrBR,MAAM,EAAE,EAAE;MACVS,eAAe,EAAE;KACpB;;IAEDC,cAAc,EAAE,KAAK;IACrBC,IAAI,EAAEb,qBAAqB;IAC3Bc,OAAO,EAAEd;GACZ;AACL;;;;"}
1
+ {"version":3,"file":"EditingActions.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/internal/EditingActions.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { CellContext, TableMeta, DisplayColumnDef } from '@tanstack/react-table';\nimport { Spinner } from '../../../../Spinner/Spinner';\nimport { SavingStateValue } from '../../../hooks/features/useEditing';\nimport { IconButton } from '../../../../IconButton/IconButton';\nimport { Menu } from '../../../../Menu/Menu';\nimport { RowContext } from '../../rows/RowContext';\nimport { DisplayCell } from '../cell/DisplayCell';\nimport { Header as ColumnHeader } from '../header/Header';\nimport { Footer } from '../footer/Footer';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport useTimer from '../../../../../utils/hooks/useTimer';\nimport { Icon } from '../../../../Icon/Icon';\nimport { Tooltip } from '../../../../Tooltip/Tooltip';\n\nexport type EditingActionsProps<TType = unknown> = CellContext<TType, unknown> & {\n className?: string;\n isHovered: boolean;\n};\n\nconst savingIndicatorHideDelay = 3000;\n\nexport const COLUMN_ID = '__editing_actions';\n\ntype MemoedCellProps<TType = unknown> = CellContext<TType, unknown> & {\n hasChanges: boolean;\n isCurrentRow: boolean;\n isEditing: boolean;\n};\n\nconst MemoedCell = React.memo(function MemoedCell<TType = unknown>(props: MemoedCellProps<TType>) {\n const { hasChanges, isCurrentRow, isEditing, row, table } = props;\n\n const tableMeta = table.options.meta as TableMeta<TType>;\n const savingState = tableMeta.editing.savingStates && tableMeta.editing.savingStates[row.id];\n const [isSavedIndicatorVisible, setIsSavingIndicatorVisible] = React.useState(false);\n const { texts } = useLocalization();\n\n const handleSaved = () => {\n setIsSavingIndicatorVisible(false);\n tableMeta.editing.removeSavingState(row.id);\n };\n const timer = useTimer(savingIndicatorHideDelay, handleSaved);\n\n React.useEffect(() => {\n if (savingState && savingState.state === SavingStateValue.Saved && !isSavedIndicatorVisible) {\n setIsSavingIndicatorVisible(true);\n timer.start();\n }\n }, [savingState]);\n\n let content;\n\n if (savingState) {\n if (savingState.state === SavingStateValue.Saving) {\n content = (\n <Tooltip title={texts.table3.editing.saving.progress}>\n <Spinner delay={0} className=\"!text-grey-700 mr-1 !h-5 !w-5\" />\n </Tooltip>\n );\n } else if (isSavedIndicatorVisible) {\n content = (\n <Tooltip title={texts.table3.editing.saving.complete}>\n <Icon name=\"tick\" className=\"!text-grey-700 mr-1 !h-5 !w-5\" />\n </Tooltip>\n );\n }\n }\n\n if (isEditing && isCurrentRow) {\n content = (\n <>\n {content}\n <IconButton\n appearance=\"transparent\"\n aria-label={texts.table3.editing.actions.tooltip}\n icon=\"more\"\n menu={menuProps => (\n <Menu {...menuProps}>\n <Menu.Content>\n <Menu.Item\n icon=\"tick\"\n disabled={!hasChanges}\n onClick={() => tableMeta.editing.saveChangesIfNeeded()}>\n {texts.table3.editing.actions.save}\n </Menu.Item>\n <Menu.Item\n icon=\"close\"\n disabled={!hasChanges}\n onClick={() => tableMeta.editing.resetChange(row.id)}>\n {texts.table3.editing.actions.clear}\n </Menu.Item>\n <Menu.Item icon=\"undo\" onClick={() => tableMeta.editing.toggleEditing(false)}>\n {texts.table3.editing.actions.exit}\n </Menu.Item>\n </Menu.Content>\n </Menu>\n )}\n tabIndex={isCurrentRow ? 0 : -1}\n />\n </>\n );\n }\n\n const contentClassName = cn('flex items-center justify-end text-right', { '-mb-2 -mt-2': isCurrentRow });\n return (\n <DisplayCell {...props} className={cn({ '!sticky': !!content })}>\n {content ? <span className={contentClassName}>{content}</span> : undefined}\n </DisplayCell>\n );\n}) as <TType = unknown>(props: MemoedCellProps<TType>) => JSX.Element;\n\ntype CellProps<TType = unknown> = CellContext<TType, unknown> & {};\n\nfunction Cell<TType = unknown>(props: CellProps<TType>) {\n const { rowIndex } = React.useContext(RowContext);\n const tableMeta = props.table.options.meta as TableMeta<TType>;\n const changeset = tableMeta.editing.changes ? Object.keys(tableMeta.editing.changes) : [];\n\n return (\n <MemoedCell\n {...props}\n hasChanges={changeset.indexOf(props.row.id) >= 0}\n isCurrentRow={tableMeta.currentRow.currentRowIndex === rowIndex}\n isEditing={tableMeta.editing.isEditing}\n />\n );\n}\n\nexport const EDITING_ACTIONS_WIDTH = 60;\n\nexport function createRowEditingActionsColumn<TType = unknown>(): DisplayColumnDef<TType, unknown> {\n return {\n id: COLUMN_ID,\n header: ColumnHeader,\n cell: Cell,\n footer: Footer,\n meta: {\n align: 'right',\n className: cn(\n 'items-center print:opacity-0 [[role=\"table\"][data-editing=\"true\"]_&]:group-[[data-current=\"true\"]]/row:sticky right-0 !pl-0 !pr-1',\n '[[role=\"table\"][data-editing=\"true\"]_&]:group-[[data-current=\"true\"]]/row:shadow-[-6px_0px_6px_var(--table3-row-actions-shadow)]',\n 'group-[[data-current=\"true\"][data-selected=\"false\"]]/row:text-grey-200',\n 'group-[[data-selected=\"true\"]]/row:text-blue-100',\n 'group-[[data-selected=\"false\"]:hover]/row:text-grey-100'\n ),\n enableOrdering: false,\n enableSearch: false,\n enableTruncate: false,\n header: '',\n headerClassName: 'items-center !p-0',\n },\n // options\n enableResizing: false,\n size: EDITING_ACTIONS_WIDTH,\n minSize: EDITING_ACTIONS_WIDTH,\n };\n}\n"],"names":["savingIndicatorHideDelay","COLUMN_ID","MemoedCell","React","memo","props","hasChanges","isCurrentRow","isEditing","row","table","tableMeta","options","meta","savingState","editing","savingStates","id","isSavedIndicatorVisible","setIsSavingIndicatorVisible","useState","texts","useLocalization","handleSaved","removeSavingState","timer","useTimer","useEffect","state","SavingStateValue","Saved","start","content","Saving","Tooltip","title","table3","saving","progress","Spinner","delay","className","complete","Icon","name","IconButton","appearance","actions","tooltip","icon","menu","menuProps","Menu","Content","Item","disabled","onClick","saveChangesIfNeeded","save","resetChange","clear","toggleEditing","exit","tabIndex","contentClassName","cn","DisplayCell","undefined","Cell","rowIndex","useContext","RowContext","changeset","changes","Object","keys","indexOf","currentRow","currentRowIndex","EDITING_ACTIONS_WIDTH","createRowEditingActionsColumn","header","ColumnHeader","cell","footer","Footer","align","enableOrdering","enableSearch","enableTruncate","headerClassName","enableResizing","size","minSize"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAMA,wBAAwB,GAAG,IAAI;MAExBC,SAAS,GAAG;AAQzB,MAAMC,UAAU,gBAAG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E,kDAAkD,EAClD,yDAAyD,CAC5D;MACDsB,cAAc,EAAE,KAAK;MACrBC,YAAY,EAAE,KAAK;MACnBC,cAAc,EAAE,KAAK;MACrBR,MAAM,EAAE,EAAE;MACVS,eAAe,EAAE;KACpB;;IAEDC,cAAc,EAAE,KAAK;IACrBC,IAAI,EAAEb,qBAAqB;IAC3Bc,OAAO,EAAEd;GACZ;AACL;;;;"}
@@ -1,6 +1,6 @@
1
1
  import cn from 'classnames';
2
+ import { FONT_SIZE } from '../toolbar/FontSize.js';
2
3
 
3
- const MIN_COLUMN_SIZE = 80; // accounts for padding and sort controls
4
4
  const PRINT_MIN_COLUMN_SIZE = 20; // while printing, it accounts for minimum width each column can take
5
5
  const getCellAlignmentClasses = (alignment = 'left') => {
6
6
  return cn({
@@ -9,10 +9,22 @@ const getCellAlignmentClasses = (alignment = 'left') => {
9
9
  'justify-center text-center': alignment === 'center'
10
10
  });
11
11
  };
12
+ const getFontBasedMinColumnSize = fontSize => {
13
+ // The minimum column size are based on the minimum usuable width of Datepicker
14
+ switch (fontSize) {
15
+ case FONT_SIZE.small:
16
+ return 57;
17
+ case FONT_SIZE.large:
18
+ return 83;
19
+ default:
20
+ case FONT_SIZE.medium:
21
+ return 72;
22
+ }
23
+ };
12
24
  // Hiding input number spin buttons
13
25
  const getInputAppearanceClassnames = () => {
14
26
  return cn('[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none');
15
27
  };
16
28
 
17
- export { MIN_COLUMN_SIZE, PRINT_MIN_COLUMN_SIZE, getCellAlignmentClasses, getInputAppearanceClassnames };
29
+ export { PRINT_MIN_COLUMN_SIZE, getCellAlignmentClasses, getFontBasedMinColumnSize, getInputAppearanceClassnames };
18
30
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sources":["../../../../../../../../../src/components/Table3/components/columns/styles.ts"],"sourcesContent":["import cn from 'classnames';\nimport { Table3ColumnAlignment } from '../../types';\n\nexport const MIN_COLUMN_SIZE = 80; // accounts for padding and sort controls\nexport const PRINT_MIN_COLUMN_SIZE = 20; // while printing, it accounts for minimum width each column can take\n\nexport const getCellAlignmentClasses = (alignment: Table3ColumnAlignment = 'left') => {\n return cn({\n 'justify-start text-left': alignment === 'left',\n 'justify-end text-right': alignment === 'right',\n 'justify-center text-center': alignment === 'center',\n });\n};\n\n// Hiding input number spin buttons\nexport const getInputAppearanceClassnames = () => {\n return cn(\n '[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none'\n );\n};\n"],"names":["MIN_COLUMN_SIZE","PRINT_MIN_COLUMN_SIZE","getCellAlignmentClasses","alignment","cn","getInputAppearanceClassnames"],"mappings":";;MAGaA,eAAe,GAAG,GAAG;MACrBC,qBAAqB,GAAG,GAAG;MAE3BC,uBAAuB,GAAGA,CAACC,YAAmC,MAAM;EAC7E,OAAOC,EAAE,CAAC;IACN,yBAAyB,EAAED,SAAS,KAAK,MAAM;IAC/C,wBAAwB,EAAEA,SAAS,KAAK,OAAO;IAC/C,4BAA4B,EAAEA,SAAS,KAAK;GAC/C,CAAC;AACN;AAEA;MACaE,4BAA4B,GAAGA;EACxC,OAAOD,EAAE,CACL,sHAAsH,CACzH;AACL;;;;"}
1
+ {"version":3,"file":"styles.js","sources":["../../../../../../../../../src/components/Table3/components/columns/styles.ts"],"sourcesContent":["import cn from 'classnames';\nimport { Table3ColumnAlignment, Table3FontSize } from '../../types';\nimport { FONT_SIZE } from '../toolbar/FontSize';\n\nexport const PRINT_MIN_COLUMN_SIZE = 20; // while printing, it accounts for minimum width each column can take\n\nexport const getCellAlignmentClasses = (alignment: Table3ColumnAlignment = 'left') => {\n return cn({\n 'justify-start text-left': alignment === 'left',\n 'justify-end text-right': alignment === 'right',\n 'justify-center text-center': alignment === 'center',\n });\n};\n\nexport const getFontBasedMinColumnSize = (fontSize: Table3FontSize | undefined) => {\n // The minimum column size are based on the minimum usuable width of Datepicker\n switch (fontSize) {\n case FONT_SIZE.small:\n return 57;\n case FONT_SIZE.large:\n return 83;\n default:\n case FONT_SIZE.medium:\n return 72;\n }\n};\n\n// Hiding input number spin buttons\nexport const getInputAppearanceClassnames = () => {\n return cn(\n '[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none'\n );\n};\n"],"names":["PRINT_MIN_COLUMN_SIZE","getCellAlignmentClasses","alignment","cn","getFontBasedMinColumnSize","fontSize","FONT_SIZE","small","large","medium","getInputAppearanceClassnames"],"mappings":";;;MAIaA,qBAAqB,GAAG,GAAG;MAE3BC,uBAAuB,GAAGA,CAACC,YAAmC,MAAM;EAC7E,OAAOC,EAAE,CAAC;IACN,yBAAyB,EAAED,SAAS,KAAK,MAAM;IAC/C,wBAAwB,EAAEA,SAAS,KAAK,OAAO;IAC/C,4BAA4B,EAAEA,SAAS,KAAK;GAC/C,CAAC;AACN;MAEaE,yBAAyB,GAAIC,QAAoC;;EAE1E,QAAQA,QAAQ;IACZ,KAAKC,SAAS,CAACC,KAAK;MAChB,OAAO,EAAE;IACb,KAAKD,SAAS,CAACE,KAAK;MAChB,OAAO,EAAE;IACb;IACA,KAAKF,SAAS,CAACG,MAAM;MACjB,OAAO,EAAE;;AAErB;AAEA;MACaC,4BAA4B,GAAGA;EACxC,OAAOP,EAAE,CACL,sHAAsH,CACzH;AACL;;;;"}
@@ -5,15 +5,15 @@ import { useLocalization } from '../../../Provider/Localization.js';
5
5
  import { Checkbox } from '../../../Checkbox/Checkbox.js';
6
6
  import { Input } from '../../../Input/Input.js';
7
7
  import { Popover } from '../../../Popover/Popover.js';
8
+ import { isInternalColumn } from '../../util/columns.js';
9
+ import { ensureOrdering } from '../../hooks/features/useColumnOrdering.js';
8
10
  import { Container } from '../../../../primitives/Sortable/components/Container.js';
9
11
  import { arrayMove } from '@dnd-kit/sortable';
10
12
  import { Item } from '../../../../primitives/Sortable/components/Item.js';
11
13
  import { List } from '../../../../primitives/Sortable/components/List.js';
12
- import { isInternalColumn } from '../../util/columns.js';
13
- import { ensureOrdering } from '../../hooks/features/useColumnOrdering.js';
14
14
 
15
15
  const Column = /*#__PURE__*/React__default.forwardRef(function Column(props, ref) {
16
- var _column$columnDef$met;
16
+ var _column$parent, _column$parent$column, _column$columnDef$met;
17
17
  const {
18
18
  column,
19
19
  draggable = false,
@@ -27,6 +27,7 @@ const Column = /*#__PURE__*/React__default.forwardRef(function Column(props, ref
27
27
  });
28
28
  const attributes = draggable ? dragAttributes : undefined;
29
29
  const isVisible = column.getIsVisible();
30
+ const parentText = column.parent ? (_column$parent = column.parent) === null || _column$parent === void 0 ? void 0 : (_column$parent$column = _column$parent.columnDef.meta) === null || _column$parent$column === void 0 ? void 0 : _column$parent$column.header : null;
30
31
  return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
31
32
  key: column.id,
32
33
  className: className,
@@ -37,7 +38,9 @@ const Column = /*#__PURE__*/React__default.forwardRef(function Column(props, ref
37
38
  className: "text-grey-500 group-hover/column:text-grey-700 -mx-2 !h-5"
38
39
  }) : null, /*#__PURE__*/React__default.createElement("span", {
39
40
  className: "flex-grow truncate"
40
- }, (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.header), canHide ? /*#__PURE__*/React__default.createElement(Checkbox, {
41
+ }, (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.header, parentText ? /*#__PURE__*/React__default.createElement("span", {
42
+ className: "italic"
43
+ }, " (", parentText, ")") : null), canHide ? /*#__PURE__*/React__default.createElement(Checkbox, {
41
44
  checked: isVisible,
42
45
  onChange: () => column.toggleVisibility(!isVisible)
43
46
  }) : null);
@@ -55,8 +58,8 @@ function ColumnSettingsPopover(props) {
55
58
  const allColumns = table.getAllLeafColumns();
56
59
  const tableMeta = table.options.meta;
57
60
  const columns = React__default.useMemo(() => allColumns.filter(column => !isInternalColumn(column.id)).filter(column => {
58
- var _column$columnDef$met2;
59
- return query !== null && query !== void 0 && query.length ? (_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.header.toLowerCase().includes(query.toLowerCase()) : true;
61
+ var _column$columnDef$met2, _column$parent2, _column$parent2$colum;
62
+ return query !== null && query !== void 0 && query.length ? ((_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.header.toLowerCase().includes(query.toLowerCase())) || ((_column$parent2 = column.parent) === null || _column$parent2 === void 0 ? void 0 : (_column$parent2$colum = _column$parent2.columnDef.meta) === null || _column$parent2$colum === void 0 ? void 0 : _column$parent2$colum.header.toLowerCase().includes(query.toLowerCase())) : true;
60
63
  }), [allColumns, query]);
61
64
  const listClassName = 'flex max-h-64 flex-col gap-y-px overflow-auto';
62
65
  const handleReorder = (activeId, overId) => {
@@ -71,7 +74,7 @@ function ColumnSettingsPopover(props) {
71
74
  return /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps, {
72
75
  anchor: trigger
73
76
  }), /*#__PURE__*/React__default.createElement(Popover.Content, null, /*#__PURE__*/React__default.createElement("div", {
74
- className: "flex w-60 flex-col gap-2"
77
+ className: "flex max-w-sm flex-col gap-2"
75
78
  }, table.options.enableHiding ? /*#__PURE__*/React__default.createElement(Input, {
76
79
  onChange: event => setQuery(event.target.value),
77
80
  placeholder: texts.table3.columnSettings.search,
@@ -1 +1 @@
1
- {"version":3,"file":"ColumnSettings.js","sources":["../../../../../../../../../src/components/Table3/components/toolbar/ColumnSettings.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Table as RTable, Column as RTColumn, TableMeta } from '@tanstack/react-table';\nimport { isInternalColumn } from '../../util/columns';\nimport { useLocalization } from '../../../Provider/Localization';\nimport { Checkbox } from '../../../Checkbox/Checkbox';\nimport { Popover, PopoverProps } from '../../../Popover/Popover';\nimport { Input } from '../../../Input/Input';\nimport * as SortablePrimitive from '../../../../primitives/Sortable/Sortable';\nimport { Icon } from '../../../Icon/Icon';\nimport { ensureOrdering } from '../../hooks/features/useColumnOrdering';\n\ntype ColumnProps<TType = unknown> = React.HTMLAttributes<HTMLDivElement> & {\n column: RTColumn<TType, unknown>;\n draggable?: boolean;\n};\n\nconst Column = React.forwardRef(function Column<TType = unknown>(props: ColumnProps<TType>, ref: React.Ref<HTMLDivElement>) {\n const { column, draggable = false, ...dragAttributes } = props;\n const canHide = column.getCanHide();\n\n const className = cn('group/column flex items-center gap-x-2 rounded py-1 px-2', {\n 'hover:bg-grey-200': canHide || draggable,\n 'hover:cursor-pointer': canHide,\n 'active:cursor-move active:bg-grey-300': draggable,\n });\n\n const attributes = draggable ? dragAttributes : undefined;\n const isVisible = column.getIsVisible();\n\n return (\n <div {...attributes} key={column.id} className={className} onClick={() => column.toggleVisibility(!isVisible)} ref={ref}>\n {draggable ? <Icon name=\"drag\" className=\"text-grey-500 group-hover/column:text-grey-700 -mx-2 !h-5\" /> : null}\n <span className=\"flex-grow truncate\">{column.columnDef.meta?.header}</span>\n {canHide ? <Checkbox checked={isVisible} onChange={() => column.toggleVisibility(!isVisible)} /> : null}\n </div>\n );\n});\n\nexport type ColumnSettingsProps<TType = unknown> = PopoverProps & {\n table: RTable<TType>;\n};\n\nexport function ColumnSettingsPopover<TType = unknown>(props: ColumnSettingsProps<TType>) {\n const { table, trigger, ...popoverProps } = props;\n const { texts } = useLocalization();\n const [query, setQuery] = React.useState('');\n const allColumns = table.getAllLeafColumns();\n const tableMeta = table.options.meta as TableMeta<TType>;\n const columns = React.useMemo(\n () =>\n allColumns\n .filter(column => !isInternalColumn(column.id))\n .filter(column =>\n query?.length ? column.columnDef.meta?.header.toLowerCase().includes(query.toLowerCase()) : true\n ),\n [allColumns, query]\n );\n\n const listClassName = 'flex max-h-64 flex-col gap-y-px overflow-auto';\n\n const handleReorder = (activeId, overId) => {\n if (columns.find(column => column.id === overId && column.columnDef.meta?.enableOrdering === false)) {\n return;\n }\n\n table.setColumnOrder(currentOrder =>\n ensureOrdering(\n allColumns,\n SortablePrimitive.arrayMove(\n currentOrder,\n currentOrder.findIndex(c => c === activeId),\n currentOrder.findIndex(c => c === overId)\n )\n )\n );\n };\n\n return (\n <Popover {...popoverProps} anchor={trigger}>\n <Popover.Content>\n <div className=\"flex w-60 flex-col gap-2\">\n {table.options.enableHiding ? (\n <Input\n onChange={event => setQuery(event.target.value)}\n placeholder={texts.table3.columnSettings.search}\n value={query}\n />\n ) : null}\n {tableMeta.columnOrdering.isEnabled && columns.length && !query?.length ? (\n <SortablePrimitive.Container reorder={handleReorder}>\n <SortablePrimitive.List id=\"columns\" className={listClassName}>\n {columns.map(column => (\n <SortablePrimitive.Item\n key={column.id}\n id={column.id}\n disabled={!column.columnDef.meta?.enableOrdering}\n asChild>\n <Column column={column as any} draggable={column.columnDef.meta?.enableOrdering} />\n </SortablePrimitive.Item>\n ))}\n </SortablePrimitive.List>\n </SortablePrimitive.Container>\n ) : (\n <div className={listClassName}>\n {columns.length\n ? columns.map(column => <Column column={column as any} key={column.id} />)\n : texts.table3.columnSettings.noResults}\n </div>\n )}\n </div>\n </Popover.Content>\n </Popover>\n );\n}\n"],"names":["Column","React","forwardRef","props","ref","column","draggable","dragAttributes","canHide","getCanHide","className","cn","attributes","undefined","isVisible","getIsVisible","key","id","onClick","toggleVisibility","Icon","name","columnDef","meta","_column$columnDef$met","header","Checkbox","checked","onChange","ColumnSettingsPopover","table","trigger","popoverProps","texts","useLocalization","query","setQuery","useState","allColumns","getAllLeafColumns","tableMeta","options","columns","useMemo","filter","isInternalColumn","_column$columnDef$met2","length","toLowerCase","includes","listClassName","handleReorder","activeId","overId","find","_column$columnDef$met3","enableOrdering","setColumnOrder","currentOrder","ensureOrdering","SortablePrimitive","findIndex","c","Popover","anchor","Content","enableHiding","Input","event","target","value","placeholder","table3","columnSettings","search","columnOrdering","isEnabled","reorder","map","_column$columnDef$met4","_column$columnDef$met5","disabled","asChild","noResults"],"mappings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E9BvD;IAAKS,SAAS,EAAEwC;KACXR,OAAO,CAACK,MAAM,GACTL,OAAO,CAACoC,GAAG,CAACzE,MAAM,iBAAIJ,6BAACD,MAAM;IAACK,MAAM,EAAEA,MAAa;IAAEW,GAAG,EAAEX,MAAM,CAACY;IAAM,CAAC,GACxEgB,KAAK,CAACuC,MAAM,CAACC,cAAc,CAACU,SAAS,CAElD,CACC,CACQ,CACZ;AAElB;;;;"}
1
+ {"version":3,"file":"ColumnSettings.js","sources":["../../../../../../../../../src/components/Table3/components/toolbar/ColumnSettings.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Table as RTable, Column as RTColumn, TableMeta } from '@tanstack/react-table';\nimport { isInternalColumn } from '../../util/columns';\nimport { useLocalization } from '../../../Provider/Localization';\nimport { Checkbox } from '../../../Checkbox/Checkbox';\nimport { Popover, PopoverProps } from '../../../Popover/Popover';\nimport { Input } from '../../../Input/Input';\nimport * as SortablePrimitive from '../../../../primitives/Sortable/Sortable';\nimport { Icon } from '../../../Icon/Icon';\nimport { ensureOrdering } from '../../hooks/features/useColumnOrdering';\n\ntype ColumnProps<TType = unknown> = React.HTMLAttributes<HTMLDivElement> & {\n column: RTColumn<TType, unknown>;\n draggable?: boolean;\n};\n\nconst Column = React.forwardRef(function Column<TType = unknown>(props: ColumnProps<TType>, ref: React.Ref<HTMLDivElement>) {\n const { column, draggable = false, ...dragAttributes } = props;\n const canHide = column.getCanHide();\n\n const className = cn('group/column flex items-center gap-x-2 rounded py-1 px-2', {\n 'hover:bg-grey-200': canHide || draggable,\n 'hover:cursor-pointer': canHide,\n 'active:cursor-move active:bg-grey-300': draggable,\n });\n\n const attributes = draggable ? dragAttributes : undefined;\n const isVisible = column.getIsVisible();\n\n const parentText = column.parent ? column.parent?.columnDef.meta?.header : null;\n\n return (\n <div {...attributes} key={column.id} className={className} onClick={() => column.toggleVisibility(!isVisible)} ref={ref}>\n {draggable ? <Icon name=\"drag\" className=\"text-grey-500 group-hover/column:text-grey-700 -mx-2 !h-5\" /> : null}\n <span className=\"flex-grow truncate\">\n {column.columnDef.meta?.header}\n {parentText ? <span className=\"italic\"> ({parentText})</span> : null}\n </span>\n {canHide ? <Checkbox checked={isVisible} onChange={() => column.toggleVisibility(!isVisible)} /> : null}\n </div>\n );\n});\n\nexport type ColumnSettingsProps<TType = unknown> = PopoverProps & {\n table: RTable<TType>;\n};\n\nexport function ColumnSettingsPopover<TType = unknown>(props: ColumnSettingsProps<TType>) {\n const { table, trigger, ...popoverProps } = props;\n const { texts } = useLocalization();\n const [query, setQuery] = React.useState('');\n const allColumns = table.getAllLeafColumns();\n const tableMeta = table.options.meta as TableMeta<TType>;\n const columns = React.useMemo(\n () =>\n allColumns\n .filter(column => !isInternalColumn(column.id))\n .filter(column =>\n query?.length\n ? column.columnDef.meta?.header.toLowerCase().includes(query.toLowerCase()) ||\n column.parent?.columnDef.meta?.header.toLowerCase().includes(query.toLowerCase())\n : true\n ),\n [allColumns, query]\n );\n\n const listClassName = 'flex max-h-64 flex-col gap-y-px overflow-auto';\n\n const handleReorder = (activeId, overId) => {\n if (columns.find(column => column.id === overId && column.columnDef.meta?.enableOrdering === false)) {\n return;\n }\n\n table.setColumnOrder(currentOrder =>\n ensureOrdering(\n allColumns,\n SortablePrimitive.arrayMove(\n currentOrder,\n currentOrder.findIndex(c => c === activeId),\n currentOrder.findIndex(c => c === overId)\n )\n )\n );\n };\n\n return (\n <Popover {...popoverProps} anchor={trigger}>\n <Popover.Content>\n <div className=\"flex max-w-sm flex-col gap-2\">\n {table.options.enableHiding ? (\n <Input\n onChange={event => setQuery(event.target.value)}\n placeholder={texts.table3.columnSettings.search}\n value={query}\n />\n ) : null}\n {tableMeta.columnOrdering.isEnabled && columns.length && !query?.length ? (\n <SortablePrimitive.Container reorder={handleReorder}>\n <SortablePrimitive.List id=\"columns\" className={listClassName}>\n {columns.map(column => (\n <SortablePrimitive.Item\n key={column.id}\n id={column.id}\n disabled={!column.columnDef.meta?.enableOrdering}\n asChild>\n <Column column={column as any} draggable={column.columnDef.meta?.enableOrdering} />\n </SortablePrimitive.Item>\n ))}\n </SortablePrimitive.List>\n </SortablePrimitive.Container>\n ) : (\n <div className={listClassName}>\n {columns.length\n ? columns.map(column => <Column column={column as any} key={column.id} />)\n : texts.table3.columnSettings.noResults}\n </div>\n )}\n </div>\n </Popover.Content>\n </Popover>\n );\n}\n"],"names":["Column","React","forwardRef","props","ref","column","draggable","dragAttributes","canHide","getCanHide","className","cn","attributes","undefined","isVisible","getIsVisible","parentText","parent","_column$parent","_column$parent$column","columnDef","meta","header","key","id","onClick","toggleVisibility","Icon","name","_column$columnDef$met","Checkbox","checked","onChange","ColumnSettingsPopover","table","trigger","popoverProps","texts","useLocalization","query","setQuery","useState","allColumns","getAllLeafColumns","tableMeta","options","columns","useMemo","filter","isInternalColumn","_column$columnDef$met2","_column$parent2","_column$parent2$colum","length","toLowerCase","includes","listClassName","handleReorder","activeId","overId","find","_column$columnDef$met3","enableOrdering","setColumnOrder","currentOrder","ensureOrdering","SortablePrimitive","findIndex","c","Popover","anchor","Content","enableHiding","Input","event","target","value","placeholder","table3","columnSettings","search","columnOrdering","isEnabled","reorder","map","_column$columnDef$met4","_column$columnDef$met5","disabled","asChild","noResults"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAMA,MAAM,gBAAGC,cAAK,CAACC,UAAU,CAAC,SAASF,MAAMA,CAAkBG,KAAyB,EAAEC,GAA8B;;EACtH,MAAM;IAAEC,MAAM;IAAEC,SAAS,GAAG,KAAK;IAAE,GAAGC;GAAgB,GAAGJ,KAAK;EAC9D,MAAMK,OAAO,GAAGH,MAAM,CAACI,UAAU,EAAE;EAEnC,MAAMC,SAAS,GAAGC,EAAE,CAAC,0DAA0D,EAAE;IAC7E,mBAAmB,EAAEH,OAAO,IAAIF,SAAS;IACzC,sBAAsB,EAAEE,OAAO;IAC/B,uCAAuC,EAAEF;GAC5C,CAAC;EAEF,MAAMM,UAAU,GAAGN,SAAS,GAAGC,cAA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,CAACC,IAAI,cAAAiE,sBAAA,uBAArBA,sBAAA,CAAuBxB;MAAkB,CAC9D;GAC5B,CAAC,CACmB,CACC,gBAE9B7D;IAAKS,SAAS,EAAE8C;KACXV,OAAO,CAACO,MAAM,GACTP,OAAO,CAACsC,GAAG,CAAC/E,MAAM,iBAAIJ,6BAACD,MAAM;IAACK,MAAM,EAAEA,MAAa;IAAEkB,GAAG,EAAElB,MAAM,CAACmB;IAAM,CAAC,GACxEa,KAAK,CAACyC,MAAM,CAACC,cAAc,CAACU,SAAS,CAElD,CACC,CACQ,CACZ;AAElB;;;;"}
@@ -77,14 +77,21 @@ function FiltersButton(props) {
77
77
  };
78
78
  //
79
79
  const handleApply = () => {
80
- table.setColumnFilters(filters.filter(f => {
81
- var _allColumns$find$colu;
82
- const controlRenderer = (_allColumns$find$colu = allColumns.find(c => c.id === f.id).columnDef.meta) === null || _allColumns$find$colu === void 0 ? void 0 : _allColumns$find$colu.control;
83
- if (f.value.comparator === Table3FilterComparator.IsEmpty || f.value.comparator === Table3FilterComparator.IsNotEmpty || controlRenderer === 'switch') {
84
- return true;
85
- }
86
- return !!f.value.value;
87
- }));
80
+ table.setColumnFilters(() => {
81
+ const newFilters = filters.filter(f => {
82
+ var _allColumns$find, _allColumns$find$colu;
83
+ if (f.id === null) {
84
+ return false;
85
+ }
86
+ const controlRenderer = (_allColumns$find = allColumns.find(c => c.id === f.id)) === null || _allColumns$find === void 0 ? void 0 : (_allColumns$find$colu = _allColumns$find.columnDef.meta) === null || _allColumns$find$colu === void 0 ? void 0 : _allColumns$find$colu.control;
87
+ if (f.value.comparator === Table3FilterComparator.IsEmpty || f.value.comparator === Table3FilterComparator.IsNotEmpty || controlRenderer === 'switch') {
88
+ return true;
89
+ }
90
+ return !!f.value.value;
91
+ });
92
+ // Compiler didn't get that we stripped out filters with null ids, so we still need to cast a ColumnFilter type here
93
+ return newFilters;
94
+ });
88
95
  };
89
96
  const handleClear = () => {
90
97
  table.resetColumnFilters();
@@ -1 +1 @@
1
- {"version":3,"file":"Filters.js","sources":["../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/Filters.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Table as RTable, Column as RTColumn } from '@tanstack/react-table';\nimport { Button } from '../../../../../Button/Button';\nimport { Icon } from '../../../../../Icon/Icon';\nimport { Popover } from '../../../../../Popover/Popover';\nimport { Table3FilterValue, Table3FilterComparator, Table3Filter } from '../../../../types';\nimport { Shortcut } from '../../../../../Shortcut/Shortcut';\nimport { useGlobalKeyDown } from '../../../../../../hooks/useGlobalKeyDown';\nimport { useLocalization } from '../../../../../Provider/Localization';\nimport { isInternalColumn } from '../../../../util/columns';\nimport { Placeholder } from './components/Placeholder';\nimport { Filter } from './components/Filter';\nimport { Group } from '../../../../../Group/Group';\nimport { useIsLargeScreen } from '../../../../../../hooks/useIsLargeScreen';\nimport { IconButton } from '../../../../../IconButton/IconButton';\n\nfunction sortByHeader<TType = unknown>(a: RTColumn<TType>, b: RTColumn<TType>) {\n return (a.columnDef.meta?.header as string)?.localeCompare?.(b.columnDef.meta?.header as string);\n}\n\nexport type FiltersProps<TType = unknown> = {\n total: number;\n table: RTable<TType>;\n};\n\nexport function FiltersButton<TType = unknown>(props: FiltersProps<TType>) {\n const { total, table } = props;\n const { locale, texts } = useLocalization();\n const ref = React.useRef<HTMLButtonElement>(null);\n const isLargeScreen = useIsLargeScreen();\n const allColumns = table\n .getAllLeafColumns()\n .filter(column => !isInternalColumn(column.id))\n .sort(sortByHeader);\n const appliedFilters = table.getState().columnFilters;\n\n useGlobalKeyDown({ key: 'f', meta: true, shift: true }, (event: KeyboardEvent) => {\n event.preventDefault();\n ref.current?.click();\n });\n\n // state, since we \"apply\" filters\n const [filters, setFilters] = React.useState<Table3Filter[]>(table.getState().columnFilters as Table3Filter[]);\n const [placeholderCount, setPlaceholderCount] = React.useState(1);\n\n // filters\n const handleChangeFilter = (currentId: string, filter: { id: string; value: Table3FilterValue }) => {\n setFilters(currentFilters => {\n const nextFilters = [...currentFilters];\n const index = nextFilters.findIndex(f => f.id === currentId);\n nextFilters[index] = filter;\n return nextFilters;\n });\n };\n\n const handleRemoveFilter = (columnId: string) => {\n if (filters.length === 1 && placeholderCount === 0) {\n setPlaceholderCount(count => count + 1);\n }\n\n setFilters(currentFilters => currentFilters.filter(f => f.id !== columnId));\n };\n\n // placeholders\n const handleCreateFilterFromPlaceholder = (columnId: string) => {\n setFilters(currentFilters => [\n ...currentFilters,\n {\n id: columnId,\n value: {\n comparator: Table3FilterComparator.Contains,\n value: undefined,\n },\n },\n ]);\n handleRemovePlaceholder();\n };\n\n const handleCreatePlaceholder = () => {\n setPlaceholderCount(count => count + 1);\n };\n\n const handleRemovePlaceholder = () => {\n setPlaceholderCount(count => count - 1);\n };\n\n //\n const handleApply = () => {\n table.setColumnFilters(\n filters.filter(f => {\n const controlRenderer = (allColumns.find(c => c.id === f.id) as RTColumn<TType, unknown>).columnDef.meta?.control;\n if (\n f.value.comparator === Table3FilterComparator.IsEmpty ||\n f.value.comparator === Table3FilterComparator.IsNotEmpty ||\n controlRenderer === 'switch'\n ) {\n return true;\n }\n return !!f.value.value;\n })\n );\n };\n\n const handleClear = () => {\n table.resetColumnFilters();\n setFilters([]);\n setPlaceholderCount(1);\n };\n\n const buttonProps = {\n 'aria-label': texts.table3.filters.tooltip,\n className: cn({ '!wcag-blue-100': appliedFilters.length }),\n popover: popoverProps => (\n <Popover {...popoverProps}>\n <Popover.Content>\n <div className=\"flex w-[40rem] flex-col gap-4\">\n <div className=\"flex h-8\">\n <div className=\"flex w-full items-center gap-2\">\n <h4 className=\"mb-0 inline-flex\">{texts.table3.filters.button}</h4>\n <p className=\"text-grey-700 mb-0 mr-auto mt-px inline-flex\">\n {texts.table3.filters.total\n .replace(\n '[CURRENT]',\n new Intl.NumberFormat(locale).format(table.getFilteredRowModel().rows.length)\n )\n .replace('[TOTAL]', new Intl.NumberFormat(locale).format(total))}\n </p>\n </div>\n </div>\n <div className=\"flex flex-col gap-2\">\n {filters.map((filter, index) => (\n <Filter\n key={`filter_${index}`}\n allColumns={allColumns as RTColumn<unknown, unknown>[]}\n filter={filter}\n filters={filters}\n position={index}\n onChange={handleChangeFilter}\n onRemove={handleRemoveFilter}\n />\n ))}\n {[...Array(placeholderCount)].map((_, index) => (\n <Placeholder\n key={`placeholder_${index}`}\n allColumns={allColumns as RTColumn<unknown, unknown>[]}\n filters={filters}\n position={filters.length + index}\n onCreate={handleCreateFilterFromPlaceholder as any}\n onRemove={placeholderCount > 1 || filters.length > 0 ? handleRemovePlaceholder : undefined}\n />\n ))}\n <div className=\"justify-start\">\n <Button appearance=\"discrete\" onClick={handleCreatePlaceholder}>\n + {texts.table3.filters.buttons.addFilter}\n </Button>\n </div>\n </div>\n <Group className=\"ml-auto\">\n <Popover.Close>\n <Button>Cancel</Button>\n </Popover.Close>\n <Button onClick={handleClear}>Clear</Button>\n <Button appearance=\"primary\" onClick={handleApply}>\n Apply\n </Button>\n </Group>\n </div>\n </Popover.Content>\n </Popover>\n ),\n ref,\n tooltip: (\n <>\n {texts.table3.filters.tooltip}\n <Shortcut className=\"ml-2\" keys={{ key: 'f', meta: true, shift: true }} />\n </>\n ),\n };\n\n if (!isLargeScreen && !appliedFilters.length) {\n return <IconButton {...buttonProps} icon=\"filter\" />;\n }\n return (\n <Button {...buttonProps}>\n <Icon className={cn({ '-mr-1.5': !isLargeScreen })} name={appliedFilters.length ? 'filter-solid' : 'filter'} />\n {isLargeScreen ? texts.table3.filters.button : ''}\n {appliedFilters.length ? `(${appliedFilters.length})` : ''}\n </Button>\n );\n}\n"],"names":["sortByHeader","a","b","_a$columnDef$meta","columnDef","meta","_a$columnDef$meta$hea","header","_a$columnDef$meta$hea2","localeCompare","call","_b$columnDef$meta","FiltersButton","props","total","table","locale","texts","useLocalization","ref","React","useRef","isLargeScreen","useIsLargeScreen","allColumns","getAllLeafColumns","filter","column","isInternalColumn","id","sort","appliedFilters","getState","columnFilters","useGlobalKeyDown","key","shift","event","preventDefault","_ref$current","current","click","filters","setFilters","useState","placeholderCount","setPlaceholderCount","handleChangeFilter","currentId","currentFilters","nextFilters","index","findIndex","f","handleRemoveFilter","columnId","length","count","handleCreateFilterFromPlaceholder","value","comparator","Table3FilterComparator","Contains","undefined","handleRemovePlaceholder","handleCreatePlaceholder","handleApply","setColumnFilters","controlRenderer","_allColumns$find$colu","find","c","control","IsEmpty","IsNotEmpty","handleClear","resetColumnFilters","buttonProps","table3","tooltip","className","cn","popover","popoverProps","Popover","Content","button","replace","Intl","NumberFormat","format","getFilteredRowModel","rows","map","Filter","position","onChange","onRemove","Array","_","Placeholder","onCreate","Button","appearance","onClick","buttons","addFilter","Group","Close","Shortcut","keys","IconButton","icon","Icon","name"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAASA,YAAYA,CAAkBC,CAAkB,EAAEC,CAAkB;;EACzE,QAAAC,iBAAA,GAAQF,CAAC,CAACG,SAAS,CAACC,IAAI,cAAAF,iBAAA,wBAAAG,qBAAA,GAAhBH,iBAAA,CAAkBI,MAAiB,cAAAD,qBAAA,wBAAAE,sBAAA,GAAnCF,qBAAA,CAAqCG,aAAa,cAAAD,sBAAA,uBAAlDA,sBAAA,CAAAE,IAAA,CAAAJ,qBAAA,GAAAK,iBAAA,GAAqDT,CAAC,CAACE,SAAS,CAACC,IAAI,cAAAM,iBAAA,uBAAhBA,iBAAA,CAAkBJ,MAAgB,CAAC;AACpG;SAOgBK,aAAaA,CAAkBC,KAA0B;EACrE,MAAM;IAAEC,KAAK;IAAEC;GAAO,GAAGF,KAAK;EAC9B,MAAM;IAAEG,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EAC3C,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMC,aAAa,GAAGC,gBAAgB,EAAE;EACxC,MAAMC,UAAU,GAAGT,KAAK,CACnBU,iBAAiB,EAAE,CACnBC,MAAM,CAACC,MAAM,IAAI,CAACC,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AAC3D;KAAe,CAAC;IAAE4F,IAAI,EAAEnF,cAAc,CAACyB,MAAM,GAAG,cAAc,GAAG;IAAY,EAC9GlC,aAAa,GAAGL,KAAK,CAAC6D,MAAM,CAACpC,OAAO,CAAC4C,MAAM,GAAG,EAAE,EAChDvD,cAAc,CAACyB,MAAM,OAAOzB,cAAc,CAACyB,SAAS,GAAG,EAAE,CACrD;AAEjB;;;;"}
1
+ {"version":3,"file":"Filters.js","sources":["../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/Filters.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Table as RTable, Column as RTColumn } from '@tanstack/react-table';\nimport { Button } from '../../../../../Button/Button';\nimport { Icon } from '../../../../../Icon/Icon';\nimport { Popover } from '../../../../../Popover/Popover';\nimport { Table3FilterValue, Table3FilterComparator, Table3Filter, ColumnFilter } from '../../../../types';\nimport { Shortcut } from '../../../../../Shortcut/Shortcut';\nimport { useGlobalKeyDown } from '../../../../../../hooks/useGlobalKeyDown';\nimport { useLocalization } from '../../../../../Provider/Localization';\nimport { isInternalColumn } from '../../../../util/columns';\nimport { Placeholder } from './components/Placeholder';\nimport { Filter } from './components/Filter';\nimport { Group } from '../../../../../Group/Group';\nimport { useIsLargeScreen } from '../../../../../../hooks/useIsLargeScreen';\nimport { IconButton } from '../../../../../IconButton/IconButton';\n\nfunction sortByHeader<TType = unknown>(a: RTColumn<TType>, b: RTColumn<TType>) {\n return (a.columnDef.meta?.header as string)?.localeCompare?.(b.columnDef.meta?.header as string);\n}\n\nexport type FiltersProps<TType = unknown> = {\n total: number;\n table: RTable<TType>;\n};\n\nexport function FiltersButton<TType = unknown>(props: FiltersProps<TType>) {\n const { total, table } = props;\n const { locale, texts } = useLocalization();\n const ref = React.useRef<HTMLButtonElement>(null);\n const isLargeScreen = useIsLargeScreen();\n const allColumns = table\n .getAllLeafColumns()\n .filter(column => !isInternalColumn(column.id))\n .sort(sortByHeader);\n const appliedFilters = table.getState().columnFilters;\n\n useGlobalKeyDown({ key: 'f', meta: true, shift: true }, (event: KeyboardEvent) => {\n event.preventDefault();\n ref.current?.click();\n });\n\n // state, since we \"apply\" filters\n const [filters, setFilters] = React.useState<Table3Filter[]>(table.getState().columnFilters as Table3Filter[]);\n const [placeholderCount, setPlaceholderCount] = React.useState(1);\n\n // filters\n const handleChangeFilter = (currentId: string | null, filter: { id: string | null; value: Table3FilterValue }) => {\n setFilters(currentFilters => {\n const nextFilters = [...currentFilters];\n const index = nextFilters.findIndex(f => f.id === currentId);\n nextFilters[index] = filter;\n return nextFilters;\n });\n };\n\n const handleRemoveFilter = (columnId: string | null) => {\n if (filters.length === 1 && placeholderCount === 0) {\n setPlaceholderCount(count => count + 1);\n }\n\n setFilters(currentFilters => currentFilters.filter(f => f.id !== columnId));\n };\n\n // placeholders\n const handleCreateFilterFromPlaceholder = (columnId: string) => {\n setFilters(currentFilters => [\n ...currentFilters,\n {\n id: columnId,\n value: {\n comparator: Table3FilterComparator.Contains,\n value: undefined,\n },\n },\n ]);\n handleRemovePlaceholder();\n };\n\n const handleCreatePlaceholder = () => {\n setPlaceholderCount(count => count + 1);\n };\n\n const handleRemovePlaceholder = () => {\n setPlaceholderCount(count => count - 1);\n };\n\n //\n const handleApply = () => {\n table.setColumnFilters(() => {\n const newFilters = filters.filter(f => {\n if (f.id === null) {\n return false;\n }\n\n const controlRenderer = (allColumns.find(c => c.id === f.id) as RTColumn<TType, unknown>)?.columnDef.meta\n ?.control;\n if (\n f.value.comparator === Table3FilterComparator.IsEmpty ||\n f.value.comparator === Table3FilterComparator.IsNotEmpty ||\n controlRenderer === 'switch'\n ) {\n return true;\n }\n return !!f.value.value;\n });\n // Compiler didn't get that we stripped out filters with null ids, so we still need to cast a ColumnFilter type here\n return newFilters as ColumnFilter[];\n });\n };\n\n const handleClear = () => {\n table.resetColumnFilters();\n setFilters([]);\n setPlaceholderCount(1);\n };\n\n const buttonProps = {\n 'aria-label': texts.table3.filters.tooltip,\n className: cn({ '!wcag-blue-100': appliedFilters.length }),\n popover: popoverProps => (\n <Popover {...popoverProps}>\n <Popover.Content>\n <div className=\"flex w-[40rem] flex-col gap-4\">\n <div className=\"flex h-8\">\n <div className=\"flex w-full items-center gap-2\">\n <h4 className=\"mb-0 inline-flex\">{texts.table3.filters.button}</h4>\n <p className=\"text-grey-700 mb-0 mr-auto mt-px inline-flex\">\n {texts.table3.filters.total\n .replace(\n '[CURRENT]',\n new Intl.NumberFormat(locale).format(table.getFilteredRowModel().rows.length)\n )\n .replace('[TOTAL]', new Intl.NumberFormat(locale).format(total))}\n </p>\n </div>\n </div>\n <div className=\"flex flex-col gap-2\">\n {filters.map((filter, index) => (\n <Filter\n key={`filter_${index}`}\n allColumns={allColumns as RTColumn<unknown, unknown>[]}\n filter={filter}\n filters={filters}\n position={index}\n onChange={handleChangeFilter}\n onRemove={handleRemoveFilter}\n />\n ))}\n {[...Array(placeholderCount)].map((_, index) => (\n <Placeholder\n key={`placeholder_${index}`}\n allColumns={allColumns as RTColumn<unknown, unknown>[]}\n filters={filters}\n position={filters.length + index}\n onCreate={handleCreateFilterFromPlaceholder as any}\n onRemove={placeholderCount > 1 || filters.length > 0 ? handleRemovePlaceholder : undefined}\n />\n ))}\n <div className=\"justify-start\">\n <Button appearance=\"discrete\" onClick={handleCreatePlaceholder}>\n + {texts.table3.filters.buttons.addFilter}\n </Button>\n </div>\n </div>\n <Group className=\"ml-auto\">\n <Popover.Close>\n <Button>Cancel</Button>\n </Popover.Close>\n <Button onClick={handleClear}>Clear</Button>\n <Button appearance=\"primary\" onClick={handleApply}>\n Apply\n </Button>\n </Group>\n </div>\n </Popover.Content>\n </Popover>\n ),\n ref,\n tooltip: (\n <>\n {texts.table3.filters.tooltip}\n <Shortcut className=\"ml-2\" keys={{ key: 'f', meta: true, shift: true }} />\n </>\n ),\n };\n\n if (!isLargeScreen && !appliedFilters.length) {\n return <IconButton {...buttonProps} icon=\"filter\" />;\n }\n return (\n <Button {...buttonProps}>\n <Icon className={cn({ '-mr-1.5': !isLargeScreen })} name={appliedFilters.length ? 'filter-solid' : 'filter'} />\n {isLargeScreen ? texts.table3.filters.button : ''}\n {appliedFilters.length ? `(${appliedFilters.length})` : ''}\n </Button>\n );\n}\n"],"names":["sortByHeader","a","b","_a$columnDef$meta","columnDef","meta","_a$columnDef$meta$hea","header","_a$columnDef$meta$hea2","localeCompare","call","_b$columnDef$meta","FiltersButton","props","total","table","locale","texts","useLocalization","ref","React","useRef","isLargeScreen","useIsLargeScreen","allColumns","getAllLeafColumns","filter","column","isInternalColumn","id","sort","appliedFilters","getState","columnFilters","useGlobalKeyDown","key","shift","event","preventDefault","_ref$current","current","click","filters","setFilters","useState","placeholderCount","setPlaceholderCount","handleChangeFilter","currentId","currentFilters","nextFilters","index","findIndex","f","handleRemoveFilter","columnId","length","count","handleCreateFilterFromPlaceholder","value","comparator","Table3FilterComparator","Contains","undefined","handleRemovePlaceholder","handleCreatePlaceholder","handleApply","setColumnFilters","newFilters","controlRenderer","_allColumns$find","find","c","_allColumns$find$colu","control","IsEmpty","IsNotEmpty","handleClear","resetColumnFilters","buttonProps","table3","tooltip","className","cn","popover","popoverProps","Popover","Content","button","replace","Intl","NumberFormat","format","getFilteredRowModel","rows","map","Filter","position","onChange","onRemove","Array","_","Placeholder","onCreate","Button","appearance","onClick","buttons","addFilter","Group","Close","Shortcut","keys","IconButton","icon","Icon","name"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAASA,YAAYA,CAAkBC,CAAkB,EAAEC,CAAkB;;EACzE,QAAAC,iBAAA,GAAQF,CAAC,CAACG,SAAS,CAACC,IAAI,cAAAF,iBAAA,wBAAAG,qBAAA,GAAhBH,iBAAA,CAAkBI,MAAiB,cAAAD,qBAAA,wBAAAE,sBAAA,GAAnCF,qBAAA,CAAqCG,aAAa,cAAAD,sBAAA,uBAAlDA,sBAAA,CAAAE,IAAA,CAAAJ,qBAAA,GAAAK,iBAAA,GAAqDT,CAAC,CAACE,SAAS,CAACC,IAAI,cAAA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AU,EAAC,SAAS;MAACC,OAAO,EAAExC;eAE7B,CACL,CACN,CACQ,CAEzB;IACD/C,GAAG;IACH8D,OAAO,eACH7D,4DACKH,KAAK,CAAC+D,MAAM,CAACtC,OAAO,CAACuC,OAAO,eAC7B7D,6BAAC2F,QAAQ;MAAC7B,SAAS,EAAC,MAAM;MAAC8B,IAAI,EAAE;QAAE7E,GAAG,EAAE,GAAG;QAAE9B,IAAI,EAAE,IAAI;QAAE+B,KAAK,EAAE;;MAAU;GAGrF;EAED,IAAI,CAACd,aAAa,IAAI,CAACS,cAAc,CAACyB,MAAM,EAAE;IAC1C,oBAAOpC,6BAAC6F,UAAU,oBAAKlC,WAAW;MAAEmC,IAAI,EAAC;OAAW;;EAExD,oBACI9F,6BAACoF,MAAM,oBAAKzB,WAAW,gBACnB3D,6BAAC+F,IAAI;IAACjC,SAAS,EAAEC,EAAE,CAAC;MAAE,SAAS,EAAE,CAAC7D;KAAe,CAAC;IAAE8F,IAAI,EAAErF,cAAc,CAACyB,MAAM,GAAG,cAAc,GAAG;IAAY,EAC9GlC,aAAa,GAAGL,KAAK,CAAC+D,MAAM,CAACtC,OAAO,CAAC8C,MAAM,GAAG,EAAE,EAChDzD,cAAc,CAACyB,MAAM,OAAOzB,cAAc,CAACyB,SAAS,GAAG,EAAE,CACrD;AAEjB;;;;"}
@@ -56,9 +56,9 @@ function Filter(props) {
56
56
  };
57
57
  const handleRemove = () => onRemove(id);
58
58
  return /*#__PURE__*/React__default.createElement("div", {
59
- className: "flex gap-2"
59
+ className: "flex items-start gap-2"
60
60
  }, /*#__PURE__*/React__default.createElement("div", {
61
- className: "flex w-14 flex-shrink-0 items-center justify-end pr-2 text-right"
61
+ className: "flex min-h-[theme(spacing.8)] w-14 flex-shrink-0 items-center justify-end pr-2 text-right"
62
62
  }, position > 0 ? texts.table3.filters.conditions.and : texts.table3.filters.conditions.where), /*#__PURE__*/React__default.createElement(FilterColumn, {
63
63
  allColumns: allColumns,
64
64
  filters: filters,
@@ -1 +1 @@
1
- {"version":3,"file":"Filter.js","sources":["../../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/components/Filter.tsx"],"sourcesContent":["import React from 'react';\nimport { Column as RTColumn, ColumnFiltersState } from '@tanstack/react-table';\nimport { IconButton } from '../../../../../../IconButton/IconButton';\nimport { Table3Filter, Table3FilterComparator } from '../../../../../types';\nimport { useLocalization } from '../../../../../../Provider/Localization';\nimport { FilterColumn } from './FilterColumn';\nimport { FilterComparator } from './FilterComparator';\nimport { FilterValue } from './FilterValue';\n\nexport type FilterProps<TType = unknown> = {\n allColumns: RTColumn<TType, unknown>[];\n filter: Table3Filter;\n filters: ColumnFiltersState;\n position: number;\n onChange: (id: string, value: Table3Filter) => void;\n onRemove: (columnId: string) => void;\n};\n\nexport function Filter<TType = unknown>(props: FilterProps<TType>) {\n const { allColumns, filter, filters, onChange: handleChange, onRemove, position } = props;\n const { texts } = useLocalization();\n const column = allColumns.find(c => c.id === filter.id) as RTColumn<TType, unknown>;\n\n const {\n id,\n value: { comparator, value },\n } = filter;\n\n const handleChangeColumn = (columnId: string) => {\n handleChange(id, { id: columnId, value: filter.value });\n };\n\n const handleChangeComparator = (comparator: Table3FilterComparator) => {\n let nextValue = filter.value.value;\n\n if (comparator === Table3FilterComparator.IsEmpty || comparator === Table3FilterComparator.IsNotEmpty) {\n nextValue = undefined;\n }\n handleChange(id, { id, value: { comparator, value: nextValue } });\n };\n\n const handleChangeValue = (value: any) => {\n handleChange(id, { id, value: { ...filter.value, value } });\n };\n\n const handleRemove = () => onRemove(id);\n\n return (\n <div className=\"flex gap-2\">\n <div className=\"flex w-14 flex-shrink-0 items-center justify-end pr-2 text-right\">\n {position > 0 ? texts.table3.filters.conditions.and : texts.table3.filters.conditions.where}\n </div>\n <FilterColumn allColumns={allColumns} filters={filters} onChange={handleChangeColumn as any} value={id} />\n <FilterComparator column={column} onChange={handleChangeComparator as any} value={comparator} />\n <FilterValue column={column} comparator={comparator} onChange={handleChangeValue} value={value} />\n <IconButton appearance=\"discrete\" className=\"ml-auto\" icon=\"close\" onClick={handleRemove} />\n </div>\n );\n}\n"],"names":["Filter","props","allColumns","filter","filters","onChange","handleChange","onRemove","position","texts","useLocalization","column","find","c","id","value","comparator","handleChangeColumn","columnId","handleChangeComparator","nextValue","Table3FilterComparator","IsEmpty","IsNotEmpty","undefined","handleChangeValue","handleRemove","React","className","table3","conditions","and","where","FilterColumn","FilterComparator","FilterValue","IconButton","appearance","icon","onClick"],"mappings":";;;;;;;;SAkBgBA,MAAMA,CAAkBC,KAAyB;EAC7D,MAAM;IAAEC,UAAU;IAAEC,MAAM;IAAEC,OAAO;IAAEC,QAAQ,EAAEC,YAAY;IAAEC,QAAQ;IAAEC;GAAU,GAAGP,KAAK;EACzF,MAAM;IAAEQ;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,MAAM,GAAGT,UAAU,CAACU,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,EAAE,KAAKX,MAAM,CAACW,EAAE,CAA6B;EAEnF,MAAM;IACFA,EAAE;IACFC,KAAK,EAAE;MAAEC,UAAU;MAAED;;GACxB,GAAGZ,MAAM;EAEV,MAAMc,kBAAkB,GAAIC,QAAgB;IACxCZ,YAAY,CAACQ,EAAE,EAAE;MAAEA,EAAE,EAAEI,QAAQ;MAAEH,KAAK,EAAEZ,MAAM,CAACY;KAAO,CAAC;GAC1D;EAED,MAAMI,sBAAsB,GAAIH,UAAkC;IAC9D,IAAII,SAAS,GAAGjB,MAAM,CAACY,KAAK,CAACA,KAAK;IAElC,IAAIC,UAAU,KAAKK,sBAAsB,CAACC,OAAO,IAAIN,UAAU,KAAKK,sBAAsB,CAACE,UAAU,EAAE;MACnGH,SAAS,GAAGI,SAAS;;IAEzBlB,YAAY,CAACQ,EAAE,EAAE;MAAEA,EAAE;MAAEC,KAAK,EAAE;QAAEC,UAAU;QAAED,KAAK,EAAEK;;KAAa,CAAC;GACpE;EAED,MAAMK,iBAAiB,GAAIV,KAAU;IACjCT,YAAY,CAACQ,EAAE,EAAE;MAAEA,EAAE;MAAEC,KAAK,EAAE;QAAE,GAAGZ,MAAM,CAACY,KAAK;QAAEA;;KAAS,CAAC;GAC9D;EAED,MAAMW,YAAY,GAAGA,MAAMnB,QAAQ,CAACO,EAAE,CAAC;EAEvC,oBACIa;IAAKC,SAAS,EAAC;kBACXD;IAAKC,SAAS,EAAC;KACVpB,QAAQ,GAAG,CAAC,GAAGC,KAAK,CAACoB,MAAM,CAACzB,OAAO,CAAC0B,UAAU,CAACC,GAAG,GAAGtB,KAAK,CAACoB,MAAM,CAACzB,OAAO,CAAC0B,UAAU,CAACE,KAAK,CACzF,eACNL,6BAACM,YAAY;IAAC/B,UAAU,EAAEA,UAAU;IAAEE,OAAO,EAAEA,OAAO;IAAEC,QAAQ,EAAEY,kBAAyB;IAAEF,KAAK,EAAED;IAAM,eAC1Ga,6BAACO,gBAAgB;IAACvB,MAAM,EAAEA,MAAM;IAAEN,QAAQ,EAAEc,sBAA6B;IAAEJ,KAAK,EAAEC;IAAc,eAChGW,6BAACQ,WAAW;IAACxB,MAAM,EAAEA,MAAM;IAAEK,UAAU,EAAEA,UAAU;IAAEX,QAAQ,EAAEoB,iBAAiB;IAAEV,KAAK,EAAEA;IAAS,eAClGY,6BAACS,UAAU;IAACC,UAAU,EAAC,UAAU;IAACT,SAAS,EAAC,SAAS;IAACU,IAAI,EAAC,OAAO;IAACC,OAAO,EAAEb;IAAgB,CAC1F;AAEd;;;;"}
1
+ {"version":3,"file":"Filter.js","sources":["../../../../../../../../../../../../src/components/Table3/components/toolbar/Filter/filters/components/Filter.tsx"],"sourcesContent":["import React from 'react';\nimport { Column as RTColumn } from '@tanstack/react-table';\nimport { IconButton } from '../../../../../../IconButton/IconButton';\nimport { Table3Filter, Table3FilterComparator } from '../../../../../types';\nimport { useLocalization } from '../../../../../../Provider/Localization';\nimport { FilterColumn } from './FilterColumn';\nimport { FilterComparator } from './FilterComparator';\nimport { FilterValue } from './FilterValue';\n\nexport type FilterProps<TType = unknown> = {\n allColumns: RTColumn<TType, unknown>[];\n filter: Table3Filter;\n filters: Table3Filter[];\n position: number;\n onChange: (id: string | null, value: Table3Filter) => void;\n onRemove: (columnId: string | null) => void;\n};\n\nexport function Filter<TType = unknown>(props: FilterProps<TType>) {\n const { allColumns, filter, filters, onChange: handleChange, onRemove, position } = props;\n const { texts } = useLocalization();\n const column = allColumns.find(c => c.id === filter.id) as RTColumn<TType, unknown>;\n\n const {\n id,\n value: { comparator, value },\n } = filter;\n\n const handleChangeColumn = (columnId: string | null) => {\n handleChange(id, { id: columnId, value: filter.value });\n };\n\n const handleChangeComparator = (comparator: Table3FilterComparator) => {\n let nextValue = filter.value.value;\n\n if (comparator === Table3FilterComparator.IsEmpty || comparator === Table3FilterComparator.IsNotEmpty) {\n nextValue = undefined;\n }\n handleChange(id, { id, value: { comparator, value: nextValue } });\n };\n\n const handleChangeValue = (value: any) => {\n handleChange(id, { id, value: { ...filter.value, value } });\n };\n\n const handleRemove = () => onRemove(id);\n\n return (\n <div className=\"flex items-start gap-2\">\n <div className=\"flex min-h-[theme(spacing.8)] w-14 flex-shrink-0 items-center justify-end pr-2 text-right\">\n {position > 0 ? texts.table3.filters.conditions.and : texts.table3.filters.conditions.where}\n </div>\n <FilterColumn allColumns={allColumns} filters={filters} onChange={handleChangeColumn as any} value={id} />\n <FilterComparator column={column} onChange={handleChangeComparator as any} value={comparator} />\n <FilterValue column={column} comparator={comparator} onChange={handleChangeValue} value={value} />\n <IconButton appearance=\"discrete\" className=\"ml-auto\" icon=\"close\" onClick={handleRemove} />\n </div>\n );\n}\n"],"names":["Filter","props","allColumns","filter","filters","onChange","handleChange","onRemove","position","texts","useLocalization","column","find","c","id","value","comparator","handleChangeColumn","columnId","handleChangeComparator","nextValue","Table3FilterComparator","IsEmpty","IsNotEmpty","undefined","handleChangeValue","handleRemove","React","className","table3","conditions","and","where","FilterColumn","FilterComparator","FilterValue","IconButton","appearance","icon","onClick"],"mappings":";;;;;;;;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0B,UAAU,CAACC,GAAG,GAAGtB,KAAK,CAACoB,MAAM,CAACzB,OAAO,CAAC0B,UAAU,CAACE,KAAK,CACzF,eACNL,6BAACM,YAAY;IAAC/B,UAAU,EAAEA,UAAU;IAAEE,OAAO,EAAEA,OAAO;IAAEC,QAAQ,EAAEY,kBAAyB;IAAEF,KAAK,EAAED;IAAM,eAC1Ga,6BAACO,gBAAgB;IAACvB,MAAM,EAAEA,MAAM;IAAEN,QAAQ,EAAEc,sBAA6B;IAAEJ,KAAK,EAAEC;IAAc,eAChGW,6BAACQ,WAAW;IAACxB,MAAM,EAAEA,MAAM;IAAEK,UAAU,EAAEA,UAAU;IAAEX,QAAQ,EAAEoB,iBAAiB;IAAEV,KAAK,EAAEA;IAAS,eAClGY,6BAACS,UAAU;IAACC,UAAU,EAAC,UAAU;IAACT,SAAS,EAAC,SAAS;IAACU,IAAI,EAAC,OAAO;IAACC,OAAO,EAAEb;IAAgB,CAC1F;AAEd;;;;"}
@@ -1,4 +1,8 @@
1
1
  import React__default from 'react';
2
+ import { Icon } from '../../../../../../Icon/Icon.js';
3
+ import { Tooltip } from '../../../../../../Tooltip/Tooltip.js';
4
+ import { useLocalization } from '../../../../../../Provider/Localization.js';
5
+ import { Field } from '../../../../../../Field/Field.js';
2
6
  import { Select2 } from '../../../../../../Select2/Select2.js';
3
7
 
4
8
  function FilterColumn(props) {
@@ -9,19 +13,36 @@ function FilterColumn(props) {
9
13
  value = null,
10
14
  ...attributes
11
15
  } = props;
12
- return /*#__PURE__*/React__default.createElement(Select2, Object.assign({}, attributes, {
16
+ const {
17
+ texts
18
+ } = useLocalization();
19
+ const selectedColumn = allColumns.find(column => column.id === value);
20
+ const warning = selectedColumn && !selectedColumn.getIsVisible();
21
+ return /*#__PURE__*/React__default.createElement("div", {
22
+ className: "flex flex-col"
23
+ }, /*#__PURE__*/React__default.createElement(Field, {
24
+ message: warning ? texts.table3.filters.hiddenColumn : undefined,
25
+ warning: warning,
26
+ className: "min-h-[theme(spacing.8)]"
27
+ }, /*#__PURE__*/React__default.createElement(Select2, Object.assign({}, attributes, {
13
28
  className: "!w-32 flex-shrink-0",
14
29
  emptyValue: null,
15
30
  onChange: handleChange,
16
31
  value: value
17
32
  }), allColumns.map(column => {
18
- var _column$columnDef$met;
33
+ var _column$columnDef$met, _column$parent, _column$parent$column;
19
34
  return /*#__PURE__*/React__default.createElement(Select2.Option, {
20
35
  key: column.id,
21
36
  value: column.id,
37
+ postfix: !column.getIsVisible() ? /*#__PURE__*/React__default.createElement(Tooltip, {
38
+ title: texts.table3.filters.hiddenColumn
39
+ }, /*#__PURE__*/React__default.createElement(Icon, {
40
+ name: "eye-off",
41
+ className: "text-grey-500 !h-5 !w-5"
42
+ })) : undefined,
22
43
  disabled: column.id !== value && (!column.getCanFilter() || !!filters.find(f => f.id === column.id))
23
- }, (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.header);
24
- }));
44
+ }, ((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.header) + (column.parent ? ` (${(_column$parent = column.parent) === null || _column$parent === void 0 ? void 0 : (_column$parent$column = _column$parent.columnDef.meta) === null || _column$parent$column === void 0 ? void 0 : _column$parent$column.header})` : ''));
45
+ }))));
25
46
  }
26
47
 
27
48
  export { FilterColumn };