@jsenv/navi 0.20.12 → 0.20.14
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 +20 -89
- package/dist/jsenv_navi.js.map +3 -2
- package/dist/jsenv_navi_side_effects.js.map +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,110 +1,41 @@
|
|
|
1
1
|
# @jsenv/navi
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A frontend framework for building modern web applications, focused on routing, async data, and UI components.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Routing
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Routing is signal-based, which means URL state — including search params — can be bound to signals with two-way synchronization. Change a signal, the URL updates. Navigate to a URL, the signals update. Search params can also be validated and typed, so you always work with the right shape of data.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Routes are flexible: you can create route groups to share logic, state, or UI across multiple routes. Nested routing is supported, and the structure naturally maps to how your application is organized.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Actions
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
- **Link components** that enhance standard anchor tags
|
|
15
|
-
- **Route components** with nested routing support
|
|
16
|
-
- **History management** and navigation state hooks
|
|
17
|
-
- **Keyboard navigation** with keyboard shortcuts
|
|
13
|
+
Actions are async operations with lifecycle management — pending, success, error. You can declare actions that run when navigating to a route, and any component can subscribe to them via `useAsyncData` to reflect what is happening: loading states, results, errors. No manual wiring.
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
## Layout & Typography
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
- **Action system** for async operations with lifecycle management
|
|
23
|
-
- **Resource management** with caching and request deduplication
|
|
24
|
-
- **Form validation** with custom constraints and real-time feedback
|
|
25
|
-
- **State synchronization** utilities and debugging tools
|
|
17
|
+
**`Box`** is the main layout primitive. It wraps CSS Flexbox with a friendlier API: `flex` for horizontal layout, `flex="y"` for vertical (no more guessing what `flex-direction: column` does visually). Supports `grid`, `inline`, alignment via `alignX`/`alignY`, and spacing props.
|
|
26
18
|
|
|
27
|
-
|
|
19
|
+
**`Text`** and related components (`Title`, `Paragraph`, `Code`, `Caption`) handle typography consistently across the app.
|
|
28
20
|
|
|
29
|
-
|
|
21
|
+
## Icons
|
|
30
22
|
|
|
31
|
-
|
|
32
|
-
- **Radio/RadioList, Checkbox/CheckboxList** - Selection controls with icons and custom appearances
|
|
33
|
-
- **Select, Form** - Complete form building blocks
|
|
34
|
-
- **Field validation** with constraint validation API integration
|
|
35
|
-
- **Editable components** with inline editing capabilities
|
|
23
|
+
Icons are a piece that is often missing or painful in web projects. The `Icon` component makes icons behave like text — they scale with font size, inherit color, and align naturally in any layout. No sizing hacks, no SVG wrangling.
|
|
36
24
|
|
|
37
|
-
|
|
25
|
+
## Fields & Forms
|
|
38
26
|
|
|
39
|
-
|
|
40
|
-
- **Selection system** - Multi-selection with keyboard shortcuts
|
|
41
|
-
- **Error boundaries** - Graceful error handling components
|
|
27
|
+
UI field components (`Input`, `Select`, `Checkbox`, `Radio`, etc.) accept an `action` prop — the standard way to respond to user interaction. Composing fields into forms is natural, and form submission flows through the same action system.
|
|
42
28
|
|
|
43
|
-
|
|
29
|
+
Validation goes beyond native browser constraints: custom rules, better error positioning, real-time feedback, and a UX that doesn't punish users before they've finished typing.
|
|
44
30
|
|
|
45
|
-
|
|
46
|
-
- **Details** - Collapsible content with navigation state persistence
|
|
47
|
-
- **Dialog, Viewport layouts** - Modal and full-screen layouts
|
|
48
|
-
- **Separator** - Visual content dividers
|
|
49
|
-
- **UI Transitions** - Smooth component transitions
|
|
31
|
+
## Table
|
|
50
32
|
|
|
51
|
-
|
|
33
|
+
A capable `Table` component that handles what you'd expect from a spreadsheet-like interface: column management, sorting, multi-selection with keyboard shortcuts, and more.
|
|
52
34
|
|
|
53
|
-
|
|
54
|
-
- **Code, Caption** - Specialized text displays
|
|
55
|
-
- **Icon, Image, Svg** - Graphics with built-in icon library
|
|
56
|
-
- **Badge, MessageBox** - Status and notification displays
|
|
57
|
-
- **Address** - Semantic contact information component
|
|
35
|
+
## Other
|
|
58
36
|
|
|
59
|
-
|
|
37
|
+
Dialogs, badges, details/collapsible, separators, keyboard shortcuts, popovers, copy-to-clipboard, and other utilities.
|
|
60
38
|
|
|
61
|
-
|
|
62
|
-
- **Focus management** - Accessibility-focused navigation
|
|
63
|
-
- **Callouts & popovers** - Contextual overlays and tooltips
|
|
64
|
-
- **Copy to clipboard** - One-click content copying
|
|
39
|
+
---
|
|
65
40
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```jsx
|
|
69
|
-
import { render } from "preact";
|
|
70
|
-
import { Link, Button, Box } from "@jsenv/navi";
|
|
71
|
-
|
|
72
|
-
const userSignal = signal();
|
|
73
|
-
const requestUser = async ({ id }) => {
|
|
74
|
-
const response = await fetch(`/api/users/${id}`);
|
|
75
|
-
const user = response.json();
|
|
76
|
-
userSignal.value = user;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const App = () => {
|
|
80
|
-
const user = userSignal.value;
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<Box row spacing="lg">
|
|
84
|
-
<Link href="/profile">Go to Profile</Link>
|
|
85
|
-
|
|
86
|
-
<Button
|
|
87
|
-
action={async () => {
|
|
88
|
-
await requestUser();
|
|
89
|
-
}}
|
|
90
|
-
>
|
|
91
|
-
Load User Data
|
|
92
|
-
</Button>
|
|
93
|
-
|
|
94
|
-
{user && <div>Welcome, {user.name}!</div>}
|
|
95
|
-
</Box>
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
render(<App />, document.querySelector("#root"));
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## Architecture
|
|
103
|
-
|
|
104
|
-
The framework is built around three core concepts:
|
|
105
|
-
|
|
106
|
-
1. **Signals** - Reactive state primitives that automatically update the UI
|
|
107
|
-
2. **Actions** - Async operations with built-in lifecycle management
|
|
108
|
-
3. **Components** - Composable UI building blocks with consistent APIs
|
|
109
|
-
|
|
110
|
-
This combination provides a powerful yet simple foundation for building interactive web applications that scale from simple pages to complex SPAs.
|
|
41
|
+
Named after Navi, the fairy guide from Zelda — it helps you navigate through the complexities of building modern web applications.
|