|
| 1 | +--- |
| 2 | +title: "Filter UI" |
| 3 | +description: "Build flexible filter panels for list and view toolbars" |
| 4 | +--- |
| 5 | + |
| 6 | +import { ComponentDemo } from '@/app/components/ComponentDemo'; |
| 7 | + |
| 8 | +The Filter UI component renders configurable filters with text, select, date, and boolean inputs. |
| 9 | + |
| 10 | +## JSON Configuration |
| 11 | + |
| 12 | +```plaintext |
| 13 | +{ |
| 14 | + type: 'filter-ui', |
| 15 | + layout: 'popover', |
| 16 | + showApply: true, |
| 17 | + showClear: true, |
| 18 | + filters: [ |
| 19 | + { field: 'name', label: 'Name', type: 'text', placeholder: 'Search name' }, |
| 20 | + { field: 'status', label: 'Status', type: 'select', options: [ |
| 21 | + { label: 'Open', value: 'open' }, |
| 22 | + { label: 'Closed', value: 'closed' } |
| 23 | + ] }, |
| 24 | + { field: 'created_at', label: 'Created', type: 'date-range' } |
| 25 | + ] |
| 26 | +} |
| 27 | +``` |
| 28 | + |
| 29 | +## Basic Usage |
| 30 | + |
| 31 | +<ComponentDemo |
| 32 | + schema={{ |
| 33 | + type: 'filter-ui', |
| 34 | + layout: 'popover', |
| 35 | + showApply: true, |
| 36 | + showClear: true, |
| 37 | + filters: [ |
| 38 | + { field: 'name', label: 'Name', type: 'text', placeholder: 'Search name' }, |
| 39 | + { |
| 40 | + field: 'status', |
| 41 | + label: 'Status', |
| 42 | + type: 'select', |
| 43 | + options: [ |
| 44 | + { label: 'Open', value: 'open' }, |
| 45 | + { label: 'Closed', value: 'closed' }, |
| 46 | + { label: 'In Progress', value: 'in_progress' } |
| 47 | + ] |
| 48 | + }, |
| 49 | + { field: 'priority', label: 'Priority', type: 'number' }, |
| 50 | + { field: 'created_at', label: 'Created', type: 'date-range' } |
| 51 | + ] |
| 52 | + }} |
| 53 | + title="Filter UI" |
| 54 | + description="Popover-based filters with apply and clear actions." |
| 55 | +/> |
| 56 | + |
| 57 | +## Schema |
| 58 | + |
| 59 | +```plaintext |
| 60 | +interface FilterUISchema { |
| 61 | + type: 'filter-ui'; |
| 62 | + filters: Array<{ |
| 63 | + field: string; |
| 64 | + label?: string; |
| 65 | + type: 'text' | 'number' | 'select' | 'date' | 'date-range' | 'boolean'; |
| 66 | + operator?: 'equals' | 'contains' | 'startsWith' | 'gt' | 'lt' | 'between' | 'in'; |
| 67 | + options?: Array<{ label: string; value: any }>; |
| 68 | + placeholder?: string; |
| 69 | + }>; |
| 70 | + values?: Record<string, any>; |
| 71 | + onChange?: string; |
| 72 | + showClear?: boolean; |
| 73 | + showApply?: boolean; |
| 74 | + layout?: 'inline' | 'popover' | 'drawer'; |
| 75 | +} |
| 76 | +``` |
0 commit comments