@dxos/react-ui-table 0.3.8 → 0.3.9-main.03b62b6

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.
@@ -1,45 +1,42 @@
1
1
  // packages/ui/react-ui-table/src/components/ColumnMenu.tsx
2
2
  import { Check, CaretDown, Trash, X } from "@phosphor-icons/react";
3
3
  import React, { useRef, useState } from "react";
4
- import { Button, DensityProvider, Input, Popover, Select, Separator } from "@dxos/react-ui";
4
+ import { Button, DensityProvider, Input, Popover, Select, Separator, useTranslation } from "@dxos/react-ui";
5
5
  import { getSize, mx } from "@dxos/react-ui-theme";
6
6
  import { safeParseInt } from "@dxos/util";
7
7
 
8
- // packages/ui/react-ui-table/src/schema.ts
9
- var columnTypes = /* @__PURE__ */ new Map([
10
- [
11
- "string",
12
- "Text"
13
- ],
14
- [
15
- "boolean",
16
- "Checkbox"
17
- ],
18
- [
19
- "number",
20
- "Number"
21
- ],
22
- [
23
- "date",
24
- "Date"
25
- ],
26
- [
27
- "ref",
28
- "Reference"
29
- ]
30
- ]);
8
+ // packages/ui/react-ui-table/src/translations.ts
9
+ var translationKey = "table";
10
+ var translations_default = [
11
+ {
12
+ "en-US": {
13
+ [translationKey]: {
14
+ "no selection label": "\xA0",
15
+ "number column type label": "Number",
16
+ "boolean column type label": "Toggle",
17
+ "date column type label": "Date",
18
+ "string column type label": "Text",
19
+ "ref column type label": "Reference",
20
+ "digits label": "Decimal places",
21
+ "save label": "Save",
22
+ "delete label": "Delete",
23
+ "column label label": "Label",
24
+ "property key label": "Property",
25
+ "column type label": "Type"
26
+ }
27
+ }
28
+ }
29
+ ];
31
30
 
32
31
  // packages/ui/react-ui-table/src/components/ColumnMenu.tsx
