@dxos/react-ui-table 0.6.14-main.f49f251 → 0.6.14-staging.54a8bab

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.
@@ -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, FieldValueTypes.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, 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 { FieldValueType, mapSchemaToFields } from "@dxos/schema";
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
- const classified = mapSchemaToFields(schema);
1397
- return classified.map(([name, type]) => {
1398
- const propertyKey = name.toString();
1399
- let column;
1400
- switch (type) {
1401
- case FieldValueType.String: {
1402
- column = builder.string({
1403
- label: propertyKey,
1404
- classNames: [
1405
- name === "id" && "font-mono"
1406
- ]
1407
- });
1408
- break;
1409
- }
1410
- case FieldValueType.Number: {
1411
- column = builder.number({
1412
- label: propertyKey
1413
- });
1414
- break;
1415
- }
1416
- case FieldValueType.Boolean: {
1417
- column = builder.switch({
1418
- label: propertyKey
1419
- });
1420
- break;
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
- case FieldValueType.Date: {
1423
- column = builder.date({
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 FieldValueType.JSON: {
1429
- column = builder.json({
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 column type: ${type}`);
1438
+ throw new Error(`Unhandled format: ${format2}`);
1437
1439
  }
1438
1440
  }
1439
- return helper.accessor(propertyKey, column);
1440
1441
  });
1441
1442
  };
1442
1443
  export {