@theseam/ui-common 0.2.10 → 0.2.14

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 (353) 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 +1313 -378
  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 +27 -29
  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 +46 -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-menu-bar/datatable-menu-bar.component.d.ts +1 -1
  96. package/datatable/directives/datatable-filter.directive.d.ts +1 -1
  97. package/datatable/models/columns-alteration.d.ts +61 -0
  98. package/datatable/models/columns-alterations/hide-column.columns-alteration.d.ts +15 -0
  99. package/datatable/models/columns-alterations/order.columns-alteration.d.ts +20 -0
  100. package/datatable/models/columns-alterations/sort.columns-alteration.d.ts +14 -0
  101. package/datatable/models/columns-alterations/width.columns-alteration.d.ts +16 -0
  102. package/datatable/models/datatable-accessor.d.ts +5 -3
  103. package/datatable/models/internal-column-props.d.ts +7 -0
  104. package/datatable/models/page-info.d.ts +12 -0
  105. package/datatable/models/preferences-accessor.d.ts +1 -1
  106. package/datatable/models/preferences.d.ts +11 -3
  107. package/datatable/models/sort-item.d.ts +2 -1
  108. package/datatable/services/columns-alterations-manager.service.d.ts +39 -0
  109. package/datatable/services/columns-manager.service.d.ts +55 -0
  110. package/datatable/services/datatable-preferences.service.d.ts +10 -7
  111. package/datatable/theseam-ui-common-datatable.d.ts +2 -0
  112. package/datatable/theseam-ui-common-datatable.metadata.json +1 -1
  113. package/datatable/tokens/datatable-preferences-accessor.d.ts +2 -2
  114. package/datatable/utils/create-action-menu-column.d.ts +3 -0
  115. package/datatable/utils/create-checkbox-column.d.ts +3 -0
  116. package/datatable/utils/get-column-prop.d.ts +5 -0
  117. package/datatable/utils/map-columns-alterations-states.d.ts +2 -0
  118. package/datatable/utils/remove-unused-diffs.d.ts +7 -0
  119. package/datatable/utils/set-column-defaults.d.ts +2 -0
  120. package/datatable/utils/translate-templates.d.ts +2 -0
  121. package/datatable/utils/with-stored-column-info.d.ts +2 -2
  122. package/datatable-dynamic/theseam-ui-common-datatable-dynamic.metadata.json +1 -1
  123. package/esm2015/buttons/progress-circle-button/progress-circle-button.component.js +1 -1
  124. package/esm2015/card/card-action/card-action.component.js +1 -1
  125. package/esm2015/card/card-body/card-body.component.js +1 -1
  126. package/esm2015/data-filters/data-filter.js +5 -2
  127. package/esm2015/data-filters/filters/data-filter-search/data-filter-search.component.js +1 -1
  128. package/esm2015/data-filters/filters/data-filter-text/data-filter-text.component.js +1 -1
  129. package/esm2015/datatable/datatable/datatable.component.js +195 -211
  130. package/esm2015/datatable/datatable-action-menu/datatable-action-menu.component.js +1 -1
  131. package/esm2015/datatable/datatable-column/datatable-column.component.js +1 -1
  132. package/esm2015/datatable/datatable-column-preferences/datatable-column-preferences.component.js +42 -19
  133. package/esm2015/datatable/datatable-column-preferences-button/datatable-column-preferences-button.component.js +38 -4
  134. package/esm2015/datatable/datatable-export-button/datatable-export-button.component.js +7 -6
  135. package/esm2015/datatable/datatable-menu-bar/datatable-menu-bar.component.js +1 -1
  136. package/esm2015/datatable/datatable-menu-bar-column-center/datatable-menu-bar-column-center.component.js +1 -1
  137. package/esm2015/datatable/datatable-menu-bar-column-left/datatable-menu-bar-column-left.component.js +1 -1
  138. package/esm2015/datatable/datatable-menu-bar-column-right/datatable-menu-bar-column-right.component.js +1 -1
  139. package/esm2015/datatable/datatable-menu-bar-row/datatable-menu-bar-row.component.js +1 -1
  140. package/esm2015/datatable/models/columns-alteration.js +38 -0
  141. package/esm2015/datatable/models/columns-alterations/hide-column.columns-alteration.js +38 -0
  142. package/esm2015/datatable/models/columns-alterations/order.columns-alteration.js +81 -0
  143. package/esm2015/datatable/models/columns-alterations/sort.columns-alteration.js +33 -0
  144. package/esm2015/datatable/models/columns-alterations/width.columns-alteration.js +41 -0
  145. package/esm2015/datatable/models/datatable-accessor.js +1 -1
  146. package/esm2015/datatable/models/internal-column-props.js +15 -0
  147. package/esm2015/datatable/models/page-info.js +1 -1
  148. package/esm2015/datatable/models/preferences-accessor.js +1 -1
  149. package/esm2015/datatable/models/preferences.js +6 -2
  150. package/esm2015/datatable/models/sort-item.js +1 -1
  151. package/esm2015/datatable/services/columns-alterations-manager.service.js +134 -0
  152. package/esm2015/datatable/services/columns-manager.service.js +257 -0
  153. package/esm2015/datatable/services/datatable-preferences.service.js +78 -32
  154. package/esm2015/datatable/theseam-ui-common-datatable.js +3 -1
  155. package/esm2015/datatable/tokens/datatable-preferences-accessor.js +2 -2
  156. package/esm2015/datatable/utils/create-action-menu-column.js +18 -0
  157. package/esm2015/datatable/utils/create-checkbox-column.js +15 -0
  158. package/esm2015/datatable/utils/get-column-prop.js +9 -0
  159. package/esm2015/datatable/utils/map-columns-alterations-states.js +39 -0
  160. package/esm2015/datatable/utils/remove-unused-diffs.js +9 -0
  161. package/esm2015/datatable/utils/set-column-defaults.js +10 -0
  162. package/esm2015/datatable/utils/translate-templates.js +12 -0
  163. package/esm2015/datatable/utils/with-stored-column-info.js +1 -1
  164. package/esm2015/datatable-dynamic/datatable-dynamic-action-menu/datatable-dynamic-action-menu.component.js +1 -1
  165. package/esm2015/datatable-dynamic/datatable-dynamic-filter-container/datatable-dynamic-filter-container.component.js +1 -1
  166. package/esm2015/datatable-dynamic/datatable-dynamic.component.js +1 -1
  167. package/esm2015/form-field/form-field.component.js +1 -1
  168. package/esm2015/form-field-error/form-field-error/form-field-error.component.js +1 -1
  169. package/esm2015/framework/base-layout/base-layout.component.js +1 -1
  170. package/esm2015/framework/dashboard/dashboard-widgets/dashboard-widgets.component.js +1 -1
  171. package/esm2015/framework/dynamic-router/hierarchy-router-outlet/hierarchy-router-outlet.component.js +1 -1
  172. package/esm2015/framework/schema-form-controls/schema-form-input/schema-form-input.component.js +1 -1
  173. package/esm2015/framework/schema-form-controls/schema-form-number/schema-form-number.component.js +1 -1
  174. package/esm2015/framework/schema-form-controls/schema-form-select/schema-form-select.component.js +1 -1
  175. package/esm2015/framework/schema-form-controls/schema-form-submit-split/schema-form-submit-split.component.js +1 -1
  176. package/esm2015/framework/side-nav/side-nav-item/side-nav-item.component.js +1 -1
  177. package/esm2015/framework/side-nav/side-nav-toggle/side-nav-toggle.component.js +1 -1
  178. package/esm2015/framework/side-nav/side-nav.component.js +1 -1
  179. package/esm2015/framework/top-bar/top-bar-menu-button/top-bar-menu-button.component.js +1 -1
  180. package/esm2015/framework/top-bar/top-bar-title/top-bar-title.component.js +1 -1
  181. package/esm2015/framework/top-bar/top-bar.component.js +1 -1
  182. package/esm2015/graphql/datatable/create-page-info-observable.js +38 -0
  183. package/esm2015/graphql/datatable/datatable-graphql-query-ref.js +236 -0
  184. package/esm2015/graphql/datatable/datatable-graphql.service.js +35 -0
  185. package/esm2015/graphql/datatable/datatable-helpers.js +170 -0
  186. package/esm2015/graphql/datatable/get-page-info.js +11 -0
  187. package/esm2015/graphql/datatable/index.js +7 -0
  188. package/esm2015/graphql/datatable/map-filter-states.js +64 -0
  189. package/esm2015/graphql/datatable/map-page-info.js +14 -0
  190. package/esm2015/graphql/datatable/mapper-context.js +2 -0
  191. package/esm2015/graphql/models/gql-datatable-accessor.js +2 -0
  192. package/esm2015/graphql/models/index.js +2 -1
  193. package/esm2015/graphql/models/query-processing-config.js +1 -1
  194. package/esm2015/graphql/public-api.js +2 -1
  195. package/esm2015/graphql/utils/parse-hints.js +3 -3
  196. package/esm2015/icon/icon/icon.component.js +1 -1
  197. package/esm2015/loading/loading/loading.component.js +1 -1
  198. package/esm2015/menu/menu.component.js +1 -1
  199. package/esm2015/modal/modal-body/modal-body.component.js +1 -1
  200. package/esm2015/modal/modal-container/modal-container.component.js +1 -1
  201. package/esm2015/popover/popover/popover.component.js +1 -1
  202. package/esm2015/progress/progress-circle/progress-circle.component.js +1 -1
  203. package/esm2015/tabbed/tabbed.component.js +1 -1
  204. package/esm2015/table/table/table.component.js +1 -1
  205. package/esm2015/table-cell-types/public-api.js +8 -1
  206. package/esm2015/table-cell-types/table-cell-type-currency/table-cell-type-currency-config.js +2 -0
  207. package/esm2015/table-cell-types/table-cell-type-currency/table-cell-type-currency.component.js +74 -0
  208. package/esm2015/table-cell-types/table-cell-type-currency/table-cell-type-currency.js +2 -0
  209. package/esm2015/table-cell-types/table-cell-type-decimal/table-cell-type-decimal-config.js +1 -1
  210. package/esm2015/table-cell-types/table-cell-type-decimal/table-cell-type-decimal.component.js +73 -0
  211. package/esm2015/table-cell-types/table-cell-type-decimal/table-cell-type-decimal.js +2 -0
  212. package/esm2015/table-cell-types/table-cell-type-icon/table-cell-type-icon.component.js +1 -1
  213. package/esm2015/table-cell-types/table-cell-type-integer/table-cell-type-integer-config.js +1 -1
  214. package/esm2015/table-cell-types/table-cell-type-integer/table-cell-type-integer.component.js +71 -0
  215. package/esm2015/table-cell-types/table-cell-type-integer/table-cell-type-integer.js +2 -0
  216. package/esm2015/table-cell-types/table-cell-type-manifests.js +29 -17
  217. package/esm2015/table-cell-types/table-cell-type-progress-circle/table-cell-type-progress-circle.component.js +1 -1
  218. package/esm2015/table-cell-types/table-cell-types.module.js +9 -2
  219. package/esm2015/tel-input/tel-input/tel-input.component.js +1 -1
  220. package/esm2015/testing/current-tick-time.js +16 -0
  221. package/esm2015/testing/fake-toastr.js +29 -0
  222. package/esm2015/testing/get-harness.js +16 -0
  223. package/esm2015/testing/public-api.js +7 -0
  224. package/esm2015/testing/render-story.js +12 -0
  225. package/esm2015/testing/story-expect.js +39 -0
  226. package/esm2015/testing/theseam-ui-common-testing.js +5 -0
  227. package/esm2015/testing/tick-helper.js +74 -0
  228. package/esm2015/tiled-select/components/tiled-select/tiled-select.component.js +25 -17
  229. package/esm2015/tiled-select/components/tiled-select-tile/tiled-select-tile.component.js +5 -2
  230. package/esm2015/tiled-select/components/tiled-select-tile-icon/tiled-select-tile-icon.component.js +1 -1
  231. package/esm2015/tiled-select/public-api.js +2 -1
  232. package/esm2015/tiled-select/tiled-select.models.js +1 -1
  233. package/esm2015/tiled-select/tiled-select.module.js +4 -4
  234. package/esm2015/toggle-edit/toggle-edit-actions-container/toggle-edit-actions-container.component.js +1 -1
  235. package/esm2015/toggle-edit/toggle-edit.component.js +1 -1
  236. package/esm2015/utils/array-move.js +62 -0
  237. package/esm2015/utils/public-api.js +2 -1
  238. package/esm2015/utils/router/is-empty-url-route.js +1 -1
  239. package/esm2015/utils/subscriber-count.js +31 -4
  240. package/esm2015/widget/widget/widget.component.js +1 -1
  241. package/esm2015/widget/widget-content-components/widget-button-group/widget-button-group.component.js +1 -1
  242. package/esm2015/widget/widget-content-components/widget-content-header/widget-content-header.component.js +1 -1
  243. package/esm2015/widget/widget-content-components/widget-empty-label/widget-empty-label.component.js +1 -1
  244. package/esm2015/widget/widget-content-components/widget-footer-link/widget-footer-link.component.js +1 -1
  245. package/esm2015/widget/widget-content-components/widget-footer-text/widget-footer-text.component.js +1 -1
  246. package/esm2015/widget/widget-content-components/widget-header-badge/widget-header-badge.component.js +1 -1
  247. package/esm2015/widget/widget-content-components/widget-tile/widget-tile-footer-item/widget-tile-footer-item.component.js +1 -1
  248. package/esm2015/widget/widget-content-components/widget-tile/widget-tile-group/widget-tile-group.component.js +1 -1
  249. package/esm2015/widget/widget-content-components/widget-tile/widget-tile.component.js +1 -1
  250. package/esm2015/widget/widget-content-components/widget-tile-list/widget-tile-list.component.js +1 -1
  251. package/esm2015/widget/widget-footer/widget-footer.component.js +1 -1
  252. package/fesm2015/theseam-ui-common-buttons.js +1 -1
  253. package/fesm2015/theseam-ui-common-card.js +2 -2
  254. package/fesm2015/theseam-ui-common-data-filters.js +6 -3
  255. package/fesm2015/theseam-ui-common-data-filters.js.map +1 -1
  256. package/fesm2015/theseam-ui-common-datatable-dynamic.js +3 -3
  257. package/fesm2015/theseam-ui-common-datatable.js +1105 -319
  258. package/fesm2015/theseam-ui-common-datatable.js.map +1 -1
  259. package/fesm2015/theseam-ui-common-form-field-error.js +1 -1
  260. package/fesm2015/theseam-ui-common-form-field.js +1 -1
  261. package/fesm2015/theseam-ui-common-framework.js +13 -13
  262. package/fesm2015/theseam-ui-common-graphql.js +555 -5
  263. package/fesm2015/theseam-ui-common-graphql.js.map +1 -1
  264. package/fesm2015/theseam-ui-common-icon.js +1 -1
  265. package/fesm2015/theseam-ui-common-loading.js +1 -1
  266. package/fesm2015/theseam-ui-common-menu.js +1 -1
  267. package/fesm2015/theseam-ui-common-modal.js +2 -2
  268. package/fesm2015/theseam-ui-common-popover.js +1 -1
  269. package/fesm2015/theseam-ui-common-progress.js +1 -1
  270. package/fesm2015/theseam-ui-common-tabbed.js +1 -1
  271. package/fesm2015/theseam-ui-common-table-cell-types.js +234 -22
  272. package/fesm2015/theseam-ui-common-table-cell-types.js.map +1 -1
  273. package/fesm2015/theseam-ui-common-table.js +1 -1
  274. package/fesm2015/theseam-ui-common-tel-input.js +1 -1
  275. package/fesm2015/theseam-ui-common-testing.js +191 -0
  276. package/fesm2015/theseam-ui-common-testing.js.map +1 -0
  277. package/fesm2015/theseam-ui-common-tiled-select.js +34 -21
  278. package/fesm2015/theseam-ui-common-tiled-select.js.map +1 -1
  279. package/fesm2015/theseam-ui-common-toggle-edit.js +2 -2
  280. package/fesm2015/theseam-ui-common-utils.js +92 -4
  281. package/fesm2015/theseam-ui-common-utils.js.map +1 -1
  282. package/fesm2015/theseam-ui-common-widget.js +12 -12
  283. package/form-field/theseam-ui-common-form-field.metadata.json +1 -1
  284. package/form-field-error/theseam-ui-common-form-field-error.metadata.json +1 -1
  285. package/framework/theseam-ui-common-framework.metadata.json +1 -1
  286. package/graphql/datatable/create-page-info-observable.d.ts +4 -0
  287. package/graphql/datatable/datatable-graphql-query-ref.d.ts +65 -0
  288. package/graphql/datatable/datatable-graphql.service.d.ts +26 -0
  289. package/graphql/datatable/datatable-helpers.d.ts +12 -0
  290. package/graphql/datatable/get-page-info.d.ts +4 -0
  291. package/graphql/datatable/index.d.ts +6 -0
  292. package/graphql/datatable/map-filter-states.d.ts +18 -0
  293. package/graphql/datatable/map-page-info.d.ts +11 -0
  294. package/graphql/datatable/mapper-context.d.ts +6 -0
  295. package/graphql/models/gql-datatable-accessor.d.ts +9 -0
  296. package/graphql/models/index.d.ts +1 -0
  297. package/graphql/models/query-processing-config.d.ts +4 -0
  298. package/graphql/public-api.d.ts +1 -0
  299. package/graphql/theseam-ui-common-graphql.metadata.json +1 -1
  300. package/icon/theseam-ui-common-icon.metadata.json +1 -1
  301. package/loading/theseam-ui-common-loading.metadata.json +1 -1
  302. package/menu/theseam-ui-common-menu.metadata.json +1 -1
  303. package/modal/theseam-ui-common-modal.metadata.json +1 -1
  304. package/package.json +1 -1
  305. package/popover/theseam-ui-common-popover.metadata.json +1 -1
  306. package/progress/theseam-ui-common-progress.metadata.json +1 -1
  307. package/styles/vendor/ngx-datatable/_ngx-datatable.scss +87 -82
  308. package/styles/vendor/ngx-datatable/_themes/bootstrap/_variables.scss +3 -2
  309. package/tabbed/theseam-ui-common-tabbed.metadata.json +1 -1
  310. package/table/theseam-ui-common-table.metadata.json +1 -1
  311. package/table-cell-types/public-api.d.ts +7 -0
  312. package/table-cell-types/table-cell-type-currency/table-cell-type-currency-config.d.ts +39 -0
  313. package/table-cell-types/table-cell-type-currency/table-cell-type-currency.component.d.ts +19 -0
  314. package/table-cell-types/table-cell-type-currency/table-cell-type-currency.d.ts +3 -0
  315. package/table-cell-types/table-cell-type-decimal/table-cell-type-decimal-config.d.ts +31 -1
  316. package/table-cell-types/table-cell-type-decimal/table-cell-type-decimal.component.d.ts +19 -0
  317. package/table-cell-types/table-cell-type-decimal/table-cell-type-decimal.d.ts +3 -0
  318. package/table-cell-types/table-cell-type-integer/table-cell-type-integer-config.d.ts +23 -1
  319. package/table-cell-types/table-cell-type-integer/table-cell-type-integer.component.d.ts +19 -0
  320. package/table-cell-types/table-cell-type-integer/table-cell-type-integer.d.ts +3 -0
  321. package/table-cell-types/table-cell-type-manifests.d.ts +2 -1
  322. package/table-cell-types/theseam-ui-common-table-cell-types.metadata.json +1 -1
  323. package/tel-input/theseam-ui-common-tel-input.metadata.json +1 -1
  324. package/testing/current-tick-time.d.ts +13 -0
  325. package/testing/fake-toastr.d.ts +30 -0
  326. package/testing/get-harness.d.ts +7 -0
  327. package/testing/package.json +11 -0
  328. package/testing/public-api.d.ts +6 -0
  329. package/testing/render-story.d.ts +2 -0
  330. package/testing/story-expect.d.ts +5 -0
  331. package/{test-helpers/theseam-ui-common-test-helpers.d.ts → testing/theseam-ui-common-testing.d.ts} +0 -0
  332. package/testing/theseam-ui-common-testing.metadata.json +1 -0
  333. package/{test-helpers → testing}/tick-helper.d.ts +0 -0
  334. package/tiled-select/components/tiled-select/tiled-select.component.d.ts +7 -3
  335. package/tiled-select/components/tiled-select-tile/tiled-select-tile.component.d.ts +1 -0
  336. package/tiled-select/theseam-ui-common-tiled-select.metadata.json +1 -1
  337. package/tiled-select/tiled-select.models.d.ts +3 -1
  338. package/toggle-edit/theseam-ui-common-toggle-edit.metadata.json +1 -1
  339. package/utils/array-move.d.ts +49 -0
  340. package/utils/public-api.d.ts +1 -0
  341. package/utils/subscriber-count.d.ts +13 -1
  342. package/utils/theseam-ui-common-utils.metadata.json +1 -1
  343. package/widget/theseam-ui-common-widget.metadata.json +1 -1
  344. package/bundles/theseam-ui-common-test-helpers.umd.js +0 -94
  345. package/bundles/theseam-ui-common-test-helpers.umd.js.map +0 -1
  346. package/esm2015/test-helpers/public-api.js +0 -2
  347. package/esm2015/test-helpers/theseam-ui-common-test-helpers.js +0 -5
  348. package/esm2015/test-helpers/tick-helper.js +0 -74
  349. package/fesm2015/theseam-ui-common-test-helpers.js +0 -81
  350. package/fesm2015/theseam-ui-common-test-helpers.js.map +0 -1
  351. package/test-helpers/package.json +0 -11
  352. package/test-helpers/public-api.d.ts +0 -1
  353. 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 [
@@ -744,7 +700,7 @@
744
700
  selector: 'seam-datatable-menu-bar',
745
701
  template: "<div class=\"bg-light border rounded p-2\">\n <ng-content></ng-content>\n</div>\n",
746
702
  providers: [_THESEAM_DATA_FILTER_CONTAINER],
747
- styles: [":host{display:block}"]
703
+ styles: [":host{display:block}\n"]
748
704
  },] }
