@sudobility/building_blocks 0.0.18 → 0.0.22

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/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.18",
3
+ "version": "0.0.22",
4
4
  "description": "Higher-level shared UI building blocks for Sudobility apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -34,7 +34,7 @@
34
34
  "peerDependencies": {
35
35
  "@heroicons/react": "^2.0.0",
36
36
  "@sudobility/components": "^4.0.134",
37
- "@sudobility/design": "^1.1.17",
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",
@@ -65,9 +65,9 @@
65
65
  "@eslint/js": "^9.38.0",
66
66
  "@heroicons/react": "^2.2.0",
67
67
  "@sudobility/components": "^4.0.134",
68
- "@sudobility/design": "^1.1.17",
68
+ "@sudobility/design": "^1.1.18",
69
69
  "@sudobility/subscription-components": "^1.0.13",
70
- "@sudobility/types": "^1.9.43",
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",
@@ -1,137 +0,0 @@
1
- import React, { type ReactNode, type ComponentType } from 'react';
2
- /**
3
- * Configuration for a content section with a list
4
- */
5
- export interface PrivacySectionWithList {
6
- /** Section title */
7
- title: string;
8
- /** Optional description before the list */
9
- description?: string;
10
- /** List items */
11
- items: string[];
12
- }
13
- /**
14
- * Configuration for a content section with paragraph text
15
- */
16
- export interface PrivacySectionWithContent {
17
- /** Section title */
18
- title: string;
19
- /** Paragraph content */
20
- content: string;
21
- }
22
- /**
23
- * Configuration for a subsection (h3 level)
24
- */
25
- export interface PrivacySubsection {
26
- /** Subsection title */
27
- title: string;
28
- /** List items */
29
- items: string[];
30
- }
31
- /**
32
- * Contact information configuration
33
- */
34
- export interface PrivacyContactInfo {
35
- /** Email label (e.g., "Email:") */
36
- emailLabel: string;
37
- /** Email address */
38
- email: string;
39
- /** Website label (e.g., "Website:") */
40
- websiteLabel: string;
41
- /** Website URL */
42
- websiteUrl: string;
43
- /** Data Protection Officer label */
44
- dpoLabel: string;
45
- /** DPO email */
46
- dpoEmail: string;
47
- /** GDPR section title */
48
- gdprTitle: string;
49
- /** GDPR section content */
50
- gdprContent: string;
51
- }
52
- /**
53
- * All text content for the privacy policy page
54
- */
55
- export interface PrivacyPolicyPageText {
56
- /** Page heading */
57
- heading: string;
58
- /** Last updated label */
59
- lastUpdatedLabel: string;
60
- /** Introduction section */
61
- introduction: PrivacySectionWithContent;
62
- /** Information We Collect section */
63
- informationWeCollect: {
64
- title: string;
65
- youProvide: PrivacySubsection;
66
- automatic: PrivacySubsection;
67
- };
68
- /** How We Use Your Information section */
69
- howWeUse: PrivacySectionWithList;
70
- /** Information Sharing section */
71
- informationSharing: PrivacySectionWithList;
72
- /** Data Security section */
73
- dataSecurity: PrivacySectionWithList;
74
- /** Data Retention section */
75
- dataRetention: PrivacySectionWithContent;
76
- /** Your Privacy Rights section */
77
- privacyRights: PrivacySectionWithList;
78
- /** Web3 Considerations section (optional) */
79
- web3Considerations?: PrivacySectionWithList;
80
- /** International Transfers section */
81
- internationalTransfers: PrivacySectionWithContent;
82
- /** Children's Privacy section */
83
- childrensPrivacy: PrivacySectionWithContent;
84
- /** Cookies section */
85
- cookies: PrivacySectionWithContent;
86
- /** Changes to Policy section */
87
- changes: PrivacySectionWithContent;
88
- /** Contact section */
89
- contact: {
90
- title: string;
91
- description: string;
92
- info: PrivacyContactInfo;
93
- };
94
- }
95
- /**
96
- * Props for AppPrivacyPolicyPage component
97
- */
98
- export interface AppPrivacyPolicyPageProps {
99
- /** All text content (must be provided by consumer) */
100
- text: PrivacyPolicyPageText;
101
- /** Current date for "last updated" display */
102
- lastUpdatedDate?: string;
103
- /** Optional wrapper component for the page layout */
104
- PageWrapper?: ComponentType<{
105
- children: ReactNode;
106
- }>;
107
- /** Optional className for the container */
108
- className?: string;
109
- }
110
- /**
111
- * AppPrivacyPolicyPage - A reusable privacy policy page component
112
- *
113
- * Displays a comprehensive privacy policy with:
114
- * - Standard legal sections
115
- * - Optional Web3-specific considerations
116
- * - Contact information with GDPR notice
117
- *
118
- * All text content must be provided by the consumer app.
119
- *
120
- * @example
121
- * ```tsx
122
- * <AppPrivacyPolicyPage
123
- * text={{
124
- * heading: "Privacy Policy",
125
- * lastUpdatedLabel: "Last updated",
126
- * introduction: {
127
- * title: "Introduction",
128
- * content: "We respect your privacy..."
129
- * },
130
- * // ... other sections
131
- * }}
132
- * lastUpdatedDate="January 1, 2025"
133
- * />
134
- * ```
135
- */
136
- export declare const AppPrivacyPolicyPage: React.FC<AppPrivacyPolicyPageProps>;
137
- export default AppPrivacyPolicyPage;
@@ -1,107 +0,0 @@
1
- import React, { type ReactNode, type ComponentType } from 'react';
2
- /**
3
- * Configuration for a section with paragraph content
4
- */
5
- export interface TermsSectionWithContent {
6
- /** Section title */
7
- title: string;
8
- /** Paragraph content (can include HTML for links) */
9
- content: string;
10
- /** Whether content contains HTML that should be rendered */
11
- isHtml?: boolean;
12
- }
13
- /**
14
- * Configuration for a section with a list
15
- */
16
- export interface TermsSectionWithList {
17
- /** Section title */
18
- title: string;
19
- /** Optional description before the list */
20
- description?: string;
21
- /** List items */
22
- items: string[];
23
- /** Optional additional content after the list */
24
- additionalContent?: string;
25
- }
26
- /**
27
- * Contact information configuration
28
- */
29
- export interface TermsContactInfo {
30
- /** Email label (e.g., "Email:") */
31
- emailLabel: string;
32
- /** Email address */
33
- email: string;
34
- /** Website label (e.g., "Website:") */
35
- websiteLabel: string;
36
- /** Website URL */
37
- websiteUrl: string;
38
- }
39
- /**
40
- * All text content for the terms of service page
41
- */
42
- export interface TermsOfServicePageText {
43
- /** Page title */
44
- title: string;
45
- /** Last updated text (with placeholder for date) */
46
- lastUpdated: string;
47
- /** All sections in order */
48
- sections: Array<TermsSectionWithContent | TermsSectionWithList>;
49
- /** Contact information */
50
- contact: {
51
- /** Section title */
52
- title: string;
53
- /** Section description */
54
- description: string;
55
- /** Whether description contains HTML */
56
- isHtml?: boolean;
57
- /** Contact details */
58
- info: TermsContactInfo;
59
- };
60
- }
61
- /**
62
- * Props for AppTermsOfServicePage component
63
- */
64
- export interface AppTermsOfServicePageProps {
65
- /** All text content (must be provided by consumer) */
66
- text: TermsOfServicePageText;
67
- /** Current date for "last updated" display */
68
- lastUpdatedDate?: string;
69
- /** Optional wrapper component for the page layout */
70
- PageWrapper?: ComponentType<{
71
- children: ReactNode;
72
- }>;
73
- /** Optional className for the container */
74
- className?: string;
75
- }
76
- /**
77
- * AppTermsOfServicePage - A reusable terms of service page component
78
- *
79
- * Displays a comprehensive terms of service document with:
80
- * - Flexible section structure (content or list-based)
81
- * - Contact information
82
- * - Support for HTML content in specific sections
83
- *
84
- * All text content must be provided by the consumer app.
85
- *
86
- * @example
87
- * ```tsx
88
- * <AppTermsOfServicePage
89
- * text={{
90
- * title: "Terms of Service",
91
- * lastUpdated: "Last updated: {{date}}",
92
- * sections: [
93
- * { title: "Acceptance", content: "By using..." },
94
- * { title: "User Responsibilities", items: ["Item 1", "Item 2"] }
95
- * ],
96
- * contact: {
97
- * title: "Contact",
98
- * description: "Questions?",
99
- * info: { emailLabel: "Email:", email: "support@example.com", ... }
100
- * }
101
- * }}
102
- * lastUpdatedDate="January 1, 2025"
103
- * />
104
- * ```
105
- */
106
- export declare const AppTermsOfServicePage: React.FC<AppTermsOfServicePageProps>;
107
- export default AppTermsOfServicePage;