tosijs-ui 1.6.11 → 1.6.12
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/CHANGELOG.md +37 -0
- package/dist/float.js +33 -22
- package/dist/iife.js +89 -89
- package/dist/iife.js.map +6 -6
- package/dist/menu.js +32 -15
- package/dist/tooltip.js +14 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/llms.txt +1 -1
- package/package.json +37 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.6.12
|
|
4
|
+
|
|
5
|
+
Packaging improvements for independent, tree-shakeable consumption. All changes
|
|
6
|
+
are **additive — no breaking changes**; one minor behavioral edge case is noted
|
|
7
|
+
below.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **Subpath exports**, so an app can import only what it needs without the barrel
|
|
12
|
+
dragging in dev tools:
|
|
13
|
+
- curated: `tosijs-ui/icons`, `tosijs-ui/code-editor`, `tosijs-ui/live-example`,
|
|
14
|
+
`tosijs-ui/doc-browser`, `tosijs-ui/diff`, `tosijs-ui/theme`
|
|
15
|
+
- per-component wildcard: `import { tosiRating } from 'tosijs-ui/rating'`
|
|
16
|
+
(resolves `dist/rating.js`, registering just that element)
|
|
17
|
+
|
|
18
|
+
The full barrel `import 'tosijs-ui'` is unchanged and still registers every
|
|
19
|
+
`<tosi-*>` element.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- **`menu`, `tooltip`, and `float` now inject their stylesheet and register their
|
|
24
|
+
global listeners on first use, not at import.** Importing these modules (or the
|
|
25
|
+
barrel) no longer has import-time side effects. This also fixes a latent bug
|
|
26
|
+
where the menu `keydown` handler attached to `document.body` at import time,
|
|
27
|
+
which may not exist yet.
|
|
28
|
+
|
|
29
|
+
### Possible edge case
|
|
30
|
+
|
|
31
|
+
If you imported `menu` / `tooltip` / `float` **purely for the side effect** — i.e.
|
|
32
|
+
you hand-author markup with the internal classes (`.tosi-menu`, `.tosi-tooltip`,
|
|
33
|
+
…) and relied on a bare `import` injecting the stylesheet, **without** ever
|
|
34
|
+
calling the API (`popMenu`, `popDropMenu`, `initTooltips`, `showTooltip`) or using
|
|
35
|
+
the `<tosi-*>` element — those styles now apply only once the API/element is first
|
|
36
|
+
used. Normal usage (the element creators, the `<tosi-*>` elements, and the
|
|
37
|
+
`popMenu`/`initTooltips` entry points) is unaffected.
|
package/dist/float.js
CHANGED
|
@@ -131,6 +131,7 @@ export class TosiFloat extends WebComponent {
|
|
|
131
131
|
};
|
|
132
132
|
connectedCallback() {
|
|
133
133
|
super.connectedCallback();
|
|
134
|
+
ensureFloatListeners();
|
|
134
135
|
TosiFloat.floats.add(this);
|
|
135
136
|
const PASSIVE = { passive: true };
|
|
136
137
|
this.addEventListener('touchstart', this.reposition, PASSIVE);
|
|
@@ -147,27 +148,37 @@ export const XinFloat = TosiFloat;
|
|
|
147
148
|
export const tosiFloat = TosiFloat.elementCreator();
|
|
148
149
|
/** @deprecated Use tosiFloat instead */
|
|
149
150
|
export const xinFloat = tosiFloat;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}, { passive: true });
|
|
160
|
-
document.addEventListener('scroll', (event) => {
|
|
161
|
-
if (event.target instanceof HTMLElement &&
|
|
162
|
-
event.target.closest(TosiFloat.tagName)) {
|
|
151
|
+
// Register the global reposition/dismiss handlers on first float connecting,
|
|
152
|
+
// not at import (keeps the module side-effect-free for tree-shaking). They
|
|
153
|
+
// iterate TosiFloat.floats, so they're no-ops until a float exists — registered
|
|
154
|
+
// once, no teardown needed.
|
|
155
|
+
let floatListenersRegistered = false;
|
|
156
|
+
function ensureFloatListeners() {
|
|
157
|
+
if (floatListenersRegistered)
|
|
163
158
|
return;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
float.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
float.remove
|
|
159
|
+
floatListenersRegistered = true;
|
|
160
|
+
window.addEventListener('resize', () => {
|
|
161
|
+
Array.from(TosiFloat.floats).forEach((float) => {
|
|
162
|
+
if (float.remainOnResize === 'hide') {
|
|
163
|
+
float.hidden = true;
|
|
164
|
+
}
|
|
165
|
+
else if (float.remainOnResize === 'remove') {
|
|
166
|
+
float.remove();
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}, { passive: true });
|
|
170
|
+
document.addEventListener('scroll', (event) => {
|
|
171
|
+
if (event.target instanceof HTMLElement &&
|
|
172
|
+
event.target.closest(TosiFloat.tagName)) {
|
|
173
|
+
return;
|
|
171
174
|
}
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
Array.from(TosiFloat.floats).forEach((float) => {
|
|
176
|
+
if (float.remainOnScroll === 'hide') {
|
|
177
|
+
float.hidden = true;
|
|
178
|
+
}
|
|
179
|
+
else if (float.remainOnScroll === 'remove') {
|
|
180
|
+
float.remove();
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}, { passive: true, capture: true });
|
|
184
|
+
}
|