749
705
  ];
750
706
  DatatableMenuBarComponent.ctorParameters = function () { return []; };
@@ -854,52 +810,426 @@
854
810
  { type: i0.TemplateRef }
855
811
  ]; };
856
812
 
857
- 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));
854
+
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
+ }
858
872
 
859
- function withStoredColumnInfo(columns, preferenceColumns) {
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) {
860
896
  var e_1, _a;
861
- var _columns = [];
862
- var _loop_1 = function (col) {
863
- var storedCol = preferenceColumns.find(function (v) { return v.prop === col.prop; });
864
- if (storedCol) {
865
- var _col = Object.assign({}, col);
866
- if (utils.hasProperty(storedCol, 'width')) {
867
- _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;
868
902
  }
869
- _col.canAutoResize = storedCol.canAutoResize;
870
- _columns.push(_col);
871
903
  }
872
- else {
873
- _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);
874
909
  }
875
- };
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);
876
920
  try {
877
- for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
878
- var col = columns_1_1.value;
879
- _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);
880
924
  }
881
925
  }
882
926
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
883
927
  finally {
884
928
  try {
885
- 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);
886
930
  }
887
931
  finally { if (e_1) throw e_1.error; }
888
932
  }
889
- return _columns;
933
+ return cols;
890
934
  }
