@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.
Files changed (95) hide show
  1. package/dist/lib/browser/{chunk-PFFO5LYM.mjs → chunk-YWNRUF4J.mjs} +6 -7
  2. package/dist/lib/browser/chunk-YWNRUF4J.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +181 -330
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/types/index.mjs +1 -1
  7. package/dist/lib/node/{chunk-VREQOYRW.cjs → chunk-TGG6OZ54.cjs} +8 -9
  8. package/dist/lib/node/chunk-TGG6OZ54.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +160 -306
  10. package/dist/lib/node/index.cjs.map +4 -4
  11. package/dist/lib/node/meta.json +1 -1
  12. package/dist/lib/node/types/index.cjs +3 -3
  13. package/dist/lib/node/types/index.cjs.map +1 -1
  14. package/dist/lib/node-esm/{chunk-34JG3SDI.mjs → chunk-KKLP54L3.mjs} +6 -7
  15. package/dist/lib/node-esm/chunk-KKLP54L3.mjs.map +7 -0
  16. package/dist/lib/node-esm/index.mjs +181 -330
  17. package/dist/lib/node-esm/index.mjs.map +4 -4
  18. package/dist/lib/node-esm/meta.json +1 -1
  19. package/dist/lib/node-esm/types/index.mjs +1 -1
  20. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
  21. package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
  22. package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
  23. package/dist/types/src/components/Table/DynamicTable.d.ts +4 -3
  24. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  25. package/dist/types/src/components/Table/RefPanel.d.ts +9 -0
  26. package/dist/types/src/components/Table/RefPanel.d.ts.map +1 -0
  27. package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
  28. package/dist/types/src/components/Table/Table.d.ts +0 -2
  29. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  30. package/dist/types/src/components/Table/Table.stories.d.ts +0 -1
  31. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  32. package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -1
  33. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +0 -3
  34. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  35. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  36. package/dist/types/src/components/TableCellEditor/extension.d.ts.map +1 -1
  37. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +2 -2
  38. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
  39. package/dist/types/src/components/testing.d.ts +40 -40
  40. package/dist/types/src/components/testing.d.ts.map +1 -1
  41. package/dist/types/src/hooks/useTableModel.d.ts +2 -2
  42. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  43. package/dist/types/src/model/modal-controller.d.ts +3 -3
  44. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  45. package/dist/types/src/model/selection-model.d.ts.map +1 -1
  46. package/dist/types/src/model/table-model.d.ts.map +1 -1
  47. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  48. package/dist/types/src/types/table.d.ts +43 -44
  49. package/dist/types/src/types/table.d.ts.map +1 -1
  50. package/dist/types/src/util/dynamic-table.d.ts +3 -4
  51. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  52. package/dist/types/src/util/index.d.ts +0 -1
  53. package/dist/types/src/util/index.d.ts.map +1 -1
  54. package/dist/types/src/util/signals.d.ts.map +1 -1
  55. package/dist/types/src/util/table-buttons.d.ts +14 -0
  56. package/dist/types/src/util/table-buttons.d.ts.map +1 -1
  57. package/dist/types/src/util/table-controls.d.ts.map +1 -1
  58. package/dist/types/src/util/table.d.ts +2 -2
  59. package/dist/types/src/util/table.d.ts.map +1 -1
  60. package/dist/types/tsconfig.tsbuildinfo +1 -1
  61. package/package.json +33 -34
  62. package/src/components/Table/CreateRefPanel.tsx +5 -5
  63. package/src/components/Table/DynamicTable.stories.tsx +4 -4
  64. package/src/components/Table/DynamicTable.tsx +5 -4
  65. package/src/components/Table/RefPanel.tsx +52 -0
  66. package/src/components/Table/Table.stories.tsx +27 -73
  67. package/src/components/Table/Table.tsx +28 -25
  68. package/src/components/Table/relations.stories.tsx +31 -38
  69. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +10 -11
  70. package/src/components/TableCellEditor/TableCellEditor.tsx +4 -45
  71. package/src/components/TableToolbar/TableToolbar.tsx +13 -12
  72. package/src/components/testing.ts +9 -10
  73. package/src/hooks/useTableModel.ts +2 -2
  74. package/src/model/modal-controller.ts +3 -3
  75. package/src/model/table-model.test.ts +6 -7
  76. package/src/model/table-model.ts +2 -19
  77. package/src/model/table-presentation.test.ts +6 -7
  78. package/src/model/table-presentation.ts +10 -54
  79. package/src/types/table.ts +7 -15
  80. package/src/util/dynamic-table.ts +6 -9
  81. package/src/util/index.ts +0 -1
  82. package/src/util/table-buttons.ts +23 -0
  83. package/src/util/table.ts +16 -13
  84. package/dist/lib/browser/chunk-PFFO5LYM.mjs.map +0 -7
  85. package/dist/lib/node/chunk-VREQOYRW.cjs.map +0 -7
  86. package/dist/lib/node-esm/chunk-34JG3SDI.mjs.map +0 -7
  87. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +0 -13
  88. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +0 -1
  89. package/dist/types/src/util/schema.d.ts +0 -12
  90. package/dist/types/src/util/schema.d.ts.map +0 -1
  91. package/dist/types/src/util/tag.d.ts +0 -11
  92. package/dist/types/src/util/tag.d.ts.map +0 -1
  93. package/src/components/TableCellEditor/FormCellEditor.tsx +0 -94
  94. package/src/util/schema.ts +0 -36
  95. 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
- };
@@ -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
- };