33
32
  var ColumnMenu = ({ column, ...props }) => {
34
33
  const title = column.label?.length ? column.label : column.id;
35
34
  return /* @__PURE__ */ React.createElement("div", {
36
- className: "flex grow items-center overflow-hidden"
35
+ className: "flex items-center gap-2"
37
36
  }, /* @__PURE__ */ React.createElement("div", {
38
- className: "truncate",
37
+ className: "flex-1 min-is-0 truncate",
39
38
  title
40
39
  }, title), /* @__PURE__ */ React.createElement("div", {
41
- className: "grow"
42
- }), /* @__PURE__ */ React.createElement("div", {
43
40
  className: "flex shrink-0"
44
41
  }, /* @__PURE__ */ React.createElement(ColumnPanel, {
45
42
  ...props,
@@ -59,6 +56,7 @@ var ColumnPanel = ({ context, tableDefs, tableDef, column, onUpdate, onDelete })
59
56
  const [label, setLabel] = useState(column.label);
60
57
  const [digits, setDigits] = useState(String(column.digits ?? "0"));
61
58
  const propRef = useRef(null);
59
+ const { t } = useTranslation(translationKey);
62
60
  const handleCancel = () => {
63
61
  setProp(column.id);
64
62
  setOpen(false);
@@ -93,7 +91,7 @@ var ColumnPanel = ({ context, tableDefs, tableDef, column, onUpdate, onDelete })
93
91
  asChild: true
94
92
  }, /* @__PURE__ */ React.createElement(Button, {
95
93
  variant: "ghost",
96
- classNames: "p-0"
94
+ classNames: "p-1"
97
95
  }, /* @__PURE__ */ React.createElement(CaretDown, {
98
96
  className: getSize(4)
99
97
  }))), /* @__PURE__ */ React.createElement(Popover.Portal, null, /* @__PURE__ */ React.createElement(Popover.Content, null, /* @__PURE__ */ React.createElement(Popover.Viewport, {
@@ -104,14 +102,14 @@ var ColumnPanel = ({ context, tableDefs, tableDef, column, onUpdate, onDelete })
104
102
  className: "flex flex-col gap-1"
105
103
  }, /* @__PURE__ */ React.createElement(Section, null, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, {
106
104
  classNames: "mbe-1"
107
- }, "Label"), /* @__PURE__ */ React.createElement(Input.TextInput, {
105
+ }, t("column label label")), /* @__PURE__ */ React.createElement(Input.TextInput, {
108
106
  placeholder: "Column label",
109
107
  value: label ?? "",
110
108
  onChange: (event) => setLabel(event.target.value),
111
109
  autoFocus: true
112
110
  })), /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, {
113
111
  classNames: "mbe-1 mbs-3"
114
- }, "Property"), /* @__PURE__ */ React.createElement(Input.TextInput, {
112
+ }, t("property key label")), /* @__PURE__ */ React.createElement(Input.TextInput, {
115
113
  ref: propRef,
116
114
  placeholder: "Property key",
117
115
  // TODO(burdon): Provide hooks for value normalization, ENTER, ESC, etc.
@@ -119,18 +117,23 @@ var ColumnPanel = ({ context, tableDefs, tableDef, column, onUpdate, onDelete })
119
117
  onChange: (event) => setProp(event.target.value.replace(/[^\w_]/g, ""))
120
118
  })), /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, {
121
119
  classNames: "mbe-1 mbs-3"
122
- }, "Type"), /* @__PURE__ */ React.createElement(Select.Root, {
120
+ }, t("column type label")), /* @__PURE__ */ React.createElement(Select.Root, {
123
121
  value: type,
124
122
  onValueChange: setType
125
123
  }, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
126
124
  placeholder: "Type",
127
125
  classNames: "is-full"
128
- }), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, Array.from(columnTypes.entries()).map(([type2, label2]) => /* @__PURE__ */ React.createElement(Select.Option, {
126
+ }), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, [
127
+ "number",
128
+ "boolean",
129
+ "string",
130
+ "ref"
131
+ ].map((type2) => /* @__PURE__ */ React.createElement(Select.Option, {
129
132
  key: type2,
130
133
  value: type2
131
- }, label2)))))))), type === "number" && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Section, null, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, {
134
+ }, t(`${type2} column type label`))))))))), type === "number" && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Section, null, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, {
132
135
  classNames: "mbe-1 mbs-3"
133
- }, "Decimal places"), /* @__PURE__ */ React.createElement(Input.TextInput, {
136
+ }, t("digits label")), /* @__PURE__ */ React.createElement(Input.TextInput, {
134
137
  value: digits ?? "",
135
138
  onChange: (event) => setDigits(event.target.value)
136
139
  })))), type === "ref" && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Section, null, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, {
@@ -141,7 +144,7 @@ var ColumnPanel = ({ context, tableDefs, tableDef, column, onUpdate, onDelete })
141
144
  }, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
142
145
  placeholder: "Table",
143
146
  classNames: "is-full"