891
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
892
1216
  var DatatablePreferencesService = /** @class */ (function () {
893
1217
  function DatatablePreferencesService(_prefsAccessor) {
894
1218
  this._prefsAccessor = _prefsAccessor;
895
1219
  this._tablePrefsMap = new Map();
896
1220
  this._pending = false;
1221
+ this._loaded = false;
897
1222
  }
898
1223
  Object.defineProperty(DatatablePreferencesService.prototype, "pending", {
899
1224
  get: function () { return this._pending; },
900
1225
  enumerable: false,
901
1226
  configurable: true
902
1227
  });
1228
+ Object.defineProperty(DatatablePreferencesService.prototype, "loaded", {
1229
+ get: function () { return this._loaded; },
1230
+ enumerable: false,
1231
+ configurable: true
1232
+ });
903
1233
  DatatablePreferencesService.prototype.preferences = function (preferenceKey) {
904
1234
  var prefs = this._tablePrefsMap.get(preferenceKey);
905
1235
  if (!prefs) {
@@ -915,16 +1245,17 @@
915
1245
  DatatablePreferencesService.prototype._createObservable = function (refreshSubject, prefKey) {
916
1246
  var _this = this;
917
1247
  if (!this._prefsAccessor) {
918
- return rxjs.of({});
1248
+ return rxjs.of(EMPTY_DATATABLE_PREFERENCES);
919
1249
  }
920
- var accessor = function (key) { return _this._prefsAccessor ? _this._prefsAccessor.get(key) : rxjs.of('{}'); };
921
- 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) {
922
1252
  if (!v) {
923
1253
  return null;
924
1254
  }
925
1255
  // TODO: Add a schema validator and migration tool to avoid parsing issues.
926
1256
  try {
927
- return JSON.parse(v);
1257
+ // return JSON.parse(v) as TheSeamDatatablePreferences
1258
+ return _this._descerializePreferences(v);
928
1259
  }
929
1260
  catch (error) {
930
1261
  if (i0.isDevMode()) {
@@ -932,7 +1263,12 @@
932
1263
  }
933
1264
  return null;
934
1265
  }
935
- }), 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 }));
936
1272
  };
