@theseam/ui-common 0.2.9 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/assets/vendor/intl-tel-input/js/utils.js +255 -254
  2. package/bundles/theseam-ui-common-asset-reader.umd.js +7 -9
  3. package/bundles/theseam-ui-common-asset-reader.umd.js.map +1 -1
  4. package/bundles/theseam-ui-common-breadcrumbs.umd.js +6 -8
  5. package/bundles/theseam-ui-common-breadcrumbs.umd.js.map +1 -1
  6. package/bundles/theseam-ui-common-buttons.umd.js +5 -5
  7. package/bundles/theseam-ui-common-buttons.umd.js.map +1 -1
  8. package/bundles/theseam-ui-common-card.umd.js +6 -6
  9. package/bundles/theseam-ui-common-card.umd.js.map +1 -1
  10. package/bundles/theseam-ui-common-checkbox.umd.js +4 -4
  11. package/bundles/theseam-ui-common-checkbox.umd.js.map +1 -1
  12. package/bundles/theseam-ui-common-confirm-dialog.umd.js +4 -4
  13. package/bundles/theseam-ui-common-confirm-dialog.umd.js.map +1 -1
  14. package/bundles/theseam-ui-common-core.umd.js +4 -4
  15. package/bundles/theseam-ui-common-core.umd.js.map +1 -1
  16. package/bundles/theseam-ui-common-data-exporter.umd.js +5 -5
  17. package/bundles/theseam-ui-common-data-filters.umd.js +9 -6
  18. package/bundles/theseam-ui-common-data-filters.umd.js.map +1 -1
  19. package/bundles/theseam-ui-common-datatable-dynamic.umd.js +7 -7
  20. package/bundles/theseam-ui-common-datatable-dynamic.umd.js.map +1 -1
  21. package/bundles/theseam-ui-common-datatable.umd.js +1353 -375
  22. package/bundles/theseam-ui-common-datatable.umd.js.map +1 -1
  23. package/bundles/theseam-ui-common-dynamic-component-loader.umd.js +5 -7
  24. package/bundles/theseam-ui-common-dynamic-component-loader.umd.js.map +1 -1
  25. package/bundles/theseam-ui-common-dynamic.umd.js +7 -9
  26. package/bundles/theseam-ui-common-dynamic.umd.js.map +1 -1
  27. package/bundles/theseam-ui-common-footer-bar.umd.js +3 -3
  28. package/bundles/theseam-ui-common-form-field-error.umd.js +5 -5
  29. package/bundles/theseam-ui-common-form-field-error.umd.js.map +1 -1
  30. package/bundles/theseam-ui-common-form-field.umd.js +5 -5
  31. package/bundles/theseam-ui-common-form-field.umd.js.map +1 -1
  32. package/bundles/theseam-ui-common-framework.umd.js +28 -30
  33. package/bundles/theseam-ui-common-framework.umd.js.map +1 -1
  34. package/bundles/theseam-ui-common-graphql.umd.js +958 -8
  35. package/bundles/theseam-ui-common-graphql.umd.js.map +1 -1
  36. package/bundles/theseam-ui-common-icon.umd.js +5 -5
  37. package/bundles/theseam-ui-common-icon.umd.js.map +1 -1
  38. package/bundles/theseam-ui-common-layout.umd.js +5 -7
  39. package/bundles/theseam-ui-common-layout.umd.js.map +1 -1
  40. package/bundles/theseam-ui-common-loading.umd.js +4 -4
  41. package/bundles/theseam-ui-common-menu.umd.js +5 -5
  42. package/bundles/theseam-ui-common-menu.umd.js.map +1 -1
  43. package/bundles/theseam-ui-common-modal.umd.js +6 -6
  44. package/bundles/theseam-ui-common-modal.umd.js.map +1 -1
  45. package/bundles/theseam-ui-common-models.umd.js +3 -3
  46. package/bundles/theseam-ui-common-popover.umd.js +4 -4
  47. package/bundles/theseam-ui-common-progress.umd.js +5 -5
  48. package/bundles/theseam-ui-common-progress.umd.js.map +1 -1
  49. package/bundles/theseam-ui-common-scrollbar.umd.js +7 -9
  50. package/bundles/theseam-ui-common-scrollbar.umd.js.map +1 -1
  51. package/bundles/theseam-ui-common-services.umd.js +6 -8
  52. package/bundles/theseam-ui-common-services.umd.js.map +1 -1
  53. package/bundles/theseam-ui-common-shared.umd.js +4 -4
  54. package/bundles/theseam-ui-common-shared.umd.js.map +1 -1
  55. package/bundles/theseam-ui-common-storage.umd.js +5 -7
  56. package/bundles/theseam-ui-common-storage.umd.js.map +1 -1
  57. package/bundles/theseam-ui-common-story-helpers.umd.js +4 -4
  58. package/bundles/theseam-ui-common-story-helpers.umd.js.map +1 -1
  59. package/bundles/theseam-ui-common-tabbed.umd.js +5 -5
  60. package/bundles/theseam-ui-common-tabbed.umd.js.map +1 -1
  61. package/bundles/theseam-ui-common-table-cell-type.umd.js +5 -7
  62. package/bundles/theseam-ui-common-table-cell-type.umd.js.map +1 -1
  63. package/bundles/theseam-ui-common-table-cell-types.umd.js +258 -32
  64. package/bundles/theseam-ui-common-table-cell-types.umd.js.map +1 -1
  65. package/bundles/theseam-ui-common-table.umd.js +5 -5
  66. package/bundles/theseam-ui-common-table.umd.js.map +1 -1
  67. package/bundles/theseam-ui-common-tel-input.umd.js +6 -6
  68. package/bundles/theseam-ui-common-tel-input.umd.js.map +1 -1
  69. package/bundles/theseam-ui-common-testing.umd.js +568 -0
  70. package/bundles/theseam-ui-common-testing.umd.js.map +1 -0
  71. package/bundles/theseam-ui-common-tiled-select.umd.js +56 -39
  72. package/bundles/theseam-ui-common-tiled-select.umd.js.map +1 -1
  73. package/bundles/theseam-ui-common-toggle-edit.umd.js +8 -10
  74. package/bundles/theseam-ui-common-toggle-edit.umd.js.map +1 -1
  75. package/bundles/theseam-ui-common-toggle-group.umd.js +4 -4
  76. package/bundles/theseam-ui-common-toggle-group.umd.js.map +1 -1
  77. package/bundles/theseam-ui-common-unsaved-changes-dialog.umd.js +5 -7
  78. package/bundles/theseam-ui-common-unsaved-changes-dialog.umd.js.map +1 -1
  79. package/bundles/theseam-ui-common-utils.umd.js +174 -81
  80. package/bundles/theseam-ui-common-utils.umd.js.map +1 -1
  81. package/bundles/theseam-ui-common-validators.umd.js +3 -3
  82. package/bundles/theseam-ui-common-viewers.umd.js +6 -8
  83. package/bundles/theseam-ui-common-viewers.umd.js.map +1 -1
  84. package/bundles/theseam-ui-common-widget.umd.js +18 -20
  85. package/bundles/theseam-ui-common-widget.umd.js.map +1 -1
  86. package/bundles/theseam-ui-common.umd.js +2 -2
  87. package/buttons/theseam-ui-common-buttons.metadata.json +1 -1
  88. package/card/theseam-ui-common-card.metadata.json +1 -1
  89. package/data-filters/data-filter.d.ts +10 -6
  90. package/data-filters/theseam-ui-common-data-filters.metadata.json +1 -1
  91. package/datatable/datatable/datatable.component.d.ts +48 -32
  92. package/datatable/datatable-column/datatable-column.component.d.ts +26 -25
  93. package/datatable/datatable-column-preferences/datatable-column-preferences.component.d.ts +7 -5
  94. package/datatable/datatable-column-preferences-button/datatable-column-preferences-button.component.d.ts +7 -1
  95. package/datatable/datatable-footer/datatable-footer-tpl.directive.d.ts +5 -0
  96. package/datatable/datatable-footer/datatable-footer.directive.d.ts +6 -0
  97. package/datatable/datatable-menu-bar/datatable-menu-bar.component.d.ts +1 -1
  98. package/datatable/directives/datatable-filter.directive.d.ts +1 -1
  99. package/datatable/models/columns-alteration.d.ts +61 -0
  100. package/datatable/models/columns-alterations/hide-column.columns-alteration.d.ts +15 -0
  101. package/datatable/models/columns-alterations/order.columns-alteration.d.ts +20 -0
  102. package/datatable/models/columns-alterations/sort.columns-alteration.d.ts +14 -0
  103. package/datatable/models/columns-alterations/width.columns-alteration.d.ts +16 -0
  104. package/datatable/models/datatable-accessor.d.ts +5 -3
  105. package/datatable/models/internal-column-props.d.ts +7 -0
  106. package/datatable/models/page-info.d.ts +12 -0
  107. package/datatable/models/preferences-accessor.d.ts +1 -1
  108. package/datatable/models/preferences.d.ts +11 -3
  109. package/datatable/models/sort-item.d.ts +2 -1
  110. package/datatable/public-api.d.ts +2 -0
  111. package/datatable/services/columns-alterations-manager.service.d.ts +39 -0
  112. package/datatable/services/columns-manager.service.d.ts +55 -0
  113. package/datatable/services/datatable-preferences.service.d.ts +10 -7
  114. package/datatable/theseam-ui-common-datatable.d.ts +2 -0
  115. package/datatable/theseam-ui-common-datatable.metadata.json +1 -1
  116. package/datatable/tokens/datatable-preferences-accessor.d.ts +2 -2
  117. package/datatable/utils/create-action-menu-column.d.ts +3 -0
  118. package/datatable/utils/create-checkbox-column.d.ts +3 -0
  119. package/datatable/utils/get-column-prop.d.ts +5 -0
  120. package/datatable/utils/map-columns-alterations-states.d.ts +2 -0
  121. package/datatable/utils/remove-unused-diffs.d.ts +7 -0
  122. package/datatable/utils/set-column-defaults.d.ts +2 -0
  123. package/datatable/utils/translate-templates.d.ts +2 -0
  124. package/datatable/utils/with-stored-column-info.d.ts +2 -2
  125. package/datatable-dynamic/theseam-ui-common-datatable-dynamic.metadata.json +1 -1
  126. package/esm2015/buttons/progress-circle-button/progress-circle-button.component.js +1 -1
  127. package/esm2015/card/card-action/card-action.component.js +1 -1
  128. package/esm2015/card/card-body/card-body.component.js +1 -1
  129. package/esm2015/data-filters/data-filter.js +5 -2
  130. package/esm2015/data-filters/filters/data-filter-search/data-filter-search.component.js +1 -1
  131. package/esm2015/data-filters/filters/data-filter-text/data-filter-text.component.js +1 -1
  132. package/esm2015/datatable/datatable/datatable.component.js +197 -211
  133. package/esm2015/datatable/datatable-action-menu/datatable-action-menu.component.js +1 -1
  134. package/esm2015/datatable/datatable-column/datatable-column.component.js +1 -1
  135. package/esm2015/datatable/datatable-column-preferences/datatable-column-preferences.component.js +42 -19
  136. package/esm2015/datatable/datatable-column-preferences-button/datatable-column-preferences-button.component.js +38 -4
  137. package/esm2015/datatable/datatable-export-button/datatable-export-button.component.js +1 -1
  138. package/esm2015/datatable/datatable-footer/datatable-footer-tpl.directive.js +15 -0
  139. package/esm2015/datatable/datatable-footer/datatable-footer.directive.js +18 -0
  140. package/esm2015/datatable/datatable-menu-bar/datatable-menu-bar.component.js +1 -1
  141. package/esm2015/datatable/datatable-menu-bar-column-center/datatable-menu-bar-column-center.component.js +1 -1
  142. package/esm2015/datatable/datatable-menu-bar-column-left/datatable-menu-bar-column-left.component.js +1 -1
  143. package/esm2015/datatable/datatable-menu-bar-column-right/datatable-menu-bar-column-right.component.js +1 -1
  144. package/esm2015/datatable/datatable-menu-bar-row/datatable-menu-bar-row.component.js +1 -1
  145. package/esm2015/datatable/datatable.module.js +7 -1
  146. package/esm2015/datatable/models/columns-alteration.js +38 -0
  147. package/esm2015/datatable/models/columns-alterations/hide-column.columns-alteration.js +38 -0
  148. package/esm2015/datatable/models/columns-alterations/order.columns-alteration.js +81 -0
  149. package/esm2015/datatable/models/columns-alterations/sort.columns-alteration.js +33 -0
  150. package/esm2015/datatable/models/columns-alterations/width.columns-alteration.js +41 -0
  151. package/esm2015/datatable/models/datatable-accessor.js +1 -1
  152. package/esm2015/datatable/models/internal-column-props.js +15 -0
  153. package/esm2015/datatable/models/page-info.js +1 -1
  154. package/esm2015/datatable/models/preferences-accessor.js +1 -1
  155. package/esm2015/datatable/models/preferences.js +6 -2
  156. package/esm2015/datatable/models/sort-item.js +1 -1
  157. package/esm2015/datatable/public-api.js +3 -1
  158. package/esm2015/datatable/services/columns-alterations-manager.service.js +134 -0
  159. package/esm2015/datatable/services/columns-manager.service.js +257 -0
  160. package/esm2015/datatable/services/datatable-preferences.service.js +78 -32
  161. package/esm2015/datatable/theseam-ui-common-datatable.js +3 -1
  162. package/esm2015/datatable/tokens/datatable-preferences-accessor.js +2 -2
  163. package/esm2015/datatable/utils/create-action-menu-column.js +18 -0
  164. package/esm2015/datatable/utils/create-checkbox-column.js +15 -0
  165. package/esm2015/datatable/utils/get-column-prop.js +9 -0
  166. package/esm2015/datatable/utils/map-columns-alterations-states.js +39 -0
  167. package/esm2015/datatable/utils/remove-unused-diffs.js +9 -0
  168. package/esm2015/datatable/utils/set-column-defaults.js +10 -0
  169. package/esm2015/datatable/utils/translate-templates.js +12 -0
  170. package/esm2015/datatable/utils/with-stored-column-info.js +1 -1
  171. package/esm2015/datatable-dynamic/datatable-dynamic-action-menu/datatable-dynamic-action-menu.component.js +1 -1
  172. package/esm2015/datatable-dynamic/datatable-dynamic-filter-container/datatable-dynamic-filter-container.component.js +1 -1
  173. package/esm2015/datatable-dynamic/datatable-dynamic.component.js +1 -1
  174. package/esm2015/form-field/form-field.component.js +1 -1
  175. package/esm2015/form-field-error/form-field-error/form-field-error.component.js +1 -1
  176. package/esm2015/framework/base-layout/base-layout.component.js +1 -1
  177. package/esm2015/framework/dashboard/dashboard-widgets/dashboard-widgets.component.js +1 -1
  178. package/esm2015/framework/dynamic-router/hierarchy-router-outlet/hierarchy-router-outlet.component.js +1 -1
  179. package/esm2015/framework/schema-form-controls/schema-form-input/schema-form-input.component.js +1 -1
  180. package/esm2015/framework/schema-form-controls/schema-form-number/schema-form-number.component.js +1 -1
  181. package/esm2015/framework/schema-form-controls/schema-form-select/schema-form-select.component.js +1 -1
  182. package/esm2015/framework/schema-form-controls/schema-form-submit-split/schema-form-submit-split.component.js +1 -1
  183. package/esm2015/framework/side-nav/side-nav-item/side-nav-item.component.js +3 -3
  184. package/esm2015/framework/side-nav/side-nav-toggle/side-nav-toggle.component.js +1 -1
  185. package/esm2015/framework/side-nav/side-nav.component.js +1 -1
  186. package/esm2015/framework/top-bar/top-bar-menu-button/top-bar-menu-button.component.js +1 -1
  187. package/esm2015/framework/top-bar/top-bar-title/top-bar-title.component.js +1 -1
  188. package/esm2015/framework/top-bar/top-bar.component.js +1 -1
  189. package/esm2015/graphql/datatable/create-page-info-observable.js +38 -0
  190. package/esm2015/graphql/datatable/datatable-graphql-query-ref.js +236 -0
  191. package/esm2015/graphql/datatable/datatable-graphql.service.js +35 -0
  192. package/esm2015/graphql/datatable/datatable-helpers.js +170 -0
  193. package/esm2015/graphql/datatable/get-page-info.js +11 -0
  194. package/esm2015/graphql/datatable/index.js +7 -0
  195. package/esm2015/graphql/datatable/map-filter-states.js +64 -0
  196. package/esm2015/graphql/datatable/map-page-info.js +14 -0
  197. package/esm2015/graphql/datatable/mapper-context.js +2 -0
  198. package/esm2015/graphql/models/gql-datatable-accessor.js +2 -0
  199. package/esm2015/graphql/models/index.js +2 -1
  200. package/esm2015/graphql/models/query-processing-config.js +1 -1
  201. package/esm2015/graphql/public-api.js +2 -1
  202. package/esm2015/graphql/utils/parse-hints.js +3 -3
  203. package/esm2015/icon/icon/icon.component.js +1 -1
  204. package/esm2015/loading/loading/loading.component.js +1 -1
  205. package/esm2015/menu/menu.component.js +1 -1
  206. package/esm2015/modal/modal-body/modal-body.component.js +1 -1
  207. package/esm2015/modal/modal-container/modal-container.component.js +1 -1
  208. package/esm2015/popover/popover/popover.component.js +1 -1
  209. package/esm2015/progress/progress-circle/progress-circle.component.js +1 -1
  210. package/esm2015/tabbed/tabbed.component.js +1 -1
  211. package/esm2015/table/table/table.component.js +1 -1
  212. package/esm2015/table-cell-types/public-api.js +8 -1
  213. package/esm2015/table-cell-types/table-cell-type-currency/table-cell-type-currency-config.js +2 -0
  214. package/esm2015/table-cell-types/table-cell-type-currency/table-cell-type-currency.component.js +74 -0
  215. package/esm2015/table-cell-types/table-cell-type-currency/table-cell-type-currency.js +2 -0
  216. package/esm2015/table-cell-types/table-cell-type-decimal/table-cell-type-decimal-config.js +1 -1
  217. package/esm2015/table-cell-types/table-cell-type-decimal/table-cell-type-decimal.component.js +73 -0
  218. package/esm2015/table-cell-types/table-cell-type-decimal/table-cell-type-decimal.js +2 -0
  219. package/esm2015/table-cell-types/table-cell-type-icon/table-cell-type-icon.component.js +1 -1
  220. package/esm2015/table-cell-types/table-cell-type-integer/table-cell-type-integer-config.js +1 -1
  221. package/esm2015/table-cell-types/table-cell-type-integer/table-cell-type-integer.component.js +71 -0
  222. package/esm2015/table-cell-types/table-cell-type-integer/table-cell-type-integer.js +2 -0
  223. package/esm2015/table-cell-types/table-cell-type-manifests.js +29 -17
  224. package/esm2015/table-cell-types/table-cell-type-progress-circle/table-cell-type-progress-circle.component.js +1 -1
  225. package/esm2015/table-cell-types/table-cell-types.module.js +9 -2
  226. package/esm2015/tel-input/tel-input/tel-input.component.js +1 -1
  227. package/esm2015/testing/current-tick-time.js +16 -0
  228. package/esm2015/testing/fake-toastr.js +29 -0
  229. package/esm2015/testing/get-harness.js +16 -0
  230. package/esm2015/testing/public-api.js +7 -0
  231. package/esm2015/testing/render-story.js +12 -0
  232. package/esm2015/testing/story-expect.js +39 -0
  233. package/esm2015/testing/theseam-ui-common-testing.js +5 -0
  234. package/esm2015/testing/tick-helper.js +74 -0
  235. package/esm2015/tiled-select/components/tiled-select/tiled-select.component.js +25 -17
  236. package/esm2015/tiled-select/components/tiled-select-tile/tiled-select-tile.component.js +5 -2
  237. package/esm2015/tiled-select/components/tiled-select-tile-icon/tiled-select-tile-icon.component.js +1 -1
  238. package/esm2015/tiled-select/public-api.js +2 -1
  239. package/esm2015/tiled-select/tiled-select.models.js +1 -1
  240. package/esm2015/tiled-select/tiled-select.module.js +4 -4
  241. package/esm2015/toggle-edit/toggle-edit-actions-container/toggle-edit-actions-container.component.js +1 -1
  242. package/esm2015/toggle-edit/toggle-edit.component.js +1 -1
  243. package/esm2015/utils/array-move.js +62 -0
  244. package/esm2015/utils/public-api.js +2 -1
  245. package/esm2015/utils/subscriber-count.js +31 -4
  246. package/esm2015/widget/widget/widget.component.js +1 -1
  247. package/esm2015/widget/widget-content-components/widget-button-group/widget-button-group.component.js +1 -1
  248. package/esm2015/widget/widget-content-components/widget-content-header/widget-content-header.component.js +1 -1
  249. package/esm2015/widget/widget-content-components/widget-empty-label/widget-empty-label.component.js +1 -1
  250. package/esm2015/widget/widget-content-components/widget-footer-link/widget-footer-link.component.js +1 -1
  251. package/esm2015/widget/widget-content-components/widget-footer-text/widget-footer-text.component.js +1 -1
  252. package/esm2015/widget/widget-content-components/widget-header-badge/widget-header-badge.component.js +1 -1
  253. package/esm2015/widget/widget-content-components/widget-tile/widget-tile-footer-item/widget-tile-footer-item.component.js +1 -1
  254. package/esm2015/widget/widget-content-components/widget-tile/widget-tile-group/widget-tile-group.component.js +1 -1
  255. package/esm2015/widget/widget-content-components/widget-tile/widget-tile.component.js +1 -1
  256. package/esm2015/widget/widget-content-components/widget-tile-list/widget-tile-list.component.js +1 -1
  257. package/esm2015/widget/widget-footer/widget-footer.component.js +1 -1
  258. package/fesm2015/theseam-ui-common-buttons.js +1 -1
  259. package/fesm2015/theseam-ui-common-card.js +2 -2
  260. package/fesm2015/theseam-ui-common-data-filters.js +6 -3
  261. package/fesm2015/theseam-ui-common-data-filters.js.map +1 -1
  262. package/fesm2015/theseam-ui-common-datatable-dynamic.js +3 -3
  263. package/fesm2015/theseam-ui-common-datatable.js +1136 -316
  264. package/fesm2015/theseam-ui-common-datatable.js.map +1 -1
  265. package/fesm2015/theseam-ui-common-form-field-error.js +1 -1
  266. package/fesm2015/theseam-ui-common-form-field.js +1 -1
  267. package/fesm2015/theseam-ui-common-framework.js +14 -14
  268. package/fesm2015/theseam-ui-common-framework.js.map +1 -1
  269. package/fesm2015/theseam-ui-common-graphql.js +555 -5
  270. package/fesm2015/theseam-ui-common-graphql.js.map +1 -1
  271. package/fesm2015/theseam-ui-common-icon.js +1 -1
  272. package/fesm2015/theseam-ui-common-loading.js +1 -1
  273. package/fesm2015/theseam-ui-common-menu.js +1 -1
  274. package/fesm2015/theseam-ui-common-modal.js +2 -2
  275. package/fesm2015/theseam-ui-common-popover.js +1 -1
  276. package/fesm2015/theseam-ui-common-progress.js +1 -1
  277. package/fesm2015/theseam-ui-common-tabbed.js +1 -1
  278. package/fesm2015/theseam-ui-common-table-cell-types.js +234 -22
  279. package/fesm2015/theseam-ui-common-table-cell-types.js.map +1 -1
  280. package/fesm2015/theseam-ui-common-table.js +1 -1
  281. package/fesm2015/theseam-ui-common-tel-input.js +1 -1
  282. package/fesm2015/theseam-ui-common-testing.js +191 -0
  283. package/fesm2015/theseam-ui-common-testing.js.map +1 -0
  284. package/fesm2015/theseam-ui-common-tiled-select.js +34 -21
  285. package/fesm2015/theseam-ui-common-tiled-select.js.map +1 -1
  286. package/fesm2015/theseam-ui-common-toggle-edit.js +2 -2
  287. package/fesm2015/theseam-ui-common-utils.js +92 -4
  288. package/fesm2015/theseam-ui-common-utils.js.map +1 -1
  289. package/fesm2015/theseam-ui-common-widget.js +12 -12
  290. package/form-field/theseam-ui-common-form-field.metadata.json +1 -1
  291. package/form-field-error/theseam-ui-common-form-field-error.metadata.json +1 -1
  292. package/framework/side-nav/side-nav-item/side-nav-item.component.scss +36 -9
  293. package/framework/theseam-ui-common-framework.metadata.json +1 -1
  294. package/graphql/datatable/create-page-info-observable.d.ts +4 -0
  295. package/graphql/datatable/datatable-graphql-query-ref.d.ts +65 -0
  296. package/graphql/datatable/datatable-graphql.service.d.ts +26 -0
  297. package/graphql/datatable/datatable-helpers.d.ts +12 -0
  298. package/graphql/datatable/get-page-info.d.ts +4 -0
  299. package/graphql/datatable/index.d.ts +6 -0
  300. package/graphql/datatable/map-filter-states.d.ts +18 -0
  301. package/graphql/datatable/map-page-info.d.ts +11 -0
  302. package/graphql/datatable/mapper-context.d.ts +6 -0
  303. package/graphql/models/gql-datatable-accessor.d.ts +9 -0
  304. package/graphql/models/index.d.ts +1 -0
  305. package/graphql/models/query-processing-config.d.ts +4 -0
  306. package/graphql/public-api.d.ts +1 -0
  307. package/graphql/theseam-ui-common-graphql.metadata.json +1 -1
  308. package/icon/theseam-ui-common-icon.metadata.json +1 -1
  309. package/loading/theseam-ui-common-loading.metadata.json +1 -1
  310. package/menu/theseam-ui-common-menu.metadata.json +1 -1
  311. package/modal/theseam-ui-common-modal.metadata.json +1 -1
  312. package/package.json +1 -1
  313. package/popover/theseam-ui-common-popover.metadata.json +1 -1
  314. package/progress/theseam-ui-common-progress.metadata.json +1 -1
  315. package/styles/common/_table.scss +0 -5
  316. package/styles/vendor/ngx-datatable/_ngx-datatable.scss +478 -87
  317. package/styles/vendor/ngx-datatable/_themes/bootstrap/_variables.scss +174 -0
  318. package/styles/vendor/ngx-datatable/_themes/dark/_variables.scss +166 -0
  319. package/styles/vendor/ngx-datatable/_themes/material/_variables.scss +165 -0
  320. package/styles/vendor/ngx-datatable/_variables.scss +3 -0
  321. package/tabbed/theseam-ui-common-tabbed.metadata.json +1 -1
  322. package/table/theseam-ui-common-table.metadata.json +1 -1
  323. package/table-cell-types/public-api.d.ts +7 -0
  324. package/table-cell-types/table-cell-type-currency/table-cell-type-currency-config.d.ts +39 -0
  325. package/table-cell-types/table-cell-type-currency/table-cell-type-currency.component.d.ts +19 -0
  326. package/table-cell-types/table-cell-type-currency/table-cell-type-currency.d.ts +3 -0
  327. package/table-cell-types/table-cell-type-decimal/table-cell-type-decimal-config.d.ts +31 -1
  328. package/table-cell-types/table-cell-type-decimal/table-cell-type-decimal.component.d.ts +19 -0
  329. package/table-cell-types/table-cell-type-decimal/table-cell-type-decimal.d.ts +3 -0
  330. package/table-cell-types/table-cell-type-integer/table-cell-type-integer-config.d.ts +23 -1
  331. package/table-cell-types/table-cell-type-integer/table-cell-type-integer.component.d.ts +19 -0
  332. package/table-cell-types/table-cell-type-integer/table-cell-type-integer.d.ts +3 -0
  333. package/table-cell-types/table-cell-type-manifests.d.ts +2 -1
  334. package/table-cell-types/theseam-ui-common-table-cell-types.metadata.json +1 -1
  335. package/tel-input/theseam-ui-common-tel-input.metadata.json +1 -1
  336. package/testing/current-tick-time.d.ts +13 -0
  337. package/testing/fake-toastr.d.ts +30 -0
  338. package/testing/get-harness.d.ts +7 -0
  339. package/testing/package.json +11 -0
  340. package/testing/public-api.d.ts +6 -0
  341. package/testing/render-story.d.ts +2 -0
  342. package/testing/story-expect.d.ts +5 -0
  343. package/{test-helpers/theseam-ui-common-test-helpers.d.ts → testing/theseam-ui-common-testing.d.ts} +0 -0
  344. package/testing/theseam-ui-common-testing.metadata.json +1 -0
  345. package/{test-helpers → testing}/tick-helper.d.ts +0 -0
  346. package/tiled-select/components/tiled-select/tiled-select.component.d.ts +7 -3
  347. package/tiled-select/components/tiled-select-tile/tiled-select-tile.component.d.ts +1 -0
  348. package/tiled-select/theseam-ui-common-tiled-select.metadata.json +1 -1
  349. package/tiled-select/tiled-select.models.d.ts +3 -1
  350. package/toggle-edit/theseam-ui-common-toggle-edit.metadata.json +1 -1
  351. package/utils/array-move.d.ts +49 -0
  352. package/utils/public-api.d.ts +1 -0
  353. package/utils/subscriber-count.d.ts +13 -1
  354. package/utils/theseam-ui-common-utils.metadata.json +1 -1
  355. package/widget/theseam-ui-common-widget.metadata.json +1 -1
  356. package/bundles/theseam-ui-common-test-helpers.umd.js +0 -94
  357. package/bundles/theseam-ui-common-test-helpers.umd.js.map +0 -1
  358. package/esm2015/test-helpers/public-api.js +0 -2
  359. package/esm2015/test-helpers/theseam-ui-common-test-helpers.js +0 -5
  360. package/esm2015/test-helpers/tick-helper.js +0 -74
  361. package/fesm2015/theseam-ui-common-test-helpers.js +0 -81
  362. package/fesm2015/theseam-ui-common-test-helpers.js.map +0 -1
  363. package/test-helpers/package.json +0 -11
  364. package/test-helpers/public-api.d.ts +0 -1
  365. package/test-helpers/theseam-ui-common-test-helpers.metadata.json +0 -1
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/animations'), require('@angular/cdk/coercion'), require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/cdk/collections'), require('@fortawesome/free-solid-svg-icons'), require('@marklb/ngx-datatable'), require('@theseam/ui-common/core'), require('@theseam/ui-common/data-filters'), require('@theseam/ui-common/utils'), require('@angular/router'), require('@theseam/ui-common/confirm-dialog'), require('@angular/forms'), require('ngx-toastr'), require('@theseam/ui-common/dynamic'), require('@theseam/ui-common/loading'), require('@angular/common/http'), require('@theseam/ui-common/dynamic-component-loader'), require('@theseam/ui-common/modal'), require('@angular/cdk/keycodes'), require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@theseam/ui-common/scrollbar'), require('@angular/cdk/a11y'), require('@angular/common'), require('@fortawesome/angular-fontawesome'), require('@theseam/ui-common/buttons'), require('@theseam/ui-common/checkbox'), require('@theseam/ui-common/form-field'), require('@theseam/ui-common/icon'), require('@theseam/ui-common/menu'), require('@theseam/ui-common/popover'), require('@theseam/ui-common/shared'), require('@theseam/ui-common/table-cell-type')) :
3
- typeof define === 'function' && define.amd ? define('@theseam/ui-common/datatable', ['exports', '@angular/animations', '@angular/cdk/coercion', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/cdk/collections', '@fortawesome/free-solid-svg-icons', '@marklb/ngx-datatable', '@theseam/ui-common/core', '@theseam/ui-common/data-filters', '@theseam/ui-common/utils', '@angular/router', '@theseam/ui-common/confirm-dialog', '@angular/forms', 'ngx-toastr', '@theseam/ui-common/dynamic', '@theseam/ui-common/loading', '@angular/common/http', '@theseam/ui-common/dynamic-component-loader', '@theseam/ui-common/modal', '@angular/cdk/keycodes', '@angular/cdk/overlay', '@angular/cdk/portal', '@theseam/ui-common/scrollbar', '@angular/cdk/a11y', '@angular/common', '@fortawesome/angular-fontawesome', '@theseam/ui-common/buttons', '@theseam/ui-common/checkbox', '@theseam/ui-common/form-field', '@theseam/ui-common/icon', '@theseam/ui-common/menu', '@theseam/ui-common/popover', '@theseam/ui-common/shared', '@theseam/ui-common/table-cell-type'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.theseam = global.theseam || {}, global.theseam['ui-common'] = global.theseam['ui-common'] || {}, global.theseam['ui-common'].datatable = {}), global.ng.animations, global.ng.cdk.coercion, global.ng.core, global.rxjs, global.rxjs.operators, global.ng.cdk.collections, global.freeSolidSvgIcons, global.ngxDatatable, global.theseam['ui-common'].core, global.theseam['ui-common']['data-filters'], global.theseam['ui-common'].utils, global.ng.router, global.theseam['ui-common']['confirm-dialog'], global.ng.forms, global.ngxToastr, global.theseam['ui-common'].dynamic, global.theseam['ui-common'].loading, global.ng.common.http, global.theseam['ui-common']['dynamic-component-loader'], global.theseam['ui-common'].modal, global.ng.cdk.keycodes, global.ng.cdk.overlay, global.ng.cdk.portal, global.theseam['ui-common'].scrollbar, global.ng.cdk.a11y, global.ng.common, global.angularFontawesome, global.theseam['ui-common'].buttons, global.theseam['ui-common'].checkbox, global.theseam['ui-common']['form-field'], global.theseam['ui-common'].icon, global.theseam['ui-common'].menu, global.theseam['ui-common'].popover, global.theseam['ui-common'].shared, global.theseam['ui-common']['table-cell-type']));
5
- }(this, (function (exports, animations, coercion, i0, rxjs, operators, collections, freeSolidSvgIcons, ngxDatatable, core, dataFilters, utils, router, confirmDialog, forms, ngxToastr, dynamic, loading, http, dynamicComponentLoader, modal, keycodes, overlay, portal, scrollbar, a11y, common, angularFontawesome, buttons, checkbox, formField, icon, menu, popover, shared, tableCellType) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/animations'), require('@angular/cdk/coercion'), require('@angular/cdk/collections'), require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@fortawesome/free-solid-svg-icons'), require('@marklb/ngx-datatable'), require('@theseam/ui-common/core'), require('@theseam/ui-common/data-filters'), require('@theseam/ui-common/utils'), require('@angular/router'), require('@theseam/ui-common/confirm-dialog'), require('@angular/forms'), require('ngx-toastr'), require('@theseam/ui-common/dynamic'), require('@theseam/ui-common/loading'), require('@angular/common/http'), require('@theseam/ui-common/dynamic-component-loader'), require('@theseam/ui-common/modal'), require('@angular/cdk/keycodes'), require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@theseam/ui-common/scrollbar'), require('@angular/cdk/a11y'), require('@angular/common'), require('@fortawesome/angular-fontawesome'), require('@theseam/ui-common/buttons'), require('@theseam/ui-common/checkbox'), require('@theseam/ui-common/form-field'), require('@theseam/ui-common/icon'), require('@theseam/ui-common/menu'), require('@theseam/ui-common/popover'), require('@theseam/ui-common/shared'), require('@theseam/ui-common/table-cell-type')) :
3
+ typeof define === 'function' && define.amd ? define('@theseam/ui-common/datatable', ['exports', '@angular/animations', '@angular/cdk/coercion', '@angular/cdk/collections', '@angular/core', 'rxjs', 'rxjs/operators', '@fortawesome/free-solid-svg-icons', '@marklb/ngx-datatable', '@theseam/ui-common/core', '@theseam/ui-common/data-filters', '@theseam/ui-common/utils', '@angular/router', '@theseam/ui-common/confirm-dialog', '@angular/forms', 'ngx-toastr', '@theseam/ui-common/dynamic', '@theseam/ui-common/loading', '@angular/common/http', '@theseam/ui-common/dynamic-component-loader', '@theseam/ui-common/modal', '@angular/cdk/keycodes', '@angular/cdk/overlay', '@angular/cdk/portal', '@theseam/ui-common/scrollbar', '@angular/cdk/a11y', '@angular/common', '@fortawesome/angular-fontawesome', '@theseam/ui-common/buttons', '@theseam/ui-common/checkbox', '@theseam/ui-common/form-field', '@theseam/ui-common/icon', '@theseam/ui-common/menu', '@theseam/ui-common/popover', '@theseam/ui-common/shared', '@theseam/ui-common/table-cell-type'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.theseam = global.theseam || {}, global.theseam["ui-common"] = global.theseam["ui-common"] || {}, global.theseam["ui-common"].datatable = {}), global.ng.animations, global.ng.cdk.coercion, global.ng.cdk.collections, global.ng.core, global.rxjs, global.rxjs.operators, global.freeSolidSvgIcons, global.ngxDatatable, global.theseam["ui-common"].core, global.theseam["ui-common"]["data-filters"], global.theseam["ui-common"].utils, global.ng.router, global.theseam["ui-common"]["confirm-dialog"], global.ng.forms, global.ngxToastr, global.theseam["ui-common"].dynamic, global.theseam["ui-common"].loading, global.ng.common.http, global.theseam["ui-common"]["dynamic-component-loader"], global.theseam["ui-common"].modal, global.ng.cdk.keycodes, global.ng.cdk.overlay, global.ng.cdk.portal, global.theseam["ui-common"].scrollbar, global.ng.cdk.a11y, global.ng.common, global.angularFontawesome, global.theseam["ui-common"].buttons, global.theseam["ui-common"].checkbox, global.theseam["ui-common"]["form-field"], global.theseam["ui-common"].icon, global.theseam["ui-common"].menu, global.theseam["ui-common"].popover, global.theseam["ui-common"].shared, global.theseam["ui-common"]["table-cell-type"]));
5
+ })(this, (function (exports, animations, coercion, collections, i0, rxjs, operators, freeSolidSvgIcons, ngxDatatable, core, dataFilters, utils, router, confirmDialog, forms, ngxToastr, dynamic, loading, http, dynamicComponentLoader, modal, keycodes, overlay, portal, scrollbar, a11y, common, angularFontawesome, buttons, checkbox, formField, icon, menu, popover, shared, tableCellType) { 'use strict';
6
6
 
7
7
  function _interopNamespace(e) {
8
8
  if (e && e.__esModule) return e;
@@ -13,14 +13,12 @@
13
13
  var d = Object.getOwnPropertyDescriptor(e, k);
14
14
  Object.defineProperty(n, k, d.get ? d : {
15
15
  enumerable: true,
16
- get: function () {
17
- return e[k];
18
- }
16
+ get: function () { return e[k]; }
19
17
  });
20
18
  }
21
19
  });
22
20
  }
