@dxos/react-ui-table 0.7.5-labs.a279d8c → 0.7.5-labs.ea4b4c2

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.
@@ -68,7 +68,8 @@ export class TablePresentation<T extends BaseTableRow = { id: string }> {
68
68
  }
69
69
 
70
70
  switch (props.format) {
71
- case FormatEnum.Boolean: {
71
+ case FormatEnum.Boolean:
72
+ case FormatEnum.SingleSelect: {
72
73
  return '';
73
74
  }
74
75
  case FormatEnum.Ref: {
@@ -119,6 +120,17 @@ export class TablePresentation<T extends BaseTableRow = { id: string }> {
119
120
  cell.readonly = true;
120
121
  }
121
122
 
123
+ if (props.format === FormatEnum.SingleSelect) {
124
+ const value = getValue(obj, field.path);
125
+ const options = this.model.projection.getFieldProjection(field.id).props.options;
126
+ if (options) {
127
+ const option = options.find((o) => o.id === value);
128
+ if (option) {
129
+ cell.accessoryHtml = `<span class="dx-tag" data-hue="${option.color}">${option.title}</span>`;
130
+ }
131
+ }
132
+ }
133
+
122
134
  const idx = toPlaneCellIndex({ col: colIndex, row: displayIndex });
123
135
  cells[idx] = cell;
124
136
  };
@@ -188,6 +188,20 @@ export class TableSorting<T extends BaseTableRow> {
188
188
  return value;
189
189
  }
190
190
 
191
+ /**
192
+ * For single select fields, the sort value is determined by the index of the option in the
193
+ * options array. This ensures sort order matches the configured option order.
194
+ */
195
+ if (format === FormatEnum.SingleSelect) {
196
+ const options = props.options;
197
+ if (!options) {
198
+ return undefined;
199
+ }
200
+
201
+ const option = options.find((option) => option.id === value);
202
+ return option ? options.indexOf(option) : undefined;
203
+ }
204
+
191
205
  // TODO(ZaymonFC): Should we format this returned value for display based on the referenced prop format?
192
206
  // Right now we're going to be sorting based on the raw values.
193
207
  // Maybe we need to recurse this function with the referenced prop format and field?
@@ -39,7 +39,7 @@ const createButton = ({
39
39
  .join(' ');
40
40
 
41
41
  const positionClass = type === 'primary' ? 'inline-end-2' : 'inline-end-9';
42
- return `<button ${attr} data-testid="${testId}" class="ch-button is-6 pli-0.5 min-bs-0 absolute inset-block-1 ${positionClass}" ${dataAttrs} ${disabled ? 'disabled' : ''}><svg><use href="/icons.svg#${icon}"/></svg></button>`;
42
+ return `<button ${attr} data-testid="${testId}" class="dx-button is-6 pli-0.5 min-bs-0 absolute inset-block-1 ${positionClass}" ${dataAttrs} ${disabled ? 'disabled' : ''}><svg><use href="/icons.svg#${icon}"/></svg></button>`;
43
43
  };
44
44
 
45
45
  const addColumnButton = {
@@ -23,8 +23,8 @@ export const CONTROL_IDENTIFIERS = {
23
23
  } as const;
24
24
 
25
25
  const BASE_CLASSES = {
26
- checkbox: 'absolute inset-block-[.375rem] inline-end-[.375rem] ch-checkbox',
27
- switch: 'absolute inset-block-[.25rem] inline-end-[.25rem] ch-checkbox--switch',
26
+ checkbox: 'absolute inset-block-[.375rem] inline-end-[.375rem] dx-checkbox',
27
+ switch: 'absolute inset-block-[.25rem] inline-end-[.25rem] dx-checkbox--switch',
28
28
  } as const;
29
29
 
30
30
  const renderAttributes = (data: Record<string, string>) => {