937
1273
  DatatablePreferencesService.prototype.refresh = function (preferenceKey) {
938
1274
  var prefs = this._tablePrefsMap.get(preferenceKey);
@@ -948,7 +1284,40 @@
948
1284
  // out of order updates. This shouldn't be an issue, with how fast preferences
949
1285
  // will most likely be changing, but it could happen in situations, such as
950
1286
  // network issues.
951
- 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) {
952
1321
  var _this = this;
953
1322
  if (!this._prefsAccessor) {
954
1323
  return;
@@ -957,71 +1326,547 @@
957
1326
  this.preferences(preferenceKey).pipe(operators.map(function (prefs) {
958
1327
  // Making the preferences immutable may not be necessary, but for now
959
1328
  // this obj->str->obj will work as a naive clone.
960
- var columns = JSON.parse(JSON.stringify(prefs.columns || []));
961
- var _colPref = columns.find(function (c) { return c.prop === column.prop; });
962
- // console.log('has', _colPref)
963
- if (_colPref) {
964
- // console.log('hasProperty(column, "width"))', hasProperty(column, 'width'))
965
- if (utils.hasProperty(column, 'width')) {
966
- _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;
967
1446
  }
968
- if (utils.hasProperty(column, 'canAutoResize')) {
969
- _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
+ }
970
1531
  }
971
- if (utils.hasProperty(column, 'hidden')) {
972
- _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
+ .map(function (column, index) { return ({ column: column, index: index }); })
1747
+ .filter(function (x) { return isInternalColumn(x.column); });
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?");
973
1776
  }
974
1777
  }
975
- else {
976
- 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);
977
1783
  }
978
- var newPrefs = Object.assign(Object.assign({}, prefs), { columns: columns });
979
- return newPrefs;
980
- }),
981
- // tap(v => console.log('newPrefs', v)),
982
- operators.take(1), operators.switchMap(function (newPrefs) { return _this._prefsAccessor
983
- ? _this._prefsAccessor.update(preferenceKey, JSON.stringify(newPrefs))
984
- : rxjs.of(newPrefs); }), operators.tap(function () { return _this.refresh(preferenceKey); }))
985
- .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
+ }
986
1792
  };
987
- DatatablePreferencesService.prototype.withColumnPreferences = function (preferenceKey, columns) {
988
- return this.preferences(preferenceKey).pipe(operators.startWith({}), operators.map(function (preferences) { return preferences && preferences.columns
989
- ? withStoredColumnInfo(columns, preferences.columns)
990
- : 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;
991
1806
  };
992
- return DatatablePreferencesService;
993
- }());
994
- DatatablePreferencesService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function DatatablePreferencesService_Factory() { return new DatatablePreferencesService(i0__namespace.ɵɵinject(THESEAM_DATATABLE_PREFERENCES_ACCESSOR, 8)); }, token: DatatablePreferencesService, providedIn: "root" });
995
- DatatablePreferencesService.decorators = [
996
- { type: i0.Injectable, args: [{
997
- providedIn: 'root'
998
- },] }
999
- ];
1000
- DatatablePreferencesService.ctorParameters = function () { return [
1001
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [THESEAM_DATATABLE_PREFERENCES_ACCESSOR,] }] }
1002
- ]; };
1003
-
1004
- 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));
1005
1824
 
1006
- function _setColumnDefaults(columns) {
1007
- var e_1, _h;
1825
+ function mapColumnsAlterationsStates(states) {
1826
+ var e_1, _a;
1827
+ var alterations = [];
1008
1828
  try {
1009
- for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
1010
- var column = columns_1_1.value;
1011
- if (!column.hasOwnProperty('hidden')) {
1012
- 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
+ }
1013
1857
  }
1014
1858
  }
1015
1859
  }
1016
1860
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
1017
1861
  finally {
1018
1862
  try {
1019
- 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);
1020
1864
  }
1021
1865
  finally { if (e_1) throw e_1.error; }
1022
1866
  }
1023
- ngxDatatable.setColumnDefaults(columns);
1024
- }
1867
+ return alterations;
1868
+ }
1869
+
1025
1870
  /**
1026
1871
  * Intended for internal classes declared by the `TheSeamDatatableModule`.
1027
1872
  */
@@ -1036,26 +1881,20 @@
1036
1881
  // tslint:disable-next-line:no-use-before-declare
1037
1882
  useExisting: i0.forwardRef(function () { return DatatableComponent; })
1038
1883
  };
