@likable-hair/svelte 3.3.15 → 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.
@@ -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";
@@ -625,28 +644,30 @@ async function handleLoadForward() {
625
644
  }
626
645
  }
627
646
  async function handleLoadBackward() {
628
- userScrolling = false;
629
- const anchorIndex = 0;
630
- const anchorUniqueKey = renderedRows[anchorIndex].item[uniqueKey];
631
- const anchorElement = findAnchorElement(anchorUniqueKey);
632
- const anchorOffsetBefore = anchorElement?.getBoundingClientRect().top || 0;
633
- let removedRowCount = 0;
634
- for (let i = renderedRows.length - 1; removedRowCount < sectionRowsNumber; i--) {
635
- let row = tableBody.children.item(i);
636
- removedRowCount++;
637
- const rowKey = row?.getAttribute("data-key");
638
- const isExpanded = expandedRows.some((r) => r.item[uniqueKey] == rowKey);
639
- if (isExpanded) {
640
- i--;
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
+ }
641
662
  }
663
+ currentSectionNumber = currentSectionNumber - 1;
664
+ await tick();
665
+ const anchorElementAfter = findAnchorElement(anchorUniqueKey);
666
+ const anchorOffsetAfter = anchorElementAfter?.getBoundingClientRect().top || 0;
667
+ const offsetDiff = anchorOffsetAfter - anchorOffsetBefore;
668
+ tableContainer.scrollTop += offsetDiff;
669
+ userScrolling = true;
642
670
  }
643
- currentSectionNumber = currentSectionNumber - 1;
644
- await tick();
645
- const anchorElementAfter = findAnchorElement(anchorUniqueKey);
646
- const anchorOffsetAfter = anchorElementAfter?.getBoundingClientRect().top || 0;
647
- const offsetDiff = anchorOffsetAfter - anchorOffsetBefore;
648
- tableContainer.scrollTop += offsetDiff;
649
- userScrolling = true;
650
671
  }
