@dxos/react-ui-table 0.6.14-main.f49f251 → 0.6.14-staging.77003c1
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 +39 -38
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/ColumnMenu/ColumnSettings.stories.d.ts +4 -4
- package/dist/types/src/components/ColumnMenu/ColumnSettings.stories.d.ts.map +1 -1
- package/dist/types/src/schema/column-utils.d.ts +3 -0
- package/dist/types/src/schema/column-utils.d.ts.map +1 -1
- package/dist/types/src/schema/types.d.ts +3 -2
- package/dist/types/src/schema/types.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/components/ColumnMenu/ColumnMenu.stories.tsx +4 -4
- package/src/components/ColumnMenu/ColumnSettings.stories.tsx +9 -9
- package/src/components/ColumnMenu/ColumnSettings.tsx +3 -3
- package/src/schema/column-utils.ts +33 -27
- package/src/schema/types.ts +3 -2
|
@@ -98,8 +98,8 @@ import { getSize as getSize2, mx as mx2 } from "@dxos/react-ui-theme";
|
|
|
98
98
|
|
|
99
99
|
// packages/ui/react-ui-table/src/components/ColumnMenu/ColumnSettings.tsx
|
|
100
100
|
import React2, { useRef, useState as useState2 } from "react";
|
|
101
|
+
import { FormatEnums } from "@dxos/echo-schema";
|
|
101
102
|
import { Button, Input, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
102
|
-
import { FieldValueTypes } from "@dxos/schema";
|
|
103
103
|
import { safeParseInt } from "@dxos/util";
|
|
104
104
|
var ColumnSettings = ({ column, tableDef, tablesToReference, onUpdate, onDelete, onClose }) => {
|
|
105
105
|
const { t } = useTranslation2(translationKey);
|
|
@@ -170,7 +170,7 @@ var ColumnSettings = ({ column, tableDef, tablesToReference, onUpdate, onDelete,
|
|
|
170
170
|
}, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
|
|
171
171
|
classNames: "is-full",
|
|
172
172
|
placeholder: "Type"
|
|
173
|
-
}), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null,
|
|
173
|
+
}), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, FormatEnums.map((type) => /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
174
174
|
key: type,
|
|
175
175
|
value: type
|
|
176
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, {
|
|
@@ -1390,53 +1390,54 @@ var ColumnBuilder = class {
|
|
|
1390
1390
|
};
|
|
1391
1391
|
|
|
1392
1392
|
// packages/ui/react-ui-table/src/schema/column-utils.ts
|
|
1393
|
-
import {
|
|
1393
|
+
import { TypeEnum } from "@dxos/echo-schema";
|
|
1394
|
+
import { FormatEnum } from "@dxos/echo-schema";
|
|
1395
|
+
import { mapSchemaToFields } from "@dxos/schema";
|
|
1394
1396
|
var schemaToColumnDefs = (schema) => {
|
|
1395
1397
|
const { helper, builder } = createColumnBuilder();
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1398
|
+
return mapSchemaToFields(schema).map(({ property, type, format: format2 }) => {
|
|
1399
|
+
const propertyKey = property.toString();
|
|
1400
|
+
if (!format2) {
|
|
1401
|
+
switch (type) {
|
|
1402
|
+
case TypeEnum.String: {
|
|
1403
|
+
return helper.accessor(propertyKey, builder.string({
|
|
1404
|
+
label: propertyKey,
|
|
1405
|
+
classNames: [
|
|
1406
|
+
property === "id" && "font-mono"
|
|
1407
|
+
]
|
|
1408
|
+
}));
|
|
1409
|
+
}
|
|
1410
|
+
case TypeEnum.Number: {
|
|
1411
|
+
return helper.accessor(propertyKey, builder.number({
|
|
1412
|
+
label: propertyKey
|
|
1413
|
+
}));
|
|
1414
|
+
}
|
|
1415
|
+
case TypeEnum.Boolean: {
|
|
1416
|
+
return helper.accessor(propertyKey, builder.switch({
|
|
1417
|
+
label: propertyKey
|
|
1418
|
+
}));
|
|
1419
|
+
}
|
|
1420
|
+
default: {
|
|
1421
|
+
throw new Error(`Unhandled scalar type: ${type}`);
|
|
1422
|
+
}
|
|
1421
1423
|
}
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
+
}
|
|
1425
|
+
switch (format2) {
|
|
1426
|
+
case FormatEnum.Date: {
|
|
1427
|
+
return helper.accessor(propertyKey, builder.date({
|
|
1424
1428
|
label: propertyKey
|
|
1425
|
-
});
|
|
1426
|
-
break;
|
|
1429
|
+
}));
|
|
1427
1430
|
}
|
|
1428
|
-
case
|
|
1429
|
-
|
|
1431
|
+
case FormatEnum.JSON: {
|
|
1432
|
+
return helper.accessor(propertyKey, builder.json({
|
|
1430
1433
|
label: propertyKey,
|
|
1431
1434
|
id: propertyKey
|
|
1432
|
-
});
|
|
1433
|
-
break;
|
|
1435
|
+
}));
|
|
1434
1436
|
}
|
|
1435
1437
|
default: {
|
|
1436
|
-
throw new Error(`Unhandled
|
|
1438
|
+
throw new Error(`Unhandled format: ${format2}`);
|
|
1437
1439
|
}
|
|
1438
1440
|
}
|
|
1439
|
-
return helper.accessor(propertyKey, column);
|
|
1440
1441
|
});
|
|
1441
1442
|
};
|
|
1442
1443
|
export {
|