@petrarca/sonnet-ui 0.4.1 → 0.4.2

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/dist/index.d.ts CHANGED
@@ -655,22 +655,29 @@ interface EntityTableProps<TRow extends RowData> {
655
655
  declare function EntityTable<TRow extends RowData>(props: EntityTableProps<TRow>): React__default.ReactElement;
656
656
 
657
657
  /**
658
- * PropertyList — read-only display of a record's properties as a stacked list.
658
+ * PropertyList — read-only display of a record's properties.
659
659
  *
660
- * Layout matches the established graph node/edge cards: an uppercase muted key
661
- * label above each value, values rendered by {@link PropertyValue}. Optional
662
- * per-property schema refines value rendering (schema is NOT required).
660
+ * Two layout modes:
661
+ * - `"inline"` (default) — horizontal two-column grid, key left / value right.
662
+ * - `"stacked"` — key label above each value.
663
+ *
664
+ * Values rendered by {@link PropertyValue}. Optional per-property schema
665
+ * refines value rendering (schema is NOT required).
663
666
  *
664
667
  * Shared by the graph view's node/edge cards and the table inspector so all
665
668
  * property displays look identical.
666
669
  */
667
670
 
671
+ /** Layout mode for the property list. */
672
+ type PropertyListLayout = "inline" | "stacked";
668
673
  interface PropertyListProps {
669
674
  /** Property name -> value. */
670
675
  properties: Record<string, unknown>;
671
676
  /** Optional property name -> schema, to refine value rendering. */
672
677
  propertySchemas?: Record<string, JsonSchemaProperty>;
673
- /** Show a "PROPERTIES" section header. Default false. */
678
+ /** Layout mode. Default "inline" (horizontal key-value grid). */
679
+ layout?: PropertyListLayout;
680
+ /** Show a "Properties" section header. Default false. */
674
681
  showHeader?: boolean;
675
682
  /** Click value to copy it to the clipboard. Default true. */
676
683
  copyable?: boolean;
@@ -678,7 +685,7 @@ interface PropertyListProps {
678
685
  emptyLabel?: string;
679
686
  className?: string;
680
687
  }
681
- declare function PropertyList({ properties, propertySchemas, showHeader, copyable, emptyLabel, className, }: PropertyListProps): React__default.ReactElement;
688
+ declare function PropertyList({ properties, propertySchemas, layout, showHeader, copyable, emptyLabel, className, }: PropertyListProps): React__default.ReactElement;
682
689
 
683
690
  /**
684
691
  * PropertyValue — read-only, type-aware rendering of a single property value.
@@ -1080,4 +1087,4 @@ type Props = {
1080
1087
  */
1081
1088
  declare function ClipboardMenu({ onAddItem }: Props): react_jsx_runtime.JSX.Element;
1082
1089
 
1083
- export { Alert, AlertDescription, AlertTitle, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeProps, Button, CELL_RENDERERS, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CellRenderer, type CellRendererProps, Checkbox, ClipboardButton, ClipboardItemComponent as ClipboardItem, ClipboardMenu, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EntitySelect, type EntitySelectProps, EntityTable, type EntityTableProps, EntityTree, type EntityTreeHandle, type EntityTreeProps, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Popover, PopoverContent, PopoverTrigger, PropertyList, type PropertyListProps, PropertyValue, type PropertyValueProps, ResizeHandle, type ResizeHandleProps, type ResolvedColumn, type RowAction, ScrollArea, ScrollBar, SearchInput, type SearchMode, Separator, Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetTitle, SheetTrigger, SimpleGroup, SimpleStack, SimpleTooltip, Skeleton, Spinner, Stepper, StepperContent, StepperDescription, StepperIndicator, StepperItem, StepperList, StepperNext, StepperPrev, type StepperProps, StepperSeparator, StepperTitle, StepperTrigger, type TableUiSchema, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type TreeNode, TreeView, type TreeViewHandle, type TreeViewProps, badgeVariants, buttonVariants, createRenderer, useStore as useStepper };
1090
+ export { Alert, AlertDescription, AlertTitle, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeProps, Button, CELL_RENDERERS, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CellRenderer, type CellRendererProps, Checkbox, ClipboardButton, ClipboardItemComponent as ClipboardItem, ClipboardMenu, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EntitySelect, type EntitySelectProps, EntityTable, type EntityTableProps, EntityTree, type EntityTreeHandle, type EntityTreeProps, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Popover, PopoverContent, PopoverTrigger, PropertyList, type PropertyListLayout, type PropertyListProps, PropertyValue, type PropertyValueProps, ResizeHandle, type ResizeHandleProps, type ResolvedColumn, type RowAction, ScrollArea, ScrollBar, SearchInput, type SearchMode, Separator, Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetTitle, SheetTrigger, SimpleGroup, SimpleStack, SimpleTooltip, Skeleton, Spinner, Stepper, StepperContent, StepperDescription, StepperIndicator, StepperItem, StepperList, StepperNext, StepperPrev, type StepperProps, StepperSeparator, StepperTitle, StepperTrigger, type TableUiSchema, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type TreeNode, TreeView, type TreeViewHandle, type TreeViewProps, badgeVariants, buttonVariants, createRenderer, useStore as useStepper };
package/dist/index.js CHANGED
@@ -3008,6 +3008,7 @@ function PaginationFooter({
3008
3008
  }
3009
3009
 
3010
3010
  // src/PropertyList/PropertyList.tsx
3011
+ import React26 from "react";
3011
3012
  import { copyTextToClipboard } from "@petrarca/sonnet-core";
3012
3013
 
3013
3014
  // src/PropertyList/PropertyValue.tsx
@@ -3184,6 +3185,7 @@ import { jsx as jsx30, jsxs as jsxs10 } from "react/jsx-runtime";
3184
3185
  function PropertyList({
3185
3186
  properties,
3186
3187
  propertySchemas,
3188
+ layout = "inline",
3187
3189
  showHeader = false,
3188
3190
  copyable = true,
3189
3191
  emptyLabel = "No properties",
@@ -3193,20 +3195,27 @@ function PropertyList({
3193
3195
  if (entries.length === 0) {
3194
3196
  return /* @__PURE__ */ jsx30("p", { className: "text-sm text-muted-foreground italic", children: emptyLabel });
3195
3197
  }
3196
- return /* @__PURE__ */ jsxs10("ul", { className: `list-none ${className ?? ""}`, children: [
3197
- showHeader && /* @__PURE__ */ jsx30("li", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1", children: "Properties" }),
3198
- entries.map(([key, value]) => /* @__PURE__ */ jsxs10("li", { className: "mb-2 leading-tight", children: [
3199
- /* @__PURE__ */ jsx30(
3200
- "p",
3201
- {
3202
- className: `text-xs text-muted-foreground uppercase tracking-wide ${copyable ? "cursor-pointer hover:text-foreground" : ""}`,
3203
- onClick: copyable ? () => copyTextToClipboard(stringForCopy(value)) : void 0,
3204
- title: copyable ? "Click to copy value" : void 0,
3205
- children: key
3206
- }
3207
- ),
3208
- /* @__PURE__ */ jsx30("div", { className: "text-sm text-foreground", children: /* @__PURE__ */ jsx30(PropertyValue, { value, schema: propertySchemas?.[key] }) })
3209
- ] }, key))
3198
+ const header = showHeader && /* @__PURE__ */ jsx30("p", { className: "text-[11px] text-muted-foreground mb-1.5", children: "Properties" });
3199
+ const dtClass = `text-[11px] text-muted-foreground ${copyable ? "cursor-pointer hover:text-foreground" : ""}`;
3200
+ const dtProps = (value) => copyable ? {
3201
+ onClick: () => copyTextToClipboard(stringForCopy(value)),
3202
+ title: "Click to copy value"
3203
+ } : {};
3204
+ if (layout === "stacked") {
3205
+ return /* @__PURE__ */ jsxs10("div", { className, children: [
3206
+ header,
3207
+ /* @__PURE__ */ jsx30("dl", { className: "space-y-1", children: entries.map(([key, value]) => /* @__PURE__ */ jsxs10("div", { children: [
3208
+ /* @__PURE__ */ jsx30("dt", { className: dtClass, ...dtProps(value), children: key }),
3209
+ /* @__PURE__ */ jsx30("dd", { className: "text-sm text-foreground font-medium break-words", children: /* @__PURE__ */ jsx30(PropertyValue, { value, schema: propertySchemas?.[key] }) })
3210
+ ] }, key)) })
3211
+ ] });
3212
+ }
3213
+ return /* @__PURE__ */ jsxs10("div", { className, children: [
3214
+ header,
3215
+ /* @__PURE__ */ jsx30("dl", { className: "grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 items-baseline", children: entries.map(([key, value]) => /* @__PURE__ */ jsxs10(React26.Fragment, { children: [
3216
+ /* @__PURE__ */ jsx30("dt", { className: `${dtClass} whitespace-nowrap`, ...dtProps(value), children: key }),
3217
+ /* @__PURE__ */ jsx30("dd", { className: "text-sm text-foreground min-w-0 break-words", children: /* @__PURE__ */ jsx30(PropertyValue, { value, schema: propertySchemas?.[key] }) })
3218
+ ] }, key)) })
3210
3219
  ] });
3211
3220
  }
3212
3221
  function stringForCopy(value) {
@@ -3216,7 +3225,7 @@ function stringForCopy(value) {
3216
3225
  }
3217
3226
 
3218
3227
  // src/EntitySelect/EntitySelect.tsx
3219
- import * as React26 from "react";
3228
+ import * as React27 from "react";
3220
3229
  import { Check as Check4, ChevronsUpDown, Loader2 } from "lucide-react";
3221
3230
  import { cn as cn27 } from "@petrarca/sonnet-core";
3222
3231
  import {
@@ -3240,8 +3249,8 @@ function emptyStateMessage({
3240
3249
  return emptyMessage;
3241
3250
  }
3242
3251
  function useHasSearched(submit) {
3243
- const [hasSearched, setHasSearched] = React26.useState(false);
3244
- const wrappedSubmit = React26.useCallback(() => {
3252
+ const [hasSearched, setHasSearched] = React27.useState(false);
3253
+ const wrappedSubmit = React27.useCallback(() => {
3245
3254
  setHasSearched(true);
3246
3255
  submit();
3247
3256
  }, [submit]);
@@ -3363,8 +3372,8 @@ function EntitySelect(props) {
3363
3372
  emptyMessage,
3364
3373
  disabled
3365
3374
  } = resolveEntitySelectDefaults(props);
3366
- const [open, setOpen] = React26.useState(false);
3367
- const [selectedLabel, setSelectedLabel] = React26.useState(null);
3375
+ const [open, setOpen] = React27.useState(false);
3376
+ const [selectedLabel, setSelectedLabel] = React27.useState(null);
3368
3377
  const {
3369
3378
  options,
3370
3379
  isLoading,
@@ -3373,7 +3382,7 @@ function EntitySelect(props) {
3373
3382
  submit: rawSubmit
3374
3383
  } = useEntityOptions({ fetcher, queryKey, mode, minChars });
3375
3384
  const [hasSearched, submit] = useHasSearched(rawSubmit);
3376
- React26.useEffect(() => {
3385
+ React27.useEffect(() => {
3377
3386
  if (!value) {
3378
3387
  setSelectedLabel(null);
3379
3388
  return;
@@ -3383,7 +3392,7 @@ function EntitySelect(props) {
3383
3392
  setSelectedLabel(found.label);
3384
3393
  }
3385
3394
  }, [value, options]);
3386
- const handleSelect = React26.useCallback(
3395
+ const handleSelect = React27.useCallback(
3387
3396
  (selectedValue) => {
3388
3397
  const opt = options.find((o) => o.value === selectedValue);
3389
3398
  if (opt) setSelectedLabel(opt.label);
@@ -3396,7 +3405,7 @@ function EntitySelect(props) {
3396
3405
  },
3397
3406
  [options, value, onChange, onChangeOption, setSearch]
3398
3407
  );
3399
- const handleOpenChange = React26.useCallback(
3408
+ const handleOpenChange = React27.useCallback(
3400
3409
  (newOpen) => {
3401
3410
  setOpen(newOpen);
3402
3411
  if (!newOpen) {
@@ -4032,7 +4041,7 @@ function EntityTreeInner(props, ref) {
4032
4041
  var EntityTree = forwardRef20(EntityTreeInner);
4033
4042
 
4034
4043
  // src/SearchInput/SearchInput.tsx
4035
- import React31, { useMemo as useMemo6, useRef as useRef9, useState as useState8, useEffect as useEffect9 } from "react";
4044
+ import React32, { useMemo as useMemo6, useRef as useRef9, useState as useState8, useEffect as useEffect9 } from "react";
4036
4045
  import { Search as Search2, X as X3, ChevronDown } from "lucide-react";
4037
4046
  import { cn as cn31 } from "@petrarca/sonnet-core";
4038
4047
  import { getFieldTitle as getFieldTitle2 } from "@petrarca/sonnet-core/schema";
@@ -4817,7 +4826,7 @@ function SearchInput(props) {
4817
4826
  const showFacetControls = isFaceted && !pendingFacet;
4818
4827
  const pickerVisible = showFacetControls && pickerOpen;
4819
4828
  const hasFacetsToShow = pickerVisible && filteredFacets.length > 0;
4820
- const acceptFacet = React31.useCallback(
4829
+ const acceptFacet = React32.useCallback(
4821
4830
  (facet) => {
4822
4831
  selectFacet(facet);
4823
4832
  setPickerOpen(false);