JSPM

@egovernments/digit-ui-components

0.2.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1503
  • Score
    100M100P100Q111480F
  • License MIT

Package Exports

  • @egovernments/digit-ui-components
  • @egovernments/digit-ui-components/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@egovernments/digit-ui-components) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

DIGIT UI Components

A comprehensive React component library for DIGIT platform applications, providing standardized UI components, form composers, and search interfaces.

📦 Install

npm install --save @egovernments/digit-ui-components

Latest Version: 0.2.1 🎉

🚀 What's New in v0.2.1

🔄 InboxSearchComposer Enhancements

1. Enhanced Table Component

  • Replaced old table with ResultsDataTable using react-data-table-component (v7.6.2)
  • Features: sorting, filtering, selection, pagination, and expandable rows
  • Better performance and customization options
{
  label: "Id",
  jsonPath: "id", 
  link: true, // Creates clickable links
  buttonProps: {
    size: "medium",
    icon: "Edit",
    linkTo: "/edit-page" // Optional: direct navigation
  }
}

3. Row Selection & Actions

// Row selection configuration
selectionProps: {
  showCheckBox: true,
  showSelectedState: true,
  selectableRowsNoSelectAll: false,
  showSelectedStatePosition: "top" // or "bottom"
}

// Action buttons for selected rows
actionProps: {
  actions: [
    { label: "Edit", variation: "secondary", icon: "Edit" },
    { label: "Delete", variation: "primary", icon: "Delete" }
  ]
}
footerProps: {
  showFooter: true,
  allowedRolesForFooter: ["ADMIN"],
  actionFields: [
    { 
      label: "Previous", 
      icon: "ArrowBack", 
      variation: "secondary",
      allowedRoles: ["USER"] 
    },
    { 
      label: "Next", 
      icon: "ArrowForward", 
      variation: "primary",
      allowedRoles: ["ADMIN"] 
    }
  ],
  setactionFieldsToRight: true
}

5. Expandable Rows

const ExpandedComponent = ({ data }) => (
  <pre>{JSON.stringify(data, null, 2)}</pre>
);

expandableProps: {
  expandableRows: true,
  expandableRowsComponent: ExpandedComponent
}

6. Editable Tables

  • Inline Editing: Edit fields directly within table rows
  • Popup Editing: Edit in modal with additional fields
  • Field Validation: FieldV1 configurations for consistency
// Inline editable column
{
  label: "Name",
  jsonPath: "data.name",
  editable: true,
  editableFieldConfig: {
    type: "text",
    validation: { minlength: 2 },
    populators: { name: "row.name" }
  }
}

// Additional popup fields
additionalPopupColumns: [
  {
    label: "Description",
    jsonPath: "data.description", 
    editable: true,
    editableFieldConfig: {
      type: "textarea",
      populators: { name: "row.description" }
    }
  }
]

7. UICustomizations Handlers

Enhanced event handling through UICustomizations:

// Handle link column clicks
linkColumnHandler: (row) => {
  const url = `/${window.contextPath}/employee/view?id=${row?.id}`;
  window.location.href = url;
},

// Handle row selections
selectionHandler: (event) => {
  const { allSelected, selectedCount, selectedRows } = event;
  console.log('Selected:', selectedCount, 'rows');
},

// Handle action button clicks
actionSelectHandler: (index, label, selectedRows) => {
  if (label === "Delete") {
    // Handle delete action
  }
},

// Handle footer action clicks  
footerActionHandler: (index, event) => {
  console.log('Footer action:', index, event);
}

🎯 FormComposer Enhancements

1. Extended Field Types

Now supports 20+ field types:

// New field types added
"text", "date", "time", "geolocation", "password", 
"search", "number", "numeric", "textarea", "radio", 
"dropdown", "select", "radioordropdown", "toggle", 
"checkbox", "multiselectdropdown", "mobileNumber",
"component", "custom", "amount", "locationdropdown", 
"apidropdown", "dateRange"

2. Boundary Dropdowns (Dependent Dropdowns)

{
  type: "boundary",
  label: "Administrative Area",
  populators: {
    name: "boundary",
    levelConfig: {
      lowestLevel: "VILLAGE",
      highestLevel: "STATE",
      isSingleSelect: ["STATE"] // Single selection for state level
    },
    hierarchyType: "ADMIN_BOUNDARY",
    layoutConfig: {
      isDropdownLayoutHorizontal: true,
      isLabelFieldLayoutHorizontal: false  
    },
    preSelected: ["STATE_001", "DISTRICT_001"], // Pre-fill values
    frozenData: [ // Locked selections
      { code: "STATE_001", name: "State 1" }
    ]
  }
}

🎨 Major Enhancements

  • 🌍 Boundary Dropdowns for hierarchical administrative boundary selection
  • 📊 Editable Tables with inline editing and popup functionality
  • 🎨 Improved Typography & Styling with responsive design updates
  • 🔧 Better Component Variants for increased flexibility

Breaking Changes

  • MDMS v2 Integration - Updated prop formats required
  • Pagination Updates - Enhanced pagination implementation
  • Employee → UserType - Configuration property updates
  • Custom Row Components - New structure requirements

📖 Migration Guide - Complete guide for upgrading from v0.2.0

🎯 Usage

