@dxos/react-ui-table 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446
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/{chunk-PFFO5LYM.mjs → chunk-YWNRUF4J.mjs} +6 -7
- package/dist/lib/browser/chunk-YWNRUF4J.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +181 -330
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{chunk-VREQOYRW.cjs → chunk-TGG6OZ54.cjs} +8 -9
- package/dist/lib/node/chunk-TGG6OZ54.cjs.map +7 -0
- package/dist/lib/node/index.cjs +160 -306
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +3 -3
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{chunk-34JG3SDI.mjs → chunk-KKLP54L3.mjs} +6 -7
- package/dist/lib/node-esm/chunk-KKLP54L3.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +181 -330
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +4 -3
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/RefPanel.d.ts +9 -0
- package/dist/types/src/components/Table/RefPanel.d.ts.map +1 -0
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +0 -2
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +0 -1
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +0 -3
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +2 -2
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +40 -40
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +2 -2
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts +3 -3
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +43 -44
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +3 -4
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +0 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/signals.d.ts.map +1 -1
- package/dist/types/src/util/table-buttons.d.ts +14 -0
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/src/util/table.d.ts +2 -2
- package/dist/types/src/util/table.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -34
- package/src/components/Table/CreateRefPanel.tsx +5 -5
- package/src/components/Table/DynamicTable.stories.tsx +4 -4
- package/src/components/Table/DynamicTable.tsx +5 -4
- package/src/components/Table/RefPanel.tsx +52 -0
- package/src/components/Table/Table.stories.tsx +27 -73
- package/src/components/Table/Table.tsx +28 -25
- package/src/components/Table/relations.stories.tsx +31 -38
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +10 -11
- package/src/components/TableCellEditor/TableCellEditor.tsx +4 -45
- package/src/components/TableToolbar/TableToolbar.tsx +13 -12
- package/src/components/testing.ts +9 -10
- package/src/hooks/useTableModel.ts +2 -2
- package/src/model/modal-controller.ts +3 -3
- package/src/model/table-model.test.ts +6 -7
- package/src/model/table-model.ts +2 -19
- package/src/model/table-presentation.test.ts +6 -7
- package/src/model/table-presentation.ts +10 -54
- package/src/types/table.ts +7 -15
- package/src/util/dynamic-table.ts +6 -9
- package/src/util/index.ts +0 -1
- package/src/util/table-buttons.ts +23 -0
- package/src/util/table.ts +16 -13
- package/dist/lib/browser/chunk-PFFO5LYM.mjs.map +0 -7
- package/dist/lib/node/chunk-VREQOYRW.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-34JG3SDI.mjs.map +0 -7
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +0 -13
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +0 -1
- package/dist/types/src/util/schema.d.ts +0 -12
- package/dist/types/src/util/schema.d.ts.map +0 -1
- package/dist/types/src/util/tag.d.ts +0 -11
- package/dist/types/src/util/tag.d.ts.map +0 -1
- package/src/components/TableCellEditor/FormCellEditor.tsx +0 -94
- package/src/util/schema.ts +0 -36
- package/src/util/tag.ts +0 -33
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/table.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\n// import { ThreadType } from '@dxos/plugin-space/types';\nimport { LabelAnnotationId, ObjectId, Ref, Expando, EchoObject } from '@dxos/echo-schema';\nimport { ViewType } from '@dxos/schema';\n\nexport const TableSchema = Schema.Struct({\n id: ObjectId,\n name: Schema.optional(Schema.String),\n view: Schema.optional(Ref(ViewType)),\n // TODO(burdon): Document why threads is included here?\n threads: Schema.optional(Schema.Array(Ref(Expando /* ThreadType */))),\n}).annotations({\n // TODO(burdon): Move annotation to property.\n [LabelAnnotationId]: 'name',\n});\n\n// TODO(burdon): Move out of react-ui-xxx.\nexport const TableType = TableSchema.pipe(\n EchoObject({\n typename: 'dxos.org/type/Table',\n version: '0.1.0',\n }),\n);\nexport interface TableType extends Schema.Schema.Type<typeof TableType> {}\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,cAAc;AAGvB,SAASC,mBAAmBC,UAAUC,KAAKC,SAASC,kBAAkB;AACtE,SAASC,gBAAgB;AAElB,IAAMC,cAAcC,OAAOC,OAAO;EACvCC,IAAIC;EACJC,MAAMJ,OAAOK,SAASL,OAAOM,MAAM;EACnCC,MAAMP,OAAOK,SAASG,IAAIC,QAAAA,CAAAA;;EAE1BC,SAASV,OAAOK,SAASL,OAAOW,MAAMH;IAAII;;EAAsB,CAAA,CAAA;AAClE,CAAA,EAAGC,YAAY;;EAEb,CAACC,iBAAAA,GAAoB;AACvB,CAAA;AAGO,IAAMC,YAAYhB,YAAYiB,KACnCC,WAAW;EACTC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;",
|
|
6
|
-
"names": ["Schema", "LabelAnnotationId", "ObjectId", "Ref", "Expando", "EchoObject", "ViewType", "TableSchema", "Schema", "Struct", "id", "ObjectId", "name", "optional", "String", "view", "Ref", "ViewType", "threads", "Array", "Expando", "annotations", "LabelAnnotationId", "TableType", "pipe", "EchoObject", "typename", "version"]
|
|
7
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type Schema } from 'effect';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { type FieldProjection } from '@dxos/schema';
|
|
4
|
-
import { type TableModel } from '../../model';
|
|
5
|
-
type FormCellEditorProps = {
|
|
6
|
-
fieldProjection: FieldProjection;
|
|
7
|
-
model?: TableModel;
|
|
8
|
-
schema?: Schema.Schema.AnyNoContext;
|
|
9
|
-
__gridScope: any;
|
|
10
|
-
};
|
|
11
|
-
export declare const FormCellEditor: ({ fieldProjection, model, schema, __gridScope }: FormCellEditorProps) => React.JSX.Element | null;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=FormCellEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormCellEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/TableCellEditor/FormCellEditor.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAkD,MAAM,OAAO,CAAC;AAOvE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,KAAK,mBAAmB,GAAG;IACzB,eAAe,EAAE,eAAe,CAAC;IACjC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;IACpC,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,iDAAiD,mBAAmB,6BAoElG,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a narrowed schema from an original schema that only includes
|
|
4
|
-
* the specified paths. This allows form components to only display
|
|
5
|
-
* and edit/validate specific fields rather than the entire object.
|
|
6
|
-
*
|
|
7
|
-
* @param schema The original schema to narrow
|
|
8
|
-
* @param paths Array of field paths to extract
|
|
9
|
-
* @returns A narrowed Schema instance containing only the properties at the specified paths
|
|
10
|
-
*/
|
|
11
|
-
export declare const narrowSchema: <S extends Schema.Schema.AnyNoContext>(schema: S, paths: string[]) => Schema.Schema<unknown, unknown> | undefined;
|
|
12
|
-
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/util/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,YAAY,EAC/D,QAAQ,CAAC,EACT,OAAO,MAAM,EAAE,KACd,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,SAgBpC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Regex pattern for matching tags in the format [Label](id)
|
|
3
|
-
*/
|
|
4
|
-
export declare const TAG_PATTERN_REGEX: RegExp;
|
|
5
|
-
/**
|
|
6
|
-
* Extracts tag IDs from a string in the format [Label](id)
|
|
7
|
-
* @param value The string to extract IDs from
|
|
8
|
-
* @returns Array of extracted IDs or undefined if no matches or value is not a string
|
|
9
|
-
*/
|
|
10
|
-
export declare const extractTagIds: (value: unknown) => string[] | undefined;
|
|
11
|
-
//# sourceMappingURL=tag.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../../src/util/tag.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAA6B,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,MAAM,EAAE,GAAG,SAgBzD,CAAC"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Schema } from 'effect';
|
|
6
|
-
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
7
|
-
|
|
8
|
-
import { getSnapshot } from '@dxos/echo-schema';
|
|
9
|
-
import { invariant } from '@dxos/invariant';
|
|
10
|
-
import { Popover } from '@dxos/react-ui';
|
|
11
|
-
import { Form } from '@dxos/react-ui-form';
|
|
12
|
-
import { parseCellIndex, useGridContext } from '@dxos/react-ui-grid';
|
|
13
|
-
import { type FieldProjection } from '@dxos/schema';
|
|
14
|
-
import { getDeep, setDeep } from '@dxos/util';
|
|
15
|
-
|
|
16
|
-
import { type TableModel } from '../../model';
|
|
17
|
-
import { narrowSchema } from '../../util';
|
|
18
|
-
|
|
19
|
-
type FormCellEditorProps = {
|
|
20
|
-
fieldProjection: FieldProjection;
|
|
21
|
-
model?: TableModel;
|
|
22
|
-
schema?: Schema.Schema.AnyNoContext;
|
|
23
|
-
__gridScope: any;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const FormCellEditor = ({ fieldProjection, model, schema, __gridScope }: FormCellEditorProps) => {
|
|
27
|
-
const { editing, setEditing } = useGridContext('ArrayEditor', __gridScope);
|
|
28
|
-
const cellRef = useRef<HTMLButtonElement | null>(null);
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (editing && editing.cellElement) {
|
|
32
|
-
cellRef.current = editing.cellElement as HTMLButtonElement;
|
|
33
|
-
}
|
|
34
|
-
}, [editing?.cellElement]);
|
|
35
|
-
|
|
36
|
-
const narrowedSchema = useMemo(() => {
|
|
37
|
-
if (!schema) {
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
return narrowSchema(schema, [fieldProjection.field.path]);
|
|
41
|
-
}, [JSON.stringify(schema), fieldProjection.field.path]);
|
|
42
|
-
|
|
43
|
-
const originalRow = useMemo(() => {
|
|
44
|
-
if (model && editing) {
|
|
45
|
-
const cell = parseCellIndex(editing.index);
|
|
46
|
-
const row = model.getRowAt(cell.row);
|
|
47
|
-
invariant(row);
|
|
48
|
-
|
|
49
|
-
return row;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return undefined;
|
|
53
|
-
}, [model, editing]);
|
|
54
|
-
|
|
55
|
-
const formValues = useMemo(() => {
|
|
56
|
-
if (originalRow) {
|
|
57
|
-
// NOTE(ZaymonFC): Important to get a snapshot to eject from the live object.
|
|
58
|
-
return getSnapshot(originalRow);
|
|
59
|
-
}
|
|
60
|
-
}, [originalRow]);
|
|
61
|
-
|
|
62
|
-
const handleSave = useCallback(
|
|
63
|
-
(values: any) => {
|
|
64
|
-
const path = fieldProjection.field.path;
|
|
65
|
-
const value = getDeep(values, [path]);
|
|
66
|
-
setDeep(originalRow, [path], value);
|
|
67
|
-
setEditing(null);
|
|
68
|
-
},
|
|
69
|
-
[fieldProjection.field.path, originalRow],
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const handleOpenChange = useCallback(
|
|
73
|
-
(nextOpen: boolean) => {
|
|
74
|
-
if (nextOpen === false) {
|
|
75
|
-
setEditing(null);
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
[setEditing],
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
if (!editing) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<Popover.Root open={editing !== null} onOpenChange={handleOpenChange}>
|
|
87
|
-
<Popover.VirtualTrigger virtualRef={cellRef} />
|
|
88
|
-
<Popover.Content tabIndex={-1} classNames='popover-consistent-width'>
|
|
89
|
-
<Popover.Arrow />
|
|
90
|
-
<Form values={formValues} schema={narrowedSchema as any} onSave={handleSave} />
|
|
91
|
-
</Popover.Content>
|
|
92
|
-
</Popover.Root>
|
|
93
|
-
);
|
|
94
|
-
};
|
package/src/util/schema.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
import { isTypeLiteral, TypeLiteral } from 'effect/SchemaAST';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Creates a narrowed schema from an original schema that only includes
|
|
10
|
-
* the specified paths. This allows form components to only display
|
|
11
|
-
* and edit/validate specific fields rather than the entire object.
|
|
12
|
-
*
|
|
13
|
-
* @param schema The original schema to narrow
|
|
14
|
-
* @param paths Array of field paths to extract
|
|
15
|
-
* @returns A narrowed Schema instance containing only the properties at the specified paths
|
|
16
|
-
*/
|
|
17
|
-
export const narrowSchema = <S extends Schema.Schema.AnyNoContext>(
|
|
18
|
-
schema: S,
|
|
19
|
-
paths: string[],
|
|
20
|
-
): Schema.Schema<unknown, unknown> | undefined => {
|
|
21
|
-
const ast = (schema as any)?.ast;
|
|
22
|
-
|
|
23
|
-
if (isTypeLiteral(ast)) {
|
|
24
|
-
// Filter property signatures that match any of the provided paths
|
|
25
|
-
const propertySignatures = ast.propertySignatures.filter((signature) => paths.includes(signature.name.toString()));
|
|
26
|
-
|
|
27
|
-
// If we found at least one matching property
|
|
28
|
-
if (propertySignatures.length > 0) {
|
|
29
|
-
// Create a new TypeLiteral with only the matching properties
|
|
30
|
-
const narrowType = new TypeLiteral(propertySignatures, []);
|
|
31
|
-
return Schema.make(narrowType);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return undefined;
|
|
36
|
-
};
|
package/src/util/tag.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// TODO(ZaymonFC): Push this into the tag picker module.
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Regex pattern for matching tags in the format [Label](id)
|
|
9
|
-
*/
|
|
10
|
-
export const TAG_PATTERN_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Extracts tag IDs from a string in the format [Label](id)
|
|
14
|
-
* @param value The string to extract IDs from
|
|
15
|
-
* @returns Array of extracted IDs or undefined if no matches or value is not a string
|
|
16
|
-
*/
|
|
17
|
-
export const extractTagIds = (value: unknown): string[] | undefined => {
|
|
18
|
-
if (typeof value !== 'string') {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const ids: string[] = [];
|
|
23
|
-
let match;
|
|
24
|
-
|
|
25
|
-
// Use the global regex to find all matches
|
|
26
|
-
while ((match = TAG_PATTERN_REGEX.exec(value)) !== null) {
|
|
27
|
-
if (match[2]) {
|
|
28
|
-
ids.push(match[2]);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return ids.length > 0 ? ids : undefined;
|
|
33
|
-
};
|