23
- n['default'] = e;
21
+ n["default"] = e;
24
22
  return Object.freeze(n);
25
23
  }
26
24
 
@@ -261,7 +259,7 @@
261
259
  ar[i] = from[i];
262
260
  }
263
261
  }
264
- return to.concat(ar || from);
262
+ return to.concat(ar || Array.prototype.slice.call(from));
265
263
  }
266
264
  function __await(v) {
267
265
  return this instanceof __await ? (this.v = v, this) : new __await(v);
@@ -344,48 +342,6 @@
344
342
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
345
343
  }
346
344
 
347
- var DatatableDataSource = /** @class */ (function (_super) {
348
- __extends(DatatableDataSource, _super);
349
- function DatatableDataSource() {
350
- var _this = _super.call(this) || this;
351
- _this._datatableSubject = new rxjs.BehaviorSubject(undefined);
352
- _this.sorts$ = _this._datatableSubject.pipe(operators.switchMap(function (_datatable) {
353
- if (!_datatable) {
354
- return rxjs.of([]);
355
- }
356
- return _datatable.sort.pipe(operators.map(function (v) { return v.sorts; }), operators.startWith(_datatable.sorts));
357
- }));
358
- _this.filterStates$ = _this._datatableSubject.pipe(operators.switchMap(function (_datatable) {
359
- if (!_datatable) {
360
- return rxjs.of([]);
361
- }
362
- return _datatable.filterStates;
363
- }));
364
- _this.page$ = _this._datatableSubject.pipe(operators.switchMap(function (_datatable) {
365
- if (!_datatable) {
366
- return rxjs.of({
367
- offset: 0,
368
- pageSize: 0,
369
- limit: undefined,
370
- count: 0
371
- });
372
- }
373
- return _datatable.page.pipe(operators.startWith(_datatable.pageInfo));
374
- }));
375
- return _this;
376
- }
377
- // connect(): Observable<readonly TRow[]> {
378
- // return this.
379
- // }
380
- // disconnect(): void {
381
- // throw new Error('Method not implemented.')
382
- // }
383
- DatatableDataSource.prototype.setDatatableAccessor = function (accessor) {
384
- this._datatableSubject.next(accessor);
385
- };
386
- return DatatableDataSource;
387
- }(collections.DataSource));
388
-
389
345
  var DatatableActionMenuItemComponent = /** @class */ (function () {
390
346
  function DatatableActionMenuItemComponent() {
391
347
  this.click = new i0.EventEmitter();
@@ -503,7 +459,7 @@
503
459
  { type: i0.Component, args: [{
504
460
  selector: 'seam-datatable-action-menu',
505
461
  template: "<seam-menu #menu\n menuClass=\"list-group py-0 border-0 seam-datatable-action-menu\"\n animationType=\"fade\">\n\n <ng-container *ngFor=\"let item of items\">\n <ng-container *ngIf=\"(item.routerLink || item.href) && !item.confirmDialog; else noRouterLink\">\n <a *ngIf=\"item.href; else noHref\"\n seamMenuItem\n class=\"list-group-item list-group-item-action py-1\"\n [disabled]=\"item.disabled\"\n [attr.href]=\"item.href\"\n [target]=\"item.target\"\n (click)=\"activateItem($event, item)\">\n {{ item.label }}\n </a>\n <ng-template #noHref>\n <a seamMenuItem\n class=\"list-group-item list-group-item-action py-1\"\n [disabled]=\"item.disabled\"\n [queryParams]=\"item.queryParams\"\n [fragment]=\"$any(item.fragment)\"\n [queryParamsHandling]=\"item.queryParamsHandling\"\n [preserveFragment]=\"$any(item.preserveFragment)\"\n [skipLocationChange]=\"$any(item.skipLocationChange)\"\n [replaceUrl]=\"$any(item.replaceUrl)\"\n [state]=\"$any(item.state)\"\n [routerLink]=\"item.routerLink\"\n [target]=\"$any(item.target)\"\n (click)=\"activateItem($event, item)\">\n {{ item.label }}\n </a>\n </ng-template>\n </ng-container>\n <ng-template #noRouterLink>\n <button seamMenuItem\n type=\"button\"\n class=\"list-group-item list-group-item-action py-1\"\n [disabled]=\"item.disabled\"\n (click)=\"activateItem($event, item)\">\n {{ item.label }}\n </button>\n </ng-template>\n </ng-container>\n</seam-menu>\n\n<button type=\"button\" class=\"datatable-action-button btn\"\n [seamMenuToggle]=\"menu\"\n [positions]=\"_actionMenuPositions || []\"\n title=\"Row Actions\">\n <seam-icon [icon]=\"faEllipsisH\"></seam-icon>\n</button>\n",
506
- styles: [":host{display:block;position:relative}.datatable-action-button{font-size:20px;line-height:20px;width:30px;height:30px;padding:0;border-radius:15px;text-align:center}.datatable-action-button::ng-deep .svg-inline--fa{vertical-align:middle}"]
462
+ styles: [":host{display:block;position:relative}.datatable-action-button{font-size:20px;line-height:20px;width:30px;height:30px;padding:0;border-radius:15px;text-align:center}.datatable-action-button::ng-deep .svg-inline--fa{vertical-align:middle}\n"]
507
463
  },] }
508
464
  ];
509
465
  DatatableActionMenuComponent.ctorParameters = function () { return [
@@ -634,6 +590,44 @@
634
590
  _cellTemplateQuery: [{ type: i0.ContentChild, args: [DatatableCellTplDirective, { read: i0.TemplateRef, static: true },] }]
635
591
  };
636
592
 
593
+ var DatatableFooterTplDirective = /** @class */ (function () {
594
+ function DatatableFooterTplDirective(template) {
595
+ this.template = template;
596
+ }
597
+ return DatatableFooterTplDirective;
598
+ }());
599
+ DatatableFooterTplDirective.decorators = [
600
+ { type: i0.Directive, args: [{
601
+ selector: '[seamDatatableFooterTpl]'
602
+ },] }
603
+ ];
604
+ DatatableFooterTplDirective.ctorParameters = function () { return [
605
+ { type: i0.TemplateRef }
606
+ ]; };
607
+
608
+ var TheSeamDatatableFooterDirective = /** @class */ (function () {
609
+ function TheSeamDatatableFooterDirective() {
610
+ }
611
+ Object.defineProperty(TheSeamDatatableFooterDirective.prototype, "template", {
612
+ get: function () {
613
+ return this._templateInput || this._templateQuery;
614
+ },
615
+ enumerable: false,
616
+ configurable: true
617
+ });
618
+ return TheSeamDatatableFooterDirective;
619
+ }());
620
+ TheSeamDatatableFooterDirective.decorators = [
621
+ { type: i0.Directive, args: [{
622
+ // tslint:disable-next-line: directive-selector
623
+ selector: 'seam-datatable-footer'
624
+ },] }
625
+ ];
626
+ TheSeamDatatableFooterDirective.propDecorators = {
627
+ _templateInput: [{ type: i0.Input, args: ['template',] }],
628
+ _templateQuery: [{ type: i0.ContentChild, args: [DatatableFooterTplDirective, { read: i0.TemplateRef, static: true },] }]
629
+ };
630
+
637
631
  var DatatableFilterDirective = /** @class */ (function () {
638
632
  function DatatableFilterDirective(dataFilters) {
639
633
  if (dataFilters && dataFilters.length > 0) {
@@ -706,7 +700,7 @@
706
700
  selector: 'seam-datatable-menu-bar',
707
701
  template: "<div class=\"bg-light border rounded p-2\">\n <ng-content></ng-content>\n</div>\n",
708
702
  providers: [_THESEAM_DATA_FILTER_CONTAINER],
709
- styles: [":host{display:block}"]
703
+ styles: [":host{display:block}\n"]
710
704
  },] }
711
705
  ];
712
706
  DatatableMenuBarComponent.ctorParameters = function () { return []; };
@@ -816,52 +810,426 @@
816
810
  { type: i0.TemplateRef }
817
811
  ]; };
818
812
 
819
- var THESEAM_DATATABLE_PREFERENCES_ACCESSOR = new i0.InjectionToken('ITheSeamDatatablePreferencesAccessor');
813
+ var DatatableDataSource = /** @class */ (function (_super) {
814
+ __extends(DatatableDataSource, _super);
815
+ function DatatableDataSource() {
816
+ var _this = _super.call(this) || this;
817
+ _this._datatableSubject = new rxjs.BehaviorSubject(undefined);
818
+ _this.sorts$ = _this._datatableSubject.pipe(operators.switchMap(function (_datatable) {
819
+ if (!_datatable) {
820
+ return rxjs.of([]);
821
+ }
822
+ return _datatable.sort.pipe(operators.map(function (v) { return v.sorts; }), operators.startWith(_datatable.sorts));
823
+ }));
824
+ _this.filterStates$ = _this._datatableSubject.pipe(operators.switchMap(function (_datatable) {
825
+ if (!_datatable) {
826
+ return rxjs.of([]);
827
+ }
828
+ return _datatable.filterStates;
829
+ }));
830
+ _this.page$ = _this._datatableSubject.pipe(operators.switchMap(function (_datatable) {
831
+ if (!_datatable) {
832
+ return rxjs.of({
833
+ offset: 0,
834
+ pageSize: 0,
835
+ limit: undefined,
836
+ count: 0
837
+ });
838
+ }
839
+ return _datatable.page.pipe(operators.startWith(_datatable.pageInfo));
840
+ }));
841
+ return _this;
842
+ }
843
+ // connect(): Observable<readonly TRow[]> {
844
+ // return this.
845
+ // }
846
+ // disconnect(): void {
847
+ // throw new Error('Method not implemented.')
848
+ // }
849
+ DatatableDataSource.prototype.setDatatableAccessor = function (accessor) {
850
+ this._datatableSubject.next(accessor);
851
+ };
852
+ return DatatableDataSource;
853
+ }(collections.DataSource));
820
854
 
821
- function withStoredColumnInfo(columns, preferenceColumns) {
855
+ var ACTION_MENU_COLUMN_PROP = '$$__actionMenu__';
856
+ function createActionMenuColumn(cellTemplate, headerTemplate) {
857
+ return {
858
+ prop: ACTION_MENU_COLUMN_PROP,
859
+ name: '',
860
+ width: 50,
861
+ minWidth: 50,
862
+ maxWidth: 50,
863
+ resizeable: false,
864
+ sortable: false,
865
+ draggable: false,
866
+ // TODO: Fix column auto sizing with fixed column and cell overlay before enabling.
867
+ // frozenRight: true,
868
+ cellTemplate: cellTemplate,
869
+ headerTemplate: headerTemplate,
870
+ };
871
+ }
872
+
873
+ var CHECKBOX_COLUMN_PROP = '$$__checkbox__';
874
+ function createCheckboxColumn() {
875
+ return {
876
+ prop: CHECKBOX_COLUMN_PROP,
877
+ name: '',
878
+ width: 40,
879
+ sortable: false,
880
+ canAutoResize: false,
881
+ draggable: false,
882
+ resizeable: false,
883
+ headerCheckboxable: true,
884
+ checkboxable: true,
885
+ };
886
+ }
887
+
888
+ function getColumnProp(col) {
889
+ if (!utils.notNullOrUndefined(col.prop) && col.name) {
890
+ return ngxDatatable.camelCase(col.name);
891
+ }
892
+ return col.prop === null ? undefined : col.prop;
893
+ }
894
+
895
+ function setColumnDefaults(columns) {
822
896
  var e_1, _a;
823
- var _columns = [];
824
- var _loop_1 = function (col) {
825
- var storedCol = preferenceColumns.find(function (v) { return v.prop === col.prop; });
826
- if (storedCol) {
827
- var _col = Object.assign({}, col);
828
- if (utils.hasProperty(storedCol, 'width')) {
829
- _col.width = Math.max(storedCol.width, 0);
897
+ try {
898
+ for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
899
+ var column = columns_1_1.value;
900
+ if (!column.hasOwnProperty('hidden')) {
901
+ column.hidden = false;
830
902
  }
831
- _col.canAutoResize = storedCol.canAutoResize;
832
- _columns.push(_col);
833
903
  }
834
- else {
835
- _columns.push(col);
904
+ }
905
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
906
+ finally {
907
+ try {
908
+ if (columns_1_1 && !columns_1_1.done && (_a = columns_1.return)) _a.call(columns_1);
836
909
  }
837
- };
910
+ finally { if (e_1) throw e_1.error; }
911
+ }
912
+ ngxDatatable.setColumnDefaults(columns);
913
+ }
914
+
915
+ // TODO: Replace with a `translateTemplates` function that fits the
916
+ // wrapper component better.
917
+ function translateTemplateColumns(v) {
918
+ var e_1, _a;
919
+ var cols = ngxDatatable.translateTemplates(v);
838
920
  try {
839
- for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
840
- var col = columns_1_1.value;
841
- _loop_1(col);
921
+ for (var cols_1 = __values(cols), cols_1_1 = cols_1.next(); !cols_1_1.done; cols_1_1 = cols_1.next()) {
922
+ var col = cols_1_1.value;
923
+ col.prop = getColumnProp(col);
842
924
  }
843
925
  }
844
926
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
845
927
  finally {
846
928
  try {
847
- if (columns_1_1 && !columns_1_1.done && (_a = columns_1.return)) _a.call(columns_1);
929
+ if (cols_1_1 && !cols_1_1.done && (_a = cols_1.return)) _a.call(cols_1);
848
930
  }
849
931
  finally { if (e_1) throw e_1.error; }
850
932
  }
851
- return _columns;
933
+ return cols;
852
934
  }
853
935
 
936
+ var ColumnsTypes;
937
+ (function (ColumnsTypes) {
938
+ ColumnsTypes[ColumnsTypes["Input"] = 0] = "Input";
939
+ ColumnsTypes[ColumnsTypes["Template"] = 1] = "Template";
940
+ ColumnsTypes[ColumnsTypes["Result"] = 2] = "Result";
941
+ })(ColumnsTypes || (ColumnsTypes = {}));
942
+ var ColumnsManagerService = /** @class */ (function () {
943
+ function ColumnsManagerService(_differs, _columnChangesService) {
944
+ var _this = this;
945
+ this._differs = _differs;
946
+ this._columnChangesService = _columnChangesService;
947
+ this._updateColumns = new rxjs.Subject();
948
+ this._inputColumns = new rxjs.BehaviorSubject([]);
949
+ this._templateColumns = new rxjs.BehaviorSubject([]);
950
+ this._inpColDiffersMap = new Map();
951
+ this._tplColDiffersMap = new Map();
952
+ this._resultColDiffersMap = new Map();
953
+ var templateColumns$ = this._columnChangesService.columnInputChanges$.pipe(operators.startWith(undefined), operators.switchMap(function () {
954
+ return _this._templateColumns.asObservable().pipe(operators.map(translateTemplateColumns));
955
+ }));
956
+ this.columns$ = rxjs.defer(function () {
957
+ var isFirst = true;
958
+ return rxjs.combineLatest([
959
+ _this._inputColumns.asObservable(),
960
+ templateColumns$,
961
+ _this._updateColumns.asObservable().pipe(operators.auditTime(0), operators.startWith(undefined))
962
+ ]).pipe(operators.switchMap(function (_a) {
963
+ var _b = __read(_a, 2), inputColumns = _b[0], templateColumns = _b[1];
964
+ var cols = _this._mergeColumns(inputColumns, templateColumns);
965
+ var hasColumnsChanged = _this._hasColumnsChanged(cols);
966
+ // TODO: Look for columns added/removed and remove the removed columns
967
+ // differs, not just changes to columns.
968
+ var hasAddedOrRemovedColumns = _this._hasAddedOrRemovedColumns(cols);
969
+ // NOTE: Both checks need to be run, even though only one needs to be
970
+ // true, because their differs need to be called.
971
+ if (hasColumnsChanged || hasAddedOrRemovedColumns || isFirst) {
972
+ isFirst = false;
973
+ return rxjs.of(cols);
974
+ }
975
+ return rxjs.EMPTY;
976
+ }));
977
+ }).pipe(operators.shareReplay({ refCount: true, bufferSize: 1 }));
978
+ }
979
+ ColumnsManagerService.prototype.setInputColumns = function (columns) {
980
+ this._inputColumns.next(columns);
981
+ };
982
+ ColumnsManagerService.prototype.setTemplateColumns = function (columns) {
983
+ this._templateColumns.next(columns);
984
+ };
985
+ ColumnsManagerService.prototype.setInternalColumnsGetter = function (getter) {
986
+ this._internalColumnsGetter = getter || undefined;
987
+ this._updateColumns.next(undefined);
988
+ };
989
+ ColumnsManagerService.prototype.setSelectionType = function (selectionType) {
990
+ var changed = this._selectionType !== selectionType;
991
+ this._selectionType = selectionType;
992
+ if (changed) {
993
+ this._updateColumns.next(undefined);
994
+ }
995
+ };
996
+ ColumnsManagerService.prototype.getSelectionType = function () {
997
+ return this._selectionType;
998
+ };
999
+ ColumnsManagerService.prototype.setRowActionItem = function (rowActionItem) {
1000
+ var changed = this._rowActionItem !== rowActionItem;
1001
+ this._rowActionItem = rowActionItem;
1002
+ if (changed) {
1003
+ this._updateColumns.next(undefined);
1004
+ }
1005
+ };
1006
+ ColumnsManagerService.prototype.setActionMenuCellTpl = function (actionMenuCellTpl) {
1007
+ var changed = this._actionMenuCellTpl !== actionMenuCellTpl;
1008
+ this._actionMenuCellTpl = actionMenuCellTpl;
1009
+ if (changed) {
1010
+ this._updateColumns.next(undefined);
1011
+ }
1012
+ };
1013
+ ColumnsManagerService.prototype.setBlankHeaderTpl = function (blankHeaderTpl) {
1014
+ var changed = this._blankHeaderTpl !== blankHeaderTpl;
1015
+ this._blankHeaderTpl = blankHeaderTpl;
1016
+ if (changed) {
1017
+ this._updateColumns.next(undefined);
1018
+ }
1019
+ };
1020
+ ColumnsManagerService.prototype.setTreeToggleTpl = function (treeToggleTpl) {
1021
+ var changed = this._treeToggleTpl !== treeToggleTpl;
1022
+ this._treeToggleTpl = treeToggleTpl;
1023
+ if (changed) {
1024
+ this._updateColumns.next(undefined);
1025
+ }
1026
+ };
1027
+ ColumnsManagerService.prototype.setHeaderTpl = function (headerTpl) {
1028
+ var changed = this._headerTpl !== headerTpl;
1029
+ this._headerTpl = headerTpl;
1030
+ if (changed) {
1031
+ this._updateColumns.next(undefined);
1032
+ }
1033
+ };
1034
+ ColumnsManagerService.prototype.setCellTypeSelectorTpl = function (cellTypeSelectorTpl) {
1035
+ var changed = this._cellTypeSelectorTpl !== cellTypeSelectorTpl;
1036
+ this._cellTypeSelectorTpl = cellTypeSelectorTpl;
1037
+ if (changed) {
1038
+ this._updateColumns.next(undefined);
1039
+ }
1040
+ };
1041
+ ColumnsManagerService.prototype._mergeColumns = function (inputColumns, templateColumns) {
1042
+ var e_1, _a;
1043
+ var cols = [];
1044
+ // Add the first column checkbox if 'checkbox' selection is enabled.
1045
+ if (this._shouldAddCheckboxColumn()) {
1046
+ cols.push(createCheckboxColumn());
1047
+ }
1048
+ try {
1049
+ // Column needs to be provided in the inputColumns, so iterate the
1050
+ // inputColumns.
1051
+ for (var inputColumns_1 = __values(inputColumns), inputColumns_1_1 = inputColumns_1.next(); !inputColumns_1_1.done; inputColumns_1_1 = inputColumns_1.next()) {
1052
+ var inpCol = inputColumns_1_1.value;
1053
+ var prop = getColumnProp(inpCol);
1054
+ if (!utils.notNullOrUndefined(prop)) {
1055
+ throw Error("Column may have 'prop' or 'name' defined.");
1056
+ }
1057
+ var internalCol = this._getInternalColumn(prop);
1058
+ var inpColDif = this._getColDif(inpCol, ColumnsTypes.Input);
1059
+ if (utils.notNullOrUndefined(inpColDif)) {
1060
+ this._updateColDif(inpColDif, internalCol, inpCol);
1061
+ }
1062
+ var tplCol = this._findColumnByProp(prop, templateColumns);
1063
+ if (tplCol !== undefined) {
1064
+ var tplColDif = this._getColDif(tplCol, ColumnsTypes.Template);
1065
+ if (utils.notNullOrUndefined(tplColDif)) {
1066
+ this._updateColDif(tplColDif, internalCol, tplCol);
1067
+ }
1068
+ }
1069
+ var _col = Object.assign(Object.assign(Object.assign({}, (internalCol || {})), inpCol), (tplCol || {}));
1070
+ if (this._shouldAddTreeToggleColumn(_col)) {
1071
+ _col.treeToggleTemplate = this._treeToggleTpl;
1072
+ }
1073
+ if (this._shouldAddHeaderTemplate(_col)) {
1074
+ _col.headerTemplate = this._headerTpl;
1075
+ }
1076
+ if (this._shouldAddCellTypeSelectorTpl(_col)) {
1077
+ _col.cellTemplate = this._cellTypeSelectorTpl;
1078
+ }
1079
+ cols.push(_col);
1080
+ }
1081
+ }
1082
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1083
+ finally {
1084
+ try {
1085
+ if (inputColumns_1_1 && !inputColumns_1_1.done && (_a = inputColumns_1.return)) _a.call(inputColumns_1);
1086
+ }
1087
+ finally { if (e_1) throw e_1.error; }
1088
+ }
1089
+ if (this._shouldAddRowActionColumn()) {
1090
+ cols.push(createActionMenuColumn(this._actionMenuCellTpl, this._blankHeaderTpl));
1091
+ }
1092
+ // Make sure the default for any missing props are set.
1093
+ // TODO: Determine if this should be done earlier, because I don't like
1094
+ // how this is done after dif checks.
1095
+ setColumnDefaults(cols);
1096
+ return cols;
1097
+ };
1098
+ ColumnsManagerService.prototype._getInternalColumns = function () {
1099
+ if (this._internalColumnsGetter === undefined) {
1100
+ return undefined;
1101
+ }
1102
+ return this._internalColumnsGetter();
1103
+ };
1104
+ ColumnsManagerService.prototype._getInternalColumn = function (prop) {
1105
+ var internalCols = this._getInternalColumns();
1106
+ if (internalCols === undefined) {
1107
+ return undefined;
1108
+ }
1109
+ return internalCols.find(function (c) { return getColumnProp(c) === prop; });
1110
+ };
1111
+ ColumnsManagerService.prototype._findColumnByProp = function (prop, columns) {
1112
+ return columns.find(function (c) { return getColumnProp(c) === prop; });
1113
+ };
1114
+ ColumnsManagerService.prototype._getDifMapForColumnsType = function (columnsType) {
1115
+ switch (columnsType) {
1116
+ case ColumnsTypes.Input: return this._inpColDiffersMap;
1117
+ case ColumnsTypes.Template: return this._tplColDiffersMap;
1118
+ case ColumnsTypes.Result: return this._resultColDiffersMap;
1119
+ }
1120
+ };
1121
+ ColumnsManagerService.prototype._getColumnDiffer = function (prop, colsType) {
1122
+ var difMap = this._getDifMapForColumnsType(colsType);
1123
+ if (difMap === null) {
1124
+ throw Error("Invalid columns type.");
1125
+ }
1126
+ if (!difMap.has(prop)) {
1127
+ difMap.set(prop, this._differs.find({}).create());
1128
+ }
1129
+ var differ = difMap.get(prop);
1130
+ if (differ === undefined) {
1131
+ throw Error("Differ not found. New differ should have been created.");
1132
+ }
1133
+ return differ;
1134
+ };
1135
+ ColumnsManagerService.prototype._getColDif = function (col, colsType) {
1136
+ var prop = getColumnProp(col);
1137
+ if (prop === undefined) {
1138
+ throw Error("Column prop not found.");
1139
+ }
1140
+ return this._getColumnDiffer(prop, colsType).diff(col);
1141
+ };
1142
+ ColumnsManagerService.prototype._updateColDif = function (colDif, internalColumn, col) {
1143
+ colDif.forEachRemovedItem(function (r) {
1144
+ if (internalColumn && internalColumn.hasOwnProperty(r.key)) {
1145
+ var k = r.key;
1146
+ delete internalColumn[k];
1147
+ }
1148
+ });
1149
+ colDif.forEachAddedItem(function (r) { return col[r.key] = r.currentValue; });
1150
+ colDif.forEachChangedItem(function (r) { return col[r.key] = r.currentValue; });
1151
+ };
1152
+ ColumnsManagerService.prototype._hasAddedOrRemovedColumns = function (columns) {
1153
+ if (!this._colPropsDiffer) {
1154
+ this._colPropsDiffer = this._differs.find([]).create();
1155
+ }
1156
+ var props = columns.map(function (c) { return getColumnProp(c); });
1157
+ return this._colPropsDiffer.diff(props) !== null;
1158
+ };
1159
+ ColumnsManagerService.prototype._hasColumnsChanged = function (columns) {
1160
+ var e_2, _a;
1161
+ var colChanged = false;
1162
+ try {
1163
+ for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
1164
+ var col = columns_1_1.value;
1165
+ var resultDif = this._getColDif(col, ColumnsTypes.Result);
1166
+ if (resultDif) {
1167
+ // NOTE: Can't return early, because the differs need to be updated.
1168
+ colChanged = true;
1169
+ }
1170
+ }
1171
+ }
1172
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1173
+ finally {
1174
+ try {
1175
+ if (columns_1_1 && !columns_1_1.done && (_a = columns_1.return)) _a.call(columns_1);
1176
+ }
1177
+ finally { if (e_2) throw e_2.error; }
1178
+ }
1179
+ return colChanged;
1180
+ };
1181
+ ColumnsManagerService.prototype._shouldAddCheckboxColumn = function () {
1182
+ return this._selectionType === ngxDatatable.SelectionType.checkbox;
1183
+ };
1184
+ ColumnsManagerService.prototype._shouldAddRowActionColumn = function () {
1185
+ return this._rowActionItem !== undefined;
1186
+ };
1187
+ ColumnsManagerService.prototype._shouldAddTreeToggleColumn = function (column) {
1188
+ return column.isTreeColumn !== undefined && column.isTreeColumn &&
1189
+ (!utils.hasProperty(column, 'treeToggleTemplate') || !utils.notNullOrUndefined(column.treeToggleTemplate));
1190
+ };
1191
+ ColumnsManagerService.prototype._shouldAddHeaderTemplate = function (column) {
1192
+ return !utils.hasProperty(column, 'headerTemplate');
1193
+ };
1194
+ ColumnsManagerService.prototype._shouldAddCellTypeSelectorTpl = function (column) {
1195
+ return utils.hasProperty(column, 'cellType');
1196
+ };
1197
+ return ColumnsManagerService;
1198
+ }());
1199
+ ColumnsManagerService.decorators = [
1200
+ { type: i0.Injectable }
1201
+ ];
1202
+ ColumnsManagerService.ctorParameters = function () { return [
1203
+ { type: i0.KeyValueDiffers },
1204
+ { type: DatatableColumnChangesService }
1205
+ ]; };
1206
+
1207
+ var CURRENT_DATATABLE_PREFERENCES_VERSION = 2;
1208
+ var EMPTY_DATATABLE_PREFERENCES = {
1209
+ version: 2,
1210
+ alterations: []
1211
+ };
1212
+
1213
+ var THESEAM_DATATABLE_PREFERENCES_ACCESSOR = new i0.InjectionToken('TheSeamDatatablePreferencesAccessor');
1214
+
1215
+ // TODO: Add per key status
854
1216
  var DatatablePreferencesService = /** @class */ (function () {
855
1217
  function DatatablePreferencesService(_prefsAccessor) {
856
1218
  this._prefsAccessor = _prefsAccessor;
857
1219
  this._tablePrefsMap = new Map();
858
1220
  this._pending = false;
1221
+ this._loaded = false;
859
1222
  }
860
1223
  Object.defineProperty(DatatablePreferencesService.prototype, "pending", {
861
1224
  get: function () { return this._pending; },
862
1225
  enumerable: false,
863
1226
  configurable: true
864
1227
  });
1228
+ Object.defineProperty(DatatablePreferencesService.prototype, "loaded", {
1229
+ get: function () { return this._loaded; },
1230
+ enumerable: false,
1231
+ configurable: true
1232
+ });
865
1233
  DatatablePreferencesService.prototype.preferences = function (preferenceKey) {
866
1234
  var prefs = this._tablePrefsMap.get(preferenceKey);
867
1235
  if (!prefs) {
@@ -877,16 +1245,17 @@
877
1245
  DatatablePreferencesService.prototype._createObservable = function (refreshSubject, prefKey) {
878
1246
  var _this = this;
879
1247
  if (!this._prefsAccessor) {
880
- return rxjs.of({});
1248
+ return rxjs.of(EMPTY_DATATABLE_PREFERENCES);
881
1249
  }
882
- var accessor = function (key) { return _this._prefsAccessor ? _this._prefsAccessor.get(key) : rxjs.of('{}'); };
883
- return refreshSubject.pipe(operators.startWith({}), operators.switchMap(function () { return accessor(prefKey).pipe(operators.map(function (v) {
1250
+ var accessor = function (key) { return _this._prefsAccessor ? _this._prefsAccessor.get(key) : rxjs.of(JSON.stringify(EMPTY_DATATABLE_PREFERENCES)); };
1251
+ return refreshSubject.pipe(operators.startWith(undefined), operators.switchMap(function () { return accessor(prefKey).pipe(operators.map(function (v) {
884
1252
  if (!v) {
885
1253
  return null;
886
1254
  }
887
1255
  // TODO: Add a schema validator and migration tool to avoid parsing issues.
888
1256
  try {
889
- return JSON.parse(v);
1257
+ // return JSON.parse(v) as TheSeamDatatablePreferences
1258
+ return _this._descerializePreferences(v);
890
1259
  }
891
1260
  catch (error) {
892
1261
  if (i0.isDevMode()) {
@@ -894,7 +1263,12 @@
894
1263
  }
895
1264
  return null;
896
1265
  }
897
- }), operators.map(function (v) { return !!v ? v : {}; })); }), operators.shareReplay(1));
1266
+ }), operators.map(function (v) { return utils.notNullOrUndefined(v) ? v : EMPTY_DATATABLE_PREFERENCES; }),
1267
+ // tap(v => console.log('preferences$', v)),
1268
+ operators.tap(function () {
1269
+ _this._pending = false;
1270
+ _this._loaded = true;
1271
+ })); }), operators.shareReplay({ bufferSize: 1, refCount: true }));
898
1272
  };
899
1273
  DatatablePreferencesService.prototype.refresh = function (preferenceKey) {
900
1274
  var prefs = this._tablePrefsMap.get(preferenceKey);
@@ -910,7 +1284,40 @@
910
1284
  // out of order updates. This shouldn't be an issue, with how fast preferences
911
1285
  // will most likely be changing, but it could happen in situations, such as
912
1286
  // network issues.
913
- DatatablePreferencesService.prototype.setColumnPreference = function (preferenceKey, column) {
1287
+ // public setColumnPreference(preferenceKey: string, column: TheSeamDatatablePreferencesColumn): void {
1288
+ // if (!this._prefsAccessor) {
1289
+ // return
1290
+ // }
1291
+ // this._pending = true
1292
+ // this.preferences(preferenceKey).pipe(
1293
+ // map(prefs => {
1294
+ // // Making the preferences immutable may not be necessary, but for now
1295
+ // // this obj->str->obj will work as a naive clone.
1296
+ // const columns = JSON.parse(JSON.stringify(prefs.columns || []))
1297
+ // const _colPref = columns.find((c: any) => c.prop === column.prop)
1298
+ // // console.log('has', _colPref)
1299
+ // if (_colPref) {
1300
+ // // console.log('hasProperty(column, "width"))', hasProperty(column, 'width'))
1301
+ // if (hasProperty(column, 'width')) { _colPref.width = column.width }
1302
+ // if (hasProperty(column, 'canAutoResize')) { _colPref.canAutoResize = column.canAutoResize }
1303
+ // if (hasProperty(column, 'hidden')) { _colPref.hidden = column.hidden }
1304
+ // } else {
1305
+ // columns.push({ ...column })
1306
+ // }
1307
+ // const newPrefs: TheSeamDatatablePreferences = { ...prefs, columns }
1308
+ // return newPrefs
1309
+ // }),
1310
+ // // tap(v => console.log('newPrefs', v)),
1311
+ // take(1),
1312
+ // switchMap(newPrefs => this._prefsAccessor
1313
+ // ? this._prefsAccessor.update(preferenceKey, JSON.stringify(newPrefs))
1314
+ // : of(newPrefs)
1315
+ // ),
1316
+ // tap(() => this.refresh(preferenceKey))
1317
+ // )
1318
+ // .subscribe()
1319
+ // }
1320
+ DatatablePreferencesService.prototype.setAlterations = function (preferenceKey, alterations) {
914
1321
  var _this = this;
915
1322
  if (!this._prefsAccessor) {
916
1323
  return;
@@ -919,71 +1326,547 @@
919
1326
  this.preferences(preferenceKey).pipe(operators.map(function (prefs) {
920
1327
  // Making the preferences immutable may not be necessary, but for now
921
1328
  // this obj->str->obj will work as a naive clone.
922
- var columns = JSON.parse(JSON.stringify(prefs.columns || []));
923
- var _colPref = columns.find(function (c) { return c.prop === column.prop; });
924
- // console.log('has', _colPref)
925
- if (_colPref) {
926
- // console.log('hasProperty(column, "width"))', hasProperty(column, 'width'))
927
- if (utils.hasProperty(column, 'width')) {
928
- _colPref.width = column.width;
1329
+ // const columns = JSON.parse(JSON.stringify(prefs.columns || []))
1330
+ // const _colPref = columns.find((c: any) => c.prop === column.prop)
1331
+ // // console.log('has', _colPref)
1332
+ // if (_colPref) {
1333
+ // // console.log('hasProperty(column, "width"))', hasProperty(column, 'width'))
1334
+ // if (hasProperty(column, 'width')) { _colPref.width = column.width }
1335
+ // if (hasProperty(column, 'canAutoResize')) { _colPref.canAutoResize = column.canAutoResize }
1336
+ // if (hasProperty(column, 'hidden')) { _colPref.hidden = column.hidden }
1337
+ // } else {
1338
+ // columns.push({ ...column })
1339
+ // }
1340
+ // const newPrefs: TheSeamDatatablePreferences = { ...prefs, columns }
1341
+ // return newPrefs
1342
+ var newPrefs = Object.assign(Object.assign({}, EMPTY_DATATABLE_PREFERENCES), { alterations: alterations });
1343
+ return newPrefs;
1344
+ }),
1345
+ // tap(v => console.log('newPrefs', v)),
1346
+ operators.take(1), operators.switchMap(function (newPrefs) { return _this._prefsAccessor
1347
+ ? _this._prefsAccessor.update(preferenceKey, JSON.stringify(newPrefs))
1348
+ : rxjs.of(newPrefs); }), operators.tap(function () { return _this.refresh(preferenceKey); }))
1349
+ .subscribe();
1350
+ };
1351
+ // public withColumnPreferences<T>(preferenceKey: string, columns: T[]): Observable<T[]> {
1352
+ // return this.preferences(preferenceKey).pipe(
1353
+ // startWith(EMPTY_DATATABLE_PREFERENCES),
1354
+ // map(preferences => preferences && preferences.columns
1355
+ // ? withStoredColumnInfo(columns, preferences.columns) as T[]
1356
+ // : columns
1357
+ // )
1358
+ // )
1359
+ // }
1360
+ DatatablePreferencesService.prototype._descerializePreferences = function (serialized) {
1361
+ var prefs = JSON.parse(serialized);
1362
+ // TODO: Implement migration
1363
+ return prefs;
1364
+ };
1365
+ return DatatablePreferencesService;
1366
+ }());
1367
+ DatatablePreferencesService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function DatatablePreferencesService_Factory() { return new DatatablePreferencesService(i0__namespace.ɵɵinject(THESEAM_DATATABLE_PREFERENCES_ACCESSOR, 8)); }, token: DatatablePreferencesService, providedIn: "root" });
1368
+ DatatablePreferencesService.decorators = [
1369
+ { type: i0.Injectable, args: [{
1370
+ providedIn: 'root'
1371
+ },] }
1372
+ ];
1373
+ DatatablePreferencesService.ctorParameters = function () { return [
1374
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [THESEAM_DATATABLE_PREFERENCES_ACCESSOR,] }] }
1375
+ ]; };
1376
+
1377
+ var THESEAM_DATATABLE_ACCESSOR = new i0.InjectionToken('TheSeamDatatableAccessor');
1378
+
1379
+ function removeUnusedDiffs(cols, colDiffersInp, colDiffersTpl) {
1380
+ var inpKeys = Object.keys(colDiffersInp);
1381
+ inpKeys.filter(function (k) { return cols.findIndex(function (c) { return c.prop === k; }) === -1; })
1382
+ .forEach(function (k) { delete colDiffersInp[k]; });
1383
+ var tplKeys = Object.keys(colDiffersTpl);
1384
+ tplKeys.filter(function (k) { return cols.findIndex(function (c) { return c.prop === k; }) === -1; })
1385
+ .forEach(function (k) { delete colDiffersTpl[k]; });
1386
+ }
1387
+
1388
+ /**
1389
+ * Alteration applied to a column or columns that can be persisted.
1390
+ *
1391
+ * Tracking if a column was altered by user or library code can be confusing.
1392
+ * This allows us to store a list of replayable alterations on columns. By
1393
+ * having a defined way to implement alterations, the datatable should be easier
1394
+ * to support external features that want to provide an alteration.
1395
+ *
1396
+ * NOTE: Current, to unapply an alteration you can create an alteration with
1397
+ * `persistent` set to false and the alteration will be removed after `apply()`
1398
+ * is called.
1399
+ */
1400
+ var ColumnsAlteration = /** @class */ (function () {
1401
+ function ColumnsAlteration(
1402
+ /**
1403
+ * Persistable state.
1404
+ *
1405
+ * Returned value should be JSON stringifyable.
1406
+ */
1407
+ state,
1408
+ /**
1409
+ * If false, the state will not be persisted to a persistent storage and
1410
+ * will be removed after applied.
1411
+ */
1412
+ persistent) {
1413
+ this.state = state;
1414
+ this.persistent = persistent;
1415
+ this.state = state;
1416
+ }
1417
+ ColumnsAlteration.prototype.toJSON = function () {
1418
+ return {
1419
+ id: this.id,
1420
+ type: this.type,
1421
+ state: this.state
1422
+ };
1423
+ };
1424
+ return ColumnsAlteration;
1425
+ }());
1426
+
1427
+ var HideColumnColumnsAlteration = /** @class */ (function (_super) {
1428
+ __extends(HideColumnColumnsAlteration, _super);
1429
+ function HideColumnColumnsAlteration(state, persistent) {
1430
+ var _this = _super.call(this, state, persistent) || this;
1431
+ _this.type = 'hide-column';
1432
+ if (!_this._isValidState(state)) {
1433
+ throw Error("Invalid state: " + JSON.stringify(state));
1434
+ }
1435
+ _this.id = _this.type + "--" + state.columnProp;
1436
+ return _this;
1437
+ }
1438
+ HideColumnColumnsAlteration.prototype.apply = function (columns, datatable) {
1439
+ var e_1, _a;
1440
+ try {
1441
+ for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
1442
+ var col = columns_1_1.value;
1443
+ var prop = getColumnProp(col);
1444
+ if (prop === this.state.columnProp) {
1445
+ col.hidden = this.state.hidden;
929
1446
  }
930
- if (utils.hasProperty(column, 'canAutoResize')) {
931
- _colPref.canAutoResize = column.canAutoResize;
1447
+ }
1448
+ }
1449
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1450
+ finally {
1451
+ try {
1452
+ if (columns_1_1 && !columns_1_1.done && (_a = columns_1.return)) _a.call(columns_1);
1453
+ }
1454
+ finally { if (e_1) throw e_1.error; }
1455
+ }
1456
+ };
1457
+ HideColumnColumnsAlteration.prototype._isValidState = function (state) {
1458
+ // NOTE: Checking null or undefined, even though the type doesn't allow,
1459
+ // because the state may have been loaded from an invalid persistant
1460
+ // storage.
1461
+ // TODO: Remove when state validation/migration is implemented to happen
1462
+ // when retrieved from storage.
1463
+ if (!utils.notNullOrUndefined(state.columnProp)) {
1464
+ return false;
1465
+ }
1466
+ // TODO: Remove when state validation/migration is implemented to happen
1467
+ // when retrieved from storage.
1468
+ if (!utils.notNullOrUndefined(state.hidden)) {
1469
+ return false;
1470
+ }
1471
+ return true;
1472
+ };
1473
+ return HideColumnColumnsAlteration;
1474
+ }(ColumnsAlteration));
1475
+
1476
+ var SortColumnsAlteration = /** @class */ (function (_super) {
1477
+ __extends(SortColumnsAlteration, _super);
1478
+ function SortColumnsAlteration(state, persistent) {
1479
+ var _this = _super.call(this, state, persistent) || this;
1480
+ _this.type = 'sort';
1481
+ if (!_this._isValidState(state)) {
1482
+ throw Error("Invalid state: " + JSON.stringify(state));
1483
+ }
1484
+ _this.id = "" + _this.type;
1485
+ return _this;
1486
+ }
1487
+ SortColumnsAlteration.prototype.apply = function (columns, datatable) {
1488
+ if (datatable.sortType === ngxDatatable.SortType.single) {
1489
+ datatable.sorts = this.state.sorts.length > 0 ? [this.state.sorts[0]] : [];
1490
+ }
1491
+ else {
1492
+ datatable.sorts = this.state.sorts;
1493
+ }
1494
+ };
1495
+ SortColumnsAlteration.prototype._isValidState = function (state) {
1496
+ // NOTE: Checking null or undefined, even though the type doesn't allow,
1497
+ // because the state may have been loaded from an invalid persistant
1498
+ // storage.
1499
+ // TODO: Remove when state validation/migration is implemented to happen
1500
+ // when retrieved from storage.
1501
+ if (!utils.notNullOrUndefined(state.sorts)) {
1502
+ return false;
1503
+ }
1504
+ return true;
1505
+ };
1506
+ return SortColumnsAlteration;
1507
+ }(ColumnsAlteration));
1508
+
1509
+ var WidthColumnsAlteration = /** @class */ (function (_super) {
1510
+ __extends(WidthColumnsAlteration, _super);
1511
+ function WidthColumnsAlteration(state, persistent) {
1512
+ var _this = _super.call(this, state, persistent) || this;
1513
+ _this.type = 'width';
1514
+ if (!_this._isValidState(state)) {
1515
+ throw Error("Invalid state: " + JSON.stringify(state));
1516
+ }
1517
+ _this.id = _this.type + "--" + state.columnProp;
1518
+ return _this;
1519
+ }
1520
+ WidthColumnsAlteration.prototype.apply = function (columns, datatable) {
1521
+ var e_1, _a;
1522
+ try {
1523
+ for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
1524
+ var col = columns_1_1.value;
1525
+ var prop = getColumnProp(col);
1526
+ if (prop === this.state.columnProp) {
1527
+ col.canAutoResize = this.state.canAutoResize;
1528
+ if (utils.notNullOrUndefined(this.state.width)) {
1529
+ col.width = this.state.width;
1530
+ }
932
1531
  }
933
- if (utils.hasProperty(column, 'hidden')) {
934
- _colPref.hidden = column.hidden;
1532
+ }
1533
+ }
1534
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1535
+ finally {
1536
+ try {
1537
+ if (columns_1_1 && !columns_1_1.done && (_a = columns_1.return)) _a.call(columns_1);
1538
+ }
1539
+ finally { if (e_1) throw e_1.error; }
1540
+ }
1541
+ };
1542
+ WidthColumnsAlteration.prototype._isValidState = function (state) {
1543
+ // NOTE: Checking null or undefined, even though the type doesn't allow,
1544
+ // because the state may have been loaded from an invalid persistant
1545
+ // storage.
1546
+ // TODO: Remove when state validation/migration is implemented to happen
1547
+ // when retrieved from storage.
1548
+ if (!utils.notNullOrUndefined(state.columnProp)) {
1549
+ return false;
1550
+ }
1551
+ // TODO: Remove when state validation/migration is implemented to happen
1552
+ // when retrieved from storage.
1553
+ if (!utils.notNullOrUndefined(state.canAutoResize)) {
1554
+ return false;
1555
+ }
1556
+ return true;
1557
+ };
1558
+ return WidthColumnsAlteration;
1559
+ }(ColumnsAlteration));
1560
+
1561
+ var ColumnsAlterationsManagerService = /** @class */ (function () {
1562
+ function ColumnsAlterationsManagerService() {
1563
+ this._changesSubject = new rxjs.Subject();
1564
+ this._alterations = [];
1565
+ this.changes = this._changesSubject.asObservable();
1566
+ }
1567
+ ColumnsAlterationsManagerService.prototype.get = function () {
1568
+ return __spreadArray([], __read(this._alterations));
1569
+ };
1570
+ /**
1571
+ * Adds alterations to be applied to columns.
1572
+ *
1573
+ * If an alteration with the same `id` already exists then the existing
1574
+ * alteration will be removed and the new one added.
1575
+ *
1576
+ * NOTE: When there is a duplicate alteration the old alteration is removed,
1577
+ * instead of updated, to maintain the order alterations are applied.
1578
+ */
1579
+ ColumnsAlterationsManagerService.prototype.add = function (alterations, options) {
1580
+ // console.log('add', alterations)
1581
+ var removed = this.remove(alterations, { emitEvent: false });
1582
+ this._alterations = __spreadArray(__spreadArray([], __read(this._alterations)), __read(alterations));
1583
+ var changes = __spreadArray(__spreadArray([], __read(removed)), __read(alterations.map(function (a) {
1584
+ var record = {
1585
+ type: 'added',
1586
+ alteration: a
1587
+ };
1588
+ return record;
1589
+ })));
1590
+ if (utils.notNullOrUndefined(options === null || options === void 0 ? void 0 : options.emitEvent) && !(options === null || options === void 0 ? void 0 : options.emitEvent)) {
1591
+ return changes;
1592
+ }
1593
+ this._emitChanges(changes);
1594
+ return changes;
1595
+ };
1596
+ ColumnsAlterationsManagerService.prototype.remove = function (alterations, options) {
1597
+ // console.log('remove', alterations)
1598
+ var removed = [];
1599
+ this._alterations = this._alterations.filter(function (x) {
1600
+ var found = alterations.findIndex(function (y) { return y.id === x.id; }) !== -1;
1601
+ if (found) {
1602
+ var eventRecord = {
1603
+ type: 'removed',
1604
+ alteration: x
1605
+ };
1606
+ removed.push(eventRecord);
1607
+ }
1608
+ return !found;
1609
+ });
1610
+ // console.log('removed', removed, this._alterations)
1611
+ if (utils.notNullOrUndefined(options === null || options === void 0 ? void 0 : options.emitEvent) && !(options === null || options === void 0 ? void 0 : options.emitEvent)) {
1612
+ return removed;
1613
+ }
1614
+ this._emitChanges(removed);
1615
+ return removed;
1616
+ };
1617
+ ColumnsAlterationsManagerService.prototype.apply = function (columns, datatable) {
1618
+ var e_1, _a;
1619
+ try {
1620
+ for (var _b = __values(this._alterations), _c = _b.next(); !_c.done; _c = _b.next()) {
1621
+ var a = _c.value;
1622
+ a.apply(columns, datatable);
1623
+ }
1624
+ }
1625
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1626
+ finally {
1627
+ try {
1628
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1629
+ }
1630
+ finally { if (e_1) throw e_1.error; }
1631
+ }
1632
+ this._removeNonPersistant();
1633
+ };
1634
+ // TODO: Make aware of original column order and properties. This is tricky,
1635
+ // because the datatable does not deal with immutable column/row records and
1636
+ // it is hard to know where changes happened. Just serializing the columns
1637
+ // input is not enough, because the columns input is called anytime the user
1638
+ // makes a column change. We can probably come up with a mostly accurate
1639
+ // implementation, such as "reset original columns cache when preferencesKey
1640
+ // changes" or "number of columns change". There are issues with those rules,
1641
+ // but with some testing/experimenting I think there should be a "good enough"
1642
+ // solution.
1643
+ //
1644
+ // TODO: Find a generic way to clear alterations. I would like to add an
1645
+ // `unapply` method to `ColumnsAlteration`, but since the alterations
1646
+ // themselves are not too generic it may be tricky.
1647
+ ColumnsAlterationsManagerService.prototype.clear = function (options) {
1648
+ var e_2, _a;
1649
+ var changes = [];
1650
+ try {
1651
+ for (var _b = __values(this._alterations), _c = _b.next(); !_c.done; _c = _b.next()) {
1652
+ var colAlt = _c.value;
1653
+ switch (colAlt.type) {
1654
+ case 'hide-column': {
1655
+ var alteration = new HideColumnColumnsAlteration({ columnProp: colAlt.state.columnProp, hidden: false }, false);
1656
+ changes.push.apply(changes, __spreadArray([], __read(this.add([alteration]))));
1657
+ break;
1658
+ }
1659
+ case 'order': {
1660
+ changes.push.apply(changes, __spreadArray([], __read(this.remove([colAlt]))));
1661
+ break;
1662
+ }
1663
+ case 'sort': {
1664
+ var alteration = new SortColumnsAlteration({ sorts: [] }, false);
1665
+ changes.push.apply(changes, __spreadArray([], __read(this.add([alteration]))));
1666
+ break;
1667
+ }
1668
+ case 'width': {
1669
+ var alteration = new WidthColumnsAlteration({ columnProp: colAlt.state.columnProp, canAutoResize: true }, false);
1670
+ changes.push.apply(changes, __spreadArray([], __read(this.add([alteration]))));
1671
+ break;
1672
+ }
1673
+ }
1674
+ }
1675
+ }
1676
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1677
+ finally {
1678
+ try {
1679
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1680
+ }
1681
+ finally { if (e_2) throw e_2.error; }
1682
+ }
1683
+ if (utils.notNullOrUndefined(options === null || options === void 0 ? void 0 : options.emitEvent) && !(options === null || options === void 0 ? void 0 : options.emitEvent)) {
1684
+ return changes;
1685
+ }
1686
+ this._emitChanges(changes);
1687
+ return changes;
1688
+ };
1689
+ ColumnsAlterationsManagerService.prototype._removeNonPersistant = function () {
1690
+ var nonPersistent = this._alterations.filter(function (x) { return !x.persistent; });
1691
+ this.remove(nonPersistent, { emitEvent: false });
1692
+ };
1693
+ ColumnsAlterationsManagerService.prototype._emitChanges = function (changes) {
1694
+ if (changes.length === 0) {
1695
+ return;
1696
+ }
1697
+ var event = {
1698
+ changes: changes
1699
+ };
1700
+ this._changesSubject.next(event);
1701
+ };
1702
+ return ColumnsAlterationsManagerService;
1703
+ }());
1704
+ ColumnsAlterationsManagerService.decorators = [
1705
+ { type: i0.Injectable }
1706
+ ];
1707
+ ColumnsAlterationsManagerService.ctorParameters = function () { return []; };
1708
+
1709
+ /**
1710
+ * Strings used for columns created and managed
1711
+ * by the datatable.
1712
+ */
1713
+ var INTERNAL_COLUMN_PROPS = [
1714
+ ACTION_MENU_COLUMN_PROP,
1715
+ CHECKBOX_COLUMN_PROP
1716
+ ];
1717
+ function isInternalColumn(column) {
1718
+ return INTERNAL_COLUMN_PROPS.findIndex(function (p) { return getColumnProp(column) === p; }) !== -1;
1719
+ }
1720
+
1721
+ var OrderColumnsAlteration = /** @class */ (function (_super) {
1722
+ __extends(OrderColumnsAlteration, _super);
1723
+ function OrderColumnsAlteration(state, persistent) {
1724
+ var _this = _super.call(this, state, persistent) || this;
1725
+ _this.type = 'order';
1726
+ if (!_this._isValidState(state)) {
1727
+ throw Error("Invalid state: " + JSON.stringify(state));
1728
+ }
1729
+ _this.id = "" + _this.type;
1730
+ return _this;
1731
+ }
1732
+ OrderColumnsAlteration.prototype.apply = function (columns, datatable) {
1733
+ var e_1, _a, e_2, _b;
1734
+ if (this.state.columns.length === 0) {
1735
+ return;
1736
+ }
1737
+ var stateColumns = this._stateColumns();
1738
+ // The internal columns are not intended for a user to be able to move them.
1739
+ // Store the internal columns current index, so it can be moved back ofter
1740
+ // sorting. This may not be the best way to do this, but it is easier than
1741
+ // making a sort that avoids them.
1742
+ //
1743
+ // NOTE: If we add an internal column that can be moved then this will need
1744
+ // to be changed.
1745
+ var internalColumns = columns
1746
+ .filter(function (c) { return isInternalColumn(c); })
1747
+ .map(function (column, index) { return ({ column: column, index: index }); });
1748
+ var _loop_1 = function (c) {
1749
+ var currentIndex = columns.findIndex(function (x) { return getColumnProp(x) === c.columnProp; });
1750
+ if (currentIndex === c.index || currentIndex === -1) {
1751
+ return "continue";
1752
+ }
1753
+ utils.arrayMoveMutable(columns, currentIndex, c.index);
1754
+ };
1755
+ try {
1756
+ for (var stateColumns_1 = __values(stateColumns), stateColumns_1_1 = stateColumns_1.next(); !stateColumns_1_1.done; stateColumns_1_1 = stateColumns_1.next()) {
1757
+ var c = stateColumns_1_1.value;
1758
+ _loop_1(c);
1759
+ }
1760
+ }
1761
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1762
+ finally {
1763
+ try {
1764
+ if (stateColumns_1_1 && !stateColumns_1_1.done && (_a = stateColumns_1.return)) _a.call(stateColumns_1);
1765
+ }
1766
+ finally { if (e_1) throw e_1.error; }
1767
+ }
1768
+ var _loop_2 = function (c) {
1769
+ var currentIndex = columns.findIndex(function (col) { return col === c.column; });
1770
+ if (currentIndex !== -1) {
1771
+ utils.arrayMoveMutable(columns, currentIndex, c.index);
1772
+ }
1773
+ else {
1774
+ if (i0.isDevMode()) {
1775
+ console.warn("Internal column could not be found after sorting. Was it lost during the sorting?");
935
1776
  }
936
1777
  }
937
- else {
938
- columns.push(Object.assign({}, column));
1778
+ };
1779
+ try {
1780
+ for (var internalColumns_1 = __values(internalColumns), internalColumns_1_1 = internalColumns_1.next(); !internalColumns_1_1.done; internalColumns_1_1 = internalColumns_1.next()) {
1781
+ var c = internalColumns_1_1.value;
1782
+ _loop_2(c);
939
1783
  }
940
- var newPrefs = Object.assign(Object.assign({}, prefs), { columns: columns });
941
- return newPrefs;
942
- }),
943
- // tap(v => console.log('newPrefs', v)),
944
- operators.take(1), operators.switchMap(function (newPrefs) { return _this._prefsAccessor
945
- ? _this._prefsAccessor.update(preferenceKey, JSON.stringify(newPrefs))
946
- : rxjs.of(newPrefs); }), operators.tap(function () { return _this.refresh(preferenceKey); }))
947
- .subscribe();
1784
+ }
1785
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1786
+ finally {
1787
+ try {
1788
+ if (internalColumns_1_1 && !internalColumns_1_1.done && (_b = internalColumns_1.return)) _b.call(internalColumns_1);
1789
+ }
1790
+ finally { if (e_2) throw e_2.error; }
1791
+ }
948
1792
  };
949
- DatatablePreferencesService.prototype.withColumnPreferences = function (preferenceKey, columns) {
950
- return this.preferences(preferenceKey).pipe(operators.startWith({}), operators.map(function (preferences) { return preferences && preferences.columns
951
- ? withStoredColumnInfo(columns, preferences.columns)
952
- : columns; }));
1793
+ OrderColumnsAlteration.prototype._isValidState = function (state) {
1794
+ // NOTE: Checking null or undefined, even though the type doesn't allow,
1795
+ // because the state may have been loaded from an invalid persistant
1796
+ // storage.
1797
+ // TODO: Remove when state validation/migration is implemented to happen
1798
+ // when retrieved from storage.
1799
+ if (!utils.notNullOrUndefined(state.columns)) {
1800
+ return false;
1801
+ }
1802
+ // NOTE: Didn't iterate each column record, because it is probably better to
1803
+ // just skip to invalid column records. It does prevent being able to
1804
+ // validate the whole state though.
1805
+ return true;
953
1806
  };
954
- return DatatablePreferencesService;
955
- }());
956
- DatatablePreferencesService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function DatatablePreferencesService_Factory() { return new DatatablePreferencesService(i0__namespace.ɵɵinject(THESEAM_DATATABLE_PREFERENCES_ACCESSOR, 8)); }, token: DatatablePreferencesService, providedIn: "root" });
957
- DatatablePreferencesService.decorators = [
958
- { type: i0.Injectable, args: [{
959
- providedIn: 'root'
960
- },] }
961
- ];
962
- DatatablePreferencesService.ctorParameters = function () { return [
963
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [THESEAM_DATATABLE_PREFERENCES_ACCESSOR,] }] }
964
- ]; };
965
-
966
- var THESEAM_DATATABLE_ACCESSOR = new i0.InjectionToken('TheSeamDatatableAccessor');
1807
+ OrderColumnsAlteration.prototype._isColumnOrderRecordValid = function (columnOrder) {
1808
+ return utils.notNullOrUndefined(columnOrder.columnProp) && utils.notNullOrUndefined(columnOrder.index);
1809
+ };
1810
+ OrderColumnsAlteration.prototype._stateColumns = function () {
1811
+ var _this = this;
1812
+ return this.state.columns.filter(function (c) {
1813
+ if (!_this._isColumnOrderRecordValid(c)) {
1814
+ if (i0.isDevMode()) {
1815
+ console.warn('Invalid column order record', c);
1816
+ }
1817
+ return false;
1818
+ }
1819
+ return true;
1820
+ }).sort(function (a, b) { return a.index === b.index ? 0 : a.index > b.index ? 1 : -1; });
1821
+ };
1822
+ return OrderColumnsAlteration;
1823
+ }(ColumnsAlteration));
967
1824
 
