docblocks-react-ui 0.4.7 → 0.5.0

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.
@@ -15,9 +15,9 @@ import * as PopoverPrimitive from "@radix-ui/react-popover";
15
15
  import * as SeparatorPrimitive from "@radix-ui/react-separator";
16
16
  import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
17
17
  import * as SelectPrimitive from "@radix-ui/react-select";
18
+ import { AnimatePresence, Reorder, useDragControls } from "framer-motion";
18
19
  import { createStore } from "zustand/vanilla";
19
20
  import hljs from "highlight.js/lib/core";
20
- import { AnimatePresence, Reorder, useDragControls } from "framer-motion";
21
21
  //#region src/blob-store.ts
22
22
  /** Derive the subtype from the file's mime (the consumer's `meta.subtype` wins). */
23
23
  function blobSubtypeOf(file) {
@@ -1836,7 +1836,7 @@ function Badge({ className, variant, asChild = false, ...props }) {
1836
1836
  function BareSelect({ className, children, ...props }) {
1837
1837
  return /* @__PURE__ */ jsx("select", {
1838
1838
  "data-slot": "select-bare",
1839
- className: cn("h-8 rounded-md border border-border bg-transparent px-2 text-sm text-foreground outline-none", className),
1839
+ className: cn("h-8 rounded-md border border-input bg-transparent px-2 text-sm text-foreground outline-none dark:bg-input/30", className),
1840
1840
  ...props,
1841
1841
  children
1842
1842
  });
@@ -4383,8 +4383,13 @@ const INIT_OPTIONS = {
4383
4383
  "undo": "Undo",
4384
4384
  "redo": "Redo",
4385
4385
  "filter": "Filter",
4386
+ "columns": "Columns",
4386
4387
  "apply": "Apply"
4387
4388
  },
4389
+ columns: {
4390
+ "move": "Move {name}",
4391
+ "visibility": "Show {name}"
4392
+ },
4388
4393
  columnTypes: {
4389
4394
  "text": "Text",
4390
4395
  "integer": "Integer",
@@ -4437,12 +4442,15 @@ const INIT_OPTIONS = {
4437
4442
  filter: {
4438
4443
  "empty": "No columns to filter on.",
4439
4444
  "logic": "Filter logic",
4445
+ "and": "AND",
4446
+ "or": "OR",
4440
4447
  "matchAll": "match all of the conditions",
4441
4448
  "matchAny": "match any of the conditions",
4442
- "nestedGroup": "{logic} nested group",
4443
4449
  "removeGroup": "Remove group",
4444
4450
  "condition": "+ Condition",
4445
4451
  "group": "+ Group",
4452
+ "groupHeader": "Group {index}",
4453
+ "removeCondition": "Remove condition",
4446
4454
  "valuePlaceholder": "value, value"
4447
4455
  },
4448
4456
  picker: {
@@ -4822,8 +4830,13 @@ const INIT_OPTIONS = {
4822
4830
  "undo": "Отменить",
4823
4831
  "redo": "Повторить",
4824
4832
  "filter": "Фильтр",
4833
+ "columns": "Колонки",
4825
4834
  "apply": "Применить"
4826
4835
  },
4836
+ columns: {
4837
+ "move": "Переместить {name}",
4838
+ "visibility": "Показать {name}"
4839
+ },
4827
4840
  columnTypes: {
4828
4841
  "text": "Текст",
4829
4842
  "integer": "Целое",
@@ -4876,12 +4889,15 @@ const INIT_OPTIONS = {
4876
4889
  filter: {
4877
4890
  "empty": "Нет столбцов для фильтрации.",
4878
4891
  "logic": "Логика фильтра",
4892
+ "and": "И",
4893
+ "or": "ИЛИ",
4879
4894
  "matchAll": "выполнены все условия",
4880
4895
  "matchAny": "выполнено любое из условий",
4881
- "nestedGroup": "Вложенная группа ({logic})",
4882
4896
  "removeGroup": "Удалить группу",
4883
4897
  "condition": "+ Условие",
4884
4898
  "group": "+ Группа",
4899
+ "groupHeader": "Группа {index}",
4900
+ "removeCondition": "Удалить условие",
4885
4901
  "valuePlaceholder": "значение, значение"
4886
4902
  },
4887
4903
  picker: {
@@ -6018,9 +6034,11 @@ function SelectScrollDownButton({ className, ...props }) {
6018
6034
  * the value and the `onChange` behavior (the no-op-on-current guard is the
6019
6035
  * caller's). The pill's travel runs a back-out easing (a slight overshoot
6020
6036
  * that settles into the measured stand — the end position stands exact,
6021
- * the overshoot is the animation only).
6037
+ * the overshoot is the animation only). The pill's fill runs a theme
6038
+ * variant: `accent` (the default's soft highlight) or `primary` (the
6039
+ * prominent fill — the active label stands the `primary-foreground`).
6022
6040
  */
6023
- function SegmentSelector({ options, value, onChange, ariaLabel, slot, pillSlot, buttonAttrName, size = "icon" }) {
6041
+ function SegmentSelector({ options, value, onChange, ariaLabel, slot, pillSlot, buttonAttrName, size = "icon", pillTheme = "accent" }) {
6024
6042
  const listRef = useRef(null);
6025
6043
  /** The sliding pill's geometry (the active button's position and size in the list). */
6026
6044
  const [pill, setPill] = useState(null);
@@ -6047,6 +6065,10 @@ function SegmentSelector({ options, value, onChange, ariaLabel, slot, pillSlot,
6047
6065
  return () => observer.disconnect();
6048
6066
  }, [value, buttonAttrName]);
6049
6067
  const selectOption = (value) => () => onChange(value);
6068
+ /** The active button's label stand (over the pill's fill): the `primary`
6069
+ * pill's stand reads the `primary-foreground`, the `accent` pill's stand
6070
+ * reads the `foreground`. */
6071
+ const activeLabelClass = pillTheme === "primary" ? "text-primary-foreground" : "text-foreground";
6050
6072
  return /* @__PURE__ */ jsxs("div", {
6051
6073
  ref: listRef,
6052
6074
  role: "group",
@@ -6056,7 +6078,10 @@ function SegmentSelector({ options, value, onChange, ariaLabel, slot, pillSlot,
6056
6078
  children: [pill !== null && /* @__PURE__ */ jsx("span", {
6057
6079
  "data-slot": pillSlot,
6058
6080
  "aria-hidden": true,
6059
- className: "\n absolute top-0 left-0 rounded-md bg-accent shadow-sm transition-[transform,width,height] duration-200\n ease-[cubic-bezier(0.34,1.56,0.64,1)]\n dark:bg-ring\n ",
6081
+ className: cn(`
6082
+ absolute top-0 left-0 rounded-md shadow-sm transition-[transform,width,height] duration-200
6083
+ ease-[cubic-bezier(0.34,1.56,0.64,1)]
6084
+ `, pillTheme === "primary" ? "bg-primary" : "bg-accent dark:bg-ring"),
6060
6085
  style: {
6061
6086
  transform: `translate(${pill.left}px, ${pill.top}px)`,
6062
6087
  width: pill.width,
@@ -6075,7 +6100,7 @@ function SegmentSelector({ options, value, onChange, ariaLabel, slot, pillSlot,
6075
6100
  hover:bg-transparent
6076
6101
  focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1
6077
6102
  focus-visible:outline-ring
6078
- `, size === "icon" ? "size-6" : "h-6 px-2 text-xs", value === option.value ? "text-foreground" : "hover:text-foreground", option.disabled && "cursor-not-allowed text-muted-foreground/50 hover:text-muted-foreground/50"),
6103
+ `, size === "icon" ? "size-6" : "h-6 px-2 text-xs", value === option.value ? activeLabelClass : "hover:text-foreground", option.disabled && "cursor-not-allowed text-muted-foreground/50 hover:text-muted-foreground/50"),
6079
6104
  onClick: selectOption(option.value),
6080
6105
  children: size === "text" ? option.label : option.icon
6081
6106
  }, option.value))]
@@ -6276,21 +6301,21 @@ function filterIsComplete(payload, columns) {
6276
6301
  //#region src/database/filter-builder/FilterBuilder.tsx
6277
6302
  /**
6278
6303
  * The recursive and/or filter editor: the top-level FilterBuilder renders a
6279
- * FilterGroup (the group card), which renders the condition rows
6280
- * (FilterConditionRow) + the nested groups; each condition's value is a
6281
- * ValueInput over the column's annotation.
6282
- */
6283
- /** The recursive and/or filter editor (the group card). */
6284
- const FILTER_LOGIC_OPTIONS = [{
6285
- value: "and",
6286
- label: "AND"
6287
- }, {
6288
- value: "or",
6289
- label: "OR"
6290
- }];
6304
+ * FilterGroup (the logic selector + the gutter body), which renders the
6305
+ * condition rows (FilterConditionRow) + the nested groups (FilterGroupCard);
6306
+ * each condition's value is a ValueInput over the column's annotation.
6307
+ * Every body item draws its share of the group's vertical connector line
6308
+ * (the thin left line that binds the conditions and the groups into one
6309
+ * tree — the last item stops the line at its tick).
6310
+ */
6311
+ const FILTER_LOGIC_VALUES = ["and", "or"];
6291
6312
  function FilterBuilder({ value, columns, onChange, refTableData }) {
6292
6313
  const { t } = useTranslation("database");
6293
6314
  const payload = value ?? emptyFilter();
6315
+ const logicOptions = FILTER_LOGIC_VALUES.map((entry) => ({
6316
+ value: entry,
6317
+ label: t(`filter.${entry}`)
6318
+ }));
6294
6319
  return /* @__PURE__ */ jsx("div", {
6295
6320
  "data-slot": "docblocks/filter-builder",
6296
6321
  className: "flex max-h-80 flex-col gap-2 overflow-y-auto",
@@ -6302,13 +6327,15 @@ function FilterBuilder({ value, columns, onChange, refTableData }) {
6302
6327
  payload,
6303
6328
  columns,
6304
6329
  depth: 0,
6330
+ logicOptions,
6305
6331
  onChange,
6306
6332
  refTableData
6307
6333
  })
6308
6334
  });
6309
6335
  }
6310
- function FilterGroup({ payload, columns, depth, onChange, refTableData }) {
6336
+ function FilterGroup({ payload, columns, depth, logicOptions, onChange, refTableData }) {
6311
6337
  const { t } = useTranslation("database");
6338
+ const groups = payload.groups ?? [];
6312
6339
  const setLogic = (logic) => onChange({
6313
6340
  ...payload,
6314
6341
  logic
@@ -6323,15 +6350,15 @@ function FilterGroup({ payload, columns, depth, onChange, refTableData }) {
6323
6350
  });
6324
6351
  const setGroup = (index, group) => onChange({
6325
6352
  ...payload,
6326
- groups: (payload.groups ?? []).map((entry, at) => at === index ? group : entry)
6353
+ groups: groups.map((entry, at) => at === index ? group : entry)
6327
6354
  });
6328
6355
  const removeGroup = (index) => onChange({
6329
6356
  ...payload,
6330
- groups: (payload.groups ?? []).filter((_, at) => at !== index)
6357
+ groups: groups.filter((_, at) => at !== index)
6331
6358
  });
6332
6359
  const addGroup = () => onChange({
6333
6360
  ...payload,
6334
- groups: [...payload.groups ?? [], emptyFilter()]
6361
+ groups: [...groups, emptyFilter()]
6335
6362
  });
6336
6363
  const addCondition = () => {
6337
6364
  const column = columns[0];
@@ -6352,60 +6379,53 @@ function FilterGroup({ payload, columns, depth, onChange, refTableData }) {
6352
6379
  const conditionRemove = (index) => () => removeCondition(index);
6353
6380
  const removeGroupAt = (index) => () => removeGroup(index);
6354
6381
  const groupChange = (index) => (next) => setGroup(index, next);
6382
+ const isLastCondition = (index) => index === payload.conditions.length - 1 && groups.length === 0;
6383
+ const isLastGroup = (index) => index === groups.length - 1;
6355
6384
  return /* @__PURE__ */ jsxs("div", {
6356
6385
  "data-slot": "docblocks/filter-group",
6357
6386
  "data-logic": payload.logic,
6358
- className: "flex flex-col gap-2 rounded-md border border-border p-2",
6387
+ className: "flex flex-col gap-2",
6359
6388
  children: [
6360
6389
  /* @__PURE__ */ jsxs("div", {
6361
6390
  className: "flex items-center gap-2",
6362
6391
  children: [/* @__PURE__ */ jsx(SegmentSelector, {
6363
- options: FILTER_LOGIC_OPTIONS,
6392
+ options: logicOptions,
6364
6393
  value: payload.logic,
6365
6394
  onChange: onLogicChange,
6366
6395
  ariaLabel: t("filter.logic"),
6367
6396
  slot: "docblocks/filter-logic",
6368
6397
  pillSlot: "docblocks/filter-logic-pill",
6369
6398
  buttonAttrName: "filter-logic",
6370
- size: "text"
6399
+ size: "text",
6400
+ pillTheme: "primary"
6371
6401
  }), /* @__PURE__ */ jsx("span", {
6372
6402
  className: "text-xs text-muted-foreground",
6373
6403
  children: payload.logic === "and" ? t("filter.matchAll") : t("filter.matchAny")
6374
6404
  })]
6375
6405
  }),
6376
- payload.conditions.map((condition, index) => /* @__PURE__ */ jsx(FilterConditionRow, {
6377
- condition,
6378
- columns,
6379
- onChange: conditionChange(index),
6380
- onRemove: conditionRemove(index),
6381
- refTableData
6382
- }, index)),
6383
- (payload.groups ?? []).map((group, index) => /* @__PURE__ */ jsxs("div", {
6384
- className: "flex flex-col gap-1",
6385
- "data-slot": "docblocks/filter-nested",
6386
- children: [/* @__PURE__ */ jsxs("div", {
6387
- className: "flex items-center gap-1 text-xs text-muted-foreground",
6388
- children: [/* @__PURE__ */ jsx("span", {
6389
- "data-slot": "docblocks/filter-connector",
6390
- children: t("filter.nestedGroup", { logic: payload.logic === "and" ? "AND" : "OR" })
6391
- }), /* @__PURE__ */ jsx(Button, {
6392
- type: "button",
6393
- variant: "outline",
6394
- size: "sm",
6395
- "data-slot": "docblocks/filter-remove-group",
6396
- onClick: removeGroupAt(index),
6397
- children: t("filter.removeGroup")
6398
- })]
6399
- }), /* @__PURE__ */ jsx(FilterGroup, {
6406
+ /* @__PURE__ */ jsxs("div", {
6407
+ className: "flex flex-col gap-2 pl-5",
6408
+ children: [payload.conditions.map((condition, index) => /* @__PURE__ */ jsx(FilterConditionRow, {
6409
+ condition,
6410
+ columns,
6411
+ onChange: conditionChange(index),
6412
+ onRemove: conditionRemove(index),
6413
+ refTableData,
6414
+ isLast: isLastCondition(index)
6415
+ }, index)), groups.map((group, index) => /* @__PURE__ */ jsx(FilterGroupCard, {
6416
+ index,
6400
6417
  payload: group,
6401
6418
  columns,
6402
6419
  depth: depth + 1,
6420
+ logicOptions,
6403
6421
  onChange: groupChange(index),
6404
- refTableData
6405
- })]
6406
- }, index)),
6422
+ onRemove: removeGroupAt(index),
6423
+ refTableData,
6424
+ isLast: isLastGroup(index)
6425
+ }, index))]
6426
+ }),
6407
6427
  /* @__PURE__ */ jsxs("div", {
6408
- className: "flex gap-2",
6428
+ className: "flex gap-2 pl-5",
6409
6429
  children: [/* @__PURE__ */ jsx(Button, {
6410
6430
  type: "button",
6411
6431
  variant: "outline",
@@ -6425,7 +6445,8 @@ function FilterGroup({ payload, columns, depth, onChange, refTableData }) {
6425
6445
  ]
6426
6446
  });
6427
6447
  }
6428
- function FilterConditionRow({ condition, columns, onChange, onRemove, refTableData }) {
6448
+ function FilterConditionRow({ condition, columns, onChange, onRemove, refTableData, isLast }) {
6449
+ const { t } = useTranslation("database");
6429
6450
  const column = columns.find((entry) => entry.id === condition.columnId) ?? columns[0];
6430
6451
  if (column === void 0) return null;
6431
6452
  const annotation = columnAnnotation(column);
@@ -6455,10 +6476,19 @@ function FilterConditionRow({ condition, columns, onChange, onRemove, refTableDa
6455
6476
  "data-slot": "docblocks/filter-condition",
6456
6477
  "data-column-id": condition.columnId,
6457
6478
  "data-op": operator,
6458
- className: "flex flex-wrap items-center gap-2",
6479
+ className: "relative flex items-center gap-2",
6459
6480
  children: [
6481
+ /* @__PURE__ */ jsx("span", {
6482
+ "aria-hidden": true,
6483
+ className: "absolute bottom-4 -left-5 h-px w-5 bg-border"
6484
+ }),
6485
+ /* @__PURE__ */ jsx("span", {
6486
+ "aria-hidden": true,
6487
+ className: cn("absolute top-0 -left-5 w-px bg-border", isLast ? "bottom-4" : "-bottom-2")
6488
+ }),
6460
6489
  /* @__PURE__ */ jsx(BareSelect, {
6461
6490
  "data-slot": "docblocks/filter-column",
6491
+ className: "max-w-60 min-w-35",
6462
6492
  value: column.id,
6463
6493
  onChange: onColumnChange,
6464
6494
  children: columns.map((entry) => /* @__PURE__ */ jsx("option", {
@@ -6484,16 +6514,69 @@ function FilterConditionRow({ condition, columns, onChange, onRemove, refTableDa
6484
6514
  }),
6485
6515
  /* @__PURE__ */ jsx(Button, {
6486
6516
  type: "button",
6487
- variant: "outline",
6488
- size: "sm",
6517
+ variant: "ghost",
6518
+ size: "icon",
6489
6519
  "data-slot": "docblocks/filter-remove-condition",
6520
+ "aria-label": t("filter.removeCondition"),
6521
+ className: "size-8 shrink-0",
6490
6522
  onClick: onRemove,
6491
- children: "×"
6523
+ children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
6524
+ })
6525
+ ]
6526
+ });
6527
+ }
6528
+ /** The nested filter group: the bordered card with the ordinal header and
6529
+ * the remove, and the recursive `FilterGroup` inside. Draws its share of
6530
+ * the parent group's connector line (the border-less wrapper is the line's
6531
+ * positioning context). */
6532
+ function FilterGroupCard({ index, payload, columns, depth, logicOptions, onChange, onRemove, refTableData, isLast }) {
6533
+ const { t } = useTranslation("database");
6534
+ return /* @__PURE__ */ jsxs("div", {
6535
+ "data-slot": "docblocks/filter-nested",
6536
+ className: "relative",
6537
+ children: [
6538
+ /* @__PURE__ */ jsx("span", {
6539
+ "aria-hidden": true,
6540
+ className: "absolute top-6 -left-5 h-px w-5 bg-border"
6541
+ }),
6542
+ /* @__PURE__ */ jsx("span", {
6543
+ "aria-hidden": true,
6544
+ className: cn("absolute top-0 -left-5 w-px bg-border", isLast ? "h-6" : "-bottom-2")
6545
+ }),
6546
+ /* @__PURE__ */ jsxs("div", {
6547
+ className: "flex flex-col gap-2 rounded-md border border-border p-2",
6548
+ children: [/* @__PURE__ */ jsxs("div", {
6549
+ className: "flex items-center justify-between gap-2",
6550
+ children: [/* @__PURE__ */ jsx("span", {
6551
+ "data-slot": "docblocks/filter-group-header",
6552
+ className: "text-xs font-medium text-muted-foreground",
6553
+ children: t("filter.groupHeader", { index: index + 1 })
6554
+ }), /* @__PURE__ */ jsx(Button, {
6555
+ type: "button",
6556
+ variant: "ghost",
6557
+ size: "icon",
6558
+ "data-slot": "docblocks/filter-remove-group",
6559
+ "aria-label": t("filter.removeGroup"),
6560
+ className: "size-8 shrink-0",
6561
+ onClick: onRemove,
6562
+ children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
6563
+ })]
6564
+ }), /* @__PURE__ */ jsx(FilterGroup, {
6565
+ payload,
6566
+ columns,
6567
+ depth,
6568
+ logicOptions,
6569
+ onChange,
6570
+ refTableData
6571
+ })]
6492
6572
  })
6493
6573
  ]
6494
6574
  });
6495
6575
  }
6496
- /** The value input per the annotation (the `in` / `not in` multi-value is a comma list). */
6576
+ /** The value input per the annotation (the `in` / `not in` multi-value is a
6577
+ * comma list). The input stands the row's leftover (the field / the
6578
+ * operator take their content width, the value fills the rest — the
6579
+ * single line's stand). */
6497
6580
  function ValueInput({ column, operator, value, onChange, refTableData }) {
6498
6581
  const { t } = useTranslation("database");
6499
6582
  const multiValue = operator === "in" || operator === "not in";
@@ -6511,7 +6594,7 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
6511
6594
  type: "text",
6512
6595
  size: "sm",
6513
6596
  "data-slot": "docblocks/filter-value",
6514
- className: "w-auto",
6597
+ className: "min-w-0 flex-1 border-input",
6515
6598
  placeholder: t("filter.valuePlaceholder"),
6516
6599
  value: text,
6517
6600
  onChange: onMultiChange
@@ -6522,12 +6605,13 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
6522
6605
  type: "number",
6523
6606
  size: "sm",
6524
6607
  "data-slot": "docblocks/filter-value",
6525
- className: "w-auto",
6608
+ className: "min-w-0 flex-1 border-input",
6526
6609
  value: value === void 0 || value === null ? "" : String(value),
6527
6610
  onChange: onNumberChange
6528
6611
  });
6529
6612
  case "boolean": return /* @__PURE__ */ jsxs(BareSelect, {
6530
6613
  "data-slot": "docblocks/filter-value",
6614
+ className: "min-w-0 flex-1",
6531
6615
  value: value === void 0 || value === null ? "" : String(value),
6532
6616
  onChange: onBooleanChange,
6533
6617
  children: [
@@ -6549,7 +6633,7 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
6549
6633
  type: "date",
6550
6634
  size: "sm",
6551
6635
  "data-slot": "docblocks/filter-value",
6552
- className: "w-auto",
6636
+ className: "min-w-0 flex-1 border-input",
6553
6637
  value: value === void 0 || value === null ? "" : String(value),
6554
6638
  onChange: onScalarChange
6555
6639
  });
@@ -6557,7 +6641,7 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
6557
6641
  type: "datetime-local",
6558
6642
  size: "sm",
6559
6643
  "data-slot": "docblocks/filter-value",
6560
- className: "w-auto",
6644
+ className: "min-w-0 flex-1 border-input",
6561
6645
  value: value === void 0 || value === null ? "" : String(value),
6562
6646
  onChange: onScalarChange
6563
6647
  });
@@ -6570,6 +6654,7 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
6570
6654
  const entries = refTable?.rowIds ?? [];
6571
6655
  return /* @__PURE__ */ jsxs(BareSelect, {
6572
6656
  "data-slot": "docblocks/filter-value",
6657
+ className: "min-w-0 flex-1",
6573
6658
  value: value === void 0 || value === null ? "" : String(value),
6574
6659
  onChange: onScalarChange,
6575
6660
  children: [/* @__PURE__ */ jsx("option", {
@@ -6585,7 +6670,7 @@ function ValueInput({ column, operator, value, onChange, refTableData }) {
6585
6670
  type: "text",
6586
6671
  size: "sm",
6587
6672
  "data-slot": "docblocks/filter-value",
6588
- className: "w-auto",
6673
+ className: "min-w-0 flex-1 border-input",
6589
6674
  value: value === void 0 || value === null ? "" : String(value),
6590
6675
  onChange: onScalarChange
6591
6676
  });
@@ -6719,6 +6804,7 @@ function useDatabaseTable(bridge, tableId, filter) {
6719
6804
  const [phase, setPhase] = useState("loading");
6720
6805
  const [table, setTable] = useState(null);
6721
6806
  const [rows, setRows] = useState([]);
6807
+ const [pendingRow, setPendingRow] = useState(null);
6722
6808
  const [nextCursor, setNextCursor] = useState(null);
6723
6809
  const [error, setError] = useState(null);
6724
6810
  const [errorCode, setErrorCode] = useState(null);
@@ -6727,6 +6813,8 @@ function useDatabaseTable(bridge, tableId, filter) {
6727
6813
  const [, setStackVersion] = useState(0);
6728
6814
  const rowsRef = useRef(rows);
6729
6815
  rowsRef.current = rows;
6816
+ const pendingRowRef = useRef(pendingRow);
6817
+ pendingRowRef.current = pendingRow;
6730
6818
  const descriptionRef = useRef(null);
6731
6819
  const revisionsRef = useRef(/* @__PURE__ */ new Map());
6732
6820
  const pageRef = useRef({
@@ -6778,12 +6866,17 @@ function useDatabaseTable(bridge, tableId, filter) {
6778
6866
  columns: snapshot.columns.map((column) => ({ ...column })),
6779
6867
  schemaRevision: snapshot.schemaRevision
6780
6868
  };
6869
+ const visibleIds = new Set(snapshot.page.rows.map((row) => row.id));
6870
+ const pendingBefore = pendingRowRef.current;
6871
+ const pendingRevision = pendingBefore === null ? void 0 : revisionsRef.current.get(pendingBefore.rowId);
6781
6872
  revisionsRef.current = new Map(snapshot.page.rows.map((row) => [row.id, row.revision]));
6873
+ if (pendingBefore !== null && !visibleIds.has(pendingBefore.rowId) && pendingRevision !== void 0) revisionsRef.current.set(pendingBefore.rowId, pendingRevision);
6782
6874
  setTable(descriptionToGrid(snapshot));
6783
6875
  setRows(snapshot.page.rows.map((row) => ({
6784
6876
  rowId: row.id,
6785
6877
  cells: { ...row.cells }
6786
6878
  })));
6879
+ setPendingRow((current) => current !== null && visibleIds.has(current.rowId) ? null : current);
6787
6880
  setNextCursor(snapshot.page.nextCursor);
6788
6881
  if (clearError) {
6789
6882
  setError(null);
@@ -6792,12 +6885,14 @@ function useDatabaseTable(bridge, tableId, filter) {
6792
6885
  setPhase("ready");
6793
6886
  };
6794
6887
  useEffect(() => {
6888
+ setPendingRow(null);
6795
6889
  let disposed = false;
6796
6890
  let handle = null;
6797
6891
  let lastSeenSeq = null;
6798
6892
  const seenSeqs = /* @__PURE__ */ new Set();
6799
6893
  const die = (operationError) => {
6800
6894
  setRows([]);
6895
+ setPendingRow(null);
6801
6896
  setNextCursor(null);
6802
6897
  revisionsRef.current = /* @__PURE__ */ new Map();
6803
6898
  if (handle !== null) handle.unsubscribe();
@@ -6895,7 +6990,7 @@ function useDatabaseTable(bridge, tableId, filter) {
6895
6990
  redoStackRef.current = [];
6896
6991
  bump();
6897
6992
  }, [bump]);
6898
- const refresh = useCallback(() => {
6993
+ const refresh = useCallback((onApplied) => {
6899
6994
  (async () => {
6900
6995
  const token = ++loadTokenRef.current;
6901
6996
  try {
@@ -6905,6 +7000,7 @@ function useDatabaseTable(bridge, tableId, filter) {
6905
7000
  });
6906
7001
  if (token !== loadTokenRef.current) return;
6907
7002
  applySnapshot(snapshot);
7003
+ onApplied?.(snapshot);
6908
7004
  } catch {}
6909
7005
  })();
6910
7006
  }, [
@@ -6920,6 +7016,8 @@ function useDatabaseTable(bridge, tableId, filter) {
6920
7016
  };
6921
7017
  const insertRow = useCallback(async (cells = {}) => {
6922
7018
  let liveRowId;
7019
+ let createdCells = {};
7020
+ let createdRevision;
6923
7021
  try {
6924
7022
  const receipt = await bridge.batchRows(tableId, { ops: [{
6925
7023
  op: "create",
@@ -6929,6 +7027,8 @@ function useDatabaseTable(bridge, tableId, filter) {
6929
7027
  const created = receipt.result.rows[0];
6930
7028
  if (created === void 0) throw new BridgeError("unavailable", "The insert's receipt carries no created row.");
6931
7029
  liveRowId = created.id;
7030
+ createdCells = { ...created.cells };
7031
+ createdRevision = created.revision;
6932
7032
  for (const [id, revision] of Object.entries(receipt.revisions)) revisionsRef.current.set(id, revision);
6933
7033
  } catch (operationError) {
6934
7034
  noteError(operationError);
@@ -6951,7 +7051,17 @@ function useDatabaseTable(bridge, tableId, filter) {
6951
7051
  }] }, newMutationContext());
6952
7052
  }
6953
7053
  }, bridge, tableId);
6954
- refresh();
7054
+ const insertedRowId = liveRowId;
7055
+ refresh((snapshot) => {
7056
+ if (snapshot.page.rows.some((row) => row.id === insertedRowId)) return;
7057
+ if (createdRevision !== void 0) revisionsRef.current.set(insertedRowId, createdRevision);
7058
+ const inserted = {
7059
+ rowId: insertedRowId,
7060
+ cells: { ...createdCells }
7061
+ };
7062
+ pendingRowRef.current = inserted;
7063
+ setPendingRow(inserted);
7064
+ });
6955
7065
  return liveRowId;
6956
7066
  }, [
6957
7067
  bridge,
@@ -6964,6 +7074,7 @@ function useDatabaseTable(bridge, tableId, filter) {
6964
7074
  rowId: row.rowId,
6965
7075
  cells: { ...row.cells }
6966
7076
  }));
7077
+ const pendingSnapshot = pendingRowRef.current;
6967
7078
  const current = rowsRef.current.find((row) => row.rowId === rowId);
6968
7079
  const cleaned = {};
6969
7080
  for (const [key, value] of Object.entries(cells)) if (value !== void 0) cleaned[key] = value;
@@ -6975,6 +7086,13 @@ function useDatabaseTable(bridge, tableId, filter) {
6975
7086
  ...cleaned
6976
7087
  }
6977
7088
  } : row));
7089
+ setPendingRow((current) => current?.rowId === rowId ? {
7090
+ ...current,
7091
+ cells: {
7092
+ ...current.cells,
7093
+ ...cleaned
7094
+ }
7095
+ } : current);
6978
7096
  try {
6979
7097
  const receipt = await bridge.batchRows(tableId, { ops: [{
6980
7098
  op: "update",
@@ -7008,6 +7126,7 @@ function useDatabaseTable(bridge, tableId, filter) {
7008
7126
  refresh();
7009
7127
  } catch (operationError) {
7010
7128
  setRows(snapshot);
7129
+ setPendingRow(pendingSnapshot);
7011
7130
  noteError(operationError);
7012
7131
  refresh();
7013
7132
  throw toBridgeError(operationError);
@@ -7024,6 +7143,7 @@ function useDatabaseTable(bridge, tableId, filter) {
7024
7143
  rowId: row.rowId,
7025
7144
  cells: { ...row.cells }
7026
7145
  }));
7146
+ const pendingSnapshot = pendingRowRef.current;
7027
7147
  const before = new Map(rowsRef.current.map((row) => [row.rowId, row.cells]));
7028
7148
  const cleaned = updates.map(({ rowId, cells }) => {
7029
7149
  const patch = {};
@@ -7048,6 +7168,17 @@ function useDatabaseTable(bridge, tableId, filter) {
7048
7168
  }
7049
7169
  };
7050
7170
  }));
7171
+ setPendingRow((current) => {
7172
+ if (current === null) return null;
7173
+ const patch = byId.get(current.rowId);
7174
+ return patch === void 0 ? current : {
7175
+ ...current,
7176
+ cells: {
7177
+ ...current.cells,
7178
+ ...patch
7179
+ }
7180
+ };
7181
+ });
7051
7182
  try {
7052
7183
  const receipt = await bridge.batchRows(tableId, { ops: cleaned.map(({ rowId, cells }) => ({
7053
7184
  op: "update",
@@ -7088,6 +7219,7 @@ function useDatabaseTable(bridge, tableId, filter) {
7088
7219
  refresh();
7089
7220
  } catch (operationError) {
7090
7221
  setRows(snapshot);
7222
+ setPendingRow(pendingSnapshot);
7091
7223
  noteError(operationError);
7092
7224
  refresh();
7093
7225
  throw toBridgeError(operationError);
@@ -7108,6 +7240,7 @@ function useDatabaseTable(bridge, tableId, filter) {
7108
7240
  rowId,
7109
7241
  ...casOf(rowId)
7110
7242
  }] }, newMutationContext());
7243
+ setPendingRow((current) => current?.rowId === rowId ? null : current);
7111
7244
  if (row !== void 0 && capabilitiesRef.current.includes("rowRestore")) pushUndo({
7112
7245
  label: `remove row ${rowId}`,
7113
7246
  forward: async () => {
@@ -7199,6 +7332,7 @@ function useDatabaseTable(bridge, tableId, filter) {
7199
7332
  rowId: row.rowId,
7200
7333
  cells: { ...row.cells }
7201
7334
  }));
7335
+ const pendingSnapshot = pendingRowRef.current;
7202
7336
  const before = new Map(rowsRef.current.map((row) => [row.rowId, row.cells]));
7203
7337
  const cleaned = updates.map(({ rowId, cells }) => {
7204
7338
  const patch = {};
@@ -7225,6 +7359,17 @@ function useDatabaseTable(bridge, tableId, filter) {
7225
7359
  }
7226
7360
  };
7227
7361
  }));
7362
+ setPendingRow((current) => {
7363
+ if (current === null) return null;
7364
+ const patch = byId.get(current.rowId);
7365
+ return patch === void 0 ? current : {
7366
+ ...current,
7367
+ cells: {
7368
+ ...current.cells,
7369
+ ...patch
7370
+ }
7371
+ };
7372
+ });
7228
7373
  }
7229
7374
  let liveRowIds = [];
7230
7375
  try {
@@ -7284,7 +7429,10 @@ function useDatabaseTable(bridge, tableId, filter) {
7284
7429
  refresh();
7285
7430
  return liveRowIds;
7286
7431
  } catch (operationError) {
7287
- if (updatesChanged) setRows(snapshot);
7432
+ if (updatesChanged) {
7433
+ setRows(snapshot);
7434
+ setPendingRow(pendingSnapshot);
7435
+ }
7288
7436
  noteError(operationError);
7289
7437
  refresh();
7290
7438
  throw toBridgeError(operationError);
@@ -7400,10 +7548,159 @@ function useDatabaseTable(bridge, tableId, filter) {
7400
7548
  if (hasNumberPatch) wirePatch.numberDisplay = numberDisplay;
7401
7549
  return Object.keys(wirePatch).length > 0 ? wirePatch : null;
7402
7550
  };
7551
+ const updateColumn = useCallback(async (columnId, patch) => {
7552
+ const current = descriptionRef.current?.columns.find((entry) => entry.id === columnId);
7553
+ const wirePatch = columnPatchOf(columnId, patch);
7554
+ if (current === void 0 || wirePatch === null) return;
7555
+ const previous = {
7556
+ ...current.operators !== void 0 ? { operators: [...current.operators] } : {},
7557
+ ...current.reference !== void 0 ? { reference: { ...current.reference } } : {},
7558
+ ...current.numberDisplay !== void 0 ? { numberDisplay: { ...current.numberDisplay } } : {}
7559
+ };
7560
+ try {
7561
+ await bridge.updateColumn(tableId, columnId, wirePatch, newMutationContext());
7562
+ pushUndo({
7563
+ label: `update column ${columnId}`,
7564
+ forward: async () => {
7565
+ await bridge.updateColumn(tableId, columnId, wirePatch, newMutationContext());
7566
+ },
7567
+ inverse: async () => {
7568
+ const restore = {};
7569
+ for (const key of Object.keys(wirePatch)) {
7570
+ const value = previous[key];
7571
+ if (value !== void 0) restore[key] = value;
7572
+ }
7573
+ await bridge.updateColumn(tableId, columnId, restore, newMutationContext());
7574
+ }
7575
+ }, bridge, tableId);
7576
+ } catch (operationError) {
7577
+ noteError(operationError);
7578
+ throw toBridgeError(operationError);
7579
+ }
7580
+ }, [
7581
+ bridge,
7582
+ tableId,
7583
+ pushUndo
7584
+ ]);
7585
+ const deleteColumn = useCallback(async (columnId) => {
7586
+ if (descriptionRef.current?.columns.some((entry) => entry.id === columnId) !== true) return;
7587
+ try {
7588
+ await bridge.deleteColumn(tableId, columnId, newMutationContext());
7589
+ if (capabilitiesRef.current.includes("columnRestore")) pushUndo({
7590
+ label: `delete column ${columnId}`,
7591
+ forward: async () => {
7592
+ await bridge.deleteColumn(tableId, columnId, newMutationContext());
7593
+ },
7594
+ inverse: async () => {
7595
+ await bridge.restoreDeletedColumn(tableId, columnId, newMutationContext());
7596
+ }
7597
+ }, bridge, tableId);
7598
+ } catch (operationError) {
7599
+ noteError(operationError);
7600
+ throw toBridgeError(operationError);
7601
+ }
7602
+ }, [
7603
+ bridge,
7604
+ tableId,
7605
+ pushUndo
7606
+ ]);
7607
+ const renameColumn = useCallback(async (columnId, name) => {
7608
+ const current = descriptionRef.current?.columns.find((entry) => entry.id === columnId);
7609
+ if (current === void 0 || current.name === name) return;
7610
+ try {
7611
+ await bridge.updateColumn(tableId, columnId, { name }, newMutationContext());
7612
+ pushUndo({
7613
+ label: `rename column ${columnId}`,
7614
+ forward: async () => {
7615
+ await bridge.updateColumn(tableId, columnId, { name }, newMutationContext());
7616
+ },
7617
+ inverse: async () => {
7618
+ await bridge.updateColumn(tableId, columnId, { name: current.name }, newMutationContext());
7619
+ }
7620
+ }, bridge, tableId);
7621
+ } catch (operationError) {
7622
+ noteError(operationError);
7623
+ throw toBridgeError(operationError);
7624
+ }
7625
+ }, [
7626
+ bridge,
7627
+ tableId,
7628
+ pushUndo
7629
+ ]);
7630
+ const renameTable = useCallback(async (name) => {
7631
+ const previous = descriptionRef.current?.table.name;
7632
+ if (previous === void 0 || previous === name) return;
7633
+ try {
7634
+ await bridge.renameTable(tableId, { name }, newMutationContext());
7635
+ pushUndo({
7636
+ label: `rename table to ${name}`,
7637
+ forward: async () => {
7638
+ await bridge.renameTable(tableId, { name }, newMutationContext());
7639
+ },
7640
+ inverse: async () => {
7641
+ await bridge.renameTable(tableId, { name: previous }, newMutationContext());
7642
+ }
7643
+ }, bridge, tableId);
7644
+ } catch (operationError) {
7645
+ noteError(operationError);
7646
+ throw toBridgeError(operationError);
7647
+ }
7648
+ }, [
7649
+ bridge,
7650
+ tableId,
7651
+ pushUndo
7652
+ ]);
7653
+ const loadMore = useCallback(async () => {
7654
+ if (nextCursor === null) return;
7655
+ const token = loadTokenRef.current;
7656
+ const { asOfSeq, fingerprint } = pageRef.current;
7657
+ try {
7658
+ const page = await bridge.queryNextPage(tableId, {
7659
+ cursor: nextCursor,
7660
+ asOfSeq,
7661
+ queryFingerprint: fingerprint
7662
+ });
7663
+ if (token !== loadTokenRef.current) return;
7664
+ pageRef.current = {
7665
+ asOfSeq: page.asOfSeq,
7666
+ fingerprint: page.queryFingerprint
7667
+ };
7668
+ for (const row of page.rows) revisionsRef.current.set(row.id, row.revision);
7669
+ setRows((rows) => {
7670
+ const known = new Set(rows.map((row) => row.rowId));
7671
+ const appended = page.rows.filter((row) => !known.has(row.id)).map((row) => ({
7672
+ rowId: row.id,
7673
+ cells: { ...row.cells }
7674
+ }));
7675
+ return [...rows, ...appended];
7676
+ });
7677
+ setNextCursor(page.nextCursor);
7678
+ } catch (operationError) {
7679
+ if (token !== loadTokenRef.current) return;
7680
+ if (isBridgeError(operationError) && operationError.code === "cursor_expired") {
7681
+ refresh();
7682
+ return;
7683
+ }
7684
+ noteError(operationError);
7685
+ }
7686
+ }, [
7687
+ bridge,
7688
+ tableId,
7689
+ nextCursor,
7690
+ refresh
7691
+ ]);
7692
+ const retry = useCallback(() => setLoadVersion((version) => version + 1), []);
7403
7693
  return {
7404
7694
  phase,
7405
7695
  table,
7406
7696
  rows,
7697
+ pendingRow,
7698
+ dismissPendingRow: useCallback((rowId) => {
7699
+ setPendingRow((current) => {
7700
+ if (current === null || rowId !== void 0 && current.rowId !== rowId) return current;
7701
+ return null;
7702
+ });
7703
+ }, []),
7407
7704
  revisionOf,
7408
7705
  nextCursor,
7409
7706
  error,
@@ -7414,153 +7711,18 @@ function useDatabaseTable(bridge, tableId, filter) {
7414
7711
  removeRow,
7415
7712
  moveRow,
7416
7713
  addColumn,
7417
- updateColumn: useCallback(async (columnId, patch) => {
7418
- const current = descriptionRef.current?.columns.find((entry) => entry.id === columnId);
7419
- const wirePatch = columnPatchOf(columnId, patch);
7420
- if (current === void 0 || wirePatch === null) return;
7421
- const previous = {
7422
- ...current.operators !== void 0 ? { operators: [...current.operators] } : {},
7423
- ...current.reference !== void 0 ? { reference: { ...current.reference } } : {},
7424
- ...current.numberDisplay !== void 0 ? { numberDisplay: { ...current.numberDisplay } } : {}
7425
- };
7426
- try {
7427
- await bridge.updateColumn(tableId, columnId, wirePatch, newMutationContext());
7428
- pushUndo({
7429
- label: `update column ${columnId}`,
7430
- forward: async () => {
7431
- await bridge.updateColumn(tableId, columnId, wirePatch, newMutationContext());
7432
- },
7433
- inverse: async () => {
7434
- const restore = {};
7435
- for (const key of Object.keys(wirePatch)) {
7436
- const value = previous[key];
7437
- if (value !== void 0) restore[key] = value;
7438
- }
7439
- await bridge.updateColumn(tableId, columnId, restore, newMutationContext());
7440
- }
7441
- }, bridge, tableId);
7442
- } catch (operationError) {
7443
- noteError(operationError);
7444
- throw toBridgeError(operationError);
7445
- }
7446
- }, [
7447
- bridge,
7448
- tableId,
7449
- pushUndo
7450
- ]),
7451
- deleteColumn: useCallback(async (columnId) => {
7452
- if (descriptionRef.current?.columns.some((entry) => entry.id === columnId) !== true) return;
7453
- try {
7454
- await bridge.deleteColumn(tableId, columnId, newMutationContext());
7455
- if (capabilitiesRef.current.includes("columnRestore")) pushUndo({
7456
- label: `delete column ${columnId}`,
7457
- forward: async () => {
7458
- await bridge.deleteColumn(tableId, columnId, newMutationContext());
7459
- },
7460
- inverse: async () => {
7461
- await bridge.restoreDeletedColumn(tableId, columnId, newMutationContext());
7462
- }
7463
- }, bridge, tableId);
7464
- } catch (operationError) {
7465
- noteError(operationError);
7466
- throw toBridgeError(operationError);
7467
- }
7468
- }, [
7469
- bridge,
7470
- tableId,
7471
- pushUndo
7472
- ]),
7473
- renameColumn: useCallback(async (columnId, name) => {
7474
- const current = descriptionRef.current?.columns.find((entry) => entry.id === columnId);
7475
- if (current === void 0 || current.name === name) return;
7476
- try {
7477
- await bridge.updateColumn(tableId, columnId, { name }, newMutationContext());
7478
- pushUndo({
7479
- label: `rename column ${columnId}`,
7480
- forward: async () => {
7481
- await bridge.updateColumn(tableId, columnId, { name }, newMutationContext());
7482
- },
7483
- inverse: async () => {
7484
- await bridge.updateColumn(tableId, columnId, { name: current.name }, newMutationContext());
7485
- }
7486
- }, bridge, tableId);
7487
- } catch (operationError) {
7488
- noteError(operationError);
7489
- throw toBridgeError(operationError);
7490
- }
7491
- }, [
7492
- bridge,
7493
- tableId,
7494
- pushUndo
7495
- ]),
7496
- renameTable: useCallback(async (name) => {
7497
- const previous = descriptionRef.current?.table.name;
7498
- if (previous === void 0 || previous === name) return;
7499
- try {
7500
- await bridge.renameTable(tableId, { name }, newMutationContext());
7501
- pushUndo({
7502
- label: `rename table to ${name}`,
7503
- forward: async () => {
7504
- await bridge.renameTable(tableId, { name }, newMutationContext());
7505
- },
7506
- inverse: async () => {
7507
- await bridge.renameTable(tableId, { name: previous }, newMutationContext());
7508
- }
7509
- }, bridge, tableId);
7510
- } catch (operationError) {
7511
- noteError(operationError);
7512
- throw toBridgeError(operationError);
7513
- }
7514
- }, [
7515
- bridge,
7516
- tableId,
7517
- pushUndo
7518
- ]),
7519
- loadMore: useCallback(async () => {
7520
- if (nextCursor === null) return;
7521
- const token = loadTokenRef.current;
7522
- const { asOfSeq, fingerprint } = pageRef.current;
7523
- try {
7524
- const page = await bridge.queryNextPage(tableId, {
7525
- cursor: nextCursor,
7526
- asOfSeq,
7527
- queryFingerprint: fingerprint
7528
- });
7529
- if (token !== loadTokenRef.current) return;
7530
- pageRef.current = {
7531
- asOfSeq: page.asOfSeq,
7532
- fingerprint: page.queryFingerprint
7533
- };
7534
- for (const row of page.rows) revisionsRef.current.set(row.id, row.revision);
7535
- setRows((rows) => {
7536
- const known = new Set(rows.map((row) => row.rowId));
7537
- const appended = page.rows.filter((row) => !known.has(row.id)).map((row) => ({
7538
- rowId: row.id,
7539
- cells: { ...row.cells }
7540
- }));
7541
- return [...rows, ...appended];
7542
- });
7543
- setNextCursor(page.nextCursor);
7544
- } catch (operationError) {
7545
- if (token !== loadTokenRef.current) return;
7546
- if (isBridgeError(operationError) && operationError.code === "cursor_expired") {
7547
- refresh();
7548
- return;
7549
- }
7550
- noteError(operationError);
7551
- }
7552
- }, [
7553
- bridge,
7554
- tableId,
7555
- nextCursor,
7556
- refresh
7557
- ]),
7558
- retry: useCallback(() => setLoadVersion((version) => version + 1), []),
7714
+ updateColumn,
7715
+ deleteColumn,
7716
+ renameColumn,
7717
+ renameTable,
7718
+ loadMore,
7719
+ retry,
7559
7720
  undo: useCallback(async () => {
7560
7721
  if (historyInFlightRef.current) return;
7561
7722
  const ops = undoStackRef.current;
7562
7723
  const op = ops[ops.length - 1];
7563
7724
  if (op === void 0) return;
7725
+ setPendingRow(null);
7564
7726
  const identity = {
7565
7727
  bridge: historyRef.current.bridge,
7566
7728
  tableId: historyRef.current.tableId
@@ -7594,6 +7756,7 @@ function useDatabaseTable(bridge, tableId, filter) {
7594
7756
  const ops = redoStackRef.current;
7595
7757
  const op = ops[ops.length - 1];
7596
7758
  if (op === void 0) return;
7759
+ setPendingRow(null);
7597
7760
  const identity = {
7598
7761
  bridge: historyRef.current.bridge,
7599
7762
  tableId: historyRef.current.tableId
@@ -7630,26 +7793,310 @@ function useDatabaseTable(bridge, tableId, filter) {
7630
7793
  };
7631
7794
  }
7632
7795
  //#endregion
7633
- //#region src/database/grid/EnumOptionsEditor.tsx
7634
- /** The enum's options editor (the create / the edit's form stand): the
7635
- * option's rows over the draft (the grip's press-drag stands the live
7636
- * reorder — the draft's pure stand, no bridge write until the form's
7637
- * commit; the color's swatch stands the palette's popover — the hex
7638
- * stands the data; the name's input; the delete's control) + the
7639
- * add-option's entry. The row's pitch stands the drag's index math
7640
- * (the 32 px row + the 4 px gap = the 36 px pitch). */
7641
- function EnumOptionsEditor({ options, onChange }) {
7642
- const { t } = useTranslation("database");
7643
- const [colorOpen, setColorOpen] = useState(null);
7644
- const setOption = (index, patch) => {
7645
- onChange(options.map((option, i) => i === index ? {
7646
- ...option,
7647
- ...patch
7648
- } : option));
7649
- };
7650
- /** The grip's drag session (the window-level pointer stand — the capture
7651
- * would retarget the presses): the live reorder over the draft's stand
7652
- * (the release stands nothing extra — the draft IS the order). The
7796
+ //#region src/database/grid/utils.ts
7797
+ /** The database grid's pure helpers: the visible-column derivation, the
7798
+ * number column's display attributes / input step, the cell's selection
7799
+ * key, and the date/datetime value parsing + labels. */
7800
+ /** The full known id order: explicit ids first, then new schema columns. */
7801
+ function normalizeColumnOrder(columns, columnOrder) {
7802
+ const byId = new Map((columns ?? []).map((column) => [column.id, column]));
7803
+ const ordered = [];
7804
+ for (const id of columnOrder ?? []) {
7805
+ if (!byId.has(id) || ordered.includes(id)) continue;
7806
+ ordered.push(id);
7807
+ byId.delete(id);
7808
+ }
7809
+ for (const column of byId.values()) ordered.push(column.id);
7810
+ return ordered;
7811
+ }
7812
+ /** The block's visible columns: the full order minus the hidden ids. */
7813
+ function visibleColumns(columns, columnOrder, hiddenColumns) {
7814
+ const byId = new Map((columns ?? []).map((column) => [column.id, column]));
7815
+ const hidden = new Set(hiddenColumns ?? []);
7816
+ return normalizeColumnOrder(columns, columnOrder).flatMap((id) => {
7817
+ const column = byId.get(id);
7818
+ return column === void 0 || hidden.has(id) ? [] : [column];
7819
+ });
7820
+ }
7821
+ /** One immutable list move; an invalid or identity move returns the input. */
7822
+ function reorderItems(items, fromIndex, toIndex) {
7823
+ if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length) return items;
7824
+ const next = [...items];
7825
+ const [moved] = next.splice(fromIndex, 1);
7826
+ if (moved === void 0) return items;
7827
+ next.splice(toIndex, 0, moved);
7828
+ return next;
7829
+ }
7830
+ /** A visible header drop mapped into the full order without moving hidden ids over an anchor. */
7831
+ function moveVisibleColumn(columns, columnOrder, hiddenColumns, columnId, toIndex) {
7832
+ const fullOrder = normalizeColumnOrder(columns, columnOrder);
7833
+ const visibleIds = visibleColumns(columns, columnOrder, hiddenColumns).map((column) => column.id);
7834
+ const stationary = visibleIds.filter((id) => id !== columnId);
7835
+ if (stationary.length === visibleIds.length || toIndex < 0 || toIndex > stationary.length) return fullOrder;
7836
+ const next = fullOrder.filter((id) => id !== columnId);
7837
+ const targetId = stationary[toIndex];
7838
+ if (targetId !== void 0) {
7839
+ next.splice(next.indexOf(targetId), 0, columnId);
7840
+ return next;
7841
+ }
7842
+ const anchorId = stationary.at(-1);
7843
+ if (anchorId === void 0) return fullOrder;
7844
+ next.splice(next.indexOf(anchorId) + 1, 0, columnId);
7845
+ return next;
7846
+ }
7847
+ /** The number input's step stand: the explicit `decimals` stands the
7848
+ * `10^-decimals` step; the absent stand follows the integer types only
7849
+ * (the float types stand no step — the 0.5 must be typeable). */
7850
+ function numberStepFor(column) {
7851
+ if (column.decimals !== void 0) {
7852
+ const decimals = Math.max(0, Math.min(10, Math.trunc(Number(column.decimals)) || 0));
7853
+ return decimals === 0 ? "1" : String(10 ** -decimals);
7854
+ }
7855
+ const base = column.type.replace(/\[\]$/, "").trim();
7856
+ return base === "integer" || base === "int" || base === "smallint" || base === "bigint" ? "1" : void 0;
7857
+ }
7858
+ /** The display's attributes stand: the explicit `decimals` (or the
7859
+ * integer stand) takes the fixed-digit format; the float types without
7860
+ * the explicit digits stand the RAW value (no rounding — the display
7861
+ * must not lose the value's own stand). */
7862
+ function numberDisplayAttrs(column) {
7863
+ const base = column.type.replace(/\[\]$/, "").trim();
7864
+ return {
7865
+ decimals: column.decimals !== void 0 || base === "integer" || base === "int" || base === "smallint" || base === "bigint" || base === "number" ? column.decimals ?? 0 : null,
7866
+ thousands: column.thousands,
7867
+ prefix: column.prefix,
7868
+ suffix: column.suffix
7869
+ };
7870
+ }
7871
+ /** The cell's selection/editing key (the row id + the column id). */
7872
+ const cellKeyOf = (rowId, colId) => `${rowId}\u0000${colId}`;
7873
+ /** The cell's clipboard text: the TSV's flat stand (the tab / the
7874
+ * newline stand the space — the TSV's shape stands; the row-link's array
7875
+ * joins over the comma — the label's stand, never the id). */
7876
+ function cellTextOf(value) {
7877
+ if (value === void 0 || value === null) return "";
7878
+ if (Array.isArray(value)) return value.map((item) => cellTextOf(item)).join(",");
7879
+ return String(value).replace(/[\t\n\r]/g, " ");
7880
+ }
7881
+ /** The TSV's parse (the clipboard's plain text over the grid's paste):
7882
+ * the rows over the newline (the carriage return stands the newline),
7883
+ * the cells over the tab; the trailing empty row stands no stand (the
7884
+ * clipboard's trailing newline). An empty text stands no grid. */
7885
+ function parseClipboardTsv(text) {
7886
+ const lines = text.replace(/\r\n?/g, "\n").split("\n");
7887
+ if (lines.length > 1 && lines[lines.length - 1] === "") lines.pop();
7888
+ if (lines.length === 0 || lines.length === 1 && lines[0] === "") return [];
7889
+ return lines.map((line) => line.split(" "));
7890
+ }
7891
+ /** The local-calendar day (the year / month / date stand, the time is
7892
+ * dropped) — the picker's draft stand. */
7893
+ function dateOnly(value) {
7894
+ return new Date(value.getFullYear(), value.getMonth(), value.getDate());
7895
+ }
7896
+ /** The time stand (the hours / minutes / the seconds are not all zero). */
7897
+ function hasTime(value) {
7898
+ return value.getHours() !== 0 || value.getMinutes() !== 0 || value.getSeconds() !== 0;
7899
+ }
7900
+ /** The datetime cell's value (the optional "THH:MM" / "THH:MM:SS" time
7901
+ * part) parsed to the local-calendar Date; null when absent / invalid. */
7902
+ function parseCellDateTime(value) {
7903
+ const raw = value === void 0 || value === null ? "" : String(value);
7904
+ if (raw === "") return null;
7905
+ if (raw.includes("T")) {
7906
+ const withSeconds = parse(raw, "yyyy-MM-dd'T'HH:mm:ss", /* @__PURE__ */ new Date());
7907
+ const result = Number.isNaN(withSeconds.getTime()) ? parse(raw, "yyyy-MM-dd'T'HH:mm", /* @__PURE__ */ new Date()) : withSeconds;
7908
+ return Number.isNaN(result.getTime()) ? null : result;
7909
+ }
7910
+ const dateOnlyResult = parse(raw, "yyyy-MM-dd", /* @__PURE__ */ new Date());
7911
+ return Number.isNaN(dateOnlyResult.getTime()) ? null : dateOnlyResult;
7912
+ }
7913
+ /** The datetime's compact label (`dd.MM.yyyy HH:mm` — the seconds stand
7914
+ * only when they are not zero; the midnight zero stands the date only). */
7915
+ function dateTimeLabel(value) {
7916
+ const base = format(value, "dd.MM.yyyy");
7917
+ if (!hasTime(value)) return base;
7918
+ const label = format(value, "HH:mm");
7919
+ return value.getSeconds() !== 0 ? `${base} ${label}:${format(value, "ss")}` : `${base} ${label}`;
7920
+ }
7921
+ /** The form draft over a catalog entry (the name prefills the type's
7922
+ * label — the create's commit takes the input's name). */
7923
+ function emptyColumnForm(entry) {
7924
+ return {
7925
+ key: entry.key,
7926
+ type: entry.type,
7927
+ name: entry.label,
7928
+ numberKind: entry.numberKind,
7929
+ decimals: entry.numberKind === "decimal" ? 2 : 0,
7930
+ thousands: false,
7931
+ prefix: "",
7932
+ suffix: "",
7933
+ allowNegative: true,
7934
+ refKind: entry.refKind,
7935
+ refMany: entry.refMany,
7936
+ refPick: "",
7937
+ newTableName: ""
7938
+ };
7939
+ }
7940
+ //#endregion
7941
+ //#region src/database/grid/ColumnManager.tsx
7942
+ function ColumnRow({ column, hidden, hideDisabled, onToggle, onMove, onDragStart, onDragEnd }) {
7943
+ const { t } = useTranslation("database");
7944
+ const dragControls = useDragControls();
7945
+ const onGripPointerDown = (event) => {
7946
+ if (event.button !== 0) return;
7947
+ dragControls.start(event);
7948
+ };
7949
+ const onGripKeyDown = (event) => {
7950
+ if (event.key !== "ArrowUp" && event.key !== "ArrowDown") return;
7951
+ event.preventDefault();
7952
+ event.stopPropagation();
7953
+ onMove(column.id, event.key === "ArrowUp" ? -1 : 1);
7954
+ };
7955
+ const onVisibilityChange = () => onToggle(column.id);
7956
+ const onReorderEnd = () => onDragEnd(column.id);
7957
+ return /* @__PURE__ */ jsxs(Reorder.Item, {
7958
+ as: "div",
7959
+ value: column.id,
7960
+ dragListener: false,
7961
+ dragControls,
7962
+ onDragStart,
7963
+ onDragEnd: onReorderEnd,
7964
+ className: "flex items-center gap-1 rounded-sm px-1 py-0.5 text-sm",
7965
+ children: [
7966
+ /* @__PURE__ */ jsx(Button, {
7967
+ type: "button",
7968
+ variant: "ghost",
7969
+ size: "icon",
7970
+ "data-slot": "docblocks/database-column-move",
7971
+ "data-column-id": column.id,
7972
+ "aria-label": t("columns.move", { name: column.name }),
7973
+ className: "size-6 shrink-0 cursor-grab text-muted-foreground active:cursor-grabbing",
7974
+ onPointerDown: onGripPointerDown,
7975
+ onKeyDown: onGripKeyDown,
7976
+ children: /* @__PURE__ */ jsx(GripVertical, { className: "size-3.5" })
7977
+ }),
7978
+ /* @__PURE__ */ jsx("span", {
7979
+ className: cn("min-w-0 flex-1 truncate px-1", hidden && "text-muted-foreground"),
7980
+ children: column.name
7981
+ }),
7982
+ /* @__PURE__ */ jsx(Checkbox, {
7983
+ "data-slot": "docblocks/database-column-visibility",
7984
+ "data-column-id": column.id,
7985
+ "aria-label": t("columns.visibility", { name: column.name }),
7986
+ checked: !hidden,
7987
+ disabled: hideDisabled,
7988
+ onCheckedChange: onVisibilityChange
7989
+ })
7990
+ ]
7991
+ });
7992
+ }
7993
+ function ColumnManager({ columns, columnOrder, hiddenColumns, columnWidths, triggerClassName, onViewChange }) {
7994
+ const { t } = useTranslation("database");
7995
+ const [open, setOpen] = useState(false);
7996
+ const [draftOrder, setDraftOrder] = useState(null);
7997
+ const dragStartOrderRef = useRef(null);
7998
+ const normalizedOrder = normalizeColumnOrder(columns, columnOrder);
7999
+ const order = draftOrder ?? normalizedOrder;
8000
+ const hidden = new Set(hiddenColumns ?? []);
8001
+ const hiddenCount = columns.filter((column) => hidden.has(column.id)).length;
8002
+ const visibleCount = columns.length - hiddenCount;
8003
+ const onOpenChange = (nextOpen) => {
8004
+ setOpen(nextOpen);
8005
+ if (!nextOpen) setDraftOrder(null);
8006
+ };
8007
+ const commitOrder = (columnId, nextOrder, previousOrder) => {
8008
+ if (nextOrder.every((id, index) => id === previousOrder[index])) return;
8009
+ const previousVisible = visibleColumns(columns, previousOrder, hiddenColumns).map((column) => column.id);
8010
+ const nextVisible = visibleColumns(columns, nextOrder, hiddenColumns).map((column) => column.id);
8011
+ const fromIndex = previousVisible.indexOf(columnId);
8012
+ const toIndex = nextVisible.indexOf(columnId);
8013
+ onViewChange({
8014
+ columnOrder: nextOrder,
8015
+ ...columnWidths !== void 0 ? { columnWidths: reorderItems(columnWidths, fromIndex, toIndex) } : {}
8016
+ });
8017
+ setDraftOrder(nextOrder);
8018
+ };
8019
+ const onDragStart = () => {
8020
+ dragStartOrderRef.current = order;
8021
+ };
8022
+ const onDragEnd = (columnId) => {
8023
+ const previousOrder = dragStartOrderRef.current ?? order;
8024
+ dragStartOrderRef.current = null;
8025
+ if (draftOrder !== null) commitOrder(columnId, draftOrder, previousOrder);
8026
+ };
8027
+ const onMove = (columnId, delta) => {
8028
+ const fromIndex = order.indexOf(columnId);
8029
+ const toIndex = fromIndex + delta;
8030
+ if (fromIndex < 0 || toIndex < 0 || toIndex >= order.length) return;
8031
+ commitOrder(columnId, reorderItems(order, fromIndex, toIndex), order);
8032
+ };
8033
+ const onToggle = (columnId) => {
8034
+ const isHidden = hidden.has(columnId);
8035
+ if (!isHidden && visibleCount === 1) return;
8036
+ onViewChange({ hiddenColumns: isHidden ? [...hidden].filter((id) => id !== columnId) : [...hidden, columnId] });
8037
+ };
8038
+ return /* @__PURE__ */ jsxs(Popover, {
8039
+ open,
8040
+ onOpenChange,
8041
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
8042
+ asChild: true,
8043
+ children: /* @__PURE__ */ jsxs(Button, {
8044
+ "data-slot": "docblocks/database-columns",
8045
+ variant: "outline",
8046
+ size: "sm",
8047
+ "data-active": hiddenCount > 0 ? "true" : void 0,
8048
+ className: triggerClassName,
8049
+ children: [t("toolbar.columns"), hiddenCount > 0 ? " •" : ""]
8050
+ })
8051
+ }), /* @__PURE__ */ jsx(PopoverContent, {
8052
+ "data-slot": "docblocks/database-columns-content",
8053
+ "aria-label": t("toolbar.columns"),
8054
+ align: "end",
8055
+ className: "w-72 p-2",
8056
+ children: /* @__PURE__ */ jsx(Reorder.Group, {
8057
+ as: "div",
8058
+ axis: "y",
8059
+ values: order,
8060
+ onReorder: setDraftOrder,
8061
+ className: "flex max-h-80 scrollbar-thin flex-col gap-0.5 overflow-y-auto",
8062
+ children: order.map((columnId) => {
8063
+ const column = columns.find((entry) => entry.id === columnId);
8064
+ if (column === void 0) return null;
8065
+ return /* @__PURE__ */ jsx(ColumnRow, {
8066
+ column,
8067
+ hidden: hidden.has(column.id),
8068
+ hideDisabled: !hidden.has(column.id) && visibleCount === 1,
8069
+ onToggle,
8070
+ onMove,
8071
+ onDragStart,
8072
+ onDragEnd
8073
+ }, column.id);
8074
+ })
8075
+ })
8076
+ })]
8077
+ });
8078
+ }
8079
+ //#endregion
8080
+ //#region src/database/grid/EnumOptionsEditor.tsx
8081
+ /** The enum's options editor (the create / the edit's form stand): the
8082
+ * option's rows over the draft (the grip's press-drag stands the live
8083
+ * reorder — the draft's pure stand, no bridge write until the form's
8084
+ * commit; the color's swatch stands the palette's popover — the hex
8085
+ * stands the data; the name's input; the delete's control) + the
8086
+ * add-option's entry. The row's pitch stands the drag's index math
8087
+ * (the 32 px row + the 4 px gap = the 36 px pitch). */
8088
+ function EnumOptionsEditor({ options, onChange }) {
8089
+ const { t } = useTranslation("database");
8090
+ const [colorOpen, setColorOpen] = useState(null);
8091
+ const setOption = (index, patch) => {
8092
+ onChange(options.map((option, i) => i === index ? {
8093
+ ...option,
8094
+ ...patch
8095
+ } : option));
8096
+ };
8097
+ /** The grip's drag session (the window-level pointer stand — the capture
8098
+ * would retarget the presses): the live reorder over the draft's stand
8099
+ * (the release stands nothing extra — the draft IS the order). The
7653
8100
  * pitch stands measured (the row's own box + the group's row-gap —
7654
8101
  * the stand is layout-driven, not a constant). */
7655
8102
  const beginGripDrag = (index) => (event) => {
@@ -7866,8 +8313,6 @@ const CELL_WRAP = "flex min-h-6 min-w-0 items-center overflow-hidden border-(--d
7866
8313
  * edit's stand). */
7867
8314
  const CELL_INPUT = "select-text rounded-(--docblocks-radius) border-0 bg-transparent px-1 text-(length:--docblocks-font-size) focus:bg-(--docblocks-selected-background)/50 dark:bg-transparent";
7868
8315
  const GRID_DRAG_TRANSITION = "transform 120ms ease-out";
7869
- /** The undo / redo button's frame stand (the disabled's off). */
7870
- const GRID_HISTORY_BUTTON = "h-auto px-2 py-0.5 text-xs font-normal shadow-none disabled:cursor-default disabled:opacity-40";
7871
8316
  //#endregion
7872
8317
  //#region src/database/grid/HeaderCell.tsx
7873
8318
  /** The grid's header cell (the column's name + the press menu + the
@@ -8076,122 +8521,6 @@ function frame(frameText, trailing = false) {
8076
8521
  return trailing ? ` ${frameText}` : `${frameText} `;
8077
8522
  }
8078
8523
  //#endregion
8079
- //#region src/database/grid/utils.ts
8080
- /** The database grid's pure helpers: the visible-column derivation, the
8081
- * number column's display attributes / input step, the cell's selection
8082
- * key, and the date/datetime value parsing + labels. */
8083
- /** The block's visible columns: the `columnOrder` attr first (the
8084
- * additive columns not listed keep the schema order), the hidden
8085
- * columns dropped. */
8086
- function visibleColumns(columns, columnOrder, hiddenColumns) {
8087
- const all = columns ?? [];
8088
- const hidden = new Set(hiddenColumns ?? []);
8089
- const byId = new Map(all.filter((column) => !hidden.has(column.id)).map((column) => [column.id, column]));
8090
- const ordered = [];
8091
- if (columnOrder !== void 0) for (const id of columnOrder) {
8092
- const column = byId.get(id);
8093
- if (column !== void 0) {
8094
- ordered.push(column);
8095
- byId.delete(id);
8096
- }
8097
- }
8098
- for (const column of byId.values()) ordered.push(column);
8099
- return ordered;
8100
- }
8101
- /** The number input's step stand: the explicit `decimals` stands the
8102
- * `10^-decimals` step; the absent stand follows the integer types only
8103
- * (the float types stand no step — the 0.5 must be typeable). */
8104
- function numberStepFor(column) {
8105
- if (column.decimals !== void 0) {
8106
- const decimals = Math.max(0, Math.min(10, Math.trunc(Number(column.decimals)) || 0));
8107
- return decimals === 0 ? "1" : String(10 ** -decimals);
8108
- }
8109
- const base = column.type.replace(/\[\]$/, "").trim();
8110
- return base === "integer" || base === "int" || base === "smallint" || base === "bigint" ? "1" : void 0;
8111
- }
8112
- /** The display's attributes stand: the explicit `decimals` (or the
8113
- * integer stand) takes the fixed-digit format; the float types without
8114
- * the explicit digits stand the RAW value (no rounding — the display
8115
- * must not lose the value's own stand). */
8116
- function numberDisplayAttrs(column) {
8117
- const base = column.type.replace(/\[\]$/, "").trim();
8118
- return {
8119
- decimals: column.decimals !== void 0 || base === "integer" || base === "int" || base === "smallint" || base === "bigint" || base === "number" ? column.decimals ?? 0 : null,
8120
- thousands: column.thousands,
8121
- prefix: column.prefix,
8122
- suffix: column.suffix
8123
- };
8124
- }
8125
- /** The cell's selection/editing key (the row id + the column id). */
8126
- const cellKeyOf = (rowId, colId) => `${rowId}\u0000${colId}`;
8127
- /** The cell's clipboard text: the TSV's flat stand (the tab / the
8128
- * newline stand the space — the TSV's shape stands; the row-link's array
8129
- * joins over the comma — the label's stand, never the id). */
8130
- function cellTextOf(value) {
8131
- if (value === void 0 || value === null) return "";
8132
- if (Array.isArray(value)) return value.map((item) => cellTextOf(item)).join(",");
8133
- return String(value).replace(/[\t\n\r]/g, " ");
8134
- }
8135
- /** The TSV's parse (the clipboard's plain text over the grid's paste):
8136
- * the rows over the newline (the carriage return stands the newline),
8137
- * the cells over the tab; the trailing empty row stands no stand (the
8138
- * clipboard's trailing newline). An empty text stands no grid. */
8139
- function parseClipboardTsv(text) {
8140
- const lines = text.replace(/\r\n?/g, "\n").split("\n");
8141
- if (lines.length > 1 && lines[lines.length - 1] === "") lines.pop();
8142
- if (lines.length === 0 || lines.length === 1 && lines[0] === "") return [];
8143
- return lines.map((line) => line.split(" "));
8144
- }
8145
- /** The local-calendar day (the year / month / date stand, the time is
8146
- * dropped) — the picker's draft stand. */
8147
- function dateOnly(value) {
8148
- return new Date(value.getFullYear(), value.getMonth(), value.getDate());
8149
- }
8150
- /** The time stand (the hours / minutes / the seconds are not all zero). */
8151
- function hasTime(value) {
8152
- return value.getHours() !== 0 || value.getMinutes() !== 0 || value.getSeconds() !== 0;
8153
- }
8154
- /** The datetime cell's value (the optional "THH:MM" / "THH:MM:SS" time
8155
- * part) parsed to the local-calendar Date; null when absent / invalid. */
8156
- function parseCellDateTime(value) {
8157
- const raw = value === void 0 || value === null ? "" : String(value);
8158
- if (raw === "") return null;
8159
- if (raw.includes("T")) {
8160
- const withSeconds = parse(raw, "yyyy-MM-dd'T'HH:mm:ss", /* @__PURE__ */ new Date());
8161
- const result = Number.isNaN(withSeconds.getTime()) ? parse(raw, "yyyy-MM-dd'T'HH:mm", /* @__PURE__ */ new Date()) : withSeconds;
8162
- return Number.isNaN(result.getTime()) ? null : result;
8163
- }
8164
- const dateOnlyResult = parse(raw, "yyyy-MM-dd", /* @__PURE__ */ new Date());
8165
- return Number.isNaN(dateOnlyResult.getTime()) ? null : dateOnlyResult;
8166
- }
8167
- /** The datetime's compact label (`dd.MM.yyyy HH:mm` — the seconds stand
8168
- * only when they are not zero; the midnight zero stands the date only). */
8169
- function dateTimeLabel(value) {
8170
- const base = format(value, "dd.MM.yyyy");
8171
- if (!hasTime(value)) return base;
8172
- const label = format(value, "HH:mm");
8173
- return value.getSeconds() !== 0 ? `${base} ${label}:${format(value, "ss")}` : `${base} ${label}`;
8174
- }
8175
- /** The form draft over a catalog entry (the name prefills the type's
8176
- * label — the create's commit takes the input's name). */
8177
- function emptyColumnForm(entry) {
8178
- return {
8179
- key: entry.key,
8180
- type: entry.type,
8181
- name: entry.label,
8182
- numberKind: entry.numberKind,
8183
- decimals: entry.numberKind === "decimal" ? 2 : 0,
8184
- thousands: false,
8185
- prefix: "",
8186
- suffix: "",
8187
- allowNegative: true,
8188
- refKind: entry.refKind,
8189
- refMany: entry.refMany,
8190
- refPick: "",
8191
- newTableName: ""
8192
- };
8193
- }
8194
- //#endregion
8195
8524
  //#region src/database/grid/cells/constants.ts
8196
8525
  /** The chip's ink (the option's colors stand the pastel data — the dark
8197
8526
  * ink stands legible on them over both themes). */
@@ -8570,7 +8899,7 @@ function RowLinkPicker({ rowIds, displays, current, open, onPick, onClear, onEdi
8570
8899
  * placeholder, no trigger chrome): the pickers open on the double press
8571
8900
  * over the cell itself.
8572
8901
  */
8573
- function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, first, lastRow, dragDx, dragShifted, selected, singleSelected, editing, onChange, onPointerDown, onEditStart, onEditEnd, booleanPress, refTableData }) {
8902
+ function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, first, lastRow, filterPending, dragDx, dragShifted, selected, singleSelected, editing, onChange, onPointerDown, onEditStart, onEditEnd, booleanPress, refTableData }) {
8574
8903
  const annotation = columnAnnotation(column);
8575
8904
  const empty = value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
8576
8905
  const isDate = annotation.valueInput === "date";
@@ -8591,6 +8920,14 @@ function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, firs
8591
8920
  const openValueRef = useRef(null);
8592
8921
  const openDateRef = useRef(null);
8593
8922
  const openRevisionRef = useRef(void 0);
8923
+ useEffect(() => {
8924
+ if (!editing || !isText && !isNumber || openValueRef.current !== null) return;
8925
+ textCancelledRef.current = false;
8926
+ textSettledRef.current = false;
8927
+ openValueRef.current = rawValue;
8928
+ openRevisionRef.current = revision;
8929
+ setTextDraft(rawValue);
8930
+ }, [editing]);
8594
8931
  const multiLineSeatRef = useRef(null);
8595
8932
  useEffect(() => {
8596
8933
  if (!editing) multiLineSeatRef.current = null;
@@ -8858,6 +9195,8 @@ function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, firs
8858
9195
  const cell = /* @__PURE__ */ jsx("div", {
8859
9196
  "data-slot": "docblocks/database-cell",
8860
9197
  "data-key": cellKeyOf(rowId, column.id),
9198
+ "data-row-id": rowId,
9199
+ "data-filter-pending": filterPending ? "true" : void 0,
8861
9200
  "data-row": rowIndex,
8862
9201
  "data-col": colIndex,
8863
9202
  "data-column-id": column.id,
@@ -8918,11 +9257,13 @@ function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, firs
8918
9257
  /** The grid's row-menu track (the trailing grid column: the move / the
8919
9258
  * delete row affordances). */
8920
9259
  /** The row's menu track (the trailing grid column). */
8921
- function RowMenuCell({ row, rowMenu, setRowMenu, canMoveUp, canMoveDown, onMoveUp, onMoveDown, onRemove, lastRow }) {
9260
+ function RowMenuCell({ row, rowMenu, setRowMenu, canMoveUp, canMoveDown, onMoveUp, onMoveDown, onRemove, lastRow, filterPending }) {
8922
9261
  const { t } = useTranslation("database");
8923
9262
  const onRowMenuChange = (open) => setRowMenu(open ? row.rowId : null);
8924
9263
  return /* @__PURE__ */ jsx("div", {
8925
9264
  "data-slot": "docblocks/database-row-menu",
9265
+ "data-row-id": row.rowId,
9266
+ "data-filter-pending": filterPending ? "true" : void 0,
8926
9267
  className: cn(`
8927
9268
  flex w-10 items-center justify-center border-l-(length:--docblocks-table-border-width)
8928
9269
  border-(--docblocks-table-border-color)
@@ -9276,7 +9617,7 @@ function useGridCellInteraction({ rows, columns, data, tableRef, readOnly = fals
9276
9617
  * columns against the press-time snapshot — a peer restructure stands no
9277
9618
  * commit), and the cancel. The preview's state stands in the hook (the view
9278
9619
  * reads the dragged column's live dx + the parting shift). */
9279
- function useGridColumnDrag({ columns, updateView, tableRef }) {
9620
+ function useGridColumnDrag({ columns, allColumns, columnOrder, hiddenColumns, columnWidths, updateView, tableRef }) {
9280
9621
  const [drag, setDrag] = useState(null);
9281
9622
  const dragSession = useRef(null);
9282
9623
  const onColumnPointerDown = (column, event) => {
@@ -9288,6 +9629,7 @@ function useGridColumnDrag({ columns, updateView, tableRef }) {
9288
9629
  index,
9289
9630
  startX: event.clientX,
9290
9631
  ids: columns.map((entry) => entry.id),
9632
+ order: normalizeColumnOrder(allColumns, columnOrder),
9291
9633
  started: false,
9292
9634
  startWidth: event.currentTarget.getBoundingClientRect().width
9293
9635
  };
@@ -9334,11 +9676,13 @@ function useGridColumnDrag({ columns, updateView, tableRef }) {
9334
9676
  if (!session.started) return;
9335
9677
  setDrag(null);
9336
9678
  if (!columns.map((entry) => entry.id).every((value, i) => session.ids[i] === value)) return;
9679
+ if (!normalizeColumnOrder(allColumns, columnOrder).every((value, i) => session.order[i] === value)) return;
9337
9680
  const toIndex = columnDropIndexAt(event.clientX, session.columnId);
9338
9681
  if (toIndex === null || toIndex === session.index) return;
9339
- const ids = session.ids.filter((value) => value !== session.columnId);
9340
- ids.splice(toIndex, 0, session.columnId);
9341
- updateView({ columnOrder: ids });
9682
+ updateView({
9683
+ columnOrder: moveVisibleColumn(allColumns, columnOrder, hiddenColumns, session.columnId, toIndex),
9684
+ ...columnWidths !== void 0 ? { columnWidths: reorderItems(columnWidths, session.index, toIndex) } : {}
9685
+ });
9342
9686
  };
9343
9687
  return {
9344
9688
  drag,
@@ -9753,6 +10097,7 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9753
10097
  };
9754
10098
  const [nameDraft, setNameDraft] = useState(null);
9755
10099
  const tableRef = useRef(null);
10100
+ const pendingDismissTimerRef = useRef(null);
9756
10101
  const columns = visibleColumns(data.table?.columns, columnOrder, hiddenColumns);
9757
10102
  const updateView = (patch) => {
9758
10103
  onViewChange(patch);
@@ -9764,6 +10109,10 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9764
10109
  });
9765
10110
  const { drag, onColumnPointerDown, onColumnPointerMove, onColumnPointerUp } = useGridColumnDrag({
9766
10111
  columns,
10112
+ allColumns: data.table?.columns,
10113
+ columnOrder,
10114
+ hiddenColumns,
10115
+ columnWidths,
9767
10116
  updateView,
9768
10117
  tableRef
9769
10118
  });
@@ -9774,7 +10123,10 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9774
10123
  return (index < dragFrom ? index >= to ? 1 : 0 : index - 1 < to ? -1 : 0) * drag.startWidth;
9775
10124
  };
9776
10125
  const displayName = data.table?.name ?? tableId;
9777
- const rows = data.rows;
10126
+ const showName = blockId !== void 0;
10127
+ const pendingRow = data.pendingRow !== null && !data.rows.some((row) => row.rowId === data.pendingRow?.rowId) ? data.pendingRow : null;
10128
+ const pendingRowId = pendingRow?.rowId ?? null;
10129
+ const rows = pendingRow === null ? data.rows : [...data.rows, pendingRow];
9778
10130
  const { editingCell, setEditingCell, selectedCells, booleanPressRef, onCellPointerDown, onTableKeyDown, onTablePaste } = useGridCellInteraction({
9779
10131
  rows,
9780
10132
  columns,
@@ -9782,6 +10134,40 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9782
10134
  tableRef,
9783
10135
  readOnly
9784
10136
  });
10137
+ const pendingEditKey = pendingRowId !== null && columns[0] !== void 0 ? cellKeyOf(pendingRowId, columns[0].id) : null;
10138
+ useEffect(() => {
10139
+ if (pendingEditKey !== null) setEditingCell(pendingEditKey);
10140
+ }, [pendingEditKey, setEditingCell]);
10141
+ const dismissPending = useCallback(() => {
10142
+ if (pendingRowId === null) return;
10143
+ setEditingCell(null);
10144
+ if (pendingDismissTimerRef.current !== null) window.clearTimeout(pendingDismissTimerRef.current);
10145
+ pendingDismissTimerRef.current = window.setTimeout(() => {
10146
+ data.dismissPendingRow(pendingRowId);
10147
+ pendingDismissTimerRef.current = null;
10148
+ }, 0);
10149
+ }, [
10150
+ pendingRowId,
10151
+ data.dismissPendingRow,
10152
+ setEditingCell
10153
+ ]);
10154
+ useEffect(() => {
10155
+ if (pendingRowId === null) return;
10156
+ const onDown = (event) => {
10157
+ const target = event.target instanceof Element ? event.target : null;
10158
+ if (target === null) return;
10159
+ if (target.closest("[data-radix-popper-content-wrapper], [data-filter-pending='true']") !== null) return;
10160
+ dismissPending();
10161
+ };
10162
+ document.addEventListener("pointerdown", onDown, true);
10163
+ return () => {
10164
+ document.removeEventListener("pointerdown", onDown, true);
10165
+ if (pendingDismissTimerRef.current !== null) {
10166
+ window.clearTimeout(pendingDismissTimerRef.current);
10167
+ pendingDismissTimerRef.current = null;
10168
+ }
10169
+ };
10170
+ }, [pendingRowId, dismissPending]);
9785
10171
  if (data.phase === "loading") return /* @__PURE__ */ jsx(Card, {
9786
10172
  "data-slot": "docblocks/block",
9787
10173
  "data-block-type": "database",
@@ -9860,7 +10246,10 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9860
10246
  const columnMenuChange = (column) => (open) => setColumnMenu(open ? column.id : null);
9861
10247
  const columnRename = (column) => (renameName) => void data.renameColumn(column.id, renameName).catch(() => void 0);
9862
10248
  const columnEditOptions = (column) => column.refKind === "enum" && column.refTableId !== void 0 ? () => openColumnFormEdit(column) : void 0;
9863
- const columnHide = (column) => () => updateView({ hiddenColumns: [...hiddenColumns ?? [], column.id] });
10249
+ const columnHide = (column) => () => {
10250
+ if (columns.length <= 1) return;
10251
+ updateView({ hiddenColumns: [...hiddenColumns ?? [], column.id] });
10252
+ };
9864
10253
  const columnShow = (column) => () => updateView({ hiddenColumns: (hiddenColumns ?? []).filter((entryId) => entryId !== column.id) });
9865
10254
  const columnDelete = (column) => () => void data.deleteColumn(column.id).catch(() => void 0);
9866
10255
  const columnPointerDown = (column) => (event) => {
@@ -9880,6 +10269,14 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9880
10269
  setEditingCell(cellKey);
9881
10270
  };
9882
10271
  const cellEditEnd = () => setEditingCell(null);
10272
+ const onTableBlur = (event) => {
10273
+ if (pendingRowId === null) return;
10274
+ const next = event.relatedTarget;
10275
+ if (!(next instanceof Node)) return;
10276
+ if (tableRef.current?.contains(next)) return;
10277
+ if (next instanceof Element && next.closest("[data-radix-popper-content-wrapper]") !== null) return;
10278
+ dismissPending();
10279
+ };
9883
10280
  const rowMoveUp = (row) => () => {
9884
10281
  const index = rows.indexOf(row);
9885
10282
  if (index > 0) data.moveRow(row.rowId, rows[index - 1].rowId).catch(() => void 0);
@@ -9904,10 +10301,13 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9904
10301
  "data-slot": "docblocks/database-toolbar",
9905
10302
  className: "flex flex-wrap items-center gap-2",
9906
10303
  children: [
9907
- nameDraft !== null ? /* @__PURE__ */ jsx(Input, {
10304
+ showName && (nameDraft !== null ? /* @__PURE__ */ jsx(Input, {
9908
10305
  size: "sm",
9909
10306
  "data-slot": "docblocks/database-name-input",
9910
- className: cn(GRID_CHROME_FRAME, "h-auto min-w-32 px-1 py-0.5 text-(length:--docblocks-font-size) font-(--docblocks-heading-font-weight)"),
10307
+ className: cn(GRID_CHROME_FRAME, `
10308
+ h-auto min-w-32 px-1 py-0.5 text-(length:--docblocks-font-size)
10309
+ font-(--docblocks-heading-font-weight)
10310
+ `),
9911
10311
  value: nameDraft,
9912
10312
  autoFocus: true,
9913
10313
  onChange: onNameChange,
@@ -9925,81 +10325,88 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
9925
10325
  className: " h-auto cursor-text border-0 bg-transparent px-1 text-(length:--docblocks-font-size) font-(--docblocks-heading-font-weight) hover:bg-transparent hover:opacity-70 hover:text-inherit dark:bg-transparent dark:hover:bg-transparent",
9926
10326
  onClick: beginNameEdit,
9927
10327
  children: displayName
9928
- }),
10328
+ })),
9929
10329
  /* @__PURE__ */ jsxs(Badge, {
9930
10330
  "data-slot": "docblocks/database-count",
9931
10331
  variant: "secondary",
9932
10332
  children: [
9933
- rows.length,
10333
+ data.rows.length,
9934
10334
  " ",
9935
- t("rowCount", { count: rows.length })
10335
+ t("rowCount", { count: data.rows.length })
9936
10336
  ]
9937
10337
  }),
9938
10338
  /* @__PURE__ */ jsxs("div", {
9939
10339
  className: "ml-auto flex items-center gap-2",
9940
- children: [readOnly ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
9941
- "data-slot": "docblocks/database-undo",
9942
- variant: "outline",
9943
- size: "sm",
9944
- "data-disabled": data.canUndo ? void 0 : true,
9945
- className: cn(GRID_CHROME_FRAME, GRID_BUTTON_HOVER, GRID_HISTORY_BUTTON),
9946
- disabled: !data.canUndo,
9947
- onClick: undoStep,
9948
- children: t("toolbar.undo")
9949
- }), /* @__PURE__ */ jsx(Button, {
9950
- "data-slot": "docblocks/database-redo",
9951
- variant: "outline",
9952
- size: "sm",
9953
- "data-disabled": data.canRedo ? void 0 : true,
9954
- className: cn(GRID_CHROME_FRAME, GRID_BUTTON_HOVER, GRID_HISTORY_BUTTON),
9955
- disabled: !data.canRedo,
9956
- onClick: redoStep,
9957
- children: t("toolbar.redo")
9958
- })] }), readOnly ? null : /* @__PURE__ */ jsxs(Popover, {
9959
- open: filterOpen,
9960
- onOpenChange: onFilterOpenChange,
9961
- children: [/* @__PURE__ */ jsx(PopoverTrigger, {
9962
- asChild: true,
9963
- children: /* @__PURE__ */ jsxs(Button, {
9964
- "data-slot": "docblocks/database-filter",
9965
- variant: "outline",
9966
- size: "sm",
9967
- "data-active": filter !== void 0 && filter.conditions.length > 0 ? "true" : void 0,
9968
- className: cn(GRID_CHROME_FRAME, GRID_BUTTON_HOVER, "h-auto px-2 py-0.5 text-xs font-normal shadow-none"),
9969
- children: [t("toolbar.filter"), filter !== void 0 && filter.conditions.length > 0 ? " •" : ""]
9970
- })
9971
- }), /* @__PURE__ */ jsx(PopoverContent, {
9972
- align: "end",
9973
- className: "w-96",
9974
- children: /* @__PURE__ */ jsxs("div", {
9975
- className: "flex flex-col gap-(--docblocks-block-spacing)",
9976
- children: [/* @__PURE__ */ jsx(FilterBuilder, {
9977
- value: filterDraft,
9978
- columns: data.table.columns,
9979
- onChange: setFilterDraft,
9980
- refTableData
9981
- }), /* @__PURE__ */ jsxs("div", {
9982
- className: "flex items-center justify-between gap-2",
9983
- children: [/* @__PURE__ */ jsx(Button, {
9984
- "data-slot": "docblocks/filter-clear",
9985
- variant: "outline",
9986
- size: "sm",
9987
- className: "\n cursor-pointer bg-transparent px-2 py-1 text-xs font-normal shadow-none\n hover:bg-transparent hover:opacity-70\n dark:bg-transparent\n dark:hover:bg-transparent\n ",
9988
- onClick: resetFilterDraft,
9989
- children: t("common:clear")
9990
- }), /* @__PURE__ */ jsx(Button, {
9991
- "data-slot": "docblocks/filter-apply",
9992
- variant: "outline",
9993
- size: "sm",
9994
- disabled: !filterIsComplete(filterDraft, data.table.columns),
9995
- className: "\n cursor-pointer bg-accent px-2 py-1 text-xs font-normal\n hover:opacity-70\n disabled:cursor-default disabled:opacity-40\n ",
9996
- onClick: applyFilter,
9997
- children: t("toolbar.apply")
10340
+ children: [
10341
+ readOnly ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
10342
+ "data-slot": "docblocks/database-undo",
10343
+ variant: "outline",
10344
+ size: "sm",
10345
+ "data-disabled": data.canUndo ? void 0 : true,
10346
+ disabled: !data.canUndo,
10347
+ onClick: undoStep,
10348
+ children: t("toolbar.undo")
10349
+ }), /* @__PURE__ */ jsx(Button, {
10350
+ "data-slot": "docblocks/database-redo",
10351
+ variant: "outline",
10352
+ size: "sm",
10353
+ "data-disabled": data.canRedo ? void 0 : true,
10354
+ disabled: !data.canRedo,
10355
+ onClick: redoStep,
10356
+ children: t("toolbar.redo")
10357
+ })] }),
10358
+ readOnly ? null : /* @__PURE__ */ jsx(ColumnManager, {
10359
+ columns: data.table.columns,
10360
+ columnOrder,
10361
+ hiddenColumns,
10362
+ columnWidths,
10363
+ onViewChange: updateView
10364
+ }),
10365
+ readOnly ? null : /* @__PURE__ */ jsxs(Popover, {
10366
+ open: filterOpen,
10367
+ onOpenChange: onFilterOpenChange,
10368
+ children: [/* @__PURE__ */ jsx(PopoverTrigger, {
10369
+ asChild: true,
10370
+ children: /* @__PURE__ */ jsxs(Button, {
10371
+ "data-slot": "docblocks/database-filter",
10372
+ variant: "outline",
10373
+ size: "sm",
10374
+ "data-active": filter !== void 0 && filter.conditions.length > 0 ? "true" : void 0,
10375
+ children: [t("toolbar.filter"), filter !== void 0 && filter.conditions.length > 0 ? " •" : ""]
10376
+ })
10377
+ }), /* @__PURE__ */ jsx(PopoverContent, {
10378
+ align: "end",
10379
+ className: "w-fit max-w-xl min-w-110",
10380
+ children: /* @__PURE__ */ jsxs("div", {
10381
+ className: "flex flex-col gap-(--docblocks-block-spacing)",
10382
+ children: [/* @__PURE__ */ jsx(FilterBuilder, {
10383
+ value: filterDraft,
10384
+ columns: data.table.columns,
10385
+ onChange: setFilterDraft,
10386
+ refTableData
10387
+ }), /* @__PURE__ */ jsxs("div", {
10388
+ "data-slot": "docblocks/filter-footer",
10389
+ className: "flex items-center gap-2 border-t border-border pt-2",
10390
+ children: [/* @__PURE__ */ jsx(Button, {
10391
+ "data-slot": "docblocks/filter-clear",
10392
+ variant: "outline",
10393
+ size: "sm",
10394
+ onClick: resetFilterDraft,
10395
+ children: t("common:clear")
10396
+ }), /* @__PURE__ */ jsx(Button, {
10397
+ "data-slot": "docblocks/filter-apply",
10398
+ variant: "outline",
10399
+ size: "sm",
10400
+ disabled: !filterIsComplete(filterDraft, data.table.columns),
10401
+ className: "bg-accent text-accent-foreground",
10402
+ onClick: applyFilter,
10403
+ children: t("toolbar.apply")
10404
+ })]
9998
10405
  })]
9999
- })]
10000
- })
10001
- })]
10002
- })]
10406
+ })
10407
+ })]
10408
+ })
10409
+ ]
10003
10410
  })
10004
10411
  ]
10005
10412
  }),
@@ -10013,6 +10420,7 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
10013
10420
  className: "grid w-full outline-none select-none",
10014
10421
  onKeyDown: onTableKeyDown,
10015
10422
  onPaste: onTablePaste,
10423
+ onBlur: onTableBlur,
10016
10424
  style: {
10017
10425
  gridTemplateRows: "auto",
10018
10426
  gridAutoRows: "var(--docblocks-database-row-height)",
@@ -10211,6 +10619,7 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
10211
10619
  colIndex: index,
10212
10620
  first: index === 0,
10213
10621
  lastRow: row.rowId === lastRowId,
10622
+ filterPending: row.rowId === pendingRowId,
10214
10623
  dragDx: drag !== null && drag.id === column.id ? drag.dx : dragShiftOf(index),
10215
10624
  dragShifted: drag !== null && drag.id !== column.id,
10216
10625
  selected: selectedCells.has(key),
@@ -10228,6 +10637,7 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
10228
10637
  }, column.id);
10229
10638
  }), readOnly ? /* @__PURE__ */ jsx("div", {
10230
10639
  "data-slot": "docblocks/database-row-menu",
10640
+ "data-filter-pending": row.rowId === pendingRowId ? "true" : void 0,
10231
10641
  className: cn(`
10232
10642
  flex w-10 items-center justify-center border-l-(length:--docblocks-table-border-width)
10233
10643
  border-(--docblocks-table-border-color)
@@ -10236,12 +10646,13 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
10236
10646
  row,
10237
10647
  rowMenu,
10238
10648
  setRowMenu,
10239
- canMoveUp: rows.indexOf(row) > 0,
10240
- canMoveDown: rows.indexOf(row) < rows.length - 1,
10649
+ canMoveUp: row.rowId !== pendingRowId && rows.indexOf(row) > 0,
10650
+ canMoveDown: row.rowId !== pendingRowId && rows.indexOf(row) < rows.length - 1 && rows[rows.indexOf(row) + 1]?.rowId !== pendingRowId,
10241
10651
  onMoveUp: rowMoveUp(row),
10242
10652
  onMoveDown: rowMoveDown(row),
10243
10653
  onRemove: rowRemove(row),
10244
- lastRow: row.rowId === lastRowId
10654
+ lastRow: row.rowId === lastRowId,
10655
+ filterPending: row.rowId === pendingRowId
10245
10656
  })] }, row.rowId)),
10246
10657
  data.nextCursor !== null && /* @__PURE__ */ jsx("div", {
10247
10658
  "data-slot": "docblocks/database-load-more-row",
@@ -25220,7 +25631,7 @@ function HandleMenu({ kind, index, visible, left, top, open, onOpenChange, dragg
25220
25631
  style: {
25221
25632
  left: left + dragDx,
25222
25633
  top: top + dragDy,
25223
- ...dragTransition !== void 0 ? { transition: HANDLE_DRAG_TRANSITION } : {}
25634
+ ...dragTransition !== void 0 && !dragging ? { transition: HANDLE_DRAG_TRANSITION } : {}
25224
25635
  },
25225
25636
  onPointerDown,
25226
25637
  onPointerMove,
@@ -25467,7 +25878,7 @@ const TableCell = memo(function TableCell({ id, dragX, dragShifted, rowDy, rowSh
25467
25878
  const style = {
25468
25879
  ...background !== void 0 ? { background } : {},
25469
25880
  ...dragged && background === void 0 ? { background: "var(--docblocks-table-drag-background, transparent)" } : {},
25470
- ...dragged ? { boxShadow: "var(--docblocks-table-drag-shadow, none)" } : {},
25881
+ ...dragged ? { boxShadow: "var(--docblocks-table-drag-shadow, none), inset 0 0 0 var(--docblocks-table-border-width) var(--docblocks-table-border-color)" } : {},
25471
25882
  ...hasDrag ? {
25472
25883
  transform: `translate(${dragX}px, ${rowDy}px)`,
25473
25884
  position: "relative",