@nanoporetech-digital/components 6.0.1 → 6.2.0
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 +30 -0
- package/dist/cjs/index-14451c95.js +6 -2
- package/dist/cjs/index-browser.cjs-d4554470.js +39 -0
- package/dist/cjs/index-browser.cjs-d4554470.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/nano-algolia.cjs.entry.js +6 -1
- package/dist/cjs/nano-algolia.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-animation.cjs.entry.js +1209 -0
- package/dist/cjs/nano-animation.cjs.entry.js.map +1 -0
- package/dist/cjs/nano-components.cjs.js +1 -1
- package/dist/cjs/nano-global-nav-user-profile_3.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-global-nav.cjs.entry.js +24 -25
- package/dist/cjs/nano-global-nav.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-global-search-results.cjs.entry.js +51 -27
- package/dist/cjs/nano-global-search-results.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-hero.cjs.entry.js +1 -1
- package/dist/cjs/nano-hero.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-intersection-observe.cjs.entry.js +131 -0
- package/dist/cjs/nano-intersection-observe.cjs.entry.js.map +1 -0
- package/dist/cjs/nano-resize-observe_2.cjs.entry.js +1 -1
- package/dist/cjs/nano-resize-observe_2.cjs.entry.js.map +1 -1
- package/dist/cjs/nano-sticker.cjs.entry.js +2 -27
- package/dist/cjs/nano-sticker.cjs.entry.js.map +1 -1
- package/dist/cjs/{nano-table-400049cc.js → nano-table-06530d49.js} +5 -25
- package/dist/cjs/nano-table-06530d49.js.map +1 -0
- package/dist/cjs/nano-table.cjs.entry.js +2 -1
- package/dist/cjs/nano-table.cjs.entry.js.map +1 -1
- package/dist/cjs/scroll-parent-87393de2.js +31 -0
- package/dist/cjs/scroll-parent-87393de2.js.map +1 -0
- package/dist/cjs/search-insights-b2bb12bd.js +50 -0
- package/dist/cjs/search-insights-b2bb12bd.js.map +1 -0
- package/dist/cjs/{table.worker-a37f8365.js → table.worker-b4922b9b.js} +3 -2
- package/dist/cjs/table.worker-b4922b9b.js.map +1 -0
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/algolia/algolia-interface.js.map +1 -1
- package/dist/collection/components/algolia/algolia.js +8 -3
- package/dist/collection/components/algolia/algolia.js.map +1 -1
- package/dist/collection/components/animation/animation.js +547 -0
- package/dist/collection/components/animation/animation.js.map +1 -0
- package/dist/collection/components/animation/animations/attention_seekers/bounce.js +43 -0
- package/dist/collection/components/animation/animations/attention_seekers/flash.js +7 -0
- package/dist/collection/components/animation/animations/attention_seekers/headShake.js +8 -0
- package/dist/collection/components/animation/animations/attention_seekers/heartBeat.js +7 -0
- package/dist/collection/components/animation/animations/attention_seekers/jello.js +15 -0
- package/dist/collection/components/animation/animations/attention_seekers/pulse.js +5 -0
- package/dist/collection/components/animation/animations/attention_seekers/rubberBand.js +9 -0
- package/dist/collection/components/animation/animations/attention_seekers/shake.js +13 -0
- package/dist/collection/components/animation/animations/attention_seekers/shakeX.js +13 -0
- package/dist/collection/components/animation/animations/attention_seekers/shakeY.js +13 -0
- package/dist/collection/components/animation/animations/attention_seekers/swing.js +7 -0
- package/dist/collection/components/animation/animations/attention_seekers/tada.js +13 -0
- package/dist/collection/components/animation/animations/attention_seekers/wobble.js +18 -0
- package/dist/collection/components/animation/animations/back_entrances/backInDown.js +5 -0
- package/dist/collection/components/animation/animations/back_entrances/backInLeft.js +5 -0
- package/dist/collection/components/animation/animations/back_entrances/backInRight.js +5 -0
- package/dist/collection/components/animation/animations/back_entrances/backInUp.js +5 -0
- package/dist/collection/components/animation/animations/back_exits/backOutDown.js +5 -0
- package/dist/collection/components/animation/animations/back_exits/backOutLeft.js +5 -0
- package/dist/collection/components/animation/animations/back_exits/backOutRight.js +5 -0
- package/dist/collection/components/animation/animations/back_exits/backOutUp.js +5 -0
- package/dist/collection/components/animation/animations/bouncing_entrances/bounceIn.js +14 -0
- package/dist/collection/components/animation/animations/bouncing_entrances/bounceInDown.js +20 -0
- package/dist/collection/components/animation/animations/bouncing_entrances/bounceInLeft.js +16 -0
- package/dist/collection/components/animation/animations/bouncing_entrances/bounceInRight.js +16 -0
- package/dist/collection/components/animation/animations/bouncing_entrances/bounceInUp.js +16 -0
- package/dist/collection/components/animation/animations/bouncing_exits/bounceOut.js +6 -0
- package/dist/collection/components/animation/animations/bouncing_exits/bounceOutDown.js +14 -0
- package/dist/collection/components/animation/animations/bouncing_exits/bounceOutLeft.js +12 -0
- package/dist/collection/components/animation/animations/bouncing_exits/bounceOutRight.js +8 -0
- package/dist/collection/components/animation/animations/bouncing_exits/bounceOutUp.js +18 -0
- package/dist/collection/components/animation/animations/easings/easings.js +35 -0
- package/dist/collection/components/animation/animations/easings/easings.js.map +1 -0
- package/dist/collection/components/animation/animations/fading_entrances/fadeIn.js +4 -0
- package/dist/collection/components/animation/animations/fading_entrances/fadeInBottomLeft.js +4 -0
- package/dist/collection/components/animation/animations/fading_entrances/fadeInBottomRight.js +4 -0
- package/dist/collection/components/animation/animations/fading_entrances/fadeInDown.js +4 -0
- package/dist/collection/components/animation/animations/fading_entrances/fadeInDownBig.js +4 -0
- package/dist/collection/components/animation/animations/fading_entrances/fadeInLeft.js +4 -0
- package/dist/collection/components/animation/animations/fading_entrances/fadeInLeftBig.js +4 -0
- package/dist/collection/components/animation/animations/fading_entrances/fadeInRight.js +4 -0
- package/dist/collection/components/animation/animations/fading_entrances/fadeInRightBig.js +4 -0
- package/dist/collection/components/animation/animations/fading_entrances/fadeInTopLeft.js +4 -0
- package/dist/collection/components/animation/animations/fading_entrances/fadeInTopRight.js +4 -0
- package/dist/collection/components/animation/animations/fading_entrances/fadeInUp.js +4 -0
- package/dist/collection/components/animation/animations/fading_entrances/fadeInUpBig.js +4 -0
- package/dist/collection/components/animation/animations/fading_exits/fadeOut.js +4 -0
- package/dist/collection/components/animation/animations/fading_exits/fadeOutBottomLeft.js +4 -0
- package/dist/collection/components/animation/animations/fading_exits/fadeOutBottomRight.js +4 -0
- package/dist/collection/components/animation/animations/fading_exits/fadeOutDown.js +4 -0
- package/dist/collection/components/animation/animations/fading_exits/fadeOutDownBig.js +4 -0
- package/dist/collection/components/animation/animations/fading_exits/fadeOutLeft.js +4 -0
- package/dist/collection/components/animation/animations/fading_exits/fadeOutLeftBig.js +4 -0
- package/dist/collection/components/animation/animations/fading_exits/fadeOutRight.js +4 -0
- package/dist/collection/components/animation/animations/fading_exits/fadeOutRightBig.js +4 -0
- package/dist/collection/components/animation/animations/fading_exits/fadeOutTopLeft.js +4 -0
- package/dist/collection/components/animation/animations/fading_exits/fadeOutTopRight.js +4 -0
- package/dist/collection/components/animation/animations/fading_exits/fadeOutUp.js +4 -0
- package/dist/collection/components/animation/animations/fading_exits/fadeOutUpBig.js +4 -0
- package/dist/collection/components/animation/animations/flippers/flip.js +32 -0
- package/dist/collection/components/animation/animations/flippers/flipInX.js +20 -0
- package/dist/collection/components/animation/animations/flippers/flipInY.js +20 -0
- package/dist/collection/components/animation/animations/flippers/flipOutX.js +13 -0
- package/dist/collection/components/animation/animations/flippers/flipOutY.js +13 -0
- package/dist/collection/components/animation/animations/index.js +203 -0
- package/dist/collection/components/animation/animations/index.js.map +1 -0
- package/dist/collection/components/animation/animations/lightspeed/lightSpeedInLeft.js +10 -0
- package/dist/collection/components/animation/animations/lightspeed/lightSpeedInRight.js +10 -0
- package/dist/collection/components/animation/animations/lightspeed/lightSpeedOutLeft.js +8 -0
- package/dist/collection/components/animation/animations/lightspeed/lightSpeedOutRight.js +8 -0
- package/dist/collection/components/animation/animations/rotating_entrances/rotateIn.js +4 -0
- package/dist/collection/components/animation/animations/rotating_entrances/rotateInDownLeft.js +4 -0
- package/dist/collection/components/animation/animations/rotating_entrances/rotateInDownRight.js +4 -0
- package/dist/collection/components/animation/animations/rotating_entrances/rotateInUpLeft.js +4 -0
- package/dist/collection/components/animation/animations/rotating_entrances/rotateInUpRight.js +4 -0
- package/dist/collection/components/animation/animations/rotating_exits/rotateOut.js +4 -0
- package/dist/collection/components/animation/animations/rotating_exits/rotateOutDownLeft.js +4 -0
- package/dist/collection/components/animation/animations/rotating_exits/rotateOutDownRight.js +4 -0
- package/dist/collection/components/animation/animations/rotating_exits/rotateOutUpLeft.js +4 -0
- package/dist/collection/components/animation/animations/rotating_exits/rotateOutUpRight.js +4 -0
- package/dist/collection/components/animation/animations/sliding_entrances/slideInDown.js +4 -0
- package/dist/collection/components/animation/animations/sliding_entrances/slideInLeft.js +4 -0
- package/dist/collection/components/animation/animations/sliding_entrances/slideInRight.js +4 -0
- package/dist/collection/components/animation/animations/sliding_entrances/slideInUp.js +4 -0
- package/dist/collection/components/animation/animations/sliding_exits/slideOutDown.js +4 -0
- package/dist/collection/components/animation/animations/sliding_exits/slideOutLeft.js +4 -0
- package/dist/collection/components/animation/animations/sliding_exits/slideOutRight.js +4 -0
- package/dist/collection/components/animation/animations/sliding_exits/slideOutUp.js +4 -0
- package/dist/collection/components/animation/animations/specials/hinge.js +18 -0
- package/dist/collection/components/animation/animations/specials/jackInTheBox.js +11 -0
- package/dist/collection/components/animation/animations/specials/rollIn.js +8 -0
- package/dist/collection/components/animation/animations/specials/rollOut.js +8 -0
- package/dist/collection/components/animation/animations/zooming_entrances/zoomIn.js +4 -0
- package/dist/collection/components/animation/animations/zooming_entrances/zoomInDown.js +14 -0
- package/dist/collection/components/animation/animations/zooming_entrances/zoomInLeft.js +14 -0
- package/dist/collection/components/animation/animations/zooming_entrances/zoomInRight.js +14 -0
- package/dist/collection/components/animation/animations/zooming_entrances/zoomInUp.js +14 -0
- package/dist/collection/components/animation/animations/zooming_exits/zoomOut.js +5 -0
- package/dist/collection/components/animation/animations/zooming_exits/zoomOutDown.js +14 -0
- package/dist/collection/components/animation/animations/zooming_exits/zoomOutLeft.js +12 -0
- package/dist/collection/components/animation/animations/zooming_exits/zoomOutRight.js +12 -0
- package/dist/collection/components/animation/animations/zooming_exits/zoomOutUp.js +14 -0
- package/dist/collection/components/global-nav/global-nav-interface.js.map +1 -1
- package/dist/collection/components/global-nav/global-nav.js +25 -25
- package/dist/collection/components/global-nav/global-nav.js.map +1 -1
- package/dist/collection/components/global-search-results/global-search-results.js +51 -27
- package/dist/collection/components/global-search-results/global-search-results.js.map +1 -1
- package/dist/collection/components/hero/hero.css +0 -1
- package/dist/collection/components/intersection-observe/intersection-observe.js +256 -0
- package/dist/collection/components/intersection-observe/intersection-observe.js.map +1 -0
- package/dist/collection/components/resize-observe/resize-observe.js +1 -1
- package/dist/collection/components/resize-observe/resize-observe.js.map +1 -1
- package/dist/collection/components/select/select.js +5 -5
- package/dist/collection/components/select/select.js.map +1 -1
- package/dist/collection/components/sticker/sticker.js +2 -27
- package/dist/collection/components/sticker/sticker.js.map +1 -1
- package/dist/collection/components/table/table.js +2 -1
- package/dist/collection/components/table/table.js.map +1 -1
- package/dist/collection/components/table/table.utils.js +0 -21
- package/dist/collection/components/table/table.utils.js.map +1 -1
- package/dist/collection/utils/scroll-parent.js +26 -0
- package/dist/collection/utils/scroll-parent.js.map +1 -0
- package/dist/collection/utils/search-insights.js +46 -0
- package/dist/collection/utils/search-insights.js.map +1 -0
- package/dist/components/algolia.js +6 -1
- package/dist/components/algolia.js.map +1 -1
- package/dist/components/index-browser.cjs.js +37 -0
- package/dist/components/index-browser.cjs.js.map +1 -0
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +2 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/{nano-aspect-ratio.d.ts → nano-animation.d.ts} +4 -4
- package/dist/components/nano-animation.js +1239 -0
- package/dist/components/nano-animation.js.map +1 -0
- package/dist/components/nano-global-nav.js +24 -25
- package/dist/components/nano-global-nav.js.map +1 -1
- package/dist/components/nano-global-search-results.js +51 -27
- package/dist/components/nano-global-search-results.js.map +1 -1
- package/dist/components/nano-hero.js +1 -1
- package/dist/components/nano-hero.js.map +1 -1
- package/dist/components/nano-intersection-observe.d.ts +11 -0
- package/dist/components/nano-intersection-observe.js +149 -0
- package/dist/components/nano-intersection-observe.js.map +1 -0
- package/dist/components/resize-observe.js +1 -1
- package/dist/components/resize-observe.js.map +1 -1
- package/dist/components/scroll-parent.js +29 -0
- package/dist/components/scroll-parent.js.map +1 -0
- package/dist/components/search-insights.js +48 -0
- package/dist/components/search-insights.js.map +1 -0
- package/dist/components/select.js.map +1 -1
- package/dist/components/sticker.js +2 -27
- package/dist/components/sticker.js.map +1 -1
- package/dist/components/table.js +1 -21
- package/dist/components/table.js.map +1 -1
- package/dist/esm/index-9695db0a.js +6 -2
- package/dist/esm/index-browser.cjs-bf702094.js +37 -0
- package/dist/esm/index-browser.cjs-bf702094.js.map +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/nano-algolia.entry.js +6 -1
- package/dist/esm/nano-algolia.entry.js.map +1 -1
- package/dist/esm/nano-animation.entry.js +1205 -0
- package/dist/esm/nano-animation.entry.js.map +1 -0
- package/dist/esm/nano-components.js +1 -1
- package/dist/esm/nano-global-nav-user-profile_3.entry.js.map +1 -1
- package/dist/esm/nano-global-nav.entry.js +24 -25
- package/dist/esm/nano-global-nav.entry.js.map +1 -1
- package/dist/esm/nano-global-search-results.entry.js +51 -27
- package/dist/esm/nano-global-search-results.entry.js.map +1 -1
- package/dist/esm/nano-hero.entry.js +1 -1
- package/dist/esm/nano-hero.entry.js.map +1 -1
- package/dist/esm/nano-intersection-observe.entry.js +127 -0
- package/dist/esm/nano-intersection-observe.entry.js.map +1 -0
- package/dist/esm/nano-resize-observe_2.entry.js +1 -1
- package/dist/esm/nano-resize-observe_2.entry.js.map +1 -1
- package/dist/esm/nano-sticker.entry.js +2 -27
- package/dist/esm/nano-sticker.entry.js.map +1 -1
- package/dist/esm/{nano-table-a6641aef.js → nano-table-c85a2fd3.js} +3 -23
- package/dist/esm/nano-table-c85a2fd3.js.map +1 -0
- package/dist/esm/nano-table.entry.js +2 -1
- package/dist/esm/nano-table.entry.js.map +1 -1
- package/dist/esm/scroll-parent-bab1cbf7.js +29 -0
- package/dist/esm/scroll-parent-bab1cbf7.js.map +1 -0
- package/dist/esm/search-insights-f64a6b4c.js +48 -0
- package/dist/esm/search-insights-f64a6b4c.js.map +1 -0
- package/dist/esm/{table.worker-6b597e20.js → table.worker-761fba3e.js} +3 -2
- package/dist/esm/table.worker-761fba3e.js.map +1 -0
- package/dist/nano-components/index-browser.cjs-bf702094.js +5 -0
- package/dist/nano-components/index-browser.cjs-bf702094.js.map +1 -0
- package/dist/nano-components/nano-algolia.entry.js +1 -1
- package/dist/nano-components/nano-algolia.entry.js.map +1 -1
- package/dist/nano-components/nano-animation.entry.js +5 -0
- package/dist/nano-components/nano-animation.entry.js.map +1 -0
- package/dist/nano-components/nano-components.css +1 -1
- package/dist/nano-components/nano-components.esm.js +1 -1
- package/dist/nano-components/nano-components.esm.js.map +1 -1
- package/dist/nano-components/nano-global-nav-user-profile_3.entry.js.map +1 -1
- package/dist/nano-components/nano-global-nav.entry.js +1 -1
- package/dist/nano-components/nano-global-nav.entry.js.map +1 -1
- package/dist/nano-components/nano-global-search-results.entry.js +1 -1
- package/dist/nano-components/nano-global-search-results.entry.js.map +1 -1
- package/dist/nano-components/nano-hero.entry.js +1 -1
- package/dist/nano-components/nano-hero.entry.js.map +1 -1
- package/dist/nano-components/nano-intersection-observe.entry.js +5 -0
- package/dist/nano-components/nano-intersection-observe.entry.js.map +1 -0
- package/dist/nano-components/nano-resize-observe_2.entry.js +1 -1
- package/dist/nano-components/nano-resize-observe_2.entry.js.map +1 -1
- package/dist/nano-components/nano-sticker.entry.js +1 -1
- package/dist/nano-components/nano-sticker.entry.js.map +1 -1
- package/dist/nano-components/nano-table-c85a2fd3.js +5 -0
- package/dist/nano-components/nano-table-c85a2fd3.js.map +1 -0
- package/dist/nano-components/nano-table.entry.js +1 -1
- package/dist/nano-components/scroll-parent-bab1cbf7.js +5 -0
- package/dist/nano-components/scroll-parent-bab1cbf7.js.map +1 -0
- package/dist/nano-components/search-insights-f64a6b4c.js +5 -0
- package/dist/nano-components/search-insights-f64a6b4c.js.map +1 -0
- package/dist/nano-components/table.worker-761fba3e.js +5 -0
- package/dist/types/components/algolia/algolia-interface.d.ts +2 -1
- package/dist/types/components/algolia/algolia.d.ts +7 -1
- package/dist/types/components/animation/animation.d.ts +74 -0
- package/dist/types/components/animation/animations/easings/easings.d.ts +31 -0
- package/dist/types/components/animation/animations/index.d.ts +101 -0
- package/dist/types/components/global-nav/global-nav-interface.d.ts +1 -0
- package/dist/types/components/global-nav/global-nav.d.ts +2 -6
- package/dist/types/components/global-search-results/global-search-results.d.ts +13 -7
- package/dist/types/components/intersection-observe/intersection-observe.d.ts +45 -0
- package/dist/types/components/select/select.d.ts +2 -4
- package/dist/types/components/sticker/sticker.d.ts +0 -5
- package/dist/types/components/table/table.utils.d.ts +0 -6
- package/dist/types/components.d.ts +213 -43
- package/dist/types/interface.d.ts +7 -2
- package/dist/types/utils/scroll-parent.d.ts +6 -0
- package/dist/types/utils/search-insights.d.ts +22 -0
- package/docs-json.json +1031 -117
- package/docs-vscode.json +488 -8
- package/hydrate/index.js +1636 -249
- package/package.json +3 -2
- package/dist/cjs/nano-aspect-ratio.cjs.entry.js +0 -53
- package/dist/cjs/nano-aspect-ratio.cjs.entry.js.map +0 -1
- package/dist/cjs/nano-table-400049cc.js.map +0 -1
- package/dist/cjs/table.worker-a37f8365.js.map +0 -1
- package/dist/collection/components/aspect-ratio/aspect-ratio.css +0 -38
- package/dist/collection/components/aspect-ratio/aspect-ratio.js +0 -106
- package/dist/collection/components/aspect-ratio/aspect-ratio.js.map +0 -1
- package/dist/components/nano-aspect-ratio.js +0 -70
- package/dist/components/nano-aspect-ratio.js.map +0 -1
- package/dist/esm/nano-aspect-ratio.entry.js +0 -49
- package/dist/esm/nano-aspect-ratio.entry.js.map +0 -1
- package/dist/esm/nano-table-a6641aef.js.map +0 -1
- package/dist/esm/table.worker-6b597e20.js.map +0 -1
- package/dist/nano-components/nano-aspect-ratio.entry.js +0 -5
- package/dist/nano-components/nano-aspect-ratio.entry.js.map +0 -1
- package/dist/nano-components/nano-table-a6641aef.js +0 -5
- package/dist/nano-components/nano-table-a6641aef.js.map +0 -1
- package/dist/nano-components/table.worker-6b597e20.js +0 -5
- package/dist/types/components/aspect-ratio/aspect-ratio.d.ts +0 -19
- /package/dist/nano-components/{table.worker-6b597e20.js.map → table.worker-761fba3e.js.map} +0 -0
@@ -0,0 +1,256 @@
|
|
1
|
+
/*!
|
2
|
+
* Web Components for Nanopore digital Web Apps
|
3
|
+
*/
|
4
|
+
import { h, } from '@stencil/core';
|
5
|
+
import { findScrollParent } from '../../utils/scroll-parent';
|
6
|
+
/**
|
7
|
+
* A thin, declarative interface to the IntersectionObserver API.
|
8
|
+
* @slot - Main slot for any content.
|
9
|
+
*/
|
10
|
+
export class IntersectionObserve {
|
11
|
+
constructor() {
|
12
|
+
this.ioCallback = (entries) => {
|
13
|
+
entries.forEach((entry) => {
|
14
|
+
this.nanoIntersectionChange.emit(entry);
|
15
|
+
if (entry.isIntersecting)
|
16
|
+
this.nanoIntersecting.emit(entry);
|
17
|
+
if (!entry.isIntersecting)
|
18
|
+
this.nanoNotIntersecting.emit(entry);
|
19
|
+
});
|
20
|
+
};
|
21
|
+
this.handleSlotChange = () => {
|
22
|
+
this.addIO();
|
23
|
+
};
|
24
|
+
this.root = 'auto';
|
25
|
+
this.rootMargin = undefined;
|
26
|
+
this.threshold = undefined;
|
27
|
+
}
|
28
|
+
get observerOptions() {
|
29
|
+
const opts = {};
|
30
|
+
if (!!this._root)
|
31
|
+
opts.root = this._root;
|
32
|
+
if (this.rootMargin)
|
33
|
+
opts.rootMargin = this.rootMargin;
|
34
|
+
if (this.threshold)
|
35
|
+
opts.threshold = this._threshold;
|
36
|
+
return opts;
|
37
|
+
}
|
38
|
+
get elements() {
|
39
|
+
const slotted = this.defaultSlot?.assignedElements() || [];
|
40
|
+
return slotted.flatMap((el) => {
|
41
|
+
const style = getComputedStyle(el);
|
42
|
+
if (style.display.includes('contents'))
|
43
|
+
return Array.from(el.children);
|
44
|
+
else
|
45
|
+
return el;
|
46
|
+
});
|
47
|
+
}
|
48
|
+
handleRootChange() {
|
49
|
+
if (!this.root) {
|
50
|
+
this._root = undefined;
|
51
|
+
this.removeIO();
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
let newRoot;
|
55
|
+
if (this.root === 'auto') {
|
56
|
+
// try to find nearest scrolling parent
|
57
|
+
newRoot = findScrollParent(this.host);
|
58
|
+
}
|
59
|
+
else if (this.root === 'root') {
|
60
|
+
newRoot = undefined;
|
61
|
+
}
|
62
|
+
else {
|
63
|
+
// root is set explicitly
|
64
|
+
newRoot = this.root;
|
65
|
+
}
|
66
|
+
// if it's the document - unset as that's IO's default
|
67
|
+
if (newRoot === document.documentElement)
|
68
|
+
newRoot = undefined;
|
69
|
+
// if new root is what we already have - ignore
|
70
|
+
if (newRoot === this._root)
|
71
|
+
return;
|
72
|
+
// cache and setup io
|
73
|
+
this._root = newRoot;
|
74
|
+
this.addIO();
|
75
|
+
}
|
76
|
+
handleThresholdChange() {
|
77
|
+
if (!this.threshold) {
|
78
|
+
this._threshold = undefined;
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
if (this.threshold.includes(',')) {
|
82
|
+
this._threshold = this.threshold
|
83
|
+
.split(',')
|
84
|
+
.map((numStr) => Number(numStr));
|
85
|
+
return;
|
86
|
+
}
|
87
|
+
this._threshold = Number(this.threshold);
|
88
|
+
}
|
89
|
+
addIO() {
|
90
|
+
if (!window['IntersectionObserver'] || !this.elements?.length)
|
91
|
+
return;
|
92
|
+
if (this.io)
|
93
|
+
this.removeIO();
|
94
|
+
const io = (this.io = new IntersectionObserver(this.ioCallback, this.observerOptions));
|
95
|
+
this.elements?.forEach((el) => {
|
96
|
+
io.observe(el);
|
97
|
+
});
|
98
|
+
}
|
99
|
+
removeIO() {
|
100
|
+
if (!this.io)
|
101
|
+
return;
|
102
|
+
this.io.disconnect();
|
103
|
+
this.io = undefined;
|
104
|
+
}
|
105
|
+
connectedCallback() {
|
106
|
+
this.handleThresholdChange();
|
107
|
+
this.handleRootChange();
|
108
|
+
}
|
109
|
+
disconnectedCallback() {
|
110
|
+
this.removeIO();
|
111
|
+
this.root = this._root = undefined;
|
112
|
+
}
|
113
|
+
render() {
|
114
|
+
return (h("slot", { ref: (slot) => (this.defaultSlot = slot), onSlotchange: this.handleSlotChange }));
|
115
|
+
}
|
116
|
+
static get is() { return "nano-intersection-observe"; }
|
117
|
+
static get encapsulation() { return "shadow"; }
|
118
|
+
static get styles() { return "nano-intersection-observe { display: contents }"; }
|
119
|
+
static get properties() {
|
120
|
+
return {
|
121
|
+
"root": {
|
122
|
+
"type": "string",
|
123
|
+
"mutable": false,
|
124
|
+
"complexType": {
|
125
|
+
"original": "globalThis.Element | 'root' | 'auto'",
|
126
|
+
"resolved": "\"auto\" | \"root\" | Element",
|
127
|
+
"references": {
|
128
|
+
"globalThis": {
|
129
|
+
"location": "global"
|
130
|
+
}
|
131
|
+
}
|
132
|
+
},
|
133
|
+
"required": false,
|
134
|
+
"optional": false,
|
135
|
+
"docs": {
|
136
|
+
"tags": [],
|
137
|
+
"text": "The element that is used as the viewport for checking visibility of the target. Must be the ancestor of the target.\nDefaults to an automatic check for ancestors that `overflow: auto` or otherwise the `Document`."
|
138
|
+
},
|
139
|
+
"getter": false,
|
140
|
+
"setter": false,
|
141
|
+
"attribute": "root",
|
142
|
+
"reflect": false,
|
143
|
+
"defaultValue": "'auto'"
|
144
|
+
},
|
145
|
+
"rootMargin": {
|
146
|
+
"type": "string",
|
147
|
+
"mutable": false,
|
148
|
+
"complexType": {
|
149
|
+
"original": "string",
|
150
|
+
"resolved": "string",
|
151
|
+
"references": {}
|
152
|
+
},
|
153
|
+
"required": false,
|
154
|
+
"optional": true,
|
155
|
+
"docs": {
|
156
|
+
"tags": [],
|
157
|
+
"text": "Margin around the root. Can be similar to CSS margins property, e.g. \"10px 20px 30px 40px\" (top, right, bottom, left).\nThe values can be percentages. This set of values serves to grow or shrink each side of the root element's\nbounding box before computing intersections. Defaults to zeros."
|
158
|
+
},
|
159
|
+
"getter": false,
|
160
|
+
"setter": false,
|
161
|
+
"attribute": "root-margin",
|
162
|
+
"reflect": false
|
163
|
+
},
|
164
|
+
"threshold": {
|
165
|
+
"type": "string",
|
166
|
+
"mutable": false,
|
167
|
+
"complexType": {
|
168
|
+
"original": "string",
|
169
|
+
"resolved": "string",
|
170
|
+
"references": {}
|
171
|
+
},
|
172
|
+
"required": false,
|
173
|
+
"optional": true,
|
174
|
+
"docs": {
|
175
|
+
"tags": [],
|
176
|
+
"text": "Indicate at what percentage of the target's visibility the observer's callback should be executed.\nIf you only want to detect when visibility passes the 50% mark, you can use a value of '0.5'.\nIf you want the callback to run every time visibility passes another '25%',\nyou would specify a string of values (separated by ',') array '0, 0.25, 0.5, 0.75, 1'.\nA value of '1.0' means that the threshold isn't considered passed until every pixel is visible."
|
177
|
+
},
|
178
|
+
"getter": false,
|
179
|
+
"setter": false,
|
180
|
+
"attribute": "threshold",
|
181
|
+
"reflect": false
|
182
|
+
}
|
183
|
+
};
|
184
|
+
}
|
185
|
+
static get events() {
|
186
|
+
return [{
|
187
|
+
"method": "nanoIntersectionChange",
|
188
|
+
"name": "nanoIntersectionChange",
|
189
|
+
"bubbles": true,
|
190
|
+
"cancelable": true,
|
191
|
+
"composed": true,
|
192
|
+
"docs": {
|
193
|
+
"tags": [],
|
194
|
+
"text": "A resize break point is switched on or off"
|
195
|
+
},
|
196
|
+
"complexType": {
|
197
|
+
"original": "IntersectionObserverEntry",
|
198
|
+
"resolved": "IntersectionObserverEntry",
|
199
|
+
"references": {
|
200
|
+
"IntersectionObserverEntry": {
|
201
|
+
"location": "global"
|
202
|
+
}
|
203
|
+
}
|
204
|
+
}
|
205
|
+
}, {
|
206
|
+
"method": "nanoIntersecting",
|
207
|
+
"name": "nanoIntersecting",
|
208
|
+
"bubbles": true,
|
209
|
+
"cancelable": true,
|
210
|
+
"composed": true,
|
211
|
+
"docs": {
|
212
|
+
"tags": [],
|
213
|
+
"text": "A resize break point is switched on or off"
|
214
|
+
},
|
215
|
+
"complexType": {
|
216
|
+
"original": "IntersectionObserverEntry",
|
217
|
+
"resolved": "IntersectionObserverEntry",
|
218
|
+
"references": {
|
219
|
+
"IntersectionObserverEntry": {
|
220
|
+
"location": "global"
|
221
|
+
}
|
222
|
+
}
|
223
|
+
}
|
224
|
+
}, {
|
225
|
+
"method": "nanoNotIntersecting",
|
226
|
+
"name": "nanoNotIntersecting",
|
227
|
+
"bubbles": true,
|
228
|
+
"cancelable": true,
|
229
|
+
"composed": true,
|
230
|
+
"docs": {
|
231
|
+
"tags": [],
|
232
|
+
"text": "A resize break point is switched on or off"
|
233
|
+
},
|
234
|
+
"complexType": {
|
235
|
+
"original": "IntersectionObserverEntry",
|
236
|
+
"resolved": "IntersectionObserverEntry",
|
237
|
+
"references": {
|
238
|
+
"IntersectionObserverEntry": {
|
239
|
+
"location": "global"
|
240
|
+
}
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}];
|
244
|
+
}
|
245
|
+
static get elementRef() { return "host"; }
|
246
|
+
static get watchers() {
|
247
|
+
return [{
|
248
|
+
"propName": "root",
|
249
|
+
"methodName": "handleRootChange"
|
250
|
+
}, {
|
251
|
+
"propName": "threshold",
|
252
|
+
"methodName": "handleThresholdChange"
|
253
|
+
}];
|
254
|
+
}
|
255
|
+
}
|
256
|
+
//# sourceMappingURL=intersection-observe.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"intersection-observe.js","sourceRoot":"","sources":["../../../src/components/intersection-observe/intersection-observe.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,CAAC,EACD,IAAI,EACJ,OAAO,EACP,KAAK,EAEL,KAAK,GAEN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D;;;GAGG;AAMH,MAAM,OAAO,mBAAmB;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entInterface,\n Event,\n EventEmitter,\n} from '@stencil/core';\nimport { findScrollParent } from '../../utils/scroll-parent';\n\n/**\n * A thin, declarative interface to the IntersectionObserver API.\n * @slot - Main slot for any content.\n */\n@Component({\n tag: 'nano-intersection-observe',\n styles: `nano-intersection-observe { display: contents }`,\n shadow: true,\n})\nexport class IntersectionObserve implements ComponentInterface {\n private io: IntersectionObserver;\n private _root: Element | Document;\n private _threshold: number | number[];\n private defaultSlot: HTMLSlotElement;\n\n get observerOptions() {\n const opts: IntersectionObserverInit = {};\n\n if (!!this._root) opts.root = this._root;\n if (this.rootMargin) opts.rootMargin = this.rootMargin;\n if (this.threshold) opts.threshold = this._threshold;\n\n return opts;\n }\n\n get elements(): Element[] | undefined {\n const slotted = this.defaultSlot?.assignedElements() || [];\n\n return slotted.flatMap((el) => {\n const style = getComputedStyle(el);\n if (style.display.includes('contents')) return Array.from(el.children);\n else return el;\n });\n }\n\n @Element() host: HTMLNanoIntersectionObserveElement;\n\n /** The element that is used as the viewport for checking visibility of the target. Must be the ancestor of the target.\n * Defaults to an automatic check for ancestors that `overflow: auto` or otherwise the `Document`. */\n @Prop() root: globalThis.Element | 'root' | 'auto' = 'auto';\n\n @Watch('root')\n handleRootChange() {\n if (!this.root) {\n this._root = undefined;\n this.removeIO();\n return;\n }\n\n let newRoot;\n\n if (this.root === 'auto') {\n // try to find nearest scrolling parent\n newRoot = findScrollParent(this.host);\n } else if (this.root === 'root') {\n newRoot = undefined;\n } else {\n // root is set explicitly\n newRoot = this.root;\n }\n\n // if it's the document - unset as that's IO's default\n if (newRoot === document.documentElement) newRoot = undefined;\n // if new root is what we already have - ignore\n if (newRoot === this._root) return;\n\n // cache and setup io\n this._root = newRoot;\n this.addIO();\n }\n\n /**\n * Margin around the root. Can be similar to CSS margins property, e.g. \"10px 20px 30px 40px\" (top, right, bottom, left).\n * The values can be percentages. This set of values serves to grow or shrink each side of the root element's\n * bounding box before computing intersections. Defaults to zeros. */\n @Prop() rootMargin?: string;\n\n /**\n * Indicate at what percentage of the target's visibility the observer's callback should be executed.\n * If you only want to detect when visibility passes the 50% mark, you can use a value of '0.5'.\n * If you want the callback to run every time visibility passes another '25%',\n * you would specify a string of values (separated by ',') array '0, 0.25, 0.5, 0.75, 1'.\n * A value of '1.0' means that the threshold isn't considered passed until every pixel is visible.\n */\n @Prop() threshold?: string;\n\n @Watch('threshold')\n handleThresholdChange() {\n if (!this.threshold) {\n this._threshold = undefined;\n return;\n }\n\n if (this.threshold.includes(',')) {\n this._threshold = this.threshold\n .split(',')\n .map((numStr) => Number(numStr));\n return;\n }\n\n this._threshold = Number(this.threshold);\n }\n\n /** A resize break point is switched on or off */\n @Event() nanoIntersectionChange!: EventEmitter<IntersectionObserverEntry>;\n\n /** A resize break point is switched on or off */\n @Event() nanoIntersecting!: EventEmitter<IntersectionObserverEntry>;\n\n /** A resize break point is switched on or off */\n @Event() nanoNotIntersecting!: EventEmitter<IntersectionObserverEntry>;\n\n private ioCallback: IntersectionObserverCallback = (entries) => {\n entries.forEach((entry) => {\n this.nanoIntersectionChange.emit(entry);\n if (entry.isIntersecting) this.nanoIntersecting.emit(entry);\n if (!entry.isIntersecting) this.nanoNotIntersecting.emit(entry);\n });\n };\n\n private handleSlotChange = () => {\n this.addIO();\n };\n\n private addIO() {\n if (!window['IntersectionObserver'] || !this.elements?.length) return;\n if (this.io) this.removeIO();\n\n const io = (this.io = new IntersectionObserver(\n this.ioCallback,\n this.observerOptions\n ));\n this.elements?.forEach((el) => {\n io.observe(el);\n });\n }\n\n private removeIO() {\n if (!this.io) return;\n\n this.io.disconnect();\n this.io = undefined;\n }\n\n connectedCallback(): void {\n this.handleThresholdChange();\n this.handleRootChange();\n }\n\n disconnectedCallback(): void {\n this.removeIO();\n this.root = this._root = undefined;\n }\n\n render() {\n return (\n <slot\n ref={(slot) => (this.defaultSlot = slot as HTMLSlotElement)}\n onSlotchange={this.handleSlotChange}\n />\n );\n }\n}\n"]}
|
@@ -220,7 +220,7 @@ export class ResizeObserve {
|
|
220
220
|
}
|
221
221
|
static get is() { return "nano-resize-observe"; }
|
222
222
|
static get encapsulation() { return "shadow"; }
|
223
|
-
static get styles() { return "nano-resize-observe { display:
|
223
|
+
static get styles() { return "nano-resize-observe { display: block }"; }
|
224
224
|
static get properties() {
|
225
225
|
return {
|
226
226
|
"notifyContentFit": {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"resize-observe.js","sourceRoot":"","sources":["../../../src/components/resize-observe/resize-observe.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,CAAC,EACD,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,KAAK,EACL,KAAK,EAEL,KAAK,EAEL,QAAQ,GACT,MAAM,eAAe,CAAC;AASvB;;;;;;;;;;GAUG;AAMH,MAAM,OAAO,aAAa;;IAGhB,YAAO,GAAG,KAAK,CAAC;IA8IhB,kBAAa,GAAG,GAAG,EAAE;MAC3B,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,aAAa;QAAE,OAAO;MACtD,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;MAEvC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,aAAa;QAAE,OAAO;MAEhD,MAAM,aAAa,GAAc,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;MAChE,IAAI,UAAU,GAAG,KAAK,CAAC;MAEvB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAClD,IAAI,GAAW,CAAC;QAChB,IAAI,OAAO,KAAK,GAAG;UAAE,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC;;UACzC,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC;QAE7B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC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C1D,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CACnB,YAAM,IAAI,EAAC,eAAe,GAAG,CAC9B,CAAC,CAAC,CAAC,CACF,YAAM,IAAI,EAAC,iBAAiB,GAAG,CAChC;QACD,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CACnB,YAAM,IAAI,EAAC,eAAe,GAAG,CAC9B,CAAC,CAAC,CAAC,CACF,YAAM,IAAI,EAAC,iBAAiB,GAAG,CAChC;OACF,CACE,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n h,\n Prop,\n Element,\n Host,\n State,\n Watch,\n ComponentInterface,\n Event,\n EventEmitter,\n readTask,\n} from '@stencil/core';\nimport type { ResizeStateChangeEventDetail } from '../../interface';\n\ntype ResizeObserverState = { states?: string[]; applied?: boolean };\ninterface StateMaps {\n h: Map<number, ResizeObserverState>;\n w: Map<number, ResizeObserverState>;\n}\n\n/**\n * A Resize-Observer utility component.\n * Takes a string list of sizes and optional class-names.\n * Adds class-names and fires `nanoResizeStateChange` events when the component reaches those sizes.\n * Additionally, can fire events when content no-longer fits within the element.\n * @slot - Main slot for any content.\n * @slot content-fit-x - optional slot (when `notifyContentFit` is set). Shows when content fits / doesn't get cut off\n * @slot content-nofit-x - optional slot (when `notifyContentFit` is set). Shows when content doesn't get cut off\n * @slot content-fit-y - optional slot (when `notifyContentFit` is set). Shows when content fits / doesn't get cut off\n * @slot content-nofit-y - optional slot (when `notifyContentFit` is set). Shows when content doesn't get cut off\n */\n@Component({\n tag: 'nano-resize-observe',\n styles: `nano-resize-observe { display: contents }`,\n shadow: true,\n})\nexport class ResizeObserve implements ComponentInterface {\n private ro: ResizeObserver;\n private appliedStates: StateMaps;\n private isReady = false;\n\n @Element() host: HTMLNanoResizeObserveElement;\n @State() currentWidth: number;\n @State() currentHeight: number;\n @State() classNames: string[] = [];\n @State() contentFitX = null;\n @State() contentFitY = null;\n\n @Watch('classNames')\n classNameChange() {\n this.host.className = this.classNames.join(' ');\n if (!this.isReady && this.classNames.includes('is-ready')) {\n this.isReady = true;\n this.nanoResizeObserverReady.emit();\n }\n }\n\n /** Fire `nanoResizeContentFitChange` events notifying\n * whether content currently fits or does not on the x, y or both axis'.\n * Also makes the `content-fit-...` slots available */\n @Prop() notifyContentFit: 'x' | 'y' | 'xy';\n\n /** string list of sizes and optional class-names.\n * Adds class-names and fires nanoResizeStateChange events. Upon hitting breakpoints.\n * Format: `states=\"800w, 300h class1 class2\"` */\n @Prop() states: string;\n\n @Watch('states')\n newStatesProp() {\n this.statesChanged();\n }\n\n /** A resize break point is switched on or off */\n @Event() nanoResizeStateChange!: EventEmitter<ResizeStateChangeEventDetail>;\n\n /** Fires after the initial loading and assessment */\n @Event() nanoResizeObserverReady!: EventEmitter<void>;\n\n /** Fires when the content either begins or stops fitting.\n * Will only work when `notifyContentFit` is set. */\n @Event() nanoResizeContentFitChange!: EventEmitter<{\n x: boolean;\n y: boolean;\n }>;\n\n /** Fires after any resizing */\n @Event() nanoResize!: EventEmitter<ResizeObserverEntry[]>;\n\n @Watch('currentHeight')\n @Watch('currentWidth')\n dimensionChanged() {\n this.assessChanges();\n }\n\n @Watch('states')\n statesChanged() {\n if (!this.states) return;\n\n const toBpDir = (bpDir: string) => {\n const bpDirSpl = bpDir.split(/(\\d+)/).filter((bs) => bs.length);\n return { bp: parseInt(bpDirSpl[0]), dir: bpDirSpl[1] };\n };\n this.appliedStates = { h: new Map(), w: new Map() };\n\n // parse state string\n this.states.split(',').map((st) => {\n st = st.trim();\n if (st.includes(' ')) {\n const [key, ...classes] = st.split(' ');\n const { bp, dir } = toBpDir(key);\n this.appliedStates[dir as keyof StateMaps].set(bp, {\n states: classes,\n applied: false,\n });\n } else {\n const { bp, dir } = toBpDir(st);\n this.appliedStates[dir as keyof StateMaps].set(bp, { applied: false });\n }\n });\n }\n\n private assesContentFit() {\n if (!this.notifyContentFit) return;\n\n const findNonContentsEle = (ele: Element) => {\n if (window.getComputedStyle(ele).display !== 'contents') return ele;\n\n const recurse = (e: Element): Element | null => {\n return Array.from(e.children).find((cEle: HTMLElement) => {\n if (window.getComputedStyle(cEle).display !== 'contents') return cEle;\n recurse(cEle);\n });\n };\n return recurse(ele);\n };\n\n let didChange = false;\n const measureEle = findNonContentsEle(this.host.firstElementChild);\n\n if (measureEle) {\n if (this.notifyContentFit && this.notifyContentFit.includes('x')) {\n if (\n this.currentWidth < measureEle.scrollWidth &&\n this.contentFitX !== false\n ) {\n didChange = true;\n this.contentFitX = false;\n } else if (\n this.currentWidth >= measureEle.scrollWidth &&\n this.contentFitX !== true\n ) {\n didChange = true;\n this.contentFitX = true;\n }\n }\n\n if (this.notifyContentFit && this.notifyContentFit.includes('y')) {\n if (\n this.currentHeight < measureEle.scrollHeight &&\n this.contentFitY !== false\n ) {\n didChange = true;\n this.contentFitY = false;\n } else if (\n this.currentHeight >= measureEle.scrollHeight &&\n this.contentFitY !== true\n ) {\n didChange = true;\n this.contentFitY = true;\n }\n }\n\n if (didChange) {\n this.nanoResizeContentFitChange.emit({\n x: this.contentFitX,\n y: this.contentFitY,\n });\n }\n }\n }\n\n private assessChanges = () => {\n if (!this.currentWidth && !this.currentHeight) return;\n readTask(() => this.assesContentFit());\n\n if (!this.states || !this.appliedStates) return;\n\n const changedStates: StateMaps = { h: new Map(), w: new Map() };\n let hasChanged = false;\n\n Object.keys(this.appliedStates).forEach((dimType) => {\n let dim: number;\n if (dimType === 'h') dim = this.currentHeight;\n else dim = this.currentWidth;\n\n this.appliedStates[dimType].forEach(\n (state: ResizeObserverState, bp: number) => {\n if (dim >= bp && state.applied === false) {\n state.applied = true;\n changedStates[dimType].set(bp, state);\n hasChanged = true;\n } else if (dim < bp && state.applied === true) {\n state.applied = false;\n changedStates[dimType].set(bp, state);\n hasChanged = true;\n }\n }\n );\n });\n if (hasChanged) this.applyChanges(changedStates);\n else if (!this.classNames.includes('is-ready'))\n this.classNames = [...this.classNames, 'is-ready'];\n };\n\n private applyChanges(changes: StateMaps) {\n if (!this.states) return;\n\n let classNames = [...this.classNames];\n Object.keys(changes).forEach((dimType: keyof StateMaps) => {\n changes[dimType].forEach((state) => {\n if (!state.states) return;\n state.states.map((st) => {\n if (state.applied) {\n classNames.push(st);\n classNames = classNames.filter((cl) => cl !== 'not-' + st);\n } else {\n classNames.push('not-' + st);\n classNames = classNames.filter((cl) => cl !== st);\n }\n });\n });\n });\n this.classNames = ['is-ready', ...classNames];\n this.nanoResizeStateChange.emit(this.toSimpleObj(changes));\n }\n\n private toSimpleObj(stateMaps: StateMaps) {\n const retObj = {};\n Object.keys(stateMaps).forEach((dimType: keyof StateMaps) => {\n stateMaps[dimType].forEach((state: ResizeObserverState, bp: number) => {\n retObj[bp + dimType] = state.applied;\n });\n });\n return retObj;\n }\n\n private attachRO() {\n if (!window['ResizeObserver']) return;\n\n this.ro = new ResizeObserver((ro) => {\n const { width, height } = this.host.getBoundingClientRect();\n this.currentWidth = Math.ceil(width);\n this.currentHeight = Math.ceil(height);\n this.nanoResize.emit(ro);\n });\n this.ro.observe(this.host);\n }\n\n componentWillLoad() {\n this.classNames = Array.from(this.host.classList);\n\n this.statesChanged();\n // set all class as 'not-' by deafult\n this.applyChanges(this.appliedStates);\n\n if (!this.currentWidth && !this.currentHeight) {\n readTask(() => {\n const { width, height } = this.host.getBoundingClientRect();\n this.currentWidth = Math.ceil(width);\n this.currentHeight = Math.ceil(height);\n });\n } else {\n this.assessChanges();\n }\n }\n\n connectedCallback() {\n if (!this.ro) this.attachRO();\n }\n\n disconnectedCallback() {\n if (this.ro) this.ro.disconnect();\n }\n\n render() {\n return (\n <Host>\n <slot />\n {!!this.notifyContentFit &&\n (this.contentFitX !== null || this.contentFitY !== null) && [\n !!this.contentFitX ? (\n <slot name=\"content-fit-x\" />\n ) : (\n <slot name=\"content-nofit-x\" />\n ),\n !!this.contentFitY ? (\n <slot name=\"content-fit-y\" />\n ) : (\n <slot name=\"content-nofit-y\" />\n ),\n ]}\n </Host>\n );\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"resize-observe.js","sourceRoot":"","sources":["../../../src/components/resize-observe/resize-observe.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,CAAC,EACD,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,KAAK,EACL,KAAK,EAEL,KAAK,EAEL,QAAQ,GACT,MAAM,eAAe,CAAC;AASvB;;;;;;;;;;GAUG;AAMH,MAAM,OAAO,aAAa;;IAGhB,YAAO,GAAG,KAAK,CAAC;IA8IhB,kBAAa,GAAG,GAAG,EAAE;MAC3B,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,aAAa;QAAE,OAAO;MACtD,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;MAEvC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,aAAa;QAAE,OAAO;MAEhD,MAAM,aAAa,GAAc,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;MAChE,IAAI,UAAU,GAAG,KAAK,CAAC;MAEvB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAClD,IAAI,GAAW,CAAC;QAChB,IAAI,OAAO,KAAK,GAAG;UAAE,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC;;UACzC,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC;QAE7B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,CACjC,CAAC,KAA0B,EAAE,EAAU,EAAE,EAAE;UACz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ACnB,YAAM,IAAI,EAAC,eAAe,GAAG,CAC9B,CAAC,CAAC,CAAC,CACF,YAAM,IAAI,EAAC,iBAAiB,GAAG,CAChC;QACD,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CACnB,YAAM,IAAI,EAAC,eAAe,GAAG,CAC9B,CAAC,CAAC,CAAC,CACF,YAAM,IAAI,EAAC,iBAAiB,GAAG,CAChC;OACF,CACE,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n h,\n Prop,\n Element,\n Host,\n State,\n Watch,\n ComponentInterface,\n Event,\n EventEmitter,\n readTask,\n} from '@stencil/core';\nimport type { ResizeStateChangeEventDetail } from '../../interface';\n\ntype ResizeObserverState = { states?: string[]; applied?: boolean };\ninterface StateMaps {\n h: Map<number, ResizeObserverState>;\n w: Map<number, ResizeObserverState>;\n}\n\n/**\n * A Resize-Observer utility component.\n * Takes a string list of sizes and optional class-names.\n * Adds class-names and fires `nanoResizeStateChange` events when the component reaches those sizes.\n * Additionally, can fire events when content no-longer fits within the element.\n * @slot - Main slot for any content.\n * @slot content-fit-x - optional slot (when `notifyContentFit` is set). Shows when content fits / doesn't get cut off\n * @slot content-nofit-x - optional slot (when `notifyContentFit` is set). Shows when content doesn't get cut off\n * @slot content-fit-y - optional slot (when `notifyContentFit` is set). Shows when content fits / doesn't get cut off\n * @slot content-nofit-y - optional slot (when `notifyContentFit` is set). Shows when content doesn't get cut off\n */\n@Component({\n tag: 'nano-resize-observe',\n styles: `nano-resize-observe { display: block }`,\n shadow: true,\n})\nexport class ResizeObserve implements ComponentInterface {\n private ro: ResizeObserver;\n private appliedStates: StateMaps;\n private isReady = false;\n\n @Element() host: HTMLNanoResizeObserveElement;\n @State() currentWidth: number;\n @State() currentHeight: number;\n @State() classNames: string[] = [];\n @State() contentFitX = null;\n @State() contentFitY = null;\n\n @Watch('classNames')\n classNameChange() {\n this.host.className = this.classNames.join(' ');\n if (!this.isReady && this.classNames.includes('is-ready')) {\n this.isReady = true;\n this.nanoResizeObserverReady.emit();\n }\n }\n\n /** Fire `nanoResizeContentFitChange` events notifying\n * whether content currently fits or does not on the x, y or both axis'.\n * Also makes the `content-fit-...` slots available */\n @Prop() notifyContentFit: 'x' | 'y' | 'xy';\n\n /** string list of sizes and optional class-names.\n * Adds class-names and fires nanoResizeStateChange events. Upon hitting breakpoints.\n * Format: `states=\"800w, 300h class1 class2\"` */\n @Prop() states: string;\n\n @Watch('states')\n newStatesProp() {\n this.statesChanged();\n }\n\n /** A resize break point is switched on or off */\n @Event() nanoResizeStateChange!: EventEmitter<ResizeStateChangeEventDetail>;\n\n /** Fires after the initial loading and assessment */\n @Event() nanoResizeObserverReady!: EventEmitter<void>;\n\n /** Fires when the content either begins or stops fitting.\n * Will only work when `notifyContentFit` is set. */\n @Event() nanoResizeContentFitChange!: EventEmitter<{\n x: boolean;\n y: boolean;\n }>;\n\n /** Fires after any resizing */\n @Event() nanoResize!: EventEmitter<ResizeObserverEntry[]>;\n\n @Watch('currentHeight')\n @Watch('currentWidth')\n dimensionChanged() {\n this.assessChanges();\n }\n\n @Watch('states')\n statesChanged() {\n if (!this.states) return;\n\n const toBpDir = (bpDir: string) => {\n const bpDirSpl = bpDir.split(/(\\d+)/).filter((bs) => bs.length);\n return { bp: parseInt(bpDirSpl[0]), dir: bpDirSpl[1] };\n };\n this.appliedStates = { h: new Map(), w: new Map() };\n\n // parse state string\n this.states.split(',').map((st) => {\n st = st.trim();\n if (st.includes(' ')) {\n const [key, ...classes] = st.split(' ');\n const { bp, dir } = toBpDir(key);\n this.appliedStates[dir as keyof StateMaps].set(bp, {\n states: classes,\n applied: false,\n });\n } else {\n const { bp, dir } = toBpDir(st);\n this.appliedStates[dir as keyof StateMaps].set(bp, { applied: false });\n }\n });\n }\n\n private assesContentFit() {\n if (!this.notifyContentFit) return;\n\n const findNonContentsEle = (ele: Element) => {\n if (window.getComputedStyle(ele).display !== 'contents') return ele;\n\n const recurse = (e: Element): Element | null => {\n return Array.from(e.children).find((cEle: HTMLElement) => {\n if (window.getComputedStyle(cEle).display !== 'contents') return cEle;\n recurse(cEle);\n });\n };\n return recurse(ele);\n };\n\n let didChange = false;\n const measureEle = findNonContentsEle(this.host.firstElementChild);\n\n if (measureEle) {\n if (this.notifyContentFit && this.notifyContentFit.includes('x')) {\n if (\n this.currentWidth < measureEle.scrollWidth &&\n this.contentFitX !== false\n ) {\n didChange = true;\n this.contentFitX = false;\n } else if (\n this.currentWidth >= measureEle.scrollWidth &&\n this.contentFitX !== true\n ) {\n didChange = true;\n this.contentFitX = true;\n }\n }\n\n if (this.notifyContentFit && this.notifyContentFit.includes('y')) {\n if (\n this.currentHeight < measureEle.scrollHeight &&\n this.contentFitY !== false\n ) {\n didChange = true;\n this.contentFitY = false;\n } else if (\n this.currentHeight >= measureEle.scrollHeight &&\n this.contentFitY !== true\n ) {\n didChange = true;\n this.contentFitY = true;\n }\n }\n\n if (didChange) {\n this.nanoResizeContentFitChange.emit({\n x: this.contentFitX,\n y: this.contentFitY,\n });\n }\n }\n }\n\n private assessChanges = () => {\n if (!this.currentWidth && !this.currentHeight) return;\n readTask(() => this.assesContentFit());\n\n if (!this.states || !this.appliedStates) return;\n\n const changedStates: StateMaps = { h: new Map(), w: new Map() };\n let hasChanged = false;\n\n Object.keys(this.appliedStates).forEach((dimType) => {\n let dim: number;\n if (dimType === 'h') dim = this.currentHeight;\n else dim = this.currentWidth;\n\n this.appliedStates[dimType].forEach(\n (state: ResizeObserverState, bp: number) => {\n if (dim >= bp && state.applied === false) {\n state.applied = true;\n changedStates[dimType].set(bp, state);\n hasChanged = true;\n } else if (dim < bp && state.applied === true) {\n state.applied = false;\n changedStates[dimType].set(bp, state);\n hasChanged = true;\n }\n }\n );\n });\n if (hasChanged) this.applyChanges(changedStates);\n else if (!this.classNames.includes('is-ready'))\n this.classNames = [...this.classNames, 'is-ready'];\n };\n\n private applyChanges(changes: StateMaps) {\n if (!this.states) return;\n\n let classNames = [...this.classNames];\n Object.keys(changes).forEach((dimType: keyof StateMaps) => {\n changes[dimType].forEach((state) => {\n if (!state.states) return;\n state.states.map((st) => {\n if (state.applied) {\n classNames.push(st);\n classNames = classNames.filter((cl) => cl !== 'not-' + st);\n } else {\n classNames.push('not-' + st);\n classNames = classNames.filter((cl) => cl !== st);\n }\n });\n });\n });\n this.classNames = ['is-ready', ...classNames];\n this.nanoResizeStateChange.emit(this.toSimpleObj(changes));\n }\n\n private toSimpleObj(stateMaps: StateMaps) {\n const retObj = {};\n Object.keys(stateMaps).forEach((dimType: keyof StateMaps) => {\n stateMaps[dimType].forEach((state: ResizeObserverState, bp: number) => {\n retObj[bp + dimType] = state.applied;\n });\n });\n return retObj;\n }\n\n private attachRO() {\n if (!window['ResizeObserver']) return;\n\n this.ro = new ResizeObserver((ro) => {\n const { width, height } = this.host.getBoundingClientRect();\n this.currentWidth = Math.ceil(width);\n this.currentHeight = Math.ceil(height);\n this.nanoResize.emit(ro);\n });\n this.ro.observe(this.host);\n }\n\n componentWillLoad() {\n this.classNames = Array.from(this.host.classList);\n\n this.statesChanged();\n // set all class as 'not-' by deafult\n this.applyChanges(this.appliedStates);\n\n if (!this.currentWidth && !this.currentHeight) {\n readTask(() => {\n const { width, height } = this.host.getBoundingClientRect();\n this.currentWidth = Math.ceil(width);\n this.currentHeight = Math.ceil(height);\n });\n } else {\n this.assessChanges();\n }\n }\n\n connectedCallback() {\n if (!this.ro) this.attachRO();\n }\n\n disconnectedCallback() {\n if (this.ro) this.ro.disconnect();\n }\n\n render() {\n return (\n <Host>\n <slot />\n {!!this.notifyContentFit &&\n (this.contentFitX !== null || this.contentFitY !== null) && [\n !!this.contentFitX ? (\n <slot name=\"content-fit-x\" />\n ) : (\n <slot name=\"content-nofit-x\" />\n ),\n !!this.contentFitY ? (\n <slot name=\"content-fit-y\" />\n ) : (\n <slot name=\"content-nofit-y\" />\n ),\n ]}\n </Host>\n );\n }\n}\n"]}
|
@@ -1107,7 +1107,7 @@ export class Select {
|
|
1107
1107
|
},
|
1108
1108
|
"OptionInterface": {
|
1109
1109
|
"location": "import",
|
1110
|
-
"path": "
|
1110
|
+
"path": "../../interface"
|
1111
1111
|
}
|
1112
1112
|
}
|
1113
1113
|
},
|
@@ -1184,15 +1184,15 @@ export class Select {
|
|
1184
1184
|
"type": "unknown",
|
1185
1185
|
"mutable": true,
|
1186
1186
|
"complexType": {
|
1187
|
-
"original": "Partial<
|
1187
|
+
"original": "Partial<DropdownInterface>",
|
1188
1188
|
"resolved": "{ host?: HTMLNanoDropdownElement; autoOpen?: boolean; open?: boolean; handleOpenChange?: () => void; closeOnSelect?: boolean; containingElement?: HTMLElement; tetherTo?: HTMLElement; handleTetherToChange?: () => void; placement?: PopoverPlacement; distance?: number; skidding?: number; hoist?: boolean; handlePopoverOptionsChange?: () => void; dialogTitle?: string; nanoShow?: EventEmitter<any>; nanoAfterShow?: EventEmitter<any>; nanoHide?: EventEmitter<any>; nanoAfterHide?: EventEmitter<any>; eventType?: EventEmitter<any>; secondaryOpen?: (ev: CustomEvent<any>) => void; secondaryClose?: (ev: CustomEvent<any>) => void; handlePanelSelect?: (event: CustomEvent<any>) => void; show?: () => Promise<void>; hide?: () => Promise<void>; connectedCallback?: () => void; componentDidLoad?: () => void; disconnectedCallback?: () => void; render?: () => any; }",
|
1189
1189
|
"references": {
|
1190
1190
|
"Partial": {
|
1191
1191
|
"location": "global"
|
1192
1192
|
},
|
1193
|
-
"
|
1193
|
+
"DropdownInterface": {
|
1194
1194
|
"location": "import",
|
1195
|
-
"path": "
|
1195
|
+
"path": "../../interface"
|
1196
1196
|
}
|
1197
1197
|
}
|
1198
1198
|
},
|
@@ -1215,7 +1215,7 @@ export class Select {
|
|
1215
1215
|
"references": {
|
1216
1216
|
"OptionInterface": {
|
1217
1217
|
"location": "import",
|
1218
|
-
"path": "
|
1218
|
+
"path": "../../interface"
|
1219
1219
|
}
|
1220
1220
|
}
|
1221
1221
|
},
|