Installation

Add the dependency to your package.json:

"@egovernments/digit-ui-components": "0.2.1"

Basic Import

// Import individual components
import { Button, TextInput, FormComposerV2, InboxSearchComposer } from "@egovernments/digit-ui-components";

// Import SVG icons
import { SVG } from "@egovernments/digit-ui-components";

// Usage
<Button variant="primary">Click Me</Button>
<SVG.Accessibility />

Component Categories

🔧 Atoms (Basic Components)

  • Button, TextInput, Toggle, Tag, RadioButtons, OTPInput
  • Dropdown, MultiSelectDropdown, CheckBox, Chip
  • Loader, Toast, Timeline, Stepper, and more

🧩 Molecules (Composite Components)

  • CustomDropdown, ApiDropdown, ResultsDataTable
  • FilterCard, SummaryCard, FormCard, PanelCard
  • Header, Footer, SideNav, BottomSheet

🎯 HOCs (Higher Order Components)

  • FormComposerV2 - Dynamic form builder
  • InboxSearchComposer - Search & inbox interfaces
  • BoundaryFilter - Hierarchical boundary selection

📋 Quick Start Examples

FormComposer Usage

import { FormComposerV2 } from "@egovernments/digit-ui-components";

const formConfig = {
  head: "User Details",
  body: [
    {
      type: "text",
      label: "Name",
      isMandatory: true,
      populators: { name: "userName" }
    },
    {
      type: "boundary", // New boundary dropdown
      label: "Location",
      populators: {
        name: "location",
        hierarchyType: "ADMIN",
        levelConfig: {
          lowestLevel: "LOCALITY",
          highestLevel: "STATE"
        }
      }
    }
  ]
};

<FormComposerV2 
  config={[formConfig]} 
  onSubmit={handleSubmit}
  defaultValues={defaultData}
/>

InboxSearchComposer Usage

import { InboxSearchComposer } from "@egovernments/digit-ui-components";

const searchConfig = {
  headerLabel: "Search Applications", // Updated from 'label'
  type: "search",
  actions: { // Updated structure
    actionLabel: "Create New",
    actionRoles: ["ADMIN"],
    actionLink: "/create"
  },
  // ... rest of config
};

<div className="digit-inbox-search-wrapper">
  <InboxSearchComposer configs={searchConfig} />
</div>

🛠️ Local Development

Prerequisites

  • Node.js 14+
  • Yarn package manager

Setup Storybook

# Step 1: Install dependencies
yarn install 

# Step 2: Start Storybook
yarn storybook 

🔄 Migration & Version History

v0.2.1 (Current) - 2025-10-23

✨ Major Features

  • Enhanced FormComposer & InboxSearchComposer with improved config structure
  • Boundary Dropdowns for hierarchical selection (Country → State → City)
  • Editable Tables with inline editing and popup functionality
  • Footer Actions support in InboxSearchComposer
  • Custom Row Components in ResultsDataTable

🐛 Key Fixes

  • Fixed pagination issues in InboxSearchComposer
  • Resolved dropdown text clearing after re-render
  • Fixed multiple API call prevention
  • Improved error handling across components

⚠️ Breaking Changes

  • labelheaderLabel in InboxSearchComposer configs
  • employeeuserType in actionLink configurations
  • MDMS v2 prop format requirements
  • Enhanced pagination implementation

📖 Full Migration Guide

v0.2.0 - Previous Major Release

New Components Added

  • Error Message, Info Button, Panels, Popup Components
  • Stepper, TextBlock, Timeline Components
  • Uploader variants (UploadFile, UploadPopup, UploadImage)
  • PanelCard Molecule

Enhancements

  • Updated Button & Dropdown Component Styles
  • Toast animations and new type prop
  • Typography updates with lineHeight
  • Enhanced Color Typography

Migration Examples

Toast Component (v0.2.0 Breaking Change)

// ❌ Old Usage (pre v0.2.0)
<Toast info={true} label={"Info Toast"} />
<Toast warning="warning" label={"Warning Toast"}/>

// ✅ New Usage (v0.2.0+)
<Toast type="info" label={"Info Toast"} />
<Toast type="warning" label={"Warning Toast"} />
<Toast type="success" label={"Success Toast"} />

InboxSearchComposer Config (v0.2.1 Breaking Change)

// ❌ Old Config (v0.2.0)
const oldConfig = {
  label: "Search Applications",
  actionLabel: "Create",
  actionRoles: ["ADMIN"]
};

// ✅ New Config (v0.2.1)
const newConfig = {
  headerLabel: "Search Applications", // Changed from 'label'
  actions: { // Grouped under 'actions'
    actionLabel: "Create",
    actionRoles: ["ADMIN"],
    actionLink: "/create"
  }
};

📖 Documentation & Resources

📚 Documentation

📋 Sample Configurations & Examples

🎨 Live Examples

🤝 Contributors

Special thanks to our contributors:

📄 License

MIT © jagankumar-egov

🏛️ About DIGIT

This component library is part of the DIGIT (Digital Infrastructure for Governance, Impact & Transformation) platform - India's largest open-source platform for digital governance.

DIGIT Logo


🎯 Ready to build with DIGIT UI Components? Start with our Quick Start Guide or explore the Storybook for interactive examples!