@petrarca/sonnet-ui 0.2.0 → 0.4.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.
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>>;
@@ -990,4 +1025,4 @@ type Props = {
990
1025
  */
991
1026
  declare function ClipboardMenu({ onAddItem }: Props): react_jsx_runtime.JSX.Element;
992
1027
 
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 };
1028
+ 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, 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 };