144
- }), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, tableDefs.filter((t) => t.id !== tableDef.id).map(({ id, name }) => /* @__PURE__ */ React.createElement(Select.Option, {
147
+ }), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, tableDefs.filter((t2) => t2.id !== tableDef.id).map(({ id, name }) => /* @__PURE__ */ React.createElement(Select.Option, {
145
148
  key: id,
146
149
  value: id
147
150
  }, name ?? id))))))), refTable && /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, {
@@ -163,21 +166,23 @@ var ColumnPanel = ({ context, tableDefs, tableDef, column, onUpdate, onDelete })
163
166
  variant: "primary",
164
167
  classNames: "is-full flex gap-2",
165
168
  onClick: handleSave
166
- }, /* @__PURE__ */ React.createElement("span", null, "Save"), /* @__PURE__ */ React.createElement("div", {
169
+ }, /* @__PURE__ */ React.createElement("span", null, t("save label")), /* @__PURE__ */ React.createElement("div", {
167
170
  className: "grow"
168
171
  }), /* @__PURE__ */ React.createElement(Check, {
169
172
  className: getSize(5)
170
173
  })), /* @__PURE__ */ React.createElement(Button, {
171
174
  classNames: "is-full flex gap-2",
172
175
  onClick: handleCancel
173
- }, /* @__PURE__ */ React.createElement("span", null, "Cancel"), /* @__PURE__ */ React.createElement("div", {
176
+ }, /* @__PURE__ */ React.createElement("span", null, t("cancel label", {
177
+ ns: "os"
178
+ })), /* @__PURE__ */ React.createElement("div", {
174
179
  className: "grow"
175
180
  }), /* @__PURE__ */ React.createElement(X, {
176
181
  className: getSize(5)
177
182
  })), /* @__PURE__ */ React.createElement(Button, {
178
183
  classNames: "is-full flex gap-2",
179
184
  onClick: () => onDelete?.(column.id)
180
- }, /* @__PURE__ */ React.createElement("span", null, "Delete"), /* @__PURE__ */ React.createElement("div", {
185
+ }, /* @__PURE__ */ React.createElement("span", null, t("delete label")), /* @__PURE__ */ React.createElement("div", {
181
186
  className: "grow"
182
187
  }), /* @__PURE__ */ React.createElement(Trash, {
183
188
  className: getSize(5)
@@ -202,7 +207,7 @@ var [TableProvider, useUntypedTableContext] = createContext(TABLE_NAME);
202
207
  var useTableContext = (consumerName) => useUntypedTableContext(consumerName);
203
208
 
204
209
  // packages/ui/react-ui-table/src/theme.ts
205
- import { chromeSurface, fixedSurface, focusRing, groupBorder, hoverColors, mx as mx2 } from "@dxos/react-ui-theme";
210
+ import { chromeSurface, fixedSurface, focusRing, ghostSelected, ghostSelectedCurrent, groupBorder, mx as mx2 } from "@dxos/react-ui-theme";
206
211
  var currentRow = "!bg-neutral-75 !dark:bg-neutral-850";
207
212
  var selectedRow = "!bg-primary-100 dark:!bg-primary-700";
208
213
  var flushPadding = "pli-0 plb-0";
@@ -211,13 +216,13 @@ var headPadding = "pli-2 plb-1.5";
211
216
  var gridCellFocusRing = "focus:z-[11] focus:outline outline-2 outline-primary-500 dark:outline-primary-400";
212
217
  var tableRoot = ({ fullWidth }, ...etc) => mx2("table-fixed", fullWidth && "is-full", ...etc);
213
218
  var groupTh = (_props, ...etc) => mx2("text-start font-medium", flushPadding, ...etc);
214
- var theadRoot = ({ header }, ...etc) => mx2(header ? "sticky block-start-0 z-10" : "collapse", header && fixedSurface, ...etc);
219
+ var theadRoot = ({ header, stickyHeader }, ...etc) => mx2(header ? stickyHeader && "sticky block-start-[--sticky-top] z-[1]" : "collapse", header && fixedSurface, ...etc);
215
220
  var theadTr = (_props, ...etc) => mx2("group", ...etc);
216
221
  var theadTh = ({ border }, ...etc) => mx2("relative text-start font-medium select-none truncate", headPadding, border && "border", border && groupBorder, ...etc);
217
222
  var theadResizeRoot = (_props, ...etc) => mx2("absolute top-0 pis-1 h-full z-[10] w-[7px] -right-[5px] cursor-col-resize select-none touch-none opacity-20 hover:opacity-100", ...etc);
218
223
  var theadResizeThumb = (_props, ...etc) => mx2("flex group-hover:bg-neutral-700 -ml-[2px] w-[1px] h-full", ...etc);
219
224
  var tbodyRoot = (_props, ...etc) => mx2(...etc);
220
- var tbodyTr = ({ isSelected, isCurrent, canBeCurrent }, ...etc) => mx2("group", isSelected ? selectedRow : isCurrent && currentRow, canBeCurrent && focusRing, canBeCurrent && hoverColors, canBeCurrent && "cursor-pointer rounded", ...etc);
225
+ var tbodyTr = ({ canBeCurrent }, ...etc) => mx2("group", canBeCurrent ? ghostSelectedCurrent : ghostSelected, canBeCurrent && focusRing, canBeCurrent && "cursor-pointer rounded", ...etc);
221
226
  var tdRoot = ({ border, isGrid }, ...etc) => mx2("relative", flushPadding, border && "border", border && groupBorder, isGrid && gridCellFocusRing, ...etc);
222
227
  var tdContent = (_props, ...etc) => mx2(...etc);
223
228
  var tfootRoot = (_props, ...etc) => mx2("sticky block-end-0 z-10", chromeSurface, ...etc);
@@ -270,13 +275,14 @@ var TableBody = ({ rows }) => {
270
275
  return /* @__PURE__ */ React3.createElement("tr", {
271
276
  key: keyAccessor ? keyAccessor(row.original) : row.id,
272
277
  className: tbodyTr({
273
- isSelected,
274
- isCurrent,
275
278
  canBeCurrent
276
279
  }),
277
280
  ...isCurrent && {
278
281
  "aria-current": "location"
279
282
  },
283
+ ...isSelected && {
284
+ "aria-selected": "true"
285
+ },
280
286
  ...canBeCurrent && {
281
287
  tabIndex: 0,
282
288
  onClick: () => {
@@ -371,7 +377,7 @@ TableHead.displayName = TABLE_HEAD_NAME;
371
377
 
372
378
  // packages/ui/react-ui-table/src/components/Table/Table.tsx
373
379
  var Table = (props) => {
374
- const { role, data = [], columns = [], onColumnResize, columnVisibility, header = true, footer, rowsSelectable, fullWidth, debug, onDataSelectionChange } = props;
380
+ const { role, data = [], columns = [], onColumnResize, columnVisibility, header = true, footer, rowsSelectable, fullWidth, debug, onDataSelectionChange, classNames } = props;
375
381
  const TableProvider2 = TableProvider;
376
382
  const [rowSelection = {}, directlySetRowSelection] = useControllableState({
377
383
  prop: props.rowSelection,
@@ -461,7 +467,7 @@ var Table = (props) => {
461
467
  isGrid: role === "grid" || role === "treegrid"
462
468
  }, /* @__PURE__ */ React6.createElement("table", {
463
469
  role,
464
- className: tableRoot(props),
470
+ className: tableRoot(props, classNames),
465
471
  ...!fullWidth && {
466
472
  style: {
467
473
  width: table.getTotalSize()
@@ -487,23 +493,9 @@ var Table = (props) => {
487
493
  // packages/ui/react-ui-table/src/components/Cell/CellCombobox.tsx
488
494
  import { CaretDown as CaretDown2 } from "@phosphor-icons/react";
489
495
  import React7, { useCallback as useCallback2, useState as useState3 } from "react";
490
- import { Popover as Popover2, useTranslation } from "@dxos/react-ui";
496
+ import { Popover as Popover2, useTranslation as useTranslation2 } from "@dxos/react-ui";
491
497
  import { PopoverCombobox } from "@dxos/react-ui-searchlist";
492
498
  import { descriptionText, getSize as getSize2, mx as mx4, staticPlaceholderText } from "@dxos/react-ui-theme";
493
-
494
- // packages/ui/react-ui-table/src/translations.ts
495
- var translationKey = "table";
496
- var translations_default = [
497
- {
498
- "en-US": {
499
- [translationKey]: {
500
- "no selection label": "\xA0"
501
- }
502
- }
503
- }
504
- ];
505
-
506
- // packages/ui/react-ui-table/src/components/Cell/CellCombobox.tsx
507
499
  var initialItems = (model, value) => value ? {
508
500
  [model.getId(value)]: {
509
501
  label: model.getText(value),
@@ -511,7 +503,7 @@ var initialItems = (model, value) => value ? {
511
503
  }
512
504
  } : {};
513
505
  var CellCombobox = ({ model, value, onValueChange }) => {
514
- const { t } = useTranslation(translationKey);
506
+ const { t } = useTranslation2(translationKey);
515
507
  const [items, setItems] = useState3(initialItems(model, value));
516
508
  const [loading, setLoading] = useState3(false);
517
509
  const [searchInputValue, setSearchInputValue] = useState3("");
@@ -568,29 +560,25 @@ var CellCombobox = ({ model, value, onValueChange }) => {
568
560
  };
569
561
 
570
562
  // packages/ui/react-ui-table/src/helpers.tsx
563
+ import { useFocusFinders } from "@fluentui/react-tabster";
571
564
  import { Check as Check2, ClipboardText, X as X2 } from "@phosphor-icons/react";
572
565
  import { createColumnHelper } from "@tanstack/react-table";
573
566
  import format from "date-fns/format";
574
567
  import formatDistanceToNow from "date-fns/formatDistanceToNow";
575
- import defaultsDeep from "lodash.defaultsdeep";
576
- import React8, { useRef as useRef2, useState as useState4 } from "react";
568
+ import React8, { useEffect as useEffect2, useRef as useRef2, useState as useState4 } from "react";
577
569
  import { Input as Input2, Tooltip } from "@dxos/react-ui";
578
570
  import { getSize as getSize3, mx as mx5 } from "@dxos/react-ui-theme";
579
- import { stripUndefinedValues } from "@dxos/util";
580
571
  var createColumnBuilder = () => ({
581
572
  helper: createColumnHelper(),
582
573
  builder: new ColumnBuilder()
583
574
  });
584
- var defaults = (options, ...sources) => {
585
- return stripUndefinedValues(defaultsDeep({}, options, ...sources));
586
- };
587
575
  var ComboboxBuilderCell = (cellContext) => {
588
576
  const { model, onUpdate } = cellContext.column.columnDef.meta;
589
- return /* @__PURE__ */ React8.createElement(CellCombobox, {
577
+ return model ? /* @__PURE__ */ React8.createElement(CellCombobox, {
590
578
  model,
591
579
  value: cellContext.getValue(),
592
580
  onValueChange: (value) => onUpdate?.(cellContext.row.original, cellContext.column.id, value)
593
- });
581
+ }) : null;
594
582
  };
595
583
  var StringBuilderCell = (cellContext) => {
596
584
  const { onUpdate } = cellContext.column.columnDef.meta;
@@ -623,40 +611,55 @@ var StringBuilderCell = (cellContext) => {
623
611
  onKeyDown: (event) => event.key === "Enter" && handleSave() || event.key === "Escape" && handleCancel()
624
612
  }));
625
613
  };
614
+ var parseNumber = (text) => text?.trim().length ? Number(text) : NaN;
615
+ var displayNumber = (value, digits) => value || value === 0 ? value.toLocaleString(void 0, {
616
+ minimumFractionDigits: digits ?? 0,
617
+ maximumFractionDigits: digits ?? 2
618
+ }) : "";
626
619
  var NumberBuilderCell = (cellContext) => {
627
- const { onUpdate, cell, digits } = cellContext.column.columnDef.meta;
620
+ const { onUpdate, digits } = cellContext.column.columnDef.meta;
628
621
  const value = cellContext.getValue();
629
- const [text, setText] = useState4();
622
+ const [text, setText] = useState4(displayNumber(value, digits));
623
+ const { findPrevFocusable } = useFocusFinders();
624
+ const ref = useRef2(null);
625
+ useEffect2(() => {
626
+ (!document.activeElement || document.activeElement !== ref.current) && setText(displayNumber(value, digits));
627
+ }, [
628
+ digits,
629
+ value
630
+ ]);
630
631
  const handleEdit = () => {
631
632
  if (onUpdate) {
632
633
  setText(value !== void 0 ? String(value) : "");
633
634
  }
634
635
  };
635
636
  const handleSave = () => {
636
- const value2 = text?.trim().length ? Number(text) : NaN;
637
- onUpdate?.(cellContext.row.original, cellContext.column.id, isNaN(value2) ? void 0 : value2);
638
- setText(void 0);
637
+ const nextValue = parseNumber(text);
638
+ onUpdate?.(cellContext.row.original, cellContext.column.id, isNaN(nextValue) ? void 0 : nextValue);
639
+ setText(displayNumber(nextValue, digits));
640
+ ref.current && document.activeElement === ref.current && findPrevFocusable(ref.current)?.focus();
639
641
  };
640
- const handleCancel = () => {
641
- setText(void 0);
642
+ const _handleCancel = () => {
643
+ setText(displayNumber(value, digits));
644
+ ref.current && findPrevFocusable(ref.current)?.focus();
642
645
  };
643
- if (text !== void 0) {
644
- return /* @__PURE__ */ React8.createElement(Input2.Root, null, /* @__PURE__ */ React8.createElement(Input2.TextInput, {
645
- value: text,
646
- classNames: [
647
- "is-full text-end font-mono"
648
- ],
649
- onBlur: handleSave,
650
- onChange: (event) => setText(event.target.value),
651
- onKeyDown: (event) => event.key === "Escape" && handleCancel() || event.key === "Enter" && handleSave()
652
- }));
653
- }
654
- return /* @__PURE__ */ React8.createElement("div", {
655
- className: mx5('is-full text-end font-mono empty:after:content-["\xA0"]', textPadding, cell?.classNames),
656
- onClick: handleEdit
657
- }, value?.toLocaleString(void 0, {
658
- minimumFractionDigits: digits ?? 0,
659
- maximumFractionDigits: digits ?? 2
646
+ return /* @__PURE__ */ React8.createElement(Input2.Root, null, /* @__PURE__ */ React8.createElement(Input2.TextInput, {
647
+ ref,
648
+ variant: "subdued",
649
+ value: text,
650
+ classNames: [
651
+ "is-full text-end font-mono",
652
+ textPadding
653
+ ],
654
+ onBlur: handleSave,
655
+ onFocus: handleEdit,
656
+ onChange: ({ target: { value: value2 } }) => setText(value2),
657
+ onKeyDown: (event) => {
658
+ return (
659
+ /* (event.key === 'Escape' && handleCancel()) || */
660
+ event.key === "Enter" && handleSave()
661
+ );
662
+ }
660
663
  }));
661
664
  };
662
665
  var RowSelectorBuilderCell = (cellContext) => {
@@ -696,15 +699,8 @@ var ColumnBuilder = class {
696
699
  * Combobox value
697
700
  */
698
701
  combobox({ label, classNames, model, onUpdate, ...props }) {
699
- return defaults(props, {
702
+ return {
700
703
  minSize: 100,
701
- meta: {
702
- model,
703
- onUpdate,
704
- cell: {
705
- classNames
706
- }
707
- },
708
704
  header: (column) => {
709
705
  return label ?? column.header.id;
710
706
  },
@@ -713,21 +709,25 @@ var ColumnBuilder = class {
713
709
  return /* @__PURE__ */ React8.createElement("div", {
714
710
  className: mx5("truncate", classNames)
715
711
  }, cellValue ? model?.getText(cellValue) : "");
712
+ },
713
+ ...props,
714
+ meta: {
715
+ ...props.meta,
716
+ model,
717
+ onUpdate,
718
+ cell: {
719
+ classNames,
720
+ ...props.meta?.cell
721
+ }
716
722
  }
717
- });
723
+ };
718
724
  }
719
725
  /**
720
726
  * String formats.
721
727
  */
722
728
  string({ label, classNames, onUpdate, ...props } = {}) {
723
- return defaults(props, {
729
+ return {
724
730
  minSize: 100,
725
- meta: {
726
- onUpdate,
727
- cell: {
728
- classNames
729
- }
730
- },
731
731
  // TODO(burdon): Default.
732
732
  header: (column) => {
733
733
  return label ?? column.header.id;
@@ -737,43 +737,51 @@ var ColumnBuilder = class {
737
737
  return /* @__PURE__ */ React8.createElement("div", {
738
738
  className: mx5("truncate", textPadding, classNames)
739
739
  }, value);
740
+ },
741
+ ...props,
742
+ meta: {
743
+ ...props.meta,
744
+ onUpdate,
745
+ cell: {
746
+ ...props.meta?.cell,
747
+ classNames
748
+ }
740
749
  }
741
- });
750
+ };
742
751
  }
743
752
  /**
744
753
  * Number formats.
745
754
  */
746
755
  number({ label, minSize, classNames, digits, onUpdate, ...props } = {}) {
747
- return defaults(props, {
756
+ return {
748
757
  size: 100,
749
758
  minSize: 100,
759
+ header: (cell) => label ?? cell.header.id,
760
+ cell: NumberBuilderCell,
761
+ ...props,
750
762
  meta: {
763
+ ...props.meta,
751
764
  onUpdate,
752
765
  digits,
753
766
  header: {
754
- classNames: "text-end"
767
+ classNames: "text-end",
768
+ ...props.meta?.header
755
769
  },
756
770
  cell: {
771
+ ...props.meta?.cell,
757
772
  classNames
758
773
  }
759
- },
760
- header: (cell) => label ?? cell.header.id,
761
- cell: NumberBuilderCell
762
- });
774
+ }
775
+ };
763
776
  }
764
777
  /**
765
778
  * Date formats.
766
779
  */
767
780
  // TODO(burdon): Date picker (pluggable renderers?)
768
781
  date({ label, format: formatSpec, relative, classNames, ...props } = {}) {
769
- return defaults(props, {
782
+ return {
770
783
  size: 220,
771
784
  minSize: 100,
772
- meta: {
773
- cell: {
774
- classNames
775
- }
776
- },
777
785
  header: (cell) => label ?? cell.header.id,
778
786
  cell: (cell) => {
779
787
  const value = cell.getValue();
@@ -788,24 +796,24 @@ var ColumnBuilder = class {
788
796
  console.log(value);
789
797
  return null;
790
798
  }
799
+ },
800
+ ...props,
801
+ meta: {
802
+ ...props.meta,
803
+ cell: {
804
+ ...props.meta?.cell,
805
+ classNames
806
+ }
791
807
  }
792
- });
808
+ };
793
809
  }
794
810
  /**
795
811
  * PublicKey with tooltip.
796
812
  */
797
- key({ label, tooltip, ...props } = {}) {
798
- return defaults(props, {
813
+ key({ label, tooltip, classNames, ...props } = {}) {
814
+ return {
799
815
  size: 94,
800
816
  minSize: 94,
801
- meta: {
802
- cell: {
803
- classNames: [
804
- "font-mono",
805
- textPadding
806
- ]
807
- }
808
- },
809
817
  header: (cell) => label ?? cell.header.id,
810
818
  cell: (cell) => {
811
819
  const value = cell.getValue();
@@ -816,21 +824,33 @@ var ColumnBuilder = class {
816
824
  if (!tooltip) {
817
825
  return element;
818
826
  }
819
- return /* @__PURE__ */ React8.createElement(Tooltip.Provider, null, /* @__PURE__ */ React8.createElement(Tooltip.Root, null, /* @__PURE__ */ React8.createElement(Tooltip.Trigger, null, element), /* @__PURE__ */ React8.createElement(Tooltip.Content, {
827
+ return /* @__PURE__ */ React8.createElement(Tooltip.Provider, null, /* @__PURE__ */ React8.createElement(Tooltip.Root, null, /* @__PURE__ */ React8.createElement(Tooltip.Trigger, null, element), /* @__PURE__ */ React8.createElement(Tooltip.Portal, null, /* @__PURE__ */ React8.createElement(Tooltip.Content, {
820
828
  side: "right"
821
829
  }, /* @__PURE__ */ React8.createElement(Tooltip.Arrow, null), /* @__PURE__ */ React8.createElement(ClipboardText, {
822
830
  onClick: (ev) => {
823
831
  ev.stopPropagation();
824
832
  void navigator.clipboard.writeText(value.toHex());
825
833
  }
826
- }))));
834
+ })))));
835
+ },
836
+ ...props,
837
+ meta: {
838
+ ...props.meta,
839
+ cell: {
840
+ ...props.meta?.cell,
841
+ classNames: [
842
+ "font-mono",
843
+ textPadding,
844
+ classNames
845
+ ]
846
+ }
827
847
  }
828
- });
848
+ };
829
849
  }
830
850
  /**
831
851
  * Row selector
832
852
  */
833
- selectRow({ label, classNames, onUpdate, id = "selectRow", ...props } = {}) {
853
+ selectRow({ classNames, onUpdate, id = "selectRow" } = {}) {
834
854
  return {
835
855
  id,
836
856
  size: 32,
@@ -862,21 +882,24 @@ var ColumnBuilder = class {
862
882
  * Switch
863
883
  */
864
884
  switch({ label, classNames, onUpdate, ...props } = {}) {
865
- return defaults(props, {
885
+ return {
866
886
  size: 50,
867
887
  minSize: 50,
888
+ header: (column) => label ?? column.header.id,
889
+ cell: SwitchBuilderCell,
890
+ ...props,
868
891
  meta: {
892
+ ...props.meta,
869
893
  onUpdate,
870
894
  cell: {
895
+ ...props.meta?.cell,
871
896
  classNames: [
872
897
  textPadding,
873
898
  classNames
874
899
  ]
875
900
  }
876
- },
877
- header: (column) => label ?? column.header.id,
878
- cell: SwitchBuilderCell
879
- });
901
+ }
902
+ };
880
903
  }
881
904
  /**
882
905
  * Icon based on boolean value.
@@ -884,7 +907,7 @@ var ColumnBuilder = class {
884
907
  icon({ label, size, on, off, ...props } = {}) {
885
908
  const IconOn = on?.Icon ?? Check2;
886
909
  const IconOff = off?.Icon ?? X2;
887
- return defaults(props, {
910
+ return {
888
911
  size: size ?? 32,
889
912
  header: (column) => /* @__PURE__ */ React8.createElement("div", {
890
913
  className: "justify-center"
@@ -902,8 +925,9 @@ var ColumnBuilder = class {
902
925
  } else {
903
926
  return null;
904
927
  }
905
- }
906
- });
928
+ },
929
+ ...props
930
+ };
907
931
  }
908
932
  };
909
933
  export {
@@ -912,7 +936,6 @@ export {
912
936
  ColumnMenu,
913
937
  ColumnPanel,
914
938
  Table,
915
- columnTypes,
916
939
  createColumnBuilder,
917
940
  currentRow,
918
941
  flushPadding,
@@ -933,6 +956,7 @@ export {
933
956
  theadResizeThumb,
934
957
  theadRoot,
935
958
  theadTh,
936
- theadTr
959
+ theadTr,
960
+ translations_default as translations
937
961
  };
938
962
  //# sourceMappingURL=index.mjs.map