docblocks-react-ui 0.6.0 → 0.6.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # docblocks-react-ui
2
2
 
3
+ ## 0.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 47a8334: Remove column drag, resize, menu, and add-column affordances from database grids in view and published modes.
8
+ - 2fd97ce: Block every database cell write in view and published modes, including direct boolean toggles.
9
+
3
10
  ## 0.6.0
4
11
 
5
12
  ### Minor Changes
@@ -9540,7 +9540,7 @@ const GRID_DRAG_TRANSITION = "transform 120ms ease-out";
9540
9540
  * floor, the live preview, the one `updateBlock` on the release). The menu
9541
9541
  * content: the editable name line (the rename commits on the blur / the
9542
9542
  * Enter), the type line (read-only), and the show / hide / delete items. */
9543
- function HeaderCell({ column, colIndex, first, resizing, dragDx, dragShifted, menuOpen, onMenuChange, onRename, onEditOptions, onHide, onShow, onDelete, hidden, onPointerDown, onPointerMove, onPointerUp, onResizePointerDown, onResizePointerMove, onResizePointerUp, onResizePointerCancel }) {
9543
+ 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 }) {
9544
9544
  const { t } = useTranslation("database");
9545
9545
  const [nameDraft, setNameDraft] = useState(column.name);
9546
9546
  const ColumnIcon = columnTypeIcon(column.type, column.refKind, column.refMany);
@@ -9577,20 +9577,19 @@ function HeaderCell({ column, colIndex, first, resizing, dragDx, dragShifted, me
9577
9577
  transition: dragShifted ? GRID_DRAG_TRANSITION : void 0
9578
9578
  } : void 0,
9579
9579
  className: cn(`
9580
- relative flex min-w-0 cursor-grab items-center gap-1 border-b-(length:--docblocks-table-border-width)
9580
+ relative flex min-w-0 items-center gap-1 border-b-(length:--docblocks-table-border-width)
9581
9581
  border-(--docblocks-table-border-color) bg-muted/40 px-2 py-1 select-none
9582
- active:cursor-grabbing
9583
- `, !first && "border-l-(length:--docblocks-table-border-width)"),
9584
- onPointerDown,
9585
- onPointerMove,
9586
- onPointerUp,
9582
+ `, !readOnly && "cursor-grab active:cursor-grabbing", !first && "border-l-(length:--docblocks-table-border-width)"),
9583
+ onPointerDown: readOnly ? void 0 : onPointerDown,
9584
+ onPointerMove: readOnly ? void 0 : onPointerMove,
9585
+ onPointerUp: readOnly ? void 0 : onPointerUp,
9587
9586
  children: [
9588
9587
  /* @__PURE__ */ jsx(ColumnIcon, { className: "size-4 shrink-0 text-muted-foreground" }),
9589
9588
  /* @__PURE__ */ jsx("span", {
9590
9589
  className: "\n min-w-0 flex-1 truncate px-1 text-(length:--docblocks-font-size) font-(--docblocks-heading-font-weight)\n ",
9591
9590
  children: column.name
9592
9591
  }),
9593
- /* @__PURE__ */ jsx("div", {
9592
+ !readOnly && /* @__PURE__ */ jsx("div", {
9594
9593
  className: "ml-auto flex shrink-0 items-center",
9595
9594
  children: /* @__PURE__ */ jsxs(DropdownMenu, {
9596
9595
  modal: false,
@@ -9602,7 +9601,7 @@ function HeaderCell({ column, colIndex, first, resizing, dragDx, dragShifted, me
9602
9601
  "data-slot": "docblocks/database-column-menu",
9603
9602
  variant: "ghost",
9604
9603
  size: "icon",
9605
- className: "\n size-5 cursor-pointer rounded-(--docblocks-radius) p-0.5 text-(--docblocks-placeholder-color)\n hover:bg-transparent hover:text-(--docblocks-text-color)\n dark:hover:bg-transparent\n ",
9604
+ className: "\n size-5 cursor-pointer rounded-(--docblocks-radius) p-0.5 text-(--docblocks-placeholder-color)\n hover:bg-transparent hover:text-(--docblocks-text-color)\n dark:hover:bg-transparent\n ",
9606
9605
  children: /* @__PURE__ */ jsx(Ellipsis, { className: "size-4" })
9607
9606
  })
9608
9607
  }), /* @__PURE__ */ jsxs(DropdownMenuContent, {
@@ -9646,13 +9645,13 @@ function HeaderCell({ column, colIndex, first, resizing, dragDx, dragShifted, me
9646
9645
  })]
9647
9646
  })
9648
9647
  }),
9649
- /* @__PURE__ */ jsx("div", {
9648
+ !readOnly && /* @__PURE__ */ jsx("div", {
9650
9649
  "data-slot": "docblocks/database-col-resize",
9651
9650
  "data-index": colIndex,
9652
9651
  className: cn(`
9653
- absolute top-0 -right-0.75 z-10 h-full w-1.5 cursor-col-resize opacity-0 transition-opacity
9654
- hover:opacity-100
9655
- `, resizing && "opacity-100"),
9652
+ absolute top-0 -right-0.75 z-10 h-full w-1.5 cursor-col-resize opacity-0 transition-opacity
9653
+ hover:opacity-100
9654
+ `, resizing && "opacity-100"),
9656
9655
  onPointerDown: onResizePointerDown,
9657
9656
  onPointerMove: onResizePointerMove,
9658
9657
  onPointerUp: onResizePointerUp,
@@ -11479,6 +11478,7 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
11479
11478
  };
