@likable-hair/svelte 3.3.14 → 3.3.16

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.
@@ -13,7 +13,7 @@
13
13
  ToolTip
14
14
  } from "../../..";
15
15
  import { DateTime } from "luxon";
16
- import { createEventDispatcher, onMount } from "svelte";
16
+ import { createEventDispatcher, onMount, tick } from "svelte";
17
17
  import { quintOut } from "svelte/easing";
18
18
  import { crossfade, fade } from "svelte/transition";
19
19
  import Filters from "../search/Filters.svelte";
@@ -36,6 +36,24 @@ 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
+ }
53
+ }
54
+ let table = document.getElementsByClassName("table")[0];
55
+ table.classList.add("resizable");
56
+ }
39
57
  return () => {
40
58
  window.removeEventListener("resize", updateHeaderHeight);
41
59
  tableContainer.removeEventListener("scroll", setReachedBottomOrTop);
@@ -86,8 +104,9 @@ const [send, receive] = crossfade({
86
104
  let clazz = {};
87
105
  export { clazz as class };
88
106
  const dispatch = createEventDispatcher();
89
- 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;
90
- 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;
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;
109
+ const DEFAULT_MIN_WIDTH_PX = 100, DEFAULT_MAX_WIDTH_PX = 400;
91
110
  $:
92
111
  totalSections = (totalRows - renderedRowsNumber) / sectionRowsNumber;
93
112
  $:
@@ -117,7 +136,7 @@ function saveHeadersToShow() {
117
136
  openHeaderDrawer = false;
118
137
  }
119
138
  function handleHeaderClick(header) {
120
- if (header.sortable && !loading) {
139
+ if (header.sortable && !loading && !resizing) {
121
140
  if (!!sortedBy && header.value == sortedBy) {
122
141
  if (sortDirection == "asc")
123
142
  sortDirection = "desc";
@@ -595,7 +614,7 @@ function handleRemoveFilter(filter) {
595
614
  dispatch("removeFilter", { filter });
596
615
  handleSearchChange(searchText);
597
616
  }
598
- function handleLoadForward() {
617
+ async function handleLoadForward() {
599
618
  if (renderedRows.length >= renderedRowsNumber) {
600
619
  userScrolling = false;
601
620
  const anchorIndex = renderedRowsNumber - 1;
@@ -613,42 +632,42 @@ function handleLoadForward() {
613
632
  }
614
633
  }
615
634
  currentSectionNumber = currentSectionNumber + 1;
616
- setTimeout(() => {
617
- const anchorElementAfter = findAnchorElement(anchorUniqueKey);
618
- const anchorOffsetAfter = anchorElementAfter?.getBoundingClientRect().top || 0;
619
- const offsetDiff = anchorOffsetAfter - anchorOffsetBefore;
620
- tableContainer.scrollTop += offsetDiff;
621
- userScrolling = true;
622
- }, 10);
635
+ await tick();
636
+ const anchorElementAfter = findAnchorElement(anchorUniqueKey);
637
+ const anchorOffsetAfter = anchorElementAfter?.getBoundingClientRect().top || 0;
638
+ const offsetDiff = anchorOffsetAfter - anchorOffsetBefore;
639
+ tableContainer.scrollTop += offsetDiff;
640
+ userScrolling = true;
623
641
  }
624
642
  if (totalCachedSections - sectionThreshold <= currentSectionNumber && !loading && totalRows > rows.length) {
625
643
  dispatch("fetchData", {});
626
644
  }
627
645
  }
628
- function handleLoadBackward() {
629
- userScrolling = false;
630
- const anchorIndex = 0;
631
- const anchorUniqueKey = renderedRows[anchorIndex].item[uniqueKey];
632
- const anchorElement = findAnchorElement(anchorUniqueKey);
633
- const anchorOffsetBefore = anchorElement?.getBoundingClientRect().top || 0;
634
- let removedRowCount = 0;
635
- for (let i = renderedRows.length - 1; removedRowCount < sectionRowsNumber; i--) {
636
- let row = tableBody.children.item(i);
637
- removedRowCount++;
638
- const rowKey = row?.getAttribute("data-key");
639
- const isExpanded = expandedRows.some((r) => r.item[uniqueKey] == rowKey);
640
- if (isExpanded) {
641
- i--;
646
+ async function handleLoadBackward() {
647
+ if (currentSectionNumber > 0) {
648
+ userScrolling = false;
649
+ const anchorIndex = 0;
650
+ const anchorUniqueKey = renderedRows[anchorIndex].item[uniqueKey];
651
+ const anchorElement = findAnchorElement(anchorUniqueKey);
652
+ const anchorOffsetBefore = anchorElement?.getBoundingClientRect().top || 0;
653
+ let removedRowCount = 0;
654
+ for (let i = renderedRows.length - 1; removedRowCount < sectionRowsNumber; i--) {
655
+ let row = tableBody.children.item(i);
656
+ removedRowCount++;
657
+ const rowKey = row?.getAttribute("data-key");
658
+ const isExpanded = expandedRows.some((r) => r.item[uniqueKey] == rowKey);
659
+ if (isExpanded) {
660
+ i--;
661
+ }
642
662
  }
643
- }
644
- currentSectionNumber = currentSectionNumber - 1;
645
- setTimeout(() => {
663
+ currentSectionNumber = currentSectionNumber - 1;
664
+ await tick();
646
665
  const anchorElementAfter = findAnchorElement(anchorUniqueKey);
647
666
  const anchorOffsetAfter = anchorElementAfter?.getBoundingClientRect().top || 0;
648
667
  const offsetDiff = anchorOffsetAfter - anchorOffsetBefore;
649
668
  tableContainer.scrollTop += offsetDiff;
650
669
  userScrolling = true;
651
- }, 10);
670
+ }
652
671
  }
653
672
  function findAnchorElement(key) {
654
673
  for (let i = 0; i < tableBody.children.length; i++) {
@@ -659,6 +678,110 @@ function findAnchorElement(key) {
659
678
  }
660
679
  return void 0;
661
680
  }
681
+ function resize(node) {
682
+ let th = node.parentElement;
683
+ let resizingInner = false;
684
+ if (!!th) {
685
+ let mouseMoveHandler = function(e) {
686
+ if (resizingInner && !!th && !!tableContainer) {
687
+ width += e.movementX;
688
+ const { paddingLeft, paddingRight } = getComputedStyle(th);
689
+ const minWidth = headers.find((h) => h.value === th.id)?.minWidth;
690
+ let minWidthPx;
691
+ if (!!minWidth && minWidth.endsWith("px")) {
692
+ minWidthPx = parseInt(minWidth, 10);
693
+ }
694
+ const maxWidth = headers.find((h) => h.value === th.id)?.maxWidth;
695
+ let maxWidthPx;
696
+ if (!!maxWidth && maxWidth.endsWith("px")) {
697
+ maxWidthPx = parseInt(maxWidth, 10);
698
+ }
699
+ const actualMinWidth = (minWidthPx || DEFAULT_MIN_WIDTH_PX) - parseFloat(paddingLeft) - parseFloat(paddingRight);
700
+ const actualMaxWidth = (maxWidthPx || DEFAULT_MAX_WIDTH_PX) - parseFloat(paddingLeft) - parseFloat(paddingRight);
701
+ if (width > actualMinWidth && width < actualMaxWidth) {
702
+ th.style.width = width + "px";
703
+ resizedColumnSizeWithPadding[th.id] = th.getBoundingClientRect().width;
704
+ resizedColumnSizeWithPadding = resizedColumnSizeWithPadding;
705
+ }
706
+ }
707
+ }, mouseUpHandler = function(e, setResize = true) {
708
+ if (!!th) {
709
+ resizingInner = false;
710
+ let { paddingLeft, paddingRight } = getComputedStyle(th);
711
+ width = th.getBoundingClientRect().width - parseFloat(paddingLeft) - parseFloat(paddingRight);
712
+ if (setResize) {
713
+ setTimeout(() => resizing = false, 20);
714
+ }
715
+ dispatch("columnResize", {
716
+ id: th.id,
717
+ newWidthPx: width
718
+ });
719
+ }
720
+ }, mouseDownHandler = function(e) {
721
+ if (!!th) {
722
+ resizing = true;
723
+ resizingInner = true;
724
+ let { paddingLeft, paddingRight } = getComputedStyle(th);
725
+ width = th.getBoundingClientRect().width - parseFloat(paddingLeft) - parseFloat(paddingRight);
726
+ }
727
+ };
728
+ let { width } = th.getBoundingClientRect();
729
+ node.addEventListener("mousedown", mouseDownHandler);
730
+ document.addEventListener("mouseup", mouseUpHandler);
731
+ document.addEventListener("mousemove", mouseMoveHandler);
732
+ return {
733
+ destroy() {
734
+ node.removeEventListener("mousedown", mouseDownHandler);
735
+ document.removeEventListener("mouseup", mouseUpHandler);
736
+ document.removeEventListener("mousemove", mouseMoveHandler);
737
+ }
738
+ };
739
+ }
740
+ }
741
+ $:
742
+ if (resizableColumns && !!tableContainer && resizableColumns && headersToShowInTable.length > 0 && resizedColumnSizeWithPadding && headersToShow.length > 0 && mainHeader) {
743
+ tick().then(updateRemainingWidth);
744
+ }
745
+ async function updateRemainingWidth() {
746
+ if (tableContainer != null && !!tableContainer) {
747
+ const containerWidth = tableContainer?.getBoundingClientRect().width - 30;
748
+ if (containerWidth) {
749
+ const totalResizableWidth = headersToShowInTable.reduce((sum, head) => {
750
+ let th = document.getElementById(head.value);
751
+ if (!!th) {
752
+ resizeHeader(th, head);
753
+ }
754
+ const width = th?.getBoundingClientRect().width || 0;
755
+ return sum + width + 1;
756
+ }, 0);
757
+ const extraStaticWidth = Array.from(mainHeader.querySelectorAll("th.non-resizable, th.slot-append, th.customize-headers")).reduce((sum, th) => sum + th.getBoundingClientRect().width + 1, 0);
758
+ remainingWidth = Math.max(0, containerWidth - totalResizableWidth - extraStaticWidth);
759
+ }
760
+ }
761
+ }
762
+ function resizeHeader(th, header) {
763
+ if (!resizedColumnSizeWithPadding[header.value]) {
764
+ let widthWihtPadding = th.getBoundingClientRect().width;
765
+ let minWidth = header.minWidth, minWidthPx = DEFAULT_MIN_WIDTH_PX;
766
+ if (!!minWidth && minWidth.endsWith("px")) {
767
+ minWidthPx = parseInt(minWidth, 10);
768
+ }
769
+ if (widthWihtPadding < minWidthPx) {
770
+ widthWihtPadding = minWidthPx;
771
+ }
772
+ let maxWidth = header.maxWidth, maxWidthPx = DEFAULT_MAX_WIDTH_PX;
773
+ if (!!maxWidth && maxWidth.endsWith("px")) {
774
+ maxWidthPx = parseInt(maxWidth, 10);
775
+ }
776
+ if (widthWihtPadding > maxWidthPx) {
777
+ widthWihtPadding = maxWidthPx;
778
+ }
779
+ resizedColumnSizeWithPadding[header.value] = widthWihtPadding;
780
+ }
781
+ let { paddingLeft, paddingRight } = getComputedStyle(th);
782
+ let width = resizedColumnSizeWithPadding[header.value] - parseFloat(paddingLeft) - parseFloat(paddingRight);
783
+ th.style.width = `${width}px`;
784
+ }
662
785
  </script>
663
786
 
664
787
  {#if !!rows && Array.isArray(rows) && !!headersToShowInTable && Array.isArray(headersToShowInTable)}
@@ -795,7 +918,6 @@ function findAnchorElement(key) {
795
918
 
796
919
  <div class="outer-container">
797
920
  <div class="inner-container" bind:this={tableContainer} on:scroll>
798
- <!-- <div class="table-container" bind:this={tableContainer}> -->
799
921
  <InfiniteScroll
800
922
  on:loadMore={handleLoadBackward}
801
923
  threshold={backwardThresholdPixel}
@@ -810,6 +932,7 @@ function findAnchorElement(key) {
810
932
  style:width="30px"
811
933
  style:min-width="30px"
812
934
  style:text-align="center"
935
+ class="non-resizable"
813
936
  >
814
937
  {#if selectMode === "multiple"}
815
938
  <Checkbox
@@ -824,16 +947,22 @@ function findAnchorElement(key) {
824
947
  {#if showExpand}
825
948
  <th
826
949
  style:min-width="60px"
950
+ style:max-width="60px"
827
951
  style:text-align="center"
952
+ class="non-resizable"
828
953
  />
829
954
  {/if}
830
955
  {#each headersToShowInTable as head, index}
831
956
  <th
832
- style:width={head.width}
957
+ style={`${resizableColumns || !head.width ? '' : `width: ${head.width}`}`}
833
958
  style:min-width={head.minWidth}
834
959
  class:sortable={head.sortable}
835
960
  on:click={() => handleHeaderClick(head)}
961
+ id={head.value}
836
962
  >
963
+ {#if resizableColumns}
964
+ <div class="resizer" use:resize></div>
965
+ {/if}
837
966
  <slot name="header" {head}>
838
967
  <span class="header-label" bind:this={infoActivators[index]}>
839
968
  <slot name="headerLabel">{head.label}</slot>
@@ -876,17 +1005,27 @@ function findAnchorElement(key) {
876
1005
  </th>
877
1006
  {/each}
878
1007
  {#if $$slots.rowActions || $$slots.append}
879
- <th>
1008
+ <th
1009
+ class="slot-append"
1010
+ >
880
1011
  <slot name="append" index={-1} items={undefined} />
881
1012
  </th>
882
1013
  {/if}
1014
+ {#if resizableColumns && remainingWidth}
1015
+ <th
1016
+ style:width={remainingWidth + 'px'}
1017
+ class="filler"
1018
+ aria-hidden="true"
1019
+ />
1020
+ {/if}
883
1021
  {#if customizeHeaders}
884
1022
  <th
885
- style:width="30px"
886
- style:min-width="30px"
1023
+ style:width="15px"
1024
+ style:min-width="15px"
887
1025
  style:text-align="center"
1026
+ class="customize-headers"
888
1027
  >
889
- <div style="display: flex; gap: 8px;">
1028
+ <div style="display: flex; justify-content: center;">
890
1029
  <Icon
891
1030
  name="mdi-plus-circle-outline"
892
1031
  click
@@ -1034,6 +1173,7 @@ function findAnchorElement(key) {
1034
1173
  <td
1035
1174
  colspan={headersToShowInTable.length + 1}
1036
1175
  style:border="none"
1176
+ class="expanded-row"
1037
1177
  >
1038
1178
  <table style="display: table;">
1039
1179
  <thead class="table-header table-subheader">
@@ -1607,10 +1747,25 @@ function findAnchorElement(key) {
1607
1747
  border-collapse: separate;
1608
1748
  }
1609
1749
 
1750
+ .table.resizable {
1751
+ table-layout: fixed;
1752
+ width: fit-content;
1753
+ }
1754
+
1755
+ .slot-append {
1756
+ width: 1px;
1757
+ min-width: unset;
1758
+ box-sizing: content-box;
1759
+ }
1760
+
1610
1761
  .table-header {
1611
1762
  position: sticky;
1612
1763
  top: 0;
1613
1764
  z-index: 2;
1765
+ height: var(
1766
+ --dynamic-table-header-height,
1767
+ var(--dynamic-table-default-header-height)
1768
+ );
1614
1769
  }
1615
1770
 
1616
1771
  @media not all and (min-resolution:.001dpcm) {
@@ -1651,12 +1806,6 @@ function findAnchorElement(key) {
1651
1806
  );
1652
1807
  }
1653
1808
 
1654
- .table-header th.sortable {
1655
- cursor: pointer;
1656
- transition: all 0.1s ease-in;
1657
- user-select: none;
1658
- }
1659
-
1660
1809
  .table-header th.sortable:hover {
1661
1810
  color: var(
1662
1811
  --dynamic-table-header-hover-color,
@@ -1699,13 +1848,6 @@ function findAnchorElement(key) {
1699
1848
  );
1700
1849
  }
1701
1850
 
1702
- .thead {
1703
- height: var(
1704
- --dynamic-table-header-height,
1705
- var(--dynamic-table-default-header-height)
1706
- );
1707
- }
1708
-
1709
1851
  table {
1710
1852
  border-collapse: separate;
1711
1853
  width: 100%;
@@ -1715,6 +1857,9 @@ function findAnchorElement(key) {
1715
1857
  text-align: start;
1716
1858
  padding-left: 10px;
1717
1859
  min-width: 100px;
1860
+ position: relative;
1861
+ user-select: none;
1862
+ box-sizing: content-box;
1718
1863
  }
1719
1864
 
1720
1865
  td {
@@ -1722,6 +1867,20 @@ function findAnchorElement(key) {
1722
1867
  border: 1px solid transparent;
1723
1868
  }
1724
1869
 
1870
+ table.table > tbody > tr > td {
1871
+ overflow: hidden;
1872
+ text-overflow: ellipsis;
1873
+ }
1874
+
1875
+ table.table > thead > tr > th {
1876
+ overflow: hidden;
1877
+ text-overflow: ellipsis;
1878
+ }
1879
+
1880
+ table.table > tbody > tr > td.expanded-row {
1881
+ overflow: visible;
1882
+ }
1883
+
1725
1884
  .hover-cell:hover, .hover-cell:focus, .cell-edit-activator {
1726
1885
  cursor: pointer;
1727
1886
  border: 1px solid rgb(var(--global-color-contrast-800));
@@ -1925,4 +2084,16 @@ function findAnchorElement(key) {
1925
2084
  align-items: center;
1926
2085
  gap: 4px;
1927
2086
  }
2087
+ .resizer {
2088
+ position: absolute;
2089
+ top: 0;
2090
+ right: 0;
2091
+ width: 6px;
2092
+ height: 100%;
2093
+ cursor: col-resize;
2094
+ z-index: 100;
2095
+ }
2096
+ .filler {
2097
+ padding: 0 !important;
2098
+ }
1928
2099
  </style>
@@ -45,6 +45,7 @@ declare const __propDef: {
45
45
  info?: string | undefined;
46
46
  } | undefined;
47
47
  info?: string | undefined;
48
+ maxWidth?: string | undefined;
48
49
  })[] | undefined;
49
50
  headersToShowInTable?: (import("../../simple/lists/SimpleTable.svelte").Header & {
50
51
  cellEditorInfo?: {
@@ -77,6 +78,7 @@ declare const __propDef: {
77
78
  info?: string | undefined;
78
79
  } | undefined;
79
80
  info?: string | undefined;
81
+ maxWidth?: string | undefined;
80
82
  })[] | undefined;
81
83
  subHeaders?: (import("../../simple/lists/SimpleTable.svelte").Header & {
82
84
  cellEditorInfo?: {
@@ -109,6 +111,7 @@ declare const __propDef: {
109
111
  info?: string | undefined;
110
112
  } | undefined;
111
113
  info?: string | undefined;
114
+ maxWidth?: string | undefined;
112
115
  })[] | undefined;
113
116
  customizeHeaders?: boolean | undefined;
114
117
  rows?: {
@@ -163,6 +166,10 @@ declare const __propDef: {
163
166
  } | undefined;
164
167
  numberOfResultsVisible?: boolean | undefined;
165
168
  endLineVisible?: boolean | undefined;
169
+ resizableColumns?: boolean | undefined;
170
+ resizedColumnSizeWithPadding?: {
171
+ [value: string]: number;
172
+ } | undefined;
166
173
  };
167
174
  events: {
168
175
  scroll: Event;
@@ -209,6 +216,10 @@ declare const __propDef: {
209
216
  quickFilter: QuickFilter;
210
217
  setQuickFilterValue: (quickFilter: QuickFilter, value?: any) => void;
211
218
  }>;
219
+ columnResize: CustomEvent<{
220
+ id: string;
221
+ newWidthPx: number;
222
+ }>;
212
223
  } & {
213
224
  [evt: string]: CustomEvent<any>;
214
225
  };
@@ -257,6 +268,7 @@ declare const __propDef: {
257
268
  info?: string | undefined;
258
269
  } | undefined;
259
270
  info?: string | undefined;
271
+ maxWidth?: string | undefined;
260
272
  };
261
273
  };
262
274
  headerLabel: {};
@@ -309,6 +321,7 @@ declare const __propDef: {
309
321
  info?: string | undefined;
310
322
  } | undefined;
311
323
  info?: string | undefined;
324
+ maxWidth?: string | undefined;
312
325
  };
313
326
  row: {
314
327
  item: {
@@ -380,6 +393,7 @@ declare const __propDef: {
380
393
  info?: string | undefined;
381
394
  } | undefined;
382
395
  info?: string | undefined;
396
+ maxWidth?: string | undefined;
383
397
  };
384
398
  subItem: {
385
399
  [key: string]: any;
@@ -14,7 +14,7 @@ export let headers = [], items = [], sortedBy = void 0, sortDirection = void 0,
14
14
  { label: "20", value: 20 },
15
15
  { label: "50", value: 50 },
16
16
  { label: "100", value: 100 }
17
- ], hideRowsPerPage = false, totalElements = void 0, rowsPerPage = 20, filters = [], searchBarColumns = void 0, searchBarVisible = true, searchBarPlaceholder = "Type something to search...", lang = "en", editFilterMode = "one-edit", showActiveFilters = true, resizableColumns = false, resizedColumnSizeWithPadding = {}, pointerOnRowHover = void 0;
17
+ ], hideRowsPerPage = false, totalElements = void 0, rowsPerPage = 20, filters = [], searchBarColumns = void 0, searchBarVisible = true, searchBarPlaceholder = "Type something to search...", lang = "en", editFilterMode = "one-edit", showActiveFilters = true, resizableColumns = false, resizedColumnSizeWithPadding = {}, pointerOnRowHover = void 0, doubleClickActive = false, doubleClickDelay = 250;
18
18
  export let calculateRowStyles = void 0;
19
19
  export let calculateRowClasses = void 0;
20
20
  let searchBarInput, searchText = void 0;
@@ -118,9 +118,12 @@ function buildFilters(params) {
118
118
  bind:sortedBy
119
119
  bind:sortDirection
120
120
  bind:pointerOnRowHover
121
+ {doubleClickActive}
122
+ {doubleClickDelay}
121
123
  on:sort={handleFiltersChange}
122
124
  on:sort
123
125
  on:rowClick
126
+ on:rowDoubleClick
124
127
  {calculateRowStyles}
125
128
  {calculateRowClasses}
126
129
  {resizableColumns}
@@ -33,6 +33,8 @@ declare const __propDef: {
33
33
  [value: string]: number;
34
34
  } | undefined;
35
35
  pointerOnRowHover?: boolean | undefined;
36
+ doubleClickActive?: ComponentProps<SimpleTable>['doubleClickActive'];
37
+ doubleClickDelay?: ComponentProps<SimpleTable>['doubleClickDelay'];
36
38
  calculateRowStyles?: CalculateRowStyles | undefined;
37
39
  calculateRowClasses?: CalculateRowClasses | undefined;
38
40
  };
@@ -48,6 +50,9 @@ declare const __propDef: {
48
50
  rowClick: CustomEvent<{
49
51
  item: import("../../simple/lists/SimpleTable.svelte").Item;
50
52
  }>;
53
+ rowDoubleClick: CustomEvent<{
54
+ item: import("../../simple/lists/SimpleTable.svelte").Item;
55
+ }>;
51
56
  } & {
52
57
  [evt: string]: CustomEvent<any>;
53
58
  };
@@ -7,7 +7,8 @@ import { createEventDispatcher, onMount } from "svelte";
7
7
  let clazz = {};
8
8
  export { clazz as class };
9
9
  const dispatch = createEventDispatcher();
10
- export let headers = [], items = [], sortedBy = void 0, sortDirection = "asc", resizableColumns = false, resizedColumnSizeWithPadding = {}, pointerOnRowHover = false;
10
+ export let headers = [], items = [], sortedBy = void 0, sortDirection = "asc", resizableColumns = false, resizedColumnSizeWithPadding = {}, pointerOnRowHover = false, doubleClickActive = false, doubleClickDelay = 250;
11
+ let clickTimeout = void 0;
11
12
  export let calculateRowStyles = void 0;
12
13
  export let calculateRowClasses = void 0;
13
14
  onMount(() => {
@@ -65,9 +66,20 @@ function handleHeaderClick(header) {
65
66
  }
66
67
  }
67
68
  function handleRowClick(item) {
68
- dispatch("rowClick", {
69
- item
70
- });
69
+ if (doubleClickActive) {
70
+ if (clickTimeout) {
71
+ clearTimeout(clickTimeout);
72
+ clickTimeout = void 0;
73
+ dispatch("rowDoubleClick", { item });
74
+ } else {
75
+ clickTimeout = setTimeout(() => {
76
+ dispatch("rowClick", { item });
77
+ clickTimeout = void 0;
78
+ }, doubleClickDelay);
79
+ }
80
+ } else {
81
+ dispatch("rowClick", { item });
82
+ }
71
83
  }
72
84
  function formatDate(dateTime, dateFormat) {
73
85
  return dateTime.setLocale(dateFormat.locale).toFormat(dateFormat.format);
@@ -40,6 +40,8 @@ declare const __propDef: {
40
40
  [value: string]: number;
41
41
  } | undefined;
42
42
  pointerOnRowHover?: boolean | undefined;
43
+ doubleClickActive?: boolean | undefined;
44
+ doubleClickDelay?: number | undefined;
43
45
  calculateRowStyles?: CalculateRowStyles | undefined;
44
46
  calculateRowClasses?: CalculateRowClasses | undefined;
45
47
  };
@@ -51,6 +53,9 @@ declare const __propDef: {
51
53
  rowClick: CustomEvent<{
52
54
  item: Item;
53
55
  }>;
56
+ rowDoubleClick: CustomEvent<{
57
+ item: Item;
58
+ }>;
54
59
  columnResize: CustomEvent<{
55
60
  id: string;
56
61
  newWidthPx: number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likable-hair/svelte",
3
3
  "description": "A Svelte component for likablehair and others",
4
- "version": "3.3.14",
4
+ "version": "3.3.16",
5
5
  "scripts": {
6
6
  "host": "vite --host",
7
7
  "dev": "vite dev",