@xh/hoist 79.0.0-SNAPSHOT.1765207418027 → 79.0.0-SNAPSHOT.1765207715965

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.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,7 @@
10
10
 
11
11
  ### 🐞 Bug Fixes
12
12
 
13
+ * Fixed column chooser to display columns in the same order as they appear in the grid.
13
14
  * Defaulted Highcharts font to Hoist default (--xh-font-family)
14
15
  * Tweaked `GridFindField` to forward a provided `ref` to its underlying `TextInput`.
15
16
 
@@ -1,5 +1,5 @@
1
- import { GridModel } from '@xh/hoist/cmp/grid';
2
- import { HoistModel, HSide } from '@xh/hoist/core';
1
+ import { GridModel, GridSorterLike } from '@xh/hoist/cmp/grid';
2
+ import { HoistModel, HSide, Some } from '@xh/hoist/core';
3
3
  import '@xh/hoist/desktop/register';
4
4
  import { FilterTestFn, StoreRecord } from '@xh/hoist/data';
5
5
  export interface LeftRightChooserConfig {
@@ -14,11 +14,13 @@ export interface LeftRightChooserConfig {
14
14
  showCounts?: boolean;
15
15
  leftTitle?: string;
16
16
  leftSorted?: boolean;
17
+ leftSortBy?: Some<GridSorterLike>;
17
18
  leftGroupingEnabled?: boolean;
18
19
  leftGroupingExpanded?: boolean;
19
20
  leftEmptyText?: string;
20
21
  rightTitle?: string;
21
22
  rightSorted?: boolean;
23
+ rightSortBy?: Some<GridSorterLike>;
22
24
  rightGroupingEnabled?: boolean;
23
25
  rightGroupingExpanded?: boolean;
24
26
  rightEmptyText?: string;
@@ -39,6 +41,7 @@ export interface LeftRightChooserItem {
39
41
  /** True to prevent the user from moving the item between sides. */
40
42
  locked?: boolean;
41
43
  exclude?: boolean;
44
+ sortValue?: any;
42
45
  }
43
46
  /**
44
47
  * A Model for managing the state of a LeftRightChooser.
@@ -72,7 +75,7 @@ export declare class LeftRightChooserModel extends HoistModel {
72
75
  get rightValues(): any[];
73
76
  /** Currently 'selected' values on the left hand side. */
74
77
  get leftValues(): any[];
75
- constructor({ data, onChange, ungroupedName, leftTitle, leftSorted, leftGroupingEnabled, leftGroupingExpanded, leftEmptyText, readonly, rightTitle, rightSorted, rightGroupingEnabled, rightGroupingExpanded, rightEmptyText, showCounts, xhImpl }: LeftRightChooserConfig);
78
+ constructor({ data, onChange, ungroupedName, leftTitle, leftSorted, leftSortBy, leftGroupingEnabled, leftGroupingExpanded, leftEmptyText, readonly, rightTitle, rightSorted, rightSortBy, rightGroupingEnabled, rightGroupingExpanded, rightEmptyText, showCounts, xhImpl }: LeftRightChooserConfig);
76
79
  setData(data: LeftRightChooserItem[]): void;
77
80
  moveRows(rows: StoreRecord[]): void;
78
81
  private getTextColRenderer;
@@ -8,6 +8,7 @@ import {GridModel} from '@xh/hoist/cmp/grid';
8
8
  import {HoistModel, managed} from '@xh/hoist/core';
9
9
  import {LeftRightChooserModel} from '@xh/hoist/desktop/cmp/leftrightchooser';
10
10
  import {action, makeObservable, observable} from '@xh/hoist/mobx';
11
+ import {sortBy} from 'lodash';
11
12
 
12
13
  /**
13
14
  * State management for the ColChooser component.
@@ -55,6 +56,8 @@ export class ColChooserModel extends HoistModel {
55
56
  rightTitle: 'Displayed Columns',
56
57
  rightEmptyText: 'No columns will be visible.',
57
58
  leftSorted: true,
59
+ leftSortBy: 'text',
60
+ rightSorted: true,
58
61
  rightGroupingEnabled: false,
59
62
  onChange: () => {
60
63
  if (this.commitOnChange) this.commit();
@@ -111,19 +114,33 @@ export class ColChooserModel extends HoistModel {
111
114
  //------------------------
112
115
  syncChooserData() {
113
116
  const {gridModel, lrModel} = this,
114
- columns = gridModel.getLeafColumns(),
115
- hasGrouping = columns.some(it => it.chooserGroup);
117
+ hasGrouping = gridModel.getLeafColumns().some(it => it.chooserGroup),
118
+ columnState = sortBy(gridModel.columnState, it => {
119
+ const {pinned} = it;
120
+ if (pinned === 'left') {
121
+ return 0;
122
+ }
123
+
124
+ if (pinned === 'right') {
125
+ return 2;
126
+ }
127
+
128
+ return 1;
129
+ });
130
+
131
+ const data = columnState.map((it, idx) => {
132
+ const visible = !it.hidden,
133
+ col = gridModel.getColumn(it.colId);
116
134
 
117
- const data = columns.map(it => {
118
- const visible = gridModel.isColumnVisible(it.colId);
119
135
  return {
120
136
  value: it.colId,
121
- text: it.chooserName,
122
- description: it.chooserDescription,
123
- group: hasGrouping ? (it.chooserGroup ?? 'Ungrouped') : null,
124
- exclude: it.excludeFromChooser,
125
- locked: visible && !it.hideable,
126
- side: visible ? 'right' : 'left'
137
+ text: col.chooserName,
138
+ description: col.chooserDescription,
139
+ group: hasGrouping ? (col.chooserGroup ?? 'Ungrouped') : null,
140
+ exclude: col.excludeFromChooser,
141
+ locked: visible && !col.hideable,
142
+ side: visible ? 'right' : 'left',
143
+ sortValue: idx
127
144
  } as const;
128
145
  });
129
146
 
@@ -4,9 +4,9 @@
4
4
  *
5
5
  * Copyright © 2025 Extremely Heavy Industries Inc.
6
6
  */
7
- import {GridModel} from '@xh/hoist/cmp/grid';
7
+ import {GridModel, GridSorterLike} from '@xh/hoist/cmp/grid';
8
8
  import {div} from '@xh/hoist/cmp/layout';
9
- import {HoistModel, HSide, managed, XH} from '@xh/hoist/core';
9
+ import {HoistModel, HSide, managed, Some, XH} from '@xh/hoist/core';
10
10
  import '@xh/hoist/desktop/register';
11
11
  import {Icon} from '@xh/hoist/icon';
12
12
  import {bindable, computed, makeObservable} from '@xh/hoist/mobx';
@@ -29,12 +29,14 @@ export interface LeftRightChooserConfig {
29
29
 
30
30
  leftTitle?: string;
31
31
  leftSorted?: boolean;
32
+ leftSortBy?: Some<GridSorterLike>;
32
33
  leftGroupingEnabled?: boolean;
33
34
  leftGroupingExpanded?: boolean;
34
35
  leftEmptyText?: string;
35
36
 
36
37
  rightTitle?: string;
37
38
  rightSorted?: boolean;
39
+ rightSortBy?: Some<GridSorterLike>;
38
40
  rightGroupingEnabled?: boolean;
39
41
  rightGroupingExpanded?: boolean;
40
42
  rightEmptyText?: string;
@@ -64,6 +66,9 @@ export interface LeftRightChooserItem {
64
66
 
65
67
  /* True to exclude the item from the chooser entirely. */
66
68
  exclude?: boolean;
69
+
70
+ /* Value to use for sorting. If unset then sort order will be based solely on the text value. */
71
+ sortValue?: any;
67
72
  }
68
73
 
69
74
  /**
@@ -122,12 +127,14 @@ export class LeftRightChooserModel extends HoistModel {
122
127
  ungroupedName = 'Ungrouped',
123
128
  leftTitle = 'Available',
124
129
  leftSorted = false,
130
+ leftSortBy = ['sortValue', 'text'],
125
131
  leftGroupingEnabled = true,
126
132
  leftGroupingExpanded = true,
127
133
  leftEmptyText = null,
128
134
  readonly = false,
129
135
  rightTitle = 'Selected',
130
136
  rightSorted = false,
137
+ rightSortBy = ['sortValue', 'text'],
131
138
  rightGroupingEnabled = true,
132
139
  rightGroupingExpanded = true,
133
140
  rightEmptyText = null,
@@ -154,7 +161,8 @@ export class LeftRightChooserModel extends HoistModel {
154
161
  {name: 'group', type: 'string'},
155
162
  {name: 'side', type: 'string'},
156
163
  {name: 'locked', type: 'bool'},
157
- {name: 'exclude', type: 'bool'}
164
+ {name: 'exclude', type: 'bool'},
165
+ {name: 'sortValue'}
158
166
  ]
159
167
  };
160
168
 
@@ -179,15 +187,19 @@ export class LeftRightChooserModel extends HoistModel {
179
187
  field: 'group',
180
188
  headerName: 'Group',
181
189
  hidden: true
190
+ },
191
+ sortValueCol = {
192
+ field: 'sortValue',
193
+ hidden: true
182
194
  };
183
195
 
184
196
  this.leftModel = new GridModel({
185
197
  store,
186
198
  selModel: 'multiple',
187
- sortBy: leftSorted ? 'text' : null,
199
+ sortBy: leftSorted ? leftSortBy : null,
188
200
  emptyText: leftEmptyText,
189
201
  onRowDoubleClicked: e => this.onRowDoubleClicked(e),
190
- columns: [leftTextCol, groupCol],
202
+ columns: [leftTextCol, groupCol, sortValueCol],
191
203
  contextMenu: false,
192
204
  expandLevel: leftGroupingExpanded ? 1 : 0,
193
205
  xhImpl: true
@@ -196,10 +208,10 @@ export class LeftRightChooserModel extends HoistModel {
196
208
  this.rightModel = new GridModel({
197
209
  store,
198
210
  selModel: 'multiple',
199
- sortBy: rightSorted ? 'text' : null,
211
+ sortBy: rightSorted ? rightSortBy : null,
200
212
  emptyText: rightEmptyText,
201
213
  onRowDoubleClicked: e => this.onRowDoubleClicked(e),
202
- columns: [rightTextCol, groupCol],
214
+ columns: [rightTextCol, groupCol, sortValueCol],
203
215
  contextMenu: false,
204
216
  expandLevel: rightGroupingExpanded ? 1 : 0,
205
217
  xhImpl: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "79.0.0-SNAPSHOT.1765207418027",
3
+ "version": "79.0.0-SNAPSHOT.1765207715965",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",