@yoyomq/ije-react 0.1.2 → 0.1.3

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,26 +4,189 @@
4
4
 
5
5
  <h1 align="center">@yoyomq/ije-react</h1>
6
6
 
7
- <p align="center">React wrappers for the Ije SDK by <strong>Yoyo</strong>.</p>
7
+ <p align="center">First-class React components for the Ije SDK by <strong>Yoyo</strong>.</p>
8
8
 
9
9
  ---
10
10
 
11
- > ⚠️ **Placeholder not yet implemented.** This package currently exports
12
- > nothing. First-class, typed React components are planned.
11
+ ## Get your API key
13
12
 
14
- In the meantime, the [`@yoyomq/ije-ui`](../ui) Web Components work inside React
15
- directly initialize once and use the tags as JSX:
13
+ 1. Sign in at [yoyomq.com](https://yoyomq.com)
14
+ 2. Go to **Settings API Keys**
15
+ 3. Create a new key and copy it
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install @yoyomq/ije-react
21
+ ```
22
+
23
+ React 16.8+ is required as a peer dependency.
24
+
25
+ ## Quick start
26
+
27
+ Wrap your app (or the relevant subtree) with `IjeProvider`, then drop in any component:
28
+
29
+ ```tsx
30
+ import { IjeProvider, MapTracker, TelemetryStat } from '@yoyomq/ije-react';
31
+
32
+ export default function App() {
33
+ return (
34
+ <IjeProvider config={{ apiKey: 'YOUR_YOYO_API_KEY' }}>
35
+ <MapTracker deviceId={1001} title="Vehicle Location" />
36
+ <TelemetryStat deviceId={1001} metric="speed" title="Speed" unit="km/h" />
37
+ </IjeProvider>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ## Next.js App Router
43
+
44
+ All components include `'use client'` — no extra setup needed. Place `IjeProvider` in a client boundary:
16
45
 
17
46
  ```tsx
18
- import { useEffect } from 'react';
19
- import { Ije } from '@yoyomq/ije-core';
20
- import '@yoyomq/ije-ui';
47
+ // app/dashboard/layout.tsx
48
+ import { IjeProvider } from '@yoyomq/ije-react';
21
49
 
22
- export function Dashboard({ apiKey }: { apiKey: string }) {
23
- useEffect(() => { Ije.init({ apiKey }); }, [apiKey]);
24
- return <ije-map-tracker device-id="truck-001" title="Vehicle Location" />;
50
+ export default function DashboardLayout({ children }: { children: React.ReactNode }) {
51
+ return (
52
+ <IjeProvider config={{ apiKey: process.env.NEXT_PUBLIC_YOYO_API_KEY! }}>
53
+ {children}
54
+ </IjeProvider>
55
+ );
25
56
  }
26
57
  ```
27
58
 
28
- 📖 **Full documentation:** see the [Ije SDK README](../../README.md), including the
29
- [Using with React](../../README.md#using-with-react) section.
59
+ ## Components
60
+
61
+ ### `<MapTracker>`
62
+
63
+ Live map showing a device's current position and movement trail. Click the position marker to open an info bubble with speed, heading, altitude, coordinates, and timestamp. Optionally enables historical trip replay mode.
64
+
65
+ ```tsx
66
+ <MapTracker
67
+ deviceId={1001}
68
+ title="Vehicle Location"
69
+ width="100%"
70
+ height="400px"
71
+ />
72
+ ```
73
+
74
+ | Prop | Type | Description |
75
+ |------|------|-------------|
76
+ | `deviceId` | `number` | **Required.** Numeric device ID |
77
+ | `title` | `string` | Card title |
78
+ | `helpMessage` | `string` | Tooltip shown on hover |
79
+ | `width` | `string` | CSS width (default `100%`) |
80
+ | `height` | `string` | CSS height (default `400px`) |
81
+ | `tripPicker` | `boolean` | Enable historical trip replay mode |
82
+ | `triggerId` | `number` | Trip trigger ID (trip-picker mode) |
83
+ | `triggerName` | `string` | Trip trigger label (trip-picker mode) |
84
+ | `startsAt` | `number` | Trip start Unix timestamp in seconds (trip-picker mode) |
85
+ | `endsAt` | `number` | Trip end Unix timestamp in seconds (trip-picker mode) |
86
+
87
+ ### `<TelemetryStat>`
88
+
89
+ Single live telemetry value (speed, fuel, temperature, etc.).
90
+
91
+ ```tsx
92
+ <TelemetryStat deviceId={1001} metric="speed" title="Speed" unit="km/h" />
93
+ ```
94
+
95
+ | Prop | Type | Description |
96
+ |------|------|-------------|
97
+ | `deviceId` | `number` | **Required.** Numeric device ID |
98
+ | `metric` | `string` | **Required.** Telemetry field name |
99
+ | `title` | `string` | Card title |
100
+ | `unit` | `string` | Unit label (e.g. `km/h`, `°C`) |
101
+ | `helpMessage` | `string` | Tooltip shown on hover |
102
+
103
+ ### `<TelemetryChart>`
104
+
105
+ Live time-series chart for a telemetry metric.
106
+
107
+ ```tsx
108
+ <TelemetryChart deviceId={1001} metric="speed" title="Speed over time" height="200px" />
109
+ ```
110
+
111
+ | Prop | Type | Description |
112
+ |------|------|-------------|
113
+ | `deviceId` | `number` | **Required.** Numeric device ID |
114
+ | `metric` | `string` | Telemetry field name |
115
+ | `title` | `string` | Card title |
116
+ | `helpMessage` | `string` | Tooltip shown on hover |
117
+ | `width` | `string` | CSS width |
118
+ | `height` | `string` | CSS height |
119
+
120
+ ### `<AggregateStat>`
121
+
122
+ Displays a set of aggregate metrics (totals, averages, counts) passed in as data.
123
+
124
+ ```tsx
125
+ import type { AggregateData } from '@yoyomq/ije-react';
126
+
127
+ const data: AggregateData = {
128
+ metrics: [
129
+ { label: 'Total distance', value: 1240, unit: 'km' },
130
+ { label: 'Trips', value: 38 },
131
+ ],
132
+ };
133
+
134
+ <AggregateStat data={data} />
135
+ ```
136
+
137
+ | Prop | Type | Description |
138
+ |------|------|-------------|
139
+ | `data` | `AggregateData` | Metrics to display |
140
+ | `loading` | `boolean` | Show loading skeleton |
141
+
142
+ ### `<BarChart>`
143
+
144
+ Horizontal bar chart for comparing values across categories.
145
+
146
+ ```tsx
147
+ import type { BarChartData } from '@yoyomq/ije-react';
148
+
149
+ const data: BarChartData[] = [
150
+ { label: 'Mon', value: 120 },
151
+ { label: 'Tue', value: 95 },
152
+ ];
153
+
154
+ <BarChart data={data} height="200px" />
155
+ ```
156
+
157
+ | Prop | Type | Description |
158
+ |------|------|-------------|
159
+ | `data` | `BarChartData[]` | Array of `{ label, value }` entries |
160
+ | `loading` | `boolean` | Show loading skeleton |
161
+ | `height` | `string` | CSS height |
162
+
163
+ ### `<Chat>`
164
+
165
+ AI-powered fleet assistant chat widget.
166
+
167
+ ```tsx
168
+ <Chat title="Fleet Assistant" placeholder="Ask about your fleet…" />
169
+ ```
170
+
171
+ | Prop | Type | Description |
172
+ |------|------|-------------|
173
+ | `title` | `string` | Widget title |
174
+ | `placeholder` | `string` | Input placeholder text |
175
+ | `width` | `string` | CSS width |
176
+ | `height` | `string` | CSS height |
177
+
178
+ ## `IjeProvider`
179
+
180
+ Initializes the SDK once. Place it high in your component tree.
181
+
182
+ ```tsx
183
+ <IjeProvider config={{ apiKey: 'YOUR_YOYO_API_KEY' }}>
184
+ {children}
185
+ </IjeProvider>
186
+ ```
187
+
188
+ The `config` prop accepts a [`SdkConfig`](https://github.com/Yoyo-MQ/ije) object from `@yoyomq/ije-core`.
189
+
190
+ ---
191
+
192
+ 📖 **Full SDK documentation:** [github.com/Yoyo-MQ/ije](https://github.com/Yoyo-MQ/ije)
@@ -1,6 +1,5 @@
1
1
  export interface MapTrackerProps {
2
- deviceId: string;
3
- numericDeviceId?: number;
2
+ deviceId: number;
4
3
  title?: string;
5
4
  helpMessage?: string;
6
5
  width?: string;
@@ -12,4 +11,4 @@ export interface MapTrackerProps {
12
11
  startsAt?: number;
13
12
  endsAt?: number;
14
13
  }
15
- export declare function MapTracker({ deviceId, numericDeviceId, title, helpMessage, width, height, tripPicker, triggerId, triggerName, startsAt, endsAt, }: MapTrackerProps): import("react").JSX.Element;
14
+ export declare function MapTracker({ deviceId, title, helpMessage, width, height, tripPicker, triggerId, triggerName, startsAt, endsAt, }: MapTrackerProps): import("react").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- export function MapTracker({ deviceId, numericDeviceId, title, helpMessage, width, height, tripPicker, triggerId, triggerName, startsAt, endsAt, }) {
4
- return (_jsx("ije-map-tracker", { "device-id": deviceId, "numeric-device-id": numericDeviceId != null ? String(numericDeviceId) : undefined, title: title, "help-message": helpMessage, width: width, height: height, "trip-picker": tripPicker ? '' : undefined, "trigger-id": triggerId != null ? String(triggerId) : undefined, "trigger-name": triggerName, "starts-at": startsAt != null ? String(startsAt) : undefined, "ends-at": endsAt != null ? String(endsAt) : undefined }));
3
+ export function MapTracker({ deviceId, title, helpMessage, width, height, tripPicker, triggerId, triggerName, startsAt, endsAt, }) {
4
+ return (_jsx("ije-map-tracker", { "device-id": deviceId, title: title, "help-message": helpMessage, width: width, height: height, "trip-picker": tripPicker ? '' : undefined, "trigger-id": triggerId, "trigger-name": triggerName, "starts-at": startsAt, "ends-at": endsAt }));
5
5
  }
@@ -1,5 +1,5 @@
1
1
  export interface TelemetryChartProps {
2
- deviceId: string;
2
+ deviceId: number;
3
3
  metric?: string;
4
4
  title?: string;
5
5
  helpMessage?: string;
@@ -1,5 +1,5 @@
1
1
  export interface TelemetryStatProps {
2
- deviceId: string;
2
+ deviceId: number;
3
3
  metric: string;
4
4
  title?: string;
5
5
  unit?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoyomq/ije-react",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "source": "src/index.tsx",
@@ -12,8 +12,8 @@
12
12
  "access": "public"
13
13
  },
14
14
  "dependencies": {
15
- "@yoyomq/ije-core": "0.1.2",
16
- "@yoyomq/ije-ui": "0.1.2"
15
+ "@yoyomq/ije-ui": "0.1.3",
16
+ "@yoyomq/ije-core": "0.1.3"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": ">=16.8.0",