27 |
--------------------------------------------------------------------------------
/src/lib/components/table/components/CellEditableTemplate.svelte:
--------------------------------------------------------------------------------
1 |
19 |
20 | {#if !column.cell?.componentEditable}
21 | {#if getNestedValue(row, column.accessor) !== undefined}
22 | {getNestedValue(row, column.accessor)}
23 | {:else}
24 | {row[column.accessor]}
25 | {/if}
26 | {:else if column.cell?.componentEditable}
27 |
36 | {:else if column?.cell?.simplified}
37 | {@html column.cell.simplified({ column, row, rowIndex, value })}
38 | {/if}
39 |
--------------------------------------------------------------------------------
/src/lib/components/ui/dropdown-menu/dropdown-menu-item.svelte:
--------------------------------------------------------------------------------
1 |
14 |
15 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/lib/components/ui/input/input.svelte:
--------------------------------------------------------------------------------
1 |
13 |
14 |
36 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Sebastian Drozd
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/lib/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte:
--------------------------------------------------------------------------------
1 |
15 |
16 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/lib/components/table/components/SortingToggle.svelte:
--------------------------------------------------------------------------------
1 |
10 |
11 | {#if $sorting.accessor == column.accessor}
12 | {#if $sorting.direction == 'asc'}
13 |
23 | {:else if $sorting.direction == 'desc'}
24 |
34 | {/if}
35 | {:else}
36 |
46 | {/if}
47 |
--------------------------------------------------------------------------------
/src/routes/(examples)/column-ordering/+page.svelte:
--------------------------------------------------------------------------------
1 |
43 |
44 |
45 |
12 | Virtualisation is not easy especially with something as complex as tables. In a private
13 | project I use it with the table component in several places, but I am aware of one bug and
14 | until I fix it it will not be implemented. I need to spend some time on this and it will
15 | certainly be added.
16 |
17 |
18 |
Client-side functionalities
19 |
20 | I actually have this already implemented in a private project too, but it's not pretty code and
21 | needs to be rewritten before it sees the light of day.
22 |
23 |
More examples
24 |
25 | There are things such as filter slots or additional actions or global search that are not
26 | described. More examples will be added when I have time. Unfortunately I have a lot of other
27 | work right now.
28 |
29 |
Advanced filter functionality
30 |
31 | I don't quite know if this fits in well with the theme of the table, on the one hand it is
32 | geared towards server data, but on the other hand such a component is something else entirely.
33 | Maybe it will be as an additional component.
34 |
35 |
36 |
37 |
Async loading indicator
38 |
39 | In theory this is implemented and you can pass `loading` to a component, but the loading
40 | indicator is a simple loader, not some beauty. Definitely to be improved as I find time.
41 |
42 |
43 |
Column filtering
44 |
45 | I'm not a big fan of this solution but I know some people will need it. To be done in the
46 | future.
47 |
48 |
Density toggle
49 |
This is actually implemented in my private project, I will soon add it for sure.
94 | In response to a question, I add an example of how to build column filtering. The component as
95 | such does not have a built-in way to add column filtering with a single value like
96 | "enableColumnFilter: number". You need to add a custom header cell with input and handle the
97 | change of value. You could make a store and bind values to it and then refetch the data by
98 | detecting the change.
99 |
Not tested enough, I would not use it in production
111 |
Pagination does not work with virtualization
112 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TZEZAR's TABLE
2 |
3 | > **Archived and No Longer Maintained**
4 |
5 | This project has been archived and is no longer actively maintained. It is provided as-is, and no further updates, bug fixes, or new features will be added.
6 |
7 | ## Status
8 |
9 | - **Archived**: The repository is in an archived state and is no longer actively developed or supported.
10 | - **No active support**: No further issues will be addressed, and pull requests will not be merged.
11 |
12 | ## Usage
13 |
14 | You are welcome to fork or clone the repository if you wish to continue using or contributing to it. However, please be aware that there will be no official updates or support from the maintainers.
15 |
16 | ## Alternatives
17 |
18 | If you're looking for actively maintained alternatives, you might consider [Tzezar's Datagrid](https://datagrid.tzezar.pl/) built with svelte 5.
19 |
20 | \
21 | \
22 | \
23 | \
24 | \
25 | \
26 | \
27 | \
28 | \
29 | \
30 | \
31 | \
32 | \
33 | \
34 | \
35 | \
36 | \
37 | \
38 | ...\
39 | ---
40 |
41 |
42 |
43 | Table component built in svelte based on shadcn-svelte components.
44 |
45 | [documentation, examples and live demo](https://tzezar-table.vercel.app/)
46 |
47 | ## What is this?
48 | Table component for easy display of tables based on remote data (planned support for client-side functionality).
49 | Based on the excellent [shadcn-svelte](https://github.com/huntabyte/shadcn-svelte) component library.
50 |
51 | ## For whom?
52 | You copy the [component](https://github.com/tzezar/table/tree/main/src/lib/components/table) directly into your project and can edit it as you wish. It is something between a ready-made data-grid and a headless table.
53 |
54 | ## Supported Functions
55 | - Virtualization
56 | - Column hiding
57 | - Column reordering
58 | - Column resizing
59 | - Conditional styling
60 | - Content alignment
61 | - Custom content
62 | - Pagination
63 | - Inline row editing
64 | - Modal row editing
65 | - Row editing
66 | - Row expanding
67 | - Single column sorting
68 |
69 | ## Shortcuts
70 | [live examples](https://tzezar-table.vercel.app/)
71 | [installation](https://tzezar-table.vercel.app/installation)
72 | [component code](https://github.com/tzezar/table/tree/main/src/lib/components/table)
73 | [examples code](https://github.com/tzezar/table/tree/main/src/routes/(examples))
74 |
75 | ## MIT License
76 |
77 | Copyright (c) 2024 Sebastian Drozd
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 |
--------------------------------------------------------------------------------
/src/routes/installation/+page.svelte:
--------------------------------------------------------------------------------
1 |
5 |
6 |
59 | npm i svelte-dnd-action
60 | npm i svelte-legos
61 |
62 |
63 |
64 |
Optional
65 |
66 |
67 | npm install mode-watcher
68 | npm i @tanstack/svelte-query
69 | npm i @tanstack/svelte-query-devtools
70 |
71 |
72 |
73 |
74 | mode-watches is easy way to implement dark mode, and tanstack-query is good for data fetching
75 |
76 |
77 |
04/04/2024 update
78 |
79 | I rebuilt the shadcn table to use divs (easier styling, ability to change width, no weird
80 | behaviour) and used them in the component. It made component cleaner and easier to read. You don't
81 | have to overwrite it, you can have both the
82 | official shadcn version and the one for the component built with divs.
83 |
84 |
85 |
86 |
87 |
88 |
89 |
Code from examples
90 |
91 | The code from the example as well as the annotations are available at GITHUB
95 |
166 | It is more common practice to save a row when clicking the save button than to edit cells directly
167 | as in the previous example. The nature of the component is very flexible, in this example I will
168 | show how I usually do it. You can add e.g. cancel button etc. it is up to you. Check out the code
169 | on github for more tips.
170 |
289 | I entrust to you a modest component, crafted atop the robust shadcn-svelte library, utilizing
290 | built-in svelte functions such as stores, among others. Every aspect of the table - its
291 | aesthetics, functionality, and beyond - can be customized to your heart's content. This serves as
292 | an excellent foundation to tailor a solution precisely to your requirements. If a component or
293 | basic solution doesn't quite align with your vision, fear not - mold it to your liking!
294 |
295 |
296 |
For whom?
297 |
298 | The component efficiently manages server-side data (with client-side capability coming soon). It's
299 | designed for seamless extension with extra features, and styling integration should pose no major
300 | challenges. If you're already leveraging shadcn-svelte and tailwind, incorporating this component
301 | into your workflow is a natural fit.
302 |
303 |
Genesis
304 |
305 | This project started as a way for me to make warehouse operations smoother with dynamic table
306 | displays. Despite trying options like ag-grid and headless solutions, none quite fit the bill.
307 | 'Full' solutions were tough to customize, and headless ones like tanstack-table had tricky
308 | documentation. Dealing with remote data was also a hassle. So, TZEZAR's TABLE (pronounced like
309 | 'Caesar') was born to bridge the gap, offering flexibility. Feel free to tweak this component to
310 | suit your needs!
311 |
312 |
313 |
Currently Supported Functions
314 |
315 |
Column Hiding
316 |
Column Reordering
317 |
Column Resizing
318 |
Conditional Styling
319 |
Content Alignment
320 |
Custom Content
321 |
Pagination
322 |
Inline Row Editing
323 |
Modal Row Editing
324 |
Row Editing
325 |
Row Expanding
326 |
Single Column Sorting
327 |
328 |
Planned Functions
329 |
330 |
Client-Side Functionality
331 |
332 |
Virtualization
333 |
Added 21/03/2024
334 |
335 |
336 |
Fullscreen Mode
337 |
Added 21/03/2024
338 |
339 |
340 | HELP NEEDED For unknown reason portal set to #tableContainer
341 | cause expandedRows to render below table.
342 |
343 |
344 |
345 |
Not Planned for Immediate Addition
346 |
347 |
Aggregation and Grouping
348 |
Column Pinning
349 |
350 |
351 | If you spot any missing features, don't worry! Adding them should be a breeze. Feel free to
352 | suggest ideas or improvements, and let's work together to make our component even better. Your
353 | input is always welcome, and together, we can create something truly outstanding!
354 |
355 |
356 |
357 | If you find the project interesting feel free to give a star on github. Thanks! ❤️
360 |