@skyux/ag-grid 14.19.0 → 14.20.0

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.
@@ -87,6 +87,56 @@ const RESOURCES = {
87
87
  sky_ag_grid_locale_no_rows_to_show: { message: 'No data available' },
88
88
  sky_ag_grid_locale_no_matching_rows: { message: 'No matching rows' },
89
89
  },
90
+ ES: {
91
+ sky_ag_grid_row_selector_aria_label: {
92
+ message: 'Selector de fila para la fila {0}',
93
+ },
94
+ sky_ag_grid_row_selector_column_heading: { message: 'Selección de filas' },
95
+ sky_ag_grid_cell_editor_datepicker_aria_label: {
96
+ message: 'Fecha editable {0} para la fila {1}',
97
+ },
98
+ sky_ag_grid_cell_editor_datepicker_hint_text: {
99
+ message: 'Utilice el formato {0}.',
100
+ },
101
+ sky_ag_grid_cell_editor_number_aria_label: {
102
+ message: 'Número editable {0} para la fila {1}',
103
+ },
104
+ sky_ag_grid_cell_editor_text_aria_label: {
105
+ message: 'Texto editable {0} para la fila {1}',
106
+ },
107
+ sky_ag_grid_cell_editor_autocomplete_aria_label: {
108
+ message: 'Autocompletado editable {0} para la fila {1}',
109
+ },
110
+ sky_ag_grid_cell_renderer_number_validator_message: {
111
+ message: 'Introduzca un número válido.',
112
+ },
113
+ sky_ag_grid_cell_renderer_currency_validator_message: {
114
+ message: 'Introduzca un valor de moneda válido.',
115
+ },
116
+ skyux_lookup_tokens_summary: { message: '{0} artículos seleccionados' },
117
+ sky_ag_grid_cell_editor_currency_aria_label: {
118
+ message: 'Valor de moneda editable {0} para la fila {1}',
119
+ },
120
+ sky_ag_grid_column_header_sort_button_aria_label_currently_asc: {
121
+ message: 'Ordenar columna {0}, actualmente en orden ascendente',
122
+ },
123
+ sky_ag_grid_column_header_sort_button_aria_label_currently_desc: {
124
+ message: 'Ordenar columna {0}, actualmente en orden descendente',
125
+ },
126
+ sky_ag_grid_column_header_sort_button_aria_label_currently_not_sorted: {
127
+ message: 'Ordenar columna {0}, actualmente sin ordenar',
128
+ },
129
+ sky_ag_grid_column_group_header_expand_aria_label: {
130
+ message: 'Expandir grupo de columnas {0}',
131
+ },
132
+ sky_ag_grid_column_group_header_collapse_aria_label: {
133
+ message: 'Contraer grupo de columnas {0}',
134
+ },
135
+ sky_ag_grid_locale_no_rows_to_show: { message: 'No hay datos disponibles' },
136
+ sky_ag_grid_locale_no_matching_rows: {
137
+ message: 'No hay filas coincidentes',
138
+ },
139
+ },
90
140
  'FR-CA': {
91
141
  sky_ag_grid_row_selector_aria_label: {
92
142
  message: 'Sélecteur de ligne pour la ligne {0}',
@@ -889,24 +939,33 @@ class SkyAgGridDataManagerAdapterDirective {
889
939
  gridColumnStates?.find((aGridColumnState) => aGridColumnState.sort);
890
940
  if (viewConfig && this.#currentDataState) {
891
941
  const newState = new SkyDataManagerState(this.#currentDataState.getStateOptions());
892
- if (activeSortColumnState) {
893
- const activeSortColumnDef = agGrid.api.getColumnDef(activeSortColumnState.colId);
894
- newState.activeSortOption = {
895
- descending: activeSortColumnState.sort === 'desc',
896
- id: activeSortColumnState.colId,
897
- propertyName: activeSortColumnDef?.field || '',
898
- label: activeSortColumnDef?.headerName || '',
899
- };
900
- }
901
- else {
902
- newState.activeSortOption = undefined;
903
- }
942
+ newState.activeSortOption = activeSortColumnState
943
+ ? this.#resolveActiveSortOption(agGrid.api, activeSortColumnState)
944
+ : undefined;
904
945
  this.#currentDataState = newState;
905
946
  this.#dataManagerSvc.updateDataState(newState, viewConfig.id);
906
947
  }
907
948
  });
908
949
  }
909
950
  }
951
+ #resolveActiveSortOption(api, activeSortColumnState) {
952
+ const activeSortColumnDef = api.getColumnDef(activeSortColumnState.colId);
953
+ const descending = activeSortColumnState.sort === 'desc';
954
+ const propertyName = activeSortColumnDef?.field || activeSortColumnState.colId;
955
+ // Prefer the configured sort option matching this column and direction
956
+ // so the sort menu's selected item stays in sync; columns without a
957
+ // matching option fall back to a column-derived sort option.
958
+ const matchingSortOption = this.#dataManagerSvc
959
+ .getCurrentDataManagerConfig()
960
+ .sortOptions?.find((option) => option.propertyName === propertyName &&
961
+ !!option.descending === descending);
962
+ return (matchingSortOption ?? {
963
+ descending,
964
+ id: activeSortColumnState.colId,
965
+ propertyName,
966
+ label: activeSortColumnDef?.headerName || '',
967
+ });
968
+ }
910
969
  #updateColumnsInCurrentDataState(api) {
911
970
  const viewConfig = this.#viewConfig();
912
971
  if (viewConfig && this.#currentDataState) {
@@ -959,17 +1018,30 @@ class SkyAgGridDataManagerAdapterDirective {
959
1018
  const agGridApi = this.#currentAgGrid()?.api;
960
1019
  const activeSort = dataState.activeSortOption;
961
1020
  if (agGridApi && activeSort) {
962
- agGridApi.applyColumnState({
963
- state: [
964
- {
965
- colId: activeSort.id,
966
- sort: activeSort.descending ? 'desc' : 'asc',
967
- },
968
- ],
969
- defaultState: { sort: null },
970
- });
1021
+ const colId = this.#resolveSortColumnId(agGridApi, activeSort);
1022
+ if (colId) {
1023
+ agGridApi.applyColumnState({
1024
+ state: [
1025
+ {
1026
+ colId,
1027
+ sort: activeSort.descending ? 'desc' : 'asc',
1028
+ },
1029
+ ],
1030
+ defaultState: { sort: null },
1031
+ });
1032
+ }
971
1033
  }
972
1034
  }
1035
+ #resolveSortColumnId(api, activeSort) {
1036
+ const columnStates = api.getColumnState();
1037
+ const findColId = (predicate) => columnStates.find(predicate)?.colId;
1038
+ // Match on the option's data property first, since a sort option's ID is
1039
+ // arbitrary and could otherwise select an unrelated column. Only fall
1040
+ // back to the legacy ID match for options predating the property lookup.
1041
+ return (findColId((state) => api.getColumnDef(state.colId)?.field === activeSort.propertyName) ??
1042
+ findColId((state) => state.colId === activeSort.propertyName) ??
1043
+ findColId((state) => state.colId === activeSort.id));
1044
+ }
973
1045
  #updateColumnWidth(colId, width, breakpoint) {
974
1046
  const viewId = this.viewId();
975
1047
  const viewState = viewId && this.#currentDataState?.getViewStateById(viewId);