@osiloke/chalo 0.1.1 โ†’ 0.1.2

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 (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +532 -0
  3. package/package.json +4 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Osiloke Harold Emoekpere
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,532 @@
1
+ # chalo
2
+ <p align="center">
3
+ <img src="./apps/demo/src/assets/logo.svg" alt="Chalo Logo" width="120" />
4
+ </p>
5
+
6
+ [![npm version](https://img.shields.io/npm/v/chalo.svg?style=flat-square)](https://www.npmjs.com/package/chalo)
7
+ [![npm downloads](https://img.shields.io/npm/dm/chalo.svg?style=flat-square)](https://www.npmjs.com/package/chalo)
8
+ [![license](https://img.shields.io/npm/l/chalo.svg?style=flat-square)](LICENSE)
9
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/chalo?style=flat-square)](https://bundlephobia.com/package/chalo)
10
+ [![typescript](https://img.shields.io/badge/TypeScript-5.0%2B-blue?style=flat-square)](https://www.typescriptlang.org/)
11
+
12
+ > **A modern React component library for building intelligent, action-driven UI experiences.**
13
+
14
+ Chalo provides a declarative API for creating guided user experiences, interactive walkthroughs, and automated UI workflows. Built with Zustand for state management and Framer Motion for smooth animations.
15
+
16
+ ---
17
+
18
+ ## โœจ Features
19
+
20
+ - ๐ŸŽฏ **Declarative Missions** - Define multi-step guided experiences with JSON-like configs
21
+ - ๐Ÿ”„ **Action Execution Engine** - Automate UI interactions (clicks, form fills, API calls, navigation)
22
+ - ๐ŸŽจ **Smart Components** - Pre-built `SmartDrawer`, `TargetHighlight`, and more
23
+ - ๐Ÿ’ซ **Smooth Animations** - Powered by Framer Motion with zero configuration
24
+ - ๐Ÿง  **State Management** - Lightweight Zustand store with full TypeScript support
25
+ - ๐Ÿ”Œ **Extensible Handlers** - Register custom action handlers for any UI interaction
26
+ - ๐Ÿ“ฆ **Tree-Shakeable** - Only bundle what you use
27
+ - ๐ŸŒณ **Dual ESM/CJS** - Works with all modern bundlers and legacy setups
28
+
29
+ ---
30
+
31
+ ## ๐Ÿ“ฆ Installation
32
+
33
+ ```bash
34
+ # npm
35
+ npm install @osiloke/chalo
36
+
37
+ # yarn
38
+ yarn add @osiloke/chalo
39
+
40
+ # pnpm
41
+ pnpm add @osiloke/chalo
42
+ ```
43
+
44
+ ### Peer Dependencies
45
+
46
+ Chalo requires the following packages (must be installed in your project):
47
+
48
+ ```json
49
+ {
50
+ "react": ">=18.0.0",
51
+ "react-dom": ">=18.0.0",
52
+ "zustand": ">=5.0.0",
53
+ "framer-motion": ">=12.0.0"
54
+ }
55
+ ```
56
+
57
+ ---
58
+
59
+ ## ๐Ÿš€ Quick Start
60
+
61
+ ### 1. Basic Setup
62
+
63
+ ```tsx
64
+ import { useChalo, SmartDrawer, Mission } from 'chalo';
65
+
66
+ function App() {
67
+ const {
68
+ activeMissionId,
69
+ currentStepId,
70
+ nextStep,
71
+ prevStep,
72
+ completeMission
73
+ } = useChalo();
74
+
75
+ return (
76
+ <div>
77
+ {/* Your app content */}
78
+ <SmartDrawer />
79
+ </div>
80
+ );
81
+ }
82
+ ```
83
+
84
+ ### 2. Define a Mission
85
+
86
+ ```tsx
87
+ import { Mission, Step, Bubble } from 'chalo';
88
+
89
+ const onboardingMission: Mission = {
90
+ id: 'app-onboarding',
91
+ title: 'Welcome to the App! ๐Ÿ‘‹',
92
+ description: 'Let us walk you through the main features.',
93
+ steps: [
94
+ {
95
+ id: 'welcome',
96
+ title: 'Getting Started',
97
+ content: 'This is the dashboard. Here you can manage your projects.',
98
+ targetElement: '#dashboard',
99
+ bubbles: [
100
+ {
101
+ id: 'continue-btn',
102
+ type: 'action-group',
103
+ actions: [
104
+ { label: 'Next โ†’', type: 'next' }
105
+ ]
106
+ }
107
+ ]
108
+ },
109
+ {
110
+ id: 'create-project',
111
+ title: 'Create Your First Project',
112
+ content: 'Click the button below to create a new project.',
113
+ targetElement: '#create-btn',
114
+ waitFor: {
115
+ type: 'field_value',
116
+ field: 'projectCreated',
117
+ value: true
118
+ },
119
+ actionSequence: [
120
+ {
121
+ id: 'click-create',
122
+ type: 'click',
123
+ config: { field: 'create-btn' }
124
+ }
125
+ ]
126
+ }
127
+ ],
128
+ allowCompletion: true
129
+ };
130
+ ```
131
+
132
+ ### 3. Register and Start
133
+
134
+ ```tsx
135
+ import { useChalo } from 'chalo';
136
+ import { useEffect } from 'react';
137
+
138
+ function App() {
139
+ const { registerMission, startMission } = useChalo();
140
+
141
+ useEffect(() => {
142
+ registerMission(onboardingMission);
143
+ startMission('app-onboarding');
144
+ }, [registerMission, startMission]);
145
+
146
+ return <YourApp />;
147
+ }
148
+ ```
149
+
150
+ ---
151
+
152
+ ## ๐Ÿ“– API Reference
153
+
154
+ ### Hooks
155
+
156
+ #### `useChalo(options?)`
157
+
158
+ Main hook for accessing chalo state and actions.
159
+
160
+ **Parameters:**
161
+ ```typescript
162
+ interface UseChaloOptions {
163
+ debug?: boolean; // Enable debug logging (default: false)
164
+ }
165
+ ```
166
+
167
+ **Returns:**
168
+ ```typescript
169
+ interface ChaloActions {
170
+ // Mission Management
171
+ registerMission: (mission: Mission) => void;
172
+ startMission: (missionId: string) => void;
173
+ pauseMission: () => void;
174
+ resumeMission: () => void;
175
+ completeMission: () => void;
176
+ resetMission: () => void;
177
+
178
+ // Navigation
179
+ nextStep: () => void;
180
+ prevStep: () => void;
181
+ goToStep: (stepId: string) => void;
182
+
183
+ // Field Management
184
+ updateField: (name: string, value: any, status?: FieldStatus) => void;
185
+
186
+ // Action Engine
187
+ registerActionHandler: (type: string, handler: ActionHandler) => void;
188
+ executeAction: (action: Action) => Promise<ActionResult>;
189
+ executeActionSequence: (actions: Action[]) => Promise<Record<string, ActionResult>>;
190
+ cancelExecution: () => void;
191
+
192
+ // Tours & History
193
+ dismissAllTours: () => void;
194
+ recordTourEntry: (missionId: string, stepId: string, completed: boolean) => void;
195
+
196
+ // State
197
+ reset: () => void;
198
+ setError: (error: string | null) => void;
199
+ }
200
+ ```
201
+
202
+ **Example:**
203
+ ```tsx
204
+ const {
205
+ activeMissionId,
206
+ currentStepId,
207
+ missionProgress,
208
+ fieldValues,
209
+ nextStep,
210
+ prevStep,
211
+ updateField
212
+ } = useChalo({ debug: true });
213
+ ```
214
+
215
+ ---
216
+
217
+ ### Components
218
+
219
+ #### `<SmartDrawer />`
220
+
221
+ A context-aware drawer component for displaying mission steps.
222
+
223
+ ```tsx
224
+ <SmartDrawer
225
+ position="right"
226
+ width="400px"
227
+ renderBubble={(bubble) => <CustomBubble {...bubble} />}
228
+ />
229
+ ```
230
+
231
+ **Props:**
232
+
233
+ | Prop | Type | Default | Description |
234
+ |------|------|---------|-------------|
235
+ | `position` | `'left' \| 'right' \| 'top' \| 'bottom'` | `'right'` | Drawer position |
236
+ | `width` | `string` | `'360px'` | Drawer width |
237
+ | `renderBubble` | `(bubble: Bubble) => ReactNode` | - | Custom bubble renderer |
238
+ | `onOpen` | `() => void` | - | Open callback |
239
+ | `onClose` | `() => void` | - | Close callback |
240
+
241
+ ---
242
+
243
+ #### `<TargetHighlight />`
244
+
245
+ Highlights target elements with animated overlays.
246
+
247
+ ```tsx
248
+ <TargetHighlight
249
+ selector="#my-element"
250
+ label="Click here to continue"
251
+ pulse
252
+ />
253
+ ```
254
+
255
+ **Props:**
256
+
257
+ | Prop | Type | Default | Description |
258
+ |------|------|---------|-------------|
259
+ | `selector` | `string` | **required** | CSS selector for target |
260
+ | `label` | `string` | - | Tooltip text |
261
+ | `pulse` | `boolean` | `false` | Enable pulse animation |
262
+ | `onClick` | `() => void` | - | Click handler |
263
+ | `style` | `CSSProperties` | - | Custom styles |
264
+
265
+ ---
266
+
267
+ ### Core Types
268
+
269
+ #### `Mission`
270
+
271
+ Defines a complete guided experience.
272
+
273
+ ```typescript
274
+ interface Mission {
275
+ id: string;
276
+ title: string;
277
+ description?: string;
278
+ steps: Step[];
279
+ metadata?: Record<string, unknown>;
280
+ onComplete?: () => void;
281
+ allowCompletion?: boolean;
282
+ actions?: Action[];
283
+ }
284
+ ```
285
+
286
+ #### `Step`
287
+
288
+ A single step within a mission.
289
+
290
+ ```typescript
291
+ interface Step {
292
+ id: string;
293
+ title: string;
294
+ content: string | ReactNode;
295
+ bubbles?: Bubble[];
296
+ targetField?: string;
297
+ targetElement?: string;
298
+ successCondition?: SuccessCondition;
299
+ waitFor?: SuccessCondition;
300
+ condition?: SuccessCondition;
301
+ navigationRules?: {
302
+ canGoBack?: boolean;
303
+ canSkip?: boolean;
304
+ };
305
+ actions?: StepAction[];
306
+ actionSequence?: Action[];
307
+ }
308
+ ```
309
+
310
+ #### `Action`
311
+
312
+ Atomic UI interaction for the execution engine.
313
+
314
+ ```typescript
315
+ interface Action {
316
+ id: string;
317
+ type: 'click' | 'scroll' | 'fill_field' | 'api_call' | 'wait' | 'conditional' | 'navigate' | 'custom';
318
+ config: ActionConfig;
319
+ label?: string;
320
+ retry?: RetryConfig;
321
+ rollback?: RollbackConfig;
322
+ dependsOn?: string[];
323
+ condition?: SuccessCondition;
324
+ }
325
+ ```
326
+
327
+ > ๐Ÿ’ก **See the [TypeScript Definitions](packages/chalo/src/types.ts) for complete type documentation.**
328
+
329
+ ---
330
+
331
+ ## ๐Ÿ”ง Advanced Usage
332
+
333
+ ### Custom Action Handlers
334
+
335
+ Extend the engine with your own action types:
336
+
337
+ ```tsx
338
+ import { useChalo, ActionHandler } from 'chalo';
339
+
340
+ function App() {
341
+ const { registerActionHandler } = useChalo();
342
+
343
+ useEffect(() => {
344
+ const showToast: ActionHandler = async (config, context) => {
345
+ const { message, duration } = config;
346
+ toast.show(message, { duration });
347
+ return { success: true };
348
+ };
349
+
350
+ registerActionHandler('show_toast', showToast);
351
+ }, [registerActionHandler]);
352
+ }
353
+ ```
354
+
355
+ ### Conditional Steps
356
+
357
+ Make steps dynamic based on user state:
358
+
359
+ ```tsx
360
+ {
361
+ id: 'advanced-feature',
362
+ title: 'Advanced Features',
363
+ content: 'Check out these powerful tools!',
364
+ condition: {
365
+ type: 'custom',
366
+ predicate: (value, formState) => formState.isPremiumUser
367
+ },
368
+ // This step only runs if the user is premium
369
+ }
370
+ ```
371
+
372
+ ### Tour History & Resumption
373
+
374
+ Chalo automatically tracks tour progress:
375
+
376
+ ```tsx
377
+ const { tourHistory, recordTourEntry } = useChalo();
378
+
379
+ // Check if user completed a tour
380
+ if (tourHistory['onboarding']?.completed) {
381
+ // Skip onboarding next time
382
+ }
383
+ ```
384
+
385
+ ---
386
+
387
+ ## ๐Ÿ“ Package Structure
388
+
389
+ ```
390
+ packages/chalo/
391
+ โ”œโ”€โ”€ src/
392
+ โ”‚ โ”œโ”€โ”€ components/ # UI components
393
+ โ”‚ โ”‚ โ”œโ”€โ”€ SmartDrawer.tsx
394
+ โ”‚ โ”‚ โ””โ”€โ”€ TargetHighlight.tsx
395
+ โ”‚ โ”œโ”€โ”€ engine/ # Action execution engines
396
+ โ”‚ โ”‚ โ”œโ”€โ”€ action-engine.ts
397
+ โ”‚ โ”‚ โ””โ”€โ”€ index.ts
398
+ โ”‚ โ”œโ”€โ”€ hooks/ # React hooks
399
+ โ”‚ โ”‚ โ””โ”€โ”€ use-chalo.ts
400
+ โ”‚ โ”œโ”€โ”€ store.ts # Zustand store
401
+ โ”‚ โ”œโ”€โ”€ types.ts # TypeScript definitions
402
+ โ”‚ โ””โ”€โ”€ index.ts # Public API
403
+ โ”œโ”€โ”€ package.json
404
+ โ”œโ”€โ”€ tsconfig.json
405
+ โ””โ”€โ”€ vite.config.ts
406
+ ```
407
+
408
+ ---
409
+
410
+ ## ๐Ÿงช Development
411
+
412
+ This package is part of a **pnpm monorepo**:
413
+
414
+ ```bash
415
+ # Install dependencies
416
+ pnpm install
417
+
418
+ # Build the library
419
+ pnpm run build:chalo
420
+
421
+ # Run tests
422
+ pnpm test
423
+
424
+ # Run tests with UI
425
+ pnpm run test:ui
426
+
427
+ # Lint code
428
+ pnpm run lint
429
+
430
+ # Format code
431
+ pnpm run format:fix
432
+
433
+ # Verify build
434
+ ./scripts/verify-build.sh
435
+ ```
436
+
437
+ ---
438
+
439
+ ## ๐Ÿšข Publishing
440
+
441
+ Releases are fully automated via [semantic-release](https://github.com/semantic-release/semantic-release). Every push to `main` is analyzed for conventional commits, and if there are release-worthy changes, a new version is automatically:
442
+
443
+ 1. **Version-bumped** (semver based on commit type)
444
+ 2. **Changelog-updated**
445
+ 3. **Published to npm** with provenance
446
+ 4. **Released on GitHub** with auto-generated notes
447
+
448
+ ### Conventional Commits
449
+
450
+ Use these commit prefixes to trigger releases:
451
+
452
+ | Prefix | Example | Effect |
453
+ |--------|---------|--------|
454
+ | `feat:` | `feat: add TargetHighlight component` | Bumps **minor** version |
455
+ | `fix:` | `fix: resolve drawer positioning bug` | Bumps **patch** version |
456
+ | `BREAKING CHANGE:` in body | `feat: redesign API\n\nBREAKING CHANGE: ...` | Bumps **major** version |
457
+ | `docs:`, `chore:`, `ci:` | `docs: update README` | No release |
458
+
459
+ ### Manual Release (Local)
460
+
461
+ ```bash
462
+ npx semantic-release --dry-run
463
+ ```
464
+
465
+ > ๐Ÿ“– See [GitHub Actions Workflow](.github/workflows/release.yml) for details.
466
+
467
+ ---
468
+
469
+ ## ๐Ÿค Contributing
470
+
471
+ Contributions are welcome! Please follow these steps:
472
+
473
+ 1. **Fork** the repository
474
+ 2. **Create a branch** (`git checkout -b feature/amazing-feature`)
475
+ 3. **Make your changes**
476
+ 4. **Run tests** (`pnpm test`)
477
+ 5. **Lint & format** (`pnpm run lint && pnpm run format:fix`)
478
+ 6. **Commit** using [Conventional Commits](https://www.conventionalcommits.org/)
479
+ 7. **Push** and **open a PR**
480
+
481
+ ### Development Guidelines
482
+
483
+ - Use TypeScript strictly (no `any` unless absolutely necessary)
484
+ - Follow existing code style (enforced by ESLint + Prettier)
485
+ - Write tests for new features
486
+ - Update documentation for API changes
487
+
488
+ ---
489
+
490
+ ## ๐Ÿ“ Versioning
491
+
492
+ This project follows [Semantic Versioning](https://semver.org/):
493
+
494
+ - **MAJOR** - Breaking changes
495
+ - **MINOR** - New features (backwards compatible)
496
+ - **PATCH** - Bug fixes
497
+
498
+ See [CHANGELOG.md](CHANGELOG.md) for release history.
499
+
500
+ ---
501
+
502
+ ## ๐Ÿ› Known Issues & Limitations
503
+
504
+ | Issue | Workaround | Status |
505
+ |-------|-----------|--------|
506
+ | SSR not yet supported | Use dynamic imports with `ssr: false` | ๐Ÿšง Planned |
507
+ | React 17 compatibility | Use React 18+ | โš ๏ธ Won't Fix |
508
+
509
+ > Found a bug? [Open an issue](https://github.com/osiloke/chalo/issues)!
510
+
511
+ ---
512
+
513
+ ## ๐Ÿ“„ License
514
+
515
+ [MIT](LICENSE) ยฉ Osiloke Harold Emoekpere
516
+
517
+ ---
518
+
519
+ ## ๐Ÿ™ Acknowledgments
520
+
521
+ Built with:
522
+ - [React](https://react.dev/) - UI library
523
+ - [Zustand](https://zustand-demo.pmnd.rs/) - State management
524
+ - [Framer Motion](https://www.framer.com/motion/) - Animations
525
+ - [Vite](https://vitejs.dev/) - Build tool
526
+ - [TypeScript](https://www.typescriptlang.org/) - Type safety
527
+
528
+ ---
529
+
530
+ <div align="center">
531
+ <strong>chalo</strong> โ€” Making UIs smarter, one step at a time. ๐Ÿš€
532
+ </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osiloke/chalo",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A modern React component library for intelligent UI interactions and guided experiences",
5
5
  "type": "module",
6
6
  "private": false,
@@ -55,6 +55,8 @@
55
55
  "test": "vitest",
56
56
  "test:ui": "vitest --ui",
57
57
  "coverage": "vitest run --coverage",
58
+ "prepack": "cp ../../README.md ./README.md && cp ../../LICENSE ./LICENSE",
59
+ "postpack": "rm -f README.md LICENSE",
58
60
  "prepublishOnly": "vitest run --passWithNoTests && npm run build"
59
61
  },
60
62
  "devDependencies": {
@@ -79,4 +81,4 @@
79
81
  "vitest": "^1.6.0",
80
82
  "zustand": "^5.0.12"
81
83
  }
82
- }
84
+ }