@sudobility/building_blocks 0.0.21 → 0.0.23
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 +149 -7
- package/dist/components/footer/app-footer-for-home-page.d.ts +3 -1
- package/dist/components/footer/app-footer.d.ts +3 -1
- package/dist/components/settings/global-settings-page.d.ts +3 -0
- package/dist/components/subscription/AppPricingPage.d.ts +4 -1
- package/dist/components/subscription/AppSubscriptionsPage.d.ts +8 -3
- package/dist/index.js +229 -35
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +114 -0
- package/package.json +6 -6
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Type definitions for @sudobility/building_blocks
|
|
3
|
+
*
|
|
4
|
+
* @ai-context This file contains all TypeScript interfaces and types used across
|
|
5
|
+
* the building_blocks component library. Types are organized by domain:
|
|
6
|
+
* - Navigation (MenuItemConfig, LogoConfig, BreadcrumbItem)
|
|
7
|
+
* - Footer (FooterLinkItem, FooterLinkSection, SocialLinksConfig)
|
|
8
|
+
* - Layout (MaxWidth, ContentPadding, BackgroundVariant)
|
|
9
|
+
* - Analytics (AnalyticsEventType, AnalyticsTrackingParams)
|
|
10
|
+
*
|
|
11
|
+
* @ai-pattern All interfaces use JSDoc comments with property descriptions.
|
|
12
|
+
* Optional properties are marked with `?` suffix.
|
|
13
|
+
*/
|
|
1
14
|
import type { ComponentType, ReactNode } from 'react';
|
|
2
15
|
export type { LanguageConfig } from './constants/languages';
|
|
3
16
|
/**
|
|
4
17
|
* Menu item configuration for AppTopBar navigation.
|
|
18
|
+
*
|
|
19
|
+
* @ai-context Used by AppTopBar, AppTopBarWithFirebaseAuth, AppTopBarWithWallet
|
|
20
|
+
* @ai-usage Pass an array of these to the `menuItems` prop
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const menuItems: MenuItemConfig[] = [
|
|
25
|
+
* { id: 'docs', label: 'Docs', icon: DocumentTextIcon, href: '/docs' },
|
|
26
|
+
* { id: 'settings', label: 'Settings', icon: Cog6ToothIcon, href: '/settings', show: isLoggedIn },
|
|
27
|
+
* ];
|
|
28
|
+
* ```
|
|
5
29
|
*/
|
|
6
30
|
export interface MenuItemConfig {
|
|
7
31
|
/** Unique identifier for the menu item */
|
|
@@ -131,3 +155,93 @@ export type ContentPadding = 'none' | 'sm' | 'md' | 'lg';
|
|
|
131
155
|
* Background variant options.
|
|
132
156
|
*/
|
|
133
157
|
export type BackgroundVariant = 'default' | 'white' | 'gradient';
|
|
158
|
+
/**
|
|
159
|
+
* Analytics tracking event types for building blocks components.
|
|
160
|
+
*
|
|
161
|
+
* @ai-context These event types categorize user interactions for analytics.
|
|
162
|
+
* Each component uses specific event types based on its functionality.
|
|
163
|
+
*
|
|
164
|
+
* @ai-pattern Components call `onTrack` with these event types:
|
|
165
|
+
* - AppFooter, AppFooterForHomePage: 'link_click'
|
|
166
|
+
* - GlobalSettingsPage: 'settings_change'
|
|
167
|
+
* - AppPricingPage: 'subscription_action'
|
|
168
|
+
*/
|
|
169
|
+
export type AnalyticsEventType =
|
|
170
|
+
/** User clicked a button (e.g., CTA, submit) */
|
|
171
|
+
'button_click'
|
|
172
|
+
/** User clicked a navigation link */
|
|
173
|
+
| 'link_click'
|
|
174
|
+
/** User navigated to a different section/page */
|
|
175
|
+
| 'navigation'
|
|
176
|
+
/** User changed a setting (theme, font size, etc.) */
|
|
177
|
+
| 'settings_change'
|
|
178
|
+
/** User interacted with subscription/pricing (plan click, billing change) */
|
|
179
|
+
| 'subscription_action'
|
|
180
|
+
/** Page was viewed (typically tracked by router, not components) */
|
|
181
|
+
| 'page_view';
|
|
182
|
+
/**
|
|
183
|
+
* Analytics tracking parameters passed to onTrack callbacks.
|
|
184
|
+
*
|
|
185
|
+
* @ai-context This is the standard payload for all analytics events from
|
|
186
|
+
* building_blocks components. The consuming app maps these to their
|
|
187
|
+
* analytics provider (Firebase, Mixpanel, Segment, etc.).
|
|
188
|
+
*
|
|
189
|
+
* @ai-usage
|
|
190
|
+
* ```tsx
|
|
191
|
+
* const handleTrack = (params: AnalyticsTrackingParams) => {
|
|
192
|
+
* firebase.analytics().logEvent(params.label, {
|
|
193
|
+
* component: params.componentName,
|
|
194
|
+
* event_type: params.eventType,
|
|
195
|
+
* ...params.params,
|
|
196
|
+
* });
|
|
197
|
+
* };
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* // Example params from AppPricingPage
|
|
203
|
+
* {
|
|
204
|
+
* eventType: 'subscription_action',
|
|
205
|
+
* componentName: 'AppPricingPage',
|
|
206
|
+
* label: 'plan_clicked',
|
|
207
|
+
* params: { plan_identifier: 'pro_monthly', action_type: 'upgrade' }
|
|
208
|
+
* }
|
|
209
|
+
*
|
|
210
|
+
* // Example params from AppFooter
|
|
211
|
+
* {
|
|
212
|
+
* eventType: 'link_click',
|
|
213
|
+
* componentName: 'AppFooter',
|
|
214
|
+
* label: 'footer_link_clicked',
|
|
215
|
+
* params: { link_label: 'Privacy', link_href: '/privacy' }
|
|
216
|
+
* }
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
export interface AnalyticsTrackingParams {
|
|
220
|
+
/** Type of event being tracked (categorizes the interaction) */
|
|
221
|
+
eventType: AnalyticsEventType;
|
|
222
|
+
/** Component name where the event originated (e.g., 'AppPricingPage') */
|
|
223
|
+
componentName: string;
|
|
224
|
+
/** Human-readable label for the action (e.g., 'plan_clicked', 'theme_changed') */
|
|
225
|
+
label: string;
|
|
226
|
+
/** Additional context-specific parameters (varies by component and action) */
|
|
227
|
+
params?: Record<string, unknown>;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Analytics tracking callback interface for components.
|
|
231
|
+
*
|
|
232
|
+
* @ai-context Components that support analytics accept an optional `onTrack` prop
|
|
233
|
+
* of type `(params: AnalyticsTrackingParams) => void`. This interface is provided
|
|
234
|
+
* for consumers who want to type their tracking implementation.
|
|
235
|
+
*
|
|
236
|
+
* @ai-pattern To add analytics to a component:
|
|
237
|
+
* 1. Add `onTrack?: (params: AnalyticsTrackingParams) => void` to props
|
|
238
|
+
* 2. Create a track helper: `const track = (label, params) => onTrack?.({...})`
|
|
239
|
+
* 3. Call `track()` on user interactions
|
|
240
|
+
*/
|
|
241
|
+
export interface AnalyticsTracker {
|
|
242
|
+
/**
|
|
243
|
+
* Track an analytics event.
|
|
244
|
+
* @param params The tracking parameters including event type, component, label, and custom params
|
|
245
|
+
*/
|
|
246
|
+
onTrack: (params: AnalyticsTrackingParams) => void;
|
|
247
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sudobility/building_blocks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"description": "Higher-level shared UI building blocks for Sudobility apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@heroicons/react": "^2.0.0",
|
|
36
|
-
"@sudobility/components": "^4.0.
|
|
37
|
-
"@sudobility/design": "^1.1.
|
|
36
|
+
"@sudobility/components": "^4.0.139",
|
|
37
|
+
"@sudobility/design": "^1.1.18",
|
|
38
38
|
"class-variance-authority": "^0.7.0",
|
|
39
39
|
"clsx": "^2.0.0",
|
|
40
40
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@eslint/js": "^9.38.0",
|
|
66
66
|
"@heroicons/react": "^2.2.0",
|
|
67
|
-
"@sudobility/components": "^4.0.
|
|
68
|
-
"@sudobility/design": "^1.1.
|
|
67
|
+
"@sudobility/components": "^4.0.139",
|
|
68
|
+
"@sudobility/design": "^1.1.18",
|
|
69
69
|
"@sudobility/subscription-components": "^1.0.13",
|
|
70
|
-
"@sudobility/types": "^1.9.
|
|
70
|
+
"@sudobility/types": "^1.9.44",
|
|
71
71
|
"@testing-library/dom": "^10.4.1",
|
|
72
72
|
"@testing-library/jest-dom": "^6.9.1",
|
|
73
73
|
"@testing-library/react": "^16.3.0",
|