@dxos/react-ui-table 0.9.0 → 0.9.1-staging.ee54ba693a
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-4KOQTPFC.mjs → chunk-K4J2CKTZ.mjs} +73 -24
- package/dist/lib/browser/chunk-K4J2CKTZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-62PYOJPY.mjs → chunk-VV3P3ADH.mjs} +5 -5
- package/dist/lib/browser/chunk-VV3P3ADH.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +76 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +2 -2
- package/dist/lib/browser/translations.mjs +5 -2
- package/dist/lib/browser/translations.mjs.map +2 -2
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{chunk-KOSV2J5N.mjs → chunk-E6V274ZW.mjs} +73 -24
- package/dist/lib/node-esm/chunk-E6V274ZW.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7LMOZUTS.mjs → chunk-RPEWNOZZ.mjs} +5 -5
- package/dist/lib/node-esm/chunk-RPEWNOZZ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +76 -10
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +2 -2
- package/dist/lib/node-esm/translations.mjs +5 -2
- package/dist/lib/node-esm/translations.mjs.map +2 -2
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +4 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +4 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +1 -0
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +6 -3
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableToolbar.d.ts +3 -1
- package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +7 -4
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +2 -3
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/index.d.ts +1 -0
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +15 -8
- 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/model/table-view-state.d.ts +19 -0
- package/dist/types/src/model/table-view-state.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +4 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Table.d.ts +3 -11
- package/dist/types/src/types/Table.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +43 -44
- package/src/components/Table/Table.stories.tsx +3 -3
- package/src/components/Table/Table.tsx +1 -0
- package/src/components/Table/TableToolbar.tsx +38 -5
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +2 -2
- package/src/components/testing.ts +8 -6
- package/src/hooks/useTableModel.ts +7 -6
- package/src/model/index.ts +1 -0
- package/src/model/table-model.test.ts +93 -5
- package/src/model/table-model.ts +36 -20
- package/src/model/table-presentation.test.ts +6 -4
- package/src/model/table-presentation.ts +34 -4
- package/src/model/table-view-state.ts +30 -0
- package/src/translations.ts +4 -1
- package/src/types/Table.ts +17 -19
- package/dist/lib/browser/chunk-4KOQTPFC.mjs.map +0 -7
- package/dist/lib/browser/chunk-62PYOJPY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7LMOZUTS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KOSV2J5N.mjs.map +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/Table.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\n// QueryAST is referenced indirectly through `Type.InstanceType<typeof TableSchema>`\n// (Ref.Ref(View.View) → View.View → QueryAST.Query) in the emitted .d.ts; the\n// namespace import keeps the inferred types portable.\n// eslint-disable-next-line unused-imports/no-unused-imports\nimport { Annotation, DXN, JsonSchema, Obj, QueryAST, Ref, Type, View } from '@dxos/echo';\nimport { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/Annotation';\nimport { type JsonSchema as JsonSchemaType } from '@dxos/echo/JsonSchema';\nimport { SchemaEx } from '@dxos/effect';\nimport { ViewAnnotation } from '@dxos/schema';\n\n// TODO(wittjosiah): Try to clean up this type inference.\nexport class Table extends Type.makeObject<Table>(DXN.make('org.dxos.type.table', '0.1.0'))(\n Schema.Struct({\n name: Schema.String.pipe(Schema.optional),\n\n view: Ref.Ref(View.View).pipe(FormInputAnnotation.set(false)),\n\n sizes: Schema.Record({\n // TODO(wittjosiah): Should be JsonPath.\n key: Schema.String,\n value: Schema.Number,\n }).pipe(Schema.mutable, FormInputAnnotation.set(false)),\n }).pipe(\n LabelAnnotation.set(['name']),\n ViewAnnotation.set(['view']),\n Annotation.IconAnnotation.set({ icon: 'ph--table--regular', hue: 'green' }),\n ),\n) {}\n\ntype MakeProps = {\n name?: string;\n sizes?: Record<string, number>;\n view: View.View;\n /** Required to auto-size columns. */\n jsonSchema?: JsonSchemaType;\n};\n\n/**\n * Make a table as a view of a data set.\n */\nexport const make = ({ name, sizes = {}, view, jsonSchema }: MakeProps): Table => {\n const table = Obj.make(Table, { name, view: Ref.make(view), sizes } as Obj.MakeProps<typeof Table>);\n\n // Preset sizes.\n if (jsonSchema) {\n const schema = JsonSchema.toEffectSchema(jsonSchema);\n const properties = SchemaAST.getPropertySignatures(schema.ast);\n for (const property of properties) {\n const name = property.name.toString() as SchemaEx.JsonPath;\n if (sizes?.[name]) {\n table.sizes[name] = sizes[name];\n continue;\n }\n\n Match.type<SchemaAST.AST>().pipe(\n Match.when({ _tag: 'BooleanKeyword' }, () => {\n table.sizes[name] = 100;\n }),\n Match.when({ _tag: 'NumberKeyword' }, () => {\n table.sizes[name] = 100;\n }),\n Match.orElse(() => {\n // Noop.\n }),\n )(property.type);\n }\n }\n\n return table;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;;AAIA,YAAYA,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,eAAe;AAM3B,SAASC,YAAYC,KAAKC,YAAYC,KAAeC,KAAKC,MAAMC,YAAY;AAC5E,SAASC,qBAAqBC,uBAAuB;AAGrD,SAASC,sBAAsB;AAGxB,IAAMC,QAAN,cAAoBL,KAAKM,WAAkBV,IAAIW,KAAK,uBAAuB,OAAA,CAAA,EACzEC,cAAO;EACZC,MAAaC,cAAOC,KAAYC,eAAQ;EAExCC,MAAMd,IAAIA,IAAIE,KAAKA,IAAI,EAAEU,KAAKT,oBAAoBY,IAAI,KAAA,CAAA;EAEtDC,OAAcC,cAAO;;IAEnBC,KAAYP;IACZQ,OAAcC;EAChB,CAAA,EAAGR,KAAYS,gBAASlB,oBAAoBY,IAAI,KAAA,CAAA;AAClD,CAAA,EAAGH,KACDR,gBAAgBW,IAAI;EAAC;CAAO,GAC5BV,eAAeU,IAAI;EAAC;CAAO,GAC3BnB,WAAW0B,eAAeP,IAAI;EAAEQ,MAAM;EAAsBC,KAAK;AAAQ,CAAA,CAAA,CAAA,EAAA;AAE1E;AAaI,IAAMhB,OAAO,CAAC,EAAEE,MAAMM,QAAQ,CAAC,GAAGF,MAAMW,WAAU,MAAa;AACpE,QAAMC,QAAQ3B,IAAIS,KAAKF,OAAO;IAAEI;IAAMI,MAAMd,IAAIQ,KAAKM,IAAAA;IAAOE;EAAM,CAAA;AAGlE,MAAIS,YAAY;AACd,UAAME,SAAS7B,WAAW8B,eAAeH,UAAAA;AACzC,UAAMI,aAAuBC,gCAAsBH,OAAOI,GAAG;AAC7D,eAAWC,YAAYH,YAAY;AACjC,YAAMnB,QAAOsB,SAAStB,KAAKuB,SAAQ;AACnC,UAAIjB,QAAQN,KAAAA,GAAO;AACjBgB,cAAMV,MAAMN,KAAAA,IAAQM,MAAMN,KAAAA;AAC1B;MACF;AAEAjB,MAAMyC,WAAI,EAAkBtB,KACpBuB,WAAK;QAAEC,MAAM;MAAiB,GAAG,MAAA;AACrCV,cAAMV,MAAMN,KAAAA,IAAQ;MACtB,CAAA,GACMyB,WAAK;QAAEC,MAAM;MAAgB,GAAG,MAAA;AACpCV,cAAMV,MAAMN,KAAAA,IAAQ;MACtB,CAAA,GACM2B,aAAO,MAAA;MAEb,CAAA,CAAA,EACAL,SAASE,IAAI;IACjB;EACF;AAEA,SAAOR;AACT;",
|
|
6
|
+
"names": ["Match", "Schema", "SchemaAST", "Annotation", "DXN", "JsonSchema", "Obj", "Ref", "Type", "View", "FormInputAnnotation", "LabelAnnotation", "ViewAnnotation", "Table", "makeObject", "make", "Struct", "name", "String", "pipe", "optional", "view", "set", "sizes", "Record", "key", "value", "Number", "mutable", "IconAnnotation", "icon", "hue", "jsonSchema", "table", "schema", "toEffectSchema", "properties", "getPropertySignatures", "ast", "property", "toString", "type", "when", "_tag", "orElse"]
|
|
7
|
+
}
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
BUTTON_IDENTIFIERS,
|
|
3
3
|
CONTROL_IDENTIFIERS,
|
|
4
4
|
CheckboxStory,
|
|
5
|
+
FieldSortSchema,
|
|
5
6
|
SwitchStory,
|
|
6
7
|
TableModel,
|
|
7
8
|
TablePresentation,
|
|
@@ -13,13 +14,14 @@ import {
|
|
|
13
14
|
getSortValue,
|
|
14
15
|
tableButtons,
|
|
15
16
|
tableControls,
|
|
17
|
+
tableSortAspect,
|
|
16
18
|
useAddRow,
|
|
17
19
|
useProjectionModel,
|
|
18
20
|
useTableModel
|
|
19
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-K4J2CKTZ.mjs";
|
|
20
22
|
import {
|
|
21
23
|
Table_exports
|
|
22
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-VV3P3ADH.mjs";
|
|
23
25
|
import "./chunk-J5LGTIGS.mjs";
|
|
24
26
|
|
|
25
27
|
// src/components/Table/Table.tsx
|
|
@@ -1135,10 +1137,11 @@ TableContent.displayName = TABLE_CONTENT_NAME;
|
|
|
1135
1137
|
import { Atom as Atom3, RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
|
|
1136
1138
|
import React8, { useContext as useContext2, useEffect as useEffect4, useMemo as useMemo5 } from "react";
|
|
1137
1139
|
import { composable as composable2, composableProps as composableProps2 } from "@dxos/react-ui";
|
|
1138
|
-
import { Menu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
|
|
1140
|
+
import { Menu, createGapSeparator, createMenuAction, createMenuItemGroup, useMenuActions } from "@dxos/react-ui-menu";
|
|
1139
1141
|
import { translationKey as translationKey4 } from "#translations";
|
|
1140
|
-
var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom3.make((get) => {
|
|
1142
|
+
var createTableToolbarActions = ({ stateAtom, onAdd, onSave, onExport, customActions }) => Atom3.make((get) => {
|
|
1141
1143
|
const nodes = [];
|
|
1144
|
+
const edges = [];
|
|
1142
1145
|
if (onAdd) {
|
|
1143
1146
|
const add = createMenuAction("add-row", onAdd, {
|
|
1144
1147
|
type: "add-row",
|
|
@@ -1152,6 +1155,11 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1152
1155
|
testId: "table.toolbar.add-row"
|
|
1153
1156
|
});
|
|
1154
1157
|
nodes.push(add);
|
|
1158
|
+
edges.push({
|
|
1159
|
+
source: "root",
|
|
1160
|
+
target: add.id,
|
|
1161
|
+
relation: "child"
|
|
1162
|
+
});
|
|
1155
1163
|
}
|
|
1156
1164
|
if (onSave) {
|
|
1157
1165
|
const state = get(stateAtom);
|
|
@@ -1169,14 +1177,68 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1169
1177
|
hidden: !state.viewDirty
|
|
1170
1178
|
});
|
|
1171
1179
|
nodes.push(save);
|
|
1180
|
+
edges.push({
|
|
1181
|
+
source: "root",
|
|
1182
|
+
target: save.id,
|
|
1183
|
+
relation: "child"
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
if (onExport) {
|
|
1187
|
+
const exportGroup = createMenuItemGroup("export-rows", {
|
|
1188
|
+
label: [
|
|
1189
|
+
"export-rows.menu",
|
|
1190
|
+
{
|
|
1191
|
+
ns: translationKey4
|
|
1192
|
+
}
|
|
1193
|
+
],
|
|
1194
|
+
icon: "ph--export--regular",
|
|
1195
|
+
iconOnly: true,
|
|
1196
|
+
variant: "dropdownMenu"
|
|
1197
|
+
});
|
|
1198
|
+
nodes.push(exportGroup);
|
|
1199
|
+
edges.push({
|
|
1200
|
+
source: "root",
|
|
1201
|
+
target: exportGroup.id,
|
|
1202
|
+
relation: "child"
|
|
1203
|
+
});
|
|
1204
|
+
const formats = [
|
|
1205
|
+
{
|
|
1206
|
+
format: "csv",
|
|
1207
|
+
type: "export-csv",
|
|
1208
|
+
label: "export-rows-csv.menu"
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
format: "json",
|
|
1212
|
+
type: "export-json",
|
|
1213
|
+
label: "export-rows-json.menu"
|
|
1214
|
+
},
|
|
1215
|
+
{
|
|
1216
|
+
format: "xml",
|
|
1217
|
+
type: "export-xml",
|
|
1218
|
+
label: "export-rows-xml.menu"
|
|
1219
|
+
}
|
|
1220
|
+
];
|
|
1221
|
+
for (const { format, type, label } of formats) {
|
|
1222
|
+
const action = createMenuAction(type, () => onExport(format), {
|
|
1223
|
+
type,
|
|
1224
|
+
label: [
|
|
1225
|
+
label,
|
|
1226
|
+
{
|
|
1227
|
+
ns: translationKey4
|
|
1228
|
+
}
|
|
1229
|
+
]
|
|
1230
|
+
});
|
|
1231
|
+
nodes.push(action);
|
|
1232
|
+
edges.push({
|
|
1233
|
+
source: exportGroup.id,
|
|
1234
|
+
target: action.id,
|
|
1235
|
+
relation: "child"
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1172
1238
|
}
|
|
1173
1239
|
const gap = createGapSeparator();
|
|
1174
1240
|
nodes.push(...gap.nodes);
|
|
1175
|
-
|
|
1176
|
-
source: "root",
|
|
1177
|
-
target,
|
|
1178
|
-
relation: "child"
|
|
1179
|
-
}));
|
|
1241
|
+
edges.push(...gap.edges);
|
|
1180
1242
|
if (customActions) {
|
|
1181
1243
|
const custom = get(customActions);
|
|
1182
1244
|
nodes.push(...custom.nodes);
|
|
@@ -1187,7 +1249,7 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
|
|
|
1187
1249
|
edges
|
|
1188
1250
|
};
|
|
1189
1251
|
});
|
|
1190
|
-
var TableToolbar = composable2(({ attendableId, viewDirty, onAdd, onSave, customActions, ...props }, forwardedRef) => {
|
|
1252
|
+
var TableToolbar = composable2(({ attendableId, viewDirty, onAdd, onSave, onExport, customActions, ...props }, forwardedRef) => {
|
|
1191
1253
|
const registry = useContext2(RegistryContext2);
|
|
1192
1254
|
const stateAtom = useMemo5(() => Atom3.make({
|
|
1193
1255
|
viewDirty
|
|
@@ -1205,11 +1267,13 @@ var TableToolbar = composable2(({ attendableId, viewDirty, onAdd, onSave, custom
|
|
|
1205
1267
|
stateAtom,
|
|
1206
1268
|
onAdd,
|
|
1207
1269
|
onSave,
|
|
1270
|
+
onExport,
|
|
1208
1271
|
customActions
|
|
1209
1272
|
}), [
|
|
1210
1273
|
stateAtom,
|
|
1211
1274
|
onAdd,
|
|
1212
1275
|
onSave,
|
|
1276
|
+
onExport,
|
|
1213
1277
|
customActions
|
|
1214
1278
|
]);
|
|
1215
1279
|
const menuActions = useMenuActions(actionsCreator);
|
|
@@ -1325,6 +1389,7 @@ export {
|
|
|
1325
1389
|
CONTROL_IDENTIFIERS,
|
|
1326
1390
|
CheckboxStory,
|
|
1327
1391
|
DynamicTable,
|
|
1392
|
+
FieldSortSchema,
|
|
1328
1393
|
ModalController,
|
|
1329
1394
|
SwitchStory,
|
|
1330
1395
|
Table,
|
|
@@ -1341,6 +1406,7 @@ export {
|
|
|
1341
1406
|
narrowSchema,
|
|
1342
1407
|
tableButtons,
|
|
1343
1408
|
tableControls,
|
|
1409
|
+
tableSortAspect,
|
|
1344
1410
|
touch,
|
|
1345
1411
|
useAddRow,
|
|
1346
1412
|
useProjectionModel,
|