A Teable plugin for automatic ranking of table records.
- π Multiple Ranking Methods - Standard and Dense ranking algorithms
- π― Field Mapping - Flexible source and target field selection
- π Group-based Ranking - Calculate rankings within specific groups
- π§ Advanced Configuration - Sort direction, zero value handling, and more
- π¨ Theme Support - Full light/dark mode compatibility with automatic theme detection
- π Internationalization - Complete i18n support (English/Chinese)
- π± Responsive Design - Optimized for all screen sizes
- β‘ Performance Optimized - Built with React Query for efficient data fetching
- π‘οΈ Error Handling - Comprehensive error reporting and user feedback
- π Teable Integration - Seamless integration with Teable tables and fields
- Next.js 14.2.14 - React full-stack framework with App Router
- React 18.2.0 - UI library with modern React features
- TypeScript 5 - Type-safe JavaScript superset (strict mode enabled)
@teable/sdk- Plugin bridge and UI configuration@teable/openapi- API client and type definitions@teable/core- Core type definitions and utilities@teable/ui-lib- Teable official UI component library (shadcn/ui based)@teable/next-themes- Theme switching support
- Tailwind CSS 3.4.1 - Atomic CSS framework with Teable UI configuration
- Lucide React - Icon library for modern interfaces
@tanstack/react-query 4.36.1- Server state management, caching, and synchronizationreact-i18next 14.1.0- Internationalization frameworki18next 23.10.1- Core internationalization library
- Node.js 18+
- npm or yarn
- Teable account with plugin access
npm installnpm run dev -p 3001Visit http://localhost:3001 to view the plugin.
npm run buildnpm startnpm run lint # Run ESLintsrc/
βββ app/ # Next.js App Router
β βββ page.tsx # Main app entry with i18n and theme setup
β βββ Main.tsx # Theme and QueryClient integration
β βββ layout.tsx # Root layout component
β βββ globals.css # Global styles and CSS variables
βββ components/
β βββ RankingPages.tsx # Main ranking interface component
β βββ ErrorBoundary.tsx # Error boundary component
β βββ context/ # React Context providers
β β βββ EnvProvider.tsx # Environment variable injection
β β βββ I18nProvider.tsx # Internationalization provider
β β βββ getQueryClient.ts # QueryClient configuration
β β βββ types.ts # TypeScript type definitions
β βββ ranking/ # Ranking-specific components
β β βββ FieldSelector.tsx # Field selection component
β β βββ GroupFieldSelector.tsx # Group field selection
β β βββ ViewSelector.tsx # View selection component
β β βββ RankingConfig.tsx # Ranking configuration UI
β β βββ RankingExecutor.tsx # Ranking execution engine
β β βββ RankingAlgorithms.ts # Ranking algorithm implementation
β β βββ types.ts # Ranking type definitions
β βββ ui/ # UI utility components
β βββ Icons.tsx # Icon components
βββ hooks/ # Custom React hooks
β βββ useInitApi.ts # API initialization
β βββ useFields.ts # Field data fetching
β βββ useFieldMap.ts # Field mapping utilities
β βββ useGlobalUrlParams.ts # URL parameter management
β βββ useToast.ts # Toast notifications
β βββ useViewId.ts # View ID management
β βββ useViews.ts # View data fetching
βββ lib/ # Business logic and utilities
β βββ api.ts # API configuration and authentication
βββ types/ # Global type definitions
β βββ index.ts # Type exports
βββ locales/ # Internationalization files
β βββ en.json # English translations
β βββ zh.json # Chinese translations
βββ image/ # Static image assets
βββ 20251120012132_rec_.gif # Feature demo GIF
The plugin reads configuration from URL parameters via EnvProvider.tsx:
baseId- Teable base identifierpluginId- Plugin identifierpluginInstallId- Plugin installation IDtableId- Target table for ranking operationsshareId,positionId,positionType- UI positioninglang,theme- Localization and theme settings
The plugin supports the following ranking configurations:
- Standard Ranking:
1, 2, 2, 4- Standard competition ranking - Dense Ranking:
1, 2, 2, 3- Dense ranking with no gaps - European Ranking:
1, 2, 2, 3- European competition ranking
- Skip Zero Values: Ignore zero values in ranking calculations
- Include Zero Values: Include zero values in ranking
- No Grouping: Calculate rankings across all records
- Group-based: Calculate rankings within specified groups
- CSS Variables - Comprehensive theme system with HSL color values
- Responsive Design - Mobile-first approach with breakpoints
- Component Isolation - Scoped styles for custom components
- Dark Mode Support - Automatic theme detection and switching
- Shadcn/ui Components - Modern, accessible UI components
- Teable UI Integration - Consistent with Teable design system
- Form Controls - Custom form elements for ranking configuration
Supported languages:
- English (en)
- Chinese (zh)
- Create translation file in
src/locales/[lang].json - Update
I18nProvider.tsxresources configuration - Add language-specific content to components
import { usePluginBridge } from '@teable/sdk';
const bridge = usePluginBridge();
// Listen for configuration changes
bridge.on('syncUIConfig', handleConfigChange);
// Get temporary token for API calls
const token = await bridge.getSelfTempToken();The plugin uses Teable's OpenAPI with automatic authentication:
import { openApi } from '@teable/openapi';
// All API calls are automatically authenticated
const fields = await openApi.getFields(tableId);
const records = await openApi.getTableRecords(tableId, viewId);The plugin implements two ranking algorithms:
// Example: Values [10, 20, 20, 30] β Ranks [1, 2, 2, 4]
// Standard competition ranking with gaps// Example: Values [10, 20, 20, 30] β Ranks [1, 2, 2, 3]
// Dense ranking without gapsWe welcome contributions! Please follow these steps:
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
