overflowed 0.0.0-experimental-20230103160007 → 0.0.0-experimental-20260129225612
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/box-mirror/HTMLBoxMirror.css +15 -0
- package/box-mirror/HTMLBoxMirror.ts +99 -0
- package/content-mirror/HTMLContentMirror.css +3 -0
- package/content-mirror/HTMLContentMirror.ts +43 -0
- package/dist/mod.d.ts +54 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +189 -0
- package/dist/mod.js.map +1 -0
- package/mod.ts +2 -0
- package/overflow-container/HTMLOverflowContainerElement.css +42 -0
- package/overflow-container/HTMLOverflowContainerElement.ts +171 -0
- package/overflow-container/HTMLOverflowContainerEvent.ts +11 -0
- package/package.json +9 -48
- package/LICENSE.md +0 -21
- package/Overflowed-4d9a04ab.d.ts +0 -30
- package/README.md +0 -50
- package/chunk-DZKPYTOC.mjs +0 -163
- package/chunk-TXQIKLPR.mjs +0 -0
- package/core/index.d.ts +0 -1
- package/core/index.js +0 -189
- package/core/index.mjs +0 -7
- package/index.d.ts +0 -4
- package/index.js +0 -31
- package/index.mjs +0 -8
- package/react/index.d.ts +0 -17
- package/react/index.js +0 -291
- package/react/index.mjs +0 -108
- package/svelte/index.d.ts +0 -9
- package/svelte/index.js +0 -216
- package/svelte/index.mjs +0 -34
package/package.json
CHANGED
|
@@ -1,49 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
},
|
|
25
|
-
"peerDependencies": {
|
|
26
|
-
"@types/react": "^17.0.0 || ^18.0.0",
|
|
27
|
-
"preact": "^10.0.0",
|
|
28
|
-
"react": "^17.0.0 || ^18.0.0",
|
|
29
|
-
"svelte": "^3.0.0"
|
|
30
|
-
},
|
|
31
|
-
"peerDependenciesMeta": {
|
|
32
|
-
"@types/react": {
|
|
33
|
-
"optional": true
|
|
34
|
-
},
|
|
35
|
-
"preact": {
|
|
36
|
-
"optional": true
|
|
37
|
-
},
|
|
38
|
-
"react": {
|
|
39
|
-
"optional": true
|
|
40
|
-
},
|
|
41
|
-
"svelte": {
|
|
42
|
-
"optional": true
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
"scripts": {
|
|
46
|
-
"build": "tsup",
|
|
47
|
-
"dev": "pnpm --recursive dev"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
2
|
+
"name": "overflowed",
|
|
3
|
+
"version": "0.0.0-experimental-20260129225612",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/mod.js",
|
|
8
|
+
"./package.json": "./package.json"
|
|
9
|
+
}
|
|
10
|
+
}
|
package/LICENSE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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.
|
package/Overflowed-4d9a04ab.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
interface OverflowedOptions {
|
|
2
|
-
axis?: "horizontal" | "vertical";
|
|
3
|
-
onUpdate: (visibleItemCount: number, indicatorElementOffset: number) => void;
|
|
4
|
-
disableIndicatorResizeProtection?: boolean;
|
|
5
|
-
ResizeObserver?: typeof ResizeObserver;
|
|
6
|
-
}
|
|
7
|
-
type Breakpoint = [lowerBound: number, upperBound: number];
|
|
8
|
-
declare class Overflowed {
|
|
9
|
-
readonly axis: "horizontal" | "vertical";
|
|
10
|
-
private onUpdate;
|
|
11
|
-
private resizeObserver;
|
|
12
|
-
private containerElement;
|
|
13
|
-
private indicatorElement;
|
|
14
|
-
private indicatorSize?;
|
|
15
|
-
constructor({ ResizeObserver, axis, onUpdate, }: OverflowedOptions);
|
|
16
|
-
registerContainerElement(containerElement: HTMLElement): void;
|
|
17
|
-
registerIndicatorElement(indicatorElement: HTMLElement): void;
|
|
18
|
-
registerItemElement(itemElement: HTMLElement): void;
|
|
19
|
-
/** Should be called before the container element is unmounted. */
|
|
20
|
-
onContainerElementWillUnmount(): void;
|
|
21
|
-
private getElementSize;
|
|
22
|
-
private getElementOffsetFromRight;
|
|
23
|
-
private getElementOffsetFromLeft;
|
|
24
|
-
private getElementComputedValues;
|
|
25
|
-
private update;
|
|
26
|
-
private requestedUpdate;
|
|
27
|
-
requestUpdate(): void;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { Breakpoint as B, OverflowedOptions as O, Overflowed as a };
|
package/README.md
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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.
|
package/chunk-DZKPYTOC.mjs
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
// modules/core/Overflowed.ts
|
|
2
|
-
var Overflowed = class {
|
|
3
|
-
axis;
|
|
4
|
-
onUpdate;
|
|
5
|
-
resizeObserver;
|
|
6
|
-
containerElement = null;
|
|
7
|
-
indicatorElement = null;
|
|
8
|
-
indicatorSize;
|
|
9
|
-
constructor({
|
|
10
|
-
ResizeObserver = typeof window === "undefined" ? void 0 : window.ResizeObserver,
|
|
11
|
-
axis = "horizontal",
|
|
12
|
-
onUpdate
|
|
13
|
-
}) {
|
|
14
|
-
this.resizeObserver = ResizeObserver && new ResizeObserver((entries) => {
|
|
15
|
-
for (const entry of entries) {
|
|
16
|
-
if (entry.target === this.indicatorElement) {
|
|
17
|
-
if (entry.target.clientWidth > 0 && entry.target.clientWidth !== this.indicatorSize) {
|
|
18
|
-
console.warn("width doesn't match", this.indicatorSize, entry.target.clientWidth);
|
|
19
|
-
}
|
|
20
|
-
this.indicatorSize = entry.target.clientWidth;
|
|
21
|
-
} else if (entry.target.parentNode === this.containerElement) {
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
this.requestUpdate();
|
|
25
|
-
});
|
|
26
|
-
this.axis = axis;
|
|
27
|
-
this.onUpdate = onUpdate;
|
|
28
|
-
}
|
|
29
|
-
registerContainerElement(containerElement) {
|
|
30
|
-
this.containerElement = containerElement;
|
|
31
|
-
this.resizeObserver?.observe(containerElement);
|
|
32
|
-
this.requestUpdate();
|
|
33
|
-
}
|
|
34
|
-
registerIndicatorElement(indicatorElement) {
|
|
35
|
-
this.indicatorElement = indicatorElement;
|
|
36
|
-
this.indicatorSize = indicatorElement.clientWidth;
|
|
37
|
-
this.resizeObserver?.observe(indicatorElement);
|
|
38
|
-
this.requestUpdate();
|
|
39
|
-
}
|
|
40
|
-
registerItemElement(itemElement) {
|
|
41
|
-
this.resizeObserver?.observe(itemElement);
|
|
42
|
-
this.requestUpdate();
|
|
43
|
-
}
|
|
44
|
-
onContainerElementWillUnmount() {
|
|
45
|
-
this.resizeObserver?.disconnect();
|
|
46
|
-
this.containerElement = null;
|
|
47
|
-
this.indicatorElement = null;
|
|
48
|
-
}
|
|
49
|
-
getElementSize(element) {
|
|
50
|
-
if (!element) {
|
|
51
|
-
return 0;
|
|
52
|
-
}
|
|
53
|
-
if (this.axis === "horizontal") {
|
|
54
|
-
return element.offsetWidth;
|
|
55
|
-
}
|
|
56
|
-
return element.offsetHeight;
|
|
57
|
-
}
|
|
58
|
-
getElementOffsetFromRight(element) {
|
|
59
|
-
if (!element) {
|
|
60
|
-
return 0;
|
|
61
|
-
}
|
|
62
|
-
if (this.axis === "horizontal") {
|
|
63
|
-
return this.getElementSize(element.parentElement) - this.getElementSize(element) - element.offsetLeft;
|
|
64
|
-
}
|
|
65
|
-
return this.getElementSize(element.parentElement) - this.getElementSize(element) - element.offsetTop;
|
|
66
|
-
}
|
|
67
|
-
getElementOffsetFromLeft(element) {
|
|
68
|
-
if (!element) {
|
|
69
|
-
return 0;
|
|
70
|
-
}
|
|
71
|
-
if (this.axis === "horizontal") {
|
|
72
|
-
return element.offsetLeft;
|
|
73
|
-
}
|
|
74
|
-
return element.offsetTop;
|
|
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
|
-
}
|
|
107
|
-
update() {
|
|
108
|
-
if (!this.containerElement) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
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;
|
|
119
|
-
const childrenArray = Array.from(this.containerElement.children).filter((element) => element !== this.indicatorElement).filter(isHtmlElement);
|
|
120
|
-
const getOffset = isRtl ? this.getElementOffsetFromRight.bind(this) : this.getElementOffsetFromLeft.bind(this);
|
|
121
|
-
const breakpoints = [];
|
|
122
|
-
for (const childElement of childrenArray.values()) {
|
|
123
|
-
const childOffset = getOffset(childElement);
|
|
124
|
-
const childSize = this.getElementSize(childElement);
|
|
125
|
-
breakpoints.push([childOffset - containerPaddingStart, childOffset + childSize + containerPaddingEnd]);
|
|
126
|
-
}
|
|
127
|
-
if (breakpoints.length === 0) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
const containerIntersectingChildIndex = breakpoints.findIndex(([_start, end]) => end > containerElementSize);
|
|
131
|
-
if (containerIntersectingChildIndex !== -1) {
|
|
132
|
-
const intersectingChildIndex = breakpoints.findIndex(
|
|
133
|
-
([start, end]) => (this.indicatorElement ? start : end) > containerElementSize - indicatorElementSize
|
|
134
|
-
);
|
|
135
|
-
const newVisibleItemCount = Math.max(intersectingChildIndex - (this.indicatorElement ? 1 : 0), 0);
|
|
136
|
-
const newIndicatorElementOffset = breakpoints[newVisibleItemCount]?.[0] + containerPaddingStart;
|
|
137
|
-
this.onUpdate(newVisibleItemCount, newIndicatorElementOffset);
|
|
138
|
-
} else {
|
|
139
|
-
this.onUpdate(breakpoints.length, 0);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
requestedUpdate = false;
|
|
143
|
-
requestUpdate() {
|
|
144
|
-
if (this.requestedUpdate) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
this.requestedUpdate = true;
|
|
148
|
-
this.update();
|
|
149
|
-
window.requestAnimationFrame(() => {
|
|
150
|
-
this.requestedUpdate = false;
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
var isHtmlElement = (element) => {
|
|
155
|
-
if (element instanceof HTMLElement) {
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
throw new Error("Element provided is not a HTMLElement.");
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
export {
|
|
162
|
-
Overflowed
|
|
163
|
-
};
|
package/chunk-TXQIKLPR.mjs
DELETED
|
File without changes
|
package/core/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { B as Breakpoint, a as Overflowed, O as OverflowedOptions } from '../Overflowed-4d9a04ab.js';
|
package/core/index.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// modules/core/index.ts
|
|
21
|
-
var core_exports = {};
|
|
22
|
-
__export(core_exports, {
|
|
23
|
-
Overflowed: () => Overflowed
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(core_exports);
|
|
26
|
-
|
|
27
|
-
// modules/core/Overflowed.ts
|
|
28
|
-
var Overflowed = class {
|
|
29
|
-
axis;
|
|
30
|
-
onUpdate;
|
|
31
|
-
resizeObserver;
|
|
32
|
-
containerElement = null;
|
|
33
|
-
indicatorElement = null;
|
|
34
|
-
indicatorSize;
|
|
35
|
-
constructor({
|
|
36
|
-
ResizeObserver = typeof window === "undefined" ? void 0 : window.ResizeObserver,
|
|
37
|
-
axis = "horizontal",
|
|
38
|
-
onUpdate
|
|
39
|
-
}) {
|
|
40
|
-
this.resizeObserver = ResizeObserver && new ResizeObserver((entries) => {
|
|
41
|
-
for (const entry of entries) {
|
|
42
|
-
if (entry.target === this.indicatorElement) {
|
|
43
|
-
if (entry.target.clientWidth > 0 && entry.target.clientWidth !== this.indicatorSize) {
|
|
44
|
-
console.warn("width doesn't match", this.indicatorSize, entry.target.clientWidth);
|
|
45
|
-
}
|
|
46
|
-
this.indicatorSize = entry.target.clientWidth;
|
|
47
|
-
} else if (entry.target.parentNode === this.containerElement) {
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
this.requestUpdate();
|
|
51
|
-
});
|
|
52
|
-
this.axis = axis;
|
|
53
|
-
this.onUpdate = onUpdate;
|
|
54
|
-
}
|
|
55
|
-
registerContainerElement(containerElement) {
|
|
56
|
-
this.containerElement = containerElement;
|
|
57
|
-
this.resizeObserver?.observe(containerElement);
|
|
58
|
-
this.requestUpdate();
|
|
59
|
-
}
|
|
60
|
-
registerIndicatorElement(indicatorElement) {
|
|
61
|
-
this.indicatorElement = indicatorElement;
|
|
62
|
-
this.indicatorSize = indicatorElement.clientWidth;
|
|
63
|
-
this.resizeObserver?.observe(indicatorElement);
|
|
64
|
-
this.requestUpdate();
|
|
65
|
-
}
|
|
66
|
-
registerItemElement(itemElement) {
|
|
67
|
-
this.resizeObserver?.observe(itemElement);
|
|
68
|
-
this.requestUpdate();
|
|
69
|
-
}
|
|
70
|
-
onContainerElementWillUnmount() {
|
|
71
|
-
this.resizeObserver?.disconnect();
|
|
72
|
-
this.containerElement = null;
|
|
73
|
-
this.indicatorElement = null;
|
|
74
|
-
}
|
|
75
|
-
getElementSize(element) {
|
|
76
|
-
if (!element) {
|
|
77
|
-
return 0;
|
|
78
|
-
}
|
|
79
|
-
if (this.axis === "horizontal") {
|
|
80
|
-
return element.offsetWidth;
|
|
81
|
-
}
|
|
82
|
-
return element.offsetHeight;
|
|
83
|
-
}
|
|
84
|
-
getElementOffsetFromRight(element) {
|
|
85
|
-
if (!element) {
|
|
86
|
-
return 0;
|
|
87
|
-
}
|
|
88
|
-
if (this.axis === "horizontal") {
|
|
89
|
-
return this.getElementSize(element.parentElement) - this.getElementSize(element) - element.offsetLeft;
|
|
90
|
-
}
|
|
91
|
-
return this.getElementSize(element.parentElement) - this.getElementSize(element) - element.offsetTop;
|
|
92
|
-
}
|
|
93
|
-
getElementOffsetFromLeft(element) {
|
|
94
|
-
if (!element) {
|
|
95
|
-
return 0;
|
|
96
|
-
}
|
|
97
|
-
if (this.axis === "horizontal") {
|
|
98
|
-
return element.offsetLeft;
|
|
99
|
-
}
|
|
100
|
-
return element.offsetTop;
|
|
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
|
-
}
|
|
133
|
-
update() {
|
|
134
|
-
if (!this.containerElement) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
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;
|
|
145
|
-
const childrenArray = Array.from(this.containerElement.children).filter((element) => element !== this.indicatorElement).filter(isHtmlElement);
|
|
146
|
-
const getOffset = isRtl ? this.getElementOffsetFromRight.bind(this) : this.getElementOffsetFromLeft.bind(this);
|
|
147
|
-
const breakpoints = [];
|
|
148
|
-
for (const childElement of childrenArray.values()) {
|
|
149
|
-
const childOffset = getOffset(childElement);
|
|
150
|
-
const childSize = this.getElementSize(childElement);
|
|
151
|
-
breakpoints.push([childOffset - containerPaddingStart, childOffset + childSize + containerPaddingEnd]);
|
|
152
|
-
}
|
|
153
|
-
if (breakpoints.length === 0) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
const containerIntersectingChildIndex = breakpoints.findIndex(([_start, end]) => end > containerElementSize);
|
|
157
|
-
if (containerIntersectingChildIndex !== -1) {
|
|
158
|
-
const intersectingChildIndex = breakpoints.findIndex(
|
|
159
|
-
([start, end]) => (this.indicatorElement ? start : end) > containerElementSize - indicatorElementSize
|
|
160
|
-
);
|
|
161
|
-
const newVisibleItemCount = Math.max(intersectingChildIndex - (this.indicatorElement ? 1 : 0), 0);
|
|
162
|
-
const newIndicatorElementOffset = breakpoints[newVisibleItemCount]?.[0] + containerPaddingStart;
|
|
163
|
-
this.onUpdate(newVisibleItemCount, newIndicatorElementOffset);
|
|
164
|
-
} else {
|
|
165
|
-
this.onUpdate(breakpoints.length, 0);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
requestedUpdate = false;
|
|
169
|
-
requestUpdate() {
|
|
170
|
-
if (this.requestedUpdate) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
this.requestedUpdate = true;
|
|
174
|
-
this.update();
|
|
175
|
-
window.requestAnimationFrame(() => {
|
|
176
|
-
this.requestedUpdate = false;
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
var isHtmlElement = (element) => {
|
|
181
|
-
if (element instanceof HTMLElement) {
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
throw new Error("Element provided is not a HTMLElement.");
|
|
185
|
-
};
|
|
186
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
187
|
-
0 && (module.exports = {
|
|
188
|
-
Overflowed
|
|
189
|
-
});
|
package/core/index.mjs
DELETED
package/index.d.ts
DELETED
package/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// modules/index.ts
|
|
21
|
-
var modules_exports = {};
|
|
22
|
-
__export(modules_exports, {
|
|
23
|
-
default: () => modules_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(modules_exports);
|
|
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
|
-
);
|
|
30
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
-
0 && (module.exports = {});
|
package/index.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// modules/index.ts
|
|
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
|
-
);
|
|
6
|
-
export {
|
|
7
|
-
modules_default as default
|
|
8
|
-
};
|
package/react/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { O as OverflowedOptions } from '../Overflowed-4d9a04ab.js';
|
|
2
|
-
|
|
3
|
-
interface UseOverflowedItemsState {
|
|
4
|
-
visibleItemCount: number;
|
|
5
|
-
indicatorElementOffset: number | undefined;
|
|
6
|
-
isMounted: boolean;
|
|
7
|
-
}
|
|
8
|
-
interface UseOverflowedItemsOptions extends Omit<OverflowedOptions, "onUpdate"> {
|
|
9
|
-
enableEmptyOverflowedItems?: boolean;
|
|
10
|
-
maxItemCount?: number;
|
|
11
|
-
}
|
|
12
|
-
declare const useOverflowedItems: <Item extends unknown>(items: Item[], { enableEmptyOverflowedItems, maxItemCount, ...options }?: UseOverflowedItemsOptions) => readonly [(readonly [Item, any])[], Item[], {
|
|
13
|
-
getContainerProps: any;
|
|
14
|
-
getIndicatorProps: any;
|
|
15
|
-
}];
|
|
16
|
-
|
|
17
|
-
export { UseOverflowedItemsOptions, UseOverflowedItemsState, useOverflowedItems };
|