651
672
  function findAnchorElement(key) {
652
673
  for (let i = 0; i < tableBody.children.length; i++) {
@@ -657,6 +678,110 @@ function findAnchorElement(key) {
657
678
  }
658
679
  return void 0;
659
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
+ }
660
785
  </script>
661
786
 
662
787
  {#if !!rows && Array.isArray(rows) && !!headersToShowInTable && Array.isArray(headersToShowInTable)}
@@ -793,7 +918,6 @@ function findAnchorElement(key) {
793
918
 
794
919
  <div class="outer-container">
795
920
  <div class="inner-container" bind:this={tableContainer} on:scroll>
796
- <!-- <div class="table-container" bind:this={tableContainer}> -->
797
921
  <InfiniteScroll
798
922
  on:loadMore={handleLoadBackward}
799
923
  threshold={backwardThresholdPixel}
@@ -808,6 +932,7 @@ function findAnchorElement(key) {
808
932
  style:width="30px"
809
933
  style:min-width="30px"
810
934
  style:text-align="center"
935
+ class="non-resizable"
811
936
  >
812
937
  {#if selectMode === "multiple"}
813
938
  <Checkbox
@@ -822,16 +947,22 @@ function findAnchorElement(key) {
822
947
  {#if showExpand}
823
948
  <th
824
949
  style:min-width="60px"
950
+ style:max-width="60px"
825
951
  style:text-align="center"
952
+ class="non-resizable"
826
953
  />
827
954
  {/if}
828
955
  {#each headersToShowInTable as head, index}
829
956
  <th
830
- style:width={head.width}
957
+ style={`${resizableColumns || !head.width ? '' : `width: ${head.width}`}`}
831
958
  style:min-width={head.minWidth}
832
959
  class:sortable={head.sortable}
833
960
  on:click={() => handleHeaderClick(head)}
961
+ id={head.value}
834
962
  >
963
+ {#if resizableColumns}
964
+ <div class="resizer" use:resize></div>
965
+ {/if}
835
966
  <slot name="header" {head}>
836
967
  <span class="header-label" bind:this={infoActivators[index]}>
837
968
  <slot name="headerLabel">{head.label}</slot>
@@ -874,17 +1005,27 @@ function findAnchorElement(key) {
874
1005
  </th>
875
1006
  {/each}
876
1007
  {#if $$slots.rowActions || $$slots.append}
877
- <th>
1008
+ <th
1009
+ class="slot-append"
1010
+ >
878
1011
  <slot name="append" index={-1} items={undefined} />
879
1012
  </th>
880
1013
  {/if}
1014
+ {#if resizableColumns && remainingWidth}
1015
+ <th
1016
+ style:width={remainingWidth + 'px'}
1017
+ class="filler"
1018
+ aria-hidden="true"
1019
+ />
1020
+ {/if}
881
1021
  {#if customizeHeaders}
882
1022
  <th
883
- style:width="30px"
884
- style:min-width="30px"
1023
+ style:width="15px"
1024
+ style:min-width="15px"
885
1025
  style:text-align="center"
1026
+ class="customize-headers"
886
1027
  >
887
- <div style="display: flex; gap: 8px;">
1028
+ <div style="display: flex; justify-content: center;">
888
1029
  <Icon
889
1030
  name="mdi-plus-circle-outline"
890
1031
  click
@@ -1032,6 +1173,7 @@ function findAnchorElement(key) {
1032
1173
  <td
1033
1174
  colspan={headersToShowInTable.length + 1}
1034
1175
  style:border="none"
1176
+ class="expanded-row"
1035
1177
  >
1036
1178
  <table style="display: table;">
1037
1179
  <thead class="table-header table-subheader">
@@ -1605,10 +1747,25 @@ function findAnchorElement(key) {
1605
1747
  border-collapse: separate;
1606
1748
  }
1607
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
+
1608
1761
  .table-header {
1609
1762
  position: sticky;
1610
1763
  top: 0;
1611
1764
  z-index: 2;
1765
+ height: var(
1766
+ --dynamic-table-header-height,
1767
+ var(--dynamic-table-default-header-height)
1768
+ );
1612
1769
  }
1613
1770
 
1614
1771
  @media not all and (min-resolution:.001dpcm) {
@@ -1649,12 +1806,6 @@ function findAnchorElement(key) {
1649
1806
  );
1650
1807
  }
1651
1808
 
1652
- .table-header th.sortable {
1653
- cursor: pointer;
1654
- transition: all 0.1s ease-in;
1655
- user-select: none;
1656
- }
1657
-
1658
1809
  .table-header th.sortable:hover {
1659
1810
  color: var(
1660
1811
  --dynamic-table-header-hover-color,
@@ -1697,13 +1848,6 @@ function findAnchorElement(key) {
1697
1848
  );
1698
1849
  }
1699
1850
 
1700
- .thead {
1701
- height: var(
1702
- --dynamic-table-header-height,
1703
- var(--dynamic-table-default-header-height)
1704
- );
1705
- }
1706
-
1707
1851
  table {
1708
1852
  border-collapse: separate;
1709
1853
  width: 100%;
@@ -1713,6 +1857,9 @@ function findAnchorElement(key) {
1713
1857
  text-align: start;
1714
1858
  padding-left: 10px;
1715
1859
  min-width: 100px;
1860
+ position: relative;
1861
+ user-select: none;
1862
+ box-sizing: content-box;
1716
1863
  }
1717
1864
 
1718
1865
  td {
@@ -1720,6 +1867,20 @@ function findAnchorElement(key) {
1720
1867
  border: 1px solid transparent;
1721
1868
  }
1722
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
+
1723
1884
  .hover-cell:hover, .hover-cell:focus, .cell-edit-activator {
1724
1885
  cursor: pointer;
1725
1886
  border: 1px solid rgb(var(--global-color-contrast-800));
@@ -1923,4 +2084,16 @@ function findAnchorElement(key) {
1923
2084
  align-items: center;
1924
2085
  gap: 4px;
1925
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
+ }
1926
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.15",
4
+ "version": "3.3.16",
5
5
  "scripts": {
6
6
  "host": "vite --host",
7
7
  "dev": "vite dev",