overflowed 0.0.0-experimental-20221120013127 → 0.0.0-experimental-20230103160007

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.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2033 Alexandre Hitchcox
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -21,6 +21,7 @@ declare class Overflowed {
21
21
  private getElementSize;
22
22
  private getElementOffsetFromRight;
23
23
  private getElementOffsetFromLeft;
24
+ private getElementComputedValues;
24
25
  private update;
25
26
  private requestedUpdate;
26
27
  requestUpdate(): void;
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Overflowed
2
+
3
+ Overflowed is a small library allowing you to make your websites more responsive with collapsible
4
+ lists. It's currently in it's alpha stage and the APIs are potentially unstable, but I aim to
5
+ satisfy the following goals before a stable version.
6
+
7
+ - ⚛️ Works across all major frameworks
8
+ - 🌳 Lightweight and dependency-free, tree-shakable
9
+ - 🏗️ Includes strongly typed TypeScript declarations
10
+ - 🎨 Infinitely customizable, sensible defaults
11
+ - ⚡ Highly optimized and performant
12
+ - 📚 Clean API and comprehensive documentation
13
+ - ♿ Encourages accessible practices
14
+ - ↩️ Supports right-to-left writing modes
15
+ - 🦄 Ponyfills can be provided
16
+ - ⚙️ Supports SSR and environments without JS
17
+ - 🧩 Ships with ESM and CJS bundles
18
+
19
+ ## Installation
20
+
21
+ ```
22
+ npm install overflowed
23
+ yarn add overflowed
24
+ pnpm add overflowed
25
+ ```
26
+
27
+ ## Progress
28
+
29
+ - [ ] Documentation
30
+ - [ ] Getting started
31
+ - [ ] React
32
+ - [ ] Vue.js
33
+ - [ ] Svelte
34
+ - [ ] Preact
35
+ - [ ] SolidJS
36
+ - [ ] Examples
37
+ - [ ] Playground
38
+ - [ ] `overflowed/core`
39
+ - [ ] `overflowed/react`
40
+ - [ ] `useOverflowedItems`
41
+ - [ ] `overflowed/vue`
42
+ - [ ] `overflowed/svelte`
43
+ - [ ] `overflowedItems`
44
+ - [ ] `overflowed/preact`
45
+ - [ ] `overflowed/solid`
46
+
47
+ ## Usage
48
+
49
+ Check out the [examples](https://overflowed.aht.cx/examples) to see the library being used in
50
+ various scenarios and it's implementations.
@@ -73,23 +73,56 @@ var Overflowed = class {
73
73
  }
74
74
  return element.offsetTop;
75
75
  }
76
+ getElementComputedValues(element) {
77
+ const {
78
+ direction,
79
+ marginBlockStart,
80
+ marginBlockEnd,
81
+ marginInlineStart,
82
+ marginInlineEnd,
83
+ paddingBlockStart,
84
+ paddingBlockEnd,
85
+ paddingInlineStart,
86
+ paddingInlineEnd
87
+ } = window.getComputedStyle(element);
88
+ const marginStartAsString = this.axis === "horizontal" ? marginInlineStart : marginBlockStart;
89
+ const marginEndAsString = this.axis === "horizontal" ? marginInlineEnd : marginBlockEnd;
90
+ const paddingStartAsString = this.axis === "horizontal" ? paddingInlineStart : paddingBlockStart;
91
+ const paddingEndAsString = this.axis === "horizontal" ? paddingInlineEnd : paddingBlockEnd;
92
+ if (marginStartAsString && !marginStartAsString.endsWith("px"))
93
+ throw new Error("ok1");
94
+ if (marginEndAsString && !marginEndAsString.endsWith("px"))
95
+ throw new Error("ok2");
96
+ if (paddingStartAsString && !paddingStartAsString.endsWith("px"))
97
+ throw new Error("ok3");
98
+ if (paddingEndAsString && !paddingEndAsString.endsWith("px"))
99
+ throw new Error("ok4");
100
+ const marginStart = parseInt(marginStartAsString || "0", 10);
101
+ const marginEnd = parseInt(marginEndAsString || "0", 10);
102
+ const paddingStart = parseInt(paddingStartAsString || "0", 10);
103
+ const paddingEnd = parseInt(paddingEndAsString || "0", 10);
104
+ const isRtl = direction === "rtl";
105
+ return { isRtl, marginStart, marginEnd, paddingStart, paddingEnd };
106
+ }
76
107
  update() {
77
108
  if (!this.containerElement) {
78
109
  return;
79
110
  }
80
- const { direction, paddingBlockStart, paddingBlockEnd, paddingInlineStart, paddingInlineEnd } = window.getComputedStyle(this.containerElement);
81
- const offsetStart = parseInt(this.axis === "horizontal" ? paddingInlineStart : paddingBlockStart, 10);
82
- const offsetEnd = parseInt(this.axis === "horizontal" ? paddingInlineEnd : paddingBlockEnd, 10);
83
- const isRtl = direction === "rtl";
84
- const containerElementSize = this.getElementSize(this.containerElement) - offsetStart - offsetEnd;
85
- const indicatorElementSize = this.getElementSize(this.indicatorElement);
111
+ const {
112
+ isRtl,
113
+ paddingStart: containerPaddingStart,
114
+ paddingEnd: containerPaddingEnd
115
+ } = this.getElementComputedValues(this.containerElement);
116
+ const indicatorMarginEnd = this.indicatorElement ? this.getElementComputedValues(this.indicatorElement).marginEnd : 0;
117
+ const containerElementSize = this.getElementSize(this.containerElement) - containerPaddingStart - containerPaddingEnd;
118
+ const indicatorElementSize = this.getElementSize(this.indicatorElement) + indicatorMarginEnd;
86
119
  const childrenArray = Array.from(this.containerElement.children).filter((element) => element !== this.indicatorElement).filter(isHtmlElement);
87
120
  const getOffset = isRtl ? this.getElementOffsetFromRight.bind(this) : this.getElementOffsetFromLeft.bind(this);
88
121
  const breakpoints = [];
89
- for (const [_index, childElement] of childrenArray.entries()) {
122
+ for (const childElement of childrenArray.values()) {
90
123
  const childOffset = getOffset(childElement);
91
124
  const childSize = this.getElementSize(childElement);
92
- breakpoints.push([childOffset - offsetStart, childOffset + childSize + offsetEnd]);
125
+ breakpoints.push([childOffset - containerPaddingStart, childOffset + childSize + containerPaddingEnd]);
93
126
  }
94
127
  if (breakpoints.length === 0) {
95
128
  return;
@@ -100,7 +133,7 @@ var Overflowed = class {
100
133
  ([start, end]) => (this.indicatorElement ? start : end) > containerElementSize - indicatorElementSize
101
134
  );
102
135
  const newVisibleItemCount = Math.max(intersectingChildIndex - (this.indicatorElement ? 1 : 0), 0);
103
- const newIndicatorElementOffset = breakpoints[newVisibleItemCount]?.[0] + offsetStart;
136
+ const newIndicatorElementOffset = breakpoints[newVisibleItemCount]?.[0] + containerPaddingStart;
104
137
  this.onUpdate(newVisibleItemCount, newIndicatorElementOffset);
105
138
  } else {
106
139
  this.onUpdate(breakpoints.length, 0);
package/core/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { B as Breakpoint, a as Overflowed, O as OverflowedOptions } from '../Overflowed-53afb67e.js';
1
+ export { B as Breakpoint, a as Overflowed, O as OverflowedOptions } from '../Overflowed-4d9a04ab.js';
package/core/index.js CHANGED
@@ -99,23 +99,56 @@ var Overflowed = class {
99
99
  }
100
100
  return element.offsetTop;
101
101
  }
102
+ getElementComputedValues(element) {
103
+ const {
104
+ direction,
105
+ marginBlockStart,
106
+ marginBlockEnd,
107
+ marginInlineStart,
108
+ marginInlineEnd,
109
+ paddingBlockStart,
110
+ paddingBlockEnd,
111
+ paddingInlineStart,
112
+ paddingInlineEnd
113
+ } = window.getComputedStyle(element);
114
+ const marginStartAsString = this.axis === "horizontal" ? marginInlineStart : marginBlockStart;
115
+ const marginEndAsString = this.axis === "horizontal" ? marginInlineEnd : marginBlockEnd;
116
+ const paddingStartAsString = this.axis === "horizontal" ? paddingInlineStart : paddingBlockStart;
117
+ const paddingEndAsString = this.axis === "horizontal" ? paddingInlineEnd : paddingBlockEnd;
118
+ if (marginStartAsString && !marginStartAsString.endsWith("px"))
119
+ throw new Error("ok1");
120
+ if (marginEndAsString && !marginEndAsString.endsWith("px"))
121
+ throw new Error("ok2");
122
+ if (paddingStartAsString && !paddingStartAsString.endsWith("px"))
123
+ throw new Error("ok3");
124
+ if (paddingEndAsString && !paddingEndAsString.endsWith("px"))
125
+ throw new Error("ok4");
126
+ const marginStart = parseInt(marginStartAsString || "0", 10);
127
+ const marginEnd = parseInt(marginEndAsString || "0", 10);
128
+ const paddingStart = parseInt(paddingStartAsString || "0", 10);
129
+ const paddingEnd = parseInt(paddingEndAsString || "0", 10);
130
+ const isRtl = direction === "rtl";
131
+ return { isRtl, marginStart, marginEnd, paddingStart, paddingEnd };
132
+ }
102
133
  update() {
103
134
  if (!this.containerElement) {
104
135
  return;
105
136
  }
106
- const { direction, paddingBlockStart, paddingBlockEnd, paddingInlineStart, paddingInlineEnd } = window.getComputedStyle(this.containerElement);
107
- const offsetStart = parseInt(this.axis === "horizontal" ? paddingInlineStart : paddingBlockStart, 10);
108
- const offsetEnd = parseInt(this.axis === "horizontal" ? paddingInlineEnd : paddingBlockEnd, 10);
109
- const isRtl = direction === "rtl";
110
- const containerElementSize = this.getElementSize(this.containerElement) - offsetStart - offsetEnd;
111
- const indicatorElementSize = this.getElementSize(this.indicatorElement);
137
+ const {
138
+ isRtl,
139
+ paddingStart: containerPaddingStart,
140
+ paddingEnd: containerPaddingEnd
141
+ } = this.getElementComputedValues(this.containerElement);
142
+ const indicatorMarginEnd = this.indicatorElement ? this.getElementComputedValues(this.indicatorElement).marginEnd : 0;
143
+ const containerElementSize = this.getElementSize(this.containerElement) - containerPaddingStart - containerPaddingEnd;
144
+ const indicatorElementSize = this.getElementSize(this.indicatorElement) + indicatorMarginEnd;
112
145
  const childrenArray = Array.from(this.containerElement.children).filter((element) => element !== this.indicatorElement).filter(isHtmlElement);
113
146
  const getOffset = isRtl ? this.getElementOffsetFromRight.bind(this) : this.getElementOffsetFromLeft.bind(this);
114
147
  const breakpoints = [];
115
- for (const [_index, childElement] of childrenArray.entries()) {
148
+ for (const childElement of childrenArray.values()) {
116
149
  const childOffset = getOffset(childElement);
117
150
  const childSize = this.getElementSize(childElement);
118
- breakpoints.push([childOffset - offsetStart, childOffset + childSize + offsetEnd]);
151
+ breakpoints.push([childOffset - containerPaddingStart, childOffset + childSize + containerPaddingEnd]);
119
152
  }
120
153
  if (breakpoints.length === 0) {
121
154
  return;
@@ -126,7 +159,7 @@ var Overflowed = class {
126
159
  ([start, end]) => (this.indicatorElement ? start : end) > containerElementSize - indicatorElementSize
127
160
  );
128
161
  const newVisibleItemCount = Math.max(intersectingChildIndex - (this.indicatorElement ? 1 : 0), 0);
129
- const newIndicatorElementOffset = breakpoints[newVisibleItemCount]?.[0] + offsetStart;
162
+ const newIndicatorElementOffset = breakpoints[newVisibleItemCount]?.[0] + containerPaddingStart;
130
163
  this.onUpdate(newVisibleItemCount, newIndicatorElementOffset);
131
164
  } else {
132
165
  this.onUpdate(breakpoints.length, 0);
package/core/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import "../chunk-TXQIKLPR.mjs";
2
2
  import {
3
3
  Overflowed
4
- } from "../chunk-DATLJDI5.mjs";
4
+ } from "../chunk-DZKPYTOC.mjs";
5
5
  export {
6
6
  Overflowed
7
7
  };
package/index.js CHANGED
@@ -24,5 +24,8 @@ __export(modules_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(modules_exports);
26
26
  var modules_default = void 0;
27
+ throw new Error(
28
+ "You imported `overflowed` directly, instead you should import from it's subdirectories such as `overflowed/react` or `overflowed/core`. Documentation for this error is available at https://overflowed.aht.cx/errors/imported-root"
29
+ );
27
30
  // Annotate the CommonJS export names for ESM import in node:
28
31
  0 && (module.exports = {});
package/index.mjs CHANGED
@@ -1,5 +1,8 @@
1
1
  // modules/index.ts
2
2
  var modules_default = void 0;
3
+ throw new Error(
4
+ "You imported `overflowed` directly, instead you should import from it's subdirectories such as `overflowed/react` or `overflowed/core`. Documentation for this error is available at https://overflowed.aht.cx/errors/imported-root"
5
+ );
3
6
  export {
4
7
  modules_default as default
5
8
  };
package/package.json CHANGED
@@ -1,11 +1,30 @@
1
1
  {
2
2
  "name": "overflowed",
3
- "version": "0.0.0-experimental-20221120013127",
3
+ "version": "0.0.0-experimental-20230103160007",
4
+ "description": "Create toolbars with responsive overflow menus ✂️",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/ahtcx/overflowed.git"
8
+ },
4
9
  "main": "./index.js",
5
10
  "module": "./index.mjs",
6
11
  "types": "./index.d.ts",
12
+ "devDependencies": {
13
+ "@changesets/cli": "2.26.0",
14
+ "@types/node": "18.11.18",
15
+ "@types/react": "18.0.26",
16
+ "@types/react-dom": "18.0.10",
17
+ "preact": "10.11.3",
18
+ "react": "18.2.0",
19
+ "react-dom": "18.2.0",
20
+ "rome": "11.0.0",
21
+ "svelte": "3.55.0",
22
+ "tsup": "6.5.0",
23
+ "typescript": "4.9.4"
24
+ },
7
25
  "peerDependencies": {
8
26
  "@types/react": "^17.0.0 || ^18.0.0",
27
+ "preact": "^10.0.0",
9
28
  "react": "^17.0.0 || ^18.0.0",
10
29
  "svelte": "^3.0.0"
11
30
  },
@@ -13,11 +32,18 @@
13
32
  "@types/react": {
14
33
  "optional": true
15
34
  },
35
+ "preact": {
36
+ "optional": true
37
+ },
16
38
  "react": {
17
39
  "optional": true
18
40
  },
19
41
  "svelte": {
20
42
  "optional": true
21
43
  }
44
+ },
45
+ "scripts": {
46
+ "build": "tsup",
47
+ "dev": "pnpm --recursive dev"
22
48
  }
23
49
  }
package/react/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { O as OverflowedOptions } from '../Overflowed-53afb67e.js';
1
+ import { O as OverflowedOptions } from '../Overflowed-4d9a04ab.js';
2
2
 
3
3
  interface UseOverflowedItemsState {
4
4
  visibleItemCount: number;
package/react/index.js CHANGED
@@ -102,23 +102,56 @@ var Overflowed = class {
102
102
  }
103
103
  return element.offsetTop;
104
104
  }
105
+ getElementComputedValues(element) {
106
+ const {
107
+ direction,
108
+ marginBlockStart,
109
+ marginBlockEnd,
110
+ marginInlineStart,
111
+ marginInlineEnd,
112
+ paddingBlockStart,
113
+ paddingBlockEnd,
114
+ paddingInlineStart,
115
+ paddingInlineEnd
116
+ } = window.getComputedStyle(element);
117
+ const marginStartAsString = this.axis === "horizontal" ? marginInlineStart : marginBlockStart;
118
+ const marginEndAsString = this.axis === "horizontal" ? marginInlineEnd : marginBlockEnd;
119
+ const paddingStartAsString = this.axis === "horizontal" ? paddingInlineStart : paddingBlockStart;
120
+ const paddingEndAsString = this.axis === "horizontal" ? paddingInlineEnd : paddingBlockEnd;
121
+ if (marginStartAsString && !marginStartAsString.endsWith("px"))
122
+ throw new Error("ok1");
123
+ if (marginEndAsString && !marginEndAsString.endsWith("px"))
124
+ throw new Error("ok2");
125
+ if (paddingStartAsString && !paddingStartAsString.endsWith("px"))
126
+ throw new Error("ok3");
127
+ if (paddingEndAsString && !paddingEndAsString.endsWith("px"))
128
+ throw new Error("ok4");
129
+ const marginStart = parseInt(marginStartAsString || "0", 10);
130
+ const marginEnd = parseInt(marginEndAsString || "0", 10);
131
+ const paddingStart = parseInt(paddingStartAsString || "0", 10);
132
+ const paddingEnd = parseInt(paddingEndAsString || "0", 10);
133
+ const isRtl = direction === "rtl";
134
+ return { isRtl, marginStart, marginEnd, paddingStart, paddingEnd };
135
+ }
105
136
  update() {
106
137
  if (!this.containerElement) {
107
138
  return;
108
139
  }
109
- const { direction, paddingBlockStart, paddingBlockEnd, paddingInlineStart, paddingInlineEnd } = window.getComputedStyle(this.containerElement);
110
- const offsetStart = parseInt(this.axis === "horizontal" ? paddingInlineStart : paddingBlockStart, 10);
111
- const offsetEnd = parseInt(this.axis === "horizontal" ? paddingInlineEnd : paddingBlockEnd, 10);
112
- const isRtl = direction === "rtl";
113
- const containerElementSize = this.getElementSize(this.containerElement) - offsetStart - offsetEnd;
114
- const indicatorElementSize = this.getElementSize(this.indicatorElement);
140
+ const {
141
+ isRtl,
142
+ paddingStart: containerPaddingStart,
143
+ paddingEnd: containerPaddingEnd
144
+ } = this.getElementComputedValues(this.containerElement);
145
+ const indicatorMarginEnd = this.indicatorElement ? this.getElementComputedValues(this.indicatorElement).marginEnd : 0;
146
+ const containerElementSize = this.getElementSize(this.containerElement) - containerPaddingStart - containerPaddingEnd;
147
+ const indicatorElementSize = this.getElementSize(this.indicatorElement) + indicatorMarginEnd;
115
148
  const childrenArray = Array.from(this.containerElement.children).filter((element) => element !== this.indicatorElement).filter(isHtmlElement);
116
149
  const getOffset = isRtl ? this.getElementOffsetFromRight.bind(this) : this.getElementOffsetFromLeft.bind(this);
117
150
  const breakpoints = [];
118
- for (const [_index, childElement] of childrenArray.entries()) {
151
+ for (const childElement of childrenArray.values()) {
119
152
  const childOffset = getOffset(childElement);
120
153
  const childSize = this.getElementSize(childElement);
121
- breakpoints.push([childOffset - offsetStart, childOffset + childSize + offsetEnd]);
154
+ breakpoints.push([childOffset - containerPaddingStart, childOffset + childSize + containerPaddingEnd]);
122
155
  }
123
156
  if (breakpoints.length === 0) {
124
157
  return;
@@ -129,7 +162,7 @@ var Overflowed = class {
129
162
  ([start, end]) => (this.indicatorElement ? start : end) > containerElementSize - indicatorElementSize
130
163
  );
131
164
  const newVisibleItemCount = Math.max(intersectingChildIndex - (this.indicatorElement ? 1 : 0), 0);
132
- const newIndicatorElementOffset = breakpoints[newVisibleItemCount]?.[0] + offsetStart;
165
+ const newIndicatorElementOffset = breakpoints[newVisibleItemCount]?.[0] + containerPaddingStart;
133
166
  this.onUpdate(newVisibleItemCount, newIndicatorElementOffset);
134
167
  } else {
135
168
  this.onUpdate(breakpoints.length, 0);
@@ -165,6 +198,7 @@ var defaultCreateGetContainerProps = (overflowed, state) => ({ style } = {}) =>
165
198
  style: {
166
199
  overflowX: overflowed.axis === "horizontal" ? state.isMounted ? "clip" : "auto" : void 0,
167
200
  overflowY: overflowed.axis === "horizontal" ? state.isMounted ? "clip" : "auto" : void 0,
201
+ position: "relative",
168
202
  ...style
169
203
  }
170
204
  });
@@ -177,15 +211,14 @@ var defaultCreateGetIndicatorProps = (overflowed, state, isVisible) => ({ style
177
211
  }
178
212
  overflowed.registerIndicatorElement(indicatorElement);
179
213
  },
180
- style: isVisible ? {
181
- position: isVisible ? "absolute" : void 0,
182
- insetInlineStart: isVisible ? state.indicatorElementOffset : void 0,
214
+ style: {
215
+ position: "absolute",
183
216
  marginInlineStart: 0,
217
+ insetInlineStart: isVisible ? state.indicatorElementOffset : 0,
218
+ userSelect: isVisible ? void 0 : "none",
219
+ pointerEvents: isVisible ? void 0 : "none",
220
+ visibility: isVisible ? void 0 : "hidden",
184
221
  ...style
185
- } : {
186
- userSelect: "none",
187
- pointerEvents: "none",
188
- visibility: "hidden"
189
222
  }
190
223
  });
191
224
 
package/react/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Overflowed
3
- } from "../chunk-DATLJDI5.mjs";
3
+ } from "../chunk-DZKPYTOC.mjs";
4
4
 
5
5
  // modules/react/useOverflowedItems.tsx
6
6
  import { useEffect, useMemo, useRef, useState } from "react";
@@ -16,6 +16,7 @@ var defaultCreateGetContainerProps = (overflowed, state) => ({ style } = {}) =>
16
16
  style: {
17
17
  overflowX: overflowed.axis === "horizontal" ? state.isMounted ? "clip" : "auto" : void 0,
18
18
  overflowY: overflowed.axis === "horizontal" ? state.isMounted ? "clip" : "auto" : void 0,
19
+ position: "relative",
19
20
  ...style
20
21
  }
21
22
  });
