@likable-hair/svelte 3.3.16 → 3.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,30 +36,30 @@ onMount(() => {
36
36
  updateHeaderHeight();
37
37
  window.addEventListener("resize", updateHeaderHeight);
38
38
  tableContainer.addEventListener("scroll", setReachedBottomOrTop);
39
- if (tableContainer.scrollHeight <= tableContainer.clientHeight) {
40
- tableContainer.style.marginRight = "0px";
41
- }
42
- if (resizableColumns) {
43
- for (const head of [...headers, { value: "non-resizable", minWidth: DEFAULT_MIN_WIDTH_PX + "px", maxWidth: DEFAULT_MAX_WIDTH_PX + "px" }, { value: "slot-append", minWidth: DEFAULT_MIN_WIDTH_PX + "px", maxWidth: DEFAULT_MAX_WIDTH_PX + "px" }]) {
44
- let th;
45
- if (head.value == "non-resizable" || head.value == "slot-append") {
46
- th = document.getElementsByClassName(head.value).item(0);
47
- } else {
48
- th = document.getElementById(head.value);
49
- }
50
- if (!!th) {
51
- resizeHeader(th, head);
52
- }
39
+ hideScrollbar = tableContainer.scrollHeight > tableContainer.clientHeight;
40
+ for (const head of [...headers, { value: "non-resizable", minWidth: DEFAULT_MIN_WIDTH_PX + "px", maxWidth: DEFAULT_MAX_WIDTH_PX + "px" }, { value: "customize-headers", minWidth: DEFAULT_MIN_WIDTH_PX + "px", maxWidth: DEFAULT_MAX_WIDTH_PX + "px" }]) {
41
+ let th;
42
+ if (head.value == "non-resizable" || head.value == "customize-headers") {
43
+ th = document.getElementsByClassName(head.value).item(0);
44
+ } else {
45
+ th = document.getElementById(head.value);
46
+ }
47
+ if (!!th) {
48
+ resizeHeader(th, head);
53
49
  }
54
- let table = document.getElementsByClassName("table")[0];
55
- table.classList.add("resizable");
56
50
  }
51
+ let table = document.getElementsByClassName("dynamic-table")[0];
52
+ table.classList.add("dynamic-resizable");
53
+ resizeObserver = new ResizeObserver(() => {
54
+ updateRemainingWidth();
55
+ });
56
+ resizeObserver.observe(tableContainer);
57
57
  return () => {
58
58
  window.removeEventListener("resize", updateHeaderHeight);
59
59
  tableContainer.removeEventListener("scroll", setReachedBottomOrTop);
60
+ resizeObserver?.disconnect();
60
61
  };
61
62
  });
62
- let mainHeader;
63
63
  function updateHeaderHeight() {
64
64
  if (mainHeader) {
65
65
  const headerHeight = mainHeader.getBoundingClientRect().height;
@@ -69,6 +69,7 @@ function updateHeaderHeight() {
69
69
  function setReachedBottomOrTop() {
70
70
  reachedBottom = tableContainer.scrollHeight - tableContainer.scrollTop === tableContainer.clientHeight;
71
71
  reachedTop = tableContainer.scrollTop === 0;
72
+ hideScrollbar = tableContainer.scrollHeight > tableContainer.clientHeight;
72
73
  }
73
74
  $:
74
75
  if (reachedBottom && rows.length < totalRows) {
@@ -104,8 +105,8 @@ const [send, receive] = crossfade({
104
105
  let clazz = {};
105
106
  export { clazz as class };
106
107
  const dispatch = createEventDispatcher();
107
- export let headers = [], headersToShowInTable = headers, subHeaders = [], customizeHeaders = false, rows = [], sortedBy = void 0, sortDirection = "asc", cellEdit = false, noItemsText = "No items to show", showSelect = false, showSelectContainer = true, selectMode = "single", selectedItems = [], showExpand = false, loading = false, disabled = false, filters = [], searchBarColumns = void 0, searchBarVisible = false, searchBarPlaceholder = "Type to search for identification code, description and MRN...", filtersVisible = false, quickFiltersVisible = false, lang = "en", editFilterMode = "one-edit", showActiveFilters = true, quickFilters = [], actionsForSelectedItems = [], totalRows = rows.length, searchText = void 0, renderedRowsNumber = 100, sectionRowsNumber = 20, sectionThreshold = 2, backwardThresholdPixel = 100, forwardThresholdPixel = 100, uniqueKey = "id", numberOfResultsVisible = false, endLineVisible = false, resizableColumns = false, resizedColumnSizeWithPadding = {};
108
- let openCellEditor = false, cellEditorActivator, cellEditorContainer, menuElementCellEditor, menuElementQuickFilters, cellEditorInfoActive, saveEditDisabled = false, searchBarInput = void 0, openQuickFilter = false, quickFilterActivator, quickFilterActive, globalBuilder = new FilterBuilder(), slotSelectActionsContainer, isSelectedAll = false, calendarOpened = false, calendarOpened2 = false, selectedIndexes = [], cellEditorIndexRow, cellEditorIndexHeader, cellEditorSubItem, currentSectionNumber = 0, tableBody, tableContainer, userScrolling = true, reachedBottom = false, reachedTop = false, resizing = false, remainingWidth = 0;
108
+ export let headers = [], headersToShowInTable = headers, subHeaders = [], customizeHeaders = false, rows = [], sortedBy = void 0, sortDirection = "asc", cellEdit = false, lang = "en", dateLocale = void 0, noItemsText = lang == "en" ? "No items to show" : "Nessun elemento da visualizzare", showSelect = false, showActions = true, selectMode = "single", selectedItems = [], unselectedItems = [], selectedAll = false, showExpand = false, loading = false, disabled = false, filters = [], searchBarColumns = void 0, searchBarVisible = false, searchBarPlaceholder = lang == "en" ? "Type to search..." : "Scrivi per cercare...", filtersVisible = false, quickFiltersVisible = false, editFilterMode = "one-edit", showActiveFilters = true, quickFilters = [], actionsForSelectedItems = [], quickActionsDisabled = false, totalRows = rows.length, searchText = void 0, renderedRowsNumber = 100, sectionRowsNumber = 20, sectionThreshold = 2, backwardThresholdPixel = 100, forwardThresholdPixel = 100, uniqueKey = "id", numberOfResultsVisible = false, endLineVisible = false, resizableColumns = false, resizedColumnSizeWithPadding = {}, dynamicFilters = true;
109
+ let openCellEditor = false, cellEditorActivator, cellEditorContainer, menuElementCellEditor, menuElementQuickFilters, cellEditorInfoActive, saveEditDisabled = false, searchBarInput = void 0, openQuickFilter = false, quickFilterActivator, quickFilterActive, globalBuilder = new FilterBuilder(), calendarOpened = false, calendarOpened2 = false, selectedIndexes = [], cellEditorIndexRow, cellEditorIndexHeader, cellEditorSubItem, currentSectionNumber = 0, tableBody, tableContainer, userScrolling = true, reachedBottom = false, reachedTop = false, resizing = false, remainingWidth = 0, hideScrollbar = false, sortModify, mainHeader, resizeObserver;
109
110
  const DEFAULT_MIN_WIDTH_PX = 100, DEFAULT_MAX_WIDTH_PX = 400;
110
111
  $:
111
112
  totalSections = (totalRows - renderedRowsNumber) / sectionRowsNumber;
@@ -142,10 +143,12 @@ function handleHeaderClick(header) {
142
143
  sortDirection = "desc";
143
144
  else if (sortDirection == "desc") {
144
145
  sortedBy = void 0;
146
+ sortModify = void 0;
145
147
  }
146
148
  } else {
147
149
  sortedBy = header.value;
148
150
  sortDirection = "asc";
151
+ sortModify = header.sortModify;
149
152
  }
150
153
  handleSearchChange(searchText);
151
154
  dispatch("sort", {
@@ -218,13 +221,18 @@ function handleCancelClick() {
218
221
  openQuickFilter = false;
219
222
  }
220
223
  function handleSelect(item, shiftKeyPressed) {
221
- let index = selectedItems.findIndex((i) => i[uniqueKey] == item[uniqueKey]);
224
+ let index = -1;
225
+ if (selectedAll) {
226
+ index = unselectedItems.findIndex((i) => i[uniqueKey] == item[uniqueKey]);
227
+ } else {
228
+ index = selectedItems.findIndex((i) => i[uniqueKey] == item[uniqueKey]);
229
+ }
222
230
  if (index == -1) {
223
231
  if (selectMode == "single") {
224
232
  selectedItems = [item];
225
233
  selectedIndexes = [rows.findIndex((r) => r.item[uniqueKey] == item[uniqueKey])];
226
234
  } else if (selectMode == "multiple") {
227
- if (shiftKeyPressed && selectedIndexes.length > 0 && !isSelectedAll) {
235
+ if (shiftKeyPressed && selectedIndexes.length > 0) {
228
236
  let lastSelectedIndex = selectedIndexes[selectedIndexes.length - 1], selectedIndex = rows.findIndex((r) => r.item[uniqueKey] == item[uniqueKey]);
229
237
  if (selectedIndex != -1) {
230
238
  if (selectedIndex < lastSelectedIndex) {
@@ -233,32 +241,41 @@ function handleSelect(item, shiftKeyPressed) {
233
241
  selectedIndex = x;
234
242
  }
235
243
  for (let i = lastSelectedIndex + 1; i <= selectedIndex; i++) {
236
- if (!selectedItems.find((selectedItem) => selectedItem[uniqueKey] == rows[i].item[uniqueKey])) {
237
- selectedItems = [...selectedItems, rows[i].item];
244
+ if (selectedAll) {
245
+ if (!unselectedItems.find((unselectedItem) => unselectedItem[uniqueKey] == rows[i].item[uniqueKey])) {
246
+ unselectedItems = [...unselectedItems, rows[i].item];
247
+ }
248
+ } else {
249
+ if (!selectedItems.find((selectedItem) => selectedItem[uniqueKey] == rows[i].item[uniqueKey])) {
250
+ selectedItems = [...selectedItems, rows[i].item];
251
+ }
238
252
  }
239
253
  }
240
254
  }
241
255
  } else {
242
- selectedItems = [...selectedItems, item];
256
+ if (selectedAll) {
257
+ unselectedItems = [...unselectedItems, item];
258
+ } else {
259
+ selectedItems = [...selectedItems, item];
260
+ }
243
261
  selectedIndexes.push(rows.findIndex((r) => r.item[uniqueKey] == item[uniqueKey]));
244
262
  }
245
263
  }
246
264
  } else {
247
- selectedItems = selectedItems.filter((i) => i[uniqueKey] != item[uniqueKey]);
265
+ if (selectedAll) {
266
+ unselectedItems = unselectedItems.filter((i) => i[uniqueKey] != item[uniqueKey]);
267
+ } else {
268
+ selectedItems = selectedItems.filter((i) => i[uniqueKey] != item[uniqueKey]);
269
+ }
248
270
  selectedIndexes = selectedIndexes.filter((r) => r != rows.findIndex((r2) => r2.item[uniqueKey] == item[uniqueKey]));
249
- isSelectedAll = false;
250
271
  }
251
272
  }
252
273
  function handleSelectAll() {
253
274
  if (selectMode == "multiple") {
254
- if (selectedItems.length == rows.length) {
255
- selectedItems = [];
256
- selectedIndexes = [];
257
- isSelectedAll = false;
258
- } else {
259
- selectedItems = rows.map((r) => r.item);
260
- isSelectedAll = true;
261
- }
275
+ selectedItems = [];
276
+ selectedIndexes = [];
277
+ unselectedItems = [];
278
+ selectedAll = !selectedAll;
262
279
  }
263
280
  }
264
281
  function expandRow(row) {
@@ -286,9 +303,6 @@ $: {
286
303
  } else {
287
304
  saveEditDisabled = false;
288
305
  }
289
- if (!!isSelectedAll && rows.length > 0 && !loading && !disabled && selectedItems.length < rows.length) {
290
- selectedItems = rows.map((r) => r.item);
291
- }
292
306
  }
293
307
  function searchTextBuilder(searchText2) {
294
308
  let builder;
@@ -304,9 +318,6 @@ function searchTextBuilder(searchText2) {
304
318
  }
305
319
  });
306
320
  }
307
- if (!!sortedBy) {
308
- builder.orderBy(sortedBy, sortDirection || "asc");
309
- }
310
321
  return builder;
311
322
  }
312
323
  let syncTimer;
@@ -330,6 +341,13 @@ function handleFiltersChange() {
330
341
  tableContainer.scrollTop = 0;
331
342
  setTimeout(() => userScrolling = true, 20);
332
343
  }
344
+ if (!!sortedBy) {
345
+ if (sortModify) {
346
+ globalBuilder = sortModify({ builder: globalBuilder, sortDirection });
347
+ } else {
348
+ globalBuilder.orderBy(sortedBy, sortDirection || "asc");
349
+ }
350
+ }
333
351
  dispatch("filtersChange", {
334
352
  builder: globalBuilder
335
353
  });
@@ -577,9 +595,6 @@ function quickFilterBuilder(builder, quickFilter, clearPreaviousValue = true) {
577
595
  }
578
596
  }
579
597
  }
580
- if (!!sortedBy) {
581
- builder.orderBy(sortedBy, sortDirection || "asc");
582
- }
583
598
  return builder;
584
599
  }
585
600
  function updateFilterValues(filter, updateMultiFilterValues) {
@@ -603,10 +618,7 @@ function updateFilterValues(filter, updateMultiFilterValues) {
603
618
  }
604
619
  updateMultiFilterValues(filter.name, newValue, newValid, newMode);
605
620
  }
606
- function handleRemoveAllFilters(removeAllFilters) {
607
- if (!!removeAllFilters) {
608
- removeAllFilters();
609
- }
621
+ function handleRemoveAllFilters() {
610
622
  dispatch("removeAllFilters", {});
611
623
  handleSearchChange(searchText);
612
624
  }
@@ -739,7 +751,7 @@ function resize(node) {
739
751
  }
740
752
  }
741
753
  $:
742
- if (resizableColumns && !!tableContainer && resizableColumns && headersToShowInTable.length > 0 && resizedColumnSizeWithPadding && headersToShow.length > 0 && mainHeader) {
754
+ if (!!tableContainer && headersToShowInTable.length > 0 && resizedColumnSizeWithPadding && headersToShow.length > 0 && mainHeader) {
743
755
  tick().then(updateRemainingWidth);
744
756
  }
745
757
  async function updateRemainingWidth() {
@@ -785,86 +797,128 @@ function resizeHeader(th, header) {
785
797
  </script>
786
798
 
787
799
  {#if !!rows && Array.isArray(rows) && !!headersToShowInTable && Array.isArray(headersToShowInTable)}
788
- <QuickActions
789
- {selectedItems}
790
- {showSelectContainer}
791
- {isSelectedAll}
792
- {totalRows}
793
- {slotSelectActionsContainer}
794
- {disabled}
795
- {loading}
796
- {actionsForSelectedItems}
797
- {lang}
798
- />
800
+ {#if showActions}
801
+ <QuickActions
802
+ selectedItems={selectedAll ? totalRows - unselectedItems.length : selectedItems.length}
803
+ disabled={quickActionsDisabled}
804
+ {actionsForSelectedItems}
805
+ {lang}
806
+ on:close={() => {
807
+ selectedAll = false
808
+ unselectedItems = []
809
+ selectedItems = []
810
+ }}
811
+ />
812
+ {/if}
799
813
 
800
- <slot name="search-bar" {handleSearchChange}>
801
- {#if searchBarVisible || filtersVisible}
814
+ {#if searchBarVisible || filtersVisible || $$slots.appendFilterRow}
815
+ <div class="filter-container">
802
816
  <div class="search-bar-container">
803
- {#if searchBarVisible}
804
- <SimpleTextField
805
- placeholder={searchBarPlaceholder}
806
- appendInnerIcon="mdi-magnify"
807
- bind:value={searchText}
808
- bind:input={searchBarInput}
809
- on:keydown={handleSearchBoxKeydown}
810
- --simple-textfield-default-width="450px"
811
- --simple-textfield-border-radius= 0.5rem
812
- --simple-textfield-background-color= transparent
813
- --simple-textfield-box-shadow= 'inset 0 0 0 1px rgb(var(--global-color-background-500))'
814
- --simple-textfield-focus-box-shadow='inset 0 0 0 2px rgb(var(--global-color-primary-500))'
815
- />
816
- {/if}
817
+ <slot name="search-bar" {handleSearchChange}>
818
+ {#if searchBarVisible}
819
+ <div style="margin-right: 20px;">
820
+ <SimpleTextField
821
+ placeholder={searchBarPlaceholder}
822
+ appendInnerIcon="mdi-magnify"
823
+ bind:value={searchText}
824
+ bind:input={searchBarInput}
825
+ on:keydown={handleSearchBoxKeydown}
826
+ --simple-textfield-default-width="450px"
827
+ --simple-textfield-border-radius= 0.5rem
828
+ --simple-textfield-background-color= transparent
829
+ --simple-textfield-box-shadow= 'inset 0 0 0 1px rgb(var(--global-color-background-500))'
830
+ --simple-textfield-focus-box-shadow='inset 0 0 0 2px rgb(var(--global-color-primary-500))'
831
+ />
832
+ </div>
833
+ {/if}
834
+ </slot>
817
835
 
818
836
  {#if filtersVisible}
819
- <div style="margin-left: 20px;">
820
- <Filters
821
- bind:filters
822
- on:applyFilter={() => {
823
- handleSearchChange(searchText);
824
- }}
825
- on:removeFilter={e => { handleRemoveFilter(e.detail.filter) }}
826
- on:removeAllFilters={() => handleRemoveAllFilters()}
827
- --filters-default-wrapper-width="100%"
828
- {lang}
829
- {editFilterMode}
830
- {showActiveFilters}
831
- >
832
- <svelte:fragment slot="append">
833
- <slot name="filter-append" />
834
- </svelte:fragment>
835
- <svelte:fragment slot="custom-chip" let:filter>
836
- <slot name="custom-filter-chip" {filter} />
837
- </svelte:fragment>
838
- <svelte:fragment
839
- slot="custom"
840
- let:filter
841
- let:updateFunction
842
- let:mAndDown
837
+ <div>
838
+ {#if dynamicFilters}
839
+ <Filters
840
+ bind:filters
841
+ on:applyFilter={() => {
842
+ handleSearchChange(searchText);
843
+ }}
844
+ on:removeFilter={e => { handleRemoveFilter(e.detail.filter) }}
845
+ on:removeAllFilters={() => handleRemoveAllFilters()}
846
+ --filters-default-wrapper-width="100%"
847
+ {lang}
848
+ {dateLocale}
849
+ {editFilterMode}
850
+ {showActiveFilters}
843
851
  >
844
- <slot name="custom-filter" {filter} {updateFunction} {mAndDown} />
845
- </svelte:fragment>
852
+ <svelte:fragment slot="append">
853
+ <slot name="filter-append" />
854
+ </svelte:fragment>
855
+ <svelte:fragment slot="custom-chip" let:filter>
856
+ <slot name="custom-filter-chip" {filter} />
857
+ </svelte:fragment>
858
+ <svelte:fragment
859
+ slot="custom"
860
+ let:filter
861
+ let:updateFunction
862
+ let:mAndDown
863
+ >
864
+ <slot name="custom-filter" {filter} {updateFunction} {mAndDown} />
865
+ </svelte:fragment>
846
866
 
847
- <svelte:fragment slot="content" let:mAndDown let:filters let:updateMultiFilterValues let:handleRemoveAllFilters={removeAllFilters}>
848
- {#key filters}
849
- <DynamicFilters
850
- {lang}
851
- {filters}
852
- {mAndDown}
853
- on:change={e => updateFilterValues(e.detail.filter, updateMultiFilterValues)}
854
- on:removeAllFilters={() => handleRemoveAllFilters(removeAllFilters)}
855
- >
856
- <svelte:fragment slot="custom" let:filter let:mAndDown>
857
- <slot name="custom-filter" {filter} {updateMultiFilterValues} {mAndDown}></slot>
858
- </svelte:fragment>
859
- </DynamicFilters>
860
- {/key}
861
- </svelte:fragment>
862
- </Filters>
867
+ <svelte:fragment slot="content" let:mAndDown let:filters let:updateMultiFilterValues>
868
+ {#key filters}
869
+ <DynamicFilters
870
+ {lang}
871
+ {filters}
872
+ {mAndDown}
873
+ {updateMultiFilterValues}
874
+ on:change={e => updateFilterValues(e.detail.filter, updateMultiFilterValues)}
875
+ >
876
+ <svelte:fragment slot="custom" let:filter let:mAndDown let:updateCustomFilterValues>
877
+ <slot name="custom-filter" {filter} {updateCustomFilterValues} {mAndDown}></slot>
878
+ </svelte:fragment>
879
+ </DynamicFilters>
880
+ {/key}
881
+ </svelte:fragment>
882
+ </Filters>
883
+ {:else}
884
+ <Filters
885
+ bind:filters
886
+ on:applyFilter={() => {
887
+ handleSearchChange(searchText);
888
+ }}
889
+ on:removeFilter={e => { handleRemoveFilter(e.detail.filter) }}
890
+ on:removeAllFilters={() => handleRemoveAllFilters()}
891
+ --filters-default-wrapper-width="100%"
892
+ {lang}
893
+ {dateLocale}
894
+ {editFilterMode}
895
+ {showActiveFilters}
896
+ >
897
+ <svelte:fragment slot="append">
898
+ <slot name="filter-append" />
899
+ </svelte:fragment>
900
+ <svelte:fragment slot="custom-chip" let:filter>
901
+ <slot name="custom-filter-chip" {filter} />
902
+ </svelte:fragment>
903
+ <svelte:fragment
904
+ slot="custom"
905
+ let:filter
906
+ let:updateFunction
907
+ let:mAndDown
908
+ >
909
+ <slot name="custom-static-filter" {filter} {updateFunction} {mAndDown}/>
910
+ </svelte:fragment>
911
+ </Filters>
912
+ {/if}
863
913
  </div>
864
914
  {/if}
865
915
  </div>
866
- {/if}
867
- </slot>
916
+
917
+ <div>
918
+ <slot name="appendFilterRow"></slot>
919
+ </div>
920
+ </div>
921
+ {/if}
868
922
 
869
923
  {#if quickFiltersVisible || numberOfResultsVisible}
870
924
  <div class="quick-filters-results-container">
@@ -917,14 +971,14 @@ function resizeHeader(th, header) {
917
971
  {/if}
918
972
 
919
973
  <div class="outer-container">
920
- <div class="inner-container" bind:this={tableContainer} on:scroll>
974
+ <div class="inner-container" class:hide-scrollbar={hideScrollbar} bind:this={tableContainer} on:scroll>
921
975
  <InfiniteScroll
922
976
  on:loadMore={handleLoadBackward}
923
977
  threshold={backwardThresholdPixel}
924
978
  hasMore={currentSectionNumber > 0 && userScrolling}
925
979
  direction='backward'
926
980
  />
927
- <table style="display: table;" class="table">
981
+ <table style="display: table;" class="dynamic-table">
928
982
  <thead class="table-header" bind:this={mainHeader}>
929
983
  <tr>
930
984
  {#if !!showSelect && !showExpand && rows.length > 0}
@@ -937,7 +991,7 @@ function resizeHeader(th, header) {
937
991
  {#if selectMode === "multiple"}
938
992
  <Checkbox
939
993
  id="select-all"
940
- value={selectedItems.length == totalBatchLength}
994
+ value={selectedAll}
941
995
  disabled={disabled || loading}
942
996
  on:change={handleSelectAll}
943
997
  />
@@ -956,6 +1010,7 @@ function resizeHeader(th, header) {
956
1010
  <th
957
1011
  style={`${resizableColumns || !head.width ? '' : `width: ${head.width}`}`}
958
1012
  style:min-width={head.minWidth}
1013
+ style:max-width={head.maxWidth}
959
1014
  class:sortable={head.sortable}
960
1015
  on:click={() => handleHeaderClick(head)}
961
1016
  id={head.value}
@@ -1004,34 +1059,29 @@ function resizeHeader(th, header) {
1004
1059
  </slot>
1005
1060
  </th>
1006
1061
  {/each}
1007
- {#if $$slots.rowActions || $$slots.append}
1008
- <th
1009
- class="slot-append"
1010
- >
1011
- <slot name="append" index={-1} items={undefined} />
1012
- </th>
1013
- {/if}
1014
- {#if resizableColumns && remainingWidth}
1062
+ {#if remainingWidth && (customizeHeaders || resizableColumns)}
1015
1063
  <th
1016
1064
  style:width={remainingWidth + 'px'}
1017
1065
  class="filler"
1018
1066
  aria-hidden="true"
1019
1067
  />
1020
1068
  {/if}
1021
- {#if customizeHeaders}
1069
+ {#if customizeHeaders || $$slots.rowActions || $$slots.append}
1022
1070
  <th
1023
- style:width="15px"
1024
- style:min-width="15px"
1025
1071
  style:text-align="center"
1026
1072
  class="customize-headers"
1027
1073
  >
1028
- <div style="display: flex; justify-content: center;">
1029
- <Icon
1030
- name="mdi-plus-circle-outline"
1031
- click
1032
- on:click={() => (openHeaderDrawer = true)}
1033
- />
1034
- </div>
1074
+ {#if customizeHeaders}
1075
+ <div style="display: flex; justify-content: start;">
1076
+ <Icon
1077
+ name="mdi-plus-circle-outline"
1078
+ click
1079
+ on:click={() => (openHeaderDrawer = true)}
1080
+ />
1081
+ </div>
1082
+ {:else}
1083
+ <slot name="append" index={-1} items={undefined} />
1084
+ {/if}
1035
1085
  </th>
1036
1086
  {/if}
1037
1087
  </tr>
@@ -1072,16 +1122,20 @@ function resizeHeader(th, header) {
1072
1122
  class="item-row"
1073
1123
  data-key={row.item[uniqueKey]}
1074
1124
  style:background-color={
1075
- !!row.item.disableEdit ?
1076
- !!row.item.rowDisableBackgroundColor ?
1077
- row.item.rowDisableBackgroundColor :
1078
- 'var(--dynamic-table-row-disabled-background-color, var(--dynamic-table-default-row-disabled-background-color))' :
1079
- expandedRows.findIndex((r) => r.item[uniqueKey] == row.item[uniqueKey] ) != -1 ?
1080
- 'var(--dynamic-table-expanded-row-background-color, var(--dynamic-table-default-expanded-row-background-color))' :
1081
- !!selectedItems.find(i => i[uniqueKey] == row.item[uniqueKey]) ?
1082
- 'var(--dynamic-table-selected-row-background-color, var(--dynamic-table-default-selected-row-background-color))' :
1083
- ""
1084
- }
1125
+ !!row.item.disableEdit
1126
+ ? !!row.item.rowDisableBackgroundColor
1127
+ ? row.item.rowDisableBackgroundColor
1128
+ : 'var(--dynamic-table-row-disabled-background-color, var(--dynamic-table-default-row-disabled-background-color))'
1129
+ : expandedRows.findIndex(r => r.item[uniqueKey] == row.item[uniqueKey]) != -1
1130
+ ? 'var(--dynamic-table-expanded-row-background-color, var(--dynamic-table-default-expanded-row-background-color))'
1131
+ : selectedAll
1132
+ ? !unselectedItems.find(i => i[uniqueKey] == row.item[uniqueKey])
1133
+ ? 'var(--dynamic-table-selected-row-background-color, var(--dynamic-table-default-selected-row-background-color))'
1134
+ : ''
1135
+ : selectedItems.find(i => i[uniqueKey] == row.item[uniqueKey])
1136
+ ? 'var(--dynamic-table-selected-row-background-color, var(--dynamic-table-default-selected-row-background-color))'
1137
+ : ''
1138
+ }
1085
1139
  class:row-activator={cellEditorIndexRow == indexRow && !cellEditorSubItem}
1086
1140
  on:click={() => handleRowClick(row)}
1087
1141
  >
@@ -1089,9 +1143,15 @@ function resizeHeader(th, header) {
1089
1143
  <td style:padding-left="0px" style:text-align="center">
1090
1144
  <Checkbox
1091
1145
  id={row.item[uniqueKey]}
1092
- value={selectedItems.findIndex(
1093
- (i) => i[uniqueKey] == row.item[uniqueKey]
1094
- ) != -1}
1146
+ value={
1147
+ selectedAll ?
1148
+ unselectedItems.findIndex(
1149
+ (i) => i[uniqueKey] == row.item[uniqueKey]
1150
+ ) == -1 :
1151
+ selectedItems.findIndex(
1152
+ (i) => i[uniqueKey] == row.item[uniqueKey]
1153
+ ) != -1
1154
+ }
1095
1155
  disabled={disabled || loading}
1096
1156
  on:change={(e) => handleSelect(row.item, e.detail.shiftKeyPressed)}
1097
1157
  />
@@ -1160,6 +1220,9 @@ function resizeHeader(th, header) {
1160
1220
  {/if}
1161
1221
  </td>
1162
1222
  {/each}
1223
+ {#if remainingWidth && (customizeHeaders || resizableColumns)}
1224
+ <td/>
1225
+ {/if}
1163
1226
  {#if $$slots.rowActions || $$slots.append}
1164
1227
  <td class={clazz.cell || ""}>
1165
1228
  <slot name="rowActions" index={indexRow} {row} />
@@ -1182,6 +1245,7 @@ function resizeHeader(th, header) {
1182
1245
  <th
1183
1246
  style:width={subHeader.width}
1184
1247
  style:min-width={subHeader.minWidth}
1248
+ style:max-width={subHeader.maxWidth}
1185
1249
  class:sortable={subHeader.sortable}
1186
1250
  on:click={() => handleHeaderClick(subHeader)}
1187
1251
  >
@@ -1567,6 +1631,7 @@ function resizeHeader(th, header) {
1567
1631
  : quickFilterActive.description,
1568
1632
  multiple: true,
1569
1633
  }}
1634
+ --autocomplete-border-radius= 0.5rem
1570
1635
  --autocomplete-border="1px solid rgb(var(--global-color-background-500))"
1571
1636
  --autocomplete-focus-box-shadow="0 0 0 2px rgb(var(--global-color-primary-500))"
1572
1637
  />
@@ -1655,11 +1720,11 @@ function resizeHeader(th, header) {
1655
1720
  <MediaQuery let:sAndDown>
1656
1721
  <Drawer
1657
1722
  bind:open={openHeaderDrawer}
1658
- _space={sAndDown ? "60vh" : "20vw"}
1723
+ _space={sAndDown ? "60vh" : "400px"}
1659
1724
  position={sAndDown ? "bottom" : "right"}
1660
1725
  >
1726
+ <div class="personalize-header">{lang == 'en' ? 'Personalize your headers' : 'Personalizza le tue intestazioni'}</div>
1661
1727
  <div style="padding: 20px;">
1662
- <div class="personalize-header">{lang == 'en' ? 'Personalize your headers' : 'Personalizza le tue intestazioni'}</div>
1663
1728
 
1664
1729
  <span class="headers-show grid-col-1">{lang == 'en' ? 'Headers shown in table' : 'Intestazioni visualizzate in tabella'}</span>
1665
1730
 
@@ -1670,19 +1735,26 @@ function resizeHeader(th, header) {
1670
1735
  headersToShow = e.detail.items;
1671
1736
  }}
1672
1737
  >
1673
- <svelte:fragment slot="item" let:item>
1674
- <Switch
1675
- --switch-label-width="90%"
1676
- value={headersToShow.find((h) => h.id == item.id) != undefined}
1677
- label={item.name}
1678
- on:change={(e) => {
1679
- if (e.detail.value == false) {
1680
- headersToShow = headersToShow.filter((h) => h.id != item.id);
1681
- headersToSelect = [...headersToSelect, item];
1682
- }
1683
- }}
1684
- />
1685
- </svelte:fragment>
1738
+ <div slot="item" let:item>
1739
+ <div
1740
+ style:display=flex
1741
+ >
1742
+ <div
1743
+ style:flex-grow=1
1744
+ >
1745
+ {item.name}
1746
+ </div>
1747
+ <Switch
1748
+ value={headersToShow.find((h) => h.id == item.id) != undefined}
1749
+ on:change={(e) => {
1750
+ if (e.detail.value == false) {
1751
+ headersToShow = headersToShow.filter((h) => h.id != item.id);
1752
+ headersToSelect = [...headersToSelect, item];
1753
+ }
1754
+ }}
1755
+ />
1756
+ </div>
1757
+ </div>
1686
1758
  </VerticalDraggableList>
1687
1759
  {/if}
1688
1760
  <Divider --divider-color=rgb(var(--global-color-contrast-100) />
@@ -1695,19 +1767,26 @@ function resizeHeader(th, header) {
1695
1767
  out:send={{ key: header }}
1696
1768
  class="headers-show grid-col-1"
1697
1769
  >
1698
- <Switch
1699
- --switch-label-width="90%"
1700
- value={false}
1701
- label={header.name}
1702
- on:change={(e) => {
1703
- if (e.detail.value == true) {
1704
- headersToSelect = headersToSelect.filter(
1705
- (h) => h.id != header.id
1706
- );
1707
- headersToShow = [...headersToShow, header];
1708
- }
1709
- }}
1710
- />
1770
+ <div
1771
+ style:display=flex
1772
+ >
1773
+ <div
1774
+ style:flex-grow=1
1775
+ >
1776
+ {header.name}
1777
+ </div>
1778
+ <Switch
1779
+ value={false}
1780
+ on:change={(e) => {
1781
+ if (e.detail.value == true) {
1782
+ headersToSelect = headersToSelect.filter(
1783
+ (h) => h.id != header.id
1784
+ );
1785
+ headersToShow = [...headersToShow, header];
1786
+ }
1787
+ }}
1788
+ />
1789
+ </div>
1711
1790
  </div>
1712
1791
  {/each}
1713
1792
  {:else}
@@ -1715,10 +1794,10 @@ function resizeHeader(th, header) {
1715
1794
  <span style="text-align: center;">{lang == 'en' ? 'No headers to add' : 'Nessuna intestazione da aggiungere'}</span>
1716
1795
  </div>
1717
1796
  {/if}
1718
- <div style="width: 100%; display: flex; justify-content: center;">
1797
+ <div style="width: 100%; display: flex; justify-content: center; padding-top: 15px;">
1719
1798
  <Button
1720
1799
  class="mr-3 mt-5"
1721
- --button-width="70%"
1800
+ --button-width="100%"
1722
1801
  on:click={saveHeadersToShow}
1723
1802
  >
1724
1803
  {lang == 'en' ? 'Save preferences' : 'Salva preferenze'}
@@ -1735,11 +1814,14 @@ function resizeHeader(th, header) {
1735
1814
 
1736
1815
  .inner-container {
1737
1816
  overflow-y: auto;
1738
- margin-right: -15px;
1739
1817
  max-height: var(--dynamic-table-max-height, var(--dynamic-table-default-max-height));
1740
1818
  }
1741
1819
 
1742
- .table {
1820
+ .hide-scrollbar {
1821
+ margin-right: -15px;
1822
+ }
1823
+
1824
+ .dynamic-table {
1743
1825
  background-color: var(
1744
1826
  --dynamic-table-background-color,
1745
1827
  var(--dynamic-table-default-background-color)
@@ -1747,7 +1829,7 @@ function resizeHeader(th, header) {
1747
1829
  border-collapse: separate;
1748
1830
  }
1749
1831
 
1750
- .table.resizable {
1832
+ .dynamic-table.dynamic-resizable {
1751
1833
  table-layout: fixed;
1752
1834
  width: fit-content;
1753
1835
  }
@@ -1867,17 +1949,17 @@ function resizeHeader(th, header) {
1867
1949
  border: 1px solid transparent;
1868
1950
  }
1869
1951
 
1870
- table.table > tbody > tr > td {
1952
+ table.dynamic-table > tbody > tr > td {
1871
1953
  overflow: hidden;
1872
1954
  text-overflow: ellipsis;
1873
1955
  }
1874
1956
 
1875
- table.table > thead > tr > th {
1957
+ table.dynamic-table > thead > tr > th {
1876
1958
  overflow: hidden;
1877
1959
  text-overflow: ellipsis;
1878
1960
  }
1879
1961
 
1880
- table.table > tbody > tr > td.expanded-row {
1962
+ table.dynamic-table > tbody > tr > td.expanded-row {
1881
1963
  overflow: visible;
1882
1964
  }
1883
1965
 
@@ -1974,6 +2056,12 @@ function resizeHeader(th, header) {
1974
2056
  .search-bar-container {
1975
2057
  display: flex;
1976
2058
  flex-direction: row;
2059
+ }
2060
+
2061
+ .filter-container {
2062
+ display: flex;
2063
+ flex-direction: row;
2064
+ justify-content: space-between;
1977
2065
  margin-bottom: 20px;
1978
2066
  }
1979
2067