@dxos/react-ui-table 0.6.12-staging.e11e696 → 0.6.13-main.548ca8d
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 +40 -124
- 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 +21 -9
- 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/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/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} +1 -1
- 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 +18 -15
- package/src/components/ColumnMenu/ColumnMenu.stories.tsx +13 -12
- 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} +43 -43
- package/src/components/ColumnMenu/index.ts +1 -1
- package/src/components/Table/Table.stories.tsx +97 -85
- package/src/components/Table/Table.tsx +5 -6
- package/src/components/Table/TableContext.tsx +13 -7
- package/src/components/Table/index.ts +2 -1
- package/src/components/Table/props.ts +4 -4
- package/src/helpers.tsx +4 -6
- package/src/schema/{SchemaToTable.stories.tsx → Schema.stories.tsx} +10 -22
- package/src/schema/{schemaToColumns.ts → column-utils.ts} +8 -8
- 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 -146
- package/src/schema/schema.ts +0 -92
|
@@ -6,7 +6,7 @@ var translations_default = [
|
|
|
6
6
|
[translationKey]: {
|
|
7
7
|
"no selection label": "\xA0",
|
|
8
8
|
"number column type label": "Number",
|
|
9
|
-
"boolean column type label": "
|
|
9
|
+
"boolean column type label": "Boolean",
|
|
10
10
|
"date column type label": "Date",
|
|
11
11
|
"string column type label": "Text",
|
|
12
12
|
"ref column type label": "Reference",
|
|
@@ -96,11 +96,14 @@ import React4, { useRef as useRef2, useState as useState6, useCallback as useCal
|
|
|
96
96
|
import { Button as Button2, Popover as Popover2, DropdownMenu } from "@dxos/react-ui";
|
|
97
97
|
import { getSize as getSize2, mx as mx2 } from "@dxos/react-ui-theme";
|
|
98
98
|
|
|
99
|
-
// packages/ui/react-ui-table/src/components/ColumnMenu/
|
|
99
|
+
// packages/ui/react-ui-table/src/components/ColumnMenu/ColumnSettings.tsx
|
|
100
100
|
import React2, { useRef, useState as useState2 } from "react";
|
|
101
101
|
import { Button, Input, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
102
|
+
import { FieldValueTypes } from "@dxos/schema";
|
|
102
103
|
import { safeParseInt } from "@dxos/util";
|
|
103
|
-
var
|
|
104
|
+
var ColumnSettings = ({ column, tableDef, tablesToReference, onUpdate, onDelete, onClose }) => {
|
|
105
|
+
const { t } = useTranslation2(translationKey);
|
|
106
|
+
const propRef = useRef(null);
|
|
104
107
|
const [formState, setFormState] = useState2({
|
|
105
108
|
prop: column.id,
|
|
106
109
|
refTable: column.refTable,
|
|
@@ -109,8 +112,6 @@ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDel
|
|
|
109
112
|
label: column.label,
|
|
110
113
|
digits: String(column.digits ?? "0")
|
|
111
114
|
});
|
|
112
|
-
const propRef = useRef(null);
|
|
113
|
-
const { t } = useTranslation2(translationKey);
|
|
114
115
|
const handleSave = () => {
|
|
115
116
|
const { prop, refTable, refProp, type, label, digits } = formState;
|
|
116
117
|
if (!prop.length || !prop.match(/^[a-zA-Z_].+/i)) {
|
|
@@ -140,9 +141,9 @@ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDel
|
|
|
140
141
|
onClose?.();
|
|
141
142
|
};
|
|
142
143
|
return /* @__PURE__ */ React2.createElement("div", {
|
|
143
|
-
className: "
|
|
144
|
+
className: "flex flex-col w-full gap-4"
|
|
144
145
|
}, /* @__PURE__ */ React2.createElement("div", {
|
|
145
|
-
className: "
|
|
146
|
+
className: "flex flex-col gap-2"
|
|
146
147
|
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, t("column label label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
147
148
|
placeholder: "Column label",
|
|
148
149
|
value: formState.label ?? "",
|
|
@@ -152,9 +153,7 @@ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDel
|
|
|
152
153
|
})),
|
|
153
154
|
autoFocus: true,
|
|
154
155
|
"data-testid": "table.column-settings.label"
|
|
155
|
-
}))
|
|
156
|
-
className: "space-y-1"
|
|
157
|
-
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, t("property key label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
156
|
+
})), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, t("property key label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
158
157
|
ref: propRef,
|
|
159
158
|
placeholder: "Property key",
|
|
160
159
|
value: formState.prop ?? "",
|
|
@@ -162,9 +161,7 @@ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDel
|
|
|
162
161
|
...prevState,
|
|
163
162
|
prop: event.target.value.replace(/[^\w_]/g, "")
|
|
164
163
|
}))
|
|
165
|
-
}))
|
|
166
|
-
className: "space-y-1"
|
|
167
|
-
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, t("column type label")), /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
164
|
+
})), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, t("column type label")), /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
168
165
|
value: formState.type,
|
|
169
166
|
onValueChange: (value) => setFormState((prevState) => ({
|
|
170
167
|
...prevState,
|
|
@@ -173,25 +170,16 @@ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDel
|
|
|
173
170
|
}, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
|
|
174
171
|
classNames: "is-full",
|
|
175
172
|
placeholder: "Type"
|
|
176
|
-
}), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null,
|
|
177
|
-
"number",
|
|
178
|
-
"boolean",
|
|
179
|
-
"string",
|
|
180
|
-
"ref"
|
|
181
|
-
].map((type) => /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
173
|
+
}), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, FieldValueTypes.map((type) => /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
182
174
|
key: type,
|
|
183
175
|
value: type
|
|
184
|
-
}, t(`${type} column type label`))))))))
|
|
185
|
-
className: "space-y-1"
|
|
186
|
-
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, t("digits label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
176
|
+
}, t(`${type} column type label`)))))))), formState.type === "number" && /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, t("digits label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
187
177
|
value: formState.digits ?? "",
|
|
188
178
|
onChange: (event) => setFormState((prevState) => ({
|
|
189
179
|
...prevState,
|
|
190
180
|
digits: event.target.value
|
|
191
181
|
}))
|
|
192
|
-
}))
|
|
193
|
-
className: "space-y-1"
|
|
194
|
-
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, "Table"), /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
182
|
+
})), formState.type === "ref" && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, "Table"), /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
195
183
|
value: formState.refTable,
|
|
196
184
|
onValueChange: (value) => setFormState((prevState) => ({
|
|
197
185
|
...prevState,
|
|
@@ -203,9 +191,7 @@ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDel
|
|
|
203
191
|
}), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, tablesToReference.filter((t2) => t2.id !== tableDef.id).map(({ id, name }) => /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
204
192
|
key: id,
|
|
205
193
|
value: id
|
|
206
|
-
}, name ?? id)))))))
|
|
207
|
-
className: "space-y-1"
|
|
208
|
-
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, "Table property"), /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
194
|
+
}, name ?? id))))))), formState.refTable && /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, "Table property"), /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
209
195
|
value: formState.refProp,
|
|
210
196
|
onValueChange: (value) => setFormState((prevState) => ({
|
|
211
197
|
...prevState,
|
|
@@ -216,10 +202,7 @@ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDel
|
|
|
216
202
|
}), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, tablesToReference.find((tableDef2) => tableDef2.id === formState.refTable)?.columns.map(({ id, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
217
203
|
key: id,
|
|
218
204
|
value: id
|
|
219
|
-
}, label ?? id))))))))), /* @__PURE__ */ React2.createElement("div", {
|
|
220
|
-
role: "none",
|
|
221
|
-
className: "h-1"
|
|
222
|
-
}), /* @__PURE__ */ React2.createElement("div", {
|
|
205
|
+
}, label ?? id))))))))), /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement("div", {
|
|
223
206
|
className: "flex flex-row justify-end gap-1"
|
|
224
207
|
}, /* @__PURE__ */ React2.createElement(Button, {
|
|
225
208
|
onClick: handleDelete,
|
|
@@ -228,7 +211,7 @@ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDel
|
|
|
228
211
|
variant: "primary",
|
|
229
212
|
onClick: handleSave,
|
|
230
213
|
"data-testid": "table.column-settings.save"
|
|
231
|
-
}, t("save label"))));
|
|
214
|
+
}, t("save label")))));
|
|
232
215
|
};
|
|
233
216
|
|
|
234
217
|
// packages/ui/react-ui-table/src/hooks/useColumnSizing.ts
|
|
@@ -269,14 +252,16 @@ import { useState as useState4 } from "react";
|
|
|
269
252
|
|
|
270
253
|
// packages/ui/react-ui-table/src/components/Table/TableContext.tsx
|
|
271
254
|
import React3, { useContext, createContext } from "react";
|
|
272
|
-
|
|
255
|
+
import { raise } from "@dxos/debug";
|
|
256
|
+
var TABLE_NAME = "Table";
|
|
257
|
+
var TableContext = /* @__PURE__ */ createContext(void 0);
|
|
273
258
|
var TableProvider = ({ children, ...value }) => {
|
|
274
259
|
return /* @__PURE__ */ React3.createElement(TableContext.Provider, {
|
|
275
260
|
value
|
|
276
261
|
}, children);
|
|
277
262
|
};
|
|
278
263
|
var useTableContext = () => {
|
|
279
|
-
return useContext(TableContext);
|
|
264
|
+
return useContext(TableContext) ?? raise(new Error("Missing TableContext"));
|
|
280
265
|
};
|
|
281
266
|
|
|
282
267
|
// packages/ui/react-ui-table/src/hooks/useColumnSorting.ts
|
|
@@ -511,7 +496,7 @@ var ColumnMenu = ({ column, columnOrderable, columnPosition, onColumnReorder, ..
|
|
|
511
496
|
className: "opacity-50"
|
|
512
497
|
}, /* @__PURE__ */ React4.createElement(GearSix, {
|
|
513
498
|
className: mx2(getSize2(4), "rotate-90")
|
|
514
|
-
})))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))), /* @__PURE__ */ React4.createElement(Popover2.Portal, null, /* @__PURE__ */ React4.createElement(Popover2.Content, null, /* @__PURE__ */ React4.createElement(Popover2.Viewport, null, /* @__PURE__ */ React4.createElement(
|
|
499
|
+
})))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))), /* @__PURE__ */ React4.createElement(Popover2.Portal, null, /* @__PURE__ */ React4.createElement(Popover2.Content, null, /* @__PURE__ */ React4.createElement(Popover2.Viewport, null, /* @__PURE__ */ React4.createElement(ColumnSettings, {
|
|
515
500
|
...props,
|
|
516
501
|
column,
|
|
517
502
|
onClose: () => setIsColumnSettingsOpen(false)
|
|
@@ -543,7 +528,7 @@ var SortIndicator = ({ direction, onClick }) => {
|
|
|
543
528
|
// packages/ui/react-ui-table/src/components/Table/Table.tsx
|
|
544
529
|
import { Slot } from "@radix-ui/react-slot";
|
|
545
530
|
import { getCoreRowModel, getExpandedRowModel, getGroupedRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
546
|
-
import React8, { Fragment, useCallback as useCallback7, useEffect as useEffect3, useState as useState8, useContext as useContext3
|
|
531
|
+
import React8, { Fragment, memo, useCallback as useCallback7, useEffect as useEffect3, useState as useState8, useContext as useContext3 } from "react";
|
|
547
532
|
import { DensityProvider, useDefaultValue } from "@dxos/react-ui";
|
|
548
533
|
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
549
534
|
|
|
@@ -794,7 +779,7 @@ var TableViewport = ({ children, classNames, asChild, ...props }) => {
|
|
|
794
779
|
}, children);
|
|
795
780
|
};
|
|
796
781
|
var TablePrimitive = (props) => {
|
|
797
|
-
const { role,
|
|
782
|
+
const { role, header = true, rowsSelectable, debug, pinLastRow, columnVisibility, onColumnResize, onDataSelectionChange } = props;
|
|
798
783
|
const columns = useDefaultValue(props.columns, () => []);
|
|
799
784
|
const incomingData = useDefaultValue(props.data, () => []);
|
|
800
785
|
const [data, setData] = useState8([
|
|
@@ -1229,7 +1214,7 @@ var ColumnBuilder = class {
|
|
|
1229
1214
|
value
|
|
1230
1215
|
}, {
|
|
1231
1216
|
F: __dxlog_file,
|
|
1232
|
-
L:
|
|
1217
|
+
L: 377,
|
|
1233
1218
|
S: this,
|
|
1234
1219
|
C: (f, a) => f(...a)
|
|
1235
1220
|
});
|
|
@@ -1327,7 +1312,7 @@ var ColumnBuilder = class {
|
|
|
1327
1312
|
size: 50,
|
|
1328
1313
|
minSize: 50,
|
|
1329
1314
|
header: (column) => label ?? column.header.id,
|
|
1330
|
-
// TODO(zan): Implement sort algorithm
|
|
1315
|
+
// TODO(zan): Implement sort algorithm.
|
|
1331
1316
|
enableSorting: true,
|
|
1332
1317
|
cell: SwitchBuilderCell,
|
|
1333
1318
|
...props,
|
|
@@ -1352,7 +1337,7 @@ var ColumnBuilder = class {
|
|
|
1352
1337
|
const IconOff = off?.Icon ?? X2;
|
|
1353
1338
|
return {
|
|
1354
1339
|
size: size ?? 32,
|
|
1355
|
-
// TODO(zan): Implement sort algorithm
|
|
1340
|
+
// TODO(zan): Implement sort algorithm.
|
|
1356
1341
|
enableSorting: false,
|
|
1357
1342
|
header: (column) => /* @__PURE__ */ React9.createElement("div", {
|
|
1358
1343
|
className: "justify-center"
|
|
@@ -1377,7 +1362,7 @@ var ColumnBuilder = class {
|
|
|
1377
1362
|
/**
|
|
1378
1363
|
* This display column type is for nested/unhandled data to appear as JSON.
|
|
1379
1364
|
*/
|
|
1380
|
-
|
|
1365
|
+
json({ label, classNames, ...props } = {}) {
|
|
1381
1366
|
return {
|
|
1382
1367
|
size: 120,
|
|
1383
1368
|
minSize: 120,
|
|
@@ -1406,113 +1391,41 @@ var ColumnBuilder = class {
|
|
|
1406
1391
|
}
|
|
1407
1392
|
};
|
|
1408
1393
|
|
|
1409
|
-
// packages/ui/react-ui-table/src/schema/
|
|
1410
|
-
import {
|
|
1411
|
-
var classifySchemaProperties = (schema) => {
|
|
1412
|
-
const recurse = (node, path, acc) => {
|
|
1413
|
-
const properties = AST.getPropertySignatures(node);
|
|
1414
|
-
properties.forEach((prop) => {
|
|
1415
|
-
const propName = prop.name.toString();
|
|
1416
|
-
if (prop.isOptional) {
|
|
1417
|
-
const unwrappedAst = unwrapOptionProperty(prop);
|
|
1418
|
-
if (isStruct(unwrappedAst)) {
|
|
1419
|
-
return recurse(unwrappedAst, [
|
|
1420
|
-
...path,
|
|
1421
|
-
propName
|
|
1422
|
-
], acc);
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
if (isStruct(prop.type)) {
|
|
1426
|
-
recurse(prop.type, [
|
|
1427
|
-
...path,
|
|
1428
|
-
propName
|
|
1429
|
-
], acc);
|
|
1430
|
-
} else {
|
|
1431
|
-
acc.push([
|
|
1432
|
-
path.concat(propName).join("."),
|
|
1433
|
-
propertyToColumn(prop)
|
|
1434
|
-
]);
|
|
1435
|
-
}
|
|
1436
|
-
});
|
|
1437
|
-
return acc;
|
|
1438
|
-
};
|
|
1439
|
-
return recurse(schema.ast, [], []);
|
|
1440
|
-
};
|
|
1441
|
-
var isStruct = (node) => AST.isTypeLiteral(node);
|
|
1442
|
-
var isOptionalUnion = (prop) => AST.isUnion(prop.type) && prop.isOptional;
|
|
1443
|
-
var unwrapOptionProperty = (prop) => {
|
|
1444
|
-
if (!isOptionalUnion(prop)) {
|
|
1445
|
-
throw new Error(`Not an optional property: ${String(prop.name)}`);
|
|
1446
|
-
}
|
|
1447
|
-
if (!AST.isUnion(prop.type)) {
|
|
1448
|
-
throw new Error(`Not a union type: ${String(prop.name)}`);
|
|
1449
|
-
}
|
|
1450
|
-
const [type, _undefinedCase] = prop.type.types;
|
|
1451
|
-
return type;
|
|
1452
|
-
};
|
|
1453
|
-
var typeToColumn = (type) => {
|
|
1454
|
-
if (AST.isStringKeyword(type)) {
|
|
1455
|
-
return "string";
|
|
1456
|
-
} else if (AST.isNumberKeyword(type)) {
|
|
1457
|
-
return "number";
|
|
1458
|
-
} else if (AST.isBooleanKeyword(type)) {
|
|
1459
|
-
return "boolean";
|
|
1460
|
-
}
|
|
1461
|
-
if (AST.isRefinement(type)) {
|
|
1462
|
-
return typeToColumn(type.from);
|
|
1463
|
-
}
|
|
1464
|
-
if (AST.isTransformation(type)) {
|
|
1465
|
-
const identifier = AST.getIdentifierAnnotation(type);
|
|
1466
|
-
if (identifier._tag === "Some") {
|
|
1467
|
-
if (identifier.value === "DateFromString") {
|
|
1468
|
-
return "date";
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
return "display";
|
|
1473
|
-
};
|
|
1474
|
-
var propertyToColumn = (prop) => {
|
|
1475
|
-
let type = prop.type;
|
|
1476
|
-
if (prop.isOptional) {
|
|
1477
|
-
type = unwrapOptionProperty(prop);
|
|
1478
|
-
}
|
|
1479
|
-
return typeToColumn(type);
|
|
1480
|
-
};
|
|
1481
|
-
|
|
1482
|
-
// packages/ui/react-ui-table/src/schema/schemaToColumns.ts
|
|
1394
|
+
// packages/ui/react-ui-table/src/schema/column-utils.ts
|
|
1395
|
+
import { FieldValueType, mapSchemaToFields } from "@dxos/schema";
|
|
1483
1396
|
var schemaToColumnDefs = (schema) => {
|
|
1484
1397
|
const { helper, builder } = createColumnBuilder();
|
|
1485
|
-
const classified =
|
|
1398
|
+
const classified = mapSchemaToFields(schema);
|
|
1486
1399
|
return classified.map(([name, type]) => {
|
|
1487
1400
|
const propertyKey = name.toString();
|
|
1488
1401
|
let column;
|
|
1489
1402
|
switch (type) {
|
|
1490
|
-
case
|
|
1403
|
+
case FieldValueType.String: {
|
|
1491
1404
|
column = builder.string({
|
|
1492
1405
|
label: propertyKey
|
|
1493
1406
|
});
|
|
1494
1407
|
break;
|
|
1495
1408
|
}
|
|
1496
|
-
case
|
|
1409
|
+
case FieldValueType.Number: {
|
|
1497
1410
|
column = builder.number({
|
|
1498
1411
|
label: propertyKey
|
|
1499
1412
|
});
|
|
1500
1413
|
break;
|
|
1501
1414
|
}
|
|
1502
|
-
case
|
|
1415
|
+
case FieldValueType.Boolean: {
|
|
1503
1416
|
column = builder.switch({
|
|
1504
1417
|
label: propertyKey
|
|
1505
1418
|
});
|
|
1506
1419
|
break;
|
|
1507
1420
|
}
|
|
1508
|
-
case
|
|
1421
|
+
case FieldValueType.Date: {
|
|
1509
1422
|
column = builder.date({
|
|
1510
1423
|
label: propertyKey
|
|
1511
1424
|
});
|
|
1512
1425
|
break;
|
|
1513
1426
|
}
|
|
1514
|
-
case
|
|
1515
|
-
column = builder.
|
|
1427
|
+
case FieldValueType.JSON: {
|
|
1428
|
+
column = builder.json({
|
|
1516
1429
|
label: propertyKey,
|
|
1517
1430
|
id: propertyKey
|
|
1518
1431
|
});
|
|
@@ -1529,11 +1442,13 @@ export {
|
|
|
1529
1442
|
CellCombobox,
|
|
1530
1443
|
ColumnBuilder,
|
|
1531
1444
|
ColumnMenu,
|
|
1532
|
-
|
|
1445
|
+
ColumnSettings,
|
|
1533
1446
|
MemoizedVirtualizedTableContent,
|
|
1534
1447
|
SortIndicator,
|
|
1448
|
+
TABLE_NAME,
|
|
1535
1449
|
Table,
|
|
1536
1450
|
TablePrimitive,
|
|
1451
|
+
TableProvider,
|
|
1537
1452
|
TableRootContext,
|
|
1538
1453
|
createColumnBuilder,
|
|
1539
1454
|
currentRow,
|
|
@@ -1558,6 +1473,7 @@ export {
|
|
|
1558
1473
|
usePinLastRow,
|
|
1559
1474
|
useRowSelection,
|
|
1560
1475
|
useSortColumn,
|
|
1476
|
+
useTableContext,
|
|
1561
1477
|
useTableRootContext
|
|
1562
1478
|
};
|
|
1563
1479
|
//# sourceMappingURL=index.mjs.map
|