@dxos/react-ui-table 0.6.13 → 0.6.14-main.7bd9c89
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/dist/lib/browser/index.mjs +45 -131
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/ColumnMenu/ColumnMenu.d.ts +6 -3
- package/dist/types/src/components/ColumnMenu/ColumnMenu.d.ts.map +1 -1
- package/dist/types/src/components/ColumnMenu/ColumnMenu.stories.d.ts +3 -3
- package/dist/types/src/components/ColumnMenu/ColumnMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/ColumnMenu/ColumnSettings.d.ts +15 -0
- package/dist/types/src/components/ColumnMenu/ColumnSettings.d.ts.map +1 -0
- package/dist/types/src/components/ColumnMenu/ColumnSettings.stories.d.ts +84 -0
- package/dist/types/src/components/ColumnMenu/ColumnSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/ColumnMenu/index.d.ts +1 -1
- package/dist/types/src/components/ColumnMenu/index.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +9 -27
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContext.d.ts +2 -4
- package/dist/types/src/components/Table/TableContext.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableHead.d.ts.map +1 -1
- package/dist/types/src/components/Table/index.d.ts +2 -1
- package/dist/types/src/components/Table/index.d.ts.map +1 -1
- package/dist/types/src/helpers.d.ts +1 -1
- package/dist/types/src/helpers.d.ts.map +1 -1
- package/dist/types/src/hooks/useRowSelection.d.ts.map +1 -1
- package/dist/types/src/schema/{SchemaToTable.stories.d.ts → Schema.stories.d.ts} +2 -3
- package/dist/types/src/schema/Schema.stories.d.ts.map +1 -0
- package/dist/types/src/schema/{schemaToColumns.d.ts → column-utils.d.ts} +2 -2
- package/dist/types/src/schema/column-utils.d.ts.map +1 -0
- package/dist/types/src/schema/index.d.ts +1 -1
- package/dist/types/src/schema/index.d.ts.map +1 -1
- package/dist/types/src/schema/types.d.ts +10 -4
- package/dist/types/src/schema/types.d.ts.map +1 -1
- package/package.json +22 -20
- package/src/components/ColumnMenu/ColumnMenu.stories.tsx +14 -13
- package/src/components/ColumnMenu/ColumnMenu.tsx +8 -5
- package/src/components/ColumnMenu/{ColumnSettingsForm.stories.tsx → ColumnSettings.stories.tsx} +27 -23
- package/src/components/ColumnMenu/{ColumnSettingsForm.tsx → ColumnSettings.tsx} +44 -43
- package/src/components/ColumnMenu/index.ts +1 -1
- package/src/components/Table/Table.stories.tsx +93 -95
- package/src/components/Table/Table.tsx +10 -15
- package/src/components/Table/TableContext.tsx +13 -7
- package/src/components/Table/TableHead.tsx +0 -1
- package/src/components/Table/index.ts +2 -1
- package/src/components/Table/props.ts +4 -4
- package/src/helpers.tsx +4 -6
- package/src/hooks/useRowSelection.ts +1 -0
- package/src/schema/{SchemaToTable.stories.tsx → Schema.stories.tsx} +11 -23
- package/src/schema/{schemaToColumns.ts → column-utils.ts} +9 -9
- package/src/schema/index.ts +1 -1
- package/src/schema/types.ts +14 -6
- package/src/translations.ts +1 -1
- package/dist/types/src/components/ColumnMenu/ColumnSettingsForm.d.ts +0 -12
- package/dist/types/src/components/ColumnMenu/ColumnSettingsForm.d.ts.map +0 -1
- package/dist/types/src/components/ColumnMenu/ColumnSettingsForm.stories.d.ts +0 -63
- package/dist/types/src/components/ColumnMenu/ColumnSettingsForm.stories.d.ts.map +0 -1
- package/dist/types/src/schema/SchemaToTable.stories.d.ts.map +0 -1
- package/dist/types/src/schema/schema.d.ts +0 -5
- package/dist/types/src/schema/schema.d.ts.map +0 -1
- package/dist/types/src/schema/schema.test.d.ts +0 -2
- package/dist/types/src/schema/schema.test.d.ts.map +0 -1
- package/dist/types/src/schema/schemaToColumns.d.ts.map +0 -1
- package/src/schema/schema.test.ts +0 -148
- package/src/schema/schema.ts +0 -93
package/src/schema/schema.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as AST from '@effect/schema/AST';
|
|
6
|
-
import type * as S from '@effect/schema/Schema';
|
|
7
|
-
|
|
8
|
-
import { type ColumnType } from './types';
|
|
9
|
-
|
|
10
|
-
// TODO(burdon): Reconcile with react-ui-table.
|
|
11
|
-
export type ClassifiedColumnType = ColumnType | 'display';
|
|
12
|
-
|
|
13
|
-
// TODO(burdon): Rename getX? and return typed array?
|
|
14
|
-
export const classifySchemaProperties = (schema: S.Schema<any, any>): [string, ClassifiedColumnType][] => {
|
|
15
|
-
const recurse = (node: AST.AST, path: string[], acc: [string, ClassifiedColumnType][]) => {
|
|
16
|
-
const properties = AST.getPropertySignatures(node);
|
|
17
|
-
properties.forEach((prop) => {
|
|
18
|
-
const propName = prop.name.toString();
|
|
19
|
-
|
|
20
|
-
if (prop.isOptional) {
|
|
21
|
-
const unwrappedAst = unwrapOptionProperty(prop);
|
|
22
|
-
if (isStruct(unwrappedAst)) {
|
|
23
|
-
return recurse(unwrappedAst, [...path, propName], acc);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (isStruct(prop.type)) {
|
|
28
|
-
recurse(prop.type, [...path, propName], acc);
|
|
29
|
-
} else {
|
|
30
|
-
acc.push([path.concat(propName).join('.'), propertyToColumn(prop)]);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
return acc;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return recurse(schema.ast, [], []);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const isStruct = (node: AST.AST) => AST.isTypeLiteral(node);
|
|
41
|
-
|
|
42
|
-
const isOptionalUnion = (prop: AST.PropertySignature) => AST.isUnion(prop.type) && prop.isOptional;
|
|
43
|
-
|
|
44
|
-
const unwrapOptionProperty = (prop: AST.PropertySignature) => {
|
|
45
|
-
if (!isOptionalUnion(prop)) {
|
|
46
|
-
throw new Error(`Not an optional property: ${String(prop.name)}`);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (!AST.isUnion(prop.type)) {
|
|
50
|
-
throw new Error(`Not a union type: ${String(prop.name)}`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const [type, _undefinedCase] = prop.type.types;
|
|
54
|
-
return type;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const typeToColumn = (type: AST.AST): ClassifiedColumnType => {
|
|
58
|
-
if (AST.isStringKeyword(type)) {
|
|
59
|
-
return 'string';
|
|
60
|
-
} else if (AST.isNumberKeyword(type)) {
|
|
61
|
-
return 'number';
|
|
62
|
-
} else if (AST.isBooleanKeyword(type)) {
|
|
63
|
-
return 'boolean';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (AST.isRefinement(type)) {
|
|
67
|
-
return typeToColumn(type.from);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// TODO(zan): How should we be thinking about transformations?
|
|
71
|
-
// - Which of these are we storing in the database?
|
|
72
|
-
// - For types that aren't the 'DateFromString' transformation, should we be using the 'from' or 'to' type?
|
|
73
|
-
|
|
74
|
-
if (AST.isTransformation(type)) {
|
|
75
|
-
const identifier = AST.getIdentifierAnnotation(type);
|
|
76
|
-
if (identifier._tag === 'Some') {
|
|
77
|
-
if (identifier.value === 'DateFromString') {
|
|
78
|
-
return 'date';
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return 'display';
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const propertyToColumn = (prop: AST.PropertySignature): ClassifiedColumnType => {
|
|
87
|
-
let type = prop.type;
|
|
88
|
-
if (prop.isOptional) {
|
|
89
|
-
type = unwrapOptionProperty(prop);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return typeToColumn(type);
|
|
93
|
-
};
|