@likable-hair/svelte 3.1.41 → 3.1.43

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.
@@ -62,14 +62,18 @@ function handleInputChange(event) {
62
62
  }
63
63
  }, 30);
64
64
  }
65
- function handleYearSelect(ev) {
66
- if (!!selectedYear) {
67
- mask.value = selectedYear.toString();
68
- }
65
+ function handleYearClick(ev) {
69
66
  dispatch("year-click", {
70
67
  year: ev.detail.year
71
68
  });
72
69
  }
70
+ function handleYearChange(ev) {
71
+ if (!!selectedYear) {
72
+ mask.value = selectedYear.toString();
73
+ } else {
74
+ mask.value = "";
75
+ }
76
+ }
73
77
  $:
74
78
  if (!!selectedYear) {
75
79
  setTimeout(() => {
@@ -139,7 +143,8 @@ $:
139
143
  >
140
144
  <YearSelector
141
145
  bind:selectedYear={selectedYear}
142
- on:click={handleYearSelect}
146
+ on:click={handleYearClick}
147
+ on:change={handleYearChange}
143
148
  {disabled}
144
149
  ></YearSelector>
145
150
  </div>
@@ -162,7 +167,8 @@ $:
162
167
  >
163
168
  <YearSelector
164
169
  bind:selectedYear={selectedYear}
165
- on:click={handleYearSelect}
170
+ on:click={handleYearClick}
171
+ on:change={handleYearChange}
166
172
  {disabled}
167
173
  selectableYears={[...Array((maxYearInRange - minYearInRange) + 1).keys()].map((v) => {
168
174
  return minYearInRange + v
@@ -108,7 +108,7 @@ function calcScrollY(elem) {
108
108
  while (!!parent) {
109
109
  scroll += parent.scrollTop;
110
110
  let parentPosition = getComputedStyle(parent).position;
111
- if (parentPosition === "absolute" || parentPosition === "fixed")
111
+ if (parentPosition === "absolute" || parentPosition === "fixed" || parentPosition === "relative")
112
112
  break;
113
113
  parent = parent.parentElement;
114
114
  }
@@ -121,7 +121,7 @@ $:
121
121
  while (!!parent) {
122
122
  let parentPosition = getComputedStyle(parent).position;
123
123
  parent.addEventListener("scroll", refreshMenuPosition);
124
- if (parentPosition == "absolute" || parentPosition == "fixed")
124
+ if (parentPosition == "absolute" || parentPosition == "fixed" || parentPosition === "relative")
125
125
  break;
126
126
  parent = parent.parentElement;
127
127
  }
@@ -204,7 +204,7 @@ $:
204
204
  function getPositionedAncestor(elem) {
205
205
  if (!elem)
206
206
  return null;
207
- if (["fixed", "absolute", "sticky"].includes(getComputedStyle(elem).position))
207
+ if (["fixed", "absolute", "sticky", "relative"].includes(getComputedStyle(elem).position))
208
208
  return elem;
209
209
  return getPositionedAncestor(elem.parentElement);
210
210
  }
@@ -224,7 +224,7 @@ function getParentInstanceFromViewport(activatorParent) {
224
224
  const computedStyle = getComputedStyle(currentParent);
225
225
  const position = computedStyle.position;
226
226
  const display = computedStyle.display;
227
- if ((position === "fixed" || position === "absolute") && display === "flex") {
227
+ if ((position === "fixed" || position === "absolute" || position === "relative") && display === "flex") {
228
228
  const boundingClientRect = activatorParent.getBoundingClientRect();
229
229
  top = top + boundingClientRect.top;
230
230
  left = left + boundingClientRect.left;
@@ -14,11 +14,18 @@ onMount(() => {
14
14
  });
15
15
  const dispatch = createEventDispatcher();
16
16
  function handleYearClick(year) {
17
- selectedYear = year;
18
- scrollAtCenter(container, targetButtons[selectedYear], "smooth");
17
+ if (selectedYear === year) {
18
+ selectedYear = void 0;
19
+ } else {
20
+ selectedYear = year;
21
+ scrollAtCenter(container, targetButtons[selectedYear], "smooth");
22
+ }
19
23
  dispatch("click", {
20
24
  year
21
25
  });
26
+ dispatch("change", {
27
+ year: selectedYear
28
+ });
22
29
  }
23
30
  import Button from "../buttons/Button.svelte";
24
31
  </script>
@@ -12,6 +12,9 @@ declare const __propDef: {
12
12
  click: CustomEvent<{
13
13
  year: number;
14
14
  }>;
15
+ change: CustomEvent<{
16
+ year: number | undefined;
17
+ }>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
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.41",
4
+ "version": "3.1.43",
5
5
  "scripts": {
6
6
  "host": "vite --host",
7
7
  "dev": "vite dev",