1039
- // TODO: Reduce reliance on BehaviorSubject based observables, because it should
1040
- // be easier to avoit over emitting observables.
1041
1884
  var DatatableComponent = /** @class */ (function () {
1042
- function DatatableComponent(_columnChangesService, _differs, _preferences) {
1885
+ function DatatableComponent(_preferences, _columnsManager, _columnsAlterationsManager) {
1043
1886
  var _this = this;
1044
- // this.displayColumns$ = this.hiddenColumns$.pipe(
1045
- // switchMap(hiddenColumns => this.columns$.pipe(map(cols => cols.filter(c => hiddenColumns.findIndex(hc => hc === c.prop) === -1))))
1046
- // )
1047
- this._columnChangesService = _columnChangesService;
1048
- this._differs = _differs;
1049
1887
  this._preferences = _preferences;
1050
- this.faChevronDown = freeSolidSvgIcons.faChevronDown;
1051
- this.faChevronRight = freeSolidSvgIcons.faChevronRight;
1052
- 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;
1053
1893
  this._ngUnsubscribe = new rxjs.Subject();
1054
1894
  this._filtersSubject = new rxjs.BehaviorSubject([]);
1055
- this._columnsObservable = new rxjs.BehaviorSubject(undefined);
1056
1895
  this._dataSourceSubject = new rxjs.BehaviorSubject(undefined);
1896
+ this._resizing = {};
1057
1897
  this._preferencesKey = new rxjs.BehaviorSubject(undefined);
1058
- this._columns = new rxjs.BehaviorSubject([]);
1059
1898
  this._rows = new rxjs.BehaviorSubject([]);
1060
1899
  this.columnMode = ngxDatatable.ColumnMode.force;
1061
1900
  this.selected = [];
@@ -1067,7 +1906,7 @@
1067
1906
  this.loadingIndicator = false;
1068
1907
  this.reorderable = true;
1069
1908
  this.swapColumns = false;
1070
- this.sortType = ngxDatatable.SortType.single;
1909
+ this._sortType = ngxDatatable.SortType.single;
1071
1910
  this._sorts = [];
1072
1911
  this.cssClasses = {
1073
1912
  sortAscending: 'datatable-icon-up',
@@ -1112,27 +1951,50 @@
1112
1951
  this._colDiffersInp = {};
1113
1952
  this._colDiffersTpl = {};
1114
1953
  this._rowDetailToggleSubscription = rxjs.Subscription.EMPTY;
1115
- var applyPrefs = function (cols) { return _this._preferencesKey.pipe(operators.switchMap(function (name) { return !!name
1116
- // NOTE: This pending check is temporary to avoid table using previously
1117
- // retrieved preference while the new one is being updated on the
1118
- // server.
1119
- ? !_this._preferences.pending
1120
- ? _this._preferences.withColumnPreferences(name, cols)
1121
- : rxjs.of(cols)
1122
- : rxjs.of(cols); })); };
1123
- this.columns$ = this._columnsObservable.pipe(operators.switchMap(function (colsObs) { return colsObs !== null && colsObs !== void 0 ? colsObs : rxjs.of([]); }));
1124
- 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); }));
1125
1996
  this.filters$ = this._filtersSubject.asObservable();
1126
1997
  this.filterStates = this._filtersSubject.asObservable().pipe(operators.switchMap(function (filters) { return dataFilters.composeDataFilterStates(filters); }));
1127
- // this.rows$ = this._filtersSubject.asObservable()
1128
- // .pipe(
1129
- // switchMap(filters => {
1130
- // if (this.externalFiltering) {
1131
- // return this._rows.asObservable()
1132
- // }
1133
- // return this._rows.asObservable().pipe(composeDataFilters(filters))
1134
- // })
1135
- // )
1136
1998
  this.rows$ = this._dataSourceSubject.pipe(operators.switchMap(function (dataSource) {
1137
1999
  // console.log('dataSource', dataSource)
1138
2000
  var dataStream;
@@ -1168,20 +2030,6 @@
1168
2030
  // tap(v => console.log('stream', v)),
1169
2031
  operators.takeUntil(_this._ngUnsubscribe));
1170
2032
  }));
1171
- // this.hiddenColumns$ = this._hiddenColumns.asObservable()
1172
- // this._hiddenColumns.pipe(
1173
- // skip(1),
1174
- // distinctUntilChanged((a, b) => {
1175
- // const _a = Array.isArray(a) ? a : []
1176
- // const _b = Array.isArray(b) ? b : []
1177
- // if (_a.length !== _b.length) { return false }
1178
- // const _as = _a.sort()
1179
- // const _bs = _b.sort()
1180
- // return !_as.sort().every((value: string, index: number) => _bs[index] === value)
1181
- // }),
1182
- // tap(v => this.hiddenColumnsChange.emit(v)),
1183
- // untilDestroyed(this)
1184
- // ).subscribe(v => console.log('hiddenColumnsChange', v))
1185
2033
  // TODO: Implement viewChange for CollectionViewer.
1186
2034
  this.viewChange = this.page.pipe(operators.map(function (p) { return ({ start: 0, end: p.count }); }));
1187
2035
  }
@@ -1197,22 +2045,45 @@
1197
2045
  configurable: true
1198
2046
  });
1199
2047
  Object.defineProperty(DatatableComponent.prototype, "columns", {
1200
- get: function () { return this._columns.value; },
1201
2048
  set: function (value) {
1202
- // console.log('columns input', value)
1203
- this._columns.next(Array.isArray(value) ? value : []);
2049
+ this._columnsManager.setInputColumns(Array.isArray(value) ? value : []);
1204
2050
  },
1205
2051
  enumerable: false,
1206
2052
  configurable: true
1207
2053
  });
1208
2054
  Object.defineProperty(DatatableComponent.prototype, "rows", {
1209
2055
  get: function () { return this._rows.value; },
1210
- 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
+ },
1211
2080
  enumerable: false,
1212
2081
  configurable: true
1213
2082
  });