968
- function _setColumnDefaults(columns) {
969
- var e_1, _h;
1825
+ function mapColumnsAlterationsStates(states) {
1826
+ var e_1, _a;
1827
+ var alterations = [];
970
1828
  try {
971
- for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
972
- var column = columns_1_1.value;
973
- if (!column.hasOwnProperty('hidden')) {
974
- column.hidden = false;
1829
+ for (var states_1 = __values(states), states_1_1 = states_1.next(); !states_1_1.done; states_1_1 = states_1.next()) {
1830
+ var state = states_1_1.value;
1831
+ try {
1832
+ switch (state.type) {
1833
+ case 'hide-column':
1834
+ alterations.push(new HideColumnColumnsAlteration(state.state, true));
1835
+ break;
1836
+ case 'width':
1837
+ alterations.push(new WidthColumnsAlteration(state.state, true));
1838
+ break;
1839
+ case 'order':
1840
+ alterations.push(new OrderColumnsAlteration(state.state, true));
1841
+ break;
1842
+ case 'sort':
1843
+ alterations.push(new SortColumnsAlteration(state.state, true));
1844
+ break;
1845
+ default: {
1846
+ if (i0.isDevMode()) {
1847
+ console.warn('Unrecognized ColumnsAlteration state', state);
1848
+ }
1849
+ }
1850
+ }
1851
+ }
1852
+ catch (e) {
1853
+ if (i0.isDevMode()) {
1854
+ console.warn('Unable to map ColumnsAlteration state', state);
1855
+ console.warn(e);
1856
+ }
975
1857
  }
976
1858
  }
977
1859
  }
978
1860
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
979
1861
  finally {
980
1862
  try {
981
- if (columns_1_1 && !columns_1_1.done && (_h = columns_1.return)) _h.call(columns_1);
1863
+ if (states_1_1 && !states_1_1.done && (_a = states_1.return)) _a.call(states_1);
982
1864
  }
983
1865
  finally { if (e_1) throw e_1.error; }
984
1866
  }
985
- ngxDatatable.setColumnDefaults(columns);
986
- }
1867
+ return alterations;
1868
+ }
1869
+
987
1870
  /**
988
1871
  * Intended for internal classes declared by the `TheSeamDatatableModule`.
989
1872
  */
@@ -998,26 +1881,20 @@
998
1881
  // tslint:disable-next-line:no-use-before-declare
999
1882
  useExisting: i0.forwardRef(function () { return DatatableComponent; })
1000
1883
  };
