Skip to content

Commit 3e12827

Browse files
committed
Add drag & drop
1 parent 11b4b7e commit 3e12827

12 files changed

Lines changed: 1577 additions & 202 deletions

File tree

NOTICES

Lines changed: 159 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,99 @@
1+
@dnd-kit/accessibility 3.1.1
2+
MIT
3+
MIT License
4+
5+
Copyright (c) 2021, Claudéric Demers
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.
24+
25+
@dnd-kit/core 6.3.1
26+
MIT
27+
MIT License
28+
29+
Copyright (c) 2021, Claudéric Demers
30+
31+
Permission is hereby granted, free of charge, to any person obtaining a copy
32+
of this software and associated documentation files (the "Software"), to deal
33+
in the Software without restriction, including without limitation the rights
34+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35+
copies of the Software, and to permit persons to whom the Software is
36+
furnished to do so, subject to the following conditions:
37+
38+
The above copyright notice and this permission notice shall be included in all
39+
copies or substantial portions of the Software.
40+
41+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47+
SOFTWARE.
48+
49+
@dnd-kit/sortable 10.0.0
50+
MIT
51+
MIT License
52+
53+
Copyright (c) 2021, Claudéric Demers
54+
55+
Permission is hereby granted, free of charge, to any person obtaining a copy
56+
of this software and associated documentation files (the "Software"), to deal
57+
in the Software without restriction, including without limitation the rights
58+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
59+
copies of the Software, and to permit persons to whom the Software is
60+
furnished to do so, subject to the following conditions:
61+
62+
The above copyright notice and this permission notice shall be included in all
63+
copies or substantial portions of the Software.
64+
65+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
66+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
67+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
68+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
69+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
70+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
71+
SOFTWARE.
72+
73+
@dnd-kit/utilities 3.2.2
74+
MIT
75+
MIT License
76+
77+
Copyright (c) 2021, Claudéric Demers
78+
79+
Permission is hereby granted, free of charge, to any person obtaining a copy
80+
of this software and associated documentation files (the "Software"), to deal
81+
in the Software without restriction, including without limitation the rights
82+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
83+
copies of the Software, and to permit persons to whom the Software is
84+
furnished to do so, subject to the following conditions:
85+
86+
The above copyright notice and this permission notice shall be included in all
87+
copies or substantial portions of the Software.
88+
89+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
90+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
91+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
92+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
93+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
94+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
95+
SOFTWARE.
96+
197
@fast-csv/format 4.3.5
298
MIT
399
The MIT License
@@ -749,27 +845,27 @@ Apache-2.0
749845

750846
archiver-utils 2.1.0
751847
MIT
752-
Copyright (c) 2015 Chris Talkington.
753-
754-
Permission is hereby granted, free of charge, to any person
755-
obtaining a copy of this software and associated documentation
756-
files (the "Software"), to deal in the Software without
757-
restriction, including without limitation the rights to use,
758-
copy, modify, merge, publish, distribute, sublicense, and/or sell
759-
copies of the Software, and to permit persons to whom the
760-
Software is furnished to do so, subject to the following
761-
conditions:
762-
763-
The above copyright notice and this permission notice shall be
764-
included in all copies or substantial portions of the Software.
765-
766-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
767-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
768-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
769-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
770-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
771-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
772-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
848+
Copyright (c) 2015 Chris Talkington.
849+
850+
Permission is hereby granted, free of charge, to any person
851+
obtaining a copy of this software and associated documentation
852+
files (the "Software"), to deal in the Software without
853+
restriction, including without limitation the rights to use,
854+
copy, modify, merge, publish, distribute, sublicense, and/or sell
855+
copies of the Software, and to permit persons to whom the
856+
Software is furnished to do so, subject to the following
857+
conditions:
858+
859+
The above copyright notice and this permission notice shall be
860+
included in all copies or substantial portions of the Software.
861+
862+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
863+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
864+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
865+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
866+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
867+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
868+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
773869
OTHER DEALINGS IN THE SOFTWARE.
774870

775871
archiver-utils 3.0.4
@@ -922,30 +1018,30 @@ THE SOFTWARE.
9221018