1214
2083
  Object.defineProperty(DatatableComponent.prototype, "sorts", {
1215
- get: function () { return this.ngxDatatable ? this.ngxDatatable.sorts : this._sorts; },
2084
+ get: function () {
2085
+ return this.ngxDatatable ? this.ngxDatatable.sorts : this._sorts;
2086
+ },
1216
2087
  set: function (value) {
1217
2088
  this._sorts = utils.notNullOrUndefined(value) ? coercion.coerceArray(value) : [];
1218
2089
  },
@@ -1229,6 +2100,23 @@
1229
2100
  enumerable: false,
1230
2101
  configurable: true
1231
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
+ });
1232
2120
  Object.defineProperty(DatatableComponent.prototype, "menuBarComponent", {
1233
2121
  get: function () { return this._menuBarComponent; },
1234
2122
  set: function (value) {
@@ -1246,6 +2134,75 @@
1246
2134
  enumerable: false,
1247
2135
  configurable: true
1248
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
+ };
1249
2206
  DatatableComponent.prototype.ngOnInit = function () {
1250
2207
  var _this = this;
1251
2208
  if (this.rowDetail) {
@@ -1259,160 +2216,7 @@
1259
2216
  DatatableComponent.prototype.ngOnDestroy = function () {
1260
2217
  this._rowDetailToggleSubscription.unsubscribe();
1261
2218
  };
1262
- DatatableComponent.prototype.ngAfterContentInit = function () {
1263
- var _this = this;
1264
- var _a, _b;
1265
- 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 }));
1266
- var _columns = rxjs.combineLatest([
1267
- this.columnComponents$,
1268
- this._columns
1269
- ]).pipe(operators.map(function (v) { var _a; return _this._getMergedTplAndInpColumns(v[0], (_a = v[1]) !== null && _a !== void 0 ? _a : []); }),
1270
- // tap(v => console.log('cols', v)),
1271
- operators.shareReplay({ bufferSize: 1, refCount: true }));
1272
- this._columnsObservable.next(_columns);
1273
- };
1274
- DatatableComponent.prototype._getMergedTplAndInpColumns = function (tplCols, inpCols) {
1275
- var e_2, _h, e_3, _j;
1276
- var cols = [];
1277
- if (this.selectionType === 'checkbox') {
1278
- var checkBoxCol = {
1279
- prop: '$$__checkbox__',
1280
- name: '',
1281
- width: 40,
1282
- sortable: false,
1283
- canAutoResize: false,
1284
- draggable: false,
1285
- resizeable: false,
1286
- headerCheckboxable: true,
1287
- checkboxable: true
1288
- };
1289
- cols.push(checkBoxCol);
1290
- }
1291
- var _tplCols = ngxDatatable.translateTemplates((tplCols || []));
1292
- var _loop_1 = function (col) {
1293
- var tplCol = _tplCols.find(function (t) { return t.prop === col.prop; });
1294
- // console.log({ col: { ...(col || {}) }, tplCol: { ...(tplCol || {}) } })
1295
- var dtColumns = (this_1.ngxDatatable && this_1.ngxDatatable._internalColumns) || [];
1296
- var prev = dtColumns.find(function (c) { return c.prop === col.prop; });
1297
- var inpColDiff = this_1._getColDiff(col);
1298
- var _inpCol = inpColDiff ? {} : this_1._hasPrevColDiff(col) ? {} : col;
1299
- if (inpColDiff) {
1300
- inpColDiff.forEachRemovedItem(function (r) {
1301
- if (prev && prev.hasOwnProperty(r.key)) {
1302
- var k = r.key;
1303
- delete prev[k];
1304
- }
1305
- });
1306
- inpColDiff.forEachAddedItem(function (r) { return _inpCol[r.key] = r.currentValue; });
1307
- inpColDiff.forEachChangedItem(function (r) { return _inpCol[r.key] = r.currentValue; });
1308
- }
1309
- var _tplCol = {};
1310
- if (tplCol) {
1311
- var tplColDiff = tplCol ? this_1._getColDiff(tplCol, true) : undefined;
1312
- _tplCol = tplColDiff ? {} : this_1._hasPrevColDiff(col, true) ? {} : tplCol;
1313
- if (tplColDiff) {
1314
- tplColDiff.forEachRemovedItem(function (r) {
1315
- if (prev && prev.hasOwnProperty(r.key)) {
1316
- var k = r.key;
1317
- delete prev[k];
1318
- }
1319
- });
1320
- tplColDiff.forEachAddedItem(function (r) { return _tplCol[r.key] = r.currentValue; });
1321
- tplColDiff.forEachChangedItem(function (r) { return _tplCol[r.key] = r.currentValue; });
1322
- }
1323
- }
1324
- var _col = Object.assign(Object.assign(Object.assign({}, (prev || {})), _inpCol), _tplCol);
1325
- cols.push(_col);
1326
- };
1327
- var this_1 = this;
1328
- try {
1329
- for (var inpCols_1 = __values(inpCols), inpCols_1_1 = inpCols_1.next(); !inpCols_1_1.done; inpCols_1_1 = inpCols_1.next()) {
1330
- var col = inpCols_1_1.value;
1331
- _loop_1(col);
1332
- }
1333
- }
1334
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1335
- finally {
1336
- try {
1337
- if (inpCols_1_1 && !inpCols_1_1.done && (_h = inpCols_1.return)) _h.call(inpCols_1);
1338
- }
1339
- finally { if (e_2) throw e_2.error; }
1340
- }
1341
- if (this.rowActionItem) {
1342
- var actionMenuColumn = {
1343
- prop: '$$__actionMenu__',
1344
- name: '',
1345
- width: 50,
1346
- minWidth: 50,
1347
- maxWidth: 50,
1348
- resizeable: false,
1349
- sortable: false,
1350
- draggable: false,
1351
- // TODO: Fix column auto sizing with fixed column and cell overlay before enabling.
1352
- // frozenRight: true,
1353
- cellTemplate: this.actionMenuCellTpl,
1354
- headerTemplate: this.blankHeaderTpl
1355
- };
1356
- cols.push(actionMenuColumn);
1357
- }
1358
- try {
1359
- for (var cols_1 = __values(cols), cols_1_1 = cols_1.next(); !cols_1_1.done; cols_1_1 = cols_1.next()) {
1360
- var col = cols_1_1.value;
1361
- if (col.isTreeColumn && utils.hasProperty(col, 'treeToggleTemplate')) {
1362
- col.treeToggleTemplate = this.treeToggleTpl;
1363
- }
1364
- if (!utils.hasProperty(col, 'headerTemplate')) {
1365
- col.headerTemplate = this.headerTpl;
1366
- }
1367
- if (utils.hasProperty(col, 'cellType')) {
1368
- col.cellTemplate = this.cellTypeSelectorTpl;
1369
- }
1370
- }
1371
- }
1372
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1373
- finally {
1374
- try {
1375
- if (cols_1_1 && !cols_1_1.done && (_j = cols_1.return)) _j.call(cols_1);
1376
- }
1377
- finally { if (e_3) throw e_3.error; }
1378
- }
1379
- // setColumnDefaults(cols)
1380
- _setColumnDefaults(cols);
1381
- // console.log(cols.map(c => ({ prop: c.prop, canAutoResize: c.canAutoResize })))
1382
- return cols;
1383
- };
1384
- DatatableComponent.prototype._hasPrevColDiff = function (col, isTpl) {
1385
- if (isTpl === void 0) { isTpl = false; }
1386
- if (!col || !col.prop) {
1387
- return false;
1388
- }
1389
- var differsMap = isTpl ? this._colDiffersTpl : this._colDiffersInp;
1390
- return !!differsMap;
1391
- };
1392
- DatatableComponent.prototype._getColDiff = function (col, isTpl) {
1393
- if (isTpl === void 0) { isTpl = false; }
1394
- if (!col || !col.prop) {
1395
- return;
1396
- }
1397
- var differsMap = isTpl ? this._colDiffersTpl : this._colDiffersInp;
1398
- if (!differsMap[col.prop]) {
1399
- differsMap[col.prop] = this._differs.find({}).create();
1400
- }
1401
- var differ = differsMap[col.prop];
1402
- var diff = differ.diff(col);
1403
- return diff;
1404
- };
1405
- DatatableComponent.prototype._removeUnusedDiffs = function (cols) {
1406
- var _this = this;
1407
- var inpKeys = Object.keys(this._colDiffersInp);
1408
- inpKeys.filter(function (k) { return cols.findIndex(function (c) { return c.prop === k; }) === -1; })
1409
- .forEach(function (k) { delete _this._colDiffersInp[k]; });
1410
- var tplKeys = Object.keys(this._colDiffersTpl);
1411
- tplKeys.filter(function (k) { return cols.findIndex(function (c) { return c.prop === k; }) === -1; })
1412
- .forEach(function (k) { delete _this._colDiffersTpl[k]; });
1413
- };
1414
2219
  DatatableComponent.prototype._setMenuBarFilters = function (filters) {
1415
- // console.log('_setMenuBarFilters', filters)
1416
2220
  this._filtersSubject.next(filters || []);
1417
2221
  };
1418
2222
  DatatableComponent.prototype.getColumnComponent = function (propName) {
@@ -1446,21 +2250,50 @@
1446
2250
  }
1447
2251
  };
