@omnikit-js/ui 0.5.5 → 0.6.1

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.
Files changed (52) hide show
  1. package/README.md +100 -255
  2. package/dist/chunk-FPLMULY5.mjs +436 -0
  3. package/dist/chunk-FPLMULY5.mjs.map +1 -0
  4. package/dist/chunk-MQEH3FTA.mjs +196 -0
  5. package/dist/chunk-MQEH3FTA.mjs.map +1 -0
  6. package/dist/components/client/index.d.mts +40 -0
  7. package/dist/components/client/index.mjs +8 -0
  8. package/dist/components/client/index.mjs.map +1 -0
  9. package/dist/components/server/index.d.mts +2 -0
  10. package/dist/components/server/index.mjs +4 -0
  11. package/dist/components/server/index.mjs.map +1 -0
  12. package/dist/index-CsOyTW-D.d.mts +87 -0
  13. package/dist/index.d.mts +47 -0
  14. package/dist/index.mjs +4 -0
  15. package/dist/index.mjs.map +1 -0
  16. package/package.json +41 -77
  17. package/LICENSE +0 -21
  18. package/dist/styles.css +0 -2506
  19. package/dist/styles.isolated.css +0 -2643
  20. package/dist/styles.prefixed.css +0 -248
  21. package/src/components/BillingClient.tsx +0 -686
  22. package/src/components/BillingServer.tsx +0 -129
  23. package/src/components/PaymentMethodForm.tsx +0 -125
  24. package/src/components/SubscriptionConfirmModal.tsx +0 -213
  25. package/src/components/theme-provider.tsx +0 -11
  26. package/src/components/ui/alert.tsx +0 -59
  27. package/src/components/ui/avatar.tsx +0 -53
  28. package/src/components/ui/badge.tsx +0 -46
  29. package/src/components/ui/button.tsx +0 -59
  30. package/src/components/ui/card-brand-icon.tsx +0 -88
  31. package/src/components/ui/card.tsx +0 -92
  32. package/src/components/ui/chart.tsx +0 -353
  33. package/src/components/ui/dialog.tsx +0 -122
  34. package/src/components/ui/dropdown-menu.tsx +0 -257
  35. package/src/components/ui/input.tsx +0 -21
  36. package/src/components/ui/label.tsx +0 -24
  37. package/src/components/ui/navigation-menu.tsx +0 -168
  38. package/src/components/ui/progress.tsx +0 -31
  39. package/src/components/ui/radio-group.tsx +0 -44
  40. package/src/components/ui/select.tsx +0 -185
  41. package/src/components/ui/separator.tsx +0 -28
  42. package/src/components/ui/switch.tsx +0 -31
  43. package/src/components/ui/tabs.tsx +0 -66
  44. package/src/components/ui/textarea.tsx +0 -18
  45. package/src/components/ui/tooltip.tsx +0 -30
  46. package/src/index.ts +0 -13
  47. package/src/lib/utils.ts +0 -6
  48. package/src/styles/globals.css +0 -1
  49. package/src/styles/isolated.css +0 -316
  50. package/src/styles/main.css +0 -122
  51. package/src/styles/prefixed-main.css +0 -95
  52. package/src/styles/prefixed.css +0 -1
package/README.md CHANGED
@@ -1,300 +1,145 @@
1
1
  # @omnikit-js/ui
2
2
 
3
- A comprehensive SaaS billing component for Next.js applications with Stripe integration. Built with React Server Components support and Tailwind CSS v4.
4
-
5
- ## Features
6
-
7
- - 🚀 **Server Components Support** - Optimized for Next.js App Router
8
- - 💳 **Stripe Integration** - Complete payment processing and subscription management
9
- - 🎨 **Beautiful UI** - Built with Tailwind CSS v4 and Radix UI
10
- - 📊 **Usage Tracking** - Monitor and display resource usage
11
- - 🔄 **Subscription Management** - Handle upgrades, downgrades, and cancellations
12
- - 💰 **Payment Methods** - Add, remove, and manage multiple payment methods
13
- - 📜 **Billing History** - View and download past invoices
14
- - 🔐 **Secure** - Server-side API key handling
15
- - 🎯 **No Style Conflicts** - Prefixed CSS option to avoid conflicts with your app
3
+ React component library for OmniKit serverless platform. Provides both server and client components for building data-driven applications.
16
4
 
17
5
  ## Installation
18
6
 
19
7
  ```bash
20
8
  npm install @omnikit-js/ui
9
+ # or
10
+ pnpm add @omnikit-js/ui
11
+ # or
12
+ yarn add @omnikit-js/ui
21
13
  ```
