@robosophy/ui-react 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/AGENTS.md ADDED
@@ -0,0 +1,86 @@
1
+ # Robosophy UI React Agent Notes
2
+
3
+ Use `@robosophy/ui-react` before creating project-local UI components from scratch.
4
+
5
+ ## Consumer Rules
6
+
7
+ - Import shared components from `@robosophy/ui-react`.
8
+ - Read `dist/index.d.ts` when exact prop, callback, or type names are needed.
9
+ - Keep app-specific behavior in the consuming project: router pushes, stores, API calls, permissions, logout, redirects, and module switching.
10
+ - Prefer props and callback handlers over hardcoded actions inside components.
11
+ - Use render props for project-specific content when the component exposes one.
12
+ - Use PrimeReact `Button` for actions in PrimeReact apps.
13
+ - Use `RsSidebar` for module navigation.
14
+ - Use `@robosophy/tokens` CSS variables (`--rs-*`) for new styles.
15
+ - Do not duplicate `@robosophy/tokens/tokens.css` when the app already imports `@robosophy/prime-theme/prime.css`.
16
+
17
+ ## Sub-exports for selective imports
18
+
19
+ If your app does not use PrimeReact, import components individually to avoid loading PrimeReact:
20
+
21
+ ```tsx
22
+ import RsIcon from "@robosophy/ui-react/RsIcon";
23
+ import RsSidebar from "@robosophy/ui-react/RsSidebar";
24
+ ```
25
+
26
+ The main barrel (`@robosophy/ui-react`) loads all components including PrimeReact dependencies. Use sub-exports when you only need specific components without PrimeReact.
27
+
28
+ ## CSS Imports
29
+
30
+ PrimeReact apps:
31
+
32
+ ```tsx
33
+ import { PrimeReactProvider } from "primereact/api";
34
+ import RobosophyPreset from "@robosophy/prime-theme";
35
+ import "@robosophy/prime-theme/prime.css";
36
+ import "@robosophy/ui-react/styles.css";
37
+
38
+ function MyApp({ Component, pageProps }) {
39
+ return (
40
+ <PrimeReactProvider value={{ theme: { preset: RobosophyPreset } }}>
41
+ <Component {...pageProps} />
42
+ </PrimeReactProvider>
43
+ );
44
+ }
45
+ ```
46
+
47
+ Non-PrimeReact apps:
48
+
49
+ ```tsx
50
+ import "@robosophy/tokens/tokens.css";
51
+ import "@robosophy/ui-react/styles.css";
52
+ ```
53
+
54
+ Component styles are carried by the component entrypoints. Import `@robosophy/ui-react/styles.css` once in your app.
55
+
56
+ ## Next.js Integration
57
+
58
+ For Next.js apps, import CSS in your root layout:
59
+
60
+ ```tsx
61
+ // app/layout.tsx
62
+ import "@robosophy/tokens/tokens.css";
63
+ import "@robosophy/ui-react/styles.css";
64
+
65
+ export default function RootLayout({ children }) {
66
+ return (
67
+ <html>
68
+ <body>{children}</body>
69
+ </html>
70
+ );
71
+ }
72
+ ```
73
+
74
+ For the Material Symbols plugin, add it to your `next.config.js`:
75
+
76
+ ```js
77
+ // next.config.js
78
+ const { robosophyMaterialSymbols } = require("@robosophy/ui-react/vite");
79
+
80
+ module.exports = {
81
+ webpack: (config) => {
82
+ config.plugins.push(robosophyMaterialSymbols());
83
+ return config;
84
+ },
85
+ };
86
+ ```
package/README.md ADDED
@@ -0,0 +1,197 @@
1
+ # @robosophy/ui-react
2
+
3
+ React component library for shared Robosophy UI.
4
+
5
+ ## Documentation
6
+
7
+ Interactive component documentation, examples, props, and usage notes are available via Storybook:
8
+
9
+ ```sh
10
+ npm run storybook:react
11
+ ```
12
+
13
+ Then open http://localhost:6007/
14
+
15
+ ## Install
16
+
17
+ With PrimeReact:
18
+
19
+ ```sh
20
+ npm install @robosophy/ui-react @robosophy/prime-theme react react-dom primereact
21
+ ```
22
+
23
+ Without PrimeReact:
24
+
25
+ ```sh
26
+ npm install @robosophy/ui-react @robosophy/tokens react react-dom
27
+ ```
28
+
29
+ ## PrimeReact theme
30
+
31
+ If your app uses PrimeReact, configure the Robosophy preset and load its tokens/overrides once:
32
+
33
+ ```tsx
34
+ // app/layout.tsx or pages/_app.tsx
35
+ import { PrimeReactProvider } from "primereact/api";
36
+ import RobosophyPreset from "@robosophy/prime-theme";
37
+ import "@robosophy/prime-theme/prime.css";
38
+ import "@robosophy/ui-react/styles.css";
39
+
40
+ function MyApp({ Component, pageProps }) {
41
+ return (
42
+ <PrimeReactProvider value={{ theme: { preset: RobosophyPreset } }}>
43
+ <Component {...pageProps} />
44
+ </PrimeReactProvider>
45
+ );
46
+ }
47
+ ```
48
+
49
+ `prime.css` already imports `@robosophy/tokens/tokens.css`, so don't duplicate that import.
50
+
51
+ If your app doesn't use PrimeReact, import tokens once:
52
+
53
+ ```tsx
54
+ import "@robosophy/tokens/tokens.css";
55
+ import "@robosophy/ui-react/styles.css";
56
+ ```
57
+
58
+ Components carry their own local styles through their component entrypoint.
59
+
60
+ ## AI agent context
61
+
62
+ For agents working inside a consuming project, read these package files first:
63
+
64
+ - `node_modules/@robosophy/ui-react/AGENTS.md`: short rules for prioritizing Robosophy components.
65
+ - `node_modules/@robosophy/ui-react/dist/index.d.ts`: exact exported types and component contracts.
66
+
67
+ Use `@robosophy/ui-react` components before creating local equivalents. Keep router, stores, fetches, permissions, and logout in the consuming app.
68
+
69
+ ## Usage
70
+
71
+ ```tsx
72
+ import { RsIcon, RsSidebar, rsPrimeIcon } from "@robosophy/ui-react";
73
+ import type { RsSidebarItem, RsSidebarModule } from "@robosophy/ui-react";
74
+
75
+ const sidebarItems: RsSidebarItem[] = [
76
+ { id: "dashboard", label: "Dashboard", icon: "dashboard", active: true },
77
+ { id: "settings", label: "Configuracion", icon: "settings" },
78
+ ];
79
+
80
+ const sidebarModules: RsSidebarModule[] = [
81
+ { text: "Mi Alta", link: "/alta" },
82
+ { text: "Mi Cuenta y Orden", link: "/cyo", active: true },
83
+ { text: "Mi Cuenta Corriente", link: "/cc" },
84
+ ];
85
+
86
+ function App() {
87
+ const handleItemClick = (item: RsSidebarItem) => {
88
+ console.log("Item clicked:", item);
89
+ };
90
+
91
+ const handleModuleSelect = (module: RsSidebarModule) => {
92
+ console.log("Module selected:", module);
93
+ };
94
+
95
+ return (
96
+ <>
97
+ <RsSidebar
98
+ items={sidebarItems}
99
+ modules={sidebarModules}
100
+ navigateOnModuleSelect={false}
101
+ onItemClick={handleItemClick}
102
+ onModuleSelect={handleModuleSelect}
103
+ />
104
+
105
+ <RsIcon name="home" />
106
+ </>
107
+ );
108
+ }
109
+ ```
110
+
111
+ ## Material Symbols
112
+
113
+ `RsIcon` renders inline SVG icons. Combine it with the Vite plugin that downloads only the necessary SVGs from the official Google repository and generates a sprite injected into the HTML:
114
+
115
+ ```ts
116
+ // vite.config.ts
117
+ import { defineConfig } from "vite";
118
+ import react from "@vitejs/plugin-react";
119
+ import { robosophyMaterialSymbols } from "@robosophy/ui-react/vite";
120
+
121
+ export default defineConfig({
122
+ plugins: [
123
+ react(),
124
+ robosophyMaterialSymbols(),
125
+ ],
126
+ });
127
+ ```
128
+
129
+ The plugin automatically scans for `<RsIcon name="..." />`, `rsPrimeIcon("...")`, and objects with `icon: "..."` in the source code. No need to declare icons manually. During build, it downloads SVGs from the GitHub CDN, caches them locally, and generates an inline SVG sprite. No font files are loaded.
130
+
131
+ The sprite includes variants for fill (outlined/filled) and grade (-25, 0, 200).
132
+
133
+ ### Dynamic icons (optional)
134
+
135
+ If an icon is calculated at runtime (API, permissions, remote config, etc.), declare it in `include` so the scanner includes it:
136
+
137
+ ```ts
138
+ robosophyMaterialSymbols({
139
+ include: [
140
+ "home",
141
+ { family: "rounded", name: "settings" },
142
+ ],
143
+ });
144
+ ```
145
+
146
+ ### PrimeReact
147
+
148
+ For PrimeReact APIs that receive `icon` as a string, use the helper:
149
+
150
+ ```tsx
151
+ import { Button } from "primereact/button";
152
+ import { rsPrimeIcon } from "@robosophy/ui-react";
153
+
154
+ <Button label="Inicio" icon={rsPrimeIcon("home")} />
155
+ <Button label="Configurar" icon={rsPrimeIcon("settings", { family: "rounded" })} />
156
+ ```
157
+
158
+ For full control over props (fill, grade, etc.), use the `icon` slot:
159
+
160
+ ```tsx
161
+ import { Button } from "primereact/button";
162
+ import { RsIcon } from "@robosophy/ui-react";
163
+
164
+ <Button label="Favorito" icon={<RsIcon name="favorite" fill color="danger" />} />
165
+ ```
166
+
167
+ ## Component Structure
168
+
169
+ Every public component must be self-contained:
170
+
171
+ ```txt
172
+ src/components/RsSidebar/
173
+ RsSidebar.tsx
174
+ RsSidebar.css
175
+ RsSidebar.types.ts
176
+ RsSidebar.test.tsx
177
+ RsSidebar.stories.tsx
178
+ index.ts
179
+ ```
180
+
181
+ Rules:
182
+
183
+ - use `@robosophy/tokens` variables for visual decisions;
184
+ - keep styles local to the component folder;
185
+ - add tests and Storybook stories with every exported component;
186
+ - use props for stable API and render props for flexible project content;
187
+ - use PrimeReact only when it provides behavior that belongs inside the component.
188
+ - use PrimeReact `Button` for actions in PrimeReact apps.
189
+ - use `RsSidebar` for reusable module navigation instead of project-local navbars.
190
+
191
+ ## Scripts
192
+
193
+ ```sh
194
+ npm run build -w @robosophy/ui-react
195
+ npm run test -w @robosophy/ui-react
196
+ npm run build:storybook -w @robosophy/ui-react
197
+ ```
@@ -0,0 +1,23 @@
1
+ type RsIconFamily = "outlined" | "rounded" | "sharp";
2
+ type RsIconSize = "sm" | "md" | "lg" | number;
3
+ type RsIconColor = "primary" | "secondary" | "success" | "warning" | "danger" | "inherit" | (string & {});
4
+ type RsIconWeight = 100 | 200 | 300 | 400 | 500 | 600 | 700;
5
+ type RsIconProps = {
6
+ name: string;
7
+ family?: RsIconFamily;
8
+ size?: RsIconSize;
9
+ color?: RsIconColor;
10
+ fill?: boolean;
11
+ weight?: RsIconWeight;
12
+ grade?: number;
13
+ interactive?: boolean;
14
+ ariaLabel?: string;
15
+ notification?: boolean;
16
+ notificationColor?: string;
17
+ className?: string;
18
+ };
19
+ type RsPrimeIconOptions = {
20
+ family?: RsIconFamily;
21
+ };
22
+
23
+ export type { RsIconColor as R, RsIconFamily as a, RsIconProps as b, RsIconSize as c, RsIconWeight as d, RsPrimeIconOptions as e };