@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
@@ -1 +1 @@
|
|
1
|
-
{"file":"nano-hero.js","mappings":";;;;;;;;;AAAA,MAAM,OAAO,GAAG,i5QAAi5Q;;MC8Bp5Q,IAAI;;;;;IAyGP,gBAAW,GAAG;MACpB,OAAO;QACL,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,IAC9B,WAAK,KAAK,EAAC,YAAY,IACrB,YAAM,IAAI,EAAC,gBAAgB,GAAG,CAC1B,KAEN,EAAE,CACH;QACD,WAAK,KAAK,EAAC,aAAa,IACtB,YAAM,IAAI,EAAC,OAAO,GAAG,CACjB;QACN,iBAAW,KAAK,EAAC,eAAe,EAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,IACpE,0BAAiB,eAAe,IAC9B,WAAK,KAAK,EAAC,mBAAmB,IAC5B,YAAM,IAAI,EAAC,YAAY,GAAG,CACtB,CACF,EACN,0BAEI,IAAI,CAAC,mBAAmB;cACpB,6CAA6C;cAC7C,6CAA6C,IAGnD,WAAK,KAAK,EAAC,eAAe,IACxB,WAAK,KAAK,EAAC,uBAAuB,IAChC,YAAM,IAAI,EAAC,UAAU,GAAG,EACxB,eACE,YAAM,IAAI,EAAC,iBAAiB,GAAG,CAC3B,CACF,CACF,CACF,EACL,IAAI,CAAC,mBAAmB,KACvB,0BAAiB,6CAA6C,IAC5D,WAAK,KAAK,EAAC,iBAAiB,IAC1B,YAAM,IAAI,EAAC,mBAAmB,GAAG,EAChC,IAAI,CAAC,UAAU,KACd,WAAK,KAAK,EAAC,gBA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E,KAAK,EACX,UAAU,QACV,MAAM,EAAE,IAAI,CAAC,SAAS,EACtB,GAAG,EAAE,IAAI,CAAC,MAAM,IAEhB,EAAC,IAAI,CAAC,WAAW,OAAG,CACX,CACZ,EACA,CAAC,IAAI,CAAC,MAAM,IAAI;MACf,WAAK,KAAK,EAAC,eAAe,IACxB,YAAM,IAAI,EAAC,YAAY,GAAG,CACtB;MACN,EAAC,IAAI,CAAC,WAAW,OAAG;KACrB,CACG,CACF,CACD,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/hero/hero.scss?tag=nano-hero&encapsulation=shadow","./src/components/hero/hero.tsx"],"sourcesContent":["@use 'sass:map';\n@use 'sass:list';\n\n@import '../../global/style/utilities/globals';\n@import '../../global/style/nano-theme/colours';\n\n/**\nTODO - as soon as container queries hits everywhere, strip out reliance on nano-grid breakpoints\n**/\n\n:host {\n /**\n * @prop --nano-loader-base: Base colour of nano-skeleton. Default depends on theme;\n * @prop --nano-loader-tint: Tint colour of nano-skeleton. Default depends on theme;\n * @prop --theme-color: Text color. Default depends on theme;\n * @prop --theme-tint-color: Color used for bread crumbs and icons. Defaults to #{map.get($colors, lightblue)};\n * @prop --scrim-color: Color of the gradient covering the background. Default depends on theme;\n * @prop --scrim-direction: Direction of the gradient covering the background. Default what content slots are present;\n * @prop --scrim-opacity-from: Starting opactiy of the gradient covering the background. Default .25;\n * @prop --scrim-opacity-to: Final opactiy of the gradient covering the background. Default depends on `theme`;\n * @prop --quote-size: Font size of the quote. Defaults to 1.3em and grows to 3rem on the xl breakpoint;\n */\n\n --nano-loader-base: #{map.get($colors, black)};\n --nano-loader-tint: #{lighten(map.get($colors, black), 20%)};\n --theme-color: #{map.get($colors, white)};\n --theme-tint-color: #{map.get($colors, lightblue)};\n --scrim-color: 0 0 0;\n --scrim-direction: 90deg;\n --scrim-opacity-from: 0.25;\n --scrim-opacity-to: 0.7;\n --padding: 0;\n --quote-size: 1.3rem;\n\n color: var(--theme-color);\n display: block;\n container-type: inline-size;\n}\n\n:host([theme='light']) {\n --nano-loader-base: #{map.get($colors, white)};\n --nano-loader-tint: #{lighten(map.get($colors, white), 20%)};\n --theme-color: #{map.get($colors, black)};\n --scrim-color: 255 255 255;\n --scrim-opacity-from: 0.25;\n --scrim-opacity-to: 1;\n --scrim-direction: 270deg;\n\n color: var(--theme-color);\n\n .hero__primary-content {\n --color: #{map.get($colors, black)};\n }\n}\n\n.hero {\n position: relative;\n\n @container (min-width: 800px) {\n --quote-size: 3rem;\n }\n\n &--rtl {\n --scrim-direction: 270deg;\n }\n\n &--secondary:not(.hero--iconbox) {\n --scrim-direction: 0deg;\n }\n\n &__bg-wrap {\n overflow: hidden;\n }\n\n &__bg-slot {\n position: absolute;\n inset: 0;\n }\n\n &__ctas {\n @media (max-width: 52em) {\n display: none;\n }\n\n @media (max-width: 58em) {\n margin-block-end: -48px;\n }\n\n display: flex;\n justify-content: flex-end;\n padding-block: 32px 0;\n padding-inline: 32px;\n margin-block-end: -64px;\n position: relative;\n z-index: 1;\n\n ::slotted(a.button[slot='secondary-ctas']) {\n padding-block: 0.25rem !important;\n padding-inline: 0.5rem !important;\n font-size: 0.875rem !important;\n margin-block: 0 !important;\n margin-inline: 0.25rem !important;\n }\n }\n\n &__img {\n display: block;\n\n --padding: inherit;\n }\n\n &__breadcrumbs {\n display: none;\n margin-block: 20px 0;\n margin-inline: 14px;\n line-height: 14px;\n\n .hero--breadcrumb & {\n display: block;\n }\n\n @container (min-width: 800px) {\n margin-block: 0;\n margin-inline: 50px;\n max-inline-size: 50%;\n }\n\n @container (min-width: 900px) {\n margin-block: 0;\n margin-inline: 83px;\n }\n\n ::slotted(*[slot='breadcrumb']) {\n font-size: 0.85rem;\n text-transform: uppercase;\n letter-spacing: 1.5px;\n font-weight: 600;\n font-stretch: 125%;\n display: inline-block;\n margin-block-end: 16px;\n position: relative;\n z-index: 2;\n\n .hero--hasbg & {\n text-shadow: 1px 1px rgb(0 0 0 / 15%);\n }\n }\n\n ::slotted(a[slot='breadcrumb']) {\n color: var(--theme-tint-color) !important;\n cursor: pointer;\n }\n\n ::slotted(.slash[slot='breadcrumb']) {\n color: var(--theme-color);\n position: relative;\n margin-block: 0;\n margin-inline: 0.5rem;\n display: inline-block;\n }\n }\n\n &__scrim {\n position: absolute;\n inset: 0;\n z-index: 0;\n background:\n linear-gradient(\n var(--scrim-direction),\n rgb(var(--scrim-color) / var(--scrim-opacity-from)) 0%,\n rgb(var(--scrim-color) / var(--scrim-opacity-to)) 100%\n );\n\n .hero--scrim & {\n background: none;\n }\n }\n\n &__content {\n max-inline-size: 1440px;\n display: block;\n\n --grid-row-gap: 0;\n\n margin-block: 0;\n margin-inline: auto;\n position: relative;\n\n @container (min-width: 800px) {\n margin-block: 50px 0 !important;\n max-inline-size: 1540px !important;\n }\n\n @container (min-width: 900px) {\n margin-block: 83px 0 !important;\n max-inline-size: 1606px !important;\n }\n }\n\n &__primary {\n margin: 16px;\n\n .hero--breadcrumb & {\n margin-block: 0;\n margin-inline: 16px;\n }\n\n .hero--backbtn & {\n margin-inline-start: 0;\n }\n\n ::slotted(nano-icon-button[slot='back-btn']) {\n font-size: 2rem;\n }\n\n @container (min-width: 800px) {\n margin-block: 0 50px !important;\n margin-inline: 50px 0 !important;\n\n ::slotted(nano-icon-button[slot='back-btn']) {\n margin-block: 0 !important;\n margin-inline: -3rem 0 !important;\n }\n }\n\n @container (min-width: 900px) {\n margin-block: 0 83px !important;\n margin-inline: 83px 0 !important;\n }\n }\n\n &__primary-content {\n max-inline-size: 45rem;\n\n --color: #fff;\n\n display: flex;\n\n .hero--backbtn & {\n > div {\n padding-block: 10px 0;\n padding-inline: 0;\n }\n }\n\n ::slotted(h1[slot='primary-content']) {\n line-height: 26px !important;\n margin-block: 0 18px !important;\n font-size: 2rem !important;\n }\n\n @container (min-width: 800px) {\n ::slotted(h1[slot='primary-content']) {\n line-height: 31px !important;\n margin-block-end: 30px !important;\n }\n\n ::slotted(.button[slot='primary-content']) {\n margin-block-start: 20px !important;\n }\n }\n }\n\n &__secondary {\n display: none;\n block-size: 100%;\n padding-block: 0 20px;\n padding-inline: 14px;\n\n .hero--secondary & {\n display: flex;\n align-items: center;\n }\n\n @container (min-width: 800px) {\n padding-block: 0 50px;\n padding-inline: 50px;\n justify-content: flex-end;\n }\n\n @container (min-width: 900px) {\n padding-block: 0 83px;\n padding-inline: 83px;\n }\n }\n\n &__icon-box {\n background: rgb(0 0 0 / 70%);\n padding: 24px;\n inline-size: 100%;\n margin-block-end: auto;\n display: flex;\n flex-direction: column;\n color: white;\n\n @container (min-width: 800px) {\n max-inline-size: 410px;\n flex: 0 1 410px;\n }\n\n ::slotted([slot='icon-box-item']) {\n --nano-color-base: var(--theme-tint-color);\n --nano-icon-size: 32px;\n --nano-icon-margin-end: 20px;\n\n display: flex;\n align-items: center;\n font-size: 0.8125rem;\n margin-block-end: 20px;\n }\n\n ::slotted(.last[slot='icon-box-item']) {\n margin-block-end: 0;\n }\n }\n\n &__quote-content {\n margin-block-start: auto;\n text-align: center;\n inline-size: 100%;\n\n @container (min-width: 800px) {\n max-inline-size: 500px;\n flex: 0 1 500px;\n text-align: initial;\n }\n }\n\n &__quote {\n &::before,\n &::after {\n content: '\"';\n font-size: var(--quote-size);\n font-weight: 700;\n font-style: italic;\n line-height: 0;\n color: #abb6b8;\n display: inline;\n position: relative;\n }\n\n ::slotted([slot='quote']) {\n font-size: var(--quote-size);\n font-weight: 300;\n font-style: italic;\n display: inline;\n }\n }\n\n &__quote-author {\n text-align: end;\n font-size: 1rem;\n opacity: 0.8;\n }\n\n &--sub {\n .hero__content {\n @container (min-width: 800px) {\n margin-block-start: 40px;\n\n .hero__primary {\n margin-block: 0 40px;\n margin-inline: 50px 0;\n }\n\n .hero__secondary {\n padding-block: 0 50px;\n padding-inline: 40px 50px;\n }\n\n ::slotted(.button[slot='primary-content']) {\n margin-block-start: 8px !important;\n }\n\n ::slotted(h1[slot='primary-content']) {\n margin-block-end: 18px !important;\n }\n }\n\n @container (min-width: 900px) {\n .hero__primary {\n margin-block: 0 40px;\n margin-inline: 83px 0;\n }\n\n .hero__secondary {\n padding-block: 0 83px;\n padding-inline: 40px 83px;\n }\n }\n }\n }\n}\n","import {\n Component,\n Prop,\n h,\n ComponentInterface,\n VNode,\n State,\n Element,\n Watch,\n Host,\n} from '@stencil/core';\n/**\n * Hero components are designed to be used once per content page to add visual impact to the introductory section of a page.\n * @slot primary-content - title, leading paragraph and CTA\n * @slot breadcrumb - each individual bread crumb should be assigned seperately\n * @slot secondary-content - free form secondary content.\n * @slot icon-box - free form icon box container\n * @slot icon-box-item - seperate icon box items. Designed to contain 1 icon and 1 text element.\n * @slot secondary-ctas - CTAs. each individual button should be assigned seperately\n * @slot quote - quote content\n * @slot quote-author - quote author\n * @slot scrim - optional background overlay (e.g. faded colour or gradient)\n * @slot background - custom background. Only active when img-src is empty\n * @slot back-btn - a back button.\n */\n@Component({\n tag: 'nano-hero',\n styleUrl: 'hero.scss',\n shadow: true,\n})\nexport class Hero implements ComponentInterface {\n private mo?: MutationObserver;\n\n @Element() host: HTMLNanoHeroElement;\n\n @State() hasIconBox: boolean;\n @State() hasScrim: boolean;\n @State() hasSecondaryContent: boolean;\n @State() hasQuote: boolean;\n @State() hasBg: boolean;\n @State() hasBackBtn: boolean;\n @State() hasCtas: boolean;\n @State() breadCrumbs: Element[];\n @Watch('breadCrumbs')\n breadCrumbChange() {\n // safari doesn't support ::slotted()::after ... so this :/\n this.breadCrumbs\n .filter(\n (crumb) =>\n crumb.tagName === 'A' &&\n !crumb.nextElementSibling.classList.contains('slash')\n )\n .forEach((crumb) => {\n crumb.insertAdjacentHTML(\n 'afterend',\n '<span slot=\"breadcrumb\" class=\"slash\">/</span>'\n );\n });\n }\n @State() iconBoxItems: Element[];\n @Watch('iconBoxItems')\n iconBoxItemChange() {\n this.iconBoxItems.forEach((item) => item.classList.remove('last'));\n if (\n this.iconBoxItems[this.iconBoxItems.length - 1] &&\n this.iconBoxItems[this.iconBoxItems.length - 1].classList\n )\n this.iconBoxItems[this.iconBoxItems.length - 1].classList.add('last');\n }\n\n /** src for background image. For more control use the `background` slot instead. */\n @Prop() imgSrc?: string;\n\n /** Optional list string providing media sizes with corresponding image srcs.\n * i.e. show img-x at 300px wide. Format `srcSet=\"200w src/imgSmall.jpg, 500h src/imgMed.png\"` */\n @Prop() imgSrcSet?: string = null;\n\n /** The Break Point width that the hero component will change to the large view. Defaults to the XL grid size (900px) */\n @Prop() largeScreenBP: number = 900;\n\n /** Base style for the hero. Either 'light' (white bg / dark text), or 'dark' (dark bg / white text) */\n @Prop() theme: 'dark' | 'light' = 'dark';\n\n /** Set the content structure level of the hero. Defaults to 'top' */\n @Prop() level: 'top' | 'sub' = 'top';\n\n private slotChangeObserver() {\n if (!window['MutationObserver']) return;\n\n if (this.mo) this.mo.disconnect();\n const mo = (this.mo = new MutationObserver(() =>\n this.processSlottedContent()\n ));\n mo.observe(this.host, { childList: true });\n }\n\n // Event handlers\n\n private processSlottedContent() {\n this.hasCtas = !!this.host.querySelector('[slot=\"secondary-ctas\"]');\n this.iconBoxItems = Array.from(\n this.host.querySelectorAll('[slot=\"icon-box-item\"]')\n );\n this.hasIconBox =\n !!this.host.querySelector('[slot=\"icon-box\"]') ||\n !!this.iconBoxItems.length;\n this.hasScrim = !!this.host.querySelector('[slot=\"scrim\"]');\n this.breadCrumbs = Array.from(\n this.host.querySelectorAll('[slot=\"breadcrumb\"]')\n );\n this.hasSecondaryContent =\n !!this.host.querySelector('[slot=\"icon-box\"]') ||\n !!this.host.querySelector('[slot=\"quote\"]') ||\n !!this.host.querySelector('[slot=\"icon-box-item\"]') ||\n !!this.host.querySelector('[slot=\"secondary-content\"]');\n this.hasBg =\n !!this.host.querySelector('[slot=\"background\"]') || !!this.imgSrc;\n this.hasBackBtn = !!this.host.querySelector('[slot=\"back-btn\"]');\n this.hasQuote = !!this.host.querySelector('[slot=\"quote\"]');\n }\n\n // Component lifecycle\n\n disconnectedCallback() {\n if (this.mo) this.mo.disconnect();\n }\n\n componentDidLoad() {\n this.slotChangeObserver();\n }\n\n componentWillLoad() {\n this.processSlottedContent();\n }\n\n private HeroContent = (): VNode[] => {\n return [\n !this.hasIconBox && this.hasCtas ? (\n <div class=\"hero__ctas\">\n <slot name=\"secondary-ctas\" />\n </div>\n ) : (\n ''\n ),\n <div class=\"hero__scrim\">\n <slot name=\"scrim\" />\n </div>,\n <nano-grid class=\"hero__content\" xlCols={2} xlSize={this.largeScreenBP}>\n <div grid-states=\"xl-col-span-2\">\n <div class=\"hero__breadcrumbs\">\n <slot name=\"breadcrumb\" />\n </div>\n </div>\n <div\n grid-states={\n this.hasSecondaryContent\n ? 'xl-col-span-1 xl-col-start-1 xl-row-start-2'\n : 'xl-col-span-2 xl-col-start-1 xl-row-start-2'\n }\n >\n <div class=\"hero__primary\">\n <div class=\"hero__primary-content\">\n <slot name=\"back-btn\" />\n <div>\n <slot name=\"primary-content\" />\n </div>\n </div>\n </div>\n </div>\n {this.hasSecondaryContent && (\n <div grid-states=\"xl-col-span-1 xl-col-start-2 xl-row-start-2\">\n <div class=\"hero__secondary\">\n <slot name=\"secondary-content\" />\n {this.hasIconBox && (\n <div class=\"hero__icon-box\">\n <slot name=\"icon-box\" />\n <slot name=\"icon-box-item\" />\n </div>\n )}\n {this.hasQuote && (\n <div class=\"hero__quote-content\">\n <span class=\"hero__quote\">\n <slot name=\"quote\" />\n </span>\n <div class=\"hero__quote-author\">\n <slot name=\"quote-author\" />\n </div>\n </div>\n )}\n </div>\n </div>\n )}\n </nano-grid>,\n ];\n };\n\n render() {\n const rtl =\n this.host.dir === 'rtl' ||\n (this.host.ownerDocument as Document).dir === 'rtl';\n\n return (\n <Host>\n <div\n class={{\n hero: true,\n 'hero--light': this.theme === 'light',\n 'hero--secondary': this.hasSecondaryContent,\n 'hero--iconbox': this.hasIconBox,\n 'hero--rtl': rtl,\n 'hero--scrim': this.hasScrim,\n 'hero--breadcrumb': !!this.breadCrumbs.length,\n 'hero--hasbg': this.hasBg,\n 'hero--backbtn': this.hasBackBtn,\n 'hero--sub': this.level === 'sub',\n }}\n >\n <div class=\"hero__bg-wrap\">\n {!!this.imgSrc && (\n <nano-img\n class=\"hero__img\"\n lazy={false}\n background\n srcSet={this.imgSrcSet}\n src={this.imgSrc}\n >\n <this.HeroContent />\n </nano-img>\n )}\n {!this.imgSrc && [\n <div class=\"hero__bg-slot\">\n <slot name=\"background\" />\n </div>,\n <this.HeroContent />,\n ]}\n </div>\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
|
1
|
+
{"file":"nano-hero.js","mappings":";;;;;;;;;AAAA,MAAM,OAAO,GAAG,22QAA22Q;;MC8B92Q,IAAI;;;;;IAyGP,gBAAW,GAAG;MACpB,OAAO;QACL,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,IAC9B,WAAK,KAAK,EAAC,YAAY,IACrB,YAAM,IAAI,EAAC,gBAAgB,GAAG,CAC1B,KAEN,EAAE,CACH;QACD,WAAK,KAAK,EAAC,aAAa,IACtB,YAAM,IAAI,EAAC,OAAO,GAAG,CACjB;QACN,iBAAW,KAAK,EAAC,eAAe,EAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,IACpE,0BAAiB,eAAe,IAC9B,WAAK,KAAK,EAAC,mBAAmB,IAC5B,YAAM,IAAI,EAAC,YAAY,GAAG,CACtB,CACF,EACN,0BAEI,IAAI,CAAC,mBAAmB;cACpB,6CAA6C;cAC7C,6CAA6C,IAGnD,WAAK,KAAK,EAAC,eAAe,IACxB,WAAK,KAAK,EAAC,uBAAuB,IAChC,YAAM,IAAI,EAAC,UAAU,GAAG,EACxB,eACE,YAAM,IAAI,EAAC,iBAAiB,GAAG,CAC3B,CACF,CACF,CACF,EACL,IAAI,CAAC,mBAAmB,KACvB,0BAAiB,6CAA6C,IAC5D,WAAK,KAAK,EAAC,iBAAiB,IAC1B,YA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ACvB,CAAC,CAAC,IAAI,CAAC,MAAM,KACZ,gBACE,KAAK,EAAC,WAAW,EACjB,IAAI,EAAE,KAAK,EACX,UAAU,QACV,MAAM,EAAE,IAAI,CAAC,SAAS,EACtB,GAAG,EAAE,IAAI,CAAC,MAAM,IAEhB,EAAC,IAAI,CAAC,WAAW,OAAG,CACX,CACZ,EACA,CAAC,IAAI,CAAC,MAAM,IAAI;MACf,WAAK,KAAK,EAAC,eAAe,IACxB,YAAM,IAAI,EAAC,YAAY,GAAG,CACtB;MACN,EAAC,IAAI,CAAC,WAAW,OAAG;KACrB,CACG,CACF,CACD,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/hero/hero.scss?tag=nano-hero&encapsulation=shadow","./src/components/hero/hero.tsx"],"sourcesContent":["@use 'sass:map';\n@use 'sass:list';\n\n@import '../../global/style/utilities/globals';\n@import '../../global/style/nano-theme/colours';\n\n/**\nTODO - as soon as container queries hits everywhere, strip out reliance on nano-grid breakpoints\n**/\n\n:host {\n /**\n * @prop --nano-loader-base: Base colour of nano-skeleton. Default depends on theme;\n * @prop --nano-loader-tint: Tint colour of nano-skeleton. Default depends on theme;\n * @prop --theme-color: Text color. Default depends on theme;\n * @prop --theme-tint-color: Color used for bread crumbs and icons. Defaults to #{map.get($colors, lightblue)};\n * @prop --scrim-color: Color of the gradient covering the background. Default depends on theme;\n * @prop --scrim-direction: Direction of the gradient covering the background. Default what content slots are present;\n * @prop --scrim-opacity-from: Starting opactiy of the gradient covering the background. Default .25;\n * @prop --scrim-opacity-to: Final opactiy of the gradient covering the background. Default depends on `theme`;\n * @prop --quote-size: Font size of the quote. Defaults to 1.3em and grows to 3rem on the xl breakpoint;\n */\n\n --nano-loader-base: #{map.get($colors, black)};\n --nano-loader-tint: #{lighten(map.get($colors, black), 20%)};\n --theme-color: #{map.get($colors, white)};\n --theme-tint-color: #{map.get($colors, lightblue)};\n --scrim-color: 0 0 0;\n --scrim-direction: 90deg;\n --scrim-opacity-from: 0.25;\n --scrim-opacity-to: 0.7;\n --padding: 0;\n --quote-size: 1.3rem;\n\n color: var(--theme-color);\n display: block;\n container-type: inline-size;\n}\n\n:host([theme='light']) {\n --nano-loader-base: #{map.get($colors, white)};\n --nano-loader-tint: #{lighten(map.get($colors, white), 20%)};\n --theme-color: #{map.get($colors, black)};\n --scrim-color: 255 255 255;\n --scrim-opacity-from: 0.25;\n --scrim-opacity-to: 1;\n --scrim-direction: 270deg;\n\n color: var(--theme-color);\n\n .hero__primary-content {\n --color: #{map.get($colors, black)};\n }\n}\n\n.hero {\n position: relative;\n\n @container (min-width: 800px) {\n --quote-size: 3rem;\n }\n\n &--rtl {\n --scrim-direction: 270deg;\n }\n\n &--secondary:not(.hero--iconbox) {\n --scrim-direction: 0deg;\n }\n\n &__bg-wrap {\n overflow: hidden;\n }\n\n &__bg-slot {\n position: absolute;\n inset: 0;\n }\n\n &__ctas {\n @media (max-width: 52em) {\n display: none;\n }\n\n @media (max-width: 58em) {\n margin-block-end: -48px;\n }\n\n display: flex;\n justify-content: flex-end;\n padding-block: 32px 0;\n padding-inline: 32px;\n margin-block-end: -64px;\n position: relative;\n z-index: 1;\n\n ::slotted(a.button[slot='secondary-ctas']) {\n padding-inline: 0.5rem !important;\n font-size: 0.875rem !important;\n margin-block: 0 !important;\n margin-inline: 0.25rem !important;\n }\n }\n\n &__img {\n display: block;\n\n --padding: inherit;\n }\n\n &__breadcrumbs {\n display: none;\n margin-block: 20px 0;\n margin-inline: 14px;\n line-height: 14px;\n\n .hero--breadcrumb & {\n display: block;\n }\n\n @container (min-width: 800px) {\n margin-block: 0;\n margin-inline: 50px;\n max-inline-size: 50%;\n }\n\n @container (min-width: 900px) {\n margin-block: 0;\n margin-inline: 83px;\n }\n\n ::slotted(*[slot='breadcrumb']) {\n font-size: 0.85rem;\n text-transform: uppercase;\n letter-spacing: 1.5px;\n font-weight: 600;\n font-stretch: 125%;\n display: inline-block;\n margin-block-end: 16px;\n position: relative;\n z-index: 2;\n\n .hero--hasbg & {\n text-shadow: 1px 1px rgb(0 0 0 / 15%);\n }\n }\n\n ::slotted(a[slot='breadcrumb']) {\n color: var(--theme-tint-color) !important;\n cursor: pointer;\n }\n\n ::slotted(.slash[slot='breadcrumb']) {\n color: var(--theme-color);\n position: relative;\n margin-block: 0;\n margin-inline: 0.5rem;\n display: inline-block;\n }\n }\n\n &__scrim {\n position: absolute;\n inset: 0;\n z-index: 0;\n background:\n linear-gradient(\n var(--scrim-direction),\n rgb(var(--scrim-color) / var(--scrim-opacity-from)) 0%,\n rgb(var(--scrim-color) / var(--scrim-opacity-to)) 100%\n );\n\n .hero--scrim & {\n background: none;\n }\n }\n\n &__content {\n max-inline-size: 1440px;\n display: block;\n\n --grid-row-gap: 0;\n\n margin-block: 0;\n margin-inline: auto;\n position: relative;\n\n @container (min-width: 800px) {\n margin-block: 50px 0 !important;\n max-inline-size: 1540px !important;\n }\n\n @container (min-width: 900px) {\n margin-block: 83px 0 !important;\n max-inline-size: 1606px !important;\n }\n }\n\n &__primary {\n margin: 16px;\n\n .hero--breadcrumb & {\n margin-block: 0;\n margin-inline: 16px;\n }\n\n .hero--backbtn & {\n margin-inline-start: 0;\n }\n\n ::slotted(nano-icon-button[slot='back-btn']) {\n font-size: 2rem;\n }\n\n @container (min-width: 800px) {\n margin-block: 0 50px !important;\n margin-inline: 50px 0 !important;\n\n ::slotted(nano-icon-button[slot='back-btn']) {\n margin-block: 0 !important;\n margin-inline: -3rem 0 !important;\n }\n }\n\n @container (min-width: 900px) {\n margin-block: 0 83px !important;\n margin-inline: 83px 0 !important;\n }\n }\n\n &__primary-content {\n max-inline-size: 45rem;\n\n --color: #fff;\n\n display: flex;\n\n .hero--backbtn & {\n > div {\n padding-block: 10px 0;\n padding-inline: 0;\n }\n }\n\n ::slotted(h1[slot='primary-content']) {\n line-height: 26px !important;\n margin-block: 0 18px !important;\n font-size: 2rem !important;\n }\n\n @container (min-width: 800px) {\n ::slotted(h1[slot='primary-content']) {\n line-height: 31px !important;\n margin-block-end: 30px !important;\n }\n\n ::slotted(.button[slot='primary-content']) {\n margin-block-start: 20px !important;\n }\n }\n }\n\n &__secondary {\n display: none;\n block-size: 100%;\n padding-block: 0 20px;\n padding-inline: 14px;\n\n .hero--secondary & {\n display: flex;\n align-items: center;\n }\n\n @container (min-width: 800px) {\n padding-block: 0 50px;\n padding-inline: 50px;\n justify-content: flex-end;\n }\n\n @container (min-width: 900px) {\n padding-block: 0 83px;\n padding-inline: 83px;\n }\n }\n\n &__icon-box {\n background: rgb(0 0 0 / 70%);\n padding: 24px;\n inline-size: 100%;\n margin-block-end: auto;\n display: flex;\n flex-direction: column;\n color: white;\n\n @container (min-width: 800px) {\n max-inline-size: 410px;\n flex: 0 1 410px;\n }\n\n ::slotted([slot='icon-box-item']) {\n --nano-color-base: var(--theme-tint-color);\n --nano-icon-size: 32px;\n --nano-icon-margin-end: 20px;\n\n display: flex;\n align-items: center;\n font-size: 0.8125rem;\n margin-block-end: 20px;\n }\n\n ::slotted(.last[slot='icon-box-item']) {\n margin-block-end: 0;\n }\n }\n\n &__quote-content {\n margin-block-start: auto;\n text-align: center;\n inline-size: 100%;\n\n @container (min-width: 800px) {\n max-inline-size: 500px;\n flex: 0 1 500px;\n text-align: initial;\n }\n }\n\n &__quote {\n &::before,\n &::after {\n content: '\"';\n font-size: var(--quote-size);\n font-weight: 700;\n font-style: italic;\n line-height: 0;\n color: #abb6b8;\n display: inline;\n position: relative;\n }\n\n ::slotted([slot='quote']) {\n font-size: var(--quote-size);\n font-weight: 300;\n font-style: italic;\n display: inline;\n }\n }\n\n &__quote-author {\n text-align: end;\n font-size: 1rem;\n opacity: 0.8;\n }\n\n &--sub {\n .hero__content {\n @container (min-width: 800px) {\n margin-block-start: 40px;\n\n .hero__primary {\n margin-block: 0 40px;\n margin-inline: 50px 0;\n }\n\n .hero__secondary {\n padding-block: 0 50px;\n padding-inline: 40px 50px;\n }\n\n ::slotted(.button[slot='primary-content']) {\n margin-block-start: 8px !important;\n }\n\n ::slotted(h1[slot='primary-content']) {\n margin-block-end: 18px !important;\n }\n }\n\n @container (min-width: 900px) {\n .hero__primary {\n margin-block: 0 40px;\n margin-inline: 83px 0;\n }\n\n .hero__secondary {\n padding-block: 0 83px;\n padding-inline: 40px 83px;\n }\n }\n }\n }\n}\n","import {\n Component,\n Prop,\n h,\n ComponentInterface,\n VNode,\n State,\n Element,\n Watch,\n Host,\n} from '@stencil/core';\n/**\n * Hero components are designed to be used once per content page to add visual impact to the introductory section of a page.\n * @slot primary-content - title, leading paragraph and CTA\n * @slot breadcrumb - each individual bread crumb should be assigned seperately\n * @slot secondary-content - free form secondary content.\n * @slot icon-box - free form icon box container\n * @slot icon-box-item - seperate icon box items. Designed to contain 1 icon and 1 text element.\n * @slot secondary-ctas - CTAs. each individual button should be assigned seperately\n * @slot quote - quote content\n * @slot quote-author - quote author\n * @slot scrim - optional background overlay (e.g. faded colour or gradient)\n * @slot background - custom background. Only active when img-src is empty\n * @slot back-btn - a back button.\n */\n@Component({\n tag: 'nano-hero',\n styleUrl: 'hero.scss',\n shadow: true,\n})\nexport class Hero implements ComponentInterface {\n private mo?: MutationObserver;\n\n @Element() host: HTMLNanoHeroElement;\n\n @State() hasIconBox: boolean;\n @State() hasScrim: boolean;\n @State() hasSecondaryContent: boolean;\n @State() hasQuote: boolean;\n @State() hasBg: boolean;\n @State() hasBackBtn: boolean;\n @State() hasCtas: boolean;\n @State() breadCrumbs: Element[];\n @Watch('breadCrumbs')\n breadCrumbChange() {\n // safari doesn't support ::slotted()::after ... so this :/\n this.breadCrumbs\n .filter(\n (crumb) =>\n crumb.tagName === 'A' &&\n !crumb.nextElementSibling.classList.contains('slash')\n )\n .forEach((crumb) => {\n crumb.insertAdjacentHTML(\n 'afterend',\n '<span slot=\"breadcrumb\" class=\"slash\">/</span>'\n );\n });\n }\n @State() iconBoxItems: Element[];\n @Watch('iconBoxItems')\n iconBoxItemChange() {\n this.iconBoxItems.forEach((item) => item.classList.remove('last'));\n if (\n this.iconBoxItems[this.iconBoxItems.length - 1] &&\n this.iconBoxItems[this.iconBoxItems.length - 1].classList\n )\n this.iconBoxItems[this.iconBoxItems.length - 1].classList.add('last');\n }\n\n /** src for background image. For more control use the `background` slot instead. */\n @Prop() imgSrc?: string;\n\n /** Optional list string providing media sizes with corresponding image srcs.\n * i.e. show img-x at 300px wide. Format `srcSet=\"200w src/imgSmall.jpg, 500h src/imgMed.png\"` */\n @Prop() imgSrcSet?: string = null;\n\n /** The Break Point width that the hero component will change to the large view. Defaults to the XL grid size (900px) */\n @Prop() largeScreenBP: number = 900;\n\n /** Base style for the hero. Either 'light' (white bg / dark text), or 'dark' (dark bg / white text) */\n @Prop() theme: 'dark' | 'light' = 'dark';\n\n /** Set the content structure level of the hero. Defaults to 'top' */\n @Prop() level: 'top' | 'sub' = 'top';\n\n private slotChangeObserver() {\n if (!window['MutationObserver']) return;\n\n if (this.mo) this.mo.disconnect();\n const mo = (this.mo = new MutationObserver(() =>\n this.processSlottedContent()\n ));\n mo.observe(this.host, { childList: true });\n }\n\n // Event handlers\n\n private processSlottedContent() {\n this.hasCtas = !!this.host.querySelector('[slot=\"secondary-ctas\"]');\n this.iconBoxItems = Array.from(\n this.host.querySelectorAll('[slot=\"icon-box-item\"]')\n );\n this.hasIconBox =\n !!this.host.querySelector('[slot=\"icon-box\"]') ||\n !!this.iconBoxItems.length;\n this.hasScrim = !!this.host.querySelector('[slot=\"scrim\"]');\n this.breadCrumbs = Array.from(\n this.host.querySelectorAll('[slot=\"breadcrumb\"]')\n );\n this.hasSecondaryContent =\n !!this.host.querySelector('[slot=\"icon-box\"]') ||\n !!this.host.querySelector('[slot=\"quote\"]') ||\n !!this.host.querySelector('[slot=\"icon-box-item\"]') ||\n !!this.host.querySelector('[slot=\"secondary-content\"]');\n this.hasBg =\n !!this.host.querySelector('[slot=\"background\"]') || !!this.imgSrc;\n this.hasBackBtn = !!this.host.querySelector('[slot=\"back-btn\"]');\n this.hasQuote = !!this.host.querySelector('[slot=\"quote\"]');\n }\n\n // Component lifecycle\n\n disconnectedCallback() {\n if (this.mo) this.mo.disconnect();\n }\n\n componentDidLoad() {\n this.slotChangeObserver();\n }\n\n componentWillLoad() {\n this.processSlottedContent();\n }\n\n private HeroContent = (): VNode[] => {\n return [\n !this.hasIconBox && this.hasCtas ? (\n <div class=\"hero__ctas\">\n <slot name=\"secondary-ctas\" />\n </div>\n ) : (\n ''\n ),\n <div class=\"hero__scrim\">\n <slot name=\"scrim\" />\n </div>,\n <nano-grid class=\"hero__content\" xlCols={2} xlSize={this.largeScreenBP}>\n <div grid-states=\"xl-col-span-2\">\n <div class=\"hero__breadcrumbs\">\n <slot name=\"breadcrumb\" />\n </div>\n </div>\n <div\n grid-states={\n this.hasSecondaryContent\n ? 'xl-col-span-1 xl-col-start-1 xl-row-start-2'\n : 'xl-col-span-2 xl-col-start-1 xl-row-start-2'\n }\n >\n <div class=\"hero__primary\">\n <div class=\"hero__primary-content\">\n <slot name=\"back-btn\" />\n <div>\n <slot name=\"primary-content\" />\n </div>\n </div>\n </div>\n </div>\n {this.hasSecondaryContent && (\n <div grid-states=\"xl-col-span-1 xl-col-start-2 xl-row-start-2\">\n <div class=\"hero__secondary\">\n <slot name=\"secondary-content\" />\n {this.hasIconBox && (\n <div class=\"hero__icon-box\">\n <slot name=\"icon-box\" />\n <slot name=\"icon-box-item\" />\n </div>\n )}\n {this.hasQuote && (\n <div class=\"hero__quote-content\">\n <span class=\"hero__quote\">\n <slot name=\"quote\" />\n </span>\n <div class=\"hero__quote-author\">\n <slot name=\"quote-author\" />\n </div>\n </div>\n )}\n </div>\n </div>\n )}\n </nano-grid>,\n ];\n };\n\n render() {\n const rtl =\n this.host.dir === 'rtl' ||\n (this.host.ownerDocument as Document).dir === 'rtl';\n\n return (\n <Host>\n <div\n class={{\n hero: true,\n 'hero--light': this.theme === 'light',\n 'hero--secondary': this.hasSecondaryContent,\n 'hero--iconbox': this.hasIconBox,\n 'hero--rtl': rtl,\n 'hero--scrim': this.hasScrim,\n 'hero--breadcrumb': !!this.breadCrumbs.length,\n 'hero--hasbg': this.hasBg,\n 'hero--backbtn': this.hasBackBtn,\n 'hero--sub': this.level === 'sub',\n }}\n >\n <div class=\"hero__bg-wrap\">\n {!!this.imgSrc && (\n <nano-img\n class=\"hero__img\"\n lazy={false}\n background\n srcSet={this.imgSrcSet}\n src={this.imgSrc}\n >\n <this.HeroContent />\n </nano-img>\n )}\n {!this.imgSrc && [\n <div class=\"hero__bg-slot\">\n <slot name=\"background\" />\n </div>,\n <this.HeroContent />,\n ]}\n </div>\n </div>\n </Host>\n );\n }\n}\n"],"version":3}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
2
|
+
|
3
|
+
interface NanoIntersectionObserve extends Components.NanoIntersectionObserve, HTMLElement {}
|
4
|
+
export const NanoIntersectionObserve: {
|
5
|
+
prototype: NanoIntersectionObserve;
|
6
|
+
new (): NanoIntersectionObserve;
|
7
|
+
};
|
8
|
+
/**
|
9
|
+
* Used to define this component and all nested components recursively.
|
10
|
+
*/
|
11
|
+
export const defineCustomElement: () => void;
|
@@ -0,0 +1,149 @@
|
|
1
|
+
/*!
|
2
|
+
* Web Components for Nanopore digital Web Apps
|
3
|
+
*/
|
4
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
5
|
+
import { f as findScrollParent } from './scroll-parent.js';
|
6
|
+
|
7
|
+
const IntersectionObserve = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
8
|
+
constructor() {
|
9
|
+
super();
|
10
|
+
this.__registerHost();
|
11
|
+
this.__attachShadow();
|
12
|
+
this.nanoIntersectionChange = createEvent(this, "nanoIntersectionChange", 7);
|
13
|
+
this.nanoIntersecting = createEvent(this, "nanoIntersecting", 7);
|
14
|
+
this.nanoNotIntersecting = createEvent(this, "nanoNotIntersecting", 7);
|
15
|
+
this.ioCallback = (entries) => {
|
16
|
+
entries.forEach((entry) => {
|
17
|
+
this.nanoIntersectionChange.emit(entry);
|
18
|
+
if (entry.isIntersecting)
|
19
|
+
this.nanoIntersecting.emit(entry);
|
20
|
+
if (!entry.isIntersecting)
|
21
|
+
this.nanoNotIntersecting.emit(entry);
|
22
|
+
});
|
23
|
+
};
|
24
|
+
this.handleSlotChange = () => {
|
25
|
+
this.addIO();
|
26
|
+
};
|
27
|
+
this.root = 'auto';
|
28
|
+
this.rootMargin = undefined;
|
29
|
+
this.threshold = undefined;
|
30
|
+
}
|
31
|
+
get observerOptions() {
|
32
|
+
const opts = {};
|
33
|
+
if (!!this._root)
|
34
|
+
opts.root = this._root;
|
35
|
+
if (this.rootMargin)
|
36
|
+
opts.rootMargin = this.rootMargin;
|
37
|
+
if (this.threshold)
|
38
|
+
opts.threshold = this._threshold;
|
39
|
+
return opts;
|
40
|
+
}
|
41
|
+
get elements() {
|
42
|
+
const slotted = this.defaultSlot?.assignedElements() || [];
|
43
|
+
return slotted.flatMap((el) => {
|
44
|
+
const style = getComputedStyle(el);
|
45
|
+
if (style.display.includes('contents'))
|
46
|
+
return Array.from(el.children);
|
47
|
+
else
|
48
|
+
return el;
|
49
|
+
});
|
50
|
+
}
|
51
|
+
handleRootChange() {
|
52
|
+
if (!this.root) {
|
53
|
+
this._root = undefined;
|
54
|
+
this.removeIO();
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
let newRoot;
|
58
|
+
if (this.root === 'auto') {
|
59
|
+
// try to find nearest scrolling parent
|
60
|
+
newRoot = findScrollParent(this.host);
|
61
|
+
}
|
62
|
+
else if (this.root === 'root') {
|
63
|
+
newRoot = undefined;
|
64
|
+
}
|
65
|
+
else {
|
66
|
+
// root is set explicitly
|
67
|
+
newRoot = this.root;
|
68
|
+
}
|
69
|
+
// if it's the document - unset as that's IO's default
|
70
|
+
if (newRoot === document.documentElement)
|
71
|
+
newRoot = undefined;
|
72
|
+
// if new root is what we already have - ignore
|
73
|
+
if (newRoot === this._root)
|
74
|
+
return;
|
75
|
+
// cache and setup io
|
76
|
+
this._root = newRoot;
|
77
|
+
this.addIO();
|
78
|
+
}
|
79
|
+
handleThresholdChange() {
|
80
|
+
if (!this.threshold) {
|
81
|
+
this._threshold = undefined;
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
if (this.threshold.includes(',')) {
|
85
|
+
this._threshold = this.threshold
|
86
|
+
.split(',')
|
87
|
+
.map((numStr) => Number(numStr));
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
this._threshold = Number(this.threshold);
|
91
|
+
}
|
92
|
+
addIO() {
|
93
|
+
if (!window['IntersectionObserver'] || !this.elements?.length)
|
94
|
+
return;
|
95
|
+
if (this.io)
|
96
|
+
this.removeIO();
|
97
|
+
const io = (this.io = new IntersectionObserver(this.ioCallback, this.observerOptions));
|
98
|
+
this.elements?.forEach((el) => {
|
99
|
+
io.observe(el);
|
100
|
+
});
|
101
|
+
}
|
102
|
+
removeIO() {
|
103
|
+
if (!this.io)
|
104
|
+
return;
|
105
|
+
this.io.disconnect();
|
106
|
+
this.io = undefined;
|
107
|
+
}
|
108
|
+
connectedCallback() {
|
109
|
+
this.handleThresholdChange();
|
110
|
+
this.handleRootChange();
|
111
|
+
}
|
112
|
+
disconnectedCallback() {
|
113
|
+
this.removeIO();
|
114
|
+
this.root = this._root = undefined;
|
115
|
+
}
|
116
|
+
render() {
|
117
|
+
return (h("slot", { ref: (slot) => (this.defaultSlot = slot), onSlotchange: this.handleSlotChange }));
|
118
|
+
}
|
119
|
+
get host() { return this; }
|
120
|
+
static get watchers() { return {
|
121
|
+
"root": ["handleRootChange"],
|
122
|
+
"threshold": ["handleThresholdChange"]
|
123
|
+
}; }
|
124
|
+
static get style() { return "nano-intersection-observe { display: contents }"; }
|
125
|
+
}, [1, "nano-intersection-observe", {
|
126
|
+
"root": [1],
|
127
|
+
"rootMargin": [1, "root-margin"],
|
128
|
+
"threshold": [1]
|
129
|
+
}]);
|
130
|
+
function defineCustomElement$1() {
|
131
|
+
if (typeof customElements === "undefined") {
|
132
|
+
return;
|
133
|
+
}
|
134
|
+
const components = ["nano-intersection-observe"];
|
135
|
+
components.forEach(tagName => { switch (tagName) {
|
136
|
+
case "nano-intersection-observe":
|
137
|
+
if (!customElements.get(tagName)) {
|
138
|
+
customElements.define(tagName, IntersectionObserve);
|
139
|
+
}
|
140
|
+
break;
|
141
|
+
} });
|
142
|
+
}
|
143
|
+
|
144
|
+
const NanoIntersectionObserve = IntersectionObserve;
|
145
|
+
const defineCustomElement = defineCustomElement$1;
|
146
|
+
|
147
|
+
export { NanoIntersectionObserve, defineCustomElement };
|
148
|
+
|
149
|
+
//# sourceMappingURL=nano-intersection-observe.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"file":"nano-intersection-observe.js","mappings":";;;;;;MAqBa,mBAAmB;;;;;;;;IAuGtB,eAAU,GAAiC,CAAC,OAAO;MACzD,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK;QACpB,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,KAAK,CAAC,cAAc;UAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5D,IAAI,CAAC,KAAK,CAAC,cAAc;UAAE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;OACjE,CAAC,CAAC;KACJ,CAAC;IAEM,qBAAgB,GAAG;MACzB,IAAI,CAAC,KAAK,EAAE,CAAC;KACd,CAAC;gBAnFmD,MAAM;;;;EAxB3D,IAAI,eAAe;IACjB,MAAM,IAAI,GAA6B,EAAE,CAAC;IAE1C,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK;MAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;IACzC,IAAI,IAAI,CAAC,UAAU;MAAE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACvD,IAAI,IAAI,C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,YAAY,EAAE,IAAI,CAAC,gBAAgB,GACnC,EACF;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/intersection-observe/intersection-observe.tsx"],"sourcesContent":["import {\n Component,\n h,\n Prop,\n Element,\n Watch,\n ComponentInterface,\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"],"version":3}
|
@@ -222,7 +222,7 @@ const ResizeObserve = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
222
222
|
"currentHeight": ["dimensionChanged"],
|
223
223
|
"currentWidth": ["dimensionChanged"]
|
224
224
|
}; }
|
225
|
-
static get style() { return "nano-resize-observe { display:
|
225
|
+
static get style() { return "nano-resize-observe { display: block }"; }
|
226
226
|
}, [1, "nano-resize-observe", {
|
227
227
|
"notifyContentFit": [1, "notify-content-fit"],
|
228
228
|
"states": [1],
|
@@ -1 +1 @@
|
|
1
|
-
{"file":"resize-observe.js","mappings":";;;;;MAqCa,aAAa;;;;;;;;;IAGhB,YAAO,GAAG,KAAK,CAAC;IA8IhB,kBAAa,GAAG;MACtB,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,aAAa;QAAE,OAAO;MACtD,QAAQ,CAAC,MAAM,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;QAC9C,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,OAA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a,EAAE,CAAC;;IAErB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAEtC,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;MAC7C,QAAQ,CAAC;QACP,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC5D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;OACxC,CAAC,CAAC;KACJ;SAAM;MACL,IAAI,CAAC,aAAa,EAAE,CAAC;KACtB;GACF;EAED,iBAAiB;IACf,IAAI,CAAC,IAAI,CAAC,EAAE;MAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;GAC/B;EAED,oBAAoB;IAClB,IAAI,IAAI,CAAC,EAAE;MAAE,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;GACnC;EAED,MAAM;IACJ,QACE,EAAC,IAAI,QACH,eAAQ,EACP,CAAC,CAAC,IAAI,CAAC,gBAAgB;OACrB,IAAI,CAAC,WAAW,KAAK,IAAI,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,IAAI;MAC1D,CAAC,CAAC,IAAI,CAAC,WAAW,IAChB,YAAM,IAAI,EAAC,eAAe,GAAG,KAE7B,YAAM,IAAI,EAAC,iBAAiB,GAAG,CAChC;MACD,CAAC,CAAC,IAAI,CAAC,WAAW,IAChB,YAAM,IAAI,EAAC,eAAe,GAAG,KAE7B,YAAM,IAAI,EAAC,iBAAiB,GAAG,CAChC;KACF,CACE,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/resize-observe/resize-observe.tsx"],"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"],"version":3}
|
1
|
+
{"file":"resize-observe.js","mappings":";;;;;MAqCa,aAAa;;;;;;;;;IAGhB,YAAO,GAAG,KAAK,CAAC;IA8IhB,kBAAa,GAAG;MACtB,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,aAAa;QAAE,OAAO;MACtD,QAAQ,CAAC,MAAM,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,EAA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AAW,IAChB,YAAM,IAAI,EAAC,eAAe,GAAG,KAE7B,YAAM,IAAI,EAAC,iBAAiB,GAAG,CAChC;MACD,CAAC,CAAC,IAAI,CAAC,WAAW,IAChB,YAAM,IAAI,EAAC,eAAe,GAAG,KAE7B,YAAM,IAAI,EAAC,iBAAiB,GAAG,CAChC;KACF,CACE,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["./src/components/resize-observe/resize-observe.tsx"],"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"],"version":3}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/*!
|
2
|
+
* Web Components for Nanopore digital Web Apps
|
3
|
+
*/
|
4
|
+
/**
|
5
|
+
* Attempts to find the closest scrolling parental element
|
6
|
+
* @param element - the element from which to traverse up the DOM
|
7
|
+
* @returns - the closest scrolling parental element
|
8
|
+
*/
|
9
|
+
function findScrollParent(element) {
|
10
|
+
let style = getComputedStyle(element);
|
11
|
+
const excludeStaticParent = style.position === 'absolute';
|
12
|
+
const overflowRegex = /(auto|scroll)/;
|
13
|
+
if (style.position === 'fixed')
|
14
|
+
return document.documentElement;
|
15
|
+
for (let parent = element; (parent = parent.parentElement);) {
|
16
|
+
style = getComputedStyle(parent);
|
17
|
+
if (excludeStaticParent && style.position === 'static') {
|
18
|
+
continue;
|
19
|
+
}
|
20
|
+
if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) {
|
21
|
+
return parent;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
return document.documentElement;
|
25
|
+
}
|
26
|
+
|
27
|
+
export { findScrollParent as f };
|
28
|
+
|
29
|
+
//# sourceMappingURL=scroll-parent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"file":"scroll-parent.js","mappings":";;;AAAA;;;;;SAKgB,gBAAgB,CAAC,OAAoB;EACnD,IAAI,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;EACtC,MAAM,mBAAmB,GAAG,KAAK,CAAC,QAAQ,KAAK,UAAU,CAAC;EAC1D,MAAM,aAAa,GAAG,eAAe,CAAC;EAEtC,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO;IAAE,OAAO,QAAQ,CAAC,eAAe,CAAC;EAEhE,KAAK,IAAI,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,aAAa,IAAK;IAC5D,KAAK,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,mBAAmB,IAAI,KAAK,CAAC,QAAQ,KAAK,QAAQ,EAAE;MACtD,SAAS;KACV;IACD,IACE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,EACtE;MACA,OAAO,MAAM,CAAC;KACf;GACF;EACD,OAAO,QAAQ,CAAC,eAAe,CAAC;AAClC;;;;","names":[],"sources":["./src/utils/scroll-parent.ts"],"sourcesContent":["/**\n * Attempts to find the closest scrolling parental element\n * @param element - the element from which to traverse up the DOM\n * @returns - the closest scrolling parental element\n */\nexport function findScrollParent(element: HTMLElement) {\n let style = getComputedStyle(element);\n const excludeStaticParent = style.position === 'absolute';\n const overflowRegex = /(auto|scroll)/;\n\n if (style.position === 'fixed') return document.documentElement;\n\n for (let parent = element; (parent = parent.parentElement); ) {\n style = getComputedStyle(parent);\n if (excludeStaticParent && style.position === 'static') {\n continue;\n }\n if (\n overflowRegex.test(style.overflow + style.overflowY + style.overflowX)\n ) {\n return parent;\n }\n }\n return document.documentElement;\n}\n"],"version":3}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/*!
|
2
|
+
* Web Components for Nanopore digital Web Apps
|
3
|
+
*/
|
4
|
+
let searchInsights;
|
5
|
+
const searchInsight = {
|
6
|
+
/**
|
7
|
+
* Initialise algolia search insights.
|
8
|
+
* Will asynchronously import the search-insight library
|
9
|
+
* @param appId
|
10
|
+
* @param apiKey
|
11
|
+
*/
|
12
|
+
init: async (appId, apiKey) => {
|
13
|
+
if (searchInsights)
|
14
|
+
return;
|
15
|
+
searchInsights = (await import('./index-browser.cjs.js').then(function (n) { return n.i; })).default;
|
16
|
+
searchInsights('init', {
|
17
|
+
appId,
|
18
|
+
apiKey,
|
19
|
+
});
|
20
|
+
},
|
21
|
+
/**
|
22
|
+
* Sends a `clickedObjectIDsAfterSearch` event to algolia search-insights.
|
23
|
+
* `init(...)` Must have been called first.
|
24
|
+
* @param params
|
25
|
+
*/
|
26
|
+
sendClick: (params) => {
|
27
|
+
if (!searchInsights) {
|
28
|
+
console.error('You must call `init()` first');
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
searchInsights('clickedObjectIDsAfterSearch', { ...params });
|
32
|
+
},
|
33
|
+
/**
|
34
|
+
* Associates algolia analytics with a user id
|
35
|
+
* @param userToken
|
36
|
+
*/
|
37
|
+
setUser: (userToken) => {
|
38
|
+
if (!searchInsights) {
|
39
|
+
console.error('You must call `init()` first');
|
40
|
+
return;
|
41
|
+
}
|
42
|
+
searchInsights('setUserToken', userToken);
|
43
|
+
},
|
44
|
+
};
|
45
|
+
|
46
|
+
export { searchInsight as s };
|
47
|
+
|
48
|
+
//# sourceMappingURL=search-insights.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"file":"search-insights.js","mappings":";;;AAGA,IAAI,cAAqC,CAAC;MAEpC,aAAa,GAAG;;;;;;;EAOpB,IAAI,EAAE,OAAO,KAAa,EAAE,MAAc;IACxC,IAAI,cAAc;MAAE,OAAO;IAE3B,cAAc,GAAG,CAAC,MAAM,OAAO,wBAAiB,oCAAC,EAAE,OAAO,CAAC;IAC3D,cAAc,CAAC,MAAM,EAAE;MACrB,KAAK;MACL,MAAM;KACP,CAAC,CAAC;GACJ;;;;;;EAOD,SAAS,EAAE,CAAC,MAAgC;IAC1C,IAAI,CAAC,cAAc,EAAE;MACnB,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;MAC9C,OAAO;KACR;IACD,cAAc,CAAC,6BAA6B,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;GAC9D;;;;;EAMD,OAAO,EAAE,CAAC,SAAiB;IACzB,IAAI,CAAC,cAAc,EAAE;MACnB,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;MAC9C,OAAO;KACR;IACD,cAAc,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;GAC3C;;;;;","names":[],"sources":["./src/utils/search-insights.ts"],"sourcesContent":["import type SearchInsights from 'search-insights';\nimport type { InsightsSearchClickEvent } from 'search-insights/dist/click';\n\nlet searchInsights: typeof SearchInsights;\n\nconst searchInsight = {\n /**\n * Initialise algolia search insights.\n * Will asynchronously import the search-insight library\n * @param appId\n * @param apiKey\n */\n init: async (appId: string, apiKey: string) => {\n if (searchInsights) return;\n\n searchInsights = (await import('search-insights')).default;\n searchInsights('init', {\n appId,\n apiKey,\n });\n },\n\n /**\n * Sends a `clickedObjectIDsAfterSearch` event to algolia search-insights.\n * `init(...)` Must have been called first.\n * @param params\n */\n sendClick: (params: InsightsSearchClickEvent) => {\n if (!searchInsights) {\n console.error('You must call `init()` first');\n return;\n }\n searchInsights('clickedObjectIDsAfterSearch', { ...params });\n },\n\n /**\n * Associates algolia analytics with a user id\n * @param userToken\n */\n setUser: (userToken: string) => {\n if (!searchInsights) {\n console.error('You must call `init()` first');\n return;\n }\n searchInsights('setUserToken', userToken);\n },\n};\n\nexport default searchInsight;\n"],"version":3}
|