@likable-hair/svelte 3.1.23 → 3.1.24

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.
@@ -11,7 +11,7 @@ import Dialog from "../../simple/dialogs/Dialog.svelte";
11
11
  let clazz = {};
12
12
  export { clazz as class };
13
13
  let dispatch = createEventDispatcher();
14
- export let menuOpened = false, openingId = "date-picker-text-field", pattern = "dd/MM/yyyy", selectedMonth = void 0, selectedYear = void 0, visibleMonth = void 0, visibleYear = void 0, selectedDate = void 0, placeholder = void 0, mobileDialog = true, maxYearInRange = 2100, minYearInRange = 1970, disabled = false;
14
+ export let menuOpened = false, openingId = "date-picker-text-field", pattern = "dd/MM/yyyy", selectedMonth = void 0, selectedYear = void 0, visibleMonth = void 0, visibleYear = void 0, selectedDate = void 0, placeholder = void 0, mobileDialog = true, maxYearInRange = 2100, minYearInRange = 1970, disabled = false, flipOnOverflow = true;
15
15
  let activator, refreshPosition = false, menuElement, inputElement, mask = {
16
16
  value: void 0
17
17
  }, maskFactoryArgs = {
@@ -211,6 +211,7 @@ $:
211
211
  bind:refreshPosition
212
212
  bind:menuElement
213
213
  bind:openingId={openingId}
214
+ flipOnOverflow={flipOnOverflow}
214
215
  >
215
216
  <div
216
217
  style:background-color="rgb(var(--global-color-background-100))"
@@ -21,6 +21,7 @@ declare const __propDef: {
21
21
  maxYearInRange?: number | undefined;
22
22
  minYearInRange?: number | undefined;
23
23
  disabled?: boolean | undefined;
24
+ flipOnOverflow?: boolean | undefined;
24
25
  };
25
26
  events: {
26
27
  'day-click': CustomEvent<{
@@ -124,6 +124,7 @@ $:
124
124
  bind:menuOpened={calendarOpened}
125
125
  on:day-click={() => {calendarOpened = false}}
126
126
  --simple-textfield-width="100%"
127
+ flipOnOverflow
127
128
  >
128
129
  <svelte:fragment slot="append-inner">
129
130
  <Icon
@@ -202,6 +203,7 @@ $:
202
203
  bind:menuOpened={calendarOpened2}
203
204
  on:day-click={() => {calendarOpened2 = false}}
204
205
  --simple-textfield-width="100%"
206
+ flipOnOverflow
205
207
  >
206
208
  <svelte:fragment slot="append-inner">
207
209
  <Icon
@@ -296,7 +296,7 @@ let moreItemsActivator;
296
296
 
297
297
  <MediaQuery let:mAndDown>
298
298
  <div class="filters-wrapper" class:mobile={mAndDown} style:--filter-dot-size={activeFilters.length > 0 ? '22px' : '0px'} style:--filter-dot-content={activeFilters.length > 0 ? `"${activeFilters.length}"` : '""'}>
299
- <div class="filters-container" class:mobile={mAndDown}>
299
+ <div class="filters-container" class:mobile={mAndDown} class:hidden={mAndDown && (!showActiveFilters || activeFilters.length == 0)}>
300
300
  {#if showActiveFilters}
301
301
  {#each activeFilters as filter}
302
302
  <div
@@ -587,6 +587,7 @@ let moreItemsActivator;
587
587
  _borderRadius="5px"
588
588
  anchor="bottom"
589
589
  openingId="select-filter"
590
+ flipOnOverflow
590
591
  >
591
592
  <div
592
593
  style:background-color="rgb(var(--global-color-background-200))"
@@ -917,4 +918,8 @@ let moreItemsActivator;
917
918
  grid-column: span 2;
918
919
  }
919
920
 
921
+ .hidden {
922
+ display: none;
923
+ }
924
+
920
925
  </style>
@@ -59,9 +59,9 @@ function calculateMenuPosition(params) {
59
59
  }
60
60
  }
61
61
  if (flipOnOverflow && !!params.activator) {
62
- if (window.innerHeight + window.scrollY < (_top || 0) + (menuElement?.offsetHeight || 0)) {
63
- let { top: activatorTop } = params.activator.getBoundingClientRect();
64
- _top = activatorTop + window.scrollY - _activatorGap - (menuElement?.offsetHeight || 0);
62
+ let { top: activatorTopDistance } = params.activator.getBoundingClientRect();
63
+ if (window.innerHeight < activatorTopDistance + (menuElement?.offsetHeight || 0) + (menuElement?.offsetHeight || 0) * 0.1) {
64
+ _top = getTopDistance(params.activator) - _activatorGap - (menuElement?.offsetHeight || 0);
65
65
  }
66
66
  if (anchor == "right-center" && window.innerWidth + window.scrollX < (_left || 0) + (menuElement?.offsetWidth || 0)) {
67
67
  let { left: activatorLeft } = params.activator.getBoundingClientRect();
@@ -94,8 +94,38 @@ function calculateMenuPosition(params) {
94
94
  }
95
95
  }
96
96
  }
97
+ function getTopDistance(elem) {
98
+ let positionedAncestor2 = getPositionedAncestor(elem);
99
+ if (!!positionedAncestor2) {
100
+ let top = parseInt(getComputedStyle(positionedAncestor2).top);
101
+ return (isNaN(top) ? 0 : top) + elem.offsetTop - calcScrollY(elem);
102
+ }
103
+ return window.scrollY + elem.getBoundingClientRect().top;
104
+ }
105
+ function calcScrollY(elem) {
106
+ let parent = elem.parentElement;
107
+ let scroll = 0;
108
+ while (!!parent) {
109
+ scroll += parent.scrollTop;
110
+ let parentPosition = getComputedStyle(parent).position;
111
+ if (parentPosition === "absolute" || parentPosition === "fixed")
112
+ break;
113
+ parent = parent.parentElement;
114
+ }
115
+ return scroll;
116
+ }
97
117
  $:
98
118
  if (open) {
119
+ if (!!activator) {
120
+ let parent = activator.parentElement;
121
+ while (!!parent) {
122
+ let parentPosition = getComputedStyle(parent).position;
123
+ parent.addEventListener("scroll", refreshMenuPosition);
124
+ if (parentPosition == "absolute" || parentPosition == "fixed")
125
+ break;
126
+ parent = parent.parentElement;
127
+ }
128
+ }
99
129
  if (!!openingId) {
100
130
  const controllers = document.querySelectorAll(`[data-operation="close"][data-opening-id="${openingId}"]`);
101
131
  for (let k = 0; k < controllers.length; k += 1) {
@@ -251,6 +281,7 @@ $:
251
281
  ></div>
252
282
  {#if open}
253
283
  <div
284
+ role="presentation"
254
285
  bind:this={menuElement}
255
286
  data-menu
256
287
  data-uid={currentUid}
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.1.23",
4
+ "version": "3.1.24",
5
5
  "scripts": {
6
6
  "host": "vite --host",
7
7
  "dev": "vite dev",