da-apps-sdk
v1.0.13
Published
DataActions Apps SDK - Shared components, layouts, and utilities for building apps
Maintainers
Readme
DA-APPS-SDK
A comprehensive React SDK containing shared components, layouts, contexts, and utilities for building applications at DataActions.
🚀 Features
- Modular Architecture: Well-organized component structure with clear separation of concerns
- TypeScript Support: Full TypeScript coverage with comprehensive type definitions
- Tailwind CSS: Utility-first styling with custom design system
- Multiple Build Formats: CommonJS and ES Modules support
- Development Tools: Hot reloading, linting, testing, and more
- React Icons: Extensive icon library integration
- Real Components: Production-ready components for common UI patterns
- SSR Support: Optimized for Server-Side Rendering environments
📦 Installation
Using npm
npm install da-apps-sdkUsing yarn
yarn add da-apps-sdkUsing yalc (for local development)
# In the SDK directory
yalc publish
# In your project directory
yalc add da-apps-sdk🎯 Quick Start
import { Button, Input, PanelLayout, Table, ModalContextProvider, useModalContext } from "da-apps-sdk";
// Use components
function App() {
return (
<ModalContextProvider>
<PanelLayout>
<div className="p-6">
<h1 className="text-2xl font-bold mb-4">Dashboard</h1>
<div className="space-y-4">
<Input name="email" label="Email Address" placeholder="Enter your email" />
<Button label="Submit" className="bg-blue-600 hover:bg-blue-700 text-white" />
<Table
data={[
{ id: 1, name: "John Doe", email: "[email protected]" },
{ id: 2, name: "Jane Smith", email: "[email protected]" },
]}
columns={[
{ key: "name", title: "Name" },
{ key: "email", title: "Email" },
]}
/>
</div>
</div>
</PanelLayout>
</ModalContextProvider>
);
}🔧 SSR (Server-Side Rendering) Support
The SDK is optimized for SSR environments like Next.js, Remix, and other frameworks. Here are some important considerations:
Next.js Usage
// In your Next.js app
import { Button, Input, Table } from "da-apps-sdk";
// Components work seamlessly in both client and server components
export default function Page() {
return (
<div>
<Button label="Click me" />
<Input name="test" label="Test Input" />
</div>
);
}Important SSR Notes
- React Version: The SDK requires React 18+ and is compatible with React 19
- Peer Dependencies: React and React-DOM are peer dependencies and must be installed in your project
- No Side Effects: The SDK is marked as
sideEffects: falsefor optimal tree-shaking - External Dependencies: All React-related imports are properly externalized
Troubleshooting SSR Issues
If you encounter SSR-related errors:
- Ensure React is installed: Make sure
reactandreact-domare in your project's dependencies - Check React version: The SDK requires React 18+ or 19+
- Import order: Import SDK components after React is available
- Build configuration: Ensure your bundler is configured to handle external dependencies
- JSX Runtime: The SDK uses production JSX runtime - ensure your app doesn't override this
// ✅ Correct import order
import React from "react";
import { Button, Input } from "da-apps-sdk";
// ❌ Avoid importing SDK before React
import { Button, Input } from "da-apps-sdk";
import React from "react";Common Error Solutions
"jsxDevRuntime.jsxDEV is not a function"
- This error occurs when development JSX runtime is used in production
- The SDK is configured to use production JSX runtime
- Ensure your app's build configuration doesn't override the SDK's JSX settings
"React is not defined"
- Ensure React is properly installed as a peer dependency
- Check that React is imported before using SDK components
- Verify your bundler is configured to handle external dependencies
📚 Documentation
Base Components
UI Components
Button- Versatile button component with customizable stylingInput- Form input component with validation supportLabel- Label component with icon supportLoader- Loading spinner componentDropdown- Dropdown menu componentMultiDropdown- Multi-select dropdown componentIllustration- Illustration placeholder component
Functional Components
Data & Navigation
Table- Data table component with sorting and actionsTabs- Tab navigation componentBreadcrumbs- Breadcrumb navigation componentList- List component with navigation support
User Interface
ModalWrapper- Modal dialog wrapperPopupWrapper- Popup wrapper componentPopUpMenu- Popup menu componentConfirmModal- Confirmation modal componentWizard- Multi-step wizard componentLabels- Label management componentLoading- Loading state componentError- Error display component
Layouts
PanelLayout- Panel-based layout componentScreenLayout- Full-screen layout component
Contexts
ModalContext- Modal state management contextWizardContext- Wizard state management context
Hooks
useResizeObserver- Resize observer hook for responsive components
Utilities
General Utilities
import { cn, classNames, sleep } from "da-apps-sdk";
// Combine class names with Tailwind merge
const className = cn("bg-blue-500", "bg-red-500"); // Returns 'bg-red-500'
// Simple class name combination
const classes = classNames("bg-blue-500", "text-white", false && "hidden");
// Sleep utility
await sleep(1000); // Wait for 1 second🛠️ Development
Prerequisites
- Node.js 16+
- npm or yarn
Setup
# Clone the repository
git clone <repository-url>
cd da-apps-sdk
# Install dependencies
npm install
# Start development server
npm run devAvailable Scripts
npm run build- Build for productionnpm run build:dev- Build for developmentnpm run build:watch- Build in watch modenpm run dev- Development mode with hot reloadnpm run type-check- TypeScript type checkingnpm run lint- ESLint checkingnpm run lint:fix- ESLint auto-fixnpm run test- Run testsnpm run test:watch- Run tests in watch modenpm run clean- Clean build directory
Project Structure
src/
├── base/ # Base UI components
│ ├── Button.jsx # Button component
│ ├── Input.jsx # Input component
│ ├── Label.jsx # Label component
│ ├── Loader.jsx # Loading component
│ ├── Dropdown.jsx # Dropdown component
│ ├── MultiDropdown.jsx # Multi-select dropdown
│ └── Illustration.jsx # Illustration component
├── functional/ # Functional components
│ ├── Table.jsx # Data table
│ ├── Tabs.jsx # Tab navigation
│ ├── Wizard.jsx # Multi-step wizard
│ ├── ModalWrapper.jsx # Modal wrapper
│ ├── PopupWrapper.jsx # Popup wrapper
│ ├── PopUpMenu.jsx # Popup menu
│ ├── ConfirmModal.jsx # Confirmation modal
│ ├── Labels.jsx # Label management
│ ├── List.jsx # List component
│ ├── Error.jsx # Error component
│ ├── Loading.jsx # Loading component
│ └── Breadcrumbs.jsx # Breadcrumb navigation
├── layouts/ # Layout components
│ ├── PanelLayout.jsx # Panel layout
│ └── ScreenLayout.jsx # Screen layout
├── contexts/ # React contexts
│ ├── ModalContext.jsx # Modal context
│ └── WizardContext.jsx # Wizard context
├── hooks/ # Custom React hooks
│ └── useResizeObserver.jsx # Resize observer hook
├── utils/ # Utility functions
│ └── general.util.js # General utilities
└── index.ts # Main entry pointBuilding
The SDK builds to multiple formats:
- CommonJS (
.cjs.js) - For Node.js and bundlers - ES Modules (
.esm.js) - For modern bundlers - TypeScript declarations (
.d.ts) - For TypeScript support - CSS (
styles.css) - For styling
Testing with yalc
# In the SDK directory
npm run build
yalc publish
# In your project directory
yalc add da-apps-sdk
npm install🎨 Styling and CSS
The SDK includes a comprehensive CSS file with all Tailwind CSS utilities and custom component styles. To ensure proper styling, you need to import the CSS file in your application.
CSS Import
Option 1: Import in your main application file
// In your main App.jsx, index.jsx, or similar
import "da-apps-sdk/styles.css";Option 2: Import in your CSS file
/* In your main CSS file */
@import "da-apps-sdk/styles.css";Option 3: Import in your build configuration
// In your webpack.config.js, vite.config.js, or similar
import "da-apps-sdk/styles.css";Tailwind CSS Integration
The SDK uses Tailwind CSS with custom design tokens. If your application also uses Tailwind CSS, you may need to configure it to avoid conflicts:
// tailwind.config.js
module.exports = {
content: ["./src/**/*.{js,ts,jsx,tsx}", "./node_modules/da-apps-sdk/dist/**/*.{js,ts,jsx,tsx}"],
// ... rest of your config
};Custom Design System
The SDK includes a custom design system with:
- Primary Colors: Blue-based color palette
- Secondary Colors: Gray-based color palette
- Custom Spacing: Extended spacing scale
- Custom Typography: Extended font sizes
- Custom Shadows: Soft and medium shadow variants
- Custom Animations: Fade and slide animations
Component-Specific Classes
The SDK provides utility classes for common component patterns:
/* Button variants */
.btn-primary
.btn-secondary
.btn-outline
/* Input styles */
.input-base
/* Card styles */
.card-base
/* Modal styles */
.modal-overlay
.modal-content
/* Dropdown styles */
.dropdown-menu
/* Tooltip styles */
.tooltip-base
/* Loading spinner */
.spinner
/* Alert styles */
.alert-success
.alert-error
.alert-warning
.alert-info;Troubleshooting Styling Issues
Classes not applying:
- Ensure you've imported the CSS file
- Check that the CSS file is being loaded in your browser
- Verify there are no CSS conflicts with your application styles
- Check the browser's developer tools for CSS loading errors
Conflicts with existing Tailwind:
- Configure your Tailwind to include the SDK's content paths
- Use the
cn()utility function to merge classes safely - Consider using CSS modules or scoped styles if conflicts persist
Missing styles in production:
- Ensure your build process includes the CSS file
- Check that the CSS file is being copied to your build output
- Verify the CSS file path in your production environment
🔧 Component Examples
Using the Table Component
import { Table } from "da-apps-sdk";
const data = [
{ id: 1, name: "John Doe", email: "[email protected]", status: "Active" },
{ id: 2, name: "Jane Smith", email: "[email protected]", status: "Inactive" },
];
const columns = [
{ key: "name", title: "Name" },
{ key: "email", title: "Email" },
{
key: "status",
title: "Status",
render: (value) => (
<span
className={`px-2 py-1 rounded text-xs ${
value === "Active" ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800"
}`}
>
{value}
</span>
),
},
];
const actions = [
{ name: "Add User", onClick: () => console.log("Add user") },
{ name: "Export", onClick: () => console.log("Export") },
];
<Table data={data} columns={columns} actions={actions} onRowClick={(row) => console.log("Row clicked:", row)} />;Using the Modal Context
import { ModalContextProvider, useModalContext } from "da-apps-sdk";
function MyComponent() {
const { openModal, closeModal } = useModalContext();
const handleOpenModal = () => {
openModal({
title: "Confirmation",
content: "Are you sure you want to proceed?",
onConfirm: () => {
console.log("Confirmed!");
closeModal();
},
});
};
return <button onClick={handleOpenModal}>Open Modal</button>;
}
// Wrap your app with the provider
<ModalContextProvider>
<MyComponent />
</ModalContextProvider>;Using the Panel Layout
import { PanelLayout } from "da-apps-sdk";
function App() {
return (
<PanelLayout>
<div className="p-6">
<h1>Dashboard Content</h1>
{/* Your app content */}
</div>
</PanelLayout>
);
}Using the Tabs Component
import { Tabs } from "da-apps-sdk";
const tabs = [
{
id: 1,
label: "Users",
value: "users",
component: <div>Users content</div>,
},
{
id: 2,
label: "Settings",
value: "settings",
component: <div>Settings content</div>,
},
];
<Tabs tabs={tabs} onTabChange={(value) => console.log("Tab changed:", value)} />;Using the Wizard Component
import { Wizard, WizardContext } from "da-apps-sdk";
const steps = [
{
id: 1,
title: "Step 1",
component: <div>Step 1 content</div>,
},
{
id: 2,
title: "Step 2",
component: <div>Step 2 content</div>,
},
];
<Wizard steps={steps} />;🤝 Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Guidelines
- Follow TypeScript best practices
- Write comprehensive tests
- Use semantic commit messages
- Follow the existing code style
- Add proper documentation
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🆘 Support
For support and questions:
- Create an issue in the repository
- Contact the development team
- Check the documentation
🔄 Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
📝 Changelog
See CHANGELOG.md for a list of changes and version history.
