@petrarca/sonnet-ui 0.3.0 → 0.4.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/README.md CHANGED
@@ -4,15 +4,22 @@ UI primitives and data components for the Petrarca Sonnet component library.
4
4
 
5
5
  ## What's included
6
6
 
7
- **UI primitives** -- Tailwind CSS + Radix UI based components following the shadcn pattern: Button, Badge, Card, Dialog, Tabs, Input, Tooltip, Spinner, Stepper, and more.
7
+ **UI primitives** — Tailwind + Radix UI components: Button, Badge, Card,
8
+ Dialog, Tabs, Input, Textarea, Checkbox, Label, Tooltip, Spinner, Avatar,
9
+ Separator, Stepper, ResizeHandle (draggable divider for resizable panes), and
10
+ more.
8
11
 
9
- **Data components** -- Higher-level components for building data-driven UIs:
10
- - **EntityTable** -- Schema-driven data table with pagination, row actions, custom cell renderers
11
- - **EntitySelect** -- Async searchable select with typeahead, backed by a fetcher API
12
- - **EntityTree** -- Hierarchical tree browser with search, edit, drag support
13
- - **TreeView** -- Generic tree renderer with keyboard navigation
14
- - **SearchInput** -- Faceted search input with chip-based filters
15
- - **JsonEditor** -- CodeMirror-based JSON editor with validation highlighting (subpath: `@petrarca/sonnet-ui/json-editor`)
12
+ **Data components** — Higher-level data-driven UI:
13
+ - **EntityTable** — Schema-driven table with pagination, row actions, custom cell renderers
14
+ - **EntitySelect** — Async searchable select with typeahead, backed by a fetcher API
15
+ - **EntityTree** — Hierarchical tree browser with search and edit support
16
+ - **TreeView** — Generic accessible tree with keyboard navigation and row selection
17
+ - **SearchInput** — Faceted search input with chip-based filters (simple, searchFields, faceted modes)
18
+ - **JsonEditor** — CodeMirror JSON editor with validation (subpath: `@petrarca/sonnet-ui/json-editor`)
19
+
20
+ **Design tokens** — Shipped as `styles.css` and `tailwind-preset.js`.
21
+
22
+ ---
16
23
 
17
24
  ## Install
18
25
 
@@ -20,19 +27,78 @@ UI primitives and data components for the Petrarca Sonnet component library.
20
27
  pnpm add @petrarca/sonnet-ui @petrarca/sonnet-core
21
28
  ```
22
29
 
23
- Peer dependencies: `react`, `react-dom`, `tailwindcss`.
30
+ Peer dependencies: `react >=19`, `react-dom >=19`, `tailwindcss >=3`,
31
+ `tailwindcss-animate`, `@tailwindcss/typography`.
32
+
33
+ ---
34
+
35
+ ## Setup
36
+
37
+ ### CSS
24
38
 
25
- ## Tailwind setup
39
+ Import `styles.css` in your app's global CSS. It provides design tokens
40
+ (light + dark), base resets, heading utilities, and typography classes.
26
41
 
27
- Add the package dist to your Tailwind `content` config so component classes are included:
42
+ ```css
43
+ /* index.css */
44
+ @import "@petrarca/sonnet-ui/styles.css";
45
+
46
+ /* Shell layout — add below the import (app-level, not provided by the library) */
47
+ html, body, #root { height: 100%; }
48
+ #root { display: flex; flex-direction: column; overflow: hidden; }
49
+ body { min-height: 100vh; overflow: hidden; }
50
+ ```
51
+
52
+ Override any token after the import for white-labeling:
53
+
54
+ ```css
55
+ @import "@petrarca/sonnet-ui/styles.css";
56
+
57
+ :root {
58
+ --primary: 210 80% 40%; /* custom brand color */
59
+ }
60
+ ```
61
+
62
+ ### Tailwind
63
+
64
+ Use the preset in `tailwind.config.js`. It maps all design tokens to Tailwind
65
+ utility classes (`bg-primary`, `text-muted-foreground`, `border-border`, etc.):
28
66
 
29
67
  ```js