22
14
 
23
- ## Usage
24
-
25
- ### Option 1: Standard CSS (For Apps Without Tailwind)
26
-
27
- If your app doesn't use Tailwind CSS or you want to use the component's default styles:
28
-
29
- ```javascript
30
- // Import the CSS in your app's entry point (e.g., _app.tsx or layout.tsx)
31
- import '@omnikit-js/ui/dist/styles.css'
15
+ ## Components
32
16
 
33
- // Use the component
34
- import { Billing } from '@omnikit-js/ui'
35
-
36
- export default function BillingPage() {
37
- return (
38
- <Billing
39
- userId="user_123"
40
- apiUrl="https://your-api.com"
41
- apiKey="your-api-key"
42
- />
43
- )
44
- }
45
- ```
17
+ ### DataList
46
18
 
47
- ### Option 2: Isolated CSS (Recommended for Apps With Style Conflicts)
19
+ A server-side component that fetches and displays data from OmniKit API with zero client JavaScript.
48
20
 
49
- To completely isolate the component styles and avoid any conflicts:
21
+ **Features:**
22
+ - Server-side rendering (SSR)
23
+ - Automatic data fetching from OmniKit `/data/{table}` endpoints
24
+ - Support for filtering, sorting, pagination
25
+ - Tailwind CSS styling (customizable)
26
+ - TypeScript support
50
27
 
51
- ```javascript
52
- // Import the isolated CSS version
53
- import '@omnikit-js/ui/dist/styles.isolated.css'
28
+ **Usage:**
54
29
 
55
- // Use the component
56
- import { Billing } from '@omnikit-js/ui'
30
+ ```tsx
31
+ import { DataList } from '@omnikit-js/ui'
57
32
 
