docblocks-react-ui 0.25.0 → 0.27.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.
@@ -453,6 +453,10 @@ const INIT_OPTIONS = {
453
453
  rowCount_few: "rows",
454
454
  rowCount_many: "rows",
455
455
  rowCount_other: "rows",
456
+ visibleRowCount_one: "{count} shown",
457
+ visibleRowCount_few: "{count} shown",
458
+ visibleRowCount_many: "{count} shown",
459
+ visibleRowCount_other: "{count} shown",
456
460
  toolbar: {
457
461
  "undo": "Undo",
458
462
  "redo": "Redo",
@@ -460,7 +464,10 @@ const INIT_OPTIONS = {
460
464
  "columns": "Columns",
461
465
  "apply": "Apply"
462
466
  },
467
+ rename: { "aria": "Rename {name}" },
468
+ renameTable: { "aria": "Rename table {name}" },
463
469
  columns: {
470
+ "empty": "No columns yet.",
464
471
  "move": "Move {name}",
465
472
  "visibility": "Show {name}"
466
473
  },
@@ -503,6 +510,7 @@ const INIT_OPTIONS = {
503
510
  "delete": "Delete column",
504
511
  "resizeHeight": "Resize the header row"
505
512
  },
513
+ resizeHeight: "Resize the database block",
506
514
  row: {
507
515
  "moveUp": "Move up",
508
516
  "moveDown": "Move down",
@@ -997,6 +1005,10 @@ const INIT_OPTIONS = {
997
1005
  rowCount_few: "строки",
998
1006
  rowCount_many: "строк",
999
1007
  rowCount_other: "строк",
1008
+ visibleRowCount_one: "Показана {count} строка",
1009
+ visibleRowCount_few: "Показано {count} строки",
1010
+ visibleRowCount_many: "Показано {count} строк",
1011
+ visibleRowCount_other: "Показано {count} строк",
1000
1012
  toolbar: {
1001
1013
  "undo": "Отменить",
1002
1014
  "redo": "Повторить",
@@ -1004,7 +1016,10 @@ const INIT_OPTIONS = {
1004
1016
  "columns": "Колонки",
1005
1017
  "apply": "Применить"
1006
1018
  },
1019
+ rename: { "aria": "Переименовать {name}" },
1020
+ renameTable: { "aria": "Переименовать таблицу {name}" },
1007
1021
  columns: {
1022
+ "empty": "Колонок пока нет.",
1008
1023
  "move": "Переместить {name}",
1009
1024
  "visibility": "Показать {name}"
1010
1025
  },
@@ -1047,6 +1062,7 @@ const INIT_OPTIONS = {
1047
1062
  "delete": "Удалить столбец",
1048
1063
  "resizeHeight": "Изменить высоту заголовка"
1049
1064
  },
1065
+ resizeHeight: "Изменить высоту блока базы данных",
1050
1066
  row: {
1051
1067
  "moveUp": "Переместить вверх",
1052
1068
  "moveDown": "Переместить вниз",
@@ -3072,6 +3088,23 @@ function Quote(props) {
3072
3088
  });
3073
3089
  }
3074
3090
  //#endregion
3091
+ //#region src/shared/ui/icons/Redo.tsx
3092
+ function Redo(props) {
3093
+ return /* @__PURE__ */ jsxs("svg", {
3094
+ xmlns: "http://www.w3.org/2000/svg",
3095
+ width: 24,
3096
+ height: 24,
3097
+ viewBox: "0 0 24 24",
3098
+ fill: "none",
3099
+ stroke: "currentColor",
3100
+ strokeWidth: 2,
3101
+ strokeLinecap: "round",
3102
+ strokeLinejoin: "round",
3103
+ ...props,
3104
+ children: [/* @__PURE__ */ jsx("path", { d: "M21 7v6h-6" }), /* @__PURE__ */ jsx("path", { d: "M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7" })]
3105
+ });
3106
+ }
3107
+ //#endregion
3075
3108
  //#region src/shared/ui/icons/RotateCcw.tsx
3076
3109
  function RotateCcw(props) {
3077
3110
  return /* @__PURE__ */ jsxs("svg", {
@@ -3588,6 +3621,23 @@ function Underline(props) {
3588
3621
  });
3589
3622
  }
3590
3623
  //#endregion
3624
+ //#region src/shared/ui/icons/Undo.tsx
3625
+ function Undo(props) {
3626
+ return /* @__PURE__ */ jsxs("svg", {
3627
+ xmlns: "http://www.w3.org/2000/svg",
3628
+ width: 24,
3629
+ height: 24,
3630
+ viewBox: "0 0 24 24",
3631
+ fill: "none",
3632
+ stroke: "currentColor",
3633
+ strokeWidth: 2,
3634
+ strokeLinecap: "round",
3635
+ strokeLinejoin: "round",
3636
+ ...props,
3637
+ children: [/* @__PURE__ */ jsx("path", { d: "M3 7v6h6" }), /* @__PURE__ */ jsx("path", { d: "M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13" })]
3638
+ });
3639
+ }
3640
+ //#endregion
3591
3641
  //#region src/shared/ui/icons/User.tsx
3592
3642
  function User(props) {
3593
3643
  return /* @__PURE__ */ jsxs("svg", {
@@ -5730,7 +5780,7 @@ function Input({ className, size, variant, type, ...props }) {
5730
5780
  * user's text is never clobbered mid-edit — the input wins until the
5731
5781
  * commit or the cancel).
5732
5782
  */
5733
- function InlineEditInput({ initial, ariaLabel, slot, className, placeholder, invalid, variant, selectOnMount, onCommit, onCancel }) {
5783
+ function InlineEditInput({ initial, ariaLabel, slot, className, placeholder, invalid, size, variant, selectOnMount, onCommit, onCancel }) {
5734
5784
  const inputRef = useRef(null);
5735
5785
  const committedRef = useRef(false);
5736
5786
  const [value, setValue] = useState(initial);
@@ -5776,6 +5826,7 @@ function InlineEditInput({ initial, ariaLabel, slot, className, placeholder, inv
5776
5826
  };
5777
5827
  const onInputBlur = (event) => commit(event.target.value);
5778
5828
  const onInputKeyDown = (event) => {
5829
+ event.stopPropagation();
5779
5830
  if (event.key === "Enter") {
5780
5831
  event.preventDefault();
5781
5832
  commit(event.currentTarget.value);
@@ -5789,6 +5840,7 @@ function InlineEditInput({ initial, ariaLabel, slot, className, placeholder, inv
5789
5840
  "data-slot": slot,
5790
5841
  "aria-label": ariaLabel,
5791
5842
  "aria-invalid": invalid ? true : void 0,
5843
+ size,
5792
5844
  variant,
5793
5845
  placeholder,
5794
5846
  value,
@@ -6280,6 +6332,17 @@ function reorderItems(items, fromIndex, toIndex) {
6280
6332
  next.splice(toIndex, 0, moved);
6281
6333
  return next;
6282
6334
  }
6335
+ /** The pointer's Y (the pointer / mouse's `clientY`; the touch's last
6336
+ * changed touch's `clientY`) — the drag's release's commit input (the
6337
+ * native event's coordinate over the drag's tracked position's stand). */
6338
+ function pointerYOf$1(event) {
6339
+ if ("changedTouches" in event) {
6340
+ const touches = event.changedTouches;
6341
+ const touch = touches[touches.length - 1];
6342
+ return touch === null || touch === void 0 ? null : touch.clientY;
6343
+ }
6344
+ return event.clientY;
6345
+ }
6283
6346
  /** A visible header drop mapped into the full order without moving hidden ids over an anchor. */
6284
6347
  function moveVisibleColumn(columns, columnOrder, hiddenColumns, columnId, toIndex) {
6285
6348
  const fullOrder = normalizeColumnOrder(columns, columnOrder);
@@ -6383,13 +6446,12 @@ function formatCellDateTime(value) {
6383
6446
  const time = format(value, "HH:mm");
6384
6447
  return value.getSeconds() !== 0 ? `${base}T${time}:${format(value, "ss")}` : `${base}T${time}`;
6385
6448
  }
6386
- /** The form draft over a catalog entry (the name prefills the type's
6387
- * label — the create's commit takes the input's name). */
6388
- function emptyColumnForm(entry) {
6449
+ /** The form draft over a catalog entry and its localized display name. */
6450
+ function emptyColumnForm(entry, name) {
6389
6451
  return {
6390
6452
  key: entry.key,
6391
6453
  type: entry.type,
6392
- name: entry.label,
6454
+ name,
6393
6455
  numberKind: entry.numberKind,
6394
6456
  decimals: entry.numberKind === "decimal" ? 2 : 0,
6395
6457
  thousands: false,
@@ -8111,6 +8173,28 @@ function useDatabaseTable(bridge, tableId, filter) {
8111
8173
  };
8112
8174
  }
8113
8175
  //#endregion
8176
+ //#region src/database/grid/DatabaseResizeHandle.tsx
8177
+ /** The database block's bottom-edge height handle. */
8178
+ function DatabaseResizeHandle({ height, minHeight, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, onKeyDown }) {
8179
+ const { t } = useTranslation("database");
8180
+ return /* @__PURE__ */ jsx("div", {
8181
+ "data-slot": "docblocks/database-resize",
8182
+ role: "slider",
8183
+ "aria-orientation": "vertical",
8184
+ "aria-valuemin": minHeight,
8185
+ "aria-valuenow": Math.round(height),
8186
+ "aria-label": t("resizeHeight"),
8187
+ tabIndex: 0,
8188
+ className: "\n absolute inset-x-0 bottom-0 z-10 flex h-2 cursor-row-resize items-end justify-center opacity-0\n transition-opacity outline-none\n group-hover:opacity-100\n focus-visible:opacity-100\n ",
8189
+ onPointerDown,
8190
+ onPointerMove,
8191
+ onPointerUp,
8192
+ onPointerCancel,
8193
+ onKeyDown,
8194
+ children: /* @__PURE__ */ jsx("div", { className: "mb-0.5 h-0.5 w-10 rounded-full bg-(--docblocks-divider-border-color)" })
8195
+ });
8196
+ }
8197
+ //#endregion
8114
8198
  //#region src/database/grid/EnumOptionsEditor.tsx
8115
8199
  /** The enum's options editor (the create / the edit's form stand): the
8116
8200
  * option's rows over the draft (the grip's press-drag stands the live
@@ -8254,59 +8338,50 @@ function EnumOptionsEditor({ options, onChange }) {
8254
8338
  }
8255
8339
  //#endregion
8256
8340
  //#region src/database/grid/constants.ts
8257
- /** The add-column type catalog (the `label` is the form's `name` prefill —
8258
- * the document data; the `labelKey` is the menu's i18n key, the
8259
- * `database` namespace's `columnTypes.*`). */
8341
+ /** The add-column type catalog; `labelKey` supplies the localized menu
8342
+ * label and the create form's name prefill. */
8260
8343
  const ADD_COLUMN_TYPES = [
8261
8344
  {
8262
8345
  key: "text",
8263
8346
  type: "text",
8264
- label: "Text",
8265
8347
  labelKey: "columnTypes.text"
8266
8348
  },
8267
8349
  {
8268
8350
  key: "integer",
8269
8351
  type: "integer",
8270
- label: "Integer",
8271
8352
  labelKey: "columnTypes.integer",
8272
8353
  numberKind: "integer"
8273
8354
  },
8274
8355
  {
8275
8356
  key: "decimal",
8276
8357
  type: "numeric",
8277
- label: "Decimal",
8278
8358
  labelKey: "columnTypes.decimal",
8279
8359
  numberKind: "decimal"
8280
8360
  },
8281
8361
  {
8282
8362
  key: "checkbox",
8283
8363
  type: "boolean",
8284
- label: "Checkbox",
8285
8364
  labelKey: "columnTypes.checkbox"
8286
8365
  },
8287
8366
  {
8288
8367
  key: "date",
8289
8368
  type: "date",
8290
- label: "Date",
8291
8369
  labelKey: "columnTypes.date"
8292
8370
  },
8293
8371
  {
8294
8372
  key: "datetime",
8295
8373
  type: "timestamptz",
8296
- label: "Date & time",
8297
8374
  labelKey: "columnTypes.datetime"
8298
8375
  },
8299
8376
  {
8300
8377
  key: "enum",
8301
8378
  type: "text",
8302
- label: "Enum",
8303
8379
  labelKey: "columnTypes.enum",
8304
8380
  refKind: "enum"
8305
8381
  },
8306
8382
  {
8307
8383
  key: "multi-enum",
8308
8384
  type: "text",
8309
- label: "Multi-enum",
8310
8385
  labelKey: "columnTypes.multiEnum",
8311
8386
  refKind: "enum",
8312
8387
  refMany: true
@@ -8314,19 +8389,18 @@ const ADD_COLUMN_TYPES = [
8314
8389
  {
8315
8390
  key: "row-link",
8316
8391
  type: "text",
8317
- label: "Row link",
8318
8392
  labelKey: "columnTypes.rowLink",
8319
8393
  refKind: "row"
8320
8394
  },
8321
8395
  {
8322
8396
  key: "row-links",
8323
8397
  type: "text",
8324
- label: "Row links",
8325
8398
  labelKey: "columnTypes.rowLinks",
8326
8399
  refKind: "row",
8327
8400
  refMany: true
8328
8401
  }
8329
8402
  ];
8403
+ const DATABASE_HEADER_WRAP_ATTR = "data-header-wrap";
8330
8404
  /** The shared cell wrapper classes (the left border + the padding). */
8331
8405
  const CELL_WRAP = "flex min-h-6 min-w-0 items-center overflow-hidden border-(--docblocks-table-border-color) p-(--docblocks-table-cell-padding)";
8332
8406
  /** The input's shared classes over the `Input` primitive's sm base: no
@@ -8339,68 +8413,6 @@ const GRID_DRAG_TRANSITION = "transform 120ms ease-out";
8339
8413
  const GRID_CHROME_FRAME = "rounded-(--docblocks-radius) border-(length:--docblocks-table-border-width) border-(--docblocks-table-border-color) bg-transparent dark:border-(--docblocks-table-border-color) dark:bg-transparent";
8340
8414
  const GRID_BUTTON_HOVER = "cursor-pointer hover:opacity-70 hover:bg-transparent hover:text-inherit dark:hover:bg-transparent";
8341
8415
  //#endregion
8342
- //#region src/database/grid/GridStateCards.tsx
8343
- /**
8344
- * The grid's non-ready state's surfaces: the loading's stand (the
8345
- * placeholder's text) and the broken's stand (the table's death / the
8346
- * fatal read's error surface + the reload's entry). The frames stand the
8347
- * block's data attributes (the inspector's / the e2e's locators).
8348
- */
8349
- function GridStateCard({ blockId, children, className }) {
8350
- return /* @__PURE__ */ jsx(Card, {
8351
- "data-slot": "docblocks/block",
8352
- "data-block-type": "database",
8353
- "data-block-id": blockId,
8354
- className: cn("min-h-0 flex-1", className),
8355
- children
8356
- });
8357
- }
8358
- function GridLoadingCard({ blockId }) {
8359
- const { t } = useTranslation("database");
8360
- return /* @__PURE__ */ jsx(GridStateCard, {
8361
- blockId,
8362
- children: /* @__PURE__ */ jsx(CardContent, {
8363
- "data-slot": "docblocks/database",
8364
- "data-state": "loading",
8365
- className: "p-(--docblocks-block-spacing)",
8366
- children: /* @__PURE__ */ jsx("span", {
8367
- className: "text-(length:--docblocks-font-size) text-(--docblocks-placeholder-color)",
8368
- children: t("state.loading")
8369
- })
8370
- })
8371
- });
8372
- }
8373
- function GridBrokenCard({ blockId, tableId, error, onRetry }) {
8374
- const { t } = useTranslation("database");
8375
- return /* @__PURE__ */ jsx(GridStateCard, {
8376
- blockId,
8377
- className: "\n my-(--docblocks-block-spacing) rounded-(--docblocks-radius) border-(length:--docblocks-table-border-width)\n border-(--docblocks-table-border-color) outline-none\n ",
8378
- children: /* @__PURE__ */ jsxs(CardContent, {
8379
- "data-slot": "docblocks/database",
8380
- "data-state": "broken",
8381
- className: "flex items-center justify-between gap-(--docblocks-block-spacing) p-(--docblocks-block-spacing)",
8382
- children: [/* @__PURE__ */ jsxs("div", {
8383
- className: "flex flex-col",
8384
- children: [/* @__PURE__ */ jsx("span", {
8385
- "data-slot": "docblocks/database-broken",
8386
- className: "text-(length:--docblocks-font-size) font-(--docblocks-heading-font-weight)",
8387
- children: t("state.notFound")
8388
- }), /* @__PURE__ */ jsx("span", {
8389
- className: "text-(length:--docblocks-font-size) text-(--docblocks-placeholder-color)",
8390
- children: error ?? t("state.unknownTable", { tableId })
8391
- })]
8392
- }), /* @__PURE__ */ jsx(Button, {
8393
- "data-slot": "docblocks/database-retry",
8394
- variant: "outline",
8395
- size: "sm",
8396
- className: cn(GRID_CHROME_FRAME, GRID_BUTTON_HOVER, "h-auto px-2 py-1 text-(length:--docblocks-font-size) font-normal shadow-none"),
8397
- onClick: onRetry,
8398
- children: t("state.retry")
8399
- })]
8400
- })
8401
- });
8402
- }
8403
- //#endregion
8404
8416
  //#region src/database/grid/AddColumnForm.tsx
8405
8417
  /**
8406
8418
  * The add-column's create form (the popover over the add-column track's
@@ -8558,63 +8570,149 @@ function columnTypeIcon(type, refKind, refMany) {
8558
8570
  return Type;
8559
8571
  }
8560
8572
  //#endregion
8561
- //#region src/database/grid/AddColumnCell.tsx
8562
- /** The grid's header-row "add column" cell: the plus chip (the type's menu)
8563
- * and the create form over it. The cell carries its own explicit grid
8564
- * placement (the header row's track after the last column) — the header's
8565
- * resize strip occupies the same row across all tracks. The read-only
8566
- * modes render the empty track (the primitive's stand: no chip, no form). */
8567
- function AddColumnCell({ gridColumn, readOnly, form, OptionsEditor }) {
8573
+ //#region src/database/grid/AddColumnControl.tsx
8574
+ /** The add-column type menu and its create/edit form. */
8575
+ function AddColumnControl({ form, OptionsEditor, className, withLabel = false }) {
8576
+ const { t } = useTranslation("database");
8577
+ const openEntry = (entry) => () => form.openCreateForm(entry);
8578
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(DropdownMenu, {
8579
+ modal: false,
8580
+ open: form.addingColumn,
8581
+ onOpenChange: form.setAddingColumn,
8582
+ children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
8583
+ asChild: true,
8584
+ children: /* @__PURE__ */ jsxs(Button, {
8585
+ "data-slot": "docblocks/database-add-column-trigger",
8586
+ variant: withLabel ? "outline" : "ghost",
8587
+ size: withLabel ? "sm" : "icon",
8588
+ "aria-label": t("form.addColumn"),
8589
+ className,
8590
+ children: [/* @__PURE__ */ jsx(Plus, { className: "size-4" }), withLabel ? t("form.addColumn") : null]
8591
+ })
8592
+ }), /* @__PURE__ */ jsx(DropdownMenuContent, {
8593
+ align: "end",
8594
+ className: "min-w-32",
8595
+ children: ADD_COLUMN_TYPES.map((entry) => {
8596
+ const EntryIcon = columnTypeIcon(entry.type, entry.refKind, entry.refMany);
8597
+ return /* @__PURE__ */ jsxs(DropdownMenuItem, {
8598
+ "data-column-entry": entry.key,
8599
+ onClick: openEntry(entry),
8600
+ children: [/* @__PURE__ */ jsx(EntryIcon, { className: "size-4 shrink-0 text-muted-foreground" }), t(entry.labelKey)]
8601
+ }, entry.key);
8602
+ })
8603
+ })]
8604
+ }), /* @__PURE__ */ jsx(AddColumnForm, {
8605
+ open: form.columnFormOpen,
8606
+ onOpenChange: form.onColumnFormOpenChange,
8607
+ form: form.columnForm,
8608
+ formNumber: form.columnFormNumber,
8609
+ formRef: form.columnFormRef,
8610
+ error: form.columnFormError,
8611
+ bridgeTables: form.bridgeTables,
8612
+ OptionsEditor,
8613
+ onCommit: form.commitColumnForm,
8614
+ onNameChange: form.onColumnNameChange,
8615
+ onDecimalsChange: form.onColumnDecimalsChange,
8616
+ onThousandsChange: form.onColumnThousandsChange,
8617
+ onPrefixChange: form.onColumnPrefixChange,
8618
+ onSuffixChange: form.onColumnSuffixChange,
8619
+ onAllowNegativeChange: form.onColumnAllowNegativeChange,
8620
+ onEnumOptionsChange: form.onColumnEnumOptionsChange,
8621
+ onRefPickChange: form.onColumnRefPickChange,
8622
+ onNewTableNameChange: form.onColumnNewTableNameChange
8623
+ })] });
8624
+ }
8625
+ //#endregion
8626
+ //#region src/database/grid/GridEmptyState.tsx
8627
+ /** The schema-less grid's empty state and its first-column entry. */
8628
+ function GridEmptyState({ form, OptionsEditor, readOnly }) {
8568
8629
  const { t } = useTranslation("database");
8569
8630
  return /* @__PURE__ */ jsxs("div", {
8631
+ "data-slot": "docblocks/database-empty",
8632
+ className: `relative flex min-h-28 flex-1 flex-col items-center justify-center gap-2 text-sm text-muted-foreground ${GRID_CHROME_FRAME}`,
8633
+ children: [/* @__PURE__ */ jsx("span", { children: t("columns.empty") }), !readOnly && /* @__PURE__ */ jsx(AddColumnControl, {
8634
+ form,
8635
+ OptionsEditor,
8636
+ withLabel: true,
8637
+ className: "cursor-pointer"
8638
+ })]
8639
+ });
8640
+ }
8641
+ //#endregion
8642
+ //#region src/database/grid/GridStateCards.tsx
8643
+ /**
8644
+ * The grid's non-ready state's surfaces: the loading's stand (the
8645
+ * placeholder's text) and the broken's stand (the table's death / the
8646
+ * fatal read's error surface + the reload's entry). The frames stand the
8647
+ * block's data attributes (the inspector's / the e2e's locators).
8648
+ */
8649
+ function GridStateCard({ blockId, children, className }) {
8650
+ return /* @__PURE__ */ jsx(Card, {
8651
+ "data-slot": "docblocks/block",
8652
+ "data-block-type": "database",
8653
+ "data-block-id": blockId,
8654
+ className: cn("min-h-0 flex-1", className),
8655
+ children
8656
+ });
8657
+ }
8658
+ function GridLoadingCard({ blockId }) {
8659
+ const { t } = useTranslation("database");
8660
+ return /* @__PURE__ */ jsx(GridStateCard, {
8661
+ blockId,
8662
+ children: /* @__PURE__ */ jsx(CardContent, {
8663
+ "data-slot": "docblocks/database",
8664
+ "data-state": "loading",
8665
+ className: "p-(--docblocks-block-spacing)",
8666
+ children: /* @__PURE__ */ jsx("span", {
8667
+ className: "text-(length:--docblocks-font-size) text-(--docblocks-placeholder-color)",
8668
+ children: t("state.loading")
8669
+ })
8670
+ })
8671
+ });
8672
+ }
8673
+ function GridBrokenCard({ blockId, tableId, error, onRetry }) {
8674
+ const { t } = useTranslation("database");
8675
+ return /* @__PURE__ */ jsx(GridStateCard, {
8676
+ blockId,
8677
+ className: "\n my-(--docblocks-block-spacing) rounded-(--docblocks-radius) border-(length:--docblocks-table-border-width)\n border-(--docblocks-table-border-color) outline-none\n ",
8678
+ children: /* @__PURE__ */ jsxs(CardContent, {
8679
+ "data-slot": "docblocks/database",
8680
+ "data-state": "broken",
8681
+ className: "flex items-center justify-between gap-(--docblocks-block-spacing) p-(--docblocks-block-spacing)",
8682
+ children: [/* @__PURE__ */ jsxs("div", {
8683
+ className: "flex flex-col",
8684
+ children: [/* @__PURE__ */ jsx("span", {
8685
+ "data-slot": "docblocks/database-broken",
8686
+ className: "text-(length:--docblocks-font-size) font-(--docblocks-heading-font-weight)",
8687
+ children: t("state.notFound")
8688
+ }), /* @__PURE__ */ jsx("span", {
8689
+ className: "text-(length:--docblocks-font-size) text-(--docblocks-placeholder-color)",
8690
+ children: error ?? t("state.unknownTable", { tableId })
8691
+ })]
8692
+ }), /* @__PURE__ */ jsx(Button, {
8693
+ "data-slot": "docblocks/database-retry",
8694
+ variant: "outline",
8695
+ size: "sm",
8696
+ className: cn(GRID_CHROME_FRAME, GRID_BUTTON_HOVER, "h-auto px-2 py-1 text-(length:--docblocks-font-size) font-normal shadow-none"),
8697
+ onClick: onRetry,
8698
+ children: t("state.retry")
8699
+ })]
8700
+ })
8701
+ });
8702
+ }
8703
+ //#endregion
8704
+ //#region src/database/grid/AddColumnCell.tsx
8705
+ /** The header-row cell hosting the add-column control and its form. */
8706
+ function AddColumnCell({ gridColumn, readOnly, form, OptionsEditor }) {
8707
+ return /* @__PURE__ */ jsx("div", {
8570
8708
  "data-slot": "docblocks/database-add-column",
8571
- className: "\n relative row-start-1 flex items-center justify-center border-b-(length:--docblocks-table-border-width)\n border-(--docblocks-table-border-color)\n ",
8709
+ className: "\n relative row-start-1 flex items-center justify-center rounded-tr-(--docblocks-radius)\n border-b-(length:--docblocks-table-border-width) border-(--docblocks-table-border-color)\n ",
8572
8710
  style: { gridColumn },
8573
- children: [!readOnly && /* @__PURE__ */ jsxs(DropdownMenu, {
8574
- modal: false,
8575
- open: form.addingColumn,
8576
- onOpenChange: form.setAddingColumn,
8577
- children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
8578
- asChild: true,
8579
- children: /* @__PURE__ */ jsx(Button, {
8580
- "data-slot": "docblocks/database-add-column-trigger",
8581
- variant: "ghost",
8582
- size: "icon",
8583
- className: cn("rounded-(--docblocks-radius) border-(length:--docblocks-table-border-width) border-(--docblocks-table-border-color) bg-transparent dark:border-(--docblocks-table-border-color) dark:bg-transparent", "size-6 cursor-pointer p-1 text-(--docblocks-placeholder-color) hover:bg-transparent", "hover:text-(--docblocks-text-color) dark:hover:bg-transparent"),
8584
- children: /* @__PURE__ */ jsx(Plus, { className: "size-4" })
8585
- })
8586
- }), /* @__PURE__ */ jsx(DropdownMenuContent, {
8587
- align: "end",
8588
- className: "min-w-32",
8589
- children: ADD_COLUMN_TYPES.map((entry) => {
8590
- const EntryIcon = columnTypeIcon(entry.type, entry.refKind, entry.refMany);
8591
- return /* @__PURE__ */ jsxs(DropdownMenuItem, {
8592
- "data-column-entry": entry.key,
8593
- onClick: () => form.openCreateForm(entry),
8594
- children: [/* @__PURE__ */ jsx(EntryIcon, { className: "size-4 shrink-0 text-muted-foreground" }), t(entry.labelKey)]
8595
- }, entry.key);
8596
- })
8597
- })]
8598
- }), /* @__PURE__ */ jsx(AddColumnForm, {
8599
- open: form.columnFormOpen,
8600
- onOpenChange: form.onColumnFormOpenChange,
8601
- form: form.columnForm,
8602
- formNumber: form.columnFormNumber,
8603
- formRef: form.columnFormRef,
8604
- error: form.columnFormError,
8605
- bridgeTables: form.bridgeTables,
8711
+ children: !readOnly && /* @__PURE__ */ jsx(AddColumnControl, {
8712
+ form,
8606
8713
  OptionsEditor,
8607
- onCommit: form.commitColumnForm,
8608
- onNameChange: form.onColumnNameChange,
8609
- onDecimalsChange: form.onColumnDecimalsChange,
8610
- onThousandsChange: form.onColumnThousandsChange,
8611
- onPrefixChange: form.onColumnPrefixChange,
8612
- onSuffixChange: form.onColumnSuffixChange,
8613
- onAllowNegativeChange: form.onColumnAllowNegativeChange,
8614
- onEnumOptionsChange: form.onColumnEnumOptionsChange,
8615
- onRefPickChange: form.onColumnRefPickChange,
8616
- onNewTableNameChange: form.onColumnNewTableNameChange
8617
- })]
8714
+ className: cn("rounded-(--docblocks-radius) border-(length:--docblocks-table-border-width) border-(--docblocks-table-border-color) bg-transparent dark:border-(--docblocks-table-border-color) dark:bg-transparent", "size-6 cursor-pointer p-1 text-(--docblocks-placeholder-color) hover:bg-transparent", "hover:text-(--docblocks-text-color) dark:hover:bg-transparent")
8715
+ })
8618
8716
  });
8619
8717
  }
8620
8718
  //#endregion
@@ -9558,7 +9656,7 @@ function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, firs
9558
9656
  "data-empty": empty ? "true" : void 0,
9559
9657
  "data-selected": selected ? "true" : void 0,
9560
9658
  "data-editing": editing ? "true" : void 0,
9561
- className: cn(CELL_WRAP, !first && "border-l-(length:--docblocks-table-border-width)", !lastRow && "border-b-(length:--docblocks-table-border-width)", selected && (singleSelected ? "bg-(--docblocks-selected-background) outline-(length:--docblocks-canvas-selection-border-width) outline-offset-[-1px] outline-(--docblocks-canvas-selection-border-color) outline-solid" : "bg-(--docblocks-canvas-selection-fill)")),
9659
+ className: cn(CELL_WRAP, !first && "border-l-(length:--docblocks-table-border-width)", !lastRow && "border-b-(length:--docblocks-table-border-width)", first && lastRow && "rounded-bl-(--docblocks-radius)", selected && (singleSelected ? "bg-(--docblocks-selected-background) outline-(length:--docblocks-canvas-selection-border-width) outline-offset-[-1px] outline-(--docblocks-canvas-selection-border-color) outline-solid" : "bg-(--docblocks-canvas-selection-fill)")),
9562
9660
  style: dragStyle,
9563
9661
  onPointerDown,
9564
9662
  onClick: onCellClick,
@@ -9593,7 +9691,7 @@ function RowMenuCell({ row, rowMenu, setRowMenu, canMoveUp, canMoveDown, onMoveU
9593
9691
  className: cn(`
9594
9692
  flex w-10 items-center justify-center border-l-(length:--docblocks-table-border-width)
9595
9693
  border-(--docblocks-table-border-color)
9596
- `, !lastRow && "border-b-(length:--docblocks-table-border-width)"),
9694
+ `, !lastRow && "border-b-(length:--docblocks-table-border-width)", lastRow && "rounded-br-(--docblocks-radius)"),
9597
9695
  children: /* @__PURE__ */ jsxs(DropdownMenu, {
9598
9696
  modal: false,
9599
9697
  open: rowMenu === row.rowId,
@@ -9698,7 +9796,7 @@ function GridRows({ rows, columns, data, selectedCells, editingCell, setEditingC
9698
9796
  className: cn(`
9699
9797
  flex w-10 items-center justify-center border-l-(length:--docblocks-table-border-width)
9700
9798
  border-(--docblocks-table-border-color)
9701
- `, row.rowId !== lastRowId && "border-b-(length:--docblocks-table-border-width)")
9799
+ `, row.rowId !== lastRowId && "border-b-(length:--docblocks-table-border-width)", row.rowId === lastRowId && "rounded-br-(--docblocks-radius)")
9702
9800
  }) : /* @__PURE__ */ jsx(RowMenuCell, {
9703
9801
  row,
9704
9802
  rowMenu,
@@ -9739,11 +9837,16 @@ function GridRows({ rows, columns, data, selectedCells, editingCell, setEditingC
9739
9837
  * drag, the Ellipsis's press stands the menu). The right-edge seam resizes
9740
9838
  * the column (the table block's seam idiom: the 6 px strip, the 50 px
9741
9839
  * floor, the live preview, the one `updateBlock` on the release). The menu
9742
- * content: the editable name line (the rename commits on the blur / the
9743
- * Enter), the type line (read-only), and the show / hide / delete items. */
9744
- function HeaderCell({ readOnly = false, column, colIndex, first, resizing, dragDx, dragShifted, menuOpen, onMenuChange, onRename, onEditOptions, onHide, onShow, onDelete, hidden, onPointerDown, onPointerMove, onPointerUp, onResizePointerDown, onResizePointerMove, onResizePointerUp, onResizePointerCancel }) {
9840
+ * content: the rename's line (the `InlineEditInput`'s contract — the
9841
+ * mount's focus + the select-all over the rename's replace, the reseed
9842
+ * over an open edit (a pristine field stands the live column's name — a
9843
+ * peer's rename, the own commit's settle — a typed draft stands until the
9844
+ * next open), the commit over the Enter / the blur (one write — the
9845
+ * committed-once's guard), the Escape's cancel without a write; the
9846
+ * empty / the unchanged's trimmed stand the no-write), the type line
9847
+ * (read-only), and the show / hide / delete items. */
9848
+ function HeaderCell({ readOnly = false, onDoubleClickReset, column, colIndex, first, resizing, dragDx, dragShifted, menuOpen, onMenuChange, onRename, onEditOptions, onHide, onShow, onDelete, hidden, onPointerDown, onPointerMove, onPointerUp, onResizePointerDown, onResizePointerMove, onResizePointerUp, onResizePointerCancel }) {
9745
9849
  const { t } = useTranslation("database");
9746
- const [nameDraft, setNameDraft] = useState(column.name);
9747
9850
  const ColumnIcon = columnTypeIcon(column.type, column.refKind, column.refMany);
9748
9851
  const dragStyle = dragDx !== 0 ? {
9749
9852
  transform: `translateX(${dragDx}px)`,
@@ -9751,19 +9854,13 @@ function HeaderCell({ readOnly = false, column, colIndex, first, resizing, dragD
9751
9854
  zIndex: dragShifted ? void 0 : 10,
9752
9855
  transition: dragShifted ? GRID_DRAG_TRANSITION : void 0
9753
9856
  } : null;
9754
- const commitRename = () => {
9755
- const trimmed = nameDraft.trim();
9756
- if (trimmed !== "" && trimmed !== column.name) onRename(trimmed);
9757
- setNameDraft(column.name);
9857
+ const commitRename = (value) => {
9858
+ const trimmed = value.trim();
9859
+ if (trimmed === "" || trimmed === column.name) return;
9860
+ onRename(trimmed);
9758
9861
  };
9759
- const onNameChange = (event) => setNameDraft(event.target.value);
9760
- const focusName = () => setNameDraft(column.name);
9761
- const onNameKeyDown = (event) => {
9762
- if (event.key === "Enter") event.target.blur();
9763
- if (event.key === "Escape") {
9764
- setNameDraft(column.name);
9765
- onMenuChange(false);
9766
- }
9862
+ const stopDoubleClick = (event) => {
9863
+ event.stopPropagation();
9767
9864
  };
9768
9865
  const onEditOptionsPress = () => {
9769
9866
  if (onEditOptions === void 0) return;
@@ -9785,18 +9882,24 @@ function HeaderCell({ readOnly = false, column, colIndex, first, resizing, dragD
9785
9882
  className: cn(`
9786
9883
  relative flex min-w-0 items-center gap-1 border-b-(length:--docblocks-table-border-width)
9787
9884
  border-(--docblocks-table-border-color) bg-muted/40 px-2 py-1 select-none
9788
- `, !readOnly && "cursor-grab active:cursor-grabbing", !first && "border-l-(length:--docblocks-table-border-width)"),
9885
+ `, !readOnly && "cursor-grab active:cursor-grabbing", first && "rounded-tl-(--docblocks-radius)", !first && "border-l-(length:--docblocks-table-border-width)"),
9789
9886
  onPointerDown: readOnly ? void 0 : onPointerDown,
9790
9887
  onPointerMove: readOnly ? void 0 : onPointerMove,
9791
9888
  onPointerUp: readOnly ? void 0 : onPointerUp,
9889
+ onDoubleClick: onDoubleClickReset,
9792
9890
  children: [
9793
9891
  /* @__PURE__ */ jsx(ColumnIcon, { className: "size-4 shrink-0 text-muted-foreground" }),
9794
9892
  /* @__PURE__ */ jsx("span", {
9795
- className: "\n min-w-0 flex-1 truncate px-1 text-(length:--docblocks-font-size) font-(--docblocks-heading-font-weight)\n ",
9893
+ "data-slot": "docblocks/database-header-name",
9894
+ className: `
9895
+ max-h-full min-w-0 flex-1 overflow-hidden px-1 text-(length:--docblocks-font-size)
9896
+ font-(--docblocks-heading-font-weight)
9897
+ `,
9796
9898
  children: column.name
9797
9899
  }),
9798
9900
  !readOnly && /* @__PURE__ */ jsx("div", {
9799
9901
  className: "ml-auto flex shrink-0 items-center",
9902
+ onDoubleClick: stopDoubleClick,
9800
9903
  children: /* @__PURE__ */ jsxs(DropdownMenu, {
9801
9904
  modal: false,
9802
9905
  open: menuOpen,
@@ -9817,15 +9920,15 @@ function HeaderCell({ readOnly = false, column, colIndex, first, resizing, dragD
9817
9920
  children: [
9818
9921
  /* @__PURE__ */ jsxs("div", {
9819
9922
  className: "flex flex-col gap-1",
9820
- children: [/* @__PURE__ */ jsx(Input, {
9923
+ children: [/* @__PURE__ */ jsx(InlineEditInput, {
9821
9924
  size: "sm",
9822
- "data-slot": "docblocks/database-rename-input",
9925
+ initial: column.name,
9926
+ selectOnMount: true,
9927
+ ariaLabel: t("rename.aria", { name: column.name }),
9928
+ slot: "docblocks/database-rename-input",
9823
9929
  className: "border-0 bg-muted/60 px-2 py-1 text-foreground select-text focus:bg-muted",
9824
- value: nameDraft,
9825
- onChange: onNameChange,
9826
- onFocus: focusName,
9827
- onBlur: commitRename,
9828
- onKeyDown: onNameKeyDown
9930
+ onCommit: commitRename,
9931
+ onCancel: () => onMenuChange(false)
9829
9932
  }), /* @__PURE__ */ jsxs("span", {
9830
9933
  "data-slot": "docblocks/database-column-type",
9831
9934
  className: "flex items-center gap-1 px-1.5 text-xs text-muted-foreground",
@@ -9854,6 +9957,7 @@ function HeaderCell({ readOnly = false, column, colIndex, first, resizing, dragD
9854
9957
  !readOnly && /* @__PURE__ */ jsx("div", {
9855
9958
  "data-slot": "docblocks/database-col-resize",
9856
9959
  "data-index": colIndex,
9960
+ onDoubleClick: stopDoubleClick,
9857
9961
  className: cn(`
9858
9962
  absolute top-0 -right-0.75 z-10 h-full w-1.5 cursor-col-resize opacity-0 transition-opacity
9859
9963
  hover:opacity-100
@@ -9879,8 +9983,10 @@ function HeaderCell({ readOnly = false, column, colIndex, first, resizing, dragD
9879
9983
  * the read-only modes render no handle (the height itself still
9880
9984
  * applies). */
9881
9985
  /** The header's bottom edge: the 6 px strip straddles the border (the
9882
- * seam idiom — the pointer over the edge stands the stable row-resize). */
9883
- function HeaderResizeHandle({ resizing, onPointerDown, onPointerMove, onPointerUp, onPointerCancel }) {
9986
+ * seam idiom — the pointer over the edge stands the stable row-resize).
9987
+ * The double click over the strip stands the height's reset (the default
9988
+ * height's return — the press's no-op's parity over the drag's release). */
9989
+ function HeaderResizeHandle({ resizing, onDoubleClickReset, onPointerDown, onPointerMove, onPointerUp, onPointerCancel }) {
9884
9990
  const { t } = useTranslation("database");
9885
9991
  return /* @__PURE__ */ jsx("div", {
9886
9992
  role: "separator",
@@ -9896,6 +10002,7 @@ function HeaderResizeHandle({ resizing, onPointerDown, onPointerMove, onPointerU
9896
10002
  onPointerMove,
9897
10003
  onPointerUp,
9898
10004
  onPointerCancel,
10005
+ onDoubleClick: onDoubleClickReset,
9899
10006
  children: /* @__PURE__ */ jsx("div", {
9900
10007
  "data-slot": "docblocks/database-header-resize-line",
9901
10008
  className: "h-0.5 w-full rounded bg-(--muted-foreground)"
@@ -10014,10 +10121,13 @@ function clampDatabaseHeaderHeight(requested, natural) {
10014
10121
  function measureDatabaseHeaderHeight(grid) {
10015
10122
  if (grid === null) return 0;
10016
10123
  const previous = grid.style.gridTemplateRows;
10124
+ const wrapped = grid.hasAttribute(DATABASE_HEADER_WRAP_ATTR);
10125
+ grid.removeAttribute(DATABASE_HEADER_WRAP_ATTR);
10017
10126
  grid.style.gridTemplateRows = "auto";
10018
10127
  let natural = 0;
10019
10128
  for (const cell of grid.querySelectorAll("[data-slot=\"docblocks/database-header-cell\"]")) natural = Math.max(natural, cell.offsetHeight);
10020
10129
  grid.style.gridTemplateRows = previous;
10130
+ if (wrapped) grid.setAttribute(DATABASE_HEADER_WRAP_ATTR, "true");
10021
10131
  return natural;
10022
10132
  }
10023
10133
  //#endregion
@@ -10172,6 +10282,35 @@ function useGridSeamResize({ columns, columnWidths, updateView }) {
10172
10282
  };
10173
10283
  }
10174
10284
  //#endregion
10285
+ //#region src/database/grid/use-single-line-header-height.ts
10286
+ /** The grid's header row's single-line (auto) height, tracked live over
10287
+ * the laid-out grid. The stand is the stretch's decision's threshold (the
10288
+ * names' wrap over the height's stand) and the drag's clamp's floor's
10289
+ * source (the one-line fallback over the unmeasured's stand). The read
10290
+ * stands the single-line's stand over the current's wrap (the
10291
+ * measurement's suppression's parity), so the value is the auto height
10292
+ * regardless of the stretch. A detached / unlaid-out grid (no layout in
10293
+ * the runtime) stands 0. */
10294
+ /** The grid's header row's single-line (auto) height in px (the live
10295
+ * stand over the column's widths / the theme's font's changes). */
10296
+ function useSingleLineHeaderHeight(tableRef) {
10297
+ const [height, setHeight] = useState(0);
10298
+ useLayoutEffect(() => {
10299
+ const grid = tableRef.current;
10300
+ if (grid === null) return;
10301
+ const measure = () => {
10302
+ const next = measureDatabaseHeaderHeight(grid);
10303
+ setHeight((current) => current === next ? current : next);
10304
+ };
10305
+ measure();
10306
+ if (typeof ResizeObserver === "undefined") return;
10307
+ const observer = new ResizeObserver(measure);
10308
+ observer.observe(grid);
10309
+ return () => observer.disconnect();
10310
+ }, [tableRef]);
10311
+ return height;
10312
+ }
10313
+ //#endregion
10175
10314
  //#region src/database/grid/GridTable.tsx
10176
10315
  /**
10177
10316
  * The grid's table: the column tracks (the header cells — the menu / the
@@ -10181,7 +10320,7 @@ function useGridSeamResize({ columns, columnWidths, updateView }) {
10181
10320
  * model (the cell / column selection — the native text selection over the
10182
10321
  * drag is suppressed).
10183
10322
  */
10184
- function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidths, onViewChange, data, rows, selectedCells, editingCell, setEditingCell, onCellPointerDown, booleanPressRef, pendingRowId, refTableData, filter, readOnly = false, headerHeight, onHeaderHeightChange, tableRef, onTableKeyDown, onTablePaste, onTableBlur, form, OptionsEditor }) {
10323
+ function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidths, onViewChange, data, rows, selectedCells, editingCell, setEditingCell, onCellPointerDown, booleanPressRef, pendingRowId, refTableData, filter, readOnly = false, headerHeight, onHeaderHeightChange, onHeaderHeightReset, tableRef, onTableKeyDown, onTablePaste, onTableBlur, form, OptionsEditor }) {
10185
10324
  const [columnMenu, setColumnMenu] = useState(null);
10186
10325
  const { resizePreview, onSeamPointerDown, onSeamPointerMove, onSeamPointerUp, onSeamPointerCancel } = useGridSeamResize({
10187
10326
  columns,
@@ -10203,6 +10342,11 @@ function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidt
10203
10342
  onCommit: onHeaderHeightChange ?? (() => void 0)
10204
10343
  });
10205
10344
  const headerRowHeight = headerPreview ?? headerHeight;
10345
+ const naturalHeaderHeight = useSingleLineHeaderHeight(tableRef);
10346
+ const headerWrap = headerRowHeight !== void 0 && headerRowHeight > naturalHeaderHeight;
10347
+ const resetHeaderHeight = () => {
10348
+ onHeaderHeightReset?.();
10349
+ };
10206
10350
  const dragFrom = drag === null ? -1 : columns.findIndex((entry) => entry.id === drag.id);
10207
10351
  const dragShiftOf = (index) => {
10208
10352
  if (drag === null || drag.toIndex === null || index === dragFrom) return 0;
@@ -10230,8 +10374,9 @@ function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidt
10230
10374
  return /* @__PURE__ */ jsxs("div", {
10231
10375
  ref: tableRef,
10232
10376
  "data-slot": "docblocks/database-table",
10377
+ "data-header-wrap": headerWrap ? "true" : void 0,
10233
10378
  tabIndex: 0,
10234
- className: "grid w-full outline-none select-none",
10379
+ className: cn(GRID_CHROME_FRAME, "grid w-full overflow-hidden outline-none select-none"),
10235
10380
  onKeyDown: onTableKeyDown,
10236
10381
  onPaste: onTablePaste,
10237
10382
  onBlur: onTableBlur,
@@ -10253,6 +10398,7 @@ function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidt
10253
10398
  dragDx: drag !== null && drag.id === column.id ? drag.dx : dragShiftOf(index),
10254
10399
  dragShifted: drag !== null && drag.id !== column.id,
10255
10400
  menuOpen: columnMenu === column.id,
10401
+ onDoubleClickReset: !readOnly && onHeaderHeightReset !== void 0 ? resetHeaderHeight : void 0,
10256
10402
  onMenuChange: readOnly ? () => void 0 : columnMenuChange(column),
10257
10403
  onRename: columnRename(column),
10258
10404
  onEditOptions: columnEditOptions(column),
@@ -10270,6 +10416,7 @@ function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidt
10270
10416
  }, column.id)),
10271
10417
  !readOnly && onHeaderHeightChange !== void 0 && /* @__PURE__ */ jsx(HeaderResizeHandle, {
10272
10418
  resizing: headerPreview !== null,
10419
+ onDoubleClickReset: !readOnly && onHeaderHeightReset !== void 0 ? resetHeaderHeight : void 0,
10273
10420
  onPointerDown: onHeaderPointerDown,
10274
10421
  onPointerMove: onHeaderPointerMove,
10275
10422
  onPointerUp: onHeaderPointerUp,
@@ -10302,7 +10449,7 @@ function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidt
10302
10449
  }
10303
10450
  //#endregion
10304
10451
  //#region src/database/grid/ColumnManager.tsx
10305
- function ColumnRow({ column, hidden, hideDisabled, onToggle, onMove, onDragStart, onDragEnd }) {
10452
+ function ColumnRow({ column, hidden, hideDisabled, onToggle, onMove, onDragEnd }) {
10306
10453
  const { t } = useTranslation("database");
10307
10454
  const dragControls = useDragControls();
10308
10455
  const onGripPointerDown = (event) => {
@@ -10316,13 +10463,12 @@ function ColumnRow({ column, hidden, hideDisabled, onToggle, onMove, onDragStart
10316
10463
  onMove(column.id, event.key === "ArrowUp" ? -1 : 1);
10317
10464
  };
10318
10465
  const onVisibilityChange = () => onToggle(column.id);
10319
- const onReorderEnd = () => onDragEnd(column.id);
10466
+ const onReorderEnd = (event) => onDragEnd(column.id, event);
10320
10467
  return /* @__PURE__ */ jsxs(Reorder.Item, {
10321
10468
  as: "div",
10322
10469
  value: column.id,
10323
10470
  dragListener: false,
10324
10471
  dragControls,
10325
- onDragStart,
10326
10472
  onDragEnd: onReorderEnd,
10327
10473
  className: "flex items-center gap-1 rounded-sm px-1 py-0.5 text-sm",
10328
10474
  children: [
@@ -10357,7 +10503,7 @@ function ColumnManager({ columns, columnOrder, hiddenColumns, columnWidths, trig
10357
10503
  const { t } = useTranslation("database");
10358
10504
  const [open, setOpen] = useState(false);
10359
10505
  const [draftOrder, setDraftOrder] = useState(null);
10360
- const dragStartOrderRef = useRef(null);
10506
+ const groupRef = useRef(null);
10361
10507
  const normalizedOrder = normalizeColumnOrder(columns, columnOrder);
10362
10508
  const order = draftOrder ?? normalizedOrder;
10363
10509
  const hidden = new Set(hiddenColumns ?? []);
@@ -10379,13 +10525,46 @@ function ColumnManager({ columns, columnOrder, hiddenColumns, columnWidths, trig
10379
10525
  });
10380
10526
  setDraftOrder(nextOrder);
10381
10527
  };
10382
- const onDragStart = () => {
10383
- dragStartOrderRef.current = order;
10528
+ const commitAtPointer = (columnId, clientY) => {
10529
+ const group = groupRef.current;
10530
+ if (group === null) return;
10531
+ const rows = Array.from(group.children).filter((row) => row instanceof HTMLElement);
10532
+ const displayed = rows.map((row) => row.querySelector("[data-slot='docblocks/database-column-move']")?.getAttribute("data-column-id")).filter((id) => id !== null);
10533
+ if (displayed.length === 0 || displayed.includes(columnId) === false) return;
10534
+ const previousOrder = normalizedOrder;
10535
+ const others = displayed.filter((id) => id !== columnId);
10536
+ let insertAt = 0;
10537
+ for (const row of rows) {
10538
+ const id = row.querySelector("[data-slot='docblocks/database-column-move']")?.getAttribute("data-column-id");
10539
+ if (id === null || id === columnId) continue;
10540
+ const rect = row.getBoundingClientRect();
10541
+ if (clientY > rect.top + rect.height / 2) insertAt += 1;
10542
+ }
10543
+ const newVisible = [
10544
+ ...others.slice(0, insertAt),
10545
+ columnId,
10546
+ ...others.slice(insertAt)
10547
+ ];
10548
+ const visibleIds = new Set(newVisible);
10549
+ const visibleSlots = normalizedOrder.map((id, index) => visibleIds.has(id) ? index : -1).filter((index) => index >= 0);
10550
+ const nextOrder = [...normalizedOrder];
10551
+ newVisible.forEach((id, slot) => {
10552
+ const target = visibleSlots[slot];
10553
+ if (target !== void 0) nextOrder[target] = id;
10554
+ });
10555
+ if (nextOrder.every((id, index) => id === previousOrder[index])) {
10556
+ setDraftOrder(null);
10557
+ return;
10558
+ }
10559
+ commitOrder(columnId, nextOrder, previousOrder);
10384
10560
  };
10385
- const onDragEnd = (columnId) => {
10386
- const previousOrder = dragStartOrderRef.current ?? order;
10387
- dragStartOrderRef.current = null;
10388
- if (draftOrder !== null) commitOrder(columnId, draftOrder, previousOrder);
10561
+ const onDragEnd = (columnId, event) => {
10562
+ const pointerY = pointerYOf$1(event);
10563
+ if (pointerY === null) {
10564
+ setDraftOrder(null);
10565
+ return;
10566
+ }
10567
+ commitAtPointer(columnId, pointerY);
10389
10568
  };
10390
10569
  const onMove = (columnId, delta) => {
10391
10570
  const fromIndex = order.indexOf(columnId);
@@ -10408,6 +10587,8 @@ function ColumnManager({ columns, columnOrder, hiddenColumns, columnWidths, trig
10408
10587
  variant: "outline",
10409
10588
  size: "sm",
10410
10589
  "data-active": hiddenCount > 0 ? "true" : void 0,
10590
+ "data-disabled": columns.length === 0 ? true : void 0,
10591
+ disabled: columns.length === 0,
10411
10592
  className: triggerClassName,
10412
10593
  children: [t("toolbar.columns"), hiddenCount > 0 ? " •" : ""]
10413
10594
  })
@@ -10418,6 +10599,7 @@ function ColumnManager({ columns, columnOrder, hiddenColumns, columnWidths, trig
10418
10599
  className: "w-72 p-2",
10419
10600
  children: /* @__PURE__ */ jsx(Reorder.Group, {
10420
10601
  as: "div",
10602
+ ref: groupRef,
10421
10603
  axis: "y",
10422
10604
  values: order,
10423
10605
  onReorder: setDraftOrder,
@@ -10431,7 +10613,6 @@ function ColumnManager({ columns, columnOrder, hiddenColumns, columnWidths, trig
10431
10613
  hideDisabled: !hidden.has(column.id) && visibleCount === 1,
10432
10614
  onToggle,
10433
10615
  onMove,
10434
- onDragStart,
10435
10616
  onDragEnd
10436
10617
  }, column.id);
10437
10618
  })
@@ -10440,6 +10621,54 @@ function ColumnManager({ columns, columnOrder, hiddenColumns, columnWidths, trig
10440
10621
  });
10441
10622
  }
10442
10623
  //#endregion
10624
+ //#region src/database/grid/GridHistoryButtons.tsx
10625
+ /** The bridge history's icon controls. */
10626
+ function GridHistoryButtons({ canUndo, canRedo, onUndo, onRedo }) {
10627
+ const { t } = useTranslation("database");
10628
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
10629
+ "data-slot": "docblocks/database-undo",
10630
+ variant: "outline",
10631
+ size: "icon",
10632
+ className: "size-8",
10633
+ "data-disabled": canUndo ? void 0 : true,
10634
+ disabled: !canUndo,
10635
+ title: t("toolbar.undo"),
10636
+ "aria-label": t("toolbar.undo"),
10637
+ onClick: onUndo,
10638
+ children: /* @__PURE__ */ jsx(Undo, {})
10639
+ }), /* @__PURE__ */ jsx(Button, {
10640
+ "data-slot": "docblocks/database-redo",
10641
+ variant: "outline",
10642
+ size: "icon",
10643
+ className: "size-8",
10644
+ "data-disabled": canRedo ? void 0 : true,
10645
+ disabled: !canRedo,
10646
+ title: t("toolbar.redo"),
10647
+ "aria-label": t("toolbar.redo"),
10648
+ onClick: onRedo,
10649
+ children: /* @__PURE__ */ jsx(Redo, {})
10650
+ })] });
10651
+ }
10652
+ //#endregion
10653
+ //#region src/database/grid/GridRowCount.tsx
10654
+ /** The consumer's total row count and the loaded filtered-window count. */
10655
+ function GridRowCount({ total, visible, filtered }) {
10656
+ const { t } = useTranslation("database");
10657
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Badge, {
10658
+ "data-slot": "docblocks/database-count",
10659
+ variant: "secondary",
10660
+ children: [
10661
+ total,
10662
+ " ",
10663
+ t("rowCount", { count: total })
10664
+ ]
10665
+ }), filtered && /* @__PURE__ */ jsx(Badge, {
10666
+ "data-slot": "docblocks/database-visible-count",
10667
+ variant: "outline",
10668
+ children: t("visibleRowCount", { count: visible })
10669
+ })] });
10670
+ }
10671
+ //#endregion
10443
10672
  //#region src/database/grid/GridToolbar.tsx
10444
10673
  /**
10445
10674
  * The grid's toolbar: the table's display name (the bridge's table name —
@@ -10450,25 +10679,20 @@ function ColumnManager({ columns, columnOrder, hiddenColumns, columnWidths, trig
10450
10679
  * column manager, and the filter popover (the draft stands the apply's
10451
10680
  * press — the close stands no write).
10452
10681
  */
10453
- function GridToolbar({ tableId, table, data, filter, columnOrder, hiddenColumns, columnWidths, onViewChange, refTableData, showName, readOnly = false }) {
10682
+ function GridToolbar({ tableId, table, data, totalRows, filter, columnOrder, hiddenColumns, columnWidths, onViewChange, refTableData, showName, readOnly = false }) {
10454
10683
  const { t } = useTranslation("database");
10455
- const [nameDraft, setNameDraft] = useState(null);
10684
+ const [nameEditing, setNameEditing] = useState(false);
10456
10685
  const [filterOpen, setFilterOpen] = useState(false);
10457
10686
  const [filterDraft, setFilterDraft] = useState(filter ?? null);
10458
10687
  const displayName = data.table?.name ?? tableId;
10688
+ const resolvedRowCount = totalRows ?? data.rows.length;
10689
+ const hasActiveFilter = filter !== void 0 && filter.conditions.length > 0;
10459
10690
  const commitName = (draft) => {
10460
- setNameDraft(null);
10691
+ setNameEditing(false);
10461
10692
  const trimmed = draft.trim();
10462
10693
  if (trimmed === "" || trimmed === data.table?.name) return;
10463
10694
  data.renameTable(trimmed).catch(() => void 0);
10464
10695
  };
10465
- const onNameChange = (event) => setNameDraft(event.target.value);
10466
- const onNameBlur = (event) => commitName(event.target.value);
10467
- const onNameKeyDown = (event) => {
10468
- if (event.key === "Enter") event.target.blur();
10469
- if (event.key === "Escape") setNameDraft(null);
10470
- };
10471
- const beginNameEdit = () => setNameDraft(displayName);
10472
10696
  const undoStep = () => void data.undo().catch(() => void 0);
10473
10697
  const redoStep = () => void data.redo().catch(() => void 0);
10474
10698
  const applyFilter = () => {
@@ -10480,19 +10704,20 @@ function GridToolbar({ tableId, table, data, filter, columnOrder, hiddenColumns,
10480
10704
  if (open) setFilterDraft(filter ?? null);
10481
10705
  };
10482
10706
  const resetFilterDraft = () => setFilterDraft(emptyFilter());
10707
+ const insertEmptyRow = () => void data.insertRow({}).catch(() => void 0);
10483
10708
  return /* @__PURE__ */ jsxs("div", {
10484
10709
  "data-slot": "docblocks/database-toolbar",
10485
10710
  className: "flex flex-wrap items-center gap-2",
10486
10711
  children: [
10487
- showName && (nameDraft !== null ? /* @__PURE__ */ jsx(Input, {
10712
+ showName && (nameEditing ? /* @__PURE__ */ jsx(InlineEditInput, {
10488
10713
  size: "sm",
10489
- "data-slot": "docblocks/database-name-input",
10714
+ initial: displayName,
10715
+ selectOnMount: true,
10716
+ ariaLabel: t("renameTable.aria", { name: displayName }),
10717
+ slot: "docblocks/database-name-input",
10490
10718
  className: cn("rounded-(--docblocks-radius) border-(length:--docblocks-table-border-width) border-(--docblocks-table-border-color) bg-transparent dark:border-(--docblocks-table-border-color) dark:bg-transparent", `h-auto min-w-32 px-1 py-0.5 text-(length:--docblocks-font-size) font-(--docblocks-heading-font-weight)`),
10491
- value: nameDraft,
10492
- autoFocus: true,
10493
- onChange: onNameChange,
10494
- onBlur: onNameBlur,
10495
- onKeyDown: onNameKeyDown
10719
+ onCommit: commitName,
10720
+ onCancel: () => setNameEditing(false)
10496
10721
  }) : readOnly ? /* @__PURE__ */ jsx("span", {
10497
10722
  "data-slot": "docblocks/database-name",
10498
10723
  className: "font-(--docblocks-heading-font-weight)",
@@ -10503,38 +10728,31 @@ function GridToolbar({ tableId, table, data, filter, columnOrder, hiddenColumns,
10503
10728
  size: "sm",
10504
10729
  title: t("common:rename"),
10505
10730
  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",
10506
- onClick: beginNameEdit,
10731
+ onClick: () => setNameEditing(true),
10507
10732
  children: displayName
10508
10733
  })),
10509
- /* @__PURE__ */ jsxs(Badge, {
10510
- "data-slot": "docblocks/database-count",
10511
- variant: "secondary",
10512
- children: [
10513
- data.rows.length,
10514
- " ",
10515
- t("rowCount", { count: data.rows.length })
10516
- ]
10734
+ /* @__PURE__ */ jsx(GridRowCount, {
10735
+ total: resolvedRowCount,
10736
+ visible: data.rows.length,
10737
+ filtered: hasActiveFilter
10738
+ }),
10739
+ !readOnly && /* @__PURE__ */ jsx(Button, {
10740
+ "data-slot": "docblocks/database-add-row",
10741
+ variant: "outline",
10742
+ size: "sm",
10743
+ className: "bg-accent text-accent-foreground select-none",
10744
+ onClick: insertEmptyRow,
10745
+ children: t("rows.add")
10517
10746
  }),
10518
10747
  /* @__PURE__ */ jsxs("div", {
10519
10748
  className: "ml-auto flex items-center gap-2",
10520
10749
  children: [
10521
- readOnly ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
10522
- "data-slot": "docblocks/database-undo",
10523
- variant: "outline",
10524
- size: "sm",
10525
- "data-disabled": data.canUndo ? void 0 : true,
10526
- disabled: !data.canUndo,
10527
- onClick: undoStep,
10528
- children: t("toolbar.undo")
10529
- }), /* @__PURE__ */ jsx(Button, {
10530
- "data-slot": "docblocks/database-redo",
10531
- variant: "outline",
10532
- size: "sm",
10533
- "data-disabled": data.canRedo ? void 0 : true,
10534
- disabled: !data.canRedo,
10535
- onClick: redoStep,
10536
- children: t("toolbar.redo")
10537
- })] }),
10750
+ readOnly ? null : /* @__PURE__ */ jsx(GridHistoryButtons, {
10751
+ canUndo: data.canUndo,
10752
+ canRedo: data.canRedo,
10753
+ onUndo: undoStep,
10754
+ onRedo: redoStep
10755
+ }),
10538
10756
  readOnly ? null : /* @__PURE__ */ jsx(ColumnManager, {
10539
10757
  columns: table.columns,
10540
10758
  columnOrder,
@@ -10551,8 +10769,10 @@ function GridToolbar({ tableId, table, data, filter, columnOrder, hiddenColumns,
10551
10769
  "data-slot": "docblocks/database-filter",
10552
10770
  variant: "outline",
10553
10771
  size: "sm",
10554
- "data-active": filter !== void 0 && filter.conditions.length > 0 ? "true" : void 0,
10555
- children: [t("toolbar.filter"), filter !== void 0 && filter.conditions.length > 0 ? " •" : ""]
10772
+ "data-active": hasActiveFilter ? "true" : void 0,
10773
+ "data-disabled": resolvedRowCount === 0 ? true : void 0,
10774
+ disabled: resolvedRowCount === 0,
10775
+ children: [t("toolbar.filter"), hasActiveFilter ? " •" : ""]
10556
10776
  })
10557
10777
  }), /* @__PURE__ */ jsx(PopoverContent, {
10558
10778
  align: "end",
@@ -10829,6 +11049,7 @@ function useBridgeTables(bridge, refreshKey) {
10829
11049
  * commit).
10830
11050
  */
10831
11051
  function useColumnForm({ bridge, tableId, data, refTableData, readColumnOrder, onViewChange }) {
11052
+ const { t } = useTranslation("database");
10832
11053
  const [addingColumn, setAddingColumn] = useState(false);
10833
11054
  const [columnFormOpen, setColumnFormOpen] = useState(false);
10834
11055
  const [columnForm, setColumnForm] = useState(null);
@@ -10875,7 +11096,7 @@ function useColumnForm({ bridge, tableId, data, refTableData, readColumnOrder, o
10875
11096
  * the create form (the name input + the type-specific block over it) —
10876
11097
  * the create commits on the form's button only. */
10877
11098
  const openCreateForm = (entry) => {
10878
- setColumnForm(emptyColumnForm(entry));
11099
+ setColumnForm(emptyColumnForm(entry, t(entry.labelKey)));
10879
11100
  setAddingColumn(false);
10880
11101
  setColumnFormError(null);
10881
11102
  setColumnFormOpen(true);
@@ -10968,6 +11189,140 @@ function useColumnForm({ bridge, tableId, data, refTableData, readColumnOrder, o
10968
11189
  };
10969
11190
  }
10970
11191
  //#endregion
11192
+ //#region src/database/grid/block-height.ts
11193
+ /** The document database block's measured auto height and resize floor. */
11194
+ function cssPixels(value) {
11195
+ const parsed = Number.parseFloat(value);
11196
+ return Number.isFinite(parsed) ? parsed : 0;
11197
+ }
11198
+ function positivePixels(value, fallback) {
11199
+ const parsed = cssPixels(value);
11200
+ return parsed > 0 ? parsed : fallback;
11201
+ }
11202
+ /** Measures the fixed chrome around the scrolling grid, so the block's
11203
+ * explicit height leaves the toolbar visible and the floor stays usable. */
11204
+ function measureDatabaseBlockMetrics(card, table, scroller, headerHeight) {
11205
+ const header = headerHeight ?? Math.max(measureDatabaseHeaderHeight(table), 28);
11206
+ const rowHeight = positivePixels(card === null ? "" : getComputedStyle(card).getPropertyValue("--docblocks-database-row-height"), 32);
11207
+ let chrome = 0;
11208
+ if (card !== null) {
11209
+ const cardStyle = getComputedStyle(card);
11210
+ chrome += cssPixels(cardStyle.borderTopWidth) + cssPixels(cardStyle.borderBottomWidth);
11211
+ const content = card.querySelector(":scope > [data-slot='docblocks/database']");
11212
+ const toolbar = card.querySelector("[data-slot='docblocks/database-toolbar']");
11213
+ chrome += toolbar?.offsetHeight ?? 0;
11214
+ if (content !== null) {
11215
+ const style = getComputedStyle(content);
11216
+ chrome += cssPixels(style.paddingTop) + cssPixels(style.paddingBottom) + cssPixels(style.rowGap);
11217
+ }
11218
+ if (table !== null) {
11219
+ const style = getComputedStyle(table);
11220
+ chrome += cssPixels(style.borderTopWidth) + cssPixels(style.borderBottomWidth);
11221
+ }
11222
+ if (scroller !== null) chrome += Math.max(0, scroller.offsetHeight - scroller.clientHeight);
11223
+ }
11224
+ return {
11225
+ auto: Math.round(chrome + header + 10 * rowHeight),
11226
+ min: Math.round(chrome + header + 3 * rowHeight)
11227
+ };
11228
+ }
11229
+ //#endregion
11230
+ //#region src/database/grid/use-database-block-height.ts
11231
+ /** The document database block's bottom-edge resize session. */
11232
+ const INITIAL_METRICS = {
11233
+ auto: 348,
11234
+ min: 124
11235
+ };
11236
+ function useDatabaseBlockHeight({ enabled, ready, height, headerHeight, cardRef, tableRef, scrollerRef, onCommit }) {
11237
+ const [metrics, setMetrics] = useState(INITIAL_METRICS);
11238
+ const [preview, setPreview] = useState(null);
11239
+ const session = useRef(null);
11240
+ useLayoutEffect(() => {
11241
+ if (!enabled || !ready) return;
11242
+ const measure = () => {
11243
+ const next = measureDatabaseBlockMetrics(cardRef.current, tableRef.current, scrollerRef.current, headerHeight);
11244
+ setMetrics((current) => current.auto === next.auto && current.min === next.min ? current : next);
11245
+ };
11246
+ measure();
11247
+ if (typeof ResizeObserver === "undefined") return;
11248
+ const observer = new ResizeObserver(measure);
11249
+ const toolbar = cardRef.current?.querySelector("[data-slot='docblocks/database-toolbar']");
11250
+ if (toolbar !== null && toolbar !== void 0) observer.observe(toolbar);
11251
+ if (tableRef.current !== null) observer.observe(tableRef.current);
11252
+ return () => observer.disconnect();
11253
+ }, [
11254
+ cardRef,
11255
+ enabled,
11256
+ headerHeight,
11257
+ ready,
11258
+ scrollerRef,
11259
+ tableRef
11260
+ ]);
11261
+ const currentHeight = preview ?? height;
11262
+ const style = enabled ? {
11263
+ height: currentHeight,
11264
+ maxHeight: currentHeight === void 0 ? metrics.auto : void 0
11265
+ } : void 0;
11266
+ const onPointerDown = (event) => {
11267
+ if (!enabled || event.button !== 0 || session.current !== null) return;
11268
+ const card = cardRef.current;
11269
+ if (card === null) return;
11270
+ event.preventDefault();
11271
+ event.stopPropagation();
11272
+ event.currentTarget.setPointerCapture?.(event.pointerId);
11273
+ const nextMetrics = measureDatabaseBlockMetrics(card, tableRef.current, scrollerRef.current, headerHeight);
11274
+ setMetrics(nextMetrics);
11275
+ const measured = card.getBoundingClientRect().height;
11276
+ const startHeight = height ?? (measured > 0 ? measured : nextMetrics.auto);
11277
+ session.current = {
11278
+ pointerId: event.pointerId,
11279
+ startY: event.clientY,
11280
+ startHeight,
11281
+ min: nextMetrics.min,
11282
+ height: startHeight
11283
+ };
11284
+ setPreview(startHeight);
11285
+ };
11286
+ const onPointerMove = (event) => {
11287
+ const live = session.current;
11288
+ if (live === null || live.pointerId !== event.pointerId) return;
11289
+ live.height = Math.max(live.min, live.startHeight + event.clientY - live.startY);
11290
+ setPreview(live.height);
11291
+ };
11292
+ const onPointerUp = (event) => {
11293
+ const live = session.current;
11294
+ if (live === null || live.pointerId !== event.pointerId) return;
11295
+ event.currentTarget.releasePointerCapture?.(event.pointerId);
11296
+ session.current = null;
11297
+ setPreview(null);
11298
+ const committed = Math.round(live.height);
11299
+ if (committed !== Math.round(live.startHeight) && committed !== height) onCommit?.(committed);
11300
+ };
11301
+ const onPointerCancel = () => {
11302
+ session.current = null;
11303
+ setPreview(null);
11304
+ };
11305
+ const onKeyDown = (event) => {
11306
+ if (!enabled) return;
11307
+ const delta = event.key === "ArrowDown" ? 16 : event.key === "ArrowUp" ? -16 : null;
11308
+ if (delta === null) return;
11309
+ event.preventDefault();
11310
+ const current = Math.round(currentHeight ?? metrics.auto);
11311
+ const next = Math.max(metrics.min, current + delta);
11312
+ if (next !== current) onCommit?.(next);
11313
+ };
11314
+ return {
11315
+ style,
11316
+ currentHeight: currentHeight ?? metrics.auto,
11317
+ minHeight: metrics.min,
11318
+ onPointerDown,
11319
+ onPointerMove,
11320
+ onPointerUp,
11321
+ onPointerCancel,
11322
+ onKeyDown
11323
+ };
11324
+ }
11325
+ //#endregion
10971
11326
  //#region src/database/grid/use-enum-options-motion.ts
10972
11327
  /** The enum's options editor's motion's slot: the framer-wired editor
10973
11328
  * (the Reorder's rows) provides the motion's variant here; the renderer
@@ -11351,10 +11706,12 @@ function useGridPendingRow({ pendingRow, data, columns, tableRef, setEditingCell
11351
11706
  * toolbar over `GridToolbar`, the table over `GridTable` (+ `GridRows`),
11352
11707
  * the pending row's lifecycle over `use-grid-pending-row`, the state's
11353
11708
  * surfaces over `GridStateCards`. */
11354
- function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns, columnWidths, headerHeight, sectionHeaderHeight, onHeaderHeightChange, onViewChange, readColumnOrder, readOnly = false }) {
11355
- const { t } = useTranslation("database");
11709
+ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns, columnWidths, height, headerHeight, sectionHeaderHeight, getRowCount, onHeightChange, onHeaderHeightChange, onHeaderHeightReset, onViewChange, readColumnOrder, readOnly = false }) {
11356
11710
  const data = useDatabaseTable(bridge, tableId, filter);
11711
+ const sectionRowCount = getRowCount?.(tableId);
11357
11712
  const tableRef = useRef(null);
11713
+ const cardRef = useRef(null);
11714
+ const scrollerRef = useRef(null);
11358
11715
  const refTableData = useRefTables(bridge, useMemo(() => {
11359
11716
  const map = /* @__PURE__ */ new Map();
11360
11717
  for (const column of data.table?.columns ?? []) {
@@ -11378,6 +11735,16 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
11378
11735
  });
11379
11736
  const columns = visibleColumns(data.table?.columns, columnOrder, hiddenColumns);
11380
11737
  const resolvedHeaderHeight = resolveDatabaseHeaderHeight(headerHeight, sectionHeaderHeight);
11738
+ const blockHeight = useDatabaseBlockHeight({
11739
+ enabled: blockId !== void 0 && onHeightChange !== void 0,
11740
+ ready: data.phase === "ready",
11741
+ height,
11742
+ headerHeight: resolvedHeaderHeight,
11743
+ cardRef,
11744
+ tableRef,
11745
+ scrollerRef,
11746
+ onCommit: onHeightChange
11747
+ });
11381
11748
  const updateView = (patch) => {
11382
11749
  onViewChange(patch);
11383
11750
  };
@@ -11404,75 +11771,77 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
11404
11771
  error: data.error,
11405
11772
  onRetry: () => data.retry()
11406
11773
  });
11407
- const insertEmptyRow = () => void data.insertRow({}).catch(() => void 0);
11408
- return /* @__PURE__ */ jsx(Card, {
11774
+ return /* @__PURE__ */ jsxs(Card, {
11775
+ ref: cardRef,
11409
11776
  "data-slot": "docblocks/block",
11410
11777
  "data-block-type": "database",
11411
11778
  "data-block-id": blockId,
11412
11779
  "data-state": "ready",
11413
11780
  contentEditable: false,
11414
- className: "\n my-(--docblocks-block-spacing) flex min-h-0 flex-1 flex-col rounded-(--docblocks-radius)\n border-(length:--docblocks-table-border-width) border-(--docblocks-table-border-color) outline-none\n ",
11415
- children: /* @__PURE__ */ jsxs(CardContent, {
11781
+ style: blockHeight.style,
11782
+ className: "\n group relative my-(--docblocks-block-spacing) flex min-h-0 flex-1 flex-col rounded-(--docblocks-radius)\n border-(length:--docblocks-table-border-width) border-(--docblocks-table-border-color) outline-none\n ",
11783
+ children: [/* @__PURE__ */ jsxs(CardContent, {
11416
11784
  "data-slot": "docblocks/database",
11417
11785
  className: "flex min-h-0 flex-1 flex-col gap-(--docblocks-block-spacing) p-(--docblocks-block-spacing)",
11418
- children: [
11419
- /* @__PURE__ */ jsx(GridToolbar, {
11420
- tableId,
11421
- table: data.table,
11422
- data,
11423
- filter,
11786
+ children: [/* @__PURE__ */ jsx(GridToolbar, {
11787
+ tableId,
11788
+ table: data.table,
11789
+ data,
11790
+ totalRows: sectionRowCount,
11791
+ filter,
11792
+ columnOrder,
11793
+ hiddenColumns,
11794
+ columnWidths,
11795
+ onViewChange: updateView,
11796
+ refTableData,
11797
+ showName: blockId !== void 0,
11798
+ readOnly
11799
+ }), data.table.columns.length === 0 ? /* @__PURE__ */ jsx(GridEmptyState, {
11800
+ form,
11801
+ OptionsEditor,
11802
+ readOnly
11803
+ }) : /* @__PURE__ */ jsx(ScrollArea, {
11804
+ ref: scrollerRef,
11805
+ "data-slot": "docblocks/database-grid",
11806
+ className: "min-h-0 flex-1",
11807
+ children: /* @__PURE__ */ jsx(GridTable, {
11808
+ columns,
11809
+ allColumns: data.table.columns,
11424
11810
  columnOrder,
11425
11811
  hiddenColumns,
11426
11812
  columnWidths,
11427
11813
  onViewChange: updateView,
11814
+ data,
11815
+ rows,
11816
+ selectedCells,
11817
+ editingCell,
11818
+ setEditingCell,
11819
+ onCellPointerDown,
11820
+ booleanPressRef,
11821
+ pendingRowId,
11428
11822
  refTableData,
11429
- showName: blockId !== void 0,
11430
- readOnly
11431
- }),
11432
- /* @__PURE__ */ jsx(ScrollArea, {
11433
- "data-slot": "docblocks/database-grid",
11434
- className: "min-h-0 flex-1",
11435
- children: /* @__PURE__ */ jsx(GridTable, {
11436
- columns,
11437
- allColumns: data.table.columns,
11438
- columnOrder,
11439
- hiddenColumns,
11440
- columnWidths,
11441
- onViewChange: updateView,
11442
- data,
11443
- rows,
11444
- selectedCells,
11445
- editingCell,
11446
- setEditingCell,
11447
- onCellPointerDown,
11448
- booleanPressRef,
11449
- pendingRowId,
11450
- refTableData,
11451
- filter,
11452
- readOnly,
11453
- headerHeight: resolvedHeaderHeight,
11454
- onHeaderHeightChange,
11455
- tableRef,
11456
- onTableKeyDown,
11457
- onTablePaste,
11458
- onTableBlur,
11459
- form,
11460
- OptionsEditor
11461
- })
11462
- }),
11463
- readOnly ? null : /* @__PURE__ */ jsx(Button, {
11464
- "data-slot": "docblocks/database-add-row",
11465
- variant: "outline",
11466
- size: "sm",
11467
- className: cn(GRID_CHROME_FRAME, `
11468
- h-auto cursor-pointer self-start px-2 py-1 text-(length:--docblocks-font-size) font-normal shadow-none
11469
- select-none
11470
- `, "text-(--docblocks-placeholder-color) hover:bg-transparent", "hover:text-(--docblocks-text-color) dark:hover:bg-transparent"),
11471
- onClick: insertEmptyRow,
11472
- children: t("rows.add")
11823
+ filter,
11824
+ readOnly,
11825
+ headerHeight: resolvedHeaderHeight,
11826
+ onHeaderHeightChange,
11827
+ onHeaderHeightReset,
11828
+ tableRef,
11829
+ onTableKeyDown,
11830
+ onTablePaste,
11831
+ onTableBlur,
11832
+ form,
11833
+ OptionsEditor
11473
11834
  })
11474
- ]
11475
- })
11835
+ })]
11836
+ }), blockId !== void 0 && onHeightChange !== void 0 && !readOnly && /* @__PURE__ */ jsx(DatabaseResizeHandle, {
11837
+ height: blockHeight.currentHeight,
11838
+ minHeight: blockHeight.minHeight,
11839
+ onPointerDown: blockHeight.onPointerDown,
11840
+ onPointerMove: blockHeight.onPointerMove,
11841
+ onPointerUp: blockHeight.onPointerUp,
11842
+ onPointerCancel: blockHeight.onPointerCancel,
11843
+ onKeyDown: blockHeight.onKeyDown
11844
+ })]
11476
11845
  });
11477
11846
  }
11478
11847
  //#endregion
@@ -11539,9 +11908,18 @@ function DatabaseGrid({ id, block }) {
11539
11908
  columnOrder: block.attrs.columnOrder,
11540
11909
  hiddenColumns: block.attrs.hiddenColumns,
11541
11910
  columnWidths: block.attrs.columnWidths,
11911
+ height: block.attrs.height,
11542
11912
  headerHeight: block.attrs.headerHeight,
11543
11913
  sectionHeaderHeight: databaseTableSection?.getHeaderHeight?.(tableId),
11914
+ getRowCount: databaseTableSection?.getRowCount,
11915
+ onHeightChange: (height) => doc.updateBlock(id, { height }),
11544
11916
  onHeaderHeightChange: (height) => doc.updateBlock(id, { headerHeight: height }),
11917
+ onHeaderHeightReset: () => {
11918
+ const current = doc.getBlock(id);
11919
+ if (current === null || current.type !== "database") return;
11920
+ if (current.attrs.headerHeight !== void 0) doc.removeBlockAttr(id, "headerHeight");
11921
+ else if (databaseTableSection?.getHeaderHeight?.(tableId) !== void 0) databaseTableSection.setHeaderHeight?.(tableId, void 0);
11922
+ },
11545
11923
  onViewChange: (patch) => doc.updateBlock(id, patch),
11546
11924
  readColumnOrder: () => {
11547
11925
  const current = doc.getBlock(id);
@@ -17178,6 +17556,7 @@ function mapBlocksSelection(root, domSelection, anchorBlock) {
17178
17556
  const range = domSelection.getRangeAt(0);
17179
17557
  const ids = [];
17180
17558
  for (const element of Array.from(root.querySelectorAll("[data-block-id]"))) {
17559
+ if (element.getAttribute("data-slot") === "docblocks/row") continue;
17181
17560
  const blockId = element.dataset.blockId;
17182
17561
  if (ids.includes(blockId)) continue;
17183
17562
  if (range.intersectsNode(element)) ids.push(blockId);
@@ -17379,7 +17758,7 @@ function focusCellActivation(cellId, scope = document) {
17379
17758
  //#region src/editing/block-commands/utils/focus-restore.ts
17380
17759
  /** The parent block id per the DOM: the wrapper above the block's own wrapper; null at the doc root. */
17381
17760
  function domParentBlockIdOf(el) {
17382
- return (el.parentElement?.closest("[data-block-id]"))?.parentElement?.closest("[data-block-id]")?.dataset.blockId ?? null;
17761
+ return (el.parentElement?.closest("[data-block-id]"))?.parentElement?.closest("[data-block-id]:not([data-slot='docblocks/row'])")?.dataset.blockId ?? null;
17383
17762
  }
17384
17763
  /**
17385
17764
  * Whether the candidate inner is the SURVIVOR of the remount, not a framer
@@ -35683,7 +36062,7 @@ function PresenceCaretOverlay({ rootRef }) {
35683
36062
  const next = [];
35684
36063
  for (const peer of presence) {
35685
36064
  for (const point of caretPointsOf(peer.selection)) {
35686
- const block = root.querySelector(`[data-block-id="${CSS.escape(point.blockId)}"][data-slot="docblocks/block-content"]`) ?? root.querySelector(`[data-block-id="${CSS.escape(point.blockId)}"]`);
36065
+ const block = root.querySelector(`[data-block-id="${CSS.escape(point.blockId)}"][data-slot="docblocks/block-content"]`) ?? root.querySelector(`[data-block-id="${CSS.escape(point.blockId)}"]:not([data-slot="docblocks/row"])`);
35687
36066
  if (block === null) continue;
35688
36067
  next.push({
35689
36068
  key: `${peer.peerId}:caret:${point.blockId}:${point.offset}`,
@@ -39297,6 +39676,8 @@ const RowItem = memo(function RowItem({ node, layoutSlide, isDragged, animated,
39297
39676
  as: "div",
39298
39677
  ref: rowRef,
39299
39678
  "data-slot": "docblocks/row",
39679
+ "data-block-id": node.id,
39680
+ "data-block-type": block !== void 0 ? block.type : void 0,
39300
39681
  "data-selected": selected ? "true" : void 0,
39301
39682
  "data-divider": block !== void 0 && block.type === "divider" ? "true" : void 0,
39302
39683
  value: node.id,