|
| 1 | +# Navigator |
| 2 | + |
| 3 | +The Navigator Action is a utility designed to facilitate keyboard and click navigation within various UI components such as lists, trees, or tables. It aims to provide a consistent and intuitive way for users to navigate through items, select/deselect them, and perform actions based on user inputs. |
| 4 | + |
| 5 | +## Key Goals |
| 6 | + |
| 7 | +- Modularity: The navigator action should be modular and easily adaptable to different UI components and navigation requirements. |
| 8 | +- Customizability: Users should be able to configure navigation behavior and options according to specific needs. |
| 9 | +- Accessibility: The action should enhance accessibility by providing keyboard navigation support for users who rely on keyboard input. |
| 10 | +- Efficiency: Navigation should be efficient, allowing users to quickly move through items, select/deselect them, and perform actions with minimal effort. |
| 11 | + |
| 12 | +## Interaction Flow |
| 13 | + |
| 14 | +1. Keyboard Navigation: Users can navigate through items using arrow keys, page up/down, home/end keys. |
| 15 | +2. Selection: Single-clicking on an item selects/deselects it. |
| 16 | +3. Expansion/Collapse: Arrow keys, double-clicks, or specific keys like Right/Left arrows expand or collapse items with hierarchical structures. |
| 17 | +4. Efficient Navigation: Page up/down keys allow users to navigate through items efficiently, especially in long lists or tables. |
| 18 | +5. Drag and Drop: When enabled, users can drag items within the component and drop them onto valid targets. |
| 19 | +6. Multi-Select: When multi-select mode is enabled, users can select multiple items using Shift key and arrow keys or mouse click. |
| 20 | +7. Modifier Keys: Users can use modifier keys like Shift or Ctrl to modify selection behavior. |
| 21 | + |
| 22 | +## Supported Events and Actions |
| 23 | + |
| 24 | +### Keyboard Events |
| 25 | + |
| 26 | +- Arrow Up |
| 27 | +- Arrow Down |
| 28 | +- Arrow Right |
| 29 | +- Arrow Left |
| 30 | +- Page Up |
| 31 | +- Page Down |
| 32 | +- Home |
| 33 | +- End |
| 34 | +- Enter/Return |
| 35 | + |
| 36 | +### Extended Selection with Shift Key |
| 37 | + |
| 38 | +- Shift + Arrow Down - In a grid, this will select the next row. |
| 39 | +- Shift + Arrow Up - In a grid, this will select the previous row. |
| 40 | +- Shift + Arrow Right - In a grid, this will select the next cell |
| 41 | +- Shift + Arrow Left - In a grid, this will select the previous cell |
| 42 | +- Shift + Page Down - In a grid, this will select the next page of rows. |
| 43 | +- Shift + Page Up - In a grid, this will select the previous page of rows. |
| 44 | +- Shift + Home |
| 45 | +- Shift + End |
| 46 | +- Ctrl/Meta + 'X' (Cut) |
| 47 | +- Ctrl/Meta + 'C' (Copy) |
| 48 | +- Ctrl/Meta + 'V' (Paste) |
| 49 | + |
| 50 | +### Click Events |
| 51 | + |
| 52 | +- Single Click |
| 53 | +- Modifier Keys (Shift or Ctrl) |
| 54 | +- DoubleClick |
| 55 | +- Drag and Drop |
| 56 | + |
| 57 | +## Options |
| 58 | + |
| 59 | +- Multi-Select (default: `false`) |
| 60 | +- Page Size (default: 10) |
| 61 | +- Allow Drag (default: `false`) |
| 62 | +- Allow Drop (default: `false`) |
| 63 | +- horizontal (default: `false`) |
| 64 | +- vertical (default: `true`) |
| 65 | + |
| 66 | +## Events |
| 67 | + |
| 68 | +- `select`: Triggered when an item is selected. |
| 69 | +- `change`: Triggered when the selection changes. |
| 70 | +- `expand`: Triggered when an item is expanded. |
| 71 | +- `collapse`: Triggered when an item is collapsed. |
| 72 | +- `dragstart`: Triggered when an item is dragged. |
| 73 | +- `dragover`: Triggered when an item is dragged over a valid drop target. |
| 74 | +- `drop`: Triggered when an item is dropped onto a valid target. |
| 75 | + |
| 76 | +## Implementation Considerations |
| 77 | + |
| 78 | +- Maintain a reference to the first clicked or selected item when Shift key is pressed. |
| 79 | +- Track the direction of navigation (up or down) to determine which items to include in the selection. |
| 80 | +- Update the selection dynamically as the user navigates with arrow keys while holding down the Shift key. |
| 81 | +- Implement event handlers for drag start, drag over, and drop events. |
| 82 | +- Determine valid drop targets based on the UI component's structure and state. |
| 83 | +- Update the component's state based on drag and drop interactions. |
| 84 | +- Offload state management to the store or parent component to ensure consistency across multiple instances of the navigator action. |
0 commit comments