@roxyapi/ui 0.3.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/AGENTS.md +228 -29
- package/README.md +291 -19
- package/dist/cdn/components/ashtakavarga-grid.js +74 -19
- package/dist/cdn/components/ashtakavarga-grid.js.map +2 -2
- package/dist/cdn/components/biorhythm-chart.js +18 -4
- package/dist/cdn/components/biorhythm-chart.js.map +2 -2
- package/dist/cdn/components/choghadiya-grid.js +47 -12
- package/dist/cdn/components/choghadiya-grid.js.map +3 -3
- package/dist/cdn/components/compatibility-card.js +21 -7
- package/dist/cdn/components/compatibility-card.js.map +2 -2
- package/dist/cdn/components/dasha-timeline.js +113 -28
- package/dist/cdn/components/dasha-timeline.js.map +3 -3
- package/dist/cdn/components/data.js +27 -13
- package/dist/cdn/components/data.js.map +2 -2
- package/dist/cdn/components/divisional-chart.js +225 -118
- package/dist/cdn/components/divisional-chart.js.map +4 -4
- package/dist/cdn/components/dosha-card.js +18 -4
- package/dist/cdn/components/dosha-card.js.map +2 -2
- package/dist/cdn/components/endpoint-form.js +25 -11
- package/dist/cdn/components/endpoint-form.js.map +2 -2
- package/dist/cdn/components/guna-milan.js +20 -6
- package/dist/cdn/components/guna-milan.js.map +2 -2
- package/dist/cdn/components/hexagram.js +22 -8
- package/dist/cdn/components/hexagram.js.map +2 -2
- package/dist/cdn/components/horoscope-card.js +20 -6
- package/dist/cdn/components/horoscope-card.js.map +2 -2
- package/dist/cdn/components/kp-chart.js +19 -5
- package/dist/cdn/components/kp-chart.js.map +2 -2
- package/dist/cdn/components/kp-planets-table.js +17 -3
- package/dist/cdn/components/kp-planets-table.js.map +2 -2
- package/dist/cdn/components/kp-ruling-planets.js +17 -3
- package/dist/cdn/components/kp-ruling-planets.js.map +2 -2
- package/dist/cdn/components/location-search.js +18 -4
- package/dist/cdn/components/location-search.js.map +2 -2
- package/dist/cdn/components/moon-phase.js +27 -13
- package/dist/cdn/components/moon-phase.js.map +2 -2
- package/dist/cdn/components/nakshatra-card.js +16 -2
- package/dist/cdn/components/nakshatra-card.js.map +2 -2
- package/dist/cdn/components/natal-chart.js +79 -40
- package/dist/cdn/components/natal-chart.js.map +3 -3
- package/dist/cdn/components/numerology-card.js +18 -4
- package/dist/cdn/components/numerology-card.js.map +2 -2
- package/dist/cdn/components/panchang-table.js +53 -25
- package/dist/cdn/components/panchang-table.js.map +3 -3
- package/dist/cdn/components/shadbala-table.js +24 -10
- package/dist/cdn/components/shadbala-table.js.map +2 -2
- package/dist/cdn/components/synastry-chart.js +96 -48
- package/dist/cdn/components/synastry-chart.js.map +3 -3
- package/dist/cdn/components/tarot-card.js +17 -3
- package/dist/cdn/components/tarot-card.js.map +2 -2
- package/dist/cdn/components/tarot-spread.js +39 -25
- package/dist/cdn/components/tarot-spread.js.map +2 -2
- package/dist/cdn/components/transits-table.js +18 -4
- package/dist/cdn/components/transits-table.js.map +2 -2
- package/dist/cdn/components/vedic-kundli.js +215 -105
- package/dist/cdn/components/vedic-kundli.js.map +4 -4
- package/dist/cdn/components/vedic-planets-table.js +22 -8
- package/dist/cdn/components/vedic-planets-table.js.map +2 -2
- package/dist/cdn/components/western-planets-table.js +18 -4
- package/dist/cdn/components/western-planets-table.js.map +2 -2
- package/dist/cdn/components/yoga-list.js +17 -3
- package/dist/cdn/components/yoga-list.js.map +2 -2
- package/dist/cdn/roxy-ui.js +1082 -816
- package/dist/cdn/roxy-ui.js.map +4 -4
- package/dist/components/ashtakavarga-grid.d.ts +13 -1
- package/dist/components/ashtakavarga-grid.d.ts.map +1 -1
- package/dist/components/ashtakavarga-grid.js +86 -11
- package/dist/components/ashtakavarga-grid.js.map +2 -2
- package/dist/components/biorhythm-chart.js +14 -0
- package/dist/components/biorhythm-chart.js.map +2 -2
- package/dist/components/choghadiya-grid.d.ts +6 -0
- package/dist/components/choghadiya-grid.d.ts.map +1 -1
- package/dist/components/choghadiya-grid.js +50 -2
- package/dist/components/choghadiya-grid.js.map +2 -2
- package/dist/components/compatibility-card.js +14 -0
- package/dist/components/compatibility-card.js.map +2 -2
- package/dist/components/dasha-timeline.d.ts +10 -0
- package/dist/components/dasha-timeline.d.ts.map +1 -1
- package/dist/components/dasha-timeline.js +135 -4
- package/dist/components/dasha-timeline.js.map +2 -2
- package/dist/components/data.js +14 -0
- package/dist/components/data.js.map +2 -2
- package/dist/components/divisional-chart.d.ts +9 -6
- package/dist/components/divisional-chart.d.ts.map +1 -1
- package/dist/components/divisional-chart.js +546 -251
- package/dist/components/divisional-chart.js.map +4 -4
- package/dist/components/dosha-card.js +14 -0
- package/dist/components/dosha-card.js.map +2 -2
- package/dist/components/endpoint-form.js +14 -0
- package/dist/components/endpoint-form.js.map +2 -2
- package/dist/components/guna-milan.js +14 -0
- package/dist/components/guna-milan.js.map +2 -2
- package/dist/components/hexagram.js +14 -0
- package/dist/components/hexagram.js.map +2 -2
- package/dist/components/horoscope-card.js +14 -0
- package/dist/components/horoscope-card.js.map +2 -2
- package/dist/components/kp-chart.js +14 -0
- package/dist/components/kp-chart.js.map +2 -2
- package/dist/components/kp-planets-table.js +14 -0
- package/dist/components/kp-planets-table.js.map +2 -2
- package/dist/components/kp-ruling-planets.js +14 -0
- package/dist/components/kp-ruling-planets.js.map +2 -2
- package/dist/components/location-search.js +14 -0
- package/dist/components/location-search.js.map +2 -2
- package/dist/components/moon-phase.js +14 -0
- package/dist/components/moon-phase.js.map +2 -2
- package/dist/components/nakshatra-card.js +14 -0
- package/dist/components/nakshatra-card.js.map +2 -2
- package/dist/components/natal-chart.d.ts.map +1 -1
- package/dist/components/natal-chart.js +76 -6
- package/dist/components/natal-chart.js.map +2 -2
- package/dist/components/numerology-card.js +14 -0
- package/dist/components/numerology-card.js.map +2 -2
- package/dist/components/panchang-table.d.ts +1 -0
- package/dist/components/panchang-table.d.ts.map +1 -1
- package/dist/components/panchang-table.js +37 -1
- package/dist/components/panchang-table.js.map +2 -2
- package/dist/components/shadbala-table.js +14 -0
- package/dist/components/shadbala-table.js.map +2 -2
- package/dist/components/synastry-chart.d.ts +6 -0
- package/dist/components/synastry-chart.d.ts.map +1 -1
- package/dist/components/synastry-chart.js +106 -7
- package/dist/components/synastry-chart.js.map +2 -2
- package/dist/components/tarot-card.js +14 -0
- package/dist/components/tarot-card.js.map +2 -2
- package/dist/components/tarot-spread.js +14 -0
- package/dist/components/tarot-spread.js.map +2 -2
- package/dist/components/transits-table.js +14 -0
- package/dist/components/transits-table.js.map +2 -2
- package/dist/components/vedic-kundli.d.ts +14 -9
- package/dist/components/vedic-kundli.d.ts.map +1 -1
- package/dist/components/vedic-kundli.js +537 -245
- package/dist/components/vedic-kundli.js.map +4 -4
- package/dist/components/vedic-planets-table.js +14 -0
- package/dist/components/vedic-planets-table.js.map +2 -2
- package/dist/components/western-planets-table.js +14 -0
- package/dist/components/western-planets-table.js.map +2 -2
- package/dist/components/yoga-list.js +14 -0
- package/dist/components/yoga-list.js.map +2 -2
- package/dist/index.cjs +1397 -797
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +1278 -678
- package/dist/index.js.map +4 -4
- package/dist/styles/tokens.css +8 -23
- package/dist/utils/base-styles.d.ts.map +1 -1
- package/dist/utils/kundli-render.d.ts +43 -104
- package/dist/utils/kundli-render.d.ts.map +1 -1
- package/dist/utils/kundli-styles.d.ts +13 -0
- package/dist/utils/kundli-styles.d.ts.map +1 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/ashtakavarga-grid.ts +73 -11
- package/src/components/choghadiya-grid.ts +37 -2
- package/src/components/dasha-timeline.ts +135 -4
- package/src/components/divisional-chart.ts +40 -97
- package/src/components/natal-chart.ts +89 -6
- package/src/components/panchang-table.ts +34 -1
- package/src/components/synastry-chart.ts +84 -8
- package/src/components/vedic-kundli.ts +35 -95
- package/src/styles/tokens.css +8 -23
- package/src/utils/base-styles.ts +14 -0
- package/src/utils/kundli-render.ts +609 -270
- package/src/utils/kundli-styles.ts +124 -0
- package/src/version.ts +1 -1
package/AGENTS.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# AGENTS.md
|
|
2
2
|
|
|
3
|
-
This file teaches AI coding agents (Claude Code, Cursor, Copilot, Codex, Gemini CLI) how to use Roxy UI when integrating RoxyAPI into a project.
|
|
3
|
+
This file teaches AI coding agents (Claude Code, Cursor, Copilot, Codex, Gemini CLI, and any MCP-compatible client) how to use Roxy UI when integrating RoxyAPI into a project.
|
|
4
|
+
|
|
5
|
+
This file ships inside both `@roxyapi/ui` and `@roxyapi/ui-react` on npm. After install, read it at `node_modules/@roxyapi/ui/AGENTS.md`.
|
|
6
|
+
|
|
7
|
+
Live preview: <https://roxyapi.github.io/ui/>. Source of truth for component types: the OpenAPI spec at `roxyapi.com/openapi.json`, regenerated into `packages/ui/src/types/types.gen.ts`.
|
|
4
8
|
|
|
5
9
|
## Identity
|
|
6
10
|
|
|
@@ -8,7 +12,36 @@ Roxy UI is the official web component library for the RoxyAPI catalog. Component
|
|
|
8
12
|
|
|
9
13
|
## Decision tree for picking a component
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
### Pick by user phrase
|
|
16
|
+
|
|
17
|
+
Map the natural-language request to a component first; fall back to the table below if the request names a specific endpoint.
|
|
18
|
+
|
|
19
|
+
| If the user says... | Render |
|
|
20
|
+
|---|---|
|
|
21
|
+
| "daily horoscope for `{sign}`", "weekly horoscope", "monthly horoscope" | `<roxy-horoscope-card>` |
|
|
22
|
+
| "birth chart", "natal chart", "Western chart", "show me my planets" | `<roxy-natal-chart>` |
|
|
23
|
+
| "match two birth charts", "compare us in Western astrology", "synastry" | `<roxy-synastry-chart>` |
|
|
24
|
+
| "kundli", "Vedic chart", "rashi chart", "South/North Indian chart" | `<roxy-vedic-kundli>` |
|
|
25
|
+
| "kundli matching", "Guna Milan", "match for marriage", "36-point compatibility" | `<roxy-guna-milan>` |
|
|
26
|
+
| "are we compatible", "compatibility score", "love score" (cross-domain) | `<roxy-compatibility-card>` |
|
|
27
|
+
| "panchang for today", "tithi", "nakshatra", "muhurta", "auspicious times" | `<roxy-panchang-table>` |
|
|
28
|
+
| "dasha", "mahadasha", "current planetary period", "Vimshottari" | `<roxy-dasha-timeline>` |
|
|
29
|
+
| "manglik", "kalsarpa", "sadhesati", "any doshas in my chart" | `<roxy-dosha-card>` |
|
|
30
|
+
| "KP planets", "sub-lord", "Krishnamurti" | `<roxy-kp-planets-table>` |
|
|
31
|
+
| "life path number", "expression number", "personal year", "numerology chart" | `<roxy-numerology-card>` |
|
|
32
|
+
| "draw a tarot card", "card of the day", "card meaning" | `<roxy-tarot-card>` |
|
|
33
|
+
| "tarot reading", "three-card spread", "Celtic Cross", "yes or no tarot" | `<roxy-tarot-spread>` |
|
|
34
|
+
| "biorhythm", "physical/emotional/intellectual cycle", "critical days" | `<roxy-biorhythm-chart>` |
|
|
35
|
+
| "I Ching", "hexagram", "cast the coins", "Book of Changes" | `<roxy-hexagram>` |
|
|
36
|
+
| "moon phase", "moon calendar", "next full moon", "current moon" | `<roxy-moon-phase>` |
|
|
37
|
+
| "search a city", "geocode", "lat/long for a place" | `<roxy-location-search>` |
|
|
38
|
+
| "build a form for endpoint X" | `<roxy-endpoint-form>` |
|
|
39
|
+
|
|
40
|
+
**Fallback rule.** If the response shape does not match any component above, render with `<roxy-data>`. It accepts any RoxyAPI response and produces a structured layout from the JSON.
|
|
41
|
+
|
|
42
|
+
### Endpoint reference
|
|
43
|
+
|
|
44
|
+
Use the table below for the formal endpoint to component mapping.
|
|
12
45
|
|
|
13
46
|
<!-- BEGIN:COMPONENTS -->
|
|
14
47
|
| Element | Domain | Endpoint(s) | What it renders |
|
|
@@ -45,6 +78,100 @@ Use the table below. Match the user request against the endpoint, render the mat
|
|
|
45
78
|
| `<roxy-data>` | Helper | Any response shape | Generic fallback renderer for unknown shapes |
|
|
46
79
|
<!-- END:COMPONENTS -->
|
|
47
80
|
|
|
81
|
+
## Common integration bugs (read this first)
|
|
82
|
+
|
|
83
|
+
These are the bugs that come up over and over. Read this section before writing the first line of integration code.
|
|
84
|
+
|
|
85
|
+
### 1. Envelope not unwrapped
|
|
86
|
+
|
|
87
|
+
The `@roxyapi/sdk` returns `{ data, error, request, response }`. **Always destructure `data` before passing to a component.** Passing the full envelope renders `[object Object]`. This is the single most common integration bug.
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
// Wrong: passes the envelope
|
|
91
|
+
const response = await roxy.astrology.generateNatalChart({ body });
|
|
92
|
+
element.data = response; // → renders [object Object]
|
|
93
|
+
|
|
94
|
+
// Right: unwrap data
|
|
95
|
+
const { data } = await roxy.astrology.generateNatalChart({ body });
|
|
96
|
+
element.data = data;
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Every snippet below follows this rule.
|
|
100
|
+
|
|
101
|
+
### 2. Hardcoded coordinates
|
|
102
|
+
|
|
103
|
+
Every chart endpoint (Western, Vedic, KP, synastry, transits, dasha, dosha, panchang) needs `latitude`, `longitude`, and `timezone`. Never ask the user to type coordinates. Call `/location/search` first, then feed the result into the chart endpoint.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
// Right
|
|
107
|
+
const { data: cities } = await roxy.location.searchCities({ query: { q: 'Mumbai' } });
|
|
108
|
+
const { latitude, longitude, timezone } = cities.cities[0];
|
|
109
|
+
const { data: chart } = await roxy.astrology.generateNatalChart({
|
|
110
|
+
body: { date, time, latitude, longitude, timezone },
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 3. Timezone format inconsistency
|
|
115
|
+
|
|
116
|
+
Every chart endpoint accepts `timezone` as either a decimal-hour offset (`5.5` for IST, `-5` for EST) or an IANA name (`'Asia/Kolkata'`, `'America/New_York'`). The decimal form is what `/location/search` returns; the IANA form is correct over DST boundaries. Pick one and stay consistent in a single integration. Mixing them does not break the API but makes the bug surface area larger.
|
|
117
|
+
|
|
118
|
+
### 4. Secret key in the browser
|
|
119
|
+
|
|
120
|
+
There are two key classes. **Secret keys are unprefixed** and grant full access; they belong server-side only (Node, Bun, Hono, Next.js route handlers, Workers, Edge functions). **Publishable keys** are prefixed `pk_live_*` or `pk_test_*` and are safe in the browser; they are locked to an origin allowlist at the API gateway. For widgets, embeds, vanilla HTML, and `data-publishable-key` use the publishable key. For the typed SDK on a server, use the secret key.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
// Server (Next.js route handler, Workers, Bun): secret key
|
|
124
|
+
const roxy = createRoxy(process.env.ROXY_API_KEY!);
|
|
125
|
+
|
|
126
|
+
// Browser (widgets auto-mount): publishable key
|
|
127
|
+
<div data-roxy-widget="natal-chart" data-publishable-key="pk_live_xxx" ...></div>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 5. Missing `'use client'` in Next.js App Router
|
|
131
|
+
|
|
132
|
+
The React components in `@roxyapi/ui-react` mount Custom Elements, which need the DOM. In the App Router, files that import them must declare `'use client'` at the top. Server Components can fetch with the SDK; the client component renders.
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
// app/chart-view.tsx
|
|
136
|
+
'use client';
|
|
137
|
+
import { RoxyNatalChart } from '@roxyapi/ui-react';
|
|
138
|
+
|
|
139
|
+
export default function ChartView({ data }) {
|
|
140
|
+
return <RoxyNatalChart data={data} />;
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 6. React 17 or 18 swallowing custom events
|
|
145
|
+
|
|
146
|
+
React 19 routes hyphenated DOM events through camelCase props correctly. React 17 and 18 do not. On 17/18, attach the listener with a ref:
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
const ref = useRef<HTMLElement>(null);
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
const el = ref.current;
|
|
152
|
+
if (!el) return;
|
|
153
|
+
const handler = (e: Event) => setData((e as CustomEvent).detail);
|
|
154
|
+
el.addEventListener('roxy-location-select', handler);
|
|
155
|
+
return () => el.removeEventListener('roxy-location-select', handler);
|
|
156
|
+
}, []);
|
|
157
|
+
|
|
158
|
+
return <roxy-location-search ref={ref} />;
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
The React 19 path is `<RoxyLocationSearch onRoxyLocationSelect={handler} />`.
|
|
162
|
+
|
|
163
|
+
### 7. Local response interface drift
|
|
164
|
+
|
|
165
|
+
Do not declare `interface XyzData { ... }` for a RoxyAPI response. Import the spec-derived type from `@roxyapi/sdk` (or let the SDK return type flow through inference). Local interfaces drift the moment the spec changes; the component will keep compiling while rendering nothing.
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
// Wrong
|
|
169
|
+
interface NatalChart { planets: ...; houses: ...; }
|
|
170
|
+
|
|
171
|
+
// Right
|
|
172
|
+
import type { NatalChartResponse } from '@roxyapi/sdk';
|
|
173
|
+
```
|
|
174
|
+
|
|
48
175
|
## Integration patterns
|
|
49
176
|
|
|
50
177
|
### Pattern 1: vanilla HTML, no build step
|
|
@@ -58,18 +185,11 @@ Use the table below. Match the user request against the endpoint, render the mat
|
|
|
58
185
|
<roxy-natal-chart id="chart"></roxy-natal-chart>
|
|
59
186
|
|
|
60
187
|
<script type="module">
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
body:
|
|
65
|
-
date: '1990-01-15',
|
|
66
|
-
time: '14:30:00',
|
|
67
|
-
latitude: 28.6139,
|
|
68
|
-
longitude: 77.209,
|
|
69
|
-
timezone: 5.5,
|
|
70
|
-
}),
|
|
188
|
+
import { createRoxy } from 'https://cdn.jsdelivr.net/npm/@roxyapi/sdk@latest/dist/factory.js';
|
|
189
|
+
const roxy = createRoxy('pk_live_xxx');
|
|
190
|
+
const { data } = await roxy.astrology.generateNatalChart({
|
|
191
|
+
body: { date: '1990-01-15', time: '14:30:00', latitude: 28.6139, longitude: 77.209, timezone: 5.5 },
|
|
71
192
|
});
|
|
72
|
-
const data = await res.json();
|
|
73
193
|
document.getElementById('chart').data = data;
|
|
74
194
|
</script>
|
|
75
195
|
```
|
|
@@ -77,25 +197,33 @@ Use the table below. Match the user request against the endpoint, render the mat
|
|
|
77
197
|
### Pattern 2: React, with the typed SDK
|
|
78
198
|
|
|
79
199
|
```tsx
|
|
200
|
+
'use client';
|
|
201
|
+
|
|
80
202
|
import { createRoxy } from '@roxyapi/sdk';
|
|
81
|
-
import {
|
|
203
|
+
import {
|
|
204
|
+
RoxyNatalChart,
|
|
205
|
+
RoxyLocationSearch,
|
|
206
|
+
type RoxyNatalChartProps,
|
|
207
|
+
} from '@roxyapi/ui-react';
|
|
82
208
|
import { useState } from 'react';
|
|
83
209
|
|
|
84
210
|
const roxy = createRoxy(process.env.NEXT_PUBLIC_ROXY_API_KEY!);
|
|
85
211
|
|
|
86
212
|
export function BirthChartView() {
|
|
87
|
-
const [chart, setChart] = useState(
|
|
213
|
+
const [chart, setChart] = useState<RoxyNatalChartProps['data']>(undefined);
|
|
88
214
|
|
|
89
|
-
const onLocationSelect = async (e: CustomEvent<{ latitude
|
|
215
|
+
const onLocationSelect = async (e: CustomEvent<{ latitude?: number; longitude?: number; timezone?: number | string }>) => {
|
|
216
|
+
const { latitude, longitude, timezone } = e.detail;
|
|
217
|
+
if (latitude == null || longitude == null) return;
|
|
90
218
|
const { data } = await roxy.astrology.generateNatalChart({
|
|
91
|
-
body: { date: '1990-01-15', time: '14:30:00',
|
|
219
|
+
body: { date: '1990-01-15', time: '14:30:00', latitude, longitude, timezone },
|
|
92
220
|
});
|
|
93
221
|
setChart(data);
|
|
94
222
|
};
|
|
95
223
|
|
|
96
224
|
return (
|
|
97
225
|
<div>
|
|
98
|
-
<RoxyLocationSearch
|
|
226
|
+
<RoxyLocationSearch onRoxyLocationSelect={onLocationSelect} />
|
|
99
227
|
{chart && <RoxyNatalChart data={chart} />}
|
|
100
228
|
</div>
|
|
101
229
|
);
|
|
@@ -114,15 +242,12 @@ export function BirthChartView() {
|
|
|
114
242
|
></roxy-endpoint-form>
|
|
115
243
|
|
|
116
244
|
<script type="module">
|
|
245
|
+
import { createRoxy } from 'https://cdn.jsdelivr.net/npm/@roxyapi/sdk@latest/dist/factory.js';
|
|
246
|
+
const roxy = createRoxy('pk_live_xxx');
|
|
117
247
|
const form = document.querySelector('roxy-endpoint-form');
|
|
118
248
|
form.addEventListener('roxy-submit', async (e) => {
|
|
119
|
-
const {
|
|
120
|
-
const
|
|
121
|
-
method: 'POST',
|
|
122
|
-
headers: { 'Content-Type': 'application/json', 'X-API-Key': 'roxy_xxx' },
|
|
123
|
-
body: JSON.stringify(values),
|
|
124
|
-
});
|
|
125
|
-
const kundli = await res.json();
|
|
249
|
+
const { values } = e.detail;
|
|
250
|
+
const { data: kundli } = await roxy.vedicAstrology.generateBirthChart({ body: values });
|
|
126
251
|
document.querySelector('roxy-vedic-kundli').data = kundli;
|
|
127
252
|
});
|
|
128
253
|
</script>
|
|
@@ -130,7 +255,7 @@ export function BirthChartView() {
|
|
|
130
255
|
|
|
131
256
|
### Pattern 4: widgets auto-mount (no JavaScript wiring)
|
|
132
257
|
|
|
133
|
-
Use
|
|
258
|
+
Use a publishable key (`pk_live_*` or `pk_test_*`) for client-side embeds. Get one at <https://roxyapi.com/account>. Publishable keys are origin-restricted at the API gateway. Register the customer domain (e.g. `https://customer.com`) when creating the key, and the gateway will reject requests from any other origin. Never use a secret key in client-side code (secret keys are unprefixed and live server-side only).
|
|
134
259
|
|
|
135
260
|
```html
|
|
136
261
|
<script
|
|
@@ -151,14 +276,84 @@ Use the publishable key flow for vibecoder embeds.
|
|
|
151
276
|
|
|
152
277
|
The auto-mount script reads `data-*` attributes, calls the matching endpoint, and renders the matching component.
|
|
153
278
|
|
|
279
|
+
### Pattern 5: MCP tool-call response
|
|
280
|
+
|
|
281
|
+
A remote MCP server at `roxyapi.com/mcp/{domain}` exposes each RoxyAPI endpoint as an MCP tool. The JSON returned by the tool call has the same shape as the SDK response. Pass it straight into the matching component.
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
// Pseudocode for any MCP-aware agent
|
|
285
|
+
const result = await mcp.call('roxyapi.astrology.generate_natal_chart', {
|
|
286
|
+
date: '1990-01-15', time: '14:30:00', latitude: 28.6139, longitude: 77.209, timezone: 5.5,
|
|
287
|
+
});
|
|
288
|
+
document.querySelector('roxy-natal-chart').data = result;
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
No field renames. No glue code. Use the decision tree above to pick the component for any tool.
|
|
292
|
+
|
|
293
|
+
### Pattern 6: Next.js RSC streaming
|
|
294
|
+
|
|
295
|
+
Server fetches with the secret key, client renders with the React component. The API key never crosses the network.
|
|
296
|
+
|
|
297
|
+
```tsx
|
|
298
|
+
// app/page.tsx (Server Component)
|
|
299
|
+
import { createRoxy } from '@roxyapi/sdk';
|
|
300
|
+
import BirthChartView from './birth-chart-view';
|
|
301
|
+
|
|
302
|
+
const roxy = createRoxy(process.env.ROXY_API_KEY!);
|
|
303
|
+
|
|
304
|
+
export default async function Page() {
|
|
305
|
+
const { data } = await roxy.vedicAstrology.generateBirthChart({
|
|
306
|
+
body: { date: '1990-01-15', time: '14:30:00', latitude: 28.6139, longitude: 77.209, timezone: 5.5 },
|
|
307
|
+
});
|
|
308
|
+
return <BirthChartView data={data} />;
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
```tsx
|
|
313
|
+
// app/birth-chart-view.tsx (Client Component)
|
|
314
|
+
'use client';
|
|
315
|
+
import { RoxyVedicKundli } from '@roxyapi/ui-react';
|
|
316
|
+
|
|
317
|
+
export default function BirthChartView({ data }: { data: unknown }) {
|
|
318
|
+
return <RoxyVedicKundli data={data} />;
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## Theming and dark mode
|
|
323
|
+
|
|
324
|
+
Components react to three signals in priority order. No events to dispatch. No JS bridge to write.
|
|
325
|
+
|
|
326
|
+
| Signal | Where | Effect |
|
|
327
|
+
|---|---|---|
|
|
328
|
+
| `prefers-color-scheme: dark` | OS | Default. Follows user system setting. |
|
|
329
|
+
| `data-theme="light"` or `data-theme="dark"` | `<html>` / `<body>` / any ancestor / the component itself | Wins over OS. Per-element override scope works. |
|
|
330
|
+
| `.dark` class | Any ancestor | Equivalent to `data-theme="dark"`. Use when the host stack already ships a `.dark` toggle (Tailwind, shadcn). |
|
|
331
|
+
|
|
332
|
+
To toggle at runtime:
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
document.documentElement.dataset.theme = 'dark'; // or 'light'
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
That single line re-themes every Roxy UI component on the page. Persist user choice in `localStorage` from your own code; the library does not own preferences.
|
|
339
|
+
|
|
340
|
+
Per-element scope is supported:
|
|
341
|
+
|
|
342
|
+
```html
|
|
343
|
+
<roxy-natal-chart data-theme="dark" .data=${chart}></roxy-natal-chart>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Every visible aspect of the chart is driven by `--roxy-*` CSS custom properties on `:host`. Override any token on `:root`, on `:host`, or per element. Do not write Tailwind utility classes inside the components; the Shadow DOM boundary stops them at the door.
|
|
347
|
+
|
|
154
348
|
## Rules every agent must follow
|
|
155
349
|
|
|
156
350
|
- Always call `/location/search` first before any chart endpoint that takes latitude, longitude, or timezone. Use `<roxy-location-search>` for the input UI.
|
|
157
351
|
- Pass the response object directly. Components are stateless; they do not fetch internally except for `<roxy-location-search>`, `<roxy-endpoint-form>`, and the widgets auto-mount script.
|
|
158
352
|
- Use the typed SDK from `@roxyapi/sdk` so prop shapes match the spec automatically.
|
|
159
|
-
- Theming is CSS custom properties on `:root` or per element. Do not write Tailwind classes inside the components; the shadow DOM ignores them.
|
|
353
|
+
- Theming is CSS custom properties on `:root` or per element. Switch light and dark via `data-theme` on any ancestor (see the table above). Do not write Tailwind classes inside the components; the shadow DOM ignores them.
|
|
160
354
|
- Honor reduced motion. The library already respects `prefers-reduced-motion: reduce` and the `--roxy-motion-duration` variable.
|
|
161
355
|
- A11y violations are CI failures. Do not paste over `role` or `aria-*` attributes; the components emit them correctly already.
|
|
356
|
+
- Component types come from the OpenAPI spec via `@hey-api/openapi-ts`. Do not redefine response shapes locally; if a field is missing, fix the spec, regenerate, propagate.
|
|
162
357
|
|
|
163
358
|
## Domain ordering
|
|
164
359
|
|
|
@@ -166,10 +361,14 @@ When listing domains in user-visible copy, use the canonical order: Western astr
|
|
|
166
361
|
|
|
167
362
|
## What not to ship
|
|
168
363
|
|
|
169
|
-
- Do not bundle `@roxyapi/ui` and `@roxyapi/ui-react` together; they
|
|
364
|
+
- Do not bundle `@roxyapi/ui` and `@roxyapi/ui-react` together; they ship independently.
|
|
170
365
|
- Use `@roxyapi/ui-react` for React projects. Use `@roxyapi/ui` directly elsewhere.
|
|
171
366
|
- Do not write your own kundli component. The lifted layout in `<roxy-vedic-kundli>` is the canonical RoxyAPI render path.
|
|
172
367
|
- Do not call astrology endpoints with hardcoded coordinates. Always geocode first via `<roxy-location-search>` or `roxy.location.searchCities()`.
|
|
368
|
+
- Do not declare a local `interface XyzData` to describe a RoxyAPI response. Import the type from the spec-derived bundle: `import type { XyzResponse } from '@roxyapi/sdk'`. Local interfaces drift the moment the spec changes.
|
|
369
|
+
- Do not write Tailwind utility classes inside a component. The Shadow DOM boundary stops them at the door. Theme through `--roxy-*` CSS custom properties on `:root` or per element instead.
|
|
370
|
+
- Do not fetch inside chart, table, or card components. They are stateless: pass `data` as a prop. Documented exceptions are `<roxy-location-search>`, `<roxy-endpoint-form>`, and the widgets auto-mount script.
|
|
371
|
+
- Do not redefine theme tokens or invent your own naming. Override the existing `--roxy-*` custom properties; the full list is in `THEMING.md`.
|
|
173
372
|
|
|
174
373
|
## Where to look next
|
|
175
374
|
|
|
@@ -177,4 +376,4 @@ When listing domains in user-visible copy, use the canonical order: Western astr
|
|
|
177
376
|
- Sample data for every component: `apps/docs/sample-data.js`
|
|
178
377
|
- Token reference: `packages/ui/THEMING.md`
|
|
179
378
|
- Live preview: `bun run preview` then open `http://localhost:3001`
|
|
180
|
-
-
|
|
379
|
+
- Endpoint reference: <https://roxyapi.com/api-reference>
|