1448
2252
  DatatableComponent.prototype._onResize = function (event) {
1449
- // console.log('resize', event, event.column.prop)
1450
2253
  this.resize.emit(event);
1451
- if (event.isDone && this.columns) {
1452
- var columns = this.columns;
1453
- var col = columns.find(function (c) { return c.prop === event.column.prop; });
1454
- if (col) {
1455
- 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;
1456
2263
  }
1457
- if (this.preferencesKey) {
1458
- var pref = { prop: event.column.prop, width: event.column.width, canAutoResize: false };
1459
- this._preferences.setColumnPreference(this.preferencesKey, pref);
2264
+ if (event.isDone) {
2265
+ this._resizing[columnProp] = false;
2266
+ addAlteration = true;
1460
2267
  }
1461
- 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]);
1462
2290
  }
1463
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
+ };
1464
2297
  DatatableComponent.prototype._onTreeAction = function (event) {
1465
2298
  var index = event.rowIndex;
1466
2299
  var row = event.row;
@@ -1476,6 +2309,9 @@
1476
2309
  this.actionRefreshRequest.emit(undefined);
1477
2310
  };
1478
2311
  Object.defineProperty(DatatableComponent.prototype, "pageInfo", {
2312
+ /**
2313
+ * Returns the page info from the wrapped NgxDatatable instance or defaults.
2314
+ */
1479
2315
  get: function () {
1480
2316
  var _a, _b, _c, _d, _e, _f, _g;
1481
2317
  return {
@@ -1493,7 +2329,7 @@
1493
2329
  DatatableComponent.decorators = [
1494
2330
  { type: i0.Component, args: [{
1495
2331
  selector: 'seam-datatable',
1496
- 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)=\"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-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\"></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",
1497
2333
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1498
2334
  animations: [
1499
2335
  animations.trigger('slideDown', [
@@ -1507,14 +2343,20 @@
1507
2343
  ])
1508
2344
  ])
1509
2345
  ],
1510
- providers: [_THESEAM_DATATABLE, DatatableColumnChangesService, _THESEAM_DATATABLE_ACCESSOR],
1511
- 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}.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"]
1512
2354
  },] }
1513
2355
  ];
1514
2356
  DatatableComponent.ctorParameters = function () { return [
1515
- { type: DatatableColumnChangesService },
1516
- { type: i0.KeyValueDiffers },
1517
- { type: DatatablePreferencesService }
2357
+ { type: DatatablePreferencesService },
2358
+ { type: ColumnsManagerService },
2359
+ { type: ColumnsAlterationsManagerService }
1518
2360
  ]; };
1519
2361
  DatatableComponent.propDecorators = {
1520
2362
  preferencesKey: [{ type: i0.Input }],
@@ -1582,7 +2424,8 @@
1582
2424
  treeToggleTpl: [{ type: i0.ViewChild, args: ['treeToggleTpl', { static: true },] }],
1583
2425
  headerTpl: [{ type: i0.ViewChild, args: ['headerTpl', { static: true },] }],
1584
2426
  blankHeaderTpl: [{ type: i0.ViewChild, args: ['blankHeaderTpl', { static: true },] }],
1585
- 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'],] }]
1586
2429
  };
1587
2430
  __decorate([
1588
2431
  core.InputBoolean()
@@ -1643,63 +2486,117 @@
1643
2486
  ], DatatableComponent.prototype, "scrollbarH", void 0);
1644
2487
 
1645
2488
  var DatatableColumnPreferencesComponent = /** @class */ (function () {
1646
- function DatatableColumnPreferencesComponent(_datatable) {
2489
+ function DatatableColumnPreferencesComponent(_datatable, _columnsAlterationsManager) {
2490
+ var _this = this;
1647
2491
  var _a;
1648
2492
  this._datatable = _datatable;
2493
+ this._columnsAlterationsManager = _columnsAlterationsManager;
1649
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
+ };
1650
2500
  this._columns$ = rxjs.combineLatest([
1651
2501
  (_a = this._datatable.columns$) !== null && _a !== void 0 ? _a : rxjs.of([]),
1652
2502
  utils.observeControlValue(this._filterControl)
1653
2503
  ]).pipe(operators.map(function (_b) {
1654
2504
  var _c = __read(_b, 2), columns = _c[0], filter = _c[1];
1655
2505
  var _filter = (filter || '').trim().toLowerCase();
1656
- return columns.filter(function (c) { return ("" + (c.name || c.prop || '')).toLowerCase().indexOf(_filter) !== -1; });
1657
- }), 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
+ }));
1658
2510
  }
1659
- DatatableColumnPreferencesComponent.prototype.ngOnInit = function () { };
1660
- DatatableColumnPreferencesComponent.prototype._onChange = function (event, col) {
1661
- // TODO: Figure out the right way to update this value. If it is set by
1662
- // column component input this may not work right.
1663
- var columns = this._datatable.columns || [];
1664
- var column = columns.find(function (c) { return c.prop === col.prop; });
1665
- if (column) {
1666
- column.hidden = !event.checked;
1667
- 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;
1668
2521
  }
2522
+ return ("" + (getColumnProp(column) || '')).toLowerCase().indexOf(filter) !== -1;
1669
2523
  };
1670
- DatatableColumnPreferencesComponent.prototype._onCloseClick = function () {
1671
- // 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]);
1672
2535
  };
1673
2536
  return DatatableColumnPreferencesComponent;
1674
2537
  }());
1675
2538
  DatatableColumnPreferencesComponent.decorators = [
1676
2539
  { type: i0.Component, args: [{
1677
2540
  selector: 'seam-datatable-column-preferences',
1678
- 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",
1679
2542
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1680
- styles: [":host{display:flex;flex-direction:column}"]
2543
+ styles: [":host{display:flex;flex-direction:column}\n"]
1681
2544
  },] }
1682
2545
  ];
1683
2546
  DatatableColumnPreferencesComponent.ctorParameters = function () { return [
1684
- { type: DatatableComponent, decorators: [{ type: i0.Inject, args: [THESEAM_DATATABLE,] }] }
2547
+ { type: DatatableComponent, decorators: [{ type: i0.Inject, args: [THESEAM_DATATABLE,] }] },
2548
+ { type: ColumnsAlterationsManagerService }
1685
2549
  ]; };
1686
2550
 
1687
2551
  var DatatableColumnPreferencesButtonComponent = /** @class */ (function () {
1688
- function DatatableColumnPreferencesButtonComponent() {
2552
+ function DatatableColumnPreferencesButtonComponent(_columnsAlterationsManager) {
2553
+ this._columnsAlterationsManager = _columnsAlterationsManager;
1689
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
+ ];
1690
2582
  }
1691
2583
  DatatableColumnPreferencesButtonComponent.prototype.ngOnInit = function () { };
2584
+ DatatableColumnPreferencesButtonComponent.prototype._resetColumns = function (event) {
2585
+ this._columnsAlterationsManager.clear();
2586
+ };
1692
2587
  return DatatableColumnPreferencesButtonComponent;
1693
2588
  }());
1694
2589
  DatatableColumnPreferencesButtonComponent.decorators = [
1695
2590
  { type: i0.Component, args: [{
1696
2591
  selector: 'seam-datatable-column-preferences-button',
1697
- 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",
1698
2593
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1699
2594
  styles: [""]
1700
2595
  },] }
1701
2596
  ];
1702
- DatatableColumnPreferencesButtonComponent.ctorParameters = function () { return []; };
2597
+ DatatableColumnPreferencesButtonComponent.ctorParameters = function () { return [
2598
+ { type: ColumnsAlterationsManagerService }
2599
+ ]; };
1703
2600
 
