Shared utilities, types, and event system for Shiro UI Components
npm install @i-am-shashikant-d/corebash
npm install @i-am-shashikant-d/core
`
Features
- šÆ Event Management System - Unified event handling with debouncing, priority, and cleanup
- š§ TypeScript Types - Comprehensive type definitions for all components
- šØ Shared Styles - SCSS variables, mixins, and base styles
- āļø React Hooks - Custom hooks for keyboard shortcuts and utilities
- š
°ļø Angular Services - Injectable services for Angular applications
- š Framework Agnostic - Core utilities work with any framework
Usage
$3
`typescript
import {
globalEventManager,
ShiroEventType,
ButtonProps,
CardProps
} from '@i-am-shashikant-d/core';
// Subscribe to events
const subscription = globalEventManager.addEventListener(
'onClick',
(eventData) => {
console.log('Button clicked:', eventData);
},
{
debounce: 300,
priority: 'high'
}
);
// Dispatch custom events
globalEventManager.dispatchEvent('onClick', {
timestamp: Date.now(),
target: event.target
});
// Cleanup
subscription.unsubscribe();
`
$3
`tsx
import { useKeyboardShortcut } from '@i-am-shashikant-d/core';
function MyComponent() {
useKeyboardShortcut('ctrl+s', () => {
console.log('Save triggered!');
});
return Press Ctrl+S to save;
}
`
$3
`typescript
import { KeyboardShortcutService } from '@i-am-shashikant-d/core';
@Component({
selector: 'app-my-component',
template: 'Press Ctrl+S to save'
})
export class MyComponent implements OnInit, OnDestroy {
constructor(private keyboardService: KeyboardShortcutService) {}
ngOnInit() {
this.keyboardService.registerShortcut('ctrl+s', () => {
console.log('Save triggered!');
});
}
ngOnDestroy() {
this.keyboardService.cleanup();
}
}
`
$3
`scss
// Import all styles
@import '@i-am-shashikant-d/core/dist/index.css';
// Or import SCSS for customization
@import '@i-am-shashikant-d/core/styles/variables';
@import '@i-am-shashikant-d/core/styles/mixins';
`
Development
$3
`bash
Install dependencies
npm install
Build for production
npm run build
Build for development (with source maps)
npm run build:dev
Watch mode
npm run watch
`
$3
`bash
npm run typecheck
`
$3
`bash
npm run lint
`
Package Structure
`
dist/
āāā index.cjs.js # CommonJS bundle
āāā index.esm.js # ES Module bundle
āāā index.umd.js # UMD bundle (browser)
āāā index.css # Compiled CSS
āāā types/ # TypeScript declarations
`
Exports
$3
- Event types and interfaces
- Component prop types (Button, Card, Header, etc.)
- Keyboard shortcut types
$3
- globalEventManager - Global event manager instance
- ShiroEventManager` - Event manager class