@dxos/react-ui-table 0.8.4-main.fd6878d → 0.9.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.
- package/LICENSE +102 -5
- package/dist/lib/browser/chunk-4KOQTPFC.mjs +1702 -0
- package/dist/lib/browser/chunk-4KOQTPFC.mjs.map +7 -0
- package/dist/lib/browser/chunk-62PYOJPY.mjs +67 -0
- package/dist/lib/browser/chunk-62PYOJPY.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1151 -1175
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +37 -45
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/translations.mjs +36 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -3
- package/dist/lib/node-esm/chunk-7LMOZUTS.mjs +68 -0
- package/dist/lib/node-esm/chunk-7LMOZUTS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KOSV2J5N.mjs +1704 -0
- package/dist/lib/node-esm/chunk-KOSV2J5N.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1151 -1175
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +37 -45
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/translations.mjs +37 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +4 -3
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +1 -2
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts +2 -2
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +6 -7
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +36 -3
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +112 -5
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +21 -19
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +115 -5
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContent.d.ts +18 -0
- package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
- package/dist/types/src/components/Table/TableToolbar.d.ts +21 -0
- package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -0
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts +1 -1
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +12 -9
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +7 -14
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +38 -5
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/index.d.ts +1 -0
- package/dist/types/src/components/TableCellEditor/index.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +23 -16
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +2 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts +6 -6
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts +6 -0
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useTableModel.d.ts +9 -9
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +5 -8
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts +18 -9
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +111 -30
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +4 -2
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/playwright/TableManager.d.ts +2 -1
- package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
- package/dist/types/src/testing/useTestTableModel.d.ts +18 -34
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +21 -23
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Table.d.ts +32 -0
- package/dist/types/src/types/Table.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +14 -12
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.test.d.ts +2 -0
- package/dist/types/src/util/dynamic-table.test.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +2 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/query-ast.d.ts +7 -0
- package/dist/types/src/util/query-ast.d.ts.map +1 -0
- package/dist/types/src/util/schema.d.ts +1 -1
- package/dist/types/src/util/schema.d.ts.map +1 -1
- package/dist/types/src/util/signals.d.ts.map +1 -1
- package/dist/types/src/util/sort.d.ts +12 -0
- package/dist/types/src/util/sort.d.ts.map +1 -0
- package/dist/types/src/util/table-buttons.d.ts +20 -20
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts +4 -4
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/src/util/tag.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +68 -77
- package/src/components/Table/ColumnActionsMenu.tsx +17 -12
- package/src/components/Table/ColumnSettings.tsx +8 -9
- package/src/components/Table/DynamicTable.stories.tsx +41 -38
- package/src/components/Table/DynamicTable.tsx +32 -36
- package/src/components/Table/Relations.stories.tsx +219 -61
- package/src/components/Table/RowActionsMenu.tsx +27 -17
- package/src/components/Table/Table.stories.tsx +217 -141
- package/src/components/Table/Table.tsx +46 -391
- package/src/components/Table/TableContent.tsx +426 -0
- package/src/components/Table/TableToolbar.tsx +111 -0
- package/src/components/TableCellEditor/CellValidationMessage.tsx +5 -6
- package/src/components/TableCellEditor/FormCellEditor.tsx +136 -41
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +39 -73
- package/src/components/TableCellEditor/TableCellEditor.tsx +81 -223
- package/src/components/TableCellEditor/index.ts +1 -0
- package/src/components/index.ts +0 -1
- package/src/components/testing.ts +42 -21
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useAddRow.ts +14 -14
- package/src/hooks/useProjectionModel.ts +38 -0
- package/src/hooks/useTableModel.ts +36 -34
- package/src/index.ts +0 -4
- package/src/model/modal-controller.ts +23 -40
- package/src/model/selection-model.ts +75 -44
- package/src/model/table-model.test.ts +86 -56
- package/src/model/table-model.ts +464 -182
- package/src/model/table-presentation.test.ts +64 -59
- package/src/model/table-presentation.ts +107 -83
- package/src/playwright/TableManager.ts +13 -6
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/smoke.spec.ts +92 -46
- package/src/testing/useTestTableModel.ts +51 -42
- package/src/translations.ts +20 -22
- package/src/types/Table.ts +80 -0
- package/src/types/index.ts +1 -1
- package/src/util/dynamic-table.test.ts +63 -0
- package/src/util/dynamic-table.ts +53 -39
- package/src/util/index.ts +2 -1
- package/src/util/query-ast.ts +22 -0
- package/src/util/schema.ts +4 -4
- package/src/util/sort.ts +90 -0
- package/src/util/table-buttons.ts +3 -3
- package/src/util/table-controls.ts +2 -2
- package/dist/lib/browser/chunk-L2LSB6KV.mjs +0 -18
- package/dist/lib/browser/chunk-L2LSB6KV.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZAOSIG3L.mjs +0 -1814
- package/dist/lib/browser/chunk-ZAOSIG3L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NXZ4CJYX.mjs +0 -20
- package/dist/lib/node-esm/chunk-NXZ4CJYX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZOFFI3JJ.mjs +0 -1815
- package/dist/lib/node-esm/chunk-ZOFFI3JJ.mjs.map +0 -7
- package/dist/types/src/components/Table/CreateRefPanel.d.ts +0 -9
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +0 -1
- package/dist/types/src/components/TableCellEditor/extension.d.ts +0 -13
- package/dist/types/src/components/TableCellEditor/extension.d.ts.map +0 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +0 -21
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +0 -1
- package/dist/types/src/components/TableToolbar/index.d.ts +0 -2
- package/dist/types/src/components/TableToolbar/index.d.ts.map +0 -1
- package/dist/types/src/model/table-sorting.d.ts +0 -53
- package/dist/types/src/model/table-sorting.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -8
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/util/table.d.ts +0 -12
- package/dist/types/src/util/table.d.ts.map +0 -1
- package/src/components/Table/CreateRefPanel.tsx +0 -86
- package/src/components/TableCellEditor/extension.ts +0 -61
- package/src/components/TableToolbar/TableToolbar.tsx +0 -102
- package/src/components/TableToolbar/index.ts +0 -5
- package/src/model/table-sorting.ts +0 -216
- package/src/types/schema.ts +0 -16
- package/src/util/table.ts +0 -53
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Registry } from '@effect-atom/atom-react';
|
|
6
|
+
import type * as Types from 'effect/Types';
|
|
6
7
|
|
|
7
|
-
import { Obj } from '@dxos/echo';
|
|
8
|
-
import { getTypename, toJsonSchema } from '@dxos/echo-schema';
|
|
9
|
-
import type { JsonSchemaType, SortDirectionType } from '@dxos/echo-schema';
|
|
8
|
+
import { Filter, type JsonSchema, Obj, Order, Query, type QueryAST, Ref, Type, type View } from '@dxos/echo';
|
|
10
9
|
import {
|
|
11
|
-
type DataType,
|
|
12
10
|
ProjectionModel,
|
|
13
11
|
type SchemaPropertyDefinition,
|
|
14
|
-
|
|
12
|
+
ViewModel,
|
|
13
|
+
createEchoChangeCallback,
|
|
14
|
+
getSchemaFromJsonSchema,
|
|
15
15
|
getSchemaFromPropertyDefinitions,
|
|
16
16
|
} from '@dxos/schema';
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import { Table } from '../types';
|
|
19
19
|
|
|
20
20
|
// TODO(ZaymonFC): Upstream these extra fields to SchemaPropertyDefinition to enhance schema-tools schema creation.
|
|
21
21
|
type PropertyDisplayProps = {
|
|
22
22
|
size: number;
|
|
23
23
|
title: string;
|
|
24
|
-
sort:
|
|
24
|
+
sort: QueryAST.OrderDirection;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export type TablePropertyDefinition = SchemaPropertyDefinition & Partial<PropertyDisplayProps>;
|
|
@@ -31,64 +31,72 @@ export type TablePropertyDefinition = SchemaPropertyDefinition & Partial<Propert
|
|
|
31
31
|
*/
|
|
32
32
|
// TODO(burdon): Remove variance.
|
|
33
33
|
export const getBaseSchema = ({
|
|
34
|
+
type,
|
|
34
35
|
typename,
|
|
35
36
|
properties,
|
|
36
37
|
jsonSchema,
|
|
37
|
-
schema,
|
|
38
38
|
}: {
|
|
39
|
+
type?: Type.AnyEntity;
|
|
39
40
|
typename?: string;
|
|
40
41
|
properties?: TablePropertyDefinition[];
|
|
41
|
-
jsonSchema?:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return { typename: getTypename(schema)!, jsonSchema: toJsonSchema(schema) };
|
|
49
|
-
} else if (typename && jsonSchema) {
|
|
50
|
-
return { typename, jsonSchema };
|
|
51
|
-
} else {
|
|
42
|
+
jsonSchema?: Types.DeepMutable<JsonSchema.JsonSchema>;
|
|
43
|
+
}): { typename: string; type: Type.AnyEntity } => {
|
|
44
|
+
const resolved =
|
|
45
|
+
typename && properties
|
|
46
|
+
? getSchemaFromPropertyDefinitions(typename, properties)
|
|
47
|
+
: (type ?? (jsonSchema ? getSchemaFromJsonSchema(jsonSchema, typename) : undefined));
|
|
48
|
+
if (!resolved) {
|
|
52
49
|
throw new Error('invalid properties');
|
|
53
50
|
}
|
|
51
|
+
|
|
52
|
+
return { typename: Type.getTypename(resolved)!, type: resolved };
|
|
54
53
|
};
|
|
55
54
|
|
|
56
55
|
export const makeDynamicTable = ({
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
registry,
|
|
57
|
+
type,
|
|
59
58
|
properties,
|
|
60
59
|
}: {
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
registry: Registry.Registry;
|
|
61
|
+
type: Type.AnyEntity;
|
|
63
62
|
properties?: TablePropertyDefinition[];
|
|
64
|
-
}): { projection: ProjectionModel;
|
|
65
|
-
const
|
|
66
|
-
const view =
|
|
67
|
-
|
|
63
|
+
}): { projection: ProjectionModel; object: Table.Table } => {
|
|
64
|
+
const jsonSchema = type.jsonSchema;
|
|
65
|
+
const view = ViewModel.make({
|
|
66
|
+
query: Query.select(Filter.everything()),
|
|
68
67
|
jsonSchema,
|
|
69
|
-
|
|
68
|
+
type,
|
|
70
69
|
...(properties && { fields: properties.map((property) => property.name) }),
|
|
71
70
|
});
|
|
71
|
+
const object = Obj.make(Table.Table, { view: Ref.make(view), sizes: {} });
|
|
72
72
|
|
|
73
|
-
const projection = new ProjectionModel(
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
const projection = new ProjectionModel({
|
|
74
|
+
registry,
|
|
75
|
+
view,
|
|
76
|
+
baseSchema: jsonSchema,
|
|
77
|
+
change: createEchoChangeCallback(view, type),
|
|
78
|
+
});
|
|
79
|
+
projection.normalizeView();
|
|
80
|
+
if (properties && projection.getFields()) {
|
|
81
|
+
setProperties(view, projection, object, properties);
|
|
76
82
|
}
|
|
77
83
|
|
|
78
|
-
return { projection,
|
|
84
|
+
return { projection, object };
|
|
79
85
|
};
|
|
80
86
|
|
|
81
87
|
const setProperties = (
|
|
82
|
-
view:
|
|
88
|
+
view: View.View,
|
|
83
89
|
projection: ProjectionModel,
|
|
84
|
-
table:
|
|
90
|
+
table: Table.Table,
|
|
85
91
|
properties: TablePropertyDefinition[],
|
|
86
92
|
) => {
|
|
87
93
|
for (const property of properties) {
|
|
88
|
-
const field = projection.
|
|
94
|
+
const field = projection.getFields().find((field) => field.path === property.name);
|
|
89
95
|
if (field) {
|
|
90
96
|
if (property.size !== undefined) {
|
|
91
|
-
table
|
|
97
|
+
Obj.update(table, (table) => {
|
|
98
|
+
table.sizes[field.path] = property.size!;
|
|
99
|
+
});
|
|
92
100
|
}
|
|
93
101
|
|
|
94
102
|
if (property.title !== undefined) {
|
|
@@ -100,8 +108,14 @@ const setProperties = (
|
|
|
100
108
|
}
|
|
101
109
|
|
|
102
110
|
if (property.sort) {
|
|
103
|
-
|
|
104
|
-
view.query.
|
|
111
|
+
// Apply sort to query instead of deprecated view.sort
|
|
112
|
+
const currentQuery = Query.fromAst(Obj.getSnapshot(view).query.ast);
|
|
113
|
+
// Use any type parameter since we're working with dynamic field paths
|
|
114
|
+
const newQuery = currentQuery.orderBy(Order.property<any>(field.path as string, property.sort));
|
|
115
|
+
Obj.update(view, (view) => {
|
|
116
|
+
// Type assertion needed because Query AST types have some variance issues.
|
|
117
|
+
view.query.ast = newQuery.ast as typeof view.query.ast;
|
|
118
|
+
});
|
|
105
119
|
}
|
|
106
120
|
}
|
|
107
121
|
}
|
package/src/util/index.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type QueryAST } from '@dxos/echo';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Extracts order clauses from a query AST.
|
|
9
|
+
* Handles nested structures (options, order, etc.).
|
|
10
|
+
*/
|
|
11
|
+
export const extractOrder = (queryAst: QueryAST.Query): readonly QueryAST.Order[] | undefined => {
|
|
12
|
+
if (queryAst.type === 'order') {
|
|
13
|
+
return queryAst.order;
|
|
14
|
+
}
|
|
15
|
+
if (queryAst.type === 'options') {
|
|
16
|
+
return extractOrder(queryAst.query);
|
|
17
|
+
}
|
|
18
|
+
if (queryAst.type === 'from') {
|
|
19
|
+
return extractOrder(queryAst.query);
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
};
|
package/src/util/schema.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Creates a narrowed schema from an original schema that only includes
|
|
@@ -20,14 +20,14 @@ export const narrowSchema = <S extends Schema.Schema.AnyNoContext>(
|
|
|
20
20
|
): Schema.Schema<unknown, unknown> | undefined => {
|
|
21
21
|
const ast = (schema as any)?.ast;
|
|
22
22
|
|
|
23
|
-
if (isTypeLiteral(ast)) {
|
|
23
|
+
if (SchemaAST.isTypeLiteral(ast)) {
|
|
24
24
|
// Filter property signatures that match any of the provided paths
|
|
25
25
|
const propertySignatures = ast.propertySignatures.filter((signature) => paths.includes(signature.name.toString()));
|
|
26
26
|
|
|
27
27
|
// If we found at least one matching property
|
|
28
28
|
if (propertySignatures.length > 0) {
|
|
29
29
|
// Create a new TypeLiteral with only the matching properties
|
|
30
|
-
const narrowType = new TypeLiteral(propertySignatures, []);
|
|
30
|
+
const narrowType = new SchemaAST.TypeLiteral(propertySignatures, []);
|
|
31
31
|
return Schema.make(narrowType);
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/util/sort.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Format, type QueryAST } from '@dxos/echo';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Gets a normalized sort value for a given value and format.
|
|
9
|
+
* This ensures consistent sorting behavior across different data types.
|
|
10
|
+
*/
|
|
11
|
+
export const getSortValue = (value: any, format: Format.TypeFormat): any => {
|
|
12
|
+
// Handle null/undefined
|
|
13
|
+
if (value === undefined || value === null) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Handle dates chronologically if schema indicates date format
|
|
18
|
+
const isDateFormat = format === Format.TypeFormat.DateTime || format === Format.TypeFormat.Date;
|
|
19
|
+
if (isDateFormat) {
|
|
20
|
+
const date = new Date(value);
|
|
21
|
+
if (!isNaN(date.getTime())) {
|
|
22
|
+
return date.getTime();
|
|
23
|
+
}
|
|
24
|
+
// Fallback to string if date parsing fails
|
|
25
|
+
return String(value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Handle numbers if schema indicates number format
|
|
29
|
+
if (
|
|
30
|
+
format === Format.TypeFormat.Number ||
|
|
31
|
+
format === Format.TypeFormat.Integer ||
|
|
32
|
+
format === Format.TypeFormat.Currency ||
|
|
33
|
+
format === Format.TypeFormat.Percent ||
|
|
34
|
+
format === Format.TypeFormat.Duration
|
|
35
|
+
) {
|
|
36
|
+
const num = typeof value === 'number' ? value : Number(value);
|
|
37
|
+
if (!isNaN(num)) {
|
|
38
|
+
return num;
|
|
39
|
+
}
|
|
40
|
+
// Fallback to string if number parsing fails
|
|
41
|
+
return String(value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Default to string comparison
|
|
45
|
+
if (typeof value === 'string') {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
if (typeof value === 'number') {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Fallback to string representation
|
|
53
|
+
return String(value);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Compares two values for sorting based on the field format.
|
|
58
|
+
* Handles dates, numbers, and strings appropriately.
|
|
59
|
+
*/
|
|
60
|
+
export const compareValues = (
|
|
61
|
+
aValue: any,
|
|
62
|
+
bValue: any,
|
|
63
|
+
format: Format.TypeFormat,
|
|
64
|
+
direction: QueryAST.OrderDirection,
|
|
65
|
+
): number => {
|
|
66
|
+
// Handle null/undefined values - nulls sort to the end
|
|
67
|
+
if (aValue === undefined || aValue === null) {
|
|
68
|
+
return bValue === undefined || bValue === null ? 0 : 1;
|
|
69
|
+
}
|
|
70
|
+
if (bValue === undefined || bValue === null) {
|
|
71
|
+
return -1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Get normalized sort values
|
|
75
|
+
const aSortValue = getSortValue(aValue, format);
|
|
76
|
+
const bSortValue = getSortValue(bValue, format);
|
|
77
|
+
|
|
78
|
+
// Compare based on type
|
|
79
|
+
let comparison = 0;
|
|
80
|
+
if (typeof aSortValue === 'number' && typeof bSortValue === 'number') {
|
|
81
|
+
comparison = aSortValue - bSortValue;
|
|
82
|
+
} else if (typeof aSortValue === 'string' && typeof bSortValue === 'string') {
|
|
83
|
+
comparison = aSortValue.localeCompare(bSortValue);
|
|
84
|
+
} else {
|
|
85
|
+
// Mixed types - convert both to strings
|
|
86
|
+
comparison = String(aSortValue).localeCompare(String(bSortValue));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return direction === 'desc' ? -comparison : comparison;
|
|
90
|
+
};
|
|
@@ -26,7 +26,7 @@ const createButton = ({
|
|
|
26
26
|
disabled = false,
|
|
27
27
|
icon,
|
|
28
28
|
testId,
|
|
29
|
-
type = 'primary',
|
|
29
|
+
type: _type = 'primary',
|
|
30
30
|
}: {
|
|
31
31
|
attr: string;
|
|
32
32
|
data: Record<string, string>;
|
|
@@ -39,8 +39,7 @@ const createButton = ({
|
|
|
39
39
|
.map(([k, v]) => `${k}="${v}"`)
|
|
40
40
|
.join(' ');
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
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' : ''} data-dx-grid-action="accessory"><svg data-size="4"><use href="/icons.svg#${icon}"/></svg></button>`;
|
|
42
|
+
return `<button ${attr} data-testid="${testId}" class="dx-button w-6 aspect-square px-0.5 min-h-0" ${dataAttrs} ${disabled ? 'disabled' : ''} data-dx-grid-action="accessory"><svg data-size="4"><use href="/icons.svg#${icon}"/></svg></button>`;
|
|
44
43
|
};
|
|
45
44
|
|
|
46
45
|
const addColumnButton = {
|
|
@@ -67,6 +66,7 @@ const columnSettingsButton = {
|
|
|
67
66
|
icon: columnSettingsButton.icon,
|
|
68
67
|
data: {
|
|
69
68
|
'data-field-id': fieldId,
|
|
69
|
+
'data-variant': 'ghost',
|
|
70
70
|
},
|
|
71
71
|
testId: 'table-column-settings-button',
|
|
72
72
|
});
|
|
@@ -25,8 +25,8 @@ export const CONTROL_IDENTIFIERS = {
|
|
|
25
25
|
} as const;
|
|
26
26
|
|
|
27
27
|
const BASE_CLASSES = {
|
|
28
|
-
checkbox: 'absolute inset-
|
|
29
|
-
switch: 'absolute inset-
|
|
28
|
+
checkbox: 'absolute inset-y-[.375rem] end-[.375rem] dx-checkbox',
|
|
29
|
+
switch: 'absolute inset-y-[.25rem] end-[.25rem] dx-checkbox--switch',
|
|
30
30
|
} as const;
|
|
31
31
|
|
|
32
32
|
const renderAttributes = (data: Record<string, string>) => {
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// src/types/schema.ts
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
import { Type } from "@dxos/echo";
|
|
4
|
-
import { JsonPath } from "@dxos/effect";
|
|
5
|
-
var TableView = Schema.Struct({
|
|
6
|
-
sizes: Schema.Record({
|
|
7
|
-
key: JsonPath,
|
|
8
|
-
value: Schema.Number
|
|
9
|
-
}).pipe(Schema.mutable)
|
|
10
|
-
}).pipe(Type.Obj({
|
|
11
|
-
typename: "dxos.org/type/TableView",
|
|
12
|
-
version: "0.1.0"
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
TableView
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=chunk-L2LSB6KV.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/schema.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { Type } from '@dxos/echo';\nimport { JsonPath } from '@dxos/effect';\n\nexport const TableView = Schema.Struct({\n sizes: Schema.Record({\n key: JsonPath,\n value: Schema.Number,\n }).pipe(Schema.mutable),\n}).pipe(Type.Obj({ typename: 'dxos.org/type/TableView', version: '0.1.0' }));\nexport type TableView = Schema.Schema.Type<typeof TableView>;\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,cAAc;AAEvB,SAASC,YAAY;AACrB,SAASC,gBAAgB;AAElB,IAAMC,YAAYC,OAAOC,OAAO;EACrCC,OAAOF,OAAOG,OAAO;IACnBC,KAAKC;IACLC,OAAON,OAAOO;EAChB,CAAA,EAAGC,KAAKR,OAAOS,OAAO;AACxB,CAAA,EAAGD,KAAKE,KAAKC,IAAI;EAAEC,UAAU;EAA2BC,SAAS;AAAQ,CAAA,CAAA;",
|
|
6
|
-
"names": ["Schema", "Type", "JsonPath", "TableView", "Schema", "Struct", "sizes", "Record", "key", "JsonPath", "value", "Number", "pipe", "mutable", "Type", "Obj", "typename", "version"]
|
|
7
|
-
}
|