1704
2601
  var DatatableExportButtonComponent = /** @class */ (function () {
1705
2602
  function DatatableExportButtonComponent(_datatable, _toastr, _loading, _valueHelper, _data) {
@@ -1729,12 +2626,14 @@
1729
2626
  : exporter.label + " export is not available.";
1730
2627
  this._toastr.error(msg, 'Data Export');
1731
2628
  }
1732
- var export$ = this._datatable.rows$
1733
- .pipe(operators.take(1), operators.map(function (rows) {
2629
+ var export$ = rxjs.combineLatest([
2630
+ this._datatable.rows$, this._datatable.columns$
2631
+ ]).pipe(operators.take(1), operators.map(function (_a) {
2632
+ var _b = __read(_a, 2), rows = _b[0], columns = _b[1];
1734
2633
  if (exporter.skipDataMapping) {
1735
2634
  return rows;
1736
2635
  }
1737
- return _this._mapExportData(_this._datatable.columns || [], rows);
2636
+ return _this._mapExportData(columns || [], rows);
1738
2637
  }), operators.concatMap(function (data) { return exporter.export(data); }), operators.catchError(function (err) {
1739
2638
  console.error(err);
1740
2639
  return rxjs.of(false);
@@ -1803,7 +2702,7 @@
1803
2702
  selector: 'seam-datatable-export-button',
1804
2703
  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",
1805
2704
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1806
- styles: [":host{display:inline-block}"]
2705
+ styles: [":host{display:inline-block}\n"]
1807
2706
  },] }
1808
2707
  ];
1809
2708
  DatatableExportButtonComponent.ctorParameters = function () { return [
@@ -1829,7 +2728,7 @@
1829
2728
  selector: 'seam-datatable-menu-bar-column-center',
1830
2729
  template: "<ng-content></ng-content>\n",
1831
2730
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1832
- styles: [":host{display:flex;flex-direction:row;flex:1 1 auto;justify-content:center}"]
2731
+ styles: [":host{display:flex;flex-direction:row;flex:1 1 auto;justify-content:center}\n"]
1833
2732
  },] }
1834
2733
  ];
1835
2734
  DatatableMenuBarColumnCenterComponent.ctorParameters = function () { return []; };
@@ -1846,7 +2745,7 @@
1846
2745
  selector: 'seam-datatable-menu-bar-column-left',
1847
2746
  template: "<ng-content></ng-content>\n",
1848
2747
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1849
- styles: [":host{display:flex;flex-direction:row;flex:1 1 0%;justify-content:flex-start}"]
2748
+ styles: [":host{display:flex;flex-direction:row;flex:1 1 0%;justify-content:flex-start}\n"]
1850
2749
  },] }
1851
2750
  ];
1852
2751
  DatatableMenuBarColumnLeftComponent.ctorParameters = function () { return []; };
@@ -1863,7 +2762,7 @@
1863
2762
  selector: 'seam-datatable-menu-bar-column-right',
1864
2763
  template: "<ng-content></ng-content>\n",
1865
2764
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1866
- styles: [":host{display:flex;flex-direction:row;flex:1 1 0%;justify-content:flex-end}"]
2765
+ styles: [":host{display:flex;flex-direction:row;flex:1 1 0%;justify-content:flex-end}\n"]
1867
2766
  },] }
1868
2767
  ];
1869
2768
  DatatableMenuBarColumnRightComponent.ctorParameters = function () { return []; };
@@ -1880,7 +2779,7 @@
1880
2779
  selector: 'seam-datatable-menu-bar-row',
1881
2780
  template: "<ng-content></ng-content>\n",
1882
2781
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
1883
- styles: [":host{display:flex;flex-direction:row;flex-wrap:wrap}"]
2782
+ styles: [":host{display:flex;flex-direction:row;flex-wrap:wrap}\n"]
1884
2783
  },] }
1885
2784
  ];
1886
2785
  DatatableMenuBarRowComponent.ctorParameters = function () { return []; };
@@ -2158,6 +3057,39 @@
2158
3057
  { type: scrollbar.OverlayScrollbarsService }
2159
3058
  ]; };
2160
3059
 
3060
+ function withStoredColumnInfo(columns, preferenceColumns) {
3061
+ var e_1, _a;
3062
+ var _columns = [];
3063
+ var _loop_1 = function (col) {
3064
+ var storedCol = preferenceColumns.find(function (v) { return v.prop === col.prop; });
3065
+ if (storedCol) {
3066
+ var _col = Object.assign({}, col);
3067
+ if (utils.hasProperty(storedCol, 'width')) {
3068
+ _col.width = Math.max(storedCol.width, 0);
3069
+ }
3070
+ _col.canAutoResize = storedCol.canAutoResize;
3071
+ _columns.push(_col);
3072
+ }
3073
+ else {
3074
+ _columns.push(col);
3075
+ }
3076
+ };
3077
+ try {
3078
+ for (var columns_1 = __values(columns), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
3079
+ var col = columns_1_1.value;
3080
+ _loop_1(col);
3081
+ }
3082
+ }
3083
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3084
+ finally {
3085
+ try {
3086
+ if (columns_1_1 && !columns_1_1.done && (_a = columns_1.return)) _a.call(columns_1);
3087
+ }
3088
+ finally { if (e_1) throw e_1.error; }
3089
+ }
3090
+ return _columns;
3091
+ }
3092
+
2161
3093
  var TheSeamDatatableModule = /** @class */ (function () {
2162
3094
  function TheSeamDatatableModule() {
2163
3095
  }
@@ -2248,6 +3180,7 @@
2248
3180
  * Generated bundle index. Do not edit.
2249
3181
  */
2250
3182
 
3183
+ exports.CURRENT_DATATABLE_PREFERENCES_VERSION = CURRENT_DATATABLE_PREFERENCES_VERSION;
2251
3184
  exports.DatatableActionMenuComponent = DatatableActionMenuComponent;
2252
3185
  exports.DatatableActionMenuItemComponent = DatatableActionMenuItemComponent;
2253
3186
  exports.DatatableActionMenuItemDirective = DatatableActionMenuItemDirective;
@@ -2272,6 +3205,7 @@
2272
3205
  exports.DatatablePreferencesService = DatatablePreferencesService;
2273
3206
  exports.DatatableRowActionItemDirective = DatatableRowActionItemDirective;
2274
3207
  exports.DatatableRowDetailTplDirective = DatatableRowDetailTplDirective;
3208
+ exports.EMPTY_DATATABLE_PREFERENCES = EMPTY_DATATABLE_PREFERENCES;
2275
3209
  exports.THESEAM_DATATABLE = THESEAM_DATATABLE;
2276
3210
  exports.THESEAM_DATATABLE_PREFERENCES_ACCESSOR = THESEAM_DATATABLE_PREFERENCES_ACCESSOR;
2277
3211
  exports.THESEAM_MENUBAR_ITEM_DATA = THESEAM_MENUBAR_ITEM_DATA;
@@ -2282,11 +3216,12 @@
2282
3216
  exports._THESEAM_DATATABLE = _THESEAM_DATATABLE;
2283
3217
  exports._THESEAM_DATATABLE_ACCESSOR = _THESEAM_DATATABLE_ACCESSOR;
2284
3218
  exports._THESEAM_DATA_FILTER_CONTAINER = _THESEAM_DATA_FILTER_CONTAINER;
2285
- exports._setColumnDefaults = _setColumnDefaults;
2286
3219
  exports.withStoredColumnInfo = withStoredColumnInfo;
2287
- exports.ɵa = THESEAM_DATATABLE_ACCESSOR;
3220
+ exports["ɵa"] = THESEAM_DATATABLE_ACCESSOR;
3221
+ exports["ɵb"] = ColumnsManagerService;
3222
+ exports["ɵc"] = ColumnsAlterationsManagerService;
2288
3223
 
2289
3224
  Object.defineProperty(exports, '__esModule', { value: true });
2290
3225
 
2291
- })));
3226
+ }));
2292
3227
  //# sourceMappingURL=theseam-ui-common-datatable.umd.js.map