1001
- // TODO: Reduce reliance on BehaviorSubject based observables, because it should
1002
- // be easier to avoit over emitting observables.
1003
1884
  var DatatableComponent = /** @class */ (function () {
1004
- function DatatableComponent(_columnChangesService, _differs, _preferences) {
1885
+ function DatatableComponent(_preferences, _columnsManager, _columnsAlterationsManager) {
1005
1886
  var _this = this;
1006
- // this.displayColumns$ = this.hiddenColumns$.pipe(
1007
- // switchMap(hiddenColumns => this.columns$.pipe(map(cols => cols.filter(c => hiddenColumns.findIndex(hc => hc === c.prop) === -1))))
1008
- // )
1009
- this._columnChangesService = _columnChangesService;
1010
- this._differs = _differs;
1011
1887
  this._preferences = _preferences;
1012
- this.faChevronDown = freeSolidSvgIcons.faChevronDown;
1013
- this.faChevronRight = freeSolidSvgIcons.faChevronRight;
1014
- this.faSpinner = freeSolidSvgIcons.faSpinner;
1888
+ this._columnsManager = _columnsManager;
1889
+ this._columnsAlterationsManager = _columnsAlterationsManager;
1890
+ this._faChevronDown = freeSolidSvgIcons.faChevronDown;
1891
+ this._faChevronRight = freeSolidSvgIcons.faChevronRight;
1892
+ this._faSpinner = freeSolidSvgIcons.faSpinner;
1015
1893
  this._ngUnsubscribe = new rxjs.Subject();
1016
1894
  this._filtersSubject = new rxjs.BehaviorSubject([]);
1017
- this._columnsObservable = new rxjs.BehaviorSubject(undefined);
1018
1895
  this._dataSourceSubject = new rxjs.BehaviorSubject(undefined);
1896
+ this._resizing = {};
1019
1897
  this._preferencesKey = new rxjs.BehaviorSubject(undefined);
1020
- this._columns = new rxjs.BehaviorSubject([]);
1021
1898
  this._rows = new rxjs.BehaviorSubject([]);
1022
1899
  this.columnMode = ngxDatatable.ColumnMode.force;
1023
1900
  this.selected = [];
@@ -1029,7 +1906,7 @@
1029
1906
  this.loadingIndicator = false;
1030
1907
  this.reorderable = true;
1031
1908
  this.swapColumns = false;
1032
- this.sortType = ngxDatatable.SortType.single;
1909
+ this._sortType = ngxDatatable.SortType.single;
1033
1910
  this._sorts = [];
1034
1911
  this.cssClasses = {
1035
1912
  sortAscending: 'datatable-icon-up',
@@ -1074,27 +1951,50 @@
1074
1951
  this._colDiffersInp = {};
1075
1952
  this._colDiffersTpl = {};
1076
1953
  this._rowDetailToggleSubscription = rxjs.Subscription.EMPTY;
1077
- var applyPrefs = function (cols) { return _this._preferencesKey.pipe(operators.switchMap(function (name) { return !!name
1078
- // NOTE: This pending check is temporary to avoid table using previously
1079
- // retrieved preference while the new one is being updated on the
1080
- // server.
1081
- ? !_this._preferences.pending
1082
- ? _this._preferences.withColumnPreferences(name, cols)
1083
- : rxjs.of(cols)
1084
- : rxjs.of(cols); })); };
1085
- this.columns$ = this._columnsObservable.pipe(operators.switchMap(function (colsObs) { return colsObs !== null && colsObs !== void 0 ? colsObs : rxjs.of([]); }));
1086
- this.displayColumns$ = this.columns$.pipe(operators.map(function (cols) { return cols.filter(function (c) { return !c.hidden; }); }), operators.tap(function (v) { return _this._removeUnusedDiffs(v); }), operators.switchMap(function (cols) { return applyPrefs(cols); }));
1954
+ this._preferencesKey.pipe(operators.distinctUntilChanged(), operators.switchMap(function (key) {
1955
+ if (!utils.notNullOrUndefined(key) || key.length === 0) {
1956
+ return rxjs.of(undefined);
1957
+ }
1958
+ return rxjs.from(utils.waitOnConditionAsync(function () { return _this._preferences.loaded; })).pipe(operators.switchMap(function () { return _this._columnsAlterationsManager.changes.pipe(operators.startWith(undefined), operators.tap(function () {
1959
+ _this._preferences.setAlterations(key, _this._columnsAlterationsManager.get());
1960
+ })); }));
1961
+ }), operators.takeUntil(this._ngUnsubscribe)).subscribe();
1962
+ var applyPrefs = function (cols) { return _this._columnsAlterationsManager.changes.pipe(operators.startWith(undefined), operators.map(function () {
1963
+ _this._columnsAlterationsManager.apply(cols, _this);
1964
+ return cols;
1965
+ })); };
1966
+ this._preferencesKey.pipe(operators.distinctUntilChanged(), operators.switchMap(function (prefsKey) {
1967
+ if (!utils.notNullOrUndefined(prefsKey)) {
1968
+ return rxjs.of(undefined);
1969
+ }
1970
+ return _this._preferences.preferences(prefsKey).pipe(operators.switchMap(function (preferences) { return __awaiter(_this, void 0, void 0, function () {
1971
+ var _this = this;
1972
+ return __generator(this, function (_h) {
1973
+ switch (_h.label) {
1974
+ case 0: return [4 /*yield*/, utils.waitOnConditionAsync(function () { return _this._preferences.loaded; })];
1975
+ case 1:
1976
+ _h.sent();
1977
+ return [2 /*return*/, preferences];
1978
+ }
1979
+ });
1980
+ }); }), operators.take(1), operators.map(function (preferences) {
1981
+ var alterations = [];
1982
+ try {
1983
+ alterations = mapColumnsAlterationsStates(preferences.alterations);
1984
+ }
1985
+ catch (e) {
1986
+ if (i0.isDevMode()) {
1987
+ console.warn('Unable to map columns alterations states');
1988
+ console.warn(e);
1989
+ }
1990
+ }
1991
+ _this._columnsAlterationsManager.add(alterations);
1992
+ }));
1993
+ }), operators.takeUntil(this._ngUnsubscribe)).subscribe();
1994
+ this.columns$ = this._columnsManager.columns$;
1995
+ this.displayColumns$ = this.columns$.pipe(operators.switchMap(function (cols) { return applyPrefs(cols); }), operators.map(function (cols) { return cols.filter(function (c) { return !c.hidden; }); }), operators.tap(function (v) { return removeUnusedDiffs(v, _this._colDiffersInp, _this._colDiffersTpl); }));
1087
1996
  this.filters$ = this._filtersSubject.asObservable();
1088
1997
  this.filterStates = this._filtersSubject.asObservable().pipe(operators.switchMap(function (filters) { return dataFilters.composeDataFilterStates(filters); }));
1089
- // this.rows$ = this._filtersSubject.asObservable()
1090
- // .pipe(
1091
- // switchMap(filters => {
1092
- // if (this.externalFiltering) {
1093
- // return this._rows.asObservable()
1094
- // }
1095
- // return this._rows.asObservable().pipe(composeDataFilters(filters))
1096
- // })
1097
- // )
1098
1998
  this.rows$ = this._dataSourceSubject.pipe(operators.switchMap(function (dataSource) {
1099
1999
  // console.log('dataSource', dataSource)
1100
2000
  var dataStream;
@@ -1130,20 +2030,6 @@
1130
2030
  // tap(v => console.log('stream', v)),
1131
2031
  operators.takeUntil(_this._ngUnsubscribe));
1132
2032
  }));
1133
- // this.hiddenColumns$ = this._hiddenColumns.asObservable()
1134
- // this._hiddenColumns.pipe(
1135
- // skip(1),
1136
- // distinctUntilChanged((a, b) => {
1137
- // const _a = Array.isArray(a) ? a : []
1138
- // const _b = Array.isArray(b) ? b : []
1139
- // if (_a.length !== _b.length) { return false }
1140
- // const _as = _a.sort()
1141
- // const _bs = _b.sort()
1142
- // return !_as.sort().every((value: string, index: number) => _bs[index] === value)
1143
- // }),
1144
- // tap(v => this.hiddenColumnsChange.emit(v)),
1145
- // untilDestroyed(this)
1146
- // ).subscribe(v => console.log('hiddenColumnsChange', v))
1147
2033
  // TODO: Implement viewChange for CollectionViewer.
1148
2034
  this.viewChange = this.page.pipe(operators.map(function (p) { return ({ start: 0, end: p.count }); }));
1149
2035
  }
@@ -1159,22 +2045,45 @@
1159
2045
  configurable: true
1160
2046
  });
1161
2047
  Object.defineProperty(DatatableComponent.prototype, "columns", {
1162
- get: function () { return this._columns.value; },
1163
2048
  set: function (value) {
1164
- // console.log('columns input', value)
1165
- this._columns.next(Array.isArray(value) ? value : []);
2049
+ this._columnsManager.setInputColumns(Array.isArray(value) ? value : []);
1166
2050
  },
1167
2051
  enumerable: false,
1168
2052
  configurable: true
1169
2053
  });
1170
2054
  Object.defineProperty(DatatableComponent.prototype, "rows", {
1171
2055
  get: function () { return this._rows.value; },
1172
- set: function (value) { this._rows.next(value || []); },
2056
+ set: function (value) {
2057
+ this._rows.next(value || []);
2058
+ },
2059
+ enumerable: false,
2060
+ configurable: true
2061
+ });
2062
+ Object.defineProperty(DatatableComponent.prototype, "selectionType", {
2063
+ get: function () { return this._columnsManager.getSelectionType(); },
2064
+ set: function (value) {
2065
+ this._columnsManager.setSelectionType(utils.notNullOrUndefined(value) ? value : undefined);
2066
+ },
2067
+ enumerable: false,
2068
+ configurable: true
2069
+ });
2070
+ Object.defineProperty(DatatableComponent.prototype, "sortType", {
2071
+ get: function () { return this._sortType; },
2072
+ set: function (value) {
2073
+ if (utils.notNullOrUndefined(value) && (value === ngxDatatable.SortType.single || value == ngxDatatable.SortType.multi)) {
2074
+ this._sortType = value;
2075
+ }
2076
+ else {
2077
+ this._sortType = ngxDatatable.SortType.single;
2078
+ }
2079
+ },
1173
2080
  enumerable: false,
1174
2081
  configurable: true
1175
2082
  });
1176
2083
  Object.defineProperty(DatatableComponent.prototype, "sorts", {
1177
- get: function () { return this.ngxDatatable ? this.ngxDatatable.sorts : this._sorts; },
2084
+ get: function () {
2085
+ return this.ngxDatatable ? this.ngxDatatable.sorts : this._sorts;
2086
+ },
1178
2087
  set: function (value) {
1179
2088
  this._sorts = utils.notNullOrUndefined(value) ? coercion.coerceArray(value) : [];
1180
2089
  },
@@ -1191,6 +2100,23 @@
1191
2100
  enumerable: false,
1192
2101
  configurable: true
1193
2102
  });
2103
+ Object.defineProperty(DatatableComponent.prototype, "columnComponents", {
2104
+ set: function (value) {
2105
+ var _a;
2106
+ this._columnsManager.setTemplateColumns(translateTemplateColumns((_a = value === null || value === void 0 ? void 0 : value.toArray()) !== null && _a !== void 0 ? _a : []));
2107
+ },
2108
+ enumerable: false,
2109
+ configurable: true
2110
+ });
2111
+ Object.defineProperty(DatatableComponent.prototype, "rowActionItem", {
2112
+ get: function () { return this._rowActionItem; },
2113
+ set: function (value) {
2114
+ this._rowActionItem = value;
2115
+ this._columnsManager.setRowActionItem(utils.notNullOrUndefined(value) ? value : undefined);
2116
+ },
2117
+ enumerable: false,
2118
+ configurable: true
2119
+ });
1194
2120
  Object.defineProperty(DatatableComponent.prototype, "menuBarComponent", {
1195
2121
  get: function () { return this._menuBarComponent; },
1196
2122
  set: function (value) {
@@ -1208,6 +2134,75 @@
1208
2134
  enumerable: false,
1209
2135
  configurable: true
1210
2136
  });
2137
+ Object.defineProperty(DatatableComponent.prototype, "actionMenuCellTpl", {
2138
+ get: function () { return this._actionMenuCellTpl; },
2139
+ set: function (value) {
2140
+ this._actionMenuCellTpl = value;
2141
+ this._columnsManager.setActionMenuCellTpl(utils.notNullOrUndefined(value) ? value : undefined);
2142
+ },
2143
+ enumerable: false,
2144
+ configurable: true
2145
+ });
2146
+ Object.defineProperty(DatatableComponent.prototype, "treeToggleTpl", {
2147
+ get: function () { return this._treeToggleTpl; },
2148
+ set: function (value) {
2149
+ this._treeToggleTpl = value;
2150
+ this._columnsManager.setTreeToggleTpl(utils.notNullOrUndefined(value) ? value : undefined);
2151
+ },
2152
+ enumerable: false,
2153
+ configurable: true
2154
+ });
2155
+ Object.defineProperty(DatatableComponent.prototype, "headerTpl", {
2156
+ get: function () { return this._headerTpl; },
2157
+ set: function (value) {
2158
+ this._headerTpl = value;
2159
+ this._columnsManager.setHeaderTpl(utils.notNullOrUndefined(value) ? value : undefined);
2160
+ },
2161
+ enumerable: false,
2162
+ configurable: true
2163
+ });
2164
+ Object.defineProperty(DatatableComponent.prototype, "blankHeaderTpl", {
2165
+ get: function () { return this._blankHeaderTpl; },
2166
+ set: function (value) {
2167
+ this._blankHeaderTpl = value;
2168
+ this._columnsManager.setBlankHeaderTpl(utils.notNullOrUndefined(value) ? value : undefined);
2169
+ },
2170
+ enumerable: false,
2171
+ configurable: true
2172
+ });
2173
+ Object.defineProperty(DatatableComponent.prototype, "cellTypeSelectorTpl", {
2174
+ get: function () { return this._cellTypeSelectorTpl; },
2175
+ set: function (value) {
2176
+ this._cellTypeSelectorTpl = value;
2177
+ this._columnsManager.setCellTypeSelectorTpl(utils.notNullOrUndefined(value) ? value : undefined);
2178
+ },
2179
+ enumerable: false,
2180
+ configurable: true
2181
+ });
2182
+ // TODO: Remove this DOM-dependent code when a way to property listen for
2183
+ // dblclick on the header reasize handles.
2184
+ DatatableComponent.prototype._dblClick = function (event) {
2185
+ var _this = this;
2186
+ var _a, _b, _c;
2187
+ var isHandle = event.target.classList.contains('resize-handle');
2188
+ if (isHandle) {
2189
+ var isResizeable = (_a = event.target.parentElement) === null || _a === void 0 ? void 0 : _a.classList.contains('resizeable');
2190
+ if (isResizeable) {
2191
+ event.stopPropagation();
2192
+ var id_1 = (_c = (_b = event.target.parentElement) === null || _b === void 0 ? void 0 : _b.querySelector('.datatable-column-header-separator')) === null || _c === void 0 ? void 0 : _c.getAttribute('data-column-id');
2193
+ this._columnsManager.columns$.pipe(operators.take(1)).subscribe(function (columns) {
2194
+ var column = columns.find(function (c) { return c.$$id === id_1; });
2195
+ if (column) {
2196
+ var columnProp = getColumnProp(column);
2197
+ if (columnProp) {
2198
+ var alteration = new WidthColumnsAlteration({ columnProp: columnProp, canAutoResize: true }, false);
2199
+ _this._columnsAlterationsManager.add([alteration]);
2200
+ }
2201
+ }
2202
+ });
2203
+ }
2204
+ }
2205
+ };
1211
2206
  DatatableComponent.prototype.ngOnInit = function () {
1212
2207
  var _this = this;
1213
2208
  if (this.rowDetail) {
@@ -1221,160 +2216,7 @@
1221
2216
  DatatableComponent.prototype.ngOnDestroy = function () {
1222
2217
  this._rowDetailToggleSubscription.unsubscribe();
1223
2218
  };
1224
- DatatableComponent.prototype.ngAfterContentInit = function () {
1225
- var _this = this;
1226
- var _a, _b;
1227
- this.columnComponents$ = this._columnChangesService.columnInputChanges$.pipe(operators.map(function () { var _a, _b; return (_b = (_a = _this.columnComponents) === null || _a === void 0 ? void 0 : _a.toArray()) !== null && _b !== void 0 ? _b : []; }), operators.startWith((_b = (_a = this.columnComponents) === null || _a === void 0 ? void 0 : _a.toArray()) !== null && _b !== void 0 ? _b : []), operators.shareReplay({ bufferSize: 1, refCount: true }));
1228
- var _columns = rxjs.combineLatest([
1229
- this.columnComponents$,
1230
- this._columns
1231
- ]).pipe(operators.map(function (v) { var _a; return _this._getMergedTplAndInpColumns(v[0], (_a = v[1]) !== null && _a !== void 0 ? _a : []); }),
1232
- // tap(v => console.log('cols', v)),
1233
- operators.shareReplay({ bufferSize: 1, refCount: true }));
1234
- this._columnsObservable.next(_columns);
1235
- };
1236
- DatatableComponent.prototype._getMergedTplAndInpColumns = function (tplCols, inpCols) {
1237
- var e_2, _h, e_3, _j;
1238
- var cols = [];
1239
- if (this.selectionType === 'checkbox') {
1240
- var checkBoxCol = {
1241
- prop: '$$__checkbox__',
1242
- name: '',
1243
- width: 40,
1244
- sortable: false,
1245
- canAutoResize: false,
1246
- draggable: false,
1247
- resizeable: false,
1248
- headerCheckboxable: true,
1249
- checkboxable: true
1250
- };
1251
- cols.push(checkBoxCol);
1252
- }
1253
- var _tplCols = ngxDatatable.translateTemplates((tplCols || []));
1254
- var _loop_1 = function (col) {
1255
- var tplCol = _tplCols.find(function (t) { return t.prop === col.prop; });
1256
- // console.log({ col: { ...(col || {}) }, tplCol: { ...(tplCol || {}) } })
1257
- var dtColumns = (this_1.ngxDatatable && this_1.ngxDatatable._internalColumns) || [];
1258
- var prev = dtColumns.find(function (c) { return c.prop === col.prop; });
1259
- var inpColDiff = this_1._getColDiff(col);
1260
- var _inpCol = inpColDiff ? {} : this_1._hasPrevColDiff(col) ? {} : col;
1261
- if (inpColDiff) {
1262
- inpColDiff.forEachRemovedItem(function (r) {
1263
- if (prev && prev.hasOwnProperty(r.key)) {
1264
- var k = r.key;
1265
- delete prev[k];
1266
- }
1267
- });
1268
- inpColDiff.forEachAddedItem(function (r) { return _inpCol[r.key] = r.currentValue; });
1269
- inpColDiff.forEachChangedItem(function (r) { return _inpCol[r.key] = r.currentValue; });
1270
- }
1271
- var _tplCol = {};
1272
- if (tplCol) {
1273
- var tplColDiff = tplCol ? this_1._getColDiff(tplCol, true) : undefined;
1274
- _tplCol = tplColDiff ? {} : this_1._hasPrevColDiff(col, true) ? {} : tplCol;
1275
- if (tplColDiff) {
1276
- tplColDiff.forEachRemovedItem(function (r) {
1277
- if (prev && prev.hasOwnProperty(r.key)) {
1278
- var k = r.key;
1279
- delete prev[k];
1280
- }
1281
- });
1282
- tplColDiff.forEachAddedItem(function (r) { return _tplCol[r.key] = r.currentValue; });
1283
- tplColDiff.forEachChangedItem(function (r) { return _tplCol[r.key] = r.currentValue; });
1284
- }
1285
- }
1286
- var _col = Object.assign(Object.assign(Object.assign({}, (prev || {})), _inpCol), _tplCol);
1287
- cols.push(_col);
1288
- };
1289
- var this_1 = this;
1290
- try {
1291
- for (var inpCols_1 = __values(inpCols), inpCols_1_1 = inpCols_1.next(); !inpCols_1_1.done; inpCols_1_1 = inpCols_1.next()) {
1292
- var col = inpCols_1_1.value;
1293
- _loop_1(col);
1294
- }
1295
- }
1296
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1297
- finally {
1298
- try {
1299
- if (inpCols_1_1 && !inpCols_1_1.done && (_h = inpCols_1.return)) _h.call(inpCols_1);
1300
- }
1301
- finally { if (e_2) throw e_2.error; }
1302
- }
1303
- if (this.rowActionItem) {
1304
- var actionMenuColumn = {
1305
- prop: '$$__actionMenu__',
1306
- name: '',
1307
- width: 50,
1308
- minWidth: 50,
1309
- maxWidth: 50,
1310
- resizeable: false,
1311
- sortable: false,
1312
- draggable: false,
1313
- // TODO: Fix column auto sizing with fixed column and cell overlay before enabling.
1314
- // frozenRight: true,
1315
- cellTemplate: this.actionMenuCellTpl,
1316
- headerTemplate: this.blankHeaderTpl
1317
- };
1318
- cols.push(actionMenuColumn);
1319
- }
1320
- try {
1321
- for (var cols_1 = __values(cols), cols_1_1 = cols_1.next(); !cols_1_1.done; cols_1_1 = cols_1.next()) {
1322
- var col = cols_1_1.value;
1323
- if (col.isTreeColumn && utils.hasProperty(col, 'treeToggleTemplate')) {
1324
- col.treeToggleTemplate = this.treeToggleTpl;
1325
- }
1326
- if (!utils.hasProperty(col, 'headerTemplate')) {
1327
- col.headerTemplate = this.headerTpl;
1328
- }
1329
- if (utils.hasProperty(col, 'cellType')) {
1330
- col.cellTemplate = this.cellTypeSelectorTpl;
1331
- }
1332
- }
1333
- }
1334
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1335
- finally {
1336
- try {
1337
- if (cols_1_1 && !cols_1_1.done && (_j = cols_1.return)) _j.call(cols_1);
1338
- }
1339
- finally { if (e_3) throw e_3.error; }
1340
- }
1341
- // setColumnDefaults(cols)
1342
- _setColumnDefaults(cols);
1343
- // console.log(cols.map(c => ({ prop: c.prop, canAutoResize: c.canAutoResize })))
1344
- return cols;
1345
- };
1346
- DatatableComponent.prototype._hasPrevColDiff = function (col, isTpl) {
1347
- if (isTpl === void 0) { isTpl = false; }
1348
- if (!col || !col.prop) {
1349
- return false;
1350
- }
1351
- var differsMap = isTpl ? this._colDiffersTpl : this._colDiffersInp;
1352
- return !!differsMap;
1353
- };
1354
- DatatableComponent.prototype._getColDiff = function (col, isTpl) {
1355
- if (isTpl === void 0) { isTpl = false; }
1356
- if (!col || !col.prop) {
1357
- return;
1358
- }
1359
- var differsMap = isTpl ? this._colDiffersTpl : this._colDiffersInp;
1360
- if (!differsMap[col.prop]) {
1361
- differsMap[col.prop] = this._differs.find({}).create();
1362
- }
1363
- var differ = differsMap[col.prop];
1364
- var diff = differ.diff(col);
1365
- return diff;
1366
- };
1367
- DatatableComponent.prototype._removeUnusedDiffs = function (cols) {
1368
- var _this = this;
1369
- var inpKeys = Object.keys(this._colDiffersInp);
1370
- inpKeys.filter(function (k) { return cols.findIndex(function (c) { return c.prop === k; }) === -1; })
1371
- .forEach(function (k) { delete _this._colDiffersInp[k]; });
1372
- var tplKeys = Object.keys(this._colDiffersTpl);
1373
- tplKeys.filter(function (k) { return cols.findIndex(function (c) { return c.prop === k; }) === -1; })
1374
- .forEach(function (k) { delete _this._colDiffersTpl[k]; });
1375
- };
1376
2219
  DatatableComponent.prototype._setMenuBarFilters = function (filters) {
1377
- // console.log('_setMenuBarFilters', filters)
1378
2220
  this._filtersSubject.next(filters || []);
1379
2221
  };
1380
2222
  DatatableComponent.prototype.getColumnComponent = function (propName) {
@@ -1408,21 +2250,50 @@
1408
2250
  }
1409
2251
  };
1410
2252
  DatatableComponent.prototype._onResize = function (event) {
1411
- // console.log('resize', event, event.column.prop)
1412
2253
  this.resize.emit(event);
1413
- if (event.isDone && this.columns) {
1414
- var columns = this.columns;
1415
- var col = columns.find(function (c) { return c.prop === event.column.prop; });
1416
- if (col) {
1417
- col.canAutoResize = false;
2254
+ if (!utils.notNullOrUndefined(event.column)) {
2255
+ return;
2256
+ }
2257
+ var columnProp = getColumnProp(event.column);
2258
+ if (columnProp) {
2259
+ var addAlteration = false;
2260
+ if (!this._resizing[columnProp]) {
2261
+ this._resizing[columnProp] = true;
2262
+ addAlteration = true;
1418
2263
  }
1419
- if (this.preferencesKey) {
1420
- var pref = { prop: event.column.prop, width: event.column.width, canAutoResize: false };
1421
- this._preferences.setColumnPreference(this.preferencesKey, pref);
2264
+ if (event.isDone) {
2265
+ this._resizing[columnProp] = false;
2266
+ addAlteration = true;
1422
2267
  }
1423
- this.columns = __spreadArray([], __read(this.columns));
2268
+ if (addAlteration) {
2269
+ var alteration = new WidthColumnsAlteration({
2270
+ columnProp: columnProp,
2271
+ width: event.column.width,
2272
+ canAutoResize: false
2273
+ }, true);
2274
+ this._columnsAlterationsManager.add([alteration]);
2275
+ }
2276
+ }
2277
+ };
2278
+ DatatableComponent.prototype._onReorder = function (event) {
2279
+ this.reorder.emit(event);
2280
+ var columnProp = getColumnProp(event.column);
2281
+ if (columnProp) {
2282
+ var currentOrderAlteration = this._columnsAlterationsManager.get().find(function (x) { return x.type === 'order'; });
2283
+ var state = {
2284
+ columns: __spreadArray(__spreadArray([], __read(((currentOrderAlteration === null || currentOrderAlteration === void 0 ? void 0 : currentOrderAlteration.state.columns) || []))), [
2285
+ { columnProp: columnProp, index: event.newValue }
2286
+ ])
2287
+ };
2288
+ var alteration = new OrderColumnsAlteration(state, true);
2289
+ this._columnsAlterationsManager.add([alteration]);
1424
2290
  }
1425
2291
  };
2292
+ DatatableComponent.prototype._onSort = function (event) {
2293
+ this.sort.emit(event);
2294
+ var alteration = new SortColumnsAlteration({ sorts: event.sorts }, true);
2295
+ this._columnsAlterationsManager.add([alteration]);
2296
+ };
1426
2297
  DatatableComponent.prototype._onTreeAction = function (event) {
1427
2298
  var index = event.rowIndex;
1428
2299
  var row = event.row;
@@ -1438,6 +2309,9 @@
1438
2309
  this.actionRefreshRequest.emit(undefined);
1439
2310
  };
1440
2311
  Object.defineProperty(DatatableComponent.prototype, "pageInfo", {
2312
+ /**
2313
+ * Returns the page info from the wrapped NgxDatatable instance or defaults.
2314
+ */
1441
2315
  get: function () {
1442
2316
  var _a, _b, _c, _d, _e, _f, _g;
1443
2317
  return {
@@ -1455,7 +2329,7 @@
1455
2329
  DatatableComponent.decorators = [
1456
2330
  { type: i0.Component, args: [{
1457
2331
  selector: 'seam-datatable',
1458
- template: "<div class=\"datatable-wrapper\">\n <ng-content select=\"seam-datatable-menu-bar\"></ng-content>\n <div class=\"datatable-table-wrapper\">\n <ng-container>\n <ngx-datatable\n class=\"bootstrap\"\n [columnMode]=\"$any(columnMode)\"\n [scrollbarV]=\"scrollbarV\"\n [scrollbarH]=\"scrollbarH\"\n [virtualization]=\"virtualization\"\n [targetMarkerTemplate]=\"targetMarkerTemplate\"\n [groupRowsBy]=\"$any(groupRowsBy)\"\n [groupedRows]=\"$any(groupedRows)\"\n [selected]=\"$any(selected)\"\n [externalPaging]=\"externalPaging\"\n [externalSorting]=\"externalSorting\"\n [limit]=\"$any(limit)\"\n [count]=\"$any(count)\"\n [offset]=\"$any(offset)\"\n [loadingIndicator]=\"loadingIndicator\"\n [selectionType]=\"$any(selectionType)\"\n [reorderable]=\"reorderable\"\n [swapColumns]=\"swapColumns\"\n [sortType]=\"$any(sortType)\"\n [sorts]=\"$any(_sorts)\"\n [cssClasses]=\"cssClasses\"\n [messages]=\"messages\"\n [rowIdentity]=\"$any(rowIdentity)\"\n [rowClass]=\"rowClass\"\n [selectCheck]=\"selectCheck\"\n [displayCheck]=\"$any(displayCheck)\"\n [groupExpansionDefault]=\"groupExpansionDefault\"\n [trackByProp]=\"$any(trackByProp)\"\n [selectAllRowsOnPage]=\"selectAllRowsOnPage\"\n [treeFromRelation]=\"$any(treeFromRelation)\"\n [treeToRelation]=\"$any(treeToRelation)\"\n [summaryRow]=\"summaryRow\"\n [summaryHeight]=\"$any(summaryHeight)\"\n [summaryPosition]=\"$any(summaryPosition)\"\n [rows]=\"rows$ | async\"\n [columns]=\"$any(displayColumns$ | async)\"\n [headerHeight]=\"$any(headerHeight)\"\n [rowHeight]=\"$any(rowHeight)\"\n [footerHeight]=\"$any(footerHeight)\"\n (scroll)=\"scroll.emit($event)\"\n (activate)=\"activate.emit($event)\"\n (select)=\"select.emit($event)\"\n (sort)=\"sort.emit($event)\"\n (page)=\"page.emit($event)\"\n (reorder)=\"reorder.emit($event)\"\n (resize)=\"_onResize($event)\"\n (tableContextmenu)=\"tableContextmenu.emit($event)\"\n (treeAction)=\"treeAction.emit($event)\"\n (seamElemResized)=\"onDatatableResize($event)\"\n (treeAction)=\"_onTreeAction($event)\">\n\n <ngx-datatable-group-header [rowHeight]=\"50\" #myGroupHeader *ngIf=\"groupRowsBy\">\n <ng-template let-group=\"group\" let-expanded=\"expanded\" ngx-datatable-group-header-template>\n <div\n class=\"w-100 bg-light p-1\"\n [class.border-bottom]=\"!expanded\"\n [class.datatable-icon-right]=\"!expanded\"\n [class.datatable-icon-down]=\"expanded\"\n title=\"Expand/Collapse Group\"\n (click)=\"ngxDatatable?.groupHeader?.toggleExpandGroup(group)\">\n <b>Age: {{ group.age }}</b>\n </div>\n </ng-template>\n </ngx-datatable-group-header>\n\n <ngx-datatable-row-detail *ngIf=\"rowDetail && rowDetail.template\"\n [rowHeight]=\"rowDetail.rowHeight || 0\"\n [template]=\"$any(rowDetail.template)\"\n (toggle)=\"rowDetail.toggle.emit($event)\">\n </ngx-datatable-row-detail>\n\n </ngx-datatable>\n </ng-container>\n </div>\n</div>\n\n<ng-template #blankHeaderTpl ngx-datatable-header-template></ng-template>\n\n<ng-template #headerTpl ngx-datatable-header-template\n let-column=\"column\" let-sortFn=\"sortFn\">\n <strong *ngIf=\"!column.sortable\" class=\"draggable\">{{column.name}}</strong>\n <strong *ngIf=\"column.sortable\" class=\"datatable-sort-target draggable\" (click)=\"sortFn()\">{{column.name}}</strong>\n <div class=\"datatable-column-header-separator\"></div>\n</ng-template>\n\n<ng-template #cellTypeSelectorTpl ngx-datatable-cell-template\n let-value=\"value\" let-rowIndex=\"rowIndex\" let-row=\"row\" let-column=\"column\">\n <seam-table-cell-type-selector *ngIf=\"row\"\n [type]=\"column.cellType\"\n [value]=\"value\"\n [rowIndex]=\"rowIndex\"\n [row]=\"row\"\n [colData]=\"column\">\n </seam-table-cell-type-selector>\n</ng-template>\n\n<ng-template #actionMenuCellTpl ngx-datatable-cell-template\n let-value=\"value\" let-rowIndex=\"rowIndex\" let-row=\"row\">\n\n <ng-container *ngIf=\"row && rowActionItem?.template\">\n <ng-template\n [ngTemplateOutlet]=\"$any(rowActionItem?.template)\"\n [ngTemplateOutletContext]=\"{ $implicit: row, row: row, rowIndex: rowIndex }\">\n </ng-template>\n </ng-container>\n\n</ng-template>\n\n<ng-template #treeToggleTpl ngx-datatable-tree-toggle let-tree=\"cellContext\">\n <button\n class=\"p-0 bg-transparent border-0 btn\"\n [disabled]=\"tree.treeStatus==='disabled'\"\n (click)=\"tree.onTreeAction()\">\n <span *ngIf=\"tree.treeStatus==='loading'\">\n <fa-icon [icon]=\"faSpinner\"></fa-icon>\n </span>\n <span *ngIf=\"tree.treeStatus==='collapsed'\">\n <fa-icon [icon]=\"faChevronRight\"></fa-icon>\n </span>\n <span *ngIf=\"tree.treeStatus==='expanded'\">\n <fa-icon [icon]=\"faChevronDown\"></fa-icon>\n </span>\n <span *ngIf=\"tree.treeStatus==='disabled'\">\n <fa-icon [icon]=\"faChevronRight\"></fa-icon>\n </span>\n </button>\n</ng-template>\n",
2332
+ template: "<div class=\"datatable-wrapper\">\n <ng-content select=\"seam-datatable-menu-bar\"></ng-content>\n <div class=\"datatable-table-wrapper\">\n <ng-container>\n <ngx-datatable\n [columnMode]=\"$any(columnMode)\"\n [scrollbarV]=\"scrollbarV\"\n [scrollbarH]=\"scrollbarH\"\n [virtualization]=\"virtualization\"\n [targetMarkerTemplate]=\"targetMarkerTemplate\"\n [groupRowsBy]=\"$any(groupRowsBy)\"\n [groupedRows]=\"$any(groupedRows)\"\n [selected]=\"$any(selected)\"\n [externalPaging]=\"externalPaging\"\n [externalSorting]=\"externalSorting\"\n [limit]=\"$any(limit)\"\n [count]=\"$any(count)\"\n [offset]=\"$any(offset)\"\n [loadingIndicator]=\"loadingIndicator\"\n [selectionType]=\"$any(selectionType)\"\n [reorderable]=\"reorderable\"\n [swapColumns]=\"swapColumns\"\n [sortType]=\"$any(sortType)\"\n [sorts]=\"$any(_sorts)\"\n [cssClasses]=\"cssClasses\"\n [messages]=\"messages\"\n [rowIdentity]=\"$any(rowIdentity)\"\n [rowClass]=\"rowClass\"\n [selectCheck]=\"selectCheck\"\n [displayCheck]=\"$any(displayCheck)\"\n [groupExpansionDefault]=\"groupExpansionDefault\"\n [trackByProp]=\"$any(trackByProp)\"\n [selectAllRowsOnPage]=\"selectAllRowsOnPage\"\n [treeFromRelation]=\"$any(treeFromRelation)\"\n [treeToRelation]=\"$any(treeToRelation)\"\n [summaryRow]=\"summaryRow\"\n [summaryHeight]=\"$any(summaryHeight)\"\n [summaryPosition]=\"$any(summaryPosition)\"\n [rows]=\"rows$ | async\"\n [columns]=\"$any(displayColumns$ | async)\"\n [headerHeight]=\"$any(headerHeight)\"\n [rowHeight]=\"$any(rowHeight)\"\n [footerHeight]=\"$any(footerHeight)\"\n (scroll)=\"scroll.emit($event)\"\n (activate)=\"activate.emit($event)\"\n (select)=\"select.emit($event)\"\n (sort)=\"_onSort($event)\"\n (page)=\"page.emit($event)\"\n (reorder)=\"_onReorder($event)\"\n (resize)=\"_onResize($event)\"\n (tableContextmenu)=\"tableContextmenu.emit($event)\"\n (treeAction)=\"treeAction.emit($event)\"\n (seamElemResized)=\"onDatatableResize($event)\"\n (treeAction)=\"_onTreeAction($event)\">\n\n <ngx-datatable-group-header [rowHeight]=\"50\" #myGroupHeader *ngIf=\"groupRowsBy\">\n <ng-template let-group=\"group\" let-expanded=\"expanded\" ngx-datatable-group-header-template>\n <div\n class=\"w-100 bg-light p-1\"\n [class.border-bottom]=\"!expanded\"\n [class.datatable-icon-right]=\"!expanded\"\n [class.datatable-icon-down]=\"expanded\"\n title=\"Expand/Collapse Group\"\n (click)=\"ngxDatatable?.groupHeader?.toggleExpandGroup(group)\">\n <b>Age: {{ group.age }}</b>\n </div>\n </ng-template>\n </ngx-datatable-group-header>\n\n <ngx-datatable-row-detail *ngIf=\"rowDetail && rowDetail.template\"\n [rowHeight]=\"rowDetail.rowHeight || 0\"\n [template]=\"$any(rowDetail.template)\"\n (toggle)=\"rowDetail.toggle.emit($event)\">\n </ngx-datatable-row-detail>\n\n <ngx-datatable-footer *ngIf=\"footer && footer.template\"\n [template]=\"$any(footer.template)\">\n </ngx-datatable-footer>\n </ngx-datatable>\n </ng-container>\n </div>\n</div>\n\n<ng-template #blankHeaderTpl ngx-datatable-header-template></ng-template>\n\n<ng-template #headerTpl ngx-datatable-header-template\n let-column=\"column\" let-sortFn=\"sortFn\">\n <strong *ngIf=\"!column.sortable\" class=\"draggable\">{{column.name}}</strong>\n <strong *ngIf=\"column.sortable\" class=\"datatable-sort-target draggable\" (click)=\"sortFn()\">{{column.name}}</strong>\n <div class=\"datatable-column-header-separator\" [attr.data-column-id]=\"column.$$id\"></div>\n</ng-template>\n\n<ng-template #cellTypeSelectorTpl ngx-datatable-cell-template\n let-value=\"value\" let-rowIndex=\"rowIndex\" let-row=\"row\" let-column=\"column\">\n <seam-table-cell-type-selector *ngIf=\"row\"\n [type]=\"column.cellType\"\n [value]=\"value\"\n [rowIndex]=\"rowIndex\"\n [row]=\"row\"\n [colData]=\"column\">\n </seam-table-cell-type-selector>\n</ng-template>\n\n<ng-template #actionMenuCellTpl ngx-datatable-cell-template\n let-value=\"value\" let-rowIndex=\"rowIndex\" let-row=\"row\">\n\n <ng-container *ngIf=\"row && rowActionItem?.template\">\n <ng-template\n [ngTemplateOutlet]=\"$any(rowActionItem?.template)\"\n [ngTemplateOutletContext]=\"{ $implicit: row, row: row, rowIndex: rowIndex }\">\n </ng-template>\n </ng-container>\n\n</ng-template>\n\n<ng-template #treeToggleTpl ngx-datatable-tree-toggle let-tree=\"cellContext\">\n <button\n class=\"p-0 bg-transparent border-0 btn\"\n [disabled]=\"tree.treeStatus==='disabled'\"\n (click)=\"tree.onTreeAction()\">\n <span *ngIf=\"tree.treeStatus==='loading'\">\n <fa-icon [icon]=\"_faSpinner\"></fa-icon>\n </span>\n <span *ngIf=\"tree.treeStatus==='collapsed'\">\n <fa-icon [icon]=\"_faChevronRight\"></fa-icon>\n </span>\n <span *ngIf=\"tree.treeStatus==='expanded'\">\n <fa-icon [icon]=\"_faChevronDown\"></fa-icon>\n </span>\n <span *ngIf=\"tree.treeStatus==='disabled'\">\n <fa-icon [icon]=\"_faChevronRight\"></fa-icon>\n </span>\n </button>\n</ng-template>\n",
1459
2333
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1460
2334
  animations: [
1461
2335
  animations.trigger('slideDown', [
@@ -1469,14 +2343,20 @@
1469
2343
  ])
1470
2344
  ])
1471
2345
  ],
1472
- providers: [_THESEAM_DATATABLE, DatatableColumnChangesService, _THESEAM_DATATABLE_ACCESSOR],
1473
- styles: [":host{display:flex;flex-grow:1;flex-direction:column}::ng-deep .seam-datatable-action-menu{min-width:auto!important}ngx-datatable{position:absolute;top:0;left:0;right:0;bottom:0}.datatable-wrapper{display:flex;flex-direction:column;flex-grow:1}.datatable-wrapper .datatable-table-wrapper{position:relative;flex:1 1 100%}.datatable-column-header-separator{position:absolute;top:12px;bottom:12px;right:0;width:2px;background-color:#e1e3e6}.datatable-sort-target{cursor:pointer}"]
2346
+ providers: [
2347
+ _THESEAM_DATATABLE,
2348
+ DatatableColumnChangesService,
2349
+ _THESEAM_DATATABLE_ACCESSOR,
2350
+ ColumnsManagerService,
2351
+ ColumnsAlterationsManagerService,
2352
+ ],
2353
+ styles: [":host{display:flex;flex-grow:1;flex-direction:column}::ng-deep .seam-datatable-action-menu{min-width:auto!important}ngx-datatable{position:absolute!important;top:0;left:0;right:0;bottom:0}.datatable-wrapper{display:flex;flex-direction:column;flex-grow:1}.datatable-wrapper .datatable-table-wrapper{position:relative;flex:1 1 100%}.datatable-column-header-separator{position:absolute}.datatable-sort-target{cursor:pointer}\n"]
1474
2354
  },] }
1475
2355
  ];
1476
2356
  DatatableComponent.ctorParameters = function () { return [
1477
- { type: DatatableColumnChangesService },
1478
- { type: i0.KeyValueDiffers },
1479
- { type: DatatablePreferencesService }
2357
+ { type: DatatablePreferencesService },
2358
+ { type: ColumnsManagerService },
2359
+ { type: ColumnsAlterationsManagerService }
1480
2360
  ]; };
1481
2361
  DatatableComponent.propDecorators = {
1482
2362
  preferencesKey: [{ type: i0.Input }],
@@ -1535,6 +2415,7 @@
1535
2415
  actionMenu: [{ type: i0.ContentChild, args: [DatatableActionMenuComponent, { static: true },] }],
1536
2416
  rowActionItem: [{ type: i0.ContentChild, args: [DatatableRowActionItemDirective, { static: true },] }],
1537
2417
  rowDetail: [{ type: i0.ContentChild, args: [TheSeamDatatableRowDetailDirective, { static: true },] }],
2418
+ footer: [{ type: i0.ContentChild, args: [TheSeamDatatableFooterDirective, { static: true },] }],
1538
2419
  menuBarComponent: [{ type: i0.ContentChild, args: [DatatableMenuBarComponent,] }],
1539
2420
  ngxDatatable: [{ type: i0.ViewChild, args: [ngxDatatable.DatatableComponent,] }],
1540
2421
  ngxDatatableElement: [{ type: i0.ViewChild, args: [ngxDatatable.DatatableComponent, { read: i0.ElementRef },] }],
@@ -1543,7 +2424,8 @@
1543
2424
  treeToggleTpl: [{ type: i0.ViewChild, args: ['treeToggleTpl', { static: true },] }],
1544
2425
  headerTpl: [{ type: i0.ViewChild, args: ['headerTpl', { static: true },] }],
1545
2426
  blankHeaderTpl: [{ type: i0.ViewChild, args: ['blankHeaderTpl', { static: true },] }],
1546
- cellTypeSelectorTpl: [{ type: i0.ViewChild, args: ['cellTypeSelectorTpl', { static: true },] }]
2427
+ cellTypeSelectorTpl: [{ type: i0.ViewChild, args: ['cellTypeSelectorTpl', { static: true },] }],
2428
+ _dblClick: [{ type: i0.HostListener, args: ['dblclick', ['$event'],] }]
1547
2429
  };
1548
2430
  __decorate([
1549
2431
  core.InputBoolean()
@@ -1604,63 +2486,117 @@
1604
2486
  ], DatatableComponent.prototype, "scrollbarH", void 0);
1605
2487
 
1606
2488
  var DatatableColumnPreferencesComponent = /** @class */ (function () {
1607
- function DatatableColumnPreferencesComponent(_datatable) {
2489
+ function DatatableColumnPreferencesComponent(_datatable, _columnsAlterationsManager) {
2490
+ var _this = this;
1608
2491
  var _a;
1609
2492
  this._datatable = _datatable;
2493
+ this._columnsAlterationsManager = _columnsAlterationsManager;
1610
2494
  this._filterControl = new forms.FormControl();
2495
+ this._alphabeticalColumnCompareFn = function (a, b) {
2496
+ var aProp = getColumnProp(a);
2497
+ var bProp = getColumnProp(b);
2498
+ return aProp === bProp ? 0 : aProp > bProp ? 1 : -1;
2499
+ };
1611
2500
  this._columns$ = rxjs.combineLatest([
1612
2501
  (_a = this._datatable.columns$) !== null && _a !== void 0 ? _a : rxjs.of([]),
1613
2502
  utils.observeControlValue(this._filterControl)
1614
2503
  ]).pipe(operators.map(function (_b) {
1615
2504
  var _c = __read(_b, 2), columns = _c[0], filter = _c[1];
1616
2505
  var _filter = (filter || '').trim().toLowerCase();
1617
- return columns.filter(function (c) { return ("" + (c.name || c.prop || '')).toLowerCase().indexOf(_filter) !== -1; });
1618
- }), operators.map(function (cols) { return cols.sort(function (a, b) { return a.prop === b.prop ? 0 : a.prop > b.prop ? 1 : -1; }); }));
2506
+ return columns
2507
+ .filter(function (c) { return _this._canToggleColumn(c, _filter); })
2508
+ .sort(_this._alphabeticalColumnCompareFn);
2509
+ }));
1619
2510
  }
1620
- DatatableColumnPreferencesComponent.prototype.ngOnInit = function () { };
1621
- DatatableColumnPreferencesComponent.prototype._onChange = function (event, col) {
1622
- // TODO: Figure out the right way to update this value. If it is set by
1623
- // column component input this may not work right.
1624
- var columns = this._datatable.columns || [];
1625
- var column = columns.find(function (c) { return c.prop === col.prop; });
1626
- if (column) {
1627
- column.hidden = !event.checked;
1628
- this._datatable.columns = __spreadArray([], __read(columns));
2511
+ DatatableColumnPreferencesComponent.prototype._canToggleColumn = function (column, filter, omitInternalColumns) {
2512
+ if (omitInternalColumns === void 0) { omitInternalColumns = true; }
2513
+ if (omitInternalColumns && isInternalColumn(column)) {
2514
+ return false;
2515
+ }
2516
+ return this._columnMatchesFilter(column, filter);
2517
+ };
2518
+ DatatableColumnPreferencesComponent.prototype._columnMatchesFilter = function (column, filter) {
2519
+ if (filter.length === 0) {
2520
+ return true;
1629
2521
  }
2522
+ return ("" + (getColumnProp(column) || '')).toLowerCase().indexOf(filter) !== -1;
1630
2523
  };
1631
- DatatableColumnPreferencesComponent.prototype._onCloseClick = function () {
1632
- // TODO: Implement when PopoverRef is implemented.
2524
+ DatatableColumnPreferencesComponent.prototype._onChange = function (event, col) {
2525
+ var columnProp = getColumnProp(col);
2526
+ var hidden = !event.checked;
2527
+ if (!utils.notNullOrUndefined(columnProp)) {
2528
+ throw Error("Unable to get column prop.");
2529
+ }
2530
+ var alteration = new HideColumnColumnsAlteration({
2531
+ columnProp: columnProp,
2532
+ hidden: hidden
2533
+ }, hidden);
2534
+ this._columnsAlterationsManager.add([alteration]);
1633
2535
  };
1634
2536
  return DatatableColumnPreferencesComponent;
1635
2537
  }());
1636
2538
  DatatableColumnPreferencesComponent.decorators = [
1637
2539
  { type: i0.Component, args: [{
1638
2540
  selector: 'seam-datatable-column-preferences',
1639
- template: "<h3>Columns</h3>\n\n<seam-form-field [numPaddingErrors]=\"0\" >\n <input seamInput [formControl]=\"_filterControl\" seamInputSize=\"sm\" placeholder=\"Search\">\n</seam-form-field>\n\n<div seamOverlayScrollbar style=\"min-height: 200px; max-height: 600px; min-width: 250px;\" class=\"flex-grow-1 mb-2\">\n <div class=\"p-2\">\n <ng-container *ngFor=\"let col of _columns$ | async\">\n <seam-checkbox [checked]=\"!col.hidden\" (change)=\"_onChange($event, col)\">{{ col.name || col.prop }}</seam-checkbox>\n </ng-container>\n </div>\n\n</div>\n<div class=\"d-flex flex-row justify-content-end\">\n <!-- <button seamButton size=\"sm\" theme=\"lightgray\" (click)=\"_onCloseClick()\">Close</button> -->\n <!-- <button seamButton size=\"sm\" theme=\"lightgray\" class=\"mr-1\">Cancel</button>\n <button seamButton size=\"sm\" theme=\"success\">Done</button> -->\n</div>\n",
2541
+ template: "<h3>Columns</h3>\n\n<seam-form-field [numPaddingErrors]=\"0\" >\n <input seamInput [formControl]=\"_filterControl\" seamInputSize=\"sm\" placeholder=\"Search\" seamAutoFocus>\n</seam-form-field>\n\n<div seamOverlayScrollbar style=\"min-height: 200px; max-height: 600px; min-width: 250px;\" class=\"flex-grow-1 mb-2\">\n <div class=\"p-2\">\n <ng-container *ngFor=\"let col of _columns$ | async\">\n <seam-checkbox [checked]=\"!col.hidden\" (change)=\"_onChange($event, col)\">{{ col.name || col.prop }}</seam-checkbox>\n </ng-container>\n </div>\n\n</div>\n<div class=\"d-flex flex-row justify-content-end\">\n <!-- <button seamButton size=\"sm\" theme=\"lightgray\" (click)=\"_onCloseClick()\">Close</button> -->\n <!-- <button seamButton size=\"sm\" theme=\"lightgray\" class=\"mr-1\">Cancel</button>\n <button seamButton size=\"sm\" theme=\"success\">Done</button> -->\n</div>\n",
1640
2542
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1641
- styles: [":host{display:flex;flex-direction:column}"]
2543
+ styles: [":host{display:flex;flex-direction:column}\n"]
1642
2544
  },] }
1643
2545
  ];
1644
2546
  DatatableColumnPreferencesComponent.ctorParameters = function () { return [
1645
- { type: DatatableComponent, decorators: [{ type: i0.Inject, args: [THESEAM_DATATABLE,] }] }
2547
+ { type: DatatableComponent, decorators: [{ type: i0.Inject, args: [THESEAM_DATATABLE,] }] },
2548
+ { type: ColumnsAlterationsManagerService }
1646
2549
  ]; };
1647
2550
 
1648
2551
  var DatatableColumnPreferencesButtonComponent = /** @class */ (function () {
1649
- function DatatableColumnPreferencesButtonComponent() {
2552
+ function DatatableColumnPreferencesButtonComponent(_columnsAlterationsManager) {
2553
+ this._columnsAlterationsManager = _columnsAlterationsManager;
1650
2554
  this.icon = freeSolidSvgIcons.faColumns;
2555
+ /** @ignore */
2556
+ this._actionMenuPositions = [
2557
+ {
2558
+ originX: 'start',
2559
+ originY: 'bottom',
2560
+ overlayX: 'end',
2561
+ overlayY: 'top',
2562
+ },
2563
+ {
2564
+ originX: 'start',
2565
+ originY: 'top',
2566
+ overlayX: 'end',
2567
+ overlayY: 'bottom',
2568
+ },
2569
+ {
2570
+ originX: 'end',
2571
+ originY: 'bottom',
2572
+ overlayX: 'start',
2573
+ overlayY: 'top',
2574
+ },
2575
+ {
2576
+ originX: 'end',
2577
+ originY: 'top',
2578
+ overlayX: 'start',
2579
+ overlayY: 'bottom',
2580
+ },
2581
+ ];
1651
2582
  }
1652
2583
  DatatableColumnPreferencesButtonComponent.prototype.ngOnInit = function () { };
2584
+ DatatableColumnPreferencesButtonComponent.prototype._resetColumns = function (event) {
2585
+ this._columnsAlterationsManager.clear();
2586
+ };
1653
2587
  return DatatableColumnPreferencesButtonComponent;
1654
2588
  }());
1655
2589
  DatatableColumnPreferencesButtonComponent.decorators = [
1656
2590
  { type: i0.Component, args: [{
1657
2591
  selector: 'seam-datatable-column-preferences-button',
1658
- template: "<ng-template #colPrefsTpl>\n <seam-datatable-column-preferences></seam-datatable-column-preferences>\n</ng-template>\n\n\n<button\n seamButton\n [seamPopover]=\"colPrefsTpl\"\n theme=\"lightgray\"\n size=\"sm\"\n style=\"padding-left: 10px; padding-right: 10px;\"\n title=\"Column Preferences\"\n >\n <seam-icon [icon]=\"icon\"></seam-icon>\n <span class=\"sr-only\">Column Preferences</span>\n</button>\n",
2592
+ template: "<ng-template #colPrefsTpl>\n <seam-datatable-column-preferences></seam-datatable-column-preferences>\n</ng-template>\n\n<seam-menu #menu\n menuClass=\"list-group py-0 border-0 seam-datatable-action-menu\"\n animationType=\"fade\">\n <button seamMenuItem\n type=\"button\"\n class=\"list-group-item list-group-item-action py-1\"\n [seamPopover]=\"colPrefsTpl\">\n Show/Hide Columns\n </button>\n\n <button seamMenuItem\n type=\"button\"\n class=\"list-group-item list-group-item-action py-1\"\n (click)=\"_resetColumns($event)\">\n Reset Columns\n </button>\n</seam-menu>\n\n<button type=\"button\" class=\"btn btn-lightgray btn-sm\"\n [seamMenuToggle]=\"menu\"\n [positions]=\"_actionMenuPositions || []\"\n style=\"padding-left: 10px; padding-right: 10px;\"\n title=\"Column Preferences\">\n <seam-icon [icon]=\"icon\"></seam-icon>\n <span class=\"sr-only\">Column Preferences</span>\n</button>\n\n",
1659
2593
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1660
2594
  styles: [""]
1661
2595
  },] }
1662
2596
  ];
1663
- DatatableColumnPreferencesButtonComponent.ctorParameters = function () { return []; };
2597
+ DatatableColumnPreferencesButtonComponent.ctorParameters = function () { return [
2598
+ { type: ColumnsAlterationsManagerService }
2599
+ ]; };
1664
2600
 
1665
2601
  var DatatableExportButtonComponent = /** @class */ (function () {
1666
2602
  function DatatableExportButtonComponent(_datatable, _toastr, _loading, _valueHelper, _data) {
@@ -1764,7 +2700,7 @@
1764
2700
  selector: 'seam-datatable-export-button',
1765
2701
  template: "<seam-menu #menu>\n <button *ngFor=\"let exp of exporters\"\n seamMenuItem\n [icon]=\"exp?.icon\"\n (click)=\"_onExporterClicked(exp)\">\n {{ exp.label }}\n </button>\n</seam-menu>\n<button\n [seamMenuToggle]=\"menu\"\n seamButton\n theme=\"lightgray\"\n size=\"sm\"\n class=\"dropdown-toggle\"\n style=\"padding-left: 10px; padding-right: 10px;\"\n title=\"Export\"\n [disabled]=\"disabled\"\n >\n <seam-icon [icon]=\"icon\" class=\"mr-2\"></seam-icon>\n</button>\n",
1766
2702
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1767
- styles: [":host{display:inline-block}"]
2703
+ styles: [":host{display:inline-block}\n"]
1768
2704
  },] }
1769
2705
  ];
1770
2706
  DatatableExportButtonComponent.ctorParameters = function () { return [
@@ -1790,7 +2726,7 @@
1790
2726
  selector: 'seam-datatable-menu-bar-column-center',
1791
2727
  template: "<ng-content></ng-content>\n",
1792
2728
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1793
- styles: [":host{display:flex;flex-direction:row;flex:1 1 auto;justify-content:center}"]
2729
+ styles: [":host{display:flex;flex-direction:row;flex:1 1 auto;justify-content:center}\n"]
1794
2730
  },] }
1795
2731
  ];
1796
2732
  DatatableMenuBarColumnCenterComponent.ctorParameters = function () { return []; };
@@ -1807,7 +2743,7 @@
1807
2743
  selector: 'seam-datatable-menu-bar-column-left',
1808
2744
  template: "<ng-content></ng-content>\n",
1809
2745
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1810
- styles: [":host{display:flex;flex-direction:row;flex:1 1 0%;justify-content:flex-start}"]
2746
+ styles: [":host{display:flex;flex-direction:row;flex:1 1 0%;justify-content:flex-start}\n"]
1811
2747
  },] }
1812
2748
  ];
1813
2749
  DatatableMenuBarColumnLeftComponent.ctorParameters = function () { return []; };
@@ -1824,7 +2760,7 @@
1824
2760
  selector: 'seam-datatable-menu-bar-column-right',
1825
2761
  template: "<ng-content></ng-content>\n",
1826
2762
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1827
- styles: [":host{display:flex;flex-direction:row;flex:1 1 0%;justify-content:flex-end}"]
2763
+ styles: [":host{display:flex;flex-direction:row;flex:1 1 0%;justify-content:flex-end}\n"]
1828
2764
  },] }
