|
1 | 1 | <script lang="ts">
|
| 2 | + import Fa from 'svelte-fa'; |
| 3 | + import { faEye } from '@fortawesome/free-solid-svg-icons'; |
2 | 4 | import { popup } from '@skeletonlabs/skeleton';
|
3 | 5 | import type { PopupSettings } from '@skeletonlabs/skeleton';
|
4 | 6 |
|
|
8 | 10 | const popupCombobox: PopupSettings = {
|
9 | 11 | event: 'click',
|
10 | 12 | target: `${tableId}-columns-menu`,
|
11 |
| - placement: 'bottom' |
| 13 | + placement: 'bottom', |
| 14 | + closeQuery: '' |
| 15 | + }; |
| 16 | +
|
| 17 | + const selectAll = () => { |
| 18 | + columns = columns.map((column) => ({ ...column, visible: true })); |
| 19 | + }; |
| 20 | +
|
| 21 | + const deselectAll = () => { |
| 22 | + columns = columns.map((column) => ({ ...column, visible: false })); |
| 23 | + columns[0].visible = true; |
12 | 24 | };
|
13 | 25 | </script>
|
14 | 26 |
|
15 | 27 | <button
|
16 | 28 | type="button"
|
17 |
| - class="btn btn-sm variant-filled-primary rounded-full order-last" |
| 29 | + class="btn btn-sm variant-filled-primary rounded-full order-last gap-2" |
18 | 30 | aria-label="Open menu to hide/show columns"
|
19 |
| - use:popup={popupCombobox}>Columns</button |
| 31 | + use:popup={popupCombobox}><Fa icon={faEye} /> Columns</button |
20 | 32 | >
|
21 |
| - |
22 | 33 | <div
|
23 |
| - class="bg-white dark:bg-surface-500 p-4 rounded-md shadow-md z-10" |
| 34 | + class="bg-white dark:bg-surface-500 p-4 px-5 rounded-md shadow-md z-10 border border-primary-500" |
24 | 35 | data-popup="{tableId}-columns-menu"
|
25 | 36 | >
|
| 37 | + <div class="flex items-center gap-4 pb-5 grow justify-between"> |
| 38 | + <button |
| 39 | + on:click|preventDefault={selectAll} |
| 40 | + type="button" |
| 41 | + class="btn p-0 text-sm grow underline text-primary-500" |
| 42 | + > |
| 43 | + Select All |
| 44 | + </button> |
| 45 | + <div class="border border-r border-neutral-200 h-6" /> |
| 46 | + <button |
| 47 | + on:click|preventDefault={deselectAll} |
| 48 | + type="button" |
| 49 | + class="btn p-0 text-sm grow underline text-neutral-500" |
| 50 | + > |
| 51 | + Deselect All |
| 52 | + </button> |
| 53 | + </div> |
26 | 54 | {#each columns as column}
|
27 | 55 | <div class="flex gap-3 items-center">
|
28 | 56 | <input
|
29 | 57 | aria-label={`${column.visible ? 'Hide' : 'Show'} ${column.label} column`}
|
30 | 58 | type="checkbox"
|
| 59 | + class="checkbox" |
31 | 60 | bind:checked={column.visible}
|
32 | 61 | title={`${column.visible ? 'Hide' : 'Show'} ${column.label} column`}
|
33 | 62 | disabled={columns.filter((c) => c.visible).length === 1 && column.visible}
|
|
36 | 65 | </div>
|
37 | 66 | {/each}
|
38 | 67 |
|
39 |
| - <div class="arrow bg-white dark:bg-surface-500" /> |
| 68 | + <div class="arrow bg-white dark:bg-surface-500 border-l border-t border-primary-500" /> |
40 | 69 | </div>
|
0 commit comments