@@ -28,15 +29,14 @@ var defaultCreateGetIndicatorProps = (overflowed, state, isVisible) => ({ style
28
29
  }
29
30
  overflowed.registerIndicatorElement(indicatorElement);
30
31
  },
31
- style: isVisible ? {
32
- position: isVisible ? "absolute" : void 0,
33
- insetInlineStart: isVisible ? state.indicatorElementOffset : void 0,
32
+ style: {
33
+ position: "absolute",
34
34
  marginInlineStart: 0,
35
+ insetInlineStart: isVisible ? state.indicatorElementOffset : 0,
36
+ userSelect: isVisible ? void 0 : "none",
37
+ pointerEvents: isVisible ? void 0 : "none",
38
+ visibility: isVisible ? void 0 : "hidden",
35
39
  ...style
36
- } : {
37
- userSelect: "none",
38
- pointerEvents: "none",
39
- visibility: "hidden"
40
40
  }
41
41
  });
42
42
 
package/svelte/index.js CHANGED
@@ -99,23 +99,56 @@ var Overflowed = class {
99
99
  }
100
100
  return element.offsetTop;
101
101
  }
102
+ getElementComputedValues(element) {
103
+ const {
104
+ direction,
105
+ marginBlockStart,
106
+ marginBlockEnd,
107
+ marginInlineStart,
108
+ marginInlineEnd,
109
+ paddingBlockStart,
110
+ paddingBlockEnd,
111
+ paddingInlineStart,
112
+ paddingInlineEnd
113
+ } = window.getComputedStyle(element);
114
+ const marginStartAsString = this.axis === "horizontal" ? marginInlineStart : marginBlockStart;
115
+ const marginEndAsString = this.axis === "horizontal" ? marginInlineEnd : marginBlockEnd;
116
+ const paddingStartAsString = this.axis === "horizontal" ? paddingInlineStart : paddingBlockStart;
117
+ const paddingEndAsString = this.axis === "horizontal" ? paddingInlineEnd : paddingBlockEnd;
118
+ if (marginStartAsString && !marginStartAsString.endsWith("px"))
119
+ throw new Error("ok1");
120
+ if (marginEndAsString && !marginEndAsString.endsWith("px"))
121
+ throw new Error("ok2");
122
+ if (paddingStartAsString && !paddingStartAsString.endsWith("px"))
123
+ throw new Error("ok3");
124
+ if (paddingEndAsString && !paddingEndAsString.endsWith("px"))
125
+ throw new Error("ok4");
126
+ const marginStart = parseInt(marginStartAsString || "0", 10);
127
+ const marginEnd = parseInt(marginEndAsString || "0", 10);
128
+ const paddingStart = parseInt(paddingStartAsString || "0", 10);
129
+ const paddingEnd = parseInt(paddingEndAsString || "0", 10);
130
+ const isRtl = direction === "rtl";
131
+ return { isRtl, marginStart, marginEnd, paddingStart, paddingEnd };
132
+ }
102
133
  update() {
103
134
  if (!this.containerElement) {
104
135
  return;
105
136
  }
106
- const { direction, paddingBlockStart, paddingBlockEnd, paddingInlineStart, paddingInlineEnd } = window.getComputedStyle(this.containerElement);
107
- const offsetStart = parseInt(this.axis === "horizontal" ? paddingInlineStart : paddingBlockStart, 10);
108
- const offsetEnd = parseInt(this.axis === "horizontal" ? paddingInlineEnd : paddingBlockEnd, 10);
109
- const isRtl = direction === "rtl";
110
- const containerElementSize = this.getElementSize(this.containerElement) - offsetStart - offsetEnd;
111
- const indicatorElementSize = this.getElementSize(this.indicatorElement);
137
+ const {
138
+ isRtl,
139
+ paddingStart: containerPaddingStart,
140
+ paddingEnd: containerPaddingEnd
141
+ } = this.getElementComputedValues(this.containerElement);
142
+ const indicatorMarginEnd = this.indicatorElement ? this.getElementComputedValues(this.indicatorElement).marginEnd : 0;
143
+ const containerElementSize = this.getElementSize(this.containerElement) - containerPaddingStart - containerPaddingEnd;
144
+ const indicatorElementSize = this.getElementSize(this.indicatorElement) + indicatorMarginEnd;
112
145
  const childrenArray = Array.from(this.containerElement.children).filter((element) => element !== this.indicatorElement).filter(isHtmlElement);
113
146
  const getOffset = isRtl ? this.getElementOffsetFromRight.bind(this) : this.getElementOffsetFromLeft.bind(this);
114
147
  const breakpoints = [];
115
- for (const [_index, childElement] of childrenArray.entries()) {
148
+ for (const childElement of childrenArray.values()) {
116
149
  const childOffset = getOffset(childElement);
117
150
  const childSize = this.getElementSize(childElement);
118
- breakpoints.push([childOffset - offsetStart, childOffset + childSize + offsetEnd]);
151
+ breakpoints.push([childOffset - containerPaddingStart, childOffset + childSize + containerPaddingEnd]);
119
152
  }
120
153
  if (breakpoints.length === 0) {
121
154
  return;
@@ -126,7 +159,7 @@ var Overflowed = class {
126
159
  ([start, end]) => (this.indicatorElement ? start : end) > containerElementSize - indicatorElementSize
127
160
  );
128
161
  const newVisibleItemCount = Math.max(intersectingChildIndex - (this.indicatorElement ? 1 : 0), 0);
129
- const newIndicatorElementOffset = breakpoints[newVisibleItemCount]?.[0] + offsetStart;
162
+ const newIndicatorElementOffset = breakpoints[newVisibleItemCount]?.[0] + containerPaddingStart;
130
163
  this.onUpdate(newVisibleItemCount, newIndicatorElementOffset);
131
164
  } else {
132
165
  this.onUpdate(breakpoints.length, 0);
@@ -151,7 +184,7 @@ var isHtmlElement = (element) => {
151
184
  throw new Error("Element provided is not a HTMLElement.");
152
185
  };
153
186
 
154
- // modules/svelte/OverflowedActions.ts
187
+ // modules/svelte/overflowedItems.ts
155
188
  var overflowedItems = (items, onUpdate) => {
156
189
  const overflowed = new Overflowed({
157
190
  onUpdate: (newVisibleItemCount, indicatorElementOffset) => {
package/svelte/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import "../chunk-TXQIKLPR.mjs";
2
2
  import {
3
3
  Overflowed
4
- } from "../chunk-DATLJDI5.mjs";
4
+ } from "../chunk-DZKPYTOC.mjs";
5
5
 
6
- // modules/svelte/OverflowedActions.ts
6
+ // modules/svelte/overflowedItems.ts
7
7
  var overflowedItems = (items, onUpdate) => {
8
8
  const overflowed = new Overflowed({
9
9
  onUpdate: (newVisibleItemCount, indicatorElementOffset) => {