@globalbrain/sefirot 4.53.0 → 4.54.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.
@@ -39,9 +39,17 @@ const orderTextDict = {
39
39
  }
40
40
 
41
41
  function getFieldName(sort: LensQuerySort): string {
42
- return lang === 'ja'
43
- ? props.fields[sort[0]].labelJa
44
- : props.fields[sort[0]].labelEn
42
+ // A still-applied sort can reference a field that's not in the field set — a
43
+ // stale saved/URL sort, or a sort emitted under a companion key (e.g. an
44
+ // avatar sorting by its display-name field). Fall back to the raw key rather
45
+ // than crash, mirroring how the filter chip handles an unknown field.
46
+ const field = props.fields[sort[0]]
47
+
48
+ if (!field) {
49
+ return sort[0]
50
+ }
51
+
52
+ return lang === 'ja' ? field.labelJa : field.labelEn
45
53
  }
46
54
 
47
55
  function getOrderText(sort: LensQuerySort): string {
@@ -29,6 +29,13 @@ export class AvatarField extends Field<AvatarFieldData> {
29
29
  return {}
30
30
  }
31
31
 
32
+ // Sort by the display-name companion (resolved by the active language), since
33
+ // the field value itself is the image URL. With no companion configured there's
34
+ // nothing meaningful to sort on, so the field stays unsortable (no sort menu).
35
+ protected override sortKey(): string | null {
36
+ return this.nameKey()
37
+ }
38
+
32
39
  override dataListItemComponent(): any {
33
40
  return this.defineDataListItemComponent((value) => {
34
41
  // Render nothing for a missing image so SDataListItem shows its empty
@@ -81,12 +81,25 @@ export abstract class Field<T extends FieldData> {
81
81
  }
82
82
  }
83
83
 
84
+ /**
85
+ * The field key sorts are emitted under — the catalog sends it to the backend,
86
+ * which orders by that field's column. Defaults to the field's own key; a
87
+ * subtype whose own value isn't meaningful to sort on can redirect it (e.g. an
88
+ * avatar sorts by its display-name companion). A `null` makes the field
89
+ * unsortable, so no sort menu is shown.
90
+ */
91
+ protected sortKey(): string | null {
92
+ return this.data.key
93
+ }
94
+
84
95
  /**
85
96
  * Renders the table sort menu for the field. The sort maybe null when
86
- * the field `sortable` option is false.
97
+ * the field `sortable` option is false (or it has no sortable key).
87
98
  */
88
99
  tableSortMenu(onSortUpdated: (sort: LensQuerySort) => void): DropdownSection | null {
89
- if (!this.data.sortable) {
100
+ const sortKey = this.sortKey()
101
+
102
+ if (!this.data.sortable || sortKey === null) {
90
103
  return null
91
104
  }
92
105
 
@@ -100,8 +113,8 @@ export abstract class Field<T extends FieldData> {
100
113
  return {
101
114
  type: 'menu',
102
115
  options: [
103
- { label: t.sort_asc, onClick: () => onSortUpdated?.([this.data.key, 'asc']) },
104
- { label: t.sort_desc, onClick: () => onSortUpdated?.([this.data.key, 'desc']) }
116
+ { label: t.sort_asc, onClick: () => onSortUpdated?.([sortKey, 'asc']) },
117
+ { label: t.sort_desc, onClick: () => onSortUpdated?.([sortKey, 'desc']) }
105
118
  ]
106
119
  }
107
120
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "4.53.0",
3
+ "version": "4.54.0",
4
4
  "description": "Vue Components for Global Brain Design System.",
5
5
  "keywords": [
6
6
  "components",