30
- content: [
31
- "./src/**/*.{ts,tsx}",
32
- "./node_modules/@petrarca/sonnet-*/dist/**/*.js",
33
- ]
68
+ module.exports = {
69
+ presets: [require("@petrarca/sonnet-ui/tailwind-preset")],
70
+ content: [
71
+ "./src/**/*.{ts,tsx}",
72
+ "./node_modules/@petrarca/sonnet-*/dist/**/*.js",
73
+ ],
74
+ plugins: [require("tailwindcss-animate"), require("@tailwindcss/typography")],
75
+ };
34
76
  ```
35
77
 
78
+ ---
79
+
80
+ ## Design tokens
81
+
82
+ All tokens are CSS custom properties (HSL triplets). Key semantic tokens:
83
+
84
+ | Token | Role |
85
+ |---|---|
86
+ | `--background` / `--foreground` | Page surface / primary text |
87
+ | `--card` / `--card-foreground` | Card surface / text |
88
+ | `--primary` / `--primary-foreground` | Brand action color |
89
+ | `--destructive` | Error / danger |
90
+ | `--muted` / `--muted-foreground` | Quiet surface / secondary text |
91
+ | `--tertiary-foreground` | Tertiary text (timestamps, helpers) |
92
+ | `--faint-foreground` | Ghost text (annotations, disabled) |
93
+ | `--border` / `--border-subtle` / `--border-strong` | 3-tier border system |
94
+ | `--state-hover` / `--state-selected` | Interaction state backgrounds |
95
+ | `--ring` | Focus ring |
96
+ | `--radius` | Base border radius |
97
+
98
+ See `DESIGN.md` at the repo root for the full token reference.
99
+
100
+ ---
101
+
36
102
  ## License
37
103
 
38
- Apache 2.0
104
+ See [LICENSE.md](../../LICENSE.md).
package/dist/index.d.ts CHANGED
@@ -209,6 +209,41 @@ declare const ScrollBar: React$1.ForwardRefExoticComponent<Omit<ScrollAreaPrimit
209
209
 
210
210
  declare const Separator: React$1.ForwardRefExoticComponent<Omit<SeparatorPrimitive.SeparatorProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
211
211
 
212
+ interface ResizeHandleProps extends React$1.HTMLAttributes<HTMLDivElement> {
213
+ /**
214
+ * Orientation of the handle bar:
215
+ * - "vertical" (default): a vertical bar separating LEFT/RIGHT panes
216
+ * (drag horizontally). Uses `cursor-col-resize`.
217
+ * - "horizontal": a horizontal bar separating TOP/BOTTOM panes
218
+ * (drag vertically). Uses `cursor-row-resize`.
219
+ */
220
+ orientation?: "vertical" | "horizontal";
221
+ /** Length of the centered grip in pixels. Defaults to 48. */
222
+ gripLength?: number;
223
+ }
224
+ /**
225
+ * ResizeHandle — a quiet, flat draggable divider between two resizable panes.
226
+ *
227
+ * Renders a wide invisible hit-area with a short centered grip (quiet
228
+ * `bg-border` at rest, `bg-border-strong` on hover), a focus ring, and the
229
+ * correct `role="separator"` / `aria-orientation` / resize cursor. No
230
+ * full-height seam line — the adjacent panes own their own edges.
231
+ *
232
+ * The consumer owns the resize math: wire `onPointerDown` (and optionally
233
+ * `onDoubleClick`, `tabIndex`, `aria-valuenow`/min/max) via props.
234
+ *
235
+ * @example
236
+ * <ResizeHandle
237
+ * orientation="vertical"
238
+ * aria-valuenow={width}
239
+ * aria-valuemin={MIN}
240
+ * aria-valuemax={MAX}
241
+ * onPointerDown={startResize}
242
+ * onDoubleClick={resetWidth}
243
+ * />
244
+ */
245
+ declare const ResizeHandle: React$1.ForwardRefExoticComponent<ResizeHandleProps & React$1.RefAttributes<HTMLDivElement>>;
246
+
212
247
  declare const Sheet: React$1.FC<DialogPrimitive.DialogProps>;
213
248
  declare const SheetTrigger: React$1.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React$1.RefAttributes<HTMLButtonElement>>;
214
249
  declare const SheetClose: React$1.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React$1.RefAttributes<HTMLButtonElement>>;
@@ -619,6 +654,61 @@ interface EntityTableProps<TRow extends RowData> {
619
654
  }
620
655
  declare function EntityTable<TRow extends RowData>(props: EntityTableProps<TRow>): React__default.ReactElement;
621
656
 
657
+ /**
658
+ * PropertyList — read-only display of a record's properties as a stacked list.
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).
663
+ *
664
+ * Shared by the graph view's node/edge cards and the table inspector so all
665
+ * property displays look identical.
666
+ */
667
+
668
+ interface PropertyListProps {
669
+ /** Property name -> value. */
670
+ properties: Record<string, unknown>;
671
+ /** Optional property name -> schema, to refine value rendering. */
672
+ propertySchemas?: Record<string, JsonSchemaProperty>;
673
+ /** Show a "PROPERTIES" section header. Default false. */
674
+ showHeader?: boolean;
675
+ /** Click value to copy it to the clipboard. Default true. */
676
+ copyable?: boolean;
677
+ /** Message when there are no properties. Default "No properties". */
678
+ emptyLabel?: string;
679
+ className?: string;
680
+ }
681
+ declare function PropertyList({ properties, propertySchemas, showHeader, copyable, emptyLabel, className, }: PropertyListProps): React__default.ReactElement;
682
+
683
+ /**
684
+ * PropertyValue — read-only, type-aware rendering of a single property value.
685
+ *
686
+ * Reliable model (matches graph-explorer best practice): render by the actual
687
+ * VALUE TYPE, never by guessing string contents.
688
+ * - object / array -> collapsed summary that expands to a JSON tree (bounded box)
689
+ * - long string -> clamped to a few lines with a "Show more" toggle
690
+ * - scalar -> inline text
691
+ * - boolean -> true/false (or schema boolean cell)
692
+ * - array of scalars-> comma list
693
+ *
694
+ * Schema is OPTIONAL and only REFINES rendering when present:
695
+ * - x-ui-cell / inferred type/format (date, datetime, boolean, number)
696
+ * - x-ui-cell: "json" forces a JSON tree even for a string value
697
+ * A plain string is treated as text by default — it is NOT auto-parsed as
698
+ * JSON (avoids fragile, surprising behaviour). Schema is the only signal that
699
+ * turns a JSON-looking string into a tree.
700
+ */
701
+
702
+ interface PropertyValueProps {
703
+ value: unknown;
704
+ /** Optional schema for this property; refines rendering when present. */
705
+ schema?: JsonSchemaProperty;
706
+ className?: string;
707
+ /** Strings longer than this clamp with a "Show more" toggle. */
708
+ clampChars?: number;
709
+ }
710
+ declare function PropertyValue({ value, schema, className, clampChars, }: PropertyValueProps): React__default.ReactElement;
711
+
622
712
  /**
623
713
  * EntitySelect -- async searchable single-select for entity references.
624
714
  *
@@ -990,4 +1080,4 @@ type Props = {
990
1080
  */
991
1081
  declare function ClipboardMenu({ onAddItem }: Props): react_jsx_runtime.JSX.Element;
992
1082
 
993
- 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, 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 };
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 };