1829
2765
  ];
1830
2766
  DatatableMenuBarColumnRightComponent.ctorParameters = function () { return []; };
@@ -1841,7 +2777,7 @@
1841
2777
  selector: 'seam-datatable-menu-bar-row',
1842
2778
  template: "<ng-content></ng-content>\n",
1843
2779
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1844
- styles: [":host{display:flex;flex-direction:row;flex-wrap:wrap}"]
2780
+ styles: [":host{display:flex;flex-direction:row;flex-wrap:wrap}\n"]
1845
2781
  },] }
1846
2782
  ];
1847
2783
  DatatableMenuBarRowComponent.ctorParameters = function () { return []; };
@@ -2119,6 +3055,39 @@
2119
3055
  { type: scrollbar.OverlayScrollbarsService }
2120
3056
  ]; };
2121
3057
 
3058
+ function withStoredColumnInfo(columns, preferenceColumns) {
3059
+ var e_1, _a;
3060
+ var _columns = [];
3061
+ var _loop_1 = function (col) {
3062
+ var storedCol = preferenceColumns.find(function (v) { return v.prop === col.prop; });
3063
+ if (storedCol) {
3064
+ var _col = Object.assign({}, col);
3065
+ if (utils.hasProperty(storedCol, 'width')) {
3066
+ _col.width = Math.max(storedCol.width, 0);
3067
+ }
3068
+ _col.canAutoResize = storedCol.canAutoResize;
3069
+ _columns.push(_col);
3070
+ }
3071
+ else {
3072
+ _columns.push(col);
3073
+ }
3074
+ };
3075
+ try {
3076
+ for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
3077
+ var col = columns_1_1.value;
3078
+ _loop_1(col);
3079
+ }
3080
+ }
3081
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3082
+ finally {
3083
+ try {
3084
+ if (columns_1_1 && !columns_1_1.done && (_a = columns_1.return)) _a.call(columns_1);
3085
+ }
3086
+ finally { if (e_1) throw e_1.error; }
3087
+ }
3088
+ return _columns;
3089
+ }
3090
+
2122
3091
  var TheSeamDatatableModule = /** @class */ (function () {
2123
3092
  function TheSeamDatatableModule() {
2124
3093
  }
@@ -2139,6 +3108,8 @@
2139
3108
  DatatableExportButtonComponent,
2140
3109
  TheSeamDatatableRowDetailDirective,
2141
3110
  DatatableRowDetailTplDirective,
3111
+ TheSeamDatatableFooterDirective,
3112
+ DatatableFooterTplDirective,
2142
3113
  DatatableColumnPreferencesComponent,
2143
3114
  DatatableColumnPreferencesButtonComponent,
2144
3115
  DatatableActionMenuItemDirective,
@@ -2181,6 +3152,8 @@
2181
3152
  DatatableExportButtonComponent,
2182
3153
  TheSeamDatatableRowDetailDirective,
2183
3154
  DatatableRowDetailTplDirective,
3155
+ TheSeamDatatableFooterDirective,
3156
+ DatatableFooterTplDirective,
2184
3157
  DatatableColumnPreferencesComponent,
2185
3158
  DatatableColumnPreferencesButtonComponent,
2186
3159
  DatatableActionMenuItemDirective,
@@ -2205,6 +3178,7 @@
2205
3178
  * Generated bundle index. Do not edit.
2206
3179
  */
2207
3180
 
3181
+ exports.CURRENT_DATATABLE_PREFERENCES_VERSION = CURRENT_DATATABLE_PREFERENCES_VERSION;
2208
3182
  exports.DatatableActionMenuComponent = DatatableActionMenuComponent;
2209
3183
  exports.DatatableActionMenuItemComponent = DatatableActionMenuItemComponent;
2210
3184
  exports.DatatableActionMenuItemDirective = DatatableActionMenuItemDirective;
@@ -2218,6 +3192,7 @@
2218
3192
  exports.DatatableDataSource = DatatableDataSource;
2219
3193
  exports.DatatableExportButtonComponent = DatatableExportButtonComponent;
2220
3194
  exports.DatatableFilterDirective = DatatableFilterDirective;
3195
+ exports.DatatableFooterTplDirective = DatatableFooterTplDirective;
2221
3196
  exports.DatatableGqlDataSource = DatatableGqlDataSource;
2222
3197
  exports.DatatableMenuBarColumnCenterComponent = DatatableMenuBarColumnCenterComponent;
2223
3198
  exports.DatatableMenuBarColumnLeftComponent = DatatableMenuBarColumnLeftComponent;
@@ -2228,20 +3203,23 @@
2228
3203
  exports.DatatablePreferencesService = DatatablePreferencesService;
2229
3204
  exports.DatatableRowActionItemDirective = DatatableRowActionItemDirective;
2230
3205
  exports.DatatableRowDetailTplDirective = DatatableRowDetailTplDirective;
3206
+ exports.EMPTY_DATATABLE_PREFERENCES = EMPTY_DATATABLE_PREFERENCES;
2231
3207
  exports.THESEAM_DATATABLE = THESEAM_DATATABLE;
2232
3208
  exports.THESEAM_DATATABLE_PREFERENCES_ACCESSOR = THESEAM_DATATABLE_PREFERENCES_ACCESSOR;
2233
3209
  exports.THESEAM_MENUBAR_ITEM_DATA = THESEAM_MENUBAR_ITEM_DATA;
3210
+ exports.TheSeamDatatableFooterDirective = TheSeamDatatableFooterDirective;
2234
3211
  exports.TheSeamDatatableModule = TheSeamDatatableModule;
2235
3212
  exports.TheSeamDatatableRowDetailDirective = TheSeamDatatableRowDetailDirective;
2236
3213
  exports.TheSeamDatatableScrollbarHelperService = TheSeamDatatableScrollbarHelperService;
2237
3214
  exports._THESEAM_DATATABLE = _THESEAM_DATATABLE;
2238
3215
  exports._THESEAM_DATATABLE_ACCESSOR = _THESEAM_DATATABLE_ACCESSOR;
2239
3216
  exports._THESEAM_DATA_FILTER_CONTAINER = _THESEAM_DATA_FILTER_CONTAINER;
2240
- exports._setColumnDefaults = _setColumnDefaults;
2241
3217
  exports.withStoredColumnInfo = withStoredColumnInfo;
2242
- exports.ɵa = THESEAM_DATATABLE_ACCESSOR;
3218
+ exports["ɵa"] = THESEAM_DATATABLE_ACCESSOR;
3219
+ exports["ɵb"] = ColumnsManagerService;
3220
+ exports["ɵc"] = ColumnsAlterationsManagerService;
2243
3221
 
2244
3222
  Object.defineProperty(exports, '__esModule', { value: true });
2245
3223
 
2246
- })));
3224
+ }));
2247
3225
  //# sourceMappingURL=theseam-ui-common-datatable.umd.js.map