9231019
big-integer 1.6.52
9241020
Unlicense
925-
This is free and unencumbered software released into the public domain.
926-
927-
Anyone is free to copy, modify, publish, use, compile, sell, or
928-
distribute this software, either in source code form or as a compiled
929-
binary, for any purpose, commercial or non-commercial, and by any
930-
means.
931-
932-
In jurisdictions that recognize copyright laws, the author or authors
933-
of this software dedicate any and all copyright interest in the
934-
software to the public domain. We make this dedication for the benefit
935-
of the public at large and to the detriment of our heirs and
936-
successors. We intend this dedication to be an overt act of
937-
relinquishment in perpetuity of all present and future rights to this
938-
software under copyright law.
939-
940-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
941-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
942-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
943-
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
944-
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
945-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
946-
OTHER DEALINGS IN THE SOFTWARE.
947-
948-
For more information, please refer to <http://unlicense.org>
1021+
This is free and unencumbered software released into the public domain.
1022+
1023+
Anyone is free to copy, modify, publish, use, compile, sell, or
1024+
distribute this software, either in source code form or as a compiled
1025+
binary, for any purpose, commercial or non-commercial, and by any
1026+
means.
1027+
1028+
In jurisdictions that recognize copyright laws, the author or authors
1029+
of this software dedicate any and all copyright interest in the
1030+
software to the public domain. We make this dedication for the benefit
1031+
of the public at large and to the detriment of our heirs and
1032+
successors. We intend this dedication to be an overt act of
1033+
relinquishment in perpetuity of all present and future rights to this
1034+
software under copyright law.
1035+
1036+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1037+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1038+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1039+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
1040+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1041+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1042+
OTHER DEALINGS IN THE SOFTWARE.
1043+
1044+
For more information, please refer to <http://unlicense.org>
9491045

9501046

9511047
binary 0.3.0
@@ -1636,13 +1732,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16361732

16371733
color-name 1.1.4
16381734
MIT
1639-
The MIT License (MIT)
1640-
Copyright (c) 2015 Dmitry Ivanov
1641-
1642-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1643-
1644-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1645-
1735+
The MIT License (MIT)
1736+
Copyright (c) 2015 Dmitry Ivanov
1737+
1738+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1739+
1740+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1741+
16461742
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16471743

16481744
command-line-args 6.0.1
@@ -5282,17 +5378,17 @@ THE SOFTWARE.
52825378

52835379
tslib 2.8.1
52845380
0BSD
5285-
Copyright (c) Microsoft Corporation.
5286-
5287-
Permission to use, copy, modify, and/or distribute this software for any
5288-
purpose with or without fee is hereby granted.
5289-
5290-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
5291-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5292-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
5293-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5294-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
5295-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5381+
Copyright (c) Microsoft Corporation.
5382+
5383+
Permission to use, copy, modify, and/or distribute this software for any
5384+
purpose with or without fee is hereby granted.
5385+
5386+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
5387+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5388+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
5389+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5390+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
5391+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
52965392
PERFORMANCE OF THIS SOFTWARE.
52975393

52985394
typical 7.3.0

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Returns a `PivotTableResult` dict containing the current `config` state.
104104
| `locked` | `bool` | `False` | Viewer mode with exploration enabled. Toolbar config controls are read-only, viewer-safe actions like data export and group expand/collapse remain available, and header-menu sorting/filtering/`Show Values As` plus drill-down still work. |
105105
| `export_filename` | `str \| None` | `None` | Base filename (without extension) for exported files (.xlsx, .csv, .tsv). Date and extension are appended automatically. Defaults to `"pivot-table"`. |
106106

107-
> **Frontend-only interactions:** Column resize (drag header edges) and fullscreen mode (toolbar expand icon) are available automatically when `interactive=True`. No additional Python parameters are needed.
107+
> **Frontend-only interactions:** Drag-and-drop field reordering/moving, column resize (drag header edges), and fullscreen mode (toolbar expand icon) are available automatically when `interactive=True`. No additional Python parameters are needed.
108108
109109
#### Data Control
110110

