@structyl/primitives 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 your-lib contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # @structyl/primitives
2
+
3
+ > Headless, accessible React behavior primitives — structure without styling.
4
+
5
+ ![npm](https://img.shields.io/npm/v/@structyl/primitives)
6
+ ![license](https://img.shields.io/npm/l/@structyl/primitives)
7
+
8
+ `@structyl/primitives` is the headless behavior layer of [structyl](https://structyl.dev). It provides unstyled, WAI-ARIA compliant React components — dialogs, menus, selects, date pickers, and dozens more — that ship full keyboard navigation, focus management, and accessibility while leaving styling entirely up to you. It is the foundation that `@structyl/styled` builds on, and it's also a complete toolkit on its own for teams that bring their own design system.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ # pnpm
14
+ pnpm add @structyl/primitives
15
+
16
+ # npm
17
+ npm install @structyl/primitives
18
+
19
+ # yarn
20
+ yarn add @structyl/primitives
21
+ ```
22
+
23
+ React 18 or 19 (and the matching `react-dom`) are required as peer dependencies.
24
+
25
+ ## Usage
26
+
27
+ Multi-part components use a compound, dot-notation API. Every primitive is unstyled — apply your own classes or styles.
28
+
29
+ ```tsx
30
+ import { Dialog, Button } from '@structyl/primitives';
31
+
32
+ export function Example() {
33
+ return (
34
+ <Dialog.Root>
35
+ <Dialog.Trigger asChild>
36
+ <Button>Open dialog</Button>
37
+ </Dialog.Trigger>
38
+ <Dialog.Portal>
39
+ <Dialog.Overlay />
40
+ <Dialog.Content>
41
+ <Dialog.Title>Confirm action</Dialog.Title>
42
+ <Dialog.Description>This cannot be undone.</Dialog.Description>
43
+ <Dialog.Close asChild>
44
+ <Button>Cancel</Button>
45
+ </Dialog.Close>
46
+ </Dialog.Content>
47
+ </Dialog.Portal>
48
+ </Dialog.Root>
49
+ );
50
+ }
51
+ ```
52
+
53
+ Stateful primitives support both controlled and uncontrolled usage:
54
+
55
+ ```tsx
56
+ import { Dialog } from '@structyl/primitives';
57
+
58
+ // Uncontrolled
59
+ <Dialog.Root defaultOpen={false}>{/* ... */}</Dialog.Root>
60
+
61
+ // Controlled
62
+ <Dialog.Root open={open} onOpenChange={setOpen}>{/* ... */}</Dialog.Root>
63
+ ```
64
+
65
+ ## Features
66
+
67
+ - **Accessible by default** — WAI-ARIA APG patterns, correct roles and attributes, and full keyboard support for every interaction.
68
+ - **Headless** — zero styling shipped; render with Tailwind, CSS Modules, or anything else.
69
+ - **Compound APIs** — composable dot-notation parts (`Dialog.Root`, `Dialog.Trigger`, `Dialog.Content`, …).
70
+ - **`asChild` slots** — merge behavior onto your own element or component instead of an extra wrapper.
71
+ - **Controlled & uncontrolled** — every stateful primitive works both ways via `value`/`defaultValue` plus change handlers.
72
+ - **Ref forwarding** — all primitives forward refs to their underlying DOM node.
73
+ - **TypeScript-first** — strict types and exported prop types for every component.
74
+ - **SSR / RSC friendly** — tested in the Next.js App Router.
75
+
76
+ ## API
77
+
78
+ The package exports both standalone primitives and namespaced compound components. A selection of the main exports:
79
+
80
+ | Export | Type | Description |
81
+ | --- | --- | --- |
82
+ | `Button` | component | Accessible button with `asChild` and loading state |
83
+ | `Rating` | component | Star/icon rating input |
84
+ | `Dialog` | namespace | Modal dialog (`Root`, `Trigger`, `Portal`, `Overlay`, `Content`, `Title`, `Description`, `Close`) |
85
+ | `AlertDialog` | namespace | Confirmation dialog with required action affordances |
86
+ | `Popover` / `Tooltip` / `HoverCard` | namespace | Floating overlays |
87
+ | `DropdownMenu` / `ContextMenu` / `Menubar` / `Menu` | namespace | Menu patterns |
88
+ | `NavigationMenu` / `Breadcrumb` / `Pagination` / `Stepper` | namespace | Navigation |
89
+ | `Select` / `MultiSelect` / `Combobox` / `Command` | namespace | Listbox & command palette inputs |
90
+ | `Tabs` / `Accordion` / `Collapsible` | namespace | Disclosure & sectioned content |
91
+ | `RadioGroup` / `ToggleGroup` / `Slider` / `Form` | namespace | Form controls |
92
+ | `Calendar` / `DatePicker` / `DateRangePicker` / `TimePicker` / `DateTimePicker` | namespace | Date & time pickers |
93
+ | `ColorPicker` / `FileUpload` / `TagsInput` / `Mentions` / `Editable` | namespace | Specialty inputs |
94
+ | `NumberField` / `OneTimePasswordField` / `PasswordToggleField` | namespace | Specialty form fields |
95
+ | `ScrollArea` / `Resizable` / `Carousel` / `Tree` / `Toolbar` | namespace | Layout & utility |
96
+ | `Avatar` / `Progress` / `Toast` / `Card` / `Chart` | namespace | Display & feedback |
97
+ | `Switch` / `Toggle` / `Checkbox` / `Label` / `Separator` / `Skeleton` / `Spinner` / `Badge` / `Alert` / `Input` / `Textarea` / `AspectRatio` | component | Standalone primitives |
98
+
99
+ Every component ships its corresponding prop types (for example `ButtonProps`, `DialogContentProps`, `SelectRootProps`). See the [documentation](https://structyl.dev) for the full API reference.
100
+
101
+ ## Part of structyl
102
+
103
+ Part of the [structyl](https://github.com/imirfanul/structyl) component library — see the full docs at [structyl.dev](https://structyl.dev).
104
+
105
+ ## License
106
+
107
+ MIT