11480
11479
  const columnPointerUp = (column) => (event) => onColumnPointerUp(column, event);
11481
11480
  const cellChange = (row, column) => (value, expectedRevision) => {
11481
+ if (readOnly) return;
11482
11482
  data.updateRow(row.rowId, { [column.id]: value }, expectedRevision).catch(() => void 0);
11483
11483
  };
11484
11484
  const cellEditStart = (cellKey) => () => {
@@ -11648,6 +11648,7 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
11648
11648
  },
11649
11649
  children: [
11650
11650
  columns.map((column, index) => /* @__PURE__ */ jsx(HeaderCell, {
11651
+ readOnly,
11651
11652
  column,
11652
11653
  colIndex: index,
11653
11654
  first: index === 0,
@@ -11673,10 +11674,7 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
11673
11674
  /* @__PURE__ */ jsxs("div", {
11674
11675
  "data-slot": "docblocks/database-add-column",
11675
11676
  className: "\n relative flex items-center justify-center border-b-(length:--docblocks-table-border-width)\n border-(--docblocks-table-border-color)\n ",
11676
- children: [readOnly ? /* @__PURE__ */ jsx("span", {
11677
- className: "flex size-6 items-center justify-center text-(--docblocks-placeholder-color)",
11678
- children: /* @__PURE__ */ jsx(Plus, { className: "size-4" })
11679
- }) : /* @__PURE__ */ jsxs(DropdownMenu, {
11677
+ children: [!readOnly && /* @__PURE__ */ jsxs(DropdownMenu, {
11680
11678
  modal: false,
11681
11679
  open: addingColumn,
11682
11680
  onOpenChange: setAddingColumn,
package/dist/index.d.mts CHANGED
@@ -322,7 +322,7 @@ declare function AlertDescription({ className, ...props }: React.ComponentProps<
322
322
  //#endregion
323
323
  //#region src/shared/ui/Badge.d.ts
324
324
  declare const badgeVariants: (props?: ({
325
- variant?: "default" | "custom" | "secondary" | "destructive" | "outline" | null | undefined;
325
+ variant?: "default" | "destructive" | "custom" | "secondary" | "outline" | null | undefined;
326
326
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
327
327
  declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
328
328
  asChild?: boolean;
@@ -333,7 +333,7 @@ declare function BareSelect({ className, children, ...props }: React.ComponentPr
333
333
  //#endregion
334
334
  //#region src/shared/ui/Button.d.ts
335
335
  declare const buttonVariants: (props?: ({
336
- variant?: "link" | "default" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined;
336
+ variant?: "link" | "default" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
337
337
  size?: "default" | "icon" | "sm" | "lg" | "xl" | null | undefined;
338
338
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
339
339
  declare function Button({ className, variant, size, asChild, type, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as SelectValue, A as useBlock, At as CardFooter, B as DEFAULT_EMBED_SANDBOX, Bt as Badge, C as isBridgeError, Ct as PopoverTrigger, D as parseCellValue, Dt as CardAction, E as conditionMatches, Et as Card, F as useSelection, G as SelectContent, Gt as DocblocksI18nProvider, H as SegmentSelector, Ht as Alert, I as useSelectionView, It as BookOpen, J as SelectLabel, Jt as createMemoryBlobStore, K as SelectGroup, L as useText, Lt as Button, M as useMeta, Mt as CardTitle, N as usePresence, Nt as Pen, O as TEXT_TYPES, Ot as CardContent, P as usePresenceSharing, Pt as Eye, Q as SelectTrigger, R as EditorProvider, Rt as buttonVariants, S as BridgeError, St as PopoverTitle, T as toBridgeError, Tt as Checkbox, U as ScrollArea, Ut as AlertDescription, V as Skeleton, Vt as badgeVariants, W as Select, Wt as AlertTitle, X as SelectScrollUpButton, Y as SelectScrollDownButton, Z as SelectSeparator, _ as BASELINE_CAPABILITIES, _t as Popover, a as SHAPE_FONT_STACKS, at as DropdownMenuItem, b as validateProtocolDescriptor, bt as PopoverDescription, ct as DropdownMenuRadioGroup, d as useDatabaseTable, dt as DropdownMenuShortcut, et as Label, f as cellValueEqual, ft as DropdownMenuSub, g as filterIsComplete, gt as Separator, h as emptyFilter, ht as DropdownMenuTrigger, i as SHAPE_FONT_OPTIONS, it as DropdownMenuGroup, j as useDoc, jt as CardHeader, k as columnAnnotation, kt as CardDescription, l as markToggleAction, lt as DropdownMenuRadioItem, m as FilterBuilder, mt as DropdownMenuSubTrigger, nt as DropdownMenuCheckboxItem, ot as DropdownMenuLabel, p as newMutationContext, pt as DropdownMenuSubContent, q as SelectItem, qt as renderRuns, rt as DropdownMenuContent, s as FORMAT_PALETTE, st as DropdownMenuPortal, t as Editor, tt as DropdownMenu, u as GridBody, ut as DropdownMenuSeparator, v as PROTOCOL_VERSION, vt as PopoverAnchor, w as isBridgeErrorCode, wt as Input, x as BRIDGE_ERROR_CODES, xt as PopoverHeader, y as isDatabaseBridge, yt as PopoverContent, z as useEditorContext, zt as BareSelect } from "./Editor-BavCl07r.mjs";
1
+ import { $ as SelectValue, A as useBlock, At as CardFooter, B as DEFAULT_EMBED_SANDBOX, Bt as Badge, C as isBridgeError, Ct as PopoverTrigger, D as parseCellValue, Dt as CardAction, E as conditionMatches, Et as Card, F as useSelection, G as SelectContent, Gt as DocblocksI18nProvider, H as SegmentSelector, Ht as Alert, I as useSelectionView, It as BookOpen, J as SelectLabel, Jt as createMemoryBlobStore, K as SelectGroup, L as useText, Lt as Button, M as useMeta, Mt as CardTitle, N as usePresence, Nt as Pen, O as TEXT_TYPES, Ot as CardContent, P as usePresenceSharing, Pt as Eye, Q as SelectTrigger, R as EditorProvider, Rt as buttonVariants, S as BridgeError, St as PopoverTitle, T as toBridgeError, Tt as Checkbox, U as ScrollArea, Ut as AlertDescription, V as Skeleton, Vt as badgeVariants, W as Select, Wt as AlertTitle, X as SelectScrollUpButton, Y as SelectScrollDownButton, Z as SelectSeparator, _ as BASELINE_CAPABILITIES, _t as Popover, a as SHAPE_FONT_STACKS, at as DropdownMenuItem, b as validateProtocolDescriptor, bt as PopoverDescription, ct as DropdownMenuRadioGroup, d as useDatabaseTable, dt as DropdownMenuShortcut, et as Label, f as cellValueEqual, ft as DropdownMenuSub, g as filterIsComplete, gt as Separator, h as emptyFilter, ht as DropdownMenuTrigger, i as SHAPE_FONT_OPTIONS, it as DropdownMenuGroup, j as useDoc, jt as CardHeader, k as columnAnnotation, kt as CardDescription, l as markToggleAction, lt as DropdownMenuRadioItem, m as FilterBuilder, mt as DropdownMenuSubTrigger, nt as DropdownMenuCheckboxItem, ot as DropdownMenuLabel, p as newMutationContext, pt as DropdownMenuSubContent, q as SelectItem, qt as renderRuns, rt as DropdownMenuContent, s as FORMAT_PALETTE, st as DropdownMenuPortal, t as Editor, tt as DropdownMenu, u as GridBody, ut as DropdownMenuSeparator, v as PROTOCOL_VERSION, vt as PopoverAnchor, w as isBridgeErrorCode, wt as Input, x as BRIDGE_ERROR_CODES, xt as PopoverHeader, y as isDatabaseBridge, yt as PopoverContent, z as useEditorContext, zt as BareSelect } from "./Editor-DcQTuUsM.mjs";
2
2
  import { a as preventDefault, p as cn } from "./constants-2VXoyPmd.mjs";
3
3
  import { useCallback, useEffect, useRef, useState } from "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1,4 +1,4 @@
1
- import { Ft as CodeXml, H as SegmentSelector, Ht as Alert, Kt as INLINE_CODE_CLASS, Pt as Eye, Ut as AlertDescription, V as Skeleton, Wt as AlertTitle, c as textOf, n as childrenSlot, o as TextBlock, r as CodeHeader, z as useEditorContext } from "../Editor-BavCl07r.mjs";
1
+ import { Ft as CodeXml, H as SegmentSelector, Ht as Alert, Kt as INLINE_CODE_CLASS, Pt as Eye, Ut as AlertDescription, V as Skeleton, Wt as AlertTitle, c as textOf, n as childrenSlot, o as TextBlock, r as CodeHeader, z as useEditorContext } from "../Editor-DcQTuUsM.mjs";
2
2
  import { c as TriangleAlert } from "../constants-2VXoyPmd.mjs";
3
3
  import { t as LoaderCircle } from "../LoaderCircle-AGVFE4IP.mjs";
4
4
  import { useEffect, useRef, useState } from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docblocks-react-ui",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "React rendering + editing layer for docblocks: hooks, block renderers, caret/selection, keyboard, clipboard.",
5
5
  "type": "module",
6
6
  "license": "MIT",