@@ -113,7 +113,7 @@ Returns a `PivotTableResult` dict containing the current `config` state.
113113
| `null_handling` | `str \| dict[str, str] \| None` | `None` | How to treat null/NaN values. See [Null Handling](#null-handling). |
114114
| `hidden_attributes` | `list[str] \| None` | `None` | Column names to hide entirely from the UI. |
115115
| `hidden_from_aggregators` | `list[str] \| None` | `None` | Column names hidden from the values/aggregators dropdown only. |
116-
| `frozen_columns` | `list[str] \| None` | `None` | Column names that cannot be removed from their toolbar zone. |
116+
| `frozen_columns` | `list[str] \| None` | `None` | Column names that cannot be removed from their toolbar zone and cannot be reordered or moved via drag-and-drop. |
117117
| `sorters` | `dict[str, list[str]] \| None` | `None` | Custom sort orderings per dimension. Maps column name to ordered list of values. |
118118
| `menu_limit` | `int \| None` | `None` | Max items in the header-menu filter checklist. Defaults to 50. |
119119
| `execution_mode` | `str` | `"auto"` | Performance execution mode. See [Execution Mode](#execution-mode). |
@@ -521,6 +521,29 @@ When `interactive=True`, hovering over the top-right of the toolbar reveals util
521521

522522
In **locked mode**, Reset, Swap, and config import/export are hidden. `Export Data` remains available as a viewer action. The Settings gear remains visible, its popover shows read-only display status plus group expand/collapse actions, and header-menu sorting, filtering, and `Show Values As` stay enabled.
523523

524+
### Drag-and-Drop Field Configuration
525+
526+
When `interactive=True`, each chip in the Rows, Columns, and Values toolbar zones has a **grip-dots drag handle** on its left side. Drag chips to:
527+
528+
- **Reorder within a zone** — change the grouping hierarchy (e.g., swap which dimension is the outer vs. inner group in Rows).
529+
- **Move between zones** — drag a chip from Rows to Columns (or vice versa), or between Rows/Columns and Values. The Values zone only accepts numeric columns; non-numeric drops are silently rejected.
530+
531+
**Visual feedback:**
532+
- A floating overlay chip follows the cursor during drag.
533+
- The source chip stays in place at reduced opacity (ghosted).
534+
- When dragging over a valid target zone, the zone highlights with a dashed border and subtle tint.
535+
- Within-zone reorders show smooth shift animations as chips make room.
536+
537+
**Constraints:**
538+
- `frozen_columns` render without drag handles and cannot be dragged.
539+
- Synthetic measures cannot be dragged to other zones.
540+
- When `locked=True`, drag-and-drop is fully disabled.
541+
- A 5 px activation distance distinguishes clicks from drags, so remove buttons and dropdown toggles work normally.
542+
543+
**Config cleanup on move:** When fields move between zones, related config properties (aggregation, sort, collapsed groups, subtotals, conditional formatting, show-values-as, per-measure totals) are automatically synchronized.
544+
545+
No Python API parameter is required — drag-and-drop is a purely frontend interaction.
546+
524547
### Column Resize
525548

526549
Drag the **right edge of any column header** to resize that column. A thin resize handle appears on hover (cursor changes to `col-resize`). Minimum column width is 40 px.
@@ -598,6 +621,7 @@ The returned `config` dict contains the current supported configuration state, i
598621
The component follows WAI-ARIA patterns for all interactive elements:
599622

600623
- **Toolbar**: Arrow keys navigate between toolbar buttons (roving tabindex). Space/Enter activates.
624+
- **Drag-and-drop**: Space to pick up a chip, arrow keys to move, Space to drop at the new position. Screen reader announcements provided by dnd-kit.
601625
- **Header menus**: Escape closes. Arrow keys navigate options. Space/Enter selects.
602626
- **Export/Import popovers**: Focus is automatically placed on the first interactive element when opened. Tab/Shift+Tab moves between controls; tabbing out closes the popover.
603627
- **Settings popover** (gear icon): Focus moves to first checkbox on open. Escape closes. Tab navigates between toggles.
@@ -623,7 +647,7 @@ uv pip install -e '.[with-streamlit]' --force-reinstall
623647
uv run streamlit run streamlit_app.py
624648
```
625649

626-
The example app (`streamlit_app.py`) contains 16 sections covering the major features and usage patterns with interactive examples and inline documentation.
650+
The example app (`streamlit_app.py`) contains 17 sections covering the major features and usage patterns with interactive examples and inline documentation.
627651

628652
### Building the frontend
629653

0 commit comments

Comments
 (0)