58
- export default function BillingPage() {
33
+ export default async function UsersPage() {
59
34
  return (
60
- <Billing
61
- userId="user_123"
62
- apiUrl="https://your-api.com"
63
- apiKey="your-api-key"
35
+ <DataList
36
+ table="users"
37
+ baseUrl={process.env.OMNIKIT_BASE_URL!}
38
+ apiKey={process.env.OMNIKIT_API_KEY!}
39
+ columns={['name', 'email', 'created_at']}
40
+ filter={{ active: true }}
41
+ limit={20}
64
42
  />
65
43
  )
66
44
  }
67
45
  ```
68
46
 
69
- **Note:** The isolated version wraps all styles in `.omnikit-billing-component` and uses `!important` for critical styles like progress bars to prevent conflicts.
70
-
71
- ### Next.js App Router Example
72
-
73
- ```javascript
74
- // app/billing/page.tsx
75
- import '@omnikit-js/ui/dist/styles.isolated.css'
76
- import { Billing } from '@omnikit-js/ui'
77
-
78
- export default function BillingPage() {
79
- return (
80
- <main className="container mx-auto p-4">
81
- <h1 className="text-2xl font-bold mb-6">Billing & Subscription</h1>
82
- <Billing
83
- userId="user_123"
84
- apiUrl={process.env.NEXT_PUBLIC_API_URL}
85
- apiKey={process.env.API_KEY}
86
- />
87
- </main>
88
- )
89
- }
90
- ```
91
-
92
- ### Next.js Pages Router Example
93
-
94
- ```javascript
95
- // pages/_app.tsx
96
- import '@omnikit-js/ui/dist/styles.isolated.css'
97
- import type { AppProps } from 'next/app'
98
-
99
- export default function App({ Component, pageProps }: AppProps) {
100
- return <Component {...pageProps} />
101
- }
102
-
103
- // pages/billing.tsx
104
- import { Billing } from '@omnikit-js/ui'
105
-
106
- export default function BillingPage() {
107
- return (
108
- <div className="container mx-auto p-4">
109
- <h1 className="text-2xl font-bold mb-6">Billing & Subscription</h1>
110
- <Billing
111
- userId="user_123"
112
- apiUrl={process.env.NEXT_PUBLIC_API_URL}
113
- apiKey={process.env.API_KEY}
114
- />
115
- </div>
116
- )
117
- }
118
- ```
119
-
120
- ### Using Client Component Directly
121
-
122
- If you need to use the client component directly (e.g., in a client-side only context):
123
-
124
- ```jsx
125
- 'use client';
126
-
127
- import { BillingClient } from '@omnikit-js/ui';
128
-
129
- export default function ClientBillingPage({ customerData, pricingData, paymentMethods }) {
130
- return (
131
- <BillingClient
132
- customerData={customerData}
133
- pricingData={pricingData}
134
- paymentMethods={paymentMethods}
135
- apiUrl="https://api.yourdomain.com"
136
- apiKey="your-api-key"
137
- />
138
- );
139
- }
47
+ **Props:**
48
+
49
+ | Prop | Type | Required | Description |
50
+ |------|------|----------|-------------|
51
+ | `table` | `string` | Yes | Table name to query |
52
+ | `baseUrl` | `string` | Yes | OmniKit API base URL (e.g., `http://localhost:3000/omnikit`) |
53
+ | `apiKey` | `string` | No | API Key for authentication |
54
+ | `jwt` | `string` | No | JWT token (alternative to apiKey) |
55
+ | `columns` | `Column[]` | Yes | Columns to display |
56
+ | `keyField` | `string` | No | Row key field (default: `'id'`) |
57
+ | `filter` | `object` | No | Query filter |
58
+ | `sort` | `string` | No | Sort order (e.g., `'name:asc'`) |
59
+ | `limit` | `number` | No | Max records to fetch |
60
+ | `offset` | `number` | No | Pagination offset |
61
+ | `className` | `string` | No | Custom container class |
62
+ | `emptyMessage` | `string` | No | Message when no data |
63
+ | `errorMessage` | `string` | No | Error message |
64
+
65
+ **Custom Columns:**
66
+
67
+ ```tsx
68
+ <DataList
69
+ table="users"
70
+ baseUrl={baseUrl}
71
+ apiKey={apiKey}
72
+ columns={[
73
+ 'name',
74
+ 'email',
75
+ {
76
+ key: 'created_at',
77
+ label: 'Joined',
78
+ render: (value) => new Date(value).toLocaleDateString(),
79
+ },
80
+ {
81
+ key: 'active',
82
+ label: 'Status',
83
+ render: (value) => value ? '✓ Active' : '✗ Inactive',
84
+ },
85
+ ]}
86
+ />
140
87
  ```
141
88
 
142
- ## Resolving Style Conflicts
143
-
144
- If you experience style conflicts, especially with progress bars or grid layouts:
89
+ ## API Client
145
90
 
146
- ### Progress Bar Color Conflicts
91
+ Use the OmniKit client for custom data fetching:
147
92
 
148
- Override the progress bar styles in your global CSS:
93
+ ```tsx
94
+ import { createOmniKitClient } from '@omnikit-js/ui'
149
95
 
150
- ```css
151
- /* Force specific progress bar colors */
152
- .omnikit-progress-fill {
153
- background-color: #3b82f6 !important;
154
- }
96
+ const client = createOmniKitClient({
97
+ baseUrl: 'http://localhost:3000/omnikit',
98
+ apiKey: 'your-api-key',
99
+ })
155
100
 
156
- /* Or for dark mode */
157
- @media (prefers-color-scheme: dark) {
158
- .omnikit-progress-fill {
159
- background-color: #60a5fa !important;
160
- }
161
- }
162
- ```
101
+ // Query data
102
+ const users = await client.query('users', {
103
+ filter: { active: true },
104
+ sort: 'name:asc',
105
+ limit: 10,
106
+ })
163
107
 
164
- ### Grid Layout Conflicts
108
+ // Find by ID
109
+ const user = await client.findById('users', '123')
165
110
 
166
- Wrap the component in a scoped container to isolate styles:
167
-
168
- ```css
169
- /* Create an isolation container */
170
- .billing-wrapper {
171
- /* Reset conflicting styles */
172
- all: initial;
173
- font-family: inherit;
174
- color: inherit;
175
- }
176
-
177
- .billing-wrapper * {
178
- box-sizing: border-box;
179
- }
111
+ // Insert
112
+ await client.insert('users', { name: 'John', email: 'john@example.com' })
180
113
 
181
- /* Fix specific grid issues */
182
- .billing-wrapper .omnikit-pricing-grid {
183
- display: grid !important;
184
- gap: 1rem !important;
185
- }
186
- ```
114
+ // Update
115
+ await client.update('users', '123', { name: 'Jane' })
187
116
 
188
- ```javascript
189
- <div className="billing-wrapper">
190
- <Billing userId="user_123" />
191
- </div>
117
+ // Delete
118
+ await client.delete('users', '123')
192
119
  ```
193
120
 
194
- ## Component Props
195
-
196
- ### Billing (Server Component)
197
-
198
- | Prop | Type | Default | Description |
199
- |------|------|---------|-------------|
200
- | userId | string | required | The user ID to fetch billing data for |
201
- | apiUrl | string | `process.env.NEXT_PUBLIC_API_URL` | The API base URL |
202
- | apiKey | string | `process.env.API_KEY` | The API key for authentication |
203
- | projectId | string | `process.env.NEXT_PUBLIC_API_PROJECT` | The project ID for multi-tenant support |
204
-
205
- ### BillingClient (Client Component)
121
+ ## Development
206
122
 
207
- | Prop | Type | Description |
208
- |------|------|-------------|
209
- | customerData | object | Customer data including subscriptions and usage |
210
- | pricingData | object | Available pricing plans and products |
211
- | paymentMethods | object | User's payment methods |
212
- | apiUrl | string | The API base URL |
213
- | apiKey | string | The API key for authentication |
123
+ ### Quick Start
214
124
 
215
- ## Environment Variables
125
+ Run library watch build + demo app:
216
126
 
217
- Create a `.env.local` file in your Next.js project:
218
-
219
- ```env
220
- # API Configuration
221
- NEXT_PUBLIC_API_URL=http://localhost:3000
222
- API_KEY=your-secret-api-key
223
-
224
- # Stripe Configuration
225
- NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_your_publishable_key
226
-
227
- # Project Configuration (optional)
228
- NEXT_PUBLIC_API_PROJECT=1
127
+ ```bash
128
+ cd /Users/marcoschwartz/Documents/code/frontends/omnikit/omnikit-ui
129
+ ./dev.sh
229
130
  ```
230
131
 
231
- ## API Endpoints
132
+ Visit: **http://localhost:3060**
232
133
 
233
- The component expects the following API endpoints:
134
+ See [QUICKSTART.md](QUICKSTART.md) for detailed instructions.
234
135
 
235
- - `GET /billing/customers/:userId` - Fetch customer data
236
- - `GET /billing/prices?project_id=:projectId` - Fetch pricing plans
237
- - `GET /billing/payment-methods?user_id=:userId` - Fetch payment methods
238
- - `POST /billing/setup-intent` - Create Stripe setup intent
239
- - `POST /billing/subscriptions` - Create subscription
240
- - `DELETE /billing/subscriptions/:id` - Cancel subscription
241
- - `POST /billing/payment-methods/:id/default` - Set default payment method
242
- - `DELETE /billing/payment-methods/:id` - Delete payment method
136
+ ### Tech Stack
243
137
 
244
- ## Troubleshooting
245
-
246
- ### Common Issues and Solutions
247
-
248
- 1. **Progress bar showing wrong color**
249
- - Use the prefixed CSS version
250
- - Override `.omnikit-progress-fill` with `!important`
251
-
252
- 2. **Grid layout breaking on pricing page**
253
- - Check for global grid styles in your app
254
- - Use the isolation container approach shown above
255
- - Ensure no conflicting CSS Grid properties
256
-
257
- 3. **Modal z-index conflicts**
258
- - Component modals use `z-50` (z-index: 50)
259
- - Adjust your app's z-index scale if needed
260
-
261
- 4. **Font inconsistencies**
262
- - The component inherits font-family
263
- - Set font on a parent element
264
-
265
- 5. **Styles not loading**
266
- - Ensure you're importing the CSS file
267
- - Check the correct path: `@omnikit-js/ui/dist/styles.css` or `@omnikit-js/ui/dist/styles.isolated.css`
268
- - For apps with style conflicts, use the isolated version
269
-
270
- ## Version History
271
-
272
- - **0.5.3** - Added isolated CSS option for better style conflict resolution
273
- - **0.5.2** - Fixed CSS exports in package.json
274
- - **0.5.1** - Tailwind CSS v4 support with prefix option
275
- - **0.3.5** - Previous version with Tailwind CSS v3
276
-
277
- ## Browser Support
278
-
279
- Requires modern browsers:
280
- - Safari 16.4+
281
- - Chrome 111+
282
- - Firefox 128+
283
-
284
- For older browser support, use version 0.3.5.
285
-
286
- ## TypeScript
287
-
288
- The package includes TypeScript definitions. No additional setup required.
138
+ - **React 18/19** - Peer dependency
139
+ - **TypeScript** - Full type safety
140
+ - **Tailwind CSS v4** - Styling (requires Tailwind in your project)
141
+ - **tsup** - Build tooling
289
142
 
290
143
  ## License
291
144
 
292
145
  MIT
293
-
294
- ## Contributing
295
-
296
- Contributions are welcome! Please feel free to submit a Pull Request.
297
-
298
- ## Support
299
-
300
- For issues and feature requests, please use the [GitHub issue tracker](https://github.com/omnikit-ui/billing/issues).