@dxos/react-ui-table 0.5.1-main.bf560fd → 0.5.1-main.c4f37e4

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.
@@ -91,7 +91,7 @@ var CellCombobox = ({ model, value, onValueChange }) => {
91
91
  };
92
92
 
93
93
  // packages/ui/react-ui-table/src/components/ColumnMenu/ColumnMenu.tsx
94
- import { X as X2, GearSix, CaretDown as CaretDown2, ArrowDown, ArrowUp } from "@phosphor-icons/react";
94
+ import { X as X2, GearSix, CaretDown as CaretDown2, ArrowDown, ArrowUp, ArrowRight, ArrowLeft } from "@phosphor-icons/react";
95
95
  import React4, { useRef as useRef2, useState as useState6, useCallback as useCallback5 } from "react";
96
96
  import { Button as Button2, DensityProvider, Popover as Popover2, DropdownMenu } from "@dxos/react-ui";
97
97
  import { getSize as getSize3, mx as mx3 } from "@dxos/react-ui-theme";
@@ -106,7 +106,7 @@ var Section = ({ children, className }) => /* @__PURE__ */ React2.createElement(
106
106
  role: "none",
107
107
  className: mx2("p-2", className)
108
108
  }, children);
109
- var ColumnSettingsForm = ({ column, tableDef, tableDefs, onUpdate, onDelete, onClose }) => {
109
+ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDelete, onClose }) => {
110
110
  const [formState, setFormState] = useState2({
111
111
  prop: column.id,
112
112
  refTable: column.refTable,
@@ -208,7 +208,7 @@ var ColumnSettingsForm = ({ column, tableDef, tableDefs, onUpdate, onDelete, onC
208
208
  }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
209
209
  placeholder: "Table",
210
210
  classNames: "is-full"
211
- }), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, tableDefs.filter((t2) => t2.id !== tableDef.id).map(({ id, name }) => /* @__PURE__ */ React2.createElement(Select.Option, {
211
+ }), /* @__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, {
212
212
  key: id,
213
213
  value: id
214
214
  }, name ?? id))))))), formState.refTable && /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, {
@@ -222,7 +222,7 @@ var ColumnSettingsForm = ({ column, tableDef, tableDefs, onUpdate, onDelete, onC
222
222
  }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
223
223
  placeholder: "Property",
224
224
  classNames: "is-full"
225
- }), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, tableDefs.find((tableDef2) => tableDef2.id === formState.refTable)?.columns.map(({ id, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
225
+ }), /* @__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, {
226
226
  key: id,
227
227
  value: id
228
228
  }, label ?? id)))))))), /* @__PURE__ */ React2.createElement(Separator, {
@@ -450,7 +450,7 @@ var useRowSelection = (props) => {
450
450
  };
451
451
 
452
452
  // packages/ui/react-ui-table/src/components/ColumnMenu/ColumnMenu.tsx
453
- var ColumnMenu = ({ column, ...props }) => {
453
+ var ColumnMenu = ({ column, columnOrderable, columnPosition, onColumnReorder, ...props }) => {
454
454
  const title = column.label?.length ? column.label : column.id;
455
455
  const header = props.context.header;
456
456
  const { canSort, sortDirection, onSelectSort, onToggleSort, onClearSort } = useSortColumn(header.column);
@@ -525,6 +525,22 @@ var ColumnMenu = ({ column, ...props }) => {
525
525
  className: "opacity-50"
526
526
  }, /* @__PURE__ */ React4.createElement(X2, {
527
527
  className: getSize3(4)
528
+ })))), columnOrderable && /* @__PURE__ */ React4.createElement(React4.Fragment, null, columnPosition !== "start" && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
529
+ onClick: () => onColumnReorder(header.column.id, "left")
530
+ }, /* @__PURE__ */ React4.createElement("span", {
531
+ className: "grow"
532
+ }, "Move left"), /* @__PURE__ */ React4.createElement("span", {
533
+ className: "opacity-50"
534
+ }, /* @__PURE__ */ React4.createElement(ArrowLeft, {
535
+ className: mx3(getSize3(4))
536
+ }))), columnPosition !== "end" && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
537
+ onClick: () => onColumnReorder(header.column.id, "right")
538
+ }, /* @__PURE__ */ React4.createElement("span", {
539
+ className: "grow"
540
+ }, "Move right"), /* @__PURE__ */ React4.createElement("span", {
541
+ className: "opacity-50"
542
+ }, /* @__PURE__ */ React4.createElement(ArrowRight, {
543
+ className: mx3(getSize3(4))
528
544
  })))), /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
529
545
  onClick: onOpenColumnSettings
530
546
  }, /* @__PURE__ */ React4.createElement("span", {
@@ -974,8 +990,8 @@ var GroupedTableContent = () => {
974
990
  };
975
991
  var Table = {
976
992
  Root: TableRoot,
977
- Table: TablePrimitive,
978
- Viewport: TableViewport
993
+ Viewport: TableViewport,
994
+ Main: TablePrimitive
979
995
  };
980
996
 
981
997
  // packages/ui/react-ui-table/src/helpers.tsx