cx 26.7.5 → 26.7.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "26.7.5",
3
+ "version": "26.7.6",
4
4
  "description": "Advanced JavaScript UI framework for admin and dashboard applications with ready to use grid, form and chart components.",
5
5
  "exports": {
6
6
  "./data": {
@@ -919,10 +919,13 @@ export class Grid<T = unknown> extends ContainerBase<GridConfig<T>, GridInstance
919
919
 
920
920
  let sortField = null;
921
921
 
922
- if (isDefined(this.sortField) && isDefined(this.sortDirection)) {
922
+ // rebuild sorters from the sortField/sortDirection bindings only if a sort field
923
+ // is actually set; sorts identified by a value selector (columns without a field)
924
+ // live in data.sorters/state.sorters and cannot round-trip through a field name
925
+ if (isDefined(this.sortField) && isDefined(this.sortDirection) && data.sortField) {
923
926
  let sorter = {
924
927
  field: data.sortField,
925
- direction: data.sortDirection,
928
+ direction: data.sortDirection || "ASC",
926
929
  };
927
930
  sortField = data.sortField;
928
931
  data.sorters = [sorter];
@@ -939,11 +942,11 @@ export class Grid<T = unknown> extends ContainerBase<GridConfig<T>, GridInstance
939
942
  }
940
943
 
941
944
  if (sortField) {
942
- for (let l = 1; l < 10; l++) {
945
+ for (let l = 0; l < 10; l++) {
943
946
  let line = instance.row[`line${l}`];
944
- let sortColumn = line && line.columns && line.columns.find((c: any) => c.field == sortField);
947
+ let sortColumn = line && line.columns && line.columns.find((c: any) => (c.sortField || c.field) == sortField);
945
948
  if (sortColumn) {
946
- data.sorters[0].value = sortColumn.sortValue || sortColumn.value;
949
+ data.sorters[0].value = isDefined(sortColumn.sortValue) ? sortColumn.sortValue : sortColumn.value;
947
950
  data.sorters[0].comparer = sortColumn.comparer;
948
951
  data.sorters[0].sortOptions = sortColumn.sortOptions;
949
952
  break;
@@ -1307,8 +1310,18 @@ export class Grid<T = unknown> extends ContainerBase<GridConfig<T>, GridInstance
1307
1310
 
1308
1311
  if (hdwidget.sortable && header.widget.allowSorting) {
1309
1312
  mods.push("sortable");
1310
- if (data.sorters && data.sorters[0].field == (hdwidget.sortField || hdwidget.field)) {
1311
- mods.push("sorted-" + data.sorters[0].direction.toLowerCase());
1313
+ let sorter = data.sorters && data.sorters[0];
1314
+ let sortColumnField = hdwidget.sortField || hdwidget.field;
1315
+ let sortColumnValue = isDefined(hdwidget.sortValue) ? hdwidget.sortValue : hdwidget.value;
1316
+ // a sort is identified by its (field, value selector) pair, so columns
1317
+ // sorting by the same field through different value selectors don't both match
1318
+ let sorted =
1319
+ sorter &&
1320
+ !!sorter.direction &&
1321
+ (sortColumnField ? sorter.field == sortColumnField : !sorter.field && isDefined(sortColumnValue)) &&
1322
+ sorter.value === sortColumnValue;
1323
+ if (sorted) {
1324
+ mods.push("sorted-" + sorter.direction.toLowerCase());
1312
1325
  sortIcon = <DropDownIcon className={CSS.element(baseClass, "column-sort-icon")} />;
1313
1326
  }
1314
1327
  }
@@ -1481,17 +1494,16 @@ export class Grid<T = unknown> extends ContainerBase<GridConfig<T>, GridInstance
1481
1494
  let header = column.components[`header${headerLine + 1}`];
1482
1495
 
1483
1496
  let field = column.sortField || column.field;
1484
- let value = column.sortValue || column.value;
1497
+ let value = isDefined(column.sortValue) ? column.sortValue : column.value;
1485
1498
  let comparer = column.comparer;
1486
1499
  let sortOptions = column.sortOptions;
1487
1500
 
1488
- if (header && header.allowSorting && column.sortable && (field || value || data.sortField)) {
1501
+ if (header && header.allowSorting && column.sortable && (field || isDefined(value))) {
1489
1502
  let direction = column.primarySortDirection ?? "ASC";
1490
- if (
1491
- isNonEmptyArray(data.sorters) &&
1492
- ((!!data.sorters[0].field && data.sorters[0].field == (field || data.sortField)) ||
1493
- (!!value && data.sorters[0].value == value))
1494
- ) {
1503
+ // the column matches the active sorter only if both the field and the value
1504
+ // selector are the same; two columns may sort by the same field through
1505
+ // different value selectors and represent different sorts
1506
+ if (isNonEmptyArray(data.sorters) && data.sorters[0].field == field && data.sorters[0].value === value) {
1495
1507
  if (data.sorters[0].direction == "ASC" && (!this.clearableSort || direction == "ASC")) direction = "DESC";
1496
1508
  else if (data.sorters[0].direction == "DESC" && (!this.clearableSort || direction == "DESC"))
1497
1509
  direction = "ASC";
@@ -1,63 +1,41 @@
1
- import { Widget } from "../ui/Widget";
2
- import { Text } from "../ui/Text";
3
- import { StaticText } from "../ui/StaticText";
4
- import { PureContainer } from "../ui/PureContainer";
5
- import { IsolatedScope } from "../ui/IsolatedScope";
6
- import { DetachedScope } from "../ui/DetachedScope";
7
- import { Restate, PrivateStore } from "../ui/Restate";
8
- import { DataProxy } from "../ui/DataProxy";
9
- import { Content } from "../ui/layout/Content";
10
- import { ContentPlaceholder, ContentPlaceholderScope } from "../ui/layout/ContentPlaceholder";
11
- import { LabelsTopLayout, LabelsTopLayoutCell } from "../ui/layout/LabelsTopLayout";
12
- import { LabelsLeftLayout } from "../ui/layout/LabelsLeftLayout";
13
- import { ContentResolver } from "../ui/ContentResolver";
14
- import { Rescope } from "../ui/Rescope";
15
- import { Repeater } from "../ui/Repeater";
16
-
17
- //re-export widgets defined in ui namespace
18
- export {
19
- Widget,
20
- StaticText,
21
- Text,
22
- PureContainer,
23
- Content,
24
- ContentPlaceholder,
25
- ContentPlaceholderScope,
26
- ContentResolver,
27
- Rescope,
28
- Repeater,
29
- IsolatedScope,
30
- DetachedScope,
31
- Restate,
32
- PrivateStore,
33
- DataProxy,
34
- LabelsTopLayout,
35
- LabelsTopLayoutCell,
36
- LabelsLeftLayout,
37
- };
38
-
39
- export * from "./cx";
40
- export * from "./HtmlElement";
41
- export * from "./Button";
42
- export * from "./DocumentTitle";
43
- export * from "./List";
44
- export * from "./Sandbox";
45
- export * from "./CxCredit";
46
- export * from "./Heading";
47
- export * from "./Section";
48
- export * from "./FlexBox";
49
- export * from "./Icon";
50
- export * from "./ProgressBar";
51
- export * from "./Resizer";
52
- export * from "./HighlightedSearchText";
53
- export * from "./autoFocus";
54
- export * from "./ReactElementWrapper";
55
-
56
- export * from "./icons/index";
57
- export * from "./overlay/index";
58
- export * from "./nav/index";
59
- export * from "./form/index";
60
- export * from "./grid/index";
61
- export * from "./drag-drop/index";
62
-
63
- export * from "./enableAllInternalDependencies";
1
+ export { Widget } from "../ui/Widget";
2
+ export { Text } from "../ui/Text";
3
+ export { StaticText } from "../ui/StaticText";
4
+ export { PureContainer } from "../ui/PureContainer";
5
+ export { IsolatedScope } from "../ui/IsolatedScope";
6
+ export { DetachedScope } from "../ui/DetachedScope";
7
+ export { Restate, PrivateStore } from "../ui/Restate";
8
+ export { DataProxy } from "../ui/DataProxy";
9
+ export { Content } from "../ui/layout/Content";
10
+ export { ContentPlaceholder, ContentPlaceholderScope } from "../ui/layout/ContentPlaceholder";
11
+ export { LabelsTopLayout, LabelsTopLayoutCell } from "../ui/layout/LabelsTopLayout";
12
+ export { LabelsLeftLayout } from "../ui/layout/LabelsLeftLayout";
13
+ export { ContentResolver } from "../ui/ContentResolver";
14
+ export { Rescope } from "../ui/Rescope";
15
+ export { Repeater } from "../ui/Repeater";
16
+
17
+ export * from "./cx";
18
+ export * from "./HtmlElement";
19
+ export * from "./Button";
20
+ export * from "./DocumentTitle";
21
+ export * from "./List";
22
+ export * from "./Sandbox";
23
+ export * from "./CxCredit";
24
+ export * from "./Heading";
25
+ export * from "./Section";
26
+ export * from "./FlexBox";
27
+ export * from "./Icon";
28
+ export * from "./ProgressBar";
29
+ export * from "./Resizer";
30
+ export * from "./HighlightedSearchText";
31
+ export * from "./autoFocus";
32
+ export * from "./ReactElementWrapper";
33
+
34
+ export * from "./icons/index";
35
+ export * from "./overlay/index";
36
+ export * from "./nav/index";
37
+ export * from "./form/index";
38
+ export * from "./grid/index";
39
+ export * from "./drag-drop/index";
40
+
41
+ export * from "./enableAllInternalDependencies";